Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 0.1.0-alpha.3 #14

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
676a868
chore(internal): remove unused method (#13)
stainless-app[bot] Feb 13, 2025
a0b504c
chore(internal): codegen related update (#16)
stainless-app[bot] Feb 13, 2025
c41e942
chore(internal): update eslint config (#17)
stainless-app[bot] Feb 14, 2025
7d38d98
fix(client): fix export map for index exports, accept BunFile (#18)
stainless-app[bot] Feb 14, 2025
7f7be64
chore(internal): fix tests not always being type checked (#19)
stainless-app[bot] Feb 18, 2025
4818115
feat(client): improve logging (#20)
stainless-app[bot] Feb 22, 2025
bdccc24
chore(internal): fix devcontainers setup (#21)
stainless-app[bot] Feb 22, 2025
50b5b64
fix(internal): return in castToError instead of throwing (#22)
stainless-app[bot] Feb 22, 2025
43587fa
chore(internal): remove unnecessary todo (#23)
stainless-app[bot] Feb 22, 2025
8e0ab12
docs: update URLs from stainlessapi.com to stainless.com (#24)
stainless-app[bot] Feb 28, 2025
c5e8df8
chore(client): only accept standard types for file uploads (#25)
stainless-app[bot] Mar 4, 2025
ca13c87
chore(internal): fix tests failing on node v18 (#26)
stainless-app[bot] Mar 4, 2025
c5d034a
chore(internal): constrain synckit dev dependency (#27)
stainless-app[bot] Mar 4, 2025
2bc2cb6
fix(client): fix TypeError with undefined File (#28)
stainless-app[bot] Mar 4, 2025
313a6f7
fix(internal): clean up undefined File test (#29)
stainless-app[bot] Mar 4, 2025
8211340
fix(tests): manually reset node:buffer File (#30)
stainless-app[bot] Mar 4, 2025
4d59d92
chore(types): improved go to definition on fetchOptions (#31)
stainless-app[bot] Mar 5, 2025
71c7c33
chore(docs): improve docs for withResponse/asResponse (#32)
stainless-app[bot] Mar 5, 2025
a47189e
release: 0.1.0-alpha.3
stainless-app[bot] Mar 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .devcontainer/Dockerfile

This file was deleted.

27 changes: 12 additions & 15 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/debian
{
"name": "Debian",
"build": {
"dockerfile": "Dockerfile"
"name": "Development",
"image": "mcr.microsoft.com/devcontainers/typescript-node:latest",
"features": {
"ghcr.io/devcontainers/features/node:1": {}
},
"postCreateCommand": "yarn install",
"customizations": {
"vscode": {
"extensions": [
"esbenp.prettier-vscode"
]
}
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
29 changes: 0 additions & 29 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.2"
".": "0.1.0-alpha.3"
}
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,42 @@
# Changelog

## 0.1.0-alpha.3 (2025-03-05)

Full Changelog: [v0.1.0-alpha.2...v0.1.0-alpha.3](https://github.com/GitbookIO/lightswitch/compare/v0.1.0-alpha.2...v0.1.0-alpha.3)

### Features

* **client:** improve logging ([#20](https://github.com/GitbookIO/lightswitch/issues/20)) ([4818115](https://github.com/GitbookIO/lightswitch/commit/4818115c707adaa7ef4afab2913e4082a263b4c3))


### Bug Fixes

* **client:** fix export map for index exports, accept BunFile ([#18](https://github.com/GitbookIO/lightswitch/issues/18)) ([7d38d98](https://github.com/GitbookIO/lightswitch/commit/7d38d985253dcd56cf4f017f00af40d3ecdb843d))
* **client:** fix TypeError with undefined File ([#28](https://github.com/GitbookIO/lightswitch/issues/28)) ([2bc2cb6](https://github.com/GitbookIO/lightswitch/commit/2bc2cb6443f8039fc4fd642261a8b861c0aeb5d6))
* **internal:** clean up undefined File test ([#29](https://github.com/GitbookIO/lightswitch/issues/29)) ([313a6f7](https://github.com/GitbookIO/lightswitch/commit/313a6f7ddc4207aba3979d500d35c0ff4ece7169))
* **internal:** return in castToError instead of throwing ([#22](https://github.com/GitbookIO/lightswitch/issues/22)) ([50b5b64](https://github.com/GitbookIO/lightswitch/commit/50b5b64351ff6a4de6210d161a9889a72becf680))
* **tests:** manually reset node:buffer File ([#30](https://github.com/GitbookIO/lightswitch/issues/30)) ([8211340](https://github.com/GitbookIO/lightswitch/commit/82113405c05cefebce29191e8b810c287c763a82))


### Chores

* **client:** only accept standard types for file uploads ([#25](https://github.com/GitbookIO/lightswitch/issues/25)) ([c5e8df8](https://github.com/GitbookIO/lightswitch/commit/c5e8df8ef19ba385e5e286daa12a2260c9730872))
* **docs:** improve docs for withResponse/asResponse ([#32](https://github.com/GitbookIO/lightswitch/issues/32)) ([71c7c33](https://github.com/GitbookIO/lightswitch/commit/71c7c3331af782b307b21dd18070992ce90b9bda))
* **internal:** codegen related update ([#16](https://github.com/GitbookIO/lightswitch/issues/16)) ([a0b504c](https://github.com/GitbookIO/lightswitch/commit/a0b504c5bf3acdd499eb67b2d9451aa9b201c332))
* **internal:** constrain synckit dev dependency ([#27](https://github.com/GitbookIO/lightswitch/issues/27)) ([c5d034a](https://github.com/GitbookIO/lightswitch/commit/c5d034ad65a1715e4dd81e2023ce88fe4f2aa4f1))
* **internal:** fix devcontainers setup ([#21](https://github.com/GitbookIO/lightswitch/issues/21)) ([bdccc24](https://github.com/GitbookIO/lightswitch/commit/bdccc2455f2e87cd3780873616fa8632b7232d38))
* **internal:** fix tests failing on node v18 ([#26](https://github.com/GitbookIO/lightswitch/issues/26)) ([ca13c87](https://github.com/GitbookIO/lightswitch/commit/ca13c873f7f6377df94f27a6be5b984fee98d38b))
* **internal:** fix tests not always being type checked ([#19](https://github.com/GitbookIO/lightswitch/issues/19)) ([7f7be64](https://github.com/GitbookIO/lightswitch/commit/7f7be648402d60169dc2ddf3f8c9aabe14f6f5ca))
* **internal:** remove unnecessary todo ([#23](https://github.com/GitbookIO/lightswitch/issues/23)) ([43587fa](https://github.com/GitbookIO/lightswitch/commit/43587fa0494a0fb6834c2273e2cc138f03c07eb0))
* **internal:** remove unused method ([#13](https://github.com/GitbookIO/lightswitch/issues/13)) ([676a868](https://github.com/GitbookIO/lightswitch/commit/676a868abeeccf928a50e1b7d850f2892857e298))
* **internal:** update eslint config ([#17](https://github.com/GitbookIO/lightswitch/issues/17)) ([c41e942](https://github.com/GitbookIO/lightswitch/commit/c41e942a9ee9400fba7b22dde2d2e2fc50eec6cb))
* **types:** improved go to definition on fetchOptions ([#31](https://github.com/GitbookIO/lightswitch/issues/31)) ([4d59d92](https://github.com/GitbookIO/lightswitch/commit/4d59d92b7c7fa7999bab233282c0da9c98396870))


### Documentation

* update URLs from stainlessapi.com to stainless.com ([#24](https://github.com/GitbookIO/lightswitch/issues/24)) ([8e0ab12](https://github.com/GitbookIO/lightswitch/commit/8e0ab1247afb8e9c44340ff9b3f507d5793a8a87))

## 0.1.0-alpha.2 (2025-02-06)

Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/GitbookIO/lightswitch/compare/v0.1.0-alpha.1...v0.1.0-alpha.2)
80 changes: 57 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ This library provides convenient access to the Lightswitch REST API from server-

The REST API documentation can be found on [docs.lightswitch.com](https://docs.lightswitch.com). The full API of this library can be found in [api.md](api.md).

It is generated with [Stainless](https://www.stainlessapi.com/).
It is generated with [Stainless](https://www.stainless.com/).

## Installation

@@ -133,8 +133,10 @@ Note that requests which time out will be [retried twice by default](#retries).
### Accessing raw Response data (e.g., headers)

The "raw" `Response` returned by `fetch()` can be accessed through the `.asResponse()` method on the `APIPromise` type that all methods return.
This method returns as soon as the headers for a successful response are received and does not consume the response body, so you are free to write custom parsing or streaming logic.

You can also use the `.withResponse()` method to get the raw `Response` along with the parsed data.
Unlike `.asResponse()` this method consumes the body, returning once it is parsed.

<!-- prettier-ignore -->
```ts
@@ -149,6 +151,59 @@ console.log(raw.headers.get('X-My-Header'));
console.log(projects);
```

### Logging

> [!IMPORTANT]
> All log messages are intended for debugging only. The format and content of log messages
> may change between releases.

#### Log levels

The log level can be configured in two ways:

1. Via the `LIGHTSWITCH_LOG` environment variable
2. Using the `logLevel` client option (overrides the environment variable if set)

```ts
import Lightswitch from 'lightswitch-api';

const client = new Lightswitch({
logLevel: 'debug', // Show all log messages
});
```

Available log levels, from most to least verbose:

- `'debug'` - Show debug messages, info, warnings, and errors
- `'info'` - Show info messages, warnings, and errors
- `'warn'` - Show warnings and errors (default)
- `'error'` - Show only errors
- `'off'` - Disable all logging

At the `'debug'` level, all HTTP requests and responses are logged, including headers and bodies.
Some authentication-related headers are redacted, but sensitive data in request and response bodies
may still be visible.

#### Custom logger

By default, this library logs to `globalThis.console`. You can also provide a custom logger.
Most logging libraries are supported, including [pino](https://www.npmjs.com/package/pino), [winston](https://www.npmjs.com/package/winston), [bunyan](https://www.npmjs.com/package/bunyan), [consola](https://www.npmjs.com/package/consola), [signale](https://www.npmjs.com/package/signale), and [@std/log](https://jsr.io/@std/log). If your logger doesn't work, please open an issue.

When providing a custom logger, the `logLevel` option still controls which messages are emitted, messages
below the configured level will not be sent to your logger.

```ts
import Lightswitch from 'lightswitch-api';
import pino from 'pino';

const logger = pino();

const client = new Lightswitch({
logger: logger.child({ name: 'Lightswitch' }),
logLevel: 'debug', // Send all messages to pino, allowing it to filter
});
```

### Making custom/undocumented requests

This library is typed for convenient access to the documented API. If you need to access undocumented
@@ -208,33 +263,12 @@ globalThis.fetch = fetch;
Or pass it to the client:

```ts
import Lightswitch from 'lightswitch-api';
import fetch from 'my-fetch';

const client = new Lightswitch({ fetch });
```

### Logging and middleware

You may also provide a custom `fetch` function when instantiating the client,
which can be used to inspect or alter the `Request` or `Response` before/after each request:

```ts
import { fetch } from 'undici'; // as one example
import Lightswitch from 'lightswitch-api';

const client = new Lightswitch({
fetch: async (url: RequestInfo, init?: RequestInit): Promise<Response> => {
console.log('About to make a request', url, init);
const response = await fetch(url, init);
console.log('Got response', response);
return response;
},
});
```

Note that if given a `LIGHTSWITCH_LOG=debug` environment variable, this library will log all requests and responses automatically.
This is intended for debugging purposes only and may change in the future without notice.

### Fetch options

If you want to set custom `fetch` options without overriding the `fetch` function, you can provide a `fetchOptions` object when instantiating the client or making a request. (Request-specific options override client options.)
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@

## Reporting Security Issues

This SDK is generated by [Stainless Software Inc](http://stainlessapi.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken.
This SDK is generated by [Stainless Software Inc](http://stainless.com). Stainless takes security seriously, and encourages you to report any security vulnerability promptly so that appropriate action can be taken.

To report a security issue, please contact the Stainless team at security@stainlessapi.com.
To report a security issue, please contact the Stainless team at security@stainless.com.

## Responsible Disclosure

42 changes: 42 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// @ts-check
import tseslint from 'typescript-eslint';
import unusedImports from 'eslint-plugin-unused-imports';
import prettier from 'eslint-plugin-prettier';

export default tseslint.config(
{
languageOptions: {
parser: tseslint.parser,
parserOptions: { sourceType: 'module' },
},
files: ['**/*.ts', '**/*.mts', '**/*.cts', '**/*.js', '**/*.mjs', '**/*.cjs'],
ignores: ['dist/**'],
plugins: {
'@typescript-eslint': tseslint.plugin,
'unused-imports': unusedImports,
prettier,
},
rules: {
'no-unused-vars': 'off',
'prettier/prettier': 'error',
'unused-imports/no-unused-imports': 'error',
'no-restricted-imports': [
'error',
{
patterns: [
{
regex: '^lightswitch-api(/.*)?',
message: 'Use a relative import, not a package import.',
},
],
},
],
},
},
{
files: ['tests/**', 'examples/**'],
rules: {
'no-restricted-imports': 'off',
},
},
);
16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lightswitch-api",
"version": "0.1.0-alpha.2",
"version": "0.1.0-alpha.3",
"description": "The official TypeScript library for the Lightswitch API",
"author": "Lightswitch <dev-feedback@lightswitch.com>",
"types": "dist/index.d.ts",
@@ -30,11 +30,12 @@
"@swc/jest": "^0.2.29",
"@types/jest": "^29.4.0",
"@types/node": "^20.17.6",
"@typescript-eslint/eslint-plugin": "^6.7.0",
"@typescript-eslint/parser": "^6.0.0",
"eslint": "^8.49.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-unused-imports": "^3.0.0",
"typescript-eslint": "^8.24.0",
"@typescript-eslint/eslint-plugin": "^8.24.0",
"@typescript-eslint/parser": "^8.24.0",
"eslint": "^9.20.1",
"eslint-plugin-prettier": "^5.2.3",
"eslint-plugin-unused-imports": "^4.1.4",
"iconv-lite": "^0.6.3",
"jest": "^29.4.0",
"prettier": "^3.0.0",
@@ -45,6 +46,9 @@
"tsconfig-paths": "^4.0.0",
"typescript": "^4.8.2"
},
"resolutions": {
"synckit": "0.8.8"
},
"imports": {
"lightswitch-api": ".",
"lightswitch-api/*": "./src/*"
4 changes: 2 additions & 2 deletions scripts/build
Original file line number Diff line number Diff line change
@@ -40,8 +40,8 @@ cp dist/index.d.ts dist/index.d.mts
cp tsconfig.dist-src.json dist/src/tsconfig.json
cp src/internal/shim-types.d.ts dist/internal/shim-types.d.ts
cp src/internal/shim-types.d.ts dist/internal/shim-types.d.mts
mkdir -p dist/internal/polyfill
cp src/internal/polyfill/*.{mjs,js,d.ts} dist/internal/polyfill
mkdir -p dist/internal/shims
cp src/internal/shims/*.{mjs,js,d.ts} dist/internal/shims

node scripts/utils/postprocess-files.cjs

2 changes: 1 addition & 1 deletion scripts/format
Original file line number Diff line number Diff line change
@@ -5,4 +5,4 @@ set -e
cd "$(dirname "$0")/.."

echo "==> Running eslint --fix"
ESLINT_USE_FLAT_CONFIG="false" ./node_modules/.bin/eslint --fix --ext ts,js .
./node_modules/.bin/eslint --fix .
7 changes: 5 additions & 2 deletions scripts/lint
Original file line number Diff line number Diff line change
@@ -5,10 +5,13 @@ set -e
cd "$(dirname "$0")/.."

echo "==> Running eslint"
ESLINT_USE_FLAT_CONFIG="false" ./node_modules/.bin/eslint --ext ts,js .
./node_modules/.bin/eslint .

echo "==> Building"
./scripts/build # also checks types
./scripts/build

echo "==> Checking types"
./node_modules/typescript/bin/tsc

echo "==> Running Are The Types Wrong?"
./node_modules/.bin/attw --pack dist -f json >.attw.json || true
8 changes: 4 additions & 4 deletions scripts/utils/postprocess-files.cjs
Original file line number Diff line number Diff line change
@@ -50,14 +50,14 @@ async function postprocess() {
if (entry.isDirectory() && entry.name !== 'src' && entry.name !== 'internal' && entry.name !== 'bin') {
const subpath = './' + entry.name;
newExports[subpath + '/*.mjs'] = {
default: subpath + '/*.mjs',
default: [subpath + '/*.mjs', subpath + '/*/index.mjs'],
};
newExports[subpath + '/*.js'] = {
default: subpath + '/*.js',
default: [subpath + '/*.js', subpath + '/*/index.js'],
};
newExports[subpath + '/*'] = {
import: subpath + '/*.mjs',
require: subpath + '/*.js',
import: [subpath + '/*.mjs', subpath + '/*/index.mjs'],
require: [subpath + '/*.js', subpath + '/*/index.js'],
};
} else if (entry.isFile() && /\.[cm]?js$/.test(entry.name)) {
const { name, ext } = path.parse(entry.name);
Loading
Oops, something went wrong.