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,405 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ToJsonSchemaError,
|
|
3
|
+
copyConfig,
|
|
4
|
+
isSameConfig,
|
|
5
|
+
validateToJsonSchemaTarget
|
|
6
|
+
} from "./chunk-W2XOI5DY.js";
|
|
7
|
+
import {
|
|
8
|
+
editsBetween
|
|
9
|
+
} from "./chunk-TACLEIDM.js";
|
|
10
|
+
import {
|
|
11
|
+
compileSerializedValue
|
|
12
|
+
} from "./chunk-VYMXHSFR.js";
|
|
13
|
+
import {
|
|
14
|
+
$ark,
|
|
15
|
+
configureAfterTypeMessage,
|
|
16
|
+
configureLocale,
|
|
17
|
+
errorWriters,
|
|
18
|
+
errorWritersByCode,
|
|
19
|
+
namedReference,
|
|
20
|
+
registeredReference
|
|
21
|
+
} from "./chunk-PDLTEX6Z.js";
|
|
22
|
+
import {
|
|
23
|
+
isNode,
|
|
24
|
+
removedProblemMessage
|
|
25
|
+
} from "./chunk-3KBOPH3J.js";
|
|
26
|
+
import {
|
|
27
|
+
envHasCsp,
|
|
28
|
+
flatMorph,
|
|
29
|
+
getBuiltinNameOfConstructor,
|
|
30
|
+
hasDomain,
|
|
31
|
+
hasOwn,
|
|
32
|
+
printable,
|
|
33
|
+
serializePrimitive,
|
|
34
|
+
throwInternalError,
|
|
35
|
+
throwParseError
|
|
36
|
+
} from "./chunk-3HZC67MT.js";
|
|
37
|
+
|
|
38
|
+
// ../schema/out/shared/implement.js
|
|
39
|
+
var basisKinds = ["unit", "proto", "domain"];
|
|
40
|
+
var structuralKinds = [
|
|
41
|
+
"required",
|
|
42
|
+
"optional",
|
|
43
|
+
"index",
|
|
44
|
+
"sequence"
|
|
45
|
+
];
|
|
46
|
+
var prestructuralKinds = [
|
|
47
|
+
"pattern",
|
|
48
|
+
"divisor",
|
|
49
|
+
"exactLength",
|
|
50
|
+
"max",
|
|
51
|
+
"min",
|
|
52
|
+
"maxLength",
|
|
53
|
+
"minLength",
|
|
54
|
+
"before",
|
|
55
|
+
"after",
|
|
56
|
+
"notEqual",
|
|
57
|
+
"notEqualLength"
|
|
58
|
+
];
|
|
59
|
+
var refinementKinds = [
|
|
60
|
+
...prestructuralKinds,
|
|
61
|
+
"structure",
|
|
62
|
+
"predicate"
|
|
63
|
+
];
|
|
64
|
+
var constraintKinds = [...refinementKinds, ...structuralKinds];
|
|
65
|
+
var rootKinds = [
|
|
66
|
+
"alias",
|
|
67
|
+
"union",
|
|
68
|
+
"morph",
|
|
69
|
+
"unit",
|
|
70
|
+
"intersection",
|
|
71
|
+
"proto",
|
|
72
|
+
"domain"
|
|
73
|
+
];
|
|
74
|
+
var nodeKinds = [...rootKinds, ...constraintKinds];
|
|
75
|
+
var constraintKeys = flatMorph(constraintKinds, (i, kind) => [kind, 1]);
|
|
76
|
+
var structureKeys = flatMorph([...structuralKinds, "undeclared", "order"], (i, k) => [k, 1]);
|
|
77
|
+
var precedenceByKind = flatMorph(nodeKinds, (i, kind) => [kind, i]);
|
|
78
|
+
var isNodeKind = (value) => typeof value === "string" && value in precedenceByKind;
|
|
79
|
+
function assertNodeKind(value, kind) {
|
|
80
|
+
const valueIsNode = isNode(value);
|
|
81
|
+
if (!valueIsNode || value.kind !== kind) {
|
|
82
|
+
throwParseError(`Expected node of kind ${kind} (was ${valueIsNode ? `${value.kind} node` : printable(value)})`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
var precedenceOfKind = (kind) => precedenceByKind[kind];
|
|
86
|
+
var schemaKindsRightOf = (kind) => rootKinds.slice(precedenceOfKind(kind) + 1);
|
|
87
|
+
var unionChildKinds = /* @__PURE__ */ (() => [...schemaKindsRightOf("union"), "alias"])();
|
|
88
|
+
var morphChildKinds = /* @__PURE__ */ (() => [...schemaKindsRightOf("morph"), "alias"])();
|
|
89
|
+
var ambiguousStringPattern = /^(?:"|\$ark\d*\.|(?:NaN|-?Infinity|-0|-?\d+n|undefined|Invalid Date|[+-]?\d{4,6}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z)$)/;
|
|
90
|
+
var defaultValueSerializer = function (v) {
|
|
91
|
+
if (typeof v === "string")
|
|
92
|
+
return ambiguousStringPattern.test(v) ? JSON.stringify(v) : v;
|
|
93
|
+
if (typeof v === "boolean" || v === null)
|
|
94
|
+
return v;
|
|
95
|
+
if (typeof v === "number") {
|
|
96
|
+
if (Number.isNaN(v))
|
|
97
|
+
return "NaN";
|
|
98
|
+
if (v === Number.POSITIVE_INFINITY)
|
|
99
|
+
return "Infinity";
|
|
100
|
+
if (v === Number.NEGATIVE_INFINITY)
|
|
101
|
+
return "-Infinity";
|
|
102
|
+
if (Object.is(v, -0))
|
|
103
|
+
return "-0";
|
|
104
|
+
return v;
|
|
105
|
+
}
|
|
106
|
+
return hasDomain(v, "object") || typeof v === "symbol" ? namedReference(v) : serializePrimitive(v);
|
|
107
|
+
};
|
|
108
|
+
var metaJsonOf = (meta) => flatMorph(meta, (k, v) => [
|
|
109
|
+
k,
|
|
110
|
+
k === "examples" ? v.map(defaultValueSerializer) : defaultValueSerializer(v)
|
|
111
|
+
]);
|
|
112
|
+
var compileObjectLiteral = function (ctx) {
|
|
113
|
+
let result = "{ ";
|
|
114
|
+
for (const [k, v] of Object.entries(ctx))
|
|
115
|
+
result += `${k}: ${compileSerializedValue(v)}, `;
|
|
116
|
+
return result + " }";
|
|
117
|
+
};
|
|
118
|
+
var implementNode = function (_) {
|
|
119
|
+
const implementation = _;
|
|
120
|
+
if (implementation.ownErr) {
|
|
121
|
+
Object.assign(implementation.defaults, errorWriters, errorWritersByCode[implementation.kind]);
|
|
122
|
+
implementation.defaults.expected ??= (ctx) => "description" in ctx ? ctx.description : implementation.defaults.description(ctx);
|
|
123
|
+
}
|
|
124
|
+
return implementation;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// ../schema/out/shared/toJsonSchema.js
|
|
128
|
+
var foreignTypesByMorph = /* @__PURE__ */ new WeakMap();
|
|
129
|
+
var throwFallback = (ctx) => ToJsonSchema.throw(ctx.code, ctx);
|
|
130
|
+
var defaultConfig = {
|
|
131
|
+
target: "draft-2020-12",
|
|
132
|
+
dialect: "https://json-schema.org/draft/2020-12/schema",
|
|
133
|
+
useRefs: false,
|
|
134
|
+
aliasDefs: false,
|
|
135
|
+
fallback: {
|
|
136
|
+
arrayObject: throwFallback,
|
|
137
|
+
arrayPostfix: throwFallback,
|
|
138
|
+
arrayPrefix: throwFallback,
|
|
139
|
+
defaultValue: throwFallback,
|
|
140
|
+
defs: throwFallback,
|
|
141
|
+
domain: throwFallback,
|
|
142
|
+
indexKey: throwFallback,
|
|
143
|
+
morph: throwFallback,
|
|
144
|
+
patternFlags: throwFallback,
|
|
145
|
+
patternIntersection: throwFallback,
|
|
146
|
+
predicate: throwFallback,
|
|
147
|
+
proto: throwFallback,
|
|
148
|
+
symbolKey: throwFallback,
|
|
149
|
+
unit: throwFallback,
|
|
150
|
+
date: throwFallback
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
var annotate = (base, keyword, value) => ({ ...base, [`x-arktype-${keyword}`]: value });
|
|
154
|
+
var appendAnnotation = (base, keyword, value) => annotate(base, keyword, [
|
|
155
|
+
...base[`x-arktype-${keyword}`] ?? [],
|
|
156
|
+
value
|
|
157
|
+
]);
|
|
158
|
+
var allOfPatterns = (ctx) => {
|
|
159
|
+
const { allOf = [] } = ctx.base;
|
|
160
|
+
return { ...ctx.base, allOf: [...allOf, { pattern: ctx.pattern }] };
|
|
161
|
+
};
|
|
162
|
+
var annotatingFallback = {
|
|
163
|
+
arrayObject: (ctx) => annotate(ctx.base, "object", ctx.object),
|
|
164
|
+
arrayPostfix: (ctx) => annotate(ctx.base, "postfix", ctx.elements),
|
|
165
|
+
arrayPrefix: function ({ base, elements, items }) {
|
|
166
|
+
const annotated = annotate(base, "prefix", elements);
|
|
167
|
+
return items ? annotate(annotated, "items", items) : annotated;
|
|
168
|
+
},
|
|
169
|
+
// written as the default itself
|
|
170
|
+
defaultValue: (ctx) => defaultValueSerializer(ctx.value),
|
|
171
|
+
defs: (ctx) => annotate(ctx.base, "defs", ctx.defs),
|
|
172
|
+
domain: (ctx) => annotate(ctx.base, "domain", ctx.domain),
|
|
173
|
+
indexKey: (ctx) => appendAnnotation(ctx.base, "index", { key: ctx.key, value: ctx.value }),
|
|
174
|
+
morph: (ctx) => annotate(ctx.base, "out", ctx.out),
|
|
175
|
+
patternFlags: (ctx) => appendAnnotation(ctx.base, "patterns", {
|
|
176
|
+
rule: ctx.pattern,
|
|
177
|
+
flags: ctx.flags
|
|
178
|
+
}),
|
|
179
|
+
patternIntersection: (ctx) => allOfPatterns(ctx),
|
|
180
|
+
predicate: (ctx) => appendAnnotation(ctx.base, "predicates", namedReference(ctx.predicate)),
|
|
181
|
+
proto: (ctx) => annotate(ctx.base, "proto", getBuiltinNameOfConstructor(ctx.proto) ?? registeredReference(ctx.proto)),
|
|
182
|
+
symbolKey: function (ctx) { return appendAnnotation(ctx.base, "symbolKeys", {
|
|
183
|
+
key: ctx.key && registeredReference(ctx.key),
|
|
184
|
+
value: ctx.value,
|
|
185
|
+
optional: ctx.optional
|
|
186
|
+
}) },
|
|
187
|
+
unit: function (ctx) { return annotate(ctx.base, "unit", ctx.unit instanceof Date ? ctx.unit.toISOString() : hasDomain(ctx.unit, "object") || typeof ctx.unit === "symbol" ? registeredReference(ctx.unit) : defaultValueSerializer(ctx.unit)) },
|
|
188
|
+
date: function (ctx) {
|
|
189
|
+
const base = {
|
|
190
|
+
...ctx.base,
|
|
191
|
+
"x-arktype-proto": "Date",
|
|
192
|
+
...ctx.before && { "x-arktype-before": ctx.before.toISOString() },
|
|
193
|
+
...ctx.after && { "x-arktype-after": ctx.after.toISOString() }
|
|
194
|
+
};
|
|
195
|
+
return ctx.notEqual ? annotate(base, "notEqual", ctx.notEqual.map((date) => date.toISOString())) : base;
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
var keepBase = (ctx) => ctx.base;
|
|
199
|
+
var standardFallback = {
|
|
200
|
+
arrayObject: keepBase,
|
|
201
|
+
// draft-07 tuples keep their prefix in items
|
|
202
|
+
arrayPostfix: ({ base: { items, additionalItems, ...base } }) => Array.isArray(items) ? { ...base, items } : base,
|
|
203
|
+
arrayPrefix: keepBase,
|
|
204
|
+
defaultValue: () => void 0,
|
|
205
|
+
// beside the $refs, which point to #/definitions/ here, so the schema
|
|
206
|
+
// resolves its own, and a caller can move them to components.schemas
|
|
207
|
+
defs: ({ base, defs }) => ({ ...base, definitions: defs }),
|
|
208
|
+
domain: keepBase,
|
|
209
|
+
// rejecting undeclared keys would reject those the index allows
|
|
210
|
+
indexKey: ({ base }) => {
|
|
211
|
+
const { additionalProperties, ...rest } = base;
|
|
212
|
+
return additionalProperties === false ? rest : base;
|
|
213
|
+
},
|
|
214
|
+
morph: keepBase,
|
|
215
|
+
patternFlags: keepBase,
|
|
216
|
+
// JSON Schema can require each pattern, so each is kept
|
|
217
|
+
patternIntersection: allOfPatterns,
|
|
218
|
+
predicate: keepBase,
|
|
219
|
+
proto: keepBase,
|
|
220
|
+
symbolKey: keepBase,
|
|
221
|
+
unit: keepBase,
|
|
222
|
+
date: keepBase
|
|
223
|
+
};
|
|
224
|
+
var unionJsonSchemaWritersKey = Symbol("unionJsonSchemaWriters");
|
|
225
|
+
var ToJsonSchema = {
|
|
226
|
+
Error: ToJsonSchemaError,
|
|
227
|
+
throw: (...args) => {
|
|
228
|
+
throw new ToJsonSchema.Error(...args);
|
|
229
|
+
},
|
|
230
|
+
throwOperandError: (kind, schema) => throwInternalError(`Unexpected JSON Schema input for ${kind}: ${printable(schema)}`),
|
|
231
|
+
defaultConfig,
|
|
232
|
+
standardFallback
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// ../schema/out/config.js
|
|
236
|
+
$ark.config ??= {};
|
|
237
|
+
var optionNames = {
|
|
238
|
+
undeclared: 1,
|
|
239
|
+
discriminant: 1,
|
|
240
|
+
jitless: 1,
|
|
241
|
+
onUndeclaredKey: 1,
|
|
242
|
+
numberAllowsNaN: 1,
|
|
243
|
+
numberAllowsInfinity: 1,
|
|
244
|
+
dateAllowsInvalid: 1,
|
|
245
|
+
exactOptionalPropertyTypes: 1,
|
|
246
|
+
onFail: 1,
|
|
247
|
+
errors: 1,
|
|
248
|
+
mutatesInput: 1,
|
|
249
|
+
keywords: 1,
|
|
250
|
+
toJsonSchema: 1,
|
|
251
|
+
locale: 1
|
|
252
|
+
};
|
|
253
|
+
var writeUnknownConfigOptionMessage = (name) => `configure() has no option '${name}'`;
|
|
254
|
+
var nearestOptionTo = function (name) {
|
|
255
|
+
let nearest;
|
|
256
|
+
let fewest = 3;
|
|
257
|
+
for (const option of [...Object.keys(optionNames), ...nodeKinds]) {
|
|
258
|
+
const edits = editsBetween(name.toLowerCase(), option.toLowerCase());
|
|
259
|
+
if (edits < fewest)
|
|
260
|
+
[nearest, fewest] = [option, edits];
|
|
261
|
+
}
|
|
262
|
+
return nearest;
|
|
263
|
+
};
|
|
264
|
+
var undeclaredKeyBehaviors = { reject: 1, delete: 1, ignore: 1 };
|
|
265
|
+
var writeInvalidUndeclaredKeyBehaviorMessage = (actual) => `onUndeclaredKey must be 'reject', 'delete', or 'ignore' (was ${printable(actual)})`;
|
|
266
|
+
var assertNoProblemConfig = function (config) {
|
|
267
|
+
for (const k in config) {
|
|
268
|
+
const ofCode = config[k];
|
|
269
|
+
if ((isNodeKind(k) || k === "undeclared" || k === "discriminant") && hasDomain(ofCode, "object") && "problem" in ofCode)
|
|
270
|
+
throwParseError(removedProblemMessage);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
var configureSchema = function (config) {
|
|
274
|
+
assertNoProblemConfig(config);
|
|
275
|
+
for (const k in config) {
|
|
276
|
+
if (isNodeKind(k) || hasOwn(optionNames, k))
|
|
277
|
+
continue;
|
|
278
|
+
const nearest = nearestOptionTo(k);
|
|
279
|
+
throwParseError(writeUnknownConfigOptionMessage(k) + (nearest ? `. Did you mean '${nearest}'?` : ""));
|
|
280
|
+
}
|
|
281
|
+
if (config.onUndeclaredKey !== void 0 && !hasOwn(undeclaredKeyBehaviors, config.onUndeclaredKey)) {
|
|
282
|
+
throwParseError(writeInvalidUndeclaredKeyBehaviorMessage(config.onUndeclaredKey));
|
|
283
|
+
}
|
|
284
|
+
if (config.locale !== void 0 && !hasDomain(config.locale, "object"))
|
|
285
|
+
throwParseError(writeInvalidLocaleMessage(config.locale));
|
|
286
|
+
const merged = mergeConfigs($ark.config, copyConfig(config));
|
|
287
|
+
if ($ark.cfg) {
|
|
288
|
+
if (!isSameConfig(merged, $ark.config))
|
|
289
|
+
return throwParseError(configureAfterTypeMessage);
|
|
290
|
+
} else
|
|
291
|
+
Object.assign($ark.config, merged);
|
|
292
|
+
return config;
|
|
293
|
+
};
|
|
294
|
+
var resolveGlobalConfig = function (base) {
|
|
295
|
+
const resolved = mergeConfigs(
|
|
296
|
+
// probed as the config is fixed, so configuring jitless after import skips it
|
|
297
|
+
{ ...base, jitless: $ark.config.jitless ?? envHasCsp() },
|
|
298
|
+
$ark.config
|
|
299
|
+
);
|
|
300
|
+
resolved.locale = configureLocale($ark.config.locale, base);
|
|
301
|
+
return resolved;
|
|
302
|
+
};
|
|
303
|
+
var writeInvalidLocaleMessage = (locale) => `locale must be a Locale or a function returning one (was ${printable(locale)})`;
|
|
304
|
+
var mergeConfigs = function (base, merged) {
|
|
305
|
+
if (!merged)
|
|
306
|
+
return base;
|
|
307
|
+
const result = { ...base, ...merged };
|
|
308
|
+
let k;
|
|
309
|
+
for (k in merged) {
|
|
310
|
+
const keywords = { ...base.keywords };
|
|
311
|
+
if (k === "keywords") {
|
|
312
|
+
for (const flatAlias in merged[k]) {
|
|
313
|
+
const v = merged.keywords[flatAlias];
|
|
314
|
+
if (v === void 0)
|
|
315
|
+
continue;
|
|
316
|
+
keywords[flatAlias] = typeof v === "string" ? { description: v } : v;
|
|
317
|
+
}
|
|
318
|
+
result.keywords = keywords;
|
|
319
|
+
} else if (k === "toJsonSchema") {
|
|
320
|
+
result[k] = mergeToJsonSchemaConfigs(base.toJsonSchema, merged.toJsonSchema);
|
|
321
|
+
} else if (isNodeKind(k) || k === "undeclared" || k === "discriminant") {
|
|
322
|
+
result[k] = // not casting this makes TS compute a very inefficient
|
|
323
|
+
// type that is not needed
|
|
324
|
+
{
|
|
325
|
+
...base[k],
|
|
326
|
+
...merged[k]
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return result;
|
|
331
|
+
};
|
|
332
|
+
var jsonSchemaTargetToDialect = {
|
|
333
|
+
"draft-2020-12": "https://json-schema.org/draft/2020-12/schema",
|
|
334
|
+
"draft-07": "http://json-schema.org/draft-07/schema#",
|
|
335
|
+
// an OpenAPI Schema Object has no $schema
|
|
336
|
+
"openapi-3.0": null,
|
|
337
|
+
"openapi-3.1": null
|
|
338
|
+
};
|
|
339
|
+
var mergeToJsonSchemaConfigs = (function (baseConfig, mergedConfig) {
|
|
340
|
+
if (!baseConfig)
|
|
341
|
+
return resolveTargetToDialect(mergedConfig ?? {}, mergedConfig);
|
|
342
|
+
if (!mergedConfig)
|
|
343
|
+
return baseConfig;
|
|
344
|
+
const result = { ...baseConfig };
|
|
345
|
+
let k;
|
|
346
|
+
for (k in mergedConfig) {
|
|
347
|
+
if (k === "fallback") {
|
|
348
|
+
result.fallback = mergeFallbacks(baseConfig.fallback, mergedConfig.fallback);
|
|
349
|
+
} else
|
|
350
|
+
result[k] = mergedConfig[k];
|
|
351
|
+
}
|
|
352
|
+
return resolveTargetToDialect(result, mergedConfig);
|
|
353
|
+
});
|
|
354
|
+
var resolveTargetToDialect = function (opts, userOpts) {
|
|
355
|
+
if (userOpts?.target === void 0)
|
|
356
|
+
return opts;
|
|
357
|
+
const dialect = jsonSchemaTargetToDialect[validateToJsonSchemaTarget(userOpts.target)];
|
|
358
|
+
return userOpts.dialect === void 0 ? { ...opts, dialect } : opts;
|
|
359
|
+
};
|
|
360
|
+
var mergeFallbacks = function (base, merged) {
|
|
361
|
+
base = normalizeFallback(base);
|
|
362
|
+
merged = normalizeFallback(merged);
|
|
363
|
+
const result = {};
|
|
364
|
+
let code;
|
|
365
|
+
for (code in ToJsonSchema.defaultConfig.fallback) {
|
|
366
|
+
result[code] = merged[code] ?? merged.default ?? base[code] ?? base.default ?? ToJsonSchema.defaultConfig.fallback[code];
|
|
367
|
+
}
|
|
368
|
+
return result;
|
|
369
|
+
};
|
|
370
|
+
var normalizeFallback = (fallback) => typeof fallback === "function" ? { default: fallback } : fallback ?? {};
|
|
371
|
+
|
|
372
|
+
export {
|
|
373
|
+
basisKinds,
|
|
374
|
+
structuralKinds,
|
|
375
|
+
prestructuralKinds,
|
|
376
|
+
refinementKinds,
|
|
377
|
+
constraintKinds,
|
|
378
|
+
rootKinds,
|
|
379
|
+
nodeKinds,
|
|
380
|
+
constraintKeys,
|
|
381
|
+
structureKeys,
|
|
382
|
+
precedenceByKind,
|
|
383
|
+
isNodeKind,
|
|
384
|
+
assertNodeKind,
|
|
385
|
+
precedenceOfKind,
|
|
386
|
+
schemaKindsRightOf,
|
|
387
|
+
unionChildKinds,
|
|
388
|
+
morphChildKinds,
|
|
389
|
+
defaultValueSerializer,
|
|
390
|
+
metaJsonOf,
|
|
391
|
+
compileObjectLiteral,
|
|
392
|
+
implementNode,
|
|
393
|
+
foreignTypesByMorph,
|
|
394
|
+
annotatingFallback,
|
|
395
|
+
unionJsonSchemaWritersKey,
|
|
396
|
+
ToJsonSchema,
|
|
397
|
+
writeUnknownConfigOptionMessage,
|
|
398
|
+
writeInvalidUndeclaredKeyBehaviorMessage,
|
|
399
|
+
assertNoProblemConfig,
|
|
400
|
+
configureSchema,
|
|
401
|
+
resolveGlobalConfig,
|
|
402
|
+
writeInvalidLocaleMessage,
|
|
403
|
+
mergeConfigs,
|
|
404
|
+
mergeToJsonSchemaConfigs
|
|
405
|
+
};
|
|
File without changes
|