@redocly/client-generator 0.5.2 → 0.6.0
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/eject-assets/generators/cli/docs.ts +1 -1
- package/eject-assets/generators/cli/engine-source.ts +1 -1
- package/eject-assets/generators/cli/index.ts +2 -2
- package/eject-assets/generators/cli/render.ts +1 -1
- package/eject-assets/generators/go/client.ts +1 -1
- package/eject-assets/generators/go/descriptor.ts +2 -1
- package/eject-assets/generators/go/index.ts +2 -2
- package/eject-assets/generators/go/models.ts +1 -1
- package/eject-assets/generators/go/naming.ts +1 -1
- package/eject-assets/generators/go/operations.ts +1 -1
- package/eject-assets/generators/go/pagination.ts +1 -1
- package/eject-assets/generators/go/types.ts +1 -1
- package/eject-assets/generators/mock/faker.ts +1 -1
- package/eject-assets/generators/mock/index.ts +2 -2
- package/eject-assets/generators/mock/render.ts +1 -1
- package/eject-assets/generators/mock/sample.ts +1 -1
- package/eject-assets/generators/mock/values.ts +1 -1
- package/eject-assets/generators/php/client.ts +1 -1
- package/eject-assets/generators/php/descriptor.ts +2 -1
- package/eject-assets/generators/php/index.ts +2 -2
- package/eject-assets/generators/php/models.ts +1 -1
- package/eject-assets/generators/php/naming.ts +1 -1
- package/eject-assets/generators/php/operations.ts +1 -1
- package/eject-assets/generators/php/pagination.ts +1 -1
- package/eject-assets/generators/php/types.ts +1 -1
- package/eject-assets/generators/python/client.ts +1 -1
- package/eject-assets/generators/python/descriptor.ts +2 -1
- package/eject-assets/generators/python/index.ts +2 -2
- package/eject-assets/generators/python/models.ts +1 -1
- package/eject-assets/generators/python/naming.ts +1 -1
- package/eject-assets/generators/python/operations.ts +1 -1
- package/eject-assets/generators/python/pagination.ts +1 -1
- package/eject-assets/generators/python/types.ts +1 -1
- package/eject-assets/generators/swr/index.ts +2 -2
- package/eject-assets/generators/swr/render.ts +1 -1
- package/eject-assets/generators/tanstack-query/index.ts +2 -2
- package/eject-assets/generators/tanstack-query/render.ts +56 -9
- package/eject-assets/generators/transformers/index.ts +2 -2
- package/eject-assets/generators/transformers/render.ts +1 -1
- package/eject-assets/generators/typescript/banner.ts +1 -1
- package/eject-assets/generators/typescript/client.ts +1 -1
- package/eject-assets/generators/typescript/descriptor.ts +1 -1
- package/eject-assets/generators/typescript/index.ts +2 -2
- package/eject-assets/generators/typescript/inline-runtime.ts +1 -1
- package/eject-assets/generators/typescript/operation-signature.ts +1 -1
- package/eject-assets/generators/typescript/operation-types.ts +1 -1
- package/eject-assets/generators/typescript/operations.ts +1 -1
- package/eject-assets/generators/typescript/response-headers.ts +1 -1
- package/eject-assets/generators/typescript/type-guards.ts +1 -1
- package/eject-assets/generators/typescript/types.ts +1 -1
- package/eject-assets/generators/zod/index.ts +2 -2
- package/eject-assets/generators/zod/schemas.ts +1 -1
- package/eject-assets/skills/tanstack-query-generator/SKILL.md +5 -2
- package/eject-assets/skills/typescript-generator/SKILL.md +5 -0
- package/lib/authoring/pagination.d.ts +5 -4
- package/lib/authoring/pagination.d.ts.map +1 -1
- package/lib/authoring/pagination.js +32 -12
- package/lib/authoring/pagination.js.map +1 -1
- package/lib/authoring/reference-page.d.ts.map +1 -1
- package/lib/authoring/reference-page.js +3 -3
- package/lib/authoring/reference-page.js.map +1 -1
- package/lib/generators/go/descriptor.d.ts.map +1 -1
- package/lib/generators/go/descriptor.js +1 -0
- package/lib/generators/go/descriptor.js.map +1 -1
- package/lib/generators/php/descriptor.d.ts.map +1 -1
- package/lib/generators/php/descriptor.js +1 -0
- package/lib/generators/php/descriptor.js.map +1 -1
- package/lib/generators/python/descriptor.d.ts.map +1 -1
- package/lib/generators/python/descriptor.js +1 -0
- package/lib/generators/python/descriptor.js.map +1 -1
- package/lib/generators/tanstack-query/render.d.ts.map +1 -1
- package/lib/generators/tanstack-query/render.js +48 -7
- package/lib/generators/tanstack-query/render.js.map +1 -1
- package/lib/generators/typescript/runtime/create-client.d.ts +1 -1
- package/lib/generators/typescript/runtime/create-client.d.ts.map +1 -1
- package/lib/generators/typescript/runtime/create-client.js +2 -2
- package/lib/generators/typescript/runtime/create-client.js.map +1 -1
- package/lib/generators/typescript/runtime/paginate.d.ts +9 -7
- package/lib/generators/typescript/runtime/paginate.d.ts.map +1 -1
- package/lib/generators/typescript/runtime/paginate.js +18 -12
- package/lib/generators/typescript/runtime/paginate.js.map +1 -1
- package/lib/generators/typescript/runtime/send.d.ts.map +1 -1
- package/lib/generators/typescript/runtime/send.js +44 -10
- package/lib/generators/typescript/runtime/send.js.map +1 -1
- package/lib/pagination.d.ts +17 -5
- package/lib/pagination.d.ts.map +1 -1
- package/lib/pagination.js +26 -6
- package/lib/pagination.js.map +1 -1
- package/lib/reserved-names.d.ts.map +1 -1
- package/lib/reserved-names.js +1 -0
- package/lib/reserved-names.js.map +1 -1
- package/lib/runtime-sources/go.d.ts +1 -1
- package/lib/runtime-sources/go.d.ts.map +1 -1
- package/lib/runtime-sources/go.js +1 -1
- package/lib/runtime-sources/go.js.map +1 -1
- package/lib/runtime-sources/php.d.ts +1 -1
- package/lib/runtime-sources/php.d.ts.map +1 -1
- package/lib/runtime-sources/php.js +1 -1
- package/lib/runtime-sources/php.js.map +1 -1
- package/lib/runtime-sources/python.d.ts +1 -1
- package/lib/runtime-sources/python.js +1 -1
- package/lib/runtime-sources/python.js.map +1 -1
- package/lib/runtime-sources/typescript.d.ts +9 -9
- package/lib/runtime-sources/typescript.d.ts.map +1 -1
- package/lib/runtime-sources/typescript.js +10 -8
- package/lib/runtime-sources/typescript.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paginate.d.ts","sourceRoot":"","sources":["../../../../src/generators/typescript/runtime/paginate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAc,cAAc,EAAE,MAAM,YAAY,CAAC;AAE7E;;;;;;;;;;GAUG;AAEH;;;;GAIG;AACH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EACtC,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,cAAc,EACpB,IAAI,CAAC,EAAE,aAAa,EACpB,IAAI,CAAC,EAAE,cAAc,GACpB,cAAc,CAAC,KAAK,CAAC,CAKvB"}
|
|
@@ -74,9 +74,9 @@ export async function* pages(call, spec, args = {}, init) {
|
|
|
74
74
|
cursor = next;
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
else if (spec.style === 'link') {
|
|
78
|
-
//
|
|
79
|
-
// cannot carry — the client wires those operations to `pagesByLink
|
|
77
|
+
else if (spec.style === 'link' || spec.style === 'body-link') {
|
|
78
|
+
// Link iteration needs the response's `Link` header and the page URL, which the
|
|
79
|
+
// parsed-page `call` cannot carry — the client wires those operations to `pagesByLink`.
|
|
80
80
|
throw new Error('link-style pagination iterates via pagesByLink');
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
@@ -137,22 +137,28 @@ export function linkNext(header) {
|
|
|
137
137
|
return undefined;
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
|
-
* Iterate a `link`-style operation's pages: follow the
|
|
141
|
-
*
|
|
142
|
-
*
|
|
140
|
+
* Iterate a `link`- or `body-link`-style operation's pages: follow the next page's URL —
|
|
141
|
+
* the `Link` header's `rel="next"` target (`link`), or the value at the `nextLink` pointer
|
|
142
|
+
* (`body-link`) — by merging ITS query params into the next call. Every page goes through
|
|
143
|
+
* the same declared endpoint, so auth, middleware, and `serverUrl` handling apply
|
|
143
144
|
* unchanged, and credentials can never be handed to a cross-origin `next` URL.
|
|
144
|
-
* Stops when no
|
|
145
|
-
*
|
|
145
|
+
* Stops when there is no next URL (`body-link`: `undefined`/`null`/`''`); throws when a
|
|
146
|
+
* `nextLink` value is not a string, or when the link does not advance (the same target
|
|
147
|
+
* twice, or a self-link — an infinite-loop guard).
|
|
146
148
|
*/
|
|
147
|
-
export async function* pagesByLink(call, args = {}, init) {
|
|
149
|
+
export async function* pagesByLink(call, spec, args = {}, init) {
|
|
150
|
+
const pointer = spec.style === 'body-link' ? spec.nextLink : undefined;
|
|
148
151
|
let query = args.query;
|
|
149
152
|
let previous;
|
|
150
153
|
while (true) {
|
|
151
154
|
const { page, linkHeader, url } = await call({ ...args, query }, init);
|
|
152
155
|
yield page;
|
|
153
|
-
const target = linkNext(linkHeader);
|
|
154
|
-
if (target === undefined)
|
|
156
|
+
const target = pointer === undefined ? linkNext(linkHeader) : resolvePointer(page, pointer);
|
|
157
|
+
if (target === undefined || target === null || target === '')
|
|
155
158
|
return;
|
|
159
|
+
if (typeof target !== 'string') {
|
|
160
|
+
throw new Error(`Pagination link at ${pointer} is not a string`);
|
|
161
|
+
}
|
|
156
162
|
// A relative target resolves against the page's own URL (RFC 8288 §3.1) — which may
|
|
157
163
|
// itself be relative (relative `serverUrl`, mocked fetch), so both resolve against a
|
|
158
164
|
// placeholder origin. It never reaches the wire: only the target's query params
|
|
@@ -180,7 +186,7 @@ export async function* pagesByLink(call, args = {}, init) {
|
|
|
180
186
|
}
|
|
181
187
|
/** Iterate a `link`-style operation's individual items: each page's `items` pointer, flattened. */
|
|
182
188
|
export async function* itemsByLink(call, spec, args, init) {
|
|
183
|
-
for await (const page of pagesByLink(call, args, init)) {
|
|
189
|
+
for await (const page of pagesByLink(call, spec, args, init)) {
|
|
184
190
|
const pageItems = resolvePointer(page, spec.items);
|
|
185
191
|
if (Array.isArray(pageItems))
|
|
186
192
|
yield* pageItems;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paginate.js","sourceRoot":"","sources":["../../../../src/generators/typescript/runtime/paginate.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AAEH;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc,EAAE,OAAe;IAC5D,IAAI,OAAO,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC;IACjC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC;IAC/C,IAAI,OAAO,GAAG,KAA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,CAWvF;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,EAAE,CAMlE;
|
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../../../src/generators/typescript/runtime/send.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,cAAc,EAEf,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,qEAAqE;IACrE,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,QAAQ,CAAC;CAClE,CAAC;AAEF;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAWvF;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,EAAE,CAMlE;AAsCD;;;;;;;GAOG;AACH,wBAAsB,IAAI,CACxB,MAAM,EAAE,YAAY,EACpB,EAAE,EAAE,gBAAgB,EACpB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,OAAO,GAAG,SAAS,EACzB,QAAQ,EAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,EAClE,IAAI,EAAE,gBAAgB,EACtB,MAAM,SAAqB,GAC1B,OAAO,CAAC;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,cAAc,CAAA;CAAE,CAAC,CAmK1D"}
|
|
@@ -28,6 +28,43 @@ export function middlewareChain(config) {
|
|
|
28
28
|
: [];
|
|
29
29
|
return [...single, ...(config.middleware ?? [])];
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* `AbortSignal.timeout()` where the platform has it, else an `AbortController` armed by
|
|
33
|
+
* `setTimeout`: Chrome before 103, Safari before 16, and Firefox before 100 lack the
|
|
34
|
+
* static, and every request with a timeout would throw before `fetch` runs.
|
|
35
|
+
*/
|
|
36
|
+
function timeoutSignal(ms) {
|
|
37
|
+
if (typeof AbortSignal.timeout === 'function')
|
|
38
|
+
return AbortSignal.timeout(ms);
|
|
39
|
+
const controller = new AbortController();
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
controller.abort(new DOMException(`Timed out after ${ms} ms`, 'TimeoutError'));
|
|
42
|
+
}, ms);
|
|
43
|
+
return controller.signal;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* `AbortSignal.any()` where the platform has it, else a controller that follows whichever
|
|
47
|
+
* signal aborts first: Chrome before 116, Safari before 17.4, and Firefox before 124 lack
|
|
48
|
+
* the static. The listeners come off once one signal fires, so a caller's long-lived
|
|
49
|
+
* signal does not keep one per request.
|
|
50
|
+
*/
|
|
51
|
+
function anySignal(signals) {
|
|
52
|
+
if (typeof AbortSignal.any === 'function')
|
|
53
|
+
return AbortSignal.any(signals);
|
|
54
|
+
const controller = new AbortController();
|
|
55
|
+
const listeners = new Map();
|
|
56
|
+
const abort = (reason) => {
|
|
57
|
+
for (const [signal, listener] of listeners)
|
|
58
|
+
signal.removeEventListener('abort', listener);
|
|
59
|
+
controller.abort(reason);
|
|
60
|
+
};
|
|
61
|
+
for (const signal of signals) {
|
|
62
|
+
const listener = () => abort(signal.reason);
|
|
63
|
+
listeners.set(signal, listener);
|
|
64
|
+
signal.addEventListener('abort', listener);
|
|
65
|
+
}
|
|
66
|
+
return controller.signal;
|
|
67
|
+
}
|
|
31
68
|
/**
|
|
32
69
|
* The fetch core shared by every operation: default + config + per-call headers, the
|
|
33
70
|
* `onRequest` chain (BEFORE body serialization, so mutations are sent), body
|
|
@@ -136,11 +173,8 @@ export async function send(config, op, url, init, body, bodySpec, caps, accept =
|
|
|
136
173
|
throw abortError(signal);
|
|
137
174
|
// A fresh timeout budget per attempt; the caller's signal still wins the race.
|
|
138
175
|
// The composed signal also governs reading the response body.
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
? AbortSignal.any([signal, AbortSignal.timeout(timeout)])
|
|
142
|
-
: AbortSignal.timeout(timeout)
|
|
143
|
-
: signal;
|
|
176
|
+
const budget = timeout ? timeoutSignal(timeout) : undefined;
|
|
177
|
+
const attemptSignal = budget && signal ? anySignal([signal, budget]) : (budget ?? signal);
|
|
144
178
|
let response;
|
|
145
179
|
try {
|
|
146
180
|
response = await doFetch(context.url, {
|
|
@@ -154,6 +188,10 @@ export async function send(config, op, url, init, body, bodySpec, caps, accept =
|
|
|
154
188
|
});
|
|
155
189
|
}
|
|
156
190
|
catch (error) {
|
|
191
|
+
// Decided before any await, when no timer can have fired since `fetch` rejected: an
|
|
192
|
+
// aborted budget means this attempt timed out. The abort reason's name is no
|
|
193
|
+
// evidence, because Chrome 103 to 123 abort a timeout with `AbortError`.
|
|
194
|
+
const timedOut = timeout !== undefined && budget?.aborted && !signal?.aborted;
|
|
157
195
|
if (attempt < maxAttempts &&
|
|
158
196
|
!signal?.aborted &&
|
|
159
197
|
(await retryOn({ attempt, request: context, error }))) {
|
|
@@ -162,12 +200,8 @@ export async function send(config, op, url, init, body, bodySpec, caps, accept =
|
|
|
162
200
|
}
|
|
163
201
|
// Our timeout fired (never the caller's own abort — that rethrows untouched):
|
|
164
202
|
// wrap the bare DOMException with the context a log line needs.
|
|
165
|
-
if (
|
|
166
|
-
!signal?.aborted &&
|
|
167
|
-
error instanceof DOMException &&
|
|
168
|
-
error.name === 'TimeoutError') {
|
|
203
|
+
if (timedOut)
|
|
169
204
|
throw new TimeoutError(op.id, timeout, attempt);
|
|
170
|
-
}
|
|
171
205
|
throw error;
|
|
172
206
|
}
|
|
173
207
|
// Reverse order: the last-registered middleware wraps closest to the network (onion).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"send.js","sourceRoot":"","sources":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C,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;oBACrD,QAAQ,GAAG,QAAQ,CAAC;gBACtB,CAAC;YACH,CAAC;QACH,CAAC;QACD,IACE,CAAC,QAAQ,CAAC,EAAE;YACZ,OAAO,GAAG,WAAW;YACrB,CAAC,MAAM,EAAE,OAAO;YAChB,CAAC,MAAM,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,EACxD,CAAC;YACD,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;YACvD,4EAA4E;YAC5E,8EAA8E;YAC9E,oFAAoF;YACpF,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YACrD,MAAM,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,CAAC;YAC5D,SAAS;QACX,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;IAC/B,CAAC;AACH,CAAC"}
|
package/lib/pagination.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ApiModel, type OperationModel, type SchemaModel } from './intermediate-representation/model.js';
|
|
2
2
|
/**
|
|
3
3
|
* How to auto-iterate a paginated operation (drives its `.pages()`/`.items()` members).
|
|
4
|
-
* `nextCursor` and `items` are RFC 6901 JSON pointers into the page (response) value.
|
|
4
|
+
* `nextCursor`, `nextLink`, and `items` are RFC 6901 JSON pointers into the page (response) value.
|
|
5
5
|
*/
|
|
6
6
|
export type PaginationSpec = {
|
|
7
7
|
style: 'cursor';
|
|
@@ -30,17 +30,27 @@ export type PaginationSpec = {
|
|
|
30
30
|
limitParam?: string;
|
|
31
31
|
/** Pointer to the page's item array. */
|
|
32
32
|
items: string;
|
|
33
|
+
} | {
|
|
34
|
+
/** Follow the next page's URL at `nextLink` in the page; stop when it is absent. */
|
|
35
|
+
style: 'body-link';
|
|
36
|
+
/** Optional page-size query param (recorded for tooling; never set by the runtime). */
|
|
37
|
+
limitParam?: string;
|
|
38
|
+
/** Pointer to the next page's URL in the page. */
|
|
39
|
+
nextLink: string;
|
|
40
|
+
/** Pointer to the page's item array. */
|
|
41
|
+
items: string;
|
|
33
42
|
};
|
|
34
43
|
/** The pagination styles the generated runtime can drive. */
|
|
35
|
-
export type PaginationStyle = 'cursor' | 'offset' | 'page' | 'link';
|
|
44
|
+
export type PaginationStyle = 'cursor' | 'offset' | 'page' | 'link' | 'body-link';
|
|
36
45
|
/**
|
|
37
46
|
* One user-facing pagination rule — the shared shape of the `x-redoclyPagination` operation
|
|
38
|
-
* extension and every `pagination` config rule. `nextCursor` and `items` are
|
|
39
|
-
* JSON pointers (starting with `/`) into the operation's success response.
|
|
47
|
+
* extension and every `pagination` config rule. `nextCursor`, `nextLink`, and `items` are
|
|
48
|
+
* RFC 6901 JSON pointers (starting with `/`) into the operation's success response.
|
|
40
49
|
*/
|
|
41
50
|
export type PaginationRule = {
|
|
42
51
|
/** `cursor` follows a response cursor; `offset`/`page` increment a numeric param;
|
|
43
|
-
* `link` follows the response's RFC 8288 `Link` header `rel="next"
|
|
52
|
+
* `link` follows the response's RFC 8288 `Link` header `rel="next"`; `body-link` follows
|
|
53
|
+
* the next page's URL at `nextLink` in the response. */
|
|
44
54
|
style: PaginationStyle;
|
|
45
55
|
/** Cursor style: the request query param that receives the cursor. */
|
|
46
56
|
cursorParam?: string;
|
|
@@ -54,6 +64,8 @@ export type PaginationRule = {
|
|
|
54
64
|
hasMore?: string;
|
|
55
65
|
/** Offset/page styles: the request query param the iterator advances. */
|
|
56
66
|
offsetParam?: string;
|
|
67
|
+
/** Body-link style: JSON pointer to the next page's URL in the response. */
|
|
68
|
+
nextLink?: string;
|
|
57
69
|
/** Optional page-size query param (any style; recorded for tooling). */
|
|
58
70
|
limitParam?: string;
|
|
59
71
|
/** JSON pointer to the page's item array in the response; `''` when the body IS the array. */
|
package/lib/pagination.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAWA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,WAAW,EACjB,MAAM,wCAAwC,CAAC;AAEhD;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB;IACE,KAAK,EAAE,QAAQ,CAAC;IAChB,wEAAwE;IACxE,KAAK,EAAE,MAAM,CAAC;IACd,uFAAuF;IACvF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,iFAAiF;IACjF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,KAAK,EAAE,QAAQ,GAAG,MAAM,CAAC;IACzB,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,uFAAuF;IACvF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,oFAAoF;IACpF,KAAK,EAAE,MAAM,CAAC;IACd,uFAAuF;IACvF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEN,6DAA6D;AAC7D,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAWA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,WAAW,EACjB,MAAM,wCAAwC,CAAC;AAEhD;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB;I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Q,CAAC,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8FAA8F;IAC9F,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,CAAC,cAAc,CAAC,GAAG;IACvD,2CAA2C;IAC3C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,iGAAiG;IACjG,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAC7C,CAAC;AAEF,0FAA0F;AAC1F,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,+EAA+E;AAC/E,MAAM,MAAM,eAAe,GAAG,GAAG,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,UAAU,EAAE,WAAW,CAAA;CAAE,CAAC,CAAC;AAE7F;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,EAAE,EAAE,cAAc,EAClB,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,gBAAgB,GAAG,SAAS,GACnC,kBAAkB,CAepB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,QAAQ,EACf,MAAM,EAAE,gBAAgB,GAAG,SAAS,GACnC,eAAe,CAcjB;AAuLD,oFAAoF;AACpF,OAAO,EAAE,eAAe,IAAI,oBAAoB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/lib/pagination.js
CHANGED
|
@@ -65,7 +65,7 @@ function applyRule(op, model, rule, source, explicit) {
|
|
|
65
65
|
const misfit = (problem) => explicit ? { error: `${label}: ${problem}` } : {};
|
|
66
66
|
if (op.sse !== undefined)
|
|
67
67
|
return misfit('the operation is a Server-Sent Events stream');
|
|
68
|
-
if (valid.style !== 'link') {
|
|
68
|
+
if (valid.style !== 'link' && valid.style !== 'body-link') {
|
|
69
69
|
const paramField = valid.style === 'cursor' ? 'cursorParam' : 'offsetParam';
|
|
70
70
|
const param = valid.style === 'cursor' ? valid.cursorParam : valid.offsetParam;
|
|
71
71
|
const advance = op.queryParams.find((p) => p.name === param);
|
|
@@ -113,6 +113,15 @@ function applyRule(op, model, rule, source, explicit) {
|
|
|
113
113
|
if (itemsTarget.kind !== 'array') {
|
|
114
114
|
return misfit(`the "items" pointer "${valid.items}" must point at an array (got ${itemsTarget.kind})`);
|
|
115
115
|
}
|
|
116
|
+
if (valid.style === 'body-link') {
|
|
117
|
+
const linkTarget = resolveSchemaPointer(page.schema, valid.nextLink, model);
|
|
118
|
+
if (linkTarget === undefined) {
|
|
119
|
+
return misfit(`the "nextLink" pointer "${valid.nextLink}" does not resolve in the success response schema`);
|
|
120
|
+
}
|
|
121
|
+
if (!isStringish(linkTarget, model)) {
|
|
122
|
+
return misfit(`the "nextLink" pointer "${valid.nextLink}" must point at a string (got ${linkTarget.kind})`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
116
125
|
if (valid.style === 'cursor') {
|
|
117
126
|
const cursorTarget = resolveSchemaPointer(page.schema, valid.nextCursor, model);
|
|
118
127
|
if (cursorTarget === undefined) {
|
|
@@ -143,7 +152,9 @@ function applyRule(op, model, rule, source, explicit) {
|
|
|
143
152
|
}
|
|
144
153
|
: valid.style === 'link'
|
|
145
154
|
? { style: 'link', ...limitParam, items: valid.items }
|
|
146
|
-
:
|
|
155
|
+
: valid.style === 'body-link'
|
|
156
|
+
? { style: 'body-link', ...limitParam, nextLink: valid.nextLink, items: valid.items }
|
|
157
|
+
: { style: valid.style, param: valid.offsetParam, ...limitParam, items: valid.items };
|
|
147
158
|
return { spec, itemSchema: itemsTarget.items };
|
|
148
159
|
}
|
|
149
160
|
/**
|
|
@@ -154,9 +165,13 @@ function applyRule(op, model, rule, source, explicit) {
|
|
|
154
165
|
function ruleShapeProblem(rule) {
|
|
155
166
|
if (!isPlainObject(rule))
|
|
156
167
|
return 'the rule must be an object';
|
|
157
|
-
const { style, cursorParam, nextCursor, hasMore, offsetParam, limitParam, items } = rule;
|
|
158
|
-
if (style !== 'cursor' &&
|
|
159
|
-
|
|
168
|
+
const { style, cursorParam, nextCursor, hasMore, offsetParam, nextLink, limitParam, items } = rule;
|
|
169
|
+
if (style !== 'cursor' &&
|
|
170
|
+
style !== 'offset' &&
|
|
171
|
+
style !== 'page' &&
|
|
172
|
+
style !== 'link' &&
|
|
173
|
+
style !== 'body-link') {
|
|
174
|
+
return `"style" must be one of "cursor" | "offset" | "page" | "link" | "body-link" (got ${JSON.stringify(style)})`;
|
|
160
175
|
}
|
|
161
176
|
if (typeof items !== 'string' || (items !== '' && !items.startsWith('/'))) {
|
|
162
177
|
return '"items" must be a JSON pointer starting with "/" (or "" when the response body is the item array itself)';
|
|
@@ -177,7 +192,12 @@ function ruleShapeProblem(rule) {
|
|
|
177
192
|
return `${style} style requires an "offsetParam" query parameter name`;
|
|
178
193
|
}
|
|
179
194
|
}
|
|
180
|
-
|
|
195
|
+
else if (style === 'body-link') {
|
|
196
|
+
if (typeof nextLink !== 'string' || !nextLink.startsWith('/')) {
|
|
197
|
+
return 'body-link style requires a "nextLink" JSON pointer starting with "/"';
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
// `link` and `body-link` need no advance parameter: the runtime follows the next page's URL.
|
|
181
201
|
if (limitParam !== undefined && typeof limitParam !== 'string') {
|
|
182
202
|
return '"limitParam" must be a query parameter name';
|
|
183
203
|
}
|
package/lib/pagination.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,kFAAkF;AAClF,uFAAuF;AACvF,mFAAmF;AACnF,mGAAmG;AACnG,oFAAoF;AACpF,kFAAkF;AAElF,OAAO,EAAE,aAAa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,QAAQ,CAAC;IACvE,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC5B,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE;YACrC,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YACtC,OAAO,CACL,QAAQ,KAAK,SAAS;gBACtB,CAAC,QAAQ,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,OAAO,IAAI,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAC1F,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reserved-names.d.ts","sourceRoot":"","sources":["../src/reserved-names.ts"],"names":[],"mappings":"AAYA,6FAA6F;AAC7F,eAAO,MAAM,YAAY,UA0BxB,CAAC;
|
|
1
|
+
{"version":3,"file":"reserved-names.d.ts","sourceRoot":"","sources":["../src/reserved-names.ts"],"names":[],"mappings":"AAYA,6FAA6F;AAC7F,eAAO,MAAM,YAAY,UA0BxB,CAAC;AAkFF;;;6EAG6E;AAC7E,wBAAgB,mBAAmB,IAAI,GAAG,CAAC,MAAM,CAAC,CAUjD"}
|
package/lib/reserved-names.js
CHANGED
|
@@ -59,6 +59,7 @@ const SATELLITE_NAMES = [
|
|
|
59
59
|
// the runtime's free identifiers with a scope walk and fails when this list falls
|
|
60
60
|
// behind. `undefined` is here because `export type undefined` would not even parse.
|
|
61
61
|
const GLOBAL_NAMES = [
|
|
62
|
+
'AbortController',
|
|
62
63
|
'AbortSignal',
|
|
63
64
|
'Array',
|
|
64
65
|
'ArrayBuffer',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reserved-names.js","sourceRoot":"","sources":["../src/reserved-names.ts"],"names":[],"mappings":"AAAA,+EAA+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V,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,aAAa;IACb,aAAa;IACb,WAAW;IACX,YAAY;IACZ,KAAK;IACL,iBAAiB;IACjB,MAAM;IACN,cAAc;IACd,QAAQ;IACR,oBAAoB;IACpB,UAAU;IACV,oBAAoB;IACpB,OAAO;IACP,YAAY;IACZ,YAAY;IACZ,WAAW;CACZ,CAAC;AAEF,IAAI,MAA+B,CAAC;AAEpC;;;6EAG6E;AAC7E,MAAM,UAAU,mBAAmB;IACjC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,GAAG,IAAI,GAAG,CAAC;YACf,GAAG,YAAY;YACf,GAAG,eAAe;YAClB,GAAG,YAAY;YACf,GAAG,sBAAsB;SAC1B,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
1
|
+
{"version":3,"file":"reserved-names.js","sourceRoot":"","sources":["../src/reserved-names.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,oFAAoF;AACpF,oFAAoF;AACpF,8EAA8E;AAC9E,oFAAoF;AACpF,iFAAiF;AACjF,mFAAmF;AACnF,mFAAmF;AACnF,sDAAsD;AAEtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAEzE,6FAA6F;AAC7F,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,QAAQ;IACR,YAAY;IACZ,KAAK;IACL,aAAa;IACb,eAAe;IACf,cAAc;IACd,cAAc;IACd,YAAY;IACZ,UAAU;IACV,cAAc;IACd,WAAW;IACX,KAAK;IACL,MAAM;IACN,gBAAgB;IAChB,cAAc;IACd,gBAAgB;IAChB,YAAY;IACZ,YAAY;IACZ,qBAAqB;IACrB,iBAAiB;IACjB,QAAQ;IACR,UAAU;IACV,gBAAgB;IAChB,eAAe;IACf,gBAAgB;CACjB,CAAC;AAEF,gFAAgF;AAChF,mFAAmF;AACnF,8BAA8B;AAC9B,MAAM,eAAe,GAAG;IACtB,GAAG;IACH,MAAM;IACN,cAAc;IACd,UAAU;IACV,OAAO;IACP,cAAc;IACd,QAAQ;IACR,gBAAgB;IAChB,YAAY;CACb,CAAC;AAEF,uFAAuF;AACvF,uFAAuF;AACvF,mFAAmF;AACnF,uFAAuF;AACvF,mFAAmF;AACnF,uFAAuF;AACvF,kFAAkF;AAClF,oFAAoF;AACpF,MAAM,YAAY,GAAG;IACnB,iBAAiB;IACjB,aAAa;IACb,OAAO;IACP,aAAa;IACb,iBAAiB;IACjB,gBAAgB;IAChB,eAAe;IACf,MAAM;IACN,UAAU;IACV,SAAS;IACT,cAAc;IACd,MAAM;IACN,OAAO;IACP,SAAS;IACT,UAAU;IACV,SAAS;IACT,aAAa;IACb,MAAM;IACN,KAAK;IACL,MAAM;IACN,aAAa;IACb,QAAQ;IACR,QAAQ;IACR,MAAM;IACN,SAAS;IACT,SAAS;IACT,gBAAgB;IAChB,QAAQ;IACR,QAAQ;IACR,iBAAiB;IACjB,SAAS;IACT,aAAa;IACb,UAAU;IACV,KAAK;IACL,QAAQ;IACR,QAAQ;IACR,aAAa;IACb,aAAa;IACb,WAAW;IACX,YAAY;IACZ,KAAK;IACL,iBAAiB;IACjB,MAAM;IACN,cAAc;IACd,QAAQ;IACR,oBAAoB;IACpB,UAAU;IACV,oBAAoB;IACpB,OAAO;IACP,YAAY;IACZ,YAAY;IACZ,WAAW;CACZ,CAAC;AAEF,IAAI,MAA+B,CAAC;AAEpC;;;6EAG6E;AAC7E,MAAM,UAAU,mBAAmB;IACjC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,GAAG,IAAI,GAAG,CAAC;YACf,GAAG,YAAY;YACf,GAAG,eAAe;YAClB,GAAG,YAAY;YACf,GAAG,sBAAsB;SAC1B,CAAC,CAAC;IACL,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const GO_RUNTIME_SOURCE = "// Package client \u2014 the embedded runtime for generated Go SDKs. Hand-authored\n// once and stitched into every generated client (see\n// scripts/generate-runtime-sources.mjs), semantically in lockstep with the\n// TypeScript runtime: auth OR-alternatives, a retry loop with Retry-After and\n// full-jitter backoff, per-attempt timeouts, idempotency keys, and middleware\n// hooks. Standard library only \u2014 a generated Go SDK has zero dependencies.\npackage client\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"encoding/base64\"\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math/rand\"\n\t\"mime/multipart\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n)\n\n// APIError is returned for a non-2xx response, carrying the decoded error body.\ntype APIError struct {\n\tURL string\n\tStatus int\n\tStatusText string\n\tBody any\n}\n\nfunc (e *APIError) Error() string {\n\treturn fmt.Sprintf(\"request failed with status %d\", e.Status)\n}\n\n// TimeoutError is returned when a request attempt exceeds the configured\n// timeout \u2014 carrying the context a log line needs.\ntype TimeoutError struct {\n\tOperationID string\n\tTimeout time.Duration\n\tAttempt int\n}\n\nfunc (e *TimeoutError) Error() string {\n\treturn fmt.Sprintf(\"request %q timed out after %s (attempt %d)\", e.OperationID, e.Timeout, e.Attempt)\n}\n\n// SecuritySpec mirrors the descriptor table's security entries.\ntype SecuritySpec struct {\n\tScheme string\n\tKind string // \"bearer\" | \"basic\" | \"apiKey\"\n\tName string // header/query/cookie name for apiKey\n\tIn string // \"header\" | \"query\" | \"cookie\"\n}\n\n// Auth holds the client credentials; zero value = anonymous.\ntype Auth struct {\n\tBearer func() string\n\tBasic *BasicAuth\n\tAPIKey map[string]func() string\n}\n\ntype BasicAuth struct {\n\tUsername string\n\tPassword string\n}\n\n// RetryConfig mirrors the TypeScript runtime's retry policy knobs.\ntype RetryConfig struct {\n\tRetries int\n\tRetryDelay time.Duration // base; default 1s\n\tRetryStrategy string // \"\" (exponential) | \"fixed\"\n\tNoJitter bool\n\t// RetryOn fully replaces the default predicate when set.\n\tRetryOn func(attempt int, resp *http.Response, err error) bool\n}\n\n// Middleware hooks run around every request (OnRequest before serialization order\n// is N/A in Go \u2014 bodies are values; OnResponse runs in reverse registration order).\ntype Middleware struct {\n\tOnRequest func(req *http.Request)\n\tOnResponse func(resp *http.Response)\n}\n\n// Date is an RFC 3339 full-date \u2014 a calendar date with no time component. Fields\n// typed `date` under `dateType: Date` use it because encoding/json speaks only\n// RFC 3339 date-time for time.Time, which a bare \"2006-01-02\" fails to satisfy.\ntype Date struct {\n\ttime.Time\n}\n\nconst dateLayout = \"2006-01-02\"\n\n// UnmarshalJSON parses a \"2006-01-02\" string; an empty string leaves the zero value.\nfunc (d *Date) UnmarshalJSON(data []byte) error {\n\tvar raw string\n\tif err := json.Unmarshal(data, &raw); err != nil {\n\t\treturn err\n\t}\n\tif raw == \"\" {\n\t\treturn nil\n\t}\n\tparsed, err := time.Parse(dateLayout, raw)\n\tif err != nil {\n\t\treturn err\n\t}\n\td.Time = parsed\n\treturn nil\n}\n\n// MarshalJSON writes the date back without a time component.\nfunc (d Date) MarshalJSON() ([]byte, error) {\n\treturn json.Marshal(d.Format(dateLayout))\n}\n\n// Config is the per-client configuration shared by every operation method.\ntype Config struct {\n\tServerURL string\n\tHTTPClient *http.Client\n\tHeaders map[string]string\n\tTimeout time.Duration\n\tRetry RetryConfig\n\tMiddleware []Middleware\n\tIdempotencyKey func() string\n\tAuth Auth\n}\n\nfunc resolveToken(provider func() string) string {\n\tif provider == nil {\n\t\treturn \"\"\n\t}\n\treturn provider()\n}\n\nfunc schemeConfigured(spec SecuritySpec, auth Auth) bool {\n\tswitch spec.Kind {\n\tcase \"apiKey\":\n\t\t_, ok := auth.APIKey[spec.Scheme]\n\t\treturn ok\n\tcase \"bearer\":\n\t\treturn auth.Bearer != nil\n\tdefault:\n\t\treturn auth.Basic != nil\n\t}\n}\n\n// resolveAuth applies the first fully-configured OR-alternative; when none is,\n// the first alternative's configured schemes are still sent (the server rejects\n// the request \u2014 same behavior as the TypeScript runtime).\nfunc resolveAuth(security [][]SecuritySpec, auth Auth) (map[string]string, url.Values) {\n\theaders := map[string]string{}\n\tquery := url.Values{}\n\tif len(security) == 0 {\n\t\treturn headers, query\n\t}\n\talternative := security[0]\n\tfor _, candidate := range security {\n\t\tall := true\n\t\tfor _, spec := range candidate {\n\t\t\tif !schemeConfigured(spec, auth) {\n\t\t\t\tall = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif all {\n\t\t\talternative = candidate\n\t\t\tbreak\n\t\t}\n\t}\n\tvar cookies []string\n\tfor _, spec := range alternative {\n\t\tswitch spec.Kind {\n\t\tcase \"apiKey\":\n\t\t\tprovider, ok := auth.APIKey[spec.Scheme]\n\t\t\tif !ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tvalue := resolveToken(provider)\n\t\t\tswitch spec.In {\n\t\t\tcase \"query\":\n\t\t\t\tquery.Set(spec.Name, value)\n\t\t\tcase \"cookie\":\n\t\t\t\tcookies = append(cookies, spec.Name+\"=\"+url.QueryEscape(value))\n\t\t\tdefault:\n\t\t\t\theaders[spec.Name] = value\n\t\t\t}\n\t\tcase \"bearer\":\n\t\t\tif auth.Bearer != nil {\n\t\t\t\theaders[\"Authorization\"] = \"Bearer \" + resolveToken(auth.Bearer)\n\t\t\t}\n\t\tdefault:\n\t\t\tif auth.Basic != nil {\n\t\t\t\ttoken := base64.StdEncoding.EncodeToString([]byte(auth.Basic.Username + \":\" + auth.Basic.Password))\n\t\t\t\theaders[\"Authorization\"] = \"Basic \" + token\n\t\t\t}\n\t\t}\n\t}\n\tif len(cookies) > 0 {\n\t\theaders[\"Cookie\"] = strings.Join(cookies, \"; \")\n\t}\n\treturn headers, query\n}\n\n// buildURL substitutes {param} path placeholders with percent-encoded values.\nfunc buildURL(serverURL, path string, pathParams map[string]string) string {\n\tfilled := path\n\tfor name, value := range pathParams {\n\t\tfilled = strings.ReplaceAll(filled, \"{\"+name+\"}\", url.PathEscape(value))\n\t}\n\treturn strings.TrimRight(serverURL, \"/\") + filled\n}\n\nvar transientStatus = map[int]bool{408: true, 429: true, 500: true, 502: true, 503: true, 504: true}\n\nfunc defaultRetryOn(method string, headers map[string]string, resp *http.Response, err error) bool {\n\tsafe := false\n\tswitch strings.ToUpper(method) {\n\tcase \"GET\", \"HEAD\", \"PUT\", \"DELETE\", \"OPTIONS\":\n\t\tsafe = true\n\t}\n\tif _, ok := headers[\"Idempotency-Key\"]; ok {\n\t\tsafe = true\n\t}\n\tif !safe {\n\t\treturn false\n\t}\n\tif err != nil {\n\t\treturn true\n\t}\n\treturn resp != nil && transientStatus[resp.StatusCode]\n}\n\nfunc retryDelay(retry RetryConfig, attempt int, retryAfter string) time.Duration {\n\tif retryAfter != \"\" {\n\t\tif seconds, err := strconv.ParseFloat(retryAfter, 64); err == nil {\n\t\t\treturn time.Duration(seconds * float64(time.Second))\n\t\t}\n\t}\n\tbase := retry.RetryDelay\n\tif base == 0 {\n\t\tbase = time.Second\n\t}\n\traw := base\n\tif retry.RetryStrategy != \"fixed\" {\n\t\traw = base * time.Duration(1<<(attempt-1))\n\t}\n\tif retry.NoJitter {\n\t\treturn raw\n\t}\n\treturn time.Duration(rand.Int63n(int64(raw) + 1))\n}\n\ntype requestSpec struct {\n\tOperationID string\n\tMethod string\n\tURL string\n\tHeaders map[string]string\n\tQuery url.Values\n\tBody io.Reader\n\t// Stream sends Body as is: no buffering, one attempt, the caller's Content-Type.\n\tStream bool\n\tContentType string\n\tTimeout time.Duration\n\tRetry *RetryConfig\n\tIdempotencyKey string\n\t// bodyBytes is retained so retries can replay the body.\n\tbodyBytes []byte\n}\n\n// send is the request core: header merge, idempotency keys, the retry loop\n// (fresh timeout budget per attempt), and the middleware onion.\nfunc send(ctx context.Context, config *Config, spec requestSpec) (*http.Response, error) {\n\tretry := config.Retry\n\tif spec.Retry != nil {\n\t\tretry = *spec.Retry\n\t}\n\ttimeout := config.Timeout\n\tif spec.Timeout != 0 {\n\t\ttimeout = spec.Timeout\n\t}\n\theaders := map[string]string{}\n\tfor key, value := range config.Headers {\n\t\theaders[key] = value\n\t}\n\tfor key, value := range spec.Headers {\n\t\theaders[key] = value\n\t}\n\tmethod := strings.ToUpper(spec.Method)\n\tif (method == \"POST\" || method == \"PATCH\") && headers[\"Idempotency-Key\"] == \"\" {\n\t\tif spec.IdempotencyKey != \"\" {\n\t\t\theaders[\"Idempotency-Key\"] = spec.IdempotencyKey\n\t\t} else if config.IdempotencyKey != nil {\n\t\t\theaders[\"Idempotency-Key\"] = config.IdempotencyKey()\n\t\t}\n\t}\n\thttpClient := config.HTTPClient\n\tif httpClient == nil {\n\t\thttpClient = http.DefaultClient\n\t}\n\tif spec.Body != nil && !spec.Stream {\n\t\tpayload, err := io.ReadAll(spec.Body)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tspec.bodyBytes = payload\n\t}\n\tfullURL := spec.URL\n\tif len(spec.Query) > 0 {\n\t\tseparator := \"?\"\n\t\tif strings.Contains(fullURL, \"?\") {\n\t\t\tseparator = \"&\"\n\t\t}\n\t\tfullURL += separator + spec.Query.Encode()\n\t}\n\tmaxAttempts := 1 + retry.Retries\n\tif spec.Stream {\n\t\t// The first attempt consumes the reader, so there is nothing to replay.\n\t\tmaxAttempts = 1\n\t}\n\tfor attempt := 1; ; attempt++ {\n\t\tattemptCtx := ctx\n\t\tvar cancel context.CancelFunc\n\t\tif timeout > 0 {\n\t\t\tattemptCtx, cancel = context.WithTimeout(ctx, timeout)\n\t\t}\n\t\tvar bodyReader io.Reader\n\t\tswitch {\n\t\tcase spec.Stream:\n\t\t\tbodyReader = spec.Body\n\t\tcase spec.bodyBytes != nil:\n\t\t\tbodyReader = bytes.NewReader(spec.bodyBytes)\n\t\t}\n\t\treq, err := http.NewRequestWithContext(attemptCtx, method, fullURL, bodyReader)\n\t\tif err != nil {\n\t\t\tif cancel != nil {\n\t\t\t\tcancel()\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\t\tfor key, value := range headers {\n\t\t\treq.Header.Set(key, value)\n\t\t}\n\t\tif spec.ContentType != \"\" && bodyReader != nil && req.Header.Get(\"Content-Type\") == \"\" {\n\t\t\treq.Header.Set(\"Content-Type\", spec.ContentType)\n\t\t}\n\t\tfor _, mw := range config.Middleware {\n\t\t\tif mw.OnRequest != nil {\n\t\t\t\tmw.OnRequest(req)\n\t\t\t}\n\t\t}\n\t\tresp, err := httpClient.Do(req)\n\t\tshouldRetry := retry.RetryOn\n\t\tretryable := false\n\t\tif shouldRetry != nil {\n\t\t\tretryable = shouldRetry(attempt, resp, err)\n\t\t} else {\n\t\t\tretryable = defaultRetryOn(method, headers, resp, err)\n\t\t}\n\t\tif err != nil {\n\t\t\tif cancel != nil {\n\t\t\t\tcancel()\n\t\t\t}\n\t\t\ttimedOut := errors.Is(err, context.DeadlineExceeded) && ctx.Err() == nil\n\t\t\tif attempt < maxAttempts && retryable {\n\t\t\t\ttime.Sleep(retryDelay(retry, attempt, \"\"))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif timedOut {\n\t\t\t\treturn nil, &TimeoutError{OperationID: spec.OperationID, Timeout: timeout, Attempt: attempt}\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\t\tfor i := len(config.Middleware) - 1; i >= 0; i-- {\n\t\t\tif config.Middleware[i].OnResponse != nil {\n\t\t\t\tconfig.Middleware[i].OnResponse(resp)\n\t\t\t}\n\t\t}\n\t\tif resp.StatusCode >= 400 && attempt < maxAttempts && retryable {\n\t\t\tafter := resp.Header.Get(\"Retry-After\")\n\t\t\tio.Copy(io.Discard, resp.Body)\n\t\t\tresp.Body.Close()\n\t\t\tif cancel != nil {\n\t\t\t\tcancel()\n\t\t\t}\n\t\t\ttime.Sleep(retryDelay(retry, attempt, after))\n\t\t\tcontinue\n\t\t}\n\t\t// The response body outlives this call; tie the attempt context's lifetime to it.\n\t\tif cancel != nil {\n\t\t\tresp.Body = &cancelOnClose{ReadCloser: resp.Body, cancel: cancel}\n\t\t}\n\t\treturn resp, nil\n\t}\n}\n\ntype cancelOnClose struct {\n\tio.ReadCloser\n\tcancel context.CancelFunc\n}\n\nfunc (c *cancelOnClose) Close() error {\n\tc.cancel()\n\treturn c.ReadCloser.Close()\n}\n\n// decodeJSON decodes a response body into target; a nil target drains and closes.\nfunc decodeJSON(resp *http.Response, target any) error {\n\tdefer resp.Body.Close()\n\tif target == nil {\n\t\t_, err := io.Copy(io.Discard, resp.Body)\n\t\treturn err\n\t}\n\treturn json.NewDecoder(resp.Body).Decode(target)\n}\n\n// headerString returns the named response header, or nil when absent.\nfunc headerString(header http.Header, name string) *string {\n\tvalue := header.Get(name)\n\tif value == \"\" {\n\t\treturn nil\n\t}\n\treturn &value\n}\n\n// headerInt64 parses the named header as an integer; nil when absent or unparsable.\nfunc headerInt64(header http.Header, name string) *int64 {\n\traw := strings.TrimSpace(header.Get(name))\n\tif raw == \"\" {\n\t\treturn nil\n\t}\n\tvalue, err := strconv.ParseInt(raw, 10, 64)\n\tif err != nil {\n\t\treturn nil\n\t}\n\treturn &value\n}\n\n// headerFloat64 parses the named header as a number; nil when absent or unparsable.\nfunc headerFloat64(header http.Header, name string) *float64 {\n\traw := strings.TrimSpace(header.Get(name))\n\tif raw == \"\" {\n\t\treturn nil\n\t}\n\tvalue, err := strconv.ParseFloat(raw, 64)\n\tif err != nil {\n\t\treturn nil\n\t}\n\treturn &value\n}\n\n// headerBool parses a `true`/`false` header; nil when absent or anything else.\nfunc headerBool(header http.Header, name string) *bool {\n\traw := strings.ToLower(strings.TrimSpace(header.Get(name)))\n\tif raw != \"true\" && raw != \"false\" {\n\t\treturn nil\n\t}\n\tvalue := raw == \"true\"\n\treturn &value\n}\n\n// apiErrorFrom builds the structured error for a non-2xx response.\nfunc apiErrorFrom(resp *http.Response, requestURL string) error {\n\tdefer resp.Body.Close()\n\tvar body any\n\tdata, _ := io.ReadAll(resp.Body)\n\tif len(data) > 0 {\n\t\tif err := json.Unmarshal(data, &body); err != nil {\n\t\t\tbody = string(data)\n\t\t}\n\t}\n\treturn &APIError{URL: requestURL, Status: resp.StatusCode, StatusText: resp.Status, Body: body}\n}\n\n// \u2500\u2500\u2500 Pagination \u2500\u2500\u2500\n\n// PaginationSpec mirrors the descriptor table's pagination entries.\ntype PaginationSpec struct {\n\tStyle string\n\tParam string\n\tNextCursor string\n\tHasMore string\n\tLimitParam string\n\tItems string\n}\n\n// resolvePointer walks an RFC 6901 JSON pointer over decoded JSON; nil on any miss.\nfunc resolvePointer(data any, pointer string) any {\n\tif pointer == \"\" {\n\t\treturn data\n\t}\n\tif !strings.HasPrefix(pointer, \"/\") {\n\t\treturn nil\n\t}\n\tcurrent := data\n\tfor _, token := range strings.Split(pointer[1:], \"/\") {\n\t\tkey := strings.ReplaceAll(strings.ReplaceAll(token, \"~1\", \"/\"), \"~0\", \"~\")\n\t\tswitch typed := current.(type) {\n\t\tcase map[string]any:\n\t\t\tcurrent = typed[key]\n\t\tcase []any:\n\t\t\tindex, err := strconv.Atoi(key)\n\t\t\tif err != nil || index < 0 || index >= len(typed) {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tcurrent = typed[index]\n\t\tdefault:\n\t\t\treturn nil\n\t\t}\n\t\tif current == nil {\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn current\n}\n\n// reencode converts decoded JSON (maps/slices) into a typed value via a JSON round-trip.\nfunc reencode(raw any, target any) error {\n\tdata, err := json.Marshal(raw)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn json.Unmarshal(data, target)\n}\n\ntype pageCall func(params url.Values) (any, *http.Response, error)\n\n// iterPages yields raw page JSON per the pagination spec \u2014 the same stop\n// conditions and infinite-loop guards as the TypeScript runtime. The returned\n// function is a range-over-func iterator (Go 1.23+) and plainly callable before that.\nfunc iterPages(call pageCall, spec PaginationSpec, base url.Values) func(yield func(any, error) bool) {\n\treturn func(yield func(any, error) bool) {\n\t\tswitch spec.Style {\n\t\tcase \"cursor\":\n\t\t\tvar cursor any\n\t\t\tif values, ok := base[spec.Param]; ok && len(values) > 0 {\n\t\t\t\tcursor = values[0]\n\t\t\t}\n\t\t\tfor {\n\t\t\t\tparams := cloneValues(base)\n\t\t\t\tif cursor != nil {\n\t\t\t\t\tparams.Set(spec.Param, fmt.Sprint(cursor))\n\t\t\t\t}\n\t\t\t\tpage, _, err := call(params)\n\t\t\t\tif err != nil {\n\t\t\t\t\tyield(nil, err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif !yield(page, nil) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif spec.HasMore != \"\" {\n\t\t\t\t\tif more, ok := resolvePointer(page, spec.HasMore).(bool); ok && !more {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnext := resolvePointer(page, spec.NextCursor)\n\t\t\t\tif next == nil || next == \"\" {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tswitch next.(type) {\n\t\t\t\tcase string, float64:\n\t\t\t\tdefault:\n\t\t\t\t\tyield(nil, fmt.Errorf(\"pagination cursor at %s is not a string or number\", spec.NextCursor))\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif cursor != nil && fmt.Sprint(next) == fmt.Sprint(cursor) {\n\t\t\t\t\tyield(nil, errors.New(\"pagination did not advance: the operation returned the same cursor twice\"))\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tcursor = next\n\t\t\t}\n\t\tcase \"link\":\n\t\t\tparams := cloneValues(base)\n\t\t\tprevious := \"\"\n\t\t\tfor {\n\t\t\t\tpage, resp, err := call(params)\n\t\t\t\tif err != nil {\n\t\t\t\t\tyield(nil, err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif !yield(page, nil) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\ttarget := linkNext(resp.Header.Get(\"Link\"))\n\t\t\t\tif target == \"\" {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tpageURL := \"\"\n\t\t\t\tif resp.Request != nil && resp.Request.URL != nil {\n\t\t\t\t\tpageURL = resp.Request.URL.String()\n\t\t\t\t}\n\t\t\t\tbaseURL, err := url.Parse(pageURL)\n\t\t\t\tif err != nil || pageURL == \"\" {\n\t\t\t\t\tbaseURL, _ = url.Parse(\"http://relative.invalid\")\n\t\t\t\t}\n\t\t\t\ttargetURL, err := baseURL.Parse(target)\n\t\t\t\tif err != nil {\n\t\t\t\t\tyield(nil, err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tnext := targetURL.String()\n\t\t\t\tif next == previous || next == pageURL {\n\t\t\t\t\tyield(nil, errors.New(`pagination did not advance: the Link rel=\"next\" target repeats`))\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tprevious = next\n\t\t\t\tparams = cloneValues(base)\n\t\t\t\tfor key, values := range targetURL.Query() {\n\t\t\t\t\tfor _, value := range values {\n\t\t\t\t\t\tparams.Add(key, value)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\tdefault: // offset / page\n\t\t\tposition := 0\n\t\t\tif spec.Style == \"page\" {\n\t\t\t\tposition = 1\n\t\t\t}\n\t\t\tif values, ok := base[spec.Param]; ok && len(values) > 0 && values[0] != \"\" {\n\t\t\t\tif parsed, err := strconv.Atoi(values[0]); err == nil {\n\t\t\t\t\tposition = parsed\n\t\t\t\t}\n\t\t\t}\n\t\t\tpreviousItems := \"\"\n\t\t\tfor {\n\t\t\t\tparams := cloneValues(base)\n\t\t\t\tparams.Set(spec.Param, strconv.Itoa(position))\n\t\t\t\tpage, _, err := call(params)\n\t\t\t\tif err != nil {\n\t\t\t\t\tyield(nil, err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\titems, _ := resolvePointer(page, spec.Items).([]any)\n\t\t\t\tserialized := \"\"\n\t\t\t\tif items != nil {\n\t\t\t\t\tserialized = fmt.Sprint(items)\n\t\t\t\t\tif serialized == previousItems {\n\t\t\t\t\t\tyield(nil, errors.New(\"pagination did not advance: the operation returned the same page twice\"))\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif !yield(page, nil) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif len(items) == 0 {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tpreviousItems = serialized\n\t\t\t\tif spec.Style == \"page\" {\n\t\t\t\t\tposition++\n\t\t\t\t} else {\n\t\t\t\t\tposition += len(items)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc cloneValues(values url.Values) url.Values {\n\tout := url.Values{}\n\tfor key, entries := range values {\n\t\tfor _, entry := range entries {\n\t\t\tout.Add(key, entry)\n\t\t}\n\t}\n\treturn out\n}\n\nfunc linkNext(header string) string {\n\tif header == \"\" {\n\t\treturn \"\"\n\t}\n\tfor _, entry := range strings.Split(header, \",\") {\n\t\tparts := strings.Split(entry, \";\")\n\t\tif len(parts) < 2 {\n\t\t\tcontinue\n\t\t}\n\t\ttarget := strings.TrimSpace(parts[0])\n\t\tif !strings.HasPrefix(target, \"<\") || !strings.HasSuffix(target, \">\") {\n\t\t\tcontinue\n\t\t}\n\t\tfor _, param := range parts[1:] {\n\t\t\ttrimmed := strings.TrimSpace(param)\n\t\t\tif strings.HasPrefix(trimmed, \"rel=\") {\n\t\t\t\trel := strings.Trim(strings.TrimPrefix(trimmed, \"rel=\"), `\"`)\n\t\t\t\tfor _, kind := range strings.Fields(rel) {\n\t\t\t\t\tif kind == \"next\" {\n\t\t\t\t\t\treturn strings.Trim(target, \"<>\")\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\"\n}\n\n// \u2500\u2500\u2500 Server-Sent Events \u2500\u2500\u2500\n\n// ServerSentEvent is one decoded event; Data is the raw text (or parsed JSON\n// for operations that declare a JSON event stream).\ntype ServerSentEvent struct {\n\tEvent string\n\tData any\n\tID string\n\tRetry int\n}\n\nfunc parseSSEFrame(raw string, jsonData bool) (ServerSentEvent, bool, error) {\n\tevent := ServerSentEvent{Retry: -1}\n\tsawField := false\n\tvar dataLines []string\n\tnormalized := strings.ReplaceAll(strings.ReplaceAll(raw, \"\\r\\n\", \"\\n\"), \"\\r\", \"\\n\")\n\tfor _, line := range strings.Split(normalized, \"\\n\") {\n\t\tif line == \"\" || strings.HasPrefix(line, \":\") {\n\t\t\tcontinue\n\t\t}\n\t\tfield, value, _ := strings.Cut(line, \":\")\n\t\tvalue = strings.TrimPrefix(value, \" \")\n\t\tsawField = true\n\t\tswitch field {\n\t\tcase \"event\":\n\t\t\tevent.Event = value\n\t\tcase \"data\":\n\t\t\tdataLines = append(dataLines, value)\n\t\tcase \"id\":\n\t\t\tevent.ID = value\n\t\tcase \"retry\":\n\t\t\tif parsed, err := strconv.Atoi(value); err == nil && parsed >= 0 && value != \"\" {\n\t\t\t\tevent.Retry = parsed\n\t\t\t}\n\t\t}\n\t}\n\tif !sawField {\n\t\treturn event, false, nil\n\t}\n\ttext := strings.Join(dataLines, \"\\n\")\n\tevent.Data = text\n\tif jsonData && text != \"\" {\n\t\tvar parsed any\n\t\tif err := json.Unmarshal([]byte(text), &parsed); err != nil {\n\t\t\treturn event, false, err\n\t\t}\n\t\tevent.Data = parsed\n\t}\n\treturn event, true, nil\n}\n\n// iterSSE streams events, reconnecting on dropped connections with Last-Event-ID\n// (a fresh open call = fresh auth); a 4xx/5xx or a bad JSON payload is definitive.\nfunc iterSSE(open func(extraHeaders map[string]string) (*http.Response, error), jsonData bool) func(yield func(ServerSentEvent, error) bool) {\n\treturn func(yield func(ServerSentEvent, error) bool) {\n\t\tlastEventID := \"\"\n\t\tserverRetry := -1\n\t\tfailures := 0\n\t\tfor {\n\t\t\theaders := map[string]string{\"Accept\": \"text/event-stream\"}\n\t\t\tif lastEventID != \"\" {\n\t\t\t\theaders[\"Last-Event-ID\"] = lastEventID\n\t\t\t}\n\t\t\tresp, err := open(headers)\n\t\t\tif err == nil && resp.StatusCode >= 400 {\n\t\t\t\tyield(ServerSentEvent{}, apiErrorFrom(resp, \"\"))\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif err == nil {\n\t\t\t\tfailures = 0\n\t\t\t\tbuffer := \"\"\n\t\t\t\tchunk := make([]byte, 4096)\n\t\t\t\tclean := false\n\t\t\t\tfor {\n\t\t\t\t\tn, readErr := resp.Body.Read(chunk)\n\t\t\t\t\tbuffer += string(chunk[:n])\n\t\t\t\t\tfor {\n\t\t\t\t\t\tframe, rest, found := strings.Cut(buffer, \"\\n\\n\")\n\t\t\t\t\t\tif !found {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbuffer = rest\n\t\t\t\t\t\tevent, ok, parseErr := parseSSEFrame(frame, jsonData)\n\t\t\t\t\t\tif parseErr != nil {\n\t\t\t\t\t\t\tresp.Body.Close()\n\t\t\t\t\t\t\tyield(ServerSentEvent{}, parseErr)\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ok {\n\t\t\t\t\t\t\tif event.ID != \"\" {\n\t\t\t\t\t\t\t\tlastEventID = event.ID\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif event.Retry >= 0 {\n\t\t\t\t\t\t\t\tserverRetry = event.Retry\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif !yield(event, nil) {\n\t\t\t\t\t\t\t\tresp.Body.Close()\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif readErr == io.EOF {\n\t\t\t\t\t\tclean = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tif readErr != nil {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tresp.Body.Close()\n\t\t\t\tif clean {\n\t\t\t\t\tif strings.TrimSpace(buffer) != \"\" {\n\t\t\t\t\t\tif event, ok, parseErr := parseSSEFrame(buffer, jsonData); parseErr == nil && ok {\n\t\t\t\t\t\t\tyield(event, nil)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tfailures++\n\t\t\tbase := time.Second\n\t\t\tif serverRetry >= 0 {\n\t\t\t\tbase = time.Duration(serverRetry) * time.Millisecond\n\t\t\t}\n\t\t\tdelay := base * time.Duration(1<<(failures-1))\n\t\t\tif delay > 30*time.Second {\n\t\t\t\tdelay = 30 * time.Second\n\t\t\t}\n\t\t\ttime.Sleep(time.Duration(rand.Int63n(int64(delay) + 1)))\n\t\t}\n\t}\n}\n\n// \u2500\u2500\u2500 Multipart \u2500\u2500\u2500\n\n// toMultipart splits a typed body into a multipart/form-data payload: []byte\n// values upload as file parts, everything else as form fields (nested values\n// JSON-encoded) \u2014 mirroring the TypeScript runtime's FormData serialization.\nfunc toMultipart(body any) (string, io.Reader, error) {\n\tvar wire map[string]any\n\tif err := reencode(body, &wire); err != nil {\n\t\treturn \"\", nil, err\n\t}\n\tbuffer := &bytes.Buffer{}\n\twriter := multipart.NewWriter(buffer)\n\tfor key, value := range wire {\n\t\tswitch typed := value.(type) {\n\t\tcase string:\n\t\t\tif err := writer.WriteField(key, typed); err != nil {\n\t\t\t\treturn \"\", nil, err\n\t\t\t}\n\t\tcase float64, bool:\n\t\t\tif err := writer.WriteField(key, fmt.Sprint(typed)); err != nil {\n\t\t\t\treturn \"\", nil, err\n\t\t\t}\n\t\tdefault:\n\t\t\tencoded, err := json.Marshal(typed)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", nil, err\n\t\t\t}\n\t\t\tif err := writer.WriteField(key, string(encoded)); err != nil {\n\t\t\t\treturn \"\", nil, err\n\t\t\t}\n\t\t}\n\t}\n\tif err := writer.Close(); err != nil {\n\t\treturn \"\", nil, err\n\t}\n\treturn writer.FormDataContentType(), buffer, nil\n}\n\n// multipartBody prepares the body of an untyped multipart operation: an io.Reader is\n// streamed and a []byte or string sent as is, all under the caller's Content-Type (the\n// boundary is theirs to set); any other value goes through toMultipart.\nfunc multipartBody(body any) (string, io.Reader, bool, error) {\n\tif reader, stream, raw := rawBody(body); raw {\n\t\treturn \"\", reader, stream, nil\n\t}\n\tcontentType, reader, err := toMultipart(body)\n\treturn contentType, reader, false, err\n}\n\n// binaryBody prepares the body of a binary operation: an io.Reader is streamed, a\n// []byte or string sent as is, and any other value JSON-marshalled.\nfunc binaryBody(body any) (io.Reader, bool, error) {\n\tif reader, stream, raw := rawBody(body); raw {\n\t\treturn reader, stream, nil\n\t}\n\tpayload, err := json.Marshal(body)\n\treturn bytes.NewReader(payload), false, err\n}\n\n// rawBody recognizes a body that needs no encoding: an io.Reader streams through in one\n// attempt, a []byte or a string is replayable bytes.\nfunc rawBody(body any) (io.Reader, bool, bool) {\n\tswitch typed := body.(type) {\n\tcase io.Reader:\n\t\treturn typed, true, true\n\tcase []byte:\n\t\treturn bytes.NewReader(typed), false, true\n\tcase string:\n\t\treturn strings.NewReader(typed), false, true\n\t}\n\treturn nil, false, false\n}\n";
|
|
1
|
+
export declare const GO_RUNTIME_SOURCE = "// Package client \u2014 the embedded runtime for generated Go SDKs. Hand-authored\n// once and stitched into every generated client (see\n// scripts/generate-runtime-sources.mjs), semantically in lockstep with the\n// TypeScript runtime: auth OR-alternatives, a retry loop with Retry-After and\n// full-jitter backoff, per-attempt timeouts, idempotency keys, and middleware\n// hooks. Standard library only \u2014 a generated Go SDK has zero dependencies.\npackage client\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"encoding/base64\"\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"math/rand\"\n\t\"mime/multipart\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n)\n\n// APIError is returned for a non-2xx response, carrying the decoded error body.\ntype APIError struct {\n\tURL string\n\tStatus int\n\tStatusText string\n\tBody any\n}\n\nfunc (e *APIError) Error() string {\n\treturn fmt.Sprintf(\"request failed with status %d\", e.Status)\n}\n\n// TimeoutError is returned when a request attempt exceeds the configured\n// timeout \u2014 carrying the context a log line needs.\ntype TimeoutError struct {\n\tOperationID string\n\tTimeout time.Duration\n\tAttempt int\n}\n\nfunc (e *TimeoutError) Error() string {\n\treturn fmt.Sprintf(\"request %q timed out after %s (attempt %d)\", e.OperationID, e.Timeout, e.Attempt)\n}\n\n// SecuritySpec mirrors the descriptor table's security entries.\ntype SecuritySpec struct {\n\tScheme string\n\tKind string // \"bearer\" | \"basic\" | \"apiKey\"\n\tName string // header/query/cookie name for apiKey\n\tIn string // \"header\" | \"query\" | \"cookie\"\n}\n\n// Auth holds the client credentials; zero value = anonymous.\ntype Auth struct {\n\tBearer func() string\n\tBasic *BasicAuth\n\tAPIKey map[string]func() string\n}\n\ntype BasicAuth struct {\n\tUsername string\n\tPassword string\n}\n\n// RetryConfig mirrors the TypeScript runtime's retry policy knobs.\ntype RetryConfig struct {\n\tRetries int\n\tRetryDelay time.Duration // base; default 1s\n\tRetryStrategy string // \"\" (exponential) | \"fixed\"\n\tNoJitter bool\n\t// RetryOn fully replaces the default predicate when set.\n\tRetryOn func(attempt int, resp *http.Response, err error) bool\n}\n\n// Middleware hooks run around every request (OnRequest before serialization order\n// is N/A in Go \u2014 bodies are values; OnResponse runs in reverse registration order).\ntype Middleware struct {\n\tOnRequest func(req *http.Request)\n\tOnResponse func(resp *http.Response)\n}\n\n// Date is an RFC 3339 full-date \u2014 a calendar date with no time component. Fields\n// typed `date` under `dateType: Date` use it because encoding/json speaks only\n// RFC 3339 date-time for time.Time, which a bare \"2006-01-02\" fails to satisfy.\ntype Date struct {\n\ttime.Time\n}\n\nconst dateLayout = \"2006-01-02\"\n\n// UnmarshalJSON parses a \"2006-01-02\" string; an empty string leaves the zero value.\nfunc (d *Date) UnmarshalJSON(data []byte) error {\n\tvar raw string\n\tif err := json.Unmarshal(data, &raw); err != nil {\n\t\treturn err\n\t}\n\tif raw == \"\" {\n\t\treturn nil\n\t}\n\tparsed, err := time.Parse(dateLayout, raw)\n\tif err != nil {\n\t\treturn err\n\t}\n\td.Time = parsed\n\treturn nil\n}\n\n// MarshalJSON writes the date back without a time component.\nfunc (d Date) MarshalJSON() ([]byte, error) {\n\treturn json.Marshal(d.Format(dateLayout))\n}\n\n// Config is the per-client configuration shared by every operation method.\ntype Config struct {\n\tServerURL string\n\tHTTPClient *http.Client\n\tHeaders map[string]string\n\tTimeout time.Duration\n\tRetry RetryConfig\n\tMiddleware []Middleware\n\tIdempotencyKey func() string\n\tAuth Auth\n}\n\nfunc resolveToken(provider func() string) string {\n\tif provider == nil {\n\t\treturn \"\"\n\t}\n\treturn provider()\n}\n\nfunc schemeConfigured(spec SecuritySpec, auth Auth) bool {\n\tswitch spec.Kind {\n\tcase \"apiKey\":\n\t\t_, ok := auth.APIKey[spec.Scheme]\n\t\treturn ok\n\tcase \"bearer\":\n\t\treturn auth.Bearer != nil\n\tdefault:\n\t\treturn auth.Basic != nil\n\t}\n}\n\n// resolveAuth applies the first fully-configured OR-alternative; when none is,\n// the first alternative's configured schemes are still sent (the server rejects\n// the request \u2014 same behavior as the TypeScript runtime).\nfunc resolveAuth(security [][]SecuritySpec, auth Auth) (map[string]string, url.Values) {\n\theaders := map[string]string{}\n\tquery := url.Values{}\n\tif len(security) == 0 {\n\t\treturn headers, query\n\t}\n\talternative := security[0]\n\tfor _, candidate := range security {\n\t\tall := true\n\t\tfor _, spec := range candidate {\n\t\t\tif !schemeConfigured(spec, auth) {\n\t\t\t\tall = false\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif all {\n\t\t\talternative = candidate\n\t\t\tbreak\n\t\t}\n\t}\n\tvar cookies []string\n\tfor _, spec := range alternative {\n\t\tswitch spec.Kind {\n\t\tcase \"apiKey\":\n\t\t\tprovider, ok := auth.APIKey[spec.Scheme]\n\t\t\tif !ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tvalue := resolveToken(provider)\n\t\t\tswitch spec.In {\n\t\t\tcase \"query\":\n\t\t\t\tquery.Set(spec.Name, value)\n\t\t\tcase \"cookie\":\n\t\t\t\tcookies = append(cookies, spec.Name+\"=\"+url.QueryEscape(value))\n\t\t\tdefault:\n\t\t\t\theaders[spec.Name] = value\n\t\t\t}\n\t\tcase \"bearer\":\n\t\t\tif auth.Bearer != nil {\n\t\t\t\theaders[\"Authorization\"] = \"Bearer \" + resolveToken(auth.Bearer)\n\t\t\t}\n\t\tdefault:\n\t\t\tif auth.Basic != nil {\n\t\t\t\ttoken := base64.StdEncoding.EncodeToString([]byte(auth.Basic.Username + \":\" + auth.Basic.Password))\n\t\t\t\theaders[\"Authorization\"] = \"Basic \" + token\n\t\t\t}\n\t\t}\n\t}\n\tif len(cookies) > 0 {\n\t\theaders[\"Cookie\"] = strings.Join(cookies, \"; \")\n\t}\n\treturn headers, query\n}\n\n// buildURL substitutes {param} path placeholders with percent-encoded values.\nfunc buildURL(serverURL, path string, pathParams map[string]string) string {\n\tfilled := path\n\tfor name, value := range pathParams {\n\t\tfilled = strings.ReplaceAll(filled, \"{\"+name+\"}\", url.PathEscape(value))\n\t}\n\treturn strings.TrimRight(serverURL, \"/\") + filled\n}\n\nvar transientStatus = map[int]bool{408: true, 429: true, 500: true, 502: true, 503: true, 504: true}\n\nfunc defaultRetryOn(method string, headers map[string]string, resp *http.Response, err error) bool {\n\tsafe := false\n\tswitch strings.ToUpper(method) {\n\tcase \"GET\", \"HEAD\", \"PUT\", \"DELETE\", \"OPTIONS\":\n\t\tsafe = true\n\t}\n\tif _, ok := headers[\"Idempotency-Key\"]; ok {\n\t\tsafe = true\n\t}\n\tif !safe {\n\t\treturn false\n\t}\n\tif err != nil {\n\t\treturn true\n\t}\n\treturn resp != nil && transientStatus[resp.StatusCode]\n}\n\nfunc retryDelay(retry RetryConfig, attempt int, retryAfter string) time.Duration {\n\tif retryAfter != \"\" {\n\t\tif seconds, err := strconv.ParseFloat(retryAfter, 64); err == nil {\n\t\t\treturn time.Duration(seconds * float64(time.Second))\n\t\t}\n\t}\n\tbase := retry.RetryDelay\n\tif base == 0 {\n\t\tbase = time.Second\n\t}\n\traw := base\n\tif retry.RetryStrategy != \"fixed\" {\n\t\traw = base * time.Duration(1<<(attempt-1))\n\t}\n\tif retry.NoJitter {\n\t\treturn raw\n\t}\n\treturn time.Duration(rand.Int63n(int64(raw) + 1))\n}\n\ntype requestSpec struct {\n\tOperationID string\n\tMethod string\n\tURL string\n\tHeaders map[string]string\n\tQuery url.Values\n\tBody io.Reader\n\t// Stream sends Body as is: no buffering, one attempt, the caller's Content-Type.\n\tStream bool\n\tContentType string\n\tTimeout time.Duration\n\tRetry *RetryConfig\n\tIdempotencyKey string\n\t// bodyBytes is retained so retries can replay the body.\n\tbodyBytes []byte\n}\n\n// send is the request core: header merge, idempotency keys, the retry loop\n// (fresh timeout budget per attempt), and the middleware onion.\nfunc send(ctx context.Context, config *Config, spec requestSpec) (*http.Response, error) {\n\tretry := config.Retry\n\tif spec.Retry != nil {\n\t\tretry = *spec.Retry\n\t}\n\ttimeout := config.Timeout\n\tif spec.Timeout != 0 {\n\t\ttimeout = spec.Timeout\n\t}\n\theaders := map[string]string{}\n\tfor key, value := range config.Headers {\n\t\theaders[key] = value\n\t}\n\tfor key, value := range spec.Headers {\n\t\theaders[key] = value\n\t}\n\tmethod := strings.ToUpper(spec.Method)\n\tif (method == \"POST\" || method == \"PATCH\") && headers[\"Idempotency-Key\"] == \"\" {\n\t\tif spec.IdempotencyKey != \"\" {\n\t\t\theaders[\"Idempotency-Key\"] = spec.IdempotencyKey\n\t\t} else if config.IdempotencyKey != nil {\n\t\t\theaders[\"Idempotency-Key\"] = config.IdempotencyKey()\n\t\t}\n\t}\n\thttpClient := config.HTTPClient\n\tif httpClient == nil {\n\t\thttpClient = http.DefaultClient\n\t}\n\tif spec.Body != nil && !spec.Stream {\n\t\tpayload, err := io.ReadAll(spec.Body)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tspec.bodyBytes = payload\n\t}\n\tfullURL := spec.URL\n\tif len(spec.Query) > 0 {\n\t\tseparator := \"?\"\n\t\tif strings.Contains(fullURL, \"?\") {\n\t\t\tseparator = \"&\"\n\t\t}\n\t\tfullURL += separator + spec.Query.Encode()\n\t}\n\tmaxAttempts := 1 + retry.Retries\n\tif spec.Stream {\n\t\t// The first attempt consumes the reader, so there is nothing to replay.\n\t\tmaxAttempts = 1\n\t}\n\tfor attempt := 1; ; attempt++ {\n\t\tattemptCtx := ctx\n\t\tvar cancel context.CancelFunc\n\t\tif timeout > 0 {\n\t\t\tattemptCtx, cancel = context.WithTimeout(ctx, timeout)\n\t\t}\n\t\tvar bodyReader io.Reader\n\t\tswitch {\n\t\tcase spec.Stream:\n\t\t\tbodyReader = spec.Body\n\t\tcase spec.bodyBytes != nil:\n\t\t\tbodyReader = bytes.NewReader(spec.bodyBytes)\n\t\t}\n\t\treq, err := http.NewRequestWithContext(attemptCtx, method, fullURL, bodyReader)\n\t\tif err != nil {\n\t\t\tif cancel != nil {\n\t\t\t\tcancel()\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\t\tfor key, value := range headers {\n\t\t\treq.Header.Set(key, value)\n\t\t}\n\t\tif spec.ContentType != \"\" && bodyReader != nil && req.Header.Get(\"Content-Type\") == \"\" {\n\t\t\treq.Header.Set(\"Content-Type\", spec.ContentType)\n\t\t}\n\t\tfor _, mw := range config.Middleware {\n\t\t\tif mw.OnRequest != nil {\n\t\t\t\tmw.OnRequest(req)\n\t\t\t}\n\t\t}\n\t\tresp, err := httpClient.Do(req)\n\t\tshouldRetry := retry.RetryOn\n\t\tretryable := false\n\t\tif shouldRetry != nil {\n\t\t\tretryable = shouldRetry(attempt, resp, err)\n\t\t} else {\n\t\t\tretryable = defaultRetryOn(method, headers, resp, err)\n\t\t}\n\t\tif err != nil {\n\t\t\tif cancel != nil {\n\t\t\t\tcancel()\n\t\t\t}\n\t\t\ttimedOut := errors.Is(err, context.DeadlineExceeded) && ctx.Err() == nil\n\t\t\tif attempt < maxAttempts && retryable {\n\t\t\t\ttime.Sleep(retryDelay(retry, attempt, \"\"))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif timedOut {\n\t\t\t\treturn nil, &TimeoutError{OperationID: spec.OperationID, Timeout: timeout, Attempt: attempt}\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\t\tfor i := len(config.Middleware) - 1; i >= 0; i-- {\n\t\t\tif config.Middleware[i].OnResponse != nil {\n\t\t\t\tconfig.Middleware[i].OnResponse(resp)\n\t\t\t}\n\t\t}\n\t\tif resp.StatusCode >= 400 && attempt < maxAttempts && retryable {\n\t\t\tafter := resp.Header.Get(\"Retry-After\")\n\t\t\tio.Copy(io.Discard, resp.Body)\n\t\t\tresp.Body.Close()\n\t\t\tif cancel != nil {\n\t\t\t\tcancel()\n\t\t\t}\n\t\t\ttime.Sleep(retryDelay(retry, attempt, after))\n\t\t\tcontinue\n\t\t}\n\t\t// The response body outlives this call; tie the attempt context's lifetime to it.\n\t\tif cancel != nil {\n\t\t\tresp.Body = &cancelOnClose{ReadCloser: resp.Body, cancel: cancel}\n\t\t}\n\t\treturn resp, nil\n\t}\n}\n\ntype cancelOnClose struct {\n\tio.ReadCloser\n\tcancel context.CancelFunc\n}\n\nfunc (c *cancelOnClose) Close() error {\n\tc.cancel()\n\treturn c.ReadCloser.Close()\n}\n\n// decodeJSON decodes a response body into target; a nil target drains and closes.\nfunc decodeJSON(resp *http.Response, target any) error {\n\tdefer resp.Body.Close()\n\tif target == nil {\n\t\t_, err := io.Copy(io.Discard, resp.Body)\n\t\treturn err\n\t}\n\treturn json.NewDecoder(resp.Body).Decode(target)\n}\n\n// headerString returns the named response header, or nil when absent.\nfunc headerString(header http.Header, name string) *string {\n\tvalue := header.Get(name)\n\tif value == \"\" {\n\t\treturn nil\n\t}\n\treturn &value\n}\n\n// headerInt64 parses the named header as an integer; nil when absent or unparsable.\nfunc headerInt64(header http.Header, name string) *int64 {\n\traw := strings.TrimSpace(header.Get(name))\n\tif raw == \"\" {\n\t\treturn nil\n\t}\n\tvalue, err := strconv.ParseInt(raw, 10, 64)\n\tif err != nil {\n\t\treturn nil\n\t}\n\treturn &value\n}\n\n// headerFloat64 parses the named header as a number; nil when absent or unparsable.\nfunc headerFloat64(header http.Header, name string) *float64 {\n\traw := strings.TrimSpace(header.Get(name))\n\tif raw == \"\" {\n\t\treturn nil\n\t}\n\tvalue, err := strconv.ParseFloat(raw, 64)\n\tif err != nil {\n\t\treturn nil\n\t}\n\treturn &value\n}\n\n// headerBool parses a `true`/`false` header; nil when absent or anything else.\nfunc headerBool(header http.Header, name string) *bool {\n\traw := strings.ToLower(strings.TrimSpace(header.Get(name)))\n\tif raw != \"true\" && raw != \"false\" {\n\t\treturn nil\n\t}\n\tvalue := raw == \"true\"\n\treturn &value\n}\n\n// apiErrorFrom builds the structured error for a non-2xx response.\nfunc apiErrorFrom(resp *http.Response, requestURL string) error {\n\tdefer resp.Body.Close()\n\tvar body any\n\tdata, _ := io.ReadAll(resp.Body)\n\tif len(data) > 0 {\n\t\tif err := json.Unmarshal(data, &body); err != nil {\n\t\t\tbody = string(data)\n\t\t}\n\t}\n\treturn &APIError{URL: requestURL, Status: resp.StatusCode, StatusText: resp.Status, Body: body}\n}\n\n// \u2500\u2500\u2500 Pagination \u2500\u2500\u2500\n\n// PaginationSpec mirrors the descriptor table's pagination entries.\ntype PaginationSpec struct {\n\tStyle string\n\tParam string\n\tNextCursor string\n\tHasMore string\n\tNextLink string\n\tLimitParam string\n\tItems string\n}\n\n// resolvePointer walks an RFC 6901 JSON pointer over decoded JSON; nil on any miss.\nfunc resolvePointer(data any, pointer string) any {\n\tif pointer == \"\" {\n\t\treturn data\n\t}\n\tif !strings.HasPrefix(pointer, \"/\") {\n\t\treturn nil\n\t}\n\tcurrent := data\n\tfor _, token := range strings.Split(pointer[1:], \"/\") {\n\t\tkey := strings.ReplaceAll(strings.ReplaceAll(token, \"~1\", \"/\"), \"~0\", \"~\")\n\t\tswitch typed := current.(type) {\n\t\tcase map[string]any:\n\t\t\tcurrent = typed[key]\n\t\tcase []any:\n\t\t\tindex, err := strconv.Atoi(key)\n\t\t\tif err != nil || index < 0 || index >= len(typed) {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tcurrent = typed[index]\n\t\tdefault:\n\t\t\treturn nil\n\t\t}\n\t\tif current == nil {\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn current\n}\n\n// reencode converts decoded JSON (maps/slices) into a typed value via a JSON round-trip.\nfunc reencode(raw any, target any) error {\n\tdata, err := json.Marshal(raw)\n\tif err != nil {\n\t\treturn err\n\t}\n\treturn json.Unmarshal(data, target)\n}\n\ntype pageCall func(params url.Values) (any, *http.Response, error)\n\n// iterPages yields raw page JSON per the pagination spec \u2014 the same stop\n// conditions and infinite-loop guards as the TypeScript runtime. The returned\n// function is a range-over-func iterator (Go 1.23+) and plainly callable before that.\nfunc iterPages(call pageCall, spec PaginationSpec, base url.Values) func(yield func(any, error) bool) {\n\treturn func(yield func(any, error) bool) {\n\t\tswitch spec.Style {\n\t\tcase \"cursor\":\n\t\t\tvar cursor any\n\t\t\tif values, ok := base[spec.Param]; ok && len(values) > 0 {\n\t\t\t\tcursor = values[0]\n\t\t\t}\n\t\t\tfor {\n\t\t\t\tparams := cloneValues(base)\n\t\t\t\tif cursor != nil {\n\t\t\t\t\tparams.Set(spec.Param, fmt.Sprint(cursor))\n\t\t\t\t}\n\t\t\t\tpage, _, err := call(params)\n\t\t\t\tif err != nil {\n\t\t\t\t\tyield(nil, err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif !yield(page, nil) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif spec.HasMore != \"\" {\n\t\t\t\t\tif more, ok := resolvePointer(page, spec.HasMore).(bool); ok && !more {\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tnext := resolvePointer(page, spec.NextCursor)\n\t\t\t\tif next == nil || next == \"\" {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tswitch next.(type) {\n\t\t\t\tcase string, float64:\n\t\t\t\tdefault:\n\t\t\t\t\tyield(nil, fmt.Errorf(\"pagination cursor at %s is not a string or number\", spec.NextCursor))\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif cursor != nil && fmt.Sprint(next) == fmt.Sprint(cursor) {\n\t\t\t\t\tyield(nil, errors.New(\"pagination did not advance: the operation returned the same cursor twice\"))\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tcursor = next\n\t\t\t}\n\t\tcase \"link\", \"body-link\":\n\t\t\tparams := cloneValues(base)\n\t\t\tprevious := \"\"\n\t\t\tfor {\n\t\t\t\tpage, resp, err := call(params)\n\t\t\t\tif err != nil {\n\t\t\t\t\tyield(nil, err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif !yield(page, nil) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tvar target string\n\t\t\t\tif spec.Style == \"link\" {\n\t\t\t\t\ttarget = linkNext(resp.Header.Get(\"Link\"))\n\t\t\t\t} else {\n\t\t\t\t\tvalue := resolvePointer(page, spec.NextLink)\n\t\t\t\t\tlink, isString := value.(string)\n\t\t\t\t\tif value != nil && !isString {\n\t\t\t\t\t\tyield(nil, fmt.Errorf(\"pagination link at %s is not a string\", spec.NextLink))\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\ttarget = link\n\t\t\t\t}\n\t\t\t\tif target == \"\" {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tpageURL := \"\"\n\t\t\t\tif resp.Request != nil && resp.Request.URL != nil {\n\t\t\t\t\tpageURL = resp.Request.URL.String()\n\t\t\t\t}\n\t\t\t\tbaseURL, err := url.Parse(pageURL)\n\t\t\t\tif err != nil || pageURL == \"\" {\n\t\t\t\t\tbaseURL, _ = url.Parse(\"http://relative.invalid\")\n\t\t\t\t}\n\t\t\t\ttargetURL, err := baseURL.Parse(target)\n\t\t\t\tif err != nil {\n\t\t\t\t\tyield(nil, err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tnext := targetURL.String()\n\t\t\t\tif next == previous || next == pageURL {\n\t\t\t\t\tyield(nil, errors.New(`pagination did not advance: the Link rel=\"next\" target repeats`))\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tprevious = next\n\t\t\t\tparams = cloneValues(base)\n\t\t\t\tfor key, values := range targetURL.Query() {\n\t\t\t\t\tparams[key] = values\n\t\t\t\t}\n\t\t\t}\n\t\tdefault: // offset / page\n\t\t\tposition := 0\n\t\t\tif spec.Style == \"page\" {\n\t\t\t\tposition = 1\n\t\t\t}\n\t\t\tif values, ok := base[spec.Param]; ok && len(values) > 0 && values[0] != \"\" {\n\t\t\t\tif parsed, err := strconv.Atoi(values[0]); err == nil {\n\t\t\t\t\tposition = parsed\n\t\t\t\t}\n\t\t\t}\n\t\t\tpreviousItems := \"\"\n\t\t\tfor {\n\t\t\t\tparams := cloneValues(base)\n\t\t\t\tparams.Set(spec.Param, strconv.Itoa(position))\n\t\t\t\tpage, _, err := call(params)\n\t\t\t\tif err != nil {\n\t\t\t\t\tyield(nil, err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\titems, _ := resolvePointer(page, spec.Items).([]any)\n\t\t\t\tserialized := \"\"\n\t\t\t\tif items != nil {\n\t\t\t\t\tserialized = fmt.Sprint(items)\n\t\t\t\t\tif serialized == previousItems {\n\t\t\t\t\t\tyield(nil, errors.New(\"pagination did not advance: the operation returned the same page twice\"))\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif !yield(page, nil) {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tif len(items) == 0 {\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\tpreviousItems = serialized\n\t\t\t\tif spec.Style == \"page\" {\n\t\t\t\t\tposition++\n\t\t\t\t} else {\n\t\t\t\t\tposition += len(items)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunc cloneValues(values url.Values) url.Values {\n\tout := url.Values{}\n\tfor key, entries := range values {\n\t\tfor _, entry := range entries {\n\t\t\tout.Add(key, entry)\n\t\t}\n\t}\n\treturn out\n}\n\nfunc linkNext(header string) string {\n\tif header == \"\" {\n\t\treturn \"\"\n\t}\n\tfor _, entry := range strings.Split(header, \",\") {\n\t\tparts := strings.Split(entry, \";\")\n\t\tif len(parts) < 2 {\n\t\t\tcontinue\n\t\t}\n\t\ttarget := strings.TrimSpace(parts[0])\n\t\tif !strings.HasPrefix(target, \"<\") || !strings.HasSuffix(target, \">\") {\n\t\t\tcontinue\n\t\t}\n\t\tfor _, param := range parts[1:] {\n\t\t\ttrimmed := strings.TrimSpace(param)\n\t\t\tif strings.HasPrefix(trimmed, \"rel=\") {\n\t\t\t\trel := strings.Trim(strings.TrimPrefix(trimmed, \"rel=\"), `\"`)\n\t\t\t\tfor _, kind := range strings.Fields(rel) {\n\t\t\t\t\tif kind == \"next\" {\n\t\t\t\t\t\treturn strings.Trim(target, \"<>\")\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn \"\"\n}\n\n// \u2500\u2500\u2500 Server-Sent Events \u2500\u2500\u2500\n\n// ServerSentEvent is one decoded event; Data is the raw text (or parsed JSON\n// for operations that declare a JSON event stream).\ntype ServerSentEvent struct {\n\tEvent string\n\tData any\n\tID string\n\tRetry int\n}\n\nfunc parseSSEFrame(raw string, jsonData bool) (ServerSentEvent, bool, error) {\n\tevent := ServerSentEvent{Retry: -1}\n\tsawField := false\n\tvar dataLines []string\n\tnormalized := strings.ReplaceAll(strings.ReplaceAll(raw, \"\\r\\n\", \"\\n\"), \"\\r\", \"\\n\")\n\tfor _, line := range strings.Split(normalized, \"\\n\") {\n\t\tif line == \"\" || strings.HasPrefix(line, \":\") {\n\t\t\tcontinue\n\t\t}\n\t\tfield, value, _ := strings.Cut(line, \":\")\n\t\tvalue = strings.TrimPrefix(value, \" \")\n\t\tsawField = true\n\t\tswitch field {\n\t\tcase \"event\":\n\t\t\tevent.Event = value\n\t\tcase \"data\":\n\t\t\tdataLines = append(dataLines, value)\n\t\tcase \"id\":\n\t\t\tevent.ID = value\n\t\tcase \"retry\":\n\t\t\tif parsed, err := strconv.Atoi(value); err == nil && parsed >= 0 && value != \"\" {\n\t\t\t\tevent.Retry = parsed\n\t\t\t}\n\t\t}\n\t}\n\tif !sawField {\n\t\treturn event, false, nil\n\t}\n\ttext := strings.Join(dataLines, \"\\n\")\n\tevent.Data = text\n\tif jsonData && text != \"\" {\n\t\tvar parsed any\n\t\tif err := json.Unmarshal([]byte(text), &parsed); err != nil {\n\t\t\treturn event, false, err\n\t\t}\n\t\tevent.Data = parsed\n\t}\n\treturn event, true, nil\n}\n\n// iterSSE streams events, reconnecting on dropped connections with Last-Event-ID\n// (a fresh open call = fresh auth); a 4xx/5xx or a bad JSON payload is definitive.\nfunc iterSSE(open func(extraHeaders map[string]string) (*http.Response, error), jsonData bool) func(yield func(ServerSentEvent, error) bool) {\n\treturn func(yield func(ServerSentEvent, error) bool) {\n\t\tlastEventID := \"\"\n\t\tserverRetry := -1\n\t\tfailures := 0\n\t\tfor {\n\t\t\theaders := map[string]string{\"Accept\": \"text/event-stream\"}\n\t\t\tif lastEventID != \"\" {\n\t\t\t\theaders[\"Last-Event-ID\"] = lastEventID\n\t\t\t}\n\t\t\tresp, err := open(headers)\n\t\t\tif err == nil && resp.StatusCode >= 400 {\n\t\t\t\tyield(ServerSentEvent{}, apiErrorFrom(resp, \"\"))\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif err == nil {\n\t\t\t\tfailures = 0\n\t\t\t\tbuffer := \"\"\n\t\t\t\tchunk := make([]byte, 4096)\n\t\t\t\tclean := false\n\t\t\t\tfor {\n\t\t\t\t\tn, readErr := resp.Body.Read(chunk)\n\t\t\t\t\tbuffer += string(chunk[:n])\n\t\t\t\t\tfor {\n\t\t\t\t\t\tframe, rest, found := strings.Cut(buffer, \"\\n\\n\")\n\t\t\t\t\t\tif !found {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbuffer = rest\n\t\t\t\t\t\tevent, ok, parseErr := parseSSEFrame(frame, jsonData)\n\t\t\t\t\t\tif parseErr != nil {\n\t\t\t\t\t\t\tresp.Body.Close()\n\t\t\t\t\t\t\tyield(ServerSentEvent{}, parseErr)\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif ok {\n\t\t\t\t\t\t\tif event.ID != \"\" {\n\t\t\t\t\t\t\t\tlastEventID = event.ID\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif event.Retry >= 0 {\n\t\t\t\t\t\t\t\tserverRetry = event.Retry\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif !yield(event, nil) {\n\t\t\t\t\t\t\t\tresp.Body.Close()\n\t\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif readErr == io.EOF {\n\t\t\t\t\t\tclean = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t\tif readErr != nil {\n\t\t\t\t\t\tbreak\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tresp.Body.Close()\n\t\t\t\tif clean {\n\t\t\t\t\tif strings.TrimSpace(buffer) != \"\" {\n\t\t\t\t\t\tif event, ok, parseErr := parseSSEFrame(buffer, jsonData); parseErr == nil && ok {\n\t\t\t\t\t\t\tyield(event, nil)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t\tfailures++\n\t\t\tbase := time.Second\n\t\t\tif serverRetry >= 0 {\n\t\t\t\tbase = time.Duration(serverRetry) * time.Millisecond\n\t\t\t}\n\t\t\tdelay := base * time.Duration(1<<(failures-1))\n\t\t\tif delay > 30*time.Second {\n\t\t\t\tdelay = 30 * time.Second\n\t\t\t}\n\t\t\ttime.Sleep(time.Duration(rand.Int63n(int64(delay) + 1)))\n\t\t}\n\t}\n}\n\n// \u2500\u2500\u2500 Multipart \u2500\u2500\u2500\n\n// toMultipart splits a typed body into a multipart/form-data payload: []byte\n// values upload as file parts, everything else as form fields (nested values\n// JSON-encoded) \u2014 mirroring the TypeScript runtime's FormData serialization.\nfunc toMultipart(body any) (string, io.Reader, error) {\n\tvar wire map[string]any\n\tif err := reencode(body, &wire); err != nil {\n\t\treturn \"\", nil, err\n\t}\n\tbuffer := &bytes.Buffer{}\n\twriter := multipart.NewWriter(buffer)\n\tfor key, value := range wire {\n\t\tswitch typed := value.(type) {\n\t\tcase string:\n\t\t\tif err := writer.WriteField(key, typed); err != nil {\n\t\t\t\treturn \"\", nil, err\n\t\t\t}\n\t\tcase float64, bool:\n\t\t\tif err := writer.WriteField(key, fmt.Sprint(typed)); err != nil {\n\t\t\t\treturn \"\", nil, err\n\t\t\t}\n\t\tdefault:\n\t\t\tencoded, err := json.Marshal(typed)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", nil, err\n\t\t\t}\n\t\t\tif err := writer.WriteField(key, string(encoded)); err != nil {\n\t\t\t\treturn \"\", nil, err\n\t\t\t}\n\t\t}\n\t}\n\tif err := writer.Close(); err != nil {\n\t\treturn \"\", nil, err\n\t}\n\treturn writer.FormDataContentType(), buffer, nil\n}\n\n// multipartBody prepares the body of an untyped multipart operation: an io.Reader is\n// streamed and a []byte or string sent as is, all under the caller's Content-Type (the\n// boundary is theirs to set); any other value goes through toMultipart.\nfunc multipartBody(body any) (string, io.Reader, bool, error) {\n\tif reader, stream, raw := rawBody(body); raw {\n\t\treturn \"\", reader, stream, nil\n\t}\n\tcontentType, reader, err := toMultipart(body)\n\treturn contentType, reader, false, err\n}\n\n// binaryBody prepares the body of a binary operation: an io.Reader is streamed, a\n// []byte or string sent as is, and any other value JSON-marshalled.\nfunc binaryBody(body any) (io.Reader, bool, error) {\n\tif reader, stream, raw := rawBody(body); raw {\n\t\treturn reader, stream, nil\n\t}\n\tpayload, err := json.Marshal(body)\n\treturn bytes.NewReader(payload), false, err\n}\n\n// rawBody recognizes a body that needs no encoding: an io.Reader streams through in one\n// attempt, a []byte or a string is replayable bytes.\nfunc rawBody(body any) (io.Reader, bool, bool) {\n\tswitch typed := body.(type) {\n\tcase io.Reader:\n\t\treturn typed, true, true\n\tcase []byte:\n\t\treturn bytes.NewReader(typed), false, true\n\tcase string:\n\t\treturn strings.NewReader(typed), false, true\n\t}\n\treturn nil, false, false\n}\n";
|
|
2
2
|
//# sourceMappingURL=go.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"go.d.ts","sourceRoot":"","sources":["../../src/runtime-sources/go.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"go.d.ts","sourceRoot":"","sources":["../../src/runtime-sources/go.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,iBAAiB,4y1BACw20B,CAAC"}
|