@ahoo-wang/fetcher-generator 3.2.0 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +2 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +3 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +13 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +473 -467
- package/dist/index.js.map +1 -1
- package/dist/model/typeGenerator.d.ts.map +1 -1
- package/dist/utils/naming.d.ts +2 -0
- package/dist/utils/naming.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,126 +1,132 @@
|
|
|
1
|
-
import { Scope as
|
|
1
|
+
import { Scope as ye, VariableDeclarationKind as D, Project as xe } from "ts-morph";
|
|
2
2
|
import { ContentTypeValues as I, combineURLs as E } from "@ahoo-wang/fetcher";
|
|
3
|
-
import { ResourceAttributionPathSpec as
|
|
4
|
-
import { parse as
|
|
5
|
-
import { readFile as
|
|
6
|
-
import { join as
|
|
7
|
-
function P(
|
|
8
|
-
return
|
|
9
|
-
}
|
|
10
|
-
function S(
|
|
11
|
-
const t = P(
|
|
3
|
+
import { ResourceAttributionPathSpec as L } from "@ahoo-wang/fetcher-wow";
|
|
4
|
+
import { parse as K } from "yaml";
|
|
5
|
+
import { readFile as Ae } from "fs";
|
|
6
|
+
import { join as Ce, relative as Pe } from "path";
|
|
7
|
+
function P(n) {
|
|
8
|
+
return n.$ref.split("/").pop();
|
|
9
|
+
}
|
|
10
|
+
function S(n, e) {
|
|
11
|
+
const t = P(n);
|
|
12
12
|
return e.schemas?.[t];
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
const t = P(
|
|
14
|
+
function Y(n, e) {
|
|
15
|
+
const t = P(n);
|
|
16
16
|
return e.requestBodies?.[t];
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
const t = P(
|
|
18
|
+
function Z(n, e) {
|
|
19
|
+
const t = P(n);
|
|
20
20
|
return e.parameters?.[t];
|
|
21
21
|
}
|
|
22
|
-
function $(
|
|
22
|
+
function $(n, e) {
|
|
23
23
|
return {
|
|
24
|
-
key: P(
|
|
25
|
-
schema: S(
|
|
24
|
+
key: P(n),
|
|
25
|
+
schema: S(n, e)
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
function
|
|
30
|
-
return
|
|
28
|
+
const $e = /[-_'\s.]+/;
|
|
29
|
+
function O(n) {
|
|
30
|
+
return n.split($e);
|
|
31
31
|
}
|
|
32
|
-
function X(
|
|
33
|
-
return Array.isArray(
|
|
32
|
+
function X(n) {
|
|
33
|
+
return Array.isArray(n) ? n.flatMap((e) => B(O(e))) : B(O(n));
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
return
|
|
35
|
+
function B(n) {
|
|
36
|
+
return n.flatMap((e) => {
|
|
37
37
|
if (e.length === 0)
|
|
38
38
|
return [];
|
|
39
39
|
const t = [];
|
|
40
|
-
let
|
|
40
|
+
let o = "";
|
|
41
41
|
for (let r = 0; r < e.length; r++) {
|
|
42
42
|
const i = e[r], s = /[A-Z]/.test(i), a = r > 0 && /[a-z]/.test(e[r - 1]);
|
|
43
|
-
s && a &&
|
|
43
|
+
s && a && o ? (t.push(o), o = i) : o += i;
|
|
44
44
|
}
|
|
45
|
-
return
|
|
45
|
+
return o && t.push(o), t;
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
function R(
|
|
49
|
-
return
|
|
50
|
-
const
|
|
51
|
-
return (/[a-zA-Z]/.test(
|
|
48
|
+
function R(n) {
|
|
49
|
+
return n === "" || n.length === 0 ? "" : X(n).filter((t) => t.length > 0).map((t) => {
|
|
50
|
+
const o = t.charAt(0), r = t.slice(1);
|
|
51
|
+
return (/[a-zA-Z]/.test(o) ? o.toUpperCase() : o) + r.toLowerCase();
|
|
52
52
|
}).join("");
|
|
53
53
|
}
|
|
54
|
-
function f(
|
|
55
|
-
const e = R(
|
|
54
|
+
function f(n) {
|
|
55
|
+
const e = R(n);
|
|
56
56
|
return e.charAt(0).toLowerCase() + e.slice(1);
|
|
57
57
|
}
|
|
58
|
-
function
|
|
59
|
-
return
|
|
58
|
+
function ee(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
|
-
function
|
|
62
|
-
return
|
|
61
|
+
function M(n) {
|
|
62
|
+
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(n) ? n : `'${n}'`;
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function Te(n) {
|
|
65
|
+
return /^\d+$/.test(n) ? `NUM_${n}` : M(ee(n));
|
|
66
|
+
}
|
|
67
|
+
function g(n) {
|
|
68
|
+
return !!(n && typeof n == "object" && "$ref" in n);
|
|
69
|
+
}
|
|
70
|
+
function G(n, e) {
|
|
65
71
|
if (e && !g(e) && e.content)
|
|
66
|
-
return e.content[
|
|
72
|
+
return e.content[n]?.schema;
|
|
67
73
|
}
|
|
68
|
-
function
|
|
69
|
-
return G(I.APPLICATION_JSON,
|
|
74
|
+
function te(n) {
|
|
75
|
+
return G(I.APPLICATION_JSON, n);
|
|
70
76
|
}
|
|
71
|
-
function
|
|
72
|
-
return G(I.TEXT_EVENT_STREAM,
|
|
77
|
+
function ve(n) {
|
|
78
|
+
return G(I.TEXT_EVENT_STREAM, n);
|
|
73
79
|
}
|
|
74
|
-
function
|
|
75
|
-
return G("*/*",
|
|
80
|
+
function Ie(n) {
|
|
81
|
+
return G("*/*", n);
|
|
76
82
|
}
|
|
77
|
-
const
|
|
83
|
+
const Ee = [
|
|
78
84
|
"string",
|
|
79
85
|
"number",
|
|
80
86
|
"integer",
|
|
81
87
|
"boolean",
|
|
82
88
|
"null"
|
|
83
89
|
];
|
|
84
|
-
function
|
|
85
|
-
return Array.isArray(
|
|
90
|
+
function ne(n) {
|
|
91
|
+
return Array.isArray(n) ? !0 : Ee.includes(n);
|
|
86
92
|
}
|
|
87
|
-
function
|
|
88
|
-
return Array.isArray(
|
|
93
|
+
function U(n) {
|
|
94
|
+
return Array.isArray(n.enum) && n.enum.length > 0;
|
|
89
95
|
}
|
|
90
|
-
function T(
|
|
91
|
-
return
|
|
96
|
+
function T(n) {
|
|
97
|
+
return n.type === "object" && !!n.properties;
|
|
92
98
|
}
|
|
93
|
-
function
|
|
94
|
-
return
|
|
99
|
+
function b(n) {
|
|
100
|
+
return n.type === "array" && !!n.items;
|
|
95
101
|
}
|
|
96
|
-
function
|
|
97
|
-
return Array.isArray(
|
|
102
|
+
function Se(n) {
|
|
103
|
+
return Array.isArray(n.anyOf) && n.anyOf.length > 0;
|
|
98
104
|
}
|
|
99
|
-
function
|
|
100
|
-
return Array.isArray(
|
|
105
|
+
function Re(n) {
|
|
106
|
+
return Array.isArray(n.oneOf) && n.oneOf.length > 0;
|
|
101
107
|
}
|
|
102
|
-
function
|
|
103
|
-
return Array.isArray(
|
|
108
|
+
function q(n) {
|
|
109
|
+
return Array.isArray(n.allOf) && n.allOf.length > 0;
|
|
104
110
|
}
|
|
105
|
-
function J(
|
|
106
|
-
return
|
|
111
|
+
function J(n) {
|
|
112
|
+
return Se(n) || Re(n) || q(n);
|
|
107
113
|
}
|
|
108
|
-
function
|
|
109
|
-
return
|
|
114
|
+
function we(n) {
|
|
115
|
+
return n.includes("|") || n.includes("&") ? `(${n})[]` : `${n}[]`;
|
|
110
116
|
}
|
|
111
|
-
function
|
|
112
|
-
return
|
|
117
|
+
function Ne(n) {
|
|
118
|
+
return n.type === "object" && !n.properties && n.additionalProperties !== void 0;
|
|
113
119
|
}
|
|
114
|
-
function
|
|
115
|
-
return
|
|
120
|
+
function De(n) {
|
|
121
|
+
return n.type !== "object" ? !1 : n.properties ? Object.keys(n.properties).length === 0 : !0;
|
|
116
122
|
}
|
|
117
|
-
function
|
|
118
|
-
return
|
|
123
|
+
function Oe(n) {
|
|
124
|
+
return n.readOnly === !0;
|
|
119
125
|
}
|
|
120
|
-
function w(
|
|
121
|
-
if (Array.isArray(
|
|
122
|
-
return
|
|
123
|
-
switch (
|
|
126
|
+
function w(n) {
|
|
127
|
+
if (Array.isArray(n))
|
|
128
|
+
return n.map((e) => w(e)).join(" | ");
|
|
129
|
+
switch (n) {
|
|
124
130
|
case "string":
|
|
125
131
|
return "string";
|
|
126
132
|
case "number":
|
|
@@ -134,92 +140,92 @@ function w(o) {
|
|
|
134
140
|
return "any";
|
|
135
141
|
}
|
|
136
142
|
}
|
|
137
|
-
function
|
|
138
|
-
if (!T(
|
|
143
|
+
function Me(n) {
|
|
144
|
+
if (!T(n))
|
|
139
145
|
return [];
|
|
140
|
-
const e =
|
|
141
|
-
return Object.keys(
|
|
146
|
+
const e = n.required || [];
|
|
147
|
+
return Object.keys(n.properties).filter((t) => !e.includes(t));
|
|
142
148
|
}
|
|
143
|
-
function
|
|
144
|
-
return
|
|
149
|
+
function be(n, e) {
|
|
150
|
+
return n.operation.operationId && e.operation.operationId ? n.operation.operationId.localeCompare(
|
|
145
151
|
e.operation.operationId
|
|
146
|
-
) :
|
|
152
|
+
) : n.path && e.path ? n.path.localeCompare(e.path) : n.method && e.method ? n.method.localeCompare(e.method) : 0;
|
|
147
153
|
}
|
|
148
|
-
function
|
|
154
|
+
function oe(n) {
|
|
149
155
|
const e = [];
|
|
150
|
-
for (const [t,
|
|
151
|
-
|
|
156
|
+
for (const [t, o] of Object.entries(n))
|
|
157
|
+
re(o).forEach((r) => {
|
|
152
158
|
e.push({
|
|
153
159
|
method: r.method,
|
|
154
160
|
operation: r.operation,
|
|
155
161
|
path: t
|
|
156
162
|
});
|
|
157
163
|
});
|
|
158
|
-
return e.sort(
|
|
164
|
+
return e.sort(be);
|
|
159
165
|
}
|
|
160
|
-
function
|
|
166
|
+
function re(n) {
|
|
161
167
|
return [
|
|
162
|
-
{ method: "get", operation:
|
|
163
|
-
{ method: "put", operation:
|
|
164
|
-
{ method: "post", operation:
|
|
165
|
-
{ method: "delete", operation:
|
|
166
|
-
{ method: "options", operation:
|
|
167
|
-
{ method: "head", operation:
|
|
168
|
-
{ method: "patch", operation:
|
|
169
|
-
{ method: "trace", operation:
|
|
168
|
+
{ method: "get", operation: n.get },
|
|
169
|
+
{ method: "put", operation: n.put },
|
|
170
|
+
{ method: "post", operation: n.post },
|
|
171
|
+
{ method: "delete", operation: n.delete },
|
|
172
|
+
{ method: "options", operation: n.options },
|
|
173
|
+
{ method: "head", operation: n.head },
|
|
174
|
+
{ method: "patch", operation: n.patch },
|
|
175
|
+
{ method: "trace", operation: n.trace }
|
|
170
176
|
].filter(({ operation: e }) => e !== void 0);
|
|
171
177
|
}
|
|
172
|
-
function
|
|
173
|
-
return
|
|
178
|
+
function W(n) {
|
|
179
|
+
return n.responses[200];
|
|
174
180
|
}
|
|
175
|
-
function
|
|
176
|
-
const e =
|
|
177
|
-
return
|
|
181
|
+
function Q(n) {
|
|
182
|
+
const e = W(n);
|
|
183
|
+
return te(e);
|
|
178
184
|
}
|
|
179
|
-
function
|
|
180
|
-
return
|
|
185
|
+
function qe(n, e) {
|
|
186
|
+
return n.parameters ? n.parameters.map((t) => g(t) ? Z(t, e) : t).filter((t) => t.in === "path") : [];
|
|
181
187
|
}
|
|
182
|
-
const
|
|
183
|
-
function
|
|
184
|
-
return !
|
|
188
|
+
const Fe = "string";
|
|
189
|
+
function ie(n) {
|
|
190
|
+
return !n.schema || g(n.schema) || !n.schema.type || !ne(n.schema.type) ? Fe : w(n.schema.type);
|
|
185
191
|
}
|
|
186
|
-
function
|
|
187
|
-
return
|
|
192
|
+
function se(n) {
|
|
193
|
+
return n.startsWith("http://") || n.startsWith("https://") ? je(n) : _e(n);
|
|
188
194
|
}
|
|
189
|
-
async function
|
|
190
|
-
return await (await fetch(
|
|
195
|
+
async function je(n) {
|
|
196
|
+
return await (await fetch(n)).text();
|
|
191
197
|
}
|
|
192
|
-
function
|
|
198
|
+
function _e(n) {
|
|
193
199
|
return new Promise((e, t) => {
|
|
194
|
-
|
|
195
|
-
|
|
200
|
+
Ae(n, "utf-8", (o, r) => {
|
|
201
|
+
o ? t(o) : e(r);
|
|
196
202
|
});
|
|
197
203
|
});
|
|
198
204
|
}
|
|
199
|
-
async function
|
|
200
|
-
const e = await
|
|
201
|
-
switch (
|
|
205
|
+
async function Ge(n) {
|
|
206
|
+
const e = await se(n);
|
|
207
|
+
switch (ae(e)) {
|
|
202
208
|
case "json":
|
|
203
209
|
return JSON.parse(e);
|
|
204
210
|
case "yaml":
|
|
205
|
-
return
|
|
211
|
+
return K(e);
|
|
206
212
|
default:
|
|
207
|
-
throw new Error(`Unsupported file format: ${
|
|
213
|
+
throw new Error(`Unsupported file format: ${n}`);
|
|
208
214
|
}
|
|
209
215
|
}
|
|
210
|
-
async function
|
|
211
|
-
const e = await
|
|
212
|
-
switch (
|
|
216
|
+
async function We(n) {
|
|
217
|
+
const e = await se(n);
|
|
218
|
+
switch (ae(e)) {
|
|
213
219
|
case "json":
|
|
214
220
|
return JSON.parse(e);
|
|
215
221
|
case "yaml":
|
|
216
|
-
return
|
|
222
|
+
return K(e);
|
|
217
223
|
default:
|
|
218
|
-
throw new Error(`Unsupported file format: ${
|
|
224
|
+
throw new Error(`Unsupported file format: ${n}`);
|
|
219
225
|
}
|
|
220
226
|
}
|
|
221
|
-
function
|
|
222
|
-
const e =
|
|
227
|
+
function ae(n) {
|
|
228
|
+
const e = n.trimStart();
|
|
223
229
|
if (e.startsWith("{") || e.startsWith("["))
|
|
224
230
|
return "json";
|
|
225
231
|
if (e.startsWith("-") || e.startsWith("%YAML"))
|
|
@@ -232,136 +238,136 @@ function se(o) {
|
|
|
232
238
|
}
|
|
233
239
|
throw new Error("Unable to infer file format");
|
|
234
240
|
}
|
|
235
|
-
const
|
|
236
|
-
function
|
|
237
|
-
return E(
|
|
241
|
+
const ce = "types.ts", ke = "@";
|
|
242
|
+
function ze(n) {
|
|
243
|
+
return E(n.path, ce);
|
|
238
244
|
}
|
|
239
|
-
function
|
|
240
|
-
const
|
|
241
|
-
return r ||
|
|
245
|
+
function ge(n, e, t) {
|
|
246
|
+
const o = E(e, t), r = n.getSourceFile(o);
|
|
247
|
+
return r || n.createSourceFile(o, "", {
|
|
242
248
|
overwrite: !0
|
|
243
249
|
});
|
|
244
250
|
}
|
|
245
|
-
function A(
|
|
246
|
-
let
|
|
251
|
+
function A(n, e, t) {
|
|
252
|
+
let o = n.getImportDeclaration(
|
|
247
253
|
(r) => r.getModuleSpecifierValue() === e
|
|
248
254
|
);
|
|
249
|
-
|
|
255
|
+
o || (o = n.addImportDeclaration({
|
|
250
256
|
moduleSpecifier: e
|
|
251
257
|
})), t.forEach((r) => {
|
|
252
|
-
|
|
258
|
+
o.getNamedImports().some(
|
|
253
259
|
(s) => s.getName() === r
|
|
254
|
-
) ||
|
|
260
|
+
) || o.addNamedImport(r);
|
|
255
261
|
});
|
|
256
262
|
}
|
|
257
|
-
function d(
|
|
258
|
-
if (t.path.startsWith(
|
|
259
|
-
A(
|
|
263
|
+
function d(n, e, t) {
|
|
264
|
+
if (t.path.startsWith(ke)) {
|
|
265
|
+
A(n, t.path, [t.name]);
|
|
260
266
|
return;
|
|
261
267
|
}
|
|
262
|
-
const
|
|
263
|
-
let i =
|
|
264
|
-
i = i.replace(/\.ts$/, ""), i.startsWith(".") || (i = "./" + i), A(
|
|
268
|
+
const o = n.getDirectoryPath(), r = Ce(e, t.path, ce);
|
|
269
|
+
let i = Pe(o, r);
|
|
270
|
+
i = i.replace(/\.ts$/, ""), i.startsWith(".") || (i = "./" + i), A(n, i, [t.name]);
|
|
265
271
|
}
|
|
266
|
-
function
|
|
267
|
-
|
|
272
|
+
function Le(n, e, t, o) {
|
|
273
|
+
n.path !== o.path && d(e, t, o);
|
|
268
274
|
}
|
|
269
|
-
function
|
|
275
|
+
function pe(n, e = `
|
|
270
276
|
`) {
|
|
271
|
-
if (!Array.isArray(
|
|
277
|
+
if (!Array.isArray(n))
|
|
272
278
|
return;
|
|
273
|
-
const t =
|
|
274
|
-
(
|
|
279
|
+
const t = n.filter(
|
|
280
|
+
(o) => typeof o == "string" && o.length > 0
|
|
275
281
|
);
|
|
276
282
|
return t.length > 0 ? t.join(e) : void 0;
|
|
277
283
|
}
|
|
278
|
-
function C(
|
|
279
|
-
const t =
|
|
280
|
-
t &&
|
|
284
|
+
function C(n, e) {
|
|
285
|
+
const t = pe(e);
|
|
286
|
+
t && n.addJsDoc(t);
|
|
281
287
|
}
|
|
282
|
-
function
|
|
288
|
+
function k(n, e) {
|
|
283
289
|
const t = [
|
|
284
|
-
|
|
285
|
-
|
|
290
|
+
n.title,
|
|
291
|
+
n.description
|
|
286
292
|
];
|
|
287
|
-
return e && t.push(`- key: ${e}`),
|
|
293
|
+
return e && t.push(`- key: ${e}`), n.format && t.push(`- format: ${n.format}`), V(t, n, "default"), V(t, n, "example"), Je(t, n), Qe(t, n), Ve(t, n), t;
|
|
288
294
|
}
|
|
289
|
-
function
|
|
290
|
-
const
|
|
291
|
-
C(
|
|
295
|
+
function Be(n, e, t) {
|
|
296
|
+
const o = k(e, t);
|
|
297
|
+
C(n, o);
|
|
292
298
|
}
|
|
293
|
-
function
|
|
294
|
-
const
|
|
295
|
-
|
|
299
|
+
function Ue(n, e, t) {
|
|
300
|
+
const o = k(e, t);
|
|
301
|
+
ue(o, "schema", e), C(n, o);
|
|
296
302
|
}
|
|
297
|
-
function
|
|
298
|
-
const
|
|
299
|
-
if (
|
|
300
|
-
if (typeof
|
|
301
|
-
|
|
303
|
+
function V(n, e, t) {
|
|
304
|
+
const o = e[t];
|
|
305
|
+
if (o) {
|
|
306
|
+
if (typeof o != "object") {
|
|
307
|
+
n.push(`- ${t}: \`${o}\``);
|
|
302
308
|
return;
|
|
303
309
|
}
|
|
304
|
-
|
|
310
|
+
ue(n, t, o);
|
|
305
311
|
}
|
|
306
312
|
}
|
|
307
|
-
function
|
|
308
|
-
|
|
313
|
+
function ue(n, e, t) {
|
|
314
|
+
n.push(`- ${e}: `), n.push("```json"), n.push(JSON.stringify(t, null, 2)), n.push("```");
|
|
309
315
|
}
|
|
310
|
-
function
|
|
316
|
+
function Je(n, e) {
|
|
311
317
|
const t = ["- Numeric Constraints"];
|
|
312
318
|
e.minimum !== void 0 && t.push(` - minimum: ${e.minimum}`), e.maximum !== void 0 && t.push(` - maximum: ${e.maximum}`), e.exclusiveMinimum !== void 0 && t.push(
|
|
313
319
|
` - exclusiveMinimum: ${e.exclusiveMinimum}`
|
|
314
320
|
), e.exclusiveMaximum !== void 0 && t.push(
|
|
315
321
|
` - exclusiveMaximum: ${e.exclusiveMaximum}`
|
|
316
|
-
), e.multipleOf !== void 0 && t.push(` - multipleOf: ${e.multipleOf}`), t.length !== 1 &&
|
|
322
|
+
), e.multipleOf !== void 0 && t.push(` - multipleOf: ${e.multipleOf}`), t.length !== 1 && n.push(...t);
|
|
317
323
|
}
|
|
318
|
-
function
|
|
324
|
+
function Qe(n, e) {
|
|
319
325
|
const t = ["- String Constraints"];
|
|
320
|
-
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 &&
|
|
326
|
+
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);
|
|
321
327
|
}
|
|
322
|
-
function
|
|
328
|
+
function Ve(n, e) {
|
|
323
329
|
const t = ["- Array Constraints"];
|
|
324
|
-
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 &&
|
|
330
|
+
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);
|
|
325
331
|
}
|
|
326
|
-
function
|
|
327
|
-
const e =
|
|
332
|
+
function He(n) {
|
|
333
|
+
const e = n.split(".");
|
|
328
334
|
return e.length != 2 || e[0].length === 0 || e[1].length === 0 ? null : e;
|
|
329
335
|
}
|
|
330
|
-
function
|
|
331
|
-
const e =
|
|
336
|
+
function Ke(n) {
|
|
337
|
+
const e = He(n.name);
|
|
332
338
|
return e ? {
|
|
333
|
-
tag:
|
|
339
|
+
tag: n,
|
|
334
340
|
contextAlias: e[0],
|
|
335
341
|
aggregateName: e[1]
|
|
336
342
|
} : null;
|
|
337
343
|
}
|
|
338
|
-
function
|
|
339
|
-
const e =
|
|
344
|
+
function Ye(n) {
|
|
345
|
+
const e = n?.map((o) => Ke(o)).filter((o) => o !== null);
|
|
340
346
|
if (!e)
|
|
341
347
|
return /* @__PURE__ */ new Map();
|
|
342
348
|
const t = /* @__PURE__ */ new Map();
|
|
343
|
-
return e.forEach((
|
|
344
|
-
t.set(
|
|
345
|
-
aggregate:
|
|
349
|
+
return e.forEach((o) => {
|
|
350
|
+
t.set(o.tag.name, {
|
|
351
|
+
aggregate: o,
|
|
346
352
|
commands: /* @__PURE__ */ new Map(),
|
|
347
353
|
events: /* @__PURE__ */ new Map()
|
|
348
354
|
});
|
|
349
355
|
}), t;
|
|
350
356
|
}
|
|
351
|
-
function
|
|
352
|
-
if (!
|
|
357
|
+
function Ze(n) {
|
|
358
|
+
if (!n)
|
|
353
359
|
return null;
|
|
354
|
-
const e =
|
|
360
|
+
const e = n.split(".");
|
|
355
361
|
return e.length != 3 ? null : e[2];
|
|
356
362
|
}
|
|
357
|
-
const
|
|
358
|
-
class
|
|
363
|
+
const Xe = "#/components/responses/wow.CommandOk", et = "#/components/parameters/wow.id";
|
|
364
|
+
class tt {
|
|
359
365
|
/**
|
|
360
366
|
* Creates a new AggregateResolver instance.
|
|
361
367
|
* @param openAPI - The OpenAPI specification to resolve aggregates from
|
|
362
368
|
*/
|
|
363
369
|
constructor(e) {
|
|
364
|
-
this.openAPI = e, this.aggregates =
|
|
370
|
+
this.openAPI = e, this.aggregates = Ye(e.tags), this.build();
|
|
365
371
|
}
|
|
366
372
|
aggregates;
|
|
367
373
|
/**
|
|
@@ -369,7 +375,7 @@ class Ze {
|
|
|
369
375
|
* @private
|
|
370
376
|
*/
|
|
371
377
|
build() {
|
|
372
|
-
const e =
|
|
378
|
+
const e = oe(this.openAPI.paths);
|
|
373
379
|
for (const t of e)
|
|
374
380
|
this.commands(t.path, t), this.state(t.operation), this.events(t.operation), this.fields(t.operation);
|
|
375
381
|
}
|
|
@@ -382,9 +388,9 @@ class Ze {
|
|
|
382
388
|
for (const t of this.aggregates.values()) {
|
|
383
389
|
if (!t.state || !t.fields)
|
|
384
390
|
continue;
|
|
385
|
-
const
|
|
386
|
-
let r = e.get(
|
|
387
|
-
r || (r = /* @__PURE__ */ new Set(), e.set(
|
|
391
|
+
const o = t.aggregate.contextAlias;
|
|
392
|
+
let r = e.get(o);
|
|
393
|
+
r || (r = /* @__PURE__ */ new Set(), e.set(o, r)), r.add(t);
|
|
388
394
|
}
|
|
389
395
|
return e;
|
|
390
396
|
}
|
|
@@ -394,43 +400,43 @@ class Ze {
|
|
|
394
400
|
* @param methodOperation - The HTTP method and operation details
|
|
395
401
|
*/
|
|
396
402
|
commands(e, t) {
|
|
397
|
-
const
|
|
398
|
-
if (
|
|
403
|
+
const o = t.operation;
|
|
404
|
+
if (o.operationId === "wow.command.send")
|
|
399
405
|
return;
|
|
400
|
-
const r =
|
|
406
|
+
const r = Ze(o.operationId);
|
|
401
407
|
if (!r)
|
|
402
408
|
return;
|
|
403
|
-
const i =
|
|
404
|
-
if (!i || !g(i) || i.$ref !==
|
|
409
|
+
const i = W(o);
|
|
410
|
+
if (!i || !g(i) || i.$ref !== Xe || !o.requestBody)
|
|
405
411
|
return;
|
|
406
|
-
const s =
|
|
412
|
+
const s = o.parameters ?? [], a = s.filter((l) => g(l) && l.$ref === et).at(0), c = s.filter(
|
|
407
413
|
(l) => !g(l) && l.in === "path"
|
|
408
414
|
);
|
|
409
415
|
if (a) {
|
|
410
|
-
const l =
|
|
416
|
+
const l = Z(
|
|
411
417
|
a,
|
|
412
418
|
this.openAPI.components
|
|
413
419
|
);
|
|
414
420
|
c.push(l);
|
|
415
421
|
}
|
|
416
|
-
const p =
|
|
422
|
+
const p = o.requestBody.content[I.APPLICATION_JSON].schema, x = $(
|
|
417
423
|
p,
|
|
418
424
|
this.openAPI.components
|
|
419
425
|
);
|
|
420
|
-
x.schema.title = x.schema.title ||
|
|
421
|
-
const
|
|
426
|
+
x.schema.title = x.schema.title || o.summary, x.schema.description = x.schema.description || o.description;
|
|
427
|
+
const he = {
|
|
422
428
|
name: r,
|
|
423
429
|
method: t.method,
|
|
424
430
|
path: e,
|
|
425
431
|
pathParameters: c,
|
|
426
|
-
summary:
|
|
427
|
-
description:
|
|
432
|
+
summary: o.summary,
|
|
433
|
+
description: o.description,
|
|
428
434
|
schema: x,
|
|
429
|
-
operation:
|
|
435
|
+
operation: o
|
|
430
436
|
};
|
|
431
|
-
|
|
432
|
-
const
|
|
433
|
-
|
|
437
|
+
o.tags?.forEach((l) => {
|
|
438
|
+
const z = this.aggregates.get(l);
|
|
439
|
+
z && z.commands.set(r, he);
|
|
434
440
|
});
|
|
435
441
|
}
|
|
436
442
|
/**
|
|
@@ -440,16 +446,16 @@ class Ze {
|
|
|
440
446
|
state(e) {
|
|
441
447
|
if (!e.operationId?.endsWith(".snapshot_state.single"))
|
|
442
448
|
return;
|
|
443
|
-
const t =
|
|
449
|
+
const t = Q(e);
|
|
444
450
|
if (!g(t))
|
|
445
451
|
return;
|
|
446
|
-
const
|
|
452
|
+
const o = $(
|
|
447
453
|
t,
|
|
448
454
|
this.openAPI.components
|
|
449
455
|
);
|
|
450
456
|
e.tags?.forEach((r) => {
|
|
451
457
|
const i = this.aggregates.get(r);
|
|
452
|
-
i && (i.state =
|
|
458
|
+
i && (i.state = o);
|
|
453
459
|
});
|
|
454
460
|
}
|
|
455
461
|
/**
|
|
@@ -459,14 +465,14 @@ class Ze {
|
|
|
459
465
|
events(e) {
|
|
460
466
|
if (!this.openAPI.components || !e.operationId?.endsWith(".event.list_query"))
|
|
461
467
|
return;
|
|
462
|
-
const t =
|
|
468
|
+
const t = Q(e);
|
|
463
469
|
if (g(t))
|
|
464
470
|
return;
|
|
465
|
-
const
|
|
466
|
-
if (!g(
|
|
471
|
+
const o = t?.items;
|
|
472
|
+
if (!g(o))
|
|
467
473
|
return;
|
|
468
474
|
const i = S(
|
|
469
|
-
|
|
475
|
+
o,
|
|
470
476
|
this.openAPI.components
|
|
471
477
|
).properties.body.items.anyOf.map((s) => {
|
|
472
478
|
const a = s.title, c = s.properties.name.const, u = s.properties.body, p = $(
|
|
@@ -493,11 +499,11 @@ class Ze {
|
|
|
493
499
|
fields(e) {
|
|
494
500
|
if (!this.openAPI.components || !e.operationId?.endsWith(".snapshot.count"))
|
|
495
501
|
return;
|
|
496
|
-
const
|
|
502
|
+
const o = Y(
|
|
497
503
|
e.requestBody,
|
|
498
504
|
this.openAPI.components
|
|
499
505
|
).content[I.APPLICATION_JSON].schema, i = S(
|
|
500
|
-
|
|
506
|
+
o,
|
|
501
507
|
this.openAPI.components
|
|
502
508
|
).properties?.field, s = $(i, this.openAPI.components);
|
|
503
509
|
e.tags?.forEach((a) => {
|
|
@@ -506,7 +512,7 @@ class Ze {
|
|
|
506
512
|
});
|
|
507
513
|
}
|
|
508
514
|
}
|
|
509
|
-
const y = "@ahoo-wang/fetcher-wow",
|
|
515
|
+
const y = "@ahoo-wang/fetcher-wow", nt = {
|
|
510
516
|
"wow.command.CommandResult": "CommandResult",
|
|
511
517
|
"wow.command.CommandResultArray": "CommandResultArray",
|
|
512
518
|
"wow.MessageHeaderSqlType": "MessageHeaderSqlType",
|
|
@@ -536,44 +542,44 @@ const y = "@ahoo-wang/fetcher-wow", et = {
|
|
|
536
542
|
"wow.openapi.BatchResult": "BatchResult",
|
|
537
543
|
"wow.messaging.CompensationTarget": "CompensationTarget"
|
|
538
544
|
};
|
|
539
|
-
function m(
|
|
540
|
-
if (!
|
|
545
|
+
function m(n) {
|
|
546
|
+
if (!n)
|
|
541
547
|
return { name: "", path: "/" };
|
|
542
|
-
const e =
|
|
548
|
+
const e = nt[n];
|
|
543
549
|
if (e)
|
|
544
550
|
return { name: e, path: y };
|
|
545
|
-
const t =
|
|
546
|
-
let
|
|
551
|
+
const t = n.split(".");
|
|
552
|
+
let o = -1;
|
|
547
553
|
for (let c = 0; c < t.length; c++)
|
|
548
554
|
if (t[c] && /^[A-Z]/.test(t[c])) {
|
|
549
|
-
|
|
555
|
+
o = c;
|
|
550
556
|
break;
|
|
551
557
|
}
|
|
552
|
-
const r = t.slice(0,
|
|
558
|
+
const r = t.slice(0, o), i = r.length > 0 ? `/${r.join("/")}` : "/", s = t.slice(o);
|
|
553
559
|
return { name: R(s), path: i };
|
|
554
560
|
}
|
|
555
|
-
function v(
|
|
556
|
-
const e = P(
|
|
561
|
+
function v(n) {
|
|
562
|
+
const e = P(n);
|
|
557
563
|
return m(e);
|
|
558
564
|
}
|
|
559
|
-
function
|
|
560
|
-
return `${
|
|
565
|
+
function N(n) {
|
|
566
|
+
return `${ee(n)}_BOUNDED_CONTEXT_ALIAS`;
|
|
561
567
|
}
|
|
562
|
-
class
|
|
563
|
-
constructor(e, t,
|
|
564
|
-
this.modelInfo = e, this.sourceFile = t, this.keySchema =
|
|
568
|
+
class ot {
|
|
569
|
+
constructor(e, t, o, r) {
|
|
570
|
+
this.modelInfo = e, this.sourceFile = t, this.keySchema = o, this.outputDir = r;
|
|
565
571
|
}
|
|
566
572
|
generate() {
|
|
567
573
|
const e = this.process();
|
|
568
|
-
e &&
|
|
574
|
+
e && Ue(e, this.keySchema.schema, this.keySchema.key);
|
|
569
575
|
}
|
|
570
576
|
process() {
|
|
571
577
|
const { schema: e } = this.keySchema;
|
|
572
|
-
return
|
|
578
|
+
return U(e) ? this.processEnum(e) : T(e) ? this.processInterface(e) : b(e) ? this.processArray(e) : q(e) ? this.processIntersection(e) : J(e) ? this.processComposition(e) : this.processTypeAlias(e);
|
|
573
579
|
}
|
|
574
580
|
resolveReference(e) {
|
|
575
581
|
const t = v(e);
|
|
576
|
-
return
|
|
582
|
+
return Le(
|
|
577
583
|
this.modelInfo,
|
|
578
584
|
this.sourceFile,
|
|
579
585
|
this.outputDir,
|
|
@@ -585,20 +591,20 @@ class tt {
|
|
|
585
591
|
}
|
|
586
592
|
resolvePropertyDefinitions(e) {
|
|
587
593
|
const { properties: t } = e;
|
|
588
|
-
return Object.entries(t).map(([
|
|
589
|
-
const i = this.resolveType(r);
|
|
594
|
+
return Object.entries(t).map(([o, r]) => {
|
|
595
|
+
const i = this.resolveType(r), s = M(o);
|
|
590
596
|
if (!g(r)) {
|
|
591
|
-
const
|
|
597
|
+
const a = k(r), c = pe(a, `
|
|
592
598
|
* `);
|
|
593
|
-
if (
|
|
599
|
+
if (c)
|
|
594
600
|
return `
|
|
595
601
|
/**
|
|
596
|
-
* ${
|
|
602
|
+
* ${c}
|
|
597
603
|
*/
|
|
598
|
-
${
|
|
604
|
+
${s}: ${i}
|
|
599
605
|
`;
|
|
600
606
|
}
|
|
601
|
-
return `${
|
|
607
|
+
return `${s}: ${i}`;
|
|
602
608
|
});
|
|
603
609
|
}
|
|
604
610
|
resolveObjectType(e) {
|
|
@@ -607,8 +613,8 @@ class tt {
|
|
|
607
613
|
const r = this.resolvePropertyDefinitions(e);
|
|
608
614
|
t.push(...r);
|
|
609
615
|
}
|
|
610
|
-
const
|
|
611
|
-
return
|
|
616
|
+
const o = this.resolveAdditionalProperties(e);
|
|
617
|
+
return o && t.push(o), t.length === 0 ? "Record<string, any>" : `{
|
|
612
618
|
${t.join(`;
|
|
613
619
|
`)};
|
|
614
620
|
}`;
|
|
@@ -619,19 +625,19 @@ class tt {
|
|
|
619
625
|
resolveType(e) {
|
|
620
626
|
if (g(e))
|
|
621
627
|
return this.resolveReference(e).name;
|
|
622
|
-
if (
|
|
628
|
+
if (Ne(e))
|
|
623
629
|
return `Record<string,${this.resolveMapValueType(e)}>`;
|
|
624
630
|
if (e.const)
|
|
625
631
|
return `'${e.const}'`;
|
|
626
|
-
if (
|
|
627
|
-
return e.enum.map((t) =>
|
|
632
|
+
if (U(e))
|
|
633
|
+
return e.enum.map((t) => `\`${t}\``).join(" | ");
|
|
628
634
|
if (J(e)) {
|
|
629
|
-
const
|
|
630
|
-
return `(${
|
|
635
|
+
const o = (e.oneOf || e.anyOf || e.allOf || []).map((i) => this.resolveType(i)), r = q(e) ? " & " : " | ";
|
|
636
|
+
return `(${o.join(r)})`;
|
|
631
637
|
}
|
|
632
|
-
if (
|
|
638
|
+
if (b(e)) {
|
|
633
639
|
const t = this.resolveType(e.items);
|
|
634
|
-
return
|
|
640
|
+
return we(t);
|
|
635
641
|
}
|
|
636
642
|
return e.type === "object" ? this.resolveObjectType(e) : e.type ? w(e.type) : "any";
|
|
637
643
|
}
|
|
@@ -640,26 +646,26 @@ class tt {
|
|
|
640
646
|
name: this.modelInfo.name,
|
|
641
647
|
isExported: !0,
|
|
642
648
|
members: e.enum.filter((t) => typeof t == "string" && t.length > 0).map((t) => ({
|
|
643
|
-
name:
|
|
644
|
-
initializer:
|
|
649
|
+
name: Te(t),
|
|
650
|
+
initializer: `\`${t}\``
|
|
645
651
|
}))
|
|
646
652
|
});
|
|
647
653
|
}
|
|
648
|
-
addPropertyToInterface(e, t,
|
|
649
|
-
const r = this.resolveType(
|
|
650
|
-
let
|
|
651
|
-
|
|
652
|
-
name:
|
|
654
|
+
addPropertyToInterface(e, t, o) {
|
|
655
|
+
const r = this.resolveType(o), i = M(t);
|
|
656
|
+
let s = e.getProperty(i);
|
|
657
|
+
s ? s.setType(r) : s = e.addProperty({
|
|
658
|
+
name: i,
|
|
653
659
|
type: r,
|
|
654
|
-
isReadonly:
|
|
655
|
-
}),
|
|
660
|
+
isReadonly: Oe(o)
|
|
661
|
+
}), Be(s, o);
|
|
656
662
|
}
|
|
657
663
|
processInterface(e) {
|
|
658
664
|
const t = this.sourceFile.addInterface({
|
|
659
665
|
name: this.modelInfo.name,
|
|
660
666
|
isExported: !0
|
|
661
|
-
}),
|
|
662
|
-
return Object.entries(
|
|
667
|
+
}), o = e.properties || {};
|
|
668
|
+
return Object.entries(o).forEach(([r, i]) => {
|
|
663
669
|
this.addPropertyToInterface(t, r, i);
|
|
664
670
|
}), e.additionalProperties && t.addIndexSignature({
|
|
665
671
|
keyName: "key",
|
|
@@ -689,13 +695,13 @@ class tt {
|
|
|
689
695
|
name: this.modelInfo.name,
|
|
690
696
|
isExported: !0
|
|
691
697
|
});
|
|
692
|
-
return e.allOf.forEach((
|
|
693
|
-
if (g(
|
|
694
|
-
const r = this.resolveType(
|
|
698
|
+
return e.allOf.forEach((o) => {
|
|
699
|
+
if (g(o)) {
|
|
700
|
+
const r = this.resolveType(o);
|
|
695
701
|
t.addExtends(r);
|
|
696
702
|
return;
|
|
697
703
|
}
|
|
698
|
-
T(
|
|
704
|
+
T(o) && Object.entries(o.properties).forEach(
|
|
699
705
|
([r, i]) => {
|
|
700
706
|
this.addPropertyToInterface(
|
|
701
707
|
t,
|
|
@@ -714,12 +720,12 @@ class tt {
|
|
|
714
720
|
});
|
|
715
721
|
}
|
|
716
722
|
}
|
|
717
|
-
class
|
|
723
|
+
class rt {
|
|
718
724
|
constructor(e) {
|
|
719
725
|
this.context = e;
|
|
720
726
|
}
|
|
721
727
|
getOrCreateSourceFile(e) {
|
|
722
|
-
const t =
|
|
728
|
+
const t = ze(e);
|
|
723
729
|
return this.context.getOrCreateSourceFile(t);
|
|
724
730
|
}
|
|
725
731
|
/**
|
|
@@ -736,24 +742,24 @@ class nt {
|
|
|
736
742
|
this.context.logger.info("No schemas found in OpenAPI specification");
|
|
737
743
|
return;
|
|
738
744
|
}
|
|
739
|
-
const t = this.stateAggregatedTypeNames(),
|
|
745
|
+
const t = this.stateAggregatedTypeNames(), o = this.filterSchemas(e, t);
|
|
740
746
|
this.context.logger.progress(
|
|
741
|
-
`Generating models for ${
|
|
742
|
-
),
|
|
747
|
+
`Generating models for ${o.length} schemas`
|
|
748
|
+
), o.forEach((r, i) => {
|
|
743
749
|
this.context.logger.progressWithCount(
|
|
744
750
|
i + 1,
|
|
745
|
-
|
|
751
|
+
o.length,
|
|
746
752
|
`Processing schema: ${r.key}`,
|
|
747
753
|
2
|
|
748
754
|
), this.generateKeyedSchema(r);
|
|
749
755
|
}), this.context.logger.success("Model generation completed");
|
|
750
756
|
}
|
|
751
757
|
filterSchemas(e, t) {
|
|
752
|
-
return Object.entries(e).map(([
|
|
753
|
-
key:
|
|
758
|
+
return Object.entries(e).map(([o, r]) => ({
|
|
759
|
+
key: o,
|
|
754
760
|
schema: r
|
|
755
761
|
})).filter(
|
|
756
|
-
(
|
|
762
|
+
(o) => !this.isWowSchema(o.key, t)
|
|
757
763
|
);
|
|
758
764
|
}
|
|
759
765
|
isWowSchema(e, t) {
|
|
@@ -763,8 +769,8 @@ class nt {
|
|
|
763
769
|
"AggregatedDomainEventStreamServerSentEventNonNullData"
|
|
764
770
|
) || e.endsWith("AggregatedListQuery") || e.endsWith("AggregatedPagedQuery") || e.endsWith("AggregatedSingleQuery"))
|
|
765
771
|
return !0;
|
|
766
|
-
const
|
|
767
|
-
return t.has(
|
|
772
|
+
const o = m(e);
|
|
773
|
+
return t.has(o.name);
|
|
768
774
|
}
|
|
769
775
|
aggregatedSchemaSuffix = [
|
|
770
776
|
"MaterializedSnapshot",
|
|
@@ -777,9 +783,9 @@ class nt {
|
|
|
777
783
|
];
|
|
778
784
|
stateAggregatedTypeNames() {
|
|
779
785
|
const e = /* @__PURE__ */ new Set();
|
|
780
|
-
for (const [t,
|
|
786
|
+
for (const [t, o] of this.context.contextAggregates) {
|
|
781
787
|
this.generateBoundedContext(t);
|
|
782
|
-
for (const r of
|
|
788
|
+
for (const r of o)
|
|
783
789
|
this.aggregatedSchemaSuffix.forEach((i) => {
|
|
784
790
|
const s = m(r.state.key), a = R(s.name) + i;
|
|
785
791
|
e.add(a);
|
|
@@ -800,10 +806,10 @@ class nt {
|
|
|
800
806
|
* 4. Type alias processing
|
|
801
807
|
*/
|
|
802
808
|
generateKeyedSchema(e) {
|
|
803
|
-
const t = m(e.key),
|
|
804
|
-
new
|
|
809
|
+
const t = m(e.key), o = this.getOrCreateSourceFile(t);
|
|
810
|
+
new ot(
|
|
805
811
|
t,
|
|
806
|
-
|
|
812
|
+
o,
|
|
807
813
|
e,
|
|
808
814
|
this.context.outputDir
|
|
809
815
|
).generate();
|
|
@@ -811,11 +817,11 @@ class nt {
|
|
|
811
817
|
generateBoundedContext(e) {
|
|
812
818
|
const t = `${e}/boundedContext.ts`;
|
|
813
819
|
this.context.logger.info(`Creating bounded context file: ${t}`);
|
|
814
|
-
const
|
|
815
|
-
|
|
820
|
+
const o = this.context.getOrCreateSourceFile(t), r = N(e);
|
|
821
|
+
o.addStatements(`export const ${r} = '${e}';`);
|
|
816
822
|
}
|
|
817
823
|
}
|
|
818
|
-
const
|
|
824
|
+
const it = "@ahoo-wang/fetcher-decorator", st = [
|
|
819
825
|
"type ApiMetadata",
|
|
820
826
|
"type ApiMetadataCapable",
|
|
821
827
|
"type ParameterRequest",
|
|
@@ -829,24 +835,24 @@ const ot = "@ahoo-wang/fetcher-decorator", rt = [
|
|
|
829
835
|
"attribute",
|
|
830
836
|
"path",
|
|
831
837
|
"autoGeneratedError"
|
|
832
|
-
],
|
|
838
|
+
], at = {
|
|
833
839
|
type: "Promise<Response>",
|
|
834
840
|
metadata: "{resultExtractor: ResultExtractors.Response }"
|
|
835
|
-
},
|
|
841
|
+
}, H = {
|
|
836
842
|
type: "Promise<string>",
|
|
837
843
|
metadata: "{resultExtractor: ResultExtractors.Text }"
|
|
838
|
-
},
|
|
844
|
+
}, F = `{
|
|
839
845
|
headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },
|
|
840
846
|
resultExtractor: JsonEventStreamResultExtractor,
|
|
841
847
|
}`;
|
|
842
|
-
function
|
|
843
|
-
A(
|
|
848
|
+
function le(n) {
|
|
849
|
+
A(n, it, st);
|
|
844
850
|
}
|
|
845
|
-
function
|
|
851
|
+
function j(n, e, t = [], o = [], r) {
|
|
846
852
|
return e.addClass({
|
|
847
|
-
name:
|
|
853
|
+
name: n,
|
|
848
854
|
isExported: !0,
|
|
849
|
-
typeParameters:
|
|
855
|
+
typeParameters: o,
|
|
850
856
|
extends: r,
|
|
851
857
|
decorators: [
|
|
852
858
|
{
|
|
@@ -856,68 +862,68 @@ function F(o, e, t = [], n = [], r) {
|
|
|
856
862
|
]
|
|
857
863
|
});
|
|
858
864
|
}
|
|
859
|
-
function
|
|
860
|
-
|
|
865
|
+
function me(n, e) {
|
|
866
|
+
n.addImplements("ApiMetadataCapable"), n.addConstructor({
|
|
861
867
|
parameters: [
|
|
862
868
|
{
|
|
863
869
|
name: "apiMetadata",
|
|
864
870
|
type: "ApiMetadata",
|
|
865
871
|
hasQuestionToken: e === void 0,
|
|
866
|
-
scope:
|
|
872
|
+
scope: ye.Public,
|
|
867
873
|
isReadonly: !0,
|
|
868
874
|
initializer: e
|
|
869
875
|
}
|
|
870
876
|
]
|
|
871
877
|
});
|
|
872
878
|
}
|
|
873
|
-
const
|
|
874
|
-
function
|
|
875
|
-
A(
|
|
879
|
+
const ct = "@ahoo-wang/fetcher-eventstream";
|
|
880
|
+
function de(n) {
|
|
881
|
+
A(n, ct, [
|
|
876
882
|
"JsonEventStreamResultExtractor",
|
|
877
883
|
"type JsonServerSentEventStream"
|
|
878
884
|
]);
|
|
879
885
|
}
|
|
880
|
-
function
|
|
886
|
+
function gt(n) {
|
|
881
887
|
let e = 0, t = 0;
|
|
882
|
-
return
|
|
883
|
-
|
|
888
|
+
return n.commands.forEach((o) => {
|
|
889
|
+
o.path.startsWith(L.TENANT) && (e += 1), o.path.startsWith(L.OWNER) && (t += 1);
|
|
884
890
|
}), e === 0 && t === 0 ? "ResourceAttributionPathSpec.NONE" : e > t ? "ResourceAttributionPathSpec.TENANT" : "ResourceAttributionPathSpec.OWNER";
|
|
885
891
|
}
|
|
886
|
-
function
|
|
887
|
-
const r = `${t.contextAlias}/${t.aggregateName}/${
|
|
888
|
-
return
|
|
892
|
+
function fe(n, e, t, o) {
|
|
893
|
+
const r = `${t.contextAlias}/${t.aggregateName}/${o}.ts`;
|
|
894
|
+
return ge(n, e, r);
|
|
889
895
|
}
|
|
890
|
-
function h(
|
|
891
|
-
return `${R(
|
|
896
|
+
function h(n, e) {
|
|
897
|
+
return `${R(n.aggregateName)}${e}`;
|
|
892
898
|
}
|
|
893
|
-
function
|
|
894
|
-
return
|
|
899
|
+
function _(n) {
|
|
900
|
+
return n === "delete" ? "del" : n;
|
|
895
901
|
}
|
|
896
|
-
const
|
|
897
|
-
function
|
|
898
|
-
const t =
|
|
902
|
+
const pt = "x-fetcher-method";
|
|
903
|
+
function ut(n, e) {
|
|
904
|
+
const t = n[pt];
|
|
899
905
|
if (t)
|
|
900
906
|
return t;
|
|
901
|
-
if (!
|
|
907
|
+
if (!n.operationId)
|
|
902
908
|
return;
|
|
903
|
-
const
|
|
904
|
-
for (let r =
|
|
905
|
-
const i = f(
|
|
909
|
+
const o = O(n.operationId);
|
|
910
|
+
for (let r = o.length - 1; r >= 0; r--) {
|
|
911
|
+
const i = f(o.slice(r));
|
|
906
912
|
if (!e(i))
|
|
907
913
|
return i;
|
|
908
914
|
}
|
|
909
|
-
return f(
|
|
915
|
+
return f(o);
|
|
910
916
|
}
|
|
911
|
-
class
|
|
917
|
+
class lt {
|
|
912
918
|
/**
|
|
913
919
|
* Creates a new ApiClientGenerator instance.
|
|
914
920
|
* @param context - The generation context containing OpenAPI spec and configuration
|
|
915
921
|
*/
|
|
916
922
|
constructor(e) {
|
|
917
|
-
this.context = e, this.apiMetadataCtorInitializer = this.context.currentContextAlias ? `{basePath:${
|
|
923
|
+
this.context = e, this.apiMetadataCtorInitializer = this.context.currentContextAlias ? `{basePath:${N(this.context.currentContextAlias)}}` : void 0;
|
|
918
924
|
}
|
|
919
925
|
defaultParameterRequestType = "ParameterRequest";
|
|
920
|
-
defaultReturnType =
|
|
926
|
+
defaultReturnType = at;
|
|
921
927
|
apiMetadataCtorInitializer;
|
|
922
928
|
/**
|
|
923
929
|
* Generates API client classes for all valid tags in the OpenAPI specification.
|
|
@@ -943,10 +949,10 @@ class pt {
|
|
|
943
949
|
this.context.logger.info(
|
|
944
950
|
`Generating ${t.size} API client classes`
|
|
945
951
|
);
|
|
946
|
-
let
|
|
952
|
+
let o = 0;
|
|
947
953
|
for (const [r, i] of t) {
|
|
948
|
-
|
|
949
|
-
|
|
954
|
+
o++, this.context.logger.progressWithCount(
|
|
955
|
+
o,
|
|
950
956
|
t.size,
|
|
951
957
|
`Generating API client for tag: ${r}`
|
|
952
958
|
);
|
|
@@ -969,22 +975,22 @@ class pt {
|
|
|
969
975
|
* @param operations - Set of operations for this client
|
|
970
976
|
*/
|
|
971
977
|
generateApiClient(e, t) {
|
|
972
|
-
const
|
|
978
|
+
const o = m(e.name);
|
|
973
979
|
this.context.logger.info(
|
|
974
|
-
`Generating API client class: ${
|
|
980
|
+
`Generating API client class: ${o.name}ApiClient with ${t.size} operations`
|
|
975
981
|
);
|
|
976
|
-
const r = this.createApiClientFile(
|
|
977
|
-
|
|
978
|
-
const i =
|
|
979
|
-
|
|
982
|
+
const r = this.createApiClientFile(o);
|
|
983
|
+
le(r), de(r);
|
|
984
|
+
const i = j(
|
|
985
|
+
o.name + "ApiClient",
|
|
980
986
|
r
|
|
981
987
|
);
|
|
982
|
-
C(i, [e.description]),
|
|
983
|
-
`Processing ${t.size} operations for ${
|
|
988
|
+
C(i, [e.description]), me(i, this.apiMetadataCtorInitializer), this.context.logger.info(
|
|
989
|
+
`Processing ${t.size} operations for ${o.name}ApiClient`
|
|
984
990
|
), t.forEach((s) => {
|
|
985
991
|
this.processOperation(e, r, i, s);
|
|
986
992
|
}), this.context.logger.success(
|
|
987
|
-
`Completed API client: ${
|
|
993
|
+
`Completed API client: ${o.name}ApiClient`
|
|
988
994
|
);
|
|
989
995
|
}
|
|
990
996
|
/**
|
|
@@ -994,12 +1000,12 @@ class pt {
|
|
|
994
1000
|
* @returns A unique camelCase method name
|
|
995
1001
|
*/
|
|
996
1002
|
getMethodName(e, t) {
|
|
997
|
-
const
|
|
998
|
-
if (!
|
|
1003
|
+
const o = ut(t, (r) => e.getMethod(r) !== void 0);
|
|
1004
|
+
if (!o)
|
|
999
1005
|
throw new Error(
|
|
1000
1006
|
`Unable to resolve method name for apiClientClass:${e.getName()}.`
|
|
1001
1007
|
);
|
|
1002
|
-
return
|
|
1008
|
+
return o;
|
|
1003
1009
|
}
|
|
1004
1010
|
/**
|
|
1005
1011
|
* Resolves the request type for an operation based on its request body.
|
|
@@ -1012,22 +1018,22 @@ class pt {
|
|
|
1012
1018
|
return this.context.logger.info(
|
|
1013
1019
|
`No request body found for operation ${t.operationId}, using default: ${this.defaultParameterRequestType}`
|
|
1014
1020
|
), this.defaultParameterRequestType;
|
|
1015
|
-
let
|
|
1021
|
+
let o;
|
|
1016
1022
|
if (g(t.requestBody) ? (this.context.logger.info(
|
|
1017
1023
|
`Extracting request body from reference for operation: ${t.operationId}`
|
|
1018
|
-
),
|
|
1024
|
+
), o = Y(
|
|
1019
1025
|
t.requestBody,
|
|
1020
1026
|
this.context.openAPI.components
|
|
1021
|
-
)) :
|
|
1027
|
+
)) : o = t.requestBody, !o)
|
|
1022
1028
|
return this.context.logger.info(
|
|
1023
1029
|
`Request body extraction failed for operation ${t.operationId}, using default: ${this.defaultParameterRequestType}`
|
|
1024
1030
|
), this.defaultParameterRequestType;
|
|
1025
|
-
if (
|
|
1031
|
+
if (o.content["multipart/form-data"])
|
|
1026
1032
|
return this.context.logger.info(
|
|
1027
1033
|
`Detected multipart/form-data content for operation ${t.operationId}, using ParameterRequest<FormData>`
|
|
1028
1034
|
), "ParameterRequest<FormData>";
|
|
1029
|
-
if (
|
|
1030
|
-
const r =
|
|
1035
|
+
if (o.content["application/json"]) {
|
|
1036
|
+
const r = o.content["application/json"].schema;
|
|
1031
1037
|
if (g(r)) {
|
|
1032
1038
|
const i = v(r);
|
|
1033
1039
|
this.context.logger.info(
|
|
@@ -1050,19 +1056,19 @@ class pt {
|
|
|
1050
1056
|
* @param operation - The operation to resolve parameters for
|
|
1051
1057
|
* @returns Array of parameter declarations
|
|
1052
1058
|
*/
|
|
1053
|
-
resolveParameters(e, t,
|
|
1054
|
-
const r =
|
|
1055
|
-
|
|
1059
|
+
resolveParameters(e, t, o) {
|
|
1060
|
+
const r = qe(
|
|
1061
|
+
o,
|
|
1056
1062
|
this.context.openAPI.components
|
|
1057
1063
|
).filter((a) => !this.context.isIgnoreApiClientPathParameters(
|
|
1058
1064
|
e.name,
|
|
1059
1065
|
a.name
|
|
1060
1066
|
));
|
|
1061
1067
|
this.context.logger.info(
|
|
1062
|
-
`Found ${r.length} path parameters for operation ${
|
|
1068
|
+
`Found ${r.length} path parameters for operation ${o.operationId}`
|
|
1063
1069
|
);
|
|
1064
1070
|
const i = r.map((a) => {
|
|
1065
|
-
const c =
|
|
1071
|
+
const c = ie(a);
|
|
1066
1072
|
return this.context.logger.info(
|
|
1067
1073
|
`Adding path parameter: ${a.name} (type: ${c})`
|
|
1068
1074
|
), {
|
|
@@ -1076,7 +1082,7 @@ class pt {
|
|
|
1076
1082
|
}
|
|
1077
1083
|
]
|
|
1078
1084
|
};
|
|
1079
|
-
}), s = this.resolveRequestType(t,
|
|
1085
|
+
}), s = this.resolveRequestType(t, o);
|
|
1080
1086
|
return this.context.logger.info(`Adding httpRequest parameter: ${s}`), i.push({
|
|
1081
1087
|
name: "httpRequest",
|
|
1082
1088
|
hasQuestionToken: s === this.defaultParameterRequestType,
|
|
@@ -1108,7 +1114,7 @@ class pt {
|
|
|
1108
1114
|
* @returns The resolved return type string
|
|
1109
1115
|
*/
|
|
1110
1116
|
resolveSchemaReturnType(e, t) {
|
|
1111
|
-
const
|
|
1117
|
+
const o = "Promise<any>";
|
|
1112
1118
|
if (g(t)) {
|
|
1113
1119
|
const r = v(t);
|
|
1114
1120
|
this.context.logger.info(
|
|
@@ -1119,15 +1125,15 @@ class pt {
|
|
|
1119
1125
|
}
|
|
1120
1126
|
if (!t.type)
|
|
1121
1127
|
return this.context.logger.info(
|
|
1122
|
-
`Schema has no type, using default return type: ${
|
|
1123
|
-
),
|
|
1124
|
-
if (
|
|
1128
|
+
`Schema has no type, using default return type: ${o}`
|
|
1129
|
+
), o;
|
|
1130
|
+
if (ne(t.type)) {
|
|
1125
1131
|
const i = `Promise<${w(t.type)}>`;
|
|
1126
1132
|
return this.context.logger.info(`Resolved primitive return type: ${i}`), i;
|
|
1127
1133
|
}
|
|
1128
1134
|
return this.context.logger.info(
|
|
1129
|
-
`Using default return type: ${
|
|
1130
|
-
),
|
|
1135
|
+
`Using default return type: ${o}`
|
|
1136
|
+
), o;
|
|
1131
1137
|
}
|
|
1132
1138
|
/**
|
|
1133
1139
|
* Resolves the return type for an operation based on its responses.
|
|
@@ -1136,29 +1142,29 @@ class pt {
|
|
|
1136
1142
|
* @returns Object containing type and optional stream flag
|
|
1137
1143
|
*/
|
|
1138
1144
|
resolveReturnType(e, t) {
|
|
1139
|
-
const
|
|
1140
|
-
if (!
|
|
1145
|
+
const o = W(t);
|
|
1146
|
+
if (!o)
|
|
1141
1147
|
return this.context.logger.info(
|
|
1142
1148
|
`No OK response found for operation ${t.operationId}, using default return type: ${this.defaultReturnType.type}`
|
|
1143
1149
|
), this.defaultReturnType;
|
|
1144
|
-
const r =
|
|
1150
|
+
const r = te(o) || Ie(o);
|
|
1145
1151
|
if (r) {
|
|
1146
1152
|
const s = this.resolveSchemaReturnType(e, r);
|
|
1147
1153
|
return this.context.logger.info(
|
|
1148
1154
|
`Resolved JSON/wildcard response return type for operation ${t.operationId}: ${s}`
|
|
1149
1155
|
), {
|
|
1150
1156
|
type: s,
|
|
1151
|
-
metadata: s ===
|
|
1157
|
+
metadata: s === H.type ? H.metadata : void 0
|
|
1152
1158
|
};
|
|
1153
1159
|
}
|
|
1154
|
-
const i =
|
|
1160
|
+
const i = ve(o);
|
|
1155
1161
|
if (i) {
|
|
1156
1162
|
if (g(i)) {
|
|
1157
1163
|
const a = S(
|
|
1158
1164
|
i,
|
|
1159
1165
|
this.context.openAPI.components
|
|
1160
1166
|
);
|
|
1161
|
-
if (
|
|
1167
|
+
if (b(a) && g(a.items)) {
|
|
1162
1168
|
const c = v(a.items);
|
|
1163
1169
|
this.context.logger.info(
|
|
1164
1170
|
`Adding import for event stream model: ${c.name} from ${c.path}`
|
|
@@ -1168,14 +1174,14 @@ class pt {
|
|
|
1168
1174
|
`Resolved event stream return type for operation ${t.operationId}: ${p}`
|
|
1169
1175
|
), {
|
|
1170
1176
|
type: p,
|
|
1171
|
-
metadata:
|
|
1177
|
+
metadata: F
|
|
1172
1178
|
};
|
|
1173
1179
|
}
|
|
1174
1180
|
}
|
|
1175
1181
|
const s = "Promise<JsonServerSentEventStream<any>>";
|
|
1176
1182
|
return this.context.logger.info(
|
|
1177
1183
|
`Resolved generic event stream return type for operation ${t.operationId}: ${s}`
|
|
1178
|
-
), { type: s, metadata:
|
|
1184
|
+
), { type: s, metadata: F };
|
|
1179
1185
|
}
|
|
1180
1186
|
return this.context.logger.info(
|
|
1181
1187
|
`Using default return type for operation ${t.operationId}: ${this.defaultReturnType.type}`
|
|
@@ -1188,27 +1194,27 @@ class pt {
|
|
|
1188
1194
|
* @param apiClientClass - The client class to add the method to
|
|
1189
1195
|
* @param operation - The operation to process
|
|
1190
1196
|
*/
|
|
1191
|
-
processOperation(e, t,
|
|
1197
|
+
processOperation(e, t, o, r) {
|
|
1192
1198
|
this.context.logger.info(
|
|
1193
1199
|
`Processing operation: ${r.operation.operationId} (${r.method} ${r.path})`
|
|
1194
1200
|
);
|
|
1195
|
-
const i = this.getMethodName(
|
|
1201
|
+
const i = this.getMethodName(o, r.operation);
|
|
1196
1202
|
this.context.logger.info(`Generated method name: ${i}`);
|
|
1197
1203
|
const s = this.resolveParameters(
|
|
1198
1204
|
e,
|
|
1199
1205
|
t,
|
|
1200
1206
|
r.operation
|
|
1201
1207
|
), a = this.resolveReturnType(t, r.operation), c = a.metadata ? {
|
|
1202
|
-
name:
|
|
1208
|
+
name: _(r.method),
|
|
1203
1209
|
arguments: [`'${r.path}'`, a.metadata]
|
|
1204
1210
|
} : {
|
|
1205
|
-
name:
|
|
1211
|
+
name: _(r.method),
|
|
1206
1212
|
arguments: [`'${r.path}'`]
|
|
1207
1213
|
};
|
|
1208
1214
|
this.context.logger.info(
|
|
1209
1215
|
`Creating method with ${s.length} parameters, return type: ${a.type}`
|
|
1210
1216
|
);
|
|
1211
|
-
const u =
|
|
1217
|
+
const u = o.addMethod({
|
|
1212
1218
|
name: i,
|
|
1213
1219
|
decorators: [c],
|
|
1214
1220
|
parameters: s,
|
|
@@ -1231,7 +1237,7 @@ class pt {
|
|
|
1231
1237
|
*/
|
|
1232
1238
|
groupOperations(e) {
|
|
1233
1239
|
this.context.logger.info("Grouping operations by API client tags");
|
|
1234
|
-
const t = /* @__PURE__ */ new Map(),
|
|
1240
|
+
const t = /* @__PURE__ */ new Map(), o = oe(
|
|
1235
1241
|
this.context.openAPI.paths
|
|
1236
1242
|
).filter((i) => {
|
|
1237
1243
|
if (!i.operation.operationId)
|
|
@@ -1240,7 +1246,7 @@ class pt {
|
|
|
1240
1246
|
return !s || s.length == 0 ? !1 : s.every((a) => e.has(a));
|
|
1241
1247
|
});
|
|
1242
1248
|
let r = 0;
|
|
1243
|
-
for (const i of
|
|
1249
|
+
for (const i of o)
|
|
1244
1250
|
i.operation.tags.forEach((s) => {
|
|
1245
1251
|
t.has(s) || t.set(s, /* @__PURE__ */ new Set()), t.get(s).add(i), r++;
|
|
1246
1252
|
});
|
|
@@ -1262,7 +1268,7 @@ class pt {
|
|
|
1262
1268
|
);
|
|
1263
1269
|
const e = /* @__PURE__ */ new Map(), t = this.context.openAPI.tags?.length || 0;
|
|
1264
1270
|
for (const r of Object.values(this.context.openAPI.paths))
|
|
1265
|
-
|
|
1271
|
+
re(r).forEach((i) => {
|
|
1266
1272
|
i.operation.tags?.forEach((s) => {
|
|
1267
1273
|
!this.shouldIgnoreTag(s) && !e.has(s) && e.set(s, {
|
|
1268
1274
|
name: s,
|
|
@@ -1270,24 +1276,24 @@ class pt {
|
|
|
1270
1276
|
});
|
|
1271
1277
|
});
|
|
1272
1278
|
});
|
|
1273
|
-
let
|
|
1279
|
+
let o = 0;
|
|
1274
1280
|
return this.context.openAPI.tags?.forEach((r) => {
|
|
1275
1281
|
this.shouldIgnoreTag(r.name) ? this.context.logger.info(
|
|
1276
1282
|
`Excluded tag: ${r.name} (wow/Actuator/aggregate)`
|
|
1277
|
-
) : (e.set(r.name, r),
|
|
1283
|
+
) : (e.set(r.name, r), o++, this.context.logger.info(`Included API client tag: ${r.name}`));
|
|
1278
1284
|
}), this.context.logger.info(
|
|
1279
|
-
`Resolved ${
|
|
1285
|
+
`Resolved ${o} API client tags from ${t} total tags`
|
|
1280
1286
|
), e;
|
|
1281
1287
|
}
|
|
1282
1288
|
isAggregateTag(e) {
|
|
1283
1289
|
for (const t of this.context.contextAggregates.values())
|
|
1284
|
-
for (const
|
|
1285
|
-
if (
|
|
1290
|
+
for (const o of t)
|
|
1291
|
+
if (o.aggregate.tag.name === e)
|
|
1286
1292
|
return !0;
|
|
1287
1293
|
return !1;
|
|
1288
1294
|
}
|
|
1289
1295
|
}
|
|
1290
|
-
class
|
|
1296
|
+
class mt {
|
|
1291
1297
|
/**
|
|
1292
1298
|
* Creates a new CommandClientGenerator instance.
|
|
1293
1299
|
* @param context - The generation context containing OpenAPI spec and project details
|
|
@@ -1303,13 +1309,13 @@ class ut {
|
|
|
1303
1309
|
generate() {
|
|
1304
1310
|
const e = Array.from(
|
|
1305
1311
|
this.context.contextAggregates.values()
|
|
1306
|
-
).reduce((
|
|
1312
|
+
).reduce((o, r) => o + r.size, 0);
|
|
1307
1313
|
this.context.logger.info("--- Generating Command Clients ---"), this.context.logger.progress(
|
|
1308
1314
|
`Generating command clients for ${e} aggregates`
|
|
1309
1315
|
);
|
|
1310
1316
|
let t = 0;
|
|
1311
|
-
for (const [,
|
|
1312
|
-
|
|
1317
|
+
for (const [, o] of this.context.contextAggregates)
|
|
1318
|
+
o.forEach((r) => {
|
|
1313
1319
|
t++, this.context.logger.progressWithCount(
|
|
1314
1320
|
t,
|
|
1315
1321
|
e,
|
|
@@ -1326,7 +1332,7 @@ class ut {
|
|
|
1326
1332
|
this.context.logger.info(
|
|
1327
1333
|
`Processing command client for aggregate: ${e.aggregate.aggregateName} in context: ${e.aggregate.contextAlias}`
|
|
1328
1334
|
);
|
|
1329
|
-
const t =
|
|
1335
|
+
const t = fe(
|
|
1330
1336
|
this.context.project,
|
|
1331
1337
|
this.context.outputDir,
|
|
1332
1338
|
e.aggregate,
|
|
@@ -1335,20 +1341,20 @@ class ut {
|
|
|
1335
1341
|
this.context.logger.info(
|
|
1336
1342
|
`Processing command endpoint paths for ${e.commands.size} commands`
|
|
1337
1343
|
);
|
|
1338
|
-
const
|
|
1344
|
+
const o = this.processCommandEndpointPaths(
|
|
1339
1345
|
t,
|
|
1340
1346
|
e
|
|
1341
1347
|
);
|
|
1342
1348
|
this.processCommandTypes(t, e), this.context.logger.info(
|
|
1343
1349
|
`Creating default command client options: ${this.defaultCommandClientOptionsName}`
|
|
1344
1350
|
), t.addVariableStatement({
|
|
1345
|
-
declarationKind:
|
|
1351
|
+
declarationKind: D.Const,
|
|
1346
1352
|
declarations: [
|
|
1347
1353
|
{
|
|
1348
1354
|
name: this.defaultCommandClientOptionsName,
|
|
1349
1355
|
type: "ApiMetadata",
|
|
1350
1356
|
initializer: `{
|
|
1351
|
-
basePath: ${
|
|
1357
|
+
basePath: ${N(e.aggregate.contextAlias)}
|
|
1352
1358
|
}`
|
|
1353
1359
|
}
|
|
1354
1360
|
],
|
|
@@ -1368,14 +1374,14 @@ class ut {
|
|
|
1368
1374
|
isTypeOnly: !0
|
|
1369
1375
|
}), this.context.logger.info(
|
|
1370
1376
|
"Adding import from @ahoo-wang/fetcher-eventstream: JsonEventStreamResultExtractor"
|
|
1371
|
-
),
|
|
1377
|
+
), de(t), this.context.logger.info(
|
|
1372
1378
|
"Adding import from @ahoo-wang/fetcher: ContentTypeValues"
|
|
1373
1379
|
), A(t, "@ahoo-wang/fetcher", ["ContentTypeValues"]), this.context.logger.info(
|
|
1374
1380
|
"Adding imports from @ahoo-wang/fetcher-decorator: ApiMetadata types and decorators"
|
|
1375
|
-
),
|
|
1381
|
+
), le(t), this.context.logger.info("Generating standard command client class"), this.processCommandClient(
|
|
1376
1382
|
t,
|
|
1377
1383
|
e,
|
|
1378
|
-
|
|
1384
|
+
o
|
|
1379
1385
|
), this.context.logger.info("Generating stream command client class"), this.processStreamCommandClient(t, e), this.context.logger.success(
|
|
1380
1386
|
`Command client generation completed for aggregate: ${e.aggregate.aggregateName}`
|
|
1381
1387
|
);
|
|
@@ -1384,14 +1390,14 @@ class ut {
|
|
|
1384
1390
|
return h(e, this.commandEndpointPathsSuffix);
|
|
1385
1391
|
}
|
|
1386
1392
|
processCommandEndpointPaths(e, t) {
|
|
1387
|
-
const
|
|
1393
|
+
const o = this.resolveAggregateCommandEndpointPathsName(
|
|
1388
1394
|
t.aggregate
|
|
1389
1395
|
);
|
|
1390
1396
|
this.context.logger.info(
|
|
1391
|
-
`Creating command endpoint paths enum: ${
|
|
1397
|
+
`Creating command endpoint paths enum: ${o}`
|
|
1392
1398
|
);
|
|
1393
1399
|
const r = e.addEnum({
|
|
1394
|
-
name:
|
|
1400
|
+
name: o,
|
|
1395
1401
|
isExported: !0
|
|
1396
1402
|
});
|
|
1397
1403
|
return t.commands.forEach((i) => {
|
|
@@ -1403,19 +1409,19 @@ class ut {
|
|
|
1403
1409
|
});
|
|
1404
1410
|
}), this.context.logger.success(
|
|
1405
1411
|
`Command endpoint paths enum created with ${t.commands.size} entries`
|
|
1406
|
-
),
|
|
1412
|
+
), o;
|
|
1407
1413
|
}
|
|
1408
1414
|
resolveCommandTypeName(e) {
|
|
1409
1415
|
const t = m(e.schema.key);
|
|
1410
1416
|
return [t, t.name + "Command"];
|
|
1411
1417
|
}
|
|
1412
1418
|
resolveCommandType(e, t) {
|
|
1413
|
-
const [
|
|
1414
|
-
if (
|
|
1419
|
+
const [o, r] = this.resolveCommandTypeName(t);
|
|
1420
|
+
if (o.path === y)
|
|
1415
1421
|
return;
|
|
1416
|
-
d(e, this.context.outputDir,
|
|
1417
|
-
let i = `${
|
|
1418
|
-
const s =
|
|
1422
|
+
d(e, this.context.outputDir, o);
|
|
1423
|
+
let i = `${o.name}`;
|
|
1424
|
+
const s = Me(t.schema.schema).map((a) => `'${a}'`).join(" | ");
|
|
1419
1425
|
s !== "" && (i = `PartialBy<${i},${s}>`), i = `CommandBody<${i}>`, e.addTypeAlias({
|
|
1420
1426
|
name: r,
|
|
1421
1427
|
type: `${i}`,
|
|
@@ -1423,46 +1429,46 @@ class ut {
|
|
|
1423
1429
|
});
|
|
1424
1430
|
}
|
|
1425
1431
|
processCommandTypes(e, t) {
|
|
1426
|
-
t.commands.forEach((
|
|
1427
|
-
this.resolveCommandType(e,
|
|
1432
|
+
t.commands.forEach((o) => {
|
|
1433
|
+
this.resolveCommandType(e, o);
|
|
1428
1434
|
});
|
|
1429
1435
|
}
|
|
1430
1436
|
getEndpointPath(e, t) {
|
|
1431
1437
|
return `${e}.${t.name.toUpperCase()}`;
|
|
1432
1438
|
}
|
|
1433
|
-
processCommandClient(e, t,
|
|
1439
|
+
processCommandClient(e, t, o) {
|
|
1434
1440
|
const r = h(
|
|
1435
1441
|
t.aggregate,
|
|
1436
1442
|
"CommandClient"
|
|
1437
|
-
), i =
|
|
1443
|
+
), i = j(
|
|
1438
1444
|
r,
|
|
1439
1445
|
e,
|
|
1440
1446
|
[],
|
|
1441
1447
|
["R = CommandResult"]
|
|
1442
1448
|
);
|
|
1443
|
-
|
|
1449
|
+
me(i, this.defaultCommandClientOptionsName), t.commands.forEach((s) => {
|
|
1444
1450
|
this.processCommandMethod(
|
|
1445
1451
|
t,
|
|
1446
1452
|
i,
|
|
1447
1453
|
s,
|
|
1448
|
-
|
|
1454
|
+
o
|
|
1449
1455
|
);
|
|
1450
1456
|
});
|
|
1451
1457
|
}
|
|
1452
1458
|
processStreamCommandClient(e, t) {
|
|
1453
|
-
const
|
|
1459
|
+
const o = h(
|
|
1454
1460
|
t.aggregate,
|
|
1455
1461
|
"CommandClient"
|
|
1456
1462
|
), r = h(
|
|
1457
1463
|
t.aggregate,
|
|
1458
1464
|
"StreamCommandClient"
|
|
1459
1465
|
);
|
|
1460
|
-
|
|
1466
|
+
j(
|
|
1461
1467
|
r,
|
|
1462
1468
|
e,
|
|
1463
|
-
["''",
|
|
1469
|
+
["''", F],
|
|
1464
1470
|
[],
|
|
1465
|
-
`${
|
|
1471
|
+
`${o}<CommandResultEventStream>`
|
|
1466
1472
|
).addConstructor({
|
|
1467
1473
|
parameters: [
|
|
1468
1474
|
{
|
|
@@ -1475,15 +1481,15 @@ class ut {
|
|
|
1475
1481
|
});
|
|
1476
1482
|
}
|
|
1477
1483
|
resolveParameters(e, t) {
|
|
1478
|
-
const [
|
|
1484
|
+
const [o, r] = this.resolveCommandTypeName(t);
|
|
1479
1485
|
this.context.logger.info(
|
|
1480
|
-
`Adding import for command model: ${
|
|
1486
|
+
`Adding import for command model: ${o.name} from path: ${o.path}`
|
|
1481
1487
|
);
|
|
1482
1488
|
const i = t.pathParameters.filter((s) => !this.context.isIgnoreCommandClientPathParameters(
|
|
1483
1489
|
e.name,
|
|
1484
1490
|
s.name
|
|
1485
1491
|
)).map((s) => {
|
|
1486
|
-
const a =
|
|
1492
|
+
const a = ie(s);
|
|
1487
1493
|
return this.context.logger.info(
|
|
1488
1494
|
`Adding path parameter: ${s.name} (type: ${a})`
|
|
1489
1495
|
), {
|
|
@@ -1502,7 +1508,7 @@ class ut {
|
|
|
1502
1508
|
`Adding command request parameter: commandRequest (type: CommandRequest<${r}>)`
|
|
1503
1509
|
), i.push({
|
|
1504
1510
|
name: "commandRequest",
|
|
1505
|
-
hasQuestionToken:
|
|
1511
|
+
hasQuestionToken: De(t.schema.schema),
|
|
1506
1512
|
type: `CommandRequest<${r}>`,
|
|
1507
1513
|
decorators: [
|
|
1508
1514
|
{
|
|
@@ -1524,22 +1530,22 @@ class ut {
|
|
|
1524
1530
|
]
|
|
1525
1531
|
}), i;
|
|
1526
1532
|
}
|
|
1527
|
-
processCommandMethod(e, t,
|
|
1533
|
+
processCommandMethod(e, t, o, r) {
|
|
1528
1534
|
this.context.logger.info(
|
|
1529
|
-
`Generating command method: ${f(
|
|
1535
|
+
`Generating command method: ${f(o.name)} for command: ${o.name}`
|
|
1530
1536
|
), this.context.logger.info(
|
|
1531
|
-
`Command method details: HTTP ${
|
|
1537
|
+
`Command method details: HTTP ${o.method}, path: ${o.path}`
|
|
1532
1538
|
);
|
|
1533
1539
|
const i = this.resolveParameters(
|
|
1534
1540
|
e.aggregate.tag,
|
|
1535
|
-
|
|
1541
|
+
o
|
|
1536
1542
|
), s = t.addMethod({
|
|
1537
|
-
name: f(
|
|
1543
|
+
name: f(o.name),
|
|
1538
1544
|
decorators: [
|
|
1539
1545
|
{
|
|
1540
|
-
name:
|
|
1546
|
+
name: _(o.method),
|
|
1541
1547
|
arguments: [
|
|
1542
|
-
`${this.getEndpointPath(r,
|
|
1548
|
+
`${this.getEndpointPath(r, o)}`
|
|
1543
1549
|
]
|
|
1544
1550
|
}
|
|
1545
1551
|
],
|
|
@@ -1548,18 +1554,18 @@ class ut {
|
|
|
1548
1554
|
statements: `throw autoGeneratedError(${i.map((a) => a.name).join(",")});`
|
|
1549
1555
|
});
|
|
1550
1556
|
this.context.logger.info(
|
|
1551
|
-
`Adding JSDoc documentation for method: ${f(
|
|
1557
|
+
`Adding JSDoc documentation for method: ${f(o.name)}`
|
|
1552
1558
|
), C(s, [
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
`- operationId: \`${
|
|
1556
|
-
`- path: \`${
|
|
1559
|
+
o.summary,
|
|
1560
|
+
o.description,
|
|
1561
|
+
`- operationId: \`${o.operation.operationId}\``,
|
|
1562
|
+
`- path: \`${o.path}\``
|
|
1557
1563
|
]), this.context.logger.success(
|
|
1558
|
-
`Command method generated: ${f(
|
|
1564
|
+
`Command method generated: ${f(o.name)}`
|
|
1559
1565
|
);
|
|
1560
1566
|
}
|
|
1561
1567
|
}
|
|
1562
|
-
class
|
|
1568
|
+
class dt {
|
|
1563
1569
|
/**
|
|
1564
1570
|
* Creates a new QueryClientGenerator instance.
|
|
1565
1571
|
* @param context - The generation context containing OpenAPI spec and project details
|
|
@@ -1575,13 +1581,13 @@ class lt {
|
|
|
1575
1581
|
generate() {
|
|
1576
1582
|
const e = Array.from(
|
|
1577
1583
|
this.context.contextAggregates.values()
|
|
1578
|
-
).reduce((
|
|
1584
|
+
).reduce((o, r) => o + r.size, 0);
|
|
1579
1585
|
this.context.logger.info("--- Generating Query Clients ---"), this.context.logger.progress(
|
|
1580
1586
|
`Generating query clients for ${e} aggregates`
|
|
1581
1587
|
);
|
|
1582
1588
|
let t = 0;
|
|
1583
|
-
for (const [,
|
|
1584
|
-
|
|
1589
|
+
for (const [, o] of this.context.contextAggregates)
|
|
1590
|
+
o.forEach((r) => {
|
|
1585
1591
|
t++, this.context.logger.progressWithCount(
|
|
1586
1592
|
t,
|
|
1587
1593
|
e,
|
|
@@ -1597,7 +1603,7 @@ class lt {
|
|
|
1597
1603
|
* @returns The source file for the client
|
|
1598
1604
|
*/
|
|
1599
1605
|
createClientFilePath(e, t) {
|
|
1600
|
-
return
|
|
1606
|
+
return fe(
|
|
1601
1607
|
this.context.project,
|
|
1602
1608
|
this.context.outputDir,
|
|
1603
1609
|
e,
|
|
@@ -1625,19 +1631,19 @@ class lt {
|
|
|
1625
1631
|
"ResourceAttributionPathSpec"
|
|
1626
1632
|
]
|
|
1627
1633
|
});
|
|
1628
|
-
const
|
|
1634
|
+
const o = "DEFAULT_QUERY_CLIENT_OPTIONS";
|
|
1629
1635
|
this.context.logger.info(
|
|
1630
|
-
`Creating default query client options: ${
|
|
1636
|
+
`Creating default query client options: ${o}`
|
|
1631
1637
|
), t.addVariableStatement({
|
|
1632
|
-
declarationKind:
|
|
1638
|
+
declarationKind: D.Const,
|
|
1633
1639
|
declarations: [
|
|
1634
1640
|
{
|
|
1635
|
-
name:
|
|
1641
|
+
name: o,
|
|
1636
1642
|
type: "QueryClientOptions",
|
|
1637
1643
|
initializer: `{
|
|
1638
|
-
contextAlias: ${
|
|
1644
|
+
contextAlias: ${N(e.aggregate.contextAlias)},
|
|
1639
1645
|
aggregateName: '${e.aggregate.aggregateName}',
|
|
1640
|
-
resourceAttribution: ${
|
|
1646
|
+
resourceAttribution: ${gt(e)},
|
|
1641
1647
|
}`
|
|
1642
1648
|
}
|
|
1643
1649
|
],
|
|
@@ -1654,11 +1660,11 @@ class lt {
|
|
|
1654
1660
|
), d(t, this.context.outputDir, a), this.context.logger.info(
|
|
1655
1661
|
`Creating query client factory: ${i}`
|
|
1656
1662
|
), t.addVariableStatement({
|
|
1657
|
-
declarationKind:
|
|
1663
|
+
declarationKind: D.Const,
|
|
1658
1664
|
declarations: [
|
|
1659
1665
|
{
|
|
1660
1666
|
name: i,
|
|
1661
|
-
initializer: `new QueryClientFactory<${s.name}, ${a.name} | string, ${r}>(${
|
|
1667
|
+
initializer: `new QueryClientFactory<${s.name}, ${a.name} | string, ${r}>(${o})`
|
|
1662
1668
|
}
|
|
1663
1669
|
],
|
|
1664
1670
|
isExported: !0
|
|
@@ -1667,7 +1673,7 @@ class lt {
|
|
|
1667
1673
|
);
|
|
1668
1674
|
}
|
|
1669
1675
|
processAggregateDomainEventType(e, t) {
|
|
1670
|
-
const
|
|
1676
|
+
const o = [];
|
|
1671
1677
|
this.context.logger.info(
|
|
1672
1678
|
`Processing ${e.events.size} domain events for aggregate: ${e.aggregate.aggregateName}`
|
|
1673
1679
|
);
|
|
@@ -1679,12 +1685,12 @@ class lt {
|
|
|
1679
1685
|
t,
|
|
1680
1686
|
this.context.outputDir,
|
|
1681
1687
|
a
|
|
1682
|
-
),
|
|
1688
|
+
), o.push(a);
|
|
1683
1689
|
}
|
|
1684
1690
|
const r = h(
|
|
1685
1691
|
e.aggregate,
|
|
1686
1692
|
this.domainEventTypeSuffix
|
|
1687
|
-
), i =
|
|
1693
|
+
), i = o.map((s) => s.name).join(" | ");
|
|
1688
1694
|
return this.context.logger.info(
|
|
1689
1695
|
`Creating domain event types union: ${r} = ${i}`
|
|
1690
1696
|
), t.addTypeAlias({
|
|
@@ -1694,11 +1700,11 @@ class lt {
|
|
|
1694
1700
|
}), r;
|
|
1695
1701
|
}
|
|
1696
1702
|
processAggregateDomainEventTypes(e, t) {
|
|
1697
|
-
const
|
|
1703
|
+
const o = h(
|
|
1698
1704
|
e.aggregate,
|
|
1699
1705
|
this.domainEventTypeMapTitleSuffix
|
|
1700
1706
|
), r = t.addEnum({
|
|
1701
|
-
name:
|
|
1707
|
+
name: o,
|
|
1702
1708
|
isExported: !0
|
|
1703
1709
|
});
|
|
1704
1710
|
for (const i of e.events.values())
|
|
@@ -1708,13 +1714,13 @@ class lt {
|
|
|
1708
1714
|
});
|
|
1709
1715
|
}
|
|
1710
1716
|
}
|
|
1711
|
-
class
|
|
1717
|
+
class ft {
|
|
1712
1718
|
/**
|
|
1713
1719
|
* Creates a new ClientGenerator instance.
|
|
1714
1720
|
* @param context - The generation context containing OpenAPI spec and project details
|
|
1715
1721
|
*/
|
|
1716
1722
|
constructor(e) {
|
|
1717
|
-
this.context = e, this.queryClientGenerator = new
|
|
1723
|
+
this.context = e, this.queryClientGenerator = new dt(e), this.commandClientGenerator = new mt(e), this.apiClientGenerator = new lt(e);
|
|
1718
1724
|
}
|
|
1719
1725
|
queryClientGenerator;
|
|
1720
1726
|
commandClientGenerator;
|
|
@@ -1737,7 +1743,7 @@ class mt {
|
|
|
1737
1743
|
this.queryClientGenerator.generate(), this.commandClientGenerator.generate(), this.apiClientGenerator.generate(), this.context.logger.success("Client generation completed");
|
|
1738
1744
|
}
|
|
1739
1745
|
}
|
|
1740
|
-
class
|
|
1746
|
+
class ht {
|
|
1741
1747
|
/** The ts-morph project instance used for code generation */
|
|
1742
1748
|
project;
|
|
1743
1749
|
/** The OpenAPI specification object */
|
|
@@ -1755,7 +1761,7 @@ class dt {
|
|
|
1755
1761
|
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"];
|
|
1756
1762
|
}
|
|
1757
1763
|
getOrCreateSourceFile(e) {
|
|
1758
|
-
return
|
|
1764
|
+
return ge(this.project, this.outputDir, e);
|
|
1759
1765
|
}
|
|
1760
1766
|
isIgnoreApiClientPathParameters(e, t) {
|
|
1761
1767
|
return (this.config.apiClients?.[e]?.ignorePathParameters ?? this.defaultIgnorePathParameters).includes(t);
|
|
@@ -1764,8 +1770,8 @@ class dt {
|
|
|
1764
1770
|
return this.defaultIgnorePathParameters.includes(t);
|
|
1765
1771
|
}
|
|
1766
1772
|
}
|
|
1767
|
-
const
|
|
1768
|
-
class
|
|
1773
|
+
const yt = "./fetcher-generator.config.json";
|
|
1774
|
+
class vt {
|
|
1769
1775
|
/**
|
|
1770
1776
|
* Creates a new CodeGenerator instance with the specified options.
|
|
1771
1777
|
*
|
|
@@ -1773,7 +1779,7 @@ class $t {
|
|
|
1773
1779
|
* @throws Error if the project initialization fails due to invalid TypeScript configuration or missing files.
|
|
1774
1780
|
*/
|
|
1775
1781
|
constructor(e) {
|
|
1776
|
-
this.options = e, this.project = new
|
|
1782
|
+
this.options = e, this.project = new xe(e), this.options.logger.info(
|
|
1777
1783
|
`Project instance created with tsConfigFilePath: ${this.options.tsConfigFilePath}`
|
|
1778
1784
|
);
|
|
1779
1785
|
}
|
|
@@ -1801,28 +1807,28 @@ class $t {
|
|
|
1801
1807
|
this.options.logger.info(
|
|
1802
1808
|
"Starting code generation from OpenAPI specification"
|
|
1803
1809
|
), 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");
|
|
1804
|
-
const e = await
|
|
1810
|
+
const e = await Ge(this.options.inputPath);
|
|
1805
1811
|
this.options.logger.info("OpenAPI specification parsed successfully"), this.options.logger.info("Resolving bounded context aggregates");
|
|
1806
|
-
const
|
|
1812
|
+
const o = new tt(e).resolve();
|
|
1807
1813
|
this.options.logger.info(
|
|
1808
|
-
`Resolved ${
|
|
1814
|
+
`Resolved ${o.size} bounded context aggregates`
|
|
1809
1815
|
);
|
|
1810
|
-
const r = this.options.configPath ??
|
|
1816
|
+
const r = this.options.configPath ?? yt;
|
|
1811
1817
|
let i = {};
|
|
1812
1818
|
try {
|
|
1813
|
-
this.options.logger.info(`Parsing configuration file: ${r}`), i = await
|
|
1819
|
+
this.options.logger.info(`Parsing configuration file: ${r}`), i = await We(r);
|
|
1814
1820
|
} catch (p) {
|
|
1815
1821
|
this.options.logger.info(`Configuration file parsing failed: ${p}`);
|
|
1816
1822
|
}
|
|
1817
|
-
const s = new
|
|
1823
|
+
const s = new ht({
|
|
1818
1824
|
openAPI: e,
|
|
1819
1825
|
project: this.project,
|
|
1820
1826
|
outputDir: this.options.outputDir,
|
|
1821
|
-
contextAggregates:
|
|
1827
|
+
contextAggregates: o,
|
|
1822
1828
|
logger: this.options.logger,
|
|
1823
1829
|
config: i
|
|
1824
1830
|
});
|
|
1825
|
-
this.options.logger.info("Generating models"), new
|
|
1831
|
+
this.options.logger.info("Generating models"), new rt(s).generate(), this.options.logger.info("Models generated successfully"), this.options.logger.info("Generating clients"), new ft(s).generate(), this.options.logger.info("Clients generated successfully");
|
|
1826
1832
|
const u = this.project.getDirectory(this.options.outputDir);
|
|
1827
1833
|
if (!u) {
|
|
1828
1834
|
this.options.logger.info("Output directory not found.");
|
|
@@ -1855,8 +1861,8 @@ class $t {
|
|
|
1855
1861
|
processDirectory(e) {
|
|
1856
1862
|
const t = e.getDirectories();
|
|
1857
1863
|
this.options.logger.info(`Processing ${t.length} subdirectories`);
|
|
1858
|
-
for (const
|
|
1859
|
-
this.options.logger.info(`Processing subdirectory: ${
|
|
1864
|
+
for (const o of t)
|
|
1865
|
+
this.options.logger.info(`Processing subdirectory: ${o.getPath()}`), this.generateIndexForDirectory(o), this.processDirectory(o);
|
|
1860
1866
|
}
|
|
1861
1867
|
/**
|
|
1862
1868
|
* Generates an index.ts file for a specific directory.
|
|
@@ -1868,12 +1874,12 @@ class $t {
|
|
|
1868
1874
|
generateIndexForDirectory(e) {
|
|
1869
1875
|
const t = e.getPath();
|
|
1870
1876
|
this.options.logger.info(`Generating index for directory: ${t}`);
|
|
1871
|
-
const
|
|
1877
|
+
const o = e.getSourceFiles().filter(
|
|
1872
1878
|
(a) => a.getBaseName().endsWith(".ts") && a.getBaseName() !== "index.ts"
|
|
1873
1879
|
), r = e.getDirectories();
|
|
1874
1880
|
if (this.options.logger.info(
|
|
1875
|
-
`Found ${
|
|
1876
|
-
),
|
|
1881
|
+
`Found ${o.length} TypeScript files and ${r.length} subdirectories in ${t}`
|
|
1882
|
+
), o.length === 0 && r.length === 0) {
|
|
1877
1883
|
this.options.logger.info(
|
|
1878
1884
|
`No files or subdirectories to export in ${t}, skipping index generation`
|
|
1879
1885
|
);
|
|
@@ -1881,7 +1887,7 @@ class $t {
|
|
|
1881
1887
|
}
|
|
1882
1888
|
const i = `${t}/index.ts`, s = this.project.getSourceFile(i) || this.project.createSourceFile(i, "", { overwrite: !0 });
|
|
1883
1889
|
s.removeText();
|
|
1884
|
-
for (const a of
|
|
1890
|
+
for (const a of o) {
|
|
1885
1891
|
const c = `./${a.getBaseNameWithoutExtension()}`;
|
|
1886
1892
|
s.addExportDeclaration({
|
|
1887
1893
|
moduleSpecifier: c,
|
|
@@ -1898,7 +1904,7 @@ class $t {
|
|
|
1898
1904
|
});
|
|
1899
1905
|
}
|
|
1900
1906
|
this.options.logger.info(
|
|
1901
|
-
`Index file generated for ${t} with ${
|
|
1907
|
+
`Index file generated for ${t} with ${o.length + r.length} exports`
|
|
1902
1908
|
);
|
|
1903
1909
|
}
|
|
1904
1910
|
/**
|
|
@@ -1911,15 +1917,15 @@ class $t {
|
|
|
1911
1917
|
const t = e.getDescendantSourceFiles();
|
|
1912
1918
|
this.options.logger.info(
|
|
1913
1919
|
`Optimizing ${t.length} source files in ${e.getPath()}`
|
|
1914
|
-
), t.forEach((
|
|
1920
|
+
), t.forEach((o, r) => {
|
|
1915
1921
|
this.options.logger.info(
|
|
1916
|
-
`Optimizing file [${
|
|
1917
|
-
),
|
|
1922
|
+
`Optimizing file [${o.getFilePath()}] - ${r + 1}/${t.length}`
|
|
1923
|
+
), o.formatText(), o.organizeImports(), o.fixMissingImports();
|
|
1918
1924
|
}), this.options.logger.info("All source files optimized");
|
|
1919
1925
|
}
|
|
1920
1926
|
}
|
|
1921
1927
|
export {
|
|
1922
|
-
|
|
1923
|
-
|
|
1928
|
+
vt as CodeGenerator,
|
|
1929
|
+
yt as DEFAULT_CONFIG_PATH
|
|
1924
1930
|
};
|
|
1925
1931
|
//# sourceMappingURL=index.js.map
|