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,10 @@
|
|
|
1
|
+
// ../schema/out/structure/shared.js
|
|
2
|
+
var arrayIndexSource = `^(?:0|[1-9]\\d*)$`;
|
|
3
|
+
var arrayIndexMatcher = /* @__PURE__ */ new RegExp(arrayIndexSource);
|
|
4
|
+
var maxArrayLength = 4294967295;
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
arrayIndexSource,
|
|
8
|
+
arrayIndexMatcher,
|
|
9
|
+
maxArrayLength
|
|
10
|
+
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
encode,
|
|
3
|
+
inverses
|
|
4
|
+
} from "./chunk-GID3FSQA.js";
|
|
1
5
|
import {
|
|
2
6
|
type
|
|
3
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-C2V6QPE3.js";
|
|
4
8
|
import {
|
|
5
9
|
capitalizeString,
|
|
6
10
|
keepFormatted,
|
|
@@ -19,13 +23,18 @@ import {
|
|
|
19
23
|
writeEpoch,
|
|
20
24
|
writeIsoDate,
|
|
21
25
|
writeUrl
|
|
22
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-4HREHNIV.js";
|
|
27
|
+
import {
|
|
28
|
+
$ark
|
|
29
|
+
} from "./chunk-PDLTEX6Z.js";
|
|
30
|
+
|
|
31
|
+
// ../schema/out/codecs.js
|
|
32
|
+
$ark.encode = encode;
|
|
23
33
|
|
|
24
34
|
// out/codecs.js
|
|
25
|
-
|
|
26
|
-
var codec = function (i, o, { decode, encode }) {
|
|
35
|
+
var codec = function (i, o, { decode, encode: encode2 }) {
|
|
27
36
|
const In = type(i).internal;
|
|
28
|
-
return In.$.node("morph", { morphs: [In, decode], inverse:
|
|
37
|
+
return In.$.node("morph", { morphs: [In, decode], inverse: encode2 }).pipe(type(o));
|
|
29
38
|
};
|
|
30
39
|
inverses.set(parseDate, writeIsoDate);
|
|
31
40
|
inverses.set(parseIsoDate, writeIsoDate);
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import {
|
|
2
|
+
referencesWithoutCases,
|
|
3
|
+
withoutUndefined
|
|
4
|
+
} from "./chunk-KXOC3JEX.js";
|
|
5
|
+
import {
|
|
6
|
+
$ark
|
|
7
|
+
} from "./chunk-PDLTEX6Z.js";
|
|
8
|
+
import {
|
|
9
|
+
assertUnchecked,
|
|
10
|
+
defining,
|
|
11
|
+
hasArkKind,
|
|
12
|
+
isResolutionFinal
|
|
13
|
+
} from "./chunk-3KBOPH3J.js";
|
|
14
|
+
import {
|
|
15
|
+
omit,
|
|
16
|
+
throwParseError
|
|
17
|
+
} from "./chunk-3HZC67MT.js";
|
|
18
|
+
|
|
19
|
+
// ../schema/out/shared/codecs.js
|
|
20
|
+
var inverses = /* @__PURE__ */ new WeakMap();
|
|
21
|
+
var encoders = /* @__PURE__ */ new WeakMap();
|
|
22
|
+
var writeMissingInverseMessage = (expression) => `A morph must have an inverse to be encoded: ${expression}`;
|
|
23
|
+
var encode = function (node) {
|
|
24
|
+
let encoder = encoders.get(node);
|
|
25
|
+
if (!encoder) {
|
|
26
|
+
const isFinal = isResolutionFinal();
|
|
27
|
+
if (isFinal)
|
|
28
|
+
defining(() => {
|
|
29
|
+
});
|
|
30
|
+
let raw;
|
|
31
|
+
try {
|
|
32
|
+
raw = encoderOf(node);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
if (isFinal)
|
|
35
|
+
defining(() => {
|
|
36
|
+
});
|
|
37
|
+
throw e;
|
|
38
|
+
}
|
|
39
|
+
assertUnchecked();
|
|
40
|
+
encoders.set(node, encoder = node.$.fin(raw));
|
|
41
|
+
}
|
|
42
|
+
return encoder;
|
|
43
|
+
};
|
|
44
|
+
var encoderOf = function (node) {
|
|
45
|
+
const branchTfs = [];
|
|
46
|
+
const mapper = (kind, inner, ctx) => kind === "morph" ? invert(inner, node.$, mapper, ctx) : kind === "optional" && "default" in inner ? node.$.node("required", {
|
|
47
|
+
...omit(inner, { default: 1 }),
|
|
48
|
+
value: decodedValueOf(inner.value, node.$)
|
|
49
|
+
}) : kind === "structure" ? requireDefaulted(inner) : kind === "sequence" ? requireDefaultables(inner, node.$) : kind === "union" ? encodeUnion(inner, branchTfs.pop(), node.$) : inner;
|
|
50
|
+
return node.transform(mapper, {
|
|
51
|
+
shouldTf: (n) => {
|
|
52
|
+
const tfs = n.tfs || n.is("optional") && n.hasDef();
|
|
53
|
+
if (tfs && n.is("union"))
|
|
54
|
+
branchTfs.push(n.branches.map(transformsOnEncode));
|
|
55
|
+
return tfs;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
var transformsOnEncode = function (root) {
|
|
60
|
+
if (!root.tfs)
|
|
61
|
+
return false;
|
|
62
|
+
const visited = /* @__PURE__ */ new Set();
|
|
63
|
+
const queue = [root];
|
|
64
|
+
for (let i = 0; i < queue.length; i++) {
|
|
65
|
+
for (const ref of referencesWithoutCases(queue[i])) {
|
|
66
|
+
if (visited.has(ref))
|
|
67
|
+
continue;
|
|
68
|
+
visited.add(ref);
|
|
69
|
+
if (ref.is("morph"))
|
|
70
|
+
return true;
|
|
71
|
+
if (ref.is("structure") && ref.undeclared === "delete")
|
|
72
|
+
return true;
|
|
73
|
+
if (ref.is("alias") && !ref.isIo)
|
|
74
|
+
queue.push(ref.resolution);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
};
|
|
79
|
+
var encodeUnion = function (inner, tfs, $) {
|
|
80
|
+
if (inner.ordered) {
|
|
81
|
+
return {
|
|
82
|
+
...inner,
|
|
83
|
+
branches: sortByTfs(inner.branches, tfs),
|
|
84
|
+
ordered: true
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const plain = [];
|
|
88
|
+
const morphed = [];
|
|
89
|
+
for (let i = 0; i < inner.branches.length; i++) {
|
|
90
|
+
const branch = inner.branches[i];
|
|
91
|
+
if (branch.hasAlias ? tfs[i] : branch.tfs)
|
|
92
|
+
morphed.push(branch);
|
|
93
|
+
else
|
|
94
|
+
plain.push(branch);
|
|
95
|
+
}
|
|
96
|
+
if (!plain.length)
|
|
97
|
+
return { ...inner, branches: morphed };
|
|
98
|
+
if (!morphed.length)
|
|
99
|
+
return inner;
|
|
100
|
+
const morphedBranches = morphed.length > 1 ? $.node("union", { branches: morphed }).branches : morphed;
|
|
101
|
+
const overlapsPlain = plain.some((p) => morphedBranches.some((m) => p._in.overlaps(m._in)));
|
|
102
|
+
if (!overlapsPlain)
|
|
103
|
+
return { ...inner, branches: [...plain, ...morphedBranches] };
|
|
104
|
+
const plainBranches = plain.length > 1 ? $.node("union", { branches: plain }).branches : plain;
|
|
105
|
+
return {
|
|
106
|
+
...inner,
|
|
107
|
+
// a branch without morphs encodes a value unchanged, so try it before
|
|
108
|
+
// an overlapping codec branch
|
|
109
|
+
branches: [...plainBranches, ...morphedBranches],
|
|
110
|
+
ordered: true
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
var sortByTfs = (branches, tfs) => branches.map((branch, i) => [branch, tfs[i]]).sort((l, r) => Number(l[1]) - Number(r[1])).map(([branch]) => branch);
|
|
114
|
+
var invert = function (inner, $, mapper, ctx) {
|
|
115
|
+
let encoder = inner.declaredOut ?? $ark.kw.unknown.internal;
|
|
116
|
+
let inverse = inner.inverse;
|
|
117
|
+
const head = hasArkKind(inner.morphs[0], "root") ? inner.morphs[0] : void 0;
|
|
118
|
+
for (let i = inner.morphs.length - 1; i >= (head ? 1 : 0); i--) {
|
|
119
|
+
const morph = inner.morphs[i];
|
|
120
|
+
if (hasArkKind(morph, "root")) {
|
|
121
|
+
encoder = pipeEncoder(encoder, morph.transformWithin(mapper, ctx) ?? $ark.kw.unknown.internal);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
encoder = $.node("morph", {
|
|
125
|
+
morphs: [
|
|
126
|
+
encoder,
|
|
127
|
+
inverse ?? inverses.get(morph) ?? throwParseError(writeMissingInverseMessage($.node("morph", inner).expression))
|
|
128
|
+
],
|
|
129
|
+
inverse: morph
|
|
130
|
+
});
|
|
131
|
+
inverse = void 0;
|
|
132
|
+
}
|
|
133
|
+
const decodedIn = inner.declaredIn ?? head;
|
|
134
|
+
return decodedIn ? pipeEncoder(encoder, decodedIn) : encoder;
|
|
135
|
+
};
|
|
136
|
+
var pipeEncoder = (encoder, next) => encoder.isUnknown() ? next : next.isUnknown() ? encoder : encoder.rawPipeOnce(next);
|
|
137
|
+
var requireDefaulted = function (inner) {
|
|
138
|
+
if (!inner.optional)
|
|
139
|
+
return inner;
|
|
140
|
+
const props = [...inner.required ?? [], ...inner.optional];
|
|
141
|
+
return {
|
|
142
|
+
...inner,
|
|
143
|
+
required: props.filter((prop) => prop.is("required")),
|
|
144
|
+
optional: props.filter((prop) => prop.is("optional")),
|
|
145
|
+
order: inner.order ?? props.map((prop) => prop.key)
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
var requireDefaultables = function ({ defaultables = [], ...inner }, $) { return ({
|
|
149
|
+
...inner,
|
|
150
|
+
prefix: [
|
|
151
|
+
...inner.prefix ?? [],
|
|
152
|
+
...defaultables.map(([node]) => decodedValueOf(node, $))
|
|
153
|
+
]
|
|
154
|
+
}) };
|
|
155
|
+
var decodedValueOf = (value, $) => $.cfg.exactOptionalPropertyTypes === false ? withoutUndefined(value) : value;
|
|
156
|
+
|
|
157
|
+
export {
|
|
158
|
+
inverses,
|
|
159
|
+
writeMissingInverseMessage,
|
|
160
|
+
encode
|
|
161
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = function (to, from, except, desc) {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
__export,
|
|
21
|
+
__reExport
|
|
22
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CompiledFunction
|
|
3
|
+
} from "./chunk-VYMXHSFR.js";
|
|
4
|
+
import {
|
|
5
|
+
ArkTraversal,
|
|
6
|
+
applyUnread
|
|
7
|
+
} from "./chunk-PDLTEX6Z.js";
|
|
8
|
+
import {
|
|
9
|
+
TransformErrors,
|
|
10
|
+
addMorphErrs,
|
|
11
|
+
allowsAcyclic,
|
|
12
|
+
allowsInContext,
|
|
13
|
+
applyCyclic,
|
|
14
|
+
transformResolution
|
|
15
|
+
} from "./chunk-3KBOPH3J.js";
|
|
16
|
+
import {
|
|
17
|
+
unset
|
|
18
|
+
} from "./chunk-3HZC67MT.js";
|
|
19
|
+
|
|
20
|
+
// ../schema/out/shared/rootApply.js
|
|
21
|
+
var rootApplyRuntime = {
|
|
22
|
+
Traversal: ArkTraversal,
|
|
23
|
+
TransformErrors,
|
|
24
|
+
addMorphErrs,
|
|
25
|
+
applyCyclic,
|
|
26
|
+
applyRejected: applyUnread,
|
|
27
|
+
allowsAcyclic,
|
|
28
|
+
allowsInContext,
|
|
29
|
+
transformResolution
|
|
30
|
+
};
|
|
31
|
+
var nodeMembers = ["allows", "tAllows", "tTransform"];
|
|
32
|
+
var rootApplyParams = [
|
|
33
|
+
"node",
|
|
34
|
+
"config",
|
|
35
|
+
...Object.keys(rootApplyRuntime)
|
|
36
|
+
];
|
|
37
|
+
var writeRootApply = function (node, name) {
|
|
38
|
+
const [reads, rootApply, applyFailed] = rootApplyParts(node, name);
|
|
39
|
+
return `"use strict"
|
|
40
|
+
const ${reads.join(", ")}
|
|
41
|
+
${applyFailed ? `const applyFailed = ${applyFailed}
|
|
42
|
+
` : ""}return (${rootApply})`;
|
|
43
|
+
};
|
|
44
|
+
var rootApplyParts = function (node, name, refOf) {
|
|
45
|
+
const ref = refOf ?? ((param) => param);
|
|
46
|
+
const js = new CompiledFunction("data", "onFail").indent();
|
|
47
|
+
const applyFailed = new CompiledFunction("data", "onFail").indent();
|
|
48
|
+
const newCtx = `new ${ref("Traversal")}(data, ${ref("config")})`;
|
|
49
|
+
const handler = refOf ? "onFail" : "onFail === undefined ? node.onFail : onFail";
|
|
50
|
+
const fallback = (body) => node.hasAlias ? body.return(`${ref("applyCyclic")}(node, data, ${newCtx}).fin(${handler})`) : body.return(`${ref("applyRejected")}(node, data, ${ref("config")}, ${handler}, ${ref("Traversal")})`);
|
|
51
|
+
const returnResult = () => node.hasMorph ? js.if(`result !== data && typeof result === "function" && result instanceof ${ref("TransformErrors")}`, () => js.const("ctx", newCtx).line(`${ref("addMorphErrs")}(ctx, result)`).return(`ctx.fin(${handler})`)).return("result") : js.return("result");
|
|
52
|
+
if (node.applyMode === "contextual") {
|
|
53
|
+
fallback(applyFailed);
|
|
54
|
+
js.const("ctx", newCtx).if("!tAllows(data, ctx) || ctx.hasError()", () => js.return("applyFailed(data, onFail)")).return("data");
|
|
55
|
+
} else if (node.applyMode === "allows")
|
|
56
|
+
js.if("!allows(data)", fallback).return("data");
|
|
57
|
+
else if (node.applyMode === "contextualTransform") {
|
|
58
|
+
if (node.hasAlias) {
|
|
59
|
+
js.const("untracked", `${ref("allowsAcyclic")}(node, data)`).if(`!(untracked ?? ${ref("allowsInContext")}(node, data, ${ref("config")}, ${ref("Traversal")}))`, fallback).const("ctx", newCtx).set("ctx.isTree", "untracked === undefined").const("result", `${ref("transformResolution")}(ctx, ${refOf ? "node.id" : `"${name}"`}, data, tTransform)`);
|
|
60
|
+
} else {
|
|
61
|
+
js.if("!allows(data)", fallback).const("ctx", newCtx).const("result", "tTransform(data, ctx)");
|
|
62
|
+
}
|
|
63
|
+
js.return(`ctx.hasError() ? ctx.fin(${handler}) : result`);
|
|
64
|
+
} else if (node.is("union") && !node.discriminant) {
|
|
65
|
+
js.const("result", "tTransform(data)").if(`result === ${JSON.stringify(unset)}`, fallback);
|
|
66
|
+
returnResult();
|
|
67
|
+
} else if (node.hasMorph) {
|
|
68
|
+
js.if("!allows(data)", fallback).const("result", "tTransform(data)");
|
|
69
|
+
returnResult();
|
|
70
|
+
} else
|
|
71
|
+
js.if("!allows(data)", fallback).return("tTransform(data)");
|
|
72
|
+
const prefix = refOf ? "" : name;
|
|
73
|
+
const failurePath = applyFailed.body ? `function ${applyFailed.write(`${prefix}ApplyFailed`)}` : void 0;
|
|
74
|
+
const rootApply = `function ${js.write(`${prefix}RootApply`)}`;
|
|
75
|
+
const reads = nodeMembers.filter((member) => new RegExp(`\\b${member}\\b`).test(`${failurePath}${rootApply}`)).map((member) => `${member} = node.${member}`);
|
|
76
|
+
return [reads, rootApply, failurePath];
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
rootApplyRuntime,
|
|
81
|
+
rootApplyParams,
|
|
82
|
+
writeRootApply,
|
|
83
|
+
rootApplyParts
|
|
84
|
+
};
|