@ahoo-wang/fetcher-generator 3.0.2 → 3.0.5
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 +76 -72
- package/dist/index.js.map +1 -1
- 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/dist/utils/sourceFiles.d.ts +2 -2
- package/dist/utils/sourceFiles.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Scope as fe, VariableDeclarationKind as
|
|
1
|
+
import { Scope as fe, VariableDeclarationKind as O, Project as he } from "ts-morph";
|
|
2
2
|
import { ContentTypeValues as T, combineURLs as v } from "@ahoo-wang/fetcher";
|
|
3
3
|
import { ResourceAttributionPathSpec as W } from "@ahoo-wang/fetcher-wow";
|
|
4
4
|
import { parse as V } from "yaml";
|
|
@@ -26,11 +26,11 @@ function P(n, e) {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
const Ce = /[-_\s.]+/;
|
|
29
|
-
function
|
|
29
|
+
function D(n) {
|
|
30
30
|
return n.split(Ce);
|
|
31
31
|
}
|
|
32
32
|
function Y(n) {
|
|
33
|
-
return Array.isArray(n) ? n.flatMap((e) => k(
|
|
33
|
+
return Array.isArray(n) ? n.flatMap((e) => k(D(e))) : k(D(n));
|
|
34
34
|
}
|
|
35
35
|
function k(n) {
|
|
36
36
|
return n.flatMap((e) => {
|
|
@@ -114,6 +114,9 @@ function Se(n) {
|
|
|
114
114
|
function Re(n) {
|
|
115
115
|
return n.type !== "object" ? !1 : n.properties ? Object.keys(n.properties).length === 0 : !0;
|
|
116
116
|
}
|
|
117
|
+
function we(n) {
|
|
118
|
+
return n.readOnly === !0;
|
|
119
|
+
}
|
|
117
120
|
function R(n) {
|
|
118
121
|
if (Array.isArray(n))
|
|
119
122
|
return n.map((e) => R(e)).join(" | ");
|
|
@@ -131,7 +134,7 @@ function R(n) {
|
|
|
131
134
|
return "any";
|
|
132
135
|
}
|
|
133
136
|
}
|
|
134
|
-
function
|
|
137
|
+
function Oe(n, e) {
|
|
135
138
|
return n.operation.operationId && e.operation.operationId ? n.operation.operationId.localeCompare(
|
|
136
139
|
e.operation.operationId
|
|
137
140
|
) : n.path && e.path ? n.path.localeCompare(e.path) : n.method && e.method ? n.method.localeCompare(e.method) : 0;
|
|
@@ -146,7 +149,7 @@ function te(n) {
|
|
|
146
149
|
path: t
|
|
147
150
|
});
|
|
148
151
|
});
|
|
149
|
-
return e.sort(
|
|
152
|
+
return e.sort(Oe);
|
|
150
153
|
}
|
|
151
154
|
function ne(n) {
|
|
152
155
|
return [
|
|
@@ -170,24 +173,24 @@ function B(n) {
|
|
|
170
173
|
function De(n, e) {
|
|
171
174
|
return n.parameters ? n.parameters.map((t) => g(t) ? K(t, e) : t).filter((t) => t.in === "path") : [];
|
|
172
175
|
}
|
|
173
|
-
const
|
|
176
|
+
const Ne = "string";
|
|
174
177
|
function oe(n) {
|
|
175
|
-
return !n.schema || g(n.schema) || !n.schema.type || !ee(n.schema.type) ?
|
|
178
|
+
return !n.schema || g(n.schema) || !n.schema.type || !ee(n.schema.type) ? Ne : R(n.schema.type);
|
|
176
179
|
}
|
|
177
180
|
function re(n) {
|
|
178
|
-
return n.startsWith("http://") || n.startsWith("https://") ?
|
|
181
|
+
return n.startsWith("http://") || n.startsWith("https://") ? Me(n) : be(n);
|
|
179
182
|
}
|
|
180
|
-
async function
|
|
183
|
+
async function Me(n) {
|
|
181
184
|
return await (await fetch(n)).text();
|
|
182
185
|
}
|
|
183
|
-
function
|
|
186
|
+
function be(n) {
|
|
184
187
|
return new Promise((e, t) => {
|
|
185
188
|
ye(n, "utf-8", (o, r) => {
|
|
186
189
|
o ? t(o) : e(r);
|
|
187
190
|
});
|
|
188
191
|
});
|
|
189
192
|
}
|
|
190
|
-
async function
|
|
193
|
+
async function qe(n) {
|
|
191
194
|
const e = await re(n);
|
|
192
195
|
switch (ie(e)) {
|
|
193
196
|
case "json":
|
|
@@ -198,7 +201,7 @@ async function be(n) {
|
|
|
198
201
|
throw new Error(`Unsupported file format: ${n}`);
|
|
199
202
|
}
|
|
200
203
|
}
|
|
201
|
-
async function
|
|
204
|
+
async function Fe(n) {
|
|
202
205
|
const e = await re(n);
|
|
203
206
|
switch (ie(e)) {
|
|
204
207
|
case "json":
|
|
@@ -223,8 +226,8 @@ function ie(n) {
|
|
|
223
226
|
}
|
|
224
227
|
throw new Error("Unable to infer file format");
|
|
225
228
|
}
|
|
226
|
-
const se = "types.ts",
|
|
227
|
-
function
|
|
229
|
+
const se = "types.ts", je = "@";
|
|
230
|
+
function Ge(n) {
|
|
228
231
|
return v(n.path, se);
|
|
229
232
|
}
|
|
230
233
|
function ae(n, e, t) {
|
|
@@ -246,7 +249,7 @@ function x(n, e, t) {
|
|
|
246
249
|
});
|
|
247
250
|
}
|
|
248
251
|
function m(n, e, t) {
|
|
249
|
-
if (t.path.startsWith(
|
|
252
|
+
if (t.path.startsWith(je)) {
|
|
250
253
|
x(n, t.path, [t.name]);
|
|
251
254
|
return;
|
|
252
255
|
}
|
|
@@ -254,7 +257,7 @@ function m(n, e, t) {
|
|
|
254
257
|
let i = Ae(o, r);
|
|
255
258
|
i = i.replace(/\.ts$/, ""), i.startsWith(".") || (i = "./" + i), x(n, i, [t.name]);
|
|
256
259
|
}
|
|
257
|
-
function
|
|
260
|
+
function _e(n, e, t, o) {
|
|
258
261
|
n.path !== o.path && m(e, t, o);
|
|
259
262
|
}
|
|
260
263
|
function ce(n, e = `
|
|
@@ -275,7 +278,7 @@ function ge(n, e) {
|
|
|
275
278
|
n.title,
|
|
276
279
|
n.description
|
|
277
280
|
];
|
|
278
|
-
return e && t.push(`- key: ${e}`), n.format && t.push(`- format: ${n.format}`), U(t, n, "default"), U(t, n, "example"),
|
|
281
|
+
return e && t.push(`- key: ${e}`), n.format && t.push(`- format: ${n.format}`), U(t, n, "default"), U(t, n, "example"), We(t, n), ke(t, n), ze(t, n), t;
|
|
279
282
|
}
|
|
280
283
|
function Q(n, e, t) {
|
|
281
284
|
const o = ge(e, t);
|
|
@@ -291,7 +294,7 @@ function U(n, e, t) {
|
|
|
291
294
|
n.push(`- ${t}: `), n.push("```json"), n.push(JSON.stringify(o)), n.push("```");
|
|
292
295
|
}
|
|
293
296
|
}
|
|
294
|
-
function
|
|
297
|
+
function We(n, e) {
|
|
295
298
|
const t = ["- Numeric Constraints"];
|
|
296
299
|
e.minimum !== void 0 && t.push(` - minimum: ${e.minimum}`), e.maximum !== void 0 && t.push(` - maximum: ${e.maximum}`), e.exclusiveMinimum !== void 0 && t.push(
|
|
297
300
|
` - exclusiveMinimum: ${e.exclusiveMinimum}`
|
|
@@ -299,28 +302,28 @@ function _e(n, e) {
|
|
|
299
302
|
` - exclusiveMaximum: ${e.exclusiveMaximum}`
|
|
300
303
|
), e.multipleOf !== void 0 && t.push(` - multipleOf: ${e.multipleOf}`), t.length !== 1 && n.push(...t);
|
|
301
304
|
}
|
|
302
|
-
function
|
|
305
|
+
function ke(n, e) {
|
|
303
306
|
const t = ["- String Constraints"];
|
|
304
307
|
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);
|
|
305
308
|
}
|
|
306
|
-
function
|
|
309
|
+
function ze(n, e) {
|
|
307
310
|
const t = ["- Array Constraints"];
|
|
308
311
|
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);
|
|
309
312
|
}
|
|
310
|
-
function
|
|
313
|
+
function Le(n) {
|
|
311
314
|
const e = n.split(".");
|
|
312
315
|
return e.length != 2 || e[0].length === 0 || e[1].length === 0 ? null : e;
|
|
313
316
|
}
|
|
314
|
-
function
|
|
315
|
-
const e =
|
|
317
|
+
function Be(n) {
|
|
318
|
+
const e = Le(n.name);
|
|
316
319
|
return e ? {
|
|
317
320
|
tag: n,
|
|
318
321
|
contextAlias: e[0],
|
|
319
322
|
aggregateName: e[1]
|
|
320
323
|
} : null;
|
|
321
324
|
}
|
|
322
|
-
function
|
|
323
|
-
const e = n?.map((o) =>
|
|
325
|
+
function Qe(n) {
|
|
326
|
+
const e = n?.map((o) => Be(o)).filter((o) => o !== null);
|
|
324
327
|
if (!e)
|
|
325
328
|
return /* @__PURE__ */ new Map();
|
|
326
329
|
const t = /* @__PURE__ */ new Map();
|
|
@@ -332,20 +335,20 @@ function Be(n) {
|
|
|
332
335
|
});
|
|
333
336
|
}), t;
|
|
334
337
|
}
|
|
335
|
-
function
|
|
338
|
+
function Ue(n) {
|
|
336
339
|
if (!n)
|
|
337
340
|
return null;
|
|
338
341
|
const e = n.split(".");
|
|
339
342
|
return e.length != 3 ? null : e[2];
|
|
340
343
|
}
|
|
341
|
-
const
|
|
342
|
-
class
|
|
344
|
+
const Je = "#/components/responses/wow.CommandOk", Ve = "#/components/parameters/wow.id";
|
|
345
|
+
class He {
|
|
343
346
|
/**
|
|
344
347
|
* Creates a new AggregateResolver instance.
|
|
345
348
|
* @param openAPI - The OpenAPI specification to resolve aggregates from
|
|
346
349
|
*/
|
|
347
350
|
constructor(e) {
|
|
348
|
-
this.openAPI = e, this.aggregates =
|
|
351
|
+
this.openAPI = e, this.aggregates = Qe(e.tags), this.build();
|
|
349
352
|
}
|
|
350
353
|
aggregates;
|
|
351
354
|
/**
|
|
@@ -381,13 +384,13 @@ class Ve {
|
|
|
381
384
|
const o = t.operation;
|
|
382
385
|
if (o.operationId === "wow.command.send")
|
|
383
386
|
return;
|
|
384
|
-
const r =
|
|
387
|
+
const r = Ue(o.operationId);
|
|
385
388
|
if (!r)
|
|
386
389
|
return;
|
|
387
390
|
const i = G(o);
|
|
388
|
-
if (!i || !g(i) || i.$ref !==
|
|
391
|
+
if (!i || !g(i) || i.$ref !== Je || !o.requestBody)
|
|
389
392
|
return;
|
|
390
|
-
const s = o.parameters ?? [], a = s.filter((l) => g(l) && l.$ref ===
|
|
393
|
+
const s = o.parameters ?? [], a = s.filter((l) => g(l) && l.$ref === Ve).at(0), c = s.filter(
|
|
391
394
|
(l) => !g(l) && l.in === "path"
|
|
392
395
|
);
|
|
393
396
|
if (a) {
|
|
@@ -490,7 +493,7 @@ class Ve {
|
|
|
490
493
|
});
|
|
491
494
|
}
|
|
492
495
|
}
|
|
493
|
-
const A = "@ahoo-wang/fetcher-wow",
|
|
496
|
+
const A = "@ahoo-wang/fetcher-wow", Ke = {
|
|
494
497
|
"wow.command.CommandResult": "CommandResult",
|
|
495
498
|
"wow.command.CommandResultArray": "CommandResultArray",
|
|
496
499
|
"wow.MessageHeaderSqlType": "MessageHeaderSqlType",
|
|
@@ -523,7 +526,7 @@ const A = "@ahoo-wang/fetcher-wow", He = {
|
|
|
523
526
|
function d(n) {
|
|
524
527
|
if (!n)
|
|
525
528
|
return { name: "", path: "/" };
|
|
526
|
-
const e =
|
|
529
|
+
const e = Ke[n];
|
|
527
530
|
if (e)
|
|
528
531
|
return { name: e, path: A };
|
|
529
532
|
const t = n.split(".");
|
|
@@ -540,7 +543,7 @@ function $(n) {
|
|
|
540
543
|
const e = C(n);
|
|
541
544
|
return d(e);
|
|
542
545
|
}
|
|
543
|
-
class
|
|
546
|
+
class Ye {
|
|
544
547
|
constructor(e, t, o, r) {
|
|
545
548
|
this.modelInfo = e, this.sourceFile = t, this.keySchema = o, this.outputDir = r;
|
|
546
549
|
}
|
|
@@ -554,7 +557,7 @@ class Ke {
|
|
|
554
557
|
}
|
|
555
558
|
resolveReference(e) {
|
|
556
559
|
const t = $(e);
|
|
557
|
-
return
|
|
560
|
+
return _e(
|
|
558
561
|
this.modelInfo,
|
|
559
562
|
this.sourceFile,
|
|
560
563
|
this.outputDir,
|
|
@@ -633,7 +636,8 @@ class Ke {
|
|
|
633
636
|
let i = e.getProperty(t);
|
|
634
637
|
i ? i.setType(r) : i = e.addProperty({
|
|
635
638
|
name: t,
|
|
636
|
-
type: r
|
|
639
|
+
type: r,
|
|
640
|
+
isReadonly: we(o)
|
|
637
641
|
}), Q(i, o);
|
|
638
642
|
}
|
|
639
643
|
processInterface(e) {
|
|
@@ -696,12 +700,12 @@ class Ke {
|
|
|
696
700
|
});
|
|
697
701
|
}
|
|
698
702
|
}
|
|
699
|
-
class
|
|
703
|
+
class Xe {
|
|
700
704
|
constructor(e) {
|
|
701
705
|
this.context = e;
|
|
702
706
|
}
|
|
703
707
|
getOrCreateSourceFile(e) {
|
|
704
|
-
const t =
|
|
708
|
+
const t = Ge(e);
|
|
705
709
|
return this.context.getOrCreateSourceFile(t);
|
|
706
710
|
}
|
|
707
711
|
/**
|
|
@@ -779,7 +783,7 @@ class Ye {
|
|
|
779
783
|
*/
|
|
780
784
|
generateKeyedSchema(e) {
|
|
781
785
|
const t = d(e.key), o = this.getOrCreateSourceFile(t);
|
|
782
|
-
new
|
|
786
|
+
new Ye(t, o, e, this.context.outputDir).generate();
|
|
783
787
|
}
|
|
784
788
|
generateBoundedContext(e) {
|
|
785
789
|
const t = `${e}/boundedContext.ts`;
|
|
@@ -790,7 +794,7 @@ class Ye {
|
|
|
790
794
|
);
|
|
791
795
|
}
|
|
792
796
|
}
|
|
793
|
-
const
|
|
797
|
+
const Ze = "@ahoo-wang/fetcher-decorator", et = [
|
|
794
798
|
"type ApiMetadata",
|
|
795
799
|
"type ApiMetadataCapable",
|
|
796
800
|
"type ParameterRequest",
|
|
@@ -804,7 +808,7 @@ const Xe = "@ahoo-wang/fetcher-decorator", Ze = [
|
|
|
804
808
|
"attribute",
|
|
805
809
|
"path",
|
|
806
810
|
"autoGeneratedError"
|
|
807
|
-
],
|
|
811
|
+
], tt = {
|
|
808
812
|
type: "Promise<Response>",
|
|
809
813
|
metadata: "{resultExtractor: ResultExtractors.Response }"
|
|
810
814
|
}, J = {
|
|
@@ -815,7 +819,7 @@ const Xe = "@ahoo-wang/fetcher-decorator", Ze = [
|
|
|
815
819
|
resultExtractor: JsonEventStreamResultExtractor,
|
|
816
820
|
}`;
|
|
817
821
|
function pe(n) {
|
|
818
|
-
x(n,
|
|
822
|
+
x(n, Ze, et);
|
|
819
823
|
}
|
|
820
824
|
function q(n, e, t = [], o = [], r) {
|
|
821
825
|
return e.addClass({
|
|
@@ -845,14 +849,14 @@ function ue(n, e) {
|
|
|
845
849
|
]
|
|
846
850
|
});
|
|
847
851
|
}
|
|
848
|
-
const
|
|
852
|
+
const nt = "@ahoo-wang/fetcher-eventstream";
|
|
849
853
|
function le(n) {
|
|
850
|
-
x(n,
|
|
854
|
+
x(n, nt, [
|
|
851
855
|
"JsonEventStreamResultExtractor",
|
|
852
856
|
"type JsonServerSentEventStream"
|
|
853
857
|
]);
|
|
854
858
|
}
|
|
855
|
-
function
|
|
859
|
+
function ot(n) {
|
|
856
860
|
let e = 0, t = 0;
|
|
857
861
|
return n.commands.forEach((o) => {
|
|
858
862
|
o.path.startsWith(W.TENANT) && (e += 1), o.path.startsWith(W.OWNER) && (t += 1);
|
|
@@ -868,14 +872,14 @@ function h(n, e) {
|
|
|
868
872
|
function F(n) {
|
|
869
873
|
return n === "delete" ? "del" : n;
|
|
870
874
|
}
|
|
871
|
-
const
|
|
872
|
-
function
|
|
873
|
-
const t = n[
|
|
875
|
+
const rt = "x-fetcher-method";
|
|
876
|
+
function it(n, e) {
|
|
877
|
+
const t = n[rt];
|
|
874
878
|
if (t)
|
|
875
879
|
return t;
|
|
876
880
|
if (!n.operationId)
|
|
877
881
|
return;
|
|
878
|
-
const o =
|
|
882
|
+
const o = D(n.operationId);
|
|
879
883
|
for (let r = o.length - 1; r >= 0; r--) {
|
|
880
884
|
const i = f(o.slice(r));
|
|
881
885
|
if (!e(i))
|
|
@@ -883,7 +887,7 @@ function rt(n, e) {
|
|
|
883
887
|
}
|
|
884
888
|
return f(o);
|
|
885
889
|
}
|
|
886
|
-
class
|
|
890
|
+
class st {
|
|
887
891
|
/**
|
|
888
892
|
* Creates a new ApiClientGenerator instance.
|
|
889
893
|
* @param context - The generation context containing OpenAPI spec and configuration
|
|
@@ -892,7 +896,7 @@ class it {
|
|
|
892
896
|
this.context = e, this.apiMetadataCtorInitializer = this.context.currentContextAlias ? `{basePath:'${this.context.currentContextAlias}'}` : void 0;
|
|
893
897
|
}
|
|
894
898
|
defaultParameterRequestType = "ParameterRequest";
|
|
895
|
-
defaultReturnType =
|
|
899
|
+
defaultReturnType = tt;
|
|
896
900
|
apiMetadataCtorInitializer;
|
|
897
901
|
/**
|
|
898
902
|
* Generates API client classes for all valid tags in the OpenAPI specification.
|
|
@@ -969,7 +973,7 @@ class it {
|
|
|
969
973
|
* @returns A unique camelCase method name
|
|
970
974
|
*/
|
|
971
975
|
getMethodName(e, t) {
|
|
972
|
-
const o =
|
|
976
|
+
const o = it(t, (r) => e.getMethod(r) !== void 0);
|
|
973
977
|
if (!o)
|
|
974
978
|
throw new Error(`Unable to resolve method name for apiClientClass:${e.getName()}.`);
|
|
975
979
|
return o;
|
|
@@ -1260,7 +1264,7 @@ class it {
|
|
|
1260
1264
|
return !1;
|
|
1261
1265
|
}
|
|
1262
1266
|
}
|
|
1263
|
-
class
|
|
1267
|
+
class at {
|
|
1264
1268
|
/**
|
|
1265
1269
|
* Creates a new CommandClientGenerator instance.
|
|
1266
1270
|
* @param context - The generation context containing OpenAPI spec and project details
|
|
@@ -1312,7 +1316,7 @@ class st {
|
|
|
1312
1316
|
this.context.logger.info(
|
|
1313
1317
|
`Creating default command client options: ${this.defaultCommandClientOptionsName}`
|
|
1314
1318
|
), t.addVariableStatement({
|
|
1315
|
-
declarationKind:
|
|
1319
|
+
declarationKind: O.Const,
|
|
1316
1320
|
declarations: [
|
|
1317
1321
|
{
|
|
1318
1322
|
name: this.defaultCommandClientOptionsName,
|
|
@@ -1502,7 +1506,7 @@ class st {
|
|
|
1502
1506
|
);
|
|
1503
1507
|
}
|
|
1504
1508
|
}
|
|
1505
|
-
class
|
|
1509
|
+
class ct {
|
|
1506
1510
|
/**
|
|
1507
1511
|
* Creates a new QueryClientGenerator instance.
|
|
1508
1512
|
* @param context - The generation context containing OpenAPI spec and project details
|
|
@@ -1573,7 +1577,7 @@ class at {
|
|
|
1573
1577
|
this.context.logger.info(
|
|
1574
1578
|
`Creating default query client options: ${o}`
|
|
1575
1579
|
), t.addVariableStatement({
|
|
1576
|
-
declarationKind:
|
|
1580
|
+
declarationKind: O.Const,
|
|
1577
1581
|
declarations: [
|
|
1578
1582
|
{
|
|
1579
1583
|
name: o,
|
|
@@ -1581,7 +1585,7 @@ class at {
|
|
|
1581
1585
|
initializer: `{
|
|
1582
1586
|
contextAlias: '${e.aggregate.contextAlias}',
|
|
1583
1587
|
aggregateName: '${e.aggregate.aggregateName}',
|
|
1584
|
-
resourceAttribution: ${
|
|
1588
|
+
resourceAttribution: ${ot(e)},
|
|
1585
1589
|
}`
|
|
1586
1590
|
}
|
|
1587
1591
|
],
|
|
@@ -1593,7 +1597,7 @@ class at {
|
|
|
1593
1597
|
), m(t, this.context.outputDir, s), this.context.logger.info(
|
|
1594
1598
|
`Adding import for fields model: ${a.name} from path: ${a.path}`
|
|
1595
1599
|
), m(t, this.context.outputDir, a), this.context.logger.info(`Creating query client factory: ${i}`), t.addVariableStatement({
|
|
1596
|
-
declarationKind:
|
|
1600
|
+
declarationKind: O.Const,
|
|
1597
1601
|
declarations: [
|
|
1598
1602
|
{
|
|
1599
1603
|
name: i,
|
|
@@ -1637,13 +1641,13 @@ class at {
|
|
|
1637
1641
|
});
|
|
1638
1642
|
}
|
|
1639
1643
|
}
|
|
1640
|
-
class
|
|
1644
|
+
class gt {
|
|
1641
1645
|
/**
|
|
1642
1646
|
* Creates a new ClientGenerator instance.
|
|
1643
1647
|
* @param context - The generation context containing OpenAPI spec and project details
|
|
1644
1648
|
*/
|
|
1645
1649
|
constructor(e) {
|
|
1646
|
-
this.context = e, this.queryClientGenerator = new
|
|
1650
|
+
this.context = e, this.queryClientGenerator = new ct(e), this.commandClientGenerator = new at(e), this.apiClientGenerator = new st(e);
|
|
1647
1651
|
}
|
|
1648
1652
|
queryClientGenerator;
|
|
1649
1653
|
commandClientGenerator;
|
|
@@ -1666,7 +1670,7 @@ class ct {
|
|
|
1666
1670
|
this.queryClientGenerator.generate(), this.commandClientGenerator.generate(), this.apiClientGenerator.generate(), this.context.logger.success("Client generation completed");
|
|
1667
1671
|
}
|
|
1668
1672
|
}
|
|
1669
|
-
class
|
|
1673
|
+
class pt {
|
|
1670
1674
|
/** The ts-morph project instance used for code generation */
|
|
1671
1675
|
project;
|
|
1672
1676
|
/** The OpenAPI specification object */
|
|
@@ -1693,8 +1697,8 @@ class gt {
|
|
|
1693
1697
|
return this.defaultIgnorePathParameters.includes(t);
|
|
1694
1698
|
}
|
|
1695
1699
|
}
|
|
1696
|
-
const
|
|
1697
|
-
class
|
|
1700
|
+
const ut = "./fetcher-generator.config.json";
|
|
1701
|
+
class xt {
|
|
1698
1702
|
/**
|
|
1699
1703
|
* Creates a new CodeGenerator instance with the specified options.
|
|
1700
1704
|
*
|
|
@@ -1730,20 +1734,20 @@ class yt {
|
|
|
1730
1734
|
this.options.logger.info(
|
|
1731
1735
|
"Starting code generation from OpenAPI specification"
|
|
1732
1736
|
), 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");
|
|
1733
|
-
const e = await
|
|
1737
|
+
const e = await qe(this.options.inputPath);
|
|
1734
1738
|
this.options.logger.info("OpenAPI specification parsed successfully"), this.options.logger.info("Resolving bounded context aggregates");
|
|
1735
|
-
const o = new
|
|
1739
|
+
const o = new He(e).resolve();
|
|
1736
1740
|
this.options.logger.info(
|
|
1737
1741
|
`Resolved ${o.size} bounded context aggregates`
|
|
1738
1742
|
);
|
|
1739
|
-
const r = this.options.configPath ??
|
|
1743
|
+
const r = this.options.configPath ?? ut;
|
|
1740
1744
|
let i = {};
|
|
1741
1745
|
try {
|
|
1742
|
-
this.options.logger.info(`Parsing configuration file: ${r}`), i = await
|
|
1746
|
+
this.options.logger.info(`Parsing configuration file: ${r}`), i = await Fe(r);
|
|
1743
1747
|
} catch (p) {
|
|
1744
1748
|
this.options.logger.info(`Configuration file parsing failed: ${p}`);
|
|
1745
1749
|
}
|
|
1746
|
-
const s = new
|
|
1750
|
+
const s = new pt({
|
|
1747
1751
|
openAPI: e,
|
|
1748
1752
|
project: this.project,
|
|
1749
1753
|
outputDir: this.options.outputDir,
|
|
@@ -1751,7 +1755,7 @@ class yt {
|
|
|
1751
1755
|
logger: this.options.logger,
|
|
1752
1756
|
config: i
|
|
1753
1757
|
});
|
|
1754
|
-
this.options.logger.info("Generating models"), new
|
|
1758
|
+
this.options.logger.info("Generating models"), new Xe(s).generate(), this.options.logger.info("Models generated successfully"), this.options.logger.info("Generating clients"), new gt(s).generate(), this.options.logger.info("Clients generated successfully");
|
|
1755
1759
|
const u = this.project.getDirectory(this.options.outputDir);
|
|
1756
1760
|
if (!u) {
|
|
1757
1761
|
this.options.logger.info("Output directory not found.");
|
|
@@ -1848,7 +1852,7 @@ class yt {
|
|
|
1848
1852
|
}
|
|
1849
1853
|
}
|
|
1850
1854
|
export {
|
|
1851
|
-
|
|
1852
|
-
|
|
1855
|
+
xt as CodeGenerator,
|
|
1856
|
+
ut as DEFAULT_CONFIG_PATH
|
|
1853
1857
|
};
|
|
1854
1858
|
//# sourceMappingURL=index.js.map
|