@apiuikit/web-component 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -5
- package/dist/CodeSamples-CvGJUENN-CR16fFmG.js +4234 -0
- package/dist/LinkedInExtension-BL-4T9tt-CwUePUjv.js +21 -0
- package/dist/LogoExtension-BCPMpWxf-CD0UVJhy.js +16 -0
- package/dist/XExtension-GyRtdHLL-DPPkXhkP.js +23 -0
- package/dist/c-Bz1-FJiA-CwNanOv1.js +277 -0
- package/dist/clojure-aY2138WD-CzZhvUkO.js +135 -0
- package/dist/crystal-BtD5fR4q-B1F7Ovrt.js +283 -0
- package/dist/csharp-AnFv7wyC-DBJ0ahb9.js +382 -0
- package/dist/elements/asyncapi-info.d.ts +7 -0
- package/dist/elements/asyncapi-info.js +17 -0
- package/dist/elements/asyncapi-messages.d.ts +7 -0
- package/dist/elements/asyncapi-messages.js +17 -0
- package/dist/elements/asyncapi-operations.d.ts +7 -0
- package/dist/elements/asyncapi-operations.js +17 -0
- package/dist/elements/asyncapi-renderer.d.ts +7 -0
- package/dist/elements/asyncapi-renderer.js +17 -0
- package/dist/elements/asyncapi-servers.d.ts +7 -0
- package/dist/elements/asyncapi-servers.js +17 -0
- package/dist/elements/asyncapi.d.ts +7 -0
- package/dist/elements/asyncapi.js +17 -0
- package/dist/elements/openapi-endpoints.d.ts +7 -0
- package/dist/elements/openapi-endpoints.js +17 -0
- package/dist/elements/openapi-info.d.ts +7 -0
- package/dist/elements/openapi-info.js +17 -0
- package/dist/elements/openapi-renderer.d.ts +7 -0
- package/dist/elements/openapi-renderer.js +17 -0
- package/dist/elements/openapi-servers.d.ts +7 -0
- package/dist/elements/openapi-servers.js +17 -0
- package/dist/elements/openapi-webhooks.d.ts +7 -0
- package/dist/elements/openapi-webhooks.js +17 -0
- package/dist/elements/openapi.d.ts +7 -0
- package/dist/elements/openapi.js +17 -0
- package/dist/elements/schemas.d.ts +7 -0
- package/dist/elements/schemas.js +17 -0
- package/dist/go-CkZ9_bn0-BavTPlHs.js +151 -0
- package/dist/http-DKeNlJKS-CncZekYb.js +85 -0
- package/dist/index-227TxMRF-BYlp71U_.js +25403 -0
- package/dist/index-Bf4YsziL-DPjrM_Iz.js +17529 -0
- package/dist/index-DCDYBZcY-B5md4zhj.js +1459 -0
- package/dist/java-BicX26Pg-BE9j1hqd.js +240 -0
- package/dist/kotlin-BwB8b-YX-DrhZ7rRS.js +242 -0
- package/dist/objectivec-CnyrJ13Z-crbGiB8Q.js +237 -0
- package/dist/ocaml-T8IqWCjo-T8IqWCjo.js +67 -0
- package/dist/php-BL35ZHWM-BVESXHm8.js +566 -0
- package/dist/powershell-DuhUKWoO-BkKc-lpt.js +236 -0
- package/dist/protoToJsonSchema-nTI0cRt8-B1zlLwd7.js +6127 -0
- package/dist/protobufSchemaParser-ChAv0AAl-DDsAdtNH.js +55 -0
- package/dist/r-B8fCBydS-B8fCBydS.js +207 -0
- package/dist/registerElement-DAVqIcyy.js +25412 -0
- package/dist/ruby-CvOid-1s-CANQXRsZ.js +386 -0
- package/dist/rust-BocnJ3Ns-BBcgTcYY.js +305 -0
- package/dist/swift-C35Eof-I-CeYSuGtY.js +799 -0
- package/dist/web-component.css +1 -1
- package/dist/web-component.es.js +20617 -20262
- package/dist/web-component.iife.js +329 -326
- package/package.json +57 -5
- package/dist/adapters.d.ts +0 -25
|
@@ -0,0 +1,1459 @@
|
|
|
1
|
+
var be = Object.defineProperty, $e = (e, t, n) => t in e ? be(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, we = (e, t, n) => $e(e, t + "", n);
|
|
2
|
+
function Oe(e) {
|
|
3
|
+
let t = e | 0;
|
|
4
|
+
return () => {
|
|
5
|
+
t = t + 1831565813 | 0;
|
|
6
|
+
let n = Math.imul(t ^ t >>> 15, 1 | t);
|
|
7
|
+
return n = n + Math.imul(n ^ n >>> 7, 61 | n) ^ n, ((n ^ n >>> 14) >>> 0) / 4294967296;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function le(e) {
|
|
11
|
+
let t = Oe(e), n = { next() {
|
|
12
|
+
return t();
|
|
13
|
+
}, int(r, i) {
|
|
14
|
+
return r + Math.floor(n.next() * (i - r + 1));
|
|
15
|
+
}, bool(r = 0.5) {
|
|
16
|
+
return n.next() < r;
|
|
17
|
+
}, pick(r) {
|
|
18
|
+
return r[n.int(0, r.length - 1)];
|
|
19
|
+
}, shuffle(r) {
|
|
20
|
+
let i = [...r];
|
|
21
|
+
for (let o = i.length - 1; o > 0; o--) {
|
|
22
|
+
let a = n.int(0, o);
|
|
23
|
+
[i[o], i[a]] = [i[a], i[o]];
|
|
24
|
+
}
|
|
25
|
+
return i;
|
|
26
|
+
}, fork() {
|
|
27
|
+
let r = Math.floor(n.next() * 4294967296);
|
|
28
|
+
return le(r);
|
|
29
|
+
} };
|
|
30
|
+
return n;
|
|
31
|
+
}
|
|
32
|
+
function je(e) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
function Pe(e) {
|
|
36
|
+
return e.random.bool();
|
|
37
|
+
}
|
|
38
|
+
function se(e, t, n = !1) {
|
|
39
|
+
let r = -1e3, i = 1e3, o = !1, a = !1;
|
|
40
|
+
if (e.minimum !== void 0 && (r = e.minimum), e.maximum !== void 0 && (i = e.maximum), e.exclusiveMinimum !== void 0 && (r = e.exclusiveMinimum, o = !0), e.exclusiveMaximum !== void 0 && (i = e.exclusiveMaximum, a = !0), e.multipleOf !== void 0) return ke(e.multipleOf, r, i, o, a, t);
|
|
41
|
+
if (n) {
|
|
42
|
+
let p = o ? Math.floor(r) + 1 : Math.ceil(r), y = a ? Math.ceil(i) - 1 : Math.floor(i);
|
|
43
|
+
return t.random.int(p, y);
|
|
44
|
+
}
|
|
45
|
+
let l = o ? r + Number.EPSILON : r, s = a ? i - Number.EPSILON : i;
|
|
46
|
+
return l + t.random.next() * (s - l);
|
|
47
|
+
}
|
|
48
|
+
function ke(e, t, n, r, i, o) {
|
|
49
|
+
let a = Math.ceil(t / e), l = Math.floor(n / e);
|
|
50
|
+
return r && a * e === t && a++, i && l * e === n && l--, a > l ? a * e : o.random.int(a, l) * e;
|
|
51
|
+
}
|
|
52
|
+
function Ie(e, t) {
|
|
53
|
+
if (e.autoIncrement) {
|
|
54
|
+
let n = e.initialOffset ?? 1, r = Me(t.path), i = t.autoIncrementCounters ?? /* @__PURE__ */ new Map(), o = (i.get(r) ?? n - 1) + 1;
|
|
55
|
+
return i.set(r, o), t.autoIncrementCounters && t.autoIncrementCounters.set(r, o), o;
|
|
56
|
+
}
|
|
57
|
+
return se(e, t, !0);
|
|
58
|
+
}
|
|
59
|
+
function Me(e) {
|
|
60
|
+
return e.split("/").filter((t) => t !== "" && !/^\d+$/.test(t)).join("/");
|
|
61
|
+
}
|
|
62
|
+
function B(e, t) {
|
|
63
|
+
let n = fe(e, 0);
|
|
64
|
+
return T(n.node, t);
|
|
65
|
+
}
|
|
66
|
+
function T(e, t) {
|
|
67
|
+
switch (e.type) {
|
|
68
|
+
case "literal":
|
|
69
|
+
return e.value;
|
|
70
|
+
case "dot":
|
|
71
|
+
return t.pick([..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#%&*()-_=+[]{}|;:',.<>/? "]);
|
|
72
|
+
case "anchor":
|
|
73
|
+
return "";
|
|
74
|
+
case "charClass":
|
|
75
|
+
return De(e, t);
|
|
76
|
+
case "sequence":
|
|
77
|
+
return e.nodes.map((n) => T(n, t)).join("");
|
|
78
|
+
case "alternation":
|
|
79
|
+
return T(t.pick(e.branches), t);
|
|
80
|
+
case "quantifier": {
|
|
81
|
+
let n = t.int(e.min, Math.min(e.max, e.min + 5));
|
|
82
|
+
return Array.from({ length: n }, () => T(e.node, t)).join("");
|
|
83
|
+
}
|
|
84
|
+
case "group":
|
|
85
|
+
return T(e.node, t);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function De(e, t) {
|
|
89
|
+
if (!e.negated) return t.pick(e.chars);
|
|
90
|
+
let n = new Set(e.chars), r = [..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#%&*()-_=+[]{}|;:',.<>/? "].filter((i) => !n.has(i));
|
|
91
|
+
return r.length > 0 ? t.pick(r) : "a";
|
|
92
|
+
}
|
|
93
|
+
function fe(e, t) {
|
|
94
|
+
let n = [], r = [];
|
|
95
|
+
for (; t < e.length; ) {
|
|
96
|
+
let i = e[t];
|
|
97
|
+
if (i === ")") break;
|
|
98
|
+
if (i === "|") {
|
|
99
|
+
n.push(G(r)), r = [], t++;
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (i === "(") {
|
|
103
|
+
let l = t + 1;
|
|
104
|
+
if (e[l] === "?") if (e[l + 1] === ":") l += 2;
|
|
105
|
+
else if (e[l + 1] === "=" || e[l + 1] === "!") {
|
|
106
|
+
let h = 1, $ = l;
|
|
107
|
+
for (; $ < e.length && h > 0; )
|
|
108
|
+
$++, e[$] === "(" && h++, e[$] === ")" && h--;
|
|
109
|
+
t = $ + 1;
|
|
110
|
+
continue;
|
|
111
|
+
} else {
|
|
112
|
+
for (l += 2; l < e.length && e[l] !== ">"; ) l++;
|
|
113
|
+
l++;
|
|
114
|
+
}
|
|
115
|
+
let s = fe(e, l), p = { type: "group", node: s.node };
|
|
116
|
+
t = s.pos + 1;
|
|
117
|
+
let y = N(e, t, p);
|
|
118
|
+
r.push(y.node), t = y.pos;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (i === "[") {
|
|
122
|
+
let l = Ae(e, t), s = N(e, l.pos, l.node);
|
|
123
|
+
r.push(s.node), t = s.pos;
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (i === ".") {
|
|
127
|
+
let l = { type: "dot" };
|
|
128
|
+
t++;
|
|
129
|
+
let s = N(e, t, l);
|
|
130
|
+
r.push(s.node), t = s.pos;
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (i === "^" || i === "$") {
|
|
134
|
+
r.push({ type: "anchor" }), t++;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (i === "\\") {
|
|
138
|
+
t++;
|
|
139
|
+
let l = Se(e, t);
|
|
140
|
+
t = l.pos;
|
|
141
|
+
let s = N(e, t, l.node);
|
|
142
|
+
r.push(s.node), t = s.pos;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
let o = { type: "literal", value: i };
|
|
146
|
+
t++;
|
|
147
|
+
let a = N(e, t, o);
|
|
148
|
+
r.push(a.node), t = a.pos;
|
|
149
|
+
}
|
|
150
|
+
return n.push(G(r)), { node: n.length === 1 ? n[0] : { type: "alternation", branches: n }, pos: t };
|
|
151
|
+
}
|
|
152
|
+
function G(e) {
|
|
153
|
+
return e.length === 0 ? { type: "literal", value: "" } : e.length === 1 ? e[0] : { type: "sequence", nodes: e };
|
|
154
|
+
}
|
|
155
|
+
function Se(e, t) {
|
|
156
|
+
let n = e[t];
|
|
157
|
+
switch (t++, n) {
|
|
158
|
+
case "d":
|
|
159
|
+
return { node: { type: "charClass", chars: [..."0123456789"], negated: !1 }, pos: t };
|
|
160
|
+
case "D":
|
|
161
|
+
return { node: { type: "charClass", chars: [..."0123456789"], negated: !0 }, pos: t };
|
|
162
|
+
case "w":
|
|
163
|
+
return { node: { type: "charClass", chars: [..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"], negated: !1 }, pos: t };
|
|
164
|
+
case "W":
|
|
165
|
+
return { node: { type: "charClass", chars: [..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"], negated: !0 }, pos: t };
|
|
166
|
+
case "s":
|
|
167
|
+
return { node: { type: "charClass", chars: [...`
|
|
168
|
+
`], negated: !1 }, pos: t };
|
|
169
|
+
case "S":
|
|
170
|
+
return { node: { type: "charClass", chars: [...`
|
|
171
|
+
`], negated: !0 }, pos: t };
|
|
172
|
+
case "b":
|
|
173
|
+
case "B":
|
|
174
|
+
return { node: { type: "anchor" }, pos: t };
|
|
175
|
+
default:
|
|
176
|
+
return { node: { type: "literal", value: n }, pos: t };
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function Ae(e, t) {
|
|
180
|
+
t++;
|
|
181
|
+
let n = !1;
|
|
182
|
+
e[t] === "^" && (n = !0, t++);
|
|
183
|
+
let r = [];
|
|
184
|
+
for (; t < e.length && e[t] !== "]"; ) {
|
|
185
|
+
if (e[t] === "\\" && t + 1 < e.length) {
|
|
186
|
+
t++;
|
|
187
|
+
let i = e[t];
|
|
188
|
+
switch (i) {
|
|
189
|
+
case "d":
|
|
190
|
+
r.push(..."0123456789");
|
|
191
|
+
break;
|
|
192
|
+
case "w":
|
|
193
|
+
r.push(..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_");
|
|
194
|
+
break;
|
|
195
|
+
case "s":
|
|
196
|
+
r.push(...`
|
|
197
|
+
`);
|
|
198
|
+
break;
|
|
199
|
+
default:
|
|
200
|
+
r.push(i);
|
|
201
|
+
}
|
|
202
|
+
t++;
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
if (t + 2 < e.length && e[t + 1] === "-" && e[t + 2] !== "]") {
|
|
206
|
+
let i = e.charCodeAt(t), o = e.charCodeAt(t + 2);
|
|
207
|
+
for (let a = i; a <= o; a++) r.push(String.fromCharCode(a));
|
|
208
|
+
t += 3;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
r.push(e[t]), t++;
|
|
212
|
+
}
|
|
213
|
+
return t++, { node: { type: "charClass", chars: r, negated: n }, pos: t };
|
|
214
|
+
}
|
|
215
|
+
function N(e, t, n) {
|
|
216
|
+
if (t >= e.length) return { node: n, pos: t };
|
|
217
|
+
let r = e[t], i, o;
|
|
218
|
+
switch (r) {
|
|
219
|
+
case "*":
|
|
220
|
+
i = 0, o = 5, t++;
|
|
221
|
+
break;
|
|
222
|
+
case "+":
|
|
223
|
+
i = 1, o = 5, t++;
|
|
224
|
+
break;
|
|
225
|
+
case "?":
|
|
226
|
+
i = 0, o = 1, t++;
|
|
227
|
+
break;
|
|
228
|
+
case "{": {
|
|
229
|
+
let a = Le(e, t);
|
|
230
|
+
if (a) i = a.min, o = a.max, t = a.pos;
|
|
231
|
+
else return { node: n, pos: t };
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
default:
|
|
235
|
+
return { node: n, pos: t };
|
|
236
|
+
}
|
|
237
|
+
return t < e.length && (e[t] === "?" || e[t] === "+") && t++, { node: { type: "quantifier", node: n, min: i, max: o }, pos: t };
|
|
238
|
+
}
|
|
239
|
+
function Le(e, t) {
|
|
240
|
+
let n = e.slice(t).match(/^\{(\d+)(?:,(\d*))?\}/);
|
|
241
|
+
if (!n) return null;
|
|
242
|
+
let r = parseInt(n[1], 10), i;
|
|
243
|
+
return n[2] === void 0 ? i = r : n[2] === "" ? i = r + 5 : i = parseInt(n[2], 10), { min: r, max: i, pos: t + n[0].length };
|
|
244
|
+
}
|
|
245
|
+
function I(e) {
|
|
246
|
+
return e < 10 ? `0${e}` : `${e}`;
|
|
247
|
+
}
|
|
248
|
+
function Ee(e, t) {
|
|
249
|
+
return new Date(e, t, 0).getDate();
|
|
250
|
+
}
|
|
251
|
+
var ue = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
252
|
+
function Ne(e) {
|
|
253
|
+
return !(e === "^" || e === "$" || e === "^$");
|
|
254
|
+
}
|
|
255
|
+
function Te(e, t) {
|
|
256
|
+
if (e.format) {
|
|
257
|
+
if (e.format === "date-time" && (t.minDateTime !== void 0 || t.maxDateTime !== void 0)) return qe(t);
|
|
258
|
+
let a = t.formatRegistry.get(e.format);
|
|
259
|
+
if (a) {
|
|
260
|
+
let l = a(t.random), s = t.minLength ?? e.minLength, p = t.maxLength ?? e.maxLength;
|
|
261
|
+
return s !== void 0 && l.length < s ? R(l, s, t) : p !== void 0 && l.length > p ? l.slice(0, p) : l;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
if (e.pattern) {
|
|
265
|
+
let a = t.minLength ?? e.minLength, l = t.maxLength ?? e.maxLength;
|
|
266
|
+
for (let y = 0; y < 50; y++) {
|
|
267
|
+
let h = B(e.pattern, t.random);
|
|
268
|
+
if (!(a !== void 0 && h.length < a) && !(l !== void 0 && h.length > l))
|
|
269
|
+
return h;
|
|
270
|
+
}
|
|
271
|
+
let s = B(e.pattern, t.random), p = Ne(e.pattern);
|
|
272
|
+
return a !== void 0 && s.length < a && p ? R(s, a, t) : l !== void 0 && s.length > l ? s.slice(0, l) : s;
|
|
273
|
+
}
|
|
274
|
+
let n = e.minLength ?? 0, r = e.maxLength ?? Math.max(n + 10, 10), i = t.random.int(n, r), o = "";
|
|
275
|
+
for (let a = 0; a < i; a++) o += t.random.pick([...ue]);
|
|
276
|
+
return t.maxLength !== void 0 && o.length > t.maxLength && (o = o.slice(0, t.maxLength)), t.minLength !== void 0 && o.length < t.minLength && (o = R(o, t.minLength, t)), o;
|
|
277
|
+
}
|
|
278
|
+
function R(e, t, n) {
|
|
279
|
+
for (; e.length < t; ) e += n.random.pick([...ue]);
|
|
280
|
+
return e;
|
|
281
|
+
}
|
|
282
|
+
function qe(e) {
|
|
283
|
+
let t = e.minDateTime ? new Date(e.minDateTime) : /* @__PURE__ */ new Date("1970-01-01"), n = e.maxDateTime ? new Date(e.maxDateTime) : /* @__PURE__ */ new Date(), r = t.getTime(), i = n.getTime(), o = r + e.random.next() * (i - r), a = new Date(o), l = a.getFullYear(), s = I(a.getMonth() + 1), p = I(a.getDate());
|
|
284
|
+
return `${l}-${s}-${p}T01:01:01.0Z`;
|
|
285
|
+
}
|
|
286
|
+
function H(e, t) {
|
|
287
|
+
if (e.const !== void 0) return structuredClone(e.const);
|
|
288
|
+
if (e.enum !== void 0 && e.enum.length > 0) {
|
|
289
|
+
let n = e.enum;
|
|
290
|
+
if (e.minimum !== void 0 || e.maximum !== void 0 || e.exclusiveMinimum !== void 0 || e.exclusiveMaximum !== void 0 || e.multipleOf !== void 0) {
|
|
291
|
+
let i = e.exclusiveMinimum ?? e.minimum ?? -1 / 0, o = e.exclusiveMaximum ?? e.maximum ?? 1 / 0, a = e.exclusiveMinimum !== void 0, l = e.exclusiveMaximum !== void 0;
|
|
292
|
+
n = n.filter((s) => {
|
|
293
|
+
if (typeof s != "number") return !0;
|
|
294
|
+
let p = a ? s > i : s >= i, y = l ? s < o : s <= o;
|
|
295
|
+
if (!p || !y) return !1;
|
|
296
|
+
if (e.multipleOf !== void 0) {
|
|
297
|
+
let h = e.multipleOf, $ = h.toString().includes(".") ? h.toString().split(".")[1].length : 0, O = Math.pow(10, $), k = Math.round(s * O), D = Math.round(h * O);
|
|
298
|
+
if (k % D !== 0) return !1;
|
|
299
|
+
}
|
|
300
|
+
return !0;
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
if (e.minLength !== void 0 || e.maxLength !== void 0) {
|
|
304
|
+
let i = e.minLength ?? 0, o = e.maxLength ?? 1 / 0;
|
|
305
|
+
n = n.filter((a) => typeof a != "string" ? !0 : a.length >= i && a.length <= o);
|
|
306
|
+
}
|
|
307
|
+
if (e.minItems !== void 0 || e.maxItems !== void 0) {
|
|
308
|
+
let i = e.minItems ?? 0, o = e.maxItems ?? 1 / 0;
|
|
309
|
+
n = n.filter((a) => Array.isArray(a) ? a.length >= i && a.length <= o : !0);
|
|
310
|
+
}
|
|
311
|
+
if (e.minProperties !== void 0 || e.maxProperties !== void 0) {
|
|
312
|
+
let i = e.minProperties ?? 0, o = e.maxProperties ?? 1 / 0;
|
|
313
|
+
n = n.filter((a) => typeof a != "object" || a === null || Array.isArray(a) ? !0 : Object.keys(a).length >= i && Object.keys(a).length <= o);
|
|
314
|
+
}
|
|
315
|
+
if (n.length === 0) {
|
|
316
|
+
let i = [];
|
|
317
|
+
throw e.minLength !== void 0 && i.push(`minLength: ${e.minLength}`), e.maxLength !== void 0 && i.push(`maxLength: ${e.maxLength}`), e.minItems !== void 0 && i.push(`minItems: ${e.minItems}`), e.maxItems !== void 0 && i.push(`maxItems: ${e.maxItems}`), e.minProperties !== void 0 && i.push(`minProperties: ${e.minProperties}`), e.maxProperties !== void 0 && i.push(`maxProperties: ${e.maxProperties}`), e.minimum !== void 0 && i.push(`minimum: ${e.minimum}`), e.maximum !== void 0 && i.push(`maximum: ${e.maximum}`), e.exclusiveMinimum !== void 0 && i.push(`exclusiveMinimum: ${e.exclusiveMinimum}`), e.exclusiveMaximum !== void 0 && i.push(`exclusiveMaximum: ${e.exclusiveMaximum}`), e.multipleOf !== void 0 && i.push(`multipleOf: ${e.multipleOf}`), Error(`enum values conflict with constraints [${i.join(", ")}] at ${t.path}`);
|
|
318
|
+
}
|
|
319
|
+
let r = t.random.pick(n);
|
|
320
|
+
return typeof r == "object" && r !== null ? structuredClone(r) : r;
|
|
321
|
+
}
|
|
322
|
+
throw Error(`generateEnumConst called without enum or const at ${t.path}`);
|
|
323
|
+
}
|
|
324
|
+
function M(e) {
|
|
325
|
+
let t = {};
|
|
326
|
+
for (let n of e) {
|
|
327
|
+
if (typeof n == "boolean") {
|
|
328
|
+
if (!n) return { not: {} };
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
ce(t, n);
|
|
332
|
+
}
|
|
333
|
+
return t;
|
|
334
|
+
}
|
|
335
|
+
function pe(e, t) {
|
|
336
|
+
if (typeof e == "boolean" || typeof t == "boolean") return {};
|
|
337
|
+
if (typeof e != "object" || e === null) return typeof t == "object" && t !== null ? t : {};
|
|
338
|
+
if (typeof t != "object" || t === null) return e;
|
|
339
|
+
let n = { ...e };
|
|
340
|
+
return ce(n, t), n;
|
|
341
|
+
}
|
|
342
|
+
function ce(e, t) {
|
|
343
|
+
if (t.type !== void 0 && (e.type === void 0 ? e.type = t.type : e.type = Ce(e.type, t.type)), t.minimum !== void 0 && (e.minimum = e.minimum !== void 0 ? Math.max(e.minimum, t.minimum) : t.minimum), t.maximum !== void 0 && (e.maximum = e.maximum !== void 0 ? Math.min(e.maximum, t.maximum) : t.maximum), t.exclusiveMinimum !== void 0 && (e.exclusiveMinimum = e.exclusiveMinimum !== void 0 ? Math.max(e.exclusiveMinimum, t.exclusiveMinimum) : t.exclusiveMinimum), t.exclusiveMaximum !== void 0 && (e.exclusiveMaximum = e.exclusiveMaximum !== void 0 ? Math.min(e.exclusiveMaximum, t.exclusiveMaximum) : t.exclusiveMaximum), t.multipleOf !== void 0 && (e.multipleOf = t.multipleOf), t.minLength !== void 0 && (e.minLength = e.minLength !== void 0 ? Math.max(e.minLength, t.minLength) : t.minLength), t.maxLength !== void 0 && (e.maxLength = e.maxLength !== void 0 ? Math.min(e.maxLength, t.maxLength) : t.maxLength), t.pattern !== void 0 && (e.pattern = t.pattern), t.format !== void 0 && (e.format = t.format), t.minItems !== void 0 && (e.minItems = e.minItems !== void 0 ? Math.max(e.minItems, t.minItems) : t.minItems), t.maxItems !== void 0 && (e.maxItems = e.maxItems !== void 0 ? Math.min(e.maxItems, t.maxItems) : t.maxItems), t.uniqueItems && (e.uniqueItems = !0), t.items !== void 0 && (e.items = t.items), t.prefixItems !== void 0) if (e.prefixItems === void 0) e.prefixItems = t.prefixItems;
|
|
344
|
+
else {
|
|
345
|
+
let n = [], r = Math.max(e.prefixItems.length, t.prefixItems.length);
|
|
346
|
+
for (let i = 0; i < r; i++) {
|
|
347
|
+
let o = e.prefixItems[i], a = t.prefixItems[i];
|
|
348
|
+
o !== void 0 && a !== void 0 ? n.push(pe(o, a)) : o !== void 0 ? n.push(o) : a !== void 0 && n.push(a);
|
|
349
|
+
}
|
|
350
|
+
e.prefixItems = n;
|
|
351
|
+
}
|
|
352
|
+
if (t.contains !== void 0 && (e.containsAll !== void 0 ? e.containsAll = [...e.containsAll, t.contains] : e.contains !== void 0 ? (e.containsAll = [e.contains, t.contains], delete e.contains) : e.contains = t.contains), t.properties && (e.properties = Je(e.properties ?? {}, t.properties)), t.required && (e.required = [.../* @__PURE__ */ new Set([...e.required ?? [], ...t.required])]), t.additionalProperties !== void 0 && (e.additionalProperties = t.additionalProperties), t.patternProperties && (e.patternProperties = { ...e.patternProperties ?? {}, ...t.patternProperties }), t.minProperties !== void 0 && (e.minProperties = e.minProperties !== void 0 ? Math.max(e.minProperties, t.minProperties) : t.minProperties), t.maxProperties !== void 0 && (e.maxProperties = e.maxProperties !== void 0 ? Math.min(e.maxProperties, t.maxProperties) : t.maxProperties), t.const !== void 0 && (e.const = t.const), t.enum !== void 0) if (e.enum !== void 0) {
|
|
353
|
+
let n = new Set(t.enum.map((r) => JSON.stringify(r)));
|
|
354
|
+
e.enum = e.enum.filter((r) => n.has(JSON.stringify(r)));
|
|
355
|
+
} else e.enum = t.enum;
|
|
356
|
+
t.$ref && (e.$ref = t.$ref), t.$defs && (e.$defs = { ...e.$defs ?? {}, ...t.$defs }), t.allOf && (e.allOf = [...e.allOf ?? [], ...t.allOf]), t.anyOf && (e.anyOf = t.anyOf), t.oneOf && (e.oneOf = t.oneOf);
|
|
357
|
+
}
|
|
358
|
+
function Ce(e, t) {
|
|
359
|
+
let n = Array.isArray(e) ? e : [e], r = Array.isArray(t) ? t : [t], i = n.filter((o) => r.includes(o));
|
|
360
|
+
return i.length === 0 ? n[0] : i.length === 1 ? i[0] : i;
|
|
361
|
+
}
|
|
362
|
+
function Je(e, t) {
|
|
363
|
+
let n = { ...e };
|
|
364
|
+
for (let [r, i] of Object.entries(t)) {
|
|
365
|
+
let o = e[r];
|
|
366
|
+
o === void 0 ? n[r] = i : typeof o == "object" && typeof i == "object" ? n[r] = pe(o, i) : n[r] = i;
|
|
367
|
+
}
|
|
368
|
+
return n;
|
|
369
|
+
}
|
|
370
|
+
var J = /* @__PURE__ */ new Set(["$schema", "$id", "$ref", "$defs", "$anchor", "$dynamicRef", "$dynamicAnchor", "$vocabulary", "$comment", "type", "enum", "const", "minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum", "multipleOf", "minLength", "maxLength", "pattern", "format", "contentEncoding", "contentMediaType", "contentSchema", "items", "prefixItems", "contains", "minItems", "maxItems", "uniqueItems", "minContains", "maxContains", "properties", "required", "additionalProperties", "patternProperties", "minProperties", "maxProperties", "propertyNames", "dependentRequired", "dependentSchemas", "allOf", "anyOf", "oneOf", "not", "if", "then", "else", "faker", "chance", "jsonPath", "template", "default", "examples", "description", "title", "readOnly", "writeOnly", "deprecated"]);
|
|
371
|
+
function me(e) {
|
|
372
|
+
return typeof e != "object" || e === null ? !1 : Object.keys(e).some((t) => J.has(t));
|
|
373
|
+
}
|
|
374
|
+
function Q(e, t) {
|
|
375
|
+
if (typeof t != "object" || t === null) return !1;
|
|
376
|
+
let n = t;
|
|
377
|
+
return n.const !== void 0 ? e === n.const : n.enum !== void 0 ? n.enum.some((r) => r === e) : !1;
|
|
378
|
+
}
|
|
379
|
+
function Re(e) {
|
|
380
|
+
return typeof e == "boolean" ? !e : typeof e != "object" || e === null ? !1 : e.not === !0 || typeof e.not == "object" && e.not !== null && Object.keys(e.not).length === 0;
|
|
381
|
+
}
|
|
382
|
+
function Fe(e) {
|
|
383
|
+
if (e.properties) return e.properties;
|
|
384
|
+
if (e.type === "object" || e.type === void 0) {
|
|
385
|
+
let t = {}, n = !1;
|
|
386
|
+
for (let [r, i] of Object.entries(e))
|
|
387
|
+
J.has(r) || (me(i) ? (t[r] = i, n = !0) : (t[r] = { const: i }, n = !0));
|
|
388
|
+
if (n) return t;
|
|
389
|
+
}
|
|
390
|
+
return {};
|
|
391
|
+
}
|
|
392
|
+
function We(e, t) {
|
|
393
|
+
return e.required ? e.required : e.properties === void 0 && Object.keys(t).length > 0 ? Object.keys(t) : [];
|
|
394
|
+
}
|
|
395
|
+
async function Ue(e, t) {
|
|
396
|
+
var n;
|
|
397
|
+
let r = Fe(e), i = We(e, r);
|
|
398
|
+
if (t.depth >= t.maxDepth) {
|
|
399
|
+
if (i.length === 0) return {};
|
|
400
|
+
let f = {};
|
|
401
|
+
for (let u of i) {
|
|
402
|
+
let d = r[u];
|
|
403
|
+
if (d && typeof d == "object" && d !== null) {
|
|
404
|
+
let c = d;
|
|
405
|
+
c.const !== void 0 ? f[u] = c.const : c.default !== void 0 ? f[u] = c.default : c.enum !== void 0 && c.enum.length > 0 ? f[u] = c.enum[0] : f[u] = Ze(c.type);
|
|
406
|
+
} else f[u] = null;
|
|
407
|
+
}
|
|
408
|
+
return f;
|
|
409
|
+
}
|
|
410
|
+
if (e.additionalProperties === !1) {
|
|
411
|
+
let f = Object.keys(r).length > 0, u = e.patternProperties && Object.keys(e.patternProperties).length > 0, d = new Set(Object.keys(r)), c = [...new Set(i)].filter((m) => !d.has(m));
|
|
412
|
+
if ((e.minProperties ?? 0) > 0 && !f && !u) throw Error(`missing properties for ${e.minProperties} in ${t.path}: additionalProperties is false but no properties or patternProperties defined`);
|
|
413
|
+
if (c.length > 0 && !u && !f) throw Error(`missing properties for ${c.join(", ")} in ${t.path}: additionalProperties is false but required properties not defined in properties`);
|
|
414
|
+
}
|
|
415
|
+
let o = t.path === "/" ? "/properties" : `${t.path}/properties`, a = { ...t, depth: t.depth + 1, path: o }, l = {}, s = /* @__PURE__ */ new Set(), p = new Set(i), y = t.alwaysFakeOptionals ?? !1, h = t.fillProperties ?? !0, $ = t.fixedProbabilities ?? !1, O = t.optionalsProbability ?? 0.5, k = Object.keys(r).filter((f) => !p.has(f)), D;
|
|
416
|
+
if ($ && !y && k.length > 0) {
|
|
417
|
+
let f = Math.round(k.length * O);
|
|
418
|
+
D = new Set(k.slice(0, f));
|
|
419
|
+
}
|
|
420
|
+
let E = (f) => y ? !0 : D ? D.has(f) : t.random.bool(O);
|
|
421
|
+
if (Object.keys(r).length > 0) for (let [f, u] of Object.entries(r)) {
|
|
422
|
+
if (Re(u)) continue;
|
|
423
|
+
s.add(f);
|
|
424
|
+
let d = A(a, f), c = p.has(f), m = typeof u == "object" && u !== null && u.type === "object", b = u;
|
|
425
|
+
if (e.patternProperties && typeof u == "object" && u !== null) {
|
|
426
|
+
let x = [];
|
|
427
|
+
for (let [w, S] of Object.entries(e.patternProperties)) try {
|
|
428
|
+
new RegExp(w).test(f) && x.push(S);
|
|
429
|
+
} catch {
|
|
430
|
+
}
|
|
431
|
+
x.length > 0 && (b = M([u, ...x]));
|
|
432
|
+
}
|
|
433
|
+
if (c) {
|
|
434
|
+
let x = await v(b, d);
|
|
435
|
+
x !== void 0 && (l[f] = x);
|
|
436
|
+
} else if (E(f)) {
|
|
437
|
+
let x = await v(b, d);
|
|
438
|
+
x !== void 0 && (l[f] = x);
|
|
439
|
+
} else if (m && !h) {
|
|
440
|
+
let x = u.required ?? [];
|
|
441
|
+
if (x.length > 0) {
|
|
442
|
+
let w = {};
|
|
443
|
+
for (let S of x) {
|
|
444
|
+
let ve = (u.properties ?? {})[S] ?? {}, xe = A(d, S), Z = await v(ve, xe);
|
|
445
|
+
Z !== void 0 && (w[S] = Z);
|
|
446
|
+
}
|
|
447
|
+
l[f] = w;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
for (let f of p)
|
|
452
|
+
if (!(l[f] !== void 0 || s.has(f))) {
|
|
453
|
+
if (e.patternProperties) {
|
|
454
|
+
let u = [];
|
|
455
|
+
for (let [d, c] of Object.entries(e.patternProperties)) new RegExp(d).test(f) && u.push(c);
|
|
456
|
+
if (u.length > 0) {
|
|
457
|
+
let d = u.length === 1 ? u[0] : M(u), c = A(a, f), m = await v(d, c);
|
|
458
|
+
m !== void 0 && (l[f] = m), s.add(f);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
if (!s.has(f)) {
|
|
462
|
+
let u = e.additionalProperties ?? !0;
|
|
463
|
+
if (u !== !1) {
|
|
464
|
+
let d = A(a, f), c = await v(u === !0 ? {} : u, d);
|
|
465
|
+
c !== void 0 && (l[f] = c), s.add(f);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
if (e.dependencies) {
|
|
470
|
+
for (let [f, u] of Object.entries(e.dependencies))
|
|
471
|
+
if (!(typeof u != "object" || u === null || Array.isArray(u)) && l[f] !== void 0 && !s.has(f + "_dep")) {
|
|
472
|
+
s.add(f + "_dep");
|
|
473
|
+
let d = u.oneOf ?? u.anyOf ?? u.allOf ?? [u], c = null;
|
|
474
|
+
for (let m of d) {
|
|
475
|
+
if (typeof m != "object" || m === null) continue;
|
|
476
|
+
let { properties: b, not: x } = m;
|
|
477
|
+
if (b && b[f]) {
|
|
478
|
+
let w = b[f], S = l[f];
|
|
479
|
+
if (Q(S, w)) {
|
|
480
|
+
c = m;
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
if (x != null && x.properties) {
|
|
485
|
+
let w = x.properties[f];
|
|
486
|
+
if (w) {
|
|
487
|
+
let S = l[f];
|
|
488
|
+
if (!Q(S, w)) {
|
|
489
|
+
c = m;
|
|
490
|
+
break;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
if (!c && d.length > 0 && typeof d[0] == "object" && (c = d[0]), c != null && c.not) {
|
|
496
|
+
let m = c.not;
|
|
497
|
+
if (m.required && Array.isArray(m.required)) for (let b of m.required) delete l[b];
|
|
498
|
+
}
|
|
499
|
+
if (c != null && c.required) for (let m of c.required) {
|
|
500
|
+
if (m === f || l[m] !== void 0) continue;
|
|
501
|
+
let b = ((n = c.properties) == null ? void 0 : n[m]) ?? { type: "object" }, x = A(a, m), w = await v(b, x);
|
|
502
|
+
w !== void 0 && (l[m] = w);
|
|
503
|
+
}
|
|
504
|
+
if (c && c.properties) for (let [m, b] of Object.entries(c.properties)) {
|
|
505
|
+
if (m === f) continue;
|
|
506
|
+
let x = A(a, m), w = await v(b, x);
|
|
507
|
+
w !== void 0 && (l[m] = w);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
let P = e.minProperties ?? 0, g = e.maxProperties;
|
|
512
|
+
if (Object.keys(l).length < P) {
|
|
513
|
+
if (e.patternProperties && Object.keys(e.patternProperties).length > 0) {
|
|
514
|
+
let f = Object.entries(e.patternProperties), u = 0, d = 1e3;
|
|
515
|
+
for (; Object.keys(l).length < P && u < d; ) {
|
|
516
|
+
u++;
|
|
517
|
+
let [c, m] = t.random.pick(f), b = Ve(c, t);
|
|
518
|
+
if (b && !l[b]) {
|
|
519
|
+
let x = A(a, b), w = await v(m, x);
|
|
520
|
+
w !== void 0 && (l[b] = w), s.add(b);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (Object.keys(l).length < P) {
|
|
525
|
+
let f = e.additionalProperties, u = f === void 0 || f === !0 ? { type: "string" } : f;
|
|
526
|
+
if (u !== !1) {
|
|
527
|
+
let d = 0, c = 1e3;
|
|
528
|
+
for (; Object.keys(l).length < P && d < c; ) {
|
|
529
|
+
d++;
|
|
530
|
+
let m = `prop${t.random.int(0, 99999)}`;
|
|
531
|
+
if (!l[m]) {
|
|
532
|
+
let b = A(a, m), x = await v(u, b);
|
|
533
|
+
x !== void 0 && (l[m] = x), s.add(m);
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
if (Object.keys(l).length < P) {
|
|
539
|
+
let f = Object.keys(r).join(", ");
|
|
540
|
+
throw Error(`properties '${f}' were not found while additionalProperties is false in ${t.path}`);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
if (g !== void 0 && Object.keys(l).length > g) {
|
|
544
|
+
let f = Object.keys(l).filter((u) => !p.has(u));
|
|
545
|
+
for (t.random.shuffle(f); Object.keys(l).length > g && f.length > 0; ) {
|
|
546
|
+
let u = f.pop();
|
|
547
|
+
delete l[u];
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
return t.pruneProperties && t.pruneProperties.length > 0 && F(l, t.pruneProperties), ze(l, r), l;
|
|
551
|
+
}
|
|
552
|
+
function A(e, t) {
|
|
553
|
+
let n = Ye(t), r = e.outputPath === "/" ? `/${n}` : `${e.outputPath}/${n}`;
|
|
554
|
+
return { ...e, path: `${e.path}/${t}`, outputPath: r };
|
|
555
|
+
}
|
|
556
|
+
function Ye(e) {
|
|
557
|
+
return e.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
558
|
+
}
|
|
559
|
+
function ze(e, t) {
|
|
560
|
+
for (let [n, r] of Object.entries(t)) {
|
|
561
|
+
if (typeof r != "object" || r === null) continue;
|
|
562
|
+
let i = r;
|
|
563
|
+
if (i.template === void 0) continue;
|
|
564
|
+
let o = i.template;
|
|
565
|
+
if (typeof o != "string") continue;
|
|
566
|
+
let a = o.replace(/#\{(\w+)\}/g, (l, s) => {
|
|
567
|
+
let p = e[s];
|
|
568
|
+
return p !== void 0 ? String(p) : "";
|
|
569
|
+
});
|
|
570
|
+
e[n] = a;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
function Ve(e, t) {
|
|
574
|
+
let n = e.match(/^\^([a-zA-Z]+)(\.\*|\(\?\:.*\))?/);
|
|
575
|
+
if (n) {
|
|
576
|
+
let s = n[1], p = n[2];
|
|
577
|
+
if (p === ".*" || p != null && p.includes("?:")) {
|
|
578
|
+
let y = t.random.int(0, 10), h = "";
|
|
579
|
+
for (let $ = 0; $ < y; $++) h += t.random.pick("abcdefghijklmnopqrstuvwxyz".split(""));
|
|
580
|
+
return s + h;
|
|
581
|
+
}
|
|
582
|
+
return s;
|
|
583
|
+
}
|
|
584
|
+
let r = e.match(/(.*\*)?([a-zA-Z]+)\$$/);
|
|
585
|
+
if (r) {
|
|
586
|
+
let s = r[2], p = t.random.int(1, 10), y = "";
|
|
587
|
+
for (let h = 0; h < p; h++) y += t.random.pick("abcdefghijklmnopqrstuvwxyz".split(""));
|
|
588
|
+
return y + s;
|
|
589
|
+
}
|
|
590
|
+
let i = e.match(/^\^([a-zA-Z]+)\$$/);
|
|
591
|
+
if (i) return i[1];
|
|
592
|
+
let o = t.random.int(3, 10), a = "abcdefghijklmnopqrstuvwxyz", l = "";
|
|
593
|
+
for (let s = 0; s < o; s++) l += t.random.pick(a.split(""));
|
|
594
|
+
try {
|
|
595
|
+
if (new RegExp(e).test(l)) return l;
|
|
596
|
+
} catch {
|
|
597
|
+
}
|
|
598
|
+
return null;
|
|
599
|
+
}
|
|
600
|
+
function F(e, t) {
|
|
601
|
+
if (typeof e != "object" || e === null) return;
|
|
602
|
+
if (Array.isArray(e)) {
|
|
603
|
+
for (let r of e) F(r, t);
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
let n = e;
|
|
607
|
+
for (let r of Object.keys(n)) t.includes(r) ? delete n[r] : F(n[r], t);
|
|
608
|
+
}
|
|
609
|
+
function Ze(e) {
|
|
610
|
+
switch (Array.isArray(e) ? e[0] : e) {
|
|
611
|
+
case "string":
|
|
612
|
+
return "";
|
|
613
|
+
case "number":
|
|
614
|
+
case "integer":
|
|
615
|
+
return 0;
|
|
616
|
+
case "boolean":
|
|
617
|
+
return !1;
|
|
618
|
+
case "null":
|
|
619
|
+
return null;
|
|
620
|
+
case "array":
|
|
621
|
+
return [];
|
|
622
|
+
case "object":
|
|
623
|
+
return {};
|
|
624
|
+
default:
|
|
625
|
+
return null;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
async function Be(e, t) {
|
|
629
|
+
var n;
|
|
630
|
+
if (t.depth >= t.maxDepth) {
|
|
631
|
+
let g = e.minItems ?? 0;
|
|
632
|
+
return g > 0 ? Array.from({ length: g }, () => null) : [];
|
|
633
|
+
}
|
|
634
|
+
if (t.refDepthReached) {
|
|
635
|
+
let g = e.minItems ?? 0;
|
|
636
|
+
return g > 0 ? Array.from({ length: g }, () => null) : [];
|
|
637
|
+
}
|
|
638
|
+
if (e.items === !1 && (e.minItems ?? 0) > 0) {
|
|
639
|
+
let g = ((n = e.prefixItems) == null ? void 0 : n.length) ?? 0;
|
|
640
|
+
if ((e.minItems ?? 0) > g) throw Error(`missing items for ${e.minItems} in ${t.path}: items is false but minItems (${e.minItems}) exceeds prefixItems count (${g})`);
|
|
641
|
+
}
|
|
642
|
+
let r = t.path === "/" ? "/items" : `${t.path}/items`, i = { ...t, depth: t.depth + 1, path: r }, o = [], a = t.refDepthMax, l = t.minItems ?? e.minItems ?? 0, s = t.maxItems ?? e.maxItems ?? Math.max(l, t.maxDefaultItems);
|
|
643
|
+
e.maxItems !== void 0 && s > e.maxItems && (s = e.maxItems), e.minItems !== void 0 && l < e.minItems && (l = e.minItems), s < l && (e.maxItems !== void 0 ? l = s : s = l), t.alwaysFakeOptionals && (s = Math.max(l, s));
|
|
644
|
+
let p = e.uniqueItems ? /* @__PURE__ */ new Set() : null, y = async (g, f) => {
|
|
645
|
+
let u = await v(g, f);
|
|
646
|
+
if (u === void 0) return "omitted";
|
|
647
|
+
if (p) {
|
|
648
|
+
let d = JSON.stringify(u);
|
|
649
|
+
if (p.has(d)) {
|
|
650
|
+
for (let c = 0; c < 50; c++) {
|
|
651
|
+
if (u = await v(g, L(i, o.length)), u === void 0) continue;
|
|
652
|
+
let m = JSON.stringify(u);
|
|
653
|
+
if (!p.has(m)) return p.add(m), o.push(u), "added";
|
|
654
|
+
}
|
|
655
|
+
return "failed";
|
|
656
|
+
}
|
|
657
|
+
p.add(d);
|
|
658
|
+
}
|
|
659
|
+
return o.push(u), "added";
|
|
660
|
+
};
|
|
661
|
+
if (e.prefixItems) for (let g = 0; g < e.prefixItems.length && o.length < s; g++) {
|
|
662
|
+
let f = L(i, g);
|
|
663
|
+
if (await y(e.prefixItems[g], f) === "failed") break;
|
|
664
|
+
}
|
|
665
|
+
let h;
|
|
666
|
+
if (a !== void 0 && t.refDepth >= a - 1) {
|
|
667
|
+
let g = e.minItems ?? 0;
|
|
668
|
+
return g > 0 ? Array.from({ length: g }, () => null) : [];
|
|
669
|
+
}
|
|
670
|
+
let $ = t.alwaysFakeOptionals ?? !1, O = t.fixedProbabilities ?? !1, k = t.optionalsProbability ?? 0.5;
|
|
671
|
+
if ($) h = s;
|
|
672
|
+
else if (O) {
|
|
673
|
+
let g = s - Math.max(l, o.length), f = Math.round(g * k);
|
|
674
|
+
h = Math.max(l, o.length) + f;
|
|
675
|
+
} else h = t.random.int(Math.max(l, o.length), s);
|
|
676
|
+
e.items;
|
|
677
|
+
let D = e.prefixItems !== void 0, E = e.additionalItems !== void 0, P;
|
|
678
|
+
if (D ? E ? P = e.additionalItems : e.items !== void 0 && (P = e.items) : P = e.items, P !== !1 && P !== void 0) {
|
|
679
|
+
let g = P ?? {}, f = 0, u = Math.max(h * 20, 50);
|
|
680
|
+
for (; o.length < h; ) {
|
|
681
|
+
let d = await y(g, L(i, o.length));
|
|
682
|
+
if (d === "added") {
|
|
683
|
+
f = 0;
|
|
684
|
+
continue;
|
|
685
|
+
}
|
|
686
|
+
if (f++, d === "failed" || f >= u) break;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
if (e.contains) {
|
|
690
|
+
let g = e.minContains ?? 1, f = e.maxContains ?? Math.max(g, 1), u = t.random.int(g, f);
|
|
691
|
+
for (let d = 0; d < u; d++) {
|
|
692
|
+
let c = await v(e.contains, L(i, o.length));
|
|
693
|
+
if (c !== void 0) {
|
|
694
|
+
if (p) {
|
|
695
|
+
let m = JSON.stringify(c);
|
|
696
|
+
if (p.has(m)) {
|
|
697
|
+
let b = !1;
|
|
698
|
+
for (let x = 0; x < 50; x++) {
|
|
699
|
+
if (c = await v(e.contains, L(i, o.length)), c === void 0) continue;
|
|
700
|
+
let w = JSON.stringify(c);
|
|
701
|
+
if (!p.has(w)) {
|
|
702
|
+
p.add(w), b = !0;
|
|
703
|
+
break;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
if (!b) continue;
|
|
707
|
+
} else p.add(m);
|
|
708
|
+
}
|
|
709
|
+
if (o.length < s) {
|
|
710
|
+
let m = t.random.int(0, o.length);
|
|
711
|
+
o.splice(m, 0, c);
|
|
712
|
+
} else if (o.length > 0) {
|
|
713
|
+
let m = t.random.int(0, o.length - 1);
|
|
714
|
+
o[m] = c;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
for (; o.length > s; ) o.pop();
|
|
719
|
+
}
|
|
720
|
+
if (e.containsAll) {
|
|
721
|
+
let g = /* @__PURE__ */ new Set();
|
|
722
|
+
for (let f of e.containsAll) {
|
|
723
|
+
let u = await v(f, L(i, o.length));
|
|
724
|
+
if (u !== void 0) {
|
|
725
|
+
if (p) {
|
|
726
|
+
let d = JSON.stringify(u);
|
|
727
|
+
if (p.has(d)) {
|
|
728
|
+
let c = !1;
|
|
729
|
+
for (let m = 0; m < 50; m++) {
|
|
730
|
+
if (u = await v(f, L(i, o.length)), u === void 0) continue;
|
|
731
|
+
let b = JSON.stringify(u);
|
|
732
|
+
if (!p.has(b)) {
|
|
733
|
+
p.add(b), c = !0;
|
|
734
|
+
break;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
if (!c) continue;
|
|
738
|
+
} else p.add(d);
|
|
739
|
+
}
|
|
740
|
+
if (o.length < s) {
|
|
741
|
+
let d = t.random.int(0, o.length);
|
|
742
|
+
o.splice(d, 0, u);
|
|
743
|
+
let c = /* @__PURE__ */ new Set();
|
|
744
|
+
for (let m of g) c.add(m >= d ? m + 1 : m);
|
|
745
|
+
g.clear();
|
|
746
|
+
for (let m of c) g.add(m);
|
|
747
|
+
g.add(d);
|
|
748
|
+
} else if (o.length > 0) {
|
|
749
|
+
let d = Array.from({ length: o.length }, (c, m) => m).filter((c) => !g.has(c));
|
|
750
|
+
if (d.length > 0) {
|
|
751
|
+
let c = d[t.random.int(0, d.length - 1)];
|
|
752
|
+
o[c] = u, g.add(c);
|
|
753
|
+
} else o.push(u), g.add(o.length - 1);
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
for (; o.length > s; ) o.pop();
|
|
758
|
+
}
|
|
759
|
+
return e.uniqueItems && o.length > 0 ? Ge(o, e, i, l, s, p) : o;
|
|
760
|
+
}
|
|
761
|
+
async function Ge(e, t, n, r, i, o) {
|
|
762
|
+
let a = t.items ?? {}, l = 0, s = 100;
|
|
763
|
+
for (; e.length < r && l < s; ) {
|
|
764
|
+
l++;
|
|
765
|
+
let p = await v(a, L(n, e.length));
|
|
766
|
+
if (p === void 0) continue;
|
|
767
|
+
let y = JSON.stringify(p);
|
|
768
|
+
o.has(y) || (o.add(y), e.push(p));
|
|
769
|
+
}
|
|
770
|
+
for (; e.length > i; ) e.pop();
|
|
771
|
+
return e;
|
|
772
|
+
}
|
|
773
|
+
function L(e, t) {
|
|
774
|
+
let n = e.outputPath === "/" ? `/${t}` : `${e.outputPath}/${t}`;
|
|
775
|
+
return { ...e, path: `${e.path}/${t}`, outputPath: n };
|
|
776
|
+
}
|
|
777
|
+
function Ft(e = {}) {
|
|
778
|
+
let t = e.cache ?? /* @__PURE__ */ new Map(), n = e.baseUrl;
|
|
779
|
+
return async (r) => {
|
|
780
|
+
let { url: i, fragment: o } = He(r, n), a;
|
|
781
|
+
if (t.has(i)) a = t.get(i);
|
|
782
|
+
else {
|
|
783
|
+
if (i.startsWith("http://") || i.startsWith("https://")) a = await Qe(i, e.fetch);
|
|
784
|
+
else if (i.startsWith("file://")) {
|
|
785
|
+
let l = decodeURIComponent(i.slice(7));
|
|
786
|
+
a = await _(l, e.readFile);
|
|
787
|
+
} else a = await _(i, e.readFile);
|
|
788
|
+
t.set(i, a);
|
|
789
|
+
}
|
|
790
|
+
return a;
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
function He(e, t) {
|
|
794
|
+
let n = e.indexOf("#");
|
|
795
|
+
if (n === -1) return { url: X(e, t), fragment: null };
|
|
796
|
+
let r = e.slice(0, n), i = e.slice(n + 1);
|
|
797
|
+
return { url: X(r || "#", t), fragment: i || null };
|
|
798
|
+
}
|
|
799
|
+
function X(e, t) {
|
|
800
|
+
if (!t || e.startsWith("http://") || e.startsWith("https://") || e.startsWith("file://")) return e === "#" ? t || "#" : e;
|
|
801
|
+
if (t.startsWith("file://")) {
|
|
802
|
+
let n = t.slice(7), r = n.includes("/") ? "/" : "\\", i = n.lastIndexOf(r);
|
|
803
|
+
return (i >= 0 ? n.slice(0, i + 1) : "") + e;
|
|
804
|
+
}
|
|
805
|
+
try {
|
|
806
|
+
return new URL(e, t).href;
|
|
807
|
+
} catch {
|
|
808
|
+
return e;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
async function Qe(e, t) {
|
|
812
|
+
let n = t ?? globalThis.fetch;
|
|
813
|
+
if (!n) throw Error(`Cannot fetch ${e}: fetch is not available. Provide a custom fetch function via the 'fetch' option.`);
|
|
814
|
+
let r = await n(e);
|
|
815
|
+
if (!r.ok) throw Error(`Failed to fetch schema from ${e}: ${r.status} ${r.statusText}`);
|
|
816
|
+
if ((r.headers.get("content-type") || "").includes("application/json")) return r.json();
|
|
817
|
+
let i = await r.text();
|
|
818
|
+
try {
|
|
819
|
+
return JSON.parse(i);
|
|
820
|
+
} catch (o) {
|
|
821
|
+
throw Error(`Failed to parse schema from ${e} as JSON: ${o}`);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
async function _(e, t) {
|
|
825
|
+
if (!t) throw Error(`Cannot read file ${e}: readFile is not available. Provide a custom readFile function via the 'readFile' option. In Node.js, import { readFile } from "node:fs/promises" and pass it as an option.`);
|
|
826
|
+
let n = await t(e);
|
|
827
|
+
return JSON.parse(n);
|
|
828
|
+
}
|
|
829
|
+
function K(e, t) {
|
|
830
|
+
if (!t || t === "") return e;
|
|
831
|
+
if (typeof e != "object" || e === null) throw Error(`Cannot resolve fragment "${t}" in non-object schema`);
|
|
832
|
+
if (t.startsWith("/")) return Xe(e, t);
|
|
833
|
+
throw Error(`Unsupported fragment type: ${t}. Only JSON pointers (starting with /) are supported.`);
|
|
834
|
+
}
|
|
835
|
+
function Xe(e, t) {
|
|
836
|
+
if (t === "" || t === "/") return e;
|
|
837
|
+
let n = t.slice(1).split("/"), r = e;
|
|
838
|
+
for (let i of n) {
|
|
839
|
+
let o = i.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
840
|
+
if (typeof r != "object" || r === null) throw Error(`Cannot resolve JSON pointer "${t}": not an object at "${o}"`);
|
|
841
|
+
if (Array.isArray(r)) {
|
|
842
|
+
let a = parseInt(o, 10);
|
|
843
|
+
if (isNaN(a) || a < 0 || a >= r.length) throw Error(`Cannot resolve JSON pointer "${t}": invalid array index "${o}"`);
|
|
844
|
+
r = r[a];
|
|
845
|
+
} else {
|
|
846
|
+
if (!(o in r)) throw Error(`Cannot resolve JSON pointer "${t}": property "${o}" not found`);
|
|
847
|
+
r = r[o];
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
return r;
|
|
851
|
+
}
|
|
852
|
+
function _e(e) {
|
|
853
|
+
let t = /* @__PURE__ */ new Map();
|
|
854
|
+
if (typeof e == "boolean") return t;
|
|
855
|
+
if (e.$id && typeof e == "object") {
|
|
856
|
+
let n = e, r = n.$id, { $id: i, ...o } = n;
|
|
857
|
+
t.set(r, o);
|
|
858
|
+
}
|
|
859
|
+
if (e.$defs) for (let [n, r] of Object.entries(e.$defs)) t.set(`#/$defs/${n}`, r);
|
|
860
|
+
return t;
|
|
861
|
+
}
|
|
862
|
+
async function C(e, t) {
|
|
863
|
+
let n = e.$ref;
|
|
864
|
+
if (!n) return { schema: e, ctx: t };
|
|
865
|
+
let r = t.refDepth + 1;
|
|
866
|
+
if (t.refDepthMax !== void 0 && r >= t.refDepthMax) return { schema: {}, ctx: { ...t, refDepthReached: !0 } };
|
|
867
|
+
if (t.refStack.has(n)) {
|
|
868
|
+
if (t.refDepthMax !== void 0) {
|
|
869
|
+
if (t.refDepth >= t.refDepthMax) return { schema: {}, ctx: { ...t, refDepthReached: !0 } };
|
|
870
|
+
} else if (t.depth >= t.maxDepth) return { schema: { type: "null" }, ctx: t };
|
|
871
|
+
}
|
|
872
|
+
let i, o;
|
|
873
|
+
if (n.startsWith("#/")) {
|
|
874
|
+
if (i = t.refRegistry.get(n), i === void 0 && n.length > 2) {
|
|
875
|
+
let h = t.refRegistry.get("#");
|
|
876
|
+
if (h !== void 0 && typeof h == "object") try {
|
|
877
|
+
i = K(h, n.slice(1));
|
|
878
|
+
} catch {
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
i === void 0 && t.refResolver && (i = await t.refResolver(n), i !== void 0 && t.refRegistry.set(n, i));
|
|
882
|
+
} else if (n === "#") i = t.refRegistry.get("#") ?? {};
|
|
883
|
+
else if (i = t.refRegistry.get(n), i === void 0 && t.refResolver) {
|
|
884
|
+
o = await t.refResolver(n);
|
|
885
|
+
let h = n.indexOf("#");
|
|
886
|
+
if (h !== -1) {
|
|
887
|
+
let $ = n.slice(h + 1);
|
|
888
|
+
$ ? i = K(o, $) : i = o;
|
|
889
|
+
} else i = o;
|
|
890
|
+
if (o && typeof o == "object" && o !== null) {
|
|
891
|
+
let $ = o;
|
|
892
|
+
if ($.$defs) for (let [O, k] of Object.entries($.$defs)) t.refRegistry.set(`#/$defs/${O}`, k);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
if (i === void 0) throw Error(`Unresolved $ref: ${n}`);
|
|
896
|
+
let a = /* @__PURE__ */ new Set(["description", "title", "$comment", "readOnly", "writeOnly", "deprecated"]), { $ref: l, ...s } = e, p = Object.fromEntries(Object.entries(s).filter(([h]) => !a.has(h)));
|
|
897
|
+
Object.keys(p).length > 0 && typeof i == "object" && i !== null && (i = { ...i, ...p });
|
|
898
|
+
let y = { ...t, refStack: /* @__PURE__ */ new Set([...t.refStack, n]), refDepth: t.refDepth + 1 };
|
|
899
|
+
return { schema: i, ctx: y };
|
|
900
|
+
}
|
|
901
|
+
function Ke(e, t) {
|
|
902
|
+
typeof e != "boolean" && (t.set("#", e), W(e, "#", t));
|
|
903
|
+
}
|
|
904
|
+
function W(e, t, n) {
|
|
905
|
+
if (e.$id) {
|
|
906
|
+
let { $id: r, ...i } = e;
|
|
907
|
+
n.set(r, i);
|
|
908
|
+
}
|
|
909
|
+
if (e.$defs) for (let [r, i] of Object.entries(e.$defs)) {
|
|
910
|
+
let o = `${t}/$defs/${r}`;
|
|
911
|
+
n.set(o, i), typeof i == "object" && i !== null && W(i, o, n);
|
|
912
|
+
}
|
|
913
|
+
if (e.properties)
|
|
914
|
+
for (let [r, i] of Object.entries(e.properties)) typeof i == "object" && i !== null && W(i, `${t}/properties/${r}`, n);
|
|
915
|
+
}
|
|
916
|
+
async function et(e, t) {
|
|
917
|
+
return e.$ref ? (await C(e, t)).schema : e;
|
|
918
|
+
}
|
|
919
|
+
async function tt(e, t) {
|
|
920
|
+
let n = [];
|
|
921
|
+
for (let r of e) if (typeof r == "object" && r !== null && "$ref" in r) {
|
|
922
|
+
let i = await et(r, t);
|
|
923
|
+
n.push(i);
|
|
924
|
+
} else typeof r == "object" && r !== null && n.push(r);
|
|
925
|
+
return n;
|
|
926
|
+
}
|
|
927
|
+
async function nt(e, t) {
|
|
928
|
+
let { allOf: n, anyOf: r, oneOf: i, not: o, if: a, then: l, else: s, ...p } = e;
|
|
929
|
+
if (n) {
|
|
930
|
+
let y = await tt(n, t), h = M([p, ...y]);
|
|
931
|
+
return v(h, t);
|
|
932
|
+
}
|
|
933
|
+
if (i) {
|
|
934
|
+
let y = t.random.shuffle([...i]), h = p.required ?? [];
|
|
935
|
+
for (let f of y) {
|
|
936
|
+
let u = typeof f == "object" && f !== null ? f : {};
|
|
937
|
+
u.$ref && (u = (await C(u, t)).schema);
|
|
938
|
+
let d = u.required ?? [], c = [.../* @__PURE__ */ new Set([...h, ...d])], m = { ...p, required: c }, b = M([m, u]), x = { ...t, optionalsProbability: 0, alwaysFakeOptionals: !1 };
|
|
939
|
+
try {
|
|
940
|
+
return await v(b, x);
|
|
941
|
+
} catch {
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
let $ = i[0], O = typeof $ == "object" && $ !== null ? $ : {};
|
|
945
|
+
O.$ref && (O = (await C(O, t)).schema);
|
|
946
|
+
let k = O.required ?? [], D = [.../* @__PURE__ */ new Set([...h, ...k])], E = { ...p, required: D }, P = M([E, O]), g = { ...t, optionalsProbability: 0, alwaysFakeOptionals: !1 };
|
|
947
|
+
return v(P, g);
|
|
948
|
+
}
|
|
949
|
+
if (r) {
|
|
950
|
+
let y = t.random.shuffle([...r]);
|
|
951
|
+
for (let O of y) {
|
|
952
|
+
let k = M([p, O]);
|
|
953
|
+
try {
|
|
954
|
+
return await v(k, t);
|
|
955
|
+
} catch {
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
let h = r[0], $ = M([p, h]);
|
|
959
|
+
return v($, t);
|
|
960
|
+
}
|
|
961
|
+
return a !== void 0 ? rt(p, a, l, s, t) : o ? it(p, o, t) : v(p, t);
|
|
962
|
+
}
|
|
963
|
+
async function rt(e, t, n, r, i) {
|
|
964
|
+
if (n !== void 0) {
|
|
965
|
+
let o = M([e, t, n]);
|
|
966
|
+
try {
|
|
967
|
+
return await v(o, i);
|
|
968
|
+
} catch {
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
if (r !== void 0) {
|
|
972
|
+
let o = M([e, r]);
|
|
973
|
+
try {
|
|
974
|
+
return await v(o, i);
|
|
975
|
+
} catch {
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
return v(e, i);
|
|
979
|
+
}
|
|
980
|
+
async function it(e, t, n) {
|
|
981
|
+
if (typeof t == "boolean") {
|
|
982
|
+
if (t === !0) throw Error(`Cannot generate value for 'not: true' at ${n.path}`);
|
|
983
|
+
return v(e, n);
|
|
984
|
+
}
|
|
985
|
+
if (t.type && !t.enum && !t.const) {
|
|
986
|
+
let r = Array.isArray(t.type) ? t.type : [t.type], i = ["string", "number", "integer", "boolean", "null", "object", "array"].filter((o) => !r.includes(o));
|
|
987
|
+
if (i.length > 0) {
|
|
988
|
+
let o = n.random.pick(i), a = M([e, { type: o }]);
|
|
989
|
+
return v(a, n);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
if (t.const !== void 0 || t.enum !== void 0) {
|
|
993
|
+
let r = t.enum ?? [t.const], i = new Set(r.map((o) => JSON.stringify(o)));
|
|
994
|
+
for (let o = 0; o < 20; o++) {
|
|
995
|
+
let a = await v(e, n);
|
|
996
|
+
if (!i.has(JSON.stringify(a))) return a;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
return v(e, n);
|
|
1000
|
+
}
|
|
1001
|
+
class ot {
|
|
1002
|
+
constructor() {
|
|
1003
|
+
we(this, "extensions", /* @__PURE__ */ new Map());
|
|
1004
|
+
}
|
|
1005
|
+
define(t, n) {
|
|
1006
|
+
this.extensions.set(t, { callback: n, context: {} });
|
|
1007
|
+
}
|
|
1008
|
+
has(t) {
|
|
1009
|
+
return this.extensions.has(t);
|
|
1010
|
+
}
|
|
1011
|
+
reset(t) {
|
|
1012
|
+
if (t) {
|
|
1013
|
+
let n = this.extensions.get(t);
|
|
1014
|
+
n && (n.context = {}, this.extensions.delete(t));
|
|
1015
|
+
} else this.extensions.clear();
|
|
1016
|
+
}
|
|
1017
|
+
keys() {
|
|
1018
|
+
return this.extensions.keys();
|
|
1019
|
+
}
|
|
1020
|
+
generate(t, n) {
|
|
1021
|
+
let r = Object.keys(t);
|
|
1022
|
+
for (let i = r.length - 1; i >= 0; i--) {
|
|
1023
|
+
let o = r[i], a = o.startsWith("x-") ? o.slice(2) : o, l = this.extensions.get(a);
|
|
1024
|
+
if (l) {
|
|
1025
|
+
let s = t[o], p = l.callback.call(l.context, s, t, n);
|
|
1026
|
+
if (p !== void 0) return p;
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
getContext(t) {
|
|
1031
|
+
var n;
|
|
1032
|
+
return (n = this.extensions.get(t)) == null ? void 0 : n.context;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
var z = new ot();
|
|
1036
|
+
function at(e, t) {
|
|
1037
|
+
z.define(e, t);
|
|
1038
|
+
}
|
|
1039
|
+
function lt(e) {
|
|
1040
|
+
z.reset(e);
|
|
1041
|
+
}
|
|
1042
|
+
function st(e, t) {
|
|
1043
|
+
return z.generate(e, t);
|
|
1044
|
+
}
|
|
1045
|
+
var ft = ["string", "number", "integer", "boolean", "null", "object", "array"];
|
|
1046
|
+
function ee(e, t, n) {
|
|
1047
|
+
if (e.faker !== void 0 && e.chance !== void 0) throw Error(`ambiguous generator: both faker and chance are defined in ${t.path}`);
|
|
1048
|
+
if (e.faker !== void 0) try {
|
|
1049
|
+
let r = ut(e.faker, t), i = ne(r, n ?? e.type, t.path);
|
|
1050
|
+
return typeof i == "string" && e.format ? te(i, e.format, t) : i;
|
|
1051
|
+
} catch {
|
|
1052
|
+
}
|
|
1053
|
+
if (e.chance !== void 0) try {
|
|
1054
|
+
let r = pt(e.chance, t), i = ne(r, n ?? e.type, t.path);
|
|
1055
|
+
return typeof i == "string" && e.format ? te(i, e.format, t) : i;
|
|
1056
|
+
} catch {
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
function te(e, t, n) {
|
|
1060
|
+
if (t === "date") {
|
|
1061
|
+
let r = typeof e == "string" ? new Date(e) : e;
|
|
1062
|
+
if (r instanceof Date && !isNaN(r.getTime())) {
|
|
1063
|
+
let i = r.getFullYear(), o = I(r.getMonth() + 1), a = I(r.getDate());
|
|
1064
|
+
return `${i}-${o}-${a}`;
|
|
1065
|
+
}
|
|
1066
|
+
if (typeof e == "string") {
|
|
1067
|
+
let i = Date.parse(e);
|
|
1068
|
+
if (!isNaN(i)) {
|
|
1069
|
+
let o = new Date(i), a = o.getFullYear(), l = I(o.getMonth() + 1), s = I(o.getDate());
|
|
1070
|
+
return `${a}-${l}-${s}`;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
if (t === "date-time") {
|
|
1075
|
+
let r = typeof e == "string" ? new Date(e) : e;
|
|
1076
|
+
if (r instanceof Date && !isNaN(r.getTime())) return r.toISOString();
|
|
1077
|
+
if (typeof e == "string" && Date.parse(e)) return new Date(e).toISOString();
|
|
1078
|
+
}
|
|
1079
|
+
return e;
|
|
1080
|
+
}
|
|
1081
|
+
function ne(e, t, n) {
|
|
1082
|
+
if (t === void 0) return e;
|
|
1083
|
+
let r = Array.isArray(t) ? t[0] : t;
|
|
1084
|
+
switch (r) {
|
|
1085
|
+
case "string":
|
|
1086
|
+
return e === null ? "null" : e === void 0 ? "undefined" : String(e);
|
|
1087
|
+
case "number":
|
|
1088
|
+
case "integer":
|
|
1089
|
+
let i = Number(e);
|
|
1090
|
+
return r === "integer" ? Math.floor(i) : i;
|
|
1091
|
+
case "boolean":
|
|
1092
|
+
return !!e;
|
|
1093
|
+
case "null":
|
|
1094
|
+
return null;
|
|
1095
|
+
default:
|
|
1096
|
+
return e;
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
function ut(e, t) {
|
|
1100
|
+
var n;
|
|
1101
|
+
if (!((n = t.extensions) != null && n.faker)) {
|
|
1102
|
+
let l = typeof e == "string" ? e : JSON.stringify(e);
|
|
1103
|
+
throw Error(`cannot resolve faker-generator for ${l} in ${t.path}`);
|
|
1104
|
+
}
|
|
1105
|
+
let r, i;
|
|
1106
|
+
if (typeof e == "object" && e !== null) {
|
|
1107
|
+
let l = e, s = Object.keys(l);
|
|
1108
|
+
if (s.length > 0) r = s[0], i = l[r];
|
|
1109
|
+
else throw Error(`cannot resolve faker-generator for ${JSON.stringify(e)} in ${t.path}`);
|
|
1110
|
+
} else r = e;
|
|
1111
|
+
let o = r.split("."), a = t.extensions.faker;
|
|
1112
|
+
for (let l of o) try {
|
|
1113
|
+
a = a[l];
|
|
1114
|
+
} catch {
|
|
1115
|
+
throw Error(`failed to resolve .${l} (${r})`);
|
|
1116
|
+
}
|
|
1117
|
+
if (typeof a == "function") return i ? a(...i) : a();
|
|
1118
|
+
throw Error(`cannot resolve faker-generator for ${r} in ${t.path}`);
|
|
1119
|
+
}
|
|
1120
|
+
function pt(e, t) {
|
|
1121
|
+
var n;
|
|
1122
|
+
if (!((n = t.extensions) != null && n.chance)) {
|
|
1123
|
+
let r = typeof e == "string" ? e : Object.keys(e)[0];
|
|
1124
|
+
throw Error(`cannot resolve chance-generator for ${r} in ${t.path}`);
|
|
1125
|
+
}
|
|
1126
|
+
if (typeof e == "string") {
|
|
1127
|
+
let r = t.extensions.chance[e];
|
|
1128
|
+
if (typeof r == "function") return r.call(t.extensions.chance);
|
|
1129
|
+
throw Error(`cannot resolve chance-generator for ${e} in ${t.path}`);
|
|
1130
|
+
}
|
|
1131
|
+
if (typeof e == "object" && e !== null) {
|
|
1132
|
+
let r = e, i = Object.keys(r)[0], o = r[i], a = t.extensions.chance[i];
|
|
1133
|
+
if (typeof a == "function") return o ? a.call(t.extensions.chance, o) : a.call(t.extensions.chance);
|
|
1134
|
+
}
|
|
1135
|
+
throw Error(`cannot resolve chance-generator in ${t.path}`);
|
|
1136
|
+
}
|
|
1137
|
+
function ct(e, t) {
|
|
1138
|
+
let n = e.path === "/" ? `/${t}` : `${e.path}/${t}`;
|
|
1139
|
+
return { ...e, depth: e.depth + 1, path: n, refDepthReached: e.refDepthReached };
|
|
1140
|
+
}
|
|
1141
|
+
async function j(e, t, n) {
|
|
1142
|
+
return n.outputTransform ? n.outputTransform(e, t, n.outputPath) : e;
|
|
1143
|
+
}
|
|
1144
|
+
async function v(e, t) {
|
|
1145
|
+
if (e === !0) return v({}, t);
|
|
1146
|
+
if (e === !1) throw Error(`Cannot generate value for 'false' schema at ${t.path}`);
|
|
1147
|
+
if (t.propAliases && typeof e == "object" && e !== null) {
|
|
1148
|
+
let o = e, a = null;
|
|
1149
|
+
for (let [l, s] of Object.entries(t.propAliases)) l in o && !(s in o) && (a || (a = { ...o }), a[s] = a[l], delete a[l]);
|
|
1150
|
+
a && (e = a);
|
|
1151
|
+
}
|
|
1152
|
+
let n;
|
|
1153
|
+
if (Array.isArray(e.type)) {
|
|
1154
|
+
let o = e.type;
|
|
1155
|
+
n = t.random.pick(o);
|
|
1156
|
+
let a = { ...t, resolvedType: n }, l = ee(e, a, n);
|
|
1157
|
+
if (l !== void 0)
|
|
1158
|
+
return typeof l == "string" && a.maxLength !== void 0 && l.length > a.maxLength ? j(l.slice(0, a.maxLength), e, a) : j(l, e, a);
|
|
1159
|
+
} else {
|
|
1160
|
+
let o = ee(e, t, n);
|
|
1161
|
+
if (o !== void 0)
|
|
1162
|
+
return typeof o == "string" && t.maxLength !== void 0 && o.length > t.maxLength ? j(o.slice(0, t.maxLength), e, t) : j(o, e, t);
|
|
1163
|
+
}
|
|
1164
|
+
let r = st(e, t);
|
|
1165
|
+
if (r !== void 0) return j(r, e, t);
|
|
1166
|
+
if (e.$ref) {
|
|
1167
|
+
let o = await C(e, t);
|
|
1168
|
+
return v(o.schema, ct(o.ctx, "$ref"));
|
|
1169
|
+
}
|
|
1170
|
+
if (e.allOf || e.anyOf || e.oneOf || e.not || e.if) return nt(e, t);
|
|
1171
|
+
if (e.const !== void 0) return j(H(e, t), e, t);
|
|
1172
|
+
if (t.useDefaultValue && e.default !== void 0) return j(e.default, e, t);
|
|
1173
|
+
if (e.enum !== void 0) return j(H(e, t), e, t);
|
|
1174
|
+
if (t.useExamplesValue) {
|
|
1175
|
+
if (Array.isArray(e.examples) && e.examples.length > 0) return j(t.random.pick(e.examples), e, t);
|
|
1176
|
+
if (e.example !== void 0) return j(e.example, e, t);
|
|
1177
|
+
}
|
|
1178
|
+
let i = mt(e, t);
|
|
1179
|
+
if (i === null) {
|
|
1180
|
+
if (t.failOnInvalidTypes === !1) {
|
|
1181
|
+
if (t.defaultInvalidTypeProduct !== void 0) {
|
|
1182
|
+
let o = t.defaultInvalidTypeProduct;
|
|
1183
|
+
return typeof o == "string" ? dt(o) : o;
|
|
1184
|
+
}
|
|
1185
|
+
return null;
|
|
1186
|
+
}
|
|
1187
|
+
throw Error(`unknown primitive ${e.type} in ${t.path}/type`);
|
|
1188
|
+
}
|
|
1189
|
+
switch (i) {
|
|
1190
|
+
case "null":
|
|
1191
|
+
return j(je(), e, t);
|
|
1192
|
+
case "boolean":
|
|
1193
|
+
return j(Pe(t), e, t);
|
|
1194
|
+
case "number":
|
|
1195
|
+
return j(se(e, t), e, t);
|
|
1196
|
+
case "integer":
|
|
1197
|
+
return j(Ie(e, t), e, t);
|
|
1198
|
+
case "string":
|
|
1199
|
+
return j(Te(e, t), e, t);
|
|
1200
|
+
case "object":
|
|
1201
|
+
return j(await Ue(e, t), e, t);
|
|
1202
|
+
case "array":
|
|
1203
|
+
return j(await Be(e, t), e, t);
|
|
1204
|
+
default:
|
|
1205
|
+
throw Error(`Unknown type: ${i} at ${t.path}`);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
function mt(e, t) {
|
|
1209
|
+
return t.resolvedType !== void 0 ? t.resolvedType : typeof e.type == "string" ? ["string", "number", "integer", "boolean", "null", "object", "array"].includes(e.type) ? e.type : null : Array.isArray(e.type) ? t.random.pick(e.type) : e.properties || e.required || e.additionalProperties !== void 0 || e.patternProperties || e.minProperties !== void 0 || e.maxProperties !== void 0 || ht(e) ? "object" : e.items || e.prefixItems || e.contains || e.minItems !== void 0 || e.maxItems !== void 0 || e.uniqueItems ? "array" : e.minimum !== void 0 || e.maximum !== void 0 || e.exclusiveMinimum !== void 0 || e.exclusiveMaximum !== void 0 || e.multipleOf !== void 0 ? "number" : e.minLength !== void 0 || e.maxLength !== void 0 || e.pattern || e.format || e.faker !== void 0 || e.chance !== void 0 ? "string" : t.random.pick(ft);
|
|
1210
|
+
}
|
|
1211
|
+
function ht(e) {
|
|
1212
|
+
if (e.properties || e.type === "object" || e.type === "array") return !1;
|
|
1213
|
+
for (let t of Object.keys(e)) {
|
|
1214
|
+
if (J.has(t)) continue;
|
|
1215
|
+
let n = e[t];
|
|
1216
|
+
if (typeof n == "object" && n !== null && !Array.isArray(n)) return !0;
|
|
1217
|
+
}
|
|
1218
|
+
return !1;
|
|
1219
|
+
}
|
|
1220
|
+
function dt(e, t) {
|
|
1221
|
+
switch (e) {
|
|
1222
|
+
case "string":
|
|
1223
|
+
return "";
|
|
1224
|
+
case "number":
|
|
1225
|
+
case "integer":
|
|
1226
|
+
return 0;
|
|
1227
|
+
case "boolean":
|
|
1228
|
+
return !1;
|
|
1229
|
+
case "null":
|
|
1230
|
+
return null;
|
|
1231
|
+
case "object":
|
|
1232
|
+
return {};
|
|
1233
|
+
case "array":
|
|
1234
|
+
return [];
|
|
1235
|
+
default:
|
|
1236
|
+
return null;
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
function gt(e) {
|
|
1240
|
+
let t = he(e), n = de(e);
|
|
1241
|
+
return `${t}T${n}`;
|
|
1242
|
+
}
|
|
1243
|
+
function he(e) {
|
|
1244
|
+
let t = e.int(2e3, 2030), n = e.int(1, 12), r = Ee(t, n), i = e.int(1, r);
|
|
1245
|
+
return `${t}-${I(n)}-${I(i)}`;
|
|
1246
|
+
}
|
|
1247
|
+
function de(e) {
|
|
1248
|
+
let t = e.int(0, 23), n = e.int(0, 59), r = e.int(0, 59);
|
|
1249
|
+
return `${I(t)}:${I(n)}:${I(r)}Z`;
|
|
1250
|
+
}
|
|
1251
|
+
var yt = ["alice", "bob", "charlie", "dave", "eve", "frank", "grace", "heidi"], vt = ["example.com", "test.org", "demo.net", "sample.io"];
|
|
1252
|
+
function re(e) {
|
|
1253
|
+
let t = e.pick(yt), n = e.int(1, 999), r = e.pick(vt);
|
|
1254
|
+
return `${t}${n}@${r}`;
|
|
1255
|
+
}
|
|
1256
|
+
var xt = ["https"], bt = ["example.com", "test.org", "demo.net"], $t = ["api", "v1", "users", "items", "data", "resource"];
|
|
1257
|
+
function q(e) {
|
|
1258
|
+
let t = e.pick(xt), n = e.pick(bt), r = e.int(1, 3), i = [];
|
|
1259
|
+
for (let o = 0; o < r; o++) i.push(e.pick($t));
|
|
1260
|
+
return `${t}://${n}/${i.join("/")}`;
|
|
1261
|
+
}
|
|
1262
|
+
var wt = ["alpha", "beta", "gamma", "delta", "echo", "fox", "golf", "hotel"], Ot = ["com", "org", "net", "io", "dev"];
|
|
1263
|
+
function ie(e) {
|
|
1264
|
+
let t = e.int(1, 3), n = [];
|
|
1265
|
+
for (let r = 0; r < t; r++) n.push(e.pick(wt));
|
|
1266
|
+
return n.push(e.pick(Ot)), n.join(".");
|
|
1267
|
+
}
|
|
1268
|
+
function jt(e) {
|
|
1269
|
+
return `${e.int(1, 254)}.${e.int(0, 255)}.${e.int(0, 255)}.${e.int(1, 254)}`;
|
|
1270
|
+
}
|
|
1271
|
+
function Pt(e) {
|
|
1272
|
+
let t = [];
|
|
1273
|
+
for (let n = 0; n < 8; n++) t.push(e.int(0, 65535).toString(16));
|
|
1274
|
+
return t.join(":");
|
|
1275
|
+
}
|
|
1276
|
+
function kt(e) {
|
|
1277
|
+
let t = (n) => {
|
|
1278
|
+
let r = "";
|
|
1279
|
+
for (let i = 0; i < n; i++) r += e.int(0, 15).toString(16);
|
|
1280
|
+
return r;
|
|
1281
|
+
};
|
|
1282
|
+
return `${t(8)}-${t(4)}-4${t(3)}-${["8", "9", "a", "b"][e.int(0, 3)]}${t(3)}-${t(12)}`;
|
|
1283
|
+
}
|
|
1284
|
+
var It = ["foo", "bar", "baz", "items", "0", "1", "2", "name", "value"];
|
|
1285
|
+
function oe(e) {
|
|
1286
|
+
let t = e.int(1, 4), n = [];
|
|
1287
|
+
for (let r = 0; r < t; r++) n.push(e.pick(It));
|
|
1288
|
+
return "/" + n.join("/");
|
|
1289
|
+
}
|
|
1290
|
+
function Mt(e) {
|
|
1291
|
+
let t = ["P"], n = e.bool(), r = e.bool();
|
|
1292
|
+
return n && (e.bool() && t.push(`${e.int(0, 100)}Y`), e.bool() && t.push(`${e.int(0, 12)}M`), e.bool() && t.push(`${e.int(0, 30)}D`)), r && (t.push("T"), e.bool() && t.push(`${e.int(0, 23)}H`), e.bool() && t.push(`${e.int(0, 59)}M`), e.bool() && t.push(`${e.int(0, 59)}S`)), (t.length === 1 || t.length === 2 && t[1] === "T") && t.push("0D"), t.join("");
|
|
1293
|
+
}
|
|
1294
|
+
var Dt = /* @__PURE__ */ new Map([["date-time", gt], ["date", he], ["time", de], ["duration", Mt], ["email", re], ["idn-email", re], ["uri", q], ["uri-reference", q], ["iri", q], ["iri-reference", q], ["hostname", ie], ["idn-hostname", ie], ["ipv4", jt], ["ipv6", Pt], ["uuid", kt], ["json-pointer", oe], ["relative-json-pointer", (e) => `${e.int(0, 5)}${oe(e)}`]]);
|
|
1295
|
+
function ge(e) {
|
|
1296
|
+
let t = new Map(Dt);
|
|
1297
|
+
if (e) for (let [n, r] of Object.entries(e)) t.set(n, r);
|
|
1298
|
+
return t;
|
|
1299
|
+
}
|
|
1300
|
+
function St(e, t, n) {
|
|
1301
|
+
n.set(e, t);
|
|
1302
|
+
}
|
|
1303
|
+
function At(e, t) {
|
|
1304
|
+
if (!e.startsWith("$")) throw Error(`Invalid JSONPath: ${e} (must start with $)`);
|
|
1305
|
+
let n = e.slice(1).split(/\.|\[(\d+|\*)\]/).filter(Boolean), r = [t];
|
|
1306
|
+
for (let i of n) {
|
|
1307
|
+
if (i === "") continue;
|
|
1308
|
+
let o = [];
|
|
1309
|
+
for (let a of r)
|
|
1310
|
+
if (a != null)
|
|
1311
|
+
if (i === "*")
|
|
1312
|
+
Array.isArray(a) && o.push(...a);
|
|
1313
|
+
else if (/^\d+$/.test(i)) {
|
|
1314
|
+
let l = parseInt(i, 10);
|
|
1315
|
+
Array.isArray(a) && l < a.length && o.push(a[l]);
|
|
1316
|
+
} else i === "" ? U(a, o) : typeof a == "object" && a !== null && i in a && o.push(a[i]);
|
|
1317
|
+
r = o;
|
|
1318
|
+
}
|
|
1319
|
+
return r;
|
|
1320
|
+
}
|
|
1321
|
+
function U(e, t) {
|
|
1322
|
+
if (e != null) {
|
|
1323
|
+
if (Array.isArray(e)) for (let n of e) t.push(n), U(n, t);
|
|
1324
|
+
else if (typeof e == "object") for (let n of Object.values(e)) t.push(n), U(n, t);
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
function Lt(e) {
|
|
1328
|
+
if (e.properties) return e.properties;
|
|
1329
|
+
if (e.type === "object" || e.type === void 0) {
|
|
1330
|
+
let t = {}, n = !1;
|
|
1331
|
+
for (let [r, i] of Object.entries(e))
|
|
1332
|
+
J.has(r) || (me(i) ? (t[r] = i, n = !0) : (t[r] = { const: i }, n = !0));
|
|
1333
|
+
if (n) return t;
|
|
1334
|
+
}
|
|
1335
|
+
return {};
|
|
1336
|
+
}
|
|
1337
|
+
async function Y(e, t, n, r) {
|
|
1338
|
+
if (!n.resolveJsonPath) return e;
|
|
1339
|
+
let i = r ?? e;
|
|
1340
|
+
if (t === !0 || t === !1 || t.$ref) return e;
|
|
1341
|
+
let o = t;
|
|
1342
|
+
if (o.allOf || o.anyOf || o.oneOf) return e;
|
|
1343
|
+
if (typeof e == "object" && e !== null && !Array.isArray(e)) {
|
|
1344
|
+
let a = { ...e }, l = Lt(o);
|
|
1345
|
+
for (let [s, p] of Object.entries(l)) if (s in a) {
|
|
1346
|
+
let y = a[s];
|
|
1347
|
+
if (typeof p == "object" && p !== null && "jsonPath" in p && typeof p.jsonPath == "string") {
|
|
1348
|
+
let h = At(p.jsonPath, i);
|
|
1349
|
+
h.length > 0 && (a[s] = n.random.pick(h));
|
|
1350
|
+
} else {
|
|
1351
|
+
let h = await Y(y, p, n, i);
|
|
1352
|
+
a[s] = h;
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
return a;
|
|
1356
|
+
}
|
|
1357
|
+
if (Array.isArray(e) && o.items) {
|
|
1358
|
+
let a = [];
|
|
1359
|
+
for (let l of e) {
|
|
1360
|
+
let s = await Y(l, o.items, n, i);
|
|
1361
|
+
a.push(s);
|
|
1362
|
+
}
|
|
1363
|
+
return a;
|
|
1364
|
+
}
|
|
1365
|
+
return e;
|
|
1366
|
+
}
|
|
1367
|
+
var ye = ge(), ae = /* @__PURE__ */ new Set(["https://json-schema.org/draft/2020-12/schema", "https://json-schema.org/draft/2019-09/schema"]);
|
|
1368
|
+
async function V(e, t) {
|
|
1369
|
+
if ((t == null ? void 0 : t.validateSchemaVersion) === !0 && !(t != null && t.propAliases) && typeof e == "object" && e !== null && "$schema" in e) {
|
|
1370
|
+
let h = e.$schema;
|
|
1371
|
+
if (typeof h == "string" && !ae.has(h)) throw Error(`Unsupported JSON Schema version: ${h}. Supported versions: ${[...ae].join(", ")}`);
|
|
1372
|
+
}
|
|
1373
|
+
let n = qt(t), r = le((t == null ? void 0 : t.seed) ?? 1), i = n.propAliases ? Tt(e, n.propAliases) : e, o = _e(i);
|
|
1374
|
+
Ke(i, o);
|
|
1375
|
+
let a = n.formats ? ge(n.formats) : new Map(ye), l = n.refDepthMin ?? n.refDepth, s = n.refDepthMax ?? n.refDepth;
|
|
1376
|
+
if (l !== void 0 && s !== void 0 && l > s) throw Error(`refDepthMin (${l}) cannot be greater than refDepthMax (${s})`);
|
|
1377
|
+
let p = { random: r, maxDepth: n.maxDepth ?? (s ? s + 20 : 5), maxDefaultItems: n.maxDefaultItems ?? 3, optionalsProbability: n.optionalsProbability ?? 0.5, depth: 0, refRegistry: o, refStack: /* @__PURE__ */ new Set(), formatRegistry: a, refResolver: n.refResolver, minItems: n.minItems, maxItems: n.maxItems, minLength: n.minLength, maxLength: n.maxLength, useDefaultValue: n.useDefaultValue, path: "/", outputPath: "/", alwaysFakeOptionals: n.alwaysFakeOptionals, fixedProbabilities: n.fixedProbabilities, fillProperties: n.fillProperties, extensions: n.extensions, resolveJsonPath: n.resolveJsonPath, autoIncrementCounters: /* @__PURE__ */ new Map(), refDepth: 0, refDepthMin: l, refDepthMax: s, useExamplesValue: n.useExamplesValue, pruneProperties: n.pruneProperties, failOnInvalidTypes: n.failOnInvalidTypes, defaultInvalidTypeProduct: n.defaultInvalidTypeProduct, minDateTime: n.minDateTime, maxDateTime: n.maxDateTime, propAliases: n.propAliases, outputTransform: n.outputTransform }, y = await v(i, p);
|
|
1378
|
+
return n.resolveJsonPath ? Y(y, e, p, y) : y;
|
|
1379
|
+
}
|
|
1380
|
+
function Wt(e) {
|
|
1381
|
+
let t = { ...e }, n = 0;
|
|
1382
|
+
return { generate(r) {
|
|
1383
|
+
let i = (t.seed ?? 1) + n++;
|
|
1384
|
+
return V(r, { ...t, seed: i });
|
|
1385
|
+
} };
|
|
1386
|
+
}
|
|
1387
|
+
function Ut(e, t) {
|
|
1388
|
+
St(e, t, ye);
|
|
1389
|
+
}
|
|
1390
|
+
function Yt(e, t) {
|
|
1391
|
+
at(e, t);
|
|
1392
|
+
}
|
|
1393
|
+
function zt(e) {
|
|
1394
|
+
lt(e);
|
|
1395
|
+
}
|
|
1396
|
+
async function Et(e, t) {
|
|
1397
|
+
let n = await V(e, t), r = (t == null ? void 0 : t.pretty) !== !1 ? { space: 2, ...t == null ? void 0 : t.jsonStringifyOptions } : { space: 0, ...t == null ? void 0 : t.jsonStringifyOptions };
|
|
1398
|
+
return JSON.stringify(n, r.replacer, r.space);
|
|
1399
|
+
}
|
|
1400
|
+
function Vt(e) {
|
|
1401
|
+
let t = { ...e }, n = 0;
|
|
1402
|
+
return { generate(r) {
|
|
1403
|
+
let i = (t.seed ?? 1) + n++;
|
|
1404
|
+
return Et(r, { ...t, seed: i });
|
|
1405
|
+
} };
|
|
1406
|
+
}
|
|
1407
|
+
async function Nt(e, t) {
|
|
1408
|
+
var n;
|
|
1409
|
+
let r = (t == null ? void 0 : t.yaml) ?? ((n = t == null ? void 0 : t.extensions) == null ? void 0 : n.yaml);
|
|
1410
|
+
if (!r) throw Error("YAML support requires 'yaml' package. Provide via options.extensions.yaml or options.yaml.");
|
|
1411
|
+
let i = await V(e, t), o = (t == null ? void 0 : t.pretty) !== !1 ? { indent: 2, lineWidth: 0 } : {};
|
|
1412
|
+
return r.stringify(i, o);
|
|
1413
|
+
}
|
|
1414
|
+
function Zt(e) {
|
|
1415
|
+
let t = { ...e }, n = 0;
|
|
1416
|
+
return { generate(r) {
|
|
1417
|
+
let i = (t.seed ?? 1) + n++;
|
|
1418
|
+
return Nt(r, { ...t, seed: i });
|
|
1419
|
+
} };
|
|
1420
|
+
}
|
|
1421
|
+
function Tt(e, t) {
|
|
1422
|
+
if (typeof e != "object" || e === null) return e;
|
|
1423
|
+
let n = e, r = null;
|
|
1424
|
+
for (let [i, o] of Object.entries(t)) i in n && !(o in n) && (r || (r = { ...n }), r[o] = r[i], delete r[i]);
|
|
1425
|
+
return r ?? e;
|
|
1426
|
+
}
|
|
1427
|
+
function qt(e) {
|
|
1428
|
+
if (!e) return {};
|
|
1429
|
+
let t = e, n = { ...e };
|
|
1430
|
+
return t.requiredOnly === !0 && n.optionalsProbability === void 0 && (n = { ...n, optionalsProbability: 0, alwaysFakeOptionals: !1 }), t.ignoreProperties && t.ignoreProperties.length > 0 && (n = { ...n, outputTransform: Ct(n.outputTransform, Jt(t.ignoreProperties)) }), n;
|
|
1431
|
+
}
|
|
1432
|
+
function Ct(e, t) {
|
|
1433
|
+
return e ? t ? async (n, r, i) => {
|
|
1434
|
+
let o = await e(n, r, i);
|
|
1435
|
+
return t(o, r, i);
|
|
1436
|
+
} : e : t;
|
|
1437
|
+
}
|
|
1438
|
+
function Jt(e) {
|
|
1439
|
+
return (t, n, r) => {
|
|
1440
|
+
if (r === "/") return t;
|
|
1441
|
+
let i = Rt(r.slice(r.lastIndexOf("/") + 1));
|
|
1442
|
+
return e.some((o) => typeof o == "string" ? o === i : o instanceof RegExp ? o.test(i) : o(n)) ? void 0 : t;
|
|
1443
|
+
};
|
|
1444
|
+
}
|
|
1445
|
+
function Rt(e) {
|
|
1446
|
+
return e.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
1447
|
+
}
|
|
1448
|
+
export {
|
|
1449
|
+
Wt as createGenerator,
|
|
1450
|
+
Vt as createJsonGenerator,
|
|
1451
|
+
Ft as createRemoteResolver,
|
|
1452
|
+
Zt as createYamlGenerator,
|
|
1453
|
+
Yt as define,
|
|
1454
|
+
V as generate,
|
|
1455
|
+
Et as generateJson,
|
|
1456
|
+
Nt as generateYaml,
|
|
1457
|
+
Ut as registerFormat,
|
|
1458
|
+
zt as reset
|
|
1459
|
+
};
|