@xemahq/api-client-generator 0.20.0 → 0.21.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/dist/.source-stamp.json +1 -1
- package/dist/lib/client-package.d.ts.map +1 -1
- package/dist/lib/client-package.js +19 -7
- package/dist/lib/client-package.js.map +1 -1
- package/dist/lib/client-repository.d.ts +7 -1
- package/dist/lib/client-repository.d.ts.map +1 -1
- package/dist/lib/client-repository.js +42 -21
- package/dist/lib/client-repository.js.map +1 -1
- package/dist/lib/custom-fetch-template.d.ts +1 -1
- package/dist/lib/custom-fetch-template.d.ts.map +1 -1
- package/dist/lib/custom-fetch-template.js +10 -3
- package/dist/lib/custom-fetch-template.js.map +1 -1
- package/dist/lib/extract-openapi.d.ts.map +1 -1
- package/dist/lib/extract-openapi.js +35 -0
- package/dist/lib/extract-openapi.js.map +1 -1
- package/dist/lib/generate-clients.d.ts.map +1 -1
- package/dist/lib/generate-clients.js +7 -3
- package/dist/lib/generate-clients.js.map +1 -1
- package/dist/lib/service-config.d.ts +2 -0
- package/dist/lib/service-config.d.ts.map +1 -1
- package/dist/lib/service-config.js.map +1 -1
- package/package.json +3 -3
package/dist/.source-stamp.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-package.d.ts","sourceRoot":"","sources":["../../src/lib/client-package.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAO1D,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,kBAAkB,CAAC;AAG1B,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;
|
|
1
|
+
{"version":3,"file":"client-package.d.ts","sourceRoot":"","sources":["../../src/lib/client-package.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAO1D,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,kBAAkB,CAAC;AAG1B,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAiID,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAgCtE;AAqDD,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,GACd;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAsJ1C"}
|
|
@@ -7,6 +7,7 @@ const node_path_1 = require("node:path");
|
|
|
7
7
|
const client_repository_1 = require("./client-repository");
|
|
8
8
|
const custom_fetch_template_1 = require("./custom-fetch-template");
|
|
9
9
|
const service_config_1 = require("./service-config");
|
|
10
|
+
const RELEASE_CONFIG_HINT = 'release.config.mjs (`client.license`)';
|
|
10
11
|
const REPOSITORY_LICENSES = new Map([
|
|
11
12
|
['Xema Business Source License 1.1', 'LicenseRef-Xema-BSL-1.1'],
|
|
12
13
|
['Xema Proprietary License', 'LicenseRef-Xema-Proprietary'],
|
|
@@ -58,8 +59,11 @@ function recordOrEmpty(value) {
|
|
|
58
59
|
function resolveGeneratedClientLicense(repoRoot) {
|
|
59
60
|
const licensePath = (0, node_path_1.join)(repoRoot, 'LICENSE');
|
|
60
61
|
if (!(0, node_fs_1.existsSync)(licensePath)) {
|
|
61
|
-
throw new Error(`api-client-generator: ${repoRoot} has no LICENSE file
|
|
62
|
-
|
|
62
|
+
throw new Error(`api-client-generator: ${repoRoot} has no LICENSE file and declares no ` +
|
|
63
|
+
`\`client.license\` in ${RELEASE_CONFIG_HINT}; generated clients ` +
|
|
64
|
+
`require one repository-level licence authority. A repository whose ` +
|
|
65
|
+
`source is not first-party should DECLARE its licence there — that ` +
|
|
66
|
+
`is the generic mechanism and it needs no change to this generator.`);
|
|
63
67
|
}
|
|
64
68
|
const title = (0, node_fs_1.readFileSync)(licensePath, 'utf8')
|
|
65
69
|
.split(/\r?\n/u)
|
|
@@ -67,9 +71,17 @@ function resolveGeneratedClientLicense(repoRoot) {
|
|
|
67
71
|
?.trim();
|
|
68
72
|
const license = title === undefined ? undefined : REPOSITORY_LICENSES.get(title);
|
|
69
73
|
if (license === undefined) {
|
|
70
|
-
throw new Error(`api-client-generator:
|
|
71
|
-
`${
|
|
72
|
-
`
|
|
74
|
+
throw new Error(`api-client-generator: ${licensePath} carries the licence title ` +
|
|
75
|
+
`${JSON.stringify(title ?? '')}, which this generator does not ` +
|
|
76
|
+
`recognise as a FIRST-PARTY Xema licence. ` +
|
|
77
|
+
`DECLARE \`client.license\` (an SPDX id or \`LicenseRef-…\`) in ` +
|
|
78
|
+
`${RELEASE_CONFIG_HINT} instead — it is believed verbatim and takes ` +
|
|
79
|
+
`precedence over this file. ` +
|
|
80
|
+
`DO NOT add the title to this generator's first-party map: that map ` +
|
|
81
|
+
`is the set of licences XEMA ITSELF publishes under, and putting a ` +
|
|
82
|
+
`customer's or a white-label licence in it writes their naming ` +
|
|
83
|
+
`permanently into generic Xema tooling — the coupling the white-label ` +
|
|
84
|
+
`programme exists to remove.`);
|
|
73
85
|
}
|
|
74
86
|
return license;
|
|
75
87
|
}
|
|
@@ -130,9 +142,9 @@ function ensureClientPackage(ctx, surface, version, repositoryUrl, license) {
|
|
|
130
142
|
prepublishOnly: 'npm run build',
|
|
131
143
|
},
|
|
132
144
|
publishConfig: {
|
|
133
|
-
access: 'public',
|
|
145
|
+
access: ctx.ownership?.access ?? 'public',
|
|
134
146
|
...existingPublishConfig,
|
|
135
|
-
registry: 'https://registry.npmjs.org/',
|
|
147
|
+
registry: ctx.ownership?.registry ?? 'https://registry.npmjs.org/',
|
|
136
148
|
},
|
|
137
149
|
devDependencies: {
|
|
138
150
|
...existingDevDeps,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-package.js","sourceRoot":"","sources":["../../src/lib/client-package.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"client-package.js","sourceRoot":"","sources":["../../src/lib/client-package.ts"],"names":[],"mappings":";;AA+JA,sEAgCC;AAqDD,kDA4JC;AAhZD,qCAKiB;AACjB,yCAAiC;AAIjC,2DAG6B;AAC7B,mEAAiE;AACjE,qDAI0B;AAkB1B,MAAM,mBAAmB,GAAG,uCAAuC,CAAC;AAmBpE,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAiB;IAClD,CAAC,kCAAkC,EAAE,yBAAyB,CAAC;IAC/D,CAAC,0BAA0B,EAAE,6BAA6B,CAAC;CAC5D,CAAC,CAAC;AA6BH,MAAM,cAAc,GAAG;IACrB,GAAG,EAAE,EAAE,KAAK,EAAE,mBAAmB,EAAE,OAAO,EAAE,iBAAiB,EAAE;IAC/D,UAAU,EAAE;QACV,KAAK,EAAE,0BAA0B;QACjC,OAAO,EAAE,wBAAwB;KAClC;IACD,YAAY,EAAE;QACZ,KAAK,EAAE,sBAAsB;QAC7B,OAAO,EAAE,oBAAoB;KAC9B;IACD,eAAe,EA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eAAe,CAAC,CAAC;IACtD,IAAI,CAAC,IAAA,oBAAU,EAAC,YAAY,CAAC,EAAE,CAAC;QAC9B,IAAA,uBAAa,EACX,YAAY,EACZ,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAC/C,MAAM,CACP,CAAC;IACJ,CAAC;IAED,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAE5B,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAClC,CAAC;AAsBD,SAAS,gBAAgB,CAAC,SAAiB;IACzC,IAAA,uBAAa,EACX,IAAA,gBAAI,EAAC,SAAS,EAAE,iBAAiB,CAAC,EAClC,8CAAsB,EACtB,MAAM,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -6,10 +6,16 @@ export interface GeneratedClientRepository {
|
|
|
6
6
|
export declare const RELEASE_CONFIG_PATH = "tooling/ci/release.config.mjs";
|
|
7
7
|
export declare function packageRepositoryUrl(repositorySlug: string): string;
|
|
8
8
|
export declare function resolveClientRepositoryUrl(repoRoot: string): Promise<string>;
|
|
9
|
-
export declare function declaredClientLicense(repoRoot: string): Promise<string | undefined>;
|
|
10
9
|
export declare function generatedClientRepository(params: {
|
|
11
10
|
repositoryUrl: string;
|
|
12
11
|
repoRoot: string;
|
|
13
12
|
clientDir: string;
|
|
14
13
|
}): GeneratedClientRepository;
|
|
14
|
+
export type ClientOwnershipDeclaration = {
|
|
15
|
+
readonly license?: string;
|
|
16
|
+
readonly copyrightHolder?: string;
|
|
17
|
+
readonly access?: 'public' | 'restricted';
|
|
18
|
+
readonly registry?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare function resolveClientOwnership(repoRoot: string): Promise<ClientOwnershipDeclaration>;
|
|
15
21
|
//# sourceMappingURL=client-repository.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-repository.d.ts","sourceRoot":"","sources":["../../src/lib/client-repository.ts"],"names":[],"mappings":"AAg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CF,wBAAsB,sBAAsB,CAC1C,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,0BAA0B,CAAC,CAqDrC"}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RELEASE_CONFIG_PATH = void 0;
|
|
4
4
|
exports.packageRepositoryUrl = packageRepositoryUrl;
|
|
5
5
|
exports.resolveClientRepositoryUrl = resolveClientRepositoryUrl;
|
|
6
|
-
exports.declaredClientLicense = declaredClientLicense;
|
|
7
6
|
exports.generatedClientRepository = generatedClientRepository;
|
|
7
|
+
exports.resolveClientOwnership = resolveClientOwnership;
|
|
8
8
|
const node_fs_1 = require("node:fs");
|
|
9
9
|
const node_path_1 = require("node:path");
|
|
10
10
|
const node_url_1 = require("node:url");
|
|
@@ -38,26 +38,6 @@ async function resolveClientRepositoryUrl(repoRoot) {
|
|
|
38
38
|
}
|
|
39
39
|
return packageRepositoryUrl(repository);
|
|
40
40
|
}
|
|
41
|
-
async function declaredClientLicense(repoRoot) {
|
|
42
|
-
const configPath = (0, node_path_1.join)(repoRoot, exports.RELEASE_CONFIG_PATH);
|
|
43
|
-
if (!(0, node_fs_1.existsSync)(configPath)) {
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
|
-
const config = (await importModule(configPath)).default;
|
|
47
|
-
const license = config?.license;
|
|
48
|
-
if (license === undefined || license === null) {
|
|
49
|
-
return undefined;
|
|
50
|
-
}
|
|
51
|
-
if (typeof license !== 'string' || !isUsableNpmLicense(license)) {
|
|
52
|
-
throw new Error(`api-client-generator: ${configPath} declares a \`license\` npm cannot use ` +
|
|
53
|
-
`(found ${JSON.stringify(license)}). Expected an SPDX expression, ` +
|
|
54
|
-
`\`SEE LICENSE IN <file>\`, or \`UNLICENSED\`. ` +
|
|
55
|
-
`Ignoring it would publish this repository's clients under the ` +
|
|
56
|
-
`first-party licence, which for a customer-owned repository is a false ` +
|
|
57
|
-
`legal assertion.`);
|
|
58
|
-
}
|
|
59
|
-
return license;
|
|
60
|
-
}
|
|
61
41
|
const SPDX_EXPRESSION_PATTERN = /^[A-Za-z0-9][A-Za-z0-9.+-]*(?: (?:AND|OR|WITH) [A-Za-z0-9][A-Za-z0-9.+-]*)*$/u;
|
|
62
42
|
const SEE_LICENSE_IN_PATTERN = /^SEE LICENSE IN \S.*$/u;
|
|
63
43
|
function isUsableNpmLicense(value) {
|
|
@@ -75,4 +55,45 @@ function generatedClientRepository(params) {
|
|
|
75
55
|
}
|
|
76
56
|
return { type: 'git', url: repositoryUrl, directory };
|
|
77
57
|
}
|
|
58
|
+
function asString(value) {
|
|
59
|
+
return typeof value === 'string' && value.trim() !== '' ? value : undefined;
|
|
60
|
+
}
|
|
61
|
+
async function resolveClientOwnership(repoRoot) {
|
|
62
|
+
const configPath = (0, node_path_1.join)(repoRoot, exports.RELEASE_CONFIG_PATH);
|
|
63
|
+
if (!(0, node_fs_1.existsSync)(configPath)) {
|
|
64
|
+
return {};
|
|
65
|
+
}
|
|
66
|
+
const config = (await importModule(configPath)).default;
|
|
67
|
+
const declared = config?.client;
|
|
68
|
+
if (declared === undefined || declared === null) {
|
|
69
|
+
return {};
|
|
70
|
+
}
|
|
71
|
+
const access = asString(declared.access);
|
|
72
|
+
if (access !== undefined && access !== 'public' && access !== 'restricted') {
|
|
73
|
+
throw new Error(`api-client-generator: ${configPath} declares client.access ` +
|
|
74
|
+
`${JSON.stringify(access)}. It must be "public" or "restricted" — a ` +
|
|
75
|
+
`value that is neither must not fall back to "public", which would ` +
|
|
76
|
+
`publish a private client to the public registry.`);
|
|
77
|
+
}
|
|
78
|
+
const rawLicense = declared.license;
|
|
79
|
+
if (rawLicense !== undefined &&
|
|
80
|
+
rawLicense !== null &&
|
|
81
|
+
!(typeof rawLicense === 'string' && isUsableNpmLicense(rawLicense))) {
|
|
82
|
+
throw new Error(`api-client-generator: ${configPath} declares a \`client.license\` npm ` +
|
|
83
|
+
`cannot use (found ${JSON.stringify(declared.license)}). Expected an ` +
|
|
84
|
+
`SPDX expression, \`SEE LICENSE IN <file>\`, or \`UNLICENSED\`. ` +
|
|
85
|
+
`Ignoring it would publish this repository's clients under the ` +
|
|
86
|
+
`first-party licence, which for a customer-owned repository is a false ` +
|
|
87
|
+
`legal assertion.`);
|
|
88
|
+
}
|
|
89
|
+
const license = asString(rawLicense);
|
|
90
|
+
const copyrightHolder = asString(declared.copyrightHolder);
|
|
91
|
+
const registry = asString(declared.registry);
|
|
92
|
+
return {
|
|
93
|
+
...(license === undefined ? {} : { license }),
|
|
94
|
+
...(copyrightHolder === undefined ? {} : { copyrightHolder }),
|
|
95
|
+
...(access === undefined ? {} : { access: access }),
|
|
96
|
+
...(registry === undefined ? {} : { registry }),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
78
99
|
//# sourceMappingURL=client-repository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-repository.js","sourceRoot":"","sources":["../../src/lib/client-repository.ts"],"names":[],"mappings":";;;AAmEA,oDAEC;AAqBD,gEA4BC;
|
|
1
|
+
{"version":3,"file":"client-repository.js","sourceRoot":"","sources":["../../src/lib/client-repository.ts"],"names":[],"mappings":";;;AAmEA,oDAEC;AAqBD,gEA4BC;AA6CD,8DAeC;AA8FD,wDAuDC;AAvUD,qCAAqC;AACrC,yCAAgD;AAChD,uCAAyC;AAiD5B,QAAA,mBAAmB,GAAG,+BAA+B,CAAC;AAGnE,MAAM,uBAAuB,GAAG,2DAA2D,CAAC;AAa5F,SAAgB,oBAAoB,CAAC,cAAsB;IACzD,OAAO,0BAA0B,cAAc,MAAM,CAAC;AACxD,CAAC;AAQD,KAAK,UAAU,YAAY,CAAC,IAAY;IACtC,MAAM,aAAa,GAAG,IAAI,QAAQ,CAAC,GAAG,EAAE,kBAAkB,CAErB,CAAC;IACtC,OAAO,aAAa,CAAC,IAAA,wBAAa,EAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;AACjD,CAAC;AAQM,KAAK,UAAU,0BAA0B,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urable fetch wrapper for Orval-generated clients.\n *\n * GENERATED by `@xemahq/api-client-generator` \u2014 do not edit. Every client in\n * the fleet ships this file byte-for-byte; a local edit is erased by the next\n * `pnpm refresh` and, until then, makes this one client speak to the platform\n * differently from all of its siblings. Change the template instead:\n * `api-client-generator/src/lib/custom-fetch-template.ts`.\n *\n * Consumers must call `configureClient()` before using any endpoint function.\n * The baseUrl is prepended to the relative paths generated by Orval.\n *\n * By default this transport issues exactly ONE request and adds no delay of its\n * own, so a slow call is a slow server. Retrying is opt-in, and opting in\n * requires supplying an observer \u2014 see `maxRetries` / `onRetry` below.\n */\n\n/** What {@link ClientConfig.onRetry} is told before each re-attempt. */\nexport interface RetryNotice {\n /** 1-based index of the re-attempt about to be made. */\n attempt: number;\n /** The configured budget this re-attempt is spending from. */\n maxRetries: number;\n /** The response status that made the previous attempt retryable. */\n status: number;\n /** Delay before the re-attempt, in ms \u2014 from `Retry-After` when the server sent one. */\n waitMs: number;\n /** Whether {@link waitMs} came from the server's `Retry-After` header. */\n retryAfterHonoured: boolean;\n /** Absolute URL being re-requested. */\n url: string;\n /** HTTP method being re-requested. */\n method: string;\n}\n\nexport interface ClientConfig {\n /**\n * Static base URL (e.g. 'http://localhost:3140') \u2014 no trailing slash.\n * Mutually exclusive with `baseUrlResolver`; exactly one MUST be set.\n */\n baseUrl?: string;\n /**\n * Per-request base-URL resolver. When set, the peer URL is resolved from\n * the service registry on EVERY request (boot-order-safe). Wired by\n * `configureOrvalClientResolved` from `@xemahq/platform-common`.\n */\n baseUrlResolver?: () => string | Promise<string>;\n /** Optional async callback to get an auth token. Auto-sets Authorization header on every request. */\n getAuthToken?: () => Promise<string>;\n /** Optional callback returning headers to inject on every request. Per-call headers take precedence. */\n getHeaders?: () => Record<string, string> | Promise<Record<string, string>>;\n /**\n * Optional resolver for the CORRELATION ID of the request being made \u2014 the\n * handle that ties one causal chain together across every service hop.\n *\n * WHY IT IS A CALLBACK AND NOT A VALUE. `ClientConfig` is process-global\n * (`configureClient` is called once at wiring time), and a correlation id is\n * per-request. This is invoked INSIDE the request, so a server can point it\n * at whatever carries its ambient request context and get the CURRENT id\n * rather than the one that happened to be live at boot.\n *\n * WHY THE TRANSPORT DOES NOT MINT ONE. Returning `undefined` sends no header,\n * and the receiving service's `RequestContextMiddleware` mints its own \u2014 a\n * new trace, which is honest. A transport that minted per call would produce\n * a FRESH id on every hop while looking like propagation, which is strictly\n * worse than none: every row would carry a correlation id and no two rows\n * that belong together would share one. That is the exact defect this exists\n * to fix, so the transport must not reproduce it one layer down.\n *\n * A caller-supplied `X-Correlation-Id` header always wins, and so does one\n * from `getHeaders`.\n */\n getCorrelationId?: () =>\n | string\n | undefined\n | Promise<string | undefined>;\n /**\n * Optional callback invoked on a 401 before ONE re-attempt. Supplying it is\n * what opts this client into that re-attempt; without it a 401 comes back to\n * the caller as a `ClientError` like any other 4xx.\n */\n onUnauthorized?: () => Promise<void>;\n /**\n * Re-attempts for a retryable status. **Defaults to 0 \u2014 no retry.**\n *\n * Setting it above 0 REQUIRES `onRetry`; `configureClient` throws otherwise.\n * See the block above `customFetch` for why the budget is opt-in and why an\n * observer is mandatory rather than advisory.\n */\n maxRetries?: number;\n /**\n * Called immediately before every re-attempt, with the reason and the delay.\n *\n * Mandatory whenever `maxRetries` is above 0. It is the difference between a\n * retry and a hidden degradation path: without it a caller cannot tell a slow\n * server from this transport sleeping between attempts.\n */\n onRetry?: (notice: RetryNotice) => void;\n}\n\nexport class ClientError extends Error {\n constructor(\n public readonly status: number,\n public readonly url: string,\n public readonly body: unknown,\n ) {\n super(`HTTP ${status} from ${url}`);\n this.name = 'ClientError';\n }\n}\n\nlet clientConfig: ClientConfig | null = null;\n\nexport function configureClient(config: ClientConfig): void {\n // Fail at WIRING time, not on the request that happens to be retried. A\n // client configured to retry without an observer is the exact defect this\n // transport was rebuilt to remove, so it must not be constructible.\n if ((config.maxRetries ?? 0) > 0 && !config.onRetry) {\n throw new Error(\n 'configureClient: maxRetries above 0 requires onRetry. A retry nothing ' +\n 'reports is indistinguishable from a slow server, which is how two ' +\n 'silent re-attempts were read as a 3,312ms call.',\n );\n }\n clientConfig = config;\n}\n\nexport function getClientConfig(): ClientConfig {\n if (!clientConfig) {\n throw new Error(\n 'Client not configured. Call configureClient({ baseUrl }) before using endpoint functions.',\n );\n }\n return clientConfig;\n}\n\n/*\n * RETRYING IS OPT-IN, OBSERVED, AND NARROW. Do not widen any of the three.\n *\n * This transport used to retry up to `maxRetries` (defaulting to THREE) over\n * 429/502/503/504 AND over any thrown network error, backing off from 1000ms,\n * with no log line anywhere. Three properties were wrong:\n *\n * 1. The DEFAULT was on. ~99% of the fleet's client configurations never\n * mention `maxRetries`, so two re-attempts could add ~3s to any call with\n * nothing to distinguish that from a slow peer. Every caller that DID set\n * it set it LOWER \u2014 canopy's control plane to 1, \"so a hard outage\n * surfaces inside the turn's latency budget rather than after three\n * backoffs\"; two llm-registry callers to 1; a test to 0. Nobody ever\n * raised it. A default three separate call sites work around is not a\n * default, and `configureOrvalClientResolved` cannot express the field at\n * all, so most callers could not have opted out if they had wanted to.\n * 2. It retried AMBIGUOUS failures. 502 and 504 mean a gateway did not get a\n * timely answer from upstream \u2014 the upstream may well have APPLIED the\n * request. So did a thrown network error mid-flight. Re-sending a POST in\n * either case is a duplicate write, and no amount of logging makes that\n * safe. Only 429 and 503 state positively that the request was NOT\n * processed, so only those are retried; everything else surfaces at once.\n * 3. Nothing reported it. Now `onRetry` is mandatory whenever the budget is\n * above 0, enforced in `configureClient`.\n *\n * Also note `baseUrlResolver` is awaited ONCE, above the loop: a re-attempt\n * returns to the same resolved instance. In a registry-resolved fleet the cure\n * for an unhealthy peer is re-resolution, which lives above this file \u2014 which\n * is a further reason not to lean on retrying here.\n *\n * Retry policy a caller genuinely wants belongs in `@xemahq/managed-fetch`,\n * which has backoff, a circuit breaker, a token bucket and health reporting,\n * and reports what it did.\n *\n * Enforced fleet-wide by `check-client-transport-envelope`, which compares\n * every client's transport to this template.\n */\n\n/** The only statuses that state the request was NOT processed. See above. */\nconst RETRYABLE_STATUSES = [429, 503];\n\n/**\n * The platform's correlation header, spelled once.\n *\n * Value-identical to what `RequestContextMiddleware` reads in\n * `@xemahq/platform-common`. It is a literal here rather than an import\n * because this file has ZERO imports on purpose: it ships byte-identical into\n * browser-target clients as well as server-target ones, and a dependency on a\n * NestJS-peer package would follow it into every one of them.\n */\nconst CORRELATION_ID_HEADER = 'X-Correlation-Id';\n\n/** Backoff floor, doubling per attempt up to {@link MAX_BACKOFF_MS}. */\nconst BASE_BACKOFF_MS = 1000;\n\n/** Ceiling on a single backoff, however many attempts have elapsed. */\nconst MAX_BACKOFF_MS = 30_000;\n\nasync function buildHeaders(\n config: ClientConfig,\n callerHeaders: RequestInit['headers'],\n): Promise<Headers> {\n const headers = new Headers(callerHeaders);\n\n // Global headers from config (caller-provided headers take precedence)\n if (config.getHeaders) {\n const globalHeaders = await Promise.resolve(config.getHeaders());\n for (const [key, value] of Object.entries(globalHeaders)) {\n if (!headers.has(key)) {\n headers.set(key, value);\n }\n }\n }\n\n // Correlation id (caller and global headers still take precedence).\n //\n // Without this, every server-to-server hop through a generated client started\n // a NEW trace: the id is read-or-minted per hop by the receiving service's\n // RequestContextMiddleware, and nothing carried it outbound \u2014 so an audit\n // journal could record a whole causal chain and offer no way to join it back\n // together.\n //\n // Absent resolver, or a resolver that answers `undefined`: NO header. The\n // receiver mints and a new trace begins, which is the truthful outcome when\n // there is nothing to continue.\n if (config.getCorrelationId && !headers.has(CORRELATION_ID_HEADER)) {\n const correlationId = await Promise.resolve(config.getCorrelationId());\n if (correlationId) {\n headers.set(CORRELATION_ID_HEADER, correlationId);\n }\n }\n\n // Auth token (caller or global headers take precedence)\n if (config.getAuthToken && !headers.has('Authorization')) {\n const token = await config.getAuthToken();\n headers.set('Authorization', `Bearer ${token}`);\n }\n\n return headers;\n}\n\n/*\n * THE TRANSPORT RETURNS THE BODY UNCHANGED. Do not reintroduce an unwrap here.\n *\n * Xema services wrap every 2xx payload in a { data: T } envelope via the global\n * ResponseEnvelopeInterceptor (platform-common), and the generator emits types\n * that describe THAT ENVELOPE \u2014 every endpoint returns Promise<XDataEnvelope>\n * or Promise<XPaginatedEnvelope>, never a bare inner T. Consumers read the data\n * property themselves.\n *\n * This template used to peel data, justified by a comment claiming generated\n * types describe the inner T. That stopped being true when the generator moved\n * to envelope-typed returns, and the comment outlived the fact \u2014 so the peel\n * then contradicted every type in every package it seeded. Four clients shipped\n * that way (resource-governance x3, workload-runtime-api): declared\n * *DataEnvelope, returned the already-peeled inner object, so .data read\n * undefined at runtime on every non-paginated endpoint. Paginated calls hid it,\n * because the old peel deliberately preserved an envelope carrying pagination.\n *\n * Four MORE shipped it in repositories the gate could not see \u2014 license-api and\n * license-internal-api in xema-operator, plus their host-web mirrors \u2014 because\n * the gate ran in xema-base only. That is why it now runs in every repository\n * that ships a client, and why this file is generator-owned rather than seeded.\n */\n\nexport const customFetch = async <T>(\n url: string,\n options: RequestInit,\n): Promise<T> => {\n const config = getClientConfig();\n const base = config.baseUrlResolver\n ? await config.baseUrlResolver()\n : config.baseUrl;\n if (base === undefined) {\n throw new Error(\n 'Client not configured: set baseUrl or baseUrlResolver via configureClient().',\n );\n }\n const fullUrl = `${base}${url}`;\n const maxRetries = config.maxRetries ?? 0;\n\n // A caller that supplied its own Authorization header owns that credential.\n // `buildHeaders` lets it win, so refreshing the CLIENT-WIDE token and\n // re-sending would replay the identical failing request with the identical\n // credential: one wasted round trip, plus a global refresh nobody asked for.\n const callerSuppliedAuth = new Headers(options.headers).has('Authorization');\n\n const headers = await buildHeaders(config, options.headers);\n const requestInit: RequestInit = { ...options, headers };\n\n let delay = BASE_BACKOFF_MS;\n\n for (let attempt = 0; ; attempt++) {\n const response = await fetch(fullUrl, requestInit);\n\n if (\n response.status === 401 &&\n config.onUnauthorized &&\n !callerSuppliedAuth &&\n attempt === 0\n ) {\n await config.onUnauthorized();\n const refreshedHeaders = await buildHeaders(config, options.headers);\n const retryResponse = await fetch(fullUrl, {\n ...options,\n headers: refreshedHeaders,\n });\n const retryBody = await parseBody(retryResponse);\n if (retryResponse.status >= 400) {\n throw new ClientError(retryResponse.status, fullUrl, retryBody);\n }\n return retryBody as T;\n }\n\n if (\n !RETRYABLE_STATUSES.includes(response.status) ||\n attempt >= maxRetries\n ) {\n const body = await parseBody(response);\n if (response.status >= 400) {\n throw new ClientError(response.status, fullUrl, body);\n }\n return body as T;\n }\n\n const retryAfter = parseRetryAfter(response.headers.get('Retry-After'));\n const waitMs = retryAfter ?? addJitter(delay);\n // Non-null: `configureClient` refuses a budget above 0 without an observer,\n // and this line is unreachable unless `maxRetries` is above 0.\n (config.onRetry as (notice: RetryNotice) => void)({\n attempt: attempt + 1,\n maxRetries,\n status: response.status,\n waitMs,\n retryAfterHonoured: retryAfter !== undefined,\n url: fullUrl,\n method: options.method ?? 'GET',\n });\n await sleep(waitMs);\n delay = Math.min(delay * 2, MAX_BACKOFF_MS);\n }\n};\n\n/**\n * Does this media type carry JSON?\n *\n * \u2500\u2500 THE OUTAGE THIS FIXES \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n *\n * This used to be `contentType?.includes('application/json')`, and EVERY error\n * this fleet returns failed that test. The platform's `GlobalExceptionFilter`\n * emits RFC 9457 problem documents and sets the media type explicitly \u2014\n * `.type(PROBLEM_DETAILS_CONTENT_TYPE)` before `.json()`, so it cannot be\n * overridden \u2014 and that constant is `application/problem+json`, which does NOT\n * contain the substring `application/json`: after `application/` comes\n * `problem+json`.\n *\n * So every non-2xx body fell through to `response.text()` and reached the\n * caller as an UNPARSED STRING. `ClientError.body` is typed `unknown`, so\n * nothing complained; every consumer that reads a machine-readable code off an\n * error \u2014 `error.body.code`, `error.body.details.code` \u2014 silently read\n * `undefined` instead, for every error, in every service.\n *\n * Measured in production on 2026-09-15: skill-registry-api's\n * `resolveOrNull()` absorbs `RELEASE_CHANNEL_NOT_FOUND` into `null` by exactly\n * that read. With the code unreadable the absorb never fired, a routine \"no\n * pointer on this channel\" 404 became a 500 on `GET /skills` and\n * `GET /describe-objects`, and agent-session-api's `apply_control_bundle` step\n * aborted EVERY session launch in the organisation \u2014 7,871 failed resolutions\n * an hour. A fix written for that exact page months earlier was present in the\n * running image and could not help, because the classifier it repaired was\n * being handed a string.\n *\n * \u2500\u2500 WHY THE STRUCTURED SUFFIX, NOT A SECOND SUBSTRING \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n *\n * Adding `|| includes('application/problem+json')` would fix this one media\n * type and leave the next one \u2014 `application/vnd.api+json`, and anything else\n * a service legitimately emits. RFC 6839 defines `+json` as the structured\n * syntax suffix meaning \"this is JSON\"; that is the actual rule, so it is the\n * rule implemented. Parameters are stripped first, because\n * `application/problem+json; charset=utf-8` is the same media type.\n */\nfunction isJsonMediaType(contentType: string | null): boolean {\n if (contentType === null) {\n return false;\n }\n const essence = contentType.split(';')[0]?.trim().toLowerCase() ?? '';\n return essence === 'application/json' || essence.endsWith('+json');\n}\n\nasync function parseBody(response: Response): Promise<unknown> {\n const contentType = response.headers.get('content-type');\n if (isJsonMediaType(contentType)) {\n return response.json();\n }\n if (response.status === 204) {\n return undefined;\n }\n return response.text();\n}\n\nfunction parseRetryAfter(value: string | null): number | undefined {\n if (!value) return undefined;\n const seconds = Number(value);\n if (!isNaN(seconds) && seconds >= 0) return seconds * 1000;\n const date = new Date(value);\n if (!isNaN(date.getTime())) return Math.max(0, date.getTime() - Date.now());\n return undefined;\n}\n\nfunction addJitter(delay: number): number {\n return delay + (Math.random() * 2 - 1) * delay * 0.25;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport default customFetch;\n";
|
|
1
|
+
export declare const CANONICAL_CUSTOM_FETCH = "/**\n * Configurable fetch wrapper for Orval-generated clients.\n *\n * GENERATED by `@xemahq/api-client-generator` \u2014 do not edit. Every client in\n * the fleet ships this file byte-for-byte; a local edit is erased by the next\n * `pnpm refresh` and, until then, makes this one client speak to the platform\n * differently from all of its siblings. Change the template instead:\n * `api-client-generator/src/lib/custom-fetch-template.ts`.\n *\n * Consumers must call `configureClient()` before using any endpoint function.\n * The baseUrl is prepended to the relative paths generated by Orval.\n *\n * By default this transport issues exactly ONE request and adds no delay of its\n * own, so a slow call is a slow server. Retrying is opt-in, and opting in\n * requires supplying an observer \u2014 see `maxRetries` / `onRetry` below.\n */\n\n/** What {@link ClientConfig.onRetry} is told before each re-attempt. */\nexport interface RetryNotice {\n /** 1-based index of the re-attempt about to be made. */\n attempt: number;\n /** The configured budget this re-attempt is spending from. */\n maxRetries: number;\n /** The response status that made the previous attempt retryable. */\n status: number;\n /** Delay before the re-attempt, in ms \u2014 from `Retry-After` when the server sent one. */\n waitMs: number;\n /** Whether {@link waitMs} came from the server's `Retry-After` header. */\n retryAfterHonoured: boolean;\n /** Absolute URL being re-requested. */\n url: string;\n /** HTTP method being re-requested. */\n method: string;\n}\n\nexport interface ClientConfig {\n /**\n * Static base URL (e.g. 'http://localhost:3140') \u2014 no trailing slash.\n * Mutually exclusive with `baseUrlResolver`; exactly one MUST be set.\n */\n baseUrl?: string;\n /**\n * Per-request base-URL resolver. When set, the peer URL is resolved from\n * the service registry on EVERY request (boot-order-safe). Wired by\n * `configureOrvalClientResolved` from `@xemahq/platform-common`.\n */\n baseUrlResolver?: () => string | Promise<string>;\n /** Optional async callback to get an auth token. Auto-sets Authorization header on every request. */\n getAuthToken?: () => Promise<string>;\n /** Optional callback returning headers to inject on every request. Per-call headers take precedence. */\n getHeaders?: () => Record<string, string> | Promise<Record<string, string>>;\n /**\n * Optional resolver for the CORRELATION ID of the request being made \u2014 the\n * handle that ties one causal chain together across every service hop.\n *\n * WHY IT IS A CALLBACK AND NOT A VALUE. `ClientConfig` is process-global\n * (`configureClient` is called once at wiring time), and a correlation id is\n * per-request. This is invoked INSIDE the request, so a server can point it\n * at whatever carries its ambient request context and get the CURRENT id\n * rather than the one that happened to be live at boot.\n *\n * WHY THE TRANSPORT DOES NOT MINT ONE. Returning `undefined` sends no header,\n * and the receiving service's `RequestContextMiddleware` mints its own \u2014 a\n * new trace, which is honest. A transport that minted per call would produce\n * a FRESH id on every hop while looking like propagation, which is strictly\n * worse than none: every row would carry a correlation id and no two rows\n * that belong together would share one. That is the exact defect this exists\n * to fix, so the transport must not reproduce it one layer down.\n *\n * A caller-supplied `X-Correlation-Id` header always wins, and so does one\n * from `getHeaders`.\n */\n getCorrelationId?: () =>\n | string\n | undefined\n | Promise<string | undefined>;\n /**\n * Optional callback invoked on a 401 before ONE re-attempt. Supplying it is\n * what opts this client into that re-attempt; without it a 401 comes back to\n * the caller as a `ClientError` like any other 4xx.\n */\n onUnauthorized?: () => Promise<void>;\n /**\n * Re-attempts for a retryable status. **Defaults to 0 \u2014 no retry.**\n *\n * Setting it above 0 REQUIRES `onRetry`; `configureClient` throws otherwise.\n * See the block above `customFetch` for why the budget is opt-in and why an\n * observer is mandatory rather than advisory.\n */\n maxRetries?: number;\n /**\n * Called immediately before every re-attempt, with the reason and the delay.\n *\n * Mandatory whenever `maxRetries` is above 0. It is the difference between a\n * retry and a hidden degradation path: without it a caller cannot tell a slow\n * server from this transport sleeping between attempts.\n */\n onRetry?: (notice: RetryNotice) => void;\n}\n\nexport class ClientError extends Error {\n constructor(\n public readonly status: number,\n public readonly url: string,\n public readonly body: unknown,\n ) {\n super(`HTTP ${status} from ${url}`);\n this.name = 'ClientError';\n }\n}\n\nlet clientConfig: ClientConfig | null = null;\n\nexport function configureClient(config: ClientConfig): void {\n // Fail at WIRING time, not on the request that happens to be retried. A\n // client configured to retry without an observer is the exact defect this\n // transport was rebuilt to remove, so it must not be constructible.\n if ((config.maxRetries ?? 0) > 0 && !config.onRetry) {\n throw new Error(\n 'configureClient: maxRetries above 0 requires onRetry. A retry nothing ' +\n 'reports is indistinguishable from a slow server, which is how two ' +\n 'silent re-attempts were read as a 3,312ms call.',\n );\n }\n clientConfig = config;\n}\n\nexport function getClientConfig(): ClientConfig {\n if (!clientConfig) {\n throw new Error(\n 'Client not configured. Call configureClient({ baseUrl }) before using endpoint functions.',\n );\n }\n return clientConfig;\n}\n\n/*\n * RETRYING IS OPT-IN, OBSERVED, AND NARROW. Do not widen any of the three.\n *\n * This transport used to retry up to `maxRetries` (defaulting to THREE) over\n * 429/502/503/504 AND over any thrown network error, backing off from 1000ms,\n * with no log line anywhere. Three properties were wrong:\n *\n * 1. The DEFAULT was on. ~99% of the fleet's client configurations never\n * mention `maxRetries`, so two re-attempts could add ~3s to any call with\n * nothing to distinguish that from a slow peer. Every caller that DID set\n * it set it LOWER \u2014 canopy's control plane to 1, \"so a hard outage\n * surfaces inside the turn's latency budget rather than after three\n * backoffs\"; two llm-registry callers to 1; a test to 0. Nobody ever\n * raised it. A default three separate call sites work around is not a\n * default, and `configureOrvalClientResolved` cannot express the field at\n * all, so most callers could not have opted out if they had wanted to.\n * 2. It retried AMBIGUOUS failures. 502 and 504 mean a gateway did not get a\n * timely answer from upstream \u2014 the upstream may well have APPLIED the\n * request. So did a thrown network error mid-flight. Re-sending a POST in\n * either case is a duplicate write, and no amount of logging makes that\n * safe. Only 429 and 503 state positively that the request was NOT\n * processed, so only those are retried; everything else surfaces at once.\n * 3. Nothing reported it. Now `onRetry` is mandatory whenever the budget is\n * above 0, enforced in `configureClient`.\n *\n * Also note `baseUrlResolver` is awaited ONCE, above the loop: a re-attempt\n * returns to the same resolved instance. In a registry-resolved fleet the cure\n * for an unhealthy peer is re-resolution, which lives above this file \u2014 which\n * is a further reason not to lean on retrying here.\n *\n * Retry policy a caller genuinely wants belongs in `@xemahq/managed-fetch`,\n * which has backoff, a circuit breaker, a token bucket and health reporting,\n * and reports what it did.\n *\n * Enforced fleet-wide by `check-client-transport-envelope`, which compares\n * every client's transport to this template.\n */\n\n/** The only statuses that state the request was NOT processed. See above. */\nconst RETRYABLE_STATUSES = [429, 503];\n\n/**\n * The platform's correlation header, spelled once.\n *\n * Value-identical to what `RequestContextMiddleware` reads in\n * `@xemahq/platform-common`. It is a literal here rather than an import\n * because this file has ZERO imports on purpose: it ships byte-identical into\n * browser-target clients as well as server-target ones, and a dependency on a\n * NestJS-peer package would follow it into every one of them.\n */\nconst CORRELATION_ID_HEADER = 'X-Correlation-Id';\n\n/** Backoff floor, doubling per attempt up to {@link MAX_BACKOFF_MS}. */\nconst BASE_BACKOFF_MS = 1000;\n\n/** Ceiling on a single backoff, however many attempts have elapsed. */\nconst MAX_BACKOFF_MS = 30_000;\n\nasync function buildHeaders(\n config: ClientConfig,\n callerHeaders: RequestInit['headers'],\n): Promise<Headers> {\n const headers = new Headers(callerHeaders);\n\n // Global headers from config (caller-provided headers take precedence)\n if (config.getHeaders) {\n const globalHeaders = await Promise.resolve(config.getHeaders());\n for (const [key, value] of Object.entries(globalHeaders)) {\n if (!headers.has(key)) {\n headers.set(key, value);\n }\n }\n }\n\n // Correlation id (caller and global headers still take precedence).\n //\n // Without this, every server-to-server hop through a generated client started\n // a NEW trace: the id is read-or-minted per hop by the receiving service's\n // RequestContextMiddleware, and nothing carried it outbound \u2014 so an audit\n // journal could record a whole causal chain and offer no way to join it back\n // together.\n //\n // Absent resolver, or a resolver that answers `undefined`: NO header. The\n // receiver mints and a new trace begins, which is the truthful outcome when\n // there is nothing to continue.\n if (config.getCorrelationId && !headers.has(CORRELATION_ID_HEADER)) {\n const correlationId = await Promise.resolve(config.getCorrelationId());\n if (correlationId) {\n headers.set(CORRELATION_ID_HEADER, correlationId);\n }\n }\n\n // Auth token (caller or global headers take precedence)\n if (config.getAuthToken && !headers.has('Authorization')) {\n const token = await config.getAuthToken();\n headers.set('Authorization', `Bearer ${token}`);\n }\n\n return headers;\n}\n\n/*\n * THE TRANSPORT RETURNS THE BODY UNCHANGED. Do not reintroduce an unwrap here.\n *\n * Xema services wrap every 2xx payload in a { data: T } envelope via the global\n * ResponseEnvelopeInterceptor (platform-common), and the generator emits types\n * that describe THAT ENVELOPE \u2014 every endpoint returns Promise<XDataEnvelope>\n * or Promise<XPaginatedEnvelope>, never a bare inner T. Consumers read the data\n * property themselves.\n *\n * This template used to peel data, justified by a comment claiming generated\n * types describe the inner T. That stopped being true when the generator moved\n * to envelope-typed returns, and the comment outlived the fact \u2014 so the peel\n * then contradicted every type in every package it seeded. Four clients shipped\n * that way (resource-governance x3, workload-runtime-api): declared\n * *DataEnvelope, returned the already-peeled inner object, so .data read\n * undefined at runtime on every non-paginated endpoint. Paginated calls hid it,\n * because the old peel deliberately preserved an envelope carrying pagination.\n *\n * Four MORE shipped it in repositories the gate could not see \u2014 license-api and\n * license-internal-api in xema-operator, plus their host-web mirrors \u2014 because\n * the gate ran in xema-base only. That is why it now runs in every repository\n * that ships a client, and why this file is generator-owned rather than seeded.\n */\n\nexport const customFetch = async <T>(\n url: string,\n options: RequestInit,\n): Promise<T> => {\n const config = getClientConfig();\n const base = config.baseUrlResolver\n ? await config.baseUrlResolver()\n : config.baseUrl;\n if (base === undefined) {\n throw new Error(\n 'Client not configured: set baseUrl or baseUrlResolver via configureClient().',\n );\n }\n const fullUrl = `${base}${url}`;\n const maxRetries = config.maxRetries ?? 0;\n\n // A caller that supplied its own Authorization header owns that credential.\n // `buildHeaders` lets it win, so refreshing the CLIENT-WIDE token and\n // re-sending would replay the identical failing request with the identical\n // credential: one wasted round trip, plus a global refresh nobody asked for.\n const callerSuppliedAuth = new Headers(options.headers).has('Authorization');\n\n const headers = await buildHeaders(config, options.headers);\n const requestInit: RequestInit = { ...options, headers };\n\n let delay = BASE_BACKOFF_MS;\n\n for (let attempt = 0; ; attempt++) {\n const response = await fetch(fullUrl, requestInit);\n\n if (\n response.status === 401 &&\n config.onUnauthorized &&\n !callerSuppliedAuth &&\n attempt === 0\n ) {\n await config.onUnauthorized();\n const refreshedHeaders = await buildHeaders(config, options.headers);\n const retryResponse = await fetch(fullUrl, {\n ...options,\n headers: refreshedHeaders,\n });\n const retryBody = await parseBody(retryResponse);\n if (retryResponse.status >= 400) {\n throw new ClientError(retryResponse.status, fullUrl, retryBody);\n }\n return retryBody as T;\n }\n\n if (\n !RETRYABLE_STATUSES.includes(response.status) ||\n attempt >= maxRetries\n ) {\n const body = await parseBody(response);\n if (response.status >= 400) {\n throw new ClientError(response.status, fullUrl, body);\n }\n return body as T;\n }\n\n const retryAfter = parseRetryAfter(response.headers.get('Retry-After'));\n const waitMs = retryAfter ?? addJitter(delay);\n // Non-null: `configureClient` refuses a budget above 0 without an observer,\n // and this line is unreachable unless `maxRetries` is above 0.\n (config.onRetry as (notice: RetryNotice) => void)({\n attempt: attempt + 1,\n maxRetries,\n status: response.status,\n waitMs,\n retryAfterHonoured: retryAfter !== undefined,\n url: fullUrl,\n method: options.method ?? 'GET',\n });\n await sleep(waitMs);\n delay = Math.min(delay * 2, MAX_BACKOFF_MS);\n }\n};\n\n/**\n * Does this media type carry JSON?\n *\n * \u2500\u2500 THE OUTAGE THIS FIXES \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n *\n * This used to be `contentType?.includes('application/json')`, and EVERY error\n * this fleet returns failed that test. The platform's `GlobalExceptionFilter`\n * emits RFC 9457 problem documents and sets the media type explicitly \u2014\n * `.type(PROBLEM_DETAILS_CONTENT_TYPE)` before `.json()`, so it cannot be\n * overridden \u2014 and that constant is `application/problem+json`, which does NOT\n * contain the substring `application/json`: after `application/` comes\n * `problem+json`.\n *\n * So every non-2xx body fell through to `response.text()` and reached the\n * caller as an UNPARSED STRING. `ClientError.body` is typed `unknown`, so\n * nothing complained; every consumer that reads a machine-readable code off an\n * error \u2014 `error.body.code`, `error.body.details.code` \u2014 silently read\n * `undefined` instead, for every error, in every service.\n *\n * Measured in production on 2026-09-15: skill-registry-api's\n * `resolveOrNull()` absorbs `RELEASE_CHANNEL_NOT_FOUND` into `null` by exactly\n * that read. With the code unreadable the absorb never fired, a routine \"no\n * pointer on this channel\" 404 became a 500 on `GET /skills` and\n * `GET /describe-objects`, and agent-session-api's `apply_control_bundle` step\n * aborted EVERY session launch in the organisation \u2014 7,871 failed resolutions\n * an hour. A fix written for that exact page months earlier was present in the\n * running image and could not help, because the classifier it repaired was\n * being handed a string.\n *\n * \u2500\u2500 WHY THE STRUCTURED SUFFIX, NOT A SECOND SUBSTRING \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n *\n * Adding `|| includes('application/problem+json')` would fix this one media\n * type and leave the next one \u2014 `application/vnd.api+json`, and anything else\n * a service legitimately emits. RFC 6839 defines `+json` as the structured\n * syntax suffix meaning \"this is JSON\"; that is the actual rule, so it is the\n * rule implemented. Parameters are stripped first, because\n * `application/problem+json; charset=utf-8` is the same media type.\n */\nfunction isJsonMediaType(contentType: string | null): boolean {\n if (contentType === null) {\n return false;\n }\n const essence = contentType.split(';')[0]?.trim().toLowerCase() ?? '';\n return essence === 'application/json' || essence.endsWith('+json');\n}\n\nasync function parseBody(response: Response): Promise<unknown> {\n // 204 FIRST, and deliberately \u2014 this ORDER is carried from `develop`, which\n // fixed the same defect independently and got this half right where `main`\n // did not. A 204 carries no body, so `response.json()` on one throws\n // SyntaxError; and a 204 whose headers STILL declare a JSON content type is\n // ordinary, because the framework sets the header before the handler returns\n // nothing. With the JSON branch first, a documented `undefined` becomes a\n // thrown parse error. Pinned by a case in `transport-problem-json.test.cjs`.\n if (response.status === 204) {\n return undefined;\n }\n const contentType = response.headers.get('content-type');\n if (isJsonMediaType(contentType)) {\n return response.json();\n }\n return response.text();\n}\n\nfunction parseRetryAfter(value: string | null): number | undefined {\n if (!value) return undefined;\n const seconds = Number(value);\n if (!isNaN(seconds) && seconds >= 0) return seconds * 1000;\n const date = new Date(value);\n if (!isNaN(date.getTime())) return Math.max(0, date.getTime() - Date.now());\n return undefined;\n}\n\nfunction addJitter(delay: number): number {\n return delay + (Math.random() * 2 - 1) * delay * 0.25;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport default customFetch;\n";
|
|
2
2
|
//# sourceMappingURL=custom-fetch-template.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-fetch-template.d.ts","sourceRoot":"","sources":["../../src/lib/custom-fetch-template.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"custom-fetch-template.d.ts","sourceRoot":"","sources":["../../src/lib/custom-fetch-template.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,sBAAsB,w+kBAqalC,CAAC"}
|
|
@@ -387,13 +387,20 @@ function isJsonMediaType(contentType: string | null): boolean {
|
|
|
387
387
|
}
|
|
388
388
|
|
|
389
389
|
async function parseBody(response: Response): Promise<unknown> {
|
|
390
|
+
// 204 FIRST, and deliberately — this ORDER is carried from \`develop\`, which
|
|
391
|
+
// fixed the same defect independently and got this half right where \`main\`
|
|
392
|
+
// did not. A 204 carries no body, so \`response.json()\` on one throws
|
|
393
|
+
// SyntaxError; and a 204 whose headers STILL declare a JSON content type is
|
|
394
|
+
// ordinary, because the framework sets the header before the handler returns
|
|
395
|
+
// nothing. With the JSON branch first, a documented \`undefined\` becomes a
|
|
396
|
+
// thrown parse error. Pinned by a case in \`transport-problem-json.test.cjs\`.
|
|
397
|
+
if (response.status === 204) {
|
|
398
|
+
return undefined;
|
|
399
|
+
}
|
|
390
400
|
const contentType = response.headers.get('content-type');
|
|
391
401
|
if (isJsonMediaType(contentType)) {
|
|
392
402
|
return response.json();
|
|
393
403
|
}
|
|
394
|
-
if (response.status === 204) {
|
|
395
|
-
return undefined;
|
|
396
|
-
}
|
|
397
404
|
return response.text();
|
|
398
405
|
}
|
|
399
406
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-fetch-template.js","sourceRoot":"","sources":["../../src/lib/custom-fetch-template.ts"],"names":[],"mappings":";;;AAca,QAAA,sBAAsB,GAAG
|
|
1
|
+
{"version":3,"file":"custom-fetch-template.js","sourceRoot":"","sources":["../../src/lib/custom-fetch-template.ts"],"names":[],"mappings":";;;AAca,QAAA,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqarC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-openapi.d.ts","sourceRoot":"","sources":["../../src/lib/extract-openapi.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"extract-openapi.d.ts","sourceRoot":"","sources":["../../src/lib/extract-openapi.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,UAAU,EAYhB,MAAM,yBAAyB,CAAC;AA+DjC,wBAAsB,wBAAwB,CAC5C,UAAU,GAAE,MAAsB,EAOlC,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,UAAU,EAAE,CAAC,CAuSvB;AAGD,wBAAgB,aAAa,IAAI,IAAI,CAiBpC"}
|
|
@@ -78,6 +78,41 @@ async function extractOpenApiForService(serviceDir = process.cwd(), outDir) {
|
|
|
78
78
|
`(${unaccounted.join(', ')}). A controller is emitted into the spec ` +
|
|
79
79
|
`but unreachable from the DiscoveryService scan.`);
|
|
80
80
|
}
|
|
81
|
+
const standardProjections = [...scan.projections.values()].filter((projection) => projection.classification === xema_decorators_1.RouteClassification.Standard);
|
|
82
|
+
const missingResource = standardProjections.filter((projection) => projection.resource === undefined);
|
|
83
|
+
if (missingResource.length > 0) {
|
|
84
|
+
throw new Error(`api-client-generator: ${ctx.api.serviceId} has ${missingResource.length} ` +
|
|
85
|
+
`@XemaRoute handler(s) whose controller declares no @XemaResource, ` +
|
|
86
|
+
`which makes the service refuse to boot ` +
|
|
87
|
+
`(XEMA_RUNTIME_MISSING_RESOURCE).\n` +
|
|
88
|
+
missingResource
|
|
89
|
+
.map((projection) => ` - ${projection.controller}.${projection.methodName} — add ` +
|
|
90
|
+
`@XemaResource('<name>') at the class level.`)
|
|
91
|
+
.join('\n'));
|
|
92
|
+
}
|
|
93
|
+
const unknownAction = standardProjections.filter((projection) => projection.action === undefined);
|
|
94
|
+
if (unknownAction.length > 0) {
|
|
95
|
+
throw new Error(`api-client-generator: ${ctx.api.serviceId} has ${unknownAction.length} ` +
|
|
96
|
+
`@XemaRoute handler(s) whose action cannot be inferred, which makes ` +
|
|
97
|
+
`the service refuse to boot (XEMA_RUNTIME_UNKNOWN_ACTION).\n` +
|
|
98
|
+
unknownAction
|
|
99
|
+
.map((projection) => ` - ${projection.controller}.${projection.methodName} — rename ` +
|
|
100
|
+
`to a known verb or supply @XemaRoute({ action: '<verb>' }).`)
|
|
101
|
+
.join('\n'));
|
|
102
|
+
}
|
|
103
|
+
const ambiguous = (0, xema_decorators_1.findAmbiguousOperationIds)([...scan.projections.values()]
|
|
104
|
+
.filter((projection) => projection.classification === xema_decorators_1.RouteClassification.Standard &&
|
|
105
|
+
projection.xemaOperationId !== undefined)
|
|
106
|
+
.map((projection) => ({
|
|
107
|
+
controller: projection.controller,
|
|
108
|
+
methodName: projection.methodName,
|
|
109
|
+
operationId: projection.xemaOperationId,
|
|
110
|
+
})));
|
|
111
|
+
if (ambiguous.length > 0) {
|
|
112
|
+
throw new Error(`api-client-generator: ${ctx.api.serviceId} has ${ambiguous.length} ` +
|
|
113
|
+
`operationId collision(s) that would make the service refuse to boot.\n` +
|
|
114
|
+
ambiguous.map((g) => ` - ${(0, xema_decorators_1.describeAmbiguousOperationId)(g)}`).join('\n'));
|
|
115
|
+
}
|
|
81
116
|
const getResponseSummary = (0, assert_declared_get_responses_1.assertDeclaredGetResponses)({
|
|
82
117
|
serviceId: ctx.api.serviceId,
|
|
83
118
|
shapes: (0, assert_declared_get_responses_1.collectOperationResponseShapes)(fullDoc),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-openapi.js","sourceRoot":"","sources":["../../src/lib/extract-openapi.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"extract-openapi.js","sourceRoot":"","sources":["../../src/lib/extract-openapi.ts"],"names":[],"mappings":";;AAgFA,4DAgTC;AAGD,sCAiBC;AApZD,qCAA4D;AAC5D,yCAAiC;AAEjC,6DAciC;AAEjC,mFAIyC;AACzC,uEAAkE;AAClE,mDAA2D;AAC3D,2CAAmD;AACnD,uDAAwD;AACxD,yDAAoD;AACpD,qDAI0B;AAC1B,iDAAmE;AAInE,KAAK,UAAU,QAAQ,CACrB,GAA2B,EAC3B,IAAiB;IAKjB,MAAM,YAAY,GAAG,OAAO,CAAC,IAAA,gBAAI,EAAC,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,YAAY,CAAC,CAErE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AAC,OAAO,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;IAE1E,wBAAwB,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC;SAC5C,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SAC3B,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;QACtB,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,GAAG,CAAC,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-clients.d.ts","sourceRoot":"","sources":["../../src/lib/generate-clients.ts"],"names":[],"mappings":"AAKA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"generate-clients.d.ts","sourceRoot":"","sources":["../../src/lib/generate-clients.ts"],"names":[],"mappings":"AAKA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAWxE,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,kBAAkB,CAAC;AAyN1B,MAAM,WAAW,sBAAsB;IAQrC,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAE3C,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/C;AAgGD,wBAAsB,yBAAyB,CAC7C,UAAU,GAAE,MAAsB,EAClC,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,UAAU,EAAE,CAAC,CAqJvB;AAmBD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG;IACjF,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9C,CA8BA;AAGD,wBAAgB,oBAAoB,IAAI,IAAI,CAe3C"}
|
|
@@ -132,11 +132,15 @@ function resolveSurfaceBumpClass(args) {
|
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
134
|
async function generateClientsForService(serviceDir = process.cwd(), options = {}) {
|
|
135
|
-
const
|
|
135
|
+
const baseCtx = (0, service_config_1.resolveServiceContext)(serviceDir);
|
|
136
|
+
const ownership = await (0, client_repository_1.resolveClientOwnership)(baseCtx.repoRoot);
|
|
137
|
+
const ctx = {
|
|
138
|
+
...baseCtx,
|
|
139
|
+
...(Object.keys(ownership).length === 0 ? {} : { ownership }),
|
|
140
|
+
};
|
|
136
141
|
const generate = await resolveOrvalGenerate(ctx.serviceDir);
|
|
137
142
|
const repositoryUrl = await (0, client_repository_1.resolveClientRepositoryUrl)(ctx.repoRoot);
|
|
138
|
-
const license =
|
|
139
|
-
(0, client_package_1.resolveGeneratedClientLicense)(ctx.repoRoot);
|
|
143
|
+
const license = ownership.license ?? (0, client_package_1.resolveGeneratedClientLicense)(ctx.repoRoot);
|
|
140
144
|
const surfacesWithSpec = xema_decorators_1.ALL_SURFACES.filter((s) => (0, node_fs_1.existsSync)((0, service_config_1.surfaceSpecPath)(ctx, s)));
|
|
141
145
|
assertNoOrphanedSurfaceClients(ctx, surfacesWithSpec);
|
|
142
146
|
const existingClientVersions = (0, client_version_1.readExistingClientVersions)(ctx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-clients.js","sourceRoot":"","sources":["../../src/lib/generate-clients.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"generate-clients.js","sourceRoot":"","sources":["../../src/lib/generate-clients.ts"],"names":[],"mappings":";;AA4VA,8DAwJC;AAmBD,4CAiCC;AAGD,oDAeC;AA1jBD,2DAAkD;AAClD,qCAA0E;AAC1E,yCAAiC;AACjC,uCAAyC;AAEzC,6DAAwE;AAExE,qDAAsF;A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AO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,OAAO;IACT,CAAC;IACD,yBAAyB,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC;SAC9C,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SAC3B,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;QACtB,OAAO,CAAC,KAAK,CAAC,2CAA2C,EAAE,GAAG,CAAC,CAAC;QAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ApiSurface } from '@xemahq/xema-decorators';
|
|
2
|
+
import type { ClientOwnershipDeclaration } from './client-repository';
|
|
2
3
|
export interface XemaApiConfig {
|
|
3
4
|
readonly serviceId: string;
|
|
4
5
|
readonly biomeId: string;
|
|
@@ -10,6 +11,7 @@ export interface ResolvedServiceContext {
|
|
|
10
11
|
readonly repoRoot: string;
|
|
11
12
|
readonly api: XemaApiConfig;
|
|
12
13
|
readonly version: string;
|
|
14
|
+
readonly ownership?: ClientOwnershipDeclaration;
|
|
13
15
|
}
|
|
14
16
|
export declare function findRepoRoot(start: string): string;
|
|
15
17
|
export declare function resolveServiceContext(serviceDir: string): ResolvedServiceContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-config.d.ts","sourceRoot":"","sources":["../../src/lib/service-config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"service-config.d.ts","sourceRoot":"","sources":["../../src/lib/service-config.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAetE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,sBAAsB;IAErC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC;IAQ5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAQzB,QAAQ,CAAC,SAAS,CAAC,EAAE,0BAA0B,CAAC;CACjD;AAGD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAYlD;AAOD,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,sBAAsB,CA0DhF;AAeD,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,UAAU,GAClB,MAAM,CAUR;AAGD,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,UAAU,GAClB,MAAM,CAER;AAGD,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,UAAU,GAClB,MAAM,CAMR;AAGD,wBAAgB,eAAe,CAC7B,GAAG,EAAE,sBAAsB,EAC3B,OAAO,EAAE,UAAU,EAWnB,MAAM,CAAC,EAAE,MAAM,GACd,MAAM,CAER"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-config.js","sourceRoot":"","sources":["../../src/lib/service-config.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"service-config.js","sourceRoot":"","sources":["../../src/lib/service-config.ts"],"names":[],"mappings":";;AAqDA,oCAYC;AAOD,sDA0DC;AAeD,wDAaC;AAGD,4DAKC;AAGD,4CASC;AAGD,0CAgBC;AArM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AC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;KACtD,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xemahq/api-client-generator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Layer 1 — the single, central OpenAPI + ORVAL client generator for every Xema NestJS service. Replaces the per-service orval.config.ts / scripts/extract-openapi.ts / scripts/build-client-index.js trio with two bins (xema-openapi, xema-client-generate). Extracts one OpenAPI document per ApiSurface (public/internal/operator) using the @XemaApiSurface decorator metadata, generates one ORVAL client package per non-empty surface (every surface of a service landing on ONE derived version — the highest its clients already carry, advanced a patch when the generated output changes), and stamps deterministic `xema` provenance metadata into each generated client package.json. No heuristics: a route ships in a surface only if it (or its controller) is explicitly classified, and no client version is ever typed by hand.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"xema",
|
|
@@ -62,8 +62,8 @@
|
|
|
62
62
|
"prettier": "3.6.2",
|
|
63
63
|
"reflect-metadata": "0.2.2",
|
|
64
64
|
"typescript": "5.9.3",
|
|
65
|
-
"@xemahq/
|
|
66
|
-
"@xemahq/
|
|
65
|
+
"@xemahq/xema-decorators": "0.16.0",
|
|
66
|
+
"@xemahq/eslint-config": "0.7.0"
|
|
67
67
|
},
|
|
68
68
|
"exports": {
|
|
69
69
|
".": {
|