@redocly/client-generator 0.0.0-snapshot.1785152186 → 0.0.0-snapshot.1785166289

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -53,37 +53,57 @@ With `runtime: 'package'` the generated client also imports its whole engine fro
53
53
 
54
54
  ### Write a custom generator
55
55
 
56
- A custom generator reads the same spec-derived model the built-ins consume, runs in the same pass, and returns files:
56
+ A custom generator reads the same spec-derived model the built-ins consume, runs in the same pass, and returns files.
57
+ Build real TypeScript with the emit toolkit from `@redocly/client-generator/generate` — the same `ts.factory` + printer the built-in generators use, so the schema→type mapping matches the sdk's exactly:
57
58
 
58
59
  ```ts
59
- // route-map-generator.ts
60
+ // response-map-generator.ts
60
61
  import { defineGenerator } from '@redocly/client-generator';
62
+ import { printStatements, schemaToTypeNode, ts } from '@redocly/client-generator/generate';
63
+
64
+ const { factory } = ts;
61
65
 
62
66
  export default defineGenerator({
63
- name: 'route-map',
67
+ name: 'response-map',
64
68
  requires: ['sdk'],
65
69
  run({ model, outputPath }) {
66
- const routes = model.services
70
+ // One `ResponseShapes` entry per operation with a JSON success body.
71
+ const members = model.services
67
72
  .flatMap((service) => service.operations)
68
- .map((op) => ` ${op.name}: '${op.method.toUpperCase()} ${op.path}',`)
69
- .join('\n');
73
+ .flatMap((op) => {
74
+ const success = op.successResponses.find((r) => r.contentType.includes('json'));
75
+ if (!success) return [];
76
+ return [
77
+ factory.createPropertySignature(
78
+ undefined,
79
+ op.name,
80
+ undefined,
81
+ schemaToTypeNode(success.schema)
82
+ ),
83
+ ];
84
+ });
85
+ const alias = factory.createTypeAliasDeclaration(
86
+ [factory.createModifier(ts.SyntaxKind.ExportKeyword)],
87
+ 'ResponseShapes',
88
+ undefined,
89
+ factory.createTypeLiteralNode(members)
90
+ );
70
91
  return [
71
- {
72
- path: outputPath.replace(/\.ts$/, '.routes.ts'),
73
- content: `export const routes = {\n${routes}\n} as const;\n`,
74
- },
92
+ { path: outputPath.replace(/\.ts$/, '.responses.ts'), content: printStatements([alias]) },
75
93
  ];
76
94
  },
77
95
  });
78
96
  ```
79
97
 
80
- Select it in `generators` by import specifier (a path or a package name), or register it inline via `customGenerators` and select it by `name`.
98
+ For a trivial artifact, returning a plain string as `content` works too — no toolkit required.
99
+ Select the generator in `generators` by import specifier (a path or a package name), or register it inline via `customGenerators` and select it by `name`.
81
100
  A custom generator never adds dependencies to the generated client.
101
+ See [Custom generators](https://redocly.com/docs/cli/guides/customize-client-generation#custom-generators).
82
102
 
83
- ### Bake defaults into a published SDK
103
+ ### Pre-configure a published SDK
84
104
 
85
- The `setup` option takes a module that default-exports `defineClientSetup({ config, middleware })`; its defaults are baked into the generated client so a published SDK ships them built in, and consumers can still override.
86
- See [Publisher defaults](https://redocly.com/docs/cli/guides/use-generated-client#publisher-defaults).
105
+ The `setup` option takes a module that default-exports a `{ config, middleware }` object (optionally wrapped in `defineClientSetup` for editor typing); its defaults are included into the generated client so a published SDK ships them built in, and consumers can still override.
106
+ See [Publisher defaults](https://redocly.com/docs/cli/guides/customize-client-generation#publisher-defaults).
87
107
 
88
108
  ## API
89
109
 
@@ -101,7 +121,7 @@ type GenerateClientResult = {
101
121
  };
102
122
  ```
103
123
 
104
- `GenerateClientOptions` is the [`Config` type](./src/config.ts) (`api` and `output` required; `outputMode`, `runtime`, `argsStyle`, `errorMode`, `dateType`, `serverUrl`, `mockData`, `mockSeed`, `generators`, `customGenerators`, `setup`, `pagination` optional) plus an optional resolved Redocly `config` used for spec loading.
124
+ `GenerateClientOptions` is the [`Config` type](./src/config.ts) (`api` and `output` required; `outputMode`, `runtime`, `importExt`, `argsStyle`, `errorMode`, `dateType`, `serverUrl`, `mockData`, `mockSeed`, `generators`, `customGenerators`, `setup`, `pagination` optional) plus an optional resolved Redocly `config` used for spec loading.
105
125
 
106
126
  ### `collectGeneratedFiles`
107
127
 
@@ -133,7 +153,7 @@ The `@redocly/client-generator/generate` entry also exports the emit toolkit the
133
153
 
134
154
  ### `defineClientSetup`
135
155
 
136
- Authors a publisher setup module for the `setup` option:
156
+ Optional typing sugar for authoring a publisher setup module — a plain default-exported `{ config, middleware }` object works too, with no imports:
137
157
 
138
158
  ```ts
139
159
  function defineClientSetup(setup: {
@@ -142,7 +162,7 @@ function defineClientSetup(setup: {
142
162
  }): ClientSetup;
143
163
  ```
144
164
 
145
- A setup module may import only from `@redocly/client-generator`, so it never adds a dependency to the client.
165
+ A setup module may import only from `@redocly/client-generator`, so it never adds a dependency to the client (the import is stripped at generation time).
146
166
 
147
167
  ### `createClient`
148
168
 
@@ -157,13 +177,14 @@ function createClient<Ops>(
157
177
 
158
178
  ## Examples
159
179
 
160
- Runnable examples — from a zero-install quickstart to middleware, baked setup, SSE streaming, pagination, custom generators, and the package runtime — live in [`tests/e2e/generate-client/examples`](https://github.com/Redocly/redocly-cli/tree/main/tests/e2e/generate-client/examples).
180
+ Runnable examples — from a zero-install quickstart to middleware, publisher setup, SSE streaming, pagination, custom generators, and the package runtime — live in [`tests/e2e/generate-client/examples`](https://github.com/Redocly/redocly-cli/tree/main/tests/e2e/generate-client/examples).
161
181
  Each is a standalone Vite app with a checked-in, drift-checked generated client.
162
182
 
163
183
  ## Documentation
164
184
 
165
185
  - [`generate-client` command reference](https://redocly.com/docs/cli/commands/generate-client) — CLI usage, flags, and `redocly.yaml` configuration.
166
186
  - [Use the generated client](https://redocly.com/docs/cli/guides/use-generated-client) — the runtime API and the add-on generators.
187
+ - [Customize client generation](https://redocly.com/docs/cli/guides/customize-client-generation) — publisher defaults and custom generators.
167
188
  - [`ARCHITECTURE.md`](./ARCHITECTURE.md) and the [ADRs](./docs/adr/) — how the package is built and why.
168
189
 
169
190
  ## Development
package/lib/config.d.ts CHANGED
@@ -8,7 +8,7 @@ import type { CustomGenerator, OutputMode } from './generators/types.js';
8
8
  * via `mergeConfig` (see config-file.ts).
9
9
  */
10
10
  export type Config = {
11
- /** Path or URL to the OpenAPI document (or an `apis:` alias from `redocly.yaml`). */
11
+ /** Path or URL to the OpenAPI description (or an `apis:` alias from `redocly.yaml`). */
12
12
  api: string;
13
13
  /** Output anchor path (a `.ts` file; multi-file modes derive siblings from it). */
14
14
  output: string;
@@ -31,6 +31,9 @@ export type Config = {
31
31
  mockData?: 'static' | 'faker';
32
32
  /** Seed for faker-mode mocks: emits `faker.seed(<n>)` so runs reproduce. Static mode ignores it. */
33
33
  mockSeed?: number;
34
+ /** Leading element for every tanstack-query key — namespaces the cache when several
35
+ * generated APIs share one QueryClient (operationIds may collide across APIs). */
36
+ queryKeyPrefix?: string;
34
37
  /**
35
38
  * Generators to run, in order. Defaults to `['sdk']`. Each entry is a built-in name, the `name`
36
39
  * of an inline `customGenerators` entry, or an import specifier (path or package) for a plugin.
@@ -42,9 +45,10 @@ export type Config = {
42
45
  */
43
46
  customGenerators?: CustomGenerator[];
44
47
  /**
45
- * Path to a publisher setup module (`export default defineClientSetup({ config, middleware })`)
46
- * baked into the generated client, so a published SDK ships its request/response defaults built
47
- * in. Resolved against the config dir. Works across all output modes.
48
+ * Path to a publisher setup module (a file default-exporting `{ config, middleware }`)
49
+ * that gets included into the generated client — pre-configures defaults such as the
50
+ * server URL, retries, headers, and middleware, so a published SDK ships with them
51
+ * built in. Resolved against the config dir. Works across all output modes.
48
52
  */
49
53
  setup?: string;
50
54
  /** Runtime distribution: 'inline' (default, self-contained) | 'package' (imports @redocly/client-generator). */
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEzE;;;;;GAKG;AACH,MAAM,MAAM,MAAM,GAAG;IACnB,qFAAqF;IACrF,GAAG,EAAE,MAAM,CAAC;IACZ,m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U,CAAC;IACxB,iDAAiD;IACjD,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,0EAA0E;IAC1E,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;qFACiF;IACjF,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC/B;;kDAE8C;IAC9C,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC7B;;6DAEyD;IACzD,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC9B,oGAAoG;IACpG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;sFACkF;IAClF,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gHAAgH;IAChH,OAAO,CAAC,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC/B;;4CAEwC;IACxC,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB;;8CAE0C;IAC1C,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B,CAAC"}
@@ -4,11 +4,11 @@ import type { PaginationConfig } from './pagination.js';
4
4
  import type { DateType } from './types.js';
5
5
  export type { ArgsStyle } from './operations.js';
6
6
  /** The generated-by banner prepended to every emitted module. */
7
- export declare const HEADER = "// Generated by @redocly/client-generator \u2014 do not edit by hand.\n// Source: OpenAPI document. Re-run `redocly generate-client` to update.";
7
+ export declare const HEADER = "// Generated by @redocly/client-generator \u2014 do not edit by hand.\n// Source: OpenAPI description. Re-run `redocly generate-client` to update.";
8
8
  export type EmitOptions = {
9
9
  /**
10
10
  * Override the server URL baked into the generated client config. When omitted,
11
- * the value is derived from `servers[0].url` in the source OpenAPI document.
11
+ * the value is derived from `servers[0].url` in the source OpenAPI description.
12
12
  */
13
13
  serverUrl?: string;
14
14
  /**
@@ -32,6 +32,9 @@ export type EmitOptions = {
32
32
  mockData?: 'static' | 'faker';
33
33
  /** Seed for faker-mode mocks: emits a top-level `faker.seed(<n>)` so runs reproduce. */
34
34
  mockSeed?: number;
35
+ /** Leading element for every tanstack-query key — namespaces the cache when several
36
+ * generated APIs share one QueryClient (operationIds may collide across APIs). */
37
+ queryKeyPrefix?: string;
35
38
  /**
36
39
  * A pre-baked publisher setup block (from `bakeSetup`) merged into the client's config
37
40
  * via `mergeSetup`. Absent when no `--setup` is given.
@@ -1 +1 @@
1
- {"version":3,"file":"emit-options.d.ts","sourceRoot":"","sources":["../../src/emitters/emit-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAI3C,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,iEAAiE;AACjE,eAAO,MAAM,MAAM,oJACwD,CAAC;AAE5E,MAAM,MAAM,WAAW,GAAG;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC9B,wFAAwF;IACxF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gHAAgH;IAChH,OAAO,CAAC,EAAE,QAAQ,GAAG,SAAS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AC;IAC/B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACxB;;;;OAIG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAEjD;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAa1D"}
@@ -2,7 +2,7 @@ import { splitLines } from './support.js';
2
2
  import { escapeJsDoc } from './ts.js';
3
3
  /** The generated-by banner prepended to every emitted module. */
4
4
  export const HEADER = `// Generated by @redocly/client-generator — do not edit by hand.
5
- // Source: OpenAPI document. Re-run \`redocly generate-client\` to update.`;
5
+ // Source: OpenAPI description. Re-run \`redocly generate-client\` to update.`;
6
6
  /**
7
7
  * Assemble file content from a header banner and a printed body: the leading
8
8
  * `// Generated by …` comment and the `/** title *​/` block are structural
@@ -1 +1 @@
1
- {"version":3,"file":"emit-options.js","sourceRoot":"","sources":["../../src/emitters/emit-options.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAOtC,iEAAiE;AACjE,MAAM,CAAC,MAAM,MAAM,GAAG;2EACqD,CAAC;AAmD5E;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,QAAkB;IACvC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;AAClE,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAe;IAChD,8EAA8E;IAC9E,gFAAgF;IAChF,8EAA8E;IAC9E,MAAM,KAAK,GAAG,CAAC,KAAK,EAAE,MAAM,WAAW,CAAC,GAAG,KAAK,CAAC,KAA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,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC;YAC9D,kFAAkF;YAClF,KAAK,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -2,7 +2,7 @@ export declare const RUNTIME_SOURCES: {
2
2
  readonly 'types.ts': "/**\n * The public type surface of the client runtime — `@redocly/client-generator`'s\n * app-facing runtime module. Pure types, no runtime code (excluded from coverage).\n * The generator emits `OPERATIONS` literals typed\n * `satisfies Record<string, OperationDescriptor>` against this module, so an\n * incompatible runtime/generated pair fails the consumer's build (the semver skew guard).\n */\n\n/** How one operation parameter is sent: its location plus OpenAPI query-serialization hints. */\nexport type ParamSpec = {\n name: string;\n in: 'path' | 'query' | 'header' | 'cookie';\n style?: 'form' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject';\n explode?: boolean;\n allowReserved?: boolean;\n};\n\n/** One security scheme, denormalized onto the operation (`scheme` names the spec's scheme). */\nexport type SecuritySpec =\n | { scheme: string; kind: 'bearer' | 'basic' }\n | { scheme: string; kind: 'apiKey'; name: string; in: 'header' | 'query' | 'cookie' };\n\n/**\n * How to auto-iterate a paginated operation (drives its `.pages()`/`.items()` members).\n * `nextCursor` and `items` are RFC 6901 JSON pointers into the page (response) value.\n */\nexport type PaginationSpec =\n | {\n style: 'cursor';\n /** The query param the iterator advances with the response's cursor. */\n param: string;\n /** Optional page-size query param (recorded for tooling; never set by the runtime). */\n limitParam?: string;\n /** Pointer to the next cursor in the page. */\n nextCursor: string;\n /** Optional pointer to a boolean \"more pages\" flag — `false` stops iteration. */\n hasMore?: string;\n /** Pointer to the page's item array. */\n items: string;\n }\n | {\n style: 'offset' | 'page';\n /** The numeric query param the iterator advances. */\n param: string;\n /** Optional page-size query param (recorded for tooling; never set by the runtime). */\n limitParam?: string;\n /** Pointer to the page's item array. */\n items: string;\n };\n\n/** The frozen data contract between generated code and the runtime: one operation's wire shape. */\nexport type OperationDescriptor = {\n id: string;\n method: string;\n path: string;\n tags?: readonly string[];\n params?: readonly ParamSpec[];\n /** `multipart: true` marks a typed object body serialized to FormData by the runtime. */\n body?: { contentType: string; multipart?: boolean };\n /** Defaults to `'json'` (content-type negotiation on parse). */\n responseKind?: 'json' | 'text' | 'blob' | 'void' | 'sse';\n sseDataKind?: 'json' | 'text';\n /** OR-alternatives, each an AND-set: the runtime applies the first fully-configured one. */\n security?: readonly (readonly SecuritySpec[])[];\n pagination?: PaginationSpec;\n};\n\n/** A query value: scalars, arrays of scalars, or objects (serialized as deepObject brackets). */\nexport type QueryValue =\n | string\n | number\n | boolean\n | null\n | undefined\n | Array<string | number | boolean | null | undefined>\n | Record<string, unknown>;\n\n/** A credential: a literal, or a (possibly async) function resolved per request (refresh flows). */\nexport type TokenProvider = string | (() => string | Promise<string>);\n\n/** Per-instance credentials, keyed by the scheme kinds the runtime can inject. */\nexport type AuthCredentials = {\n bearer?: TokenProvider;\n basic?: { username: string; password: string };\n apiKey?: Record<string, TokenProvider>;\n};\n\n/** Backoff shape: 'fixed' = constant delay; 'exponential' = doubling per attempt. */\nexport type RetryStrategy = 'fixed' | 'exponential';\n\n/**\n * The operation's identity, exposed to middleware for targeting (`ctx.operation`).\n * Generated clients instantiate the type parameters with the spec's literal unions\n * (`OperationId`/`OperationPath`/`OperationTag`) so a misspelled operation id in a\n * middleware comparison fails to compile; the string defaults keep every\n * spec-independent consumer (`runtime-contract.ts`, the runtime internals) working\n * with the base shape. `tags` stays mutable (`Tag[]`) so setup-contract types\n * (byte-locked to generated output) remain assignable through middleware callbacks.\n */\nexport type OperationContext<\n Id extends string = string,\n Path extends string = string,\n Tag extends string = string,\n> = { id: Id; path: Path; tags: Tag[] };\n\n/** The mutable request context threaded through the middleware chain. */\nexport type RequestContext<Op extends OperationContext = OperationContext> = {\n url: string;\n method: string;\n headers: Record<string, string>;\n body?: unknown;\n operation: Op;\n};\n\n/** The failed attempt handed to a custom `retryOn`: exactly one of `response`/`error` is set. */\nexport type RetryContext<Op extends OperationContext = OperationContext> = {\n attempt: number;\n request: RequestContext<Op>;\n response?: Response;\n error?: unknown;\n};\n\n/** Opt-in retry policy; a per-call override merges field-by-field over the config policy. */\nexport type RetryConfig<Op extends OperationContext = OperationContext> = {\n retries?: number;\n retryDelay?: number;\n retryStrategy?: RetryStrategy;\n jitter?: boolean;\n retryOn?: (ctx: RetryContext<Op>) => boolean | Promise<boolean>;\n};\n\n/**\n * Structural stand-in for the runtime's ApiError so this module stays import-free\n * (pure types); the real `ApiError` class is assignable to it.\n */\nexport type ApiErrorLike = globalThis.Error & {\n url: string;\n status: number;\n statusText: string;\n body: unknown;\n};\n\n/** One interceptor: any subset of the three hooks. */\nexport type Middleware<Op extends OperationContext = OperationContext> = {\n onRequest?: (ctx: RequestContext<Op>) => void | Promise<void>;\n onResponse?: (\n response: Response,\n ctx: RequestContext<Op>\n ) => Response | void | Promise<Response | void>;\n /** Throw mode only: may map/replace the error. */\n // `globalThis.Error` so a spec schema named `Error` cannot shadow it in inline mode.\n onError?: (\n error: ApiErrorLike,\n ctx: RequestContext<Op>\n ) => globalThis.Error | Promise<globalThis.Error>;\n};\n\n/** Client configuration: transport, defaults, retry policy, middleware, and credentials. */\nexport type ClientConfig<Op extends OperationContext = OperationContext> = {\n serverUrl?: string;\n fetch?: typeof fetch;\n headers?:\n | Record<string, string>\n | (() => Record<string, string> | Promise<Record<string, string>>);\n retry?: RetryConfig<Op>;\n middleware?: Middleware<Op>[];\n auth?: AuthCredentials;\n /** Fixed at generate time by the generator (`'throw'` when omitted); `configure()` ignores it. */\n errorMode?: 'throw' | 'result';\n onRequest?: Middleware<Op>['onRequest'];\n onResponse?: Middleware<Op>['onResponse'];\n onError?: Middleware<Op>['onError'];\n};\n\n/** Response readers for the per-call `parseAs` override. */\nexport type ParseAs = 'auto' | 'json' | 'text' | 'blob' | 'arrayBuffer' | 'formData' | 'stream';\n\n/** Per-call options: standard `RequestInit` plus a retry override and a forced reader. */\nexport type RequestOptions = RequestInit & { retry?: RetryConfig; parseAs?: ParseAs };\n\n/** Per-call options for an SSE stream; reconnect defaults to true. */\nexport type SseOptions = RequestInit & { reconnect?: boolean; reconnectDelay?: number };\n\n/** A single decoded Server-Sent Event with its payload typed from the spec. */\nexport type ServerSentEvent<T> = { event?: string; data: T; id?: string; retry?: number };\n\n/** Result-mode return shape: exactly one of `data`/`error` is set. */\nexport type Result<TData, TError> =\n | { data: TData; error: undefined; response: Response }\n | { data: undefined; error: TError; response: Response };\n\n/**\n * The generated `Ops` type's shape: per-operation args/result, plus `kind: 'sse'` for\n * streams and, for paginated operations, `item` (the page's element type) and — on\n * result-mode clients only — `page` (the RAW page type `.pages()` yields, since\n * iteration unwraps the `Result` envelope the one-shot `result` carries).\n */\nexport type OpsShape = Record<\n string,\n { args: object; result: unknown; kind?: 'sse'; item?: unknown; page?: unknown }\n>;\n\n/** The always-present client members (assigned after the operation loop — they win collisions). */\nexport type ClientCore<Op extends OperationContext = OperationContext> = {\n /** Merge into the config; note `middleware` REPLACES the chain (use `use()` to compose). */\n configure(config: ClientConfig<Op>): void;\n /** Append interceptors (composes with baked/publisher middleware). */\n use(...middleware: Middleware<Op>[]): void;\n auth: {\n bearer(token: TokenProvider): void;\n basic(username: string, password: string): void;\n apiKey(scheme: string, value: TokenProvider): void;\n };\n};\n\n/**\n * The standard TypeScript optionality probe: `{}` has no required members, so\n * `{} extends A` is true exactly when every member of `A` is optional.\n */\n// oxlint-disable-next-line typescript/no-empty-object-type\ntype NoRequiredKeys<A> = {} extends A ? true : false;\n\n/**\n * The page type `.pages()` yields: the RAW page declared by `page` (the generator\n * writes it only on result-mode paginated entries, whose `result` is the envelope),\n * or the method's own `result` (throw mode — already the raw page).\n */\ntype PageOf<Entry extends OpsShape[string]> = Entry extends { page: unknown }\n ? Entry['page']\n : Entry['result'];\n\n/**\n * The auto-pagination members intersected onto a paginated method — present exactly when\n * the Ops entry declares `item` (the generator writes it only for paginated operations).\n * Args optionality mirrors the method's own; `unknown` otherwise (identity under `&`).\n * Iteration is error-mode-agnostic: `.pages()`/`.items()` yield raw pages/items, and a\n * failed page aborts iteration by throwing `ApiError`, even on result-mode clients; the\n * `onError` middleware hook (throw-mode-only) is not invoked.\n */\ntype Paginated<Entry extends OpsShape[string]> = 'item' extends keyof Entry\n ? NoRequiredKeys<Entry['args']> extends true\n ? {\n pages(args?: Entry['args'], init?: RequestOptions): AsyncGenerator<PageOf<Entry>>;\n items(args?: Entry['args'], init?: RequestOptions): AsyncGenerator<Entry['item']>;\n }\n : {\n pages(args: Entry['args'], init?: RequestOptions): AsyncGenerator<PageOf<Entry>>;\n items(args: Entry['args'], init?: RequestOptions): AsyncGenerator<Entry['item']>;\n }\n : unknown;\n\n/**\n * The stable identity every client method carries: the SPEC operationId (also set as\n * `fn.name`, but `operationId` is the explicit, minification-proof form) — a robust\n * cache key for consumer wrappers (react-query keys and the like).\n */\nexport type OperationMethodIdentity = { readonly operationId: string };\n\n/** The typed instance client: one bound method per operation plus the core members. */\nexport type Client<Ops extends OpsShape, Op extends OperationContext = OperationContext> = {\n [K in keyof Ops]: Ops[K] extends { kind: 'sse' }\n ? (NoRequiredKeys<Ops[K]['args']> extends true\n ? (\n args?: Ops[K]['args'],\n init?: SseOptions\n ) => AsyncGenerator<ServerSentEvent<Ops[K]['result']>>\n : (\n args: Ops[K]['args'],\n init?: SseOptions\n ) => AsyncGenerator<ServerSentEvent<Ops[K]['result']>>) &\n OperationMethodIdentity\n : (NoRequiredKeys<Ops[K]['args']> extends true\n ? (args?: Ops[K]['args'], init?: RequestOptions) => Promise<Ops[K]['result']>\n : (args: Ops[K]['args'], init?: RequestOptions) => Promise<Ops[K]['result']>) &\n OperationMethodIdentity &\n Paginated<Ops[K]>;\n} & ClientCore<Op>;\n";
3
3
  readonly 'errors.ts': "/** The error thrown (throw mode) for a non-2xx response, carrying the decoded error body. */\nexport class ApiError extends Error {\n public readonly url: string;\n public readonly status: number;\n public readonly statusText: string;\n public readonly body: unknown;\n constructor(url: string, status: number, statusText: string, body: unknown) {\n super(`Request failed with status ${status}`);\n this.name = 'ApiError';\n this.url = url;\n this.status = status;\n this.statusText = statusText;\n this.body = body;\n }\n}\n\n/** The error to throw for an aborted request: the caller's abort reason when it is an Error. */\n// `globalThis.Error` (not bare `Error`) so a spec schema named `Error` cannot shadow it\n// when this module is embedded alongside generated types (inline mode).\nexport function abortError(signal: AbortSignal): globalThis.Error {\n const reason = (signal as { reason?: unknown }).reason;\n if (reason instanceof Error) return reason;\n return new DOMException('The operation was aborted.', 'AbortError');\n}\n";
4
4
  readonly 'url.ts': "import type { ParamSpec, QueryValue } from './types.js';\n\n/**\n * The RESOLVED OpenAPI serialization spec for one query parameter — callers apply the\n * OpenAPI defaults (`style: 'form'`, `explode: true`) before building one.\n */\nexport type QueryStyle = {\n style: NonNullable<ParamSpec['style']>;\n explode: boolean;\n allowReserved?: boolean;\n};\n\n/**\n * Encode everything except the RFC-3986 reserved set, for `allowReserved: true` params —\n * `filter=a/b` survives instead of `filter=a%2Fb`.\n */\nexport function encodeReserved(value: string): string {\n return encodeURIComponent(value).replace(\n /%(3A|2F|3F|23|5B|5D|40|21|24|26|27|28|29|2A|2B|2C|3B|3D)/g,\n (match) => decodeURIComponent(match)\n );\n}\n\n/** Substitute `{name}` template segments with encoded values; a missing value is a caller bug. */\nexport function substitutePath(template: string, values: Record<string, unknown>): string {\n return template.replace(/\\{([^{}]+)\\}/g, (_match, name: string) => {\n const value = values[name];\n if (value === undefined) throw new Error(`Missing path parameter \"${name}\"`);\n return encodeURIComponent(String(value));\n });\n}\n\n/**\n * Build the request URL: `serverUrl` (trailing slash trimmed) + path + serialized query.\n * Query parameters honor their OpenAPI `style`/`explode`/`allowReserved` (from `styles`);\n * without a spec, arrays repeat the key (`form`+`explode`), objects serialize as\n * `deepObject` brackets, and `null`/`undefined` entries are skipped.\n */\nexport function buildUrl(\n serverUrl: string,\n path: string,\n query?: Record<string, QueryValue>,\n styles?: Record<string, QueryStyle>\n): string {\n // Trim trailing slashes with a scan, not `/\\/+$/` — an anchored `+` regex is\n // quadratic on adversarial many-slash input (the server URL is caller data).\n let end = serverUrl.length;\n while (end > 0 && serverUrl.charCodeAt(end - 1) === 47 /* '/' */) end--;\n const url = serverUrl.slice(0, end) + path;\n if (!query) return url;\n const params = new URLSearchParams();\n const raw: string[] = [];\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined || value === null) continue;\n const spec = styles?.[key];\n if (!spec) {\n if (Array.isArray(value)) {\n for (const v of value) {\n if (v !== undefined && v !== null) params.append(key, String(v));\n }\n } else if (Object(value) === value) {\n // Object-valued query params use `deepObject` style: key[subKey]=subValue.\n for (const [subKey, subValue] of Object.entries(value)) {\n if (subValue !== undefined && subValue !== null) {\n params.append(`${key}[${subKey}]`, String(subValue));\n }\n }\n } else {\n params.append(key, String(value));\n }\n continue;\n }\n if (Array.isArray(value)) {\n const items = value.filter((v) => v !== undefined && v !== null).map(String);\n if (spec.style === 'form' && spec.explode) {\n for (const v of items) {\n if (spec.allowReserved) raw.push(`${key}=${encodeReserved(v)}`);\n else params.append(key, v);\n }\n } else {\n // Delimited styles put the LITERAL delimiter on the wire; only the\n // values are encoded. `%20` (not `+`) is the literal space delimiter.\n const delim =\n spec.style === 'pipeDelimited' ? '|' : spec.style === 'spaceDelimited' ? '%20' : ',';\n const enc = spec.allowReserved ? encodeReserved : encodeURIComponent;\n raw.push(`${encodeURIComponent(key)}=${items.map(enc).join(delim)}`);\n }\n } else if (Object(value) === value) {\n // `deepObject` (and any object spec, for now): key[subKey]=subValue.\n for (const [subKey, subValue] of Object.entries(value)) {\n if (subValue !== undefined && subValue !== null) {\n if (spec.allowReserved) raw.push(`${key}[${subKey}]=${encodeReserved(String(subValue))}`);\n else params.append(`${key}[${subKey}]`, String(subValue));\n }\n }\n } else if (spec.allowReserved) {\n raw.push(`${key}=${encodeReserved(String(value))}`);\n } else {\n params.append(key, String(value));\n }\n }\n const qs = [params.toString(), ...raw].filter(Boolean).join('&');\n return qs ? `${url}?${qs}` : url;\n}\n";
5
- readonly 'parse.ts': "import type { ParseAs } from './types.js';\n\n/**\n * Read the response body per `kind`. `'auto'` negotiates from the content type\n * (JSON, then `text/*`, then Blob); `204` responses read nothing. A `'void'`\n * operation (no declared 2xx content) still returns a JSON body the server\n * actually sends: the static type stays `void`, but silently dropping real data\n * behind a spec gap is the worse failure — consumers can reach it with a cast\n * while the API description catches up.\n */\nexport async function parse(response: Response, kind: ParseAs | 'void'): Promise<unknown> {\n if (kind === 'void') {\n if (response.status === 204 || response.status === 205 || response.status === 304) {\n return undefined;\n }\n const contentType = (response.headers.get('content-type') ?? '').toLowerCase();\n if (!contentType.includes('json')) return undefined;\n // Best-effort: an empty or malformed body on an undeclared response stays undefined.\n const text = await response.text().catch(() => '');\n if (text === '') return undefined;\n try {\n return JSON.parse(text);\n } catch {\n return undefined;\n }\n }\n if (response.status === 204) return undefined;\n if (kind === 'stream') return response.body;\n if (kind === 'blob') return response.blob();\n if (kind === 'arrayBuffer') return response.arrayBuffer();\n if (kind === 'formData') return response.formData();\n if (kind === 'text') return response.text();\n if (kind === 'json') return response.json();\n // 'auto' — negotiate from the response's content type (case-insensitively:\n // `Text/Plain` and `application/JSON` are valid per RFC 9110).\n const contentType = (response.headers.get('content-type') ?? '').toLowerCase();\n if (contentType.includes('json')) return response.json();\n if (contentType.startsWith('text/')) return response.text();\n return response.blob();\n}\n\n/** Best-effort decode of a non-2xx body (JSON when declared, else text; undefined on failure). */\nexport async function readError(response: Response): Promise<unknown> {\n const contentType = response.headers.get('content-type') ?? '';\n if (contentType.toLowerCase().includes('json')) {\n return response.json().catch(() => undefined);\n }\n return response.text().catch(() => undefined);\n}\n";
5
+ readonly 'parse.ts': "import type { ParseAs } from './types.js';\n\n/**\n * Read the response body per `kind`. `'auto'` negotiates from the content type\n * (JSON, then `text/*`, then Blob); `204` responses read nothing. A `'void'`\n * operation (no declared 2xx content) still returns a JSON body the server\n * actually sends: the static type stays `void`, but silently dropping real data\n * behind a spec gap is the worse failure — consumers can reach it with a cast\n * while the API description catches up.\n */\nexport async function parse(response: Response, kind: ParseAs | 'void'): Promise<unknown> {\n if (kind === 'void') {\n if (response.status === 204 || response.status === 205 || response.status === 304) {\n return undefined;\n }\n const contentType = (response.headers.get('content-type') ?? '').toLowerCase();\n if (!contentType.includes('json')) return undefined;\n // Best-effort: an empty or malformed body on an undeclared response stays undefined.\n const text = await response.text().catch(() => '');\n if (text === '') return undefined;\n try {\n return JSON.parse(text);\n } catch {\n return undefined;\n }\n }\n if (response.status === 204) return undefined;\n if (kind === 'stream') return response.body;\n if (kind === 'blob') return response.blob();\n if (kind === 'arrayBuffer') return response.arrayBuffer();\n if (kind === 'formData') return response.formData();\n if (kind === 'text') return response.text();\n if (kind === 'json') return response.json();\n // 'auto' — negotiate from the response's content type (case-insensitively:\n // `Text/Plain` and `application/JSON` are valid per RFC 9110).\n const contentType = (response.headers.get('content-type') ?? '').toLowerCase();\n if (contentType.includes('json')) return response.json();\n if (contentType.startsWith('text/')) return response.text();\n // An untyped body reads as a Blob — but an EMPTY one resolves to undefined: a 2xx\n // with `Content-Length: 0` must not yield a truthy `new Blob([])` that silently\n // defeats every `!data` guard downstream.\n const blob = await response.blob();\n return blob.size > 0 ? blob : undefined;\n}\n\n/** Best-effort decode of a non-2xx body (JSON when declared, else text; undefined on failure). */\nexport async function readError(response: Response): Promise<unknown> {\n const contentType = response.headers.get('content-type') ?? '';\n if (contentType.toLowerCase().includes('json')) {\n return response.json().catch(() => undefined);\n }\n return response.text().catch(() => undefined);\n}\n";
6
6
  readonly 'retry.ts': "import { abortError } from './errors.js';\nimport type { RetryConfig, RetryContext } from './types.js';\n\nconst IDEMPOTENT_METHODS = new Set(['GET', 'HEAD', 'PUT', 'DELETE', 'OPTIONS']);\nconst TRANSIENT_STATUS = new Set([408, 429, 500, 502, 503, 504]);\n\n/**\n * The default retry predicate: idempotent methods only, on a transport error or a\n * transient status. A custom `retryOn` fully replaces this (no method check kept).\n */\nexport function defaultRetryOn(ctx: RetryContext): boolean {\n if (!IDEMPOTENT_METHODS.has(ctx.request.method.toUpperCase())) return false;\n return ctx.response === undefined || TRANSIENT_STATUS.has(ctx.response.status);\n}\n\n/**\n * The delay before the next attempt: a `Retry-After` header (seconds or HTTP-date)\n * wins; otherwise fixed/exponential backoff over `retryDelay`, with full jitter\n * unless `jitter === false`.\n */\nexport function retryDelay(retry: RetryConfig, attempt: number, retryAfter: string | null): number {\n if (retryAfter) {\n const seconds = Number(retryAfter);\n if (!Number.isNaN(seconds)) return seconds * 1000;\n const when = Date.parse(retryAfter);\n if (!Number.isNaN(when)) return Math.max(0, when - Date.now());\n }\n const base = retry.retryDelay ?? 1000;\n const raw = retry.retryStrategy === 'fixed' ? base : base * Math.pow(2, attempt - 1);\n return retry.jitter === false ? raw : Math.random() * raw;\n}\n\n/** Abort-aware sleep: resolves after `ms`, rejects with the abort reason immediately on abort. */\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) {\n reject(abortError(signal));\n return;\n }\n const onAbort = () => {\n clearTimeout(timer);\n reject(abortError(signal as AbortSignal));\n };\n const timer = setTimeout(() => {\n if (signal) signal.removeEventListener('abort', onAbort);\n resolve();\n }, ms);\n if (signal) signal.addEventListener('abort', onAbort, { once: true });\n });\n}\n";
7
7
  readonly 'multipart.ts': "/**\n * Serialize a plain object into `FormData` for a typed `multipart/form-data` body\n * (capability module — wired into `createClient`, never imported by the send core).\n * `Blob`/`File` and strings pass through; `Date`s become ISO strings; arrays append\n * one field per item; other objects are JSON-encoded; everything else is stringified.\n * `undefined`/`null` entries are skipped.\n */\nexport function toFormData(body: Record<string, unknown>): FormData {\n const fd = new FormData();\n const append = (key: string, value: unknown): void => {\n if (value === undefined || value === null) return;\n if (value instanceof Blob || typeof value === 'string') fd.append(key, value);\n else if (value instanceof Date) fd.append(key, value.toISOString());\n else if (Object(value) === value) fd.append(key, JSON.stringify(value));\n else fd.append(key, String(value));\n };\n for (const [key, value] of Object.entries(body)) {\n if (Array.isArray(value)) for (const item of value) append(key, item);\n else append(key, value);\n }\n return fd;\n}\n";
8
8
  readonly 'auth.ts': "import type { ClientConfig, SecuritySpec, TokenProvider } from './types.js';\n\n/** Resolve a credential: a literal passes through; a function is awaited per request. */\nasync function resolveToken(provider: TokenProvider): Promise<string> {\n return typeof provider === 'function' ? await provider() : provider;\n}\n\n/** UTF-8-safe base64: bare `btoa` throws on non-Latin-1 credentials (RFC 7617 allows UTF-8). */\nfunction encodeBase64(text: string): string {\n let binary = '';\n for (const byte of new TextEncoder().encode(text)) binary += String.fromCharCode(byte);\n return btoa(binary);\n}\n\n/** Whether a credential for this scheme is configured on the instance. */\nfunction isConfigured(scheme: SecuritySpec, config: ClientConfig): boolean {\n if (scheme.kind === 'apiKey') return config.auth?.apiKey?.[scheme.scheme] !== undefined;\n if (scheme.kind === 'bearer') return config.auth?.bearer !== undefined;\n return config.auth?.basic !== undefined;\n}\n\n/**\n * Build the auth headers/query for one operation's `security` OR-alternatives from the\n * instance credentials (`config.auth`) — capability module, wired into `createClient`.\n * The first alternative whose schemes (an AND-set) are all configured is applied, so\n * \"bearer OR apiKey\" works with either credential and never sends both. When none is\n * fully configured, the first alternative's configured schemes are still sent (the\n * server rejects the request, mirroring the previous behavior).\n * Cookie-borne apiKeys fold into a single `Cookie` header joined with `; `.\n */\nexport async function resolveAuth(\n security: readonly (readonly SecuritySpec[])[],\n config: ClientConfig\n): Promise<{ headers: Record<string, string>; query: Record<string, string> }> {\n const alternative =\n security.find((schemes) => schemes.every((scheme) => isConfigured(scheme, config))) ??\n security[0] ??\n [];\n const headers: Record<string, string> = {};\n const query: Record<string, string> = {};\n const cookies: string[] = [];\n for (const scheme of alternative) {\n if (scheme.kind === 'apiKey') {\n const provider = config.auth?.apiKey?.[scheme.scheme];\n if (provider === undefined) continue;\n const value = await resolveToken(provider);\n if (scheme.in === 'header') headers[scheme.name] = value;\n else if (scheme.in === 'query') query[scheme.name] = value;\n // Cookie values may contain reserved characters (`;`, `=`, space, …); percent-encode\n // so the credential can't break the `Cookie` header syntax.\n else cookies.push(`${scheme.name}=${encodeURIComponent(value)}`);\n } else if (scheme.kind === 'bearer') {\n const provider = config.auth?.bearer;\n if (provider !== undefined) headers.Authorization = `Bearer ${await resolveToken(provider)}`;\n } else {\n const basic = config.auth?.basic;\n if (basic !== undefined) {\n headers.Authorization = `Basic ${encodeBase64(`${basic.username}:${basic.password}`)}`;\n }\n }\n }\n if (cookies.length > 0) headers.Cookie = cookies.join('; ');\n return { headers, query };\n}\n";
@@ -3,7 +3,7 @@ export const RUNTIME_SOURCES = {
3
3
  'types.ts': "/**\n * The public type surface of the client runtime — `@redocly/client-generator`'s\n * app-facing runtime module. Pure types, no runtime code (excluded from coverage).\n * The generator emits `OPERATIONS` literals typed\n * `satisfies Record<string, OperationDescriptor>` against this module, so an\n * incompatible runtime/generated pair fails the consumer's build (the semver skew guard).\n */\n\n/** How one operation parameter is sent: its location plus OpenAPI query-serialization hints. */\nexport type ParamSpec = {\n name: string;\n in: 'path' | 'query' | 'header' | 'cookie';\n style?: 'form' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject';\n explode?: boolean;\n allowReserved?: boolean;\n};\n\n/** One security scheme, denormalized onto the operation (`scheme` names the spec's scheme). */\nexport type SecuritySpec =\n | { scheme: string; kind: 'bearer' | 'basic' }\n | { scheme: string; kind: 'apiKey'; name: string; in: 'header' | 'query' | 'cookie' };\n\n/**\n * How to auto-iterate a paginated operation (drives its `.pages()`/`.items()` members).\n * `nextCursor` and `items` are RFC 6901 JSON pointers into the page (response) value.\n */\nexport type PaginationSpec =\n | {\n style: 'cursor';\n /** The query param the iterator advances with the response's cursor. */\n param: string;\n /** Optional page-size query param (recorded for tooling; never set by the runtime). */\n limitParam?: string;\n /** Pointer to the next cursor in the page. */\n nextCursor: string;\n /** Optional pointer to a boolean \"more pages\" flag — `false` stops iteration. */\n hasMore?: string;\n /** Pointer to the page's item array. */\n items: string;\n }\n | {\n style: 'offset' | 'page';\n /** The numeric query param the iterator advances. */\n param: string;\n /** Optional page-size query param (recorded for tooling; never set by the runtime). */\n limitParam?: string;\n /** Pointer to the page's item array. */\n items: string;\n };\n\n/** The frozen data contract between generated code and the runtime: one operation's wire shape. */\nexport type OperationDescriptor = {\n id: string;\n method: string;\n path: string;\n tags?: readonly string[];\n params?: readonly ParamSpec[];\n /** `multipart: true` marks a typed object body serialized to FormData by the runtime. */\n body?: { contentType: string; multipart?: boolean };\n /** Defaults to `'json'` (content-type negotiation on parse). */\n responseKind?: 'json' | 'text' | 'blob' | 'void' | 'sse';\n sseDataKind?: 'json' | 'text';\n /** OR-alternatives, each an AND-set: the runtime applies the first fully-configured one. */\n security?: readonly (readonly SecuritySpec[])[];\n pagination?: PaginationSpec;\n};\n\n/** A query value: scalars, arrays of scalars, or objects (serialized as deepObject brackets). */\nexport type QueryValue =\n | string\n | number\n | boolean\n | null\n | undefined\n | Array<string | number | boolean | null | undefined>\n | Record<string, unknown>;\n\n/** A credential: a literal, or a (possibly async) function resolved per request (refresh flows). */\nexport type TokenProvider = string | (() => string | Promise<string>);\n\n/** Per-instance credentials, keyed by the scheme kinds the runtime can inject. */\nexport type AuthCredentials = {\n bearer?: TokenProvider;\n basic?: { username: string; password: string };\n apiKey?: Record<string, TokenProvider>;\n};\n\n/** Backoff shape: 'fixed' = constant delay; 'exponential' = doubling per attempt. */\nexport type RetryStrategy = 'fixed' | 'exponential';\n\n/**\n * The operation's identity, exposed to middleware for targeting (`ctx.operation`).\n * Generated clients instantiate the type parameters with the spec's literal unions\n * (`OperationId`/`OperationPath`/`OperationTag`) so a misspelled operation id in a\n * middleware comparison fails to compile; the string defaults keep every\n * spec-independent consumer (`runtime-contract.ts`, the runtime internals) working\n * with the base shape. `tags` stays mutable (`Tag[]`) so setup-contract types\n * (byte-locked to generated output) remain assignable through middleware callbacks.\n */\nexport type OperationContext<\n Id extends string = string,\n Path extends string = string,\n Tag extends string = string,\n> = { id: Id; path: Path; tags: Tag[] };\n\n/** The mutable request context threaded through the middleware chain. */\nexport type RequestContext<Op extends OperationContext = OperationContext> = {\n url: string;\n method: string;\n headers: Record<string, string>;\n body?: unknown;\n operation: Op;\n};\n\n/** The failed attempt handed to a custom `retryOn`: exactly one of `response`/`error` is set. */\nexport type RetryContext<Op extends OperationContext = OperationContext> = {\n attempt: number;\n request: RequestContext<Op>;\n response?: Response;\n error?: unknown;\n};\n\n/** Opt-in retry policy; a per-call override merges field-by-field over the config policy. */\nexport type RetryConfig<Op extends OperationContext = OperationContext> = {\n retries?: number;\n retryDelay?: number;\n retryStrategy?: RetryStrategy;\n jitter?: boolean;\n retryOn?: (ctx: RetryContext<Op>) => boolean | Promise<boolean>;\n};\n\n/**\n * Structural stand-in for the runtime's ApiError so this module stays import-free\n * (pure types); the real `ApiError` class is assignable to it.\n */\nexport type ApiErrorLike = globalThis.Error & {\n url: string;\n status: number;\n statusText: string;\n body: unknown;\n};\n\n/** One interceptor: any subset of the three hooks. */\nexport type Middleware<Op extends OperationContext = OperationContext> = {\n onRequest?: (ctx: RequestContext<Op>) => void | Promise<void>;\n onResponse?: (\n response: Response,\n ctx: RequestContext<Op>\n ) => Response | void | Promise<Response | void>;\n /** Throw mode only: may map/replace the error. */\n // `globalThis.Error` so a spec schema named `Error` cannot shadow it in inline mode.\n onError?: (\n error: ApiErrorLike,\n ctx: RequestContext<Op>\n ) => globalThis.Error | Promise<globalThis.Error>;\n};\n\n/** Client configuration: transport, defaults, retry policy, middleware, and credentials. */\nexport type ClientConfig<Op extends OperationContext = OperationContext> = {\n serverUrl?: string;\n fetch?: typeof fetch;\n headers?:\n | Record<string, string>\n | (() => Record<string, string> | Promise<Record<string, string>>);\n retry?: RetryConfig<Op>;\n middleware?: Middleware<Op>[];\n auth?: AuthCredentials;\n /** Fixed at generate time by the generator (`'throw'` when omitted); `configure()` ignores it. */\n errorMode?: 'throw' | 'result';\n onRequest?: Middleware<Op>['onRequest'];\n onResponse?: Middleware<Op>['onResponse'];\n onError?: Middleware<Op>['onError'];\n};\n\n/** Response readers for the per-call `parseAs` override. */\nexport type ParseAs = 'auto' | 'json' | 'text' | 'blob' | 'arrayBuffer' | 'formData' | 'stream';\n\n/** Per-call options: standard `RequestInit` plus a retry override and a forced reader. */\nexport type RequestOptions = RequestInit & { retry?: RetryConfig; parseAs?: ParseAs };\n\n/** Per-call options for an SSE stream; reconnect defaults to true. */\nexport type SseOptions = RequestInit & { reconnect?: boolean; reconnectDelay?: number };\n\n/** A single decoded Server-Sent Event with its payload typed from the spec. */\nexport type ServerSentEvent<T> = { event?: string; data: T; id?: string; retry?: number };\n\n/** Result-mode return shape: exactly one of `data`/`error` is set. */\nexport type Result<TData, TError> =\n | { data: TData; error: undefined; response: Response }\n | { data: undefined; error: TError; response: Response };\n\n/**\n * The generated `Ops` type's shape: per-operation args/result, plus `kind: 'sse'` for\n * streams and, for paginated operations, `item` (the page's element type) and — on\n * result-mode clients only — `page` (the RAW page type `.pages()` yields, since\n * iteration unwraps the `Result` envelope the one-shot `result` carries).\n */\nexport type OpsShape = Record<\n string,\n { args: object; result: unknown; kind?: 'sse'; item?: unknown; page?: unknown }\n>;\n\n/** The always-present client members (assigned after the operation loop — they win collisions). */\nexport type ClientCore<Op extends OperationContext = OperationContext> = {\n /** Merge into the config; note `middleware` REPLACES the chain (use `use()` to compose). */\n configure(config: ClientConfig<Op>): void;\n /** Append interceptors (composes with baked/publisher middleware). */\n use(...middleware: Middleware<Op>[]): void;\n auth: {\n bearer(token: TokenProvider): void;\n basic(username: string, password: string): void;\n apiKey(scheme: string, value: TokenProvider): void;\n };\n};\n\n/**\n * The standard TypeScript optionality probe: `{}` has no required members, so\n * `{} extends A` is true exactly when every member of `A` is optional.\n */\n// oxlint-disable-next-line typescript/no-empty-object-type\ntype NoRequiredKeys<A> = {} extends A ? true : false;\n\n/**\n * The page type `.pages()` yields: the RAW page declared by `page` (the generator\n * writes it only on result-mode paginated entries, whose `result` is the envelope),\n * or the method's own `result` (throw mode — already the raw page).\n */\ntype PageOf<Entry extends OpsShape[string]> = Entry extends { page: unknown }\n ? Entry['page']\n : Entry['result'];\n\n/**\n * The auto-pagination members intersected onto a paginated method — present exactly when\n * the Ops entry declares `item` (the generator writes it only for paginated operations).\n * Args optionality mirrors the method's own; `unknown` otherwise (identity under `&`).\n * Iteration is error-mode-agnostic: `.pages()`/`.items()` yield raw pages/items, and a\n * failed page aborts iteration by throwing `ApiError`, even on result-mode clients; the\n * `onError` middleware hook (throw-mode-only) is not invoked.\n */\ntype Paginated<Entry extends OpsShape[string]> = 'item' extends keyof Entry\n ? NoRequiredKeys<Entry['args']> extends true\n ? {\n pages(args?: Entry['args'], init?: RequestOptions): AsyncGenerator<PageOf<Entry>>;\n items(args?: Entry['args'], init?: RequestOptions): AsyncGenerator<Entry['item']>;\n }\n : {\n pages(args: Entry['args'], init?: RequestOptions): AsyncGenerator<PageOf<Entry>>;\n items(args: Entry['args'], init?: RequestOptions): AsyncGenerator<Entry['item']>;\n }\n : unknown;\n\n/**\n * The stable identity every client method carries: the SPEC operationId (also set as\n * `fn.name`, but `operationId` is the explicit, minification-proof form) — a robust\n * cache key for consumer wrappers (react-query keys and the like).\n */\nexport type OperationMethodIdentity = { readonly operationId: string };\n\n/** The typed instance client: one bound method per operation plus the core members. */\nexport type Client<Ops extends OpsShape, Op extends OperationContext = OperationContext> = {\n [K in keyof Ops]: Ops[K] extends { kind: 'sse' }\n ? (NoRequiredKeys<Ops[K]['args']> extends true\n ? (\n args?: Ops[K]['args'],\n init?: SseOptions\n ) => AsyncGenerator<ServerSentEvent<Ops[K]['result']>>\n : (\n args: Ops[K]['args'],\n init?: SseOptions\n ) => AsyncGenerator<ServerSentEvent<Ops[K]['result']>>) &\n OperationMethodIdentity\n : (NoRequiredKeys<Ops[K]['args']> extends true\n ? (args?: Ops[K]['args'], init?: RequestOptions) => Promise<Ops[K]['result']>\n : (args: Ops[K]['args'], init?: RequestOptions) => Promise<Ops[K]['result']>) &\n OperationMethodIdentity &\n Paginated<Ops[K]>;\n} & ClientCore<Op>;\n",
4
4
  'errors.ts': "/** The error thrown (throw mode) for a non-2xx response, carrying the decoded error body. */\nexport class ApiError extends Error {\n public readonly url: string;\n public readonly status: number;\n public readonly statusText: string;\n public readonly body: unknown;\n constructor(url: string, status: number, statusText: string, body: unknown) {\n super(`Request failed with status ${status}`);\n this.name = 'ApiError';\n this.url = url;\n this.status = status;\n this.statusText = statusText;\n this.body = body;\n }\n}\n\n/** The error to throw for an aborted request: the caller's abort reason when it is an Error. */\n// `globalThis.Error` (not bare `Error`) so a spec schema named `Error` cannot shadow it\n// when this module is embedded alongside generated types (inline mode).\nexport function abortError(signal: AbortSignal): globalThis.Error {\n const reason = (signal as { reason?: unknown }).reason;\n if (reason instanceof Error) return reason;\n return new DOMException('The operation was aborted.', 'AbortError');\n}\n",
5
5
  'url.ts': "import type { ParamSpec, QueryValue } from './types.js';\n\n/**\n * The RESOLVED OpenAPI serialization spec for one query parameter — callers apply the\n * OpenAPI defaults (`style: 'form'`, `explode: true`) before building one.\n */\nexport type QueryStyle = {\n style: NonNullable<ParamSpec['style']>;\n explode: boolean;\n allowReserved?: boolean;\n};\n\n/**\n * Encode everything except the RFC-3986 reserved set, for `allowReserved: true` params —\n * `filter=a/b` survives instead of `filter=a%2Fb`.\n */\nexport function encodeReserved(value: string): string {\n return encodeURIComponent(value).replace(\n /%(3A|2F|3F|23|5B|5D|40|21|24|26|27|28|29|2A|2B|2C|3B|3D)/g,\n (match) => decodeURIComponent(match)\n );\n}\n\n/** Substitute `{name}` template segments with encoded values; a missing value is a caller bug. */\nexport function substitutePath(template: string, values: Record<string, unknown>): string {\n return template.replace(/\\{([^{}]+)\\}/g, (_match, name: string) => {\n const value = values[name];\n if (value === undefined) throw new Error(`Missing path parameter \"${name}\"`);\n return encodeURIComponent(String(value));\n });\n}\n\n/**\n * Build the request URL: `serverUrl` (trailing slash trimmed) + path + serialized query.\n * Query parameters honor their OpenAPI `style`/`explode`/`allowReserved` (from `styles`);\n * without a spec, arrays repeat the key (`form`+`explode`), objects serialize as\n * `deepObject` brackets, and `null`/`undefined` entries are skipped.\n */\nexport function buildUrl(\n serverUrl: string,\n path: string,\n query?: Record<string, QueryValue>,\n styles?: Record<string, QueryStyle>\n): string {\n // Trim trailing slashes with a scan, not `/\\/+$/` — an anchored `+` regex is\n // quadratic on adversarial many-slash input (the server URL is caller data).\n let end = serverUrl.length;\n while (end > 0 && serverUrl.charCodeAt(end - 1) === 47 /* '/' */) end--;\n const url = serverUrl.slice(0, end) + path;\n if (!query) return url;\n const params = new URLSearchParams();\n const raw: string[] = [];\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined || value === null) continue;\n const spec = styles?.[key];\n if (!spec) {\n if (Array.isArray(value)) {\n for (const v of value) {\n if (v !== undefined && v !== null) params.append(key, String(v));\n }\n } else if (Object(value) === value) {\n // Object-valued query params use `deepObject` style: key[subKey]=subValue.\n for (const [subKey, subValue] of Object.entries(value)) {\n if (subValue !== undefined && subValue !== null) {\n params.append(`${key}[${subKey}]`, String(subValue));\n }\n }\n } else {\n params.append(key, String(value));\n }\n continue;\n }\n if (Array.isArray(value)) {\n const items = value.filter((v) => v !== undefined && v !== null).map(String);\n if (spec.style === 'form' && spec.explode) {\n for (const v of items) {\n if (spec.allowReserved) raw.push(`${key}=${encodeReserved(v)}`);\n else params.append(key, v);\n }\n } else {\n // Delimited styles put the LITERAL delimiter on the wire; only the\n // values are encoded. `%20` (not `+`) is the literal space delimiter.\n const delim =\n spec.style === 'pipeDelimited' ? '|' : spec.style === 'spaceDelimited' ? '%20' : ',';\n const enc = spec.allowReserved ? encodeReserved : encodeURIComponent;\n raw.push(`${encodeURIComponent(key)}=${items.map(enc).join(delim)}`);\n }\n } else if (Object(value) === value) {\n // `deepObject` (and any object spec, for now): key[subKey]=subValue.\n for (const [subKey, subValue] of Object.entries(value)) {\n if (subValue !== undefined && subValue !== null) {\n if (spec.allowReserved) raw.push(`${key}[${subKey}]=${encodeReserved(String(subValue))}`);\n else params.append(`${key}[${subKey}]`, String(subValue));\n }\n }\n } else if (spec.allowReserved) {\n raw.push(`${key}=${encodeReserved(String(value))}`);\n } else {\n params.append(key, String(value));\n }\n }\n const qs = [params.toString(), ...raw].filter(Boolean).join('&');\n return qs ? `${url}?${qs}` : url;\n}\n",
6
- 'parse.ts': "import type { ParseAs } from './types.js';\n\n/**\n * Read the response body per `kind`. `'auto'` negotiates from the content type\n * (JSON, then `text/*`, then Blob); `204` responses read nothing. A `'void'`\n * operation (no declared 2xx content) still returns a JSON body the server\n * actually sends: the static type stays `void`, but silently dropping real data\n * behind a spec gap is the worse failure — consumers can reach it with a cast\n * while the API description catches up.\n */\nexport async function parse(response: Response, kind: ParseAs | 'void'): Promise<unknown> {\n if (kind === 'void') {\n if (response.status === 204 || response.status === 205 || response.status === 304) {\n return undefined;\n }\n const contentType = (response.headers.get('content-type') ?? '').toLowerCase();\n if (!contentType.includes('json')) return undefined;\n // Best-effort: an empty or malformed body on an undeclared response stays undefined.\n const text = await response.text().catch(() => '');\n if (text === '') return undefined;\n try {\n return JSON.parse(text);\n } catch {\n return undefined;\n }\n }\n if (response.status === 204) return undefined;\n if (kind === 'stream') return response.body;\n if (kind === 'blob') return response.blob();\n if (kind === 'arrayBuffer') return response.arrayBuffer();\n if (kind === 'formData') return response.formData();\n if (kind === 'text') return response.text();\n if (kind === 'json') return response.json();\n // 'auto' — negotiate from the response's content type (case-insensitively:\n // `Text/Plain` and `application/JSON` are valid per RFC 9110).\n const contentType = (response.headers.get('content-type') ?? '').toLowerCase();\n if (contentType.includes('json')) return response.json();\n if (contentType.startsWith('text/')) return response.text();\n return response.blob();\n}\n\n/** Best-effort decode of a non-2xx body (JSON when declared, else text; undefined on failure). */\nexport async function readError(response: Response): Promise<unknown> {\n const contentType = response.headers.get('content-type') ?? '';\n if (contentType.toLowerCase().includes('json')) {\n return response.json().catch(() => undefined);\n }\n return response.text().catch(() => undefined);\n}\n",
6
+ 'parse.ts': "import type { ParseAs } from './types.js';\n\n/**\n * Read the response body per `kind`. `'auto'` negotiates from the content type\n * (JSON, then `text/*`, then Blob); `204` responses read nothing. A `'void'`\n * operation (no declared 2xx content) still returns a JSON body the server\n * actually sends: the static type stays `void`, but silently dropping real data\n * behind a spec gap is the worse failure — consumers can reach it with a cast\n * while the API description catches up.\n */\nexport async function parse(response: Response, kind: ParseAs | 'void'): Promise<unknown> {\n if (kind === 'void') {\n if (response.status === 204 || response.status === 205 || response.status === 304) {\n return undefined;\n }\n const contentType = (response.headers.get('content-type') ?? '').toLowerCase();\n if (!contentType.includes('json')) return undefined;\n // Best-effort: an empty or malformed body on an undeclared response stays undefined.\n const text = await response.text().catch(() => '');\n if (text === '') return undefined;\n try {\n return JSON.parse(text);\n } catch {\n return undefined;\n }\n }\n if (response.status === 204) return undefined;\n if (kind === 'stream') return response.body;\n if (kind === 'blob') return response.blob();\n if (kind === 'arrayBuffer') return response.arrayBuffer();\n if (kind === 'formData') return response.formData();\n if (kind === 'text') return response.text();\n if (kind === 'json') return response.json();\n // 'auto' — negotiate from the response's content type (case-insensitively:\n // `Text/Plain` and `application/JSON` are valid per RFC 9110).\n const contentType = (response.headers.get('content-type') ?? '').toLowerCase();\n if (contentType.includes('json')) return response.json();\n if (contentType.startsWith('text/')) return response.text();\n // An untyped body reads as a Blob — but an EMPTY one resolves to undefined: a 2xx\n // with `Content-Length: 0` must not yield a truthy `new Blob([])` that silently\n // defeats every `!data` guard downstream.\n const blob = await response.blob();\n return blob.size > 0 ? blob : undefined;\n}\n\n/** Best-effort decode of a non-2xx body (JSON when declared, else text; undefined on failure). */\nexport async function readError(response: Response): Promise<unknown> {\n const contentType = response.headers.get('content-type') ?? '';\n if (contentType.toLowerCase().includes('json')) {\n return response.json().catch(() => undefined);\n }\n return response.text().catch(() => undefined);\n}\n",
7
7
  'retry.ts': "import { abortError } from './errors.js';\nimport type { RetryConfig, RetryContext } from './types.js';\n\nconst IDEMPOTENT_METHODS = new Set(['GET', 'HEAD', 'PUT', 'DELETE', 'OPTIONS']);\nconst TRANSIENT_STATUS = new Set([408, 429, 500, 502, 503, 504]);\n\n/**\n * The default retry predicate: idempotent methods only, on a transport error or a\n * transient status. A custom `retryOn` fully replaces this (no method check kept).\n */\nexport function defaultRetryOn(ctx: RetryContext): boolean {\n if (!IDEMPOTENT_METHODS.has(ctx.request.method.toUpperCase())) return false;\n return ctx.response === undefined || TRANSIENT_STATUS.has(ctx.response.status);\n}\n\n/**\n * The delay before the next attempt: a `Retry-After` header (seconds or HTTP-date)\n * wins; otherwise fixed/exponential backoff over `retryDelay`, with full jitter\n * unless `jitter === false`.\n */\nexport function retryDelay(retry: RetryConfig, attempt: number, retryAfter: string | null): number {\n if (retryAfter) {\n const seconds = Number(retryAfter);\n if (!Number.isNaN(seconds)) return seconds * 1000;\n const when = Date.parse(retryAfter);\n if (!Number.isNaN(when)) return Math.max(0, when - Date.now());\n }\n const base = retry.retryDelay ?? 1000;\n const raw = retry.retryStrategy === 'fixed' ? base : base * Math.pow(2, attempt - 1);\n return retry.jitter === false ? raw : Math.random() * raw;\n}\n\n/** Abort-aware sleep: resolves after `ms`, rejects with the abort reason immediately on abort. */\nexport function sleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise((resolve, reject) => {\n if (signal?.aborted) {\n reject(abortError(signal));\n return;\n }\n const onAbort = () => {\n clearTimeout(timer);\n reject(abortError(signal as AbortSignal));\n };\n const timer = setTimeout(() => {\n if (signal) signal.removeEventListener('abort', onAbort);\n resolve();\n }, ms);\n if (signal) signal.addEventListener('abort', onAbort, { once: true });\n });\n}\n",
8
8
  'multipart.ts': "/**\n * Serialize a plain object into `FormData` for a typed `multipart/form-data` body\n * (capability module — wired into `createClient`, never imported by the send core).\n * `Blob`/`File` and strings pass through; `Date`s become ISO strings; arrays append\n * one field per item; other objects are JSON-encoded; everything else is stringified.\n * `undefined`/`null` entries are skipped.\n */\nexport function toFormData(body: Record<string, unknown>): FormData {\n const fd = new FormData();\n const append = (key: string, value: unknown): void => {\n if (value === undefined || value === null) return;\n if (value instanceof Blob || typeof value === 'string') fd.append(key, value);\n else if (value instanceof Date) fd.append(key, value.toISOString());\n else if (Object(value) === value) fd.append(key, JSON.stringify(value));\n else fd.append(key, String(value));\n };\n for (const [key, value] of Object.entries(body)) {\n if (Array.isArray(value)) for (const item of value) append(key, item);\n else append(key, value);\n }\n return fd;\n}\n",
9
9
  'auth.ts': "import type { ClientConfig, SecuritySpec, TokenProvider } from './types.js';\n\n/** Resolve a credential: a literal passes through; a function is awaited per request. */\nasync function resolveToken(provider: TokenProvider): Promise<string> {\n return typeof provider === 'function' ? await provider() : provider;\n}\n\n/** UTF-8-safe base64: bare `btoa` throws on non-Latin-1 credentials (RFC 7617 allows UTF-8). */\nfunction encodeBase64(text: string): string {\n let binary = '';\n for (const byte of new TextEncoder().encode(text)) binary += String.fromCharCode(byte);\n return btoa(binary);\n}\n\n/** Whether a credential for this scheme is configured on the instance. */\nfunction isConfigured(scheme: SecuritySpec, config: ClientConfig): boolean {\n if (scheme.kind === 'apiKey') return config.auth?.apiKey?.[scheme.scheme] !== undefined;\n if (scheme.kind === 'bearer') return config.auth?.bearer !== undefined;\n return config.auth?.basic !== undefined;\n}\n\n/**\n * Build the auth headers/query for one operation's `security` OR-alternatives from the\n * instance credentials (`config.auth`) — capability module, wired into `createClient`.\n * The first alternative whose schemes (an AND-set) are all configured is applied, so\n * \"bearer OR apiKey\" works with either credential and never sends both. When none is\n * fully configured, the first alternative's configured schemes are still sent (the\n * server rejects the request, mirroring the previous behavior).\n * Cookie-borne apiKeys fold into a single `Cookie` header joined with `; `.\n */\nexport async function resolveAuth(\n security: readonly (readonly SecuritySpec[])[],\n config: ClientConfig\n): Promise<{ headers: Record<string, string>; query: Record<string, string> }> {\n const alternative =\n security.find((schemes) => schemes.every((scheme) => isConfigured(scheme, config))) ??\n security[0] ??\n [];\n const headers: Record<string, string> = {};\n const query: Record<string, string> = {};\n const cookies: string[] = [];\n for (const scheme of alternative) {\n if (scheme.kind === 'apiKey') {\n const provider = config.auth?.apiKey?.[scheme.scheme];\n if (provider === undefined) continue;\n const value = await resolveToken(provider);\n if (scheme.in === 'header') headers[scheme.name] = value;\n else if (scheme.in === 'query') query[scheme.name] = value;\n // Cookie values may contain reserved characters (`;`, `=`, space, …); percent-encode\n // so the credential can't break the `Cookie` header syntax.\n else cookies.push(`${scheme.name}=${encodeURIComponent(value)}`);\n } else if (scheme.kind === 'bearer') {\n const provider = config.auth?.bearer;\n if (provider !== undefined) headers.Authorization = `Bearer ${await resolveToken(provider)}`;\n } else {\n const basic = config.auth?.basic;\n if (basic !== undefined) {\n headers.Authorization = `Basic ${encodeBase64(`${basic.username}:${basic.password}`)}`;\n }\n }\n }\n if (cookies.length > 0) headers.Cookie = cookies.join('; ');\n return { headers, query };\n}\n",
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-sources.js","sourceRoot":"","sources":["../../src/emitters/runtime-sources.ts"],"names":[],"mappings":"AAAA,iKAAiK;AACjK,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,UAAU,EACR,wlXAAwlX;IAC1lX,WAAW,EACT,0iCAA0iC;IAC5iC,QAAQ,EACN,8wIAA8wI;IAChxI,UAAU,EACR,2wEAA2wE;IAC7wE,UAAU,EACR,kgEAAkgE;IACpgE,cAAc,EACZ,yjCAAyjC;IAC3jC,SAAS,EACP,ujGAAujG;IACzjG,UAAU,EACR,6kBAA6kB;IAC/kB,SAAS,EACP,+kMAA+kM;IACjlM,QAAQ,EACN,k2NAAk2N;IACp2N,kBAAkB,EAChB,o6eAAo6e;IACt6e,aAAa,EACX,2pKAA2pK;CACrpK,CAAC"}
1
+ {"version":3,"file":"runtime-sources.js","sourceRoot":"","sources":["../../src/emitters/runtime-sources.ts"],"names":[],"mappings":"AAAA,iKAAiK;AACjK,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,UAAU,EACR,wlXAAwlX;IAC1lX,WAAW,EACT,0iCAA0iC;IAC5iC,QAAQ,EACN,8wIAA8wI;IAChxI,UAAU,EACR,2hFAA2hF;IAC7hF,UAAU,EACR,kgEAAkgE;IACpgE,cAAc,EACZ,yjCAAyjC;IAC3jC,SAAS,EACP,ujGAAujG;IACzjG,UAAU,EACR,6kBAA6kB;IAC/kB,SAAS,EACP,+kMAA+kM;IACjlM,QAAQ,EACN,k2NAAk2N;IACp2N,kBAAkB,EAChB,o6eAAo6e;IACt6e,aAAa,EACX,2pKAA2pK;CACrpK,CAAC"}
@@ -1,10 +1,15 @@
1
1
  import type { ApiModel } from '../intermediate-representation/model.js';
2
+ import { type PaginationConfig } from './pagination.js';
2
3
  export type TanstackOptions = {
3
- argsStyle: 'flat' | 'grouped';
4
- /** Import specifier for the sdk entry the operation functions/types live in. */
4
+ /** Import specifier for the sdk entry the `client` instance and types live in. */
5
5
  sdkModule: string;
6
- /** TanStack adapter to import `queryOptions` from (`@tanstack/${framework}-query`). */
6
+ /** TanStack adapter to import the option helpers from (`@tanstack/${framework}-query`). */
7
7
  framework: 'react' | 'vue' | 'svelte' | 'solid';
8
+ /** Auto-pagination rules — paginated query ops gain `<op>InfiniteOptions`. */
9
+ pagination?: PaginationConfig;
10
+ /** Leading element for every query/mutation key — namespaces the cache when several
11
+ * generated APIs share one QueryClient (operationIds may collide across APIs). */
12
+ queryKeyPrefix?: string;
8
13
  };
9
14
  /** Render the full TanStack Query module source. `''` when there are no wrappable operations. */
10
15
  export declare function renderTanstackModule(model: ApiModel, opts: TanstackOptions): string;
@@ -1 +1 @@
1
- {"version":3,"file":"tanstack-query.d.ts","sourceRoot":"","sources":["../../src/emitters/tanstack-query.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,QAAQ,EAAkB,MAAM,yCAAyC,CAAC;AAoBxF,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC;IAClB,uFAAuF;IACvF,SAAS,EAAE,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;CACjD,CAAC;AAEF,iGAAiG;AACjG,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,GAAG,MAAM,CAInF"}
1
+ {"version":3,"file":"tanstack-query.d.ts","sourceRoot":"","sources":["../../src/emitters/tanstack-query.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,QAAQ,EAAkB,MAAM,yCAAyC,CAAC;AAGxF,OAAO,EAEL,KAAK,gBAAgB,EAGtB,MAAM,iBAAiB,CAAC;AAIzB,MAAM,MAAM,eAAe,GAAG;IAC5B,kFAAkF;IAClF,SAAS,EAAE,MAAM,CAAC;IAClB,2FAA2F;IAC3F,SAAS,EAAE,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,CAAC;IAChD,8EAA8E;IAC9E,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B;sFACkF;IAClF,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,iGAAiG;AACjG,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,GAAG,MAAM,CAWnF"}
@@ -1,68 +1,234 @@
1
- // Emits an idiomatic TanStack Query v5 (React) module wrapping the sdk operation
2
- // functions. Per query operation (GET/HEAD) a `<op>QueryKey(vars)` +
3
- // `<op>Options(vars, init?)` (`queryOptions({ queryKey, queryFn })`); per mutation
4
- // (everything else) a `<op>Mutation()` (`{ mutationKey, mutationFn }`). Each
5
- // factory forwards to the sdk function per the configured args style — grouped
6
- // (`getPet(vars, init)`) or flat (`getPet(vars.petId, vars.params, …, init)`),
7
- // matching `operations.ts` positional order so the call type-checks against the
8
- // generated sdk. AST-native via `ts.factory`.
9
- import { arrow, constArray, exportConstStatement as exportConst, printStatements, ts, } from './ts.js';
10
- import { hasInputs, initParam, isQuery, sdkCall, sdkNamedImport, varsParam, wrappableOperations, } from './wrapper-support.js';
11
- const { factory } = ts;
1
+ // Emits an idiomatic TanStack Query v5 module over the generated client. The factories
2
+ // are built by `createQueryFactories(c)` — bindable to any client instance (per-instance
3
+ // config, middleware, retry) — and the module-level exports bind the sdk's default
4
+ // `client`. Per query operation (GET/HEAD): `<op>QueryKey(vars?)` (the no-args form is
5
+ // the invalidation prefix) and `<op>Options(vars, init?)` whose `queryFn` forwards
6
+ // TanStack's abort `signal`. A paginated query op additionally gets
7
+ // `<op>InfiniteOptions(vars, init?)` with `initialPageParam`/`getNextPageParam` compiled
8
+ // from the pagination rule's JSON pointers. Per mutation: `<op>Mutation(init?)`. Calls go
9
+ // through the client instance's grouped methods, so the module is independent of the
10
+ // sdk's `--args-style`.
11
+ //
12
+ // The factory bodies are authored as source text and round-tripped through
13
+ // `parseStatements` → `printStatements`, which validates the syntax at generation time
14
+ // and normalizes everything to the printer's canonical style. Every interpolated piece
15
+ // is generator-derived (sanitized operation names, JSON-pointer property chains built
16
+ // here) — never raw spec text.
17
+ import { isSafeIdentifier, safeIdent } from './identifier.js';
18
+ import { resolveModelPagination, resolveSchemaPointer, } from './pagination.js';
19
+ import { parseStatements, printStatements } from './ts.js';
20
+ import { hasInputs, isQuery, variablesName, wrappableOperations } from './wrapper-support.js';
12
21
  /** Render the full TanStack Query module source. `''` when there are no wrappable operations. */
13
22
  export function renderTanstackModule(model, opts) {
14
23
  const ops = wrappableOperations(model, 'tanstack-query');
15
24
  if (ops.length === 0)
16
25
  return '';
17
- return printStatements(tanstackStatements(ops, opts));
18
- }
19
- /** The TanStack module statements: the import header followed by per-op factories. */
20
- function tanstackStatements(ops, opts) {
21
- const hasQuery = ops.some(isQuery);
22
- const statements = [];
23
- for (const op of ops) {
24
- statements.push(...(isQuery(op) ? queryStatements(op, opts) : [mutationStatement(op, opts)]));
26
+ const pagination = resolveModelPagination(model, opts.pagination);
27
+ const source = [
28
+ importHeader(ops, opts, pagination),
29
+ ...ops.filter(isQuery).map((op) => queryKeySource(op, opts.queryKeyPrefix)),
30
+ factoriesSource(model, ops, pagination, opts.queryKeyPrefix),
31
+ ...defaultBindings(ops, pagination),
32
+ ].join('\n');
33
+ return printStatements(parseStatements(source));
34
+ }
35
+ /** Whether the op gets an `<op>InfiniteOptions` factory: a paginated query operation. */
36
+ function isInfinite(op, pagination) {
37
+ return isQuery(op) && pagination.has(op.name);
38
+ }
39
+ /**
40
+ * The import header: the option helpers from `@tanstack/${framework}-query` (only the
41
+ * ones used), then the sdk's `client` instance plus the referenced types.
42
+ */
43
+ function importHeader(ops, opts, pagination) {
44
+ const helpers = [
45
+ ...(ops.some((op) => isInfinite(op, pagination)) ? ['infiniteQueryOptions'] : []),
46
+ ...(ops.some(isQuery) ? ['queryOptions'] : []),
47
+ ];
48
+ const types = [...ops.filter(hasInputs).map(variablesName), 'RequestOptions']
49
+ .sort()
50
+ .map((name) => `type ${name}`);
51
+ const lines = [];
52
+ if (helpers.length > 0) {
53
+ lines.push(`import { ${helpers.join(', ')} } from "@tanstack/${opts.framework}-query";`);
54
+ }
55
+ lines.push(`import { client, ${types.join(', ')} } from "${opts.sdkModule}";`);
56
+ return lines.join('\n');
57
+ }
58
+ /**
59
+ * `<op>QueryKey(vars?)` — with `vars` the exact key `<op>Options` uses; without, the
60
+ * one-element prefix matching every cached page/filter of the operation
61
+ * (`queryClient.invalidateQueries({ queryKey: getOrderQueryKey() })`).
62
+ */
63
+ function queryKeySource(op, prefix) {
64
+ const base = keyElements(op, prefix);
65
+ if (!hasInputs(op)) {
66
+ return `export const ${op.name}QueryKey = () => [${base}] as const;`;
67
+ }
68
+ return (`export const ${op.name}QueryKey = (vars?: ${variablesName(op)}) =>\n` +
69
+ ` vars === undefined ? ([${base}] as const) : ([${base}, vars] as const);`);
70
+ }
71
+ /** The constant leading key elements: `"main", "getOrder"` with a prefix, else the id alone. */
72
+ function keyElements(op, prefix) {
73
+ // The prefix is config-supplied text — JSON.stringify is the escaping.
74
+ return prefix === undefined ? `"${op.name}"` : `${JSON.stringify(prefix)}, "${op.name}"`;
75
+ }
76
+ /** The `createQueryFactories(c)` declaration wrapping every option/mutation factory. */
77
+ function factoriesSource(model, ops, pagination, prefix) {
78
+ const members = ops.flatMap((op) => {
79
+ if (!isQuery(op))
80
+ return [mutationMember(op, prefix)];
81
+ const paginated = pagination.get(op.name);
82
+ return paginated === undefined
83
+ ? [optionsMember(op)]
84
+ : [optionsMember(op), infiniteMember(model, op, paginated.spec)];
85
+ });
86
+ return ('/**\n' +
87
+ ' * Build the factories over a specific client instance — its config, middleware, and\n' +
88
+ ' * retry apply to every call (`createQueryFactories(createClient(OPERATIONS, config))`).\n' +
89
+ " * The module-level exports below are these factories bound to the sdk's default `client`.\n" +
90
+ ' */\n' +
91
+ 'export const createQueryFactories = (c: typeof client = client) => ({\n' +
92
+ members.join(',\n') +
93
+ '\n});');
94
+ }
95
+ /** `<op>Options` — `queryFn` forwards TanStack's abort `signal` into the request `init`. */
96
+ function optionsMember(op) {
97
+ const { params, keyArg, callArgs } = varsPieces(op);
98
+ return (` ${op.name}Options: (${params}) => queryOptions({\n` +
99
+ ` queryKey: ${op.name}QueryKey(${keyArg}),\n` +
100
+ ` queryFn: ({ signal }) => c.${op.name}(${callArgs}, { ...init, signal }),\n` +
101
+ ` })`);
102
+ }
103
+ /** `<op>Mutation(init?)` — per-call `RequestOptions` (headers, a retry override) reach the mutation. */
104
+ function mutationMember(op, prefix) {
105
+ const mutationFn = hasInputs(op)
106
+ ? `(vars: ${variablesName(op)}) => c.${op.name}(vars, init)`
107
+ : `() => c.${op.name}({}, init)`;
108
+ return (` ${op.name}Mutation: (init?: RequestOptions) => ({\n` +
109
+ ` mutationKey: [${keyElements(op, prefix)}] as const,\n` +
110
+ ` mutationFn: ${mutationFn},\n` +
111
+ ` })`);
112
+ }
113
+ /**
114
+ * `<op>InfiniteOptions` — the pagination rule compiled into TanStack's contract: the
115
+ * page param rides the rule's advance query parameter, `initialPageParam` resumes from
116
+ * the caller's own value, and `getNextPageParam` mirrors the runtime iterators' stop
117
+ * conditions (cursor: absent/`null`/`''`, plus the optional `hasMore === false`;
118
+ * offset/page: an empty items page).
119
+ */
120
+ function infiniteMember(model, op, spec) {
121
+ const { params, keyArg } = varsPieces(op);
122
+ const override = `{ ...vars, params: { ...vars.params, ${safeIdent(spec.param)}: pageParam } }`;
123
+ return (` ${op.name}InfiniteOptions: (${params}) => infiniteQueryOptions({\n` +
124
+ ` queryKey: [...${op.name}QueryKey(${keyArg}), "infinite"] as const,\n` +
125
+ ` queryFn: ({ pageParam, signal }) => c.${op.name}(${override}, { ...init, signal }),\n` +
126
+ nextPageSource(model, op, spec) +
127
+ ` })`);
128
+ }
129
+ /** The `initialPageParam` + `getNextPageParam` pair for one pagination style. */
130
+ function nextPageSource(model, op, spec) {
131
+ const advance = paramsAccess(spec.param);
132
+ if (spec.style === 'cursor') {
133
+ const stopEarly = spec.hasMore === undefined
134
+ ? ''
135
+ : ` if (lastPage${pointerChain(spec.hasMore)} === false) return undefined;\n`;
136
+ // Only the stop checks the cursor's static type admits are emitted — a `=== null`
137
+ // against a non-nullable string is a TS2367 in the consumer's build. TanStack v5
138
+ // itself stops on a returned `null`/`undefined`, so an omitted check stays safe
139
+ // even when the server sends a value the description says it cannot.
140
+ const checks = cursorStopChecks(model, op, spec.nextCursor);
141
+ const body = checks.length === 0
142
+ ? ` return lastPage${pointerChain(spec.nextCursor)};\n`
143
+ : ` const next = lastPage${pointerChain(spec.nextCursor)};\n` +
144
+ ` return ${checks.join(' || ')} ? undefined : next;\n`;
145
+ return (` initialPageParam: vars.params?.${advance},\n` +
146
+ ` getNextPageParam: (lastPage) => {\n` +
147
+ stopEarly +
148
+ body +
149
+ ` },\n`);
25
150
  }
26
- return [...importHeader(ops, opts, hasQuery), ...statements];
27
- }
28
- /** A query op's `<op>QueryKey` + `<op>Options` statements. */
29
- function queryStatements(op, opts) {
30
- const inputs = hasInputs(op);
31
- const keyId = factory.createStringLiteral(op.name);
32
- const keyParams = inputs ? [varsParam(op)] : [];
33
- const keyElements = inputs ? [keyId, factory.createIdentifier('vars')] : [keyId];
34
- const queryKey = exportConst(`${op.name}QueryKey`, arrow(keyParams, constArray(keyElements)));
35
- const keyCall = factory.createCallExpression(factory.createIdentifier(`${op.name}QueryKey`), undefined, inputs ? [factory.createIdentifier('vars')] : []);
36
- const queryOptionsCall = factory.createCallExpression(factory.createIdentifier('queryOptions'), undefined, [
37
- factory.createObjectLiteralExpression([
38
- factory.createPropertyAssignment('queryKey', keyCall),
39
- factory.createPropertyAssignment('queryFn', arrow([], sdkCall(op, opts.argsStyle, 'vars', true))),
40
- ], true),
41
- ]);
42
- const optionsParams = inputs ? [varsParam(op), initParam()] : [initParam()];
43
- const options = exportConst(`${op.name}Options`, arrow(optionsParams, queryOptionsCall));
44
- return [queryKey, options];
45
- }
46
- /** A mutation op's `<op>Mutation` statement. */
47
- function mutationStatement(op, opts) {
48
- const inputs = hasInputs(op);
49
- const mutationFn = arrow(inputs ? [varsParam(op)] : [], sdkCall(op, opts.argsStyle, 'vars', false));
50
- const obj = factory.createObjectLiteralExpression([
51
- factory.createPropertyAssignment('mutationKey', constArray([factory.createStringLiteral(op.name)])),
52
- factory.createPropertyAssignment('mutationFn', mutationFn),
53
- ], true);
54
- // Wrap in parens so the arrow body is an object literal, not a block.
55
- return exportConst(`${op.name}Mutation`, arrow([], factory.createParenthesizedExpression(obj)));
151
+ const step = spec.style === 'offset' ? 'lastPageParam + count' : 'lastPageParam + 1';
152
+ const start = spec.style === 'offset' ? '0' : '1';
153
+ return (` initialPageParam: vars.params?.${advance} ?? ${start},\n` +
154
+ ` getNextPageParam: (lastPage, _allPages, lastPageParam) => {\n` +
155
+ ` const count = ${itemsLength(spec.items)};\n` +
156
+ ` return count === 0 ? undefined : ${step};\n` +
157
+ ` },\n`);
56
158
  }
57
159
  /**
58
- * The import header: `queryOptions` from `@tanstack/${framework}-query` (when any
59
- * query op), then the shared sdk named import.
160
+ * The `next === …` stop conditions whose comparison the cursor's static type allows:
161
+ * `undefined` when any step of the chain can miss, `null` when the cursor is nullable,
162
+ * `""` when it is a plain string.
60
163
  */
61
- function importHeader(ops, opts, hasQuery) {
62
- const tanstack = factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports([
63
- factory.createImportSpecifier(false, undefined, factory.createIdentifier('queryOptions')),
64
- ])), factory.createStringLiteral(`@tanstack/${opts.framework}-query`));
65
- const sdkImport = sdkNamedImport(ops, opts.sdkModule, hasQuery);
66
- return hasQuery ? [tanstack, sdkImport] : [sdkImport];
164
+ function cursorStopChecks(model, op, pointer) {
165
+ const page = op.successResponses.find((response) => response.contentType.toLowerCase().includes('json'));
166
+ // Both resolve — `resolveModelPagination` already verified the rule fits the operation.
167
+ const root = resolveSchemaPointer(page.schema, '', model);
168
+ const target = resolveSchemaPointer(page.schema, pointer, model);
169
+ const keys = pointer.slice(1).split('/');
170
+ let canBeUndefined = keys.length > 1;
171
+ if (!canBeUndefined && root?.kind === 'object') {
172
+ const property = root.properties.find((candidate) => candidate.name === keys[0]);
173
+ canBeUndefined = property === undefined || !property.required;
174
+ }
175
+ const members = target?.kind === 'union' ? target.members : target ? [target] : [];
176
+ const nullable = members.some((member) => member.kind === 'null');
177
+ const plainString = members.some((member) => member.kind === 'scalar' && member.scalar === 'string');
178
+ return [
179
+ ...(canBeUndefined ? ['next === undefined'] : []),
180
+ ...(nullable ? ['next === null'] : []),
181
+ ...(plainString ? ['next === ""'] : []),
182
+ ];
183
+ }
184
+ /** The shared `(vars, init?)` parameter list plus how `vars` reaches the key and the call. */
185
+ function varsPieces(op) {
186
+ if (!hasInputs(op)) {
187
+ return { params: 'init?: RequestOptions', keyArg: '', callArgs: '{}' };
188
+ }
189
+ return {
190
+ params: `vars: ${variablesName(op)}, init?: RequestOptions`,
191
+ keyArg: 'vars',
192
+ callArgs: 'vars',
193
+ };
194
+ }
195
+ /** One query-param access step: `.name`, or `["a b"]` when not a bare identifier. */
196
+ function paramsAccess(name) {
197
+ return isSafeIdentifier(name) ? name : `[${safeIdent(name)}]`;
198
+ }
199
+ /** An RFC 6901 pointer as an optional property chain: `/page/endCursor` → `.page?.endCursor`. */
200
+ function pointerChain(pointer) {
201
+ const keys = pointer
202
+ .slice(1)
203
+ .split('/')
204
+ .map((token) => token.replaceAll('~1', '/').replaceAll('~0', '~'));
205
+ return keys
206
+ .map((key, index) => {
207
+ const bare = isSafeIdentifier(key);
208
+ if (index === 0)
209
+ return bare ? `.${key}` : `[${safeIdent(key)}]`;
210
+ return bare ? `?.${key}` : `?.[${safeIdent(key)}]`;
211
+ })
212
+ .join('');
213
+ }
214
+ /** The page's item count per the `items` pointer (`''` means the page IS the array). */
215
+ function itemsLength(items) {
216
+ if (items === '')
217
+ return 'lastPage?.length ?? 0';
218
+ return `lastPage${pointerChain(items)}?.length ?? 0`;
219
+ }
220
+ /** `export const <name> = defaultFactories.<name>;` per factory, bound to the default client. */
221
+ function defaultBindings(ops, pagination) {
222
+ const names = ops.flatMap((op) => {
223
+ if (!isQuery(op))
224
+ return [`${op.name}Mutation`];
225
+ return pagination.has(op.name)
226
+ ? [`${op.name}Options`, `${op.name}InfiniteOptions`]
227
+ : [`${op.name}Options`];
228
+ });
229
+ return [
230
+ 'const defaultFactories = createQueryFactories();',
231
+ ...names.map((name) => `export const ${name} = defaultFactories.${name};`),
232
+ ];
67
233
  }
68
234
  //# sourceMappingURL=tanstack-query.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tanstack-query.js","sourceRoot":"","sources":["../../src/emitters/tanstack-query.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,qEAAqE;AACrE,mFAAmF;AACnF,6EAA6E;AAC7E,+EAA+E;AAC/E,+EAA+E;AAC/E,gFAAgF;AAChF,8CAA8C;AAG9C,OAAO,EACL,KAAK,EACL,UAAU,EACV,oBAAoB,IAAI,WAAW,EACnC,eAAe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C;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE;IACP,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,UAAU,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;CAC7C,GACA,aAAa,EAAE,CAuBjB;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,oBAAoB,CAAC,CAgF/B"}
package/lib/generate.js CHANGED
@@ -96,6 +96,7 @@ export async function generateClient(options) {
96
96
  dateType: options.dateType,
97
97
  mockData: options.mockData,
98
98
  mockSeed: options.mockSeed,
99
+ queryKeyPrefix: options.queryKeyPrefix,
99
100
  setup: setupBlock,
100
101
  runtime: options.runtime,
101
102
  importExt: options.importExt,
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,2FAA2F;AAC3F,0FAA0F;AAC1F,0FAA0F;AAC1F,wFAAwF;AACxF,sCAAsC;AAEtC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG7C,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAA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D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACrD,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAClD,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;IACrF,CAAC;IAED,OAAO;QACL,UAAU;QACV,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QACzD,KAAK,EAAE,OAAO;KACf,CAAC;AACJ,CAAC"}
@@ -1,11 +1,12 @@
1
1
  import type { Generator } from './types.js';
2
2
  /**
3
3
  * The tanstack-query generator: a standalone `<stem>.tanstack.ts` module of
4
- * TanStack Query v5 factories that wrap the sdk operation functions —
5
- * `<op>QueryKey`/`<op>Options` per query (GET/HEAD), `<op>Mutation` per mutation.
6
- * It imports the operation functions + their `<Op>Variables` types from the sdk
7
- * entry (`./<stem>.js`), so it requires the `sdk` generator and targets its
8
- * throw-mode operation functions. The framework-agnostic `queryOptions` helper is
4
+ * TanStack Query v5 factories over the generated client — `<op>QueryKey`/`<op>Options`
5
+ * per query (GET/HEAD), `<op>InfiniteOptions` per paginated query, `<op>Mutation` per
6
+ * mutation, all built by `createQueryFactories(c)` (bindable to any client instance)
7
+ * with the module-level exports bound to the sdk's default `client`. It imports the
8
+ * `client` instance + the `<Op>Variables` types from the sdk entry (`./<stem>.js`), so
9
+ * it requires the `sdk` generator and its throw-mode client. The option helpers are
9
10
  * imported from `@tanstack/<framework>-query` (the consumer's peer); the registry binds
10
11
  * one framework per generator name, and the emitted body is byte-identical across them.
11
12
  *
@@ -1 +1 @@
1
- {"version":3,"file":"tanstack-query.d.ts","sourceRoot":"","sources":["../../src/generators/tanstack-query.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAWjG"}
1
+ {"version":3,"file":"tanstack-query.d.ts","sourceRoot":"","sources":["../../src/generators/tanstack-query.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAYjG"}
@@ -4,11 +4,12 @@ import { renderTanstackModule } from '../emitters/tanstack-query.js';
4
4
  import { anchor } from './anchor.js';
5
5
  /**
6
6
  * The tanstack-query generator: a standalone `<stem>.tanstack.ts` module of
7
- * TanStack Query v5 factories that wrap the sdk operation functions —
8
- * `<op>QueryKey`/`<op>Options` per query (GET/HEAD), `<op>Mutation` per mutation.
9
- * It imports the operation functions + their `<Op>Variables` types from the sdk
10
- * entry (`./<stem>.js`), so it requires the `sdk` generator and targets its
11
- * throw-mode operation functions. The framework-agnostic `queryOptions` helper is
7
+ * TanStack Query v5 factories over the generated client — `<op>QueryKey`/`<op>Options`
8
+ * per query (GET/HEAD), `<op>InfiniteOptions` per paginated query, `<op>Mutation` per
9
+ * mutation, all built by `createQueryFactories(c)` (bindable to any client instance)
10
+ * with the module-level exports bound to the sdk's default `client`. It imports the
11
+ * `client` instance + the `<Op>Variables` types from the sdk entry (`./<stem>.js`), so
12
+ * it requires the `sdk` generator and its throw-mode client. The option helpers are
12
13
  * imported from `@tanstack/<framework>-query` (the consumer's peer); the registry binds
13
14
  * one framework per generator name, and the emitted body is byte-identical across them.
14
15
  *
@@ -20,9 +21,10 @@ export function tanstackQueryGenerator(framework) {
20
21
  return ({ model, outputPath, emit }) => {
21
22
  const { dir, stem } = anchor(outputPath);
22
23
  const content = renderTanstackModule(model, {
23
- argsStyle: emit.argsStyle ?? 'flat',
24
24
  sdkModule: `./${stem}.${emit.importExt ?? 'js'}`,
25
25
  framework,
26
+ pagination: emit.pagination,
27
+ queryKeyPrefix: emit.queryKeyPrefix,
26
28
  });
27
29
  if (content === '')
28
30
  return [];
@@ -1 +1 @@
1
- {"version":3,"file":"tanstack-query.js","sourceRoot":"","sources":["../../src/generators/tanstack-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,sBAAsB,CAAC,SAA+C;IACpF,OAAO,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,EAAE;QACrC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QACzC,MAAM,OAAO,GAAG,oBAAoB,CAAC,KAAK,EAAE;YAC1C,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,MAAM;YACnC,SAAS,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,EAAE;YAChD,SAAS;SACV,CAAC,CAAC;QACH,IAAI,OAAO,KAAK,EAAE;YAAE,OAAO,EAAE,CAAC;QAC9B,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,cAAc,CAAC,EAAE,OAAO,EAAE,GAAG,MAAM,OAAO,OAAO,EAAE,EAAE,CAAC,CAAC;IAC1F,CAAC,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"tanstack-query.js","sourceRoot":"","sources":["../../src/generators/tanstack-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrC;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,sBAAsB,CAAC,SAA+C;IACpF,OAAO,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,EAAE;QACrC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;QACzC,MAAM,OAAO,GAAG,oBAAoB,CAAC,KAAK,EAAE;YAC1C,SAAS,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,EAAE;YAChD,SAAS;YACT,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,cAAc,EAAE,IAAI,CAAC,cAAc;SACpC,CAAC,CAAC;QACH,IAAI,OAAO,KAAK,EAAE;YAAE,OAAO,EAAE,CAAC;QAC9B,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,cAAc,CAAC,EAAE,OAAO,EAAE,GAAG,MAAM,OAAO,OAAO,EAAE,EAAE,CAAC,CAAC;IAC1F,CAAC,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/runtime/parse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;;GAOG;AACH,wBAAsB,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA6BxF;AAED,kGAAkG;AAClG,wBAAsB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAMpE"}
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/runtime/parse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;;GAOG;AACH,wBAAsB,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAiCxF;AAED,kGAAkG;AAClG,wBAAsB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAMpE"}
@@ -46,7 +46,11 @@ export async function parse(response, kind) {
46
46
  return response.json();
47
47
  if (contentType.startsWith('text/'))
48
48
  return response.text();
49
- return response.blob();
49
+ // An untyped body reads as a Blob — but an EMPTY one resolves to undefined: a 2xx
50
+ // with `Content-Length: 0` must not yield a truthy `new Blob([])` that silently
51
+ // defeats every `!data` guard downstream.
52
+ const blob = await response.blob();
53
+ return blob.size > 0 ? blob : undefined;
50
54
  }
51
55
  /** Best-effort decode of a non-2xx body (JSON when declared, else text; undefined on failure). */
52
56
  export async function readError(response) {
@@ -1 +1 @@
1
- {"version":3,"file":"parse.js","sourceRoot":"","sources":["../../src/runtime/parse.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,QAAkB,EAAE,IAAsB;IACpE,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACpB,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAA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C;IAC1C,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,OAAO,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1C,CAAC;AAED,kGAAkG;AAClG,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAkB;IAChD,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IAC/D,IAAI,WAAW,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/C,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;AAChD,CAAC"}
package/lib/types.d.ts CHANGED
@@ -3,7 +3,7 @@ import type { ArgsStyle } from './emitters/emit-options.js';
3
3
  import type { PaginationConfig } from './emitters/pagination.js';
4
4
  import type { CustomGenerator, OutputMode } from './generators/types.js';
5
5
  export type GenerateClientOptions = {
6
- /** Path or URL to the OpenAPI document (or an `apis:` alias from `redocly.yaml`). */
6
+ /** Path or URL to the OpenAPI description (or an `apis:` alias from `redocly.yaml`). */
7
7
  api: string;
8
8
  output: string;
9
9
  /** Resolved Redocly config for spec loading. */
@@ -22,7 +22,7 @@ export type GenerateClientOptions = {
22
22
  argsStyle?: ArgsStyle;
23
23
  /**
24
24
  * Override the BASE URL inlined into the generated runtime. When omitted,
25
- * the value is derived from `servers[0].url` in the source OpenAPI document.
25
+ * the value is derived from `servers[0].url` in the source OpenAPI description.
26
26
  * Validation (e.g. `new URL(value)`) is the caller's responsibility — the
27
27
  * CLI handler validates before calling.
28
28
  */
@@ -53,6 +53,9 @@ export type GenerateClientOptions = {
53
53
  * `faker.seed(<n>)` so generated data is reproducible across runs. Ignored in static mode.
54
54
  */
55
55
  mockSeed?: number;
56
+ /** Leading element for every tanstack-query key — namespaces the cache when several
57
+ * generated APIs share one QueryClient (operationIds may collide across APIs). */
58
+ queryKeyPrefix?: string;
56
59
  /**
57
60
  * Generators to run, in order. Defaults to `['sdk']`. Each entry is a built-in name
58
61
  * (`sdk`/`zod`/`tanstack-query`/`swr`/`transformers`/`mock`), the `name` of an inline
@@ -71,8 +74,10 @@ export type GenerateClientOptions = {
71
74
  */
72
75
  configDir?: string;
73
76
  /**
74
- * Path to a publisher setup module (`export default defineClientSetup({ config, middleware })`)
75
- * baked into the generated client. Resolved against `configDir`. Works across all output modes.
77
+ * Path to a publisher setup module (a file default-exporting `{ config, middleware }`)
78
+ * that gets included into the generated client — pre-configures defaults such as the
79
+ * server URL, retries, headers, and middleware. Resolved against `configDir`. Works
80
+ * across all output modes.
76
81
  */
77
82
  setup?: string;
78
83
  /** Runtime distribution: 'inline' (default, self-contained) | 'package' (imports @redocly/client-generator). */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEjG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEzE,MAAM,MAAM,qBAAqB,GAAG;IAClC,qFAAqF;IACrF,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB;;;OAGG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB;;;;;OAKG;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AOG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,uEAAuE;IACvE,UAAU,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,EAAE,cAAc,CAAC;IACzB,mFAAmF;IACnF,OAAO,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;CACxC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/client-generator",
3
- "version": "0.0.0-snapshot.1785152186",
3
+ "version": "0.0.0-snapshot.1785166289",
4
4
  "description": "Generate typed, zero-dependency TypeScript clients (fetch, auth, retries, middleware, SSE) from OpenAPI descriptions.",
5
5
  "type": "module",
6
6
  "types": "lib/index.d.ts",
@@ -50,7 +50,7 @@
50
50
  "Roman Marshevskyi <roman.marshevskyy@redocly.com> (https://redocly.com/)"
51
51
  ],
52
52
  "dependencies": {
53
- "@redocly/openapi-core": "0.0.0-snapshot.1785152186"
53
+ "@redocly/openapi-core": "0.0.0-snapshot.1785166289"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "typescript": ">=5.5.0"