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
package/out/scope.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseScope, RootModule, type AliasDefEntry, type ArkSchemaRegistry, type ArkSchemaScopeConfig, type BaseNode, type BaseParseContext, type BaseParseContextInput, type BaseParseOptions, type BaseRoot, type GenericAst, type GenericParamAst, type GenericParamDef, type NodeInput, type NodeKind, type PreparsedNodeResolution, type PrivateDeclaration, type RootSchema, type arkKind, type exportedNameOf, type nodeOfKind, type reducibleKindOf, type toInternalScope, type writeDuplicateAliasError, type writeShallowCycleErrorMessage } from "
|
|
2
|
-
import { type Brand, type Dict, type ErrorMessage, type ErrorType, type JsonStructure, type anyOrNever, type array, type inferred, type noSuggest } from "
|
|
1
|
+
import { BaseScope, RootModule, type AliasDefEntry, type ArkSchemaRegistry, type ArkSchemaScopeConfig, type BaseNode, type BaseParseContext, type BaseParseContextInput, type BaseParseOptions, type BaseRoot, type GenericAst, type GenericParamAst, type GenericParamDef, type NodeInput, type NodeKind, type PreparsedNodeResolution, type PrivateDeclaration, type RootSchema, type arkKind, type exportedNameOf, type nodeOfKind, type reducibleKindOf, type toInternalScope, type writeDuplicateAliasError, type writeShallowCycleErrorMessage } from "./_internal/schema/index.js";
|
|
2
|
+
import { type Brand, type Dict, type ErrorMessage, type ErrorType, type JsonStructure, type anyOrNever, type array, type inferred, type noSuggest } from "./_internal/util/index.js";
|
|
3
3
|
import type { InferredMorph } from "./attributes.ts";
|
|
4
4
|
import type { DeclarationParser } from "./declare.ts";
|
|
5
5
|
import { InternalFnParser, type FnParser } from "./fn.ts";
|
|
@@ -48,9 +48,8 @@ type bootstrapAliases<def> = {
|
|
|
48
48
|
type inferBootstrapped<$> = {
|
|
49
49
|
[name in keyof $]: $[name] extends Def<infer def> ? inferDefinition<def, $, {}> : $[name] extends {
|
|
50
50
|
t: infer g extends GenericAst;
|
|
51
|
-
} ?
|
|
51
|
+
} ? GenericAst<g["paramsAst"], g["bodyDef"], g["$"] extends UnparsedScope ? $ : g["$"], $> : $[name];
|
|
52
52
|
} & unknown;
|
|
53
|
-
export type bindGenericToScope<g extends GenericAst, $> = GenericAst<g["paramsAst"], g["bodyDef"], g["$"] extends UnparsedScope ? $ : g["$"], $>;
|
|
54
53
|
type extractGenericName<k> = k extends GenericDeclaration<infer name> ? name : never;
|
|
55
54
|
type extractGenericParameters<k> = k extends `${string}<${infer params}>` ? ParameterString<params> : never;
|
|
56
55
|
export type resolutionToAst<alias extends string, resolution> = [
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** an array's index in an issue's path */
|
|
2
|
+
export declare const reportsIndices: boolean;
|
|
3
|
+
/** a key in an issue's path that isn't an identifier, like a record's */
|
|
4
|
+
export declare const bracketsKeys: boolean;
|
|
5
|
+
/** text a site writes from the program's config, or a message configured or supplied as a sentence */
|
|
6
|
+
export declare const writesText: boolean;
|
|
7
|
+
/** a site's `text`, called on its issue: text a function configured writes, or the note that its message is its code's */
|
|
8
|
+
export declare const callsSiteText: boolean;
|
|
9
|
+
/** a union's issue listing its branches', written again where its path changes */
|
|
10
|
+
export declare const listsUnions: boolean;
|
|
11
|
+
/** a union's issue written again where its path changes, as by a pipe or Standard Schema */
|
|
12
|
+
export declare const rewritesUnions: boolean;
|
|
13
|
+
/** a union's issue added to a Traversal, where a validator isn't a checker */
|
|
14
|
+
export declare const traversesUnions: boolean;
|
|
15
|
+
/** a checker applying a value itself, holding a morph, an alias or a callback reading its ctx */
|
|
16
|
+
export declare const appliesValues: boolean;
|
|
17
|
+
/** a union a branch of which transforms data */
|
|
18
|
+
export declare const transformsBranches: boolean;
|
|
19
|
+
/** such a union whose transform can fail, holding a morph or an alias */
|
|
20
|
+
export declare const failsInBranches: boolean;
|
|
21
|
+
/** a union told apart by a key holding a boolean */
|
|
22
|
+
export declare const discriminatesBooleans: boolean;
|
|
23
|
+
/** an errors object's `summary` */
|
|
24
|
+
export declare const readsSummary: boolean;
|
|
25
|
+
/** an errors object read other than by its issues or summary: thrown, printed or passed on */
|
|
26
|
+
export declare const readsErrors: boolean;
|
|
27
|
+
/** a validator holding its expression, which printing one reads: no issue's, but found by a build and written as they are */
|
|
28
|
+
export declare const holdsExpression: boolean;
|
|
29
|
+
/** TraversalError named by a program, which may test what an assert threw against it: no issue's, but found by a build and written as they are */
|
|
30
|
+
export declare const namesTraversalError: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* errors that find their issues once they're read, held by a validator whose
|
|
33
|
+
* failing call may return errors nobody reads. The one a build sets true:
|
|
34
|
+
* where it does, the errors classes are written to take what finds their
|
|
35
|
+
* issues, and where none wrote it, as in arktype itself, their issues stay a
|
|
36
|
+
* field and the runtime makes errors that wait another way
|
|
37
|
+
*/
|
|
38
|
+
export declare const findsOnRead: boolean;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// each set false by a build finding no validator that writes it; only
|
|
2
|
+
// constants, as a bundler inlines one only where no statement precedes it
|
|
3
|
+
/** an array's index in an issue's path */
|
|
4
|
+
export const reportsIndices = true;
|
|
5
|
+
/** a key in an issue's path that isn't an identifier, like a record's */
|
|
6
|
+
export const bracketsKeys = true;
|
|
7
|
+
/** text a site writes from the program's config, or a message configured or supplied as a sentence */
|
|
8
|
+
export const writesText = true;
|
|
9
|
+
/** a site's `text`, called on its issue: text a function configured writes, or the note that its message is its code's */
|
|
10
|
+
export const callsSiteText = true;
|
|
11
|
+
/** a union's issue listing its branches', written again where its path changes */
|
|
12
|
+
export const listsUnions = true;
|
|
13
|
+
/** a union's issue written again where its path changes, as by a pipe or Standard Schema */
|
|
14
|
+
export const rewritesUnions = true;
|
|
15
|
+
/** a union's issue added to a Traversal, where a validator isn't a checker */
|
|
16
|
+
export const traversesUnions = true;
|
|
17
|
+
/** a checker applying a value itself, holding a morph, an alias or a callback reading its ctx */
|
|
18
|
+
export const appliesValues = true;
|
|
19
|
+
/** a union a branch of which transforms data */
|
|
20
|
+
export const transformsBranches = true;
|
|
21
|
+
/** such a union whose transform can fail, holding a morph or an alias */
|
|
22
|
+
export const failsInBranches = true;
|
|
23
|
+
/** a union told apart by a key holding a boolean */
|
|
24
|
+
export const discriminatesBooleans = true;
|
|
25
|
+
/** an errors object's `summary` */
|
|
26
|
+
export const readsSummary = true;
|
|
27
|
+
/** an errors object read other than by its issues or summary: thrown, printed or passed on */
|
|
28
|
+
export const readsErrors = true;
|
|
29
|
+
/** a validator holding its expression, which printing one reads: no issue's, but found by a build and written as they are */
|
|
30
|
+
export const holdsExpression = true;
|
|
31
|
+
/** TraversalError named by a program, which may test what an assert threw against it: no issue's, but found by a build and written as they are */
|
|
32
|
+
export const namesTraversalError = true;
|
|
33
|
+
/**
|
|
34
|
+
* errors that find their issues once they're read, held by a validator whose
|
|
35
|
+
* failing call may return errors nobody reads. The one a build sets true:
|
|
36
|
+
* where it does, the errors classes are written to take what finds their
|
|
37
|
+
* issues, and where none wrote it, as in arktype itself, their issues stay a
|
|
38
|
+
* field and the runtime makes errors that wait another way
|
|
39
|
+
*/
|
|
40
|
+
export const findsOnRead = false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ToJsonSchema, type BaseNode, type BaseRoot, type RootUnit } from "
|
|
1
|
+
import { ToJsonSchema, type BaseNode, type BaseRoot, type RootUnit } from "../_internal/schema/index.js";
|
|
2
2
|
import type { InternalTypedFn } from "../fn.ts";
|
|
3
3
|
import type { HoleKind } from "../runtime.ts";
|
|
4
4
|
import { failureSources, type Baking, type Configured, type DefaultCheck, type ExportedValue, type FactoryParam, type Foldable, type SharedWrite, type StandaloneBake, type StandaloneFactory, type StandaloneIntrospection, type ValidatorMember } from "./baking.ts";
|
|
@@ -66,11 +66,11 @@ export declare class StandaloneArtifact {
|
|
|
66
66
|
classes: Set<unknown>;
|
|
67
67
|
checks: string[];
|
|
68
68
|
checksAsWhole: boolean;
|
|
69
|
-
validatorNames: Map<BaseRoot<import("
|
|
70
|
-
defaultValues: Set<BaseRoot<import("
|
|
71
|
-
readRoots: Set<BaseRoot<import("
|
|
72
|
-
runtimeReadRoots: Set<BaseRoot<import("
|
|
73
|
-
unitRoots: Set<BaseRoot<import("
|
|
69
|
+
validatorNames: Map<BaseRoot<import("../_internal/schema/index.js").InternalRootDeclaration>, string>;
|
|
70
|
+
defaultValues: Set<BaseRoot<import("../_internal/schema/index.js").InternalRootDeclaration>>;
|
|
71
|
+
readRoots: Set<BaseRoot<import("../_internal/schema/index.js").InternalRootDeclaration>>;
|
|
72
|
+
runtimeReadRoots: Set<BaseRoot<import("../_internal/schema/index.js").InternalRootDeclaration>>;
|
|
73
|
+
unitRoots: Set<BaseRoot<import("../_internal/schema/index.js").InternalRootDeclaration>>;
|
|
74
74
|
unitsRead: [rootCount: number, units: RootUnit[]] | undefined;
|
|
75
75
|
writtenRead: [rootCount: number, nodes: BaseNode[]] | undefined;
|
|
76
76
|
unitsByHead: Map<string, RootUnit>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BaseRoot, type BaseScope, type ErrorDetail, type GenericRoot, type MutatesInput } from "
|
|
1
|
+
import { type BaseRoot, type BaseScope, type ErrorDetail, type GenericRoot, type MutatesInput } from "../_internal/schema/index.js";
|
|
2
2
|
import type { TypedFn } from "../fn.ts";
|
|
3
3
|
import type { Generic } from "../generic.ts";
|
|
4
4
|
import type { type } from "../keywords/keywords.ts";
|
|
@@ -12,7 +12,7 @@ export type Foldable = BaseRoot | ExportedValue | BaseScope | GenericRoot;
|
|
|
12
12
|
export type StandaloneExport = ExportedValue | StandaloneFactory | StandaloneIntrospection | StandaloneBake;
|
|
13
13
|
export declare const introspectionMembers: readonly ["expression", "description", "json", "toJSON", "toJsonSchema", "~standard.jsonSchema"];
|
|
14
14
|
export type FoldedMember = Exclude<IntrospectionMember, "~standard.jsonSchema">;
|
|
15
|
-
export declare const defaultMembers: readonly ["assert", "meta", "~standard", "methods"];
|
|
15
|
+
export declare const defaultMembers: readonly ["assert", "meta", "~standard", "methods", "withContext"];
|
|
16
16
|
export type ValidatorMember = (typeof defaultMembers)[number] | IntrospectionMember;
|
|
17
17
|
export type ValidatorMembers = {
|
|
18
18
|
[member in ValidatorMember]?: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BaseNode, type NodeCompiler, type NodeId } from "
|
|
1
|
+
import { type BaseNode, type NodeCompiler, type NodeId } from "../_internal/schema/index.js";
|
|
2
2
|
export declare const combines: (node: BaseNode) => boolean;
|
|
3
3
|
export interface CombinatorCompiler extends NodeCompiler {
|
|
4
4
|
readonly link: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BaseNode, type BaseRoot, type nodeOfKind, type RootUnit, type UnionNode } from "
|
|
1
|
+
import { type BaseNode, type BaseRoot, type nodeOfKind, type RootUnit, type UnionNode } from "../_internal/schema/index.js";
|
|
2
2
|
import { type IssueContext } from "./sites.ts";
|
|
3
3
|
import { runtimeKeyOf } from "./values.ts";
|
|
4
4
|
export declare const discriminantContextOf: (node: UnionNode) => IssueContext;
|
package/out/standalone/keys.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BaseNode, type BaseRoot, type BaseScope } from "
|
|
1
|
+
import { type BaseNode, type BaseRoot, type BaseScope } from "../_internal/schema/index.js";
|
|
2
2
|
import { InternalTypedFn } from "../fn.ts";
|
|
3
3
|
import type { Foldable } from "./baking.ts";
|
|
4
4
|
import { type CollectedDefault } from "./units.ts";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type ArkErrorCode, type BaseNode, type BaseRoot, type RootUnit } from "
|
|
2
|
-
import { type FailureSite, type SiteContext, type UnionSite } from "
|
|
3
|
-
import { type Fn } from "
|
|
1
|
+
import { type ArkEnv, type ArkErrorCode, type BaseNode, type BaseRoot, type RootUnit } from "../_internal/schema/index.js";
|
|
2
|
+
import { type FailureSite, type SiteContext, type UnionSite } from "../_internal/schema/internal.js";
|
|
3
|
+
import { type Fn } from "../_internal/util/index.js";
|
|
4
4
|
import type { IssueFeatures } from "./baking.ts";
|
|
5
5
|
declare const describingKeys: readonly ["expected", "actual", "message"];
|
|
6
6
|
export declare const assertDescribed: (root: BaseRoot) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BaseNode, type BaseRoot, type IntersectionNode, type Optional, type RootUnit, type Sequence, type UnitMember } from "
|
|
1
|
+
import { type BaseNode, type BaseRoot, type IntersectionNode, type Optional, type RootUnit, type Sequence, type UnitMember } from "../_internal/schema/index.js";
|
|
2
2
|
import { type Baking, type IssueFeatures } from "./baking.ts";
|
|
3
3
|
import { type HoleCells } from "./values.ts";
|
|
4
4
|
export interface Written {
|
package/out/type.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ArkErrors, BaseRoot, type BaseParseOptions, type Morph, type NodeSelector, type RootSchema, type TypeMeta } from "
|
|
2
|
-
import { Callable, Hkt, type Constructor, type array, type conform } from "
|
|
1
|
+
import { ArkErrors, BaseRoot, type BaseParseOptions, type Morph, type NodeSelector, type Predicate, type RootSchema, type TypeMeta } from "./_internal/schema/index.js";
|
|
2
|
+
import { Callable, Hkt, type Constructor, type array, type conform } from "./_internal/util/index.js";
|
|
3
3
|
import type { distill } from "./attributes.ts";
|
|
4
4
|
import type { DeclarationParser } from "./declare.ts";
|
|
5
5
|
import type { FnParser } from "./fn.ts";
|
|
@@ -7,8 +7,8 @@ import type { Generic, GenericParser, ParameterString, baseGenericConstraints, p
|
|
|
7
7
|
import type { Ark, keywords, type } from "./keywords/keywords.ts";
|
|
8
8
|
import type { MatchParser } from "./match.ts";
|
|
9
9
|
import type { NaryIntersectionParser, NaryMergeParser, NaryPipeParser, NaryUnionParser } from "./nary.ts";
|
|
10
|
-
import type { validateDefinition } from "./parser/definition.ts";
|
|
11
|
-
import type { ArgTwoOperator, IndexZeroOperator, TupleInfixOperator
|
|
10
|
+
import type { inferDefinition, validateDefinition } from "./parser/definition.ts";
|
|
11
|
+
import type { ArgTwoOperator, IndexZeroOperator, TupleInfixOperator } from "./parser/tupleExpressions.ts";
|
|
12
12
|
import { type bindThis, type InternalScope, type ModuleParser, type Scope, type ScopeParser } from "./scope.ts";
|
|
13
13
|
import type { BaseType } from "./variants/base.ts";
|
|
14
14
|
import type { instantiateType } from "./variants/instantiate.ts";
|
|
@@ -37,8 +37,8 @@ import type { instantiateType } from "./variants/instantiate.ts";
|
|
|
37
37
|
export interface ValidatedArgs<in out zero, in out one, in out rest extends array, in out $> {
|
|
38
38
|
params: zero extends ParameterString ? validateParameterString<zero, $> : never;
|
|
39
39
|
body: zero extends ParameterString ? validateDefinition<one, $, baseGenericConstraints<parseValidGenericParams<zero, $>>> : never;
|
|
40
|
-
predicate:
|
|
41
|
-
morph: Morph<distill.Out<
|
|
40
|
+
predicate: Predicate<distill.Out<inferDefinition<zero, $>>>;
|
|
41
|
+
morph: Morph<distill.Out<inferDefinition<zero, $>>, unknown>;
|
|
42
42
|
operand: validateDefinition<rest[0], $, bindThis<rest[0]>>;
|
|
43
43
|
predicateRest: [
|
|
44
44
|
ValidatedArgs<zero, one, rest, $>[zero extends unknown ? "predicate" : never]
|
package/out/util.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./_internal/util/index.js";
|
package/out/util.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
export { brand, inferred, narrow } from "./chunk-4NZCLVBD.js";
|
|
2
|
+
export { Hkt, Scanner, writeUnclosedGroupMessage, writeUnmatchedGroupCloseMessage } from "./chunk-BDJVONP7.js";
|
|
3
|
+
export { WeakCache, defineLazily, holdsWeakly, lazily } from "./chunk-UJJGG4VQ.js";
|
|
4
|
+
export { ipv4Matcher, ipv6Matcher, isIpv4, isIpv6, isIso8601, isUuid, iso8601Matcher, uuidMatcher } from "./chunk-US6BWOGJ.js";
|
|
5
|
+
export { Backslash, alphabet, anchoredSource, capitalize, deanchoredRegex, deanchoredSource, editsBetween, emojiToUnicode, hashOf, uncapitalize, whitespaceChars } from "./chunk-TACLEIDM.js";
|
|
6
|
+
export { arkUtilVersion, initialRegistryContents, nameOf, register, registeredNameOf, registry } from "./chunk-ZRYEHGSG.js";
|
|
7
|
+
export { isolate, listPattern } from "./chunk-3SH2BQ4T.js";
|
|
8
|
+
import { NoopBase, ancestorsOf, defineProperties, getBuiltinNameOfConstructor, hasDomain, includes, isArray, noSuggest, timeOf } from "./chunk-3HZC67MT.js";
|
|
9
|
+
export { Callable, CastableBase, DynamicBase, DynamicFunction, FileConstructor, InnerDynamicBase, InternalArktypeError, ParseError, ZeroWidthSpace, append, appendStringifiedKey, appendUnique, arityOf, arkKind, arkKindOf, arrayEquals, baseNameOf, builtinConstructors, cached, conflatenate, conflatenateAll, constructorExtends, constructorNameOf, dateGetTime, defineValue, describeCollapsibleDate, domainDescriptions, domainOf, ecmascriptConstructors, ecmascriptDescriptions, entriesOf, enumValues, envHasCsp, expressionOf, flatMorph, fromEntries, functionNameOf, getDuplicatesOf, getPath, groupBy, hasDefinedKey, hasKey, hasObjectKind, hasOwn, integerLikeMatcher, intersectUniqueLists, invert, isDate, isDateObject, isDigitCode, isDotAccessible, isEmptyObject, isInstanceOf, isKeyOf, isNumericString, isPlainObjectOrArray, isRegExpObject, isStandardSchema, isThunk, isValidDate, isWellFormedInteger, isWellFormedNumber, join, jsTypeOfDescriptions, keysOf, liftArray, nearestFloat, nonFiniteNumbers, numberLikeMatcher, numericStringMatcher, objectKindDescriptions, objectKindOf, objectKindOrDomainOf, omit, ownEntriesOf, pathAt, pick, platformConstructors, platformDescriptions, print, printDecimal, printKind, printSymbol, printable, prototypeOf, range, readsOnlyData, returnsReports, serializePrimitive, snapshot, splitByKeys, spliterate, stringAndSymbolicEntriesOf, stringifyPath, testsOrRejects, throwError, throwInternalError, throwParseError, toJsonMethodOf, tryCatch, tryParseDate, tryParseInteger, tryParseNumber, tryParseWellFormedBigint, tryParseWellFormedNumber, typedArrayConstructors, typedArrayDescriptions, unset, wellFormedIntegerMatcher, wellFormedNumberMatcher, withAlphabetizedKeys, writeInvalidDateMessage, writeMalformedNumericLiteralMessage } from "./chunk-3HZC67MT.js";
|
|
10
|
+
import "./chunk-I2KLQ2HA.js";
|
|
11
|
+
|
|
12
|
+
// ../util/out/clone.js
|
|
13
|
+
var shallowClone = (input) => _clone(input, null);
|
|
14
|
+
var deepClone = (input) => _clone(input, /* @__PURE__ */ new Map());
|
|
15
|
+
var _clone = (input, seen) => {
|
|
16
|
+
if (typeof input !== "object" || input === null)
|
|
17
|
+
return input;
|
|
18
|
+
if (seen?.has(input))
|
|
19
|
+
return seen.get(input);
|
|
20
|
+
if (input instanceof Date && getBuiltinNameOfConstructor(input.constructor) === "Date") {
|
|
21
|
+
const time = timeOf(input);
|
|
22
|
+
if (time !== void 0)
|
|
23
|
+
return new Date(time);
|
|
24
|
+
}
|
|
25
|
+
const inputIsArray = isArray(input);
|
|
26
|
+
if (!inputIsArray && Object.prototype.toString.call(input) !== "[object Object]")
|
|
27
|
+
return input;
|
|
28
|
+
const cloned = inputIsArray ? input.slice() : Object.create(Object.getPrototypeOf(input));
|
|
29
|
+
const propertyDescriptors = Object.getOwnPropertyDescriptors(input);
|
|
30
|
+
if (seen) {
|
|
31
|
+
seen.set(input, cloned);
|
|
32
|
+
for (const k of Reflect.ownKeys(propertyDescriptors)) {
|
|
33
|
+
const desc = propertyDescriptors[k];
|
|
34
|
+
if ("get" in desc || "set" in desc)
|
|
35
|
+
continue;
|
|
36
|
+
desc.value = _clone(desc.value, seen);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
Object.defineProperties(cloned, propertyDescriptors);
|
|
40
|
+
return cloned;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// ../util/out/isomorphic.js
|
|
44
|
+
var fileName = () => {
|
|
45
|
+
try {
|
|
46
|
+
const error = new Error();
|
|
47
|
+
const stackLine = error.stack?.split("\n")[2]?.trim() || "";
|
|
48
|
+
const filePath = stackLine.match(/\(?(.+?)(?::\d+:\d+)?\)?$/)?.[1] || "unknown";
|
|
49
|
+
return filePath.replace(/^file:\/\//, "");
|
|
50
|
+
} catch {
|
|
51
|
+
return "unknown";
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var env = /* @__PURE__ */ (() => globalThis.process?.env ?? {})();
|
|
55
|
+
var isomorphic = {
|
|
56
|
+
fileName,
|
|
57
|
+
env
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// ../util/out/traits.js
|
|
61
|
+
var implementedTraits = /* @__PURE__ */ noSuggest("implementedTraits");
|
|
62
|
+
var hasTrait = (traitClass) => (o) => {
|
|
63
|
+
if (!hasDomain(o, "object"))
|
|
64
|
+
return false;
|
|
65
|
+
if (implementedTraits in o.constructor && o.constructor[implementedTraits].includes(traitClass))
|
|
66
|
+
return true;
|
|
67
|
+
return ancestorsOf(o).includes(traitClass);
|
|
68
|
+
};
|
|
69
|
+
var Trait = class extends NoopBase {
|
|
70
|
+
static get [Symbol.hasInstance]() {
|
|
71
|
+
return hasTrait(this);
|
|
72
|
+
}
|
|
73
|
+
traitsOf() {
|
|
74
|
+
return implementedTraits in this.constructor ? this.constructor[implementedTraits] : [];
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
var collectPrototypeDescriptors = (trait) => {
|
|
78
|
+
let proto = trait.prototype;
|
|
79
|
+
let result = {};
|
|
80
|
+
do {
|
|
81
|
+
result = Object.assign(Object.getOwnPropertyDescriptors(proto), result);
|
|
82
|
+
proto = Object.getPrototypeOf(proto);
|
|
83
|
+
} while (proto !== Object.prototype && proto !== null);
|
|
84
|
+
return result;
|
|
85
|
+
};
|
|
86
|
+
var compose = ((...traits) => {
|
|
87
|
+
const base = function(...args) {
|
|
88
|
+
for (const trait of traits) {
|
|
89
|
+
const instance = Reflect.construct(trait, args, this.constructor);
|
|
90
|
+
Object.assign(this, instance);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
const flatImplementedTraits = [];
|
|
94
|
+
for (const trait of traits) {
|
|
95
|
+
Object.assign(base, trait);
|
|
96
|
+
Object.defineProperties(base.prototype, collectPrototypeDescriptors(trait));
|
|
97
|
+
if (implementedTraits in trait) {
|
|
98
|
+
for (const innerTrait of trait[implementedTraits]) {
|
|
99
|
+
if (!flatImplementedTraits.includes(innerTrait))
|
|
100
|
+
flatImplementedTraits.push(innerTrait);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (!flatImplementedTraits.includes(trait))
|
|
104
|
+
flatImplementedTraits.push(trait);
|
|
105
|
+
}
|
|
106
|
+
Object.defineProperty(base, implementedTraits, {
|
|
107
|
+
value: flatImplementedTraits,
|
|
108
|
+
enumerable: false
|
|
109
|
+
});
|
|
110
|
+
return base;
|
|
111
|
+
});
|
|
112
|
+
var implement = (...args) => {
|
|
113
|
+
if (args[args.length - 1] instanceof Trait)
|
|
114
|
+
return compose(...args);
|
|
115
|
+
const implementation = args[args.length - 1];
|
|
116
|
+
const base = compose(...args.slice(0, -1));
|
|
117
|
+
Object.defineProperties(base.prototype, Object.getOwnPropertyDescriptors(implementation));
|
|
118
|
+
return base;
|
|
119
|
+
};
|
|
120
|
+
export {
|
|
121
|
+
NoopBase,
|
|
122
|
+
Trait,
|
|
123
|
+
ancestorsOf,
|
|
124
|
+
compose,
|
|
125
|
+
deepClone,
|
|
126
|
+
defineProperties,
|
|
127
|
+
getBuiltinNameOfConstructor,
|
|
128
|
+
hasDomain,
|
|
129
|
+
hasTrait,
|
|
130
|
+
implement,
|
|
131
|
+
includes,
|
|
132
|
+
isArray,
|
|
133
|
+
isomorphic,
|
|
134
|
+
noSuggest,
|
|
135
|
+
shallowClone,
|
|
136
|
+
timeOf
|
|
137
|
+
};
|
package/out/variants/array.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { ExactLength, ExclusiveNumericRangeSchema, InclusiveNumericRangeSchema } from "
|
|
1
|
+
import type { MessageConfig, ExactLength, ExclusiveNumericRangeSchema, InclusiveNumericRangeSchema } from "../_internal/schema/index.js";
|
|
2
2
|
import type { ObjectType } from "./object.ts";
|
|
3
3
|
interface Type<
|
|
4
4
|
/** @ts-ignore cast variance */
|
|
5
5
|
out t extends readonly unknown[] = readonly unknown[], in out $ = {}> extends ObjectType<t, $> {
|
|
6
|
-
atLeastLength(schema: InclusiveNumericRangeSchema): this;
|
|
7
|
-
atMostLength(schema: InclusiveNumericRangeSchema): this;
|
|
8
|
-
moreThanLength(schema: ExclusiveNumericRangeSchema): this;
|
|
9
|
-
lessThanLength(schema: ExclusiveNumericRangeSchema): this;
|
|
10
|
-
exactlyLength(schema: ExactLength.Schema): this;
|
|
6
|
+
atLeastLength(schema: InclusiveNumericRangeSchema, message?: MessageConfig<"minLength">): this;
|
|
7
|
+
atMostLength(schema: InclusiveNumericRangeSchema, message?: MessageConfig<"maxLength">): this;
|
|
8
|
+
moreThanLength(schema: ExclusiveNumericRangeSchema, message?: MessageConfig<"minLength">): this;
|
|
9
|
+
lessThanLength(schema: ExclusiveNumericRangeSchema, message?: MessageConfig<"maxLength">): this;
|
|
10
|
+
exactlyLength(schema: ExactLength.Schema, message?: MessageConfig<"exactLength">): this;
|
|
11
11
|
}
|
|
12
12
|
export type { Type as ArrayType };
|
package/out/variants/base.d.ts
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
|
-
import type { BaseNode, BaseRoot, Disjoint, JsonSchema, NodeSelector, Predicate, StandardSchemaV1, ToJsonSchema, TypeMeta, UndeclaredKeyBehavior } from "
|
|
2
|
-
import type { anyOrNever, array, Callable, ErrorMessage, inferred, JsonStructure, unset } from "
|
|
3
|
-
import type { defaultFor, distill, inferIntersection, inferPipe, InferredMorph, Out, To } from "../attributes.ts";
|
|
1
|
+
import type { ArkEnv, BaseNode, BaseRoot, Disjoint, JsonSchema, MessageConfig, NodeSelector, Predicate, StandardSchemaV1, ToJsonSchema, TypeMeta, UndeclaredKeyBehavior } from "../_internal/schema/index.js";
|
|
2
|
+
import type { anyOrNever, array, Callable, ErrorMessage, inferred, JsonStructure, unset } from "../_internal/util/index.js";
|
|
3
|
+
import type { defaultFor, distill, distillEncoded, inferIntersection, inferPipe, InferredMorph, Out, To } from "../attributes.ts";
|
|
4
4
|
import type { ArkAmbient } from "../config.ts";
|
|
5
5
|
import type { type } from "../keywords/keywords.ts";
|
|
6
6
|
import type { NaryPipeParser } from "../nary.ts";
|
|
7
|
+
import type { inferDefinition } from "../parser/definition.ts";
|
|
7
8
|
import type { Scope } from "../scope.ts";
|
|
8
9
|
import type { ArrayType } from "./array.ts";
|
|
9
10
|
import type { instantiateType } from "./instantiate.ts";
|
|
11
|
+
/** a Type's validation, each run in the context `withContext` bound */
|
|
12
|
+
export interface BoundType<In = unknown, Out = unknown> extends Callable<(data: unknown) => Out | ArkEnv.onFail> {
|
|
13
|
+
/** validate and return transformed data or throw */
|
|
14
|
+
assert: (data: unknown) => Out;
|
|
15
|
+
/** check input without applying morphs */
|
|
16
|
+
allows: (data: unknown) => data is In;
|
|
17
|
+
/** the Type's [StandardSchema](https://github.com/standard-schema/standard-schema) properties, validating in context */
|
|
18
|
+
"~standard": StandardSchemaV1.ArkTypeProps<In, Out>;
|
|
19
|
+
}
|
|
10
20
|
/** @ts-ignore cast variance */
|
|
11
21
|
export interface Inferred<out t = unknown, in out $ = {}> {
|
|
12
22
|
internal: BaseRoot;
|
|
@@ -189,6 +199,25 @@ export interface Inferred<out t = unknown, in out $ = {}> {
|
|
|
189
199
|
* const badPattern = AToZ("albatross")
|
|
190
200
|
*/
|
|
191
201
|
describe: NodeSelector.SelectableFn<string, this>;
|
|
202
|
+
/**
|
|
203
|
+
* #### set the sentence an error says
|
|
204
|
+
*
|
|
205
|
+
* 🔗 equivalent to `.configure({ message })` (see {@link configure})
|
|
206
|
+
* ✅ a missing key says it too, as Zod's `required_error`
|
|
207
|
+
* ✅ a selector like `"minLength"` scopes it to that check, as Zod's `.min(1, "Name is required")`
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* const Name = type("string >= 1").message("Name is required")
|
|
211
|
+
* // ArkErrors: Name is required
|
|
212
|
+
* const empty = Name("")
|
|
213
|
+
*
|
|
214
|
+
* const Password = type("string >= 8").message("Use 8 or more characters", "minLength")
|
|
215
|
+
* // ArkErrors: Use 8 or more characters
|
|
216
|
+
* const short = Password("abc")
|
|
217
|
+
* // ArkErrors: must be a string
|
|
218
|
+
* const nonString = Password(5)
|
|
219
|
+
*/
|
|
220
|
+
message: NodeSelector.SelectableFn<MessageConfig, this>;
|
|
192
221
|
/**
|
|
193
222
|
* #### apply undeclared key behavior
|
|
194
223
|
*
|
|
@@ -214,6 +243,28 @@ export interface Inferred<out t = unknown, in out $ = {}> {
|
|
|
214
243
|
* const data = T.from({ foo: 5 });
|
|
215
244
|
*/
|
|
216
245
|
from(literal: this["inferIn"]): this["infer"];
|
|
246
|
+
/**
|
|
247
|
+
* #### bind a context its narrows and morphs read as `ctx.context`
|
|
248
|
+
*
|
|
249
|
+
* ✅ creates no Type, so a static, precompilable Type can validate with what a caller has, e.g. a form's saved values
|
|
250
|
+
* ✅ is a Standard Schema, as form libraries take one
|
|
251
|
+
* ✅ typed as declared on `ArkEnv`
|
|
252
|
+
* 🔗 `~standard.validate(data, { libraryOptions: { context } })` passes a context without binding one
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* declare module "arktype" {
|
|
256
|
+
* interface ArkEnv {
|
|
257
|
+
* context(): { saved?: string }
|
|
258
|
+
* }
|
|
259
|
+
* }
|
|
260
|
+
*
|
|
261
|
+
* const Street = type("string").narrow(
|
|
262
|
+
* (s, ctx) => s === ctx.context?.saved || s.length > 3 || ctx.mustBe("a full street")
|
|
263
|
+
* )
|
|
264
|
+
* // the street as saved passes, though it's short
|
|
265
|
+
* const out = Street.withContext({ saved: "Elm" })("Elm")
|
|
266
|
+
*/
|
|
267
|
+
withContext(context: ArkEnv.context): BoundType<this["inferIn"] extends infer _ ? _ : never, this["infer"]>;
|
|
217
268
|
/**
|
|
218
269
|
* #### deeply extract inputs
|
|
219
270
|
*
|
|
@@ -372,7 +423,7 @@ export interface Inferred<out t = unknown, in out $ = {}> {
|
|
|
372
423
|
* // parse a string and validate the result as a user
|
|
373
424
|
* const parseUser = type("string").pipe(s => JSON.parse(s)).to({ name: "string" })
|
|
374
425
|
*/
|
|
375
|
-
to<const def, r = instantiateType<inferPipe<t,
|
|
426
|
+
to<const def, r = instantiateType<inferPipe<t, inferDefinition<def, $>>, $>>(def: type.validate<def, $>): r extends infer _ ? _ : never;
|
|
376
427
|
/**
|
|
377
428
|
* #### query internal node references
|
|
378
429
|
*
|
|
@@ -405,7 +456,7 @@ interface Type<out t = unknown, in out $ = {}> extends Callable<(data: unknown)
|
|
|
405
456
|
* // ParseError: Intersection at foo of number and string results in an unsatisfiable type
|
|
406
457
|
* const Bad = type({ foo: "number" }).and({ foo: "string" })
|
|
407
458
|
*/
|
|
408
|
-
and<const def, r = instantiateType<inferIntersection<t,
|
|
459
|
+
and<const def, r = instantiateType<inferIntersection<t, inferDefinition<def, $>>, $>>(def: type.validate<def, $>): r extends infer _ ? _ : never;
|
|
409
460
|
/**
|
|
410
461
|
* #### union with the parsed Type
|
|
411
462
|
*
|
|
@@ -415,7 +466,7 @@ interface Type<out t = unknown, in out $ = {}> extends Callable<(data: unknown)
|
|
|
415
466
|
* // Type<string | { box: string }>
|
|
416
467
|
* const T = type("string").or({ box: "string" })
|
|
417
468
|
*/
|
|
418
|
-
or<const def, r = instantiateType<t |
|
|
469
|
+
or<const def, r = instantiateType<t | inferDefinition<def, $>, $>>(def: type.validate<def, $>): r extends infer _ ? _ : never;
|
|
419
470
|
/**
|
|
420
471
|
* #### intersect the parsed Type, returning an introspectable {@link Disjoint} if the result is unsatisfiable
|
|
421
472
|
*
|
|
@@ -428,7 +479,7 @@ interface Type<out t = unknown, in out $ = {}> extends Callable<(data: unknown)
|
|
|
428
479
|
* // logs "Intersection of > 10 and < 5 results in an unsatisfiable type"
|
|
429
480
|
* if (!(Bad instanceof Type)) console.log(Bad.summary)
|
|
430
481
|
*/
|
|
431
|
-
intersect<const def, r = instantiateType<inferIntersection<t,
|
|
482
|
+
intersect<const def, r = instantiateType<inferIntersection<t, inferDefinition<def, $>>, $>>(def: type.validate<def, $>): r extends infer _ ? _ | Disjoint : never;
|
|
432
483
|
/**
|
|
433
484
|
* #### check if the parsed Type's constraints are identical
|
|
434
485
|
*
|
|
@@ -500,7 +551,7 @@ interface Type<out t = unknown, in out $ = {}> extends Callable<(data: unknown)
|
|
|
500
551
|
* // Type<true | 0 | 2>
|
|
501
552
|
* const T = type("boolean | 0 | 'one' | 2 | bigint").extract("number | 0n | true")
|
|
502
553
|
*/
|
|
503
|
-
extract<const def, r = instantiateType<t extends
|
|
554
|
+
extract<const def, r = instantiateType<t extends inferDefinition<def, $> ? t : never, $>>(r: type.validate<def, $>): r extends infer _ extends r ? _ : never;
|
|
504
555
|
/**
|
|
505
556
|
* #### exclude branches {@link extend}ing the parsed Type
|
|
506
557
|
*
|
|
@@ -509,7 +560,7 @@ interface Type<out t = unknown, in out $ = {}> extends Callable<(data: unknown)
|
|
|
509
560
|
* // Type<false | 'one' | bigint>
|
|
510
561
|
* const T = type("boolean | 0 | 'one' | 2 | bigint").exclude("number | 0n | true")
|
|
511
562
|
*/
|
|
512
|
-
exclude<const def, r = instantiateType<t extends
|
|
563
|
+
exclude<const def, r = instantiateType<t extends inferDefinition<def, $> ? never : t, $>>(r: type.validate<def, $>): r extends infer _ ? _ : never;
|
|
513
564
|
/**
|
|
514
565
|
* @experimental
|
|
515
566
|
* Map and optionally reduce branches of a union. Types that are not unions
|
|
@@ -546,7 +597,7 @@ interface Type<out t = unknown, in out $ = {}> extends Callable<(data: unknown)
|
|
|
546
597
|
Symbol: never;
|
|
547
598
|
}
|
|
548
599
|
type inferEncoder<t> = {
|
|
549
|
-
encode(In: distill.Out<t>): To<
|
|
600
|
+
encode(In: distill.Out<t>): To<distillEncoded<t>>;
|
|
550
601
|
}["encode"];
|
|
551
602
|
export interface ChainedPipeParser<$, t> extends NaryPipeParser<$, t> {
|
|
552
603
|
try: NaryPipeParser<$, t>;
|
package/out/variants/date.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ExclusiveDateRangeSchema, InclusiveDateRangeSchema } from "
|
|
1
|
+
import type { MessageConfig, ExclusiveDateRangeSchema, InclusiveDateRangeSchema } from "../_internal/schema/index.js";
|
|
2
2
|
import type { ObjectType } from "./object.ts";
|
|
3
3
|
/** @ts-ignore cast variance */
|
|
4
4
|
interface Type<out t extends globalThis.Date = globalThis.Date, in out $ = {}> extends ObjectType<t, $> {
|
|
5
|
-
atOrAfter(schema: InclusiveDateRangeSchema): this;
|
|
6
|
-
atOrBefore(schema: InclusiveDateRangeSchema): this;
|
|
7
|
-
laterThan(schema: ExclusiveDateRangeSchema): this;
|
|
8
|
-
earlierThan(schema: ExclusiveDateRangeSchema): this;
|
|
5
|
+
atOrAfter(schema: InclusiveDateRangeSchema, message?: MessageConfig<"after">): this;
|
|
6
|
+
atOrBefore(schema: InclusiveDateRangeSchema, message?: MessageConfig<"before">): this;
|
|
7
|
+
laterThan(schema: ExclusiveDateRangeSchema, message?: MessageConfig<"after">): this;
|
|
8
|
+
earlierThan(schema: ExclusiveDateRangeSchema, message?: MessageConfig<"before">): this;
|
|
9
9
|
}
|
|
10
10
|
export type { Type as DateType };
|
package/out/variants/number.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { Divisor, ExclusiveNumericRangeSchema, InclusiveNumericRangeSchema } from "
|
|
1
|
+
import type { MessageConfig, Divisor, ExclusiveNumericRangeSchema, InclusiveNumericRangeSchema } from "../_internal/schema/index.js";
|
|
2
2
|
import type { BaseType } from "./base.ts";
|
|
3
3
|
/** @ts-ignore cast variance */
|
|
4
4
|
interface Type<out t extends number = number, in out $ = {}> extends BaseType<t, $> {
|
|
5
|
-
divisibleBy(schema: Divisor.Schema): this;
|
|
6
|
-
atLeast(schema: InclusiveNumericRangeSchema): this;
|
|
7
|
-
atMost(schema: InclusiveNumericRangeSchema): this;
|
|
8
|
-
moreThan(schema: ExclusiveNumericRangeSchema): this;
|
|
9
|
-
lessThan(schema: ExclusiveNumericRangeSchema): this;
|
|
5
|
+
divisibleBy(schema: Divisor.Schema, message?: MessageConfig<"divisor">): this;
|
|
6
|
+
atLeast(schema: InclusiveNumericRangeSchema, message?: MessageConfig<"min">): this;
|
|
7
|
+
atMost(schema: InclusiveNumericRangeSchema, message?: MessageConfig<"max">): this;
|
|
8
|
+
moreThan(schema: ExclusiveNumericRangeSchema, message?: MessageConfig<"min">): this;
|
|
9
|
+
lessThan(schema: ExclusiveNumericRangeSchema, message?: MessageConfig<"max">): this;
|
|
10
10
|
}
|
|
11
11
|
export type { Type as NumberType };
|