arktype 3.0.0-beta.2 → 3.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -20
- package/out/_internal/regex/quantify.d.ts +17 -1
- package/out/_internal/schema/refinements/range.d.ts +2 -1
- package/out/_internal/schema/roots/domain.d.ts +1 -0
- package/out/_internal/schema/roots/root.d.ts +3 -1
- package/out/_internal/schema/roots/union.d.ts +8 -3
- package/out/_internal/schema/shared/compile.d.ts +2 -0
- package/out/_internal/schema/shared/declare.d.ts +9 -6
- package/out/_internal/schema/shared/errors.d.ts +3 -0
- package/out/_internal/schema/shared/issues.d.ts +5 -1
- package/out/_internal/schema/shared/issuesLean.d.ts +4 -0
- package/out/_internal/schema/shared/issuesNone.d.ts +1 -0
- package/out/_internal/schema/shared/issuesNoneLean.d.ts +1 -0
- package/out/_internal/schema/shared/standardFailure.d.ts +1 -0
- package/out/_internal/schema/shared/toJsonSchema.d.ts +16 -3
- package/out/_internal/schema/shared/transform.d.ts +1 -0
- package/out/_internal/sets/constraint.d.ts +2 -0
- package/out/_internal/sets/fromJsonSchema.d.ts +3 -1
- package/out/_internal/util/registry.d.ts +1 -1
- package/out/attributes.d.ts +12 -8
- package/out/chunk-2FVJ5JBN.js +161 -0
- package/out/{chunk-QBX4MEQR.js → chunk-3HZC67MT.js} +15 -15
- package/out/{chunk-5TN5JRP7.js → chunk-3KBOPH3J.js} +63 -41
- package/out/{chunk-GPNWBJL3.js → chunk-3WYMLH45.js} +17 -11
- package/out/{chunk-NIZDOWFU.js → chunk-46PLKNON.js} +2 -2
- package/out/{chunk-7JXN4WJX.js → chunk-4FTHWK63.js} +1 -1
- package/out/{chunk-EA2DNEDI.js → chunk-4HREHNIV.js} +12 -12
- package/out/{chunk-ZFB6DQWY.js → chunk-4J7H2ELX.js} +6 -11
- package/out/{chunk-7SVIUP6X.js → chunk-4MUH2MO4.js} +2 -2
- package/out/{chunk-J7CKAEDX.js → chunk-4NZCLVBD.js} +1 -1
- package/out/{chunk-RAM6G3F6.js → chunk-54U3D6OV.js} +26 -25
- package/out/{chunk-HA3POWOU.js → chunk-5FNHK7CC.js} +6 -5
- package/out/{chunk-KVQCLBJR.js → chunk-7SUZFAHZ.js} +241 -66
- package/out/{chunk-YMYPW3L5.js → chunk-AMNHRY72.js} +3 -3
- package/out/{chunk-UH6XKS3C.js → chunk-BQR65UPE.js} +30 -9
- package/out/{chunk-V4TZHFNK.js → chunk-BWKJV74G.js} +1 -1
- package/out/{chunk-7N3JEHA4.js → chunk-CXHXN7DF.js} +1 -1
- package/out/{chunk-FY4M7GE7.js → chunk-E4OQHHFS.js} +4 -4
- package/out/{chunk-CGWRW4JZ.js → chunk-ERGIJZFA.js} +4 -4
- package/out/{chunk-OA5Q2JLI.js → chunk-H44UG6HG.js} +8 -4
- package/out/{chunk-A7A6FDBS.js → chunk-I65VSWGS.js} +50 -44
- package/out/{chunk-C5JGK6GT.js → chunk-J2BFVWVY.js} +20 -3
- package/out/{chunk-W77ROLOT.js → chunk-JIILWIU4.js} +1 -1
- package/out/{chunk-5WRZ25AB.js → chunk-LMUBBBHJ.js} +4 -4
- package/out/{chunk-CQU7WIIR.js → chunk-P3HEEGB5.js} +6 -6
- package/out/{chunk-JZ4KBCMM.js → chunk-RKJNLXEQ.js} +21 -13
- package/out/{chunk-XMEK4I7J.js → chunk-TM22D5DL.js} +887 -266
- package/out/{chunk-PIFOURNM.js → chunk-TQYLOZRT.js} +11 -4
- package/out/{chunk-YN3XRJ7H.js → chunk-UJJGG4VQ.js} +1 -1
- package/out/{chunk-NIYAI7AF.js → chunk-US6BWOGJ.js} +3 -3
- package/out/{chunk-57LF5Y5P.js → chunk-W2XOI5DY.js} +1 -1
- package/out/{chunk-KDMHK4KP.js → chunk-XVLEFUSY.js} +2 -2
- package/out/{chunk-SGFGLENC.js → chunk-YPN67JMD.js} +3 -3
- package/out/cli.d.ts +5 -1
- package/out/cli.js +301 -49
- package/out/codecs.d.ts +4 -3
- package/out/codecs.js +18 -18
- package/out/config.js +8 -8
- package/out/declare.d.ts +2 -4
- package/out/errors.js +8 -8
- package/out/fn.d.ts +2 -2
- package/out/fromJsonSchema.d.ts +1 -1
- package/out/generic.d.ts +7 -4
- package/out/i18n.js +5 -5
- package/out/index.js +19 -19
- package/out/internal.js +32 -32
- package/out/island.js +18 -18
- package/out/islandDependency.js +33 -33
- package/out/jsonSchema/infer.d.ts +16 -6
- package/out/jsonSchema/validate.d.ts +16 -4
- package/out/keywords/functions.d.ts +4 -169
- package/out/keywords/keywords.d.ts +1 -1
- package/out/keywords/phrases.d.ts +3 -168
- package/out/keywords/ts.js +14 -14
- package/out/locales/de.js +6 -6
- package/out/locales/en.js +15 -15
- package/out/match.d.ts +12 -9
- package/out/mutatesInput.js +14 -14
- package/out/nary.d.ts +219 -193
- package/out/parser/definition.d.ts +2 -2
- package/out/parser/shift/operator/default.d.ts +2 -2
- package/out/parser/tupleExpressions.d.ts +2 -0
- package/out/precompiled.js +11 -11
- package/out/runtime.d.ts +1 -1
- package/out/runtime.js +5 -5
- package/out/schema.js +11 -11
- package/out/schemaInternal.js +29 -17
- package/out/schemaRuntime.js +4 -4
- package/out/schemaRuntimeLean.js +60 -36
- package/out/schemaRuntimeNone.js +52 -31
- package/out/schemaRuntimeNoneLean.js +52 -31
- package/out/type.d.ts +3 -3
- package/out/util.js +14 -11
- package/out/variants/base.d.ts +9 -8
- package/out/variants/object.d.ts +14 -6
- package/package.json +4 -4
- package/skills/arktype/SKILL.md +17 -17
- package/skills/arktype/references/migrating.md +13 -13
- package/skills/arktype/references/precompile.md +4 -4
- package/out/chunk-CSVAPWDE.js +0 -83
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
WeakCache,
|
|
8
8
|
defineLazily,
|
|
9
9
|
holdsWeakly
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-UJJGG4VQ.js";
|
|
11
11
|
import {
|
|
12
12
|
ipv4Matcher,
|
|
13
13
|
ipv6Matcher,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
isUuid,
|
|
18
18
|
iso8601Matcher,
|
|
19
19
|
uuidMatcher
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-US6BWOGJ.js";
|
|
21
21
|
import {
|
|
22
22
|
ToJsonSchema,
|
|
23
23
|
assertNoProblemConfig,
|
|
@@ -37,10 +37,10 @@ import {
|
|
|
37
37
|
rootKinds,
|
|
38
38
|
structuralKinds,
|
|
39
39
|
structureKeys
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-P3HEEGB5.js";
|
|
41
41
|
import {
|
|
42
42
|
validateStandardJsonSchemaTarget
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-W2XOI5DY.js";
|
|
44
44
|
import {
|
|
45
45
|
capitalize,
|
|
46
46
|
hashOf
|
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
rootApplyParams,
|
|
50
50
|
rootApplyRuntime,
|
|
51
51
|
writeRootApply
|
|
52
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-ERGIJZFA.js";
|
|
53
53
|
import {
|
|
54
54
|
CompiledFunction,
|
|
55
55
|
NodeCompiler,
|
|
@@ -60,7 +60,7 @@ import {
|
|
|
60
60
|
isRefinedBasis,
|
|
61
61
|
returnsTransformErrors,
|
|
62
62
|
tryJit
|
|
63
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-TQYLOZRT.js";
|
|
64
64
|
import {
|
|
65
65
|
$ark,
|
|
66
66
|
ArkErrors,
|
|
@@ -79,7 +79,7 @@ import {
|
|
|
79
79
|
registeredReference,
|
|
80
80
|
registryName,
|
|
81
81
|
siteTraversalOf
|
|
82
|
-
} from "./chunk-
|
|
82
|
+
} from "./chunk-I65VSWGS.js";
|
|
83
83
|
import {
|
|
84
84
|
Issues,
|
|
85
85
|
TransformErrors,
|
|
@@ -136,6 +136,7 @@ import {
|
|
|
136
136
|
rejects,
|
|
137
137
|
removedProblemMessage,
|
|
138
138
|
resolving,
|
|
139
|
+
setOwnValue,
|
|
139
140
|
silentCtx,
|
|
140
141
|
throwOnDefault,
|
|
141
142
|
transform,
|
|
@@ -149,11 +150,12 @@ import {
|
|
|
149
150
|
withContextOf,
|
|
150
151
|
withoutHoleNames,
|
|
151
152
|
writeLine
|
|
152
|
-
} from "./chunk-
|
|
153
|
+
} from "./chunk-3KBOPH3J.js";
|
|
153
154
|
import {
|
|
155
|
+
arkUtilVersion,
|
|
154
156
|
nameOf,
|
|
155
157
|
registeredNameOf
|
|
156
|
-
} from "./chunk-
|
|
158
|
+
} from "./chunk-J2BFVWVY.js";
|
|
157
159
|
import {
|
|
158
160
|
Callable,
|
|
159
161
|
DynamicBase,
|
|
@@ -211,7 +213,7 @@ import {
|
|
|
211
213
|
unset,
|
|
212
214
|
wellFormedIntegerMatcher,
|
|
213
215
|
withAlphabetizedKeys
|
|
214
|
-
} from "./chunk-
|
|
216
|
+
} from "./chunk-3HZC67MT.js";
|
|
215
217
|
|
|
216
218
|
// ../schema/out/shared/disjoint.js
|
|
217
219
|
var Disjoint = class Disjoint extends Array {
|
|
@@ -1732,10 +1734,17 @@ var zeroDivisorMessage = "divisor must be non-zero";
|
|
|
1732
1734
|
|
|
1733
1735
|
// ../schema/out/refinements/range.js
|
|
1734
1736
|
var BaseRange = class extends InternalPrimitiveConstraint {
|
|
1737
|
+
expression;
|
|
1735
1738
|
constructor(...args) {
|
|
1736
1739
|
super(...args);
|
|
1737
1740
|
if (this.opKind === "length")
|
|
1738
1741
|
assertLengthRule(this.kind, this.rule);
|
|
1742
|
+
else if (this.opKind === "value") {
|
|
1743
|
+
if (typeof this.rule !== "number" || Number.isNaN(this.rule))
|
|
1744
|
+
throwParseError(writeInvalidRangeRuleMessage(this.kind, this.rule));
|
|
1745
|
+
} else if (!(this.rule instanceof Date) || !isValidDate(this.rule))
|
|
1746
|
+
throwParseError(writeInvalidRangeRuleMessage(this.kind, this.rule));
|
|
1747
|
+
this.expression = `${this.comparator} ${this.opKind === "date" ? `d'${this.stringLimit}'` : printDecimal(this.rule)}`;
|
|
1739
1748
|
}
|
|
1740
1749
|
sameInner(r) {
|
|
1741
1750
|
if (!Number.isFinite(this.rule) || !Number.isFinite(r.rule))
|
|
@@ -1753,13 +1762,12 @@ var BaseRange = class extends InternalPrimitiveConstraint {
|
|
|
1753
1762
|
get numRule() {
|
|
1754
1763
|
return this.rule.valueOf();
|
|
1755
1764
|
}
|
|
1756
|
-
expression = `${this.comparator} ${this.opKind === "date" ? `d'${this.stringLimit}'` : printDecimal(this.rule)}`;
|
|
1757
1765
|
get limitKind() {
|
|
1758
1766
|
return this.comparator["0"] === "<" ? "upper" : "lower";
|
|
1759
1767
|
}
|
|
1760
1768
|
jsCond(js, data) {
|
|
1761
1769
|
const actual = this.opKind === "value" ? data : this.opKind === "length" ? `${data}.length` : `${data}.valueOf()`;
|
|
1762
|
-
return `${actual} ${this.comparator} ${this.numRule}`;
|
|
1770
|
+
return `${actual} ${this.comparator} ${js.num(this.numRule)}`;
|
|
1763
1771
|
}
|
|
1764
1772
|
get stringLimit() {
|
|
1765
1773
|
return this.opKind === "date" ? dateLimitToString(this.numRule) : `${this.numRule}`;
|
|
@@ -1785,6 +1793,7 @@ var boundKindPairsByLower = {
|
|
|
1785
1793
|
after: "before"
|
|
1786
1794
|
};
|
|
1787
1795
|
var writeInvalidLengthBoundMessage = (kind, limit) => `${kind} bound must be a positive integer (was ${limit})`;
|
|
1796
|
+
var writeInvalidRangeRuleMessage = function (kind, limit) { return `${kind} bound must be ${kind === "before" || kind === "after" ? "a valid Date" : "a number"} (was ${printable(limit)})` };
|
|
1788
1797
|
var assertLengthRule = (kind, rule) => {
|
|
1789
1798
|
if (!Number.isInteger(rule) || rule < 0)
|
|
1790
1799
|
throwParseError(writeInvalidLengthBoundMessage(kind, rule));
|
|
@@ -2155,10 +2164,40 @@ var message = {
|
|
|
2155
2164
|
},
|
|
2156
2165
|
enumerable: true
|
|
2157
2166
|
};
|
|
2158
|
-
var
|
|
2159
|
-
value
|
|
2160
|
-
|
|
2161
|
-
|
|
2167
|
+
var toJson = {
|
|
2168
|
+
value() {
|
|
2169
|
+
return {
|
|
2170
|
+
issues: this._s(true),
|
|
2171
|
+
message: this._s()
|
|
2172
|
+
};
|
|
2173
|
+
},
|
|
2174
|
+
writable: true,
|
|
2175
|
+
configurable: true
|
|
2176
|
+
};
|
|
2177
|
+
var jsonKeyOf = (k) => typeof k === "symbol" ? String(k) : k;
|
|
2178
|
+
var jsonPathOf = function (path) { return path.map((segment) => typeof segment === "object" && segment !== null ? { key: jsonKeyOf(segment.key) } : jsonKeyOf(segment)) };
|
|
2179
|
+
var jsonIssueOf = function (issue) { return ({
|
|
2180
|
+
...issue.code !== void 0 && { code: issue.code },
|
|
2181
|
+
...issue.path !== void 0 && { path: jsonPathOf(issue.path) },
|
|
2182
|
+
...issue.expected !== void 0 && { expected: issue.expected },
|
|
2183
|
+
message: issue.message,
|
|
2184
|
+
...issue.errors?.length ? { errors: issue.errors.map(jsonIssueOf) } : {}
|
|
2185
|
+
}) };
|
|
2186
|
+
var issuesToJson = {
|
|
2187
|
+
value() {
|
|
2188
|
+
return this.map(jsonIssueOf);
|
|
2189
|
+
},
|
|
2190
|
+
writable: true,
|
|
2191
|
+
configurable: true
|
|
2192
|
+
};
|
|
2193
|
+
var serializableIssuesOf = function (issues) { return typeof issues.toJSON === "function" ? issues : Object.defineProperty(Object.isExtensible(issues) ? issues : [...issues], "toJSON", issuesToJson) };
|
|
2194
|
+
var standardFailureOf = function (errors) {
|
|
2195
|
+
const issues = serializableIssuesOf(errors.issues);
|
|
2196
|
+
return Object.defineProperty(Object.defineProperty(Object.defineProperty({ issues }, "_s", {
|
|
2197
|
+
value: (json) => json ? typeof errors.toJSON === "function" ? errors.toJSON() : issues.map(jsonIssueOf) : errors.summary,
|
|
2198
|
+
writable: true
|
|
2199
|
+
}), "message", message), "toJSON", toJson);
|
|
2200
|
+
};
|
|
2162
2201
|
|
|
2163
2202
|
// ../schema/out/structure/prop.js
|
|
2164
2203
|
var BaseProp = class extends BaseConstraint {
|
|
@@ -2400,7 +2439,7 @@ var BaseRoot = class BaseRoot extends BaseNode {
|
|
|
2400
2439
|
jsonSchema: {
|
|
2401
2440
|
// _in has no defaults, so the input is this Type as it's accepted
|
|
2402
2441
|
input: (opts) => toStandardJsonSchema(this, opts, "in"),
|
|
2403
|
-
output: (opts) => toStandardJsonSchema(this._out, opts)
|
|
2442
|
+
output: (opts) => toStandardJsonSchema(this._out, opts, "out")
|
|
2404
2443
|
}
|
|
2405
2444
|
},
|
|
2406
2445
|
// whether an issue of its own is custom, which another copy of
|
|
@@ -2565,16 +2604,33 @@ var BaseRoot = class BaseRoot extends BaseNode {
|
|
|
2565
2604
|
}, { reduced: true });
|
|
2566
2605
|
}
|
|
2567
2606
|
overlaps(r) {
|
|
2568
|
-
|
|
2569
|
-
|
|
2607
|
+
if (this.isNever())
|
|
2608
|
+
return false;
|
|
2609
|
+
const l = withoutDefaults(this);
|
|
2610
|
+
const rNode = withoutDefaults(this.$.parseDef(r));
|
|
2611
|
+
if (rNode.isNever())
|
|
2612
|
+
return false;
|
|
2613
|
+
const intersection = l.intersect(rNode, false);
|
|
2614
|
+
return !(intersection instanceof Disjoint) && !intersection.isNever();
|
|
2570
2615
|
}
|
|
2571
2616
|
extends(r) {
|
|
2572
2617
|
if (this.isNever() || isNode(r) && this.kind === r.kind && innerHashesMatch(this, r))
|
|
2573
2618
|
return true;
|
|
2574
|
-
const
|
|
2619
|
+
const l = withoutDefaults(this);
|
|
2620
|
+
const rNode = withoutDefaults(this.$.parseDef(r));
|
|
2621
|
+
if (l.kind === rNode.kind && innerHashesMatch(l, rNode))
|
|
2622
|
+
return true;
|
|
2623
|
+
const intersection = l.intersect(rNode, false);
|
|
2575
2624
|
if (intersection instanceof Disjoint)
|
|
2576
2625
|
return false;
|
|
2577
|
-
return
|
|
2626
|
+
return l.equals(intersection) || !l.hasAlias && !intersection.hasAlias && isMutuallySimulated(l, intersection);
|
|
2627
|
+
}
|
|
2628
|
+
/** transforms this root inside an enclosing transform, sharing its cycle state */
|
|
2629
|
+
transformWithin(mapper, ctx) {
|
|
2630
|
+
return this._tf(mapper, {
|
|
2631
|
+
...ctx,
|
|
2632
|
+
undeclaredHandling: void 0
|
|
2633
|
+
});
|
|
2578
2634
|
}
|
|
2579
2635
|
ifExtends(r) {
|
|
2580
2636
|
return this.extends(r) ? this : void 0;
|
|
@@ -2772,20 +2828,86 @@ var makeMorph = (make, ...args) => {
|
|
|
2772
2828
|
madeMorphs.set(morph, [make, args]);
|
|
2773
2829
|
return morph;
|
|
2774
2830
|
};
|
|
2831
|
+
var isDefaultedNode = (node2) => node2.is("optional") && node2.hasDef() || node2.is("sequence") && node2.defLen !== 0;
|
|
2832
|
+
var reachesDefaultCache = /* @__PURE__ */ new WeakMap();
|
|
2833
|
+
var withoutDefaultsCache = /* @__PURE__ */ new WeakMap();
|
|
2834
|
+
var computeReachesDefault = function (root, final) {
|
|
2835
|
+
if (!root.alters && !(final && root.tfs))
|
|
2836
|
+
return false;
|
|
2837
|
+
const followAliases = root.hasAlias && final;
|
|
2838
|
+
const visited = /* @__PURE__ */ new Set();
|
|
2839
|
+
const queue = [root];
|
|
2840
|
+
for (let i = 0; i < queue.length; i++) {
|
|
2841
|
+
for (const ref of referencesWithoutCases(queue[i])) {
|
|
2842
|
+
if (visited.has(ref))
|
|
2843
|
+
continue;
|
|
2844
|
+
visited.add(ref);
|
|
2845
|
+
if (isDefaultedNode(ref))
|
|
2846
|
+
return true;
|
|
2847
|
+
if (followAliases && ref.is("alias"))
|
|
2848
|
+
queue.push(ref.resolution);
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2851
|
+
return false;
|
|
2852
|
+
};
|
|
2853
|
+
var reachesDefault = function (root) {
|
|
2854
|
+
if (!root.alters && !root.hasAlias)
|
|
2855
|
+
return false;
|
|
2856
|
+
const final = isResolutionFinal();
|
|
2857
|
+
const cacheable = final || !root.hasAlias;
|
|
2858
|
+
if (cacheable) {
|
|
2859
|
+
const cached2 = reachesDefaultCache.get(root);
|
|
2860
|
+
if (cached2 !== void 0)
|
|
2861
|
+
return cached2;
|
|
2862
|
+
}
|
|
2863
|
+
const result = computeReachesDefault(root, final);
|
|
2864
|
+
if (cacheable)
|
|
2865
|
+
reachesDefaultCache.set(root, result);
|
|
2866
|
+
return result;
|
|
2867
|
+
};
|
|
2868
|
+
var withoutDefaults = function (node2) {
|
|
2869
|
+
if (!node2.alters && !node2.hasAlias)
|
|
2870
|
+
return node2;
|
|
2871
|
+
const final = isResolutionFinal();
|
|
2872
|
+
const cacheable = final || !node2.hasAlias;
|
|
2873
|
+
if (cacheable) {
|
|
2874
|
+
const cached2 = withoutDefaultsCache.get(node2);
|
|
2875
|
+
if (cached2 !== void 0)
|
|
2876
|
+
return cached2;
|
|
2877
|
+
}
|
|
2878
|
+
const result = reachesDefault(node2) ? node2.transform((kind, inner) => {
|
|
2879
|
+
if (kind === "optional" && "default" in inner)
|
|
2880
|
+
return omit(inner, { default: 1 });
|
|
2881
|
+
if (kind === "sequence" && inner.defaultables) {
|
|
2882
|
+
const { defaultables, optionals, ...rest } = inner;
|
|
2883
|
+
return {
|
|
2884
|
+
...rest,
|
|
2885
|
+
optionals: [
|
|
2886
|
+
...defaultables.map(([element]) => element),
|
|
2887
|
+
...optionals ?? []
|
|
2888
|
+
]
|
|
2889
|
+
};
|
|
2890
|
+
}
|
|
2891
|
+
return inner;
|
|
2892
|
+
}, {
|
|
2893
|
+
shouldTf: (n) => n.alters || n.is("optional") && n.hasDef() || final && n.tfs
|
|
2894
|
+
}) : node2;
|
|
2895
|
+
if (cacheable)
|
|
2896
|
+
withoutDefaultsCache.set(node2, result);
|
|
2897
|
+
return result;
|
|
2898
|
+
};
|
|
2775
2899
|
var emptyBrandNameMessage = `Expected a non-empty brand name after #`;
|
|
2776
2900
|
var toStandardJsonSchema = function (node2, opts, io) {
|
|
2901
|
+
const target = validateStandardJsonSchemaTarget(opts.target);
|
|
2777
2902
|
const ctx = mergeToJsonSchemaConfigs(node2.$.cfg.toJsonSchema, {
|
|
2778
|
-
|
|
2779
|
-
|
|
2903
|
+
...opts.libraryOptions,
|
|
2904
|
+
target
|
|
2780
2905
|
});
|
|
2781
2906
|
const fallback = flatMorph(ctx.fallback, (code, handler) => [
|
|
2782
2907
|
code,
|
|
2783
2908
|
handler === ToJsonSchema.defaultConfig.fallback[code] ? ToJsonSchema.standardFallback[code] : handler
|
|
2784
2909
|
]);
|
|
2785
|
-
|
|
2786
|
-
if (io)
|
|
2787
|
-
standardCtx.io = io;
|
|
2788
|
-
return node2.toJsonSchema(standardCtx);
|
|
2910
|
+
return node2.toJsonSchema({ ...ctx, fallback, io });
|
|
2789
2911
|
};
|
|
2790
2912
|
var withMessage = function (kind, schema, message2) {
|
|
2791
2913
|
if (message2 === void 0)
|
|
@@ -3142,6 +3264,8 @@ var implementation15 = implementNode({
|
|
|
3142
3264
|
var DomainNode = class extends InternalBasis {
|
|
3143
3265
|
constructor(...args) {
|
|
3144
3266
|
super(...args);
|
|
3267
|
+
if (typeof this.domain !== "string" || !hasOwn(domainDescriptions, this.domain))
|
|
3268
|
+
throwParseError(Domain.writeInvalidDomainMessage(this.domain));
|
|
3145
3269
|
if (this.domain !== "number") {
|
|
3146
3270
|
if (this.numberAllowsNaN !== void 0)
|
|
3147
3271
|
throwParseError(Domain.writeBadAllowNanMessage(this.domain));
|
|
@@ -3161,7 +3285,7 @@ var DomainNode = class extends InternalBasis {
|
|
|
3161
3285
|
return this.domain === "object" ? (
|
|
3162
3286
|
// the check an object's Allows writes, so a bundle holding both compresses it away
|
|
3163
3287
|
js.trav === "Apply" ? `(${data} instanceof Object || Object(${data}) === ${data})` : `${data} !== null && (typeof ${data} === "object" || typeof ${data} === "function")`
|
|
3164
|
-
) : this.checksNaN && this.checksInf ? `Number.isFinite(${data})` : `typeof ${data} ===
|
|
3288
|
+
) : this.checksNaN && this.checksInf ? `Number.isFinite(${data})` : `typeof ${data} === ${JSON.stringify(this.domain)}${this.checksNaN ? ` && !Number.isNaN(${data})` : this.checksInf ? ` && ${data} !== Infinity && ${data} !== -Infinity` : ""}`;
|
|
3165
3289
|
}
|
|
3166
3290
|
expression = this.numberAllowsNaN || this.numberAllowsInfinity ? `number${this.numberAllowsNaN ? " | NaN" : ""}${this.numberAllowsInfinity ? " | Infinity | -Infinity" : ""}` : this.domain;
|
|
3167
3291
|
get nestedExpr() {
|
|
@@ -3174,6 +3298,7 @@ var DomainNode = class extends InternalBasis {
|
|
|
3174
3298
|
var Domain = {
|
|
3175
3299
|
impl: implementation15,
|
|
3176
3300
|
Node: DomainNode,
|
|
3301
|
+
writeInvalidDomainMessage: (actual) => `domain must be a valid JS domain (was ${printable(actual)})`,
|
|
3177
3302
|
writeBadAllowNanMessage: (actual) => `numberAllowsNaN may only be specified with domain "number" (was ${actual})`,
|
|
3178
3303
|
writeBadAllowInfinityMessage: (actual) => `numberAllowsInfinity may only be specified with domain "number" (was ${actual})`
|
|
3179
3304
|
};
|
|
@@ -3833,14 +3958,19 @@ var UnionNode = class extends BaseRoot {
|
|
|
3833
3958
|
return this.distribute((branch) => branch.brief, describeBranches);
|
|
3834
3959
|
}
|
|
3835
3960
|
/**
|
|
3836
|
-
*
|
|
3837
|
-
*
|
|
3961
|
+
* the discriminant an uncompiled check reads. A Type compiled later checks
|
|
3962
|
+
* its first data through its branches, sparing that call discriminating
|
|
3963
|
+
* every union on the data's path. A predicate reading ctx is only called for
|
|
3964
|
+
* the branch compiled code picks, and a node never compiled checks as
|
|
3965
|
+
* compiled code would. This reads no cache: whether something else had
|
|
3966
|
+
* already discriminated the union (a binding sizing its references by id,
|
|
3967
|
+
* a describe of a miss) would decide which branches' predicates are called
|
|
3838
3968
|
*/
|
|
3839
|
-
get
|
|
3840
|
-
return this.
|
|
3969
|
+
get uncompiledDisc() {
|
|
3970
|
+
return this.checksCtx || !canJit(this.$.cfg) ? this.discriminant : null;
|
|
3841
3971
|
}
|
|
3842
3972
|
tAllows(data, ctx) {
|
|
3843
|
-
const discriminant = this.
|
|
3973
|
+
const discriminant = this.uncompiledDisc;
|
|
3844
3974
|
if (!discriminant) {
|
|
3845
3975
|
return this.branches.some((b) => b.checksCtx ? allowsInBranch(ctx, b, data) : b.tAllows(data, ctx));
|
|
3846
3976
|
}
|
|
@@ -3978,10 +4108,10 @@ var UnionNode = class extends BaseRoot {
|
|
|
3978
4108
|
written.push([caseCondition, caseResult]);
|
|
3979
4109
|
}
|
|
3980
4110
|
const otherwise = js.trav === "Allows" ? "false" : js.trav === "Transform" ? "data" : js.missFails?.(this) ?? `${js.ref(this)}.applyMiss(data, ctx, ${value})`;
|
|
3981
|
-
if (js.trav === "Apply" && written.length === 2) {
|
|
4111
|
+
if (js.trav === "Apply" && discriminant.kind === "domain" && written.length === 2) {
|
|
3982
4112
|
const unitIndex = written.findIndex(([label2, result2]) => result2 === "true" && (label2 === `case "null"` || label2 === `case "undefined"`));
|
|
3983
4113
|
const [label, result] = written[1 - unitIndex] ?? [];
|
|
3984
|
-
if (unitIndex !== -1 && label !== `case "object"` && label !== "default") {
|
|
4114
|
+
if (unitIndex !== -1 && label !== `case "object"` && label !== `case "null"` && label !== "default") {
|
|
3985
4115
|
js.return(`${value} === ${written[unitIndex][0].slice(6, -1)} || (typeof ${value} === ${label.slice(5)} ? ${result} : ${otherwise})`);
|
|
3986
4116
|
return;
|
|
3987
4117
|
}
|
|
@@ -4067,7 +4197,21 @@ var unitOf = function (k) { return k.startsWith(registeredPrefix) ? $ark[k.slice
|
|
|
4067
4197
|
var invokeTransform = function (js, branch, member) { return member ? `${js.ref(transformResolution)}(ctx, "${js.nameOf(member.id)}", data, ${js.refToId(branch.id, { kind: "Transform" })})` : js.needsCtx && returnsTransformErrors(branch) ? `${js.ref(transformed)}(ctx, ${js.inv(branch)}, data)` : js.inv(branch) };
|
|
4068
4198
|
|
|
4069
4199
|
// ../schema/out/roots/unit.js
|
|
4070
|
-
var
|
|
4200
|
+
var dateTimeOf = (v) => isDate(v) ? timeOf(v) : void 0;
|
|
4201
|
+
var describeUnit = function (unit) {
|
|
4202
|
+
if (isDate(unit)) {
|
|
4203
|
+
const time = timeOf(unit);
|
|
4204
|
+
if (time === void 0)
|
|
4205
|
+
return printable({ ...unit }, { ownDataOnly: true });
|
|
4206
|
+
if (Number.isNaN(time))
|
|
4207
|
+
return "Invalid Date";
|
|
4208
|
+
}
|
|
4209
|
+
return printable(unit, { ownDataOnly: true });
|
|
4210
|
+
};
|
|
4211
|
+
var serializeUnit = function (unit) {
|
|
4212
|
+
const time = dateTimeOf(unit);
|
|
4213
|
+
return time !== void 0 ? Number.isNaN(time) ? "Invalid Date" : unit.toISOString() : hasDomain(unit, "object") || typeof unit === "symbol" ? registeredReference(unit) : defaultValueSerializer(unit);
|
|
4214
|
+
};
|
|
4071
4215
|
var implementation20 = implementNode({
|
|
4072
4216
|
kind: "unit",
|
|
4073
4217
|
ownErr: true,
|
|
@@ -4078,26 +4222,30 @@ var implementation20 = implementNode({
|
|
|
4078
4222
|
}
|
|
4079
4223
|
},
|
|
4080
4224
|
defaults: {
|
|
4081
|
-
description: (node2) =>
|
|
4225
|
+
description: (node2) => describeUnit(node2.unit)
|
|
4082
4226
|
}
|
|
4083
4227
|
});
|
|
4084
4228
|
var UnitNode = class extends InternalBasis {
|
|
4085
4229
|
/** its unit as JSON: a Date by its ISO string, an object or symbol by its registered reference */
|
|
4086
4230
|
unitJson = serializeUnit(this.unit);
|
|
4087
4231
|
/** its unit written as a JavaScript literal, as compiled code compares data to it */
|
|
4088
|
-
jsUnit =
|
|
4232
|
+
jsUnit = dateTimeOf(this.unit) !== void 0 ? JSON.stringify(this.unitJson) : compileSerializedValue(this.unit);
|
|
4089
4233
|
sameInner(r) {
|
|
4090
4234
|
return this.unitJson === r.unitJson;
|
|
4091
4235
|
}
|
|
4092
4236
|
jsCond(js, data) {
|
|
4093
|
-
|
|
4237
|
+
const time = dateTimeOf(this.unit);
|
|
4238
|
+
return time !== void 0 ? Number.isNaN(time) ? `${data} instanceof Date && Number.isNaN(${js.ref(timeOf)}(${data}))` : `${data} instanceof Date && ${js.ref(timeOf)}(${data}) === ${time}` : Number.isNaN(this.unit) ? `Number.isNaN(${data})` : hasDomain(this.unit, "object") || typeof this.unit === "symbol" ? `${data} === ${js.ref(this.unit)}` : `${data} === ${this.jsUnit}`;
|
|
4094
4239
|
}
|
|
4095
|
-
expression =
|
|
4240
|
+
expression = dateTimeOf(this.unit) !== void 0 ? this.unitJson === "Invalid Date" ? "Invalid Date" : `d'${this.unitJson}'` : typeof this.unit === "number" ? printDecimal(this.unit) : describeUnit(this.unit);
|
|
4096
4241
|
domain = domainOf(this.unit);
|
|
4097
4242
|
get brief() {
|
|
4098
4243
|
return this.domain === "object" ? domainDescriptions.object : this.description;
|
|
4099
4244
|
}
|
|
4100
|
-
tAllows =
|
|
4245
|
+
tAllows = (() => {
|
|
4246
|
+
const time = dateTimeOf(this.unit);
|
|
4247
|
+
return time !== void 0 ? Number.isNaN(time) ? (data) => data instanceof Date && Number.isNaN(timeOf(data)) : (data) => data instanceof Date && timeOf(data) === time : Number.isNaN(this.unit) ? (data) => Number.isNaN(data) : (data) => data === this.unit;
|
|
4248
|
+
})();
|
|
4101
4249
|
};
|
|
4102
4250
|
var Unit = {
|
|
4103
4251
|
impl: implementation20,
|
|
@@ -4974,7 +5122,8 @@ var StructureNode = class extends BaseConstraint {
|
|
|
4974
5122
|
return value;
|
|
4975
5123
|
if (out === data && copies)
|
|
4976
5124
|
out = this.copy(data);
|
|
4977
|
-
|
|
5125
|
+
setOwnValue(out, k, transformed2);
|
|
5126
|
+
return transformed2;
|
|
4978
5127
|
};
|
|
4979
5128
|
const hasIndexedProp = this.hasIndexedProp;
|
|
4980
5129
|
const props = this.inOrder;
|
|
@@ -5104,11 +5253,11 @@ var StructureNode = class extends BaseConstraint {
|
|
|
5104
5253
|
if (out !== data && !sequence) {
|
|
5105
5254
|
for (const prop of this.inOrder) {
|
|
5106
5255
|
if (!(prop.key in out) && prop.key in data)
|
|
5107
|
-
out
|
|
5256
|
+
setOwnValue(out, prop.key, data[prop.key]);
|
|
5108
5257
|
}
|
|
5109
5258
|
for (const prop of this.protoProps) {
|
|
5110
5259
|
if (!hasOwn(out, prop.key) && hasOwn(data, prop.key))
|
|
5111
|
-
out
|
|
5260
|
+
setOwnValue(out, prop.key, data[prop.key]);
|
|
5112
5261
|
}
|
|
5113
5262
|
}
|
|
5114
5263
|
if (this.undeclared !== "delete" || sliced)
|
|
@@ -5126,7 +5275,7 @@ var StructureNode = class extends BaseConstraint {
|
|
|
5126
5275
|
const result = {};
|
|
5127
5276
|
for (const prop of this.inOrder)
|
|
5128
5277
|
if (prop.key in out)
|
|
5129
|
-
result
|
|
5278
|
+
setOwnValue(result, prop.key, out[prop.key]);
|
|
5130
5279
|
for (const prop of this.protoProps) {
|
|
5131
5280
|
if (!this.tfsOf(prop).length && !hasOwn(data, prop.key))
|
|
5132
5281
|
delete result[prop.key];
|
|
@@ -5134,7 +5283,7 @@ var StructureNode = class extends BaseConstraint {
|
|
|
5134
5283
|
if (this.index) {
|
|
5135
5284
|
for (const k of ownKeysOf(out)) {
|
|
5136
5285
|
if (!(k in this.byKey) && this.declaresKey(k))
|
|
5137
|
-
result
|
|
5286
|
+
setOwnValue(result, k, out[k]);
|
|
5138
5287
|
}
|
|
5139
5288
|
}
|
|
5140
5289
|
return result;
|
|
@@ -5145,9 +5294,10 @@ var StructureNode = class extends BaseConstraint {
|
|
|
5145
5294
|
}
|
|
5146
5295
|
copy(data, copy = copyOf(data)) {
|
|
5147
5296
|
if (this.sequence) {
|
|
5148
|
-
for (const prop of this.inOrder)
|
|
5297
|
+
for (const prop of this.inOrder) {
|
|
5149
5298
|
if (prop.key in data)
|
|
5150
|
-
copy
|
|
5299
|
+
setOwnValue(copy, prop.key, data[prop.key]);
|
|
5300
|
+
}
|
|
5151
5301
|
}
|
|
5152
5302
|
return copy;
|
|
5153
5303
|
}
|
|
@@ -5275,7 +5425,7 @@ var StructureNode = class extends BaseConstraint {
|
|
|
5275
5425
|
const { key, optional } = prop;
|
|
5276
5426
|
const keyExpr = js.serialize(key);
|
|
5277
5427
|
const onChange = () => {
|
|
5278
|
-
this.jsCopy(js, { first: i === 0 }).line(
|
|
5428
|
+
this.jsCopy(js, { first: i === 0 }).line(jsSetOwnProp(js, "out", key, `transformed${i}`));
|
|
5279
5429
|
if (once)
|
|
5280
5430
|
this.jsDeclaredCopy(js, [key]);
|
|
5281
5431
|
};
|
|
@@ -5369,7 +5519,7 @@ var StructureNode = class extends BaseConstraint {
|
|
|
5369
5519
|
js.line(`${js.ref(keepOwn)}(out, data, ${js.serialize(prop.key)})`);
|
|
5370
5520
|
}
|
|
5371
5521
|
for (const prop of this.protoProps) {
|
|
5372
|
-
js.if(`!Object.prototype.hasOwnProperty.call(out, ${js.serialize(prop.key)}) && Object.prototype.hasOwnProperty.call(data, ${js.serialize(prop.key)})`, () => js.line(
|
|
5522
|
+
js.if(`!Object.prototype.hasOwnProperty.call(out, ${js.serialize(prop.key)}) && Object.prototype.hasOwnProperty.call(data, ${js.serialize(prop.key)})`, () => js.line(jsSetOwnProp(js, "out", prop.key, `data${js.prop(prop.key)}`)));
|
|
5373
5523
|
}
|
|
5374
5524
|
return js;
|
|
5375
5525
|
};
|
|
@@ -5378,7 +5528,7 @@ var StructureNode = class extends BaseConstraint {
|
|
|
5378
5528
|
/** writes the copy of data's props: an array's copy has only its enumerable props */
|
|
5379
5529
|
jsCopyProps(js, from, to) {
|
|
5380
5530
|
for (const prop of this.inOrder) {
|
|
5381
|
-
const store =
|
|
5531
|
+
const store = jsSetOwnProp(js, to, prop.key, `${from}${js.prop(prop.key)}`);
|
|
5382
5532
|
if (prop.required)
|
|
5383
5533
|
js.line(store);
|
|
5384
5534
|
else
|
|
@@ -5418,7 +5568,7 @@ var StructureNode = class extends BaseConstraint {
|
|
|
5418
5568
|
for (let i = 0; i < transformedProps.length; i++) {
|
|
5419
5569
|
const prop = transformedProps[i];
|
|
5420
5570
|
const changed = js.cmpTfd(this.tfsOf(prop), `transformed${i}`, "!==", `value${i}`);
|
|
5421
|
-
js.if(changed, () => this.jsCopy(js).line(
|
|
5571
|
+
js.if(changed, () => this.jsCopy(js).line(jsSetOwnProp(js, "out", prop.key, `transformed${i}`)));
|
|
5422
5572
|
}
|
|
5423
5573
|
this.jsDefaults(js);
|
|
5424
5574
|
if (outMayBeCopied || transformedProps.length || this.defaultable.length)
|
|
@@ -5455,7 +5605,7 @@ var StructureNode = class extends BaseConstraint {
|
|
|
5455
5605
|
return i === -1 ? `out${js.prop(prop.key)}` : `transformed${i}`;
|
|
5456
5606
|
};
|
|
5457
5607
|
const [literal, added] = this.resultLayout;
|
|
5458
|
-
const literalOf = (props, valueOf) => `{ ${props.map((prop) => `${typeof prop.key === "symbol" ? `[${js.ref(prop.key)}]` : prop.serializedKey}: ${valueOf(prop)}`).join(", ")} }`;
|
|
5608
|
+
const literalOf = (props, valueOf) => `{ ${props.map((prop) => `${typeof prop.key === "symbol" ? `[${js.ref(prop.key)}]` : prop.key === "__proto__" ? '["__proto__"]' : prop.serializedKey}: ${valueOf(prop)}`).join(", ")} }`;
|
|
5459
5609
|
if (js.copiesValues || this.declaresKey("__proto__"))
|
|
5460
5610
|
js.const("result", literalOf(literal, outputOf));
|
|
5461
5611
|
else {
|
|
@@ -5467,7 +5617,7 @@ var StructureNode = class extends BaseConstraint {
|
|
|
5467
5617
|
}
|
|
5468
5618
|
js.const("result", literalOf(slots, () => "null"));
|
|
5469
5619
|
for (const prop of literal)
|
|
5470
|
-
js.line(
|
|
5620
|
+
js.line(jsSetOwnProp(js, "result", prop.key, outputOf(prop)));
|
|
5471
5621
|
}
|
|
5472
5622
|
const copies = this.declaresKey("__proto__") ? `Object.getPrototypeOf(data) !== Object.prototype || Object.prototype.hasOwnProperty.call(data, "__proto__")` : "Object.getPrototypeOf(data) !== Object.prototype";
|
|
5473
5623
|
js.if(copies, () => !this.defaultable.length && !this.protoProps.length && !this.index ? js.return(`${js.ref(copyDeclared)}(data, [${this.inOrder.map((prop) => js.serialize(prop.key)).join(", ")}]${transformedProps.length ? `, [${transformedProps.map((prop, i) => `${js.serialize(prop.key)}, value${i}, transformed${i}`).join(", ")}]` : ""})`) : js.outline(`${js.nameOf(this.id)}Copy`, [
|
|
@@ -5478,7 +5628,7 @@ var StructureNode = class extends BaseConstraint {
|
|
|
5478
5628
|
])
|
|
5479
5629
|
], deleteFromCopy));
|
|
5480
5630
|
for (const prop of added) {
|
|
5481
|
-
const store = () => js.line(
|
|
5631
|
+
const store = () => js.line(jsSetOwnProp(js, "result", prop.key, outputOf(prop)));
|
|
5482
5632
|
if (prop.is("required"))
|
|
5483
5633
|
store();
|
|
5484
5634
|
else {
|
|
@@ -5576,9 +5726,10 @@ var getPossibleMorph = function (node2) {
|
|
|
5576
5726
|
const $arkStructuralMorph = (data, ctx) => node2.applyStructMorph(data, data, ctx);
|
|
5577
5727
|
return defaultableMorphsCache.set(cacheKey, $arkStructuralMorph);
|
|
5578
5728
|
};
|
|
5729
|
+
var jsSetOwnProp = function (js, target, key, value) { return key === "__proto__" ? `Object.defineProperty(${target}, "__proto__", { value: ${value}, writable: true, enumerable: true, configurable: true })` : `${target}${js.prop(key)} = ${value}` };
|
|
5579
5730
|
var compileDefault = function (js, node2, out) {
|
|
5580
5731
|
if (hasPlainDefault(node2)) {
|
|
5581
|
-
return js.line(
|
|
5732
|
+
return js.line(jsSetOwnProp(js, out, node2.key, serializeDefault(js, node2.default)));
|
|
5582
5733
|
}
|
|
5583
5734
|
return compileDefaultMorph(js, node2, `${js.ref(node2.defMorph)}(${out}${node2.defMorph.length === 2 ? ", ctx" : ""})`, out);
|
|
5584
5735
|
};
|
|
@@ -5781,7 +5932,7 @@ var registerNodeId = function (written) {
|
|
|
5781
5932
|
var idPrefixes = /* @__PURE__ */ Object.create(null);
|
|
5782
5933
|
var idPrefixOf = function (written) {
|
|
5783
5934
|
let prefix = written.replace(/[^\w$]/g, "_");
|
|
5784
|
-
if (/^\d/.test(prefix))
|
|
5935
|
+
if (!prefix || /^\d/.test(prefix))
|
|
5785
5936
|
prefix = `_${prefix}`;
|
|
5786
5937
|
if (/\d$/.test(prefix))
|
|
5787
5938
|
prefix += "_";
|
|
@@ -5907,7 +6058,11 @@ var idsOf = function (nodes, $) {
|
|
|
5907
6058
|
};
|
|
5908
6059
|
var idOf = (node2, $) => node2.$ === $ ? `#${node2.id}` : `#${node2.id}@${node2.$.index}`;
|
|
5909
6060
|
var valueKeyOf = (v, $) => isNode(v) ? idOf(v, $) : isArray(v) ? `[${v.map((item) => valueKeyOf(item, $)).join()}]` : literalKeyOf(v);
|
|
5910
|
-
var literalKeyOf = function (v) { return typeof v === "string" ? JSON.stringify(v) : typeof v === "number" ? Object.is(v, -0) ? "-0" : `${v}` : typeof v === "bigint" ? `${v}n` : isDate(v) ?
|
|
6061
|
+
var literalKeyOf = function (v) { return typeof v === "string" ? JSON.stringify(v) : typeof v === "number" ? Object.is(v, -0) ? "-0" : `${v}` : typeof v === "bigint" ? `${v}n` : isDate(v) ? dateKeyOf(v) : typeof v === "object" && v !== null || typeof v === "function" || typeof v === "symbol" ? `$${nameOf(v)}` : `${v}` };
|
|
6062
|
+
var dateKeyOf = function (v) {
|
|
6063
|
+
const time = timeOf(v);
|
|
6064
|
+
return time === void 0 ? `$${nameOf(v)}` : Number.isNaN(time) ? "d'Invalid Date'" : `d'${v.toISOString()}'`;
|
|
6065
|
+
};
|
|
5911
6066
|
var requiredPropOf = function (key, value, $) {
|
|
5912
6067
|
if (!holdsWeakly || value.topAlias || value.$ !== $)
|
|
5913
6068
|
return $.node("required", { key, value });
|
|
@@ -6017,6 +6172,11 @@ var bootstrapIntrinsic = function () {
|
|
|
6017
6172
|
index: {
|
|
6018
6173
|
signature: "string",
|
|
6019
6174
|
value: "$jsonData"
|
|
6175
|
+
},
|
|
6176
|
+
meta: {
|
|
6177
|
+
jsonSchema: {
|
|
6178
|
+
anyOf: [{ type: "object" }, { type: "array", items: {} }]
|
|
6179
|
+
}
|
|
6020
6180
|
}
|
|
6021
6181
|
},
|
|
6022
6182
|
jsonData: ["$jsonPrimitive", "$jsonObject"]
|
|
@@ -6472,7 +6632,8 @@ var precompiledKeyOf = function (root) {
|
|
|
6472
6632
|
childCounts += `[${node2.inOrder.map((prop) => node2.props.indexOf(prop))}]`;
|
|
6473
6633
|
}
|
|
6474
6634
|
const content = root.hash.includes(`"$ark.`) ? keyRegisteredNames(root) : root.hash;
|
|
6475
|
-
return hashOf(`${
|
|
6635
|
+
return hashOf(`${arkUtilVersion}
|
|
6636
|
+
${content}
|
|
6476
6637
|
${childCounts}
|
|
6477
6638
|
${$ark.sets !== void 0}`);
|
|
6478
6639
|
};
|
|
@@ -7707,7 +7868,7 @@ var discriminateRootKind = function (schema) {
|
|
|
7707
7868
|
return isInstanceOf(schema, BaseRoot) ? schema.kind : throwParseError(writeForeignArkMessage("A Type passed as a schema"));
|
|
7708
7869
|
}
|
|
7709
7870
|
if (typeof schema === "string") {
|
|
7710
|
-
return schema[0] === "$" ? "alias" : schema
|
|
7871
|
+
return schema[0] === "$" ? "alias" : hasOwn(domainDescriptions, schema) ? "domain" : "proto";
|
|
7711
7872
|
}
|
|
7712
7873
|
if (typeof schema === "function")
|
|
7713
7874
|
return "proto";
|
|
@@ -7730,7 +7891,13 @@ var discriminateRootKind = function (schema) {
|
|
|
7730
7891
|
return "domain";
|
|
7731
7892
|
return throwParseError(writeInvalidSchemaMessage(schema));
|
|
7732
7893
|
};
|
|
7733
|
-
var readConstraint = (kind) => (schema) => constraintInputOf(kind, schema);
|
|
7894
|
+
var readConstraint = (kind) => (schema) => constraintInputOf(kind, schema === null ? { rule: null } : schema);
|
|
7895
|
+
var readDateRange = function (kind) { return (schema) => {
|
|
7896
|
+
const rawRule = typeof schema === "object" && schema !== null && !(schema instanceof Date) ? schema.rule : schema;
|
|
7897
|
+
if (typeof rawRule !== "string" && (typeof rawRule !== "number" || Number.isNaN(rawRule)) && !(rawRule instanceof Date))
|
|
7898
|
+
throwParseError(writeInvalidRangeRuleMessage(kind, rawRule));
|
|
7899
|
+
return constraintInputOf(kind, schema);
|
|
7900
|
+
} };
|
|
7734
7901
|
var readProp = (schema, $) => ({
|
|
7735
7902
|
...schema,
|
|
7736
7903
|
value: parseSchema(schema.value, $)
|
|
@@ -7744,9 +7911,9 @@ var readers = {
|
|
|
7744
7911
|
return hasArkKind(registered, "root") ? registered : $.resolveRoot(input.reference.slice(1));
|
|
7745
7912
|
},
|
|
7746
7913
|
domain: (schema) => typeof schema === "string" ? { domain: schema } : schema,
|
|
7747
|
-
proto: function (schema) { return typeof schema === "string" ? { proto:
|
|
7914
|
+
proto: function (schema) { return typeof schema === "string" ? { proto: lookupBuiltinProto(schema, schema) } : typeof schema === "function" ? { proto: schema } : typeof schema.proto === "string" ? {
|
|
7748
7915
|
...schema,
|
|
7749
|
-
proto:
|
|
7916
|
+
proto: lookupBuiltinProto(schema.proto, schema)
|
|
7750
7917
|
} : schema },
|
|
7751
7918
|
unit: (schema) => schema,
|
|
7752
7919
|
union: function (schema, $) {
|
|
@@ -7839,12 +8006,19 @@ var readers = {
|
|
|
7839
8006
|
min: readConstraint("min"),
|
|
7840
8007
|
maxLength: readConstraint("maxLength"),
|
|
7841
8008
|
minLength: readConstraint("minLength"),
|
|
7842
|
-
before:
|
|
7843
|
-
after:
|
|
7844
|
-
notEqual:
|
|
8009
|
+
before: readDateRange("before"),
|
|
8010
|
+
after: readDateRange("after"),
|
|
8011
|
+
notEqual: function (schema) {
|
|
8012
|
+
const input = constraintInputOf("notEqual", schema === null ? { rule: null } : schema);
|
|
8013
|
+
if ((typeof input.rule !== "number" || Number.isNaN(input.rule)) && (!(input.rule instanceof Date) || !isValidDate(input.rule))) {
|
|
8014
|
+
throwParseError(`notEqual bound must be a number or Date (was ${printable(input.rule)})`);
|
|
8015
|
+
}
|
|
8016
|
+
return input;
|
|
8017
|
+
},
|
|
7845
8018
|
notEqualLength: readConstraint("notEqualLength"),
|
|
7846
8019
|
pattern: readConstraint("pattern")
|
|
7847
8020
|
};
|
|
8021
|
+
var lookupBuiltinProto = (name, schema) => hasOwn(builtinConstructors, name) ? builtinConstructors[name] : throwParseError(writeInvalidSchemaMessage(schema));
|
|
7848
8022
|
var parseConstraint = function (kind, schema, $) {
|
|
7849
8023
|
if (isArray(schema)) {
|
|
7850
8024
|
if (schema.length === 0)
|
|
@@ -7918,6 +8092,7 @@ export {
|
|
|
7918
8092
|
BaseRange,
|
|
7919
8093
|
boundKindPairsByLower,
|
|
7920
8094
|
writeInvalidLengthBoundMessage,
|
|
8095
|
+
writeInvalidRangeRuleMessage,
|
|
7921
8096
|
assertLengthRule,
|
|
7922
8097
|
compileComparator,
|
|
7923
8098
|
dateLimitToString,
|