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,54 @@
|
|
|
1
|
+
export * from "./config.ts";
|
|
2
|
+
export * from "./constraint.ts";
|
|
3
|
+
export * from "./generic.ts";
|
|
4
|
+
export * from "./intrinsic.ts";
|
|
5
|
+
export * from "./kinds.ts";
|
|
6
|
+
export * from "./module.ts";
|
|
7
|
+
export * from "./node.ts";
|
|
8
|
+
export * from "./parse.ts";
|
|
9
|
+
export * from "./parseSchema.ts";
|
|
10
|
+
export * from "./predicate.ts";
|
|
11
|
+
export * from "./refinements/after.ts";
|
|
12
|
+
export * from "./refinements/before.ts";
|
|
13
|
+
export * from "./refinements/divisor.ts";
|
|
14
|
+
export * from "./refinements/exactLength.ts";
|
|
15
|
+
export * from "./refinements/kinds.ts";
|
|
16
|
+
export * from "./refinements/max.ts";
|
|
17
|
+
export * from "./refinements/maxLength.ts";
|
|
18
|
+
export * from "./refinements/min.ts";
|
|
19
|
+
export * from "./refinements/minLength.ts";
|
|
20
|
+
export * from "./refinements/notEqual.ts";
|
|
21
|
+
export * from "./refinements/notEqualLength.ts";
|
|
22
|
+
export * from "./refinements/pattern.ts";
|
|
23
|
+
export * from "./refinements/range.ts";
|
|
24
|
+
export * from "./roots/alias.ts";
|
|
25
|
+
export * from "./roots/domain.ts";
|
|
26
|
+
export * from "./roots/intersection.ts";
|
|
27
|
+
export * from "./roots/morph.ts";
|
|
28
|
+
export * from "./roots/proto.ts";
|
|
29
|
+
export * from "./roots/root.ts";
|
|
30
|
+
export * from "./roots/union.ts";
|
|
31
|
+
export * from "./roots/unit.ts";
|
|
32
|
+
export * from "./scope.ts";
|
|
33
|
+
export * from "./shared/compile.ts";
|
|
34
|
+
export * from "./shared/declare.ts";
|
|
35
|
+
export * from "./shared/disjoint.ts";
|
|
36
|
+
export * from "./shared/errors.ts";
|
|
37
|
+
export * from "./shared/implement.ts";
|
|
38
|
+
export * from "./shared/jsonSchema.ts";
|
|
39
|
+
export * from "./shared/locale.ts";
|
|
40
|
+
export * from "./shared/registry.ts";
|
|
41
|
+
export * from "./shared/sets.ts";
|
|
42
|
+
export * from "./shared/standardSchema.ts";
|
|
43
|
+
export * from "./shared/toJsonSchema.ts";
|
|
44
|
+
export * from "./shared/transform.ts";
|
|
45
|
+
export * from "./shared/traversal.ts";
|
|
46
|
+
export * from "./shared/utils.ts";
|
|
47
|
+
export * from "./structure/index.ts";
|
|
48
|
+
export * from "./structure/optional.ts";
|
|
49
|
+
export * from "./structure/prop.ts";
|
|
50
|
+
export * from "./structure/required.ts";
|
|
51
|
+
export * from "./structure/sequence.ts";
|
|
52
|
+
export * from "./structure/structure.ts";
|
|
53
|
+
export { bindPrecompiledUnits, precompileInPlace, precompileRootUnits, registerPrecompiledUnits, TraversalCompiler, writePrecompiledUnits, type PrecompiledUnit, type RootUnit, type UnboundTraversals, type UnitMember } from "./units.ts";
|
|
54
|
+
export { arkKind, ParseError } from "../util/index.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export * from "./index.ts";
|
|
2
|
+
export { ArkErrors, TraversalError } from "./shared/errors.ts";
|
|
3
|
+
export * from "./roots/basis.ts";
|
|
4
|
+
export * from "./shared/codecs.ts";
|
|
5
|
+
export * from "./shared/render.ts";
|
|
6
|
+
export * from "./runtime.ts";
|
|
7
|
+
export * from "./shared/errorModes.ts";
|
|
8
|
+
export * from "./shared/inPlace.ts";
|
|
9
|
+
export * from "./shared/issueFeatures.ts";
|
|
10
|
+
export { printedActualOf } from "./shared/enWriters.ts";
|
|
11
|
+
export * from "./shared/errorWriters.ts";
|
|
12
|
+
export * from "./shared/rootApply.ts";
|
|
13
|
+
export * from "./shared/standardFailure.ts";
|
|
14
|
+
export * from "./structure/shared.ts";
|
|
15
|
+
export * from "./units.ts";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { BaseRoot } from "./roots/root.ts";
|
|
2
|
+
declare const jsonIntrinsicNames: readonly ["jsonPrimitive", "jsonObject", "jsonData"];
|
|
3
|
+
type IntrinsicJson = Record<(typeof jsonIntrinsicNames)[number], BaseRoot>;
|
|
4
|
+
declare const bootstrapIntrinsic: () => {
|
|
5
|
+
Array: BaseRoot<import("./roots/root.ts").InternalRootDeclaration>;
|
|
6
|
+
Date: BaseRoot<import("./roots/root.ts").InternalRootDeclaration>;
|
|
7
|
+
bigint: BaseRoot<import("./roots/root.ts").InternalRootDeclaration>;
|
|
8
|
+
boolean: BaseRoot<import("./roots/root.ts").InternalRootDeclaration>;
|
|
9
|
+
false: BaseRoot<import("./roots/root.ts").InternalRootDeclaration>;
|
|
10
|
+
integer: BaseRoot<import("./roots/root.ts").InternalRootDeclaration>;
|
|
11
|
+
key: BaseRoot<import("./roots/root.ts").InternalRootDeclaration>;
|
|
12
|
+
lengthBoundable: BaseRoot<import("./roots/root.ts").InternalRootDeclaration>;
|
|
13
|
+
never: BaseRoot<import("./roots/root.ts").InternalRootDeclaration>;
|
|
14
|
+
nonNegativeIntegerString: BaseRoot<import("./roots/root.ts").InternalRootDeclaration>;
|
|
15
|
+
null: BaseRoot<import("./roots/root.ts").InternalRootDeclaration>;
|
|
16
|
+
number: BaseRoot<import("./roots/root.ts").InternalRootDeclaration>;
|
|
17
|
+
object: BaseRoot<import("./roots/root.ts").InternalRootDeclaration>;
|
|
18
|
+
string: BaseRoot<import("./roots/root.ts").InternalRootDeclaration>;
|
|
19
|
+
symbol: BaseRoot<import("./roots/root.ts").InternalRootDeclaration>;
|
|
20
|
+
true: BaseRoot<import("./roots/root.ts").InternalRootDeclaration>;
|
|
21
|
+
undefined: BaseRoot<import("./roots/root.ts").InternalRootDeclaration>;
|
|
22
|
+
unknown: BaseRoot<import("./roots/root.ts").InternalRootDeclaration>;
|
|
23
|
+
} & IntrinsicJson & {
|
|
24
|
+
emptyStructure: import("./index.ts").StructureNode;
|
|
25
|
+
};
|
|
26
|
+
export declare const bootstrap: () => void;
|
|
27
|
+
export declare const intrinsic: ReturnType<typeof bootstrapIntrinsic>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { type array } from "../util/index.js";
|
|
2
|
+
import type { BaseNode } from "./node.ts";
|
|
3
|
+
import { Predicate } from "./predicate.ts";
|
|
4
|
+
import { Divisor } from "./refinements/divisor.ts";
|
|
5
|
+
import { type BoundDeclarations, type BoundNodesByKind } from "./refinements/kinds.ts";
|
|
6
|
+
import { Pattern } from "./refinements/pattern.ts";
|
|
7
|
+
import { Alias } from "./roots/alias.ts";
|
|
8
|
+
import { Domain } from "./roots/domain.ts";
|
|
9
|
+
import { Intersection } from "./roots/intersection.ts";
|
|
10
|
+
import { Morph } from "./roots/morph.ts";
|
|
11
|
+
import { Proto } from "./roots/proto.ts";
|
|
12
|
+
import { Union } from "./roots/union.ts";
|
|
13
|
+
import { Unit } from "./roots/unit.ts";
|
|
14
|
+
import type { BaseScope } from "./scope.ts";
|
|
15
|
+
import type { BaseNodeInput } from "./shared/declare.ts";
|
|
16
|
+
import { type ArkErrorCode, type ErrorContextsByCode } from "./shared/errors.ts";
|
|
17
|
+
import { type ConstraintKind, type NodeKind, type OpenNodeKind, type UnknownAttachmentsInput, type UnknownNodeImplementation } from "./shared/implement.ts";
|
|
18
|
+
import { type Locale } from "./shared/locale.ts";
|
|
19
|
+
import { type makeRootAndArrayPropertiesMutable } from "./shared/utils.ts";
|
|
20
|
+
import { Index } from "./structure/index.ts";
|
|
21
|
+
import { Optional } from "./structure/optional.ts";
|
|
22
|
+
import { Required } from "./structure/required.ts";
|
|
23
|
+
import { Sequence } from "./structure/sequence.ts";
|
|
24
|
+
import { Structure } from "./structure/structure.ts";
|
|
25
|
+
export interface NodeDeclarationsByKind extends BoundDeclarations {
|
|
26
|
+
alias: Alias.Declaration;
|
|
27
|
+
domain: Domain.Declaration;
|
|
28
|
+
unit: Unit.Declaration;
|
|
29
|
+
proto: Proto.Declaration;
|
|
30
|
+
union: Union.Declaration;
|
|
31
|
+
morph: Morph.Declaration;
|
|
32
|
+
intersection: Intersection.Declaration;
|
|
33
|
+
sequence: Sequence.Declaration;
|
|
34
|
+
divisor: Divisor.Declaration;
|
|
35
|
+
required: Required.Declaration;
|
|
36
|
+
optional: Optional.Declaration;
|
|
37
|
+
index: Index.Declaration;
|
|
38
|
+
pattern: Pattern.Declaration;
|
|
39
|
+
predicate: Predicate.Declaration;
|
|
40
|
+
structure: Structure.Declaration;
|
|
41
|
+
}
|
|
42
|
+
export declare const nodeImplementationsByKind: Record<NodeKind, UnknownNodeImplementation>;
|
|
43
|
+
export declare const en: Locale.Complete;
|
|
44
|
+
export declare const nodeClassesByKind: Record<NodeKind, new (attachments: UnknownAttachmentsInput, $: BaseScope) => BaseNode>;
|
|
45
|
+
interface NodesByKind extends BoundNodesByKind {
|
|
46
|
+
alias: Alias.Node;
|
|
47
|
+
union: Union.Node;
|
|
48
|
+
morph: Morph.Node;
|
|
49
|
+
intersection: Intersection.Node;
|
|
50
|
+
unit: Unit.Node;
|
|
51
|
+
proto: Proto.Node;
|
|
52
|
+
domain: Domain.Node;
|
|
53
|
+
divisor: Divisor.Node;
|
|
54
|
+
pattern: Pattern.Node;
|
|
55
|
+
predicate: Predicate.Node;
|
|
56
|
+
required: Required.Node;
|
|
57
|
+
optional: Optional.Node;
|
|
58
|
+
index: Index.Node;
|
|
59
|
+
sequence: Sequence.Node;
|
|
60
|
+
structure: Structure.Node;
|
|
61
|
+
}
|
|
62
|
+
export type nodeOfKind<kind extends NodeKind> = NodesByKind[kind];
|
|
63
|
+
export type Declaration<kind extends NodeKind> = NodeDeclarationsByKind[kind];
|
|
64
|
+
export type childKindOf<kind extends NodeKind> = Declaration<kind>["childKind"];
|
|
65
|
+
export type Prerequisite<kind extends NodeKind> = Declaration<kind>["prerequisite"];
|
|
66
|
+
export type reducibleKindOf<kind extends NodeKind> = Declaration<kind>["reducibleTo"] extends NodeKind ? Declaration<kind>["reducibleTo"] : kind;
|
|
67
|
+
export type Inner<kind extends NodeKind> = Declaration<kind>["inner"];
|
|
68
|
+
export type NodeInput<kind extends NodeKind = NodeKind> = kind extends "union" ? Union.Input : kind extends "structure" ? Structure.Input : Inner<kind> & BaseNodeInput;
|
|
69
|
+
export type innerAttachedAs<kind extends ConstraintKind> = kind extends OpenNodeKind ? array<nodeOfKind<kind>> : nodeOfKind<kind>;
|
|
70
|
+
/** make nested arrays mutable while keeping nested nodes immutable */
|
|
71
|
+
export type mutableInnerOfKind<kind extends NodeKind> = makeRootAndArrayPropertiesMutable<Inner<kind>>;
|
|
72
|
+
export type errorCtx<code extends ArkErrorCode> = ErrorContextsByCode[code];
|
|
73
|
+
export type NodeErrorContextsByKind = {
|
|
74
|
+
[kind in NodeKind as Declaration<kind>["errorCtx"] extends null ? never : kind]: Declaration<kind>["errorCtx"];
|
|
75
|
+
};
|
|
76
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { arkKind, DynamicBase, type anyOrNever } from "../util/index.js";
|
|
2
|
+
import type { BaseRoot } from "./roots/root.ts";
|
|
3
|
+
import type { BaseScope, InternalResolution, InternalResolutions } from "./scope.ts";
|
|
4
|
+
export type PreparsedNodeResolution = {
|
|
5
|
+
[arkKind]: "generic" | "module";
|
|
6
|
+
};
|
|
7
|
+
export declare class RootModule<exports extends {} = {}> extends DynamicBase<exports> {
|
|
8
|
+
get [arkKind](): "module";
|
|
9
|
+
}
|
|
10
|
+
export interface InternalModule<exports extends InternalResolutions = InternalResolutions> extends RootModule<exports> {
|
|
11
|
+
root?: BaseRoot;
|
|
12
|
+
}
|
|
13
|
+
export declare const bindModule: (module: InternalModule, $: BaseScope) => InternalModule;
|
|
14
|
+
type exportSchemaScope<$> = {
|
|
15
|
+
[k in keyof $]: instantiateRoot<$[k]>;
|
|
16
|
+
};
|
|
17
|
+
export type instantiateRoot<t> = t extends InternalResolution ? [
|
|
18
|
+
t
|
|
19
|
+
] extends [anyOrNever] ? BaseRoot : t : BaseRoot;
|
|
20
|
+
export declare const SchemaModule: new <$ = {}>(types: exportSchemaScope<$>) => SchemaModule<$>;
|
|
21
|
+
export interface SchemaModule<$ = {}> extends RootModule<exportSchemaScope<$>> {
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { Callable, type Entry, type Fn, type GuardablePredicate, type Json, type JsonObject, type JsonStructure, type Key, type array, type conform, type listable, type mutable, type requireKeys } from "../util/index.js";
|
|
2
|
+
import type { ResolvedConfig } from "./config.ts";
|
|
3
|
+
import type { Inner, childKindOf, nodeOfKind, reducibleKindOf } from "./kinds.ts";
|
|
4
|
+
import type { BaseParseContext, BaseParseOptions } from "./parse.ts";
|
|
5
|
+
import type { Intersection } from "./roots/intersection.ts";
|
|
6
|
+
import type { Morph } from "./roots/morph.ts";
|
|
7
|
+
import type { BaseRoot } from "./roots/root.ts";
|
|
8
|
+
import type { Unit } from "./roots/unit.ts";
|
|
9
|
+
import type { BaseScope } from "./scope.ts";
|
|
10
|
+
import { type NodeCompiler } from "./shared/compile.ts";
|
|
11
|
+
import type { ArkEnv, BaseNodeDeclaration, BaseNodeInput, TypeMeta, attachmentsOf } from "./shared/declare.ts";
|
|
12
|
+
import { type ArkErrors } from "./shared/errors.ts";
|
|
13
|
+
import { type FailureSite, type UnionSite } from "./shared/issues.ts";
|
|
14
|
+
import { type BasisKind, type NodeKind, type OpenNodeKind, type StructuralKind, type UnknownAttachmentsInput } from "./shared/implement.ts";
|
|
15
|
+
import { type RootApplyRuntime } from "./shared/rootApply.ts";
|
|
16
|
+
import { type AliasDepth, type FailHandler, type InternalTraversal, type Traversal, type TraverseApply, type TraverseTransform } from "./shared/traversal.ts";
|
|
17
|
+
import type { UndeclaredKeyHandling } from "./structure/structure.ts";
|
|
18
|
+
import type { UnboundTraversals } from "./units.ts";
|
|
19
|
+
export declare const forgetReferences: (node: BaseNode) => void;
|
|
20
|
+
/** a callable and cache a Type holds until it's read, and then is a node of its kind */
|
|
21
|
+
export declare const deferredCallable: () => {
|
|
22
|
+
fn: Function;
|
|
23
|
+
c: object;
|
|
24
|
+
};
|
|
25
|
+
declare class NodeCache {
|
|
26
|
+
self: any;
|
|
27
|
+
expression: string | undefined;
|
|
28
|
+
requiredProps: Map<Key, {
|
|
29
|
+
deref(): BaseNode | undefined;
|
|
30
|
+
}> | undefined;
|
|
31
|
+
kv: readonly Entry<string>[] | undefined;
|
|
32
|
+
metaJson: object | undefined;
|
|
33
|
+
byId: Record<string, BaseNode> | undefined;
|
|
34
|
+
/** whether collecting its references replaced one with an equal node */
|
|
35
|
+
replacedRefs: boolean | undefined;
|
|
36
|
+
/** whether it's what its scope's nodesByKey holds for its inner and meta */
|
|
37
|
+
key: string | undefined;
|
|
38
|
+
/** the node a Scope bound it from, whose id, inner and meta it keeps */
|
|
39
|
+
boundFrom: BaseNode | undefined;
|
|
40
|
+
/** whether every alias it reaches has resolved */
|
|
41
|
+
reachedResolved: boolean | undefined;
|
|
42
|
+
/** whether it reaches user code, through any alias */
|
|
43
|
+
reachesUserCode: boolean | undefined;
|
|
44
|
+
shallowRefs: BaseNode[] | undefined;
|
|
45
|
+
flatRefs: FlatRef[] | undefined;
|
|
46
|
+
fullJson: JsonObject | undefined;
|
|
47
|
+
innerJson: JsonStructure | undefined;
|
|
48
|
+
json: JsonStructure | undefined;
|
|
49
|
+
bareJson: Json | undefined;
|
|
50
|
+
innerHash: string | undefined;
|
|
51
|
+
hash: string | undefined;
|
|
52
|
+
flatMorphs: FlatRef<Morph.Node | Intersection.Node>[] | undefined;
|
|
53
|
+
entersAlias: boolean | undefined;
|
|
54
|
+
trackedId: string | undefined;
|
|
55
|
+
tfs: boolean | undefined;
|
|
56
|
+
checksCtx: boolean | undefined;
|
|
57
|
+
/** whether it was used before it was compiled, so it's compiled at its next use */
|
|
58
|
+
usedPreJit: boolean | undefined;
|
|
59
|
+
failSite: FailureSite | UnionSite | undefined;
|
|
60
|
+
finalizedIn: unknown;
|
|
61
|
+
_in: BaseNode | undefined;
|
|
62
|
+
finalizedOut: unknown;
|
|
63
|
+
_out: BaseNode | undefined;
|
|
64
|
+
assert: ((data: any, pipedFromCtx?: Traversal) => unknown) | undefined;
|
|
65
|
+
pipe: BaseRoot["pipe"] | undefined;
|
|
66
|
+
description: string | undefined;
|
|
67
|
+
isAliasResolution: boolean | undefined;
|
|
68
|
+
/** the `allows` a Type has while it defers compiling until it's used */
|
|
69
|
+
preJit: BaseNode["allows"] | undefined;
|
|
70
|
+
isReusableLeaf: boolean | undefined;
|
|
71
|
+
onFail: ArkErrors.Handler | null;
|
|
72
|
+
rootApply?: RootApply;
|
|
73
|
+
applyInPlace?: TraverseApply;
|
|
74
|
+
transformInPlace?: TraverseTransform;
|
|
75
|
+
unbound?: UnboundTraversals | undefined;
|
|
76
|
+
}
|
|
77
|
+
export declare const writeContextAtDefinitionMessage = "A narrow read ctx.context where ArkType checks a literal as it defines a Type, before any call can pass one. Narrow a wider Type, like string, and check the literal in the narrow";
|
|
78
|
+
export declare const hashedPrefixLength = 1024;
|
|
79
|
+
export declare const jsonLengthOf: (json: unknown) => number;
|
|
80
|
+
export declare const holdsSameChildren: (l: BaseNode, r: BaseNode) => boolean;
|
|
81
|
+
export declare const hashesMatch: (l: BaseNode, r: BaseNode) => boolean;
|
|
82
|
+
export declare const innerHashesMatch: (l: BaseNode, r: BaseNode) => boolean;
|
|
83
|
+
export declare abstract class BaseNode<
|
|
84
|
+
/** @ts-ignore allow instantiation assignment to the base type */
|
|
85
|
+
out d extends BaseNodeDeclaration = BaseNodeDeclaration> extends Callable<(data: d["prerequisite"], ctx?: Traversal, onFail?: ArkErrors.Handler | null) => unknown, attachmentsOf<d>> {
|
|
86
|
+
$: BaseScope;
|
|
87
|
+
bits: number;
|
|
88
|
+
/** whether it or a node it holds alters data, with a morph or a default */
|
|
89
|
+
alters: boolean;
|
|
90
|
+
/** whether it or a node it holds is a morph */
|
|
91
|
+
hasMorph: boolean;
|
|
92
|
+
/** whether it or a node it holds has a narrow that reads `ctx` */
|
|
93
|
+
ctxPred: boolean;
|
|
94
|
+
/** whether it or a node it holds has a narrow a build proved reaches `ctx` only to return what it reports */
|
|
95
|
+
reportsPred: boolean;
|
|
96
|
+
isCyclic: boolean;
|
|
97
|
+
/** whether it or a node it holds is an alias */
|
|
98
|
+
hasAlias: boolean;
|
|
99
|
+
/** whether it is an alias, or a union or morph whose own data an alias checks */
|
|
100
|
+
topAlias: boolean;
|
|
101
|
+
/** whether its Allows needs `ctx`, so it can't be called with data alone */
|
|
102
|
+
allowsCtx: boolean;
|
|
103
|
+
/** whether it or a node it holds has a morph that reads `ctx` or pipes to a node */
|
|
104
|
+
ctxMorph: boolean;
|
|
105
|
+
/** whether it or a node it holds keeps the description it had in its original scope */
|
|
106
|
+
keptDesc: boolean;
|
|
107
|
+
/** whether it or a node it holds calls a morph or a narrow other than a keyword's */
|
|
108
|
+
userCode: boolean;
|
|
109
|
+
/** whether it or a node it holds loops or runs a regex, as a sequence or a pattern does */
|
|
110
|
+
costly: boolean;
|
|
111
|
+
/** its cache: what's derived from it, each computed when first read */
|
|
112
|
+
readonly c: NodeCache;
|
|
113
|
+
allows: (data: d["prerequisite"]) => boolean;
|
|
114
|
+
/** the morphs its own data passes through, not a prop's */
|
|
115
|
+
get topMorphs(): array<Morph>;
|
|
116
|
+
/** its inner keys and values, as entries */
|
|
117
|
+
get kv(): readonly Entry<string>[];
|
|
118
|
+
get metaJson(): object;
|
|
119
|
+
get onFail(): ArkErrors.Handler | null;
|
|
120
|
+
constructor(attachments: UnknownAttachmentsInput, $: BaseScope);
|
|
121
|
+
get entersAlias(): boolean;
|
|
122
|
+
get trackedId(): string;
|
|
123
|
+
/**
|
|
124
|
+
* whether it alters data, counting what it reaches through aliases, which
|
|
125
|
+
* `alters` doesn't see; final once nothing but inputs and outputs is open
|
|
126
|
+
*/
|
|
127
|
+
get tfs(): boolean;
|
|
128
|
+
/** whether checking data reaches a narrow that reads `ctx`, through aliases too, so Allows needs a traversal */
|
|
129
|
+
get checksCtx(): boolean;
|
|
130
|
+
private reaches;
|
|
131
|
+
get tfsById(): boolean;
|
|
132
|
+
/** whether transforming data needs `ctx`: a morph reading it, an alias, or a `ctx` narrow choosing a branch */
|
|
133
|
+
get tfCtx(): boolean;
|
|
134
|
+
/** whether a child's transform needs `ctx`, so a `ctx` narrow choosing between children does too */
|
|
135
|
+
protected get ctxSel(): boolean;
|
|
136
|
+
/** how its root apply validates: by Allows alone, with a traversal, or transforming with or without `ctx` */
|
|
137
|
+
get applyMode(): RootApplyStrategy;
|
|
138
|
+
/** each node it references, keyed by id */
|
|
139
|
+
get byId(): Record<string, BaseNode>;
|
|
140
|
+
selectReferences(selects: (node: BaseNode) => boolean): readonly BaseNode[];
|
|
141
|
+
/** the nodes it references that aren't its children, like the node a morph pipes to */
|
|
142
|
+
get otherRefs(): readonly BaseNode[];
|
|
143
|
+
private collectReferences;
|
|
144
|
+
get shallowRefs(): BaseNode[];
|
|
145
|
+
get flatRefs(): FlatRef[];
|
|
146
|
+
get flatMorphs(): FlatRef<Morph.Node | Intersection.Node>[];
|
|
147
|
+
/** collects its flat references and flat morphs */
|
|
148
|
+
protected initFlat(): void;
|
|
149
|
+
private get checksUncompiled();
|
|
150
|
+
deferJit(): void;
|
|
151
|
+
initRootApply(): RootApply;
|
|
152
|
+
protected createRootApply(): RootApply;
|
|
153
|
+
/**
|
|
154
|
+
* a root apply transforming by the first branch allowing data, with no
|
|
155
|
+
* `ctx`, since a transform that doesn't need one has only context-free morphs
|
|
156
|
+
*/
|
|
157
|
+
private optimisticApply;
|
|
158
|
+
private rejectRoot;
|
|
159
|
+
/** checks data without collecting errors, `t` and a traversal kind naming each traversal */
|
|
160
|
+
abstract tAllows(data: d["prerequisite"], ctx: InternalTraversal | AliasDepth): boolean;
|
|
161
|
+
/** checks data, collecting its errors in `ctx`, and applies its morphs */
|
|
162
|
+
abstract tApply(data: d["prerequisite"], ctx: InternalTraversal): void;
|
|
163
|
+
/** applies its morphs and defaults to data already found valid */
|
|
164
|
+
tTransform?(data: d["prerequisite"], ctx: InternalTraversal): unknown;
|
|
165
|
+
abstract expression: string;
|
|
166
|
+
abstract compile(js: NodeCompiler): void;
|
|
167
|
+
/** writes one expression for whether `data` satisfies it, for a leaf checked inline, if it can */
|
|
168
|
+
jsCond?(js: NodeCompiler, data: string): string | undefined;
|
|
169
|
+
/** writes one expression computing its traversal's result, if it can */
|
|
170
|
+
jsExpression?(js: NodeCompiler): string | undefined;
|
|
171
|
+
/** what compiled code reports when data fails it, holding its `errorCtx` as `v` */
|
|
172
|
+
get failSite(): FailureSite | UnionSite;
|
|
173
|
+
get description(): string;
|
|
174
|
+
get references(): BaseNode[];
|
|
175
|
+
get precedence(): number;
|
|
176
|
+
/** its precompiled unit's function, whose source is its `precompilation` */
|
|
177
|
+
unitFn: Fn | undefined;
|
|
178
|
+
get precompilation(): string | undefined;
|
|
179
|
+
get assert(): (data: d["prerequisite"], pipedFromCtx?: Traversal) => unknown;
|
|
180
|
+
traverse(data: d["prerequisite"], pipedFromCtx?: Traversal): ArkErrors | {} | null | undefined;
|
|
181
|
+
traverseUnused(data: d["prerequisite"]): ArkErrors | {} | null | undefined;
|
|
182
|
+
allowsUnused(data: d["prerequisite"]): boolean;
|
|
183
|
+
/** _in should be used internally instead */
|
|
184
|
+
get in(): unknown;
|
|
185
|
+
/** the input it accepts as a node, each morph replaced by its input: what `in` finalizes */
|
|
186
|
+
get _in(): BaseNode;
|
|
187
|
+
/** _out should be used internally instead */
|
|
188
|
+
get out(): unknown;
|
|
189
|
+
/** the output it returns as a node, each morph replaced by its output: what `out` finalizes */
|
|
190
|
+
get _out(): BaseNode;
|
|
191
|
+
private finalized;
|
|
192
|
+
private cachedIo;
|
|
193
|
+
getIo(ioKind: "in" | "out"): BaseNode;
|
|
194
|
+
get innerJson(): JsonStructure;
|
|
195
|
+
get json(): JsonStructure;
|
|
196
|
+
/** its json, or the value of its `bareKey` alone where that's all it holds */
|
|
197
|
+
get bareJson(): Json;
|
|
198
|
+
get innerHash(): string;
|
|
199
|
+
get hash(): string;
|
|
200
|
+
/** its inner JSON before collapsing, with every key it has */
|
|
201
|
+
protected get fullJson(): JsonObject;
|
|
202
|
+
toJSON(): JsonStructure;
|
|
203
|
+
toString(): string;
|
|
204
|
+
equals(r: unknown): boolean;
|
|
205
|
+
ifEquals(r: unknown): BaseNode | undefined;
|
|
206
|
+
/**
|
|
207
|
+
* whether its inner JSON is that of r, a node of its kind, where that's
|
|
208
|
+
* decided without writing either, as most comparisons of nodes are
|
|
209
|
+
*/
|
|
210
|
+
sameInner(r: BaseNode): boolean | undefined;
|
|
211
|
+
/** whether it's a node of `kind`, narrowing it to that kind's node */
|
|
212
|
+
is<kind extends NodeKind>(kind: kind): this is nodeOfKind<kind>;
|
|
213
|
+
/** it as a node of `kind`, or a thrown error if it's another kind */
|
|
214
|
+
assertIs<kind extends NodeKind>(kind: kind): nodeOfKind<kind>;
|
|
215
|
+
hasKindIn<kinds extends NodeKind[]>(...kinds: kinds): this is nodeOfKind<kinds[number]>;
|
|
216
|
+
isBasis(): this is nodeOfKind<BasisKind>;
|
|
217
|
+
isStructural(): this is nodeOfKind<StructuralKind>;
|
|
218
|
+
isRoot(): this is BaseRoot;
|
|
219
|
+
isUnknown(): boolean;
|
|
220
|
+
isNever(): boolean;
|
|
221
|
+
hasUnit<value>(value: unknown): this is Unit.Node & {
|
|
222
|
+
unit: value;
|
|
223
|
+
};
|
|
224
|
+
/** whether its kind's intersection can hold several of it, like predicates */
|
|
225
|
+
canStack(): this is nodeOfKind<OpenNodeKind>;
|
|
226
|
+
/** its expression written inside another, grouped where precedence needs it */
|
|
227
|
+
get nestedExpr(): string;
|
|
228
|
+
select<const selector extends NodeSelector.CompositeInput, predicate extends GuardablePredicate<NodeSelector.inferSelectKind<d["kind"], selector>>>(selector: NodeSelector.validateComposite<selector, predicate>): NodeSelector.infer<d["kind"], selector>;
|
|
229
|
+
select<const selector extends NodeSelector.Single>(selector: selector): NodeSelector.infer<d["kind"], selector>;
|
|
230
|
+
private _select;
|
|
231
|
+
transform<mapper extends DeepNodeTransformation>(mapper: mapper, opts?: DeepNodeTransformOptions): nodeOfKind<reducibleKindOf<this["kind"]>> | Extract<ReturnType<mapper>, null>;
|
|
232
|
+
/** the context a transform starts with */
|
|
233
|
+
protected _tfContext(opts: DeepNodeTransformOptions | undefined): DeepNodeTransformContext;
|
|
234
|
+
/** transforms it and the nodes it holds with mapper, returning null to remove it */
|
|
235
|
+
protected _tf(mapper: DeepNodeTransformation, ctx: DeepNodeTransformContext): BaseNode | null;
|
|
236
|
+
/** its inner with each child transformed, a child the mapper removed left out */
|
|
237
|
+
private _tfChildren;
|
|
238
|
+
/** a copy with meta applied to the references a selector picks */
|
|
239
|
+
configureRefs(meta: TypeMeta.MappableInput.Internal, selector?: NodeSelector): this;
|
|
240
|
+
}
|
|
241
|
+
export declare const isMutuallySimulated: (l: BaseNode, r: BaseNode, unfoldsAliases?: boolean) => boolean;
|
|
242
|
+
export declare const referencesThroughAliases: (references: readonly BaseNode[]) => BaseNode[];
|
|
243
|
+
export declare const referencesWithoutCases: (root: BaseNode) => Set<BaseNode>;
|
|
244
|
+
export declare const resolveReachedAliases: (root: BaseNode) => void;
|
|
245
|
+
/** a literal key (named property) or a node (index signatures) representing part of a type structure */
|
|
246
|
+
export type KeyOrKeyNode = Key | BaseRoot;
|
|
247
|
+
export type GettableKeyOrNode = KeyOrKeyNode | number;
|
|
248
|
+
export type RootApply = (data: unknown, onFail: FailHandler | null | undefined) => unknown;
|
|
249
|
+
export type RootApplyStrategy = "allows" | "contextual" | "transform" | "contextualTransform";
|
|
250
|
+
export type FlatRef<root extends BaseRoot = BaseRoot> = {
|
|
251
|
+
path: array<KeyOrKeyNode>;
|
|
252
|
+
node: root;
|
|
253
|
+
propString: string;
|
|
254
|
+
};
|
|
255
|
+
export type NodeSelector = NodeSelector.Single | NodeSelector.Composite;
|
|
256
|
+
export declare namespace NodeSelector {
|
|
257
|
+
interface SelectableFn<input, returns, kind extends NodeKind = NodeKind> {
|
|
258
|
+
(input: input, selector: NodeSelector.CompositeOf<kind>): returns;
|
|
259
|
+
(input: input, selector?: NodeSelector.Single): returns;
|
|
260
|
+
}
|
|
261
|
+
type CompositeOf<selfKind extends NodeKind = NodeKind> = {
|
|
262
|
+
[k in NodeKind]: {
|
|
263
|
+
kind: k;
|
|
264
|
+
boundary?: Boundary;
|
|
265
|
+
method?: Method;
|
|
266
|
+
where?: GuardablePredicate<nodeOfKind<k>>;
|
|
267
|
+
};
|
|
268
|
+
}[NodeKind] | {
|
|
269
|
+
[b in Boundary]: {
|
|
270
|
+
kind?: undefined;
|
|
271
|
+
boundary: b;
|
|
272
|
+
method?: Method;
|
|
273
|
+
where?: GuardablePredicate<inferSelectKind<selfKind, b>>;
|
|
274
|
+
};
|
|
275
|
+
}[Boundary] | {
|
|
276
|
+
kind?: undefined;
|
|
277
|
+
boundary?: undefined;
|
|
278
|
+
method?: Method;
|
|
279
|
+
where?: GuardablePredicate<inferSelectKind<selfKind, "references">>;
|
|
280
|
+
};
|
|
281
|
+
type Single = NodeSelector.Boundary | NodeSelector.Kind | GuardablePredicate<BaseNode>;
|
|
282
|
+
type Boundary = "self" | "child" | "shallow" | "references";
|
|
283
|
+
type Kind = NodeKind;
|
|
284
|
+
type Method = "filter" | "assertFilter" | "find" | "assertFind";
|
|
285
|
+
interface Composite {
|
|
286
|
+
method?: Method;
|
|
287
|
+
boundary?: Boundary;
|
|
288
|
+
kind?: Kind;
|
|
289
|
+
where?: GuardablePredicate<BaseNode>;
|
|
290
|
+
}
|
|
291
|
+
type Normalized = requireKeys<Composite, "method" | "boundary">;
|
|
292
|
+
type CompositeInput = Omit<Composite, "where">;
|
|
293
|
+
type BaseResult = BaseNode | BaseNode[] | undefined;
|
|
294
|
+
type validateComposite<selector, predicate> = {
|
|
295
|
+
[k in keyof selector]: k extends "where" ? predicate : conform<selector[k], CompositeInput[k & keyof CompositeInput]>;
|
|
296
|
+
};
|
|
297
|
+
type infer<selfKind extends NodeKind, selector> = applyMethod<selector extends NodeSelector.WhereCastInput<any, infer narrowed> ? narrowed : NodeSelector.inferSelectKind<selfKind, selector>, selector>;
|
|
298
|
+
type BoundaryInput<b extends Boundary> = b | {
|
|
299
|
+
boundary: b;
|
|
300
|
+
};
|
|
301
|
+
type KindInput<k extends Kind> = k | {
|
|
302
|
+
kind: k;
|
|
303
|
+
};
|
|
304
|
+
type WhereCastInput<kindNode extends BaseNode, narrowed extends kindNode> = ((In: kindNode) => In is narrowed) | {
|
|
305
|
+
where: (In: kindNode) => In is narrowed;
|
|
306
|
+
};
|
|
307
|
+
type inferSelectKind<selfKind extends NodeKind, selector> = selectKind<selfKind, selector> extends infer kind extends NodeKind ? NodeKind extends kind ? BaseNode : nodeOfKind<kind> : never;
|
|
308
|
+
type selectKind<selfKind extends NodeKind, selector> = selector extends BoundaryInput<"self"> ? selfKind : selector extends KindInput<infer kind> ? kind : selector extends BoundaryInput<"child"> ? selfKind | childKindOf<selfKind> : NodeKind;
|
|
309
|
+
type applyMethod<t, selector> = selector extends {
|
|
310
|
+
method: infer method extends Method;
|
|
311
|
+
} ? method extends "filter" ? t[] : method extends "assertFilter" ? [t, ...t[]] : method extends "find" ? t | undefined : method extends "assertFind" ? t : never : t[];
|
|
312
|
+
}
|
|
313
|
+
export declare const typePathToPropString: (path: array<KeyOrKeyNode>) => string;
|
|
314
|
+
export declare const flatRef: <node extends BaseRoot>(path: array<KeyOrKeyNode>, node: node) => FlatRef<node>;
|
|
315
|
+
export declare const ioOf: <node extends BaseNode>(node: node, ioKind: "in" | "out") => node;
|
|
316
|
+
export declare const flatRefsAt: (key: KeyOrKeyNode, node: BaseRoot) => FlatRef[];
|
|
317
|
+
export declare const flatRefsAreEqual: (l: FlatRef, r: FlatRef) => boolean;
|
|
318
|
+
export declare const flatMorphsAreEqual: (l: FlatRef<Morph.Node | Intersection.Node>, r: FlatRef<Morph.Node | Intersection.Node>) => boolean;
|
|
319
|
+
export declare const uniqueFlatRefs: (refs: FlatRef[]) => FlatRef[];
|
|
320
|
+
export declare const appendUniqueNodes: <node extends BaseNode>(existing: node[] | undefined, refs: listable<node>) => node[];
|
|
321
|
+
export type DeepNodeTransformOptions = {
|
|
322
|
+
/** whether a transform visits a node, else it's kept as is */
|
|
323
|
+
shouldTf?: ShouldTransformFn;
|
|
324
|
+
bindScope?: BaseScope;
|
|
325
|
+
/** whether the schema is already reduced, so it's parsed as is */
|
|
326
|
+
reduced?: boolean;
|
|
327
|
+
selected?: readonly BaseNode[] | undefined;
|
|
328
|
+
names?: Record<string, string>;
|
|
329
|
+
};
|
|
330
|
+
export type ShouldTransformFn = (node: BaseNode, ctx: DeepNodeTransformContext) => boolean;
|
|
331
|
+
export interface DeepNodeTransformContext extends DeepNodeTransformOptions {
|
|
332
|
+
root: BaseNode;
|
|
333
|
+
selected: readonly BaseNode[] | undefined;
|
|
334
|
+
path: mutable<array<KeyOrKeyNode>>;
|
|
335
|
+
seen: {
|
|
336
|
+
[originalId: string]: (() => BaseNode | undefined) | undefined;
|
|
337
|
+
};
|
|
338
|
+
parseOptions: BaseParseOptions;
|
|
339
|
+
undeclaredHandling: UndeclaredKeyHandling | undefined;
|
|
340
|
+
throughAliases: boolean;
|
|
341
|
+
/** the synthetic aliases a transform opened for the resolutions it transformed, by id */
|
|
342
|
+
synth: Record<string, BaseParseContext>;
|
|
343
|
+
}
|
|
344
|
+
export type DeepNodeTransformation = <kind extends NodeKind>(kind: kind, innerWithMeta: Inner<kind> & {
|
|
345
|
+
meta: ArkEnv.meta;
|
|
346
|
+
}, ctx: DeepNodeTransformContext) => (Inner<kind> & BaseNodeInput) | null;
|
|
347
|
+
export declare const rootApplyRuntimeOf: (config: ResolvedConfig) => RootApplyRuntime;
|
|
348
|
+
export declare const writeInnerJson: (node: BaseNode) => JsonObject;
|
|
349
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { type arkKind, type dict, type Key } from "../util/index.js";
|
|
2
|
+
import { type NodeInput, type nodeOfKind } from "./kinds.ts";
|
|
3
|
+
import type { BaseNode } from "./node.ts";
|
|
4
|
+
import type { BaseRoot } from "./roots/root.ts";
|
|
5
|
+
import type { BaseScope } from "./scope.ts";
|
|
6
|
+
import { type NodeKind } from "./shared/implement.ts";
|
|
7
|
+
import { nodesById, type NodeId } from "./shared/registry.ts";
|
|
8
|
+
import type { ArkEnv } from "./shared/declare.ts";
|
|
9
|
+
export type ContextualArgs = Record<string, BaseRoot | NodeId>;
|
|
10
|
+
export type BaseParseOptions<reduced extends boolean = boolean> = {
|
|
11
|
+
alias?: string;
|
|
12
|
+
reduced?: reduced;
|
|
13
|
+
args?: ContextualArgs;
|
|
14
|
+
id?: NodeId;
|
|
15
|
+
name?: string;
|
|
16
|
+
};
|
|
17
|
+
export interface BaseParseContextInput extends BaseParseOptions {
|
|
18
|
+
prefix: string;
|
|
19
|
+
def: unknown;
|
|
20
|
+
}
|
|
21
|
+
export interface AttachedParseContext {
|
|
22
|
+
[arkKind]: "context";
|
|
23
|
+
$: BaseScope;
|
|
24
|
+
id: NodeId;
|
|
25
|
+
phase: "unresolved" | "resolving" | "member" | "resolved" | "failed";
|
|
26
|
+
isReferencedById?: true;
|
|
27
|
+
isReferencedAsThis?: true;
|
|
28
|
+
index?: number;
|
|
29
|
+
lowlink?: number;
|
|
30
|
+
/** whether a reference reached it while it was resolving */
|
|
31
|
+
closes?: true;
|
|
32
|
+
resolution?: BaseRoot;
|
|
33
|
+
error?: unknown;
|
|
34
|
+
}
|
|
35
|
+
export interface BaseParseContext extends BaseParseContextInput, AttachedParseContext {
|
|
36
|
+
id: NodeId;
|
|
37
|
+
}
|
|
38
|
+
export interface NodeParseContextInput<kind extends NodeKind = NodeKind> extends BaseParseContextInput {
|
|
39
|
+
kind: kind;
|
|
40
|
+
def: NodeInput<kind>;
|
|
41
|
+
}
|
|
42
|
+
export interface NodeParseContext<kind extends NodeKind = NodeKind> {
|
|
43
|
+
kind: kind;
|
|
44
|
+
def: NodeInput<kind>;
|
|
45
|
+
$: BaseScope;
|
|
46
|
+
id: NodeId | undefined;
|
|
47
|
+
alias: string | undefined;
|
|
48
|
+
reduced: boolean | undefined;
|
|
49
|
+
}
|
|
50
|
+
export declare const writeInvalidSchemaMessage: (schema: unknown) => string;
|
|
51
|
+
export { nodesById, type NodeId };
|
|
52
|
+
export type NodeResolver = (id: NodeId) => BaseNode;
|
|
53
|
+
export declare const registerNodeId: (written: string) => NodeId;
|
|
54
|
+
export declare const parseNode: (ctx: NodeParseContext) => BaseNode;
|
|
55
|
+
export declare const compareInnerKeys: (l: string, r: string) => number;
|
|
56
|
+
export declare const deferAliases: (v: unknown, $: BaseScope) => unknown;
|
|
57
|
+
export type CreateNodeInput = {
|
|
58
|
+
id: NodeId | undefined;
|
|
59
|
+
alias?: string | undefined;
|
|
60
|
+
kind: NodeKind;
|
|
61
|
+
inner: dict;
|
|
62
|
+
meta: ArkEnv.meta;
|
|
63
|
+
$: BaseScope;
|
|
64
|
+
ignoreCache?: true;
|
|
65
|
+
shell?: DeferredShell | undefined;
|
|
66
|
+
};
|
|
67
|
+
export interface DeferredShell {
|
|
68
|
+
fn: Function;
|
|
69
|
+
c: object;
|
|
70
|
+
}
|
|
71
|
+
/** the id of the node created last, so a deferred Type can tell it reached a new one */
|
|
72
|
+
export declare let lastCreated: string | undefined;
|
|
73
|
+
export declare const createNode: ({ id, alias, kind, inner, meta, $, ignoreCache, shell }: CreateNodeInput) => BaseNode;
|
|
74
|
+
export declare const requiredPropOf: (key: Key, value: BaseRoot, $: BaseScope) => nodeOfKind<"required">;
|
|
75
|
+
export declare const resolveDescription: <node extends BaseNode>(node: node) => node;
|
|
76
|
+
export declare const withId: <node extends BaseNode>(node: node, id: NodeId) => node;
|
|
77
|
+
export declare const withMeta: <node extends BaseNode>(node: node, meta: ArkEnv.meta, id?: NodeId) => node;
|