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