apiuikit 1.12.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -52
- package/dist/CodeSamples-C5Tl3k83.cjs +50 -0
- package/dist/{CodeSamples-BzQONJ_W.js → CodeSamples-bu8KSzOn.js} +1225 -1231
- package/dist/{LogoExtension-NutcLQ6T.cjs → LogoExtension-BVOE2HZc.cjs} +1 -1
- package/dist/{LogoExtension-DyWnBQ1M.js → LogoExtension-CZJpJnyk.js} +1 -1
- package/dist/apiuikit.cjs.js +1 -1
- package/dist/apiuikit.css +1 -1
- package/dist/apiuikit.es.js +1 -1
- package/dist/c-B4BAHWS4.cjs +1 -0
- package/dist/{c-Bz1-FJiA.js → c-C0DTNf68.js} +122 -63
- package/dist/components/AsyncCodeSample.d.ts +1 -1
- package/dist/components/Authorization.d.ts +5 -5
- package/dist/components/Bindings.d.ts +1 -1
- package/dist/components/ChannelAddress.d.ts +1 -1
- package/dist/components/CodeBlock.d.ts +1 -1
- package/dist/components/CodeSamples.d.ts +1 -1
- package/dist/components/CollapsiblePanel.d.ts +1 -1
- package/dist/components/ContentTab.d.ts +1 -1
- package/dist/components/CopyButton.d.ts +1 -1
- package/dist/components/DefinitionListItem.d.ts +1 -1
- package/dist/components/DocumentTopBar.d.ts +1 -1
- package/dist/components/ErrorBoundary.d.ts +1 -1
- package/dist/components/Examples.d.ts +1 -1
- package/dist/components/InfoMetadata.d.ts +1 -1
- package/dist/components/MarkdownExportMenu.d.ts +1 -1
- package/dist/components/MethodBadge.d.ts +1 -1
- package/dist/components/Navigation/AsyncAPINavigation.d.ts +1 -1
- package/dist/components/Navigation/Navigation.d.ts +1 -1
- package/dist/components/Navigation/OpenAPINavigation.d.ts +1 -1
- package/dist/components/Navigation/SpecNavigation.d.ts +1 -1
- package/dist/components/QueryParameters.d.ts +1 -1
- package/dist/components/RenderExtensions.d.ts +1 -1
- package/dist/components/Reply.d.ts +1 -1
- package/dist/components/SearchPanel.d.ts +1 -1
- package/dist/components/Section.d.ts +8 -1
- package/dist/components/ServerAddressBanner.d.ts +1 -1
- package/dist/components/TabToggle.d.ts +1 -1
- package/dist/components/Tabs.d.ts +2 -2
- package/dist/components/Tag.d.ts +1 -1
- package/dist/components/VerticalNavigation.d.ts +1 -1
- package/dist/components/schema/ExpandToggle.d.ts +1 -1
- package/dist/components/schema/SchemaCaseDetail.d.ts +1 -1
- package/dist/components/schema/SchemaConstraints.d.ts +1 -1
- package/dist/components/schema/SchemaFieldMeta.d.ts +1 -1
- package/dist/components/schema/SchemaIfThenElseBranch.d.ts +1 -1
- package/dist/components/schema/SchemaMapBranch.d.ts +1 -1
- package/dist/components/schema/SchemaNode.d.ts +1 -1
- package/dist/components/schema/SchemaNotBranch.d.ts +2 -2
- package/dist/components/schema/SchemaTab.d.ts +1 -1
- package/dist/components/schema/SchemaTree.d.ts +1 -1
- package/dist/components/schema/SchemaTreeBranch.d.ts +1 -1
- package/dist/components/schema/SchemaTreeRow.d.ts +1 -1
- package/dist/components/schema/SchemaTypeLabel.d.ts +1 -1
- package/dist/components/schema/SchemaUnionBranch.d.ts +1 -1
- package/dist/config/config.d.ts +17 -0
- package/dist/containers/AsyncAPI/AsyncAPI.d.ts +1 -1
- package/dist/containers/AsyncAPI/AsyncAPIDocumentProvider.d.ts +1 -1
- package/dist/containers/AsyncAPI/AsyncAPIRenderer.d.ts +1 -1
- package/dist/containers/AsyncAPI/Layout.d.ts +1 -1
- package/dist/containers/Information/InformationSection.d.ts +2 -2
- package/dist/containers/Information/OpenAPIInformation.d.ts +1 -1
- package/dist/containers/Messages/Message.d.ts +1 -1
- package/dist/containers/Messages/MessageDetails.d.ts +1 -1
- package/dist/containers/Messages/Messages.d.ts +1 -1
- package/dist/containers/OpenAPI/Layout.d.ts +1 -1
- package/dist/containers/OpenAPI/OpenAPI.d.ts +1 -1
- package/dist/containers/OpenAPI/OpenAPIDocumentProvider.d.ts +1 -1
- package/dist/containers/OpenAPI/OpenAPIRenderer.d.ts +1 -1
- package/dist/containers/Operation/Operation.d.ts +1 -1
- package/dist/containers/Operation/Operations.d.ts +1 -1
- package/dist/containers/Path/OperationCallbacks.d.ts +1 -1
- package/dist/containers/Path/PathOperation.d.ts +1 -1
- package/dist/containers/Path/Paths.d.ts +1 -1
- package/dist/containers/Path/ResponseLinks.d.ts +1 -1
- package/dist/containers/Schema/Schemas.d.ts +1 -1
- package/dist/containers/Server/OpenAPIServer.d.ts +1 -1
- package/dist/containers/Server/OpenAPIServers.d.ts +1 -1
- package/dist/containers/Server/Server.d.ts +1 -1
- package/dist/containers/Server/Servers.d.ts +1 -1
- package/dist/contexts/useSpec.d.ts +5 -0
- package/dist/{crystal-BcGgviMR.cjs → crystal-BA1RB3o9.cjs} +1 -1
- package/dist/{crystal-BtD5fR4q.js → crystal-C5EKc8oK.js} +29 -18
- package/dist/{csharp-AnFv7wyC.js → csharp-B6YWt0KR.js} +47 -47
- package/dist/csharp-IihVQN8U.cjs +1 -0
- package/dist/{go-BpetKc7b.cjs → go-By8nj0Vi.cjs} +1 -1
- package/dist/{go-CkZ9_bn0.js → go-C8VcBUsu.js} +7 -2
- package/dist/helpers/openapiParser.d.ts +1 -1
- package/dist/helpers/parser.d.ts +1 -1
- package/dist/hooks/useDocumentProviderValue.d.ts +1 -0
- package/dist/icons/ArrowDown.d.ts +1 -1
- package/dist/icons/ArrowRight.d.ts +1 -1
- package/dist/icons/AtSymbol.d.ts +1 -1
- package/dist/icons/BookOpen.d.ts +1 -1
- package/dist/icons/Check.d.ts +1 -1
- package/dist/icons/Clipboard.d.ts +1 -1
- package/dist/icons/Connection.d.ts +1 -1
- package/dist/icons/Copy.d.ts +1 -1
- package/dist/icons/ExternalLink.d.ts +1 -1
- package/dist/icons/Globe.d.ts +1 -1
- package/dist/icons/IconWrapper.d.ts +1 -1
- package/dist/icons/Info.d.ts +1 -1
- package/dist/icons/Link.d.ts +1 -1
- package/dist/icons/Message.d.ts +1 -1
- package/dist/icons/Operation.d.ts +1 -1
- package/dist/icons/Scale.d.ts +1 -1
- package/dist/icons/Schema.d.ts +1 -1
- package/dist/icons/Server.d.ts +1 -1
- package/dist/icons/ShieldCheck.d.ts +1 -1
- package/dist/icons/Tag.d.ts +1 -1
- package/dist/icons/Variable.d.ts +1 -1
- package/dist/index-1SEMQuYi.js +1704 -0
- package/dist/index-29FyeXas.cjs +137 -0
- package/dist/index-C2tdEw22.cjs +178 -0
- package/dist/{index-Zmu_k8_1.js → index-CbVUi36m.js} +3637 -3400
- package/dist/{index-ByyWsuPc.js → index-Ccaf5SNM.js} +10357 -10196
- package/dist/index-Ccy_JZ0T.cjs +4 -0
- package/dist/index-DKcgVKzx.cjs +107 -0
- package/dist/{index-CxOoKEXt.js → index-DkjcpZQZ.js} +3118 -3026
- package/dist/{java-BicX26Pg.js → java-BoRJOXvw.js} +48 -39
- package/dist/java-DFXAwvvK.cjs +1 -0
- package/dist/{kotlin-kGuORR5a.cjs → kotlin-B3HlgtFq.cjs} +2 -2
- package/dist/{kotlin-BwB8b-YX.js → kotlin-CIEA64JZ.js} +3 -1
- package/dist/markdown-assets/protoToJsonSchema-B7uaS_Ic.js +83 -0
- package/dist/markdown-assets/{protoToJsonSchema-CBPWaboT.js → protoToJsonSchema-CWtEPUyE.js} +1807 -1788
- package/dist/markdown.cjs +37 -37
- package/dist/markdown.es.js +927 -900
- package/dist/{php-DF4zG2hq.cjs → php-BMUCoWpx.cjs} +2 -2
- package/dist/{php-BL35ZHWM.js → php-DJ7KS8rT.js} +39 -33
- package/dist/plugins/OperationPluginTabs.d.ts +1 -1
- package/dist/plugins/PluginSlot.d.ts +2 -2
- package/dist/{protoToJsonSchema-DYct0Ubq.js → protoToJsonSchema-BvNrF6Ce.js} +787 -769
- package/dist/protoToJsonSchema-CQwj_Ytd.cjs +83 -0
- package/dist/{protobufSchemaParser-AhCAnBeA.cjs → protobufSchemaParser-DO1jnL81.cjs} +1 -1
- package/dist/{protobufSchemaParser-DDehPdy5.js → protobufSchemaParser-hOIbQrct.js} +2 -2
- package/dist/public/createSectionRoot.d.ts +1 -1
- package/dist/public/openapiSections.d.ts +5 -5
- package/dist/public/schemasSection.d.ts +1 -1
- package/dist/public/sections.d.ts +5 -5
- package/dist/{ruby-nPcbuC2a.cjs → ruby-CGL4kvvH.cjs} +1 -1
- package/dist/{ruby-CvOid-1s.js → ruby-t1jbZ0Fv.js} +2 -2
- package/dist/{rust-BocnJ3Ns.js → rust-DY-oA2gr.js} +40 -26
- package/dist/rust-_vvcEGSJ.cjs +1 -0
- package/dist/swift-BAji1QIq.cjs +1 -0
- package/dist/{swift-C35Eof-I.js → swift-CdDIFB_j.js} +25 -11
- package/dist/utils/theme.d.ts +14 -0
- package/package.json +20 -4
- package/dist/App.d.ts +0 -2
- package/dist/CodeSamples-BpMwzCbt.cjs +0 -50
- package/dist/c-C_Sx7N-F.cjs +0 -1
- package/dist/csharp-yuAGIuP4.cjs +0 -1
- package/dist/index-BKvXpIUY.cjs +0 -107
- package/dist/index-DCDYBZcY.js +0 -1461
- package/dist/index-DgKIIH6w.cjs +0 -139
- package/dist/index-DwDyiZr3.cjs +0 -178
- package/dist/index-d8kJa7YD.cjs +0 -4
- package/dist/java-BIk0G-rH.cjs +0 -1
- package/dist/main.d.ts +0 -0
- package/dist/markdown-assets/protoToJsonSchema-CgkcluFJ.js +0 -83
- package/dist/protoToJsonSchema-B86Gpg5n.cjs +0 -83
- package/dist/rust-DKnYCg2f.cjs +0 -1
- package/dist/swift-CAnH__EC.cjs +0 -1
|
@@ -0,0 +1,1704 @@
|
|
|
1
|
+
var Xe = Object.defineProperty;
|
|
2
|
+
var Ne = (e, t, i) => t in e ? Xe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
|
3
|
+
var Z = (e, t, i) => Ne(e, typeof t != "symbol" ? t + "" : t, i);
|
|
4
|
+
function We(e) {
|
|
5
|
+
let t = e | 0;
|
|
6
|
+
return () => {
|
|
7
|
+
t = t + 1831565813 | 0;
|
|
8
|
+
let i = Math.imul(t ^ t >>> 15, 1 | t);
|
|
9
|
+
return i = i + Math.imul(i ^ i >>> 7, 61 | i) ^ i, ((i ^ i >>> 14) >>> 0) / 4294967296;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function de(e) {
|
|
13
|
+
let t = We(e), i = { next() {
|
|
14
|
+
return t();
|
|
15
|
+
}, int(r, n) {
|
|
16
|
+
return r + Math.floor(i.next() * (n - r + 1));
|
|
17
|
+
}, bool(r = 0.5) {
|
|
18
|
+
return i.next() < r;
|
|
19
|
+
}, pick(r) {
|
|
20
|
+
return r[i.int(0, r.length - 1)];
|
|
21
|
+
}, shuffle(r) {
|
|
22
|
+
let n = [...r];
|
|
23
|
+
for (let o = n.length - 1; o > 0; o--) {
|
|
24
|
+
let l = i.int(0, o);
|
|
25
|
+
[n[o], n[l]] = [n[l], n[o]];
|
|
26
|
+
}
|
|
27
|
+
return n;
|
|
28
|
+
}, fork() {
|
|
29
|
+
let r = Math.floor(i.next() * 4294967296);
|
|
30
|
+
return de(r);
|
|
31
|
+
} };
|
|
32
|
+
return i;
|
|
33
|
+
}
|
|
34
|
+
function Te(e) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
function qe(e) {
|
|
38
|
+
return e.random.bool();
|
|
39
|
+
}
|
|
40
|
+
function he(e, t, i = !1) {
|
|
41
|
+
let r = -1e3, n = 1e3, o = !1, l = !1;
|
|
42
|
+
if (e.minimum !== void 0 && (r = e.minimum), e.maximum !== void 0 && (n = e.maximum), e.exclusiveMinimum !== void 0 && (r = e.exclusiveMinimum, o = !0), e.exclusiveMaximum !== void 0 && (n = e.exclusiveMaximum, l = !0), e.multipleOf !== void 0) return Ce(e.multipleOf, r, n, o, l, t);
|
|
43
|
+
if (i) {
|
|
44
|
+
let c = o ? Math.floor(r) + 1 : Math.ceil(r), g = l ? Math.ceil(n) - 1 : Math.floor(n);
|
|
45
|
+
return t.random.int(c, g);
|
|
46
|
+
}
|
|
47
|
+
let a = o ? r + Number.EPSILON : r, s = l ? n - Number.EPSILON : n;
|
|
48
|
+
return a + t.random.next() * (s - a);
|
|
49
|
+
}
|
|
50
|
+
function Ce(e, t, i, r, n, o) {
|
|
51
|
+
let l = Math.ceil(t / e), a = Math.floor(i / e);
|
|
52
|
+
return r && l * e === t && l++, n && a * e === i && a--, l > a ? l * e : o.random.int(l, a) * e;
|
|
53
|
+
}
|
|
54
|
+
function Re(e, t) {
|
|
55
|
+
if (e.autoIncrement) {
|
|
56
|
+
let i = e.initialOffset ?? 1, r = Ye(t.path), n = t.autoIncrementCounters ?? /* @__PURE__ */ new Map(), o = (n.get(r) ?? i - 1) + 1;
|
|
57
|
+
return n.set(r, o), t.autoIncrementCounters && t.autoIncrementCounters.set(r, o), o;
|
|
58
|
+
}
|
|
59
|
+
return he(e, t, !0);
|
|
60
|
+
}
|
|
61
|
+
function Ye(e) {
|
|
62
|
+
let t = /* @__PURE__ */ new Set(["items", "prefixItems", "contains", "additionalItems"]), i = e.split("/").filter((r) => r !== "");
|
|
63
|
+
return i.filter((r, n) => {
|
|
64
|
+
let o = i[n - 1];
|
|
65
|
+
return !(/^\d+$/.test(r) && o !== void 0 && t.has(o));
|
|
66
|
+
}).join("/");
|
|
67
|
+
}
|
|
68
|
+
function $(e, t) {
|
|
69
|
+
let i = ye(e, 0);
|
|
70
|
+
return L(i.node, t);
|
|
71
|
+
}
|
|
72
|
+
function L(e, t) {
|
|
73
|
+
switch (e.type) {
|
|
74
|
+
case "literal":
|
|
75
|
+
return e.value;
|
|
76
|
+
case "dot":
|
|
77
|
+
return t.pick([..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#%&*()-_=+[]{}|;:',.<>/? "]);
|
|
78
|
+
case "anchor":
|
|
79
|
+
return "";
|
|
80
|
+
case "charClass":
|
|
81
|
+
return _e(e, t);
|
|
82
|
+
case "sequence":
|
|
83
|
+
return e.nodes.map((i) => L(i, t)).join("");
|
|
84
|
+
case "alternation":
|
|
85
|
+
return L(t.pick(e.branches), t);
|
|
86
|
+
case "quantifier": {
|
|
87
|
+
let i = t.int(e.min, Math.min(e.max, e.min + 5));
|
|
88
|
+
return Array.from({ length: i }, () => L(e.node, t)).join("");
|
|
89
|
+
}
|
|
90
|
+
case "group":
|
|
91
|
+
return L(e.node, t);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function _e(e, t) {
|
|
95
|
+
if (!e.negated) return t.pick(e.chars);
|
|
96
|
+
let i = new Set(e.chars), r = [..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#%&*()-_=+[]{}|;:',.<>/? "].filter((n) => !i.has(n));
|
|
97
|
+
return r.length > 0 ? t.pick(r) : "a";
|
|
98
|
+
}
|
|
99
|
+
function ye(e, t) {
|
|
100
|
+
let i = [], r = [];
|
|
101
|
+
for (; t < e.length; ) {
|
|
102
|
+
let n = e[t];
|
|
103
|
+
if (n === ")") break;
|
|
104
|
+
if (n === "|") {
|
|
105
|
+
i.push(ee(r)), r = [], t++;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (n === "(") {
|
|
109
|
+
let a = t + 1;
|
|
110
|
+
if (e[a] === "?") if (e[a + 1] === ":") a += 2;
|
|
111
|
+
else if (e[a + 1] === "=" || e[a + 1] === "!") {
|
|
112
|
+
let v = 1, b = a;
|
|
113
|
+
for (; b < e.length && v > 0; )
|
|
114
|
+
b++, e[b] === "(" && v++, e[b] === ")" && v--;
|
|
115
|
+
t = b + 1;
|
|
116
|
+
continue;
|
|
117
|
+
} else {
|
|
118
|
+
for (a += 2; a < e.length && e[a] !== ">"; ) a++;
|
|
119
|
+
a++;
|
|
120
|
+
}
|
|
121
|
+
let s = ye(e, a), c = { type: "group", node: s.node };
|
|
122
|
+
t = s.pos + 1;
|
|
123
|
+
let g = J(e, t, c);
|
|
124
|
+
r.push(g.node), t = g.pos;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (n === "[") {
|
|
128
|
+
let a = ze(e, t), s = J(e, a.pos, a.node);
|
|
129
|
+
r.push(s.node), t = s.pos;
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
if (n === ".") {
|
|
133
|
+
let a = { type: "dot" };
|
|
134
|
+
t++;
|
|
135
|
+
let s = J(e, t, a);
|
|
136
|
+
r.push(s.node), t = s.pos;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (n === "^" || n === "$") {
|
|
140
|
+
r.push({ type: "anchor" }), t++;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (n === "\\") {
|
|
144
|
+
t++;
|
|
145
|
+
let a = Fe(e, t);
|
|
146
|
+
t = a.pos;
|
|
147
|
+
let s = J(e, t, a.node);
|
|
148
|
+
r.push(s.node), t = s.pos;
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
let o = { type: "literal", value: n };
|
|
152
|
+
t++;
|
|
153
|
+
let l = J(e, t, o);
|
|
154
|
+
r.push(l.node), t = l.pos;
|
|
155
|
+
}
|
|
156
|
+
return i.push(ee(r)), { node: i.length === 1 ? i[0] : { type: "alternation", branches: i }, pos: t };
|
|
157
|
+
}
|
|
158
|
+
function ee(e) {
|
|
159
|
+
return e.length === 0 ? { type: "literal", value: "" } : e.length === 1 ? e[0] : { type: "sequence", nodes: e };
|
|
160
|
+
}
|
|
161
|
+
function Fe(e, t) {
|
|
162
|
+
let i = e[t];
|
|
163
|
+
switch (t++, i) {
|
|
164
|
+
case "d":
|
|
165
|
+
return { node: { type: "charClass", chars: [..."0123456789"], negated: !1 }, pos: t };
|
|
166
|
+
case "D":
|
|
167
|
+
return { node: { type: "charClass", chars: [..."0123456789"], negated: !0 }, pos: t };
|
|
168
|
+
case "w":
|
|
169
|
+
return { node: { type: "charClass", chars: [..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"], negated: !1 }, pos: t };
|
|
170
|
+
case "W":
|
|
171
|
+
return { node: { type: "charClass", chars: [..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"], negated: !0 }, pos: t };
|
|
172
|
+
case "s":
|
|
173
|
+
return { node: { type: "charClass", chars: [...`
|
|
174
|
+
`], negated: !1 }, pos: t };
|
|
175
|
+
case "S":
|
|
176
|
+
return { node: { type: "charClass", chars: [...`
|
|
177
|
+
`], negated: !0 }, pos: t };
|
|
178
|
+
case "b":
|
|
179
|
+
case "B":
|
|
180
|
+
return { node: { type: "anchor" }, pos: t };
|
|
181
|
+
default:
|
|
182
|
+
return { node: { type: "literal", value: i }, pos: t };
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function ze(e, t) {
|
|
186
|
+
t++;
|
|
187
|
+
let i = !1;
|
|
188
|
+
e[t] === "^" && (i = !0, t++);
|
|
189
|
+
let r = [];
|
|
190
|
+
for (; t < e.length && e[t] !== "]"; ) {
|
|
191
|
+
if (e[t] === "\\" && t + 1 < e.length) {
|
|
192
|
+
t++;
|
|
193
|
+
let n = e[t];
|
|
194
|
+
switch (n) {
|
|
195
|
+
case "d":
|
|
196
|
+
r.push(..."0123456789");
|
|
197
|
+
break;
|
|
198
|
+
case "w":
|
|
199
|
+
r.push(..."abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_");
|
|
200
|
+
break;
|
|
201
|
+
case "s":
|
|
202
|
+
r.push(...`
|
|
203
|
+
`);
|
|
204
|
+
break;
|
|
205
|
+
default:
|
|
206
|
+
r.push(n);
|
|
207
|
+
}
|
|
208
|
+
t++;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
if (t + 2 < e.length && e[t + 1] === "-" && e[t + 2] !== "]") {
|
|
212
|
+
let n = e.charCodeAt(t), o = e.charCodeAt(t + 2);
|
|
213
|
+
for (let l = n; l <= o; l++) r.push(String.fromCharCode(l));
|
|
214
|
+
t += 3;
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
r.push(e[t]), t++;
|
|
218
|
+
}
|
|
219
|
+
return t++, { node: { type: "charClass", chars: r, negated: i }, pos: t };
|
|
220
|
+
}
|
|
221
|
+
function J(e, t, i) {
|
|
222
|
+
if (t >= e.length) return { node: i, pos: t };
|
|
223
|
+
let r = e[t], n, o;
|
|
224
|
+
switch (r) {
|
|
225
|
+
case "*":
|
|
226
|
+
n = 0, o = 5, t++;
|
|
227
|
+
break;
|
|
228
|
+
case "+":
|
|
229
|
+
n = 1, o = 5, t++;
|
|
230
|
+
break;
|
|
231
|
+
case "?":
|
|
232
|
+
n = 0, o = 1, t++;
|
|
233
|
+
break;
|
|
234
|
+
case "{": {
|
|
235
|
+
let l = Ue(e, t);
|
|
236
|
+
if (l) n = l.min, o = l.max, t = l.pos;
|
|
237
|
+
else return { node: i, pos: t };
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
default:
|
|
241
|
+
return { node: i, pos: t };
|
|
242
|
+
}
|
|
243
|
+
return t < e.length && (e[t] === "?" || e[t] === "+") && t++, { node: { type: "quantifier", node: i, min: n, max: o }, pos: t };
|
|
244
|
+
}
|
|
245
|
+
function Ue(e, t) {
|
|
246
|
+
let i = e.slice(t).match(/^\{(\d+)(?:,(\d*))?\}/);
|
|
247
|
+
if (!i) return null;
|
|
248
|
+
let r = parseInt(i[1], 10), n;
|
|
249
|
+
return i[2] === void 0 ? n = r : i[2] === "" ? n = r + 5 : n = parseInt(i[2], 10), { min: r, max: n, pos: t + i[0].length };
|
|
250
|
+
}
|
|
251
|
+
function M(e) {
|
|
252
|
+
return e < 10 ? `0${e}` : `${e}`;
|
|
253
|
+
}
|
|
254
|
+
function Ve(e, t) {
|
|
255
|
+
return new Date(e, t, 0).getDate();
|
|
256
|
+
}
|
|
257
|
+
var ge = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
258
|
+
function Ge(e) {
|
|
259
|
+
return !(e === "^" || e === "$" || e === "^$");
|
|
260
|
+
}
|
|
261
|
+
function Be(e, t) {
|
|
262
|
+
if (e.format) {
|
|
263
|
+
if (e.format === "date-time" && (t.minDateTime !== void 0 || t.maxDateTime !== void 0)) return Ke(t);
|
|
264
|
+
let l = t.formatRegistry.get(e.format);
|
|
265
|
+
if (l) {
|
|
266
|
+
let a = l(t.random), s = t.minLength ?? e.minLength, c = t.maxLength ?? e.maxLength;
|
|
267
|
+
return s !== void 0 && a.length < s ? R(a, s, t) : c !== void 0 && a.length > c ? a.slice(0, c) : a;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
if (e.pattern) {
|
|
271
|
+
let l = t.minLength ?? e.minLength, a = t.maxLength ?? e.maxLength;
|
|
272
|
+
for (let g = 0; g < 50; g++) {
|
|
273
|
+
let v = $(e.pattern, t.random);
|
|
274
|
+
if (!(l !== void 0 && v.length < l) && !(a !== void 0 && v.length > a))
|
|
275
|
+
return v;
|
|
276
|
+
}
|
|
277
|
+
let s = $(e.pattern, t.random), c = Ge(e.pattern);
|
|
278
|
+
return l !== void 0 && s.length < l && c ? R(s, l, t) : a !== void 0 && s.length > a ? s.slice(0, a) : s;
|
|
279
|
+
}
|
|
280
|
+
let i = e.minLength ?? 0, r = e.maxLength ?? Math.max(i + 10, 10), n = t.random.int(i, r), o = "";
|
|
281
|
+
for (let l = 0; l < n; l++) o += t.random.pick([...ge]);
|
|
282
|
+
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;
|
|
283
|
+
}
|
|
284
|
+
function R(e, t, i) {
|
|
285
|
+
for (; e.length < t; ) e += i.random.pick([...ge]);
|
|
286
|
+
return e;
|
|
287
|
+
}
|
|
288
|
+
function Ke(e) {
|
|
289
|
+
let t = e.minDateTime ? new Date(e.minDateTime) : /* @__PURE__ */ new Date("1970-01-01"), i = e.maxDateTime ? new Date(e.maxDateTime) : /* @__PURE__ */ new Date(), r = t.getTime(), n = i.getTime(), o = r + e.random.next() * (n - r), l = new Date(o), a = l.getFullYear(), s = M(l.getMonth() + 1), c = M(l.getDate());
|
|
290
|
+
return `${a}-${s}-${c}T01:01:01.0Z`;
|
|
291
|
+
}
|
|
292
|
+
function te(e, t) {
|
|
293
|
+
if (e.const !== void 0) return structuredClone(e.const);
|
|
294
|
+
if (e.enum !== void 0 && e.enum.length > 0) {
|
|
295
|
+
let i = e.enum;
|
|
296
|
+
if (e.minimum !== void 0 || e.maximum !== void 0 || e.exclusiveMinimum !== void 0 || e.exclusiveMaximum !== void 0 || e.multipleOf !== void 0) {
|
|
297
|
+
let n = e.exclusiveMinimum ?? e.minimum ?? -1 / 0, o = e.exclusiveMaximum ?? e.maximum ?? 1 / 0, l = e.exclusiveMinimum !== void 0, a = e.exclusiveMaximum !== void 0;
|
|
298
|
+
i = i.filter((s) => {
|
|
299
|
+
if (typeof s != "number") return !0;
|
|
300
|
+
let c = l ? s > n : s >= n, g = a ? s < o : s <= o;
|
|
301
|
+
if (!c || !g) return !1;
|
|
302
|
+
if (e.multipleOf !== void 0) {
|
|
303
|
+
let v = e.multipleOf, b = v.toString().includes(".") ? v.toString().split(".")[1].length : 0, w = Math.pow(10, b), k = Math.round(s * w), A = Math.round(v * w);
|
|
304
|
+
if (k % A !== 0) return !1;
|
|
305
|
+
}
|
|
306
|
+
return !0;
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
if (e.minLength !== void 0 || e.maxLength !== void 0) {
|
|
310
|
+
let n = e.minLength ?? 0, o = e.maxLength ?? 1 / 0;
|
|
311
|
+
i = i.filter((l) => typeof l != "string" ? !0 : l.length >= n && l.length <= o);
|
|
312
|
+
}
|
|
313
|
+
if (e.minItems !== void 0 || e.maxItems !== void 0) {
|
|
314
|
+
let n = e.minItems ?? 0, o = e.maxItems ?? 1 / 0;
|
|
315
|
+
i = i.filter((l) => Array.isArray(l) ? l.length >= n && l.length <= o : !0);
|
|
316
|
+
}
|
|
317
|
+
if (e.minProperties !== void 0 || e.maxProperties !== void 0) {
|
|
318
|
+
let n = e.minProperties ?? 0, o = e.maxProperties ?? 1 / 0;
|
|
319
|
+
i = i.filter((l) => typeof l != "object" || l === null || Array.isArray(l) ? !0 : Object.keys(l).length >= n && Object.keys(l).length <= o);
|
|
320
|
+
}
|
|
321
|
+
if (i.length === 0) {
|
|
322
|
+
let n = [];
|
|
323
|
+
throw e.minLength !== void 0 && n.push(`minLength: ${e.minLength}`), e.maxLength !== void 0 && n.push(`maxLength: ${e.maxLength}`), e.minItems !== void 0 && n.push(`minItems: ${e.minItems}`), e.maxItems !== void 0 && n.push(`maxItems: ${e.maxItems}`), e.minProperties !== void 0 && n.push(`minProperties: ${e.minProperties}`), e.maxProperties !== void 0 && n.push(`maxProperties: ${e.maxProperties}`), e.minimum !== void 0 && n.push(`minimum: ${e.minimum}`), e.maximum !== void 0 && n.push(`maximum: ${e.maximum}`), e.exclusiveMinimum !== void 0 && n.push(`exclusiveMinimum: ${e.exclusiveMinimum}`), e.exclusiveMaximum !== void 0 && n.push(`exclusiveMaximum: ${e.exclusiveMaximum}`), e.multipleOf !== void 0 && n.push(`multipleOf: ${e.multipleOf}`), Error(`enum values conflict with constraints [${n.join(", ")}] at ${t.path}`);
|
|
324
|
+
}
|
|
325
|
+
let r = t.random.pick(i);
|
|
326
|
+
return typeof r == "object" && r !== null ? structuredClone(r) : r;
|
|
327
|
+
}
|
|
328
|
+
throw Error(`generateEnumConst called without enum or const at ${t.path}`);
|
|
329
|
+
}
|
|
330
|
+
function q(e) {
|
|
331
|
+
return typeof e == "object" && e !== null && "then" in e && typeof e.then == "function";
|
|
332
|
+
}
|
|
333
|
+
var ve = Symbol("walkCall");
|
|
334
|
+
function j(e, t) {
|
|
335
|
+
return { [ve]: !0, schema: e, ctx: t };
|
|
336
|
+
}
|
|
337
|
+
function xe(e) {
|
|
338
|
+
return typeof e == "object" && e !== null && ve in e;
|
|
339
|
+
}
|
|
340
|
+
function N(e, t) {
|
|
341
|
+
e.push({ gen: t, sent: void 0, hasThrown: !1, threw: void 0 });
|
|
342
|
+
}
|
|
343
|
+
function be(e) {
|
|
344
|
+
let t = e[e.length - 1], i;
|
|
345
|
+
try {
|
|
346
|
+
i = t.hasThrown ? t.gen.throw(t.threw) : t.gen.next(t.sent);
|
|
347
|
+
} catch (r) {
|
|
348
|
+
if (e.pop(), e.length === 0) throw r;
|
|
349
|
+
let n = e[e.length - 1];
|
|
350
|
+
n.hasThrown = !0, n.threw = r;
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
return t.hasThrown = !1, i;
|
|
354
|
+
}
|
|
355
|
+
async function Ze(e, t) {
|
|
356
|
+
let i = [];
|
|
357
|
+
for (N(i, e); ; ) {
|
|
358
|
+
let r = be(i);
|
|
359
|
+
if (r === void 0) continue;
|
|
360
|
+
if (r.done) {
|
|
361
|
+
if (i.pop(), i.length === 0) return r.value;
|
|
362
|
+
i[i.length - 1].sent = r.value;
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
if (xe(r.value)) {
|
|
366
|
+
N(i, t(r.value.schema, r.value.ctx));
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
let n = i[i.length - 1];
|
|
370
|
+
try {
|
|
371
|
+
n.sent = await r.value;
|
|
372
|
+
} catch (o) {
|
|
373
|
+
n.hasThrown = !0, n.threw = o;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
function $e(e, t) {
|
|
378
|
+
let i = [];
|
|
379
|
+
for (N(i, e); ; ) {
|
|
380
|
+
let r = be(i);
|
|
381
|
+
if (r !== void 0) {
|
|
382
|
+
if (r.done) {
|
|
383
|
+
if (i.pop(), i.length === 0) return r.value;
|
|
384
|
+
i[i.length - 1].sent = r.value;
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
if (xe(r.value)) {
|
|
388
|
+
N(i, t(r.value.schema, r.value.ctx));
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
if (q(r.value)) throw Error("generateSync() encountered an unexpected asynchronous operation.");
|
|
392
|
+
i[i.length - 1].sent = r.value;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
function I(e) {
|
|
397
|
+
let t = {};
|
|
398
|
+
for (let i of e) {
|
|
399
|
+
if (typeof i == "boolean") {
|
|
400
|
+
if (!i) return { not: {} };
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
403
|
+
je(t, i);
|
|
404
|
+
}
|
|
405
|
+
return t;
|
|
406
|
+
}
|
|
407
|
+
function we(e, t) {
|
|
408
|
+
if (typeof e == "boolean" || typeof t == "boolean") return {};
|
|
409
|
+
if (typeof e != "object" || e === null) return typeof t == "object" && t !== null ? t : {};
|
|
410
|
+
if (typeof t != "object" || t === null) return e;
|
|
411
|
+
let i = { ...e };
|
|
412
|
+
return je(i, t), i;
|
|
413
|
+
}
|
|
414
|
+
function je(e, t) {
|
|
415
|
+
if (t.type !== void 0 && (e.type === void 0 ? e.type = t.type : e.type = et(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;
|
|
416
|
+
else {
|
|
417
|
+
let i = [], r = Math.max(e.prefixItems.length, t.prefixItems.length);
|
|
418
|
+
for (let n = 0; n < r; n++) {
|
|
419
|
+
let o = e.prefixItems[n], l = t.prefixItems[n];
|
|
420
|
+
o !== void 0 && l !== void 0 ? i.push(we(o, l)) : o !== void 0 ? i.push(o) : l !== void 0 && i.push(l);
|
|
421
|
+
}
|
|
422
|
+
e.prefixItems = i;
|
|
423
|
+
}
|
|
424
|
+
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 = tt(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) {
|
|
425
|
+
let i = new Set(t.enum.map((r) => JSON.stringify(r)));
|
|
426
|
+
e.enum = e.enum.filter((r) => i.has(JSON.stringify(r)));
|
|
427
|
+
} else e.enum = t.enum;
|
|
428
|
+
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);
|
|
429
|
+
}
|
|
430
|
+
function et(e, t) {
|
|
431
|
+
let i = Array.isArray(e) ? e : [e], r = Array.isArray(t) ? t : [t], n = i.filter((o) => r.includes(o));
|
|
432
|
+
return n.length === 0 ? i[0] : n.length === 1 ? n[0] : n;
|
|
433
|
+
}
|
|
434
|
+
function tt(e, t) {
|
|
435
|
+
let i = { ...e };
|
|
436
|
+
for (let [r, n] of Object.entries(t)) {
|
|
437
|
+
let o = e[r];
|
|
438
|
+
o === void 0 ? i[r] = n : typeof o == "object" && typeof n == "object" ? i[r] = we(o, n) : i[r] = n;
|
|
439
|
+
}
|
|
440
|
+
return i;
|
|
441
|
+
}
|
|
442
|
+
var C = /* @__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"]);
|
|
443
|
+
function Oe(e) {
|
|
444
|
+
return typeof e != "object" || e === null ? !1 : Object.keys(e).some((t) => C.has(t));
|
|
445
|
+
}
|
|
446
|
+
function F(e) {
|
|
447
|
+
if (e.properties) return e.properties;
|
|
448
|
+
if (e.type === "object" || e.type === void 0) {
|
|
449
|
+
let t = {}, i = !1;
|
|
450
|
+
for (let [r, n] of Object.entries(e))
|
|
451
|
+
C.has(r) || (Oe(n) ? (t[r] = n, i = !0) : (t[r] = { const: n }, i = !0));
|
|
452
|
+
if (i) return t;
|
|
453
|
+
}
|
|
454
|
+
return {};
|
|
455
|
+
}
|
|
456
|
+
function Pe(e, t) {
|
|
457
|
+
return e.required ? e.required : e.properties === void 0 && Object.keys(t).length > 0 ? Object.keys(t) : [];
|
|
458
|
+
}
|
|
459
|
+
function ke(e, t) {
|
|
460
|
+
let i = e.alwaysFakeOptionals ?? !1, r = e.fixedProbabilities ?? !1, n = e.optionalsProbability ?? 0.5, o;
|
|
461
|
+
if (r && !i && t.length > 0) {
|
|
462
|
+
let l = Math.round(t.length * n);
|
|
463
|
+
o = new Set(t.slice(0, l));
|
|
464
|
+
}
|
|
465
|
+
return (l) => i ? !0 : o ? o.has(l) : e.random.bool(n);
|
|
466
|
+
}
|
|
467
|
+
function Ie(e) {
|
|
468
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
469
|
+
}
|
|
470
|
+
function it(e) {
|
|
471
|
+
return e.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
472
|
+
}
|
|
473
|
+
function D(e, t) {
|
|
474
|
+
let i = it(t), r = e.outputPath === "/" ? `/${i}` : `${e.outputPath}/${i}`, n = e.path === "/" ? `/${i}` : `${e.path}/${i}`;
|
|
475
|
+
return { ...e, path: n, outputPath: r };
|
|
476
|
+
}
|
|
477
|
+
function rt(e) {
|
|
478
|
+
let t = F(e);
|
|
479
|
+
if (Object.keys(t).length > 0) return t;
|
|
480
|
+
if (Array.isArray(e.allOf)) {
|
|
481
|
+
let i = {};
|
|
482
|
+
for (let r of e.allOf) {
|
|
483
|
+
if (typeof r != "object" || r === null) continue;
|
|
484
|
+
let n = F(r);
|
|
485
|
+
Object.assign(i, n);
|
|
486
|
+
}
|
|
487
|
+
return i;
|
|
488
|
+
}
|
|
489
|
+
return {};
|
|
490
|
+
}
|
|
491
|
+
function nt(e, t) {
|
|
492
|
+
let i = Pe(e, t);
|
|
493
|
+
if (i.length > 0) return i;
|
|
494
|
+
if (Array.isArray(e.allOf)) {
|
|
495
|
+
let r = [];
|
|
496
|
+
for (let n of e.allOf) {
|
|
497
|
+
if (typeof n != "object" || n === null) continue;
|
|
498
|
+
let o = n;
|
|
499
|
+
Array.isArray(o.required) && r.push(...o.required);
|
|
500
|
+
}
|
|
501
|
+
if (r.length > 0) return [...new Set(r)];
|
|
502
|
+
}
|
|
503
|
+
return [];
|
|
504
|
+
}
|
|
505
|
+
function ot(e, t, i) {
|
|
506
|
+
return !Ie(e) || typeof t != "object" || t === null ? e : Me(e, t, i);
|
|
507
|
+
}
|
|
508
|
+
function Me(e, t, i) {
|
|
509
|
+
if (i.alwaysFakeOptionals === !0) return e;
|
|
510
|
+
let r = rt(t);
|
|
511
|
+
if (Object.keys(r).length === 0) return e;
|
|
512
|
+
let n = nt(t, r), o = new Set(n), l = new Set(Object.keys(r)), a = [...l].filter((w) => !o.has(w)), s = ke(i, a), c = /* @__PURE__ */ new Set([...l, ...Object.keys(e)]), g = i.path === "/" ? "/properties" : `${i.path}/properties`, v = { ...i, depth: i.depth + 1, path: g }, b = {};
|
|
513
|
+
for (let w of c) {
|
|
514
|
+
if (!(w in e)) continue;
|
|
515
|
+
let k = D(v, w), A = r[w] ?? !0;
|
|
516
|
+
(!(l.has(w) && !o.has(w)) || s(w)) && (b[w] = ot(e[w], A, k));
|
|
517
|
+
}
|
|
518
|
+
return b;
|
|
519
|
+
}
|
|
520
|
+
function Y(e, t, i) {
|
|
521
|
+
return !i.filterExampleDefaults || !Ie(e) ? e : Me(e, t, i);
|
|
522
|
+
}
|
|
523
|
+
function ie(e, t) {
|
|
524
|
+
if (typeof t != "object" || t === null) return !1;
|
|
525
|
+
let i = t;
|
|
526
|
+
return i.const !== void 0 ? e === i.const : i.enum !== void 0 ? i.enum.some((r) => r === e) : !1;
|
|
527
|
+
}
|
|
528
|
+
function Ae(e) {
|
|
529
|
+
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;
|
|
530
|
+
}
|
|
531
|
+
function _(e) {
|
|
532
|
+
let t = [];
|
|
533
|
+
if (e.dependentRequired)
|
|
534
|
+
for (let [i, r] of Object.entries(e.dependentRequired)) Array.isArray(r) && t.push([i, r.filter((n) => typeof n == "string")]);
|
|
535
|
+
if (e.dependencies)
|
|
536
|
+
for (let [i, r] of Object.entries(e.dependencies)) Array.isArray(r) && t.push([i, r.filter((n) => typeof n == "string")]);
|
|
537
|
+
return t;
|
|
538
|
+
}
|
|
539
|
+
function lt(e) {
|
|
540
|
+
let t = [];
|
|
541
|
+
if (e.dependencies)
|
|
542
|
+
for (let [i, r] of Object.entries(e.dependencies)) Array.isArray(r) || t.push([i, r]);
|
|
543
|
+
if (e.dependentSchemas) for (let [i, r] of Object.entries(e.dependentSchemas)) t.push([i, r]);
|
|
544
|
+
return t;
|
|
545
|
+
}
|
|
546
|
+
function* at(e, t, i, r, n, o, l = { type: "string" }) {
|
|
547
|
+
if (i[o] !== void 0) return;
|
|
548
|
+
let a = t[o];
|
|
549
|
+
if (a === void 0 && e.patternProperties) {
|
|
550
|
+
let g = [];
|
|
551
|
+
for (let [v, b] of Object.entries(e.patternProperties)) try {
|
|
552
|
+
new RegExp(v).test(o) && g.push(b);
|
|
553
|
+
} catch {
|
|
554
|
+
}
|
|
555
|
+
g.length > 0 && (a = g.length === 1 ? g[0] : I(g));
|
|
556
|
+
}
|
|
557
|
+
if (a === void 0) {
|
|
558
|
+
if (e.additionalProperties === !1) return;
|
|
559
|
+
a = e.additionalProperties !== void 0 && e.additionalProperties !== !0 ? e.additionalProperties : l;
|
|
560
|
+
}
|
|
561
|
+
if (Ae(a)) return;
|
|
562
|
+
let s = D(n, o), c = yield j(a, s);
|
|
563
|
+
c !== void 0 && (i[o] = c, r.add(o));
|
|
564
|
+
}
|
|
565
|
+
function* st(e, t) {
|
|
566
|
+
var A;
|
|
567
|
+
let i = F(e), r = Pe(e, i);
|
|
568
|
+
if (t.depth >= t.maxDepth) {
|
|
569
|
+
let u = new Set(r);
|
|
570
|
+
for (let [f, p] of _(e)) if (u.has(f)) for (let h of p) u.add(h);
|
|
571
|
+
if (u.size === 0) return {};
|
|
572
|
+
let d = {};
|
|
573
|
+
for (let f of u) {
|
|
574
|
+
let p = i[f];
|
|
575
|
+
if (p && typeof p == "object" && p !== null) {
|
|
576
|
+
let h = p;
|
|
577
|
+
h.const !== void 0 ? d[f] = h.const : h.default !== void 0 ? d[f] = h.default : h.enum !== void 0 && h.enum.length > 0 ? d[f] = h.enum[0] : d[f] = ct(h.type);
|
|
578
|
+
} else d[f] = null;
|
|
579
|
+
}
|
|
580
|
+
return d;
|
|
581
|
+
}
|
|
582
|
+
if (e.additionalProperties === !1) {
|
|
583
|
+
let u = Object.keys(i).length > 0, d = e.patternProperties && Object.keys(e.patternProperties).length > 0, f = new Set(Object.keys(i)), p = [...new Set(r)].filter((h) => !f.has(h));
|
|
584
|
+
if ((e.minProperties ?? 0) > 0 && !u && !d) throw Error(`missing properties for ${e.minProperties} in ${t.path}: additionalProperties is false but no properties or patternProperties defined`);
|
|
585
|
+
if (p.length > 0 && !d && !u) throw Error(`missing properties for ${p.join(", ")} in ${t.path}: additionalProperties is false but required properties not defined in properties`);
|
|
586
|
+
}
|
|
587
|
+
let n = t.path === "/" ? "/properties" : `${t.path}/properties`, o = { ...t, depth: t.depth + 1, path: n }, l = {}, a = /* @__PURE__ */ new Set(), s = new Set(r);
|
|
588
|
+
for (let [u, d] of _(e)) if (s.has(u)) for (let f of d) s.add(f);
|
|
589
|
+
let c = t.fillProperties ?? !0, g = Object.keys(i).filter((u) => !s.has(u)), v = ke(t, g);
|
|
590
|
+
if (Object.keys(i).length > 0) for (let [u, d] of Object.entries(i)) {
|
|
591
|
+
if (Ae(d)) continue;
|
|
592
|
+
a.add(u);
|
|
593
|
+
let f = D(o, u), p = s.has(u), h = typeof d == "object" && d !== null && d.type === "object", m = d;
|
|
594
|
+
if (e.patternProperties && typeof d == "object" && d !== null) {
|
|
595
|
+
let y = [];
|
|
596
|
+
for (let [x, O] of Object.entries(e.patternProperties)) try {
|
|
597
|
+
new RegExp(x).test(u) && y.push(O);
|
|
598
|
+
} catch {
|
|
599
|
+
}
|
|
600
|
+
y.length > 0 && (m = I([d, ...y]));
|
|
601
|
+
}
|
|
602
|
+
if (p) {
|
|
603
|
+
let y = yield j(m, f);
|
|
604
|
+
y !== void 0 && (l[u] = y);
|
|
605
|
+
} else if (v(u)) {
|
|
606
|
+
let y = yield j(m, f);
|
|
607
|
+
y !== void 0 && (l[u] = y);
|
|
608
|
+
} else if (h && !c) {
|
|
609
|
+
let y = d.required ?? [];
|
|
610
|
+
if (y.length > 0) {
|
|
611
|
+
let x = {};
|
|
612
|
+
for (let O of y) {
|
|
613
|
+
let S = (d.properties ?? {})[O] ?? {}, E = D(f, O), K = yield j(S, E);
|
|
614
|
+
K !== void 0 && (x[O] = K);
|
|
615
|
+
}
|
|
616
|
+
l[u] = x;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
for (let u of s)
|
|
621
|
+
if (!(l[u] !== void 0 || a.has(u))) {
|
|
622
|
+
if (e.patternProperties) {
|
|
623
|
+
let d = [];
|
|
624
|
+
for (let [f, p] of Object.entries(e.patternProperties)) new RegExp(f).test(u) && d.push(p);
|
|
625
|
+
if (d.length > 0) {
|
|
626
|
+
let f = d.length === 1 ? d[0] : I(d), p = D(o, u), h = yield j(f, p);
|
|
627
|
+
h !== void 0 && (l[u] = h), a.add(u);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
if (!a.has(u)) {
|
|
631
|
+
let d = e.additionalProperties ?? !0;
|
|
632
|
+
if (d !== !1) {
|
|
633
|
+
let f = D(o, u), p = yield j(d === !0 ? {} : d, f);
|
|
634
|
+
p !== void 0 && (l[u] = p), a.add(u);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
let b = !0;
|
|
639
|
+
for (; b; ) {
|
|
640
|
+
b = !1;
|
|
641
|
+
for (let [u, d] of _(e))
|
|
642
|
+
if (l[u] !== void 0)
|
|
643
|
+
for (let f of d) {
|
|
644
|
+
let p = l[f];
|
|
645
|
+
yield* at(e, i, l, a, o, f), p === void 0 && l[f] !== void 0 && (b = !0), l[f] !== void 0 && s.add(f);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
for (let [u, d] of lt(e)) if (l[u] !== void 0 && !a.has(u + "_dep")) {
|
|
649
|
+
if (a.add(u + "_dep"), typeof d == "boolean") continue;
|
|
650
|
+
let f = d.oneOf ?? d.anyOf ?? d.allOf ?? [d], p = null;
|
|
651
|
+
for (let m of f) {
|
|
652
|
+
if (typeof m != "object" || m === null) continue;
|
|
653
|
+
let { properties: y, not: x } = m;
|
|
654
|
+
if (y && y[u]) {
|
|
655
|
+
let O = y[u], S = l[u];
|
|
656
|
+
if (ie(S, O)) {
|
|
657
|
+
p = m;
|
|
658
|
+
break;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
if (x != null && x.properties) {
|
|
662
|
+
let O = x.properties[u];
|
|
663
|
+
if (O) {
|
|
664
|
+
let S = l[u];
|
|
665
|
+
if (!ie(S, O)) {
|
|
666
|
+
p = m;
|
|
667
|
+
break;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
if (!p && f.length > 0 && typeof f[0] == "object" && (p = f[0]), p != null && p.not) {
|
|
673
|
+
let m = p.not;
|
|
674
|
+
if (m.required && Array.isArray(m.required)) for (let y of m.required) delete l[y];
|
|
675
|
+
}
|
|
676
|
+
let h = /* @__PURE__ */ new Set();
|
|
677
|
+
if (p != null && p.required) for (let m of p.required) {
|
|
678
|
+
if (m === u || l[m] !== void 0) continue;
|
|
679
|
+
h.add(m);
|
|
680
|
+
let y = ((A = p.properties) == null ? void 0 : A[m]) ?? i[m] ?? { type: "object" }, x = D(o, m), O = yield j(y, x);
|
|
681
|
+
O !== void 0 && (l[m] = O);
|
|
682
|
+
}
|
|
683
|
+
if (p && p.properties) for (let [m, y] of Object.entries(p.properties)) {
|
|
684
|
+
if (m === u || h.has(m)) continue;
|
|
685
|
+
let x = D(o, m), O = yield j(y, x);
|
|
686
|
+
O !== void 0 && (l[m] = O);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
let w = e.minProperties ?? 0, k = e.maxProperties;
|
|
690
|
+
if (Object.keys(l).length < w) {
|
|
691
|
+
if (e.patternProperties && Object.keys(e.patternProperties).length > 0) {
|
|
692
|
+
let u = Object.entries(e.patternProperties), d = 0, f = 1e3;
|
|
693
|
+
for (; Object.keys(l).length < w && d < f; ) {
|
|
694
|
+
d++;
|
|
695
|
+
let [p, h] = t.random.pick(u), m = ut(p, t);
|
|
696
|
+
if (m && !l[m]) {
|
|
697
|
+
let y = D(o, m), x = yield j(h, y);
|
|
698
|
+
x !== void 0 && (l[m] = x), a.add(m);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
if (Object.keys(l).length < w) {
|
|
703
|
+
let u = e.additionalProperties, d = u === void 0 || u === !0 ? { type: "string" } : u;
|
|
704
|
+
if (d !== !1) {
|
|
705
|
+
let f = 0, p = 1e3;
|
|
706
|
+
for (; Object.keys(l).length < w && f < p; ) {
|
|
707
|
+
f++;
|
|
708
|
+
let h = `prop${t.random.int(0, 99999)}`;
|
|
709
|
+
if (!l[h]) {
|
|
710
|
+
let m = D(o, h), y = yield j(d, m);
|
|
711
|
+
y !== void 0 && (l[h] = y), a.add(h);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
if (Object.keys(l).length < w) {
|
|
717
|
+
let u = Object.keys(i).join(", ");
|
|
718
|
+
throw Error(`properties '${u}' were not found while additionalProperties is false in ${t.path}`);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
if (k !== void 0 && Object.keys(l).length > k) {
|
|
722
|
+
let u = Object.keys(l).filter((d) => !s.has(d));
|
|
723
|
+
for (t.random.shuffle(u); Object.keys(l).length > k && u.length > 0; ) {
|
|
724
|
+
let d = u.pop();
|
|
725
|
+
delete l[d];
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
return t.pruneProperties && t.pruneProperties.length > 0 && z(l, t.pruneProperties), ft(l, i), l;
|
|
729
|
+
}
|
|
730
|
+
function ft(e, t) {
|
|
731
|
+
for (let [i, r] of Object.entries(t)) {
|
|
732
|
+
if (typeof r != "object" || r === null) continue;
|
|
733
|
+
let n = r;
|
|
734
|
+
if (n.template === void 0) continue;
|
|
735
|
+
let o = n.template;
|
|
736
|
+
if (typeof o != "string") continue;
|
|
737
|
+
let l = o.replace(/#\{(\w+)\}/g, (a, s) => {
|
|
738
|
+
let c = e[s];
|
|
739
|
+
return c !== void 0 ? String(c) : "";
|
|
740
|
+
});
|
|
741
|
+
e[i] = l;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
function ut(e, t) {
|
|
745
|
+
let i = e.match(/^\^([a-zA-Z]+)(\.\*|\(\?\:.*\))?/);
|
|
746
|
+
if (i) {
|
|
747
|
+
let s = i[1], c = i[2];
|
|
748
|
+
if (c === ".*" || c != null && c.includes("?:")) {
|
|
749
|
+
let g = t.random.int(0, 10), v = "";
|
|
750
|
+
for (let b = 0; b < g; b++) v += t.random.pick("abcdefghijklmnopqrstuvwxyz".split(""));
|
|
751
|
+
return s + v;
|
|
752
|
+
}
|
|
753
|
+
return s;
|
|
754
|
+
}
|
|
755
|
+
let r = e.match(/(.*\*)?([a-zA-Z]+)\$$/);
|
|
756
|
+
if (r) {
|
|
757
|
+
let s = r[2], c = t.random.int(1, 10), g = "";
|
|
758
|
+
for (let v = 0; v < c; v++) g += t.random.pick("abcdefghijklmnopqrstuvwxyz".split(""));
|
|
759
|
+
return g + s;
|
|
760
|
+
}
|
|
761
|
+
let n = e.match(/^\^([a-zA-Z]+)\$$/);
|
|
762
|
+
if (n) return n[1];
|
|
763
|
+
let o = t.random.int(3, 10), l = "abcdefghijklmnopqrstuvwxyz", a = "";
|
|
764
|
+
for (let s = 0; s < o; s++) a += t.random.pick(l.split(""));
|
|
765
|
+
try {
|
|
766
|
+
if (new RegExp(e).test(a)) return a;
|
|
767
|
+
} catch {
|
|
768
|
+
}
|
|
769
|
+
return null;
|
|
770
|
+
}
|
|
771
|
+
function z(e, t) {
|
|
772
|
+
if (typeof e != "object" || e === null) return;
|
|
773
|
+
if (Array.isArray(e)) {
|
|
774
|
+
for (let r of e) z(r, t);
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
let i = e;
|
|
778
|
+
for (let r of Object.keys(i)) t.includes(r) ? delete i[r] : z(i[r], t);
|
|
779
|
+
}
|
|
780
|
+
function ct(e) {
|
|
781
|
+
switch (Array.isArray(e) ? e[0] : e) {
|
|
782
|
+
case "string":
|
|
783
|
+
return "";
|
|
784
|
+
case "number":
|
|
785
|
+
case "integer":
|
|
786
|
+
return 0;
|
|
787
|
+
case "boolean":
|
|
788
|
+
return !1;
|
|
789
|
+
case "null":
|
|
790
|
+
return null;
|
|
791
|
+
case "array":
|
|
792
|
+
return [];
|
|
793
|
+
case "object":
|
|
794
|
+
return {};
|
|
795
|
+
default:
|
|
796
|
+
return null;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
function* pt(e, t) {
|
|
800
|
+
var d;
|
|
801
|
+
if (t.depth >= t.maxDepth) {
|
|
802
|
+
let f = e.minItems ?? 0;
|
|
803
|
+
return f > 0 ? Array.from({ length: f }, () => null) : [];
|
|
804
|
+
}
|
|
805
|
+
if (t.refDepthReached) {
|
|
806
|
+
let f = e.minItems ?? 0;
|
|
807
|
+
return f > 0 ? Array.from({ length: f }, () => null) : [];
|
|
808
|
+
}
|
|
809
|
+
if (e.items === !1 && (e.minItems ?? 0) > 0) {
|
|
810
|
+
let f = ((d = e.prefixItems) == null ? void 0 : d.length) ?? 0;
|
|
811
|
+
if ((e.minItems ?? 0) > f) throw Error(`missing items for ${e.minItems} in ${t.path}: items is false but minItems (${e.minItems}) exceeds prefixItems count (${f})`);
|
|
812
|
+
}
|
|
813
|
+
let i = t.path === "/" ? "/items" : `${t.path}/items`, r = { ...t, depth: t.depth + 1, path: i }, n = [], o = t.refDepthMax, l = t.minItems ?? e.minItems ?? 0, a = t.maxItems ?? e.maxItems ?? Math.max(l, t.maxDefaultItems);
|
|
814
|
+
e.maxItems !== void 0 && a > e.maxItems && (a = e.maxItems), e.minItems !== void 0 && l < e.minItems && (l = e.minItems), a < l && (e.maxItems !== void 0 ? l = a : a = l), t.alwaysFakeOptionals && (a = Math.max(l, a));
|
|
815
|
+
let s = e.uniqueItems ? /* @__PURE__ */ new Set() : null;
|
|
816
|
+
function* c(f, p) {
|
|
817
|
+
let h = yield j(f, p);
|
|
818
|
+
if (h === void 0) return "omitted";
|
|
819
|
+
if (s) {
|
|
820
|
+
let m = JSON.stringify(h);
|
|
821
|
+
if (s.has(m)) {
|
|
822
|
+
for (let y = 0; y < 50; y++) {
|
|
823
|
+
if (h = yield j(f, H(r, n.length)), h === void 0) continue;
|
|
824
|
+
let x = JSON.stringify(h);
|
|
825
|
+
if (!s.has(x)) return s.add(x), n.push(h), "added";
|
|
826
|
+
}
|
|
827
|
+
return "failed";
|
|
828
|
+
}
|
|
829
|
+
s.add(m);
|
|
830
|
+
}
|
|
831
|
+
return n.push(h), "added";
|
|
832
|
+
}
|
|
833
|
+
if (e.prefixItems) for (let f = 0; f < e.prefixItems.length && n.length < a; f++) {
|
|
834
|
+
let p = H(r, f);
|
|
835
|
+
if ((yield* c(e.prefixItems[f], p)) === "failed") break;
|
|
836
|
+
}
|
|
837
|
+
let g;
|
|
838
|
+
if (o !== void 0 && t.refDepth >= o - 1) {
|
|
839
|
+
let f = e.minItems ?? 0;
|
|
840
|
+
return f > 0 ? Array.from({ length: f }, () => null) : [];
|
|
841
|
+
}
|
|
842
|
+
let v = t.alwaysFakeOptionals ?? !1, b = t.fixedProbabilities ?? !1, w = t.optionalsProbability ?? 0.5;
|
|
843
|
+
if (v) g = a;
|
|
844
|
+
else if (b) {
|
|
845
|
+
let f = a - Math.max(l, n.length), p = Math.round(f * w);
|
|
846
|
+
g = Math.max(l, n.length) + p;
|
|
847
|
+
} else g = t.random.int(Math.max(l, n.length), a);
|
|
848
|
+
let k = e.prefixItems !== void 0, A = e.additionalItems !== void 0, u;
|
|
849
|
+
if (k ? A ? u = e.additionalItems : e.items !== void 0 && (u = e.items) : u = e.items, u !== !1 && u !== void 0) {
|
|
850
|
+
let f = u ?? {}, p = 0, h = Math.max(g * 20, 50);
|
|
851
|
+
for (; n.length < g; ) {
|
|
852
|
+
let m = yield* c(f, H(r, n.length));
|
|
853
|
+
if (m === "added") {
|
|
854
|
+
p = 0;
|
|
855
|
+
continue;
|
|
856
|
+
}
|
|
857
|
+
if (p++, m === "failed" || p >= h) break;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
if (e.contains) {
|
|
861
|
+
let f = e.minContains ?? 1, p = e.maxContains ?? Math.max(f, 1), h = t.random.int(f, p);
|
|
862
|
+
for (let m = 0; m < h; m++) {
|
|
863
|
+
let y = yield j(e.contains, H(r, n.length));
|
|
864
|
+
if (y !== void 0) {
|
|
865
|
+
if (s) {
|
|
866
|
+
let x = JSON.stringify(y);
|
|
867
|
+
if (s.has(x)) {
|
|
868
|
+
let O = !1;
|
|
869
|
+
for (let S = 0; S < 50; S++) {
|
|
870
|
+
if (y = yield j(e.contains, H(r, n.length)), y === void 0) continue;
|
|
871
|
+
let E = JSON.stringify(y);
|
|
872
|
+
if (!s.has(E)) {
|
|
873
|
+
s.add(E), O = !0;
|
|
874
|
+
break;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
if (!O) continue;
|
|
878
|
+
} else s.add(x);
|
|
879
|
+
}
|
|
880
|
+
if (n.length < a) {
|
|
881
|
+
let x = t.random.int(0, n.length);
|
|
882
|
+
n.splice(x, 0, y);
|
|
883
|
+
} else if (n.length > 0) {
|
|
884
|
+
let x = t.random.int(0, n.length - 1);
|
|
885
|
+
n[x] = y;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
for (; n.length > a; ) n.pop();
|
|
890
|
+
}
|
|
891
|
+
if (e.containsAll) {
|
|
892
|
+
let f = /* @__PURE__ */ new Set();
|
|
893
|
+
for (let p of e.containsAll) {
|
|
894
|
+
let h = yield j(p, H(r, n.length));
|
|
895
|
+
if (h !== void 0) {
|
|
896
|
+
if (s) {
|
|
897
|
+
let m = JSON.stringify(h);
|
|
898
|
+
if (s.has(m)) {
|
|
899
|
+
let y = !1;
|
|
900
|
+
for (let x = 0; x < 50; x++) {
|
|
901
|
+
if (h = yield j(p, H(r, n.length)), h === void 0) continue;
|
|
902
|
+
let O = JSON.stringify(h);
|
|
903
|
+
if (!s.has(O)) {
|
|
904
|
+
s.add(O), y = !0;
|
|
905
|
+
break;
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
if (!y) continue;
|
|
909
|
+
} else s.add(m);
|
|
910
|
+
}
|
|
911
|
+
if (n.length < a) {
|
|
912
|
+
let m = t.random.int(0, n.length);
|
|
913
|
+
n.splice(m, 0, h);
|
|
914
|
+
let y = /* @__PURE__ */ new Set();
|
|
915
|
+
for (let x of f) y.add(x >= m ? x + 1 : x);
|
|
916
|
+
f.clear();
|
|
917
|
+
for (let x of y) f.add(x);
|
|
918
|
+
f.add(m);
|
|
919
|
+
} else if (n.length > 0) {
|
|
920
|
+
let m = Array.from({ length: n.length }, (y, x) => x).filter((y) => !f.has(y));
|
|
921
|
+
if (m.length > 0) {
|
|
922
|
+
let y = m[t.random.int(0, m.length - 1)];
|
|
923
|
+
n[y] = h, f.add(y);
|
|
924
|
+
} else n.push(h), f.add(n.length - 1);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
for (; n.length > a; ) n.pop();
|
|
929
|
+
}
|
|
930
|
+
return e.uniqueItems && n.length > 0 ? yield* mt(n, e, r, l, a, s) : n;
|
|
931
|
+
}
|
|
932
|
+
function* mt(e, t, i, r, n, o) {
|
|
933
|
+
let l = t.items ?? {}, a = 0, s = 100;
|
|
934
|
+
for (; e.length < r && a < s; ) {
|
|
935
|
+
a++;
|
|
936
|
+
let c = yield j(l, H(i, e.length));
|
|
937
|
+
if (c === void 0) continue;
|
|
938
|
+
let g = JSON.stringify(c);
|
|
939
|
+
o.has(g) || (o.add(g), e.push(c));
|
|
940
|
+
}
|
|
941
|
+
for (; e.length > n; ) e.pop();
|
|
942
|
+
return e;
|
|
943
|
+
}
|
|
944
|
+
function H(e, t) {
|
|
945
|
+
let i = e.outputPath === "/" ? `/${t}` : `${e.outputPath}/${t}`;
|
|
946
|
+
return { ...e, path: `${e.path}/${t}`, outputPath: i };
|
|
947
|
+
}
|
|
948
|
+
function ui(e = {}) {
|
|
949
|
+
let t = e.cache ?? /* @__PURE__ */ new Map(), i = e.baseUrl;
|
|
950
|
+
return async (r) => {
|
|
951
|
+
let { url: n, fragment: o } = dt(r, i), l;
|
|
952
|
+
if (t.has(n)) l = t.get(n);
|
|
953
|
+
else {
|
|
954
|
+
if (n.startsWith("http://") || n.startsWith("https://")) l = await ht(n, e.fetch);
|
|
955
|
+
else if (n.startsWith("file://")) {
|
|
956
|
+
let a = decodeURIComponent(n.slice(7));
|
|
957
|
+
l = await ne(a, e.readFile);
|
|
958
|
+
} else l = await ne(n, e.readFile);
|
|
959
|
+
t.set(n, l);
|
|
960
|
+
}
|
|
961
|
+
return l;
|
|
962
|
+
};
|
|
963
|
+
}
|
|
964
|
+
function dt(e, t) {
|
|
965
|
+
let i = e.indexOf("#");
|
|
966
|
+
if (i === -1) return { url: re(e, t), fragment: null };
|
|
967
|
+
let r = e.slice(0, i), n = e.slice(i + 1);
|
|
968
|
+
return { url: re(r || "#", t), fragment: n || null };
|
|
969
|
+
}
|
|
970
|
+
function re(e, t) {
|
|
971
|
+
if (!t || e.startsWith("http://") || e.startsWith("https://") || e.startsWith("file://")) return e === "#" ? t || "#" : e;
|
|
972
|
+
if (t.startsWith("file://")) {
|
|
973
|
+
let i = t.slice(7), r = i.includes("/") ? "/" : "\\", n = i.lastIndexOf(r);
|
|
974
|
+
return (n >= 0 ? i.slice(0, n + 1) : "") + e;
|
|
975
|
+
}
|
|
976
|
+
try {
|
|
977
|
+
return new URL(e, t).href;
|
|
978
|
+
} catch {
|
|
979
|
+
return e;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
async function ht(e, t) {
|
|
983
|
+
let i = t ?? globalThis.fetch;
|
|
984
|
+
if (!i) throw Error(`Cannot fetch ${e}: fetch is not available. Provide a custom fetch function via the 'fetch' option.`);
|
|
985
|
+
let r = await i(e);
|
|
986
|
+
if (!r.ok) throw Error(`Failed to fetch schema from ${e}: ${r.status} ${r.statusText}`);
|
|
987
|
+
if ((r.headers.get("content-type") || "").includes("application/json")) return r.json();
|
|
988
|
+
let n = await r.text();
|
|
989
|
+
try {
|
|
990
|
+
return JSON.parse(n);
|
|
991
|
+
} catch (o) {
|
|
992
|
+
throw Error(`Failed to parse schema from ${e} as JSON: ${o}`);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
async function ne(e, t) {
|
|
996
|
+
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.`);
|
|
997
|
+
let i = await t(e);
|
|
998
|
+
return JSON.parse(i);
|
|
999
|
+
}
|
|
1000
|
+
function oe(e, t) {
|
|
1001
|
+
if (!t || t === "") return e;
|
|
1002
|
+
if (typeof e != "object" || e === null) throw Error(`Cannot resolve fragment "${t}" in non-object schema`);
|
|
1003
|
+
if (t.startsWith("/")) return yt(e, t);
|
|
1004
|
+
throw Error(`Unsupported fragment type: ${t}. Only JSON pointers (starting with /) are supported.`);
|
|
1005
|
+
}
|
|
1006
|
+
function yt(e, t) {
|
|
1007
|
+
if (t === "" || t === "/") return e;
|
|
1008
|
+
let i = t.slice(1).split("/"), r = e;
|
|
1009
|
+
for (let n of i) {
|
|
1010
|
+
let o = n.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
1011
|
+
if (typeof r != "object" || r === null) throw Error(`Cannot resolve JSON pointer "${t}": not an object at "${o}"`);
|
|
1012
|
+
if (Array.isArray(r)) {
|
|
1013
|
+
let l = parseInt(o, 10);
|
|
1014
|
+
if (isNaN(l) || l < 0 || l >= r.length) throw Error(`Cannot resolve JSON pointer "${t}": invalid array index "${o}"`);
|
|
1015
|
+
r = r[l];
|
|
1016
|
+
} else {
|
|
1017
|
+
if (!(o in r)) throw Error(`Cannot resolve JSON pointer "${t}": property "${o}" not found`);
|
|
1018
|
+
r = r[o];
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
return r;
|
|
1022
|
+
}
|
|
1023
|
+
function* le(e, t) {
|
|
1024
|
+
let i = t.refResolver(e);
|
|
1025
|
+
if (t.__sync && q(i)) throw Promise.resolve(i).catch(() => {
|
|
1026
|
+
}), Error(`Cannot use async refResolver in generateSync(): resolving '${e}' returned a Promise`);
|
|
1027
|
+
return yield i;
|
|
1028
|
+
}
|
|
1029
|
+
function gt(e) {
|
|
1030
|
+
let t = /* @__PURE__ */ new Map();
|
|
1031
|
+
if (typeof e == "boolean") return t;
|
|
1032
|
+
if (e.$id && typeof e == "object") {
|
|
1033
|
+
let i = e, r = i.$id, { $id: n, ...o } = i;
|
|
1034
|
+
t.set(r, o);
|
|
1035
|
+
}
|
|
1036
|
+
if (e.$defs) for (let [i, r] of Object.entries(e.$defs)) t.set(`#/$defs/${i}`, r);
|
|
1037
|
+
return t;
|
|
1038
|
+
}
|
|
1039
|
+
function* W(e, t) {
|
|
1040
|
+
let i = e.$ref;
|
|
1041
|
+
if (!i) return { schema: e, ctx: t };
|
|
1042
|
+
let r = t.refDepth + 1;
|
|
1043
|
+
if (t.refDepthMax !== void 0 && r >= t.refDepthMax) return { schema: {}, ctx: { ...t, refDepthReached: !0 } };
|
|
1044
|
+
if (t.refStack.has(i)) {
|
|
1045
|
+
if (t.refDepthMax !== void 0) {
|
|
1046
|
+
if (t.refDepth >= t.refDepthMax) return { schema: {}, ctx: { ...t, refDepthReached: !0 } };
|
|
1047
|
+
} else if (t.depth >= t.maxDepth) return { schema: { type: "null" }, ctx: t };
|
|
1048
|
+
}
|
|
1049
|
+
let n, o;
|
|
1050
|
+
if (i.startsWith("#/")) {
|
|
1051
|
+
if (n = t.refRegistry.get(i), n === void 0 && i.length > 2) {
|
|
1052
|
+
let v = t.refRegistry.get("#");
|
|
1053
|
+
if (v !== void 0 && typeof v == "object") try {
|
|
1054
|
+
n = oe(v, i.slice(1));
|
|
1055
|
+
} catch {
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
n === void 0 && t.refResolver && (n = yield* le(i, t), n !== void 0 && t.refRegistry.set(i, n));
|
|
1059
|
+
} else if (i === "#") n = t.refRegistry.get("#") ?? {};
|
|
1060
|
+
else if (n = t.refRegistry.get(i), n === void 0 && t.refResolver) {
|
|
1061
|
+
o = yield* le(i, t);
|
|
1062
|
+
let v = i.indexOf("#");
|
|
1063
|
+
if (v !== -1) {
|
|
1064
|
+
let b = i.slice(v + 1);
|
|
1065
|
+
b ? n = oe(o, b) : n = o;
|
|
1066
|
+
} else n = o;
|
|
1067
|
+
if (o && typeof o == "object" && o !== null) {
|
|
1068
|
+
let b = o;
|
|
1069
|
+
if (b.$defs) for (let [w, k] of Object.entries(b.$defs)) t.refRegistry.set(`#/$defs/${w}`, k);
|
|
1070
|
+
}
|
|
1071
|
+
} else if (n === void 0 && t.__sync) throw Error(`Remote $ref '${i}' cannot be resolved in generateSync(); pre-resolve refs or use generate()`);
|
|
1072
|
+
if (n === void 0) throw Error(`Unresolved $ref: ${i}`);
|
|
1073
|
+
let l = /* @__PURE__ */ new Set(["description", "title", "$comment", "readOnly", "writeOnly", "deprecated"]), { $ref: a, ...s } = e, c = Object.fromEntries(Object.entries(s).filter(([v]) => !l.has(v)));
|
|
1074
|
+
Object.keys(c).length > 0 && typeof n == "object" && n !== null && (n = { ...n, ...c });
|
|
1075
|
+
let g = { ...t, refStack: /* @__PURE__ */ new Set([...t.refStack, i]), refDepth: t.refDepth + 1 };
|
|
1076
|
+
return { schema: n, ctx: g };
|
|
1077
|
+
}
|
|
1078
|
+
function vt(e, t) {
|
|
1079
|
+
typeof e != "boolean" && (t.set("#", e), U(e, "#", t));
|
|
1080
|
+
}
|
|
1081
|
+
function U(e, t, i) {
|
|
1082
|
+
if (e.$id) {
|
|
1083
|
+
let { $id: r, ...n } = e;
|
|
1084
|
+
i.set(r, n);
|
|
1085
|
+
}
|
|
1086
|
+
if (e.$defs) for (let [r, n] of Object.entries(e.$defs)) {
|
|
1087
|
+
let o = `${t}/$defs/${r}`;
|
|
1088
|
+
i.set(o, n), typeof n == "object" && n !== null && U(n, o, i);
|
|
1089
|
+
}
|
|
1090
|
+
if (e.properties)
|
|
1091
|
+
for (let [r, n] of Object.entries(e.properties)) typeof n == "object" && n !== null && U(n, `${t}/properties/${r}`, i);
|
|
1092
|
+
}
|
|
1093
|
+
function* xt(e, t) {
|
|
1094
|
+
return e.$ref ? (yield* W(e, t)).schema : e;
|
|
1095
|
+
}
|
|
1096
|
+
function* bt(e, t) {
|
|
1097
|
+
let i = [];
|
|
1098
|
+
for (let r of e) if (typeof r == "object" && r !== null && "$ref" in r) {
|
|
1099
|
+
let n = yield* xt(r, t);
|
|
1100
|
+
i.push(n);
|
|
1101
|
+
} else typeof r == "object" && r !== null && i.push(r);
|
|
1102
|
+
return i;
|
|
1103
|
+
}
|
|
1104
|
+
function* wt(e, t) {
|
|
1105
|
+
let { allOf: i, anyOf: r, oneOf: n, not: o, if: l, then: a, else: s, ...c } = e;
|
|
1106
|
+
if (i) {
|
|
1107
|
+
let g = yield* bt(i, t), v = I([c, ...g]);
|
|
1108
|
+
return yield j(v, t);
|
|
1109
|
+
}
|
|
1110
|
+
if (n) {
|
|
1111
|
+
let g = t.random.shuffle([...n]), v = c.required ?? [];
|
|
1112
|
+
for (let p of g) {
|
|
1113
|
+
let h = typeof p == "object" && p !== null ? p : {};
|
|
1114
|
+
h.$ref && (h = (yield* W(h, t)).schema);
|
|
1115
|
+
let m = h.required ?? [], y = [.../* @__PURE__ */ new Set([...v, ...m])], x = { ...c, required: y }, O = I([x, h]), S = { ...t, optionalsProbability: 0, alwaysFakeOptionals: !1 };
|
|
1116
|
+
try {
|
|
1117
|
+
return yield j(O, S);
|
|
1118
|
+
} catch {
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
let b = n[0], w = typeof b == "object" && b !== null ? b : {};
|
|
1122
|
+
w.$ref && (w = (yield* W(w, t)).schema);
|
|
1123
|
+
let k = w.required ?? [], A = [.../* @__PURE__ */ new Set([...v, ...k])], u = { ...c, required: A }, d = I([u, w]), f = { ...t, optionalsProbability: 0, alwaysFakeOptionals: !1 };
|
|
1124
|
+
return yield j(d, f);
|
|
1125
|
+
}
|
|
1126
|
+
if (r) {
|
|
1127
|
+
let g = t.random.shuffle([...r]);
|
|
1128
|
+
for (let w of g) {
|
|
1129
|
+
let k = I([c, w]);
|
|
1130
|
+
try {
|
|
1131
|
+
return yield j(k, t);
|
|
1132
|
+
} catch {
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
let v = r[0], b = I([c, v]);
|
|
1136
|
+
return yield j(b, t);
|
|
1137
|
+
}
|
|
1138
|
+
return l !== void 0 ? yield* jt(c, l, a, s, t) : o ? yield* Ot(c, o, t) : yield j(c, t);
|
|
1139
|
+
}
|
|
1140
|
+
function* jt(e, t, i, r, n) {
|
|
1141
|
+
if (i !== void 0) {
|
|
1142
|
+
let o = I([e, t, i]);
|
|
1143
|
+
try {
|
|
1144
|
+
return yield j(o, n);
|
|
1145
|
+
} catch {
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
if (r !== void 0) {
|
|
1149
|
+
let o = I([e, r]);
|
|
1150
|
+
try {
|
|
1151
|
+
return yield j(o, n);
|
|
1152
|
+
} catch {
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
return yield j(e, n);
|
|
1156
|
+
}
|
|
1157
|
+
function* Ot(e, t, i) {
|
|
1158
|
+
if (typeof t == "boolean") {
|
|
1159
|
+
if (t === !0) throw Error(`Cannot generate value for 'not: true' at ${i.path}`);
|
|
1160
|
+
return yield j(e, i);
|
|
1161
|
+
}
|
|
1162
|
+
if (t.type && !t.enum && !t.const) {
|
|
1163
|
+
let r = Array.isArray(t.type) ? t.type : [t.type], n = ["string", "number", "integer", "boolean", "null", "object", "array"].filter((o) => !r.includes(o));
|
|
1164
|
+
if (n.length > 0) {
|
|
1165
|
+
let o = i.random.pick(n), l = I([e, { type: o }]);
|
|
1166
|
+
return yield j(l, i);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
if (t.const !== void 0 || t.enum !== void 0) {
|
|
1170
|
+
let r = t.enum ?? [t.const], n = new Set(r.map((o) => JSON.stringify(o)));
|
|
1171
|
+
for (let o = 0; o < 20; o++) {
|
|
1172
|
+
let l = yield j(e, i);
|
|
1173
|
+
if (!n.has(JSON.stringify(l))) return l;
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
return yield j(e, i);
|
|
1177
|
+
}
|
|
1178
|
+
class Pt {
|
|
1179
|
+
constructor() {
|
|
1180
|
+
Z(this, "extensions", /* @__PURE__ */ new Map());
|
|
1181
|
+
}
|
|
1182
|
+
define(t, i) {
|
|
1183
|
+
this.extensions.set(t, { callback: i, context: {} });
|
|
1184
|
+
}
|
|
1185
|
+
has(t) {
|
|
1186
|
+
return this.extensions.has(t);
|
|
1187
|
+
}
|
|
1188
|
+
reset(t) {
|
|
1189
|
+
if (t) {
|
|
1190
|
+
let i = this.extensions.get(t);
|
|
1191
|
+
i && (i.context = {}, this.extensions.delete(t));
|
|
1192
|
+
} else this.extensions.clear();
|
|
1193
|
+
}
|
|
1194
|
+
keys() {
|
|
1195
|
+
return this.extensions.keys();
|
|
1196
|
+
}
|
|
1197
|
+
*generateGen(t, i) {
|
|
1198
|
+
let r = Object.keys(t);
|
|
1199
|
+
for (let n = r.length - 1; n >= 0; n--) {
|
|
1200
|
+
let o = r[n], l = o.startsWith("x-") ? o.slice(2) : o, a = this.extensions.get(l);
|
|
1201
|
+
if (a) {
|
|
1202
|
+
let s = t[o], c = a.callback.call(a.context, s, t, i);
|
|
1203
|
+
if (i.__sync && q(c)) throw Promise.resolve(c).catch(() => {
|
|
1204
|
+
}), Error(`Cannot use async extension '${l}' in generateSync()`);
|
|
1205
|
+
let g = yield c;
|
|
1206
|
+
if (g !== void 0) return g;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
getContext(t) {
|
|
1211
|
+
var i;
|
|
1212
|
+
return (i = this.extensions.get(t)) == null ? void 0 : i.context;
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
var G = new Pt();
|
|
1216
|
+
function kt(e, t) {
|
|
1217
|
+
G.define(e, t);
|
|
1218
|
+
}
|
|
1219
|
+
function It(e) {
|
|
1220
|
+
G.reset(e);
|
|
1221
|
+
}
|
|
1222
|
+
function* Mt(e, t) {
|
|
1223
|
+
return yield* G.generateGen(e, t);
|
|
1224
|
+
}
|
|
1225
|
+
var At = ["string", "number", "integer", "boolean", "null", "object", "array"];
|
|
1226
|
+
function ae(e, t, i) {
|
|
1227
|
+
if (e.faker !== void 0 && e.chance !== void 0) throw Error(`ambiguous generator: both faker and chance are defined in ${t.path}`);
|
|
1228
|
+
if (e.faker !== void 0) try {
|
|
1229
|
+
let r = St(e.faker, t), n = fe(r, i ?? e.type, t.path);
|
|
1230
|
+
return typeof n == "string" && e.format ? se(n, e.format, t) : n;
|
|
1231
|
+
} catch {
|
|
1232
|
+
}
|
|
1233
|
+
if (e.chance !== void 0) try {
|
|
1234
|
+
let r = Dt(e.chance, t), n = fe(r, i ?? e.type, t.path);
|
|
1235
|
+
return typeof n == "string" && e.format ? se(n, e.format, t) : n;
|
|
1236
|
+
} catch {
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
function se(e, t, i) {
|
|
1240
|
+
if (t === "date") {
|
|
1241
|
+
let r = typeof e == "string" ? new Date(e) : e;
|
|
1242
|
+
if (r instanceof Date && !isNaN(r.getTime())) {
|
|
1243
|
+
let n = r.getFullYear(), o = M(r.getMonth() + 1), l = M(r.getDate());
|
|
1244
|
+
return `${n}-${o}-${l}`;
|
|
1245
|
+
}
|
|
1246
|
+
if (typeof e == "string") {
|
|
1247
|
+
let n = Date.parse(e);
|
|
1248
|
+
if (!isNaN(n)) {
|
|
1249
|
+
let o = new Date(n), l = o.getFullYear(), a = M(o.getMonth() + 1), s = M(o.getDate());
|
|
1250
|
+
return `${l}-${a}-${s}`;
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
if (t === "date-time") {
|
|
1255
|
+
let r = typeof e == "string" ? new Date(e) : e;
|
|
1256
|
+
if (r instanceof Date && !isNaN(r.getTime())) return r.toISOString();
|
|
1257
|
+
if (typeof e == "string" && Date.parse(e)) return new Date(e).toISOString();
|
|
1258
|
+
}
|
|
1259
|
+
return e;
|
|
1260
|
+
}
|
|
1261
|
+
function fe(e, t, i) {
|
|
1262
|
+
if (t === void 0) return e;
|
|
1263
|
+
let r = Array.isArray(t) ? t[0] : t;
|
|
1264
|
+
switch (r) {
|
|
1265
|
+
case "string":
|
|
1266
|
+
return e === null ? "null" : e === void 0 ? "undefined" : String(e);
|
|
1267
|
+
case "number":
|
|
1268
|
+
case "integer":
|
|
1269
|
+
let n = Number(e);
|
|
1270
|
+
return r === "integer" ? Math.floor(n) : n;
|
|
1271
|
+
case "boolean":
|
|
1272
|
+
return !!e;
|
|
1273
|
+
case "null":
|
|
1274
|
+
return null;
|
|
1275
|
+
default:
|
|
1276
|
+
return e;
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
function St(e, t) {
|
|
1280
|
+
var l;
|
|
1281
|
+
if (!((l = t.extensions) != null && l.faker)) {
|
|
1282
|
+
let a = typeof e == "string" ? e : JSON.stringify(e);
|
|
1283
|
+
throw Error(`cannot resolve faker-generator for ${a} in ${t.path}`);
|
|
1284
|
+
}
|
|
1285
|
+
let i, r;
|
|
1286
|
+
if (typeof e == "object" && e !== null) {
|
|
1287
|
+
let a = e, s = Object.keys(a);
|
|
1288
|
+
if (s.length > 0) i = s[0], r = a[i];
|
|
1289
|
+
else throw Error(`cannot resolve faker-generator for ${JSON.stringify(e)} in ${t.path}`);
|
|
1290
|
+
} else i = e;
|
|
1291
|
+
let n = i.split("."), o = t.extensions.faker;
|
|
1292
|
+
for (let a of n) try {
|
|
1293
|
+
o = o[a];
|
|
1294
|
+
} catch {
|
|
1295
|
+
throw Error(`failed to resolve .${a} (${i})`);
|
|
1296
|
+
}
|
|
1297
|
+
if (typeof o == "function") return r ? o(...r) : o();
|
|
1298
|
+
throw Error(`cannot resolve faker-generator for ${i} in ${t.path}`);
|
|
1299
|
+
}
|
|
1300
|
+
function Dt(e, t) {
|
|
1301
|
+
var i;
|
|
1302
|
+
if (!((i = t.extensions) != null && i.chance)) {
|
|
1303
|
+
let r = typeof e == "string" ? e : Object.keys(e)[0];
|
|
1304
|
+
throw Error(`cannot resolve chance-generator for ${r} in ${t.path}`);
|
|
1305
|
+
}
|
|
1306
|
+
if (typeof e == "string") {
|
|
1307
|
+
let r = t.extensions.chance[e];
|
|
1308
|
+
if (typeof r == "function") return r.call(t.extensions.chance);
|
|
1309
|
+
throw Error(`cannot resolve chance-generator for ${e} in ${t.path}`);
|
|
1310
|
+
}
|
|
1311
|
+
if (typeof e == "object" && e !== null) {
|
|
1312
|
+
let r = e, n = Object.keys(r)[0], o = r[n], l = t.extensions.chance[n];
|
|
1313
|
+
if (typeof l == "function") return o ? l.call(t.extensions.chance, o) : l.call(t.extensions.chance);
|
|
1314
|
+
}
|
|
1315
|
+
throw Error(`cannot resolve chance-generator in ${t.path}`);
|
|
1316
|
+
}
|
|
1317
|
+
function Ht(e, t) {
|
|
1318
|
+
let i = e.path === "/" ? `/${t}` : `${e.path}/${t}`;
|
|
1319
|
+
return { ...e, depth: e.depth + 1, path: i, refDepthReached: e.refDepthReached };
|
|
1320
|
+
}
|
|
1321
|
+
function* P(e, t, i) {
|
|
1322
|
+
if (!i.outputTransform) return e;
|
|
1323
|
+
let r = i.outputTransform(e, t, i.outputPath);
|
|
1324
|
+
if (i.__sync && q(r)) throw Promise.resolve(r).catch(() => {
|
|
1325
|
+
}), Error("Cannot use async outputTransform in generateSync()");
|
|
1326
|
+
return yield r;
|
|
1327
|
+
}
|
|
1328
|
+
function* Q(e, t) {
|
|
1329
|
+
if (e === !0) return yield* Q({}, t);
|
|
1330
|
+
if (e === !1) throw Error(`Cannot generate value for 'false' schema at ${t.path}`);
|
|
1331
|
+
let i = null;
|
|
1332
|
+
if (typeof e == "object" && e !== null && e.$defs) {
|
|
1333
|
+
i = [];
|
|
1334
|
+
for (let [r, n] of Object.entries(e.$defs)) {
|
|
1335
|
+
let o = `#/$defs/${r}`;
|
|
1336
|
+
i.push([o, t.refRegistry.has(o) ? t.refRegistry.get(o) : void 0]), t.refRegistry.set(o, n);
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
try {
|
|
1340
|
+
return yield* Jt(e, t);
|
|
1341
|
+
} finally {
|
|
1342
|
+
if (i) for (let [r, n] of i) n === void 0 ? t.refRegistry.delete(r) : t.refRegistry.set(r, n);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
function* Jt(e, t) {
|
|
1346
|
+
if (t.propAliases) {
|
|
1347
|
+
let l = null;
|
|
1348
|
+
for (let [a, s] of Object.entries(t.propAliases)) a in e && !(s in e) && (l || (l = { ...e }), l[s] = l[a], delete l[a]);
|
|
1349
|
+
l && (e = l);
|
|
1350
|
+
}
|
|
1351
|
+
let i;
|
|
1352
|
+
if (Array.isArray(e.type)) {
|
|
1353
|
+
let l = e.type;
|
|
1354
|
+
i = t.random.pick(l);
|
|
1355
|
+
let a = { ...t, resolvedType: i }, s = ae(e, a, i);
|
|
1356
|
+
if (s !== void 0)
|
|
1357
|
+
return typeof s == "string" && a.maxLength !== void 0 && s.length > a.maxLength ? yield* P(s.slice(0, a.maxLength), e, a) : yield* P(s, e, a);
|
|
1358
|
+
} else {
|
|
1359
|
+
let l = ae(e, t, i);
|
|
1360
|
+
if (l !== void 0)
|
|
1361
|
+
return typeof l == "string" && t.maxLength !== void 0 && l.length > t.maxLength ? yield* P(l.slice(0, t.maxLength), e, t) : yield* P(l, e, t);
|
|
1362
|
+
}
|
|
1363
|
+
let r = { ...t, proceed: (l, a) => (t.__sync ? De : Se)(l, { ...t, ...a }) }, n = yield* Mt(e, r);
|
|
1364
|
+
if (n !== void 0) return yield* P(n, e, r);
|
|
1365
|
+
if (e.$ref) {
|
|
1366
|
+
let l = yield* W(e, t);
|
|
1367
|
+
return yield j(l.schema, Ht(l.ctx, "$ref"));
|
|
1368
|
+
}
|
|
1369
|
+
if (e.allOf || e.anyOf || e.oneOf || e.not || e.if) return yield* wt(e, t);
|
|
1370
|
+
if (e.const !== void 0) return yield* P(te(e, t), e, t);
|
|
1371
|
+
if (t.useDefaultValue && e.default !== void 0) return yield* P(Y(e.default, e, t), e, t);
|
|
1372
|
+
if (e.enum !== void 0) return yield* P(te(e, t), e, t);
|
|
1373
|
+
if (t.useExamplesValue) {
|
|
1374
|
+
if (Array.isArray(e.examples) && e.examples.length > 0) {
|
|
1375
|
+
let l = t.random.pick(e.examples);
|
|
1376
|
+
return yield* P(Y(l, e, t), e, t);
|
|
1377
|
+
}
|
|
1378
|
+
if (e.example !== void 0) return yield* P(Y(e.example, e, t), e, t);
|
|
1379
|
+
}
|
|
1380
|
+
let o = Lt(e, t);
|
|
1381
|
+
if (o === null) {
|
|
1382
|
+
if (t.failOnInvalidTypes === !1) {
|
|
1383
|
+
if (t.defaultInvalidTypeProduct !== void 0) {
|
|
1384
|
+
let l = t.defaultInvalidTypeProduct;
|
|
1385
|
+
return typeof l == "string" ? Et(l) : l;
|
|
1386
|
+
}
|
|
1387
|
+
return null;
|
|
1388
|
+
}
|
|
1389
|
+
throw Error(`unknown primitive ${e.type} in ${t.path}/type`);
|
|
1390
|
+
}
|
|
1391
|
+
switch (o) {
|
|
1392
|
+
case "null":
|
|
1393
|
+
return yield* P(Te(), e, t);
|
|
1394
|
+
case "boolean":
|
|
1395
|
+
return yield* P(qe(t), e, t);
|
|
1396
|
+
case "number":
|
|
1397
|
+
return yield* P(he(e, t), e, t);
|
|
1398
|
+
case "integer":
|
|
1399
|
+
return yield* P(Re(e, t), e, t);
|
|
1400
|
+
case "string":
|
|
1401
|
+
return yield* P(Be(e, t), e, t);
|
|
1402
|
+
case "object":
|
|
1403
|
+
return yield* P(yield* st(e, t), e, t);
|
|
1404
|
+
case "array":
|
|
1405
|
+
return yield* P(yield* pt(e, t), e, t);
|
|
1406
|
+
default:
|
|
1407
|
+
throw Error(`Unknown type: ${o} at ${t.path}`);
|
|
1408
|
+
}
|
|
1409
|
+
}
|
|
1410
|
+
function Lt(e, t) {
|
|
1411
|
+
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 || Qt(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(At);
|
|
1412
|
+
}
|
|
1413
|
+
function Qt(e) {
|
|
1414
|
+
if (e.properties || e.type === "object" || e.type === "array") return !1;
|
|
1415
|
+
for (let t of Object.keys(e)) {
|
|
1416
|
+
if (C.has(t)) continue;
|
|
1417
|
+
let i = e[t];
|
|
1418
|
+
if (typeof i == "object" && i !== null && !Array.isArray(i)) return !0;
|
|
1419
|
+
}
|
|
1420
|
+
return !1;
|
|
1421
|
+
}
|
|
1422
|
+
function Et(e) {
|
|
1423
|
+
switch (e) {
|
|
1424
|
+
case "string":
|
|
1425
|
+
return "";
|
|
1426
|
+
case "number":
|
|
1427
|
+
case "integer":
|
|
1428
|
+
return 0;
|
|
1429
|
+
case "boolean":
|
|
1430
|
+
return !1;
|
|
1431
|
+
case "null":
|
|
1432
|
+
return null;
|
|
1433
|
+
case "object":
|
|
1434
|
+
return {};
|
|
1435
|
+
case "array":
|
|
1436
|
+
return [];
|
|
1437
|
+
default:
|
|
1438
|
+
return null;
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
function Se(e, t) {
|
|
1442
|
+
return Ze(Q(e, t), Q);
|
|
1443
|
+
}
|
|
1444
|
+
function De(e, t) {
|
|
1445
|
+
return $e(Q(e, t), Q);
|
|
1446
|
+
}
|
|
1447
|
+
function Xt(e) {
|
|
1448
|
+
let t = He(e), i = Je(e);
|
|
1449
|
+
return `${t}T${i}`;
|
|
1450
|
+
}
|
|
1451
|
+
function He(e) {
|
|
1452
|
+
let t = e.int(2e3, 2030), i = e.int(1, 12), r = Ve(t, i), n = e.int(1, r);
|
|
1453
|
+
return `${t}-${M(i)}-${M(n)}`;
|
|
1454
|
+
}
|
|
1455
|
+
function Je(e) {
|
|
1456
|
+
let t = e.int(0, 23), i = e.int(0, 59), r = e.int(0, 59);
|
|
1457
|
+
return `${M(t)}:${M(i)}:${M(r)}Z`;
|
|
1458
|
+
}
|
|
1459
|
+
var Nt = ["alice", "bob", "charlie", "dave", "eve", "frank", "grace", "heidi"], Wt = ["example.com", "test.org", "demo.net", "sample.io"];
|
|
1460
|
+
function ue(e) {
|
|
1461
|
+
let t = e.pick(Nt), i = e.int(1, 999), r = e.pick(Wt);
|
|
1462
|
+
return `${t}${i}@${r}`;
|
|
1463
|
+
}
|
|
1464
|
+
var Tt = ["https"], qt = ["example.com", "test.org", "demo.net"], Ct = ["api", "v1", "users", "items", "data", "resource"];
|
|
1465
|
+
function X(e) {
|
|
1466
|
+
let t = e.pick(Tt), i = e.pick(qt), r = e.int(1, 3), n = [];
|
|
1467
|
+
for (let o = 0; o < r; o++) n.push(e.pick(Ct));
|
|
1468
|
+
return `${t}://${i}/${n.join("/")}`;
|
|
1469
|
+
}
|
|
1470
|
+
var Rt = ["alpha", "beta", "gamma", "delta", "echo", "fox", "golf", "hotel"], Yt = ["com", "org", "net", "io", "dev"];
|
|
1471
|
+
function ce(e) {
|
|
1472
|
+
let t = e.int(1, 3), i = [];
|
|
1473
|
+
for (let r = 0; r < t; r++) i.push(e.pick(Rt));
|
|
1474
|
+
return i.push(e.pick(Yt)), i.join(".");
|
|
1475
|
+
}
|
|
1476
|
+
function _t(e) {
|
|
1477
|
+
return `${e.int(1, 254)}.${e.int(0, 255)}.${e.int(0, 255)}.${e.int(1, 254)}`;
|
|
1478
|
+
}
|
|
1479
|
+
function Ft(e) {
|
|
1480
|
+
let t = [];
|
|
1481
|
+
for (let i = 0; i < 8; i++) t.push(e.int(0, 65535).toString(16));
|
|
1482
|
+
return t.join(":");
|
|
1483
|
+
}
|
|
1484
|
+
function zt(e) {
|
|
1485
|
+
let t = (i) => {
|
|
1486
|
+
let r = "";
|
|
1487
|
+
for (let n = 0; n < i; n++) r += e.int(0, 15).toString(16);
|
|
1488
|
+
return r;
|
|
1489
|
+
};
|
|
1490
|
+
return `${t(8)}-${t(4)}-4${t(3)}-${["8", "9", "a", "b"][e.int(0, 3)]}${t(3)}-${t(12)}`;
|
|
1491
|
+
}
|
|
1492
|
+
var Ut = ["foo", "bar", "baz", "items", "0", "1", "2", "name", "value"];
|
|
1493
|
+
function pe(e) {
|
|
1494
|
+
let t = e.int(1, 4), i = [];
|
|
1495
|
+
for (let r = 0; r < t; r++) i.push(e.pick(Ut));
|
|
1496
|
+
return "/" + i.join("/");
|
|
1497
|
+
}
|
|
1498
|
+
function Vt(e) {
|
|
1499
|
+
let t = ["P"], i = e.bool(), r = e.bool();
|
|
1500
|
+
return i && (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("");
|
|
1501
|
+
}
|
|
1502
|
+
var Gt = /* @__PURE__ */ new Map([["date-time", Xt], ["date", He], ["time", Je], ["duration", Vt], ["email", ue], ["idn-email", ue], ["uri", X], ["uri-reference", X], ["iri", X], ["iri-reference", X], ["hostname", ce], ["idn-hostname", ce], ["ipv4", _t], ["ipv6", Ft], ["uuid", zt], ["json-pointer", pe], ["relative-json-pointer", (e) => `${e.int(0, 5)}${pe(e)}`]]);
|
|
1503
|
+
function Le(e) {
|
|
1504
|
+
let t = new Map(Gt);
|
|
1505
|
+
if (e) for (let [i, r] of Object.entries(e)) t.set(i, r);
|
|
1506
|
+
return t;
|
|
1507
|
+
}
|
|
1508
|
+
function Bt(e, t, i) {
|
|
1509
|
+
i.set(e, t);
|
|
1510
|
+
}
|
|
1511
|
+
function Kt(e, t) {
|
|
1512
|
+
if (!e.startsWith("$")) throw Error(`Invalid JSONPath: ${e} (must start with $)`);
|
|
1513
|
+
let i = Zt(e), r = [t];
|
|
1514
|
+
for (let n of i) {
|
|
1515
|
+
let o = [];
|
|
1516
|
+
if (n === "") {
|
|
1517
|
+
for (let l of r) V(l, o);
|
|
1518
|
+
o.push(...r), r = o;
|
|
1519
|
+
continue;
|
|
1520
|
+
}
|
|
1521
|
+
for (let l of r)
|
|
1522
|
+
if (l != null)
|
|
1523
|
+
if (n.startsWith("q:")) {
|
|
1524
|
+
let a = n.slice(2);
|
|
1525
|
+
typeof l == "object" && l !== null && a in l && o.push(l[a]);
|
|
1526
|
+
} else if (n === "*")
|
|
1527
|
+
Array.isArray(l) && o.push(...l);
|
|
1528
|
+
else if (/^\d+$/.test(n)) {
|
|
1529
|
+
let a = parseInt(n, 10);
|
|
1530
|
+
Array.isArray(l) && a < l.length && o.push(l[a]);
|
|
1531
|
+
} else typeof l == "object" && l !== null && n in l && o.push(l[n]);
|
|
1532
|
+
r = o;
|
|
1533
|
+
}
|
|
1534
|
+
return r;
|
|
1535
|
+
}
|
|
1536
|
+
function V(e, t) {
|
|
1537
|
+
if (e != null) {
|
|
1538
|
+
if (Array.isArray(e)) for (let i of e) t.push(i), V(i, t);
|
|
1539
|
+
else if (typeof e == "object") for (let i of Object.values(e)) t.push(i), V(i, t);
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
function Zt(e) {
|
|
1543
|
+
if (!e.startsWith("$")) throw Error(`Invalid JSONPath: ${e}`);
|
|
1544
|
+
let t = [], i = e.slice(1);
|
|
1545
|
+
for (; i.length > 0; ) if (i.startsWith(".")) {
|
|
1546
|
+
i = i.slice(1), i.startsWith(".") && (i = i.slice(1), t.push(""));
|
|
1547
|
+
let r = i.match(/^([a-zA-Z_][a-zA-Z0-9_]*)/);
|
|
1548
|
+
if (r) t.push(r[1]), i = i.slice(r[1].length);
|
|
1549
|
+
else break;
|
|
1550
|
+
} else if (i.startsWith("[")) {
|
|
1551
|
+
let r = i.indexOf("]");
|
|
1552
|
+
if (r === -1) break;
|
|
1553
|
+
let n = i.slice(1, r), o = $t(n), l = n[0] === '"' || n[0] === "'";
|
|
1554
|
+
t.push(l ? `q:${o}` : o), i = i.slice(r + 1);
|
|
1555
|
+
} else break;
|
|
1556
|
+
return t;
|
|
1557
|
+
}
|
|
1558
|
+
function $t(e) {
|
|
1559
|
+
let t = e[0];
|
|
1560
|
+
return (t === '"' || t === "'") && e[e.length - 1] === t ? e.slice(1, -1).replace(/\\(["'\\])/g, "$1") : e;
|
|
1561
|
+
}
|
|
1562
|
+
function ei(e) {
|
|
1563
|
+
if (e.properties) return e.properties;
|
|
1564
|
+
if (e.type === "object" || e.type === void 0) {
|
|
1565
|
+
let t = {}, i = !1;
|
|
1566
|
+
for (let [r, n] of Object.entries(e))
|
|
1567
|
+
C.has(r) || (Oe(n) ? (t[r] = n, i = !0) : (t[r] = { const: n }, i = !0));
|
|
1568
|
+
if (i) return t;
|
|
1569
|
+
}
|
|
1570
|
+
return {};
|
|
1571
|
+
}
|
|
1572
|
+
function T(e, t, i, r) {
|
|
1573
|
+
if (!i.resolveJsonPath) return e;
|
|
1574
|
+
let n = r ?? e;
|
|
1575
|
+
if (t === !0 || t === !1 || t.$ref) return e;
|
|
1576
|
+
let o = t;
|
|
1577
|
+
if (o.allOf || o.anyOf || o.oneOf) return e;
|
|
1578
|
+
if (typeof e == "object" && e !== null && !Array.isArray(e)) {
|
|
1579
|
+
let l = { ...e }, a = ei(o);
|
|
1580
|
+
for (let [s, c] of Object.entries(a)) if (s in l) {
|
|
1581
|
+
let g = l[s];
|
|
1582
|
+
if (typeof c == "object" && c !== null && "jsonPath" in c && typeof c.jsonPath == "string") {
|
|
1583
|
+
let v = Kt(c.jsonPath, n);
|
|
1584
|
+
v.length > 0 && (l[s] = i.random.pick(v));
|
|
1585
|
+
} else l[s] = T(g, c, i, n);
|
|
1586
|
+
}
|
|
1587
|
+
return l;
|
|
1588
|
+
}
|
|
1589
|
+
return Array.isArray(e) && o.items ? e.map((l) => T(l, o.items, i, n)) : e;
|
|
1590
|
+
}
|
|
1591
|
+
var Qe = Le(), me = /* @__PURE__ */ new Set(["https://json-schema.org/draft/2020-12/schema", "https://json-schema.org/draft/2019-09/schema"]);
|
|
1592
|
+
function Ee(e, t) {
|
|
1593
|
+
if ((t == null ? void 0 : t.validateSchemaVersion) === !0 && !(t != null && t.propAliases) && typeof e == "object" && e !== null && "$schema" in e) {
|
|
1594
|
+
let g = e.$schema;
|
|
1595
|
+
if (typeof g == "string" && !me.has(g)) throw Error(`Unsupported JSON Schema version: ${g}. Supported versions: ${[...me].join(", ")}`);
|
|
1596
|
+
}
|
|
1597
|
+
let i = oi(t), r = de((t == null ? void 0 : t.seed) ?? 1), n = i.propAliases ? ni(e, i.propAliases) : e, o = gt(n);
|
|
1598
|
+
vt(n, o);
|
|
1599
|
+
let l = i.formats ? Le(i.formats) : new Map(Qe), a = i.refDepthMin ?? i.refDepth, s = i.refDepthMax ?? i.refDepth;
|
|
1600
|
+
if (a !== void 0 && s !== void 0 && a > s) throw Error(`refDepthMin (${a}) cannot be greater than refDepthMax (${s})`);
|
|
1601
|
+
let c = { random: r, maxDepth: i.maxDepth ?? (s ? s + 20 : 5), maxDefaultItems: i.maxDefaultItems ?? 3, optionalsProbability: i.optionalsProbability ?? 0.5, depth: 0, refRegistry: o, refStack: /* @__PURE__ */ new Set(), formatRegistry: l, minItems: i.minItems, maxItems: i.maxItems, minLength: i.minLength, maxLength: i.maxLength, useDefaultValue: i.useDefaultValue, path: "/", outputPath: "/", alwaysFakeOptionals: i.alwaysFakeOptionals, fixedProbabilities: i.fixedProbabilities, fillProperties: i.fillProperties, extensions: i.extensions, resolveJsonPath: i.resolveJsonPath, autoIncrementCounters: /* @__PURE__ */ new Map(), refDepth: 0, refDepthMin: a, refDepthMax: s, useExamplesValue: i.useExamplesValue, filterExampleDefaults: i.filterExampleDefaults ?? !1, pruneProperties: i.pruneProperties, failOnInvalidTypes: i.failOnInvalidTypes, defaultInvalidTypeProduct: i.defaultInvalidTypeProduct, minDateTime: i.minDateTime, maxDateTime: i.maxDateTime, propAliases: i.propAliases, outputTransform: i.outputTransform };
|
|
1602
|
+
return { schema_: n, normalizedOptions: i, ctx: c };
|
|
1603
|
+
}
|
|
1604
|
+
async function B(e, t) {
|
|
1605
|
+
let { schema_: i, normalizedOptions: r, ctx: n } = Ee(e, t);
|
|
1606
|
+
n.refResolver = r.refResolver;
|
|
1607
|
+
let o = await Se(i, n);
|
|
1608
|
+
return r.resolveJsonPath ? T(o, e, n, o) : o;
|
|
1609
|
+
}
|
|
1610
|
+
function ci(e) {
|
|
1611
|
+
let t = { ...e }, i = 0;
|
|
1612
|
+
return { generate(r) {
|
|
1613
|
+
let n = (t.seed ?? 1) + i++;
|
|
1614
|
+
return B(r, { ...t, seed: n });
|
|
1615
|
+
} };
|
|
1616
|
+
}
|
|
1617
|
+
function ti(e, t) {
|
|
1618
|
+
let { schema_: i, normalizedOptions: r, ctx: n } = Ee(e, t);
|
|
1619
|
+
n.__sync = !0, n.refResolver = r.refResolver;
|
|
1620
|
+
let o = De(i, n);
|
|
1621
|
+
return r.resolveJsonPath ? T(o, e, n, o) : o;
|
|
1622
|
+
}
|
|
1623
|
+
function pi(e) {
|
|
1624
|
+
let t = { ...e }, i = 0;
|
|
1625
|
+
return { generate(r) {
|
|
1626
|
+
let n = (t.seed ?? 1) + i++;
|
|
1627
|
+
return ti(r, { ...t, seed: n });
|
|
1628
|
+
} };
|
|
1629
|
+
}
|
|
1630
|
+
function mi(e, t) {
|
|
1631
|
+
Bt(e, t, Qe);
|
|
1632
|
+
}
|
|
1633
|
+
function di(e, t) {
|
|
1634
|
+
kt(e, t);
|
|
1635
|
+
}
|
|
1636
|
+
function hi(e) {
|
|
1637
|
+
It(e);
|
|
1638
|
+
}
|
|
1639
|
+
async function ii(e, t) {
|
|
1640
|
+
let i = await B(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 };
|
|
1641
|
+
return JSON.stringify(i, r.replacer, r.space);
|
|
1642
|
+
}
|
|
1643
|
+
function yi(e) {
|
|
1644
|
+
let t = { ...e }, i = 0;
|
|
1645
|
+
return { generate(r) {
|
|
1646
|
+
let n = (t.seed ?? 1) + i++;
|
|
1647
|
+
return ii(r, { ...t, seed: n });
|
|
1648
|
+
} };
|
|
1649
|
+
}
|
|
1650
|
+
async function ri(e, t) {
|
|
1651
|
+
var o;
|
|
1652
|
+
let i = (t == null ? void 0 : t.yaml) ?? ((o = t == null ? void 0 : t.extensions) == null ? void 0 : o.yaml);
|
|
1653
|
+
if (!i) throw Error("YAML support requires 'yaml' package. Provide via options.extensions.yaml or options.yaml.");
|
|
1654
|
+
let r = await B(e, t), n = (t == null ? void 0 : t.pretty) !== !1 ? { indent: 2, lineWidth: 0 } : {};
|
|
1655
|
+
return i.stringify(r, n);
|
|
1656
|
+
}
|
|
1657
|
+
function gi(e) {
|
|
1658
|
+
let t = { ...e }, i = 0;
|
|
1659
|
+
return { generate(r) {
|
|
1660
|
+
let n = (t.seed ?? 1) + i++;
|
|
1661
|
+
return ri(r, { ...t, seed: n });
|
|
1662
|
+
} };
|
|
1663
|
+
}
|
|
1664
|
+
function ni(e, t) {
|
|
1665
|
+
if (typeof e != "object" || e === null) return e;
|
|
1666
|
+
let i = e, r = null;
|
|
1667
|
+
for (let [n, o] of Object.entries(t)) n in i && !(o in i) && (r || (r = { ...i }), r[o] = r[n], delete r[n]);
|
|
1668
|
+
return r ?? e;
|
|
1669
|
+
}
|
|
1670
|
+
function oi(e) {
|
|
1671
|
+
if (!e) return {};
|
|
1672
|
+
let t = e, i = { ...e };
|
|
1673
|
+
return t.requiredOnly === !0 && i.optionalsProbability === void 0 && (i = { ...i, optionalsProbability: 0, alwaysFakeOptionals: !1 }), t.ignoreProperties && t.ignoreProperties.length > 0 && (i = { ...i, outputTransform: li(i.outputTransform, ai(t.ignoreProperties)) }), i;
|
|
1674
|
+
}
|
|
1675
|
+
function li(e, t) {
|
|
1676
|
+
return e ? t ? (i, r, n) => {
|
|
1677
|
+
let o = e(i, r, n);
|
|
1678
|
+
return o && typeof o == "object" && "then" in o && typeof o.then == "function" ? o.then((l) => t(l, r, n)) : t(o, r, n);
|
|
1679
|
+
} : e : t;
|
|
1680
|
+
}
|
|
1681
|
+
function ai(e) {
|
|
1682
|
+
return (t, i, r) => {
|
|
1683
|
+
if (r === "/") return t;
|
|
1684
|
+
let n = si(r.slice(r.lastIndexOf("/") + 1));
|
|
1685
|
+
return e.some((o) => typeof o == "string" ? o === n : o instanceof RegExp ? o.test(n) : o(i)) ? void 0 : t;
|
|
1686
|
+
};
|
|
1687
|
+
}
|
|
1688
|
+
function si(e) {
|
|
1689
|
+
return e.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
1690
|
+
}
|
|
1691
|
+
export {
|
|
1692
|
+
ci as createGenerator,
|
|
1693
|
+
pi as createGeneratorSync,
|
|
1694
|
+
yi as createJsonGenerator,
|
|
1695
|
+
ui as createRemoteResolver,
|
|
1696
|
+
gi as createYamlGenerator,
|
|
1697
|
+
di as define,
|
|
1698
|
+
B as generate,
|
|
1699
|
+
ii as generateJson,
|
|
1700
|
+
ti as generateSync,
|
|
1701
|
+
ri as generateYaml,
|
|
1702
|
+
mi as registerFormat,
|
|
1703
|
+
hi as reset
|
|
1704
|
+
};
|