@ahoo-wang/fetcher-generator 3.15.9 → 3.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,169 +2,37 @@ import { Project as e, Scope as t, VariableDeclarationKind as n } from "ts-morph
2
2
  import { ContentTypeValues as r, combineURLs as i } from "@ahoo-wang/fetcher";
3
3
  import { parse as a } from "yaml";
4
4
  import { readFile as o } from "fs";
5
- import { join as s, relative as c, sep as l } from "path";
6
- import { ResourceAttributionPathSpec as u } from "@ahoo-wang/fetcher-wow";
7
- //#region src/utils/logger.ts
8
- var ee = class {
9
- getTimestamp() {
10
- return (/* @__PURE__ */ new Date()).toTimeString().slice(0, 8);
11
- }
12
- info(e, ...t) {
13
- let n = this.getTimestamp();
14
- t.length > 0 ? console.log(`[${n}] ℹ️ ${e}`, ...t) : console.log(`[${n}] ℹ️ ${e}`);
15
- }
16
- success(e, ...t) {
17
- let n = this.getTimestamp();
18
- t.length > 0 ? console.log(`[${n}] ✅ ${e}`, ...t) : console.log(`[${n}] ✅ ${e}`);
19
- }
20
- error(e, ...t) {
21
- let n = this.getTimestamp();
22
- t.length > 0 ? console.error(`[${n}] ❌ ${e}`, ...t) : console.error(`[${n}] ❌ ${e}`);
23
- }
24
- progress(e, t = 0, ...n) {
25
- let r = this.getTimestamp(), i = " ".repeat(t);
26
- n.length > 0 ? console.log(`[${r}] 🔄 ${i}${e}`, ...n) : console.log(`[${r}] 🔄 ${i}${e}`);
27
- }
28
- progressWithCount(e, t, n, r = 0, ...i) {
29
- let a = this.getTimestamp(), o = " ".repeat(r), s = `[${e}/${t}]`;
30
- i.length > 0 ? console.log(`[${a}] 🔄 ${o}${s} ${n}`, ...i) : console.log(`[${a}] 🔄 ${o}${s} ${n}`);
31
- }
32
- }, te = {
33
- name: "@ahoo-wang/fetcher-generator",
34
- version: "3.15.9",
35
- description: "A powerful TypeScript code generation tool that automatically generates type-safe API client code based on OpenAPI specifications. It is designed for general use cases and is also deeply optimized for the [Wow](https://github.com/Ahoo-Wang/Wow) Domain-Driven Design framework, providing native support for the CQRS architectural pattern.",
36
- keywords: [
37
- "fetch",
38
- "http",
39
- "client",
40
- "openapi",
41
- "openapi3",
42
- "swagger",
43
- "generator",
44
- "typescript",
45
- "codegen",
46
- "api",
47
- "rest"
48
- ],
49
- author: "Ahoo-Wang",
50
- license: "Apache-2.0",
51
- homepage: "https://github.com/Ahoo-Wang/fetcher/tree/master/packages/generator",
52
- repository: {
53
- type: "git",
54
- url: "https://github.com/Ahoo-Wang/fetcher.git",
55
- directory: "packages/generator"
56
- },
57
- bugs: { url: "https://github.com/Ahoo-Wang/fetcher/issues" },
58
- type: "module",
59
- main: "./dist/index.umd.js",
60
- module: "./dist/index.es.js",
61
- types: "./dist/index.d.ts",
62
- bin: { "fetcher-generator": "./dist/cli.js" },
63
- exports: { ".": {
64
- types: "./dist/index.d.ts",
65
- import: "./dist/index.es.js",
66
- require: "./dist/index.umd.js"
67
- } },
68
- files: [
69
- "dist",
70
- "README.md",
71
- "README.zh-CN.md"
72
- ],
73
- scripts: {
74
- build: "vite build",
75
- "test:ui": "vitest --ui",
76
- test: "vitest run --coverage --testTimeout=15000",
77
- lint: "eslint . --fix",
78
- clean: "rm -rf dist",
79
- analyze: "npx vite-bundle-analyzer -p auto",
80
- generate: "node dist/cli.js generate -i test/demo.spec.json -o test-output -t tsconfig.json"
81
- },
82
- peerDependencies: {
83
- "@ahoo-wang/fetcher": "workspace:^3.0.0",
84
- "@ahoo-wang/fetcher-eventstream": "workspace:^3.0.0",
85
- "@ahoo-wang/fetcher-decorator": "workspace:^3.0.0",
86
- "@ahoo-wang/fetcher-openapi": "workspace:^3.0.0",
87
- "@ahoo-wang/fetcher-wow": "workspace:^3.0.0"
88
- },
89
- dependencies: {
90
- "ts-morph": "catalog:",
91
- commander: "catalog:",
92
- yaml: "catalog:"
93
- },
94
- devDependencies: {
95
- "@eslint/js": "catalog:",
96
- "@types/node": "catalog:",
97
- "@vitest/coverage-v8": "catalog:",
98
- "@vitest/ui": "catalog:",
99
- eslint: "catalog:",
100
- globals: "catalog:",
101
- prettier: "catalog:",
102
- typescript: "catalog:",
103
- "typescript-eslint": "catalog:",
104
- "unplugin-dts": "catalog:",
105
- vite: "catalog:",
106
- "vite-bundle-analyzer": "catalog:",
107
- vitest: "catalog:"
108
- }
109
- };
110
- //#endregion
111
- //#region src/utils/clis.ts
112
- function ne(e) {
113
- if (!e) return !1;
114
- try {
115
- let t = new URL(e);
116
- return t.protocol === "http:" || t.protocol === "https:";
117
- } catch {
118
- return e.length > 0;
119
- }
120
- }
121
- async function re(e) {
122
- let t = new ee();
123
- process.on("SIGINT", () => {
124
- t.error("Generation interrupted by user"), process.exit(130);
125
- }), ne(e.input) || (t.error("Invalid input: must be a valid file path or HTTP/HTTPS URL"), process.exit(2));
126
- try {
127
- t.info(`Fetcher Generator v${te.version}`), t.info("Starting code generation..."), await new $({
128
- inputPath: e.input,
129
- outputDir: e.output,
130
- configPath: e.config,
131
- tsConfigFilePath: e.tsConfigFilePath,
132
- logger: t
133
- }).generate(), t.success(`Code generation completed successfully! Files generated in: ${e.output}`);
134
- } catch (e) {
135
- t.error("Error during code generation: \n", e), process.exit(1);
136
- }
137
- }
138
- //#endregion
5
+ import { join as s, relative as c, sep as ee } from "path";
6
+ import { ResourceAttributionPathSpec as l } from "@ahoo-wang/fetcher-wow";
139
7
  //#region src/utils/components.ts
140
- var d = "#/components/";
141
- `${d}`, `${d}`, `${d}`, `${d}`, `${d}`;
142
- function f(e) {
8
+ var u = "#/components/";
9
+ `${u}`, `${u}`, `${u}`, `${u}`, `${u}`;
10
+ function d(e) {
143
11
  return e.$ref.split("/").pop();
144
12
  }
145
- function p(e, t) {
146
- let n = f(e);
13
+ function f(e, t) {
14
+ let n = d(e);
147
15
  return t.schemas?.[n];
148
16
  }
149
- function ie(e, t) {
150
- let n = f(e);
17
+ function p(e, t) {
18
+ let n = d(e);
151
19
  return t.requestBodies?.[n];
152
20
  }
153
- function ae(e, t) {
154
- let n = f(e);
21
+ function te(e, t) {
22
+ let n = d(e);
155
23
  return t.parameters?.[n];
156
24
  }
157
25
  function m(e, t) {
158
26
  return {
159
- key: f(e),
160
- schema: p(e, t)
27
+ key: d(e),
28
+ schema: f(e, t)
161
29
  };
162
30
  }
163
31
  //#endregion
164
32
  //#region src/utils/naming.ts
165
- var oe = /[-_'\s./?;:,()[\]{}|\\]+/;
33
+ var ne = /[-_'\s./?;:,()[\]{}|\\]+/;
166
34
  function h(e) {
167
- return e.split(oe);
35
+ return e.split(ne);
168
36
  }
169
37
  function g(e) {
170
38
  return Array.isArray(e) ? e.flatMap((e) => _(h(e))) : _(h(e));
@@ -190,14 +58,14 @@ function y(e) {
190
58
  let t = v(e);
191
59
  return t.charAt(0).toLowerCase() + t.slice(1);
192
60
  }
193
- function se(e) {
61
+ function re(e) {
194
62
  return e === "" || Array.isArray(e) && e.length === 0 ? "" : g(e).filter((e) => e.length > 0).map((e) => e.toUpperCase()).join("_");
195
63
  }
196
64
  function b(e) {
197
65
  return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e) ? e : `'${e}'`;
198
66
  }
199
- function ce(e) {
200
- return /^\d+$/.test(e) ? `NUM_${e}` : b(se(e));
67
+ function ie(e) {
68
+ return /^\d+$/.test(e) ? `NUM_${e}` : b(re(e));
201
69
  }
202
70
  //#endregion
203
71
  //#region src/utils/references.ts
@@ -209,70 +77,70 @@ function x(e) {
209
77
  function S(e, t) {
210
78
  if (t && !x(t) && t.content) return t.content[e]?.schema;
211
79
  }
212
- function le(e) {
80
+ function ae(e) {
213
81
  return S(r.APPLICATION_JSON, e);
214
82
  }
215
- function ue(e) {
83
+ function oe(e) {
216
84
  return S(r.TEXT_EVENT_STREAM, e);
217
85
  }
218
- function de(e) {
86
+ function se(e) {
219
87
  return S("*/*", e);
220
88
  }
221
89
  //#endregion
222
90
  //#region src/utils/schemas.ts
223
- var fe = [
91
+ var ce = [
224
92
  "string",
225
93
  "number",
226
94
  "integer",
227
95
  "boolean",
228
96
  "null"
229
97
  ];
230
- function pe(e) {
231
- return Array.isArray(e) ? !0 : fe.includes(e);
98
+ function C(e) {
99
+ return Array.isArray(e) ? !0 : ce.includes(e);
232
100
  }
233
- function me(e) {
101
+ function w(e) {
234
102
  return Array.isArray(e.enum) && e.enum.length > 0;
235
103
  }
236
- var he = "x-enum-text";
237
- function ge(e) {
238
- return e[he];
104
+ var le = "x-enum-text";
105
+ function ue(e) {
106
+ return e[le];
239
107
  }
240
- function C(e) {
108
+ function T(e) {
241
109
  return e.type === "object" && !!e.properties;
242
110
  }
243
- function w(e) {
111
+ function E(e) {
244
112
  return e.type === "array" && !!e.items;
245
113
  }
246
- function _e(e) {
114
+ function de(e) {
247
115
  return Array.isArray(e.anyOf) && e.anyOf.length > 0;
248
116
  }
249
- function ve(e) {
117
+ function fe(e) {
250
118
  return Array.isArray(e.oneOf) && e.oneOf.length > 0;
251
119
  }
252
- function T(e) {
120
+ function D(e) {
253
121
  return Array.isArray(e.allOf) && e.allOf.length > 0;
254
122
  }
255
- function E(e) {
256
- return _e(e) || ve(e) || T(e);
123
+ function O(e) {
124
+ return de(e) || fe(e) || D(e);
257
125
  }
258
- function D(e) {
126
+ function k(e) {
259
127
  return e.includes("|") || e.includes("&") ? `(${e})[]` : `${e}[]`;
260
128
  }
261
- function O(e) {
129
+ function A(e) {
262
130
  return e.type === "object" && !e.properties && e.additionalProperties !== void 0;
263
131
  }
264
- var ye = "x-map-key-schema";
265
- function be(e) {
266
- return e[ye];
132
+ var pe = "x-map-key-schema";
133
+ function me(e) {
134
+ return e[pe];
267
135
  }
268
- function xe(e) {
136
+ function he(e) {
269
137
  return e.type === "object" ? e.properties ? Object.keys(e.properties).length === 0 : !0 : !1;
270
138
  }
271
- function Se(e) {
139
+ function ge(e) {
272
140
  return e.readOnly === !0;
273
141
  }
274
- function k(e) {
275
- if (Array.isArray(e)) return e.map((e) => k(e)).join(" | ");
142
+ function j(e) {
143
+ if (Array.isArray(e)) return e.map((e) => j(e)).join(" | ");
276
144
  switch (e) {
277
145
  case "string": return "string";
278
146
  case "number":
@@ -282,28 +150,28 @@ function k(e) {
282
150
  default: return "any";
283
151
  }
284
152
  }
285
- function Ce(e) {
286
- if (!C(e)) return [];
153
+ function _e(e) {
154
+ if (!T(e)) return [];
287
155
  let t = e.required || [];
288
156
  return Object.keys(e.properties).filter((e) => !t.includes(e));
289
157
  }
290
158
  //#endregion
291
159
  //#region src/utils/operations.ts
292
- function we(e, t) {
160
+ function ve(e, t) {
293
161
  return e.operation.operationId && t.operation.operationId ? e.operation.operationId.localeCompare(t.operation.operationId) : e.path && t.path ? e.path.localeCompare(t.path) : e.method && t.method ? e.method.localeCompare(t.method) : 0;
294
162
  }
295
- function A(e) {
163
+ function M(e) {
296
164
  let t = [];
297
- for (let [n, r] of Object.entries(e)) j(r).forEach((e) => {
165
+ for (let [n, r] of Object.entries(e)) N(r).forEach((e) => {
298
166
  t.push({
299
167
  method: e.method,
300
168
  operation: e.operation,
301
169
  path: n
302
170
  });
303
171
  });
304
- return t.sort(we);
172
+ return t.sort(ve);
305
173
  }
306
- function j(e) {
174
+ function N(e) {
307
175
  return [
308
176
  {
309
177
  method: "get",
@@ -339,28 +207,28 @@ function j(e) {
339
207
  }
340
208
  ].filter(({ operation: e }) => e !== void 0);
341
209
  }
342
- function M(e) {
210
+ function P(e) {
343
211
  return e.responses[200];
344
212
  }
345
- function N(e) {
346
- return le(M(e));
213
+ function F(e) {
214
+ return ae(P(e));
347
215
  }
348
- function Te(e, t) {
349
- return e.parameters ? e.parameters.map((e) => x(e) ? ae(e, t) : e).filter((e) => e.in === "path") : [];
216
+ function ye(e, t) {
217
+ return e.parameters ? e.parameters.map((e) => x(e) ? te(e, t) : e).filter((e) => e.in === "path") : [];
350
218
  }
351
- var Ee = "string";
352
- function P(e) {
353
- return !e.schema || x(e.schema) || !e.schema.type || !pe(e.schema.type) ? Ee : k(e.schema.type);
219
+ var be = "string";
220
+ function I(e) {
221
+ return !e.schema || x(e.schema) || !e.schema.type || !C(e.schema.type) ? be : j(e.schema.type);
354
222
  }
355
223
  //#endregion
356
224
  //#region src/utils/resources.ts
357
- function F(e) {
358
- return e.startsWith("http://") || e.startsWith("https://") ? De(e) : Oe(e);
225
+ function L(e) {
226
+ return e.startsWith("http://") || e.startsWith("https://") ? xe(e) : Se(e);
359
227
  }
360
- async function De(e) {
228
+ async function xe(e) {
361
229
  return await (await fetch(e)).text();
362
230
  }
363
- function Oe(e) {
231
+ function Se(e) {
364
232
  return new Promise((t, n) => {
365
233
  o(e, "utf-8", (e, r) => {
366
234
  e ? n(e) : t(r);
@@ -369,124 +237,124 @@ function Oe(e) {
369
237
  }
370
238
  //#endregion
371
239
  //#region src/utils/parsers.ts
372
- async function ke(e) {
373
- let t = await F(e);
374
- switch (L(t)) {
375
- case I.JSON: return JSON.parse(t);
376
- case I.YAML: return a(t);
240
+ async function Ce(e) {
241
+ let t = await L(e);
242
+ switch (z(t)) {
243
+ case R.JSON: return JSON.parse(t);
244
+ case R.YAML: return a(t);
377
245
  default: throw Error(`Unsupported file format: ${e}`);
378
246
  }
379
247
  }
380
- async function Ae(e) {
381
- let t = await F(e);
382
- switch (L(t)) {
383
- case I.JSON: return JSON.parse(t);
384
- case I.YAML: return a(t);
248
+ async function we(e) {
249
+ let t = await L(e);
250
+ switch (z(t)) {
251
+ case R.JSON: return JSON.parse(t);
252
+ case R.YAML: return a(t);
385
253
  default: throw Error(`Unsupported file format: ${e}`);
386
254
  }
387
255
  }
388
- var I = /* @__PURE__ */ function(e) {
256
+ var R = /* @__PURE__ */ function(e) {
389
257
  return e.JSON = "json", e.YAML = "yaml", e;
390
258
  }({});
391
- function L(e) {
259
+ function z(e) {
392
260
  let t = e.trimStart();
393
- if (t.startsWith("{") || t.startsWith("[")) return I.JSON;
394
- if (t.startsWith("-") || t.startsWith("%YAML")) return I.YAML;
261
+ if (t.startsWith("{") || t.startsWith("[")) return R.JSON;
262
+ if (t.startsWith("-") || t.startsWith("%YAML")) return R.YAML;
395
263
  try {
396
- return JSON.parse(t), I.JSON;
264
+ return JSON.parse(t), R.JSON;
397
265
  } catch {
398
- if (t.length > 0) return I.YAML;
266
+ if (t.length > 0) return R.YAML;
399
267
  }
400
268
  throw Error("Unable to infer file format");
401
269
  }
402
270
  //#endregion
403
271
  //#region src/utils/sourceFiles.ts
404
- var R = "types.ts", je = "@";
405
- function Me(e) {
406
- return i(e.path, R);
272
+ var B = "types.ts", Te = "@";
273
+ function Ee(e) {
274
+ return i(e.path, B);
407
275
  }
408
- function z(e, t, n) {
276
+ function V(e, t, n) {
409
277
  let r = i(t, n);
410
278
  return e.getSourceFile(r) || e.createSourceFile(r, "", { overwrite: !0 });
411
279
  }
412
- function B(e, t, n) {
280
+ function H(e, t, n) {
413
281
  let r = e.getImportDeclaration((e) => e.getModuleSpecifierValue() === t);
414
282
  r ||= e.addImportDeclaration({ moduleSpecifier: t }), n.forEach((e) => {
415
283
  r.getNamedImports().some((t) => t.getName() === e) || r.addNamedImport(e);
416
284
  });
417
285
  }
418
- function V(e, t, n) {
419
- if (n.path.startsWith(je)) {
420
- B(e, n.path, [n.name]);
286
+ function U(e, t, n) {
287
+ if (n.path.startsWith(Te)) {
288
+ H(e, n.path, [n.name]);
421
289
  return;
422
290
  }
423
- let r = c(e.getDirectoryPath(), s(t, n.path, R));
424
- r = r.replace(/\.ts$/, ""), r = r.split(l).join("/"), r.startsWith(".") || (r = "./" + r), B(e, r, [n.name]);
291
+ let r = c(e.getDirectoryPath(), s(t, n.path, B));
292
+ r = r.replace(/\.ts$/, ""), r = r.split(ee).join("/"), r.startsWith(".") || (r = "./" + r), H(e, r, [n.name]);
425
293
  }
426
- function Ne(e, t, n, r) {
427
- e.path !== r.path && V(t, n, r);
294
+ function De(e, t, n, r) {
295
+ e.path !== r.path && U(t, n, r);
428
296
  }
429
- function Pe(e, t = "\n") {
297
+ function Oe(e, t = "\n") {
430
298
  if (!Array.isArray(e)) return;
431
299
  let n = e.filter((e) => typeof e == "string" && e.length > 0);
432
300
  return n.length > 0 ? n.join(t) : void 0;
433
301
  }
434
- function H(e, t) {
435
- let n = Pe(t);
302
+ function W(e, t) {
303
+ let n = Oe(t);
436
304
  n && e.addJsDoc(n);
437
305
  }
438
- function U(e, t) {
306
+ function G(e, t) {
439
307
  let n = [e.title, e.description];
440
- return t && n.push(`- key: ${t}`), e.format && n.push(`- format: ${e.format}`), Le(n, e, "default"), Le(n, e, "example"), ze(n, e), Be(n, e), Ve(n, e), n;
308
+ return t && n.push(`- key: ${t}`), e.format && n.push(`- format: ${e.format}`), je(n, e, "default"), je(n, e, "example"), Ne(n, e), Pe(n, e), Fe(n, e), n;
441
309
  }
442
- function Fe(e, t, n) {
443
- H(e, U(t, n));
310
+ function ke(e, t, n) {
311
+ W(e, G(t, n));
444
312
  }
445
- function Ie(e, t, n) {
446
- let r = U(t, n);
447
- Re(r, "schema", t), H(e, r);
313
+ function Ae(e, t, n) {
314
+ let r = G(t, n);
315
+ Me(r, "schema", t), W(e, r);
448
316
  }
449
- function Le(e, t, n) {
317
+ function je(e, t, n) {
450
318
  let r = t[n];
451
319
  if (r) {
452
320
  if (typeof r != "object") {
453
321
  e.push(`- ${n}: \`${r}\``);
454
322
  return;
455
323
  }
456
- Re(e, n, r);
324
+ Me(e, n, r);
457
325
  }
458
326
  }
459
- function Re(e, t, n) {
327
+ function Me(e, t, n) {
460
328
  e.push(`- ${t}: `), e.push("```json"), e.push(JSON.stringify(n, null, 2)), e.push("```");
461
329
  }
462
- function ze(e, t) {
330
+ function Ne(e, t) {
463
331
  let n = ["- Numeric Constraints"];
464
332
  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);
465
333
  }
466
- function Be(e, t) {
334
+ function Pe(e, t) {
467
335
  let n = ["- String Constraints"];
468
336
  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);
469
337
  }
470
- function Ve(e, t) {
338
+ function Fe(e, t) {
471
339
  let n = ["- Array Constraints"];
472
340
  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);
473
341
  }
474
342
  //#endregion
475
343
  //#region src/aggregate/utils.ts
476
- function He(e) {
344
+ function Ie(e) {
477
345
  let t = e.split(".");
478
346
  return t.length != 2 || t[0].length === 0 || t[1].length === 0 ? null : t;
479
347
  }
480
- function Ue(e) {
481
- let t = He(e.name);
348
+ function Le(e) {
349
+ let t = Ie(e.name);
482
350
  return t ? {
483
351
  tag: e,
484
352
  contextAlias: t[0],
485
353
  aggregateName: t[1]
486
354
  } : null;
487
355
  }
488
- function We(e) {
489
- let t = e?.map((e) => Ue(e)).filter((e) => e !== null);
356
+ function Re(e) {
357
+ let t = e?.map((e) => Le(e)).filter((e) => e !== null);
490
358
  if (!t) return /* @__PURE__ */ new Map();
491
359
  let n = /* @__PURE__ */ new Map();
492
360
  return t.forEach((e) => {
@@ -497,20 +365,20 @@ function We(e) {
497
365
  });
498
366
  }), n;
499
367
  }
500
- function Ge(e) {
368
+ function ze(e) {
501
369
  if (!e) return null;
502
370
  let t = e.split(".");
503
371
  return t.length == 3 ? t[2] : null;
504
372
  }
505
373
  //#endregion
506
374
  //#region src/aggregate/aggregateResolver.ts
507
- var Ke = "#/components/responses/wow.CommandOk", qe = "#/components/parameters/wow.id", Je = class {
375
+ var Be = "#/components/responses/wow.CommandOk", Ve = "#/components/parameters/wow.id", He = class {
508
376
  aggregates;
509
377
  constructor(e) {
510
- this.openAPI = e, this.aggregates = We(e.tags), this.build();
378
+ this.openAPI = e, this.aggregates = Re(e.tags), this.build();
511
379
  }
512
380
  build() {
513
- let e = A(this.openAPI.paths);
381
+ let e = M(this.openAPI.paths);
514
382
  for (let t of e) this.commands(t.path, t), this.state(t.operation), this.events(t.operation), this.fields(t.operation);
515
383
  }
516
384
  resolve() {
@@ -525,35 +393,35 @@ var Ke = "#/components/responses/wow.CommandOk", qe = "#/components/parameters/w
525
393
  commands(e, t) {
526
394
  let n = t.operation;
527
395
  if (n.operationId === "wow.command.send") return;
528
- let i = Ge(n.operationId);
396
+ let i = ze(n.operationId);
529
397
  if (!i) return;
530
- let a = M(n);
531
- if (!a || !x(a) || a.$ref !== Ke || !n.requestBody) return;
532
- let o = n.parameters ?? [], s = o.filter((e) => x(e) && e.$ref === qe).at(0), c = o.filter((e) => !x(e) && e.in === "path");
398
+ let a = P(n);
399
+ if (!a || !x(a) || a.$ref !== Be || !n.requestBody) return;
400
+ let o = n.parameters ?? [], s = o.filter((e) => x(e) && e.$ref === Ve).at(0), c = o.filter((e) => !x(e) && e.in === "path");
533
401
  if (s) {
534
- let e = ae(s, this.openAPI.components);
402
+ let e = te(s, this.openAPI.components);
535
403
  c.push(e);
536
404
  }
537
- let l = n.requestBody.content[r.APPLICATION_JSON].schema, u = m(l, this.openAPI.components);
538
- u.schema.title = u.schema.title || n.summary, u.schema.description = u.schema.description || n.description;
539
- let ee = {
405
+ let ee = n.requestBody.content[r.APPLICATION_JSON].schema, l = m(ee, this.openAPI.components);
406
+ l.schema.title = l.schema.title || n.summary, l.schema.description = l.schema.description || n.description;
407
+ let u = {
540
408
  name: i,
541
409
  method: t.method,
542
410
  path: e,
543
411
  pathParameters: c,
544
412
  summary: n.summary,
545
413
  description: n.description,
546
- schema: u,
414
+ schema: l,
547
415
  operation: n
548
416
  };
549
417
  n.tags?.forEach((e) => {
550
418
  let t = this.aggregates.get(e);
551
- t && t.commands.set(i, ee);
419
+ t && t.commands.set(i, u);
552
420
  });
553
421
  }
554
422
  state(e) {
555
423
  if (!e.operationId?.endsWith(".snapshot_state.single")) return;
556
- let t = N(e);
424
+ let t = F(e);
557
425
  if (!x(t)) return;
558
426
  let n = m(t, this.openAPI.components);
559
427
  e.tags?.forEach((e) => {
@@ -563,11 +431,11 @@ var Ke = "#/components/responses/wow.CommandOk", qe = "#/components/parameters/w
563
431
  }
564
432
  events(e) {
565
433
  if (!this.openAPI.components || !e.operationId?.endsWith(".event.list_query")) return;
566
- let t = N(e);
434
+ let t = F(e);
567
435
  if (x(t)) return;
568
436
  let n = t?.items;
569
437
  if (!x(n)) return;
570
- let r = p(n, this.openAPI.components).properties.body.items.anyOf.map((e) => {
438
+ let r = f(n, this.openAPI.components).properties.body.items.anyOf.map((e) => {
571
439
  let t = e.title, n = e.properties.name.const, r = e.properties.body, i = m(r, this.openAPI.components);
572
440
  return i.schema.title = i.schema.title || e.title, {
573
441
  title: t,
@@ -584,13 +452,13 @@ var Ke = "#/components/responses/wow.CommandOk", qe = "#/components/parameters/w
584
452
  }
585
453
  fields(e) {
586
454
  if (!this.openAPI.components || !e.operationId?.endsWith(".snapshot.count")) return;
587
- let t = ie(e.requestBody, this.openAPI.components).content[r.APPLICATION_JSON].schema, n = p(t, this.openAPI.components).properties?.field, i = m(n, this.openAPI.components);
455
+ let t = p(e.requestBody, this.openAPI.components).content[r.APPLICATION_JSON].schema, n = f(t, this.openAPI.components).properties?.field, i = m(n, this.openAPI.components);
588
456
  e.tags?.forEach((e) => {
589
457
  let t = this.aggregates.get(e);
590
458
  t && (t.fields = i);
591
459
  });
592
460
  }
593
- }, W = "@ahoo-wang/fetcher-wow", Ye = {
461
+ }, K = "@ahoo-wang/fetcher-wow", Ue = {
594
462
  "wow.command.CommandResult": "CommandResult",
595
463
  "wow.command.CommandResultArray": "CommandResultArray",
596
464
  "wow.MessageHeaderSqlType": "MessageHeaderSqlType",
@@ -625,15 +493,15 @@ var Ke = "#/components/responses/wow.CommandOk", qe = "#/components/parameters/w
625
493
  };
626
494
  //#endregion
627
495
  //#region src/model/modelInfo.ts
628
- function G(e) {
496
+ function q(e) {
629
497
  if (!e) return {
630
498
  name: "",
631
499
  path: "/"
632
500
  };
633
- let t = Ye[e];
501
+ let t = Ue[e];
634
502
  if (t) return {
635
503
  name: t,
636
- path: W
504
+ path: K
637
505
  };
638
506
  let n = e.split("."), r = -1;
639
507
  for (let e = 0; e < n.length; e++) if (n[e] && /^[A-Z]/.test(n[e])) {
@@ -646,29 +514,29 @@ function G(e) {
646
514
  path: a
647
515
  };
648
516
  }
649
- function K(e) {
650
- return G(f(e));
517
+ function J(e) {
518
+ return q(d(e));
651
519
  }
652
- function q(e) {
653
- return `${se(e)}_BOUNDED_CONTEXT_ALIAS`;
520
+ function Y(e) {
521
+ return `${re(e)}_BOUNDED_CONTEXT_ALIAS`;
654
522
  }
655
523
  //#endregion
656
524
  //#region src/model/typeGenerator.ts
657
- var Xe = class {
525
+ var We = class {
658
526
  constructor(e, t, n, r) {
659
527
  this.modelInfo = e, this.sourceFile = t, this.keySchema = n, this.outputDir = r;
660
528
  }
661
529
  generate() {
662
530
  let e = this.process();
663
- e && Ie(e, this.keySchema.schema, this.keySchema.key);
531
+ e && Ae(e, this.keySchema.schema, this.keySchema.key);
664
532
  }
665
533
  process() {
666
534
  let { schema: e } = this.keySchema;
667
- return me(e) ? this.processEnum(e) : C(e) ? this.processInterface(e) : w(e) ? this.processArray(e) : T(e) ? this.processIntersection(e) : E(e) ? this.processComposition(e) : this.processTypeAlias(e);
535
+ return w(e) ? this.processEnum(e) : T(e) ? this.processInterface(e) : E(e) ? this.processArray(e) : D(e) ? this.processIntersection(e) : O(e) ? this.processComposition(e) : this.processTypeAlias(e);
668
536
  }
669
537
  resolveReference(e) {
670
- let t = K(e);
671
- return Ne(this.modelInfo, this.sourceFile, this.outputDir, t), t;
538
+ let t = J(e);
539
+ return De(this.modelInfo, this.sourceFile, this.outputDir, t), t;
672
540
  }
673
541
  resolveAdditionalProperties(e) {
674
542
  return e.additionalProperties === void 0 || e.additionalProperties === !1 ? "" : e.additionalProperties === !0 ? "[key: string]: any" : `[key: string]: ${this.resolveType(e.additionalProperties)}`;
@@ -678,7 +546,7 @@ var Xe = class {
678
546
  return Object.entries(t).map(([e, t]) => {
679
547
  let n = this.resolveType(t), r = b(e);
680
548
  if (!x(t)) {
681
- let e = Pe(U(t), "\n * ");
549
+ let e = Oe(G(t), "\n * ");
682
550
  if (e) return `
683
551
  /**
684
552
  * ${e}
@@ -691,7 +559,7 @@ var Xe = class {
691
559
  }
692
560
  resolveObjectType(e) {
693
561
  let t = [];
694
- if (C(e)) {
562
+ if (T(e)) {
695
563
  let n = this.resolvePropertyDefinitions(e);
696
564
  t.push(...n);
697
565
  }
@@ -702,7 +570,7 @@ var Xe = class {
702
570
  return e.additionalProperties === void 0 || e.additionalProperties === !1 || e.additionalProperties === !0 ? "any" : this.resolveType(e.additionalProperties);
703
571
  }
704
572
  resolveMapKeyType(e) {
705
- let t = be(e);
573
+ let t = me(e);
706
574
  return t ? this.resolveType(t) : "string";
707
575
  }
708
576
  resolveMapType(e) {
@@ -710,29 +578,29 @@ var Xe = class {
710
578
  }
711
579
  resolveType(e) {
712
580
  if (x(e)) return this.resolveReference(e).name;
713
- if (O(e)) return this.resolveMapType(e);
581
+ if (A(e)) return this.resolveMapType(e);
714
582
  if (e.const) return `'${e.const}'`;
715
- if (me(e)) return e.enum.map((e) => `\`${e}\``).join(" | ");
716
- if (E(e)) {
717
- let t = (e.oneOf || e.anyOf || e.allOf || []).map((e) => this.resolveType(e)), n = T(e) ? " & " : " | ";
583
+ if (w(e)) return e.enum.map((e) => `\`${e}\``).join(" | ");
584
+ if (O(e)) {
585
+ let t = (e.oneOf || e.anyOf || e.allOf || []).map((e) => this.resolveType(e)), n = D(e) ? " & " : " | ";
718
586
  return `(${t.join(n)})`;
719
587
  }
720
- return w(e) ? D(this.resolveType(e.items)) : e.type === "object" ? this.resolveObjectType(e) : e.type ? k(e.type) : "any";
588
+ return E(e) ? k(this.resolveType(e.items)) : e.type === "object" ? this.resolveObjectType(e) : e.type ? j(e.type) : "any";
721
589
  }
722
590
  processEnum(e) {
723
- let t = ge(e);
591
+ let t = ue(e);
724
592
  return t && this.sourceFile.addEnum({
725
593
  name: this.modelInfo.name + "EnumText",
726
594
  isExported: !0,
727
595
  members: Object.entries(t).map(([e, t]) => ({
728
- name: ce(e),
596
+ name: ie(e),
729
597
  initializer: `\`${t}\``
730
598
  }))
731
599
  }), this.sourceFile.addEnum({
732
600
  name: this.modelInfo.name,
733
601
  isExported: !0,
734
602
  members: e.enum.filter((e) => typeof e == "string" && e.length > 0).map((e) => ({
735
- name: ce(e),
603
+ name: ie(e),
736
604
  initializer: `\`${e}\``
737
605
  }))
738
606
  });
@@ -742,8 +610,8 @@ var Xe = class {
742
610
  a ? a.setType(r) : a = e.addProperty({
743
611
  name: i,
744
612
  type: r,
745
- isReadonly: Se(n)
746
- }), Fe(a, n);
613
+ isReadonly: ge(n)
614
+ }), ke(a, n);
747
615
  }
748
616
  processInterface(e) {
749
617
  let t = this.sourceFile.addInterface({
@@ -784,7 +652,7 @@ var Xe = class {
784
652
  t.addExtends(n);
785
653
  return;
786
654
  }
787
- C(e) && Object.entries(e.properties).forEach(([e, n]) => {
655
+ T(e) && Object.entries(e.properties).forEach(([e, n]) => {
788
656
  this.addPropertyToInterface(t, e, n);
789
657
  });
790
658
  }), t;
@@ -796,12 +664,12 @@ var Xe = class {
796
664
  isExported: !0
797
665
  });
798
666
  }
799
- }, Ze = class {
667
+ }, Ge = class {
800
668
  constructor(e) {
801
669
  this.context = e;
802
670
  }
803
671
  getOrCreateSourceFile(e) {
804
- let t = Me(e);
672
+ let t = Ee(e);
805
673
  return this.context.getOrCreateSourceFile(t);
806
674
  }
807
675
  generate() {
@@ -824,7 +692,7 @@ var Xe = class {
824
692
  isWowSchema(e, t) {
825
693
  if (e !== "wow.api.query.PagedList" && e.startsWith("wow.api.query.") && e.endsWith("PagedList") || e.startsWith("wow.api.query.Operator") && e.endsWith("Map")) return !1;
826
694
  if (e.startsWith("wow.") || e.endsWith("AggregatedCondition") || e.endsWith("AggregatedDomainEventStream") || e.endsWith("AggregatedDomainEventStreamPagedList") || e.endsWith("AggregatedDomainEventStreamServerSentEventNonNullData") || e.endsWith("AggregatedListQuery") || e.endsWith("AggregatedPagedQuery") || e.endsWith("AggregatedSingleQuery")) return !0;
827
- let n = G(e);
695
+ let n = q(e);
828
696
  return t.has(n.name);
829
697
  }
830
698
  aggregatedSchemaSuffix = [
@@ -841,23 +709,23 @@ var Xe = class {
841
709
  for (let [t, n] of this.context.contextAggregates) {
842
710
  this.generateBoundedContext(t);
843
711
  for (let t of n) this.aggregatedSchemaSuffix.forEach((n) => {
844
- let r = v(G(t.state.key).name) + n;
712
+ let r = v(q(t.state.key).name) + n;
845
713
  e.add(r);
846
714
  });
847
715
  }
848
716
  return e;
849
717
  }
850
718
  generateKeyedSchema(e) {
851
- let t = G(e.key);
852
- new Xe(t, this.getOrCreateSourceFile(t), e, this.context.outputDir).generate();
719
+ let t = q(e.key);
720
+ new We(t, this.getOrCreateSourceFile(t), e, this.context.outputDir).generate();
853
721
  }
854
722
  generateBoundedContext(e) {
855
723
  let t = `${e}/boundedContext.ts`;
856
724
  this.context.logger.info(`Creating bounded context file: ${t}`);
857
- let n = this.context.getOrCreateSourceFile(t), r = q(e);
725
+ let n = this.context.getOrCreateSourceFile(t), r = Y(e);
858
726
  n.addStatements(`export const ${r} = '${e}';`);
859
727
  }
860
- }, Qe = "@ahoo-wang/fetcher", $e = ["ResultExtractors"], et = "@ahoo-wang/fetcher-decorator", tt = [
728
+ }, Ke = "@ahoo-wang/fetcher", qe = ["ResultExtractors"], Je = "@ahoo-wang/fetcher-decorator", Ye = [
861
729
  "type ApiMetadata",
862
730
  "type ApiMetadataCapable",
863
731
  "type ParameterRequest",
@@ -871,20 +739,20 @@ var Xe = class {
871
739
  "attribute",
872
740
  "path",
873
741
  "autoGeneratedError"
874
- ], nt = {
742
+ ], Xe = {
875
743
  type: "Promise<Response>",
876
744
  metadata: "{resultExtractor: ResultExtractors.Response }"
877
- }, rt = {
745
+ }, Ze = {
878
746
  type: "Promise<string>",
879
747
  metadata: "{resultExtractor: ResultExtractors.Text }"
880
- }, J = "{\n headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },\n resultExtractor: JsonEventStreamResultExtractor,\n}";
881
- function it(e) {
882
- B(e, Qe, $e);
748
+ }, X = "{\n headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },\n resultExtractor: JsonEventStreamResultExtractor,\n}";
749
+ function Qe(e) {
750
+ H(e, Ke, qe);
883
751
  }
884
- function at(e) {
885
- B(e, et, tt);
752
+ function $e(e) {
753
+ H(e, Je, Ye);
886
754
  }
887
- function Y(e, t, n = [], r = [], i) {
755
+ function Z(e, t, n = [], r = [], i) {
888
756
  return t.addClass({
889
757
  name: e,
890
758
  isExported: !0,
@@ -896,7 +764,7 @@ function Y(e, t, n = [], r = [], i) {
896
764
  }]
897
765
  });
898
766
  }
899
- function ot(e, n) {
767
+ function et(e, n) {
900
768
  e.addImplements("ApiMetadataCapable"), e.addConstructor({ parameters: [{
901
769
  name: "apiMetadata",
902
770
  type: "ApiMetadata",
@@ -906,30 +774,30 @@ function ot(e, n) {
906
774
  initializer: n
907
775
  }] });
908
776
  }
909
- var st = "@ahoo-wang/fetcher-eventstream";
910
- function X(e) {
911
- B(e, st, ["JsonEventStreamResultExtractor", "type JsonServerSentEventStream"]);
777
+ var tt = "@ahoo-wang/fetcher-eventstream";
778
+ function nt(e) {
779
+ H(e, tt, ["JsonEventStreamResultExtractor", "type JsonServerSentEventStream"]);
912
780
  }
913
781
  //#endregion
914
782
  //#region src/client/utils.ts
915
- function ct(e) {
783
+ function rt(e) {
916
784
  let t = 0, n = 0;
917
785
  return e.commands.forEach((e) => {
918
- e.path.startsWith(u.TENANT) && (t += 1), e.path.startsWith(u.OWNER) && (n += 1);
786
+ e.path.startsWith(l.TENANT) && (t += 1), e.path.startsWith(l.OWNER) && (n += 1);
919
787
  }), t === 0 && n === 0 ? "ResourceAttributionPathSpec.NONE" : t > n ? "ResourceAttributionPathSpec.TENANT" : "ResourceAttributionPathSpec.OWNER";
920
788
  }
921
- function lt(e, t, n, r) {
922
- return z(e, t, `${n.contextAlias}/${n.aggregateName}/${r}.ts`);
789
+ function it(e, t, n, r) {
790
+ return V(e, t, `${n.contextAlias}/${n.aggregateName}/${r}.ts`);
923
791
  }
924
- function Z(e, t) {
792
+ function Q(e, t) {
925
793
  return `${v(e.aggregateName)}${t}`;
926
794
  }
927
- function Q(e) {
795
+ function $(e) {
928
796
  return e === "delete" ? "del" : e;
929
797
  }
930
- var ut = "x-fetcher-method";
931
- function dt(e, t) {
932
- let n = e[ut];
798
+ var at = "x-fetcher-method";
799
+ function ot(e, t) {
800
+ let n = e[at];
933
801
  if (n) return n;
934
802
  if (!e.operationId) return;
935
803
  let r = h(e.operationId);
@@ -941,12 +809,12 @@ function dt(e, t) {
941
809
  }
942
810
  //#endregion
943
811
  //#region src/client/apiClientGenerator.ts
944
- var ft = class {
812
+ var st = class {
945
813
  defaultParameterRequestType = "ParameterRequest";
946
- defaultReturnType = nt;
814
+ defaultReturnType = Xe;
947
815
  apiMetadataCtorInitializer;
948
816
  constructor(e) {
949
- this.context = e, this.apiMetadataCtorInitializer = this.context.currentContextAlias ? `{basePath:${q(this.context.currentContextAlias)}}` : void 0;
817
+ this.context = e, this.apiMetadataCtorInitializer = this.context.currentContextAlias ? `{basePath:${Y(this.context.currentContextAlias)}}` : void 0;
950
818
  }
951
819
  generate() {
952
820
  this.context.logger.info("Starting API client generation");
@@ -969,30 +837,30 @@ var ft = class {
969
837
  return this.context.currentContextAlias && (t = i(this.context.currentContextAlias, t)), t = i(t, `${e.name}ApiClient.ts`), this.context.logger.info(`Creating API client file: ${t}`), this.context.getOrCreateSourceFile(t);
970
838
  }
971
839
  generateApiClient(e, t) {
972
- let n = G(e.name);
840
+ let n = q(e.name);
973
841
  this.context.logger.info(`Generating API client class: ${n.name}ApiClient with ${t.size} operations`);
974
842
  let r = this.createApiClientFile(n);
975
- it(r), at(r), X(r);
976
- let i = Y(n.name + "ApiClient", r);
977
- H(i, [e.description]), ot(i, this.apiMetadataCtorInitializer), this.context.logger.info(`Processing ${t.size} operations for ${n.name}ApiClient`), t.forEach((t) => {
843
+ Qe(r), $e(r), nt(r);
844
+ let i = Z(n.name + "ApiClient", r);
845
+ W(i, [e.description]), et(i, this.apiMetadataCtorInitializer), this.context.logger.info(`Processing ${t.size} operations for ${n.name}ApiClient`), t.forEach((t) => {
978
846
  this.processOperation(e, r, i, t);
979
847
  }), this.context.logger.success(`Completed API client: ${n.name}ApiClient`);
980
848
  }
981
849
  getMethodName(e, t) {
982
- let n = dt(t, (t) => e.getMethod(t) !== void 0);
850
+ let n = ot(t, (t) => e.getMethod(t) !== void 0);
983
851
  if (!n) throw Error(`Unable to resolve method name for apiClientClass:${e.getName()}.`);
984
852
  return n;
985
853
  }
986
854
  resolveRequestType(e, t) {
987
855
  if (!t.requestBody) return this.context.logger.info(`No request body found for operation ${t.operationId}, using default: ${this.defaultParameterRequestType}`), this.defaultParameterRequestType;
988
856
  let n;
989
- if (x(t.requestBody) ? (this.context.logger.info(`Extracting request body from reference for operation: ${t.operationId}`), n = ie(t.requestBody, this.context.openAPI.components)) : n = t.requestBody, !n) return this.context.logger.info(`Request body extraction failed for operation ${t.operationId}, using default: ${this.defaultParameterRequestType}`), this.defaultParameterRequestType;
857
+ if (x(t.requestBody) ? (this.context.logger.info(`Extracting request body from reference for operation: ${t.operationId}`), n = p(t.requestBody, this.context.openAPI.components)) : n = t.requestBody, !n) return this.context.logger.info(`Request body extraction failed for operation ${t.operationId}, using default: ${this.defaultParameterRequestType}`), this.defaultParameterRequestType;
990
858
  if (n.content["multipart/form-data"]) return this.context.logger.info(`Detected multipart/form-data content for operation ${t.operationId}, using ParameterRequest<FormData>`), "ParameterRequest<FormData>";
991
859
  if (n.content["application/json"]) {
992
860
  let r = n.content["application/json"].schema;
993
861
  if (x(r)) {
994
- let n = K(r);
995
- this.context.logger.info(`Adding import for request body model: ${n.name} from ${n.path}`), V(e, this.context.outputDir, n);
862
+ let n = J(r);
863
+ this.context.logger.info(`Adding import for request body model: ${n.name} from ${n.path}`), U(e, this.context.outputDir, n);
996
864
  let i = `ParameterRequest<${n.name}>`;
997
865
  return this.context.logger.info(`Resolved request type for operation ${t.operationId}: ${i}`), i;
998
866
  }
@@ -1000,10 +868,10 @@ var ft = class {
1000
868
  return this.context.logger.info(`Using default request type for operation ${t.operationId}: ${this.defaultParameterRequestType}`), this.defaultParameterRequestType;
1001
869
  }
1002
870
  resolveParameters(e, t, n) {
1003
- let r = Te(n, this.context.openAPI.components).filter((t) => !this.context.isIgnoreApiClientPathParameters(e.name, t.name));
871
+ let r = ye(n, this.context.openAPI.components).filter((t) => !this.context.isIgnoreApiClientPathParameters(e.name, t.name));
1004
872
  this.context.logger.info(`Found ${r.length} path parameters for operation ${n.operationId}`);
1005
873
  let i = r.map((e) => {
1006
- let t = P(e);
874
+ let t = I(e);
1007
875
  return this.context.logger.info(`Adding path parameter: ${e.name} (type: ${t})`), {
1008
876
  name: e.name,
1009
877
  type: t,
@@ -1034,48 +902,48 @@ var ft = class {
1034
902
  }
1035
903
  resolveType(e, t) {
1036
904
  if (x(t)) {
1037
- let n = K(t);
1038
- return V(e, this.context.outputDir, n), n.name;
905
+ let n = J(t);
906
+ return U(e, this.context.outputDir, n), n.name;
1039
907
  }
1040
- if (w(t)) return D(this.resolveType(e, t.items));
1041
- if (O(t)) {
908
+ if (E(t)) return k(this.resolveType(e, t.items));
909
+ if (A(t)) {
1042
910
  let n = t.additionalProperties;
1043
911
  return typeof n == "boolean" ? "Record<string, any>" : `Record<string, ${this.resolveType(e, n)}>`;
1044
912
  }
1045
- return t.type && pe(t.type) ? k(t.type) : "any";
913
+ return t.type && C(t.type) ? j(t.type) : "any";
1046
914
  }
1047
915
  resolveSchemaReturnType(e, t) {
1048
916
  return `Promise<${this.resolveType(e, t)}>`;
1049
917
  }
1050
918
  resolveReturnType(e, t) {
1051
- let n = M(t);
919
+ let n = P(t);
1052
920
  if (!n) return this.context.logger.info(`No OK response found for operation ${t.operationId}, using default return type: ${this.defaultReturnType.type}`), this.defaultReturnType;
1053
- let r = le(n) || de(n);
921
+ let r = ae(n) || se(n);
1054
922
  if (r) {
1055
923
  let n = this.resolveSchemaReturnType(e, r);
1056
924
  return this.context.logger.info(`Resolved JSON/wildcard response return type for operation ${t.operationId}: ${n}`), {
1057
925
  type: n,
1058
- metadata: n === rt.type ? rt.metadata : void 0
926
+ metadata: n === Ze.type ? Ze.metadata : void 0
1059
927
  };
1060
928
  }
1061
- let i = ue(n);
929
+ let i = oe(n);
1062
930
  if (i) {
1063
931
  if (x(i)) {
1064
- let n = p(i, this.context.openAPI.components);
1065
- if (w(n) && x(n.items)) {
1066
- let r = K(n.items);
1067
- this.context.logger.info(`Adding import for event stream model: ${r.name} from ${r.path}`), V(e, this.context.outputDir, r);
932
+ let n = f(i, this.context.openAPI.components);
933
+ if (E(n) && x(n.items)) {
934
+ let r = J(n.items);
935
+ this.context.logger.info(`Adding import for event stream model: ${r.name} from ${r.path}`), U(e, this.context.outputDir, r);
1068
936
  let i = `Promise<JsonServerSentEventStream<${r.name.includes("ServerSentEvent") ? `${r.name}['data']` : r.name}>>`;
1069
937
  return this.context.logger.info(`Resolved event stream return type for operation ${t.operationId}: ${i}`), {
1070
938
  type: i,
1071
- metadata: J
939
+ metadata: X
1072
940
  };
1073
941
  }
1074
942
  }
1075
943
  let n = "Promise<JsonServerSentEventStream<any>>";
1076
944
  return this.context.logger.info(`Resolved generic event stream return type for operation ${t.operationId}: ${n}`), {
1077
945
  type: n,
1078
- metadata: J
946
+ metadata: X
1079
947
  };
1080
948
  }
1081
949
  return this.context.logger.info(`Using default return type for operation ${t.operationId}: ${this.defaultReturnType.type}`), this.defaultReturnType;
@@ -1085,13 +953,13 @@ var ft = class {
1085
953
  let i = this.getMethodName(n, r.operation);
1086
954
  this.context.logger.info(`Generated method name: ${i}`);
1087
955
  let a = this.resolveParameters(e, t, r.operation), o = this.resolveReturnType(t, r.operation), s = o.metadata ? {
1088
- name: Q(r.method),
956
+ name: $(r.method),
1089
957
  arguments: [`'${r.path}'`, o.metadata]
1090
958
  } : {
1091
- name: Q(r.method),
959
+ name: $(r.method),
1092
960
  arguments: [`'${r.path}'`]
1093
961
  };
1094
- this.context.logger.info(`Creating method with ${a.length} parameters, return type: ${o.type}`), H(n.addMethod({
962
+ this.context.logger.info(`Creating method with ${a.length} parameters, return type: ${o.type}`), W(n.addMethod({
1095
963
  name: i,
1096
964
  decorators: [s],
1097
965
  parameters: a,
@@ -1106,7 +974,7 @@ var ft = class {
1106
974
  }
1107
975
  groupOperations(e) {
1108
976
  this.context.logger.info("Grouping operations by API client tags");
1109
- let t = /* @__PURE__ */ new Map(), n = A(this.context.openAPI.paths).filter((t) => {
977
+ let t = /* @__PURE__ */ new Map(), n = M(this.context.openAPI.paths).filter((t) => {
1110
978
  if (!t.operation.operationId) return !1;
1111
979
  let n = t.operation.tags;
1112
980
  return !n || n.length == 0 ? !1 : n.every((t) => e.has(t));
@@ -1122,7 +990,7 @@ var ft = class {
1122
990
  resolveApiTags() {
1123
991
  this.context.logger.info("Resolving API client tags from OpenAPI specification");
1124
992
  let e = /* @__PURE__ */ new Map(), t = this.context.openAPI.tags?.length || 0;
1125
- for (let t of Object.values(this.context.openAPI.paths)) j(t).forEach((t) => {
993
+ for (let t of Object.values(this.context.openAPI.paths)) N(t).forEach((t) => {
1126
994
  t.operation.tags?.forEach((t) => {
1127
995
  !this.shouldIgnoreTag(t) && !e.has(t) && e.set(t, {
1128
996
  name: t,
@@ -1139,7 +1007,7 @@ var ft = class {
1139
1007
  for (let t of this.context.contextAggregates.values()) for (let n of t) if (n.aggregate.tag.name === e) return !0;
1140
1008
  return !1;
1141
1009
  }
1142
- }, pt = class {
1010
+ }, ct = class {
1143
1011
  commandEndpointPathsSuffix = "CommandEndpointPaths";
1144
1012
  defaultCommandClientOptionsName = "DEFAULT_COMMAND_CLIENT_OPTIONS";
1145
1013
  constructor(e) {
@@ -1156,7 +1024,7 @@ var ft = class {
1156
1024
  }
1157
1025
  processAggregate(e) {
1158
1026
  this.context.logger.info(`Processing command client for aggregate: ${e.aggregate.aggregateName} in context: ${e.aggregate.contextAlias}`);
1159
- let t = lt(this.context.project, this.context.outputDir, e.aggregate, "commandClient");
1027
+ let t = it(this.context.project, this.context.outputDir, e.aggregate, "commandClient");
1160
1028
  this.context.logger.info(`Processing command endpoint paths for ${e.commands.size} commands`);
1161
1029
  let r = this.processCommandEndpointPaths(t, e);
1162
1030
  this.processCommandTypes(t, e), this.context.logger.info(`Creating default command client options: ${this.defaultCommandClientOptionsName}`), t.addVariableStatement({
@@ -1165,12 +1033,12 @@ var ft = class {
1165
1033
  name: this.defaultCommandClientOptionsName,
1166
1034
  type: "ApiMetadata",
1167
1035
  initializer: `{
1168
- basePath: ${q(e.aggregate.contextAlias)}
1036
+ basePath: ${Y(e.aggregate.contextAlias)}
1169
1037
  }`
1170
1038
  }],
1171
1039
  isExported: !1
1172
- }), this.context.logger.info(`Adding imports from ${W}: CommandRequest, CommandResult, CommandResultEventStream, CommandBody, DeleteAggregateCommand, RecoverAggregateCommand`), t.addImportDeclaration({
1173
- moduleSpecifier: W,
1040
+ }), this.context.logger.info(`Adding imports from ${K}: CommandRequest, CommandResult, CommandResultEventStream, CommandBody, DeleteAggregateCommand, RecoverAggregateCommand`), t.addImportDeclaration({
1041
+ moduleSpecifier: K,
1174
1042
  namedImports: [
1175
1043
  "CommandRequest",
1176
1044
  "CommandResult",
@@ -1180,10 +1048,10 @@ var ft = class {
1180
1048
  "RecoverAggregateCommand"
1181
1049
  ],
1182
1050
  isTypeOnly: !0
1183
- }), this.context.logger.info("Adding import from @ahoo-wang/fetcher-eventstream: JsonEventStreamResultExtractor"), X(t), this.context.logger.info("Adding import from @ahoo-wang/fetcher: ContentTypeValues"), B(t, "@ahoo-wang/fetcher", ["ContentTypeValues"]), this.context.logger.info("Adding imports from @ahoo-wang/fetcher-decorator: ApiMetadata types and decorators"), at(t), this.context.logger.info("Generating standard command client class"), this.processCommandClient(t, e, r), this.context.logger.info("Generating stream command client class"), this.processStreamCommandClient(t, e), this.context.logger.success(`Command client generation completed for aggregate: ${e.aggregate.aggregateName}`);
1051
+ }), this.context.logger.info("Adding import from @ahoo-wang/fetcher-eventstream: JsonEventStreamResultExtractor"), nt(t), this.context.logger.info("Adding import from @ahoo-wang/fetcher: ContentTypeValues"), H(t, "@ahoo-wang/fetcher", ["ContentTypeValues"]), this.context.logger.info("Adding imports from @ahoo-wang/fetcher-decorator: ApiMetadata types and decorators"), $e(t), this.context.logger.info("Generating standard command client class"), this.processCommandClient(t, e, r), this.context.logger.info("Generating stream command client class"), this.processStreamCommandClient(t, e), this.context.logger.success(`Command client generation completed for aggregate: ${e.aggregate.aggregateName}`);
1184
1052
  }
1185
1053
  resolveAggregateCommandEndpointPathsName(e) {
1186
- return Z(e, this.commandEndpointPathsSuffix);
1054
+ return Q(e, this.commandEndpointPathsSuffix);
1187
1055
  }
1188
1056
  processCommandEndpointPaths(e, t) {
1189
1057
  let n = this.resolveAggregateCommandEndpointPathsName(t.aggregate);
@@ -1200,14 +1068,14 @@ var ft = class {
1200
1068
  }), this.context.logger.success(`Command endpoint paths enum created with ${t.commands.size} entries`), n;
1201
1069
  }
1202
1070
  resolveCommandTypeName(e) {
1203
- let t = G(e.schema.key);
1071
+ let t = q(e.schema.key);
1204
1072
  return [t, t.name + "Command"];
1205
1073
  }
1206
1074
  resolveCommandType(e, t) {
1207
1075
  let [n, r] = this.resolveCommandTypeName(t);
1208
1076
  if (n.path === "@ahoo-wang/fetcher-wow") return;
1209
- V(e, this.context.outputDir, n);
1210
- let i = `${n.name}`, a = Ce(t.schema.schema).map((e) => `'${e}'`).join(" | ");
1077
+ U(e, this.context.outputDir, n);
1078
+ let i = `${n.name}`, a = _e(t.schema.schema).map((e) => `'${e}'`).join(" | ");
1211
1079
  a !== "" && (i = `PartialBy<${i},${a}>`), i = `CommandBody<${i}>`, e.addTypeAlias({
1212
1080
  name: r,
1213
1081
  type: `${i}`,
@@ -1223,14 +1091,14 @@ var ft = class {
1223
1091
  return `${e}.${t.name.toUpperCase()}`;
1224
1092
  }
1225
1093
  processCommandClient(e, t, n) {
1226
- let r = Y(Z(t.aggregate, "CommandClient"), e, [], ["R = CommandResult"]);
1227
- ot(r, this.defaultCommandClientOptionsName), t.commands.forEach((e) => {
1094
+ let r = Z(Q(t.aggregate, "CommandClient"), e, [], ["R = CommandResult"]);
1095
+ et(r, this.defaultCommandClientOptionsName), t.commands.forEach((e) => {
1228
1096
  this.processCommandMethod(t, r, e, n);
1229
1097
  });
1230
1098
  }
1231
1099
  processStreamCommandClient(e, t) {
1232
- let n = Z(t.aggregate, "CommandClient");
1233
- Y(Z(t.aggregate, "StreamCommandClient"), e, ["''", J], [], `${n}<CommandResultEventStream>`).addConstructor({
1100
+ let n = Q(t.aggregate, "CommandClient");
1101
+ Z(Q(t.aggregate, "StreamCommandClient"), e, ["''", X], [], `${n}<CommandResultEventStream>`).addConstructor({
1234
1102
  parameters: [{
1235
1103
  name: "apiMetadata",
1236
1104
  type: "ApiMetadata",
@@ -1243,7 +1111,7 @@ var ft = class {
1243
1111
  let [n, r] = this.resolveCommandTypeName(t);
1244
1112
  this.context.logger.info(`Adding import for command model: ${n.name} from path: ${n.path}`);
1245
1113
  let i = t.pathParameters.filter((t) => !this.context.isIgnoreCommandClientPathParameters(e.name, t.name)).map((e) => {
1246
- let t = P(e);
1114
+ let t = I(e);
1247
1115
  return this.context.logger.info(`Adding path parameter: ${e.name} (type: ${t})`), {
1248
1116
  name: e.name,
1249
1117
  type: t,
@@ -1256,7 +1124,7 @@ var ft = class {
1256
1124
  });
1257
1125
  return this.context.logger.info(`Adding command request parameter: commandRequest (type: CommandRequest<${r}>)`), i.push({
1258
1126
  name: "commandRequest",
1259
- hasQuestionToken: xe(t.schema.schema),
1127
+ hasQuestionToken: he(t.schema.schema),
1260
1128
  type: `CommandRequest<${r}>`,
1261
1129
  decorators: [{
1262
1130
  name: "request",
@@ -1277,21 +1145,21 @@ var ft = class {
1277
1145
  let i = this.resolveParameters(e.aggregate.tag, n), a = t.addMethod({
1278
1146
  name: y(n.name),
1279
1147
  decorators: [{
1280
- name: Q(n.method),
1148
+ name: $(n.method),
1281
1149
  arguments: [`${this.getEndpointPath(r, n)}`]
1282
1150
  }],
1283
1151
  parameters: i,
1284
1152
  returnType: "Promise<R>",
1285
1153
  statements: `throw autoGeneratedError(${i.map((e) => e.name).join(",")});`
1286
1154
  });
1287
- this.context.logger.info(`Adding JSDoc documentation for method: ${y(n.name)}`), H(a, [
1155
+ this.context.logger.info(`Adding JSDoc documentation for method: ${y(n.name)}`), W(a, [
1288
1156
  n.summary,
1289
1157
  n.description,
1290
1158
  `- operationId: \`${n.operation.operationId}\``,
1291
1159
  `- path: \`${n.path}\``
1292
1160
  ]), this.context.logger.success(`Command method generated: ${y(n.name)}`);
1293
1161
  }
1294
- }, mt = class {
1162
+ }, lt = class {
1295
1163
  domainEventTypeSuffix = "DomainEventType";
1296
1164
  domainEventTypeMapTitleSuffix = "DomainEventTypeMapTitle";
1297
1165
  constructor(e) {
@@ -1307,12 +1175,12 @@ var ft = class {
1307
1175
  this.context.logger.success("Query client generation completed");
1308
1176
  }
1309
1177
  createClientFilePath(e, t) {
1310
- return lt(this.context.project, this.context.outputDir, e, t);
1178
+ return it(this.context.project, this.context.outputDir, e, t);
1311
1179
  }
1312
1180
  processQueryClient(e) {
1313
1181
  let t = this.createClientFilePath(e.aggregate, "queryClient");
1314
- this.context.logger.info(`Processing query client for aggregate: ${e.aggregate.aggregateName} in context: ${e.aggregate.contextAlias}`), this.context.logger.info(`Adding imports from ${W}: QueryClientFactory, QueryClientOptions, ResourceAttributionPathSpec`), t.addImportDeclaration({
1315
- moduleSpecifier: W,
1182
+ this.context.logger.info(`Processing query client for aggregate: ${e.aggregate.aggregateName} in context: ${e.aggregate.contextAlias}`), this.context.logger.info(`Adding imports from ${K}: QueryClientFactory, QueryClientOptions, ResourceAttributionPathSpec`), t.addImportDeclaration({
1183
+ moduleSpecifier: K,
1316
1184
  namedImports: [
1317
1185
  "QueryClientFactory",
1318
1186
  "QueryClientOptions",
@@ -1326,15 +1194,15 @@ var ft = class {
1326
1194
  name: r,
1327
1195
  type: "QueryClientOptions",
1328
1196
  initializer: `{
1329
- contextAlias: ${q(e.aggregate.contextAlias)},
1197
+ contextAlias: ${Y(e.aggregate.contextAlias)},
1330
1198
  aggregateName: '${e.aggregate.aggregateName}',
1331
- resourceAttribution: ${ct(e)},
1199
+ resourceAttribution: ${rt(e)},
1332
1200
  }`
1333
1201
  }],
1334
1202
  isExported: !1
1335
1203
  }), this.processAggregateDomainEventTypes(e, t);
1336
- let i = this.processAggregateDomainEventType(e, t), a = `${y(e.aggregate.aggregateName)}QueryClientFactory`, o = G(e.state.key), s = G(e.fields.key);
1337
- this.context.logger.info(`Adding import for state model: ${o.name} from path: ${o.path}`), V(t, this.context.outputDir, o), this.context.logger.info(`Adding import for fields model: ${s.name} from path: ${s.path}`), V(t, this.context.outputDir, s), this.context.logger.info(`Creating query client factory: ${a}`), t.addVariableStatement({
1204
+ let i = this.processAggregateDomainEventType(e, t), a = `${y(e.aggregate.aggregateName)}QueryClientFactory`, o = q(e.state.key), s = q(e.fields.key);
1205
+ this.context.logger.info(`Adding import for state model: ${o.name} from path: ${o.path}`), U(t, this.context.outputDir, o), this.context.logger.info(`Adding import for fields model: ${s.name} from path: ${s.path}`), U(t, this.context.outputDir, s), this.context.logger.info(`Creating query client factory: ${a}`), t.addVariableStatement({
1338
1206
  declarationKind: n.Const,
1339
1207
  declarations: [{
1340
1208
  name: a,
@@ -1347,10 +1215,10 @@ var ft = class {
1347
1215
  let n = [];
1348
1216
  this.context.logger.info(`Processing ${e.events.size} domain events for aggregate: ${e.aggregate.aggregateName}`);
1349
1217
  for (let r of e.events.values()) {
1350
- let e = G(r.schema.key);
1351
- this.context.logger.info(`Adding import for event model: ${e.name} from path: ${e.path}`), V(t, this.context.outputDir, e), n.push(e);
1218
+ let e = q(r.schema.key);
1219
+ this.context.logger.info(`Adding import for event model: ${e.name} from path: ${e.path}`), U(t, this.context.outputDir, e), n.push(e);
1352
1220
  }
1353
- let r = Z(e.aggregate, this.domainEventTypeSuffix), i = n.map((e) => e.name).join(" | ");
1221
+ let r = Q(e.aggregate, this.domainEventTypeSuffix), i = n.map((e) => e.name).join(" | ");
1354
1222
  return this.context.logger.info(`Creating domain event types union: ${r} = ${i}`), t.addTypeAlias({
1355
1223
  isExported: !0,
1356
1224
  name: r,
@@ -1358,7 +1226,7 @@ var ft = class {
1358
1226
  }), r;
1359
1227
  }
1360
1228
  processAggregateDomainEventTypes(e, t) {
1361
- let n = Z(e.aggregate, this.domainEventTypeMapTitleSuffix), r = t.addEnum({
1229
+ let n = Q(e.aggregate, this.domainEventTypeMapTitleSuffix), r = t.addEnum({
1362
1230
  name: n,
1363
1231
  isExported: !0
1364
1232
  });
@@ -1367,12 +1235,12 @@ var ft = class {
1367
1235
  initializer: `'${t.title}'`
1368
1236
  });
1369
1237
  }
1370
- }, ht = class {
1238
+ }, ut = class {
1371
1239
  queryClientGenerator;
1372
1240
  commandClientGenerator;
1373
1241
  apiClientGenerator;
1374
1242
  constructor(e) {
1375
- this.context = e, this.queryClientGenerator = new mt(e), this.commandClientGenerator = new pt(e), this.apiClientGenerator = new ft(e);
1243
+ this.context = e, this.queryClientGenerator = new lt(e), this.commandClientGenerator = new ct(e), this.apiClientGenerator = new st(e);
1376
1244
  }
1377
1245
  generate() {
1378
1246
  this.context.logger.info("--- Generating Clients ---"), this.context.logger.progress(`Generating clients for ${this.context.contextAggregates.size} bounded contexts`);
@@ -1380,7 +1248,7 @@ var ft = class {
1380
1248
  for (let [t] of this.context.contextAggregates) e++, this.context.logger.progressWithCount(e, this.context.contextAggregates.size, `Processing bounded context: ${t}`, 1);
1381
1249
  this.queryClientGenerator.generate(), this.commandClientGenerator.generate(), this.apiClientGenerator.generate(), this.context.logger.success("Client generation completed");
1382
1250
  }
1383
- }, gt = class {
1251
+ }, dt = class {
1384
1252
  project;
1385
1253
  openAPI;
1386
1254
  outputDir;
@@ -1393,7 +1261,7 @@ var ft = class {
1393
1261
  this.project = e.project, this.openAPI = e.openAPI, this.outputDir = e.outputDir, this.contextAggregates = e.contextAggregates, this.logger = e.logger, this.config = e.config ?? {}, this.currentContextAlias = this.openAPI.info["x-wow-context-alias"];
1394
1262
  }
1395
1263
  getOrCreateSourceFile(e) {
1396
- return z(this.project, this.outputDir, e);
1264
+ return V(this.project, this.outputDir, e);
1397
1265
  }
1398
1266
  isIgnoreApiClientPathParameters(e, t) {
1399
1267
  return (this.config.apiClients?.[e]?.ignorePathParameters ?? this.defaultIgnorePathParameters).includes(t);
@@ -1401,7 +1269,7 @@ var ft = class {
1401
1269
  isIgnoreCommandClientPathParameters(e, t) {
1402
1270
  return this.defaultIgnorePathParameters.includes(t);
1403
1271
  }
1404
- }, _t = "./fetcher-generator.config.json", $ = class {
1272
+ }, ft = "./fetcher-generator.config.json", pt = class {
1405
1273
  project;
1406
1274
  constructor(t) {
1407
1275
  this.options = t, this.project = new e(t), this.options.logger.info(`Project instance created with tsConfigFilePath: ${this.options.tsConfigFilePath}`);
@@ -1410,17 +1278,17 @@ var ft = class {
1410
1278
  this.options.logger.info("Starting code generation from OpenAPI specification");
1411
1279
  let e = process.cwd();
1412
1280
  this.options.logger.info(`Work directory: ${e}`), this.options.logger.info(`Input path: ${this.options.inputPath}`), this.options.logger.info(`Output directory: ${this.options.outputDir}`), this.options.logger.info("Parsing OpenAPI specification");
1413
- let t = await ke(this.options.inputPath);
1281
+ let t = await Ce(this.options.inputPath);
1414
1282
  this.options.logger.info("OpenAPI specification parsed successfully"), this.options.logger.info("Resolving bounded context aggregates");
1415
- let n = new Je(t).resolve();
1283
+ let n = new He(t).resolve();
1416
1284
  this.options.logger.info(`Resolved ${n.size} bounded context aggregates`);
1417
1285
  let r = this.options.configPath ?? "./fetcher-generator.config.json", i = {};
1418
1286
  try {
1419
- this.options.logger.info(`Parsing configuration file: ${r}`), i = await Ae(r);
1287
+ this.options.logger.info(`Parsing configuration file: ${r}`), i = await we(r);
1420
1288
  } catch (e) {
1421
1289
  this.options.logger.info(`Configuration file parsing failed: ${e}`);
1422
1290
  }
1423
- let a = new gt({
1291
+ let a = new dt({
1424
1292
  openAPI: t,
1425
1293
  project: this.project,
1426
1294
  outputDir: this.options.outputDir,
@@ -1428,7 +1296,7 @@ var ft = class {
1428
1296
  logger: this.options.logger,
1429
1297
  config: i
1430
1298
  });
1431
- this.options.logger.info("Generating models"), new Ze(a).generate(), this.options.logger.info("Models generated successfully"), this.options.logger.info("Generating clients"), new ht(a).generate(), this.options.logger.info("Clients generated successfully");
1299
+ this.options.logger.info("Generating models"), new Ge(a).generate(), this.options.logger.info("Models generated successfully"), this.options.logger.info("Generating clients"), new ut(a).generate(), this.options.logger.info("Clients generated successfully");
1432
1300
  let o = this.project.getDirectory(this.options.outputDir);
1433
1301
  if (!o) {
1434
1302
  this.options.logger.info("Output directory not found.");
@@ -1480,6 +1348,6 @@ var ft = class {
1480
1348
  }
1481
1349
  };
1482
1350
  //#endregion
1483
- export { te as i, _t as n, re as r, $ as t };
1351
+ export { ft as n, pt as t };
1484
1352
 
1485
- //# sourceMappingURL=src--JU4xGKu.js.map
1353
+ //# sourceMappingURL=src-Drc8UO0Q.js.map