Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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.3.2"
".": "0.3.3"
}
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## [0.3.3](https://github.com/scalar/galaxy-node/compare/v0.3.2...v0.3.3) (2026-10-07)


### Chores

* **api:** regenerate SDK ([246e56b](https://github.com/scalar/galaxy-node/commit/246e56b91dcd34b5a823817de9c24ba140996431))
* **api:** regenerate SDK ([0fbedef](https://github.com/scalar/galaxy-node/commit/0fbedefbd566f34ec42acf62d5b564017bef7c04))
* **api:** update generated SDK content ([25e1b91](https://github.com/scalar/galaxy-node/commit/25e1b91dd668612c9123dc10a88fcb9f97472a7f))

## [0.3.2](https://github.com/scalar/galaxy-node/compare/v0.3.1...v0.3.2) (2026-09-15)


Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ Pass credentials to the generated client constructor. Environment variables are

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `bearerAuth` | `string \| provider` | - | JWT Bearer token authentication Defaults to BEARER_AUTH. |
| `basicAuthUsername` | `string \| provider` | - | Basic HTTP authentication Defaults to BASIC_AUTH_USERNAME. |
| `basicAuthPassword` | `string \| provider` | - | Basic HTTP authentication Defaults to BASIC_AUTH_PASSWORD. |
| `apiKeyHeader` | `string \| provider` | - | API key request header Defaults to API_KEY_HEADER. |
| `apiKeyQuery` | `string \| provider` | - | API key query parameter Defaults to API_KEY_QUERY. |
| `apiKeyCookie` | `string \| provider` | - | API key browser cookie Defaults to API_KEY_COOKIE. |
| `oAuth2` | `string \| provider` | - | OAuth 2.0 authentication Defaults to SCALAR_O_AUTH2. |
| `openIDConnect` | `string \| provider` | - | OpenID Connect Authentication Defaults to SCALAR_OPEN_ID_CONNECT. |
| `bearerAuth` | `string \| AuthTokenProvider` | - | JWT Bearer token authentication Defaults to BEARER_AUTH. |
| `basicAuthUsername` | `string \| AuthTokenProvider` | - | Basic HTTP authentication Defaults to BASIC_AUTH_USERNAME. |
| `basicAuthPassword` | `string \| AuthTokenProvider` | - | Basic HTTP authentication Defaults to BASIC_AUTH_PASSWORD. |
| `apiKeyHeader` | `string \| AuthTokenProvider` | - | API key request header Defaults to API_KEY_HEADER. |
| `apiKeyQuery` | `string \| AuthTokenProvider` | - | API key query parameter Defaults to API_KEY_QUERY. |
| `apiKeyCookie` | `string \| AuthTokenProvider` | - | API key browser cookie Defaults to API_KEY_COOKIE. |
| `oAuth2` | `string \| AuthTokenProvider` | - | OAuth 2.0 authentication Defaults to SCALAR_O_AUTH2. |
| `openIDConnect` | `string \| AuthTokenProvider` | - | OpenID Connect Authentication Defaults to SCALAR_OPEN_ID_CONNECT. |

Declared schemes:

Expand Down
14 changes: 14 additions & 0 deletions VERSIONING.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ different fixes:
platform and the `github-actions` bot to push (or be left unprotected); the default
branch only ever advances by merging release PRs, and `scalar-next` receives each
released state back from the release workflow.
- **`scalar-next` must not enable "Require linear history."** The Scalar platform merges each
regeneration into it, and merges a resolved conflict back the same way; the release sync
adds another merge whenever a release PR is squash- or rebase-merged. That setting rejects
all of them.
- No Actions settings changes are required: the generated workflows declare their own
permissions and never create pull requests.
- If this package publishes through OIDC trusted publishing (for example PyPI or npm),
Expand All @@ -84,3 +88,13 @@ different fixes:
manual re-publishes at an existing tag; register it as an additional trusted publisher
only if you use it. If the publish job is configured with a deployment environment,
include that environment in the registration too.

### Recommended, not required

Releases work without this; it closes a window where one can go out at the wrong version.

- **If this repository uses auto-merge, make the `Release PR version` check a required status
check.** Auto-merge merges as soon as the checks that are *required* go green, with no
human present — so a check that is not required but still red at that moment stops
nothing, which is exactly the window between retitling a release PR and the platform
re-rendering it.
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/2.5.7/schema.json",
"$schema": "https://biomejs.dev/schemas/2.5.14/schema.json",
"root": true,
"files": {
"includes": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@scalar/galaxy-node",
"version": "0.3.2",
"version": "0.3.3",
"description": "The Scalar Galaxy is an example OpenAPI document to test OpenAPI tools and libraries. It's a fictional universe with fictional planets and fictional data.",
"author": "Scalar Galaxy",
"repository": {
Expand Down
6 changes: 1 addition & 5 deletions scalar-sdk.manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ScalarGalaxy",
"slug": "scalarGalaxy",
"generatorVersion": "0.32.14",
"generatorVersion": "0.36.3",
"servers": [
"https://galaxy.scalar.com",
"{protocol}://void.scalar.com/{path}"
Expand Down Expand Up @@ -58,7 +58,6 @@
"kind": "authorizationCode",
"authorizationUrl": "https://galaxy.scalar.com/oauth/authorize",
"tokenUrl": "https://galaxy.scalar.com/oauth/token",
"refreshUrl": "",
"scopes": [
"read:account",
"write:planets",
Expand All @@ -68,7 +67,6 @@
{
"kind": "clientCredentials",
"tokenUrl": "https://galaxy.scalar.com/oauth/token",
"refreshUrl": "",
"scopes": [
"read:account",
"write:planets",
Expand All @@ -78,7 +76,6 @@
{
"kind": "password",
"tokenUrl": "https://galaxy.scalar.com/oauth/token",
"refreshUrl": "",
"scopes": [
"read:account",
"write:planets",
Expand All @@ -88,7 +85,6 @@
{
"kind": "implicit",
"authorizationUrl": "https://galaxy.scalar.com/oauth/authorize",
"refreshUrl": "",
"scopes": [
"read:account",
"write:planets",
Expand Down
69 changes: 21 additions & 48 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
formatRequestDetails,
loggerFor,
parseLogLevel,
redactUrl,
type LogLevel,
type Logger,
} from './internal/utils/log';
Expand Down Expand Up @@ -190,12 +191,12 @@ export type GalaxyOptions = ClientOptions;
* API Client for interfacing with the ScalarGalaxy API.
*/
export class Galaxy {
bearerAuth: string | AuthTokenProvider;
basicAuthUsername: string | AuthTokenProvider;
basicAuthPassword: string | AuthTokenProvider;
apiKeyHeader: string | AuthTokenProvider;
apiKeyQuery: string | AuthTokenProvider;
apiKeyCookie: string | AuthTokenProvider;
bearerAuth: string | AuthTokenProvider | undefined;
basicAuthUsername: string | AuthTokenProvider | undefined;
basicAuthPassword: string | AuthTokenProvider | undefined;
apiKeyHeader: string | AuthTokenProvider | undefined;
apiKeyQuery: string | AuthTokenProvider | undefined;
apiKeyCookie: string | AuthTokenProvider | undefined;
oAuth2: string | AuthTokenProvider | undefined;
openIDConnect: string | AuthTokenProvider | undefined;
webhookSecret: string | null;
Expand Down Expand Up @@ -247,37 +248,6 @@ export class Galaxy {
webhookSecret = readEnv('SCALAR_WEBHOOK_SECRET') ?? null,
...opts
}: ClientOptions = {}) {
if (bearerAuth === undefined) {
throw new Errors.GalaxyError(
"The BEARER_AUTH environment variable is missing or empty; either provide it, or instantiate the Galaxy client with an bearerAuth option, like new Galaxy({ bearerAuth: 'My Bearer Auth' }).",
);
}
if (basicAuthUsername === undefined) {
throw new Errors.GalaxyError(
"The BASIC_AUTH_USERNAME environment variable is missing or empty; either provide it, or instantiate the Galaxy client with an basicAuthUsername option, like new Galaxy({ basicAuthUsername: 'My Basic Auth Username' }).",
);
}
if (basicAuthPassword === undefined) {
throw new Errors.GalaxyError(
"The BASIC_AUTH_PASSWORD environment variable is missing or empty; either provide it, or instantiate the Galaxy client with an basicAuthPassword option, like new Galaxy({ basicAuthPassword: 'My Basic Auth Password' }).",
);
}
if (apiKeyHeader === undefined) {
throw new Errors.GalaxyError(
"The API_KEY_HEADER environment variable is missing or empty; either provide it, or instantiate the Galaxy client with an apiKeyHeader option, like new Galaxy({ apiKeyHeader: 'My API Key Header' }).",
);
}
if (apiKeyQuery === undefined) {
throw new Errors.GalaxyError(
"The API_KEY_QUERY environment variable is missing or empty; either provide it, or instantiate the Galaxy client with an apiKeyQuery option, like new Galaxy({ apiKeyQuery: 'My API Key Query' }).",
);
}
if (apiKeyCookie === undefined) {
throw new Errors.GalaxyError(
"The API_KEY_COOKIE environment variable is missing or empty; either provide it, or instantiate the Galaxy client with an apiKeyCookie option, like new Galaxy({ apiKeyCookie: 'My API Key Cookie' }).",
);
}

const options: ClientOptions = {
bearerAuth,
basicAuthUsername,
Expand Down Expand Up @@ -391,7 +361,7 @@ export class Galaxy {
}

private getUserAgent(): string {
return `${this.constructor.name}/JS ${VERSION}`;
return `Galaxy/JS ${VERSION}`;
}

protected defaultIdempotencyKey(): string {
Expand Down Expand Up @@ -577,7 +547,7 @@ export class Galaxy {
throw new Errors.APIConnectionError({ cause: response });
}

const responseInfo = `[${requestLogID}${retryLogStr}] ${req.method} ${url} ${
const responseInfo = `[${requestLogID}${retryLogStr}] ${req.method} ${redactUrl(url)} ${
response.ok ? 'succeeded' : 'failed'
} with status ${response.status} in ${headersTime - startTime}ms`;

Expand Down Expand Up @@ -654,7 +624,8 @@ export class Galaxy {
): Promise<Response> {
const { signal, method, ...options } = init || {};
const abort = this._makeAbort(controller);
if (signal) signal.addEventListener('abort', abort, { once: true });
if (signal?.aborted) abort();
else if (signal) signal.addEventListener('abort', abort, { once: true });

const timeout = setTimeout(abort, ms);

Expand All @@ -675,7 +646,7 @@ export class Galaxy {
}

try {
// use undefined this binding; fetch errors if bound to something else in browser/cloudflare
// use undefined this binding; fetch errors if bound to something else in browsers and edge runtimes / workers
return await this.fetch.call(undefined, url, fetchOptions);
} finally {
clearTimeout(timeout);
Expand Down Expand Up @@ -866,18 +837,20 @@ export class Galaxy {
if (body == null) {
return { bodyHeaders: undefined, body: undefined };
}
const headers = buildHeaders([rawHeaders]);
// A `content-type` from either header bag says how the body is already encoded; the request's
// own wins over the client-wide default, as it does on the wire.
const headers = buildHeaders([this._options.defaultHeaders, rawHeaders]);
if (
// Pass raw type verbatim
ArrayBuffer.isView(body) ||
body instanceof ArrayBuffer ||
body instanceof DataView ||
// Always pass strings through verbatim. The previous guard required a caller-set
// `content-type` and otherwise fell through to `FallbackEncoder`, which JSON.stringifies
// the value and labels it `application/json` — silently quoting plain-text payloads and
// mislabeling them as JSON. fetch defaults a string body to `text/plain;charset=UTF-8`
// when no `content-type` is set, which is a safer default than misclaiming JSON.
typeof body === 'string' ||
// A string is only already-encoded when something has said what it is encoded as.
// Generated call sites state the declared request media type, so a `text/plain` or
// ndjson payload reaches the wire byte-for-byte. A string with no `content-type` came
// from a body the document declared as JSON — `{ "type": "string" }` — and encoding it
// below is what puts the quotes the server parses for around it.
(typeof body === 'string' && headers.values.has('content-type')) ||
// `Blob` is superset of `File`
((globalThis as any).Blob && body instanceof (globalThis as any).Blob) ||
// `FormData` -> `multipart/form-data`
Expand Down
2 changes: 1 addition & 1 deletion src/internal/detect-platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const getPlatformProperties = (): PlatformProperties => {
};
}

// TODO add support for Cloudflare workers, etc.
// TODO add support for worker runtimes that expose no EdgeRuntime global, etc.
return {
'X-Scalar-Lang': 'js',
'X-Scalar-Package-Version': VERSION,
Expand Down
Loading
Loading