@ahoo-wang/fetcher-generator 2.11.3 → 2.12.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.
package/dist/index.js CHANGED
@@ -1,78 +1,78 @@
1
- import { Scope as le, VariableDeclarationKind as O, Project as pe } from "ts-morph";
2
- import { ContentTypeValues as E, combineURLs as v } from "@ahoo-wang/fetcher";
3
- import { ResourceAttributionPathSpec as W } from "@ahoo-wang/fetcher-wow";
1
+ import { Scope as le, VariableDeclarationKind as w, Project as de } from "ts-morph";
2
+ import { ContentTypeValues as $, combineURLs as T } from "@ahoo-wang/fetcher";
3
+ import { ResourceAttributionPathSpec as G } from "@ahoo-wang/fetcher-wow";
4
4
  import { parse as J } from "yaml";
5
5
  import { readFile as me } from "fs";
6
- import { join as de, relative as fe } from "path";
7
- function $(o) {
8
- return o.$ref.split("/").pop();
6
+ import { join as fe, relative as he } from "path";
7
+ function A(n) {
8
+ return n.$ref.split("/").pop();
9
9
  }
10
- function S(o, e) {
11
- const t = $(o);
10
+ function I(n, e) {
11
+ const t = A(n);
12
12
  return e.schemas?.[t];
13
13
  }
14
- function V(o, e) {
15
- const t = $(o);
14
+ function V(n, e) {
15
+ const t = A(n);
16
16
  return e.requestBodies?.[t];
17
17
  }
18
- function H(o, e) {
19
- const t = $(o);
18
+ function H(n, e) {
19
+ const t = A(n);
20
20
  return e.parameters?.[t];
21
21
  }
22
- function I(o, e) {
22
+ function P(n, e) {
23
23
  return {
24
- key: $(o),
25
- schema: S(o, e)
24
+ key: A(n),
25
+ schema: I(n, e)
26
26
  };
27
27
  }
28
- const he = /[-_\s.]+/;
29
- function N(o) {
30
- return o.split(he);
28
+ const ye = /[-_\s.]+/;
29
+ function O(n) {
30
+ return n.split(ye);
31
31
  }
32
- function Y(o) {
33
- return Array.isArray(o) ? o.flatMap((e) => L(N(e))) : L(N(o));
32
+ function Y(n) {
33
+ return Array.isArray(n) ? n.flatMap((e) => W(O(e))) : W(O(n));
34
34
  }
35
- function L(o) {
36
- return o.flatMap((e) => {
35
+ function W(n) {
36
+ return n.flatMap((e) => {
37
37
  if (e.length === 0)
38
38
  return [];
39
39
  const t = [];
40
- let n = "";
40
+ let o = "";
41
41
  for (let r = 0; r < e.length; r++) {
42
42
  const i = e[r], s = /[A-Z]/.test(i), a = r > 0 && /[a-z]/.test(e[r - 1]);
43
- s && a && n ? (t.push(n), n = i) : n += i;
43
+ s && a && o ? (t.push(o), o = i) : o += i;
44
44
  }
45
- return n && t.push(n), t;
45
+ return o && t.push(o), t;
46
46
  });
47
47
  }
48
- function x(o) {
49
- return o === "" || o.length === 0 ? "" : Y(o).filter((t) => t.length > 0).map((t) => {
50
- const n = t.charAt(0), r = t.slice(1);
51
- return (/[a-zA-Z]/.test(n) ? n.toUpperCase() : n) + r.toLowerCase();
48
+ function S(n) {
49
+ return n === "" || n.length === 0 ? "" : Y(n).filter((t) => t.length > 0).map((t) => {
50
+ const o = t.charAt(0), r = t.slice(1);
51
+ return (/[a-zA-Z]/.test(o) ? o.toUpperCase() : o) + r.toLowerCase();
52
52
  }).join("");
53
53
  }
54
- function h(o) {
55
- const e = x(o);
54
+ function h(n) {
55
+ const e = S(n);
56
56
  return e.charAt(0).toLowerCase() + e.slice(1);
57
57
  }
58
- function ye(o) {
59
- return o === "" || Array.isArray(o) && o.length === 0 ? "" : Y(o).filter((t) => t.length > 0).map((t) => t.toUpperCase()).join("_");
58
+ function xe(n) {
59
+ return n === "" || Array.isArray(n) && n.length === 0 ? "" : Y(n).filter((t) => t.length > 0).map((t) => t.toUpperCase()).join("_");
60
60
  }
61
- function g(o) {
62
- return !!(o && typeof o == "object" && "$ref" in o);
61
+ function u(n) {
62
+ return !!(n && typeof n == "object" && "$ref" in n);
63
63
  }
64
- function j(o, e) {
65
- if (e && !g(e) && e.content)
66
- return e.content[o]?.schema;
64
+ function F(n, e) {
65
+ if (e && !u(e) && e.content)
66
+ return e.content[n]?.schema;
67
67
  }
68
- function K(o) {
69
- return j(E.APPLICATION_JSON, o);
68
+ function K(n) {
69
+ return F($.APPLICATION_JSON, n);
70
70
  }
71
- function xe(o) {
72
- return j(E.TEXT_EVENT_STREAM, o);
71
+ function Ae(n) {
72
+ return F($.TEXT_EVENT_STREAM, n);
73
73
  }
74
- function Ae(o) {
75
- return j("*/*", o);
74
+ function Pe(n) {
75
+ return F("*/*", n);
76
76
  }
77
77
  const Ce = [
78
78
  "string",
@@ -81,40 +81,43 @@ const Ce = [
81
81
  "boolean",
82
82
  "null"
83
83
  ];
84
- function _(o) {
85
- return Array.isArray(o) ? !0 : Ce.includes(o);
84
+ function X(n) {
85
+ return Array.isArray(n) ? !0 : Ce.includes(n);
86
86
  }
87
- function D(o) {
88
- return o.type === "array";
87
+ function k(n) {
88
+ return Array.isArray(n.enum) && n.enum.length > 0;
89
89
  }
90
- function Pe(o) {
91
- return Array.isArray(o.enum) && o.enum.length > 0;
90
+ function R(n) {
91
+ return n.type === "object" && !!n.properties;
92
92
  }
93
- function X(o) {
94
- return Array.isArray(o.anyOf) && o.anyOf.length > 0;
93
+ function D(n) {
94
+ return n.type === "array" && !!n.items;
95
95
  }
96
- function Z(o) {
97
- return Array.isArray(o.oneOf) && o.oneOf.length > 0;
96
+ function $e(n) {
97
+ return Array.isArray(n.anyOf) && n.anyOf.length > 0;
98
98
  }
99
- function $e(o) {
100
- return X(o) || Z(o);
99
+ function Te(n) {
100
+ return Array.isArray(n.oneOf) && n.oneOf.length > 0;
101
101
  }
102
- function Ie(o) {
103
- return Array.isArray(o.allOf) && o.allOf.length > 0;
102
+ function N(n) {
103
+ return Array.isArray(n.allOf) && n.allOf.length > 0;
104
104
  }
105
- function z(o) {
106
- return X(o) || Z(o) || Ie(o);
105
+ function L(n) {
106
+ return $e(n) || Te(n) || N(n);
107
107
  }
108
- function k(o) {
109
- return o.includes("|") || o.includes("&") ? `(${o})[]` : `${o}[]`;
108
+ function Ie(n) {
109
+ return n.includes("|") || n.includes("&") ? `(${n})[]` : `${n}[]`;
110
110
  }
111
- function Te(o) {
112
- return o.type !== "object" ? !1 : o.properties ? Object.keys(o.properties).length === 0 : !0;
111
+ function ve(n) {
112
+ return n.type === "object" && !n.properties && n.additionalProperties !== void 0;
113
113
  }
114
- function A(o) {
115
- if (Array.isArray(o))
116
- return o.map((e) => A(e)).join(" | ");
117
- switch (o) {
114
+ function Se(n) {
115
+ return n.type !== "object" ? !1 : n.properties ? Object.keys(n.properties).length === 0 : !0;
116
+ }
117
+ function E(n) {
118
+ if (Array.isArray(n))
119
+ return n.map((e) => E(e)).join(" | ");
120
+ switch (n) {
118
121
  case "string":
119
122
  return "string";
120
123
  case "number":
@@ -128,69 +131,69 @@ function A(o) {
128
131
  return "any";
129
132
  }
130
133
  }
131
- function M(o) {
134
+ function b(n) {
132
135
  return [
133
- { method: "get", operation: o.get },
134
- { method: "put", operation: o.put },
135
- { method: "post", operation: o.post },
136
- { method: "delete", operation: o.delete },
137
- { method: "options", operation: o.options },
138
- { method: "head", operation: o.head },
139
- { method: "patch", operation: o.patch },
140
- { method: "trace", operation: o.trace }
136
+ { method: "get", operation: n.get },
137
+ { method: "put", operation: n.put },
138
+ { method: "post", operation: n.post },
139
+ { method: "delete", operation: n.delete },
140
+ { method: "options", operation: n.options },
141
+ { method: "head", operation: n.head },
142
+ { method: "patch", operation: n.patch },
143
+ { method: "trace", operation: n.trace }
141
144
  ].filter(({ operation: e }) => e !== void 0);
142
145
  }
143
- function F(o) {
144
- return o.responses[200];
146
+ function j(n) {
147
+ return n.responses[200];
145
148
  }
146
- function B(o) {
147
- const e = F(o);
149
+ function z(n) {
150
+ const e = j(n);
148
151
  return K(e);
149
152
  }
150
- function Ee(o, e) {
151
- return o.parameters ? o.parameters.map((t) => g(t) ? H(t, e) : t).filter((t) => t.in === "path") : [];
153
+ function Ee(n, e) {
154
+ return n.parameters ? n.parameters.map((t) => u(t) ? H(t, e) : t).filter((t) => t.in === "path") : [];
152
155
  }
153
- const ve = "string";
154
- function ee(o) {
155
- return !o.schema || g(o.schema) || !o.schema.type || !_(o.schema.type) ? ve : A(o.schema.type);
156
+ const Re = "string";
157
+ function Z(n) {
158
+ return !n.schema || u(n.schema) || !n.schema.type || !X(n.schema.type) ? Re : E(n.schema.type);
156
159
  }
157
- function te(o) {
158
- return o.startsWith("http://") || o.startsWith("https://") ? Se(o) : we(o);
160
+ function ee(n) {
161
+ return n.startsWith("http://") || n.startsWith("https://") ? we(n) : Oe(n);
159
162
  }
160
- async function Se(o) {
161
- return await (await fetch(o)).text();
163
+ async function we(n) {
164
+ return await (await fetch(n)).text();
162
165
  }
163
- function we(o) {
166
+ function Oe(n) {
164
167
  return new Promise((e, t) => {
165
- me(o, "utf-8", (n, r) => {
166
- n ? t(n) : e(r);
168
+ me(n, "utf-8", (o, r) => {
169
+ o ? t(o) : e(r);
167
170
  });
168
171
  });
169
172
  }
170
- async function Re(o) {
171
- const e = await te(o);
172
- switch (ne(e)) {
173
+ async function De(n) {
174
+ const e = await ee(n);
175
+ switch (te(e)) {
173
176
  case "json":
174
177
  return JSON.parse(e);
175
178
  case "yaml":
176
179
  return J(e);
177
180
  default:
178
- throw new Error(`Unsupported file format: ${o}`);
181
+ throw new Error(`Unsupported file format: ${n}`);
179
182
  }
180
183
  }
181
- async function Oe(o) {
182
- const e = await te(o);
183
- switch (ne(e)) {
184
+ async function Ne(n) {
185
+ const e = await ee(n);
186
+ switch (te(e)) {
184
187
  case "json":
185
188
  return JSON.parse(e);
186
189
  case "yaml":
187
190
  return J(e);
188
191
  default:
189
- throw new Error(`Unsupported file format: ${o}`);
192
+ throw new Error(`Unsupported file format: ${n}`);
190
193
  }
191
194
  }
192
- function ne(o) {
193
- const e = o.trimStart();
195
+ function te(n) {
196
+ const e = n.trimStart();
194
197
  if (e.startsWith("{") || e.startsWith("["))
195
198
  return "json";
196
199
  if (e.startsWith("-") || e.startsWith("%YAML"))
@@ -203,125 +206,129 @@ function ne(o) {
203
206
  }
204
207
  throw new Error("Unable to infer file format");
205
208
  }
206
- const oe = "types.ts", Ne = "@";
207
- function De(o) {
208
- return v(o.path, oe);
209
+ const ne = "types.ts", be = "@";
210
+ function Me(n) {
211
+ return T(n.path, ne);
209
212
  }
210
- function re(o, e, t) {
211
- const n = v(e, t), r = o.getSourceFile(n);
212
- return r || o.createSourceFile(n, "", {
213
+ function oe(n, e, t) {
214
+ const o = T(e, t), r = n.getSourceFile(o);
215
+ return r || n.createSourceFile(o, "", {
213
216
  overwrite: !0
214
217
  });
215
218
  }
216
- function C(o, e, t) {
217
- let n = o.getImportDeclaration(
219
+ function y(n, e, t) {
220
+ let o = n.getImportDeclaration(
218
221
  (r) => r.getModuleSpecifierValue() === e
219
222
  );
220
- n || (n = o.addImportDeclaration({
223
+ o || (o = n.addImportDeclaration({
221
224
  moduleSpecifier: e
222
225
  })), t.forEach((r) => {
223
- n.getNamedImports().some(
226
+ o.getNamedImports().some(
224
227
  (s) => s.getName() === r
225
- ) || n.addNamedImport(r);
228
+ ) || o.addNamedImport(r);
226
229
  });
227
230
  }
228
- function f(o, e, t) {
229
- if (t.path.startsWith(Ne)) {
230
- C(o, t.path, [t.name]);
231
+ function f(n, e, t) {
232
+ if (t.path.startsWith(be)) {
233
+ y(n, t.path, [t.name]);
231
234
  return;
232
235
  }
233
- const n = o.getDirectoryPath(), r = de(e, t.path, oe);
234
- let i = fe(n, r);
235
- i = i.replace(/\.ts$/, ""), i.startsWith(".") || (i = "./" + i), C(o, i, [t.name]);
236
+ const o = n.getDirectoryPath(), r = fe(e, t.path, ne);
237
+ let i = he(o, r);
238
+ i = i.replace(/\.ts$/, ""), i.startsWith(".") || (i = "./" + i), y(n, i, [t.name]);
236
239
  }
237
- function T(o, e, t, n) {
238
- o.path !== n.path && f(e, t, n);
240
+ function qe(n, e, t, o) {
241
+ n.path !== o.path && f(e, t, o);
239
242
  }
240
- function Me(o) {
241
- if (!Array.isArray(o))
243
+ function re(n, e = `
244
+ `) {
245
+ if (!Array.isArray(n))
242
246
  return;
243
- const e = o.filter(
244
- (t) => typeof t == "string" && t.length > 0
247
+ const t = n.filter(
248
+ (o) => typeof o == "string" && o.length > 0
245
249
  );
246
- return e.length > 0 ? e.join(`
247
- `) : void 0;
250
+ return t.length > 0 ? t.join(e) : void 0;
248
251
  }
249
- function w(o, e) {
250
- const t = Me(e);
251
- t && o.addJsDoc(t);
252
+ function v(n, e) {
253
+ const t = re(e);
254
+ t && n.addJsDoc(t);
252
255
  }
253
- function R(o, e) {
256
+ function ie(n, e) {
254
257
  const t = [
255
- e.title,
256
- e.description
258
+ n.title,
259
+ n.description
257
260
  ];
258
- e.format && t.push(`- format: ${e.format}`), U(t, e, "default"), U(t, e, "example"), be(t, e), qe(t, e), je(t, e), w(o, t);
261
+ return e && t.push(`- key: ${e}`), n.format && t.push(`- format: ${n.format}`), Q(t, n, "default"), Q(t, n, "example"), Fe(t, n), je(t, n), _e(t, n), t;
262
+ }
263
+ function B(n, e, t) {
264
+ const o = ie(e, t);
265
+ v(n, o);
259
266
  }
260
- function U(o, e, t) {
261
- const n = e[t];
262
- if (n) {
263
- if (typeof n != "object") {
264
- o.push(`- ${t}: \`${n}\``);
267
+ function Q(n, e, t) {
268
+ const o = e[t];
269
+ if (o) {
270
+ if (typeof o != "object") {
271
+ n.push(`- ${t}: \`${o}\``);
265
272
  return;
266
273
  }
267
- o.push(`- ${t}: `), o.push("```json"), o.push(JSON.stringify(n)), o.push("```");
274
+ n.push(`- ${t}: `), n.push("```json"), n.push(JSON.stringify(o)), n.push("```");
268
275
  }
269
276
  }
270
- function be(o, e) {
277
+ function Fe(n, e) {
271
278
  const t = ["- Numeric Constraints"];
272
279
  e.minimum !== void 0 && t.push(` - minimum: ${e.minimum}`), e.maximum !== void 0 && t.push(` - maximum: ${e.maximum}`), e.exclusiveMinimum !== void 0 && t.push(
273
280
  ` - exclusiveMinimum: ${e.exclusiveMinimum}`
274
281
  ), e.exclusiveMaximum !== void 0 && t.push(
275
282
  ` - exclusiveMaximum: ${e.exclusiveMaximum}`
276
- ), e.multipleOf !== void 0 && t.push(` - multipleOf: ${e.multipleOf}`), t.length !== 1 && o.push(...t);
283
+ ), e.multipleOf !== void 0 && t.push(` - multipleOf: ${e.multipleOf}`), t.length !== 1 && n.push(...t);
277
284
  }
278
- function qe(o, e) {
285
+ function je(n, e) {
279
286
  const t = ["- String Constraints"];
280
- e.minLength !== void 0 && t.push(` - minLength: ${e.minLength}`), e.maxLength !== void 0 && t.push(` - maxLength: ${e.maxLength}`), e.pattern !== void 0 && t.push(` - pattern: ${e.pattern}`), t.length !== 1 && o.push(...t);
287
+ e.minLength !== void 0 && t.push(` - minLength: ${e.minLength}`), e.maxLength !== void 0 && t.push(` - maxLength: ${e.maxLength}`), e.pattern !== void 0 && t.push(` - pattern: ${e.pattern}`), t.length !== 1 && n.push(...t);
281
288
  }
282
- function je(o, e) {
289
+ function _e(n, e) {
283
290
  const t = ["- Array Constraints"];
284
- e.minItems !== void 0 && t.push(` - minItems: ${e.minItems}`), e.maxItems !== void 0 && t.push(` - maxItems: ${e.maxItems}`), e.uniqueItems !== void 0 && t.push(` - uniqueItems: ${e.uniqueItems}`), t.length !== 1 && o.push(...t);
291
+ e.minItems !== void 0 && t.push(` - minItems: ${e.minItems}`), e.maxItems !== void 0 && t.push(` - maxItems: ${e.maxItems}`), e.uniqueItems !== void 0 && t.push(` - uniqueItems: ${e.uniqueItems}`), t.length !== 1 && n.push(...t);
285
292
  }
286
- function _e(o) {
287
- const e = o.split(".");
293
+ function Ge(n) {
294
+ const e = n.split(".");
288
295
  return e.length != 2 || e[0].length === 0 || e[1].length === 0 ? null : e;
289
296
  }
290
- function Fe(o) {
291
- const e = _e(o.name);
297
+ function We(n) {
298
+ const e = Ge(n.name);
292
299
  return e ? {
293
- tag: o,
300
+ tag: n,
294
301
  contextAlias: e[0],
295
302
  aggregateName: e[1]
296
303
  } : null;
297
304
  }
298
- function Ge(o) {
299
- const e = o?.map((n) => Fe(n)).filter((n) => n !== null);
305
+ function ke(n) {
306
+ const e = n?.map((o) => We(o)).filter((o) => o !== null);
300
307
  if (!e)
301
308
  return /* @__PURE__ */ new Map();
302
309
  const t = /* @__PURE__ */ new Map();
303
- return e.forEach((n) => {
304
- t.set(n.tag.name, {
305
- aggregate: n,
310
+ return e.forEach((o) => {
311
+ t.set(o.tag.name, {
312
+ aggregate: o,
306
313
  commands: /* @__PURE__ */ new Map(),
307
314
  events: /* @__PURE__ */ new Map()
308
315
  });
309
316
  }), t;
310
317
  }
311
- function We(o) {
312
- if (!o)
318
+ function Le(n) {
319
+ if (!n)
313
320
  return null;
314
- const e = o.split(".");
321
+ const e = n.split(".");
315
322
  return e.length != 3 ? null : e[2];
316
323
  }
317
- const Le = "#/components/responses/wow.CommandOk", ze = "#/components/parameters/wow.id";
318
- class ke {
324
+ const ze = "#/components/responses/wow.CommandOk", Be = "#/components/parameters/wow.id";
325
+ class Qe {
319
326
  /**
320
327
  * Creates a new AggregateResolver instance.
321
328
  * @param openAPI - The OpenAPI specification to resolve aggregates from
322
329
  */
323
330
  constructor(e) {
324
- this.openAPI = e, this.aggregates = Ge(e.tags), this.build();
331
+ this.openAPI = e, this.aggregates = ke(e.tags), this.build();
325
332
  }
326
333
  aggregates;
327
334
  /**
@@ -330,8 +337,8 @@ class ke {
330
337
  */
331
338
  build() {
332
339
  for (const [e, t] of Object.entries(this.openAPI.paths)) {
333
- const n = M(t);
334
- for (const r of n)
340
+ const o = b(t);
341
+ for (const r of o)
335
342
  this.commands(e, r), this.state(r.operation), this.events(r.operation), this.fields(r.operation);
336
343
  }
337
344
  }
@@ -344,9 +351,9 @@ class ke {
344
351
  for (const t of this.aggregates.values()) {
345
352
  if (!t.state || !t.fields)
346
353
  continue;
347
- const n = t.aggregate.contextAlias;
348
- let r = e.get(n);
349
- r || (r = /* @__PURE__ */ new Set(), e.set(n, r)), r.add(t);
354
+ const o = t.aggregate.contextAlias;
355
+ let r = e.get(o);
356
+ r || (r = /* @__PURE__ */ new Set(), e.set(o, r)), r.add(t);
350
357
  }
351
358
  return e;
352
359
  }
@@ -356,43 +363,43 @@ class ke {
356
363
  * @param methodOperation - The HTTP method and operation details
357
364
  */
358
365
  commands(e, t) {
359
- const n = t.operation;
360
- if (n.operationId === "wow.command.send")
366
+ const o = t.operation;
367
+ if (o.operationId === "wow.command.send")
361
368
  return;
362
- const r = We(n.operationId);
369
+ const r = Le(o.operationId);
363
370
  if (!r)
364
371
  return;
365
- const i = F(n);
366
- if (!i || !g(i) || i.$ref !== Le || !n.requestBody)
372
+ const i = j(o);
373
+ if (!i || !u(i) || i.$ref !== ze || !o.requestBody)
367
374
  return;
368
- const s = n.parameters ?? [], a = s.filter((m) => g(m) && m.$ref === ze).at(0), c = s.filter(
369
- (m) => !g(m) && m.in === "path"
375
+ const s = o.parameters ?? [], a = s.filter((d) => u(d) && d.$ref === Be).at(0), c = s.filter(
376
+ (d) => !u(d) && d.in === "path"
370
377
  );
371
378
  if (a) {
372
- const m = H(
379
+ const d = H(
373
380
  a,
374
381
  this.openAPI.components
375
382
  );
376
- c.push(m);
383
+ c.push(d);
377
384
  }
378
- const l = n.requestBody.content[E.APPLICATION_JSON].schema, p = I(
379
- l,
385
+ const p = o.requestBody.content[$.APPLICATION_JSON].schema, l = P(
386
+ p,
380
387
  this.openAPI.components
381
388
  );
382
- p.schema.title = p.schema.title || n.summary, p.schema.description = p.schema.description || n.description;
383
- const ue = {
389
+ l.schema.title = l.schema.title || o.summary, l.schema.description = l.schema.description || o.description;
390
+ const pe = {
384
391
  name: r,
385
392
  method: t.method,
386
393
  path: e,
387
394
  pathParameters: c,
388
- summary: n.summary,
389
- description: n.description,
390
- schema: p,
391
- operation: n
395
+ summary: o.summary,
396
+ description: o.description,
397
+ schema: l,
398
+ operation: o
392
399
  };
393
- n.tags?.forEach((m) => {
394
- const G = this.aggregates.get(m);
395
- G && G.commands.set(r, ue);
400
+ o.tags?.forEach((d) => {
401
+ const _ = this.aggregates.get(d);
402
+ _ && _.commands.set(r, pe);
396
403
  });
397
404
  }
398
405
  /**
@@ -402,16 +409,16 @@ class ke {
402
409
  state(e) {
403
410
  if (!e.operationId?.endsWith(".snapshot_state.single"))
404
411
  return;
405
- const t = B(e);
406
- if (!g(t))
412
+ const t = z(e);
413
+ if (!u(t))
407
414
  return;
408
- const n = I(
415
+ const o = P(
409
416
  t,
410
417
  this.openAPI.components
411
418
  );
412
419
  e.tags?.forEach((r) => {
413
420
  const i = this.aggregates.get(r);
414
- i && (i.state = n);
421
+ i && (i.state = o);
415
422
  });
416
423
  }
417
424
  /**
@@ -421,24 +428,24 @@ class ke {
421
428
  events(e) {
422
429
  if (!this.openAPI.components || !e.operationId?.endsWith(".event.list_query"))
423
430
  return;
424
- const t = B(e);
425
- if (g(t))
431
+ const t = z(e);
432
+ if (u(t))
426
433
  return;
427
- const n = t?.items;
428
- if (!g(n))
434
+ const o = t?.items;
435
+ if (!u(o))
429
436
  return;
430
- const i = S(
431
- n,
437
+ const i = I(
438
+ o,
432
439
  this.openAPI.components
433
440
  ).properties.body.items.anyOf.map((s) => {
434
- const a = s.title, c = s.properties.name.const, u = s.properties.body, l = I(
435
- u,
441
+ const a = s.title, c = s.properties.name.const, g = s.properties.body, p = P(
442
+ g,
436
443
  this.openAPI.components
437
444
  );
438
- return l.schema.title = l.schema.title || s.title, {
445
+ return p.schema.title = p.schema.title || s.title, {
439
446
  title: a,
440
447
  name: c,
441
- schema: l
448
+ schema: p
442
449
  };
443
450
  });
444
451
  e.tags?.forEach((s) => {
@@ -455,20 +462,20 @@ class ke {
455
462
  fields(e) {
456
463
  if (!this.openAPI.components || !e.operationId?.endsWith(".snapshot.count"))
457
464
  return;
458
- const n = V(
465
+ const o = V(
459
466
  e.requestBody,
460
467
  this.openAPI.components
461
- ).content[E.APPLICATION_JSON].schema, i = S(
462
- n,
468
+ ).content[$.APPLICATION_JSON].schema, i = I(
469
+ o,
463
470
  this.openAPI.components
464
- ).properties?.field, s = I(i, this.openAPI.components);
471
+ ).properties?.field, s = P(i, this.openAPI.components);
465
472
  e.tags?.forEach((a) => {
466
473
  const c = this.aggregates.get(a);
467
474
  c && (c.fields = s);
468
475
  });
469
476
  }
470
477
  }
471
- const P = "@ahoo-wang/fetcher-wow", Be = {
478
+ const x = "@ahoo-wang/fetcher-wow", Ue = {
472
479
  "wow.command.CommandResult": "CommandResult",
473
480
  "wow.command.CommandResultArray": "CommandResultArray",
474
481
  "wow.MessageHeaderSqlType": "MessageHeaderSqlType",
@@ -498,32 +505,188 @@ const P = "@ahoo-wang/fetcher-wow", Be = {
498
505
  "wow.openapi.BatchResult": "BatchResult",
499
506
  "wow.messaging.CompensationTarget": "CompensationTarget"
500
507
  };
501
- function d(o) {
502
- if (!o)
508
+ function m(n) {
509
+ if (!n)
503
510
  return { name: "", path: "/" };
504
- const e = Be[o];
511
+ const e = Ue[n];
505
512
  if (e)
506
- return { name: e, path: P };
507
- const t = o.split(".");
508
- let n = -1;
513
+ return { name: e, path: x };
514
+ const t = n.split(".");
515
+ let o = -1;
509
516
  for (let c = 0; c < t.length; c++)
510
517
  if (t[c] && /^[A-Z]/.test(t[c])) {
511
- n = c;
518
+ o = c;
512
519
  break;
513
520
  }
514
- const r = t.slice(0, n), i = r.length > 0 ? `/${r.join("/")}` : "/", s = t.slice(n);
515
- return { name: x(s), path: i };
521
+ const r = t.slice(0, o), i = r.length > 0 ? `/${r.join("/")}` : "/", s = t.slice(o);
522
+ return { name: S(s), path: i };
516
523
  }
517
- function y(o) {
518
- const e = $(o);
519
- return d(e);
524
+ function C(n) {
525
+ const e = A(n);
526
+ return m(e);
520
527
  }
521
- class Ue {
528
+ class Je {
529
+ constructor(e, t, o, r) {
530
+ this.modelInfo = e, this.sourceFile = t, this.keySchema = o, this.outputDir = r;
531
+ }
532
+ generate() {
533
+ const e = this.process();
534
+ e && B(e, this.keySchema.schema, this.keySchema.key);
535
+ }
536
+ process() {
537
+ const { schema: e } = this.keySchema;
538
+ return k(e) ? this.processEnum(e) : R(e) ? this.processInterface(e) : D(e) ? this.processArray(e) : N(e) ? this.processIntersection(e) : L(e) ? this.processComposition(e) : this.processTypeAlias(e);
539
+ }
540
+ resolveReference(e) {
541
+ const t = C(e);
542
+ return qe(
543
+ this.modelInfo,
544
+ this.sourceFile,
545
+ this.outputDir,
546
+ t
547
+ ), t;
548
+ }
549
+ resolveAdditionalProperties(e) {
550
+ return e.additionalProperties === void 0 || e.additionalProperties === !1 ? "" : e.additionalProperties === !0 ? "[key: string]: any" : `[key: string]: ${this.resolveType(
551
+ e.additionalProperties
552
+ )}`;
553
+ }
554
+ resolvePropertyDefinitions(e) {
555
+ const { properties: t } = e;
556
+ return Object.entries(t).map(([o, r]) => {
557
+ const i = this.resolveType(r);
558
+ if (!u(r)) {
559
+ const s = ie(r), a = re(s, `
560
+ * `);
561
+ if (a)
562
+ return `
563
+ /**
564
+ * ${a}
565
+ */
566
+ ${o}: ${i}
567
+ `;
568
+ }
569
+ return `${o}: ${i}`;
570
+ });
571
+ }
572
+ resolveObjectType(e) {
573
+ const t = [];
574
+ if (R(e)) {
575
+ const r = this.resolvePropertyDefinitions(e);
576
+ t.push(...r);
577
+ }
578
+ const o = this.resolveAdditionalProperties(e);
579
+ return o && t.push(o), t.length === 0 ? "Record<string, any>" : `{
580
+ ${t.join(`;
581
+ `)};
582
+ }`;
583
+ }
584
+ resolveMapValueType(e) {
585
+ return e.additionalProperties === void 0 || e.additionalProperties === !1 || e.additionalProperties === !0 ? "any" : this.resolveType(e.additionalProperties);
586
+ }
587
+ resolveType(e) {
588
+ if (u(e))
589
+ return this.resolveReference(e).name;
590
+ if (ve(e))
591
+ return `Record<string,${this.resolveMapValueType(e)}>`;
592
+ if (e.const)
593
+ return `'${e.const}'`;
594
+ if (k(e))
595
+ return e.enum.map((t) => `'${t}'`).join(" | ");
596
+ if (L(e)) {
597
+ const o = (e.oneOf || e.anyOf || e.allOf || []).map((i) => this.resolveType(i)), r = N(e) ? " & " : " | ";
598
+ return `(${o.join(r)})`;
599
+ }
600
+ if (D(e)) {
601
+ const t = this.resolveType(e.items);
602
+ return Ie(t);
603
+ }
604
+ return e.type === "object" ? this.resolveObjectType(e) : e.type ? E(e.type) : "any";
605
+ }
606
+ processEnum(e) {
607
+ return this.sourceFile.addEnum({
608
+ name: this.modelInfo.name,
609
+ isExported: !0,
610
+ members: e.enum.filter((t) => typeof t == "string" && t.length > 0).map((t) => ({
611
+ name: xe(t),
612
+ initializer: `'${t}'`
613
+ }))
614
+ });
615
+ }
616
+ addPropertyToInterface(e, t, o) {
617
+ const r = this.resolveType(o);
618
+ let i = e.getProperty(t);
619
+ i ? i.setType(r) : i = e.addProperty({
620
+ name: t,
621
+ type: r
622
+ }), u(o) || B(i, o);
623
+ }
624
+ processInterface(e) {
625
+ const t = this.sourceFile.addInterface({
626
+ name: this.modelInfo.name,
627
+ isExported: !0
628
+ }), o = e.properties || {};
629
+ return Object.entries(o).forEach(([r, i]) => {
630
+ this.addPropertyToInterface(t, r, i);
631
+ }), e.additionalProperties && t.addIndexSignature({
632
+ keyName: "key",
633
+ keyType: "string",
634
+ returnType: this.resolveType(
635
+ e.additionalProperties === !0 ? {} : e.additionalProperties
636
+ )
637
+ }).addJsDoc("Additional properties"), t;
638
+ }
639
+ processArray(e) {
640
+ const t = this.resolveType(e.items);
641
+ return this.sourceFile.addTypeAlias({
642
+ name: this.modelInfo.name,
643
+ type: `Array<${t}>`,
644
+ isExported: !0
645
+ });
646
+ }
647
+ processComposition(e) {
648
+ return this.sourceFile.addTypeAlias({
649
+ name: this.modelInfo.name,
650
+ type: this.resolveType(e),
651
+ isExported: !0
652
+ });
653
+ }
654
+ processIntersection(e) {
655
+ const t = this.sourceFile.addInterface({
656
+ name: this.modelInfo.name,
657
+ isExported: !0
658
+ });
659
+ return e.allOf.forEach((o) => {
660
+ if (u(o)) {
661
+ const r = this.resolveType(o);
662
+ t.addExtends(r);
663
+ return;
664
+ }
665
+ R(o) && Object.entries(o.properties).forEach(
666
+ ([r, i]) => {
667
+ this.addPropertyToInterface(
668
+ t,
669
+ r,
670
+ i
671
+ );
672
+ }
673
+ );
674
+ }), t;
675
+ }
676
+ processTypeAlias(e) {
677
+ return this.sourceFile.addTypeAlias({
678
+ name: this.modelInfo.name,
679
+ type: this.resolveType(e),
680
+ isExported: !0
681
+ });
682
+ }
683
+ }
684
+ class Ve {
522
685
  constructor(e) {
523
686
  this.context = e;
524
687
  }
525
688
  getOrCreateSourceFile(e) {
526
- const t = De(e);
689
+ const t = Me(e);
527
690
  return this.context.getOrCreateSourceFile(t);
528
691
  }
529
692
  /**
@@ -540,29 +703,29 @@ class Ue {
540
703
  this.context.logger.info("No schemas found in OpenAPI specification");
541
704
  return;
542
705
  }
543
- const t = this.stateAggregatedTypeNames(), n = this.filterSchemas(e, t);
544
- this.context.logger.progress(`Generating models for ${n.length} schemas`), n.forEach((r, i) => {
706
+ const t = this.stateAggregatedTypeNames(), o = this.filterSchemas(e, t);
707
+ this.context.logger.progress(`Generating models for ${o.length} schemas`), o.forEach((r, i) => {
545
708
  this.context.logger.progressWithCount(
546
709
  i + 1,
547
- n.length,
710
+ o.length,
548
711
  `Processing schema: ${r.key}`,
549
712
  2
550
713
  ), this.generateKeyedSchema(r);
551
714
  }), this.context.logger.success("Model generation completed");
552
715
  }
553
716
  filterSchemas(e, t) {
554
- return Object.entries(e).map(([n, r]) => ({
555
- key: n,
717
+ return Object.entries(e).map(([o, r]) => ({
718
+ key: o,
556
719
  schema: r
557
- })).filter((n) => !this.isWowSchema(n.key, t));
720
+ })).filter((o) => !this.isWowSchema(o.key, t));
558
721
  }
559
722
  isWowSchema(e, t) {
560
723
  if (e !== "wow.api.query.PagedList" && e.startsWith("wow.api.query.") && e.endsWith("PagedList"))
561
724
  return !1;
562
725
  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"))
563
726
  return !0;
564
- const n = d(e);
565
- return t.has(n.name);
727
+ const o = m(e);
728
+ return t.has(o.name);
566
729
  }
567
730
  aggregatedSchemaSuffix = [
568
731
  "MaterializedSnapshot",
@@ -576,10 +739,10 @@ class Ue {
576
739
  stateAggregatedTypeNames() {
577
740
  const e = /* @__PURE__ */ new Set();
578
741
  for (const t of this.context.contextAggregates.values())
579
- for (const n of t)
742
+ for (const o of t)
580
743
  this.aggregatedSchemaSuffix.forEach(
581
744
  (r) => {
582
- const i = d(n.state.key), s = x(i.name) + r;
745
+ const i = m(o.state.key), s = S(i.name) + r;
583
746
  e.add(s);
584
747
  }
585
748
  );
@@ -589,8 +752,6 @@ class Ue {
589
752
  * Generates a model for a specific schema key.
590
753
  * Processes enums, objects, unions, and type aliases in order.
591
754
  *
592
- * @param schemaKey - The key of the schema to generate
593
- * @param schema - The schema definition
594
755
  *
595
756
  * @remarks
596
757
  * The generation process follows this order:
@@ -599,151 +760,12 @@ class Ue {
599
760
  * 3. Union processing
600
761
  * 4. Type alias processing
601
762
  */
602
- generateKeyedSchema({ key: e, schema: t }) {
603
- const n = d(e), r = this.getOrCreateSourceFile(n), i = this.process(n, r, t);
604
- i && R(i, t);
605
- }
606
- process(e, t, n) {
607
- if (Pe(n))
608
- return t.addEnum({
609
- name: e.name,
610
- isExported: !0,
611
- members: n.enum.filter((i) => typeof i == "string" && i.length > 0).map((i) => ({
612
- name: ye(i),
613
- initializer: `'${i}'`
614
- }))
615
- });
616
- if (D(n) && g(n.items)) {
617
- const i = y(n.items);
618
- return T(
619
- e,
620
- t,
621
- this.context.outputDir,
622
- i
623
- ), t.addTypeAlias({
624
- name: e.name,
625
- type: k(i.name),
626
- isExported: !0
627
- });
628
- }
629
- const r = t.addInterface({
630
- name: e.name,
631
- isExported: !0
632
- });
633
- return n.type === "object" && n.properties ? this.processInterface(
634
- t,
635
- e,
636
- n,
637
- r
638
- ) : (z(n) && (n.anyOf || n.oneOf || n.allOf).forEach((s) => {
639
- if (g(s)) {
640
- const a = y(s);
641
- T(
642
- e,
643
- t,
644
- this.context.outputDir,
645
- a
646
- ), r.addExtends(a.name);
647
- return;
648
- }
649
- this.processInterface(
650
- t,
651
- e,
652
- s,
653
- r
654
- );
655
- }), r);
656
- }
657
- processObject(e, t, n) {
658
- const r = e.addInterface({
659
- name: t.name,
660
- isExported: !0
661
- });
662
- return this.processInterface(
663
- e,
664
- t,
665
- n,
666
- r
667
- );
668
- }
669
- processInterface(e, t, n, r) {
670
- for (const [i, s] of Object.entries(n.properties)) {
671
- const a = this.resolvePropertyType(
672
- t,
673
- e,
674
- i,
675
- s
676
- );
677
- let c = r.getProperty(i);
678
- c ? c.setType(a) : c = r.addProperty({
679
- name: i,
680
- type: a
681
- }), g(s) || R(c, s);
682
- }
683
- return r;
684
- }
685
- resolvePropertyType(e, t, n, r) {
686
- if (g(r)) {
687
- const i = y(r);
688
- return T(
689
- e,
690
- t,
691
- this.context.outputDir,
692
- i
693
- ), i.name;
694
- }
695
- if (r.const)
696
- return `'${r.const}'`;
697
- if (D(r)) {
698
- const i = this.resolvePropertyType(
699
- e,
700
- t,
701
- n,
702
- r.items
703
- );
704
- return k(i);
705
- }
706
- if (r.type && _(r.type))
707
- return A(r.type);
708
- if (z(r))
709
- return this.resolvePropertyCompositionType(
710
- e,
711
- t,
712
- r
713
- );
714
- if (r.type === "object" && r.properties) {
715
- const i = {
716
- path: e.path,
717
- name: `${e.name}${x(n)}`
718
- }, s = this.processObject(
719
- t,
720
- i,
721
- r
722
- );
723
- return R(s, r), i.name;
724
- }
725
- return "any";
726
- }
727
- resolvePropertyCompositionType(e, t, n) {
728
- const r = n.anyOf || n.oneOf || n.allOf, i = /* @__PURE__ */ new Set();
729
- r.forEach((a) => {
730
- if (g(a)) {
731
- const c = y(a);
732
- T(
733
- e,
734
- t,
735
- this.context.outputDir,
736
- c
737
- ), i.add(c.name);
738
- return;
739
- }
740
- i.add(A(a.type ?? "string"));
741
- });
742
- const s = $e(n) ? "|" : "&";
743
- return Array.from(i).join(s);
763
+ generateKeyedSchema(e) {
764
+ const t = m(e.key), o = this.getOrCreateSourceFile(t);
765
+ new Je(t, o, e, this.context.outputDir).generate();
744
766
  }
745
767
  }
746
- const Qe = "@ahoo-wang/fetcher-decorator", Je = [
768
+ const He = "@ahoo-wang/fetcher-decorator", Ye = [
747
769
  "type ApiMetadata",
748
770
  "type ApiMetadataCapable",
749
771
  "type ParameterRequest",
@@ -757,22 +779,22 @@ const Qe = "@ahoo-wang/fetcher-decorator", Je = [
757
779
  "attribute",
758
780
  "path",
759
781
  "autoGeneratedError"
760
- ], Ve = {
782
+ ], Ke = {
761
783
  type: "Promise<Response>",
762
784
  metadata: "{resultExtractor: ResultExtractors.Response }"
763
- }, Q = {
785
+ }, U = {
764
786
  type: "Promise<string>",
765
787
  metadata: "{resultExtractor: ResultExtractors.Text }"
766
- }, b = `{
788
+ }, M = `{
767
789
  headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },
768
790
  resultExtractor: JsonEventStreamResultExtractor,
769
791
  }`;
770
- function ie(o) {
771
- C(o, Qe, Je);
792
+ function se(n) {
793
+ y(n, He, Ye);
772
794
  }
773
- function se(o, e, t = []) {
795
+ function ae(n, e, t = []) {
774
796
  return e.addClass({
775
- name: o,
797
+ name: n,
776
798
  isExported: !0,
777
799
  decorators: [
778
800
  {
@@ -782,8 +804,8 @@ function se(o, e, t = []) {
782
804
  ]
783
805
  });
784
806
  }
785
- function ae(o, e) {
786
- o.addImplements("ApiMetadataCapable"), o.addConstructor({
807
+ function ce(n, e) {
808
+ n.addImplements("ApiMetadataCapable"), n.addConstructor({
787
809
  parameters: [
788
810
  {
789
811
  name: "apiMetadata",
@@ -796,42 +818,42 @@ function ae(o, e) {
796
818
  ]
797
819
  });
798
820
  }
799
- const He = "@ahoo-wang/fetcher-eventstream";
800
- function ce(o) {
801
- C(o, He, ["JsonEventStreamResultExtractor", "type JsonServerSentEventStream"]);
821
+ const Xe = "@ahoo-wang/fetcher-eventstream";
822
+ function ge(n) {
823
+ y(n, Xe, ["JsonEventStreamResultExtractor", "type JsonServerSentEventStream"]);
802
824
  }
803
- function Ye(o) {
825
+ function Ze(n) {
804
826
  let e = 0, t = 0;
805
- return o.commands.forEach((n) => {
806
- n.path.startsWith(W.TENANT) && (e += 1), n.path.startsWith(W.OWNER) && (t += 1);
827
+ return n.commands.forEach((o) => {
828
+ o.path.startsWith(G.TENANT) && (e += 1), o.path.startsWith(G.OWNER) && (t += 1);
807
829
  }), e === 0 && t === 0 ? "ResourceAttributionPathSpec.NONE" : e > t ? "ResourceAttributionPathSpec.TENANT" : "ResourceAttributionPathSpec.OWNER";
808
830
  }
809
- function ge(o, e, t, n) {
810
- const r = `${t.contextAlias}/${t.aggregateName}/${n}.ts`;
811
- return re(o, e, r);
831
+ function ue(n, e, t, o) {
832
+ const r = `${t.contextAlias}/${t.aggregateName}/${o}.ts`;
833
+ return oe(n, e, r);
812
834
  }
813
- function Ke(o, e) {
814
- return `${x(o.aggregateName)}${e}`;
835
+ function et(n, e) {
836
+ return `${S(n.aggregateName)}${e}`;
815
837
  }
816
- function q(o) {
817
- return o === "delete" ? "del" : o;
838
+ function q(n) {
839
+ return n === "delete" ? "del" : n;
818
840
  }
819
- const Xe = "x-fetcher-method";
820
- function Ze(o, e) {
821
- const t = o[Xe];
841
+ const tt = "x-fetcher-method";
842
+ function nt(n, e) {
843
+ const t = n[tt];
822
844
  if (t)
823
845
  return t;
824
- if (!o.operationId)
846
+ if (!n.operationId)
825
847
  return;
826
- const n = N(o.operationId);
827
- for (let r = n.length - 1; r >= 0; r--) {
828
- const i = h(n.slice(r));
848
+ const o = O(n.operationId);
849
+ for (let r = o.length - 1; r >= 0; r--) {
850
+ const i = h(o.slice(r));
829
851
  if (!e(i))
830
852
  return i;
831
853
  }
832
- return h(n);
854
+ return h(o);
833
855
  }
834
- class et {
856
+ class ot {
835
857
  /**
836
858
  * Creates a new ApiClientGenerator instance.
837
859
  * @param context - The generation context containing OpenAPI spec and configuration
@@ -840,7 +862,7 @@ class et {
840
862
  this.context = e, this.apiMetadataCtorInitializer = this.context.currentContextAlias ? `{basePath:'${this.context.currentContextAlias}'}` : void 0;
841
863
  }
842
864
  defaultParameterRequestType = "ParameterRequest";
843
- defaultReturnType = Ve;
865
+ defaultReturnType = Ke;
844
866
  apiMetadataCtorInitializer;
845
867
  /**
846
868
  * Generates API client classes for all valid tags in the OpenAPI specification.
@@ -866,10 +888,10 @@ class et {
866
888
  this.context.logger.info(
867
889
  `Generating ${t.size} API client classes`
868
890
  );
869
- let n = 0;
891
+ let o = 0;
870
892
  for (const [r, i] of t) {
871
- n++, this.context.logger.progressWithCount(
872
- n,
893
+ o++, this.context.logger.progressWithCount(
894
+ o,
873
895
  t.size,
874
896
  `Generating API client for tag: ${r}`
875
897
  );
@@ -884,7 +906,7 @@ class et {
884
906
  */
885
907
  createApiClientFile(e) {
886
908
  let t = e.path;
887
- return this.context.currentContextAlias && (t = v(this.context.currentContextAlias, t)), t = v(t, `${e.name}ApiClient.ts`), this.context.logger.info(`Creating API client file: ${t}`), this.context.getOrCreateSourceFile(t);
909
+ return this.context.currentContextAlias && (t = T(this.context.currentContextAlias, t)), t = T(t, `${e.name}ApiClient.ts`), this.context.logger.info(`Creating API client file: ${t}`), this.context.getOrCreateSourceFile(t);
888
910
  }
889
911
  /**
890
912
  * Generates a single API client class for the given tag and operations.
@@ -892,22 +914,22 @@ class et {
892
914
  * @param operations - Set of operations for this client
893
915
  */
894
916
  generateApiClient(e, t) {
895
- const n = d(e.name);
917
+ const o = m(e.name);
896
918
  this.context.logger.info(
897
- `Generating API client class: ${n.name}ApiClient with ${t.size} operations`
919
+ `Generating API client class: ${o.name}ApiClient with ${t.size} operations`
898
920
  );
899
- const r = this.createApiClientFile(n);
900
- ie(r), ce(r);
901
- const i = se(
902
- n.name + "ApiClient",
921
+ const r = this.createApiClientFile(o);
922
+ se(r), ge(r);
923
+ const i = ae(
924
+ o.name + "ApiClient",
903
925
  r
904
926
  );
905
- w(i, [e.description]), ae(i, this.apiMetadataCtorInitializer), this.context.logger.info(
906
- `Processing ${t.size} operations for ${n.name}ApiClient`
927
+ v(i, [e.description]), ce(i, this.apiMetadataCtorInitializer), this.context.logger.info(
928
+ `Processing ${t.size} operations for ${o.name}ApiClient`
907
929
  ), t.forEach((s) => {
908
930
  this.processOperation(e, r, i, s);
909
931
  }), this.context.logger.success(
910
- `Completed API client: ${n.name}ApiClient`
932
+ `Completed API client: ${o.name}ApiClient`
911
933
  );
912
934
  }
913
935
  /**
@@ -917,10 +939,10 @@ class et {
917
939
  * @returns A unique camelCase method name
918
940
  */
919
941
  getMethodName(e, t) {
920
- const n = Ze(t, (r) => e.getMethod(r) !== void 0);
921
- if (!n)
942
+ const o = nt(t, (r) => e.getMethod(r) !== void 0);
943
+ if (!o)
922
944
  throw new Error(`Unable to resolve method name for apiClientClass:${e.getName()}.`);
923
- return n;
945
+ return o;
924
946
  }
925
947
  /**
926
948
  * Resolves the request type for an operation based on its request body.
@@ -933,24 +955,24 @@ class et {
933
955
  return this.context.logger.info(
934
956
  `No request body found for operation ${t.operationId}, using default: ${this.defaultParameterRequestType}`
935
957
  ), this.defaultParameterRequestType;
936
- let n;
937
- if (g(t.requestBody) ? (this.context.logger.info(
958
+ let o;
959
+ if (u(t.requestBody) ? (this.context.logger.info(
938
960
  `Extracting request body from reference for operation: ${t.operationId}`
939
- ), n = V(
961
+ ), o = V(
940
962
  t.requestBody,
941
963
  this.context.openAPI.components
942
- )) : n = t.requestBody, !n)
964
+ )) : o = t.requestBody, !o)
943
965
  return this.context.logger.info(
944
966
  `Request body extraction failed for operation ${t.operationId}, using default: ${this.defaultParameterRequestType}`
945
967
  ), this.defaultParameterRequestType;
946
- if (n.content["multipart/form-data"])
968
+ if (o.content["multipart/form-data"])
947
969
  return this.context.logger.info(
948
970
  `Detected multipart/form-data content for operation ${t.operationId}, using ParameterRequest<FormData>`
949
971
  ), "ParameterRequest<FormData>";
950
- if (n.content["application/json"]) {
951
- const r = n.content["application/json"].schema;
952
- if (g(r)) {
953
- const i = y(r);
972
+ if (o.content["application/json"]) {
973
+ const r = o.content["application/json"].schema;
974
+ if (u(r)) {
975
+ const i = C(r);
954
976
  this.context.logger.info(
955
977
  `Adding import for request body model: ${i.name} from ${i.path}`
956
978
  ), f(e, this.context.outputDir, i);
@@ -971,16 +993,16 @@ class et {
971
993
  * @param operation - The operation to resolve parameters for
972
994
  * @returns Array of parameter declarations
973
995
  */
974
- resolveParameters(e, t, n) {
975
- const r = Ee(n, this.context.openAPI.components).filter((a) => !this.context.isIgnoreApiClientPathParameters(
996
+ resolveParameters(e, t, o) {
997
+ const r = Ee(o, this.context.openAPI.components).filter((a) => !this.context.isIgnoreApiClientPathParameters(
976
998
  e.name,
977
999
  a.name
978
1000
  ));
979
1001
  this.context.logger.info(
980
- `Found ${r.length} path parameters for operation ${n.operationId}`
1002
+ `Found ${r.length} path parameters for operation ${o.operationId}`
981
1003
  );
982
1004
  const i = r.map((a) => {
983
- const c = ee(a);
1005
+ const c = Z(a);
984
1006
  return this.context.logger.info(
985
1007
  `Adding path parameter: ${a.name} (type: ${c})`
986
1008
  ), {
@@ -994,7 +1016,7 @@ class et {
994
1016
  }
995
1017
  ]
996
1018
  };
997
- }), s = this.resolveRequestType(t, n);
1019
+ }), s = this.resolveRequestType(t, o);
998
1020
  return this.context.logger.info(`Adding httpRequest parameter: ${s}`), i.push({
999
1021
  name: "httpRequest",
1000
1022
  hasQuestionToken: s === this.defaultParameterRequestType,
@@ -1026,9 +1048,9 @@ class et {
1026
1048
  * @returns The resolved return type string
1027
1049
  */
1028
1050
  resolveSchemaReturnType(e, t) {
1029
- const n = "Promise<any>";
1030
- if (g(t)) {
1031
- const r = y(t);
1051
+ const o = "Promise<any>";
1052
+ if (u(t)) {
1053
+ const r = C(t);
1032
1054
  this.context.logger.info(
1033
1055
  `Adding import for response model: ${r.name} from ${r.path}`
1034
1056
  ), f(e, this.context.outputDir, r);
@@ -1037,15 +1059,15 @@ class et {
1037
1059
  }
1038
1060
  if (!t.type)
1039
1061
  return this.context.logger.info(
1040
- `Schema has no type, using default return type: ${n}`
1041
- ), n;
1042
- if (_(t.type)) {
1043
- const i = `Promise<${A(t.type)}>`;
1062
+ `Schema has no type, using default return type: ${o}`
1063
+ ), o;
1064
+ if (X(t.type)) {
1065
+ const i = `Promise<${E(t.type)}>`;
1044
1066
  return this.context.logger.info(`Resolved primitive return type: ${i}`), i;
1045
1067
  }
1046
1068
  return this.context.logger.info(
1047
- `Using default return type: ${n}`
1048
- ), n;
1069
+ `Using default return type: ${o}`
1070
+ ), o;
1049
1071
  }
1050
1072
  /**
1051
1073
  * Resolves the return type for an operation based on its responses.
@@ -1054,46 +1076,46 @@ class et {
1054
1076
  * @returns Object containing type and optional stream flag
1055
1077
  */
1056
1078
  resolveReturnType(e, t) {
1057
- const n = F(t);
1058
- if (!n)
1079
+ const o = j(t);
1080
+ if (!o)
1059
1081
  return this.context.logger.info(
1060
1082
  `No OK response found for operation ${t.operationId}, using default return type: ${this.defaultReturnType.type}`
1061
1083
  ), this.defaultReturnType;
1062
- const r = K(n) || Ae(n);
1084
+ const r = K(o) || Pe(o);
1063
1085
  if (r) {
1064
1086
  const s = this.resolveSchemaReturnType(e, r);
1065
1087
  return this.context.logger.info(
1066
1088
  `Resolved JSON/wildcard response return type for operation ${t.operationId}: ${s}`
1067
1089
  ), {
1068
1090
  type: s,
1069
- metadata: s === Q.type ? Q.metadata : void 0
1091
+ metadata: s === U.type ? U.metadata : void 0
1070
1092
  };
1071
1093
  }
1072
- const i = xe(n);
1094
+ const i = Ae(o);
1073
1095
  if (i) {
1074
- if (g(i)) {
1075
- const a = S(
1096
+ if (u(i)) {
1097
+ const a = I(
1076
1098
  i,
1077
1099
  this.context.openAPI.components
1078
1100
  );
1079
- if (D(a) && g(a.items)) {
1080
- const c = y(a.items);
1101
+ if (D(a) && u(a.items)) {
1102
+ const c = C(a.items);
1081
1103
  this.context.logger.info(
1082
1104
  `Adding import for event stream model: ${c.name} from ${c.path}`
1083
1105
  ), f(e, this.context.outputDir, c);
1084
- const l = `Promise<JsonServerSentEventStream<${c.name.includes("ServerSentEvent") ? `${c.name}['data']` : c.name}>>`;
1106
+ const p = `Promise<JsonServerSentEventStream<${c.name.includes("ServerSentEvent") ? `${c.name}['data']` : c.name}>>`;
1085
1107
  return this.context.logger.info(
1086
- `Resolved event stream return type for operation ${t.operationId}: ${l}`
1108
+ `Resolved event stream return type for operation ${t.operationId}: ${p}`
1087
1109
  ), {
1088
- type: l,
1089
- metadata: b
1110
+ type: p,
1111
+ metadata: M
1090
1112
  };
1091
1113
  }
1092
1114
  }
1093
1115
  const s = "Promise<JsonServerSentEventStream<any>>";
1094
1116
  return this.context.logger.info(
1095
1117
  `Resolved generic event stream return type for operation ${t.operationId}: ${s}`
1096
- ), { type: s, metadata: b };
1118
+ ), { type: s, metadata: M };
1097
1119
  }
1098
1120
  return this.context.logger.info(
1099
1121
  `Using default return type for operation ${t.operationId}: ${this.defaultReturnType.type}`
@@ -1106,11 +1128,11 @@ class et {
1106
1128
  * @param apiClientClass - The client class to add the method to
1107
1129
  * @param operation - The operation to process
1108
1130
  */
1109
- processOperation(e, t, n, r) {
1131
+ processOperation(e, t, o, r) {
1110
1132
  this.context.logger.info(
1111
1133
  `Processing operation: ${r.operation.operationId} (${r.method} ${r.path})`
1112
1134
  );
1113
- const i = this.getMethodName(n, r.operation);
1135
+ const i = this.getMethodName(o, r.operation);
1114
1136
  this.context.logger.info(`Generated method name: ${i}`);
1115
1137
  const s = this.resolveParameters(
1116
1138
  e,
@@ -1126,17 +1148,17 @@ class et {
1126
1148
  this.context.logger.info(
1127
1149
  `Creating method with ${s.length} parameters, return type: ${a.type}`
1128
1150
  );
1129
- const u = n.addMethod({
1151
+ const g = o.addMethod({
1130
1152
  name: i,
1131
1153
  decorators: [c],
1132
1154
  parameters: s,
1133
1155
  returnType: a.type,
1134
1156
  statements: [
1135
- `throw autoGeneratedError(${s.map((l) => l.name).join(",")});`
1157
+ `throw autoGeneratedError(${s.map((p) => p.name).join(",")});`
1136
1158
  ]
1137
1159
  });
1138
- w(
1139
- u,
1160
+ v(
1161
+ g,
1140
1162
  [
1141
1163
  r.operation.summary,
1142
1164
  r.operation.description,
@@ -1153,14 +1175,14 @@ class et {
1153
1175
  groupOperations(e) {
1154
1176
  this.context.logger.info("Grouping operations by API client tags");
1155
1177
  const t = /* @__PURE__ */ new Map();
1156
- let n = 0;
1178
+ let o = 0;
1157
1179
  for (const [r, i] of Object.entries(this.context.openAPI.paths)) {
1158
- const s = M(i).filter(
1180
+ const s = b(i).filter(
1159
1181
  (a) => {
1160
1182
  if (!a.operation.operationId)
1161
1183
  return !1;
1162
1184
  const c = a.operation.tags;
1163
- return !c || c.length == 0 ? !1 : c.every((u) => e.has(u));
1185
+ return !c || c.length == 0 ? !1 : c.every((g) => e.has(g));
1164
1186
  }
1165
1187
  );
1166
1188
  this.context.logger.info(
@@ -1168,15 +1190,15 @@ class et {
1168
1190
  );
1169
1191
  for (const a of s)
1170
1192
  a.operation.tags.forEach((c) => {
1171
- const u = {
1193
+ const g = {
1172
1194
  ...a,
1173
1195
  path: r
1174
1196
  };
1175
- t.has(c) || t.set(c, /* @__PURE__ */ new Set()), t.get(c).add(u), n++;
1197
+ t.has(c) || t.set(c, /* @__PURE__ */ new Set()), t.get(c).add(g), o++;
1176
1198
  });
1177
1199
  }
1178
1200
  return this.context.logger.info(
1179
- `Grouped ${n} operations into ${t.size} tag groups`
1201
+ `Grouped ${o} operations into ${t.size} tag groups`
1180
1202
  ), t;
1181
1203
  }
1182
1204
  shouldIgnoreTag(e) {
@@ -1193,7 +1215,7 @@ class et {
1193
1215
  );
1194
1216
  const e = /* @__PURE__ */ new Map(), t = this.context.openAPI.tags?.length || 0;
1195
1217
  for (const r of Object.values(this.context.openAPI.paths))
1196
- M(r).forEach((i) => {
1218
+ b(r).forEach((i) => {
1197
1219
  i.operation.tags?.forEach((s) => {
1198
1220
  !this.shouldIgnoreTag(s) && !e.has(s) && e.set(s, {
1199
1221
  name: s,
@@ -1201,24 +1223,24 @@ class et {
1201
1223
  });
1202
1224
  });
1203
1225
  });
1204
- let n = 0;
1226
+ let o = 0;
1205
1227
  return this.context.openAPI.tags?.forEach((r) => {
1206
1228
  this.shouldIgnoreTag(r.name) ? this.context.logger.info(
1207
1229
  `Excluded tag: ${r.name} (wow/Actuator/aggregate)`
1208
- ) : (e.set(r.name, r), n++, this.context.logger.info(`Included API client tag: ${r.name}`));
1230
+ ) : (e.set(r.name, r), o++, this.context.logger.info(`Included API client tag: ${r.name}`));
1209
1231
  }), this.context.logger.info(
1210
- `Resolved ${n} API client tags from ${t} total tags`
1232
+ `Resolved ${o} API client tags from ${t} total tags`
1211
1233
  ), e;
1212
1234
  }
1213
1235
  isAggregateTag(e) {
1214
1236
  for (const t of this.context.contextAggregates.values())
1215
- for (const n of t)
1216
- if (n.aggregate.tag.name === e)
1237
+ for (const o of t)
1238
+ if (o.aggregate.tag.name === e)
1217
1239
  return !0;
1218
1240
  return !1;
1219
1241
  }
1220
1242
  }
1221
- class tt {
1243
+ class rt {
1222
1244
  /**
1223
1245
  * Creates a new CommandClientGenerator instance.
1224
1246
  * @param context - The generation context containing OpenAPI spec and project details
@@ -1233,15 +1255,15 @@ class tt {
1233
1255
  */
1234
1256
  generate() {
1235
1257
  const e = Array.from(this.context.contextAggregates.values()).reduce(
1236
- (n, r) => n + r.size,
1258
+ (o, r) => o + r.size,
1237
1259
  0
1238
1260
  );
1239
1261
  this.context.logger.info("--- Generating Command Clients ---"), this.context.logger.progress(
1240
1262
  `Generating command clients for ${e} aggregates`
1241
1263
  );
1242
1264
  let t = 0;
1243
- for (const [, n] of this.context.contextAggregates)
1244
- n.forEach((r) => {
1265
+ for (const [, o] of this.context.contextAggregates)
1266
+ o.forEach((r) => {
1245
1267
  t++, this.context.logger.progressWithCount(
1246
1268
  t,
1247
1269
  e,
@@ -1258,7 +1280,7 @@ class tt {
1258
1280
  this.context.logger.info(
1259
1281
  `Processing command client for aggregate: ${e.aggregate.aggregateName} in context: ${e.aggregate.contextAlias}`
1260
1282
  );
1261
- const t = ge(
1283
+ const t = ue(
1262
1284
  this.context.project,
1263
1285
  this.context.outputDir,
1264
1286
  e.aggregate,
@@ -1269,7 +1291,7 @@ class tt {
1269
1291
  ), this.processCommandEndpointPaths(t, e), this.context.logger.info(
1270
1292
  `Creating default command client options: ${this.defaultCommandClientOptionsName}`
1271
1293
  ), t.addVariableStatement({
1272
- declarationKind: O.Const,
1294
+ declarationKind: w.Const,
1273
1295
  declarations: [
1274
1296
  {
1275
1297
  name: this.defaultCommandClientOptionsName,
@@ -1281,9 +1303,9 @@ class tt {
1281
1303
  ],
1282
1304
  isExported: !1
1283
1305
  }), this.context.logger.info(
1284
- `Adding imports from ${P}: CommandRequest, CommandResult, CommandResultEventStream, DeleteAggregate, RecoverAggregate`
1306
+ `Adding imports from ${x}: CommandRequest, CommandResult, CommandResultEventStream, DeleteAggregate, RecoverAggregate`
1285
1307
  ), t.addImportDeclaration({
1286
- moduleSpecifier: P,
1308
+ moduleSpecifier: x,
1287
1309
  namedImports: [
1288
1310
  "CommandRequest",
1289
1311
  "CommandResult",
@@ -1294,11 +1316,11 @@ class tt {
1294
1316
  isTypeOnly: !0
1295
1317
  }), this.context.logger.info(
1296
1318
  "Adding import from @ahoo-wang/fetcher-eventstream: JsonEventStreamResultExtractor"
1297
- ), ce(t), this.context.logger.info(
1319
+ ), ge(t), this.context.logger.info(
1298
1320
  "Adding import from @ahoo-wang/fetcher: ContentTypeValues"
1299
- ), C(t, "@ahoo-wang/fetcher", ["ContentTypeValues"]), this.context.logger.info(
1321
+ ), y(t, "@ahoo-wang/fetcher", ["ContentTypeValues"]), this.context.logger.info(
1300
1322
  "Adding imports from @ahoo-wang/fetcher-decorator: ApiMetadata types and decorators"
1301
- ), ie(t), this.context.logger.info("Generating standard command client class"), this.processCommandClient(t, e), this.context.logger.info("Generating stream command client class"), this.processCommandClient(t, e, !0), this.context.logger.success(
1323
+ ), se(t), this.context.logger.info("Generating standard command client class"), this.processCommandClient(t, e), this.context.logger.info("Generating stream command client class"), this.processCommandClient(t, e, !0), this.context.logger.success(
1302
1324
  `Command client generation completed for aggregate: ${e.aggregate.aggregateName}`
1303
1325
  );
1304
1326
  }
@@ -1306,13 +1328,13 @@ class tt {
1306
1328
  this.context.logger.info(
1307
1329
  `Creating command endpoint paths enum: ${this.commandEndpointPathsName}`
1308
1330
  );
1309
- const n = e.addEnum({
1331
+ const o = e.addEnum({
1310
1332
  name: this.commandEndpointPathsName
1311
1333
  });
1312
1334
  t.commands.forEach((r) => {
1313
1335
  this.context.logger.info(
1314
1336
  `Adding command endpoint: ${r.name.toUpperCase()} = '${r.path}'`
1315
- ), n.addMember({
1337
+ ), o.addMember({
1316
1338
  name: r.name.toUpperCase(),
1317
1339
  initializer: `'${r.path}'`
1318
1340
  });
@@ -1323,30 +1345,30 @@ class tt {
1323
1345
  getEndpointPath(e) {
1324
1346
  return `${this.commandEndpointPathsName}.${e.name.toUpperCase()}`;
1325
1347
  }
1326
- processCommandClient(e, t, n = !1) {
1348
+ processCommandClient(e, t, o = !1) {
1327
1349
  let r = "CommandClient", i = [], s = "Promise<CommandResult>";
1328
- n && (r = "Stream" + r, i = [
1350
+ o && (r = "Stream" + r, i = [
1329
1351
  "''",
1330
- b
1352
+ M
1331
1353
  ], s = "Promise<CommandResultEventStream>");
1332
- const a = Ke(
1354
+ const a = et(
1333
1355
  t.aggregate,
1334
1356
  r
1335
- ), c = se(a, e, i);
1336
- ae(c, this.defaultCommandClientOptionsName), t.commands.forEach((u) => {
1337
- this.processCommandMethod(t, e, c, u, s);
1357
+ ), c = ae(a, e, i);
1358
+ ce(c, this.defaultCommandClientOptionsName), t.commands.forEach((g) => {
1359
+ this.processCommandMethod(t, e, c, g, s);
1338
1360
  });
1339
1361
  }
1340
- resolveParameters(e, t, n) {
1341
- const r = d(n.schema.key);
1362
+ resolveParameters(e, t, o) {
1363
+ const r = m(o.schema.key);
1342
1364
  this.context.logger.info(
1343
1365
  `Adding import for command model: ${r.name} from path: ${r.path}`
1344
1366
  ), f(t, this.context.outputDir, r);
1345
- const i = n.pathParameters.filter((s) => !this.context.isIgnoreCommandClientPathParameters(
1367
+ const i = o.pathParameters.filter((s) => !this.context.isIgnoreCommandClientPathParameters(
1346
1368
  e.name,
1347
1369
  s.name
1348
1370
  )).map((s) => {
1349
- const a = ee(s);
1371
+ const a = Z(s);
1350
1372
  return this.context.logger.info(
1351
1373
  `Adding path parameter: ${s.name} (type: ${a})`
1352
1374
  ), {
@@ -1365,7 +1387,7 @@ class tt {
1365
1387
  `Adding command request parameter: commandRequest (type: CommandRequest<${r.name}>)`
1366
1388
  ), i.push({
1367
1389
  name: "commandRequest",
1368
- hasQuestionToken: Te(n.schema.schema),
1390
+ hasQuestionToken: Se(o.schema.schema),
1369
1391
  type: `CommandRequest<${r.name}>`,
1370
1392
  decorators: [
1371
1393
  {
@@ -1387,13 +1409,13 @@ class tt {
1387
1409
  ]
1388
1410
  }), i;
1389
1411
  }
1390
- processCommandMethod(e, t, n, r, i) {
1412
+ processCommandMethod(e, t, o, r, i) {
1391
1413
  this.context.logger.info(
1392
1414
  `Generating command method: ${h(r.name)} for command: ${r.name}`
1393
1415
  ), this.context.logger.info(
1394
1416
  `Command method details: HTTP ${r.method}, path: ${r.path}, return type: ${i}`
1395
1417
  );
1396
- const s = this.resolveParameters(e.aggregate.tag, t, r), a = n.addMethod({
1418
+ const s = this.resolveParameters(e.aggregate.tag, t, r), a = o.addMethod({
1397
1419
  name: h(r.name),
1398
1420
  decorators: [
1399
1421
  {
@@ -1409,7 +1431,7 @@ class tt {
1409
1431
  });
1410
1432
  this.context.logger.info(
1411
1433
  `Adding JSDoc documentation for method: ${h(r.name)}`
1412
- ), w(
1434
+ ), v(
1413
1435
  a,
1414
1436
  [
1415
1437
  r.summary,
@@ -1422,7 +1444,7 @@ class tt {
1422
1444
  );
1423
1445
  }
1424
1446
  }
1425
- class nt {
1447
+ class it {
1426
1448
  /**
1427
1449
  * Creates a new QueryClientGenerator instance.
1428
1450
  * @param context - The generation context containing OpenAPI spec and project details
@@ -1435,15 +1457,15 @@ class nt {
1435
1457
  */
1436
1458
  generate() {
1437
1459
  const e = Array.from(this.context.contextAggregates.values()).reduce(
1438
- (n, r) => n + r.size,
1460
+ (o, r) => o + r.size,
1439
1461
  0
1440
1462
  );
1441
1463
  this.context.logger.info("--- Generating Query Clients ---"), this.context.logger.progress(
1442
1464
  `Generating query clients for ${e} aggregates`
1443
1465
  );
1444
1466
  let t = 0;
1445
- for (const [, n] of this.context.contextAggregates)
1446
- n.forEach((r) => {
1467
+ for (const [, o] of this.context.contextAggregates)
1468
+ o.forEach((r) => {
1447
1469
  t++, this.context.logger.progressWithCount(
1448
1470
  t,
1449
1471
  e,
@@ -1459,7 +1481,7 @@ class nt {
1459
1481
  * @returns The source file for the client
1460
1482
  */
1461
1483
  createClientFilePath(e, t) {
1462
- return ge(
1484
+ return ue(
1463
1485
  this.context.project,
1464
1486
  this.context.outputDir,
1465
1487
  e,
@@ -1478,28 +1500,28 @@ class nt {
1478
1500
  this.context.logger.info(
1479
1501
  `Processing query client for aggregate: ${e.aggregate.aggregateName} in context: ${e.aggregate.contextAlias}`
1480
1502
  ), this.context.logger.info(
1481
- `Adding imports from ${P}: QueryClientFactory, QueryClientOptions, ResourceAttributionPathSpec`
1503
+ `Adding imports from ${x}: QueryClientFactory, QueryClientOptions, ResourceAttributionPathSpec`
1482
1504
  ), t.addImportDeclaration({
1483
- moduleSpecifier: P,
1505
+ moduleSpecifier: x,
1484
1506
  namedImports: [
1485
1507
  "QueryClientFactory",
1486
1508
  "QueryClientOptions",
1487
1509
  "ResourceAttributionPathSpec"
1488
1510
  ]
1489
1511
  });
1490
- const n = "DEFAULT_QUERY_CLIENT_OPTIONS";
1512
+ const o = "DEFAULT_QUERY_CLIENT_OPTIONS";
1491
1513
  this.context.logger.info(
1492
- `Creating default query client options: ${n}`
1514
+ `Creating default query client options: ${o}`
1493
1515
  ), t.addVariableStatement({
1494
- declarationKind: O.Const,
1516
+ declarationKind: w.Const,
1495
1517
  declarations: [
1496
1518
  {
1497
- name: n,
1519
+ name: o,
1498
1520
  type: "QueryClientOptions",
1499
1521
  initializer: `{
1500
1522
  contextAlias: '${e.aggregate.contextAlias}',
1501
1523
  aggregateName: '${e.aggregate.aggregateName}',
1502
- resourceAttribution: ${Ye(e)},
1524
+ resourceAttribution: ${Ze(e)},
1503
1525
  }`
1504
1526
  }
1505
1527
  ],
@@ -1509,30 +1531,30 @@ class nt {
1509
1531
  this.context.logger.info(
1510
1532
  `Processing ${e.events.size} domain events for aggregate: ${e.aggregate.aggregateName}`
1511
1533
  );
1512
- for (const l of e.events.values()) {
1513
- const p = d(l.schema.key);
1534
+ for (const p of e.events.values()) {
1535
+ const l = m(p.schema.key);
1514
1536
  this.context.logger.info(
1515
- `Adding import for event model: ${p.name} from path: ${p.path}`
1516
- ), f(t, this.context.outputDir, p), r.push(p);
1537
+ `Adding import for event model: ${l.name} from path: ${l.path}`
1538
+ ), f(t, this.context.outputDir, l), r.push(l);
1517
1539
  }
1518
- const i = "DOMAIN_EVENT_TYPES", s = r.map((l) => l.name).join(" | ");
1540
+ const i = "DOMAIN_EVENT_TYPES", s = r.map((p) => p.name).join(" | ");
1519
1541
  this.context.logger.info(
1520
1542
  `Creating domain event types union: ${i} = ${s}`
1521
1543
  ), t.addTypeAlias({
1522
1544
  name: i,
1523
1545
  type: s
1524
1546
  });
1525
- const a = `${h(e.aggregate.aggregateName)}QueryClientFactory`, c = d(e.state.key), u = d(e.fields.key);
1547
+ const a = `${h(e.aggregate.aggregateName)}QueryClientFactory`, c = m(e.state.key), g = m(e.fields.key);
1526
1548
  this.context.logger.info(
1527
1549
  `Adding import for state model: ${c.name} from path: ${c.path}`
1528
1550
  ), f(t, this.context.outputDir, c), this.context.logger.info(
1529
- `Adding import for fields model: ${u.name} from path: ${u.path}`
1530
- ), f(t, this.context.outputDir, u), this.context.logger.info(`Creating query client factory: ${a}`), t.addVariableStatement({
1531
- declarationKind: O.Const,
1551
+ `Adding import for fields model: ${g.name} from path: ${g.path}`
1552
+ ), f(t, this.context.outputDir, g), this.context.logger.info(`Creating query client factory: ${a}`), t.addVariableStatement({
1553
+ declarationKind: w.Const,
1532
1554
  declarations: [
1533
1555
  {
1534
1556
  name: a,
1535
- initializer: `new QueryClientFactory<${c.name}, ${u.name} | string, ${i}>(${n})`
1557
+ initializer: `new QueryClientFactory<${c.name}, ${g.name} | string, ${i}>(${o})`
1536
1558
  }
1537
1559
  ],
1538
1560
  isExported: !0
@@ -1541,13 +1563,13 @@ class nt {
1541
1563
  );
1542
1564
  }
1543
1565
  }
1544
- class ot {
1566
+ class st {
1545
1567
  /**
1546
1568
  * Creates a new ClientGenerator instance.
1547
1569
  * @param context - The generation context containing OpenAPI spec and project details
1548
1570
  */
1549
1571
  constructor(e) {
1550
- this.context = e, this.queryClientGenerator = new nt(e), this.commandClientGenerator = new tt(e), this.apiClientGenerator = new et(e);
1572
+ this.context = e, this.queryClientGenerator = new it(e), this.commandClientGenerator = new rt(e), this.apiClientGenerator = new ot(e);
1551
1573
  }
1552
1574
  queryClientGenerator;
1553
1575
  commandClientGenerator;
@@ -1576,17 +1598,17 @@ class ot {
1576
1598
  processBoundedContext(e) {
1577
1599
  const t = `${e}/boundedContext.ts`;
1578
1600
  this.context.logger.info(`Creating bounded context file: ${t}`);
1579
- const n = this.context.getOrCreateSourceFile(t);
1601
+ const o = this.context.getOrCreateSourceFile(t);
1580
1602
  this.context.logger.info(
1581
1603
  `Adding bounded context alias constant: BOUNDED_CONTEXT_ALIAS = '${e}'`
1582
- ), n.addStatements(
1604
+ ), o.addStatements(
1583
1605
  `export const BOUNDED_CONTEXT_ALIAS = '${e}';`
1584
1606
  ), this.context.logger.success(
1585
1607
  `Bounded context file created successfully: ${t}`
1586
1608
  );
1587
1609
  }
1588
1610
  }
1589
- class rt {
1611
+ class at {
1590
1612
  /** The ts-morph project instance used for code generation */
1591
1613
  project;
1592
1614
  /** The OpenAPI specification object */
@@ -1604,7 +1626,7 @@ class rt {
1604
1626
  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"];
1605
1627
  }
1606
1628
  getOrCreateSourceFile(e) {
1607
- return re(this.project, this.outputDir, e);
1629
+ return oe(this.project, this.outputDir, e);
1608
1630
  }
1609
1631
  isIgnoreApiClientPathParameters(e, t) {
1610
1632
  return (this.config.apiClients?.[e]?.ignorePathParameters ?? this.defaultIgnorePathParameters).includes(t);
@@ -1613,14 +1635,14 @@ class rt {
1613
1635
  return this.defaultIgnorePathParameters.includes(t);
1614
1636
  }
1615
1637
  }
1616
- const it = "./fetcher-generator.config.json";
1617
- class pt {
1638
+ const ct = "./fetcher-generator.config.json";
1639
+ class ft {
1618
1640
  /**
1619
1641
  * Creates a new CodeGenerator instance.
1620
1642
  * @param options - Configuration options for code generation
1621
1643
  */
1622
1644
  constructor(e) {
1623
- this.options = e, this.project = new pe(e), this.options.logger.info("Project instance created with tsConfigFilePath: ", this.options.tsConfigFilePath);
1645
+ this.options = e, this.project = new de(e), this.options.logger.info("Project instance created with tsConfigFilePath: ", this.options.tsConfigFilePath);
1624
1646
  }
1625
1647
  project;
1626
1648
  /**
@@ -1632,28 +1654,28 @@ class pt {
1632
1654
  this.options.logger.info(
1633
1655
  "Starting code generation from OpenAPI specification"
1634
1656
  ), 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");
1635
- const e = await Re(this.options.inputPath);
1657
+ const e = await De(this.options.inputPath);
1636
1658
  this.options.logger.info("OpenAPI specification parsed successfully"), this.options.logger.info("Resolving bounded context aggregates");
1637
- const n = new ke(e).resolve();
1659
+ const o = new Qe(e).resolve();
1638
1660
  this.options.logger.info(
1639
- `Resolved ${n.size} bounded context aggregates`
1661
+ `Resolved ${o.size} bounded context aggregates`
1640
1662
  );
1641
- const r = this.options.configPath ?? it;
1663
+ const r = this.options.configPath ?? ct;
1642
1664
  let i = {};
1643
1665
  try {
1644
- this.options.logger.info("Parsing configuration file:", r), i = await Oe(r);
1645
- } catch (u) {
1646
- this.options.logger.info("Configuration file parsing failed ", u);
1666
+ this.options.logger.info("Parsing configuration file:", r), i = await Ne(r);
1667
+ } catch (g) {
1668
+ this.options.logger.info("Configuration file parsing failed ", g);
1647
1669
  }
1648
- const s = new rt({
1670
+ const s = new at({
1649
1671
  openAPI: e,
1650
1672
  project: this.project,
1651
1673
  outputDir: this.options.outputDir,
1652
- contextAggregates: n,
1674
+ contextAggregates: o,
1653
1675
  logger: this.options.logger,
1654
1676
  config: i
1655
1677
  });
1656
- this.options.logger.info("Generating models"), new Ue(s).generate(), this.options.logger.info("Models generated successfully"), this.options.logger.info("Generating clients"), new ot(s).generate(), this.options.logger.info("Clients generated successfully"), this.options.logger.info("Generating index files"), this.generateIndex(), this.options.logger.info("Index files generated successfully"), this.options.logger.info("Optimizing source files"), this.optimizeSourceFiles(), this.options.logger.info("Source files optimized successfully"), this.options.logger.info("Saving project to disk"), await this.project.save(), this.options.logger.info("Code generation completed successfully");
1678
+ this.options.logger.info("Generating models"), new Ve(s).generate(), this.options.logger.info("Models generated successfully"), this.options.logger.info("Generating clients"), new st(s).generate(), this.options.logger.info("Clients generated successfully"), this.options.logger.info("Generating index files"), this.generateIndex(), this.options.logger.info("Index files generated successfully"), this.options.logger.info("Optimizing source files"), this.optimizeSourceFiles(), this.options.logger.info("Source files optimized successfully"), this.options.logger.info("Saving project to disk"), await this.project.save(), this.options.logger.info("Code generation completed successfully");
1657
1679
  }
1658
1680
  /**
1659
1681
  * Generates index.ts files for all subdirectories in the output directory.
@@ -1676,8 +1698,8 @@ class pt {
1676
1698
  processDirectory(e) {
1677
1699
  const t = e.getDirectories();
1678
1700
  this.options.logger.info(`Processing ${t.length} subdirectories`);
1679
- for (const n of t)
1680
- this.options.logger.info(`Processing subdirectory: ${n.getPath()}`), this.generateIndexForDirectory(n), this.processDirectory(n);
1701
+ for (const o of t)
1702
+ this.options.logger.info(`Processing subdirectory: ${o.getPath()}`), this.generateIndexForDirectory(o), this.processDirectory(o);
1681
1703
  }
1682
1704
  /**
1683
1705
  * Generates an index.ts file for a specific directory.
@@ -1686,12 +1708,12 @@ class pt {
1686
1708
  generateIndexForDirectory(e) {
1687
1709
  const t = e.getPath();
1688
1710
  this.options.logger.info(`Generating index for directory: ${t}`);
1689
- const n = e.getSourceFiles().filter(
1711
+ const o = e.getSourceFiles().filter(
1690
1712
  (a) => a.getBaseName().endsWith(".ts") && a.getBaseName() !== "index.ts"
1691
1713
  ), r = e.getDirectories();
1692
1714
  if (this.options.logger.info(
1693
- `Found ${n.length} TypeScript files and ${r.length} subdirectories in ${t}`
1694
- ), n.length === 0 && r.length === 0) {
1715
+ `Found ${o.length} TypeScript files and ${r.length} subdirectories in ${t}`
1716
+ ), o.length === 0 && r.length === 0) {
1695
1717
  this.options.logger.info(
1696
1718
  `No files or subdirectories to export in ${t}, skipping index generation`
1697
1719
  );
@@ -1701,7 +1723,7 @@ class pt {
1701
1723
  this.options.logger.info(`Creating/updating index file: ${i}`);
1702
1724
  const s = this.project.getSourceFile(i) || this.project.createSourceFile(i, "", { overwrite: !0 });
1703
1725
  s.removeText();
1704
- for (const a of n) {
1726
+ for (const a of o) {
1705
1727
  const c = `./${a.getBaseNameWithoutExtension()}`;
1706
1728
  this.options.logger.info(`Adding export for file: ${c}`), s.addExportDeclaration({
1707
1729
  moduleSpecifier: c,
@@ -1720,20 +1742,20 @@ class pt {
1720
1742
  });
1721
1743
  }
1722
1744
  this.options.logger.info(
1723
- `Index file generated for ${t} with ${n.length + r.length} exports`
1745
+ `Index file generated for ${t} with ${o.length + r.length} exports`
1724
1746
  );
1725
1747
  }
1726
1748
  optimizeSourceFiles() {
1727
1749
  const e = this.project.getSourceFiles();
1728
- this.options.logger.info(`Optimizing ${e.length} source files`), e.forEach((t, n) => {
1750
+ this.options.logger.info(`Optimizing ${e.length} source files`), e.forEach((t, o) => {
1729
1751
  this.options.logger.info(
1730
- `Optimizing file ${n + 1}/${e.length}`
1752
+ `Optimizing file ${o + 1}/${e.length}`
1731
1753
  ), t.formatText(), t.organizeImports(), t.fixMissingImports();
1732
1754
  }), this.options.logger.info("All source files optimized");
1733
1755
  }
1734
1756
  }
1735
1757
  export {
1736
- pt as CodeGenerator,
1737
- it as DEFAULT_CONFIG_PATH
1758
+ ft as CodeGenerator,
1759
+ ct as DEFAULT_CONFIG_PATH
1738
1760
  };
1739
1761
  //# sourceMappingURL=index.js.map