@ahoo-wang/fetcher-generator 3.8.3 → 3.8.6
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/cli.cjs +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.cjs +7 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +101 -91
- package/dist/index.js.map +1 -1
- package/dist/model/modelGenerator.d.ts.map +1 -1
- package/dist/model/typeGenerator.d.ts +2 -0
- package/dist/model/typeGenerator.d.ts.map +1 -1
- package/dist/utils/schemas.d.ts +1 -0
- package/dist/utils/schemas.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ function Y(n, e) {
|
|
|
15
15
|
const t = P(n);
|
|
16
16
|
return e.requestBodies?.[t];
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function X(n, e) {
|
|
19
19
|
const t = P(n);
|
|
20
20
|
return e.parameters?.[t];
|
|
21
21
|
}
|
|
@@ -29,7 +29,7 @@ const Ie = /[-_'\s./?;:,()[\]{}|\\]+/;
|
|
|
29
29
|
function M(n) {
|
|
30
30
|
return n.split(Ie);
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function Z(n) {
|
|
33
33
|
return Array.isArray(n) ? n.flatMap((e) => B(M(e))) : B(M(n));
|
|
34
34
|
}
|
|
35
35
|
function B(n) {
|
|
@@ -46,7 +46,7 @@ function B(n) {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
function w(n) {
|
|
49
|
-
return n === "" || n.length === 0 ? "" :
|
|
49
|
+
return n === "" || n.length === 0 ? "" : Z(n).filter((t) => t.length > 0).map((t) => {
|
|
50
50
|
const o = t.charAt(0), r = t.slice(1);
|
|
51
51
|
return (/[a-zA-Z]/.test(o) ? o.toUpperCase() : o) + r.toLowerCase();
|
|
52
52
|
}).join("");
|
|
@@ -56,7 +56,7 @@ function f(n) {
|
|
|
56
56
|
return e.charAt(0).toLowerCase() + e.slice(1);
|
|
57
57
|
}
|
|
58
58
|
function ee(n) {
|
|
59
|
-
return n === "" || Array.isArray(n) && n.length === 0 ? "" :
|
|
59
|
+
return n === "" || Array.isArray(n) && n.length === 0 ? "" : Z(n).filter((t) => t.length > 0).map((t) => t.toUpperCase()).join("_");
|
|
60
60
|
}
|
|
61
61
|
function b(n) {
|
|
62
62
|
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(n) ? n : `'${n}'`;
|
|
@@ -117,10 +117,14 @@ function oe(n) {
|
|
|
117
117
|
function re(n) {
|
|
118
118
|
return n.type === "object" && !n.properties && n.additionalProperties !== void 0;
|
|
119
119
|
}
|
|
120
|
-
|
|
120
|
+
const Oe = "x-map-key-schema";
|
|
121
|
+
function Me(n) {
|
|
122
|
+
return n[Oe];
|
|
123
|
+
}
|
|
124
|
+
function be(n) {
|
|
121
125
|
return n.type !== "object" ? !1 : n.properties ? Object.keys(n.properties).length === 0 : !0;
|
|
122
126
|
}
|
|
123
|
-
function
|
|
127
|
+
function qe(n) {
|
|
124
128
|
return n.readOnly === !0;
|
|
125
129
|
}
|
|
126
130
|
function D(n) {
|
|
@@ -140,13 +144,13 @@ function D(n) {
|
|
|
140
144
|
return "any";
|
|
141
145
|
}
|
|
142
146
|
}
|
|
143
|
-
function
|
|
147
|
+
function Fe(n) {
|
|
144
148
|
if (!T(n))
|
|
145
149
|
return [];
|
|
146
150
|
const e = n.required || [];
|
|
147
151
|
return Object.keys(n.properties).filter((t) => !e.includes(t));
|
|
148
152
|
}
|
|
149
|
-
function
|
|
153
|
+
function je(n, e) {
|
|
150
154
|
return n.operation.operationId && e.operation.operationId ? n.operation.operationId.localeCompare(
|
|
151
155
|
e.operation.operationId
|
|
152
156
|
) : n.path && e.path ? n.path.localeCompare(e.path) : n.method && e.method ? n.method.localeCompare(e.method) : 0;
|
|
@@ -161,7 +165,7 @@ function ie(n) {
|
|
|
161
165
|
path: t
|
|
162
166
|
});
|
|
163
167
|
});
|
|
164
|
-
return e.sort(
|
|
168
|
+
return e.sort(je);
|
|
165
169
|
}
|
|
166
170
|
function se(n) {
|
|
167
171
|
return [
|
|
@@ -182,27 +186,27 @@ function Q(n) {
|
|
|
182
186
|
const e = W(n);
|
|
183
187
|
return te(e);
|
|
184
188
|
}
|
|
185
|
-
function
|
|
186
|
-
return n.parameters ? n.parameters.map((t) => p(t) ?
|
|
189
|
+
function _e(n, e) {
|
|
190
|
+
return n.parameters ? n.parameters.map((t) => p(t) ? X(t, e) : t).filter((t) => t.in === "path") : [];
|
|
187
191
|
}
|
|
188
|
-
const
|
|
192
|
+
const Ge = "string";
|
|
189
193
|
function ae(n) {
|
|
190
|
-
return !n.schema || p(n.schema) || !n.schema.type || !ne(n.schema.type) ?
|
|
194
|
+
return !n.schema || p(n.schema) || !n.schema.type || !ne(n.schema.type) ? Ge : D(n.schema.type);
|
|
191
195
|
}
|
|
192
196
|
function ce(n) {
|
|
193
|
-
return n.startsWith("http://") || n.startsWith("https://") ?
|
|
197
|
+
return n.startsWith("http://") || n.startsWith("https://") ? We(n) : ke(n);
|
|
194
198
|
}
|
|
195
|
-
async function
|
|
199
|
+
async function We(n) {
|
|
196
200
|
return await (await fetch(n)).text();
|
|
197
201
|
}
|
|
198
|
-
function
|
|
202
|
+
function ke(n) {
|
|
199
203
|
return new Promise((e, t) => {
|
|
200
204
|
Pe(n, "utf-8", (o, r) => {
|
|
201
205
|
o ? t(o) : e(r);
|
|
202
206
|
});
|
|
203
207
|
});
|
|
204
208
|
}
|
|
205
|
-
async function
|
|
209
|
+
async function ze(n) {
|
|
206
210
|
const e = await ce(n);
|
|
207
211
|
switch (pe(e)) {
|
|
208
212
|
case "json":
|
|
@@ -213,7 +217,7 @@ async function We(n) {
|
|
|
213
217
|
throw new Error(`Unsupported file format: ${n}`);
|
|
214
218
|
}
|
|
215
219
|
}
|
|
216
|
-
async function
|
|
220
|
+
async function Le(n) {
|
|
217
221
|
const e = await ce(n);
|
|
218
222
|
switch (pe(e)) {
|
|
219
223
|
case "json":
|
|
@@ -238,8 +242,8 @@ function pe(n) {
|
|
|
238
242
|
}
|
|
239
243
|
throw new Error("Unable to infer file format");
|
|
240
244
|
}
|
|
241
|
-
const ge = "types.ts",
|
|
242
|
-
function
|
|
245
|
+
const ge = "types.ts", Be = "@";
|
|
246
|
+
function Ue(n) {
|
|
243
247
|
return E(n.path, ge);
|
|
244
248
|
}
|
|
245
249
|
function ue(n, e, t) {
|
|
@@ -261,7 +265,7 @@ function A(n, e, t) {
|
|
|
261
265
|
});
|
|
262
266
|
}
|
|
263
267
|
function m(n, e, t) {
|
|
264
|
-
if (t.path.startsWith(
|
|
268
|
+
if (t.path.startsWith(Be)) {
|
|
265
269
|
A(n, t.path, [t.name]);
|
|
266
270
|
return;
|
|
267
271
|
}
|
|
@@ -269,7 +273,7 @@ function m(n, e, t) {
|
|
|
269
273
|
let i = Te(o, r);
|
|
270
274
|
i = i.replace(/\.ts$/, ""), i = i.split(ve).join("/"), i.startsWith(".") || (i = "./" + i), A(n, i, [t.name]);
|
|
271
275
|
}
|
|
272
|
-
function
|
|
276
|
+
function Je(n, e, t, o) {
|
|
273
277
|
n.path !== o.path && m(e, t, o);
|
|
274
278
|
}
|
|
275
279
|
function le(n, e = `
|
|
@@ -290,13 +294,13 @@ function k(n, e) {
|
|
|
290
294
|
n.title,
|
|
291
295
|
n.description
|
|
292
296
|
];
|
|
293
|
-
return e && t.push(`- key: ${e}`), n.format && t.push(`- format: ${n.format}`), V(t, n, "default"), V(t, n, "example"),
|
|
297
|
+
return e && t.push(`- key: ${e}`), n.format && t.push(`- format: ${n.format}`), V(t, n, "default"), V(t, n, "example"), He(t, n), Ke(t, n), Ye(t, n), t;
|
|
294
298
|
}
|
|
295
|
-
function
|
|
299
|
+
function Qe(n, e, t) {
|
|
296
300
|
const o = k(e, t);
|
|
297
301
|
C(n, o);
|
|
298
302
|
}
|
|
299
|
-
function
|
|
303
|
+
function Ve(n, e, t) {
|
|
300
304
|
const o = k(e, t);
|
|
301
305
|
me(o, "schema", e), C(n, o);
|
|
302
306
|
}
|
|
@@ -313,7 +317,7 @@ function V(n, e, t) {
|
|
|
313
317
|
function me(n, e, t) {
|
|
314
318
|
n.push(`- ${e}: `), n.push("```json"), n.push(JSON.stringify(t, null, 2)), n.push("```");
|
|
315
319
|
}
|
|
316
|
-
function
|
|
320
|
+
function He(n, e) {
|
|
317
321
|
const t = ["- Numeric Constraints"];
|
|
318
322
|
e.minimum !== void 0 && t.push(` - minimum: ${e.minimum}`), e.maximum !== void 0 && t.push(` - maximum: ${e.maximum}`), e.exclusiveMinimum !== void 0 && t.push(
|
|
319
323
|
` - exclusiveMinimum: ${e.exclusiveMinimum}`
|
|
@@ -321,28 +325,28 @@ function Qe(n, e) {
|
|
|
321
325
|
` - exclusiveMaximum: ${e.exclusiveMaximum}`
|
|
322
326
|
), e.multipleOf !== void 0 && t.push(` - multipleOf: ${e.multipleOf}`), t.length !== 1 && n.push(...t);
|
|
323
327
|
}
|
|
324
|
-
function
|
|
328
|
+
function Ke(n, e) {
|
|
325
329
|
const t = ["- String Constraints"];
|
|
326
330
|
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);
|
|
327
331
|
}
|
|
328
|
-
function
|
|
332
|
+
function Ye(n, e) {
|
|
329
333
|
const t = ["- Array Constraints"];
|
|
330
334
|
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);
|
|
331
335
|
}
|
|
332
|
-
function
|
|
336
|
+
function Xe(n) {
|
|
333
337
|
const e = n.split(".");
|
|
334
338
|
return e.length != 2 || e[0].length === 0 || e[1].length === 0 ? null : e;
|
|
335
339
|
}
|
|
336
|
-
function
|
|
337
|
-
const e =
|
|
340
|
+
function Ze(n) {
|
|
341
|
+
const e = Xe(n.name);
|
|
338
342
|
return e ? {
|
|
339
343
|
tag: n,
|
|
340
344
|
contextAlias: e[0],
|
|
341
345
|
aggregateName: e[1]
|
|
342
346
|
} : null;
|
|
343
347
|
}
|
|
344
|
-
function
|
|
345
|
-
const e = n?.map((o) =>
|
|
348
|
+
function et(n) {
|
|
349
|
+
const e = n?.map((o) => Ze(o)).filter((o) => o !== null);
|
|
346
350
|
if (!e)
|
|
347
351
|
return /* @__PURE__ */ new Map();
|
|
348
352
|
const t = /* @__PURE__ */ new Map();
|
|
@@ -354,20 +358,20 @@ function Ze(n) {
|
|
|
354
358
|
});
|
|
355
359
|
}), t;
|
|
356
360
|
}
|
|
357
|
-
function
|
|
361
|
+
function tt(n) {
|
|
358
362
|
if (!n)
|
|
359
363
|
return null;
|
|
360
364
|
const e = n.split(".");
|
|
361
365
|
return e.length != 3 ? null : e[2];
|
|
362
366
|
}
|
|
363
|
-
const
|
|
364
|
-
class
|
|
367
|
+
const nt = "#/components/responses/wow.CommandOk", ot = "#/components/parameters/wow.id";
|
|
368
|
+
class rt {
|
|
365
369
|
/**
|
|
366
370
|
* Creates a new AggregateResolver instance.
|
|
367
371
|
* @param openAPI - The OpenAPI specification to resolve aggregates from
|
|
368
372
|
*/
|
|
369
373
|
constructor(e) {
|
|
370
|
-
this.openAPI = e, this.aggregates =
|
|
374
|
+
this.openAPI = e, this.aggregates = et(e.tags), this.build();
|
|
371
375
|
}
|
|
372
376
|
aggregates;
|
|
373
377
|
/**
|
|
@@ -403,17 +407,17 @@ class nt {
|
|
|
403
407
|
const o = t.operation;
|
|
404
408
|
if (o.operationId === "wow.command.send")
|
|
405
409
|
return;
|
|
406
|
-
const r =
|
|
410
|
+
const r = tt(o.operationId);
|
|
407
411
|
if (!r)
|
|
408
412
|
return;
|
|
409
413
|
const i = W(o);
|
|
410
|
-
if (!i || !p(i) || i.$ref !==
|
|
414
|
+
if (!i || !p(i) || i.$ref !== nt || !o.requestBody)
|
|
411
415
|
return;
|
|
412
|
-
const s = o.parameters ?? [], a = s.filter((u) => p(u) && u.$ref ===
|
|
416
|
+
const s = o.parameters ?? [], a = s.filter((u) => p(u) && u.$ref === ot).at(0), c = s.filter(
|
|
413
417
|
(u) => !p(u) && u.in === "path"
|
|
414
418
|
);
|
|
415
419
|
if (a) {
|
|
416
|
-
const u =
|
|
420
|
+
const u = X(
|
|
417
421
|
a,
|
|
418
422
|
this.openAPI.components
|
|
419
423
|
);
|
|
@@ -512,7 +516,7 @@ class nt {
|
|
|
512
516
|
});
|
|
513
517
|
}
|
|
514
518
|
}
|
|
515
|
-
const x = "@ahoo-wang/fetcher-wow",
|
|
519
|
+
const x = "@ahoo-wang/fetcher-wow", it = {
|
|
516
520
|
"wow.command.CommandResult": "CommandResult",
|
|
517
521
|
"wow.command.CommandResultArray": "CommandResultArray",
|
|
518
522
|
"wow.MessageHeaderSqlType": "MessageHeaderSqlType",
|
|
@@ -547,7 +551,7 @@ const x = "@ahoo-wang/fetcher-wow", ot = {
|
|
|
547
551
|
function l(n) {
|
|
548
552
|
if (!n)
|
|
549
553
|
return { name: "", path: "/" };
|
|
550
|
-
const e =
|
|
554
|
+
const e = it[n];
|
|
551
555
|
if (e)
|
|
552
556
|
return { name: e, path: x };
|
|
553
557
|
const t = n.split(".");
|
|
@@ -567,13 +571,13 @@ function v(n) {
|
|
|
567
571
|
function N(n) {
|
|
568
572
|
return `${ee(n)}_BOUNDED_CONTEXT_ALIAS`;
|
|
569
573
|
}
|
|
570
|
-
class
|
|
574
|
+
class st {
|
|
571
575
|
constructor(e, t, o, r) {
|
|
572
576
|
this.modelInfo = e, this.sourceFile = t, this.keySchema = o, this.outputDir = r;
|
|
573
577
|
}
|
|
574
578
|
generate() {
|
|
575
579
|
const e = this.process();
|
|
576
|
-
e &&
|
|
580
|
+
e && Ve(e, this.keySchema.schema, this.keySchema.key);
|
|
577
581
|
}
|
|
578
582
|
process() {
|
|
579
583
|
const { schema: e } = this.keySchema;
|
|
@@ -581,7 +585,7 @@ class rt {
|
|
|
581
585
|
}
|
|
582
586
|
resolveReference(e) {
|
|
583
587
|
const t = v(e);
|
|
584
|
-
return
|
|
588
|
+
return Je(
|
|
585
589
|
this.modelInfo,
|
|
586
590
|
this.sourceFile,
|
|
587
591
|
this.outputDir,
|
|
@@ -624,11 +628,19 @@ class rt {
|
|
|
624
628
|
resolveMapValueType(e) {
|
|
625
629
|
return e.additionalProperties === void 0 || e.additionalProperties === !1 || e.additionalProperties === !0 ? "any" : this.resolveType(e.additionalProperties);
|
|
626
630
|
}
|
|
631
|
+
resolveMapKeyType(e) {
|
|
632
|
+
const t = Me(e);
|
|
633
|
+
return t ? this.resolveType(t) : "string";
|
|
634
|
+
}
|
|
635
|
+
resolveMapType(e) {
|
|
636
|
+
const t = this.resolveMapKeyType(e), o = this.resolveMapValueType(e);
|
|
637
|
+
return `Record<${t},${o}>`;
|
|
638
|
+
}
|
|
627
639
|
resolveType(e) {
|
|
628
640
|
if (p(e))
|
|
629
641
|
return this.resolveReference(e).name;
|
|
630
642
|
if (re(e))
|
|
631
|
-
return
|
|
643
|
+
return this.resolveMapType(e);
|
|
632
644
|
if (e.const)
|
|
633
645
|
return `'${e.const}'`;
|
|
634
646
|
if (U(e))
|
|
@@ -659,8 +671,8 @@ class rt {
|
|
|
659
671
|
s ? s.setType(r) : s = e.addProperty({
|
|
660
672
|
name: i,
|
|
661
673
|
type: r,
|
|
662
|
-
isReadonly:
|
|
663
|
-
}),
|
|
674
|
+
isReadonly: qe(o)
|
|
675
|
+
}), Qe(s, o);
|
|
664
676
|
}
|
|
665
677
|
processInterface(e) {
|
|
666
678
|
const t = this.sourceFile.addInterface({
|
|
@@ -722,12 +734,12 @@ class rt {
|
|
|
722
734
|
});
|
|
723
735
|
}
|
|
724
736
|
}
|
|
725
|
-
class
|
|
737
|
+
class at {
|
|
726
738
|
constructor(e) {
|
|
727
739
|
this.context = e;
|
|
728
740
|
}
|
|
729
741
|
getOrCreateSourceFile(e) {
|
|
730
|
-
const t =
|
|
742
|
+
const t = Ue(e);
|
|
731
743
|
return this.context.getOrCreateSourceFile(t);
|
|
732
744
|
}
|
|
733
745
|
/**
|
|
@@ -765,11 +777,9 @@ class it {
|
|
|
765
777
|
);
|
|
766
778
|
}
|
|
767
779
|
isWowSchema(e, t) {
|
|
768
|
-
if (e !== "wow.api.query.PagedList" && e.startsWith("wow.api.query.") && e.endsWith("PagedList"))
|
|
780
|
+
if (e !== "wow.api.query.PagedList" && e.startsWith("wow.api.query.") && e.endsWith("PagedList") || e.startsWith("wow.api.query.Operator") && e.endsWith("Map"))
|
|
769
781
|
return !1;
|
|
770
|
-
if (e.startsWith("wow.") || e.endsWith("AggregatedCondition") || e.endsWith("AggregatedDomainEventStream") || e.endsWith("AggregatedDomainEventStreamPagedList") || e.endsWith(
|
|
771
|
-
"AggregatedDomainEventStreamServerSentEventNonNullData"
|
|
772
|
-
) || e.endsWith("AggregatedListQuery") || e.endsWith("AggregatedPagedQuery") || e.endsWith("AggregatedSingleQuery"))
|
|
782
|
+
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"))
|
|
773
783
|
return !0;
|
|
774
784
|
const o = l(e);
|
|
775
785
|
return t.has(o.name);
|
|
@@ -809,7 +819,7 @@ class it {
|
|
|
809
819
|
*/
|
|
810
820
|
generateKeyedSchema(e) {
|
|
811
821
|
const t = l(e.key), o = this.getOrCreateSourceFile(t);
|
|
812
|
-
new
|
|
822
|
+
new st(
|
|
813
823
|
t,
|
|
814
824
|
o,
|
|
815
825
|
e,
|
|
@@ -823,9 +833,9 @@ class it {
|
|
|
823
833
|
o.addStatements(`export const ${r} = '${e}';`);
|
|
824
834
|
}
|
|
825
835
|
}
|
|
826
|
-
const
|
|
836
|
+
const ct = "@ahoo-wang/fetcher", pt = [
|
|
827
837
|
"ResultExtractors"
|
|
828
|
-
],
|
|
838
|
+
], gt = "@ahoo-wang/fetcher-decorator", ut = [
|
|
829
839
|
"type ApiMetadata",
|
|
830
840
|
"type ApiMetadataCapable",
|
|
831
841
|
"type ParameterRequest",
|
|
@@ -839,7 +849,7 @@ const st = "@ahoo-wang/fetcher", at = [
|
|
|
839
849
|
"attribute",
|
|
840
850
|
"path",
|
|
841
851
|
"autoGeneratedError"
|
|
842
|
-
],
|
|
852
|
+
], lt = {
|
|
843
853
|
type: "Promise<Response>",
|
|
844
854
|
metadata: "{resultExtractor: ResultExtractors.Response }"
|
|
845
855
|
}, H = {
|
|
@@ -849,11 +859,11 @@ const st = "@ahoo-wang/fetcher", at = [
|
|
|
849
859
|
headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },
|
|
850
860
|
resultExtractor: JsonEventStreamResultExtractor,
|
|
851
861
|
}`;
|
|
852
|
-
function
|
|
853
|
-
A(n,
|
|
862
|
+
function mt(n) {
|
|
863
|
+
A(n, ct, pt);
|
|
854
864
|
}
|
|
855
865
|
function de(n) {
|
|
856
|
-
A(n,
|
|
866
|
+
A(n, gt, ut);
|
|
857
867
|
}
|
|
858
868
|
function j(n, e, t = [], o = [], r) {
|
|
859
869
|
return e.addClass({
|
|
@@ -883,14 +893,14 @@ function fe(n, e) {
|
|
|
883
893
|
]
|
|
884
894
|
});
|
|
885
895
|
}
|
|
886
|
-
const
|
|
896
|
+
const dt = "@ahoo-wang/fetcher-eventstream";
|
|
887
897
|
function he(n) {
|
|
888
|
-
A(n,
|
|
898
|
+
A(n, dt, [
|
|
889
899
|
"JsonEventStreamResultExtractor",
|
|
890
900
|
"type JsonServerSentEventStream"
|
|
891
901
|
]);
|
|
892
902
|
}
|
|
893
|
-
function
|
|
903
|
+
function ft(n) {
|
|
894
904
|
let e = 0, t = 0;
|
|
895
905
|
return n.commands.forEach((o) => {
|
|
896
906
|
o.path.startsWith(L.TENANT) && (e += 1), o.path.startsWith(L.OWNER) && (t += 1);
|
|
@@ -906,9 +916,9 @@ function y(n, e) {
|
|
|
906
916
|
function _(n) {
|
|
907
917
|
return n === "delete" ? "del" : n;
|
|
908
918
|
}
|
|
909
|
-
const
|
|
910
|
-
function
|
|
911
|
-
const t = n[
|
|
919
|
+
const ht = "x-fetcher-method";
|
|
920
|
+
function yt(n, e) {
|
|
921
|
+
const t = n[ht];
|
|
912
922
|
if (t)
|
|
913
923
|
return t;
|
|
914
924
|
if (!n.operationId)
|
|
@@ -921,7 +931,7 @@ function ft(n, e) {
|
|
|
921
931
|
}
|
|
922
932
|
return f(o);
|
|
923
933
|
}
|
|
924
|
-
class
|
|
934
|
+
class xt {
|
|
925
935
|
/**
|
|
926
936
|
* Creates a new ApiClientGenerator instance.
|
|
927
937
|
* @param context - The generation context containing OpenAPI spec and configuration
|
|
@@ -930,7 +940,7 @@ class ht {
|
|
|
930
940
|
this.context = e, this.apiMetadataCtorInitializer = this.context.currentContextAlias ? `{basePath:${N(this.context.currentContextAlias)}}` : void 0;
|
|
931
941
|
}
|
|
932
942
|
defaultParameterRequestType = "ParameterRequest";
|
|
933
|
-
defaultReturnType =
|
|
943
|
+
defaultReturnType = lt;
|
|
934
944
|
apiMetadataCtorInitializer;
|
|
935
945
|
/**
|
|
936
946
|
* Generates API client classes for all valid tags in the OpenAPI specification.
|
|
@@ -987,7 +997,7 @@ class ht {
|
|
|
987
997
|
`Generating API client class: ${o.name}ApiClient with ${t.size} operations`
|
|
988
998
|
);
|
|
989
999
|
const r = this.createApiClientFile(o);
|
|
990
|
-
|
|
1000
|
+
mt(r), de(r), he(r);
|
|
991
1001
|
const i = j(
|
|
992
1002
|
o.name + "ApiClient",
|
|
993
1003
|
r
|
|
@@ -1007,7 +1017,7 @@ class ht {
|
|
|
1007
1017
|
* @returns A unique camelCase method name
|
|
1008
1018
|
*/
|
|
1009
1019
|
getMethodName(e, t) {
|
|
1010
|
-
const o =
|
|
1020
|
+
const o = yt(t, (r) => e.getMethod(r) !== void 0);
|
|
1011
1021
|
if (!o)
|
|
1012
1022
|
throw new Error(
|
|
1013
1023
|
`Unable to resolve method name for apiClientClass:${e.getName()}.`
|
|
@@ -1064,7 +1074,7 @@ class ht {
|
|
|
1064
1074
|
* @returns Array of parameter declarations
|
|
1065
1075
|
*/
|
|
1066
1076
|
resolveParameters(e, t, o) {
|
|
1067
|
-
const r =
|
|
1077
|
+
const r = _e(
|
|
1068
1078
|
o,
|
|
1069
1079
|
this.context.openAPI.components
|
|
1070
1080
|
).filter((a) => !this.context.isIgnoreApiClientPathParameters(
|
|
@@ -1296,7 +1306,7 @@ class ht {
|
|
|
1296
1306
|
return !1;
|
|
1297
1307
|
}
|
|
1298
1308
|
}
|
|
1299
|
-
class
|
|
1309
|
+
class At {
|
|
1300
1310
|
/**
|
|
1301
1311
|
* Creates a new CommandClientGenerator instance.
|
|
1302
1312
|
* @param context - The generation context containing OpenAPI spec and project details
|
|
@@ -1424,7 +1434,7 @@ class yt {
|
|
|
1424
1434
|
return;
|
|
1425
1435
|
m(e, this.context.outputDir, o);
|
|
1426
1436
|
let i = `${o.name}`;
|
|
1427
|
-
const s =
|
|
1437
|
+
const s = Fe(t.schema.schema).map((a) => `'${a}'`).join(" | ");
|
|
1428
1438
|
s !== "" && (i = `PartialBy<${i},${s}>`), i = `CommandBody<${i}>`, e.addTypeAlias({
|
|
1429
1439
|
name: r,
|
|
1430
1440
|
type: `${i}`,
|
|
@@ -1511,7 +1521,7 @@ class yt {
|
|
|
1511
1521
|
`Adding command request parameter: commandRequest (type: CommandRequest<${r}>)`
|
|
1512
1522
|
), i.push({
|
|
1513
1523
|
name: "commandRequest",
|
|
1514
|
-
hasQuestionToken:
|
|
1524
|
+
hasQuestionToken: be(t.schema.schema),
|
|
1515
1525
|
type: `CommandRequest<${r}>`,
|
|
1516
1526
|
decorators: [
|
|
1517
1527
|
{
|
|
@@ -1568,7 +1578,7 @@ class yt {
|
|
|
1568
1578
|
);
|
|
1569
1579
|
}
|
|
1570
1580
|
}
|
|
1571
|
-
class
|
|
1581
|
+
class Ct {
|
|
1572
1582
|
/**
|
|
1573
1583
|
* Creates a new QueryClientGenerator instance.
|
|
1574
1584
|
* @param context - The generation context containing OpenAPI spec and project details
|
|
@@ -1646,7 +1656,7 @@ class xt {
|
|
|
1646
1656
|
initializer: `{
|
|
1647
1657
|
contextAlias: ${N(e.aggregate.contextAlias)},
|
|
1648
1658
|
aggregateName: '${e.aggregate.aggregateName}',
|
|
1649
|
-
resourceAttribution: ${
|
|
1659
|
+
resourceAttribution: ${ft(e)},
|
|
1650
1660
|
}`
|
|
1651
1661
|
}
|
|
1652
1662
|
],
|
|
@@ -1717,13 +1727,13 @@ class xt {
|
|
|
1717
1727
|
});
|
|
1718
1728
|
}
|
|
1719
1729
|
}
|
|
1720
|
-
class
|
|
1730
|
+
class Pt {
|
|
1721
1731
|
/**
|
|
1722
1732
|
* Creates a new ClientGenerator instance.
|
|
1723
1733
|
* @param context - The generation context containing OpenAPI spec and project details
|
|
1724
1734
|
*/
|
|
1725
1735
|
constructor(e) {
|
|
1726
|
-
this.context = e, this.queryClientGenerator = new
|
|
1736
|
+
this.context = e, this.queryClientGenerator = new Ct(e), this.commandClientGenerator = new At(e), this.apiClientGenerator = new xt(e);
|
|
1727
1737
|
}
|
|
1728
1738
|
queryClientGenerator;
|
|
1729
1739
|
commandClientGenerator;
|
|
@@ -1746,7 +1756,7 @@ class At {
|
|
|
1746
1756
|
this.queryClientGenerator.generate(), this.commandClientGenerator.generate(), this.apiClientGenerator.generate(), this.context.logger.success("Client generation completed");
|
|
1747
1757
|
}
|
|
1748
1758
|
}
|
|
1749
|
-
class
|
|
1759
|
+
class $t {
|
|
1750
1760
|
/** The ts-morph project instance used for code generation */
|
|
1751
1761
|
project;
|
|
1752
1762
|
/** The OpenAPI specification object */
|
|
@@ -1773,8 +1783,8 @@ class Ct {
|
|
|
1773
1783
|
return this.defaultIgnorePathParameters.includes(t);
|
|
1774
1784
|
}
|
|
1775
1785
|
}
|
|
1776
|
-
const
|
|
1777
|
-
class
|
|
1786
|
+
const Tt = "./fetcher-generator.config.json";
|
|
1787
|
+
class Dt {
|
|
1778
1788
|
/**
|
|
1779
1789
|
* Creates a new CodeGenerator instance with the specified options.
|
|
1780
1790
|
*
|
|
@@ -1812,20 +1822,20 @@ class Rt {
|
|
|
1812
1822
|
);
|
|
1813
1823
|
const e = process.cwd();
|
|
1814
1824
|
this.options.logger.info(`Work directory: ${e}`), this.options.logger.info(`Input path: ${this.options.inputPath}`), this.options.logger.info(`Output directory: ${this.options.outputDir}`), this.options.logger.info("Parsing OpenAPI specification");
|
|
1815
|
-
const t = await
|
|
1825
|
+
const t = await ze(this.options.inputPath);
|
|
1816
1826
|
this.options.logger.info("OpenAPI specification parsed successfully"), this.options.logger.info("Resolving bounded context aggregates");
|
|
1817
|
-
const r = new
|
|
1827
|
+
const r = new rt(t).resolve();
|
|
1818
1828
|
this.options.logger.info(
|
|
1819
1829
|
`Resolved ${r.size} bounded context aggregates`
|
|
1820
1830
|
);
|
|
1821
|
-
const i = this.options.configPath ??
|
|
1831
|
+
const i = this.options.configPath ?? Tt;
|
|
1822
1832
|
let s = {};
|
|
1823
1833
|
try {
|
|
1824
|
-
this.options.logger.info(`Parsing configuration file: ${i}`), s = await
|
|
1834
|
+
this.options.logger.info(`Parsing configuration file: ${i}`), s = await Le(i);
|
|
1825
1835
|
} catch (d) {
|
|
1826
1836
|
this.options.logger.info(`Configuration file parsing failed: ${d}`);
|
|
1827
1837
|
}
|
|
1828
|
-
const a = new
|
|
1838
|
+
const a = new $t({
|
|
1829
1839
|
openAPI: t,
|
|
1830
1840
|
project: this.project,
|
|
1831
1841
|
outputDir: this.options.outputDir,
|
|
@@ -1833,7 +1843,7 @@ class Rt {
|
|
|
1833
1843
|
logger: this.options.logger,
|
|
1834
1844
|
config: s
|
|
1835
1845
|
});
|
|
1836
|
-
this.options.logger.info("Generating models"), new
|
|
1846
|
+
this.options.logger.info("Generating models"), new at(a).generate(), this.options.logger.info("Models generated successfully"), this.options.logger.info("Generating clients"), new Pt(a).generate(), this.options.logger.info("Clients generated successfully");
|
|
1837
1847
|
const g = this.project.getDirectory(this.options.outputDir);
|
|
1838
1848
|
if (!g) {
|
|
1839
1849
|
this.options.logger.info("Output directory not found.");
|
|
@@ -1930,7 +1940,7 @@ class Rt {
|
|
|
1930
1940
|
}
|
|
1931
1941
|
}
|
|
1932
1942
|
export {
|
|
1933
|
-
|
|
1934
|
-
|
|
1943
|
+
Dt as CodeGenerator,
|
|
1944
|
+
Tt as DEFAULT_CONFIG_PATH
|
|
1935
1945
|
};
|
|
1936
1946
|
//# sourceMappingURL=index.js.map
|