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,8 @@
|
|
|
1
|
+
import type { MutatesInput } from "../config.ts";
|
|
2
|
+
import type { BaseRoot } from "../roots/root.ts";
|
|
3
|
+
import type { InPlaceTransforms } from "./transform.ts";
|
|
4
|
+
/** arktype's morphs passed ctx that read only their input through it */
|
|
5
|
+
export declare const inputOnlyMorphs: WeakSet<Function>;
|
|
6
|
+
/** whether a valid input's transforms write into it */
|
|
7
|
+
export declare const writesInPlace: (root: BaseRoot, mutatesInput: MutatesInput | undefined) => boolean;
|
|
8
|
+
export declare const inPlaceTransforms: InPlaceTransforms;
|
|
@@ -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,261 @@
|
|
|
1
|
+
import { type array } from "../../util/index.js";
|
|
2
|
+
import type { ArkErrorCode } from "./errors.ts";
|
|
3
|
+
import type { StandardSchemaV1 } from "./standardSchema.ts";
|
|
4
|
+
/**
|
|
5
|
+
* A failed check of a standalone validator: its code, the path and data it
|
|
6
|
+
* failed at, and what its node describes.
|
|
7
|
+
*/
|
|
8
|
+
export interface ArkIssue {
|
|
9
|
+
code: ArkErrorCode;
|
|
10
|
+
path: PropertyKey[];
|
|
11
|
+
data: unknown;
|
|
12
|
+
expected: string | undefined;
|
|
13
|
+
/** what failed, without the path it failed at, which a summary writes */
|
|
14
|
+
message?: string | undefined;
|
|
15
|
+
/** a union's: each branch's first issue */
|
|
16
|
+
errors?: readonly ArkIssue[];
|
|
17
|
+
/** @internal a union's line of a summary, naming its errors' paths whole */
|
|
18
|
+
readonly _l?: string | undefined;
|
|
19
|
+
/** @internal 2 where its message is one configured for its code: see codedIssue */
|
|
20
|
+
readonly _c?: 2 | undefined;
|
|
21
|
+
/** @internal a union's, its text written again at a path before its own */
|
|
22
|
+
_m?(prefix: array<PropertyKey>): ArkIssue;
|
|
23
|
+
}
|
|
24
|
+
type WrittenIssue = ArkIssue & {
|
|
25
|
+
message: string;
|
|
26
|
+
};
|
|
27
|
+
/** what a site reports: its code and description */
|
|
28
|
+
export interface SiteContext {
|
|
29
|
+
code: ArkErrorCode;
|
|
30
|
+
description?: string | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* the message configured for the site, which names no path. A summary sets
|
|
33
|
+
* it apart from its path with a colon unless it begins as what's written
|
|
34
|
+
* from what the site expects would: see isCustomIssue
|
|
35
|
+
*/
|
|
36
|
+
x?: string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* writes other text configured for the site onto its issue, or notes that
|
|
39
|
+
* its message is its code's, as codedIssue does
|
|
40
|
+
*/
|
|
41
|
+
text?: ((issue: ArkIssue) => unknown) | undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* a check's site: its node's context, or a key's. Every site is written into
|
|
45
|
+
* the bundle and a minifier keeps property names, so a key's are short
|
|
46
|
+
*/
|
|
47
|
+
export interface FailureSite extends Partial<SiteContext> {
|
|
48
|
+
/** the context its value fails with */
|
|
49
|
+
v?: SiteContext;
|
|
50
|
+
/** the context the missing key fails with */
|
|
51
|
+
m?: SiteContext;
|
|
52
|
+
/**
|
|
53
|
+
* @internal the functions arktype's own traversal builds v's and m's errors
|
|
54
|
+
* with, kept on the site once found. A standalone validator has none
|
|
55
|
+
*/
|
|
56
|
+
vb?: ((...args: never[]) => unknown) | undefined;
|
|
57
|
+
mb?: ((...args: never[]) => unknown) | undefined;
|
|
58
|
+
}
|
|
59
|
+
export interface UnionSite {
|
|
60
|
+
meta?: object;
|
|
61
|
+
description: string;
|
|
62
|
+
}
|
|
63
|
+
export type CompactApply = (data: unknown, ctx: FailureContext) => boolean;
|
|
64
|
+
/**
|
|
65
|
+
* what a missing key fails with, after its code, which is always required's:
|
|
66
|
+
* what it expects, the message configured for it, and what writes other text
|
|
67
|
+
* onto its issue. Passed to _k after the key, each as _e takes it
|
|
68
|
+
*/
|
|
69
|
+
export type MissingText = [
|
|
70
|
+
expected?: string | undefined,
|
|
71
|
+
message?: string | undefined,
|
|
72
|
+
text?: SiteContext["text"]
|
|
73
|
+
];
|
|
74
|
+
/**
|
|
75
|
+
* where a validator's compact Apply reports failures; each returns whether to
|
|
76
|
+
* stop. A minifier keeps property names, and compiled code calls these at
|
|
77
|
+
* each failure, so they're named short. _e fails data at the path the context
|
|
78
|
+
* is at, with a code, what's expected and the message configured, each a
|
|
79
|
+
* literal where it fails: a site there is three strings, where an object
|
|
80
|
+
* holding them is a call to build it at every failure and the function it
|
|
81
|
+
* calls in every bundle. _k applies data's value at a key, failing the key
|
|
82
|
+
* as required where it's missing and passed what a missing key says, even
|
|
83
|
+
* only `undefined`: an optional key is passed nothing
|
|
84
|
+
*/
|
|
85
|
+
export interface FailureContext {
|
|
86
|
+
_e(data: unknown, code: ArkErrorCode, expected?: string, message?: string, text?: SiteContext["text"]): boolean | undefined;
|
|
87
|
+
_k(apply: CompactApply, data: unknown, key: PropertyKey, ...missing: MissingText): boolean | undefined;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* where arktype's own compiled code reports failures: _at fails a site, whose
|
|
91
|
+
* contexts its traversal builds errors from, at a key where it's passed one,
|
|
92
|
+
* and _in applies data's value at a key, passed the site a missing key fails
|
|
93
|
+
* and the value too, read where its key is a constant. Named apart from a
|
|
94
|
+
* validator's, so a traversal can take both
|
|
95
|
+
*/
|
|
96
|
+
export interface SiteFailureContext {
|
|
97
|
+
_at(site: FailureSite, data: unknown, key?: PropertyKey): boolean | undefined;
|
|
98
|
+
_in(apply: CompactApply, data: unknown, key: PropertyKey, missing?: FailureSite, value?: unknown): boolean | undefined;
|
|
99
|
+
}
|
|
100
|
+
declare class ReadIssues implements StandardSchemaV1.FailureResult, FailureContext {
|
|
101
|
+
/** @internal each issue in the order it was added */
|
|
102
|
+
_: ArkIssue[];
|
|
103
|
+
/** @internal the path a fused traversal is at */
|
|
104
|
+
_p: PropertyKey[];
|
|
105
|
+
constructor();
|
|
106
|
+
/**
|
|
107
|
+
* The number of issues.
|
|
108
|
+
*/
|
|
109
|
+
get count(): number;
|
|
110
|
+
/**
|
|
111
|
+
* Each issue, its message written when they are first read.
|
|
112
|
+
*/
|
|
113
|
+
get issues(): readonly WrittenIssue[];
|
|
114
|
+
/**
|
|
115
|
+
* @internal fails data at the path it's at. Every bundle holds this, so it
|
|
116
|
+
* takes neither a key nor a site: a validator whose code fails nothing at
|
|
117
|
+
* a key would hold what enters one for nothing, which failsKey does
|
|
118
|
+
* through _k, and a site is a function building it in every bundle
|
|
119
|
+
*/
|
|
120
|
+
_e(data: unknown, code: ArkErrorCode, expected?: string, message?: string, text?: SiteContext["text"]): true | undefined;
|
|
121
|
+
/** @internal */
|
|
122
|
+
_k(apply: CompactApply, data: unknown, key: PropertyKey, ...missing: MissingText): boolean | undefined;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* @internal fails a key of data: where it's missing, as required with what
|
|
126
|
+
* a missing key expects, which is what its value does unless passed, or its
|
|
127
|
+
* value, with a code and what's expected. Entered through _k, which each
|
|
128
|
+
* ctx implements for a key, so errors needn't hold any of it in their _e,
|
|
129
|
+
* and a bundler drops this from a program failing nothing at a key
|
|
130
|
+
*/
|
|
131
|
+
export declare const failsKey: (ctx: FailureContext, data: unknown, key: PropertyKey, code: ArkErrorCode, expected?: string, missing?: string | undefined) => boolean | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* @internal fails a context: a site held as an object, as one whose text a
|
|
134
|
+
* function writes is, or a checker, which is its own
|
|
135
|
+
*/
|
|
136
|
+
export declare const failsSite: (ctx: FailureContext, context: SiteContext, data: unknown) => boolean | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* @internal as failsKey, of a site held as an object: the missing key, where
|
|
139
|
+
* the site holds what one fails, or the key's value, with the site's context
|
|
140
|
+
* for it or the site itself where it's a context
|
|
141
|
+
*/
|
|
142
|
+
export declare const failsKeySite: (ctx: FailureContext, site: FailureSite, data: unknown, key: PropertyKey) => boolean | undefined;
|
|
143
|
+
/** @internal what _k is passed of a missing key's context, or nothing */
|
|
144
|
+
export declare const missingTextOf: (missing: SiteContext | undefined) => MissingText;
|
|
145
|
+
declare const Issues: IssuesClass;
|
|
146
|
+
/**
|
|
147
|
+
* @internal an errors class: built with nothing, or as a traversal is, with
|
|
148
|
+
* data and a config, and, where its build has it find its issues once read
|
|
149
|
+
* (findsOnRead), with what finds them
|
|
150
|
+
*/
|
|
151
|
+
export type IssuesClass<errors extends Issues = Issues> = new (data?: unknown, config?: unknown, apply?: CompactApply) => errors;
|
|
152
|
+
/**
|
|
153
|
+
* The errors returned by a Type on invalid input.
|
|
154
|
+
*/
|
|
155
|
+
interface Issues extends ReadIssues {
|
|
156
|
+
/**
|
|
157
|
+
* A human-readable summary of all errors.
|
|
158
|
+
*/
|
|
159
|
+
readonly summary: string;
|
|
160
|
+
/**
|
|
161
|
+
* The summary in `locale`, or as configured without one.
|
|
162
|
+
*/
|
|
163
|
+
summaryIn(locale?: unknown): string;
|
|
164
|
+
/**
|
|
165
|
+
* Throw a TraversalError based on these errors.
|
|
166
|
+
*/
|
|
167
|
+
throw(): never;
|
|
168
|
+
/**
|
|
169
|
+
* Each issue's JSON: what it says and where, without its data.
|
|
170
|
+
*/
|
|
171
|
+
toJSON(): readonly unknown[];
|
|
172
|
+
toString(): string;
|
|
173
|
+
/**
|
|
174
|
+
* Each issue, as `issues` holds them.
|
|
175
|
+
*/
|
|
176
|
+
[Symbol.iterator](): IterableIterator<this["issues"][number]>;
|
|
177
|
+
/** @internal set by a build asking for only the first issue */
|
|
178
|
+
failFast?: true;
|
|
179
|
+
/** @internal arktype's errors, which copy their contexts when merged */
|
|
180
|
+
_merge?(merged: Issues, prefix: array<PropertyKey>): void;
|
|
181
|
+
/** @internal arktype's errors, grouped by path */
|
|
182
|
+
readonly _i?: ArkIssue[];
|
|
183
|
+
}
|
|
184
|
+
/** an issue's JSON, as a standalone validator's errors write it */
|
|
185
|
+
export interface IssueJson {
|
|
186
|
+
code: ArkErrorCode;
|
|
187
|
+
path: (string | number)[];
|
|
188
|
+
expected?: string;
|
|
189
|
+
message: string;
|
|
190
|
+
errors?: IssueJson[];
|
|
191
|
+
}
|
|
192
|
+
declare namespace Issues {
|
|
193
|
+
type Handler<returns = unknown> = (errors: Issues) => returns;
|
|
194
|
+
}
|
|
195
|
+
export { Issues as ArkErrors };
|
|
196
|
+
export declare class FirstIssues extends Issues {
|
|
197
|
+
get failFast(): true;
|
|
198
|
+
_e(...failure: Parameters<Issues["_e"]>): true;
|
|
199
|
+
}
|
|
200
|
+
export declare const applyIssues: (apply: CompactApply, data: unknown, onFail: Issues.Handler | null, Ctx?: new () => Issues) => unknown;
|
|
201
|
+
export declare const issuesOf: (apply: CompactApply, data: unknown, errors: Issues) => ArkIssue[];
|
|
202
|
+
export declare const foundErrors: (apply: CompactApply, data: unknown, onFail: Issues.Handler | null, Ctx?: new () => Issues) => unknown;
|
|
203
|
+
export declare const issueAt: (path: PropertyKey[], site: FailureSite, data: unknown, key: PropertyKey | undefined) => ArkIssue;
|
|
204
|
+
export declare const throwOnDefault: Issues.Handler;
|
|
205
|
+
export declare const mergeIssues: (errors: Issues, merged: Issues, prefix: array<PropertyKey>) => void;
|
|
206
|
+
/**
|
|
207
|
+
* @internal whether an issue's message is a sentence configured or supplied
|
|
208
|
+
* for it, which a summary sets apart from its path with a colon, rather than
|
|
209
|
+
* what's written from what it expected, which follows its path. An issue holds
|
|
210
|
+
* nothing saying which: a message is a sentence of its own unless it begins as
|
|
211
|
+
* the one written from what the issue expects would, so one configured as that
|
|
212
|
+
* text, or as it with more after it, like what the value was, reads on from
|
|
213
|
+
* its path as that would. A union listing its errors wrote its own line
|
|
214
|
+
*/
|
|
215
|
+
export declare const isCustomIssue: (issue: ArkIssue) => boolean;
|
|
216
|
+
/**
|
|
217
|
+
* @internal notes that an issue's message is one configured for its code, as
|
|
218
|
+
* `configure({ required: { message } })` does for every missing key. A union
|
|
219
|
+
* says the message its branches' errors share where each was configured for
|
|
220
|
+
* its error's Type or supplied where it was raised, and lists errors saying a
|
|
221
|
+
* code's, which the text alone doesn't tell from those. Defined on the issue
|
|
222
|
+
* so it isn't enumerable, as only what its readers see is. A site whose
|
|
223
|
+
* message is its code's passes this as its `text`, so only a program that
|
|
224
|
+
* configures one holds it
|
|
225
|
+
*/
|
|
226
|
+
export declare const codedIssue: <issue extends ArkIssue>(issue: issue) => issue;
|
|
227
|
+
/**
|
|
228
|
+
* @internal a copy of an issue, noted as it was. Only a union reads the note,
|
|
229
|
+
* and only of a message that was written
|
|
230
|
+
*/
|
|
231
|
+
export declare const notedAs: (issue: ArkIssue, copy: ArkIssue) => ArkIssue;
|
|
232
|
+
/** @internal an issue at another path, saying what it did */
|
|
233
|
+
export declare const movedIssue: (issue: ArkIssue, path: PropertyKey[]) => ArkIssue;
|
|
234
|
+
/**
|
|
235
|
+
* @internal the path as arktype's stringifyPath writes it: a key that isn't
|
|
236
|
+
* an identifier is bracketed and quoted, as an index or a symbol (which has no
|
|
237
|
+
* JSON) is bracketed
|
|
238
|
+
*/
|
|
239
|
+
export declare const pathOf: (issue: {
|
|
240
|
+
readonly path: readonly PropertyKey[];
|
|
241
|
+
}) => string;
|
|
242
|
+
/**
|
|
243
|
+
* @internal an issue's line of a summary: its message after its path, one
|
|
244
|
+
* configured or supplied as a sentence (isCustomIssue) after a colon. A union
|
|
245
|
+
* listing its branches' issues names each one's path instead. Each flag is read in the
|
|
246
|
+
* one expression returned: a bundler that inlines a flag as it prints folds
|
|
247
|
+
* an expression it's in, and leaves a statement testing it, and a function
|
|
248
|
+
* returning it, as they are. A listed issue's message is set as it's created
|
|
249
|
+
*/
|
|
250
|
+
export declare const lineOf: (issue: ArkIssue) => string;
|
|
251
|
+
export declare const messageOf: (issue: {
|
|
252
|
+
readonly code?: ArkErrorCode;
|
|
253
|
+
readonly expected?: string | undefined;
|
|
254
|
+
}) => string;
|
|
255
|
+
interface ThrownIssues extends Error {
|
|
256
|
+
readonly name: "TraversalError";
|
|
257
|
+
arkErrors: Issues;
|
|
258
|
+
}
|
|
259
|
+
declare const ThrownIssues: new (errors: Issues) => ThrownIssues;
|
|
260
|
+
export { ThrownIssues as TraversalError };
|
|
261
|
+
export declare const throwIssues: (apply: CompactApply, data: unknown) => never;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { array } from "../../util/index.js";
|
|
2
|
+
import type { ArkErrorCode } from "./errors.ts";
|
|
3
|
+
import type { ArkIssue, CompactApply, FailureContext, FailureSite, MissingText, SiteContext } from "./issues.ts";
|
|
4
|
+
type WrittenIssue = ArkIssue & {
|
|
5
|
+
message: string;
|
|
6
|
+
};
|
|
7
|
+
declare class ReadIssues implements FailureContext {
|
|
8
|
+
/** @internal each issue in the order it was added */
|
|
9
|
+
_: ArkIssue[];
|
|
10
|
+
/** @internal the path a fused traversal is at */
|
|
11
|
+
_p: PropertyKey[];
|
|
12
|
+
/**
|
|
13
|
+
* The number of issues.
|
|
14
|
+
*/
|
|
15
|
+
get count(): number;
|
|
16
|
+
/**
|
|
17
|
+
* Each issue, its message written when they are first read.
|
|
18
|
+
*/
|
|
19
|
+
get issues(): readonly WrittenIssue[];
|
|
20
|
+
/** @internal takes neither a key nor a site, as issues.ts's */
|
|
21
|
+
_e(data: unknown, code: ArkErrorCode, expected?: string, message?: string, text?: SiteContext["text"]): true | undefined;
|
|
22
|
+
/** @internal */
|
|
23
|
+
_k(apply: CompactApply, data: unknown, key: PropertyKey, ...missing: MissingText): boolean | undefined;
|
|
24
|
+
}
|
|
25
|
+
export declare const failsKey: (ctx: FailureContext, data: unknown, key: PropertyKey, code: ArkErrorCode, expected?: string, missing?: string | undefined) => boolean | undefined;
|
|
26
|
+
export declare const failsSite: (ctx: FailureContext, context: SiteContext, data: unknown) => boolean | undefined;
|
|
27
|
+
export declare const failsKeySite: (ctx: FailureContext, site: FailureSite, data: unknown, key: PropertyKey) => boolean | undefined;
|
|
28
|
+
export declare const missingTextOf: (missing: SiteContext | undefined) => MissingText;
|
|
29
|
+
declare const Issues: new () => Issues;
|
|
30
|
+
interface Issues extends ReadIssues {
|
|
31
|
+
/**
|
|
32
|
+
* A human-readable summary of all errors.
|
|
33
|
+
*/
|
|
34
|
+
readonly summary: string;
|
|
35
|
+
/**
|
|
36
|
+
* The summary in `locale`, or as configured without one.
|
|
37
|
+
*/
|
|
38
|
+
summaryIn(locale?: unknown): string;
|
|
39
|
+
/**
|
|
40
|
+
* Throw a TraversalError based on these errors.
|
|
41
|
+
*/
|
|
42
|
+
throw(): never;
|
|
43
|
+
toJSON(): readonly unknown[];
|
|
44
|
+
toString(): string;
|
|
45
|
+
[Symbol.iterator](): IterableIterator<this["issues"][number]>;
|
|
46
|
+
/** @internal set by a build asking for only the first issue */
|
|
47
|
+
failFast?: true;
|
|
48
|
+
/** @internal arktype's errors, which copy their contexts when merged */
|
|
49
|
+
_merge?(merged: Issues, prefix: array<PropertyKey>): void;
|
|
50
|
+
}
|
|
51
|
+
export { Issues as ArkErrors };
|
|
52
|
+
export declare class FirstIssues extends Issues {
|
|
53
|
+
get failFast(): true;
|
|
54
|
+
_e(...failure: Parameters<Issues["_e"]>): true;
|
|
55
|
+
}
|
|
56
|
+
export declare const issueAt: (path: PropertyKey[], site: FailureSite, data: unknown, key: PropertyKey | undefined) => ArkIssue;
|
|
57
|
+
export declare const issuesOf: (apply: CompactApply, data: unknown, errors: Issues) => ArkIssue[];
|
|
58
|
+
export declare const foundErrors: (apply: CompactApply, data: unknown, onFail: ((errors: Issues) => unknown) | null, Ctx?: new () => Issues) => unknown;
|
|
59
|
+
export declare const throwIssues: (apply: CompactApply, data: unknown) => never;
|
|
60
|
+
export declare const applyIssues: (apply: CompactApply, data: unknown, onFail: ((errors: Issues) => unknown) | null, Ctx?: new () => Issues) => unknown;
|
|
61
|
+
export declare const throwOnDefault: (errors: Issues) => never;
|
|
62
|
+
export declare const mergeIssues: (errors: Issues, merged: Issues, prefix: array<PropertyKey>) => void;
|
|
63
|
+
export declare const isCustomIssue: (issue: ArkIssue) => boolean;
|
|
64
|
+
export declare const codedIssue: <issue extends ArkIssue>(issue: issue) => issue;
|
|
65
|
+
export declare const notedAs: (issue: ArkIssue, copy: ArkIssue) => ArkIssue;
|
|
66
|
+
export declare const movedIssue: (issue: ArkIssue, path: PropertyKey[]) => ArkIssue;
|
|
67
|
+
export declare const pathOf: (issue: {
|
|
68
|
+
readonly path: readonly PropertyKey[];
|
|
69
|
+
}) => string;
|
|
70
|
+
export declare const lineOf: (issue: ArkIssue) => string;
|
|
71
|
+
export declare const messageOf: (issue: {
|
|
72
|
+
readonly code?: ArkErrorCode;
|
|
73
|
+
readonly expected?: string | undefined;
|
|
74
|
+
}) => string;
|
|
75
|
+
interface ThrownIssues extends Error {
|
|
76
|
+
readonly name: "TraversalError";
|
|
77
|
+
arkErrors: Issues;
|
|
78
|
+
}
|
|
79
|
+
declare const ThrownIssues: new (errors: Issues) => ThrownIssues;
|
|
80
|
+
export { ThrownIssues as TraversalError };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { arkKind } from "../../util/index.js";
|
|
2
|
+
import type { ArkIssue } from "./issues.ts";
|
|
3
|
+
export * from "./issuesUndetailed.ts";
|
|
4
|
+
export declare class ArkErrors {
|
|
5
|
+
_: ArkIssue[];
|
|
6
|
+
get [arkKind](): "errors";
|
|
7
|
+
get count(): number;
|
|
8
|
+
get issues(): readonly ArkIssue[];
|
|
9
|
+
get summary(): string;
|
|
10
|
+
summaryIn(): string;
|
|
11
|
+
throw(): never;
|
|
12
|
+
toJSON(): readonly object[];
|
|
13
|
+
toString(): string;
|
|
14
|
+
[Symbol.iterator](): IterableIterator<ArkIssue>;
|
|
15
|
+
}
|
|
16
|
+
export { ArkErrors as FirstIssues };
|
|
17
|
+
interface ThrownErrors extends Error {
|
|
18
|
+
readonly name: "TraversalError";
|
|
19
|
+
arkErrors: ArkErrors;
|
|
20
|
+
}
|
|
21
|
+
declare const ThrownErrors: new (errors: ArkErrors) => ThrownErrors;
|
|
22
|
+
export { ThrownErrors as TraversalError };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ArkIssue } from "./issues.ts";
|
|
2
|
+
export * from "./issuesUndetailed.ts";
|
|
3
|
+
export declare class ArkErrors {
|
|
4
|
+
_: ArkIssue[];
|
|
5
|
+
get count(): number;
|
|
6
|
+
get issues(): readonly ArkIssue[];
|
|
7
|
+
get summary(): string;
|
|
8
|
+
summaryIn(): string;
|
|
9
|
+
throw(): never;
|
|
10
|
+
toJSON(): readonly object[];
|
|
11
|
+
toString(): string;
|
|
12
|
+
[Symbol.iterator](): IterableIterator<ArkIssue>;
|
|
13
|
+
}
|
|
14
|
+
export { ArkErrors as FirstIssues };
|
|
15
|
+
interface ThrownErrors extends Error {
|
|
16
|
+
readonly name: "TraversalError";
|
|
17
|
+
arkErrors: ArkErrors;
|
|
18
|
+
}
|
|
19
|
+
declare const ThrownErrors: new (errors: ArkErrors) => ThrownErrors;
|
|
20
|
+
export { ThrownErrors as TraversalError };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type array } from "../../util/index.js";
|
|
2
|
+
import type { ArkErrors } from "./issuesNone.ts";
|
|
3
|
+
import type { ArkErrorCode } from "./errors.ts";
|
|
4
|
+
import type { ArkIssue, FailureContext, FailureSite, MissingText, SiteContext } from "./issues.ts";
|
|
5
|
+
export declare const failsKey: (ctx: FailureContext, data: unknown, key: PropertyKey, code: ArkErrorCode, expected?: string, missing?: string | undefined) => boolean | undefined;
|
|
6
|
+
export declare const failsSite: (ctx: FailureContext, context: SiteContext, data: unknown) => boolean | undefined;
|
|
7
|
+
export declare const failsKeySite: (ctx: FailureContext, site: FailureSite, data: unknown, key: PropertyKey) => boolean | undefined;
|
|
8
|
+
export declare const missingTextOf: (missing: SiteContext | undefined) => MissingText;
|
|
9
|
+
export declare const applyIssues: () => never;
|
|
10
|
+
export declare const issuesOf: () => never;
|
|
11
|
+
export declare const foundErrors: typeof issuesOf;
|
|
12
|
+
export declare const throwIssues: typeof issuesOf;
|
|
13
|
+
export declare const throwOnDefault: (errors: ArkErrors) => never;
|
|
14
|
+
export declare const mergeIssues: (errors: ArkErrors, merged: ArkErrors, prefix: array<PropertyKey>) => void;
|
|
15
|
+
export declare const movedIssue: (issue: ArkIssue, path: PropertyKey[]) => ArkIssue;
|
|
16
|
+
export declare const pathOf: (issue: {
|
|
17
|
+
readonly path: readonly PropertyKey[];
|
|
18
|
+
}) => string;
|
|
19
|
+
export declare const messageOf: () => string;
|
|
20
|
+
export declare const lineOf: (issue: ArkIssue) => string;
|
|
21
|
+
export declare const isCustomIssue: () => boolean;
|
|
22
|
+
export declare const codedIssue: <issue extends ArkIssue>(issue: issue) => issue;
|
|
23
|
+
export declare const notedAs: (issue: ArkIssue, copy: ArkIssue) => ArkIssue;
|
|
24
|
+
declare const issueOf: (path: PropertyKey[]) => ArkIssue;
|
|
25
|
+
export { issueOf as issueAt };
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { type autocomplete, type Json, type JsonArray, type JsonObject, type listable } from "../../util/index.js";
|
|
2
|
+
import type { StandardJSONSchemaV1 } from "./standardSchema.ts";
|
|
3
|
+
import type { ToJsonSchema } from "./toJsonSchema.ts";
|
|
4
|
+
export type JsonSchema = JsonSchema.NonBooleanBranch;
|
|
5
|
+
export type ListableJsonSchema = listable<JsonSchema>;
|
|
6
|
+
export type JsonSchemaOrBoolean = listable<JsonSchema.Branch>;
|
|
7
|
+
export declare namespace JsonSchema {
|
|
8
|
+
type TypeName = "string" | "integer" | "number" | "object" | "array" | "boolean" | "null";
|
|
9
|
+
/**
|
|
10
|
+
* a subset of JSON Schema's annotations, see:
|
|
11
|
+
* https://json-schema.org/understanding-json-schema/reference/annotations
|
|
12
|
+
**/
|
|
13
|
+
interface Meta<t = Json> extends UniversalMeta<t> {
|
|
14
|
+
[k: string]: unknown;
|
|
15
|
+
$schema?: string;
|
|
16
|
+
$defs?: Record<string, JsonSchema>;
|
|
17
|
+
definitions?: Record<string, JsonSchema>;
|
|
18
|
+
examples?: t[];
|
|
19
|
+
example?: t;
|
|
20
|
+
nullable?: boolean;
|
|
21
|
+
}
|
|
22
|
+
type Format = autocomplete<"date-time" | "date" | "time" | "email" | "ipv4" | "ipv6" | "uri" | "uuid" | "regex">;
|
|
23
|
+
/**
|
|
24
|
+
* the annotations a Type's meta writes to its JSON Schema, which doesn't
|
|
25
|
+
* include root-only keys like $schema
|
|
26
|
+
*/
|
|
27
|
+
interface UniversalMeta<t = unknown> {
|
|
28
|
+
title?: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
format?: Format;
|
|
31
|
+
contentEncoding?: string;
|
|
32
|
+
deprecated?: boolean;
|
|
33
|
+
readOnly?: boolean;
|
|
34
|
+
writeOnly?: boolean;
|
|
35
|
+
$comment?: string;
|
|
36
|
+
default?: t;
|
|
37
|
+
examples?: readonly t[];
|
|
38
|
+
}
|
|
39
|
+
type Composition = Union | OneOf | Intersection | Not;
|
|
40
|
+
type NonBooleanBranch = Constrainable | Const | Composition | Enum | String | Numeric | Object | Array | Ref;
|
|
41
|
+
type Branch = boolean | JsonSchema;
|
|
42
|
+
type Input = Branch | object;
|
|
43
|
+
type RefString = `#/${"$defs" | "definitions" | "components/schemas"}/${string}`;
|
|
44
|
+
interface Ref extends Meta {
|
|
45
|
+
$ref: RefString;
|
|
46
|
+
type?: never;
|
|
47
|
+
}
|
|
48
|
+
interface Constrainable extends Meta {
|
|
49
|
+
type?: TypeName | TypeName[];
|
|
50
|
+
}
|
|
51
|
+
interface Intersection extends Meta {
|
|
52
|
+
allOf: JsonSchema[];
|
|
53
|
+
}
|
|
54
|
+
interface Not extends Meta {
|
|
55
|
+
not: JsonSchema;
|
|
56
|
+
}
|
|
57
|
+
interface OneOf extends Meta {
|
|
58
|
+
oneOf: JsonSchema[];
|
|
59
|
+
discriminator?: Discriminator;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* OpenAPI's Discriminator Object, naming the property a oneOf's branches
|
|
63
|
+
* are told apart by
|
|
64
|
+
* https://spec.openapis.org/oas/v3.0.3#discriminator-object
|
|
65
|
+
*/
|
|
66
|
+
interface Discriminator {
|
|
67
|
+
propertyName: string;
|
|
68
|
+
/** the $ref of the branch each value selects */
|
|
69
|
+
mapping?: Record<string, string>;
|
|
70
|
+
}
|
|
71
|
+
interface Union extends Meta {
|
|
72
|
+
anyOf: JsonSchema[];
|
|
73
|
+
}
|
|
74
|
+
interface Const extends Meta {
|
|
75
|
+
const: Json;
|
|
76
|
+
}
|
|
77
|
+
interface Enum extends Meta {
|
|
78
|
+
enum: Json[];
|
|
79
|
+
}
|
|
80
|
+
interface String extends Meta<string> {
|
|
81
|
+
type: "string";
|
|
82
|
+
minLength?: number;
|
|
83
|
+
maxLength?: number;
|
|
84
|
+
pattern?: string;
|
|
85
|
+
format?: string;
|
|
86
|
+
not?: JsonSchema;
|
|
87
|
+
contentMediaType?: string;
|
|
88
|
+
}
|
|
89
|
+
interface Numeric extends Meta<number> {
|
|
90
|
+
type: "number" | "integer";
|
|
91
|
+
multipleOf?: number;
|
|
92
|
+
minimum?: number;
|
|
93
|
+
maximum?: number;
|
|
94
|
+
exclusiveMinimum?: number;
|
|
95
|
+
exclusiveMaximum?: number;
|
|
96
|
+
not?: Const | Enum;
|
|
97
|
+
}
|
|
98
|
+
interface Object extends Meta<JsonObject> {
|
|
99
|
+
type: "object";
|
|
100
|
+
properties?: Record<string, JsonSchema>;
|
|
101
|
+
required?: string[];
|
|
102
|
+
patternProperties?: Record<string, JsonSchema>;
|
|
103
|
+
additionalProperties?: Branch;
|
|
104
|
+
maxProperties?: number;
|
|
105
|
+
minProperties?: number;
|
|
106
|
+
propertyNames?: Branch;
|
|
107
|
+
}
|
|
108
|
+
interface Array extends Meta<JsonArray> {
|
|
109
|
+
type: "array";
|
|
110
|
+
additionalItems?: Branch;
|
|
111
|
+
contains?: Branch;
|
|
112
|
+
uniqueItems?: boolean;
|
|
113
|
+
minItems?: number;
|
|
114
|
+
maxItems?: number;
|
|
115
|
+
items?: Branch | Branch[];
|
|
116
|
+
prefixItems?: Branch[];
|
|
117
|
+
not?: JsonSchema;
|
|
118
|
+
}
|
|
119
|
+
type LengthBoundable = String | Array;
|
|
120
|
+
type Structure = Object | Array;
|
|
121
|
+
}
|
|
122
|
+
export declare class ToJsonSchemaError<code extends ToJsonSchema.Code = ToJsonSchema.Code> extends Error {
|
|
123
|
+
readonly name = "ToJsonSchemaError";
|
|
124
|
+
readonly code: code;
|
|
125
|
+
readonly context: ToJsonSchema.ContextByCode[code];
|
|
126
|
+
constructor(code: code, context: ToJsonSchema.ContextByCode[code], path?: string, message?: string);
|
|
127
|
+
hasCode<code extends ToJsonSchema.Code>(code: code): this is ToJsonSchemaError<code>;
|
|
128
|
+
}
|
|
129
|
+
/** the targets ~standard.jsonSchema writes, each of which a precompiled build bakes */
|
|
130
|
+
export declare const supportedJsonSchemaTargets: readonly ToJsonSchema.Target[];
|
|
131
|
+
/**
|
|
132
|
+
* the targets toJsonSchema writes. Standard JSON Schema names no OpenAPI 3.1,
|
|
133
|
+
* whose Schema Object is draft-2020-12 but for where its $refs point, so it's
|
|
134
|
+
* only toJsonSchema's, and isn't baked for ~standard.jsonSchema
|
|
135
|
+
*/
|
|
136
|
+
export declare const toJsonSchemaTargets: readonly ToJsonSchema.Target[];
|
|
137
|
+
export declare const writeInvalidJsonSchemaTargetMessage: (target: string, targets?: readonly string[]) => string;
|
|
138
|
+
export declare const validateStandardJsonSchemaTarget: (target: StandardJSONSchemaV1.Target) => ToJsonSchema.Target;
|
|
139
|
+
export declare const validateToJsonSchemaTarget: (target: StandardJSONSchemaV1.Target) => ToJsonSchema.Target;
|
|
140
|
+
export declare const openApiNull: () => JsonSchema;
|
|
141
|
+
/**
|
|
142
|
+
* the key a union's object branches each require a string at, no value of
|
|
143
|
+
* which two branches share, so exactly one branch can match any data
|
|
144
|
+
*/
|
|
145
|
+
export interface UnionDiscriminant {
|
|
146
|
+
key: string;
|
|
147
|
+
/** the strings each branch allows at the key, in the order of the branches */
|
|
148
|
+
values: string[][];
|
|
149
|
+
/** whether OpenAPI's discriminator is written beside the oneOf */
|
|
150
|
+
writesKeyword: boolean;
|
|
151
|
+
}
|
|
152
|
+
export declare const writeUnionJsonSchema: (branches: JsonSchema[], target: ToJsonSchema.Target, meta: object, metaJson: object, discriminant?: UnionDiscriminant) => JsonSchema;
|
|
153
|
+
export declare const writeNullableJsonSchema: (schema: JsonSchema, isUnion: boolean, target: ToJsonSchema.Target) => JsonSchema;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { array } from "../../util/index.js";
|
|
2
|
+
import { type ArkIssue } from "./issues.ts";
|
|
3
|
+
export declare const writeListed: (errors: readonly ArkIssue[]) => string;
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
* the message each issue's Type was configured with or its callback supplied,
|
|
7
|
+
* a sentence of its own (isCustomIssue), if they agree, which a union of them
|
|
8
|
+
* says too, as arktype's does. One configured for a code isn't its Type's
|
|
9
|
+
* (codedIssue), so it's listed
|
|
10
|
+
*/
|
|
11
|
+
export declare const sharedMessageOf: (errors: readonly ArkIssue[]) => string | undefined;
|
|
12
|
+
export type UnionIssueOf = (path: PropertyKey[], data: unknown, errors: readonly ArkIssue[]) => ArkIssue;
|
|
13
|
+
export declare const writeFromPath: (path: array<PropertyKey>, errors: readonly ArkIssue[], write: (errors: readonly ArkIssue[]) => string) => string;
|
|
14
|
+
export declare const listedIssue: UnionIssueOf;
|
|
15
|
+
export declare const alikeIssue: UnionIssueOf;
|