@ahoo-wang/fetcher-generator 2.2.9 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import { VariableDeclarationKind as E, Scope as k } from "ts-morph";
2
- import { parse as Q } from "yaml";
1
+ import { VariableDeclarationKind as E, Scope as L } from "ts-morph";
2
+ import { parse as U } from "yaml";
3
3
  import * as v from "fs";
4
- import { readFile as L } from "fs";
5
- import { ContentTypeValues as S, combineURLs as q } from "@ahoo-wang/fetcher";
6
- import * as K from "path";
7
- import { join as U, relative as J } from "path";
4
+ import { readFile as K } from "fs";
5
+ import { ContentTypeValues as S, combineURLs as G } from "@ahoo-wang/fetcher";
6
+ import * as J from "path";
7
+ import { join as V, relative as H } from "path";
8
8
  import { ResourceAttributionPathSpec as b } from "@ahoo-wang/fetcher-wow";
9
9
  function f(n) {
10
10
  return n.$ref.split("/").pop();
@@ -13,11 +13,11 @@ function I(n, e) {
13
13
  const t = f(n);
14
14
  return e.schemas?.[t];
15
15
  }
16
- function V(n, e) {
16
+ function Y(n, e) {
17
17
  const t = f(n);
18
18
  return e.requestBodies?.[t];
19
19
  }
20
- function H(n, e) {
20
+ function X(n, e) {
21
21
  const t = f(n);
22
22
  return e.parameters?.[t];
23
23
  }
@@ -27,46 +27,62 @@ function C(n, e) {
27
27
  schema: I(n, e)
28
28
  };
29
29
  }
30
- const R = /[-_\s.]+|(?=[A-Z])/;
31
- function w(n) {
32
- if (n === "" || n.length === 0)
33
- return "";
34
- let e;
35
- return Array.isArray(n) ? e = n.flatMap((t) => t.split(R)) : e = n.split(R), e.filter((t) => t.length > 0).map((t) => {
30
+ const R = /[-_\s.]+/;
31
+ function F(n) {
32
+ return Array.isArray(n) ? n.flatMap((e) => j(e.split(R))) : j(n.split(R));
33
+ }
34
+ function j(n) {
35
+ return n.flatMap((e) => {
36
+ if (e.length === 0)
37
+ return [];
38
+ const t = [];
39
+ let o = "";
40
+ for (let r = 0; r < e.length; r++) {
41
+ const s = e[r], i = /[A-Z]/.test(s), c = r > 0 && /[a-z]/.test(e[r - 1]);
42
+ i && c && o ? (t.push(o), o = s) : o += s;
43
+ }
44
+ return o && t.push(o), t;
45
+ });
46
+ }
47
+ function $(n) {
48
+ return n === "" || n.length === 0 ? "" : F(n).filter((t) => t.length > 0).map((t) => {
36
49
  if (t.length === 0) return "";
37
50
  const o = t.charAt(0), r = t.slice(1);
38
51
  return (/[a-zA-Z]/.test(o) ? o.toUpperCase() : o) + r.toLowerCase();
39
52
  }).join("");
40
53
  }
41
54
  function h(n) {
42
- const e = w(n);
55
+ const e = $(n);
43
56
  return e.charAt(0).toLowerCase() + e.slice(1);
44
57
  }
45
- function Y(n) {
46
- return n.startsWith("http://") || n.startsWith("https://") ? X(n) : Z(n);
58
+ function Z(n) {
59
+ return n === "" || Array.isArray(n) && n.length === 0 ? "" : F(n).filter((t) => t.length > 0).map((t) => t.toUpperCase()).join("_");
60
+ }
61
+ function ee(n) {
62
+ return n.startsWith("http://") || n.startsWith("https://") ? te(n) : oe(n);
47
63
  }
48
- async function X(n) {
64
+ async function te(n) {
49
65
  return await (await fetch(n)).text();
50
66
  }
51
- function Z(n) {
67
+ function oe(n) {
52
68
  return new Promise((e, t) => {
53
- L(n, "utf-8", (o, r) => {
69
+ K(n, "utf-8", (o, r) => {
54
70
  o ? t(o) : e(r);
55
71
  });
56
72
  });
57
73
  }
58
- async function ee(n) {
59
- const e = await Y(n);
60
- switch (te(e)) {
74
+ async function ne(n) {
75
+ const e = await ee(n);
76
+ switch (re(e)) {
61
77
  case "json":
62
78
  return JSON.parse(e);
63
79
  case "yaml":
64
- return Q(e);
80
+ return U(e);
65
81
  default:
66
82
  throw new Error(`Unsupported file format: ${n}`);
67
83
  }
68
84
  }
69
- function te(n) {
85
+ function re(n) {
70
86
  const e = n.trimStart();
71
87
  if (e.startsWith("{") || e.startsWith("["))
72
88
  return "json";
@@ -83,10 +99,10 @@ function te(n) {
83
99
  function g(n) {
84
100
  return !!(n && typeof n == "object" && "$ref" in n);
85
101
  }
86
- function oe(n) {
102
+ function se(n) {
87
103
  return !n || g(n) || !n.content ? void 0 : n.content[S.APPLICATION_JSON]?.schema;
88
104
  }
89
- function ne(n) {
105
+ function ie(n) {
90
106
  return [
91
107
  { method: "get", operation: n.get },
92
108
  { method: "put", operation: n.put },
@@ -98,48 +114,48 @@ function ne(n) {
98
114
  { method: "trace", operation: n.trace }
99
115
  ].filter(({ operation: e }) => e !== void 0);
100
116
  }
101
- function G(n) {
117
+ function W(n) {
102
118
  return n.responses[200];
103
119
  }
104
- function j(n) {
105
- const e = G(n);
106
- return oe(e);
120
+ function M(n) {
121
+ const e = W(n);
122
+ return se(e);
107
123
  }
108
- const re = [
124
+ const ae = [
109
125
  "string",
110
126
  "number",
111
127
  "integer",
112
128
  "boolean",
113
129
  "null"
114
130
  ];
115
- function se(n) {
116
- return Array.isArray(n) ? !0 : re.includes(n);
131
+ function ce(n) {
132
+ return Array.isArray(n) ? !0 : ae.includes(n);
117
133
  }
118
- function ie(n) {
134
+ function ge(n) {
119
135
  return n.type === "array";
120
136
  }
121
- function ae(n) {
137
+ function le(n) {
122
138
  return Array.isArray(n.enum) && n.enum.length > 0;
123
139
  }
124
- function F(n) {
140
+ function _(n) {
125
141
  return Array.isArray(n.anyOf) && n.anyOf.length > 0;
126
142
  }
127
- function W(n) {
143
+ function B(n) {
128
144
  return Array.isArray(n.oneOf) && n.oneOf.length > 0;
129
145
  }
130
- function ce(n) {
131
- return F(n) || W(n);
146
+ function pe(n) {
147
+ return _(n) || B(n);
132
148
  }
133
- function ge(n) {
149
+ function me(n) {
134
150
  return Array.isArray(n.allOf) && n.allOf.length > 0;
135
151
  }
136
- function M(n) {
137
- return F(n) || W(n) || ge(n);
152
+ function q(n) {
153
+ return _(n) || B(n) || me(n);
138
154
  }
139
- function le(n) {
155
+ function ue(n) {
140
156
  return n.includes("|") || n.includes("&") ? `(${n})[]` : `${n}[]`;
141
157
  }
142
- function pe(n) {
158
+ function de(n) {
143
159
  return n.type !== "object" ? !1 : n.properties ? Object.keys(n.properties).length === 0 : !0;
144
160
  }
145
161
  function N(n) {
@@ -159,17 +175,17 @@ function N(n) {
159
175
  return "any";
160
176
  }
161
177
  }
162
- const _ = "types.ts", me = "@";
163
- function ue(n) {
164
- return q(n.path, _);
178
+ const z = "types.ts", fe = "@";
179
+ function he(n) {
180
+ return G(n.path, z);
165
181
  }
166
182
  function T(n, e, t) {
167
- const o = q(e, t), r = n.getSourceFile(o);
183
+ const o = G(e, t), r = n.getSourceFile(o);
168
184
  return r || n.createSourceFile(o, "", {
169
185
  overwrite: !0
170
186
  });
171
187
  }
172
- function $(n, e, t) {
188
+ function w(n, e, t) {
173
189
  let o = n.getImportDeclaration(
174
190
  (r) => r.getModuleSpecifierValue() === e
175
191
  );
@@ -177,23 +193,23 @@ function $(n, e, t) {
177
193
  moduleSpecifier: e
178
194
  })), t.forEach((r) => {
179
195
  o.getNamedImports().some(
180
- (a) => a.getName() === r
196
+ (i) => i.getName() === r
181
197
  ) || o.addNamedImport(r);
182
198
  });
183
199
  }
184
200
  function y(n, e, t) {
185
- if (t.path.startsWith(me)) {
186
- $(n, t.path, [t.name]);
201
+ if (t.path.startsWith(fe)) {
202
+ w(n, t.path, [t.name]);
187
203
  return;
188
204
  }
189
- const o = n.getDirectoryPath(), r = U(e, t.path, _);
190
- let s = J(o, r);
191
- s = s.replace(/\.ts$/, ""), s.startsWith(".") || (s = "./" + s), $(n, s, [t.name]);
205
+ const o = n.getDirectoryPath(), r = V(e, t.path, z);
206
+ let s = H(o, r);
207
+ s = s.replace(/\.ts$/, ""), s.startsWith(".") || (s = "./" + s), w(n, s, [t.name]);
192
208
  }
193
209
  function O(n, e, t, o) {
194
210
  n.path !== o.path && y(e, t, o);
195
211
  }
196
- function de(n, e) {
212
+ function ye(n, e) {
197
213
  const t = [n, e].filter(
198
214
  (o) => o !== void 0 && o.length > 0
199
215
  );
@@ -201,25 +217,25 @@ function de(n, e) {
201
217
  `) : void 0;
202
218
  }
203
219
  function P(n, e, t) {
204
- const o = de(e, t);
220
+ const o = ye(e, t);
205
221
  o && n.addJsDoc({
206
222
  description: o
207
223
  });
208
224
  }
209
- function fe(n) {
225
+ function Ae(n) {
210
226
  const e = n.split(".");
211
227
  return e.length != 2 || e[0].length === 0 || e[1].length === 0 ? null : e;
212
228
  }
213
- function he(n) {
214
- const e = fe(n.name);
229
+ function Ce(n) {
230
+ const e = Ae(n.name);
215
231
  return e ? {
216
232
  tag: n,
217
233
  contextAlias: e[0],
218
234
  aggregateName: e[1]
219
235
  } : null;
220
236
  }
221
- function ye(n) {
222
- const e = n?.map((o) => he(o)).filter((o) => o !== null);
237
+ function Pe(n) {
238
+ const e = n?.map((o) => Ce(o)).filter((o) => o !== null);
223
239
  if (!e)
224
240
  return /* @__PURE__ */ new Map();
225
241
  const t = /* @__PURE__ */ new Map();
@@ -231,20 +247,20 @@ function ye(n) {
231
247
  });
232
248
  }), t;
233
249
  }
234
- function Ae(n) {
250
+ function we(n) {
235
251
  if (!n)
236
252
  return null;
237
253
  const e = n.split(".");
238
254
  return e.length != 3 ? null : e[2];
239
255
  }
240
- const Ce = "#/components/responses/wow.CommandOk", Pe = "#/components/parameters/wow.id";
241
- class $e {
256
+ const $e = "#/components/responses/wow.CommandOk", xe = "#/components/parameters/wow.id";
257
+ class Oe {
242
258
  /**
243
259
  * Creates a new AggregateResolver instance.
244
260
  * @param openAPI - The OpenAPI specification to resolve aggregates from
245
261
  */
246
262
  constructor(e) {
247
- this.openAPI = e, this.aggregates = ye(e.tags), this.build();
263
+ this.openAPI = e, this.aggregates = Pe(e.tags), this.build();
248
264
  }
249
265
  aggregates;
250
266
  /**
@@ -253,7 +269,7 @@ class $e {
253
269
  */
254
270
  build() {
255
271
  for (const [e, t] of Object.entries(this.openAPI.paths)) {
256
- const o = ne(t);
272
+ const o = ie(t);
257
273
  for (const r of o)
258
274
  this.commands(e, r), this.state(r.operation), this.events(r.operation), this.fields(r.operation);
259
275
  }
@@ -282,32 +298,32 @@ class $e {
282
298
  const o = t.operation;
283
299
  if (o.operationId === "wow.command.send")
284
300
  return;
285
- const r = Ae(o.operationId);
301
+ const r = we(o.operationId);
286
302
  if (!r)
287
303
  return;
288
- const s = G(o);
289
- if (!s || !g(s) || s.$ref !== Ce || !o.requestBody)
304
+ const s = W(o);
305
+ if (!s || !g(s) || s.$ref !== $e || !o.requestBody)
290
306
  return;
291
- const a = o.parameters ?? [], c = a.filter((u) => g(u) && u.$ref === Pe).at(0), i = a.filter(
307
+ const i = o.parameters ?? [], c = i.filter((u) => g(u) && u.$ref === xe).at(0), a = i.filter(
292
308
  (u) => !g(u) && u.in === "path"
293
309
  );
294
310
  if (c) {
295
- const u = H(
311
+ const u = X(
296
312
  c,
297
313
  this.openAPI.components
298
314
  );
299
- i.push(u);
315
+ a.push(u);
300
316
  }
301
317
  const m = o.requestBody.content[S.APPLICATION_JSON].schema, l = C(
302
318
  m,
303
319
  this.openAPI.components
304
320
  );
305
321
  l.schema.title = l.schema.title || o.summary, l.schema.description = l.schema.description || o.description;
306
- const z = {
322
+ const Q = {
307
323
  name: r,
308
324
  method: t.method,
309
325
  path: e,
310
- pathParameters: i,
326
+ pathParameters: a,
311
327
  summary: o.summary,
312
328
  description: o.description,
313
329
  schema: l,
@@ -315,7 +331,7 @@ class $e {
315
331
  };
316
332
  o.tags?.forEach((u) => {
317
333
  const D = this.aggregates.get(u);
318
- D && D.commands.set(r, z);
334
+ D && D.commands.set(r, Q);
319
335
  });
320
336
  }
321
337
  /**
@@ -325,7 +341,7 @@ class $e {
325
341
  state(e) {
326
342
  if (!e.operationId?.endsWith(".snapshot_state.single"))
327
343
  return;
328
- const t = j(e);
344
+ const t = M(e);
329
345
  if (!g(t))
330
346
  return;
331
347
  const o = C(
@@ -344,7 +360,7 @@ class $e {
344
360
  events(e) {
345
361
  if (!this.openAPI.components || !e.operationId?.endsWith(".event.list_query"))
346
362
  return;
347
- const t = j(e);
363
+ const t = M(e);
348
364
  if (g(t))
349
365
  return;
350
366
  const o = t?.items;
@@ -353,21 +369,21 @@ class $e {
353
369
  const s = I(
354
370
  o,
355
371
  this.openAPI.components
356
- ).properties.body.items.anyOf.map((a) => {
357
- const c = a.title, i = a.properties.name.const, p = a.properties.body, m = C(
372
+ ).properties.body.items.anyOf.map((i) => {
373
+ const c = i.title, a = i.properties.name.const, p = i.properties.body, m = C(
358
374
  p,
359
375
  this.openAPI.components
360
376
  );
361
- return m.schema.title = m.schema.title || a.title, {
377
+ return m.schema.title = m.schema.title || i.title, {
362
378
  title: c,
363
- name: i,
379
+ name: a,
364
380
  schema: m
365
381
  };
366
382
  });
367
- e.tags?.forEach((a) => {
368
- const c = this.aggregates.get(a);
369
- c && s.forEach((i) => {
370
- c.events.set(i.name, i);
383
+ e.tags?.forEach((i) => {
384
+ const c = this.aggregates.get(i);
385
+ c && s.forEach((a) => {
386
+ c.events.set(a.name, a);
371
387
  });
372
388
  });
373
389
  }
@@ -378,20 +394,20 @@ class $e {
378
394
  fields(e) {
379
395
  if (!this.openAPI.components || !e.operationId?.endsWith(".snapshot.count"))
380
396
  return;
381
- const o = V(
397
+ const o = Y(
382
398
  e.requestBody,
383
399
  this.openAPI.components
384
400
  ).content[S.APPLICATION_JSON].schema, s = I(
385
401
  o,
386
402
  this.openAPI.components
387
- ).properties?.field, a = C(s, this.openAPI.components);
403
+ ).properties?.field, i = C(s, this.openAPI.components);
388
404
  e.tags?.forEach((c) => {
389
- const i = this.aggregates.get(c);
390
- i && (i.fields = a);
405
+ const a = this.aggregates.get(c);
406
+ a && (a.fields = i);
391
407
  });
392
408
  }
393
409
  }
394
- const A = "@ahoo-wang/fetcher-wow", we = {
410
+ const A = "@ahoo-wang/fetcher-wow", Ee = {
395
411
  "wow.command.CommandResult": "CommandResult",
396
412
  "wow.MessageHeaderSqlType": "MessageHeaderSqlType",
397
413
  "wow.api.BindingError": "BindingError",
@@ -423,20 +439,20 @@ const A = "@ahoo-wang/fetcher-wow", we = {
423
439
  function d(n) {
424
440
  if (!n)
425
441
  return { name: "", path: "/" };
426
- const e = we[n];
442
+ const e = Ee[n];
427
443
  if (e)
428
444
  return { name: e, path: A };
429
445
  const t = n.split(".");
430
446
  let o = -1;
431
- for (let i = 0; i < t.length; i++)
432
- if (t[i] && /^[A-Z]/.test(t[i])) {
433
- o = i;
447
+ for (let a = 0; a < t.length; a++)
448
+ if (t[a] && /^[A-Z]/.test(t[a])) {
449
+ o = a;
434
450
  break;
435
451
  }
436
452
  if (o === -1)
437
453
  return { name: n, path: "/" };
438
- const r = t.slice(0, o), s = r.length > 0 ? `/${r.join("/")}` : "/", a = t.slice(o);
439
- return { name: w(a), path: s };
454
+ const r = t.slice(0, o), s = r.length > 0 ? `/${r.join("/")}` : "/", i = t.slice(o);
455
+ return { name: $(i), path: s };
440
456
  }
441
457
  class x {
442
458
  /** The ts-morph project instance used for code generation */
@@ -457,12 +473,12 @@ class x {
457
473
  this.project = e.project, this.openAPI = e.openAPI, this.outputDir = e.outputDir, this.contextAggregates = e.contextAggregates, this.logger = e.logger;
458
474
  }
459
475
  }
460
- class xe extends x {
476
+ class Se extends x {
461
477
  constructor(e) {
462
478
  super(e);
463
479
  }
464
480
  getOrCreateSourceFile(e) {
465
- const t = ue(e);
481
+ const t = he(e);
466
482
  return T(this.project, this.outputDir, t);
467
483
  }
468
484
  /**
@@ -480,9 +496,7 @@ class xe extends x {
480
496
  return;
481
497
  }
482
498
  const t = this.filterSchemas(e);
483
- this.logger.progress(
484
- `Generating models for ${t.length} schemas`
485
- ), t.forEach((o, r) => {
499
+ this.logger.progress(`Generating models for ${t.length} schemas`), t.forEach((o, r) => {
486
500
  this.logger.progressWithCount(
487
501
  r + 1,
488
502
  t.length,
@@ -492,12 +506,10 @@ class xe extends x {
492
506
  }), this.logger.success("Model generation completed");
493
507
  }
494
508
  filterSchemas(e) {
495
- return Object.entries(e).map(
496
- ([t, o]) => ({
497
- key: t,
498
- schema: o
499
- })
500
- ).filter((t) => !this.isWowSchema(t.key));
509
+ return Object.entries(e).map(([t, o]) => ({
510
+ key: t,
511
+ schema: o
512
+ })).filter((t) => !this.isWowSchema(t.key));
501
513
  }
502
514
  isWowSchema(e) {
503
515
  return e.startsWith("wow.");
@@ -521,12 +533,12 @@ class xe extends x {
521
533
  s && P(s, t.title, t.description);
522
534
  }
523
535
  process(e, t, o) {
524
- if (ae(o))
536
+ if (le(o))
525
537
  return t.addEnum({
526
538
  name: e.name,
527
539
  isExported: !0,
528
540
  members: o.enum.filter((s) => typeof s == "string" && s.length > 0).map((s) => ({
529
- name: s,
541
+ name: Z(s),
530
542
  initializer: `'${s}'`
531
543
  }))
532
544
  });
@@ -539,10 +551,10 @@ class xe extends x {
539
551
  e,
540
552
  o,
541
553
  r
542
- ) : (M(o) && (o.anyOf || o.oneOf || o.allOf).forEach((a) => {
543
- if (g(a)) {
554
+ ) : (q(o) && (o.anyOf || o.oneOf || o.allOf).forEach((i) => {
555
+ if (g(i)) {
544
556
  const c = d(
545
- f(a)
557
+ f(i)
546
558
  );
547
559
  O(
548
560
  e,
@@ -555,7 +567,7 @@ class xe extends x {
555
567
  this.processInterface(
556
568
  t,
557
569
  e,
558
- a,
570
+ i,
559
571
  r
560
572
  );
561
573
  }), r);
@@ -573,18 +585,18 @@ class xe extends x {
573
585
  );
574
586
  }
575
587
  processInterface(e, t, o, r) {
576
- for (const [s, a] of Object.entries(o.properties)) {
588
+ for (const [s, i] of Object.entries(o.properties)) {
577
589
  const c = this.resolvePropertyType(
578
590
  t,
579
591
  e,
580
592
  s,
581
- a
593
+ i
582
594
  );
583
- let i = r.getProperty(s);
584
- i ? i.setType(c) : i = r.addProperty({
595
+ let a = r.getProperty(s);
596
+ a ? a.setType(c) : a = r.addProperty({
585
597
  name: s,
586
598
  type: c
587
- }), g(a) || P(i, a.title, a.description);
599
+ }), g(i) || P(a, i.title, i.description);
588
600
  }
589
601
  return r;
590
602
  }
@@ -600,18 +612,18 @@ class xe extends x {
600
612
  }
601
613
  if (r.const)
602
614
  return `'${r.const}'`;
603
- if (ie(r)) {
615
+ if (ge(r)) {
604
616
  const s = this.resolvePropertyType(
605
617
  e,
606
618
  t,
607
619
  o,
608
620
  r.items
609
621
  );
610
- return le(s);
622
+ return ue(s);
611
623
  }
612
- if (r.type && se(r.type))
624
+ if (r.type && ce(r.type))
613
625
  return N(r.type);
614
- if (M(r))
626
+ if (q(r))
615
627
  return this.resolvePropertyCompositionType(
616
628
  e,
617
629
  t,
@@ -620,13 +632,13 @@ class xe extends x {
620
632
  if (r.type === "object" && r.properties) {
621
633
  const s = {
622
634
  path: e.path,
623
- name: `${e.name}${w(o)}`
624
- }, a = this.processObject(
635
+ name: `${e.name}${$(o)}`
636
+ }, i = this.processObject(
625
637
  t,
626
638
  s,
627
639
  r
628
640
  );
629
- return P(a, r.title, r.description), s.name;
641
+ return P(i, r.title, r.description), s.name;
630
642
  }
631
643
  return "any";
632
644
  }
@@ -634,37 +646,37 @@ class xe extends x {
634
646
  const r = o.anyOf || o.oneOf || o.allOf, s = /* @__PURE__ */ new Set();
635
647
  r.forEach((c) => {
636
648
  if (g(c)) {
637
- const i = d(
649
+ const a = d(
638
650
  f(c)
639
651
  );
640
652
  O(
641
653
  e,
642
654
  t,
643
655
  this.outputDir,
644
- i
645
- ), s.add(i.name);
656
+ a
657
+ ), s.add(a.name);
646
658
  return;
647
659
  }
648
660
  s.add(N(c.type ?? "string"));
649
661
  });
650
- const a = ce(o) ? "|" : "&";
651
- return Array.from(s).join(a);
662
+ const i = pe(o) ? "|" : "&";
663
+ return Array.from(s).join(i);
652
664
  }
653
665
  }
654
- function Oe(n) {
666
+ function Ie(n) {
655
667
  let e = 0, t = 0;
656
668
  return n.commands.forEach((o) => {
657
669
  o.path.startsWith(b.TENANT) && (e += 1), o.path.startsWith(b.OWNER) && (t += 1);
658
670
  }), e === 0 && t === 0 ? "ResourceAttributionPathSpec.NONE" : e > t ? "ResourceAttributionPathSpec.TENANT" : "ResourceAttributionPathSpec.OWNER";
659
671
  }
660
- function B(n, e, t, o) {
672
+ function k(n, e, t, o) {
661
673
  const r = `${t.contextAlias}/${t.aggregateName}/${o}.ts`;
662
674
  return T(n, e, r);
663
675
  }
664
- function Ee(n, e) {
665
- return `${w(n.aggregateName)}${e}`;
676
+ function Ne(n, e) {
677
+ return `${$(n.aggregateName)}${e}`;
666
678
  }
667
- class Se extends x {
679
+ class Te extends x {
668
680
  /**
669
681
  * Creates a new QueryClientGenerator instance.
670
682
  * @param context - The generation context containing OpenAPI spec and project details
@@ -701,7 +713,7 @@ class Se extends x {
701
713
  * @returns The source file for the client
702
714
  */
703
715
  createClientFilePath(e, t) {
704
- return B(
716
+ return k(
705
717
  this.project,
706
718
  this.outputDir,
707
719
  e,
@@ -741,7 +753,7 @@ class Se extends x {
741
753
  initializer: `{
742
754
  contextAlias: '${e.aggregate.contextAlias}',
743
755
  aggregateName: '${e.aggregate.aggregateName}',
744
- resourceAttribution: ${Oe(e)},
756
+ resourceAttribution: ${Ie(e)},
745
757
  }`
746
758
  }
747
759
  ],
@@ -757,24 +769,24 @@ class Se extends x {
757
769
  `Adding import for event model: ${l.name} from path: ${l.path}`
758
770
  ), y(t, this.outputDir, l), r.push(l);
759
771
  }
760
- const s = "DOMAIN_EVENT_TYPES", a = r.map((m) => m.name).join(" | ");
772
+ const s = "DOMAIN_EVENT_TYPES", i = r.map((m) => m.name).join(" | ");
761
773
  this.logger.info(
762
- `Creating domain event types union: ${s} = ${a}`
774
+ `Creating domain event types union: ${s} = ${i}`
763
775
  ), t.addTypeAlias({
764
776
  name: s,
765
- type: a
777
+ type: i
766
778
  });
767
- const c = `${h(e.aggregate.aggregateName)}QueryClientFactory`, i = d(e.state.key), p = d(e.fields.key);
779
+ const c = `${h(e.aggregate.aggregateName)}QueryClientFactory`, a = d(e.state.key), p = d(e.fields.key);
768
780
  this.logger.info(
769
- `Adding import for state model: ${i.name} from path: ${i.path}`
770
- ), y(t, this.outputDir, i), this.logger.info(
781
+ `Adding import for state model: ${a.name} from path: ${a.path}`
782
+ ), y(t, this.outputDir, a), this.logger.info(
771
783
  `Adding import for fields model: ${p.name} from path: ${p.path}`
772
784
  ), y(t, this.outputDir, p), this.logger.info(`Creating query client factory: ${c}`), t.addVariableStatement({
773
785
  declarationKind: E.Const,
774
786
  declarations: [
775
787
  {
776
788
  name: c,
777
- initializer: `new QueryClientFactory<${i.name}, ${p.name} | string, ${s}>(${o})`
789
+ initializer: `new QueryClientFactory<${a.name}, ${p.name} | string, ${s}>(${o})`
778
790
  }
779
791
  ],
780
792
  isExported: !0
@@ -783,7 +795,7 @@ class Se extends x {
783
795
  );
784
796
  }
785
797
  }
786
- class Ie extends x {
798
+ class De extends x {
787
799
  commandEndpointPathsName = "COMMAND_ENDPOINT_PATHS";
788
800
  defaultCommandClientOptionsName = "DEFAULT_COMMAND_CLIENT_OPTIONS";
789
801
  /**
@@ -823,7 +835,7 @@ class Ie extends x {
823
835
  this.logger.info(
824
836
  `Processing command client for aggregate: ${e.aggregate.aggregateName} in context: ${e.aggregate.contextAlias}`
825
837
  );
826
- const t = B(
838
+ const t = k(
827
839
  this.project,
828
840
  this.outputDir,
829
841
  e.aggregate,
@@ -864,9 +876,9 @@ class Ie extends x {
864
876
  namedImports: ["JsonEventStreamResultExtractor"]
865
877
  }), this.logger.info(
866
878
  "Adding import from @ahoo-wang/fetcher: ContentTypeValues"
867
- ), $(t, "@ahoo-wang/fetcher", ["ContentTypeValues"]), this.logger.info(
879
+ ), w(t, "@ahoo-wang/fetcher", ["ContentTypeValues"]), this.logger.info(
868
880
  "Adding imports from @ahoo-wang/fetcher-decorator: ApiMetadata types and decorators"
869
- ), $(t, "@ahoo-wang/fetcher-decorator", [
881
+ ), w(t, "@ahoo-wang/fetcher-decorator", [
870
882
  "type ApiMetadata",
871
883
  "type ApiMetadataCapable",
872
884
  "api",
@@ -907,7 +919,7 @@ class Ie extends x {
907
919
  let r = "CommandClient", s = {
908
920
  name: "api",
909
921
  arguments: []
910
- }, a = "Promise<CommandResult>";
922
+ }, i = "Promise<CommandResult>";
911
923
  o && (r = "Stream" + r, s = {
912
924
  name: "api",
913
925
  arguments: [
@@ -917,28 +929,28 @@ class Ie extends x {
917
929
  resultExtractor: JsonEventStreamResultExtractor,
918
930
  }`
919
931
  ]
920
- }, a = "Promise<CommandResultEventStream>");
921
- const c = Ee(
932
+ }, i = "Promise<CommandResultEventStream>");
933
+ const c = Ne(
922
934
  t.aggregate,
923
935
  r
924
- ), i = e.addClass({
936
+ ), a = e.addClass({
925
937
  name: c,
926
938
  isExported: !0,
927
939
  decorators: [s],
928
940
  implements: ["ApiMetadataCapable"]
929
941
  });
930
- i.addConstructor({
942
+ a.addConstructor({
931
943
  parameters: [
932
944
  {
933
945
  name: "apiMetadata",
934
946
  type: "ApiMetadata",
935
- scope: k.Public,
947
+ scope: L.Public,
936
948
  isReadonly: !0,
937
949
  initializer: `${this.defaultCommandClientOptionsName}`
938
950
  }
939
951
  ]
940
952
  }), t.commands.forEach((p) => {
941
- this.processCommandMethod(e, i, p, a);
953
+ this.processCommandMethod(e, a, p, i);
942
954
  });
943
955
  }
944
956
  methodToDecorator(e) {
@@ -959,24 +971,24 @@ class Ie extends x {
959
971
  ), this.logger.info(
960
972
  `Command method details: HTTP ${o.method}, path: ${o.path}, return type: ${r}`
961
973
  );
962
- const a = o.pathParameters.map((i) => (this.logger.info(
963
- `Adding path parameter: ${i.name} (type: string)`
974
+ const i = o.pathParameters.map((a) => (this.logger.info(
975
+ `Adding path parameter: ${a.name} (type: string)`
964
976
  ), {
965
- name: i.name,
977
+ name: a.name,
966
978
  type: "string",
967
979
  hasQuestionToken: !1,
968
980
  decorators: [
969
981
  {
970
982
  name: "path",
971
- arguments: [`'${i.name}'`]
983
+ arguments: [`'${a.name}'`]
972
984
  }
973
985
  ]
974
986
  }));
975
987
  this.logger.info(
976
988
  `Adding command request parameter: commandRequest (type: CommandRequest<${s.name}>)`
977
- ), a.push({
989
+ ), i.push({
978
990
  name: "commandRequest",
979
- hasQuestionToken: pe(o.schema.schema),
991
+ hasQuestionToken: de(o.schema.schema),
980
992
  type: `CommandRequest<${s.name}>`,
981
993
  decorators: [
982
994
  {
@@ -986,7 +998,7 @@ class Ie extends x {
986
998
  ]
987
999
  }), this.logger.info(
988
1000
  "Adding attributes parameter: attributes (type: Record<string, any>)"
989
- ), a.push({
1001
+ ), i.push({
990
1002
  name: "attributes",
991
1003
  hasQuestionToken: !0,
992
1004
  type: "Record<string, any>",
@@ -1005,10 +1017,10 @@ class Ie extends x {
1005
1017
  arguments: [`${this.getEndpointPath(o)}`]
1006
1018
  }
1007
1019
  ],
1008
- parameters: a,
1020
+ parameters: i,
1009
1021
  returnType: r,
1010
1022
  statements: [
1011
- `throw autoGeneratedError(${a.map((i) => i.name).join(",")});`
1023
+ `throw autoGeneratedError(${i.map((a) => a.name).join(",")});`
1012
1024
  ]
1013
1025
  });
1014
1026
  (o.summary || o.description) && this.logger.info(
@@ -1018,7 +1030,7 @@ class Ie extends x {
1018
1030
  );
1019
1031
  }
1020
1032
  }
1021
- class Ne extends x {
1033
+ class ve extends x {
1022
1034
  queryClientGenerator;
1023
1035
  commandClientGenerator;
1024
1036
  /**
@@ -1026,7 +1038,7 @@ class Ne extends x {
1026
1038
  * @param context - The generation context containing OpenAPI spec and project details
1027
1039
  */
1028
1040
  constructor(e) {
1029
- super(e), this.queryClientGenerator = new Se(e), this.commandClientGenerator = new Ie(e);
1041
+ super(e), this.queryClientGenerator = new Te(e), this.commandClientGenerator = new De(e);
1030
1042
  }
1031
1043
  /**
1032
1044
  * Generates client classes for all aggregates.
@@ -1062,7 +1074,7 @@ class Ne extends x {
1062
1074
  );
1063
1075
  }
1064
1076
  }
1065
- class Me {
1077
+ class Fe {
1066
1078
  /**
1067
1079
  * Creates a new CodeGenerator instance.
1068
1080
  * @param options - Configuration options for code generation
@@ -1080,9 +1092,9 @@ class Me {
1080
1092
  this.options.logger.info(
1081
1093
  "Starting code generation from OpenAPI specification"
1082
1094
  ), 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");
1083
- const e = await ee(this.options.inputPath);
1095
+ const e = await ne(this.options.inputPath);
1084
1096
  this.options.logger.info("OpenAPI specification parsed successfully"), this.options.logger.info("Resolving bounded context aggregates");
1085
- const o = new $e(e).resolve();
1097
+ const o = new Oe(e).resolve();
1086
1098
  this.options.logger.info(
1087
1099
  `Resolved ${o.size} bounded context aggregates`
1088
1100
  );
@@ -1093,7 +1105,7 @@ class Me {
1093
1105
  contextAggregates: o,
1094
1106
  logger: this.options.logger
1095
1107
  };
1096
- this.options.logger.info("Generating models"), new xe(r).generate(), this.options.logger.info("Models generated successfully"), this.options.logger.info("Generating clients"), new Ne(r).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");
1108
+ this.options.logger.info("Generating models"), new Se(r).generate(), this.options.logger.info("Models generated successfully"), this.options.logger.info("Generating clients"), new ve(r).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");
1097
1109
  }
1098
1110
  /**
1099
1111
  * Generates index.ts files for all subdirectories in the output directory.
@@ -1132,8 +1144,8 @@ class Me {
1132
1144
  let r = [];
1133
1145
  try {
1134
1146
  r = v.readdirSync(t).filter((c) => {
1135
- const i = K.join(t, c);
1136
- return v.statSync(i).isDirectory();
1147
+ const a = J.join(t, c);
1148
+ return v.statSync(a).isDirectory();
1137
1149
  });
1138
1150
  } catch (c) {
1139
1151
  this.options.logger.error(
@@ -1150,22 +1162,22 @@ class Me {
1150
1162
  }
1151
1163
  const s = `${t}/index.ts`;
1152
1164
  this.options.logger.info(`Creating/updating index file: ${s}`);
1153
- const a = this.project.getSourceFile(s) || this.project.createSourceFile(s, "", { overwrite: !0 });
1154
- a.removeText();
1165
+ const i = this.project.getSourceFile(s) || this.project.createSourceFile(s, "", { overwrite: !0 });
1166
+ i.removeText();
1155
1167
  for (const c of o) {
1156
- const i = `./${c.getBaseNameWithoutExtension()}`;
1157
- this.options.logger.info(`Adding export for file: ${i}`), a.addExportDeclaration({
1158
- moduleSpecifier: i,
1168
+ const a = `./${c.getBaseNameWithoutExtension()}`;
1169
+ this.options.logger.info(`Adding export for file: ${a}`), i.addExportDeclaration({
1170
+ moduleSpecifier: a,
1159
1171
  isTypeOnly: !1,
1160
1172
  namedExports: []
1161
1173
  });
1162
1174
  }
1163
1175
  for (const c of r) {
1164
- const i = `./${c}`;
1176
+ const a = `./${c}`;
1165
1177
  this.options.logger.info(
1166
- `Adding export for subdirectory: ${i}`
1167
- ), a.addExportDeclaration({
1168
- moduleSpecifier: i,
1178
+ `Adding export for subdirectory: ${a}`
1179
+ ), i.addExportDeclaration({
1180
+ moduleSpecifier: a,
1169
1181
  isTypeOnly: !1,
1170
1182
  namedExports: []
1171
1183
  });
@@ -1184,6 +1196,6 @@ class Me {
1184
1196
  }
1185
1197
  }
1186
1198
  export {
1187
- Me as CodeGenerator
1199
+ Fe as CodeGenerator
1188
1200
  };
1189
1201
  //# sourceMappingURL=index.js.map