durable-db 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/arktypeConfig-DdIO8VV1.d.ts +6130 -0
- package/dist/{arktypeConfig-CTCJm4vA.js → arktypeConfig-DxP0OcV_.js} +1014 -1033
- package/dist/cli/bin.d.ts +1 -1
- package/dist/cli/bin.js +2 -10
- package/dist/cli/index.d.ts +27 -29
- package/dist/cli/index.js +4 -9
- package/dist/{cli-DnsOTcrH.js → cli-BUSZTS2D.js} +196 -19
- package/dist/context/index.d.ts +50 -2
- package/dist/context/index.js +119 -5
- package/dist/db/index.d.ts +4 -4
- package/dist/db/index.js +10 -12
- package/dist/{debug-DmBrUmwe.js → debug-Cz8KzMft.js} +23 -27
- package/dist/{defineDatabase-DtkM6k1S.d.ts → defineDatabase-CHmTgZTx.d.ts} +4 -5
- package/dist/{defineDatabase-BD3k1L7d.js → defineDatabase-CHmzpzFf.js} +2 -4
- package/dist/{discovery-DfimBbS_.d.ts → discovery-gHeLq8jk.d.ts} +1 -1
- package/dist/{index-BHLOQ7uV.d.ts → index-M4Jp_PFM.d.ts} +2 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -8
- package/dist/{kysely-BH7QZBZw.js → kysely-Be6KwFZC.js} +45 -31
- package/dist/migrations/generator.d.ts +14 -17
- package/dist/migrations/generator.js +202 -5
- package/dist/migrations/snapshot.d.ts +1 -1
- package/dist/migrations/snapshot.js +91 -3
- package/dist/{parser-BdV7Zqcv.js → parser-DR57GOjv.js} +21 -19
- package/dist/registry.d.ts +10 -11
- package/dist/registry.js +3 -5
- package/dist/schema.d.ts +5 -2
- package/dist/schema.js +6 -3
- package/dist/snapshot-CaG5xnE2.d.ts +48 -0
- package/dist/{state-DtZ70cBR.js → state-OVuoHRC9.js} +3 -5
- package/dist/testing/index.d.ts +4 -5
- package/dist/testing/index.js +6 -10
- package/dist/transport/protocol.d.ts +7 -8
- package/dist/transport/protocol.js +34 -3
- package/dist/transport/websocket.d.ts +4 -5
- package/dist/transport/websocket.js +103 -3
- package/dist/vite/durableDb.d.ts +6 -7
- package/dist/vite/durableDb.js +23 -28
- package/package.json +12 -12
- package/dist/arktypeConfig-zgI5p6zF.d.ts +0 -6
- package/dist/context-kIVZbhye.js +0 -121
- package/dist/generator-KHBZaOI1.js +0 -202
- package/dist/index-zzQS_psa.d.ts +0 -51
- package/dist/protocol-DEubbBbR.js +0 -35
- package/dist/push-BhrMZaQx.js +0 -190
- package/dist/push-cUJBpv5y.js +0 -8
- package/dist/schema-C2yy5KCT.d.ts +0 -6
- package/dist/schema-IFq7ovQq.js +0 -8
- package/dist/snapshot-DMW6j2Ix.js +0 -93
- package/dist/snapshot-DsSRYFe-.d.ts +0 -125
- package/dist/state-vav3VCId.js +0 -5
- package/dist/websocket-eao2rnHL.js +0 -104
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region node_modules/.pnpm/@ark+util@0.56.
|
|
1
|
+
//#region node_modules/.pnpm/@ark+util@0.56.7/node_modules/@ark/util/out/arrays.js
|
|
2
2
|
const liftArray = (data) => Array.isArray(data) ? data : [data];
|
|
3
3
|
/**
|
|
4
4
|
* Splits an array into two arrays based on the result of a predicate
|
|
@@ -30,12 +30,13 @@ const range = (length, offset = 0) => [...new Array(length)].map((_, i) => i + o
|
|
|
30
30
|
/**
|
|
31
31
|
* Adds a value or array to an array, returning the concatenated result
|
|
32
32
|
*/
|
|
33
|
-
const append = (to, value
|
|
34
|
-
if (to === void 0) return value
|
|
35
|
-
if (opts?.prepend)
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
else to.push(value
|
|
33
|
+
const append = (to, value, opts) => {
|
|
34
|
+
if (to === void 0) return value === void 0 ? [] : Array.isArray(value) ? value : [value];
|
|
35
|
+
if (opts?.prepend) {
|
|
36
|
+
if (Array.isArray(value)) to.unshift(...value);
|
|
37
|
+
else to.unshift(value);
|
|
38
|
+
} else if (Array.isArray(value)) to.push(...value);
|
|
39
|
+
else to.push(value);
|
|
39
40
|
return to;
|
|
40
41
|
};
|
|
41
42
|
/**
|
|
@@ -53,10 +54,10 @@ const conflatenateAll = (...elementsOrLists) => elementsOrLists.reduce(conflaten
|
|
|
53
54
|
/**
|
|
54
55
|
* Appends a value or concatenates an array to an array if it is not already included, returning the array
|
|
55
56
|
*/
|
|
56
|
-
const appendUnique = (to, value
|
|
57
|
-
if (to === void 0) return Array.isArray(value
|
|
57
|
+
const appendUnique = (to, value, opts) => {
|
|
58
|
+
if (to === void 0) return Array.isArray(value) ? value : [value];
|
|
58
59
|
const isEqual = opts?.isEqual ?? ((l, r) => l === r);
|
|
59
|
-
for (const v of liftArray(value
|
|
60
|
+
for (const v of liftArray(value)) if (!to.some((existing) => isEqual(existing, v))) to.push(v);
|
|
60
61
|
return to;
|
|
61
62
|
};
|
|
62
63
|
const groupBy = (array, discriminant) => array.reduce((result, item) => {
|
|
@@ -65,9 +66,8 @@ const groupBy = (array, discriminant) => array.reduce((result, item) => {
|
|
|
65
66
|
return result;
|
|
66
67
|
}, {});
|
|
67
68
|
const arrayEquals = (l, r, opts) => l.length === r.length && l.every(opts?.isEqual ? (lItem, i) => opts.isEqual(lItem, r[i]) : (lItem, i) => lItem === r[i]);
|
|
68
|
-
|
|
69
69
|
//#endregion
|
|
70
|
-
//#region node_modules/.pnpm/@ark+util@0.56.
|
|
70
|
+
//#region node_modules/.pnpm/@ark+util@0.56.7/node_modules/@ark/util/out/domain.js
|
|
71
71
|
const hasDomain = (data, kind) => domainOf(data) === kind;
|
|
72
72
|
const domainOf = (data) => {
|
|
73
73
|
const builtinType = typeof data;
|
|
@@ -88,9 +88,8 @@ const jsTypeOfDescriptions = {
|
|
|
88
88
|
...domainDescriptions,
|
|
89
89
|
function: "a function"
|
|
90
90
|
};
|
|
91
|
-
|
|
92
91
|
//#endregion
|
|
93
|
-
//#region node_modules/.pnpm/@ark+util@0.56.
|
|
92
|
+
//#region node_modules/.pnpm/@ark+util@0.56.7/node_modules/@ark/util/out/errors.js
|
|
94
93
|
var InternalArktypeError = class extends Error {};
|
|
95
94
|
const throwInternalError = (message) => throwError(message, InternalArktypeError);
|
|
96
95
|
const throwError = (message, ctor = Error) => {
|
|
@@ -105,11 +104,8 @@ const throwParseError = (message) => throwError(message, ParseError);
|
|
|
105
104
|
* Useful for symbol-like string properties.
|
|
106
105
|
*/
|
|
107
106
|
const noSuggest = (s) => ` ${s}`;
|
|
108
|
-
/** Unrendered character (U+200B) used to mark a string type */
|
|
109
|
-
const ZeroWidthSpace = "";
|
|
110
|
-
|
|
111
107
|
//#endregion
|
|
112
|
-
//#region node_modules/.pnpm/@ark+util@0.56.
|
|
108
|
+
//#region node_modules/.pnpm/@ark+util@0.56.7/node_modules/@ark/util/out/flatMorph.js
|
|
113
109
|
const flatMorph = (o, flatMapEntry) => {
|
|
114
110
|
const result = {};
|
|
115
111
|
const inputIsArray = Array.isArray(o);
|
|
@@ -123,14 +119,14 @@ const flatMorph = (o, flatMapEntry) => {
|
|
|
123
119
|
}
|
|
124
120
|
return outputShouldBeArray ? Object.values(result) : result;
|
|
125
121
|
};
|
|
126
|
-
|
|
127
122
|
//#endregion
|
|
128
|
-
//#region node_modules/.pnpm/@ark+util@0.56.
|
|
123
|
+
//#region node_modules/.pnpm/@ark+util@0.56.7/node_modules/@ark/util/out/records.js
|
|
129
124
|
/**
|
|
130
125
|
* Object.entries wrapper providing narrowed types for objects with known sets
|
|
131
126
|
* of keys, e.g. those defined internally as configs
|
|
132
127
|
*/
|
|
133
128
|
const entriesOf = Object.entries;
|
|
129
|
+
const keysOf = (o) => Object.keys(o);
|
|
134
130
|
const isKeyOf = (k, o) => k in o;
|
|
135
131
|
const hasKey = (o, k) => k in o;
|
|
136
132
|
var DynamicBase = class {
|
|
@@ -161,14 +157,13 @@ const withAlphabetizedKeys = (o) => {
|
|
|
161
157
|
for (let i = 0; i < keys.length; i++) result[keys[i]] = o[keys[i]];
|
|
162
158
|
return result;
|
|
163
159
|
};
|
|
164
|
-
const unset = noSuggest(`unset
|
|
160
|
+
const unset = noSuggest(`unset`);
|
|
165
161
|
const enumValues = (tsEnum) => Object.values(tsEnum).filter((v) => {
|
|
166
162
|
if (typeof v === "number") return true;
|
|
167
163
|
return typeof tsEnum[v] !== "number";
|
|
168
164
|
});
|
|
169
|
-
|
|
170
165
|
//#endregion
|
|
171
|
-
//#region node_modules/.pnpm/@ark+util@0.56.
|
|
166
|
+
//#region node_modules/.pnpm/@ark+util@0.56.7/node_modules/@ark/util/out/objectKinds.js
|
|
172
167
|
const ecmascriptConstructors = {
|
|
173
168
|
Array,
|
|
174
169
|
Boolean,
|
|
@@ -218,6 +213,7 @@ const builtinConstructors = {
|
|
|
218
213
|
Boolean
|
|
219
214
|
};
|
|
220
215
|
const objectKindOf = (data) => {
|
|
216
|
+
if (Array.isArray(data)) return "Array";
|
|
221
217
|
let prototype = Object.getPrototypeOf(data);
|
|
222
218
|
while (prototype?.constructor && (!isKeyOf(prototype.constructor.name, builtinConstructors) || !(data instanceof builtinConstructors[prototype.constructor.name]))) prototype = Object.getPrototypeOf(prototype);
|
|
223
219
|
const name = prototype?.constructor?.name;
|
|
@@ -278,18 +274,6 @@ const getBuiltinNameOfConstructor = (ctor) => {
|
|
|
278
274
|
const constructorName = Object(ctor).name ?? null;
|
|
279
275
|
return constructorName && isKeyOf(constructorName, builtinConstructors) && builtinConstructors[constructorName] === ctor ? constructorName : null;
|
|
280
276
|
};
|
|
281
|
-
/**
|
|
282
|
-
* Returns an array of constructors for all ancestors (i.e., prototypes) of a given object.
|
|
283
|
-
*/
|
|
284
|
-
const ancestorsOf = (o) => {
|
|
285
|
-
let proto = Object.getPrototypeOf(o);
|
|
286
|
-
const result = [];
|
|
287
|
-
while (proto !== null) {
|
|
288
|
-
result.push(proto.constructor);
|
|
289
|
-
proto = Object.getPrototypeOf(proto);
|
|
290
|
-
}
|
|
291
|
-
return result;
|
|
292
|
-
};
|
|
293
277
|
const constructorExtends = (ctor, base) => {
|
|
294
278
|
let current = ctor.prototype;
|
|
295
279
|
while (current !== null) {
|
|
@@ -298,9 +282,8 @@ const constructorExtends = (ctor, base) => {
|
|
|
298
282
|
}
|
|
299
283
|
return false;
|
|
300
284
|
};
|
|
301
|
-
|
|
302
285
|
//#endregion
|
|
303
|
-
//#region node_modules/.pnpm/@ark+util@0.56.
|
|
286
|
+
//#region node_modules/.pnpm/@ark+util@0.56.7/node_modules/@ark/util/out/clone.js
|
|
304
287
|
/** Deeply copy the properties of the a non-subclassed Object, Array or Date.*/
|
|
305
288
|
const deepClone = (input) => _clone(input, /* @__PURE__ */ new Map());
|
|
306
289
|
const _clone = (input, seen) => {
|
|
@@ -322,14 +305,13 @@ const _clone = (input, seen) => {
|
|
|
322
305
|
Object.defineProperties(cloned, propertyDescriptors);
|
|
323
306
|
return cloned;
|
|
324
307
|
};
|
|
325
|
-
|
|
326
308
|
//#endregion
|
|
327
|
-
//#region node_modules/.pnpm/@ark+util@0.56.
|
|
309
|
+
//#region node_modules/.pnpm/@ark+util@0.56.7/node_modules/@ark/util/out/functions.js
|
|
328
310
|
const cached = (thunk) => {
|
|
329
311
|
let result = unset;
|
|
330
312
|
return () => result === unset ? result = thunk() : result;
|
|
331
313
|
};
|
|
332
|
-
const isThunk = (value
|
|
314
|
+
const isThunk = (value) => typeof value === "function" && value.length === 0;
|
|
333
315
|
const DynamicFunction = class extends Function {
|
|
334
316
|
constructor(...args) {
|
|
335
317
|
const params = args.slice(0, -1);
|
|
@@ -346,8 +328,8 @@ const DynamicFunction = class extends Function {
|
|
|
346
328
|
}
|
|
347
329
|
};
|
|
348
330
|
var Callable = class {
|
|
349
|
-
constructor(fn
|
|
350
|
-
return Object.assign(Object.setPrototypeOf(fn
|
|
331
|
+
constructor(fn, ...[opts]) {
|
|
332
|
+
return Object.assign(Object.setPrototypeOf(fn.bind(opts?.bind ?? this), this.constructor.prototype), opts?.attach);
|
|
351
333
|
}
|
|
352
334
|
};
|
|
353
335
|
/**
|
|
@@ -366,22 +348,16 @@ const envHasCsp = cached(() => {
|
|
|
366
348
|
return true;
|
|
367
349
|
}
|
|
368
350
|
});
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
//#region node_modules/.pnpm/@ark+util@0.56.0/node_modules/@ark/util/out/generics.js
|
|
372
|
-
const brand = noSuggest("brand");
|
|
373
|
-
/** primitive key used to represent an inferred type at compile-time */
|
|
374
|
-
const inferred = noSuggest("arkInferred");
|
|
375
|
-
|
|
351
|
+
noSuggest("brand");
|
|
352
|
+
noSuggest("arkInferred");
|
|
376
353
|
//#endregion
|
|
377
|
-
//#region node_modules/.pnpm/@ark+util@0.56.
|
|
354
|
+
//#region node_modules/.pnpm/@ark+util@0.56.7/node_modules/@ark/util/out/hkt.js
|
|
378
355
|
noSuggest("args");
|
|
379
356
|
var Hkt = class {
|
|
380
357
|
constructor() {}
|
|
381
358
|
};
|
|
382
|
-
|
|
383
359
|
//#endregion
|
|
384
|
-
//#region node_modules/.pnpm/@ark+util@0.56.
|
|
360
|
+
//#region node_modules/.pnpm/@ark+util@0.56.7/node_modules/@ark/util/out/isomorphic.js
|
|
385
361
|
/** get a CJS/ESM compatible string representing the current file */
|
|
386
362
|
const fileName = () => {
|
|
387
363
|
try {
|
|
@@ -390,38 +366,34 @@ const fileName = () => {
|
|
|
390
366
|
return "unknown";
|
|
391
367
|
}
|
|
392
368
|
};
|
|
393
|
-
const env = globalThis.process?.env ?? {};
|
|
394
369
|
const isomorphic = {
|
|
395
370
|
fileName,
|
|
396
|
-
env
|
|
371
|
+
env: globalThis.process?.env ?? {}
|
|
397
372
|
};
|
|
398
|
-
|
|
399
373
|
//#endregion
|
|
400
|
-
//#region node_modules/.pnpm/@ark+util@0.56.
|
|
401
|
-
const capitalize$1 = (s) => s[0].toUpperCase() + s.slice(1);
|
|
402
|
-
const uncapitalize = (s) => s[0].toLowerCase() + s.slice(1);
|
|
403
|
-
const anchoredRegex = (regex
|
|
404
|
-
const anchoredSource = (regex
|
|
405
|
-
return `^(?:${typeof regex
|
|
374
|
+
//#region node_modules/.pnpm/@ark+util@0.56.7/node_modules/@ark/util/out/strings.js
|
|
375
|
+
const capitalize$1 = (s) => s.length === 0 ? s : s[0].toUpperCase() + s.slice(1);
|
|
376
|
+
const uncapitalize = (s) => s.length === 0 ? s : s[0].toLowerCase() + s.slice(1);
|
|
377
|
+
const anchoredRegex = (regex) => new RegExp(anchoredSource(regex), typeof regex === "string" ? "" : regex.flags);
|
|
378
|
+
const anchoredSource = (regex) => {
|
|
379
|
+
return `^(?:${typeof regex === "string" ? regex : regex.source})$`;
|
|
406
380
|
};
|
|
407
381
|
const RegexPatterns = {
|
|
408
382
|
negativeLookahead: (pattern) => `(?!${pattern})`,
|
|
409
383
|
nonCapturingGroup: (pattern) => `(?:${pattern})`
|
|
410
384
|
};
|
|
411
|
-
const Backslash = "\\";
|
|
412
385
|
const whitespaceChars = {
|
|
413
386
|
" ": 1,
|
|
414
387
|
"\n": 1,
|
|
415
388
|
" ": 1
|
|
416
389
|
};
|
|
417
|
-
|
|
418
390
|
//#endregion
|
|
419
|
-
//#region node_modules/.pnpm/@ark+util@0.56.
|
|
391
|
+
//#region node_modules/.pnpm/@ark+util@0.56.7/node_modules/@ark/util/out/numbers.js
|
|
420
392
|
const anchoredNegativeZeroPattern = /^-0\.?0*$/.source;
|
|
421
393
|
const positiveIntegerPattern = /[1-9]\d*/.source;
|
|
422
394
|
const looseDecimalPattern = /\.\d+/.source;
|
|
423
395
|
const strictDecimalPattern = /\.\d*[1-9]/.source;
|
|
424
|
-
const createNumberMatcher = (opts) => anchoredRegex(RegexPatterns.negativeLookahead(anchoredNegativeZeroPattern) + RegexPatterns.nonCapturingGroup("-?" + RegexPatterns.nonCapturingGroup(RegexPatterns.nonCapturingGroup("0|" + positiveIntegerPattern) + RegexPatterns.nonCapturingGroup(opts.decimalPattern) + "?") + (opts.allowDecimalOnly ? "|" + opts.decimalPattern
|
|
396
|
+
const createNumberMatcher = (opts) => anchoredRegex(RegexPatterns.negativeLookahead(anchoredNegativeZeroPattern) + RegexPatterns.nonCapturingGroup("-?" + RegexPatterns.nonCapturingGroup(RegexPatterns.nonCapturingGroup("0|" + positiveIntegerPattern) + RegexPatterns.nonCapturingGroup(opts.decimalPattern) + "?") + (opts.allowDecimalOnly ? "|" + opts.decimalPattern + "?" : "")));
|
|
425
397
|
/**
|
|
426
398
|
* Matches a well-formatted numeric expression according to the following rules:
|
|
427
399
|
* 1. Must include an integer portion (i.e. '.321' must be written as '0.321')
|
|
@@ -444,7 +416,7 @@ const numericStringMatcher = createNumberMatcher({
|
|
|
444
416
|
decimalPattern: looseDecimalPattern,
|
|
445
417
|
allowDecimalOnly: true
|
|
446
418
|
});
|
|
447
|
-
|
|
419
|
+
numericStringMatcher.test.bind(numericStringMatcher);
|
|
448
420
|
const numberLikeMatcher = /^-?\d*\.?\d*$/;
|
|
449
421
|
const isNumberLike = (s) => s.length !== 0 && numberLikeMatcher.test(s);
|
|
450
422
|
/**
|
|
@@ -472,11 +444,11 @@ const tryParseWellFormedNumber = (token, options) => parseNumeric(token, "number
|
|
|
472
444
|
});
|
|
473
445
|
const tryParseInteger = (token, options) => parseNumeric(token, "integer", options);
|
|
474
446
|
const parseNumeric = (token, kind, options) => {
|
|
475
|
-
const value
|
|
476
|
-
if (!Number.isNaN(value
|
|
447
|
+
const value = parseKind(token, kind);
|
|
448
|
+
if (!Number.isNaN(value)) {
|
|
477
449
|
if (isKindLike(token, kind)) {
|
|
478
|
-
if (options?.strict) return isWellFormed(token, kind) ? value
|
|
479
|
-
return value
|
|
450
|
+
if (options?.strict) return isWellFormed(token, kind) ? value : throwParseError(writeMalformedNumericLiteralMessage(token, kind));
|
|
451
|
+
return value;
|
|
480
452
|
}
|
|
481
453
|
}
|
|
482
454
|
return options?.errorOnFail ? throwParseError(options?.errorOnFail === true ? `Failed to parse ${numericLiteralDescriptions[kind]} from '${token}'` : options?.errorOnFail) : void 0;
|
|
@@ -484,57 +456,50 @@ const parseNumeric = (token, kind, options) => {
|
|
|
484
456
|
const tryParseWellFormedBigint = (def) => {
|
|
485
457
|
if (def[def.length - 1] !== "n") return;
|
|
486
458
|
const maybeIntegerLiteral = def.slice(0, -1);
|
|
487
|
-
let value
|
|
459
|
+
let value;
|
|
488
460
|
try {
|
|
489
|
-
value
|
|
461
|
+
value = BigInt(maybeIntegerLiteral);
|
|
490
462
|
} catch {
|
|
491
463
|
return;
|
|
492
464
|
}
|
|
493
|
-
if (wellFormedIntegerMatcher.test(maybeIntegerLiteral)) return value
|
|
465
|
+
if (wellFormedIntegerMatcher.test(maybeIntegerLiteral)) return value;
|
|
494
466
|
if (integerLikeMatcher.test(maybeIntegerLiteral)) return throwParseError(writeMalformedNumericLiteralMessage(def, "bigint"));
|
|
495
467
|
};
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
//#region node_modules/.pnpm/@ark+util@0.56.0/node_modules/@ark/util/out/registry.js
|
|
499
|
-
const arkUtilVersion = "0.56.0";
|
|
500
|
-
const initialRegistryContents = {
|
|
501
|
-
version: arkUtilVersion,
|
|
468
|
+
const registry = {
|
|
469
|
+
version: "0.56.7",
|
|
502
470
|
filename: isomorphic.fileName(),
|
|
503
471
|
FileConstructor
|
|
504
472
|
};
|
|
505
|
-
const registry = initialRegistryContents;
|
|
506
473
|
const namesByResolution = /* @__PURE__ */ new Map();
|
|
507
474
|
const nameCounts = Object.create(null);
|
|
508
|
-
const register = (value
|
|
509
|
-
const existingName = namesByResolution.get(value
|
|
475
|
+
const register = (value) => {
|
|
476
|
+
const existingName = namesByResolution.get(value);
|
|
510
477
|
if (existingName) return existingName;
|
|
511
|
-
let name = baseNameFor(value
|
|
478
|
+
let name = baseNameFor(value);
|
|
512
479
|
if (nameCounts[name]) name = `${name}${nameCounts[name]++}`;
|
|
513
480
|
else nameCounts[name] = 1;
|
|
514
|
-
registry[name] = value
|
|
515
|
-
namesByResolution.set(value
|
|
481
|
+
registry[name] = value;
|
|
482
|
+
namesByResolution.set(value, name);
|
|
516
483
|
return name;
|
|
517
484
|
};
|
|
518
485
|
const isDotAccessible = (keyName) => /^[$A-Z_a-z][\w$]*$/.test(keyName);
|
|
519
|
-
const baseNameFor = (value
|
|
520
|
-
switch (typeof value
|
|
486
|
+
const baseNameFor = (value) => {
|
|
487
|
+
switch (typeof value) {
|
|
521
488
|
case "object": {
|
|
522
|
-
if (value
|
|
523
|
-
const prefix = objectKindOf(value
|
|
489
|
+
if (value === null) break;
|
|
490
|
+
const prefix = objectKindOf(value) ?? "object";
|
|
524
491
|
return prefix[0].toLowerCase() + prefix.slice(1);
|
|
525
492
|
}
|
|
526
|
-
case "function": return isDotAccessible(value
|
|
527
|
-
case "symbol": return value
|
|
493
|
+
case "function": return isDotAccessible(value.name) ? value.name : "fn";
|
|
494
|
+
case "symbol": return value.description && isDotAccessible(value.description) ? value.description : "symbol";
|
|
528
495
|
}
|
|
529
|
-
return throwInternalError(`Unexpected attempt to register serializable value of type ${domainOf(value
|
|
496
|
+
return throwInternalError(`Unexpected attempt to register serializable value of type ${domainOf(value)}`);
|
|
530
497
|
};
|
|
531
|
-
|
|
532
498
|
//#endregion
|
|
533
|
-
//#region node_modules/.pnpm/@ark+util@0.56.
|
|
534
|
-
const serializePrimitive = (value
|
|
535
|
-
|
|
499
|
+
//#region node_modules/.pnpm/@ark+util@0.56.7/node_modules/@ark/util/out/primitive.js
|
|
500
|
+
const serializePrimitive = (value) => typeof value === "string" ? JSON.stringify(value) : typeof value === "bigint" ? `${value}n` : `${value}`;
|
|
536
501
|
//#endregion
|
|
537
|
-
//#region node_modules/.pnpm/@ark+util@0.56.
|
|
502
|
+
//#region node_modules/.pnpm/@ark+util@0.56.7/node_modules/@ark/util/out/serialize.js
|
|
538
503
|
const snapshot = (data, opts = {}) => _serialize(data, {
|
|
539
504
|
onUndefined: `$ark.undefined`,
|
|
540
505
|
onBigInt: (n) => `$ark.bigint-${n}`,
|
|
@@ -545,37 +510,42 @@ const printable = (data, opts) => {
|
|
|
545
510
|
case "object":
|
|
546
511
|
const o = data;
|
|
547
512
|
const ctorName = o.constructor?.name ?? "Object";
|
|
548
|
-
return ctorName === "Object" || ctorName === "Array" ? opts?.quoteKeys === false ? stringifyUnquoted(o, opts?.indent ?? 0, "") : JSON.stringify(_serialize(o, printableOpts, []), null, opts?.indent) : stringifyUnquoted(o, opts?.indent ?? 0, "");
|
|
513
|
+
return ctorName === "Object" || ctorName === "Array" ? opts?.quoteKeys === false ? stringifyUnquoted(o, opts?.indent ?? 0, "") : JSON.stringify(_serialize(o, printableOpts, []), null, opts?.indent).replace(quotedBigIntMarker, "$1") : stringifyUnquoted(o, opts?.indent ?? 0, "");
|
|
549
514
|
case "symbol": return printableOpts.onSymbol(data);
|
|
550
515
|
default: return serializePrimitive(data);
|
|
551
516
|
}
|
|
552
517
|
};
|
|
553
|
-
const stringifyUnquoted = (value
|
|
554
|
-
if (typeof value
|
|
555
|
-
if (typeof value
|
|
556
|
-
const nextIndent = currentIndent + " ".repeat(indent
|
|
557
|
-
if (Array.isArray(value
|
|
558
|
-
if (value
|
|
559
|
-
const items = value
|
|
560
|
-
return indent
|
|
518
|
+
const stringifyUnquoted = (value, indent, currentIndent) => {
|
|
519
|
+
if (typeof value === "function") return printableOpts.onFunction(value);
|
|
520
|
+
if (typeof value !== "object" || value === null) return serializePrimitive(value);
|
|
521
|
+
const nextIndent = currentIndent + " ".repeat(indent);
|
|
522
|
+
if (Array.isArray(value)) {
|
|
523
|
+
if (value.length === 0) return "[]";
|
|
524
|
+
const items = value.map((item) => stringifyUnquoted(item, indent, nextIndent)).join(",\n" + nextIndent);
|
|
525
|
+
return indent ? `[\n${nextIndent}${items}\n${currentIndent}]` : `[${items}]`;
|
|
561
526
|
}
|
|
562
|
-
const ctorName = value
|
|
527
|
+
const ctorName = value.constructor?.name ?? "Object";
|
|
563
528
|
if (ctorName === "Object") {
|
|
564
|
-
const keyValues = stringAndSymbolicEntriesOf(value
|
|
565
|
-
|
|
529
|
+
const keyValues = stringAndSymbolicEntriesOf(value).map(([key, val]) => {
|
|
530
|
+
const stringifiedKey = typeof key === "symbol" ? printableOpts.onSymbol(key) : isDotAccessible(key) ? key : JSON.stringify(key);
|
|
531
|
+
const stringifiedValue = stringifyUnquoted(val, indent, nextIndent);
|
|
532
|
+
return `${nextIndent}${stringifiedKey}: ${stringifiedValue}`;
|
|
566
533
|
});
|
|
567
534
|
if (keyValues.length === 0) return "{}";
|
|
568
|
-
return indent
|
|
535
|
+
return indent ? `{\n${keyValues.join(",\n")}\n${currentIndent}}` : `{${keyValues.join(", ")}}`;
|
|
569
536
|
}
|
|
570
|
-
if (value
|
|
571
|
-
if ("expression" in value
|
|
537
|
+
if (value instanceof Date) return describeCollapsibleDate(value);
|
|
538
|
+
if ("expression" in value && typeof value.expression === "string") return value.expression;
|
|
572
539
|
return ctorName;
|
|
573
540
|
};
|
|
574
541
|
const printableOpts = {
|
|
575
542
|
onCycle: () => "(cycle)",
|
|
576
543
|
onSymbol: (v) => `Symbol(${register(v)})`,
|
|
577
|
-
onFunction: (v) => `Function(${register(v)})
|
|
544
|
+
onFunction: (v) => `Function(${register(v)})`,
|
|
545
|
+
onBigInt: (n) => `${bigIntMarker}${n}n`
|
|
578
546
|
};
|
|
547
|
+
const bigIntMarker = "";
|
|
548
|
+
const quotedBigIntMarker = new RegExp(`"${bigIntMarker}(-?\\d+n)"`, "g");
|
|
579
549
|
const _serialize = (data, opts, seen) => {
|
|
580
550
|
switch (domainOf(data)) {
|
|
581
551
|
case "object": {
|
|
@@ -612,12 +582,11 @@ const describeCollapsibleDate = (date) => {
|
|
|
612
582
|
if (month === 0 && dayOfMonth === 1 && hours === 0 && minutes === 0 && seconds === 0 && milliseconds === 0) return `${year}`;
|
|
613
583
|
const datePortion = `${months[month]} ${dayOfMonth}, ${year}`;
|
|
614
584
|
if (hours === 0 && minutes === 0 && seconds === 0 && milliseconds === 0) return datePortion;
|
|
615
|
-
|
|
616
|
-
const suffix
|
|
617
|
-
|
|
585
|
+
const h = hours % 12 || 12;
|
|
586
|
+
const suffix = hours < 12 ? " AM" : " PM";
|
|
587
|
+
let timePortion = seconds || milliseconds ? `${h}:${pad(minutes, 2)}:${pad(seconds, 2)}` : `${h}:${pad(minutes, 2)}`;
|
|
618
588
|
if (milliseconds) timePortion += `.${pad(milliseconds, 3)}`;
|
|
619
|
-
|
|
620
|
-
return `${timePortion + suffix$1}, ${datePortion}`;
|
|
589
|
+
return `${timePortion + suffix}, ${datePortion}`;
|
|
621
590
|
};
|
|
622
591
|
const months = [
|
|
623
592
|
"January",
|
|
@@ -633,11 +602,9 @@ const months = [
|
|
|
633
602
|
"November",
|
|
634
603
|
"December"
|
|
635
604
|
];
|
|
636
|
-
const
|
|
637
|
-
const pad = (value$1, length) => String(value$1).padStart(length, "0");
|
|
638
|
-
|
|
605
|
+
const pad = (value, length) => String(value).padStart(length, "0");
|
|
639
606
|
//#endregion
|
|
640
|
-
//#region node_modules/.pnpm/@ark+util@0.56.
|
|
607
|
+
//#region node_modules/.pnpm/@ark+util@0.56.7/node_modules/@ark/util/out/path.js
|
|
641
608
|
const appendStringifiedKey = (path, prop, ...[opts]) => {
|
|
642
609
|
const stringifySymbol = opts?.stringifySymbol ?? printable;
|
|
643
610
|
let propAccessChain = path;
|
|
@@ -684,9 +651,8 @@ var ReadonlyPath = class extends ReadonlyArray {
|
|
|
684
651
|
return this.cache.stringifyAncestors = result;
|
|
685
652
|
}
|
|
686
653
|
};
|
|
687
|
-
|
|
688
654
|
//#endregion
|
|
689
|
-
//#region node_modules/.pnpm/@ark+util@0.56.
|
|
655
|
+
//#region node_modules/.pnpm/@ark+util@0.56.7/node_modules/@ark/util/out/scanner.js
|
|
690
656
|
var Scanner = class {
|
|
691
657
|
chars;
|
|
692
658
|
i;
|
|
@@ -715,13 +681,13 @@ var Scanner = class {
|
|
|
715
681
|
else shifted += this.shift();
|
|
716
682
|
return shifted;
|
|
717
683
|
}
|
|
718
|
-
shiftUntilEscapable(condition) {
|
|
684
|
+
shiftUntilEscapable(condition, escapeEscape = "") {
|
|
719
685
|
let shifted = "";
|
|
720
|
-
while (this.lookahead) if (this.lookahead ===
|
|
686
|
+
while (this.lookahead) if (this.lookahead === "\\") {
|
|
721
687
|
this.shift();
|
|
722
688
|
if (condition(this, shifted)) shifted += this.shift();
|
|
723
|
-
else if (this.lookahead ===
|
|
724
|
-
else shifted +=
|
|
689
|
+
else if (this.lookahead === "\\") shifted += `${escapeEscape}${this.shift()}`;
|
|
690
|
+
else shifted += `\\${this.shift()}`;
|
|
725
691
|
} else if (condition(this, shifted)) break;
|
|
726
692
|
else shifted += this.shift();
|
|
727
693
|
return shifted;
|
|
@@ -759,27 +725,9 @@ var Scanner = class {
|
|
|
759
725
|
};
|
|
760
726
|
const writeUnmatchedGroupCloseMessage = (char, unscanned) => `Unmatched ${char}${unscanned === "" ? "" : ` before ${unscanned}`}`;
|
|
761
727
|
const writeUnclosedGroupMessage = (missingChar) => `Missing ${missingChar}`;
|
|
762
|
-
|
|
763
|
-
//#endregion
|
|
764
|
-
//#region node_modules/.pnpm/@ark+util@0.56.0/node_modules/@ark/util/out/traits.js
|
|
765
|
-
const implementedTraits = noSuggest("implementedTraits");
|
|
766
|
-
const hasTrait = (traitClass) => (o) => {
|
|
767
|
-
if (!hasDomain(o, "object")) return false;
|
|
768
|
-
if (implementedTraits in o.constructor && o.constructor[implementedTraits].includes(traitClass)) return true;
|
|
769
|
-
return ancestorsOf(o).includes(traitClass);
|
|
770
|
-
};
|
|
771
|
-
/** @ts-ignore required to extend NoopBase */
|
|
772
|
-
var Trait = class extends NoopBase {
|
|
773
|
-
static get [Symbol.hasInstance]() {
|
|
774
|
-
return hasTrait(this);
|
|
775
|
-
}
|
|
776
|
-
traitsOf() {
|
|
777
|
-
return implementedTraits in this.constructor ? this.constructor[implementedTraits] : [];
|
|
778
|
-
}
|
|
779
|
-
};
|
|
780
|
-
|
|
728
|
+
noSuggest("implementedTraits");
|
|
781
729
|
//#endregion
|
|
782
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
730
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/shared/registry.js
|
|
783
731
|
let _registryName = "$ark";
|
|
784
732
|
let suffix = 2;
|
|
785
733
|
while (_registryName in globalThis) _registryName = `$ark${suffix++}`;
|
|
@@ -787,10 +735,9 @@ const registryName = _registryName;
|
|
|
787
735
|
globalThis[registryName] = registry;
|
|
788
736
|
const $ark = registry;
|
|
789
737
|
const reference = (name) => `${registryName}.${name}`;
|
|
790
|
-
const registeredReference = (value
|
|
791
|
-
|
|
738
|
+
const registeredReference = (value) => reference(register(value));
|
|
792
739
|
//#endregion
|
|
793
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
740
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/shared/compile.js
|
|
794
741
|
var CompiledFunction = class extends CastableBase {
|
|
795
742
|
argNames;
|
|
796
743
|
body = "";
|
|
@@ -845,27 +792,27 @@ var CompiledFunction = class extends CastableBase {
|
|
|
845
792
|
return this.block(`for (let i = ${initialValue}; ${until}; i++)`, body);
|
|
846
793
|
}
|
|
847
794
|
/** Current key is "k" */
|
|
848
|
-
forIn(object
|
|
849
|
-
return this.block(`for (const k in ${object
|
|
795
|
+
forIn(object, body) {
|
|
796
|
+
return this.block(`for (const k in ${object})`, body);
|
|
850
797
|
}
|
|
851
|
-
block(prefix, contents, suffix
|
|
798
|
+
block(prefix, contents, suffix = "") {
|
|
852
799
|
this.line(`${prefix} {`);
|
|
853
800
|
this.indent();
|
|
854
801
|
contents(this);
|
|
855
802
|
this.dedent();
|
|
856
|
-
return this.line(`}${suffix
|
|
803
|
+
return this.line(`}${suffix}`);
|
|
857
804
|
}
|
|
858
805
|
return(expression = "") {
|
|
859
806
|
return this.line(`return ${expression}`);
|
|
860
807
|
}
|
|
861
|
-
write(name = "anonymous", indent
|
|
862
|
-
return `${name}(${this.argNames.join(", ")}) { ${indent
|
|
808
|
+
write(name = "anonymous", indent = 0) {
|
|
809
|
+
return `${name}(${this.argNames.join(", ")}) { ${indent ? this.body.split("\n").map((l) => " ".repeat(indent) + `${l}`).join("\n") : this.body} }`;
|
|
863
810
|
}
|
|
864
811
|
compile() {
|
|
865
812
|
return new DynamicFunction(...this.argNames, this.body);
|
|
866
813
|
}
|
|
867
814
|
};
|
|
868
|
-
const compileSerializedValue = (value
|
|
815
|
+
const compileSerializedValue = (value) => hasDomain(value, "object") || typeof value === "symbol" ? registeredReference(value) : serializePrimitive(value);
|
|
869
816
|
const compileLiteralPropAccess = (key, optional = false) => {
|
|
870
817
|
if (typeof key === "string" && isDotAccessible(key)) return `${optional ? "?" : ""}.${key}`;
|
|
871
818
|
return indexPropAccess(serializeLiteralKey(key), optional);
|
|
@@ -880,10 +827,10 @@ var NodeCompiler = class extends CompiledFunction {
|
|
|
880
827
|
this.traversalKind = ctx.kind;
|
|
881
828
|
this.optimistic = ctx.optimistic === true;
|
|
882
829
|
}
|
|
883
|
-
invoke(node
|
|
830
|
+
invoke(node, opts) {
|
|
884
831
|
const arg = opts?.arg ?? this.data;
|
|
885
|
-
const requiresContext = typeof node
|
|
886
|
-
const id = typeof node
|
|
832
|
+
const requiresContext = typeof node === "string" ? true : this.requiresContextFor(node);
|
|
833
|
+
const id = typeof node === "string" ? node : node.id;
|
|
887
834
|
if (requiresContext) return `${this.referenceToId(id, opts)}(${arg}, ${this.ctx})`;
|
|
888
835
|
return `${this.referenceToId(id, opts)}(${arg})`;
|
|
889
836
|
}
|
|
@@ -891,8 +838,8 @@ var NodeCompiler = class extends CompiledFunction {
|
|
|
891
838
|
const base = `this.${id}${opts?.kind ?? this.traversalKind}`;
|
|
892
839
|
return opts?.bind ? `${base}.bind(${opts?.bind})` : base;
|
|
893
840
|
}
|
|
894
|
-
requiresContextFor(node
|
|
895
|
-
return this.traversalKind === "Apply" || node
|
|
841
|
+
requiresContextFor(node) {
|
|
842
|
+
return this.traversalKind === "Apply" || node.allowsRequiresContext;
|
|
896
843
|
}
|
|
897
844
|
initializeErrorCount() {
|
|
898
845
|
return this.const("errorCount", "ctx.currentErrorCount");
|
|
@@ -903,27 +850,25 @@ var NodeCompiler = class extends CompiledFunction {
|
|
|
903
850
|
returnIfFailFast() {
|
|
904
851
|
return this.if("ctx.failFast && ctx.currentErrorCount > errorCount", () => this.return());
|
|
905
852
|
}
|
|
906
|
-
traverseKey(keyExpression, accessExpression, node
|
|
907
|
-
const requiresContext = this.requiresContextFor(node
|
|
853
|
+
traverseKey(keyExpression, accessExpression, node) {
|
|
854
|
+
const requiresContext = this.requiresContextFor(node);
|
|
908
855
|
if (requiresContext) this.line(`${this.ctx}.path.push(${keyExpression})`);
|
|
909
|
-
this.check(node
|
|
856
|
+
this.check(node, { arg: accessExpression });
|
|
910
857
|
if (requiresContext) this.line(`${this.ctx}.path.pop()`);
|
|
911
858
|
return this;
|
|
912
859
|
}
|
|
913
|
-
check(node
|
|
914
|
-
return this.traversalKind === "Allows" ? this.if(`!${this.invoke(node
|
|
860
|
+
check(node, opts) {
|
|
861
|
+
return this.traversalKind === "Allows" ? this.if(`!${this.invoke(node, opts)}`, () => this.return(false)) : this.line(this.invoke(node, opts));
|
|
915
862
|
}
|
|
916
863
|
};
|
|
917
|
-
|
|
918
864
|
//#endregion
|
|
919
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
865
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/shared/utils.js
|
|
920
866
|
const makeRootAndArrayPropertiesMutable = (o) => flatMorph(o, (k, v) => [k, isArray(v) ? [...v] : v]);
|
|
921
867
|
const arkKind = noSuggest("arkKind");
|
|
922
|
-
const hasArkKind = (value
|
|
923
|
-
const isNode = (value
|
|
924
|
-
|
|
868
|
+
const hasArkKind = (value, kind) => value?.[arkKind] === kind;
|
|
869
|
+
const isNode = (value) => hasArkKind(value, "root") || hasArkKind(value, "constraint");
|
|
925
870
|
//#endregion
|
|
926
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
871
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/shared/implement.js
|
|
927
872
|
const basisKinds = [
|
|
928
873
|
"unit",
|
|
929
874
|
"proto",
|
|
@@ -965,11 +910,11 @@ const nodeKinds = [...rootKinds, ...constraintKinds];
|
|
|
965
910
|
const constraintKeys = flatMorph(constraintKinds, (i, kind) => [kind, 1]);
|
|
966
911
|
const structureKeys = flatMorph([...structuralKinds, "undeclared"], (i, k) => [k, 1]);
|
|
967
912
|
const precedenceByKind = flatMorph(nodeKinds, (i, kind) => [kind, i]);
|
|
968
|
-
const isNodeKind = (value
|
|
913
|
+
const isNodeKind = (value) => typeof value === "string" && value in precedenceByKind;
|
|
969
914
|
const precedenceOfKind = (kind) => precedenceByKind[kind];
|
|
970
915
|
const schemaKindsRightOf = (kind) => rootKinds.slice(precedenceOfKind(kind) + 1);
|
|
971
|
-
|
|
972
|
-
|
|
916
|
+
[...schemaKindsRightOf("union")];
|
|
917
|
+
[...schemaKindsRightOf("morph")];
|
|
973
918
|
const defaultValueSerializer = (v) => {
|
|
974
919
|
if (typeof v === "string" || typeof v === "boolean" || v === null) return v;
|
|
975
920
|
if (typeof v === "number") {
|
|
@@ -986,23 +931,22 @@ const compileObjectLiteral = (ctx) => {
|
|
|
986
931
|
return result + " }";
|
|
987
932
|
};
|
|
988
933
|
const implementNode = (_) => {
|
|
989
|
-
const implementation
|
|
990
|
-
if (implementation
|
|
991
|
-
implementation
|
|
992
|
-
implementation
|
|
993
|
-
implementation
|
|
994
|
-
implementation
|
|
934
|
+
const implementation = _;
|
|
935
|
+
if (implementation.hasAssociatedError) {
|
|
936
|
+
implementation.defaults.expected ??= (ctx) => "description" in ctx ? ctx.description : implementation.defaults.description(ctx);
|
|
937
|
+
implementation.defaults.actual ??= (data) => printable(data);
|
|
938
|
+
implementation.defaults.problem ??= (ctx) => `must be ${ctx.expected}${ctx.actual ? ` (was ${ctx.actual})` : ""}`;
|
|
939
|
+
implementation.defaults.message ??= (ctx) => {
|
|
995
940
|
if (ctx.path.length === 0) return ctx.problem;
|
|
996
941
|
const problemWithLocation = `${ctx.propString} ${ctx.problem}`;
|
|
997
942
|
if (problemWithLocation[0] === "[") return `value at ${problemWithLocation}`;
|
|
998
943
|
return problemWithLocation;
|
|
999
944
|
};
|
|
1000
945
|
}
|
|
1001
|
-
return implementation
|
|
946
|
+
return implementation;
|
|
1002
947
|
};
|
|
1003
|
-
|
|
1004
948
|
//#endregion
|
|
1005
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
949
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/shared/toJsonSchema.js
|
|
1006
950
|
var ToJsonSchemaError = class extends Error {
|
|
1007
951
|
name = "ToJsonSchemaError";
|
|
1008
952
|
code;
|
|
@@ -1019,49 +963,47 @@ var ToJsonSchemaError = class extends Error {
|
|
|
1019
963
|
return this.code === code;
|
|
1020
964
|
}
|
|
1021
965
|
};
|
|
1022
|
-
const defaultConfig = {
|
|
1023
|
-
target: "draft-2020-12",
|
|
1024
|
-
dialect: "https://json-schema.org/draft/2020-12/schema",
|
|
1025
|
-
useRefs: false,
|
|
1026
|
-
fallback: {
|
|
1027
|
-
arrayObject: (ctx) => ToJsonSchema.throw("arrayObject", ctx),
|
|
1028
|
-
arrayPostfix: (ctx) => ToJsonSchema.throw("arrayPostfix", ctx),
|
|
1029
|
-
defaultValue: (ctx) => ToJsonSchema.throw("defaultValue", ctx),
|
|
1030
|
-
domain: (ctx) => ToJsonSchema.throw("domain", ctx),
|
|
1031
|
-
morph: (ctx) => ToJsonSchema.throw("morph", ctx),
|
|
1032
|
-
patternIntersection: (ctx) => ToJsonSchema.throw("patternIntersection", ctx),
|
|
1033
|
-
predicate: (ctx) => ToJsonSchema.throw("predicate", ctx),
|
|
1034
|
-
proto: (ctx) => ToJsonSchema.throw("proto", ctx),
|
|
1035
|
-
symbolKey: (ctx) => ToJsonSchema.throw("symbolKey", ctx),
|
|
1036
|
-
unit: (ctx) => ToJsonSchema.throw("unit", ctx),
|
|
1037
|
-
date: (ctx) => ToJsonSchema.throw("date", ctx)
|
|
1038
|
-
}
|
|
1039
|
-
};
|
|
1040
966
|
const ToJsonSchema = {
|
|
1041
967
|
Error: ToJsonSchemaError,
|
|
1042
968
|
throw: (...args) => {
|
|
1043
969
|
throw new ToJsonSchema.Error(...args);
|
|
1044
970
|
},
|
|
1045
|
-
throwInternalOperandError: (kind, schema
|
|
1046
|
-
defaultConfig
|
|
971
|
+
throwInternalOperandError: (kind, schema) => throwInternalError(`Unexpected JSON Schema input for ${kind}: ${printable(schema)}`),
|
|
972
|
+
defaultConfig: {
|
|
973
|
+
target: "draft-2020-12",
|
|
974
|
+
dialect: "https://json-schema.org/draft/2020-12/schema",
|
|
975
|
+
useRefs: false,
|
|
976
|
+
fallback: {
|
|
977
|
+
arrayObject: (ctx) => ToJsonSchema.throw("arrayObject", ctx),
|
|
978
|
+
arrayPostfix: (ctx) => ToJsonSchema.throw("arrayPostfix", ctx),
|
|
979
|
+
defaultValue: (ctx) => ToJsonSchema.throw("defaultValue", ctx),
|
|
980
|
+
domain: (ctx) => ToJsonSchema.throw("domain", ctx),
|
|
981
|
+
morph: (ctx) => ToJsonSchema.throw("morph", ctx),
|
|
982
|
+
patternIntersection: (ctx) => ToJsonSchema.throw("patternIntersection", ctx),
|
|
983
|
+
predicate: (ctx) => ToJsonSchema.throw("predicate", ctx),
|
|
984
|
+
proto: (ctx) => ToJsonSchema.throw("proto", ctx),
|
|
985
|
+
symbolKey: (ctx) => ToJsonSchema.throw("symbolKey", ctx),
|
|
986
|
+
unit: (ctx) => ToJsonSchema.throw("unit", ctx),
|
|
987
|
+
date: (ctx) => ToJsonSchema.throw("date", ctx)
|
|
988
|
+
}
|
|
989
|
+
}
|
|
1047
990
|
};
|
|
1048
|
-
|
|
1049
991
|
//#endregion
|
|
1050
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
992
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/config.js
|
|
1051
993
|
$ark.config ??= {};
|
|
1052
994
|
const mergeConfigs = (base, merged) => {
|
|
1053
995
|
if (!merged) return base;
|
|
1054
996
|
const result = { ...base };
|
|
1055
997
|
let k;
|
|
1056
998
|
for (k in merged) {
|
|
1057
|
-
const keywords
|
|
999
|
+
const keywords = { ...base.keywords };
|
|
1058
1000
|
if (k === "keywords") {
|
|
1059
1001
|
for (const flatAlias in merged[k]) {
|
|
1060
1002
|
const v = merged.keywords[flatAlias];
|
|
1061
1003
|
if (v === void 0) continue;
|
|
1062
|
-
keywords
|
|
1004
|
+
keywords[flatAlias] = typeof v === "string" ? { description: v } : v;
|
|
1063
1005
|
}
|
|
1064
|
-
result.keywords = keywords
|
|
1006
|
+
result.keywords = keywords;
|
|
1065
1007
|
} else if (k === "toJsonSchema") result[k] = mergeToJsonSchemaConfigs(base.toJsonSchema, merged.toJsonSchema);
|
|
1066
1008
|
else if (isNodeKind(k)) result[k] = {
|
|
1067
1009
|
...base[k],
|
|
@@ -1101,9 +1043,8 @@ const mergeFallbacks = (base, merged) => {
|
|
|
1101
1043
|
return result;
|
|
1102
1044
|
};
|
|
1103
1045
|
const normalizeFallback = (fallback) => typeof fallback === "function" ? { default: fallback } : fallback ?? {};
|
|
1104
|
-
|
|
1105
1046
|
//#endregion
|
|
1106
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
1047
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/shared/errors.js
|
|
1107
1048
|
var ArkError = class ArkError extends CastableBase {
|
|
1108
1049
|
[arkKind] = "error";
|
|
1109
1050
|
path;
|
|
@@ -1120,9 +1061,9 @@ var ArkError = class ArkError extends CastableBase {
|
|
|
1120
1061
|
if (input.code === "union") input.errors = input.errors.flatMap((innerError) => {
|
|
1121
1062
|
const flat = innerError.hasCode("union") ? innerError.errors : [innerError];
|
|
1122
1063
|
if (!prefixPath && !relativePath) return flat;
|
|
1123
|
-
return flat.map((e) => e.transform((e
|
|
1124
|
-
...e
|
|
1125
|
-
path: conflatenateAll(prefixPath, e
|
|
1064
|
+
return flat.map((e) => e.transform((e) => ({
|
|
1065
|
+
...e,
|
|
1066
|
+
path: conflatenateAll(prefixPath, e.path, relativePath)
|
|
1126
1067
|
})));
|
|
1127
1068
|
});
|
|
1128
1069
|
this.nodeConfig = ctx.config[this.code];
|
|
@@ -1194,6 +1135,14 @@ var ArkError = class ArkError extends CastableBase {
|
|
|
1194
1135
|
*/
|
|
1195
1136
|
var ArkErrors = class ArkErrors extends ReadonlyArray {
|
|
1196
1137
|
[arkKind] = "errors";
|
|
1138
|
+
/**
|
|
1139
|
+
* Inherited array methods (`map`, `filter`, `slice`, …) return a plain
|
|
1140
|
+
* `Array`, not another `ArkErrors`, so callbacks that return primitives
|
|
1141
|
+
* (e.g. `issues.map(i => i.message)`) cannot populate a new `ArkErrors` instance.
|
|
1142
|
+
*/
|
|
1143
|
+
static get [Symbol.species]() {
|
|
1144
|
+
return Array;
|
|
1145
|
+
}
|
|
1197
1146
|
ctx;
|
|
1198
1147
|
constructor(ctx) {
|
|
1199
1148
|
super();
|
|
@@ -1290,6 +1239,12 @@ var ArkErrors = class ArkErrors extends ReadonlyArray {
|
|
|
1290
1239
|
return this.toString();
|
|
1291
1240
|
}
|
|
1292
1241
|
/**
|
|
1242
|
+
* Alias of {@link summary} for consistency with `Error`.
|
|
1243
|
+
*/
|
|
1244
|
+
get message() {
|
|
1245
|
+
return this.summary;
|
|
1246
|
+
}
|
|
1247
|
+
/**
|
|
1293
1248
|
* Alias of this ArkErrors instance for StandardSchema compatibility.
|
|
1294
1249
|
*/
|
|
1295
1250
|
get issues() {
|
|
@@ -1317,9 +1272,8 @@ var TraversalError = class extends Error {
|
|
|
1317
1272
|
}
|
|
1318
1273
|
};
|
|
1319
1274
|
const indent = (error) => error.toString().split("\n").join("\n ");
|
|
1320
|
-
|
|
1321
1275
|
//#endregion
|
|
1322
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
1276
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/shared/traversal.js
|
|
1323
1277
|
var Traversal = class {
|
|
1324
1278
|
/**
|
|
1325
1279
|
* #### the path being validated or morphed
|
|
@@ -1481,7 +1435,7 @@ var Traversal = class {
|
|
|
1481
1435
|
const morphIsNode = isNode(morph);
|
|
1482
1436
|
const result = morph(parent === void 0 ? this.root : parent[key], this);
|
|
1483
1437
|
if (result instanceof ArkError) {
|
|
1484
|
-
|
|
1438
|
+
this.errors.add(result);
|
|
1485
1439
|
break;
|
|
1486
1440
|
}
|
|
1487
1441
|
if (result instanceof ArkErrors) {
|
|
@@ -1495,16 +1449,15 @@ var Traversal = class {
|
|
|
1495
1449
|
}
|
|
1496
1450
|
}
|
|
1497
1451
|
};
|
|
1498
|
-
const traverseKey = (key, fn
|
|
1499
|
-
if (!ctx) return fn
|
|
1452
|
+
const traverseKey = (key, fn, ctx) => {
|
|
1453
|
+
if (!ctx) return fn();
|
|
1500
1454
|
ctx.path.push(key);
|
|
1501
|
-
const result = fn
|
|
1455
|
+
const result = fn();
|
|
1502
1456
|
ctx.path.pop();
|
|
1503
1457
|
return result;
|
|
1504
1458
|
};
|
|
1505
|
-
|
|
1506
1459
|
//#endregion
|
|
1507
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
1460
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/node.js
|
|
1508
1461
|
var BaseNode = class extends Callable {
|
|
1509
1462
|
attachments;
|
|
1510
1463
|
$;
|
|
@@ -1598,9 +1551,9 @@ var BaseNode = class extends Callable {
|
|
|
1598
1551
|
}
|
|
1599
1552
|
}
|
|
1600
1553
|
compiledMeta = compileMeta(this.metaJson);
|
|
1601
|
-
cacheGetter(name, value
|
|
1602
|
-
Object.defineProperty(this, name, { value
|
|
1603
|
-
return value
|
|
1554
|
+
cacheGetter(name, value) {
|
|
1555
|
+
Object.defineProperty(this, name, { value });
|
|
1556
|
+
return value;
|
|
1604
1557
|
}
|
|
1605
1558
|
get description() {
|
|
1606
1559
|
return this.cacheGetter("description", this.meta?.description ?? this.$.resolvedConfig[this.kind].description(this));
|
|
@@ -1689,8 +1642,8 @@ var BaseNode = class extends Callable {
|
|
|
1689
1642
|
isNever() {
|
|
1690
1643
|
return this.hasKind("union") && this.children.length === 0;
|
|
1691
1644
|
}
|
|
1692
|
-
hasUnit(value
|
|
1693
|
-
return this.hasKind("unit") && this.allows(value
|
|
1645
|
+
hasUnit(value) {
|
|
1646
|
+
return this.hasKind("unit") && this.allows(value);
|
|
1694
1647
|
}
|
|
1695
1648
|
hasOpenIntersection() {
|
|
1696
1649
|
return this.impl.intersectionIsOpen;
|
|
@@ -1736,8 +1689,8 @@ var BaseNode = class extends Callable {
|
|
|
1736
1689
|
if (!this.impl.keys[k].child) return [k, v];
|
|
1737
1690
|
const children = v;
|
|
1738
1691
|
if (!isArray(children)) {
|
|
1739
|
-
const transformed
|
|
1740
|
-
return transformed
|
|
1692
|
+
const transformed = children._transform(mapper, ctx);
|
|
1693
|
+
return transformed ? [k, transformed] : [];
|
|
1741
1694
|
}
|
|
1742
1695
|
if (children.length === 0) return [k, v];
|
|
1743
1696
|
const transformed = children.flatMap((n) => {
|
|
@@ -1783,7 +1736,7 @@ var BaseNode = class extends Callable {
|
|
|
1783
1736
|
}));
|
|
1784
1737
|
const rawSelected = this._select(normalized);
|
|
1785
1738
|
const selected = rawSelected && liftArray(rawSelected);
|
|
1786
|
-
const shouldTransform = normalized.boundary === "child" ? (node
|
|
1739
|
+
const shouldTransform = normalized.boundary === "child" ? (node, ctx) => ctx.root.children.includes(node) : normalized.boundary === "shallow" ? (node) => node.kind !== "structure" : () => true;
|
|
1787
1740
|
return this.$.finalize(this.transform(mapper, {
|
|
1788
1741
|
shouldTransform,
|
|
1789
1742
|
selected
|
|
@@ -1792,10 +1745,10 @@ var BaseNode = class extends Callable {
|
|
|
1792
1745
|
};
|
|
1793
1746
|
const NodeSelector = {
|
|
1794
1747
|
applyBoundary: {
|
|
1795
|
-
self: (node
|
|
1796
|
-
child: (node
|
|
1797
|
-
shallow: (node
|
|
1798
|
-
references: (node
|
|
1748
|
+
self: (node) => [node],
|
|
1749
|
+
child: (node) => [...node.children],
|
|
1750
|
+
shallow: (node) => [...node.shallowReferences],
|
|
1751
|
+
references: (node) => [...node.references]
|
|
1799
1752
|
},
|
|
1800
1753
|
applyMethod: {
|
|
1801
1754
|
filter: (nodes) => nodes,
|
|
@@ -1827,20 +1780,19 @@ const NodeSelector = {
|
|
|
1827
1780
|
}
|
|
1828
1781
|
};
|
|
1829
1782
|
const writeSelectAssertionMessage = (from, selector) => `${from} had no references matching ${printable(selector)}.`;
|
|
1830
|
-
const typePathToPropString = (path) => stringifyPath(path, { stringifyNonKey: (node
|
|
1783
|
+
const typePathToPropString = (path) => stringifyPath(path, { stringifyNonKey: (node) => node.expression });
|
|
1831
1784
|
const referenceMatcher = /"(\$ark\.[^"]+)"/g;
|
|
1832
1785
|
const compileMeta = (metaJson) => JSON.stringify(metaJson).replace(referenceMatcher, "$1");
|
|
1833
|
-
const flatRef = (path, node
|
|
1786
|
+
const flatRef = (path, node) => ({
|
|
1834
1787
|
path,
|
|
1835
|
-
node
|
|
1788
|
+
node,
|
|
1836
1789
|
propString: typePathToPropString(path)
|
|
1837
1790
|
});
|
|
1838
1791
|
const flatRefsAreEqual = (l, r) => l.propString === r.propString && l.node.equals(r.node);
|
|
1839
1792
|
const appendUniqueFlatRefs = (existing, refs) => appendUnique(existing, refs, { isEqual: flatRefsAreEqual });
|
|
1840
1793
|
const appendUniqueNodes = (existing, refs) => appendUnique(existing, refs, { isEqual: (l, r) => l.equals(r) });
|
|
1841
|
-
|
|
1842
1794
|
//#endregion
|
|
1843
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
1795
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/shared/disjoint.js
|
|
1844
1796
|
var Disjoint = class Disjoint extends Array {
|
|
1845
1797
|
static init(kind, l, r, ctx) {
|
|
1846
1798
|
return new Disjoint({
|
|
@@ -1885,22 +1837,23 @@ var Disjoint = class Disjoint extends Array {
|
|
|
1885
1837
|
return result;
|
|
1886
1838
|
}
|
|
1887
1839
|
withPrefixKey(key, kind) {
|
|
1888
|
-
|
|
1840
|
+
const result = this.map((entry) => ({
|
|
1889
1841
|
...entry,
|
|
1890
1842
|
path: [key, ...entry.path],
|
|
1891
1843
|
optional: entry.optional || kind === "optional"
|
|
1892
1844
|
}));
|
|
1845
|
+
if (!(result instanceof Disjoint)) return new Disjoint(...result);
|
|
1846
|
+
return result;
|
|
1893
1847
|
}
|
|
1894
1848
|
toNeverIfDisjoint() {
|
|
1895
1849
|
return $ark.intrinsic.never;
|
|
1896
1850
|
}
|
|
1897
1851
|
};
|
|
1898
1852
|
const describeReasons = (l, r) => `${describeReason(l)} and ${describeReason(r)}`;
|
|
1899
|
-
const describeReason = (value
|
|
1853
|
+
const describeReason = (value) => isNode(value) ? value.expression : isArray(value) ? value.map(describeReason).join(" | ") || "never" : String(value);
|
|
1900
1854
|
const writeUnsatisfiableExpressionError = (expression) => `${expression} results in an unsatisfiable type`;
|
|
1901
|
-
|
|
1902
1855
|
//#endregion
|
|
1903
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
1856
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/shared/intersections.js
|
|
1904
1857
|
const intersectionCache = {};
|
|
1905
1858
|
const intersectNodesRoot = (l, r, $) => intersectOrPipeNodes(l, r, {
|
|
1906
1859
|
$,
|
|
@@ -1937,11 +1890,11 @@ const intersectOrPipeNodes = ((l, r, ctx) => {
|
|
|
1937
1890
|
});
|
|
1938
1891
|
const _intersectNodes = (l, r, ctx) => {
|
|
1939
1892
|
const leftmostKind = l.precedence < r.precedence ? l.kind : r.kind;
|
|
1940
|
-
const implementation
|
|
1941
|
-
if (implementation
|
|
1942
|
-
else if (leftmostKind === l.kind) return implementation
|
|
1893
|
+
const implementation = l.impl.intersections[r.kind] ?? r.impl.intersections[l.kind];
|
|
1894
|
+
if (implementation === void 0) return null;
|
|
1895
|
+
else if (leftmostKind === l.kind) return implementation(l, r, ctx);
|
|
1943
1896
|
else {
|
|
1944
|
-
let result = implementation
|
|
1897
|
+
let result = implementation(r, l, {
|
|
1945
1898
|
...ctx,
|
|
1946
1899
|
invert: !ctx.invert
|
|
1947
1900
|
});
|
|
@@ -1955,8 +1908,8 @@ const pipeMorphed = (from, to, ctx) => from.distribute((fromBranch) => _pipeMorp
|
|
|
1955
1908
|
if (viableBranches.length === 0) return Disjoint.init("union", from.branches, to.branches);
|
|
1956
1909
|
if (viableBranches.length < from.branches.length || !from.branches.every((branch, i) => branch.rawIn.equals(viableBranches[i].rawIn))) return ctx.$.parseSchema(viableBranches);
|
|
1957
1910
|
if (viableBranches.length === 1) return viableBranches[0];
|
|
1958
|
-
const schema
|
|
1959
|
-
return ctx.$.parseSchema(schema
|
|
1911
|
+
const schema = { branches: viableBranches };
|
|
1912
|
+
return ctx.$.parseSchema(schema);
|
|
1960
1913
|
});
|
|
1961
1914
|
const _pipeMorphed = (from, to, ctx) => {
|
|
1962
1915
|
if (from.hasKind("morph")) {
|
|
@@ -1984,9 +1937,8 @@ const _pipeMorphed = (from, to, ctx) => {
|
|
|
1984
1937
|
in: from
|
|
1985
1938
|
});
|
|
1986
1939
|
};
|
|
1987
|
-
|
|
1988
1940
|
//#endregion
|
|
1989
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
1941
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/constraint.js
|
|
1990
1942
|
var BaseConstraint = class extends BaseNode {
|
|
1991
1943
|
constructor(attachments, $) {
|
|
1992
1944
|
super(attachments, $);
|
|
@@ -2020,14 +1972,15 @@ var InternalPrimitiveConstraint = class extends BaseConstraint {
|
|
|
2020
1972
|
return compileObjectLiteral(this.errorContext);
|
|
2021
1973
|
}
|
|
2022
1974
|
};
|
|
2023
|
-
const constraintKeyParser = (kind) => (schema
|
|
2024
|
-
if (isArray(schema
|
|
2025
|
-
if (schema
|
|
2026
|
-
const nodes = schema
|
|
1975
|
+
const constraintKeyParser = (kind) => (schema, ctx) => {
|
|
1976
|
+
if (isArray(schema)) {
|
|
1977
|
+
if (schema.length === 0) return;
|
|
1978
|
+
const nodes = schema.map((schema) => ctx.$.node(kind, schema));
|
|
2027
1979
|
if (kind === "predicate") return nodes;
|
|
2028
1980
|
return nodes.sort((l, r) => l.hash < r.hash ? -1 : 1);
|
|
2029
1981
|
}
|
|
2030
|
-
const child = ctx.$.node(kind, schema
|
|
1982
|
+
const child = ctx.$.node(kind, schema);
|
|
1983
|
+
if (child.isRoot()) return;
|
|
2031
1984
|
return child.hasOpenIntersection() ? [child] : child;
|
|
2032
1985
|
};
|
|
2033
1986
|
const intersectConstraints = (s) => {
|
|
@@ -2057,7 +2010,7 @@ const intersectConstraints = (s) => {
|
|
|
2057
2010
|
}
|
|
2058
2011
|
if (!matched) s.l.push(head);
|
|
2059
2012
|
if (s.kind === "intersection") {
|
|
2060
|
-
if (head.impliedSiblings) for (const node
|
|
2013
|
+
if (head.impliedSiblings) for (const node of head.impliedSiblings) appendUnique(s.r, node);
|
|
2061
2014
|
}
|
|
2062
2015
|
return intersectConstraints(s);
|
|
2063
2016
|
};
|
|
@@ -2078,9 +2031,8 @@ const writeInvalidOperandMessage = (kind, expected, actual) => {
|
|
|
2078
2031
|
const actualDescription = actual.hasKind("morph") ? "a morph" : actual.isUnknown() ? "unknown" : actual.exclude(expected).defaultShortDescription;
|
|
2079
2032
|
return `${capitalize$1(kind)} operand must be ${expected.description} (was ${actualDescription})`;
|
|
2080
2033
|
};
|
|
2081
|
-
|
|
2082
2034
|
//#endregion
|
|
2083
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
2035
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/generic.js
|
|
2084
2036
|
const parseGeneric = (paramDefs, bodyDef, $) => new GenericRoot(paramDefs, bodyDef, $, $, null);
|
|
2085
2037
|
var LazyGenericBody = class extends Callable {};
|
|
2086
2038
|
var GenericRoot = class extends Callable {
|
|
@@ -2116,9 +2068,9 @@ var GenericRoot = class extends Callable {
|
|
|
2116
2068
|
defIsLazy() {
|
|
2117
2069
|
return this.bodyDef instanceof LazyGenericBody;
|
|
2118
2070
|
}
|
|
2119
|
-
cacheGetter(name, value
|
|
2120
|
-
Object.defineProperty(this, name, { value
|
|
2121
|
-
return value
|
|
2071
|
+
cacheGetter(name, value) {
|
|
2072
|
+
Object.defineProperty(this, name, { value });
|
|
2073
|
+
return value;
|
|
2122
2074
|
}
|
|
2123
2075
|
get json() {
|
|
2124
2076
|
return this.cacheGetter("json", {
|
|
@@ -2146,16 +2098,19 @@ var GenericRoot = class extends Callable {
|
|
|
2146
2098
|
}
|
|
2147
2099
|
};
|
|
2148
2100
|
const writeUnsatisfiedParameterConstraintMessage = (name, constraint, arg) => `${name} must be assignable to ${constraint} (was ${arg})`;
|
|
2149
|
-
|
|
2150
2101
|
//#endregion
|
|
2151
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
2102
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/predicate.js
|
|
2103
|
+
const describePredicate = (predicate) => `valid according to ${predicate?.name || "an anonymous predicate"}`;
|
|
2152
2104
|
const implementation$21 = implementNode({
|
|
2153
2105
|
kind: "predicate",
|
|
2154
2106
|
hasAssociatedError: true,
|
|
2155
2107
|
collapsibleKey: "predicate",
|
|
2156
2108
|
keys: { predicate: {} },
|
|
2157
|
-
normalize: (schema
|
|
2158
|
-
defaults: {
|
|
2109
|
+
normalize: (schema) => typeof schema === "function" ? { predicate: schema } : schema,
|
|
2110
|
+
defaults: {
|
|
2111
|
+
description: (node) => describePredicate(node.predicate),
|
|
2112
|
+
expected: (ctx) => ctx.description ?? describePredicate(ctx.predicate)
|
|
2113
|
+
},
|
|
2159
2114
|
intersectionIsOpen: true,
|
|
2160
2115
|
intersections: { predicate: () => null }
|
|
2161
2116
|
});
|
|
@@ -2196,16 +2151,15 @@ const Predicate = {
|
|
|
2196
2151
|
implementation: implementation$21,
|
|
2197
2152
|
Node: PredicateNode
|
|
2198
2153
|
};
|
|
2199
|
-
|
|
2200
2154
|
//#endregion
|
|
2201
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
2155
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/refinements/divisor.js
|
|
2202
2156
|
const implementation$20 = implementNode({
|
|
2203
2157
|
kind: "divisor",
|
|
2204
2158
|
collapsibleKey: "rule",
|
|
2205
2159
|
keys: { rule: { parse: (divisor) => Number.isInteger(divisor) ? divisor : throwParseError(writeNonIntegerDivisorMessage(divisor)) } },
|
|
2206
|
-
normalize: (schema
|
|
2160
|
+
normalize: (schema) => typeof schema === "number" ? { rule: schema } : schema,
|
|
2207
2161
|
hasAssociatedError: true,
|
|
2208
|
-
defaults: { description: (node
|
|
2162
|
+
defaults: { description: (node) => node.rule === 1 ? "an integer" : node.rule === 2 ? "even" : `a multiple of ${node.rule}` },
|
|
2209
2163
|
intersections: { divisor: (l, r, ctx) => ctx.$.node("divisor", { rule: Math.abs(l.rule * r.rule / greatestCommonDivisor(l.rule, r.rule)) }) },
|
|
2210
2164
|
obviatesBasisDescription: true
|
|
2211
2165
|
});
|
|
@@ -2215,11 +2169,11 @@ var DivisorNode = class extends InternalPrimitiveConstraint {
|
|
|
2215
2169
|
compiledNegation = `data % ${this.rule} !== 0`;
|
|
2216
2170
|
impliedBasis = $ark.intrinsic.number.internal;
|
|
2217
2171
|
expression = `% ${this.rule}`;
|
|
2218
|
-
reduceJsonSchema(schema
|
|
2219
|
-
schema
|
|
2220
|
-
if (this.rule === 1) return schema
|
|
2221
|
-
schema
|
|
2222
|
-
return schema
|
|
2172
|
+
reduceJsonSchema(schema) {
|
|
2173
|
+
schema.type = "integer";
|
|
2174
|
+
if (this.rule === 1) return schema;
|
|
2175
|
+
schema.multipleOf = this.rule;
|
|
2176
|
+
return schema;
|
|
2223
2177
|
}
|
|
2224
2178
|
};
|
|
2225
2179
|
const Divisor = {
|
|
@@ -2229,18 +2183,17 @@ const Divisor = {
|
|
|
2229
2183
|
const writeNonIntegerDivisorMessage = (divisor) => `divisor must be an integer (was ${divisor})`;
|
|
2230
2184
|
const greatestCommonDivisor = (l, r) => {
|
|
2231
2185
|
let previous;
|
|
2232
|
-
let greatestCommonDivisor
|
|
2186
|
+
let greatestCommonDivisor = l;
|
|
2233
2187
|
let current = r;
|
|
2234
2188
|
while (current !== 0) {
|
|
2235
2189
|
previous = current;
|
|
2236
|
-
current = greatestCommonDivisor
|
|
2237
|
-
greatestCommonDivisor
|
|
2190
|
+
current = greatestCommonDivisor % current;
|
|
2191
|
+
greatestCommonDivisor = previous;
|
|
2238
2192
|
}
|
|
2239
|
-
return greatestCommonDivisor
|
|
2193
|
+
return greatestCommonDivisor;
|
|
2240
2194
|
};
|
|
2241
|
-
|
|
2242
2195
|
//#endregion
|
|
2243
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
2196
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/refinements/range.js
|
|
2244
2197
|
var BaseRange = class extends InternalPrimitiveConstraint {
|
|
2245
2198
|
boundOperandKind = operandKindsByBoundKind[this.kind];
|
|
2246
2199
|
compiledActual = this.boundOperandKind === "value" ? `data` : this.boundOperandKind === "length" ? `data.length` : `data.valueOf()`;
|
|
@@ -2275,17 +2228,17 @@ const boundKindPairsByLower = {
|
|
|
2275
2228
|
after: "before"
|
|
2276
2229
|
};
|
|
2277
2230
|
const parseExclusiveKey = { parse: (flag) => flag || void 0 };
|
|
2278
|
-
const createLengthSchemaNormalizer = (kind) => (schema
|
|
2279
|
-
if (typeof schema
|
|
2280
|
-
const { exclusive, ...normalized } = schema
|
|
2231
|
+
const createLengthSchemaNormalizer = (kind) => (schema) => {
|
|
2232
|
+
if (typeof schema === "number") return { rule: schema };
|
|
2233
|
+
const { exclusive, ...normalized } = schema;
|
|
2281
2234
|
return exclusive ? {
|
|
2282
2235
|
...normalized,
|
|
2283
2236
|
rule: kind === "minLength" ? normalized.rule + 1 : normalized.rule - 1
|
|
2284
2237
|
} : normalized;
|
|
2285
2238
|
};
|
|
2286
|
-
const createDateSchemaNormalizer = (kind) => (schema
|
|
2287
|
-
if (typeof schema
|
|
2288
|
-
const { exclusive, ...normalized } = schema
|
|
2239
|
+
const createDateSchemaNormalizer = (kind) => (schema) => {
|
|
2240
|
+
if (typeof schema === "number" || typeof schema === "string" || schema instanceof Date) return { rule: schema };
|
|
2241
|
+
const { exclusive, ...normalized } = schema;
|
|
2289
2242
|
if (!exclusive) return normalized;
|
|
2290
2243
|
const numericLimit = typeof normalized.rule === "number" ? normalized.rule : typeof normalized.rule === "string" ? new Date(normalized.rule).valueOf() : normalized.rule.valueOf();
|
|
2291
2244
|
return exclusive ? {
|
|
@@ -2310,20 +2263,19 @@ const operandKindsByBoundKind = {
|
|
|
2310
2263
|
const compileComparator = (kind, exclusive) => `${isKeyOf(kind, boundKindPairsByLower) ? ">" : "<"}${exclusive ? "" : "="}`;
|
|
2311
2264
|
const dateLimitToString = (limit) => typeof limit === "string" ? limit : new Date(limit).toLocaleString();
|
|
2312
2265
|
const writeUnboundableMessage = (root) => `Bounded expression ${root} must be exactly one of number, string, Array, or Date`;
|
|
2313
|
-
|
|
2314
2266
|
//#endregion
|
|
2315
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
2267
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/refinements/after.js
|
|
2316
2268
|
const implementation$19 = implementNode({
|
|
2317
2269
|
kind: "after",
|
|
2318
2270
|
collapsibleKey: "rule",
|
|
2319
2271
|
hasAssociatedError: true,
|
|
2320
2272
|
keys: { rule: {
|
|
2321
2273
|
parse: parseDateLimit,
|
|
2322
|
-
serialize: (schema
|
|
2274
|
+
serialize: (schema) => schema.toISOString()
|
|
2323
2275
|
} },
|
|
2324
2276
|
normalize: createDateSchemaNormalizer("after"),
|
|
2325
2277
|
defaults: {
|
|
2326
|
-
description: (node
|
|
2278
|
+
description: (node) => `${node.collapsibleLimitString} or later`,
|
|
2327
2279
|
actual: describeCollapsibleDate
|
|
2328
2280
|
},
|
|
2329
2281
|
intersections: { after: (l, r) => l.isStricterThan(r) ? l : r }
|
|
@@ -2344,20 +2296,19 @@ const After = {
|
|
|
2344
2296
|
implementation: implementation$19,
|
|
2345
2297
|
Node: AfterNode
|
|
2346
2298
|
};
|
|
2347
|
-
|
|
2348
2299
|
//#endregion
|
|
2349
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
2300
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/refinements/before.js
|
|
2350
2301
|
const implementation$18 = implementNode({
|
|
2351
2302
|
kind: "before",
|
|
2352
2303
|
collapsibleKey: "rule",
|
|
2353
2304
|
hasAssociatedError: true,
|
|
2354
2305
|
keys: { rule: {
|
|
2355
2306
|
parse: parseDateLimit,
|
|
2356
|
-
serialize: (schema
|
|
2307
|
+
serialize: (schema) => schema.toISOString()
|
|
2357
2308
|
} },
|
|
2358
2309
|
normalize: createDateSchemaNormalizer("before"),
|
|
2359
2310
|
defaults: {
|
|
2360
|
-
description: (node
|
|
2311
|
+
description: (node) => `${node.collapsibleLimitString} or earlier`,
|
|
2361
2312
|
actual: describeCollapsibleDate
|
|
2362
2313
|
},
|
|
2363
2314
|
intersections: {
|
|
@@ -2381,17 +2332,16 @@ const Before = {
|
|
|
2381
2332
|
implementation: implementation$18,
|
|
2382
2333
|
Node: BeforeNode
|
|
2383
2334
|
};
|
|
2384
|
-
|
|
2385
2335
|
//#endregion
|
|
2386
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
2336
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/refinements/exactLength.js
|
|
2387
2337
|
const implementation$17 = implementNode({
|
|
2388
2338
|
kind: "exactLength",
|
|
2389
2339
|
collapsibleKey: "rule",
|
|
2390
2340
|
keys: { rule: { parse: createLengthRuleParser("exactLength") } },
|
|
2391
|
-
normalize: (schema
|
|
2341
|
+
normalize: (schema) => typeof schema === "number" ? { rule: schema } : schema,
|
|
2392
2342
|
hasAssociatedError: true,
|
|
2393
2343
|
defaults: {
|
|
2394
|
-
description: (node
|
|
2344
|
+
description: (node) => `exactly length ${node.rule}`,
|
|
2395
2345
|
actual: (data) => `${data.length}`
|
|
2396
2346
|
},
|
|
2397
2347
|
intersections: {
|
|
@@ -2406,17 +2356,17 @@ var ExactLengthNode = class extends InternalPrimitiveConstraint {
|
|
|
2406
2356
|
compiledNegation = `data.length !== ${this.rule}`;
|
|
2407
2357
|
impliedBasis = $ark.intrinsic.lengthBoundable.internal;
|
|
2408
2358
|
expression = `== ${this.rule}`;
|
|
2409
|
-
reduceJsonSchema(schema
|
|
2410
|
-
switch (schema
|
|
2359
|
+
reduceJsonSchema(schema) {
|
|
2360
|
+
switch (schema.type) {
|
|
2411
2361
|
case "string":
|
|
2412
|
-
schema
|
|
2413
|
-
schema
|
|
2414
|
-
return schema
|
|
2362
|
+
schema.minLength = this.rule;
|
|
2363
|
+
schema.maxLength = this.rule;
|
|
2364
|
+
return schema;
|
|
2415
2365
|
case "array":
|
|
2416
|
-
schema
|
|
2417
|
-
schema
|
|
2418
|
-
return schema
|
|
2419
|
-
default: return ToJsonSchema.throwInternalOperandError("exactLength", schema
|
|
2366
|
+
schema.minItems = this.rule;
|
|
2367
|
+
schema.maxItems = this.rule;
|
|
2368
|
+
return schema;
|
|
2369
|
+
default: return ToJsonSchema.throwInternalOperandError("exactLength", schema);
|
|
2420
2370
|
}
|
|
2421
2371
|
}
|
|
2422
2372
|
};
|
|
@@ -2424,9 +2374,8 @@ const ExactLength = {
|
|
|
2424
2374
|
implementation: implementation$17,
|
|
2425
2375
|
Node: ExactLengthNode
|
|
2426
2376
|
};
|
|
2427
|
-
|
|
2428
2377
|
//#endregion
|
|
2429
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
2378
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/refinements/max.js
|
|
2430
2379
|
const implementation$16 = implementNode({
|
|
2431
2380
|
kind: "max",
|
|
2432
2381
|
collapsibleKey: "rule",
|
|
@@ -2435,10 +2384,10 @@ const implementation$16 = implementNode({
|
|
|
2435
2384
|
rule: {},
|
|
2436
2385
|
exclusive: parseExclusiveKey
|
|
2437
2386
|
},
|
|
2438
|
-
normalize: (schema
|
|
2439
|
-
defaults: { description: (node
|
|
2440
|
-
if (node
|
|
2441
|
-
return `${node
|
|
2387
|
+
normalize: (schema) => typeof schema === "number" ? { rule: schema } : schema,
|
|
2388
|
+
defaults: { description: (node) => {
|
|
2389
|
+
if (node.rule === 0) return node.exclusive ? "negative" : "non-positive";
|
|
2390
|
+
return `${node.exclusive ? "less than" : "at most"} ${node.rule}`;
|
|
2442
2391
|
} },
|
|
2443
2392
|
intersections: {
|
|
2444
2393
|
max: (l, r) => l.isStricterThan(r) ? l : r,
|
|
@@ -2449,19 +2398,18 @@ const implementation$16 = implementNode({
|
|
|
2449
2398
|
var MaxNode = class extends BaseRange {
|
|
2450
2399
|
impliedBasis = $ark.intrinsic.number.internal;
|
|
2451
2400
|
traverseAllows = this.exclusive ? (data) => data < this.rule : (data) => data <= this.rule;
|
|
2452
|
-
reduceJsonSchema(schema
|
|
2453
|
-
if (this.exclusive) schema
|
|
2454
|
-
else schema
|
|
2455
|
-
return schema
|
|
2401
|
+
reduceJsonSchema(schema) {
|
|
2402
|
+
if (this.exclusive) schema.exclusiveMaximum = this.rule;
|
|
2403
|
+
else schema.maximum = this.rule;
|
|
2404
|
+
return schema;
|
|
2456
2405
|
}
|
|
2457
2406
|
};
|
|
2458
2407
|
const Max = {
|
|
2459
2408
|
implementation: implementation$16,
|
|
2460
2409
|
Node: MaxNode
|
|
2461
2410
|
};
|
|
2462
|
-
|
|
2463
2411
|
//#endregion
|
|
2464
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
2412
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/refinements/maxLength.js
|
|
2465
2413
|
const implementation$15 = implementNode({
|
|
2466
2414
|
kind: "maxLength",
|
|
2467
2415
|
collapsibleKey: "rule",
|
|
@@ -2470,7 +2418,7 @@ const implementation$15 = implementNode({
|
|
|
2470
2418
|
reduce: (inner, $) => inner.rule === 0 ? $.node("exactLength", inner) : void 0,
|
|
2471
2419
|
normalize: createLengthSchemaNormalizer("maxLength"),
|
|
2472
2420
|
defaults: {
|
|
2473
|
-
description: (node
|
|
2421
|
+
description: (node) => `at most length ${node.rule}`,
|
|
2474
2422
|
actual: (data) => `${data.length}`
|
|
2475
2423
|
},
|
|
2476
2424
|
intersections: {
|
|
@@ -2481,15 +2429,15 @@ const implementation$15 = implementNode({
|
|
|
2481
2429
|
var MaxLengthNode = class extends BaseRange {
|
|
2482
2430
|
impliedBasis = $ark.intrinsic.lengthBoundable.internal;
|
|
2483
2431
|
traverseAllows = (data) => data.length <= this.rule;
|
|
2484
|
-
reduceJsonSchema(schema
|
|
2485
|
-
switch (schema
|
|
2432
|
+
reduceJsonSchema(schema) {
|
|
2433
|
+
switch (schema.type) {
|
|
2486
2434
|
case "string":
|
|
2487
|
-
schema
|
|
2488
|
-
return schema
|
|
2435
|
+
schema.maxLength = this.rule;
|
|
2436
|
+
return schema;
|
|
2489
2437
|
case "array":
|
|
2490
|
-
schema
|
|
2491
|
-
return schema
|
|
2492
|
-
default: return ToJsonSchema.throwInternalOperandError("maxLength", schema
|
|
2438
|
+
schema.maxItems = this.rule;
|
|
2439
|
+
return schema;
|
|
2440
|
+
default: return ToJsonSchema.throwInternalOperandError("maxLength", schema);
|
|
2493
2441
|
}
|
|
2494
2442
|
}
|
|
2495
2443
|
};
|
|
@@ -2497,9 +2445,8 @@ const MaxLength = {
|
|
|
2497
2445
|
implementation: implementation$15,
|
|
2498
2446
|
Node: MaxLengthNode
|
|
2499
2447
|
};
|
|
2500
|
-
|
|
2501
2448
|
//#endregion
|
|
2502
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
2449
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/refinements/min.js
|
|
2503
2450
|
const implementation$14 = implementNode({
|
|
2504
2451
|
kind: "min",
|
|
2505
2452
|
collapsibleKey: "rule",
|
|
@@ -2508,10 +2455,10 @@ const implementation$14 = implementNode({
|
|
|
2508
2455
|
rule: {},
|
|
2509
2456
|
exclusive: parseExclusiveKey
|
|
2510
2457
|
},
|
|
2511
|
-
normalize: (schema
|
|
2512
|
-
defaults: { description: (node
|
|
2513
|
-
if (node
|
|
2514
|
-
return `${node
|
|
2458
|
+
normalize: (schema) => typeof schema === "number" ? { rule: schema } : schema,
|
|
2459
|
+
defaults: { description: (node) => {
|
|
2460
|
+
if (node.rule === 0) return node.exclusive ? "positive" : "non-negative";
|
|
2461
|
+
return `${node.exclusive ? "more than" : "at least"} ${node.rule}`;
|
|
2515
2462
|
} },
|
|
2516
2463
|
intersections: { min: (l, r) => l.isStricterThan(r) ? l : r },
|
|
2517
2464
|
obviatesBasisDescription: true
|
|
@@ -2519,19 +2466,18 @@ const implementation$14 = implementNode({
|
|
|
2519
2466
|
var MinNode = class extends BaseRange {
|
|
2520
2467
|
impliedBasis = $ark.intrinsic.number.internal;
|
|
2521
2468
|
traverseAllows = this.exclusive ? (data) => data > this.rule : (data) => data >= this.rule;
|
|
2522
|
-
reduceJsonSchema(schema
|
|
2523
|
-
if (this.exclusive) schema
|
|
2524
|
-
else schema
|
|
2525
|
-
return schema
|
|
2469
|
+
reduceJsonSchema(schema) {
|
|
2470
|
+
if (this.exclusive) schema.exclusiveMinimum = this.rule;
|
|
2471
|
+
else schema.minimum = this.rule;
|
|
2472
|
+
return schema;
|
|
2526
2473
|
}
|
|
2527
2474
|
};
|
|
2528
2475
|
const Min = {
|
|
2529
2476
|
implementation: implementation$14,
|
|
2530
2477
|
Node: MinNode
|
|
2531
2478
|
};
|
|
2532
|
-
|
|
2533
2479
|
//#endregion
|
|
2534
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
2480
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/refinements/minLength.js
|
|
2535
2481
|
const implementation$13 = implementNode({
|
|
2536
2482
|
kind: "minLength",
|
|
2537
2483
|
collapsibleKey: "rule",
|
|
@@ -2540,7 +2486,7 @@ const implementation$13 = implementNode({
|
|
|
2540
2486
|
reduce: (inner) => inner.rule === 0 ? $ark.intrinsic.unknown : void 0,
|
|
2541
2487
|
normalize: createLengthSchemaNormalizer("minLength"),
|
|
2542
2488
|
defaults: {
|
|
2543
|
-
description: (node
|
|
2489
|
+
description: (node) => node.rule === 1 ? "non-empty" : `at least length ${node.rule}`,
|
|
2544
2490
|
actual: (data) => data.length === 0 ? "" : `${data.length}`
|
|
2545
2491
|
},
|
|
2546
2492
|
intersections: { minLength: (l, r) => l.isStricterThan(r) ? l : r }
|
|
@@ -2548,15 +2494,15 @@ const implementation$13 = implementNode({
|
|
|
2548
2494
|
var MinLengthNode = class extends BaseRange {
|
|
2549
2495
|
impliedBasis = $ark.intrinsic.lengthBoundable.internal;
|
|
2550
2496
|
traverseAllows = (data) => data.length >= this.rule;
|
|
2551
|
-
reduceJsonSchema(schema
|
|
2552
|
-
switch (schema
|
|
2497
|
+
reduceJsonSchema(schema) {
|
|
2498
|
+
switch (schema.type) {
|
|
2553
2499
|
case "string":
|
|
2554
|
-
schema
|
|
2555
|
-
return schema
|
|
2500
|
+
schema.minLength = this.rule;
|
|
2501
|
+
return schema;
|
|
2556
2502
|
case "array":
|
|
2557
|
-
schema
|
|
2558
|
-
return schema
|
|
2559
|
-
default: return ToJsonSchema.throwInternalOperandError("minLength", schema
|
|
2503
|
+
schema.minItems = this.rule;
|
|
2504
|
+
return schema;
|
|
2505
|
+
default: return ToJsonSchema.throwInternalOperandError("minLength", schema);
|
|
2560
2506
|
}
|
|
2561
2507
|
}
|
|
2562
2508
|
};
|
|
@@ -2564,9 +2510,8 @@ const MinLength = {
|
|
|
2564
2510
|
implementation: implementation$13,
|
|
2565
2511
|
Node: MinLengthNode
|
|
2566
2512
|
};
|
|
2567
|
-
|
|
2568
2513
|
//#endregion
|
|
2569
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
2514
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/refinements/kinds.js
|
|
2570
2515
|
const boundImplementationsByKind = {
|
|
2571
2516
|
min: Min.implementation,
|
|
2572
2517
|
max: Max.implementation,
|
|
@@ -2585,9 +2530,8 @@ const boundClassesByKind = {
|
|
|
2585
2530
|
after: After.Node,
|
|
2586
2531
|
before: Before.Node
|
|
2587
2532
|
};
|
|
2588
|
-
|
|
2589
2533
|
//#endregion
|
|
2590
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
2534
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/refinements/pattern.js
|
|
2591
2535
|
const implementation$12 = implementNode({
|
|
2592
2536
|
kind: "pattern",
|
|
2593
2537
|
collapsibleKey: "rule",
|
|
@@ -2595,15 +2539,15 @@ const implementation$12 = implementNode({
|
|
|
2595
2539
|
rule: {},
|
|
2596
2540
|
flags: {}
|
|
2597
2541
|
},
|
|
2598
|
-
normalize: (schema
|
|
2599
|
-
rule: schema
|
|
2600
|
-
flags: schema
|
|
2601
|
-
} : { rule: schema
|
|
2542
|
+
normalize: (schema) => typeof schema === "string" ? { rule: schema } : schema instanceof RegExp ? schema.flags ? {
|
|
2543
|
+
rule: schema.source,
|
|
2544
|
+
flags: schema.flags
|
|
2545
|
+
} : { rule: schema.source } : schema,
|
|
2602
2546
|
obviatesBasisDescription: true,
|
|
2603
2547
|
obviatesBasisExpression: true,
|
|
2604
2548
|
hasAssociatedError: true,
|
|
2605
2549
|
intersectionIsOpen: true,
|
|
2606
|
-
defaults: { description: (node
|
|
2550
|
+
defaults: { description: (node) => `matched by ${node.rule}` },
|
|
2607
2551
|
intersections: { pattern: () => null }
|
|
2608
2552
|
});
|
|
2609
2553
|
var PatternNode = class extends InternalPrimitiveConstraint {
|
|
@@ -2627,32 +2571,31 @@ const Pattern = {
|
|
|
2627
2571
|
implementation: implementation$12,
|
|
2628
2572
|
Node: PatternNode
|
|
2629
2573
|
};
|
|
2630
|
-
|
|
2631
2574
|
//#endregion
|
|
2632
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
2633
|
-
const schemaKindOf = (schema
|
|
2634
|
-
const kind = discriminateRootKind(schema
|
|
2575
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/parse.js
|
|
2576
|
+
const schemaKindOf = (schema, allowedKinds) => {
|
|
2577
|
+
const kind = discriminateRootKind(schema);
|
|
2635
2578
|
if (allowedKinds && !allowedKinds.includes(kind)) return throwParseError(`Root of kind ${kind} should be one of ${allowedKinds}`);
|
|
2636
2579
|
return kind;
|
|
2637
2580
|
};
|
|
2638
|
-
const discriminateRootKind = (schema
|
|
2639
|
-
if (hasArkKind(schema
|
|
2640
|
-
if (typeof schema
|
|
2641
|
-
if (typeof schema
|
|
2642
|
-
if (typeof schema
|
|
2643
|
-
if ("morphs" in schema
|
|
2644
|
-
if ("branches" in schema
|
|
2645
|
-
if ("unit" in schema
|
|
2646
|
-
if ("reference" in schema
|
|
2647
|
-
const schemaKeys = Object.keys(schema
|
|
2581
|
+
const discriminateRootKind = (schema) => {
|
|
2582
|
+
if (hasArkKind(schema, "root")) return schema.kind;
|
|
2583
|
+
if (typeof schema === "string") return schema[0] === "$" ? "alias" : schema in domainDescriptions ? "domain" : "proto";
|
|
2584
|
+
if (typeof schema === "function") return "proto";
|
|
2585
|
+
if (typeof schema !== "object" || schema === null) return throwParseError(writeInvalidSchemaMessage(schema));
|
|
2586
|
+
if ("morphs" in schema) return "morph";
|
|
2587
|
+
if ("branches" in schema || isArray(schema)) return "union";
|
|
2588
|
+
if ("unit" in schema) return "unit";
|
|
2589
|
+
if ("reference" in schema) return "alias";
|
|
2590
|
+
const schemaKeys = Object.keys(schema);
|
|
2648
2591
|
if (schemaKeys.length === 0 || schemaKeys.some((k) => k in constraintKeys)) return "intersection";
|
|
2649
|
-
if ("proto" in schema
|
|
2650
|
-
if ("domain" in schema
|
|
2651
|
-
return throwParseError(writeInvalidSchemaMessage(schema
|
|
2592
|
+
if ("proto" in schema) return "proto";
|
|
2593
|
+
if ("domain" in schema) return "domain";
|
|
2594
|
+
return throwParseError(writeInvalidSchemaMessage(schema));
|
|
2652
2595
|
};
|
|
2653
|
-
const writeInvalidSchemaMessage = (schema
|
|
2596
|
+
const writeInvalidSchemaMessage = (schema) => `${printable(schema)} is not a valid type schema`;
|
|
2654
2597
|
const nodeCountsByPrefix = {};
|
|
2655
|
-
const serializeListableChild = (listableNode) => isArray(listableNode) ? listableNode.map((node
|
|
2598
|
+
const serializeListableChild = (listableNode) => isArray(listableNode) ? listableNode.map((node) => node.collapsibleJson) : listableNode.collapsibleJson;
|
|
2656
2599
|
const nodesByRegisteredId = {};
|
|
2657
2600
|
$ark.nodesByRegisteredId = nodesByRegisteredId;
|
|
2658
2601
|
const registerNodeId = (prefix) => {
|
|
@@ -2711,22 +2654,22 @@ const createNode = ({ id, kind, inner, meta, $, ignoreCache }) => {
|
|
|
2711
2654
|
} else if (typeof keyImpl.child === "function") children.push(...keyImpl.child(v));
|
|
2712
2655
|
}
|
|
2713
2656
|
if (impl.finalizeInnerJson) innerJson = impl.finalizeInnerJson(innerJson);
|
|
2714
|
-
let json
|
|
2657
|
+
let json = { ...innerJson };
|
|
2715
2658
|
let metaJson = {};
|
|
2716
2659
|
if (!isEmptyObject(meta)) {
|
|
2717
2660
|
metaJson = flatMorph(meta, (k, v) => [k, k === "examples" ? v : defaultValueSerializer(v)]);
|
|
2718
|
-
json
|
|
2661
|
+
json.meta = possiblyCollapse(metaJson, "description", true);
|
|
2719
2662
|
}
|
|
2720
2663
|
innerJson = possiblyCollapse(innerJson, impl.collapsibleKey, false);
|
|
2721
2664
|
const innerHash = JSON.stringify({
|
|
2722
2665
|
kind,
|
|
2723
2666
|
...innerJson
|
|
2724
2667
|
});
|
|
2725
|
-
json
|
|
2726
|
-
const collapsibleJson = possiblyCollapse(json
|
|
2668
|
+
json = possiblyCollapse(json, impl.collapsibleKey, false);
|
|
2669
|
+
const collapsibleJson = possiblyCollapse(json, impl.collapsibleKey, true);
|
|
2727
2670
|
const hash = JSON.stringify({
|
|
2728
2671
|
kind,
|
|
2729
|
-
...json
|
|
2672
|
+
...json
|
|
2730
2673
|
});
|
|
2731
2674
|
if ($.nodesByHash[hash] && !ignoreCache) return $.nodesByHash[hash];
|
|
2732
2675
|
const attachments = {
|
|
@@ -2739,7 +2682,7 @@ const createNode = ({ id, kind, inner, meta, $, ignoreCache }) => {
|
|
|
2739
2682
|
innerHash,
|
|
2740
2683
|
meta,
|
|
2741
2684
|
metaJson,
|
|
2742
|
-
json
|
|
2685
|
+
json,
|
|
2743
2686
|
hash,
|
|
2744
2687
|
collapsibleJson,
|
|
2745
2688
|
children
|
|
@@ -2747,58 +2690,59 @@ const createNode = ({ id, kind, inner, meta, $, ignoreCache }) => {
|
|
|
2747
2690
|
if (kind !== "intersection") {
|
|
2748
2691
|
for (const k in inner) if (k !== "in" && k !== "out") attachments[k] = inner[k];
|
|
2749
2692
|
}
|
|
2750
|
-
const node
|
|
2751
|
-
return $.nodesByHash[hash] = node
|
|
2693
|
+
const node = new nodeClassesByKind[kind](attachments, $);
|
|
2694
|
+
return $.nodesByHash[hash] = node;
|
|
2752
2695
|
};
|
|
2753
|
-
const withId = (node
|
|
2754
|
-
if (node
|
|
2696
|
+
const withId = (node, id) => {
|
|
2697
|
+
if (node.id === id) return node;
|
|
2755
2698
|
if (isNode(nodesByRegisteredId[id])) throwInternalError(`Unexpected attempt to overwrite node id ${id}`);
|
|
2756
2699
|
return createNode({
|
|
2757
2700
|
id,
|
|
2758
|
-
kind: node
|
|
2759
|
-
inner: node
|
|
2760
|
-
meta: node
|
|
2761
|
-
$: node
|
|
2701
|
+
kind: node.kind,
|
|
2702
|
+
inner: node.inner,
|
|
2703
|
+
meta: node.meta,
|
|
2704
|
+
$: node.$,
|
|
2762
2705
|
ignoreCache: true
|
|
2763
2706
|
});
|
|
2764
2707
|
};
|
|
2765
|
-
const withMeta = (node
|
|
2708
|
+
const withMeta = (node, meta, id) => {
|
|
2766
2709
|
if (id && isNode(nodesByRegisteredId[id])) throwInternalError(`Unexpected attempt to overwrite node id ${id}`);
|
|
2767
2710
|
return createNode({
|
|
2768
|
-
id: id ?? registerNodeId(meta.alias ?? node
|
|
2769
|
-
kind: node
|
|
2770
|
-
inner: node
|
|
2711
|
+
id: id ?? registerNodeId(meta.alias ?? node.kind),
|
|
2712
|
+
kind: node.kind,
|
|
2713
|
+
inner: node.inner,
|
|
2771
2714
|
meta,
|
|
2772
|
-
$: node
|
|
2715
|
+
$: node.$
|
|
2773
2716
|
});
|
|
2774
2717
|
};
|
|
2775
|
-
const possiblyCollapse = (json
|
|
2776
|
-
const collapsibleKeys = Object.keys(json
|
|
2718
|
+
const possiblyCollapse = (json, toKey, allowPrimitive) => {
|
|
2719
|
+
const collapsibleKeys = Object.keys(json);
|
|
2777
2720
|
if (collapsibleKeys.length === 1 && collapsibleKeys[0] === toKey) {
|
|
2778
|
-
const collapsed = json
|
|
2721
|
+
const collapsed = json[toKey];
|
|
2779
2722
|
if (allowPrimitive) return collapsed;
|
|
2780
2723
|
if (hasDomain(collapsed, "object") && (Object.keys(collapsed).length === 1 || Array.isArray(collapsed))) return collapsed;
|
|
2781
2724
|
}
|
|
2782
|
-
return json
|
|
2725
|
+
return json;
|
|
2783
2726
|
};
|
|
2784
|
-
|
|
2785
2727
|
//#endregion
|
|
2786
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
2728
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/structure/prop.js
|
|
2787
2729
|
const intersectProps = (l, r, ctx) => {
|
|
2788
2730
|
if (l.key !== r.key) return null;
|
|
2789
2731
|
const key = l.key;
|
|
2790
|
-
let value
|
|
2732
|
+
let value = intersectOrPipeNodes(l.value, r.value, ctx);
|
|
2791
2733
|
const kind = l.required || r.required ? "required" : "optional";
|
|
2792
|
-
if (value
|
|
2793
|
-
|
|
2734
|
+
if (value instanceof Disjoint) {
|
|
2735
|
+
if (kind === "optional") value = $ark.intrinsic.never.internal;
|
|
2736
|
+
else return value.withPrefixKey(l.key, l.required && r.required ? "required" : "optional");
|
|
2737
|
+
}
|
|
2794
2738
|
if (kind === "required") return ctx.$.node("required", {
|
|
2795
2739
|
key,
|
|
2796
|
-
value
|
|
2740
|
+
value
|
|
2797
2741
|
});
|
|
2798
2742
|
const defaultIntersection = l.hasDefault() ? r.hasDefault() ? l.default === r.default ? l.default : throwParseError(writeDefaultIntersectionMessage(l.default, r.default)) : l.default : r.hasDefault() ? r.default : unset;
|
|
2799
2743
|
return ctx.$.node("optional", {
|
|
2800
2744
|
key,
|
|
2801
|
-
value
|
|
2745
|
+
value,
|
|
2802
2746
|
default: defaultIntersection
|
|
2803
2747
|
});
|
|
2804
2748
|
};
|
|
@@ -2833,9 +2777,8 @@ var BaseProp = class extends BaseConstraint {
|
|
|
2833
2777
|
}
|
|
2834
2778
|
};
|
|
2835
2779
|
const writeDefaultIntersectionMessage = (lValue, rValue) => `Invalid intersection of default values ${printable(lValue)} & ${printable(rValue)}`;
|
|
2836
|
-
|
|
2837
2780
|
//#endregion
|
|
2838
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
2781
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/structure/optional.js
|
|
2839
2782
|
const implementation$11 = implementNode({
|
|
2840
2783
|
kind: "optional",
|
|
2841
2784
|
hasAssociatedError: false,
|
|
@@ -2844,11 +2787,11 @@ const implementation$11 = implementNode({
|
|
|
2844
2787
|
key: {},
|
|
2845
2788
|
value: {
|
|
2846
2789
|
child: true,
|
|
2847
|
-
parse: (schema
|
|
2790
|
+
parse: (schema, ctx) => ctx.$.parseSchema(schema)
|
|
2848
2791
|
},
|
|
2849
2792
|
default: { preserveUndefined: true }
|
|
2850
2793
|
},
|
|
2851
|
-
normalize: (schema
|
|
2794
|
+
normalize: (schema) => schema,
|
|
2852
2795
|
reduce: (inner, $) => {
|
|
2853
2796
|
if ($.resolvedConfig.exactOptionalPropertyTypes === false) {
|
|
2854
2797
|
if (!inner.value.allows(void 0)) return $.node("optional", {
|
|
@@ -2857,7 +2800,7 @@ const implementation$11 = implementNode({
|
|
|
2857
2800
|
}, { prereduced: true });
|
|
2858
2801
|
}
|
|
2859
2802
|
},
|
|
2860
|
-
defaults: { description: (node
|
|
2803
|
+
defaults: { description: (node) => `${node.compiledKey}?: ${node.value.description}` },
|
|
2861
2804
|
intersections: { optional: intersectProps }
|
|
2862
2805
|
});
|
|
2863
2806
|
var OptionalNode = class extends BaseProp {
|
|
@@ -2884,47 +2827,47 @@ const Optional = {
|
|
|
2884
2827
|
Node: OptionalNode
|
|
2885
2828
|
};
|
|
2886
2829
|
const defaultableMorphCache = {};
|
|
2887
|
-
const getDefaultableMorph = (node
|
|
2888
|
-
if (!node
|
|
2889
|
-
const cacheKey = `{${node
|
|
2890
|
-
return defaultableMorphCache[cacheKey] ??= computeDefaultValueMorph(node
|
|
2891
|
-
};
|
|
2892
|
-
const computeDefaultValueMorph = (key, value
|
|
2893
|
-
if (typeof defaultInput === "function") return value
|
|
2894
|
-
traverseKey(key, () => value
|
|
2830
|
+
const getDefaultableMorph = (node) => {
|
|
2831
|
+
if (!node.hasDefault()) return;
|
|
2832
|
+
const cacheKey = `{${node.compiledKey}: ${node.value.id} = ${defaultValueSerializer(node.default)}}`;
|
|
2833
|
+
return defaultableMorphCache[cacheKey] ??= computeDefaultValueMorph(node.key, node.value, node.default);
|
|
2834
|
+
};
|
|
2835
|
+
const computeDefaultValueMorph = (key, value, defaultInput) => {
|
|
2836
|
+
if (typeof defaultInput === "function") return value.includesTransform ? (data, ctx) => {
|
|
2837
|
+
traverseKey(key, () => value(data[key] = defaultInput(), ctx), ctx);
|
|
2895
2838
|
return data;
|
|
2896
2839
|
} : (data) => {
|
|
2897
2840
|
data[key] = defaultInput();
|
|
2898
2841
|
return data;
|
|
2899
2842
|
};
|
|
2900
|
-
const precomputedMorphedDefault = value
|
|
2843
|
+
const precomputedMorphedDefault = value.includesTransform ? value.assert(defaultInput) : defaultInput;
|
|
2901
2844
|
return hasDomain(precomputedMorphedDefault, "object") ? (data, ctx) => {
|
|
2902
|
-
traverseKey(key, () => value
|
|
2845
|
+
traverseKey(key, () => value(data[key] = defaultInput, ctx), ctx);
|
|
2903
2846
|
return data;
|
|
2904
2847
|
} : (data) => {
|
|
2905
2848
|
data[key] = precomputedMorphedDefault;
|
|
2906
2849
|
return data;
|
|
2907
2850
|
};
|
|
2908
2851
|
};
|
|
2909
|
-
const assertDefaultValueAssignability = (node
|
|
2910
|
-
const wrapped = isThunk(value
|
|
2911
|
-
if (hasDomain(value
|
|
2912
|
-
const out = node
|
|
2852
|
+
const assertDefaultValueAssignability = (node, value, key) => {
|
|
2853
|
+
const wrapped = isThunk(value);
|
|
2854
|
+
if (hasDomain(value, "object") && !wrapped) throwParseError(writeNonPrimitiveNonFunctionDefaultValueMessage(key));
|
|
2855
|
+
const out = node.in(wrapped ? value() : value);
|
|
2913
2856
|
if (out instanceof ArkErrors) {
|
|
2914
2857
|
if (key === null) throwParseError(`Default ${out.summary}`);
|
|
2915
|
-
|
|
2858
|
+
const atPath = out.transform((e) => e.transform((input) => ({
|
|
2916
2859
|
...input,
|
|
2917
2860
|
prefixPath: [key]
|
|
2918
|
-
})))
|
|
2861
|
+
})));
|
|
2862
|
+
throwParseError(`Default for ${atPath.summary}`);
|
|
2919
2863
|
}
|
|
2920
|
-
return value
|
|
2864
|
+
return value;
|
|
2921
2865
|
};
|
|
2922
2866
|
const writeNonPrimitiveNonFunctionDefaultValueMessage = (key) => {
|
|
2923
2867
|
return `Non-primitive default ${key === null ? "" : typeof key === "number" ? `for value at [${key}] ` : `for ${compileSerializedValue(key)} `}must be specified as a function like () => ({my: 'object'})`;
|
|
2924
2868
|
};
|
|
2925
|
-
|
|
2926
2869
|
//#endregion
|
|
2927
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
2870
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/roots/root.js
|
|
2928
2871
|
var BaseRoot = class extends BaseNode {
|
|
2929
2872
|
constructor(attachments, $) {
|
|
2930
2873
|
super(attachments, $);
|
|
@@ -2984,14 +2927,14 @@ var BaseRoot = class extends BaseNode {
|
|
|
2984
2927
|
toJsonSchema(opts = {}) {
|
|
2985
2928
|
const ctx = mergeToJsonSchemaConfigs(this.$.resolvedConfig.toJsonSchema, opts);
|
|
2986
2929
|
ctx.useRefs ||= this.isCyclic;
|
|
2987
|
-
const schema
|
|
2988
|
-
Object.assign(schema
|
|
2930
|
+
const schema = typeof ctx.dialect === "string" ? { $schema: ctx.dialect } : {};
|
|
2931
|
+
Object.assign(schema, this.toJsonSchemaRecurse(ctx));
|
|
2989
2932
|
if (ctx.useRefs) {
|
|
2990
2933
|
const defs = flatMorph(this.references, (i, ref) => ref.isRoot() && !ref.alwaysExpandJsonSchema ? [ref.id, ref.toResolvedJsonSchema(ctx)] : []);
|
|
2991
|
-
if (ctx.target === "draft-07") Object.assign(schema
|
|
2992
|
-
else schema
|
|
2934
|
+
if (ctx.target === "draft-07") Object.assign(schema, { definitions: defs });
|
|
2935
|
+
else schema.$defs = defs;
|
|
2993
2936
|
}
|
|
2994
|
-
return schema
|
|
2937
|
+
return schema;
|
|
2995
2938
|
}
|
|
2996
2939
|
toJsonSchemaRecurse(ctx) {
|
|
2997
2940
|
if (ctx.useRefs && !this.alwaysExpandJsonSchema) return { $ref: `#/${ctx.target === "draft-07" ? "definitions" : "$defs"}/${this.id}` };
|
|
@@ -3002,7 +2945,15 @@ var BaseRoot = class extends BaseNode {
|
|
|
3002
2945
|
}
|
|
3003
2946
|
toResolvedJsonSchema(ctx) {
|
|
3004
2947
|
const result = this.innerToJsonSchema(ctx);
|
|
3005
|
-
|
|
2948
|
+
for (const k in this.meta) {
|
|
2949
|
+
const v = this.meta[k];
|
|
2950
|
+
result[k] = typeof v !== "function" && $ark.intrinsic.jsonData.allows(v) ? v : k === "default" ? ctx.fallback.defaultValue({
|
|
2951
|
+
code: "defaultValue",
|
|
2952
|
+
base: result,
|
|
2953
|
+
value: v
|
|
2954
|
+
}) : this.metaJson[k];
|
|
2955
|
+
}
|
|
2956
|
+
return result;
|
|
3006
2957
|
}
|
|
3007
2958
|
intersect(r) {
|
|
3008
2959
|
const rNode = this.$.parseDefinition(r);
|
|
@@ -3050,7 +3001,7 @@ var BaseRoot = class extends BaseNode {
|
|
|
3050
3001
|
_keyof;
|
|
3051
3002
|
keyof() {
|
|
3052
3003
|
if (this._keyof) return this._keyof;
|
|
3053
|
-
const result = this.applyStructuralOperation("keyof", []).reduce((result
|
|
3004
|
+
const result = this.applyStructuralOperation("keyof", []).reduce((result, branch) => result.intersect(branch).toNeverIfDisjoint(), $ark.intrinsic.unknown.internal);
|
|
3054
3005
|
if (result.branches.length === 0) throwParseError(writeUnsatisfiableExpressionError(`keyof ${this.expression}`));
|
|
3055
3006
|
return this._keyof = this.$.finalize(result);
|
|
3056
3007
|
}
|
|
@@ -3064,16 +3015,18 @@ var BaseRoot = class extends BaseNode {
|
|
|
3064
3015
|
}
|
|
3065
3016
|
applyStructuralOperation(operation, args) {
|
|
3066
3017
|
return this.distribute((branch) => {
|
|
3067
|
-
if (branch.equals($ark.intrinsic.object) && operation !== "merge") return branch;
|
|
3018
|
+
if (branch.equals($ark.intrinsic.object) && operation !== "merge" && operation !== "props") return branch;
|
|
3068
3019
|
const structure = structureOf(branch);
|
|
3069
3020
|
if (!structure) throwParseError(writeNonStructuralOperandMessage(operation, branch.expression));
|
|
3070
3021
|
if (operation === "keyof") return structure.keyof();
|
|
3071
3022
|
if (operation === "get") return structure.get(...args);
|
|
3072
3023
|
if (operation === "props") return structure.props;
|
|
3073
|
-
const
|
|
3024
|
+
const transformed = structure[operation === "required" ? "require" : operation === "partial" ? "optionalize" : operation](...args);
|
|
3025
|
+
const isHomomorphic = operation === "required" || operation === "partial";
|
|
3026
|
+
if (isHomomorphic && transformed.equals(structure)) return branch;
|
|
3074
3027
|
return this.$.node("intersection", {
|
|
3075
|
-
domain: "object",
|
|
3076
|
-
structure:
|
|
3028
|
+
...isHomomorphic && transformed.sequence ? { proto: Array } : { domain: "object" },
|
|
3029
|
+
structure: transformed
|
|
3077
3030
|
});
|
|
3078
3031
|
});
|
|
3079
3032
|
}
|
|
@@ -3090,7 +3043,10 @@ var BaseRoot = class extends BaseNode {
|
|
|
3090
3043
|
return this.$.schema(this.branches.filter((branch) => !branch.extends(rNode)));
|
|
3091
3044
|
}
|
|
3092
3045
|
array() {
|
|
3093
|
-
return this.$.
|
|
3046
|
+
return this.$.finalize(this.rawArray());
|
|
3047
|
+
}
|
|
3048
|
+
rawArray() {
|
|
3049
|
+
return this.$.parseSchema(this.isUnknown() ? { proto: Array } : {
|
|
3094
3050
|
proto: Array,
|
|
3095
3051
|
sequence: this
|
|
3096
3052
|
}, { prereduced: true });
|
|
@@ -3169,17 +3125,17 @@ var BaseRoot = class extends BaseNode {
|
|
|
3169
3125
|
narrow(predicate) {
|
|
3170
3126
|
return this.constrainOut("predicate", predicate);
|
|
3171
3127
|
}
|
|
3172
|
-
constrain(kind, schema
|
|
3173
|
-
return this._constrain("root", kind, schema
|
|
3128
|
+
constrain(kind, schema) {
|
|
3129
|
+
return this._constrain("root", kind, schema);
|
|
3174
3130
|
}
|
|
3175
|
-
constrainIn(kind, schema
|
|
3176
|
-
return this._constrain("in", kind, schema
|
|
3131
|
+
constrainIn(kind, schema) {
|
|
3132
|
+
return this._constrain("in", kind, schema);
|
|
3177
3133
|
}
|
|
3178
|
-
constrainOut(kind, schema
|
|
3179
|
-
return this._constrain("out", kind, schema
|
|
3134
|
+
constrainOut(kind, schema) {
|
|
3135
|
+
return this._constrain("out", kind, schema);
|
|
3180
3136
|
}
|
|
3181
|
-
_constrain(io, kind, schema
|
|
3182
|
-
const constraint = this.$.node(kind, schema
|
|
3137
|
+
_constrain(io, kind, schema) {
|
|
3138
|
+
const constraint = this.$.node(kind, schema);
|
|
3183
3139
|
if (constraint.isRoot()) return constraint.isUnknown() ? this : throwInternalError(`Unexpected constraint node ${constraint}`);
|
|
3184
3140
|
const operand = io === "root" ? this : io === "in" ? this.rawIn : this.rawOut;
|
|
3185
3141
|
if (operand.hasKind("morph") || constraint.impliedBasis && !operand.extends(constraint.impliedBasis)) return throwInvalidOperandError(kind, constraint.impliedBasis, this);
|
|
@@ -3194,12 +3150,12 @@ var BaseRoot = class extends BaseNode {
|
|
|
3194
3150
|
return this.$.finalize(this.transform((kind, inner) => kind === "structure" ? rule === "ignore" ? omit(inner, { undeclared: 1 }) : {
|
|
3195
3151
|
...inner,
|
|
3196
3152
|
undeclared: rule
|
|
3197
|
-
} : inner, deep ? void 0 : { shouldTransform: (node
|
|
3153
|
+
} : inner, deep ? void 0 : { shouldTransform: (node) => !includes(structuralKinds, node.kind) }));
|
|
3198
3154
|
}
|
|
3199
3155
|
hasEqualMorphs(r) {
|
|
3200
3156
|
if (!this.includesTransform && !r.includesTransform) return true;
|
|
3201
3157
|
if (!arrayEquals(this.shallowMorphs, r.shallowMorphs)) return false;
|
|
3202
|
-
if (!arrayEquals(this.flatMorphs, r.flatMorphs, { isEqual: (l, r
|
|
3158
|
+
if (!arrayEquals(this.flatMorphs, r.flatMorphs, { isEqual: (l, r) => l.propString === r.propString && (l.node.hasKind("morph") && r.node.hasKind("morph") ? l.node.hasEqualMorphs(r.node) : l.node.hasKind("intersection") && r.node.hasKind("intersection") ? l.node.structure?.structuralMorphRef === r.node.structure?.structuralMorphRef : false) })) return false;
|
|
3203
3159
|
return true;
|
|
3204
3160
|
}
|
|
3205
3161
|
onDeepUndeclaredKey(behavior) {
|
|
@@ -3211,50 +3167,50 @@ var BaseRoot = class extends BaseNode {
|
|
|
3211
3167
|
filter(predicate) {
|
|
3212
3168
|
return this.constrainIn("predicate", predicate);
|
|
3213
3169
|
}
|
|
3214
|
-
divisibleBy(schema
|
|
3215
|
-
return this.constrain("divisor", schema
|
|
3170
|
+
divisibleBy(schema) {
|
|
3171
|
+
return this.constrain("divisor", schema);
|
|
3216
3172
|
}
|
|
3217
|
-
matching(schema
|
|
3218
|
-
return this.constrain("pattern", schema
|
|
3173
|
+
matching(schema) {
|
|
3174
|
+
return this.constrain("pattern", schema);
|
|
3219
3175
|
}
|
|
3220
|
-
atLeast(schema
|
|
3221
|
-
return this.constrain("min", schema
|
|
3176
|
+
atLeast(schema) {
|
|
3177
|
+
return this.constrain("min", schema);
|
|
3222
3178
|
}
|
|
3223
|
-
atMost(schema
|
|
3224
|
-
return this.constrain("max", schema
|
|
3179
|
+
atMost(schema) {
|
|
3180
|
+
return this.constrain("max", schema);
|
|
3225
3181
|
}
|
|
3226
|
-
moreThan(schema
|
|
3227
|
-
return this.constrain("min", exclusivizeRangeSchema(schema
|
|
3182
|
+
moreThan(schema) {
|
|
3183
|
+
return this.constrain("min", exclusivizeRangeSchema(schema));
|
|
3228
3184
|
}
|
|
3229
|
-
lessThan(schema
|
|
3230
|
-
return this.constrain("max", exclusivizeRangeSchema(schema
|
|
3185
|
+
lessThan(schema) {
|
|
3186
|
+
return this.constrain("max", exclusivizeRangeSchema(schema));
|
|
3231
3187
|
}
|
|
3232
|
-
atLeastLength(schema
|
|
3233
|
-
return this.constrain("minLength", schema
|
|
3188
|
+
atLeastLength(schema) {
|
|
3189
|
+
return this.constrain("minLength", schema);
|
|
3234
3190
|
}
|
|
3235
|
-
atMostLength(schema
|
|
3236
|
-
return this.constrain("maxLength", schema
|
|
3191
|
+
atMostLength(schema) {
|
|
3192
|
+
return this.constrain("maxLength", schema);
|
|
3237
3193
|
}
|
|
3238
|
-
moreThanLength(schema
|
|
3239
|
-
return this.constrain("minLength", exclusivizeRangeSchema(schema
|
|
3194
|
+
moreThanLength(schema) {
|
|
3195
|
+
return this.constrain("minLength", exclusivizeRangeSchema(schema));
|
|
3240
3196
|
}
|
|
3241
|
-
lessThanLength(schema
|
|
3242
|
-
return this.constrain("maxLength", exclusivizeRangeSchema(schema
|
|
3197
|
+
lessThanLength(schema) {
|
|
3198
|
+
return this.constrain("maxLength", exclusivizeRangeSchema(schema));
|
|
3243
3199
|
}
|
|
3244
|
-
exactlyLength(schema
|
|
3245
|
-
return this.constrain("exactLength", schema
|
|
3200
|
+
exactlyLength(schema) {
|
|
3201
|
+
return this.constrain("exactLength", schema);
|
|
3246
3202
|
}
|
|
3247
|
-
atOrAfter(schema
|
|
3248
|
-
return this.constrain("after", schema
|
|
3203
|
+
atOrAfter(schema) {
|
|
3204
|
+
return this.constrain("after", schema);
|
|
3249
3205
|
}
|
|
3250
|
-
atOrBefore(schema
|
|
3251
|
-
return this.constrain("before", schema
|
|
3206
|
+
atOrBefore(schema) {
|
|
3207
|
+
return this.constrain("before", schema);
|
|
3252
3208
|
}
|
|
3253
|
-
laterThan(schema
|
|
3254
|
-
return this.constrain("after", exclusivizeRangeSchema(schema
|
|
3209
|
+
laterThan(schema) {
|
|
3210
|
+
return this.constrain("after", exclusivizeRangeSchema(schema));
|
|
3255
3211
|
}
|
|
3256
|
-
earlierThan(schema
|
|
3257
|
-
return this.constrain("before", exclusivizeRangeSchema(schema
|
|
3212
|
+
earlierThan(schema) {
|
|
3213
|
+
return this.constrain("before", exclusivizeRangeSchema(schema));
|
|
3258
3214
|
}
|
|
3259
3215
|
};
|
|
3260
3216
|
const emptyBrandNameMessage = `Expected a non-empty brand name after #`;
|
|
@@ -3264,11 +3220,11 @@ const validateStandardJsonSchemaTarget = (target) => {
|
|
|
3264
3220
|
if (!includes(supportedJsonSchemaTargets, target)) throwParseError(writeInvalidJsonSchemaTargetMessage(target));
|
|
3265
3221
|
return target;
|
|
3266
3222
|
};
|
|
3267
|
-
const exclusivizeRangeSchema = (schema
|
|
3268
|
-
...schema
|
|
3223
|
+
const exclusivizeRangeSchema = (schema) => typeof schema === "object" && !(schema instanceof Date) ? {
|
|
3224
|
+
...schema,
|
|
3269
3225
|
exclusive: true
|
|
3270
3226
|
} : {
|
|
3271
|
-
rule: schema
|
|
3227
|
+
rule: schema,
|
|
3272
3228
|
exclusive: true
|
|
3273
3229
|
};
|
|
3274
3230
|
const typeOrTermExtends = (t, base) => hasArkKind(base, "root") ? hasArkKind(t, "root") ? t.extends(base) : base.allows(t) : hasArkKind(t, "root") ? t.hasUnit(base) : base === t;
|
|
@@ -3281,14 +3237,12 @@ const structureOf = (branch) => {
|
|
|
3281
3237
|
const writeLiteralUnionEntriesMessage = (expression) => `Props cannot be extracted from a union. Use .distribute to extract props from each branch instead. Received:
|
|
3282
3238
|
${expression}`;
|
|
3283
3239
|
const writeNonStructuralOperandMessage = (operation, operand) => `${operation} operand must be an object (was ${operand})`;
|
|
3284
|
-
|
|
3285
3240
|
//#endregion
|
|
3286
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
3287
|
-
const defineRightwardIntersections = (kind, implementation
|
|
3288
|
-
|
|
3241
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/roots/utils.js
|
|
3242
|
+
const defineRightwardIntersections = (kind, implementation) => flatMorph(schemaKindsRightOf(kind), (i, kind) => [kind, implementation]);
|
|
3289
3243
|
//#endregion
|
|
3290
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
3291
|
-
const normalizeAliasSchema = (schema
|
|
3244
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/roots/alias.js
|
|
3245
|
+
const normalizeAliasSchema = (schema) => typeof schema === "string" ? { reference: schema } : schema;
|
|
3292
3246
|
const neverIfDisjoint = (result) => result instanceof Disjoint ? $ark.intrinsic.never.internal : result;
|
|
3293
3247
|
const implementation$10 = implementNode({
|
|
3294
3248
|
kind: "alias",
|
|
@@ -3299,7 +3253,7 @@ const implementation$10 = implementNode({
|
|
|
3299
3253
|
resolve: {}
|
|
3300
3254
|
},
|
|
3301
3255
|
normalize: normalizeAliasSchema,
|
|
3302
|
-
defaults: { description: (node
|
|
3256
|
+
defaults: { description: (node) => node.reference },
|
|
3303
3257
|
intersections: {
|
|
3304
3258
|
alias: (l, r, ctx) => ctx.$.lazilyResolve(() => neverIfDisjoint(intersectOrPipeNodes(l.resolution, r.resolution, ctx)), `${l.reference}${ctx.pipe ? "=>" : "&"}${r.reference}`),
|
|
3305
3259
|
...defineRightwardIntersections("alias", (l, r, ctx) => {
|
|
@@ -3320,7 +3274,8 @@ var AliasNode = class extends BaseRoot {
|
|
|
3320
3274
|
_resolve() {
|
|
3321
3275
|
if (this.resolve) return this.resolve();
|
|
3322
3276
|
if (this.reference[0] === "$") return this.$.resolveRoot(this.reference.slice(1));
|
|
3323
|
-
|
|
3277
|
+
const id = this.reference;
|
|
3278
|
+
let resolution = nodesByRegisteredId[id];
|
|
3324
3279
|
const seen = [];
|
|
3325
3280
|
while (hasArkKind(resolution, "context")) {
|
|
3326
3281
|
if (seen.includes(resolution.id)) return throwParseError(writeShallowCycleErrorMessage(resolution.id, seen));
|
|
@@ -3372,9 +3327,8 @@ const Alias = {
|
|
|
3372
3327
|
implementation: implementation$10,
|
|
3373
3328
|
Node: AliasNode
|
|
3374
3329
|
};
|
|
3375
|
-
|
|
3376
3330
|
//#endregion
|
|
3377
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
3331
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/roots/basis.js
|
|
3378
3332
|
var InternalBasis = class extends BaseRoot {
|
|
3379
3333
|
traverseApply = (data, ctx) => {
|
|
3380
3334
|
if (!this.traverseAllows(data, ctx)) ctx.errorFromNodeContext(this.errorContext);
|
|
@@ -3395,9 +3349,8 @@ var InternalBasis = class extends BaseRoot {
|
|
|
3395
3349
|
else js.if(this.compiledNegation, () => js.line(`ctx.errorFromNodeContext(${this.compiledErrorContext})`));
|
|
3396
3350
|
}
|
|
3397
3351
|
};
|
|
3398
|
-
|
|
3399
3352
|
//#endregion
|
|
3400
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
3353
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/roots/domain.js
|
|
3401
3354
|
const implementation$9 = implementNode({
|
|
3402
3355
|
kind: "domain",
|
|
3403
3356
|
hasAssociatedError: true,
|
|
@@ -3406,13 +3359,13 @@ const implementation$9 = implementNode({
|
|
|
3406
3359
|
domain: {},
|
|
3407
3360
|
numberAllowsNaN: {}
|
|
3408
3361
|
},
|
|
3409
|
-
normalize: (schema
|
|
3410
|
-
applyConfig: (schema
|
|
3411
|
-
...schema
|
|
3362
|
+
normalize: (schema) => typeof schema === "string" ? { domain: schema } : hasKey(schema, "numberAllowsNaN") && schema.domain !== "number" ? throwParseError(Domain.writeBadAllowNanMessage(schema.domain)) : schema,
|
|
3363
|
+
applyConfig: (schema, config) => schema.numberAllowsNaN === void 0 && schema.domain === "number" && config.numberAllowsNaN ? {
|
|
3364
|
+
...schema,
|
|
3412
3365
|
numberAllowsNaN: true
|
|
3413
|
-
} : schema
|
|
3366
|
+
} : schema,
|
|
3414
3367
|
defaults: {
|
|
3415
|
-
description: (node
|
|
3368
|
+
description: (node) => domainDescriptions[node.domain],
|
|
3416
3369
|
actual: (data) => Number.isNaN(data) ? "NaN" : domainDescriptions[domainOf(data)]
|
|
3417
3370
|
},
|
|
3418
3371
|
intersections: { domain: (l, r) => l.domain === "number" && r.domain === "number" ? l.numberAllowsNaN ? r : l : Disjoint.init("domain", l, r) }
|
|
@@ -3443,18 +3396,17 @@ const Domain = {
|
|
|
3443
3396
|
Node: DomainNode,
|
|
3444
3397
|
writeBadAllowNanMessage: (actual) => `numberAllowsNaN may only be specified with domain "number" (was ${actual})`
|
|
3445
3398
|
};
|
|
3446
|
-
|
|
3447
3399
|
//#endregion
|
|
3448
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
3400
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/roots/intersection.js
|
|
3449
3401
|
const implementation$8 = implementNode({
|
|
3450
3402
|
kind: "intersection",
|
|
3451
3403
|
hasAssociatedError: true,
|
|
3452
3404
|
normalize: (rawSchema) => {
|
|
3453
3405
|
if (isNode(rawSchema)) return rawSchema;
|
|
3454
|
-
const { structure, ...schema
|
|
3406
|
+
const { structure, ...schema } = rawSchema;
|
|
3455
3407
|
const hasRootStructureKey = !!structure;
|
|
3456
3408
|
const normalizedStructure = structure ?? {};
|
|
3457
|
-
const normalized = flatMorph(schema
|
|
3409
|
+
const normalized = flatMorph(schema, (k, v) => {
|
|
3458
3410
|
if (isKeyOf(k, structureKeys)) {
|
|
3459
3411
|
if (hasRootStructureKey) throwParseError(`Flattened structure key ${k} cannot be specified alongside a root 'structure' key.`);
|
|
3460
3412
|
normalizedStructure[k] = v;
|
|
@@ -3472,18 +3424,18 @@ const implementation$8 = implementNode({
|
|
|
3472
3424
|
keys: {
|
|
3473
3425
|
domain: {
|
|
3474
3426
|
child: true,
|
|
3475
|
-
parse: (schema
|
|
3427
|
+
parse: (schema, ctx) => ctx.$.node("domain", schema)
|
|
3476
3428
|
},
|
|
3477
3429
|
proto: {
|
|
3478
3430
|
child: true,
|
|
3479
|
-
parse: (schema
|
|
3431
|
+
parse: (schema, ctx) => ctx.$.node("proto", schema)
|
|
3480
3432
|
},
|
|
3481
3433
|
structure: {
|
|
3482
3434
|
child: true,
|
|
3483
|
-
parse: (schema
|
|
3484
|
-
serialize: (node
|
|
3485
|
-
if (!node
|
|
3486
|
-
const { sequence, ...structureJson } = node
|
|
3435
|
+
parse: (schema, ctx) => ctx.$.node("structure", schema),
|
|
3436
|
+
serialize: (node) => {
|
|
3437
|
+
if (!node.sequence?.minLength) return node.collapsibleJson;
|
|
3438
|
+
const { sequence, ...structureJson } = node.collapsibleJson;
|
|
3487
3439
|
const { minVariadicLength, ...sequenceJson } = sequence;
|
|
3488
3440
|
const collapsibleSequenceJson = sequenceJson.variadic && Object.keys(sequenceJson).length === 1 ? sequenceJson.variadic : sequenceJson;
|
|
3489
3441
|
return {
|
|
@@ -3539,16 +3491,16 @@ const implementation$8 = implementNode({
|
|
|
3539
3491
|
pipe: false
|
|
3540
3492
|
}),
|
|
3541
3493
|
defaults: {
|
|
3542
|
-
description: (node
|
|
3543
|
-
if (node
|
|
3544
|
-
if (node
|
|
3494
|
+
description: (node) => {
|
|
3495
|
+
if (node.children.length === 0) return "unknown";
|
|
3496
|
+
if (node.structure) return node.structure.description;
|
|
3545
3497
|
const childDescriptions = [];
|
|
3546
|
-
if (node
|
|
3547
|
-
if (node
|
|
3548
|
-
const sortedRefinementDescriptions = node
|
|
3498
|
+
if (node.basis && !node.prestructurals.some((r) => r.impl.obviatesBasisDescription)) childDescriptions.push(node.basis.description);
|
|
3499
|
+
if (node.prestructurals.length) {
|
|
3500
|
+
const sortedRefinementDescriptions = node.prestructurals.slice().sort((l, r) => l.kind === "min" && r.kind === "max" ? -1 : 0).map((r) => r.description);
|
|
3549
3501
|
childDescriptions.push(...sortedRefinementDescriptions);
|
|
3550
3502
|
}
|
|
3551
|
-
if (node
|
|
3503
|
+
if (node.inner.predicate) childDescriptions.push(...node.inner.predicate.map((p) => p.description));
|
|
3552
3504
|
return childDescriptions.join(" and ");
|
|
3553
3505
|
},
|
|
3554
3506
|
expected: (source) => ` ◦ ${source.errors.map((e) => e.expected).join("\n ◦ ")}`,
|
|
@@ -3571,9 +3523,9 @@ const implementation$8 = implementNode({
|
|
|
3571
3523
|
var IntersectionNode = class extends BaseRoot {
|
|
3572
3524
|
basis = this.inner.domain ?? this.inner.proto ?? null;
|
|
3573
3525
|
prestructurals = [];
|
|
3574
|
-
refinements = this.children.filter((node
|
|
3575
|
-
if (!node
|
|
3576
|
-
if (includes(prestructuralKinds, node
|
|
3526
|
+
refinements = this.children.filter((node) => {
|
|
3527
|
+
if (!node.isRefinement()) return false;
|
|
3528
|
+
if (includes(prestructuralKinds, node.kind)) this.prestructurals.push(node);
|
|
3577
3529
|
return true;
|
|
3578
3530
|
});
|
|
3579
3531
|
structure = this.inner.structure;
|
|
@@ -3585,7 +3537,7 @@ var IntersectionNode = class extends BaseRoot {
|
|
|
3585
3537
|
return this.basis?.defaultShortDescription ?? "present";
|
|
3586
3538
|
}
|
|
3587
3539
|
innerToJsonSchema(ctx) {
|
|
3588
|
-
return this.children.reduce((schema
|
|
3540
|
+
return this.children.reduce((schema, child) => child.isBasis() ? child.toJsonSchemaRecurse(ctx) : child.reduceJsonSchema(schema, ctx), {});
|
|
3589
3541
|
}
|
|
3590
3542
|
traverseAllows = (data, ctx) => this.children.every((child) => child.traverseAllows(data, ctx));
|
|
3591
3543
|
traverseApply = (data, ctx) => {
|
|
@@ -3650,11 +3602,11 @@ const Intersection = {
|
|
|
3650
3602
|
implementation: implementation$8,
|
|
3651
3603
|
Node: IntersectionNode
|
|
3652
3604
|
};
|
|
3653
|
-
const writeIntersectionExpression = (node
|
|
3654
|
-
if (node
|
|
3655
|
-
const basisExpression = node
|
|
3656
|
-
const refinementsExpression = node
|
|
3657
|
-
const fullExpression = `${basisExpression}${basisExpression ? " " : ""}${refinementsExpression}`;
|
|
3605
|
+
const writeIntersectionExpression = (node) => {
|
|
3606
|
+
if (node.structure?.expression) return node.structure.expression;
|
|
3607
|
+
const basisExpression = node.basis && !node.prestructurals.some((n) => n.impl.obviatesBasisExpression) ? node.basis.nestableExpression : "";
|
|
3608
|
+
const refinementsExpression = node.prestructurals.map((n) => n.expression).join(" & ");
|
|
3609
|
+
const fullExpression = `${basisExpression}${basisExpression && refinementsExpression ? " " : ""}${refinementsExpression}`;
|
|
3658
3610
|
if (fullExpression === "Array == 0") return "[]";
|
|
3659
3611
|
return fullExpression || "unknown";
|
|
3660
3612
|
};
|
|
@@ -3674,16 +3626,15 @@ const intersectIntersections = (l, r, ctx) => {
|
|
|
3674
3626
|
ctx
|
|
3675
3627
|
});
|
|
3676
3628
|
};
|
|
3677
|
-
|
|
3678
3629
|
//#endregion
|
|
3679
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
3630
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/roots/morph.js
|
|
3680
3631
|
const implementation$7 = implementNode({
|
|
3681
3632
|
kind: "morph",
|
|
3682
3633
|
hasAssociatedError: false,
|
|
3683
3634
|
keys: {
|
|
3684
3635
|
in: {
|
|
3685
3636
|
child: true,
|
|
3686
|
-
parse: (schema
|
|
3637
|
+
parse: (schema, ctx) => ctx.$.parseSchema(schema)
|
|
3687
3638
|
},
|
|
3688
3639
|
morphs: {
|
|
3689
3640
|
parse: liftArray,
|
|
@@ -3691,15 +3642,15 @@ const implementation$7 = implementNode({
|
|
|
3691
3642
|
},
|
|
3692
3643
|
declaredIn: {
|
|
3693
3644
|
child: false,
|
|
3694
|
-
serialize: (node
|
|
3645
|
+
serialize: (node) => node.json
|
|
3695
3646
|
},
|
|
3696
3647
|
declaredOut: {
|
|
3697
3648
|
child: false,
|
|
3698
|
-
serialize: (node
|
|
3649
|
+
serialize: (node) => node.json
|
|
3699
3650
|
}
|
|
3700
3651
|
},
|
|
3701
|
-
normalize: (schema
|
|
3702
|
-
defaults: { description: (node
|
|
3652
|
+
normalize: (schema) => schema,
|
|
3653
|
+
defaults: { description: (node) => `a morph from ${node.rawIn.description} to ${node.rawOut?.description ?? "unknown"}` },
|
|
3703
3654
|
intersections: {
|
|
3704
3655
|
morph: (l, r, ctx) => {
|
|
3705
3656
|
if (!l.hasEqualMorphs(r)) return throwParseError(writeMorphIntersectionMessage(l.expression, r.expression));
|
|
@@ -3795,9 +3746,8 @@ const Morph = {
|
|
|
3795
3746
|
const writeMorphIntersectionMessage = (lDescription, rDescription) => `The intersection of distinct morphs at a single path is indeterminate:
|
|
3796
3747
|
Left: ${lDescription}
|
|
3797
3748
|
Right: ${rDescription}`;
|
|
3798
|
-
|
|
3799
3749
|
//#endregion
|
|
3800
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
3750
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/roots/proto.js
|
|
3801
3751
|
const implementation$6 = implementNode({
|
|
3802
3752
|
kind: "proto",
|
|
3803
3753
|
hasAssociatedError: true,
|
|
@@ -3806,24 +3756,24 @@ const implementation$6 = implementNode({
|
|
|
3806
3756
|
proto: { serialize: (ctor) => getBuiltinNameOfConstructor(ctor) ?? defaultValueSerializer(ctor) },
|
|
3807
3757
|
dateAllowsInvalid: {}
|
|
3808
3758
|
},
|
|
3809
|
-
normalize: (schema
|
|
3810
|
-
const normalized = typeof schema
|
|
3811
|
-
...schema
|
|
3812
|
-
proto: builtinConstructors[schema
|
|
3813
|
-
} : schema
|
|
3759
|
+
normalize: (schema) => {
|
|
3760
|
+
const normalized = typeof schema === "string" ? { proto: builtinConstructors[schema] } : typeof schema === "function" ? isNode(schema) ? schema : { proto: schema } : typeof schema.proto === "string" ? {
|
|
3761
|
+
...schema,
|
|
3762
|
+
proto: builtinConstructors[schema.proto]
|
|
3763
|
+
} : schema;
|
|
3814
3764
|
if (typeof normalized.proto !== "function") throwParseError(Proto.writeInvalidSchemaMessage(normalized.proto));
|
|
3815
3765
|
if (hasKey(normalized, "dateAllowsInvalid") && normalized.proto !== Date) throwParseError(Proto.writeBadInvalidDateMessage(normalized.proto));
|
|
3816
3766
|
return normalized;
|
|
3817
3767
|
},
|
|
3818
|
-
applyConfig: (schema
|
|
3819
|
-
if (schema
|
|
3820
|
-
...schema
|
|
3768
|
+
applyConfig: (schema, config) => {
|
|
3769
|
+
if (schema.dateAllowsInvalid === void 0 && schema.proto === Date && config.dateAllowsInvalid) return {
|
|
3770
|
+
...schema,
|
|
3821
3771
|
dateAllowsInvalid: true
|
|
3822
3772
|
};
|
|
3823
|
-
return schema
|
|
3773
|
+
return schema;
|
|
3824
3774
|
},
|
|
3825
3775
|
defaults: {
|
|
3826
|
-
description: (node
|
|
3776
|
+
description: (node) => node.builtinName ? objectKindDescriptions[node.builtinName] : `an instance of ${node.proto.name}`,
|
|
3827
3777
|
actual: (data) => data instanceof Date && data.toString() === "Invalid Date" ? "an invalid Date" : objectKindOrDomainOf(data)
|
|
3828
3778
|
},
|
|
3829
3779
|
intersections: {
|
|
@@ -3835,8 +3785,9 @@ var ProtoNode = class extends InternalBasis {
|
|
|
3835
3785
|
builtinName = getBuiltinNameOfConstructor(this.proto);
|
|
3836
3786
|
serializedConstructor = this.json.proto;
|
|
3837
3787
|
requiresInvalidDateCheck = this.proto === Date && !this.dateAllowsInvalid;
|
|
3838
|
-
|
|
3839
|
-
|
|
3788
|
+
isArrayProto = this.proto === Array;
|
|
3789
|
+
traverseAllows = this.requiresInvalidDateCheck ? (data) => data instanceof Date && data.toString() !== "Invalid Date" : this.isArrayProto ? (data) => isArray(data) : (data) => data instanceof this.proto;
|
|
3790
|
+
compiledCondition = this.isArrayProto ? `Array.isArray(data)` : `data instanceof ${this.serializedConstructor}${this.requiresInvalidDateCheck ? ` && data.toString() !== "Invalid Date"` : ""}`;
|
|
3840
3791
|
compiledNegation = `!(${this.compiledCondition})`;
|
|
3841
3792
|
innerToJsonSchema(ctx) {
|
|
3842
3793
|
switch (this.builtinName) {
|
|
@@ -3871,9 +3822,8 @@ const Proto = {
|
|
|
3871
3822
|
writeBadInvalidDateMessage: (actual) => `dateAllowsInvalid may only be specified with constructor Date (was ${actual.name})`,
|
|
3872
3823
|
writeInvalidSchemaMessage: (actual) => `instanceOf operand must be a function (was ${domainOf(actual)})`
|
|
3873
3824
|
};
|
|
3874
|
-
|
|
3875
3825
|
//#endregion
|
|
3876
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
3826
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/roots/union.js
|
|
3877
3827
|
const implementation$5 = implementNode({
|
|
3878
3828
|
kind: "union",
|
|
3879
3829
|
hasAssociatedError: true,
|
|
@@ -3882,28 +3832,29 @@ const implementation$5 = implementNode({
|
|
|
3882
3832
|
ordered: {},
|
|
3883
3833
|
branches: {
|
|
3884
3834
|
child: true,
|
|
3885
|
-
parse: (schema
|
|
3835
|
+
parse: (schema, ctx) => {
|
|
3886
3836
|
const branches = [];
|
|
3887
|
-
for (const branchSchema of schema
|
|
3837
|
+
for (const branchSchema of schema) {
|
|
3888
3838
|
const branchNodes = hasArkKind(branchSchema, "root") ? branchSchema.branches : ctx.$.parseSchema(branchSchema).branches;
|
|
3889
|
-
for (const node
|
|
3890
|
-
const matchingMorphIndex = branches.findIndex((matching) => matching.hasKind("morph") && matching.hasEqualMorphs(node
|
|
3891
|
-
if (matchingMorphIndex === -1) branches.push(node
|
|
3839
|
+
for (const node of branchNodes) if (node.hasKind("morph")) {
|
|
3840
|
+
const matchingMorphIndex = branches.findIndex((matching) => matching.hasKind("morph") && matching.hasEqualMorphs(node));
|
|
3841
|
+
if (matchingMorphIndex === -1) branches.push(node);
|
|
3892
3842
|
else {
|
|
3893
3843
|
const matchingMorph = branches[matchingMorphIndex];
|
|
3844
|
+
const mergedIn = matchingMorph.inner.in && node.inner.in ? matchingMorph.inner.in.rawOr(node.inner.in) : matchingMorph.rawIn.rawOr(node.rawIn);
|
|
3894
3845
|
branches[matchingMorphIndex] = ctx.$.node("morph", {
|
|
3895
3846
|
...matchingMorph.inner,
|
|
3896
|
-
in:
|
|
3847
|
+
in: mergedIn
|
|
3897
3848
|
});
|
|
3898
3849
|
}
|
|
3899
|
-
} else branches.push(node
|
|
3850
|
+
} else branches.push(node);
|
|
3900
3851
|
}
|
|
3901
3852
|
if (!ctx.def.ordered) branches.sort((l, r) => l.hash < r.hash ? -1 : 1);
|
|
3902
3853
|
return branches;
|
|
3903
3854
|
}
|
|
3904
3855
|
}
|
|
3905
3856
|
},
|
|
3906
|
-
normalize: (schema
|
|
3857
|
+
normalize: (schema) => isArray(schema) ? { branches: schema } : schema,
|
|
3907
3858
|
reduce: (inner, $) => {
|
|
3908
3859
|
const reducedBranches = reduceBranches(inner);
|
|
3909
3860
|
if (reducedBranches.length === 1) return reducedBranches[0];
|
|
@@ -3914,16 +3865,17 @@ const implementation$5 = implementNode({
|
|
|
3914
3865
|
}, { prereduced: true });
|
|
3915
3866
|
},
|
|
3916
3867
|
defaults: {
|
|
3917
|
-
description: (node
|
|
3868
|
+
description: (node) => node.distribute((branch) => branch.description, describeBranches),
|
|
3918
3869
|
expected: (ctx) => {
|
|
3919
3870
|
const byPath = groupBy(ctx.errors, "propString");
|
|
3920
|
-
|
|
3871
|
+
const pathDescriptions = Object.entries(byPath).map(([path, errors]) => {
|
|
3921
3872
|
const branchesAtPath = [];
|
|
3922
3873
|
for (const errorAtPath of errors) appendUnique(branchesAtPath, errorAtPath.expected);
|
|
3923
3874
|
const expected = describeBranches(branchesAtPath);
|
|
3924
3875
|
const actual = errors.every((e) => e.actual === errors[0].actual) ? errors[0].actual : printable(errors[0].data);
|
|
3925
3876
|
return `${path && `${path} `}must be ${expected}${actual && ` (was ${actual})`}`;
|
|
3926
|
-
})
|
|
3877
|
+
});
|
|
3878
|
+
return describeBranches(pathDescriptions);
|
|
3927
3879
|
},
|
|
3928
3880
|
problem: (ctx) => ctx.expected,
|
|
3929
3881
|
message: (ctx) => {
|
|
@@ -4041,10 +3993,11 @@ var UnionNode = class extends BaseRoot {
|
|
|
4041
3993
|
const caseCondition = k === "default" ? k : `case ${k}`;
|
|
4042
3994
|
let caseResult;
|
|
4043
3995
|
if (v === true) caseResult = optimistic ? "data" : "true";
|
|
4044
|
-
else if (optimistic)
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
3996
|
+
else if (optimistic) {
|
|
3997
|
+
if (v.rootApplyStrategy === "branchedOptimistic") caseResult = js.invoke(v, { kind: "Optimistic" });
|
|
3998
|
+
else if (v.contextFreeMorph) caseResult = `${js.invoke(v)} ? ${registeredReference(v.contextFreeMorph)}(data) : "${unset}"`;
|
|
3999
|
+
else caseResult = `${js.invoke(v)} ? data : "${unset}"`;
|
|
4000
|
+
} else caseResult = js.invoke(v);
|
|
4048
4001
|
js.line(`${caseCondition}: return ${caseResult}`);
|
|
4049
4002
|
}
|
|
4050
4003
|
return js;
|
|
@@ -4084,7 +4037,7 @@ var UnionNode = class extends BaseRoot {
|
|
|
4084
4037
|
return this.isBoolean ? "boolean" : `(${this.expression})`;
|
|
4085
4038
|
}
|
|
4086
4039
|
discriminate() {
|
|
4087
|
-
if (this.branches.length < 2
|
|
4040
|
+
if (this.branches.length < 2) return null;
|
|
4088
4041
|
if (this.unitBranches.length === this.branches.length) return {
|
|
4089
4042
|
kind: "unit",
|
|
4090
4043
|
path: [],
|
|
@@ -4172,7 +4125,7 @@ var UnionNode = class extends BaseRoot {
|
|
|
4172
4125
|
return Object.assign(ctx.location, { cases });
|
|
4173
4126
|
}
|
|
4174
4127
|
};
|
|
4175
|
-
const createCaseResolutionContext = (viableCandidates, node
|
|
4128
|
+
const createCaseResolutionContext = (viableCandidates, node) => {
|
|
4176
4129
|
const best = viableCandidates.sort((l, r) => l.path.length === r.path.length ? Object.keys(r.cases).length - Object.keys(l.cases).length : l.path.length - r.path.length)[0];
|
|
4177
4130
|
return {
|
|
4178
4131
|
best,
|
|
@@ -4181,11 +4134,11 @@ const createCaseResolutionContext = (viableCandidates, node$1) => {
|
|
|
4181
4134
|
path: best.path,
|
|
4182
4135
|
optionallyChainedPropString: optionallyChainPropString(best.path)
|
|
4183
4136
|
},
|
|
4184
|
-
defaultEntries: node
|
|
4137
|
+
defaultEntries: node.branches.map((branch, originalIndex) => ({
|
|
4185
4138
|
originalIndex,
|
|
4186
4139
|
branch
|
|
4187
4140
|
})),
|
|
4188
|
-
node
|
|
4141
|
+
node
|
|
4189
4142
|
};
|
|
4190
4143
|
};
|
|
4191
4144
|
const resolveCase = (ctx, key) => {
|
|
@@ -4233,21 +4186,21 @@ const viableOrderedCandidates = (candidates, originalBranches) => {
|
|
|
4233
4186
|
});
|
|
4234
4187
|
};
|
|
4235
4188
|
const discriminantCaseToNode = (caseDiscriminant, path, $) => {
|
|
4236
|
-
let node
|
|
4189
|
+
let node = caseDiscriminant === "undefined" ? $.node("unit", { unit: void 0 }) : caseDiscriminant === "null" ? $.node("unit", { unit: null }) : caseDiscriminant === "boolean" ? $.units([true, false]) : caseDiscriminant;
|
|
4237
4190
|
for (let i = path.length - 1; i >= 0; i--) {
|
|
4238
4191
|
const key = path[i];
|
|
4239
|
-
node
|
|
4192
|
+
node = $.node("intersection", typeof key === "number" ? {
|
|
4240
4193
|
proto: "Array",
|
|
4241
|
-
sequence: [...range(key).map((_) => ({})), node
|
|
4194
|
+
sequence: [...range(key).map((_) => ({})), node]
|
|
4242
4195
|
} : {
|
|
4243
4196
|
domain: "object",
|
|
4244
4197
|
required: [{
|
|
4245
4198
|
key,
|
|
4246
|
-
value: node
|
|
4199
|
+
value: node
|
|
4247
4200
|
}]
|
|
4248
4201
|
});
|
|
4249
4202
|
}
|
|
4250
|
-
return node
|
|
4203
|
+
return node;
|
|
4251
4204
|
};
|
|
4252
4205
|
const optionallyChainPropString = (path) => path.reduce((acc, k) => acc + compileLiteralPropAccess(k, true), "data");
|
|
4253
4206
|
const serializedTypeOfDescriptions = registeredReference(jsTypeOfDescriptions);
|
|
@@ -4259,7 +4212,7 @@ const Union = {
|
|
|
4259
4212
|
const discriminantToJson = (discriminant) => ({
|
|
4260
4213
|
kind: discriminant.kind,
|
|
4261
4214
|
path: discriminant.path.map((k) => typeof k === "string" ? k : compileSerializedValue(k)),
|
|
4262
|
-
cases: flatMorph(discriminant.cases, (k, node
|
|
4215
|
+
cases: flatMorph(discriminant.cases, (k, node) => [k, node === true ? node : node.hasKind("union") && node.discriminantJson ? node.discriminantJson : node.json])
|
|
4263
4216
|
});
|
|
4264
4217
|
const describeExpressionOptions = {
|
|
4265
4218
|
delimiter: " | ",
|
|
@@ -4322,17 +4275,17 @@ const reduceBranches = ({ branches, ordered }) => {
|
|
|
4322
4275
|
const assertDeterminateOverlap = (l, r) => {
|
|
4323
4276
|
if (!l.includesTransform && !r.includesTransform) return;
|
|
4324
4277
|
if (!arrayEquals(l.shallowMorphs, r.shallowMorphs)) throwParseError(writeIndiscriminableMorphMessage(l.expression, r.expression));
|
|
4325
|
-
if (!arrayEquals(l.flatMorphs, r.flatMorphs, { isEqual: (l
|
|
4278
|
+
if (!arrayEquals(l.flatMorphs, r.flatMorphs, { isEqual: (l, r) => l.propString === r.propString && (l.node.hasKind("morph") && r.node.hasKind("morph") ? l.node.hasEqualMorphs(r.node) : l.node.hasKind("intersection") && r.node.hasKind("intersection") ? l.node.structure?.structuralMorphRef === r.node.structure?.structuralMorphRef : false) })) throwParseError(writeIndiscriminableMorphMessage(l.expression, r.expression));
|
|
4326
4279
|
};
|
|
4327
4280
|
const pruneDiscriminant = (discriminantBranch, discriminantCtx) => discriminantBranch.transform((nodeKind, inner) => {
|
|
4328
4281
|
if (nodeKind === "domain" || nodeKind === "unit") return null;
|
|
4329
4282
|
return inner;
|
|
4330
|
-
}, { shouldTransform: (node
|
|
4283
|
+
}, { shouldTransform: (node, ctx) => {
|
|
4331
4284
|
const propString = optionallyChainPropString(ctx.path);
|
|
4332
4285
|
if (!discriminantCtx.optionallyChainedPropString.startsWith(propString)) return false;
|
|
4333
|
-
if (node
|
|
4334
|
-
if ((node
|
|
4335
|
-
return node
|
|
4286
|
+
if (node.hasKind("domain") && node.domain === "object") return true;
|
|
4287
|
+
if ((node.hasKind("domain") || discriminantCtx.kind === "unit") && propString === discriminantCtx.optionallyChainedPropString) return true;
|
|
4288
|
+
return node.children.length !== 0 && node.kind !== "index";
|
|
4336
4289
|
} });
|
|
4337
4290
|
const writeIndiscriminableMorphMessage = (lDescription, rDescription) => `An unordered union of a type including a morph and a type with overlapping input is indeterminate:
|
|
4338
4291
|
Left: ${lDescription}
|
|
@@ -4340,19 +4293,18 @@ Right: ${rDescription}`;
|
|
|
4340
4293
|
const writeOrderedIntersectionMessage = (lDescription, rDescription) => `The intersection of two ordered unions is indeterminate:
|
|
4341
4294
|
Left: ${lDescription}
|
|
4342
4295
|
Right: ${rDescription}`;
|
|
4343
|
-
|
|
4344
4296
|
//#endregion
|
|
4345
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
4297
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/roots/unit.js
|
|
4346
4298
|
const implementation$4 = implementNode({
|
|
4347
4299
|
kind: "unit",
|
|
4348
4300
|
hasAssociatedError: true,
|
|
4349
4301
|
keys: { unit: {
|
|
4350
4302
|
preserveUndefined: true,
|
|
4351
|
-
serialize: (schema
|
|
4303
|
+
serialize: (schema) => schema instanceof Date ? schema.toISOString() : defaultValueSerializer(schema)
|
|
4352
4304
|
} },
|
|
4353
|
-
normalize: (schema
|
|
4305
|
+
normalize: (schema) => schema,
|
|
4354
4306
|
defaults: {
|
|
4355
|
-
description: (node
|
|
4307
|
+
description: (node) => printable(node.unit),
|
|
4356
4308
|
problem: ({ expected, actual }) => `${expected === actual ? `must be reference equal to ${expected} (serialized to the same value)` : `must be ${expected} (was ${actual})`}`
|
|
4357
4309
|
},
|
|
4358
4310
|
intersections: {
|
|
@@ -4402,9 +4354,8 @@ const compileEqualityCheck = (unit, serializedValue, negated) => {
|
|
|
4402
4354
|
if (Number.isNaN(unit)) return `${negated ? "!" : ""}Number.isNaN(data)`;
|
|
4403
4355
|
return `data ${negated ? "!" : "="}== ${serializedValue}`;
|
|
4404
4356
|
};
|
|
4405
|
-
|
|
4406
4357
|
//#endregion
|
|
4407
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
4358
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/structure/index.js
|
|
4408
4359
|
const implementation$3 = implementNode({
|
|
4409
4360
|
kind: "index",
|
|
4410
4361
|
hasAssociatedError: false,
|
|
@@ -4412,8 +4363,8 @@ const implementation$3 = implementNode({
|
|
|
4412
4363
|
keys: {
|
|
4413
4364
|
signature: {
|
|
4414
4365
|
child: true,
|
|
4415
|
-
parse: (schema
|
|
4416
|
-
const key = ctx.$.parseSchema(schema
|
|
4366
|
+
parse: (schema, ctx) => {
|
|
4367
|
+
const key = ctx.$.parseSchema(schema);
|
|
4417
4368
|
if (!key.extends($ark.intrinsic.key)) return throwParseError(writeInvalidPropertyKeyMessage(key.expression));
|
|
4418
4369
|
const enumerableBranches = key.branches.filter((b) => b.hasKind("unit"));
|
|
4419
4370
|
if (enumerableBranches.length) return throwParseError(writeEnumerableIndexBranches(enumerableBranches.map((b) => printable(b.unit))));
|
|
@@ -4422,18 +4373,18 @@ const implementation$3 = implementNode({
|
|
|
4422
4373
|
},
|
|
4423
4374
|
value: {
|
|
4424
4375
|
child: true,
|
|
4425
|
-
parse: (schema
|
|
4376
|
+
parse: (schema, ctx) => ctx.$.parseSchema(schema)
|
|
4426
4377
|
}
|
|
4427
4378
|
},
|
|
4428
|
-
normalize: (schema
|
|
4429
|
-
defaults: { description: (node
|
|
4379
|
+
normalize: (schema) => schema,
|
|
4380
|
+
defaults: { description: (node) => `[${node.signature.expression}]: ${node.value.description}` },
|
|
4430
4381
|
intersections: { index: (l, r, ctx) => {
|
|
4431
4382
|
if (l.signature.equals(r.signature)) {
|
|
4432
4383
|
const valueIntersection = intersectOrPipeNodes(l.value, r.value, ctx);
|
|
4433
|
-
const value
|
|
4384
|
+
const value = valueIntersection instanceof Disjoint ? $ark.intrinsic.never.internal : valueIntersection;
|
|
4434
4385
|
return ctx.$.node("index", {
|
|
4435
4386
|
signature: l.signature,
|
|
4436
|
-
value
|
|
4387
|
+
value
|
|
4437
4388
|
});
|
|
4438
4389
|
}
|
|
4439
4390
|
if (l.signature.extends(r.signature) && l.value.subsumes(r.value)) return r;
|
|
@@ -4466,9 +4417,8 @@ const Index = {
|
|
|
4466
4417
|
};
|
|
4467
4418
|
const writeEnumerableIndexBranches = (keys) => `Index keys ${keys.join(", ")} should be specified as named props.`;
|
|
4468
4419
|
const writeInvalidPropertyKeyMessage = (indexSchema) => `Indexed key definition '${indexSchema}' must be a string or symbol`;
|
|
4469
|
-
|
|
4470
4420
|
//#endregion
|
|
4471
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
4421
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/structure/required.js
|
|
4472
4422
|
const implementation$2 = implementNode({
|
|
4473
4423
|
kind: "required",
|
|
4474
4424
|
hasAssociatedError: true,
|
|
@@ -4477,12 +4427,12 @@ const implementation$2 = implementNode({
|
|
|
4477
4427
|
key: {},
|
|
4478
4428
|
value: {
|
|
4479
4429
|
child: true,
|
|
4480
|
-
parse: (schema
|
|
4430
|
+
parse: (schema, ctx) => ctx.$.parseSchema(schema)
|
|
4481
4431
|
}
|
|
4482
4432
|
},
|
|
4483
|
-
normalize: (schema
|
|
4433
|
+
normalize: (schema) => schema,
|
|
4484
4434
|
defaults: {
|
|
4485
|
-
description: (node
|
|
4435
|
+
description: (node) => `${node.compiledKey}: ${node.value.description}`,
|
|
4486
4436
|
expected: (ctx) => ctx.missingValueDescription,
|
|
4487
4437
|
actual: () => "missing"
|
|
4488
4438
|
},
|
|
@@ -4505,9 +4455,8 @@ const Required$1 = {
|
|
|
4505
4455
|
implementation: implementation$2,
|
|
4506
4456
|
Node: RequiredNode
|
|
4507
4457
|
};
|
|
4508
|
-
|
|
4509
4458
|
//#endregion
|
|
4510
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
4459
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/structure/sequence.js
|
|
4511
4460
|
const implementation$1 = implementNode({
|
|
4512
4461
|
kind: "sequence",
|
|
4513
4462
|
hasAssociatedError: false,
|
|
@@ -4515,16 +4464,16 @@ const implementation$1 = implementNode({
|
|
|
4515
4464
|
keys: {
|
|
4516
4465
|
prefix: {
|
|
4517
4466
|
child: true,
|
|
4518
|
-
parse: (schema
|
|
4519
|
-
if (schema
|
|
4520
|
-
return schema
|
|
4467
|
+
parse: (schema, ctx) => {
|
|
4468
|
+
if (schema.length === 0) return void 0;
|
|
4469
|
+
return schema.map((element) => ctx.$.parseSchema(element));
|
|
4521
4470
|
}
|
|
4522
4471
|
},
|
|
4523
4472
|
optionals: {
|
|
4524
4473
|
child: true,
|
|
4525
|
-
parse: (schema
|
|
4526
|
-
if (schema
|
|
4527
|
-
return schema
|
|
4474
|
+
parse: (schema, ctx) => {
|
|
4475
|
+
if (schema.length === 0) return void 0;
|
|
4476
|
+
return schema.map((element) => ctx.$.parseSchema(element));
|
|
4528
4477
|
}
|
|
4529
4478
|
},
|
|
4530
4479
|
defaultables: {
|
|
@@ -4532,9 +4481,9 @@ const implementation$1 = implementNode({
|
|
|
4532
4481
|
parse: (defaultables, ctx) => {
|
|
4533
4482
|
if (defaultables.length === 0) return void 0;
|
|
4534
4483
|
return defaultables.map((element) => {
|
|
4535
|
-
const node
|
|
4536
|
-
assertDefaultValueAssignability(node
|
|
4537
|
-
return [node
|
|
4484
|
+
const node = ctx.$.parseSchema(element[0]);
|
|
4485
|
+
assertDefaultValueAssignability(node, element[1], null);
|
|
4486
|
+
return [node, element[1]];
|
|
4538
4487
|
});
|
|
4539
4488
|
},
|
|
4540
4489
|
serialize: (defaults) => defaults.map((element) => [element[0].collapsibleJson, defaultValueSerializer(element[1])]),
|
|
@@ -4548,28 +4497,28 @@ const implementation$1 = implementNode({
|
|
|
4548
4497
|
},
|
|
4549
4498
|
variadic: {
|
|
4550
4499
|
child: true,
|
|
4551
|
-
parse: (schema
|
|
4500
|
+
parse: (schema, ctx) => ctx.$.parseSchema(schema, ctx)
|
|
4552
4501
|
},
|
|
4553
4502
|
minVariadicLength: { parse: (min) => min === 0 ? void 0 : min },
|
|
4554
4503
|
postfix: {
|
|
4555
4504
|
child: true,
|
|
4556
|
-
parse: (schema
|
|
4557
|
-
if (schema
|
|
4558
|
-
return schema
|
|
4505
|
+
parse: (schema, ctx) => {
|
|
4506
|
+
if (schema.length === 0) return void 0;
|
|
4507
|
+
return schema.map((element) => ctx.$.parseSchema(element));
|
|
4559
4508
|
}
|
|
4560
4509
|
}
|
|
4561
4510
|
},
|
|
4562
|
-
normalize: (schema
|
|
4563
|
-
if (typeof schema
|
|
4564
|
-
if ("variadic" in schema
|
|
4565
|
-
if (schema
|
|
4566
|
-
if (!schema
|
|
4567
|
-
if (schema
|
|
4511
|
+
normalize: (schema) => {
|
|
4512
|
+
if (typeof schema === "string") return { variadic: schema };
|
|
4513
|
+
if ("variadic" in schema || "prefix" in schema || "defaultables" in schema || "optionals" in schema || "postfix" in schema || "minVariadicLength" in schema) {
|
|
4514
|
+
if (schema.postfix?.length) {
|
|
4515
|
+
if (!schema.variadic) return throwParseError(postfixWithoutVariadicMessage);
|
|
4516
|
+
if (schema.optionals?.length || schema.defaultables?.length) return throwParseError(postfixAfterOptionalOrDefaultableMessage);
|
|
4568
4517
|
}
|
|
4569
|
-
if (schema
|
|
4570
|
-
return schema
|
|
4518
|
+
if (schema.minVariadicLength && !schema.variadic) return throwParseError("minVariadicLength may not be specified without a variadic element");
|
|
4519
|
+
return schema;
|
|
4571
4520
|
}
|
|
4572
|
-
return { variadic: schema
|
|
4521
|
+
return { variadic: schema };
|
|
4573
4522
|
},
|
|
4574
4523
|
reduce: (raw, $) => {
|
|
4575
4524
|
let minVariadicLength = raw.minVariadicLength ?? 0;
|
|
@@ -4597,9 +4546,9 @@ const implementation$1 = implementNode({
|
|
|
4597
4546
|
minVariadicLength
|
|
4598
4547
|
}, { prereduced: true });
|
|
4599
4548
|
},
|
|
4600
|
-
defaults: { description: (node
|
|
4601
|
-
if (node
|
|
4602
|
-
return `[${node
|
|
4549
|
+
defaults: { description: (node) => {
|
|
4550
|
+
if (node.isVariadicOnly) return `${node.variadic.nestableExpression}[]`;
|
|
4551
|
+
return `[${node.tuple.map((element) => element.kind === "defaultables" ? `${element.node.nestableExpression} = ${printable(element.default)}` : element.kind === "optionals" ? `${element.node.nestableExpression}?` : element.kind === "variadic" ? `...${element.node.nestableExpression}[]` : element.node.expression).join(", ")}]`;
|
|
4603
4552
|
} },
|
|
4604
4553
|
intersections: { sequence: (l, r, ctx) => {
|
|
4605
4554
|
const rootState = _intersectSequences({
|
|
@@ -4648,6 +4597,21 @@ var SequenceNode = class extends BaseConstraint {
|
|
|
4648
4597
|
impliedSiblings = this.minLengthNode ? this.maxLengthNode ? [this.minLengthNode, this.maxLengthNode] : [this.minLengthNode] : this.maxLengthNode ? [this.maxLengthNode] : [];
|
|
4649
4598
|
defaultValueMorphs = getDefaultableMorphs(this);
|
|
4650
4599
|
defaultValueMorphsReference = this.defaultValueMorphs.length ? registeredReference(this.defaultValueMorphs) : void 0;
|
|
4600
|
+
optionalize() {
|
|
4601
|
+
const { prefix, defaultables, ...inner } = this.inner;
|
|
4602
|
+
if (!prefix) return this;
|
|
4603
|
+
return this.$.node("sequence", {
|
|
4604
|
+
...inner,
|
|
4605
|
+
optionals: conflatenate(prefix, this.defaultablesAndOptionals)
|
|
4606
|
+
});
|
|
4607
|
+
}
|
|
4608
|
+
require() {
|
|
4609
|
+
const { defaultables, optionals, ...inner } = this.inner;
|
|
4610
|
+
return this.$.node("sequence", {
|
|
4611
|
+
...inner,
|
|
4612
|
+
prefix: conflatenate(this.prefix, this.defaultablesAndOptionals)
|
|
4613
|
+
});
|
|
4614
|
+
}
|
|
4651
4615
|
elementAtIndex(data, index) {
|
|
4652
4616
|
if (index < this.prevariadic.length) return this.tuple[index];
|
|
4653
4617
|
const firstPostfixIndex = data.length - this.postfixLength;
|
|
@@ -4665,25 +4629,38 @@ var SequenceNode = class extends BaseConstraint {
|
|
|
4665
4629
|
return true;
|
|
4666
4630
|
};
|
|
4667
4631
|
traverseApply = (data, ctx) => {
|
|
4632
|
+
const errorCount = ctx.currentErrorCount;
|
|
4668
4633
|
let i = 0;
|
|
4669
|
-
for (; i < data.length; i++)
|
|
4634
|
+
for (; i < data.length; i++) {
|
|
4635
|
+
traverseKey(i, () => this.elementAtIndex(data, i).node.traverseApply(data[i], ctx), ctx);
|
|
4636
|
+
if (ctx.failFast && ctx.currentErrorCount > errorCount) return;
|
|
4637
|
+
}
|
|
4670
4638
|
};
|
|
4671
4639
|
get element() {
|
|
4672
4640
|
return this.cacheGetter("element", this.$.node("union", this.children));
|
|
4673
4641
|
}
|
|
4674
4642
|
compile(js) {
|
|
4675
|
-
if (
|
|
4676
|
-
for (const [i, node
|
|
4643
|
+
if (js.traversalKind === "Apply") js.initializeErrorCount();
|
|
4644
|
+
if (this.prefix) for (const [i, node] of this.prefix.entries()) {
|
|
4645
|
+
js.traverseKey(`${i}`, `data[${i}]`, node);
|
|
4646
|
+
if (js.traversalKind === "Apply") js.returnIfFailFast();
|
|
4647
|
+
}
|
|
4648
|
+
for (const [i, node] of this.defaultablesAndOptionals.entries()) {
|
|
4677
4649
|
const dataIndex = `${i + this.prefixLength}`;
|
|
4678
4650
|
js.if(`${dataIndex} >= data.length`, () => js.traversalKind === "Allows" ? js.return(true) : js.return());
|
|
4679
|
-
js.traverseKey(dataIndex, `data[${dataIndex}]`, node
|
|
4651
|
+
js.traverseKey(dataIndex, `data[${dataIndex}]`, node);
|
|
4652
|
+
if (js.traversalKind === "Apply") js.returnIfFailFast();
|
|
4680
4653
|
}
|
|
4681
4654
|
if (this.variadic) {
|
|
4682
4655
|
if (this.postfix) js.const("firstPostfixIndex", `data.length${this.postfix ? `- ${this.postfix.length}` : ""}`);
|
|
4683
|
-
js.for(`i < ${this.postfix ? "firstPostfixIndex" : "data.length"}`, () =>
|
|
4684
|
-
|
|
4656
|
+
js.for(`i < ${this.postfix ? "firstPostfixIndex" : "data.length"}`, () => {
|
|
4657
|
+
js.traverseKey("i", "data[i]", this.variadic);
|
|
4658
|
+
return js.traversalKind === "Apply" ? js.returnIfFailFast() : js;
|
|
4659
|
+
}, this.prevariadic.length);
|
|
4660
|
+
if (this.postfix) for (const [i, node] of this.postfix.entries()) {
|
|
4685
4661
|
const keyExpression = `firstPostfixIndex + ${i}`;
|
|
4686
|
-
js.traverseKey(keyExpression, `data[${keyExpression}]`, node
|
|
4662
|
+
js.traverseKey(keyExpression, `data[${keyExpression}]`, node);
|
|
4663
|
+
if (js.traversalKind === "Apply") js.returnIfFailFast();
|
|
4687
4664
|
}
|
|
4688
4665
|
}
|
|
4689
4666
|
if (js.traversalKind === "Allows") js.return(true);
|
|
@@ -4695,54 +4672,54 @@ var SequenceNode = class extends BaseConstraint {
|
|
|
4695
4672
|
return result;
|
|
4696
4673
|
}
|
|
4697
4674
|
expression = this.description;
|
|
4698
|
-
reduceJsonSchema(schema
|
|
4675
|
+
reduceJsonSchema(schema, ctx) {
|
|
4699
4676
|
const isDraft07 = ctx.target === "draft-07";
|
|
4700
4677
|
if (this.prevariadic.length) {
|
|
4701
4678
|
const prefixSchemas = this.prevariadic.map((el) => {
|
|
4702
4679
|
const valueSchema = el.node.toJsonSchemaRecurse(ctx);
|
|
4703
4680
|
if (el.kind === "defaultables") {
|
|
4704
|
-
const value
|
|
4705
|
-
valueSchema.default = $ark.intrinsic.jsonData.allows(value
|
|
4681
|
+
const value = typeof el.default === "function" ? el.default() : el.default;
|
|
4682
|
+
valueSchema.default = $ark.intrinsic.jsonData.allows(value) ? value : ctx.fallback.defaultValue({
|
|
4706
4683
|
code: "defaultValue",
|
|
4707
4684
|
base: valueSchema,
|
|
4708
|
-
value
|
|
4685
|
+
value
|
|
4709
4686
|
});
|
|
4710
4687
|
}
|
|
4711
4688
|
return valueSchema;
|
|
4712
4689
|
});
|
|
4713
|
-
if (isDraft07) schema
|
|
4714
|
-
else schema
|
|
4690
|
+
if (isDraft07) schema.items = prefixSchemas;
|
|
4691
|
+
else schema.prefixItems = prefixSchemas;
|
|
4715
4692
|
}
|
|
4716
|
-
if (this.minLength) schema
|
|
4693
|
+
if (this.minLength) schema.minItems = this.minLength;
|
|
4717
4694
|
if (this.variadic) {
|
|
4718
4695
|
const variadicItemSchema = this.variadic.toJsonSchemaRecurse(ctx);
|
|
4719
|
-
if (isDraft07 && this.prevariadic.length) schema
|
|
4720
|
-
else schema
|
|
4721
|
-
if (this.maxLength) schema
|
|
4696
|
+
if (isDraft07 && this.prevariadic.length) schema.additionalItems = variadicItemSchema;
|
|
4697
|
+
else schema.items = variadicItemSchema;
|
|
4698
|
+
if (this.maxLength) schema.maxItems = this.maxLength;
|
|
4722
4699
|
if (this.postfix) {
|
|
4723
4700
|
const elements = this.postfix.map((el) => el.toJsonSchemaRecurse(ctx));
|
|
4724
|
-
schema
|
|
4701
|
+
schema = ctx.fallback.arrayPostfix({
|
|
4725
4702
|
code: "arrayPostfix",
|
|
4726
|
-
base: schema
|
|
4703
|
+
base: schema,
|
|
4727
4704
|
elements
|
|
4728
4705
|
});
|
|
4729
4706
|
}
|
|
4730
4707
|
} else {
|
|
4731
|
-
if (isDraft07) schema
|
|
4732
|
-
else schema
|
|
4733
|
-
delete schema
|
|
4708
|
+
if (isDraft07) schema.additionalItems = false;
|
|
4709
|
+
else schema.items = false;
|
|
4710
|
+
delete schema.maxItems;
|
|
4734
4711
|
}
|
|
4735
|
-
return schema
|
|
4712
|
+
return schema;
|
|
4736
4713
|
}
|
|
4737
4714
|
};
|
|
4738
4715
|
const defaultableMorphsCache$1 = {};
|
|
4739
|
-
const getDefaultableMorphs = (node
|
|
4740
|
-
if (!node
|
|
4716
|
+
const getDefaultableMorphs = (node) => {
|
|
4717
|
+
if (!node.defaultables) return [];
|
|
4741
4718
|
const morphs = [];
|
|
4742
4719
|
let cacheKey = "[";
|
|
4743
|
-
const lastDefaultableIndex = node
|
|
4744
|
-
for (let i = node
|
|
4745
|
-
const [elementNode, defaultValue] = node
|
|
4720
|
+
const lastDefaultableIndex = node.prefixLength + node.defaultablesLength - 1;
|
|
4721
|
+
for (let i = node.prefixLength; i <= lastDefaultableIndex; i++) {
|
|
4722
|
+
const [elementNode, defaultValue] = node.defaultables[i - node.prefixLength];
|
|
4746
4723
|
morphs.push(computeDefaultValueMorph(i, elementNode, defaultValue));
|
|
4747
4724
|
cacheKey += `${i}: ${elementNode.id} = ${defaultValueSerializer(defaultValue)}, `;
|
|
4748
4725
|
}
|
|
@@ -4755,26 +4732,26 @@ const Sequence = {
|
|
|
4755
4732
|
};
|
|
4756
4733
|
const sequenceInnerToTuple = (inner) => {
|
|
4757
4734
|
const tuple = [];
|
|
4758
|
-
if (inner.prefix) for (const node
|
|
4735
|
+
if (inner.prefix) for (const node of inner.prefix) tuple.push({
|
|
4759
4736
|
kind: "prefix",
|
|
4760
|
-
node
|
|
4737
|
+
node
|
|
4761
4738
|
});
|
|
4762
|
-
if (inner.defaultables) for (const [node
|
|
4739
|
+
if (inner.defaultables) for (const [node, defaultValue] of inner.defaultables) tuple.push({
|
|
4763
4740
|
kind: "defaultables",
|
|
4764
|
-
node
|
|
4741
|
+
node,
|
|
4765
4742
|
default: defaultValue
|
|
4766
4743
|
});
|
|
4767
|
-
if (inner.optionals) for (const node
|
|
4744
|
+
if (inner.optionals) for (const node of inner.optionals) tuple.push({
|
|
4768
4745
|
kind: "optionals",
|
|
4769
|
-
node
|
|
4746
|
+
node
|
|
4770
4747
|
});
|
|
4771
4748
|
if (inner.variadic) tuple.push({
|
|
4772
4749
|
kind: "variadic",
|
|
4773
4750
|
node: inner.variadic
|
|
4774
4751
|
});
|
|
4775
|
-
if (inner.postfix) for (const node
|
|
4752
|
+
if (inner.postfix) for (const node of inner.postfix) tuple.push({
|
|
4776
4753
|
kind: "postfix",
|
|
4777
|
-
node
|
|
4754
|
+
node
|
|
4778
4755
|
});
|
|
4779
4756
|
return tuple;
|
|
4780
4757
|
};
|
|
@@ -4815,26 +4792,27 @@ const _intersectSequences = (s) => {
|
|
|
4815
4792
|
if (postfixBranchResult.disjoint.length === 0) s.fixedVariants.push(postfixBranchResult);
|
|
4816
4793
|
}
|
|
4817
4794
|
const result = intersectOrPipeNodes(lHead.node, rHead.node, s.ctx);
|
|
4818
|
-
if (result instanceof Disjoint)
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4795
|
+
if (result instanceof Disjoint) {
|
|
4796
|
+
if (kind === "prefix" || kind === "postfix") {
|
|
4797
|
+
s.disjoint.push(...result.withPrefixKey(kind === "prefix" ? s.result.length : `-${lTail.length + 1}`, elementIsRequired(lHead) && elementIsRequired(rHead) ? "required" : "optional"));
|
|
4798
|
+
s.result = [...s.result, {
|
|
4799
|
+
kind,
|
|
4800
|
+
node: $ark.intrinsic.never.internal
|
|
4801
|
+
}];
|
|
4802
|
+
} else if (kind === "optionals" || kind === "defaultables") return s;
|
|
4803
|
+
else return _intersectSequences({
|
|
4804
|
+
...s,
|
|
4805
|
+
fixedVariants: [],
|
|
4806
|
+
l: lTail.map((element) => ({
|
|
4807
|
+
...element,
|
|
4808
|
+
kind: "prefix"
|
|
4809
|
+
})),
|
|
4810
|
+
r: lTail.map((element) => ({
|
|
4811
|
+
...element,
|
|
4812
|
+
kind: "prefix"
|
|
4813
|
+
}))
|
|
4814
|
+
});
|
|
4815
|
+
} else if (kind === "defaultables") {
|
|
4838
4816
|
if (lHead.kind === "defaultables" && rHead.kind === "defaultables" && lHead.default !== rHead.default) throwParseError(writeDefaultIntersectionMessage(lHead.default, rHead.default));
|
|
4839
4817
|
s.result = [...s.result, {
|
|
4840
4818
|
kind,
|
|
@@ -4852,48 +4830,47 @@ const _intersectSequences = (s) => {
|
|
|
4852
4830
|
return _intersectSequences(s);
|
|
4853
4831
|
};
|
|
4854
4832
|
const elementIsRequired = (el) => el.kind === "prefix" || el.kind === "postfix";
|
|
4855
|
-
|
|
4856
4833
|
//#endregion
|
|
4857
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
4858
|
-
const createStructuralWriter = (childStringProp) => (node
|
|
4859
|
-
if (node
|
|
4860
|
-
const parts = node
|
|
4861
|
-
for (const prop of node
|
|
4862
|
-
if (node
|
|
4834
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/structure/structure.js
|
|
4835
|
+
const createStructuralWriter = (childStringProp) => (node) => {
|
|
4836
|
+
if (node.props.length || node.index) {
|
|
4837
|
+
const parts = node.index?.map((index) => index[childStringProp]) ?? [];
|
|
4838
|
+
for (const prop of node.props) parts.push(prop[childStringProp]);
|
|
4839
|
+
if (node.undeclared) parts.push(`+ (undeclared): ${node.undeclared}`);
|
|
4863
4840
|
const objectLiteralDescription = `{ ${parts.join(", ")} }`;
|
|
4864
|
-
return node
|
|
4841
|
+
return node.sequence ? `${objectLiteralDescription} & ${node.sequence.description}` : objectLiteralDescription;
|
|
4865
4842
|
}
|
|
4866
|
-
return node
|
|
4843
|
+
return node.sequence?.description ?? "{}";
|
|
4867
4844
|
};
|
|
4868
4845
|
const structuralDescription = createStructuralWriter("description");
|
|
4869
4846
|
const structuralExpression = createStructuralWriter("expression");
|
|
4870
4847
|
const intersectPropsAndIndex = (l, r, $) => {
|
|
4871
4848
|
const kind = l.required ? "required" : "optional";
|
|
4872
4849
|
if (!r.signature.allows(l.key)) return null;
|
|
4873
|
-
const value
|
|
4874
|
-
if (value
|
|
4850
|
+
const value = intersectNodesRoot(l.value, r.value, $);
|
|
4851
|
+
if (value instanceof Disjoint) return kind === "optional" ? $.node("optional", {
|
|
4875
4852
|
key: l.key,
|
|
4876
4853
|
value: $ark.intrinsic.never.internal
|
|
4877
|
-
}) : value
|
|
4854
|
+
}) : value.withPrefixKey(l.key, l.kind);
|
|
4878
4855
|
return null;
|
|
4879
4856
|
};
|
|
4880
4857
|
const implementation = implementNode({
|
|
4881
4858
|
kind: "structure",
|
|
4882
4859
|
hasAssociatedError: false,
|
|
4883
|
-
normalize: (schema
|
|
4884
|
-
applyConfig: (schema
|
|
4885
|
-
if (!schema
|
|
4886
|
-
...schema
|
|
4860
|
+
normalize: (schema) => schema,
|
|
4861
|
+
applyConfig: (schema, config) => {
|
|
4862
|
+
if (!schema.undeclared && config.onUndeclaredKey !== "ignore") return {
|
|
4863
|
+
...schema,
|
|
4887
4864
|
undeclared: config.onUndeclaredKey
|
|
4888
4865
|
};
|
|
4889
|
-
return schema
|
|
4866
|
+
return schema;
|
|
4890
4867
|
},
|
|
4891
4868
|
keys: {
|
|
4892
4869
|
required: {
|
|
4893
4870
|
child: true,
|
|
4894
4871
|
parse: constraintKeyParser("required"),
|
|
4895
4872
|
reduceIo: (ioKind, inner, nodes) => {
|
|
4896
|
-
inner.required = append(inner.required, nodes.map((node
|
|
4873
|
+
inner.required = append(inner.required, nodes.map((node) => ioKind === "in" ? node.rawIn : node.rawOut));
|
|
4897
4874
|
}
|
|
4898
4875
|
},
|
|
4899
4876
|
optional: {
|
|
@@ -4901,10 +4878,10 @@ const implementation = implementNode({
|
|
|
4901
4878
|
parse: constraintKeyParser("optional"),
|
|
4902
4879
|
reduceIo: (ioKind, inner, nodes) => {
|
|
4903
4880
|
if (ioKind === "in") {
|
|
4904
|
-
inner.optional = nodes.map((node
|
|
4881
|
+
inner.optional = nodes.map((node) => node.rawIn);
|
|
4905
4882
|
return;
|
|
4906
4883
|
}
|
|
4907
|
-
for (const node
|
|
4884
|
+
for (const node of nodes) inner[node.outProp.kind] = append(inner[node.outProp.kind], node.outProp.rawOut);
|
|
4908
4885
|
}
|
|
4909
4886
|
},
|
|
4910
4887
|
index: {
|
|
@@ -4917,8 +4894,8 @@ const implementation = implementNode({
|
|
|
4917
4894
|
},
|
|
4918
4895
|
undeclared: {
|
|
4919
4896
|
parse: (behavior) => behavior === "ignore" ? void 0 : behavior,
|
|
4920
|
-
reduceIo: (ioKind, inner, value
|
|
4921
|
-
if (value
|
|
4897
|
+
reduceIo: (ioKind, inner, value) => {
|
|
4898
|
+
if (value === "reject") {
|
|
4922
4899
|
inner.undeclared = "reject";
|
|
4923
4900
|
return;
|
|
4924
4901
|
}
|
|
@@ -4932,6 +4909,7 @@ const implementation = implementNode({
|
|
|
4932
4909
|
const lInner = { ...l.inner };
|
|
4933
4910
|
const rInner = { ...r.inner };
|
|
4934
4911
|
const disjointResult = new Disjoint();
|
|
4912
|
+
const derived = [];
|
|
4935
4913
|
if (l.undeclared) {
|
|
4936
4914
|
const lKey = l.keyof();
|
|
4937
4915
|
for (const k of r.requiredKeys) if (!lKey.allows(k)) disjointResult.add("presence", $ark.intrinsic.never.internal, r.propsByKey[k].value, { path: [k] });
|
|
@@ -4941,8 +4919,8 @@ const implementation = implementNode({
|
|
|
4941
4919
|
const indexOverlap = intersectNodesRoot(lKey, n.signature, ctx.$);
|
|
4942
4920
|
if (indexOverlap instanceof Disjoint) return [];
|
|
4943
4921
|
const normalized = normalizeIndex(indexOverlap, n.value, ctx.$);
|
|
4944
|
-
|
|
4945
|
-
|
|
4922
|
+
derived.push(...normalized.required ?? []);
|
|
4923
|
+
derived.push(...normalized.optional ?? []);
|
|
4946
4924
|
return normalized.index ?? [];
|
|
4947
4925
|
});
|
|
4948
4926
|
}
|
|
@@ -4955,8 +4933,8 @@ const implementation = implementNode({
|
|
|
4955
4933
|
const indexOverlap = intersectNodesRoot(rKey, n.signature, ctx.$);
|
|
4956
4934
|
if (indexOverlap instanceof Disjoint) return [];
|
|
4957
4935
|
const normalized = normalizeIndex(indexOverlap, n.value, ctx.$);
|
|
4958
|
-
|
|
4959
|
-
|
|
4936
|
+
derived.push(...normalized.required ?? []);
|
|
4937
|
+
derived.push(...normalized.optional ?? []);
|
|
4960
4938
|
return normalized.index ?? [];
|
|
4961
4939
|
});
|
|
4962
4940
|
}
|
|
@@ -4966,7 +4944,7 @@ const implementation = implementNode({
|
|
|
4966
4944
|
kind: "structure",
|
|
4967
4945
|
baseInner,
|
|
4968
4946
|
l: flattenConstraints(lInner),
|
|
4969
|
-
r: flattenConstraints(rInner),
|
|
4947
|
+
r: [...flattenConstraints(rInner), ...derived],
|
|
4970
4948
|
roots: [],
|
|
4971
4949
|
ctx
|
|
4972
4950
|
});
|
|
@@ -4976,7 +4954,7 @@ const implementation = implementNode({
|
|
|
4976
4954
|
} },
|
|
4977
4955
|
reduce: (inner, $) => {
|
|
4978
4956
|
if (!inner.required && !inner.optional) return;
|
|
4979
|
-
const seen =
|
|
4957
|
+
const seen = Object.create(null);
|
|
4980
4958
|
let updated = false;
|
|
4981
4959
|
const newOptionalProps = inner.optional ? [...inner.optional] : [];
|
|
4982
4960
|
if (inner.required) for (let i = 0; i < inner.required.length; i++) {
|
|
@@ -5011,11 +4989,11 @@ var StructureNode = class extends BaseConstraint {
|
|
|
5011
4989
|
impliedBasis = $ark.intrinsic.object.internal;
|
|
5012
4990
|
impliedSiblings = this.children.flatMap((n) => n.impliedSiblings ?? []);
|
|
5013
4991
|
props = conflatenate(this.required, this.optional);
|
|
5014
|
-
propsByKey = flatMorph(this.props, (i, node
|
|
4992
|
+
propsByKey = flatMorph(this.props, (i, node) => [node.key, node]);
|
|
5015
4993
|
propsByKeyReference = registeredReference(this.propsByKey);
|
|
5016
4994
|
expression = structuralExpression(this);
|
|
5017
|
-
requiredKeys = this.required?.map((node
|
|
5018
|
-
optionalKeys = this.optional?.map((node
|
|
4995
|
+
requiredKeys = this.required?.map((node) => node.key) ?? [];
|
|
4996
|
+
optionalKeys = this.optional?.map((node) => node.key) ?? [];
|
|
5019
4997
|
literalKeys = [...this.requiredKeys, ...this.optionalKeys];
|
|
5020
4998
|
_keyof;
|
|
5021
4999
|
keyof() {
|
|
@@ -5043,34 +5021,36 @@ var StructureNode = class extends BaseConstraint {
|
|
|
5043
5021
|
if (invalidKeys.length) return throwParseError(writeInvalidKeysMessage(this.expression, invalidKeys));
|
|
5044
5022
|
}
|
|
5045
5023
|
get(indexer, ...path) {
|
|
5046
|
-
let value
|
|
5024
|
+
let value;
|
|
5047
5025
|
let required = false;
|
|
5048
5026
|
const key = indexerToKey(indexer);
|
|
5049
5027
|
if ((typeof key === "string" || typeof key === "symbol") && this.propsByKey[key]) {
|
|
5050
|
-
value
|
|
5028
|
+
value = this.propsByKey[key].value;
|
|
5051
5029
|
required = this.propsByKey[key].required;
|
|
5052
5030
|
}
|
|
5053
5031
|
if (this.index) {
|
|
5054
|
-
for (const n of this.index) if (typeOrTermExtends(key, n.signature)) value
|
|
5032
|
+
for (const n of this.index) if (typeOrTermExtends(key, n.signature)) value = value?.and(n.value) ?? n.value;
|
|
5055
5033
|
}
|
|
5056
|
-
if (this.sequence && typeOrTermExtends(key, $ark.intrinsic.nonNegativeIntegerString))
|
|
5057
|
-
if (
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5034
|
+
if (this.sequence && typeOrTermExtends(key, $ark.intrinsic.nonNegativeIntegerString)) {
|
|
5035
|
+
if (hasArkKind(key, "root")) {
|
|
5036
|
+
if (this.sequence.variadic) value = value?.and(this.sequence.element) ?? this.sequence.element;
|
|
5037
|
+
} else {
|
|
5038
|
+
const index = Number.parseInt(key);
|
|
5039
|
+
if (index < this.sequence.prevariadic.length) {
|
|
5040
|
+
const fixedElement = this.sequence.prevariadic[index].node;
|
|
5041
|
+
value = value?.and(fixedElement) ?? fixedElement;
|
|
5042
|
+
required ||= index < this.sequence.prefixLength;
|
|
5043
|
+
} else if (this.sequence.variadic) {
|
|
5044
|
+
const nonFixedElement = this.$.node("union", this.sequence.variadicOrPostfix);
|
|
5045
|
+
value = value?.and(nonFixedElement) ?? nonFixedElement;
|
|
5046
|
+
}
|
|
5067
5047
|
}
|
|
5068
5048
|
}
|
|
5069
|
-
if (!value
|
|
5049
|
+
if (!value) {
|
|
5070
5050
|
if (this.sequence?.variadic && hasArkKind(key, "root") && key.extends($ark.intrinsic.number)) return throwParseError(writeNumberIndexMessage(key.expression, this.sequence.expression));
|
|
5071
5051
|
return throwParseError(writeInvalidKeysMessage(this.expression, [key]));
|
|
5072
5052
|
}
|
|
5073
|
-
const result = value
|
|
5053
|
+
const result = value.get(...path);
|
|
5074
5054
|
return required ? result : result.or($ark.intrinsic.undefined);
|
|
5075
5055
|
}
|
|
5076
5056
|
pick(...keys) {
|
|
@@ -5085,6 +5065,7 @@ var StructureNode = class extends BaseConstraint {
|
|
|
5085
5065
|
const { required, ...inner } = this.inner;
|
|
5086
5066
|
return this.$.node("structure", {
|
|
5087
5067
|
...inner,
|
|
5068
|
+
...inner.sequence ? { sequence: inner.sequence.optionalize() } : {},
|
|
5088
5069
|
optional: this.props.map((prop) => prop.hasKind("required") ? this.$.node("optional", prop.inner) : prop)
|
|
5089
5070
|
});
|
|
5090
5071
|
}
|
|
@@ -5092,6 +5073,7 @@ var StructureNode = class extends BaseConstraint {
|
|
|
5092
5073
|
const { optional, ...inner } = this.inner;
|
|
5093
5074
|
return this.$.node("structure", {
|
|
5094
5075
|
...inner,
|
|
5076
|
+
...inner.sequence ? { sequence: inner.sequence.require() } : {},
|
|
5095
5077
|
required: this.props.map((prop) => prop.hasKind("optional") ? {
|
|
5096
5078
|
key: prop.key,
|
|
5097
5079
|
value: prop.value
|
|
@@ -5129,11 +5111,13 @@ var StructureNode = class extends BaseConstraint {
|
|
|
5129
5111
|
this.props[i].traverseApply(data, ctx);
|
|
5130
5112
|
if (ctx.failFast && ctx.currentErrorCount > errorCount) return false;
|
|
5131
5113
|
}
|
|
5132
|
-
if (this.sequence)
|
|
5133
|
-
if (
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5114
|
+
if (this.sequence) {
|
|
5115
|
+
if (traversalKind === "Allows") {
|
|
5116
|
+
if (!this.sequence.traverseAllows(data, ctx)) return false;
|
|
5117
|
+
} else {
|
|
5118
|
+
this.sequence.traverseApply(data, ctx);
|
|
5119
|
+
if (ctx.failFast && ctx.currentErrorCount > errorCount) return false;
|
|
5120
|
+
}
|
|
5137
5121
|
}
|
|
5138
5122
|
if (this.index || this.undeclared === "reject") {
|
|
5139
5123
|
const keys = Object.keys(data);
|
|
@@ -5141,11 +5125,13 @@ var StructureNode = class extends BaseConstraint {
|
|
|
5141
5125
|
for (let i = 0; i < keys.length; i++) {
|
|
5142
5126
|
const k = keys[i];
|
|
5143
5127
|
if (this.index) {
|
|
5144
|
-
for (const node
|
|
5145
|
-
if (
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5128
|
+
for (const node of this.index) if (node.signature.traverseAllows(k, ctx)) {
|
|
5129
|
+
if (traversalKind === "Allows") {
|
|
5130
|
+
if (!traverseKey(k, () => node.value.traverseAllows(data[k], ctx), ctx)) return false;
|
|
5131
|
+
} else {
|
|
5132
|
+
traverseKey(k, () => node.value.traverseApply(data[k], ctx), ctx);
|
|
5133
|
+
if (ctx.failFast && ctx.currentErrorCount > errorCount) return false;
|
|
5134
|
+
}
|
|
5149
5135
|
}
|
|
5150
5136
|
}
|
|
5151
5137
|
if (this.undeclared === "reject" && !this.declaresKey(k)) {
|
|
@@ -5206,39 +5192,39 @@ var StructureNode = class extends BaseConstraint {
|
|
|
5206
5192
|
}
|
|
5207
5193
|
compileExhaustiveEntry(js) {
|
|
5208
5194
|
js.const("k", "keys[i]");
|
|
5209
|
-
if (this.index) for (const node
|
|
5195
|
+
if (this.index) for (const node of this.index) js.if(`${js.invoke(node.signature, {
|
|
5210
5196
|
arg: "k",
|
|
5211
5197
|
kind: "Allows"
|
|
5212
|
-
})}`, () => js.traverseKey("k", "data[k]", node
|
|
5198
|
+
})}`, () => js.traverseKey("k", "data[k]", node.value));
|
|
5213
5199
|
if (this.undeclared === "reject") js.if(`!(${this._compileDeclaresKey(js)})`, () => {
|
|
5214
5200
|
if (js.traversalKind === "Allows") return js.return(false);
|
|
5215
5201
|
return js.line(`ctx.errorFromNodeContext({ code: "predicate", expected: "removed", actual: "", relativePath: [k], meta: ${this.compiledMeta} })`).if("ctx.failFast", () => js.return());
|
|
5216
5202
|
});
|
|
5217
5203
|
return js;
|
|
5218
5204
|
}
|
|
5219
|
-
reduceJsonSchema(schema
|
|
5220
|
-
switch (schema
|
|
5221
|
-
case "object": return this.reduceObjectJsonSchema(schema
|
|
5205
|
+
reduceJsonSchema(schema, ctx) {
|
|
5206
|
+
switch (schema.type) {
|
|
5207
|
+
case "object": return this.reduceObjectJsonSchema(schema, ctx);
|
|
5222
5208
|
case "array":
|
|
5223
|
-
const arraySchema = this.sequence?.reduceJsonSchema(schema
|
|
5209
|
+
const arraySchema = this.sequence?.reduceJsonSchema(schema, ctx) ?? schema;
|
|
5224
5210
|
if (this.props.length || this.index) return ctx.fallback.arrayObject({
|
|
5225
5211
|
code: "arrayObject",
|
|
5226
5212
|
base: arraySchema,
|
|
5227
5213
|
object: this.reduceObjectJsonSchema({ type: "object" }, ctx)
|
|
5228
5214
|
});
|
|
5229
5215
|
return arraySchema;
|
|
5230
|
-
default: return ToJsonSchema.throwInternalOperandError("structure", schema
|
|
5216
|
+
default: return ToJsonSchema.throwInternalOperandError("structure", schema);
|
|
5231
5217
|
}
|
|
5232
5218
|
}
|
|
5233
|
-
reduceObjectJsonSchema(schema
|
|
5219
|
+
reduceObjectJsonSchema(schema, ctx) {
|
|
5234
5220
|
if (this.props.length) {
|
|
5235
|
-
schema
|
|
5221
|
+
schema.properties = {};
|
|
5236
5222
|
for (const prop of this.props) {
|
|
5237
5223
|
const valueSchema = prop.value.toJsonSchemaRecurse(ctx);
|
|
5238
5224
|
if (typeof prop.key === "symbol") {
|
|
5239
5225
|
ctx.fallback.symbolKey({
|
|
5240
5226
|
code: "symbolKey",
|
|
5241
|
-
base: schema
|
|
5227
|
+
base: schema,
|
|
5242
5228
|
key: prop.key,
|
|
5243
5229
|
value: valueSchema,
|
|
5244
5230
|
optional: prop.optional
|
|
@@ -5246,28 +5232,28 @@ var StructureNode = class extends BaseConstraint {
|
|
|
5246
5232
|
continue;
|
|
5247
5233
|
}
|
|
5248
5234
|
if (prop.hasDefault()) {
|
|
5249
|
-
const value
|
|
5250
|
-
valueSchema.default = $ark.intrinsic.jsonData.allows(value
|
|
5235
|
+
const value = typeof prop.default === "function" ? prop.default() : prop.default;
|
|
5236
|
+
valueSchema.default = $ark.intrinsic.jsonData.allows(value) ? value : ctx.fallback.defaultValue({
|
|
5251
5237
|
code: "defaultValue",
|
|
5252
5238
|
base: valueSchema,
|
|
5253
|
-
value
|
|
5239
|
+
value
|
|
5254
5240
|
});
|
|
5255
5241
|
}
|
|
5256
|
-
schema
|
|
5242
|
+
schema.properties[prop.key] = valueSchema;
|
|
5257
5243
|
}
|
|
5258
|
-
if (this.requiredKeys.length && schema
|
|
5244
|
+
if (this.requiredKeys.length && schema.properties) schema.required = this.requiredKeys.filter((k) => typeof k === "string" && k in schema.properties);
|
|
5259
5245
|
}
|
|
5260
5246
|
if (this.index) for (const index of this.index) {
|
|
5261
5247
|
const valueJsonSchema = index.value.toJsonSchemaRecurse(ctx);
|
|
5262
5248
|
if (index.signature.equals($ark.intrinsic.string)) {
|
|
5263
|
-
schema
|
|
5249
|
+
schema.additionalProperties = valueJsonSchema;
|
|
5264
5250
|
continue;
|
|
5265
5251
|
}
|
|
5266
5252
|
for (const keyBranch of index.signature.branches) {
|
|
5267
5253
|
if (!keyBranch.extends($ark.intrinsic.string)) {
|
|
5268
|
-
schema
|
|
5254
|
+
schema = ctx.fallback.symbolKey({
|
|
5269
5255
|
code: "symbolKey",
|
|
5270
|
-
base: schema
|
|
5256
|
+
base: schema,
|
|
5271
5257
|
key: null,
|
|
5272
5258
|
value: valueJsonSchema,
|
|
5273
5259
|
optional: false
|
|
@@ -5289,55 +5275,57 @@ var StructureNode = class extends BaseConstraint {
|
|
|
5289
5275
|
base: keySchemaWithPattern,
|
|
5290
5276
|
pattern: pattern[i].rule
|
|
5291
5277
|
});
|
|
5292
|
-
schema
|
|
5293
|
-
schema
|
|
5278
|
+
schema.patternProperties ??= {};
|
|
5279
|
+
schema.patternProperties[keySchemaWithPattern.pattern] = valueJsonSchema;
|
|
5294
5280
|
}
|
|
5295
5281
|
}
|
|
5296
5282
|
}
|
|
5297
|
-
if (this.undeclared && !schema
|
|
5298
|
-
return schema
|
|
5283
|
+
if (this.undeclared && !schema.additionalProperties) schema.additionalProperties = false;
|
|
5284
|
+
return schema;
|
|
5299
5285
|
}
|
|
5300
5286
|
};
|
|
5301
5287
|
const defaultableMorphsCache = {};
|
|
5302
|
-
const constructStructuralMorphCacheKey = (node
|
|
5288
|
+
const constructStructuralMorphCacheKey = (node) => {
|
|
5303
5289
|
let cacheKey = "";
|
|
5304
|
-
for (let i = 0; i < node
|
|
5305
|
-
if (node
|
|
5306
|
-
if (node
|
|
5290
|
+
for (let i = 0; i < node.defaultable.length; i++) cacheKey += node.defaultable[i].defaultValueMorphRef;
|
|
5291
|
+
if (node.sequence?.defaultValueMorphsReference) cacheKey += node.sequence?.defaultValueMorphsReference;
|
|
5292
|
+
if (node.undeclared === "delete") {
|
|
5307
5293
|
cacheKey += "delete !(";
|
|
5308
|
-
if (node
|
|
5309
|
-
if (node
|
|
5310
|
-
if (node
|
|
5311
|
-
if (node
|
|
5312
|
-
|
|
5294
|
+
if (node.required) for (const n of node.required) cacheKey += n.compiledKey + " | ";
|
|
5295
|
+
if (node.optional) for (const n of node.optional) cacheKey += n.compiledKey + " | ";
|
|
5296
|
+
if (node.index) for (const index of node.index) cacheKey += index.signature.id + " | ";
|
|
5297
|
+
if (node.sequence) {
|
|
5298
|
+
if (node.sequence.maxLength === null) cacheKey += intrinsic.nonNegativeIntegerString.id;
|
|
5299
|
+
else for (let i = 0; i < node.sequence.tuple.length; i++) cacheKey += i + " | ";
|
|
5300
|
+
}
|
|
5313
5301
|
cacheKey += ")";
|
|
5314
5302
|
}
|
|
5315
5303
|
return cacheKey;
|
|
5316
5304
|
};
|
|
5317
|
-
const getPossibleMorph = (node
|
|
5318
|
-
const cacheKey = constructStructuralMorphCacheKey(node
|
|
5305
|
+
const getPossibleMorph = (node) => {
|
|
5306
|
+
const cacheKey = constructStructuralMorphCacheKey(node);
|
|
5319
5307
|
if (!cacheKey) return void 0;
|
|
5320
5308
|
if (defaultableMorphsCache[cacheKey]) return defaultableMorphsCache[cacheKey];
|
|
5321
5309
|
const $arkStructuralMorph = (data, ctx) => {
|
|
5322
|
-
for (let i = 0; i < node
|
|
5323
|
-
if (node
|
|
5324
|
-
if (node
|
|
5325
|
-
for (const k in data) if (!node
|
|
5310
|
+
for (let i = 0; i < node.defaultable.length; i++) if (!(node.defaultable[i].key in data)) node.defaultable[i].defaultValueMorph(data, ctx);
|
|
5311
|
+
if (node.sequence?.defaultables) for (let i = data.length - node.sequence.prefixLength; i < node.sequence.defaultables.length; i++) node.sequence.defaultValueMorphs[i](data, ctx);
|
|
5312
|
+
if (node.undeclared === "delete") {
|
|
5313
|
+
for (const k in data) if (!node.declaresKey(k)) delete data[k];
|
|
5326
5314
|
}
|
|
5327
5315
|
return data;
|
|
5328
5316
|
};
|
|
5329
5317
|
return defaultableMorphsCache[cacheKey] = $arkStructuralMorph;
|
|
5330
5318
|
};
|
|
5331
|
-
const precompileMorphs = (js, node
|
|
5332
|
-
const args = `(data${node
|
|
5333
|
-
return js.block(`${args} => `, (js
|
|
5334
|
-
for (let i = 0; i < node
|
|
5335
|
-
const { serializedKey, defaultValueMorphRef } = node
|
|
5336
|
-
js
|
|
5319
|
+
const precompileMorphs = (js, node) => {
|
|
5320
|
+
const args = `(data${node.defaultable.some((node) => node.defaultValueMorph.length === 2) || node.sequence?.defaultValueMorphs.some((morph) => morph.length === 2) ? ", ctx" : ""})`;
|
|
5321
|
+
return js.block(`${args} => `, (js) => {
|
|
5322
|
+
for (let i = 0; i < node.defaultable.length; i++) {
|
|
5323
|
+
const { serializedKey, defaultValueMorphRef } = node.defaultable[i];
|
|
5324
|
+
js.if(`!(${serializedKey} in data)`, (js) => js.line(`${defaultValueMorphRef}${args}`));
|
|
5337
5325
|
}
|
|
5338
|
-
if (node
|
|
5339
|
-
if (node
|
|
5340
|
-
return js
|
|
5326
|
+
if (node.sequence?.defaultables) js.for(`i < ${node.sequence.defaultables.length}`, (js) => js.line(`${node.sequence.defaultValueMorphsReference}[i]${args}`), `data.length - ${node.sequence.prefixLength}`);
|
|
5327
|
+
if (node.undeclared === "delete") js.forIn("data", (js) => js.if(`!(${node._compileDeclaresKey(js)})`, (js) => js.line(`delete data[k]`)));
|
|
5328
|
+
return js.return("data");
|
|
5341
5329
|
});
|
|
5342
5330
|
};
|
|
5343
5331
|
const Structure = {
|
|
@@ -5351,32 +5339,31 @@ const indexerToKey = (indexable) => {
|
|
|
5351
5339
|
};
|
|
5352
5340
|
const writeNumberIndexMessage = (indexExpression, sequenceExpression) => `${indexExpression} is not allowed as an array index on ${sequenceExpression}. Use the 'nonNegativeIntegerString' keyword instead.`;
|
|
5353
5341
|
/** extract enumerable named props from an index signature */
|
|
5354
|
-
const normalizeIndex = (signature, value
|
|
5342
|
+
const normalizeIndex = (signature, value, $) => {
|
|
5355
5343
|
const [enumerableBranches, nonEnumerableBranches] = spliterate(signature.branches, (k) => k.hasKind("unit"));
|
|
5356
5344
|
if (!enumerableBranches.length) return { index: $.node("index", {
|
|
5357
5345
|
signature,
|
|
5358
|
-
value
|
|
5346
|
+
value
|
|
5359
5347
|
}) };
|
|
5360
5348
|
const normalized = {};
|
|
5361
5349
|
for (const n of enumerableBranches) {
|
|
5362
5350
|
const prop = $.node("required", {
|
|
5363
5351
|
key: n.unit,
|
|
5364
|
-
value
|
|
5352
|
+
value
|
|
5365
5353
|
});
|
|
5366
5354
|
normalized[prop.kind] = append(normalized[prop.kind], prop);
|
|
5367
5355
|
}
|
|
5368
5356
|
if (nonEnumerableBranches.length) normalized.index = $.node("index", {
|
|
5369
5357
|
signature: nonEnumerableBranches,
|
|
5370
|
-
value
|
|
5358
|
+
value
|
|
5371
5359
|
});
|
|
5372
5360
|
return normalized;
|
|
5373
5361
|
};
|
|
5374
5362
|
const typeKeyToString = (k) => hasArkKind(k, "root") ? k.expression : printable(k);
|
|
5375
5363
|
const writeInvalidKeysMessage = (o, keys) => `Key${keys.length === 1 ? "" : "s"} ${keys.map(typeKeyToString).join(", ")} ${keys.length === 1 ? "does" : "do"} not exist on ${o}`;
|
|
5376
5364
|
const writeDuplicateKeyMessage = (key) => `Duplicate key ${compileSerializedValue(key)}`;
|
|
5377
|
-
|
|
5378
5365
|
//#endregion
|
|
5379
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
5366
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/kinds.js
|
|
5380
5367
|
const nodeImplementationsByKind = {
|
|
5381
5368
|
...boundImplementationsByKind,
|
|
5382
5369
|
alias: Alias.implementation,
|
|
@@ -5395,7 +5382,7 @@ const nodeImplementationsByKind = {
|
|
|
5395
5382
|
sequence: Sequence.implementation,
|
|
5396
5383
|
structure: Structure.implementation
|
|
5397
5384
|
};
|
|
5398
|
-
$ark.defaultConfig = withAlphabetizedKeys(Object.assign(flatMorph(nodeImplementationsByKind, (kind, implementation
|
|
5385
|
+
$ark.defaultConfig = withAlphabetizedKeys(Object.assign(flatMorph(nodeImplementationsByKind, (kind, implementation) => [kind, implementation.defaults]), {
|
|
5399
5386
|
jitless: envHasCsp(),
|
|
5400
5387
|
clone: deepClone,
|
|
5401
5388
|
onUndeclaredKey: "ignore",
|
|
@@ -5425,52 +5412,50 @@ const nodeClassesByKind = {
|
|
|
5425
5412
|
sequence: Sequence.Node,
|
|
5426
5413
|
structure: Structure.Node
|
|
5427
5414
|
};
|
|
5428
|
-
|
|
5429
5415
|
//#endregion
|
|
5430
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
5416
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/module.js
|
|
5431
5417
|
var RootModule = class extends DynamicBase {
|
|
5432
5418
|
get [arkKind]() {
|
|
5433
5419
|
return "module";
|
|
5434
5420
|
}
|
|
5435
5421
|
};
|
|
5436
|
-
const bindModule = (module, $) => new RootModule(flatMorph(module, (alias, value
|
|
5437
|
-
|
|
5422
|
+
const bindModule = (module, $) => new RootModule(flatMorph(module, (alias, value) => [alias, hasArkKind(value, "module") ? bindModule(value, $) : $.bindReference(value)]));
|
|
5438
5423
|
//#endregion
|
|
5439
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
5440
|
-
const schemaBranchesOf = (schema
|
|
5424
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/scope.js
|
|
5425
|
+
const schemaBranchesOf = (schema) => isArray(schema) ? schema : "branches" in schema && isArray(schema.branches) ? schema.branches : void 0;
|
|
5441
5426
|
const throwMismatchedNodeRootError = (expected, actual) => throwParseError(`Node of kind ${actual} is not valid as a ${expected} definition`);
|
|
5442
5427
|
const writeDuplicateAliasError = (alias) => `#${alias} duplicates public alias ${alias}`;
|
|
5443
|
-
|
|
5428
|
+
let anonymousScopeCount = 0;
|
|
5444
5429
|
$ark.ambient ??= {};
|
|
5445
5430
|
let rawUnknownUnion;
|
|
5446
5431
|
const rootScopeFnName = "function $";
|
|
5447
5432
|
const precompile = (references) => bindPrecompilation(references, precompileReferences(references));
|
|
5448
|
-
const bindPrecompilation = (references, precompiler) => {
|
|
5433
|
+
const bindPrecompilation = (references, precompiler, owningScope) => {
|
|
5449
5434
|
const precompilation = precompiler.write(rootScopeFnName, 4);
|
|
5450
5435
|
const compiledTraversals = precompiler.compile()();
|
|
5451
|
-
for (const node
|
|
5452
|
-
if (node
|
|
5453
|
-
node
|
|
5454
|
-
if (node
|
|
5455
|
-
node
|
|
5456
|
-
if (compiledTraversals[`${node
|
|
5457
|
-
node
|
|
5436
|
+
for (const node of references) {
|
|
5437
|
+
if (node.precompilation && (!owningScope || node.$ !== owningScope)) continue;
|
|
5438
|
+
node.traverseAllows = compiledTraversals[`${node.id}Allows`].bind(compiledTraversals);
|
|
5439
|
+
if (node.isRoot() && !node.allowsRequiresContext) node.allows = node.traverseAllows;
|
|
5440
|
+
node.traverseApply = compiledTraversals[`${node.id}Apply`].bind(compiledTraversals);
|
|
5441
|
+
if (compiledTraversals[`${node.id}Optimistic`]) node.traverseOptimistic = compiledTraversals[`${node.id}Optimistic`].bind(compiledTraversals);
|
|
5442
|
+
node.precompilation = precompilation;
|
|
5458
5443
|
}
|
|
5459
5444
|
};
|
|
5460
|
-
const precompileReferences = (references) => new CompiledFunction().return(references.reduce((js, node
|
|
5445
|
+
const precompileReferences = (references) => new CompiledFunction().return(references.reduce((js, node) => {
|
|
5461
5446
|
const allowsCompiler = new NodeCompiler({ kind: "Allows" }).indent();
|
|
5462
|
-
node
|
|
5463
|
-
const allowsJs = allowsCompiler.write(`${node
|
|
5447
|
+
node.compile(allowsCompiler);
|
|
5448
|
+
const allowsJs = allowsCompiler.write(`${node.id}Allows`);
|
|
5464
5449
|
const applyCompiler = new NodeCompiler({ kind: "Apply" }).indent();
|
|
5465
|
-
node
|
|
5466
|
-
const result = `${js}${allowsJs},\n${applyCompiler.write(`${node
|
|
5467
|
-
if (!node
|
|
5450
|
+
node.compile(applyCompiler);
|
|
5451
|
+
const result = `${js}${allowsJs},\n${applyCompiler.write(`${node.id}Apply`)},\n`;
|
|
5452
|
+
if (!node.hasKind("union")) return result;
|
|
5468
5453
|
const optimisticCompiler = new NodeCompiler({
|
|
5469
5454
|
kind: "Allows",
|
|
5470
5455
|
optimistic: true
|
|
5471
5456
|
}).indent();
|
|
5472
|
-
node
|
|
5473
|
-
return `${result}${optimisticCompiler.write(`${node
|
|
5457
|
+
node.compile(optimisticCompiler);
|
|
5458
|
+
return `${result}${optimisticCompiler.write(`${node.id}Optimistic`)},\n`;
|
|
5474
5459
|
}, "{\n") + "}");
|
|
5475
5460
|
var BaseScope = class {
|
|
5476
5461
|
config;
|
|
@@ -5490,9 +5475,7 @@ var BaseScope = class {
|
|
|
5490
5475
|
constructor(def, config) {
|
|
5491
5476
|
this.config = mergeConfigs($ark.config, config);
|
|
5492
5477
|
this.resolvedConfig = mergeConfigs($ark.resolvedConfig, config);
|
|
5493
|
-
this.name = this.resolvedConfig.name ?? `anonymousScope${
|
|
5494
|
-
if (this.name in scopesByName) throwParseError(`A Scope already named ${this.name} already exists`);
|
|
5495
|
-
scopesByName[this.name] = this;
|
|
5478
|
+
this.name = this.resolvedConfig.name ?? `anonymousScope${anonymousScopeCount++}`;
|
|
5496
5479
|
const aliasEntries = Object.entries(def).map((entry) => this.preparseOwnAliasEntry(...entry));
|
|
5497
5480
|
for (const [k, v] of aliasEntries) {
|
|
5498
5481
|
let name = k;
|
|
@@ -5524,9 +5507,9 @@ var BaseScope = class {
|
|
|
5524
5507
|
this.nodesByHash[rawUnknownUnion.hash] = this.node("intersection", {}, { prereduced: true });
|
|
5525
5508
|
this.intrinsic = $ark.intrinsic ? flatMorph($ark.intrinsic, (k, v) => k.startsWith("json") ? [] : [k, this.bindReference(v)]) : {};
|
|
5526
5509
|
}
|
|
5527
|
-
cacheGetter(name, value
|
|
5528
|
-
Object.defineProperty(this, name, { value
|
|
5529
|
-
return value
|
|
5510
|
+
cacheGetter(name, value) {
|
|
5511
|
+
Object.defineProperty(this, name, { value });
|
|
5512
|
+
return value;
|
|
5530
5513
|
}
|
|
5531
5514
|
get internal() {
|
|
5532
5515
|
return this;
|
|
@@ -5545,7 +5528,7 @@ var BaseScope = class {
|
|
|
5545
5528
|
};
|
|
5546
5529
|
units = (values, opts) => {
|
|
5547
5530
|
const uniqueValues = [];
|
|
5548
|
-
for (const value
|
|
5531
|
+
for (const value of values) if (!uniqueValues.includes(value)) uniqueValues.push(value);
|
|
5549
5532
|
const branches = uniqueValues.map((unit) => this.node("unit", { unit }, opts));
|
|
5550
5533
|
return this.node("union", branches, {
|
|
5551
5534
|
...opts,
|
|
@@ -5554,34 +5537,34 @@ var BaseScope = class {
|
|
|
5554
5537
|
};
|
|
5555
5538
|
lazyResolutions = [];
|
|
5556
5539
|
lazilyResolve(resolve, syntheticAlias) {
|
|
5557
|
-
const node
|
|
5540
|
+
const node = this.node("alias", {
|
|
5558
5541
|
reference: syntheticAlias ?? "synthetic",
|
|
5559
5542
|
resolve
|
|
5560
5543
|
}, { prereduced: true });
|
|
5561
|
-
if (!this.resolved) this.lazyResolutions.push(node
|
|
5562
|
-
return node
|
|
5563
|
-
}
|
|
5564
|
-
schema = (schema
|
|
5565
|
-
parseSchema = (schema
|
|
5566
|
-
preparseNode(kinds, schema
|
|
5567
|
-
let kind = typeof kinds === "string" ? kinds : schemaKindOf(schema
|
|
5568
|
-
if (isNode(schema
|
|
5544
|
+
if (!this.resolved) this.lazyResolutions.push(node);
|
|
5545
|
+
return node;
|
|
5546
|
+
}
|
|
5547
|
+
schema = (schema, opts) => this.finalize(this.parseSchema(schema, opts));
|
|
5548
|
+
parseSchema = (schema, opts) => this.node(schemaKindOf(schema), schema, opts);
|
|
5549
|
+
preparseNode(kinds, schema, opts) {
|
|
5550
|
+
let kind = typeof kinds === "string" ? kinds : schemaKindOf(schema, kinds);
|
|
5551
|
+
if (isNode(schema) && schema.kind === kind) return schema;
|
|
5569
5552
|
if (kind === "alias" && !opts?.prereduced) {
|
|
5570
|
-
const { reference
|
|
5571
|
-
if (reference
|
|
5572
|
-
const resolution = this.resolveRoot(reference
|
|
5573
|
-
schema
|
|
5553
|
+
const { reference } = Alias.implementation.normalize(schema, this);
|
|
5554
|
+
if (reference.startsWith("$")) {
|
|
5555
|
+
const resolution = this.resolveRoot(reference.slice(1));
|
|
5556
|
+
schema = resolution;
|
|
5574
5557
|
kind = resolution.kind;
|
|
5575
5558
|
}
|
|
5576
|
-
} else if (kind === "union" && hasDomain(schema
|
|
5577
|
-
const branches = schemaBranchesOf(schema
|
|
5559
|
+
} else if (kind === "union" && hasDomain(schema, "object")) {
|
|
5560
|
+
const branches = schemaBranchesOf(schema);
|
|
5578
5561
|
if (branches?.length === 1) {
|
|
5579
|
-
schema
|
|
5580
|
-
kind = schemaKindOf(schema
|
|
5562
|
+
schema = branches[0];
|
|
5563
|
+
kind = schemaKindOf(schema);
|
|
5581
5564
|
}
|
|
5582
5565
|
}
|
|
5583
|
-
if (isNode(schema
|
|
5584
|
-
const normalizedSchema = nodeImplementationsByKind[kind].normalize?.(schema
|
|
5566
|
+
if (isNode(schema) && schema.kind === kind) return schema;
|
|
5567
|
+
const normalizedSchema = nodeImplementationsByKind[kind].normalize?.(schema, this) ?? schema;
|
|
5585
5568
|
if (isNode(normalizedSchema)) return normalizedSchema.kind === kind ? normalizedSchema : throwMismatchedNodeRootError(kind, normalizedSchema.kind);
|
|
5586
5569
|
return {
|
|
5587
5570
|
...opts,
|
|
@@ -5591,10 +5574,10 @@ var BaseScope = class {
|
|
|
5591
5574
|
prefix: opts.alias ?? kind
|
|
5592
5575
|
};
|
|
5593
5576
|
}
|
|
5594
|
-
bindReference(reference
|
|
5577
|
+
bindReference(reference) {
|
|
5595
5578
|
let bound;
|
|
5596
|
-
if (isNode(reference
|
|
5597
|
-
else bound = reference
|
|
5579
|
+
if (isNode(reference)) bound = reference.$ === this ? reference : new reference.constructor(reference.attachments, this);
|
|
5580
|
+
else bound = reference.$ === this ? reference : new GenericRoot(reference.params, reference.bodyDef, reference.$, this, reference.hkt);
|
|
5598
5581
|
if (!this.resolved) Object.assign(this.referencesById, bound.referencesById);
|
|
5599
5582
|
return bound;
|
|
5600
5583
|
}
|
|
@@ -5614,22 +5597,22 @@ var BaseScope = class {
|
|
|
5614
5597
|
return $ark.ambient;
|
|
5615
5598
|
}
|
|
5616
5599
|
maybeResolve(name) {
|
|
5617
|
-
const cached
|
|
5618
|
-
if (cached
|
|
5619
|
-
if (typeof cached
|
|
5620
|
-
const v = nodesByRegisteredId[cached
|
|
5600
|
+
const cached = this.resolutions[name];
|
|
5601
|
+
if (cached) {
|
|
5602
|
+
if (typeof cached !== "string") return this.bindReference(cached);
|
|
5603
|
+
const v = nodesByRegisteredId[cached];
|
|
5621
5604
|
if (hasArkKind(v, "root")) return this.resolutions[name] = v;
|
|
5622
5605
|
if (hasArkKind(v, "context")) {
|
|
5623
5606
|
if (v.phase === "resolving") return this.node("alias", { reference: `$${name}` }, { prereduced: true });
|
|
5624
5607
|
if (v.phase === "resolved") return throwInternalError(`Unexpected resolved context for was uncached by its scope: ${printable(v)}`);
|
|
5625
5608
|
v.phase = "resolving";
|
|
5626
|
-
const node
|
|
5609
|
+
const node = this.bindReference(this.parseOwnDefinitionFormat(v.def, v));
|
|
5627
5610
|
v.phase = "resolved";
|
|
5628
|
-
nodesByRegisteredId[node
|
|
5629
|
-
nodesByRegisteredId[v.id] = node
|
|
5630
|
-
return this.resolutions[name] = node
|
|
5611
|
+
nodesByRegisteredId[node.id] = node;
|
|
5612
|
+
nodesByRegisteredId[v.id] = node;
|
|
5613
|
+
return this.resolutions[name] = node;
|
|
5631
5614
|
}
|
|
5632
|
-
return throwInternalError(`Unexpected nodesById entry for ${cached
|
|
5615
|
+
return throwInternalError(`Unexpected nodesById entry for ${cached}: ${printable(v)}`);
|
|
5633
5616
|
}
|
|
5634
5617
|
let def = this.aliases[name] ?? this.ambient?.[name];
|
|
5635
5618
|
if (!def) return this.maybeResolveSubalias(name);
|
|
@@ -5654,7 +5637,7 @@ var BaseScope = class {
|
|
|
5654
5637
|
return new Traversal(root, this.resolvedConfig);
|
|
5655
5638
|
}
|
|
5656
5639
|
import(...names) {
|
|
5657
|
-
return new RootModule(flatMorph(this.export(...names), (alias, value
|
|
5640
|
+
return new RootModule(flatMorph(this.export(...names), (alias, value) => [`#${alias}`, value]));
|
|
5658
5641
|
}
|
|
5659
5642
|
precompilation;
|
|
5660
5643
|
_exportedResolutions;
|
|
@@ -5666,7 +5649,7 @@ var BaseScope = class {
|
|
|
5666
5649
|
const def = this.aliases[name];
|
|
5667
5650
|
this._exports[name] = hasArkKind(def, "module") ? bindModule(def, this) : bootstrapAliasReferences(this.maybeResolve(name));
|
|
5668
5651
|
}
|
|
5669
|
-
for (const node
|
|
5652
|
+
for (const node of this.lazyResolutions) node.resolution;
|
|
5670
5653
|
this._exportedResolutions = resolutionsOfModule(this, this._exports);
|
|
5671
5654
|
this._json = resolutionsToJson(this._exportedResolutions);
|
|
5672
5655
|
Object.assign(this.resolutions, this._exportedResolutions);
|
|
@@ -5674,11 +5657,12 @@ var BaseScope = class {
|
|
|
5674
5657
|
if (!this.resolvedConfig.jitless) {
|
|
5675
5658
|
const precompiler = precompileReferences(this.references);
|
|
5676
5659
|
this.precompilation = precompiler.write(rootScopeFnName, 4);
|
|
5677
|
-
bindPrecompilation(this.references, precompiler);
|
|
5660
|
+
bindPrecompilation(this.references, precompiler, this);
|
|
5678
5661
|
}
|
|
5679
5662
|
this.resolved = true;
|
|
5680
5663
|
}
|
|
5681
|
-
|
|
5664
|
+
const namesToExport = names.length ? names : this.exportedNames;
|
|
5665
|
+
return new RootModule(flatMorph(namesToExport, (_, name) => [name, this._exports[name]]));
|
|
5682
5666
|
}
|
|
5683
5667
|
resolve(name) {
|
|
5684
5668
|
return this.export()[name];
|
|
@@ -5686,35 +5670,40 @@ var BaseScope = class {
|
|
|
5686
5670
|
node = (kinds, nodeSchema, opts = {}) => {
|
|
5687
5671
|
const ctxOrNode = this.preparseNode(kinds, nodeSchema, opts);
|
|
5688
5672
|
if (isNode(ctxOrNode)) return this.bindReference(ctxOrNode);
|
|
5673
|
+
const hasPreassignedId = ctxOrNode.id !== void 0;
|
|
5689
5674
|
const ctx = this.createParseContext(ctxOrNode);
|
|
5690
|
-
const node
|
|
5691
|
-
const bound = this.bindReference(node
|
|
5692
|
-
|
|
5675
|
+
const node = parseNode(ctx);
|
|
5676
|
+
const bound = this.bindReference(node);
|
|
5677
|
+
if (!hasPreassignedId) releaseUnusedContextId(ctx.id, bound);
|
|
5678
|
+
else nodesByRegisteredId[ctx.id] = bound;
|
|
5679
|
+
return bound;
|
|
5693
5680
|
};
|
|
5694
5681
|
parse = (def, opts = {}) => this.finalize(this.parseDefinition(def, opts));
|
|
5695
5682
|
parseDefinition(def, opts = {}) {
|
|
5696
5683
|
if (hasArkKind(def, "root")) return this.bindReference(def);
|
|
5697
5684
|
const ctxInputOrNode = this.preparseOwnDefinitionFormat(def, opts);
|
|
5698
5685
|
if (hasArkKind(ctxInputOrNode, "root")) return this.bindReference(ctxInputOrNode);
|
|
5686
|
+
const hasPreassignedId = ctxInputOrNode.id !== void 0;
|
|
5699
5687
|
const ctx = this.createParseContext(ctxInputOrNode);
|
|
5700
|
-
|
|
5701
|
-
|
|
5702
|
-
if (
|
|
5703
|
-
nodesByRegisteredId[ctx.id] = node
|
|
5704
|
-
return node
|
|
5688
|
+
let node = this.bindReference(this.parseOwnDefinitionFormat(def, ctx));
|
|
5689
|
+
if (node.isCyclic) node = withId(node, ctx.id);
|
|
5690
|
+
if (!hasPreassignedId) releaseUnusedContextId(ctx.id, node);
|
|
5691
|
+
else nodesByRegisteredId[ctx.id] = node;
|
|
5692
|
+
return node;
|
|
5705
5693
|
}
|
|
5706
|
-
finalize(node
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5694
|
+
finalize(node) {
|
|
5695
|
+
if (node.isCyclic && hasUnresolvedContextAlias(node)) return node;
|
|
5696
|
+
bootstrapAliasReferences(node);
|
|
5697
|
+
if (!node.precompilation && !this.resolvedConfig.jitless) precompile(node.references);
|
|
5698
|
+
return node;
|
|
5710
5699
|
}
|
|
5711
5700
|
};
|
|
5712
5701
|
var SchemaScope = class extends BaseScope {
|
|
5713
5702
|
parseOwnDefinitionFormat(def, ctx) {
|
|
5714
5703
|
return parseNode(ctx);
|
|
5715
5704
|
}
|
|
5716
|
-
preparseOwnDefinitionFormat(schema
|
|
5717
|
-
return this.preparseNode(schemaKindOf(schema
|
|
5705
|
+
preparseOwnDefinitionFormat(schema, opts) {
|
|
5706
|
+
return this.preparseNode(schemaKindOf(schema), schema, opts);
|
|
5718
5707
|
}
|
|
5719
5708
|
preparseOwnAliasEntry(k, v) {
|
|
5720
5709
|
return [k, v];
|
|
@@ -5723,14 +5712,22 @@ var SchemaScope = class extends BaseScope {
|
|
|
5723
5712
|
return v;
|
|
5724
5713
|
}
|
|
5725
5714
|
};
|
|
5715
|
+
const releaseUnusedContextId = (id, node) => {
|
|
5716
|
+
if (node.id === id) nodesByRegisteredId[id] = node;
|
|
5717
|
+
else delete nodesByRegisteredId[id];
|
|
5718
|
+
};
|
|
5719
|
+
const hasUnresolvedContextAlias = (node) => node.references.some((ref) => ref.hasKind("alias") && ref.reference[0] !== "$" && hasArkKind(nodesByRegisteredId[ref.reference], "context"));
|
|
5726
5720
|
const bootstrapAliasReferences = (resolution) => {
|
|
5727
|
-
const aliases = resolution.references.filter((node
|
|
5721
|
+
const aliases = resolution.references.filter((node) => node.hasKind("alias"));
|
|
5728
5722
|
for (const aliasNode of aliases) {
|
|
5729
|
-
|
|
5730
|
-
for (const ref of resolution.references) if (aliasNode.id in ref.referencesById)
|
|
5723
|
+
addReferences(aliasNode.referencesById, aliasNode.resolution.referencesById);
|
|
5724
|
+
for (const ref of resolution.references) if (aliasNode.id in ref.referencesById) addReferences(ref.referencesById, aliasNode.referencesById);
|
|
5731
5725
|
}
|
|
5732
5726
|
return resolution;
|
|
5733
5727
|
};
|
|
5728
|
+
const addReferences = (base, references) => {
|
|
5729
|
+
for (const id in references) base[id] ??= references[id];
|
|
5730
|
+
};
|
|
5734
5731
|
const resolutionsToJson = (resolutions) => flatMorph(resolutions, (k, v) => [k, hasArkKind(v, "root") || hasArkKind(v, "generic") ? v.json : hasArkKind(v, "module") ? resolutionsToJson(v) : throwInternalError(`Unexpected resolution ${printable(v)}`)]);
|
|
5735
5732
|
const maybeResolveSubalias = (base, name) => {
|
|
5736
5733
|
const dotIndex = name.indexOf(".");
|
|
@@ -5753,7 +5750,8 @@ const resolutionsOfModule = ($, typeSet) => {
|
|
|
5753
5750
|
for (const k in typeSet) {
|
|
5754
5751
|
const v = typeSet[k];
|
|
5755
5752
|
if (hasArkKind(v, "module")) {
|
|
5756
|
-
const
|
|
5753
|
+
const innerResolutions = resolutionsOfModule($, v);
|
|
5754
|
+
const prefixedResolutions = flatMorph(innerResolutions, (innerK, innerV) => [`${k}.${innerK}`, innerV]);
|
|
5757
5755
|
Object.assign(result, prefixedResolutions);
|
|
5758
5756
|
} else if (hasArkKind(v, "root") || hasArkKind(v, "generic")) result[k] = v;
|
|
5759
5757
|
else throwInternalError(`Unexpected scope resolution ${printable(v)}`);
|
|
@@ -5766,17 +5764,14 @@ const writeMissingSubmoduleAccessMessage = (name) => `Reference to submodule '${
|
|
|
5766
5764
|
rootSchemaScope.export();
|
|
5767
5765
|
const rootSchema = rootSchemaScope.schema;
|
|
5768
5766
|
const node = rootSchemaScope.node;
|
|
5769
|
-
|
|
5767
|
+
rootSchemaScope.defineSchema;
|
|
5770
5768
|
const genericNode = rootSchemaScope.generic;
|
|
5771
|
-
|
|
5772
5769
|
//#endregion
|
|
5773
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
5770
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/structure/shared.js
|
|
5774
5771
|
const arrayIndexSource = `^(?:0|[1-9]\\d*)$`;
|
|
5775
|
-
|
|
5776
|
-
const arrayIndexMatcherReference = registeredReference(arrayIndexMatcher);
|
|
5777
|
-
|
|
5772
|
+
registeredReference(new RegExp(arrayIndexSource));
|
|
5778
5773
|
//#endregion
|
|
5779
|
-
//#region node_modules/.pnpm/@ark+schema@0.56.
|
|
5774
|
+
//#region node_modules/.pnpm/@ark+schema@0.56.7/node_modules/@ark/schema/out/intrinsic.js
|
|
5780
5775
|
const intrinsicBases = schemaScope({
|
|
5781
5776
|
bigint: "bigint",
|
|
5782
5777
|
boolean: [{ unit: false }, { unit: true }],
|
|
@@ -5831,15 +5826,13 @@ const intrinsic = {
|
|
|
5831
5826
|
emptyStructure: node("structure", {}, { prereduced: true })
|
|
5832
5827
|
};
|
|
5833
5828
|
$ark.intrinsic = { ...intrinsic };
|
|
5834
|
-
|
|
5835
5829
|
//#endregion
|
|
5836
|
-
//#region node_modules/.pnpm/arkregex@0.0.
|
|
5830
|
+
//#region node_modules/.pnpm/arkregex@0.0.13/node_modules/arkregex/out/regex.js
|
|
5837
5831
|
const regex$1 = ((src, flags) => new RegExp(src, flags));
|
|
5838
5832
|
Object.assign(regex$1, { as: regex$1 });
|
|
5839
|
-
|
|
5840
5833
|
//#endregion
|
|
5841
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
5842
|
-
const isDateLiteral = (value
|
|
5834
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/parser/shift/operand/date.js
|
|
5835
|
+
const isDateLiteral = (value) => typeof value === "string" && value[0] === "d" && (value[1] === "'" || value[1] === "\"") && value[value.length - 1] === value[1];
|
|
5843
5836
|
const isValidDate = (d) => d.toString() !== "Invalid Date";
|
|
5844
5837
|
const extractDateLiteralSource = (literal) => literal.slice(2, -1);
|
|
5845
5838
|
const writeInvalidDateMessage = (source) => `'${source}' could not be parsed by the Date constructor`;
|
|
@@ -5854,9 +5847,8 @@ const maybeParseDate = (source, errorOnFail) => {
|
|
|
5854
5847
|
}
|
|
5855
5848
|
return errorOnFail ? throwParseError(errorOnFail === true ? writeInvalidDateMessage(source) : errorOnFail) : void 0;
|
|
5856
5849
|
};
|
|
5857
|
-
|
|
5858
5850
|
//#endregion
|
|
5859
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
5851
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/parser/shift/operand/enclosed.js
|
|
5860
5852
|
const regexExecArray = rootSchema({
|
|
5861
5853
|
proto: "Array",
|
|
5862
5854
|
sequence: "string",
|
|
@@ -5866,13 +5858,13 @@ const regexExecArray = rootSchema({
|
|
|
5866
5858
|
}
|
|
5867
5859
|
});
|
|
5868
5860
|
const parseEnclosed = (s, enclosing) => {
|
|
5869
|
-
const enclosed = s.scanner.shiftUntilEscapable(untilLookaheadIsClosing[enclosingTokens[enclosing]]);
|
|
5861
|
+
const enclosed = s.scanner.shiftUntilEscapable(untilLookaheadIsClosing[enclosingTokens[enclosing]], enclosing in enclosingRegexTokens ? "\\" : "");
|
|
5870
5862
|
if (s.scanner.lookahead === "") return s.error(writeUnterminatedEnclosedMessage(enclosed, enclosing));
|
|
5871
5863
|
s.scanner.shift();
|
|
5872
5864
|
if (enclosing in enclosingRegexTokens) {
|
|
5873
|
-
let regex
|
|
5865
|
+
let regex;
|
|
5874
5866
|
try {
|
|
5875
|
-
regex
|
|
5867
|
+
regex = new RegExp(enclosed);
|
|
5876
5868
|
} catch (e) {
|
|
5877
5869
|
throwParseError(String(e));
|
|
5878
5870
|
}
|
|
@@ -5882,7 +5874,7 @@ const parseEnclosed = (s, enclosing) => {
|
|
|
5882
5874
|
}, { prereduced: true });
|
|
5883
5875
|
if (enclosing === "x/") s.root = s.ctx.$.node("morph", {
|
|
5884
5876
|
in: s.root,
|
|
5885
|
-
morphs: (s
|
|
5877
|
+
morphs: (s) => regex.exec(s),
|
|
5886
5878
|
declaredOut: regexExecArray
|
|
5887
5879
|
});
|
|
5888
5880
|
} else if (isKeyOf(enclosing, enclosingQuote)) s.root = s.ctx.$.node("unit", { unit: enclosed });
|
|
@@ -5928,15 +5920,13 @@ const enclosingCharDescriptions = {
|
|
|
5928
5920
|
"/": "forward slash"
|
|
5929
5921
|
};
|
|
5930
5922
|
const writeUnterminatedEnclosedMessage = (fragment, enclosingStart) => `${enclosingStart}${fragment} requires a closing ${enclosingCharDescriptions[enclosingTokens[enclosingStart]]}`;
|
|
5931
|
-
|
|
5932
5923
|
//#endregion
|
|
5933
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
5924
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/parser/ast/validate.js
|
|
5934
5925
|
const writePrefixedPrivateReferenceMessage = (name) => `Private type references should not include '#'. Use '${name}' instead.`;
|
|
5935
5926
|
const shallowOptionalMessage = "Optional definitions like 'string?' are only valid as properties in an object or tuple";
|
|
5936
5927
|
const shallowDefaultableMessage = "Defaultable definitions like 'number = 0' are only valid as properties in an object or tuple";
|
|
5937
|
-
|
|
5938
5928
|
//#endregion
|
|
5939
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
5929
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/parser/shift/tokens.js
|
|
5940
5930
|
const terminatingChars = {
|
|
5941
5931
|
"<": 1,
|
|
5942
5932
|
">": 1,
|
|
@@ -5953,9 +5943,8 @@ const terminatingChars = {
|
|
|
5953
5943
|
...whitespaceChars
|
|
5954
5944
|
};
|
|
5955
5945
|
const lookaheadIsFinalizing = (lookahead, unscanned) => lookahead === ">" ? unscanned[0] === "=" ? unscanned[1] === "=" : unscanned.trimStart() === "" || isKeyOf(unscanned.trimStart()[0], terminatingChars) : lookahead === "=" ? unscanned[0] !== "=" : lookahead === "," || lookahead === "?";
|
|
5956
|
-
|
|
5957
5946
|
//#endregion
|
|
5958
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
5947
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/parser/shift/operand/genericArgs.js
|
|
5959
5948
|
const parseGenericArgs = (name, g, s) => _parseGenericArgs(name, g, s, []);
|
|
5960
5949
|
const _parseGenericArgs = (name, g, s, argNodes) => {
|
|
5961
5950
|
const argState = s.parseUntilFinalizer();
|
|
@@ -5968,9 +5957,8 @@ const _parseGenericArgs = (name, g, s, argNodes) => {
|
|
|
5968
5957
|
return argState.error(writeUnclosedGroupMessage(">"));
|
|
5969
5958
|
};
|
|
5970
5959
|
const writeInvalidGenericArgCountMessage = (name, params, argDefs) => `${name}<${params.join(", ")}> requires exactly ${params.length} args (got ${argDefs.length}${argDefs.length === 0 ? "" : `: ${argDefs.join(", ")}`})`;
|
|
5971
|
-
|
|
5972
5960
|
//#endregion
|
|
5973
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
5961
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/parser/shift/operand/unenclosed.js
|
|
5974
5962
|
const parseUnenclosed = (s) => {
|
|
5975
5963
|
const token = s.scanner.shiftUntilLookahead(terminatingChars);
|
|
5976
5964
|
if (token === "keyof") s.addPrefix("keyof");
|
|
@@ -6006,13 +5994,11 @@ const writeMissingOperandMessage = (s) => {
|
|
|
6006
5994
|
};
|
|
6007
5995
|
const writeMissingRightOperandMessage = (token, unscanned = "") => `Token '${token}' requires a right operand${unscanned ? ` before '${unscanned}'` : ""}`;
|
|
6008
5996
|
const writeExpressionExpectedMessage = (unscanned) => `Expected an expression${unscanned ? ` before '${unscanned}'` : ""}`;
|
|
6009
|
-
|
|
6010
5997
|
//#endregion
|
|
6011
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
5998
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/parser/shift/operand/operand.js
|
|
6012
5999
|
const parseOperand = (s) => s.scanner.lookahead === "" ? s.error(writeMissingOperandMessage(s)) : s.scanner.lookahead === "(" ? s.shiftedBy(1).reduceGroupOpen() : s.scanner.lookaheadIsIn(enclosingChar) ? parseEnclosed(s, s.scanner.shift()) : s.scanner.lookaheadIsIn(whitespaceChars) ? parseOperand(s.shiftedBy(1)) : s.scanner.lookahead === "d" ? s.scanner.nextLookahead in enclosingQuote ? parseEnclosed(s, `${s.scanner.shift()}${s.scanner.shift()}`) : parseUnenclosed(s) : s.scanner.lookahead === "x" ? s.scanner.nextLookahead === "/" ? s.shiftedBy(2) && parseEnclosed(s, "x/") : parseUnenclosed(s) : parseUnenclosed(s);
|
|
6013
|
-
|
|
6014
6000
|
//#endregion
|
|
6015
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6001
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/parser/reduce/shared.js
|
|
6016
6002
|
const minComparators = {
|
|
6017
6003
|
">": true,
|
|
6018
6004
|
">=": true
|
|
@@ -6031,9 +6017,8 @@ const invertedComparators = {
|
|
|
6031
6017
|
const writeOpenRangeMessage = (min, comparator) => `Left bounds are only valid when paired with right bounds (try ...${comparator}${min})`;
|
|
6032
6018
|
const writeUnpairableComparatorMessage = (comparator) => `Left-bounded expressions must specify their limits using < or <= (was ${comparator})`;
|
|
6033
6019
|
const writeMultipleLeftBoundsMessage = (openLimit, openComparator, limit, comparator) => `An expression may have at most one left bound (parsed ${openLimit}${invertedComparators[openComparator]}, ${limit}${invertedComparators[comparator]})`;
|
|
6034
|
-
|
|
6035
6020
|
//#endregion
|
|
6036
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6021
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/parser/shift/operator/bounds.js
|
|
6037
6022
|
const parseBound = (s, start) => {
|
|
6038
6023
|
const comparator = shiftComparator(s, start);
|
|
6039
6024
|
if (s.root.hasKind("unit")) {
|
|
@@ -6095,17 +6080,15 @@ const parseRightBound = (s, comparator) => {
|
|
|
6095
6080
|
s.branches.leftBound = null;
|
|
6096
6081
|
};
|
|
6097
6082
|
const writeInvalidLimitMessage = (comparator, limit, boundKind) => `Comparator ${boundKind === "left" ? invertedComparators[comparator] : comparator} must be ${boundKind === "left" ? "preceded" : "followed"} by a corresponding literal (was ${limit})`;
|
|
6098
|
-
|
|
6099
6083
|
//#endregion
|
|
6100
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6084
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/parser/shift/operator/brand.js
|
|
6101
6085
|
const parseBrand = (s) => {
|
|
6102
6086
|
s.scanner.shiftUntilNonWhitespace();
|
|
6103
6087
|
const brandName = s.scanner.shiftUntilLookahead(terminatingChars);
|
|
6104
6088
|
s.root = s.root.brand(brandName);
|
|
6105
6089
|
};
|
|
6106
|
-
|
|
6107
6090
|
//#endregion
|
|
6108
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6091
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/parser/shift/operator/divisor.js
|
|
6109
6092
|
const parseDivisor = (s) => {
|
|
6110
6093
|
s.scanner.shiftUntilNonWhitespace();
|
|
6111
6094
|
const divisorToken = s.scanner.shiftUntilLookahead(terminatingChars);
|
|
@@ -6114,20 +6097,33 @@ const parseDivisor = (s) => {
|
|
|
6114
6097
|
s.root = s.root.constrain("divisor", divisor);
|
|
6115
6098
|
};
|
|
6116
6099
|
const writeInvalidDivisorMessage = (divisor) => `% operator must be followed by a non-zero integer literal (was ${divisor})`;
|
|
6117
|
-
|
|
6118
6100
|
//#endregion
|
|
6119
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6101
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/parser/shift/operator/operator.js
|
|
6120
6102
|
const parseOperator = (s) => {
|
|
6121
6103
|
const lookahead = s.scanner.shift();
|
|
6122
|
-
return lookahead === "" ? s.finalize("") : lookahead === "[" ? s.scanner.shift() === "]" ? s.setRoot(s.root.
|
|
6104
|
+
return lookahead === "" ? s.finalize("") : lookahead === "[" ? s.scanner.shift() === "]" ? s.setRoot(s.root.rawArray()) : s.error(incompleteArrayTokenMessage) : lookahead === "|" ? s.scanner.lookahead === ">" ? s.shiftedBy(1).pushRootToBranch("|>") : s.pushRootToBranch(lookahead) : lookahead === "&" ? s.pushRootToBranch(lookahead) : lookahead === ")" ? s.finalizeGroup() : lookaheadIsFinalizing(lookahead, s.scanner.unscanned) ? s.finalize(lookahead) : isKeyOf(lookahead, comparatorStartChars) ? parseBound(s, lookahead) : lookahead === "%" ? parseDivisor(s) : lookahead === "#" ? parseBrand(s) : lookahead in whitespaceChars ? parseOperator(s) : s.error(writeUnexpectedCharacterMessage(lookahead));
|
|
6123
6105
|
};
|
|
6124
6106
|
const writeUnexpectedCharacterMessage = (char, shouldBe = "") => `'${char}' is not allowed here${shouldBe && ` (should be ${shouldBe})`}`;
|
|
6125
6107
|
const incompleteArrayTokenMessage = `Missing expected ']'`;
|
|
6126
|
-
|
|
6127
6108
|
//#endregion
|
|
6128
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6109
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/parser/shift/operator/default.js
|
|
6110
|
+
const emptyCollectionDefaults = {
|
|
6111
|
+
"[]": () => [],
|
|
6112
|
+
"{}": () => ({})
|
|
6113
|
+
};
|
|
6114
|
+
const emptyCollectionLiterals = keysOf(emptyCollectionDefaults);
|
|
6129
6115
|
const parseDefault = (s) => {
|
|
6130
6116
|
const baseNode = s.unsetRoot();
|
|
6117
|
+
s.scanner.shiftUntilNonWhitespace();
|
|
6118
|
+
const emptyCollection = emptyCollectionLiterals.find((literal) => s.scanner.unscanned.startsWith(literal));
|
|
6119
|
+
if (emptyCollection !== void 0) {
|
|
6120
|
+
s.scanner.jumpForward(emptyCollection.length);
|
|
6121
|
+
return [
|
|
6122
|
+
baseNode,
|
|
6123
|
+
"=",
|
|
6124
|
+
emptyCollectionDefaults[emptyCollection]
|
|
6125
|
+
];
|
|
6126
|
+
}
|
|
6131
6127
|
s.parseOperand();
|
|
6132
6128
|
const defaultNode = s.unsetRoot();
|
|
6133
6129
|
if (!defaultNode.hasKind("unit")) return s.error(writeNonLiteralDefaultMessage(defaultNode.expression));
|
|
@@ -6138,20 +6134,19 @@ const parseDefault = (s) => {
|
|
|
6138
6134
|
];
|
|
6139
6135
|
};
|
|
6140
6136
|
const writeNonLiteralDefaultMessage = (defaultDef) => `Default value '${defaultDef}' must be a literal value`;
|
|
6141
|
-
|
|
6142
6137
|
//#endregion
|
|
6143
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6138
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/parser/string.js
|
|
6144
6139
|
const parseString = (def, ctx) => {
|
|
6145
6140
|
const aliasResolution = ctx.$.maybeResolveRoot(def);
|
|
6146
6141
|
if (aliasResolution) return aliasResolution;
|
|
6147
6142
|
if (def.endsWith("[]")) {
|
|
6148
6143
|
const possibleElementResolution = ctx.$.maybeResolveRoot(def.slice(0, -2));
|
|
6149
|
-
if (possibleElementResolution) return possibleElementResolution.
|
|
6144
|
+
if (possibleElementResolution) return possibleElementResolution.rawArray();
|
|
6150
6145
|
}
|
|
6151
6146
|
const s = new RuntimeState(new Scanner(def), ctx);
|
|
6152
|
-
const node
|
|
6147
|
+
const node = fullStringParse(s);
|
|
6153
6148
|
if (s.finalizer === ">") throwParseError(writeUnexpectedCharacterMessage(">"));
|
|
6154
|
-
return node
|
|
6149
|
+
return node;
|
|
6155
6150
|
};
|
|
6156
6151
|
const fullStringParse = (s) => {
|
|
6157
6152
|
s.parseOperand();
|
|
@@ -6168,9 +6163,8 @@ const parseUntilFinalizer = (s) => {
|
|
|
6168
6163
|
return s;
|
|
6169
6164
|
};
|
|
6170
6165
|
const next = (s) => s.hasRoot() ? s.parseOperator() : s.parseOperand();
|
|
6171
|
-
|
|
6172
6166
|
//#endregion
|
|
6173
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6167
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/parser/reduce/dynamic.js
|
|
6174
6168
|
var RuntimeState = class RuntimeState {
|
|
6175
6169
|
root;
|
|
6176
6170
|
branches = {
|
|
@@ -6198,9 +6192,9 @@ var RuntimeState = class RuntimeState {
|
|
|
6198
6192
|
this.root = root;
|
|
6199
6193
|
}
|
|
6200
6194
|
unsetRoot() {
|
|
6201
|
-
const value
|
|
6195
|
+
const value = this.root;
|
|
6202
6196
|
this.root = void 0;
|
|
6203
|
-
return value
|
|
6197
|
+
return value;
|
|
6204
6198
|
}
|
|
6205
6199
|
constrainRoot(...args) {
|
|
6206
6200
|
this.root = this.root.constrain(args[0], args[1]);
|
|
@@ -6296,9 +6290,8 @@ var RuntimeState = class RuntimeState {
|
|
|
6296
6290
|
return this;
|
|
6297
6291
|
}
|
|
6298
6292
|
};
|
|
6299
|
-
|
|
6300
6293
|
//#endregion
|
|
6301
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6294
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/generic.js
|
|
6302
6295
|
const emptyGenericParameterMessage = "An empty string is not a valid generic parameter name";
|
|
6303
6296
|
const parseGenericParamName = (scanner, result, ctx) => {
|
|
6304
6297
|
scanner.shiftUntilNonWhitespace();
|
|
@@ -6323,16 +6316,11 @@ const _parseOptionalConstraint = (scanner, name, result, ctx) => {
|
|
|
6323
6316
|
result.push([name, s.root]);
|
|
6324
6317
|
return parseGenericParamName(scanner, result, ctx);
|
|
6325
6318
|
};
|
|
6326
|
-
|
|
6327
6319
|
//#endregion
|
|
6328
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6320
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/fn.js
|
|
6329
6321
|
var InternalFnParser = class extends Callable {
|
|
6330
6322
|
constructor($) {
|
|
6331
|
-
const
|
|
6332
|
-
$,
|
|
6333
|
-
raw: $.fn
|
|
6334
|
-
};
|
|
6335
|
-
super((...signature) => {
|
|
6323
|
+
const parse = (...signature) => {
|
|
6336
6324
|
const returnOperatorIndex = signature.indexOf(":");
|
|
6337
6325
|
const lastParamIndex = returnOperatorIndex === -1 ? signature.length - 1 : returnOperatorIndex - 1;
|
|
6338
6326
|
const paramDefs = signature.slice(0, lastParamIndex + 1);
|
|
@@ -6343,7 +6331,11 @@ var InternalFnParser = class extends Callable {
|
|
|
6343
6331
|
returnType = $.parse(signature[returnOperatorIndex + 1]);
|
|
6344
6332
|
}
|
|
6345
6333
|
return (impl) => new InternalTypedFn(impl, paramTuple, returnType);
|
|
6346
|
-
}
|
|
6334
|
+
};
|
|
6335
|
+
super(parse, { attach: {
|
|
6336
|
+
$,
|
|
6337
|
+
raw: parse
|
|
6338
|
+
} });
|
|
6347
6339
|
}
|
|
6348
6340
|
};
|
|
6349
6341
|
var InternalTypedFn = class extends Callable {
|
|
@@ -6369,9 +6361,8 @@ var InternalTypedFn = class extends Callable {
|
|
|
6369
6361
|
};
|
|
6370
6362
|
const badFnReturnTypeMessage = `":" must be followed by exactly one return type e.g:
|
|
6371
6363
|
fn("string", ":", "number")(s => s.length)`;
|
|
6372
|
-
|
|
6373
6364
|
//#endregion
|
|
6374
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6365
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/match.js
|
|
6375
6366
|
var InternalMatchParser = class extends Callable {
|
|
6376
6367
|
$;
|
|
6377
6368
|
constructor($) {
|
|
@@ -6407,8 +6398,8 @@ var InternalChainedMatchParser = class extends Callable {
|
|
|
6407
6398
|
case(def, resolver) {
|
|
6408
6399
|
return this.caseEntry(this.$.parse(def), resolver);
|
|
6409
6400
|
}
|
|
6410
|
-
caseEntry(node
|
|
6411
|
-
const branch = (this.key ? this.$.parse({ [this.key]: node
|
|
6401
|
+
caseEntry(node, resolver) {
|
|
6402
|
+
const branch = (this.key ? this.$.parse({ [this.key]: node }) : node).pipe(resolver);
|
|
6412
6403
|
this.branches.push(branch);
|
|
6413
6404
|
return this;
|
|
6414
6405
|
}
|
|
@@ -6432,12 +6423,12 @@ var InternalChainedMatchParser = class extends Callable {
|
|
|
6432
6423
|
}
|
|
6433
6424
|
default(defaultCase) {
|
|
6434
6425
|
if (typeof defaultCase === "function") this.case(intrinsic.unknown, defaultCase);
|
|
6435
|
-
const schema
|
|
6426
|
+
const schema = {
|
|
6436
6427
|
branches: this.branches,
|
|
6437
6428
|
ordered: true
|
|
6438
6429
|
};
|
|
6439
|
-
if (defaultCase === "never" || defaultCase === "assert") schema
|
|
6440
|
-
const cases = this.$.node("union", schema
|
|
6430
|
+
if (defaultCase === "never" || defaultCase === "assert") schema.meta = { onFail: throwOnDefault };
|
|
6431
|
+
const cases = this.$.node("union", schema);
|
|
6441
6432
|
if (!this.in) return this.$.finalize(cases);
|
|
6442
6433
|
let inputValidatedCases = this.in.pipe(cases);
|
|
6443
6434
|
if (defaultCase === "never" || defaultCase === "assert") inputValidatedCases = inputValidatedCases.configureReferences({ onFail: throwOnDefault }, "self");
|
|
@@ -6447,9 +6438,8 @@ var InternalChainedMatchParser = class extends Callable {
|
|
|
6447
6438
|
const throwOnDefault = (errors) => errors.throw();
|
|
6448
6439
|
const chainedAtMessage = `A key matcher must be specified before the first case i.e. match.at('foo') or match.in<object>().at('bar')`;
|
|
6449
6440
|
const doubleAtMessage = `At most one key matcher may be specified per expression`;
|
|
6450
|
-
|
|
6451
6441
|
//#endregion
|
|
6452
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6442
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/parser/property.js
|
|
6453
6443
|
const parseProperty = (def, ctx) => {
|
|
6454
6444
|
if (isArray(def)) {
|
|
6455
6445
|
if (def[1] === "=") return [
|
|
@@ -6463,9 +6453,8 @@ const parseProperty = (def, ctx) => {
|
|
|
6463
6453
|
};
|
|
6464
6454
|
const invalidOptionalKeyKindMessage = `Only required keys may make their values optional, e.g. { [mySymbol]: ['number', '?'] }`;
|
|
6465
6455
|
const invalidDefaultableKeyKindMessage = `Only required keys may specify default values, e.g. { value: 'number = 0' }`;
|
|
6466
|
-
|
|
6467
6456
|
//#endregion
|
|
6468
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6457
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/parser/objectLiteral.js
|
|
6469
6458
|
const parseObjectLiteral = (def, ctx) => {
|
|
6470
6459
|
let spread;
|
|
6471
6460
|
const structure = {};
|
|
@@ -6513,7 +6502,8 @@ const parseObjectLiteral = (def, ctx) => {
|
|
|
6513
6502
|
}, ctx);
|
|
6514
6503
|
continue;
|
|
6515
6504
|
}
|
|
6516
|
-
const
|
|
6505
|
+
const signature = ctx.$.parseOwnDefinitionFormat(parsedEntryKey.normalized, ctx);
|
|
6506
|
+
const normalized = normalizeIndex(signature, parsedValue, ctx.$);
|
|
6517
6507
|
if (normalized.index) structure.index = append(structure.index, normalized.index);
|
|
6518
6508
|
if (normalized.required) structure.required = append(structure.required, normalized.required);
|
|
6519
6509
|
}
|
|
@@ -6531,7 +6521,7 @@ const nonLeadingSpreadError = "Spread operator may only be used as the first key
|
|
|
6531
6521
|
const preparseKey = (key) => typeof key === "symbol" ? {
|
|
6532
6522
|
kind: "required",
|
|
6533
6523
|
normalized: key
|
|
6534
|
-
} : key[key.length - 1] === "?" ? key[key.length - 2] ===
|
|
6524
|
+
} : key[key.length - 1] === "?" ? key[key.length - 2] === "\\" ? {
|
|
6535
6525
|
kind: "required",
|
|
6536
6526
|
normalized: `${key.slice(0, -2)}?`
|
|
6537
6527
|
} : {
|
|
@@ -6540,7 +6530,7 @@ const preparseKey = (key) => typeof key === "symbol" ? {
|
|
|
6540
6530
|
} : key[0] === "[" && key[key.length - 1] === "]" ? {
|
|
6541
6531
|
kind: "index",
|
|
6542
6532
|
normalized: key.slice(1, -1)
|
|
6543
|
-
} : key[0] ===
|
|
6533
|
+
} : key[0] === "\\" && key[1] === "[" && key[key.length - 1] === "]" ? {
|
|
6544
6534
|
kind: "required",
|
|
6545
6535
|
normalized: key.slice(1)
|
|
6546
6536
|
} : key === "..." ? { kind: "spread" } : key === "+" ? { kind: "undeclared" } : {
|
|
@@ -6548,9 +6538,8 @@ const preparseKey = (key) => typeof key === "symbol" ? {
|
|
|
6548
6538
|
normalized: key === "\\..." ? "..." : key === "\\+" ? "+" : key
|
|
6549
6539
|
};
|
|
6550
6540
|
const writeInvalidSpreadTypeMessage = (def) => `Spread operand must resolve to an object literal type (was ${def})`;
|
|
6551
|
-
|
|
6552
6541
|
//#endregion
|
|
6553
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6542
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/parser/tupleExpressions.js
|
|
6554
6543
|
const maybeParseTupleExpression = (def, ctx) => isIndexZeroExpression(def) ? indexZeroParsers[def[0]](def, ctx) : isIndexOneExpression(def) ? indexOneParsers[def[1]](def, ctx) : null;
|
|
6555
6544
|
const parseKeyOfTuple = (def, ctx) => ctx.$.parseOwnDefinitionFormat(def[1], ctx).keyof();
|
|
6556
6545
|
const parseBranchTuple = (def, ctx) => {
|
|
@@ -6562,12 +6551,12 @@ const parseBranchTuple = (def, ctx) => {
|
|
|
6562
6551
|
if (result instanceof Disjoint) return result.throw();
|
|
6563
6552
|
return result;
|
|
6564
6553
|
};
|
|
6565
|
-
const parseArrayTuple = (def, ctx) => ctx.$.parseOwnDefinitionFormat(def[0], ctx).
|
|
6554
|
+
const parseArrayTuple = (def, ctx) => ctx.$.parseOwnDefinitionFormat(def[0], ctx).rawArray();
|
|
6566
6555
|
const parseMorphTuple = (def, ctx) => {
|
|
6567
6556
|
if (typeof def[2] !== "function") return throwParseError(writeMalformedFunctionalExpressionMessage("=>", def[2]));
|
|
6568
6557
|
return ctx.$.parseOwnDefinitionFormat(def[0], ctx).pipe(def[2]);
|
|
6569
6558
|
};
|
|
6570
|
-
const writeMalformedFunctionalExpressionMessage = (operator, value
|
|
6559
|
+
const writeMalformedFunctionalExpressionMessage = (operator, value) => `${operator === ":" ? "Narrow" : "Morph"} expression requires a function following '${operator}' (was ${typeof value})`;
|
|
6571
6560
|
const parseNarrowTuple = (def, ctx) => {
|
|
6572
6561
|
if (typeof def[2] !== "function") return throwParseError(writeMalformedFunctionalExpressionMessage(":", def[2]));
|
|
6573
6562
|
return ctx.$.parseOwnDefinitionFormat(def[0], ctx).constrain("predicate", def[2]);
|
|
@@ -6604,9 +6593,8 @@ const indexZeroParsers = defineIndexZeroParsers({
|
|
|
6604
6593
|
});
|
|
6605
6594
|
const isIndexZeroExpression = (def) => indexZeroParsers[def[0]] !== void 0;
|
|
6606
6595
|
const writeInvalidConstructorMessage = (actual) => `Expected a constructor following 'instanceof' operator (was ${actual})`;
|
|
6607
|
-
|
|
6608
6596
|
//#endregion
|
|
6609
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6597
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/parser/tupleLiteral.js
|
|
6610
6598
|
const parseTupleLiteral = (def, ctx) => {
|
|
6611
6599
|
let sequences = [{}];
|
|
6612
6600
|
let i = 0;
|
|
@@ -6647,10 +6635,10 @@ const appendOptionalElement = (base, element) => {
|
|
|
6647
6635
|
base.optionals = append(base.optionals, element);
|
|
6648
6636
|
return base;
|
|
6649
6637
|
};
|
|
6650
|
-
const appendDefaultableElement = (base, element, value
|
|
6638
|
+
const appendDefaultableElement = (base, element, value) => {
|
|
6651
6639
|
if (base.variadic) return throwParseError(optionalOrDefaultableAfterVariadicMessage);
|
|
6652
6640
|
if (base.optionals) return throwParseError(defaultablePostOptionalMessage);
|
|
6653
|
-
base.defaultables = append(base.defaultables, [[element, value
|
|
6641
|
+
base.defaultables = append(base.defaultables, [[element, value]]);
|
|
6654
6642
|
return base;
|
|
6655
6643
|
};
|
|
6656
6644
|
const appendVariadicElement = (base, element) => {
|
|
@@ -6666,10 +6654,10 @@ const appendSpreadBranch = (base, branch) => {
|
|
|
6666
6654
|
kind: "sequence"
|
|
6667
6655
|
});
|
|
6668
6656
|
if (!spread) return appendVariadicElement(base, $ark.intrinsic.unknown);
|
|
6669
|
-
if (spread.prefix) for (const node
|
|
6670
|
-
if (spread.optionals) for (const node
|
|
6657
|
+
if (spread.prefix) for (const node of spread.prefix) appendRequiredElement(base, node);
|
|
6658
|
+
if (spread.optionals) for (const node of spread.optionals) appendOptionalElement(base, node);
|
|
6671
6659
|
if (spread.variadic) appendVariadicElement(base, spread.variadic);
|
|
6672
|
-
if (spread.postfix) for (const node
|
|
6660
|
+
if (spread.postfix) for (const node of spread.postfix) appendRequiredElement(base, node);
|
|
6673
6661
|
return base;
|
|
6674
6662
|
};
|
|
6675
6663
|
const writeNonArraySpreadMessage = (operand) => `Spread element must be an array (was ${operand})`;
|
|
@@ -6677,14 +6665,17 @@ const multipleVariadicMesage = "A tuple may have at most one variadic element";
|
|
|
6677
6665
|
const requiredPostOptionalMessage = "A required element may not follow an optional element";
|
|
6678
6666
|
const optionalOrDefaultableAfterVariadicMessage = "An optional element may not follow a variadic element";
|
|
6679
6667
|
const defaultablePostOptionalMessage = "A defaultable element may not follow an optional element without a default";
|
|
6680
|
-
|
|
6681
6668
|
//#endregion
|
|
6682
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6683
|
-
const parseCache =
|
|
6669
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/parser/definition.js
|
|
6670
|
+
const parseCache = /* @__PURE__ */ new WeakMap();
|
|
6684
6671
|
const parseInnerDefinition = (def, ctx) => {
|
|
6685
6672
|
if (typeof def === "string") {
|
|
6686
6673
|
if (ctx.args && Object.keys(ctx.args).some((k) => def.includes(k))) return parseString(def, ctx);
|
|
6687
|
-
|
|
6674
|
+
let scopeCache = parseCache.get(ctx.$);
|
|
6675
|
+
if (!scopeCache) {
|
|
6676
|
+
scopeCache = {};
|
|
6677
|
+
parseCache.set(ctx.$, scopeCache);
|
|
6678
|
+
}
|
|
6688
6679
|
return scopeCache[def] ??= parseString(def, ctx);
|
|
6689
6680
|
}
|
|
6690
6681
|
return hasDomain(def, "object") ? parseObject(def, ctx) : throwParseError(writeBadDefinitionTypeMessage(domainOf(def)));
|
|
@@ -6709,21 +6700,21 @@ const parseObject = (def, ctx) => {
|
|
|
6709
6700
|
default: return throwParseError(writeBadDefinitionTypeMessage(objectKind ?? printable(def)));
|
|
6710
6701
|
}
|
|
6711
6702
|
};
|
|
6712
|
-
const parseStandardSchema = (def, ctx) => ctx.$.intrinsic.unknown.pipe((v, ctx
|
|
6703
|
+
const parseStandardSchema = (def, ctx) => ctx.$.intrinsic.unknown.pipe((v, ctx) => {
|
|
6713
6704
|
const result = def["~standard"].validate(v);
|
|
6714
6705
|
if (!result.issues) return result.value;
|
|
6715
|
-
for (const { message, path } of result.issues) if (path)
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6706
|
+
for (const { message, path } of result.issues) if (path) {
|
|
6707
|
+
if (path.length) ctx.error({
|
|
6708
|
+
problem: uncapitalize(message),
|
|
6709
|
+
relativePath: path.map((k) => typeof k === "object" ? k.key : k)
|
|
6710
|
+
});
|
|
6711
|
+
else ctx.error({ message });
|
|
6712
|
+
} else ctx.error({ message });
|
|
6721
6713
|
});
|
|
6722
6714
|
const parseTuple = (def, ctx) => maybeParseTupleExpression(def, ctx) ?? parseTupleLiteral(def, ctx);
|
|
6723
6715
|
const writeBadDefinitionTypeMessage = (actual) => `Type definitions must be strings or objects (was ${actual})`;
|
|
6724
|
-
|
|
6725
6716
|
//#endregion
|
|
6726
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6717
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/type.js
|
|
6727
6718
|
var InternalTypeParser = class extends Callable {
|
|
6728
6719
|
constructor($) {
|
|
6729
6720
|
const attach = Object.assign({
|
|
@@ -6759,9 +6750,8 @@ var InternalTypeParser = class extends Callable {
|
|
|
6759
6750
|
}, { attach });
|
|
6760
6751
|
}
|
|
6761
6752
|
};
|
|
6762
|
-
|
|
6763
6753
|
//#endregion
|
|
6764
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6754
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/scope.js
|
|
6765
6755
|
const $arkTypeRegistry = $ark;
|
|
6766
6756
|
var InternalScope = class InternalScope extends BaseScope {
|
|
6767
6757
|
get ambientAttachments() {
|
|
@@ -6785,7 +6775,8 @@ var InternalScope = class InternalScope extends BaseScope {
|
|
|
6785
6775
|
const name = alias.slice(0, firstParamIndex);
|
|
6786
6776
|
const paramString = alias.slice(firstParamIndex + 1, -1);
|
|
6787
6777
|
return [name, () => {
|
|
6788
|
-
|
|
6778
|
+
const params = this.parseGenericParams(paramString, { alias: name });
|
|
6779
|
+
return parseGeneric(params, def, this);
|
|
6789
6780
|
}];
|
|
6790
6781
|
}
|
|
6791
6782
|
parseGenericParams(def, opts) {
|
|
@@ -6815,13 +6806,13 @@ var InternalScope = class InternalScope extends BaseScope {
|
|
|
6815
6806
|
}
|
|
6816
6807
|
return result;
|
|
6817
6808
|
}
|
|
6818
|
-
unit = (value
|
|
6809
|
+
unit = (value) => this.units([value]);
|
|
6819
6810
|
valueOf = (tsEnum) => this.units(enumValues(tsEnum));
|
|
6820
6811
|
enumerated = (...values) => this.units(values);
|
|
6821
6812
|
instanceOf = (ctor) => this.node("proto", { proto: ctor }, { prereduced: true });
|
|
6822
6813
|
or = (...defs) => this.schema(defs.map((def) => this.parse(def)));
|
|
6823
|
-
and = (...defs) => defs.reduce((node
|
|
6824
|
-
merge = (...defs) => defs.reduce((node
|
|
6814
|
+
and = (...defs) => defs.reduce((node, def) => node.and(this.parse(def)), this.intrinsic.unknown);
|
|
6815
|
+
merge = (...defs) => defs.reduce((node, def) => node.merge(this.parse(def)), this.intrinsic.object);
|
|
6825
6816
|
pipe = (...morphs) => this.intrinsic.unknown.pipe(...morphs);
|
|
6826
6817
|
fn = new InternalFnParser(this);
|
|
6827
6818
|
match = new InternalMatchParser(this);
|
|
@@ -6831,13 +6822,12 @@ var InternalScope = class InternalScope extends BaseScope {
|
|
|
6831
6822
|
}
|
|
6832
6823
|
type = new InternalTypeParser(this);
|
|
6833
6824
|
static scope = ((def, config = {}) => new InternalScope(def, config));
|
|
6834
|
-
static module = ((def, config = {}) =>
|
|
6825
|
+
static module = ((def, config = {}) => InternalScope.scope(def, config).export());
|
|
6835
6826
|
};
|
|
6836
6827
|
const scope = Object.assign(InternalScope.scope, { define: (def) => def });
|
|
6837
6828
|
const Scope = InternalScope;
|
|
6838
|
-
|
|
6839
6829
|
//#endregion
|
|
6840
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6830
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/keywords/builtins.js
|
|
6841
6831
|
var MergeHkt = class extends Hkt {
|
|
6842
6832
|
description = "merge an object's properties onto another like `Merge(User, { isAdmin: \"true\" })`";
|
|
6843
6833
|
};
|
|
@@ -6846,9 +6836,8 @@ const arkBuiltins = Scope.module({
|
|
|
6846
6836
|
Key: intrinsic.key,
|
|
6847
6837
|
Merge
|
|
6848
6838
|
});
|
|
6849
|
-
|
|
6850
6839
|
//#endregion
|
|
6851
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6840
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/keywords/Array.js
|
|
6852
6841
|
var liftFromHkt = class extends Hkt {};
|
|
6853
6842
|
const liftFrom = genericNode("element")((args) => {
|
|
6854
6843
|
const nonArrayElement = args.element.exclude(intrinsic.Array);
|
|
@@ -6861,9 +6850,8 @@ const arkArray = Scope.module({
|
|
|
6861
6850
|
index: intrinsic.nonNegativeIntegerString,
|
|
6862
6851
|
liftFrom
|
|
6863
6852
|
}, { name: "Array" });
|
|
6864
|
-
|
|
6865
6853
|
//#endregion
|
|
6866
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6854
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/keywords/FormData.js
|
|
6867
6855
|
const value = rootSchema(["string", registry.FileConstructor]);
|
|
6868
6856
|
const parsed = rootSchema({
|
|
6869
6857
|
meta: "an object representing parsed form data",
|
|
@@ -6891,9 +6879,8 @@ const arkFormData = Scope.module({
|
|
|
6891
6879
|
declaredOut: parsed
|
|
6892
6880
|
})
|
|
6893
6881
|
}, { name: "FormData" });
|
|
6894
|
-
|
|
6895
6882
|
//#endregion
|
|
6896
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6883
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/keywords/TypedArray.js
|
|
6897
6884
|
const TypedArray = Scope.module({
|
|
6898
6885
|
Int8: ["instanceof", Int8Array],
|
|
6899
6886
|
Uint8: ["instanceof", Uint8Array],
|
|
@@ -6907,9 +6894,8 @@ const TypedArray = Scope.module({
|
|
|
6907
6894
|
BigInt64: ["instanceof", BigInt64Array],
|
|
6908
6895
|
BigUint64: ["instanceof", BigUint64Array]
|
|
6909
6896
|
}, { name: "TypedArray" });
|
|
6910
|
-
|
|
6911
6897
|
//#endregion
|
|
6912
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6898
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/keywords/constructors.js
|
|
6913
6899
|
const omittedPrototypes = {
|
|
6914
6900
|
Boolean: 1,
|
|
6915
6901
|
Number: 1,
|
|
@@ -6924,9 +6910,8 @@ const arkPrototypes = Scope.module({
|
|
|
6924
6910
|
TypedArray,
|
|
6925
6911
|
FormData: arkFormData
|
|
6926
6912
|
});
|
|
6927
|
-
|
|
6928
6913
|
//#endregion
|
|
6929
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6914
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/keywords/number.js
|
|
6930
6915
|
/**
|
|
6931
6916
|
* As per the ECMA-262 specification:
|
|
6932
6917
|
* A time value supports a slightly smaller range of -8,640,000,000,000,000 to 8,640,000,000,000,000 milliseconds.
|
|
@@ -6972,20 +6957,19 @@ const number = Scope.module({
|
|
|
6972
6957
|
Infinity: ["===", Number.POSITIVE_INFINITY],
|
|
6973
6958
|
NegativeInfinity: ["===", Number.NEGATIVE_INFINITY]
|
|
6974
6959
|
}, { name: "number" });
|
|
6975
|
-
|
|
6976
6960
|
//#endregion
|
|
6977
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
6978
|
-
const regexStringNode = (regex
|
|
6979
|
-
const schema
|
|
6961
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/keywords/string.js
|
|
6962
|
+
const regexStringNode = (regex, description, jsonSchemaFormat) => {
|
|
6963
|
+
const schema = {
|
|
6980
6964
|
domain: "string",
|
|
6981
6965
|
pattern: {
|
|
6982
|
-
rule: regex
|
|
6983
|
-
flags: regex
|
|
6966
|
+
rule: regex.source,
|
|
6967
|
+
flags: regex.flags,
|
|
6984
6968
|
meta: description
|
|
6985
6969
|
}
|
|
6986
6970
|
};
|
|
6987
|
-
if (jsonSchemaFormat) schema
|
|
6988
|
-
return node("intersection", schema
|
|
6971
|
+
if (jsonSchemaFormat) schema.meta = { format: jsonSchemaFormat };
|
|
6972
|
+
return node("intersection", schema);
|
|
6989
6973
|
};
|
|
6990
6974
|
const stringIntegerRoot = regexStringNode(wellFormedIntegerMatcher, "a well-formed integer string");
|
|
6991
6975
|
const stringInteger = Scope.module({
|
|
@@ -6993,13 +6977,14 @@ const stringInteger = Scope.module({
|
|
|
6993
6977
|
parse: rootSchema({
|
|
6994
6978
|
in: stringIntegerRoot,
|
|
6995
6979
|
morphs: (s, ctx) => {
|
|
6996
|
-
const parsed
|
|
6997
|
-
return Number.isSafeInteger(parsed
|
|
6980
|
+
const parsed = Number.parseInt(s);
|
|
6981
|
+
return Number.isSafeInteger(parsed) ? parsed : ctx.error("an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER");
|
|
6998
6982
|
},
|
|
6999
6983
|
declaredOut: intrinsic.integer
|
|
7000
6984
|
})
|
|
7001
6985
|
}, { name: "string.integer" });
|
|
7002
6986
|
const hex = regexStringNode(/^[\dA-Fa-f]+$/, "hex characters only");
|
|
6987
|
+
const base58 = regexStringNode(/^[1-9A-HJ-NP-Za-km-z]+$/, "base58-encoded");
|
|
7003
6988
|
const base64 = Scope.module({
|
|
7004
6989
|
root: regexStringNode(/^(?:[\d+/A-Za-z]{4})*(?:[\d+/A-Za-z]{2}==|[\d+/A-Za-z]{3}=)?$/, "base64-encoded"),
|
|
7005
6990
|
url: regexStringNode(/^(?:[\w-]{4})*(?:[\w-]{2}(?:==|%3D%3D)?|[\w-]{3}(?:=|%3D)?)?$/, "base64url-encoded")
|
|
@@ -7030,12 +7015,11 @@ const isLuhnValid = (creditCardInput) => {
|
|
|
7030
7015
|
}
|
|
7031
7016
|
return !!(sum % 10 === 0 ? sanitized : false);
|
|
7032
7017
|
};
|
|
7033
|
-
const creditCardMatcher = /^(?:4\d{12}(?:\d{3,6})?|5[1-5]\d{14}|(222[1-9]|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)\d{12}|6(?:011|5\d\d)\d{12,15}|3[47]\d{13}|3(?:0[0-5]|[68]\d)\d{11}|(?:2131|1800|35\d{3})\d{11}|6[27]\d{14}|^(81\d{14,17}))$/;
|
|
7034
7018
|
const creditCard = rootSchema({
|
|
7035
7019
|
domain: "string",
|
|
7036
7020
|
pattern: {
|
|
7037
7021
|
meta: "a credit card number",
|
|
7038
|
-
rule:
|
|
7022
|
+
rule: /^(?:4\d{12}(?:\d{3,6})?|5[1-5]\d{14}|(222[1-9]|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)\d{12}|6(?:011|5\d\d)\d{12,15}|3[47]\d{13}|3(?:0[0-5]|[68]\d)\d{11}|(?:2131|1800|35\d{3})\d{11}|6[27]\d{14}|^(81\d{14,17}))$/.source
|
|
7039
7023
|
},
|
|
7040
7024
|
predicate: {
|
|
7041
7025
|
meta: "a credit card number",
|
|
@@ -7064,7 +7048,7 @@ const epoch = Scope.module({
|
|
|
7064
7048
|
root: epochRoot,
|
|
7065
7049
|
parse: rootSchema({
|
|
7066
7050
|
in: epochRoot,
|
|
7067
|
-
morphs: (s) => new Date(s),
|
|
7051
|
+
morphs: (s) => new Date(Number.parseInt(s)),
|
|
7068
7052
|
declaredOut: intrinsic.Date
|
|
7069
7053
|
})
|
|
7070
7054
|
}, { name: "string.date.epoch" });
|
|
@@ -7095,9 +7079,9 @@ const stringDate = Scope.module({
|
|
|
7095
7079
|
const email = regexStringNode(/^[\w%+.-]+@[\d.A-Za-z-]+\.[A-Za-z]{2,}$/, "an email address", "email");
|
|
7096
7080
|
const ipv4Segment = "(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])";
|
|
7097
7081
|
const ipv4Address = `(${ipv4Segment}[.]){3}${ipv4Segment}`;
|
|
7098
|
-
const ipv4Matcher =
|
|
7082
|
+
const ipv4Matcher = new RegExp(`^${ipv4Address}$`);
|
|
7099
7083
|
const ipv6Segment = "(?:[0-9a-fA-F]{1,4})";
|
|
7100
|
-
const ipv6Matcher =
|
|
7084
|
+
const ipv6Matcher = new RegExp(`^((?:${ipv6Segment}:){7}(?:${ipv6Segment}|:)|(?:${ipv6Segment}:){6}(?:${ipv4Address}|:${ipv6Segment}|:)|(?:${ipv6Segment}:){5}(?::${ipv4Address}|(:${ipv6Segment}){1,2}|:)|(?:${ipv6Segment}:){4}(?:(:${ipv6Segment}){0,1}:${ipv4Address}|(:${ipv6Segment}){1,3}|:)|(?:${ipv6Segment}:){3}(?:(:${ipv6Segment}){0,2}:${ipv4Address}|(:${ipv6Segment}){1,4}|:)|(?:${ipv6Segment}:){2}(?:(:${ipv6Segment}){0,3}:${ipv4Address}|(:${ipv6Segment}){1,5}|:)|(?:${ipv6Segment}:){1}(?:(:${ipv6Segment}){0,4}:${ipv4Address}|(:${ipv6Segment}){1,6}|:)|(?::((?::${ipv6Segment}){0,5}:${ipv4Address}|(?::${ipv6Segment}){1,7}|:)))(%[0-9a-zA-Z.]{1,})?\$`);
|
|
7101
7085
|
const ip = Scope.module({
|
|
7102
7086
|
root: [
|
|
7103
7087
|
"v4 | v6",
|
|
@@ -7287,21 +7271,22 @@ const uuid = Scope.module({
|
|
|
7287
7271
|
],
|
|
7288
7272
|
"#nil": "'00000000-0000-0000-0000-000000000000'",
|
|
7289
7273
|
"#max": "'ffffffff-ffff-ffff-ffff-ffffffffffff'",
|
|
7290
|
-
"#versioned":
|
|
7291
|
-
v1: regexStringNode(/^[\
|
|
7292
|
-
v2: regexStringNode(/^[\
|
|
7293
|
-
v3: regexStringNode(/^[\
|
|
7294
|
-
v4: regexStringNode(/^[\
|
|
7295
|
-
v5: regexStringNode(/^[\
|
|
7296
|
-
v6: regexStringNode(/^[\
|
|
7297
|
-
v7: regexStringNode(/^[\
|
|
7298
|
-
v8: regexStringNode(/^[\
|
|
7274
|
+
"#versioned": /^[\dA-Fa-f]{8}-[\dA-Fa-f]{4}-[1-8][\dA-Fa-f]{3}-[89ABab][\dA-Fa-f]{3}-[\dA-Fa-f]{12}$/,
|
|
7275
|
+
v1: regexStringNode(/^[\dA-Fa-f]{8}-[\dA-Fa-f]{4}-1[\dA-Fa-f]{3}-[89ABab][\dA-Fa-f]{3}-[\dA-Fa-f]{12}$/, "a UUIDv1"),
|
|
7276
|
+
v2: regexStringNode(/^[\dA-Fa-f]{8}-[\dA-Fa-f]{4}-2[\dA-Fa-f]{3}-[89ABab][\dA-Fa-f]{3}-[\dA-Fa-f]{12}$/, "a UUIDv2"),
|
|
7277
|
+
v3: regexStringNode(/^[\dA-Fa-f]{8}-[\dA-Fa-f]{4}-3[\dA-Fa-f]{3}-[89ABab][\dA-Fa-f]{3}-[\dA-Fa-f]{12}$/, "a UUIDv3"),
|
|
7278
|
+
v4: regexStringNode(/^[\dA-Fa-f]{8}-[\dA-Fa-f]{4}-4[\dA-Fa-f]{3}-[89ABab][\dA-Fa-f]{3}-[\dA-Fa-f]{12}$/, "a UUIDv4"),
|
|
7279
|
+
v5: regexStringNode(/^[\dA-Fa-f]{8}-[\dA-Fa-f]{4}-5[\dA-Fa-f]{3}-[89ABab][\dA-Fa-f]{3}-[\dA-Fa-f]{12}$/, "a UUIDv5"),
|
|
7280
|
+
v6: regexStringNode(/^[\dA-Fa-f]{8}-[\dA-Fa-f]{4}-6[\dA-Fa-f]{3}-[89ABab][\dA-Fa-f]{3}-[\dA-Fa-f]{12}$/, "a UUIDv6"),
|
|
7281
|
+
v7: regexStringNode(/^[\dA-Fa-f]{8}-[\dA-Fa-f]{4}-7[\dA-Fa-f]{3}-[89ABab][\dA-Fa-f]{3}-[\dA-Fa-f]{12}$/, "a UUIDv7"),
|
|
7282
|
+
v8: regexStringNode(/^[\dA-Fa-f]{8}-[\dA-Fa-f]{4}-8[\dA-Fa-f]{3}-[89ABab][\dA-Fa-f]{3}-[\dA-Fa-f]{12}$/, "a UUIDv8")
|
|
7299
7283
|
}, { name: "string.uuid" });
|
|
7300
7284
|
const string = Scope.module({
|
|
7301
7285
|
root: intrinsic.string,
|
|
7302
7286
|
alpha: regexStringNode(/^[A-Za-z]*$/, "only letters"),
|
|
7303
7287
|
alphanumeric: regexStringNode(/^[\dA-Za-z]*$/, "only letters and digits 0-9"),
|
|
7304
7288
|
hex,
|
|
7289
|
+
base58,
|
|
7305
7290
|
base64,
|
|
7306
7291
|
capitalize,
|
|
7307
7292
|
creditCard,
|
|
@@ -7321,9 +7306,8 @@ const string = Scope.module({
|
|
|
7321
7306
|
url,
|
|
7322
7307
|
uuid
|
|
7323
7308
|
}, { name: "string" });
|
|
7324
|
-
|
|
7325
7309
|
//#endregion
|
|
7326
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
7310
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/keywords/ts.js
|
|
7327
7311
|
const arkTsKeywords = Scope.module({
|
|
7328
7312
|
bigint: intrinsic.bigint,
|
|
7329
7313
|
boolean: intrinsic.boolean,
|
|
@@ -7397,9 +7381,8 @@ const arkTsGenerics = Scope.module({
|
|
|
7397
7381
|
Record,
|
|
7398
7382
|
Required
|
|
7399
7383
|
});
|
|
7400
|
-
|
|
7401
7384
|
//#endregion
|
|
7402
|
-
//#region node_modules/.pnpm/arktype@2.
|
|
7385
|
+
//#region node_modules/.pnpm/arktype@2.2.8/node_modules/arktype/out/keywords/keywords.js
|
|
7403
7386
|
const ark = scope({
|
|
7404
7387
|
...arkTsKeywords,
|
|
7405
7388
|
...arkTsGenerics,
|
|
@@ -7434,17 +7417,15 @@ $arkTypeRegistry.typeAttachments = {
|
|
|
7434
7417
|
Array: keywords.Array.root,
|
|
7435
7418
|
Date: keywords.Date
|
|
7436
7419
|
};
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7420
|
+
Object.assign(ark.type, $arkTypeRegistry.typeAttachments);
|
|
7421
|
+
ark.match;
|
|
7422
|
+
ark.fn;
|
|
7423
|
+
ark.generic;
|
|
7424
|
+
ark.schema;
|
|
7425
|
+
ark.define;
|
|
7426
|
+
ark.declare;
|
|
7445
7427
|
//#endregion
|
|
7446
7428
|
//#region src/arktypeConfig.ts
|
|
7447
7429
|
const type = scope({}, { jitless: true }).type;
|
|
7448
|
-
|
|
7449
7430
|
//#endregion
|
|
7450
|
-
export { type as t };
|
|
7431
|
+
export { type as t };
|