arktype 2.2.10 → 3.0.0-beta.1
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 +181 -15
- package/out/attributes.d.ts +50 -14
- package/out/checkers.d.ts +172 -0
- package/out/chunk-2U2AWCI3.js +626 -0
- package/out/chunk-4CUA5XIP.js +7 -0
- package/out/chunk-5U2ZMDNI.js +1566 -0
- package/out/chunk-DLWCO4RV.js +18 -0
- package/out/chunk-E3DZXEZK.js +72 -0
- package/out/chunk-EVCML554.js +47 -0
- package/out/chunk-G45P2CLE.js +63 -0
- package/out/chunk-GPNK5353.js +2529 -0
- package/out/chunk-MLKGABMK.js +9 -0
- package/out/chunk-NRIGTMPM.js +7 -0
- package/out/chunk-PRTMQCHS.js +3 -0
- package/out/chunk-R5G57XC7.js +7 -0
- package/out/chunk-RAZ3TXOE.js +313 -0
- package/out/chunk-SWOOCAHN.js +4 -0
- package/out/chunk-TAHPKDNM.js +3 -0
- package/out/chunk-UETB6YE2.js +14 -0
- package/out/chunk-UK5UGFOX.js +254 -0
- package/out/chunk-VV6YDN2D.js +6118 -0
- package/out/codecs.d.ts +21 -0
- package/out/codecs.js +7 -0
- package/out/config.d.ts +8 -3
- package/out/config.js +2 -3
- package/out/declare.d.ts +17 -3
- package/out/deferred.d.ts +10 -0
- package/out/errors.d.ts +1 -0
- package/out/errors.js +2 -0
- package/out/fn.d.ts +1 -1
- package/out/generic.d.ts +3 -3
- package/out/i18n.d.ts +2 -0
- package/out/i18n.js +2 -0
- package/out/index.d.ts +5 -4
- package/out/index.js +8 -9
- package/out/internal.d.ts +70 -0
- package/out/internal.js +17 -0
- package/out/island.d.ts +2 -0
- package/out/island.js +6 -0
- package/out/islandDependency.d.ts +2 -0
- package/out/islandDependency.js +18 -0
- package/out/keywords/Array.d.ts +2 -2
- package/out/keywords/builtins.d.ts +5 -3
- package/out/keywords/constructors.d.ts +9 -1
- package/out/keywords/functions.d.ts +254 -0
- package/out/keywords/keywords.d.ts +8 -9
- package/out/keywords/number.d.ts +2 -8
- package/out/keywords/phrases.d.ts +245 -0
- package/out/keywords/string.d.ts +14 -113
- package/out/keywords/ts.d.ts +35 -33
- package/out/keywords/ts.js +4 -82
- package/out/locale.d.ts +19 -0
- package/out/locales/de.d.ts +2 -0
- package/out/locales/de.js +2 -0
- package/out/locales/en.d.ts +4 -0
- package/out/locales/en.js +5 -0
- package/out/match.d.ts +6 -6
- package/out/module.d.ts +1 -1
- package/out/mutatesInput.js +3 -0
- package/out/parser/ast/generic.d.ts +6 -3
- package/out/parser/ast/infer.d.ts +1 -1
- package/out/parser/ast/validate.d.ts +11 -6
- package/out/parser/definition.d.ts +68 -7
- package/out/parser/objectLiteral.d.ts +40 -12
- package/out/parser/property.d.ts +3 -5
- package/out/parser/reduce/dynamic.d.ts +16 -7
- package/out/parser/reduce/shared.d.ts +4 -0
- package/out/parser/reduce/static.d.ts +13 -13
- package/out/parser/shift/operand/date.d.ts +0 -5
- package/out/parser/shift/operand/operand.d.ts +2 -1
- package/out/parser/shift/operand/unenclosed.d.ts +9 -6
- package/out/parser/shift/operand/unresolvable.d.ts +68 -0
- package/out/parser/shift/operator/bounds.d.ts +9 -4
- package/out/parser/shift/operator/brand.d.ts +2 -2
- package/out/parser/shift/operator/default.d.ts +2 -2
- package/out/parser/shift/operator/divisor.d.ts +2 -2
- package/out/parser/shift/operator/operator.d.ts +1 -1
- package/out/parser/shift/tokens.d.ts +9 -2
- package/out/parser/string.d.ts +61 -7
- package/out/parser/tupleExpressions.d.ts +7 -3
- package/out/precompiled.d.ts +1 -0
- package/out/precompiled.js +2 -0
- package/out/runtime.d.ts +181 -0
- package/out/runtime.js +4 -0
- package/out/runtimeDevelopment.d.ts +1 -0
- package/out/runtimeDevelopment.js +133 -0
- package/out/runtimeExports.d.ts +1 -0
- package/out/scope.d.ts +40 -11
- package/out/standalone/artifact.d.ts +265 -0
- package/out/standalone/baking.d.ts +201 -0
- package/out/standalone/combinators.d.ts +13 -0
- package/out/standalone/compilers.d.ts +23 -0
- package/out/standalone/creators.d.ts +41 -0
- package/out/standalone/fallbacks.d.ts +48 -0
- package/out/standalone/keys.d.ts +31 -0
- package/out/standalone/modules.d.ts +26 -0
- package/out/standalone/sites.d.ts +52 -0
- package/out/standalone/units.d.ts +31 -0
- package/out/standalone/values.d.ts +60 -0
- package/out/standalone.d.ts +16 -0
- package/out/type.d.ts +45 -6
- package/out/variants/array.d.ts +1 -1
- package/out/variants/base.d.ts +47 -27
- package/out/variants/date.d.ts +1 -1
- package/out/variants/instantiate.d.ts +4 -2
- package/out/variants/number.d.ts +1 -1
- package/out/variants/object.d.ts +17 -12
- package/out/variants/string.d.ts +1 -1
- package/package.json +169 -8
- package/skills/arktype/SKILL.md +278 -43
- package/skills/arktype/references/migrating.md +1296 -0
- package/skills/arktype/references/precompile.md +191 -0
- package/out/attributes.js +0 -3
- package/out/fn.js +0 -58
- package/out/generic.js +0 -37
- package/out/keywords/Array.js +0 -21
- package/out/keywords/FormData.js +0 -40
- package/out/keywords/TypedArray.js +0 -16
- package/out/keywords/builtins.js +0 -11
- package/out/keywords/constructors.js +0 -16
- package/out/keywords/keywords.js +0 -48
- package/out/keywords/number.js +0 -49
- package/out/keywords/string.js +0 -467
- package/out/match.js +0 -95
- package/out/module.js +0 -3
- package/out/nary.js +0 -1
- package/out/parser/ast/bounds.js +0 -1
- package/out/parser/ast/default.js +0 -1
- package/out/parser/ast/divisor.js +0 -1
- package/out/parser/ast/generic.js +0 -1
- package/out/parser/ast/infer.js +0 -1
- package/out/parser/ast/keyof.js +0 -1
- package/out/parser/ast/utils.js +0 -1
- package/out/parser/ast/validate.js +0 -3
- package/out/parser/definition.js +0 -78
- package/out/parser/objectLiteral.js +0 -113
- package/out/parser/property.js +0 -16
- package/out/parser/reduce/dynamic.js +0 -153
- package/out/parser/reduce/shared.js +0 -25
- package/out/parser/reduce/static.js +0 -1
- package/out/parser/shift/operand/date.js +0 -23
- package/out/parser/shift/operand/enclosed.js +0 -82
- package/out/parser/shift/operand/genericArgs.js +0 -16
- package/out/parser/shift/operand/operand.js +0 -16
- package/out/parser/shift/operand/unenclosed.js +0 -59
- package/out/parser/shift/operator/bounds.js +0 -91
- package/out/parser/shift/operator/brand.js +0 -6
- package/out/parser/shift/operator/default.js +0 -29
- package/out/parser/shift/operator/divisor.js +0 -13
- package/out/parser/shift/operator/operator.js +0 -28
- package/out/parser/shift/tokens.js +0 -37
- package/out/parser/string.js +0 -42
- package/out/parser/tupleExpressions.js +0 -75
- package/out/parser/tupleLiteral.js +0 -128
- package/out/scope.js +0 -106
- package/out/type.js +0 -55
- package/out/variants/array.js +0 -1
- package/out/variants/base.js +0 -1
- package/out/variants/date.js +0 -1
- package/out/variants/instantiate.js +0 -1
- package/out/variants/number.js +0 -1
- package/out/variants/object.js +0 -1
- package/out/variants/string.js +0 -1
- /package/out/{declare.js → mutatesInput.d.ts} +0 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import type { ArkError, Locale, Traversal } from "@ark/schema";
|
|
2
|
+
import { type Json } from "@ark/util";
|
|
3
|
+
import type { ParsedFormData } from "./FormData.ts";
|
|
4
|
+
export declare const parseInteger: (s: string, ctx: Traversal) => number | ArkError;
|
|
5
|
+
export declare const parseNumeric: (s: string) => number;
|
|
6
|
+
export declare const parsesFinite: (s: string) => boolean;
|
|
7
|
+
export declare const capitalizeString: (s: string) => string;
|
|
8
|
+
export declare const lowercaseString: (s: string) => string;
|
|
9
|
+
export declare const uppercaseString: (s: string) => string;
|
|
10
|
+
export declare const trimString: (s: string) => string;
|
|
11
|
+
export declare const isLuhnValid: (creditCardInput: string) => boolean;
|
|
12
|
+
export declare const isParsableDate: (s: string) => boolean;
|
|
13
|
+
export declare const parseDate: (s: string, ctx: Traversal) => Date | ArkError;
|
|
14
|
+
export declare const parseIsoDate: (s: string, ctx: Traversal) => Date | ArkError;
|
|
15
|
+
export declare const parseEpoch: (s: string) => Date;
|
|
16
|
+
/**
|
|
17
|
+
* As per the ECMA-262 specification:
|
|
18
|
+
* A time value supports a slightly smaller range of -8,640,000,000,000,000 to 8,640,000,000,000,000 milliseconds.
|
|
19
|
+
*
|
|
20
|
+
* @see https://262.ecma-international.org/15.0/index.html#sec-time-values-and-time-range
|
|
21
|
+
*/
|
|
22
|
+
export declare const maxEpoch = 8640000000000000;
|
|
23
|
+
export declare const epochDescriptions: {
|
|
24
|
+
domain: string;
|
|
25
|
+
min: string;
|
|
26
|
+
max: string;
|
|
27
|
+
};
|
|
28
|
+
export declare const isEpochString: (s: string, ctx: Traversal) => boolean;
|
|
29
|
+
export declare const writeJsonSyntaxErrorMessage: (error: unknown) => string;
|
|
30
|
+
export declare const isJsonString: (s: string, ctx: Traversal) => boolean;
|
|
31
|
+
export declare const parseJson: (s: string, ctx: Traversal) => Json | ArkError;
|
|
32
|
+
export declare const stringifyJson: (data: Json) => string;
|
|
33
|
+
export declare const writeIsoDate: (date: Date) => string;
|
|
34
|
+
export declare const writeEpoch: (date: Date) => string;
|
|
35
|
+
export declare const writeUrl: (url: URL) => string;
|
|
36
|
+
export declare const keepFormatted: (s: string) => string;
|
|
37
|
+
export declare const normalizationsByForm: {
|
|
38
|
+
NFC: {
|
|
39
|
+
predicate: (s: string) => boolean;
|
|
40
|
+
morphs: (s: string) => string;
|
|
41
|
+
};
|
|
42
|
+
NFD: {
|
|
43
|
+
predicate: (s: string) => boolean;
|
|
44
|
+
morphs: (s: string) => string;
|
|
45
|
+
};
|
|
46
|
+
NFKC: {
|
|
47
|
+
predicate: (s: string) => boolean;
|
|
48
|
+
morphs: (s: string) => string;
|
|
49
|
+
};
|
|
50
|
+
NFKD: {
|
|
51
|
+
predicate: (s: string) => boolean;
|
|
52
|
+
morphs: (s: string) => string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export declare const emptyCollectionDefaults: {
|
|
56
|
+
readonly "[]": () => [];
|
|
57
|
+
readonly "{}": () => {};
|
|
58
|
+
};
|
|
59
|
+
export declare const isRegexPattern: (s: string, ctx: Traversal) => boolean;
|
|
60
|
+
/** en's phrases of the keywords that write the errors they raise through ctx */
|
|
61
|
+
export declare const raisedErrorPhrases: {
|
|
62
|
+
readonly "string.json": {
|
|
63
|
+
readonly noun: "a JSON string";
|
|
64
|
+
readonly message: Locale.MessageWriter<import("@ark/schema").ArkErrorCode>;
|
|
65
|
+
};
|
|
66
|
+
readonly "string.json.parse": {
|
|
67
|
+
readonly noun: "a JSON string";
|
|
68
|
+
readonly message: Locale.MessageWriter<import("@ark/schema").ArkErrorCode>;
|
|
69
|
+
};
|
|
70
|
+
readonly "string.regex": {
|
|
71
|
+
readonly noun: "a regex pattern";
|
|
72
|
+
readonly message: (e: (import("@ark/util").omit<({
|
|
73
|
+
discriminantKind: "domain";
|
|
74
|
+
cases: readonly import("@ark/schema").DomainCase[];
|
|
75
|
+
onKey: boolean;
|
|
76
|
+
absent: boolean;
|
|
77
|
+
data: unknown;
|
|
78
|
+
code: "discriminant";
|
|
79
|
+
description?: string;
|
|
80
|
+
} | {
|
|
81
|
+
discriminantKind: "unit";
|
|
82
|
+
cases: readonly unknown[];
|
|
83
|
+
onKey: boolean;
|
|
84
|
+
absent: boolean;
|
|
85
|
+
data: unknown;
|
|
86
|
+
code: "discriminant";
|
|
87
|
+
description?: string;
|
|
88
|
+
}) & import("@ark/schema").WrittenErrorContext<"discriminant">, "message"> & {
|
|
89
|
+
toString(never: never): string;
|
|
90
|
+
toLocaleString(never: never): string;
|
|
91
|
+
}) | (import("@ark/util").omit<{
|
|
92
|
+
domain: import("@ark/schema").Domain.NonEnumerable;
|
|
93
|
+
numberAllowsNaN?: boolean;
|
|
94
|
+
numberAllowsInfinity?: boolean;
|
|
95
|
+
code: "domain";
|
|
96
|
+
description?: string;
|
|
97
|
+
} & import("@ark/schema").WrittenErrorContext<"domain">, "message"> & {
|
|
98
|
+
toString(never: never): string;
|
|
99
|
+
toLocaleString(never: never): string;
|
|
100
|
+
}) | (import("@ark/util").omit<{
|
|
101
|
+
unit: unknown;
|
|
102
|
+
code: "unit";
|
|
103
|
+
description?: string;
|
|
104
|
+
} & import("@ark/schema").WrittenErrorContext<"unit">, "message"> & {
|
|
105
|
+
toString(never: never): string;
|
|
106
|
+
toLocaleString(never: never): string;
|
|
107
|
+
}) | (import("@ark/util").omit<{
|
|
108
|
+
errors: readonly ArkError[];
|
|
109
|
+
code: "union";
|
|
110
|
+
description?: string;
|
|
111
|
+
} & import("@ark/schema").WrittenErrorContext<"union">, "message"> & {
|
|
112
|
+
toString(never: never): string;
|
|
113
|
+
toLocaleString(never: never): string;
|
|
114
|
+
}) | (import("@ark/util").omit<{
|
|
115
|
+
missingValueDescription: string;
|
|
116
|
+
missing: import("@ark/schema").MissingValue;
|
|
117
|
+
valueMeta: ArkEnv.meta;
|
|
118
|
+
code: "required";
|
|
119
|
+
description?: string;
|
|
120
|
+
} & import("@ark/schema").WrittenErrorContext<"required">, "message"> & {
|
|
121
|
+
toString(never: never): string;
|
|
122
|
+
toLocaleString(never: never): string;
|
|
123
|
+
}) | (import("@ark/util").omit<{
|
|
124
|
+
rule: number;
|
|
125
|
+
code: "exactLength";
|
|
126
|
+
description?: string;
|
|
127
|
+
} & import("@ark/schema").WrittenErrorContext<"exactLength">, "message"> & {
|
|
128
|
+
toString(never: never): string;
|
|
129
|
+
toLocaleString(never: never): string;
|
|
130
|
+
}) | (import("@ark/util").omit<{
|
|
131
|
+
rule: number;
|
|
132
|
+
code: "maxLength";
|
|
133
|
+
description?: string;
|
|
134
|
+
} & import("@ark/schema").WrittenErrorContext<"maxLength">, "message"> & {
|
|
135
|
+
toString(never: never): string;
|
|
136
|
+
toLocaleString(never: never): string;
|
|
137
|
+
}) | (import("@ark/util").omit<{
|
|
138
|
+
rule: number;
|
|
139
|
+
code: "minLength";
|
|
140
|
+
description?: string;
|
|
141
|
+
} & import("@ark/schema").WrittenErrorContext<"minLength">, "message"> & {
|
|
142
|
+
toString(never: never): string;
|
|
143
|
+
toLocaleString(never: never): string;
|
|
144
|
+
}) | (import("@ark/util").omit<{
|
|
145
|
+
rule: Date;
|
|
146
|
+
code: "after";
|
|
147
|
+
description?: string;
|
|
148
|
+
} & import("@ark/schema").WrittenErrorContext<"after">, "message"> & {
|
|
149
|
+
toString(never: never): string;
|
|
150
|
+
toLocaleString(never: never): string;
|
|
151
|
+
}) | (import("@ark/util").omit<{
|
|
152
|
+
rule: Date;
|
|
153
|
+
code: "before";
|
|
154
|
+
description?: string;
|
|
155
|
+
} & import("@ark/schema").WrittenErrorContext<"before">, "message"> & {
|
|
156
|
+
toString(never: never): string;
|
|
157
|
+
toLocaleString(never: never): string;
|
|
158
|
+
}) | (import("@ark/util").omit<{
|
|
159
|
+
rule: number;
|
|
160
|
+
exclusive?: true;
|
|
161
|
+
code: "max";
|
|
162
|
+
description?: string;
|
|
163
|
+
} & import("@ark/schema").WrittenErrorContext<"max">, "message"> & {
|
|
164
|
+
toString(never: never): string;
|
|
165
|
+
toLocaleString(never: never): string;
|
|
166
|
+
}) | (import("@ark/util").omit<{
|
|
167
|
+
rule: number;
|
|
168
|
+
exclusive?: true;
|
|
169
|
+
code: "min";
|
|
170
|
+
description?: string;
|
|
171
|
+
} & import("@ark/schema").WrittenErrorContext<"min">, "message"> & {
|
|
172
|
+
toString(never: never): string;
|
|
173
|
+
toLocaleString(never: never): string;
|
|
174
|
+
}) | (import("@ark/util").omit<{
|
|
175
|
+
rule: import("@ark/schema").LimitValue;
|
|
176
|
+
code: "notEqual";
|
|
177
|
+
description?: string;
|
|
178
|
+
} & import("@ark/schema").WrittenErrorContext<"notEqual">, "message"> & {
|
|
179
|
+
toString(never: never): string;
|
|
180
|
+
toLocaleString(never: never): string;
|
|
181
|
+
}) | (import("@ark/util").omit<{
|
|
182
|
+
rule: number;
|
|
183
|
+
code: "notEqualLength";
|
|
184
|
+
description?: string;
|
|
185
|
+
} & import("@ark/schema").WrittenErrorContext<"notEqualLength">, "message"> & {
|
|
186
|
+
toString(never: never): string;
|
|
187
|
+
toLocaleString(never: never): string;
|
|
188
|
+
}) | (import("@ark/util").omit<{
|
|
189
|
+
code: "proto";
|
|
190
|
+
description?: string;
|
|
191
|
+
proto: import("@ark/util").Constructor;
|
|
192
|
+
dateAllowsInvalid?: boolean;
|
|
193
|
+
} & import("@ark/schema").WrittenErrorContext<"proto">, "message"> & {
|
|
194
|
+
toString(never: never): string;
|
|
195
|
+
toLocaleString(never: never): string;
|
|
196
|
+
}) | (import("@ark/util").omit<{
|
|
197
|
+
code: "intersection";
|
|
198
|
+
description?: string;
|
|
199
|
+
domain?: import("@ark/schema").Domain.Node;
|
|
200
|
+
proto?: import("@ark/schema").Proto.Node;
|
|
201
|
+
structure?: import("@ark/schema").Structure.Node;
|
|
202
|
+
predicate?: import("@ark/util").array<import("@ark/schema").PredicateNode>;
|
|
203
|
+
errors: readonly ArkError[];
|
|
204
|
+
after?: import("@ark/schema").AfterNode;
|
|
205
|
+
before?: import("@ark/schema").BeforeNode;
|
|
206
|
+
divisor?: import("@ark/schema").DivisorNode;
|
|
207
|
+
exactLength?: import("@ark/schema").ExactLengthNode;
|
|
208
|
+
max?: import("@ark/schema").MaxNode;
|
|
209
|
+
maxLength?: import("@ark/schema").MaxLengthNode;
|
|
210
|
+
min?: import("@ark/schema").MinNode;
|
|
211
|
+
minLength?: import("@ark/schema").MinLengthNode;
|
|
212
|
+
notEqual?: readonly import("@ark/schema").NotEqualNode[];
|
|
213
|
+
notEqualLength?: readonly import("@ark/schema").NotEqualLengthNode[];
|
|
214
|
+
pattern?: readonly import("@ark/schema").PatternNode[];
|
|
215
|
+
} & import("@ark/schema").WrittenErrorContext<"intersection">, "message"> & {
|
|
216
|
+
toString(never: never): string;
|
|
217
|
+
toLocaleString(never: never): string;
|
|
218
|
+
}) | (import("@ark/util").omit<{
|
|
219
|
+
code: "predicate";
|
|
220
|
+
description?: string;
|
|
221
|
+
predicate?: import("@ark/schema").Predicate;
|
|
222
|
+
morph?: import("@ark/schema").Morph;
|
|
223
|
+
cause?: unknown;
|
|
224
|
+
} & import("@ark/schema").WrittenErrorContext<"predicate">, "message"> & {
|
|
225
|
+
toString(never: never): string;
|
|
226
|
+
toLocaleString(never: never): string;
|
|
227
|
+
}) | (import("@ark/util").omit<{
|
|
228
|
+
code: "divisor";
|
|
229
|
+
description?: string;
|
|
230
|
+
rule: number;
|
|
231
|
+
} & import("@ark/schema").WrittenErrorContext<"divisor">, "message"> & {
|
|
232
|
+
toString(never: never): string;
|
|
233
|
+
toLocaleString(never: never): string;
|
|
234
|
+
}) | (import("@ark/util").omit<{
|
|
235
|
+
code: "pattern";
|
|
236
|
+
description?: string;
|
|
237
|
+
rule: string;
|
|
238
|
+
flags?: string;
|
|
239
|
+
} & import("@ark/schema").WrittenErrorContext<"pattern">, "message"> & {
|
|
240
|
+
toString(never: never): string;
|
|
241
|
+
toLocaleString(never: never): string;
|
|
242
|
+
}) | (import("@ark/util").omit<{
|
|
243
|
+
data: unknown;
|
|
244
|
+
code: "undeclared";
|
|
245
|
+
description?: string;
|
|
246
|
+
} & import("@ark/schema").WrittenErrorContext<"undeclared">, "message"> & {
|
|
247
|
+
toString(never: never): string;
|
|
248
|
+
toLocaleString(never: never): string;
|
|
249
|
+
}), locale: Locale<string>) => string;
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
export declare const isParsableUrl: (s: string) => boolean;
|
|
253
|
+
export declare const parseUrl: (s: string, ctx: Traversal) => URL | ArkError;
|
|
254
|
+
export declare const parseFormData: (data: FormData) => ParsedFormData;
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type
|
|
1
|
+
import { type ArkErrors, type arkKind, type flatResolutionsOf } from "@ark/schema";
|
|
2
|
+
import { type Brand, type inferred } from "@ark/util";
|
|
3
3
|
import type { distill, InferredMorph, Out, To } from "../attributes.ts";
|
|
4
4
|
import type { DeclarationParser } from "../declare.ts";
|
|
5
5
|
import type { FnParser } from "../fn.ts";
|
|
6
6
|
import type { GenericParser } from "../generic.ts";
|
|
7
7
|
import type { MatchParser } from "../match.ts";
|
|
8
8
|
import type { BoundModule, Module } from "../module.ts";
|
|
9
|
-
import type { inferDefinition,
|
|
9
|
+
import type { inferDefinition, instantiateDefinition, validateDefinitionArgument } from "../parser/definition.ts";
|
|
10
10
|
import { type bindThis, type Scope } from "../scope.ts";
|
|
11
11
|
import type { DefinitionParser, SchemaParser, Type, TypeParser } from "../type.ts";
|
|
12
12
|
import type { BaseType } from "../variants/base.ts";
|
|
13
|
-
import type
|
|
14
|
-
import {
|
|
15
|
-
import { arkPrototypes } from "./constructors.ts";
|
|
13
|
+
import { type arkBuiltins } from "./builtins.ts";
|
|
14
|
+
import { type arkPrototypes } from "./constructors.ts";
|
|
16
15
|
import { number } from "./number.ts";
|
|
17
16
|
import { string } from "./string.ts";
|
|
18
|
-
import {
|
|
17
|
+
import { object, unknown, type arkTsGenerics, type arkTsKeywords } from "./ts.ts";
|
|
19
18
|
export interface Ark extends Omit<Ark.keywords, keyof Ark.wrapped>, Ark.wrapped {
|
|
20
19
|
}
|
|
21
20
|
export declare namespace Ark {
|
|
@@ -46,8 +45,8 @@ export declare namespace type {
|
|
|
46
45
|
[inferred]?: to;
|
|
47
46
|
}
|
|
48
47
|
type errors = ArkErrors;
|
|
49
|
-
type validate<def, $ = {}, args = bindThis<def>> =
|
|
50
|
-
type instantiate<def, $ = {}, args = bindThis<def>> =
|
|
48
|
+
type validate<def, $ = {}, args = bindThis<def>> = validateDefinitionArgument<def, $, args>;
|
|
49
|
+
type instantiate<def, $ = {}, args = bindThis<def>> = instantiateDefinition<def, $, args>;
|
|
51
50
|
type infer<def, $ = {}, args = bindThis<def>> = inferDefinition<def, $, args>;
|
|
52
51
|
namespace infer {
|
|
53
52
|
type In<def, $ = {}, args = {}> = distill.In<inferDefinition<def, $, args>>;
|
package/out/keywords/number.d.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import type { Module, Submodule } from "../module.ts";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* A time value supports a slightly smaller range of -8,640,000,000,000,000 to 8,640,000,000,000,000 milliseconds.
|
|
5
|
-
*
|
|
6
|
-
* @see https://262.ecma-international.org/15.0/index.html#sec-time-values-and-time-range
|
|
7
|
-
*/
|
|
8
|
-
export declare const epoch: import("@ark/schema").BaseRoot<import("@ark/schema").InternalRootDeclaration>;
|
|
9
|
-
export declare const integer: import("@ark/schema").BaseRoot<import("@ark/schema").InternalRootDeclaration>;
|
|
2
|
+
export declare const epoch: () => import("@ark/schema").nodeOfKind<"intersection" | import("@ark/schema").Intersection.BasisKind>;
|
|
3
|
+
export declare const integer: () => import("@ark/schema").nodeOfKind<"intersection" | import("@ark/schema").Intersection.BasisKind>;
|
|
10
4
|
export declare const number: number.module;
|
|
11
5
|
export declare namespace number {
|
|
12
6
|
type module = Module<submodule>;
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import { type Locale } from "@ark/schema";
|
|
2
|
+
/** the English phrase of each builtin keyword whose nodes carry one */
|
|
3
|
+
export declare const keywordPhrases: {
|
|
4
|
+
readonly "FormData.parsed": "an object representing parsed form data";
|
|
5
|
+
readonly "number.epoch": {
|
|
6
|
+
readonly noun: "an integer representing a safe Unix timestamp";
|
|
7
|
+
readonly expected: (e: import("@ark/schema").ExpectedContext | import("@ark/schema").MissingBasis) => string;
|
|
8
|
+
};
|
|
9
|
+
readonly "object.json": "a plain object or array";
|
|
10
|
+
readonly "string.alpha": "only letters";
|
|
11
|
+
readonly "string.alphanumeric": "only letters and digits 0-9";
|
|
12
|
+
readonly "string.base58": "base58-encoded";
|
|
13
|
+
readonly "string.base64": "base64-encoded";
|
|
14
|
+
readonly "string.base64.url": "base64url-encoded";
|
|
15
|
+
readonly "string.capitalize.preformatted": "capitalized";
|
|
16
|
+
readonly "string.creditCard": "a credit card number";
|
|
17
|
+
readonly "string.date": "a parsable date";
|
|
18
|
+
readonly "string.date.epoch": "an integer string representing a safe Unix timestamp";
|
|
19
|
+
readonly "string.date.iso": "an ISO 8601 date or date-time";
|
|
20
|
+
readonly "string.date.parse": "a parsable date";
|
|
21
|
+
readonly "string.digits": "only digits 0-9";
|
|
22
|
+
readonly "string.email": "an email address";
|
|
23
|
+
readonly "string.hex": "hex characters only";
|
|
24
|
+
readonly "string.integer": "a well-formed integer string";
|
|
25
|
+
readonly "string.integer.parse": "an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER";
|
|
26
|
+
readonly "string.ip": "an IP address";
|
|
27
|
+
readonly "string.ip.v4": "an IPv4 address";
|
|
28
|
+
readonly "string.ip.v6": "an IPv6 address";
|
|
29
|
+
readonly "string.json": {
|
|
30
|
+
readonly noun: "a JSON string";
|
|
31
|
+
readonly message: Locale.MessageWriter<import("@ark/schema").ArkErrorCode>;
|
|
32
|
+
};
|
|
33
|
+
readonly "string.json.parse": {
|
|
34
|
+
readonly noun: "a JSON string";
|
|
35
|
+
readonly message: Locale.MessageWriter<import("@ark/schema").ArkErrorCode>;
|
|
36
|
+
};
|
|
37
|
+
readonly "string.lower.preformatted": "lowercase";
|
|
38
|
+
readonly "string.normalize.NFC.preformatted": "NFC-normalized unicode";
|
|
39
|
+
readonly "string.normalize.NFD.preformatted": "NFD-normalized unicode";
|
|
40
|
+
readonly "string.normalize.NFKC.preformatted": "NFKC-normalized unicode";
|
|
41
|
+
readonly "string.normalize.NFKD.preformatted": "NFKD-normalized unicode";
|
|
42
|
+
readonly "string.numeric": "a well-formed numeric string";
|
|
43
|
+
readonly "string.numeric.parse": "finite";
|
|
44
|
+
readonly "string.regex": {
|
|
45
|
+
readonly noun: "a regex pattern";
|
|
46
|
+
readonly message: (e: (import("@ark/util").omit<({
|
|
47
|
+
discriminantKind: "domain";
|
|
48
|
+
cases: readonly import("@ark/schema").DomainCase[];
|
|
49
|
+
onKey: boolean;
|
|
50
|
+
absent: boolean;
|
|
51
|
+
data: unknown;
|
|
52
|
+
code: "discriminant";
|
|
53
|
+
description?: string;
|
|
54
|
+
} | {
|
|
55
|
+
discriminantKind: "unit";
|
|
56
|
+
cases: readonly unknown[];
|
|
57
|
+
onKey: boolean;
|
|
58
|
+
absent: boolean;
|
|
59
|
+
data: unknown;
|
|
60
|
+
code: "discriminant";
|
|
61
|
+
description?: string;
|
|
62
|
+
}) & import("@ark/schema").WrittenErrorContext<"discriminant">, "message"> & {
|
|
63
|
+
toString(never: never): string;
|
|
64
|
+
toLocaleString(never: never): string;
|
|
65
|
+
}) | (import("@ark/util").omit<{
|
|
66
|
+
domain: import("@ark/schema").Domain.NonEnumerable;
|
|
67
|
+
numberAllowsNaN?: boolean;
|
|
68
|
+
numberAllowsInfinity?: boolean;
|
|
69
|
+
code: "domain";
|
|
70
|
+
description?: string;
|
|
71
|
+
} & import("@ark/schema").WrittenErrorContext<"domain">, "message"> & {
|
|
72
|
+
toString(never: never): string;
|
|
73
|
+
toLocaleString(never: never): string;
|
|
74
|
+
}) | (import("@ark/util").omit<{
|
|
75
|
+
unit: unknown;
|
|
76
|
+
code: "unit";
|
|
77
|
+
description?: string;
|
|
78
|
+
} & import("@ark/schema").WrittenErrorContext<"unit">, "message"> & {
|
|
79
|
+
toString(never: never): string;
|
|
80
|
+
toLocaleString(never: never): string;
|
|
81
|
+
}) | (import("@ark/util").omit<{
|
|
82
|
+
errors: readonly import("@ark/schema").ArkError[];
|
|
83
|
+
code: "union";
|
|
84
|
+
description?: string;
|
|
85
|
+
} & import("@ark/schema").WrittenErrorContext<"union">, "message"> & {
|
|
86
|
+
toString(never: never): string;
|
|
87
|
+
toLocaleString(never: never): string;
|
|
88
|
+
}) | (import("@ark/util").omit<{
|
|
89
|
+
missingValueDescription: string;
|
|
90
|
+
missing: import("@ark/schema").MissingValue;
|
|
91
|
+
valueMeta: ArkEnv.meta;
|
|
92
|
+
code: "required";
|
|
93
|
+
description?: string;
|
|
94
|
+
} & import("@ark/schema").WrittenErrorContext<"required">, "message"> & {
|
|
95
|
+
toString(never: never): string;
|
|
96
|
+
toLocaleString(never: never): string;
|
|
97
|
+
}) | (import("@ark/util").omit<{
|
|
98
|
+
rule: number;
|
|
99
|
+
code: "exactLength";
|
|
100
|
+
description?: string;
|
|
101
|
+
} & import("@ark/schema").WrittenErrorContext<"exactLength">, "message"> & {
|
|
102
|
+
toString(never: never): string;
|
|
103
|
+
toLocaleString(never: never): string;
|
|
104
|
+
}) | (import("@ark/util").omit<{
|
|
105
|
+
rule: number;
|
|
106
|
+
code: "maxLength";
|
|
107
|
+
description?: string;
|
|
108
|
+
} & import("@ark/schema").WrittenErrorContext<"maxLength">, "message"> & {
|
|
109
|
+
toString(never: never): string;
|
|
110
|
+
toLocaleString(never: never): string;
|
|
111
|
+
}) | (import("@ark/util").omit<{
|
|
112
|
+
rule: number;
|
|
113
|
+
code: "minLength";
|
|
114
|
+
description?: string;
|
|
115
|
+
} & import("@ark/schema").WrittenErrorContext<"minLength">, "message"> & {
|
|
116
|
+
toString(never: never): string;
|
|
117
|
+
toLocaleString(never: never): string;
|
|
118
|
+
}) | (import("@ark/util").omit<{
|
|
119
|
+
rule: Date;
|
|
120
|
+
code: "after";
|
|
121
|
+
description?: string;
|
|
122
|
+
} & import("@ark/schema").WrittenErrorContext<"after">, "message"> & {
|
|
123
|
+
toString(never: never): string;
|
|
124
|
+
toLocaleString(never: never): string;
|
|
125
|
+
}) | (import("@ark/util").omit<{
|
|
126
|
+
rule: Date;
|
|
127
|
+
code: "before";
|
|
128
|
+
description?: string;
|
|
129
|
+
} & import("@ark/schema").WrittenErrorContext<"before">, "message"> & {
|
|
130
|
+
toString(never: never): string;
|
|
131
|
+
toLocaleString(never: never): string;
|
|
132
|
+
}) | (import("@ark/util").omit<{
|
|
133
|
+
rule: number;
|
|
134
|
+
exclusive?: true;
|
|
135
|
+
code: "max";
|
|
136
|
+
description?: string;
|
|
137
|
+
} & import("@ark/schema").WrittenErrorContext<"max">, "message"> & {
|
|
138
|
+
toString(never: never): string;
|
|
139
|
+
toLocaleString(never: never): string;
|
|
140
|
+
}) | (import("@ark/util").omit<{
|
|
141
|
+
rule: number;
|
|
142
|
+
exclusive?: true;
|
|
143
|
+
code: "min";
|
|
144
|
+
description?: string;
|
|
145
|
+
} & import("@ark/schema").WrittenErrorContext<"min">, "message"> & {
|
|
146
|
+
toString(never: never): string;
|
|
147
|
+
toLocaleString(never: never): string;
|
|
148
|
+
}) | (import("@ark/util").omit<{
|
|
149
|
+
rule: import("@ark/schema").LimitValue;
|
|
150
|
+
code: "notEqual";
|
|
151
|
+
description?: string;
|
|
152
|
+
} & import("@ark/schema").WrittenErrorContext<"notEqual">, "message"> & {
|
|
153
|
+
toString(never: never): string;
|
|
154
|
+
toLocaleString(never: never): string;
|
|
155
|
+
}) | (import("@ark/util").omit<{
|
|
156
|
+
rule: number;
|
|
157
|
+
code: "notEqualLength";
|
|
158
|
+
description?: string;
|
|
159
|
+
} & import("@ark/schema").WrittenErrorContext<"notEqualLength">, "message"> & {
|
|
160
|
+
toString(never: never): string;
|
|
161
|
+
toLocaleString(never: never): string;
|
|
162
|
+
}) | (import("@ark/util").omit<{
|
|
163
|
+
code: "proto";
|
|
164
|
+
description?: string;
|
|
165
|
+
proto: import("@ark/util").Constructor;
|
|
166
|
+
dateAllowsInvalid?: boolean;
|
|
167
|
+
} & import("@ark/schema").WrittenErrorContext<"proto">, "message"> & {
|
|
168
|
+
toString(never: never): string;
|
|
169
|
+
toLocaleString(never: never): string;
|
|
170
|
+
}) | (import("@ark/util").omit<{
|
|
171
|
+
code: "intersection";
|
|
172
|
+
description?: string;
|
|
173
|
+
domain?: import("@ark/schema").Domain.Node;
|
|
174
|
+
proto?: import("@ark/schema").Proto.Node;
|
|
175
|
+
structure?: import("@ark/schema").Structure.Node;
|
|
176
|
+
predicate?: import("@ark/util").array<import("@ark/schema").PredicateNode>;
|
|
177
|
+
errors: readonly import("@ark/schema").ArkError[];
|
|
178
|
+
after?: import("@ark/schema").AfterNode;
|
|
179
|
+
before?: import("@ark/schema").BeforeNode;
|
|
180
|
+
divisor?: import("@ark/schema").DivisorNode;
|
|
181
|
+
exactLength?: import("@ark/schema").ExactLengthNode;
|
|
182
|
+
max?: import("@ark/schema").MaxNode;
|
|
183
|
+
maxLength?: import("@ark/schema").MaxLengthNode;
|
|
184
|
+
min?: import("@ark/schema").MinNode;
|
|
185
|
+
minLength?: import("@ark/schema").MinLengthNode;
|
|
186
|
+
notEqual?: readonly import("@ark/schema").NotEqualNode[];
|
|
187
|
+
notEqualLength?: readonly import("@ark/schema").NotEqualLengthNode[];
|
|
188
|
+
pattern?: readonly import("@ark/schema").PatternNode[];
|
|
189
|
+
} & import("@ark/schema").WrittenErrorContext<"intersection">, "message"> & {
|
|
190
|
+
toString(never: never): string;
|
|
191
|
+
toLocaleString(never: never): string;
|
|
192
|
+
}) | (import("@ark/util").omit<{
|
|
193
|
+
code: "predicate";
|
|
194
|
+
description?: string;
|
|
195
|
+
predicate?: import("@ark/schema").Predicate;
|
|
196
|
+
morph?: import("@ark/schema").Morph;
|
|
197
|
+
cause?: unknown;
|
|
198
|
+
} & import("@ark/schema").WrittenErrorContext<"predicate">, "message"> & {
|
|
199
|
+
toString(never: never): string;
|
|
200
|
+
toLocaleString(never: never): string;
|
|
201
|
+
}) | (import("@ark/util").omit<{
|
|
202
|
+
code: "divisor";
|
|
203
|
+
description?: string;
|
|
204
|
+
rule: number;
|
|
205
|
+
} & import("@ark/schema").WrittenErrorContext<"divisor">, "message"> & {
|
|
206
|
+
toString(never: never): string;
|
|
207
|
+
toLocaleString(never: never): string;
|
|
208
|
+
}) | (import("@ark/util").omit<{
|
|
209
|
+
code: "pattern";
|
|
210
|
+
description?: string;
|
|
211
|
+
rule: string;
|
|
212
|
+
flags?: string;
|
|
213
|
+
} & import("@ark/schema").WrittenErrorContext<"pattern">, "message"> & {
|
|
214
|
+
toString(never: never): string;
|
|
215
|
+
toLocaleString(never: never): string;
|
|
216
|
+
}) | (import("@ark/util").omit<{
|
|
217
|
+
data: unknown;
|
|
218
|
+
code: "undeclared";
|
|
219
|
+
description?: string;
|
|
220
|
+
} & import("@ark/schema").WrittenErrorContext<"undeclared">, "message"> & {
|
|
221
|
+
toString(never: never): string;
|
|
222
|
+
toLocaleString(never: never): string;
|
|
223
|
+
}), locale: Locale<string>) => string;
|
|
224
|
+
};
|
|
225
|
+
readonly "string.semver": "a semantic version (see https://semver.org/)";
|
|
226
|
+
readonly "string.trim.preformatted": "trimmed";
|
|
227
|
+
readonly "string.upper.preformatted": "uppercase";
|
|
228
|
+
readonly "string.url": "a URL string";
|
|
229
|
+
readonly "string.url.parse": "a URL string";
|
|
230
|
+
readonly "string.uuid": "a UUID";
|
|
231
|
+
readonly "string.uuid.v1": "a UUIDv1";
|
|
232
|
+
readonly "string.uuid.v2": "a UUIDv2";
|
|
233
|
+
readonly "string.uuid.v3": "a UUIDv3";
|
|
234
|
+
readonly "string.uuid.v4": "a UUIDv4";
|
|
235
|
+
readonly "string.uuid.v5": "a UUIDv5";
|
|
236
|
+
readonly "string.uuid.v6": "a UUIDv6";
|
|
237
|
+
readonly "string.uuid.v7": "a UUIDv7";
|
|
238
|
+
readonly "string.uuid.v8": "a UUIDv8";
|
|
239
|
+
};
|
|
240
|
+
export type KeywordPhraseAlias = keyof typeof keywordPhrases;
|
|
241
|
+
/** meta for a node its keyword's phrase describes */
|
|
242
|
+
export declare const keywordMeta: <alias extends KeywordPhraseAlias>(alias: alias) => {
|
|
243
|
+
description: string;
|
|
244
|
+
keyword: alias;
|
|
245
|
+
};
|