@ahoo-wang/wow-generator 10.0.0-alpha.7 → 10.0.0-beta.10
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 +7 -4
- package/README.zh-CN.md +5 -3
- package/dist/analysis/clientNames.d.cts +0 -9
- package/dist/analysis/clientNames.d.ts +0 -9
- package/dist/cli.cjs +1 -1
- package/dist/cli.js +2 -2
- package/dist/{codeGenerator-Bouc_Ad8.js → codeGenerator-CXowDsB9.js} +1216 -842
- package/dist/codeGenerator-CXowDsB9.js.map +1 -0
- package/dist/codeGenerator-q59QJpfT.cjs +38 -0
- package/dist/codeGenerator-q59QJpfT.cjs.map +1 -0
- package/dist/emitters/manifest/aggregate.d.cts +4 -0
- package/dist/emitters/manifest/aggregate.d.ts +4 -0
- package/dist/emitters/manifest/commandClient.d.cts +4 -0
- package/dist/emitters/manifest/commandClient.d.ts +4 -0
- package/dist/emitters/manifest/contextClient.d.cts +8 -0
- package/dist/emitters/manifest/contextClient.d.ts +8 -0
- package/dist/emitters/manifest/contract.d.cts +17 -0
- package/dist/emitters/manifest/contract.d.ts +17 -0
- package/dist/emitters/manifest/generatedModule.d.cts +19 -0
- package/dist/emitters/manifest/generatedModule.d.ts +19 -0
- package/dist/emitters/manifest/queryClient.d.cts +4 -0
- package/dist/emitters/manifest/queryClient.d.ts +4 -0
- package/dist/emitters/manifest/routing.d.cts +9 -0
- package/dist/emitters/manifest/routing.d.ts +9 -0
- package/dist/emitters/manifest/serviceRoutes.d.cts +11 -0
- package/dist/emitters/manifest/serviceRoutes.d.ts +11 -0
- package/dist/emitters/manifest/textNumbers.d.cts +24 -0
- package/dist/emitters/manifest/textNumbers.d.ts +24 -0
- package/dist/emitters/manifest/typeDeclarations.d.cts +4 -0
- package/dist/emitters/manifest/typeDeclarations.d.ts +4 -0
- package/dist/emitters/manifestClients.d.cts +1 -5
- package/dist/emitters/manifestClients.d.ts +1 -5
- package/dist/emitters/models.d.cts +1 -1
- package/dist/emitters/models.d.ts +1 -1
- package/dist/emitters/target.d.cts +1 -1
- package/dist/emitters/target.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/manifest/aggregates.d.cts +6 -0
- package/dist/manifest/aggregates.d.ts +6 -0
- package/dist/manifest/analyze.d.cts +1 -176
- package/dist/manifest/analyze.d.ts +1 -176
- package/dist/manifest/document.d.cts +4 -0
- package/dist/manifest/document.d.ts +4 -0
- package/dist/manifest/model.d.cts +180 -0
- package/dist/manifest/model.d.ts +180 -0
- package/dist/manifest/names.d.cts +30 -0
- package/dist/manifest/names.d.ts +30 -0
- package/dist/manifest/schemaTypes.d.cts +46 -0
- package/dist/manifest/schemaTypes.d.ts +46 -0
- package/dist/manifest/serviceRoutes.d.cts +45 -0
- package/dist/manifest/serviceRoutes.d.ts +45 -0
- package/dist/manifest/textNumbers.d.cts +108 -0
- package/dist/manifest/textNumbers.d.ts +108 -0
- package/dist/manifest/typeText.d.cts +11 -0
- package/dist/manifest/typeText.d.ts +11 -0
- package/dist/naming/naming.d.cts +9 -0
- package/dist/naming/naming.d.ts +9 -0
- package/dist/types/indexSignature.d.cts +18 -0
- package/dist/types/indexSignature.d.ts +18 -0
- package/dist/types/literalTypes.d.cts +11 -0
- package/dist/types/literalTypes.d.ts +11 -0
- package/dist/types/typeContext.d.cts +66 -0
- package/dist/types/typeContext.d.ts +66 -0
- package/dist/types/typeResolver.d.cts +2 -101
- package/dist/types/typeResolver.d.ts +2 -101
- package/package.json +22 -14
- package/dist/codeGenerator-Bouc_Ad8.js.map +0 -1
- package/dist/codeGenerator-C0dKAKl6.cjs +0 -37
- package/dist/codeGenerator-C0dKAKl6.cjs.map +0 -1
|
@@ -2,9 +2,9 @@ import { CodeBlockWriter as e, IndentationText as t, Node as n, Project as r, Qu
|
|
|
2
2
|
import { isAbsolute as u, join as d, relative as f, resolve as p, sep as m } from "path";
|
|
3
3
|
import { parse as h } from "yaml";
|
|
4
4
|
import { readFile as g } from "fs";
|
|
5
|
-
import {
|
|
5
|
+
import { basename as _, join as v } from "node:path";
|
|
6
6
|
// src/api/configuration.ts
|
|
7
|
-
var
|
|
7
|
+
var y = "./wow-generator.config.json", ee = {
|
|
8
8
|
success: 0,
|
|
9
9
|
internal: 1,
|
|
10
10
|
input: 2,
|
|
@@ -12,27 +12,27 @@ var ee = "./wow-generator.config.json", te = {
|
|
|
12
12
|
specification: 4,
|
|
13
13
|
output: 5,
|
|
14
14
|
interrupted: 130
|
|
15
|
-
},
|
|
15
|
+
}, b = 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 ee[this.kind];
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
function
|
|
24
|
+
function x(e) {
|
|
25
25
|
return e instanceof Error ? e.message : String(e);
|
|
26
26
|
}
|
|
27
27
|
// src/api/logger.ts
|
|
28
|
-
function
|
|
28
|
+
function te() {
|
|
29
29
|
return !!process.stdout?.isTTY && !process.env.NO_COLOR;
|
|
30
30
|
}
|
|
31
|
-
var
|
|
31
|
+
var ne = class {
|
|
32
32
|
level;
|
|
33
33
|
decorate;
|
|
34
34
|
constructor(e = {}) {
|
|
35
|
-
this.level = e.level ?? "normal", this.decorate = e.decorate ??
|
|
35
|
+
this.level = e.level ?? "normal", this.decorate = e.decorate ?? te();
|
|
36
36
|
}
|
|
37
37
|
format(e, t, n) {
|
|
38
38
|
let r = this.decorate ? `${e} ` : t ? `${t}: ` : "";
|
|
@@ -50,25 +50,86 @@ var re = class {
|
|
|
50
50
|
error(e, ...t) {
|
|
51
51
|
console.error(this.format("❌", "error", e), ...t);
|
|
52
52
|
}
|
|
53
|
-
},
|
|
53
|
+
}, re = class {
|
|
54
54
|
debug() {}
|
|
55
55
|
info() {}
|
|
56
56
|
warn() {}
|
|
57
57
|
error() {}
|
|
58
|
-
};
|
|
58
|
+
}, ie = /[^\p{L}\p{N}$]+/u, ae = /* @__PURE__ */ new Set(/* @__PURE__ */ "arguments.await.break.case.catch.class.const.continue.debugger.default.delete.do.else.enum.eval.export.extends.false.finally.for.function.if.implements.import.in.instanceof.interface.let.new.null.package.private.protected.public.return.static.super.switch.this.throw.true.try.typeof.var.void.while.with.yield".split("."));
|
|
59
|
+
function S(e) {
|
|
60
|
+
return /^[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*$/u.test(e) && !ae.has(e);
|
|
61
|
+
}
|
|
62
|
+
function oe(e) {
|
|
63
|
+
return /^\p{N}/u.test(e) ? `_${e}` : e;
|
|
64
|
+
}
|
|
65
|
+
function se(e) {
|
|
66
|
+
if (S(e)) return e;
|
|
67
|
+
let t = oe(T(e) || "_");
|
|
68
|
+
return ae.has(t) ? `${t}_` : t;
|
|
69
|
+
}
|
|
70
|
+
function ce(e) {
|
|
71
|
+
return /^\p{Lu}[\p{L}\p{N}$]*$/u.test(e) && S(e);
|
|
72
|
+
}
|
|
73
|
+
function C(e) {
|
|
74
|
+
return oe((Array.isArray(e) ? e : [e]).map((e) => ce(e) ? e : w(e)).join("") || "_");
|
|
75
|
+
}
|
|
76
|
+
function le(e) {
|
|
77
|
+
return e.split(ie);
|
|
78
|
+
}
|
|
79
|
+
function ue(e) {
|
|
80
|
+
return Array.isArray(e) ? e.flatMap((e) => de(le(e))) : de(le(e));
|
|
81
|
+
}
|
|
82
|
+
function de(e) {
|
|
83
|
+
return e.flatMap((e) => {
|
|
84
|
+
if (e.length === 0) return [];
|
|
85
|
+
let t = [], n = "";
|
|
86
|
+
for (let r = 0; r < e.length; r++) {
|
|
87
|
+
let i = e[r], a = /[A-Z]/.test(i), o = r > 0 && /[a-z]/.test(e[r - 1]);
|
|
88
|
+
a && o && n ? (t.push(n), n = i) : n += i;
|
|
89
|
+
}
|
|
90
|
+
return n && t.push(n), t;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function w(e) {
|
|
94
|
+
return e === "" || e.length === 0 ? "" : ue(e).filter((e) => e.length > 0).map((e) => {
|
|
95
|
+
let t = e.charAt(0), n = e.slice(1);
|
|
96
|
+
return (/[a-zA-Z]/.test(t) ? t.toUpperCase() : t) + n.toLowerCase();
|
|
97
|
+
}).join("");
|
|
98
|
+
}
|
|
99
|
+
function T(e) {
|
|
100
|
+
let t = w(e);
|
|
101
|
+
return t.charAt(0).toLowerCase() + t.slice(1);
|
|
102
|
+
}
|
|
103
|
+
function E(e) {
|
|
104
|
+
return e === "" || Array.isArray(e) && e.length === 0 ? "" : ue(e).filter((e) => e.length > 0).map((e) => e.toUpperCase()).join("_");
|
|
105
|
+
}
|
|
106
|
+
function D(e) {
|
|
107
|
+
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e) ? e : O(e);
|
|
108
|
+
}
|
|
109
|
+
function fe(e) {
|
|
110
|
+
return /^\d+$/.test(e) ? `NUM_${e}` : E(e) || e;
|
|
111
|
+
}
|
|
112
|
+
function O(e) {
|
|
113
|
+
return `'${JSON.stringify(e).slice(1, -1).replace(/\\"/g, "\"").replace(/'/g, "\\'")}'`;
|
|
114
|
+
}
|
|
115
|
+
function pe(e, t) {
|
|
116
|
+
let n = se(e), r = n;
|
|
117
|
+
for (let e = 2; t.has(r); e++) r = `${n}${e}`;
|
|
118
|
+
return t.add(r), r;
|
|
119
|
+
}
|
|
59
120
|
// src/naming/paths.ts
|
|
60
|
-
function
|
|
121
|
+
function me(e, t) {
|
|
61
122
|
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? t : t ? `${e.replace(/\/+$/, "")}/${t.replace(/^\/+/, "")}` : e;
|
|
62
123
|
}
|
|
63
|
-
var
|
|
64
|
-
function
|
|
65
|
-
return
|
|
124
|
+
var he = "types.ts";
|
|
125
|
+
function ge(e) {
|
|
126
|
+
return me(e.path, he);
|
|
66
127
|
}
|
|
67
128
|
// src/openapi/references.ts
|
|
68
|
-
function
|
|
129
|
+
function k(e) {
|
|
69
130
|
return !!(e && typeof e == "object" && "$ref" in e);
|
|
70
131
|
}
|
|
71
|
-
function
|
|
132
|
+
function _e(e, t) {
|
|
72
133
|
let n = t.slice(1);
|
|
73
134
|
try {
|
|
74
135
|
n = decodeURIComponent(n);
|
|
@@ -83,7 +144,7 @@ function ce(e, t) {
|
|
|
83
144
|
}
|
|
84
145
|
return r;
|
|
85
146
|
}
|
|
86
|
-
function
|
|
147
|
+
function ve(e) {
|
|
87
148
|
let t = [], n = /* @__PURE__ */ new Set(), r = (i, a) => {
|
|
88
149
|
if (typeof i != "object" || !i || n.has(i)) return;
|
|
89
150
|
if (n.add(i), Array.isArray(i)) {
|
|
@@ -91,7 +152,7 @@ function le(e) {
|
|
|
91
152
|
return;
|
|
92
153
|
}
|
|
93
154
|
let o = i.$ref;
|
|
94
|
-
typeof o == "string" && o.startsWith("#/components/") &&
|
|
155
|
+
typeof o == "string" && o.startsWith("#/components/") && _e(e, o) === void 0 && t.push({
|
|
95
156
|
ref: o,
|
|
96
157
|
location: a || "/"
|
|
97
158
|
});
|
|
@@ -100,111 +161,111 @@ function le(e) {
|
|
|
100
161
|
return r(e, ""), t;
|
|
101
162
|
}
|
|
102
163
|
// src/openapi/components.ts
|
|
103
|
-
var
|
|
104
|
-
function
|
|
164
|
+
var ye = "#/components/", be = `${ye}parameters/`, xe = `${ye}requestBodies/`, Se = `${ye}responses/`, Ce = `${ye}schemas/`;
|
|
165
|
+
function we(e) {
|
|
105
166
|
return e.$ref.split("/").pop();
|
|
106
167
|
}
|
|
107
|
-
function
|
|
168
|
+
function Te(e, t, n) {
|
|
108
169
|
let r = /* @__PURE__ */ new Set(), i = e;
|
|
109
|
-
for (;
|
|
170
|
+
for (; k(i);) {
|
|
110
171
|
if (!i.$ref.startsWith(n)) return;
|
|
111
|
-
if (r.has(i.$ref)) throw new
|
|
172
|
+
if (r.has(i.$ref)) throw new b("specification", `Cyclic component reference: ${i.$ref}`);
|
|
112
173
|
r.add(i.$ref), i = t?.[i.$ref.slice(n.length)];
|
|
113
174
|
}
|
|
114
175
|
return i;
|
|
115
176
|
}
|
|
116
|
-
function
|
|
117
|
-
return
|
|
177
|
+
function A(e, t) {
|
|
178
|
+
return Te(e, t.schemas, Ce);
|
|
118
179
|
}
|
|
119
|
-
function
|
|
120
|
-
return
|
|
180
|
+
function Ee(e, t) {
|
|
181
|
+
return Te(e, t.responses, Se);
|
|
121
182
|
}
|
|
122
|
-
function
|
|
123
|
-
return
|
|
183
|
+
function De(e, t) {
|
|
184
|
+
return Te(e, t.requestBodies, xe);
|
|
124
185
|
}
|
|
125
|
-
function
|
|
126
|
-
return
|
|
186
|
+
function Oe(e, t) {
|
|
187
|
+
return Te(e, t.parameters, be);
|
|
127
188
|
}
|
|
128
189
|
// src/naming/order.ts
|
|
129
|
-
var
|
|
130
|
-
function
|
|
131
|
-
return
|
|
190
|
+
var ke = new Intl.Collator("en-US");
|
|
191
|
+
function j(e, t) {
|
|
192
|
+
return ke.compare(e, t);
|
|
132
193
|
}
|
|
133
194
|
// src/openapi/responses.ts
|
|
134
|
-
var
|
|
135
|
-
function
|
|
195
|
+
var Ae = "application/json", je = "text/event-stream";
|
|
196
|
+
function Me(e) {
|
|
136
197
|
return e.split(";")[0].trim().toLowerCase();
|
|
137
198
|
}
|
|
138
|
-
function
|
|
139
|
-
let t =
|
|
199
|
+
function Ne(e) {
|
|
200
|
+
let t = Me(e);
|
|
140
201
|
return t === "application/json" || /^application\/[^/]+\+json$/.test(t);
|
|
141
202
|
}
|
|
142
|
-
function
|
|
143
|
-
let t =
|
|
203
|
+
function Pe(e) {
|
|
204
|
+
let t = Me(e);
|
|
144
205
|
return t.startsWith("text/") && t !== "text/event-stream";
|
|
145
206
|
}
|
|
146
|
-
function
|
|
207
|
+
function M(e, t, n = (e) => Me(e) === t) {
|
|
147
208
|
if (!e) return;
|
|
148
209
|
if (e[t]) return e[t];
|
|
149
210
|
let r = Object.keys(e).find(n);
|
|
150
211
|
return r === void 0 ? void 0 : e[r];
|
|
151
212
|
}
|
|
152
|
-
function
|
|
153
|
-
if (t && !
|
|
213
|
+
function Fe(e, t) {
|
|
214
|
+
if (t && !k(t)) return M(t.content, e)?.schema;
|
|
154
215
|
}
|
|
155
|
-
function
|
|
156
|
-
if (e && !
|
|
216
|
+
function Ie(e) {
|
|
217
|
+
if (e && !k(e)) return M(e.content, Ae, Ne)?.schema;
|
|
157
218
|
}
|
|
158
|
-
function
|
|
159
|
-
return
|
|
219
|
+
function Le(e) {
|
|
220
|
+
return Fe(je, e);
|
|
160
221
|
}
|
|
161
|
-
function
|
|
162
|
-
return
|
|
222
|
+
function Re(e) {
|
|
223
|
+
return Fe("*/*", e);
|
|
163
224
|
}
|
|
164
|
-
function
|
|
165
|
-
return !e ||
|
|
225
|
+
function ze(e) {
|
|
226
|
+
return !e || k(e) ? !1 : Object.keys(e.content ?? {}).some(Pe);
|
|
166
227
|
}
|
|
167
228
|
// src/openapi/schemas.ts
|
|
168
|
-
function
|
|
229
|
+
function N(e) {
|
|
169
230
|
return Array.isArray(e.enum) && e.enum.length > 0;
|
|
170
231
|
}
|
|
171
|
-
var
|
|
172
|
-
function
|
|
173
|
-
return e[
|
|
232
|
+
var Be = "x-enum-text";
|
|
233
|
+
function Ve(e) {
|
|
234
|
+
return e[Be];
|
|
174
235
|
}
|
|
175
|
-
function
|
|
236
|
+
function He(e) {
|
|
176
237
|
return e.type === "object" && !!e.properties;
|
|
177
238
|
}
|
|
178
|
-
function
|
|
239
|
+
function Ue(e) {
|
|
179
240
|
return e.type === "array" && !!e.items;
|
|
180
241
|
}
|
|
181
|
-
function
|
|
242
|
+
function We(e) {
|
|
182
243
|
return Array.isArray(e.anyOf) && e.anyOf.length > 0;
|
|
183
244
|
}
|
|
184
|
-
function
|
|
245
|
+
function Ge(e) {
|
|
185
246
|
return Array.isArray(e.oneOf) && e.oneOf.length > 0;
|
|
186
247
|
}
|
|
187
|
-
function
|
|
248
|
+
function Ke(e) {
|
|
188
249
|
return Array.isArray(e.allOf) && e.allOf.length > 0;
|
|
189
250
|
}
|
|
190
|
-
function
|
|
191
|
-
return
|
|
251
|
+
function P(e) {
|
|
252
|
+
return We(e) || Ge(e) || Ke(e);
|
|
192
253
|
}
|
|
193
|
-
function
|
|
254
|
+
function qe(e) {
|
|
194
255
|
return e.includes("|") || e.includes("&") ? `(${e})[]` : `${e}[]`;
|
|
195
256
|
}
|
|
196
|
-
function
|
|
257
|
+
function Je(e) {
|
|
197
258
|
return e.type === "object" && !e.properties && e.additionalProperties !== void 0;
|
|
198
259
|
}
|
|
199
|
-
var
|
|
200
|
-
function
|
|
201
|
-
return e[
|
|
260
|
+
var Ye = "x-map-key-schema";
|
|
261
|
+
function Xe(e) {
|
|
262
|
+
return e[Ye];
|
|
202
263
|
}
|
|
203
|
-
function
|
|
264
|
+
function Ze(e) {
|
|
204
265
|
return e.readOnly === !0;
|
|
205
266
|
}
|
|
206
|
-
function
|
|
207
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
267
|
+
function Qe(e) {
|
|
268
|
+
if (Array.isArray(e)) return e.map((e) => Qe(e)).join(" | ");
|
|
208
269
|
switch (e) {
|
|
209
270
|
case "string": return "string";
|
|
210
271
|
case "number":
|
|
@@ -214,10 +275,10 @@ function Ve(e) {
|
|
|
214
275
|
default: return "any";
|
|
215
276
|
}
|
|
216
277
|
}
|
|
217
|
-
function
|
|
278
|
+
function $e(e, t) {
|
|
218
279
|
let n = [], r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = !1, o = (e) => {
|
|
219
280
|
if (!(!e || i.has(e) || a)) {
|
|
220
|
-
if (i.add(e),
|
|
281
|
+
if (i.add(e), k(e)) o(t && A(e, t));
|
|
221
282
|
else if (e.nullable || Array.isArray(e.type)) a = !0;
|
|
222
283
|
else {
|
|
223
284
|
for (let t of e.required ?? []) r.add(t);
|
|
@@ -229,32 +290,32 @@ function He(e, t) {
|
|
|
229
290
|
return o(e), a ? [] : n.filter((e) => !r.has(e));
|
|
230
291
|
}
|
|
231
292
|
// src/openapi/operations.ts
|
|
232
|
-
function
|
|
233
|
-
return e.operation.operationId && t.operation.operationId ?
|
|
293
|
+
function et(e, t) {
|
|
294
|
+
return e.operation.operationId && t.operation.operationId ? j(e.operation.operationId, t.operation.operationId) : e.path && t.path ? j(e.path, t.path) : e.method && t.method ? j(e.method, t.method) : 0;
|
|
234
295
|
}
|
|
235
|
-
function
|
|
296
|
+
function tt(e, t, n) {
|
|
236
297
|
let r = /* @__PURE__ */ new Map();
|
|
237
298
|
for (let i of [...e, ...t]) {
|
|
238
|
-
let e =
|
|
299
|
+
let e = k(i) ? n && Oe(i, n) : i, t = e ? `${e.in}:${e.name}` : i.$ref;
|
|
239
300
|
r.set(t, i);
|
|
240
301
|
}
|
|
241
302
|
return [...r.values()];
|
|
242
303
|
}
|
|
243
|
-
function
|
|
304
|
+
function nt(e, t) {
|
|
244
305
|
let n = [];
|
|
245
|
-
for (let [r, i] of Object.entries(e))
|
|
306
|
+
for (let [r, i] of Object.entries(e)) rt(i).forEach((e) => {
|
|
246
307
|
n.push({
|
|
247
308
|
method: e.method,
|
|
248
309
|
operation: i.parameters?.length ? {
|
|
249
310
|
...e.operation,
|
|
250
|
-
parameters:
|
|
311
|
+
parameters: tt(i.parameters, e.operation.parameters ?? [], t)
|
|
251
312
|
} : e.operation,
|
|
252
313
|
path: r
|
|
253
314
|
});
|
|
254
315
|
});
|
|
255
|
-
return n.sort(
|
|
316
|
+
return n.sort(et);
|
|
256
317
|
}
|
|
257
|
-
function
|
|
318
|
+
function rt(e) {
|
|
258
319
|
return [
|
|
259
320
|
{
|
|
260
321
|
method: "get",
|
|
@@ -290,103 +351,40 @@ function Ke(e) {
|
|
|
290
351
|
}
|
|
291
352
|
].filter(({ operation: e }) => e !== void 0);
|
|
292
353
|
}
|
|
293
|
-
function
|
|
354
|
+
function it(e) {
|
|
294
355
|
let t = Object.keys(e.responses ?? {});
|
|
295
356
|
if (t.includes("200")) return "200";
|
|
296
357
|
let n = t.filter((e) => /^2\d\d$/.test(e)).sort();
|
|
297
358
|
return n.length > 0 ? n[0] : t.find((e) => e.toUpperCase() === "2XX");
|
|
298
359
|
}
|
|
299
|
-
function
|
|
300
|
-
let n =
|
|
301
|
-
return t &&
|
|
360
|
+
function at(e, t) {
|
|
361
|
+
let n = it(e), r = n ? e.responses[n] : void 0;
|
|
362
|
+
return t && k(r) ? Ee(r, t) : r;
|
|
302
363
|
}
|
|
303
|
-
function
|
|
304
|
-
return (e.parameters ?? []).map((e) =>
|
|
364
|
+
function ot(e, t) {
|
|
365
|
+
return (e.parameters ?? []).map((e) => k(e) ? Oe(e, t) : e).filter((e) => e !== void 0);
|
|
305
366
|
}
|
|
306
|
-
function
|
|
367
|
+
function st(e, t) {
|
|
307
368
|
let n = (t) => {
|
|
308
369
|
let n = e.indexOf(`{${t.name}}`);
|
|
309
370
|
return n < 0 ? 2 ** 53 - 1 : n;
|
|
310
371
|
};
|
|
311
372
|
return [...t].sort((e, t) => n(e) - n(t));
|
|
312
373
|
}
|
|
313
|
-
// src/naming/naming.ts
|
|
314
|
-
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("."));
|
|
315
|
-
function O(e) {
|
|
316
|
-
return /^[\p{ID_Start}$_][\p{ID_Continue}$\u200C\u200D]*$/u.test(e) && !Qe.has(e);
|
|
317
|
-
}
|
|
318
|
-
function $e(e) {
|
|
319
|
-
return /^\p{N}/u.test(e) ? `_${e}` : e;
|
|
320
|
-
}
|
|
321
|
-
function et(e) {
|
|
322
|
-
if (O(e)) return e;
|
|
323
|
-
let t = $e(j(e) || "_");
|
|
324
|
-
return Qe.has(t) ? `${t}_` : t;
|
|
325
|
-
}
|
|
326
|
-
function tt(e) {
|
|
327
|
-
return /^\p{Lu}[\p{L}\p{N}$]*$/u.test(e) && O(e);
|
|
328
|
-
}
|
|
329
|
-
function k(e) {
|
|
330
|
-
return $e((Array.isArray(e) ? e : [e]).map((e) => tt(e) ? e : A(e)).join("") || "_");
|
|
331
|
-
}
|
|
332
|
-
function nt(e) {
|
|
333
|
-
return e.split(Ze);
|
|
334
|
-
}
|
|
335
|
-
function rt(e) {
|
|
336
|
-
return Array.isArray(e) ? e.flatMap((e) => it(nt(e))) : it(nt(e));
|
|
337
|
-
}
|
|
338
|
-
function it(e) {
|
|
339
|
-
return e.flatMap((e) => {
|
|
340
|
-
if (e.length === 0) return [];
|
|
341
|
-
let t = [], n = "";
|
|
342
|
-
for (let r = 0; r < e.length; r++) {
|
|
343
|
-
let i = e[r], a = /[A-Z]/.test(i), o = r > 0 && /[a-z]/.test(e[r - 1]);
|
|
344
|
-
a && o && n ? (t.push(n), n = i) : n += i;
|
|
345
|
-
}
|
|
346
|
-
return n && t.push(n), t;
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
function A(e) {
|
|
350
|
-
return e === "" || e.length === 0 ? "" : rt(e).filter((e) => e.length > 0).map((e) => {
|
|
351
|
-
let t = e.charAt(0), n = e.slice(1);
|
|
352
|
-
return (/[a-zA-Z]/.test(t) ? t.toUpperCase() : t) + n.toLowerCase();
|
|
353
|
-
}).join("");
|
|
354
|
-
}
|
|
355
|
-
function j(e) {
|
|
356
|
-
let t = A(e);
|
|
357
|
-
return t.charAt(0).toLowerCase() + t.slice(1);
|
|
358
|
-
}
|
|
359
|
-
function M(e) {
|
|
360
|
-
return e === "" || Array.isArray(e) && e.length === 0 ? "" : rt(e).filter((e) => e.length > 0).map((e) => e.toUpperCase()).join("_");
|
|
361
|
-
}
|
|
362
|
-
function N(e) {
|
|
363
|
-
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e) ? e : P(e);
|
|
364
|
-
}
|
|
365
|
-
function at(e) {
|
|
366
|
-
return /^\d+$/.test(e) ? `NUM_${e}` : M(e) || e;
|
|
367
|
-
}
|
|
368
|
-
function P(e) {
|
|
369
|
-
return `'${JSON.stringify(e).slice(1, -1).replace(/\\"/g, "\"").replace(/'/g, "\\'")}'`;
|
|
370
|
-
}
|
|
371
374
|
// src/analysis/clientNames.ts
|
|
372
|
-
var
|
|
373
|
-
function
|
|
375
|
+
var ct = "x-fetcher-method";
|
|
376
|
+
function lt(e, t) {
|
|
374
377
|
let n = t ?? e["x-fetcher-method"];
|
|
375
378
|
if (n !== void 0) {
|
|
376
|
-
if (typeof n != "string" || !
|
|
379
|
+
if (typeof n != "string" || !ut(n)) throw new b("specification", `${ct} of ${e.operationId ?? "an operation"} is ${JSON.stringify(n)}, which is not a valid method name.`);
|
|
377
380
|
return n;
|
|
378
381
|
}
|
|
379
382
|
if (!e.operationId) return;
|
|
380
|
-
let r =
|
|
383
|
+
let r = T(e.operationId.split(".").pop()) || "_";
|
|
381
384
|
return /^\p{N}/u.test(r) ? `_${r}` : r;
|
|
382
385
|
}
|
|
383
|
-
function
|
|
384
|
-
return
|
|
385
|
-
}
|
|
386
|
-
function lt(e, t) {
|
|
387
|
-
let n = et(e), r = n;
|
|
388
|
-
for (let e = 2; t.has(r); e++) r = `${n}${e}`;
|
|
389
|
-
return t.add(r), r;
|
|
386
|
+
function ut(e) {
|
|
387
|
+
return S(e) || /^[a-z]+$/.test(e);
|
|
390
388
|
}
|
|
391
389
|
// src/analysis/modelInfo.ts
|
|
392
390
|
function F(e) {
|
|
@@ -401,20 +399,20 @@ function F(e) {
|
|
|
401
399
|
}
|
|
402
400
|
let r = t.slice(0, n), i = r.length > 0 ? `/${r.join("/")}` : "/";
|
|
403
401
|
return {
|
|
404
|
-
name:
|
|
402
|
+
name: C(t.slice(n)),
|
|
405
403
|
path: i
|
|
406
404
|
};
|
|
407
405
|
}
|
|
408
|
-
function
|
|
409
|
-
if (!e.$ref.startsWith("#/components/schemas/")) throw new
|
|
410
|
-
return t &&
|
|
406
|
+
function dt(e, t) {
|
|
407
|
+
if (!e.$ref.startsWith("#/components/schemas/")) throw new b("specification", `Unsupported schema reference: ${e.$ref}. Bundle or inline external schemas before generation.`);
|
|
408
|
+
return t && A(e, t), F(we(e));
|
|
411
409
|
}
|
|
412
410
|
// src/analysis/apiClients.ts
|
|
413
|
-
var
|
|
414
|
-
function
|
|
415
|
-
return new
|
|
411
|
+
var ft = ["httpRequest", "attributes"];
|
|
412
|
+
function pt(e, t, n) {
|
|
413
|
+
return new mt(e, t, n).clients();
|
|
416
414
|
}
|
|
417
|
-
var
|
|
415
|
+
var mt = class {
|
|
418
416
|
document;
|
|
419
417
|
config;
|
|
420
418
|
warnings;
|
|
@@ -425,15 +423,15 @@ var pt = class {
|
|
|
425
423
|
let e = this.tags(), t = this.groupOperations(), n = /* @__PURE__ */ new Map();
|
|
426
424
|
return [...t.keys()].sort().map((r) => {
|
|
427
425
|
let i = F(r), a = i;
|
|
428
|
-
for (let e = 2; n.has(
|
|
426
|
+
for (let e = 2; n.has(gt(a)); e++) a = {
|
|
429
427
|
...i,
|
|
430
428
|
name: `${i.name}${e}`
|
|
431
429
|
};
|
|
432
|
-
return a !== i && this.warnings.push(`Tags ${n.get(
|
|
430
|
+
return a !== i && this.warnings.push(`Tags ${n.get(gt(i))} and ${r} both name the API client ${i.name}ApiClient; ${r} generates ${a.name}ApiClient.`), n.set(gt(a), r), this.client(e.get(r), a, [...t.get(r)]);
|
|
433
431
|
});
|
|
434
432
|
}
|
|
435
433
|
client(e, t, n) {
|
|
436
|
-
let r = `${t.name}ApiClient`, i =
|
|
434
|
+
let r = `${t.name}ApiClient`, i = me(t.path, ht(r)), a = /* @__PURE__ */ new Map();
|
|
437
435
|
return {
|
|
438
436
|
tagName: e.name,
|
|
439
437
|
className: r,
|
|
@@ -443,7 +441,7 @@ var pt = class {
|
|
|
443
441
|
};
|
|
444
442
|
}
|
|
445
443
|
method(e, t, n, r) {
|
|
446
|
-
let { operation: i } = n, a = this.methodName(e, t, n, r), o = new Set(
|
|
444
|
+
let { operation: i } = n, a = this.methodName(e, t, n, r), o = new Set(ft), 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);
|
|
447
445
|
return {
|
|
448
446
|
name: a,
|
|
449
447
|
httpMethod: n.method,
|
|
@@ -461,21 +459,21 @@ var pt = class {
|
|
|
461
459
|
};
|
|
462
460
|
}
|
|
463
461
|
methodName(e, t, n, r) {
|
|
464
|
-
let i = n.operation.operationId, a =
|
|
465
|
-
if (o !== void 0) throw new
|
|
462
|
+
let i = n.operation.operationId, a = lt(n.operation, this.config.apiClients?.[e.name]?.methodNames?.[i]), o = r.get(a);
|
|
463
|
+
if (o !== void 0) throw new b("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.`);
|
|
466
464
|
return r.set(a, i), a;
|
|
467
465
|
}
|
|
468
466
|
parameters(e, t, n) {
|
|
469
|
-
let r =
|
|
467
|
+
let r = ot(t.operation, this.document.components ?? {}), i = [];
|
|
470
468
|
for (let a of [
|
|
471
469
|
"path",
|
|
472
470
|
"query",
|
|
473
471
|
"header"
|
|
474
472
|
]) {
|
|
475
473
|
let o = r.filter((e) => e.in === a);
|
|
476
|
-
for (let r of a === "path" ?
|
|
474
|
+
for (let r of a === "path" ? st(t.path, o) : o) a === "path" && this.ignoresPathParameter(e.name, r.name) || i.push({
|
|
477
475
|
parameter: {
|
|
478
|
-
name:
|
|
476
|
+
name: pe(r.name, n),
|
|
479
477
|
location: a,
|
|
480
478
|
parameterName: r.name,
|
|
481
479
|
schema: r.schema,
|
|
@@ -492,26 +490,26 @@ var pt = class {
|
|
|
492
490
|
}
|
|
493
491
|
body(e, t) {
|
|
494
492
|
if (!e.requestBody) return;
|
|
495
|
-
let n =
|
|
493
|
+
let n = k(e.requestBody) ? De(e.requestBody, this.document.components) : e.requestBody;
|
|
496
494
|
if (!n) return;
|
|
497
|
-
let r = n.required === !0, i = n.content ?? {}, a =
|
|
495
|
+
let r = n.required === !0, i = n.content ?? {}, a = M(i, Ae, Ne), o = pe("body", t);
|
|
498
496
|
return a?.schema ? {
|
|
499
497
|
name: o,
|
|
500
498
|
required: r,
|
|
501
499
|
content: {
|
|
502
500
|
kind: "json",
|
|
503
501
|
schema: a.schema,
|
|
504
|
-
optionalFields:
|
|
502
|
+
optionalFields: $e(a.schema, this.document.components)
|
|
505
503
|
}
|
|
506
|
-
} :
|
|
504
|
+
} : M(i, "multipart/form-data") ? {
|
|
507
505
|
name: o,
|
|
508
506
|
required: r,
|
|
509
507
|
content: { kind: "formData" }
|
|
510
|
-
} :
|
|
508
|
+
} : M(i, "application/x-www-form-urlencoded") ? {
|
|
511
509
|
name: o,
|
|
512
510
|
required: r,
|
|
513
511
|
content: { kind: "urlEncoded" }
|
|
514
|
-
} : Object.keys(i).some(
|
|
512
|
+
} : Object.keys(i).some(Pe) ? {
|
|
515
513
|
name: o,
|
|
516
514
|
required: r,
|
|
517
515
|
content: { kind: "text" }
|
|
@@ -522,20 +520,20 @@ var pt = class {
|
|
|
522
520
|
};
|
|
523
521
|
}
|
|
524
522
|
returns(e) {
|
|
525
|
-
let t =
|
|
523
|
+
let t = at(e, this.document.components);
|
|
526
524
|
if (!t) return { kind: "response" };
|
|
527
|
-
let n =
|
|
525
|
+
let n = Ie(t), r = n || Re(t);
|
|
528
526
|
if (r) return {
|
|
529
527
|
kind: "json",
|
|
530
528
|
schema: r,
|
|
531
529
|
wildcard: !n
|
|
532
530
|
};
|
|
533
|
-
let i =
|
|
531
|
+
let i = Le(t);
|
|
534
532
|
if (i) {
|
|
535
|
-
if (
|
|
536
|
-
let e =
|
|
537
|
-
if (
|
|
538
|
-
let t =
|
|
533
|
+
if (k(i)) {
|
|
534
|
+
let e = A(i, this.document.components);
|
|
535
|
+
if (Ue(e) && k(e.items)) {
|
|
536
|
+
let t = dt(e.items, this.document.components);
|
|
539
537
|
return {
|
|
540
538
|
kind: "eventStream",
|
|
541
539
|
items: e.items,
|
|
@@ -548,7 +546,7 @@ var pt = class {
|
|
|
548
546
|
serverSentEvent: !1
|
|
549
547
|
};
|
|
550
548
|
}
|
|
551
|
-
return
|
|
549
|
+
return ze(t) ? { kind: "text" } : { kind: "response" };
|
|
552
550
|
}
|
|
553
551
|
groupOperations() {
|
|
554
552
|
let e = /* @__PURE__ */ new Map();
|
|
@@ -571,49 +569,49 @@ var pt = class {
|
|
|
571
569
|
return this.document.openAPI.tags?.forEach((t) => e.set(t.name, t)), e;
|
|
572
570
|
}
|
|
573
571
|
};
|
|
574
|
-
function
|
|
572
|
+
function ht(e) {
|
|
575
573
|
return `${e.charAt(0).toLowerCase()}${e.slice(1)}.ts`;
|
|
576
574
|
}
|
|
577
|
-
function
|
|
575
|
+
function gt(e) {
|
|
578
576
|
return `${e.path}/${e.name}`.toLowerCase();
|
|
579
577
|
}
|
|
580
578
|
// src/analysis/models.ts
|
|
581
|
-
function
|
|
579
|
+
function _t(e) {
|
|
582
580
|
let t = e.components?.schemas;
|
|
583
581
|
if (!t) return [];
|
|
584
582
|
let n = Object.keys(t);
|
|
585
|
-
return
|
|
583
|
+
return vt(n), n.map((e) => {
|
|
586
584
|
let n = t[e], r = F(e);
|
|
587
585
|
return {
|
|
588
586
|
key: e,
|
|
589
587
|
info: r,
|
|
590
|
-
file:
|
|
588
|
+
file: ge(r),
|
|
591
589
|
schema: n
|
|
592
590
|
};
|
|
593
591
|
});
|
|
594
592
|
}
|
|
595
|
-
function
|
|
593
|
+
function vt(e) {
|
|
596
594
|
let t = /* @__PURE__ */ new Map();
|
|
597
595
|
for (let n of e) {
|
|
598
596
|
let e = F(n), r = `${e.path === "/" ? "" : e.path}/${e.name}`;
|
|
599
597
|
t.set(r, [...t.get(r) ?? [], n]);
|
|
600
598
|
}
|
|
601
599
|
let n = [...t].filter(([, e]) => e.length > 1);
|
|
602
|
-
if (n.length !== 0) throw new
|
|
600
|
+
if (n.length !== 0) throw new b("specification", `Schemas generate the same model: ${n.map(([e, t]) => `${t.join(", ")} → ${e}`).join("; ")}. Rename all but one of them in the document.`);
|
|
603
601
|
}
|
|
604
602
|
// src/analysis/analyze.ts
|
|
605
|
-
function
|
|
603
|
+
function yt(e, t) {
|
|
606
604
|
let n = [];
|
|
607
605
|
return {
|
|
608
606
|
model: {
|
|
609
|
-
models:
|
|
610
|
-
apiClients:
|
|
607
|
+
models: _t(e),
|
|
608
|
+
apiClients: pt(e, t, n)
|
|
611
609
|
},
|
|
612
610
|
warnings: n
|
|
613
611
|
};
|
|
614
612
|
}
|
|
615
613
|
// src/emit/importRegistry.ts
|
|
616
|
-
var
|
|
614
|
+
var bt = class {
|
|
617
615
|
declarations = /* @__PURE__ */ new Map();
|
|
618
616
|
add(e, t) {
|
|
619
617
|
let n = this.declarations.get(e);
|
|
@@ -649,9 +647,9 @@ var yt = class {
|
|
|
649
647
|
})
|
|
650
648
|
}));
|
|
651
649
|
}
|
|
652
|
-
},
|
|
650
|
+
}, xt = class {
|
|
653
651
|
sourceFile;
|
|
654
|
-
imports = new
|
|
652
|
+
imports = new bt();
|
|
655
653
|
statements = [];
|
|
656
654
|
constructor(e) {
|
|
657
655
|
this.sourceFile = e;
|
|
@@ -668,10 +666,10 @@ var yt = class {
|
|
|
668
666
|
...n,
|
|
669
667
|
kind: o.ImportDeclaration
|
|
670
668
|
}, e.push(t);
|
|
671
|
-
for (let n of this.statements) t &&
|
|
669
|
+
for (let n of this.statements) t && wt(t, n) && e.push(Ct), e.push(n), t = n;
|
|
672
670
|
return e.length > 0 && this.sourceFile.addStatements(e), this.sourceFile;
|
|
673
671
|
}
|
|
674
|
-
},
|
|
672
|
+
}, St = class {
|
|
675
673
|
open;
|
|
676
674
|
modules = /* @__PURE__ */ new Map();
|
|
677
675
|
constructor(e) {
|
|
@@ -679,16 +677,16 @@ var yt = class {
|
|
|
679
677
|
}
|
|
680
678
|
module(e) {
|
|
681
679
|
let t = this.open(e), n = t.getFilePath(), r = this.modules.get(n);
|
|
682
|
-
return r || (r = new
|
|
680
|
+
return r || (r = new xt(t), this.modules.set(n, r)), r;
|
|
683
681
|
}
|
|
684
682
|
build() {
|
|
685
683
|
for (let e of this.modules.values()) e.build();
|
|
686
684
|
this.modules.clear();
|
|
687
685
|
}
|
|
688
|
-
},
|
|
686
|
+
}, Ct = (e) => {
|
|
689
687
|
e.blankLineIfLastNot();
|
|
690
688
|
};
|
|
691
|
-
function
|
|
689
|
+
function wt(e, t) {
|
|
692
690
|
if (typeof t == "string") return !1;
|
|
693
691
|
switch (t.kind) {
|
|
694
692
|
case o.TypeAlias:
|
|
@@ -696,7 +694,7 @@ function Ct(e, t) {
|
|
|
696
694
|
default: return !0;
|
|
697
695
|
}
|
|
698
696
|
}
|
|
699
|
-
function
|
|
697
|
+
function Tt(e, t) {
|
|
700
698
|
return {
|
|
701
699
|
name: "[key: string]",
|
|
702
700
|
type: e,
|
|
@@ -704,43 +702,43 @@ function wt(e, t) {
|
|
|
704
702
|
};
|
|
705
703
|
}
|
|
706
704
|
// src/emit/imports.ts
|
|
707
|
-
var
|
|
705
|
+
var Et = "@";
|
|
708
706
|
function I(e, t, n) {
|
|
709
707
|
return e.imports.add(t, n);
|
|
710
708
|
}
|
|
711
|
-
function
|
|
712
|
-
return n.path.startsWith(
|
|
709
|
+
function Dt(e, t, n) {
|
|
710
|
+
return n.path.startsWith(Et) ? n.path : L(e.directoryPath, d(t, n.path, he));
|
|
713
711
|
}
|
|
714
712
|
function L(e, t) {
|
|
715
713
|
let n = f(e, t).split(m).join("/");
|
|
716
714
|
return n = n.endsWith(".ts") ? n.replace(/\.ts$/, ".js") : `${n}/index.js`, n.startsWith(".") ? n : `./${n}`;
|
|
717
715
|
}
|
|
718
716
|
// src/emit/jsdoc.ts
|
|
719
|
-
function
|
|
717
|
+
function Ot(e, t = "\n") {
|
|
720
718
|
if (!Array.isArray(e)) return;
|
|
721
|
-
let n = e.filter((e) => typeof e == "string" && e.length > 0).map(
|
|
719
|
+
let n = e.filter((e) => typeof e == "string" && e.length > 0).map(kt);
|
|
722
720
|
return n.length > 0 ? n.join(t) : void 0;
|
|
723
721
|
}
|
|
724
|
-
function
|
|
722
|
+
function kt(e) {
|
|
725
723
|
return e.replace(/\*\//g, "*\\/");
|
|
726
724
|
}
|
|
727
725
|
function R(e, t) {
|
|
728
|
-
let n =
|
|
726
|
+
let n = Ot(t);
|
|
729
727
|
n && (e.docs = [...e.docs ?? [], n]);
|
|
730
728
|
}
|
|
731
|
-
function
|
|
732
|
-
e =
|
|
729
|
+
function At(e, t, n = !1) {
|
|
730
|
+
e = Nt(e);
|
|
733
731
|
let r = [e.title, e.description];
|
|
734
|
-
return t && r.push(`- key: ${t}`), n &&
|
|
732
|
+
return t && r.push(`- key: ${t}`), n && Pt(r, e), e.format && r.push(e.format === "int64" ? "- format: int64 (a value beyond Number.MAX_SAFE_INTEGER loses precision)" : `- format: ${e.format}`), Ft(r, e, "default"), Ft(r, e, "example"), Lt(r, e), Rt(r, e), zt(r, e), r;
|
|
735
733
|
}
|
|
736
|
-
function
|
|
737
|
-
R(e,
|
|
734
|
+
function jt(e, t, n) {
|
|
735
|
+
R(e, At(t, n));
|
|
738
736
|
}
|
|
739
|
-
function
|
|
740
|
-
let i =
|
|
741
|
-
r &&
|
|
737
|
+
function Mt(e, t, n, r = !1) {
|
|
738
|
+
let i = At(t, n, !0);
|
|
739
|
+
r && It(i, "schema", t), R(e, i);
|
|
742
740
|
}
|
|
743
|
-
function
|
|
741
|
+
function Nt(e) {
|
|
744
742
|
for (let t of ["anyOf", "oneOf"]) {
|
|
745
743
|
let n = e[t];
|
|
746
744
|
if (!Array.isArray(n) || n.length < 2) continue;
|
|
@@ -752,31 +750,73 @@ function Mt(e) {
|
|
|
752
750
|
}
|
|
753
751
|
return e;
|
|
754
752
|
}
|
|
755
|
-
function
|
|
753
|
+
function Pt(e, t) {
|
|
756
754
|
let n = t.required ?? [];
|
|
757
755
|
(n.length || Object.keys(t.properties ?? {}).length) && e.push(`- required: ${n.length ? n.join(", ") : "(none)"}`);
|
|
758
756
|
}
|
|
759
|
-
function
|
|
757
|
+
function Ft(e, t, n) {
|
|
760
758
|
let r = t[n];
|
|
761
|
-
r && (typeof r == "object" ?
|
|
759
|
+
r && (typeof r == "object" ? It(e, n, r) : e.push(`- ${n}: \`${r}\``));
|
|
762
760
|
}
|
|
763
|
-
function
|
|
761
|
+
function It(e, t, n) {
|
|
764
762
|
e.push(`- ${t}: `), e.push("```json"), e.push(JSON.stringify(n, null, 2)), e.push("```");
|
|
765
763
|
}
|
|
766
|
-
function
|
|
764
|
+
function Lt(e, t) {
|
|
767
765
|
let n = ["- Numeric Constraints"];
|
|
768
766
|
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);
|
|
769
767
|
}
|
|
770
|
-
function
|
|
768
|
+
function Rt(e, t) {
|
|
771
769
|
let n = ["- String Constraints"];
|
|
772
770
|
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);
|
|
773
771
|
}
|
|
774
|
-
function
|
|
772
|
+
function zt(e, t) {
|
|
775
773
|
let n = ["- Array Constraints"];
|
|
776
774
|
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);
|
|
777
775
|
}
|
|
778
|
-
// src/types/
|
|
779
|
-
function
|
|
776
|
+
// src/types/indexSignature.ts
|
|
777
|
+
function Bt(e, t) {
|
|
778
|
+
return e === void 0 ? !1 : typeof e == "string" || typeof t == "string" ? e === t : e.primitive === t.primitive;
|
|
779
|
+
}
|
|
780
|
+
function z(e, t, n = /* @__PURE__ */ new Set()) {
|
|
781
|
+
if (k(e)) {
|
|
782
|
+
if (!t || n.has(e.$ref)) return;
|
|
783
|
+
n.add(e.$ref);
|
|
784
|
+
let r = A(e, t);
|
|
785
|
+
return r ? z(r, t, n) : void 0;
|
|
786
|
+
}
|
|
787
|
+
if (!(e.nullable || Array.isArray(e.type))) {
|
|
788
|
+
if (Ke(e) && e.type === void 0) {
|
|
789
|
+
let r = e.allOf.map((e) => z(e, t, n)), [i] = r;
|
|
790
|
+
return i !== void 0 && r.every((e) => Bt(e, i)) ? i : void 0;
|
|
791
|
+
}
|
|
792
|
+
if (!(P(e) || e.const !== void 0 || e.type === void 0)) return e.type === "object" ? "object" : e.type === "array" ? "array" : { primitive: Qe(e.type) };
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
function Vt(e, t, n) {
|
|
796
|
+
let r = z(t, n);
|
|
797
|
+
if (typeof r != "object") return !1;
|
|
798
|
+
let i = z(e, n);
|
|
799
|
+
return i === void 0 || typeof i == "string" || i.primitive !== r.primitive;
|
|
800
|
+
}
|
|
801
|
+
function Ht(e, t) {
|
|
802
|
+
let n = e.additionalProperties;
|
|
803
|
+
return typeof n == "object" && Object.values(e.properties ?? {}).some((e) => Vt(e, n, t));
|
|
804
|
+
}
|
|
805
|
+
// src/types/literalTypes.ts
|
|
806
|
+
function Ut(e, t) {
|
|
807
|
+
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);
|
|
808
|
+
}
|
|
809
|
+
function B(t) {
|
|
810
|
+
if (typeof t == "string") return new e({ useSingleQuote: !0 }).quote(t).toString();
|
|
811
|
+
if (Array.isArray(t)) return `[${t.map((e) => B(e)).join(", ")}]`;
|
|
812
|
+
if (typeof t == "object" && t) {
|
|
813
|
+
let e = Object.entries(t).map(([e, t]) => `${D(e)}: ${B(t)}`);
|
|
814
|
+
return e.length ? `{ ${e.join("; ")}; readonly [globalThis.Symbol.iterator]?: never }` : "globalThis.Record<string, never>";
|
|
815
|
+
}
|
|
816
|
+
return JSON.stringify(t) ?? "never";
|
|
817
|
+
}
|
|
818
|
+
// src/types/typeContext.ts
|
|
819
|
+
function Wt(e, t) {
|
|
780
820
|
let n;
|
|
781
821
|
return {
|
|
782
822
|
components: e,
|
|
@@ -793,7 +833,7 @@ function zt(e, t) {
|
|
|
793
833
|
}
|
|
794
834
|
};
|
|
795
835
|
}
|
|
796
|
-
var
|
|
836
|
+
var Gt = [
|
|
797
837
|
"Array",
|
|
798
838
|
"Blob",
|
|
799
839
|
"Exclude",
|
|
@@ -805,11 +845,11 @@ var Bt = [
|
|
|
805
845
|
"Response",
|
|
806
846
|
"Symbol",
|
|
807
847
|
"URLSearchParams"
|
|
808
|
-
],
|
|
848
|
+
], Kt = /* @__PURE__ */ new Set([
|
|
809
849
|
"string",
|
|
810
850
|
"number",
|
|
811
851
|
"boolean"
|
|
812
|
-
]),
|
|
852
|
+
]), qt = /* @__PURE__ */ new Set([
|
|
813
853
|
"$comment",
|
|
814
854
|
"$schema",
|
|
815
855
|
"default",
|
|
@@ -823,54 +863,14 @@ var Bt = [
|
|
|
823
863
|
"writeOnly",
|
|
824
864
|
"xml"
|
|
825
865
|
]);
|
|
826
|
-
function
|
|
827
|
-
return e
|
|
828
|
-
}
|
|
829
|
-
function z(e, t, n = /* @__PURE__ */ new Set()) {
|
|
830
|
-
if (b(e)) {
|
|
831
|
-
if (!t || n.has(e.$ref)) return;
|
|
832
|
-
n.add(e.$ref);
|
|
833
|
-
let r = C(e, t);
|
|
834
|
-
return r ? z(r, t, n) : void 0;
|
|
835
|
-
}
|
|
836
|
-
if (!(e.nullable || Array.isArray(e.type))) {
|
|
837
|
-
if (Fe(e) && e.type === void 0) {
|
|
838
|
-
let r = e.allOf.map((e) => z(e, t, n)), [i] = r;
|
|
839
|
-
return i !== void 0 && r.every((e) => Ut(e, i)) ? i : void 0;
|
|
840
|
-
}
|
|
841
|
-
if (!(D(e) || e.const !== void 0 || e.type === void 0)) return e.type === "object" ? "object" : e.type === "array" ? "array" : { primitive: Ve(e.type) };
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
function Wt(e, t, n) {
|
|
845
|
-
let r = z(t, n);
|
|
846
|
-
if (typeof r != "object") return !1;
|
|
847
|
-
let i = z(e, n);
|
|
848
|
-
return i === void 0 || typeof i == "string" || i.primitive !== r.primitive;
|
|
849
|
-
}
|
|
850
|
-
function Gt(e, t) {
|
|
851
|
-
let n = e.additionalProperties;
|
|
852
|
-
return typeof n == "object" && Object.values(e.properties ?? {}).some((e) => Wt(e, n, t));
|
|
853
|
-
}
|
|
854
|
-
function Kt(e) {
|
|
855
|
-
return e.nullable !== !0 || E(e) || !D(e) ? !1 : [
|
|
866
|
+
function Jt(e) {
|
|
867
|
+
return e.nullable !== !0 || N(e) || !P(e) ? !1 : [
|
|
856
868
|
e.allOf,
|
|
857
869
|
e.oneOf,
|
|
858
870
|
e.anyOf
|
|
859
|
-
].every((e) => e === void 0 || e.every(
|
|
871
|
+
].every((e) => e === void 0 || e.every(k));
|
|
860
872
|
}
|
|
861
|
-
|
|
862
|
-
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);
|
|
863
|
-
}
|
|
864
|
-
function B(t) {
|
|
865
|
-
if (typeof t == "string") return new e({ useSingleQuote: !0 }).quote(t).toString();
|
|
866
|
-
if (Array.isArray(t)) return `[${t.map((e) => B(e)).join(", ")}]`;
|
|
867
|
-
if (typeof t == "object" && t) {
|
|
868
|
-
let e = Object.entries(t).map(([e, t]) => `${N(e)}: ${B(t)}`);
|
|
869
|
-
return e.length ? `{ ${e.join("; ")}; readonly [globalThis.Symbol.iterator]?: never }` : "globalThis.Record<string, never>";
|
|
870
|
-
}
|
|
871
|
-
return JSON.stringify(t) ?? "never";
|
|
872
|
-
}
|
|
873
|
-
var Jt = class {
|
|
873
|
+
var Yt = class {
|
|
874
874
|
scope;
|
|
875
875
|
entries;
|
|
876
876
|
requested = [];
|
|
@@ -902,7 +902,7 @@ var Jt = class {
|
|
|
902
902
|
name: t.name
|
|
903
903
|
}, this.entries.push(i)), this.request(i), i.alias) return i.alias;
|
|
904
904
|
let a = /* @__PURE__ */ new Set([
|
|
905
|
-
...
|
|
905
|
+
...Gt,
|
|
906
906
|
n.name,
|
|
907
907
|
...n.path === void 0 ? [] : this.scope.context.namesAt(n.path),
|
|
908
908
|
...this.entries.filter((e) => e !== i).map((e) => e.alias ?? e.name)
|
|
@@ -924,9 +924,9 @@ var Jt = class {
|
|
|
924
924
|
propertyDefinitions(e) {
|
|
925
925
|
let { properties: t } = e;
|
|
926
926
|
return Object.entries(t).map(([e, t]) => {
|
|
927
|
-
let n = this.type(t), r = (
|
|
928
|
-
if (!
|
|
929
|
-
let e =
|
|
927
|
+
let n = this.type(t), r = (Ze(t) ? "readonly " : "") + D(e);
|
|
928
|
+
if (!k(t)) {
|
|
929
|
+
let e = Ot(At(t), "\n * ");
|
|
930
930
|
if (e) return `
|
|
931
931
|
/**
|
|
932
932
|
* ${e}
|
|
@@ -939,9 +939,9 @@ var Jt = class {
|
|
|
939
939
|
}
|
|
940
940
|
objectType(e) {
|
|
941
941
|
let t = [];
|
|
942
|
-
|
|
943
|
-
for (let n of e.required ?? []) Object.hasOwn(e.properties ?? {}, n) || t.push(`${
|
|
944
|
-
let n =
|
|
942
|
+
He(e) && t.push(...this.propertyDefinitions(e));
|
|
943
|
+
for (let n of e.required ?? []) Object.hasOwn(e.properties ?? {}, n) || t.push(`${D(n)}: ${this.requiredAdditionalPropertyType(e)}`);
|
|
944
|
+
let n = Je(e) && Xe(e) ? this.mapType(e) : Ht(e, this.components) ? `globalThis.Record<string, ${this.additionalPropertyType(e)}>` : void 0, r = n ? "" : this.additionalProperties(e);
|
|
945
945
|
if (r && t.push(r), t.length === 0) return "globalThis.Record<string, any>";
|
|
946
946
|
let i = `{\n ${t.join(";\n ")}; \n}`;
|
|
947
947
|
return n ? `(${i} & ${n})` : i;
|
|
@@ -950,14 +950,14 @@ var Jt = class {
|
|
|
950
950
|
return e.additionalProperties === void 0 || e.additionalProperties === !1 || e.additionalProperties === !0 ? "any" : this.type(e.additionalProperties);
|
|
951
951
|
}
|
|
952
952
|
mapKeyType(e) {
|
|
953
|
-
let t =
|
|
953
|
+
let t = Xe(e);
|
|
954
954
|
return t ? this.type(t) : "string";
|
|
955
955
|
}
|
|
956
956
|
mapType(e) {
|
|
957
957
|
return `globalThis.Record<${this.mapKeyType(e)},${this.mapValueType(e)}>`;
|
|
958
958
|
}
|
|
959
959
|
objectConstrained(e) {
|
|
960
|
-
let t = (e) =>
|
|
960
|
+
let t = (e) => k(e) ? this.components && A(e, this.components) : e, n = t(e), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = n ? [n] : [];
|
|
961
961
|
for (let e of a) {
|
|
962
962
|
if (r.has(e)) continue;
|
|
963
963
|
let n = [
|
|
@@ -981,7 +981,7 @@ var Jt = class {
|
|
|
981
981
|
return n !== void 0 && i.has(n);
|
|
982
982
|
}
|
|
983
983
|
type(e) {
|
|
984
|
-
if (
|
|
984
|
+
if (k(e)) return this.reference(e);
|
|
985
985
|
if (Array.isArray(e.type)) return e.type.map((t) => {
|
|
986
986
|
let n = this.type({
|
|
987
987
|
...e,
|
|
@@ -989,11 +989,11 @@ var Jt = class {
|
|
|
989
989
|
});
|
|
990
990
|
return /[|&]/.test(n) ? `(${n})` : n;
|
|
991
991
|
}).join(" | ");
|
|
992
|
-
if (
|
|
992
|
+
if (Jt(e)) return `(${this.type({
|
|
993
993
|
...e,
|
|
994
994
|
nullable: !1
|
|
995
995
|
})}) | null`;
|
|
996
|
-
if (
|
|
996
|
+
if (P(e)) {
|
|
997
997
|
let t = this.simpleComposition(e);
|
|
998
998
|
if (t !== void 0) return t;
|
|
999
999
|
let n = [
|
|
@@ -1015,25 +1015,25 @@ var Jt = class {
|
|
|
1015
1015
|
return this.objectConstrained(e) ? `globalThis.Exclude<${o}, string | number | boolean | readonly unknown[]> & ({ readonly [globalThis.Symbol.iterator]?: never } | null)` : o;
|
|
1016
1016
|
}
|
|
1017
1017
|
if (e.const !== void 0) {
|
|
1018
|
-
if (!
|
|
1018
|
+
if (!Ut(e.const, e)) return "never";
|
|
1019
1019
|
let t = B(e.const), n = this.type({
|
|
1020
1020
|
...e,
|
|
1021
1021
|
const: void 0
|
|
1022
1022
|
});
|
|
1023
1023
|
return n === "any" ? t : `(${t}) & (${n})`;
|
|
1024
1024
|
}
|
|
1025
|
-
if (e.nullable && e.type && !
|
|
1025
|
+
if (e.nullable && e.type && !N(e)) return `(${this.type({
|
|
1026
1026
|
...e,
|
|
1027
1027
|
nullable: !1
|
|
1028
1028
|
})}) | null`;
|
|
1029
|
-
if (
|
|
1030
|
-
let t = e.enum.filter((t) =>
|
|
1029
|
+
if (N(e)) {
|
|
1030
|
+
let t = e.enum.filter((t) => Ut(t, e)).map((e) => B(e)).join(" | ") || "never", n = this.type({
|
|
1031
1031
|
...e,
|
|
1032
1032
|
enum: void 0
|
|
1033
1033
|
});
|
|
1034
|
-
return n === "any" ||
|
|
1034
|
+
return n === "any" || Kt.has(n) ? t : `(${t}) & (${n})`;
|
|
1035
1035
|
}
|
|
1036
|
-
return
|
|
1036
|
+
return Je(e) && !e.required?.length ? this.mapType(e) : e.type === "array" ? qe(this.type(e.items ?? {})) : e.type === "object" ? this.objectType(e) : e.type ? Qe(e.type) : e.required?.length || Object.keys(e.properties ?? {}).length > 0 ? `(${this.objectType({
|
|
1037
1037
|
...e,
|
|
1038
1038
|
type: "object",
|
|
1039
1039
|
additionalProperties: e.additionalProperties ?? !0
|
|
@@ -1047,43 +1047,43 @@ var Jt = class {
|
|
|
1047
1047
|
].filter((t) => e[t]?.length);
|
|
1048
1048
|
if (t.length !== 1) return;
|
|
1049
1049
|
let [n] = t;
|
|
1050
|
-
if (Object.keys(e).filter((e) => e !== n && e !== "discriminator" && !e.startsWith("x-") && !
|
|
1051
|
-
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" ||
|
|
1052
|
-
if (!r.every((e) =>
|
|
1053
|
-
let a = r.map((t) =>
|
|
1050
|
+
if (Object.keys(e).filter((e) => e !== n && e !== "discriminator" && !e.startsWith("x-") && !qt.has(e)).length > 0) return;
|
|
1051
|
+
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" || qt.has(e));
|
|
1052
|
+
if (!r.every((e) => k(e) || i(e))) return;
|
|
1053
|
+
let a = r.map((t) => k(t) ? this.memberType(e, n, t) : "null");
|
|
1054
1054
|
return [...new Set(a)].join(n === "allOf" ? " & " : " | ");
|
|
1055
1055
|
}
|
|
1056
1056
|
memberType(e, t, n) {
|
|
1057
1057
|
let r = this.type(n), i = e.discriminator;
|
|
1058
|
-
if (t === "allOf" || !i?.propertyName || !
|
|
1059
|
-
let a =
|
|
1060
|
-
return `(${r} & { ${
|
|
1058
|
+
if (t === "allOf" || !i?.propertyName || !k(n)) return r;
|
|
1059
|
+
let a = we(n), o = Object.entries(i.mapping ?? {}).filter(([, e]) => e === n.$ref || e === a).map(([e]) => e), s = (o.length > 0 ? o : [a]).map((e) => O(e)).join(" | ");
|
|
1060
|
+
return `(${r} & { ${D(i.propertyName)}: ${s} })`;
|
|
1061
1061
|
}
|
|
1062
1062
|
};
|
|
1063
1063
|
function V(e, t) {
|
|
1064
|
-
let n = new
|
|
1064
|
+
let n = new Yt(e);
|
|
1065
1065
|
return {
|
|
1066
1066
|
text: t(n),
|
|
1067
1067
|
imports: n.imports()
|
|
1068
1068
|
};
|
|
1069
1069
|
}
|
|
1070
|
-
function
|
|
1070
|
+
function Xt(e, t) {
|
|
1071
1071
|
return V(t, (t) => t.type(e));
|
|
1072
1072
|
}
|
|
1073
|
-
function
|
|
1073
|
+
function Zt(e, t) {
|
|
1074
1074
|
return V(t, (t) => t.additionalProperties(e));
|
|
1075
1075
|
}
|
|
1076
|
-
function
|
|
1076
|
+
function Qt(e, t) {
|
|
1077
1077
|
return V(t, (t) => t.additionalPropertyType(e));
|
|
1078
1078
|
}
|
|
1079
|
-
function
|
|
1079
|
+
function $t(e, t) {
|
|
1080
1080
|
return V(t, (t) => t.requiredAdditionalPropertyType(e));
|
|
1081
1081
|
}
|
|
1082
|
-
function
|
|
1082
|
+
function en(e, t) {
|
|
1083
1083
|
return V(t, (t) => t.mapValueType(e));
|
|
1084
1084
|
}
|
|
1085
1085
|
// src/emitters/decorators.ts
|
|
1086
|
-
var
|
|
1086
|
+
var tn = "@ahoo-wang/fetcher", nn = ["ContentTypeValues", "ResultExtractors"], rn = "@ahoo-wang/fetcher-decorator", an = [
|
|
1087
1087
|
"ApiMetadata",
|
|
1088
1088
|
"ApiMetadataCapable",
|
|
1089
1089
|
"ParameterRequest",
|
|
@@ -1100,20 +1100,20 @@ var en = "@ahoo-wang/fetcher", tn = ["ContentTypeValues", "ResultExtractors"], n
|
|
|
1100
1100
|
"header",
|
|
1101
1101
|
"body",
|
|
1102
1102
|
"autoGeneratedError"
|
|
1103
|
-
],
|
|
1103
|
+
], on = {
|
|
1104
1104
|
type: "Promise<Response>",
|
|
1105
1105
|
metadata: "{resultExtractor: ResultExtractors.Response }"
|
|
1106
|
-
},
|
|
1106
|
+
}, sn = {
|
|
1107
1107
|
type: "Promise<string>",
|
|
1108
1108
|
metadata: "{resultExtractor: ResultExtractors.Text }"
|
|
1109
|
-
},
|
|
1110
|
-
function cn(e) {
|
|
1111
|
-
I(e, en, tn);
|
|
1112
|
-
}
|
|
1109
|
+
}, cn = "{\n headers: { Accept: ContentTypeValues.TEXT_EVENT_STREAM },\n resultExtractor: JsonEventStreamResultExtractor,\n}";
|
|
1113
1110
|
function ln(e) {
|
|
1114
|
-
I(e,
|
|
1111
|
+
I(e, tn, nn);
|
|
1112
|
+
}
|
|
1113
|
+
function un(e) {
|
|
1114
|
+
I(e, rn, an);
|
|
1115
1115
|
}
|
|
1116
|
-
function
|
|
1116
|
+
function dn(e, t, n = [], r = [], i) {
|
|
1117
1117
|
return t.add({
|
|
1118
1118
|
kind: o.Class,
|
|
1119
1119
|
name: e,
|
|
@@ -1126,7 +1126,7 @@ function un(e, t, n = [], r = [], i) {
|
|
|
1126
1126
|
}]
|
|
1127
1127
|
});
|
|
1128
1128
|
}
|
|
1129
|
-
function
|
|
1129
|
+
function fn(e) {
|
|
1130
1130
|
e.implements = [...[e.implements ?? []].flat(), "ApiMetadataCapable"], e.ctors ??= [], e.ctors.push({ parameters: [{
|
|
1131
1131
|
name: "apiMetadata",
|
|
1132
1132
|
type: "ApiMetadata",
|
|
@@ -1135,38 +1135,38 @@ function dn(e) {
|
|
|
1135
1135
|
isReadonly: !0
|
|
1136
1136
|
}] });
|
|
1137
1137
|
}
|
|
1138
|
-
function
|
|
1138
|
+
function pn(e) {
|
|
1139
1139
|
return e === "delete" ? "del" : e;
|
|
1140
1140
|
}
|
|
1141
|
-
var
|
|
1142
|
-
function
|
|
1143
|
-
I(e,
|
|
1141
|
+
var mn = "@ahoo-wang/fetcher-eventstream";
|
|
1142
|
+
function hn(e) {
|
|
1143
|
+
I(e, mn, ["JsonEventStreamResultExtractor", "JsonServerSentEventStream"]);
|
|
1144
1144
|
}
|
|
1145
1145
|
// src/emitters/apiClients.ts
|
|
1146
|
-
function
|
|
1146
|
+
function gn(e, t) {
|
|
1147
1147
|
let n = t.modules.module(e.file);
|
|
1148
|
-
|
|
1149
|
-
let r =
|
|
1150
|
-
R(r, [e.description]),
|
|
1151
|
-
let i =
|
|
1152
|
-
for (let t of e.methods) (r.methods ??= []).push(
|
|
1148
|
+
ln(n), un(n), hn(n);
|
|
1149
|
+
let r = dn(e.className, n);
|
|
1150
|
+
R(r, [e.description]), fn(r);
|
|
1151
|
+
let i = _n(e.className, n, t);
|
|
1152
|
+
for (let t of e.methods) (r.methods ??= []).push(vn(t, i));
|
|
1153
1153
|
}
|
|
1154
|
-
function
|
|
1154
|
+
function _n(e, t, n) {
|
|
1155
1155
|
let r = {
|
|
1156
1156
|
context: n.types,
|
|
1157
1157
|
owner: { name: e },
|
|
1158
|
-
specifierOf: (e) =>
|
|
1158
|
+
specifierOf: (e) => Dt(t, n.outputDir, e),
|
|
1159
1159
|
imports: t.imports
|
|
1160
1160
|
};
|
|
1161
1161
|
return {
|
|
1162
1162
|
module: t,
|
|
1163
1163
|
resolveType(e) {
|
|
1164
|
-
let n =
|
|
1164
|
+
let n = Xt(e, r);
|
|
1165
1165
|
return t.imports.apply(n.imports), n.text;
|
|
1166
1166
|
}
|
|
1167
1167
|
};
|
|
1168
1168
|
}
|
|
1169
|
-
function
|
|
1169
|
+
function vn(e, t) {
|
|
1170
1170
|
let n = [], r = [];
|
|
1171
1171
|
for (let i of e.parameters) (i.required ? n : r).push({
|
|
1172
1172
|
name: i.name,
|
|
@@ -1174,12 +1174,12 @@ function _n(e, t) {
|
|
|
1174
1174
|
hasQuestionToken: !i.required,
|
|
1175
1175
|
decorators: [{
|
|
1176
1176
|
name: i.location,
|
|
1177
|
-
arguments: [
|
|
1177
|
+
arguments: [O(i.parameterName)]
|
|
1178
1178
|
}]
|
|
1179
1179
|
});
|
|
1180
1180
|
e.body && (e.body.required ? n : r).push({
|
|
1181
1181
|
name: e.body.name,
|
|
1182
|
-
type:
|
|
1182
|
+
type: yn(e.body, t),
|
|
1183
1183
|
hasQuestionToken: !e.body.required,
|
|
1184
1184
|
decorators: [{
|
|
1185
1185
|
name: "body",
|
|
@@ -1207,10 +1207,10 @@ function _n(e, t) {
|
|
|
1207
1207
|
arguments: []
|
|
1208
1208
|
}]
|
|
1209
1209
|
}
|
|
1210
|
-
], a =
|
|
1210
|
+
], a = bn(e.returns, t), o = O(e.path), s = {
|
|
1211
1211
|
name: e.name,
|
|
1212
1212
|
decorators: [{
|
|
1213
|
-
name:
|
|
1213
|
+
name: pn(e.httpMethod),
|
|
1214
1214
|
arguments: a.metadata ? [o, a.metadata] : [o]
|
|
1215
1215
|
}],
|
|
1216
1216
|
parameters: i,
|
|
@@ -1219,12 +1219,12 @@ function _n(e, t) {
|
|
|
1219
1219
|
};
|
|
1220
1220
|
return R(s, [...e.docs]), s;
|
|
1221
1221
|
}
|
|
1222
|
-
function
|
|
1222
|
+
function yn(e, t) {
|
|
1223
1223
|
let { content: n } = e;
|
|
1224
1224
|
switch (n.kind) {
|
|
1225
1225
|
case "json": {
|
|
1226
1226
|
let e = t.resolveType(n.schema), r = n.optionalFields;
|
|
1227
|
-
return r.length === 0 || /[|&]/.test(e) || e === "any" ? e : (I(t.module,
|
|
1227
|
+
return r.length === 0 || /[|&]/.test(e) || e === "any" ? e : (I(t.module, tn, ["PartialBy"]), `PartialBy<${e}, ${r.map(O).join(" | ")}>`);
|
|
1228
1228
|
}
|
|
1229
1229
|
case "formData": return "FormData";
|
|
1230
1230
|
case "urlEncoded": return "URLSearchParams";
|
|
@@ -1232,49 +1232,49 @@ function vn(e, t) {
|
|
|
1232
1232
|
case "binary": return "BodyInit";
|
|
1233
1233
|
}
|
|
1234
1234
|
}
|
|
1235
|
-
function
|
|
1235
|
+
function bn(e, t) {
|
|
1236
1236
|
switch (e.kind) {
|
|
1237
1237
|
case "json": {
|
|
1238
1238
|
let n = t.resolveType(e.schema);
|
|
1239
|
-
return e.wildcard && n === "string" ?
|
|
1239
|
+
return e.wildcard && n === "string" ? sn : { type: `Promise<${n}>` };
|
|
1240
1240
|
}
|
|
1241
1241
|
case "eventStream": {
|
|
1242
1242
|
if (!e.items) return {
|
|
1243
1243
|
type: "Promise<JsonServerSentEventStream<any>>",
|
|
1244
|
-
metadata:
|
|
1244
|
+
metadata: cn
|
|
1245
1245
|
};
|
|
1246
1246
|
let n = t.resolveType(e.items);
|
|
1247
1247
|
return {
|
|
1248
1248
|
type: `Promise<JsonServerSentEventStream<${e.serverSentEvent ? `${n}['data']` : n}>>`,
|
|
1249
|
-
metadata:
|
|
1249
|
+
metadata: cn
|
|
1250
1250
|
};
|
|
1251
1251
|
}
|
|
1252
|
-
case "text": return
|
|
1253
|
-
case "response": return
|
|
1252
|
+
case "text": return sn;
|
|
1253
|
+
case "response": return on;
|
|
1254
1254
|
}
|
|
1255
1255
|
}
|
|
1256
1256
|
// src/emitters/models.ts
|
|
1257
|
-
function
|
|
1258
|
-
return
|
|
1257
|
+
function xn(e) {
|
|
1258
|
+
return Wt(e, {
|
|
1259
1259
|
ofKey: (e) => F(e),
|
|
1260
|
-
ofReference:
|
|
1260
|
+
ofReference: dt
|
|
1261
1261
|
});
|
|
1262
1262
|
}
|
|
1263
|
-
function
|
|
1264
|
-
new
|
|
1263
|
+
function Sn(e, t) {
|
|
1264
|
+
new wn(e, t.modules.module(e.file), t).write();
|
|
1265
1265
|
}
|
|
1266
|
-
function
|
|
1266
|
+
function Cn(e) {
|
|
1267
1267
|
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map();
|
|
1268
1268
|
for (let r of e) {
|
|
1269
|
-
let e =
|
|
1269
|
+
let e = fe(r), i = [e];
|
|
1270
1270
|
/^\d/.test(r) || i.push(r);
|
|
1271
1271
|
let a = i.find((e) => !t.has(e));
|
|
1272
1272
|
for (let n = 2; a === void 0; n++) t.has(`${e}_${n}`) || (a = `${e}_${n}`);
|
|
1273
|
-
t.add(a), n.set(r,
|
|
1273
|
+
t.add(a), n.set(r, D(a));
|
|
1274
1274
|
}
|
|
1275
1275
|
return n;
|
|
1276
1276
|
}
|
|
1277
|
-
var
|
|
1277
|
+
var wn = class {
|
|
1278
1278
|
model;
|
|
1279
1279
|
module;
|
|
1280
1280
|
target;
|
|
@@ -1284,29 +1284,29 @@ var Cn = class {
|
|
|
1284
1284
|
this.model = e, this.module = t, this.target = n, this.modelInfo = e.info, this.components = n.types.components, this.scope = {
|
|
1285
1285
|
context: n.types,
|
|
1286
1286
|
owner: e.info,
|
|
1287
|
-
specifierOf: (e) =>
|
|
1287
|
+
specifierOf: (e) => Dt(t, n.outputDir, e),
|
|
1288
1288
|
imports: t.imports
|
|
1289
1289
|
};
|
|
1290
1290
|
}
|
|
1291
1291
|
write() {
|
|
1292
1292
|
let e = this.process();
|
|
1293
|
-
e &&
|
|
1293
|
+
e && Mt(e, this.model.schema, this.model.key, this.target.schemaDocs === "full");
|
|
1294
1294
|
}
|
|
1295
1295
|
process() {
|
|
1296
1296
|
let { schema: e } = this.model;
|
|
1297
|
-
return
|
|
1297
|
+
return k(e) ? this.processTypeAlias(e) : N(e) ? this.processEnum(e) : e.const !== void 0 || e.nullable && e.type || P(e) && (e.type || e.properties || e.required) ? this.processTypeAlias(e) : He(e) ? this.processInterface(e) : Je(e) && typeof e.additionalProperties == "object" && !Xe(e) && !e.required?.length ? this.processIndexSignature(e) : Ue(e) ? this.processArray(e) : P(e) ? this.processComposition(e) : this.processTypeAlias(e);
|
|
1298
1298
|
}
|
|
1299
1299
|
scope;
|
|
1300
1300
|
emit(e) {
|
|
1301
1301
|
return this.module.imports.apply(e.imports), e.text;
|
|
1302
1302
|
}
|
|
1303
1303
|
resolveType(e) {
|
|
1304
|
-
return this.emit(
|
|
1304
|
+
return this.emit(Xt(e, this.scope));
|
|
1305
1305
|
}
|
|
1306
1306
|
processEnum(e) {
|
|
1307
|
-
let t =
|
|
1307
|
+
let t = Ve(e);
|
|
1308
1308
|
if (t) {
|
|
1309
|
-
let e =
|
|
1309
|
+
let e = Cn(Object.keys(t));
|
|
1310
1310
|
this.module.add({
|
|
1311
1311
|
kind: o.Enum,
|
|
1312
1312
|
name: this.modelInfo.name + "EnumText",
|
|
@@ -1317,8 +1317,8 @@ var Cn = class {
|
|
|
1317
1317
|
}))
|
|
1318
1318
|
});
|
|
1319
1319
|
}
|
|
1320
|
-
let n = [...new Set(e.enum.filter((e) => typeof e == "string"))], r =
|
|
1321
|
-
return
|
|
1320
|
+
let n = [...new Set(e.enum.filter((e) => typeof e == "string"))], r = Cn(n);
|
|
1321
|
+
return P(e) || e.const !== void 0 || e.type !== void 0 && e.type !== "string" || e.enum.some((e) => typeof e != "string") ? (n.length && this.module.add({
|
|
1322
1322
|
kind: o.VariableStatement,
|
|
1323
1323
|
declarationKind: c.Const,
|
|
1324
1324
|
isExported: !0,
|
|
@@ -1342,14 +1342,14 @@ var Cn = class {
|
|
|
1342
1342
|
}
|
|
1343
1343
|
addPropertyToInterface(e, t, n) {
|
|
1344
1344
|
let r = {
|
|
1345
|
-
name:
|
|
1345
|
+
name: D(t),
|
|
1346
1346
|
type: this.resolveType(n),
|
|
1347
|
-
isReadonly:
|
|
1347
|
+
isReadonly: Ze(n)
|
|
1348
1348
|
};
|
|
1349
|
-
(e.properties ??= []).push(r),
|
|
1349
|
+
(e.properties ??= []).push(r), jt(r, n);
|
|
1350
1350
|
}
|
|
1351
1351
|
processInterface(e) {
|
|
1352
|
-
if (
|
|
1352
|
+
if (Ht(e, this.components)) return this.processTypeAlias(e);
|
|
1353
1353
|
let t = [], n = this.module.add({
|
|
1354
1354
|
kind: o.Interface,
|
|
1355
1355
|
name: this.modelInfo.name,
|
|
@@ -1360,17 +1360,17 @@ var Cn = class {
|
|
|
1360
1360
|
this.addPropertyToInterface(n, e, t);
|
|
1361
1361
|
});
|
|
1362
1362
|
for (let n of e.required ?? []) Object.hasOwn(r, n) || t.push({
|
|
1363
|
-
name:
|
|
1364
|
-
type: this.emit(
|
|
1363
|
+
name: D(n),
|
|
1364
|
+
type: this.emit($t(e, this.scope))
|
|
1365
1365
|
});
|
|
1366
|
-
return this.emit(
|
|
1366
|
+
return this.emit(Zt(e, this.scope)) && t.push(Tt(this.emit(Qt(e, this.scope)), ["Additional properties"])), n;
|
|
1367
1367
|
}
|
|
1368
1368
|
processArray(e) {
|
|
1369
1369
|
let t = this.resolveType(e.items);
|
|
1370
1370
|
return this.module.add({
|
|
1371
1371
|
kind: o.TypeAlias,
|
|
1372
1372
|
name: this.modelInfo.name,
|
|
1373
|
-
type:
|
|
1373
|
+
type: qe(t),
|
|
1374
1374
|
isExported: !0
|
|
1375
1375
|
});
|
|
1376
1376
|
}
|
|
@@ -1379,7 +1379,7 @@ var Cn = class {
|
|
|
1379
1379
|
kind: o.Interface,
|
|
1380
1380
|
name: this.modelInfo.name,
|
|
1381
1381
|
isExported: !0,
|
|
1382
|
-
properties: [
|
|
1382
|
+
properties: [Tt(this.emit(en(e, this.scope)))]
|
|
1383
1383
|
});
|
|
1384
1384
|
}
|
|
1385
1385
|
processComposition(e) {
|
|
@@ -1400,34 +1400,34 @@ var Cn = class {
|
|
|
1400
1400
|
}
|
|
1401
1401
|
};
|
|
1402
1402
|
// src/emitters/emit.ts
|
|
1403
|
-
function
|
|
1404
|
-
e.models.forEach((e) =>
|
|
1403
|
+
function Tn(e, t) {
|
|
1404
|
+
e.models.forEach((e) => Sn(e, t)), e.apiClients.forEach((e) => gn(e, t));
|
|
1405
1405
|
}
|
|
1406
1406
|
// src/emitters/indexFiles.ts
|
|
1407
|
-
function
|
|
1407
|
+
function En(e, t) {
|
|
1408
1408
|
let n = [];
|
|
1409
|
-
return
|
|
1409
|
+
return Dn(e, t, n), n;
|
|
1410
1410
|
}
|
|
1411
|
-
function
|
|
1411
|
+
function Dn(e, t, n) {
|
|
1412
1412
|
let r = [];
|
|
1413
1413
|
for (let t of e.getSourceFiles()) {
|
|
1414
1414
|
let e = t.getBaseName();
|
|
1415
1415
|
e.endsWith(".ts") && e !== "index.ts" && r.push({
|
|
1416
1416
|
specifier: `./${t.getBaseNameWithoutExtension()}.js`,
|
|
1417
|
-
exports:
|
|
1417
|
+
exports: kn(t)
|
|
1418
1418
|
});
|
|
1419
1419
|
}
|
|
1420
1420
|
for (let i of e.getDirectories()) {
|
|
1421
|
-
let e =
|
|
1421
|
+
let e = Dn(i, t, n);
|
|
1422
1422
|
e && r.push({
|
|
1423
1423
|
specifier: `./${i.getBaseName()}/index.js`,
|
|
1424
1424
|
exports: e
|
|
1425
1425
|
});
|
|
1426
1426
|
}
|
|
1427
1427
|
let i = e.getPath();
|
|
1428
|
-
return r.length === 0 ? e.getProject().getSourceFile(`${i}/index.ts`) ? /* @__PURE__ */ new Map() : void 0 :
|
|
1428
|
+
return r.length === 0 ? e.getProject().getSourceFile(`${i}/index.ts`) ? /* @__PURE__ */ new Map() : void 0 : On(i, r, t, n);
|
|
1429
1429
|
}
|
|
1430
|
-
function
|
|
1430
|
+
function On(e, t, n, r) {
|
|
1431
1431
|
let i = /* @__PURE__ */ new Map();
|
|
1432
1432
|
for (let e of t) for (let t of e.exports.keys()) i.set(t, [...i.get(t) ?? [], e.specifier]);
|
|
1433
1433
|
let a = [...i].filter(([, e]) => e.length > 1).map(([e]) => e).sort();
|
|
@@ -1436,7 +1436,7 @@ function Dn(e, t, n, r) {
|
|
|
1436
1436
|
o.removeText();
|
|
1437
1437
|
let s = /* @__PURE__ */ new Map();
|
|
1438
1438
|
for (let e of t) {
|
|
1439
|
-
let t = [...e.exports].filter(([e]) => !a.includes(e)).sort(([e], [t]) =>
|
|
1439
|
+
let t = [...e.exports].filter(([e]) => !a.includes(e)).sort(([e], [t]) => j(e, t));
|
|
1440
1440
|
t.forEach(([e, t]) => s.set(e, t)), t.length === e.exports.size ? o.addExportDeclaration({ moduleSpecifier: e.specifier }) : t.length > 0 && o.addExportDeclaration({
|
|
1441
1441
|
moduleSpecifier: e.specifier,
|
|
1442
1442
|
namedExports: t.map(([e, t]) => ({
|
|
@@ -1447,13 +1447,13 @@ function Dn(e, t, n, r) {
|
|
|
1447
1447
|
}
|
|
1448
1448
|
return o.getStatements().length === 0 && o.addStatements("export {};"), s;
|
|
1449
1449
|
}
|
|
1450
|
-
function
|
|
1450
|
+
function kn(e) {
|
|
1451
1451
|
let t = /* @__PURE__ */ new Map();
|
|
1452
1452
|
for (let [r, i] of e.getExportedDeclarations()) t.set(r, i.every((e) => n.isInterfaceDeclaration(e) || n.isTypeAliasDeclaration(e)));
|
|
1453
1453
|
return t;
|
|
1454
1454
|
}
|
|
1455
1455
|
// src/finalize/typeOnlyImports.ts
|
|
1456
|
-
function
|
|
1456
|
+
function An(e) {
|
|
1457
1457
|
let t = e;
|
|
1458
1458
|
for (let e = t.getParent(); e; t = e, e = e.getParent()) if (n.isQualifiedName(e)) {
|
|
1459
1459
|
if (e.getLeft() !== t) return !1;
|
|
@@ -1468,22 +1468,22 @@ function kn(e) {
|
|
|
1468
1468
|
}
|
|
1469
1469
|
return !1;
|
|
1470
1470
|
}
|
|
1471
|
-
function
|
|
1471
|
+
function jn(e) {
|
|
1472
1472
|
let t = e.getImportDeclarations().filter((e) => !e.getDefaultImport() && !e.getNamespaceImport() && e.getNamedImports().length > 0);
|
|
1473
1473
|
if (t.length === 0) return [];
|
|
1474
1474
|
let r = new Set(t.flatMap((e) => e.getNamedImports().map((e) => (e.getAliasNode() ?? e.getNameNode()).getText()))), i = /* @__PURE__ */ new Set();
|
|
1475
1475
|
return e.forEachDescendant((e, t) => {
|
|
1476
1476
|
if (n.isImportDeclaration(e)) t.skip();
|
|
1477
|
-
else if (n.isIdentifier(e) && r.has(e.getText()) && !
|
|
1477
|
+
else if (n.isIdentifier(e) && r.has(e.getText()) && !An(e)) {
|
|
1478
1478
|
let t = e.getSymbol();
|
|
1479
1479
|
t && i.add(t.compilerSymbol);
|
|
1480
1480
|
}
|
|
1481
|
-
}), t.map((e) =>
|
|
1481
|
+
}), t.map((e) => Mn(e, (e) => {
|
|
1482
1482
|
let t = e.getSymbol();
|
|
1483
1483
|
return !!t && !i.has(t.compilerSymbol);
|
|
1484
1484
|
}));
|
|
1485
1485
|
}
|
|
1486
|
-
function
|
|
1486
|
+
function Mn(e, t) {
|
|
1487
1487
|
let n = e.getNamedImports(), r = n.map(t), i = r.every(Boolean);
|
|
1488
1488
|
return () => {
|
|
1489
1489
|
n.forEach((e, t) => {
|
|
@@ -1492,53 +1492,57 @@ function jn(e, t) {
|
|
|
1492
1492
|
}), e.isTypeOnly() !== i && e.setIsTypeOnly(i);
|
|
1493
1493
|
};
|
|
1494
1494
|
}
|
|
1495
|
-
function
|
|
1496
|
-
let t = e.flatMap(
|
|
1495
|
+
function Nn(e) {
|
|
1496
|
+
let t = e.flatMap(jn);
|
|
1497
1497
|
for (let e of t) e();
|
|
1498
1498
|
}
|
|
1499
1499
|
// src/finalize/verification.ts
|
|
1500
|
-
var
|
|
1500
|
+
var Pn = /* @__PURE__ */ new Set([
|
|
1501
1501
|
2300,
|
|
1502
1502
|
2304,
|
|
1503
1503
|
2308,
|
|
1504
|
+
2315,
|
|
1504
1505
|
2393,
|
|
1506
|
+
2395,
|
|
1507
|
+
2440,
|
|
1505
1508
|
2451,
|
|
1506
1509
|
2456,
|
|
1507
1510
|
2503,
|
|
1508
|
-
2552
|
|
1511
|
+
2552,
|
|
1512
|
+
2749
|
|
1509
1513
|
]);
|
|
1510
|
-
function
|
|
1514
|
+
function Fn(e) {
|
|
1511
1515
|
let t = [];
|
|
1512
1516
|
for (let n of e) for (let e of n.getPreEmitDiagnostics()) {
|
|
1513
|
-
if (!
|
|
1517
|
+
if (!Pn.has(e.getCode()) || e.getSourceFile() !== n) continue;
|
|
1514
1518
|
let r = l.flattenDiagnosticMessageText(e.compilerObject.messageText, " ");
|
|
1515
1519
|
t.push(`${n.getFilePath()}:${e.getLineNumber() ?? 0} TS${e.getCode()} ${r}`);
|
|
1516
1520
|
}
|
|
1517
1521
|
if (t.length > 0) throw Error(`The generated code does not compile; nothing was written. This is a wow-generator bug:\n${t.join("\n")}`);
|
|
1518
1522
|
}
|
|
1519
1523
|
// src/finalize/finalize.ts
|
|
1520
|
-
var
|
|
1524
|
+
var In = "// Code generated by wow-generator. DO NOT EDIT.\n\n", Ln = {
|
|
1521
1525
|
indentSize: 2,
|
|
1522
1526
|
tabSize: 2,
|
|
1523
1527
|
convertTabsToSpaces: !0,
|
|
1524
1528
|
semicolons: "insert",
|
|
1525
1529
|
insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: !0
|
|
1526
1530
|
};
|
|
1527
|
-
function
|
|
1531
|
+
function Rn(e, t) {
|
|
1528
1532
|
e.forEach((n, r) => {
|
|
1529
|
-
t.debug(`Optimizing file [${n.getFilePath()}] - ${r + 1}/${e.length}`), n.formatText(
|
|
1530
|
-
}),
|
|
1531
|
-
for (let t of e) t.insertText(0,
|
|
1533
|
+
t.debug(`Optimizing file [${n.getFilePath()}] - ${r + 1}/${e.length}`), n.formatText(Ln), n.organizeImports(Ln);
|
|
1534
|
+
}), Nn(e), Fn(e);
|
|
1535
|
+
for (let t of e) t.insertText(0, In);
|
|
1532
1536
|
}
|
|
1533
1537
|
// src/input/resources.ts
|
|
1534
|
-
var
|
|
1535
|
-
function
|
|
1538
|
+
var zn = 3e4;
|
|
1539
|
+
function Bn(e) {
|
|
1536
1540
|
return /^https?:\/\//i.test(e);
|
|
1537
1541
|
}
|
|
1538
|
-
function
|
|
1539
|
-
return
|
|
1542
|
+
function Vn(e, t = {}) {
|
|
1543
|
+
return Bn(e) ? Hn(e, t) : Wn(e);
|
|
1540
1544
|
}
|
|
1541
|
-
async function
|
|
1545
|
+
async function Hn(e, t = {}) {
|
|
1542
1546
|
let n = t.timeoutMs ?? 3e4, r;
|
|
1543
1547
|
try {
|
|
1544
1548
|
let i = AbortSignal.timeout(n);
|
|
@@ -1547,7 +1551,7 @@ async function Vn(e, t = {}) {
|
|
|
1547
1551
|
signal: t.signal ? AbortSignal.any([t.signal, i]) : i
|
|
1548
1552
|
});
|
|
1549
1553
|
} catch (e) {
|
|
1550
|
-
let t = e instanceof Error && e.name === "TimeoutError" ? `no response within ${n} ms` :
|
|
1554
|
+
let t = e instanceof Error && e.name === "TimeoutError" ? `no response within ${n} ms` : Un(e);
|
|
1551
1555
|
throw Error(t, { cause: e });
|
|
1552
1556
|
}
|
|
1553
1557
|
if (!r.ok) {
|
|
@@ -1556,12 +1560,12 @@ async function Vn(e, t = {}) {
|
|
|
1556
1560
|
}
|
|
1557
1561
|
return await r.text();
|
|
1558
1562
|
}
|
|
1559
|
-
function
|
|
1563
|
+
function Un(e) {
|
|
1560
1564
|
if (!(e instanceof Error)) return String(e);
|
|
1561
1565
|
let t = e.cause;
|
|
1562
1566
|
return t instanceof Error && t.message ? `${e.message} (${t.message})` : e.message;
|
|
1563
1567
|
}
|
|
1564
|
-
function
|
|
1568
|
+
function Wn(e) {
|
|
1565
1569
|
return new Promise((t, n) => {
|
|
1566
1570
|
g(e, "utf-8", (e, r) => {
|
|
1567
1571
|
e ? n(e) : t(r);
|
|
@@ -1569,37 +1573,37 @@ function Un(e) {
|
|
|
1569
1573
|
});
|
|
1570
1574
|
}
|
|
1571
1575
|
// src/input/parsers.ts
|
|
1572
|
-
async function
|
|
1576
|
+
async function Gn(e, t) {
|
|
1573
1577
|
let n;
|
|
1574
1578
|
try {
|
|
1575
|
-
n = await
|
|
1579
|
+
n = await Vn(e, t);
|
|
1576
1580
|
} catch (t) {
|
|
1577
|
-
throw new
|
|
1581
|
+
throw new b("input", `Cannot read the OpenAPI document ${e}: ${x(t)}`, { cause: t });
|
|
1578
1582
|
}
|
|
1579
1583
|
try {
|
|
1580
|
-
return
|
|
1584
|
+
return qn(n);
|
|
1581
1585
|
} catch (t) {
|
|
1582
|
-
throw new
|
|
1586
|
+
throw new b("input", `Cannot parse the OpenAPI document ${e}: ${x(t)}`, { cause: t });
|
|
1583
1587
|
}
|
|
1584
1588
|
}
|
|
1585
|
-
function
|
|
1586
|
-
if (typeof e != "object" || !e || Array.isArray(e)) throw new
|
|
1589
|
+
function Kn(e, t) {
|
|
1590
|
+
if (typeof e != "object" || !e || Array.isArray(e)) throw new b("input", `${t} is not an OpenAPI document: expected an object at the top level.`);
|
|
1587
1591
|
let n = e;
|
|
1588
|
-
if (n.swagger !== void 0) throw new
|
|
1589
|
-
if (typeof n.openapi != "string" || !/^3\.\d+/.test(n.openapi)) throw new
|
|
1590
|
-
if (typeof n.info != "object" || n.info === null || Array.isArray(n.info)) throw new
|
|
1592
|
+
if (n.swagger !== void 0) throw new b("input", `${t} is a Swagger ${String(n.swagger)} document; wow-generator reads OpenAPI 3.x only. Convert it first, for example with swagger2openapi.`);
|
|
1593
|
+
if (typeof n.openapi != "string" || !/^3\.\d+/.test(n.openapi)) throw new b("input", `${t} is not an OpenAPI 3.x document: its "openapi" field is ${n.openapi === void 0 ? "missing" : JSON.stringify(n.openapi)}.`);
|
|
1594
|
+
if (typeof n.info != "object" || n.info === null || Array.isArray(n.info)) throw new b("input", `${t} is not a valid OpenAPI document: its "info" object is missing.`);
|
|
1591
1595
|
return {
|
|
1592
1596
|
...n,
|
|
1593
1597
|
paths: n.paths ?? {}
|
|
1594
1598
|
};
|
|
1595
1599
|
}
|
|
1596
|
-
function
|
|
1597
|
-
switch (
|
|
1600
|
+
function qn(e) {
|
|
1601
|
+
switch (Jn(e)) {
|
|
1598
1602
|
case "json": return JSON.parse(e);
|
|
1599
1603
|
case "yaml": return h(e);
|
|
1600
1604
|
}
|
|
1601
1605
|
}
|
|
1602
|
-
function
|
|
1606
|
+
function Jn(e) {
|
|
1603
1607
|
let t = e.trimStart();
|
|
1604
1608
|
if (t.startsWith("{") || t.startsWith("[")) return "json";
|
|
1605
1609
|
if (t.startsWith("-") || t.startsWith("%YAML")) return "yaml";
|
|
@@ -1611,16 +1615,16 @@ function qn(e) {
|
|
|
1611
1615
|
throw Error("Unable to infer file format");
|
|
1612
1616
|
}
|
|
1613
1617
|
// src/input/configuration.ts
|
|
1614
|
-
async function
|
|
1618
|
+
async function Yn(e, t, n) {
|
|
1615
1619
|
if (e !== void 0) return {
|
|
1616
|
-
...await
|
|
1620
|
+
...await Qn({
|
|
1617
1621
|
path: e,
|
|
1618
1622
|
explicit: !0
|
|
1619
1623
|
}, t, n),
|
|
1620
|
-
origin:
|
|
1624
|
+
origin: $n(e)
|
|
1621
1625
|
};
|
|
1622
|
-
let r = await
|
|
1623
|
-
path:
|
|
1626
|
+
let r = await Qn({
|
|
1627
|
+
path: y,
|
|
1624
1628
|
explicit: !1
|
|
1625
1629
|
}, t, n);
|
|
1626
1630
|
return r === void 0 ? (t.debug("No configuration file found, generating with defaults"), {
|
|
@@ -1628,22 +1632,22 @@ async function Jn(e, t, n) {
|
|
|
1628
1632
|
warnings: []
|
|
1629
1633
|
}) : {
|
|
1630
1634
|
...r,
|
|
1631
|
-
origin:
|
|
1635
|
+
origin: $n(y)
|
|
1632
1636
|
};
|
|
1633
1637
|
}
|
|
1634
|
-
var
|
|
1635
|
-
async function
|
|
1636
|
-
let r =
|
|
1638
|
+
var Xn = ["apiClients"], Zn = ["ignorePathParameters", "methodNames"];
|
|
1639
|
+
async function Qn(e, t, n) {
|
|
1640
|
+
let r = $n(e.path);
|
|
1637
1641
|
t.debug(`Reading configuration: ${r}`);
|
|
1638
1642
|
let i;
|
|
1639
1643
|
try {
|
|
1640
|
-
i = await
|
|
1644
|
+
i = await Vn(e.path, n);
|
|
1641
1645
|
} catch (n) {
|
|
1642
|
-
if (!e.explicit &&
|
|
1646
|
+
if (!e.explicit && er(n)) {
|
|
1643
1647
|
t.debug(`No configuration file at ${r}`);
|
|
1644
1648
|
return;
|
|
1645
1649
|
}
|
|
1646
|
-
throw new
|
|
1650
|
+
throw new b("configuration", `Cannot read configuration ${r}: ${x(n)}`, { cause: n });
|
|
1647
1651
|
}
|
|
1648
1652
|
if (!i.trim()) return {
|
|
1649
1653
|
config: {},
|
|
@@ -1651,17 +1655,17 @@ async function Zn(e, t, n) {
|
|
|
1651
1655
|
};
|
|
1652
1656
|
let a;
|
|
1653
1657
|
try {
|
|
1654
|
-
a =
|
|
1658
|
+
a = qn(i);
|
|
1655
1659
|
} catch (e) {
|
|
1656
|
-
throw new
|
|
1660
|
+
throw new b("configuration", `Cannot parse configuration ${r}: ${x(e)}`, { cause: e });
|
|
1657
1661
|
}
|
|
1658
|
-
let o =
|
|
1659
|
-
return t.debug(`Configuration loaded from ${r}: ${
|
|
1660
|
-
}
|
|
1661
|
-
function Qn(e) {
|
|
1662
|
-
return zn(e) || u(e) ? e : p(e);
|
|
1662
|
+
let o = nr(a, r);
|
|
1663
|
+
return t.debug(`Configuration loaded from ${r}: ${ir(o.config)}`), o;
|
|
1663
1664
|
}
|
|
1664
1665
|
function $n(e) {
|
|
1666
|
+
return Bn(e) || u(e) ? e : p(e);
|
|
1667
|
+
}
|
|
1668
|
+
function er(e) {
|
|
1665
1669
|
return typeof e == "object" && !!e && e.code === "ENOENT";
|
|
1666
1670
|
}
|
|
1667
1671
|
function H(e) {
|
|
@@ -1670,43 +1674,43 @@ function H(e) {
|
|
|
1670
1674
|
function U(e) {
|
|
1671
1675
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
1672
1676
|
}
|
|
1673
|
-
function
|
|
1677
|
+
function tr(e, t, n, r, i) {
|
|
1674
1678
|
let a = Object.keys(r).filter((e) => !i.includes(e));
|
|
1675
1679
|
a.length && e.push(`Ignoring unknown ${n} option(s) in ${t}: ${a.join(", ")}. Known option(s): ${i.join(", ")}`);
|
|
1676
1680
|
}
|
|
1677
|
-
function
|
|
1678
|
-
if (!U(e)) throw new
|
|
1681
|
+
function nr(e, t) {
|
|
1682
|
+
if (!U(e)) throw new b("configuration", `Configuration ${t} must be a JSON or YAML object, found ${H(e)}`);
|
|
1679
1683
|
let n = [];
|
|
1680
|
-
return
|
|
1684
|
+
return tr(n, t, "configuration", e, Xn), rr(e.apiClients, t, n), {
|
|
1681
1685
|
config: e,
|
|
1682
1686
|
warnings: n
|
|
1683
1687
|
};
|
|
1684
1688
|
}
|
|
1685
|
-
function
|
|
1689
|
+
function rr(e, t, n) {
|
|
1686
1690
|
if (e !== void 0) {
|
|
1687
|
-
if (!U(e)) throw new
|
|
1691
|
+
if (!U(e)) throw new b("configuration", `apiClients in ${t} must be an object keyed by tag name, found ${H(e)}`);
|
|
1688
1692
|
for (let [r, i] of Object.entries(e)) {
|
|
1689
|
-
if (!U(i)) throw new
|
|
1690
|
-
|
|
1693
|
+
if (!U(i)) throw new b("configuration", `apiClients["${r}"] in ${t} must be an object, found ${H(i)}`);
|
|
1694
|
+
tr(n, t, `apiClients["${r}"]`, i, Zn);
|
|
1691
1695
|
let { ignorePathParameters: e } = i;
|
|
1692
|
-
if (e !== void 0 && !(Array.isArray(e) && e.every((e) => typeof e == "string"))) throw new
|
|
1696
|
+
if (e !== void 0 && !(Array.isArray(e) && e.every((e) => typeof e == "string"))) throw new b("configuration", `apiClients["${r}"].ignorePathParameters in ${t} must be an array of strings, found ${H(e)}`);
|
|
1693
1697
|
let { methodNames: a } = i;
|
|
1694
1698
|
if (a !== void 0) {
|
|
1695
|
-
if (!U(a)) throw new
|
|
1696
|
-
for (let [e, n] of Object.entries(a)) if (typeof n != "string" || !
|
|
1699
|
+
if (!U(a)) throw new b("configuration", `apiClients["${r}"].methodNames in ${t} must be an object mapping operationIds to method names, found ${H(a)}`);
|
|
1700
|
+
for (let [e, n] of Object.entries(a)) if (typeof n != "string" || !S(n)) throw new b("configuration", `apiClients["${r}"].methodNames["${e}"] in ${t} must be a valid method name, found ${JSON.stringify(n)}`);
|
|
1697
1701
|
}
|
|
1698
1702
|
}
|
|
1699
1703
|
}
|
|
1700
1704
|
}
|
|
1701
|
-
function
|
|
1705
|
+
function ir(e) {
|
|
1702
1706
|
let t = Object.keys(e.apiClients ?? {});
|
|
1703
1707
|
return `apiClients=${t.length ? t.join(", ") : "none"}`;
|
|
1704
1708
|
}
|
|
1705
|
-
var
|
|
1709
|
+
var ar = /* @__PURE__ */ new Set(), or = "#/$defs/";
|
|
1706
1710
|
function W(e) {
|
|
1707
|
-
return e.startsWith(
|
|
1711
|
+
return e.startsWith(or) ? e.slice(8) : void 0;
|
|
1708
1712
|
}
|
|
1709
|
-
function
|
|
1713
|
+
function sr(e) {
|
|
1710
1714
|
if (typeof e != "object" || !e) return !1;
|
|
1711
1715
|
let t = e;
|
|
1712
1716
|
return t.openapi === void 0 && t.swagger === void 0 && typeof t.format == "number" && Array.isArray(t.contexts);
|
|
@@ -1714,11 +1718,11 @@ function or(e) {
|
|
|
1714
1718
|
function G(e) {
|
|
1715
1719
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
1716
1720
|
}
|
|
1717
|
-
function
|
|
1721
|
+
function cr(e, t) {
|
|
1718
1722
|
let n = e;
|
|
1719
|
-
if (n.format !== 1) throw new
|
|
1720
|
-
let r = (n.requires ?? []).filter((e) => !
|
|
1721
|
-
if (r.length > 0) throw new
|
|
1723
|
+
if (n.format !== 1) throw new b("input", `${t} is a Wow Manifest of format ${n.format}; wow-generator reads format 1.`);
|
|
1724
|
+
let r = (n.requires ?? []).filter((e) => !ar.has(e));
|
|
1725
|
+
if (r.length > 0) throw new b("input", `${t} requires ${r.join(", ")}, which this wow-generator does not understand: generate with a newer one.`);
|
|
1722
1726
|
let i = [];
|
|
1723
1727
|
if (n.contexts.forEach((e, t) => {
|
|
1724
1728
|
!G(e) || typeof e.name != "string" ? i.push(`contexts[${t}] has no name`) : (e.aggregates ?? []).forEach((t, n) => {
|
|
@@ -1729,40 +1733,457 @@ function sr(e, t) {
|
|
|
1729
1733
|
(typeof n?.name != "string" || typeof n.schema != "string") && i.push(`an event of ${e.name}.${t.name} has no name or schema`);
|
|
1730
1734
|
}));
|
|
1731
1735
|
});
|
|
1732
|
-
}), n.$defs !== void 0 && !G(n.$defs) && i.push("$defs is not an object"), i.length > 0) throw new
|
|
1736
|
+
}), n.$defs !== void 0 && !G(n.$defs) && i.push("$defs is not an object"), i.length > 0) throw new b("specification", `${t} is not a Manifest wow-generator can read: ${i.join("; ")}.`);
|
|
1733
1737
|
return n;
|
|
1734
1738
|
}
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
"
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1739
|
+
function K(e) {
|
|
1740
|
+
let t = e.type;
|
|
1741
|
+
return typeof t == "string" ? [t] : Array.isArray(t) ? t.filter((e) => typeof e == "string") : [];
|
|
1742
|
+
}
|
|
1743
|
+
// src/manifest/names.ts
|
|
1744
|
+
var lr = [
|
|
1745
|
+
"Omit",
|
|
1746
|
+
"Promise",
|
|
1747
|
+
"Record"
|
|
1748
|
+
], ur = [
|
|
1749
|
+
"CommandClient",
|
|
1750
|
+
"CommandOptions",
|
|
1751
|
+
"CommandResult",
|
|
1752
|
+
"CommandResultStream",
|
|
1753
|
+
"CommittedEvent",
|
|
1754
|
+
"CreateCommandOptions",
|
|
1755
|
+
"EventQueryClient",
|
|
1756
|
+
"Hop",
|
|
1757
|
+
"LifecycleCommands",
|
|
1758
|
+
"MANIFEST_FORMAT",
|
|
1759
|
+
"NoAccess",
|
|
1760
|
+
"OwnStateClient",
|
|
1761
|
+
"RequestOptions",
|
|
1762
|
+
"RoutingManifest",
|
|
1763
|
+
"ServiceRoutes",
|
|
1764
|
+
"SnapshotQueryClient",
|
|
1765
|
+
"StateClient",
|
|
1766
|
+
"SystemEvent",
|
|
1767
|
+
"WowClientOptions"
|
|
1768
|
+
], dr = [
|
|
1769
|
+
"Client",
|
|
1770
|
+
"Contract",
|
|
1771
|
+
"ErrorCode",
|
|
1772
|
+
"Manifest",
|
|
1773
|
+
"Routes",
|
|
1774
|
+
"Subscription"
|
|
1775
|
+
], fr = [
|
|
1776
|
+
"Access",
|
|
1777
|
+
"Aggregate",
|
|
1778
|
+
"CommandClient",
|
|
1779
|
+
"Event",
|
|
1780
|
+
"EventQueryClient",
|
|
1781
|
+
"SnapshotQueryClient",
|
|
1782
|
+
"StateClient",
|
|
1783
|
+
"StateField"
|
|
1784
|
+
];
|
|
1785
|
+
function pr(e) {
|
|
1786
|
+
return C(w(e.name));
|
|
1787
|
+
}
|
|
1788
|
+
function mr(e) {
|
|
1789
|
+
return C(w(e.name));
|
|
1790
|
+
}
|
|
1791
|
+
function hr(e) {
|
|
1792
|
+
let t = /* @__PURE__ */ new Set([...lr, ...ur]);
|
|
1793
|
+
for (let n of e.contexts) {
|
|
1794
|
+
let e = pr(n);
|
|
1795
|
+
for (let n of dr) t.add(`${e}${n}`);
|
|
1796
|
+
for (let e of n.aggregates ?? []) {
|
|
1797
|
+
let n = mr(e);
|
|
1798
|
+
for (let e of fr) t.add(`${n}${e}`);
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
return t;
|
|
1802
|
+
}
|
|
1803
|
+
function gr() {
|
|
1804
|
+
return /* @__PURE__ */ new Set([
|
|
1805
|
+
"body",
|
|
1806
|
+
"query",
|
|
1807
|
+
"options"
|
|
1808
|
+
]);
|
|
1809
|
+
}
|
|
1810
|
+
function _r(e, t) {
|
|
1811
|
+
return e.in === "path" ? pe(e.name, t) : e.name;
|
|
1812
|
+
}
|
|
1813
|
+
// src/manifest/aggregates.ts
|
|
1814
|
+
var vr = {
|
|
1815
|
+
string: "string",
|
|
1816
|
+
integer: "string",
|
|
1817
|
+
boolean: "boolean"
|
|
1818
|
+
};
|
|
1819
|
+
function yr(e) {
|
|
1820
|
+
return (e.access ?? []).map((e) => ({
|
|
1821
|
+
name: e.name,
|
|
1822
|
+
type: vr[e.type] ?? "string | number | boolean",
|
|
1823
|
+
multiple: e.multiple ?? !1,
|
|
1824
|
+
integer: e.type === "integer"
|
|
1825
|
+
}));
|
|
1826
|
+
}
|
|
1827
|
+
var br = {
|
|
1741
1828
|
"wow.lifecycle.TransferOwner": "TransferOwner",
|
|
1742
|
-
"wow.lifecycle.TransferSpace": "TransferSpace"
|
|
1743
|
-
|
|
1744
|
-
}, ur = /* @__PURE__ */ new Set([
|
|
1829
|
+
"wow.lifecycle.TransferSpace": "TransferSpace"
|
|
1830
|
+
}, xr = /* @__PURE__ */ new Set([
|
|
1745
1831
|
"wow.lifecycle.DeleteAggregate",
|
|
1746
1832
|
"wow.lifecycle.RestoreAggregate",
|
|
1747
1833
|
"wow.lifecycle.TransferOwner",
|
|
1748
|
-
"wow.lifecycle.TransferSpace"
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1834
|
+
"wow.lifecycle.TransferSpace"
|
|
1835
|
+
]);
|
|
1836
|
+
function Sr(e, t, n) {
|
|
1837
|
+
if (t === void 0) return !0;
|
|
1838
|
+
let r = e.resolve(t);
|
|
1839
|
+
return !Array.isArray(r.required) || r.required.every((e) => e === n);
|
|
1753
1840
|
}
|
|
1754
|
-
function
|
|
1755
|
-
|
|
1756
|
-
|
|
1841
|
+
function Cr(e, t, n) {
|
|
1842
|
+
if (t === void 0) return !1;
|
|
1843
|
+
let r = e.resolve(t).properties, i = G(r) ? r[n] : void 0;
|
|
1844
|
+
return G(i) && i.readOnly === !0;
|
|
1845
|
+
}
|
|
1846
|
+
function wr(e) {
|
|
1847
|
+
return (e.commands ?? []).filter((e) => e.system !== !0 && e.internal !== !0);
|
|
1848
|
+
}
|
|
1849
|
+
function Tr(e) {
|
|
1850
|
+
return (e.commands ?? []).filter((e) => e.system === !0 && e.name.startsWith("wow.lifecycle."));
|
|
1851
|
+
}
|
|
1852
|
+
function Er(e, t) {
|
|
1853
|
+
return [
|
|
1854
|
+
t.state.schema,
|
|
1855
|
+
...wr(t).map((e) => e.schema),
|
|
1856
|
+
...(t.events ?? []).map((e) => e.schema)
|
|
1857
|
+
].map(W).filter((e) => e !== void 0).concat(Dr(e, t));
|
|
1858
|
+
}
|
|
1859
|
+
function Dr(e, t) {
|
|
1860
|
+
return Tr(t).map((e) => e.name).filter((t) => br[t] !== void 0 && e.schemaOf(t));
|
|
1861
|
+
}
|
|
1862
|
+
function Or(e) {
|
|
1863
|
+
return (e.routes ?? []).map((e) => ({
|
|
1864
|
+
method: e.method,
|
|
1865
|
+
path: e.path
|
|
1866
|
+
}));
|
|
1867
|
+
}
|
|
1868
|
+
function kr(e, t, n) {
|
|
1869
|
+
let r = W(t);
|
|
1870
|
+
return r === void 0 ? "unknown" : e.refType(r, n);
|
|
1871
|
+
}
|
|
1872
|
+
function Ar(e, t, n, r) {
|
|
1873
|
+
let i = `${n.name}.${r.name}`, a = mr(r), o = r.idSource ?? "assigned", s = o === "owner", c = new Set(Dr(e, r)), l = Tr(r).filter((e) => xr.has(e.name)).map((t) => {
|
|
1874
|
+
let n = t.name, r = n.split(".").pop(), a = e.schemaOf(n)?.description, o = se(T(r)), l = s && (t.routes ?? []).some((e) => !e.path.includes("{id}"));
|
|
1875
|
+
return {
|
|
1876
|
+
name: n,
|
|
1877
|
+
member: E(r),
|
|
1878
|
+
method: o,
|
|
1879
|
+
routes: Or(t),
|
|
1880
|
+
...l ? { ownMethod: `${o}Own` } : {},
|
|
1881
|
+
...c.has(n) ? {
|
|
1882
|
+
bodyType: e.refType(n, i),
|
|
1883
|
+
bodyGenerated: !0
|
|
1884
|
+
} : br[n] ? { bodyType: br[n] } : {},
|
|
1885
|
+
...typeof a == "string" ? { description: a } : {}
|
|
1886
|
+
};
|
|
1887
|
+
}), u = new Set(l.flatMap((e) => [e.method, e.ownMethod ?? e.method])), d = wr(r).map((n) => {
|
|
1888
|
+
let r = se(T(n.name));
|
|
1889
|
+
(u.has(r) || r === "gateway") && (r = `${r}Command`), u.add(r);
|
|
1890
|
+
let a = (n.routes ?? []).filter((e) => e.method === "POST"), o = a.find((e) => e.path.includes("{id}")), c = a.find((e) => !e.path.includes("{id}")), l;
|
|
1891
|
+
s && o && c && !(n.mounted ?? !1) && (l = `${r}Own`, u.has(l) && (l = `${l}Command`), u.add(l));
|
|
1892
|
+
let d = W(n.schema), f = d === void 0 ? void 0 : e.schemaOf(d), p = n.idProperty, m = p !== void 0 && Cr(e, f, p);
|
|
1893
|
+
return {
|
|
1894
|
+
name: n.name,
|
|
1895
|
+
method: r,
|
|
1896
|
+
routes: Or(n),
|
|
1897
|
+
...o ? { byIdPath: { path: o.path } } : {},
|
|
1898
|
+
...c ? { unaddressedPath: { path: c.path } } : {},
|
|
1899
|
+
...l === void 0 ? {} : { ownMethod: l },
|
|
1900
|
+
bodyType: kr(e, n.schema, `${i}.${n.name}`),
|
|
1901
|
+
bodyOptional: Sr(e, f, m ? p : void 0),
|
|
1902
|
+
...p === void 0 ? {} : { idProperty: p },
|
|
1903
|
+
...m ? { idComputed: m } : {},
|
|
1904
|
+
creation: n.creation ?? "none",
|
|
1905
|
+
mounted: n.mounted ?? !1,
|
|
1906
|
+
produces: n.produces ?? [],
|
|
1907
|
+
...n.description ? { description: n.description } : {},
|
|
1908
|
+
...t.marks({ $ref: n.schema }, n.schema) === void 0 ? {} : { bodyNumbers: !0 }
|
|
1909
|
+
};
|
|
1910
|
+
}), f = t.marks({ $ref: r.state.schema }, r.state.schema), p = Object.fromEntries((r.events ?? []).flatMap((e) => {
|
|
1911
|
+
let i = t.marks({ $ref: e.schema }, e.schema);
|
|
1912
|
+
return i === void 0 ? [] : [[jr(n, r, e.name), i]];
|
|
1913
|
+
})), m = Object.fromEntries(wr(r).flatMap((e) => {
|
|
1914
|
+
let n = t.marks({ $ref: e.schema }, e.schema);
|
|
1915
|
+
return n === void 0 ? [] : [[e.name, n]];
|
|
1916
|
+
})), h = yr(r), g = Object.fromEntries(h.filter((e) => e.integer).map((e) => [e.name, !e.multiple || { members: { "*": !0 } }])), _ = {
|
|
1917
|
+
...f === void 0 ? {} : { state: f },
|
|
1918
|
+
...Object.keys(p).length === 0 ? {} : { events: p },
|
|
1919
|
+
...Object.keys(m).length === 0 ? {} : { commands: m },
|
|
1920
|
+
...Object.keys(g).length === 0 ? {} : { access: { members: g } }
|
|
1921
|
+
}, v = W(r.state.schema), y = v === void 0 ? void 0 : e.schemaOf(v);
|
|
1922
|
+
return {
|
|
1923
|
+
context: n.name,
|
|
1924
|
+
name: r.name,
|
|
1925
|
+
...r.description ? { description: r.description } : {},
|
|
1926
|
+
typeName: a,
|
|
1927
|
+
directory: `${n.name}/${r.name}`,
|
|
1928
|
+
ownership: r.ownership ?? "owner",
|
|
1929
|
+
idSource: o,
|
|
1930
|
+
snapshot: r.snapshot?.enabled ?? !0,
|
|
1931
|
+
stateType: kr(e, r.state.schema, `${i} state`),
|
|
1932
|
+
stateFields: y === void 0 ? [] : e.fields({ $ref: r.state.schema }, "state"),
|
|
1933
|
+
commands: d,
|
|
1934
|
+
events: (r.events ?? []).map((t) => ({
|
|
1935
|
+
name: t.name,
|
|
1936
|
+
wireName: jr(n, r, t.name),
|
|
1937
|
+
revision: t.revision ?? 1,
|
|
1938
|
+
type: kr(e, t.schema, `${i}.${t.name}`)
|
|
1939
|
+
})),
|
|
1940
|
+
lifecycle: l,
|
|
1941
|
+
queryModels: (r.queries ?? []).map((e) => e.model),
|
|
1942
|
+
access: h,
|
|
1943
|
+
...Object.keys(_).length === 0 ? {} : { textNumbers: _ }
|
|
1944
|
+
};
|
|
1757
1945
|
}
|
|
1758
|
-
function
|
|
1946
|
+
function jr(e, t, n) {
|
|
1947
|
+
return n.includes(".") ? n : `${e.name}.${t.name}.${n}`;
|
|
1948
|
+
}
|
|
1949
|
+
// src/manifest/textNumbers.ts
|
|
1950
|
+
var Mr = /* @__PURE__ */ new Set([
|
|
1951
|
+
"int64",
|
|
1952
|
+
"bigint",
|
|
1953
|
+
"decimal"
|
|
1954
|
+
]), q = class {
|
|
1955
|
+
path;
|
|
1956
|
+
detail;
|
|
1957
|
+
constructor(e, t) {
|
|
1958
|
+
this.path = e, this.detail = t;
|
|
1959
|
+
}
|
|
1960
|
+
}, Nr = class {
|
|
1961
|
+
defs;
|
|
1962
|
+
constantOf;
|
|
1963
|
+
shapes = /* @__PURE__ */ new Map();
|
|
1964
|
+
reading = /* @__PURE__ */ new Set();
|
|
1965
|
+
lazy = /* @__PURE__ */ new Map();
|
|
1966
|
+
setAside = [];
|
|
1967
|
+
variants = /* @__PURE__ */ new Map();
|
|
1968
|
+
constructor(e, t) {
|
|
1969
|
+
this.defs = e, this.constantOf = t;
|
|
1970
|
+
}
|
|
1971
|
+
marks(e, t) {
|
|
1972
|
+
let n = this.shape(e, t);
|
|
1973
|
+
return this.settle(), this.toMarks(n);
|
|
1974
|
+
}
|
|
1975
|
+
settle() {
|
|
1976
|
+
for (let { where: e, name: t, index: n, shape: r } of this.setAside.splice(0)) if (this.exact(r, /* @__PURE__ */ new Set())) throw new b("specification", `The alternatives of ${e} are told apart by their \`${t}\`, but alternative ${n + 1} has none and holds exact numbers no reader could choose by it. Give it a \`${t}\` too, or take it out of the union.`);
|
|
1977
|
+
}
|
|
1978
|
+
declarations() {
|
|
1979
|
+
let e = /* @__PURE__ */ new Map();
|
|
1980
|
+
for (; e.size < this.lazy.size;) for (let [t, n] of [...this.lazy]) {
|
|
1981
|
+
if (e.has(t)) continue;
|
|
1982
|
+
let r = this.variants.get(t);
|
|
1983
|
+
e.set(t, {
|
|
1984
|
+
key: r?.key ?? t,
|
|
1985
|
+
...r === void 0 ? {} : { beside: !0 },
|
|
1986
|
+
...n,
|
|
1987
|
+
marks: this.toMarks(r?.shape ?? this.shapes.get(t))
|
|
1988
|
+
});
|
|
1989
|
+
}
|
|
1990
|
+
return [...e.values()].sort((e, t) => e.name < t.name ? -1 : +(e.name > t.name));
|
|
1991
|
+
}
|
|
1992
|
+
shape(e, t) {
|
|
1993
|
+
if (!G(e)) return;
|
|
1994
|
+
if (typeof e.$ref == "string") {
|
|
1995
|
+
let t = W(e.$ref);
|
|
1996
|
+
return t === void 0 ? void 0 : this.shapeOf(t);
|
|
1997
|
+
}
|
|
1998
|
+
let n = [], r = K(e).find((e) => e === "number" || e === "integer");
|
|
1999
|
+
if (r !== void 0) {
|
|
2000
|
+
let t = typeof e.format == "string" ? e.format : "";
|
|
2001
|
+
n.push({ number: {
|
|
2002
|
+
exact: Mr.has(t),
|
|
2003
|
+
format: t || r
|
|
2004
|
+
} });
|
|
2005
|
+
}
|
|
2006
|
+
let i = {};
|
|
2007
|
+
if (G(e.properties)) for (let [n, r] of Object.entries(e.properties)) {
|
|
2008
|
+
let e = this.shape(r, `${t}.${n}`);
|
|
2009
|
+
e !== void 0 && (i[n] = e);
|
|
2010
|
+
}
|
|
2011
|
+
let a = J([this.shape(e.items, `${t}.*`), this.shape(e.additionalProperties, `${t}.*`)]);
|
|
2012
|
+
a !== void 0 && (i["*"] = a), Object.keys(i).length > 0 && n.push({ members: i });
|
|
2013
|
+
for (let r of ["oneOf", "anyOf"]) {
|
|
2014
|
+
let i = e[r];
|
|
2015
|
+
Array.isArray(i) && n.push(this.either(i, t));
|
|
2016
|
+
}
|
|
2017
|
+
return Array.isArray(e.allOf) && n.push(...e.allOf.map((e) => this.shape(e, t))), J(n);
|
|
2018
|
+
}
|
|
2019
|
+
shapeOf(e) {
|
|
2020
|
+
if (this.reading.has(e)) return { ref: e };
|
|
2021
|
+
if (this.shapes.has(e)) return this.shapes.get(e);
|
|
2022
|
+
let t = this.defs[e];
|
|
2023
|
+
if (!G(t)) return;
|
|
2024
|
+
this.reading.add(e);
|
|
2025
|
+
let n = this.shape(t, e);
|
|
2026
|
+
return this.reading.delete(e), this.shapes.set(e, n), n;
|
|
2027
|
+
}
|
|
2028
|
+
either(e, t) {
|
|
2029
|
+
let n = e.map((e) => this.shape(e, t));
|
|
2030
|
+
try {
|
|
2031
|
+
return n.reduce((e, t) => this.merge(e, t, ""), void 0);
|
|
2032
|
+
} catch (r) {
|
|
2033
|
+
if (!(r instanceof q)) throw r;
|
|
2034
|
+
let i = this.discriminant(e);
|
|
2035
|
+
if (i === void 0) throw new b("specification", `The alternatives of ${t} disagree at ${r.path || "their root"}: ${r.detail}, and no member with a constant value tells them apart. Give the alternatives a discriminator (@JsonTypeInfo with @JsonSubTypes), or the same number format.`);
|
|
2036
|
+
let a = {}, o;
|
|
2037
|
+
return e.forEach((e, r) => {
|
|
2038
|
+
let s = this.constant(e, i), c = n[r];
|
|
2039
|
+
s === void 0 ? (c !== void 0 && this.setAside.push({
|
|
2040
|
+
where: t,
|
|
2041
|
+
name: i,
|
|
2042
|
+
index: r,
|
|
2043
|
+
shape: {
|
|
2044
|
+
...c,
|
|
2045
|
+
number: void 0
|
|
2046
|
+
}
|
|
2047
|
+
}), o = this.merge(o, c, "")) : c !== void 0 && (a[s] = c);
|
|
2048
|
+
}), J([o?.number ? { number: o.number } : void 0, { by: {
|
|
2049
|
+
name: i,
|
|
2050
|
+
cases: a
|
|
2051
|
+
} }]);
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
discriminant(e) {
|
|
2055
|
+
let t = e.map((e) => this.properties(e, /* @__PURE__ */ new Set())).filter((e) => Object.keys(e).length > 0);
|
|
2056
|
+
if (!(t.length < 2)) return Object.keys(t[0]).sort().find((e) => {
|
|
2057
|
+
let n = t.map((t) => Fr(t[e]));
|
|
2058
|
+
return n.every((e) => e !== void 0) && new Set(n).size === n.length;
|
|
2059
|
+
});
|
|
2060
|
+
}
|
|
2061
|
+
constant(e, t) {
|
|
2062
|
+
return Fr(this.properties(e, /* @__PURE__ */ new Set())[t]);
|
|
2063
|
+
}
|
|
2064
|
+
properties(e, t) {
|
|
2065
|
+
if (!G(e)) return {};
|
|
2066
|
+
if (typeof e.$ref == "string") {
|
|
2067
|
+
let n = W(e.$ref);
|
|
2068
|
+
return n === void 0 || t.has(n) ? {} : this.properties(this.defs[n], /* @__PURE__ */ new Set([...t, n]));
|
|
2069
|
+
}
|
|
2070
|
+
return Object.assign({}, ...(Array.isArray(e.allOf) ? e.allOf : []).map((e) => this.properties(e, t)), G(e.properties) ? e.properties : {});
|
|
2071
|
+
}
|
|
2072
|
+
merge(e, t, n) {
|
|
2073
|
+
if (e === void 0) return t;
|
|
2074
|
+
if (t === void 0 || e.ref !== void 0 && e.ref === t.ref && e.beside === void 0 && t.beside === void 0) return e;
|
|
2075
|
+
if (e.ref !== void 0 || t.ref !== void 0) return this.merge(this.expand(e), this.expand(t), n);
|
|
2076
|
+
if (e.by !== void 0 || t.by !== void 0) throw new q(n, "one is an object told apart by a member, another is not");
|
|
2077
|
+
let r = e.number ?? t.number;
|
|
2078
|
+
if (e.number && t.number && e.number.exact !== t.number.exact) {
|
|
2079
|
+
let [r, i] = e.number.exact ? [e.number, t.number] : [t.number, e.number];
|
|
2080
|
+
throw new q(n, `one is \`${r.format}\`, read as its exact text, another \`${i.format}\`, read as a number`);
|
|
2081
|
+
}
|
|
2082
|
+
e.number?.exact && (r = e.number);
|
|
2083
|
+
let i = { ...e.members };
|
|
2084
|
+
for (let [e, r] of Object.entries(t.members ?? {})) i[e] = this.merge(i[e], r, n === "" ? e : `${n}.${e}`);
|
|
2085
|
+
return {
|
|
2086
|
+
...r === void 0 ? {} : { number: r },
|
|
2087
|
+
...Object.keys(i).length === 0 ? {} : { members: i }
|
|
2088
|
+
};
|
|
2089
|
+
}
|
|
2090
|
+
expand(e) {
|
|
2091
|
+
if (e.ref === void 0) return e;
|
|
2092
|
+
if (this.shapes.has(e.ref)) return J([this.shapes.get(e.ref), e.beside]);
|
|
2093
|
+
throw new q("", `one is \`${e.ref}\`, a recursive type not yet read, another is not`);
|
|
2094
|
+
}
|
|
2095
|
+
toMarks(e) {
|
|
2096
|
+
if (e === void 0) return;
|
|
2097
|
+
if (e.ref !== void 0) {
|
|
2098
|
+
let t = e.ref, n = this.exact(e.beside, /* @__PURE__ */ new Set());
|
|
2099
|
+
if (!n && !this.exact({ ref: t }, /* @__PURE__ */ new Set())) return;
|
|
2100
|
+
let r = n ? `${t} ${JSON.stringify(e.beside)}` : t, i = this.lazy.get(r);
|
|
2101
|
+
if (i === void 0) {
|
|
2102
|
+
if (i = this.constantOf(t), n) {
|
|
2103
|
+
let n = [...this.variants.values()].filter((e) => e.key === t).length;
|
|
2104
|
+
i = {
|
|
2105
|
+
...i,
|
|
2106
|
+
name: `${i.name}${n + 2}`
|
|
2107
|
+
}, this.variants.set(r, {
|
|
2108
|
+
key: t,
|
|
2109
|
+
shape: J([this.shapes.get(t), e.beside])
|
|
2110
|
+
});
|
|
2111
|
+
}
|
|
2112
|
+
this.lazy.set(r, i);
|
|
2113
|
+
}
|
|
2114
|
+
return { lazy: i };
|
|
2115
|
+
}
|
|
2116
|
+
let t;
|
|
2117
|
+
if (e.by !== void 0) {
|
|
2118
|
+
let n = Pr(e.by.cases, (e) => this.toMarks(e));
|
|
2119
|
+
t = n === void 0 ? void 0 : {
|
|
2120
|
+
by: e.by.name,
|
|
2121
|
+
cases: n
|
|
2122
|
+
};
|
|
2123
|
+
} else if (e.members !== void 0) {
|
|
2124
|
+
let n = Pr(e.members, (e) => this.toMarks(e));
|
|
2125
|
+
t = n === void 0 ? void 0 : { members: n };
|
|
2126
|
+
}
|
|
2127
|
+
return e.number?.exact ? t === void 0 || { or: t } : t;
|
|
2128
|
+
}
|
|
2129
|
+
exact(e, t) {
|
|
2130
|
+
return e === void 0 ? !1 : e.ref === void 0 ? e.number?.exact === !0 || Object.values(e.members ?? {}).some((e) => this.exact(e, t)) || Object.values(e.by?.cases ?? {}).some((e) => this.exact(e, t)) : this.exact(e.beside, t) ? !0 : !t.has(e.ref) && (t.add(e.ref), this.exact(this.shapes.get(e.ref), t));
|
|
2131
|
+
}
|
|
2132
|
+
};
|
|
2133
|
+
function J(e) {
|
|
2134
|
+
return e.reduce((e, t) => {
|
|
2135
|
+
if (e === void 0) return t;
|
|
2136
|
+
if (t === void 0) return e;
|
|
2137
|
+
if (e.ref !== void 0 || t.ref !== void 0) {
|
|
2138
|
+
let [n, r] = e.ref === void 0 ? [t, e] : [e, t];
|
|
2139
|
+
return {
|
|
2140
|
+
ref: n.ref,
|
|
2141
|
+
beside: J([n.beside, r])
|
|
2142
|
+
};
|
|
2143
|
+
}
|
|
2144
|
+
let n = e.number?.exact || t.number === void 0 ? e.number ?? t.number : t.number, r = { ...e.members };
|
|
2145
|
+
for (let [e, n] of Object.entries(t.members ?? {})) r[e] = J([r[e], n]);
|
|
2146
|
+
let i = e.by ?? t.by;
|
|
2147
|
+
return {
|
|
2148
|
+
...n === void 0 ? {} : { number: n },
|
|
2149
|
+
...i === void 0 ? Object.keys(r).length === 0 ? {} : { members: r } : { by: {
|
|
2150
|
+
name: i.name,
|
|
2151
|
+
cases: Object.fromEntries(Object.entries(i.cases).map(([e, t]) => [e, J([t, { members: r }])]))
|
|
2152
|
+
} }
|
|
2153
|
+
};
|
|
2154
|
+
}, void 0);
|
|
2155
|
+
}
|
|
2156
|
+
function Pr(e, t) {
|
|
2157
|
+
let n = Object.entries(e).flatMap(([e, n]) => {
|
|
2158
|
+
let r = t(n);
|
|
2159
|
+
return r === void 0 ? [] : [[e, r]];
|
|
2160
|
+
});
|
|
2161
|
+
return n.length === 0 ? void 0 : Object.fromEntries(n);
|
|
2162
|
+
}
|
|
2163
|
+
function Fr(e) {
|
|
2164
|
+
if (G(e)) return typeof e.const == "string" ? e.const : Array.isArray(e.enum) && e.enum.length === 1 && typeof e.enum[0] == "string" ? e.enum[0] : void 0;
|
|
2165
|
+
}
|
|
2166
|
+
// src/manifest/typeText.ts
|
|
2167
|
+
function Ir(e) {
|
|
2168
|
+
let t = 0;
|
|
2169
|
+
for (let n = 0; n < e.length; n++) {
|
|
2170
|
+
let r = e[n];
|
|
2171
|
+
if (r === "'") for (n++; n < e.length && e[n] !== "'"; n++) e[n] === "\\" && n++;
|
|
2172
|
+
else if ("({[<".includes(r)) t++;
|
|
2173
|
+
else if (")}]".includes(r) || r === ">" && e[n - 1] !== "=") t--;
|
|
2174
|
+
else if (t === 0 && (r === "|" || r === "&") && e[n - 1] === " " && e[n + 1] === " ") return !0;
|
|
2175
|
+
}
|
|
2176
|
+
return !1;
|
|
2177
|
+
}
|
|
2178
|
+
function Lr(e, t) {
|
|
1759
2179
|
let n = [...new Set(e)];
|
|
1760
|
-
return n.length === 1 ? n[0] : n.map((e) =>
|
|
2180
|
+
return n.length === 1 ? n[0] : n.map((e) => Ir(e) ? `(${e})` : e).join(t);
|
|
1761
2181
|
}
|
|
1762
|
-
function
|
|
1763
|
-
return typeof e == "string" ?
|
|
2182
|
+
function Rr(e) {
|
|
2183
|
+
return typeof e == "string" ? O(e) : JSON.stringify(e);
|
|
1764
2184
|
}
|
|
1765
|
-
|
|
2185
|
+
// src/manifest/schemaTypes.ts
|
|
2186
|
+
var zr = 4, Br = class {
|
|
1766
2187
|
defs;
|
|
1767
2188
|
names = /* @__PURE__ */ new Map();
|
|
1768
2189
|
warnings = [];
|
|
@@ -1772,28 +2193,28 @@ var mr = class {
|
|
|
1772
2193
|
inlined(e) {
|
|
1773
2194
|
return e.includes("(");
|
|
1774
2195
|
}
|
|
1775
|
-
name(e) {
|
|
1776
|
-
let
|
|
1777
|
-
for (let e = 0;
|
|
1778
|
-
let
|
|
1779
|
-
for (let
|
|
1780
|
-
let
|
|
1781
|
-
|
|
2196
|
+
name(e, t) {
|
|
2197
|
+
let n = new Set(e);
|
|
2198
|
+
for (let e = 0; n.size > 0; e++) {
|
|
2199
|
+
let r = /* @__PURE__ */ new Map();
|
|
2200
|
+
for (let t of n.keys()) {
|
|
2201
|
+
let n = t.split("."), i = n[n.length - 1].split("$"), a = C([...n.slice(Math.max(0, n.length - 1 - e), n.length - 1), ...i].map((e) => /^[a-z]/.test(e) ? w(e) : e));
|
|
2202
|
+
r.set(a, [...r.get(a) ?? [], t]);
|
|
1782
2203
|
}
|
|
1783
|
-
let
|
|
1784
|
-
for (let [
|
|
1785
|
-
let
|
|
2204
|
+
let i = /* @__PURE__ */ new Set([...t, ...this.names.values()]);
|
|
2205
|
+
for (let [t, a] of r) {
|
|
2206
|
+
let r = a.filter((t) => t.split(".").length - 1 <= e), o = a.length === 1 && !i.has(t) ? a : r;
|
|
1786
2207
|
for (let e of o) {
|
|
1787
|
-
let
|
|
1788
|
-
for (let e = 2;
|
|
1789
|
-
|
|
2208
|
+
let r = t;
|
|
2209
|
+
for (let e = 2; i.has(r); e++) r = `${t}${e}`;
|
|
2210
|
+
i.add(r), this.names.set(e, r), n.delete(e);
|
|
1790
2211
|
}
|
|
1791
2212
|
}
|
|
1792
2213
|
}
|
|
1793
2214
|
}
|
|
1794
2215
|
schemaOf(e) {
|
|
1795
2216
|
let t = this.defs[e];
|
|
1796
|
-
return
|
|
2217
|
+
return G(t) ? t : void 0;
|
|
1797
2218
|
}
|
|
1798
2219
|
resolve(e, t = /* @__PURE__ */ new Set()) {
|
|
1799
2220
|
let n = e.$ref;
|
|
@@ -1805,7 +2226,7 @@ var mr = class {
|
|
|
1805
2226
|
}
|
|
1806
2227
|
references(e, t = /* @__PURE__ */ new Set()) {
|
|
1807
2228
|
if (Array.isArray(e)) e.forEach((e) => this.references(e, t));
|
|
1808
|
-
else if (
|
|
2229
|
+
else if (G(e)) for (let [n, r] of Object.entries(e)) if (n === "$ref" && typeof r == "string") {
|
|
1809
2230
|
let e = W(r);
|
|
1810
2231
|
e !== void 0 && t.add(e);
|
|
1811
2232
|
} else n !== "enum" && n !== "const" && this.references(r, t);
|
|
@@ -1839,34 +2260,34 @@ var mr = class {
|
|
|
1839
2260
|
type(e, t) {
|
|
1840
2261
|
if (e === !0 || e === void 0) return "unknown";
|
|
1841
2262
|
if (e === !1) return "never";
|
|
1842
|
-
if (!
|
|
2263
|
+
if (!G(e)) return "unknown";
|
|
1843
2264
|
if (typeof e.$ref == "string") {
|
|
1844
2265
|
let n = W(e.$ref);
|
|
1845
2266
|
return n === void 0 ? "unknown" : this.refType(n, t);
|
|
1846
2267
|
}
|
|
1847
|
-
if ("const" in e) return
|
|
1848
|
-
if (Array.isArray(e.enum)) return e.enum.length === 0 ? "never" :
|
|
2268
|
+
if ("const" in e) return Rr(e.const);
|
|
2269
|
+
if (Array.isArray(e.enum)) return e.enum.length === 0 ? "never" : Lr(e.enum.map(Rr), " | ");
|
|
1849
2270
|
for (let [n, r] of [
|
|
1850
2271
|
["oneOf", " | "],
|
|
1851
2272
|
["anyOf", " | "],
|
|
1852
2273
|
["allOf", " & "]
|
|
1853
2274
|
]) {
|
|
1854
2275
|
let i = e[n];
|
|
1855
|
-
if (Array.isArray(i) && i.length > 0) return
|
|
2276
|
+
if (Array.isArray(i) && i.length > 0) return Lr(i.map((e) => this.type(e, t)), r);
|
|
1856
2277
|
}
|
|
1857
|
-
let n =
|
|
1858
|
-
return n.length === 0 ?
|
|
2278
|
+
let n = K(e);
|
|
2279
|
+
return n.length === 0 ? G(e.properties) ? this.objectType(e, t) : "unknown" : Lr(n.map((n) => this.primitive(n, e, t)), " | ");
|
|
1859
2280
|
}
|
|
1860
2281
|
primitive(e, t, n) {
|
|
1861
2282
|
switch (e) {
|
|
1862
2283
|
case "string": return "string";
|
|
1863
2284
|
case "integer":
|
|
1864
|
-
case "number": return typeof t.format == "string" &&
|
|
2285
|
+
case "number": return typeof t.format == "string" && Mr.has(t.format) ? "string" : "number";
|
|
1865
2286
|
case "boolean": return "boolean";
|
|
1866
2287
|
case "null": return "null";
|
|
1867
2288
|
case "array": {
|
|
1868
2289
|
let e = t.items === void 0 ? "unknown" : this.type(t.items, n);
|
|
1869
|
-
return
|
|
2290
|
+
return Ir(e) ? `(${e})[]` : `${e}[]`;
|
|
1870
2291
|
}
|
|
1871
2292
|
case "object": return this.objectType(t, n);
|
|
1872
2293
|
default: return "unknown";
|
|
@@ -1879,12 +2300,12 @@ var mr = class {
|
|
|
1879
2300
|
return r !== void 0 && i.push("[key: string]: unknown"), `{ ${i.join("; ")} }`;
|
|
1880
2301
|
}
|
|
1881
2302
|
properties(e, t) {
|
|
1882
|
-
if (!
|
|
2303
|
+
if (!G(e.properties)) return [];
|
|
1883
2304
|
let n = new Set(Array.isArray(e.required) ? e.required : []);
|
|
1884
2305
|
return Object.entries(e.properties).map(([e, r]) => {
|
|
1885
|
-
let i =
|
|
2306
|
+
let i = G(r) ? r.description : void 0;
|
|
1886
2307
|
return {
|
|
1887
|
-
name:
|
|
2308
|
+
name: D(e),
|
|
1888
2309
|
type: this.type(r, `${t}.${e}`),
|
|
1889
2310
|
optional: !n.has(e),
|
|
1890
2311
|
...typeof i == "string" ? { description: i } : {}
|
|
@@ -1896,97 +2317,84 @@ var mr = class {
|
|
|
1896
2317
|
if (n !== void 0 && n !== !1) return this.type(n, t);
|
|
1897
2318
|
}
|
|
1898
2319
|
isInterface(e) {
|
|
1899
|
-
let t =
|
|
1900
|
-
return
|
|
1901
|
-
}
|
|
1902
|
-
textNumbers(e, t = /* @__PURE__ */ new Set()) {
|
|
1903
|
-
if (!K(e)) return;
|
|
1904
|
-
let n = typeof e.$ref == "string" ? W(e.$ref) : void 0;
|
|
1905
|
-
if (n !== void 0) {
|
|
1906
|
-
let e = this.schemaOf(n);
|
|
1907
|
-
return t.has(n) || e === void 0 ? void 0 : this.textNumbers(e, /* @__PURE__ */ new Set([...t, n]));
|
|
1908
|
-
}
|
|
1909
|
-
let r = [
|
|
1910
|
-
"oneOf",
|
|
1911
|
-
"anyOf",
|
|
1912
|
-
"allOf"
|
|
1913
|
-
].flatMap((t) => Array.isArray(e[t]) ? e[t] : []).map((e) => this.textNumbers(e, t)).filter((e) => e !== void 0), i = q(e);
|
|
1914
|
-
(i.includes("integer") || i.includes("number")) && typeof e.format == "string" && cr.has(e.format) && r.push(!0);
|
|
1915
|
-
let a = {};
|
|
1916
|
-
if (K(e.properties)) for (let [n, r] of Object.entries(e.properties)) {
|
|
1917
|
-
let e = this.textNumbers(r, t);
|
|
1918
|
-
e !== void 0 && (a[n] = e);
|
|
1919
|
-
}
|
|
1920
|
-
let o = this.textNumbers(e.items, t) ?? this.textNumbers(e.additionalProperties, t);
|
|
1921
|
-
return o !== void 0 && (a["*"] = o), Object.keys(a).length > 0 && r.push(a), hr(r);
|
|
2320
|
+
let t = K(e);
|
|
2321
|
+
return G(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;
|
|
1922
2322
|
}
|
|
1923
2323
|
fields(e, t, n = 1, r = /* @__PURE__ */ new Set()) {
|
|
1924
2324
|
let i = this.resolve(e), a = typeof e.$ref == "string" ? W(e.$ref) : void 0;
|
|
1925
2325
|
if (a !== void 0 && r.has(a)) return [];
|
|
1926
2326
|
let o = a === void 0 ? r : /* @__PURE__ */ new Set([...r, a]);
|
|
1927
|
-
if (!
|
|
2327
|
+
if (!G(i.properties)) return [];
|
|
1928
2328
|
let s = [];
|
|
1929
2329
|
for (let [e, r] of Object.entries(i.properties)) {
|
|
1930
2330
|
let i = `${t}.${e}`;
|
|
1931
|
-
s.push(i), n <
|
|
2331
|
+
s.push(i), n < zr && G(r) && (K(this.resolve(r)).includes("array") || s.push(...this.fields(r, i, n + 1, o)));
|
|
1932
2332
|
}
|
|
1933
2333
|
return s;
|
|
1934
2334
|
}
|
|
1935
2335
|
};
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
let
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
}
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
}
|
|
1952
|
-
|
|
1953
|
-
|
|
2336
|
+
// src/manifest/serviceRoutes.ts
|
|
2337
|
+
function Vr(e, t, n, r) {
|
|
2338
|
+
let i = `${n.name} route ${r.name}`, a = gr();
|
|
2339
|
+
return {
|
|
2340
|
+
name: r.name,
|
|
2341
|
+
method: r.route.method,
|
|
2342
|
+
path: r.route.path,
|
|
2343
|
+
...r.description ? { description: r.description } : {},
|
|
2344
|
+
deprecated: r.deprecated === !0,
|
|
2345
|
+
parameters: (r.parameters ?? []).map((t) => ({
|
|
2346
|
+
name: t.name,
|
|
2347
|
+
identifier: _r(t, a),
|
|
2348
|
+
location: t.in === "path" ? "path" : "query",
|
|
2349
|
+
type: e.type(t.schema, `${i} ${t.name}`),
|
|
2350
|
+
required: t.required
|
|
2351
|
+
})),
|
|
2352
|
+
...r.request === void 0 ? {} : { requestType: e.type(r.request, `${i} body`) },
|
|
2353
|
+
...r.response === void 0 ? {} : { responseType: Hr(e.type(r.response, `${i} answer`), r.responseOptional === !0) },
|
|
2354
|
+
...Ur(t.marks(r.request, `${i} body`), t.marks(r.response, `${i} answer`))
|
|
2355
|
+
};
|
|
1954
2356
|
}
|
|
1955
|
-
function
|
|
1956
|
-
return
|
|
1957
|
-
t.state.schema,
|
|
1958
|
-
..._r(t).map((e) => e.schema),
|
|
1959
|
-
...(t.events ?? []).map((e) => e.schema)
|
|
1960
|
-
].map(W).filter((e) => e !== void 0).concat(br(e, t));
|
|
2357
|
+
function Hr(e, t) {
|
|
2358
|
+
return t ? `${e} | undefined` : e;
|
|
1961
2359
|
}
|
|
1962
|
-
function
|
|
1963
|
-
return
|
|
2360
|
+
function Ur(e, t) {
|
|
2361
|
+
return e === void 0 && t === void 0 ? {} : { textNumbers: {
|
|
2362
|
+
...e === void 0 ? {} : { request: e },
|
|
2363
|
+
...t === void 0 ? {} : { response: t }
|
|
2364
|
+
} };
|
|
1964
2365
|
}
|
|
1965
|
-
|
|
1966
|
-
|
|
2366
|
+
// src/manifest/analyze.ts
|
|
2367
|
+
function Wr(e) {
|
|
2368
|
+
let t = new Br(e.$defs ?? {}), n = e.contexts, r = /* @__PURE__ */ new Map();
|
|
1967
2369
|
for (let e of n) {
|
|
1968
|
-
let n = [...(e.aggregates ?? []).flatMap((e) =>
|
|
1969
|
-
for (let i of t.closure(n).sort(
|
|
2370
|
+
let n = [...(e.aggregates ?? []).flatMap((e) => Er(t, e)), ...(e.routes ?? []).flatMap((e) => [...t.references(e.request), ...t.references(e.response)])];
|
|
2371
|
+
for (let i of t.closure(n).sort(j)) r.has(i) || r.set(i, e.name);
|
|
1970
2372
|
}
|
|
1971
2373
|
let i = [...r.keys()].filter((e) => t.schemaOf(e) && !t.inlined(e));
|
|
1972
|
-
t.name([...i].sort(
|
|
1973
|
-
let a = i.map((e) =>
|
|
2374
|
+
t.name([...i].sort(j), hr(e));
|
|
2375
|
+
let a = i.map((e) => Gr(t, e, `${r.get(e)}/types.ts`)).sort((e, t) => j(e.file, t.file) || j(e.name, t.name)), o = new Nr(e.$defs ?? {}, (e) => ({
|
|
2376
|
+
name: `${T(t.names.get(e) ?? e)}Numbers`,
|
|
2377
|
+
file: `${r.get(e)}/textNumbers.ts`
|
|
2378
|
+
})), s = n.map((e) => Kr(t, o, e)).map((e) => ({
|
|
2379
|
+
...e,
|
|
2380
|
+
textNumbers: o.declarations().filter((t) => t.file === `${e.directory}/textNumbers.ts`)
|
|
2381
|
+
}));
|
|
1974
2382
|
return {
|
|
1975
2383
|
model: {
|
|
1976
2384
|
...e.service?.name ? { service: e.service.name } : {},
|
|
1977
2385
|
types: a,
|
|
1978
|
-
contexts:
|
|
2386
|
+
contexts: s
|
|
1979
2387
|
},
|
|
1980
2388
|
warnings: [...new Set(t.warnings)]
|
|
1981
2389
|
};
|
|
1982
2390
|
}
|
|
1983
|
-
function
|
|
2391
|
+
function Gr(e, t, n) {
|
|
1984
2392
|
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 = {
|
|
1985
2393
|
key: t,
|
|
1986
2394
|
name: i,
|
|
1987
2395
|
file: n,
|
|
1988
2396
|
...a === void 0 ? {} : { description: a },
|
|
1989
|
-
references: [...new Set(o)].sort(
|
|
2397
|
+
references: [...new Set(o)].sort(j)
|
|
1990
2398
|
};
|
|
1991
2399
|
if (e.isInterface(r)) {
|
|
1992
2400
|
let n = e.additional(r, t);
|
|
@@ -2001,133 +2409,33 @@ function Sr(e, t, n) {
|
|
|
2001
2409
|
type: e.type(r, t)
|
|
2002
2410
|
};
|
|
2003
2411
|
}
|
|
2004
|
-
function
|
|
2412
|
+
function Kr(e, t, n) {
|
|
2005
2413
|
return {
|
|
2006
|
-
name:
|
|
2007
|
-
...
|
|
2008
|
-
typeName:
|
|
2009
|
-
constantName:
|
|
2010
|
-
directory:
|
|
2011
|
-
errors: (
|
|
2414
|
+
name: n.name,
|
|
2415
|
+
...n.description ? { description: n.description } : {},
|
|
2416
|
+
typeName: pr(n),
|
|
2417
|
+
constantName: E(n.name),
|
|
2418
|
+
directory: n.name,
|
|
2419
|
+
errors: (n.errors ?? []).map((e) => ({
|
|
2012
2420
|
code: e.code,
|
|
2013
2421
|
status: e.status,
|
|
2014
2422
|
...e.description ? { description: e.description } : {}
|
|
2015
2423
|
})),
|
|
2016
|
-
subscriptions: [...new Set((
|
|
2017
|
-
aggregates: (
|
|
2018
|
-
routes: (
|
|
2019
|
-
let r = `${t.name} route ${n.name}`;
|
|
2020
|
-
return {
|
|
2021
|
-
name: n.name,
|
|
2022
|
-
method: n.route.method,
|
|
2023
|
-
path: n.route.path,
|
|
2024
|
-
...n.description ? { description: n.description } : {},
|
|
2025
|
-
deprecated: n.deprecated === !0,
|
|
2026
|
-
parameters: (n.parameters ?? []).map((t) => ({
|
|
2027
|
-
name: t.name,
|
|
2028
|
-
location: t.in === "path" ? "path" : "query",
|
|
2029
|
-
type: e.type(t.schema, `${r} ${t.name}`),
|
|
2030
|
-
required: t.required
|
|
2031
|
-
})),
|
|
2032
|
-
...n.request === void 0 ? {} : { requestType: e.type(n.request, `${r} body`) },
|
|
2033
|
-
...n.response === void 0 ? {} : { responseType: e.type(n.response, `${r} answer`) }
|
|
2034
|
-
};
|
|
2035
|
-
})
|
|
2036
|
-
};
|
|
2037
|
-
}
|
|
2038
|
-
function wr(e) {
|
|
2039
|
-
return (e.routes ?? []).map((e) => ({
|
|
2040
|
-
method: e.method,
|
|
2041
|
-
path: e.path
|
|
2042
|
-
}));
|
|
2043
|
-
}
|
|
2044
|
-
function Tr(e, t, n) {
|
|
2045
|
-
let r = W(t);
|
|
2046
|
-
return r === void 0 ? "unknown" : e.refType(r, n);
|
|
2047
|
-
}
|
|
2048
|
-
function Er(e, t, n) {
|
|
2049
|
-
let r = `${t.name}.${n.name}`, i = k(A(n.name)), a = n.idSource ?? "assigned", o = a === "owner", s = new Set(br(e, n)), c = vr(n).filter((e) => ur.has(e.name)).map((t) => {
|
|
2050
|
-
let n = t.name, i = n.split(".").pop(), a = e.schemaOf(n)?.description, c = et(j(i)), l = o && (t.routes ?? []).some((e) => !e.path.includes("{id}"));
|
|
2051
|
-
return {
|
|
2052
|
-
name: n,
|
|
2053
|
-
member: M(i),
|
|
2054
|
-
method: c,
|
|
2055
|
-
routes: wr(t),
|
|
2056
|
-
...l ? { ownMethod: `${c}Own` } : {},
|
|
2057
|
-
...s.has(n) ? {
|
|
2058
|
-
bodyType: e.refType(n, r),
|
|
2059
|
-
bodyGenerated: !0
|
|
2060
|
-
} : lr[n] ? { bodyType: lr[n] } : {},
|
|
2061
|
-
...typeof a == "string" ? { description: a } : {}
|
|
2062
|
-
};
|
|
2063
|
-
}), l = new Set(c.flatMap((e) => [e.method, e.ownMethod ?? e.method])), u = _r(n).map((t) => {
|
|
2064
|
-
let n = et(j(t.name));
|
|
2065
|
-
(l.has(n) || n === "gateway") && (n = `${n}Command`), l.add(n);
|
|
2066
|
-
let i = (t.routes ?? []).filter((e) => e.method === "POST"), a = i.find((e) => e.path.includes("{id}")), s = i.find((e) => !e.path.includes("{id}")), c;
|
|
2067
|
-
o && a && s && !(t.mounted ?? !1) && (c = `${n}Own`, l.has(c) && (c = `${c}Command`), l.add(c));
|
|
2068
|
-
let u = W(t.schema);
|
|
2069
|
-
return {
|
|
2070
|
-
name: t.name,
|
|
2071
|
-
method: n,
|
|
2072
|
-
routes: wr(t),
|
|
2073
|
-
...a ? { byIdPath: { path: a.path } } : {},
|
|
2074
|
-
...s ? { unaddressedPath: { path: s.path } } : {},
|
|
2075
|
-
...c === void 0 ? {} : { ownMethod: c },
|
|
2076
|
-
bodyType: Tr(e, t.schema, `${r}.${t.name}`),
|
|
2077
|
-
bodyOptional: gr(e, u === void 0 ? void 0 : e.schemaOf(u)),
|
|
2078
|
-
creation: t.creation ?? "none",
|
|
2079
|
-
mounted: t.mounted ?? !1,
|
|
2080
|
-
produces: t.produces ?? [],
|
|
2081
|
-
...t.description ? { description: t.description } : {},
|
|
2082
|
-
...e.textNumbers({ $ref: t.schema }) === void 0 ? {} : { bodyNumbers: !0 }
|
|
2083
|
-
};
|
|
2084
|
-
}), d = e.textNumbers({ $ref: n.state.schema }), f = Object.fromEntries((n.events ?? []).flatMap((r) => {
|
|
2085
|
-
let i = e.textNumbers({ $ref: r.schema });
|
|
2086
|
-
return i === void 0 ? [] : [[Dr(t, n, r.name), i]];
|
|
2087
|
-
})), p = Object.fromEntries(_r(n).flatMap((t) => {
|
|
2088
|
-
let n = e.textNumbers({ $ref: t.schema });
|
|
2089
|
-
return n === void 0 ? [] : [[t.name, n]];
|
|
2090
|
-
})), m = {
|
|
2091
|
-
...d === void 0 ? {} : { state: d },
|
|
2092
|
-
...Object.keys(f).length === 0 ? {} : { events: f },
|
|
2093
|
-
...Object.keys(p).length === 0 ? {} : { commands: p }
|
|
2094
|
-
}, h = W(n.state.schema), g = h === void 0 ? void 0 : e.schemaOf(h);
|
|
2095
|
-
return {
|
|
2096
|
-
context: t.name,
|
|
2097
|
-
name: n.name,
|
|
2098
|
-
...n.description ? { description: n.description } : {},
|
|
2099
|
-
typeName: i,
|
|
2100
|
-
directory: `${t.name}/${n.name}`,
|
|
2101
|
-
ownership: n.ownership ?? "owner",
|
|
2102
|
-
idSource: a,
|
|
2103
|
-
snapshot: n.snapshot?.enabled ?? !0,
|
|
2104
|
-
stateType: Tr(e, n.state.schema, `${r} state`),
|
|
2105
|
-
stateFields: g === void 0 ? [] : e.fields({ $ref: n.state.schema }, "state"),
|
|
2106
|
-
commands: u,
|
|
2107
|
-
events: (n.events ?? []).map((i) => ({
|
|
2108
|
-
name: i.name,
|
|
2109
|
-
wireName: Dr(t, n, i.name),
|
|
2110
|
-
revision: i.revision ?? 1,
|
|
2111
|
-
type: Tr(e, i.schema, `${r}.${i.name}`)
|
|
2112
|
-
})),
|
|
2113
|
-
lifecycle: c,
|
|
2114
|
-
queryModels: (n.queries ?? []).map((e) => e.model),
|
|
2115
|
-
...Object.keys(m).length === 0 ? {} : { textNumbers: m }
|
|
2424
|
+
subscriptions: [...new Set((n.subscriptions ?? []).map((e) => e.name))].sort(j),
|
|
2425
|
+
aggregates: (n.aggregates ?? []).map((r) => Ar(e, t, n, r)),
|
|
2426
|
+
routes: (n.routes ?? []).map((r) => Vr(e, t, n, r))
|
|
2116
2427
|
};
|
|
2117
2428
|
}
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
var J = "@ahoo-wang/wow-client", Or = "@ahoo-wang/wow-client/routes";
|
|
2123
|
-
function Y(e, t = "") {
|
|
2124
|
-
let n = e.filter((e) => typeof e == "string" && e !== "").flatMap((e) => Ot(e).split("\n"));
|
|
2429
|
+
// src/emitters/manifest/generatedModule.ts
|
|
2430
|
+
var Y = "@ahoo-wang/wow-client", qr = "@ahoo-wang/wow-client/routes";
|
|
2431
|
+
function X(e, t = "") {
|
|
2432
|
+
let n = e.filter((e) => typeof e == "string" && e !== "").flatMap((e) => kt(e).split("\n"));
|
|
2125
2433
|
return n.length === 0 ? "" : n.length === 1 ? `${t}/** ${n[0]} */\n` : `${t}/**\n${n.map((e) => `${t} * ${e}`.trimEnd()).join("\n")}\n${t} */\n`;
|
|
2126
2434
|
}
|
|
2127
|
-
function
|
|
2435
|
+
function Z(e, t) {
|
|
2128
2436
|
e.add(`\n${t}`);
|
|
2129
2437
|
}
|
|
2130
|
-
function
|
|
2438
|
+
function Jr(e) {
|
|
2131
2439
|
return e.length === 0 ? "never" : e.join(" | ");
|
|
2132
2440
|
}
|
|
2133
2441
|
function Q(e, t, n, r, i) {
|
|
@@ -2136,144 +2444,124 @@ function Q(e, t, n, r, i) {
|
|
|
2136
2444
|
let t = n.get(e);
|
|
2137
2445
|
t !== void 0 && t !== i && a.set(t, [...a.get(t) ?? [], e]);
|
|
2138
2446
|
}
|
|
2139
|
-
for (let [n, r] of a) e.imports.add(L(e.directoryPath,
|
|
2140
|
-
}
|
|
2141
|
-
function kr(e, t, n) {
|
|
2142
|
-
let r = new Map(e.types.map((e) => [e.name, e.file]));
|
|
2143
|
-
for (let i of e.types) Ar(t.module(i.file), i, r, n);
|
|
2144
|
-
for (let i of e.contexts) {
|
|
2145
|
-
Nr(i, t, n);
|
|
2146
|
-
for (let e of i.aggregates) Br(e, i, t, r, n), Wr(e, i, t, r, n), Gr(e, t, r, n);
|
|
2147
|
-
Pr(i, t), Fr(i, t, r, n), Lr(i, t, n);
|
|
2148
|
-
}
|
|
2149
|
-
}
|
|
2150
|
-
function Ar(e, t, n, r) {
|
|
2151
|
-
Q(e, r, n, t.references, t.file);
|
|
2152
|
-
let i = Y([t.description, `- key: \`${t.key}\``]);
|
|
2153
|
-
if (t.properties === void 0) {
|
|
2154
|
-
X(e, `${i}export type ${t.name} = ${t.type};`);
|
|
2155
|
-
return;
|
|
2156
|
-
}
|
|
2157
|
-
let a = t.properties.map((e) => `${Y([e.description], " ")} ${e.name}${e.optional ? "?" : ""}: ${e.type};`);
|
|
2158
|
-
t.type !== void 0 && a.push(` [key: string]: ${t.type};`), X(e, `${i}export interface ${t.name} {\n${a.join("\n")}\n}`);
|
|
2447
|
+
for (let [n, r] of a) e.imports.add(L(e.directoryPath, v(t, n)), r);
|
|
2159
2448
|
}
|
|
2160
|
-
|
|
2449
|
+
// src/emitters/manifest/contract.ts
|
|
2450
|
+
function Yr(e, t) {
|
|
2161
2451
|
let n = e.aggregates.map((t) => `${e.name}.${t.name}.`), r = t === void 0 ? `${e.name}.` : `${e.name}.${t.name}.`;
|
|
2162
2452
|
return e.errors.filter((e) => t === void 0 ? !n.some((t) => e.code.startsWith(t)) : e.code.startsWith(r)).map((e) => ({
|
|
2163
|
-
member:
|
|
2453
|
+
member: E((e.code.startsWith(r) ? e.code.slice(r.length) : e.code).split(/[^A-Za-z0-9]+/)) || "ERROR",
|
|
2164
2454
|
error: e
|
|
2165
2455
|
}));
|
|
2166
2456
|
}
|
|
2167
|
-
function
|
|
2168
|
-
return e.length === 0 ? "" : `${t}Errors: {\n${e.map(({ member: e, error: n }) => `${
|
|
2457
|
+
function Xr(e, t) {
|
|
2458
|
+
return e.length === 0 ? "" : `${t}Errors: {\n${e.map(({ member: e, error: n }) => `${X([`${n.status}: ${n.description ?? n.code}`], `${t} `)}${t} ${e}: ${O(n.code)},`).join("\n")}\n${t}},\n`;
|
|
2169
2459
|
}
|
|
2170
|
-
function
|
|
2460
|
+
function Zr(e, t, n) {
|
|
2171
2461
|
let r = t.module(`${e.directory}/contract.ts`), i = `${e.typeName}Contract`;
|
|
2172
|
-
r.imports.add(
|
|
2173
|
-
for (let t of e.aggregates) r.imports.add(L(r.directoryPath,
|
|
2462
|
+
r.imports.add(Y, ["Hop", "wait"]);
|
|
2463
|
+
for (let t of e.aggregates) r.imports.add(L(r.directoryPath, v(n, t.directory, "aggregate.ts")), [`${t.typeName}Aggregate`]);
|
|
2174
2464
|
let a = e.aggregates.map((e) => ` ${e.typeName}: ${e.typeName}Aggregate,\n`);
|
|
2175
|
-
|
|
2465
|
+
Z(r, `${X([`The bounded context \`${e.name}\`: its name, its error codes and its aggregates, as the Kotlin \`${i}\` names them. A problem's \`code\` is one of its \`Errors\`, or of an aggregate's.`, e.description])}export const ${i} = {\n NAME: ${O(e.name)},\n${Xr(Yr(e), " ")}${a.join("")}} as const;`), Z(r, `${X([`An error code of \`${e.name}\`, of the context or of one of its aggregates.`])}export type ${e.typeName}ErrorCode = ${Jr(e.errors.map((e) => O(e.code)))};`);
|
|
2176
2466
|
let o = e.subscriptions.length > 0;
|
|
2177
|
-
o &&
|
|
2467
|
+
o && Z(r, `${X([`The subscriptions of \`${e.name}\` a \`handled\` hop names.`])}export type ${e.typeName}Subscription = ${Jr(e.subscriptions.map(O))};`);
|
|
2178
2468
|
let s = `${i}.NAME`, c = [
|
|
2179
2469
|
` /** Until a command of \`${e.name}\` passed admission. */\n accepted: (): Hop => wait.accepted(${s}),`,
|
|
2180
2470
|
` /** Until a command's events are appended to the log of \`${e.name}\`. */\n committed: (): Hop => wait.committed(${s}),`,
|
|
2181
|
-
` /** Until the snapshot of \`${e.name}\` holds the commit. */\n snapshot: (): Hop => wait.snapshot(${s})
|
|
2471
|
+
` /** Until the snapshot of \`${e.name}\` holds the commit. */\n snapshot: (): Hop => wait.snapshot(${s}),`,
|
|
2472
|
+
` /** Until the store the snapshot queries of \`${e.name}\` read holds the commit. */\n queryable: (): Hop => wait.queryable(${s}),`
|
|
2182
2473
|
];
|
|
2183
|
-
o && c.push(` /** Until a subscription of \`${e.name}\` handled the commit. */\n handled: (subscription: ${e.typeName}Subscription): Hop => wait.handled(subscription, ${s}),`),
|
|
2184
|
-
}
|
|
2185
|
-
function Pr(e, t) {
|
|
2186
|
-
let n = t.module(`${e.directory}/manifest.ts`), r = `${e.typeName}Manifest`;
|
|
2187
|
-
n.imports.add(J, ["MANIFEST_FORMAT", "RoutingManifest"]);
|
|
2188
|
-
let i = (e, t) => ` { name: ${P(e)}, routes: ${Hr(t)} },`, a = e.aggregates.map((e) => {
|
|
2189
|
-
let t = [...e.commands.filter((e) => e.routes.length > 0).map((e) => i(e.name, e.routes)), ...e.lifecycle.map((e) => i(e.name, e.routes))];
|
|
2190
|
-
return ` {\n name: ${P(e.name)},\n commands: [\n${t.join("\n")}\n ],\n },`;
|
|
2191
|
-
}), o = e.routes.map((e) => ` { name: ${P(e.name)}, route: { method: ${P(e.method)}, path: ${P(e.path)} } },`), s = o.length === 0 ? "" : ` routes: [\n${o.join("\n")}\n ],\n`;
|
|
2192
|
-
X(n, `${Y([o.length === 0 ? `The routes of \`${e.name}\`'s commands, as its Manifest lists them: what its command clients send by, with no Manifest fetched and no schema.` : `The routes of \`${e.name}\`'s commands and service routes, as its Manifest lists them: what its clients send by, with no Manifest fetched and no schema.`])}export const ${r}: RoutingManifest = {\n format: MANIFEST_FORMAT,\n contexts: [\n {\n name: ${P(e.name)},\n aggregates: [\n${a.join("\n")}\n ],\n${s} },\n ],\n};`);
|
|
2193
|
-
}
|
|
2194
|
-
function Fr(e, t, n, r) {
|
|
2195
|
-
if (e.routes.length === 0) return;
|
|
2196
|
-
let i = t.module(`${e.directory}/routes.ts`), a = `${e.typeName}Routes`;
|
|
2197
|
-
i.imports.add(J, ["RequestOptions", "WowClientOptions"]), i.imports.add(Or, ["ServiceRoutes"]), i.imports.add("./manifest.js", [`${e.typeName}Manifest`]), Q(i, r, n, e.routes.flatMap((e) => [
|
|
2198
|
-
e.requestType,
|
|
2199
|
-
e.responseType,
|
|
2200
|
-
...e.parameters.map((e) => e.type)
|
|
2201
|
-
].filter((e) => e !== void 0).flatMap((e) => e.match(/[A-Za-z_$][A-Za-z0-9_$]*/g) ?? [])));
|
|
2202
|
-
let o = e.routes.map((t) => Ir(e, t));
|
|
2203
|
-
X(i, `${Y([`The service routes of \`${e.name}\`: routes whose handler is the service's own code, each called by its Manifest's name.`])}export class ${a} {\n /** Calls any route of the service by its name. */\n readonly routes: ServiceRoutes;\n\n /** @param options - How the service is reached */\n constructor(options?: WowClientOptions) {\n this.routes = new ServiceRoutes(options, { manifest: ${e.typeName}Manifest });\n }\n\n${o.join("\n\n")}\n}`);
|
|
2474
|
+
o && c.push(` /** Until a subscription of \`${e.name}\` handled the commit. */\n handled: (subscription: ${e.typeName}Subscription): Hop => wait.handled(subscription, ${s}),`), Z(r, `${X([`The hops of a wait chain (\`Wow-Wait\`) in \`${e.name}\`.`])}export const ${T(e.name)}Wait = {\n${c.join("\n")}\n} as const;`);
|
|
2204
2475
|
}
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
if (
|
|
2208
|
-
|
|
2209
|
-
|
|
2476
|
+
// src/emitters/manifest/textNumbers.ts
|
|
2477
|
+
function $(e, t) {
|
|
2478
|
+
if (e === !0) return "true";
|
|
2479
|
+
if ("members" in e) return Qr(e.members, t);
|
|
2480
|
+
if ("lazy" in e) {
|
|
2481
|
+
let n = L(t.module.directoryPath, v(t.outputDir, e.lazy.file));
|
|
2482
|
+
return n !== `./${_(t.module.sourceFile.getFilePath(), ".ts")}.js` && t.module.imports.add(n, [e.lazy.name]), `() => ${e.lazy.name}`;
|
|
2210
2483
|
}
|
|
2211
|
-
|
|
2212
|
-
let a = t.responseType ?? "void", o = [
|
|
2213
|
-
...n.length === 0 ? [] : [`path: { ${n.map((e) => N(e.name)).join(", ")} }`],
|
|
2214
|
-
...t.requestType === void 0 ? [] : ["body"],
|
|
2215
|
-
...r.length === 0 ? [] : ["query"]
|
|
2216
|
-
];
|
|
2217
|
-
return `${Y([
|
|
2218
|
-
t.description,
|
|
2219
|
-
`\`${t.method} ${t.path}\``,
|
|
2220
|
-
t.deprecated ? "@deprecated The service deprecates this route." : void 0
|
|
2221
|
-
], " ")} ${N(t.name)}(${i.join(", ")}): Promise<${a}> {\n return this.routes.call(${P(e.name)}, ${P(t.name)}, { ${o.join(", ")} }, options) as Promise<${a}>;\n }`;
|
|
2484
|
+
return "or" in e ? (t.module.imports.add(t.client, ["textNumberOr"]), `textNumberOr(${$(e.or, t)})`) : (t.module.imports.add(t.client, ["textNumbersBy"]), `textNumbersBy(${O(e.by)}, ${Qr(e.cases, t)})`);
|
|
2222
2485
|
}
|
|
2223
|
-
function
|
|
2224
|
-
|
|
2225
|
-
r.imports.add(J, ["CommandClient", "WowClientOptions"]), r.imports.add("./manifest.js", [`${e.typeName}Manifest`]);
|
|
2226
|
-
let a = [], o = [];
|
|
2227
|
-
for (let t of e.aggregates) {
|
|
2228
|
-
let e = t.typeName, i = (e) => L(r.directoryPath, _(n, t.directory, e)), s = [["commands", `${e}CommandClient`]];
|
|
2229
|
-
t.queryModels.includes("snapshot") && s.push(["snapshots", `${e}SnapshotQueryClient`]), t.queryModels.includes("events") && s.push(["events", `${e}EventQueryClient`]), s.push(["state", `${e}StateClient`]), r.imports.add(i("commandClient.ts"), [`${e}CommandClient`]), r.imports.add(i("queryClient.ts"), s.slice(1).map(([, e]) => e));
|
|
2230
|
-
let c = N(j(t.name));
|
|
2231
|
-
a.push(`${Y([`The clients of \`${t.context}.${t.name}\`.`], " ")} readonly ${c}: {\n${s.map(([e, t]) => ` readonly ${e}: ${t};`).join("\n")}\n };`), o.push(` this.${c} = {\n${s.map(([e, t]) => ` ${e}: new ${t}(options),`).join("\n")}\n };`);
|
|
2232
|
-
}
|
|
2233
|
-
e.routes.length > 0 && (r.imports.add("./routes.js", [`${e.typeName}Routes`]), a.push(`${Y([`The service routes of \`${e.name}\`.`], " ")} readonly routes: ${e.typeName}Routes;`), o.push(` this.routes = new ${e.typeName}Routes(options);`)), X(r, `${Y([e.routes.length === 0 ? `The clients of \`${e.name}\`: its command client, and per aggregate its command, query and state clients.` : `The clients of \`${e.name}\`: its command client, per aggregate its command, query and state clients, and its service routes.`])}export class ${i} {\n /** Sends any command of the service, by its Manifest's routes: \`send\`, \`wait\` and \`stream\`. */\n readonly commands: CommandClient;\n\n${a.join("\n\n")}\n\n /** @param options - How the service is reached */\n constructor(options?: WowClientOptions) {\n this.commands = new CommandClient(options, { manifest: ${e.typeName}Manifest });\n${o.join("\n")}\n }\n}`);
|
|
2486
|
+
function Qr(e, t) {
|
|
2487
|
+
return `{ ${Object.entries(e).map(([e, n]) => `${D(e)}: ${$(n, t)}`).join(", ")} }`;
|
|
2234
2488
|
}
|
|
2235
|
-
function
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
function zr(e) {
|
|
2239
|
-
let t = e.textNumbers;
|
|
2240
|
-
return t === void 0 ? "" : ` textNumbers: {\n${[
|
|
2489
|
+
function $r(e, t) {
|
|
2490
|
+
let n = e.textNumbers;
|
|
2491
|
+
return n === void 0 ? "" : ` textNumbers: {\n${[
|
|
2241
2492
|
"state",
|
|
2242
2493
|
"events",
|
|
2243
|
-
"commands"
|
|
2494
|
+
"commands",
|
|
2495
|
+
"access"
|
|
2244
2496
|
].flatMap((e) => {
|
|
2245
|
-
let
|
|
2246
|
-
return
|
|
2497
|
+
let r = n[e];
|
|
2498
|
+
return r === void 0 ? [] : e === "state" || e === "access" ? [` ${e}: ${$(r, t)},`] : [` ${e}: {\n${Object.entries(r).map(([e, n]) => ` ${D(e)}: ${$(n, t)},`).join("\n")}\n },`];
|
|
2247
2499
|
}).join("\n")}\n },\n`;
|
|
2248
2500
|
}
|
|
2249
|
-
function
|
|
2501
|
+
function ei(e, t) {
|
|
2502
|
+
let n = e.routes.flatMap((n) => {
|
|
2503
|
+
let r = n.textNumbers;
|
|
2504
|
+
if (r === void 0) return [];
|
|
2505
|
+
let i = ["request", "response"].flatMap((e) => r[e] === void 0 ? [] : [`${e}: ${$(r[e], t)}`]);
|
|
2506
|
+
return [`${O(`${e.name}.${n.name}`)}: { ${i.join(", ")} }`];
|
|
2507
|
+
});
|
|
2508
|
+
return n.length === 0 ? "" : `, textNumbers: { ${n.join(", ")} }`;
|
|
2509
|
+
}
|
|
2510
|
+
function ti(e, t, n, r) {
|
|
2511
|
+
if (e.textNumbers.length === 0) return;
|
|
2512
|
+
let i = t.module(`${e.directory}/textNumbers.ts`);
|
|
2513
|
+
i.imports.add(r, ["TextNumbers"]);
|
|
2514
|
+
let a = {
|
|
2515
|
+
module: i,
|
|
2516
|
+
outputDir: n,
|
|
2517
|
+
client: r
|
|
2518
|
+
};
|
|
2519
|
+
for (let t of e.textNumbers) i.add(`\n/** The exact numbers of \`${t.key}\`${t.beside ? " with what an `allOf` says beside it" : ""}, a recursive type: its own marks, and others', read them lazily. */\nexport const ${t.name}: TextNumbers = ${$(t.marks, a)};`);
|
|
2520
|
+
}
|
|
2521
|
+
// src/emitters/manifest/aggregate.ts
|
|
2522
|
+
function ni(e, t, n, r, i) {
|
|
2250
2523
|
let a = n.module(`${e.directory}/aggregate.ts`), o = e.typeName;
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2524
|
+
Z(a, `${X([`The aggregate \`${e.context}.${e.name}\`.`, e.description])}export const ${o}Aggregate = {\n context: ${O(t.name)},\n name: ${O(e.name)},\n path: ${O(`/${t.name}/${e.name}`)},\n ownership: ${O(e.ownership)},\n${e.idSource === "assigned" ? "" : ` idSource: ${O(e.idSource)},\n`} snapshot: ${e.snapshot},\n${$r(e, {
|
|
2525
|
+
module: a,
|
|
2526
|
+
outputDir: i,
|
|
2527
|
+
client: Y
|
|
2528
|
+
})}${Xr(Yr(t, e), " ")}} as const;`), Z(a, `${X([`The \`state.*\` paths of \`${e.name}\`'s snapshots a query filters, sorts and projects on.`])}export type ${o}StateField = ${Jr(e.stateFields.map(O))};`), ri(e, a);
|
|
2529
|
+
let s = e.events.map((e) => `CommittedEvent<${O(e.wireName)}, ${e.type}>`);
|
|
2530
|
+
a.imports.add(Y, s.length > 0 ? ["CommittedEvent", "SystemEvent"] : ["SystemEvent"]), Z(a, `${X([`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 = ${Jr([...s, "SystemEvent"])};`), Q(a, i, r, e.events.map((e) => e.type));
|
|
2531
|
+
}
|
|
2532
|
+
function ri(e, t) {
|
|
2533
|
+
let n = e.typeName, r = `\`${e.context}.${e.name}\``;
|
|
2534
|
+
if (e.access.length === 0) {
|
|
2535
|
+
t.imports.add(Y, ["NoAccess"]), Z(t, `${X([`The access attributes of ${r}: it declares none.`])}export type ${n}Access = NoAccess;`);
|
|
2536
|
+
return;
|
|
2537
|
+
}
|
|
2538
|
+
let i = e.access.map((e) => {
|
|
2539
|
+
let t = e.type.includes("|") ? `(${e.type})` : e.type, n = e.multiple ? `readonly ${t}[]` : `${e.type} | null`;
|
|
2540
|
+
return ` readonly ${D(e.name)}?: ${n};`;
|
|
2541
|
+
});
|
|
2542
|
+
Z(t, `${X([`The access attributes of ${r} (\`@Access\`) by name, as its records carry them: a single one's value or null, a multiple one's values. A record written before an attribute was declared lacks it.`])}export type ${n}Access = {\n${i.join("\n")}\n};`);
|
|
2254
2543
|
}
|
|
2255
|
-
|
|
2544
|
+
// src/emitters/manifest/commandClient.ts
|
|
2545
|
+
function ii(e, t) {
|
|
2256
2546
|
let n = (t === void 0 ? [e.byIdPath, e.unaddressedPath] : [t ? e.unaddressedPath : e.byIdPath]).filter((e) => e !== void 0).map((e) => `\`POST ${e.path}\``).join(", "), r = e.creation === "required" ? "Creates the aggregate." : e.creation === "allowed" ? "Creates the aggregate, or acts on the one that exists." : void 0;
|
|
2257
|
-
return
|
|
2547
|
+
return X([
|
|
2258
2548
|
e.description,
|
|
2259
2549
|
`\`${e.name}\`${e.mounted ? ", mounted (a transformer finds its aggregate)" : ""}${t === !0 ? ", to the caller's own aggregate, whose id is the caller's owner" : ""}: ${n}.`,
|
|
2260
2550
|
t === !1 ? "By id, for a caller with no owner; `" + e.ownMethod + "` sends it to the caller's own." : void 0,
|
|
2551
|
+
e.idProperty === void 0 ? void 0 : `Its body names its aggregate: \`${e.idProperty}\`${e.idComputed ? ", which the service computes from the fields given" : ""}.`,
|
|
2261
2552
|
r,
|
|
2262
2553
|
e.produces.length > 0 ? `Produces ${e.produces.map((e) => `\`${e}\``).join(", ")}.` : void 0
|
|
2263
2554
|
], " ");
|
|
2264
2555
|
}
|
|
2265
|
-
function
|
|
2266
|
-
|
|
2267
|
-
}
|
|
2268
|
-
function $(e, t, n, r) {
|
|
2269
|
-
let i = e.bodyType === "unknown" ? "object" : e.bodyType, a = e.bodyOptional ? `body: ${i} = {}` : `body: ${i}`, o = n ? "stream" : "wait", s = n ? "Promise<CommandResultStream>" : "Promise<CommandResult>", c = r === !0 ? e.ownMethod : e.method, l = n ? `${c}Stream` : c, u = n ? Y([`\`${e.name}\`${r === !0 ? " to the caller's own aggregate" : ""}, answered as one result per hop of its wait (\`text/event-stream\`).`], " ") : Vr(e, r), d = P(`${t.context}.${t.name}.${e.name}`), f = (e) => `{ ...options, command: ${d}, body${e} }`, p = r === void 0 ? e.byIdPath : !r, m = r === void 0 ? e.unaddressedPath : r, h = p && m ? "CreateCommandOptions" : "CommandOptions", g = p && !m ? "id: string, " : "", _ = f(p && !m ? ", id" : "");
|
|
2270
|
-
return n ? `${u} ${l}(${g}${a}, options?: ${h}): ${s} {\n return this.client.${o}(${_});\n }` : Ur(u, l, `${g}${a}`, h, _);
|
|
2556
|
+
function ai(e, t, n, r) {
|
|
2557
|
+
let i = e.bodyType === "unknown" ? "object" : e.bodyType, a = e.idComputed ? `Omit<${i}, ${O(e.idProperty)}>` : i, o = e.bodyOptional ? `body: ${a} = {}` : `body: ${a}`, s = n ? "stream" : "wait", c = n ? "Promise<CommandResultStream>" : "Promise<CommandResult>", l = r === !0 ? e.ownMethod : e.method, u = n ? `${l}Stream` : l, d = n ? X([`\`${e.name}\`${r === !0 ? " to the caller's own aggregate" : ""}, answered as one result per hop of its wait (\`text/event-stream\`).`], " ") : ii(e, r), f = O(`${t.context}.${t.name}.${e.name}`), p = (e) => `{ ...options, command: ${f}, body${e} }`, m = r === void 0 ? e.byIdPath : !r, h = r === void 0 ? e.unaddressedPath : r, g = m && h ? "CreateCommandOptions" : "CommandOptions", _ = m && !h ? "id: string, " : "", v = p(m && !h ? ", id" : "");
|
|
2558
|
+
return n ? `${d} ${u}(${_}${o}, options?: ${g}): ${c} {\n return this.client.${s}(${v});\n }` : oi(d, u, `${_}${o}`, g, v);
|
|
2271
2559
|
}
|
|
2272
|
-
function
|
|
2560
|
+
function oi(e, t, n, r, i) {
|
|
2273
2561
|
return `${e} ${t}(${n ? `${n}, ` : ""}options?: ${r}): Promise<CommandResult> {\n return this.client.wait(${i});\n }`;
|
|
2274
2562
|
}
|
|
2275
|
-
function
|
|
2276
|
-
let a = n.module(`${e.directory}/commandClient.ts`), o = e.typeName, s = e.commands.filter((e) => e.byIdPath || e.unaddressedPath), c = s.flatMap((t) => t.ownMethod === void 0 ? [
|
|
2563
|
+
function si(e, t, n, r, i) {
|
|
2564
|
+
let a = n.module(`${e.directory}/commandClient.ts`), o = e.typeName, s = e.commands.filter((e) => e.byIdPath || e.unaddressedPath), c = s.flatMap((t) => t.ownMethod === void 0 ? [ai(t, e, !1), ai(t, e, !0)] : [!1, !0].flatMap((n) => [ai(t, e, !1, n), ai(t, e, !0, n)])), l = [
|
|
2277
2565
|
"CommandClient",
|
|
2278
2566
|
"CommandResult",
|
|
2279
2567
|
"WowClientOptions"
|
|
@@ -2284,32 +2572,118 @@ function Wr(e, t, n, r, i) {
|
|
|
2284
2572
|
let d = [];
|
|
2285
2573
|
for (let t of e.lifecycle) {
|
|
2286
2574
|
l.push("LifecycleCommands"), t.bodyType && (t.bodyGenerated ? d : l).push(t.bodyType);
|
|
2287
|
-
let n = t.bodyType ? `body: ${t.bodyType}` : "", r = (n) => `{ ...options, command: LifecycleCommands.${t.member}, type: { context: ${
|
|
2288
|
-
c.push(
|
|
2575
|
+
let n = t.bodyType ? `body: ${t.bodyType}` : "", r = (n) => `{ ...options, command: LifecycleCommands.${t.member}, type: { context: ${O(e.context)}, name: ${O(e.name)} }${n ? ", id" : ""}${t.bodyType ? ", body" : ""} }`;
|
|
2576
|
+
c.push(oi(X([
|
|
2289
2577
|
t.description,
|
|
2290
2578
|
`The lifecycle command \`${t.name}\`.`,
|
|
2291
2579
|
t.ownMethod === void 0 ? void 0 : `By id, for a caller with no owner; \`${t.ownMethod}\` sends it to the caller's own.`
|
|
2292
|
-
], " "), t.method, n ? `id: string, ${n}` : "id: string", "CommandOptions", r(!0))), t.ownMethod !== void 0 && c.push(
|
|
2580
|
+
], " "), t.method, n ? `id: string, ${n}` : "id: string", "CommandOptions", r(!0))), t.ownMethod !== void 0 && c.push(oi(X([t.description, `The lifecycle command \`${t.name}\`, to the caller's own aggregate, whose id is the caller's owner.`], " "), t.ownMethod, n, "CommandOptions", r(!1)));
|
|
2293
2581
|
}
|
|
2294
2582
|
let f = s.filter((e) => e.bodyNumbers);
|
|
2295
2583
|
f.length > 0 && a.imports.add("./aggregate.js", [`${o}Aggregate`]);
|
|
2296
|
-
let p = f.length ? `, bodyNumbers: {\n${f.map((t) => ` ${
|
|
2297
|
-
a.imports.add(L(a.directoryPath,
|
|
2584
|
+
let p = f.length ? `, bodyNumbers: {\n${f.map((t) => ` ${O(`${e.context}.${e.name}.${t.name}`)}: ${o}Aggregate.textNumbers.commands${D(t.name) === t.name ? `.${t.name}` : `[${O(t.name)}]`},`).join("\n")}\n }` : "", m = `${t.typeName}Manifest`;
|
|
2585
|
+
a.imports.add(L(a.directoryPath, v(i, t.directory, "manifest.ts")), [m]), a.imports.add(Y, [...new Set(l)].sort()), Q(a, i, r, [...s.map((e) => e.bodyType), ...d]), Z(a, `${X([`Sends the commands of \`${e.context}.${e.name}\` by its service's routes (\`${m}\`). Each method answers the result its wait plan ends with, as \`CommandClient.wait\` does: the server's default plan unless the options give one, \`{ wait: WaitPlan.ACCEPTED }\` to answer once it is accepted. A rejected command rejects with a \`CommandRejectedError\`; anything else that did not succeed with a \`WowProblemError\`.`])}export class ${o}CommandClient {\n readonly client: CommandClient;\n\n /** @param options - How the service is reached */\n constructor(options?: WowClientOptions) {\n this.client = new CommandClient(options, { manifest: ${m}${p} });\n }\n\n${c.join("\n\n")}\n}`);
|
|
2298
2586
|
}
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2587
|
+
// src/emitters/manifest/contextClient.ts
|
|
2588
|
+
function ci(e, t, n) {
|
|
2589
|
+
let r = t.module(`${e.directory}/client.ts`), i = `${e.typeName}Client`;
|
|
2590
|
+
r.imports.add(Y, ["CommandClient", "WowClientOptions"]), r.imports.add("./manifest.js", [`${e.typeName}Manifest`]);
|
|
2591
|
+
let a = [], o = [];
|
|
2592
|
+
for (let t of e.aggregates) {
|
|
2593
|
+
let e = t.typeName, i = (e) => L(r.directoryPath, v(n, t.directory, e)), s = [["commands", `${e}CommandClient`]];
|
|
2594
|
+
t.queryModels.includes("snapshot") && s.push(["snapshots", `${e}SnapshotQueryClient`]), t.queryModels.includes("events") && s.push(["events", `${e}EventQueryClient`]), s.push(["state", `${e}StateClient`]), r.imports.add(i("commandClient.ts"), [`${e}CommandClient`]), r.imports.add(i("queryClient.ts"), s.slice(1).map(([, e]) => e));
|
|
2595
|
+
let c = D(T(t.name));
|
|
2596
|
+
a.push(`${X([`The clients of \`${t.context}.${t.name}\`.`], " ")} readonly ${c}: {\n${s.map(([e, t]) => ` readonly ${e}: ${t};`).join("\n")}\n };`), o.push(` this.${c} = {\n${s.map(([e, t]) => ` ${e}: new ${t}(options),`).join("\n")}\n };`);
|
|
2597
|
+
}
|
|
2598
|
+
e.routes.length > 0 && (r.imports.add("./routes.js", [`${e.typeName}Routes`]), a.push(`${X([`The service routes of \`${e.name}\`.`], " ")} readonly routes: ${e.typeName}Routes;`), o.push(` this.routes = new ${e.typeName}Routes(options);`)), Z(r, `${X([e.routes.length === 0 ? `The clients of \`${e.name}\`: its command client, and per aggregate its command, query and state clients.` : `The clients of \`${e.name}\`: its command client, per aggregate its command, query and state clients, and its service routes.`])}export class ${i} {\n /** Sends any command of the service, by its Manifest's routes: \`send\`, \`wait\` and \`stream\`. */\n readonly commands: CommandClient;\n\n${a.join("\n\n")}\n\n /** @param options - How the service is reached */\n constructor(options?: WowClientOptions) {\n this.commands = new CommandClient(options, { manifest: ${e.typeName}Manifest });\n${o.join("\n")}\n }\n}`);
|
|
2599
|
+
}
|
|
2600
|
+
// src/emitters/manifest/queryClient.ts
|
|
2601
|
+
function li(e, t, n, r) {
|
|
2602
|
+
let i = t.module(`${e.directory}/queryClient.ts`), a = e.typeName, o = e.stateType, s = e.idSource === "owner", c = s ? "OwnStateClient" : "StateClient", l = [c, "WowClientOptions"], u = [
|
|
2603
|
+
`${a}Access`,
|
|
2604
|
+
`${a}Aggregate`,
|
|
2605
|
+
`${a}Event`
|
|
2606
|
+
], d = ` /** @param options - How the service is reached */\n constructor(options?: WowClientOptions) {\n super(${a}Aggregate, options);\n }`;
|
|
2607
|
+
e.queryModels.includes("snapshot") && (l.push("SnapshotQueryClient"), u.push(`${a}StateField`), Z(i, `${X([`Queries the snapshots of \`${e.context}.${e.name}\`: \`POST /${e.context}/${e.name}/snapshot/query\`.`])}export class ${a}SnapshotQueryClient extends SnapshotQueryClient<${o}, ${a}StateField, ${a}Access> {\n${d}\n}`)), e.queryModels.includes("events") && (l.push("EventQueryClient"), Z(i, `${X([`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, ${a}Access> {\n${d}\n}`)), Z(i, `${X([s ? `Reads the states of \`${e.context}.${e.name}\`, at a version or a time, and their traces: the caller's own by no id (\`readOwn\`, \`getOwn\`, \`findOwn\`, \`traceOwn\`: \`GET /${e.context}/${e.name}/state\`), and by id for a caller with no owner (\`GET /${e.context}/${e.name}/{id}/state\`).` : `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 ${c}<${o}, ${a}Event, ${a}Access> {\n${d}\n}`), i.imports.add(Y, l.sort()), i.imports.add("./aggregate.js", u), Q(i, r, n, [o]);
|
|
2608
|
+
}
|
|
2609
|
+
// src/emitters/manifest/routing.ts
|
|
2610
|
+
function ui(e, t) {
|
|
2611
|
+
let n = t.module(`${e.directory}/manifest.ts`), r = `${e.typeName}Manifest`;
|
|
2612
|
+
n.imports.add(Y, ["MANIFEST_FORMAT", "RoutingManifest"]);
|
|
2613
|
+
let i = (e, t, n) => ` { name: ${O(e)}, routes: ${di(t)}${n === void 0 ? "" : `, idProperty: ${O(n)}`} },`, a = e.aggregates.map((e) => {
|
|
2614
|
+
let t = [...e.commands.filter((e) => e.routes.length > 0).map((e) => i(e.name, e.routes, e.idProperty)), ...e.lifecycle.map((e) => i(e.name, e.routes))];
|
|
2615
|
+
return ` {\n name: ${O(e.name)},\n commands: [\n${t.join("\n")}\n ],\n },`;
|
|
2616
|
+
}), o = e.routes.map((e) => ` { name: ${O(e.name)}, route: { method: ${O(e.method)}, path: ${O(e.path)} } },`), s = o.length === 0 ? "" : ` routes: [\n${o.join("\n")}\n ],\n`;
|
|
2617
|
+
Z(n, `${X([o.length === 0 ? `The routes of \`${e.name}\`'s commands, as its Manifest lists them: what its command clients send by, with no Manifest fetched and no schema.` : `The routes of \`${e.name}\`'s commands and service routes, as its Manifest lists them: what its clients send by, with no Manifest fetched and no schema.`])}export const ${r}: RoutingManifest = {\n format: MANIFEST_FORMAT,\n contexts: [\n {\n name: ${O(e.name)},\n aggregates: [\n${a.join("\n")}\n ],\n${s} },\n ],\n};`);
|
|
2618
|
+
}
|
|
2619
|
+
function di(e) {
|
|
2620
|
+
return `[${e.map((e) => `{ method: ${O(e.method)}, path: ${O(e.path)} }`).join(", ")}]`;
|
|
2621
|
+
}
|
|
2622
|
+
// src/emitters/manifest/serviceRoutes.ts
|
|
2623
|
+
function fi(e, t, n, r) {
|
|
2624
|
+
if (e.routes.length === 0) return;
|
|
2625
|
+
let i = t.module(`${e.directory}/routes.ts`), a = `${e.typeName}Routes`;
|
|
2626
|
+
i.imports.add(Y, ["RequestOptions", "WowClientOptions"]), i.imports.add(qr, ["ServiceRoutes"]), i.imports.add("./manifest.js", [`${e.typeName}Manifest`]), Q(i, r, n, e.routes.flatMap((e) => [
|
|
2627
|
+
e.requestType,
|
|
2628
|
+
e.responseType,
|
|
2629
|
+
...e.parameters.map((e) => e.type)
|
|
2630
|
+
].filter((e) => e !== void 0).flatMap((e) => e.match(/[A-Za-z_$][A-Za-z0-9_$]*/g) ?? [])));
|
|
2631
|
+
let o = e.routes.map((t) => pi(e, t));
|
|
2632
|
+
Z(i, `${X([`The service routes of \`${e.name}\`: routes whose handler is the service's own code, each called by its Manifest's name.`])}export class ${a} {\n /** Calls any route of the service by its name. */\n readonly routes: ServiceRoutes;\n\n /** @param options - How the service is reached */\n constructor(options?: WowClientOptions) {\n this.routes = new ServiceRoutes(options, { manifest: ${e.typeName}Manifest${ei(e, {
|
|
2633
|
+
module: i,
|
|
2634
|
+
outputDir: r,
|
|
2635
|
+
client: Y
|
|
2636
|
+
})} });\n }\n\n${o.join("\n\n")}\n}`);
|
|
2637
|
+
}
|
|
2638
|
+
function pi(e, t) {
|
|
2639
|
+
let n = t.parameters.filter((e) => e.location === "path"), r = t.parameters.filter((e) => e.location === "query"), i = n.map((e) => `${e.identifier}: ${e.type}`);
|
|
2640
|
+
if (t.requestType !== void 0 && i.push(`body: ${t.requestType}`), r.length > 0) {
|
|
2641
|
+
let e = r.map((e) => `readonly ${D(e.name)}${e.required ? "" : "?"}: ${e.type}`).join("; "), t = r.some((e) => e.required);
|
|
2642
|
+
i.push(`query${t ? "" : "?"}: { ${e} }`);
|
|
2643
|
+
}
|
|
2644
|
+
i.push("options?: RequestOptions");
|
|
2645
|
+
let a = t.responseType ?? "void", o = [
|
|
2646
|
+
...n.length === 0 ? [] : [`path: { ${n.map((e) => e.identifier === e.name ? e.name : `${D(e.name)}: ${e.identifier}`).join(", ")} }`],
|
|
2647
|
+
...t.requestType === void 0 ? [] : ["body"],
|
|
2648
|
+
...r.length === 0 ? [] : ["query"]
|
|
2649
|
+
];
|
|
2650
|
+
return `${X([
|
|
2651
|
+
t.description,
|
|
2652
|
+
`\`${t.method} ${t.path}\``,
|
|
2653
|
+
t.deprecated ? "@deprecated The service deprecates this route." : void 0
|
|
2654
|
+
], " ")} ${D(t.name)}(${i.join(", ")}): Promise<${a}> {\n return this.routes.call(${O(e.name)}, ${O(t.name)}, { ${o.join(", ")} }, options) as Promise<${a}>;\n }`;
|
|
2655
|
+
}
|
|
2656
|
+
// src/emitters/manifest/typeDeclarations.ts
|
|
2657
|
+
function mi(e, t, n, r) {
|
|
2658
|
+
Q(e, r, n, t.references, t.file);
|
|
2659
|
+
let i = X([t.description, `- key: \`${t.key}\``]);
|
|
2660
|
+
if (t.properties === void 0) {
|
|
2661
|
+
Z(e, `${i}export type ${t.name} = ${t.type};`);
|
|
2662
|
+
return;
|
|
2663
|
+
}
|
|
2664
|
+
let a = t.properties.map((e) => `${X([e.description], " ")} ${e.name}${e.optional ? "?" : ""}: ${e.type};`);
|
|
2665
|
+
t.type !== void 0 && a.push(` [key: string]: ${t.type};`), Z(e, `${i}export interface ${t.name} {\n${a.join("\n")}\n}`);
|
|
2666
|
+
}
|
|
2667
|
+
// src/emitters/manifestClients.ts
|
|
2668
|
+
function hi(e, t, n) {
|
|
2669
|
+
let r = new Map(e.types.map((e) => [e.name, e.file]));
|
|
2670
|
+
for (let i of e.types) mi(t.module(i.file), i, r, n);
|
|
2671
|
+
for (let i of e.contexts) {
|
|
2672
|
+
Zr(i, t, n);
|
|
2673
|
+
for (let e of i.aggregates) ni(e, i, t, r, n), si(e, i, t, r, n), li(e, t, r, n);
|
|
2674
|
+
ui(i, t), ti(i, t, n, Y), fi(i, t, r, n), ci(i, t, n);
|
|
2675
|
+
}
|
|
2302
2676
|
}
|
|
2303
2677
|
// src/openapi/document.ts
|
|
2304
|
-
function
|
|
2678
|
+
function gi(e) {
|
|
2305
2679
|
return {
|
|
2306
2680
|
openAPI: e,
|
|
2307
2681
|
components: e.components,
|
|
2308
|
-
endpoints:
|
|
2682
|
+
endpoints: nt(e.paths, e.components)
|
|
2309
2683
|
};
|
|
2310
2684
|
}
|
|
2311
2685
|
// src/output/outputStore.ts
|
|
2312
|
-
var
|
|
2686
|
+
var _i = ".wow-generator.json", vi = class e {
|
|
2313
2687
|
project;
|
|
2314
2688
|
outputPath;
|
|
2315
2689
|
outputDir;
|
|
@@ -2322,12 +2696,12 @@ var qr = ".wow-generator.json", Jr = class e {
|
|
|
2322
2696
|
static open(t, n, r) {
|
|
2323
2697
|
let i = t.getFileSystem(), a = n;
|
|
2324
2698
|
n = p(i.getCurrentDirectory(), n);
|
|
2325
|
-
let o = d(n,
|
|
2699
|
+
let o = d(n, _i), s = /* @__PURE__ */ new Map();
|
|
2326
2700
|
if (i.fileExistsSync(o)) {
|
|
2327
|
-
let e =
|
|
2701
|
+
let e = yi(o, i.readFileSync(o));
|
|
2328
2702
|
for (let [t, r] of Object.entries(e.files)) {
|
|
2329
2703
|
let e = p(n, t);
|
|
2330
|
-
if (
|
|
2704
|
+
if (Ci(n, e), u(t) || !t.endsWith(".ts") || typeof r != "string" || !/^[a-f0-9]{64}$/.test(r)) throw new b("output", `Invalid generated file entry in ${o}: ${t}`);
|
|
2331
2705
|
s.set(e, r);
|
|
2332
2706
|
}
|
|
2333
2707
|
}
|
|
@@ -2339,8 +2713,8 @@ var qr = ".wow-generator.json", Jr = class e {
|
|
|
2339
2713
|
return this.written;
|
|
2340
2714
|
}
|
|
2341
2715
|
claim(e, t = this.outputPath) {
|
|
2342
|
-
let n =
|
|
2343
|
-
|
|
2716
|
+
let n = me(t, e);
|
|
2717
|
+
Ci(t, n);
|
|
2344
2718
|
let r = this.project.getSourceFile(n) ?? this.project.createSourceFile(n, "", { overwrite: !0 }), i = r.getFilePath();
|
|
2345
2719
|
return this.written.has(i) || (r.removeText(), this.written.add(i)), r;
|
|
2346
2720
|
}
|
|
@@ -2351,64 +2725,64 @@ var qr = ".wow-generator.json", Jr = class e {
|
|
|
2351
2725
|
async commit(e) {
|
|
2352
2726
|
e?.throwIfAborted();
|
|
2353
2727
|
let t = this.project.getFileSystem(), n = new Set([...this.written].map((e) => e.toLowerCase()));
|
|
2354
|
-
for (let e of this.stale) !this.written.has(e) && n.has(e.toLowerCase()) && this.isUnchanged(e, this.previous.get(e)) && (await
|
|
2728
|
+
for (let e of this.stale) !this.written.has(e) && n.has(e.toLowerCase()) && this.isUnchanged(e, this.previous.get(e)) && (await Si("delete", e, () => t.delete(e)), this.stale.delete(e));
|
|
2355
2729
|
let r = [...this.written].sort().map((e) => this.project.getSourceFileOrThrow(e));
|
|
2356
2730
|
(await Promise.allSettled(r.map((e) => e.save()))).forEach((e, t) => {
|
|
2357
|
-
if (e.status === "rejected") throw
|
|
2731
|
+
if (e.status === "rejected") throw xi("write", r[t].getFilePath(), e.reason);
|
|
2358
2732
|
}), e?.throwIfAborted();
|
|
2359
|
-
for (let e of this.stale) !this.written.has(e) && this.isUnchanged(e, this.previous.get(e)) && await
|
|
2360
|
-
let i = d(this.outputDir,
|
|
2733
|
+
for (let e of this.stale) !this.written.has(e) && this.isUnchanged(e, this.previous.get(e)) && await Si("delete", e, () => t.delete(e));
|
|
2734
|
+
let i = d(this.outputDir, _i), a = JSON.stringify({
|
|
2361
2735
|
version: 1,
|
|
2362
|
-
files: Object.fromEntries(r.map((e) => [f(this.outputDir, e.getFilePath()).split(m).join("/"),
|
|
2736
|
+
files: Object.fromEntries(r.map((e) => [f(this.outputDir, e.getFilePath()).split(m).join("/"), bi(t.readFileSync(e.getFilePath()))]))
|
|
2363
2737
|
}, null, 2) + "\n";
|
|
2364
|
-
await
|
|
2738
|
+
await Si("write", i, async () => {
|
|
2365
2739
|
t.mkdirSync(this.outputDir), await t.writeFile(i, a);
|
|
2366
2740
|
});
|
|
2367
2741
|
}
|
|
2368
2742
|
isUnchanged(e, t) {
|
|
2369
2743
|
let n = this.project.getFileSystem();
|
|
2370
|
-
return n.fileExistsSync(e) ? (
|
|
2744
|
+
return n.fileExistsSync(e) ? (Ci(n.realpathSync(this.outputDir), n.realpathSync(e)), bi(n.readFileSync(e)) === t) : !1;
|
|
2371
2745
|
}
|
|
2372
2746
|
};
|
|
2373
|
-
function
|
|
2747
|
+
function yi(e, t) {
|
|
2374
2748
|
let n = "delete it; without it this run cannot remove the stale files of the last run", r;
|
|
2375
2749
|
try {
|
|
2376
2750
|
r = JSON.parse(t);
|
|
2377
2751
|
} catch (t) {
|
|
2378
|
-
throw new
|
|
2752
|
+
throw new b("output", `Cannot parse the generation manifest ${e}: ${x(t)}. Resolve the merge conflict in it if it has one, or ${n}.`, { cause: t });
|
|
2379
2753
|
}
|
|
2380
2754
|
let i = r?.version;
|
|
2381
|
-
if (typeof i == "number" && Number.isInteger(i) && i > 1) throw new
|
|
2382
|
-
if (i !== 1 || !r.files || typeof r.files != "object" || Array.isArray(r.files)) throw new
|
|
2755
|
+
if (typeof i == "number" && Number.isInteger(i) && i > 1) throw new b("output", `The generation manifest ${e} was written by a newer wow-generator (manifest version ${i}); this one reads version 1. Upgrade wow-generator.`);
|
|
2756
|
+
if (i !== 1 || !r.files || typeof r.files != "object" || Array.isArray(r.files)) throw new b("output", `Invalid generation manifest ${e}: expected "version": 1 and a "files" object. Restore it from version control, or ${n}.`);
|
|
2383
2757
|
return r;
|
|
2384
2758
|
}
|
|
2385
|
-
function
|
|
2759
|
+
function bi(e) {
|
|
2386
2760
|
if (!l.sys.createSHA256Hash) throw Error("SHA-256 hashing is unavailable in this environment.");
|
|
2387
2761
|
return l.sys.createSHA256Hash(e);
|
|
2388
2762
|
}
|
|
2389
|
-
function
|
|
2390
|
-
return n instanceof
|
|
2763
|
+
function xi(e, t, n) {
|
|
2764
|
+
return n instanceof b ? n : new b("output", `Cannot ${e} ${t}: ${x(n)}`, { cause: n });
|
|
2391
2765
|
}
|
|
2392
|
-
async function
|
|
2766
|
+
async function Si(e, t, n) {
|
|
2393
2767
|
try {
|
|
2394
2768
|
await n();
|
|
2395
2769
|
} catch (n) {
|
|
2396
|
-
throw
|
|
2770
|
+
throw xi(e, t, n);
|
|
2397
2771
|
}
|
|
2398
2772
|
}
|
|
2399
|
-
function
|
|
2773
|
+
function Ci(e, t) {
|
|
2400
2774
|
let n = t.split("/").join(m), r = p(e), i = p(n), a = f(r, i);
|
|
2401
|
-
if (a === "" || a.startsWith("..") || u(a)) throw new
|
|
2775
|
+
if (a === "" || a.startsWith("..") || u(a)) throw new b("output", `Path traversal detected: "${t}" resolves outside the output directory "${e}".`);
|
|
2402
2776
|
}
|
|
2403
2777
|
// src/pipeline/seams.ts
|
|
2404
|
-
var
|
|
2778
|
+
var wi = Symbol("project"), Ti = Symbol("signal"), Ei = class {
|
|
2405
2779
|
options;
|
|
2406
2780
|
project;
|
|
2407
2781
|
logger;
|
|
2408
2782
|
signal;
|
|
2409
2783
|
output;
|
|
2410
2784
|
constructor(e) {
|
|
2411
|
-
this.options = e, this.logger = e.logger ?? new
|
|
2785
|
+
this.options = e, this.logger = e.logger ?? new ne(), this.signal = e[Ti], this.project = e[wi] ?? Di(e.tsConfigFilePath), this.project.manipulationSettings.set({
|
|
2412
2786
|
indentationText: t.TwoSpaces,
|
|
2413
2787
|
quoteKind: i.Single,
|
|
2414
2788
|
useTrailingCommas: !0
|
|
@@ -2423,57 +2797,57 @@ var ei = Symbol("project"), ti = Symbol("signal"), ni = class {
|
|
|
2423
2797
|
headers: n.headers,
|
|
2424
2798
|
timeoutMs: n.timeoutMs,
|
|
2425
2799
|
signal: t
|
|
2426
|
-
}, o = await
|
|
2800
|
+
}, o = await Yn(n.configPath, e, a);
|
|
2427
2801
|
i(o.warnings), t?.throwIfAborted(), e.debug("Parsing the input document");
|
|
2428
|
-
let s = await
|
|
2429
|
-
if (t?.throwIfAborted(),
|
|
2430
|
-
let c =
|
|
2802
|
+
let s = await Gn(n.inputPath, a);
|
|
2803
|
+
if (t?.throwIfAborted(), sr(s)) return this.generateFromManifest(cr(s, n.inputPath), o.origin, i, () => r);
|
|
2804
|
+
let c = Kn(s, n.inputPath);
|
|
2431
2805
|
e.debug("OpenAPI specification parsed successfully");
|
|
2432
|
-
let l =
|
|
2433
|
-
if (l.length > 0) throw new
|
|
2434
|
-
let u =
|
|
2806
|
+
let l = ve(c);
|
|
2807
|
+
if (l.length > 0) throw new b("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 ? ", …" : ""}`);
|
|
2808
|
+
let u = gi(c), d = vi.open(this.project, n.outputDir, this.output);
|
|
2435
2809
|
this.output = d, e.debug("Analysing the document");
|
|
2436
|
-
let f =
|
|
2810
|
+
let f = yt(u, o.config);
|
|
2437
2811
|
i(f.warnings), e.debug("Writing generated modules");
|
|
2438
|
-
let p = new
|
|
2439
|
-
|
|
2812
|
+
let p = new St((e) => d.claim(e));
|
|
2813
|
+
Tn(f.model, {
|
|
2440
2814
|
modules: p,
|
|
2441
2815
|
outputDir: n.outputDir,
|
|
2442
|
-
types:
|
|
2816
|
+
types: xn(u.components),
|
|
2443
2817
|
schemaDocs: n.schemaDocs ?? "summary"
|
|
2444
2818
|
}), p.build(), e.debug("Generated modules written"), d.forgetStale();
|
|
2445
2819
|
let m = this.project.getDirectory(n.outputDir);
|
|
2446
|
-
return m ? (e.debug("Generating index files"), i(
|
|
2820
|
+
return m ? (e.debug("Generating index files"), i(En(m, (e) => d.claim("index.ts", e))), e.debug("Optimizing source files"), Rn(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"), {
|
|
2447
2821
|
files: [...d.files].sort(),
|
|
2448
2822
|
configPath: o.origin,
|
|
2449
2823
|
warnings: r
|
|
2450
2824
|
};
|
|
2451
2825
|
}
|
|
2452
2826
|
async generateFromManifest(e, t, n, r) {
|
|
2453
|
-
let { logger: i, signal: a, options: o } = this, s =
|
|
2827
|
+
let { logger: i, signal: a, options: o } = this, s = vi.open(this.project, o.outputDir, this.output);
|
|
2454
2828
|
this.output = s, i.debug("Analysing the Manifest");
|
|
2455
|
-
let c =
|
|
2829
|
+
let c = Wr(e);
|
|
2456
2830
|
n(c.warnings);
|
|
2457
|
-
let l = new
|
|
2458
|
-
|
|
2831
|
+
let l = new St((e) => s.claim(e));
|
|
2832
|
+
hi(c.model, l, o.outputDir), l.build(), s.forgetStale();
|
|
2459
2833
|
let u = this.project.getDirectory(o.outputDir);
|
|
2460
|
-
return u && (n(
|
|
2834
|
+
return u && (n(En(u, (e) => s.claim("index.ts", e))), Rn(u.getDescendantSourceFiles().filter((e) => s.files.has(e.getFilePath())), i)), await s.commit(a), i.debug("Code generation from the Manifest completed successfully"), {
|
|
2461
2835
|
files: [...s.files].sort(),
|
|
2462
2836
|
configPath: t,
|
|
2463
2837
|
warnings: r()
|
|
2464
2838
|
};
|
|
2465
2839
|
}
|
|
2466
2840
|
};
|
|
2467
|
-
function
|
|
2841
|
+
function Di(e) {
|
|
2468
2842
|
try {
|
|
2469
2843
|
return new r({
|
|
2470
2844
|
tsConfigFilePath: e,
|
|
2471
2845
|
skipAddingFilesFromTsConfig: !0
|
|
2472
2846
|
});
|
|
2473
2847
|
} catch (t) {
|
|
2474
|
-
throw new
|
|
2848
|
+
throw new b("configuration", `Cannot read the TypeScript configuration ${e}: ${x(t)}`, { cause: t });
|
|
2475
2849
|
}
|
|
2476
2850
|
}
|
|
2477
|
-
export {
|
|
2851
|
+
export { re as a, y as c, ne as i, Ti as n, ee as o, zn as r, b as s, Ei as t };
|
|
2478
2852
|
|
|
2479
|
-
//# sourceMappingURL=codeGenerator-
|
|
2853
|
+
//# sourceMappingURL=codeGenerator-CXowDsB9.js.map
|