@ahoo-wang/fetcher-generator 3.0.8 → 3.0.9
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/client/queryClientGenerator.d.ts.map +1 -1
- package/dist/index.cjs +10 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +198 -195
- package/dist/index.js.map +1 -1
- package/dist/model/modelInfo.d.ts +1 -0
- package/dist/model/modelInfo.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Scope as
|
|
1
|
+
import { Scope as he, VariableDeclarationKind as O, Project as ye } from "ts-morph";
|
|
2
2
|
import { ContentTypeValues as T, combineURLs as v } from "@ahoo-wang/fetcher";
|
|
3
|
-
import { ResourceAttributionPathSpec as
|
|
4
|
-
import { parse as
|
|
5
|
-
import { readFile as
|
|
6
|
-
import { join as
|
|
3
|
+
import { ResourceAttributionPathSpec as k } from "@ahoo-wang/fetcher-wow";
|
|
4
|
+
import { parse as H } from "yaml";
|
|
5
|
+
import { readFile as xe } from "fs";
|
|
6
|
+
import { join as Ae, relative as Ce } from "path";
|
|
7
7
|
function C(n) {
|
|
8
8
|
return n.$ref.split("/").pop();
|
|
9
9
|
}
|
|
@@ -11,11 +11,11 @@ function I(n, e) {
|
|
|
11
11
|
const t = C(n);
|
|
12
12
|
return e.schemas?.[t];
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function K(n, e) {
|
|
15
15
|
const t = C(n);
|
|
16
16
|
return e.requestBodies?.[t];
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function Y(n, e) {
|
|
19
19
|
const t = C(n);
|
|
20
20
|
return e.parameters?.[t];
|
|
21
21
|
}
|
|
@@ -25,14 +25,14 @@ function P(n, e) {
|
|
|
25
25
|
schema: I(n, e)
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
function
|
|
30
|
-
return n.split(
|
|
28
|
+
const Pe = /[-_\s.]+/;
|
|
29
|
+
function N(n) {
|
|
30
|
+
return n.split(Pe);
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
return Array.isArray(n) ? n.flatMap((e) =>
|
|
32
|
+
function X(n) {
|
|
33
|
+
return Array.isArray(n) ? n.flatMap((e) => z(N(e))) : z(N(n));
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function z(n) {
|
|
36
36
|
return n.flatMap((e) => {
|
|
37
37
|
if (e.length === 0)
|
|
38
38
|
return [];
|
|
@@ -46,7 +46,7 @@ function k(n) {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
function S(n) {
|
|
49
|
-
return n === "" || n.length === 0 ? "" :
|
|
49
|
+
return n === "" || n.length === 0 ? "" : X(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("");
|
|
@@ -55,66 +55,66 @@ function f(n) {
|
|
|
55
55
|
const e = S(n);
|
|
56
56
|
return e.charAt(0).toLowerCase() + e.slice(1);
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
return n === "" || Array.isArray(n) && n.length === 0 ? "" :
|
|
58
|
+
function Z(n) {
|
|
59
|
+
return n === "" || Array.isArray(n) && n.length === 0 ? "" : X(n).filter((t) => t.length > 0).map((t) => t.toUpperCase()).join("_");
|
|
60
60
|
}
|
|
61
61
|
function g(n) {
|
|
62
62
|
return !!(n && typeof n == "object" && "$ref" in n);
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function G(n, e) {
|
|
65
65
|
if (e && !g(e) && e.content)
|
|
66
66
|
return e.content[n]?.schema;
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
return
|
|
70
|
-
}
|
|
71
|
-
function Pe(n) {
|
|
72
|
-
return j(T.TEXT_EVENT_STREAM, n);
|
|
68
|
+
function ee(n) {
|
|
69
|
+
return G(T.APPLICATION_JSON, n);
|
|
73
70
|
}
|
|
74
71
|
function $e(n) {
|
|
75
|
-
return
|
|
72
|
+
return G(T.TEXT_EVENT_STREAM, n);
|
|
76
73
|
}
|
|
77
|
-
|
|
74
|
+
function Te(n) {
|
|
75
|
+
return G("*/*", n);
|
|
76
|
+
}
|
|
77
|
+
const ve = [
|
|
78
78
|
"string",
|
|
79
79
|
"number",
|
|
80
80
|
"integer",
|
|
81
81
|
"boolean",
|
|
82
82
|
"null"
|
|
83
83
|
];
|
|
84
|
-
function
|
|
85
|
-
return Array.isArray(n) ? !0 :
|
|
84
|
+
function te(n) {
|
|
85
|
+
return Array.isArray(n) ? !0 : ve.includes(n);
|
|
86
86
|
}
|
|
87
|
-
function
|
|
87
|
+
function L(n) {
|
|
88
88
|
return Array.isArray(n.enum) && n.enum.length > 0;
|
|
89
89
|
}
|
|
90
|
-
function
|
|
90
|
+
function D(n) {
|
|
91
91
|
return n.type === "object" && !!n.properties;
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function M(n) {
|
|
94
94
|
return n.type === "array" && !!n.items;
|
|
95
95
|
}
|
|
96
|
-
function
|
|
96
|
+
function Ie(n) {
|
|
97
97
|
return Array.isArray(n.anyOf) && n.anyOf.length > 0;
|
|
98
98
|
}
|
|
99
|
-
function
|
|
99
|
+
function Ee(n) {
|
|
100
100
|
return Array.isArray(n.oneOf) && n.oneOf.length > 0;
|
|
101
101
|
}
|
|
102
|
-
function
|
|
102
|
+
function b(n) {
|
|
103
103
|
return Array.isArray(n.allOf) && n.allOf.length > 0;
|
|
104
104
|
}
|
|
105
|
-
function
|
|
106
|
-
return
|
|
105
|
+
function B(n) {
|
|
106
|
+
return Ie(n) || Ee(n) || b(n);
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function Se(n) {
|
|
109
109
|
return n.includes("|") || n.includes("&") ? `(${n})[]` : `${n}[]`;
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function Re(n) {
|
|
112
112
|
return n.type === "object" && !n.properties && n.additionalProperties !== void 0;
|
|
113
113
|
}
|
|
114
|
-
function
|
|
114
|
+
function we(n) {
|
|
115
115
|
return n.type !== "object" ? !1 : n.properties ? Object.keys(n.properties).length === 0 : !0;
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function De(n) {
|
|
118
118
|
return n.readOnly === !0;
|
|
119
119
|
}
|
|
120
120
|
function R(n) {
|
|
@@ -139,10 +139,10 @@ function Oe(n, e) {
|
|
|
139
139
|
e.operation.operationId
|
|
140
140
|
) : n.path && e.path ? n.path.localeCompare(e.path) : n.method && e.method ? n.method.localeCompare(e.method) : 0;
|
|
141
141
|
}
|
|
142
|
-
function
|
|
142
|
+
function ne(n) {
|
|
143
143
|
const e = [];
|
|
144
144
|
for (const [t, o] of Object.entries(n))
|
|
145
|
-
|
|
145
|
+
oe(o).forEach((r) => {
|
|
146
146
|
e.push({
|
|
147
147
|
method: r.method,
|
|
148
148
|
operation: r.operation,
|
|
@@ -151,7 +151,7 @@ function te(n) {
|
|
|
151
151
|
});
|
|
152
152
|
return e.sort(Oe);
|
|
153
153
|
}
|
|
154
|
-
function
|
|
154
|
+
function oe(n) {
|
|
155
155
|
return [
|
|
156
156
|
{ method: "get", operation: n.get },
|
|
157
157
|
{ method: "put", operation: n.put },
|
|
@@ -163,56 +163,56 @@ function ne(n) {
|
|
|
163
163
|
{ method: "trace", operation: n.trace }
|
|
164
164
|
].filter(({ operation: e }) => e !== void 0);
|
|
165
165
|
}
|
|
166
|
-
function
|
|
166
|
+
function _(n) {
|
|
167
167
|
return n.responses[200];
|
|
168
168
|
}
|
|
169
|
-
function
|
|
170
|
-
const e =
|
|
171
|
-
return
|
|
172
|
-
}
|
|
173
|
-
function De(n, e) {
|
|
174
|
-
return n.parameters ? n.parameters.map((t) => g(t) ? K(t, e) : t).filter((t) => t.in === "path") : [];
|
|
169
|
+
function U(n) {
|
|
170
|
+
const e = _(n);
|
|
171
|
+
return ee(e);
|
|
175
172
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return !n.schema || g(n.schema) || !n.schema.type || !ee(n.schema.type) ? Ne : R(n.schema.type);
|
|
173
|
+
function Ne(n, e) {
|
|
174
|
+
return n.parameters ? n.parameters.map((t) => g(t) ? Y(t, e) : t).filter((t) => t.in === "path") : [];
|
|
179
175
|
}
|
|
176
|
+
const Me = "string";
|
|
180
177
|
function re(n) {
|
|
181
|
-
return n.
|
|
178
|
+
return !n.schema || g(n.schema) || !n.schema.type || !te(n.schema.type) ? Me : R(n.schema.type);
|
|
179
|
+
}
|
|
180
|
+
function ie(n) {
|
|
181
|
+
return n.startsWith("http://") || n.startsWith("https://") ? be(n) : qe(n);
|
|
182
182
|
}
|
|
183
|
-
async function
|
|
183
|
+
async function be(n) {
|
|
184
184
|
return await (await fetch(n)).text();
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function qe(n) {
|
|
187
187
|
return new Promise((e, t) => {
|
|
188
|
-
|
|
188
|
+
xe(n, "utf-8", (o, r) => {
|
|
189
189
|
o ? t(o) : e(r);
|
|
190
190
|
});
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
|
-
async function
|
|
194
|
-
const e = await
|
|
195
|
-
switch (
|
|
193
|
+
async function Fe(n) {
|
|
194
|
+
const e = await ie(n);
|
|
195
|
+
switch (se(e)) {
|
|
196
196
|
case "json":
|
|
197
197
|
return JSON.parse(e);
|
|
198
198
|
case "yaml":
|
|
199
|
-
return
|
|
199
|
+
return H(e);
|
|
200
200
|
default:
|
|
201
201
|
throw new Error(`Unsupported file format: ${n}`);
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
-
async function
|
|
205
|
-
const e = await
|
|
206
|
-
switch (
|
|
204
|
+
async function je(n) {
|
|
205
|
+
const e = await ie(n);
|
|
206
|
+
switch (se(e)) {
|
|
207
207
|
case "json":
|
|
208
208
|
return JSON.parse(e);
|
|
209
209
|
case "yaml":
|
|
210
|
-
return
|
|
210
|
+
return H(e);
|
|
211
211
|
default:
|
|
212
212
|
throw new Error(`Unsupported file format: ${n}`);
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
function
|
|
215
|
+
function se(n) {
|
|
216
216
|
const e = n.trimStart();
|
|
217
217
|
if (e.startsWith("{") || e.startsWith("["))
|
|
218
218
|
return "json";
|
|
@@ -226,11 +226,11 @@ function ie(n) {
|
|
|
226
226
|
}
|
|
227
227
|
throw new Error("Unable to infer file format");
|
|
228
228
|
}
|
|
229
|
-
const
|
|
230
|
-
function
|
|
231
|
-
return v(n.path,
|
|
229
|
+
const ae = "types.ts", Ge = "@";
|
|
230
|
+
function _e(n) {
|
|
231
|
+
return v(n.path, ae);
|
|
232
232
|
}
|
|
233
|
-
function
|
|
233
|
+
function ce(n, e, t) {
|
|
234
234
|
const o = v(e, t), r = n.getSourceFile(o);
|
|
235
235
|
return r || n.createSourceFile(o, "", {
|
|
236
236
|
overwrite: !0
|
|
@@ -249,18 +249,18 @@ function x(n, e, t) {
|
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
251
|
function m(n, e, t) {
|
|
252
|
-
if (t.path.startsWith(
|
|
252
|
+
if (t.path.startsWith(Ge)) {
|
|
253
253
|
x(n, t.path, [t.name]);
|
|
254
254
|
return;
|
|
255
255
|
}
|
|
256
|
-
const o = n.getDirectoryPath(), r =
|
|
257
|
-
let i =
|
|
256
|
+
const o = n.getDirectoryPath(), r = Ae(e, t.path, ae);
|
|
257
|
+
let i = Ce(o, r);
|
|
258
258
|
i = i.replace(/\.ts$/, ""), i.startsWith(".") || (i = "./" + i), x(n, i, [t.name]);
|
|
259
259
|
}
|
|
260
|
-
function
|
|
260
|
+
function We(n, e, t, o) {
|
|
261
261
|
n.path !== o.path && m(e, t, o);
|
|
262
262
|
}
|
|
263
|
-
function
|
|
263
|
+
function ge(n, e = `
|
|
264
264
|
`) {
|
|
265
265
|
if (!Array.isArray(n))
|
|
266
266
|
return;
|
|
@@ -270,21 +270,21 @@ function ce(n, e = `
|
|
|
270
270
|
return t.length > 0 ? t.join(e) : void 0;
|
|
271
271
|
}
|
|
272
272
|
function E(n, e) {
|
|
273
|
-
const t =
|
|
273
|
+
const t = ge(e);
|
|
274
274
|
t && n.addJsDoc(t);
|
|
275
275
|
}
|
|
276
|
-
function
|
|
276
|
+
function pe(n, e) {
|
|
277
277
|
const t = [
|
|
278
278
|
n.title,
|
|
279
279
|
n.description
|
|
280
280
|
];
|
|
281
|
-
return e && t.push(`- key: ${e}`), n.format && t.push(`- format: ${n.format}`),
|
|
281
|
+
return e && t.push(`- key: ${e}`), n.format && t.push(`- format: ${n.format}`), J(t, n, "default"), J(t, n, "example"), ke(t, n), ze(t, n), Le(t, n), t;
|
|
282
282
|
}
|
|
283
283
|
function Q(n, e, t) {
|
|
284
|
-
const o =
|
|
284
|
+
const o = pe(e, t);
|
|
285
285
|
E(n, o);
|
|
286
286
|
}
|
|
287
|
-
function
|
|
287
|
+
function J(n, e, t) {
|
|
288
288
|
const o = e[t];
|
|
289
289
|
if (o) {
|
|
290
290
|
if (typeof o != "object") {
|
|
@@ -294,7 +294,7 @@ function U(n, e, t) {
|
|
|
294
294
|
n.push(`- ${t}: `), n.push("```json"), n.push(JSON.stringify(o)), n.push("```");
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
|
-
function
|
|
297
|
+
function ke(n, e) {
|
|
298
298
|
const t = ["- Numeric Constraints"];
|
|
299
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(
|
|
300
300
|
` - exclusiveMinimum: ${e.exclusiveMinimum}`
|
|
@@ -302,20 +302,20 @@ function We(n, e) {
|
|
|
302
302
|
` - exclusiveMaximum: ${e.exclusiveMaximum}`
|
|
303
303
|
), e.multipleOf !== void 0 && t.push(` - multipleOf: ${e.multipleOf}`), t.length !== 1 && n.push(...t);
|
|
304
304
|
}
|
|
305
|
-
function
|
|
305
|
+
function ze(n, e) {
|
|
306
306
|
const t = ["- String Constraints"];
|
|
307
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);
|
|
308
308
|
}
|
|
309
|
-
function
|
|
309
|
+
function Le(n, e) {
|
|
310
310
|
const t = ["- Array Constraints"];
|
|
311
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);
|
|
312
312
|
}
|
|
313
|
-
function
|
|
313
|
+
function Be(n) {
|
|
314
314
|
const e = n.split(".");
|
|
315
315
|
return e.length != 2 || e[0].length === 0 || e[1].length === 0 ? null : e;
|
|
316
316
|
}
|
|
317
|
-
function
|
|
318
|
-
const e =
|
|
317
|
+
function Ue(n) {
|
|
318
|
+
const e = Be(n.name);
|
|
319
319
|
return e ? {
|
|
320
320
|
tag: n,
|
|
321
321
|
contextAlias: e[0],
|
|
@@ -323,7 +323,7 @@ function Be(n) {
|
|
|
323
323
|
} : null;
|
|
324
324
|
}
|
|
325
325
|
function Qe(n) {
|
|
326
|
-
const e = n?.map((o) =>
|
|
326
|
+
const e = n?.map((o) => Ue(o)).filter((o) => o !== null);
|
|
327
327
|
if (!e)
|
|
328
328
|
return /* @__PURE__ */ new Map();
|
|
329
329
|
const t = /* @__PURE__ */ new Map();
|
|
@@ -335,14 +335,14 @@ function Qe(n) {
|
|
|
335
335
|
});
|
|
336
336
|
}), t;
|
|
337
337
|
}
|
|
338
|
-
function
|
|
338
|
+
function Je(n) {
|
|
339
339
|
if (!n)
|
|
340
340
|
return null;
|
|
341
341
|
const e = n.split(".");
|
|
342
342
|
return e.length != 3 ? null : e[2];
|
|
343
343
|
}
|
|
344
|
-
const
|
|
345
|
-
class
|
|
344
|
+
const Ve = "#/components/responses/wow.CommandOk", He = "#/components/parameters/wow.id";
|
|
345
|
+
class Ke {
|
|
346
346
|
/**
|
|
347
347
|
* Creates a new AggregateResolver instance.
|
|
348
348
|
* @param openAPI - The OpenAPI specification to resolve aggregates from
|
|
@@ -356,7 +356,7 @@ class He {
|
|
|
356
356
|
* @private
|
|
357
357
|
*/
|
|
358
358
|
build() {
|
|
359
|
-
const e =
|
|
359
|
+
const e = ne(this.openAPI.paths);
|
|
360
360
|
for (const t of e)
|
|
361
361
|
this.commands(t.path, t), this.state(t.operation), this.events(t.operation), this.fields(t.operation);
|
|
362
362
|
}
|
|
@@ -384,17 +384,17 @@ class He {
|
|
|
384
384
|
const o = t.operation;
|
|
385
385
|
if (o.operationId === "wow.command.send")
|
|
386
386
|
return;
|
|
387
|
-
const r =
|
|
387
|
+
const r = Je(o.operationId);
|
|
388
388
|
if (!r)
|
|
389
389
|
return;
|
|
390
|
-
const i =
|
|
391
|
-
if (!i || !g(i) || i.$ref !==
|
|
390
|
+
const i = _(o);
|
|
391
|
+
if (!i || !g(i) || i.$ref !== Ve || !o.requestBody)
|
|
392
392
|
return;
|
|
393
|
-
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 === He).at(0), c = s.filter(
|
|
394
394
|
(l) => !g(l) && l.in === "path"
|
|
395
395
|
);
|
|
396
396
|
if (a) {
|
|
397
|
-
const l =
|
|
397
|
+
const l = Y(
|
|
398
398
|
a,
|
|
399
399
|
this.openAPI.components
|
|
400
400
|
);
|
|
@@ -405,7 +405,7 @@ class He {
|
|
|
405
405
|
this.openAPI.components
|
|
406
406
|
);
|
|
407
407
|
y.schema.title = y.schema.title || o.summary, y.schema.description = y.schema.description || o.description;
|
|
408
|
-
const
|
|
408
|
+
const fe = {
|
|
409
409
|
name: r,
|
|
410
410
|
method: t.method,
|
|
411
411
|
path: e,
|
|
@@ -416,8 +416,8 @@ class He {
|
|
|
416
416
|
operation: o
|
|
417
417
|
};
|
|
418
418
|
o.tags?.forEach((l) => {
|
|
419
|
-
const
|
|
420
|
-
|
|
419
|
+
const W = this.aggregates.get(l);
|
|
420
|
+
W && W.commands.set(r, fe);
|
|
421
421
|
});
|
|
422
422
|
}
|
|
423
423
|
/**
|
|
@@ -427,7 +427,7 @@ class He {
|
|
|
427
427
|
state(e) {
|
|
428
428
|
if (!e.operationId?.endsWith(".snapshot_state.single"))
|
|
429
429
|
return;
|
|
430
|
-
const t =
|
|
430
|
+
const t = U(e);
|
|
431
431
|
if (!g(t))
|
|
432
432
|
return;
|
|
433
433
|
const o = P(
|
|
@@ -446,7 +446,7 @@ class He {
|
|
|
446
446
|
events(e) {
|
|
447
447
|
if (!this.openAPI.components || !e.operationId?.endsWith(".event.list_query"))
|
|
448
448
|
return;
|
|
449
|
-
const t =
|
|
449
|
+
const t = U(e);
|
|
450
450
|
if (g(t))
|
|
451
451
|
return;
|
|
452
452
|
const o = t?.items;
|
|
@@ -480,7 +480,7 @@ class He {
|
|
|
480
480
|
fields(e) {
|
|
481
481
|
if (!this.openAPI.components || !e.operationId?.endsWith(".snapshot.count"))
|
|
482
482
|
return;
|
|
483
|
-
const o =
|
|
483
|
+
const o = K(
|
|
484
484
|
e.requestBody,
|
|
485
485
|
this.openAPI.components
|
|
486
486
|
).content[T.APPLICATION_JSON].schema, i = I(
|
|
@@ -493,7 +493,7 @@ class He {
|
|
|
493
493
|
});
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
|
-
const A = "@ahoo-wang/fetcher-wow",
|
|
496
|
+
const A = "@ahoo-wang/fetcher-wow", Ye = {
|
|
497
497
|
"wow.command.CommandResult": "CommandResult",
|
|
498
498
|
"wow.command.CommandResultArray": "CommandResultArray",
|
|
499
499
|
"wow.MessageHeaderSqlType": "MessageHeaderSqlType",
|
|
@@ -526,7 +526,7 @@ const A = "@ahoo-wang/fetcher-wow", Ke = {
|
|
|
526
526
|
function d(n) {
|
|
527
527
|
if (!n)
|
|
528
528
|
return { name: "", path: "/" };
|
|
529
|
-
const e =
|
|
529
|
+
const e = Ye[n];
|
|
530
530
|
if (e)
|
|
531
531
|
return { name: e, path: A };
|
|
532
532
|
const t = n.split(".");
|
|
@@ -543,7 +543,10 @@ function $(n) {
|
|
|
543
543
|
const e = C(n);
|
|
544
544
|
return d(e);
|
|
545
545
|
}
|
|
546
|
-
|
|
546
|
+
function w(n) {
|
|
547
|
+
return `${Z(n)}_BOUNDED_CONTEXT_ALIAS`;
|
|
548
|
+
}
|
|
549
|
+
class Xe {
|
|
547
550
|
constructor(e, t, o, r) {
|
|
548
551
|
this.modelInfo = e, this.sourceFile = t, this.keySchema = o, this.outputDir = r;
|
|
549
552
|
}
|
|
@@ -553,11 +556,11 @@ class Ye {
|
|
|
553
556
|
}
|
|
554
557
|
process() {
|
|
555
558
|
const { schema: e } = this.keySchema;
|
|
556
|
-
return
|
|
559
|
+
return L(e) ? this.processEnum(e) : D(e) ? this.processInterface(e) : M(e) ? this.processArray(e) : b(e) ? this.processIntersection(e) : B(e) ? this.processComposition(e) : this.processTypeAlias(e);
|
|
557
560
|
}
|
|
558
561
|
resolveReference(e) {
|
|
559
562
|
const t = $(e);
|
|
560
|
-
return
|
|
563
|
+
return We(
|
|
561
564
|
this.modelInfo,
|
|
562
565
|
this.sourceFile,
|
|
563
566
|
this.outputDir,
|
|
@@ -574,7 +577,7 @@ class Ye {
|
|
|
574
577
|
return Object.entries(t).map(([o, r]) => {
|
|
575
578
|
const i = this.resolveType(r);
|
|
576
579
|
if (!g(r)) {
|
|
577
|
-
const s =
|
|
580
|
+
const s = pe(r), a = ge(s, `
|
|
578
581
|
* `);
|
|
579
582
|
if (a)
|
|
580
583
|
return `
|
|
@@ -589,7 +592,7 @@ class Ye {
|
|
|
589
592
|
}
|
|
590
593
|
resolveObjectType(e) {
|
|
591
594
|
const t = [];
|
|
592
|
-
if (
|
|
595
|
+
if (D(e)) {
|
|
593
596
|
const r = this.resolvePropertyDefinitions(e);
|
|
594
597
|
t.push(...r);
|
|
595
598
|
}
|
|
@@ -605,19 +608,19 @@ class Ye {
|
|
|
605
608
|
resolveType(e) {
|
|
606
609
|
if (g(e))
|
|
607
610
|
return this.resolveReference(e).name;
|
|
608
|
-
if (
|
|
611
|
+
if (Re(e))
|
|
609
612
|
return `Record<string,${this.resolveMapValueType(e)}>`;
|
|
610
613
|
if (e.const)
|
|
611
614
|
return `'${e.const}'`;
|
|
612
|
-
if (
|
|
615
|
+
if (L(e))
|
|
613
616
|
return e.enum.map((t) => `'${t}'`).join(" | ");
|
|
614
|
-
if (
|
|
615
|
-
const o = (e.oneOf || e.anyOf || e.allOf || []).map((i) => this.resolveType(i)), r =
|
|
617
|
+
if (B(e)) {
|
|
618
|
+
const o = (e.oneOf || e.anyOf || e.allOf || []).map((i) => this.resolveType(i)), r = b(e) ? " & " : " | ";
|
|
616
619
|
return `(${o.join(r)})`;
|
|
617
620
|
}
|
|
618
|
-
if (
|
|
621
|
+
if (M(e)) {
|
|
619
622
|
const t = this.resolveType(e.items);
|
|
620
|
-
return
|
|
623
|
+
return Se(t);
|
|
621
624
|
}
|
|
622
625
|
return e.type === "object" ? this.resolveObjectType(e) : e.type ? R(e.type) : "any";
|
|
623
626
|
}
|
|
@@ -626,7 +629,7 @@ class Ye {
|
|
|
626
629
|
name: this.modelInfo.name,
|
|
627
630
|
isExported: !0,
|
|
628
631
|
members: e.enum.filter((t) => typeof t == "string" && t.length > 0).map((t) => ({
|
|
629
|
-
name:
|
|
632
|
+
name: Z(t),
|
|
630
633
|
initializer: `'${t}'`
|
|
631
634
|
}))
|
|
632
635
|
});
|
|
@@ -637,7 +640,7 @@ class Ye {
|
|
|
637
640
|
i ? i.setType(r) : i = e.addProperty({
|
|
638
641
|
name: t,
|
|
639
642
|
type: r,
|
|
640
|
-
isReadonly:
|
|
643
|
+
isReadonly: De(o)
|
|
641
644
|
}), Q(i, o);
|
|
642
645
|
}
|
|
643
646
|
processInterface(e) {
|
|
@@ -681,7 +684,7 @@ class Ye {
|
|
|
681
684
|
t.addExtends(r);
|
|
682
685
|
return;
|
|
683
686
|
}
|
|
684
|
-
|
|
687
|
+
D(o) && Object.entries(o.properties).forEach(
|
|
685
688
|
([r, i]) => {
|
|
686
689
|
this.addPropertyToInterface(
|
|
687
690
|
t,
|
|
@@ -700,12 +703,12 @@ class Ye {
|
|
|
700
703
|
});
|
|
701
704
|
}
|
|
702
705
|
}
|
|
703
|
-
class
|
|
706
|
+
class Ze {
|
|
704
707
|
constructor(e) {
|
|
705
708
|
this.context = e;
|
|
706
709
|
}
|
|
707
710
|
getOrCreateSourceFile(e) {
|
|
708
|
-
const t =
|
|
711
|
+
const t = _e(e);
|
|
709
712
|
return this.context.getOrCreateSourceFile(t);
|
|
710
713
|
}
|
|
711
714
|
/**
|
|
@@ -783,18 +786,18 @@ class Xe {
|
|
|
783
786
|
*/
|
|
784
787
|
generateKeyedSchema(e) {
|
|
785
788
|
const t = d(e.key), o = this.getOrCreateSourceFile(t);
|
|
786
|
-
new
|
|
789
|
+
new Xe(t, o, e, this.context.outputDir).generate();
|
|
787
790
|
}
|
|
788
791
|
generateBoundedContext(e) {
|
|
789
792
|
const t = `${e}/boundedContext.ts`;
|
|
790
793
|
this.context.logger.info(`Creating bounded context file: ${t}`);
|
|
791
|
-
const o = this.context.getOrCreateSourceFile(t), r =
|
|
794
|
+
const o = this.context.getOrCreateSourceFile(t), r = w(e);
|
|
792
795
|
o.addStatements(
|
|
793
|
-
`export const ${r}
|
|
796
|
+
`export const ${r} = '${e}';`
|
|
794
797
|
);
|
|
795
798
|
}
|
|
796
799
|
}
|
|
797
|
-
const
|
|
800
|
+
const et = "@ahoo-wang/fetcher-decorator", tt = [
|
|
798
801
|
"type ApiMetadata",
|
|
799
802
|
"type ApiMetadataCapable",
|
|
800
803
|
"type ParameterRequest",
|
|
@@ -808,20 +811,20 @@ const Ze = "@ahoo-wang/fetcher-decorator", et = [
|
|
|
808
811
|
"attribute",
|
|
809
812
|
"path",
|
|
810
813
|
"autoGeneratedError"
|
|
811
|
-
],
|
|
814
|
+
], nt = {
|
|
812
815
|
type: "Promise<Response>",
|
|
813
816
|
metadata: "{resultExtractor: ResultExtractors.Response }"
|
|
814
|
-
},
|
|
817
|
+
}, V = {
|
|
815
818
|
type: "Promise<string>",
|
|
816
819
|
metadata: "{resultExtractor: ResultExtractors.Text }"
|
|
817
|
-
},
|
|
820
|
+
}, q = `{
|
|
818
821
|
headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },
|
|
819
822
|
resultExtractor: JsonEventStreamResultExtractor,
|
|
820
823
|
}`;
|
|
821
|
-
function
|
|
822
|
-
x(n,
|
|
824
|
+
function ue(n) {
|
|
825
|
+
x(n, et, tt);
|
|
823
826
|
}
|
|
824
|
-
function
|
|
827
|
+
function F(n, e, t = [], o = [], r) {
|
|
825
828
|
return e.addClass({
|
|
826
829
|
name: n,
|
|
827
830
|
isExported: !0,
|
|
@@ -835,51 +838,51 @@ function q(n, e, t = [], o = [], r) {
|
|
|
835
838
|
]
|
|
836
839
|
});
|
|
837
840
|
}
|
|
838
|
-
function
|
|
841
|
+
function le(n, e) {
|
|
839
842
|
n.addImplements("ApiMetadataCapable"), n.addConstructor({
|
|
840
843
|
parameters: [
|
|
841
844
|
{
|
|
842
845
|
name: "apiMetadata",
|
|
843
846
|
type: "ApiMetadata",
|
|
844
847
|
hasQuestionToken: e === void 0,
|
|
845
|
-
scope:
|
|
848
|
+
scope: he.Public,
|
|
846
849
|
isReadonly: !0,
|
|
847
850
|
initializer: e
|
|
848
851
|
}
|
|
849
852
|
]
|
|
850
853
|
});
|
|
851
854
|
}
|
|
852
|
-
const
|
|
853
|
-
function
|
|
854
|
-
x(n,
|
|
855
|
+
const ot = "@ahoo-wang/fetcher-eventstream";
|
|
856
|
+
function de(n) {
|
|
857
|
+
x(n, ot, [
|
|
855
858
|
"JsonEventStreamResultExtractor",
|
|
856
859
|
"type JsonServerSentEventStream"
|
|
857
860
|
]);
|
|
858
861
|
}
|
|
859
|
-
function
|
|
862
|
+
function rt(n) {
|
|
860
863
|
let e = 0, t = 0;
|
|
861
864
|
return n.commands.forEach((o) => {
|
|
862
|
-
o.path.startsWith(
|
|
865
|
+
o.path.startsWith(k.TENANT) && (e += 1), o.path.startsWith(k.OWNER) && (t += 1);
|
|
863
866
|
}), e === 0 && t === 0 ? "ResourceAttributionPathSpec.NONE" : e > t ? "ResourceAttributionPathSpec.TENANT" : "ResourceAttributionPathSpec.OWNER";
|
|
864
867
|
}
|
|
865
|
-
function
|
|
868
|
+
function me(n, e, t, o) {
|
|
866
869
|
const r = `${t.contextAlias}/${t.aggregateName}/${o}.ts`;
|
|
867
|
-
return
|
|
870
|
+
return ce(n, e, r);
|
|
868
871
|
}
|
|
869
872
|
function h(n, e) {
|
|
870
873
|
return `${S(n.aggregateName)}${e}`;
|
|
871
874
|
}
|
|
872
|
-
function
|
|
875
|
+
function j(n) {
|
|
873
876
|
return n === "delete" ? "del" : n;
|
|
874
877
|
}
|
|
875
|
-
const
|
|
876
|
-
function
|
|
877
|
-
const t = n[
|
|
878
|
+
const it = "x-fetcher-method";
|
|
879
|
+
function st(n, e) {
|
|
880
|
+
const t = n[it];
|
|
878
881
|
if (t)
|
|
879
882
|
return t;
|
|
880
883
|
if (!n.operationId)
|
|
881
884
|
return;
|
|
882
|
-
const o =
|
|
885
|
+
const o = N(n.operationId);
|
|
883
886
|
for (let r = o.length - 1; r >= 0; r--) {
|
|
884
887
|
const i = f(o.slice(r));
|
|
885
888
|
if (!e(i))
|
|
@@ -887,16 +890,16 @@ function it(n, e) {
|
|
|
887
890
|
}
|
|
888
891
|
return f(o);
|
|
889
892
|
}
|
|
890
|
-
class
|
|
893
|
+
class at {
|
|
891
894
|
/**
|
|
892
895
|
* Creates a new ApiClientGenerator instance.
|
|
893
896
|
* @param context - The generation context containing OpenAPI spec and configuration
|
|
894
897
|
*/
|
|
895
898
|
constructor(e) {
|
|
896
|
-
this.context = e, this.apiMetadataCtorInitializer = this.context.currentContextAlias ? `{basePath
|
|
899
|
+
this.context = e, this.apiMetadataCtorInitializer = this.context.currentContextAlias ? `{basePath:${w(this.context.currentContextAlias)}}` : void 0;
|
|
897
900
|
}
|
|
898
901
|
defaultParameterRequestType = "ParameterRequest";
|
|
899
|
-
defaultReturnType =
|
|
902
|
+
defaultReturnType = nt;
|
|
900
903
|
apiMetadataCtorInitializer;
|
|
901
904
|
/**
|
|
902
905
|
* Generates API client classes for all valid tags in the OpenAPI specification.
|
|
@@ -953,12 +956,12 @@ class st {
|
|
|
953
956
|
`Generating API client class: ${o.name}ApiClient with ${t.size} operations`
|
|
954
957
|
);
|
|
955
958
|
const r = this.createApiClientFile(o);
|
|
956
|
-
|
|
957
|
-
const i =
|
|
959
|
+
ue(r), de(r);
|
|
960
|
+
const i = F(
|
|
958
961
|
o.name + "ApiClient",
|
|
959
962
|
r
|
|
960
963
|
);
|
|
961
|
-
E(i, [e.description]),
|
|
964
|
+
E(i, [e.description]), le(i, this.apiMetadataCtorInitializer), this.context.logger.info(
|
|
962
965
|
`Processing ${t.size} operations for ${o.name}ApiClient`
|
|
963
966
|
), t.forEach((s) => {
|
|
964
967
|
this.processOperation(e, r, i, s);
|
|
@@ -973,7 +976,7 @@ class st {
|
|
|
973
976
|
* @returns A unique camelCase method name
|
|
974
977
|
*/
|
|
975
978
|
getMethodName(e, t) {
|
|
976
|
-
const o =
|
|
979
|
+
const o = st(t, (r) => e.getMethod(r) !== void 0);
|
|
977
980
|
if (!o)
|
|
978
981
|
throw new Error(`Unable to resolve method name for apiClientClass:${e.getName()}.`);
|
|
979
982
|
return o;
|
|
@@ -992,7 +995,7 @@ class st {
|
|
|
992
995
|
let o;
|
|
993
996
|
if (g(t.requestBody) ? (this.context.logger.info(
|
|
994
997
|
`Extracting request body from reference for operation: ${t.operationId}`
|
|
995
|
-
), o =
|
|
998
|
+
), o = K(
|
|
996
999
|
t.requestBody,
|
|
997
1000
|
this.context.openAPI.components
|
|
998
1001
|
)) : o = t.requestBody, !o)
|
|
@@ -1028,7 +1031,7 @@ class st {
|
|
|
1028
1031
|
* @returns Array of parameter declarations
|
|
1029
1032
|
*/
|
|
1030
1033
|
resolveParameters(e, t, o) {
|
|
1031
|
-
const r =
|
|
1034
|
+
const r = Ne(o, this.context.openAPI.components).filter((a) => !this.context.isIgnoreApiClientPathParameters(
|
|
1032
1035
|
e.name,
|
|
1033
1036
|
a.name
|
|
1034
1037
|
));
|
|
@@ -1036,7 +1039,7 @@ class st {
|
|
|
1036
1039
|
`Found ${r.length} path parameters for operation ${o.operationId}`
|
|
1037
1040
|
);
|
|
1038
1041
|
const i = r.map((a) => {
|
|
1039
|
-
const c =
|
|
1042
|
+
const c = re(a);
|
|
1040
1043
|
return this.context.logger.info(
|
|
1041
1044
|
`Adding path parameter: ${a.name} (type: ${c})`
|
|
1042
1045
|
), {
|
|
@@ -1095,7 +1098,7 @@ class st {
|
|
|
1095
1098
|
return this.context.logger.info(
|
|
1096
1099
|
`Schema has no type, using default return type: ${o}`
|
|
1097
1100
|
), o;
|
|
1098
|
-
if (
|
|
1101
|
+
if (te(t.type)) {
|
|
1099
1102
|
const i = `Promise<${R(t.type)}>`;
|
|
1100
1103
|
return this.context.logger.info(`Resolved primitive return type: ${i}`), i;
|
|
1101
1104
|
}
|
|
@@ -1110,29 +1113,29 @@ class st {
|
|
|
1110
1113
|
* @returns Object containing type and optional stream flag
|
|
1111
1114
|
*/
|
|
1112
1115
|
resolveReturnType(e, t) {
|
|
1113
|
-
const o =
|
|
1116
|
+
const o = _(t);
|
|
1114
1117
|
if (!o)
|
|
1115
1118
|
return this.context.logger.info(
|
|
1116
1119
|
`No OK response found for operation ${t.operationId}, using default return type: ${this.defaultReturnType.type}`
|
|
1117
1120
|
), this.defaultReturnType;
|
|
1118
|
-
const r =
|
|
1121
|
+
const r = ee(o) || Te(o);
|
|
1119
1122
|
if (r) {
|
|
1120
1123
|
const s = this.resolveSchemaReturnType(e, r);
|
|
1121
1124
|
return this.context.logger.info(
|
|
1122
1125
|
`Resolved JSON/wildcard response return type for operation ${t.operationId}: ${s}`
|
|
1123
1126
|
), {
|
|
1124
1127
|
type: s,
|
|
1125
|
-
metadata: s ===
|
|
1128
|
+
metadata: s === V.type ? V.metadata : void 0
|
|
1126
1129
|
};
|
|
1127
1130
|
}
|
|
1128
|
-
const i =
|
|
1131
|
+
const i = $e(o);
|
|
1129
1132
|
if (i) {
|
|
1130
1133
|
if (g(i)) {
|
|
1131
1134
|
const a = I(
|
|
1132
1135
|
i,
|
|
1133
1136
|
this.context.openAPI.components
|
|
1134
1137
|
);
|
|
1135
|
-
if (
|
|
1138
|
+
if (M(a) && g(a.items)) {
|
|
1136
1139
|
const c = $(a.items);
|
|
1137
1140
|
this.context.logger.info(
|
|
1138
1141
|
`Adding import for event stream model: ${c.name} from ${c.path}`
|
|
@@ -1142,14 +1145,14 @@ class st {
|
|
|
1142
1145
|
`Resolved event stream return type for operation ${t.operationId}: ${p}`
|
|
1143
1146
|
), {
|
|
1144
1147
|
type: p,
|
|
1145
|
-
metadata:
|
|
1148
|
+
metadata: q
|
|
1146
1149
|
};
|
|
1147
1150
|
}
|
|
1148
1151
|
}
|
|
1149
1152
|
const s = "Promise<JsonServerSentEventStream<any>>";
|
|
1150
1153
|
return this.context.logger.info(
|
|
1151
1154
|
`Resolved generic event stream return type for operation ${t.operationId}: ${s}`
|
|
1152
|
-
), { type: s, metadata:
|
|
1155
|
+
), { type: s, metadata: q };
|
|
1153
1156
|
}
|
|
1154
1157
|
return this.context.logger.info(
|
|
1155
1158
|
`Using default return type for operation ${t.operationId}: ${this.defaultReturnType.type}`
|
|
@@ -1173,10 +1176,10 @@ class st {
|
|
|
1173
1176
|
t,
|
|
1174
1177
|
r.operation
|
|
1175
1178
|
), a = this.resolveReturnType(t, r.operation), c = a.metadata ? {
|
|
1176
|
-
name:
|
|
1179
|
+
name: j(r.method),
|
|
1177
1180
|
arguments: [`'${r.path}'`, a.metadata]
|
|
1178
1181
|
} : {
|
|
1179
|
-
name:
|
|
1182
|
+
name: j(r.method),
|
|
1180
1183
|
arguments: [`'${r.path}'`]
|
|
1181
1184
|
};
|
|
1182
1185
|
this.context.logger.info(
|
|
@@ -1208,7 +1211,7 @@ class st {
|
|
|
1208
1211
|
*/
|
|
1209
1212
|
groupOperations(e) {
|
|
1210
1213
|
this.context.logger.info("Grouping operations by API client tags");
|
|
1211
|
-
const t = /* @__PURE__ */ new Map(), o =
|
|
1214
|
+
const t = /* @__PURE__ */ new Map(), o = ne(this.context.openAPI.paths).filter(
|
|
1212
1215
|
(i) => {
|
|
1213
1216
|
if (!i.operation.operationId)
|
|
1214
1217
|
return !1;
|
|
@@ -1239,7 +1242,7 @@ class st {
|
|
|
1239
1242
|
);
|
|
1240
1243
|
const e = /* @__PURE__ */ new Map(), t = this.context.openAPI.tags?.length || 0;
|
|
1241
1244
|
for (const r of Object.values(this.context.openAPI.paths))
|
|
1242
|
-
|
|
1245
|
+
oe(r).forEach((i) => {
|
|
1243
1246
|
i.operation.tags?.forEach((s) => {
|
|
1244
1247
|
!this.shouldIgnoreTag(s) && !e.has(s) && e.set(s, {
|
|
1245
1248
|
name: s,
|
|
@@ -1264,7 +1267,7 @@ class st {
|
|
|
1264
1267
|
return !1;
|
|
1265
1268
|
}
|
|
1266
1269
|
}
|
|
1267
|
-
class
|
|
1270
|
+
class ct {
|
|
1268
1271
|
/**
|
|
1269
1272
|
* Creates a new CommandClientGenerator instance.
|
|
1270
1273
|
* @param context - The generation context containing OpenAPI spec and project details
|
|
@@ -1303,7 +1306,7 @@ class at {
|
|
|
1303
1306
|
this.context.logger.info(
|
|
1304
1307
|
`Processing command client for aggregate: ${e.aggregate.aggregateName} in context: ${e.aggregate.contextAlias}`
|
|
1305
1308
|
);
|
|
1306
|
-
const t =
|
|
1309
|
+
const t = me(
|
|
1307
1310
|
this.context.project,
|
|
1308
1311
|
this.context.outputDir,
|
|
1309
1312
|
e.aggregate,
|
|
@@ -1322,7 +1325,7 @@ class at {
|
|
|
1322
1325
|
name: this.defaultCommandClientOptionsName,
|
|
1323
1326
|
type: "ApiMetadata",
|
|
1324
1327
|
initializer: `{
|
|
1325
|
-
basePath:
|
|
1328
|
+
basePath: ${w(e.aggregate.contextAlias)}
|
|
1326
1329
|
}`
|
|
1327
1330
|
}
|
|
1328
1331
|
],
|
|
@@ -1341,11 +1344,11 @@ class at {
|
|
|
1341
1344
|
isTypeOnly: !0
|
|
1342
1345
|
}), this.context.logger.info(
|
|
1343
1346
|
"Adding import from @ahoo-wang/fetcher-eventstream: JsonEventStreamResultExtractor"
|
|
1344
|
-
),
|
|
1347
|
+
), de(t), this.context.logger.info(
|
|
1345
1348
|
"Adding import from @ahoo-wang/fetcher: ContentTypeValues"
|
|
1346
1349
|
), x(t, "@ahoo-wang/fetcher", ["ContentTypeValues"]), this.context.logger.info(
|
|
1347
1350
|
"Adding imports from @ahoo-wang/fetcher-decorator: ApiMetadata types and decorators"
|
|
1348
|
-
),
|
|
1351
|
+
), ue(t), this.context.logger.info("Generating standard command client class"), this.processCommandClient(t, e, o), this.context.logger.info("Generating stream command client class"), this.processStreamCommandClient(t, e), this.context.logger.success(
|
|
1349
1352
|
`Command client generation completed for aggregate: ${e.aggregate.aggregateName}`
|
|
1350
1353
|
);
|
|
1351
1354
|
}
|
|
@@ -1381,13 +1384,13 @@ class at {
|
|
|
1381
1384
|
const r = h(
|
|
1382
1385
|
t.aggregate,
|
|
1383
1386
|
"CommandClient"
|
|
1384
|
-
), i =
|
|
1387
|
+
), i = F(
|
|
1385
1388
|
r,
|
|
1386
1389
|
e,
|
|
1387
1390
|
[],
|
|
1388
1391
|
["R = CommandResult"]
|
|
1389
1392
|
);
|
|
1390
|
-
|
|
1393
|
+
le(i, this.defaultCommandClientOptionsName), t.commands.forEach((s) => {
|
|
1391
1394
|
this.processCommandMethod(
|
|
1392
1395
|
t,
|
|
1393
1396
|
e,
|
|
@@ -1405,10 +1408,10 @@ class at {
|
|
|
1405
1408
|
t.aggregate,
|
|
1406
1409
|
"StreamCommandClient"
|
|
1407
1410
|
);
|
|
1408
|
-
|
|
1411
|
+
F(
|
|
1409
1412
|
r,
|
|
1410
1413
|
e,
|
|
1411
|
-
["''",
|
|
1414
|
+
["''", q],
|
|
1412
1415
|
[],
|
|
1413
1416
|
`${o}<CommandResultEventStream>`
|
|
1414
1417
|
).addConstructor({
|
|
@@ -1431,7 +1434,7 @@ class at {
|
|
|
1431
1434
|
e.name,
|
|
1432
1435
|
s.name
|
|
1433
1436
|
)).map((s) => {
|
|
1434
|
-
const a =
|
|
1437
|
+
const a = re(s);
|
|
1435
1438
|
return this.context.logger.info(
|
|
1436
1439
|
`Adding path parameter: ${s.name} (type: ${a})`
|
|
1437
1440
|
), {
|
|
@@ -1450,7 +1453,7 @@ class at {
|
|
|
1450
1453
|
`Adding command request parameter: commandRequest (type: CommandRequest<${r.name}>)`
|
|
1451
1454
|
), i.push({
|
|
1452
1455
|
name: "commandRequest",
|
|
1453
|
-
hasQuestionToken:
|
|
1456
|
+
hasQuestionToken: we(o.schema.schema),
|
|
1454
1457
|
type: `CommandRequest<${r.name}>`,
|
|
1455
1458
|
decorators: [
|
|
1456
1459
|
{
|
|
@@ -1486,7 +1489,7 @@ class at {
|
|
|
1486
1489
|
name: f(r.name),
|
|
1487
1490
|
decorators: [
|
|
1488
1491
|
{
|
|
1489
|
-
name:
|
|
1492
|
+
name: j(r.method),
|
|
1490
1493
|
arguments: [`${this.getEndpointPath(i, r)}`]
|
|
1491
1494
|
}
|
|
1492
1495
|
],
|
|
@@ -1506,7 +1509,7 @@ class at {
|
|
|
1506
1509
|
);
|
|
1507
1510
|
}
|
|
1508
1511
|
}
|
|
1509
|
-
class
|
|
1512
|
+
class gt {
|
|
1510
1513
|
/**
|
|
1511
1514
|
* Creates a new QueryClientGenerator instance.
|
|
1512
1515
|
* @param context - The generation context containing OpenAPI spec and project details
|
|
@@ -1545,7 +1548,7 @@ class ct {
|
|
|
1545
1548
|
* @returns The source file for the client
|
|
1546
1549
|
*/
|
|
1547
1550
|
createClientFilePath(e, t) {
|
|
1548
|
-
return
|
|
1551
|
+
return me(
|
|
1549
1552
|
this.context.project,
|
|
1550
1553
|
this.context.outputDir,
|
|
1551
1554
|
e,
|
|
@@ -1583,9 +1586,9 @@ class ct {
|
|
|
1583
1586
|
name: o,
|
|
1584
1587
|
type: "QueryClientOptions",
|
|
1585
1588
|
initializer: `{
|
|
1586
|
-
contextAlias:
|
|
1589
|
+
contextAlias: ${w(e.aggregate.contextAlias)},
|
|
1587
1590
|
aggregateName: '${e.aggregate.aggregateName}',
|
|
1588
|
-
resourceAttribution: ${
|
|
1591
|
+
resourceAttribution: ${rt(e)},
|
|
1589
1592
|
}`
|
|
1590
1593
|
}
|
|
1591
1594
|
],
|
|
@@ -1641,13 +1644,13 @@ class ct {
|
|
|
1641
1644
|
});
|
|
1642
1645
|
}
|
|
1643
1646
|
}
|
|
1644
|
-
class
|
|
1647
|
+
class pt {
|
|
1645
1648
|
/**
|
|
1646
1649
|
* Creates a new ClientGenerator instance.
|
|
1647
1650
|
* @param context - The generation context containing OpenAPI spec and project details
|
|
1648
1651
|
*/
|
|
1649
1652
|
constructor(e) {
|
|
1650
|
-
this.context = e, this.queryClientGenerator = new
|
|
1653
|
+
this.context = e, this.queryClientGenerator = new gt(e), this.commandClientGenerator = new ct(e), this.apiClientGenerator = new at(e);
|
|
1651
1654
|
}
|
|
1652
1655
|
queryClientGenerator;
|
|
1653
1656
|
commandClientGenerator;
|
|
@@ -1670,7 +1673,7 @@ class gt {
|
|
|
1670
1673
|
this.queryClientGenerator.generate(), this.commandClientGenerator.generate(), this.apiClientGenerator.generate(), this.context.logger.success("Client generation completed");
|
|
1671
1674
|
}
|
|
1672
1675
|
}
|
|
1673
|
-
class
|
|
1676
|
+
class ut {
|
|
1674
1677
|
/** The ts-morph project instance used for code generation */
|
|
1675
1678
|
project;
|
|
1676
1679
|
/** The OpenAPI specification object */
|
|
@@ -1688,7 +1691,7 @@ class pt {
|
|
|
1688
1691
|
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"];
|
|
1689
1692
|
}
|
|
1690
1693
|
getOrCreateSourceFile(e) {
|
|
1691
|
-
return
|
|
1694
|
+
return ce(this.project, this.outputDir, e);
|
|
1692
1695
|
}
|
|
1693
1696
|
isIgnoreApiClientPathParameters(e, t) {
|
|
1694
1697
|
return (this.config.apiClients?.[e]?.ignorePathParameters ?? this.defaultIgnorePathParameters).includes(t);
|
|
@@ -1697,8 +1700,8 @@ class pt {
|
|
|
1697
1700
|
return this.defaultIgnorePathParameters.includes(t);
|
|
1698
1701
|
}
|
|
1699
1702
|
}
|
|
1700
|
-
const
|
|
1701
|
-
class
|
|
1703
|
+
const lt = "./fetcher-generator.config.json";
|
|
1704
|
+
class At {
|
|
1702
1705
|
/**
|
|
1703
1706
|
* Creates a new CodeGenerator instance with the specified options.
|
|
1704
1707
|
*
|
|
@@ -1706,7 +1709,7 @@ class xt {
|
|
|
1706
1709
|
* @throws Error if the project initialization fails due to invalid TypeScript configuration or missing files.
|
|
1707
1710
|
*/
|
|
1708
1711
|
constructor(e) {
|
|
1709
|
-
this.options = e, this.project = new
|
|
1712
|
+
this.options = e, this.project = new ye(e), this.options.logger.info(
|
|
1710
1713
|
`Project instance created with tsConfigFilePath: ${this.options.tsConfigFilePath}`
|
|
1711
1714
|
);
|
|
1712
1715
|
}
|
|
@@ -1734,20 +1737,20 @@ class xt {
|
|
|
1734
1737
|
this.options.logger.info(
|
|
1735
1738
|
"Starting code generation from OpenAPI specification"
|
|
1736
1739
|
), 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");
|
|
1737
|
-
const e = await
|
|
1740
|
+
const e = await Fe(this.options.inputPath);
|
|
1738
1741
|
this.options.logger.info("OpenAPI specification parsed successfully"), this.options.logger.info("Resolving bounded context aggregates");
|
|
1739
|
-
const o = new
|
|
1742
|
+
const o = new Ke(e).resolve();
|
|
1740
1743
|
this.options.logger.info(
|
|
1741
1744
|
`Resolved ${o.size} bounded context aggregates`
|
|
1742
1745
|
);
|
|
1743
|
-
const r = this.options.configPath ??
|
|
1746
|
+
const r = this.options.configPath ?? lt;
|
|
1744
1747
|
let i = {};
|
|
1745
1748
|
try {
|
|
1746
|
-
this.options.logger.info(`Parsing configuration file: ${r}`), i = await
|
|
1749
|
+
this.options.logger.info(`Parsing configuration file: ${r}`), i = await je(r);
|
|
1747
1750
|
} catch (p) {
|
|
1748
1751
|
this.options.logger.info(`Configuration file parsing failed: ${p}`);
|
|
1749
1752
|
}
|
|
1750
|
-
const s = new
|
|
1753
|
+
const s = new ut({
|
|
1751
1754
|
openAPI: e,
|
|
1752
1755
|
project: this.project,
|
|
1753
1756
|
outputDir: this.options.outputDir,
|
|
@@ -1755,7 +1758,7 @@ class xt {
|
|
|
1755
1758
|
logger: this.options.logger,
|
|
1756
1759
|
config: i
|
|
1757
1760
|
});
|
|
1758
|
-
this.options.logger.info("Generating models"), new
|
|
1761
|
+
this.options.logger.info("Generating models"), new Ze(s).generate(), this.options.logger.info("Models generated successfully"), this.options.logger.info("Generating clients"), new pt(s).generate(), this.options.logger.info("Clients generated successfully");
|
|
1759
1762
|
const u = this.project.getDirectory(this.options.outputDir);
|
|
1760
1763
|
if (!u) {
|
|
1761
1764
|
this.options.logger.info("Output directory not found.");
|
|
@@ -1852,7 +1855,7 @@ class xt {
|
|
|
1852
1855
|
}
|
|
1853
1856
|
}
|
|
1854
1857
|
export {
|
|
1855
|
-
|
|
1856
|
-
|
|
1858
|
+
At as CodeGenerator,
|
|
1859
|
+
lt as DEFAULT_CONFIG_PATH
|
|
1857
1860
|
};
|
|
1858
1861
|
//# sourceMappingURL=index.js.map
|