@ahoo-wang/wow-generator 9.8.0 → 10.0.0-alpha.3
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/README.md +2 -1
- package/README.zh-CN.md +1 -1
- package/dist/cli/program.d.cts +7 -0
- package/dist/cli/program.d.ts +7 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +3 -93
- package/dist/cli.js.map +1 -1
- package/dist/codeGenerator-Ba5Cz8XW.cjs +31 -0
- package/dist/codeGenerator-Ba5Cz8XW.cjs.map +1 -0
- package/dist/{codeGenerator-CsWf0pZy.js → codeGenerator-CXBTLKZP.js} +1059 -613
- package/dist/codeGenerator-CXBTLKZP.js.map +1 -0
- package/dist/emitters/manifestClients.d.cts +15 -0
- package/dist/emitters/manifestClients.d.ts +15 -0
- package/dist/fetcherGeneratorCli.cjs +3 -0
- package/dist/fetcherGeneratorCli.cjs.map +1 -0
- package/dist/fetcherGeneratorCli.d.cts +8 -0
- package/dist/fetcherGeneratorCli.d.ts +8 -0
- package/dist/fetcherGeneratorCli.js +6 -0
- package/dist/fetcherGeneratorCli.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/input/parsers.d.cts +13 -0
- package/dist/input/parsers.d.ts +13 -0
- package/dist/manifest/analyze.d.cts +132 -0
- package/dist/manifest/analyze.d.ts +132 -0
- package/dist/manifest/document.d.cts +89 -0
- package/dist/manifest/document.d.ts +89 -0
- package/dist/pipeline/codeGenerator.d.cts +7 -0
- package/dist/pipeline/codeGenerator.d.ts +7 -0
- package/dist/program-BnfzUfUQ.cjs +10 -0
- package/dist/program-BnfzUfUQ.cjs.map +1 -0
- package/dist/program-CU0GCZqM.js +103 -0
- package/dist/program-CU0GCZqM.js.map +1 -0
- package/package.json +5 -5
- package/dist/codeGenerator-BMyiC0tW.cjs +0 -23
- package/dist/codeGenerator-BMyiC0tW.cjs.map +0 -1
- package/dist/codeGenerator-CsWf0pZy.js.map +0 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { CodeBlockWriter as e, IndentationText as t, Node as n, Project as r, QuoteKind as i, Scope as a, StructureKind as o, SyntaxKind as s, VariableDeclarationKind as c, ts as l } from "ts-morph";
|
|
2
2
|
import { isAbsolute as u, join as d, relative as f, resolve as p, sep as m } from "path";
|
|
3
|
-
import { parse as
|
|
4
|
-
import { readFile as
|
|
3
|
+
import { parse as h } from "yaml";
|
|
4
|
+
import { readFile as ee } from "fs";
|
|
5
|
+
import { join as te } from "node:path";
|
|
5
6
|
//#region src/api/configuration.ts
|
|
6
|
-
var
|
|
7
|
+
var ne = "./wow-generator.config.json", g = {
|
|
7
8
|
success: 0,
|
|
8
9
|
internal: 1,
|
|
9
10
|
input: 2,
|
|
@@ -25,14 +26,14 @@ function v(e) {
|
|
|
25
26
|
}
|
|
26
27
|
//#endregion
|
|
27
28
|
//#region src/api/logger.ts
|
|
28
|
-
function
|
|
29
|
+
function re() {
|
|
29
30
|
return !!process.stdout?.isTTY && !process.env.NO_COLOR;
|
|
30
31
|
}
|
|
31
|
-
var
|
|
32
|
+
var ie = class {
|
|
32
33
|
level;
|
|
33
34
|
decorate;
|
|
34
35
|
constructor(e = {}) {
|
|
35
|
-
this.level = e.level ?? "normal", this.decorate = e.decorate ??
|
|
36
|
+
this.level = e.level ?? "normal", this.decorate = e.decorate ?? re();
|
|
36
37
|
}
|
|
37
38
|
format(e, t, n) {
|
|
38
39
|
let r = this.decorate ? `${e} ` : t ? `${t}: ` : "";
|
|
@@ -50,31 +51,31 @@ var re = class {
|
|
|
50
51
|
error(e, ...t) {
|
|
51
52
|
console.error(this.format("❌", "error", e), ...t);
|
|
52
53
|
}
|
|
53
|
-
},
|
|
54
|
+
}, ae = class {
|
|
54
55
|
debug() {}
|
|
55
56
|
info() {}
|
|
56
57
|
warn() {}
|
|
57
58
|
error() {}
|
|
58
|
-
},
|
|
59
|
+
}, oe = /[^\p{L}\p{N}$]+/u, se = /* @__PURE__ */ new Set(/* @__PURE__ */ "arguments.await.break.case.catch.class.const.continue.debugger.default.delete.do.else.enum.eval.export.extends.false.finally.for.function.if.implements.import.in.instanceof.interface.let.new.null.package.private.protected.public.return.static.super.switch.this.throw.true.try.typeof.var.void.while.with.yield".split("."));
|
|
59
60
|
function y(e) {
|
|
60
|
-
return /^[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*$/u.test(e) && !
|
|
61
|
+
return /^[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*$/u.test(e) && !se.has(e);
|
|
61
62
|
}
|
|
62
|
-
function
|
|
63
|
+
function ce(e) {
|
|
63
64
|
return /^\p{N}/u.test(e) ? `_${e}` : e;
|
|
64
65
|
}
|
|
65
|
-
function
|
|
66
|
+
function le(e) {
|
|
66
67
|
if (y(e)) return e;
|
|
67
|
-
let t =
|
|
68
|
-
return
|
|
68
|
+
let t = ce(S(e) || "_");
|
|
69
|
+
return se.has(t) ? `${t}_` : t;
|
|
69
70
|
}
|
|
70
|
-
function
|
|
71
|
+
function ue(e) {
|
|
71
72
|
return /^\p{Lu}[\p{L}\p{N}$]*$/u.test(e) && y(e);
|
|
72
73
|
}
|
|
73
|
-
function
|
|
74
|
-
return
|
|
74
|
+
function b(e) {
|
|
75
|
+
return ce((Array.isArray(e) ? e : [e]).map((e) => ue(e) ? e : x(e)).join("") || "_");
|
|
75
76
|
}
|
|
76
77
|
function de(e) {
|
|
77
|
-
return e.split(
|
|
78
|
+
return e.split(oe);
|
|
78
79
|
}
|
|
79
80
|
function fe(e) {
|
|
80
81
|
return Array.isArray(e) ? e.flatMap((e) => pe(de(e))) : pe(de(e));
|
|
@@ -90,40 +91,40 @@ function pe(e) {
|
|
|
90
91
|
return n && t.push(n), t;
|
|
91
92
|
});
|
|
92
93
|
}
|
|
93
|
-
function
|
|
94
|
+
function x(e) {
|
|
94
95
|
return e === "" || e.length === 0 ? "" : fe(e).filter((e) => e.length > 0).map((e) => {
|
|
95
96
|
let t = e.charAt(0), n = e.slice(1);
|
|
96
97
|
return (/[a-zA-Z]/.test(t) ? t.toUpperCase() : t) + n.toLowerCase();
|
|
97
98
|
}).join("");
|
|
98
99
|
}
|
|
99
|
-
function
|
|
100
|
-
let t =
|
|
100
|
+
function S(e) {
|
|
101
|
+
let t = x(e);
|
|
101
102
|
return t.charAt(0).toLowerCase() + t.slice(1);
|
|
102
103
|
}
|
|
103
|
-
function
|
|
104
|
+
function C(e) {
|
|
104
105
|
return e === "" || Array.isArray(e) && e.length === 0 ? "" : fe(e).filter((e) => e.length > 0).map((e) => e.toUpperCase()).join("_");
|
|
105
106
|
}
|
|
106
|
-
function
|
|
107
|
-
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e) ? e :
|
|
107
|
+
function w(e) {
|
|
108
|
+
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e) ? e : T(e);
|
|
108
109
|
}
|
|
109
|
-
function
|
|
110
|
-
return /^\d+$/.test(e) ? `NUM_${e}` :
|
|
110
|
+
function me(e) {
|
|
111
|
+
return /^\d+$/.test(e) ? `NUM_${e}` : C(e) || e;
|
|
111
112
|
}
|
|
112
|
-
function
|
|
113
|
+
function T(e) {
|
|
113
114
|
return `'${JSON.stringify(e).slice(1, -1).replace(/\\"/g, "\"").replace(/'/g, "\\'")}'`;
|
|
114
115
|
}
|
|
115
116
|
//#endregion
|
|
116
117
|
//#region src/naming/order.ts
|
|
117
|
-
var
|
|
118
|
-
function
|
|
119
|
-
return
|
|
118
|
+
var he = new Intl.Collator("en-US");
|
|
119
|
+
function E(e, t) {
|
|
120
|
+
return he.compare(e, t);
|
|
120
121
|
}
|
|
121
122
|
//#endregion
|
|
122
123
|
//#region src/openapi/references.ts
|
|
123
|
-
function
|
|
124
|
+
function D(e) {
|
|
124
125
|
return !!(e && typeof e == "object" && "$ref" in e);
|
|
125
126
|
}
|
|
126
|
-
function
|
|
127
|
+
function ge(e, t) {
|
|
127
128
|
let n = t.slice(1);
|
|
128
129
|
try {
|
|
129
130
|
n = decodeURIComponent(n);
|
|
@@ -138,7 +139,7 @@ function ve(e, t) {
|
|
|
138
139
|
}
|
|
139
140
|
return r;
|
|
140
141
|
}
|
|
141
|
-
function
|
|
142
|
+
function _e(e) {
|
|
142
143
|
let t = [], n = /* @__PURE__ */ new Set(), r = (i, a) => {
|
|
143
144
|
if (typeof i != "object" || !i || n.has(i)) return;
|
|
144
145
|
if (n.add(i), Array.isArray(i)) {
|
|
@@ -146,7 +147,7 @@ function ye(e) {
|
|
|
146
147
|
return;
|
|
147
148
|
}
|
|
148
149
|
let o = i.$ref;
|
|
149
|
-
typeof o == "string" && o.startsWith("#/components/") &&
|
|
150
|
+
typeof o == "string" && o.startsWith("#/components/") && ge(e, o) === void 0 && t.push({
|
|
150
151
|
ref: o,
|
|
151
152
|
location: a || "/"
|
|
152
153
|
});
|
|
@@ -156,127 +157,127 @@ function ye(e) {
|
|
|
156
157
|
}
|
|
157
158
|
//#endregion
|
|
158
159
|
//#region src/openapi/components.ts
|
|
159
|
-
var
|
|
160
|
-
function
|
|
160
|
+
var O = "#/components/", ve = `${O}parameters/`, ye = `${O}requestBodies/`, be = `${O}responses/`, xe = `${O}schemas/`;
|
|
161
|
+
function Se(e) {
|
|
161
162
|
return e.$ref.split("/").pop();
|
|
162
163
|
}
|
|
163
|
-
function
|
|
164
|
+
function k(e, t, n) {
|
|
164
165
|
let r = /* @__PURE__ */ new Set(), i = e;
|
|
165
|
-
for (;
|
|
166
|
+
for (; D(i);) {
|
|
166
167
|
if (!i.$ref.startsWith(n)) return;
|
|
167
168
|
if (r.has(i.$ref)) throw new _("specification", `Cyclic component reference: ${i.$ref}`);
|
|
168
169
|
r.add(i.$ref), i = t?.[i.$ref.slice(n.length)];
|
|
169
170
|
}
|
|
170
171
|
return i;
|
|
171
172
|
}
|
|
172
|
-
function
|
|
173
|
-
return
|
|
173
|
+
function A(e, t) {
|
|
174
|
+
return k(e, t.schemas, xe);
|
|
174
175
|
}
|
|
175
176
|
function Ce(e, t) {
|
|
176
|
-
return
|
|
177
|
+
return k(e, t.responses, be);
|
|
177
178
|
}
|
|
178
179
|
function we(e, t) {
|
|
179
|
-
return
|
|
180
|
+
return k(e, t.requestBodies, ye);
|
|
180
181
|
}
|
|
181
182
|
function Te(e, t) {
|
|
182
|
-
return
|
|
183
|
+
return k(e, t.parameters, ve);
|
|
183
184
|
}
|
|
184
|
-
function
|
|
185
|
+
function j(e, t) {
|
|
185
186
|
return {
|
|
186
|
-
key:
|
|
187
|
-
schema:
|
|
187
|
+
key: Se(e),
|
|
188
|
+
schema: A(e, t)
|
|
188
189
|
};
|
|
189
190
|
}
|
|
190
191
|
//#endregion
|
|
191
192
|
//#region src/openapi/responses.ts
|
|
192
|
-
var
|
|
193
|
-
function
|
|
193
|
+
var Ee = "application/json", De = "text/event-stream";
|
|
194
|
+
function Oe(e) {
|
|
194
195
|
return e.split(";")[0].trim().toLowerCase();
|
|
195
196
|
}
|
|
196
|
-
function
|
|
197
|
-
let t =
|
|
197
|
+
function ke(e) {
|
|
198
|
+
let t = Oe(e);
|
|
198
199
|
return t === "application/json" || /^application\/[^/]+\+json$/.test(t);
|
|
199
200
|
}
|
|
200
|
-
function
|
|
201
|
-
let t =
|
|
201
|
+
function Ae(e) {
|
|
202
|
+
let t = Oe(e);
|
|
202
203
|
return t.startsWith("text/") && t !== "text/event-stream";
|
|
203
204
|
}
|
|
204
|
-
function M(e, t, n = (e) =>
|
|
205
|
+
function M(e, t, n = (e) => Oe(e) === t) {
|
|
205
206
|
if (!e) return;
|
|
206
207
|
if (e[t]) return e[t];
|
|
207
208
|
let r = Object.keys(e).find(n);
|
|
208
209
|
return r === void 0 ? void 0 : e[r];
|
|
209
210
|
}
|
|
210
|
-
function
|
|
211
|
-
if (t && !
|
|
212
|
-
}
|
|
213
|
-
function je(e) {
|
|
214
|
-
if (e && !w(e)) return M(e.content, j, Oe)?.schema;
|
|
211
|
+
function je(e, t) {
|
|
212
|
+
if (t && !D(t)) return M(t.content, e)?.schema;
|
|
215
213
|
}
|
|
216
214
|
function Me(e) {
|
|
217
|
-
return
|
|
215
|
+
if (e && !D(e)) return M(e.content, Ee, ke)?.schema;
|
|
218
216
|
}
|
|
219
217
|
function Ne(e) {
|
|
220
|
-
return
|
|
218
|
+
return je(De, e);
|
|
221
219
|
}
|
|
222
220
|
function Pe(e) {
|
|
223
|
-
return
|
|
221
|
+
return je("*/*", e);
|
|
222
|
+
}
|
|
223
|
+
function Fe(e) {
|
|
224
|
+
return !e || D(e) ? !1 : Object.keys(e.content ?? {}).some(Ae);
|
|
224
225
|
}
|
|
225
226
|
//#endregion
|
|
226
227
|
//#region src/openapi/schemas.ts
|
|
227
|
-
var
|
|
228
|
+
var Ie = [
|
|
228
229
|
"string",
|
|
229
230
|
"number",
|
|
230
231
|
"integer",
|
|
231
232
|
"boolean",
|
|
232
233
|
"null"
|
|
233
234
|
];
|
|
234
|
-
function
|
|
235
|
-
return Array.isArray(e) ? !0 :
|
|
235
|
+
function Le(e) {
|
|
236
|
+
return Array.isArray(e) ? !0 : Ie.includes(e);
|
|
236
237
|
}
|
|
237
|
-
function
|
|
238
|
+
function Re(e) {
|
|
238
239
|
return Array.isArray(e.enum) && e.enum.length > 0;
|
|
239
240
|
}
|
|
240
|
-
var
|
|
241
|
-
function
|
|
242
|
-
return e[
|
|
241
|
+
var ze = "x-enum-text";
|
|
242
|
+
function Be(e) {
|
|
243
|
+
return e[ze];
|
|
243
244
|
}
|
|
244
|
-
function
|
|
245
|
+
function Ve(e) {
|
|
245
246
|
return e.type === "object" && !!e.properties;
|
|
246
247
|
}
|
|
247
|
-
function
|
|
248
|
+
function He(e) {
|
|
248
249
|
return e.type === "array" && !!e.items;
|
|
249
250
|
}
|
|
250
|
-
function
|
|
251
|
+
function Ue(e) {
|
|
251
252
|
return Array.isArray(e.anyOf) && e.anyOf.length > 0;
|
|
252
253
|
}
|
|
253
|
-
function
|
|
254
|
+
function We(e) {
|
|
254
255
|
return Array.isArray(e.oneOf) && e.oneOf.length > 0;
|
|
255
256
|
}
|
|
256
|
-
function
|
|
257
|
+
function Ge(e) {
|
|
257
258
|
return Array.isArray(e.allOf) && e.allOf.length > 0;
|
|
258
259
|
}
|
|
259
|
-
function
|
|
260
|
-
return
|
|
260
|
+
function N(e) {
|
|
261
|
+
return Ue(e) || We(e) || Ge(e);
|
|
261
262
|
}
|
|
262
|
-
function
|
|
263
|
+
function Ke(e) {
|
|
263
264
|
return e.includes("|") || e.includes("&") ? `(${e})[]` : `${e}[]`;
|
|
264
265
|
}
|
|
265
|
-
function
|
|
266
|
+
function qe(e) {
|
|
266
267
|
return e.type === "object" && !e.properties && e.additionalProperties !== void 0;
|
|
267
268
|
}
|
|
268
|
-
var
|
|
269
|
-
function
|
|
270
|
-
return e[
|
|
269
|
+
var Je = "x-map-key-schema";
|
|
270
|
+
function Ye(e) {
|
|
271
|
+
return e[Je];
|
|
271
272
|
}
|
|
272
|
-
function
|
|
273
|
+
function Xe(e) {
|
|
273
274
|
return e.type === "object" ? !e.properties || Object.keys(e.properties).length === 0 : !1;
|
|
274
275
|
}
|
|
275
|
-
function
|
|
276
|
+
function Ze(e) {
|
|
276
277
|
return e.readOnly === !0;
|
|
277
278
|
}
|
|
278
|
-
function
|
|
279
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
279
|
+
function P(e) {
|
|
280
|
+
if (Array.isArray(e)) return e.map((e) => P(e)).join(" | ");
|
|
280
281
|
switch (e) {
|
|
281
282
|
case "string": return "string";
|
|
282
283
|
case "number":
|
|
@@ -286,10 +287,10 @@ function I(e) {
|
|
|
286
287
|
default: return "any";
|
|
287
288
|
}
|
|
288
289
|
}
|
|
289
|
-
function
|
|
290
|
+
function Qe(e, t) {
|
|
290
291
|
let n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = !1, o = (e) => {
|
|
291
292
|
if (!(!e || i.has(e) || a)) {
|
|
292
|
-
if (i.add(e),
|
|
293
|
+
if (i.add(e), D(e)) o(t && A(e, t));
|
|
293
294
|
else if (e.nullable || Array.isArray(e.type)) a = !0;
|
|
294
295
|
else {
|
|
295
296
|
for (let t of e.required ?? []) r.add(t);
|
|
@@ -302,32 +303,32 @@ function Ye(e, t) {
|
|
|
302
303
|
}
|
|
303
304
|
//#endregion
|
|
304
305
|
//#region src/openapi/operations.ts
|
|
305
|
-
function
|
|
306
|
-
return e.operation.operationId && t.operation.operationId ?
|
|
306
|
+
function $e(e, t) {
|
|
307
|
+
return e.operation.operationId && t.operation.operationId ? E(e.operation.operationId, t.operation.operationId) : e.path && t.path ? E(e.path, t.path) : e.method && t.method ? E(e.method, t.method) : 0;
|
|
307
308
|
}
|
|
308
|
-
function
|
|
309
|
+
function et(e, t, n) {
|
|
309
310
|
let r = /* @__PURE__ */ new Map();
|
|
310
311
|
for (let i of [...e, ...t]) {
|
|
311
|
-
let e =
|
|
312
|
+
let e = D(i) ? n && Te(i, n) : i, t = e ? `${e.in}:${e.name}` : i.$ref;
|
|
312
313
|
r.set(t, i);
|
|
313
314
|
}
|
|
314
315
|
return [...r.values()];
|
|
315
316
|
}
|
|
316
|
-
function
|
|
317
|
+
function tt(e, t) {
|
|
317
318
|
let n = [];
|
|
318
|
-
for (let [r, i] of Object.entries(e))
|
|
319
|
+
for (let [r, i] of Object.entries(e)) nt(i).forEach((e) => {
|
|
319
320
|
n.push({
|
|
320
321
|
method: e.method,
|
|
321
322
|
operation: i.parameters?.length ? {
|
|
322
323
|
...e.operation,
|
|
323
|
-
parameters:
|
|
324
|
+
parameters: et(i.parameters, e.operation.parameters ?? [], t)
|
|
324
325
|
} : e.operation,
|
|
325
326
|
path: r
|
|
326
327
|
});
|
|
327
328
|
});
|
|
328
|
-
return n.sort(
|
|
329
|
+
return n.sort($e);
|
|
329
330
|
}
|
|
330
|
-
function
|
|
331
|
+
function nt(e) {
|
|
331
332
|
return [
|
|
332
333
|
{
|
|
333
334
|
method: "get",
|
|
@@ -363,60 +364,60 @@ function $e(e) {
|
|
|
363
364
|
}
|
|
364
365
|
].filter(({ operation: e }) => e !== void 0);
|
|
365
366
|
}
|
|
366
|
-
function
|
|
367
|
+
function rt(e) {
|
|
367
368
|
let t = Object.keys(e.responses ?? {});
|
|
368
369
|
if (t.includes("200")) return "200";
|
|
369
370
|
let n = t.filter((e) => /^2\d\d$/.test(e)).sort();
|
|
370
371
|
return n.length > 0 ? n[0] : t.find((e) => e.toUpperCase() === "2XX");
|
|
371
372
|
}
|
|
372
|
-
function
|
|
373
|
-
let n =
|
|
374
|
-
return t &&
|
|
373
|
+
function it(e, t) {
|
|
374
|
+
let n = rt(e), r = n ? e.responses[n] : void 0;
|
|
375
|
+
return t && D(r) ? Ce(r, t) : r;
|
|
375
376
|
}
|
|
376
|
-
function
|
|
377
|
-
return
|
|
377
|
+
function at(e, t) {
|
|
378
|
+
return Me(it(e, t));
|
|
378
379
|
}
|
|
379
|
-
function
|
|
380
|
-
return (e.parameters ?? []).map((e) =>
|
|
380
|
+
function ot(e, t) {
|
|
381
|
+
return (e.parameters ?? []).map((e) => D(e) ? Te(e, t) : e).filter((e) => e !== void 0);
|
|
381
382
|
}
|
|
382
|
-
function
|
|
383
|
-
return e.parameters ? e.parameters.map((e) =>
|
|
383
|
+
function st(e, t) {
|
|
384
|
+
return e.parameters ? e.parameters.map((e) => D(e) ? Te(e, t) : e).filter((e) => e?.in === "path") : [];
|
|
384
385
|
}
|
|
385
|
-
function
|
|
386
|
+
function ct(e, t) {
|
|
386
387
|
let n = (t) => {
|
|
387
388
|
let n = e.indexOf(`{${t.name}}`);
|
|
388
389
|
return n < 0 ? 2 ** 53 - 1 : n;
|
|
389
390
|
};
|
|
390
391
|
return [...t].sort((e, t) => n(e) - n(t));
|
|
391
392
|
}
|
|
392
|
-
var
|
|
393
|
-
function
|
|
394
|
-
return !e.schema ||
|
|
393
|
+
var lt = "string";
|
|
394
|
+
function ut(e) {
|
|
395
|
+
return !e.schema || D(e.schema) || !e.schema.type || !Le(e.schema.type) ? lt : P(e.schema.type);
|
|
395
396
|
}
|
|
396
397
|
//#endregion
|
|
397
398
|
//#region src/wow/conventions.ts
|
|
398
|
-
var
|
|
399
|
-
function
|
|
400
|
-
return e.info[
|
|
399
|
+
var dt = "8.10", ft = "x-wow-context-alias";
|
|
400
|
+
function pt(e) {
|
|
401
|
+
return e.info[ft];
|
|
401
402
|
}
|
|
402
|
-
function
|
|
403
|
+
function mt(e) {
|
|
403
404
|
let t = e.split(".");
|
|
404
405
|
return t.length != 2 || t[0].length === 0 || t[1].length === 0 ? null : t;
|
|
405
406
|
}
|
|
406
|
-
function
|
|
407
|
-
let t =
|
|
407
|
+
function ht(e) {
|
|
408
|
+
let t = mt(e.name);
|
|
408
409
|
return t ? {
|
|
409
410
|
tag: e,
|
|
410
411
|
contextAlias: t[0],
|
|
411
412
|
aggregateName: t[1]
|
|
412
413
|
} : null;
|
|
413
414
|
}
|
|
414
|
-
function
|
|
415
|
+
function gt(e) {
|
|
415
416
|
if (!e) return null;
|
|
416
417
|
let t = e.split(".");
|
|
417
418
|
return t.length == 3 ? t[2] : null;
|
|
418
419
|
}
|
|
419
|
-
var
|
|
420
|
+
var _t = ".snapshot_state.single", vt = ".snapshot.count", yt = "x-wow-query-fields", bt = /^(?:\/tenant\/\{tenantId\})?(?:\/owner\/\{ownerId\})?\/(.+?)\/snapshot(?:\/|$)/, xt = [
|
|
420
421
|
"MaterializedSnapshot",
|
|
421
422
|
"MaterializedSnapshotPagedList",
|
|
422
423
|
"MaterializedSnapshotCursorPage",
|
|
@@ -426,19 +427,19 @@ var mt = ".snapshot_state.single", ht = ".snapshot.count", gt = "x-wow-query-fie
|
|
|
426
427
|
"Snapshot",
|
|
427
428
|
"StateEvent"
|
|
428
429
|
];
|
|
429
|
-
function
|
|
430
|
-
return
|
|
430
|
+
function St(e) {
|
|
431
|
+
return xt.map((t) => e + t);
|
|
431
432
|
}
|
|
432
|
-
function
|
|
433
|
+
function Ct(e, t, n) {
|
|
433
434
|
return e !== "wow.api.query.PagedList" && e.startsWith("wow.api.query.") && e.endsWith("PagedList") || e.startsWith("wow.api.query.Operator") && e.endsWith("Map") ? !1 : e.startsWith("wow.") || e.endsWith("AggregatedCondition") || e.endsWith("AggregatedDomainEventStream") || e.endsWith("AggregatedDomainEventStreamPagedList") || e.endsWith("AggregatedDomainEventStreamCursorPage") || e.endsWith("AggregatedDomainEventStreamServerSentEventNonNullData") || e.endsWith("AggregatedListQuery") || e.endsWith("AggregatedPagedQuery") || e.endsWith("AggregatedSingleQuery") ? !0 : n.has(t());
|
|
434
435
|
}
|
|
435
|
-
var
|
|
436
|
+
var F = "@ahoo-wang/wow-client", wt = "@ahoo-wang/wow-client/legacy", Tt = /* @__PURE__ */ new Set([
|
|
436
437
|
"Condition",
|
|
437
438
|
"ConditionOptions",
|
|
438
439
|
"ListQuery",
|
|
439
440
|
"Operator",
|
|
440
441
|
"PagedQuery"
|
|
441
|
-
]),
|
|
442
|
+
]), Et = {
|
|
442
443
|
"wow.command.CommandResult": "CommandResult",
|
|
443
444
|
"wow.command.CommandResultArray": "CommandResultArray",
|
|
444
445
|
"wow.MessageHeaderSqlType": "MessageHeaderSqlType",
|
|
@@ -471,15 +472,15 @@ var L = "@ahoo-wang/wow-client", xt = "@ahoo-wang/wow-client/legacy", St = /* @_
|
|
|
471
472
|
"wow.openapi.BatchResult": "BatchResult",
|
|
472
473
|
"wow.messaging.CompensationTarget": "CompensationTarget"
|
|
473
474
|
};
|
|
474
|
-
function
|
|
475
|
-
let n =
|
|
475
|
+
function Dt(e, t) {
|
|
476
|
+
let n = Et[e];
|
|
476
477
|
if (t && "filter" in t && (e === "wow.api.query.ListQuery" ? n = "FilterListQuery" : e === "wow.api.query.PagedQuery" && (n = "FilterPagedQuery")), n) return {
|
|
477
478
|
name: n,
|
|
478
|
-
path:
|
|
479
|
+
path: Tt.has(n) ? wt : F
|
|
479
480
|
};
|
|
480
481
|
}
|
|
481
|
-
var
|
|
482
|
-
function
|
|
482
|
+
var Ot = /* @__PURE__ */ new Set(["wow", "Actuator"]), kt = ["tenantId", "ownerId"];
|
|
483
|
+
function At(e) {
|
|
483
484
|
let t = 0, n = 0;
|
|
484
485
|
return e.commands.forEach((e) => {
|
|
485
486
|
e.path.startsWith("/tenant/{tenantId}") && (t += 1), e.path.startsWith("/owner/{ownerId}") && (n += 1);
|
|
@@ -487,39 +488,39 @@ function Dt(e) {
|
|
|
487
488
|
}
|
|
488
489
|
//#endregion
|
|
489
490
|
//#region src/analysis/clientNames.ts
|
|
490
|
-
function
|
|
491
|
+
function jt(e, t) {
|
|
491
492
|
return `${e.contextAlias}/${e.aggregateName}/${t}.ts`;
|
|
492
493
|
}
|
|
493
|
-
function
|
|
494
|
-
return `${
|
|
494
|
+
function I(e, t) {
|
|
495
|
+
return `${b(e.aggregateName)}${t}`;
|
|
495
496
|
}
|
|
496
|
-
var
|
|
497
|
-
function
|
|
497
|
+
var Mt = "x-fetcher-method";
|
|
498
|
+
function Nt(e, t) {
|
|
498
499
|
let n = t ?? e["x-fetcher-method"];
|
|
499
500
|
if (n !== void 0) {
|
|
500
|
-
if (typeof n != "string" || !
|
|
501
|
+
if (typeof n != "string" || !Pt(n)) throw new _("specification", `${Mt} of ${e.operationId ?? "an operation"} is ${JSON.stringify(n)}, which is not a valid method name.`);
|
|
501
502
|
return n;
|
|
502
503
|
}
|
|
503
504
|
if (!e.operationId) return;
|
|
504
|
-
let r =
|
|
505
|
+
let r = S(e.operationId.split(".").pop()) || "_";
|
|
505
506
|
return /^\p{N}/u.test(r) ? `_${r}` : r;
|
|
506
507
|
}
|
|
507
|
-
function
|
|
508
|
+
function Pt(e) {
|
|
508
509
|
return y(e) || /^[a-z]+$/.test(e);
|
|
509
510
|
}
|
|
510
|
-
function
|
|
511
|
-
let n =
|
|
511
|
+
function Ft(e, t) {
|
|
512
|
+
let n = le(e), r = n;
|
|
512
513
|
for (let e = 2; t.has(r); e++) r = `${n}${e}`;
|
|
513
514
|
return t.add(r), r;
|
|
514
515
|
}
|
|
515
516
|
//#endregion
|
|
516
517
|
//#region src/analysis/modelInfo.ts
|
|
517
|
-
function
|
|
518
|
+
function L(e, t) {
|
|
518
519
|
if (!e) return {
|
|
519
520
|
name: "",
|
|
520
521
|
path: "/"
|
|
521
522
|
};
|
|
522
|
-
let n =
|
|
523
|
+
let n = Dt(e, t?.properties);
|
|
523
524
|
if (n) return n;
|
|
524
525
|
let r = e.split("."), i = -1;
|
|
525
526
|
for (let e = 0; e < r.length; e++) if (r[e] && /^[A-Z]/.test(r[e])) {
|
|
@@ -528,60 +529,60 @@ function z(e, t) {
|
|
|
528
529
|
}
|
|
529
530
|
let a = r.slice(0, i), o = a.length > 0 ? `/${a.join("/")}` : "/";
|
|
530
531
|
return {
|
|
531
|
-
name:
|
|
532
|
+
name: b(r.slice(i)),
|
|
532
533
|
path: o
|
|
533
534
|
};
|
|
534
535
|
}
|
|
535
|
-
function
|
|
536
|
-
if (!e.$ref.startsWith(
|
|
537
|
-
return
|
|
536
|
+
function It(e, t) {
|
|
537
|
+
if (!e.$ref.startsWith(xe)) throw new _("specification", `Unsupported schema reference: ${e.$ref}. Bundle or inline external schemas before generation.`);
|
|
538
|
+
return L(Se(e), t ? A(e, t) : void 0);
|
|
538
539
|
}
|
|
539
|
-
function
|
|
540
|
-
let t = `${
|
|
540
|
+
function Lt(e) {
|
|
541
|
+
let t = `${C(e)}_BOUNDED_CONTEXT_ALIAS`;
|
|
541
542
|
return /^\p{N}/u.test(t) ? `_${t}` : t;
|
|
542
543
|
}
|
|
543
544
|
//#endregion
|
|
544
545
|
//#region src/analysis/aggregates.ts
|
|
545
|
-
var
|
|
546
|
-
function
|
|
547
|
-
return [...t.contexts.values()].flatMap((t) => [...t].map((t) =>
|
|
546
|
+
var Rt = "Command";
|
|
547
|
+
function zt(e, t) {
|
|
548
|
+
return [...t.contexts.values()].flatMap((t) => [...t].map((t) => Bt(e, t)));
|
|
548
549
|
}
|
|
549
|
-
function
|
|
550
|
+
function Bt(e, t) {
|
|
550
551
|
let { contextAlias: n, aggregateName: r } = t.aggregate;
|
|
551
552
|
return {
|
|
552
553
|
contextAlias: n,
|
|
553
554
|
aggregateName: r,
|
|
554
555
|
context: {
|
|
555
556
|
alias: n,
|
|
556
|
-
constantName:
|
|
557
|
+
constantName: Lt(n)
|
|
557
558
|
},
|
|
558
|
-
commandClient:
|
|
559
|
-
queryClient:
|
|
559
|
+
commandClient: Vt(e, t),
|
|
560
|
+
queryClient: Kt(t)
|
|
560
561
|
};
|
|
561
562
|
}
|
|
562
|
-
function
|
|
563
|
-
let n = t.aggregate, r =
|
|
563
|
+
function Vt(e, t) {
|
|
564
|
+
let n = t.aggregate, r = Wt(t);
|
|
564
565
|
return {
|
|
565
|
-
file:
|
|
566
|
-
endpointPathsName:
|
|
567
|
-
className:
|
|
568
|
-
streamClassName:
|
|
566
|
+
file: jt(n, "commandClient"),
|
|
567
|
+
endpointPathsName: I(n, "CommandEndpointPaths"),
|
|
568
|
+
className: I(n, "CommandClient"),
|
|
569
|
+
streamClassName: I(n, "StreamCommandClient"),
|
|
569
570
|
commands: [...t.commands.values()].map((t) => {
|
|
570
|
-
let n =
|
|
571
|
+
let n = L(t.schema.key), i = /* @__PURE__ */ new Set(["commandRequest", "attributes"]);
|
|
571
572
|
return {
|
|
572
573
|
path: t.path,
|
|
573
574
|
endpointMember: r.get(t),
|
|
574
575
|
httpMethod: t.method,
|
|
575
|
-
methodName:
|
|
576
|
-
typeName:
|
|
576
|
+
methodName: Gt(t),
|
|
577
|
+
typeName: Ht(n),
|
|
577
578
|
body: n,
|
|
578
579
|
bodyKey: t.schema.key,
|
|
579
|
-
optionalFields:
|
|
580
|
-
requestOptional:
|
|
581
|
-
pathParameters:
|
|
582
|
-
name:
|
|
580
|
+
optionalFields: Qe(t.schema.schema, e.components),
|
|
581
|
+
requestOptional: Xe(t.schema.schema),
|
|
582
|
+
pathParameters: ct(t.path, t.pathParameters).filter((e) => !kt.includes(e.name)).map((e) => ({
|
|
583
|
+
name: Ft(e.name, i),
|
|
583
584
|
pathName: e.name,
|
|
584
|
-
type:
|
|
585
|
+
type: ut(e)
|
|
585
586
|
})),
|
|
586
587
|
docs: [
|
|
587
588
|
t.summary,
|
|
@@ -593,10 +594,10 @@ function Rt(e, t) {
|
|
|
593
594
|
})
|
|
594
595
|
};
|
|
595
596
|
}
|
|
596
|
-
function
|
|
597
|
-
return e.path === "@ahoo-wang/wow-client" ? `${e.name}Command` : e.name.endsWith(
|
|
597
|
+
function Ht(e) {
|
|
598
|
+
return e.path === "@ahoo-wang/wow-client" ? `${e.name}Command` : e.name.endsWith(Rt) ? void 0 : `${e.name}${Rt}`;
|
|
598
599
|
}
|
|
599
|
-
function
|
|
600
|
+
function Ut(e, t) {
|
|
600
601
|
for (let n of e) {
|
|
601
602
|
let e = `/${n.contextAlias}/${n.aggregateName}`, r = /* @__PURE__ */ new Map();
|
|
602
603
|
for (let n of t) n.info.path === e && r.set(n.info.name, {
|
|
@@ -620,7 +621,7 @@ function Bt(e, t) {
|
|
|
620
621
|
}
|
|
621
622
|
}
|
|
622
623
|
}
|
|
623
|
-
function
|
|
624
|
+
function Wt(e) {
|
|
624
625
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
|
|
625
626
|
for (let r of e.commands.values()) {
|
|
626
627
|
let e = r.name.toUpperCase().replace(/[^\p{L}\p{N}_$]/gu, "_");
|
|
@@ -631,46 +632,46 @@ function Vt(e) {
|
|
|
631
632
|
}
|
|
632
633
|
return t;
|
|
633
634
|
}
|
|
634
|
-
function
|
|
635
|
-
let t =
|
|
635
|
+
function Gt(e) {
|
|
636
|
+
let t = S(e.name) || "_";
|
|
636
637
|
return /^\p{N}/u.test(t) ? `_${t}` : t;
|
|
637
638
|
}
|
|
638
|
-
function
|
|
639
|
-
let t = e.aggregate, n =
|
|
639
|
+
function Kt(e) {
|
|
640
|
+
let t = e.aggregate, n = S(t.aggregateName) || "_";
|
|
640
641
|
return {
|
|
641
|
-
file:
|
|
642
|
+
file: jt(t, "queryClient"),
|
|
642
643
|
resourceName: e.resourceName,
|
|
643
|
-
resourceAttribution:
|
|
644
|
-
state:
|
|
645
|
-
fields:
|
|
646
|
-
eventTitlesName:
|
|
647
|
-
eventTypeName:
|
|
644
|
+
resourceAttribution: At(e),
|
|
645
|
+
state: L(e.state.key),
|
|
646
|
+
fields: L(e.fields.key),
|
|
647
|
+
eventTitlesName: I(t, "DomainEventTypeMapTitle"),
|
|
648
|
+
eventTypeName: I(t, "DomainEventType"),
|
|
648
649
|
events: [...e.events.values()].map((e) => ({
|
|
649
|
-
memberName:
|
|
650
|
+
memberName: w(e.name),
|
|
650
651
|
title: e.title,
|
|
651
|
-
body:
|
|
652
|
+
body: L(e.schema.key)
|
|
652
653
|
})),
|
|
653
654
|
factoryName: `${/^\p{N}/u.test(n) ? "_" : ""}${n}QueryClientFactory`
|
|
654
655
|
};
|
|
655
656
|
}
|
|
656
657
|
//#endregion
|
|
657
658
|
//#region src/naming/paths.ts
|
|
658
|
-
function
|
|
659
|
+
function R(e, t) {
|
|
659
660
|
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? t : t ? `${e.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}` : e;
|
|
660
661
|
}
|
|
661
|
-
var
|
|
662
|
-
function
|
|
663
|
-
return
|
|
662
|
+
var qt = "types.ts";
|
|
663
|
+
function Jt(e) {
|
|
664
|
+
return R(e.path, qt);
|
|
664
665
|
}
|
|
665
|
-
function
|
|
666
|
+
function Yt(e) {
|
|
666
667
|
return `${e}/boundedContext.ts`;
|
|
667
668
|
}
|
|
668
669
|
//#endregion
|
|
669
670
|
//#region src/wow/model.ts
|
|
670
|
-
function
|
|
671
|
+
function Xt(e) {
|
|
671
672
|
return e.contextAlias !== void 0 || e.aggregateTags.size > 0;
|
|
672
673
|
}
|
|
673
|
-
function
|
|
674
|
+
function Zt(e, t) {
|
|
674
675
|
return t ? {
|
|
675
676
|
...e,
|
|
676
677
|
...t
|
|
@@ -678,11 +679,11 @@ function Jt(e, t) {
|
|
|
678
679
|
}
|
|
679
680
|
//#endregion
|
|
680
681
|
//#region src/analysis/apiClients.ts
|
|
681
|
-
var
|
|
682
|
-
function
|
|
683
|
-
return new
|
|
682
|
+
var Qt = ["httpRequest", "attributes"];
|
|
683
|
+
function $t(e, t, n, r) {
|
|
684
|
+
return new en(e, t, n, r).clients();
|
|
684
685
|
}
|
|
685
|
-
var
|
|
686
|
+
var en = class {
|
|
686
687
|
document;
|
|
687
688
|
wow;
|
|
688
689
|
config;
|
|
@@ -690,25 +691,25 @@ var Zt = class {
|
|
|
690
691
|
basePath;
|
|
691
692
|
wowDocument;
|
|
692
693
|
constructor(e, t, n, r) {
|
|
693
|
-
this.document = e, this.wow = t, this.config = n, this.warnings = r, this.wowDocument =
|
|
694
|
+
this.document = e, this.wow = t, this.config = n, this.warnings = r, this.wowDocument = Xt(t), t.contextAlias && (this.basePath = {
|
|
694
695
|
alias: t.contextAlias,
|
|
695
|
-
constantName:
|
|
696
|
+
constantName: Lt(t.contextAlias)
|
|
696
697
|
});
|
|
697
698
|
}
|
|
698
699
|
clients() {
|
|
699
700
|
let e = this.tags(), t = this.groupOperations(e), n = /* @__PURE__ */ new Map();
|
|
700
701
|
return [...t.keys()].sort().map((r) => {
|
|
701
|
-
let i =
|
|
702
|
-
for (let e = 2; n.has(
|
|
702
|
+
let i = L(r), a = i;
|
|
703
|
+
for (let e = 2; n.has(nn(a)); e++) a = {
|
|
703
704
|
...i,
|
|
704
705
|
name: `${i.name}${e}`
|
|
705
706
|
};
|
|
706
|
-
return a !== i && this.warnings.push(`Tags ${n.get(
|
|
707
|
+
return a !== i && this.warnings.push(`Tags ${n.get(nn(i))} and ${r} both name the API client ${i.name}ApiClient; ${r} generates ${a.name}ApiClient.`), n.set(nn(a), r), this.client(e.get(r), a, [...t.get(r)]);
|
|
707
708
|
});
|
|
708
709
|
}
|
|
709
710
|
client(e, t, n) {
|
|
710
711
|
let r = `${t.name}ApiClient`, i = t.path;
|
|
711
|
-
this.wow.contextAlias && (i =
|
|
712
|
+
this.wow.contextAlias && (i = R(this.wow.contextAlias, i)), i = R(i, tn(r));
|
|
712
713
|
let a = /* @__PURE__ */ new Map();
|
|
713
714
|
return {
|
|
714
715
|
tagName: e.name,
|
|
@@ -720,7 +721,7 @@ var Zt = class {
|
|
|
720
721
|
};
|
|
721
722
|
}
|
|
722
723
|
method(e, t, n, r) {
|
|
723
|
-
let { operation: i } = n, a = this.methodName(e, t, n, r), o = new Set(
|
|
724
|
+
let { operation: i } = n, a = this.methodName(e, t, n, r), o = new Set(Qt), s = this.parameters(e, n, o), c = this.body(i, o), l = [...s.filter(({ parameter: e }) => e.required), ...s.filter(({ parameter: e }) => !e.required)].filter(({ description: e }) => e);
|
|
724
725
|
return {
|
|
725
726
|
name: a,
|
|
726
727
|
httpMethod: n.method,
|
|
@@ -738,21 +739,21 @@ var Zt = class {
|
|
|
738
739
|
};
|
|
739
740
|
}
|
|
740
741
|
methodName(e, t, n, r) {
|
|
741
|
-
let i = n.operation.operationId, a =
|
|
742
|
+
let i = n.operation.operationId, a = Nt(n.operation, this.config.apiClients?.[e.name]?.methodNames?.[i]), o = r.get(a);
|
|
742
743
|
if (o !== void 0) throw new _("specification", `Operations ${o} and ${i} of tag ${e.name} both generate the method ${t}.${a}(). Name one of them with apiClients["${e.name}"].methodNames in the generator configuration, or with the x-fetcher-method extension.`);
|
|
743
744
|
return r.set(a, i), a;
|
|
744
745
|
}
|
|
745
746
|
parameters(e, t, n) {
|
|
746
|
-
let r =
|
|
747
|
+
let r = ot(t.operation, this.document.components ?? {}), i = [];
|
|
747
748
|
for (let a of [
|
|
748
749
|
"path",
|
|
749
750
|
"query",
|
|
750
751
|
"header"
|
|
751
752
|
]) {
|
|
752
753
|
let o = r.filter((e) => e.in === a);
|
|
753
|
-
for (let r of a === "path" ?
|
|
754
|
+
for (let r of a === "path" ? ct(t.path, o) : o) a === "path" && this.ignoresPathParameter(e.name, r.name) || i.push({
|
|
754
755
|
parameter: {
|
|
755
|
-
name:
|
|
756
|
+
name: Ft(r.name, n),
|
|
756
757
|
location: a,
|
|
757
758
|
parameterName: r.name,
|
|
758
759
|
schema: r.schema,
|
|
@@ -765,20 +766,20 @@ var Zt = class {
|
|
|
765
766
|
return a.length > 0 && this.warnings.push(`${t.method.toUpperCase()} ${t.path} leaves out its cookie parameter(s) ${a.map((e) => e.name).join(", ")}: the browser sends cookies, and fetch cannot set them.`), i;
|
|
766
767
|
}
|
|
767
768
|
ignoresPathParameter(e, t) {
|
|
768
|
-
return (this.config.apiClients?.[e]?.ignorePathParameters ?? (this.wowDocument ?
|
|
769
|
+
return (this.config.apiClients?.[e]?.ignorePathParameters ?? (this.wowDocument ? kt : [])).includes(t);
|
|
769
770
|
}
|
|
770
771
|
body(e, t) {
|
|
771
772
|
if (!e.requestBody) return;
|
|
772
|
-
let n =
|
|
773
|
+
let n = D(e.requestBody) ? we(e.requestBody, this.document.components) : e.requestBody;
|
|
773
774
|
if (!n) return;
|
|
774
|
-
let r = n.required === !0, i = n.content ?? {}, a = M(i,
|
|
775
|
+
let r = n.required === !0, i = n.content ?? {}, a = M(i, Ee, ke), o = Ft("body", t);
|
|
775
776
|
return a?.schema ? {
|
|
776
777
|
name: o,
|
|
777
778
|
required: r,
|
|
778
779
|
content: {
|
|
779
780
|
kind: "json",
|
|
780
781
|
schema: a.schema,
|
|
781
|
-
optionalFields:
|
|
782
|
+
optionalFields: Qe(a.schema, this.document.components)
|
|
782
783
|
}
|
|
783
784
|
} : M(i, "multipart/form-data") ? {
|
|
784
785
|
name: o,
|
|
@@ -788,7 +789,7 @@ var Zt = class {
|
|
|
788
789
|
name: o,
|
|
789
790
|
required: r,
|
|
790
791
|
content: { kind: "urlEncoded" }
|
|
791
|
-
} : Object.keys(i).some(
|
|
792
|
+
} : Object.keys(i).some(Ae) ? {
|
|
792
793
|
name: o,
|
|
793
794
|
required: r,
|
|
794
795
|
content: { kind: "text" }
|
|
@@ -799,20 +800,20 @@ var Zt = class {
|
|
|
799
800
|
};
|
|
800
801
|
}
|
|
801
802
|
returns(e) {
|
|
802
|
-
let t =
|
|
803
|
+
let t = it(e, this.document.components);
|
|
803
804
|
if (!t) return { kind: "response" };
|
|
804
|
-
let n =
|
|
805
|
+
let n = Me(t), r = n || Pe(t);
|
|
805
806
|
if (r) return {
|
|
806
807
|
kind: "json",
|
|
807
808
|
schema: r,
|
|
808
809
|
wildcard: !n
|
|
809
810
|
};
|
|
810
|
-
let i =
|
|
811
|
+
let i = Ne(t);
|
|
811
812
|
if (i) {
|
|
812
|
-
if (
|
|
813
|
-
let e =
|
|
814
|
-
if (
|
|
815
|
-
let t =
|
|
813
|
+
if (D(i)) {
|
|
814
|
+
let e = A(i, this.document.components);
|
|
815
|
+
if (He(e) && D(e.items)) {
|
|
816
|
+
let t = It(e.items, this.document.components);
|
|
816
817
|
return {
|
|
817
818
|
kind: "eventStream",
|
|
818
819
|
items: e.items,
|
|
@@ -825,7 +826,7 @@ var Zt = class {
|
|
|
825
826
|
serverSentEvent: !1
|
|
826
827
|
};
|
|
827
828
|
}
|
|
828
|
-
return
|
|
829
|
+
return Fe(t) ? { kind: "text" } : { kind: "response" };
|
|
829
830
|
}
|
|
830
831
|
groupOperations(e) {
|
|
831
832
|
let t = /* @__PURE__ */ new Map();
|
|
@@ -856,44 +857,44 @@ var Zt = class {
|
|
|
856
857
|
}), e;
|
|
857
858
|
}
|
|
858
859
|
ignoresTag(e) {
|
|
859
|
-
return
|
|
860
|
+
return Ot.has(e) || this.wow.aggregateTags.has(e);
|
|
860
861
|
}
|
|
861
862
|
};
|
|
862
|
-
function
|
|
863
|
+
function tn(e) {
|
|
863
864
|
return `${e.charAt(0).toLowerCase()}${e.slice(1)}.ts`;
|
|
864
865
|
}
|
|
865
|
-
function
|
|
866
|
+
function nn(e) {
|
|
866
867
|
return `${e.path}/${e.name}`.toLowerCase();
|
|
867
868
|
}
|
|
868
869
|
//#endregion
|
|
869
870
|
//#region src/analysis/models.ts
|
|
870
|
-
function
|
|
871
|
+
function rn(e) {
|
|
871
872
|
let t = new Set(e.contexts.keys());
|
|
872
873
|
return e.contextAlias && t.add(e.contextAlias), [...t].sort().map((e) => ({
|
|
873
874
|
alias: e,
|
|
874
|
-
constantName:
|
|
875
|
-
file:
|
|
875
|
+
constantName: Lt(e),
|
|
876
|
+
file: Yt(e)
|
|
876
877
|
}));
|
|
877
878
|
}
|
|
878
|
-
function
|
|
879
|
+
function an(e, t) {
|
|
879
880
|
let n = e.components?.schemas;
|
|
880
881
|
if (!n) return [];
|
|
881
|
-
let r =
|
|
882
|
-
|
|
883
|
-
let o =
|
|
882
|
+
let r = sn(t), i = on(e, t), a = Object.keys(n).filter((e) => !Ct(e, () => L(e).name, r) || !e.startsWith("wow.") && i.has(e));
|
|
883
|
+
cn(a);
|
|
884
|
+
let o = ln(t);
|
|
884
885
|
return a.map((e) => {
|
|
885
|
-
let r = n[e], i =
|
|
886
|
+
let r = n[e], i = L(e);
|
|
886
887
|
return {
|
|
887
888
|
key: e,
|
|
888
889
|
info: i,
|
|
889
|
-
file:
|
|
890
|
+
file: Jt(i),
|
|
890
891
|
schema: r,
|
|
891
|
-
docSchema:
|
|
892
|
-
emptyMessageBody: o.has(e) &&
|
|
892
|
+
docSchema: Zt(r, t.schemaDocOverrides.get(e)),
|
|
893
|
+
emptyMessageBody: o.has(e) && un(r)
|
|
893
894
|
};
|
|
894
895
|
});
|
|
895
896
|
}
|
|
896
|
-
function
|
|
897
|
+
function on(e, t) {
|
|
897
898
|
let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = e.components ?? {}, a = (e) => {
|
|
898
899
|
if (typeof e != "object" || !e || r.has(e)) return;
|
|
899
900
|
if (r.add(e), Array.isArray(e)) {
|
|
@@ -902,54 +903,54 @@ function nn(e, t) {
|
|
|
902
903
|
}
|
|
903
904
|
let { $ref: t } = e;
|
|
904
905
|
if (typeof t == "string" && t.startsWith("#/components/")) {
|
|
905
|
-
let [e, ...r] = t.slice(
|
|
906
|
+
let [e, ...r] = t.slice(O.length).split("/"), o = r.join("/");
|
|
906
907
|
e === "schemas" && n.add(o), a(i[e]?.[o]);
|
|
907
908
|
}
|
|
908
909
|
Object.values(e).forEach(a);
|
|
909
910
|
};
|
|
910
911
|
for (let { operation: n } of e.endpoints) {
|
|
911
912
|
let e = n.tags ?? [];
|
|
912
|
-
e.length > 0 && e.every((e) => !
|
|
913
|
+
e.length > 0 && e.every((e) => !Ot.has(e) && !t.aggregateTags.has(e)) && a(n);
|
|
913
914
|
}
|
|
914
915
|
return n;
|
|
915
916
|
}
|
|
916
|
-
function
|
|
917
|
+
function sn(e) {
|
|
917
918
|
let t = /* @__PURE__ */ new Set();
|
|
918
|
-
for (let n of e.contexts.values()) for (let e of n)
|
|
919
|
+
for (let n of e.contexts.values()) for (let e of n) St(L(e.state.key).name).forEach((e) => t.add(e));
|
|
919
920
|
return t;
|
|
920
921
|
}
|
|
921
|
-
function
|
|
922
|
+
function cn(e) {
|
|
922
923
|
let t = /* @__PURE__ */ new Map();
|
|
923
924
|
for (let n of e) {
|
|
924
|
-
let e =
|
|
925
|
+
let e = L(n), r = `${e.path === "/" ? "" : e.path}/${e.name}`;
|
|
925
926
|
t.set(r, [...t.get(r) ?? [], n]);
|
|
926
927
|
}
|
|
927
928
|
let n = [...t].filter(([, e]) => e.length > 1);
|
|
928
929
|
if (n.length !== 0) throw new _("specification", `Schemas generate the same model: ${n.map(([e, t]) => `${t.join(", ")} → ${e}`).join("; ")}. Rename all but one of them in the document.`);
|
|
929
930
|
}
|
|
930
|
-
function
|
|
931
|
+
function ln(e) {
|
|
931
932
|
return new Set([...e.contexts.values()].flatMap((e) => [...e].flatMap((e) => [...[...e.commands.values()].map((e) => e.schema.key), ...[...e.events.values()].map((e) => e.schema.key)])));
|
|
932
933
|
}
|
|
933
|
-
function
|
|
934
|
-
return !
|
|
934
|
+
function un(e) {
|
|
935
|
+
return !D(e) && e.type === "object" && Object.keys(e.properties ?? {}).length === 0 && (e.additionalProperties === void 0 || e.additionalProperties === !1) && !e.required?.length && !N(e) && e.enum === void 0 && e.const === void 0;
|
|
935
936
|
}
|
|
936
937
|
//#endregion
|
|
937
938
|
//#region src/analysis/analyze.ts
|
|
938
|
-
function
|
|
939
|
-
let r = [], i =
|
|
940
|
-
return
|
|
939
|
+
function dn(e, t, n) {
|
|
940
|
+
let r = [], i = rn(t), a = an(e, t), o = zt(e, t);
|
|
941
|
+
return Ut(o, a), {
|
|
941
942
|
model: {
|
|
942
943
|
contexts: i,
|
|
943
944
|
models: a,
|
|
944
945
|
aggregates: o,
|
|
945
|
-
apiClients:
|
|
946
|
+
apiClients: $t(e, t, n, r)
|
|
946
947
|
},
|
|
947
948
|
warnings: r
|
|
948
949
|
};
|
|
949
950
|
}
|
|
950
951
|
//#endregion
|
|
951
952
|
//#region src/emit/importRegistry.ts
|
|
952
|
-
var
|
|
953
|
+
var fn = class {
|
|
953
954
|
declarations = /* @__PURE__ */ new Map();
|
|
954
955
|
add(e, t) {
|
|
955
956
|
let n = this.declarations.get(e);
|
|
@@ -985,9 +986,9 @@ var ln = class {
|
|
|
985
986
|
})
|
|
986
987
|
}));
|
|
987
988
|
}
|
|
988
|
-
},
|
|
989
|
+
}, pn = class {
|
|
989
990
|
sourceFile;
|
|
990
|
-
imports = new
|
|
991
|
+
imports = new fn();
|
|
991
992
|
statements = [];
|
|
992
993
|
constructor(e) {
|
|
993
994
|
this.sourceFile = e;
|
|
@@ -1004,10 +1005,10 @@ var ln = class {
|
|
|
1004
1005
|
...n,
|
|
1005
1006
|
kind: o.ImportDeclaration
|
|
1006
1007
|
}, e.push(t);
|
|
1007
|
-
for (let n of this.statements) t &&
|
|
1008
|
+
for (let n of this.statements) t && gn(t, n) && e.push(hn), e.push(n), t = n;
|
|
1008
1009
|
return e.length > 0 && this.sourceFile.addStatements(e), this.sourceFile;
|
|
1009
1010
|
}
|
|
1010
|
-
},
|
|
1011
|
+
}, mn = class {
|
|
1011
1012
|
open;
|
|
1012
1013
|
modules = /* @__PURE__ */ new Map();
|
|
1013
1014
|
constructor(e) {
|
|
@@ -1015,16 +1016,16 @@ var ln = class {
|
|
|
1015
1016
|
}
|
|
1016
1017
|
module(e) {
|
|
1017
1018
|
let t = this.open(e), n = t.getFilePath(), r = this.modules.get(n);
|
|
1018
|
-
return r || (r = new
|
|
1019
|
+
return r || (r = new pn(t), this.modules.set(n, r)), r;
|
|
1019
1020
|
}
|
|
1020
1021
|
build() {
|
|
1021
1022
|
for (let e of this.modules.values()) e.build();
|
|
1022
1023
|
this.modules.clear();
|
|
1023
1024
|
}
|
|
1024
|
-
},
|
|
1025
|
+
}, hn = (e) => {
|
|
1025
1026
|
e.blankLineIfLastNot();
|
|
1026
1027
|
};
|
|
1027
|
-
function
|
|
1028
|
+
function gn(e, t) {
|
|
1028
1029
|
if (typeof t == "string") return !1;
|
|
1029
1030
|
switch (t.kind) {
|
|
1030
1031
|
case o.TypeAlias:
|
|
@@ -1032,13 +1033,13 @@ function pn(e, t) {
|
|
|
1032
1033
|
default: return !0;
|
|
1033
1034
|
}
|
|
1034
1035
|
}
|
|
1035
|
-
function
|
|
1036
|
+
function _n(e) {
|
|
1036
1037
|
return e.map((e) => ({
|
|
1037
1038
|
...e,
|
|
1038
1039
|
initializer: `${e.initializer},`
|
|
1039
1040
|
}));
|
|
1040
1041
|
}
|
|
1041
|
-
function
|
|
1042
|
+
function vn(e, t) {
|
|
1042
1043
|
return {
|
|
1043
1044
|
name: "[key: string]",
|
|
1044
1045
|
type: e,
|
|
@@ -1047,50 +1048,50 @@ function hn(e, t) {
|
|
|
1047
1048
|
}
|
|
1048
1049
|
//#endregion
|
|
1049
1050
|
//#region src/emit/imports.ts
|
|
1050
|
-
var
|
|
1051
|
-
function
|
|
1051
|
+
var yn = "@";
|
|
1052
|
+
function z(e, t, n) {
|
|
1052
1053
|
return e.imports.add(t, n);
|
|
1053
1054
|
}
|
|
1054
|
-
function
|
|
1055
|
-
return
|
|
1055
|
+
function B(e, t, n) {
|
|
1056
|
+
return z(e, bn(e, t, n), [n.name]);
|
|
1056
1057
|
}
|
|
1057
|
-
function
|
|
1058
|
-
return n.path.startsWith(
|
|
1058
|
+
function bn(e, t, n) {
|
|
1059
|
+
return n.path.startsWith(yn) ? n.path : xn(e.directoryPath, d(t, n.path, qt));
|
|
1059
1060
|
}
|
|
1060
|
-
function
|
|
1061
|
+
function xn(e, t) {
|
|
1061
1062
|
let n = f(e, t).split(m).join("/");
|
|
1062
1063
|
return n = n.endsWith(".ts") ? n.replace(/\.ts$/, ".js") : `${n}/index.js`, n.startsWith(".") ? n : `./${n}`;
|
|
1063
1064
|
}
|
|
1064
|
-
function
|
|
1065
|
-
return
|
|
1065
|
+
function Sn(e, t, n, r) {
|
|
1066
|
+
return z(e, xn(e.directoryPath, d(t, Yt(n))), [r]);
|
|
1066
1067
|
}
|
|
1067
1068
|
//#endregion
|
|
1068
1069
|
//#region src/emit/jsdoc.ts
|
|
1069
|
-
function
|
|
1070
|
+
function Cn(e, t = "\n") {
|
|
1070
1071
|
if (!Array.isArray(e)) return;
|
|
1071
|
-
let n = e.filter((e) => typeof e == "string" && e.length > 0).map(
|
|
1072
|
+
let n = e.filter((e) => typeof e == "string" && e.length > 0).map(wn);
|
|
1072
1073
|
return n.length > 0 ? n.join(t) : void 0;
|
|
1073
1074
|
}
|
|
1074
|
-
function
|
|
1075
|
+
function wn(e) {
|
|
1075
1076
|
return e.replace(/\*\//g, "*\\/");
|
|
1076
1077
|
}
|
|
1077
|
-
function
|
|
1078
|
-
let n =
|
|
1078
|
+
function V(e, t) {
|
|
1079
|
+
let n = Cn(t);
|
|
1079
1080
|
n && (e.docs = [...e.docs ?? [], n]);
|
|
1080
1081
|
}
|
|
1081
|
-
function
|
|
1082
|
-
e =
|
|
1082
|
+
function Tn(e, t, n = !1) {
|
|
1083
|
+
e = On(e);
|
|
1083
1084
|
let r = [e.title, e.description];
|
|
1084
|
-
return t && r.push(`- key: ${t}`), n &&
|
|
1085
|
+
return t && r.push(`- key: ${t}`), n && kn(r, e), e.format && r.push(e.format === "int64" ? "- format: int64 (a value beyond Number.MAX_SAFE_INTEGER loses precision)" : `- format: ${e.format}`), An(r, e, "default"), An(r, e, "example"), Mn(r, e), Nn(r, e), Pn(r, e), r;
|
|
1085
1086
|
}
|
|
1086
|
-
function
|
|
1087
|
-
|
|
1087
|
+
function En(e, t, n) {
|
|
1088
|
+
V(e, Tn(t, n));
|
|
1088
1089
|
}
|
|
1089
|
-
function
|
|
1090
|
-
let i =
|
|
1091
|
-
r &&
|
|
1090
|
+
function Dn(e, t, n, r = !1) {
|
|
1091
|
+
let i = Tn(t, n, !0);
|
|
1092
|
+
r && jn(i, "schema", t), V(e, i);
|
|
1092
1093
|
}
|
|
1093
|
-
function
|
|
1094
|
+
function On(e) {
|
|
1094
1095
|
for (let t of ["anyOf", "oneOf"]) {
|
|
1095
1096
|
let n = e[t];
|
|
1096
1097
|
if (!Array.isArray(n) || n.length < 2) continue;
|
|
@@ -1102,32 +1103,32 @@ function Sn(e) {
|
|
|
1102
1103
|
}
|
|
1103
1104
|
return e;
|
|
1104
1105
|
}
|
|
1105
|
-
function
|
|
1106
|
+
function kn(e, t) {
|
|
1106
1107
|
let n = t.required ?? [];
|
|
1107
1108
|
(n.length || Object.keys(t.properties ?? {}).length) && e.push(`- required: ${n.length ? n.join(", ") : "(none)"}`);
|
|
1108
1109
|
}
|
|
1109
|
-
function
|
|
1110
|
+
function An(e, t, n) {
|
|
1110
1111
|
let r = t[n];
|
|
1111
|
-
r && (typeof r == "object" ?
|
|
1112
|
+
r && (typeof r == "object" ? jn(e, n, r) : e.push(`- ${n}: \`${r}\``));
|
|
1112
1113
|
}
|
|
1113
|
-
function
|
|
1114
|
+
function jn(e, t, n) {
|
|
1114
1115
|
e.push(`- ${t}: `), e.push("```json"), e.push(JSON.stringify(n, null, 2)), e.push("```");
|
|
1115
1116
|
}
|
|
1116
|
-
function
|
|
1117
|
+
function Mn(e, t) {
|
|
1117
1118
|
let n = ["- Numeric Constraints"];
|
|
1118
1119
|
t.minimum !== void 0 && n.push(` - minimum: ${t.minimum}`), t.maximum !== void 0 && n.push(` - maximum: ${t.maximum}`), t.exclusiveMinimum !== void 0 && n.push(` - exclusiveMinimum: ${t.exclusiveMinimum}`), t.exclusiveMaximum !== void 0 && n.push(` - exclusiveMaximum: ${t.exclusiveMaximum}`), t.multipleOf !== void 0 && n.push(` - multipleOf: ${t.multipleOf}`), n.length !== 1 && e.push(...n);
|
|
1119
1120
|
}
|
|
1120
|
-
function
|
|
1121
|
+
function Nn(e, t) {
|
|
1121
1122
|
let n = ["- String Constraints"];
|
|
1122
1123
|
t.minLength !== void 0 && n.push(` - minLength: ${t.minLength}`), t.maxLength !== void 0 && n.push(` - maxLength: ${t.maxLength}`), t.pattern !== void 0 && n.push(` - pattern: ${t.pattern}`), n.length !== 1 && e.push(...n);
|
|
1123
1124
|
}
|
|
1124
|
-
function
|
|
1125
|
+
function Pn(e, t) {
|
|
1125
1126
|
let n = ["- Array Constraints"];
|
|
1126
1127
|
t.minItems !== void 0 && n.push(` - minItems: ${t.minItems}`), t.maxItems !== void 0 && n.push(` - maxItems: ${t.maxItems}`), t.uniqueItems !== void 0 && n.push(` - uniqueItems: ${t.uniqueItems}`), n.length !== 1 && e.push(...n);
|
|
1127
1128
|
}
|
|
1128
1129
|
//#endregion
|
|
1129
1130
|
//#region src/types/typeResolver.ts
|
|
1130
|
-
function
|
|
1131
|
+
function Fn(e, t) {
|
|
1131
1132
|
let n;
|
|
1132
1133
|
return {
|
|
1133
1134
|
components: e,
|
|
@@ -1144,7 +1145,7 @@ function kn(e, t) {
|
|
|
1144
1145
|
}
|
|
1145
1146
|
};
|
|
1146
1147
|
}
|
|
1147
|
-
var
|
|
1148
|
+
var In = [
|
|
1148
1149
|
"Array",
|
|
1149
1150
|
"Blob",
|
|
1150
1151
|
"Exclude",
|
|
@@ -1156,11 +1157,11 @@ var An = [
|
|
|
1156
1157
|
"Response",
|
|
1157
1158
|
"Symbol",
|
|
1158
1159
|
"URLSearchParams"
|
|
1159
|
-
],
|
|
1160
|
+
], Ln = /* @__PURE__ */ new Set([
|
|
1160
1161
|
"string",
|
|
1161
1162
|
"number",
|
|
1162
1163
|
"boolean"
|
|
1163
|
-
]),
|
|
1164
|
+
]), Rn = /* @__PURE__ */ new Set([
|
|
1164
1165
|
"$comment",
|
|
1165
1166
|
"$schema",
|
|
1166
1167
|
"default",
|
|
@@ -1174,54 +1175,54 @@ var An = [
|
|
|
1174
1175
|
"writeOnly",
|
|
1175
1176
|
"xml"
|
|
1176
1177
|
]);
|
|
1177
|
-
function
|
|
1178
|
+
function zn(e, t) {
|
|
1178
1179
|
return e === void 0 ? !1 : typeof e == "string" || typeof t == "string" ? e === t : e.primitive === t.primitive;
|
|
1179
1180
|
}
|
|
1180
|
-
function
|
|
1181
|
-
if (
|
|
1181
|
+
function H(e, t, n = /* @__PURE__ */ new Set()) {
|
|
1182
|
+
if (D(e)) {
|
|
1182
1183
|
if (!t || n.has(e.$ref)) return;
|
|
1183
1184
|
n.add(e.$ref);
|
|
1184
|
-
let r =
|
|
1185
|
-
return r ?
|
|
1185
|
+
let r = A(e, t);
|
|
1186
|
+
return r ? H(r, t, n) : void 0;
|
|
1186
1187
|
}
|
|
1187
1188
|
if (!(e.nullable || Array.isArray(e.type))) {
|
|
1188
|
-
if (
|
|
1189
|
-
let r = e.allOf.map((e) =>
|
|
1190
|
-
return i !== void 0 && r.every((e) =>
|
|
1189
|
+
if (Ge(e) && e.type === void 0) {
|
|
1190
|
+
let r = e.allOf.map((e) => H(e, t, n)), [i] = r;
|
|
1191
|
+
return i !== void 0 && r.every((e) => zn(e, i)) ? i : void 0;
|
|
1191
1192
|
}
|
|
1192
|
-
if (!(
|
|
1193
|
+
if (!(N(e) || e.const !== void 0 || e.type === void 0)) return e.type === "object" ? "object" : e.type === "array" ? "array" : { primitive: P(e.type) };
|
|
1193
1194
|
}
|
|
1194
1195
|
}
|
|
1195
|
-
function
|
|
1196
|
-
let r =
|
|
1196
|
+
function Bn(e, t, n) {
|
|
1197
|
+
let r = H(t, n);
|
|
1197
1198
|
if (typeof r != "object") return !1;
|
|
1198
|
-
let i =
|
|
1199
|
+
let i = H(e, n);
|
|
1199
1200
|
return i === void 0 || typeof i == "string" || i.primitive !== r.primitive;
|
|
1200
1201
|
}
|
|
1201
|
-
function
|
|
1202
|
+
function Vn(e, t) {
|
|
1202
1203
|
let n = e.additionalProperties;
|
|
1203
|
-
return typeof n == "object" && Object.values(e.properties ?? {}).some((e) =>
|
|
1204
|
+
return typeof n == "object" && Object.values(e.properties ?? {}).some((e) => Bn(e, n, t));
|
|
1204
1205
|
}
|
|
1205
|
-
function
|
|
1206
|
-
return e.nullable !== !0 ||
|
|
1206
|
+
function Hn(e) {
|
|
1207
|
+
return e.nullable !== !0 || Re(e) || !N(e) ? !1 : [
|
|
1207
1208
|
e.allOf,
|
|
1208
1209
|
e.oneOf,
|
|
1209
1210
|
e.anyOf
|
|
1210
|
-
].every((e) => e === void 0 || e.every(
|
|
1211
|
+
].every((e) => e === void 0 || e.every(D));
|
|
1211
1212
|
}
|
|
1212
|
-
function
|
|
1213
|
+
function Un(e, t) {
|
|
1213
1214
|
return t.type === void 0 || e === null && t.nullable ? !0 : [t.type].flat().some((t) => t === "null" ? e === null : t === "array" ? Array.isArray(e) : t === "object" ? typeof e == "object" && !!e && !Array.isArray(e) : t === "integer" ? typeof e == "number" && Number.isInteger(e) : typeof e === t);
|
|
1214
1215
|
}
|
|
1215
|
-
function
|
|
1216
|
+
function U(t) {
|
|
1216
1217
|
if (typeof t == "string") return new e({ useSingleQuote: !0 }).quote(t).toString();
|
|
1217
|
-
if (Array.isArray(t)) return `[${t.map((e) =>
|
|
1218
|
+
if (Array.isArray(t)) return `[${t.map((e) => U(e)).join(", ")}]`;
|
|
1218
1219
|
if (typeof t == "object" && t) {
|
|
1219
|
-
let e = Object.entries(t).map(([e, t]) => `${
|
|
1220
|
+
let e = Object.entries(t).map(([e, t]) => `${w(e)}: ${U(t)}`);
|
|
1220
1221
|
return e.length ? `{ ${e.join("; ")}; readonly [globalThis.Symbol.iterator]?: never }` : "globalThis.Record<string, never>";
|
|
1221
1222
|
}
|
|
1222
1223
|
return JSON.stringify(t) ?? "never";
|
|
1223
1224
|
}
|
|
1224
|
-
var
|
|
1225
|
+
var Wn = class {
|
|
1225
1226
|
scope;
|
|
1226
1227
|
entries;
|
|
1227
1228
|
requested = [];
|
|
@@ -1253,7 +1254,7 @@ var Rn = class {
|
|
|
1253
1254
|
name: t.name
|
|
1254
1255
|
}, this.entries.push(i)), this.request(i), i.alias) return i.alias;
|
|
1255
1256
|
let a = /* @__PURE__ */ new Set([
|
|
1256
|
-
...
|
|
1257
|
+
...In,
|
|
1257
1258
|
n.name,
|
|
1258
1259
|
...n.path === void 0 ? [] : this.scope.context.namesAt(n.path),
|
|
1259
1260
|
...this.entries.filter((e) => e !== i).map((e) => e.alias ?? e.name)
|
|
@@ -1275,9 +1276,9 @@ var Rn = class {
|
|
|
1275
1276
|
propertyDefinitions(e) {
|
|
1276
1277
|
let { properties: t } = e;
|
|
1277
1278
|
return Object.entries(t).map(([e, t]) => {
|
|
1278
|
-
let n = this.type(t), r = (
|
|
1279
|
-
if (!
|
|
1280
|
-
let e =
|
|
1279
|
+
let n = this.type(t), r = (Ze(t) ? "readonly " : "") + w(e);
|
|
1280
|
+
if (!D(t)) {
|
|
1281
|
+
let e = Cn(Tn(t), "\n * ");
|
|
1281
1282
|
if (e) return `
|
|
1282
1283
|
/**
|
|
1283
1284
|
* ${e}
|
|
@@ -1290,9 +1291,9 @@ var Rn = class {
|
|
|
1290
1291
|
}
|
|
1291
1292
|
objectType(e) {
|
|
1292
1293
|
let t = [];
|
|
1293
|
-
|
|
1294
|
-
for (let n of e.required ?? []) Object.hasOwn(e.properties ?? {}, n) || t.push(`${
|
|
1295
|
-
let n =
|
|
1294
|
+
Ve(e) && t.push(...this.propertyDefinitions(e));
|
|
1295
|
+
for (let n of e.required ?? []) Object.hasOwn(e.properties ?? {}, n) || t.push(`${w(n)}: ${this.requiredAdditionalPropertyType(e)}`);
|
|
1296
|
+
let n = qe(e) && Ye(e) ? this.mapType(e) : Vn(e, this.components) ? `globalThis.Record<string, ${this.additionalPropertyType(e)}>` : void 0, r = n ? "" : this.additionalProperties(e);
|
|
1296
1297
|
if (r && t.push(r), t.length === 0) return "globalThis.Record<string, any>";
|
|
1297
1298
|
let i = `{\n ${t.join(";\n ")}; \n}`;
|
|
1298
1299
|
return n ? `(${i} & ${n})` : i;
|
|
@@ -1301,14 +1302,14 @@ var Rn = class {
|
|
|
1301
1302
|
return e.additionalProperties === void 0 || e.additionalProperties === !1 || e.additionalProperties === !0 ? "any" : this.type(e.additionalProperties);
|
|
1302
1303
|
}
|
|
1303
1304
|
mapKeyType(e) {
|
|
1304
|
-
let t =
|
|
1305
|
+
let t = Ye(e);
|
|
1305
1306
|
return t ? this.type(t) : "string";
|
|
1306
1307
|
}
|
|
1307
1308
|
mapType(e) {
|
|
1308
1309
|
return `globalThis.Record<${this.mapKeyType(e)},${this.mapValueType(e)}>`;
|
|
1309
1310
|
}
|
|
1310
1311
|
objectConstrained(e) {
|
|
1311
|
-
let t = (e) =>
|
|
1312
|
+
let t = (e) => D(e) ? this.components && A(e, this.components) : e, n = t(e), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = n ? [n] : [];
|
|
1312
1313
|
for (let e of a) {
|
|
1313
1314
|
if (r.has(e)) continue;
|
|
1314
1315
|
let n = [
|
|
@@ -1332,7 +1333,7 @@ var Rn = class {
|
|
|
1332
1333
|
return n !== void 0 && i.has(n);
|
|
1333
1334
|
}
|
|
1334
1335
|
type(e) {
|
|
1335
|
-
if (
|
|
1336
|
+
if (D(e)) return this.reference(e);
|
|
1336
1337
|
if (Array.isArray(e.type)) return e.type.map((t) => {
|
|
1337
1338
|
let n = this.type({
|
|
1338
1339
|
...e,
|
|
@@ -1340,11 +1341,11 @@ var Rn = class {
|
|
|
1340
1341
|
});
|
|
1341
1342
|
return /[|&]/.test(n) ? `(${n})` : n;
|
|
1342
1343
|
}).join(" | ");
|
|
1343
|
-
if (
|
|
1344
|
+
if (Hn(e)) return `(${this.type({
|
|
1344
1345
|
...e,
|
|
1345
1346
|
nullable: !1
|
|
1346
1347
|
})}) | null`;
|
|
1347
|
-
if (
|
|
1348
|
+
if (N(e)) {
|
|
1348
1349
|
let t = this.simpleComposition(e);
|
|
1349
1350
|
if (t !== void 0) return t;
|
|
1350
1351
|
let n = [
|
|
@@ -1366,25 +1367,25 @@ var Rn = class {
|
|
|
1366
1367
|
return this.objectConstrained(e) ? `globalThis.Exclude<${o}, string | number | boolean | readonly unknown[]> & ({ readonly [globalThis.Symbol.iterator]?: never } | null)` : o;
|
|
1367
1368
|
}
|
|
1368
1369
|
if (e.const !== void 0) {
|
|
1369
|
-
if (!
|
|
1370
|
-
let t =
|
|
1370
|
+
if (!Un(e.const, e)) return "never";
|
|
1371
|
+
let t = U(e.const), n = this.type({
|
|
1371
1372
|
...e,
|
|
1372
1373
|
const: void 0
|
|
1373
1374
|
});
|
|
1374
1375
|
return n === "any" ? t : `(${t}) & (${n})`;
|
|
1375
1376
|
}
|
|
1376
|
-
if (e.nullable && e.type && !
|
|
1377
|
+
if (e.nullable && e.type && !Re(e)) return `(${this.type({
|
|
1377
1378
|
...e,
|
|
1378
1379
|
nullable: !1
|
|
1379
1380
|
})}) | null`;
|
|
1380
|
-
if (
|
|
1381
|
-
let t = e.enum.filter((t) =>
|
|
1381
|
+
if (Re(e)) {
|
|
1382
|
+
let t = e.enum.filter((t) => Un(t, e)).map((e) => U(e)).join(" | ") || "never", n = this.type({
|
|
1382
1383
|
...e,
|
|
1383
1384
|
enum: void 0
|
|
1384
1385
|
});
|
|
1385
|
-
return n === "any" ||
|
|
1386
|
+
return n === "any" || Ln.has(n) ? t : `(${t}) & (${n})`;
|
|
1386
1387
|
}
|
|
1387
|
-
return
|
|
1388
|
+
return qe(e) && !e.required?.length ? this.mapType(e) : e.type === "array" ? Ke(this.type(e.items ?? {})) : e.type === "object" ? this.objectType(e) : e.type ? P(e.type) : e.required?.length || Object.keys(e.properties ?? {}).length > 0 ? `(${this.objectType({
|
|
1388
1389
|
...e,
|
|
1389
1390
|
type: "object",
|
|
1390
1391
|
additionalProperties: e.additionalProperties ?? !0
|
|
@@ -1398,44 +1399,44 @@ var Rn = class {
|
|
|
1398
1399
|
].filter((t) => e[t]?.length);
|
|
1399
1400
|
if (t.length !== 1) return;
|
|
1400
1401
|
let [n] = t;
|
|
1401
|
-
if (Object.keys(e).filter((e) => e !== n && e !== "discriminator" && !e.startsWith("x-") && !
|
|
1402
|
-
let r = e[n], i = (e) => n !== "allOf" && [e.type].flat().every((e) => e === "null") && e.type !== void 0 && Object.keys(e).every((e) => e === "type" ||
|
|
1403
|
-
if (!r.every((e) =>
|
|
1404
|
-
let a = r.map((t) =>
|
|
1402
|
+
if (Object.keys(e).filter((e) => e !== n && e !== "discriminator" && !e.startsWith("x-") && !Rn.has(e)).length > 0) return;
|
|
1403
|
+
let r = e[n], i = (e) => n !== "allOf" && [e.type].flat().every((e) => e === "null") && e.type !== void 0 && Object.keys(e).every((e) => e === "type" || Rn.has(e));
|
|
1404
|
+
if (!r.every((e) => D(e) || i(e))) return;
|
|
1405
|
+
let a = r.map((t) => D(t) ? this.memberType(e, n, t) : "null");
|
|
1405
1406
|
return [...new Set(a)].join(n === "allOf" ? " & " : " | ");
|
|
1406
1407
|
}
|
|
1407
1408
|
memberType(e, t, n) {
|
|
1408
1409
|
let r = this.type(n), i = e.discriminator;
|
|
1409
|
-
if (t === "allOf" || !i?.propertyName || !
|
|
1410
|
-
let a =
|
|
1411
|
-
return `(${r} & { ${
|
|
1410
|
+
if (t === "allOf" || !i?.propertyName || !D(n)) return r;
|
|
1411
|
+
let a = Se(n), o = Object.entries(i.mapping ?? {}).filter(([, e]) => e === n.$ref || e === a).map(([e]) => e), s = (o.length > 0 ? o : [a]).map((e) => T(e)).join(" | ");
|
|
1412
|
+
return `(${r} & { ${w(i.propertyName)}: ${s} })`;
|
|
1412
1413
|
}
|
|
1413
1414
|
};
|
|
1414
|
-
function
|
|
1415
|
-
let n = new
|
|
1415
|
+
function W(e, t) {
|
|
1416
|
+
let n = new Wn(e);
|
|
1416
1417
|
return {
|
|
1417
1418
|
text: t(n),
|
|
1418
1419
|
imports: n.imports()
|
|
1419
1420
|
};
|
|
1420
1421
|
}
|
|
1421
|
-
function
|
|
1422
|
-
return
|
|
1422
|
+
function Gn(e, t) {
|
|
1423
|
+
return W(t, (t) => t.type(e));
|
|
1423
1424
|
}
|
|
1424
|
-
function
|
|
1425
|
-
return
|
|
1425
|
+
function Kn(e, t) {
|
|
1426
|
+
return W(t, (t) => t.additionalProperties(e));
|
|
1426
1427
|
}
|
|
1427
|
-
function
|
|
1428
|
-
return
|
|
1428
|
+
function qn(e, t) {
|
|
1429
|
+
return W(t, (t) => t.additionalPropertyType(e));
|
|
1429
1430
|
}
|
|
1430
|
-
function
|
|
1431
|
-
return
|
|
1431
|
+
function Jn(e, t) {
|
|
1432
|
+
return W(t, (t) => t.requiredAdditionalPropertyType(e));
|
|
1432
1433
|
}
|
|
1433
|
-
function
|
|
1434
|
-
return
|
|
1434
|
+
function Yn(e, t) {
|
|
1435
|
+
return W(t, (t) => t.mapValueType(e));
|
|
1435
1436
|
}
|
|
1436
1437
|
//#endregion
|
|
1437
1438
|
//#region src/emitters/decorators.ts
|
|
1438
|
-
var
|
|
1439
|
+
var Xn = "@ahoo-wang/fetcher", Zn = ["ContentTypeValues", "ResultExtractors"], Qn = "@ahoo-wang/fetcher-decorator", $n = [
|
|
1439
1440
|
"ApiMetadata",
|
|
1440
1441
|
"ApiMetadataCapable",
|
|
1441
1442
|
"ParameterRequest",
|
|
@@ -1452,20 +1453,20 @@ var Wn = "@ahoo-wang/fetcher", Gn = ["ContentTypeValues", "ResultExtractors"], K
|
|
|
1452
1453
|
"header",
|
|
1453
1454
|
"body",
|
|
1454
1455
|
"autoGeneratedError"
|
|
1455
|
-
],
|
|
1456
|
+
], er = {
|
|
1456
1457
|
type: "Promise<Response>",
|
|
1457
1458
|
metadata: "{resultExtractor: ResultExtractors.Response }"
|
|
1458
|
-
},
|
|
1459
|
+
}, tr = {
|
|
1459
1460
|
type: "Promise<string>",
|
|
1460
1461
|
metadata: "{resultExtractor: ResultExtractors.Text }"
|
|
1461
|
-
},
|
|
1462
|
-
function
|
|
1463
|
-
|
|
1462
|
+
}, nr = "{\n headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },\n resultExtractor: JsonEventStreamResultExtractor,\n}", rr = "COMMAND_STREAM_ENDPOINT";
|
|
1463
|
+
function ir(e) {
|
|
1464
|
+
z(e, Xn, Zn);
|
|
1464
1465
|
}
|
|
1465
|
-
function
|
|
1466
|
-
|
|
1466
|
+
function ar(e) {
|
|
1467
|
+
z(e, Qn, $n);
|
|
1467
1468
|
}
|
|
1468
|
-
function
|
|
1469
|
+
function or(e, t, n = [], r = [], i) {
|
|
1469
1470
|
return t.add({
|
|
1470
1471
|
kind: o.Class,
|
|
1471
1472
|
name: e,
|
|
@@ -1478,7 +1479,7 @@ function er(e, t, n = [], r = [], i) {
|
|
|
1478
1479
|
}]
|
|
1479
1480
|
});
|
|
1480
1481
|
}
|
|
1481
|
-
function
|
|
1482
|
+
function sr(e, t) {
|
|
1482
1483
|
e.implements = [...[e.implements ?? []].flat(), "ApiMetadataCapable"], e.ctors ??= [], t === void 0 ? e.ctors.push({ parameters: [{
|
|
1483
1484
|
name: "apiMetadata",
|
|
1484
1485
|
type: "ApiMetadata",
|
|
@@ -1499,41 +1500,41 @@ function tr(e, t) {
|
|
|
1499
1500
|
docs: ["@param apiMetadata - Merged over the defaults, so passing only a `fetcher` keeps the base path."]
|
|
1500
1501
|
}));
|
|
1501
1502
|
}
|
|
1502
|
-
function
|
|
1503
|
+
function cr(e) {
|
|
1503
1504
|
return e === "delete" ? "del" : e;
|
|
1504
1505
|
}
|
|
1505
|
-
var
|
|
1506
|
-
function
|
|
1507
|
-
|
|
1506
|
+
var lr = "@ahoo-wang/fetcher-eventstream";
|
|
1507
|
+
function ur(e) {
|
|
1508
|
+
z(e, lr, ["JsonEventStreamResultExtractor", "JsonServerSentEventStream"]);
|
|
1508
1509
|
}
|
|
1509
1510
|
//#endregion
|
|
1510
1511
|
//#region src/emitters/apiClients.ts
|
|
1511
|
-
function
|
|
1512
|
+
function dr(e, t) {
|
|
1512
1513
|
let n = t.modules.module(e.file);
|
|
1513
|
-
|
|
1514
|
-
let r =
|
|
1515
|
-
|
|
1514
|
+
ir(n), ar(n), ur(n);
|
|
1515
|
+
let r = or(e.className, n);
|
|
1516
|
+
V(r, [e.description]);
|
|
1516
1517
|
let i;
|
|
1517
|
-
e.basePath && (
|
|
1518
|
-
let a =
|
|
1519
|
-
for (let t of e.methods) (r.methods ??= []).push(
|
|
1518
|
+
e.basePath && (Sn(n, t.outputDir, e.basePath.alias, e.basePath.constantName), i = `basePath: ${e.basePath.constantName}`), sr(r, i);
|
|
1519
|
+
let a = fr(e.className, n, t);
|
|
1520
|
+
for (let t of e.methods) (r.methods ??= []).push(pr(t, a));
|
|
1520
1521
|
}
|
|
1521
|
-
function
|
|
1522
|
+
function fr(e, t, n) {
|
|
1522
1523
|
let r = {
|
|
1523
1524
|
context: n.types,
|
|
1524
1525
|
owner: { name: e },
|
|
1525
|
-
specifierOf: (e) =>
|
|
1526
|
+
specifierOf: (e) => bn(t, n.outputDir, e),
|
|
1526
1527
|
imports: t.imports
|
|
1527
1528
|
};
|
|
1528
1529
|
return {
|
|
1529
1530
|
module: t,
|
|
1530
1531
|
resolveType(e) {
|
|
1531
|
-
let n =
|
|
1532
|
+
let n = Gn(e, r);
|
|
1532
1533
|
return t.imports.apply(n.imports), n.text;
|
|
1533
1534
|
}
|
|
1534
1535
|
};
|
|
1535
1536
|
}
|
|
1536
|
-
function
|
|
1537
|
+
function pr(e, t) {
|
|
1537
1538
|
let n = [], r = [];
|
|
1538
1539
|
for (let i of e.parameters) (i.required ? n : r).push({
|
|
1539
1540
|
name: i.name,
|
|
@@ -1541,12 +1542,12 @@ function sr(e, t) {
|
|
|
1541
1542
|
hasQuestionToken: !i.required,
|
|
1542
1543
|
decorators: [{
|
|
1543
1544
|
name: i.location,
|
|
1544
|
-
arguments: [
|
|
1545
|
+
arguments: [T(i.parameterName)]
|
|
1545
1546
|
}]
|
|
1546
1547
|
});
|
|
1547
1548
|
e.body && (e.body.required ? n : r).push({
|
|
1548
1549
|
name: e.body.name,
|
|
1549
|
-
type:
|
|
1550
|
+
type: mr(e.body, t),
|
|
1550
1551
|
hasQuestionToken: !e.body.required,
|
|
1551
1552
|
decorators: [{
|
|
1552
1553
|
name: "body",
|
|
@@ -1574,24 +1575,24 @@ function sr(e, t) {
|
|
|
1574
1575
|
arguments: []
|
|
1575
1576
|
}]
|
|
1576
1577
|
}
|
|
1577
|
-
], a =
|
|
1578
|
+
], a = hr(e.returns, t), o = T(e.path), s = {
|
|
1578
1579
|
name: e.name,
|
|
1579
1580
|
decorators: [{
|
|
1580
|
-
name:
|
|
1581
|
+
name: cr(e.httpMethod),
|
|
1581
1582
|
arguments: a.metadata ? [o, a.metadata] : [o]
|
|
1582
1583
|
}],
|
|
1583
1584
|
parameters: i,
|
|
1584
1585
|
returnType: a.type,
|
|
1585
1586
|
statements: [`throw autoGeneratedError(${i.map((e) => e.name).join(",")});`]
|
|
1586
1587
|
};
|
|
1587
|
-
return
|
|
1588
|
+
return V(s, [...e.docs]), s;
|
|
1588
1589
|
}
|
|
1589
|
-
function
|
|
1590
|
+
function mr(e, t) {
|
|
1590
1591
|
let { content: n } = e;
|
|
1591
1592
|
switch (n.kind) {
|
|
1592
1593
|
case "json": {
|
|
1593
1594
|
let e = t.resolveType(n.schema), r = n.optionalFields;
|
|
1594
|
-
return r.length === 0 || /[|&]/.test(e) || e === "any" ? e : (
|
|
1595
|
+
return r.length === 0 || /[|&]/.test(e) || e === "any" ? e : (z(t.module, Xn, ["PartialBy"]), `PartialBy<${e}, ${r.map(T).join(" | ")}>`);
|
|
1595
1596
|
}
|
|
1596
1597
|
case "formData": return "FormData";
|
|
1597
1598
|
case "urlEncoded": return "URLSearchParams";
|
|
@@ -1599,31 +1600,31 @@ function cr(e, t) {
|
|
|
1599
1600
|
case "binary": return "BodyInit";
|
|
1600
1601
|
}
|
|
1601
1602
|
}
|
|
1602
|
-
function
|
|
1603
|
+
function hr(e, t) {
|
|
1603
1604
|
switch (e.kind) {
|
|
1604
1605
|
case "json": {
|
|
1605
1606
|
let n = t.resolveType(e.schema);
|
|
1606
|
-
return e.wildcard && n === "string" ?
|
|
1607
|
+
return e.wildcard && n === "string" ? tr : { type: `Promise<${n}>` };
|
|
1607
1608
|
}
|
|
1608
1609
|
case "eventStream": {
|
|
1609
1610
|
if (!e.items) return {
|
|
1610
1611
|
type: "Promise<JsonServerSentEventStream<any>>",
|
|
1611
|
-
metadata:
|
|
1612
|
+
metadata: nr
|
|
1612
1613
|
};
|
|
1613
1614
|
let n = t.resolveType(e.items);
|
|
1614
1615
|
return {
|
|
1615
1616
|
type: `Promise<JsonServerSentEventStream<${e.serverSentEvent ? `${n}['data']` : n}>>`,
|
|
1616
|
-
metadata:
|
|
1617
|
+
metadata: nr
|
|
1617
1618
|
};
|
|
1618
1619
|
}
|
|
1619
|
-
case "text": return
|
|
1620
|
-
case "response": return
|
|
1620
|
+
case "text": return tr;
|
|
1621
|
+
case "response": return er;
|
|
1621
1622
|
}
|
|
1622
1623
|
}
|
|
1623
1624
|
//#endregion
|
|
1624
1625
|
//#region src/emitters/commandClients.ts
|
|
1625
|
-
var
|
|
1626
|
-
function
|
|
1626
|
+
var gr = "DEFAULT_COMMAND_CLIENT_OPTIONS";
|
|
1627
|
+
function _r(e, t) {
|
|
1627
1628
|
let n = e.commandClient;
|
|
1628
1629
|
if (n.commands.length === 0) return;
|
|
1629
1630
|
let r = t.modules.module(n.file);
|
|
@@ -1631,51 +1632,51 @@ function dr(e, t) {
|
|
|
1631
1632
|
kind: o.Enum,
|
|
1632
1633
|
name: n.endpointPathsName,
|
|
1633
1634
|
isExported: !0,
|
|
1634
|
-
members:
|
|
1635
|
+
members: _n(n.commands.map((e) => ({
|
|
1635
1636
|
name: e.endpointMember,
|
|
1636
|
-
initializer:
|
|
1637
|
+
initializer: T(e.path)
|
|
1637
1638
|
})))
|
|
1638
1639
|
});
|
|
1639
|
-
let i = /* @__PURE__ */ new Set(), a = n.commands.map((e) =>
|
|
1640
|
-
|
|
1640
|
+
let i = /* @__PURE__ */ new Set(), a = n.commands.map((e) => vr(r, t.outputDir, e, i));
|
|
1641
|
+
Sn(r, t.outputDir, e.context.alias, e.context.constantName), r.add({
|
|
1641
1642
|
kind: o.VariableStatement,
|
|
1642
1643
|
declarationKind: c.Const,
|
|
1643
1644
|
declarations: [{
|
|
1644
|
-
name:
|
|
1645
|
+
name: gr,
|
|
1645
1646
|
type: "ApiMetadata",
|
|
1646
1647
|
initializer: `{
|
|
1647
1648
|
basePath: ${e.context.constantName}
|
|
1648
1649
|
}`
|
|
1649
1650
|
}],
|
|
1650
1651
|
isExported: !1
|
|
1651
|
-
}),
|
|
1652
|
+
}), z(r, F, [
|
|
1652
1653
|
"CommandRequest",
|
|
1653
1654
|
"CommandResult",
|
|
1654
1655
|
"CommandResultEventStream",
|
|
1655
1656
|
"CommandBody",
|
|
1656
|
-
|
|
1657
|
-
]),
|
|
1658
|
-
let s =
|
|
1659
|
-
|
|
1657
|
+
rr
|
|
1658
|
+
]), z(r, "@ahoo-wang/fetcher", ["PartialBy"]), ar(r);
|
|
1659
|
+
let s = or(n.className, r, [], ["R = CommandResult"]);
|
|
1660
|
+
sr(s, `...${gr}`);
|
|
1660
1661
|
for (let [e, t] of n.commands.entries()) {
|
|
1661
|
-
let r =
|
|
1662
|
+
let r = yr(t, a[e]), i = {
|
|
1662
1663
|
name: t.methodName,
|
|
1663
1664
|
decorators: [{
|
|
1664
|
-
name:
|
|
1665
|
+
name: cr(t.httpMethod),
|
|
1665
1666
|
arguments: [`${n.endpointPathsName}.${t.endpointMember}`]
|
|
1666
1667
|
}],
|
|
1667
1668
|
parameters: r,
|
|
1668
1669
|
returnType: "Promise<R>",
|
|
1669
1670
|
statements: `throw autoGeneratedError(${r.map((e) => e.name).join(",")});`
|
|
1670
1671
|
};
|
|
1671
|
-
(s.methods ??= []).push(i),
|
|
1672
|
+
(s.methods ??= []).push(i), V(i, [...t.docs]);
|
|
1672
1673
|
}
|
|
1673
|
-
|
|
1674
|
+
or(n.streamClassName, r, ["''", rr], [], `${n.className}<CommandResultEventStream>`);
|
|
1674
1675
|
}
|
|
1675
|
-
function
|
|
1676
|
-
if (n.body.path === "@ahoo-wang/wow-client") return
|
|
1677
|
-
|
|
1678
|
-
let i = n.body.name, a = n.optionalFields.map(
|
|
1676
|
+
function vr(e, t, n, r) {
|
|
1677
|
+
if (n.body.path === "@ahoo-wang/wow-client") return z(e, F, [n.typeName]), n.typeName;
|
|
1678
|
+
B(e, t, n.body);
|
|
1679
|
+
let i = n.body.name, a = n.optionalFields.map(T).join(" | ");
|
|
1679
1680
|
a !== "" && (i = `PartialBy<${i},${a}>`);
|
|
1680
1681
|
let s = `CommandBody<${i}>`;
|
|
1681
1682
|
return n.typeName === void 0 ? s : (r.has(n.typeName) || (r.add(n.typeName), e.add({
|
|
@@ -1685,7 +1686,7 @@ function fr(e, t, n, r) {
|
|
|
1685
1686
|
isExported: !0
|
|
1686
1687
|
})), n.typeName);
|
|
1687
1688
|
}
|
|
1688
|
-
function
|
|
1689
|
+
function yr(e, t) {
|
|
1689
1690
|
return [
|
|
1690
1691
|
...e.pathParameters.map((e) => ({
|
|
1691
1692
|
name: e.name,
|
|
@@ -1693,7 +1694,7 @@ function pr(e, t) {
|
|
|
1693
1694
|
hasQuestionToken: !1,
|
|
1694
1695
|
decorators: [{
|
|
1695
1696
|
name: "path",
|
|
1696
|
-
arguments: [
|
|
1697
|
+
arguments: [T(e.pathName)]
|
|
1697
1698
|
}]
|
|
1698
1699
|
})),
|
|
1699
1700
|
{
|
|
@@ -1718,33 +1719,33 @@ function pr(e, t) {
|
|
|
1718
1719
|
}
|
|
1719
1720
|
//#endregion
|
|
1720
1721
|
//#region src/emitters/models.ts
|
|
1721
|
-
function
|
|
1722
|
-
return
|
|
1723
|
-
ofKey: (e) =>
|
|
1724
|
-
ofReference:
|
|
1722
|
+
function br(e) {
|
|
1723
|
+
return Fn(e, {
|
|
1724
|
+
ofKey: (e) => L(e),
|
|
1725
|
+
ofReference: It
|
|
1725
1726
|
});
|
|
1726
1727
|
}
|
|
1727
|
-
function
|
|
1728
|
+
function xr(e, t) {
|
|
1728
1729
|
let n = t.modules.module(e.file);
|
|
1729
|
-
e.emptyMessageBody ?
|
|
1730
|
+
e.emptyMessageBody ? Dn(n.add({
|
|
1730
1731
|
kind: o.TypeAlias,
|
|
1731
1732
|
name: e.info.name,
|
|
1732
1733
|
type: "globalThis.Record<string, never>",
|
|
1733
1734
|
isExported: !0
|
|
1734
|
-
}), e.docSchema, e.key, t.schemaDocs === "full") : new
|
|
1735
|
+
}), e.docSchema, e.key, t.schemaDocs === "full") : new Cr(e, n, t).write();
|
|
1735
1736
|
}
|
|
1736
|
-
function
|
|
1737
|
+
function Sr(e) {
|
|
1737
1738
|
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map();
|
|
1738
1739
|
for (let r of e) {
|
|
1739
|
-
let e =
|
|
1740
|
+
let e = me(r), i = [e];
|
|
1740
1741
|
/^\d/.test(r) || i.push(r);
|
|
1741
1742
|
let a = i.find((e) => !t.has(e));
|
|
1742
1743
|
for (let n = 2; a === void 0; n++) t.has(`${e}_${n}`) || (a = `${e}_${n}`);
|
|
1743
|
-
t.add(a), n.set(r,
|
|
1744
|
+
t.add(a), n.set(r, w(a));
|
|
1744
1745
|
}
|
|
1745
1746
|
return n;
|
|
1746
1747
|
}
|
|
1747
|
-
var
|
|
1748
|
+
var Cr = class {
|
|
1748
1749
|
model;
|
|
1749
1750
|
module;
|
|
1750
1751
|
target;
|
|
@@ -1754,41 +1755,41 @@ var _r = class {
|
|
|
1754
1755
|
this.model = e, this.module = t, this.target = n, this.modelInfo = e.info, this.components = n.types.components, this.scope = {
|
|
1755
1756
|
context: n.types,
|
|
1756
1757
|
owner: e.info,
|
|
1757
|
-
specifierOf: (e) =>
|
|
1758
|
+
specifierOf: (e) => bn(t, n.outputDir, e),
|
|
1758
1759
|
imports: t.imports
|
|
1759
1760
|
};
|
|
1760
1761
|
}
|
|
1761
1762
|
write() {
|
|
1762
1763
|
let e = this.process();
|
|
1763
|
-
e &&
|
|
1764
|
+
e && Dn(e, this.model.docSchema, this.model.key, this.target.schemaDocs === "full");
|
|
1764
1765
|
}
|
|
1765
1766
|
process() {
|
|
1766
1767
|
let { schema: e } = this.model;
|
|
1767
|
-
return
|
|
1768
|
+
return D(e) ? this.processTypeAlias(e) : Re(e) ? this.processEnum(e) : e.const !== void 0 || e.nullable && e.type || N(e) && (e.type || e.properties || e.required) ? this.processTypeAlias(e) : Ve(e) ? this.processInterface(e) : qe(e) && typeof e.additionalProperties == "object" && !Ye(e) && !e.required?.length ? this.processIndexSignature(e) : He(e) ? this.processArray(e) : N(e) ? this.processComposition(e) : this.processTypeAlias(e);
|
|
1768
1769
|
}
|
|
1769
1770
|
scope;
|
|
1770
1771
|
emit(e) {
|
|
1771
1772
|
return this.module.imports.apply(e.imports), e.text;
|
|
1772
1773
|
}
|
|
1773
1774
|
resolveType(e) {
|
|
1774
|
-
return this.emit(
|
|
1775
|
+
return this.emit(Gn(e, this.scope));
|
|
1775
1776
|
}
|
|
1776
1777
|
processEnum(e) {
|
|
1777
|
-
let t =
|
|
1778
|
+
let t = Be(e);
|
|
1778
1779
|
if (t) {
|
|
1779
|
-
let e =
|
|
1780
|
+
let e = Sr(Object.keys(t));
|
|
1780
1781
|
this.module.add({
|
|
1781
1782
|
kind: o.Enum,
|
|
1782
1783
|
name: this.modelInfo.name + "EnumText",
|
|
1783
1784
|
isExported: !0,
|
|
1784
1785
|
members: [...e].map(([e, n]) => ({
|
|
1785
1786
|
name: n,
|
|
1786
|
-
initializer:
|
|
1787
|
+
initializer: U(t[e])
|
|
1787
1788
|
}))
|
|
1788
1789
|
});
|
|
1789
1790
|
}
|
|
1790
|
-
let n = [...new Set(e.enum.filter((e) => typeof e == "string"))], r =
|
|
1791
|
-
return
|
|
1791
|
+
let n = [...new Set(e.enum.filter((e) => typeof e == "string"))], r = Sr(n);
|
|
1792
|
+
return N(e) || e.const !== void 0 || e.type !== void 0 && e.type !== "string" || e.enum.some((e) => typeof e != "string") ? (n.length && this.module.add({
|
|
1792
1793
|
kind: o.VariableStatement,
|
|
1793
1794
|
declarationKind: c.Const,
|
|
1794
1795
|
isExported: !0,
|
|
@@ -1806,20 +1807,20 @@ var _r = class {
|
|
|
1806
1807
|
isExported: !0,
|
|
1807
1808
|
members: n.map((e) => ({
|
|
1808
1809
|
name: r.get(e),
|
|
1809
|
-
initializer:
|
|
1810
|
+
initializer: U(e)
|
|
1810
1811
|
}))
|
|
1811
1812
|
});
|
|
1812
1813
|
}
|
|
1813
1814
|
addPropertyToInterface(e, t, n) {
|
|
1814
1815
|
let r = {
|
|
1815
|
-
name:
|
|
1816
|
+
name: w(t),
|
|
1816
1817
|
type: this.resolveType(n),
|
|
1817
|
-
isReadonly:
|
|
1818
|
+
isReadonly: Ze(n)
|
|
1818
1819
|
};
|
|
1819
|
-
(e.properties ??= []).push(r),
|
|
1820
|
+
(e.properties ??= []).push(r), En(r, n);
|
|
1820
1821
|
}
|
|
1821
1822
|
processInterface(e) {
|
|
1822
|
-
if (
|
|
1823
|
+
if (Vn(e, this.components)) return this.processTypeAlias(e);
|
|
1823
1824
|
let t = [], n = this.module.add({
|
|
1824
1825
|
kind: o.Interface,
|
|
1825
1826
|
name: this.modelInfo.name,
|
|
@@ -1830,17 +1831,17 @@ var _r = class {
|
|
|
1830
1831
|
this.addPropertyToInterface(n, e, t);
|
|
1831
1832
|
});
|
|
1832
1833
|
for (let n of e.required ?? []) Object.hasOwn(r, n) || t.push({
|
|
1833
|
-
name:
|
|
1834
|
-
type: this.emit(
|
|
1834
|
+
name: w(n),
|
|
1835
|
+
type: this.emit(Jn(e, this.scope))
|
|
1835
1836
|
});
|
|
1836
|
-
return this.emit(
|
|
1837
|
+
return this.emit(Kn(e, this.scope)) && t.push(vn(this.emit(qn(e, this.scope)), ["Additional properties"])), n;
|
|
1837
1838
|
}
|
|
1838
1839
|
processArray(e) {
|
|
1839
1840
|
let t = this.resolveType(e.items);
|
|
1840
1841
|
return this.module.add({
|
|
1841
1842
|
kind: o.TypeAlias,
|
|
1842
1843
|
name: this.modelInfo.name,
|
|
1843
|
-
type:
|
|
1844
|
+
type: Ke(t),
|
|
1844
1845
|
isExported: !0
|
|
1845
1846
|
});
|
|
1846
1847
|
}
|
|
@@ -1849,7 +1850,7 @@ var _r = class {
|
|
|
1849
1850
|
kind: o.Interface,
|
|
1850
1851
|
name: this.modelInfo.name,
|
|
1851
1852
|
isExported: !0,
|
|
1852
|
-
properties: [
|
|
1853
|
+
properties: [vn(this.emit(Yn(e, this.scope)))]
|
|
1853
1854
|
});
|
|
1854
1855
|
}
|
|
1855
1856
|
processComposition(e) {
|
|
@@ -1868,22 +1869,22 @@ var _r = class {
|
|
|
1868
1869
|
isExported: !0
|
|
1869
1870
|
});
|
|
1870
1871
|
}
|
|
1871
|
-
},
|
|
1872
|
-
function
|
|
1872
|
+
}, wr = "DEFAULT_QUERY_CLIENT_OPTIONS";
|
|
1873
|
+
function Tr(e, t) {
|
|
1873
1874
|
let n = e.queryClient, r = t.modules.module(n.file);
|
|
1874
|
-
|
|
1875
|
+
z(r, F, [
|
|
1875
1876
|
"QueryClientFactory",
|
|
1876
1877
|
"QueryClientOptions",
|
|
1877
1878
|
"ResourceAttributionPathSpec"
|
|
1878
|
-
]),
|
|
1879
|
+
]), Sn(r, t.outputDir, e.context.alias, e.context.constantName), r.add({
|
|
1879
1880
|
kind: o.VariableStatement,
|
|
1880
1881
|
declarationKind: c.Const,
|
|
1881
1882
|
declarations: [{
|
|
1882
|
-
name:
|
|
1883
|
+
name: wr,
|
|
1883
1884
|
type: "QueryClientOptions",
|
|
1884
1885
|
initializer: `{
|
|
1885
1886
|
contextAlias: ${e.context.constantName},
|
|
1886
|
-
aggregateName: ${
|
|
1887
|
+
aggregateName: ${T(n.resourceName)},
|
|
1887
1888
|
resourceAttribution: ${n.resourceAttribution},
|
|
1888
1889
|
}`
|
|
1889
1890
|
}],
|
|
@@ -1892,61 +1893,61 @@ function yr(e, t) {
|
|
|
1892
1893
|
kind: o.Enum,
|
|
1893
1894
|
name: n.eventTitlesName,
|
|
1894
1895
|
isExported: !0,
|
|
1895
|
-
members:
|
|
1896
|
+
members: _n(n.events.map((e) => ({
|
|
1896
1897
|
name: e.memberName,
|
|
1897
|
-
initializer:
|
|
1898
|
+
initializer: T(e.title)
|
|
1898
1899
|
})))
|
|
1899
1900
|
});
|
|
1900
|
-
for (let e of n.events)
|
|
1901
|
+
for (let e of n.events) B(r, t.outputDir, e.body);
|
|
1901
1902
|
r.add({
|
|
1902
1903
|
kind: o.TypeAlias,
|
|
1903
1904
|
isExported: !0,
|
|
1904
1905
|
name: n.eventTypeName,
|
|
1905
1906
|
type: n.events.map((e) => e.body.name).join(" | ") || "never"
|
|
1906
|
-
}),
|
|
1907
|
+
}), B(r, t.outputDir, n.state), B(r, t.outputDir, n.fields), r.add({
|
|
1907
1908
|
kind: o.VariableStatement,
|
|
1908
1909
|
declarationKind: c.Const,
|
|
1909
1910
|
declarations: [{
|
|
1910
1911
|
name: n.factoryName,
|
|
1911
|
-
initializer: `new QueryClientFactory<${n.state.name}, \`\${${n.fields.name}}\`, ${n.eventTypeName}>(${
|
|
1912
|
+
initializer: `new QueryClientFactory<${n.state.name}, \`\${${n.fields.name}}\`, ${n.eventTypeName}>(${wr})`
|
|
1912
1913
|
}],
|
|
1913
1914
|
isExported: !0
|
|
1914
1915
|
});
|
|
1915
1916
|
}
|
|
1916
1917
|
//#endregion
|
|
1917
1918
|
//#region src/emitters/emit.ts
|
|
1918
|
-
function
|
|
1919
|
-
e.contexts.forEach((e) =>
|
|
1919
|
+
function Er(e, t) {
|
|
1920
|
+
e.contexts.forEach((e) => Dr(e, t)), e.models.forEach((e) => xr(e, t)), e.aggregates.forEach((e) => Tr(e, t)), e.aggregates.forEach((e) => _r(e, t)), e.apiClients.forEach((e) => dr(e, t));
|
|
1920
1921
|
}
|
|
1921
|
-
function
|
|
1922
|
-
t.modules.module(e.file).add(`export const ${e.constantName} = ${
|
|
1922
|
+
function Dr(e, t) {
|
|
1923
|
+
t.modules.module(e.file).add(`export const ${e.constantName} = ${T(e.alias)};`);
|
|
1923
1924
|
}
|
|
1924
1925
|
//#endregion
|
|
1925
1926
|
//#region src/emitters/indexFiles.ts
|
|
1926
|
-
function
|
|
1927
|
+
function Or(e, t) {
|
|
1927
1928
|
let n = [];
|
|
1928
|
-
return
|
|
1929
|
+
return kr(e, t, n), n;
|
|
1929
1930
|
}
|
|
1930
|
-
function
|
|
1931
|
+
function kr(e, t, n) {
|
|
1931
1932
|
let r = [];
|
|
1932
1933
|
for (let t of e.getSourceFiles()) {
|
|
1933
1934
|
let e = t.getBaseName();
|
|
1934
1935
|
e.endsWith(".ts") && e !== "index.ts" && r.push({
|
|
1935
1936
|
specifier: `./${t.getBaseNameWithoutExtension()}.js`,
|
|
1936
|
-
exports:
|
|
1937
|
+
exports: jr(t)
|
|
1937
1938
|
});
|
|
1938
1939
|
}
|
|
1939
1940
|
for (let i of e.getDirectories()) {
|
|
1940
|
-
let e =
|
|
1941
|
+
let e = kr(i, t, n);
|
|
1941
1942
|
e && r.push({
|
|
1942
1943
|
specifier: `./${i.getBaseName()}/index.js`,
|
|
1943
1944
|
exports: e
|
|
1944
1945
|
});
|
|
1945
1946
|
}
|
|
1946
1947
|
let i = e.getPath();
|
|
1947
|
-
return r.length === 0 ? e.getProject().getSourceFile(`${i}/index.ts`) ? /* @__PURE__ */ new Map() : void 0 :
|
|
1948
|
+
return r.length === 0 ? e.getProject().getSourceFile(`${i}/index.ts`) ? /* @__PURE__ */ new Map() : void 0 : Ar(i, r, t, n);
|
|
1948
1949
|
}
|
|
1949
|
-
function
|
|
1950
|
+
function Ar(e, t, n, r) {
|
|
1950
1951
|
let i = /* @__PURE__ */ new Map();
|
|
1951
1952
|
for (let e of t) for (let t of e.exports.keys()) i.set(t, [...i.get(t) ?? [], e.specifier]);
|
|
1952
1953
|
let a = [...i].filter(([, e]) => e.length > 1).map(([e]) => e).sort();
|
|
@@ -1955,7 +1956,7 @@ function wr(e, t, n, r) {
|
|
|
1955
1956
|
o.removeText();
|
|
1956
1957
|
let s = /* @__PURE__ */ new Map();
|
|
1957
1958
|
for (let e of t) {
|
|
1958
|
-
let t = [...e.exports].filter(([e]) => !a.includes(e)).sort(([e], [t]) =>
|
|
1959
|
+
let t = [...e.exports].filter(([e]) => !a.includes(e)).sort(([e], [t]) => E(e, t));
|
|
1959
1960
|
t.forEach(([e, t]) => s.set(e, t)), t.length === e.exports.size ? o.addExportDeclaration({ moduleSpecifier: e.specifier }) : t.length > 0 && o.addExportDeclaration({
|
|
1960
1961
|
moduleSpecifier: e.specifier,
|
|
1961
1962
|
namedExports: t.map(([e, t]) => ({
|
|
@@ -1966,14 +1967,14 @@ function wr(e, t, n, r) {
|
|
|
1966
1967
|
}
|
|
1967
1968
|
return o.getStatements().length === 0 && o.addStatements("export {};"), s;
|
|
1968
1969
|
}
|
|
1969
|
-
function
|
|
1970
|
+
function jr(e) {
|
|
1970
1971
|
let t = /* @__PURE__ */ new Map();
|
|
1971
1972
|
for (let [r, i] of e.getExportedDeclarations()) t.set(r, i.every((e) => n.isInterfaceDeclaration(e) || n.isTypeAliasDeclaration(e)));
|
|
1972
1973
|
return t;
|
|
1973
1974
|
}
|
|
1974
1975
|
//#endregion
|
|
1975
1976
|
//#region src/finalize/typeOnlyImports.ts
|
|
1976
|
-
function
|
|
1977
|
+
function Mr(e) {
|
|
1977
1978
|
let t = e;
|
|
1978
1979
|
for (let e = t.getParent(); e; t = e, e = e.getParent()) if (n.isQualifiedName(e)) {
|
|
1979
1980
|
if (e.getLeft() !== t) return !1;
|
|
@@ -1988,22 +1989,22 @@ function Er(e) {
|
|
|
1988
1989
|
}
|
|
1989
1990
|
return !1;
|
|
1990
1991
|
}
|
|
1991
|
-
function
|
|
1992
|
+
function Nr(e) {
|
|
1992
1993
|
let t = e.getImportDeclarations().filter((e) => !e.getDefaultImport() && !e.getNamespaceImport() && e.getNamedImports().length > 0);
|
|
1993
1994
|
if (t.length === 0) return [];
|
|
1994
1995
|
let r = new Set(t.flatMap((e) => e.getNamedImports().map((e) => (e.getAliasNode() ?? e.getNameNode()).getText()))), i = /* @__PURE__ */ new Set();
|
|
1995
1996
|
return e.forEachDescendant((e, t) => {
|
|
1996
1997
|
if (n.isImportDeclaration(e)) t.skip();
|
|
1997
|
-
else if (n.isIdentifier(e) && r.has(e.getText()) && !
|
|
1998
|
+
else if (n.isIdentifier(e) && r.has(e.getText()) && !Mr(e)) {
|
|
1998
1999
|
let t = e.getSymbol();
|
|
1999
2000
|
t && i.add(t.compilerSymbol);
|
|
2000
2001
|
}
|
|
2001
|
-
}), t.map((e) =>
|
|
2002
|
+
}), t.map((e) => Pr(e, (e) => {
|
|
2002
2003
|
let t = e.getSymbol();
|
|
2003
2004
|
return !!t && !i.has(t.compilerSymbol);
|
|
2004
2005
|
}));
|
|
2005
2006
|
}
|
|
2006
|
-
function
|
|
2007
|
+
function Pr(e, t) {
|
|
2007
2008
|
let n = e.getNamedImports(), r = n.map(t), i = r.every(Boolean);
|
|
2008
2009
|
return () => {
|
|
2009
2010
|
n.forEach((e, t) => {
|
|
@@ -2012,13 +2013,13 @@ function Or(e, t) {
|
|
|
2012
2013
|
}), e.isTypeOnly() !== i && e.setIsTypeOnly(i);
|
|
2013
2014
|
};
|
|
2014
2015
|
}
|
|
2015
|
-
function
|
|
2016
|
-
let t = e.flatMap(
|
|
2016
|
+
function Fr(e) {
|
|
2017
|
+
let t = e.flatMap(Nr);
|
|
2017
2018
|
for (let e of t) e();
|
|
2018
2019
|
}
|
|
2019
2020
|
//#endregion
|
|
2020
2021
|
//#region src/finalize/verification.ts
|
|
2021
|
-
var
|
|
2022
|
+
var Ir = /* @__PURE__ */ new Set([
|
|
2022
2023
|
2300,
|
|
2023
2024
|
2304,
|
|
2024
2025
|
2308,
|
|
@@ -2028,10 +2029,10 @@ var Ar = /* @__PURE__ */ new Set([
|
|
|
2028
2029
|
2503,
|
|
2029
2030
|
2552
|
|
2030
2031
|
]);
|
|
2031
|
-
function
|
|
2032
|
+
function Lr(e) {
|
|
2032
2033
|
let t = [];
|
|
2033
2034
|
for (let n of e) for (let e of n.getPreEmitDiagnostics()) {
|
|
2034
|
-
if (!
|
|
2035
|
+
if (!Ir.has(e.getCode()) || e.getSourceFile() !== n) continue;
|
|
2035
2036
|
let r = l.flattenDiagnosticMessageText(e.compilerObject.messageText, " ");
|
|
2036
2037
|
t.push(`${n.getFilePath()}:${e.getLineNumber() ?? 0} TS${e.getCode()} ${r}`);
|
|
2037
2038
|
}
|
|
@@ -2039,29 +2040,29 @@ function jr(e) {
|
|
|
2039
2040
|
}
|
|
2040
2041
|
//#endregion
|
|
2041
2042
|
//#region src/finalize/finalize.ts
|
|
2042
|
-
var
|
|
2043
|
+
var Rr = "// Code generated by wow-generator. DO NOT EDIT.\n\n", zr = {
|
|
2043
2044
|
indentSize: 2,
|
|
2044
2045
|
tabSize: 2,
|
|
2045
2046
|
convertTabsToSpaces: !0,
|
|
2046
2047
|
semicolons: "insert",
|
|
2047
2048
|
insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: !0
|
|
2048
2049
|
};
|
|
2049
|
-
function
|
|
2050
|
+
function Br(e, t) {
|
|
2050
2051
|
e.forEach((n, r) => {
|
|
2051
|
-
t.debug(`Optimizing file [${n.getFilePath()}] - ${r + 1}/${e.length}`), n.formatText(
|
|
2052
|
-
}),
|
|
2053
|
-
for (let t of e) t.insertText(0,
|
|
2052
|
+
t.debug(`Optimizing file [${n.getFilePath()}] - ${r + 1}/${e.length}`), n.formatText(zr), n.organizeImports(zr);
|
|
2053
|
+
}), Fr(e), Lr(e);
|
|
2054
|
+
for (let t of e) t.insertText(0, Rr);
|
|
2054
2055
|
}
|
|
2055
2056
|
//#endregion
|
|
2056
2057
|
//#region src/input/resources.ts
|
|
2057
|
-
var
|
|
2058
|
-
function
|
|
2058
|
+
var Vr = 3e4;
|
|
2059
|
+
function Hr(e) {
|
|
2059
2060
|
return /^https?:\/\//i.test(e);
|
|
2060
2061
|
}
|
|
2061
|
-
function
|
|
2062
|
-
return
|
|
2062
|
+
function Ur(e, t = {}) {
|
|
2063
|
+
return Hr(e) ? Wr(e, t) : Kr(e);
|
|
2063
2064
|
}
|
|
2064
|
-
async function
|
|
2065
|
+
async function Wr(e, t = {}) {
|
|
2065
2066
|
let n = t.timeoutMs ?? 3e4, r;
|
|
2066
2067
|
try {
|
|
2067
2068
|
let i = AbortSignal.timeout(n);
|
|
@@ -2070,7 +2071,7 @@ async function Rr(e, t = {}) {
|
|
|
2070
2071
|
signal: t.signal ? AbortSignal.any([t.signal, i]) : i
|
|
2071
2072
|
});
|
|
2072
2073
|
} catch (e) {
|
|
2073
|
-
let t = e instanceof Error && e.name === "TimeoutError" ? `no response within ${n} ms` :
|
|
2074
|
+
let t = e instanceof Error && e.name === "TimeoutError" ? `no response within ${n} ms` : Gr(e);
|
|
2074
2075
|
throw Error(t, { cause: e });
|
|
2075
2076
|
}
|
|
2076
2077
|
if (!r.ok) {
|
|
@@ -2079,36 +2080,34 @@ async function Rr(e, t = {}) {
|
|
|
2079
2080
|
}
|
|
2080
2081
|
return await r.text();
|
|
2081
2082
|
}
|
|
2082
|
-
function
|
|
2083
|
+
function Gr(e) {
|
|
2083
2084
|
if (!(e instanceof Error)) return String(e);
|
|
2084
2085
|
let t = e.cause;
|
|
2085
2086
|
return t instanceof Error && t.message ? `${e.message} (${t.message})` : e.message;
|
|
2086
2087
|
}
|
|
2087
|
-
function
|
|
2088
|
+
function Kr(e) {
|
|
2088
2089
|
return new Promise((t, n) => {
|
|
2089
|
-
|
|
2090
|
+
ee(e, "utf-8", (e, r) => {
|
|
2090
2091
|
e ? n(e) : t(r);
|
|
2091
2092
|
});
|
|
2092
2093
|
});
|
|
2093
2094
|
}
|
|
2094
2095
|
//#endregion
|
|
2095
2096
|
//#region src/input/parsers.ts
|
|
2096
|
-
async function
|
|
2097
|
+
async function qr(e, t) {
|
|
2097
2098
|
let n;
|
|
2098
2099
|
try {
|
|
2099
|
-
n = await
|
|
2100
|
+
n = await Ur(e, t);
|
|
2100
2101
|
} catch (t) {
|
|
2101
2102
|
throw new _("input", `Cannot read the OpenAPI document ${e}: ${v(t)}`, { cause: t });
|
|
2102
2103
|
}
|
|
2103
|
-
let r;
|
|
2104
2104
|
try {
|
|
2105
|
-
|
|
2105
|
+
return Yr(n);
|
|
2106
2106
|
} catch (t) {
|
|
2107
2107
|
throw new _("input", `Cannot parse the OpenAPI document ${e}: ${v(t)}`, { cause: t });
|
|
2108
2108
|
}
|
|
2109
|
-
return Hr(r, e);
|
|
2110
2109
|
}
|
|
2111
|
-
function
|
|
2110
|
+
function Jr(e, t) {
|
|
2112
2111
|
if (typeof e != "object" || !e || Array.isArray(e)) throw new _("input", `${t} is not an OpenAPI document: expected an object at the top level.`);
|
|
2113
2112
|
let n = e;
|
|
2114
2113
|
if (n.swagger !== void 0) throw new _("input", `${t} is a Swagger ${String(n.swagger)} document; wow-generator reads OpenAPI 3.x only. Convert it first, for example with swagger2openapi.`);
|
|
@@ -2119,13 +2118,13 @@ function Hr(e, t) {
|
|
|
2119
2118
|
paths: n.paths ?? {}
|
|
2120
2119
|
};
|
|
2121
2120
|
}
|
|
2122
|
-
function
|
|
2123
|
-
switch (
|
|
2121
|
+
function Yr(e) {
|
|
2122
|
+
switch (Xr(e)) {
|
|
2124
2123
|
case "json": return JSON.parse(e);
|
|
2125
|
-
case "yaml": return
|
|
2124
|
+
case "yaml": return h(e);
|
|
2126
2125
|
}
|
|
2127
2126
|
}
|
|
2128
|
-
function
|
|
2127
|
+
function Xr(e) {
|
|
2129
2128
|
let t = e.trimStart();
|
|
2130
2129
|
if (t.startsWith("{") || t.startsWith("[")) return "json";
|
|
2131
2130
|
if (t.startsWith("-") || t.startsWith("%YAML")) return "yaml";
|
|
@@ -2138,25 +2137,25 @@ function Wr(e) {
|
|
|
2138
2137
|
}
|
|
2139
2138
|
//#endregion
|
|
2140
2139
|
//#region src/input/configuration.ts
|
|
2141
|
-
var
|
|
2142
|
-
async function
|
|
2140
|
+
var Zr = "./fetcher-generator.config.json";
|
|
2141
|
+
async function Qr(e, t, n) {
|
|
2143
2142
|
if (e !== void 0) return {
|
|
2144
|
-
...await
|
|
2143
|
+
...await ti({
|
|
2145
2144
|
path: e,
|
|
2146
2145
|
explicit: !0
|
|
2147
2146
|
}, t, n),
|
|
2148
|
-
origin:
|
|
2147
|
+
origin: G(e)
|
|
2149
2148
|
};
|
|
2150
|
-
for (let e of [
|
|
2151
|
-
let r = await
|
|
2149
|
+
for (let e of [ne, Zr]) {
|
|
2150
|
+
let r = await ti({
|
|
2152
2151
|
path: e,
|
|
2153
2152
|
explicit: !1
|
|
2154
2153
|
}, t, n);
|
|
2155
2154
|
if (r === void 0) continue;
|
|
2156
2155
|
let i = [...r.warnings];
|
|
2157
|
-
return e === "./fetcher-generator.config.json" && i.push(`${
|
|
2156
|
+
return e === "./fetcher-generator.config.json" && i.push(`${G(e)} uses the deprecated name; rename it to ${ne.slice(2)}. The old name is no longer read from v10.`), {
|
|
2158
2157
|
config: r.config,
|
|
2159
|
-
origin:
|
|
2158
|
+
origin: G(e),
|
|
2160
2159
|
warnings: i
|
|
2161
2160
|
};
|
|
2162
2161
|
}
|
|
@@ -2165,15 +2164,15 @@ async function Kr(e, t, n) {
|
|
|
2165
2164
|
warnings: []
|
|
2166
2165
|
};
|
|
2167
2166
|
}
|
|
2168
|
-
var
|
|
2169
|
-
async function
|
|
2170
|
-
let r =
|
|
2167
|
+
var $r = ["apiClients"], ei = ["ignorePathParameters", "methodNames"];
|
|
2168
|
+
async function ti(e, t, n) {
|
|
2169
|
+
let r = G(e.path);
|
|
2171
2170
|
t.debug(`Reading configuration: ${r}`);
|
|
2172
2171
|
let i;
|
|
2173
2172
|
try {
|
|
2174
|
-
i = await
|
|
2173
|
+
i = await Ur(e.path, n);
|
|
2175
2174
|
} catch (n) {
|
|
2176
|
-
if (!e.explicit &&
|
|
2175
|
+
if (!e.explicit && ni(n)) {
|
|
2177
2176
|
t.debug(`No configuration file at ${r}`);
|
|
2178
2177
|
return;
|
|
2179
2178
|
}
|
|
@@ -2185,69 +2184,500 @@ async function Yr(e, t, n) {
|
|
|
2185
2184
|
};
|
|
2186
2185
|
let a;
|
|
2187
2186
|
try {
|
|
2188
|
-
a =
|
|
2187
|
+
a = Yr(i);
|
|
2189
2188
|
} catch (e) {
|
|
2190
2189
|
throw new _("configuration", `Cannot parse configuration ${r}: ${v(e)}`, { cause: e });
|
|
2191
2190
|
}
|
|
2192
|
-
let o =
|
|
2193
|
-
return t.debug(`Configuration loaded from ${r}: ${
|
|
2191
|
+
let o = ii(a, r);
|
|
2192
|
+
return t.debug(`Configuration loaded from ${r}: ${oi(o.config)}`), o;
|
|
2194
2193
|
}
|
|
2195
|
-
function
|
|
2196
|
-
return
|
|
2194
|
+
function G(e) {
|
|
2195
|
+
return Hr(e) || u(e) ? e : p(e);
|
|
2197
2196
|
}
|
|
2198
|
-
function
|
|
2197
|
+
function ni(e) {
|
|
2199
2198
|
return typeof e == "object" && !!e && e.code === "ENOENT";
|
|
2200
2199
|
}
|
|
2201
|
-
function
|
|
2200
|
+
function K(e) {
|
|
2202
2201
|
return e === null ? "null" : Array.isArray(e) ? "an array" : `a ${typeof e}`;
|
|
2203
2202
|
}
|
|
2204
|
-
function
|
|
2203
|
+
function q(e) {
|
|
2205
2204
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
2206
2205
|
}
|
|
2207
|
-
function
|
|
2206
|
+
function ri(e, t, n, r, i) {
|
|
2208
2207
|
let a = Object.keys(r).filter((e) => !i.includes(e));
|
|
2209
2208
|
a.length && e.push(`Ignoring unknown ${n} option(s) in ${t}: ${a.join(", ")}. Known option(s): ${i.join(", ")}`);
|
|
2210
2209
|
}
|
|
2211
|
-
function
|
|
2212
|
-
if (!
|
|
2210
|
+
function ii(e, t) {
|
|
2211
|
+
if (!q(e)) throw new _("configuration", `Configuration ${t} must be a JSON or YAML object, found ${K(e)}`);
|
|
2213
2212
|
let n = [];
|
|
2214
|
-
return
|
|
2213
|
+
return ri(n, t, "configuration", e, $r), ai(e.apiClients, t, n), {
|
|
2215
2214
|
config: e,
|
|
2216
2215
|
warnings: n
|
|
2217
2216
|
};
|
|
2218
2217
|
}
|
|
2219
|
-
function
|
|
2218
|
+
function ai(e, t, n) {
|
|
2220
2219
|
if (e !== void 0) {
|
|
2221
|
-
if (!
|
|
2220
|
+
if (!q(e)) throw new _("configuration", `apiClients in ${t} must be an object keyed by tag name, found ${K(e)}`);
|
|
2222
2221
|
for (let [r, i] of Object.entries(e)) {
|
|
2223
|
-
if (!
|
|
2224
|
-
|
|
2222
|
+
if (!q(i)) throw new _("configuration", `apiClients["${r}"] in ${t} must be an object, found ${K(i)}`);
|
|
2223
|
+
ri(n, t, `apiClients["${r}"]`, i, ei);
|
|
2225
2224
|
let { ignorePathParameters: e } = i;
|
|
2226
|
-
if (e !== void 0 && !(Array.isArray(e) && e.every((e) => typeof e == "string"))) throw new _("configuration", `apiClients["${r}"].ignorePathParameters in ${t} must be an array of strings, found ${
|
|
2225
|
+
if (e !== void 0 && !(Array.isArray(e) && e.every((e) => typeof e == "string"))) throw new _("configuration", `apiClients["${r}"].ignorePathParameters in ${t} must be an array of strings, found ${K(e)}`);
|
|
2227
2226
|
let { methodNames: a } = i;
|
|
2228
2227
|
if (a !== void 0) {
|
|
2229
|
-
if (!
|
|
2228
|
+
if (!q(a)) throw new _("configuration", `apiClients["${r}"].methodNames in ${t} must be an object mapping operationIds to method names, found ${K(a)}`);
|
|
2230
2229
|
for (let [e, n] of Object.entries(a)) if (typeof n != "string" || !y(n)) throw new _("configuration", `apiClients["${r}"].methodNames["${e}"] in ${t} must be a valid method name, found ${JSON.stringify(n)}`);
|
|
2231
2230
|
}
|
|
2232
2231
|
}
|
|
2233
2232
|
}
|
|
2234
2233
|
}
|
|
2235
|
-
function
|
|
2234
|
+
function oi(e) {
|
|
2236
2235
|
let t = Object.keys(e.apiClients ?? {});
|
|
2237
2236
|
return `apiClients=${t.length ? t.join(", ") : "none"}`;
|
|
2238
2237
|
}
|
|
2238
|
+
var si = "#/$defs/";
|
|
2239
|
+
function J(e) {
|
|
2240
|
+
return e.startsWith(si) ? e.slice(8) : void 0;
|
|
2241
|
+
}
|
|
2242
|
+
function ci(e) {
|
|
2243
|
+
if (typeof e != "object" || !e) return !1;
|
|
2244
|
+
let t = e;
|
|
2245
|
+
return t.openapi === void 0 && t.swagger === void 0 && typeof t.format == "number" && Array.isArray(t.contexts);
|
|
2246
|
+
}
|
|
2247
|
+
function Y(e) {
|
|
2248
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
2249
|
+
}
|
|
2250
|
+
function li(e, t) {
|
|
2251
|
+
let n = e;
|
|
2252
|
+
if (n.format !== 1) throw new _("input", `${t} is a Wow Manifest of format ${n.format}; wow-generator reads format 1.`);
|
|
2253
|
+
let r = [];
|
|
2254
|
+
if (n.contexts.forEach((e, t) => {
|
|
2255
|
+
!Y(e) || typeof e.name != "string" ? r.push(`contexts[${t}] has no name`) : (e.aggregates ?? []).forEach((t, n) => {
|
|
2256
|
+
let i = `${e.name}.aggregates[${n}]`;
|
|
2257
|
+
!Y(t) || typeof t.name != "string" ? r.push(`${i} has no name`) : !Y(t.state) || typeof t.state.schema != "string" ? r.push(`${e.name}.${t.name} has no state schema`) : ((t.commands ?? []).forEach((n) => {
|
|
2258
|
+
(typeof n?.name != "string" || typeof n.schema != "string") && r.push(`a command of ${e.name}.${t.name} has no name or schema`);
|
|
2259
|
+
}), (t.events ?? []).forEach((n) => {
|
|
2260
|
+
(typeof n?.name != "string" || typeof n.schema != "string") && r.push(`an event of ${e.name}.${t.name} has no name or schema`);
|
|
2261
|
+
}));
|
|
2262
|
+
});
|
|
2263
|
+
}), n.$defs !== void 0 && !Y(n.$defs) && r.push("$defs is not an object"), r.length > 0) throw new _("specification", `${t} is not a Manifest wow-generator can read: ${r.join("; ")}.`);
|
|
2264
|
+
return n;
|
|
2265
|
+
}
|
|
2266
|
+
//#endregion
|
|
2267
|
+
//#region src/manifest/analyze.ts
|
|
2268
|
+
var ui = {
|
|
2269
|
+
"wow.lifecycle.TransferOwner": "TransferOwner",
|
|
2270
|
+
"wow.lifecycle.TransferSpace": "TransferSpace",
|
|
2271
|
+
"wow.lifecycle.ApplyTags": "ApplyTags"
|
|
2272
|
+
}, di = /* @__PURE__ */ new Set([
|
|
2273
|
+
"wow.lifecycle.DeleteAggregate",
|
|
2274
|
+
"wow.lifecycle.RestoreAggregate",
|
|
2275
|
+
"wow.lifecycle.TransferOwner",
|
|
2276
|
+
"wow.lifecycle.TransferSpace",
|
|
2277
|
+
"wow.lifecycle.ApplyTags"
|
|
2278
|
+
]), fi = 4;
|
|
2279
|
+
function X(e) {
|
|
2280
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
2281
|
+
}
|
|
2282
|
+
function pi(e) {
|
|
2283
|
+
let t = e.type;
|
|
2284
|
+
return typeof t == "string" ? [t] : Array.isArray(t) ? t.filter((e) => typeof e == "string") : [];
|
|
2285
|
+
}
|
|
2286
|
+
function mi(e, t) {
|
|
2287
|
+
let n = [...new Set(e)];
|
|
2288
|
+
return n.length === 1 ? n[0] : n.map((e) => / [|&] /.test(e) && !e.startsWith("{") ? `(${e})` : e).join(t);
|
|
2289
|
+
}
|
|
2290
|
+
function hi(e) {
|
|
2291
|
+
return typeof e == "string" ? T(e) : JSON.stringify(e);
|
|
2292
|
+
}
|
|
2293
|
+
var gi = class {
|
|
2294
|
+
defs;
|
|
2295
|
+
names = /* @__PURE__ */ new Map();
|
|
2296
|
+
warnings = [];
|
|
2297
|
+
constructor(e) {
|
|
2298
|
+
this.defs = e;
|
|
2299
|
+
}
|
|
2300
|
+
inlined(e) {
|
|
2301
|
+
return e.includes("(");
|
|
2302
|
+
}
|
|
2303
|
+
name(e) {
|
|
2304
|
+
let t = new Set(e);
|
|
2305
|
+
for (let e = 0; t.size > 0; e++) {
|
|
2306
|
+
let n = /* @__PURE__ */ new Map();
|
|
2307
|
+
for (let r of t.keys()) {
|
|
2308
|
+
let t = r.split("."), i = t[t.length - 1].split("$"), a = b([...t.slice(Math.max(0, t.length - 1 - e), t.length - 1), ...i].map((e) => /^[a-z]/.test(e) ? x(e) : e));
|
|
2309
|
+
n.set(a, [...n.get(a) ?? [], r]);
|
|
2310
|
+
}
|
|
2311
|
+
let r = new Set(this.names.values());
|
|
2312
|
+
for (let [i, a] of n) {
|
|
2313
|
+
let n = a.filter((t) => t.split(".").length - 1 <= e), o = a.length === 1 && !r.has(i) ? a : n;
|
|
2314
|
+
for (let e of o) {
|
|
2315
|
+
let n = i;
|
|
2316
|
+
for (let e = 2; r.has(n); e++) n = `${i}${e}`;
|
|
2317
|
+
r.add(n), this.names.set(e, n), t.delete(e);
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
schemaOf(e) {
|
|
2323
|
+
let t = this.defs[e];
|
|
2324
|
+
return X(t) ? t : void 0;
|
|
2325
|
+
}
|
|
2326
|
+
resolve(e, t = /* @__PURE__ */ new Set()) {
|
|
2327
|
+
let n = e.$ref;
|
|
2328
|
+
if (typeof n != "string") return e;
|
|
2329
|
+
let r = J(n);
|
|
2330
|
+
if (r === void 0 || t.has(r)) return e;
|
|
2331
|
+
let i = this.schemaOf(r);
|
|
2332
|
+
return i ? this.resolve(i, /* @__PURE__ */ new Set([...t, r])) : e;
|
|
2333
|
+
}
|
|
2334
|
+
references(e, t = /* @__PURE__ */ new Set()) {
|
|
2335
|
+
if (Array.isArray(e)) e.forEach((e) => this.references(e, t));
|
|
2336
|
+
else if (X(e)) for (let [n, r] of Object.entries(e)) if (n === "$ref" && typeof r == "string") {
|
|
2337
|
+
let e = J(r);
|
|
2338
|
+
e !== void 0 && t.add(e);
|
|
2339
|
+
} else n !== "enum" && n !== "const" && this.references(r, t);
|
|
2340
|
+
return t;
|
|
2341
|
+
}
|
|
2342
|
+
namedReferences(e) {
|
|
2343
|
+
let t = /* @__PURE__ */ new Set();
|
|
2344
|
+
for (let n of this.references(e)) {
|
|
2345
|
+
let e = this.schemaOf(n);
|
|
2346
|
+
e !== void 0 && this.inlined(n) ? this.namedReferences(e).forEach((e) => t.add(e)) : t.add(n);
|
|
2347
|
+
}
|
|
2348
|
+
return t;
|
|
2349
|
+
}
|
|
2350
|
+
closure(e) {
|
|
2351
|
+
let t = /* @__PURE__ */ new Set(), n = [...e];
|
|
2352
|
+
for (; n.length > 0;) {
|
|
2353
|
+
let e = n.pop();
|
|
2354
|
+
if (t.has(e)) continue;
|
|
2355
|
+
t.add(e);
|
|
2356
|
+
let r = this.schemaOf(e);
|
|
2357
|
+
r && n.push(...this.references(r));
|
|
2358
|
+
}
|
|
2359
|
+
return [...t];
|
|
2360
|
+
}
|
|
2361
|
+
refType(e, t) {
|
|
2362
|
+
let n = this.schemaOf(e);
|
|
2363
|
+
if (n !== void 0 && this.inlined(e)) return this.type(n, t);
|
|
2364
|
+
let r = this.names.get(e);
|
|
2365
|
+
return r !== void 0 && this.schemaOf(e) ? r : (this.warnings.push(`${t} refers to the schema ${e}, which the Manifest's $defs does not hold; it is typed as unknown.`), "unknown");
|
|
2366
|
+
}
|
|
2367
|
+
type(e, t) {
|
|
2368
|
+
if (e === !0 || e === void 0) return "unknown";
|
|
2369
|
+
if (e === !1) return "never";
|
|
2370
|
+
if (!X(e)) return "unknown";
|
|
2371
|
+
if (typeof e.$ref == "string") {
|
|
2372
|
+
let n = J(e.$ref);
|
|
2373
|
+
return n === void 0 ? "unknown" : this.refType(n, t);
|
|
2374
|
+
}
|
|
2375
|
+
if ("const" in e) return hi(e.const);
|
|
2376
|
+
if (Array.isArray(e.enum)) return e.enum.length === 0 ? "never" : mi(e.enum.map(hi), " | ");
|
|
2377
|
+
for (let [n, r] of [
|
|
2378
|
+
["oneOf", " | "],
|
|
2379
|
+
["anyOf", " | "],
|
|
2380
|
+
["allOf", " & "]
|
|
2381
|
+
]) {
|
|
2382
|
+
let i = e[n];
|
|
2383
|
+
if (Array.isArray(i) && i.length > 0) return mi(i.map((e) => this.type(e, t)), r);
|
|
2384
|
+
}
|
|
2385
|
+
let n = pi(e);
|
|
2386
|
+
return n.length === 0 ? X(e.properties) ? this.objectType(e, t) : "unknown" : mi(n.map((n) => this.primitive(n, e, t)), " | ");
|
|
2387
|
+
}
|
|
2388
|
+
primitive(e, t, n) {
|
|
2389
|
+
switch (e) {
|
|
2390
|
+
case "string": return "string";
|
|
2391
|
+
case "integer":
|
|
2392
|
+
case "number": return "number";
|
|
2393
|
+
case "boolean": return "boolean";
|
|
2394
|
+
case "null": return "null";
|
|
2395
|
+
case "array": {
|
|
2396
|
+
let e = t.items === void 0 ? "unknown" : this.type(t.items, n);
|
|
2397
|
+
return / [|&] /.test(e) ? `(${e})[]` : `${e}[]`;
|
|
2398
|
+
}
|
|
2399
|
+
case "object": return this.objectType(t, n);
|
|
2400
|
+
default: return "unknown";
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
objectType(e, t) {
|
|
2404
|
+
let n = this.properties(e, t), r = this.additional(e, t);
|
|
2405
|
+
if (n.length === 0) return `Record<string, ${r ?? "unknown"}>`;
|
|
2406
|
+
let i = n.map((e) => `${e.name}${e.optional ? "?" : ""}: ${e.type}`);
|
|
2407
|
+
return r !== void 0 && i.push("[key: string]: unknown"), `{ ${i.join("; ")} }`;
|
|
2408
|
+
}
|
|
2409
|
+
properties(e, t) {
|
|
2410
|
+
if (!X(e.properties)) return [];
|
|
2411
|
+
let n = new Set(Array.isArray(e.required) ? e.required : []);
|
|
2412
|
+
return Object.entries(e.properties).map(([e, r]) => {
|
|
2413
|
+
let i = X(r) ? r.description : void 0;
|
|
2414
|
+
return {
|
|
2415
|
+
name: w(e),
|
|
2416
|
+
type: this.type(r, `${t}.${e}`),
|
|
2417
|
+
optional: !n.has(e),
|
|
2418
|
+
...typeof i == "string" ? { description: i } : {}
|
|
2419
|
+
};
|
|
2420
|
+
});
|
|
2421
|
+
}
|
|
2422
|
+
additional(e, t) {
|
|
2423
|
+
let n = e.additionalProperties;
|
|
2424
|
+
if (n !== void 0 && n !== !1) return this.type(n, t);
|
|
2425
|
+
}
|
|
2426
|
+
isInterface(e) {
|
|
2427
|
+
let t = pi(e);
|
|
2428
|
+
return X(e.properties) && (t.length === 0 || t.length === 1 && t[0] === "object") && e.$ref === void 0 && e.allOf === void 0 && e.oneOf === void 0 && e.anyOf === void 0;
|
|
2429
|
+
}
|
|
2430
|
+
fields(e, t, n = 1, r = /* @__PURE__ */ new Set()) {
|
|
2431
|
+
let i = this.resolve(e), a = typeof e.$ref == "string" ? J(e.$ref) : void 0;
|
|
2432
|
+
if (a !== void 0 && r.has(a)) return [];
|
|
2433
|
+
let o = a === void 0 ? r : /* @__PURE__ */ new Set([...r, a]);
|
|
2434
|
+
if (!X(i.properties)) return [];
|
|
2435
|
+
let s = [];
|
|
2436
|
+
for (let [e, r] of Object.entries(i.properties)) {
|
|
2437
|
+
let i = `${t}.${e}`;
|
|
2438
|
+
s.push(i), n < fi && X(r) && (pi(this.resolve(r)).includes("array") || s.push(...this.fields(r, i, n + 1, o)));
|
|
2439
|
+
}
|
|
2440
|
+
return s;
|
|
2441
|
+
}
|
|
2442
|
+
};
|
|
2443
|
+
function _i(e, t) {
|
|
2444
|
+
if (t === void 0) return !0;
|
|
2445
|
+
let n = e.resolve(t);
|
|
2446
|
+
return !Array.isArray(n.required) || n.required.length === 0;
|
|
2447
|
+
}
|
|
2448
|
+
function vi(e, t) {
|
|
2449
|
+
return [
|
|
2450
|
+
t.state.schema,
|
|
2451
|
+
...(t.commands ?? []).map((e) => e.schema),
|
|
2452
|
+
...(t.events ?? []).map((e) => e.schema)
|
|
2453
|
+
].map(J).filter((e) => e !== void 0).concat(yi(e, t));
|
|
2454
|
+
}
|
|
2455
|
+
function yi(e, t) {
|
|
2456
|
+
return (t.lifecycle ?? []).filter((t) => ui[t] !== void 0 && e.schemaOf(t));
|
|
2457
|
+
}
|
|
2458
|
+
function bi(e) {
|
|
2459
|
+
let t = new gi(e.$defs ?? {}), n = e.contexts, r = /* @__PURE__ */ new Map();
|
|
2460
|
+
for (let e of n) {
|
|
2461
|
+
let n = (e.aggregates ?? []).flatMap((e) => vi(t, e));
|
|
2462
|
+
for (let i of t.closure(n).sort(E)) r.has(i) || r.set(i, e.name);
|
|
2463
|
+
}
|
|
2464
|
+
let i = [...r.keys()].filter((e) => t.schemaOf(e) && !t.inlined(e));
|
|
2465
|
+
t.name([...i].sort(E));
|
|
2466
|
+
let a = i.map((e) => xi(t, e, `${r.get(e)}/types.ts`)).sort((e, t) => E(e.file, t.file) || E(e.name, t.name)), o = n.map((e) => Si(t, e));
|
|
2467
|
+
return {
|
|
2468
|
+
model: {
|
|
2469
|
+
...e.service?.name ? { service: e.service.name } : {},
|
|
2470
|
+
types: a,
|
|
2471
|
+
contexts: o
|
|
2472
|
+
},
|
|
2473
|
+
warnings: [...new Set(t.warnings)]
|
|
2474
|
+
};
|
|
2475
|
+
}
|
|
2476
|
+
function xi(e, t, n) {
|
|
2477
|
+
let r = e.schemaOf(t), i = e.names.get(t), a = typeof r.description == "string" ? r.description : void 0, o = [...e.namedReferences(r)].map((t) => e.names.get(t)).filter((e) => e !== void 0 && e !== i), s = {
|
|
2478
|
+
key: t,
|
|
2479
|
+
name: i,
|
|
2480
|
+
file: n,
|
|
2481
|
+
...a === void 0 ? {} : { description: a },
|
|
2482
|
+
references: [...new Set(o)].sort(E)
|
|
2483
|
+
};
|
|
2484
|
+
if (e.isInterface(r)) {
|
|
2485
|
+
let n = e.additional(r, t);
|
|
2486
|
+
return {
|
|
2487
|
+
...s,
|
|
2488
|
+
properties: e.properties(r, t),
|
|
2489
|
+
...n === void 0 ? {} : { type: "unknown" }
|
|
2490
|
+
};
|
|
2491
|
+
}
|
|
2492
|
+
return {
|
|
2493
|
+
...s,
|
|
2494
|
+
type: e.type(r, t)
|
|
2495
|
+
};
|
|
2496
|
+
}
|
|
2497
|
+
function Si(e, t) {
|
|
2498
|
+
let n = `${t.name}.`;
|
|
2499
|
+
return {
|
|
2500
|
+
name: t.name,
|
|
2501
|
+
...t.description ? { description: t.description } : {},
|
|
2502
|
+
typeName: b(x(t.name)),
|
|
2503
|
+
constantName: C(t.name),
|
|
2504
|
+
directory: t.name,
|
|
2505
|
+
errors: (t.errors ?? []).map((e) => ({
|
|
2506
|
+
member: C((e.code.startsWith(n) ? e.code.slice(n.length) : e.code).split(/[^A-Za-z0-9]+/)) || "ERROR",
|
|
2507
|
+
code: e.code,
|
|
2508
|
+
status: e.status,
|
|
2509
|
+
...e.description ? { description: e.description } : {}
|
|
2510
|
+
})),
|
|
2511
|
+
subscriptions: [...new Set((t.subscriptions ?? []).map((e) => e.name))].sort(E),
|
|
2512
|
+
aggregates: (t.aggregates ?? []).map((n) => wi(e, t, n))
|
|
2513
|
+
};
|
|
2514
|
+
}
|
|
2515
|
+
function Ci(e, t, n) {
|
|
2516
|
+
let r = J(t);
|
|
2517
|
+
return r === void 0 ? "unknown" : e.refType(r, n);
|
|
2518
|
+
}
|
|
2519
|
+
function wi(e, t, n) {
|
|
2520
|
+
let r = `${t.name}.${n.name}`, i = b(x(n.name)), a = new Set(yi(e, n)), o = (n.lifecycle ?? []).filter((e) => di.has(e)).map((t) => {
|
|
2521
|
+
let n = t.split(".").pop(), i = e.schemaOf(t)?.description;
|
|
2522
|
+
return {
|
|
2523
|
+
name: t,
|
|
2524
|
+
member: C(n),
|
|
2525
|
+
method: le(S(n)),
|
|
2526
|
+
...a.has(t) ? {
|
|
2527
|
+
bodyType: e.refType(t, r),
|
|
2528
|
+
bodyGenerated: !0
|
|
2529
|
+
} : ui[t] ? { bodyType: ui[t] } : {},
|
|
2530
|
+
...typeof i == "string" ? { description: i } : {}
|
|
2531
|
+
};
|
|
2532
|
+
}), s = new Set(o.map((e) => e.method)), c = (n.commands ?? []).map((t) => {
|
|
2533
|
+
let n = le(S(t.name));
|
|
2534
|
+
(s.has(n) || n === "gateway") && (n = `${n}Command`), s.add(n);
|
|
2535
|
+
let i = C(t.name), a = (t.routes ?? []).filter((e) => e.method === "POST"), o = a.find((e) => e.path.includes("{id}")), c = a.find((e) => !e.path.includes("{id}")), l = J(t.schema);
|
|
2536
|
+
return {
|
|
2537
|
+
name: t.name,
|
|
2538
|
+
method: n,
|
|
2539
|
+
...o ? { byIdPath: {
|
|
2540
|
+
member: i,
|
|
2541
|
+
path: o.path
|
|
2542
|
+
} } : {},
|
|
2543
|
+
...c ? { unaddressedPath: {
|
|
2544
|
+
member: o ? `${i}_WITHOUT_ID` : i,
|
|
2545
|
+
path: c.path
|
|
2546
|
+
} } : {},
|
|
2547
|
+
bodyType: Ci(e, t.schema, `${r}.${t.name}`),
|
|
2548
|
+
bodyOptional: _i(e, l === void 0 ? void 0 : e.schemaOf(l)),
|
|
2549
|
+
creation: t.creation ?? "NONE",
|
|
2550
|
+
mounted: t.mounted ?? !1,
|
|
2551
|
+
produces: t.produces ?? [],
|
|
2552
|
+
...t.description ? { description: t.description } : {}
|
|
2553
|
+
};
|
|
2554
|
+
}), l = J(n.state.schema), u = l === void 0 ? void 0 : e.schemaOf(l);
|
|
2555
|
+
return {
|
|
2556
|
+
context: t.name,
|
|
2557
|
+
name: n.name,
|
|
2558
|
+
...n.description ? { description: n.description } : {},
|
|
2559
|
+
typeName: i,
|
|
2560
|
+
directory: `${t.name}/${n.name}`,
|
|
2561
|
+
ownership: n.ownership ?? "OWNER",
|
|
2562
|
+
snapshot: n.snapshot?.enabled ?? !0,
|
|
2563
|
+
stateType: Ci(e, n.state.schema, `${r} state`),
|
|
2564
|
+
stateFields: u === void 0 ? [] : e.fields({ $ref: n.state.schema }, "state"),
|
|
2565
|
+
commands: c,
|
|
2566
|
+
events: (n.events ?? []).map((i) => ({
|
|
2567
|
+
name: i.name,
|
|
2568
|
+
wireName: i.name.includes(".") ? i.name : `${t.name}.${n.name}.${i.name}`,
|
|
2569
|
+
revision: i.revision ?? 1,
|
|
2570
|
+
type: Ci(e, i.schema, `${r}.${i.name}`)
|
|
2571
|
+
})),
|
|
2572
|
+
lifecycle: o,
|
|
2573
|
+
queryModels: (n.queries ?? []).map((e) => e.model)
|
|
2574
|
+
};
|
|
2575
|
+
}
|
|
2576
|
+
//#endregion
|
|
2577
|
+
//#region src/emitters/manifestClients.ts
|
|
2578
|
+
var Ti = "@ahoo-wang/wow-client/v10";
|
|
2579
|
+
function Z(e, t = "") {
|
|
2580
|
+
let n = e.filter((e) => typeof e == "string" && e !== "").flatMap((e) => wn(e).split("\n"));
|
|
2581
|
+
return n.length === 0 ? "" : n.length === 1 ? `${t}/** ${n[0]} */\n` : `${t}/**\n${n.map((e) => `${t} * ${e}`.trimEnd()).join("\n")}\n${t} */\n`;
|
|
2582
|
+
}
|
|
2583
|
+
function Q(e, t) {
|
|
2584
|
+
e.add(`\n${t}`);
|
|
2585
|
+
}
|
|
2586
|
+
function Ei(e) {
|
|
2587
|
+
return e.length === 0 ? "never" : e.join(" | ");
|
|
2588
|
+
}
|
|
2589
|
+
function Di(e, t, n, r, i) {
|
|
2590
|
+
let a = /* @__PURE__ */ new Map();
|
|
2591
|
+
for (let e of new Set(r)) {
|
|
2592
|
+
let t = n.get(e);
|
|
2593
|
+
t !== void 0 && t !== i && a.set(t, [...a.get(t) ?? [], e]);
|
|
2594
|
+
}
|
|
2595
|
+
for (let [n, r] of a) e.imports.add(xn(e.directoryPath, te(t, n)), r);
|
|
2596
|
+
}
|
|
2597
|
+
function Oi(e, t, n) {
|
|
2598
|
+
let r = new Map(e.types.map((e) => [e.name, e.file]));
|
|
2599
|
+
for (let i of e.types) ki(t.module(i.file), i, r, n);
|
|
2600
|
+
for (let i of e.contexts) {
|
|
2601
|
+
Ai(i, t);
|
|
2602
|
+
for (let e of i.aggregates) ji(e, i, t, r, n), Pi(e, t, r, n), Fi(e, t, r, n);
|
|
2603
|
+
}
|
|
2604
|
+
}
|
|
2605
|
+
function ki(e, t, n, r) {
|
|
2606
|
+
Di(e, r, n, t.references, t.file);
|
|
2607
|
+
let i = Z([t.description, `- key: \`${t.key}\``]);
|
|
2608
|
+
if (t.properties === void 0) {
|
|
2609
|
+
Q(e, `${i}export type ${t.name} = ${t.type};`);
|
|
2610
|
+
return;
|
|
2611
|
+
}
|
|
2612
|
+
let a = t.properties.map((e) => `${Z([e.description], " ")} ${e.name}${e.optional ? "?" : ""}: ${e.type};`);
|
|
2613
|
+
t.type !== void 0 && a.push(` [key: string]: ${t.type};`), Q(e, `${i}export interface ${t.name} {\n${a.join("\n")}\n}`);
|
|
2614
|
+
}
|
|
2615
|
+
function Ai(e, t) {
|
|
2616
|
+
let n = t.module(`${e.directory}/boundedContext.ts`), r = `${e.constantName}_BOUNDED_CONTEXT`;
|
|
2617
|
+
n.imports.add(Ti, ["Hop", "wait"]), Q(n, `${Z([`The bounded context \`${e.name}\`.`, e.description])}export const ${r} = ${T(e.name)};`);
|
|
2618
|
+
let i = e.errors.map((e) => `${Z([`${e.status}: ${e.description ?? e.code}`], " ")} ${e.member}: ${T(e.code)},`);
|
|
2619
|
+
Q(n, `${Z([`The domain error codes of \`${e.name}\`, each a problem's \`code\` with the status the Manifest gives it.`])}export const ${e.typeName}ErrorCodes = {\n${i.join("\n")}\n} as const;`), Q(n, `${Z([`A {@link ${e.typeName}ErrorCodes} value.`])}export type ${e.typeName}ErrorCode = (typeof ${e.typeName}ErrorCodes)[keyof typeof ${e.typeName}ErrorCodes];`);
|
|
2620
|
+
let a = e.subscriptions.length > 0;
|
|
2621
|
+
a && Q(n, `${Z([`The subscriptions of \`${e.name}\` a \`handled\` hop names.`])}export type ${e.typeName}Subscription = ${Ei(e.subscriptions.map(T))};`);
|
|
2622
|
+
let o = [
|
|
2623
|
+
` /** Until a command of \`${e.name}\` passed admission. */\n accepted: (): Hop => wait.accepted(${r}),`,
|
|
2624
|
+
` /** Until a command's events are appended to the log of \`${e.name}\`. */\n committed: (): Hop => wait.committed(${r}),`,
|
|
2625
|
+
` /** Until the snapshot of \`${e.name}\` holds the commit. */\n snapshot: (): Hop => wait.snapshot(${r}),`
|
|
2626
|
+
];
|
|
2627
|
+
a && o.push(` /** Until a subscription of \`${e.name}\` handled the commit. */\n handled: (subscription: ${e.typeName}Subscription): Hop => wait.handled(subscription, ${r}),`), Q(n, `${Z([`The hops of a wait chain (\`Wow-Wait\`) in \`${e.name}\`.`])}export const ${S(e.name)}Wait = {\n${o.join("\n")}\n} as const;`);
|
|
2628
|
+
}
|
|
2629
|
+
function ji(e, t, n, r, i) {
|
|
2630
|
+
let a = n.module(`${e.directory}/aggregate.ts`), o = e.typeName;
|
|
2631
|
+
Q(a, `${Z([`The aggregate \`${e.context}.${e.name}\`.`, e.description])}export const ${o}Aggregate = {\n context: ${T(t.name)},\n name: ${T(e.name)},\n path: ${T(`/${t.name}/${e.name}`)},\n ownership: ${T(e.ownership)},\n snapshot: ${e.snapshot},\n} as const;`), Q(a, `${Z([`The \`state.*\` paths of \`${e.name}\`'s snapshots a query filters, sorts and projects on.`])}export type ${o}StateField = ${Ei(e.stateFields.map(T))};`);
|
|
2632
|
+
let s = e.events.map((e) => `EventView<${T(e.wireName)}, ${e.type}>`);
|
|
2633
|
+
a.imports.add(Ti, s.length > 0 ? ["EventView", "SystemEvent"] : ["SystemEvent"]), Q(a, `${Z([`The events of \`${e.name}\`, named as the server sends them: \`${e.context}.${e.name}.<Event>\`, and the system events every aggregate has.`])}export type ${o}Event = ${Ei([...s, "SystemEvent"])};`), Di(a, i, r, e.events.map((e) => e.type));
|
|
2634
|
+
}
|
|
2635
|
+
function Mi(e) {
|
|
2636
|
+
let t = [e.byIdPath, e.unaddressedPath].filter((e) => e !== void 0).map((e) => `\`POST ${e.path}\``).join(", "), n = e.creation === "REQUIRED" ? "Creates the aggregate." : e.creation === "ALLOWED" ? "Creates the aggregate, or acts on the one that exists." : void 0;
|
|
2637
|
+
return Z([
|
|
2638
|
+
e.description,
|
|
2639
|
+
`\`${e.name}\`${e.mounted ? ", mounted (a transformer finds its aggregate)" : ""}: ${t}.`,
|
|
2640
|
+
n,
|
|
2641
|
+
e.produces.length > 0 ? `Produces ${e.produces.map((e) => `\`${e}\``).join(", ")}.` : void 0
|
|
2642
|
+
], " ");
|
|
2643
|
+
}
|
|
2644
|
+
function Ni(e, t, n) {
|
|
2645
|
+
let r = e.bodyType === "unknown" ? "object" : e.bodyType, i = e.bodyOptional ? `body: ${r} = {}` : `body: ${r}`, a = n ? "stream" : "send", o = n ? "Promise<CommandResultStream>" : "Promise<CommandResult>", s = n ? `${e.method}Stream` : e.method, c = n ? Z([`\`${e.name}\`, answered as one result per hop of its wait (\`text/event-stream\`).`], " ") : Mi(e), l = e.byIdPath, u = e.unaddressedPath;
|
|
2646
|
+
return l && u ? `${c} ${s}(${i}, options?: CreateCommandOptions): ${o} {\n return this.gateway.${a}(options?.id === undefined ? ${t}.${u.member} : ${t}.${l.member}, body, options);\n }` : l ? `${c} ${s}(id: string, ${i}, options?: CommandOptions): ${o} {\n return this.gateway.${a}(${t}.${l.member}, body, { ...options, id });\n }` : `${c} ${s}(${i}, options?: CommandOptions): ${o} {\n return this.gateway.${a}(${t}.${u.member}, body, options);\n }`;
|
|
2647
|
+
}
|
|
2648
|
+
function Pi(e, t, n, r) {
|
|
2649
|
+
let i = t.module(`${e.directory}/commandClient.ts`), a = e.typeName, o = `${a}CommandPaths`, s = e.commands.filter((e) => e.byIdPath || e.unaddressedPath), c = s.flatMap((e) => [e.byIdPath, e.unaddressedPath].filter((e) => e !== void 0).map((e) => ` ${e.member}: ${T(e.path)},`));
|
|
2650
|
+
Q(i, `${Z([`The command routes of \`${e.context}.${e.name}\`.`])}export const ${o} = {\n${c.join("\n")}\n} as const;`);
|
|
2651
|
+
let l = s.flatMap((e) => [Ni(e, o, !1), Ni(e, o, !0)]), u = [
|
|
2652
|
+
"CommandGateway",
|
|
2653
|
+
"CommandResult",
|
|
2654
|
+
"WowClientOptions"
|
|
2655
|
+
];
|
|
2656
|
+
s.length > 0 && u.push("CommandResultStream"), s.some((e) => e.byIdPath && e.unaddressedPath) && u.push("CreateCommandOptions"), (s.some((e) => !(e.byIdPath && e.unaddressedPath)) || e.lifecycle.length > 0) && u.push("CommandOptions");
|
|
2657
|
+
let d = [];
|
|
2658
|
+
for (let t of e.lifecycle) {
|
|
2659
|
+
u.push("LifecycleCommands"), t.bodyType && (t.bodyGenerated ? d : u).push(t.bodyType);
|
|
2660
|
+
let e = t.bodyType ? `id: string, body: ${t.bodyType}, options?: CommandOptions` : "id: string, options?: CommandOptions";
|
|
2661
|
+
l.push(`${Z([t.description, `The lifecycle command \`${t.name}\`.`], " ")} ${t.method}(${e}): Promise<CommandResult> {\n return this.gateway.lifecycle(${a}Aggregate.path, id, LifecycleCommands.${t.member}, ${t.bodyType ? "body" : "undefined"}, options);\n }`);
|
|
2662
|
+
}
|
|
2663
|
+
e.lifecycle.length > 0 && i.imports.add("./aggregate.js", [`${a}Aggregate`]), i.imports.add(Ti, [...new Set(u)].sort()), Di(i, r, n, [...s.map((e) => e.bodyType), ...d]), Q(i, `${Z([`Sends the commands of \`${e.context}.${e.name}\`; a command that did not succeed rejects with a \`WowProblemError\` holding its result.`])}export class ${a}CommandClient {\n readonly gateway: CommandGateway;\n\n /** @param options - How the service is reached */\n constructor(options?: WowClientOptions) {\n this.gateway = new CommandGateway(options);\n }\n\n${l.join("\n\n")}\n}`);
|
|
2664
|
+
}
|
|
2665
|
+
function Fi(e, t, n, r) {
|
|
2666
|
+
let i = t.module(`${e.directory}/queryClient.ts`), a = e.typeName, o = e.stateType, s = ["StateClient", "WowClientOptions"], c = [`${a}Aggregate`, `${a}Event`], l = ` /** @param options - How the service is reached */\n constructor(options?: WowClientOptions) {\n super(${a}Aggregate, options);\n }`;
|
|
2667
|
+
e.queryModels.includes("snapshot") && (s.push("SnapshotQueryClient"), c.push(`${a}StateField`), Q(i, `${Z([`Queries the snapshots of \`${e.context}.${e.name}\`: \`POST /${e.context}/${e.name}/snapshot/query\`.`])}export class ${a}SnapshotQueryClient extends SnapshotQueryClient<${o}, ${a}StateField> {\n${l}\n}`)), e.queryModels.includes("events") && (s.push("EventQueryClient"), Q(i, `${Z([`Queries the event streams of \`${e.context}.${e.name}\`, one aggregate at a time: \`POST /${e.context}/${e.name}/events/query\`.`])}export class ${a}EventQueryClient extends EventQueryClient<${a}Event> {\n${l}\n}`)), Q(i, `${Z([`Reads the states of \`${e.context}.${e.name}\`, at a version or a time, and their traces: \`GET /${e.context}/${e.name}/{id}/state\`.`])}export class ${a}StateClient extends StateClient<${o}, ${a}Event> {\n${l}\n}`), i.imports.add(Ti, s.sort()), i.imports.add("./aggregate.js", c), Di(i, r, n, [o]);
|
|
2668
|
+
}
|
|
2239
2669
|
//#endregion
|
|
2240
2670
|
//#region src/openapi/document.ts
|
|
2241
|
-
function
|
|
2671
|
+
function Ii(e) {
|
|
2242
2672
|
return {
|
|
2243
2673
|
openAPI: e,
|
|
2244
2674
|
components: e.components,
|
|
2245
|
-
endpoints:
|
|
2675
|
+
endpoints: tt(e.paths, e.components)
|
|
2246
2676
|
};
|
|
2247
2677
|
}
|
|
2248
2678
|
//#endregion
|
|
2249
2679
|
//#region src/output/outputStore.ts
|
|
2250
|
-
var
|
|
2680
|
+
var Li = ".wow-generator.json", Ri = ".fetcher-generator.json", zi = class e {
|
|
2251
2681
|
project;
|
|
2252
2682
|
outputPath;
|
|
2253
2683
|
outputDir;
|
|
@@ -2261,14 +2691,14 @@ var ni = ".wow-generator.json", ri = ".fetcher-generator.json", ii = class e {
|
|
|
2261
2691
|
static open(t, n, r) {
|
|
2262
2692
|
let i = t.getFileSystem(), a = n;
|
|
2263
2693
|
n = p(i.getCurrentDirectory(), n);
|
|
2264
|
-
let o = d(n,
|
|
2694
|
+
let o = d(n, Ri), s = i.fileExistsSync(o) ? o : void 0, c = d(n, Li);
|
|
2265
2695
|
!i.fileExistsSync(c) && s && (c = s);
|
|
2266
2696
|
let l = /* @__PURE__ */ new Map();
|
|
2267
2697
|
if (i.fileExistsSync(c)) {
|
|
2268
|
-
let e =
|
|
2698
|
+
let e = Bi(c, i.readFileSync(c));
|
|
2269
2699
|
for (let [t, r] of Object.entries(e.files)) {
|
|
2270
2700
|
let e = p(n, t);
|
|
2271
|
-
if (
|
|
2701
|
+
if (Ui(n, e), u(t) || !t.endsWith(".ts") || typeof r != "string" || !/^[a-f0-9]{64}$/.test(r)) throw new _("output", `Invalid generated file entry in ${c}: ${t}`);
|
|
2272
2702
|
l.set(e, r);
|
|
2273
2703
|
}
|
|
2274
2704
|
}
|
|
@@ -2280,8 +2710,8 @@ var ni = ".wow-generator.json", ri = ".fetcher-generator.json", ii = class e {
|
|
|
2280
2710
|
return this.written;
|
|
2281
2711
|
}
|
|
2282
2712
|
claim(e, t = this.outputPath) {
|
|
2283
|
-
let n =
|
|
2284
|
-
|
|
2713
|
+
let n = R(t, e);
|
|
2714
|
+
Ui(t, n);
|
|
2285
2715
|
let r = this.project.getSourceFile(n) ?? this.project.createSourceFile(n, "", { overwrite: !0 }), i = r.getFilePath();
|
|
2286
2716
|
return this.written.has(i) || (r.removeText(), this.written.add(i)), r;
|
|
2287
2717
|
}
|
|
@@ -2295,12 +2725,12 @@ var ni = ".wow-generator.json", ri = ".fetcher-generator.json", ii = class e {
|
|
|
2295
2725
|
for (let e of this.stale) !this.written.has(e) && n.has(e.toLowerCase()) && this.isUnchanged(e, this.previous.get(e)) && (await $("delete", e, () => t.delete(e)), this.stale.delete(e));
|
|
2296
2726
|
let r = [...this.written].sort().map((e) => this.project.getSourceFileOrThrow(e));
|
|
2297
2727
|
(await Promise.allSettled(r.map((e) => e.save()))).forEach((e, t) => {
|
|
2298
|
-
if (e.status === "rejected") throw
|
|
2728
|
+
if (e.status === "rejected") throw Hi("write", r[t].getFilePath(), e.reason);
|
|
2299
2729
|
}), e?.throwIfAborted();
|
|
2300
2730
|
for (let e of this.stale) !this.written.has(e) && this.isUnchanged(e, this.previous.get(e)) && await $("delete", e, () => t.delete(e));
|
|
2301
|
-
let i = d(this.outputDir,
|
|
2731
|
+
let i = d(this.outputDir, Li), a = JSON.stringify({
|
|
2302
2732
|
version: 1,
|
|
2303
|
-
files: Object.fromEntries(r.map((e) => [f(this.outputDir, e.getFilePath()).split(m).join("/"),
|
|
2733
|
+
files: Object.fromEntries(r.map((e) => [f(this.outputDir, e.getFilePath()).split(m).join("/"), Vi(t.readFileSync(e.getFilePath()))]))
|
|
2304
2734
|
}, null, 2) + "\n";
|
|
2305
2735
|
await $("write", i, async () => {
|
|
2306
2736
|
t.mkdirSync(this.outputDir), await t.writeFile(i, a);
|
|
@@ -2310,10 +2740,10 @@ var ni = ".wow-generator.json", ri = ".fetcher-generator.json", ii = class e {
|
|
|
2310
2740
|
}
|
|
2311
2741
|
isUnchanged(e, t) {
|
|
2312
2742
|
let n = this.project.getFileSystem();
|
|
2313
|
-
return n.fileExistsSync(e) ? (
|
|
2743
|
+
return n.fileExistsSync(e) ? (Ui(n.realpathSync(this.outputDir), n.realpathSync(e)), Vi(n.readFileSync(e)) === t) : !1;
|
|
2314
2744
|
}
|
|
2315
2745
|
};
|
|
2316
|
-
function
|
|
2746
|
+
function Bi(e, t) {
|
|
2317
2747
|
let n = "delete it; without it this run cannot remove the stale files of the last run", r;
|
|
2318
2748
|
try {
|
|
2319
2749
|
r = JSON.parse(t);
|
|
@@ -2325,30 +2755,30 @@ function ai(e, t) {
|
|
|
2325
2755
|
if (i !== 1 || !r.files || typeof r.files != "object" || Array.isArray(r.files)) throw new _("output", `Invalid generation manifest ${e}: expected "version": 1 and a "files" object. Restore it from version control, or ${n}.`);
|
|
2326
2756
|
return r;
|
|
2327
2757
|
}
|
|
2328
|
-
function
|
|
2758
|
+
function Vi(e) {
|
|
2329
2759
|
if (!l.sys.createSHA256Hash) throw Error("SHA-256 hashing is unavailable in this environment.");
|
|
2330
2760
|
return l.sys.createSHA256Hash(e);
|
|
2331
2761
|
}
|
|
2332
|
-
function
|
|
2762
|
+
function Hi(e, t, n) {
|
|
2333
2763
|
return n instanceof _ ? n : new _("output", `Cannot ${e} ${t}: ${v(n)}`, { cause: n });
|
|
2334
2764
|
}
|
|
2335
2765
|
async function $(e, t, n) {
|
|
2336
2766
|
try {
|
|
2337
2767
|
await n();
|
|
2338
2768
|
} catch (n) {
|
|
2339
|
-
throw
|
|
2769
|
+
throw Hi(e, t, n);
|
|
2340
2770
|
}
|
|
2341
2771
|
}
|
|
2342
|
-
function
|
|
2772
|
+
function Ui(e, t) {
|
|
2343
2773
|
let n = t.split("/").join(m), r = p(e), i = p(n), a = f(r, i);
|
|
2344
2774
|
if (a === "" || a.startsWith("..") || u(a)) throw new _("output", `Path traversal detected: "${t}" resolves outside the output directory "${e}".`);
|
|
2345
2775
|
}
|
|
2346
2776
|
//#endregion
|
|
2347
2777
|
//#region src/wow/resolveWowModel.ts
|
|
2348
|
-
function
|
|
2778
|
+
function Wi(e) {
|
|
2349
2779
|
let { openAPI: t, components: n, endpoints: r } = e, i = [], a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), s = t.tags ?? [], c = new Set(s.map((e) => e.name)), l = new Set(r.flatMap((e) => e.operation.tags ?? []).filter((e) => !c.has(e))), u = /* @__PURE__ */ new Map();
|
|
2350
2780
|
for (let e of [...s, ...[...l].map((e) => ({ name: e }))]) {
|
|
2351
|
-
let t =
|
|
2781
|
+
let t = ht(e);
|
|
2352
2782
|
t && u.set(e.name, {
|
|
2353
2783
|
aggregate: t,
|
|
2354
2784
|
commands: /* @__PURE__ */ new Map(),
|
|
@@ -2363,31 +2793,31 @@ function li(e) {
|
|
|
2363
2793
|
r || (r = {}, a.set(e.key, r));
|
|
2364
2794
|
let i = t in r ? r[t] : e.schema[t];
|
|
2365
2795
|
r[t] = i || n;
|
|
2366
|
-
}, p = (e, t) => new _("specification", `Cannot read the Wow metadata of ${e.operationId}: ${t}. wow-generator reads documents from Wow ${
|
|
2367
|
-
let n =
|
|
2796
|
+
}, p = (e, t) => new _("specification", `Cannot read the Wow metadata of ${e.operationId}: ${t}. wow-generator reads documents from Wow ${dt} or later.`), m = (e, t) => {
|
|
2797
|
+
let n = bt.exec(t)?.[1];
|
|
2368
2798
|
n && e.forEach((e) => {
|
|
2369
2799
|
e.resourceName ??= n;
|
|
2370
2800
|
});
|
|
2371
|
-
},
|
|
2801
|
+
}, h = (e) => {
|
|
2372
2802
|
let { operation: t, path: r } = e;
|
|
2373
2803
|
if (t.operationId === "wow.command.send") return;
|
|
2374
|
-
let a =
|
|
2804
|
+
let a = gt(t.operationId);
|
|
2375
2805
|
if (!a) return;
|
|
2376
|
-
let o =
|
|
2377
|
-
for (; o &&
|
|
2378
|
-
if (!o.$ref.startsWith(
|
|
2806
|
+
let o = it(t), s = /* @__PURE__ */ new Set();
|
|
2807
|
+
for (; o && D(o) && o.$ref !== "#/components/responses/wow.CommandOk";) {
|
|
2808
|
+
if (!o.$ref.startsWith(be)) return;
|
|
2379
2809
|
if (s.has(o.$ref)) throw new _("specification", `Cyclic component reference: ${o.$ref}`);
|
|
2380
|
-
s.add(o.$ref), o = n?.responses?.[o.$ref.slice(
|
|
2810
|
+
s.add(o.$ref), o = n?.responses?.[o.$ref.slice(be.length)];
|
|
2381
2811
|
}
|
|
2382
|
-
if (!o || !
|
|
2812
|
+
if (!o || !D(o) || o.$ref !== "#/components/responses/wow.CommandOk") return;
|
|
2383
2813
|
let c = d(t);
|
|
2384
2814
|
if (!t.requestBody) return;
|
|
2385
|
-
let l =
|
|
2386
|
-
if (!
|
|
2815
|
+
let l = st(t, n ?? {}), u = (D(t.requestBody) ? we(t.requestBody, n ?? {}) : t.requestBody)?.content?.[Ee]?.schema;
|
|
2816
|
+
if (!D(u)) {
|
|
2387
2817
|
c.length > 0 && i.push(`Skipping command ${t.operationId} (${e.method.toUpperCase()} ${r}): its application/json request body is not a $ref to a component schema.`);
|
|
2388
2818
|
return;
|
|
2389
2819
|
}
|
|
2390
|
-
let p =
|
|
2820
|
+
let p = j(u, n ?? {});
|
|
2391
2821
|
if (!p.schema) return;
|
|
2392
2822
|
f(p, "title", t.summary), f(p, "description", t.description);
|
|
2393
2823
|
let m = {
|
|
@@ -2403,28 +2833,28 @@ function li(e) {
|
|
|
2403
2833
|
c.forEach((e) => {
|
|
2404
2834
|
e.commands.set(a, m);
|
|
2405
2835
|
});
|
|
2406
|
-
},
|
|
2836
|
+
}, ee = ({ operation: e, path: t }) => {
|
|
2407
2837
|
if (!e.operationId?.endsWith(".snapshot_state.single")) return;
|
|
2408
2838
|
let r = d(e);
|
|
2409
2839
|
m(r, t);
|
|
2410
|
-
let i =
|
|
2411
|
-
if (!
|
|
2840
|
+
let i = at(e, n);
|
|
2841
|
+
if (!D(i)) {
|
|
2412
2842
|
if (r.length > 0) throw p(e, "its 200 application/json response is not a $ref to the state schema");
|
|
2413
2843
|
return;
|
|
2414
2844
|
}
|
|
2415
|
-
let a =
|
|
2845
|
+
let a = j(i, n);
|
|
2416
2846
|
r.forEach((e) => {
|
|
2417
2847
|
e.state = a;
|
|
2418
2848
|
});
|
|
2419
|
-
},
|
|
2849
|
+
}, te = ({ operation: e }) => {
|
|
2420
2850
|
if (!n || !e.operationId?.endsWith(".event.list_query")) return;
|
|
2421
2851
|
let t = d(e);
|
|
2422
2852
|
if (t.length === 0) return;
|
|
2423
|
-
let r =
|
|
2424
|
-
if (
|
|
2853
|
+
let r = at(e, n);
|
|
2854
|
+
if (D(r)) return;
|
|
2425
2855
|
let i = r?.items;
|
|
2426
|
-
if (!
|
|
2427
|
-
let a =
|
|
2856
|
+
if (!D(i)) throw p(e, "its 200 application/json response is not an array of a $ref to the event stream schema");
|
|
2857
|
+
let a = Gi(A(i, n), [
|
|
2428
2858
|
"properties",
|
|
2429
2859
|
"body",
|
|
2430
2860
|
"items",
|
|
@@ -2432,13 +2862,13 @@ function li(e) {
|
|
|
2432
2862
|
]);
|
|
2433
2863
|
if (!Array.isArray(a)) throw p(e, `the event stream schema ${i.$ref} has no properties.body.items.anyOf listing the domain events`);
|
|
2434
2864
|
let o = a.map((t, r) => {
|
|
2435
|
-
let a =
|
|
2865
|
+
let a = Gi(t, [
|
|
2436
2866
|
"properties",
|
|
2437
2867
|
"name",
|
|
2438
2868
|
"const"
|
|
2439
|
-
]), o =
|
|
2440
|
-
if (typeof a != "string" || !
|
|
2441
|
-
let s =
|
|
2869
|
+
]), o = Gi(t, ["properties", "body"]);
|
|
2870
|
+
if (typeof a != "string" || !D(o)) throw p(e, `domain event ${r} of ${i.$ref} needs a properties.name.const and a properties.body that is a $ref to the event schema`);
|
|
2871
|
+
let s = j(o, n);
|
|
2442
2872
|
return f(s, "title", t.title), {
|
|
2443
2873
|
title: t.title ?? a,
|
|
2444
2874
|
name: a,
|
|
@@ -2450,52 +2880,52 @@ function li(e) {
|
|
|
2450
2880
|
e.events.set(t.name, t);
|
|
2451
2881
|
});
|
|
2452
2882
|
});
|
|
2453
|
-
},
|
|
2883
|
+
}, ne = ({ operation: e, path: t }) => {
|
|
2454
2884
|
if (!n || !e.operationId?.endsWith(".snapshot.count")) return;
|
|
2455
2885
|
let r = d(e);
|
|
2456
2886
|
if (r.length === 0) return;
|
|
2457
2887
|
m(r, t);
|
|
2458
|
-
let i = e.requestBody ?
|
|
2888
|
+
let i = e.requestBody ? D(e.requestBody) ? we(e.requestBody, n) : e.requestBody : void 0;
|
|
2459
2889
|
if (!i) throw p(e, "it has no request body");
|
|
2460
|
-
let a = i[
|
|
2890
|
+
let a = i[yt], o;
|
|
2461
2891
|
if (a !== void 0) {
|
|
2462
|
-
if (!
|
|
2892
|
+
if (!D(a)) throw p(e, `${yt} must be a schema reference`);
|
|
2463
2893
|
o = a;
|
|
2464
2894
|
} else {
|
|
2465
|
-
let t = i.content?.[
|
|
2466
|
-
if (!
|
|
2895
|
+
let t = i.content?.[Ee]?.schema, r = (D(t) ? A(t, n) : void 0)?.properties?.field;
|
|
2896
|
+
if (!D(r)) throw p(e, `its request body has no ${yt}, and its condition schema has no field $ref to read the query fields from`);
|
|
2467
2897
|
o = r;
|
|
2468
2898
|
}
|
|
2469
|
-
let s =
|
|
2899
|
+
let s = j(o, n);
|
|
2470
2900
|
r.forEach((e) => {
|
|
2471
2901
|
e.fields = s;
|
|
2472
2902
|
});
|
|
2473
2903
|
};
|
|
2474
|
-
for (let e of r)
|
|
2475
|
-
let
|
|
2904
|
+
for (let e of r) h(e), ee(e), te(e), ne(e);
|
|
2905
|
+
let g = /* @__PURE__ */ new Map();
|
|
2476
2906
|
for (let [e, t] of u) {
|
|
2477
2907
|
if (!t.state || !t.fields) {
|
|
2478
2908
|
if (o.has(e)) {
|
|
2479
|
-
let n = [t.state ? void 0 : `${e}${
|
|
2909
|
+
let n = [t.state ? void 0 : `${e}${_t}`, t.fields ? void 0 : `${e}${vt}`].filter(Boolean);
|
|
2480
2910
|
i.push(`Skipping aggregate ${e}: the document has no ${n.join(" or ")} operation, so it generates neither command nor query clients for it.`);
|
|
2481
2911
|
}
|
|
2482
2912
|
continue;
|
|
2483
2913
|
}
|
|
2484
|
-
let n = t.aggregate.contextAlias, r =
|
|
2485
|
-
r || (r = /* @__PURE__ */ new Set(),
|
|
2914
|
+
let n = t.aggregate.contextAlias, r = g.get(n);
|
|
2915
|
+
r || (r = /* @__PURE__ */ new Set(), g.set(n, r)), r.add({
|
|
2486
2916
|
...t,
|
|
2487
2917
|
resourceName: t.resourceName ?? t.aggregate.aggregateName
|
|
2488
2918
|
});
|
|
2489
2919
|
}
|
|
2490
2920
|
return {
|
|
2491
|
-
contextAlias:
|
|
2492
|
-
contexts:
|
|
2921
|
+
contextAlias: pt(t),
|
|
2922
|
+
contexts: g,
|
|
2493
2923
|
aggregateTags: o,
|
|
2494
2924
|
schemaDocOverrides: a,
|
|
2495
2925
|
warnings: i
|
|
2496
2926
|
};
|
|
2497
2927
|
}
|
|
2498
|
-
function
|
|
2928
|
+
function Gi(e, t) {
|
|
2499
2929
|
let n = e;
|
|
2500
2930
|
for (let e of t) {
|
|
2501
2931
|
if (typeof n != "object" || !n) return;
|
|
@@ -2505,14 +2935,14 @@ function ui(e, t) {
|
|
|
2505
2935
|
}
|
|
2506
2936
|
//#endregion
|
|
2507
2937
|
//#region src/pipeline/seams.ts
|
|
2508
|
-
var
|
|
2938
|
+
var Ki = Symbol("project"), qi = Symbol("signal"), Ji = class {
|
|
2509
2939
|
options;
|
|
2510
2940
|
project;
|
|
2511
2941
|
logger;
|
|
2512
2942
|
signal;
|
|
2513
2943
|
output;
|
|
2514
2944
|
constructor(e) {
|
|
2515
|
-
this.options = e, this.logger = e.logger ?? new
|
|
2945
|
+
this.options = e, this.logger = e.logger ?? new ie(), this.signal = e[qi], this.project = e[Ki] ?? Yi(e.tsConfigFilePath), this.project.manipulationSettings.set({
|
|
2516
2946
|
indentationText: t.TwoSpaces,
|
|
2517
2947
|
quoteKind: i.Single,
|
|
2518
2948
|
useTrailingCommas: !0
|
|
@@ -2527,36 +2957,52 @@ var di = Symbol("project"), fi = Symbol("signal"), pi = class {
|
|
|
2527
2957
|
headers: n.headers,
|
|
2528
2958
|
timeoutMs: n.timeoutMs,
|
|
2529
2959
|
signal: t
|
|
2530
|
-
}, o = await
|
|
2531
|
-
i(o.warnings), t?.throwIfAborted(), e.debug("Parsing
|
|
2532
|
-
let s = await
|
|
2533
|
-
t?.throwIfAborted(),
|
|
2534
|
-
let c =
|
|
2535
|
-
|
|
2536
|
-
let l =
|
|
2960
|
+
}, o = await Qr(n.configPath, e, a);
|
|
2961
|
+
i(o.warnings), t?.throwIfAborted(), e.debug("Parsing the input document");
|
|
2962
|
+
let s = await qr(n.inputPath, a);
|
|
2963
|
+
if (t?.throwIfAborted(), ci(s)) return this.generateFromManifest(li(s, n.inputPath), o.origin, i, () => r);
|
|
2964
|
+
let c = Jr(s, n.inputPath);
|
|
2965
|
+
e.debug("OpenAPI specification parsed successfully");
|
|
2966
|
+
let l = _e(c);
|
|
2967
|
+
if (l.length > 0) throw new _("specification", `${n.inputPath} has ${l.length} $ref(s) that point at nothing: ${l.slice(0, 10).map(({ ref: e, location: t }) => `${e} (at ${t})`).join(", ")}${l.length > 10 ? ", …" : ""}`);
|
|
2968
|
+
let u = Ii(c);
|
|
2537
2969
|
e.debug("Resolving bounded context aggregates");
|
|
2538
|
-
let
|
|
2539
|
-
i(
|
|
2540
|
-
let
|
|
2541
|
-
this.output =
|
|
2542
|
-
let
|
|
2543
|
-
i(
|
|
2544
|
-
let
|
|
2545
|
-
|
|
2546
|
-
modules:
|
|
2970
|
+
let d = Wi(u);
|
|
2971
|
+
i(d.warnings), e.debug(`Resolved ${d.contexts.size} bounded context aggregates`);
|
|
2972
|
+
let f = zi.open(this.project, n.outputDir, this.output);
|
|
2973
|
+
this.output = f, e.debug("Analysing the document");
|
|
2974
|
+
let p = dn(u, d, o.config);
|
|
2975
|
+
i(p.warnings), e.debug("Writing generated modules");
|
|
2976
|
+
let m = new mn((e) => f.claim(e));
|
|
2977
|
+
Er(p.model, {
|
|
2978
|
+
modules: m,
|
|
2547
2979
|
outputDir: n.outputDir,
|
|
2548
|
-
types:
|
|
2980
|
+
types: br(u.components),
|
|
2549
2981
|
schemaDocs: n.schemaDocs ?? "summary"
|
|
2550
|
-
}),
|
|
2551
|
-
let
|
|
2552
|
-
return
|
|
2553
|
-
files: [...
|
|
2982
|
+
}), m.build(), e.debug("Generated modules written"), f.forgetStale();
|
|
2983
|
+
let h = this.project.getDirectory(n.outputDir);
|
|
2984
|
+
return h ? (e.debug("Generating index files"), i(Or(h, (e) => f.claim("index.ts", e))), e.debug("Optimizing source files"), Br(h.getDescendantSourceFiles().filter((e) => f.files.has(e.getFilePath())), e), e.debug("Source files optimized successfully")) : e.debug("Output directory not found."), e.debug("Saving project to disk"), await f.commit(t), e.debug("Code generation completed successfully"), {
|
|
2985
|
+
files: [...f.files].sort(),
|
|
2554
2986
|
configPath: o.origin,
|
|
2555
2987
|
warnings: r
|
|
2556
2988
|
};
|
|
2557
2989
|
}
|
|
2990
|
+
async generateFromManifest(e, t, n, r) {
|
|
2991
|
+
let { logger: i, signal: a, options: o } = this, s = zi.open(this.project, o.outputDir, this.output);
|
|
2992
|
+
this.output = s, i.debug("Analysing the Manifest");
|
|
2993
|
+
let c = bi(e);
|
|
2994
|
+
n(c.warnings);
|
|
2995
|
+
let l = new mn((e) => s.claim(e));
|
|
2996
|
+
Oi(c.model, l, o.outputDir), l.build(), s.forgetStale();
|
|
2997
|
+
let u = this.project.getDirectory(o.outputDir);
|
|
2998
|
+
return u && (n(Or(u, (e) => s.claim("index.ts", e))), Br(u.getDescendantSourceFiles().filter((e) => s.files.has(e.getFilePath())), i)), await s.commit(a), i.debug("Code generation from the Manifest completed successfully"), {
|
|
2999
|
+
files: [...s.files].sort(),
|
|
3000
|
+
configPath: t,
|
|
3001
|
+
warnings: r()
|
|
3002
|
+
};
|
|
3003
|
+
}
|
|
2558
3004
|
};
|
|
2559
|
-
function
|
|
3005
|
+
function Yi(e) {
|
|
2560
3006
|
try {
|
|
2561
3007
|
return new r({
|
|
2562
3008
|
tsConfigFilePath: e,
|
|
@@ -2567,6 +3013,6 @@ function mi(e) {
|
|
|
2567
3013
|
}
|
|
2568
3014
|
}
|
|
2569
3015
|
//#endregion
|
|
2570
|
-
export {
|
|
3016
|
+
export { ae as a, ne as c, ie as i, qi as n, g as o, Vr as r, _ as s, Ji as t };
|
|
2571
3017
|
|
|
2572
|
-
//# sourceMappingURL=codeGenerator-
|
|
3018
|
+
//# sourceMappingURL=codeGenerator-CXBTLKZP.js.map
|