@ahoo-wang/wow-generator 10.0.0-alpha.7 → 10.0.0-beta.1

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.
@@ -4,7 +4,7 @@ import { parse as h } from "yaml";
4
4
  import { readFile as g } from "fs";
5
5
  import { join as _ } from "node:path";
6
6
  // src/api/configuration.ts
7
- var ee = "./wow-generator.config.json", te = {
7
+ var v = "./wow-generator.config.json", ee = {
8
8
  success: 0,
9
9
  internal: 1,
10
10
  input: 2,
@@ -12,27 +12,27 @@ var ee = "./wow-generator.config.json", te = {
12
12
  specification: 4,
13
13
  output: 5,
14
14
  interrupted: 130
15
- }, v = class extends Error {
15
+ }, y = class extends Error {
16
16
  kind;
17
17
  constructor(e, t, n) {
18
18
  super(t, n), this.kind = e, this.name = "GeneratorError";
19
19
  }
20
20
  get exitCode() {
21
- return te[this.kind];
21
+ return ee[this.kind];
22
22
  }
23
23
  };
24
- function y(e) {
24
+ function b(e) {
25
25
  return e instanceof Error ? e.message : String(e);
26
26
  }
27
27
  // src/api/logger.ts
28
- function ne() {
28
+ function te() {
29
29
  return !!process.stdout?.isTTY && !process.env.NO_COLOR;
30
30
  }
31
- var re = class {
31
+ var ne = class {
32
32
  level;
33
33
  decorate;
34
34
  constructor(e = {}) {
35
- this.level = e.level ?? "normal", this.decorate = e.decorate ?? ne();
35
+ this.level = e.level ?? "normal", this.decorate = e.decorate ?? te();
36
36
  }
37
37
  format(e, t, n) {
38
38
  let r = this.decorate ? `${e} ` : t ? `${t}: ` : "";
@@ -50,25 +50,25 @@ var re = class {
50
50
  error(e, ...t) {
51
51
  console.error(this.format("❌", "error", e), ...t);
52
52
  }
53
- }, ie = class {
53
+ }, re = class {
54
54
  debug() {}
55
55
  info() {}
56
56
  warn() {}
57
57
  error() {}
58
58
  };
59
59
  // src/naming/paths.ts
60
- function ae(e, t) {
60
+ function ie(e, t) {
61
61
  return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? t : t ? `${e.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}` : e;
62
62
  }
63
- var oe = "types.ts";
64
- function se(e) {
65
- return ae(e.path, oe);
63
+ var ae = "types.ts";
64
+ function oe(e) {
65
+ return ie(e.path, ae);
66
66
  }
67
67
  // src/openapi/references.ts
68
- function b(e) {
68
+ function x(e) {
69
69
  return !!(e && typeof e == "object" && "$ref" in e);
70
70
  }
71
- function ce(e, t) {
71
+ function se(e, t) {
72
72
  let n = t.slice(1);
73
73
  try {
74
74
  n = decodeURIComponent(n);
@@ -83,7 +83,7 @@ function ce(e, t) {
83
83
  }
84
84
  return r;
85
85
  }
86
- function le(e) {
86
+ function ce(e) {
87
87
  let t = [], n = /* @__PURE__ */ new Set(), r = (i, a) => {
88
88
  if (typeof i != "object" || !i || n.has(i)) return;
89
89
  if (n.add(i), Array.isArray(i)) {
@@ -91,7 +91,7 @@ function le(e) {
91
91
  return;
92
92
  }
93
93
  let o = i.$ref;
94
- typeof o == "string" && o.startsWith("#/components/") && ce(e, o) === void 0 && t.push({
94
+ typeof o == "string" && o.startsWith("#/components/") && se(e, o) === void 0 && t.push({
95
95
  ref: o,
96
96
  location: a || "/"
97
97
  });
@@ -100,111 +100,111 @@ function le(e) {
100
100
  return r(e, ""), t;
101
101
  }
102
102
  // src/openapi/components.ts
103
- var x = "#/components/", ue = `${x}parameters/`, de = `${x}requestBodies/`, fe = `${x}responses/`, pe = `${x}schemas/`;
104
- function me(e) {
103
+ var S = "#/components/", le = `${S}parameters/`, ue = `${S}requestBodies/`, de = `${S}responses/`, fe = `${S}schemas/`;
104
+ function pe(e) {
105
105
  return e.$ref.split("/").pop();
106
106
  }
107
- function S(e, t, n) {
107
+ function C(e, t, n) {
108
108
  let r = /* @__PURE__ */ new Set(), i = e;
109
- for (; b(i);) {
109
+ for (; x(i);) {
110
110
  if (!i.$ref.startsWith(n)) return;
111
- if (r.has(i.$ref)) throw new v("specification", `Cyclic component reference: ${i.$ref}`);
111
+ if (r.has(i.$ref)) throw new y("specification", `Cyclic component reference: ${i.$ref}`);
112
112
  r.add(i.$ref), i = t?.[i.$ref.slice(n.length)];
113
113
  }
114
114
  return i;
115
115
  }
116
- function C(e, t) {
117
- return S(e, t.schemas, pe);
116
+ function w(e, t) {
117
+ return C(e, t.schemas, fe);
118
+ }
119
+ function me(e, t) {
120
+ return C(e, t.responses, de);
118
121
  }
119
122
  function he(e, t) {
120
- return S(e, t.responses, fe);
123
+ return C(e, t.requestBodies, ue);
121
124
  }
122
125
  function ge(e, t) {
123
- return S(e, t.requestBodies, de);
124
- }
125
- function _e(e, t) {
126
- return S(e, t.parameters, ue);
126
+ return C(e, t.parameters, le);
127
127
  }
128
128
  // src/naming/order.ts
129
- var ve = new Intl.Collator("en-US");
130
- function w(e, t) {
131
- return ve.compare(e, t);
129
+ var _e = new Intl.Collator("en-US");
130
+ function T(e, t) {
131
+ return _e.compare(e, t);
132
132
  }
133
133
  // src/openapi/responses.ts
134
- var ye = "application/json", be = "text/event-stream";
135
- function xe(e) {
134
+ var ve = "application/json", ye = "text/event-stream";
135
+ function be(e) {
136
136
  return e.split(";")[0].trim().toLowerCase();
137
137
  }
138
- function Se(e) {
139
- let t = xe(e);
138
+ function xe(e) {
139
+ let t = be(e);
140
140
  return t === "application/json" || /^application\/[^/]+\+json$/.test(t);
141
141
  }
142
- function Ce(e) {
143
- let t = xe(e);
142
+ function Se(e) {
143
+ let t = be(e);
144
144
  return t.startsWith("text/") && t !== "text/event-stream";
145
145
  }
146
- function T(e, t, n = (e) => xe(e) === t) {
146
+ function E(e, t, n = (e) => be(e) === t) {
147
147
  if (!e) return;
148
148
  if (e[t]) return e[t];
149
149
  let r = Object.keys(e).find(n);
150
150
  return r === void 0 ? void 0 : e[r];
151
151
  }
152
- function we(e, t) {
153
- if (t && !b(t)) return T(t.content, e)?.schema;
152
+ function Ce(e, t) {
153
+ if (t && !x(t)) return E(t.content, e)?.schema;
154
+ }
155
+ function we(e) {
156
+ if (e && !x(e)) return E(e.content, ve, xe)?.schema;
154
157
  }
155
158
  function Te(e) {
156
- if (e && !b(e)) return T(e.content, ye, Se)?.schema;
159
+ return Ce(ye, e);
157
160
  }
158
161
  function Ee(e) {
159
- return we(be, e);
162
+ return Ce("*/*", e);
160
163
  }
161
164
  function De(e) {
162
- return we("*/*", e);
163
- }
164
- function Oe(e) {
165
- return !e || b(e) ? !1 : Object.keys(e.content ?? {}).some(Ce);
165
+ return !e || x(e) ? !1 : Object.keys(e.content ?? {}).some(Se);
166
166
  }
167
167
  // src/openapi/schemas.ts
168
- function E(e) {
168
+ function D(e) {
169
169
  return Array.isArray(e.enum) && e.enum.length > 0;
170
170
  }
171
- var ke = "x-enum-text";
172
- function Ae(e) {
173
- return e[ke];
171
+ var Oe = "x-enum-text";
172
+ function ke(e) {
173
+ return e[Oe];
174
174
  }
175
- function je(e) {
175
+ function Ae(e) {
176
176
  return e.type === "object" && !!e.properties;
177
177
  }
178
- function Me(e) {
178
+ function je(e) {
179
179
  return e.type === "array" && !!e.items;
180
180
  }
181
- function Ne(e) {
181
+ function Me(e) {
182
182
  return Array.isArray(e.anyOf) && e.anyOf.length > 0;
183
183
  }
184
- function Pe(e) {
184
+ function Ne(e) {
185
185
  return Array.isArray(e.oneOf) && e.oneOf.length > 0;
186
186
  }
187
- function Fe(e) {
187
+ function Pe(e) {
188
188
  return Array.isArray(e.allOf) && e.allOf.length > 0;
189
189
  }
190
- function D(e) {
191
- return Ne(e) || Pe(e) || Fe(e);
190
+ function O(e) {
191
+ return Me(e) || Ne(e) || Pe(e);
192
192
  }
193
- function Ie(e) {
193
+ function Fe(e) {
194
194
  return e.includes("|") || e.includes("&") ? `(${e})[]` : `${e}[]`;
195
195
  }
196
- function Le(e) {
196
+ function Ie(e) {
197
197
  return e.type === "object" && !e.properties && e.additionalProperties !== void 0;
198
198
  }
199
- var Re = "x-map-key-schema";
200
- function ze(e) {
201
- return e[Re];
199
+ var Le = "x-map-key-schema";
200
+ function Re(e) {
201
+ return e[Le];
202
202
  }
203
- function Be(e) {
203
+ function ze(e) {
204
204
  return e.readOnly === !0;
205
205
  }
206
- function Ve(e) {
207
- if (Array.isArray(e)) return e.map((e) => Ve(e)).join(" | ");
206
+ function Be(e) {
207
+ if (Array.isArray(e)) return e.map((e) => Be(e)).join(" | ");
208
208
  switch (e) {
209
209
  case "string": return "string";
210
210
  case "number":
@@ -214,10 +214,10 @@ function Ve(e) {
214
214
  default: return "any";
215
215
  }
216
216
  }
217
- function He(e, t) {
217
+ function Ve(e, t) {
218
218
  let n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = !1, o = (e) => {
219
219
  if (!(!e || i.has(e) || a)) {
220
- if (i.add(e), b(e)) o(t && C(e, t));
220
+ if (i.add(e), x(e)) o(t && w(e, t));
221
221
  else if (e.nullable || Array.isArray(e.type)) a = !0;
222
222
  else {
223
223
  for (let t of e.required ?? []) r.add(t);
@@ -229,32 +229,32 @@ function He(e, t) {
229
229
  return o(e), a ? [] : n.filter((e) => !r.has(e));
230
230
  }
231
231
  // src/openapi/operations.ts
232
- function Ue(e, t) {
233
- return e.operation.operationId && t.operation.operationId ? w(e.operation.operationId, t.operation.operationId) : e.path && t.path ? w(e.path, t.path) : e.method && t.method ? w(e.method, t.method) : 0;
232
+ function He(e, t) {
233
+ return e.operation.operationId && t.operation.operationId ? T(e.operation.operationId, t.operation.operationId) : e.path && t.path ? T(e.path, t.path) : e.method && t.method ? T(e.method, t.method) : 0;
234
234
  }
235
- function We(e, t, n) {
235
+ function Ue(e, t, n) {
236
236
  let r = /* @__PURE__ */ new Map();
237
237
  for (let i of [...e, ...t]) {
238
- let e = b(i) ? n && _e(i, n) : i, t = e ? `${e.in}:${e.name}` : i.$ref;
238
+ let e = x(i) ? n && ge(i, n) : i, t = e ? `${e.in}:${e.name}` : i.$ref;
239
239
  r.set(t, i);
240
240
  }
241
241
  return [...r.values()];
242
242
  }
243
- function Ge(e, t) {
243
+ function We(e, t) {
244
244
  let n = [];
245
- for (let [r, i] of Object.entries(e)) Ke(i).forEach((e) => {
245
+ for (let [r, i] of Object.entries(e)) Ge(i).forEach((e) => {
246
246
  n.push({
247
247
  method: e.method,
248
248
  operation: i.parameters?.length ? {
249
249
  ...e.operation,
250
- parameters: We(i.parameters, e.operation.parameters ?? [], t)
250
+ parameters: Ue(i.parameters, e.operation.parameters ?? [], t)
251
251
  } : e.operation,
252
252
  path: r
253
253
  });
254
254
  });
255
- return n.sort(Ue);
255
+ return n.sort(He);
256
256
  }
257
- function Ke(e) {
257
+ function Ge(e) {
258
258
  return [
259
259
  {
260
260
  method: "get",
@@ -290,20 +290,20 @@ function Ke(e) {
290
290
  }
291
291
  ].filter(({ operation: e }) => e !== void 0);
292
292
  }
293
- function qe(e) {
293
+ function Ke(e) {
294
294
  let t = Object.keys(e.responses ?? {});
295
295
  if (t.includes("200")) return "200";
296
296
  let n = t.filter((e) => /^2\d\d$/.test(e)).sort();
297
297
  return n.length > 0 ? n[0] : t.find((e) => e.toUpperCase() === "2XX");
298
298
  }
299
+ function qe(e, t) {
300
+ let n = Ke(e), r = n ? e.responses[n] : void 0;
301
+ return t && x(r) ? me(r, t) : r;
302
+ }
299
303
  function Je(e, t) {
300
- let n = qe(e), r = n ? e.responses[n] : void 0;
301
- return t && b(r) ? he(r, t) : r;
304
+ return (e.parameters ?? []).map((e) => x(e) ? ge(e, t) : e).filter((e) => e !== void 0);
302
305
  }
303
306
  function Ye(e, t) {
304
- return (e.parameters ?? []).map((e) => b(e) ? _e(e, t) : e).filter((e) => e !== void 0);
305
- }
306
- function Xe(e, t) {
307
307
  let n = (t) => {
308
308
  let n = e.indexOf(`{${t.name}}`);
309
309
  return n < 0 ? 2 ** 53 - 1 : n;
@@ -311,31 +311,31 @@ function Xe(e, t) {
311
311
  return [...t].sort((e, t) => n(e) - n(t));
312
312
  }
313
313
  // src/naming/naming.ts
314
- var Ze = /[^\p{L}\p{N}$]+/u, Qe = /* @__PURE__ */ new Set(/* @__PURE__ */ "arguments.await.break.case.catch.class.const.continue.debugger.default.delete.do.else.enum.eval.export.extends.false.finally.for.function.if.implements.import.in.instanceof.interface.let.new.null.package.private.protected.public.return.static.super.switch.this.throw.true.try.typeof.var.void.while.with.yield".split("."));
315
- function O(e) {
316
- return /^[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*$/u.test(e) && !Qe.has(e);
314
+ var Xe = /[^\p{L}\p{N}$]+/u, Ze = /* @__PURE__ */ new Set(/* @__PURE__ */ "arguments.await.break.case.catch.class.const.continue.debugger.default.delete.do.else.enum.eval.export.extends.false.finally.for.function.if.implements.import.in.instanceof.interface.let.new.null.package.private.protected.public.return.static.super.switch.this.throw.true.try.typeof.var.void.while.with.yield".split("."));
315
+ function k(e) {
316
+ return /^[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*$/u.test(e) && !Ze.has(e);
317
317
  }
318
- function $e(e) {
318
+ function Qe(e) {
319
319
  return /^\p{N}/u.test(e) ? `_${e}` : e;
320
320
  }
321
+ function $e(e) {
322
+ if (k(e)) return e;
323
+ let t = Qe(M(e) || "_");
324
+ return Ze.has(t) ? `${t}_` : t;
325
+ }
321
326
  function et(e) {
322
- if (O(e)) return e;
323
- let t = $e(j(e) || "_");
324
- return Qe.has(t) ? `${t}_` : t;
327
+ return /^\p{Lu}[\p{L}\p{N}$]*$/u.test(e) && k(e);
325
328
  }
326
- function tt(e) {
327
- return /^\p{Lu}[\p{L}\p{N}$]*$/u.test(e) && O(e);
329
+ function A(e) {
330
+ return Qe((Array.isArray(e) ? e : [e]).map((e) => et(e) ? e : j(e)).join("") || "_");
328
331
  }
329
- function k(e) {
330
- return $e((Array.isArray(e) ? e : [e]).map((e) => tt(e) ? e : A(e)).join("") || "_");
332
+ function tt(e) {
333
+ return e.split(Xe);
331
334
  }
332
335
  function nt(e) {
333
- return e.split(Ze);
336
+ return Array.isArray(e) ? e.flatMap((e) => rt(tt(e))) : rt(tt(e));
334
337
  }
335
338
  function rt(e) {
336
- return Array.isArray(e) ? e.flatMap((e) => it(nt(e))) : it(nt(e));
337
- }
338
- function it(e) {
339
339
  return e.flatMap((e) => {
340
340
  if (e.length === 0) return [];
341
341
  let t = [], n = "";
@@ -346,50 +346,50 @@ function it(e) {
346
346
  return n && t.push(n), t;
347
347
  });
348
348
  }
349
- function A(e) {
350
- return e === "" || e.length === 0 ? "" : rt(e).filter((e) => e.length > 0).map((e) => {
349
+ function j(e) {
350
+ return e === "" || e.length === 0 ? "" : nt(e).filter((e) => e.length > 0).map((e) => {
351
351
  let t = e.charAt(0), n = e.slice(1);
352
352
  return (/[a-zA-Z]/.test(t) ? t.toUpperCase() : t) + n.toLowerCase();
353
353
  }).join("");
354
354
  }
355
- function j(e) {
356
- let t = A(e);
357
- return t.charAt(0).toLowerCase() + t.slice(1);
358
- }
359
355
  function M(e) {
360
- return e === "" || Array.isArray(e) && e.length === 0 ? "" : rt(e).filter((e) => e.length > 0).map((e) => e.toUpperCase()).join("_");
356
+ let t = j(e);
357
+ return t.charAt(0).toLowerCase() + t.slice(1);
361
358
  }
362
359
  function N(e) {
363
- return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e) ? e : P(e);
364
- }
365
- function at(e) {
366
- return /^\d+$/.test(e) ? `NUM_${e}` : M(e) || e;
360
+ return e === "" || Array.isArray(e) && e.length === 0 ? "" : nt(e).filter((e) => e.length > 0).map((e) => e.toUpperCase()).join("_");
367
361
  }
368
362
  function P(e) {
363
+ return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e) ? e : F(e);
364
+ }
365
+ function it(e) {
366
+ return /^\d+$/.test(e) ? `NUM_${e}` : N(e) || e;
367
+ }
368
+ function F(e) {
369
369
  return `'${JSON.stringify(e).slice(1, -1).replace(/\\"/g, "\"").replace(/'/g, "\\'")}'`;
370
370
  }
371
371
  // src/analysis/clientNames.ts
372
- var ot = "x-fetcher-method";
373
- function st(e, t) {
372
+ var at = "x-fetcher-method";
373
+ function ot(e, t) {
374
374
  let n = t ?? e["x-fetcher-method"];
375
375
  if (n !== void 0) {
376
- if (typeof n != "string" || !ct(n)) throw new v("specification", `${ot} of ${e.operationId ?? "an operation"} is ${JSON.stringify(n)}, which is not a valid method name.`);
376
+ if (typeof n != "string" || !st(n)) throw new y("specification", `${at} of ${e.operationId ?? "an operation"} is ${JSON.stringify(n)}, which is not a valid method name.`);
377
377
  return n;
378
378
  }
379
379
  if (!e.operationId) return;
380
- let r = j(e.operationId.split(".").pop()) || "_";
380
+ let r = M(e.operationId.split(".").pop()) || "_";
381
381
  return /^\p{N}/u.test(r) ? `_${r}` : r;
382
382
  }
383
- function ct(e) {
384
- return O(e) || /^[a-z]+$/.test(e);
383
+ function st(e) {
384
+ return k(e) || /^[a-z]+$/.test(e);
385
385
  }
386
- function lt(e, t) {
387
- let n = et(e), r = n;
386
+ function ct(e, t) {
387
+ let n = $e(e), r = n;
388
388
  for (let e = 2; t.has(r); e++) r = `${n}${e}`;
389
389
  return t.add(r), r;
390
390
  }
391
391
  // src/analysis/modelInfo.ts
392
- function F(e) {
392
+ function I(e) {
393
393
  if (!e) return {
394
394
  name: "",
395
395
  path: "/"
@@ -401,20 +401,20 @@ function F(e) {
401
401
  }
402
402
  let r = t.slice(0, n), i = r.length > 0 ? `/${r.join("/")}` : "/";
403
403
  return {
404
- name: k(t.slice(n)),
404
+ name: A(t.slice(n)),
405
405
  path: i
406
406
  };
407
407
  }
408
- function ut(e, t) {
409
- if (!e.$ref.startsWith("#/components/schemas/")) throw new v("specification", `Unsupported schema reference: ${e.$ref}. Bundle or inline external schemas before generation.`);
410
- return t && C(e, t), F(me(e));
408
+ function lt(e, t) {
409
+ if (!e.$ref.startsWith("#/components/schemas/")) throw new y("specification", `Unsupported schema reference: ${e.$ref}. Bundle or inline external schemas before generation.`);
410
+ return t && w(e, t), I(pe(e));
411
411
  }
412
412
  // src/analysis/apiClients.ts
413
- var dt = ["httpRequest", "attributes"];
414
- function ft(e, t, n) {
415
- return new pt(e, t, n).clients();
413
+ var ut = ["httpRequest", "attributes"];
414
+ function dt(e, t, n) {
415
+ return new ft(e, t, n).clients();
416
416
  }
417
- var pt = class {
417
+ var ft = class {
418
418
  document;
419
419
  config;
420
420
  warnings;
@@ -424,16 +424,16 @@ var pt = class {
424
424
  clients() {
425
425
  let e = this.tags(), t = this.groupOperations(), n = /* @__PURE__ */ new Map();
426
426
  return [...t.keys()].sort().map((r) => {
427
- let i = F(r), a = i;
428
- for (let e = 2; n.has(ht(a)); e++) a = {
427
+ let i = I(r), a = i;
428
+ for (let e = 2; n.has(mt(a)); e++) a = {
429
429
  ...i,
430
430
  name: `${i.name}${e}`
431
431
  };
432
- return a !== i && this.warnings.push(`Tags ${n.get(ht(i))} and ${r} both name the API client ${i.name}ApiClient; ${r} generates ${a.name}ApiClient.`), n.set(ht(a), r), this.client(e.get(r), a, [...t.get(r)]);
432
+ return a !== i && this.warnings.push(`Tags ${n.get(mt(i))} and ${r} both name the API client ${i.name}ApiClient; ${r} generates ${a.name}ApiClient.`), n.set(mt(a), r), this.client(e.get(r), a, [...t.get(r)]);
433
433
  });
434
434
  }
435
435
  client(e, t, n) {
436
- let r = `${t.name}ApiClient`, i = ae(t.path, mt(r)), a = /* @__PURE__ */ new Map();
436
+ let r = `${t.name}ApiClient`, i = ie(t.path, pt(r)), a = /* @__PURE__ */ new Map();
437
437
  return {
438
438
  tagName: e.name,
439
439
  className: r,
@@ -443,7 +443,7 @@ var pt = class {
443
443
  };
444
444
  }
445
445
  method(e, t, n, r) {
446
- let { operation: i } = n, a = this.methodName(e, t, n, r), o = new Set(dt), s = this.parameters(e, n, o), c = this.body(i, o), l = [...s.filter(({ parameter: e }) => e.required), ...s.filter(({ parameter: e }) => !e.required)].filter(({ description: e }) => e);
446
+ let { operation: i } = n, a = this.methodName(e, t, n, r), o = new Set(ut), s = this.parameters(e, n, o), c = this.body(i, o), l = [...s.filter(({ parameter: e }) => e.required), ...s.filter(({ parameter: e }) => !e.required)].filter(({ description: e }) => e);
447
447
  return {
448
448
  name: a,
449
449
  httpMethod: n.method,
@@ -461,21 +461,21 @@ var pt = class {
461
461
  };
462
462
  }
463
463
  methodName(e, t, n, r) {
464
- let i = n.operation.operationId, a = st(n.operation, this.config.apiClients?.[e.name]?.methodNames?.[i]), o = r.get(a);
465
- if (o !== void 0) throw new v("specification", `Operations ${o} and ${i} of tag ${e.name} both generate the method ${t}.${a}(). Name one of them with apiClients["${e.name}"].methodNames in the generator configuration, or with the x-fetcher-method extension.`);
464
+ let i = n.operation.operationId, a = ot(n.operation, this.config.apiClients?.[e.name]?.methodNames?.[i]), o = r.get(a);
465
+ if (o !== void 0) throw new y("specification", `Operations ${o} and ${i} of tag ${e.name} both generate the method ${t}.${a}(). Name one of them with apiClients["${e.name}"].methodNames in the generator configuration, or with the x-fetcher-method extension.`);
466
466
  return r.set(a, i), a;
467
467
  }
468
468
  parameters(e, t, n) {
469
- let r = Ye(t.operation, this.document.components ?? {}), i = [];
469
+ let r = Je(t.operation, this.document.components ?? {}), i = [];
470
470
  for (let a of [
471
471
  "path",
472
472
  "query",
473
473
  "header"
474
474
  ]) {
475
475
  let o = r.filter((e) => e.in === a);
476
- for (let r of a === "path" ? Xe(t.path, o) : o) a === "path" && this.ignoresPathParameter(e.name, r.name) || i.push({
476
+ for (let r of a === "path" ? Ye(t.path, o) : o) a === "path" && this.ignoresPathParameter(e.name, r.name) || i.push({
477
477
  parameter: {
478
- name: lt(r.name, n),
478
+ name: ct(r.name, n),
479
479
  location: a,
480
480
  parameterName: r.name,
481
481
  schema: r.schema,
@@ -492,26 +492,26 @@ var pt = class {
492
492
  }
493
493
  body(e, t) {
494
494
  if (!e.requestBody) return;
495
- let n = b(e.requestBody) ? ge(e.requestBody, this.document.components) : e.requestBody;
495
+ let n = x(e.requestBody) ? he(e.requestBody, this.document.components) : e.requestBody;
496
496
  if (!n) return;
497
- let r = n.required === !0, i = n.content ?? {}, a = T(i, ye, Se), o = lt("body", t);
497
+ let r = n.required === !0, i = n.content ?? {}, a = E(i, ve, xe), o = ct("body", t);
498
498
  return a?.schema ? {
499
499
  name: o,
500
500
  required: r,
501
501
  content: {
502
502
  kind: "json",
503
503
  schema: a.schema,
504
- optionalFields: He(a.schema, this.document.components)
504
+ optionalFields: Ve(a.schema, this.document.components)
505
505
  }
506
- } : T(i, "multipart/form-data") ? {
506
+ } : E(i, "multipart/form-data") ? {
507
507
  name: o,
508
508
  required: r,
509
509
  content: { kind: "formData" }
510
- } : T(i, "application/x-www-form-urlencoded") ? {
510
+ } : E(i, "application/x-www-form-urlencoded") ? {
511
511
  name: o,
512
512
  required: r,
513
513
  content: { kind: "urlEncoded" }
514
- } : Object.keys(i).some(Ce) ? {
514
+ } : Object.keys(i).some(Se) ? {
515
515
  name: o,
516
516
  required: r,
517
517
  content: { kind: "text" }
@@ -522,20 +522,20 @@ var pt = class {
522
522
  };
523
523
  }
524
524
  returns(e) {
525
- let t = Je(e, this.document.components);
525
+ let t = qe(e, this.document.components);
526
526
  if (!t) return { kind: "response" };
527
- let n = Te(t), r = n || De(t);
527
+ let n = we(t), r = n || Ee(t);
528
528
  if (r) return {
529
529
  kind: "json",
530
530
  schema: r,
531
531
  wildcard: !n
532
532
  };
533
- let i = Ee(t);
533
+ let i = Te(t);
534
534
  if (i) {
535
- if (b(i)) {
536
- let e = C(i, this.document.components);
537
- if (Me(e) && b(e.items)) {
538
- let t = ut(e.items, this.document.components);
535
+ if (x(i)) {
536
+ let e = w(i, this.document.components);
537
+ if (je(e) && x(e.items)) {
538
+ let t = lt(e.items, this.document.components);
539
539
  return {
540
540
  kind: "eventStream",
541
541
  items: e.items,
@@ -548,7 +548,7 @@ var pt = class {
548
548
  serverSentEvent: !1
549
549
  };
550
550
  }
551
- return Oe(t) ? { kind: "text" } : { kind: "response" };
551
+ return De(t) ? { kind: "text" } : { kind: "response" };
552
552
  }
553
553
  groupOperations() {
554
554
  let e = /* @__PURE__ */ new Map();
@@ -571,49 +571,49 @@ var pt = class {
571
571
  return this.document.openAPI.tags?.forEach((t) => e.set(t.name, t)), e;
572
572
  }
573
573
  };
574
- function mt(e) {
574
+ function pt(e) {
575
575
  return `${e.charAt(0).toLowerCase()}${e.slice(1)}.ts`;
576
576
  }
577
- function ht(e) {
577
+ function mt(e) {
578
578
  return `${e.path}/${e.name}`.toLowerCase();
579
579
  }
580
580
  // src/analysis/models.ts
581
- function gt(e) {
581
+ function ht(e) {
582
582
  let t = e.components?.schemas;
583
583
  if (!t) return [];
584
584
  let n = Object.keys(t);
585
- return _t(n), n.map((e) => {
586
- let n = t[e], r = F(e);
585
+ return gt(n), n.map((e) => {
586
+ let n = t[e], r = I(e);
587
587
  return {
588
588
  key: e,
589
589
  info: r,
590
- file: se(r),
590
+ file: oe(r),
591
591
  schema: n
592
592
  };
593
593
  });
594
594
  }
595
- function _t(e) {
595
+ function gt(e) {
596
596
  let t = /* @__PURE__ */ new Map();
597
597
  for (let n of e) {
598
- let e = F(n), r = `${e.path === "/" ? "" : e.path}/${e.name}`;
598
+ let e = I(n), r = `${e.path === "/" ? "" : e.path}/${e.name}`;
599
599
  t.set(r, [...t.get(r) ?? [], n]);
600
600
  }
601
601
  let n = [...t].filter(([, e]) => e.length > 1);
602
- if (n.length !== 0) throw new v("specification", `Schemas generate the same model: ${n.map(([e, t]) => `${t.join(", ")} → ${e}`).join("; ")}. Rename all but one of them in the document.`);
602
+ if (n.length !== 0) throw new y("specification", `Schemas generate the same model: ${n.map(([e, t]) => `${t.join(", ")} → ${e}`).join("; ")}. Rename all but one of them in the document.`);
603
603
  }
604
604
  // src/analysis/analyze.ts
605
- function vt(e, t) {
605
+ function _t(e, t) {
606
606
  let n = [];
607
607
  return {
608
608
  model: {
609
- models: gt(e),
610
- apiClients: ft(e, t, n)
609
+ models: ht(e),
610
+ apiClients: dt(e, t, n)
611
611
  },
612
612
  warnings: n
613
613
  };
614
614
  }
615
615
  // src/emit/importRegistry.ts
616
- var yt = class {
616
+ var vt = class {
617
617
  declarations = /* @__PURE__ */ new Map();
618
618
  add(e, t) {
619
619
  let n = this.declarations.get(e);
@@ -649,9 +649,9 @@ var yt = class {
649
649
  })
650
650
  }));
651
651
  }
652
- }, bt = class {
652
+ }, yt = class {
653
653
  sourceFile;
654
- imports = new yt();
654
+ imports = new vt();
655
655
  statements = [];
656
656
  constructor(e) {
657
657
  this.sourceFile = e;
@@ -668,10 +668,10 @@ var yt = class {
668
668
  ...n,
669
669
  kind: o.ImportDeclaration
670
670
  }, e.push(t);
671
- for (let n of this.statements) t && Ct(t, n) && e.push(St), e.push(n), t = n;
671
+ for (let n of this.statements) t && St(t, n) && e.push(xt), e.push(n), t = n;
672
672
  return e.length > 0 && this.sourceFile.addStatements(e), this.sourceFile;
673
673
  }
674
- }, xt = class {
674
+ }, bt = class {
675
675
  open;
676
676
  modules = /* @__PURE__ */ new Map();
677
677
  constructor(e) {
@@ -679,16 +679,16 @@ var yt = class {
679
679
  }
680
680
  module(e) {
681
681
  let t = this.open(e), n = t.getFilePath(), r = this.modules.get(n);
682
- return r || (r = new bt(t), this.modules.set(n, r)), r;
682
+ return r || (r = new yt(t), this.modules.set(n, r)), r;
683
683
  }
684
684
  build() {
685
685
  for (let e of this.modules.values()) e.build();
686
686
  this.modules.clear();
687
687
  }
688
- }, St = (e) => {
688
+ }, xt = (e) => {
689
689
  e.blankLineIfLastNot();
690
690
  };
691
- function Ct(e, t) {
691
+ function St(e, t) {
692
692
  if (typeof t == "string") return !1;
693
693
  switch (t.kind) {
694
694
  case o.TypeAlias:
@@ -696,7 +696,7 @@ function Ct(e, t) {
696
696
  default: return !0;
697
697
  }
698
698
  }
699
- function wt(e, t) {
699
+ function Ct(e, t) {
700
700
  return {
701
701
  name: "[key: string]",
702
702
  type: e,
@@ -704,43 +704,43 @@ function wt(e, t) {
704
704
  };
705
705
  }
706
706
  // src/emit/imports.ts
707
- var Tt = "@";
708
- function I(e, t, n) {
707
+ var wt = "@";
708
+ function L(e, t, n) {
709
709
  return e.imports.add(t, n);
710
710
  }
711
- function Et(e, t, n) {
712
- return n.path.startsWith(Tt) ? n.path : L(e.directoryPath, d(t, n.path, oe));
711
+ function Tt(e, t, n) {
712
+ return n.path.startsWith(wt) ? n.path : R(e.directoryPath, d(t, n.path, ae));
713
713
  }
714
- function L(e, t) {
714
+ function R(e, t) {
715
715
  let n = f(e, t).split(m).join("/");
716
716
  return n = n.endsWith(".ts") ? n.replace(/\.ts$/, ".js") : `${n}/index.js`, n.startsWith(".") ? n : `./${n}`;
717
717
  }
718
718
  // src/emit/jsdoc.ts
719
- function Dt(e, t = "\n") {
719
+ function Et(e, t = "\n") {
720
720
  if (!Array.isArray(e)) return;
721
- let n = e.filter((e) => typeof e == "string" && e.length > 0).map(Ot);
721
+ let n = e.filter((e) => typeof e == "string" && e.length > 0).map(Dt);
722
722
  return n.length > 0 ? n.join(t) : void 0;
723
723
  }
724
- function Ot(e) {
724
+ function Dt(e) {
725
725
  return e.replace(/\*\//g, "*\\/");
726
726
  }
727
- function R(e, t) {
728
- let n = Dt(t);
727
+ function z(e, t) {
728
+ let n = Et(t);
729
729
  n && (e.docs = [...e.docs ?? [], n]);
730
730
  }
731
- function kt(e, t, n = !1) {
732
- e = Mt(e);
731
+ function Ot(e, t, n = !1) {
732
+ e = jt(e);
733
733
  let r = [e.title, e.description];
734
- return t && r.push(`- key: ${t}`), n && Nt(r, e), e.format && r.push(e.format === "int64" ? "- format: int64 (a value beyond Number.MAX_SAFE_INTEGER loses precision)" : `- format: ${e.format}`), Pt(r, e, "default"), Pt(r, e, "example"), It(r, e), Lt(r, e), Rt(r, e), r;
734
+ return t && r.push(`- key: ${t}`), n && Mt(r, e), e.format && r.push(e.format === "int64" ? "- format: int64 (a value beyond Number.MAX_SAFE_INTEGER loses precision)" : `- format: ${e.format}`), Nt(r, e, "default"), Nt(r, e, "example"), Ft(r, e), It(r, e), Lt(r, e), r;
735
735
  }
736
- function At(e, t, n) {
737
- R(e, kt(t, n));
736
+ function kt(e, t, n) {
737
+ z(e, Ot(t, n));
738
738
  }
739
- function jt(e, t, n, r = !1) {
740
- let i = kt(t, n, !0);
741
- r && Ft(i, "schema", t), R(e, i);
739
+ function At(e, t, n, r = !1) {
740
+ let i = Ot(t, n, !0);
741
+ r && Pt(i, "schema", t), z(e, i);
742
742
  }
743
- function Mt(e) {
743
+ function jt(e) {
744
744
  for (let t of ["anyOf", "oneOf"]) {
745
745
  let n = e[t];
746
746
  if (!Array.isArray(n) || n.length < 2) continue;
@@ -752,31 +752,31 @@ function Mt(e) {
752
752
  }
753
753
  return e;
754
754
  }
755
- function Nt(e, t) {
755
+ function Mt(e, t) {
756
756
  let n = t.required ?? [];
757
757
  (n.length || Object.keys(t.properties ?? {}).length) && e.push(`- required: ${n.length ? n.join(", ") : "(none)"}`);
758
758
  }
759
- function Pt(e, t, n) {
759
+ function Nt(e, t, n) {
760
760
  let r = t[n];
761
- r && (typeof r == "object" ? Ft(e, n, r) : e.push(`- ${n}: \`${r}\``));
761
+ r && (typeof r == "object" ? Pt(e, n, r) : e.push(`- ${n}: \`${r}\``));
762
762
  }
763
- function Ft(e, t, n) {
763
+ function Pt(e, t, n) {
764
764
  e.push(`- ${t}: `), e.push("```json"), e.push(JSON.stringify(n, null, 2)), e.push("```");
765
765
  }
766
- function It(e, t) {
766
+ function Ft(e, t) {
767
767
  let n = ["- Numeric Constraints"];
768
768
  t.minimum !== void 0 && n.push(` - minimum: ${t.minimum}`), t.maximum !== void 0 && n.push(` - maximum: ${t.maximum}`), t.exclusiveMinimum !== void 0 && n.push(` - exclusiveMinimum: ${t.exclusiveMinimum}`), t.exclusiveMaximum !== void 0 && n.push(` - exclusiveMaximum: ${t.exclusiveMaximum}`), t.multipleOf !== void 0 && n.push(` - multipleOf: ${t.multipleOf}`), n.length !== 1 && e.push(...n);
769
769
  }
770
- function Lt(e, t) {
770
+ function It(e, t) {
771
771
  let n = ["- String Constraints"];
772
772
  t.minLength !== void 0 && n.push(` - minLength: ${t.minLength}`), t.maxLength !== void 0 && n.push(` - maxLength: ${t.maxLength}`), t.pattern !== void 0 && n.push(` - pattern: ${t.pattern}`), n.length !== 1 && e.push(...n);
773
773
  }
774
- function Rt(e, t) {
774
+ function Lt(e, t) {
775
775
  let n = ["- Array Constraints"];
776
776
  t.minItems !== void 0 && n.push(` - minItems: ${t.minItems}`), t.maxItems !== void 0 && n.push(` - maxItems: ${t.maxItems}`), t.uniqueItems !== void 0 && n.push(` - uniqueItems: ${t.uniqueItems}`), n.length !== 1 && e.push(...n);
777
777
  }
778
778
  // src/types/typeResolver.ts
779
- function zt(e, t) {
779
+ function Rt(e, t) {
780
780
  let n;
781
781
  return {
782
782
  components: e,
@@ -793,7 +793,7 @@ function zt(e, t) {
793
793
  }
794
794
  };
795
795
  }
796
- var Bt = [
796
+ var zt = [
797
797
  "Array",
798
798
  "Blob",
799
799
  "Exclude",
@@ -805,11 +805,11 @@ var Bt = [
805
805
  "Response",
806
806
  "Symbol",
807
807
  "URLSearchParams"
808
- ], Vt = /* @__PURE__ */ new Set([
808
+ ], Bt = /* @__PURE__ */ new Set([
809
809
  "string",
810
810
  "number",
811
811
  "boolean"
812
- ]), Ht = /* @__PURE__ */ new Set([
812
+ ]), Vt = /* @__PURE__ */ new Set([
813
813
  "$comment",
814
814
  "$schema",
815
815
  "default",
@@ -823,54 +823,54 @@ var Bt = [
823
823
  "writeOnly",
824
824
  "xml"
825
825
  ]);
826
- function Ut(e, t) {
826
+ function Ht(e, t) {
827
827
  return e === void 0 ? !1 : typeof e == "string" || typeof t == "string" ? e === t : e.primitive === t.primitive;
828
828
  }
829
- function z(e, t, n = /* @__PURE__ */ new Set()) {
830
- if (b(e)) {
829
+ function B(e, t, n = /* @__PURE__ */ new Set()) {
830
+ if (x(e)) {
831
831
  if (!t || n.has(e.$ref)) return;
832
832
  n.add(e.$ref);
833
- let r = C(e, t);
834
- return r ? z(r, t, n) : void 0;
833
+ let r = w(e, t);
834
+ return r ? B(r, t, n) : void 0;
835
835
  }
836
836
  if (!(e.nullable || Array.isArray(e.type))) {
837
- if (Fe(e) && e.type === void 0) {
838
- let r = e.allOf.map((e) => z(e, t, n)), [i] = r;
839
- return i !== void 0 && r.every((e) => Ut(e, i)) ? i : void 0;
837
+ if (Pe(e) && e.type === void 0) {
838
+ let r = e.allOf.map((e) => B(e, t, n)), [i] = r;
839
+ return i !== void 0 && r.every((e) => Ht(e, i)) ? i : void 0;
840
840
  }
841
- if (!(D(e) || e.const !== void 0 || e.type === void 0)) return e.type === "object" ? "object" : e.type === "array" ? "array" : { primitive: Ve(e.type) };
841
+ if (!(O(e) || e.const !== void 0 || e.type === void 0)) return e.type === "object" ? "object" : e.type === "array" ? "array" : { primitive: Be(e.type) };
842
842
  }
843
843
  }
844
- function Wt(e, t, n) {
845
- let r = z(t, n);
844
+ function Ut(e, t, n) {
845
+ let r = B(t, n);
846
846
  if (typeof r != "object") return !1;
847
- let i = z(e, n);
847
+ let i = B(e, n);
848
848
  return i === void 0 || typeof i == "string" || i.primitive !== r.primitive;
849
849
  }
850
- function Gt(e, t) {
850
+ function Wt(e, t) {
851
851
  let n = e.additionalProperties;
852
- return typeof n == "object" && Object.values(e.properties ?? {}).some((e) => Wt(e, n, t));
852
+ return typeof n == "object" && Object.values(e.properties ?? {}).some((e) => Ut(e, n, t));
853
853
  }
854
- function Kt(e) {
855
- return e.nullable !== !0 || E(e) || !D(e) ? !1 : [
854
+ function Gt(e) {
855
+ return e.nullable !== !0 || D(e) || !O(e) ? !1 : [
856
856
  e.allOf,
857
857
  e.oneOf,
858
858
  e.anyOf
859
- ].every((e) => e === void 0 || e.every(b));
859
+ ].every((e) => e === void 0 || e.every(x));
860
860
  }
861
- function qt(e, t) {
861
+ function Kt(e, t) {
862
862
  return t.type === void 0 || e === null && t.nullable ? !0 : [t.type].flat().some((t) => t === "null" ? e === null : t === "array" ? Array.isArray(e) : t === "object" ? typeof e == "object" && !!e && !Array.isArray(e) : t === "integer" ? typeof e == "number" && Number.isInteger(e) : typeof e === t);
863
863
  }
864
- function B(t) {
864
+ function V(t) {
865
865
  if (typeof t == "string") return new e({ useSingleQuote: !0 }).quote(t).toString();
866
- if (Array.isArray(t)) return `[${t.map((e) => B(e)).join(", ")}]`;
866
+ if (Array.isArray(t)) return `[${t.map((e) => V(e)).join(", ")}]`;
867
867
  if (typeof t == "object" && t) {
868
- let e = Object.entries(t).map(([e, t]) => `${N(e)}: ${B(t)}`);
868
+ let e = Object.entries(t).map(([e, t]) => `${P(e)}: ${V(t)}`);
869
869
  return e.length ? `{ ${e.join("; ")}; readonly [globalThis.Symbol.iterator]?: never }` : "globalThis.Record<string, never>";
870
870
  }
871
871
  return JSON.stringify(t) ?? "never";
872
872
  }
873
- var Jt = class {
873
+ var qt = class {
874
874
  scope;
875
875
  entries;
876
876
  requested = [];
@@ -902,7 +902,7 @@ var Jt = class {
902
902
  name: t.name
903
903
  }, this.entries.push(i)), this.request(i), i.alias) return i.alias;
904
904
  let a = /* @__PURE__ */ new Set([
905
- ...Bt,
905
+ ...zt,
906
906
  n.name,
907
907
  ...n.path === void 0 ? [] : this.scope.context.namesAt(n.path),
908
908
  ...this.entries.filter((e) => e !== i).map((e) => e.alias ?? e.name)
@@ -924,9 +924,9 @@ var Jt = class {
924
924
  propertyDefinitions(e) {
925
925
  let { properties: t } = e;
926
926
  return Object.entries(t).map(([e, t]) => {
927
- let n = this.type(t), r = (Be(t) ? "readonly " : "") + N(e);
928
- if (!b(t)) {
929
- let e = Dt(kt(t), "\n * ");
927
+ let n = this.type(t), r = (ze(t) ? "readonly " : "") + P(e);
928
+ if (!x(t)) {
929
+ let e = Et(Ot(t), "\n * ");
930
930
  if (e) return `
931
931
  /**
932
932
  * ${e}
@@ -939,9 +939,9 @@ var Jt = class {
939
939
  }
940
940
  objectType(e) {
941
941
  let t = [];
942
- je(e) && t.push(...this.propertyDefinitions(e));
943
- for (let n of e.required ?? []) Object.hasOwn(e.properties ?? {}, n) || t.push(`${N(n)}: ${this.requiredAdditionalPropertyType(e)}`);
944
- let n = Le(e) && ze(e) ? this.mapType(e) : Gt(e, this.components) ? `globalThis.Record<string, ${this.additionalPropertyType(e)}>` : void 0, r = n ? "" : this.additionalProperties(e);
942
+ Ae(e) && t.push(...this.propertyDefinitions(e));
943
+ for (let n of e.required ?? []) Object.hasOwn(e.properties ?? {}, n) || t.push(`${P(n)}: ${this.requiredAdditionalPropertyType(e)}`);
944
+ let n = Ie(e) && Re(e) ? this.mapType(e) : Wt(e, this.components) ? `globalThis.Record<string, ${this.additionalPropertyType(e)}>` : void 0, r = n ? "" : this.additionalProperties(e);
945
945
  if (r && t.push(r), t.length === 0) return "globalThis.Record<string, any>";
946
946
  let i = `{\n ${t.join(";\n ")}; \n}`;
947
947
  return n ? `(${i} & ${n})` : i;
@@ -950,14 +950,14 @@ var Jt = class {
950
950
  return e.additionalProperties === void 0 || e.additionalProperties === !1 || e.additionalProperties === !0 ? "any" : this.type(e.additionalProperties);
951
951
  }
952
952
  mapKeyType(e) {
953
- let t = ze(e);
953
+ let t = Re(e);
954
954
  return t ? this.type(t) : "string";
955
955
  }
956
956
  mapType(e) {
957
957
  return `globalThis.Record<${this.mapKeyType(e)},${this.mapValueType(e)}>`;
958
958
  }
959
959
  objectConstrained(e) {
960
- let t = (e) => b(e) ? this.components && C(e, this.components) : e, n = t(e), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = n ? [n] : [];
960
+ let t = (e) => x(e) ? this.components && w(e, this.components) : e, n = t(e), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = n ? [n] : [];
961
961
  for (let e of a) {
962
962
  if (r.has(e)) continue;
963
963
  let n = [
@@ -981,7 +981,7 @@ var Jt = class {
981
981
  return n !== void 0 && i.has(n);
982
982
  }
983
983
  type(e) {
984
- if (b(e)) return this.reference(e);
984
+ if (x(e)) return this.reference(e);
985
985
  if (Array.isArray(e.type)) return e.type.map((t) => {
986
986
  let n = this.type({
987
987
  ...e,
@@ -989,11 +989,11 @@ var Jt = class {
989
989
  });
990
990
  return /[|&]/.test(n) ? `(${n})` : n;
991
991
  }).join(" | ");
992
- if (Kt(e)) return `(${this.type({
992
+ if (Gt(e)) return `(${this.type({
993
993
  ...e,
994
994
  nullable: !1
995
995
  })}) | null`;
996
- if (D(e)) {
996
+ if (O(e)) {
997
997
  let t = this.simpleComposition(e);
998
998
  if (t !== void 0) return t;
999
999
  let n = [
@@ -1015,25 +1015,25 @@ var Jt = class {
1015
1015
  return this.objectConstrained(e) ? `globalThis.Exclude<${o}, string | number | boolean | readonly unknown[]> & ({ readonly [globalThis.Symbol.iterator]?: never } | null)` : o;
1016
1016
  }
1017
1017
  if (e.const !== void 0) {
1018
- if (!qt(e.const, e)) return "never";
1019
- let t = B(e.const), n = this.type({
1018
+ if (!Kt(e.const, e)) return "never";
1019
+ let t = V(e.const), n = this.type({
1020
1020
  ...e,
1021
1021
  const: void 0
1022
1022
  });
1023
1023
  return n === "any" ? t : `(${t}) & (${n})`;
1024
1024
  }
1025
- if (e.nullable && e.type && !E(e)) return `(${this.type({
1025
+ if (e.nullable && e.type && !D(e)) return `(${this.type({
1026
1026
  ...e,
1027
1027
  nullable: !1
1028
1028
  })}) | null`;
1029
- if (E(e)) {
1030
- let t = e.enum.filter((t) => qt(t, e)).map((e) => B(e)).join(" | ") || "never", n = this.type({
1029
+ if (D(e)) {
1030
+ let t = e.enum.filter((t) => Kt(t, e)).map((e) => V(e)).join(" | ") || "never", n = this.type({
1031
1031
  ...e,
1032
1032
  enum: void 0
1033
1033
  });
1034
- return n === "any" || Vt.has(n) ? t : `(${t}) & (${n})`;
1034
+ return n === "any" || Bt.has(n) ? t : `(${t}) & (${n})`;
1035
1035
  }
1036
- return Le(e) && !e.required?.length ? this.mapType(e) : e.type === "array" ? Ie(this.type(e.items ?? {})) : e.type === "object" ? this.objectType(e) : e.type ? Ve(e.type) : e.required?.length || Object.keys(e.properties ?? {}).length > 0 ? `(${this.objectType({
1036
+ return Ie(e) && !e.required?.length ? this.mapType(e) : e.type === "array" ? Fe(this.type(e.items ?? {})) : e.type === "object" ? this.objectType(e) : e.type ? Be(e.type) : e.required?.length || Object.keys(e.properties ?? {}).length > 0 ? `(${this.objectType({
1037
1037
  ...e,
1038
1038
  type: "object",
1039
1039
  additionalProperties: e.additionalProperties ?? !0
@@ -1047,43 +1047,43 @@ var Jt = class {
1047
1047
  ].filter((t) => e[t]?.length);
1048
1048
  if (t.length !== 1) return;
1049
1049
  let [n] = t;
1050
- if (Object.keys(e).filter((e) => e !== n && e !== "discriminator" && !e.startsWith("x-") && !Ht.has(e)).length > 0) return;
1051
- let r = e[n], i = (e) => n !== "allOf" && [e.type].flat().every((e) => e === "null") && e.type !== void 0 && Object.keys(e).every((e) => e === "type" || Ht.has(e));
1052
- if (!r.every((e) => b(e) || i(e))) return;
1053
- let a = r.map((t) => b(t) ? this.memberType(e, n, t) : "null");
1050
+ if (Object.keys(e).filter((e) => e !== n && e !== "discriminator" && !e.startsWith("x-") && !Vt.has(e)).length > 0) return;
1051
+ let r = e[n], i = (e) => n !== "allOf" && [e.type].flat().every((e) => e === "null") && e.type !== void 0 && Object.keys(e).every((e) => e === "type" || Vt.has(e));
1052
+ if (!r.every((e) => x(e) || i(e))) return;
1053
+ let a = r.map((t) => x(t) ? this.memberType(e, n, t) : "null");
1054
1054
  return [...new Set(a)].join(n === "allOf" ? " & " : " | ");
1055
1055
  }
1056
1056
  memberType(e, t, n) {
1057
1057
  let r = this.type(n), i = e.discriminator;
1058
- if (t === "allOf" || !i?.propertyName || !b(n)) return r;
1059
- let a = me(n), o = Object.entries(i.mapping ?? {}).filter(([, e]) => e === n.$ref || e === a).map(([e]) => e), s = (o.length > 0 ? o : [a]).map((e) => P(e)).join(" | ");
1060
- return `(${r} & { ${N(i.propertyName)}: ${s} })`;
1058
+ if (t === "allOf" || !i?.propertyName || !x(n)) return r;
1059
+ let a = pe(n), o = Object.entries(i.mapping ?? {}).filter(([, e]) => e === n.$ref || e === a).map(([e]) => e), s = (o.length > 0 ? o : [a]).map((e) => F(e)).join(" | ");
1060
+ return `(${r} & { ${P(i.propertyName)}: ${s} })`;
1061
1061
  }
1062
1062
  };
1063
- function V(e, t) {
1064
- let n = new Jt(e);
1063
+ function H(e, t) {
1064
+ let n = new qt(e);
1065
1065
  return {
1066
1066
  text: t(n),
1067
1067
  imports: n.imports()
1068
1068
  };
1069
1069
  }
1070
+ function Jt(e, t) {
1071
+ return H(t, (t) => t.type(e));
1072
+ }
1070
1073
  function Yt(e, t) {
1071
- return V(t, (t) => t.type(e));
1074
+ return H(t, (t) => t.additionalProperties(e));
1072
1075
  }
1073
1076
  function Xt(e, t) {
1074
- return V(t, (t) => t.additionalProperties(e));
1077
+ return H(t, (t) => t.additionalPropertyType(e));
1075
1078
  }
1076
1079
  function Zt(e, t) {
1077
- return V(t, (t) => t.additionalPropertyType(e));
1080
+ return H(t, (t) => t.requiredAdditionalPropertyType(e));
1078
1081
  }
1079
1082
  function Qt(e, t) {
1080
- return V(t, (t) => t.requiredAdditionalPropertyType(e));
1081
- }
1082
- function $t(e, t) {
1083
- return V(t, (t) => t.mapValueType(e));
1083
+ return H(t, (t) => t.mapValueType(e));
1084
1084
  }
1085
1085
  // src/emitters/decorators.ts
1086
- var en = "@ahoo-wang/fetcher", tn = ["ContentTypeValues", "ResultExtractors"], nn = "@ahoo-wang/fetcher-decorator", rn = [
1086
+ var $t = "@ahoo-wang/fetcher", en = ["ContentTypeValues", "ResultExtractors"], tn = "@ahoo-wang/fetcher-decorator", nn = [
1087
1087
  "ApiMetadata",
1088
1088
  "ApiMetadataCapable",
1089
1089
  "ParameterRequest",
@@ -1100,20 +1100,20 @@ var en = "@ahoo-wang/fetcher", tn = ["ContentTypeValues", "ResultExtractors"], n
1100
1100
  "header",
1101
1101
  "body",
1102
1102
  "autoGeneratedError"
1103
- ], an = {
1103
+ ], rn = {
1104
1104
  type: "Promise<Response>",
1105
1105
  metadata: "{resultExtractor: ResultExtractors.Response }"
1106
- }, on = {
1106
+ }, an = {
1107
1107
  type: "Promise<string>",
1108
1108
  metadata: "{resultExtractor: ResultExtractors.Text }"
1109
- }, sn = "{\n headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },\n resultExtractor: JsonEventStreamResultExtractor,\n}";
1110
- function cn(e) {
1111
- I(e, en, tn);
1109
+ }, on = "{\n headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },\n resultExtractor: JsonEventStreamResultExtractor,\n}";
1110
+ function sn(e) {
1111
+ L(e, $t, en);
1112
1112
  }
1113
- function ln(e) {
1114
- I(e, nn, rn);
1113
+ function cn(e) {
1114
+ L(e, tn, nn);
1115
1115
  }
1116
- function un(e, t, n = [], r = [], i) {
1116
+ function ln(e, t, n = [], r = [], i) {
1117
1117
  return t.add({
1118
1118
  kind: o.Class,
1119
1119
  name: e,
@@ -1126,7 +1126,7 @@ function un(e, t, n = [], r = [], i) {
1126
1126
  }]
1127
1127
  });
1128
1128
  }
1129
- function dn(e) {
1129
+ function un(e) {
1130
1130
  e.implements = [...[e.implements ?? []].flat(), "ApiMetadataCapable"], e.ctors ??= [], e.ctors.push({ parameters: [{
1131
1131
  name: "apiMetadata",
1132
1132
  type: "ApiMetadata",
@@ -1135,38 +1135,38 @@ function dn(e) {
1135
1135
  isReadonly: !0
1136
1136
  }] });
1137
1137
  }
1138
- function fn(e) {
1138
+ function dn(e) {
1139
1139
  return e === "delete" ? "del" : e;
1140
1140
  }
1141
- var pn = "@ahoo-wang/fetcher-eventstream";
1142
- function mn(e) {
1143
- I(e, pn, ["JsonEventStreamResultExtractor", "JsonServerSentEventStream"]);
1141
+ var fn = "@ahoo-wang/fetcher-eventstream";
1142
+ function pn(e) {
1143
+ L(e, fn, ["JsonEventStreamResultExtractor", "JsonServerSentEventStream"]);
1144
1144
  }
1145
1145
  // src/emitters/apiClients.ts
1146
- function hn(e, t) {
1146
+ function mn(e, t) {
1147
1147
  let n = t.modules.module(e.file);
1148
- cn(n), ln(n), mn(n);
1149
- let r = un(e.className, n);
1150
- R(r, [e.description]), dn(r);
1151
- let i = gn(e.className, n, t);
1152
- for (let t of e.methods) (r.methods ??= []).push(_n(t, i));
1148
+ sn(n), cn(n), pn(n);
1149
+ let r = ln(e.className, n);
1150
+ z(r, [e.description]), un(r);
1151
+ let i = hn(e.className, n, t);
1152
+ for (let t of e.methods) (r.methods ??= []).push(gn(t, i));
1153
1153
  }
1154
- function gn(e, t, n) {
1154
+ function hn(e, t, n) {
1155
1155
  let r = {
1156
1156
  context: n.types,
1157
1157
  owner: { name: e },
1158
- specifierOf: (e) => Et(t, n.outputDir, e),
1158
+ specifierOf: (e) => Tt(t, n.outputDir, e),
1159
1159
  imports: t.imports
1160
1160
  };
1161
1161
  return {
1162
1162
  module: t,
1163
1163
  resolveType(e) {
1164
- let n = Yt(e, r);
1164
+ let n = Jt(e, r);
1165
1165
  return t.imports.apply(n.imports), n.text;
1166
1166
  }
1167
1167
  };
1168
1168
  }
1169
- function _n(e, t) {
1169
+ function gn(e, t) {
1170
1170
  let n = [], r = [];
1171
1171
  for (let i of e.parameters) (i.required ? n : r).push({
1172
1172
  name: i.name,
@@ -1174,12 +1174,12 @@ function _n(e, t) {
1174
1174
  hasQuestionToken: !i.required,
1175
1175
  decorators: [{
1176
1176
  name: i.location,
1177
- arguments: [P(i.parameterName)]
1177
+ arguments: [F(i.parameterName)]
1178
1178
  }]
1179
1179
  });
1180
1180
  e.body && (e.body.required ? n : r).push({
1181
1181
  name: e.body.name,
1182
- type: vn(e.body, t),
1182
+ type: _n(e.body, t),
1183
1183
  hasQuestionToken: !e.body.required,
1184
1184
  decorators: [{
1185
1185
  name: "body",
@@ -1207,24 +1207,24 @@ function _n(e, t) {
1207
1207
  arguments: []
1208
1208
  }]
1209
1209
  }
1210
- ], a = yn(e.returns, t), o = P(e.path), s = {
1210
+ ], a = vn(e.returns, t), o = F(e.path), s = {
1211
1211
  name: e.name,
1212
1212
  decorators: [{
1213
- name: fn(e.httpMethod),
1213
+ name: dn(e.httpMethod),
1214
1214
  arguments: a.metadata ? [o, a.metadata] : [o]
1215
1215
  }],
1216
1216
  parameters: i,
1217
1217
  returnType: a.type,
1218
1218
  statements: [`throw autoGeneratedError(${i.map((e) => e.name).join(",")});`]
1219
1219
  };
1220
- return R(s, [...e.docs]), s;
1220
+ return z(s, [...e.docs]), s;
1221
1221
  }
1222
- function vn(e, t) {
1222
+ function _n(e, t) {
1223
1223
  let { content: n } = e;
1224
1224
  switch (n.kind) {
1225
1225
  case "json": {
1226
1226
  let e = t.resolveType(n.schema), r = n.optionalFields;
1227
- return r.length === 0 || /[|&]/.test(e) || e === "any" ? e : (I(t.module, en, ["PartialBy"]), `PartialBy<${e}, ${r.map(P).join(" | ")}>`);
1227
+ return r.length === 0 || /[|&]/.test(e) || e === "any" ? e : (L(t.module, $t, ["PartialBy"]), `PartialBy<${e}, ${r.map(F).join(" | ")}>`);
1228
1228
  }
1229
1229
  case "formData": return "FormData";
1230
1230
  case "urlEncoded": return "URLSearchParams";
@@ -1232,49 +1232,49 @@ function vn(e, t) {
1232
1232
  case "binary": return "BodyInit";
1233
1233
  }
1234
1234
  }
1235
- function yn(e, t) {
1235
+ function vn(e, t) {
1236
1236
  switch (e.kind) {
1237
1237
  case "json": {
1238
1238
  let n = t.resolveType(e.schema);
1239
- return e.wildcard && n === "string" ? on : { type: `Promise<${n}>` };
1239
+ return e.wildcard && n === "string" ? an : { type: `Promise<${n}>` };
1240
1240
  }
1241
1241
  case "eventStream": {
1242
1242
  if (!e.items) return {
1243
1243
  type: "Promise<JsonServerSentEventStream<any>>",
1244
- metadata: sn
1244
+ metadata: on
1245
1245
  };
1246
1246
  let n = t.resolveType(e.items);
1247
1247
  return {
1248
1248
  type: `Promise<JsonServerSentEventStream<${e.serverSentEvent ? `${n}['data']` : n}>>`,
1249
- metadata: sn
1249
+ metadata: on
1250
1250
  };
1251
1251
  }
1252
- case "text": return on;
1253
- case "response": return an;
1252
+ case "text": return an;
1253
+ case "response": return rn;
1254
1254
  }
1255
1255
  }
1256
1256
  // src/emitters/models.ts
1257
- function bn(e) {
1258
- return zt(e, {
1259
- ofKey: (e) => F(e),
1260
- ofReference: ut
1257
+ function yn(e) {
1258
+ return Rt(e, {
1259
+ ofKey: (e) => I(e),
1260
+ ofReference: lt
1261
1261
  });
1262
1262
  }
1263
- function xn(e, t) {
1264
- new Cn(e, t.modules.module(e.file), t).write();
1263
+ function bn(e, t) {
1264
+ new Sn(e, t.modules.module(e.file), t).write();
1265
1265
  }
1266
- function Sn(e) {
1266
+ function xn(e) {
1267
1267
  let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map();
1268
1268
  for (let r of e) {
1269
- let e = at(r), i = [e];
1269
+ let e = it(r), i = [e];
1270
1270
  /^\d/.test(r) || i.push(r);
1271
1271
  let a = i.find((e) => !t.has(e));
1272
1272
  for (let n = 2; a === void 0; n++) t.has(`${e}_${n}`) || (a = `${e}_${n}`);
1273
- t.add(a), n.set(r, N(a));
1273
+ t.add(a), n.set(r, P(a));
1274
1274
  }
1275
1275
  return n;
1276
1276
  }
1277
- var Cn = class {
1277
+ var Sn = class {
1278
1278
  model;
1279
1279
  module;
1280
1280
  target;
@@ -1284,41 +1284,41 @@ var Cn = class {
1284
1284
  this.model = e, this.module = t, this.target = n, this.modelInfo = e.info, this.components = n.types.components, this.scope = {
1285
1285
  context: n.types,
1286
1286
  owner: e.info,
1287
- specifierOf: (e) => Et(t, n.outputDir, e),
1287
+ specifierOf: (e) => Tt(t, n.outputDir, e),
1288
1288
  imports: t.imports
1289
1289
  };
1290
1290
  }
1291
1291
  write() {
1292
1292
  let e = this.process();
1293
- e && jt(e, this.model.schema, this.model.key, this.target.schemaDocs === "full");
1293
+ e && At(e, this.model.schema, this.model.key, this.target.schemaDocs === "full");
1294
1294
  }
1295
1295
  process() {
1296
1296
  let { schema: e } = this.model;
1297
- return b(e) ? this.processTypeAlias(e) : E(e) ? this.processEnum(e) : e.const !== void 0 || e.nullable && e.type || D(e) && (e.type || e.properties || e.required) ? this.processTypeAlias(e) : je(e) ? this.processInterface(e) : Le(e) && typeof e.additionalProperties == "object" && !ze(e) && !e.required?.length ? this.processIndexSignature(e) : Me(e) ? this.processArray(e) : D(e) ? this.processComposition(e) : this.processTypeAlias(e);
1297
+ return x(e) ? this.processTypeAlias(e) : D(e) ? this.processEnum(e) : e.const !== void 0 || e.nullable && e.type || O(e) && (e.type || e.properties || e.required) ? this.processTypeAlias(e) : Ae(e) ? this.processInterface(e) : Ie(e) && typeof e.additionalProperties == "object" && !Re(e) && !e.required?.length ? this.processIndexSignature(e) : je(e) ? this.processArray(e) : O(e) ? this.processComposition(e) : this.processTypeAlias(e);
1298
1298
  }
1299
1299
  scope;
1300
1300
  emit(e) {
1301
1301
  return this.module.imports.apply(e.imports), e.text;
1302
1302
  }
1303
1303
  resolveType(e) {
1304
- return this.emit(Yt(e, this.scope));
1304
+ return this.emit(Jt(e, this.scope));
1305
1305
  }
1306
1306
  processEnum(e) {
1307
- let t = Ae(e);
1307
+ let t = ke(e);
1308
1308
  if (t) {
1309
- let e = Sn(Object.keys(t));
1309
+ let e = xn(Object.keys(t));
1310
1310
  this.module.add({
1311
1311
  kind: o.Enum,
1312
1312
  name: this.modelInfo.name + "EnumText",
1313
1313
  isExported: !0,
1314
1314
  members: [...e].map(([e, n]) => ({
1315
1315
  name: n,
1316
- initializer: B(t[e])
1316
+ initializer: V(t[e])
1317
1317
  }))
1318
1318
  });
1319
1319
  }
1320
- let n = [...new Set(e.enum.filter((e) => typeof e == "string"))], r = Sn(n);
1321
- return D(e) || e.const !== void 0 || e.type !== void 0 && e.type !== "string" || e.enum.some((e) => typeof e != "string") ? (n.length && this.module.add({
1320
+ let n = [...new Set(e.enum.filter((e) => typeof e == "string"))], r = xn(n);
1321
+ return O(e) || e.const !== void 0 || e.type !== void 0 && e.type !== "string" || e.enum.some((e) => typeof e != "string") ? (n.length && this.module.add({
1322
1322
  kind: o.VariableStatement,
1323
1323
  declarationKind: c.Const,
1324
1324
  isExported: !0,
@@ -1336,20 +1336,20 @@ var Cn = class {
1336
1336
  isExported: !0,
1337
1337
  members: n.map((e) => ({
1338
1338
  name: r.get(e),
1339
- initializer: B(e)
1339
+ initializer: V(e)
1340
1340
  }))
1341
1341
  });
1342
1342
  }
1343
1343
  addPropertyToInterface(e, t, n) {
1344
1344
  let r = {
1345
- name: N(t),
1345
+ name: P(t),
1346
1346
  type: this.resolveType(n),
1347
- isReadonly: Be(n)
1347
+ isReadonly: ze(n)
1348
1348
  };
1349
- (e.properties ??= []).push(r), At(r, n);
1349
+ (e.properties ??= []).push(r), kt(r, n);
1350
1350
  }
1351
1351
  processInterface(e) {
1352
- if (Gt(e, this.components)) return this.processTypeAlias(e);
1352
+ if (Wt(e, this.components)) return this.processTypeAlias(e);
1353
1353
  let t = [], n = this.module.add({
1354
1354
  kind: o.Interface,
1355
1355
  name: this.modelInfo.name,
@@ -1360,17 +1360,17 @@ var Cn = class {
1360
1360
  this.addPropertyToInterface(n, e, t);
1361
1361
  });
1362
1362
  for (let n of e.required ?? []) Object.hasOwn(r, n) || t.push({
1363
- name: N(n),
1364
- type: this.emit(Qt(e, this.scope))
1363
+ name: P(n),
1364
+ type: this.emit(Zt(e, this.scope))
1365
1365
  });
1366
- return this.emit(Xt(e, this.scope)) && t.push(wt(this.emit(Zt(e, this.scope)), ["Additional properties"])), n;
1366
+ return this.emit(Yt(e, this.scope)) && t.push(Ct(this.emit(Xt(e, this.scope)), ["Additional properties"])), n;
1367
1367
  }
1368
1368
  processArray(e) {
1369
1369
  let t = this.resolveType(e.items);
1370
1370
  return this.module.add({
1371
1371
  kind: o.TypeAlias,
1372
1372
  name: this.modelInfo.name,
1373
- type: Ie(t),
1373
+ type: Fe(t),
1374
1374
  isExported: !0
1375
1375
  });
1376
1376
  }
@@ -1379,7 +1379,7 @@ var Cn = class {
1379
1379
  kind: o.Interface,
1380
1380
  name: this.modelInfo.name,
1381
1381
  isExported: !0,
1382
- properties: [wt(this.emit($t(e, this.scope)))]
1382
+ properties: [Ct(this.emit(Qt(e, this.scope)))]
1383
1383
  });
1384
1384
  }
1385
1385
  processComposition(e) {
@@ -1400,34 +1400,34 @@ var Cn = class {
1400
1400
  }
1401
1401
  };
1402
1402
  // src/emitters/emit.ts
1403
- function wn(e, t) {
1404
- e.models.forEach((e) => xn(e, t)), e.apiClients.forEach((e) => hn(e, t));
1403
+ function Cn(e, t) {
1404
+ e.models.forEach((e) => bn(e, t)), e.apiClients.forEach((e) => mn(e, t));
1405
1405
  }
1406
1406
  // src/emitters/indexFiles.ts
1407
- function Tn(e, t) {
1407
+ function wn(e, t) {
1408
1408
  let n = [];
1409
- return En(e, t, n), n;
1409
+ return Tn(e, t, n), n;
1410
1410
  }
1411
- function En(e, t, n) {
1411
+ function Tn(e, t, n) {
1412
1412
  let r = [];
1413
1413
  for (let t of e.getSourceFiles()) {
1414
1414
  let e = t.getBaseName();
1415
1415
  e.endsWith(".ts") && e !== "index.ts" && r.push({
1416
1416
  specifier: `./${t.getBaseNameWithoutExtension()}.js`,
1417
- exports: On(t)
1417
+ exports: Dn(t)
1418
1418
  });
1419
1419
  }
1420
1420
  for (let i of e.getDirectories()) {
1421
- let e = En(i, t, n);
1421
+ let e = Tn(i, t, n);
1422
1422
  e && r.push({
1423
1423
  specifier: `./${i.getBaseName()}/index.js`,
1424
1424
  exports: e
1425
1425
  });
1426
1426
  }
1427
1427
  let i = e.getPath();
1428
- return r.length === 0 ? e.getProject().getSourceFile(`${i}/index.ts`) ? /* @__PURE__ */ new Map() : void 0 : Dn(i, r, t, n);
1428
+ return r.length === 0 ? e.getProject().getSourceFile(`${i}/index.ts`) ? /* @__PURE__ */ new Map() : void 0 : En(i, r, t, n);
1429
1429
  }
1430
- function Dn(e, t, n, r) {
1430
+ function En(e, t, n, r) {
1431
1431
  let i = /* @__PURE__ */ new Map();
1432
1432
  for (let e of t) for (let t of e.exports.keys()) i.set(t, [...i.get(t) ?? [], e.specifier]);
1433
1433
  let a = [...i].filter(([, e]) => e.length > 1).map(([e]) => e).sort();
@@ -1436,7 +1436,7 @@ function Dn(e, t, n, r) {
1436
1436
  o.removeText();
1437
1437
  let s = /* @__PURE__ */ new Map();
1438
1438
  for (let e of t) {
1439
- let t = [...e.exports].filter(([e]) => !a.includes(e)).sort(([e], [t]) => w(e, t));
1439
+ let t = [...e.exports].filter(([e]) => !a.includes(e)).sort(([e], [t]) => T(e, t));
1440
1440
  t.forEach(([e, t]) => s.set(e, t)), t.length === e.exports.size ? o.addExportDeclaration({ moduleSpecifier: e.specifier }) : t.length > 0 && o.addExportDeclaration({
1441
1441
  moduleSpecifier: e.specifier,
1442
1442
  namedExports: t.map(([e, t]) => ({
@@ -1447,13 +1447,13 @@ function Dn(e, t, n, r) {
1447
1447
  }
1448
1448
  return o.getStatements().length === 0 && o.addStatements("export {};"), s;
1449
1449
  }
1450
- function On(e) {
1450
+ function Dn(e) {
1451
1451
  let t = /* @__PURE__ */ new Map();
1452
1452
  for (let [r, i] of e.getExportedDeclarations()) t.set(r, i.every((e) => n.isInterfaceDeclaration(e) || n.isTypeAliasDeclaration(e)));
1453
1453
  return t;
1454
1454
  }
1455
1455
  // src/finalize/typeOnlyImports.ts
1456
- function kn(e) {
1456
+ function On(e) {
1457
1457
  let t = e;
1458
1458
  for (let e = t.getParent(); e; t = e, e = e.getParent()) if (n.isQualifiedName(e)) {
1459
1459
  if (e.getLeft() !== t) return !1;
@@ -1468,22 +1468,22 @@ function kn(e) {
1468
1468
  }
1469
1469
  return !1;
1470
1470
  }
1471
- function An(e) {
1471
+ function kn(e) {
1472
1472
  let t = e.getImportDeclarations().filter((e) => !e.getDefaultImport() && !e.getNamespaceImport() && e.getNamedImports().length > 0);
1473
1473
  if (t.length === 0) return [];
1474
1474
  let r = new Set(t.flatMap((e) => e.getNamedImports().map((e) => (e.getAliasNode() ?? e.getNameNode()).getText()))), i = /* @__PURE__ */ new Set();
1475
1475
  return e.forEachDescendant((e, t) => {
1476
1476
  if (n.isImportDeclaration(e)) t.skip();
1477
- else if (n.isIdentifier(e) && r.has(e.getText()) && !kn(e)) {
1477
+ else if (n.isIdentifier(e) && r.has(e.getText()) && !On(e)) {
1478
1478
  let t = e.getSymbol();
1479
1479
  t && i.add(t.compilerSymbol);
1480
1480
  }
1481
- }), t.map((e) => jn(e, (e) => {
1481
+ }), t.map((e) => An(e, (e) => {
1482
1482
  let t = e.getSymbol();
1483
1483
  return !!t && !i.has(t.compilerSymbol);
1484
1484
  }));
1485
1485
  }
1486
- function jn(e, t) {
1486
+ function An(e, t) {
1487
1487
  let n = e.getNamedImports(), r = n.map(t), i = r.every(Boolean);
1488
1488
  return () => {
1489
1489
  n.forEach((e, t) => {
@@ -1492,12 +1492,12 @@ function jn(e, t) {
1492
1492
  }), e.isTypeOnly() !== i && e.setIsTypeOnly(i);
1493
1493
  };
1494
1494
  }
1495
- function Mn(e) {
1496
- let t = e.flatMap(An);
1495
+ function jn(e) {
1496
+ let t = e.flatMap(kn);
1497
1497
  for (let e of t) e();
1498
1498
  }
1499
1499
  // src/finalize/verification.ts
1500
- var Nn = /* @__PURE__ */ new Set([
1500
+ var Mn = /* @__PURE__ */ new Set([
1501
1501
  2300,
1502
1502
  2304,
1503
1503
  2308,
@@ -1507,38 +1507,38 @@ var Nn = /* @__PURE__ */ new Set([
1507
1507
  2503,
1508
1508
  2552
1509
1509
  ]);
1510
- function Pn(e) {
1510
+ function Nn(e) {
1511
1511
  let t = [];
1512
1512
  for (let n of e) for (let e of n.getPreEmitDiagnostics()) {
1513
- if (!Nn.has(e.getCode()) || e.getSourceFile() !== n) continue;
1513
+ if (!Mn.has(e.getCode()) || e.getSourceFile() !== n) continue;
1514
1514
  let r = l.flattenDiagnosticMessageText(e.compilerObject.messageText, " ");
1515
1515
  t.push(`${n.getFilePath()}:${e.getLineNumber() ?? 0} TS${e.getCode()} ${r}`);
1516
1516
  }
1517
1517
  if (t.length > 0) throw Error(`The generated code does not compile; nothing was written. This is a wow-generator bug:\n${t.join("\n")}`);
1518
1518
  }
1519
1519
  // src/finalize/finalize.ts
1520
- var Fn = "// Code generated by wow-generator. DO NOT EDIT.\n\n", In = {
1520
+ var Pn = "// Code generated by wow-generator. DO NOT EDIT.\n\n", Fn = {
1521
1521
  indentSize: 2,
1522
1522
  tabSize: 2,
1523
1523
  convertTabsToSpaces: !0,
1524
1524
  semicolons: "insert",
1525
1525
  insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: !0
1526
1526
  };
1527
- function Ln(e, t) {
1527
+ function In(e, t) {
1528
1528
  e.forEach((n, r) => {
1529
- t.debug(`Optimizing file [${n.getFilePath()}] - ${r + 1}/${e.length}`), n.formatText(In), n.organizeImports(In);
1530
- }), Mn(e), Pn(e);
1531
- for (let t of e) t.insertText(0, Fn);
1529
+ t.debug(`Optimizing file [${n.getFilePath()}] - ${r + 1}/${e.length}`), n.formatText(Fn), n.organizeImports(Fn);
1530
+ }), jn(e), Nn(e);
1531
+ for (let t of e) t.insertText(0, Pn);
1532
1532
  }
1533
1533
  // src/input/resources.ts
1534
- var Rn = 3e4;
1535
- function zn(e) {
1534
+ var Ln = 3e4;
1535
+ function Rn(e) {
1536
1536
  return /^https?:\/\//i.test(e);
1537
1537
  }
1538
- function Bn(e, t = {}) {
1539
- return zn(e) ? Vn(e, t) : Un(e);
1538
+ function zn(e, t = {}) {
1539
+ return Rn(e) ? Bn(e, t) : Hn(e);
1540
1540
  }
1541
- async function Vn(e, t = {}) {
1541
+ async function Bn(e, t = {}) {
1542
1542
  let n = t.timeoutMs ?? 3e4, r;
1543
1543
  try {
1544
1544
  let i = AbortSignal.timeout(n);
@@ -1547,7 +1547,7 @@ async function Vn(e, t = {}) {
1547
1547
  signal: t.signal ? AbortSignal.any([t.signal, i]) : i
1548
1548
  });
1549
1549
  } catch (e) {
1550
- let t = e instanceof Error && e.name === "TimeoutError" ? `no response within ${n} ms` : Hn(e);
1550
+ let t = e instanceof Error && e.name === "TimeoutError" ? `no response within ${n} ms` : Vn(e);
1551
1551
  throw Error(t, { cause: e });
1552
1552
  }
1553
1553
  if (!r.ok) {
@@ -1556,12 +1556,12 @@ async function Vn(e, t = {}) {
1556
1556
  }
1557
1557
  return await r.text();
1558
1558
  }
1559
- function Hn(e) {
1559
+ function Vn(e) {
1560
1560
  if (!(e instanceof Error)) return String(e);
1561
1561
  let t = e.cause;
1562
1562
  return t instanceof Error && t.message ? `${e.message} (${t.message})` : e.message;
1563
1563
  }
1564
- function Un(e) {
1564
+ function Hn(e) {
1565
1565
  return new Promise((t, n) => {
1566
1566
  g(e, "utf-8", (e, r) => {
1567
1567
  e ? n(e) : t(r);
@@ -1569,37 +1569,37 @@ function Un(e) {
1569
1569
  });
1570
1570
  }
1571
1571
  // src/input/parsers.ts
1572
- async function Wn(e, t) {
1572
+ async function Un(e, t) {
1573
1573
  let n;
1574
1574
  try {
1575
- n = await Bn(e, t);
1575
+ n = await zn(e, t);
1576
1576
  } catch (t) {
1577
- throw new v("input", `Cannot read the OpenAPI document ${e}: ${y(t)}`, { cause: t });
1577
+ throw new y("input", `Cannot read the OpenAPI document ${e}: ${b(t)}`, { cause: t });
1578
1578
  }
1579
1579
  try {
1580
- return Kn(n);
1580
+ return Gn(n);
1581
1581
  } catch (t) {
1582
- throw new v("input", `Cannot parse the OpenAPI document ${e}: ${y(t)}`, { cause: t });
1582
+ throw new y("input", `Cannot parse the OpenAPI document ${e}: ${b(t)}`, { cause: t });
1583
1583
  }
1584
1584
  }
1585
- function Gn(e, t) {
1586
- if (typeof e != "object" || !e || Array.isArray(e)) throw new v("input", `${t} is not an OpenAPI document: expected an object at the top level.`);
1585
+ function Wn(e, t) {
1586
+ if (typeof e != "object" || !e || Array.isArray(e)) throw new y("input", `${t} is not an OpenAPI document: expected an object at the top level.`);
1587
1587
  let n = e;
1588
- if (n.swagger !== void 0) throw new v("input", `${t} is a Swagger ${String(n.swagger)} document; wow-generator reads OpenAPI 3.x only. Convert it first, for example with swagger2openapi.`);
1589
- if (typeof n.openapi != "string" || !/^3\.\d+/.test(n.openapi)) throw new v("input", `${t} is not an OpenAPI 3.x document: its "openapi" field is ${n.openapi === void 0 ? "missing" : JSON.stringify(n.openapi)}.`);
1590
- if (typeof n.info != "object" || n.info === null || Array.isArray(n.info)) throw new v("input", `${t} is not a valid OpenAPI document: its "info" object is missing.`);
1588
+ if (n.swagger !== void 0) throw new y("input", `${t} is a Swagger ${String(n.swagger)} document; wow-generator reads OpenAPI 3.x only. Convert it first, for example with swagger2openapi.`);
1589
+ if (typeof n.openapi != "string" || !/^3\.\d+/.test(n.openapi)) throw new y("input", `${t} is not an OpenAPI 3.x document: its "openapi" field is ${n.openapi === void 0 ? "missing" : JSON.stringify(n.openapi)}.`);
1590
+ if (typeof n.info != "object" || n.info === null || Array.isArray(n.info)) throw new y("input", `${t} is not a valid OpenAPI document: its "info" object is missing.`);
1591
1591
  return {
1592
1592
  ...n,
1593
1593
  paths: n.paths ?? {}
1594
1594
  };
1595
1595
  }
1596
- function Kn(e) {
1597
- switch (qn(e)) {
1596
+ function Gn(e) {
1597
+ switch (Kn(e)) {
1598
1598
  case "json": return JSON.parse(e);
1599
1599
  case "yaml": return h(e);
1600
1600
  }
1601
1601
  }
1602
- function qn(e) {
1602
+ function Kn(e) {
1603
1603
  let t = e.trimStart();
1604
1604
  if (t.startsWith("{") || t.startsWith("[")) return "json";
1605
1605
  if (t.startsWith("-") || t.startsWith("%YAML")) return "yaml";
@@ -1611,16 +1611,16 @@ function qn(e) {
1611
1611
  throw Error("Unable to infer file format");
1612
1612
  }
1613
1613
  // src/input/configuration.ts
1614
- async function Jn(e, t, n) {
1614
+ async function qn(e, t, n) {
1615
1615
  if (e !== void 0) return {
1616
- ...await Zn({
1616
+ ...await Xn({
1617
1617
  path: e,
1618
1618
  explicit: !0
1619
1619
  }, t, n),
1620
- origin: Qn(e)
1620
+ origin: Zn(e)
1621
1621
  };
1622
- let r = await Zn({
1623
- path: ee,
1622
+ let r = await Xn({
1623
+ path: v,
1624
1624
  explicit: !1
1625
1625
  }, t, n);
1626
1626
  return r === void 0 ? (t.debug("No configuration file found, generating with defaults"), {
@@ -1628,22 +1628,22 @@ async function Jn(e, t, n) {
1628
1628
  warnings: []
1629
1629
  }) : {
1630
1630
  ...r,
1631
- origin: Qn(ee)
1631
+ origin: Zn(v)
1632
1632
  };
1633
1633
  }
1634
- var Yn = ["apiClients"], Xn = ["ignorePathParameters", "methodNames"];
1635
- async function Zn(e, t, n) {
1636
- let r = Qn(e.path);
1634
+ var Jn = ["apiClients"], Yn = ["ignorePathParameters", "methodNames"];
1635
+ async function Xn(e, t, n) {
1636
+ let r = Zn(e.path);
1637
1637
  t.debug(`Reading configuration: ${r}`);
1638
1638
  let i;
1639
1639
  try {
1640
- i = await Bn(e.path, n);
1640
+ i = await zn(e.path, n);
1641
1641
  } catch (n) {
1642
- if (!e.explicit && $n(n)) {
1642
+ if (!e.explicit && Qn(n)) {
1643
1643
  t.debug(`No configuration file at ${r}`);
1644
1644
  return;
1645
1645
  }
1646
- throw new v("configuration", `Cannot read configuration ${r}: ${y(n)}`, { cause: n });
1646
+ throw new y("configuration", `Cannot read configuration ${r}: ${b(n)}`, { cause: n });
1647
1647
  }
1648
1648
  if (!i.trim()) return {
1649
1649
  config: {},
@@ -1651,118 +1651,118 @@ async function Zn(e, t, n) {
1651
1651
  };
1652
1652
  let a;
1653
1653
  try {
1654
- a = Kn(i);
1654
+ a = Gn(i);
1655
1655
  } catch (e) {
1656
- throw new v("configuration", `Cannot parse configuration ${r}: ${y(e)}`, { cause: e });
1656
+ throw new y("configuration", `Cannot parse configuration ${r}: ${b(e)}`, { cause: e });
1657
1657
  }
1658
- let o = tr(a, r);
1659
- return t.debug(`Configuration loaded from ${r}: ${rr(o.config)}`), o;
1658
+ let o = er(a, r);
1659
+ return t.debug(`Configuration loaded from ${r}: ${nr(o.config)}`), o;
1660
1660
  }
1661
- function Qn(e) {
1662
- return zn(e) || u(e) ? e : p(e);
1661
+ function Zn(e) {
1662
+ return Rn(e) || u(e) ? e : p(e);
1663
1663
  }
1664
- function $n(e) {
1664
+ function Qn(e) {
1665
1665
  return typeof e == "object" && !!e && e.code === "ENOENT";
1666
1666
  }
1667
- function H(e) {
1667
+ function U(e) {
1668
1668
  return e === null ? "null" : Array.isArray(e) ? "an array" : `a ${typeof e}`;
1669
1669
  }
1670
- function U(e) {
1670
+ function W(e) {
1671
1671
  return typeof e == "object" && !!e && !Array.isArray(e);
1672
1672
  }
1673
- function er(e, t, n, r, i) {
1673
+ function $n(e, t, n, r, i) {
1674
1674
  let a = Object.keys(r).filter((e) => !i.includes(e));
1675
1675
  a.length && e.push(`Ignoring unknown ${n} option(s) in ${t}: ${a.join(", ")}. Known option(s): ${i.join(", ")}`);
1676
1676
  }
1677
- function tr(e, t) {
1678
- if (!U(e)) throw new v("configuration", `Configuration ${t} must be a JSON or YAML object, found ${H(e)}`);
1677
+ function er(e, t) {
1678
+ if (!W(e)) throw new y("configuration", `Configuration ${t} must be a JSON or YAML object, found ${U(e)}`);
1679
1679
  let n = [];
1680
- return er(n, t, "configuration", e, Yn), nr(e.apiClients, t, n), {
1680
+ return $n(n, t, "configuration", e, Jn), tr(e.apiClients, t, n), {
1681
1681
  config: e,
1682
1682
  warnings: n
1683
1683
  };
1684
1684
  }
1685
- function nr(e, t, n) {
1685
+ function tr(e, t, n) {
1686
1686
  if (e !== void 0) {
1687
- if (!U(e)) throw new v("configuration", `apiClients in ${t} must be an object keyed by tag name, found ${H(e)}`);
1687
+ if (!W(e)) throw new y("configuration", `apiClients in ${t} must be an object keyed by tag name, found ${U(e)}`);
1688
1688
  for (let [r, i] of Object.entries(e)) {
1689
- if (!U(i)) throw new v("configuration", `apiClients["${r}"] in ${t} must be an object, found ${H(i)}`);
1690
- er(n, t, `apiClients["${r}"]`, i, Xn);
1689
+ if (!W(i)) throw new y("configuration", `apiClients["${r}"] in ${t} must be an object, found ${U(i)}`);
1690
+ $n(n, t, `apiClients["${r}"]`, i, Yn);
1691
1691
  let { ignorePathParameters: e } = i;
1692
- if (e !== void 0 && !(Array.isArray(e) && e.every((e) => typeof e == "string"))) throw new v("configuration", `apiClients["${r}"].ignorePathParameters in ${t} must be an array of strings, found ${H(e)}`);
1692
+ if (e !== void 0 && !(Array.isArray(e) && e.every((e) => typeof e == "string"))) throw new y("configuration", `apiClients["${r}"].ignorePathParameters in ${t} must be an array of strings, found ${U(e)}`);
1693
1693
  let { methodNames: a } = i;
1694
1694
  if (a !== void 0) {
1695
- if (!U(a)) throw new v("configuration", `apiClients["${r}"].methodNames in ${t} must be an object mapping operationIds to method names, found ${H(a)}`);
1696
- for (let [e, n] of Object.entries(a)) if (typeof n != "string" || !O(n)) throw new v("configuration", `apiClients["${r}"].methodNames["${e}"] in ${t} must be a valid method name, found ${JSON.stringify(n)}`);
1695
+ if (!W(a)) throw new y("configuration", `apiClients["${r}"].methodNames in ${t} must be an object mapping operationIds to method names, found ${U(a)}`);
1696
+ for (let [e, n] of Object.entries(a)) if (typeof n != "string" || !k(n)) throw new y("configuration", `apiClients["${r}"].methodNames["${e}"] in ${t} must be a valid method name, found ${JSON.stringify(n)}`);
1697
1697
  }
1698
1698
  }
1699
1699
  }
1700
1700
  }
1701
- function rr(e) {
1701
+ function nr(e) {
1702
1702
  let t = Object.keys(e.apiClients ?? {});
1703
1703
  return `apiClients=${t.length ? t.join(", ") : "none"}`;
1704
1704
  }
1705
- var ir = /* @__PURE__ */ new Set(), ar = "#/$defs/";
1706
- function W(e) {
1707
- return e.startsWith(ar) ? e.slice(8) : void 0;
1705
+ var rr = /* @__PURE__ */ new Set(), ir = "#/$defs/";
1706
+ function G(e) {
1707
+ return e.startsWith(ir) ? e.slice(8) : void 0;
1708
1708
  }
1709
- function or(e) {
1709
+ function ar(e) {
1710
1710
  if (typeof e != "object" || !e) return !1;
1711
1711
  let t = e;
1712
1712
  return t.openapi === void 0 && t.swagger === void 0 && typeof t.format == "number" && Array.isArray(t.contexts);
1713
1713
  }
1714
- function G(e) {
1714
+ function K(e) {
1715
1715
  return typeof e == "object" && !!e && !Array.isArray(e);
1716
1716
  }
1717
- function sr(e, t) {
1717
+ function or(e, t) {
1718
1718
  let n = e;
1719
- if (n.format !== 1) throw new v("input", `${t} is a Wow Manifest of format ${n.format}; wow-generator reads format 1.`);
1720
- let r = (n.requires ?? []).filter((e) => !ir.has(e));
1721
- if (r.length > 0) throw new v("input", `${t} requires ${r.join(", ")}, which this wow-generator does not understand: generate with a newer one.`);
1719
+ if (n.format !== 1) throw new y("input", `${t} is a Wow Manifest of format ${n.format}; wow-generator reads format 1.`);
1720
+ let r = (n.requires ?? []).filter((e) => !rr.has(e));
1721
+ if (r.length > 0) throw new y("input", `${t} requires ${r.join(", ")}, which this wow-generator does not understand: generate with a newer one.`);
1722
1722
  let i = [];
1723
1723
  if (n.contexts.forEach((e, t) => {
1724
- !G(e) || typeof e.name != "string" ? i.push(`contexts[${t}] has no name`) : (e.aggregates ?? []).forEach((t, n) => {
1724
+ !K(e) || typeof e.name != "string" ? i.push(`contexts[${t}] has no name`) : (e.aggregates ?? []).forEach((t, n) => {
1725
1725
  let r = `${e.name}.aggregates[${n}]`;
1726
- !G(t) || typeof t.name != "string" ? i.push(`${r} has no name`) : !G(t.state) || typeof t.state.schema != "string" ? i.push(`${e.name}.${t.name} has no state schema`) : ((t.commands ?? []).forEach((n) => {
1726
+ !K(t) || typeof t.name != "string" ? i.push(`${r} has no name`) : !K(t.state) || typeof t.state.schema != "string" ? i.push(`${e.name}.${t.name} has no state schema`) : ((t.commands ?? []).forEach((n) => {
1727
1727
  (typeof n?.name != "string" || typeof n.schema != "string") && i.push(`a command of ${e.name}.${t.name} has no name or schema`);
1728
1728
  }), (t.events ?? []).forEach((n) => {
1729
1729
  (typeof n?.name != "string" || typeof n.schema != "string") && i.push(`an event of ${e.name}.${t.name} has no name or schema`);
1730
1730
  }));
1731
1731
  });
1732
- }), n.$defs !== void 0 && !G(n.$defs) && i.push("$defs is not an object"), i.length > 0) throw new v("specification", `${t} is not a Manifest wow-generator can read: ${i.join("; ")}.`);
1732
+ }), n.$defs !== void 0 && !K(n.$defs) && i.push("$defs is not an object"), i.length > 0) throw new y("specification", `${t} is not a Manifest wow-generator can read: ${i.join("; ")}.`);
1733
1733
  return n;
1734
1734
  }
1735
1735
  // src/manifest/analyze.ts
1736
- var cr = /* @__PURE__ */ new Set([
1736
+ var sr = /* @__PURE__ */ new Set([
1737
1737
  "int64",
1738
1738
  "bigint",
1739
1739
  "decimal"
1740
- ]), lr = {
1740
+ ]), cr = {
1741
1741
  "wow.lifecycle.TransferOwner": "TransferOwner",
1742
1742
  "wow.lifecycle.TransferSpace": "TransferSpace",
1743
1743
  "wow.lifecycle.ApplyTags": "ApplyTags"
1744
- }, ur = /* @__PURE__ */ new Set([
1744
+ }, lr = /* @__PURE__ */ new Set([
1745
1745
  "wow.lifecycle.DeleteAggregate",
1746
1746
  "wow.lifecycle.RestoreAggregate",
1747
1747
  "wow.lifecycle.TransferOwner",
1748
1748
  "wow.lifecycle.TransferSpace",
1749
1749
  "wow.lifecycle.ApplyTags"
1750
- ]), dr = 4;
1751
- function K(e) {
1750
+ ]), ur = 4;
1751
+ function q(e) {
1752
1752
  return typeof e == "object" && !!e && !Array.isArray(e);
1753
1753
  }
1754
- function q(e) {
1754
+ function J(e) {
1755
1755
  let t = e.type;
1756
1756
  return typeof t == "string" ? [t] : Array.isArray(t) ? t.filter((e) => typeof e == "string") : [];
1757
1757
  }
1758
- function fr(e, t) {
1758
+ function dr(e, t) {
1759
1759
  let n = [...new Set(e)];
1760
1760
  return n.length === 1 ? n[0] : n.map((e) => / [|&] /.test(e) && !e.startsWith("{") ? `(${e})` : e).join(t);
1761
1761
  }
1762
- function pr(e) {
1763
- return typeof e == "string" ? P(e) : JSON.stringify(e);
1762
+ function fr(e) {
1763
+ return typeof e == "string" ? F(e) : JSON.stringify(e);
1764
1764
  }
1765
- var mr = class {
1765
+ var pr = class {
1766
1766
  defs;
1767
1767
  names = /* @__PURE__ */ new Map();
1768
1768
  warnings = [];
@@ -1777,7 +1777,7 @@ var mr = class {
1777
1777
  for (let e = 0; t.size > 0; e++) {
1778
1778
  let n = /* @__PURE__ */ new Map();
1779
1779
  for (let r of t.keys()) {
1780
- let t = r.split("."), i = t[t.length - 1].split("$"), a = k([...t.slice(Math.max(0, t.length - 1 - e), t.length - 1), ...i].map((e) => /^[a-z]/.test(e) ? A(e) : e));
1780
+ let t = r.split("."), i = t[t.length - 1].split("$"), a = A([...t.slice(Math.max(0, t.length - 1 - e), t.length - 1), ...i].map((e) => /^[a-z]/.test(e) ? j(e) : e));
1781
1781
  n.set(a, [...n.get(a) ?? [], r]);
1782
1782
  }
1783
1783
  let r = new Set(this.names.values());
@@ -1793,20 +1793,20 @@ var mr = class {
1793
1793
  }
1794
1794
  schemaOf(e) {
1795
1795
  let t = this.defs[e];
1796
- return K(t) ? t : void 0;
1796
+ return q(t) ? t : void 0;
1797
1797
  }
1798
1798
  resolve(e, t = /* @__PURE__ */ new Set()) {
1799
1799
  let n = e.$ref;
1800
1800
  if (typeof n != "string") return e;
1801
- let r = W(n);
1801
+ let r = G(n);
1802
1802
  if (r === void 0 || t.has(r)) return e;
1803
1803
  let i = this.schemaOf(r);
1804
1804
  return i ? this.resolve(i, /* @__PURE__ */ new Set([...t, r])) : e;
1805
1805
  }
1806
1806
  references(e, t = /* @__PURE__ */ new Set()) {
1807
1807
  if (Array.isArray(e)) e.forEach((e) => this.references(e, t));
1808
- else if (K(e)) for (let [n, r] of Object.entries(e)) if (n === "$ref" && typeof r == "string") {
1809
- let e = W(r);
1808
+ else if (q(e)) for (let [n, r] of Object.entries(e)) if (n === "$ref" && typeof r == "string") {
1809
+ let e = G(r);
1810
1810
  e !== void 0 && t.add(e);
1811
1811
  } else n !== "enum" && n !== "const" && this.references(r, t);
1812
1812
  return t;
@@ -1839,29 +1839,29 @@ var mr = class {
1839
1839
  type(e, t) {
1840
1840
  if (e === !0 || e === void 0) return "unknown";
1841
1841
  if (e === !1) return "never";
1842
- if (!K(e)) return "unknown";
1842
+ if (!q(e)) return "unknown";
1843
1843
  if (typeof e.$ref == "string") {
1844
- let n = W(e.$ref);
1844
+ let n = G(e.$ref);
1845
1845
  return n === void 0 ? "unknown" : this.refType(n, t);
1846
1846
  }
1847
- if ("const" in e) return pr(e.const);
1848
- if (Array.isArray(e.enum)) return e.enum.length === 0 ? "never" : fr(e.enum.map(pr), " | ");
1847
+ if ("const" in e) return fr(e.const);
1848
+ if (Array.isArray(e.enum)) return e.enum.length === 0 ? "never" : dr(e.enum.map(fr), " | ");
1849
1849
  for (let [n, r] of [
1850
1850
  ["oneOf", " | "],
1851
1851
  ["anyOf", " | "],
1852
1852
  ["allOf", " & "]
1853
1853
  ]) {
1854
1854
  let i = e[n];
1855
- if (Array.isArray(i) && i.length > 0) return fr(i.map((e) => this.type(e, t)), r);
1855
+ if (Array.isArray(i) && i.length > 0) return dr(i.map((e) => this.type(e, t)), r);
1856
1856
  }
1857
- let n = q(e);
1858
- return n.length === 0 ? K(e.properties) ? this.objectType(e, t) : "unknown" : fr(n.map((n) => this.primitive(n, e, t)), " | ");
1857
+ let n = J(e);
1858
+ return n.length === 0 ? q(e.properties) ? this.objectType(e, t) : "unknown" : dr(n.map((n) => this.primitive(n, e, t)), " | ");
1859
1859
  }
1860
1860
  primitive(e, t, n) {
1861
1861
  switch (e) {
1862
1862
  case "string": return "string";
1863
1863
  case "integer":
1864
- case "number": return typeof t.format == "string" && cr.has(t.format) ? "string" : "number";
1864
+ case "number": return typeof t.format == "string" && sr.has(t.format) ? "string" : "number";
1865
1865
  case "boolean": return "boolean";
1866
1866
  case "null": return "null";
1867
1867
  case "array": {
@@ -1879,12 +1879,12 @@ var mr = class {
1879
1879
  return r !== void 0 && i.push("[key: string]: unknown"), `{ ${i.join("; ")} }`;
1880
1880
  }
1881
1881
  properties(e, t) {
1882
- if (!K(e.properties)) return [];
1882
+ if (!q(e.properties)) return [];
1883
1883
  let n = new Set(Array.isArray(e.required) ? e.required : []);
1884
1884
  return Object.entries(e.properties).map(([e, r]) => {
1885
- let i = K(r) ? r.description : void 0;
1885
+ let i = q(r) ? r.description : void 0;
1886
1886
  return {
1887
- name: N(e),
1887
+ name: P(e),
1888
1888
  type: this.type(r, `${t}.${e}`),
1889
1889
  optional: !n.has(e),
1890
1890
  ...typeof i == "string" ? { description: i } : {}
@@ -1896,12 +1896,12 @@ var mr = class {
1896
1896
  if (n !== void 0 && n !== !1) return this.type(n, t);
1897
1897
  }
1898
1898
  isInterface(e) {
1899
- let t = q(e);
1900
- return K(e.properties) && (t.length === 0 || t.length === 1 && t[0] === "object") && e.$ref === void 0 && e.allOf === void 0 && e.oneOf === void 0 && e.anyOf === void 0;
1899
+ let t = J(e);
1900
+ return q(e.properties) && (t.length === 0 || t.length === 1 && t[0] === "object") && e.$ref === void 0 && e.allOf === void 0 && e.oneOf === void 0 && e.anyOf === void 0;
1901
1901
  }
1902
1902
  textNumbers(e, t = /* @__PURE__ */ new Set()) {
1903
- if (!K(e)) return;
1904
- let n = typeof e.$ref == "string" ? W(e.$ref) : void 0;
1903
+ if (!q(e)) return;
1904
+ let n = typeof e.$ref == "string" ? G(e.$ref) : void 0;
1905
1905
  if (n !== void 0) {
1906
1906
  let e = this.schemaOf(n);
1907
1907
  return t.has(n) || e === void 0 ? void 0 : this.textNumbers(e, /* @__PURE__ */ new Set([...t, n]));
@@ -1910,41 +1910,46 @@ var mr = class {
1910
1910
  "oneOf",
1911
1911
  "anyOf",
1912
1912
  "allOf"
1913
- ].flatMap((t) => Array.isArray(e[t]) ? e[t] : []).map((e) => this.textNumbers(e, t)).filter((e) => e !== void 0), i = q(e);
1914
- (i.includes("integer") || i.includes("number")) && typeof e.format == "string" && cr.has(e.format) && r.push(!0);
1913
+ ].flatMap((t) => Array.isArray(e[t]) ? e[t] : []).map((e) => this.textNumbers(e, t)).filter((e) => e !== void 0), i = J(e);
1914
+ (i.includes("integer") || i.includes("number")) && typeof e.format == "string" && sr.has(e.format) && r.push(!0);
1915
1915
  let a = {};
1916
- if (K(e.properties)) for (let [n, r] of Object.entries(e.properties)) {
1916
+ if (q(e.properties)) for (let [n, r] of Object.entries(e.properties)) {
1917
1917
  let e = this.textNumbers(r, t);
1918
1918
  e !== void 0 && (a[n] = e);
1919
1919
  }
1920
1920
  let o = this.textNumbers(e.items, t) ?? this.textNumbers(e.additionalProperties, t);
1921
- return o !== void 0 && (a["*"] = o), Object.keys(a).length > 0 && r.push(a), hr(r);
1921
+ return o !== void 0 && (a["*"] = o), Object.keys(a).length > 0 && r.push(a), mr(r);
1922
1922
  }
1923
1923
  fields(e, t, n = 1, r = /* @__PURE__ */ new Set()) {
1924
- let i = this.resolve(e), a = typeof e.$ref == "string" ? W(e.$ref) : void 0;
1924
+ let i = this.resolve(e), a = typeof e.$ref == "string" ? G(e.$ref) : void 0;
1925
1925
  if (a !== void 0 && r.has(a)) return [];
1926
1926
  let o = a === void 0 ? r : /* @__PURE__ */ new Set([...r, a]);
1927
- if (!K(i.properties)) return [];
1927
+ if (!q(i.properties)) return [];
1928
1928
  let s = [];
1929
1929
  for (let [e, r] of Object.entries(i.properties)) {
1930
1930
  let i = `${t}.${e}`;
1931
- s.push(i), n < dr && K(r) && (q(this.resolve(r)).includes("array") || s.push(...this.fields(r, i, n + 1, o)));
1931
+ s.push(i), n < ur && q(r) && (J(this.resolve(r)).includes("array") || s.push(...this.fields(r, i, n + 1, o)));
1932
1932
  }
1933
1933
  return s;
1934
1934
  }
1935
1935
  };
1936
- function hr(e) {
1936
+ function mr(e) {
1937
1937
  if (e.length === 0) return;
1938
1938
  let t = e.filter((e) => e !== !0);
1939
1939
  if (t.length === 0) return !0;
1940
1940
  let n = {};
1941
1941
  for (let e of t) for (let [t, r] of Object.entries(e)) (n[t] ??= []).push(r);
1942
- return Object.fromEntries(Object.entries(n).map(([e, t]) => [e, hr(t)]));
1942
+ return Object.fromEntries(Object.entries(n).map(([e, t]) => [e, mr(t)]));
1943
1943
  }
1944
- function gr(e, t) {
1944
+ function hr(e, t, n) {
1945
1945
  if (t === void 0) return !0;
1946
- let n = e.resolve(t);
1947
- return !Array.isArray(n.required) || n.required.length === 0;
1946
+ let r = e.resolve(t);
1947
+ return !Array.isArray(r.required) || r.required.every((e) => e === n);
1948
+ }
1949
+ function gr(e, t, n) {
1950
+ if (t === void 0) return !1;
1951
+ let r = e.resolve(t).properties, i = q(r) ? r[n] : void 0;
1952
+ return q(i) && i.readOnly === !0;
1948
1953
  }
1949
1954
  function _r(e) {
1950
1955
  return (e.commands ?? []).filter((e) => e.system !== !0);
@@ -1957,20 +1962,20 @@ function yr(e, t) {
1957
1962
  t.state.schema,
1958
1963
  ..._r(t).map((e) => e.schema),
1959
1964
  ...(t.events ?? []).map((e) => e.schema)
1960
- ].map(W).filter((e) => e !== void 0).concat(br(e, t));
1965
+ ].map(G).filter((e) => e !== void 0).concat(br(e, t));
1961
1966
  }
1962
1967
  function br(e, t) {
1963
- return vr(t).map((e) => e.name).filter((t) => lr[t] !== void 0 && e.schemaOf(t));
1968
+ return vr(t).map((e) => e.name).filter((t) => cr[t] !== void 0 && e.schemaOf(t));
1964
1969
  }
1965
1970
  function xr(e) {
1966
- let t = new mr(e.$defs ?? {}), n = e.contexts, r = /* @__PURE__ */ new Map();
1971
+ let t = new pr(e.$defs ?? {}), n = e.contexts, r = /* @__PURE__ */ new Map();
1967
1972
  for (let e of n) {
1968
1973
  let n = [...(e.aggregates ?? []).flatMap((e) => yr(t, e)), ...(e.routes ?? []).flatMap((e) => [...t.references(e.request), ...t.references(e.response)])];
1969
- for (let i of t.closure(n).sort(w)) r.has(i) || r.set(i, e.name);
1974
+ for (let i of t.closure(n).sort(T)) r.has(i) || r.set(i, e.name);
1970
1975
  }
1971
1976
  let i = [...r.keys()].filter((e) => t.schemaOf(e) && !t.inlined(e));
1972
- t.name([...i].sort(w));
1973
- let a = i.map((e) => Sr(t, e, `${r.get(e)}/types.ts`)).sort((e, t) => w(e.file, t.file) || w(e.name, t.name)), o = n.map((e) => Cr(t, e));
1977
+ t.name([...i].sort(T));
1978
+ let a = i.map((e) => Sr(t, e, `${r.get(e)}/types.ts`)).sort((e, t) => T(e.file, t.file) || T(e.name, t.name)), o = n.map((e) => Cr(t, e));
1974
1979
  return {
1975
1980
  model: {
1976
1981
  ...e.service?.name ? { service: e.service.name } : {},
@@ -1986,7 +1991,7 @@ function Sr(e, t, n) {
1986
1991
  name: i,
1987
1992
  file: n,
1988
1993
  ...a === void 0 ? {} : { description: a },
1989
- references: [...new Set(o)].sort(w)
1994
+ references: [...new Set(o)].sort(T)
1990
1995
  };
1991
1996
  if (e.isInterface(r)) {
1992
1997
  let n = e.additional(r, t);
@@ -2005,15 +2010,15 @@ function Cr(e, t) {
2005
2010
  return {
2006
2011
  name: t.name,
2007
2012
  ...t.description ? { description: t.description } : {},
2008
- typeName: k(A(t.name)),
2009
- constantName: M(t.name),
2013
+ typeName: A(j(t.name)),
2014
+ constantName: N(t.name),
2010
2015
  directory: t.name,
2011
2016
  errors: (t.errors ?? []).map((e) => ({
2012
2017
  code: e.code,
2013
2018
  status: e.status,
2014
2019
  ...e.description ? { description: e.description } : {}
2015
2020
  })),
2016
- subscriptions: [...new Set((t.subscriptions ?? []).map((e) => e.name))].sort(w),
2021
+ subscriptions: [...new Set((t.subscriptions ?? []).map((e) => e.name))].sort(T),
2017
2022
  aggregates: (t.aggregates ?? []).map((n) => Er(e, t, n)),
2018
2023
  routes: (t.routes ?? []).map((n) => {
2019
2024
  let r = `${t.name} route ${n.name}`;
@@ -2042,30 +2047,30 @@ function wr(e) {
2042
2047
  }));
2043
2048
  }
2044
2049
  function Tr(e, t, n) {
2045
- let r = W(t);
2050
+ let r = G(t);
2046
2051
  return r === void 0 ? "unknown" : e.refType(r, n);
2047
2052
  }
2048
2053
  function Er(e, t, n) {
2049
- let r = `${t.name}.${n.name}`, i = k(A(n.name)), a = n.idSource ?? "assigned", o = a === "owner", s = new Set(br(e, n)), c = vr(n).filter((e) => ur.has(e.name)).map((t) => {
2050
- let n = t.name, i = n.split(".").pop(), a = e.schemaOf(n)?.description, c = et(j(i)), l = o && (t.routes ?? []).some((e) => !e.path.includes("{id}"));
2054
+ let r = `${t.name}.${n.name}`, i = A(j(n.name)), a = n.idSource ?? "assigned", o = a === "owner", s = new Set(br(e, n)), c = vr(n).filter((e) => lr.has(e.name)).map((t) => {
2055
+ let n = t.name, i = n.split(".").pop(), a = e.schemaOf(n)?.description, c = $e(M(i)), l = o && (t.routes ?? []).some((e) => !e.path.includes("{id}"));
2051
2056
  return {
2052
2057
  name: n,
2053
- member: M(i),
2058
+ member: N(i),
2054
2059
  method: c,
2055
2060
  routes: wr(t),
2056
2061
  ...l ? { ownMethod: `${c}Own` } : {},
2057
2062
  ...s.has(n) ? {
2058
2063
  bodyType: e.refType(n, r),
2059
2064
  bodyGenerated: !0
2060
- } : lr[n] ? { bodyType: lr[n] } : {},
2065
+ } : cr[n] ? { bodyType: cr[n] } : {},
2061
2066
  ...typeof a == "string" ? { description: a } : {}
2062
2067
  };
2063
2068
  }), l = new Set(c.flatMap((e) => [e.method, e.ownMethod ?? e.method])), u = _r(n).map((t) => {
2064
- let n = et(j(t.name));
2069
+ let n = $e(M(t.name));
2065
2070
  (l.has(n) || n === "gateway") && (n = `${n}Command`), l.add(n);
2066
2071
  let i = (t.routes ?? []).filter((e) => e.method === "POST"), a = i.find((e) => e.path.includes("{id}")), s = i.find((e) => !e.path.includes("{id}")), c;
2067
2072
  o && a && s && !(t.mounted ?? !1) && (c = `${n}Own`, l.has(c) && (c = `${c}Command`), l.add(c));
2068
- let u = W(t.schema);
2073
+ let u = G(t.schema), d = u === void 0 ? void 0 : e.schemaOf(u), f = t.idProperty, p = f !== void 0 && gr(e, d, f);
2069
2074
  return {
2070
2075
  name: t.name,
2071
2076
  method: n,
@@ -2074,7 +2079,9 @@ function Er(e, t, n) {
2074
2079
  ...s ? { unaddressedPath: { path: s.path } } : {},
2075
2080
  ...c === void 0 ? {} : { ownMethod: c },
2076
2081
  bodyType: Tr(e, t.schema, `${r}.${t.name}`),
2077
- bodyOptional: gr(e, u === void 0 ? void 0 : e.schemaOf(u)),
2082
+ bodyOptional: hr(e, d, p ? f : void 0),
2083
+ ...f === void 0 ? {} : { idProperty: f },
2084
+ ...p ? { idComputed: p } : {},
2078
2085
  creation: t.creation ?? "none",
2079
2086
  mounted: t.mounted ?? !1,
2080
2087
  produces: t.produces ?? [],
@@ -2091,7 +2098,7 @@ function Er(e, t, n) {
2091
2098
  ...d === void 0 ? {} : { state: d },
2092
2099
  ...Object.keys(f).length === 0 ? {} : { events: f },
2093
2100
  ...Object.keys(p).length === 0 ? {} : { commands: p }
2094
- }, h = W(n.state.schema), g = h === void 0 ? void 0 : e.schemaOf(h);
2101
+ }, h = G(n.state.schema), g = h === void 0 ? void 0 : e.schemaOf(h);
2095
2102
  return {
2096
2103
  context: t.name,
2097
2104
  name: n.name,
@@ -2119,121 +2126,121 @@ function Dr(e, t, n) {
2119
2126
  return n.includes(".") ? n : `${e.name}.${t.name}.${n}`;
2120
2127
  }
2121
2128
  // src/emitters/manifestClients.ts
2122
- var J = "@ahoo-wang/wow-client", Or = "@ahoo-wang/wow-client/routes";
2123
- function Y(e, t = "") {
2124
- let n = e.filter((e) => typeof e == "string" && e !== "").flatMap((e) => Ot(e).split("\n"));
2129
+ var Y = "@ahoo-wang/wow-client", Or = "@ahoo-wang/wow-client/routes";
2130
+ function X(e, t = "") {
2131
+ let n = e.filter((e) => typeof e == "string" && e !== "").flatMap((e) => Dt(e).split("\n"));
2125
2132
  return n.length === 0 ? "" : n.length === 1 ? `${t}/** ${n[0]} */\n` : `${t}/**\n${n.map((e) => `${t} * ${e}`.trimEnd()).join("\n")}\n${t} */\n`;
2126
2133
  }
2127
- function X(e, t) {
2134
+ function Z(e, t) {
2128
2135
  e.add(`\n${t}`);
2129
2136
  }
2130
- function Z(e) {
2137
+ function Q(e) {
2131
2138
  return e.length === 0 ? "never" : e.join(" | ");
2132
2139
  }
2133
- function Q(e, t, n, r, i) {
2140
+ function $(e, t, n, r, i) {
2134
2141
  let a = /* @__PURE__ */ new Map();
2135
2142
  for (let e of new Set(r)) {
2136
2143
  let t = n.get(e);
2137
2144
  t !== void 0 && t !== i && a.set(t, [...a.get(t) ?? [], e]);
2138
2145
  }
2139
- for (let [n, r] of a) e.imports.add(L(e.directoryPath, _(t, n)), r);
2146
+ for (let [n, r] of a) e.imports.add(R(e.directoryPath, _(t, n)), r);
2140
2147
  }
2141
2148
  function kr(e, t, n) {
2142
2149
  let r = new Map(e.types.map((e) => [e.name, e.file]));
2143
2150
  for (let i of e.types) Ar(t.module(i.file), i, r, n);
2144
2151
  for (let i of e.contexts) {
2145
2152
  Nr(i, t, n);
2146
- for (let e of i.aggregates) Br(e, i, t, r, n), Wr(e, i, t, r, n), Gr(e, t, r, n);
2153
+ for (let e of i.aggregates) Br(e, i, t, r, n), Gr(e, i, t, r, n), Kr(e, t, r, n);
2147
2154
  Pr(i, t), Fr(i, t, r, n), Lr(i, t, n);
2148
2155
  }
2149
2156
  }
2150
2157
  function Ar(e, t, n, r) {
2151
- Q(e, r, n, t.references, t.file);
2152
- let i = Y([t.description, `- key: \`${t.key}\``]);
2158
+ $(e, r, n, t.references, t.file);
2159
+ let i = X([t.description, `- key: \`${t.key}\``]);
2153
2160
  if (t.properties === void 0) {
2154
- X(e, `${i}export type ${t.name} = ${t.type};`);
2161
+ Z(e, `${i}export type ${t.name} = ${t.type};`);
2155
2162
  return;
2156
2163
  }
2157
- let a = t.properties.map((e) => `${Y([e.description], " ")} ${e.name}${e.optional ? "?" : ""}: ${e.type};`);
2158
- t.type !== void 0 && a.push(` [key: string]: ${t.type};`), X(e, `${i}export interface ${t.name} {\n${a.join("\n")}\n}`);
2164
+ let a = t.properties.map((e) => `${X([e.description], " ")} ${e.name}${e.optional ? "?" : ""}: ${e.type};`);
2165
+ t.type !== void 0 && a.push(` [key: string]: ${t.type};`), Z(e, `${i}export interface ${t.name} {\n${a.join("\n")}\n}`);
2159
2166
  }
2160
2167
  function jr(e, t) {
2161
2168
  let n = e.aggregates.map((t) => `${e.name}.${t.name}.`), r = t === void 0 ? `${e.name}.` : `${e.name}.${t.name}.`;
2162
2169
  return e.errors.filter((e) => t === void 0 ? !n.some((t) => e.code.startsWith(t)) : e.code.startsWith(r)).map((e) => ({
2163
- member: M((e.code.startsWith(r) ? e.code.slice(r.length) : e.code).split(/[^A-Za-z0-9]+/)) || "ERROR",
2170
+ member: N((e.code.startsWith(r) ? e.code.slice(r.length) : e.code).split(/[^A-Za-z0-9]+/)) || "ERROR",
2164
2171
  error: e
2165
2172
  }));
2166
2173
  }
2167
2174
  function Mr(e, t) {
2168
- return e.length === 0 ? "" : `${t}Errors: {\n${e.map(({ member: e, error: n }) => `${Y([`${n.status}: ${n.description ?? n.code}`], `${t} `)}${t} ${e}: ${P(n.code)},`).join("\n")}\n${t}},\n`;
2175
+ return e.length === 0 ? "" : `${t}Errors: {\n${e.map(({ member: e, error: n }) => `${X([`${n.status}: ${n.description ?? n.code}`], `${t} `)}${t} ${e}: ${F(n.code)},`).join("\n")}\n${t}},\n`;
2169
2176
  }
2170
2177
  function Nr(e, t, n) {
2171
2178
  let r = t.module(`${e.directory}/contract.ts`), i = `${e.typeName}Contract`;
2172
- r.imports.add(J, ["Hop", "wait"]);
2173
- for (let t of e.aggregates) r.imports.add(L(r.directoryPath, _(n, t.directory, "aggregate.ts")), [`${t.typeName}Aggregate`]);
2179
+ r.imports.add(Y, ["Hop", "wait"]);
2180
+ for (let t of e.aggregates) r.imports.add(R(r.directoryPath, _(n, t.directory, "aggregate.ts")), [`${t.typeName}Aggregate`]);
2174
2181
  let a = e.aggregates.map((e) => ` ${e.typeName}: ${e.typeName}Aggregate,\n`);
2175
- X(r, `${Y([`The bounded context \`${e.name}\`: its name, its error codes and its aggregates, as the Kotlin \`${i}\` names them. A problem's \`code\` is one of its \`Errors\`, or of an aggregate's.`, e.description])}export const ${i} = {\n NAME: ${P(e.name)},\n${Mr(jr(e), " ")}${a.join("")}} as const;`), X(r, `${Y([`An error code of \`${e.name}\`, of the context or of one of its aggregates.`])}export type ${e.typeName}ErrorCode = ${Z(e.errors.map((e) => P(e.code)))};`);
2182
+ Z(r, `${X([`The bounded context \`${e.name}\`: its name, its error codes and its aggregates, as the Kotlin \`${i}\` names them. A problem's \`code\` is one of its \`Errors\`, or of an aggregate's.`, e.description])}export const ${i} = {\n NAME: ${F(e.name)},\n${Mr(jr(e), " ")}${a.join("")}} as const;`), Z(r, `${X([`An error code of \`${e.name}\`, of the context or of one of its aggregates.`])}export type ${e.typeName}ErrorCode = ${Q(e.errors.map((e) => F(e.code)))};`);
2176
2183
  let o = e.subscriptions.length > 0;
2177
- o && X(r, `${Y([`The subscriptions of \`${e.name}\` a \`handled\` hop names.`])}export type ${e.typeName}Subscription = ${Z(e.subscriptions.map(P))};`);
2184
+ o && Z(r, `${X([`The subscriptions of \`${e.name}\` a \`handled\` hop names.`])}export type ${e.typeName}Subscription = ${Q(e.subscriptions.map(F))};`);
2178
2185
  let s = `${i}.NAME`, c = [
2179
2186
  ` /** Until a command of \`${e.name}\` passed admission. */\n accepted: (): Hop => wait.accepted(${s}),`,
2180
2187
  ` /** Until a command's events are appended to the log of \`${e.name}\`. */\n committed: (): Hop => wait.committed(${s}),`,
2181
2188
  ` /** Until the snapshot of \`${e.name}\` holds the commit. */\n snapshot: (): Hop => wait.snapshot(${s}),`
2182
2189
  ];
2183
- o && c.push(` /** Until a subscription of \`${e.name}\` handled the commit. */\n handled: (subscription: ${e.typeName}Subscription): Hop => wait.handled(subscription, ${s}),`), X(r, `${Y([`The hops of a wait chain (\`Wow-Wait\`) in \`${e.name}\`.`])}export const ${j(e.name)}Wait = {\n${c.join("\n")}\n} as const;`);
2190
+ o && c.push(` /** Until a subscription of \`${e.name}\` handled the commit. */\n handled: (subscription: ${e.typeName}Subscription): Hop => wait.handled(subscription, ${s}),`), Z(r, `${X([`The hops of a wait chain (\`Wow-Wait\`) in \`${e.name}\`.`])}export const ${M(e.name)}Wait = {\n${c.join("\n")}\n} as const;`);
2184
2191
  }
2185
2192
  function Pr(e, t) {
2186
2193
  let n = t.module(`${e.directory}/manifest.ts`), r = `${e.typeName}Manifest`;
2187
- n.imports.add(J, ["MANIFEST_FORMAT", "RoutingManifest"]);
2188
- let i = (e, t) => ` { name: ${P(e)}, routes: ${Hr(t)} },`, a = e.aggregates.map((e) => {
2189
- let t = [...e.commands.filter((e) => e.routes.length > 0).map((e) => i(e.name, e.routes)), ...e.lifecycle.map((e) => i(e.name, e.routes))];
2190
- return ` {\n name: ${P(e.name)},\n commands: [\n${t.join("\n")}\n ],\n },`;
2191
- }), o = e.routes.map((e) => ` { name: ${P(e.name)}, route: { method: ${P(e.method)}, path: ${P(e.path)} } },`), s = o.length === 0 ? "" : ` routes: [\n${o.join("\n")}\n ],\n`;
2192
- X(n, `${Y([o.length === 0 ? `The routes of \`${e.name}\`'s commands, as its Manifest lists them: what its command clients send by, with no Manifest fetched and no schema.` : `The routes of \`${e.name}\`'s commands and service routes, as its Manifest lists them: what its clients send by, with no Manifest fetched and no schema.`])}export const ${r}: RoutingManifest = {\n format: MANIFEST_FORMAT,\n contexts: [\n {\n name: ${P(e.name)},\n aggregates: [\n${a.join("\n")}\n ],\n${s} },\n ],\n};`);
2194
+ n.imports.add(Y, ["MANIFEST_FORMAT", "RoutingManifest"]);
2195
+ let i = (e, t, n) => ` { name: ${F(e)}, routes: ${Hr(t)}${n === void 0 ? "" : `, idProperty: ${F(n)}`} },`, a = e.aggregates.map((e) => {
2196
+ let t = [...e.commands.filter((e) => e.routes.length > 0).map((e) => i(e.name, e.routes, e.idProperty)), ...e.lifecycle.map((e) => i(e.name, e.routes))];
2197
+ return ` {\n name: ${F(e.name)},\n commands: [\n${t.join("\n")}\n ],\n },`;
2198
+ }), o = e.routes.map((e) => ` { name: ${F(e.name)}, route: { method: ${F(e.method)}, path: ${F(e.path)} } },`), s = o.length === 0 ? "" : ` routes: [\n${o.join("\n")}\n ],\n`;
2199
+ Z(n, `${X([o.length === 0 ? `The routes of \`${e.name}\`'s commands, as its Manifest lists them: what its command clients send by, with no Manifest fetched and no schema.` : `The routes of \`${e.name}\`'s commands and service routes, as its Manifest lists them: what its clients send by, with no Manifest fetched and no schema.`])}export const ${r}: RoutingManifest = {\n format: MANIFEST_FORMAT,\n contexts: [\n {\n name: ${F(e.name)},\n aggregates: [\n${a.join("\n")}\n ],\n${s} },\n ],\n};`);
2193
2200
  }
2194
2201
  function Fr(e, t, n, r) {
2195
2202
  if (e.routes.length === 0) return;
2196
2203
  let i = t.module(`${e.directory}/routes.ts`), a = `${e.typeName}Routes`;
2197
- i.imports.add(J, ["RequestOptions", "WowClientOptions"]), i.imports.add(Or, ["ServiceRoutes"]), i.imports.add("./manifest.js", [`${e.typeName}Manifest`]), Q(i, r, n, e.routes.flatMap((e) => [
2204
+ i.imports.add(Y, ["RequestOptions", "WowClientOptions"]), i.imports.add(Or, ["ServiceRoutes"]), i.imports.add("./manifest.js", [`${e.typeName}Manifest`]), $(i, r, n, e.routes.flatMap((e) => [
2198
2205
  e.requestType,
2199
2206
  e.responseType,
2200
2207
  ...e.parameters.map((e) => e.type)
2201
2208
  ].filter((e) => e !== void 0).flatMap((e) => e.match(/[A-Za-z_$][A-Za-z0-9_$]*/g) ?? [])));
2202
2209
  let o = e.routes.map((t) => Ir(e, t));
2203
- X(i, `${Y([`The service routes of \`${e.name}\`: routes whose handler is the service's own code, each called by its Manifest's name.`])}export class ${a} {\n /** Calls any route of the service by its name. */\n readonly routes: ServiceRoutes;\n\n /** @param options - How the service is reached */\n constructor(options?: WowClientOptions) {\n this.routes = new ServiceRoutes(options, { manifest: ${e.typeName}Manifest });\n }\n\n${o.join("\n\n")}\n}`);
2210
+ Z(i, `${X([`The service routes of \`${e.name}\`: routes whose handler is the service's own code, each called by its Manifest's name.`])}export class ${a} {\n /** Calls any route of the service by its name. */\n readonly routes: ServiceRoutes;\n\n /** @param options - How the service is reached */\n constructor(options?: WowClientOptions) {\n this.routes = new ServiceRoutes(options, { manifest: ${e.typeName}Manifest });\n }\n\n${o.join("\n\n")}\n}`);
2204
2211
  }
2205
2212
  function Ir(e, t) {
2206
2213
  let n = t.parameters.filter((e) => e.location === "path"), r = t.parameters.filter((e) => e.location === "query"), i = n.map((e) => `${e.name}: ${e.type}`);
2207
2214
  if (t.requestType !== void 0 && i.push(`body: ${t.requestType}`), r.length > 0) {
2208
- let e = r.map((e) => `readonly ${N(e.name)}${e.required ? "" : "?"}: ${e.type}`).join("; "), t = r.some((e) => e.required);
2215
+ let e = r.map((e) => `readonly ${P(e.name)}${e.required ? "" : "?"}: ${e.type}`).join("; "), t = r.some((e) => e.required);
2209
2216
  i.push(`query${t ? "" : "?"}: { ${e} }`);
2210
2217
  }
2211
2218
  i.push("options?: RequestOptions");
2212
2219
  let a = t.responseType ?? "void", o = [
2213
- ...n.length === 0 ? [] : [`path: { ${n.map((e) => N(e.name)).join(", ")} }`],
2220
+ ...n.length === 0 ? [] : [`path: { ${n.map((e) => P(e.name)).join(", ")} }`],
2214
2221
  ...t.requestType === void 0 ? [] : ["body"],
2215
2222
  ...r.length === 0 ? [] : ["query"]
2216
2223
  ];
2217
- return `${Y([
2224
+ return `${X([
2218
2225
  t.description,
2219
2226
  `\`${t.method} ${t.path}\``,
2220
2227
  t.deprecated ? "@deprecated The service deprecates this route." : void 0
2221
- ], " ")} ${N(t.name)}(${i.join(", ")}): Promise<${a}> {\n return this.routes.call(${P(e.name)}, ${P(t.name)}, { ${o.join(", ")} }, options) as Promise<${a}>;\n }`;
2228
+ ], " ")} ${P(t.name)}(${i.join(", ")}): Promise<${a}> {\n return this.routes.call(${F(e.name)}, ${F(t.name)}, { ${o.join(", ")} }, options) as Promise<${a}>;\n }`;
2222
2229
  }
2223
2230
  function Lr(e, t, n) {
2224
2231
  let r = t.module(`${e.directory}/client.ts`), i = `${e.typeName}Client`;
2225
- r.imports.add(J, ["CommandClient", "WowClientOptions"]), r.imports.add("./manifest.js", [`${e.typeName}Manifest`]);
2232
+ r.imports.add(Y, ["CommandClient", "WowClientOptions"]), r.imports.add("./manifest.js", [`${e.typeName}Manifest`]);
2226
2233
  let a = [], o = [];
2227
2234
  for (let t of e.aggregates) {
2228
- let e = t.typeName, i = (e) => L(r.directoryPath, _(n, t.directory, e)), s = [["commands", `${e}CommandClient`]];
2235
+ let e = t.typeName, i = (e) => R(r.directoryPath, _(n, t.directory, e)), s = [["commands", `${e}CommandClient`]];
2229
2236
  t.queryModels.includes("snapshot") && s.push(["snapshots", `${e}SnapshotQueryClient`]), t.queryModels.includes("events") && s.push(["events", `${e}EventQueryClient`]), s.push(["state", `${e}StateClient`]), r.imports.add(i("commandClient.ts"), [`${e}CommandClient`]), r.imports.add(i("queryClient.ts"), s.slice(1).map(([, e]) => e));
2230
- let c = N(j(t.name));
2231
- a.push(`${Y([`The clients of \`${t.context}.${t.name}\`.`], " ")} readonly ${c}: {\n${s.map(([e, t]) => ` readonly ${e}: ${t};`).join("\n")}\n };`), o.push(` this.${c} = {\n${s.map(([e, t]) => ` ${e}: new ${t}(options),`).join("\n")}\n };`);
2237
+ let c = P(M(t.name));
2238
+ a.push(`${X([`The clients of \`${t.context}.${t.name}\`.`], " ")} readonly ${c}: {\n${s.map(([e, t]) => ` readonly ${e}: ${t};`).join("\n")}\n };`), o.push(` this.${c} = {\n${s.map(([e, t]) => ` ${e}: new ${t}(options),`).join("\n")}\n };`);
2232
2239
  }
2233
- e.routes.length > 0 && (r.imports.add("./routes.js", [`${e.typeName}Routes`]), a.push(`${Y([`The service routes of \`${e.name}\`.`], " ")} readonly routes: ${e.typeName}Routes;`), o.push(` this.routes = new ${e.typeName}Routes(options);`)), X(r, `${Y([e.routes.length === 0 ? `The clients of \`${e.name}\`: its command client, and per aggregate its command, query and state clients.` : `The clients of \`${e.name}\`: its command client, per aggregate its command, query and state clients, and its service routes.`])}export class ${i} {\n /** Sends any command of the service, by its Manifest's routes: \`send\`, \`wait\` and \`stream\`. */\n readonly commands: CommandClient;\n\n${a.join("\n\n")}\n\n /** @param options - How the service is reached */\n constructor(options?: WowClientOptions) {\n this.commands = new CommandClient(options, { manifest: ${e.typeName}Manifest });\n${o.join("\n")}\n }\n}`);
2240
+ e.routes.length > 0 && (r.imports.add("./routes.js", [`${e.typeName}Routes`]), a.push(`${X([`The service routes of \`${e.name}\`.`], " ")} readonly routes: ${e.typeName}Routes;`), o.push(` this.routes = new ${e.typeName}Routes(options);`)), Z(r, `${X([e.routes.length === 0 ? `The clients of \`${e.name}\`: its command client, and per aggregate its command, query and state clients.` : `The clients of \`${e.name}\`: its command client, per aggregate its command, query and state clients, and its service routes.`])}export class ${i} {\n /** Sends any command of the service, by its Manifest's routes: \`send\`, \`wait\` and \`stream\`. */\n readonly commands: CommandClient;\n\n${a.join("\n\n")}\n\n /** @param options - How the service is reached */\n constructor(options?: WowClientOptions) {\n this.commands = new CommandClient(options, { manifest: ${e.typeName}Manifest });\n${o.join("\n")}\n }\n}`);
2234
2241
  }
2235
2242
  function Rr(e) {
2236
- return e === !0 ? "true" : `{ ${Object.entries(e).map(([e, t]) => `${N(e)}: ${Rr(t)}`).join(", ")} }`;
2243
+ return e === !0 ? "true" : `{ ${Object.entries(e).map(([e, t]) => `${P(e)}: ${Rr(t)}`).join(", ")} }`;
2237
2244
  }
2238
2245
  function zr(e) {
2239
2246
  let t = e.textNumbers;
@@ -2243,37 +2250,38 @@ function zr(e) {
2243
2250
  "commands"
2244
2251
  ].flatMap((e) => {
2245
2252
  let n = t[e];
2246
- return n === void 0 ? [] : e === "state" ? [` state: ${Rr(n)},`] : [` ${e}: {\n${Object.entries(n).map(([e, t]) => ` ${N(e)}: ${Rr(t)},`).join("\n")}\n },`];
2253
+ return n === void 0 ? [] : e === "state" ? [` state: ${Rr(n)},`] : [` ${e}: {\n${Object.entries(n).map(([e, t]) => ` ${P(e)}: ${Rr(t)},`).join("\n")}\n },`];
2247
2254
  }).join("\n")}\n },\n`;
2248
2255
  }
2249
2256
  function Br(e, t, n, r, i) {
2250
2257
  let a = n.module(`${e.directory}/aggregate.ts`), o = e.typeName;
2251
- X(a, `${Y([`The aggregate \`${e.context}.${e.name}\`.`, e.description])}export const ${o}Aggregate = {\n context: ${P(t.name)},\n name: ${P(e.name)},\n path: ${P(`/${t.name}/${e.name}`)},\n ownership: ${P(e.ownership)},\n${e.idSource === "assigned" ? "" : ` idSource: ${P(e.idSource)},\n`} snapshot: ${e.snapshot},\n${zr(e)}${Mr(jr(t, e), " ")}} as const;`), X(a, `${Y([`The \`state.*\` paths of \`${e.name}\`'s snapshots a query filters, sorts and projects on.`])}export type ${o}StateField = ${Z(e.stateFields.map(P))};`);
2252
- let s = e.events.map((e) => `CommittedEvent<${P(e.wireName)}, ${e.type}>`);
2253
- a.imports.add(J, s.length > 0 ? ["CommittedEvent", "SystemEvent"] : ["SystemEvent"]), X(a, `${Y([`The events of \`${e.name}\`, named as the server sends them, \`${e.context}.${e.name}.<Event>\` at its current revision (the \`events\` query upgrades older records), and the system events every aggregate has.`])}export type ${o}Event = ${Z([...s, "SystemEvent"])};`), Q(a, i, r, e.events.map((e) => e.type));
2258
+ Z(a, `${X([`The aggregate \`${e.context}.${e.name}\`.`, e.description])}export const ${o}Aggregate = {\n context: ${F(t.name)},\n name: ${F(e.name)},\n path: ${F(`/${t.name}/${e.name}`)},\n ownership: ${F(e.ownership)},\n${e.idSource === "assigned" ? "" : ` idSource: ${F(e.idSource)},\n`} snapshot: ${e.snapshot},\n${zr(e)}${Mr(jr(t, e), " ")}} as const;`), Z(a, `${X([`The \`state.*\` paths of \`${e.name}\`'s snapshots a query filters, sorts and projects on.`])}export type ${o}StateField = ${Q(e.stateFields.map(F))};`);
2259
+ let s = e.events.map((e) => `CommittedEvent<${F(e.wireName)}, ${e.type}>`);
2260
+ a.imports.add(Y, s.length > 0 ? ["CommittedEvent", "SystemEvent"] : ["SystemEvent"]), Z(a, `${X([`The events of \`${e.name}\`, named as the server sends them, \`${e.context}.${e.name}.<Event>\` at its current revision (the \`events\` query upgrades older records), and the system events every aggregate has.`])}export type ${o}Event = ${Q([...s, "SystemEvent"])};`), $(a, i, r, e.events.map((e) => e.type));
2254
2261
  }
2255
2262
  function Vr(e, t) {
2256
2263
  let n = (t === void 0 ? [e.byIdPath, e.unaddressedPath] : [t ? e.unaddressedPath : e.byIdPath]).filter((e) => e !== void 0).map((e) => `\`POST ${e.path}\``).join(", "), r = e.creation === "required" ? "Creates the aggregate." : e.creation === "allowed" ? "Creates the aggregate, or acts on the one that exists." : void 0;
2257
- return Y([
2264
+ return X([
2258
2265
  e.description,
2259
2266
  `\`${e.name}\`${e.mounted ? ", mounted (a transformer finds its aggregate)" : ""}${t === !0 ? ", to the caller's own aggregate, whose id is the caller's owner" : ""}: ${n}.`,
2260
2267
  t === !1 ? "By id, for a caller with no owner; `" + e.ownMethod + "` sends it to the caller's own." : void 0,
2268
+ e.idProperty === void 0 ? void 0 : `Its body names its aggregate: \`${e.idProperty}\`${e.idComputed ? ", which the service computes from the fields given" : ""}.`,
2261
2269
  r,
2262
2270
  e.produces.length > 0 ? `Produces ${e.produces.map((e) => `\`${e}\``).join(", ")}.` : void 0
2263
2271
  ], " ");
2264
2272
  }
2265
2273
  function Hr(e) {
2266
- return `[${e.map((e) => `{ method: ${P(e.method)}, path: ${P(e.path)} }`).join(", ")}]`;
2274
+ return `[${e.map((e) => `{ method: ${F(e.method)}, path: ${F(e.path)} }`).join(", ")}]`;
2267
2275
  }
2268
- function $(e, t, n, r) {
2269
- let i = e.bodyType === "unknown" ? "object" : e.bodyType, a = e.bodyOptional ? `body: ${i} = {}` : `body: ${i}`, o = n ? "stream" : "wait", s = n ? "Promise<CommandResultStream>" : "Promise<CommandResult>", c = r === !0 ? e.ownMethod : e.method, l = n ? `${c}Stream` : c, u = n ? Y([`\`${e.name}\`${r === !0 ? " to the caller's own aggregate" : ""}, answered as one result per hop of its wait (\`text/event-stream\`).`], " ") : Vr(e, r), d = P(`${t.context}.${t.name}.${e.name}`), f = (e) => `{ ...options, command: ${d}, body${e} }`, p = r === void 0 ? e.byIdPath : !r, m = r === void 0 ? e.unaddressedPath : r, h = p && m ? "CreateCommandOptions" : "CommandOptions", g = p && !m ? "id: string, " : "", _ = f(p && !m ? ", id" : "");
2270
- return n ? `${u} ${l}(${g}${a}, options?: ${h}): ${s} {\n return this.client.${o}(${_});\n }` : Ur(u, l, `${g}${a}`, h, _);
2276
+ function Ur(e, t, n, r) {
2277
+ let i = e.bodyType === "unknown" ? "object" : e.bodyType, a = e.idComputed ? `Omit<${i}, ${F(e.idProperty)}>` : i, o = e.bodyOptional ? `body: ${a} = {}` : `body: ${a}`, s = n ? "stream" : "wait", c = n ? "Promise<CommandResultStream>" : "Promise<CommandResult>", l = r === !0 ? e.ownMethod : e.method, u = n ? `${l}Stream` : l, d = n ? X([`\`${e.name}\`${r === !0 ? " to the caller's own aggregate" : ""}, answered as one result per hop of its wait (\`text/event-stream\`).`], " ") : Vr(e, r), f = F(`${t.context}.${t.name}.${e.name}`), p = (e) => `{ ...options, command: ${f}, body${e} }`, m = r === void 0 ? e.byIdPath : !r, h = r === void 0 ? e.unaddressedPath : r, g = m && h ? "CreateCommandOptions" : "CommandOptions", _ = m && !h ? "id: string, " : "", v = p(m && !h ? ", id" : "");
2278
+ return n ? `${d} ${u}(${_}${o}, options?: ${g}): ${c} {\n return this.client.${s}(${v});\n }` : Wr(d, u, `${_}${o}`, g, v);
2271
2279
  }
2272
- function Ur(e, t, n, r, i) {
2280
+ function Wr(e, t, n, r, i) {
2273
2281
  return `${e} ${t}(${n ? `${n}, ` : ""}options?: ${r}): Promise<CommandResult> {\n return this.client.wait(${i});\n }`;
2274
2282
  }
2275
- function Wr(e, t, n, r, i) {
2276
- let a = n.module(`${e.directory}/commandClient.ts`), o = e.typeName, s = e.commands.filter((e) => e.byIdPath || e.unaddressedPath), c = s.flatMap((t) => t.ownMethod === void 0 ? [$(t, e, !1), $(t, e, !0)] : [!1, !0].flatMap((n) => [$(t, e, !1, n), $(t, e, !0, n)])), l = [
2283
+ function Gr(e, t, n, r, i) {
2284
+ let a = n.module(`${e.directory}/commandClient.ts`), o = e.typeName, s = e.commands.filter((e) => e.byIdPath || e.unaddressedPath), c = s.flatMap((t) => t.ownMethod === void 0 ? [Ur(t, e, !1), Ur(t, e, !0)] : [!1, !0].flatMap((n) => [Ur(t, e, !1, n), Ur(t, e, !0, n)])), l = [
2277
2285
  "CommandClient",
2278
2286
  "CommandResult",
2279
2287
  "WowClientOptions"
@@ -2284,32 +2292,32 @@ function Wr(e, t, n, r, i) {
2284
2292
  let d = [];
2285
2293
  for (let t of e.lifecycle) {
2286
2294
  l.push("LifecycleCommands"), t.bodyType && (t.bodyGenerated ? d : l).push(t.bodyType);
2287
- let n = t.bodyType ? `body: ${t.bodyType}` : "", r = (n) => `{ ...options, command: LifecycleCommands.${t.member}, type: { context: ${P(e.context)}, name: ${P(e.name)} }${n ? ", id" : ""}${t.bodyType ? ", body" : ""} }`;
2288
- c.push(Ur(Y([
2295
+ let n = t.bodyType ? `body: ${t.bodyType}` : "", r = (n) => `{ ...options, command: LifecycleCommands.${t.member}, type: { context: ${F(e.context)}, name: ${F(e.name)} }${n ? ", id" : ""}${t.bodyType ? ", body" : ""} }`;
2296
+ c.push(Wr(X([
2289
2297
  t.description,
2290
2298
  `The lifecycle command \`${t.name}\`.`,
2291
2299
  t.ownMethod === void 0 ? void 0 : `By id, for a caller with no owner; \`${t.ownMethod}\` sends it to the caller's own.`
2292
- ], " "), t.method, n ? `id: string, ${n}` : "id: string", "CommandOptions", r(!0))), t.ownMethod !== void 0 && c.push(Ur(Y([t.description, `The lifecycle command \`${t.name}\`, to the caller's own aggregate, whose id is the caller's owner.`], " "), t.ownMethod, n, "CommandOptions", r(!1)));
2300
+ ], " "), t.method, n ? `id: string, ${n}` : "id: string", "CommandOptions", r(!0))), t.ownMethod !== void 0 && c.push(Wr(X([t.description, `The lifecycle command \`${t.name}\`, to the caller's own aggregate, whose id is the caller's owner.`], " "), t.ownMethod, n, "CommandOptions", r(!1)));
2293
2301
  }
2294
2302
  let f = s.filter((e) => e.bodyNumbers);
2295
2303
  f.length > 0 && a.imports.add("./aggregate.js", [`${o}Aggregate`]);
2296
- let p = f.length ? `, bodyNumbers: {\n${f.map((t) => ` ${P(`${e.context}.${e.name}.${t.name}`)}: ${o}Aggregate.textNumbers.commands.${N(t.name) === t.name ? t.name : `[${P(t.name)}]`},`).join("\n")}\n }` : "", m = `${t.typeName}Manifest`;
2297
- a.imports.add(L(a.directoryPath, _(i, t.directory, "manifest.ts")), [m]), a.imports.add(J, [...new Set(l)].sort()), Q(a, i, r, [...s.map((e) => e.bodyType), ...d]), X(a, `${Y([`Sends the commands of \`${e.context}.${e.name}\` by its service's routes (\`${m}\`). Each method answers the result its wait plan ends with, as \`CommandClient.wait\` does: the server's default plan unless the options give one, \`{ wait: WaitPlan.ACCEPTED }\` to answer once it is accepted. A rejected command rejects with a \`CommandRejectedError\`; anything else that did not succeed with a \`WowProblemError\`.`])}export class ${o}CommandClient {\n readonly client: CommandClient;\n\n /** @param options - How the service is reached */\n constructor(options?: WowClientOptions) {\n this.client = new CommandClient(options, { manifest: ${m}${p} });\n }\n\n${c.join("\n\n")}\n}`);
2304
+ let p = f.length ? `, bodyNumbers: {\n${f.map((t) => ` ${F(`${e.context}.${e.name}.${t.name}`)}: ${o}Aggregate.textNumbers.commands.${P(t.name) === t.name ? t.name : `[${F(t.name)}]`},`).join("\n")}\n }` : "", m = `${t.typeName}Manifest`;
2305
+ a.imports.add(R(a.directoryPath, _(i, t.directory, "manifest.ts")), [m]), a.imports.add(Y, [...new Set(l)].sort()), $(a, i, r, [...s.map((e) => e.bodyType), ...d]), Z(a, `${X([`Sends the commands of \`${e.context}.${e.name}\` by its service's routes (\`${m}\`). Each method answers the result its wait plan ends with, as \`CommandClient.wait\` does: the server's default plan unless the options give one, \`{ wait: WaitPlan.ACCEPTED }\` to answer once it is accepted. A rejected command rejects with a \`CommandRejectedError\`; anything else that did not succeed with a \`WowProblemError\`.`])}export class ${o}CommandClient {\n readonly client: CommandClient;\n\n /** @param options - How the service is reached */\n constructor(options?: WowClientOptions) {\n this.client = new CommandClient(options, { manifest: ${m}${p} });\n }\n\n${c.join("\n\n")}\n}`);
2298
2306
  }
2299
- function Gr(e, t, n, r) {
2307
+ function Kr(e, t, n, r) {
2300
2308
  let i = t.module(`${e.directory}/queryClient.ts`), a = e.typeName, o = e.stateType, s = e.idSource === "owner", c = s ? "OwnStateClient" : "StateClient", l = [c, "WowClientOptions"], u = [`${a}Aggregate`, `${a}Event`], d = ` /** @param options - How the service is reached */\n constructor(options?: WowClientOptions) {\n super(${a}Aggregate, options);\n }`;
2301
- e.queryModels.includes("snapshot") && (l.push("SnapshotQueryClient"), u.push(`${a}StateField`), X(i, `${Y([`Queries the snapshots of \`${e.context}.${e.name}\`: \`POST /${e.context}/${e.name}/snapshot/query\`.`])}export class ${a}SnapshotQueryClient extends SnapshotQueryClient<${o}, ${a}StateField> {\n${d}\n}`)), e.queryModels.includes("events") && (l.push("EventQueryClient"), X(i, `${Y([`Queries the event streams of \`${e.context}.${e.name}\`, one record per commit: \`POST /${e.context}/${e.name}/events/query\`.`])}export class ${a}EventQueryClient extends EventQueryClient<${a}Event> {\n${d}\n}`)), X(i, `${Y([s ? `Reads the states of \`${e.context}.${e.name}\`, at a version or a time, and their traces: the caller's own by no id (\`readOwn\`, \`getOwn\`, \`findOwn\`, \`traceOwn\`: \`GET /${e.context}/${e.name}/state\`), and by id for a caller with no owner (\`GET /${e.context}/${e.name}/{id}/state\`).` : `Reads the states of \`${e.context}.${e.name}\`, at a version or a time, and their traces: \`GET /${e.context}/${e.name}/{id}/state\`.`])}export class ${a}StateClient extends ${c}<${o}, ${a}Event> {\n${d}\n}`), i.imports.add(J, l.sort()), i.imports.add("./aggregate.js", u), Q(i, r, n, [o]);
2309
+ e.queryModels.includes("snapshot") && (l.push("SnapshotQueryClient"), u.push(`${a}StateField`), Z(i, `${X([`Queries the snapshots of \`${e.context}.${e.name}\`: \`POST /${e.context}/${e.name}/snapshot/query\`.`])}export class ${a}SnapshotQueryClient extends SnapshotQueryClient<${o}, ${a}StateField> {\n${d}\n}`)), e.queryModels.includes("events") && (l.push("EventQueryClient"), Z(i, `${X([`Queries the event streams of \`${e.context}.${e.name}\`, one record per commit: \`POST /${e.context}/${e.name}/events/query\`.`])}export class ${a}EventQueryClient extends EventQueryClient<${a}Event> {\n${d}\n}`)), Z(i, `${X([s ? `Reads the states of \`${e.context}.${e.name}\`, at a version or a time, and their traces: the caller's own by no id (\`readOwn\`, \`getOwn\`, \`findOwn\`, \`traceOwn\`: \`GET /${e.context}/${e.name}/state\`), and by id for a caller with no owner (\`GET /${e.context}/${e.name}/{id}/state\`).` : `Reads the states of \`${e.context}.${e.name}\`, at a version or a time, and their traces: \`GET /${e.context}/${e.name}/{id}/state\`.`])}export class ${a}StateClient extends ${c}<${o}, ${a}Event> {\n${d}\n}`), i.imports.add(Y, l.sort()), i.imports.add("./aggregate.js", u), $(i, r, n, [o]);
2302
2310
  }
2303
2311
  // src/openapi/document.ts
2304
- function Kr(e) {
2312
+ function qr(e) {
2305
2313
  return {
2306
2314
  openAPI: e,
2307
2315
  components: e.components,
2308
- endpoints: Ge(e.paths, e.components)
2316
+ endpoints: We(e.paths, e.components)
2309
2317
  };
2310
2318
  }
2311
2319
  // src/output/outputStore.ts
2312
- var qr = ".wow-generator.json", Jr = class e {
2320
+ var Jr = ".wow-generator.json", Yr = class e {
2313
2321
  project;
2314
2322
  outputPath;
2315
2323
  outputDir;
@@ -2322,12 +2330,12 @@ var qr = ".wow-generator.json", Jr = class e {
2322
2330
  static open(t, n, r) {
2323
2331
  let i = t.getFileSystem(), a = n;
2324
2332
  n = p(i.getCurrentDirectory(), n);
2325
- let o = d(n, qr), s = /* @__PURE__ */ new Map();
2333
+ let o = d(n, Jr), s = /* @__PURE__ */ new Map();
2326
2334
  if (i.fileExistsSync(o)) {
2327
- let e = Yr(o, i.readFileSync(o));
2335
+ let e = Xr(o, i.readFileSync(o));
2328
2336
  for (let [t, r] of Object.entries(e.files)) {
2329
2337
  let e = p(n, t);
2330
- if ($r(n, e), u(t) || !t.endsWith(".ts") || typeof r != "string" || !/^[a-f0-9]{64}$/.test(r)) throw new v("output", `Invalid generated file entry in ${o}: ${t}`);
2338
+ if (ei(n, e), u(t) || !t.endsWith(".ts") || typeof r != "string" || !/^[a-f0-9]{64}$/.test(r)) throw new y("output", `Invalid generated file entry in ${o}: ${t}`);
2331
2339
  s.set(e, r);
2332
2340
  }
2333
2341
  }
@@ -2339,8 +2347,8 @@ var qr = ".wow-generator.json", Jr = class e {
2339
2347
  return this.written;
2340
2348
  }
2341
2349
  claim(e, t = this.outputPath) {
2342
- let n = ae(t, e);
2343
- $r(t, n);
2350
+ let n = ie(t, e);
2351
+ ei(t, n);
2344
2352
  let r = this.project.getSourceFile(n) ?? this.project.createSourceFile(n, "", { overwrite: !0 }), i = r.getFilePath();
2345
2353
  return this.written.has(i) || (r.removeText(), this.written.add(i)), r;
2346
2354
  }
@@ -2351,64 +2359,64 @@ var qr = ".wow-generator.json", Jr = class e {
2351
2359
  async commit(e) {
2352
2360
  e?.throwIfAborted();
2353
2361
  let t = this.project.getFileSystem(), n = new Set([...this.written].map((e) => e.toLowerCase()));
2354
- for (let e of this.stale) !this.written.has(e) && n.has(e.toLowerCase()) && this.isUnchanged(e, this.previous.get(e)) && (await Qr("delete", e, () => t.delete(e)), this.stale.delete(e));
2362
+ for (let e of this.stale) !this.written.has(e) && n.has(e.toLowerCase()) && this.isUnchanged(e, this.previous.get(e)) && (await $r("delete", e, () => t.delete(e)), this.stale.delete(e));
2355
2363
  let r = [...this.written].sort().map((e) => this.project.getSourceFileOrThrow(e));
2356
2364
  (await Promise.allSettled(r.map((e) => e.save()))).forEach((e, t) => {
2357
- if (e.status === "rejected") throw Zr("write", r[t].getFilePath(), e.reason);
2365
+ if (e.status === "rejected") throw Qr("write", r[t].getFilePath(), e.reason);
2358
2366
  }), e?.throwIfAborted();
2359
- for (let e of this.stale) !this.written.has(e) && this.isUnchanged(e, this.previous.get(e)) && await Qr("delete", e, () => t.delete(e));
2360
- let i = d(this.outputDir, qr), a = JSON.stringify({
2367
+ for (let e of this.stale) !this.written.has(e) && this.isUnchanged(e, this.previous.get(e)) && await $r("delete", e, () => t.delete(e));
2368
+ let i = d(this.outputDir, Jr), a = JSON.stringify({
2361
2369
  version: 1,
2362
- files: Object.fromEntries(r.map((e) => [f(this.outputDir, e.getFilePath()).split(m).join("/"), Xr(t.readFileSync(e.getFilePath()))]))
2370
+ files: Object.fromEntries(r.map((e) => [f(this.outputDir, e.getFilePath()).split(m).join("/"), Zr(t.readFileSync(e.getFilePath()))]))
2363
2371
  }, null, 2) + "\n";
2364
- await Qr("write", i, async () => {
2372
+ await $r("write", i, async () => {
2365
2373
  t.mkdirSync(this.outputDir), await t.writeFile(i, a);
2366
2374
  });
2367
2375
  }
2368
2376
  isUnchanged(e, t) {
2369
2377
  let n = this.project.getFileSystem();
2370
- return n.fileExistsSync(e) ? ($r(n.realpathSync(this.outputDir), n.realpathSync(e)), Xr(n.readFileSync(e)) === t) : !1;
2378
+ return n.fileExistsSync(e) ? (ei(n.realpathSync(this.outputDir), n.realpathSync(e)), Zr(n.readFileSync(e)) === t) : !1;
2371
2379
  }
2372
2380
  };
2373
- function Yr(e, t) {
2381
+ function Xr(e, t) {
2374
2382
  let n = "delete it; without it this run cannot remove the stale files of the last run", r;
2375
2383
  try {
2376
2384
  r = JSON.parse(t);
2377
2385
  } catch (t) {
2378
- throw new v("output", `Cannot parse the generation manifest ${e}: ${y(t)}. Resolve the merge conflict in it if it has one, or ${n}.`, { cause: t });
2386
+ throw new y("output", `Cannot parse the generation manifest ${e}: ${b(t)}. Resolve the merge conflict in it if it has one, or ${n}.`, { cause: t });
2379
2387
  }
2380
2388
  let i = r?.version;
2381
- if (typeof i == "number" && Number.isInteger(i) && i > 1) throw new v("output", `The generation manifest ${e} was written by a newer wow-generator (manifest version ${i}); this one reads version 1. Upgrade wow-generator.`);
2382
- if (i !== 1 || !r.files || typeof r.files != "object" || Array.isArray(r.files)) throw new v("output", `Invalid generation manifest ${e}: expected "version": 1 and a "files" object. Restore it from version control, or ${n}.`);
2389
+ if (typeof i == "number" && Number.isInteger(i) && i > 1) throw new y("output", `The generation manifest ${e} was written by a newer wow-generator (manifest version ${i}); this one reads version 1. Upgrade wow-generator.`);
2390
+ if (i !== 1 || !r.files || typeof r.files != "object" || Array.isArray(r.files)) throw new y("output", `Invalid generation manifest ${e}: expected "version": 1 and a "files" object. Restore it from version control, or ${n}.`);
2383
2391
  return r;
2384
2392
  }
2385
- function Xr(e) {
2393
+ function Zr(e) {
2386
2394
  if (!l.sys.createSHA256Hash) throw Error("SHA-256 hashing is unavailable in this environment.");
2387
2395
  return l.sys.createSHA256Hash(e);
2388
2396
  }
2389
- function Zr(e, t, n) {
2390
- return n instanceof v ? n : new v("output", `Cannot ${e} ${t}: ${y(n)}`, { cause: n });
2397
+ function Qr(e, t, n) {
2398
+ return n instanceof y ? n : new y("output", `Cannot ${e} ${t}: ${b(n)}`, { cause: n });
2391
2399
  }
2392
- async function Qr(e, t, n) {
2400
+ async function $r(e, t, n) {
2393
2401
  try {
2394
2402
  await n();
2395
2403
  } catch (n) {
2396
- throw Zr(e, t, n);
2404
+ throw Qr(e, t, n);
2397
2405
  }
2398
2406
  }
2399
- function $r(e, t) {
2407
+ function ei(e, t) {
2400
2408
  let n = t.split("/").join(m), r = p(e), i = p(n), a = f(r, i);
2401
- if (a === "" || a.startsWith("..") || u(a)) throw new v("output", `Path traversal detected: "${t}" resolves outside the output directory "${e}".`);
2409
+ if (a === "" || a.startsWith("..") || u(a)) throw new y("output", `Path traversal detected: "${t}" resolves outside the output directory "${e}".`);
2402
2410
  }
2403
2411
  // src/pipeline/seams.ts
2404
- var ei = Symbol("project"), ti = Symbol("signal"), ni = class {
2412
+ var ti = Symbol("project"), ni = Symbol("signal"), ri = class {
2405
2413
  options;
2406
2414
  project;
2407
2415
  logger;
2408
2416
  signal;
2409
2417
  output;
2410
2418
  constructor(e) {
2411
- this.options = e, this.logger = e.logger ?? new re(), this.signal = e[ti], this.project = e[ei] ?? ri(e.tsConfigFilePath), this.project.manipulationSettings.set({
2419
+ this.options = e, this.logger = e.logger ?? new ne(), this.signal = e[ni], this.project = e[ti] ?? ii(e.tsConfigFilePath), this.project.manipulationSettings.set({
2412
2420
  indentationText: t.TwoSpaces,
2413
2421
  quoteKind: i.Single,
2414
2422
  useTrailingCommas: !0
@@ -2423,57 +2431,57 @@ var ei = Symbol("project"), ti = Symbol("signal"), ni = class {
2423
2431
  headers: n.headers,
2424
2432
  timeoutMs: n.timeoutMs,
2425
2433
  signal: t
2426
- }, o = await Jn(n.configPath, e, a);
2434
+ }, o = await qn(n.configPath, e, a);
2427
2435
  i(o.warnings), t?.throwIfAborted(), e.debug("Parsing the input document");
2428
- let s = await Wn(n.inputPath, a);
2429
- if (t?.throwIfAborted(), or(s)) return this.generateFromManifest(sr(s, n.inputPath), o.origin, i, () => r);
2430
- let c = Gn(s, n.inputPath);
2436
+ let s = await Un(n.inputPath, a);
2437
+ if (t?.throwIfAborted(), ar(s)) return this.generateFromManifest(or(s, n.inputPath), o.origin, i, () => r);
2438
+ let c = Wn(s, n.inputPath);
2431
2439
  e.debug("OpenAPI specification parsed successfully");
2432
- let l = le(c);
2433
- if (l.length > 0) throw new v("specification", `${n.inputPath} has ${l.length} $ref(s) that point at nothing: ${l.slice(0, 10).map(({ ref: e, location: t }) => `${e} (at ${t})`).join(", ")}${l.length > 10 ? ", …" : ""}`);
2434
- let u = Kr(c), d = Jr.open(this.project, n.outputDir, this.output);
2440
+ let l = ce(c);
2441
+ if (l.length > 0) throw new y("specification", `${n.inputPath} has ${l.length} $ref(s) that point at nothing: ${l.slice(0, 10).map(({ ref: e, location: t }) => `${e} (at ${t})`).join(", ")}${l.length > 10 ? ", …" : ""}`);
2442
+ let u = qr(c), d = Yr.open(this.project, n.outputDir, this.output);
2435
2443
  this.output = d, e.debug("Analysing the document");
2436
- let f = vt(u, o.config);
2444
+ let f = _t(u, o.config);
2437
2445
  i(f.warnings), e.debug("Writing generated modules");
2438
- let p = new xt((e) => d.claim(e));
2439
- wn(f.model, {
2446
+ let p = new bt((e) => d.claim(e));
2447
+ Cn(f.model, {
2440
2448
  modules: p,
2441
2449
  outputDir: n.outputDir,
2442
- types: bn(u.components),
2450
+ types: yn(u.components),
2443
2451
  schemaDocs: n.schemaDocs ?? "summary"
2444
2452
  }), p.build(), e.debug("Generated modules written"), d.forgetStale();
2445
2453
  let m = this.project.getDirectory(n.outputDir);
2446
- return m ? (e.debug("Generating index files"), i(Tn(m, (e) => d.claim("index.ts", e))), e.debug("Optimizing source files"), Ln(m.getDescendantSourceFiles().filter((e) => d.files.has(e.getFilePath())), e), e.debug("Source files optimized successfully")) : e.debug("Output directory not found."), e.debug("Saving project to disk"), await d.commit(t), e.debug("Code generation completed successfully"), {
2454
+ return m ? (e.debug("Generating index files"), i(wn(m, (e) => d.claim("index.ts", e))), e.debug("Optimizing source files"), In(m.getDescendantSourceFiles().filter((e) => d.files.has(e.getFilePath())), e), e.debug("Source files optimized successfully")) : e.debug("Output directory not found."), e.debug("Saving project to disk"), await d.commit(t), e.debug("Code generation completed successfully"), {
2447
2455
  files: [...d.files].sort(),
2448
2456
  configPath: o.origin,
2449
2457
  warnings: r
2450
2458
  };
2451
2459
  }
2452
2460
  async generateFromManifest(e, t, n, r) {
2453
- let { logger: i, signal: a, options: o } = this, s = Jr.open(this.project, o.outputDir, this.output);
2461
+ let { logger: i, signal: a, options: o } = this, s = Yr.open(this.project, o.outputDir, this.output);
2454
2462
  this.output = s, i.debug("Analysing the Manifest");
2455
2463
  let c = xr(e);
2456
2464
  n(c.warnings);
2457
- let l = new xt((e) => s.claim(e));
2465
+ let l = new bt((e) => s.claim(e));
2458
2466
  kr(c.model, l, o.outputDir), l.build(), s.forgetStale();
2459
2467
  let u = this.project.getDirectory(o.outputDir);
2460
- return u && (n(Tn(u, (e) => s.claim("index.ts", e))), Ln(u.getDescendantSourceFiles().filter((e) => s.files.has(e.getFilePath())), i)), await s.commit(a), i.debug("Code generation from the Manifest completed successfully"), {
2468
+ return u && (n(wn(u, (e) => s.claim("index.ts", e))), In(u.getDescendantSourceFiles().filter((e) => s.files.has(e.getFilePath())), i)), await s.commit(a), i.debug("Code generation from the Manifest completed successfully"), {
2461
2469
  files: [...s.files].sort(),
2462
2470
  configPath: t,
2463
2471
  warnings: r()
2464
2472
  };
2465
2473
  }
2466
2474
  };
2467
- function ri(e) {
2475
+ function ii(e) {
2468
2476
  try {
2469
2477
  return new r({
2470
2478
  tsConfigFilePath: e,
2471
2479
  skipAddingFilesFromTsConfig: !0
2472
2480
  });
2473
2481
  } catch (t) {
2474
- throw new v("configuration", `Cannot read the TypeScript configuration ${e}: ${y(t)}`, { cause: t });
2482
+ throw new y("configuration", `Cannot read the TypeScript configuration ${e}: ${b(t)}`, { cause: t });
2475
2483
  }
2476
2484
  }
2477
- export { ie as a, ee as c, re as i, ti as n, te as o, Rn as r, v as s, ni as t };
2485
+ export { re as a, v as c, ne as i, ni as n, ee as o, Ln as r, y as s, ri as t };
2478
2486
 
2479
- //# sourceMappingURL=codeGenerator-Bouc_Ad8.js.map
2487
+ //# sourceMappingURL=codeGenerator-Cxlr_VOh.js.map