arktype 3.0.0-beta.1 → 3.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -144
- package/out/_internal/regex/charset.d.ts +24 -0
- package/out/_internal/regex/escape.d.ts +29 -0
- package/out/_internal/regex/execArray.d.ts +24 -0
- package/out/_internal/regex/group.d.ts +34 -0
- package/out/_internal/regex/index.d.ts +2 -0
- package/out/_internal/regex/internal.d.ts +9 -0
- package/out/_internal/regex/parse.d.ts +10 -0
- package/out/_internal/regex/quantify.d.ts +59 -0
- package/out/_internal/regex/regex.d.ts +38 -0
- package/out/_internal/regex/state.d.ts +383 -0
- package/out/_internal/schema/codecs.d.ts +2 -0
- package/out/_internal/schema/config.d.ts +103 -0
- package/out/_internal/schema/constraint.d.ts +78 -0
- package/out/_internal/schema/errors.d.ts +1 -0
- package/out/_internal/schema/generic.d.ts +85 -0
- package/out/_internal/schema/i18n.d.ts +3 -0
- package/out/_internal/schema/index.d.ts +54 -0
- package/out/_internal/schema/internal.d.ts +15 -0
- package/out/_internal/schema/intrinsic.d.ts +28 -0
- package/out/_internal/schema/kinds.d.ts +76 -0
- package/out/_internal/schema/module.d.ts +23 -0
- package/out/_internal/schema/mutatesInput.d.ts +2 -0
- package/out/_internal/schema/node.d.ts +349 -0
- package/out/_internal/schema/parse.d.ts +77 -0
- package/out/_internal/schema/parseSchema.d.ts +116 -0
- package/out/_internal/schema/predicate.d.ts +46 -0
- package/out/_internal/schema/refinements/after.d.ts +32 -0
- package/out/_internal/schema/refinements/before.d.ts +32 -0
- package/out/_internal/schema/refinements/divisor.d.ts +41 -0
- package/out/_internal/schema/refinements/exactLength.d.ts +43 -0
- package/out/_internal/schema/refinements/kinds.d.ts +40 -0
- package/out/_internal/schema/refinements/max.d.ts +33 -0
- package/out/_internal/schema/refinements/maxLength.d.ts +32 -0
- package/out/_internal/schema/refinements/min.d.ts +33 -0
- package/out/_internal/schema/refinements/minLength.d.ts +32 -0
- package/out/_internal/schema/refinements/notEqual.d.ts +38 -0
- package/out/_internal/schema/refinements/notEqualLength.d.ts +38 -0
- package/out/_internal/schema/refinements/pattern.d.ts +43 -0
- package/out/_internal/schema/refinements/range.d.ts +101 -0
- package/out/_internal/schema/roots/alias.d.ts +49 -0
- package/out/_internal/schema/roots/basis.d.ts +12 -0
- package/out/_internal/schema/roots/domain.d.ts +45 -0
- package/out/_internal/schema/roots/intersection.d.ts +72 -0
- package/out/_internal/schema/roots/morph.d.ts +59 -0
- package/out/_internal/schema/roots/proto.d.ts +42 -0
- package/out/_internal/schema/roots/root.d.ts +163 -0
- package/out/_internal/schema/roots/union.d.ts +146 -0
- package/out/_internal/schema/roots/unit.d.ts +36 -0
- package/out/_internal/schema/runtime.d.ts +29 -0
- package/out/_internal/schema/runtimeLean.d.ts +2 -0
- package/out/_internal/schema/runtimeNone.d.ts +2 -0
- package/out/_internal/schema/runtimeNoneLean.d.ts +2 -0
- package/out/_internal/schema/scope.d.ts +203 -0
- package/out/_internal/schema/shared/codecs.d.ts +5 -0
- package/out/_internal/schema/shared/compile.d.ts +144 -0
- package/out/_internal/schema/shared/configured.d.ts +14 -0
- package/out/_internal/schema/shared/declare.d.ts +100 -0
- package/out/_internal/schema/shared/disjoint.d.ts +45 -0
- package/out/_internal/schema/shared/enWriters.d.ts +30 -0
- package/out/_internal/schema/shared/errorModes.d.ts +25 -0
- package/out/_internal/schema/shared/errorWriters.d.ts +34 -0
- package/out/_internal/schema/shared/errors.d.ts +264 -0
- package/out/_internal/schema/shared/implement.d.ts +154 -0
- package/out/_internal/schema/shared/inPlace.d.ts +8 -0
- package/out/_internal/schema/shared/issueFeatures.d.ts +38 -0
- package/out/_internal/schema/shared/issues.d.ts +261 -0
- package/out/_internal/schema/shared/issuesLean.d.ts +80 -0
- package/out/_internal/schema/shared/issuesNone.d.ts +22 -0
- package/out/_internal/schema/shared/issuesNoneLean.d.ts +20 -0
- package/out/_internal/schema/shared/issuesUndetailed.d.ts +25 -0
- package/out/_internal/schema/shared/jsonSchema.d.ts +153 -0
- package/out/_internal/schema/shared/listed.d.ts +15 -0
- package/out/_internal/schema/shared/locale.d.ts +149 -0
- package/out/_internal/schema/shared/registry.d.ts +16 -0
- package/out/_internal/schema/shared/render.d.ts +3 -0
- package/out/_internal/schema/shared/rootApply.d.ts +19 -0
- package/out/_internal/schema/shared/sets.d.ts +26 -0
- package/out/_internal/schema/shared/standardFailure.d.ts +22 -0
- package/out/_internal/schema/shared/standardSchema.d.ts +124 -0
- package/out/_internal/schema/shared/toJsonSchema.d.ts +229 -0
- package/out/_internal/schema/shared/transform.d.ts +35 -0
- package/out/_internal/schema/shared/traversal.d.ts +288 -0
- package/out/_internal/schema/shared/utils.d.ts +59 -0
- package/out/_internal/schema/structure/index.d.ts +43 -0
- package/out/_internal/schema/structure/optional.d.ts +61 -0
- package/out/_internal/schema/structure/prop.d.ts +45 -0
- package/out/_internal/schema/structure/required.d.ts +49 -0
- package/out/_internal/schema/structure/sequence.d.ts +127 -0
- package/out/_internal/schema/structure/shared.d.ts +3 -0
- package/out/_internal/schema/structure/structure.d.ts +178 -0
- package/out/_internal/schema/units.d.ts +123 -0
- package/out/_internal/sets/algebra.d.ts +26 -0
- package/out/_internal/sets/constraint.d.ts +19 -0
- package/out/_internal/sets/engine.d.ts +2 -0
- package/out/_internal/sets/formats.d.ts +23 -0
- package/out/_internal/sets/fromJsonSchema.d.ts +15 -0
- package/out/_internal/sets/implement.d.ts +16 -0
- package/out/_internal/sets/index.d.ts +2 -0
- package/out/_internal/sets/internal.d.ts +20 -0
- package/out/_internal/sets/intersections.d.ts +5 -0
- package/out/_internal/sets/kinds.d.ts +3 -0
- package/out/_internal/sets/refinements.d.ts +14 -0
- package/out/_internal/sets/roots/alias.d.ts +3 -0
- package/out/_internal/sets/roots/domain.d.ts +3 -0
- package/out/_internal/sets/roots/intersection.d.ts +4 -0
- package/out/_internal/sets/roots/morph.d.ts +4 -0
- package/out/_internal/sets/roots/proto.d.ts +3 -0
- package/out/_internal/sets/roots/union.d.ts +16 -0
- package/out/_internal/sets/roots/unit.d.ts +3 -0
- package/out/_internal/sets/structure/index.d.ts +3 -0
- package/out/_internal/sets/structure/prop.d.ts +8 -0
- package/out/_internal/sets/structure/sequence.d.ts +3 -0
- package/out/_internal/sets/structure/structure.d.ts +3 -0
- package/out/_internal/sets/toJsonSchema.d.ts +25 -0
- package/out/_internal/util/arrays.d.ts +130 -0
- package/out/_internal/util/clone.d.ts +4 -0
- package/out/_internal/util/describe.d.ts +25 -0
- package/out/_internal/util/domain.d.ts +49 -0
- package/out/_internal/util/errors.d.ts +29 -0
- package/out/_internal/util/facts.d.ts +22 -0
- package/out/_internal/util/flatMorph.d.ts +41 -0
- package/out/_internal/util/formats.d.ts +8 -0
- package/out/_internal/util/functions.d.ts +33 -0
- package/out/_internal/util/generics.d.ts +65 -0
- package/out/_internal/util/get.d.ts +9 -0
- package/out/_internal/util/hkt.d.ts +27 -0
- package/out/_internal/util/i18n.d.ts +12 -0
- package/out/_internal/util/index.d.ts +28 -0
- package/out/_internal/util/internal.d.ts +2 -0
- package/out/_internal/util/intersections.d.ts +50 -0
- package/out/_internal/util/isomorphic.d.ts +8 -0
- package/out/_internal/util/keys.d.ts +18 -0
- package/out/_internal/util/lazily.d.ts +7 -0
- package/out/_internal/util/numbers.d.ts +82 -0
- package/out/_internal/util/objectKinds.d.ts +157 -0
- package/out/_internal/util/path.d.ts +16 -0
- package/out/_internal/util/primitive.d.ts +16 -0
- package/out/_internal/util/records.d.ts +173 -0
- package/out/_internal/util/registry.d.ts +13 -0
- package/out/_internal/util/scanner.d.ts +110 -0
- package/out/_internal/util/serialize.d.ts +40 -0
- package/out/_internal/util/strings.d.ts +35 -0
- package/out/_internal/util/traits.d.ts +89 -0
- package/out/_internal/util/unionToTuple.d.ts +14 -0
- package/out/_internal/util/weak.d.ts +8 -0
- package/out/attributes.d.ts +15 -11
- package/out/checkers.d.ts +1 -1
- package/out/chunk-22RQSVV3.js +0 -0
- package/out/chunk-3HZC67MT.js +965 -0
- package/out/chunk-3KBOPH3J.js +1564 -0
- package/out/chunk-3SH2BQ4T.js +15 -0
- package/out/chunk-46PLKNON.js +126 -0
- package/out/{chunk-G45P2CLE.js → chunk-4FTHWK63.js} +6 -1
- package/out/{chunk-UK5UGFOX.js → chunk-4HREHNIV.js} +23 -11
- package/out/chunk-4NZCLVBD.js +14 -0
- package/out/chunk-6FMBO47M.js +7 -0
- package/out/chunk-7TALAWYX.js +10 -0
- package/out/{chunk-DLWCO4RV.js → chunk-BCYKO54Z.js} +11 -2
- package/out/chunk-BDJVONP7.js +168 -0
- package/out/{chunk-E3DZXEZK.js → chunk-C2JOL5M2.js} +4 -2
- package/out/{chunk-2U2AWCI3.js → chunk-C2V6QPE3.js} +126 -97
- package/out/chunk-C3B4IFQL.js +6408 -0
- package/out/chunk-CWSF57VM.js +10 -0
- package/out/chunk-F5BACUJS.js +7 -0
- package/out/{chunk-EVCML554.js → chunk-FWRSDUJ2.js} +14 -5
- package/out/chunk-GID3FSQA.js +161 -0
- package/out/chunk-I2KLQ2HA.js +22 -0
- package/out/chunk-K7SLP5D2.js +84 -0
- package/out/chunk-KQPSKGUI.js +9 -0
- package/out/chunk-KXOC3JEX.js +8234 -0
- package/out/chunk-KXOSUYRA.js +405 -0
- package/out/chunk-LHNEY6QW.js +0 -0
- package/out/chunk-MTWKGAGO.js +323 -0
- package/out/chunk-NU73GNCX.js +170 -0
- package/out/{chunk-RAZ3TXOE.js → chunk-P5W67FQH.js} +34 -19
- package/out/chunk-PDLTEX6Z.js +1118 -0
- package/out/{chunk-VV6YDN2D.js → chunk-QUS4IAXJ.js} +304 -263
- package/out/chunk-R7WXIH5P.js +94 -0
- package/out/chunk-TACLEIDM.js +95 -0
- package/out/chunk-UJJGG4VQ.js +71 -0
- package/out/chunk-US6BWOGJ.js +109 -0
- package/out/chunk-VMMMOO4R.js +945 -0
- package/out/chunk-VYMXHSFR.js +439 -0
- package/out/chunk-W2XOI5DY.js +141 -0
- package/out/chunk-WC5L5YRP.js +25 -0
- package/out/{chunk-NRIGTMPM.js → chunk-WKOSL2G6.js} +4 -1
- package/out/chunk-XLG66ZDF.js +0 -0
- package/out/{chunk-5U2ZMDNI.js → chunk-XNUAQSJ4.js} +52 -30
- package/out/chunk-ZRYEHGSG.js +79 -0
- package/out/cli.d.ts +28 -0
- package/out/cli.js +636 -0
- package/out/codecs.d.ts +6 -5
- package/out/codecs.js +23 -7
- package/out/config.d.ts +5 -17
- package/out/config.js +11 -2
- package/out/declare.d.ts +40 -12
- package/out/deferred.d.ts +2 -2
- package/out/errors.d.ts +1 -1
- package/out/errors.js +10 -2
- package/out/fn.d.ts +20 -13
- package/out/fromJsonSchema.d.ts +18 -0
- package/out/generic.d.ts +9 -6
- package/out/i18n.d.ts +2 -2
- package/out/i18n.js +9 -2
- package/out/index.d.ts +16 -7
- package/out/index.js +25 -8
- package/out/internal.d.ts +4 -0
- package/out/internal.js +41 -17
- package/out/island.js +22 -6
- package/out/islandDependency.js +42 -18
- package/out/jsonSchema/infer.d.ts +805 -0
- package/out/jsonSchema/validate.d.ts +416 -0
- package/out/keywords/Array.d.ts +2 -2
- package/out/keywords/builtins.d.ts +3 -3
- package/out/keywords/constructors.d.ts +1 -1
- package/out/keywords/functions.d.ts +5 -192
- package/out/keywords/keywords.d.ts +3 -3
- package/out/keywords/number.d.ts +2 -2
- package/out/keywords/phrases.d.ts +4 -191
- package/out/keywords/string.d.ts +3 -3
- package/out/keywords/ts.d.ts +18 -18
- package/out/keywords/ts.js +19 -4
- package/out/locale.d.ts +6 -2
- package/out/locales/de.js +9 -2
- package/out/locales/en.js +21 -5
- package/out/match.d.ts +13 -10
- package/out/module.d.ts +2 -2
- package/out/mutatesInput.js +18 -3
- package/out/nary.d.ts +220 -194
- package/out/parser/ast/bounds.d.ts +2 -2
- package/out/parser/ast/default.d.ts +2 -2
- package/out/parser/ast/divisor.d.ts +2 -2
- package/out/parser/ast/generic.d.ts +2 -2
- package/out/parser/ast/infer.d.ts +1 -1
- package/out/parser/ast/keyof.d.ts +2 -2
- package/out/parser/ast/utils.d.ts +1 -1
- package/out/parser/ast/validate.d.ts +2 -2
- package/out/parser/definition.d.ts +4 -4
- package/out/parser/objectLiteral.d.ts +2 -2
- package/out/parser/property.d.ts +2 -2
- package/out/parser/reduce/dynamic.d.ts +2 -2
- package/out/parser/reduce/shared.d.ts +1 -1
- package/out/parser/reduce/static.d.ts +1 -1
- package/out/parser/shift/operand/enclosed.d.ts +2 -2
- package/out/parser/shift/operand/genericArgs.d.ts +2 -2
- package/out/parser/shift/operand/operand.d.ts +1 -1
- package/out/parser/shift/operand/unenclosed.d.ts +2 -2
- package/out/parser/shift/operand/unresolvable.d.ts +2 -2
- package/out/parser/shift/operator/bounds.d.ts +2 -2
- package/out/parser/shift/operator/brand.d.ts +2 -2
- package/out/parser/shift/operator/default.d.ts +4 -4
- package/out/parser/shift/operator/divisor.d.ts +1 -1
- package/out/parser/shift/operator/operator.d.ts +1 -1
- package/out/parser/shift/tokens.d.ts +1 -1
- package/out/parser/string.d.ts +2 -2
- package/out/parser/tupleExpressions.d.ts +6 -8
- package/out/parser/tupleLiteral.d.ts +2 -2
- package/out/precompiled.d.ts +1 -1
- package/out/precompiled.js +16 -2
- package/out/regex.d.ts +1 -0
- package/out/regex.js +2 -0
- package/out/runtime.d.ts +10 -8
- package/out/runtime.js +6 -4
- package/out/runtimeDevelopment.js +70 -52
- package/out/schema.d.ts +1 -0
- package/out/schema.js +15 -0
- package/out/schemaInternal.d.ts +1 -0
- package/out/schemaInternal.js +1401 -0
- package/out/schemaIssueFeatures.d.ts +1 -0
- package/out/schemaRuntime.d.ts +1 -0
- package/out/schemaRuntime.js +7 -0
- package/out/schemaRuntimeLean.d.ts +1 -0
- package/out/schemaRuntimeLean.js +1870 -0
- package/out/schemaRuntimeNone.d.ts +1 -0
- package/out/schemaRuntimeNone.js +1774 -0
- package/out/schemaRuntimeNoneLean.d.ts +1 -0
- package/out/schemaRuntimeNoneLean.js +1767 -0
- package/out/scope.d.ts +3 -4
- package/out/shared/issueFeatures.d.ts +38 -0
- package/out/shared/issueFeatures.js +40 -0
- package/out/standalone/artifact.d.ts +6 -6
- package/out/standalone/baking.d.ts +2 -2
- package/out/standalone/combinators.d.ts +1 -1
- package/out/standalone/compilers.d.ts +1 -1
- package/out/standalone/fallbacks.d.ts +1 -1
- package/out/standalone/keys.d.ts +1 -1
- package/out/standalone/sites.d.ts +3 -3
- package/out/standalone/units.d.ts +1 -1
- package/out/standalone/values.d.ts +1 -1
- package/out/type.d.ts +6 -6
- package/out/util.d.ts +1 -0
- package/out/util.js +137 -0
- package/out/variants/array.d.ts +6 -6
- package/out/variants/base.d.ts +61 -10
- package/out/variants/date.d.ts +5 -5
- package/out/variants/instantiate.d.ts +1 -1
- package/out/variants/number.d.ts +6 -6
- package/out/variants/object.d.ts +25 -12
- package/out/variants/string.d.ts +8 -8
- package/package.json +183 -8
- package/skills/arktype/SKILL.md +93 -93
- package/skills/arktype/references/migrating.md +144 -158
- package/skills/arktype/references/precompile.md +7 -7
- package/out/chunk-4CUA5XIP.js +0 -7
- package/out/chunk-GPNK5353.js +0 -2529
- package/out/chunk-MLKGABMK.js +0 -9
- package/out/chunk-PRTMQCHS.js +0 -3
- package/out/chunk-R5G57XC7.js +0 -7
- package/out/chunk-SWOOCAHN.js +0 -4
- package/out/chunk-TAHPKDNM.js +0 -3
- package/out/chunk-UETB6YE2.js +0 -14
|
@@ -0,0 +1,1774 @@
|
|
|
1
|
+
// ../util/out/arrays.js
|
|
2
|
+
var includes = (array, element) => array.includes(element);
|
|
3
|
+
|
|
4
|
+
// ../util/out/domain.js
|
|
5
|
+
var hasDomain = (data, kind) => domainOf(data) === kind;
|
|
6
|
+
var domainOf = (data) => {
|
|
7
|
+
const builtinType = typeof data;
|
|
8
|
+
return builtinType === "object" ? data === null ? "null" : "object" : builtinType === "function" ? "object" : builtinType;
|
|
9
|
+
};
|
|
10
|
+
var domainDescriptions = {
|
|
11
|
+
boolean: "boolean",
|
|
12
|
+
null: "null",
|
|
13
|
+
undefined: "undefined",
|
|
14
|
+
bigint: "a bigint",
|
|
15
|
+
number: "a number",
|
|
16
|
+
object: "an object",
|
|
17
|
+
string: "a string",
|
|
18
|
+
symbol: "a symbol"
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// ../util/out/errors.js
|
|
22
|
+
var InternalArktypeError = class extends Error {
|
|
23
|
+
};
|
|
24
|
+
var throwInternalError = (message) => throwError(message, InternalArktypeError);
|
|
25
|
+
var throwError = (message, ctor = Error) => {
|
|
26
|
+
throw new ctor(message);
|
|
27
|
+
};
|
|
28
|
+
var ParseError = class extends Error {
|
|
29
|
+
name = "ParseError";
|
|
30
|
+
};
|
|
31
|
+
var throwParseError = (message) => throwError(message, ParseError);
|
|
32
|
+
var noSuggest = ((s) => ` ${s}`);
|
|
33
|
+
|
|
34
|
+
// ../util/out/facts.js
|
|
35
|
+
var arkKind = " arkKind";
|
|
36
|
+
var isDate = (value) => value instanceof Date;
|
|
37
|
+
var prototypeOf = (o) => Object.getPrototypeOf(o);
|
|
38
|
+
var arityOf = (fn) => {
|
|
39
|
+
const proto = Object.getPrototypeOf(fn);
|
|
40
|
+
return proto && Object.prototype.hasOwnProperty.call(proto, "traverse") ? 2 : fn.length;
|
|
41
|
+
};
|
|
42
|
+
var functionNameOf = (fn) => fn.name;
|
|
43
|
+
var constructorNameOf = (o) => o.constructor?.name;
|
|
44
|
+
var expressionOf = (o) => "expression" in o && typeof o.expression === "string" ? o.expression : void 0;
|
|
45
|
+
var toJsonMethodOf = (o) => {
|
|
46
|
+
const toJson = o.toJSON;
|
|
47
|
+
return typeof toJson === "function" ? toJson : void 0;
|
|
48
|
+
};
|
|
49
|
+
var ownEntriesOf = (o, opts) => {
|
|
50
|
+
const result = [];
|
|
51
|
+
for (const k of Reflect.ownKeys(o)) {
|
|
52
|
+
const descriptor = Object.getOwnPropertyDescriptor(o, k);
|
|
53
|
+
if (!descriptor.enumerable)
|
|
54
|
+
continue;
|
|
55
|
+
result.push([
|
|
56
|
+
k,
|
|
57
|
+
"value" in descriptor ? descriptor.value : opts.onAccessor ? opts.onAccessor(descriptor) : o[k]
|
|
58
|
+
]);
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// ../util/out/records.js
|
|
64
|
+
var isKeyOf = (k, o) => k in o;
|
|
65
|
+
var hasOwn = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
|
|
66
|
+
var hasKey = (o, k) => k in o;
|
|
67
|
+
var isEmptyObject = (o) => {
|
|
68
|
+
for (const k in o)
|
|
69
|
+
if (hasOwn(o, k))
|
|
70
|
+
return false;
|
|
71
|
+
return true;
|
|
72
|
+
};
|
|
73
|
+
var defineProperties = ((base, merged) => (
|
|
74
|
+
// declared like this to avoid https://github.com/microsoft/TypeScript/issues/55049
|
|
75
|
+
Object.defineProperties(base, Object.getOwnPropertyDescriptors(merged))
|
|
76
|
+
));
|
|
77
|
+
var defineValue = (o, k, value) => Object.defineProperty(o, k, {
|
|
78
|
+
value,
|
|
79
|
+
writable: true,
|
|
80
|
+
enumerable: true,
|
|
81
|
+
configurable: true
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// ../util/out/objectKinds.js
|
|
85
|
+
var ecmascriptConstructorsOf = () => ({
|
|
86
|
+
Array,
|
|
87
|
+
Boolean,
|
|
88
|
+
Date,
|
|
89
|
+
Error,
|
|
90
|
+
Function,
|
|
91
|
+
Map,
|
|
92
|
+
Number,
|
|
93
|
+
Promise,
|
|
94
|
+
RegExp,
|
|
95
|
+
Set,
|
|
96
|
+
String,
|
|
97
|
+
WeakMap,
|
|
98
|
+
WeakSet
|
|
99
|
+
});
|
|
100
|
+
var platformConstructorsOf = () => ({
|
|
101
|
+
ArrayBuffer,
|
|
102
|
+
Blob: globalThis.Blob,
|
|
103
|
+
// Node loads a module for File, and undici for the rest, on first read
|
|
104
|
+
get File() {
|
|
105
|
+
return globalThis.File ?? globalThis.Blob;
|
|
106
|
+
},
|
|
107
|
+
get FormData() {
|
|
108
|
+
return globalThis.FormData;
|
|
109
|
+
},
|
|
110
|
+
get Headers() {
|
|
111
|
+
return globalThis.Headers;
|
|
112
|
+
},
|
|
113
|
+
get Request() {
|
|
114
|
+
return globalThis.Request;
|
|
115
|
+
},
|
|
116
|
+
get Response() {
|
|
117
|
+
return globalThis.Response;
|
|
118
|
+
},
|
|
119
|
+
URL: globalThis.URL
|
|
120
|
+
});
|
|
121
|
+
var typedArrayConstructorsOf = () => ({
|
|
122
|
+
Int8Array,
|
|
123
|
+
Uint8Array,
|
|
124
|
+
Uint8ClampedArray,
|
|
125
|
+
Int16Array,
|
|
126
|
+
Uint16Array,
|
|
127
|
+
Int32Array,
|
|
128
|
+
Uint32Array,
|
|
129
|
+
Float32Array,
|
|
130
|
+
Float64Array,
|
|
131
|
+
BigInt64Array,
|
|
132
|
+
BigUint64Array
|
|
133
|
+
});
|
|
134
|
+
var builtins;
|
|
135
|
+
var builtinsOf = () => builtins ??= defineProperties(defineProperties(Object.assign({}, ecmascriptConstructorsOf()), platformConstructorsOf()), typedArrayConstructorsOf());
|
|
136
|
+
var objectKindOf = (data) => {
|
|
137
|
+
if (Array.isArray(data))
|
|
138
|
+
return "Array";
|
|
139
|
+
let prototype = prototypeOf(data);
|
|
140
|
+
if (prototype === Object.prototype)
|
|
141
|
+
return void 0;
|
|
142
|
+
const constructors = builtinsOf();
|
|
143
|
+
while (prototype?.constructor && (!hasOwn(constructors, prototype.constructor.name) || constructors[prototype.constructor.name]?.prototype !== prototype))
|
|
144
|
+
prototype = Object.getPrototypeOf(prototype);
|
|
145
|
+
const name = prototype?.constructor?.name;
|
|
146
|
+
if (name === void 0 || name === "Object")
|
|
147
|
+
return void 0;
|
|
148
|
+
return name;
|
|
149
|
+
};
|
|
150
|
+
var objectKindOrDomainOf = (data) => typeof data === "object" && data !== null ? objectKindOf(data) ?? "object" : domainOf(data);
|
|
151
|
+
var isArray = /* @__PURE__ */ (() => Array.isArray)();
|
|
152
|
+
var dateGetTime = /* @__PURE__ */ (() => Date.prototype.getTime)();
|
|
153
|
+
var timeOf = (date) => {
|
|
154
|
+
try {
|
|
155
|
+
return date.getTime === dateGetTime ? date.getTime() : dateGetTime.call(date);
|
|
156
|
+
} catch {
|
|
157
|
+
return void 0;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
var isValidDate = (date) => {
|
|
161
|
+
try {
|
|
162
|
+
return !Number.isNaN(date.getTime === dateGetTime ? date.getTime() : dateGetTime.call(date));
|
|
163
|
+
} catch {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// ../util/out/functions.js
|
|
169
|
+
var isThunk = (value) => typeof value === "function" && arityOf(value) === 0;
|
|
170
|
+
|
|
171
|
+
// ../util/out/i18n.js
|
|
172
|
+
var listPattern = (or, and) => (items, type) => {
|
|
173
|
+
const pattern = type === "or" ? or : and;
|
|
174
|
+
if (items.length < 2)
|
|
175
|
+
return items[0] ?? "";
|
|
176
|
+
if (items.length === 2)
|
|
177
|
+
return `${items[0]}${pattern.two}${items[1]}`;
|
|
178
|
+
return `${items.slice(0, -1).join(pattern.middle)}${pattern.end}${items[items.length - 1]}`;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// ../util/out/primitive.js
|
|
182
|
+
var lastString;
|
|
183
|
+
var lastSerialized;
|
|
184
|
+
var serializePrimitive = (value) => typeof value === "string" ? value === lastString ? lastSerialized : lastSerialized = JSON.stringify(lastString = value) : typeof value === "bigint" ? `${value}n` : `${value}`;
|
|
185
|
+
|
|
186
|
+
// ../util/out/serialize.js
|
|
187
|
+
var printable = (data, opts) => {
|
|
188
|
+
switch (domainOf(data)) {
|
|
189
|
+
case "object":
|
|
190
|
+
const o = data;
|
|
191
|
+
const ctorName = constructorNameOf(o) ?? "Object";
|
|
192
|
+
const serializationOpts = opts?.ownDataOnly ? ownDataPrintableOpts : printableOpts;
|
|
193
|
+
return ctorName === "Object" || ctorName === "Array" ? opts?.quoteKeys === false ? stringifyUnquoted(o, opts?.indent ?? 0, "", serializationOpts) : JSON.stringify(_serialize(o, serializationOpts, []), null, opts?.indent).replace(quotedMarkedValue, "$1") : stringifyUnquoted(o, opts?.indent ?? 0, "", serializationOpts);
|
|
194
|
+
case "symbol":
|
|
195
|
+
return printableOpts.onSymbol(data);
|
|
196
|
+
default:
|
|
197
|
+
return serializePrimitive(data);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
var printKind = (data) => typeof data === "function" ? "a function" : typeof data === "symbol" ? printSymbol(data) : typeof data !== "object" || data === null ? serializePrimitive(data) : isArray(data) ? "an array" : "an object";
|
|
201
|
+
var stringifyUnquoted = (value, indent, currentIndent, opts) => {
|
|
202
|
+
if (typeof value === "function")
|
|
203
|
+
return printableOpts.onFunction(value);
|
|
204
|
+
if (typeof value === "symbol")
|
|
205
|
+
return printableOpts.onSymbol(value);
|
|
206
|
+
if (typeof value !== "object" || value === null)
|
|
207
|
+
return serializePrimitive(value);
|
|
208
|
+
const nextIndent = currentIndent + " ".repeat(indent);
|
|
209
|
+
if (isArray(value)) {
|
|
210
|
+
if (value.length === 0)
|
|
211
|
+
return "[]";
|
|
212
|
+
const items = value.map((item) => stringifyUnquoted(item, indent, nextIndent, opts)).join(",\n" + nextIndent);
|
|
213
|
+
return indent ? `[
|
|
214
|
+
${nextIndent}${items}
|
|
215
|
+
${currentIndent}]` : `[${items}]`;
|
|
216
|
+
}
|
|
217
|
+
const ctorName = constructorNameOf(value) ?? "Object";
|
|
218
|
+
if (ctorName === "Object") {
|
|
219
|
+
const keyValues = ownEntriesOf(value, opts).map(([key, val]) => {
|
|
220
|
+
const stringifiedKey = typeof key === "symbol" ? printableOpts.onSymbol(key) : isDotAccessible(key) ? key : JSON.stringify(key);
|
|
221
|
+
const stringifiedValue = stringifyUnquoted(val, indent, nextIndent, opts);
|
|
222
|
+
return `${nextIndent}${stringifiedKey}: ${stringifiedValue}`;
|
|
223
|
+
});
|
|
224
|
+
if (keyValues.length === 0)
|
|
225
|
+
return "{}";
|
|
226
|
+
return indent ? `{
|
|
227
|
+
${keyValues.join(",\n")}
|
|
228
|
+
${currentIndent}}` : `{${keyValues.join(", ")}}`;
|
|
229
|
+
}
|
|
230
|
+
if (isDate(value))
|
|
231
|
+
return describeCollapsibleDate(value);
|
|
232
|
+
return expressionOf(value) ?? ctorName;
|
|
233
|
+
};
|
|
234
|
+
var printSymbol = (symbol) => `Symbol(${baseNameOfSymbol(symbol)})`;
|
|
235
|
+
var printableOpts = {
|
|
236
|
+
onCycle: () => "(cycle)",
|
|
237
|
+
onSymbol: printSymbol,
|
|
238
|
+
onFunction: (v) => `Function(${baseNameOf(v)})`,
|
|
239
|
+
onBigInt: (n) => `${n}n`,
|
|
240
|
+
onUndefined: "undefined"
|
|
241
|
+
};
|
|
242
|
+
var ownDataPrintableOpts = /* @__PURE__ */ Object.assign({}, printableOpts, {
|
|
243
|
+
onAccessor: (descriptor) => descriptor.get ? "(getter)" : "(setter)"
|
|
244
|
+
});
|
|
245
|
+
var quotedMarkedValue = /"\uE000(-?\d+n|undefined)"/g;
|
|
246
|
+
var _serialize = (data, opts, seen) => {
|
|
247
|
+
switch (domainOf(data)) {
|
|
248
|
+
case "object": {
|
|
249
|
+
const o = data;
|
|
250
|
+
const toJson = !opts.onAccessor || isDate(o) ? toJsonMethodOf(o) : void 0;
|
|
251
|
+
if (toJson)
|
|
252
|
+
return Reflect.apply(toJson, o, []);
|
|
253
|
+
if (typeof o === "function")
|
|
254
|
+
return opts.onFunction?.(o) ?? printableOpts.onFunction(o);
|
|
255
|
+
if (seen.includes(o))
|
|
256
|
+
return opts.onCycle?.(o) ?? "(cycle)";
|
|
257
|
+
const nextSeen = [...seen, o];
|
|
258
|
+
if (isArray(o))
|
|
259
|
+
return o.map((item) => _serialize(item, opts, nextSeen));
|
|
260
|
+
if (isDate(o))
|
|
261
|
+
return o.toDateString();
|
|
262
|
+
const result = {};
|
|
263
|
+
for (const [k, v] of ownEntriesOf(o, opts)) {
|
|
264
|
+
const key = typeof k === "symbol" ? opts.onSymbol?.(k) ?? k.toString() : k;
|
|
265
|
+
defineValue(result, key, _serialize(v, opts, nextSeen));
|
|
266
|
+
}
|
|
267
|
+
return result;
|
|
268
|
+
}
|
|
269
|
+
case "symbol":
|
|
270
|
+
return opts.onSymbol?.(data) ?? printableOpts.onSymbol(data);
|
|
271
|
+
case "bigint":
|
|
272
|
+
return opts.onBigInt?.(data) ?? `${data}n`;
|
|
273
|
+
case "undefined":
|
|
274
|
+
return opts.onUndefined ?? "undefined";
|
|
275
|
+
case "string":
|
|
276
|
+
return data.replace(/\\/g, "\\\\");
|
|
277
|
+
default:
|
|
278
|
+
return data;
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
var describeCollapsibleDate = (date) => {
|
|
282
|
+
if (!isValidDate(date))
|
|
283
|
+
return "Invalid Date";
|
|
284
|
+
const year = date.getUTCFullYear();
|
|
285
|
+
const month = date.getUTCMonth();
|
|
286
|
+
const dayOfMonth = date.getUTCDate();
|
|
287
|
+
const hours = date.getUTCHours();
|
|
288
|
+
const minutes = date.getUTCMinutes();
|
|
289
|
+
const seconds = date.getUTCSeconds();
|
|
290
|
+
const milliseconds = date.getUTCMilliseconds();
|
|
291
|
+
if (hours === 0 && minutes === 0 && seconds === 0 && milliseconds === 0)
|
|
292
|
+
return `${months[month]} ${dayOfMonth}, ${year}`;
|
|
293
|
+
const h = hours % 12 || 12;
|
|
294
|
+
const suffix = hours < 12 ? " AM" : " PM";
|
|
295
|
+
let timePortion = seconds || milliseconds ? `${h}:${pad(minutes, 2)}:${pad(seconds, 2)}` : `${h}:${pad(minutes, 2)}`;
|
|
296
|
+
if (milliseconds)
|
|
297
|
+
timePortion += `.${pad(milliseconds, 3)}`;
|
|
298
|
+
return `${months[month]} ${dayOfMonth}, ${year}, ${timePortion + suffix} UTC`;
|
|
299
|
+
};
|
|
300
|
+
var months = [
|
|
301
|
+
"January",
|
|
302
|
+
"February",
|
|
303
|
+
"March",
|
|
304
|
+
"April",
|
|
305
|
+
"May",
|
|
306
|
+
"June",
|
|
307
|
+
"July",
|
|
308
|
+
"August",
|
|
309
|
+
"September",
|
|
310
|
+
"October",
|
|
311
|
+
"November",
|
|
312
|
+
"December"
|
|
313
|
+
];
|
|
314
|
+
var pad = (value, length) => String(value).padStart(length, "0");
|
|
315
|
+
var dotAccessibleKeys = /* @__PURE__ */ new Map();
|
|
316
|
+
var isDotAccessible = (keyName) => {
|
|
317
|
+
let accessible = dotAccessibleKeys.get(keyName);
|
|
318
|
+
if (accessible === void 0) {
|
|
319
|
+
accessible = /^[$A-Z_a-z][\w$]*$/.test(keyName);
|
|
320
|
+
if (keyName.length <= 64) {
|
|
321
|
+
if (dotAccessibleKeys.size === 1024)
|
|
322
|
+
dotAccessibleKeys.clear();
|
|
323
|
+
dotAccessibleKeys.set(keyName, accessible);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
return accessible;
|
|
327
|
+
};
|
|
328
|
+
var baseNameOf = (value) => {
|
|
329
|
+
switch (typeof value) {
|
|
330
|
+
case "object": {
|
|
331
|
+
if (value === null)
|
|
332
|
+
break;
|
|
333
|
+
const prefix = objectKindOf(value) ?? "object";
|
|
334
|
+
return prefix[0].toLowerCase() + prefix.slice(1);
|
|
335
|
+
}
|
|
336
|
+
case "function":
|
|
337
|
+
const name = functionNameOf(value);
|
|
338
|
+
return isDotAccessible(name) ? name : "fn";
|
|
339
|
+
case "symbol":
|
|
340
|
+
return baseNameOfSymbol(value);
|
|
341
|
+
}
|
|
342
|
+
return throwInternalError(`Unexpected attempt to register serializable value of type ${domainOf(value)}`);
|
|
343
|
+
};
|
|
344
|
+
var baseNameOfSymbol = (symbol) => symbol.description && isDotAccessible(symbol.description) ? symbol.description : "symbol";
|
|
345
|
+
|
|
346
|
+
// ../schema/out/shared/configured.js
|
|
347
|
+
var isPlain = (value) => {
|
|
348
|
+
const proto = Object.getPrototypeOf(value);
|
|
349
|
+
return proto === Object.prototype || proto === null;
|
|
350
|
+
};
|
|
351
|
+
var copyPlain = (value) => typeof value !== "object" || value === null ? value : Array.isArray(value) ? value.map(copyPlain) : isPlain(value) ? Object.fromEntries(Object.entries(value).map(([k, v]) => [k, copyPlain(v)])) : value;
|
|
352
|
+
var copyConfig = (config) => {
|
|
353
|
+
const copy = {};
|
|
354
|
+
for (const k in config) {
|
|
355
|
+
const v = config[k];
|
|
356
|
+
copy[k] = k === "locale" ? v : copyPlain(v);
|
|
357
|
+
}
|
|
358
|
+
return copy;
|
|
359
|
+
};
|
|
360
|
+
var isSameConfig = (l, r) => {
|
|
361
|
+
if (l === r)
|
|
362
|
+
return true;
|
|
363
|
+
if (typeof l === "function" && typeof r === "function") {
|
|
364
|
+
const source = Function.prototype.toString.call(l);
|
|
365
|
+
return source === Function.prototype.toString.call(r) && !/\[native code]\s*}$/.test(source);
|
|
366
|
+
}
|
|
367
|
+
if (typeof l !== "object" || typeof r !== "object" || !l || !r)
|
|
368
|
+
return false;
|
|
369
|
+
const entries = Object.entries(l);
|
|
370
|
+
return entries.length === Object.keys(r).length && entries.every(([k, v]) => Object.prototype.hasOwnProperty.call(r, k) && isSameConfig(v, r[k]));
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
// ../schema/out/shared/enWriters.js
|
|
374
|
+
var Stamp = class {
|
|
375
|
+
constructor(o) {
|
|
376
|
+
return o;
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
var DescribedActual = class extends Stamp {
|
|
380
|
+
#described = true;
|
|
381
|
+
static has(o) {
|
|
382
|
+
return #described in o;
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
var describeActual = (ctx) => {
|
|
386
|
+
if (!DescribedActual.has(ctx))
|
|
387
|
+
new DescribedActual(ctx);
|
|
388
|
+
};
|
|
389
|
+
var describeUnwrittenActual = (ctx) => {
|
|
390
|
+
try {
|
|
391
|
+
new DescribedActual(ctx);
|
|
392
|
+
} catch {
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
var printedActualOf = (ctx) => DescribedActual.has(ctx) ? "" : ctx.actual;
|
|
396
|
+
var writeMessage = (ctx) => {
|
|
397
|
+
const actual = printedActualOf(ctx);
|
|
398
|
+
return `must be ${ctx.expected}${actual ? ` (was ${actual})` : ""}`;
|
|
399
|
+
};
|
|
400
|
+
var writeLine = (ctx) => `${ctx.propString}${ctx.custom ? ":" : ""} ${ctx.message}`;
|
|
401
|
+
var writeUnitMessage = (ctx) => {
|
|
402
|
+
const actual = printedActualOf(ctx);
|
|
403
|
+
return !actual ? `must be ${ctx.expected}` : ctx.expected === actual ? `must be reference equal to ${ctx.expected} (serialized to the same value)` : `must be ${ctx.expected} (was ${actual})`;
|
|
404
|
+
};
|
|
405
|
+
var writeUnitActual = (data) => data instanceof Date && isValidDate(data) ? describeCollapsibleDate(data) : printKind(data);
|
|
406
|
+
var writeNotEqualActual = (data) => data instanceof Date ? describeCollapsibleDate(data) : printKind(data);
|
|
407
|
+
var writeDomainActual = (data) => typeof data === "number" && !Number.isFinite(data) ? String(data) : domainDescriptions[domainOf(data)];
|
|
408
|
+
var writeLengthActual = (data, e) => e.meta?.description === void 0 && e.meta?.expected === void 0 ? `${data.length}` : `length ${data.length}`;
|
|
409
|
+
var writeProtoActual = (data) => {
|
|
410
|
+
if (data instanceof Date && !isValidDate(data)) {
|
|
411
|
+
return timeOf(data) === void 0 ? domainDescriptions.object : "an invalid Date";
|
|
412
|
+
}
|
|
413
|
+
const kind = objectKindOrDomainOf(data);
|
|
414
|
+
return isKeyOf(kind, domainDescriptions) ? domainDescriptions[kind] : kind;
|
|
415
|
+
};
|
|
416
|
+
var enInfo = /* @__PURE__ */ Object.freeze({
|
|
417
|
+
tag: "en",
|
|
418
|
+
list: /* @__PURE__ */ listPattern({ two: " or ", middle: ", ", end: " or " }, { two: " and ", middle: ", ", end: " and " }),
|
|
419
|
+
plural: (n) => n === 1 ? "one" : "other",
|
|
420
|
+
number: String,
|
|
421
|
+
date: describeCollapsibleDate,
|
|
422
|
+
verbatim: (text) => text
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
// ../schema/out/runtime.js
|
|
426
|
+
export { appliesValues, discriminatesBooleans, failsInBranches, findsOnRead, holdsExpression, listsUnions, transformsBranches, traversesUnions } from "./shared/issueFeatures.js";
|
|
427
|
+
|
|
428
|
+
// ../schema/out/shared/issuesNone.js
|
|
429
|
+
import { namesTraversalError } from "./shared/issueFeatures.js";
|
|
430
|
+
|
|
431
|
+
// ../schema/out/shared/issuesUndetailed.js
|
|
432
|
+
import { bracketsKeys } from "./shared/issueFeatures.js";
|
|
433
|
+
var failsKey = (ctx, data, key, code, expected, missing = expected) => ctx._k((value, ctx2) => !ctx2._e(value, code, expected), data, key, missing);
|
|
434
|
+
var failsSite = (ctx, context, data) => ctx._e(data, context.code, context.description, context.x, context.text);
|
|
435
|
+
var failsKeySite = (ctx, site, data, key) => ctx._k((value, ctx2) => !failsSite(ctx2, site.v ?? site, value), data, key, ...missingTextOf(site.m));
|
|
436
|
+
var missingTextOf = (missing) => missing ? [missing.description, missing.x, missing.text] : [];
|
|
437
|
+
var applyIssues = () => throwInternalError('errors "none" applies no issues');
|
|
438
|
+
var issuesOf = () => throwInternalError('errors "none" finds no issues');
|
|
439
|
+
var foundErrors = issuesOf;
|
|
440
|
+
var throwIssues = issuesOf;
|
|
441
|
+
var throwOnDefault = (errors) => errors.throw();
|
|
442
|
+
var mergeIssues = (errors, merged, prefix) => {
|
|
443
|
+
for (const issue of merged._)
|
|
444
|
+
errors._.push(movedIssue(issue, [...prefix, ...issue.path]));
|
|
445
|
+
};
|
|
446
|
+
var movedIssue = (issue, path) => ({
|
|
447
|
+
...issue,
|
|
448
|
+
path
|
|
449
|
+
});
|
|
450
|
+
var pathOf = (issue) => {
|
|
451
|
+
let at = "";
|
|
452
|
+
for (const k of issue.path) {
|
|
453
|
+
at += bracketsKeys && !/^[$_a-z][\w$]*$/i.test(String(k)) ? `[${JSON.stringify(k) ?? String(k)}]` : typeof k === "number" ? `[${k}]` : (at && ".") + String(k);
|
|
454
|
+
}
|
|
455
|
+
return at;
|
|
456
|
+
};
|
|
457
|
+
var messageOf = () => "is invalid";
|
|
458
|
+
var lineOf = (issue) => {
|
|
459
|
+
const at = pathOf(issue);
|
|
460
|
+
return (at && at + " ") + (issue.message ?? "is invalid");
|
|
461
|
+
};
|
|
462
|
+
var isCustomIssue = () => false;
|
|
463
|
+
var codedIssue = (issue) => issue;
|
|
464
|
+
var notedAs = (issue, copy) => copy;
|
|
465
|
+
var issueOf = (path) => ({
|
|
466
|
+
code: "predicate",
|
|
467
|
+
path: path.slice(),
|
|
468
|
+
data: void 0,
|
|
469
|
+
expected: void 0
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
// ../schema/out/shared/issuesNone.js
|
|
473
|
+
var ArkErrors = class {
|
|
474
|
+
_ = [];
|
|
475
|
+
get [arkKind]() {
|
|
476
|
+
return "errors";
|
|
477
|
+
}
|
|
478
|
+
get count() {
|
|
479
|
+
return this._.length;
|
|
480
|
+
}
|
|
481
|
+
get issues() {
|
|
482
|
+
for (const issue of this._) {
|
|
483
|
+
issue.expected ??= "valid";
|
|
484
|
+
issue.message ??= "is invalid";
|
|
485
|
+
}
|
|
486
|
+
return this._.toJSON ? this._ : Object.defineProperty(this._, "toJSON", issuesToJson);
|
|
487
|
+
}
|
|
488
|
+
get summary() {
|
|
489
|
+
return this._.reduce((summary, issue) => summary + (summary && "\n") + lineOf(issue), "");
|
|
490
|
+
}
|
|
491
|
+
summaryIn() {
|
|
492
|
+
return this.summary;
|
|
493
|
+
}
|
|
494
|
+
// as issues.ts's: constructed by TraversalError wherever its bundle keeps
|
|
495
|
+
// the class, and otherwise an Error with the same name, message and errors
|
|
496
|
+
throw() {
|
|
497
|
+
if (namesTraversalError)
|
|
498
|
+
throw new ThrownErrors(this);
|
|
499
|
+
if (definedThrown)
|
|
500
|
+
throw new definedThrown(this);
|
|
501
|
+
const thrown = Error(this.summary);
|
|
502
|
+
thrown.name = "TraversalError";
|
|
503
|
+
throw Object.defineProperty(thrown, "arkErrors", { value: this });
|
|
504
|
+
}
|
|
505
|
+
// what it says and where, never its data, which may be private, a bigint
|
|
506
|
+
// or circular
|
|
507
|
+
toJSON() {
|
|
508
|
+
return this.issues.map(jsonIssueOf);
|
|
509
|
+
}
|
|
510
|
+
toString() {
|
|
511
|
+
return this.summary;
|
|
512
|
+
}
|
|
513
|
+
[Symbol.iterator]() {
|
|
514
|
+
return this.issues[Symbol.iterator]();
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
var jsonIssueOf = ({ code, path, expected, message }) => ({
|
|
518
|
+
code,
|
|
519
|
+
path: path.map((k) => typeof k === "symbol" ? String(k) : k),
|
|
520
|
+
...expected !== void 0 && { expected },
|
|
521
|
+
message
|
|
522
|
+
});
|
|
523
|
+
var issuesToJson = {
|
|
524
|
+
value() {
|
|
525
|
+
return this.map(jsonIssueOf);
|
|
526
|
+
},
|
|
527
|
+
writable: true,
|
|
528
|
+
configurable: true
|
|
529
|
+
};
|
|
530
|
+
var definedThrown;
|
|
531
|
+
var ThrownErrors = /* @__PURE__ */ (() => definedThrown = class TraversalError extends Error {
|
|
532
|
+
constructor(errors) {
|
|
533
|
+
super(errors.summary);
|
|
534
|
+
this.name = "TraversalError";
|
|
535
|
+
Object.defineProperty(this, "arkErrors", { value: errors });
|
|
536
|
+
}
|
|
537
|
+
})();
|
|
538
|
+
|
|
539
|
+
// ../schema/out/shared/listed.js
|
|
540
|
+
import { rewritesUnions, writesText } from "./shared/issueFeatures.js";
|
|
541
|
+
var writeBranches = (alternatives) => {
|
|
542
|
+
const unique = [...new Set(alternatives)];
|
|
543
|
+
if ([...unique].sort().join() === "false,true")
|
|
544
|
+
return "boolean";
|
|
545
|
+
const last = unique.pop();
|
|
546
|
+
return unique.length ? `${unique.join(", ")} or ${last}` : last;
|
|
547
|
+
};
|
|
548
|
+
var alternativesOf = (issues) => issues.flatMap(({ code, expected = "valid" }) => issues.length > 1 && /^(req|disc|union)/.test(code) ? expected.split(/(?:, | or )(?=(?:[^"]*"[^"]*")*[^"]*$)/) : [expected]);
|
|
549
|
+
var writeListed = (errors) => {
|
|
550
|
+
const atSubject = {};
|
|
551
|
+
for (const error of errors) {
|
|
552
|
+
error.message ??= messageOf(error);
|
|
553
|
+
const path = pathOf(error);
|
|
554
|
+
(atSubject[(path && path + " ") + "must be "] ??= []).push(error);
|
|
555
|
+
}
|
|
556
|
+
return writeBranches(Object.entries(atSubject).map(([subject, same]) => subject + writeBranches(alternativesOf(same))));
|
|
557
|
+
};
|
|
558
|
+
var writeAlike = (errors) => {
|
|
559
|
+
for (const error of errors)
|
|
560
|
+
error.message ??= messageOf(error);
|
|
561
|
+
return lineOf(errors[0]);
|
|
562
|
+
};
|
|
563
|
+
var sharedMessageOf = (errors) => {
|
|
564
|
+
let shared;
|
|
565
|
+
for (const error of errors) {
|
|
566
|
+
if (!isCustomIssue(error) || error._c || shared !== void 0 && error.message !== shared)
|
|
567
|
+
return;
|
|
568
|
+
shared = error.message;
|
|
569
|
+
}
|
|
570
|
+
return shared;
|
|
571
|
+
};
|
|
572
|
+
var ListedIssue = class {
|
|
573
|
+
code = "union";
|
|
574
|
+
// private, so only what an issue's readers see is its own
|
|
575
|
+
#line;
|
|
576
|
+
constructor(path, data, errors, line, expected, message = expected) {
|
|
577
|
+
this.path = path;
|
|
578
|
+
this.data = data;
|
|
579
|
+
this.errors = errors;
|
|
580
|
+
this.expected = expected;
|
|
581
|
+
this.message = message;
|
|
582
|
+
this.#line = line;
|
|
583
|
+
}
|
|
584
|
+
get _l() {
|
|
585
|
+
return this.#line;
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
var movedBy = (errors, path) => errors.map((error) => ({ ...error, path: path(error) }));
|
|
589
|
+
var writeFromPath = (path, errors, write) => write(path.length ? movedBy(errors, (error) => error.path.slice(path.length)) : errors);
|
|
590
|
+
var basesIssueOf = (path, data, errors, describe) => {
|
|
591
|
+
for (const { code, path: at } of errors) {
|
|
592
|
+
if (code !== "domain" && code !== "proto" && code !== "unit" || at.length !== path.length || at.some((k, i) => k !== path[i]))
|
|
593
|
+
return;
|
|
594
|
+
}
|
|
595
|
+
const expected = describe(errors.map((error) => error.expected));
|
|
596
|
+
return new ListedIssue(path.slice(), data, [], void 0, expected, messageOf({ expected }));
|
|
597
|
+
};
|
|
598
|
+
var listed = (Issue, path, data, errors, write) => {
|
|
599
|
+
const line = write(errors);
|
|
600
|
+
const expected = writeFromPath(path, errors, write);
|
|
601
|
+
const shared = writesText ? sharedMessageOf(errors) : void 0;
|
|
602
|
+
return shared === void 0 ? new Issue(path.slice(), data, errors, line, expected) : new Issue(path.slice(), data, errors, void 0, expected, shared);
|
|
603
|
+
};
|
|
604
|
+
var issueWriterOf = (write, describeBases) => rewritesUnions ? /* @__PURE__ */ (() => {
|
|
605
|
+
class RewrittenIssue extends ListedIssue {
|
|
606
|
+
_m(prefix) {
|
|
607
|
+
const moved = movedBy(this.errors, (error) => [
|
|
608
|
+
...prefix,
|
|
609
|
+
...error.path
|
|
610
|
+
]);
|
|
611
|
+
return new RewrittenIssue([...prefix, ...this.path], this.data, moved, this._l === void 0 ? void 0 : write(moved), this.expected, this.message);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
return (path, data, errors) => basesIssueOf(path, data, errors, describeBases) ?? listed(RewrittenIssue, path, data, errors, write);
|
|
615
|
+
})() : (path, data, errors) => basesIssueOf(path, data, errors, describeBases) ?? listed(ListedIssue, path, data, errors, write);
|
|
616
|
+
var listedIssue = /* @__PURE__ */ issueWriterOf(writeListed, writeBranches);
|
|
617
|
+
var alikeIssue = /* @__PURE__ */ issueWriterOf(writeAlike, (expected) => expected[0]);
|
|
618
|
+
|
|
619
|
+
// ../schema/out/shared/jsonSchema.js
|
|
620
|
+
var ToJsonSchemaError = class extends Error {
|
|
621
|
+
name = "ToJsonSchemaError";
|
|
622
|
+
code;
|
|
623
|
+
context;
|
|
624
|
+
constructor(code, context, path = "", message = `Can't convert "${code}"${path && ` at ${path}`} to JSON Schema. Configure fallback.${code} to write it:
|
|
625
|
+
${printable(context, { quoteKeys: false, indent: 4 })}`) {
|
|
626
|
+
super(message);
|
|
627
|
+
this.code = code;
|
|
628
|
+
this.context = context;
|
|
629
|
+
}
|
|
630
|
+
hasCode(code) {
|
|
631
|
+
return this.code === code;
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
var supportedJsonSchemaTargets = [
|
|
635
|
+
"draft-2020-12",
|
|
636
|
+
"draft-07",
|
|
637
|
+
"openapi-3.0"
|
|
638
|
+
];
|
|
639
|
+
var writeInvalidJsonSchemaTargetMessage = (target, targets = supportedJsonSchemaTargets) => {
|
|
640
|
+
const quoted = targets.map((t) => `"${t}"`);
|
|
641
|
+
return `JSONSchema target '${target}' is not supported (must be ${quoted.slice(0, -1).join(", ")} or ${quoted[quoted.length - 1]})`;
|
|
642
|
+
};
|
|
643
|
+
var validateStandardJsonSchemaTarget = (target) => {
|
|
644
|
+
if (!includes(supportedJsonSchemaTargets, target))
|
|
645
|
+
throwParseError(writeInvalidJsonSchemaTargetMessage(target));
|
|
646
|
+
return target;
|
|
647
|
+
};
|
|
648
|
+
var openApiNull = () => ({
|
|
649
|
+
type: "string",
|
|
650
|
+
nullable: true,
|
|
651
|
+
enum: [null]
|
|
652
|
+
});
|
|
653
|
+
var writeUnionJsonSchema = (branches, target, meta, metaJson, discriminant) => {
|
|
654
|
+
if (!branches.length)
|
|
655
|
+
return { not: {} };
|
|
656
|
+
if (branches.length === 1)
|
|
657
|
+
return branches[0];
|
|
658
|
+
const unitKey = target === "openapi-3.0" ? "enum" : "const";
|
|
659
|
+
if (branches.every((branch) => (
|
|
660
|
+
// units with no meta but the union's own are an enum
|
|
661
|
+
Object.entries(branch).every(([k, v]) => k === unitKey || k === "type" || v === meta[k] || v === metaJson[k]) && hasKey(branch, unitKey)
|
|
662
|
+
))) {
|
|
663
|
+
const values = branches.flatMap((branch) => unitKey === "enum" ? branch.enum : [branch.const]);
|
|
664
|
+
const { type } = branches[0];
|
|
665
|
+
return type && branches.every((branch) => branch.type === type) ? { type, enum: values } : { enum: values };
|
|
666
|
+
}
|
|
667
|
+
return discriminant && branches.every(requiresKeyOf(discriminant.key)) ? writeOneOf(branches, discriminant) : { anyOf: branches };
|
|
668
|
+
};
|
|
669
|
+
var requiresKeyOf = (key) => (branch) => "$ref" in branch || !!branch.required?.includes(key);
|
|
670
|
+
var writeOneOf = (branches, { key, values, writesKeyword }) => {
|
|
671
|
+
if (!writesKeyword)
|
|
672
|
+
return { oneOf: branches };
|
|
673
|
+
const mapping = {};
|
|
674
|
+
for (let i = 0; i < branches.length; i++) {
|
|
675
|
+
const ref = branches[i].$ref;
|
|
676
|
+
if (ref)
|
|
677
|
+
for (const value of values[i])
|
|
678
|
+
defineValue(mapping, value, ref);
|
|
679
|
+
}
|
|
680
|
+
return {
|
|
681
|
+
oneOf: branches,
|
|
682
|
+
discriminator: isEmptyObject(mapping) ? { propertyName: key } : { propertyName: key, mapping }
|
|
683
|
+
};
|
|
684
|
+
};
|
|
685
|
+
var writeNullableJsonSchema = (schema, isUnion, target) => {
|
|
686
|
+
if (target === "openapi-3.0" && typeof schema.type === "string") {
|
|
687
|
+
return Object.assign(schema, { nullable: true }, "enum" in schema && {
|
|
688
|
+
enum: [...schema.enum, null]
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
return {
|
|
692
|
+
anyOf: [
|
|
693
|
+
...isUnion && "anyOf" in schema ? schema.anyOf : [schema],
|
|
694
|
+
target === "openapi-3.0" ? openApiNull() : { type: "null" }
|
|
695
|
+
]
|
|
696
|
+
};
|
|
697
|
+
};
|
|
698
|
+
|
|
699
|
+
// ../schema/out/shared/transform.js
|
|
700
|
+
var TransformErrors = class TransformErrors {
|
|
701
|
+
// a function, so a check can rule out other values by typeof
|
|
702
|
+
constructor(result, data) {
|
|
703
|
+
const errors = Object.setPrototypeOf(() => {
|
|
704
|
+
}, TransformErrors.prototype);
|
|
705
|
+
errors.entries = [{ reversedPath: [], result, data }];
|
|
706
|
+
return errors;
|
|
707
|
+
}
|
|
708
|
+
addTo(gathered, key) {
|
|
709
|
+
if (key !== void 0)
|
|
710
|
+
for (const entry of this.entries)
|
|
711
|
+
entry.reversedPath.push(key);
|
|
712
|
+
if (!gathered)
|
|
713
|
+
return this;
|
|
714
|
+
gathered.entries.push(...this.entries);
|
|
715
|
+
return gathered;
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
var holdsOnlyIndices = (data) => {
|
|
719
|
+
const keys = Object.keys(data);
|
|
720
|
+
return keys.length === data.length && (!keys.length || keys[keys.length - 1] === `${keys.length - 1}`) && !Object.getOwnPropertySymbols(data).length;
|
|
721
|
+
};
|
|
722
|
+
var copyOf = (data) => {
|
|
723
|
+
if (isArray(data)) {
|
|
724
|
+
const copy = Array.prototype.slice.call(data);
|
|
725
|
+
const keys = Object.keys(data);
|
|
726
|
+
return keys.length !== copy.length || keys[copy.length - 1] !== `${copy.length - 1}` || Object.getOwnPropertySymbols(data).length ? Object.defineProperties(copy, Object.getOwnPropertyDescriptors({ ...data })) : copy;
|
|
727
|
+
}
|
|
728
|
+
const prototype = Object.getPrototypeOf(data);
|
|
729
|
+
if (prototype === Object.prototype)
|
|
730
|
+
return { ...data };
|
|
731
|
+
return Object.prototype.toString.call(data) === "[object Object]" ? Object.setPrototypeOf({ ...data }, prototype) : data;
|
|
732
|
+
};
|
|
733
|
+
var setOwnValue = (out, k, value) => {
|
|
734
|
+
if (k === "__proto__")
|
|
735
|
+
defineValue(out, k, value);
|
|
736
|
+
else
|
|
737
|
+
out[k] = value;
|
|
738
|
+
};
|
|
739
|
+
var keepOwn = (out, data, k) => {
|
|
740
|
+
if (!(k in out) && hasOwn(data, k))
|
|
741
|
+
setOwnValue(out, k, data[k]);
|
|
742
|
+
};
|
|
743
|
+
var copyDeclared = (data, declared, changes) => {
|
|
744
|
+
"use strict";
|
|
745
|
+
let out = data;
|
|
746
|
+
if (changes) {
|
|
747
|
+
for (let i = 0; i < changes.length; i += 3) {
|
|
748
|
+
if (Object.is(changes[i + 2], changes[i + 1]))
|
|
749
|
+
continue;
|
|
750
|
+
if (out === data)
|
|
751
|
+
out = copyOf(data);
|
|
752
|
+
setOwnValue(out, changes[i], changes[i + 2]);
|
|
753
|
+
}
|
|
754
|
+
if (out !== data)
|
|
755
|
+
for (const k of declared)
|
|
756
|
+
keepOwn(out, data, k);
|
|
757
|
+
}
|
|
758
|
+
for (const k of [
|
|
759
|
+
...Object.keys(data),
|
|
760
|
+
...Object.getOwnPropertySymbols(data)
|
|
761
|
+
]) {
|
|
762
|
+
if (declared.includes(k))
|
|
763
|
+
continue;
|
|
764
|
+
if (out === data)
|
|
765
|
+
out = copyOf(data);
|
|
766
|
+
delete out[k];
|
|
767
|
+
}
|
|
768
|
+
return out;
|
|
769
|
+
};
|
|
770
|
+
var mergeTransformed = (input, l, r) => {
|
|
771
|
+
if (Object.is(r, input))
|
|
772
|
+
return l;
|
|
773
|
+
if (!hasDomain(input, "object") || !hasDomain(l, "object") || !hasDomain(r, "object") || r instanceof TransformErrors)
|
|
774
|
+
return r;
|
|
775
|
+
const merged = copyOf(l);
|
|
776
|
+
for (const k in input)
|
|
777
|
+
if (!hasOwn(r, k))
|
|
778
|
+
delete merged[k];
|
|
779
|
+
for (const k in r) {
|
|
780
|
+
if (!(k in input) || !Object.is(r[k], input[k]))
|
|
781
|
+
setOwnValue(merged, k, r[k]);
|
|
782
|
+
}
|
|
783
|
+
return merged;
|
|
784
|
+
};
|
|
785
|
+
|
|
786
|
+
// ../schema/out/shared/traversal.js
|
|
787
|
+
import { callsSiteText, findsOnRead, listsUnions } from "./shared/issueFeatures.js";
|
|
788
|
+
|
|
789
|
+
// ../schema/out/shared/utils.js
|
|
790
|
+
var inProgress = {
|
|
791
|
+
definitions: 0,
|
|
792
|
+
resolutions: 0,
|
|
793
|
+
ioReads: 0,
|
|
794
|
+
compositions: 0
|
|
795
|
+
};
|
|
796
|
+
var removedProblemMessage = "problem was removed in 3.0; write message";
|
|
797
|
+
|
|
798
|
+
// ../schema/out/shared/traversal.js
|
|
799
|
+
var noBranches = [];
|
|
800
|
+
var InternalTraversal = class {
|
|
801
|
+
constructor(root, config) {
|
|
802
|
+
this.context = callContext;
|
|
803
|
+
if (onContextRead)
|
|
804
|
+
Object.defineProperty(this, "context", { get: onContextRead });
|
|
805
|
+
this.path = [];
|
|
806
|
+
this._errors = void 0;
|
|
807
|
+
this.root = root;
|
|
808
|
+
this.config = config;
|
|
809
|
+
this.branches = noBranches;
|
|
810
|
+
this.res = void 0;
|
|
811
|
+
this.isTree = true;
|
|
812
|
+
this.tfdById = void 0;
|
|
813
|
+
this.recv = root;
|
|
814
|
+
this.recvAt = 0;
|
|
815
|
+
this.chkOnly = false;
|
|
816
|
+
this.retFrom = void 0;
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* #### whether {@link currentBranch} (or the traversal root, outside a union) has one or more errors
|
|
820
|
+
*/
|
|
821
|
+
hasError() {
|
|
822
|
+
return this.errN !== 0;
|
|
823
|
+
}
|
|
824
|
+
get currentBranch() {
|
|
825
|
+
return this.branches.length === 0 ? void 0 : this.branches[this.branches.length - 1];
|
|
826
|
+
}
|
|
827
|
+
/** its result: the data, or its errors passed to `onFail` if it has any */
|
|
828
|
+
fin(onFail) {
|
|
829
|
+
if (this.hasError())
|
|
830
|
+
return onFail ? onFail(this._errors) : this._errors;
|
|
831
|
+
return this.root;
|
|
832
|
+
}
|
|
833
|
+
/** how many errors the current union branch has, or the traversal has outside a union */
|
|
834
|
+
get errN() {
|
|
835
|
+
const branches = this.branches;
|
|
836
|
+
return branches.length === 0 ? this._errors?.count ?? 0 : branches[branches.length - 1].errN;
|
|
837
|
+
}
|
|
838
|
+
get failFast() {
|
|
839
|
+
return this.branches.length !== 0;
|
|
840
|
+
}
|
|
841
|
+
/** starts counting a union branch's errors */
|
|
842
|
+
pushBr() {
|
|
843
|
+
const branch = { error: void 0, errN: 0 };
|
|
844
|
+
if (this.branches === noBranches)
|
|
845
|
+
this.branches = [branch];
|
|
846
|
+
else
|
|
847
|
+
this.branches.push(branch);
|
|
848
|
+
}
|
|
849
|
+
/** stops counting the innermost union branch's errors, returning it */
|
|
850
|
+
popBr() {
|
|
851
|
+
return this.branches.pop();
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* @internal
|
|
855
|
+
* Convenience for casting from InternalTraversal to Traversal
|
|
856
|
+
* for cases where the extra methods on the external type are expected, e.g.
|
|
857
|
+
* a morph or predicate.
|
|
858
|
+
*/
|
|
859
|
+
get external() {
|
|
860
|
+
return this;
|
|
861
|
+
}
|
|
862
|
+
nodeError(input, data) {
|
|
863
|
+
return this.addError({
|
|
864
|
+
code: input.code,
|
|
865
|
+
path: this.path.slice(),
|
|
866
|
+
data,
|
|
867
|
+
expected: input.description
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
/** @internal a validator's failure, as its errors take one */
|
|
871
|
+
_e(data, code, expected, message, text) {
|
|
872
|
+
const issue = {
|
|
873
|
+
code,
|
|
874
|
+
path: this.path.slice(),
|
|
875
|
+
data,
|
|
876
|
+
expected,
|
|
877
|
+
message
|
|
878
|
+
};
|
|
879
|
+
if (callsSiteText)
|
|
880
|
+
text?.(issue);
|
|
881
|
+
this.addError(issue);
|
|
882
|
+
return this.failFast;
|
|
883
|
+
}
|
|
884
|
+
/** @internal a validator's key, as its errors enter one */
|
|
885
|
+
_k(apply, data, key, ...missing) {
|
|
886
|
+
this.path.push(key);
|
|
887
|
+
const value = data[key];
|
|
888
|
+
const stops = value === void 0 && missing.length && !(key in data) ? this._e(data, "required", ...missing) : !apply(value, this);
|
|
889
|
+
this.path.pop();
|
|
890
|
+
return stops;
|
|
891
|
+
}
|
|
892
|
+
/** @internal */
|
|
893
|
+
failsUnion(branches, site, data) {
|
|
894
|
+
this.addError(issueOf(this.path, site, data, void 0));
|
|
895
|
+
return this.failFast;
|
|
896
|
+
}
|
|
897
|
+
/** @internal */
|
|
898
|
+
addError(error) {
|
|
899
|
+
if (this.currentBranch)
|
|
900
|
+
this.failBranch(error);
|
|
901
|
+
else {
|
|
902
|
+
const errors = errorsOf(this);
|
|
903
|
+
if (findsOnRead || errors._.length)
|
|
904
|
+
errors._.push(error);
|
|
905
|
+
else
|
|
906
|
+
errors._ = [error];
|
|
907
|
+
}
|
|
908
|
+
return error;
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
911
|
+
* @internal adds the errors of a validator called with this traversal,
|
|
912
|
+
* returning its own
|
|
913
|
+
*/
|
|
914
|
+
piped(errors) {
|
|
915
|
+
const target = errorsOf(this);
|
|
916
|
+
if (target._merge)
|
|
917
|
+
target._merge(errors, this.path);
|
|
918
|
+
else {
|
|
919
|
+
for (const issue of errors._) {
|
|
920
|
+
target._.push(listsUnions && issue._m ? issue._m(this.path) : notedAs(issue, { ...issue, path: [...this.path, ...issue.path] }));
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
return target;
|
|
924
|
+
}
|
|
925
|
+
/** @internal */
|
|
926
|
+
createErrors() {
|
|
927
|
+
return new ArkErrors();
|
|
928
|
+
}
|
|
929
|
+
failBranch(error) {
|
|
930
|
+
const branch = this.currentBranch;
|
|
931
|
+
branch.error = error;
|
|
932
|
+
branch.errN++;
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
var Traversal = class extends InternalTraversal {
|
|
936
|
+
/**
|
|
937
|
+
* #### {@link ArkErrors} that will be part of this traversal's finalized result
|
|
938
|
+
*
|
|
939
|
+
* ✅ will always be empty for a valid traversal
|
|
940
|
+
*/
|
|
941
|
+
get errors() {
|
|
942
|
+
return errorsOf(this);
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* #### the data being validated or morphed
|
|
946
|
+
*
|
|
947
|
+
* ✅ the value at {@link path}, as transformed by any morphs that have already run
|
|
948
|
+
*/
|
|
949
|
+
get data() {
|
|
950
|
+
let result = this.recv;
|
|
951
|
+
for (let i = this.recvAt; i < this.path.length; i++)
|
|
952
|
+
result = result?.[this.path[i]];
|
|
953
|
+
return result;
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* #### a string representing {@link path}
|
|
957
|
+
*
|
|
958
|
+
* @propString
|
|
959
|
+
*/
|
|
960
|
+
get propString() {
|
|
961
|
+
return pathOf(this);
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* #### add an {@link ArkError} and return `false`
|
|
965
|
+
*
|
|
966
|
+
* ✅ useful for predicates like `.narrow`
|
|
967
|
+
* ✅ `{ message: "Enter a valid email" }` is the whole sentence an issue says
|
|
968
|
+
* 🔗 to say what the value must be, as `must be even`, pass `"even"` to {@link mustBe}
|
|
969
|
+
*/
|
|
970
|
+
reject(input) {
|
|
971
|
+
this.raise(input);
|
|
972
|
+
return false;
|
|
973
|
+
}
|
|
974
|
+
/**
|
|
975
|
+
* #### add an {@link ArkError} from a description and return `false`
|
|
976
|
+
*
|
|
977
|
+
* ✅ useful for predicates like `.narrow`
|
|
978
|
+
* 🔗 equivalent to {@link reject}({ expected })
|
|
979
|
+
*/
|
|
980
|
+
mustBe(expected) {
|
|
981
|
+
this.raise(expected);
|
|
982
|
+
return false;
|
|
983
|
+
}
|
|
984
|
+
error(input) {
|
|
985
|
+
this.retFrom ??= errorsOf(this).count;
|
|
986
|
+
return this.raise(input);
|
|
987
|
+
}
|
|
988
|
+
raise(input) {
|
|
989
|
+
throwOnProblem(input);
|
|
990
|
+
const supplied = typeof input === "object" ? input : { expected: input };
|
|
991
|
+
const code = supplied.code ?? "predicate";
|
|
992
|
+
const issue = {
|
|
993
|
+
code,
|
|
994
|
+
path: [
|
|
995
|
+
...supplied.prefixPath ?? [],
|
|
996
|
+
...supplied.path ?? this.path,
|
|
997
|
+
...supplied.relativePath ?? []
|
|
998
|
+
],
|
|
999
|
+
data: "data" in supplied ? supplied.data : this.data,
|
|
1000
|
+
// a keyword raises its errors with the description of what it checks
|
|
1001
|
+
// a code of its own is written without what its rule describes
|
|
1002
|
+
expected: supplied.expected ?? supplied.description ?? (code === "predicate" || supplied.morph ? describePredicate(supplied) : "valid")
|
|
1003
|
+
};
|
|
1004
|
+
if (supplied.message !== void 0)
|
|
1005
|
+
issue.message = supplied.message;
|
|
1006
|
+
else if (supplied.cause !== void 0 && supplied.morph) {
|
|
1007
|
+
try {
|
|
1008
|
+
issue.message = `must be ${issue.expected} (${String(supplied.cause)})`;
|
|
1009
|
+
} catch {
|
|
1010
|
+
}
|
|
1011
|
+
} else if (supplied.actual)
|
|
1012
|
+
issue.message = `must be ${issue.expected} (was ${supplied.actual})`;
|
|
1013
|
+
return this.addError(issue);
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
var FirstIssueTraversal = class extends Traversal {
|
|
1017
|
+
get failFast() {
|
|
1018
|
+
return true;
|
|
1019
|
+
}
|
|
1020
|
+
fin(onFail) {
|
|
1021
|
+
this._errors?._.splice(1);
|
|
1022
|
+
return super.fin(onFail);
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
var throwOnProblem = (input) => {
|
|
1026
|
+
if (typeof input === "object" && "problem" in input)
|
|
1027
|
+
throwError(removedProblemMessage);
|
|
1028
|
+
};
|
|
1029
|
+
var errorsOf = (ctx) => ctx._errors ??= ctx.createErrors();
|
|
1030
|
+
var applyRejected = (node, data, config, onFail, ctor) => {
|
|
1031
|
+
const ctx = new ctor(data, config);
|
|
1032
|
+
node.tApply(data, ctx);
|
|
1033
|
+
return ctx.fin(onFail);
|
|
1034
|
+
};
|
|
1035
|
+
var receive = (ctx, data) => {
|
|
1036
|
+
ctx.recv = data;
|
|
1037
|
+
ctx.recvAt = ctx.path.length;
|
|
1038
|
+
};
|
|
1039
|
+
var describePredicate = (ctx) => {
|
|
1040
|
+
const fn = ctx.predicate ?? ctx.morph;
|
|
1041
|
+
return `valid according to ${fn && functionNameOf(fn) || "an anonymous predicate"}`;
|
|
1042
|
+
};
|
|
1043
|
+
var tryMorph = (morph) => (In, ctx) => {
|
|
1044
|
+
try {
|
|
1045
|
+
return morph(In, ctx);
|
|
1046
|
+
} catch (cause) {
|
|
1047
|
+
return ctx.error({ code: "predicate", morph, cause });
|
|
1048
|
+
}
|
|
1049
|
+
};
|
|
1050
|
+
var execMorph = (regex) => (s) => regex.exec(s);
|
|
1051
|
+
var callMorph = (ctx, morph, data) => {
|
|
1052
|
+
const { recv, recvAt } = ctx;
|
|
1053
|
+
receive(ctx, data);
|
|
1054
|
+
ctx.retFrom = void 0;
|
|
1055
|
+
const result = morph(data, ctx);
|
|
1056
|
+
ctx.recv = recv;
|
|
1057
|
+
ctx.recvAt = recvAt;
|
|
1058
|
+
return ctx.retFrom === void 0 ? result : returned(ctx, result);
|
|
1059
|
+
};
|
|
1060
|
+
var returned = (ctx, result) => typeof result === "object" && ctx._errors._.includes(result, ctx.retFrom) ? ctx._errors : result;
|
|
1061
|
+
var transform = (ctx, node, data) => node.tfsById ? transformResolution(ctx, node.id, data, node.tTransform, node) : transformAcyclic(ctx, node, data);
|
|
1062
|
+
var transformAcyclic = (ctx, node, data) => transformed(ctx, node.tTransform(data, ctx), data);
|
|
1063
|
+
var transformed = (ctx, result, data) => {
|
|
1064
|
+
if (!(result instanceof TransformErrors))
|
|
1065
|
+
return result;
|
|
1066
|
+
addMorphErrs(ctx, result);
|
|
1067
|
+
return data;
|
|
1068
|
+
};
|
|
1069
|
+
var pipeOf = (node) => node.hasAlias ? pipe : pipeAcyclicOf(node);
|
|
1070
|
+
var pipeAcyclicOf = (node) => node.tfs ? pipeTransformed : node.allowsCtx || node.reportsPred ? pipeChecked : pipeApplied;
|
|
1071
|
+
var pipeChecked = (ctx, node, data) => allowsPiped(ctx, node, data) ? data : errorsOf(ctx);
|
|
1072
|
+
var pipeApplied = (ctx, node, data) => {
|
|
1073
|
+
if (node.allows(data))
|
|
1074
|
+
return data;
|
|
1075
|
+
node.tApply(data, ctx);
|
|
1076
|
+
return errorsOf(ctx);
|
|
1077
|
+
};
|
|
1078
|
+
var pipeTransformed = (ctx, node, data) => allowsPiped(ctx, node, data) ? transformPiped(ctx, node, data, transformAcyclic) : errorsOf(ctx);
|
|
1079
|
+
var pipe = (ctx, node, data) => {
|
|
1080
|
+
if (!node.hasAlias)
|
|
1081
|
+
return pipeAcyclicOf(node)(ctx, node, data);
|
|
1082
|
+
if (!node.allows(data)) {
|
|
1083
|
+
applyPipedResolution(ctx, node, data);
|
|
1084
|
+
return errorsOf(ctx);
|
|
1085
|
+
}
|
|
1086
|
+
if (!node.tfs)
|
|
1087
|
+
return data;
|
|
1088
|
+
const { tfdById, isTree } = ctx;
|
|
1089
|
+
ctx.tfdById = void 0;
|
|
1090
|
+
ctx.isTree = true;
|
|
1091
|
+
const result = transformPiped(ctx, node, data, transform);
|
|
1092
|
+
ctx.tfdById = tfdById;
|
|
1093
|
+
ctx.isTree = isTree;
|
|
1094
|
+
return result;
|
|
1095
|
+
};
|
|
1096
|
+
var allowsPiped = (ctx, node, data) => {
|
|
1097
|
+
if (node.allowsCtx || node.reportsPred)
|
|
1098
|
+
return applyPiped(ctx, node, data);
|
|
1099
|
+
if (node.allows(data))
|
|
1100
|
+
return true;
|
|
1101
|
+
applyPiped(ctx, node, data);
|
|
1102
|
+
return false;
|
|
1103
|
+
};
|
|
1104
|
+
var transformPiped = (ctx, node, data, transformNode) => {
|
|
1105
|
+
const { recv, recvAt } = ctx;
|
|
1106
|
+
const errN = ctx.errN;
|
|
1107
|
+
const result = transformNode(ctx, node, data);
|
|
1108
|
+
ctx.recv = recv;
|
|
1109
|
+
ctx.recvAt = recvAt;
|
|
1110
|
+
return ctx.errN > errN ? errorsOf(ctx) : result;
|
|
1111
|
+
};
|
|
1112
|
+
var applyPiped = (ctx, node, data) => {
|
|
1113
|
+
const errN = ctx.errN;
|
|
1114
|
+
const { recv, recvAt, chkOnly } = ctx;
|
|
1115
|
+
receive(ctx, data);
|
|
1116
|
+
ctx.chkOnly = true;
|
|
1117
|
+
node.tApply(data, ctx);
|
|
1118
|
+
ctx.chkOnly = chkOnly;
|
|
1119
|
+
ctx.recv = recv;
|
|
1120
|
+
ctx.recvAt = recvAt;
|
|
1121
|
+
return ctx.errN === errN;
|
|
1122
|
+
};
|
|
1123
|
+
var applyPipedResolution = (ctx, node, data) => {
|
|
1124
|
+
const { recv, recvAt, chkOnly } = ctx;
|
|
1125
|
+
receive(ctx, data);
|
|
1126
|
+
ctx.chkOnly = true;
|
|
1127
|
+
const piped = traversalOf(ctx, data);
|
|
1128
|
+
piped.chkOnly = true;
|
|
1129
|
+
const { _errors } = applyCyclic(node, data, piped);
|
|
1130
|
+
if (_errors)
|
|
1131
|
+
addErrors(ctx, _errors);
|
|
1132
|
+
ctx.chkOnly = chkOnly;
|
|
1133
|
+
ctx.recv = recv;
|
|
1134
|
+
ctx.recvAt = recvAt;
|
|
1135
|
+
};
|
|
1136
|
+
var transformsValid = (ctx) => ctx.branches.length === 0 && !ctx.chkOnly;
|
|
1137
|
+
var transformedInApply = (ctx, result) => {
|
|
1138
|
+
if (result instanceof TransformErrors)
|
|
1139
|
+
addMorphErrs(ctx, result);
|
|
1140
|
+
};
|
|
1141
|
+
var transformIfAllowed = (ctx, node, data) => {
|
|
1142
|
+
if (!transformsValid(ctx))
|
|
1143
|
+
return false;
|
|
1144
|
+
if (node.hasAlias) {
|
|
1145
|
+
const untracked = allowsAcyclic(node, data);
|
|
1146
|
+
if (!(untracked ?? allowsInTraversal(node, data, traversalOf(ctx, data))))
|
|
1147
|
+
return false;
|
|
1148
|
+
ctx.isTree = untracked === void 0;
|
|
1149
|
+
ctx.tfdById = void 0;
|
|
1150
|
+
} else if (!allowsInBranch(ctx, node, data))
|
|
1151
|
+
return false;
|
|
1152
|
+
transformedInApply(ctx, transform(ctx, node, data));
|
|
1153
|
+
return true;
|
|
1154
|
+
};
|
|
1155
|
+
var allowsInBranch = (ctx, node, data) => node.checksCtx ? allowsInBranchBy(ctx, node.tAllows, data, node) : node.allows(data);
|
|
1156
|
+
var silentCtx = {
|
|
1157
|
+
mustBe: () => false,
|
|
1158
|
+
reject: () => false,
|
|
1159
|
+
get context() {
|
|
1160
|
+
return onContextRead ? onContextRead() : callContext;
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
1163
|
+
var callContext;
|
|
1164
|
+
var inContext = (context, run) => {
|
|
1165
|
+
const outer = callContext;
|
|
1166
|
+
callContext = context;
|
|
1167
|
+
try {
|
|
1168
|
+
return run();
|
|
1169
|
+
} finally {
|
|
1170
|
+
callContext = outer;
|
|
1171
|
+
}
|
|
1172
|
+
};
|
|
1173
|
+
var onContextRead;
|
|
1174
|
+
var readingContextWith = (onRead, run) => {
|
|
1175
|
+
const outer = onContextRead;
|
|
1176
|
+
onContextRead = onRead;
|
|
1177
|
+
try {
|
|
1178
|
+
return run();
|
|
1179
|
+
} finally {
|
|
1180
|
+
onContextRead = outer;
|
|
1181
|
+
}
|
|
1182
|
+
};
|
|
1183
|
+
var withContextOf = (t, context) => {
|
|
1184
|
+
const standard = t["~standard"];
|
|
1185
|
+
return Object.assign((data) => inContext(context, () => t(data)), {
|
|
1186
|
+
assert: (data) => inContext(context, () => t.assert(data)),
|
|
1187
|
+
allows: (data) => inContext(context, () => t.allows(data)),
|
|
1188
|
+
// as the Type's, with its vendor's own members like _c, but validating in context
|
|
1189
|
+
"~standard": Object.defineProperties({}, {
|
|
1190
|
+
...Object.getOwnPropertyDescriptors(standard),
|
|
1191
|
+
validate: {
|
|
1192
|
+
value: (value, options) => inContext(context, () => standard.validate(value, options)),
|
|
1193
|
+
enumerable: true
|
|
1194
|
+
}
|
|
1195
|
+
})
|
|
1196
|
+
});
|
|
1197
|
+
};
|
|
1198
|
+
var allowsInBranchBy = (ctx, allows, data, node) => {
|
|
1199
|
+
const pathLength = ctx.path.length;
|
|
1200
|
+
ctx.pushBr();
|
|
1201
|
+
const allowed = allows.call(node, data, ctx);
|
|
1202
|
+
if (ctx.path.length !== pathLength)
|
|
1203
|
+
ctx.path.length = pathLength;
|
|
1204
|
+
return ctx.popBr().errN === 0 && allowed;
|
|
1205
|
+
};
|
|
1206
|
+
var disallowed = () => false;
|
|
1207
|
+
var rejectedBy;
|
|
1208
|
+
var rejectedValue;
|
|
1209
|
+
var rejected = (allows, value) => {
|
|
1210
|
+
if (typeof value === "string") {
|
|
1211
|
+
rejectedBy = allows;
|
|
1212
|
+
rejectedValue = value;
|
|
1213
|
+
}
|
|
1214
|
+
return false;
|
|
1215
|
+
};
|
|
1216
|
+
var rejects = (allows, value) => {
|
|
1217
|
+
if (value !== rejectedValue || allows !== rejectedBy)
|
|
1218
|
+
return !allows(value);
|
|
1219
|
+
rejectedBy = rejectedValue = void 0;
|
|
1220
|
+
return true;
|
|
1221
|
+
};
|
|
1222
|
+
var minStickyLength = 16;
|
|
1223
|
+
var stickyCopies = /* @__PURE__ */ new WeakMap();
|
|
1224
|
+
var matchesRepeated = (pattern, data) => {
|
|
1225
|
+
if (data.length < minStickyLength)
|
|
1226
|
+
return pattern.test(data);
|
|
1227
|
+
let sticky = stickyCopies.get(pattern);
|
|
1228
|
+
if (!sticky) {
|
|
1229
|
+
sticky = new RegExp(pattern.source.slice(1, -1), `${pattern.flags}y`);
|
|
1230
|
+
stickyCopies.set(pattern, sticky);
|
|
1231
|
+
}
|
|
1232
|
+
sticky.lastIndex = 0;
|
|
1233
|
+
return sticky.test(data) && sticky.lastIndex === data.length;
|
|
1234
|
+
};
|
|
1235
|
+
var addErrors = (ctx, errors) => {
|
|
1236
|
+
if (errors === ctx._errors)
|
|
1237
|
+
return;
|
|
1238
|
+
const target = errorsOf(ctx);
|
|
1239
|
+
if (target._merge)
|
|
1240
|
+
target._merge(errors, ctx.path);
|
|
1241
|
+
else
|
|
1242
|
+
mergeIssues(target, errors, ctx.path);
|
|
1243
|
+
};
|
|
1244
|
+
var addMorphErrs = (ctx, errors, key) => {
|
|
1245
|
+
const { path, recv, recvAt } = ctx;
|
|
1246
|
+
for (const { reversedPath, result, data } of errors.entries) {
|
|
1247
|
+
ctx.path = [...path];
|
|
1248
|
+
if (key !== void 0)
|
|
1249
|
+
ctx.path.push(key);
|
|
1250
|
+
for (let i = reversedPath.length - 1; i >= 0; i--)
|
|
1251
|
+
ctx.path.push(reversedPath[i]);
|
|
1252
|
+
receive(ctx, data);
|
|
1253
|
+
addErrors(ctx, result);
|
|
1254
|
+
}
|
|
1255
|
+
ctx.path = path;
|
|
1256
|
+
ctx.recv = recv;
|
|
1257
|
+
ctx.recvAt = recvAt;
|
|
1258
|
+
};
|
|
1259
|
+
var transformResolution = (ctx, id, data, transform2, node) => {
|
|
1260
|
+
if (!ctx.isTree || !hasDomain(data, "object"))
|
|
1261
|
+
return transformed(ctx, transform2.call(node, data, ctx), data);
|
|
1262
|
+
const transformedByData = (ctx.tfdById ??= {})[id] ??= /* @__PURE__ */ new Map();
|
|
1263
|
+
if (transformedByData.has(data)) {
|
|
1264
|
+
const result2 = transformedByData.get(data);
|
|
1265
|
+
if (result2 !== transforming)
|
|
1266
|
+
return result2;
|
|
1267
|
+
const placeholder2 = isArray(data) ? [] : {};
|
|
1268
|
+
transformedByData.set(data, placeholder2);
|
|
1269
|
+
return placeholder2;
|
|
1270
|
+
}
|
|
1271
|
+
transformedByData.set(data, transforming);
|
|
1272
|
+
const result = transformed(ctx, transform2.call(node, data, ctx), data);
|
|
1273
|
+
const placeholder = transformedByData.get(data);
|
|
1274
|
+
if (placeholder === transforming || !canFill(placeholder, result)) {
|
|
1275
|
+
transformedByData.set(data, result);
|
|
1276
|
+
if (hasDomain(result, "object"))
|
|
1277
|
+
transformedByData.set(result, result);
|
|
1278
|
+
return result;
|
|
1279
|
+
}
|
|
1280
|
+
Object.defineProperties(placeholder, Object.getOwnPropertyDescriptors(result));
|
|
1281
|
+
transformedByData.set(placeholder, placeholder);
|
|
1282
|
+
return Object.setPrototypeOf(placeholder, Object.getPrototypeOf(result));
|
|
1283
|
+
};
|
|
1284
|
+
var Resolutions = class {
|
|
1285
|
+
seen = {};
|
|
1286
|
+
// untracked until data is deep or broad enough to be cyclic
|
|
1287
|
+
tracked = true;
|
|
1288
|
+
// reused by depth, so entering doesn't allocate
|
|
1289
|
+
frames = void 0;
|
|
1290
|
+
depth = 0;
|
|
1291
|
+
/** how many nodes were entered while untracked, bounded so a cycle can't run forever */
|
|
1292
|
+
visits = 0;
|
|
1293
|
+
/** whether a failure was recorded, so untracked lookups still find it */
|
|
1294
|
+
hasFailed = false;
|
|
1295
|
+
/** how many resolutions were entered, numbering each */
|
|
1296
|
+
nEntered = 0;
|
|
1297
|
+
assumedFrom = Number.POSITIVE_INFINITY;
|
|
1298
|
+
assumed = void 0;
|
|
1299
|
+
/** the first reported invalid resolution reached */
|
|
1300
|
+
invalid = void 0;
|
|
1301
|
+
};
|
|
1302
|
+
var resolutionsOf = (ctx) => ctx.res ??= new Resolutions();
|
|
1303
|
+
var enterResolution = (ctx, id, data) => {
|
|
1304
|
+
const res = resolutionsOf(ctx);
|
|
1305
|
+
const states = res.tracked || res.hasFailed ? res.seen[id] : void 0;
|
|
1306
|
+
const state = states?.get(data);
|
|
1307
|
+
if (state !== void 0) {
|
|
1308
|
+
if (typeof state === "number") {
|
|
1309
|
+
if (state < res.assumedFrom)
|
|
1310
|
+
res.assumedFrom = state;
|
|
1311
|
+
return true;
|
|
1312
|
+
}
|
|
1313
|
+
if (typeof state === "boolean")
|
|
1314
|
+
return state;
|
|
1315
|
+
if (ctx.currentBranch) {
|
|
1316
|
+
ctx.failBranch(state.error);
|
|
1317
|
+
return false;
|
|
1318
|
+
}
|
|
1319
|
+
if (state.reported) {
|
|
1320
|
+
res.invalid ??= state;
|
|
1321
|
+
return false;
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
if (!res.tracked && (res.depth >= maxAliasDepth || ++res.visits > maxAliasVisits))
|
|
1325
|
+
throw untrackedBound;
|
|
1326
|
+
const frame = (res.frames ??= [])[res.depth++] ??= {
|
|
1327
|
+
id,
|
|
1328
|
+
data,
|
|
1329
|
+
entered: 0,
|
|
1330
|
+
errN: 0,
|
|
1331
|
+
outerInvalid: void 0,
|
|
1332
|
+
assumedOuter: 0,
|
|
1333
|
+
assumedLength: 0
|
|
1334
|
+
};
|
|
1335
|
+
frame.id = id;
|
|
1336
|
+
frame.data = data;
|
|
1337
|
+
frame.errN = ctx.errN;
|
|
1338
|
+
if (!res.tracked)
|
|
1339
|
+
return;
|
|
1340
|
+
(states ?? (res.seen[id] = /* @__PURE__ */ new Map())).set(data, ++res.nEntered);
|
|
1341
|
+
frame.entered = res.nEntered;
|
|
1342
|
+
frame.outerInvalid = res.invalid;
|
|
1343
|
+
res.invalid = void 0;
|
|
1344
|
+
frame.assumedOuter = res.assumedFrom;
|
|
1345
|
+
frame.assumedLength = (res.assumed ??= []).length;
|
|
1346
|
+
res.assumedFrom = Number.POSITIVE_INFINITY;
|
|
1347
|
+
return;
|
|
1348
|
+
};
|
|
1349
|
+
var exitResolution = (ctx, allowed) => {
|
|
1350
|
+
const res = ctx.res;
|
|
1351
|
+
const frame = res.frames[--res.depth];
|
|
1352
|
+
if (!res.tracked)
|
|
1353
|
+
return allowed ?? exitUntracked(ctx, frame);
|
|
1354
|
+
const invalid = res.invalid;
|
|
1355
|
+
res.invalid = frame.outerInvalid;
|
|
1356
|
+
const valid = allowed ?? (invalid === void 0 && ctx.errN === frame.errN);
|
|
1357
|
+
const data = frame.data;
|
|
1358
|
+
const states = res.seen[frame.id];
|
|
1359
|
+
if (typeof data === "object" ? data === null : typeof data !== "function") {
|
|
1360
|
+
res.assumedFrom = frame.assumedOuter;
|
|
1361
|
+
states.delete(data);
|
|
1362
|
+
return valid;
|
|
1363
|
+
}
|
|
1364
|
+
const state = valid || allowed === false ? valid : invalidResolution(ctx, invalid?.error);
|
|
1365
|
+
const assumedFrom = res.assumedFrom;
|
|
1366
|
+
res.assumedFrom = frame.assumedOuter;
|
|
1367
|
+
const assumed = res.assumed;
|
|
1368
|
+
if (valid && assumedFrom < frame.entered) {
|
|
1369
|
+
assumed.push(states, data);
|
|
1370
|
+
if (assumedFrom < res.assumedFrom)
|
|
1371
|
+
res.assumedFrom = assumedFrom;
|
|
1372
|
+
return true;
|
|
1373
|
+
}
|
|
1374
|
+
if (assumed.length !== frame.assumedLength) {
|
|
1375
|
+
for (let i = frame.assumedLength; i < assumed.length; i += 2) {
|
|
1376
|
+
const assumedStates = assumed[i];
|
|
1377
|
+
if (valid)
|
|
1378
|
+
assumedStates.set(assumed[i + 1], true);
|
|
1379
|
+
else
|
|
1380
|
+
assumedStates.delete(assumed[i + 1]);
|
|
1381
|
+
}
|
|
1382
|
+
assumed.length = frame.assumedLength;
|
|
1383
|
+
}
|
|
1384
|
+
states.set(data, state);
|
|
1385
|
+
if (typeof state === "object" && state.reported)
|
|
1386
|
+
res.invalid ??= state;
|
|
1387
|
+
return valid;
|
|
1388
|
+
};
|
|
1389
|
+
var exitUntracked = (ctx, frame) => {
|
|
1390
|
+
if (ctx.errN === frame.errN)
|
|
1391
|
+
return true;
|
|
1392
|
+
if (!hasDomain(frame.data, "object"))
|
|
1393
|
+
return false;
|
|
1394
|
+
const res = ctx.res;
|
|
1395
|
+
(res.seen[frame.id] ??= /* @__PURE__ */ new Map()).set(frame.data, invalidResolution(ctx));
|
|
1396
|
+
res.hasFailed = true;
|
|
1397
|
+
return false;
|
|
1398
|
+
};
|
|
1399
|
+
var invalidResolution = (ctx, error = ctx.currentBranch?.error ?? lastOf(ctx._errors._i ?? ctx._errors._)) => ({
|
|
1400
|
+
error,
|
|
1401
|
+
reported: !ctx.currentBranch
|
|
1402
|
+
});
|
|
1403
|
+
var traversalOf = (ctx, data) => new ctx.constructor(data, ctx.config);
|
|
1404
|
+
var lastOf = (array) => array[array.length - 1];
|
|
1405
|
+
var transforming = /* @__PURE__ */ noSuggest("transforming");
|
|
1406
|
+
var maxAliasDepth = 64;
|
|
1407
|
+
var maxAliasVisits = 1e3;
|
|
1408
|
+
var continuation;
|
|
1409
|
+
var continuationConfig;
|
|
1410
|
+
var aliasVisits = {
|
|
1411
|
+
count: 0,
|
|
1412
|
+
tracked: false,
|
|
1413
|
+
// data past the depth bound may be cyclic, so every path past it continues one tracked traversal
|
|
1414
|
+
exceed: (data) => {
|
|
1415
|
+
aliasVisits.count += maxAliasDepth;
|
|
1416
|
+
if (aliasVisits.count > maxAliasVisits) {
|
|
1417
|
+
aliasVisits.count = Number.POSITIVE_INFINITY;
|
|
1418
|
+
return false;
|
|
1419
|
+
}
|
|
1420
|
+
aliasVisits.tracked = true;
|
|
1421
|
+
return continuation ??= new InternalTraversal(data, continuationConfig);
|
|
1422
|
+
}
|
|
1423
|
+
};
|
|
1424
|
+
var untrackedBound = /* @__PURE__ */ noSuggest("untrackedBound");
|
|
1425
|
+
var applyCyclic = (node, data, ctx) => {
|
|
1426
|
+
if (node.tfs) {
|
|
1427
|
+
applyResolution(node.trackedId, node, data, ctx);
|
|
1428
|
+
return ctx;
|
|
1429
|
+
}
|
|
1430
|
+
resolutionsOf(ctx).tracked = false;
|
|
1431
|
+
try {
|
|
1432
|
+
node.tApply(data, ctx);
|
|
1433
|
+
} catch (e) {
|
|
1434
|
+
if (e !== untrackedBound)
|
|
1435
|
+
throw e;
|
|
1436
|
+
ctx = traversalOf(ctx, data);
|
|
1437
|
+
applyResolution(node.trackedId, node, data, ctx);
|
|
1438
|
+
}
|
|
1439
|
+
return ctx;
|
|
1440
|
+
};
|
|
1441
|
+
var applyResolution = (id, node, data, ctx) => {
|
|
1442
|
+
if (enterResolution(ctx, id, data) !== void 0)
|
|
1443
|
+
return;
|
|
1444
|
+
node.tApply(data, ctx);
|
|
1445
|
+
exitResolution(ctx);
|
|
1446
|
+
};
|
|
1447
|
+
var enterApplied = (ctx, id, data) => {
|
|
1448
|
+
const entered = enterResolution(ctx, id, data);
|
|
1449
|
+
return entered === void 0 ? void 0 : entered || !ctx.failFast;
|
|
1450
|
+
};
|
|
1451
|
+
var exitApplied = (ctx, continues) => {
|
|
1452
|
+
exitResolution(ctx);
|
|
1453
|
+
return continues;
|
|
1454
|
+
};
|
|
1455
|
+
var applyMember = (node, data, ctx, member = node) => member.hasAlias ? applyResolution(member.id, node, data, ctx) : node.tApply(data, ctx);
|
|
1456
|
+
var applyValue = (node, data, ctx, tfs = true) => {
|
|
1457
|
+
if (node.tfs && (tfs && (node.hasMorph || node.hasAlias) ? transformIfAllowed(ctx, node, data) : allowsInBranch(ctx, node, data)))
|
|
1458
|
+
return;
|
|
1459
|
+
if (node.entersAlias)
|
|
1460
|
+
applyResolution(node.id, node, data, ctx);
|
|
1461
|
+
else
|
|
1462
|
+
node.tApply(data, ctx);
|
|
1463
|
+
};
|
|
1464
|
+
var allowsUntracked = (node, data) => {
|
|
1465
|
+
if (inProgress.definitions || inProgress.resolutions || node.checksCtx)
|
|
1466
|
+
return;
|
|
1467
|
+
const outerVisits = aliasVisits.count;
|
|
1468
|
+
const outerContinuation = continuation;
|
|
1469
|
+
const outerConfig = continuationConfig;
|
|
1470
|
+
aliasVisits.count = 0;
|
|
1471
|
+
continuation = void 0;
|
|
1472
|
+
continuationConfig = node.$.cfg;
|
|
1473
|
+
let allowed;
|
|
1474
|
+
try {
|
|
1475
|
+
allowed = node.tAllows(data, 0);
|
|
1476
|
+
} catch (e) {
|
|
1477
|
+
aliasVisits.count = outerVisits;
|
|
1478
|
+
continuation = outerContinuation;
|
|
1479
|
+
continuationConfig = outerConfig;
|
|
1480
|
+
throw e;
|
|
1481
|
+
}
|
|
1482
|
+
const exceeded = aliasVisits.count > maxAliasVisits;
|
|
1483
|
+
aliasVisits.count = outerVisits;
|
|
1484
|
+
continuation = outerContinuation;
|
|
1485
|
+
continuationConfig = outerConfig;
|
|
1486
|
+
return exceeded ? void 0 : allowed;
|
|
1487
|
+
};
|
|
1488
|
+
var allowsAcyclic = (node, data) => {
|
|
1489
|
+
if (inProgress.definitions || inProgress.resolutions || node.checksCtx)
|
|
1490
|
+
return;
|
|
1491
|
+
const outerTracked = aliasVisits.tracked;
|
|
1492
|
+
const outerVisits = aliasVisits.count;
|
|
1493
|
+
const outerContinuation = continuation;
|
|
1494
|
+
const outerConfig = continuationConfig;
|
|
1495
|
+
aliasVisits.tracked = false;
|
|
1496
|
+
aliasVisits.count = 0;
|
|
1497
|
+
continuation = void 0;
|
|
1498
|
+
continuationConfig = node.$.cfg;
|
|
1499
|
+
try {
|
|
1500
|
+
const allowed = node.tAllows(data, 0);
|
|
1501
|
+
return aliasVisits.count > maxAliasVisits || aliasVisits.tracked ? void 0 : allowed;
|
|
1502
|
+
} finally {
|
|
1503
|
+
aliasVisits.tracked ||= outerTracked;
|
|
1504
|
+
aliasVisits.count = outerVisits;
|
|
1505
|
+
continuation = outerContinuation;
|
|
1506
|
+
continuationConfig = outerConfig;
|
|
1507
|
+
}
|
|
1508
|
+
};
|
|
1509
|
+
var allowsInContext = (node, data, config, ctor = Traversal) => allowsInTraversal(node, data, new ctor(data, config));
|
|
1510
|
+
var allowsInTraversal = (node, data, ctx) => node.tAllows(data, ctx) && !ctx.hasError();
|
|
1511
|
+
var canFill = (placeholder, result) => typeof result === "object" && result !== null && (isArray(placeholder) ? isArray(result) : objectKindOf(result) === void 0);
|
|
1512
|
+
var travKey = (key, fn, ctx) => {
|
|
1513
|
+
if (!ctx || typeof ctx === "number")
|
|
1514
|
+
return fn();
|
|
1515
|
+
ctx.path.push(key);
|
|
1516
|
+
const result = fn();
|
|
1517
|
+
ctx.path.pop();
|
|
1518
|
+
return result;
|
|
1519
|
+
};
|
|
1520
|
+
var computeDefaultValueMorph = (key, value, defaultInput, node = value, isThunkInput = isThunk(defaultInput)) => {
|
|
1521
|
+
const thunk = isThunkInput ? defaultInput : void 0;
|
|
1522
|
+
const write = (data, v) => {
|
|
1523
|
+
setOwnValue(data, key, v);
|
|
1524
|
+
return data;
|
|
1525
|
+
};
|
|
1526
|
+
if (!thunk && !node.alters && !node.hasAlias)
|
|
1527
|
+
return (data) => write(data, defaultInput);
|
|
1528
|
+
if (!node.allowsCtx && !node.ctxMorph) {
|
|
1529
|
+
return (data) => {
|
|
1530
|
+
const input = thunk ? thunk() : defaultInput;
|
|
1531
|
+
const output = value.traverse(input);
|
|
1532
|
+
if (output instanceof ArkErrors)
|
|
1533
|
+
return new TransformErrors(output, input).addTo(void 0, key);
|
|
1534
|
+
return write(data, output);
|
|
1535
|
+
};
|
|
1536
|
+
}
|
|
1537
|
+
let transformingDefault = false;
|
|
1538
|
+
return (data, ctx) => {
|
|
1539
|
+
if (transformingDefault)
|
|
1540
|
+
return data;
|
|
1541
|
+
if (!thunk && !node.tfs)
|
|
1542
|
+
return write(data, defaultInput);
|
|
1543
|
+
transformingDefault = true;
|
|
1544
|
+
try {
|
|
1545
|
+
write(data, travKey(key, () => value(thunk ? thunk() : defaultInput, ctx), ctx));
|
|
1546
|
+
} finally {
|
|
1547
|
+
transformingDefault = false;
|
|
1548
|
+
}
|
|
1549
|
+
return data;
|
|
1550
|
+
};
|
|
1551
|
+
};
|
|
1552
|
+
|
|
1553
|
+
// ../schema/out/structure/shared.js
|
|
1554
|
+
var arrayIndexSource = `^(?:0|[1-9]\\d*)$`;
|
|
1555
|
+
var arrayIndexMatcher = /* @__PURE__ */ new RegExp(arrayIndexSource);
|
|
1556
|
+
|
|
1557
|
+
// ../schema/out/runtime.js
|
|
1558
|
+
var runtimeConfig = {
|
|
1559
|
+
// validation never generates code, so it never needs eval
|
|
1560
|
+
jitless: true,
|
|
1561
|
+
onFail: null
|
|
1562
|
+
};
|
|
1563
|
+
var runtimeScope = /* @__PURE__ */ Object.freeze({
|
|
1564
|
+
cfg: runtimeConfig
|
|
1565
|
+
});
|
|
1566
|
+
var checkConfigured;
|
|
1567
|
+
var programConfig;
|
|
1568
|
+
var configureIslands;
|
|
1569
|
+
var configure = (config, fingerprint) => {
|
|
1570
|
+
if (Object.isFrozen(runtimeConfig) || checkConfigured) {
|
|
1571
|
+
return isSameConfig(config, programConfig ?? {}) ? config : throwParseError(reconfiguredMessage);
|
|
1572
|
+
}
|
|
1573
|
+
const received = fingerprintOf(config);
|
|
1574
|
+
if (fingerprint !== void 0 && fingerprint !== received)
|
|
1575
|
+
return throwParseError(configuredUnlikeBuildMessage);
|
|
1576
|
+
configureIslands?.(config);
|
|
1577
|
+
if ("onFail" in config)
|
|
1578
|
+
runtimeConfig.onFail = config.onFail;
|
|
1579
|
+
let isRechecked = false;
|
|
1580
|
+
checkConfigured = (built) => {
|
|
1581
|
+
if (!isRechecked && fingerprintOf(config) !== received)
|
|
1582
|
+
throwParseError(writtenConfigMessage);
|
|
1583
|
+
isRechecked = true;
|
|
1584
|
+
if (fingerprint === void 0 || built !== fingerprint)
|
|
1585
|
+
throwParseError(configMismatchMessage);
|
|
1586
|
+
};
|
|
1587
|
+
programConfig = copyConfig(config);
|
|
1588
|
+
return config;
|
|
1589
|
+
};
|
|
1590
|
+
var configuredWriterOf = (code, k) => (...args) => programConfig[code][k](...args);
|
|
1591
|
+
var configuredFallbackOf = (code) => (ctx) => {
|
|
1592
|
+
const { fallback } = programConfig.toJsonSchema;
|
|
1593
|
+
return (typeof fallback === "function" ? fallback : fallback[code] ?? fallback.default)(ctx);
|
|
1594
|
+
};
|
|
1595
|
+
var fingerprintOf = (config) => {
|
|
1596
|
+
const text = staticTextOf(config, []);
|
|
1597
|
+
let a = 1;
|
|
1598
|
+
let b = 2;
|
|
1599
|
+
for (let i = 0; i < text.length; i++) {
|
|
1600
|
+
a = Math.imul(a ^ text.charCodeAt(i), 2654435761);
|
|
1601
|
+
b = Math.imul(b ^ text.charCodeAt(i), 1597334677);
|
|
1602
|
+
}
|
|
1603
|
+
return `${(a >>> 0).toString(36)}_${(b >>> 0).toString(36)}`;
|
|
1604
|
+
};
|
|
1605
|
+
var staticTextOf = (value, seen) => {
|
|
1606
|
+
if (value === null || typeof value !== "object" && typeof value !== "function") {
|
|
1607
|
+
return typeof value === "string" ? JSON.stringify(value) : typeof value === "bigint" ? `${value}n` : Object.is(value, -0) ? "-0" : String(value);
|
|
1608
|
+
}
|
|
1609
|
+
const index = seen.indexOf(value);
|
|
1610
|
+
if (index !== -1)
|
|
1611
|
+
return `#${index}`;
|
|
1612
|
+
seen.push(value);
|
|
1613
|
+
if (typeof value === "function")
|
|
1614
|
+
return "function";
|
|
1615
|
+
const tag = Object.prototype.toString.call(value);
|
|
1616
|
+
const builtins2 = [
|
|
1617
|
+
null,
|
|
1618
|
+
Object.prototype,
|
|
1619
|
+
Array.prototype,
|
|
1620
|
+
Date.prototype,
|
|
1621
|
+
RegExp.prototype
|
|
1622
|
+
];
|
|
1623
|
+
const enumerable = [];
|
|
1624
|
+
for (const k in value)
|
|
1625
|
+
enumerable.push(k);
|
|
1626
|
+
let entries = "";
|
|
1627
|
+
for (const k of /* @__PURE__ */ new Set([...enumerable, ...Reflect.ownKeys(value)])) {
|
|
1628
|
+
entries += `${enumerable.includes(k) ? "" : "~"}${JSON.stringify(
|
|
1629
|
+
// a symbol key prints as its registered name
|
|
1630
|
+
typeof k === "symbol" ? [Symbol.keyFor(k)] : k
|
|
1631
|
+
)}:${staticTextOf(value[k], seen)},`;
|
|
1632
|
+
}
|
|
1633
|
+
return `${tag}${builtins2.indexOf(Object.getPrototypeOf(value))}${tag === "[object Date]" ? Number(value) : tag === "[object RegExp]" ? `${value}` : ""}{${entries}}`;
|
|
1634
|
+
};
|
|
1635
|
+
var fixConfig = (() => {
|
|
1636
|
+
Object.freeze(runtimeConfig);
|
|
1637
|
+
checkConfigured?.();
|
|
1638
|
+
});
|
|
1639
|
+
var fixConfigured = (fingerprint, path, config) => {
|
|
1640
|
+
Object.freeze(runtimeConfig);
|
|
1641
|
+
if (!checkConfigured)
|
|
1642
|
+
return throwParseError(writeCreatedBeforeConfigureMessage(path, config));
|
|
1643
|
+
checkConfigured(fingerprint);
|
|
1644
|
+
};
|
|
1645
|
+
var shareConfig = (configureArktype) => {
|
|
1646
|
+
configureIslands = configureArktype;
|
|
1647
|
+
if (programConfig)
|
|
1648
|
+
configureArktype(programConfig);
|
|
1649
|
+
};
|
|
1650
|
+
var configuredUnlikeBuildMessage = "configure() received values other than its build's";
|
|
1651
|
+
var reconfiguredMessage = "configure() must be called once, before any Type is created";
|
|
1652
|
+
var writtenConfigMessage = "configure()'s argument was modified after it was called";
|
|
1653
|
+
var configMismatchMessage = "An artifact must run under the configuration it was built with";
|
|
1654
|
+
var writeCreatedBeforeConfigureMessage = (path, config) => `${path} creates a Type before configure() runs
|
|
1655
|
+
Import the config module before any module that creates a Type: first in the entry or test setup file that loads ${path}, or at the top of ${path}:
|
|
1656
|
+
import "${config}"`;
|
|
1657
|
+
export {
|
|
1658
|
+
ArkErrors,
|
|
1659
|
+
FirstIssueTraversal,
|
|
1660
|
+
ArkErrors as FirstIssues,
|
|
1661
|
+
InternalTraversal,
|
|
1662
|
+
ToJsonSchemaError,
|
|
1663
|
+
TransformErrors,
|
|
1664
|
+
Traversal,
|
|
1665
|
+
ThrownErrors as TraversalError,
|
|
1666
|
+
addErrors,
|
|
1667
|
+
addMorphErrs,
|
|
1668
|
+
aliasVisits,
|
|
1669
|
+
alikeIssue,
|
|
1670
|
+
allowsAcyclic,
|
|
1671
|
+
allowsInBranch,
|
|
1672
|
+
allowsInBranchBy,
|
|
1673
|
+
allowsInContext,
|
|
1674
|
+
allowsUntracked,
|
|
1675
|
+
applyCyclic,
|
|
1676
|
+
applyIssues,
|
|
1677
|
+
applyMember,
|
|
1678
|
+
applyRejected,
|
|
1679
|
+
applyResolution,
|
|
1680
|
+
applyValue,
|
|
1681
|
+
arrayIndexMatcher,
|
|
1682
|
+
callMorph,
|
|
1683
|
+
codedIssue,
|
|
1684
|
+
computeDefaultValueMorph,
|
|
1685
|
+
configMismatchMessage,
|
|
1686
|
+
configure,
|
|
1687
|
+
configuredFallbackOf,
|
|
1688
|
+
configuredUnlikeBuildMessage,
|
|
1689
|
+
configuredWriterOf,
|
|
1690
|
+
copyDeclared,
|
|
1691
|
+
copyOf,
|
|
1692
|
+
describeActual,
|
|
1693
|
+
describeCollapsibleDate,
|
|
1694
|
+
describePredicate,
|
|
1695
|
+
describeUnwrittenActual,
|
|
1696
|
+
disallowed,
|
|
1697
|
+
enInfo,
|
|
1698
|
+
enterApplied,
|
|
1699
|
+
enterResolution,
|
|
1700
|
+
errorsOf,
|
|
1701
|
+
execMorph,
|
|
1702
|
+
exitApplied,
|
|
1703
|
+
exitResolution,
|
|
1704
|
+
failsKey,
|
|
1705
|
+
failsKeySite,
|
|
1706
|
+
failsSite,
|
|
1707
|
+
fingerprintOf,
|
|
1708
|
+
fixConfig,
|
|
1709
|
+
fixConfigured,
|
|
1710
|
+
foundErrors,
|
|
1711
|
+
holdsOnlyIndices,
|
|
1712
|
+
inContext,
|
|
1713
|
+
isCustomIssue,
|
|
1714
|
+
issueOf as issueAt,
|
|
1715
|
+
issuesOf,
|
|
1716
|
+
keepOwn,
|
|
1717
|
+
lineOf,
|
|
1718
|
+
listedIssue,
|
|
1719
|
+
matchesRepeated,
|
|
1720
|
+
maxAliasDepth,
|
|
1721
|
+
maxAliasVisits,
|
|
1722
|
+
mergeIssues,
|
|
1723
|
+
mergeTransformed,
|
|
1724
|
+
messageOf,
|
|
1725
|
+
missingTextOf,
|
|
1726
|
+
movedIssue,
|
|
1727
|
+
notedAs,
|
|
1728
|
+
pathOf,
|
|
1729
|
+
pipe,
|
|
1730
|
+
pipeApplied,
|
|
1731
|
+
pipeChecked,
|
|
1732
|
+
pipeOf,
|
|
1733
|
+
pipeTransformed,
|
|
1734
|
+
printKind,
|
|
1735
|
+
printedActualOf,
|
|
1736
|
+
readingContextWith,
|
|
1737
|
+
reconfiguredMessage,
|
|
1738
|
+
rejected,
|
|
1739
|
+
rejects,
|
|
1740
|
+
runtimeConfig,
|
|
1741
|
+
runtimeScope,
|
|
1742
|
+
setOwnValue,
|
|
1743
|
+
shareConfig,
|
|
1744
|
+
sharedMessageOf,
|
|
1745
|
+
silentCtx,
|
|
1746
|
+
supportedJsonSchemaTargets,
|
|
1747
|
+
throwIssues,
|
|
1748
|
+
throwOnDefault,
|
|
1749
|
+
throwOnProblem,
|
|
1750
|
+
transform,
|
|
1751
|
+
transformIfAllowed,
|
|
1752
|
+
transformResolution,
|
|
1753
|
+
transformed,
|
|
1754
|
+
transformedInApply,
|
|
1755
|
+
transformsValid,
|
|
1756
|
+
travKey,
|
|
1757
|
+
tryMorph,
|
|
1758
|
+
validateStandardJsonSchemaTarget,
|
|
1759
|
+
withContextOf,
|
|
1760
|
+
writeCreatedBeforeConfigureMessage,
|
|
1761
|
+
writeDomainActual,
|
|
1762
|
+
writeFromPath,
|
|
1763
|
+
writeLengthActual,
|
|
1764
|
+
writeLine,
|
|
1765
|
+
writeListed,
|
|
1766
|
+
writeMessage,
|
|
1767
|
+
writeNotEqualActual,
|
|
1768
|
+
writeNullableJsonSchema,
|
|
1769
|
+
writeProtoActual,
|
|
1770
|
+
writeUnionJsonSchema,
|
|
1771
|
+
writeUnitActual,
|
|
1772
|
+
writeUnitMessage,
|
|
1773
|
+
writtenConfigMessage
|
|
1774
|
+
};
|