@alint-js/plugin-simplicity 0.0.27 → 0.0.29
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/dist/S-CK_sYI4B.mjs +3796 -0
- package/dist/core-BMoyZMrf.mjs +788 -0
- package/dist/effect-Df2gY8Wx-md27HJj5.mjs +8 -0
- package/dist/esm-DJF2n0HM.mjs +111800 -0
- package/dist/esm-Dk08cWwM.mjs +4632 -0
- package/dist/index-DoHiaFQM-9scNuUlY.mjs +16 -0
- package/dist/index.d.mts +1912 -17
- package/dist/index.mjs +9556 -978
- package/dist/rolldown-runtime-JspESFgx.mjs +35 -0
- package/dist/sury-BoOvxlMw-BFMqRCCo.mjs +8 -0
- package/dist/valibot-_ibN3zSD-p0SIbJDK.mjs +8 -0
- package/dist/zod-DjyNjMBF-G0rhiyEk.mjs +28 -0
- package/package.json +8 -9
|
@@ -0,0 +1,3796 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/sury@11.0.0-alpha.10/node_modules/sury/src/S.mjs
|
|
2
|
+
var stringTag = "string";
|
|
3
|
+
var numberTag = "number";
|
|
4
|
+
var bigintTag = "bigint";
|
|
5
|
+
var booleanTag = "boolean";
|
|
6
|
+
var symbolTag = "symbol";
|
|
7
|
+
var nullTag = "null";
|
|
8
|
+
var undefinedTag = "undefined";
|
|
9
|
+
var nanTag = "nan";
|
|
10
|
+
var functionTag = "function";
|
|
11
|
+
var instanceTag = "instance";
|
|
12
|
+
var arrayTag = "array";
|
|
13
|
+
var objectTag = "object";
|
|
14
|
+
var unionTag = "union";
|
|
15
|
+
var neverTag = "never";
|
|
16
|
+
var unknownTag = "unknown";
|
|
17
|
+
var refTag = "ref";
|
|
18
|
+
var tagFlagUnknown = 1;
|
|
19
|
+
var tagFlagString = 2;
|
|
20
|
+
var tagFlagNumber = 4;
|
|
21
|
+
var tagFlagBoolean = 8;
|
|
22
|
+
var tagFlagUndefined = 16;
|
|
23
|
+
var tagFlagNull = 32;
|
|
24
|
+
var tagFlagObject = 64;
|
|
25
|
+
var tagFlagArray = 128;
|
|
26
|
+
var tagFlagUnion = 256;
|
|
27
|
+
var tagFlagRef = 512;
|
|
28
|
+
var tagFlagBigint = 1024;
|
|
29
|
+
var tagFlagNaN = 2048;
|
|
30
|
+
var tagFlagFunction = 4096;
|
|
31
|
+
var tagFlagInstance = 8192;
|
|
32
|
+
var tagFlagSymbol = 16384;
|
|
33
|
+
var tagFlags = {
|
|
34
|
+
[unknownTag]: 1,
|
|
35
|
+
[stringTag]: 2,
|
|
36
|
+
[numberTag]: 4,
|
|
37
|
+
[booleanTag]: 8,
|
|
38
|
+
[undefinedTag]: 16,
|
|
39
|
+
[nullTag]: 32,
|
|
40
|
+
[objectTag]: 64,
|
|
41
|
+
[arrayTag]: 128,
|
|
42
|
+
[unionTag]: 256,
|
|
43
|
+
[refTag]: 512,
|
|
44
|
+
[bigintTag]: 1024,
|
|
45
|
+
[nanTag]: 2048,
|
|
46
|
+
[functionTag]: 4096,
|
|
47
|
+
[instanceTag]: 8192,
|
|
48
|
+
[neverTag]: 32768,
|
|
49
|
+
[symbolTag]: 16384
|
|
50
|
+
};
|
|
51
|
+
var flagNone = 0;
|
|
52
|
+
var flagAsync = 1;
|
|
53
|
+
var flagDisableNanNumberValidation = 2;
|
|
54
|
+
var flagUnsafeHas = (acc, flag) => {
|
|
55
|
+
return (acc & flag) !== 0;
|
|
56
|
+
};
|
|
57
|
+
var valFlagNone = 0;
|
|
58
|
+
var valFlagAsync = 1;
|
|
59
|
+
var vendor = "sury";
|
|
60
|
+
var s = /* @__PURE__ */ Symbol(vendor);
|
|
61
|
+
var itemSymbol = /* @__PURE__ */ Symbol(vendor + ":item");
|
|
62
|
+
var shouldPrependPathKey = "p";
|
|
63
|
+
var immutableEmptyArray = [];
|
|
64
|
+
var immutableEmptyObject = /* @__PURE__ */ Object.create(null);
|
|
65
|
+
var isSchemaObject = (obj) => {
|
|
66
|
+
return !!obj["~standard"];
|
|
67
|
+
};
|
|
68
|
+
var constField = "const";
|
|
69
|
+
var isLiteral = (schema) => {
|
|
70
|
+
return constField in schema;
|
|
71
|
+
};
|
|
72
|
+
var isOptional = (schema) => {
|
|
73
|
+
return schema.type === undefinedTag || schema.type === unionTag && undefinedTag in schema.has;
|
|
74
|
+
};
|
|
75
|
+
var stringify = (unknown2) => {
|
|
76
|
+
const tagFlag = tagFlags[typeof unknown2];
|
|
77
|
+
if (flagUnsafeHas(tagFlag, tagFlagUndefined)) return undefinedTag;
|
|
78
|
+
else if (flagUnsafeHas(tagFlag, tagFlagObject)) if (unknown2 === null) return nullTag;
|
|
79
|
+
else if (Array.isArray(unknown2)) return `[${unknown2.map(stringify).join(", ")}]`;
|
|
80
|
+
else if (unknown2.constructor === Object) {
|
|
81
|
+
const dict2 = unknown2;
|
|
82
|
+
return `{ ${Object.keys(dict2).map((key) => `${key}: ${stringify(dict2[key])}; `).join("")}}`;
|
|
83
|
+
} else return Object.prototype.toString.call(unknown2);
|
|
84
|
+
else if (flagUnsafeHas(tagFlag, tagFlagString)) return `"${unknown2}"`;
|
|
85
|
+
else if (flagUnsafeHas(tagFlag, tagFlagBigint)) return `${unknown2}n`;
|
|
86
|
+
else if (flagUnsafeHas(tagFlag, tagFlagFunction)) return `Function`;
|
|
87
|
+
else return unknown2.toString();
|
|
88
|
+
};
|
|
89
|
+
var toExpression = (schema) => {
|
|
90
|
+
if (schema.name !== void 0) return schema.name;
|
|
91
|
+
else if (schema.const !== void 0) return stringify(schema.const);
|
|
92
|
+
else if (schema.anyOf !== void 0) return schema.anyOf.map(toExpression).join(" | ");
|
|
93
|
+
else if (schema.format === "compactColumns") {
|
|
94
|
+
const to = schema.to;
|
|
95
|
+
if (to !== void 0) {
|
|
96
|
+
const props = to.properties;
|
|
97
|
+
if (props !== void 0) return `[${Object.keys(props).map((key) => {
|
|
98
|
+
const propSchema = props[key];
|
|
99
|
+
return `${toExpression(propSchema)}[]`;
|
|
100
|
+
}).join(", ")}]`;
|
|
101
|
+
else return "unknown[][]";
|
|
102
|
+
} else {
|
|
103
|
+
const additionalItems = schema.additionalItems;
|
|
104
|
+
if (additionalItems !== void 0 && typeof additionalItems === "object") return `${toExpression(additionalItems)}[]`;
|
|
105
|
+
else return "unknown[][]";
|
|
106
|
+
}
|
|
107
|
+
} else if (schema.format !== void 0) return schema.format;
|
|
108
|
+
else if (schema.type === objectTag) {
|
|
109
|
+
const properties = schema.properties;
|
|
110
|
+
const locations = Object.keys(properties);
|
|
111
|
+
if (locations.length === 0) if (typeof schema.additionalItems === objectTag) {
|
|
112
|
+
const additionalItems = schema.additionalItems;
|
|
113
|
+
return `{ [key: string]: ${toExpression(additionalItems)}; }`;
|
|
114
|
+
} else return `{}`;
|
|
115
|
+
else return `{ ${locations.map((location) => {
|
|
116
|
+
return `${location}: ${toExpression(properties[location])};`;
|
|
117
|
+
}).join(" ")} }`;
|
|
118
|
+
} else if (schema.type === nanTag) return "NaN";
|
|
119
|
+
else if (schema.type === arrayTag) {
|
|
120
|
+
const items = schema.items;
|
|
121
|
+
if (typeof schema.additionalItems === objectTag) {
|
|
122
|
+
const additionalItems = schema.additionalItems;
|
|
123
|
+
const itemName = toExpression(additionalItems);
|
|
124
|
+
return (additionalItems.type === unionTag ? `(${itemName})` : itemName) + "[]";
|
|
125
|
+
} else return `[${items.map((schema2) => toExpression(schema2)).join(", ")}]`;
|
|
126
|
+
} else if (schema.type === instanceTag) return schema.class.name;
|
|
127
|
+
else return schema.type;
|
|
128
|
+
};
|
|
129
|
+
function Schema() {}
|
|
130
|
+
var schemaPrototype = /* @__PURE__ */ Object.create(null);
|
|
131
|
+
Object.defineProperty(schemaPrototype, "with", { get() {
|
|
132
|
+
return (fn, ...args) => fn(this, ...args);
|
|
133
|
+
} });
|
|
134
|
+
Schema.prototype = schemaPrototype;
|
|
135
|
+
var seq = 1;
|
|
136
|
+
var exnId = {};
|
|
137
|
+
var __setExnId = (id) => {
|
|
138
|
+
exnId = id;
|
|
139
|
+
};
|
|
140
|
+
var SuryError = class extends Error {
|
|
141
|
+
constructor(params) {
|
|
142
|
+
super();
|
|
143
|
+
Object.assign(this, params);
|
|
144
|
+
}
|
|
145
|
+
get message() {
|
|
146
|
+
return formatErrorMessage(this);
|
|
147
|
+
}
|
|
148
|
+
get _1() {
|
|
149
|
+
return this;
|
|
150
|
+
}
|
|
151
|
+
get RE_EXN_ID() {
|
|
152
|
+
return exnId;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
Object.defineProperty(SuryError.prototype, "name", { value: "SuryError" });
|
|
156
|
+
Object.defineProperty(SuryError.prototype, "s", { value: s });
|
|
157
|
+
var getOrRethrow = (exn) => {
|
|
158
|
+
if (exn && exn.s === s) return exn;
|
|
159
|
+
else throw exn;
|
|
160
|
+
};
|
|
161
|
+
var panic = (message) => {
|
|
162
|
+
throw new Error(`[Sury] ${message}`);
|
|
163
|
+
};
|
|
164
|
+
var formatErrorMessage = (error) => {
|
|
165
|
+
return `${error.path === "" ? "" : `Failed at ${error.path}: `}${error.reason}`;
|
|
166
|
+
};
|
|
167
|
+
var errorClass = SuryError;
|
|
168
|
+
var initialOnAdditionalItems = "strip";
|
|
169
|
+
var initialDefaultFlag = valFlagNone;
|
|
170
|
+
var globalConfig = {
|
|
171
|
+
m: formatErrorMessage,
|
|
172
|
+
d: void 0,
|
|
173
|
+
a: initialOnAdditionalItems,
|
|
174
|
+
f: initialDefaultFlag
|
|
175
|
+
};
|
|
176
|
+
var valueOptions = {};
|
|
177
|
+
var configurableValueOptions = { configurable: true };
|
|
178
|
+
var valKey = "value";
|
|
179
|
+
var reversedKey = "r";
|
|
180
|
+
var SchemaCtor = Schema;
|
|
181
|
+
var baseSchema = (tag, selfReverse) => {
|
|
182
|
+
const schema = new SchemaCtor();
|
|
183
|
+
schema.type = tag;
|
|
184
|
+
schema.seq = seq++;
|
|
185
|
+
if (selfReverse) {
|
|
186
|
+
valueOptions[valKey] = schema;
|
|
187
|
+
Object.defineProperty(schema, reversedKey, valueOptions);
|
|
188
|
+
}
|
|
189
|
+
return schema;
|
|
190
|
+
};
|
|
191
|
+
var noopDecoder = (input) => {
|
|
192
|
+
return input;
|
|
193
|
+
};
|
|
194
|
+
var factoryCache = {};
|
|
195
|
+
var cached = (key, tag, init) => {
|
|
196
|
+
const existing = factoryCache[key];
|
|
197
|
+
if (existing !== void 0) return existing;
|
|
198
|
+
else {
|
|
199
|
+
const schema = baseSchema(tag, true);
|
|
200
|
+
init(schema);
|
|
201
|
+
factoryCache[key] = schema;
|
|
202
|
+
return schema;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
var unknown = baseSchema(unknownTag, true);
|
|
206
|
+
unknown.decoder = noopDecoder;
|
|
207
|
+
var copySchema = (schema) => {
|
|
208
|
+
const c = Object.assign(new SchemaCtor(), schema);
|
|
209
|
+
c.seq = seq++;
|
|
210
|
+
return c;
|
|
211
|
+
};
|
|
212
|
+
var updateOutput = (schema, fn) => {
|
|
213
|
+
const root = copySchema(schema);
|
|
214
|
+
let mut = root;
|
|
215
|
+
while (mut.to !== void 0) {
|
|
216
|
+
const next = copySchema(mut.to);
|
|
217
|
+
mut.to = next;
|
|
218
|
+
mut = next;
|
|
219
|
+
}
|
|
220
|
+
fn(mut);
|
|
221
|
+
return root;
|
|
222
|
+
};
|
|
223
|
+
var pathEmpty = "";
|
|
224
|
+
var pathDynamic = "[]";
|
|
225
|
+
var inlinedValueFromString = (str) => {
|
|
226
|
+
return str.includes("\"") || str.includes("\n") ? JSON.stringify(str) : `"${str}"`;
|
|
227
|
+
};
|
|
228
|
+
var pathFromInlinedLocation = (inlinedLocation) => {
|
|
229
|
+
return `[${inlinedLocation}]`;
|
|
230
|
+
};
|
|
231
|
+
var pathFromLocation = (location) => {
|
|
232
|
+
return `[${inlinedValueFromString(location)}]`;
|
|
233
|
+
};
|
|
234
|
+
var pathToArray = (path) => {
|
|
235
|
+
return path === "" ? [] : JSON.parse(path.split(`"]["`).join(`","`));
|
|
236
|
+
};
|
|
237
|
+
var pathFromArray = (array2) => {
|
|
238
|
+
switch (array2.length) {
|
|
239
|
+
case 0: return "";
|
|
240
|
+
case 1: return pathFromLocation(array2[0]);
|
|
241
|
+
default: return array2.map(pathFromLocation).join("");
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
var pathConcat = (path, concatedPath) => {
|
|
245
|
+
return path + concatedPath;
|
|
246
|
+
};
|
|
247
|
+
function _var() {
|
|
248
|
+
return this.i;
|
|
249
|
+
}
|
|
250
|
+
function _bondVar() {
|
|
251
|
+
return this.b.v();
|
|
252
|
+
}
|
|
253
|
+
function _prevVar() {
|
|
254
|
+
return this.prev.v();
|
|
255
|
+
}
|
|
256
|
+
function _notVarBeforeValidation() {
|
|
257
|
+
const val = this;
|
|
258
|
+
const v = B_varWithoutAllocation(val.g);
|
|
259
|
+
val.cp = `let ${v}=${val.i};`;
|
|
260
|
+
val.i = v;
|
|
261
|
+
val.v = _var;
|
|
262
|
+
return v;
|
|
263
|
+
}
|
|
264
|
+
function _notVarAtParent() {
|
|
265
|
+
const val = this;
|
|
266
|
+
const parent = val.p;
|
|
267
|
+
if (parent.fz) {
|
|
268
|
+
val.v = _var;
|
|
269
|
+
return val.i;
|
|
270
|
+
} else {
|
|
271
|
+
const v = B_varWithoutAllocation(val.g);
|
|
272
|
+
B_hoistDecl(parent, `${v}=${val.i}`);
|
|
273
|
+
val.v = _var;
|
|
274
|
+
val.i = v;
|
|
275
|
+
return v;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function _notVar() {
|
|
279
|
+
const val = this;
|
|
280
|
+
if (val.fz) {
|
|
281
|
+
val.v = _var;
|
|
282
|
+
val.i = `(${val.i})`;
|
|
283
|
+
return val.i;
|
|
284
|
+
} else {
|
|
285
|
+
const v = B_varWithoutAllocation(val.g);
|
|
286
|
+
if (val.prev !== void 0) if (val.i === "") val.cp = `let ${v};` + val.cp;
|
|
287
|
+
else val.cp = val.cp + `let ${v}=${val.i};`;
|
|
288
|
+
else if (val.i === "") B_hoistDecl(val, v);
|
|
289
|
+
else B_hoistDecl(val, `${v}=${val.i}`);
|
|
290
|
+
val.v = _var;
|
|
291
|
+
val.i = v;
|
|
292
|
+
return v;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
var operationArgVar = "i";
|
|
296
|
+
var failInvalidType = (input) => {
|
|
297
|
+
const em = input.e.errorMessage;
|
|
298
|
+
return B_invalidInputBuilder(void 0, void 0, em !== void 0 ? em.type !== void 0 ? em.type : em._ : void 0)(input);
|
|
299
|
+
};
|
|
300
|
+
var B_embed = (b, value) => {
|
|
301
|
+
const e = b.g.e;
|
|
302
|
+
const l = e.length;
|
|
303
|
+
e[l] = value;
|
|
304
|
+
return `e[${l}]`;
|
|
305
|
+
};
|
|
306
|
+
var B_inlineConst = (b, schema) => {
|
|
307
|
+
const tagFlag = tagFlags[schema.type];
|
|
308
|
+
const const_ = schema.const;
|
|
309
|
+
if (flagUnsafeHas(tagFlag, tagFlagUndefined)) return "void 0";
|
|
310
|
+
else if (flagUnsafeHas(tagFlag, tagFlagString)) return inlinedValueFromString(const_);
|
|
311
|
+
else if (flagUnsafeHas(tagFlag, tagFlagBigint)) return const_ + "n";
|
|
312
|
+
else if (flagUnsafeHas(tagFlag, 28672)) return B_embed(b, schema.const);
|
|
313
|
+
else return const_;
|
|
314
|
+
};
|
|
315
|
+
var B_inlineLocation = (global2, location) => {
|
|
316
|
+
const key = `"${location}"`;
|
|
317
|
+
const cached2 = global2[key];
|
|
318
|
+
if (cached2 !== void 0) return cached2;
|
|
319
|
+
else {
|
|
320
|
+
const inlinedLocation = inlinedValueFromString(location);
|
|
321
|
+
global2[key] = inlinedLocation;
|
|
322
|
+
return inlinedLocation;
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
var B_varWithoutAllocation = (global2) => {
|
|
326
|
+
const newCounter = global2.v + 1;
|
|
327
|
+
global2.v = newCounter;
|
|
328
|
+
return `v${newCounter}`;
|
|
329
|
+
};
|
|
330
|
+
var B_hoistDecl = (owner, decl) => {
|
|
331
|
+
owner.hd = owner.hd === "" ? decl : owner.hd + "," + decl;
|
|
332
|
+
};
|
|
333
|
+
var B_operationArg = (schema, expected, flag, defs) => {
|
|
334
|
+
return {
|
|
335
|
+
cp: "",
|
|
336
|
+
hd: "",
|
|
337
|
+
v: _var,
|
|
338
|
+
i: operationArgVar,
|
|
339
|
+
f: valFlagNone,
|
|
340
|
+
s: schema,
|
|
341
|
+
e: expected,
|
|
342
|
+
path: pathEmpty,
|
|
343
|
+
g: {
|
|
344
|
+
d: defs,
|
|
345
|
+
o: flag,
|
|
346
|
+
e: [],
|
|
347
|
+
v: -1
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
var B_throw = (errorDetails) => {
|
|
352
|
+
throw new SuryError(errorDetails);
|
|
353
|
+
};
|
|
354
|
+
var B_unsupportedDecode = (b, from, target) => {
|
|
355
|
+
return B_throw({
|
|
356
|
+
code: "unsupported_decode",
|
|
357
|
+
from,
|
|
358
|
+
to: target,
|
|
359
|
+
reason: `Can't decode ${toExpression(from)} to ${toExpression(target)}. Use S.to to define a custom decoder`,
|
|
360
|
+
path: b.path
|
|
361
|
+
});
|
|
362
|
+
};
|
|
363
|
+
var B_failWithArg = (b, fn, arg) => {
|
|
364
|
+
return `${B_embed(b, (arg2) => {
|
|
365
|
+
B_throw(fn(arg2));
|
|
366
|
+
})}(${arg})`;
|
|
367
|
+
};
|
|
368
|
+
var B_makeInvalidConversionDetails = (input, to, cause) => {
|
|
369
|
+
if (cause && cause.s === s) {
|
|
370
|
+
const error = cause;
|
|
371
|
+
if (!error[shouldPrependPathKey]) error["path"] = pathConcat(input.path, error.path);
|
|
372
|
+
return error;
|
|
373
|
+
} else {
|
|
374
|
+
let reason;
|
|
375
|
+
if (cause instanceof Error) {
|
|
376
|
+
const text = "" + cause;
|
|
377
|
+
if (text.startsWith("Error: ")) reason = text.slice(7);
|
|
378
|
+
else reason = text;
|
|
379
|
+
} else reason = stringify(cause);
|
|
380
|
+
return {
|
|
381
|
+
code: "invalid_conversion",
|
|
382
|
+
from: input.s,
|
|
383
|
+
to,
|
|
384
|
+
cause,
|
|
385
|
+
path: input.path,
|
|
386
|
+
reason
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
var B_receivedSchema = (val) => {
|
|
391
|
+
return val.prev !== void 0 ? val.prev.s : val.s;
|
|
392
|
+
};
|
|
393
|
+
var B_makeInvalidInputDetails = (expected, received, path, input, includeInput, unionErrors, reasonOverride) => {
|
|
394
|
+
let reasonRef = reasonOverride !== void 0 ? reasonOverride : `Expected ${toExpression(expected)}, received ${includeInput ? stringify(input) : toExpression(received)}`;
|
|
395
|
+
if (unionErrors !== void 0) {
|
|
396
|
+
const caseErrors = unionErrors;
|
|
397
|
+
const seenReasons = /* @__PURE__ */ new Set();
|
|
398
|
+
for (let idx = 0; idx < caseErrors.length; idx++) {
|
|
399
|
+
const caseError = caseErrors[idx];
|
|
400
|
+
const caseReason = caseError.reason.split("\n").join("\n ");
|
|
401
|
+
const line = `
|
|
402
|
+
- ${caseError.path === "" ? "" : `At ${caseError.path}: `}${caseReason}`;
|
|
403
|
+
if (!seenReasons.has(line)) {
|
|
404
|
+
seenReasons.add(line);
|
|
405
|
+
reasonRef = reasonRef + line;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
const details = {
|
|
410
|
+
code: "invalid_input",
|
|
411
|
+
expected,
|
|
412
|
+
received,
|
|
413
|
+
path,
|
|
414
|
+
reason: reasonRef,
|
|
415
|
+
unionErrors
|
|
416
|
+
};
|
|
417
|
+
if (includeInput) details.input = input;
|
|
418
|
+
return details;
|
|
419
|
+
};
|
|
420
|
+
var B_invalidInputBuilder = (expected, extraPath = pathEmpty, reasonOverride, includeInput = true) => {
|
|
421
|
+
return (input) => {
|
|
422
|
+
const expected_ = expected !== void 0 ? expected : input.e;
|
|
423
|
+
const received = B_receivedSchema(input);
|
|
424
|
+
const path = extraPath === pathEmpty ? input.path : pathConcat(input.path, extraPath);
|
|
425
|
+
return (value) => B_makeInvalidInputDetails(expected_, received, path, value, includeInput, void 0, reasonOverride);
|
|
426
|
+
};
|
|
427
|
+
};
|
|
428
|
+
var B_failWithErrorMessage = (key, defaultMessage) => {
|
|
429
|
+
return (input) => {
|
|
430
|
+
const em = input.e.errorMessage;
|
|
431
|
+
const override = em !== void 0 ? em[key] !== void 0 ? em[key] : em["_"] : void 0;
|
|
432
|
+
const m = override !== void 0 ? override : defaultMessage;
|
|
433
|
+
if (m !== void 0) return B_invalidInputBuilder(void 0, void 0, m)(input);
|
|
434
|
+
else return failInvalidType(input);
|
|
435
|
+
};
|
|
436
|
+
};
|
|
437
|
+
var B_embedInvalidInput = (input, expected = input.e) => {
|
|
438
|
+
return B_failWithArg(input, B_invalidInputBuilder(expected)(input), input.v());
|
|
439
|
+
};
|
|
440
|
+
var B_emitChecks = (val, inputVar) => {
|
|
441
|
+
const checks = val.vc;
|
|
442
|
+
const len = checks.length;
|
|
443
|
+
if (len === 1) {
|
|
444
|
+
const check = checks[0];
|
|
445
|
+
return `${check.c(inputVar)}||${B_failWithArg(val, check.f(val), inputVar)};`;
|
|
446
|
+
} else {
|
|
447
|
+
let out = "";
|
|
448
|
+
let i = 0;
|
|
449
|
+
while (i < len) {
|
|
450
|
+
const head = checks[i];
|
|
451
|
+
const fail = head.f;
|
|
452
|
+
let cond = head.c(inputVar);
|
|
453
|
+
i = i + 1;
|
|
454
|
+
while (i < len && checks[i].f === fail) {
|
|
455
|
+
cond = cond + "&&" + checks[i].c(inputVar);
|
|
456
|
+
i = i + 1;
|
|
457
|
+
}
|
|
458
|
+
out = out + `${cond}||${B_failWithArg(val, fail(val), inputVar)};`;
|
|
459
|
+
}
|
|
460
|
+
return out;
|
|
461
|
+
}
|
|
462
|
+
};
|
|
463
|
+
var B_isHoistable = (val) => {
|
|
464
|
+
return val.t === true ? val.prev.t !== true && val.cp === "" : true;
|
|
465
|
+
};
|
|
466
|
+
var B_merge = (val, hoistCond) => {
|
|
467
|
+
let current = val;
|
|
468
|
+
let code = "";
|
|
469
|
+
while (current !== void 0) {
|
|
470
|
+
const val2 = current;
|
|
471
|
+
current = val2.prev;
|
|
472
|
+
let currentCode = "";
|
|
473
|
+
if (val2.vc) {
|
|
474
|
+
if (hoistCond !== void 0 && B_isHoistable(val2)) {
|
|
475
|
+
const inputVar = current.v();
|
|
476
|
+
const allChecks = val2.vc;
|
|
477
|
+
let localHoist = "";
|
|
478
|
+
for (let i = 0; i < allChecks.length; i++) {
|
|
479
|
+
const check = allChecks[i];
|
|
480
|
+
const condCode = check.c(inputVar);
|
|
481
|
+
if (check.f === failInvalidType) if (localHoist) localHoist = `${localHoist}&&${condCode}`;
|
|
482
|
+
else localHoist = condCode;
|
|
483
|
+
else if (val2.e.noValidation !== true) currentCode = currentCode + `${condCode}||${B_failWithArg(val2, check.f(val2), inputVar)};`;
|
|
484
|
+
}
|
|
485
|
+
if (localHoist) {
|
|
486
|
+
const cond = hoistCond;
|
|
487
|
+
if (cond.contents) cond.contents = `${localHoist}&&${cond.contents}`;
|
|
488
|
+
else cond.contents = localHoist;
|
|
489
|
+
}
|
|
490
|
+
} else if (val2.e.noValidation !== true) currentCode = B_emitChecks(val2, current.v());
|
|
491
|
+
}
|
|
492
|
+
if (val2.hd !== "") currentCode = currentCode + `let ${val2.hd};`;
|
|
493
|
+
val2.fz = true;
|
|
494
|
+
currentCode = val2.cp + currentCode;
|
|
495
|
+
code = currentCode + code;
|
|
496
|
+
}
|
|
497
|
+
return code;
|
|
498
|
+
};
|
|
499
|
+
var B_linkVar = (val, nextVal) => {
|
|
500
|
+
const valVar = val.v.bind(val);
|
|
501
|
+
val.v = () => {
|
|
502
|
+
const v = valVar();
|
|
503
|
+
nextVal.i = v;
|
|
504
|
+
nextVal.v = _var;
|
|
505
|
+
return v;
|
|
506
|
+
};
|
|
507
|
+
};
|
|
508
|
+
var B_next = (prev, initial, schema, expected = prev.e) => {
|
|
509
|
+
return {
|
|
510
|
+
prev,
|
|
511
|
+
v: _notVar,
|
|
512
|
+
i: initial,
|
|
513
|
+
f: valFlagNone,
|
|
514
|
+
s: schema,
|
|
515
|
+
e: expected,
|
|
516
|
+
cp: "",
|
|
517
|
+
hd: "",
|
|
518
|
+
path: prev.path,
|
|
519
|
+
g: prev.g,
|
|
520
|
+
t: true,
|
|
521
|
+
d: prev.d
|
|
522
|
+
};
|
|
523
|
+
};
|
|
524
|
+
var B_refine = (val, schema = val.s, checks, expected = val.e) => {
|
|
525
|
+
const shouldLink = val.v !== _var;
|
|
526
|
+
const nextVal = {
|
|
527
|
+
prev: val,
|
|
528
|
+
i: val.i,
|
|
529
|
+
v: shouldLink ? _prevVar : _var,
|
|
530
|
+
f: val.f,
|
|
531
|
+
s: schema,
|
|
532
|
+
e: expected,
|
|
533
|
+
cp: "",
|
|
534
|
+
hd: "",
|
|
535
|
+
vc: checks,
|
|
536
|
+
path: val.path,
|
|
537
|
+
g: val.g,
|
|
538
|
+
t: val.t,
|
|
539
|
+
d: val.d
|
|
540
|
+
};
|
|
541
|
+
if (shouldLink) B_linkVar(val, nextVal);
|
|
542
|
+
return nextVal;
|
|
543
|
+
};
|
|
544
|
+
var B_pushCheck = (val, check) => {
|
|
545
|
+
if (val.vc !== void 0) val.vc.push(check);
|
|
546
|
+
else val.vc = [check];
|
|
547
|
+
};
|
|
548
|
+
var B_markOutput = (val, valInput) => {
|
|
549
|
+
let deferredInputChecks;
|
|
550
|
+
const inputRefiner = valInput.e.inputRefiner;
|
|
551
|
+
if (inputRefiner !== void 0) {
|
|
552
|
+
const checks = inputRefiner(valInput);
|
|
553
|
+
if (checks.length > 0) if (valInput.prev !== void 0) {
|
|
554
|
+
for (let i = 0; i < checks.length; i++) B_pushCheck(valInput, checks[i]);
|
|
555
|
+
deferredInputChecks = void 0;
|
|
556
|
+
} else deferredInputChecks = checks;
|
|
557
|
+
else deferredInputChecks = void 0;
|
|
558
|
+
} else deferredInputChecks = void 0;
|
|
559
|
+
let outputChecks;
|
|
560
|
+
const refiner = val.e.refiner;
|
|
561
|
+
if (refiner !== void 0) {
|
|
562
|
+
const checks = refiner(val);
|
|
563
|
+
outputChecks = checks.length > 0 ? checks : void 0;
|
|
564
|
+
} else outputChecks = void 0;
|
|
565
|
+
let result;
|
|
566
|
+
if (deferredInputChecks !== void 0 && outputChecks !== void 0) result = B_refine(val, void 0, deferredInputChecks.concat(outputChecks));
|
|
567
|
+
else if (deferredInputChecks !== void 0) result = B_refine(val, void 0, deferredInputChecks);
|
|
568
|
+
else if (outputChecks !== void 0) result = B_refine(val, void 0, outputChecks);
|
|
569
|
+
else result = val;
|
|
570
|
+
result.io = true;
|
|
571
|
+
return result;
|
|
572
|
+
};
|
|
573
|
+
var B_hoistChildChecks = (parent, child, key) => {
|
|
574
|
+
if (child.vc) {
|
|
575
|
+
const pathAppend = pathFromInlinedLocation(B_inlineLocation(parent.g, key));
|
|
576
|
+
child.vc.forEach((check) => {
|
|
577
|
+
B_pushCheck(parent, {
|
|
578
|
+
c: (inputVar) => check.c(inputVar + pathAppend),
|
|
579
|
+
f: check.f
|
|
580
|
+
});
|
|
581
|
+
});
|
|
582
|
+
child.vc = void 0;
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
var B_dynamicScope = (from, locationVar) => {
|
|
586
|
+
const schemaAdditionalItems = from.s.additionalItems;
|
|
587
|
+
const expectedAdditionalItems = from.e.additionalItems;
|
|
588
|
+
return {
|
|
589
|
+
v: _notVarBeforeValidation,
|
|
590
|
+
i: `${from.v()}[${locationVar}]`,
|
|
591
|
+
f: from.f,
|
|
592
|
+
s: schemaAdditionalItems !== void 0 && typeof schemaAdditionalItems !== "string" ? schemaAdditionalItems : unknown,
|
|
593
|
+
e: expectedAdditionalItems !== void 0 && typeof expectedAdditionalItems !== "string" ? expectedAdditionalItems : unknown,
|
|
594
|
+
cp: "",
|
|
595
|
+
hd: "",
|
|
596
|
+
p: from,
|
|
597
|
+
path: pathEmpty,
|
|
598
|
+
g: from.g
|
|
599
|
+
};
|
|
600
|
+
};
|
|
601
|
+
var B_nextConst = (from, schema, expected) => {
|
|
602
|
+
return B_next(from, B_inlineConst(from, schema), schema, expected);
|
|
603
|
+
};
|
|
604
|
+
var B_asyncVal = (from, initial) => {
|
|
605
|
+
const v = B_next(from, initial, from.s);
|
|
606
|
+
v.f = valFlagAsync;
|
|
607
|
+
return v;
|
|
608
|
+
};
|
|
609
|
+
var B_addObjectField = (objectVal, location, val) => {
|
|
610
|
+
if (objectVal.s.type === arrayTag) objectVal.s.items.push(val.s);
|
|
611
|
+
else {
|
|
612
|
+
if (!val.o) objectVal.s.required.push(location);
|
|
613
|
+
objectVal.s.properties[location] = val.s;
|
|
614
|
+
}
|
|
615
|
+
if (flagUnsafeHas(val.f, valFlagAsync)) val.v();
|
|
616
|
+
objectVal.cp = objectVal.cp + B_merge(val);
|
|
617
|
+
objectVal.d[location] = val;
|
|
618
|
+
};
|
|
619
|
+
var B_mergeObjectFields = (target, vals) => {
|
|
620
|
+
for (const location of Object.keys(vals)) B_addObjectField(target, location, vals[location]);
|
|
621
|
+
};
|
|
622
|
+
var B_addKey = (objVal, key, value) => {
|
|
623
|
+
return `${objVal.v()}[${key}]=${value.i}`;
|
|
624
|
+
};
|
|
625
|
+
var B_scope = (val) => {
|
|
626
|
+
const shouldLink = val.v !== _var;
|
|
627
|
+
const nextVal = {
|
|
628
|
+
i: val.i,
|
|
629
|
+
s: val.s,
|
|
630
|
+
e: val.e,
|
|
631
|
+
f: flagNone,
|
|
632
|
+
path: val.path,
|
|
633
|
+
g: val.g,
|
|
634
|
+
v: shouldLink ? _bondVar : _var,
|
|
635
|
+
b: val,
|
|
636
|
+
cp: "",
|
|
637
|
+
hd: "",
|
|
638
|
+
u: false,
|
|
639
|
+
t: false,
|
|
640
|
+
io: val.io,
|
|
641
|
+
d: val.d
|
|
642
|
+
};
|
|
643
|
+
if (shouldLink) B_linkVar(val, nextVal);
|
|
644
|
+
return nextVal;
|
|
645
|
+
};
|
|
646
|
+
var B_embedTransformation = (input, fn, isAsync2) => {
|
|
647
|
+
const outputVar = B_varWithoutAllocation(input.g);
|
|
648
|
+
const output = B_next(input, outputVar, unknown, input.e.to);
|
|
649
|
+
output.v = _var;
|
|
650
|
+
if (isAsync2) {
|
|
651
|
+
if (!flagUnsafeHas(input.g.o, flagAsync)) B_throw({
|
|
652
|
+
code: "invalid_operation",
|
|
653
|
+
path: pathEmpty,
|
|
654
|
+
reason: "Encountered unexpected async transform or refine. Use parseAsyncOrThrow operation instead"
|
|
655
|
+
});
|
|
656
|
+
output.f |= valFlagAsync;
|
|
657
|
+
}
|
|
658
|
+
const embeddedFn = B_embed(input, fn);
|
|
659
|
+
const failure = `${B_failWithArg(output, (e) => B_makeInvalidConversionDetails(input, unknown, e), `x`)}`;
|
|
660
|
+
output.cp = `let ${outputVar};try{${outputVar}=${embeddedFn}(${input.vc ? input.v() : input.i})${isAsync2 ? `.catch(x=>${failure})` : ""}}catch(x){${failure}}`;
|
|
661
|
+
return output;
|
|
662
|
+
};
|
|
663
|
+
var B_effectCtx = (input) => {
|
|
664
|
+
return { fail: (message, path = pathEmpty) => {
|
|
665
|
+
const error = new SuryError(B_invalidInputBuilder(void 0, path, message, false)(input)(void 0));
|
|
666
|
+
error[shouldPrependPathKey] = 1;
|
|
667
|
+
throw error;
|
|
668
|
+
} };
|
|
669
|
+
};
|
|
670
|
+
var B_invalidOperation = (val, description) => {
|
|
671
|
+
return B_throw({
|
|
672
|
+
code: "invalid_operation",
|
|
673
|
+
reason: description,
|
|
674
|
+
path: val.path
|
|
675
|
+
});
|
|
676
|
+
};
|
|
677
|
+
var B_mergeWithCatch = (val, catchFn, appendSafe) => {
|
|
678
|
+
const valCode = B_merge(val);
|
|
679
|
+
if (valCode === "" && !flagUnsafeHas(val.f, valFlagAsync)) return valCode + (appendSafe !== void 0 ? appendSafe() : "");
|
|
680
|
+
else {
|
|
681
|
+
const errorVar = B_varWithoutAllocation(val.g);
|
|
682
|
+
const catchCode = `${catchFn(errorVar)};throw ${errorVar}`;
|
|
683
|
+
if (flagUnsafeHas(val.f, valFlagAsync)) val.i = `${val.i}.catch(${errorVar}=>{${catchCode}})`;
|
|
684
|
+
return `try{${valCode}${appendSafe !== void 0 ? appendSafe() : ""}}catch(${errorVar}){${catchCode}}`;
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
var B_mergeWithPathPrepend = (val, parent, locationVar, appendSafe) => {
|
|
688
|
+
if (val.path === pathEmpty && locationVar === void 0) return B_merge(val);
|
|
689
|
+
else return B_mergeWithCatch(val, (errorVar) => `${errorVar}.path=${parent.path === "" ? "" : `${inlinedValueFromString(parent.path)}+`}${locationVar !== void 0 ? `'["'+${locationVar}+'"]'+` : ""}${errorVar}.path`, appendSafe);
|
|
690
|
+
};
|
|
691
|
+
function noopOperation(i) {
|
|
692
|
+
return i;
|
|
693
|
+
}
|
|
694
|
+
noopOperation["embedded"] = immutableEmptyArray;
|
|
695
|
+
var int32FormatValidation = (inputVar) => {
|
|
696
|
+
return `${inputVar}<=2147483647&&${inputVar}>=-2147483648&&${inputVar}%1===0`;
|
|
697
|
+
};
|
|
698
|
+
var typeofCond = (tag) => (inputVar) => `typeof ${inputVar}==="${tag}"`;
|
|
699
|
+
var nanCond = (inputVar) => `Number.isNaN(${inputVar})`;
|
|
700
|
+
var isArrayCond = (inputVar) => `Array.isArray(${inputVar})`;
|
|
701
|
+
var objectTagCond = (inputVar) => `${typeofCond(objectTag)(inputVar)}&&${inputVar}`;
|
|
702
|
+
var instanceofCond = (b, class_) => (inputVar) => `${inputVar} instanceof ${B_embed(b, class_)}`;
|
|
703
|
+
var B_refineTypeofUnknown = (input, tag) => {
|
|
704
|
+
return B_refine(input, input.e, [{
|
|
705
|
+
c: typeofCond(tag),
|
|
706
|
+
f: failInvalidType
|
|
707
|
+
}]);
|
|
708
|
+
};
|
|
709
|
+
var B_nextVar = (input, expected) => {
|
|
710
|
+
const output = B_next(input, B_varWithoutAllocation(input.g), expected);
|
|
711
|
+
output.v = _var;
|
|
712
|
+
return output;
|
|
713
|
+
};
|
|
714
|
+
var numberDecoder = (input) => {
|
|
715
|
+
const inputTagFlag = tagFlags[input.s.type];
|
|
716
|
+
if (flagUnsafeHas(inputTagFlag, tagFlagUnknown)) {
|
|
717
|
+
const checks = [{
|
|
718
|
+
c: typeofCond(numberTag),
|
|
719
|
+
f: failInvalidType
|
|
720
|
+
}];
|
|
721
|
+
if (input.e.format === "int32") checks.push({
|
|
722
|
+
c: int32FormatValidation,
|
|
723
|
+
f: failInvalidType
|
|
724
|
+
});
|
|
725
|
+
else if (!flagUnsafeHas(input.g.o, flagDisableNanNumberValidation)) checks.push({
|
|
726
|
+
c: (inputVar) => `!${nanCond(inputVar)}`,
|
|
727
|
+
f: failInvalidType
|
|
728
|
+
});
|
|
729
|
+
return B_refine(input, input.e, checks);
|
|
730
|
+
} else if (flagUnsafeHas(inputTagFlag, tagFlagString)) {
|
|
731
|
+
const output = B_nextVar(input, input.e);
|
|
732
|
+
output.cp = `let ${output.i}=+${input.v()};`;
|
|
733
|
+
output.vc = [{
|
|
734
|
+
c: (_inputVar) => input.e.format === "int32" ? int32FormatValidation(output.i) : `!${nanCond(output.i)}`,
|
|
735
|
+
f: failInvalidType
|
|
736
|
+
}];
|
|
737
|
+
return output;
|
|
738
|
+
} else if (!flagUnsafeHas(inputTagFlag, tagFlagNumber)) return B_unsupportedDecode(input, input.s, input.e);
|
|
739
|
+
else if (input.s.format !== input.e.format && input.e.format === "int32") return B_refine(input, input.e, [{
|
|
740
|
+
c: int32FormatValidation,
|
|
741
|
+
f: failInvalidType
|
|
742
|
+
}]);
|
|
743
|
+
else return input;
|
|
744
|
+
};
|
|
745
|
+
var float = () => cached(numberTag, numberTag, (s2) => {
|
|
746
|
+
s2.decoder = numberDecoder;
|
|
747
|
+
});
|
|
748
|
+
var int = () => cached("i", numberTag, (s2) => {
|
|
749
|
+
s2.format = "int32";
|
|
750
|
+
s2.decoder = numberDecoder;
|
|
751
|
+
});
|
|
752
|
+
var inputToString = (input) => {
|
|
753
|
+
return B_next(input, `""+${input.i}`, string());
|
|
754
|
+
};
|
|
755
|
+
var stringDecoderFn = (input) => {
|
|
756
|
+
const inputTagFlag = tagFlags[input.s.type];
|
|
757
|
+
if (flagUnsafeHas(inputTagFlag, tagFlagUnknown)) return B_refineTypeofUnknown(input, stringTag);
|
|
758
|
+
else if (flagUnsafeHas(inputTagFlag, 3132) && isLiteral(input.s)) {
|
|
759
|
+
const const_ = "" + input.s.const;
|
|
760
|
+
const schema = baseSchema(stringTag, false);
|
|
761
|
+
schema.const = const_;
|
|
762
|
+
return B_next(input, `"${const_}"`, schema);
|
|
763
|
+
} else if (flagUnsafeHas(inputTagFlag, 1036)) return inputToString(input);
|
|
764
|
+
else if (!flagUnsafeHas(inputTagFlag, tagFlagString)) return B_unsupportedDecode(input, input.s, input.e);
|
|
765
|
+
else return input;
|
|
766
|
+
};
|
|
767
|
+
var string = () => {
|
|
768
|
+
return cached(stringTag, stringTag, (s2) => {
|
|
769
|
+
s2.decoder = stringDecoderFn;
|
|
770
|
+
});
|
|
771
|
+
};
|
|
772
|
+
var booleanDecoder = (input) => {
|
|
773
|
+
const inputTagFlag = tagFlags[input.s.type];
|
|
774
|
+
if (flagUnsafeHas(inputTagFlag, tagFlagUnknown)) return B_refineTypeofUnknown(input, booleanTag);
|
|
775
|
+
else if (flagUnsafeHas(inputTagFlag, tagFlagString)) {
|
|
776
|
+
const output = B_nextVar(input, input.e);
|
|
777
|
+
const inputVar = input.v();
|
|
778
|
+
output.cp = `let ${output.i};(${output.i}=${inputVar}==="true")||${inputVar}==="false"||${B_embedInvalidInput(input)};`;
|
|
779
|
+
return output;
|
|
780
|
+
} else if (!flagUnsafeHas(inputTagFlag, tagFlagBoolean)) return B_unsupportedDecode(input, input.s, input.e);
|
|
781
|
+
else return input;
|
|
782
|
+
};
|
|
783
|
+
var bool = () => cached(booleanTag, booleanTag, (s2) => {
|
|
784
|
+
s2.decoder = booleanDecoder;
|
|
785
|
+
});
|
|
786
|
+
var bigintDecoder = (input) => {
|
|
787
|
+
const inputTagFlag = tagFlags[input.s.type];
|
|
788
|
+
if (flagUnsafeHas(inputTagFlag, tagFlagUnknown)) return B_refineTypeofUnknown(input, bigintTag);
|
|
789
|
+
else if (flagUnsafeHas(inputTagFlag, tagFlagString)) {
|
|
790
|
+
const output = B_nextVar(input, input.e);
|
|
791
|
+
output.cp = `let ${output.i};try{${output.i}=BigInt(${input.v()})}catch(_){${B_embedInvalidInput(input)}}`;
|
|
792
|
+
return output;
|
|
793
|
+
} else if (flagUnsafeHas(inputTagFlag, tagFlagNumber)) return B_next(input, `BigInt(${input.i})`, input.e);
|
|
794
|
+
else if (!flagUnsafeHas(inputTagFlag, tagFlagBigint)) return B_unsupportedDecode(input, input.s, input.e);
|
|
795
|
+
else return input;
|
|
796
|
+
};
|
|
797
|
+
var bigint = () => cached(bigintTag, bigintTag, (s2) => {
|
|
798
|
+
s2.decoder = bigintDecoder;
|
|
799
|
+
});
|
|
800
|
+
var symbolDecoder = (input) => {
|
|
801
|
+
const inputTagFlag = tagFlags[input.s.type];
|
|
802
|
+
if (flagUnsafeHas(inputTagFlag, tagFlagUnknown)) return B_refineTypeofUnknown(input, symbolTag);
|
|
803
|
+
else if (!flagUnsafeHas(inputTagFlag, tagFlagSymbol)) return B_unsupportedDecode(input, input.s, input.e);
|
|
804
|
+
else return input;
|
|
805
|
+
};
|
|
806
|
+
var symbol = () => cached(symbolTag, symbolTag, (s2) => {
|
|
807
|
+
s2.decoder = symbolDecoder;
|
|
808
|
+
});
|
|
809
|
+
var setHas = (has, tag) => {
|
|
810
|
+
has[flagUnsafeHas(tagFlags[tag], 768) ? unknownTag : tag] = true;
|
|
811
|
+
};
|
|
812
|
+
var jsonName = `JSON`;
|
|
813
|
+
var literalDecoder = (input) => {
|
|
814
|
+
const expectedSchema = input.e;
|
|
815
|
+
if (expectedSchema.noValidation && !input.u) return B_nextConst(input, expectedSchema);
|
|
816
|
+
else if (isLiteral(input.s)) if (input.s.const === expectedSchema.const) return input;
|
|
817
|
+
else return B_nextConst(input, expectedSchema);
|
|
818
|
+
else {
|
|
819
|
+
const schemaTagFlag = tagFlags[expectedSchema.type];
|
|
820
|
+
if (flagUnsafeHas(tagFlags[input.s.type], tagFlagString) && flagUnsafeHas(schemaTagFlag, 3132)) {
|
|
821
|
+
const stringConstSchema = baseSchema(stringTag, false);
|
|
822
|
+
stringConstSchema.const = "" + expectedSchema.const;
|
|
823
|
+
const stringConstVal = B_nextConst(input, stringConstSchema, stringConstSchema);
|
|
824
|
+
stringConstVal.vc = [{
|
|
825
|
+
c: (inputVar) => `${inputVar}==="${stringConstSchema.const}"`,
|
|
826
|
+
f: failInvalidType
|
|
827
|
+
}];
|
|
828
|
+
return B_nextConst(stringConstVal, expectedSchema, expectedSchema);
|
|
829
|
+
} else if (flagUnsafeHas(schemaTagFlag, tagFlagNaN)) return B_refine(input, expectedSchema, [{
|
|
830
|
+
c: nanCond,
|
|
831
|
+
f: failInvalidType
|
|
832
|
+
}]);
|
|
833
|
+
else return B_refine(input, expectedSchema, [{
|
|
834
|
+
c: (inputVar) => `${inputVar}===${B_inlineConst(input, expectedSchema)}`,
|
|
835
|
+
f: failInvalidType
|
|
836
|
+
}]);
|
|
837
|
+
}
|
|
838
|
+
};
|
|
839
|
+
var unit = () => cached(undefinedTag, undefinedTag, (s2) => {
|
|
840
|
+
s2.const = void 0;
|
|
841
|
+
s2.decoder = literalDecoder;
|
|
842
|
+
});
|
|
843
|
+
var void_ = () => cached("void", undefinedTag, (s2) => {
|
|
844
|
+
s2.const = void 0;
|
|
845
|
+
s2.name = "void";
|
|
846
|
+
s2.decoder = literalDecoder;
|
|
847
|
+
});
|
|
848
|
+
var nullLiteral = () => cached(nullTag, nullTag, (s2) => {
|
|
849
|
+
s2.const = null;
|
|
850
|
+
s2.decoder = literalDecoder;
|
|
851
|
+
});
|
|
852
|
+
var nan = () => cached(nanTag, nanTag, (s2) => {
|
|
853
|
+
s2.const = NaN;
|
|
854
|
+
s2.decoder = literalDecoder;
|
|
855
|
+
});
|
|
856
|
+
var Literal_parse = (value) => {
|
|
857
|
+
if (value === null) return nullLiteral();
|
|
858
|
+
else {
|
|
859
|
+
const tag = typeof value;
|
|
860
|
+
if (tag === undefinedTag) return unit();
|
|
861
|
+
else if (tag === numberTag && Number.isNaN(value)) return nan();
|
|
862
|
+
else if (tag === objectTag) {
|
|
863
|
+
const s2 = baseSchema(instanceTag, true);
|
|
864
|
+
s2.class = value["constructor"];
|
|
865
|
+
s2.const = value;
|
|
866
|
+
s2.decoder = literalDecoder;
|
|
867
|
+
return s2;
|
|
868
|
+
} else {
|
|
869
|
+
const s2 = baseSchema(tag, true);
|
|
870
|
+
s2.const = value;
|
|
871
|
+
s2.decoder = literalDecoder;
|
|
872
|
+
return s2;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
};
|
|
876
|
+
var parse = (input) => {
|
|
877
|
+
let result = input;
|
|
878
|
+
let appliedEncoderRef = void 0;
|
|
879
|
+
let loopCount = 0;
|
|
880
|
+
while (!result.io || result.e.to) {
|
|
881
|
+
const appliedEncoder = appliedEncoderRef;
|
|
882
|
+
appliedEncoderRef = void 0;
|
|
883
|
+
const loopInput = result;
|
|
884
|
+
loopCount = loopCount + 1;
|
|
885
|
+
if (loopCount > 50) throw /* @__PURE__ */ new Error("Loop count exceeded 50");
|
|
886
|
+
if (loopInput.e["$defs"]) if (loopInput.g.d) Object.assign(loopInput.g.d, loopInput.e["$defs"]);
|
|
887
|
+
else loopInput.g.d = loopInput.e["$defs"];
|
|
888
|
+
if (flagUnsafeHas(loopInput.f, valFlagAsync)) {
|
|
889
|
+
const operationInputVar = loopInput.v();
|
|
890
|
+
const operationInput = B_scope(loopInput);
|
|
891
|
+
const operationOutput = parse(operationInput);
|
|
892
|
+
const operationCode = B_merge(operationOutput);
|
|
893
|
+
if (operationInput.i !== operationOutput.i || operationCode !== "") result = B_next(loopInput, `${operationInputVar}.then(${operationInputVar}=>{${operationCode}return ${operationOutput.i}})`, operationOutput.s, operationOutput.e);
|
|
894
|
+
else result = B_refine(loopInput, operationOutput.s, void 0, operationOutput.e);
|
|
895
|
+
result.f |= valFlagAsync;
|
|
896
|
+
result.io = true;
|
|
897
|
+
} else if (loopInput.io) {
|
|
898
|
+
const to = loopInput.e.to;
|
|
899
|
+
if (loopInput.e.parser !== void 0) result = loopInput.e.parser(loopInput);
|
|
900
|
+
else result = B_refine(result, void 0, void 0, to);
|
|
901
|
+
} else {
|
|
902
|
+
const maybeEncoder = loopInput.s.encoder;
|
|
903
|
+
if (maybeEncoder && maybeEncoder !== appliedEncoder && loopInput.s !== loopInput.e && loopInput.e.type !== unknownTag) result = maybeEncoder(loopInput, loopInput.e);
|
|
904
|
+
if (loopInput !== result) appliedEncoderRef = maybeEncoder;
|
|
905
|
+
else {
|
|
906
|
+
result = loopInput.e.decoder(loopInput);
|
|
907
|
+
if (!result.io) result = B_markOutput(result, result);
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
return result;
|
|
912
|
+
};
|
|
913
|
+
var parseDynamic = (input) => {
|
|
914
|
+
try {
|
|
915
|
+
return parse(input);
|
|
916
|
+
} catch (exn) {
|
|
917
|
+
const error = getOrRethrow(exn);
|
|
918
|
+
error.path = pathConcat(input.p !== void 0 ? input.p.path : pathEmpty, pathConcat(pathConcat(input.path, pathDynamic), error.path));
|
|
919
|
+
throw error;
|
|
920
|
+
}
|
|
921
|
+
};
|
|
922
|
+
var isAsyncInternal = (schema, defs) => {
|
|
923
|
+
try {
|
|
924
|
+
const isAsync2 = flagUnsafeHas(parse(B_operationArg(unknown, schema, flagAsync, defs)).f, valFlagAsync);
|
|
925
|
+
schema.isAsync = isAsync2;
|
|
926
|
+
return isAsync2;
|
|
927
|
+
} catch (exn) {
|
|
928
|
+
getOrRethrow(exn);
|
|
929
|
+
return false;
|
|
930
|
+
}
|
|
931
|
+
};
|
|
932
|
+
var compileDecoder = (schema, expected, flag, defs) => {
|
|
933
|
+
const input = B_operationArg(isLiteral(schema) ? unknown : schema, expected, flag, defs);
|
|
934
|
+
const output = parse(input);
|
|
935
|
+
const code = B_merge(output);
|
|
936
|
+
const isAsync2 = flagUnsafeHas(output.f, valFlagAsync);
|
|
937
|
+
expected.isAsync = isAsync2;
|
|
938
|
+
expected.hasTransform = output.t === true;
|
|
939
|
+
if (code === "" && (output === input || output.i === input.i) && !flagUnsafeHas(flag, flagAsync)) return noopOperation;
|
|
940
|
+
else {
|
|
941
|
+
let inlinedOutput = output.i;
|
|
942
|
+
if (flagUnsafeHas(flag, flagAsync) && !isAsync2 && !defs) inlinedOutput = `Promise.resolve(${inlinedOutput})`;
|
|
943
|
+
const inlinedFunction = `${operationArgVar}=>{${code}return ${inlinedOutput}}`;
|
|
944
|
+
const fn = new Function("e", "s", `return ${inlinedFunction}`)(input.g.e, s);
|
|
945
|
+
fn.embedded = input.g.e;
|
|
946
|
+
return fn;
|
|
947
|
+
}
|
|
948
|
+
};
|
|
949
|
+
var getOutputSchema = (schema) => {
|
|
950
|
+
if (schema.to !== void 0) return getOutputSchema(schema.to);
|
|
951
|
+
else return schema;
|
|
952
|
+
};
|
|
953
|
+
var reverse = (schema) => {
|
|
954
|
+
const schemaRecord = schema;
|
|
955
|
+
if (reversedKey in schemaRecord) return schemaRecord[reversedKey];
|
|
956
|
+
else {
|
|
957
|
+
let reversedHead = void 0;
|
|
958
|
+
let current = schema;
|
|
959
|
+
while (current) {
|
|
960
|
+
const mut = copySchema(current);
|
|
961
|
+
const next = mut.to;
|
|
962
|
+
if (reversedHead === void 0) delete mut.to;
|
|
963
|
+
else mut.to = reversedHead;
|
|
964
|
+
const parser = mut.parser;
|
|
965
|
+
if (mut.serializer !== void 0) mut.parser = mut.serializer;
|
|
966
|
+
else delete mut.parser;
|
|
967
|
+
if (parser !== void 0) mut.serializer = parser;
|
|
968
|
+
else delete mut.serializer;
|
|
969
|
+
const refiner = mut.refiner;
|
|
970
|
+
if (mut.inputRefiner !== void 0) mut.refiner = mut.inputRefiner;
|
|
971
|
+
else delete mut.refiner;
|
|
972
|
+
if (refiner !== void 0) mut.inputRefiner = refiner;
|
|
973
|
+
else delete mut.inputRefiner;
|
|
974
|
+
const fromDefault = mut.fromDefault;
|
|
975
|
+
if (mut.default !== void 0) mut.fromDefault = mut.default;
|
|
976
|
+
else delete mut.fromDefault;
|
|
977
|
+
if (fromDefault !== void 0) mut.default = fromDefault;
|
|
978
|
+
else delete mut.default;
|
|
979
|
+
if (mut.items !== void 0) mut.items = mut.items.map(reverse);
|
|
980
|
+
if (mut.properties !== void 0) {
|
|
981
|
+
const properties = mut.properties;
|
|
982
|
+
const newProperties = {};
|
|
983
|
+
const keys = Object.keys(properties);
|
|
984
|
+
for (let idx = 0; idx <= keys.length - 1; idx++) {
|
|
985
|
+
const key = keys[idx];
|
|
986
|
+
newProperties[key] = reverse(properties[key]);
|
|
987
|
+
}
|
|
988
|
+
mut.properties = newProperties;
|
|
989
|
+
}
|
|
990
|
+
if (typeof mut.additionalItems === objectTag) mut.additionalItems = reverse(mut.additionalItems);
|
|
991
|
+
if (mut.anyOf !== void 0) {
|
|
992
|
+
const anyOf = mut.anyOf;
|
|
993
|
+
const has = {};
|
|
994
|
+
const newAnyOf = [];
|
|
995
|
+
for (let idx = 0; idx <= anyOf.length - 1; idx++) {
|
|
996
|
+
const s2 = anyOf[idx];
|
|
997
|
+
const reversed = reverse(s2);
|
|
998
|
+
newAnyOf.push(reversed);
|
|
999
|
+
setHas(has, reversed.type);
|
|
1000
|
+
}
|
|
1001
|
+
mut.has = has;
|
|
1002
|
+
mut.anyOf = newAnyOf;
|
|
1003
|
+
}
|
|
1004
|
+
if (mut["$defs"] !== void 0) {
|
|
1005
|
+
const defs = mut["$defs"];
|
|
1006
|
+
const reversedDefs = {};
|
|
1007
|
+
const defsKeys = Object.keys(defs);
|
|
1008
|
+
for (let idx = 0; idx <= defsKeys.length - 1; idx++) {
|
|
1009
|
+
const key = defsKeys[idx];
|
|
1010
|
+
reversedDefs[key] = reverse(defs[key]);
|
|
1011
|
+
}
|
|
1012
|
+
mut["$defs"] = reversedDefs;
|
|
1013
|
+
}
|
|
1014
|
+
reversedHead = mut;
|
|
1015
|
+
current = next;
|
|
1016
|
+
}
|
|
1017
|
+
const r = reversedHead;
|
|
1018
|
+
valueOptions[valKey] = r;
|
|
1019
|
+
Object.defineProperty(schema, reversedKey, valueOptions);
|
|
1020
|
+
valueOptions[valKey] = schema;
|
|
1021
|
+
Object.defineProperty(r, reversedKey, valueOptions);
|
|
1022
|
+
return r;
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
function getDecoder(..._args) {
|
|
1026
|
+
const args = arguments;
|
|
1027
|
+
let idx = 0;
|
|
1028
|
+
let flag = void 0;
|
|
1029
|
+
let keyRef = "";
|
|
1030
|
+
let maxSeq = 0;
|
|
1031
|
+
let cacheTarget = void 0;
|
|
1032
|
+
while (flag === void 0) {
|
|
1033
|
+
const arg = args[idx];
|
|
1034
|
+
if (!arg) {
|
|
1035
|
+
const f = globalConfig.f;
|
|
1036
|
+
flag = f;
|
|
1037
|
+
keyRef = keyRef + "-" + f;
|
|
1038
|
+
} else if (typeof arg === numberTag) {
|
|
1039
|
+
const f = arg | globalConfig.f;
|
|
1040
|
+
flag = f;
|
|
1041
|
+
keyRef = keyRef + "-" + f;
|
|
1042
|
+
} else {
|
|
1043
|
+
const schema = arg;
|
|
1044
|
+
const seq2 = schema.seq;
|
|
1045
|
+
if (seq2 > maxSeq) {
|
|
1046
|
+
maxSeq = seq2;
|
|
1047
|
+
cacheTarget = schema;
|
|
1048
|
+
}
|
|
1049
|
+
keyRef = keyRef + seq2 + "-";
|
|
1050
|
+
idx = idx + 1;
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
if (cacheTarget === void 0) return panic("No schema provided for decoder.");
|
|
1054
|
+
else {
|
|
1055
|
+
const key = keyRef;
|
|
1056
|
+
const cacheTargetRecord = cacheTarget;
|
|
1057
|
+
if (key in cacheTargetRecord) return cacheTargetRecord[key];
|
|
1058
|
+
else {
|
|
1059
|
+
let schema = args[idx - 1];
|
|
1060
|
+
for (let i = idx - 2; i >= 0; i--) {
|
|
1061
|
+
const to = schema;
|
|
1062
|
+
schema = updateOutput(args[i], (mut) => {
|
|
1063
|
+
mut.to = to;
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
const f = compileDecoder(schema, schema, flag, void 0);
|
|
1067
|
+
valueOptions[valKey] = f;
|
|
1068
|
+
Object.defineProperty(cacheTarget, key, valueOptions);
|
|
1069
|
+
return f;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
var nestedLoc = "BS_PRIVATE_NESTED_SOME_NONE";
|
|
1074
|
+
var neverBuilderFn = (input) => {
|
|
1075
|
+
const output = B_refine(input, void 0, void 0, never_());
|
|
1076
|
+
output.cp = B_embedInvalidInput(input) + ";";
|
|
1077
|
+
return output;
|
|
1078
|
+
};
|
|
1079
|
+
var never_ = () => {
|
|
1080
|
+
return cached(neverTag, neverTag, (s2) => {
|
|
1081
|
+
s2.decoder = neverBuilderFn;
|
|
1082
|
+
});
|
|
1083
|
+
};
|
|
1084
|
+
var nestedOptionParser = (input) => {
|
|
1085
|
+
const nextSchema = input.e.to;
|
|
1086
|
+
return B_next(input, `{${nestedLoc}:${getOutputSchema(input.e).properties[nestedLoc].const}}`, nextSchema, nextSchema);
|
|
1087
|
+
};
|
|
1088
|
+
var instanceDecoder = (input) => {
|
|
1089
|
+
const inputTagFlag = tagFlags[input.s.type];
|
|
1090
|
+
if (flagUnsafeHas(inputTagFlag, tagFlagUnknown)) return B_refine(input, input.e, [{
|
|
1091
|
+
c: instanceofCond(input, input.e.class),
|
|
1092
|
+
f: failInvalidType
|
|
1093
|
+
}]);
|
|
1094
|
+
else if (flagUnsafeHas(inputTagFlag, tagFlagInstance) && input.s.class === input.e.class) return input;
|
|
1095
|
+
else return B_unsupportedDecode(input, input.s, input.e);
|
|
1096
|
+
};
|
|
1097
|
+
var instance = (class_) => {
|
|
1098
|
+
const mut = baseSchema(instanceTag, true);
|
|
1099
|
+
mut.class = class_;
|
|
1100
|
+
mut.decoder = instanceDecoder;
|
|
1101
|
+
return mut;
|
|
1102
|
+
};
|
|
1103
|
+
var typeCheckCond = (input, schema, inputVar) => {
|
|
1104
|
+
const tagFlag = tagFlags[schema.type];
|
|
1105
|
+
if (flagUnsafeHas(tagFlag, tagFlagObject)) return `${objectTagCond(inputVar)}&&!${isArrayCond(inputVar)}`;
|
|
1106
|
+
else if (flagUnsafeHas(tagFlag, tagFlagArray)) return isArrayCond(inputVar);
|
|
1107
|
+
else if (flagUnsafeHas(tagFlag, tagFlagInstance)) return instanceofCond(input, schema.class)(inputVar);
|
|
1108
|
+
else if (flagUnsafeHas(tagFlag, tagFlagNumber)) {
|
|
1109
|
+
const typeofCheck = typeofCond(numberTag)(inputVar);
|
|
1110
|
+
if (flagUnsafeHas(input.g.o, flagDisableNanNumberValidation)) return typeofCheck;
|
|
1111
|
+
else return `${typeofCheck}&&!${nanCond(inputVar)}`;
|
|
1112
|
+
} else if (flagUnsafeHas(tagFlag, tagFlagNaN)) return nanCond(inputVar);
|
|
1113
|
+
else if (flagUnsafeHas(tagFlag, 48)) return `${inputVar}===${B_inlineConst(input, schema)}`;
|
|
1114
|
+
else if (flagUnsafeHas(tagFlag, 17418)) return typeofCond(schema.type)(inputVar);
|
|
1115
|
+
else return "";
|
|
1116
|
+
};
|
|
1117
|
+
var isItemSchema = (x) => x !== void 0 && typeof x !== "string";
|
|
1118
|
+
var makeObjectVal = (prev, schema) => {
|
|
1119
|
+
return {
|
|
1120
|
+
prev,
|
|
1121
|
+
v: _notVar,
|
|
1122
|
+
i: "",
|
|
1123
|
+
f: valFlagNone,
|
|
1124
|
+
s: schema.type === arrayTag ? {
|
|
1125
|
+
type: arrayTag,
|
|
1126
|
+
items: [],
|
|
1127
|
+
additionalItems: "strict",
|
|
1128
|
+
decoder: arrayDecoder
|
|
1129
|
+
} : {
|
|
1130
|
+
type: objectTag,
|
|
1131
|
+
required: [],
|
|
1132
|
+
properties: /* @__PURE__ */ Object.create(null),
|
|
1133
|
+
additionalItems: "strict",
|
|
1134
|
+
decoder: objectDecoder
|
|
1135
|
+
},
|
|
1136
|
+
e: prev.e,
|
|
1137
|
+
d: /* @__PURE__ */ Object.create(null),
|
|
1138
|
+
t: true,
|
|
1139
|
+
cp: "",
|
|
1140
|
+
hd: "",
|
|
1141
|
+
path: prev.path,
|
|
1142
|
+
g: prev.g
|
|
1143
|
+
};
|
|
1144
|
+
};
|
|
1145
|
+
var completeObjectVal = (objectVal) => {
|
|
1146
|
+
const isArray = objectVal.s.type === arrayTag;
|
|
1147
|
+
let inline = "";
|
|
1148
|
+
let promiseAllContent = "";
|
|
1149
|
+
let optionalSettingCode = void 0;
|
|
1150
|
+
const keys = Object.keys(objectVal.d);
|
|
1151
|
+
for (let idx = 0; idx < keys.length; idx++) {
|
|
1152
|
+
const key = keys[idx];
|
|
1153
|
+
const val = objectVal.d[key];
|
|
1154
|
+
if (flagUnsafeHas(val.f, valFlagAsync)) promiseAllContent = promiseAllContent + val.i + ",";
|
|
1155
|
+
if (val.o) {
|
|
1156
|
+
const existingFn = optionalSettingCode;
|
|
1157
|
+
optionalSettingCode = (objectVar) => {
|
|
1158
|
+
return (existingFn === void 0 ? "" : existingFn(objectVar)) + `if(${val.v()}!==void 0){${objectVar}[${B_inlineLocation(objectVal.g, key)}]=${val.i}}`;
|
|
1159
|
+
};
|
|
1160
|
+
} else inline = inline + (isArray ? `${val.i}` : `${B_inlineLocation(objectVal.g, key)}:${val.i}`) + ",";
|
|
1161
|
+
}
|
|
1162
|
+
objectVal.i = isArray ? "[" + inline + "]" : "{" + inline + "}";
|
|
1163
|
+
const valWithRequired = objectVal;
|
|
1164
|
+
if (promiseAllContent) {
|
|
1165
|
+
const operationInput = B_scope(valWithRequired);
|
|
1166
|
+
operationInput.io = true;
|
|
1167
|
+
const operationOutput = parse(operationInput);
|
|
1168
|
+
const operationCode = B_merge(operationOutput);
|
|
1169
|
+
if (operationCode === "" && promiseAllContent === `${operationOutput.i},`) valWithRequired.i = operationOutput.i;
|
|
1170
|
+
else valWithRequired.i = `Promise.all([${promiseAllContent}]).then(([${promiseAllContent}])=>{${operationCode}return ${operationOutput.i}})`;
|
|
1171
|
+
valWithRequired.f |= valFlagAsync;
|
|
1172
|
+
valWithRequired.s = operationOutput.s;
|
|
1173
|
+
valWithRequired.e = operationOutput.e;
|
|
1174
|
+
valWithRequired.io = true;
|
|
1175
|
+
return valWithRequired;
|
|
1176
|
+
} else if (optionalSettingCode === void 0) return valWithRequired;
|
|
1177
|
+
else {
|
|
1178
|
+
const code = optionalSettingCode(valWithRequired.v());
|
|
1179
|
+
const output = B_refine(valWithRequired);
|
|
1180
|
+
output.cp = output.cp + code;
|
|
1181
|
+
return output;
|
|
1182
|
+
}
|
|
1183
|
+
};
|
|
1184
|
+
var array = (item) => {
|
|
1185
|
+
const itemInternal = item;
|
|
1186
|
+
const mut = baseSchema(arrayTag, itemInternal.r === itemInternal);
|
|
1187
|
+
mut.additionalItems = itemInternal;
|
|
1188
|
+
mut.items = immutableEmptyArray;
|
|
1189
|
+
mut.decoder = arrayDecoder;
|
|
1190
|
+
return mut;
|
|
1191
|
+
};
|
|
1192
|
+
var arrayDecoder = (unknownInput) => {
|
|
1193
|
+
const isUnion = unknownInput.u;
|
|
1194
|
+
const expectedSchema = unknownInput.e;
|
|
1195
|
+
const unknownInputTagFlag = tagFlags[unknownInput.s.type];
|
|
1196
|
+
const expectedItems = expectedSchema.items;
|
|
1197
|
+
const expectedLength = expectedItems.length;
|
|
1198
|
+
let input;
|
|
1199
|
+
if (flagUnsafeHas(unknownInputTagFlag, 129)) {
|
|
1200
|
+
const isArrayInput = flagUnsafeHas(unknownInputTagFlag, tagFlagArray);
|
|
1201
|
+
let schema;
|
|
1202
|
+
if (!isArrayInput) schema = array(unknown);
|
|
1203
|
+
else schema = unknownInput.s;
|
|
1204
|
+
const checks = [];
|
|
1205
|
+
if (!isArrayInput) checks.push({
|
|
1206
|
+
c: isArrayCond,
|
|
1207
|
+
f: failInvalidType
|
|
1208
|
+
});
|
|
1209
|
+
const schemaAdditionalItems = schema.additionalItems;
|
|
1210
|
+
if (!(isItemSchema(schemaAdditionalItems) ? false : schema.items.length === expectedLength)) {
|
|
1211
|
+
const expectedAdditionalItems2 = expectedSchema.additionalItems;
|
|
1212
|
+
if (expectedAdditionalItems2 === "strict") checks.push({
|
|
1213
|
+
c: (inputVar) => `${inputVar}.length===${expectedLength}`,
|
|
1214
|
+
f: failInvalidType
|
|
1215
|
+
});
|
|
1216
|
+
else if (expectedAdditionalItems2 === "strip") checks.push({
|
|
1217
|
+
c: (inputVar) => `${inputVar}.length>=${expectedLength}`,
|
|
1218
|
+
f: failInvalidType
|
|
1219
|
+
});
|
|
1220
|
+
}
|
|
1221
|
+
if (checks.length > 0) input = B_refine(unknownInput, schema, checks);
|
|
1222
|
+
else input = B_refine(unknownInput, schema);
|
|
1223
|
+
} else input = B_unsupportedDecode(unknownInput, unknownInput.s, expectedSchema);
|
|
1224
|
+
let output;
|
|
1225
|
+
const expectedAdditionalItems = expectedSchema.additionalItems;
|
|
1226
|
+
if (isItemSchema(expectedAdditionalItems)) if (expectedAdditionalItems === unknown) output = input;
|
|
1227
|
+
else {
|
|
1228
|
+
const inputVar = input.v();
|
|
1229
|
+
const iteratorVar = B_varWithoutAllocation(input.g);
|
|
1230
|
+
const itemOutput = parseDynamic(B_dynamicScope(input, iteratorVar));
|
|
1231
|
+
const hasTransform = itemOutput.t;
|
|
1232
|
+
const output2 = hasTransform ? B_next(input, `new Array(${inputVar}.length)`, array(itemOutput.s)) : B_refine(input, expectedSchema);
|
|
1233
|
+
const itemCode = B_mergeWithPathPrepend(itemOutput, input, iteratorVar, hasTransform ? () => B_addKey(output2, iteratorVar, itemOutput) : void 0);
|
|
1234
|
+
if (hasTransform || itemCode !== "") output2.cp = output2.cp + `for(let ${iteratorVar}=${expectedLength};${iteratorVar}<${inputVar}.length;++${iteratorVar}){${itemCode}}`;
|
|
1235
|
+
if (flagUnsafeHas(itemOutput.f, valFlagAsync)) output = B_asyncVal(output2, `Promise.all(${output2.i})`);
|
|
1236
|
+
else output = output2;
|
|
1237
|
+
}
|
|
1238
|
+
else {
|
|
1239
|
+
const objectVal = makeObjectVal(input, expectedSchema);
|
|
1240
|
+
let shouldRecreateInput;
|
|
1241
|
+
{
|
|
1242
|
+
const ai = expectedSchema.additionalItems;
|
|
1243
|
+
if (ai === "strict") shouldRecreateInput = false;
|
|
1244
|
+
else if (ai === "strip") {
|
|
1245
|
+
const inputAi = input.s.additionalItems;
|
|
1246
|
+
shouldRecreateInput = isItemSchema(inputAi) ? true : input.s.items.length !== expectedLength;
|
|
1247
|
+
} else shouldRecreateInput = true;
|
|
1248
|
+
}
|
|
1249
|
+
for (let idx = 0; idx < expectedLength; idx++) {
|
|
1250
|
+
const schema = expectedItems[idx];
|
|
1251
|
+
const key = String(idx);
|
|
1252
|
+
const itemInput = valGet(input, key);
|
|
1253
|
+
itemInput.e = schema;
|
|
1254
|
+
itemInput.io = false;
|
|
1255
|
+
itemInput.u = isUnion;
|
|
1256
|
+
const itemOutput = parse(itemInput);
|
|
1257
|
+
if (isUnion && isLiteral(schema)) B_hoistChildChecks(input, itemOutput, key);
|
|
1258
|
+
B_addObjectField(objectVal, key, itemOutput);
|
|
1259
|
+
if (!shouldRecreateInput) shouldRecreateInput = itemOutput.t;
|
|
1260
|
+
}
|
|
1261
|
+
if (shouldRecreateInput) output = completeObjectVal(objectVal);
|
|
1262
|
+
else {
|
|
1263
|
+
const o = B_refine(input, expectedSchema);
|
|
1264
|
+
o.cp = objectVal.cp;
|
|
1265
|
+
o.d = objectVal.d;
|
|
1266
|
+
output = o;
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
return B_markOutput(output, input);
|
|
1270
|
+
};
|
|
1271
|
+
var objectDecoder = (unknownInput) => {
|
|
1272
|
+
const isUnion = unknownInput.u;
|
|
1273
|
+
const expectedSchema = unknownInput.e;
|
|
1274
|
+
const unknownInputTagFlag = tagFlags[unknownInput.s.type];
|
|
1275
|
+
let input;
|
|
1276
|
+
if (flagUnsafeHas(unknownInputTagFlag, 65)) {
|
|
1277
|
+
const isObjectInput = flagUnsafeHas(unknownInputTagFlag, tagFlagObject);
|
|
1278
|
+
let schema;
|
|
1279
|
+
if (!isObjectInput) {
|
|
1280
|
+
const mut = baseSchema(objectTag, false);
|
|
1281
|
+
mut.properties = immutableEmptyObject;
|
|
1282
|
+
mut.additionalItems = unknown;
|
|
1283
|
+
schema = mut;
|
|
1284
|
+
} else schema = unknownInput.s;
|
|
1285
|
+
const checks = [];
|
|
1286
|
+
if (!isObjectInput) {
|
|
1287
|
+
checks.push({
|
|
1288
|
+
c: objectTagCond,
|
|
1289
|
+
f: failInvalidType
|
|
1290
|
+
});
|
|
1291
|
+
if (expectedSchema.additionalItems !== "strip") checks.push({
|
|
1292
|
+
c: (inputVar) => `!${isArrayCond(inputVar)}`,
|
|
1293
|
+
f: failInvalidType
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
if (checks.length > 0) input = B_refine(unknownInput, schema, checks);
|
|
1297
|
+
else input = B_refine(unknownInput, schema);
|
|
1298
|
+
} else input = B_unsupportedDecode(unknownInput, unknownInput.s, expectedSchema);
|
|
1299
|
+
const expectedAdditionalItems = expectedSchema.additionalItems;
|
|
1300
|
+
const dictItem = isItemSchema(expectedAdditionalItems) ? expectedAdditionalItems : void 0;
|
|
1301
|
+
const inputAdditionalItems = input.s.additionalItems;
|
|
1302
|
+
const sourceIsDict = isItemSchema(inputAdditionalItems);
|
|
1303
|
+
let output;
|
|
1304
|
+
if (dictItem !== void 0 && dictItem === unknown) output = input;
|
|
1305
|
+
else if (dictItem !== void 0 && sourceIsDict) {
|
|
1306
|
+
const inputVar = input.v();
|
|
1307
|
+
const keyVar = B_varWithoutAllocation(input.g);
|
|
1308
|
+
const itemOutput = parseDynamic(B_dynamicScope(input, keyVar));
|
|
1309
|
+
const hasTransform = itemOutput.t;
|
|
1310
|
+
const output2 = hasTransform ? B_next(input, "{}", dictFactory(itemOutput.s)) : B_refine(input, expectedSchema);
|
|
1311
|
+
const itemCode = B_mergeWithPathPrepend(itemOutput, input, keyVar, hasTransform ? () => B_addKey(output2, keyVar, itemOutput) : void 0);
|
|
1312
|
+
if (hasTransform || itemCode !== "") output2.cp = output2.cp + `for(let ${keyVar} in ${inputVar}){${itemCode}}`;
|
|
1313
|
+
if (flagUnsafeHas(itemOutput.f, valFlagAsync)) {
|
|
1314
|
+
const resolveVar = B_varWithoutAllocation(output2.g);
|
|
1315
|
+
const rejectVar = B_varWithoutAllocation(output2.g);
|
|
1316
|
+
const asyncParseResultVar = B_varWithoutAllocation(output2.g);
|
|
1317
|
+
const counterVar = B_varWithoutAllocation(output2.g);
|
|
1318
|
+
const outputVar = output2.v();
|
|
1319
|
+
output = B_asyncVal(output2, `new Promise((${resolveVar},${rejectVar})=>{let ${counterVar}=Object.keys(${outputVar}).length;for(let ${keyVar} in ${outputVar}){${outputVar}[${keyVar}].then(${asyncParseResultVar}=>{${outputVar}[${keyVar}]=${asyncParseResultVar};if(${counterVar}--===1){${resolveVar}(${outputVar})}},${rejectVar})}})`);
|
|
1320
|
+
} else output = output2;
|
|
1321
|
+
} else if (dictItem !== void 0) {
|
|
1322
|
+
const itemSchema = dictItem;
|
|
1323
|
+
const objectVal = makeObjectVal(input, expectedSchema);
|
|
1324
|
+
const keys = Object.keys(input.s.properties);
|
|
1325
|
+
for (let idx = 0; idx < keys.length; idx++) {
|
|
1326
|
+
const key = keys[idx];
|
|
1327
|
+
const itemInput = valGet(input, key);
|
|
1328
|
+
itemInput.e = itemSchema;
|
|
1329
|
+
itemInput.io = false;
|
|
1330
|
+
itemInput.u = isUnion;
|
|
1331
|
+
B_addObjectField(objectVal, key, parse(itemInput));
|
|
1332
|
+
}
|
|
1333
|
+
output = completeObjectVal(objectVal);
|
|
1334
|
+
} else {
|
|
1335
|
+
const properties = expectedSchema.properties;
|
|
1336
|
+
const keys = Object.keys(properties);
|
|
1337
|
+
const keysCount = keys.length;
|
|
1338
|
+
const objectVal = makeObjectVal(input, expectedSchema);
|
|
1339
|
+
let shouldRecreateInput;
|
|
1340
|
+
{
|
|
1341
|
+
const ai = expectedSchema.additionalItems;
|
|
1342
|
+
if (ai === "strict") shouldRecreateInput = false;
|
|
1343
|
+
else if (ai === "strip") shouldRecreateInput = sourceIsDict || Object.keys(input.s.properties).length !== keysCount;
|
|
1344
|
+
else shouldRecreateInput = true;
|
|
1345
|
+
}
|
|
1346
|
+
const isJsonParent = isItemSchema(inputAdditionalItems) ? inputAdditionalItems.name === jsonName : false;
|
|
1347
|
+
for (let idx = 0; idx < keysCount; idx++) {
|
|
1348
|
+
const key = keys[idx];
|
|
1349
|
+
const schema = properties[key];
|
|
1350
|
+
const itemInput = valGet(input, key);
|
|
1351
|
+
itemInput.e = schema;
|
|
1352
|
+
itemInput.io = false;
|
|
1353
|
+
itemInput.u = isUnion;
|
|
1354
|
+
if (isJsonParent && schema.type === unionTag && schema.has[undefinedTag]) itemInput.i = `(${itemInput.i}??null)`;
|
|
1355
|
+
const itemOutput = parse(itemInput);
|
|
1356
|
+
if (isUnion && isLiteral(schema)) B_hoistChildChecks(input, itemOutput, key);
|
|
1357
|
+
B_addObjectField(objectVal, key, itemOutput);
|
|
1358
|
+
if (!shouldRecreateInput) shouldRecreateInput = itemOutput.t;
|
|
1359
|
+
}
|
|
1360
|
+
if (expectedSchema.additionalItems === "strict" && isItemSchema(inputAdditionalItems)) {
|
|
1361
|
+
const keyVar = B_varWithoutAllocation(objectVal.g);
|
|
1362
|
+
B_hoistDecl(input, keyVar);
|
|
1363
|
+
objectVal.cp = objectVal.cp + `for(${keyVar} in ${input.v()}){if(`;
|
|
1364
|
+
if (keys.length === 0) objectVal.cp = objectVal.cp + "true";
|
|
1365
|
+
else for (let idx = 0; idx < keys.length; idx++) {
|
|
1366
|
+
const key = keys[idx];
|
|
1367
|
+
if (idx !== 0) objectVal.cp = objectVal.cp + "&&";
|
|
1368
|
+
objectVal.cp = objectVal.cp + `${keyVar}!==${B_inlineLocation(input.g, key)}`;
|
|
1369
|
+
}
|
|
1370
|
+
objectVal.cp = objectVal.cp + `){${B_failWithArg(input, (excessFieldName) => ({
|
|
1371
|
+
code: "unrecognized_keys",
|
|
1372
|
+
path: objectVal.path,
|
|
1373
|
+
reason: `Unrecognized key "${excessFieldName}"`,
|
|
1374
|
+
keys: [excessFieldName]
|
|
1375
|
+
}), keyVar)}}}`;
|
|
1376
|
+
}
|
|
1377
|
+
if (shouldRecreateInput) output = completeObjectVal(objectVal);
|
|
1378
|
+
else {
|
|
1379
|
+
const o = B_refine(input, expectedSchema);
|
|
1380
|
+
o.cp = objectVal.cp;
|
|
1381
|
+
o.d = objectVal.d;
|
|
1382
|
+
output = o;
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
return B_markOutput(output, input);
|
|
1386
|
+
};
|
|
1387
|
+
var dictFactory = (item) => {
|
|
1388
|
+
const mut = baseSchema(objectTag, item.r === item);
|
|
1389
|
+
mut.properties = immutableEmptyObject;
|
|
1390
|
+
mut.additionalItems = item;
|
|
1391
|
+
mut.decoder = objectDecoder;
|
|
1392
|
+
return mut;
|
|
1393
|
+
};
|
|
1394
|
+
var unionToKey = (schema) => {
|
|
1395
|
+
return flagUnsafeHas(tagFlags[schema.type], tagFlagInstance) ? schema.class["name"] : schema.type;
|
|
1396
|
+
};
|
|
1397
|
+
var unionIsPriority = (tagFlag, byKey) => {
|
|
1398
|
+
return flagUnsafeHas(tagFlag, 8320) && objectTag in byKey || flagUnsafeHas(tagFlag, tagFlagNaN) && numberTag in byKey;
|
|
1399
|
+
};
|
|
1400
|
+
var unionIsSelfDecodeNoop = (schema) => {
|
|
1401
|
+
const additionalItems = schema.additionalItems;
|
|
1402
|
+
return schema.to === void 0 && schema.parser === void 0 && !flagUnsafeHas(tagFlags[schema.type], tagFlagRef) && (schema.anyOf !== void 0 ? schema.anyOf.every(unionIsSelfDecodeNoop) : true) && (schema.items !== void 0 ? schema.items.every(unionIsSelfDecodeNoop) : true) && (schema.properties !== void 0 ? Object.values(schema.properties).every(unionIsSelfDecodeNoop) : true) && (additionalItems !== void 0 && typeof additionalItems !== "string" ? unionIsSelfDecodeNoop(additionalItems) : true);
|
|
1403
|
+
};
|
|
1404
|
+
var unionIsWiderSchema = (schemaAnyOf, inputAnyOf) => {
|
|
1405
|
+
return inputAnyOf.every((inputSchema, idx) => {
|
|
1406
|
+
const schema = schemaAnyOf[idx];
|
|
1407
|
+
if (schema !== void 0) return !flagUnsafeHas(tagFlags[inputSchema.type], 9152) && inputSchema.type === schema.type && inputSchema.const === schema.const && inputSchema.to === void 0;
|
|
1408
|
+
else return false;
|
|
1409
|
+
});
|
|
1410
|
+
};
|
|
1411
|
+
var unionGetToPerCase = (schema) => {
|
|
1412
|
+
return schema.parser === void 0 && schema.to !== void 0 ? schema.to : void 0;
|
|
1413
|
+
};
|
|
1414
|
+
var unionCanDispatchPerVariant = (inputAnyOf, target) => {
|
|
1415
|
+
return !flagUnsafeHas(tagFlags[getOutputSchema(target).type], tagFlagRef) && !(target.type === unionTag && target.anyOf.some((v) => flagUnsafeHas(tagFlags[v.type], tagFlagRef))) && !inputAnyOf.some((v) => v.to !== void 0 || v.parser !== void 0 || flagUnsafeHas(tagFlags[v.type], tagFlagRef));
|
|
1416
|
+
};
|
|
1417
|
+
var unionPerVariantVal = (input, target) => {
|
|
1418
|
+
return B_refine(input, unknown, void 0, updateOutput(input.s, (mut) => {
|
|
1419
|
+
mut.to = target;
|
|
1420
|
+
}));
|
|
1421
|
+
};
|
|
1422
|
+
var unionEncoder = (input, target) => {
|
|
1423
|
+
const inputAnyOf = input.s.anyOf;
|
|
1424
|
+
if (target.type === unionTag && unionGetToPerCase(target) === void 0 && unionIsWiderSchema(target.anyOf, inputAnyOf)) return input;
|
|
1425
|
+
else if (unionCanDispatchPerVariant(inputAnyOf, target)) return unionPerVariantVal(input, target);
|
|
1426
|
+
else return input;
|
|
1427
|
+
};
|
|
1428
|
+
var unionDecoder = (input) => {
|
|
1429
|
+
const selfSchema = input.e;
|
|
1430
|
+
let schemas = selfSchema.anyOf;
|
|
1431
|
+
const initialInputTagFlag = tagFlags[input.s.type];
|
|
1432
|
+
const toPerCase = unionGetToPerCase(selfSchema);
|
|
1433
|
+
if (input.s === selfSchema && toPerCase === void 0 && schemas.every(unionIsSelfDecodeNoop) || flagUnsafeHas(initialInputTagFlag, tagFlagUnion) && unionIsWiderSchema(schemas, input.s.anyOf) && toPerCase === void 0 || input.io && input.e === input.s) return input;
|
|
1434
|
+
else {
|
|
1435
|
+
if (flagUnsafeHas(initialInputTagFlag, tagFlagUnion) || input.s.encoder === void 0 && flagUnsafeHas(initialInputTagFlag, tagFlagRef)) input.s = unknown;
|
|
1436
|
+
let activeKeyRef = "";
|
|
1437
|
+
if (!flagUnsafeHas(initialInputTagFlag, 769)) {
|
|
1438
|
+
const sourceKey = unionToKey(input.s);
|
|
1439
|
+
let hasNull = false;
|
|
1440
|
+
let hasUndefined = false;
|
|
1441
|
+
const len = schemas.length;
|
|
1442
|
+
let i = 0;
|
|
1443
|
+
while (activeKeyRef === "" && i < len) {
|
|
1444
|
+
const s2 = schemas[i];
|
|
1445
|
+
if (unionToKey(s2) === sourceKey) activeKeyRef = sourceKey;
|
|
1446
|
+
else if (s2.type === nullTag) hasNull = true;
|
|
1447
|
+
else if (s2.type === undefinedTag) hasUndefined = true;
|
|
1448
|
+
i = i + 1;
|
|
1449
|
+
}
|
|
1450
|
+
if (activeKeyRef === "") {
|
|
1451
|
+
if (flagUnsafeHas(initialInputTagFlag, tagFlagUndefined) && hasNull) activeKeyRef = nullTag;
|
|
1452
|
+
else if (flagUnsafeHas(initialInputTagFlag, tagFlagNull) && hasUndefined) activeKeyRef = undefinedTag;
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
const activeKey = activeKeyRef;
|
|
1456
|
+
const initialInline = input.i;
|
|
1457
|
+
const fail = (caught2) => {
|
|
1458
|
+
return `${B_embed(input, function() {
|
|
1459
|
+
const args = arguments;
|
|
1460
|
+
B_throw(B_makeInvalidInputDetails(selfSchema, unknown, input.path, args[0], true, args.length > 1 ? Array.from(args).slice(1) : void 0));
|
|
1461
|
+
})}(${input.v()}${caught2})`;
|
|
1462
|
+
};
|
|
1463
|
+
const output = B_refine(input);
|
|
1464
|
+
const outputAnyOf = [];
|
|
1465
|
+
let staticBlockFailure = "";
|
|
1466
|
+
const getArrItemsCode = (arr, isDeopt) => {
|
|
1467
|
+
const typeValidationInput = arr[0];
|
|
1468
|
+
const typeValidationOutput = arr[1];
|
|
1469
|
+
let itemStart = "";
|
|
1470
|
+
let itemEnd = "";
|
|
1471
|
+
let itemNextElse = false;
|
|
1472
|
+
let itemNoop = "";
|
|
1473
|
+
let caught2 = "";
|
|
1474
|
+
let byDiscriminant = {};
|
|
1475
|
+
const preItems = 2;
|
|
1476
|
+
let itemIdx = preItems;
|
|
1477
|
+
const lastIdx2 = arr.length - 1;
|
|
1478
|
+
while (itemIdx <= lastIdx2) {
|
|
1479
|
+
const input2 = B_scope(typeValidationOutput);
|
|
1480
|
+
input2.u = true;
|
|
1481
|
+
input2.t = typeValidationOutput.t;
|
|
1482
|
+
input2.io = false;
|
|
1483
|
+
input2.e = arr[itemIdx];
|
|
1484
|
+
const isLast = itemIdx === lastIdx2;
|
|
1485
|
+
const isFirst = itemIdx === preItems;
|
|
1486
|
+
const isOnlyCase = isFirst && isLast;
|
|
1487
|
+
let withExhaustiveCheck = !isOnlyCase;
|
|
1488
|
+
let itemSkipped = false;
|
|
1489
|
+
let itemCodeRef = "";
|
|
1490
|
+
const itemCondRef = { contents: "" };
|
|
1491
|
+
try {
|
|
1492
|
+
const itemOutput = parse(input2);
|
|
1493
|
+
outputAnyOf.push(itemOutput.s);
|
|
1494
|
+
itemCodeRef = B_merge(itemOutput, itemCondRef);
|
|
1495
|
+
if (itemOutput.t) {
|
|
1496
|
+
output.t = true;
|
|
1497
|
+
if (flagUnsafeHas(itemOutput.f, valFlagAsync)) output.f |= valFlagAsync;
|
|
1498
|
+
const itemVar = typeValidationInput.v();
|
|
1499
|
+
if (itemOutput.i !== itemVar) itemCodeRef = itemCodeRef + `${itemVar}=${itemOutput.i}`;
|
|
1500
|
+
}
|
|
1501
|
+
} catch (exn) {
|
|
1502
|
+
const errorVar = B_embed(input2, getOrRethrow(exn));
|
|
1503
|
+
caught2 = `${caught2},${errorVar}`;
|
|
1504
|
+
if (isDeopt && isOnlyCase) {
|
|
1505
|
+
staticBlockFailure = errorVar;
|
|
1506
|
+
itemSkipped = true;
|
|
1507
|
+
} else if (isLast) {
|
|
1508
|
+
withExhaustiveCheck = false;
|
|
1509
|
+
itemCodeRef = isDeopt ? "throw " + errorVar : fail(caught2);
|
|
1510
|
+
} else itemSkipped = true;
|
|
1511
|
+
}
|
|
1512
|
+
const itemCond = itemCondRef.contents;
|
|
1513
|
+
const itemCode = itemCodeRef;
|
|
1514
|
+
if (!itemSkipped && itemCond) if (itemCode) {
|
|
1515
|
+
const existing = byDiscriminant[itemCond];
|
|
1516
|
+
if (existing !== void 0) if (Array.isArray(existing)) existing.push(itemCode);
|
|
1517
|
+
else byDiscriminant[itemCond] = [existing, itemCode];
|
|
1518
|
+
else byDiscriminant[itemCond] = itemCode;
|
|
1519
|
+
} else itemNoop = itemNoop ? `${itemNoop}||${itemCond}` : itemCond;
|
|
1520
|
+
if (!itemSkipped && (!itemCond || isLast)) {
|
|
1521
|
+
const accedDiscriminants = Object.keys(byDiscriminant);
|
|
1522
|
+
for (let idx = 0; idx < accedDiscriminants.length; idx++) {
|
|
1523
|
+
const discrim = accedDiscriminants[idx];
|
|
1524
|
+
itemStart = itemStart + (itemNextElse ? "else if" : "if") + `(${discrim}){`;
|
|
1525
|
+
const entry = byDiscriminant[discrim];
|
|
1526
|
+
if (!Array.isArray(entry)) itemStart = itemStart + entry + "}";
|
|
1527
|
+
else {
|
|
1528
|
+
let caught3 = "";
|
|
1529
|
+
for (let idx2 = 0; idx2 < entry.length; idx2++) {
|
|
1530
|
+
const code = entry[idx2];
|
|
1531
|
+
const errorVar = `e` + idx2;
|
|
1532
|
+
itemStart = itemStart + `try{${code}}catch(${errorVar}){`;
|
|
1533
|
+
caught3 = `${caught3},${errorVar}`;
|
|
1534
|
+
}
|
|
1535
|
+
itemStart = itemStart + fail(caught3) + "}".repeat(entry.length) + "}";
|
|
1536
|
+
}
|
|
1537
|
+
itemNextElse = true;
|
|
1538
|
+
}
|
|
1539
|
+
byDiscriminant = {};
|
|
1540
|
+
}
|
|
1541
|
+
if (!itemSkipped && !itemCond) if (!itemCode) {
|
|
1542
|
+
itemNoop = "";
|
|
1543
|
+
itemIdx = lastIdx2;
|
|
1544
|
+
withExhaustiveCheck = false;
|
|
1545
|
+
} else {
|
|
1546
|
+
if (itemNoop) {
|
|
1547
|
+
itemStart = itemStart + (itemNextElse ? "else if" : "if") + `(!(${itemNoop})){`;
|
|
1548
|
+
itemEnd = "}" + itemEnd;
|
|
1549
|
+
itemNoop = "";
|
|
1550
|
+
itemNextElse = false;
|
|
1551
|
+
}
|
|
1552
|
+
if (isLast && (isDeopt || !withExhaustiveCheck || isFirst)) {
|
|
1553
|
+
itemStart = itemStart + `${itemNextElse ? "else{" : ""}${itemCode}`;
|
|
1554
|
+
itemEnd = (itemNextElse ? "}" : "") + itemEnd;
|
|
1555
|
+
} else {
|
|
1556
|
+
const errorVar = `e` + (itemIdx - preItems);
|
|
1557
|
+
itemStart = itemStart + `${itemNextElse ? "else{" : ""}try{${itemCode}}catch(${errorVar}){`;
|
|
1558
|
+
itemEnd = (itemNextElse ? "}" : "") + "}" + itemEnd;
|
|
1559
|
+
caught2 = `${caught2},${errorVar}`;
|
|
1560
|
+
itemNextElse = false;
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
if (isLast) {
|
|
1564
|
+
if (itemNoop) if (itemStart || caught2) itemStart = itemStart + (itemNextElse ? "else if" : "if") + `(!(${itemNoop})){${fail(caught2)}}`;
|
|
1565
|
+
else B_pushCheck(typeValidationOutput, {
|
|
1566
|
+
c: (_inputVar) => `(${itemNoop})`,
|
|
1567
|
+
f: failInvalidType
|
|
1568
|
+
});
|
|
1569
|
+
else if (withExhaustiveCheck) {
|
|
1570
|
+
const errorCode = fail(caught2);
|
|
1571
|
+
itemStart = itemStart + (itemNextElse ? `else{${errorCode}}` : errorCode);
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
itemIdx = itemIdx + 1;
|
|
1575
|
+
}
|
|
1576
|
+
return itemStart + itemEnd;
|
|
1577
|
+
};
|
|
1578
|
+
let start = "";
|
|
1579
|
+
let end = "";
|
|
1580
|
+
let caught = "";
|
|
1581
|
+
let exit = false;
|
|
1582
|
+
const lastIdx = schemas.length - 1;
|
|
1583
|
+
let byKey = {};
|
|
1584
|
+
let keys = [];
|
|
1585
|
+
const appendUnionRefiners = (() => {
|
|
1586
|
+
const unionRefiner = selfSchema.refiner;
|
|
1587
|
+
const unionInputRefiner = selfSchema.inputRefiner;
|
|
1588
|
+
const cachedRefinerChecks = { contents: void 0 };
|
|
1589
|
+
const cachedInputRefinerChecks = { contents: void 0 };
|
|
1590
|
+
const attach = (current, source, cache) => {
|
|
1591
|
+
if (source === void 0) return current;
|
|
1592
|
+
else {
|
|
1593
|
+
const fn = source;
|
|
1594
|
+
const getCached = (input2) => {
|
|
1595
|
+
if (cache.contents !== void 0) return cache.contents;
|
|
1596
|
+
else {
|
|
1597
|
+
const checks = fn(input2);
|
|
1598
|
+
cache.contents = checks;
|
|
1599
|
+
return checks;
|
|
1600
|
+
}
|
|
1601
|
+
};
|
|
1602
|
+
if (current === void 0) return getCached;
|
|
1603
|
+
else {
|
|
1604
|
+
const existing = current;
|
|
1605
|
+
return (input2) => {
|
|
1606
|
+
const arr = existing(input2);
|
|
1607
|
+
const next = getCached(input2);
|
|
1608
|
+
for (let i = 0; i < next.length; i++) arr.push(next[i]);
|
|
1609
|
+
return arr;
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
};
|
|
1614
|
+
return (mut) => {
|
|
1615
|
+
const r = attach(mut.refiner, unionRefiner, cachedRefinerChecks);
|
|
1616
|
+
if (r !== void 0) mut.refiner = r;
|
|
1617
|
+
const ir = attach(mut.inputRefiner, unionInputRefiner, cachedInputRefinerChecks);
|
|
1618
|
+
if (ir !== void 0) mut.inputRefiner = ir;
|
|
1619
|
+
};
|
|
1620
|
+
})();
|
|
1621
|
+
if (isLiteral(input.s)) {
|
|
1622
|
+
const matching = [];
|
|
1623
|
+
const rest = [];
|
|
1624
|
+
for (let idx = 0; idx <= lastIdx; idx++) {
|
|
1625
|
+
const schema = schemas[idx];
|
|
1626
|
+
if (isLiteral(schema) && schema.const === input.s.const) matching.push(schema);
|
|
1627
|
+
else rest.push(schema);
|
|
1628
|
+
}
|
|
1629
|
+
schemas = matching.concat(rest);
|
|
1630
|
+
}
|
|
1631
|
+
for (let idx = 0; idx <= lastIdx; idx++) {
|
|
1632
|
+
const schema = toPerCase !== void 0 ? updateOutput(schemas[idx], (mut) => {
|
|
1633
|
+
appendUnionRefiners(mut);
|
|
1634
|
+
mut.to = toPerCase;
|
|
1635
|
+
}) : schemas[idx];
|
|
1636
|
+
const tagFlag = tagFlags[schema.type];
|
|
1637
|
+
const key = unionToKey(schema);
|
|
1638
|
+
if (activeKey !== "" && activeKey !== key) {} else if (flagUnsafeHas(tagFlag, tagFlagUndefined) && "fromDefault" in selfSchema) {} else {
|
|
1639
|
+
const initialArr = byKey[key];
|
|
1640
|
+
if (initialArr !== void 0) {
|
|
1641
|
+
const arr = initialArr;
|
|
1642
|
+
if (flagUnsafeHas(tagFlag, tagFlagObject) && nestedLoc in schema.properties) arr.splice(arr.length - 1, 0, schema);
|
|
1643
|
+
else if (!flagUnsafeHas(tagFlag, 2096)) arr.push(schema);
|
|
1644
|
+
} else {
|
|
1645
|
+
const typeValidationInput = B_scope(input);
|
|
1646
|
+
if (flagUnsafeHas(tagFlag, 37633)) typeValidationInput.e = unknown;
|
|
1647
|
+
else {
|
|
1648
|
+
const narrow = baseSchema(schema.type, false);
|
|
1649
|
+
narrow.encoder = schema.encoder;
|
|
1650
|
+
if (flagUnsafeHas(tagFlag, tagFlagInstance)) narrow.class = schema.class;
|
|
1651
|
+
else if (flagUnsafeHas(tagFlag, tagFlagObject)) {
|
|
1652
|
+
narrow.properties = immutableEmptyObject;
|
|
1653
|
+
narrow.additionalItems = unknown;
|
|
1654
|
+
} else if (flagUnsafeHas(tagFlag, tagFlagArray)) {
|
|
1655
|
+
narrow.additionalItems = unknown;
|
|
1656
|
+
narrow.items = immutableEmptyArray;
|
|
1657
|
+
} else if (flagUnsafeHas(tagFlag, 2096)) narrow.const = schema.const;
|
|
1658
|
+
narrow.decoder = (input2) => {
|
|
1659
|
+
if (flagUnsafeHas(tagFlags[input2.s.type], tagFlagUnknown)) return B_refine(input2, input2.e, [{
|
|
1660
|
+
c: (inputVar) => typeCheckCond(input2, schema, inputVar),
|
|
1661
|
+
f: failInvalidType
|
|
1662
|
+
}]);
|
|
1663
|
+
else return schema.decoder(input2);
|
|
1664
|
+
};
|
|
1665
|
+
typeValidationInput.e = narrow;
|
|
1666
|
+
}
|
|
1667
|
+
let typeValidationOutput;
|
|
1668
|
+
try {
|
|
1669
|
+
typeValidationOutput = parse(typeValidationInput);
|
|
1670
|
+
} catch (_) {
|
|
1671
|
+
typeValidationInput.vc = void 0;
|
|
1672
|
+
typeValidationOutput = typeValidationInput;
|
|
1673
|
+
}
|
|
1674
|
+
if (unionIsPriority(tagFlag, byKey)) keys.unshift(key);
|
|
1675
|
+
else keys.push(key);
|
|
1676
|
+
byKey[key] = [
|
|
1677
|
+
typeValidationInput,
|
|
1678
|
+
typeValidationOutput,
|
|
1679
|
+
schema
|
|
1680
|
+
];
|
|
1681
|
+
let shouldDeopt = true;
|
|
1682
|
+
let valRef = typeValidationOutput;
|
|
1683
|
+
while (valRef !== void 0 && shouldDeopt) {
|
|
1684
|
+
const v = valRef;
|
|
1685
|
+
valRef = v.prev;
|
|
1686
|
+
shouldDeopt = !(v.vc && B_isHoistable(v));
|
|
1687
|
+
}
|
|
1688
|
+
if (shouldDeopt) {
|
|
1689
|
+
for (let keyIdx = 0; keyIdx < keys.length; keyIdx++) {
|
|
1690
|
+
const key2 = keys[keyIdx];
|
|
1691
|
+
if (!exit) {
|
|
1692
|
+
const arr = byKey[key2];
|
|
1693
|
+
const typeValidationOutput2 = arr[1];
|
|
1694
|
+
const itemsCode = getArrItemsCode(arr, true);
|
|
1695
|
+
const blockCode = B_merge(typeValidationOutput2) + itemsCode;
|
|
1696
|
+
const embeddedError = staticBlockFailure;
|
|
1697
|
+
if (embeddedError) {
|
|
1698
|
+
staticBlockFailure = "";
|
|
1699
|
+
if (blockCode) {
|
|
1700
|
+
const errorVar = `e` + (idx + keyIdx);
|
|
1701
|
+
start = start + `try{${blockCode}throw ${embeddedError}}catch(${errorVar}){`;
|
|
1702
|
+
end = "}" + end;
|
|
1703
|
+
caught = `${caught},${errorVar}`;
|
|
1704
|
+
} else caught = `${caught},${embeddedError}`;
|
|
1705
|
+
} else if (blockCode) {
|
|
1706
|
+
const errorVar = `e` + (idx + keyIdx);
|
|
1707
|
+
start = start + `try{${blockCode}}catch(${errorVar}){`;
|
|
1708
|
+
end = "}" + end;
|
|
1709
|
+
caught = `${caught},${errorVar}`;
|
|
1710
|
+
} else exit = true;
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
byKey = {};
|
|
1714
|
+
keys = [];
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
if (!exit) {
|
|
1720
|
+
let nextElse = false;
|
|
1721
|
+
let noop2 = "";
|
|
1722
|
+
for (let idx = 0; idx < keys.length; idx++) {
|
|
1723
|
+
const arr = byKey[keys[idx]];
|
|
1724
|
+
const typeValidationOutput = arr[1];
|
|
1725
|
+
const firstSchema = arr[2];
|
|
1726
|
+
const itemsCode = getArrItemsCode(arr, false);
|
|
1727
|
+
const blockCondRef = { contents: "" };
|
|
1728
|
+
const blockCode = B_merge(typeValidationOutput, blockCondRef) + itemsCode;
|
|
1729
|
+
const blockCond = blockCondRef.contents;
|
|
1730
|
+
if (blockCode || unionIsPriority(tagFlags[firstSchema.type], byKey)) {
|
|
1731
|
+
start = start + (nextElse ? "else if" : "if") + `(${blockCond}){${blockCode}}`;
|
|
1732
|
+
nextElse = true;
|
|
1733
|
+
} else noop2 = noop2 ? `${noop2}||${blockCond}` : blockCond;
|
|
1734
|
+
}
|
|
1735
|
+
const errorCode = fail(caught);
|
|
1736
|
+
start = start + (noop2 ? (nextElse ? "else if" : "if") + `(!(${noop2})){${errorCode}}` : nextElse ? `else{${errorCode}}` : end === "" ? errorCode + ";" : errorCode);
|
|
1737
|
+
}
|
|
1738
|
+
output.cp = output.cp + start + end;
|
|
1739
|
+
if (input.i !== output.i) output.i = input.i;
|
|
1740
|
+
let o;
|
|
1741
|
+
if (flagUnsafeHas(output.f, valFlagAsync)) {
|
|
1742
|
+
output.i = `Promise.resolve(${output.i})`;
|
|
1743
|
+
output.v = _notVar;
|
|
1744
|
+
o = output;
|
|
1745
|
+
} else if (output.v === _var) if (input.cp === "" && output.cp === "" && initialInline === "i") {
|
|
1746
|
+
input.hd = "";
|
|
1747
|
+
input.v = _notVar;
|
|
1748
|
+
input.i = initialInline;
|
|
1749
|
+
o = input;
|
|
1750
|
+
} else o = output;
|
|
1751
|
+
else o = output;
|
|
1752
|
+
o.s = outputAnyOf.length ? unionFactory(outputAnyOf) : never_();
|
|
1753
|
+
if (toPerCase !== void 0) {
|
|
1754
|
+
o.io = true;
|
|
1755
|
+
o.e = getOutputSchema(toPerCase);
|
|
1756
|
+
} else o.e = selfSchema;
|
|
1757
|
+
return o;
|
|
1758
|
+
}
|
|
1759
|
+
};
|
|
1760
|
+
var unionFactory = (schemas) => {
|
|
1761
|
+
if (schemas.length === 0) return panic("S.union requires at least one item");
|
|
1762
|
+
else if (schemas.length === 1) return schemas[0];
|
|
1763
|
+
else {
|
|
1764
|
+
const has = {};
|
|
1765
|
+
const anyOf = /* @__PURE__ */ new Set();
|
|
1766
|
+
schemas.forEach((schema) => {
|
|
1767
|
+
if (schema.type === unionTag && schema.to === void 0) {
|
|
1768
|
+
schema.anyOf.forEach((item) => {
|
|
1769
|
+
anyOf.add(item);
|
|
1770
|
+
});
|
|
1771
|
+
Object.assign(has, schema.has);
|
|
1772
|
+
} else {
|
|
1773
|
+
anyOf.add(schema);
|
|
1774
|
+
setHas(has, schema.type);
|
|
1775
|
+
}
|
|
1776
|
+
});
|
|
1777
|
+
const mut = baseSchema(unionTag, false);
|
|
1778
|
+
mut.anyOf = Array.from(anyOf);
|
|
1779
|
+
mut.decoder = unionDecoder;
|
|
1780
|
+
mut.encoder = unionEncoder;
|
|
1781
|
+
mut.has = has;
|
|
1782
|
+
return mut;
|
|
1783
|
+
}
|
|
1784
|
+
};
|
|
1785
|
+
var nestedNone = () => {
|
|
1786
|
+
const itemSchema = Literal_parse(0);
|
|
1787
|
+
const properties = {};
|
|
1788
|
+
properties[nestedLoc] = itemSchema;
|
|
1789
|
+
return {
|
|
1790
|
+
type: objectTag,
|
|
1791
|
+
required: [nestedLoc],
|
|
1792
|
+
properties,
|
|
1793
|
+
additionalItems: "strip",
|
|
1794
|
+
decoder: objectDecoder,
|
|
1795
|
+
serializer: (input) => {
|
|
1796
|
+
const nextSchema = input.e.to;
|
|
1797
|
+
return B_nextConst(input, nextSchema, nextSchema);
|
|
1798
|
+
}
|
|
1799
|
+
};
|
|
1800
|
+
};
|
|
1801
|
+
var nestedOption = (item) => {
|
|
1802
|
+
return updateOutput(item, (mut) => {
|
|
1803
|
+
mut.to = nestedNone();
|
|
1804
|
+
mut.parser = nestedOptionParser;
|
|
1805
|
+
});
|
|
1806
|
+
};
|
|
1807
|
+
var optionFactory = (item, unitSchema = unit()) => {
|
|
1808
|
+
const out = getOutputSchema(item);
|
|
1809
|
+
if (out.type === undefinedTag) return unionFactory([unitSchema, nestedOption(item)]);
|
|
1810
|
+
else if (out.type === unionTag) {
|
|
1811
|
+
const anyOf = out.anyOf;
|
|
1812
|
+
const has = out.has;
|
|
1813
|
+
return updateOutput(item, (mut) => {
|
|
1814
|
+
const schemas = anyOf;
|
|
1815
|
+
const mutHas = { ...has };
|
|
1816
|
+
const newAnyOf = [];
|
|
1817
|
+
for (let idx = 0; idx < schemas.length; idx++) {
|
|
1818
|
+
const schema = schemas[idx];
|
|
1819
|
+
let toPush;
|
|
1820
|
+
const schemaOut = getOutputSchema(schema);
|
|
1821
|
+
if (schemaOut.type === undefinedTag) {
|
|
1822
|
+
mutHas[unitSchema.type] = true;
|
|
1823
|
+
newAnyOf.push(unitSchema);
|
|
1824
|
+
toPush = nestedOption(schema);
|
|
1825
|
+
} else if (schemaOut.properties !== void 0) {
|
|
1826
|
+
const nestedSchema = schemaOut.properties[nestedLoc];
|
|
1827
|
+
if (nestedSchema !== void 0) toPush = updateOutput(schema, (mut2) => {
|
|
1828
|
+
const properties2 = {};
|
|
1829
|
+
properties2[nestedLoc] = {
|
|
1830
|
+
...nestedSchema,
|
|
1831
|
+
const: nestedSchema.const + 1
|
|
1832
|
+
};
|
|
1833
|
+
mut2.properties = properties2;
|
|
1834
|
+
});
|
|
1835
|
+
else toPush = schema;
|
|
1836
|
+
} else toPush = schema;
|
|
1837
|
+
newAnyOf.push(toPush);
|
|
1838
|
+
}
|
|
1839
|
+
if (newAnyOf.length === schemas.length) {
|
|
1840
|
+
mutHas[unitSchema.type] = true;
|
|
1841
|
+
newAnyOf.push(unitSchema);
|
|
1842
|
+
}
|
|
1843
|
+
mut.anyOf = newAnyOf;
|
|
1844
|
+
mut.has = mutHas;
|
|
1845
|
+
});
|
|
1846
|
+
} else return unionFactory([item, unitSchema]);
|
|
1847
|
+
};
|
|
1848
|
+
var option = (item) => {
|
|
1849
|
+
return optionFactory(item, unit());
|
|
1850
|
+
};
|
|
1851
|
+
var valGet = (parent, location) => {
|
|
1852
|
+
let vals;
|
|
1853
|
+
if (parent.d !== void 0) vals = parent.d;
|
|
1854
|
+
else {
|
|
1855
|
+
const d = /* @__PURE__ */ Object.create(null);
|
|
1856
|
+
parent.d = d;
|
|
1857
|
+
vals = d;
|
|
1858
|
+
}
|
|
1859
|
+
const existing = vals[location];
|
|
1860
|
+
if (existing !== void 0) return B_scope(existing);
|
|
1861
|
+
else {
|
|
1862
|
+
let locationSchema;
|
|
1863
|
+
if (parent.s.type === objectTag) locationSchema = parent.s.properties[location];
|
|
1864
|
+
else locationSchema = parent.s.items[Number(location)];
|
|
1865
|
+
let schema;
|
|
1866
|
+
if (locationSchema !== void 0) schema = locationSchema;
|
|
1867
|
+
else {
|
|
1868
|
+
const additionalItems = parent.s.additionalItems;
|
|
1869
|
+
if (isItemSchema(additionalItems)) {
|
|
1870
|
+
const s2 = additionalItems;
|
|
1871
|
+
if (parent.s.type === objectTag && s2.type !== unknownTag && !flagUnsafeHas(tagFlags[s2.type], tagFlagRef) && !isOptional(s2)) schema = option(s2);
|
|
1872
|
+
else schema = s2;
|
|
1873
|
+
} else schema = B_unsupportedDecode(parent, parent.s, parent.e);
|
|
1874
|
+
}
|
|
1875
|
+
const pathAppend = pathFromInlinedLocation(B_inlineLocation(parent.g, location));
|
|
1876
|
+
const item = {
|
|
1877
|
+
v: _notVarAtParent,
|
|
1878
|
+
i: isLiteral(schema) ? B_inlineConst(parent, schema) : `${parent.v()}${pathAppend}`,
|
|
1879
|
+
f: valFlagNone,
|
|
1880
|
+
s: schema,
|
|
1881
|
+
e: schema,
|
|
1882
|
+
cp: "",
|
|
1883
|
+
hd: "",
|
|
1884
|
+
path: pathConcat(parent.path, pathAppend),
|
|
1885
|
+
g: parent.g,
|
|
1886
|
+
p: parent
|
|
1887
|
+
};
|
|
1888
|
+
vals[location] = item;
|
|
1889
|
+
return item;
|
|
1890
|
+
}
|
|
1891
|
+
};
|
|
1892
|
+
var recursiveDecoder = (input) => {
|
|
1893
|
+
const expectedSchema = input.e;
|
|
1894
|
+
const schemaRef = expectedSchema["$ref"];
|
|
1895
|
+
const defs = input.g.d;
|
|
1896
|
+
const def = defs[schemaRef.slice(8)];
|
|
1897
|
+
const flag = input.g.o;
|
|
1898
|
+
const inputSchema = input.s.seq === expectedSchema.seq ? def : input.s;
|
|
1899
|
+
const key = `${inputSchema.seq}-${def.seq}--${flag}`;
|
|
1900
|
+
let recOperation = "";
|
|
1901
|
+
const fn = def[key];
|
|
1902
|
+
if (fn !== void 0) recOperation = fn === 0 ? B_embed(input, def) + `["${key}"]` : B_embed(input, fn);
|
|
1903
|
+
else {
|
|
1904
|
+
let assumedHasTransform = def.hasTransform !== void 0 ? def.hasTransform : false;
|
|
1905
|
+
let assumedIsAsync = def.isAsync !== void 0 ? def.isAsync : false;
|
|
1906
|
+
let compileNeeded = true;
|
|
1907
|
+
let finalFn = 0;
|
|
1908
|
+
while (compileNeeded) {
|
|
1909
|
+
compileNeeded = false;
|
|
1910
|
+
if (def.hasTransform === void 0) def.hasTransform = assumedHasTransform;
|
|
1911
|
+
if (def.isAsync === void 0) def.isAsync = assumedIsAsync;
|
|
1912
|
+
configurableValueOptions[valKey] = 0;
|
|
1913
|
+
Object.defineProperty(def, key, configurableValueOptions);
|
|
1914
|
+
const fn2 = compileDecoder(inputSchema, def, flag, defs);
|
|
1915
|
+
valueOptions[valKey] = fn2;
|
|
1916
|
+
Object.defineProperty(def, key, valueOptions);
|
|
1917
|
+
finalFn = fn2;
|
|
1918
|
+
const actualHasTransform = def.hasTransform;
|
|
1919
|
+
const actualIsAsync = def.isAsync;
|
|
1920
|
+
if (actualHasTransform !== assumedHasTransform || actualIsAsync !== assumedIsAsync) {
|
|
1921
|
+
assumedHasTransform = actualHasTransform;
|
|
1922
|
+
assumedIsAsync = actualIsAsync;
|
|
1923
|
+
delete def[key];
|
|
1924
|
+
compileNeeded = true;
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
recOperation = B_embed(input, finalFn);
|
|
1928
|
+
}
|
|
1929
|
+
const hasTransform = def.hasTransform === true;
|
|
1930
|
+
const isAsync2 = def.isAsync;
|
|
1931
|
+
let outputDecl = "";
|
|
1932
|
+
let output;
|
|
1933
|
+
if (hasTransform || isAsync2) {
|
|
1934
|
+
const outputVar = B_varWithoutAllocation(input.g);
|
|
1935
|
+
outputDecl = `let ${outputVar};`;
|
|
1936
|
+
output = B_next(input, outputVar, expectedSchema, expectedSchema);
|
|
1937
|
+
output.v = _var;
|
|
1938
|
+
output.cp = `${outputVar}=${recOperation}(${input.i});`;
|
|
1939
|
+
if (isAsync2) output.f |= valFlagAsync;
|
|
1940
|
+
} else {
|
|
1941
|
+
output = B_refine(input, expectedSchema, void 0, expectedSchema);
|
|
1942
|
+
output.cp = `${recOperation}(${input.i});`;
|
|
1943
|
+
}
|
|
1944
|
+
output.prev = void 0;
|
|
1945
|
+
output.cp = outputDecl + B_mergeWithPathPrepend(output, input);
|
|
1946
|
+
output.fz = void 0;
|
|
1947
|
+
output.prev = input;
|
|
1948
|
+
return output;
|
|
1949
|
+
};
|
|
1950
|
+
var standardJSONSchemaConverter;
|
|
1951
|
+
var __setStandardJSONSchemaConverter = (fn) => {
|
|
1952
|
+
standardJSONSchemaConverter = fn;
|
|
1953
|
+
};
|
|
1954
|
+
var getStandardJSONSchema = (schema, options, isOutput) => {
|
|
1955
|
+
if (standardJSONSchemaConverter !== void 0) return standardJSONSchemaConverter(schema, options, isOutput);
|
|
1956
|
+
else throw new SuryError({
|
|
1957
|
+
code: "invalid_operation",
|
|
1958
|
+
path: pathEmpty,
|
|
1959
|
+
reason: "~standard.jsonSchema requires S.enableStandardJSONSchema() to be called first"
|
|
1960
|
+
});
|
|
1961
|
+
};
|
|
1962
|
+
Object.defineProperty(schemaPrototype, "~standard", { get: function() {
|
|
1963
|
+
const schema = this;
|
|
1964
|
+
return {
|
|
1965
|
+
version: 1,
|
|
1966
|
+
vendor,
|
|
1967
|
+
validate: (input) => {
|
|
1968
|
+
try {
|
|
1969
|
+
return { value: getDecoder(unknown, schema)(input) };
|
|
1970
|
+
} catch (exn) {
|
|
1971
|
+
const error = getOrRethrow(exn);
|
|
1972
|
+
return { issues: [{
|
|
1973
|
+
message: error.reason,
|
|
1974
|
+
path: error.path === pathEmpty ? void 0 : pathToArray(error.path)
|
|
1975
|
+
}] };
|
|
1976
|
+
}
|
|
1977
|
+
},
|
|
1978
|
+
jsonSchema: {
|
|
1979
|
+
input: (options) => getStandardJSONSchema(schema, options, false),
|
|
1980
|
+
output: (options) => getStandardJSONSchema(schema, options, true)
|
|
1981
|
+
}
|
|
1982
|
+
};
|
|
1983
|
+
} });
|
|
1984
|
+
var getAssertResult = () => {
|
|
1985
|
+
return cached("a", undefinedTag, (s2) => {
|
|
1986
|
+
s2.const = void 0;
|
|
1987
|
+
s2.decoder = literalDecoder;
|
|
1988
|
+
s2.noValidation = true;
|
|
1989
|
+
});
|
|
1990
|
+
};
|
|
1991
|
+
var assertOrThrow = (any, schema) => {
|
|
1992
|
+
getDecoder(unknown, schema, getAssertResult())(any);
|
|
1993
|
+
};
|
|
1994
|
+
var assertAsyncOrThrow = (any, schema) => {
|
|
1995
|
+
return getDecoder(unknown, schema, getAssertResult(), flagAsync)(any);
|
|
1996
|
+
};
|
|
1997
|
+
var isAsync = (schema) => {
|
|
1998
|
+
if (schema.isAsync === void 0) return isAsyncInternal(schema, void 0);
|
|
1999
|
+
else return schema.isAsync;
|
|
2000
|
+
};
|
|
2001
|
+
var wrapExnToFailure = (exn) => {
|
|
2002
|
+
if (exn && exn.s === s) return {
|
|
2003
|
+
success: false,
|
|
2004
|
+
error: exn
|
|
2005
|
+
};
|
|
2006
|
+
else throw exn;
|
|
2007
|
+
};
|
|
2008
|
+
var js_safe = (fn) => {
|
|
2009
|
+
try {
|
|
2010
|
+
return {
|
|
2011
|
+
success: true,
|
|
2012
|
+
value: fn()
|
|
2013
|
+
};
|
|
2014
|
+
} catch (exn) {
|
|
2015
|
+
return wrapExnToFailure(exn);
|
|
2016
|
+
}
|
|
2017
|
+
};
|
|
2018
|
+
var js_safeAsync = (fn) => {
|
|
2019
|
+
try {
|
|
2020
|
+
return fn().then((value) => ({
|
|
2021
|
+
success: true,
|
|
2022
|
+
value
|
|
2023
|
+
}), wrapExnToFailure);
|
|
2024
|
+
} catch (exn) {
|
|
2025
|
+
return Promise.resolve(wrapExnToFailure(exn));
|
|
2026
|
+
}
|
|
2027
|
+
};
|
|
2028
|
+
var Metadata_Id_make = (namespace, name) => {
|
|
2029
|
+
return `m:${namespace}:${name}`;
|
|
2030
|
+
};
|
|
2031
|
+
var Metadata_Id_internal = (name) => {
|
|
2032
|
+
return `m:${name}`;
|
|
2033
|
+
};
|
|
2034
|
+
var Metadata_get = (schema, id) => {
|
|
2035
|
+
return schema[id];
|
|
2036
|
+
};
|
|
2037
|
+
var Metadata_setInPlace = (schema, id, metadata) => {
|
|
2038
|
+
schema[id] = metadata;
|
|
2039
|
+
};
|
|
2040
|
+
var Metadata_set = (schema, id, metadata) => {
|
|
2041
|
+
const mut = copySchema(schema);
|
|
2042
|
+
Metadata_setInPlace(mut, id, metadata);
|
|
2043
|
+
return mut;
|
|
2044
|
+
};
|
|
2045
|
+
var defsPath = `#/$defs/`;
|
|
2046
|
+
var recursive = (name, fn) => {
|
|
2047
|
+
const ref = `${defsPath}${name}`;
|
|
2048
|
+
const refSchema = baseSchema(refTag, false);
|
|
2049
|
+
refSchema["$ref"] = ref;
|
|
2050
|
+
refSchema.name = name;
|
|
2051
|
+
refSchema.decoder = recursiveDecoder;
|
|
2052
|
+
const isNestedRec = globalConfig.d !== void 0;
|
|
2053
|
+
if (!isNestedRec) globalConfig.d = {};
|
|
2054
|
+
const def = fn(refSchema);
|
|
2055
|
+
if (def.name) refSchema.name = def.name;
|
|
2056
|
+
globalConfig.d[name] = def;
|
|
2057
|
+
if (isNestedRec) return refSchema;
|
|
2058
|
+
else {
|
|
2059
|
+
const schema = baseSchema(refTag, false);
|
|
2060
|
+
schema.name = refSchema.name;
|
|
2061
|
+
schema["$ref"] = ref;
|
|
2062
|
+
schema["$defs"] = globalConfig.d;
|
|
2063
|
+
schema.decoder = recursiveDecoder;
|
|
2064
|
+
globalConfig.d = void 0;
|
|
2065
|
+
return schema;
|
|
2066
|
+
}
|
|
2067
|
+
};
|
|
2068
|
+
var noValidation = (schema, value) => {
|
|
2069
|
+
const mut = copySchema(schema);
|
|
2070
|
+
mut.noValidation = value;
|
|
2071
|
+
return mut;
|
|
2072
|
+
};
|
|
2073
|
+
var internalRefine = (schema, makeRefiner) => {
|
|
2074
|
+
return updateOutput(schema, (mut) => {
|
|
2075
|
+
const refiner = makeRefiner(mut);
|
|
2076
|
+
const existingRefiner = mut.refiner;
|
|
2077
|
+
if (existingRefiner !== void 0) mut.refiner = (input) => {
|
|
2078
|
+
const arr = existingRefiner(input);
|
|
2079
|
+
arr.push(...refiner(input));
|
|
2080
|
+
return arr;
|
|
2081
|
+
};
|
|
2082
|
+
else mut.refiner = refiner;
|
|
2083
|
+
});
|
|
2084
|
+
};
|
|
2085
|
+
var refine = (schema, refineCheck, error, path) => {
|
|
2086
|
+
const message = error !== void 0 ? error : "Refinement failed";
|
|
2087
|
+
const extraPath = path !== void 0 ? pathFromArray(path) : pathEmpty;
|
|
2088
|
+
return internalRefine(schema, (_) => (input) => {
|
|
2089
|
+
const embeddedCheck = B_embed(input, refineCheck);
|
|
2090
|
+
return [{
|
|
2091
|
+
c: (inputVar) => `${embeddedCheck}(${inputVar})`,
|
|
2092
|
+
f: B_invalidInputBuilder(void 0, extraPath, message)
|
|
2093
|
+
}];
|
|
2094
|
+
});
|
|
2095
|
+
};
|
|
2096
|
+
var getMutErrorMessage = (mut) => {
|
|
2097
|
+
const em = mut.errorMessage ? { ...mut.errorMessage } : {};
|
|
2098
|
+
mut.errorMessage = em;
|
|
2099
|
+
return em;
|
|
2100
|
+
};
|
|
2101
|
+
var transform = (schema, transformer) => {
|
|
2102
|
+
return updateOutput(schema, (mut) => {
|
|
2103
|
+
mut.parser = (input) => {
|
|
2104
|
+
const definition = transformer(B_effectCtx(input));
|
|
2105
|
+
if (definition.p !== void 0 && definition.a === void 0) return B_embedTransformation(input, definition.p, false);
|
|
2106
|
+
else if (definition.p === void 0 && definition.a !== void 0) return B_embedTransformation(input, definition.a, true);
|
|
2107
|
+
else if (definition.p === void 0 && definition.a === void 0 && definition.s === void 0) return B_refine(input, void 0, void 0, input.e.to);
|
|
2108
|
+
else if (definition.p === void 0 && definition.a === void 0) return B_invalidOperation(input, `The S.transform parser is missing`);
|
|
2109
|
+
else return B_invalidOperation(input, `The S.transform doesn't allow parser and asyncParser at the same time. Remove parser in favor of asyncParser`);
|
|
2110
|
+
};
|
|
2111
|
+
const to = copySchema(unknown);
|
|
2112
|
+
to.serializer = (input) => {
|
|
2113
|
+
const definition = transformer(B_effectCtx(input));
|
|
2114
|
+
if (definition.s !== void 0) return B_embedTransformation(input, definition.s, false);
|
|
2115
|
+
else if (definition.p === void 0 && definition.a === void 0 && definition.s === void 0) return B_refine(input, void 0, void 0, input.e.to);
|
|
2116
|
+
else return B_invalidOperation(input, `The S.transform serializer is missing`);
|
|
2117
|
+
};
|
|
2118
|
+
mut.to = to;
|
|
2119
|
+
delete mut.isAsync;
|
|
2120
|
+
});
|
|
2121
|
+
};
|
|
2122
|
+
var nullAsUnit = () => {
|
|
2123
|
+
const schema = copySchema(nullLiteral());
|
|
2124
|
+
schema.to = unit();
|
|
2125
|
+
return schema;
|
|
2126
|
+
};
|
|
2127
|
+
var Option_getWithDefault = (schema, default_) => {
|
|
2128
|
+
return updateOutput(schema, (mut) => {
|
|
2129
|
+
const anyOf = mut.anyOf;
|
|
2130
|
+
if (anyOf !== void 0) {
|
|
2131
|
+
const outputItems = [];
|
|
2132
|
+
const originalItems = [];
|
|
2133
|
+
for (let idx = 0; idx < anyOf.length; idx++) {
|
|
2134
|
+
const schema2 = anyOf[idx];
|
|
2135
|
+
const outputSchema = getOutputSchema(schema2);
|
|
2136
|
+
if (outputSchema.type !== undefinedTag) {
|
|
2137
|
+
outputItems.push(outputSchema);
|
|
2138
|
+
originalItems.push(schema2);
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
const item = outputItems.length === 0 ? panic(`Can't set default for ${toExpression(mut)}`) : outputItems.length === 1 ? outputItems[0] : unionFactory(outputItems);
|
|
2142
|
+
const originalItem = originalItems.length === 1 ? originalItems[0] : unionFactory(originalItems);
|
|
2143
|
+
if (default_.type === "value") {
|
|
2144
|
+
const v = default_.value;
|
|
2145
|
+
try {
|
|
2146
|
+
getDecoder(unknown, item)(v);
|
|
2147
|
+
} catch (exn) {
|
|
2148
|
+
const error = getOrRethrow(exn);
|
|
2149
|
+
panic(`Invalid default for ${toExpression(mut)}: ${error["message"]}`);
|
|
2150
|
+
}
|
|
2151
|
+
try {
|
|
2152
|
+
mut.default = getDecoder(reverse(originalItem))(v);
|
|
2153
|
+
} catch (_exn) {}
|
|
2154
|
+
}
|
|
2155
|
+
mut.parser = (input) => {
|
|
2156
|
+
const nextSchema = input.e.to;
|
|
2157
|
+
const inputVar = input.v();
|
|
2158
|
+
return B_next(input, `${inputVar}===void 0?${default_.type === "value" ? B_inlineConst(input, Literal_parse(default_.value)) : `${B_embed(input, default_.callback)}()`}:${inputVar}`, nextSchema, nextSchema);
|
|
2159
|
+
};
|
|
2160
|
+
const to = copySchema(item);
|
|
2161
|
+
const originalDecoder = to.decoder;
|
|
2162
|
+
to.serializer = (input) => {
|
|
2163
|
+
const nextSchema = reverse(originalItem);
|
|
2164
|
+
return B_refine(originalDecoder(input), nextSchema, void 0, nextSchema);
|
|
2165
|
+
};
|
|
2166
|
+
to.decoder = noopDecoder;
|
|
2167
|
+
mut.to = to;
|
|
2168
|
+
} else panic(`Can't set default for ${toExpression(mut)}`);
|
|
2169
|
+
});
|
|
2170
|
+
};
|
|
2171
|
+
var Option_getOr = (schema, defaultValue) => Option_getWithDefault(schema, {
|
|
2172
|
+
type: "value",
|
|
2173
|
+
value: defaultValue
|
|
2174
|
+
});
|
|
2175
|
+
var Option_getOrWith = (schema, defaultCb) => Option_getWithDefault(schema, {
|
|
2176
|
+
type: "callback",
|
|
2177
|
+
callback: defaultCb
|
|
2178
|
+
});
|
|
2179
|
+
var Object_setAdditionalItems = (schema, additionalItems, deep) => {
|
|
2180
|
+
const currentAdditionalItems = schema.additionalItems;
|
|
2181
|
+
if (currentAdditionalItems !== void 0 && currentAdditionalItems !== additionalItems && typeof currentAdditionalItems !== objectTag) {
|
|
2182
|
+
const mut = copySchema(schema);
|
|
2183
|
+
mut.additionalItems = additionalItems;
|
|
2184
|
+
if (deep) {
|
|
2185
|
+
const items = schema.items;
|
|
2186
|
+
if (items !== void 0) mut.items = items.map((s2) => Object_setAdditionalItems(s2, additionalItems, deep));
|
|
2187
|
+
const properties = schema.properties;
|
|
2188
|
+
if (properties !== void 0) mut.properties = Object.fromEntries(Object.keys(properties).map((key) => [key, Object_setAdditionalItems(properties[key], additionalItems, deep)]));
|
|
2189
|
+
}
|
|
2190
|
+
return mut;
|
|
2191
|
+
} else return schema;
|
|
2192
|
+
};
|
|
2193
|
+
var strip = (schema) => {
|
|
2194
|
+
return Object_setAdditionalItems(schema, "strip", false);
|
|
2195
|
+
};
|
|
2196
|
+
var deepStrip = (schema) => {
|
|
2197
|
+
return Object_setAdditionalItems(schema, "strip", true);
|
|
2198
|
+
};
|
|
2199
|
+
var strict = (schema) => {
|
|
2200
|
+
return Object_setAdditionalItems(schema, "strict", false);
|
|
2201
|
+
};
|
|
2202
|
+
var deepStrict = (schema) => {
|
|
2203
|
+
return Object_setAdditionalItems(schema, "strict", true);
|
|
2204
|
+
};
|
|
2205
|
+
var jsonEncoderFn = (input, target) => {
|
|
2206
|
+
const toTagFlag = tagFlags[target.type];
|
|
2207
|
+
if (flagUnsafeHas(toTagFlag, 46)) return parse(B_refine(input, unknown, void 0, target));
|
|
2208
|
+
else if (flagUnsafeHas(toTagFlag, 2064)) {
|
|
2209
|
+
const jsonExpected = copySchema(nullLiteral());
|
|
2210
|
+
jsonExpected.to = target;
|
|
2211
|
+
return parse(B_refine(input, unknown, void 0, jsonExpected));
|
|
2212
|
+
} else if (flagUnsafeHas(toTagFlag, tagFlagArray)) {
|
|
2213
|
+
const output = parse(B_refine(input, unknown, void 0, array(unknown)));
|
|
2214
|
+
output.s.additionalItems = json();
|
|
2215
|
+
output.e = target;
|
|
2216
|
+
output.io = false;
|
|
2217
|
+
return output;
|
|
2218
|
+
} else if (flagUnsafeHas(toTagFlag, tagFlagObject)) {
|
|
2219
|
+
const output = parse(B_refine(input, unknown, void 0, dictFactory(unknown)));
|
|
2220
|
+
output.s.additionalItems = json();
|
|
2221
|
+
output.e = target;
|
|
2222
|
+
output.io = false;
|
|
2223
|
+
return output;
|
|
2224
|
+
} else if (flagUnsafeHas(toTagFlag, 768)) return input;
|
|
2225
|
+
else {
|
|
2226
|
+
const jsonExpected = copySchema(string());
|
|
2227
|
+
jsonExpected.to = target;
|
|
2228
|
+
return parse(B_refine(input, unknown, void 0, jsonExpected));
|
|
2229
|
+
}
|
|
2230
|
+
};
|
|
2231
|
+
var isJsonable = (schema) => {
|
|
2232
|
+
const tagFlag = tagFlags[schema.type];
|
|
2233
|
+
return flagUnsafeHas(tagFlag, 46) || schema["$ref"] === json()["$ref"] || flagUnsafeHas(tagFlag, tagFlagUnion) && schema.anyOf.every(isJsonable) || flagUnsafeHas(tagFlag, tagFlagArray) && (typeof schema.additionalItems === "object" ? isJsonable(schema.additionalItems) : true) && schema.items.every(isJsonable) || flagUnsafeHas(tagFlag, tagFlagObject) && (typeof schema.additionalItems === "object" ? isJsonable(schema.additionalItems) : true) && Object.values(schema.properties).every(isJsonable);
|
|
2234
|
+
};
|
|
2235
|
+
var jsonDecoderFn = (input) => {
|
|
2236
|
+
const inputTagFlag = tagFlags[input.s.type];
|
|
2237
|
+
if (isJsonable(input.s)) return input;
|
|
2238
|
+
else if (flagUnsafeHas(inputTagFlag, 2064)) return B_nextConst(input, nullLiteral());
|
|
2239
|
+
else if (flagUnsafeHas(inputTagFlag, tagFlagArray)) {
|
|
2240
|
+
const expected = baseSchema(arrayTag, false);
|
|
2241
|
+
expected.items = input.s.items.map((_) => json());
|
|
2242
|
+
expected.decoder = arrayDecoder;
|
|
2243
|
+
expected.additionalItems = typeof input.s.additionalItems === "object" ? json() : input.s.additionalItems;
|
|
2244
|
+
expected.to = input.e.to;
|
|
2245
|
+
return parse(B_refine(input, void 0, void 0, expected));
|
|
2246
|
+
} else if (flagUnsafeHas(inputTagFlag, tagFlagObject)) if (typeof input.s.additionalItems === "object") {
|
|
2247
|
+
const expected = dictFactory(json());
|
|
2248
|
+
expected.to = input.e.to;
|
|
2249
|
+
return parse(B_refine(input, void 0, void 0, expected));
|
|
2250
|
+
} else {
|
|
2251
|
+
const jsonVal = makeObjectVal(input, input.s);
|
|
2252
|
+
jsonVal.e = json();
|
|
2253
|
+
if (input.e.to) {
|
|
2254
|
+
jsonVal.e = copySchema(jsonVal.e);
|
|
2255
|
+
jsonVal.e.to = input.e.to;
|
|
2256
|
+
}
|
|
2257
|
+
const keys = Object.keys(input.s.properties);
|
|
2258
|
+
for (let idx = 0; idx <= keys.length - 1; idx++) {
|
|
2259
|
+
const key = keys[idx];
|
|
2260
|
+
const itemVal = valGet(input, key);
|
|
2261
|
+
itemVal.io = false;
|
|
2262
|
+
if (itemVal.s.type === unionTag && itemVal.s.has[undefinedTag]) {
|
|
2263
|
+
itemVal.e = unionFactory([unit(), json()]);
|
|
2264
|
+
const itemOutput = parse(itemVal);
|
|
2265
|
+
itemOutput.o = true;
|
|
2266
|
+
B_addObjectField(jsonVal, key, itemOutput);
|
|
2267
|
+
} else {
|
|
2268
|
+
itemVal.e = json();
|
|
2269
|
+
B_addObjectField(jsonVal, key, parse(itemVal));
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2272
|
+
return completeObjectVal(jsonVal);
|
|
2273
|
+
}
|
|
2274
|
+
else if (flagUnsafeHas(inputTagFlag, tagFlagRef)) return recursiveDecoder(input);
|
|
2275
|
+
else if (flagUnsafeHas(inputTagFlag, tagFlagUnion) && !(undefinedTag in input.s.has)) return parse(unionPerVariantVal(input, input.e));
|
|
2276
|
+
else if (flagUnsafeHas(inputTagFlag, tagFlagUnknown)) if (!!input.e.to && !input.e.parser) {
|
|
2277
|
+
input.s = json();
|
|
2278
|
+
return jsonEncoderFn(input, input.e);
|
|
2279
|
+
} else if (input.e.noValidation) {
|
|
2280
|
+
input.s = json();
|
|
2281
|
+
return input;
|
|
2282
|
+
} else return recursiveDecoder(input);
|
|
2283
|
+
else try {
|
|
2284
|
+
const expected = copySchema(string());
|
|
2285
|
+
expected.to = input.e;
|
|
2286
|
+
input.e = expected;
|
|
2287
|
+
return parse(input);
|
|
2288
|
+
} catch {
|
|
2289
|
+
return B_unsupportedDecode(input, input.s, json());
|
|
2290
|
+
}
|
|
2291
|
+
};
|
|
2292
|
+
var json = () => {
|
|
2293
|
+
return cached(jsonName, refTag, (s2) => {
|
|
2294
|
+
const jsonRef = baseSchema(refTag, true);
|
|
2295
|
+
jsonRef["$ref"] = `${defsPath}${jsonName}`;
|
|
2296
|
+
jsonRef.name = jsonName;
|
|
2297
|
+
jsonRef.decoder = jsonDecoderFn;
|
|
2298
|
+
const jsonEncoder = jsonEncoderFn;
|
|
2299
|
+
jsonRef.encoder = jsonEncoder;
|
|
2300
|
+
s2["$ref"] = jsonRef["$ref"];
|
|
2301
|
+
s2.name = jsonName;
|
|
2302
|
+
s2.decoder = jsonDecoderFn;
|
|
2303
|
+
s2.encoder = jsonEncoder;
|
|
2304
|
+
const anyOf = [
|
|
2305
|
+
string(),
|
|
2306
|
+
bool(),
|
|
2307
|
+
float(),
|
|
2308
|
+
nullLiteral(),
|
|
2309
|
+
dictFactory(jsonRef),
|
|
2310
|
+
array(jsonRef)
|
|
2311
|
+
];
|
|
2312
|
+
const has = {};
|
|
2313
|
+
anyOf.forEach((schema) => {
|
|
2314
|
+
has[schema.type] = true;
|
|
2315
|
+
});
|
|
2316
|
+
const jsonDef = baseSchema(unionTag, true);
|
|
2317
|
+
jsonDef.anyOf = anyOf;
|
|
2318
|
+
jsonDef.has = has;
|
|
2319
|
+
jsonDef.decoder = unionDecoder;
|
|
2320
|
+
jsonDef.name = jsonName;
|
|
2321
|
+
jsonDef.type = unionTag;
|
|
2322
|
+
const defs = {};
|
|
2323
|
+
defs[jsonName] = jsonDef;
|
|
2324
|
+
s2["$defs"] = defs;
|
|
2325
|
+
});
|
|
2326
|
+
};
|
|
2327
|
+
var jsonString = /* @__PURE__ */ (() => {
|
|
2328
|
+
const inlineJsonString = (input, schema) => {
|
|
2329
|
+
const tagFlag = tagFlags[schema.type];
|
|
2330
|
+
const const_ = schema.const;
|
|
2331
|
+
if (flagUnsafeHas(tagFlag, 48)) return `"null"`;
|
|
2332
|
+
else if (flagUnsafeHas(tagFlag, tagFlagString)) return JSON.stringify(inlinedValueFromString(const_));
|
|
2333
|
+
else if (flagUnsafeHas(tagFlag, tagFlagBigint)) return `"\\"${const_}\\""`;
|
|
2334
|
+
else if (flagUnsafeHas(tagFlag, 12)) return `"${const_}"`;
|
|
2335
|
+
else return B_unsupportedDecode(input, schema, input.e);
|
|
2336
|
+
};
|
|
2337
|
+
const constSchemaToJsonStringConst = (input, target) => {
|
|
2338
|
+
const tagFlag = tagFlags[target.type];
|
|
2339
|
+
const const_ = target.const;
|
|
2340
|
+
if (flagUnsafeHas(tagFlag, 48)) return `null`;
|
|
2341
|
+
else if (flagUnsafeHas(tagFlag, tagFlagString)) return inlinedValueFromString(const_);
|
|
2342
|
+
else if (flagUnsafeHas(tagFlag, tagFlagBigint)) return `"${const_}"`;
|
|
2343
|
+
else if (flagUnsafeHas(tagFlag, 12)) return "" + const_;
|
|
2344
|
+
else return B_unsupportedDecode(input, input.s, target);
|
|
2345
|
+
};
|
|
2346
|
+
const jsonStringEncoder = (input, target) => {
|
|
2347
|
+
if (target.format !== "json") if (isLiteral(target)) {
|
|
2348
|
+
const jsonStringConstSchema = baseSchema(stringTag, true);
|
|
2349
|
+
jsonStringConstSchema.const = constSchemaToJsonStringConst(input, target);
|
|
2350
|
+
jsonStringConstSchema.to = target;
|
|
2351
|
+
jsonStringConstSchema.decoder = literalDecoder;
|
|
2352
|
+
return B_refine(input, void 0, void 0, jsonStringConstSchema);
|
|
2353
|
+
} else {
|
|
2354
|
+
const outputVar = B_varWithoutAllocation(input.g);
|
|
2355
|
+
const nextSchema = copySchema(json());
|
|
2356
|
+
nextSchema.to = target;
|
|
2357
|
+
const output = B_next(input, outputVar, nextSchema, nextSchema);
|
|
2358
|
+
output.io = true;
|
|
2359
|
+
output.v = _var;
|
|
2360
|
+
output.cp = `let ${outputVar};try{${outputVar}=JSON.parse(${input.v()})}catch(t){${B_embedInvalidInput(input, input.s)}}`;
|
|
2361
|
+
return output;
|
|
2362
|
+
}
|
|
2363
|
+
else return input;
|
|
2364
|
+
};
|
|
2365
|
+
const jsonStringDecoder = (input) => {
|
|
2366
|
+
const inputTagFlag = tagFlags[input.s.type];
|
|
2367
|
+
const expectedSchema = input.e;
|
|
2368
|
+
if (flagUnsafeHas(inputTagFlag, tagFlagUnknown)) {
|
|
2369
|
+
const to = expectedSchema.to;
|
|
2370
|
+
const preEncode = !!to && to.type !== unknownTag && !expectedSchema.parser && !expectedSchema.refiner;
|
|
2371
|
+
const stringVal = stringDecoderFn(input);
|
|
2372
|
+
stringVal.s = expectedSchema;
|
|
2373
|
+
stringVal.e = expectedSchema;
|
|
2374
|
+
if (preEncode) return jsonStringEncoder(stringVal, to);
|
|
2375
|
+
else {
|
|
2376
|
+
const stringVar = stringVal.v();
|
|
2377
|
+
const output = B_refine(stringVal, expectedSchema);
|
|
2378
|
+
output.cp = `try{JSON.parse(${stringVar})}catch(t){${B_embedInvalidInput(stringVal)}}`;
|
|
2379
|
+
return output;
|
|
2380
|
+
}
|
|
2381
|
+
} else if (input.s.format === "json") return input;
|
|
2382
|
+
else if (isLiteral(input.s)) return B_next(input, inlineJsonString(input, input.s), expectedSchema);
|
|
2383
|
+
else if (flagUnsafeHas(inputTagFlag, tagFlagString)) return B_next(input, `JSON.stringify(${input.i})`, expectedSchema);
|
|
2384
|
+
else if (flagUnsafeHas(inputTagFlag, 12)) {
|
|
2385
|
+
const output = inputToString(input);
|
|
2386
|
+
output.s = expectedSchema;
|
|
2387
|
+
return output;
|
|
2388
|
+
} else if (flagUnsafeHas(inputTagFlag, tagFlagBigint)) return B_next(input, `"\\""+${input.i}+"\\""`, expectedSchema);
|
|
2389
|
+
else if (flagUnsafeHas(inputTagFlag, 192)) {
|
|
2390
|
+
const jsonVal = parse(B_refine(input, void 0, void 0, json()));
|
|
2391
|
+
return B_next(jsonVal, `JSON.stringify(${jsonVal.i}${expectedSchema.space === 0 || expectedSchema.space === void 0 ? "" : `,null,${expectedSchema.space}`})`, expectedSchema, expectedSchema);
|
|
2392
|
+
} else return B_unsupportedDecode(input, input.s, expectedSchema);
|
|
2393
|
+
};
|
|
2394
|
+
return () => cached("json", stringTag, (s2) => {
|
|
2395
|
+
s2.format = "json";
|
|
2396
|
+
s2.name = `${jsonName} string`;
|
|
2397
|
+
s2.encoder = jsonStringEncoder;
|
|
2398
|
+
s2.decoder = jsonStringDecoder;
|
|
2399
|
+
});
|
|
2400
|
+
})();
|
|
2401
|
+
var jsonStringWithSpace = (space) => {
|
|
2402
|
+
const mut = copySchema(jsonString());
|
|
2403
|
+
mut.space = space;
|
|
2404
|
+
return mut;
|
|
2405
|
+
};
|
|
2406
|
+
var uint8Array = () => {
|
|
2407
|
+
return cached("u", instanceTag, (s2) => {
|
|
2408
|
+
s2.class = Uint8Array;
|
|
2409
|
+
s2.decoder = (inputArg) => {
|
|
2410
|
+
const inputTagFlag = tagFlags[inputArg.s.type];
|
|
2411
|
+
let input = inputArg;
|
|
2412
|
+
if (flagUnsafeHas(inputTagFlag, tagFlagString)) input = B_next(input, `${B_embed(input, new TextEncoder())}.encode(${input.i})`, s2);
|
|
2413
|
+
else if (flagUnsafeHas(inputTagFlag, 8193)) input = instanceDecoder(input);
|
|
2414
|
+
if (inputArg.e.to !== void 0 && inputArg.e.parser === void 0) {
|
|
2415
|
+
const toTagFlag = tagFlags[inputArg.e.to.type];
|
|
2416
|
+
if (flagUnsafeHas(toTagFlag, tagFlagString)) input = B_next(input, `${B_embed(input, new TextDecoder())}.decode(${input.i})`, string());
|
|
2417
|
+
return input;
|
|
2418
|
+
} else return input;
|
|
2419
|
+
};
|
|
2420
|
+
});
|
|
2421
|
+
};
|
|
2422
|
+
var isoDateTime = () => {
|
|
2423
|
+
return cached("date-time", stringTag, (s2) => {
|
|
2424
|
+
const datetimeRe = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?Z$/;
|
|
2425
|
+
s2.decoder = stringDecoderFn;
|
|
2426
|
+
s2.format = "date-time";
|
|
2427
|
+
s2.refiner = (input) => {
|
|
2428
|
+
return [{
|
|
2429
|
+
c: (inputVar) => `${B_embed(input, datetimeRe)}.test(${inputVar})`,
|
|
2430
|
+
f: B_failWithErrorMessage("format", "Invalid datetime string! Expected UTC")
|
|
2431
|
+
}];
|
|
2432
|
+
};
|
|
2433
|
+
});
|
|
2434
|
+
};
|
|
2435
|
+
var port = () => {
|
|
2436
|
+
return cached("port", numberTag, (s2) => {
|
|
2437
|
+
s2.decoder = numberDecoder;
|
|
2438
|
+
s2.format = "port";
|
|
2439
|
+
s2.refiner = (_input) => {
|
|
2440
|
+
return [{
|
|
2441
|
+
c: (inputVar) => `${inputVar}>0&&${inputVar}<65536&&${inputVar}%1===0`,
|
|
2442
|
+
f: B_failWithErrorMessage("format")
|
|
2443
|
+
}];
|
|
2444
|
+
};
|
|
2445
|
+
});
|
|
2446
|
+
};
|
|
2447
|
+
var email = () => {
|
|
2448
|
+
return cached("email", stringTag, (s2) => {
|
|
2449
|
+
const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
2450
|
+
s2.decoder = stringDecoderFn;
|
|
2451
|
+
s2.format = "email";
|
|
2452
|
+
s2.refiner = (input) => {
|
|
2453
|
+
return [{
|
|
2454
|
+
c: (inputVar) => `${B_embed(input, emailRegex)}.test(${inputVar})`,
|
|
2455
|
+
f: B_failWithErrorMessage("format")
|
|
2456
|
+
}];
|
|
2457
|
+
};
|
|
2458
|
+
});
|
|
2459
|
+
};
|
|
2460
|
+
var uuid = () => {
|
|
2461
|
+
return cached("uuid", stringTag, (s2) => {
|
|
2462
|
+
const uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
|
|
2463
|
+
s2.decoder = stringDecoderFn;
|
|
2464
|
+
s2.format = "uuid";
|
|
2465
|
+
s2.refiner = (input) => {
|
|
2466
|
+
return [{
|
|
2467
|
+
c: (inputVar) => `${B_embed(input, uuidRegex)}.test(${inputVar})`,
|
|
2468
|
+
f: B_failWithErrorMessage("format")
|
|
2469
|
+
}];
|
|
2470
|
+
};
|
|
2471
|
+
});
|
|
2472
|
+
};
|
|
2473
|
+
var cuid = () => {
|
|
2474
|
+
return cached("cuid", stringTag, (s2) => {
|
|
2475
|
+
const cuidRegex = /^c[^\s-]{8,}$/i;
|
|
2476
|
+
s2.decoder = stringDecoderFn;
|
|
2477
|
+
s2.format = "cuid";
|
|
2478
|
+
s2.refiner = (input) => {
|
|
2479
|
+
return [{
|
|
2480
|
+
c: (inputVar) => `${B_embed(input, cuidRegex)}.test(${inputVar})`,
|
|
2481
|
+
f: B_failWithErrorMessage("format")
|
|
2482
|
+
}];
|
|
2483
|
+
};
|
|
2484
|
+
});
|
|
2485
|
+
};
|
|
2486
|
+
var url = () => {
|
|
2487
|
+
return cached("url", stringTag, (s2) => {
|
|
2488
|
+
const urlValidator = (s3) => {
|
|
2489
|
+
try {
|
|
2490
|
+
new URL(s3);
|
|
2491
|
+
return true;
|
|
2492
|
+
} catch {
|
|
2493
|
+
return false;
|
|
2494
|
+
}
|
|
2495
|
+
};
|
|
2496
|
+
s2.decoder = stringDecoderFn;
|
|
2497
|
+
s2.format = "url";
|
|
2498
|
+
s2.refiner = (input) => {
|
|
2499
|
+
return [{
|
|
2500
|
+
c: (inputVar) => `${B_embed(input, urlValidator)}(${inputVar})`,
|
|
2501
|
+
f: B_failWithErrorMessage("format")
|
|
2502
|
+
}];
|
|
2503
|
+
};
|
|
2504
|
+
});
|
|
2505
|
+
};
|
|
2506
|
+
var invalidDateRefine = (input) => {
|
|
2507
|
+
return B_refine(input, input.e, [{
|
|
2508
|
+
c: (inputVar) => `!Number.isNaN(${inputVar}.getTime())`,
|
|
2509
|
+
f: failInvalidType
|
|
2510
|
+
}]);
|
|
2511
|
+
};
|
|
2512
|
+
var date = () => {
|
|
2513
|
+
return cached(instanceTag, instanceTag, (s2) => {
|
|
2514
|
+
s2.class = Date;
|
|
2515
|
+
s2.decoder = (input) => {
|
|
2516
|
+
const inputTagFlag = tagFlags[input.s.type];
|
|
2517
|
+
if (flagUnsafeHas(inputTagFlag, tagFlagString)) return invalidDateRefine(B_next(input, `new Date(${input.i})`, s2));
|
|
2518
|
+
else if (flagUnsafeHas(inputTagFlag, tagFlagUnknown)) return invalidDateRefine(instanceDecoder(input));
|
|
2519
|
+
else if (flagUnsafeHas(inputTagFlag, tagFlagInstance) && input.s.class === s2.class) return input;
|
|
2520
|
+
else return B_unsupportedDecode(input, input.s, input.e);
|
|
2521
|
+
};
|
|
2522
|
+
s2.encoder = (input, target) => {
|
|
2523
|
+
const toTagFlag = tagFlags[target.type];
|
|
2524
|
+
if (flagUnsafeHas(toTagFlag, tagFlagString)) {
|
|
2525
|
+
const dateTimeString = baseSchema(stringTag, false);
|
|
2526
|
+
dateTimeString.format = "date-time";
|
|
2527
|
+
return parse(B_next(input, `${input.i}.toISOString()`, dateTimeString, target));
|
|
2528
|
+
} else return input;
|
|
2529
|
+
};
|
|
2530
|
+
});
|
|
2531
|
+
};
|
|
2532
|
+
var listFromArray = (array2) => {
|
|
2533
|
+
let list2 = 0;
|
|
2534
|
+
for (let i = array2.length - 1; i >= 0; i--) list2 = {
|
|
2535
|
+
hd: array2[i],
|
|
2536
|
+
tl: list2
|
|
2537
|
+
};
|
|
2538
|
+
return list2;
|
|
2539
|
+
};
|
|
2540
|
+
var listToArray = (list2) => {
|
|
2541
|
+
const array2 = [];
|
|
2542
|
+
let current = list2;
|
|
2543
|
+
while (current !== 0) {
|
|
2544
|
+
array2.push(current.hd);
|
|
2545
|
+
current = current.tl;
|
|
2546
|
+
}
|
|
2547
|
+
return array2;
|
|
2548
|
+
};
|
|
2549
|
+
var list = (schema) => {
|
|
2550
|
+
return transform(array(schema), (_) => ({
|
|
2551
|
+
p: (array2) => listFromArray(array2),
|
|
2552
|
+
s: (list2) => listToArray(list2)
|
|
2553
|
+
}));
|
|
2554
|
+
};
|
|
2555
|
+
var meta = (schema, data) => {
|
|
2556
|
+
const mut = copySchema(schema);
|
|
2557
|
+
if (data.name !== void 0) if (data.name === "") mut.name = void 0;
|
|
2558
|
+
else mut.name = data.name;
|
|
2559
|
+
if (data.title !== void 0) if (data.title === "") mut.title = void 0;
|
|
2560
|
+
else mut.title = data.title;
|
|
2561
|
+
if (data.description !== void 0) if (data.description === "") mut.description = void 0;
|
|
2562
|
+
else mut.description = data.description;
|
|
2563
|
+
if (data.deprecated !== void 0) mut.deprecated = data.deprecated;
|
|
2564
|
+
if (data.examples !== void 0) if (data.examples.length === 0) delete mut.examples;
|
|
2565
|
+
else mut.examples = data.examples.map(getDecoder(reverse(schema)));
|
|
2566
|
+
if (data.errorMessage !== void 0) {
|
|
2567
|
+
const em = data.errorMessage;
|
|
2568
|
+
if (Object.keys(em).length === 0) mut.errorMessage = void 0;
|
|
2569
|
+
else mut.errorMessage = em;
|
|
2570
|
+
}
|
|
2571
|
+
return mut;
|
|
2572
|
+
};
|
|
2573
|
+
var brand = (schema, id) => {
|
|
2574
|
+
const mut = copySchema(schema);
|
|
2575
|
+
mut.name = id;
|
|
2576
|
+
return mut;
|
|
2577
|
+
};
|
|
2578
|
+
var inputFrom = immutableEmptyArray;
|
|
2579
|
+
var makeTag = (field) => (tag, asValue) => {
|
|
2580
|
+
field(tag, definitionToSchema(asValue));
|
|
2581
|
+
};
|
|
2582
|
+
var makeFieldOr = (field) => (fieldName, schema, or) => {
|
|
2583
|
+
return field(fieldName, Option_getOr(optionFactory(schema), or));
|
|
2584
|
+
};
|
|
2585
|
+
var proxifyShapedSchema = (schema, from, fromFlattened) => {
|
|
2586
|
+
const mut = copySchema(getOutputSchema(schema));
|
|
2587
|
+
mut.from = from;
|
|
2588
|
+
if (fromFlattened !== void 0) mut.fromFlattened = fromFlattened;
|
|
2589
|
+
return new Proxy(mut, { get(target, prop) {
|
|
2590
|
+
if (prop === itemSymbol) return target;
|
|
2591
|
+
else {
|
|
2592
|
+
const location = prop;
|
|
2593
|
+
let maybeField;
|
|
2594
|
+
if (target.properties !== void 0) maybeField = target.properties[location];
|
|
2595
|
+
else if (target.items !== void 0) maybeField = target.items[location];
|
|
2596
|
+
else maybeField = void 0;
|
|
2597
|
+
if (maybeField === void 0) panic(`Cannot read property "${location}" of ${toExpression(target)}`);
|
|
2598
|
+
return proxifyShapedSchema(maybeField, target.from.concat(location), target.fromFlattened);
|
|
2599
|
+
}
|
|
2600
|
+
} });
|
|
2601
|
+
};
|
|
2602
|
+
var schemaShape = (schema, definer) => {
|
|
2603
|
+
return updateOutput(schema, (mut) => {
|
|
2604
|
+
const fromProxy = proxifyShapedSchema(mut, inputFrom);
|
|
2605
|
+
const definition = definer(fromProxy);
|
|
2606
|
+
if (definition === fromProxy) {} else {
|
|
2607
|
+
mut.parser = shapedParser;
|
|
2608
|
+
mut.to = definitionToShapedSchema(definition);
|
|
2609
|
+
}
|
|
2610
|
+
});
|
|
2611
|
+
};
|
|
2612
|
+
function schemaNested(fieldName) {
|
|
2613
|
+
const parentCtx = this;
|
|
2614
|
+
const cacheId = `~${fieldName}`;
|
|
2615
|
+
const cachedCtx = parentCtx[cacheId];
|
|
2616
|
+
if (cachedCtx !== void 0) return cachedCtx;
|
|
2617
|
+
else {
|
|
2618
|
+
const properties = /* @__PURE__ */ Object.create(null);
|
|
2619
|
+
const required = [];
|
|
2620
|
+
let schema;
|
|
2621
|
+
{
|
|
2622
|
+
const s2 = baseSchema(objectTag, false);
|
|
2623
|
+
s2.required = required;
|
|
2624
|
+
s2.properties = properties;
|
|
2625
|
+
s2.additionalItems = globalConfig.a;
|
|
2626
|
+
s2.decoder = objectDecoder;
|
|
2627
|
+
schema = s2;
|
|
2628
|
+
}
|
|
2629
|
+
const parentSchema = parentCtx.f(fieldName, schema)[itemSymbol];
|
|
2630
|
+
const field = (fieldName2, schema2) => {
|
|
2631
|
+
const inlinedLocation = inlinedValueFromString(fieldName2);
|
|
2632
|
+
if (fieldName2 in properties) panic(`The field ${inlinedLocation} defined twice`);
|
|
2633
|
+
required.push(fieldName2);
|
|
2634
|
+
properties[fieldName2] = schema2;
|
|
2635
|
+
return proxifyShapedSchema(schema2, parentSchema.from.concat(fieldName2), parentSchema.fromFlattened);
|
|
2636
|
+
};
|
|
2637
|
+
const tag = makeTag(field);
|
|
2638
|
+
const fieldOr = makeFieldOr(field);
|
|
2639
|
+
const flatten = (schema2) => {
|
|
2640
|
+
if (schema2.type === objectTag) {
|
|
2641
|
+
const flattenedProperties = schema2.properties;
|
|
2642
|
+
if (schema2.to) panic(`Unsupported nested flatten for transformed object schema ${toExpression(schema2)}`);
|
|
2643
|
+
const flattenedKeys = Object.keys(flattenedProperties);
|
|
2644
|
+
const result = {};
|
|
2645
|
+
for (let idx = 0; idx < flattenedKeys.length; idx++) {
|
|
2646
|
+
const key = flattenedKeys[idx];
|
|
2647
|
+
result[key] = field(key, flattenedProperties[key]);
|
|
2648
|
+
}
|
|
2649
|
+
return result;
|
|
2650
|
+
} else return panic(`Can't flatten ${toExpression(schema2)} schema`);
|
|
2651
|
+
};
|
|
2652
|
+
const ctx = {
|
|
2653
|
+
field,
|
|
2654
|
+
f: field,
|
|
2655
|
+
fieldOr,
|
|
2656
|
+
tag,
|
|
2657
|
+
nested: schemaNested,
|
|
2658
|
+
flatten
|
|
2659
|
+
};
|
|
2660
|
+
parentCtx[cacheId] = ctx;
|
|
2661
|
+
return ctx;
|
|
2662
|
+
}
|
|
2663
|
+
}
|
|
2664
|
+
var schemaObject = (definer) => {
|
|
2665
|
+
if (typeof definer !== "function") return definitionToSchema(definer);
|
|
2666
|
+
let flattened = void 0;
|
|
2667
|
+
const properties = /* @__PURE__ */ Object.create(null);
|
|
2668
|
+
const flatten = (schema) => {
|
|
2669
|
+
if (schema.type === objectTag) {
|
|
2670
|
+
const flattenedProperties = schema.properties;
|
|
2671
|
+
const flattenedKeys = Object.keys(flattenedProperties);
|
|
2672
|
+
for (let idx = 0; idx < flattenedKeys.length; idx++) {
|
|
2673
|
+
const key = flattenedKeys[idx];
|
|
2674
|
+
const flattenedSchema = flattenedProperties[key];
|
|
2675
|
+
const existing = properties[key];
|
|
2676
|
+
if (existing !== void 0 && existing === flattenedSchema) {} else if (existing !== void 0) panic(`The field "${key}" defined twice with incompatible schemas`);
|
|
2677
|
+
else properties[key] = flattenedSchema;
|
|
2678
|
+
}
|
|
2679
|
+
return proxifyShapedSchema(schema, inputFrom, (flattened || (flattened = [])).push(schema) - 1);
|
|
2680
|
+
} else return panic(`The '${toExpression(schema)}' schema can't be flattened`);
|
|
2681
|
+
};
|
|
2682
|
+
const field = (fieldName, schema) => {
|
|
2683
|
+
if (fieldName in properties) panic(`The field "${fieldName}" defined twice with incompatible schemas`);
|
|
2684
|
+
properties[fieldName] = schema;
|
|
2685
|
+
return proxifyShapedSchema(schema, [fieldName]);
|
|
2686
|
+
};
|
|
2687
|
+
const tag = makeTag(field);
|
|
2688
|
+
const definition = definer({
|
|
2689
|
+
field,
|
|
2690
|
+
f: field,
|
|
2691
|
+
fieldOr: makeFieldOr(field),
|
|
2692
|
+
tag,
|
|
2693
|
+
nested: schemaNested,
|
|
2694
|
+
flatten
|
|
2695
|
+
});
|
|
2696
|
+
const mut = baseSchema(objectTag, false);
|
|
2697
|
+
mut.required = Object.keys(properties);
|
|
2698
|
+
mut.properties = properties;
|
|
2699
|
+
mut.additionalItems = globalConfig.a;
|
|
2700
|
+
mut.decoder = objectDecoder;
|
|
2701
|
+
mut.parser = shapedParser;
|
|
2702
|
+
mut.to = definitionToShapedSchema(definition);
|
|
2703
|
+
if (flattened !== void 0) mut.flattened = flattened;
|
|
2704
|
+
return mut;
|
|
2705
|
+
};
|
|
2706
|
+
var schemaTuple = (definer) => {
|
|
2707
|
+
if (typeof definer !== "function") return definitionToSchema(definer);
|
|
2708
|
+
const items = [];
|
|
2709
|
+
const item = (idx, schema) => {
|
|
2710
|
+
const location = String(idx);
|
|
2711
|
+
if (items[idx]) return panic(`The item [${location}] is defined multiple times`);
|
|
2712
|
+
else {
|
|
2713
|
+
items[idx] = schema;
|
|
2714
|
+
return proxifyShapedSchema(schema, [location]);
|
|
2715
|
+
}
|
|
2716
|
+
};
|
|
2717
|
+
const tag = (idx, asValue) => {
|
|
2718
|
+
item(idx, definitionToSchema(asValue));
|
|
2719
|
+
};
|
|
2720
|
+
const definition = definer({
|
|
2721
|
+
item,
|
|
2722
|
+
tag
|
|
2723
|
+
});
|
|
2724
|
+
for (let idx = 0; idx < items.length; idx++) if (!items[idx]) items[idx] = unit();
|
|
2725
|
+
const mut = baseSchema(arrayTag, false);
|
|
2726
|
+
mut.items = items;
|
|
2727
|
+
mut.additionalItems = "strict";
|
|
2728
|
+
mut.decoder = arrayDecoder;
|
|
2729
|
+
mut.parser = shapedParser;
|
|
2730
|
+
mut.to = definitionToShapedSchema(definition);
|
|
2731
|
+
return mut;
|
|
2732
|
+
};
|
|
2733
|
+
var getValByFrom = (input, from, idx) => {
|
|
2734
|
+
const key = from[idx];
|
|
2735
|
+
if (key !== void 0) return getValByFrom(input.d[key], from, idx + 1);
|
|
2736
|
+
else return input;
|
|
2737
|
+
};
|
|
2738
|
+
var assembleShapedObject = (input, schema, field, init, onMissing) => {
|
|
2739
|
+
const output = makeObjectVal(input, schema);
|
|
2740
|
+
output.io = true;
|
|
2741
|
+
if (init !== void 0) init(output);
|
|
2742
|
+
if (schema.items !== void 0) {
|
|
2743
|
+
const items = schema.items;
|
|
2744
|
+
for (let idx = 0; idx < items.length; idx++) {
|
|
2745
|
+
const location = String(idx);
|
|
2746
|
+
B_addObjectField(output, location, field(location, items[idx]));
|
|
2747
|
+
}
|
|
2748
|
+
} else if (schema.properties !== void 0) {
|
|
2749
|
+
const properties = schema.properties;
|
|
2750
|
+
const keys = Object.keys(properties);
|
|
2751
|
+
for (let idx = 0; idx < keys.length; idx++) {
|
|
2752
|
+
const location = keys[idx];
|
|
2753
|
+
if (!(location in output.d)) B_addObjectField(output, location, field(location, properties[location]));
|
|
2754
|
+
}
|
|
2755
|
+
} else if (onMissing !== void 0) onMissing();
|
|
2756
|
+
else panic(`Don't know where the value is coming from: ${toExpression(schema)}` + (input.path === "" ? "" : ` at ${input.path}`));
|
|
2757
|
+
return completeObjectVal(output);
|
|
2758
|
+
};
|
|
2759
|
+
var getShapedParserOutput = (input, targetSchema) => {
|
|
2760
|
+
let v;
|
|
2761
|
+
if (targetSchema.fromFlattened !== void 0) v = B_scope(getValByFrom(input.fv[targetSchema.fromFlattened], targetSchema.from, 0));
|
|
2762
|
+
else if (targetSchema.from !== void 0) v = B_scope(getValByFrom(input, targetSchema.from, 0));
|
|
2763
|
+
else if (isLiteral(targetSchema)) v = B_nextConst(input, targetSchema);
|
|
2764
|
+
else v = assembleShapedObject(input, targetSchema, (_location, childSchema) => getShapedParserOutput(input, childSchema));
|
|
2765
|
+
v.prev = void 0;
|
|
2766
|
+
v.e = targetSchema;
|
|
2767
|
+
return v;
|
|
2768
|
+
};
|
|
2769
|
+
var shapedParser = (input) => {
|
|
2770
|
+
const flattened = input.e.flattened;
|
|
2771
|
+
if (flattened !== void 0) {
|
|
2772
|
+
const flattenedVals = [];
|
|
2773
|
+
for (let idx = 0; idx < flattened.length; idx++) {
|
|
2774
|
+
const flattenedSchema = flattened[idx];
|
|
2775
|
+
let flattenedVal;
|
|
2776
|
+
if (flattenedSchema.to !== void 0) {
|
|
2777
|
+
const flattenedInput = B_scope(input);
|
|
2778
|
+
flattenedInput.e = flattenedSchema;
|
|
2779
|
+
flattenedInput.io = true;
|
|
2780
|
+
flattenedVal = parse(flattenedInput);
|
|
2781
|
+
} else {
|
|
2782
|
+
const assembled = assembleShapedObject(input, flattenedSchema, (location, _childSchema) => valGet(input, location));
|
|
2783
|
+
assembled.e = flattenedSchema;
|
|
2784
|
+
assembled.prev = void 0;
|
|
2785
|
+
flattenedVal = B_markOutput(assembled, assembled);
|
|
2786
|
+
}
|
|
2787
|
+
flattenedVals.push(flattenedVal);
|
|
2788
|
+
input.cp = input.cp + B_merge(flattenedVal);
|
|
2789
|
+
}
|
|
2790
|
+
input.fv = flattenedVals;
|
|
2791
|
+
}
|
|
2792
|
+
const targetSchema = input.e.to;
|
|
2793
|
+
const output = getShapedParserOutput(input, targetSchema);
|
|
2794
|
+
output.t = true;
|
|
2795
|
+
output.prev = input;
|
|
2796
|
+
return B_markOutput(output, input);
|
|
2797
|
+
};
|
|
2798
|
+
var prepareShapedSerializerAcc = (acc, input) => {
|
|
2799
|
+
if (input.e.from !== void 0) {
|
|
2800
|
+
const from = input.e.from;
|
|
2801
|
+
const fromFlattened = input.e.fromFlattened;
|
|
2802
|
+
let accAtFrom;
|
|
2803
|
+
if (fromFlattened !== void 0) {
|
|
2804
|
+
if (acc.flattened === void 0) acc.flattened = [];
|
|
2805
|
+
const existing = acc.flattened[fromFlattened];
|
|
2806
|
+
if (existing === void 0) {
|
|
2807
|
+
const newAcc = {};
|
|
2808
|
+
acc.flattened[fromFlattened] = newAcc;
|
|
2809
|
+
accAtFrom = newAcc;
|
|
2810
|
+
} else accAtFrom = existing;
|
|
2811
|
+
} else accAtFrom = acc;
|
|
2812
|
+
for (let idx = 0; idx < from.length; idx++) {
|
|
2813
|
+
const key = from[idx];
|
|
2814
|
+
let p;
|
|
2815
|
+
if (accAtFrom.properties !== void 0) p = accAtFrom.properties;
|
|
2816
|
+
else {
|
|
2817
|
+
p = {};
|
|
2818
|
+
accAtFrom.properties = p;
|
|
2819
|
+
}
|
|
2820
|
+
const existingAcc = p[key];
|
|
2821
|
+
if (existingAcc !== void 0) accAtFrom = existingAcc;
|
|
2822
|
+
else {
|
|
2823
|
+
const newAcc = {};
|
|
2824
|
+
p[key] = newAcc;
|
|
2825
|
+
accAtFrom = newAcc;
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2828
|
+
accAtFrom.val = input;
|
|
2829
|
+
} else if (input.d !== void 0) {
|
|
2830
|
+
const vals = input.d;
|
|
2831
|
+
const keys = Object.keys(vals);
|
|
2832
|
+
for (let idx = 0; idx < keys.length; idx++) prepareShapedSerializerAcc(acc, vals[keys[idx]]);
|
|
2833
|
+
}
|
|
2834
|
+
};
|
|
2835
|
+
var getShapedSerializerOutput = (input, acc, targetSchema, path) => {
|
|
2836
|
+
if (acc !== void 0 && acc.val !== void 0) {
|
|
2837
|
+
const v = B_scope(acc.val);
|
|
2838
|
+
v.t = true;
|
|
2839
|
+
v.e = targetSchema;
|
|
2840
|
+
return parse(v);
|
|
2841
|
+
} else if (isLiteral(targetSchema)) {
|
|
2842
|
+
const v = B_nextConst(input, targetSchema, targetSchema);
|
|
2843
|
+
v.prev = void 0;
|
|
2844
|
+
v.p = input;
|
|
2845
|
+
v.v = _notVarAtParent;
|
|
2846
|
+
v.io = true;
|
|
2847
|
+
return parse(v);
|
|
2848
|
+
} else {
|
|
2849
|
+
const resolvedTargetSchema = acc === void 0 ? getOutputSchema(targetSchema) : targetSchema;
|
|
2850
|
+
const missingInput = () => {
|
|
2851
|
+
const path2 = targetSchema.from !== void 0 ? path + targetSchema.from.map((item) => `["${item}"]`).join("") : path;
|
|
2852
|
+
return B_invalidOperation(input, `Missing input for ${toExpression(targetSchema)}` + (path2 === "" ? "" : ` at ${path2}`));
|
|
2853
|
+
};
|
|
2854
|
+
if (acc === void 0 && typeof resolvedTargetSchema.additionalItems === objectTag) return missingInput();
|
|
2855
|
+
return assembleShapedObject(input, resolvedTargetSchema, (location, childSchema) => getShapedSerializerOutput(input, acc !== void 0 && acc.properties !== void 0 ? acc.properties[location] : void 0, childSchema, pathConcat(path, pathFromInlinedLocation(B_inlineLocation(input.g, location)))), (v) => {
|
|
2856
|
+
v.e = resolvedTargetSchema;
|
|
2857
|
+
v.prev = void 0;
|
|
2858
|
+
v.p = input;
|
|
2859
|
+
v.v = _notVarAtParent;
|
|
2860
|
+
const flattened = resolvedTargetSchema.flattened;
|
|
2861
|
+
if (flattened !== void 0 && acc !== void 0 && acc.flattened !== void 0) {
|
|
2862
|
+
const flattenedSchemas = flattened;
|
|
2863
|
+
acc.flattened.forEach((acc2, idx) => {
|
|
2864
|
+
B_mergeObjectFields(v, getShapedSerializerOutput(input, acc2, reverse(flattenedSchemas[idx]), path).d);
|
|
2865
|
+
});
|
|
2866
|
+
}
|
|
2867
|
+
}, missingInput);
|
|
2868
|
+
}
|
|
2869
|
+
};
|
|
2870
|
+
var shapedSerializer = (input) => {
|
|
2871
|
+
const acc = {};
|
|
2872
|
+
prepareShapedSerializerAcc(acc, input);
|
|
2873
|
+
const targetSchema = input.e.to;
|
|
2874
|
+
const output = getShapedSerializerOutput(input, acc, targetSchema, pathEmpty);
|
|
2875
|
+
output.t = true;
|
|
2876
|
+
output.prev = input;
|
|
2877
|
+
return output;
|
|
2878
|
+
};
|
|
2879
|
+
var definitionToShapedSchema = (definition) => {
|
|
2880
|
+
const s2 = copySchema(traverseDefinition(definition, (definition2) => definition2[itemSymbol]));
|
|
2881
|
+
s2.serializer = shapedSerializer;
|
|
2882
|
+
return s2;
|
|
2883
|
+
};
|
|
2884
|
+
var definitionToSchema = (definition) => {
|
|
2885
|
+
return traverseDefinition(definition, (node) => {
|
|
2886
|
+
if (isSchemaObject(node)) return node;
|
|
2887
|
+
else return;
|
|
2888
|
+
});
|
|
2889
|
+
};
|
|
2890
|
+
var traverseDefinition = (definition, onNode) => {
|
|
2891
|
+
if (typeof definition === objectTag && definition !== null) {
|
|
2892
|
+
const s2 = onNode(definition);
|
|
2893
|
+
if (s2 !== void 0) return s2;
|
|
2894
|
+
else if (Array.isArray(definition)) {
|
|
2895
|
+
const node = definition;
|
|
2896
|
+
for (let idx = 0; idx < node.length; idx++) node[idx] = traverseDefinition(node[idx], onNode);
|
|
2897
|
+
const items = node;
|
|
2898
|
+
const mut = baseSchema(arrayTag, false);
|
|
2899
|
+
mut.items = items;
|
|
2900
|
+
mut.additionalItems = "strict";
|
|
2901
|
+
mut.decoder = arrayDecoder;
|
|
2902
|
+
return mut;
|
|
2903
|
+
} else {
|
|
2904
|
+
const proto = Object.getPrototypeOf(definition);
|
|
2905
|
+
if (proto !== null && proto !== Object.prototype) {
|
|
2906
|
+
const mut = baseSchema(instanceTag, true);
|
|
2907
|
+
mut.class = definition["constructor"];
|
|
2908
|
+
mut.const = definition;
|
|
2909
|
+
mut.decoder = literalDecoder;
|
|
2910
|
+
return mut;
|
|
2911
|
+
} else {
|
|
2912
|
+
const node = definition;
|
|
2913
|
+
const fieldNames = Object.keys(node);
|
|
2914
|
+
const length2 = fieldNames.length;
|
|
2915
|
+
for (let idx = 0; idx < length2; idx++) {
|
|
2916
|
+
const location = fieldNames[idx];
|
|
2917
|
+
node[location] = traverseDefinition(node[location], onNode);
|
|
2918
|
+
}
|
|
2919
|
+
const mut = baseSchema(objectTag, false);
|
|
2920
|
+
mut.required = fieldNames;
|
|
2921
|
+
mut.properties = node;
|
|
2922
|
+
mut.additionalItems = globalConfig.a;
|
|
2923
|
+
mut.decoder = objectDecoder;
|
|
2924
|
+
return mut;
|
|
2925
|
+
}
|
|
2926
|
+
}
|
|
2927
|
+
} else return Literal_parse(definition);
|
|
2928
|
+
};
|
|
2929
|
+
var schemaCtx = { m: (schema) => schema };
|
|
2930
|
+
var schemaDefiner = (definer) => {
|
|
2931
|
+
return definitionToSchema(definer(schemaCtx));
|
|
2932
|
+
};
|
|
2933
|
+
var schemaFactory = (definition) => {
|
|
2934
|
+
return definitionToSchema(definition);
|
|
2935
|
+
};
|
|
2936
|
+
var enum_ = (values) => {
|
|
2937
|
+
return unionFactory(values.map(schemaFactory));
|
|
2938
|
+
};
|
|
2939
|
+
var js_parser = (...args) => getDecoder(unknown, ...args);
|
|
2940
|
+
var js_asyncParser = (...args) => getDecoder(unknown, ...args, 1);
|
|
2941
|
+
var js_asyncDecoder = (...args) => getDecoder(...args, 1);
|
|
2942
|
+
var js_encoder = (...args) => getDecoder(...args.map(reverse));
|
|
2943
|
+
var js_asyncEncoder = (...args) => getDecoder(...args.map(reverse), 1);
|
|
2944
|
+
var js_assert = (a, b) => {
|
|
2945
|
+
const aIsSchema = !!a && isSchemaObject(a);
|
|
2946
|
+
const schema = aIsSchema ? a : b;
|
|
2947
|
+
const data = aIsSchema ? b : a;
|
|
2948
|
+
return getDecoder(unknown, schema, getAssertResult())(data);
|
|
2949
|
+
};
|
|
2950
|
+
var js_is = (a, b) => {
|
|
2951
|
+
try {
|
|
2952
|
+
js_assert(a, b);
|
|
2953
|
+
return true;
|
|
2954
|
+
} catch (exn) {
|
|
2955
|
+
getOrRethrow(exn);
|
|
2956
|
+
return false;
|
|
2957
|
+
}
|
|
2958
|
+
};
|
|
2959
|
+
var js_union = (values) => unionFactory(values.map(definitionToSchema));
|
|
2960
|
+
var js_to = /* @__PURE__ */ (() => {
|
|
2961
|
+
const customBuilder = (fn) => {
|
|
2962
|
+
return (input) => {
|
|
2963
|
+
const target = input.e.to;
|
|
2964
|
+
const outputVar = B_varWithoutAllocation(input.g);
|
|
2965
|
+
const output = B_next(input, outputVar, target, target);
|
|
2966
|
+
output.v = _var;
|
|
2967
|
+
output.cp = `let ${outputVar};try{${output.i}=${B_embed(input, fn)}(${input.i})}catch(x){${B_failWithArg(output, (e) => B_makeInvalidConversionDetails(input, target, e), `x`)}}`;
|
|
2968
|
+
return output;
|
|
2969
|
+
};
|
|
2970
|
+
};
|
|
2971
|
+
return (schema, target, maybeDecoder, maybeEncoder) => {
|
|
2972
|
+
return updateOutput(schema, (mut) => {
|
|
2973
|
+
if (maybeEncoder !== void 0) {
|
|
2974
|
+
const targetMut = copySchema(target);
|
|
2975
|
+
targetMut.serializer = customBuilder(maybeEncoder);
|
|
2976
|
+
mut.to = targetMut;
|
|
2977
|
+
} else mut.to = target;
|
|
2978
|
+
if (maybeDecoder !== void 0) mut.parser = customBuilder(maybeDecoder);
|
|
2979
|
+
});
|
|
2980
|
+
};
|
|
2981
|
+
})();
|
|
2982
|
+
var js_refine = (schema, refineCheck, refineOptions) => {
|
|
2983
|
+
const message = refineOptions?.error ?? "Refinement failed";
|
|
2984
|
+
const extraPath = refineOptions?.path !== void 0 ? pathFromArray(refineOptions.path) : pathEmpty;
|
|
2985
|
+
return internalRefine(schema, (_) => (input) => {
|
|
2986
|
+
const embeddedCheck = B_embed(input, refineCheck);
|
|
2987
|
+
return [{
|
|
2988
|
+
c: (inputVar) => `${embeddedCheck}(${inputVar})`,
|
|
2989
|
+
f: B_invalidInputBuilder(void 0, extraPath, message)
|
|
2990
|
+
}];
|
|
2991
|
+
});
|
|
2992
|
+
};
|
|
2993
|
+
var noop = (a) => a;
|
|
2994
|
+
var js_asyncDecoderAssert = (schema, assertFn) => {
|
|
2995
|
+
return transform(schema, (_) => {
|
|
2996
|
+
return {
|
|
2997
|
+
a: (v) => assertFn(v).then(() => v),
|
|
2998
|
+
s: noop
|
|
2999
|
+
};
|
|
3000
|
+
});
|
|
3001
|
+
};
|
|
3002
|
+
var js_optional = (schema, maybeOr) => {
|
|
3003
|
+
schema = unionFactory([schema, unit()]);
|
|
3004
|
+
if (maybeOr !== void 0 && typeof maybeOr === functionTag) return Option_getOrWith(schema, maybeOr);
|
|
3005
|
+
else if (maybeOr !== void 0) return Option_getOr(schema, maybeOr);
|
|
3006
|
+
else return schema;
|
|
3007
|
+
};
|
|
3008
|
+
var js_nullable = (schema, maybeOr) => {
|
|
3009
|
+
if (maybeOr !== void 0) {
|
|
3010
|
+
const schema2 = unionFactory([schema, nullAsUnit()]);
|
|
3011
|
+
if (typeof maybeOr === functionTag) return Option_getOrWith(schema2, maybeOr);
|
|
3012
|
+
else return Option_getOr(schema2, maybeOr);
|
|
3013
|
+
} else return unionFactory([schema, nullLiteral()]);
|
|
3014
|
+
};
|
|
3015
|
+
var js_merge = (s1, s2) => {
|
|
3016
|
+
let result;
|
|
3017
|
+
if (s1.type === objectTag && s2.type === objectTag && typeof s1.additionalItems === stringTag && typeof s2.additionalItems === stringTag && !s1.to && !s2.to) {
|
|
3018
|
+
const properties = {
|
|
3019
|
+
...s1.properties,
|
|
3020
|
+
...s2.properties
|
|
3021
|
+
};
|
|
3022
|
+
const mut = baseSchema(objectTag, false);
|
|
3023
|
+
mut.required = Object.keys(properties);
|
|
3024
|
+
mut.properties = properties;
|
|
3025
|
+
mut.additionalItems = s1.additionalItems;
|
|
3026
|
+
mut.decoder = objectDecoder;
|
|
3027
|
+
result = mut;
|
|
3028
|
+
}
|
|
3029
|
+
if (result !== void 0) return result;
|
|
3030
|
+
else return panic("The merge supports only structured object schemas without transformations");
|
|
3031
|
+
};
|
|
3032
|
+
var global = (override) => {
|
|
3033
|
+
globalConfig.a = override.defaultAdditionalItems !== void 0 ? override.defaultAdditionalItems : initialOnAdditionalItems;
|
|
3034
|
+
globalConfig.f = override.disableNanNumberValidation === true ? flagDisableNanNumberValidation : initialDefaultFlag;
|
|
3035
|
+
};
|
|
3036
|
+
var compactColumnsDecoder = (input) => {
|
|
3037
|
+
const selfSchema = input.e;
|
|
3038
|
+
const isUnknownInput = flagUnsafeHas(tagFlags[input.s.type], tagFlagUnknown);
|
|
3039
|
+
const declaredItemSchema = selfSchema.additionalItems.additionalItems;
|
|
3040
|
+
let forwardProps;
|
|
3041
|
+
if (selfSchema.to !== void 0 && typeof selfSchema.to.additionalItems === "object") forwardProps = selfSchema.to.additionalItems.properties;
|
|
3042
|
+
else forwardProps = void 0;
|
|
3043
|
+
const isForwardDirection = forwardProps !== void 0;
|
|
3044
|
+
let maybeProperties;
|
|
3045
|
+
if (isForwardDirection) maybeProperties = forwardProps;
|
|
3046
|
+
else if (input.s.additionalItems !== void 0 && typeof input.s.additionalItems === "object") maybeProperties = input.s.additionalItems.properties;
|
|
3047
|
+
else maybeProperties = void 0;
|
|
3048
|
+
if (maybeProperties === void 0) return panic("S.compactColumns supports only object schemas. Use S.compactColumns(S.unknown)->S.to(S.array(objectSchema)).");
|
|
3049
|
+
else {
|
|
3050
|
+
const properties = maybeProperties;
|
|
3051
|
+
const keys = Object.keys(properties);
|
|
3052
|
+
const keysLen = keys.length;
|
|
3053
|
+
let outputSchema;
|
|
3054
|
+
if (isForwardDirection) outputSchema = selfSchema.to;
|
|
3055
|
+
else {
|
|
3056
|
+
const s2 = array(array(unknown));
|
|
3057
|
+
s2.to = selfSchema.to;
|
|
3058
|
+
outputSchema = s2;
|
|
3059
|
+
}
|
|
3060
|
+
if (keysLen === 0) {
|
|
3061
|
+
if (isUnknownInput) input = B_refine(input, void 0, [{
|
|
3062
|
+
c: (inputVar) => `Array.isArray(${inputVar})&&${inputVar}.length===0`,
|
|
3063
|
+
f: failInvalidType
|
|
3064
|
+
}]);
|
|
3065
|
+
return B_markOutput(B_next(input, "[]", outputSchema, outputSchema), input);
|
|
3066
|
+
} else if (isForwardDirection) {
|
|
3067
|
+
if (isUnknownInput) input = B_refine(input, void 0, [{
|
|
3068
|
+
c: (inputVar2) => {
|
|
3069
|
+
let check = `Array.isArray(${inputVar2})&&${inputVar2}.length===${keysLen}`;
|
|
3070
|
+
for (let idx = 0; idx <= keysLen - 1; ++idx) check = check + `&&Array.isArray(${inputVar2}[${idx}])`;
|
|
3071
|
+
return check;
|
|
3072
|
+
},
|
|
3073
|
+
f: failInvalidType
|
|
3074
|
+
}]);
|
|
3075
|
+
const inputVar = input.v();
|
|
3076
|
+
const iteratorVar = B_varWithoutAllocation(input.g);
|
|
3077
|
+
const outputVar = B_varWithoutAllocation(input.g);
|
|
3078
|
+
let runtimeItemSchema;
|
|
3079
|
+
if (isUnknownInput) runtimeItemSchema = unknown;
|
|
3080
|
+
else runtimeItemSchema = input.s.additionalItems.additionalItems;
|
|
3081
|
+
let lengthCode = "";
|
|
3082
|
+
let itemBuildCode = "";
|
|
3083
|
+
let itemParseCode = "";
|
|
3084
|
+
let asyncInlines = "";
|
|
3085
|
+
let hasAsync = false;
|
|
3086
|
+
for (let idx = 0; idx <= keysLen - 1; ++idx) {
|
|
3087
|
+
const key = keys[idx];
|
|
3088
|
+
const idxStr = `${idx}`;
|
|
3089
|
+
const rawValueCode = `${inputVar}[${idxStr}][${iteratorVar}]`;
|
|
3090
|
+
const fieldSchema = properties[key];
|
|
3091
|
+
let itemExpected;
|
|
3092
|
+
if (declaredItemSchema !== runtimeItemSchema) {
|
|
3093
|
+
const chained = copySchema(declaredItemSchema);
|
|
3094
|
+
chained.to = fieldSchema;
|
|
3095
|
+
itemExpected = chained;
|
|
3096
|
+
} else itemExpected = fieldSchema;
|
|
3097
|
+
const itemInput = B_scope(input);
|
|
3098
|
+
itemInput.i = rawValueCode;
|
|
3099
|
+
itemInput.s = runtimeItemSchema;
|
|
3100
|
+
itemInput.e = itemExpected;
|
|
3101
|
+
itemInput.v = _notVarBeforeValidation;
|
|
3102
|
+
itemInput.io = false;
|
|
3103
|
+
itemInput.path = pathFromInlinedLocation(B_inlineLocation(input.g, key));
|
|
3104
|
+
const itemOutput = parse(itemInput);
|
|
3105
|
+
if (flagUnsafeHas(itemOutput.f, valFlagAsync)) hasAsync = true;
|
|
3106
|
+
itemParseCode = itemParseCode + B_merge(itemOutput);
|
|
3107
|
+
lengthCode = lengthCode + `${inputVar}[${idxStr}].length,`;
|
|
3108
|
+
asyncInlines = asyncInlines + `${itemOutput.i},`;
|
|
3109
|
+
itemBuildCode = itemBuildCode + `${inlinedValueFromString(key)}:${itemOutput.i},`;
|
|
3110
|
+
}
|
|
3111
|
+
let output = B_next(input, outputVar, outputSchema, outputSchema);
|
|
3112
|
+
output.v = _var;
|
|
3113
|
+
output.cp = `let ${outputVar}=new Array(Math.max(${lengthCode}));`;
|
|
3114
|
+
let rowAssign;
|
|
3115
|
+
if (hasAsync) {
|
|
3116
|
+
const rowResultVar = B_varWithoutAllocation(input.g);
|
|
3117
|
+
let asyncBuildCode = "";
|
|
3118
|
+
for (let idx = 0; idx <= keysLen - 1; ++idx) {
|
|
3119
|
+
const key = keys[idx];
|
|
3120
|
+
asyncBuildCode = asyncBuildCode + `${inlinedValueFromString(key)}:${rowResultVar}[${idx}],`;
|
|
3121
|
+
}
|
|
3122
|
+
rowAssign = `${outputVar}[${iteratorVar}]=Promise.all([${asyncInlines}]).then(${rowResultVar}=>({${asyncBuildCode}}));`;
|
|
3123
|
+
} else rowAssign = `${outputVar}[${iteratorVar}]={${itemBuildCode}};`;
|
|
3124
|
+
const rowBody = itemParseCode + rowAssign;
|
|
3125
|
+
let wrappedBody;
|
|
3126
|
+
if (itemParseCode === "") wrappedBody = rowBody;
|
|
3127
|
+
else {
|
|
3128
|
+
const errorVar = B_varWithoutAllocation(input.g);
|
|
3129
|
+
wrappedBody = `try{${rowBody}}catch(${errorVar}){${errorVar}.path='["'+${iteratorVar}+'"]'+${errorVar}.path;throw ${errorVar}}`;
|
|
3130
|
+
}
|
|
3131
|
+
output.cp = output.cp + `for(let ${iteratorVar}=0;${iteratorVar}<${outputVar}.length;++${iteratorVar}){${wrappedBody}}`;
|
|
3132
|
+
if (hasAsync) output = B_asyncVal(output, `Promise.all(${outputVar})`);
|
|
3133
|
+
return B_markOutput(output, input);
|
|
3134
|
+
} else {
|
|
3135
|
+
const inputVar = input.v();
|
|
3136
|
+
const iteratorVar = B_varWithoutAllocation(input.g);
|
|
3137
|
+
const outputVar = B_varWithoutAllocation(input.g);
|
|
3138
|
+
const needsPerFieldTransform = declaredItemSchema !== unknown;
|
|
3139
|
+
let initialArraysCode = "";
|
|
3140
|
+
let settingCode = "";
|
|
3141
|
+
let perFieldCode = "";
|
|
3142
|
+
for (let idx = 0; idx <= keysLen - 1; ++idx) {
|
|
3143
|
+
const key = keys[idx];
|
|
3144
|
+
initialArraysCode = initialArraysCode + `new Array(${inputVar}.length),`;
|
|
3145
|
+
if (needsPerFieldTransform) {
|
|
3146
|
+
const fieldSchema = properties[key];
|
|
3147
|
+
const rawValueCode = `${inputVar}[${iteratorVar}][${inlinedValueFromString(key)}]`;
|
|
3148
|
+
const itemInput = B_scope(input);
|
|
3149
|
+
itemInput.i = rawValueCode;
|
|
3150
|
+
itemInput.s = fieldSchema;
|
|
3151
|
+
itemInput.e = declaredItemSchema;
|
|
3152
|
+
itemInput.v = _notVarBeforeValidation;
|
|
3153
|
+
itemInput.io = false;
|
|
3154
|
+
itemInput.path = pathFromInlinedLocation(B_inlineLocation(input.g, key));
|
|
3155
|
+
const itemOutput = parse(itemInput);
|
|
3156
|
+
perFieldCode = perFieldCode + B_merge(itemOutput);
|
|
3157
|
+
settingCode = settingCode + `${outputVar}[${idx}][${iteratorVar}]=${itemOutput.i};`;
|
|
3158
|
+
} else settingCode = settingCode + `${outputVar}[${idx}][${iteratorVar}]=${inputVar}[${iteratorVar}][${inlinedValueFromString(key)}];`;
|
|
3159
|
+
}
|
|
3160
|
+
const output = B_next(input, outputVar, outputSchema, outputSchema);
|
|
3161
|
+
output.v = _var;
|
|
3162
|
+
output.cp = `let ${outputVar}=[${initialArraysCode}];`;
|
|
3163
|
+
const loopBody = perFieldCode + settingCode;
|
|
3164
|
+
let wrappedBody;
|
|
3165
|
+
if (needsPerFieldTransform && perFieldCode !== "") {
|
|
3166
|
+
const errorVar = B_varWithoutAllocation(input.g);
|
|
3167
|
+
wrappedBody = `try{${loopBody}}catch(${errorVar}){${errorVar}.path='["'+${iteratorVar}+'"]'+${errorVar}.path;throw ${errorVar}}`;
|
|
3168
|
+
} else wrappedBody = loopBody;
|
|
3169
|
+
output.cp = output.cp + `for(let ${iteratorVar}=0;${iteratorVar}<${inputVar}.length;++${iteratorVar}){${wrappedBody}}`;
|
|
3170
|
+
return B_markOutput(output, input);
|
|
3171
|
+
}
|
|
3172
|
+
}
|
|
3173
|
+
};
|
|
3174
|
+
var compactColumns = (inputSchema) => {
|
|
3175
|
+
const mut = array(array(inputSchema));
|
|
3176
|
+
mut.format = "compactColumns";
|
|
3177
|
+
mut.decoder = compactColumnsDecoder;
|
|
3178
|
+
return mut;
|
|
3179
|
+
};
|
|
3180
|
+
var object = schemaObject;
|
|
3181
|
+
var nullAsOption = (item) => optionFactory(item, nullAsUnit());
|
|
3182
|
+
var null_ = (item) => unionFactory([item, nullLiteral()]);
|
|
3183
|
+
var dict = dictFactory;
|
|
3184
|
+
var shape = schemaShape;
|
|
3185
|
+
var tuple = schemaTuple;
|
|
3186
|
+
var union = unionFactory;
|
|
3187
|
+
var assertNumber = (fnName, n) => {
|
|
3188
|
+
if (typeof n !== numberTag || Number.isNaN(n)) throw new SuryError({
|
|
3189
|
+
code: "invalid_operation",
|
|
3190
|
+
path: pathEmpty,
|
|
3191
|
+
reason: `[S.${fnName}] Expected number, received ${stringify(n)}`
|
|
3192
|
+
});
|
|
3193
|
+
};
|
|
3194
|
+
var intMin = (schema, minValue, maybeMessage) => {
|
|
3195
|
+
assertNumber("min", minValue);
|
|
3196
|
+
const message = maybeMessage ?? `Number must be greater than or equal to ${minValue}`;
|
|
3197
|
+
return internalRefine(schema, (mut) => {
|
|
3198
|
+
mut.minimum = minValue;
|
|
3199
|
+
getMutErrorMessage(mut)["minimum"] = message;
|
|
3200
|
+
return (_input) => {
|
|
3201
|
+
return [{
|
|
3202
|
+
c: (inputVar) => `${inputVar}>${minValue - 1}`,
|
|
3203
|
+
f: B_failWithErrorMessage("minimum", message)
|
|
3204
|
+
}];
|
|
3205
|
+
};
|
|
3206
|
+
});
|
|
3207
|
+
};
|
|
3208
|
+
var intMax = (schema, maxValue, maybeMessage) => {
|
|
3209
|
+
assertNumber("max", maxValue);
|
|
3210
|
+
const message = maybeMessage ?? `Number must be lower than or equal to ${maxValue}`;
|
|
3211
|
+
return internalRefine(schema, (mut) => {
|
|
3212
|
+
mut.maximum = maxValue;
|
|
3213
|
+
getMutErrorMessage(mut)["maximum"] = message;
|
|
3214
|
+
return (_input) => {
|
|
3215
|
+
return [{
|
|
3216
|
+
c: (inputVar) => `${inputVar}<${maxValue + 1}`,
|
|
3217
|
+
f: B_failWithErrorMessage("maximum", message)
|
|
3218
|
+
}];
|
|
3219
|
+
};
|
|
3220
|
+
});
|
|
3221
|
+
};
|
|
3222
|
+
var floatMin = (schema, minValue, maybeMessage) => {
|
|
3223
|
+
assertNumber("min", minValue);
|
|
3224
|
+
const message = maybeMessage ?? `Number must be greater than or equal to ${minValue}`;
|
|
3225
|
+
return internalRefine(schema, (mut) => {
|
|
3226
|
+
mut.minimum = minValue;
|
|
3227
|
+
getMutErrorMessage(mut)["minimum"] = message;
|
|
3228
|
+
return (input) => {
|
|
3229
|
+
return [{
|
|
3230
|
+
c: (inputVar) => `${inputVar}>=${B_embed(input, minValue)}`,
|
|
3231
|
+
f: B_failWithErrorMessage("minimum", message)
|
|
3232
|
+
}];
|
|
3233
|
+
};
|
|
3234
|
+
});
|
|
3235
|
+
};
|
|
3236
|
+
var floatMax = (schema, maxValue, maybeMessage) => {
|
|
3237
|
+
assertNumber("max", maxValue);
|
|
3238
|
+
const message = maybeMessage ?? `Number must be lower than or equal to ${maxValue}`;
|
|
3239
|
+
return internalRefine(schema, (mut) => {
|
|
3240
|
+
mut.maximum = maxValue;
|
|
3241
|
+
getMutErrorMessage(mut)["maximum"] = message;
|
|
3242
|
+
return (input) => {
|
|
3243
|
+
return [{
|
|
3244
|
+
c: (inputVar) => `${inputVar}<=${B_embed(input, maxValue)}`,
|
|
3245
|
+
f: B_failWithErrorMessage("maximum", message)
|
|
3246
|
+
}];
|
|
3247
|
+
};
|
|
3248
|
+
});
|
|
3249
|
+
};
|
|
3250
|
+
var arrayMinLength = (schema, length2, maybeMessage) => {
|
|
3251
|
+
assertNumber("min", length2);
|
|
3252
|
+
const message = maybeMessage ?? `Array must be ${length2} or more items long`;
|
|
3253
|
+
return internalRefine(schema, (mut) => {
|
|
3254
|
+
mut.minItems = length2;
|
|
3255
|
+
getMutErrorMessage(mut)["minItems"] = message;
|
|
3256
|
+
return (_input) => {
|
|
3257
|
+
return [{
|
|
3258
|
+
c: (inputVar) => `${inputVar}.length>${length2 - 1}`,
|
|
3259
|
+
f: B_failWithErrorMessage("minItems", message)
|
|
3260
|
+
}];
|
|
3261
|
+
};
|
|
3262
|
+
});
|
|
3263
|
+
};
|
|
3264
|
+
var arrayMaxLength = (schema, length2, maybeMessage) => {
|
|
3265
|
+
assertNumber("max", length2);
|
|
3266
|
+
const message = maybeMessage ?? `Array must be ${length2} or fewer items long`;
|
|
3267
|
+
return internalRefine(schema, (mut) => {
|
|
3268
|
+
mut.maxItems = length2;
|
|
3269
|
+
getMutErrorMessage(mut)["maxItems"] = message;
|
|
3270
|
+
return (_input) => {
|
|
3271
|
+
return [{
|
|
3272
|
+
c: (inputVar) => `${inputVar}.length<${length2 + 1}`,
|
|
3273
|
+
f: B_failWithErrorMessage("maxItems", message)
|
|
3274
|
+
}];
|
|
3275
|
+
};
|
|
3276
|
+
});
|
|
3277
|
+
};
|
|
3278
|
+
var arrayLength = (schema, length2, maybeMessage) => {
|
|
3279
|
+
assertNumber("length", length2);
|
|
3280
|
+
const message = maybeMessage ?? `Array must be exactly ${length2} items long`;
|
|
3281
|
+
return internalRefine(schema, (mut) => {
|
|
3282
|
+
mut.minItems = length2;
|
|
3283
|
+
mut.maxItems = length2;
|
|
3284
|
+
const em = getMutErrorMessage(mut);
|
|
3285
|
+
em["minItems"] = message;
|
|
3286
|
+
em["maxItems"] = message;
|
|
3287
|
+
return (_input) => {
|
|
3288
|
+
return [{
|
|
3289
|
+
c: (inputVar) => `${inputVar}.length===${length2}`,
|
|
3290
|
+
f: B_failWithErrorMessage("minItems", message)
|
|
3291
|
+
}];
|
|
3292
|
+
};
|
|
3293
|
+
});
|
|
3294
|
+
};
|
|
3295
|
+
var stringMinLength = (schema, length2, maybeMessage) => {
|
|
3296
|
+
assertNumber("min", length2);
|
|
3297
|
+
const message = maybeMessage ?? `String must be ${length2} or more characters long`;
|
|
3298
|
+
return internalRefine(schema, (mut) => {
|
|
3299
|
+
mut.minLength = length2;
|
|
3300
|
+
getMutErrorMessage(mut)["minLength"] = message;
|
|
3301
|
+
return (_input) => {
|
|
3302
|
+
return [{
|
|
3303
|
+
c: (inputVar) => `${inputVar}.length>${length2 - 1}`,
|
|
3304
|
+
f: B_failWithErrorMessage("minLength", message)
|
|
3305
|
+
}];
|
|
3306
|
+
};
|
|
3307
|
+
});
|
|
3308
|
+
};
|
|
3309
|
+
var stringMaxLength = (schema, length2, maybeMessage) => {
|
|
3310
|
+
assertNumber("max", length2);
|
|
3311
|
+
const message = maybeMessage ?? `String must be ${length2} or fewer characters long`;
|
|
3312
|
+
return internalRefine(schema, (mut) => {
|
|
3313
|
+
mut.maxLength = length2;
|
|
3314
|
+
getMutErrorMessage(mut)["maxLength"] = message;
|
|
3315
|
+
return (_input) => {
|
|
3316
|
+
return [{
|
|
3317
|
+
c: (inputVar) => `${inputVar}.length<${length2 + 1}`,
|
|
3318
|
+
f: B_failWithErrorMessage("maxLength", message)
|
|
3319
|
+
}];
|
|
3320
|
+
};
|
|
3321
|
+
});
|
|
3322
|
+
};
|
|
3323
|
+
var stringLength = (schema, length2, maybeMessage) => {
|
|
3324
|
+
assertNumber("length", length2);
|
|
3325
|
+
const message = maybeMessage ?? `String must be exactly ${length2} characters long`;
|
|
3326
|
+
return internalRefine(schema, (mut) => {
|
|
3327
|
+
mut.minLength = length2;
|
|
3328
|
+
mut.maxLength = length2;
|
|
3329
|
+
const em = getMutErrorMessage(mut);
|
|
3330
|
+
em["minLength"] = message;
|
|
3331
|
+
em["maxLength"] = message;
|
|
3332
|
+
return (_input) => {
|
|
3333
|
+
return [{
|
|
3334
|
+
c: (inputVar) => `${inputVar}.length===${length2}`,
|
|
3335
|
+
f: B_failWithErrorMessage("minLength", message)
|
|
3336
|
+
}];
|
|
3337
|
+
};
|
|
3338
|
+
});
|
|
3339
|
+
};
|
|
3340
|
+
var pattern = (schema, re, message = `Invalid pattern`) => {
|
|
3341
|
+
return internalRefine(schema, (mut) => {
|
|
3342
|
+
mut.pattern = re;
|
|
3343
|
+
getMutErrorMessage(mut)["pattern"] = message;
|
|
3344
|
+
return (input) => {
|
|
3345
|
+
const embededRe = B_embed(input, re);
|
|
3346
|
+
return [{
|
|
3347
|
+
c: (inputVar) => re.global ? `(${embededRe}.lastIndex=0,${embededRe}.test(${inputVar}))` : `${embededRe}.test(${inputVar})`,
|
|
3348
|
+
f: B_failWithErrorMessage("pattern", message)
|
|
3349
|
+
}];
|
|
3350
|
+
};
|
|
3351
|
+
});
|
|
3352
|
+
};
|
|
3353
|
+
var trim = (schema) => {
|
|
3354
|
+
const transformer = (string3) => string3.trim();
|
|
3355
|
+
return transform(schema, (_) => ({
|
|
3356
|
+
p: transformer,
|
|
3357
|
+
s: transformer
|
|
3358
|
+
}));
|
|
3359
|
+
};
|
|
3360
|
+
var nullable = (schema) => {
|
|
3361
|
+
return unionFactory([
|
|
3362
|
+
schema,
|
|
3363
|
+
unit(),
|
|
3364
|
+
nullLiteral()
|
|
3365
|
+
]);
|
|
3366
|
+
};
|
|
3367
|
+
var nullableAsOption = (schema) => {
|
|
3368
|
+
return unionFactory([
|
|
3369
|
+
schema,
|
|
3370
|
+
unit(),
|
|
3371
|
+
nullAsUnit()
|
|
3372
|
+
]);
|
|
3373
|
+
};
|
|
3374
|
+
var jsonSchemaMetadataId = /* @__PURE__ */ Metadata_Id_internal("JSONSchema");
|
|
3375
|
+
var jsonSchemaMerge = (a, b) => {
|
|
3376
|
+
return Object.assign({}, a, b);
|
|
3377
|
+
};
|
|
3378
|
+
var applyMetadataOverlay = (jsonSchema, schema, defs) => {
|
|
3379
|
+
if (schema.description !== void 0) jsonSchema.description = schema.description;
|
|
3380
|
+
if (schema.title !== void 0) jsonSchema.title = schema.title;
|
|
3381
|
+
if (schema.deprecated !== void 0) jsonSchema.deprecated = schema.deprecated;
|
|
3382
|
+
if (schema.examples !== void 0) jsonSchema.examples = schema.examples;
|
|
3383
|
+
if (schema["$defs"] !== void 0) Object.assign(defs, schema["$defs"]);
|
|
3384
|
+
const metadataRawSchema = Metadata_get(schema, jsonSchemaMetadataId);
|
|
3385
|
+
if (metadataRawSchema !== void 0) Object.assign(jsonSchema, metadataRawSchema);
|
|
3386
|
+
};
|
|
3387
|
+
var encodeToJsonSchema = (schema, path, defs, parent, target) => {
|
|
3388
|
+
const input = B_operationArg(unknown, reverse(schema), flagNone, void 0);
|
|
3389
|
+
try {
|
|
3390
|
+
return internalToJSONSchema(parse(input).s, path, defs, parent, target);
|
|
3391
|
+
} catch (exn) {
|
|
3392
|
+
getOrRethrow(exn);
|
|
3393
|
+
return;
|
|
3394
|
+
}
|
|
3395
|
+
};
|
|
3396
|
+
var internalToJSONSchema = (schema, path, defs, parent, target) => {
|
|
3397
|
+
const schemaInternal = schema;
|
|
3398
|
+
const tagFlag = tagFlags[schemaInternal.type];
|
|
3399
|
+
const encoded = !!schemaInternal.to && !flagUnsafeHas(tagFlag, 192) && !(flagUnsafeHas(tagFlag, tagFlagUnion) && !!schemaInternal.parser) ? encodeToJsonSchema(schema, path, defs, parent, target) : void 0;
|
|
3400
|
+
if (encoded !== void 0) {
|
|
3401
|
+
applyMetadataOverlay(encoded, schema, defs);
|
|
3402
|
+
return encoded;
|
|
3403
|
+
} else return internalToJSONSchemaBase(schema, path, defs, parent, target);
|
|
3404
|
+
};
|
|
3405
|
+
var internalToJSONSchemaBase = (schema, path, defs, parent, target) => {
|
|
3406
|
+
const jsonSchema = {};
|
|
3407
|
+
const setConstOrEnum = (value) => {
|
|
3408
|
+
if (target === "openapi-3.0") jsonSchema.enum = [value];
|
|
3409
|
+
else jsonSchema.const = value;
|
|
3410
|
+
};
|
|
3411
|
+
const tag = schema.type;
|
|
3412
|
+
if (tag === stringTag) {
|
|
3413
|
+
const const_ = schema.const;
|
|
3414
|
+
const format = schema.format;
|
|
3415
|
+
jsonSchema.type = "string";
|
|
3416
|
+
switch (format) {
|
|
3417
|
+
case "date-time":
|
|
3418
|
+
jsonSchema.format = "date-time";
|
|
3419
|
+
break;
|
|
3420
|
+
case "email":
|
|
3421
|
+
jsonSchema.format = "email";
|
|
3422
|
+
break;
|
|
3423
|
+
case "uuid":
|
|
3424
|
+
jsonSchema.format = "uuid";
|
|
3425
|
+
break;
|
|
3426
|
+
case "url":
|
|
3427
|
+
jsonSchema.format = "uri";
|
|
3428
|
+
break;
|
|
3429
|
+
default: break;
|
|
3430
|
+
}
|
|
3431
|
+
if (schema.minLength !== void 0) jsonSchema.minLength = schema.minLength;
|
|
3432
|
+
if (schema.maxLength !== void 0) jsonSchema.maxLength = schema.maxLength;
|
|
3433
|
+
if (schema.pattern !== void 0) jsonSchema.pattern = schema.pattern.source;
|
|
3434
|
+
if (const_ !== void 0) setConstOrEnum(const_);
|
|
3435
|
+
} else if (tag === numberTag) {
|
|
3436
|
+
const format = schema.format;
|
|
3437
|
+
const const_ = schema.const;
|
|
3438
|
+
if (format === "int32") {
|
|
3439
|
+
jsonSchema.type = "integer";
|
|
3440
|
+
jsonSchema.minimum = -2147483648;
|
|
3441
|
+
jsonSchema.maximum = 2147483647;
|
|
3442
|
+
} else if (format === "port") {
|
|
3443
|
+
jsonSchema.type = "integer";
|
|
3444
|
+
jsonSchema.minimum = 0;
|
|
3445
|
+
jsonSchema.maximum = 65535;
|
|
3446
|
+
} else jsonSchema.type = "number";
|
|
3447
|
+
if (schema.minimum !== void 0) jsonSchema.minimum = schema.minimum;
|
|
3448
|
+
if (schema.maximum !== void 0) jsonSchema.maximum = schema.maximum;
|
|
3449
|
+
if (const_ !== void 0) setConstOrEnum(const_);
|
|
3450
|
+
} else if (tag === booleanTag) {
|
|
3451
|
+
const const_ = schema.const;
|
|
3452
|
+
jsonSchema.type = "boolean";
|
|
3453
|
+
if (const_ !== void 0) setConstOrEnum(const_);
|
|
3454
|
+
} else if (tag === arrayTag) {
|
|
3455
|
+
const additionalItems = schema.additionalItems;
|
|
3456
|
+
const items = schema.items;
|
|
3457
|
+
if (typeof additionalItems === "object") {
|
|
3458
|
+
jsonSchema.items = internalToJSONSchema(additionalItems, pathConcat(path, pathDynamic), defs, schema, target);
|
|
3459
|
+
jsonSchema.type = "array";
|
|
3460
|
+
if (schema.minItems !== void 0) jsonSchema.minItems = schema.minItems;
|
|
3461
|
+
if (schema.maxItems !== void 0) jsonSchema.maxItems = schema.maxItems;
|
|
3462
|
+
} else {
|
|
3463
|
+
const itemDefinitions = items.map((itemSchema, idx) => {
|
|
3464
|
+
return internalToJSONSchema(itemSchema, pathConcat(path, pathFromLocation(idx.toString())), defs, schema, target);
|
|
3465
|
+
});
|
|
3466
|
+
const itemsNumber = itemDefinitions.length;
|
|
3467
|
+
jsonSchema.type = "array";
|
|
3468
|
+
jsonSchema.minItems = itemsNumber;
|
|
3469
|
+
jsonSchema.maxItems = itemsNumber;
|
|
3470
|
+
if (target === "openapi-3.0") jsonSchema.items = { anyOf: itemDefinitions };
|
|
3471
|
+
else if (target === "draft-2020-12") jsonSchema.prefixItems = itemDefinitions;
|
|
3472
|
+
else jsonSchema.items = itemDefinitions;
|
|
3473
|
+
}
|
|
3474
|
+
} else if (tag === unionTag) {
|
|
3475
|
+
const anyOf = schema.anyOf;
|
|
3476
|
+
const literals = [];
|
|
3477
|
+
const items = [];
|
|
3478
|
+
const seen = {};
|
|
3479
|
+
anyOf.forEach((childSchema) => {
|
|
3480
|
+
if (!(childSchema.type === undefinedTag && parent.type === objectTag)) {
|
|
3481
|
+
const childJsonSchema = internalToJSONSchema(childSchema, path, defs, schema, target);
|
|
3482
|
+
const key = JSON.stringify(childJsonSchema);
|
|
3483
|
+
if (!(key in seen)) {
|
|
3484
|
+
seen[key] = true;
|
|
3485
|
+
items.push(childJsonSchema);
|
|
3486
|
+
if (isLiteral(childSchema)) literals.push(childSchema.const);
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
});
|
|
3490
|
+
const itemsNumber = items.length;
|
|
3491
|
+
if (schema.default !== void 0) jsonSchema.default = schema.default;
|
|
3492
|
+
const isNullDefinition = (definition) => {
|
|
3493
|
+
if (typeof definition !== "boolean") {
|
|
3494
|
+
const t = definition;
|
|
3495
|
+
if (t.type === "null") return true;
|
|
3496
|
+
else if (t.enum !== void 0 && t.enum.length === 1 && t.enum[0] === null) return true;
|
|
3497
|
+
else return false;
|
|
3498
|
+
} else return false;
|
|
3499
|
+
};
|
|
3500
|
+
if (itemsNumber === 1) Object.assign(jsonSchema, items[0]);
|
|
3501
|
+
else if (literals.length === itemsNumber) jsonSchema.enum = literals;
|
|
3502
|
+
else if (target === "openapi-3.0" && itemsNumber === 2 && (isNullDefinition(items[0]) || isNullDefinition(items[1]))) {
|
|
3503
|
+
const nonNull = items[isNullDefinition(items[0]) ? 1 : 0];
|
|
3504
|
+
if (typeof nonNull !== "boolean") {
|
|
3505
|
+
Object.assign(jsonSchema, nonNull);
|
|
3506
|
+
jsonSchema.nullable = true;
|
|
3507
|
+
} else jsonSchema.anyOf = items;
|
|
3508
|
+
} else jsonSchema.anyOf = items;
|
|
3509
|
+
} else if (tag === objectTag) {
|
|
3510
|
+
const properties = schema.properties;
|
|
3511
|
+
const additionalItems = schema.additionalItems;
|
|
3512
|
+
if (typeof additionalItems === "object") {
|
|
3513
|
+
jsonSchema.type = "object";
|
|
3514
|
+
const childJsonSchema = internalToJSONSchema(additionalItems, pathConcat(path, pathDynamic), defs, schema, target);
|
|
3515
|
+
jsonSchema.additionalProperties = Object.keys(childJsonSchema).length === 0 ? true : childJsonSchema;
|
|
3516
|
+
} else {
|
|
3517
|
+
const required = [];
|
|
3518
|
+
const jsonProperties = {};
|
|
3519
|
+
Object.keys(properties).forEach((key) => {
|
|
3520
|
+
const itemSchema = properties[key];
|
|
3521
|
+
const fieldSchema = internalToJSONSchema(itemSchema, pathConcat(path, pathFromLocation(key)), defs, schema, target);
|
|
3522
|
+
if (!isOptional(itemSchema)) required.push(key);
|
|
3523
|
+
jsonProperties[key] = fieldSchema;
|
|
3524
|
+
});
|
|
3525
|
+
jsonSchema.type = "object";
|
|
3526
|
+
jsonSchema.properties = jsonProperties;
|
|
3527
|
+
if (additionalItems === "strict") jsonSchema.additionalProperties = false;
|
|
3528
|
+
if (required.length !== 0) jsonSchema.required = required;
|
|
3529
|
+
}
|
|
3530
|
+
} else if (tag === refTag && schema["$ref"] === `${defsPath}${jsonName}`) {} else if (tag === refTag) jsonSchema.$ref = schema["$ref"];
|
|
3531
|
+
else if (tag === nullTag) if (target === "openapi-3.0") jsonSchema.enum = [null];
|
|
3532
|
+
else jsonSchema.type = "null";
|
|
3533
|
+
else if (tag === neverTag) jsonSchema.not = {};
|
|
3534
|
+
else throw new SuryError(B_makeInvalidInputDetails((() => {
|
|
3535
|
+
const s2 = baseSchema(unknownTag, false);
|
|
3536
|
+
s2.name = jsonName;
|
|
3537
|
+
return s2;
|
|
3538
|
+
})(), flagUnsafeHas(tagFlags[parent.type], tagFlagUnion) ? parent : schema, path, void 0, false));
|
|
3539
|
+
applyMetadataOverlay(jsonSchema, schema, defs);
|
|
3540
|
+
return jsonSchema;
|
|
3541
|
+
};
|
|
3542
|
+
var targetSchemaUri = (target) => {
|
|
3543
|
+
switch (target) {
|
|
3544
|
+
case "draft-07": return "http://json-schema.org/draft-07/schema#";
|
|
3545
|
+
case "draft-2020-12": return "https://json-schema.org/draft/2020-12/schema";
|
|
3546
|
+
case "openapi-3.0": return;
|
|
3547
|
+
default: throw new SuryError({
|
|
3548
|
+
code: "invalid_operation",
|
|
3549
|
+
path: pathEmpty,
|
|
3550
|
+
reason: `Unsupported JSON Schema target: ${target}`
|
|
3551
|
+
});
|
|
3552
|
+
}
|
|
3553
|
+
};
|
|
3554
|
+
var toJSONSchema = (schema, options) => {
|
|
3555
|
+
let target;
|
|
3556
|
+
let schemaUri;
|
|
3557
|
+
if (options !== void 0) {
|
|
3558
|
+
target = options.target !== void 0 ? options.target : "draft-07";
|
|
3559
|
+
schemaUri = targetSchemaUri(target);
|
|
3560
|
+
} else {
|
|
3561
|
+
target = "draft-07";
|
|
3562
|
+
schemaUri = void 0;
|
|
3563
|
+
}
|
|
3564
|
+
const defs = {};
|
|
3565
|
+
const jsonSchema = internalToJSONSchema(schema, pathEmpty, defs, schema, target);
|
|
3566
|
+
delete defs.JSON;
|
|
3567
|
+
const defsKeys = Object.keys(defs);
|
|
3568
|
+
if (defsKeys.length) {
|
|
3569
|
+
const jsonSchemDefs = defs;
|
|
3570
|
+
defsKeys.forEach((key) => {
|
|
3571
|
+
const schema2 = defs[key];
|
|
3572
|
+
jsonSchemDefs[key] = internalToJSONSchema(schema2, pathEmpty, {}, schema2, target);
|
|
3573
|
+
});
|
|
3574
|
+
jsonSchema.$defs = jsonSchemDefs;
|
|
3575
|
+
}
|
|
3576
|
+
if (schemaUri !== void 0) jsonSchema.$schema = schemaUri;
|
|
3577
|
+
return jsonSchema;
|
|
3578
|
+
};
|
|
3579
|
+
var enableStandardJSONSchema = () => {
|
|
3580
|
+
__setStandardJSONSchemaConverter((schema, options, isOutput) => {
|
|
3581
|
+
return toJSONSchema(isOutput ? reverse(schema) : schema, { target: options.target });
|
|
3582
|
+
});
|
|
3583
|
+
};
|
|
3584
|
+
var extendJSONSchema = (schema, jsonSchema) => {
|
|
3585
|
+
const existingSchemaExtend = Metadata_get(schema, jsonSchemaMetadataId);
|
|
3586
|
+
return Metadata_set(schema, jsonSchemaMetadataId, existingSchemaExtend !== void 0 ? jsonSchemaMerge(existingSchemaExtend, jsonSchema) : jsonSchema);
|
|
3587
|
+
};
|
|
3588
|
+
var primitiveToSchema = (primitive) => {
|
|
3589
|
+
return Literal_parse(primitive);
|
|
3590
|
+
};
|
|
3591
|
+
var toIntSchema = (jsonSchema) => {
|
|
3592
|
+
let schema = int();
|
|
3593
|
+
if (jsonSchema.minimum !== void 0) schema = intMin(schema, jsonSchema.minimum | 0);
|
|
3594
|
+
else if (jsonSchema.exclusiveMinimum !== void 0) schema = intMin(schema, jsonSchema.exclusiveMinimum + 1 | 0);
|
|
3595
|
+
if (jsonSchema.maximum !== void 0) schema = intMax(schema, jsonSchema.maximum | 0);
|
|
3596
|
+
else if (jsonSchema.exclusiveMinimum !== void 0) schema = intMax(schema, jsonSchema.exclusiveMinimum - 1 | 0);
|
|
3597
|
+
return schema;
|
|
3598
|
+
};
|
|
3599
|
+
var definitionToDefaultValue = (definition) => {
|
|
3600
|
+
if (typeof definition !== "boolean") return definition.default;
|
|
3601
|
+
else return;
|
|
3602
|
+
};
|
|
3603
|
+
var fromJSONSchema = (jsonSchema) => {
|
|
3604
|
+
const anySchema = json();
|
|
3605
|
+
const jsonDefinitionToSchema = (definition) => {
|
|
3606
|
+
if (typeof definition !== "boolean") return fromJSONSchema(definition);
|
|
3607
|
+
else if (definition === true) return anySchema;
|
|
3608
|
+
else return never_();
|
|
3609
|
+
};
|
|
3610
|
+
let schema;
|
|
3611
|
+
if (jsonSchema.nullable) schema = null_(fromJSONSchema(jsonSchemaMerge(jsonSchema, { nullable: false })));
|
|
3612
|
+
else if (jsonSchema.type === "object") if (jsonSchema.properties !== void 0) {
|
|
3613
|
+
const properties = jsonSchema.properties;
|
|
3614
|
+
const obj = {};
|
|
3615
|
+
Object.keys(properties).forEach((key) => {
|
|
3616
|
+
const property = properties[key];
|
|
3617
|
+
let propertySchema = jsonDefinitionToSchema(property);
|
|
3618
|
+
if (!jsonSchema.required?.includes(key)) {
|
|
3619
|
+
const defaultValue = definitionToDefaultValue(property);
|
|
3620
|
+
if (defaultValue !== void 0) propertySchema = Option_getOr(option(propertySchema), defaultValue);
|
|
3621
|
+
else propertySchema = option(propertySchema);
|
|
3622
|
+
}
|
|
3623
|
+
obj[key] = propertySchema;
|
|
3624
|
+
});
|
|
3625
|
+
schema = definitionToSchema(obj);
|
|
3626
|
+
if (jsonSchema.additionalProperties === false) schema = strict(schema);
|
|
3627
|
+
} else {
|
|
3628
|
+
const additionalProperties = jsonSchema.additionalProperties;
|
|
3629
|
+
if (additionalProperties !== void 0) if (additionalProperties === true) schema = dict(anySchema);
|
|
3630
|
+
else if (additionalProperties === false) schema = strict(object(() => {}));
|
|
3631
|
+
else schema = dict(fromJSONSchema(additionalProperties));
|
|
3632
|
+
else schema = schemaFactory({});
|
|
3633
|
+
}
|
|
3634
|
+
else if (jsonSchema.type === "array") {
|
|
3635
|
+
if (jsonSchema.prefixItems !== void 0) {
|
|
3636
|
+
const prefixItems = jsonSchema.prefixItems;
|
|
3637
|
+
schema = tuple((s2) => prefixItems.map((d, idx) => s2.item(idx, jsonDefinitionToSchema(d))));
|
|
3638
|
+
} else if (jsonSchema.items !== void 0) {
|
|
3639
|
+
const items = jsonSchema.items;
|
|
3640
|
+
if (Array.isArray(items)) schema = tuple((s2) => items.map((d, idx) => s2.item(idx, jsonDefinitionToSchema(d))));
|
|
3641
|
+
else schema = array(jsonDefinitionToSchema(items));
|
|
3642
|
+
} else schema = array(anySchema);
|
|
3643
|
+
if (jsonSchema.minItems !== void 0) schema = arrayMinLength(schema, jsonSchema.minItems);
|
|
3644
|
+
if (jsonSchema.maxItems !== void 0) schema = arrayMaxLength(schema, jsonSchema.maxItems);
|
|
3645
|
+
} else if (jsonSchema.anyOf !== void 0) {
|
|
3646
|
+
const definitions = jsonSchema.anyOf;
|
|
3647
|
+
if (definitions.length === 0) schema = anySchema;
|
|
3648
|
+
else if (definitions.length === 1) schema = jsonDefinitionToSchema(definitions[0]);
|
|
3649
|
+
else schema = union(definitions.map(jsonDefinitionToSchema));
|
|
3650
|
+
} else if (jsonSchema.allOf !== void 0) {
|
|
3651
|
+
const definitions = jsonSchema.allOf;
|
|
3652
|
+
if (definitions.length === 0) schema = anySchema;
|
|
3653
|
+
else if (definitions.length === 1) schema = jsonDefinitionToSchema(definitions[0]);
|
|
3654
|
+
else schema = refine(anySchema, (data) => {
|
|
3655
|
+
return definitions.every((d) => {
|
|
3656
|
+
try {
|
|
3657
|
+
assertOrThrow(data, jsonDefinitionToSchema(d));
|
|
3658
|
+
return true;
|
|
3659
|
+
} catch (_) {
|
|
3660
|
+
return false;
|
|
3661
|
+
}
|
|
3662
|
+
});
|
|
3663
|
+
}, "Should pass for all schemas of the allOf property.");
|
|
3664
|
+
} else if (jsonSchema.oneOf !== void 0) {
|
|
3665
|
+
const definitions = jsonSchema.oneOf;
|
|
3666
|
+
if (definitions.length === 0) schema = anySchema;
|
|
3667
|
+
else if (definitions.length === 1) schema = jsonDefinitionToSchema(definitions[0]);
|
|
3668
|
+
else schema = refine(anySchema, (data) => {
|
|
3669
|
+
let validCount = 0;
|
|
3670
|
+
definitions.forEach((d) => {
|
|
3671
|
+
try {
|
|
3672
|
+
assertOrThrow(data, jsonDefinitionToSchema(d));
|
|
3673
|
+
validCount = validCount + 1;
|
|
3674
|
+
} catch {}
|
|
3675
|
+
});
|
|
3676
|
+
return validCount === 1;
|
|
3677
|
+
}, "Should pass exactly one schema according to the oneOf property.");
|
|
3678
|
+
} else if (jsonSchema.not !== void 0) {
|
|
3679
|
+
const not = jsonSchema.not;
|
|
3680
|
+
schema = refine(anySchema, (data) => {
|
|
3681
|
+
try {
|
|
3682
|
+
assertOrThrow(data, jsonDefinitionToSchema(not));
|
|
3683
|
+
return false;
|
|
3684
|
+
} catch (_) {
|
|
3685
|
+
return true;
|
|
3686
|
+
}
|
|
3687
|
+
}, "Should NOT be valid against schema in the not property.");
|
|
3688
|
+
} else if (jsonSchema.enum !== void 0) {
|
|
3689
|
+
const primitives = jsonSchema.enum;
|
|
3690
|
+
if (primitives.length === 0) schema = anySchema;
|
|
3691
|
+
else if (primitives.length === 1) schema = primitiveToSchema(primitives[0]);
|
|
3692
|
+
else schema = union(primitives.map(primitiveToSchema));
|
|
3693
|
+
} else if (jsonSchema.const !== void 0) schema = primitiveToSchema(jsonSchema.const);
|
|
3694
|
+
else if (Array.isArray(jsonSchema.type)) {
|
|
3695
|
+
const types = jsonSchema.type;
|
|
3696
|
+
schema = union(types.map((type) => fromJSONSchema(jsonSchemaMerge(jsonSchema, { type }))));
|
|
3697
|
+
} else if (jsonSchema.type === "string") {
|
|
3698
|
+
if (jsonSchema.format === "email") schema = email();
|
|
3699
|
+
else if (jsonSchema.format === "uri") schema = url();
|
|
3700
|
+
else if (jsonSchema.format === "uuid") schema = uuid();
|
|
3701
|
+
else if (jsonSchema.format === "date-time") schema = isoDateTime();
|
|
3702
|
+
else schema = string();
|
|
3703
|
+
if (jsonSchema.pattern !== void 0) schema = pattern(schema, new RegExp(jsonSchema.pattern));
|
|
3704
|
+
if (jsonSchema.minLength !== void 0) schema = stringMinLength(schema, jsonSchema.minLength);
|
|
3705
|
+
if (jsonSchema.maxLength !== void 0) schema = stringMaxLength(schema, jsonSchema.maxLength);
|
|
3706
|
+
} else if (jsonSchema.type === "integer") schema = toIntSchema(jsonSchema);
|
|
3707
|
+
else if (jsonSchema.type === "number" && jsonSchema.format === "int64") schema = toIntSchema(jsonSchema);
|
|
3708
|
+
else if (jsonSchema.type === "number" && jsonSchema.multipleOf === 1) schema = toIntSchema(jsonSchema);
|
|
3709
|
+
else if (jsonSchema.type === "number") {
|
|
3710
|
+
schema = float();
|
|
3711
|
+
if (jsonSchema.minimum !== void 0) schema = floatMin(schema, jsonSchema.minimum);
|
|
3712
|
+
else if (jsonSchema.exclusiveMinimum !== void 0) schema = floatMin(schema, jsonSchema.exclusiveMinimum + 1);
|
|
3713
|
+
if (jsonSchema.maximum !== void 0) schema = floatMax(schema, jsonSchema.maximum);
|
|
3714
|
+
else if (jsonSchema.exclusiveMinimum !== void 0) schema = floatMax(schema, jsonSchema.exclusiveMinimum - 1);
|
|
3715
|
+
} else if (jsonSchema.type === "boolean") schema = bool();
|
|
3716
|
+
else if (jsonSchema.type === "null") schema = schemaFactory(null);
|
|
3717
|
+
else if (jsonSchema.if !== void 0 && jsonSchema.then !== void 0 && jsonSchema.else !== void 0) {
|
|
3718
|
+
const ifSchema = jsonDefinitionToSchema(jsonSchema.if);
|
|
3719
|
+
const thenSchema = jsonDefinitionToSchema(jsonSchema.then);
|
|
3720
|
+
const elseSchema = jsonDefinitionToSchema(jsonSchema.else);
|
|
3721
|
+
schema = refine(anySchema, (data) => {
|
|
3722
|
+
let passed;
|
|
3723
|
+
try {
|
|
3724
|
+
assertOrThrow(data, ifSchema);
|
|
3725
|
+
passed = true;
|
|
3726
|
+
} catch (_) {
|
|
3727
|
+
passed = false;
|
|
3728
|
+
}
|
|
3729
|
+
try {
|
|
3730
|
+
if (passed) assertOrThrow(data, thenSchema);
|
|
3731
|
+
else assertOrThrow(data, elseSchema);
|
|
3732
|
+
return true;
|
|
3733
|
+
} catch (_) {
|
|
3734
|
+
return false;
|
|
3735
|
+
}
|
|
3736
|
+
}, "Should pass the if/then/else schema validation.");
|
|
3737
|
+
} else if (jsonSchema.type !== void 0) throw new SuryError({
|
|
3738
|
+
code: "invalid_operation",
|
|
3739
|
+
path: pathEmpty,
|
|
3740
|
+
reason: `Unsupported JSON Schema type: ${jsonSchema.type}`
|
|
3741
|
+
});
|
|
3742
|
+
else schema = anySchema;
|
|
3743
|
+
if (jsonSchema.description !== void 0 || jsonSchema.deprecated !== void 0 || jsonSchema.examples !== void 0 || jsonSchema.title !== void 0) schema = meta(schema, {
|
|
3744
|
+
title: jsonSchema.title,
|
|
3745
|
+
description: jsonSchema.description,
|
|
3746
|
+
deprecated: jsonSchema.deprecated,
|
|
3747
|
+
examples: jsonSchema.examples
|
|
3748
|
+
});
|
|
3749
|
+
return schema;
|
|
3750
|
+
};
|
|
3751
|
+
var min = (schema, minValue, maybeMessage) => {
|
|
3752
|
+
switch (schema.type) {
|
|
3753
|
+
case stringTag: return stringMinLength(schema, minValue, maybeMessage);
|
|
3754
|
+
case arrayTag: return arrayMinLength(schema, minValue, maybeMessage);
|
|
3755
|
+
case numberTag: return schema.format === "int32" || schema.format === "port" ? intMin(schema, minValue, maybeMessage) : floatMin(schema, minValue, maybeMessage);
|
|
3756
|
+
default: return panic(`S.min is not supported for ${toExpression(schema)} schema. Coerce the schema to string, number or array using S.to first.`);
|
|
3757
|
+
}
|
|
3758
|
+
};
|
|
3759
|
+
var max = (schema, maxValue, maybeMessage) => {
|
|
3760
|
+
switch (schema.type) {
|
|
3761
|
+
case stringTag: return stringMaxLength(schema, maxValue, maybeMessage);
|
|
3762
|
+
case arrayTag: return arrayMaxLength(schema, maxValue, maybeMessage);
|
|
3763
|
+
case numberTag: return schema.format === "int32" || schema.format === "port" ? intMax(schema, maxValue, maybeMessage) : floatMax(schema, maxValue, maybeMessage);
|
|
3764
|
+
default: return panic(`S.max is not supported for ${toExpression(schema)} schema. Coerce the schema to string, number or array using S.to first.`);
|
|
3765
|
+
}
|
|
3766
|
+
};
|
|
3767
|
+
var length = (schema, length2, maybeMessage) => {
|
|
3768
|
+
switch (schema.type) {
|
|
3769
|
+
case stringTag: return stringLength(schema, length2, maybeMessage);
|
|
3770
|
+
case arrayTag: return arrayLength(schema, length2, maybeMessage);
|
|
3771
|
+
default: return panic(`S.length is not supported for ${toExpression(schema)} schema. Coerce the schema to string or array using S.to first.`);
|
|
3772
|
+
}
|
|
3773
|
+
};
|
|
3774
|
+
var string2 = /* @__PURE__ */ string();
|
|
3775
|
+
var _boolean = /* @__PURE__ */ bool();
|
|
3776
|
+
var _int32 = /* @__PURE__ */ int();
|
|
3777
|
+
var _number = /* @__PURE__ */ float();
|
|
3778
|
+
var bigint2 = /* @__PURE__ */ bigint();
|
|
3779
|
+
var symbol2 = /* @__PURE__ */ symbol();
|
|
3780
|
+
var never = /* @__PURE__ */ never_();
|
|
3781
|
+
var nan2 = /* @__PURE__ */ nan();
|
|
3782
|
+
var _void = /* @__PURE__ */ void_();
|
|
3783
|
+
var $res_unit = /* @__PURE__ */ unit();
|
|
3784
|
+
var $res_nullAsUnit = /* @__PURE__ */ nullAsUnit();
|
|
3785
|
+
var json2 = /* @__PURE__ */ json();
|
|
3786
|
+
var jsonString2 = /* @__PURE__ */ jsonString();
|
|
3787
|
+
var uint8Array2 = /* @__PURE__ */ uint8Array();
|
|
3788
|
+
var date2 = /* @__PURE__ */ date();
|
|
3789
|
+
var isoDateTime2 = /* @__PURE__ */ isoDateTime();
|
|
3790
|
+
var port2 = /* @__PURE__ */ port();
|
|
3791
|
+
var email2 = /* @__PURE__ */ email();
|
|
3792
|
+
var uuid2 = /* @__PURE__ */ uuid();
|
|
3793
|
+
var cuid2 = /* @__PURE__ */ cuid();
|
|
3794
|
+
var url2 = /* @__PURE__ */ url();
|
|
3795
|
+
//#endregion
|
|
3796
|
+
export { Metadata_Id_make as $res_Metadata_Id_make, Metadata_get as $res_Metadata_get, Metadata_set as $res_Metadata_set, Option_getOr as $res_Option_getOr, Option_getOrWith as $res_Option_getOrWith, assertAsyncOrThrow as $res_assertAsyncOrThrow, nullAsOption as $res_nullAsOption, $res_nullAsUnit, nullableAsOption as $res_nullableAsOption, option as $res_option, pathConcat as $res_pathConcat, pathFromArray as $res_pathFromArray, pathFromLocation as $res_pathFromLocation, pathToArray as $res_pathToArray, schemaDefiner as $res_schema, __setExnId as $res_setExnId, transform as $res_transform, $res_unit, errorClass as Error, unknown as any, unknown, array, js_assert as assert, js_asyncDecoder as asyncDecoder, js_asyncDecoderAssert as asyncDecoderAssert, js_asyncEncoder as asyncEncoder, js_asyncParser as asyncParser, bigint2 as bigint, _boolean as bool, _boolean as boolean, brand, compactColumns, cuid2 as cuid, date2 as date, getDecoder as decoder, deepStrict, deepStrip, dict, dict as record, email2 as email, enableStandardJSONSchema, js_encoder as encoder, enum_ as enum, extendJSONSchema, _number as float, _number as number, fromJSONSchema, global, instance, _int32 as int, _int32 as int32, js_is as is, isAsync, isoDateTime2 as isoDateTime, json2 as json, jsonString2 as jsonString, jsonStringWithSpace, length, list, schemaFactory as literal, schemaFactory as schema, max, js_merge as merge, meta, min, nan2 as nan, never, noValidation, js_nullable as nullable, nullable as nullish, object, js_optional as optional, js_parser as parser, pattern, port2 as port, recursive, js_refine as refine, reverse, js_safe as safe, js_safeAsync as safeAsync, shape, strict, string2 as string, strip, symbol2 as symbol, js_to as to, toExpression, toJSONSchema, trim, tuple, uint8Array2 as uint8Array, js_union as union, url2 as url, uuid2 as uuid, _void as void };
|