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