Skip to content

release: 0.1.0-alpha.3 #14

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

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 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
27ce482
feat: add SKIP_BREW env var to ./scripts/bootstrap (#33)
stainless-app[bot] Mar 11, 2025
4d8f4ce
feat(client): accept RFC6838 JSON content types (#34)
stainless-app[bot] Mar 11, 2025
69a769b
chore(internal): remove extra empty newlines (#35)
stainless-app[bot] Mar 14, 2025
9861197
fix(internal): add mts file + crypto shim types (#36)
stainless-app[bot] Mar 15, 2025
9a5740b
chore(internal): minor client file refactoring (#37)
stainless-app[bot] Mar 19, 2025
989d3b5
chore(exports): cleaner resource index imports (#38)
stainless-app[bot] Mar 20, 2025
353feba
chore(exports): stop using path fallbacks (#39)
stainless-app[bot] Mar 20, 2025
e7ada47
codegen metadata
stainless-app[bot] Mar 27, 2025
7c40d45
chore(client): move misc public files to new `core/` directory, depre…
stainless-app[bot] Mar 27, 2025
a050b32
fix(client): send `X-Stainless-Timeout` in seconds (#41)
stainless-app[bot] Apr 3, 2025
2e1bebb
chore(internal): add aliases for Record and Array (#42)
stainless-app[bot] Apr 3, 2025
a39fa23
fix(api): improve type resolution when importing as a package (#43)
stainless-app[bot] Apr 4, 2025
c246dec
fix(mcp): remove unused tools.ts (#44)
stainless-app[bot] Apr 5, 2025
7b614cf
release: 0.1.0-alpha.3
stainless-app[bot] Apr 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.

1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,3 @@ jobs:

- name: Run tests
run: ./scripts/test

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"
}
2 changes: 2 additions & 0 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
configured_endpoints: 7
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lightswitch%2Flightswitch-6dc2430da32f769677553172dba258ce0d23e8a260f803a5667d344159e8f57a.yml
openapi_spec_hash: 70e4b7e54c5499041938279aaacf8c96
config_hash: dd75502347a96f8c58e49c159b0b5917
49 changes: 49 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,54 @@
# Changelog

## 0.1.0-alpha.3 (2025-04-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

* add SKIP_BREW env var to ./scripts/bootstrap ([#33](https://github.com/GitbookIO/lightswitch/issues/33)) ([27ce482](https://github.com/GitbookIO/lightswitch/commit/27ce4828b4ab6bf58197529421dd8416345fb8e1))
* **client:** accept RFC6838 JSON content types ([#34](https://github.com/GitbookIO/lightswitch/issues/34)) ([4d8f4ce](https://github.com/GitbookIO/lightswitch/commit/4d8f4ce388c51a2da29eb00f511fa4a99c96d71d))
* **client:** improve logging ([#20](https://github.com/GitbookIO/lightswitch/issues/20)) ([4818115](https://github.com/GitbookIO/lightswitch/commit/4818115c707adaa7ef4afab2913e4082a263b4c3))


### Bug Fixes

* **api:** improve type resolution when importing as a package ([#43](https://github.com/GitbookIO/lightswitch/issues/43)) ([a39fa23](https://github.com/GitbookIO/lightswitch/commit/a39fa232e01c19caeb939670672de770c87a072e))
* **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))
* **client:** send `X-Stainless-Timeout` in seconds ([#41](https://github.com/GitbookIO/lightswitch/issues/41)) ([a050b32](https://github.com/GitbookIO/lightswitch/commit/a050b3221fe97dcade80d049133dc2c0be8ee2af))
* **internal:** add mts file + crypto shim types ([#36](https://github.com/GitbookIO/lightswitch/issues/36)) ([9861197](https://github.com/GitbookIO/lightswitch/commit/98611971e42774294141e3ba8febda9da5f521b3))
* **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))
* **mcp:** remove unused tools.ts ([#44](https://github.com/GitbookIO/lightswitch/issues/44)) ([c246dec](https://github.com/GitbookIO/lightswitch/commit/c246decfe0432ff0d3d985049021826252c8d83d))
* **tests:** manually reset node:buffer File ([#30](https://github.com/GitbookIO/lightswitch/issues/30)) ([8211340](https://github.com/GitbookIO/lightswitch/commit/82113405c05cefebce29191e8b810c287c763a82))


### Chores

* **client:** move misc public files to new `core/` directory, deprecate old paths ([#40](https://github.com/GitbookIO/lightswitch/issues/40)) ([7c40d45](https://github.com/GitbookIO/lightswitch/commit/7c40d456f686691f992f70fe6722b4d4e17d3e67))
* **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))
* **exports:** cleaner resource index imports ([#38](https://github.com/GitbookIO/lightswitch/issues/38)) ([989d3b5](https://github.com/GitbookIO/lightswitch/commit/989d3b5284553723c34188c229f2a5cfbfcc3bcd))
* **exports:** stop using path fallbacks ([#39](https://github.com/GitbookIO/lightswitch/issues/39)) ([353feba](https://github.com/GitbookIO/lightswitch/commit/353feba64115b93299b08d84c50319e140b48f73))
* **internal:** add aliases for Record and Array ([#42](https://github.com/GitbookIO/lightswitch/issues/42)) ([2e1bebb](https://github.com/GitbookIO/lightswitch/commit/2e1bebbe297c4f43f8b565d704dc41eb0db32964))
* **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:** minor client file refactoring ([#37](https://github.com/GitbookIO/lightswitch/issues/37)) ([9a5740b](https://github.com/GitbookIO/lightswitch/commit/9a5740b951f4977df46d0386d9b52c7d21a0d57b))
* **internal:** remove extra empty newlines ([#35](https://github.com/GitbookIO/lightswitch/issues/35)) ([69a769b](https://github.com/GitbookIO/lightswitch/commit/69a769b12e98f13e45adbe9e5a8cf33023de15e4))
* **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)
Expand Down
80 changes: 57 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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.)
Expand Down
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
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 <[email protected]>",
"types": "dist/index.d.ts",
Expand Down Expand Up @@ -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",
Expand All @@ -45,6 +46,9 @@
"tsconfig-paths": "^4.0.0",
"typescript": "^4.8.2"
},
"resolutions": {
"synckit": "0.8.8"
},
"imports": {
"lightswitch-api": ".",
"lightswitch-api/*": "./src/*"
Expand Down
2 changes: 1 addition & 1 deletion scripts/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

cd "$(dirname "$0")/.."

if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then
if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ]; then
brew bundle check >/dev/null 2>&1 || {
echo "==> Installing Homebrew dependencies…"
brew bundle
Expand Down
13 changes: 4 additions & 9 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,15 @@ node scripts/utils/make-dist-package-json.cjs > dist/package.json

# build to .js/.mjs/.d.ts files
npm exec tsc-multi
# we need to add exports = module.exports = Lightswitch to index.js;
# No way to get that from index.ts because it would cause compile errors
# we need to patch index.js so that `new module.exports()` works for cjs backwards
# compat. No way to get that from index.ts because it would cause compile errors
# when building .mjs
node scripts/utils/fix-index-exports.cjs
# with "moduleResolution": "nodenext", if ESM resolves to index.d.ts,
# it'll have TS errors on the default import. But if it resolves to
# index.d.mts the default import will work (even though both files have
# the same export default statement)
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,d.mts} dist/internal/shims

node scripts/utils/postprocess-files.cjs

Expand Down
Loading