@ahoo-wang/wow-generator 9.6.0 → 9.6.2

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.
@@ -3,7 +3,7 @@ import { isAbsolute as u, join as d, relative as f, resolve as p, sep as m } fro
3
3
  import { parse as ee } from "yaml";
4
4
  import { readFile as te } from "fs";
5
5
  //#region src/api/configuration.ts
6
- var h = "./wow-generator.config.json", ne = {
6
+ var h = "./wow-generator.config.json", g = {
7
7
  success: 0,
8
8
  internal: 1,
9
9
  input: 2,
@@ -11,28 +11,28 @@ var h = "./wow-generator.config.json", ne = {
11
11
  specification: 4,
12
12
  output: 5,
13
13
  interrupted: 130
14
- }, g = class extends Error {
14
+ }, _ = class extends Error {
15
15
  kind;
16
16
  constructor(e, t, n) {
17
17
  super(t, n), this.kind = e, this.name = "GeneratorError";
18
18
  }
19
19
  get exitCode() {
20
- return ne[this.kind];
20
+ return g[this.kind];
21
21
  }
22
22
  };
23
- function _(e) {
23
+ function v(e) {
24
24
  return e instanceof Error ? e.message : String(e);
25
25
  }
26
26
  //#endregion
27
27
  //#region src/api/logger.ts
28
- function re() {
28
+ function ne() {
29
29
  return !!process.stdout?.isTTY && !process.env.NO_COLOR;
30
30
  }
31
- var ie = class {
31
+ var re = class {
32
32
  level;
33
33
  decorate;
34
34
  constructor(e = {}) {
35
- this.level = e.level ?? "normal", this.decorate = e.decorate ?? re();
35
+ this.level = e.level ?? "normal", this.decorate = e.decorate ?? ne();
36
36
  }
37
37
  format(e, t, n) {
38
38
  let r = this.decorate ? `${e} ` : t ? `${t}: ` : "";
@@ -50,36 +50,36 @@ var ie = class {
50
50
  error(e, ...t) {
51
51
  console.error(this.format("❌", "error", e), ...t);
52
52
  }
53
- }, ae = class {
53
+ }, ie = class {
54
54
  debug() {}
55
55
  info() {}
56
56
  warn() {}
57
57
  error() {}
58
- }, oe = /[^\p{L}\p{N}$]+/u, se = /* @__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("."));
59
- function v(e) {
60
- return /^[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*$/u.test(e) && !se.has(e);
58
+ }, ae = /[^\p{L}\p{N}$]+/u, oe = /* @__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("."));
59
+ function y(e) {
60
+ return /^[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*$/u.test(e) && !oe.has(e);
61
61
  }
62
- function ce(e) {
62
+ function se(e) {
63
63
  return /^\p{N}/u.test(e) ? `_${e}` : e;
64
64
  }
65
+ function ce(e) {
66
+ if (y(e)) return e;
67
+ let t = se(b(e) || "_");
68
+ return oe.has(t) ? `${t}_` : t;
69
+ }
65
70
  function le(e) {
66
- if (v(e)) return e;
67
- let t = ce(y(e) || "_");
68
- return se.has(t) ? `${t}_` : t;
71
+ return /^\p{Lu}[\p{L}\p{N}$]*$/u.test(e) && y(e);
69
72
  }
70
73
  function ue(e) {
71
- return /^\p{Lu}[\p{L}\p{N}$]*$/u.test(e) && v(e);
74
+ return se((Array.isArray(e) ? e : [e]).map((e) => le(e) ? e : me(e)).join("") || "_");
72
75
  }
73
76
  function de(e) {
74
- return ce((Array.isArray(e) ? e : [e]).map((e) => ue(e) ? e : he(e)).join("") || "_");
77
+ return e.split(ae);
75
78
  }
76
79
  function fe(e) {
77
- return e.split(oe);
80
+ return Array.isArray(e) ? e.flatMap((e) => pe(de(e))) : pe(de(e));
78
81
  }
79
82
  function pe(e) {
80
- return Array.isArray(e) ? e.flatMap((e) => me(fe(e))) : me(fe(e));
81
- }
82
- function me(e) {
83
83
  return e.flatMap((e) => {
84
84
  if (e.length === 0) return [];
85
85
  let t = [], n = "";
@@ -90,40 +90,40 @@ function me(e) {
90
90
  return n && t.push(n), t;
91
91
  });
92
92
  }
93
- function he(e) {
94
- return e === "" || e.length === 0 ? "" : pe(e).filter((e) => e.length > 0).map((e) => {
93
+ function me(e) {
94
+ return e === "" || e.length === 0 ? "" : fe(e).filter((e) => e.length > 0).map((e) => {
95
95
  let t = e.charAt(0), n = e.slice(1);
96
96
  return (/[a-zA-Z]/.test(t) ? t.toUpperCase() : t) + n.toLowerCase();
97
97
  }).join("");
98
98
  }
99
- function y(e) {
100
- let t = he(e);
99
+ function b(e) {
100
+ let t = me(e);
101
101
  return t.charAt(0).toLowerCase() + t.slice(1);
102
102
  }
103
- function ge(e) {
104
- return e === "" || Array.isArray(e) && e.length === 0 ? "" : pe(e).filter((e) => e.length > 0).map((e) => e.toUpperCase()).join("_");
103
+ function he(e) {
104
+ return e === "" || Array.isArray(e) && e.length === 0 ? "" : fe(e).filter((e) => e.length > 0).map((e) => e.toUpperCase()).join("_");
105
105
  }
106
- function b(e) {
107
- return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e) ? e : x(e);
106
+ function x(e) {
107
+ return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e) ? e : S(e);
108
108
  }
109
- function _e(e) {
110
- return /^\d+$/.test(e) ? `NUM_${e}` : ge(e) || e;
109
+ function ge(e) {
110
+ return /^\d+$/.test(e) ? `NUM_${e}` : he(e) || e;
111
111
  }
112
- function x(e) {
112
+ function S(e) {
113
113
  return `'${JSON.stringify(e).slice(1, -1).replace(/\\"/g, "\"").replace(/'/g, "\\'")}'`;
114
114
  }
115
115
  //#endregion
116
116
  //#region src/naming/order.ts
117
- var ve = new Intl.Collator("en-US");
118
- function S(e, t) {
119
- return ve.compare(e, t);
117
+ var _e = new Intl.Collator("en-US");
118
+ function C(e, t) {
119
+ return _e.compare(e, t);
120
120
  }
121
121
  //#endregion
122
122
  //#region src/openapi/references.ts
123
- function C(e) {
123
+ function w(e) {
124
124
  return !!(e && typeof e == "object" && "$ref" in e);
125
125
  }
126
- function ye(e, t) {
126
+ function ve(e, t) {
127
127
  let n = t.slice(1);
128
128
  try {
129
129
  n = decodeURIComponent(n);
@@ -138,7 +138,7 @@ function ye(e, t) {
138
138
  }
139
139
  return r;
140
140
  }
141
- function be(e) {
141
+ function ye(e) {
142
142
  let t = [], n = /* @__PURE__ */ new Set(), r = (i, a) => {
143
143
  if (typeof i != "object" || !i || n.has(i)) return;
144
144
  if (n.add(i), Array.isArray(i)) {
@@ -146,7 +146,7 @@ function be(e) {
146
146
  return;
147
147
  }
148
148
  let o = i.$ref;
149
- typeof o == "string" && o.startsWith("#/components/") && ye(e, o) === void 0 && t.push({
149
+ typeof o == "string" && o.startsWith("#/components/") && ve(e, o) === void 0 && t.push({
150
150
  ref: o,
151
151
  location: a || "/"
152
152
  });
@@ -156,127 +156,127 @@ function be(e) {
156
156
  }
157
157
  //#endregion
158
158
  //#region src/openapi/components.ts
159
- var w = "#/components/", xe = `${w}parameters/`, Se = `${w}requestBodies/`, T = `${w}responses/`, Ce = `${w}schemas/`;
160
- function we(e) {
159
+ var T = "#/components/", be = `${T}parameters/`, xe = `${T}requestBodies/`, E = `${T}responses/`, Se = `${T}schemas/`;
160
+ function D(e) {
161
161
  return e.$ref.split("/").pop();
162
162
  }
163
- function E(e, t, n) {
163
+ function O(e, t, n) {
164
164
  let r = /* @__PURE__ */ new Set(), i = e;
165
- for (; C(i);) {
165
+ for (; w(i);) {
166
166
  if (!i.$ref.startsWith(n)) return;
167
- if (r.has(i.$ref)) throw new g("specification", `Cyclic component reference: ${i.$ref}`);
167
+ if (r.has(i.$ref)) throw new _("specification", `Cyclic component reference: ${i.$ref}`);
168
168
  r.add(i.$ref), i = t?.[i.$ref.slice(n.length)];
169
169
  }
170
170
  return i;
171
171
  }
172
- function D(e, t) {
173
- return E(e, t.schemas, Ce);
172
+ function k(e, t) {
173
+ return O(e, t.schemas, Se);
174
174
  }
175
- function Te(e, t) {
176
- return E(e, t.responses, T);
175
+ function Ce(e, t) {
176
+ return O(e, t.responses, E);
177
177
  }
178
- function Ee(e, t) {
179
- return E(e, t.requestBodies, Se);
178
+ function we(e, t) {
179
+ return O(e, t.requestBodies, xe);
180
180
  }
181
- function De(e, t) {
182
- return E(e, t.parameters, xe);
181
+ function Te(e, t) {
182
+ return O(e, t.parameters, be);
183
183
  }
184
- function O(e, t) {
184
+ function A(e, t) {
185
185
  return {
186
- key: we(e),
187
- schema: D(e, t)
186
+ key: D(e),
187
+ schema: k(e, t)
188
188
  };
189
189
  }
190
190
  //#endregion
191
191
  //#region src/openapi/responses.ts
192
- var k = "application/json", Oe = "text/event-stream";
193
- function A(e) {
192
+ var j = "application/json", Ee = "text/event-stream";
193
+ function De(e) {
194
194
  return e.split(";")[0].trim().toLowerCase();
195
195
  }
196
- function ke(e) {
197
- let t = A(e);
196
+ function Oe(e) {
197
+ let t = De(e);
198
198
  return t === "application/json" || /^application\/[^/]+\+json$/.test(t);
199
199
  }
200
- function Ae(e) {
201
- let t = A(e);
200
+ function ke(e) {
201
+ let t = De(e);
202
202
  return t.startsWith("text/") && t !== "text/event-stream";
203
203
  }
204
- function j(e, t, n = (e) => A(e) === t) {
204
+ function M(e, t, n = (e) => De(e) === t) {
205
205
  if (!e) return;
206
206
  if (e[t]) return e[t];
207
207
  let r = Object.keys(e).find(n);
208
208
  return r === void 0 ? void 0 : e[r];
209
209
  }
210
- function je(e, t) {
211
- if (t && !C(t)) return j(t.content, e)?.schema;
210
+ function Ae(e, t) {
211
+ if (t && !w(t)) return M(t.content, e)?.schema;
212
+ }
213
+ function je(e) {
214
+ if (e && !w(e)) return M(e.content, j, Oe)?.schema;
212
215
  }
213
216
  function Me(e) {
214
- if (e && !C(e)) return j(e.content, k, ke)?.schema;
217
+ return Ae(Ee, e);
215
218
  }
216
219
  function Ne(e) {
217
- return je(Oe, e);
220
+ return Ae("*/*", e);
218
221
  }
219
222
  function Pe(e) {
220
- return je("*/*", e);
221
- }
222
- function Fe(e) {
223
- return !e || C(e) ? !1 : Object.keys(e.content ?? {}).some(Ae);
223
+ return !e || w(e) ? !1 : Object.keys(e.content ?? {}).some(ke);
224
224
  }
225
225
  //#endregion
226
226
  //#region src/openapi/schemas.ts
227
- var Ie = [
227
+ var Fe = [
228
228
  "string",
229
229
  "number",
230
230
  "integer",
231
231
  "boolean",
232
232
  "null"
233
233
  ];
234
- function Le(e) {
235
- return Array.isArray(e) ? !0 : Ie.includes(e);
234
+ function Ie(e) {
235
+ return Array.isArray(e) ? !0 : Fe.includes(e);
236
236
  }
237
- function M(e) {
237
+ function N(e) {
238
238
  return Array.isArray(e.enum) && e.enum.length > 0;
239
239
  }
240
- var Re = "x-enum-text";
241
- function ze(e) {
242
- return e[Re];
240
+ var Le = "x-enum-text";
241
+ function Re(e) {
242
+ return e[Le];
243
243
  }
244
- function Be(e) {
244
+ function ze(e) {
245
245
  return e.type === "object" && !!e.properties;
246
246
  }
247
- function Ve(e) {
247
+ function Be(e) {
248
248
  return e.type === "array" && !!e.items;
249
249
  }
250
- function He(e) {
250
+ function Ve(e) {
251
251
  return Array.isArray(e.anyOf) && e.anyOf.length > 0;
252
252
  }
253
- function Ue(e) {
253
+ function He(e) {
254
254
  return Array.isArray(e.oneOf) && e.oneOf.length > 0;
255
255
  }
256
- function We(e) {
256
+ function Ue(e) {
257
257
  return Array.isArray(e.allOf) && e.allOf.length > 0;
258
258
  }
259
- function N(e) {
260
- return He(e) || Ue(e) || We(e);
259
+ function P(e) {
260
+ return Ve(e) || He(e) || Ue(e);
261
261
  }
262
- function Ge(e) {
262
+ function We(e) {
263
263
  return e.includes("|") || e.includes("&") ? `(${e})[]` : `${e}[]`;
264
264
  }
265
- function Ke(e) {
265
+ function Ge(e) {
266
266
  return e.type === "object" && !e.properties && e.additionalProperties !== void 0;
267
267
  }
268
- var qe = "x-map-key-schema";
269
- function Je(e) {
270
- return e[qe];
268
+ var Ke = "x-map-key-schema";
269
+ function F(e) {
270
+ return e[Ke];
271
271
  }
272
- function Ye(e) {
272
+ function qe(e) {
273
273
  return e.type === "object" ? !e.properties || Object.keys(e.properties).length === 0 : !1;
274
274
  }
275
- function Xe(e) {
275
+ function Je(e) {
276
276
  return e.readOnly === !0;
277
277
  }
278
- function P(e) {
279
- if (Array.isArray(e)) return e.map((e) => P(e)).join(" | ");
278
+ function I(e) {
279
+ if (Array.isArray(e)) return e.map((e) => I(e)).join(" | ");
280
280
  switch (e) {
281
281
  case "string": return "string";
282
282
  case "number":
@@ -286,11 +286,11 @@ function P(e) {
286
286
  default: return "any";
287
287
  }
288
288
  }
289
- function Ze(e, t) {
289
+ function Ye(e, t) {
290
290
  let n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = !1, o = (e) => {
291
291
  if (!(!e || i.has(e) || a)) {
292
- if (i.add(e), C(e)) {
293
- o(t && D(e, t));
292
+ if (i.add(e), w(e)) {
293
+ o(t && k(e, t));
294
294
  return;
295
295
  }
296
296
  if (e.nullable || Array.isArray(e.type)) {
@@ -306,32 +306,32 @@ function Ze(e, t) {
306
306
  }
307
307
  //#endregion
308
308
  //#region src/openapi/operations.ts
309
- function Qe(e, t) {
310
- return e.operation.operationId && t.operation.operationId ? S(e.operation.operationId, t.operation.operationId) : e.path && t.path ? S(e.path, t.path) : e.method && t.method ? S(e.method, t.method) : 0;
309
+ function Xe(e, t) {
310
+ return e.operation.operationId && t.operation.operationId ? C(e.operation.operationId, t.operation.operationId) : e.path && t.path ? C(e.path, t.path) : e.method && t.method ? C(e.method, t.method) : 0;
311
311
  }
312
- function $e(e, t, n) {
312
+ function Ze(e, t, n) {
313
313
  let r = /* @__PURE__ */ new Map();
314
314
  for (let i of [...e, ...t]) {
315
- let e = C(i) ? n && De(i, n) : i, t = e ? `${e.in}:${e.name}` : i.$ref;
315
+ let e = w(i) ? n && Te(i, n) : i, t = e ? `${e.in}:${e.name}` : i.$ref;
316
316
  r.set(t, i);
317
317
  }
318
318
  return [...r.values()];
319
319
  }
320
- function et(e, t) {
320
+ function Qe(e, t) {
321
321
  let n = [];
322
- for (let [r, i] of Object.entries(e)) tt(i).forEach((e) => {
322
+ for (let [r, i] of Object.entries(e)) $e(i).forEach((e) => {
323
323
  n.push({
324
324
  method: e.method,
325
325
  operation: i.parameters?.length ? {
326
326
  ...e.operation,
327
- parameters: $e(i.parameters, e.operation.parameters ?? [], t)
327
+ parameters: Ze(i.parameters, e.operation.parameters ?? [], t)
328
328
  } : e.operation,
329
329
  path: r
330
330
  });
331
331
  });
332
- return n.sort(Qe);
332
+ return n.sort(Xe);
333
333
  }
334
- function tt(e) {
334
+ function $e(e) {
335
335
  return [
336
336
  {
337
337
  method: "get",
@@ -367,60 +367,60 @@ function tt(e) {
367
367
  }
368
368
  ].filter(({ operation: e }) => e !== void 0);
369
369
  }
370
- function nt(e) {
370
+ function et(e) {
371
371
  let t = Object.keys(e.responses ?? {});
372
372
  if (t.includes("200")) return "200";
373
373
  let n = t.filter((e) => /^2\d\d$/.test(e)).sort();
374
374
  return n.length > 0 ? n[0] : t.find((e) => e.toUpperCase() === "2XX");
375
375
  }
376
- function F(e, t) {
377
- let n = nt(e), r = n ? e.responses[n] : void 0;
378
- return t && C(r) ? Te(r, t) : r;
376
+ function tt(e, t) {
377
+ let n = et(e), r = n ? e.responses[n] : void 0;
378
+ return t && w(r) ? Ce(r, t) : r;
379
+ }
380
+ function nt(e, t) {
381
+ return je(tt(e, t));
379
382
  }
380
383
  function rt(e, t) {
381
- return Me(F(e, t));
384
+ return (e.parameters ?? []).map((e) => w(e) ? Te(e, t) : e).filter((e) => e !== void 0);
382
385
  }
383
386
  function it(e, t) {
384
- return (e.parameters ?? []).map((e) => C(e) ? De(e, t) : e).filter((e) => e !== void 0);
387
+ return e.parameters ? e.parameters.map((e) => w(e) ? Te(e, t) : e).filter((e) => e?.in === "path") : [];
385
388
  }
386
389
  function at(e, t) {
387
- return e.parameters ? e.parameters.map((e) => C(e) ? De(e, t) : e).filter((e) => e?.in === "path") : [];
388
- }
389
- function ot(e, t) {
390
390
  let n = (t) => {
391
391
  let n = e.indexOf(`{${t.name}}`);
392
392
  return n < 0 ? 2 ** 53 - 1 : n;
393
393
  };
394
394
  return [...t].sort((e, t) => n(e) - n(t));
395
395
  }
396
- var st = "string";
397
- function ct(e) {
398
- return !e.schema || C(e.schema) || !e.schema.type || !Le(e.schema.type) ? st : P(e.schema.type);
396
+ var ot = "string";
397
+ function st(e) {
398
+ return !e.schema || w(e.schema) || !e.schema.type || !Ie(e.schema.type) ? ot : I(e.schema.type);
399
399
  }
400
400
  //#endregion
401
401
  //#region src/wow/conventions.ts
402
- var lt = "8.10", ut = "x-wow-context-alias";
403
- function dt(e) {
404
- return e.info[ut];
402
+ var ct = "8.10", lt = "x-wow-context-alias";
403
+ function ut(e) {
404
+ return e.info[lt];
405
405
  }
406
- function ft(e) {
406
+ function dt(e) {
407
407
  let t = e.split(".");
408
408
  return t.length != 2 || t[0].length === 0 || t[1].length === 0 ? null : t;
409
409
  }
410
- function pt(e) {
411
- let t = ft(e.name);
410
+ function ft(e) {
411
+ let t = dt(e.name);
412
412
  return t ? {
413
413
  tag: e,
414
414
  contextAlias: t[0],
415
415
  aggregateName: t[1]
416
416
  } : null;
417
417
  }
418
- function mt(e) {
418
+ function pt(e) {
419
419
  if (!e) return null;
420
420
  let t = e.split(".");
421
421
  return t.length == 3 ? t[2] : null;
422
422
  }
423
- var ht = ".snapshot_state.single", gt = ".snapshot.count", _t = "x-wow-query-fields", vt = /^(?:\/tenant\/\{tenantId\})?(?:\/owner\/\{ownerId\})?\/(.+?)\/snapshot(?:\/|$)/, yt = [
423
+ var mt = ".snapshot_state.single", ht = ".snapshot.count", gt = "x-wow-query-fields", _t = /^(?:\/tenant\/\{tenantId\})?(?:\/owner\/\{ownerId\})?\/(.+?)\/snapshot(?:\/|$)/, vt = [
424
424
  "MaterializedSnapshot",
425
425
  "MaterializedSnapshotPagedList",
426
426
  "MaterializedSnapshotCursorPage",
@@ -430,19 +430,19 @@ var ht = ".snapshot_state.single", gt = ".snapshot.count", _t = "x-wow-query-fie
430
430
  "Snapshot",
431
431
  "StateEvent"
432
432
  ];
433
- function bt(e) {
434
- return yt.map((t) => e + t);
433
+ function yt(e) {
434
+ return vt.map((t) => e + t);
435
435
  }
436
- function xt(e, t, n) {
436
+ function bt(e, t, n) {
437
437
  return e !== "wow.api.query.PagedList" && e.startsWith("wow.api.query.") && e.endsWith("PagedList") || e.startsWith("wow.api.query.Operator") && e.endsWith("Map") ? !1 : e.startsWith("wow.") || e.endsWith("AggregatedCondition") || e.endsWith("AggregatedDomainEventStream") || e.endsWith("AggregatedDomainEventStreamPagedList") || e.endsWith("AggregatedDomainEventStreamCursorPage") || e.endsWith("AggregatedDomainEventStreamServerSentEventNonNullData") || e.endsWith("AggregatedListQuery") || e.endsWith("AggregatedPagedQuery") || e.endsWith("AggregatedSingleQuery") ? !0 : n.has(t());
438
438
  }
439
- var I = "@ahoo-wang/wow-client", St = "@ahoo-wang/wow-client/legacy", Ct = /* @__PURE__ */ new Set([
439
+ var L = "@ahoo-wang/wow-client", xt = "@ahoo-wang/wow-client/legacy", St = /* @__PURE__ */ new Set([
440
440
  "Condition",
441
441
  "ConditionOptions",
442
442
  "ListQuery",
443
443
  "Operator",
444
444
  "PagedQuery"
445
- ]), wt = {
445
+ ]), Ct = {
446
446
  "wow.command.CommandResult": "CommandResult",
447
447
  "wow.command.CommandResultArray": "CommandResultArray",
448
448
  "wow.MessageHeaderSqlType": "MessageHeaderSqlType",
@@ -475,15 +475,15 @@ var I = "@ahoo-wang/wow-client", St = "@ahoo-wang/wow-client/legacy", Ct = /* @_
475
475
  "wow.openapi.BatchResult": "BatchResult",
476
476
  "wow.messaging.CompensationTarget": "CompensationTarget"
477
477
  };
478
- function Tt(e, t) {
479
- let n = wt[e];
478
+ function wt(e, t) {
479
+ let n = Ct[e];
480
480
  if (t && "filter" in t && (e === "wow.api.query.ListQuery" ? n = "FilterListQuery" : e === "wow.api.query.PagedQuery" && (n = "FilterPagedQuery")), n) return {
481
481
  name: n,
482
- path: Ct.has(n) ? St : I
482
+ path: St.has(n) ? xt : L
483
483
  };
484
484
  }
485
- var Et = /* @__PURE__ */ new Set(["wow", "Actuator"]), Dt = ["tenantId", "ownerId"];
486
- function Ot(e) {
485
+ var Tt = /* @__PURE__ */ new Set(["wow", "Actuator"]), Et = ["tenantId", "ownerId"];
486
+ function Dt(e) {
487
487
  let t = 0, n = 0;
488
488
  return e.commands.forEach((e) => {
489
489
  e.path.startsWith("/tenant/{tenantId}") && (t += 1), e.path.startsWith("/owner/{ownerId}") && (n += 1);
@@ -491,39 +491,39 @@ function Ot(e) {
491
491
  }
492
492
  //#endregion
493
493
  //#region src/analysis/clientNames.ts
494
- function kt(e, t) {
494
+ function Ot(e, t) {
495
495
  return `${e.contextAlias}/${e.aggregateName}/${t}.ts`;
496
496
  }
497
- function L(e, t) {
498
- return `${de(e.aggregateName)}${t}`;
497
+ function R(e, t) {
498
+ return `${ue(e.aggregateName)}${t}`;
499
499
  }
500
- var At = "x-fetcher-method";
501
- function jt(e, t) {
500
+ var kt = "x-fetcher-method";
501
+ function At(e, t) {
502
502
  let n = t ?? e["x-fetcher-method"];
503
503
  if (n !== void 0) {
504
- if (typeof n != "string" || !Mt(n)) throw new g("specification", `${At} of ${e.operationId ?? "an operation"} is ${JSON.stringify(n)}, which is not a valid method name.`);
504
+ if (typeof n != "string" || !jt(n)) throw new _("specification", `${kt} of ${e.operationId ?? "an operation"} is ${JSON.stringify(n)}, which is not a valid method name.`);
505
505
  return n;
506
506
  }
507
507
  if (!e.operationId) return;
508
- let r = y(e.operationId.split(".").pop()) || "_";
508
+ let r = b(e.operationId.split(".").pop()) || "_";
509
509
  return /^\p{N}/u.test(r) ? `_${r}` : r;
510
510
  }
511
- function Mt(e) {
512
- return v(e) || /^[a-z]+$/.test(e);
511
+ function jt(e) {
512
+ return y(e) || /^[a-z]+$/.test(e);
513
513
  }
514
- function Nt(e, t) {
515
- let n = le(e), r = n;
514
+ function Mt(e, t) {
515
+ let n = ce(e), r = n;
516
516
  for (let e = 2; t.has(r); e++) r = `${n}${e}`;
517
517
  return t.add(r), r;
518
518
  }
519
519
  //#endregion
520
520
  //#region src/analysis/modelInfo.ts
521
- function R(e, t) {
521
+ function z(e, t) {
522
522
  if (!e) return {
523
523
  name: "",
524
524
  path: "/"
525
525
  };
526
- let n = Tt(e, t?.properties);
526
+ let n = wt(e, t?.properties);
527
527
  if (n) return n;
528
528
  let r = e.split("."), i = -1;
529
529
  for (let e = 0; e < r.length; e++) if (r[e] && /^[A-Z]/.test(r[e])) {
@@ -532,16 +532,16 @@ function R(e, t) {
532
532
  }
533
533
  let a = r.slice(0, i), o = a.length > 0 ? `/${a.join("/")}` : "/";
534
534
  return {
535
- name: de(r.slice(i)),
535
+ name: ue(r.slice(i)),
536
536
  path: o
537
537
  };
538
538
  }
539
- function Pt(e, t) {
540
- if (!e.$ref.startsWith(Ce)) throw new g("specification", `Unsupported schema reference: ${e.$ref}. Bundle or inline external schemas before generation.`);
541
- return R(we(e), t ? D(e, t) : void 0);
539
+ function Nt(e, t) {
540
+ if (!e.$ref.startsWith(Se)) throw new _("specification", `Unsupported schema reference: ${e.$ref}. Bundle or inline external schemas before generation.`);
541
+ return z(D(e), t ? k(e, t) : void 0);
542
542
  }
543
- function z(e) {
544
- let t = `${ge(e)}_BOUNDED_CONTEXT_ALIAS`;
543
+ function Pt(e) {
544
+ let t = `${he(e)}_BOUNDED_CONTEXT_ALIAS`;
545
545
  return /^\p{N}/u.test(t) ? `_${t}` : t;
546
546
  }
547
547
  //#endregion
@@ -557,7 +557,7 @@ function Lt(e, t) {
557
557
  aggregateName: r,
558
558
  context: {
559
559
  alias: n,
560
- constantName: z(n)
560
+ constantName: Pt(n)
561
561
  },
562
562
  commandClient: Rt(e, t),
563
563
  queryClient: Ut(t)
@@ -566,12 +566,12 @@ function Lt(e, t) {
566
566
  function Rt(e, t) {
567
567
  let n = t.aggregate, r = Vt(t);
568
568
  return {
569
- file: kt(n, "commandClient"),
570
- endpointPathsName: L(n, "CommandEndpointPaths"),
571
- className: L(n, "CommandClient"),
572
- streamClassName: L(n, "StreamCommandClient"),
569
+ file: Ot(n, "commandClient"),
570
+ endpointPathsName: R(n, "CommandEndpointPaths"),
571
+ className: R(n, "CommandClient"),
572
+ streamClassName: R(n, "StreamCommandClient"),
573
573
  commands: [...t.commands.values()].map((t) => {
574
- let n = R(t.schema.key), i = /* @__PURE__ */ new Set(["commandRequest", "attributes"]);
574
+ let n = z(t.schema.key), i = /* @__PURE__ */ new Set(["commandRequest", "attributes"]);
575
575
  return {
576
576
  path: t.path,
577
577
  endpointMember: r.get(t),
@@ -580,12 +580,12 @@ function Rt(e, t) {
580
580
  typeName: zt(n),
581
581
  body: n,
582
582
  bodyKey: t.schema.key,
583
- optionalFields: Ze(t.schema.schema, e.components),
584
- requestOptional: Ye(t.schema.schema),
585
- pathParameters: ot(t.path, t.pathParameters).filter((e) => !Dt.includes(e.name)).map((e) => ({
586
- name: Nt(e.name, i),
583
+ optionalFields: Ye(t.schema.schema, e.components),
584
+ requestOptional: qe(t.schema.schema),
585
+ pathParameters: at(t.path, t.pathParameters).filter((e) => !Et.includes(e.name)).map((e) => ({
586
+ name: Mt(e.name, i),
587
587
  pathName: e.name,
588
- type: ct(e)
588
+ type: st(e)
589
589
  })),
590
590
  docs: [
591
591
  t.summary,
@@ -615,7 +615,7 @@ function Bt(e, t) {
615
615
  let { typeName: t, bodyKey: i } = e;
616
616
  if (t === void 0 || e.body.path === "@ahoo-wang/wow-client") continue;
617
617
  let a = r.get(t);
618
- if (a !== void 0 && a.bodyKey !== i) throw new g("specification", `Command ${e.methodName}() of aggregate ${n.contextAlias}.${n.aggregateName} generates the type ${t} for its body ${i}, but ${a.holder} already has that name. Rename the schema ${i} or ${a.key} in the document.`);
618
+ if (a !== void 0 && a.bodyKey !== i) throw new _("specification", `Command ${e.methodName}() of aggregate ${n.contextAlias}.${n.aggregateName} generates the type ${t} for its body ${i}, but ${a.holder} already has that name. Rename the schema ${i} or ${a.key} in the document.`);
619
619
  r.set(t, {
620
620
  holder: `the type of command ${e.methodName}()`,
621
621
  key: i,
@@ -636,23 +636,23 @@ function Vt(e) {
636
636
  return t;
637
637
  }
638
638
  function Ht(e) {
639
- let t = y(e.name) || "_";
639
+ let t = b(e.name) || "_";
640
640
  return /^\p{N}/u.test(t) ? `_${t}` : t;
641
641
  }
642
642
  function Ut(e) {
643
- let t = e.aggregate, n = y(t.aggregateName) || "_";
643
+ let t = e.aggregate, n = b(t.aggregateName) || "_";
644
644
  return {
645
- file: kt(t, "queryClient"),
645
+ file: Ot(t, "queryClient"),
646
646
  resourceName: e.resourceName,
647
- resourceAttribution: Ot(e),
648
- state: R(e.state.key),
649
- fields: R(e.fields.key),
650
- eventTitlesName: L(t, "DomainEventTypeMapTitle"),
651
- eventTypeName: L(t, "DomainEventType"),
647
+ resourceAttribution: Dt(e),
648
+ state: z(e.state.key),
649
+ fields: z(e.fields.key),
650
+ eventTitlesName: R(t, "DomainEventTypeMapTitle"),
651
+ eventTypeName: R(t, "DomainEventType"),
652
652
  events: [...e.events.values()].map((e) => ({
653
- memberName: b(e.name),
653
+ memberName: x(e.name),
654
654
  title: e.title,
655
- body: R(e.schema.key)
655
+ body: z(e.schema.key)
656
656
  })),
657
657
  factoryName: `${/^\p{N}/u.test(n) ? "_" : ""}${n}QueryClientFactory`
658
658
  };
@@ -696,18 +696,18 @@ var Zt = class {
696
696
  constructor(e, t, n, r) {
697
697
  this.document = e, this.wow = t, this.config = n, this.warnings = r, this.wowDocument = qt(t), t.contextAlias && (this.basePath = {
698
698
  alias: t.contextAlias,
699
- constantName: z(t.contextAlias)
699
+ constantName: Pt(t.contextAlias)
700
700
  });
701
701
  }
702
702
  clients() {
703
703
  let e = this.tags(), t = this.groupOperations(e), n = /* @__PURE__ */ new Map();
704
704
  return [...t.keys()].sort().map((r) => {
705
- let i = R(r), a = i;
706
- for (let e = 2; n.has(V(a)); e++) a = {
705
+ let i = z(r), a = i;
706
+ for (let e = 2; n.has($t(a)); e++) a = {
707
707
  ...i,
708
708
  name: `${i.name}${e}`
709
709
  };
710
- return a !== i && this.warnings.push(`Tags ${n.get(V(i))} and ${r} both name the API client ${i.name}ApiClient; ${r} generates ${a.name}ApiClient.`), n.set(V(a), r), this.client(e.get(r), a, [...t.get(r)]);
710
+ return a !== i && this.warnings.push(`Tags ${n.get($t(i))} and ${r} both name the API client ${i.name}ApiClient; ${r} generates ${a.name}ApiClient.`), n.set($t(a), r), this.client(e.get(r), a, [...t.get(r)]);
711
711
  });
712
712
  }
713
713
  client(e, t, n) {
@@ -742,21 +742,21 @@ var Zt = class {
742
742
  };
743
743
  }
744
744
  methodName(e, t, n, r) {
745
- let i = n.operation.operationId, a = jt(n.operation, this.config.apiClients?.[e.name]?.methodNames?.[i]), o = r.get(a);
746
- if (o !== void 0) throw new g("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.`);
745
+ let i = n.operation.operationId, a = At(n.operation, this.config.apiClients?.[e.name]?.methodNames?.[i]), o = r.get(a);
746
+ if (o !== void 0) throw new _("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.`);
747
747
  return r.set(a, i), a;
748
748
  }
749
749
  parameters(e, t, n) {
750
- let r = it(t.operation, this.document.components ?? {}), i = [];
750
+ let r = rt(t.operation, this.document.components ?? {}), i = [];
751
751
  for (let a of [
752
752
  "path",
753
753
  "query",
754
754
  "header"
755
755
  ]) {
756
756
  let o = r.filter((e) => e.in === a);
757
- for (let r of a === "path" ? ot(t.path, o) : o) a === "path" && this.ignoresPathParameter(e.name, r.name) || i.push({
757
+ for (let r of a === "path" ? at(t.path, o) : o) a === "path" && this.ignoresPathParameter(e.name, r.name) || i.push({
758
758
  parameter: {
759
- name: Nt(r.name, n),
759
+ name: Mt(r.name, n),
760
760
  location: a,
761
761
  parameterName: r.name,
762
762
  schema: r.schema,
@@ -769,30 +769,30 @@ var Zt = class {
769
769
  return a.length > 0 && this.warnings.push(`${t.method.toUpperCase()} ${t.path} leaves out its cookie parameter(s) ${a.map((e) => e.name).join(", ")}: the browser sends cookies, and fetch cannot set them.`), i;
770
770
  }
771
771
  ignoresPathParameter(e, t) {
772
- return (this.config.apiClients?.[e]?.ignorePathParameters ?? (this.wowDocument ? Dt : [])).includes(t);
772
+ return (this.config.apiClients?.[e]?.ignorePathParameters ?? (this.wowDocument ? Et : [])).includes(t);
773
773
  }
774
774
  body(e, t) {
775
775
  if (!e.requestBody) return;
776
- let n = C(e.requestBody) ? Ee(e.requestBody, this.document.components) : e.requestBody;
776
+ let n = w(e.requestBody) ? we(e.requestBody, this.document.components) : e.requestBody;
777
777
  if (!n) return;
778
- let r = n.required === !0, i = n.content ?? {}, a = j(i, k, ke), o = Nt("body", t);
778
+ let r = n.required === !0, i = n.content ?? {}, a = M(i, j, Oe), o = Mt("body", t);
779
779
  return a?.schema ? {
780
780
  name: o,
781
781
  required: r,
782
782
  content: {
783
783
  kind: "json",
784
784
  schema: a.schema,
785
- optionalFields: Ze(a.schema, this.document.components)
785
+ optionalFields: Ye(a.schema, this.document.components)
786
786
  }
787
- } : j(i, "multipart/form-data") ? {
787
+ } : M(i, "multipart/form-data") ? {
788
788
  name: o,
789
789
  required: r,
790
790
  content: { kind: "formData" }
791
- } : j(i, "application/x-www-form-urlencoded") ? {
791
+ } : M(i, "application/x-www-form-urlencoded") ? {
792
792
  name: o,
793
793
  required: r,
794
794
  content: { kind: "urlEncoded" }
795
- } : Object.keys(i).some(Ae) ? {
795
+ } : Object.keys(i).some(ke) ? {
796
796
  name: o,
797
797
  required: r,
798
798
  content: { kind: "text" }
@@ -803,20 +803,20 @@ var Zt = class {
803
803
  };
804
804
  }
805
805
  returns(e) {
806
- let t = F(e, this.document.components);
806
+ let t = tt(e, this.document.components);
807
807
  if (!t) return { kind: "response" };
808
- let n = Me(t), r = n || Pe(t);
808
+ let n = je(t), r = n || Ne(t);
809
809
  if (r) return {
810
810
  kind: "json",
811
811
  schema: r,
812
812
  wildcard: !n
813
813
  };
814
- let i = Ne(t);
814
+ let i = Me(t);
815
815
  if (i) {
816
- if (C(i)) {
817
- let e = D(i, this.document.components);
818
- if (Ve(e) && C(e.items)) {
819
- let t = Pt(e.items, this.document.components);
816
+ if (w(i)) {
817
+ let e = k(i, this.document.components);
818
+ if (Be(e) && w(e.items)) {
819
+ let t = Nt(e.items, this.document.components);
820
820
  return {
821
821
  kind: "eventStream",
822
822
  items: e.items,
@@ -829,7 +829,7 @@ var Zt = class {
829
829
  serverSentEvent: !1
830
830
  };
831
831
  }
832
- return Fe(t) ? { kind: "text" } : { kind: "response" };
832
+ return Pe(t) ? { kind: "text" } : { kind: "response" };
833
833
  }
834
834
  groupOperations(e) {
835
835
  let t = /* @__PURE__ */ new Map();
@@ -863,44 +863,44 @@ var Zt = class {
863
863
  }), e;
864
864
  }
865
865
  ignoresTag(e) {
866
- return Et.has(e) || this.wow.aggregateTags.has(e);
866
+ return Tt.has(e) || this.wow.aggregateTags.has(e);
867
867
  }
868
868
  };
869
869
  function Qt(e) {
870
870
  return `${e.charAt(0).toLowerCase()}${e.slice(1)}.ts`;
871
871
  }
872
- function V(e) {
872
+ function $t(e) {
873
873
  return `${e.path}/${e.name}`.toLowerCase();
874
874
  }
875
875
  //#endregion
876
876
  //#region src/analysis/models.ts
877
- function $t(e) {
877
+ function en(e) {
878
878
  let t = new Set(e.contexts.keys());
879
879
  return e.contextAlias && t.add(e.contextAlias), [...t].sort().map((e) => ({
880
880
  alias: e,
881
- constantName: z(e),
881
+ constantName: Pt(e),
882
882
  file: Kt(e)
883
883
  }));
884
884
  }
885
- function en(e, t) {
885
+ function tn(e, t) {
886
886
  let n = e.components?.schemas;
887
887
  if (!n) return [];
888
- let r = nn(t), i = tn(e, t), a = Object.keys(n).filter((e) => !xt(e, () => R(e).name, r) || !e.startsWith("wow.") && i.has(e));
889
- rn(a);
890
- let o = an(t);
888
+ let r = rn(t), i = nn(e, t), a = Object.keys(n).filter((e) => !bt(e, () => z(e).name, r) || !e.startsWith("wow.") && i.has(e));
889
+ an(a);
890
+ let o = on(t);
891
891
  return a.map((e) => {
892
- let r = n[e], i = R(e);
892
+ let r = n[e], i = z(e);
893
893
  return {
894
894
  key: e,
895
895
  info: i,
896
896
  file: Gt(i),
897
897
  schema: r,
898
898
  docSchema: Jt(r, t.schemaDocOverrides.get(e)),
899
- emptyMessageBody: o.has(e) && on(r)
899
+ emptyMessageBody: o.has(e) && sn(r)
900
900
  };
901
901
  });
902
902
  }
903
- function tn(e, t) {
903
+ function nn(e, t) {
904
904
  let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = e.components ?? {}, a = (e) => {
905
905
  if (typeof e != "object" || !e || r.has(e)) return;
906
906
  if (r.add(e), Array.isArray(e)) {
@@ -909,41 +909,41 @@ function tn(e, t) {
909
909
  }
910
910
  let { $ref: t } = e;
911
911
  if (typeof t == "string" && t.startsWith("#/components/")) {
912
- let [e, ...r] = t.slice(w.length).split("/"), o = r.join("/");
912
+ let [e, ...r] = t.slice(T.length).split("/"), o = r.join("/");
913
913
  e === "schemas" && n.add(o), a(i[e]?.[o]);
914
914
  }
915
915
  Object.values(e).forEach(a);
916
916
  };
917
917
  for (let { operation: n } of e.endpoints) {
918
918
  let e = n.tags ?? [];
919
- e.length > 0 && e.every((e) => !Et.has(e) && !t.aggregateTags.has(e)) && a(n);
919
+ e.length > 0 && e.every((e) => !Tt.has(e) && !t.aggregateTags.has(e)) && a(n);
920
920
  }
921
921
  return n;
922
922
  }
923
- function nn(e) {
923
+ function rn(e) {
924
924
  let t = /* @__PURE__ */ new Set();
925
- for (let n of e.contexts.values()) for (let e of n) bt(R(e.state.key).name).forEach((e) => t.add(e));
925
+ for (let n of e.contexts.values()) for (let e of n) yt(z(e.state.key).name).forEach((e) => t.add(e));
926
926
  return t;
927
927
  }
928
- function rn(e) {
928
+ function an(e) {
929
929
  let t = /* @__PURE__ */ new Map();
930
930
  for (let n of e) {
931
- let e = R(n), r = `${e.path === "/" ? "" : e.path}/${e.name}`;
931
+ let e = z(n), r = `${e.path === "/" ? "" : e.path}/${e.name}`;
932
932
  t.set(r, [...t.get(r) ?? [], n]);
933
933
  }
934
934
  let n = [...t].filter(([, e]) => e.length > 1);
935
- if (n.length !== 0) throw new g("specification", `Schemas generate the same model: ${n.map(([e, t]) => `${t.join(", ")} → ${e}`).join("; ")}. Rename all but one of them in the document.`);
935
+ if (n.length !== 0) throw new _("specification", `Schemas generate the same model: ${n.map(([e, t]) => `${t.join(", ")} → ${e}`).join("; ")}. Rename all but one of them in the document.`);
936
936
  }
937
- function an(e) {
937
+ function on(e) {
938
938
  return new Set([...e.contexts.values()].flatMap((e) => [...e].flatMap((e) => [...[...e.commands.values()].map((e) => e.schema.key), ...[...e.events.values()].map((e) => e.schema.key)])));
939
939
  }
940
- function on(e) {
941
- return !C(e) && e.type === "object" && Object.keys(e.properties ?? {}).length === 0 && (e.additionalProperties === void 0 || e.additionalProperties === !1) && !e.required?.length && !N(e) && e.enum === void 0 && e.const === void 0;
940
+ function sn(e) {
941
+ return !w(e) && e.type === "object" && Object.keys(e.properties ?? {}).length === 0 && (e.additionalProperties === void 0 || e.additionalProperties === !1) && !e.required?.length && !P(e) && e.enum === void 0 && e.const === void 0;
942
942
  }
943
943
  //#endregion
944
944
  //#region src/analysis/analyze.ts
945
- function sn(e, t, n) {
946
- let r = [], i = $t(t), a = en(e, t), o = It(e, t);
945
+ function cn(e, t, n) {
946
+ let r = [], i = en(t), a = tn(e, t), o = It(e, t);
947
947
  return Bt(o, a), {
948
948
  model: {
949
949
  contexts: i,
@@ -956,7 +956,7 @@ function sn(e, t, n) {
956
956
  }
957
957
  //#endregion
958
958
  //#region src/emit/importRegistry.ts
959
- var cn = class {
959
+ var ln = class {
960
960
  declarations = /* @__PURE__ */ new Map();
961
961
  add(e, t) {
962
962
  let n = this.declarations.get(e);
@@ -992,9 +992,9 @@ var cn = class {
992
992
  })
993
993
  }));
994
994
  }
995
- }, ln = class {
995
+ }, un = class {
996
996
  sourceFile;
997
- imports = new cn();
997
+ imports = new ln();
998
998
  statements = [];
999
999
  constructor(e) {
1000
1000
  this.sourceFile = e;
@@ -1011,10 +1011,10 @@ var cn = class {
1011
1011
  ...n,
1012
1012
  kind: o.ImportDeclaration
1013
1013
  }, e.push(t);
1014
- for (let n of this.statements) t && fn(t, n) && e.push(dn), e.push(n), t = n;
1014
+ for (let n of this.statements) t && pn(t, n) && e.push(fn), e.push(n), t = n;
1015
1015
  return e.length > 0 && this.sourceFile.addStatements(e), this.sourceFile;
1016
1016
  }
1017
- }, un = class {
1017
+ }, dn = class {
1018
1018
  open;
1019
1019
  modules = /* @__PURE__ */ new Map();
1020
1020
  constructor(e) {
@@ -1022,16 +1022,16 @@ var cn = class {
1022
1022
  }
1023
1023
  module(e) {
1024
1024
  let t = this.open(e), n = t.getFilePath(), r = this.modules.get(n);
1025
- return r || (r = new ln(t), this.modules.set(n, r)), r;
1025
+ return r || (r = new un(t), this.modules.set(n, r)), r;
1026
1026
  }
1027
1027
  build() {
1028
1028
  for (let e of this.modules.values()) e.build();
1029
1029
  this.modules.clear();
1030
1030
  }
1031
- }, dn = (e) => {
1031
+ }, fn = (e) => {
1032
1032
  e.blankLineIfLastNot();
1033
1033
  };
1034
- function fn(e, t) {
1034
+ function pn(e, t) {
1035
1035
  if (typeof t == "string") return !1;
1036
1036
  switch (t.kind) {
1037
1037
  case o.TypeAlias:
@@ -1039,13 +1039,13 @@ function fn(e, t) {
1039
1039
  default: return !0;
1040
1040
  }
1041
1041
  }
1042
- function pn(e) {
1042
+ function mn(e) {
1043
1043
  return e.map((e) => ({
1044
1044
  ...e,
1045
1045
  initializer: `${e.initializer},`
1046
1046
  }));
1047
1047
  }
1048
- function mn(e, t) {
1048
+ function hn(e, t) {
1049
1049
  return {
1050
1050
  name: "[key: string]",
1051
1051
  type: e,
@@ -1054,76 +1054,93 @@ function mn(e, t) {
1054
1054
  }
1055
1055
  //#endregion
1056
1056
  //#region src/emit/imports.ts
1057
- var hn = "@";
1058
- function H(e, t, n) {
1057
+ var gn = "@";
1058
+ function V(e, t, n) {
1059
1059
  return e.imports.add(t, n);
1060
1060
  }
1061
- function U(e, t, n) {
1062
- return H(e, W(e, t, n), [n.name]);
1061
+ function H(e, t, n) {
1062
+ return V(e, U(e, t, n), [n.name]);
1063
1063
  }
1064
- function W(e, t, n) {
1065
- return n.path.startsWith(hn) ? n.path : gn(e.directoryPath, d(t, n.path, Wt));
1064
+ function U(e, t, n) {
1065
+ return n.path.startsWith(gn) ? n.path : _n(e.directoryPath, d(t, n.path, Wt));
1066
1066
  }
1067
- function gn(e, t) {
1067
+ function _n(e, t) {
1068
1068
  let n = f(e, t).split(m).join("/");
1069
1069
  return n = n.endsWith(".ts") ? n.replace(/\.ts$/, ".js") : `${n}/index.js`, n.startsWith(".") ? n : `./${n}`;
1070
1070
  }
1071
- function G(e, t, n, r) {
1072
- return H(e, gn(e.directoryPath, d(t, Kt(n))), [r]);
1071
+ function W(e, t, n, r) {
1072
+ return V(e, _n(e.directoryPath, d(t, Kt(n))), [r]);
1073
1073
  }
1074
1074
  //#endregion
1075
1075
  //#region src/emit/jsdoc.ts
1076
- function _n(e, t = "\n") {
1076
+ function vn(e, t = "\n") {
1077
1077
  if (!Array.isArray(e)) return;
1078
- let n = e.filter((e) => typeof e == "string" && e.length > 0).map(vn);
1078
+ let n = e.filter((e) => typeof e == "string" && e.length > 0).map(yn);
1079
1079
  return n.length > 0 ? n.join(t) : void 0;
1080
1080
  }
1081
- function vn(e) {
1081
+ function yn(e) {
1082
1082
  return e.replace(/\*\//g, "*\\/");
1083
1083
  }
1084
- function K(e, t) {
1085
- let n = _n(t);
1084
+ function G(e, t) {
1085
+ let n = vn(t);
1086
1086
  n && (e.docs = [...e.docs ?? [], n]);
1087
1087
  }
1088
- function yn(e, t) {
1089
- let n = [e.title, e.description];
1090
- return t && n.push(`- key: ${t}`), e.format && n.push(e.format === "int64" ? "- format: int64 (a value beyond Number.MAX_SAFE_INTEGER loses precision)" : `- format: ${e.format}`), Sn(n, e, "default"), Sn(n, e, "example"), wn(n, e), Tn(n, e), En(n, e), n;
1088
+ function K(e, t, n = !1) {
1089
+ e = Sn(e);
1090
+ let r = [e.title, e.description];
1091
+ return t && r.push(`- key: ${t}`), n && Cn(r, e), e.format && r.push(e.format === "int64" ? "- format: int64 (a value beyond Number.MAX_SAFE_INTEGER loses precision)" : `- format: ${e.format}`), wn(r, e, "default"), wn(r, e, "example"), En(r, e), Dn(r, e), On(r, e), r;
1091
1092
  }
1092
1093
  function bn(e, t, n) {
1093
- K(e, yn(t, n));
1094
+ G(e, K(t, n));
1094
1095
  }
1095
1096
  function xn(e, t, n, r = !1) {
1096
- let i = yn(t, n);
1097
- r && Cn(i, "schema", t), K(e, i);
1098
- }
1099
- function Sn(e, t, n) {
1097
+ let i = K(t, n, !0);
1098
+ r && Tn(i, "schema", t), G(e, i);
1099
+ }
1100
+ function Sn(e) {
1101
+ for (let t of ["anyOf", "oneOf"]) {
1102
+ let n = e[t];
1103
+ if (!Array.isArray(n) || n.length < 2) continue;
1104
+ let r = n.filter((e) => "$ref" in e || e.type !== "null"), [i] = r;
1105
+ if (r.length !== 1 || "$ref" in i) continue;
1106
+ let a = { ...i };
1107
+ for (let [n, r] of Object.entries(e)) n !== t && r !== void 0 && (a[n] = r);
1108
+ return a;
1109
+ }
1110
+ return e;
1111
+ }
1112
+ function Cn(e, t) {
1113
+ let n = t.required ?? [];
1114
+ (n.length || Object.keys(t.properties ?? {}).length) && e.push(`- required: ${n.length ? n.join(", ") : "(none)"}`);
1115
+ }
1116
+ function wn(e, t, n) {
1100
1117
  let r = t[n];
1101
1118
  if (r) {
1102
1119
  if (typeof r != "object") {
1103
1120
  e.push(`- ${n}: \`${r}\``);
1104
1121
  return;
1105
1122
  }
1106
- Cn(e, n, r);
1123
+ Tn(e, n, r);
1107
1124
  }
1108
1125
  }
1109
- function Cn(e, t, n) {
1126
+ function Tn(e, t, n) {
1110
1127
  e.push(`- ${t}: `), e.push("```json"), e.push(JSON.stringify(n, null, 2)), e.push("```");
1111
1128
  }
1112
- function wn(e, t) {
1129
+ function En(e, t) {
1113
1130
  let n = ["- Numeric Constraints"];
1114
1131
  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);
1115
1132
  }
1116
- function Tn(e, t) {
1133
+ function Dn(e, t) {
1117
1134
  let n = ["- String Constraints"];
1118
1135
  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);
1119
1136
  }
1120
- function En(e, t) {
1137
+ function On(e, t) {
1121
1138
  let n = ["- Array Constraints"];
1122
1139
  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);
1123
1140
  }
1124
1141
  //#endregion
1125
1142
  //#region src/types/typeResolver.ts
1126
- function Dn(e, t) {
1143
+ function kn(e, t) {
1127
1144
  let n;
1128
1145
  return {
1129
1146
  components: e,
@@ -1140,7 +1157,7 @@ function Dn(e, t) {
1140
1157
  }
1141
1158
  };
1142
1159
  }
1143
- var On = [
1160
+ var An = [
1144
1161
  "Array",
1145
1162
  "Blob",
1146
1163
  "Exclude",
@@ -1152,11 +1169,11 @@ var On = [
1152
1169
  "Response",
1153
1170
  "Symbol",
1154
1171
  "URLSearchParams"
1155
- ], kn = /* @__PURE__ */ new Set([
1172
+ ], jn = /* @__PURE__ */ new Set([
1156
1173
  "string",
1157
1174
  "number",
1158
1175
  "boolean"
1159
- ]), An = /* @__PURE__ */ new Set([
1176
+ ]), Mn = /* @__PURE__ */ new Set([
1160
1177
  "$comment",
1161
1178
  "$schema",
1162
1179
  "default",
@@ -1170,54 +1187,54 @@ var On = [
1170
1187
  "writeOnly",
1171
1188
  "xml"
1172
1189
  ]);
1173
- function jn(e, t) {
1190
+ function Nn(e, t) {
1174
1191
  return e === void 0 ? !1 : typeof e == "string" || typeof t == "string" ? e === t : e.primitive === t.primitive;
1175
1192
  }
1176
1193
  function q(e, t, n = /* @__PURE__ */ new Set()) {
1177
- if (C(e)) {
1194
+ if (w(e)) {
1178
1195
  if (!t || n.has(e.$ref)) return;
1179
1196
  n.add(e.$ref);
1180
- let r = D(e, t);
1197
+ let r = k(e, t);
1181
1198
  return r ? q(r, t, n) : void 0;
1182
1199
  }
1183
1200
  if (!(e.nullable || Array.isArray(e.type))) {
1184
- if (We(e) && e.type === void 0) {
1201
+ if (Ue(e) && e.type === void 0) {
1185
1202
  let r = e.allOf.map((e) => q(e, t, n)), [i] = r;
1186
- return i !== void 0 && r.every((e) => jn(e, i)) ? i : void 0;
1203
+ return i !== void 0 && r.every((e) => Nn(e, i)) ? i : void 0;
1187
1204
  }
1188
- if (!(N(e) || e.const !== void 0 || e.type === void 0)) return e.type === "object" ? "object" : e.type === "array" ? "array" : { primitive: P(e.type) };
1205
+ if (!(P(e) || e.const !== void 0 || e.type === void 0)) return e.type === "object" ? "object" : e.type === "array" ? "array" : { primitive: I(e.type) };
1189
1206
  }
1190
1207
  }
1191
- function Mn(e, t, n) {
1208
+ function Pn(e, t, n) {
1192
1209
  let r = q(t, n);
1193
1210
  if (typeof r != "object") return !1;
1194
1211
  let i = q(e, n);
1195
1212
  return i === void 0 || typeof i == "string" || i.primitive !== r.primitive;
1196
1213
  }
1197
- function Nn(e, t) {
1214
+ function Fn(e, t) {
1198
1215
  let n = e.additionalProperties;
1199
- return typeof n == "object" && Object.values(e.properties ?? {}).some((e) => Mn(e, n, t));
1216
+ return typeof n == "object" && Object.values(e.properties ?? {}).some((e) => Pn(e, n, t));
1200
1217
  }
1201
- function Pn(e) {
1202
- return e.nullable !== !0 || M(e) || !N(e) ? !1 : [
1218
+ function In(e) {
1219
+ return e.nullable !== !0 || N(e) || !P(e) ? !1 : [
1203
1220
  e.allOf,
1204
1221
  e.oneOf,
1205
1222
  e.anyOf
1206
- ].every((e) => e === void 0 || e.every(C));
1223
+ ].every((e) => e === void 0 || e.every(w));
1207
1224
  }
1208
- function Fn(e, t) {
1225
+ function Ln(e, t) {
1209
1226
  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);
1210
1227
  }
1211
1228
  function J(t) {
1212
1229
  if (typeof t == "string") return new e({ useSingleQuote: !0 }).quote(t).toString();
1213
1230
  if (Array.isArray(t)) return `[${t.map((e) => J(e)).join(", ")}]`;
1214
1231
  if (typeof t == "object" && t) {
1215
- let e = Object.entries(t).map(([e, t]) => `${b(e)}: ${J(t)}`);
1232
+ let e = Object.entries(t).map(([e, t]) => `${x(e)}: ${J(t)}`);
1216
1233
  return e.length ? `{ ${e.join("; ")}; readonly [globalThis.Symbol.iterator]?: never }` : "globalThis.Record<string, never>";
1217
1234
  }
1218
1235
  return JSON.stringify(t) ?? "never";
1219
1236
  }
1220
- var In = class {
1237
+ var Rn = class {
1221
1238
  scope;
1222
1239
  entries;
1223
1240
  requested = [];
@@ -1249,7 +1266,7 @@ var In = class {
1249
1266
  name: t.name
1250
1267
  }, this.entries.push(i)), this.request(i), i.alias) return i.alias;
1251
1268
  let a = /* @__PURE__ */ new Set([
1252
- ...On,
1269
+ ...An,
1253
1270
  n.name,
1254
1271
  ...n.path === void 0 ? [] : this.scope.context.namesAt(n.path),
1255
1272
  ...this.entries.filter((e) => e !== i).map((e) => e.alias ?? e.name)
@@ -1271,9 +1288,9 @@ var In = class {
1271
1288
  propertyDefinitions(e) {
1272
1289
  let { properties: t } = e;
1273
1290
  return Object.entries(t).map(([e, t]) => {
1274
- let n = this.type(t), r = (Xe(t) ? "readonly " : "") + b(e);
1275
- if (!C(t)) {
1276
- let e = _n(yn(t), "\n * ");
1291
+ let n = this.type(t), r = (Je(t) ? "readonly " : "") + x(e);
1292
+ if (!w(t)) {
1293
+ let e = vn(K(t), "\n * ");
1277
1294
  if (e) return `
1278
1295
  /**
1279
1296
  * ${e}
@@ -1286,9 +1303,9 @@ var In = class {
1286
1303
  }
1287
1304
  objectType(e) {
1288
1305
  let t = [];
1289
- Be(e) && t.push(...this.propertyDefinitions(e));
1290
- for (let n of e.required ?? []) Object.hasOwn(e.properties ?? {}, n) || t.push(`${b(n)}: ${this.requiredAdditionalPropertyType(e)}`);
1291
- let n = Ke(e) && Je(e) ? this.mapType(e) : Nn(e, this.components) ? `globalThis.Record<string, ${this.additionalPropertyType(e)}>` : void 0, r = n ? "" : this.additionalProperties(e);
1306
+ ze(e) && t.push(...this.propertyDefinitions(e));
1307
+ for (let n of e.required ?? []) Object.hasOwn(e.properties ?? {}, n) || t.push(`${x(n)}: ${this.requiredAdditionalPropertyType(e)}`);
1308
+ let n = Ge(e) && F(e) ? this.mapType(e) : Fn(e, this.components) ? `globalThis.Record<string, ${this.additionalPropertyType(e)}>` : void 0, r = n ? "" : this.additionalProperties(e);
1292
1309
  if (r && t.push(r), t.length === 0) return "globalThis.Record<string, any>";
1293
1310
  let i = `{\n ${t.join(";\n ")}; \n}`;
1294
1311
  return n ? `(${i} & ${n})` : i;
@@ -1297,14 +1314,14 @@ var In = class {
1297
1314
  return e.additionalProperties === void 0 || e.additionalProperties === !1 || e.additionalProperties === !0 ? "any" : this.type(e.additionalProperties);
1298
1315
  }
1299
1316
  mapKeyType(e) {
1300
- let t = Je(e);
1317
+ let t = F(e);
1301
1318
  return t ? this.type(t) : "string";
1302
1319
  }
1303
1320
  mapType(e) {
1304
1321
  return `globalThis.Record<${this.mapKeyType(e)},${this.mapValueType(e)}>`;
1305
1322
  }
1306
1323
  objectConstrained(e) {
1307
- let t = (e) => C(e) ? this.components && D(e, this.components) : e, n = t(e), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = n ? [n] : [];
1324
+ let t = (e) => w(e) ? this.components && k(e, this.components) : e, n = t(e), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = n ? [n] : [];
1308
1325
  for (let e of a) {
1309
1326
  if (r.has(e)) continue;
1310
1327
  let n = [
@@ -1328,7 +1345,7 @@ var In = class {
1328
1345
  return n !== void 0 && i.has(n);
1329
1346
  }
1330
1347
  type(e) {
1331
- if (C(e)) return this.reference(e);
1348
+ if (w(e)) return this.reference(e);
1332
1349
  if (Array.isArray(e.type)) return e.type.map((t) => {
1333
1350
  let n = this.type({
1334
1351
  ...e,
@@ -1336,11 +1353,11 @@ var In = class {
1336
1353
  });
1337
1354
  return /[|&]/.test(n) ? `(${n})` : n;
1338
1355
  }).join(" | ");
1339
- if (Pn(e)) return `(${this.type({
1356
+ if (In(e)) return `(${this.type({
1340
1357
  ...e,
1341
1358
  nullable: !1
1342
1359
  })}) | null`;
1343
- if (N(e)) {
1360
+ if (P(e)) {
1344
1361
  let t = this.simpleComposition(e);
1345
1362
  if (t !== void 0) return t;
1346
1363
  let n = [
@@ -1362,25 +1379,25 @@ var In = class {
1362
1379
  return this.objectConstrained(e) ? `globalThis.Exclude<${o}, string | number | boolean | readonly unknown[]> & ({ readonly [globalThis.Symbol.iterator]?: never } | null)` : o;
1363
1380
  }
1364
1381
  if (e.const !== void 0) {
1365
- if (!Fn(e.const, e)) return "never";
1382
+ if (!Ln(e.const, e)) return "never";
1366
1383
  let t = J(e.const), n = this.type({
1367
1384
  ...e,
1368
1385
  const: void 0
1369
1386
  });
1370
1387
  return n === "any" ? t : `(${t}) & (${n})`;
1371
1388
  }
1372
- if (e.nullable && e.type && !M(e)) return `(${this.type({
1389
+ if (e.nullable && e.type && !N(e)) return `(${this.type({
1373
1390
  ...e,
1374
1391
  nullable: !1
1375
1392
  })}) | null`;
1376
- if (M(e)) {
1377
- let t = e.enum.filter((t) => Fn(t, e)).map((e) => J(e)).join(" | ") || "never", n = this.type({
1393
+ if (N(e)) {
1394
+ let t = e.enum.filter((t) => Ln(t, e)).map((e) => J(e)).join(" | ") || "never", n = this.type({
1378
1395
  ...e,
1379
1396
  enum: void 0
1380
1397
  });
1381
- return n === "any" || kn.has(n) ? t : `(${t}) & (${n})`;
1398
+ return n === "any" || jn.has(n) ? t : `(${t}) & (${n})`;
1382
1399
  }
1383
- return Ke(e) && !e.required?.length ? this.mapType(e) : e.type === "array" ? Ge(this.type(e.items ?? {})) : e.type === "object" ? this.objectType(e) : e.type ? P(e.type) : e.required?.length || Object.keys(e.properties ?? {}).length > 0 ? `(${this.objectType({
1400
+ return Ge(e) && !e.required?.length ? this.mapType(e) : e.type === "array" ? We(this.type(e.items ?? {})) : e.type === "object" ? this.objectType(e) : e.type ? I(e.type) : e.required?.length || Object.keys(e.properties ?? {}).length > 0 ? `(${this.objectType({
1384
1401
  ...e,
1385
1402
  type: "object",
1386
1403
  additionalProperties: e.additionalProperties ?? !0
@@ -1394,44 +1411,44 @@ var In = class {
1394
1411
  ].filter((t) => e[t]?.length);
1395
1412
  if (t.length !== 1) return;
1396
1413
  let [n] = t;
1397
- if (Object.keys(e).filter((e) => e !== n && e !== "discriminator" && !e.startsWith("x-") && !An.has(e)).length > 0) return;
1398
- 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" || An.has(e));
1399
- if (!r.every((e) => C(e) || i(e))) return;
1400
- let a = r.map((t) => C(t) ? this.memberType(e, n, t) : "null");
1414
+ if (Object.keys(e).filter((e) => e !== n && e !== "discriminator" && !e.startsWith("x-") && !Mn.has(e)).length > 0) return;
1415
+ 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" || Mn.has(e));
1416
+ if (!r.every((e) => w(e) || i(e))) return;
1417
+ let a = r.map((t) => w(t) ? this.memberType(e, n, t) : "null");
1401
1418
  return [...new Set(a)].join(n === "allOf" ? " & " : " | ");
1402
1419
  }
1403
1420
  memberType(e, t, n) {
1404
1421
  let r = this.type(n), i = e.discriminator;
1405
- if (t === "allOf" || !i?.propertyName || !C(n)) return r;
1406
- let a = we(n), o = Object.entries(i.mapping ?? {}).filter(([, e]) => e === n.$ref || e === a).map(([e]) => e), s = (o.length > 0 ? o : [a]).map((e) => x(e)).join(" | ");
1407
- return `(${r} & { ${b(i.propertyName)}: ${s} })`;
1422
+ if (t === "allOf" || !i?.propertyName || !w(n)) return r;
1423
+ let a = D(n), o = Object.entries(i.mapping ?? {}).filter(([, e]) => e === n.$ref || e === a).map(([e]) => e), s = (o.length > 0 ? o : [a]).map((e) => S(e)).join(" | ");
1424
+ return `(${r} & { ${x(i.propertyName)}: ${s} })`;
1408
1425
  }
1409
1426
  };
1410
1427
  function Y(e, t) {
1411
- let n = new In(e);
1428
+ let n = new Rn(e);
1412
1429
  return {
1413
1430
  text: t(n),
1414
1431
  imports: n.imports()
1415
1432
  };
1416
1433
  }
1417
- function Ln(e, t) {
1434
+ function zn(e, t) {
1418
1435
  return Y(t, (t) => t.type(e));
1419
1436
  }
1420
- function Rn(e, t) {
1437
+ function Bn(e, t) {
1421
1438
  return Y(t, (t) => t.additionalProperties(e));
1422
1439
  }
1423
- function zn(e, t) {
1440
+ function Vn(e, t) {
1424
1441
  return Y(t, (t) => t.additionalPropertyType(e));
1425
1442
  }
1426
- function Bn(e, t) {
1443
+ function Hn(e, t) {
1427
1444
  return Y(t, (t) => t.requiredAdditionalPropertyType(e));
1428
1445
  }
1429
- function Vn(e, t) {
1446
+ function Un(e, t) {
1430
1447
  return Y(t, (t) => t.mapValueType(e));
1431
1448
  }
1432
1449
  //#endregion
1433
1450
  //#region src/emitters/decorators.ts
1434
- var Hn = "@ahoo-wang/fetcher", Un = ["ContentTypeValues", "ResultExtractors"], Wn = "@ahoo-wang/fetcher-decorator", Gn = [
1451
+ var Wn = "@ahoo-wang/fetcher", Gn = ["ContentTypeValues", "ResultExtractors"], Kn = "@ahoo-wang/fetcher-decorator", qn = [
1435
1452
  "ApiMetadata",
1436
1453
  "ApiMetadataCapable",
1437
1454
  "ParameterRequest",
@@ -1448,20 +1465,20 @@ var Hn = "@ahoo-wang/fetcher", Un = ["ContentTypeValues", "ResultExtractors"], W
1448
1465
  "header",
1449
1466
  "body",
1450
1467
  "autoGeneratedError"
1451
- ], Kn = {
1468
+ ], Jn = {
1452
1469
  type: "Promise<Response>",
1453
1470
  metadata: "{resultExtractor: ResultExtractors.Response }"
1454
- }, qn = {
1471
+ }, Yn = {
1455
1472
  type: "Promise<string>",
1456
1473
  metadata: "{resultExtractor: ResultExtractors.Text }"
1457
- }, Jn = "{\n headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },\n resultExtractor: JsonEventStreamResultExtractor,\n}", Yn = "COMMAND_STREAM_ENDPOINT";
1458
- function Xn(e) {
1459
- H(e, Hn, Un);
1474
+ }, Xn = "{\n headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },\n resultExtractor: JsonEventStreamResultExtractor,\n}", Zn = "COMMAND_STREAM_ENDPOINT";
1475
+ function Qn(e) {
1476
+ V(e, Wn, Gn);
1460
1477
  }
1461
- function Zn(e) {
1462
- H(e, Wn, Gn);
1478
+ function $n(e) {
1479
+ V(e, Kn, qn);
1463
1480
  }
1464
- function Qn(e, t, n = [], r = [], i) {
1481
+ function er(e, t, n = [], r = [], i) {
1465
1482
  return t.add({
1466
1483
  kind: o.Class,
1467
1484
  name: e,
@@ -1474,7 +1491,7 @@ function Qn(e, t, n = [], r = [], i) {
1474
1491
  }]
1475
1492
  });
1476
1493
  }
1477
- function $n(e, t) {
1494
+ function tr(e, t) {
1478
1495
  if (e.implements = [...[e.implements ?? []].flat(), "ApiMetadataCapable"], e.ctors ??= [], t === void 0) {
1479
1496
  e.ctors.push({ parameters: [{
1480
1497
  name: "apiMetadata",
@@ -1499,41 +1516,41 @@ function $n(e, t) {
1499
1516
  docs: ["@param apiMetadata - Merged over the defaults, so passing only a `fetcher` keeps the base path."]
1500
1517
  });
1501
1518
  }
1502
- function er(e) {
1519
+ function nr(e) {
1503
1520
  return e === "delete" ? "del" : e;
1504
1521
  }
1505
- var tr = "@ahoo-wang/fetcher-eventstream";
1506
- function nr(e) {
1507
- H(e, tr, ["JsonEventStreamResultExtractor", "JsonServerSentEventStream"]);
1522
+ var rr = "@ahoo-wang/fetcher-eventstream";
1523
+ function ir(e) {
1524
+ V(e, rr, ["JsonEventStreamResultExtractor", "JsonServerSentEventStream"]);
1508
1525
  }
1509
1526
  //#endregion
1510
1527
  //#region src/emitters/apiClients.ts
1511
- function rr(e, t) {
1528
+ function ar(e, t) {
1512
1529
  let n = t.modules.module(e.file);
1513
- Xn(n), Zn(n), nr(n);
1514
- let r = Qn(e.className, n);
1515
- K(r, [e.description]);
1530
+ Qn(n), $n(n), ir(n);
1531
+ let r = er(e.className, n);
1532
+ G(r, [e.description]);
1516
1533
  let i;
1517
- e.basePath && (G(n, t.outputDir, e.basePath.alias, e.basePath.constantName), i = `basePath: ${e.basePath.constantName}`), $n(r, i);
1518
- let a = ir(e.className, n, t);
1519
- for (let t of e.methods) (r.methods ??= []).push(ar(t, a));
1534
+ e.basePath && (W(n, t.outputDir, e.basePath.alias, e.basePath.constantName), i = `basePath: ${e.basePath.constantName}`), tr(r, i);
1535
+ let a = or(e.className, n, t);
1536
+ for (let t of e.methods) (r.methods ??= []).push(sr(t, a));
1520
1537
  }
1521
- function ir(e, t, n) {
1538
+ function or(e, t, n) {
1522
1539
  let r = {
1523
1540
  context: n.types,
1524
1541
  owner: { name: e },
1525
- specifierOf: (e) => W(t, n.outputDir, e),
1542
+ specifierOf: (e) => U(t, n.outputDir, e),
1526
1543
  imports: t.imports
1527
1544
  };
1528
1545
  return {
1529
1546
  module: t,
1530
1547
  resolveType(e) {
1531
- let n = Ln(e, r);
1548
+ let n = zn(e, r);
1532
1549
  return t.imports.apply(n.imports), n.text;
1533
1550
  }
1534
1551
  };
1535
1552
  }
1536
- function ar(e, t) {
1553
+ function sr(e, t) {
1537
1554
  let n = [], r = [];
1538
1555
  for (let i of e.parameters) (i.required ? n : r).push({
1539
1556
  name: i.name,
@@ -1541,12 +1558,12 @@ function ar(e, t) {
1541
1558
  hasQuestionToken: !i.required,
1542
1559
  decorators: [{
1543
1560
  name: i.location,
1544
- arguments: [x(i.parameterName)]
1561
+ arguments: [S(i.parameterName)]
1545
1562
  }]
1546
1563
  });
1547
1564
  e.body && (e.body.required ? n : r).push({
1548
1565
  name: e.body.name,
1549
- type: or(e.body, t),
1566
+ type: cr(e.body, t),
1550
1567
  hasQuestionToken: !e.body.required,
1551
1568
  decorators: [{
1552
1569
  name: "body",
@@ -1574,24 +1591,24 @@ function ar(e, t) {
1574
1591
  arguments: []
1575
1592
  }]
1576
1593
  }
1577
- ], a = sr(e.returns, t), o = x(e.path), s = {
1594
+ ], a = lr(e.returns, t), o = S(e.path), s = {
1578
1595
  name: e.name,
1579
1596
  decorators: [{
1580
- name: er(e.httpMethod),
1597
+ name: nr(e.httpMethod),
1581
1598
  arguments: a.metadata ? [o, a.metadata] : [o]
1582
1599
  }],
1583
1600
  parameters: i,
1584
1601
  returnType: a.type,
1585
1602
  statements: [`throw autoGeneratedError(${i.map((e) => e.name).join(",")});`]
1586
1603
  };
1587
- return K(s, [...e.docs]), s;
1604
+ return G(s, [...e.docs]), s;
1588
1605
  }
1589
- function or(e, t) {
1606
+ function cr(e, t) {
1590
1607
  let { content: n } = e;
1591
1608
  switch (n.kind) {
1592
1609
  case "json": {
1593
1610
  let e = t.resolveType(n.schema), r = n.optionalFields;
1594
- return r.length === 0 || /[|&]/.test(e) || e === "any" ? e : (H(t.module, Hn, ["PartialBy"]), `PartialBy<${e}, ${r.map(x).join(" | ")}>`);
1611
+ return r.length === 0 || /[|&]/.test(e) || e === "any" ? e : (V(t.module, Wn, ["PartialBy"]), `PartialBy<${e}, ${r.map(S).join(" | ")}>`);
1595
1612
  }
1596
1613
  case "formData": return "FormData";
1597
1614
  case "urlEncoded": return "URLSearchParams";
@@ -1599,31 +1616,31 @@ function or(e, t) {
1599
1616
  case "binary": return "BodyInit";
1600
1617
  }
1601
1618
  }
1602
- function sr(e, t) {
1619
+ function lr(e, t) {
1603
1620
  switch (e.kind) {
1604
1621
  case "json": {
1605
1622
  let n = t.resolveType(e.schema);
1606
- return e.wildcard && n === "string" ? qn : { type: `Promise<${n}>` };
1623
+ return e.wildcard && n === "string" ? Yn : { type: `Promise<${n}>` };
1607
1624
  }
1608
1625
  case "eventStream": {
1609
1626
  if (!e.items) return {
1610
1627
  type: "Promise<JsonServerSentEventStream<any>>",
1611
- metadata: Jn
1628
+ metadata: Xn
1612
1629
  };
1613
1630
  let n = t.resolveType(e.items);
1614
1631
  return {
1615
1632
  type: `Promise<JsonServerSentEventStream<${e.serverSentEvent ? `${n}['data']` : n}>>`,
1616
- metadata: Jn
1633
+ metadata: Xn
1617
1634
  };
1618
1635
  }
1619
- case "text": return qn;
1620
- case "response": return Kn;
1636
+ case "text": return Yn;
1637
+ case "response": return Jn;
1621
1638
  }
1622
1639
  }
1623
1640
  //#endregion
1624
1641
  //#region src/emitters/commandClients.ts
1625
- var cr = "DEFAULT_COMMAND_CLIENT_OPTIONS";
1626
- function lr(e, t) {
1642
+ var ur = "DEFAULT_COMMAND_CLIENT_OPTIONS";
1643
+ function dr(e, t) {
1627
1644
  let n = e.commandClient;
1628
1645
  if (n.commands.length === 0) return;
1629
1646
  let r = t.modules.module(n.file);
@@ -1631,51 +1648,51 @@ function lr(e, t) {
1631
1648
  kind: o.Enum,
1632
1649
  name: n.endpointPathsName,
1633
1650
  isExported: !0,
1634
- members: pn(n.commands.map((e) => ({
1651
+ members: mn(n.commands.map((e) => ({
1635
1652
  name: e.endpointMember,
1636
- initializer: x(e.path)
1653
+ initializer: S(e.path)
1637
1654
  })))
1638
1655
  });
1639
- let i = /* @__PURE__ */ new Set(), a = n.commands.map((e) => ur(r, t.outputDir, e, i));
1640
- G(r, t.outputDir, e.context.alias, e.context.constantName), r.add({
1656
+ let i = /* @__PURE__ */ new Set(), a = n.commands.map((e) => fr(r, t.outputDir, e, i));
1657
+ W(r, t.outputDir, e.context.alias, e.context.constantName), r.add({
1641
1658
  kind: o.VariableStatement,
1642
1659
  declarationKind: c.Const,
1643
1660
  declarations: [{
1644
- name: cr,
1661
+ name: ur,
1645
1662
  type: "ApiMetadata",
1646
1663
  initializer: `{
1647
1664
  basePath: ${e.context.constantName}
1648
1665
  }`
1649
1666
  }],
1650
1667
  isExported: !1
1651
- }), H(r, I, [
1668
+ }), V(r, L, [
1652
1669
  "CommandRequest",
1653
1670
  "CommandResult",
1654
1671
  "CommandResultEventStream",
1655
1672
  "CommandBody",
1656
- Yn
1657
- ]), H(r, "@ahoo-wang/fetcher", ["PartialBy"]), Zn(r);
1658
- let s = Qn(n.className, r, [], ["R = CommandResult"]);
1659
- $n(s, `...${cr}`);
1673
+ Zn
1674
+ ]), V(r, "@ahoo-wang/fetcher", ["PartialBy"]), $n(r);
1675
+ let s = er(n.className, r, [], ["R = CommandResult"]);
1676
+ tr(s, `...${ur}`);
1660
1677
  for (let [e, t] of n.commands.entries()) {
1661
- let r = dr(t, a[e]), i = {
1678
+ let r = pr(t, a[e]), i = {
1662
1679
  name: t.methodName,
1663
1680
  decorators: [{
1664
- name: er(t.httpMethod),
1681
+ name: nr(t.httpMethod),
1665
1682
  arguments: [`${n.endpointPathsName}.${t.endpointMember}`]
1666
1683
  }],
1667
1684
  parameters: r,
1668
1685
  returnType: "Promise<R>",
1669
1686
  statements: `throw autoGeneratedError(${r.map((e) => e.name).join(",")});`
1670
1687
  };
1671
- (s.methods ??= []).push(i), K(i, [...t.docs]);
1688
+ (s.methods ??= []).push(i), G(i, [...t.docs]);
1672
1689
  }
1673
- Qn(n.streamClassName, r, ["''", Yn], [], `${n.className}<CommandResultEventStream>`);
1690
+ er(n.streamClassName, r, ["''", Zn], [], `${n.className}<CommandResultEventStream>`);
1674
1691
  }
1675
- function ur(e, t, n, r) {
1676
- if (n.body.path === "@ahoo-wang/wow-client") return H(e, I, [n.typeName]), n.typeName;
1677
- U(e, t, n.body);
1678
- let i = n.body.name, a = n.optionalFields.map(x).join(" | ");
1692
+ function fr(e, t, n, r) {
1693
+ if (n.body.path === "@ahoo-wang/wow-client") return V(e, L, [n.typeName]), n.typeName;
1694
+ H(e, t, n.body);
1695
+ let i = n.body.name, a = n.optionalFields.map(S).join(" | ");
1679
1696
  a !== "" && (i = `PartialBy<${i},${a}>`);
1680
1697
  let s = `CommandBody<${i}>`;
1681
1698
  return n.typeName === void 0 ? s : r.has(n.typeName) ? n.typeName : (r.add(n.typeName), e.add({
@@ -1685,7 +1702,7 @@ function ur(e, t, n, r) {
1685
1702
  isExported: !0
1686
1703
  }), n.typeName);
1687
1704
  }
1688
- function dr(e, t) {
1705
+ function pr(e, t) {
1689
1706
  return [
1690
1707
  ...e.pathParameters.map((e) => ({
1691
1708
  name: e.name,
@@ -1693,7 +1710,7 @@ function dr(e, t) {
1693
1710
  hasQuestionToken: !1,
1694
1711
  decorators: [{
1695
1712
  name: "path",
1696
- arguments: [x(e.pathName)]
1713
+ arguments: [S(e.pathName)]
1697
1714
  }]
1698
1715
  })),
1699
1716
  {
@@ -1718,13 +1735,13 @@ function dr(e, t) {
1718
1735
  }
1719
1736
  //#endregion
1720
1737
  //#region src/emitters/models.ts
1721
- function fr(e) {
1722
- return Dn(e, {
1723
- ofKey: (e) => R(e),
1724
- ofReference: Pt
1738
+ function mr(e) {
1739
+ return kn(e, {
1740
+ ofKey: (e) => z(e),
1741
+ ofReference: Nt
1725
1742
  });
1726
1743
  }
1727
- function pr(e, t) {
1744
+ function hr(e, t) {
1728
1745
  let n = t.modules.module(e.file);
1729
1746
  if (e.emptyMessageBody) {
1730
1747
  xn(n.add({
@@ -1735,20 +1752,20 @@ function pr(e, t) {
1735
1752
  }), e.docSchema, e.key, t.schemaDocs === "full");
1736
1753
  return;
1737
1754
  }
1738
- new hr(e, n, t).write();
1755
+ new _r(e, n, t).write();
1739
1756
  }
1740
- function mr(e) {
1757
+ function gr(e) {
1741
1758
  let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map();
1742
1759
  for (let r of e) {
1743
- let e = _e(r), i = [e];
1760
+ let e = ge(r), i = [e];
1744
1761
  /^\d/.test(r) || i.push(r);
1745
1762
  let a = i.find((e) => !t.has(e));
1746
1763
  for (let n = 2; a === void 0; n++) t.has(`${e}_${n}`) || (a = `${e}_${n}`);
1747
- t.add(a), n.set(r, b(a));
1764
+ t.add(a), n.set(r, x(a));
1748
1765
  }
1749
1766
  return n;
1750
1767
  }
1751
- var hr = class {
1768
+ var _r = class {
1752
1769
  model;
1753
1770
  module;
1754
1771
  target;
@@ -1758,7 +1775,7 @@ var hr = class {
1758
1775
  this.model = e, this.module = t, this.target = n, this.modelInfo = e.info, this.components = n.types.components, this.scope = {
1759
1776
  context: n.types,
1760
1777
  owner: e.info,
1761
- specifierOf: (e) => W(t, n.outputDir, e),
1778
+ specifierOf: (e) => U(t, n.outputDir, e),
1762
1779
  imports: t.imports
1763
1780
  };
1764
1781
  }
@@ -1768,19 +1785,19 @@ var hr = class {
1768
1785
  }
1769
1786
  process() {
1770
1787
  let { schema: e } = this.model;
1771
- return C(e) ? this.processTypeAlias(e) : M(e) ? this.processEnum(e) : e.const !== void 0 || e.nullable && e.type || N(e) && (e.type || e.properties || e.required) ? this.processTypeAlias(e) : Be(e) ? this.processInterface(e) : Ke(e) && typeof e.additionalProperties == "object" && !Je(e) && !e.required?.length ? this.processIndexSignature(e) : Ve(e) ? this.processArray(e) : N(e) ? this.processComposition(e) : this.processTypeAlias(e);
1788
+ return w(e) ? this.processTypeAlias(e) : N(e) ? this.processEnum(e) : e.const !== void 0 || e.nullable && e.type || P(e) && (e.type || e.properties || e.required) ? this.processTypeAlias(e) : ze(e) ? this.processInterface(e) : Ge(e) && typeof e.additionalProperties == "object" && !F(e) && !e.required?.length ? this.processIndexSignature(e) : Be(e) ? this.processArray(e) : P(e) ? this.processComposition(e) : this.processTypeAlias(e);
1772
1789
  }
1773
1790
  scope;
1774
1791
  emit(e) {
1775
1792
  return this.module.imports.apply(e.imports), e.text;
1776
1793
  }
1777
1794
  resolveType(e) {
1778
- return this.emit(Ln(e, this.scope));
1795
+ return this.emit(zn(e, this.scope));
1779
1796
  }
1780
1797
  processEnum(e) {
1781
- let t = ze(e);
1798
+ let t = Re(e);
1782
1799
  if (t) {
1783
- let e = mr(Object.keys(t));
1800
+ let e = gr(Object.keys(t));
1784
1801
  this.module.add({
1785
1802
  kind: o.Enum,
1786
1803
  name: this.modelInfo.name + "EnumText",
@@ -1791,8 +1808,8 @@ var hr = class {
1791
1808
  }))
1792
1809
  });
1793
1810
  }
1794
- let n = [...new Set(e.enum.filter((e) => typeof e == "string"))], r = mr(n);
1795
- return N(e) || e.const !== void 0 || e.type !== void 0 && e.type !== "string" || e.enum.some((e) => typeof e != "string") ? (n.length && this.module.add({
1811
+ let n = [...new Set(e.enum.filter((e) => typeof e == "string"))], r = gr(n);
1812
+ return P(e) || e.const !== void 0 || e.type !== void 0 && e.type !== "string" || e.enum.some((e) => typeof e != "string") ? (n.length && this.module.add({
1796
1813
  kind: o.VariableStatement,
1797
1814
  declarationKind: c.Const,
1798
1815
  isExported: !0,
@@ -1816,14 +1833,14 @@ var hr = class {
1816
1833
  }
1817
1834
  addPropertyToInterface(e, t, n) {
1818
1835
  let r = {
1819
- name: b(t),
1836
+ name: x(t),
1820
1837
  type: this.resolveType(n),
1821
- isReadonly: Xe(n)
1838
+ isReadonly: Je(n)
1822
1839
  };
1823
1840
  (e.properties ??= []).push(r), bn(r, n);
1824
1841
  }
1825
1842
  processInterface(e) {
1826
- if (Nn(e, this.components)) return this.processTypeAlias(e);
1843
+ if (Fn(e, this.components)) return this.processTypeAlias(e);
1827
1844
  let t = [], n = this.module.add({
1828
1845
  kind: o.Interface,
1829
1846
  name: this.modelInfo.name,
@@ -1834,17 +1851,17 @@ var hr = class {
1834
1851
  this.addPropertyToInterface(n, e, t);
1835
1852
  });
1836
1853
  for (let n of e.required ?? []) Object.hasOwn(r, n) || t.push({
1837
- name: b(n),
1838
- type: this.emit(Bn(e, this.scope))
1854
+ name: x(n),
1855
+ type: this.emit(Hn(e, this.scope))
1839
1856
  });
1840
- return this.emit(Rn(e, this.scope)) && t.push(mn(this.emit(zn(e, this.scope)), ["Additional properties"])), n;
1857
+ return this.emit(Bn(e, this.scope)) && t.push(hn(this.emit(Vn(e, this.scope)), ["Additional properties"])), n;
1841
1858
  }
1842
1859
  processArray(e) {
1843
1860
  let t = this.resolveType(e.items);
1844
1861
  return this.module.add({
1845
1862
  kind: o.TypeAlias,
1846
1863
  name: this.modelInfo.name,
1847
- type: Ge(t),
1864
+ type: We(t),
1848
1865
  isExported: !0
1849
1866
  });
1850
1867
  }
@@ -1853,7 +1870,7 @@ var hr = class {
1853
1870
  kind: o.Interface,
1854
1871
  name: this.modelInfo.name,
1855
1872
  isExported: !0,
1856
- properties: [mn(this.emit(Vn(e, this.scope)))]
1873
+ properties: [hn(this.emit(Un(e, this.scope)))]
1857
1874
  });
1858
1875
  }
1859
1876
  processComposition(e) {
@@ -1872,22 +1889,22 @@ var hr = class {
1872
1889
  isExported: !0
1873
1890
  });
1874
1891
  }
1875
- }, gr = "DEFAULT_QUERY_CLIENT_OPTIONS";
1876
- function _r(e, t) {
1892
+ }, vr = "DEFAULT_QUERY_CLIENT_OPTIONS";
1893
+ function yr(e, t) {
1877
1894
  let n = e.queryClient, r = t.modules.module(n.file);
1878
- H(r, I, [
1895
+ V(r, L, [
1879
1896
  "QueryClientFactory",
1880
1897
  "QueryClientOptions",
1881
1898
  "ResourceAttributionPathSpec"
1882
- ]), G(r, t.outputDir, e.context.alias, e.context.constantName), r.add({
1899
+ ]), W(r, t.outputDir, e.context.alias, e.context.constantName), r.add({
1883
1900
  kind: o.VariableStatement,
1884
1901
  declarationKind: c.Const,
1885
1902
  declarations: [{
1886
- name: gr,
1903
+ name: vr,
1887
1904
  type: "QueryClientOptions",
1888
1905
  initializer: `{
1889
1906
  contextAlias: ${e.context.constantName},
1890
- aggregateName: ${x(n.resourceName)},
1907
+ aggregateName: ${S(n.resourceName)},
1891
1908
  resourceAttribution: ${n.resourceAttribution},
1892
1909
  }`
1893
1910
  }],
@@ -1896,61 +1913,61 @@ function _r(e, t) {
1896
1913
  kind: o.Enum,
1897
1914
  name: n.eventTitlesName,
1898
1915
  isExported: !0,
1899
- members: pn(n.events.map((e) => ({
1916
+ members: mn(n.events.map((e) => ({
1900
1917
  name: e.memberName,
1901
- initializer: x(e.title)
1918
+ initializer: S(e.title)
1902
1919
  })))
1903
1920
  });
1904
- for (let e of n.events) U(r, t.outputDir, e.body);
1921
+ for (let e of n.events) H(r, t.outputDir, e.body);
1905
1922
  r.add({
1906
1923
  kind: o.TypeAlias,
1907
1924
  isExported: !0,
1908
1925
  name: n.eventTypeName,
1909
1926
  type: n.events.map((e) => e.body.name).join(" | ") || "never"
1910
- }), U(r, t.outputDir, n.state), U(r, t.outputDir, n.fields), r.add({
1927
+ }), H(r, t.outputDir, n.state), H(r, t.outputDir, n.fields), r.add({
1911
1928
  kind: o.VariableStatement,
1912
1929
  declarationKind: c.Const,
1913
1930
  declarations: [{
1914
1931
  name: n.factoryName,
1915
- initializer: `new QueryClientFactory<${n.state.name}, \`\${${n.fields.name}}\`, ${n.eventTypeName}>(${gr})`
1932
+ initializer: `new QueryClientFactory<${n.state.name}, \`\${${n.fields.name}}\`, ${n.eventTypeName}>(${vr})`
1916
1933
  }],
1917
1934
  isExported: !0
1918
1935
  });
1919
1936
  }
1920
1937
  //#endregion
1921
1938
  //#region src/emitters/emit.ts
1922
- function vr(e, t) {
1923
- e.contexts.forEach((e) => yr(e, t)), e.models.forEach((e) => pr(e, t)), e.aggregates.forEach((e) => _r(e, t)), e.aggregates.forEach((e) => lr(e, t)), e.apiClients.forEach((e) => rr(e, t));
1939
+ function br(e, t) {
1940
+ e.contexts.forEach((e) => xr(e, t)), e.models.forEach((e) => hr(e, t)), e.aggregates.forEach((e) => yr(e, t)), e.aggregates.forEach((e) => dr(e, t)), e.apiClients.forEach((e) => ar(e, t));
1924
1941
  }
1925
- function yr(e, t) {
1926
- t.modules.module(e.file).add(`export const ${e.constantName} = ${x(e.alias)};`);
1942
+ function xr(e, t) {
1943
+ t.modules.module(e.file).add(`export const ${e.constantName} = ${S(e.alias)};`);
1927
1944
  }
1928
1945
  //#endregion
1929
1946
  //#region src/emitters/indexFiles.ts
1930
- function br(e, t) {
1947
+ function Sr(e, t) {
1931
1948
  let n = [];
1932
- return xr(e, t, n), n;
1949
+ return Cr(e, t, n), n;
1933
1950
  }
1934
- function xr(e, t, n) {
1951
+ function Cr(e, t, n) {
1935
1952
  let r = [];
1936
1953
  for (let t of e.getSourceFiles()) {
1937
1954
  let e = t.getBaseName();
1938
1955
  e.endsWith(".ts") && e !== "index.ts" && r.push({
1939
1956
  specifier: `./${t.getBaseNameWithoutExtension()}.js`,
1940
- exports: Cr(t)
1957
+ exports: Tr(t)
1941
1958
  });
1942
1959
  }
1943
1960
  for (let i of e.getDirectories()) {
1944
- let e = xr(i, t, n);
1961
+ let e = Cr(i, t, n);
1945
1962
  e && r.push({
1946
1963
  specifier: `./${i.getBaseName()}/index.js`,
1947
1964
  exports: e
1948
1965
  });
1949
1966
  }
1950
1967
  let i = e.getPath();
1951
- return r.length === 0 ? e.getProject().getSourceFile(`${i}/index.ts`) ? /* @__PURE__ */ new Map() : void 0 : Sr(i, r, t, n);
1968
+ return r.length === 0 ? e.getProject().getSourceFile(`${i}/index.ts`) ? /* @__PURE__ */ new Map() : void 0 : wr(i, r, t, n);
1952
1969
  }
1953
- function Sr(e, t, n, r) {
1970
+ function wr(e, t, n, r) {
1954
1971
  let i = /* @__PURE__ */ new Map();
1955
1972
  for (let e of t) for (let t of e.exports.keys()) i.set(t, [...i.get(t) ?? [], e.specifier]);
1956
1973
  let a = [...i].filter(([, e]) => e.length > 1).map(([e]) => e).sort();
@@ -1959,7 +1976,7 @@ function Sr(e, t, n, r) {
1959
1976
  o.removeText();
1960
1977
  let s = /* @__PURE__ */ new Map();
1961
1978
  for (let e of t) {
1962
- let t = [...e.exports].filter(([e]) => !a.includes(e)).sort(([e], [t]) => S(e, t));
1979
+ let t = [...e.exports].filter(([e]) => !a.includes(e)).sort(([e], [t]) => C(e, t));
1963
1980
  t.forEach(([e, t]) => s.set(e, t)), t.length === e.exports.size ? o.addExportDeclaration({ moduleSpecifier: e.specifier }) : t.length > 0 && o.addExportDeclaration({
1964
1981
  moduleSpecifier: e.specifier,
1965
1982
  namedExports: t.map(([e, t]) => ({
@@ -1970,14 +1987,14 @@ function Sr(e, t, n, r) {
1970
1987
  }
1971
1988
  return o.getStatements().length === 0 && o.addStatements("export {};"), s;
1972
1989
  }
1973
- function Cr(e) {
1990
+ function Tr(e) {
1974
1991
  let t = /* @__PURE__ */ new Map();
1975
1992
  for (let [r, i] of e.getExportedDeclarations()) t.set(r, i.every((e) => n.isInterfaceDeclaration(e) || n.isTypeAliasDeclaration(e)));
1976
1993
  return t;
1977
1994
  }
1978
1995
  //#endregion
1979
1996
  //#region src/finalize/typeOnlyImports.ts
1980
- function wr(e) {
1997
+ function Er(e) {
1981
1998
  let t = e;
1982
1999
  for (let e = t.getParent(); e; t = e, e = e.getParent()) {
1983
2000
  if (n.isQualifiedName(e)) {
@@ -1996,7 +2013,7 @@ function wr(e) {
1996
2013
  }
1997
2014
  return !1;
1998
2015
  }
1999
- function Tr(e) {
2016
+ function Dr(e) {
2000
2017
  let t = e.getImportDeclarations().filter((e) => !e.getDefaultImport() && !e.getNamespaceImport() && e.getNamedImports().length > 0);
2001
2018
  if (t.length === 0) return [];
2002
2019
  let r = new Set(t.flatMap((e) => e.getNamedImports().map((e) => (e.getAliasNode() ?? e.getNameNode()).getText()))), i = /* @__PURE__ */ new Set();
@@ -2005,16 +2022,16 @@ function Tr(e) {
2005
2022
  t.skip();
2006
2023
  return;
2007
2024
  }
2008
- if (n.isIdentifier(e) && r.has(e.getText()) && !wr(e)) {
2025
+ if (n.isIdentifier(e) && r.has(e.getText()) && !Er(e)) {
2009
2026
  let t = e.getSymbol();
2010
2027
  t && i.add(t.compilerSymbol);
2011
2028
  }
2012
- }), t.map((e) => Er(e, (e) => {
2029
+ }), t.map((e) => Or(e, (e) => {
2013
2030
  let t = e.getSymbol();
2014
2031
  return !!t && !i.has(t.compilerSymbol);
2015
2032
  }));
2016
2033
  }
2017
- function Er(e, t) {
2034
+ function Or(e, t) {
2018
2035
  let n = e.getNamedImports(), r = n.map(t), i = r.every(Boolean);
2019
2036
  return () => {
2020
2037
  n.forEach((e, t) => {
@@ -2023,13 +2040,13 @@ function Er(e, t) {
2023
2040
  }), e.isTypeOnly() !== i && e.setIsTypeOnly(i);
2024
2041
  };
2025
2042
  }
2026
- function Dr(e) {
2027
- let t = e.flatMap(Tr);
2043
+ function kr(e) {
2044
+ let t = e.flatMap(Dr);
2028
2045
  for (let e of t) e();
2029
2046
  }
2030
2047
  //#endregion
2031
2048
  //#region src/finalize/verification.ts
2032
- var Or = /* @__PURE__ */ new Set([
2049
+ var Ar = /* @__PURE__ */ new Set([
2033
2050
  2300,
2034
2051
  2304,
2035
2052
  2308,
@@ -2039,10 +2056,10 @@ var Or = /* @__PURE__ */ new Set([
2039
2056
  2503,
2040
2057
  2552
2041
2058
  ]);
2042
- function kr(e) {
2059
+ function jr(e) {
2043
2060
  let t = [];
2044
2061
  for (let n of e) for (let e of n.getPreEmitDiagnostics()) {
2045
- if (!Or.has(e.getCode()) || e.getSourceFile() !== n) continue;
2062
+ if (!Ar.has(e.getCode()) || e.getSourceFile() !== n) continue;
2046
2063
  let r = l.flattenDiagnosticMessageText(e.compilerObject.messageText, " ");
2047
2064
  t.push(`${n.getFilePath()}:${e.getLineNumber() ?? 0} TS${e.getCode()} ${r}`);
2048
2065
  }
@@ -2050,29 +2067,29 @@ function kr(e) {
2050
2067
  }
2051
2068
  //#endregion
2052
2069
  //#region src/finalize/finalize.ts
2053
- var Ar = "// Code generated by wow-generator. DO NOT EDIT.\n\n", jr = {
2070
+ var Mr = "// Code generated by wow-generator. DO NOT EDIT.\n\n", Nr = {
2054
2071
  indentSize: 2,
2055
2072
  tabSize: 2,
2056
2073
  convertTabsToSpaces: !0,
2057
2074
  semicolons: "insert",
2058
2075
  insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: !0
2059
2076
  };
2060
- function Mr(e, t) {
2077
+ function Pr(e, t) {
2061
2078
  e.forEach((n, r) => {
2062
- t.debug(`Optimizing file [${n.getFilePath()}] - ${r + 1}/${e.length}`), n.formatText(jr), n.organizeImports(jr);
2063
- }), Dr(e), kr(e);
2064
- for (let t of e) t.insertText(0, Ar);
2079
+ t.debug(`Optimizing file [${n.getFilePath()}] - ${r + 1}/${e.length}`), n.formatText(Nr), n.organizeImports(Nr);
2080
+ }), kr(e), jr(e);
2081
+ for (let t of e) t.insertText(0, Mr);
2065
2082
  }
2066
2083
  //#endregion
2067
2084
  //#region src/input/resources.ts
2068
- var Nr = 3e4;
2069
- function Pr(e) {
2085
+ var Fr = 3e4;
2086
+ function Ir(e) {
2070
2087
  return /^https?:\/\//i.test(e);
2071
2088
  }
2072
- function Fr(e, t = {}) {
2073
- return Pr(e) ? Ir(e, t) : Rr(e);
2089
+ function Lr(e, t = {}) {
2090
+ return Ir(e) ? Rr(e, t) : Br(e);
2074
2091
  }
2075
- async function Ir(e, t = {}) {
2092
+ async function Rr(e, t = {}) {
2076
2093
  let n = t.timeoutMs ?? 3e4, r;
2077
2094
  try {
2078
2095
  let i = AbortSignal.timeout(n);
@@ -2081,7 +2098,7 @@ async function Ir(e, t = {}) {
2081
2098
  signal: t.signal ? AbortSignal.any([t.signal, i]) : i
2082
2099
  });
2083
2100
  } catch (e) {
2084
- let t = e instanceof Error && e.name === "TimeoutError" ? `no response within ${n} ms` : Lr(e);
2101
+ let t = e instanceof Error && e.name === "TimeoutError" ? `no response within ${n} ms` : zr(e);
2085
2102
  throw Error(t, { cause: e });
2086
2103
  }
2087
2104
  if (!r.ok) {
@@ -2090,12 +2107,12 @@ async function Ir(e, t = {}) {
2090
2107
  }
2091
2108
  return await r.text();
2092
2109
  }
2093
- function Lr(e) {
2110
+ function zr(e) {
2094
2111
  if (!(e instanceof Error)) return String(e);
2095
2112
  let t = e.cause;
2096
2113
  return t instanceof Error && t.message ? `${e.message} (${t.message})` : e.message;
2097
2114
  }
2098
- function Rr(e) {
2115
+ function Br(e) {
2099
2116
  return new Promise((t, n) => {
2100
2117
  te(e, "utf-8", (e, r) => {
2101
2118
  e ? n(e) : t(r);
@@ -2104,39 +2121,39 @@ function Rr(e) {
2104
2121
  }
2105
2122
  //#endregion
2106
2123
  //#region src/input/parsers.ts
2107
- async function zr(e, t) {
2124
+ async function Vr(e, t) {
2108
2125
  let n;
2109
2126
  try {
2110
- n = await Fr(e, t);
2127
+ n = await Lr(e, t);
2111
2128
  } catch (t) {
2112
- throw new g("input", `Cannot read the OpenAPI document ${e}: ${_(t)}`, { cause: t });
2129
+ throw new _("input", `Cannot read the OpenAPI document ${e}: ${v(t)}`, { cause: t });
2113
2130
  }
2114
2131
  let r;
2115
2132
  try {
2116
- r = Vr(n);
2133
+ r = Ur(n);
2117
2134
  } catch (t) {
2118
- throw new g("input", `Cannot parse the OpenAPI document ${e}: ${_(t)}`, { cause: t });
2135
+ throw new _("input", `Cannot parse the OpenAPI document ${e}: ${v(t)}`, { cause: t });
2119
2136
  }
2120
- return Br(r, e);
2137
+ return Hr(r, e);
2121
2138
  }
2122
- function Br(e, t) {
2123
- if (typeof e != "object" || !e || Array.isArray(e)) throw new g("input", `${t} is not an OpenAPI document: expected an object at the top level.`);
2139
+ function Hr(e, t) {
2140
+ if (typeof e != "object" || !e || Array.isArray(e)) throw new _("input", `${t} is not an OpenAPI document: expected an object at the top level.`);
2124
2141
  let n = e;
2125
- if (n.swagger !== void 0) throw new g("input", `${t} is a Swagger ${String(n.swagger)} document; wow-generator reads OpenAPI 3.x only. Convert it first, for example with swagger2openapi.`);
2126
- if (typeof n.openapi != "string" || !/^3\.\d+/.test(n.openapi)) throw new g("input", `${t} is not an OpenAPI 3.x document: its "openapi" field is ${n.openapi === void 0 ? "missing" : JSON.stringify(n.openapi)}.`);
2127
- if (typeof n.info != "object" || n.info === null || Array.isArray(n.info)) throw new g("input", `${t} is not a valid OpenAPI document: its "info" object is missing.`);
2142
+ if (n.swagger !== void 0) throw new _("input", `${t} is a Swagger ${String(n.swagger)} document; wow-generator reads OpenAPI 3.x only. Convert it first, for example with swagger2openapi.`);
2143
+ if (typeof n.openapi != "string" || !/^3\.\d+/.test(n.openapi)) throw new _("input", `${t} is not an OpenAPI 3.x document: its "openapi" field is ${n.openapi === void 0 ? "missing" : JSON.stringify(n.openapi)}.`);
2144
+ if (typeof n.info != "object" || n.info === null || Array.isArray(n.info)) throw new _("input", `${t} is not a valid OpenAPI document: its "info" object is missing.`);
2128
2145
  return {
2129
2146
  ...n,
2130
2147
  paths: n.paths ?? {}
2131
2148
  };
2132
2149
  }
2133
- function Vr(e) {
2134
- switch (Hr(e)) {
2150
+ function Ur(e) {
2151
+ switch (Wr(e)) {
2135
2152
  case "json": return JSON.parse(e);
2136
2153
  case "yaml": return ee(e);
2137
2154
  }
2138
2155
  }
2139
- function Hr(e) {
2156
+ function Wr(e) {
2140
2157
  let t = e.trimStart();
2141
2158
  if (t.startsWith("{") || t.startsWith("[")) return "json";
2142
2159
  if (t.startsWith("-") || t.startsWith("%YAML")) return "yaml";
@@ -2149,17 +2166,17 @@ function Hr(e) {
2149
2166
  }
2150
2167
  //#endregion
2151
2168
  //#region src/input/configuration.ts
2152
- var Ur = "./fetcher-generator.config.json";
2153
- async function Wr(e, t, n) {
2169
+ var Gr = "./fetcher-generator.config.json";
2170
+ async function Kr(e, t, n) {
2154
2171
  if (e !== void 0) return {
2155
- ...await qr({
2172
+ ...await Yr({
2156
2173
  path: e,
2157
2174
  explicit: !0
2158
2175
  }, t, n),
2159
2176
  origin: X(e)
2160
2177
  };
2161
- for (let e of [h, Ur]) {
2162
- let r = await qr({
2178
+ for (let e of [h, Gr]) {
2179
+ let r = await Yr({
2163
2180
  path: e,
2164
2181
  explicit: !1
2165
2182
  }, t, n);
@@ -2176,19 +2193,19 @@ async function Wr(e, t, n) {
2176
2193
  warnings: []
2177
2194
  };
2178
2195
  }
2179
- var Gr = ["apiClients"], Kr = ["ignorePathParameters", "methodNames"];
2180
- async function qr(e, t, n) {
2196
+ var qr = ["apiClients"], Jr = ["ignorePathParameters", "methodNames"];
2197
+ async function Yr(e, t, n) {
2181
2198
  let r = X(e.path);
2182
2199
  t.debug(`Reading configuration: ${r}`);
2183
2200
  let i;
2184
2201
  try {
2185
- i = await Fr(e.path, n);
2202
+ i = await Lr(e.path, n);
2186
2203
  } catch (n) {
2187
- if (!e.explicit && Jr(n)) {
2204
+ if (!e.explicit && Xr(n)) {
2188
2205
  t.debug(`No configuration file at ${r}`);
2189
2206
  return;
2190
2207
  }
2191
- throw new g("configuration", `Cannot read configuration ${r}: ${_(n)}`, { cause: n });
2208
+ throw new _("configuration", `Cannot read configuration ${r}: ${v(n)}`, { cause: n });
2192
2209
  }
2193
2210
  if (!i.trim()) return {
2194
2211
  config: {},
@@ -2196,17 +2213,17 @@ async function qr(e, t, n) {
2196
2213
  };
2197
2214
  let a;
2198
2215
  try {
2199
- a = Vr(i);
2216
+ a = Ur(i);
2200
2217
  } catch (e) {
2201
- throw new g("configuration", `Cannot parse configuration ${r}: ${_(e)}`, { cause: e });
2218
+ throw new _("configuration", `Cannot parse configuration ${r}: ${v(e)}`, { cause: e });
2202
2219
  }
2203
- let o = Xr(a, r);
2204
- return t.debug(`Configuration loaded from ${r}: ${Qr(o.config)}`), o;
2220
+ let o = Qr(a, r);
2221
+ return t.debug(`Configuration loaded from ${r}: ${ei(o.config)}`), o;
2205
2222
  }
2206
2223
  function X(e) {
2207
- return Pr(e) || u(e) ? e : p(e);
2224
+ return Ir(e) || u(e) ? e : p(e);
2208
2225
  }
2209
- function Jr(e) {
2226
+ function Xr(e) {
2210
2227
  return typeof e == "object" && !!e && e.code === "ENOENT";
2211
2228
  }
2212
2229
  function Z(e) {
@@ -2215,50 +2232,50 @@ function Z(e) {
2215
2232
  function Q(e) {
2216
2233
  return typeof e == "object" && !!e && !Array.isArray(e);
2217
2234
  }
2218
- function Yr(e, t, n, r, i) {
2235
+ function Zr(e, t, n, r, i) {
2219
2236
  let a = Object.keys(r).filter((e) => !i.includes(e));
2220
2237
  a.length && e.push(`Ignoring unknown ${n} option(s) in ${t}: ${a.join(", ")}. Known option(s): ${i.join(", ")}`);
2221
2238
  }
2222
- function Xr(e, t) {
2223
- if (!Q(e)) throw new g("configuration", `Configuration ${t} must be a JSON or YAML object, found ${Z(e)}`);
2239
+ function Qr(e, t) {
2240
+ if (!Q(e)) throw new _("configuration", `Configuration ${t} must be a JSON or YAML object, found ${Z(e)}`);
2224
2241
  let n = [];
2225
- return Yr(n, t, "configuration", e, Gr), Zr(e.apiClients, t, n), {
2242
+ return Zr(n, t, "configuration", e, qr), $r(e.apiClients, t, n), {
2226
2243
  config: e,
2227
2244
  warnings: n
2228
2245
  };
2229
2246
  }
2230
- function Zr(e, t, n) {
2247
+ function $r(e, t, n) {
2231
2248
  if (e !== void 0) {
2232
- if (!Q(e)) throw new g("configuration", `apiClients in ${t} must be an object keyed by tag name, found ${Z(e)}`);
2249
+ if (!Q(e)) throw new _("configuration", `apiClients in ${t} must be an object keyed by tag name, found ${Z(e)}`);
2233
2250
  for (let [r, i] of Object.entries(e)) {
2234
- if (!Q(i)) throw new g("configuration", `apiClients["${r}"] in ${t} must be an object, found ${Z(i)}`);
2235
- Yr(n, t, `apiClients["${r}"]`, i, Kr);
2251
+ if (!Q(i)) throw new _("configuration", `apiClients["${r}"] in ${t} must be an object, found ${Z(i)}`);
2252
+ Zr(n, t, `apiClients["${r}"]`, i, Jr);
2236
2253
  let { ignorePathParameters: e } = i;
2237
- if (e !== void 0 && !(Array.isArray(e) && e.every((e) => typeof e == "string"))) throw new g("configuration", `apiClients["${r}"].ignorePathParameters in ${t} must be an array of strings, found ${Z(e)}`);
2254
+ if (e !== void 0 && !(Array.isArray(e) && e.every((e) => typeof e == "string"))) throw new _("configuration", `apiClients["${r}"].ignorePathParameters in ${t} must be an array of strings, found ${Z(e)}`);
2238
2255
  let { methodNames: a } = i;
2239
2256
  if (a !== void 0) {
2240
- if (!Q(a)) throw new g("configuration", `apiClients["${r}"].methodNames in ${t} must be an object mapping operationIds to method names, found ${Z(a)}`);
2241
- for (let [e, n] of Object.entries(a)) if (typeof n != "string" || !v(n)) throw new g("configuration", `apiClients["${r}"].methodNames["${e}"] in ${t} must be a valid method name, found ${JSON.stringify(n)}`);
2257
+ if (!Q(a)) throw new _("configuration", `apiClients["${r}"].methodNames in ${t} must be an object mapping operationIds to method names, found ${Z(a)}`);
2258
+ for (let [e, n] of Object.entries(a)) if (typeof n != "string" || !y(n)) throw new _("configuration", `apiClients["${r}"].methodNames["${e}"] in ${t} must be a valid method name, found ${JSON.stringify(n)}`);
2242
2259
  }
2243
2260
  }
2244
2261
  }
2245
2262
  }
2246
- function Qr(e) {
2263
+ function ei(e) {
2247
2264
  let t = Object.keys(e.apiClients ?? {});
2248
2265
  return `apiClients=${t.length ? t.join(", ") : "none"}`;
2249
2266
  }
2250
2267
  //#endregion
2251
2268
  //#region src/openapi/document.ts
2252
- function $r(e) {
2269
+ function ti(e) {
2253
2270
  return {
2254
2271
  openAPI: e,
2255
2272
  components: e.components,
2256
- endpoints: et(e.paths, e.components)
2273
+ endpoints: Qe(e.paths, e.components)
2257
2274
  };
2258
2275
  }
2259
2276
  //#endregion
2260
2277
  //#region src/output/outputStore.ts
2261
- var ei = ".wow-generator.json", ti = ".fetcher-generator.json", ni = class e {
2278
+ var ni = ".wow-generator.json", ri = ".fetcher-generator.json", ii = class e {
2262
2279
  project;
2263
2280
  outputPath;
2264
2281
  outputDir;
@@ -2272,14 +2289,14 @@ var ei = ".wow-generator.json", ti = ".fetcher-generator.json", ni = class e {
2272
2289
  static open(t, n, r) {
2273
2290
  let i = t.getFileSystem(), a = n;
2274
2291
  n = p(i.getCurrentDirectory(), n);
2275
- let o = d(n, ti), s = i.fileExistsSync(o) ? o : void 0, c = d(n, ei);
2292
+ let o = d(n, ri), s = i.fileExistsSync(o) ? o : void 0, c = d(n, ni);
2276
2293
  !i.fileExistsSync(c) && s && (c = s);
2277
2294
  let l = /* @__PURE__ */ new Map();
2278
2295
  if (i.fileExistsSync(c)) {
2279
- let e = ri(c, i.readFileSync(c));
2296
+ let e = ai(c, i.readFileSync(c));
2280
2297
  for (let [t, r] of Object.entries(e.files)) {
2281
2298
  let e = p(n, t);
2282
- if (oi(n, e), u(t) || !t.endsWith(".ts") || typeof r != "string" || !/^[a-f0-9]{64}$/.test(r)) throw new g("output", `Invalid generated file entry in ${c}: ${t}`);
2299
+ if (ci(n, e), u(t) || !t.endsWith(".ts") || typeof r != "string" || !/^[a-f0-9]{64}$/.test(r)) throw new _("output", `Invalid generated file entry in ${c}: ${t}`);
2283
2300
  l.set(e, r);
2284
2301
  }
2285
2302
  }
@@ -2292,7 +2309,7 @@ var ei = ".wow-generator.json", ti = ".fetcher-generator.json", ni = class e {
2292
2309
  }
2293
2310
  claim(e, t = this.outputPath) {
2294
2311
  let n = B(t, e);
2295
- oi(t, n);
2312
+ ci(t, n);
2296
2313
  let r = this.project.getSourceFile(n) ?? this.project.createSourceFile(n, "", { overwrite: !0 }), i = r.getFilePath();
2297
2314
  return this.written.has(i) || (r.removeText(), this.written.add(i)), r;
2298
2315
  }
@@ -2306,12 +2323,12 @@ var ei = ".wow-generator.json", ti = ".fetcher-generator.json", ni = class e {
2306
2323
  for (let e of this.stale) !this.written.has(e) && n.has(e.toLowerCase()) && this.isUnchanged(e, this.previous.get(e)) && (await $("delete", e, () => t.delete(e)), this.stale.delete(e));
2307
2324
  let r = [...this.written].sort().map((e) => this.project.getSourceFileOrThrow(e));
2308
2325
  (await Promise.allSettled(r.map((e) => e.save()))).forEach((e, t) => {
2309
- if (e.status === "rejected") throw ai("write", r[t].getFilePath(), e.reason);
2326
+ if (e.status === "rejected") throw si("write", r[t].getFilePath(), e.reason);
2310
2327
  }), e?.throwIfAborted();
2311
2328
  for (let e of this.stale) !this.written.has(e) && this.isUnchanged(e, this.previous.get(e)) && await $("delete", e, () => t.delete(e));
2312
- let i = d(this.outputDir, ei), a = JSON.stringify({
2329
+ let i = d(this.outputDir, ni), a = JSON.stringify({
2313
2330
  version: 1,
2314
- files: Object.fromEntries(r.map((e) => [f(this.outputDir, e.getFilePath()).split(m).join("/"), ii(t.readFileSync(e.getFilePath()))]))
2331
+ files: Object.fromEntries(r.map((e) => [f(this.outputDir, e.getFilePath()).split(m).join("/"), oi(t.readFileSync(e.getFilePath()))]))
2315
2332
  }, null, 2) + "\n";
2316
2333
  await $("write", i, async () => {
2317
2334
  t.mkdirSync(this.outputDir), await t.writeFile(i, a);
@@ -2321,45 +2338,45 @@ var ei = ".wow-generator.json", ti = ".fetcher-generator.json", ni = class e {
2321
2338
  }
2322
2339
  isUnchanged(e, t) {
2323
2340
  let n = this.project.getFileSystem();
2324
- return n.fileExistsSync(e) ? (oi(n.realpathSync(this.outputDir), n.realpathSync(e)), ii(n.readFileSync(e)) === t) : !1;
2341
+ return n.fileExistsSync(e) ? (ci(n.realpathSync(this.outputDir), n.realpathSync(e)), oi(n.readFileSync(e)) === t) : !1;
2325
2342
  }
2326
2343
  };
2327
- function ri(e, t) {
2344
+ function ai(e, t) {
2328
2345
  let n = "delete it; without it this run cannot remove the stale files of the last run", r;
2329
2346
  try {
2330
2347
  r = JSON.parse(t);
2331
2348
  } catch (t) {
2332
- throw new g("output", `Cannot parse the generation manifest ${e}: ${_(t)}. Resolve the merge conflict in it if it has one, or ${n}.`, { cause: t });
2349
+ throw new _("output", `Cannot parse the generation manifest ${e}: ${v(t)}. Resolve the merge conflict in it if it has one, or ${n}.`, { cause: t });
2333
2350
  }
2334
2351
  let i = r?.version;
2335
- if (typeof i == "number" && Number.isInteger(i) && i > 1) throw new g("output", `The generation manifest ${e} was written by a newer wow-generator (manifest version ${i}); this one reads version 1. Upgrade wow-generator.`);
2336
- if (i !== 1 || !r.files || typeof r.files != "object" || Array.isArray(r.files)) throw new g("output", `Invalid generation manifest ${e}: expected "version": 1 and a "files" object. Restore it from version control, or ${n}.`);
2352
+ if (typeof i == "number" && Number.isInteger(i) && i > 1) throw new _("output", `The generation manifest ${e} was written by a newer wow-generator (manifest version ${i}); this one reads version 1. Upgrade wow-generator.`);
2353
+ if (i !== 1 || !r.files || typeof r.files != "object" || Array.isArray(r.files)) throw new _("output", `Invalid generation manifest ${e}: expected "version": 1 and a "files" object. Restore it from version control, or ${n}.`);
2337
2354
  return r;
2338
2355
  }
2339
- function ii(e) {
2356
+ function oi(e) {
2340
2357
  if (!l.sys.createSHA256Hash) throw Error("SHA-256 hashing is unavailable in this environment.");
2341
2358
  return l.sys.createSHA256Hash(e);
2342
2359
  }
2343
- function ai(e, t, n) {
2344
- return n instanceof g ? n : new g("output", `Cannot ${e} ${t}: ${_(n)}`, { cause: n });
2360
+ function si(e, t, n) {
2361
+ return n instanceof _ ? n : new _("output", `Cannot ${e} ${t}: ${v(n)}`, { cause: n });
2345
2362
  }
2346
2363
  async function $(e, t, n) {
2347
2364
  try {
2348
2365
  await n();
2349
2366
  } catch (n) {
2350
- throw ai(e, t, n);
2367
+ throw si(e, t, n);
2351
2368
  }
2352
2369
  }
2353
- function oi(e, t) {
2370
+ function ci(e, t) {
2354
2371
  let n = t.split("/").join(m), r = p(e), i = p(n), a = f(r, i);
2355
- if (a === "" || a.startsWith("..") || u(a)) throw new g("output", `Path traversal detected: "${t}" resolves outside the output directory "${e}".`);
2372
+ if (a === "" || a.startsWith("..") || u(a)) throw new _("output", `Path traversal detected: "${t}" resolves outside the output directory "${e}".`);
2356
2373
  }
2357
2374
  //#endregion
2358
2375
  //#region src/wow/resolveWowModel.ts
2359
- function si(e) {
2376
+ function li(e) {
2360
2377
  let { openAPI: t, components: n, endpoints: r } = e, i = [], a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), s = t.tags ?? [], c = new Set(s.map((e) => e.name)), l = new Set(r.flatMap((e) => e.operation.tags ?? []).filter((e) => !c.has(e))), u = /* @__PURE__ */ new Map();
2361
2378
  for (let e of [...s, ...[...l].map((e) => ({ name: e }))]) {
2362
- let t = pt(e);
2379
+ let t = ft(e);
2363
2380
  t && u.set(e.name, {
2364
2381
  aggregate: t,
2365
2382
  commands: /* @__PURE__ */ new Map(),
@@ -2374,31 +2391,31 @@ function si(e) {
2374
2391
  r || (r = {}, a.set(e.key, r));
2375
2392
  let i = t in r ? r[t] : e.schema[t];
2376
2393
  r[t] = i || n;
2377
- }, p = (e, t) => new g("specification", `Cannot read the Wow metadata of ${e.operationId}: ${t}. wow-generator reads documents from Wow ${lt} or later.`), m = (e, t) => {
2378
- let n = vt.exec(t)?.[1];
2394
+ }, p = (e, t) => new _("specification", `Cannot read the Wow metadata of ${e.operationId}: ${t}. wow-generator reads documents from Wow ${ct} or later.`), m = (e, t) => {
2395
+ let n = _t.exec(t)?.[1];
2379
2396
  n && e.forEach((e) => {
2380
2397
  e.resourceName ??= n;
2381
2398
  });
2382
2399
  }, ee = (e) => {
2383
2400
  let { operation: t, path: r } = e;
2384
2401
  if (t.operationId === "wow.command.send") return;
2385
- let a = mt(t.operationId);
2402
+ let a = pt(t.operationId);
2386
2403
  if (!a) return;
2387
- let o = F(t), s = /* @__PURE__ */ new Set();
2388
- for (; o && C(o) && o.$ref !== "#/components/responses/wow.CommandOk";) {
2389
- if (!o.$ref.startsWith(T)) return;
2390
- if (s.has(o.$ref)) throw new g("specification", `Cyclic component reference: ${o.$ref}`);
2391
- s.add(o.$ref), o = n?.responses?.[o.$ref.slice(T.length)];
2404
+ let o = tt(t), s = /* @__PURE__ */ new Set();
2405
+ for (; o && w(o) && o.$ref !== "#/components/responses/wow.CommandOk";) {
2406
+ if (!o.$ref.startsWith(E)) return;
2407
+ if (s.has(o.$ref)) throw new _("specification", `Cyclic component reference: ${o.$ref}`);
2408
+ s.add(o.$ref), o = n?.responses?.[o.$ref.slice(E.length)];
2392
2409
  }
2393
- if (!o || !C(o) || o.$ref !== "#/components/responses/wow.CommandOk") return;
2410
+ if (!o || !w(o) || o.$ref !== "#/components/responses/wow.CommandOk") return;
2394
2411
  let c = d(t);
2395
2412
  if (!t.requestBody) return;
2396
- let l = at(t, n ?? {}), u = (C(t.requestBody) ? Ee(t.requestBody, n ?? {}) : t.requestBody)?.content?.[k]?.schema;
2397
- if (!C(u)) {
2413
+ let l = it(t, n ?? {}), u = (w(t.requestBody) ? we(t.requestBody, n ?? {}) : t.requestBody)?.content?.[j]?.schema;
2414
+ if (!w(u)) {
2398
2415
  c.length > 0 && i.push(`Skipping command ${t.operationId} (${e.method.toUpperCase()} ${r}): its application/json request body is not a $ref to a component schema.`);
2399
2416
  return;
2400
2417
  }
2401
- let p = O(u, n ?? {});
2418
+ let p = A(u, n ?? {});
2402
2419
  if (!p.schema) return;
2403
2420
  f(p, "title", t.summary), f(p, "description", t.description);
2404
2421
  let m = {
@@ -2418,12 +2435,12 @@ function si(e) {
2418
2435
  if (!e.operationId?.endsWith(".snapshot_state.single")) return;
2419
2436
  let r = d(e);
2420
2437
  m(r, t);
2421
- let i = rt(e, n);
2422
- if (!C(i)) {
2438
+ let i = nt(e, n);
2439
+ if (!w(i)) {
2423
2440
  if (r.length > 0) throw p(e, "its 200 application/json response is not a $ref to the state schema");
2424
2441
  return;
2425
2442
  }
2426
- let a = O(i, n);
2443
+ let a = A(i, n);
2427
2444
  r.forEach((e) => {
2428
2445
  e.state = a;
2429
2446
  });
@@ -2431,11 +2448,11 @@ function si(e) {
2431
2448
  if (!n || !e.operationId?.endsWith(".event.list_query")) return;
2432
2449
  let t = d(e);
2433
2450
  if (t.length === 0) return;
2434
- let r = rt(e, n);
2435
- if (C(r)) return;
2451
+ let r = nt(e, n);
2452
+ if (w(r)) return;
2436
2453
  let i = r?.items;
2437
- if (!C(i)) throw p(e, "its 200 application/json response is not an array of a $ref to the event stream schema");
2438
- let a = ci(D(i, n), [
2454
+ if (!w(i)) throw p(e, "its 200 application/json response is not an array of a $ref to the event stream schema");
2455
+ let a = ui(k(i, n), [
2439
2456
  "properties",
2440
2457
  "body",
2441
2458
  "items",
@@ -2443,13 +2460,13 @@ function si(e) {
2443
2460
  ]);
2444
2461
  if (!Array.isArray(a)) throw p(e, `the event stream schema ${i.$ref} has no properties.body.items.anyOf listing the domain events`);
2445
2462
  let o = a.map((t, r) => {
2446
- let a = ci(t, [
2463
+ let a = ui(t, [
2447
2464
  "properties",
2448
2465
  "name",
2449
2466
  "const"
2450
- ]), o = ci(t, ["properties", "body"]);
2451
- if (typeof a != "string" || !C(o)) throw p(e, `domain event ${r} of ${i.$ref} needs a properties.name.const and a properties.body that is a $ref to the event schema`);
2452
- let s = O(o, n);
2467
+ ]), o = ui(t, ["properties", "body"]);
2468
+ if (typeof a != "string" || !w(o)) throw p(e, `domain event ${r} of ${i.$ref} needs a properties.name.const and a properties.body that is a $ref to the event schema`);
2469
+ let s = A(o, n);
2453
2470
  return f(s, "title", t.title), {
2454
2471
  title: t.title ?? a,
2455
2472
  name: a,
@@ -2461,52 +2478,52 @@ function si(e) {
2461
2478
  e.events.set(t.name, t);
2462
2479
  });
2463
2480
  });
2464
- }, ne = ({ operation: e, path: t }) => {
2481
+ }, g = ({ operation: e, path: t }) => {
2465
2482
  if (!n || !e.operationId?.endsWith(".snapshot.count")) return;
2466
2483
  let r = d(e);
2467
2484
  if (r.length === 0) return;
2468
2485
  m(r, t);
2469
- let i = e.requestBody ? C(e.requestBody) ? Ee(e.requestBody, n) : e.requestBody : void 0;
2486
+ let i = e.requestBody ? w(e.requestBody) ? we(e.requestBody, n) : e.requestBody : void 0;
2470
2487
  if (!i) throw p(e, "it has no request body");
2471
- let a = i[_t], o;
2488
+ let a = i[gt], o;
2472
2489
  if (a !== void 0) {
2473
- if (!C(a)) throw p(e, `${_t} must be a schema reference`);
2490
+ if (!w(a)) throw p(e, `${gt} must be a schema reference`);
2474
2491
  o = a;
2475
2492
  } else {
2476
- let t = i.content?.[k]?.schema, r = (C(t) ? D(t, n) : void 0)?.properties?.field;
2477
- if (!C(r)) throw p(e, `its request body has no ${_t}, and its condition schema has no field $ref to read the query fields from`);
2493
+ let t = i.content?.[j]?.schema, r = (w(t) ? k(t, n) : void 0)?.properties?.field;
2494
+ if (!w(r)) throw p(e, `its request body has no ${gt}, and its condition schema has no field $ref to read the query fields from`);
2478
2495
  o = r;
2479
2496
  }
2480
- let s = O(o, n);
2497
+ let s = A(o, n);
2481
2498
  r.forEach((e) => {
2482
2499
  e.fields = s;
2483
2500
  });
2484
2501
  };
2485
- for (let e of r) ee(e), te(e), h(e), ne(e);
2486
- let _ = /* @__PURE__ */ new Map();
2502
+ for (let e of r) ee(e), te(e), h(e), g(e);
2503
+ let v = /* @__PURE__ */ new Map();
2487
2504
  for (let [e, t] of u) {
2488
2505
  if (!t.state || !t.fields) {
2489
2506
  if (o.has(e)) {
2490
- let n = [t.state ? void 0 : `${e}${ht}`, t.fields ? void 0 : `${e}${gt}`].filter(Boolean);
2507
+ let n = [t.state ? void 0 : `${e}${mt}`, t.fields ? void 0 : `${e}${ht}`].filter(Boolean);
2491
2508
  i.push(`Skipping aggregate ${e}: the document has no ${n.join(" or ")} operation, so it generates neither command nor query clients for it.`);
2492
2509
  }
2493
2510
  continue;
2494
2511
  }
2495
- let n = t.aggregate.contextAlias, r = _.get(n);
2496
- r || (r = /* @__PURE__ */ new Set(), _.set(n, r)), r.add({
2512
+ let n = t.aggregate.contextAlias, r = v.get(n);
2513
+ r || (r = /* @__PURE__ */ new Set(), v.set(n, r)), r.add({
2497
2514
  ...t,
2498
2515
  resourceName: t.resourceName ?? t.aggregate.aggregateName
2499
2516
  });
2500
2517
  }
2501
2518
  return {
2502
- contextAlias: dt(t),
2503
- contexts: _,
2519
+ contextAlias: ut(t),
2520
+ contexts: v,
2504
2521
  aggregateTags: o,
2505
2522
  schemaDocOverrides: a,
2506
2523
  warnings: i
2507
2524
  };
2508
2525
  }
2509
- function ci(e, t) {
2526
+ function ui(e, t) {
2510
2527
  let n = e;
2511
2528
  for (let e of t) {
2512
2529
  if (typeof n != "object" || !n) return;
@@ -2516,14 +2533,14 @@ function ci(e, t) {
2516
2533
  }
2517
2534
  //#endregion
2518
2535
  //#region src/pipeline/seams.ts
2519
- var li = Symbol("project"), ui = Symbol("signal"), di = class {
2536
+ var di = Symbol("project"), fi = Symbol("signal"), pi = class {
2520
2537
  options;
2521
2538
  project;
2522
2539
  logger;
2523
2540
  signal;
2524
2541
  output;
2525
2542
  constructor(e) {
2526
- this.options = e, this.logger = e.logger ?? new ie(), this.signal = e[ui], this.project = e[li] ?? fi(e.tsConfigFilePath), this.project.manipulationSettings.set({
2543
+ this.options = e, this.logger = e.logger ?? new re(), this.signal = e[fi], this.project = e[di] ?? mi(e.tsConfigFilePath), this.project.manipulationSettings.set({
2527
2544
  indentationText: t.TwoSpaces,
2528
2545
  quoteKind: i.Single,
2529
2546
  useTrailingCommas: !0
@@ -2538,46 +2555,46 @@ var li = Symbol("project"), ui = Symbol("signal"), di = class {
2538
2555
  headers: n.headers,
2539
2556
  timeoutMs: n.timeoutMs,
2540
2557
  signal: t
2541
- }, o = await Wr(n.configPath, e, a);
2558
+ }, o = await Kr(n.configPath, e, a);
2542
2559
  i(o.warnings), t?.throwIfAborted(), e.debug("Parsing OpenAPI specification");
2543
- let s = await zr(n.inputPath, a);
2560
+ let s = await Vr(n.inputPath, a);
2544
2561
  t?.throwIfAborted(), e.debug("OpenAPI specification parsed successfully");
2545
- let c = be(s);
2546
- if (c.length > 0) throw new g("specification", `${n.inputPath} has ${c.length} $ref(s) that point at nothing: ${c.slice(0, 10).map(({ ref: e, location: t }) => `${e} (at ${t})`).join(", ")}${c.length > 10 ? ", …" : ""}`);
2547
- let l = $r(s);
2562
+ let c = ye(s);
2563
+ if (c.length > 0) throw new _("specification", `${n.inputPath} has ${c.length} $ref(s) that point at nothing: ${c.slice(0, 10).map(({ ref: e, location: t }) => `${e} (at ${t})`).join(", ")}${c.length > 10 ? ", …" : ""}`);
2564
+ let l = ti(s);
2548
2565
  e.debug("Resolving bounded context aggregates");
2549
- let u = si(l);
2566
+ let u = li(l);
2550
2567
  i(u.warnings), e.debug(`Resolved ${u.contexts.size} bounded context aggregates`);
2551
- let d = ni.open(this.project, n.outputDir, this.output);
2568
+ let d = ii.open(this.project, n.outputDir, this.output);
2552
2569
  this.output = d, e.debug("Analysing the document");
2553
- let f = sn(l, u, o.config);
2570
+ let f = cn(l, u, o.config);
2554
2571
  i(f.warnings), e.debug("Writing generated modules");
2555
- let p = new un((e) => d.claim(e));
2556
- vr(f.model, {
2572
+ let p = new dn((e) => d.claim(e));
2573
+ br(f.model, {
2557
2574
  modules: p,
2558
2575
  outputDir: n.outputDir,
2559
- types: fr(l.components),
2576
+ types: mr(l.components),
2560
2577
  schemaDocs: n.schemaDocs ?? "summary"
2561
2578
  }), p.build(), e.debug("Generated modules written"), d.forgetStale();
2562
2579
  let m = this.project.getDirectory(n.outputDir);
2563
- return m ? (e.debug("Generating index files"), i(br(m, (e) => d.claim("index.ts", e))), e.debug("Optimizing source files"), Mr(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"), {
2580
+ return m ? (e.debug("Generating index files"), i(Sr(m, (e) => d.claim("index.ts", e))), e.debug("Optimizing source files"), Pr(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"), {
2564
2581
  files: [...d.files].sort(),
2565
2582
  configPath: o.origin,
2566
2583
  warnings: r
2567
2584
  };
2568
2585
  }
2569
2586
  };
2570
- function fi(e) {
2587
+ function mi(e) {
2571
2588
  try {
2572
2589
  return new r({
2573
2590
  tsConfigFilePath: e,
2574
2591
  skipAddingFilesFromTsConfig: !0
2575
2592
  });
2576
2593
  } catch (t) {
2577
- throw new g("configuration", `Cannot read the TypeScript configuration ${e}: ${_(t)}`, { cause: t });
2594
+ throw new _("configuration", `Cannot read the TypeScript configuration ${e}: ${v(t)}`, { cause: t });
2578
2595
  }
2579
2596
  }
2580
2597
  //#endregion
2581
- export { ae as a, h as c, ie as i, ui as n, ne as o, Nr as r, g as s, di as t };
2598
+ export { ie as a, h as c, re as i, fi as n, g as o, Fr as r, _ as s, pi as t };
2582
2599
 
2583
- //# sourceMappingURL=codeGenerator-kyY9eLML.js.map
2600
+ //# sourceMappingURL=codeGenerator-DCYj0aYK.js.map