@xemahq/api-client-generator 0.19.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.
Files changed (40) hide show
  1. package/README.md +26 -0
  2. package/dist/.source-stamp.json +2 -2
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +1 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/lib/assert-declared-get-responses.d.ts.map +1 -1
  8. package/dist/lib/assert-declared-get-responses.js +0 -7
  9. package/dist/lib/assert-declared-get-responses.js.map +1 -1
  10. package/dist/lib/client-package.d.ts +1 -1
  11. package/dist/lib/client-package.d.ts.map +1 -1
  12. package/dist/lib/client-package.js +43 -9
  13. package/dist/lib/client-package.js.map +1 -1
  14. package/dist/lib/client-repository.d.ts +7 -0
  15. package/dist/lib/client-repository.d.ts.map +1 -1
  16. package/dist/lib/client-repository.js +49 -0
  17. package/dist/lib/client-repository.js.map +1 -1
  18. package/dist/lib/client-surface.d.ts +26 -0
  19. package/dist/lib/client-surface.d.ts.map +1 -0
  20. package/dist/lib/client-surface.js +240 -0
  21. package/dist/lib/client-surface.js.map +1 -0
  22. package/dist/lib/client-version.d.ts +13 -0
  23. package/dist/lib/client-version.d.ts.map +1 -1
  24. package/dist/lib/client-version.js +80 -9
  25. package/dist/lib/client-version.js.map +1 -1
  26. package/dist/lib/custom-fetch-template.d.ts +1 -1
  27. package/dist/lib/custom-fetch-template.d.ts.map +1 -1
  28. package/dist/lib/custom-fetch-template.js +57 -4
  29. package/dist/lib/custom-fetch-template.js.map +1 -1
  30. package/dist/lib/extract-openapi.d.ts.map +1 -1
  31. package/dist/lib/extract-openapi.js +35 -0
  32. package/dist/lib/extract-openapi.js.map +1 -1
  33. package/dist/lib/generate-clients.d.ts +10 -1
  34. package/dist/lib/generate-clients.d.ts.map +1 -1
  35. package/dist/lib/generate-clients.js +106 -5
  36. package/dist/lib/generate-clients.js.map +1 -1
  37. package/dist/lib/service-config.d.ts +2 -0
  38. package/dist/lib/service-config.d.ts.map +1 -1
  39. package/dist/lib/service-config.js.map +1 -1
  40. package/package.json +3 -3
@@ -0,0 +1,240 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.extractClientSurface = extractClientSurface;
37
+ exports.classifySurfaceChange = classifySurfaceChange;
38
+ exports.resolveClientBumpClass = resolveClientBumpClass;
39
+ const node_fs_1 = require("node:fs");
40
+ const ts = __importStar(require("typescript"));
41
+ const client_version_1 = require("./client-version");
42
+ function extractClientSurface(clientSrc) {
43
+ const exports = new Map();
44
+ const unrecognised = [];
45
+ const printer = ts.createPrinter({
46
+ removeComments: true,
47
+ newLine: ts.NewLineKind.LineFeed,
48
+ });
49
+ for (const file of (0, client_version_1.listGeneratedSubtreeFiles)(clientSrc)) {
50
+ if (!file.rel.endsWith('.ts')) {
51
+ unrecognised.push(file.rel);
52
+ continue;
53
+ }
54
+ const moduleKey = file.rel.slice(0, -'.ts'.length);
55
+ const source = ts.createSourceFile(file.rel, (0, node_fs_1.readFileSync)(file.abs, 'utf8'), ts.ScriptTarget.Latest, false, ts.ScriptKind.TS);
56
+ for (const statement of source.statements) {
57
+ collectStatement({
58
+ statement,
59
+ source,
60
+ printer,
61
+ moduleKey,
62
+ rel: file.rel,
63
+ exports,
64
+ unrecognised,
65
+ });
66
+ }
67
+ }
68
+ return { exports, unrecognised };
69
+ }
70
+ function render(node, source, printer) {
71
+ return printer.printNode(ts.EmitHint.Unspecified, node, source);
72
+ }
73
+ function isExported(node) {
74
+ return (ts.canHaveModifiers(node) &&
75
+ (ts.getModifiers(node) ?? []).some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword));
76
+ }
77
+ function collectStatement(args) {
78
+ const { statement, source, printer, moduleKey, rel, exports, unrecognised } = args;
79
+ const put = (name, text) => {
80
+ exports.set(`${moduleKey}#${name}`, text);
81
+ };
82
+ if (ts.isExportDeclaration(statement)) {
83
+ const from = statement.moduleSpecifier
84
+ ? render(statement.moduleSpecifier, source, printer)
85
+ : '';
86
+ const typeOnly = statement.isTypeOnly ? 'type ' : '';
87
+ if (!statement.exportClause) {
88
+ put(`*${from}`, `export ${typeOnly}* from ${from}`);
89
+ return;
90
+ }
91
+ if (ts.isNamespaceExport(statement.exportClause)) {
92
+ put(statement.exportClause.name.text, `export ${typeOnly}* as ${statement.exportClause.name.text} from ${from}`);
93
+ return;
94
+ }
95
+ for (const element of statement.exportClause.elements) {
96
+ const local = element.propertyName?.text ?? element.name.text;
97
+ put(element.name.text, `export ${typeOnly}${element.isTypeOnly ? 'type ' : ''}{ ${local} as ${element.name.text} }${from ? ` from ${from}` : ''}`);
98
+ }
99
+ return;
100
+ }
101
+ if (ts.isExportAssignment(statement)) {
102
+ put(statement.isExportEquals ? 'export=' : 'default', render(statement, source, printer));
103
+ return;
104
+ }
105
+ if (!isExported(statement)) {
106
+ return;
107
+ }
108
+ if (ts.isInterfaceDeclaration(statement) ||
109
+ ts.isTypeAliasDeclaration(statement) ||
110
+ ts.isEnumDeclaration(statement) ||
111
+ ts.isClassDeclaration(statement) ||
112
+ ts.isFunctionDeclaration(statement) ||
113
+ ts.isModuleDeclaration(statement)) {
114
+ const name = statement.name;
115
+ if (!name || !ts.isIdentifier(name)) {
116
+ unrecognised.push(rel);
117
+ return;
118
+ }
119
+ put(name.text, render(statement, source, printer));
120
+ return;
121
+ }
122
+ if (ts.isVariableStatement(statement)) {
123
+ const list = statement.declarationList;
124
+ const kindWord = (list.flags & ts.NodeFlags.Const) !== 0
125
+ ? 'const'
126
+ : (list.flags & ts.NodeFlags.Let) !== 0
127
+ ? 'let'
128
+ : 'var';
129
+ for (const declaration of list.declarations) {
130
+ if (!ts.isIdentifier(declaration.name)) {
131
+ unrecognised.push(rel);
132
+ continue;
133
+ }
134
+ put(declaration.name.text, `export ${kindWord} ${render(declaration, source, printer)}`);
135
+ }
136
+ return;
137
+ }
138
+ unrecognised.push(rel);
139
+ }
140
+ const MAX_NAMED_REASONS = 8;
141
+ function summarise(label, keys) {
142
+ const named = keys.slice(0, MAX_NAMED_REASONS).join(', ');
143
+ const rest = keys.length - Math.min(keys.length, MAX_NAMED_REASONS);
144
+ return `${label} (${keys.length}): ${named}${rest > 0 ? `, +${rest} more` : ''}`;
145
+ }
146
+ function classifySurfaceChange(args) {
147
+ const { before, after, contentChanged } = args;
148
+ if (!contentChanged) {
149
+ return {
150
+ kind: 'determinate',
151
+ bumpClass: 'none',
152
+ reasons: ['no generated byte moved'],
153
+ };
154
+ }
155
+ const removed = [];
156
+ const changed = [];
157
+ for (const [key, text] of before.exports) {
158
+ const next = after.exports.get(key);
159
+ if (next === undefined) {
160
+ removed.push(key);
161
+ }
162
+ else if (next !== text) {
163
+ changed.push(key);
164
+ }
165
+ }
166
+ const added = [...after.exports.keys()].filter((key) => !before.exports.has(key));
167
+ if (removed.length > 0) {
168
+ return {
169
+ kind: 'determinate',
170
+ bumpClass: 'major',
171
+ reasons: [summarise('exports REMOVED from the published surface', removed.sort())],
172
+ };
173
+ }
174
+ const unreadable = [
175
+ ...new Set([...before.unrecognised, ...after.unrecognised]),
176
+ ].sort();
177
+ if (unreadable.length > 0) {
178
+ return {
179
+ kind: 'indeterminate',
180
+ reasons: [summarise('files carrying an export this generator cannot classify', unreadable)],
181
+ };
182
+ }
183
+ if (changed.length > 0) {
184
+ return {
185
+ kind: 'indeterminate',
186
+ reasons: [
187
+ summarise('exports whose DECLARATION changed', changed.sort()),
188
+ 'A retained export whose declaration moved may be widening or narrowing, ' +
189
+ 'and a generated client does not record whether a type is a REQUEST or ' +
190
+ 'a RESPONSE — the two have opposite variance, so the direction cannot be ' +
191
+ 'derived from the surface alone.',
192
+ ],
193
+ };
194
+ }
195
+ if (added.length > 0) {
196
+ return {
197
+ kind: 'determinate',
198
+ bumpClass: 'minor',
199
+ reasons: [summarise('exports ADDED, none removed or altered', added.sort())],
200
+ };
201
+ }
202
+ return {
203
+ kind: 'determinate',
204
+ bumpClass: 'patch',
205
+ reasons: [
206
+ 'generated bytes moved but no exported declaration did — a description ' +
207
+ 'or implementation change',
208
+ ],
209
+ };
210
+ }
211
+ function resolveClientBumpClass(args) {
212
+ const { verdict, explicit, serviceId, explicitOrigin } = args;
213
+ if (verdict.kind === 'indeterminate') {
214
+ if (explicit === undefined) {
215
+ throw new Error(`api-client-generator: ${serviceId} — regeneration changed the published ` +
216
+ 'client surface in a way this generator cannot classify, so it will not ' +
217
+ 'guess a version.\n' +
218
+ verdict.reasons.map((reason) => ` · ${reason}`).join('\n') +
219
+ '\nState the class explicitly and re-run:\n' +
220
+ ' xema-client-generate --bump-class=<patch|minor|major>\n' +
221
+ ' (or XEMA_CLIENT_BUMP_CLASS=<patch|minor|major>)\n' +
222
+ 'Decide it from the PUBLISHED tarball of the current version, not from ' +
223
+ 'this source tree — `npm pack <client>@<published>` and compare what a ' +
224
+ 'consumer can actually resolve.');
225
+ }
226
+ return explicit;
227
+ }
228
+ if (explicit === undefined) {
229
+ return verdict.bumpClass;
230
+ }
231
+ if ((0, client_version_1.bumpClassExceeds)(verdict.bumpClass, explicit)) {
232
+ throw new Error(`api-client-generator: ${serviceId} — ${explicitOrigin ?? 'the stated bump class'} ` +
233
+ `is "${explicit}", but the regenerated surface PROVES "${verdict.bumpClass}".\n` +
234
+ verdict.reasons.map((reason) => ` · ${reason}`).join('\n') +
235
+ `\nA proven class is a floor, never a suggestion. Raise the stated class to ` +
236
+ `"${verdict.bumpClass}" or higher, or remove it and let the proof decide.`);
237
+ }
238
+ return explicit;
239
+ }
240
+ //# sourceMappingURL=client-surface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-surface.js","sourceRoot":"","sources":["../../src/lib/client-surface.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwGA,oDAsCC;AA4JD,sDAoFC;AAqBD,wDAyCC;AA5bD,qCAAuC;AAEvC,+CAAiC;AAEjC,qDAI0B;AAgG1B,SAAgB,oBAAoB,CAAC,SAAiB;IACpD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC1C,MAAM,YAAY,GAAa,EAAE,CAAC;IAClC,MAAM,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC;QAC/B,cAAc,EAAE,IAAI;QACpB,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ;KACjC,CAAC,CAAC;IAEH,KAAK,MAAM,IAAI,IAAI,IAAA,0CAAyB,EAAC,SAAS,CAAC,EAAE,CAAC;QACxD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAI9B,YAAY,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CAAC,IAAI,CAAC,IAAI,CAAC;gBAC3D,4CAA4C;gBAC5C,2DAA2D;gBAC3D,qDAAqD;gBACrD,wEAAwE;gBACxE,wEAAwE;gBACxE,gCAAgC,CACnC,CAAC;QACJ,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC,SAAS,CAAC;IAC3B,CAAC;IAED,IAAI,IAAA,iCAAgB,EAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CACb,yBAAyB,SAAS,MAAM,cAAc,IAAI,uBAAuB,GAAG;YAClF,OAAO,QAAQ,0CAA0C,OAAO,CAAC,SAAS,MAAM;YAChF,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YAC3D,6EAA6E;YAC7E,IAAI,OAAO,CAAC,SAAS,qDAAqD,CAC7E,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,17 +1,30 @@
1
1
  import { type ApiSurface } from '@xemahq/xema-decorators';
2
2
  import { type ResolvedServiceContext } from './service-config';
3
+ export type BumpClass = 'none' | 'patch' | 'minor' | 'major';
4
+ export declare const BUMP_CLASSES: readonly BumpClass[];
5
+ export declare function parseBumpClass(raw: string, origin: string): BumpClass;
6
+ export declare function bumpClassExceeds(a: BumpClass, b: BumpClass): boolean;
3
7
  export declare function parseVersionCore(v: string): [number, number, number] | null;
4
8
  export declare function compareVersionCore(a: string, b: string): number;
5
9
  export declare function bumpPatch(version: string): string;
10
+ export declare function applyBumpClass(version: string, bumpClass: BumpClass): string;
6
11
  export declare function resolveClientVersionBaseline(existingClientVersions: readonly string[], serviceVersion: string): string;
7
12
  export declare function advanceClientVersionLine(args: {
8
13
  readonly baseline: string;
9
14
  readonly contentChanged: boolean;
10
15
  readonly hadExistingClients: boolean;
16
+ readonly bumpClass: BumpClass;
11
17
  }): string;
12
18
  export declare function readExistingClientVersions(ctx: ResolvedServiceContext): {
13
19
  surface: ApiSurface;
14
20
  version: string;
15
21
  }[];
22
+ export declare const GENERATED_SUBTREES: readonly ["endpoints", "models"];
23
+ export interface GeneratedClientFile {
24
+ readonly subtree: string;
25
+ readonly rel: string;
26
+ readonly abs: string;
27
+ }
28
+ export declare function listGeneratedSubtreeFiles(clientSrc: string): GeneratedClientFile[];
16
29
  export declare function fingerprintGeneratedOutput(clientSrc: string): string;
17
30
  //# sourceMappingURL=client-version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client-version.d.ts","sourceRoot":"","sources":["../../src/lib/client-version.ts"],"names":[],"mappings":"AAIA,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAExE,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,kBAAkB,CAAC;AAwD1B,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAG3E;AAOD,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAmB/D;AAGD,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAUjD;AASD,wBAAgB,4BAA4B,CAC1C,sBAAsB,EAAE,SAAS,MAAM,EAAE,EACzC,cAAc,EAAE,MAAM,GACrB,MAAM,CAcR;AAUD,wBAAgB,wBAAwB,CAAC,IAAI,EAAE;IAC7C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;CACtC,GAAG,MAAM,CAGT;AAaD,wBAAgB,0BAA0B,CACxC,GAAG,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C1B,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC/B,GAAG,MAAM,CAcT;AAaD,wBAAgB,0BAA0B,CACxC,GAAG,EAAE,sBAAsB,GAC1B;IAAE,OAAO,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAAE,CAiC5C;AAGD,eAAO,MAAM,kBAAkB,kCAAmC,CAAC;AAGnE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAWD,wBAAgB,yBAAyB,CACvC,SAAS,EAAE,MAAM,GAChB,mBAAmB,EAAE,CAYvB;AAWD,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAwBpE"}
@@ -1,17 +1,46 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GENERATED_SUBTREES = exports.BUMP_CLASSES = void 0;
4
+ exports.parseBumpClass = parseBumpClass;
5
+ exports.bumpClassExceeds = bumpClassExceeds;
3
6
  exports.parseVersionCore = parseVersionCore;
4
7
  exports.compareVersionCore = compareVersionCore;
5
8
  exports.bumpPatch = bumpPatch;
9
+ exports.applyBumpClass = applyBumpClass;
6
10
  exports.resolveClientVersionBaseline = resolveClientVersionBaseline;
7
11
  exports.advanceClientVersionLine = advanceClientVersionLine;
8
12
  exports.readExistingClientVersions = readExistingClientVersions;
13
+ exports.listGeneratedSubtreeFiles = listGeneratedSubtreeFiles;
9
14
  exports.fingerprintGeneratedOutput = fingerprintGeneratedOutput;
10
15
  const node_crypto_1 = require("node:crypto");
11
16
  const node_fs_1 = require("node:fs");
12
17
  const node_path_1 = require("node:path");
13
18
  const xema_decorators_1 = require("@xemahq/xema-decorators");
14
19
  const service_config_1 = require("./service-config");
20
+ const BUMP_CLASS_RANK = {
21
+ none: 0,
22
+ patch: 1,
23
+ minor: 2,
24
+ major: 3,
25
+ };
26
+ exports.BUMP_CLASSES = [
27
+ 'none',
28
+ 'patch',
29
+ 'minor',
30
+ 'major',
31
+ ];
32
+ function parseBumpClass(raw, origin) {
33
+ const value = raw.trim().toLowerCase();
34
+ const match = exports.BUMP_CLASSES.find((candidate) => candidate === value);
35
+ if (!match) {
36
+ throw new Error(`api-client-generator: ${origin} is "${raw}", which is not a bump class. ` +
37
+ `Use one of ${exports.BUMP_CLASSES.join(' | ')}.`);
38
+ }
39
+ return match;
40
+ }
41
+ function bumpClassExceeds(a, b) {
42
+ return BUMP_CLASS_RANK[a] > BUMP_CLASS_RANK[b];
43
+ }
15
44
  function parseVersionCore(v) {
16
45
  const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v.trim());
17
46
  return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
@@ -43,6 +72,26 @@ function bumpPatch(version) {
43
72
  const [major, minor, patch] = parsed;
44
73
  return `${major}.${minor}.${patch + 1}`;
45
74
  }
75
+ function applyBumpClass(version, bumpClass) {
76
+ const parsed = parseVersionCore(version);
77
+ if (!parsed) {
78
+ throw new Error(`api-client-generator: cannot advance client version "${version}" — it is not ` +
79
+ 'release semver `x.y.z`.');
80
+ }
81
+ const [major, minor, patch] = parsed;
82
+ if (bumpClass === 'none') {
83
+ return `${major}.${minor}.${patch}`;
84
+ }
85
+ const stable = major >= 1;
86
+ switch (bumpClass) {
87
+ case 'major':
88
+ return stable ? `${major + 1}.0.0` : `${major}.${minor + 1}.0`;
89
+ case 'minor':
90
+ return stable ? `${major}.${minor + 1}.0` : `${major}.${minor}.${patch + 1}`;
91
+ case 'patch':
92
+ return `${major}.${minor}.${patch + 1}`;
93
+ }
94
+ }
46
95
  function resolveClientVersionBaseline(existingClientVersions, serviceVersion) {
47
96
  if (existingClientVersions.length === 0) {
48
97
  if (!parseVersionCore(serviceVersion)) {
@@ -55,8 +104,17 @@ function resolveClientVersionBaseline(existingClientVersions, serviceVersion) {
55
104
  return existingClientVersions.reduce((highest, candidate) => compareVersionCore(candidate, highest) > 0 ? candidate : highest);
56
105
  }
57
106
  function advanceClientVersionLine(args) {
58
- const { baseline, contentChanged, hadExistingClients } = args;
59
- return contentChanged && hadExistingClients ? bumpPatch(baseline) : baseline;
107
+ const { baseline, contentChanged, hadExistingClients, bumpClass } = args;
108
+ if (!contentChanged || !hadExistingClients) {
109
+ return baseline;
110
+ }
111
+ if (bumpClass === 'none') {
112
+ throw new Error('api-client-generator: regeneration changed the generated output but the ' +
113
+ 'resolved bump class is "none". Changed bytes under an already-published ' +
114
+ 'version is what the version-coverage gate refuses; the class must say how ' +
115
+ 'far the line moves.');
116
+ }
117
+ return applyBumpClass(baseline, bumpClass);
60
118
  }
61
119
  function readExistingClientVersions(ctx) {
62
120
  const found = [];
@@ -85,19 +143,32 @@ function readExistingClientVersions(ctx) {
85
143
  }
86
144
  return found;
87
145
  }
88
- const GENERATED_SUBTREES = ['endpoints', 'models'];
146
+ exports.GENERATED_SUBTREES = ['endpoints', 'models'];
147
+ function listGeneratedSubtreeFiles(clientSrc) {
148
+ const files = [];
149
+ for (const subtree of exports.GENERATED_SUBTREES) {
150
+ const root = (0, node_path_1.join)(clientSrc, subtree);
151
+ if (!(0, node_fs_1.existsSync)(root)) {
152
+ continue;
153
+ }
154
+ for (const rel of listFilesRecursively(root)) {
155
+ files.push({ subtree, rel: `${subtree}/${rel}`, abs: (0, node_path_1.join)(root, rel) });
156
+ }
157
+ }
158
+ return files;
159
+ }
89
160
  function fingerprintGeneratedOutput(clientSrc) {
90
161
  const hash = (0, node_crypto_1.createHash)('sha256');
91
- for (const subtree of GENERATED_SUBTREES) {
92
- const root = (0, node_path_1.join)(clientSrc, subtree);
162
+ const files = listGeneratedSubtreeFiles(clientSrc);
163
+ for (const subtree of exports.GENERATED_SUBTREES) {
93
164
  hash.update(`\u0000tree:${subtree}\u0000`);
94
- if (!(0, node_fs_1.existsSync)(root)) {
165
+ if (!(0, node_fs_1.existsSync)((0, node_path_1.join)(clientSrc, subtree))) {
95
166
  hash.update('absent');
96
167
  continue;
97
168
  }
98
- for (const rel of listFilesRecursively(root)) {
99
- hash.update(`\u0000${rel}\u0000`);
100
- hash.update((0, node_fs_1.readFileSync)((0, node_path_1.join)(root, rel)));
169
+ for (const file of files.filter((f) => f.subtree === subtree)) {
170
+ hash.update(`\u0000${file.rel}\u0000`);
171
+ hash.update((0, node_fs_1.readFileSync)(file.abs));
101
172
  }
102
173
  }
103
174
  return hash.digest('hex');
@@ -1 +1 @@
1
- {"version":3,"file":"client-version.js","sourceRoot":"","sources":["../../src/lib/client-version.ts"],"names":[],"mappings":";;AAiEA,4CAGC;AAOD,gDAmBC;AAGD,8BAUC;AASD,oEAiBC;AAUD,4DAOC;AAaD,gEAmCC;AAcD,gEAsBC;AA1OD,6CAAyC;AACzC,qCAA0E;AAC1E,yCAAiC;AAEjC,6DAAwE;AAExE,qDAG0B;AAwD1B,SAAgB,gBAAgB,CAAC,CAAS;IACxC,MAAM,CAAC,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAChD,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/D,CAAC;AAOD,SAAgB,kBAAkB,CAAC,CAAS,EAAE,CAAS;IACrD,MAAM,EAAE,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,EAAE,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC/B,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,EAA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BACP,CAAC,CAAC,IAAA,kBAAQ,EAAC,IAAA,gBAAI,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAC9C,IAAI,WAAW,EAAE,CAAC;YAChB,GAAG,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;QAC/C,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAChB,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -1,2 +1,2 @@
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\nasync function parseBody(response: Response): Promise<unknown> {\n const contentType = response.headers.get('content-type');\n if (contentType?.includes('application/json')) {\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,iseAgXlC,CAAC"}
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"}
@@ -340,14 +340,67 @@ export const customFetch = async <T>(
340
340
  }
341
341
  };
342
342
 
343
- async function parseBody(response: Response): Promise<unknown> {
344
- const contentType = response.headers.get('content-type');
345
- if (contentType?.includes('application/json')) {
346
- return response.json();
343
+ /**
344
+ * Does this media type carry JSON?
345
+ *
346
+ * ── THE OUTAGE THIS FIXES ────────────────────────────────────────────────
347
+ *
348
+ * This used to be \`contentType?.includes('application/json')\`, and EVERY error
349
+ * this fleet returns failed that test. The platform's \`GlobalExceptionFilter\`
350
+ * emits RFC 9457 problem documents and sets the media type explicitly —
351
+ * \`.type(PROBLEM_DETAILS_CONTENT_TYPE)\` before \`.json()\`, so it cannot be
352
+ * overridden — and that constant is \`application/problem+json\`, which does NOT
353
+ * contain the substring \`application/json\`: after \`application/\` comes
354
+ * \`problem+json\`.
355
+ *
356
+ * So every non-2xx body fell through to \`response.text()\` and reached the
357
+ * caller as an UNPARSED STRING. \`ClientError.body\` is typed \`unknown\`, so
358
+ * nothing complained; every consumer that reads a machine-readable code off an
359
+ * error — \`error.body.code\`, \`error.body.details.code\` — silently read
360
+ * \`undefined\` instead, for every error, in every service.
361
+ *
362
+ * Measured in production on 2026-09-15: skill-registry-api's
363
+ * \`resolveOrNull()\` absorbs \`RELEASE_CHANNEL_NOT_FOUND\` into \`null\` by exactly
364
+ * that read. With the code unreadable the absorb never fired, a routine "no
365
+ * pointer on this channel" 404 became a 500 on \`GET /skills\` and
366
+ * \`GET /describe-objects\`, and agent-session-api's \`apply_control_bundle\` step
367
+ * aborted EVERY session launch in the organisation — 7,871 failed resolutions
368
+ * an hour. A fix written for that exact page months earlier was present in the
369
+ * running image and could not help, because the classifier it repaired was
370
+ * being handed a string.
371
+ *
372
+ * ── WHY THE STRUCTURED SUFFIX, NOT A SECOND SUBSTRING ────────────────────
373
+ *
374
+ * Adding \`|| includes('application/problem+json')\` would fix this one media
375
+ * type and leave the next one — \`application/vnd.api+json\`, and anything else
376
+ * a service legitimately emits. RFC 6839 defines \`+json\` as the structured
377
+ * syntax suffix meaning "this is JSON"; that is the actual rule, so it is the
378
+ * rule implemented. Parameters are stripped first, because
379
+ * \`application/problem+json; charset=utf-8\` is the same media type.
380
+ */
381
+ function isJsonMediaType(contentType: string | null): boolean {
382
+ if (contentType === null) {
383
+ return false;
347
384
  }
385
+ const essence = contentType.split(';')[0]?.trim().toLowerCase() ?? '';
386
+ return essence === 'application/json' || essence.endsWith('+json');
387
+ }
388
+
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\`.
348
397
  if (response.status === 204) {
349
398
  return undefined;
350
399
  }
400
+ const contentType = response.headers.get('content-type');
401
+ if (isJsonMediaType(contentType)) {
402
+ return response.json();
403
+ }
351
404
  return response.text();
352
405
  }
353
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgXrC,CAAC"}
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,EAShB,MAAM,yBAAyB,CAAC;AA+DjC,wBAAsB,wBAAwB,CAC5C,UAAU,GAAE,MAAsB,EAOlC,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,UAAU,EAAE,CAAC,CAwLvB;AAGD,wBAAgB,aAAa,IAAI,IAAI,CAiBpC"}
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"}