arktype 3.0.0-beta.0 → 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 +162 -10
- package/out/attributes.d.ts +4 -2
- package/out/checkers.d.ts +37 -2
- package/out/{chunk-Z4F45ZTE.js → chunk-2U2AWCI3.js} +3 -3
- package/out/{chunk-5NJWD7CO.js → chunk-5U2ZMDNI.js} +215 -140
- package/out/{chunk-KJ3C5GTL.js → chunk-DLWCO4RV.js} +1 -1
- package/out/{chunk-H4VRNKMB.js → chunk-E3DZXEZK.js} +1 -1
- package/out/{chunk-EJZJUYPI.js → chunk-EVCML554.js} +2 -2
- package/out/{chunk-KI2MOYNT.js → chunk-GPNK5353.js} +184 -32
- package/out/{chunk-LUXERINN.js → chunk-RAZ3TXOE.js} +40 -38
- package/out/chunk-SWOOCAHN.js +4 -0
- package/out/{chunk-ARTS74PX.js → chunk-UETB6YE2.js} +1 -1
- package/out/{chunk-JHDPSG5Y.js → chunk-UK5UGFOX.js} +6 -6
- package/out/{chunk-WEPQK3AY.js → chunk-VV6YDN2D.js} +441 -145
- package/out/codecs.js +5 -5
- package/out/config.d.ts +6 -3
- package/out/i18n.d.ts +1 -1
- package/out/i18n.js +1 -1
- package/out/index.d.ts +1 -1
- package/out/index.js +5 -5
- package/out/internal.d.ts +1 -0
- package/out/internal.js +11 -11
- package/out/island.js +2 -2
- package/out/islandDependency.js +11 -11
- package/out/keywords/functions.d.ts +24 -24
- package/out/keywords/keywords.d.ts +2 -2
- package/out/keywords/phrases.d.ts +23 -23
- package/out/keywords/ts.js +2 -2
- package/out/locale.d.ts +1 -1
- package/out/locales/de.js +1 -1
- package/out/locales/en.js +3 -3
- package/out/match.d.ts +5 -3
- package/out/mutatesInput.js +2 -2
- package/out/parser/definition.d.ts +54 -3
- package/out/parser/shift/operand/unenclosed.d.ts +3 -1
- package/out/parser/shift/operand/unresolvable.d.ts +68 -0
- package/out/parser/shift/operator/bounds.d.ts +4 -1
- package/out/runtime.d.ts +34 -25
- package/out/runtime.js +2 -2
- package/out/runtimeDevelopment.js +63 -4
- package/out/scope.d.ts +4 -4
- package/out/standalone/artifact.d.ts +4 -0
- package/out/standalone/baking.d.ts +8 -1
- package/out/standalone/sites.d.ts +6 -3
- package/out/standalone/values.d.ts +2 -0
- package/out/type.d.ts +42 -5
- package/package.json +49 -6
- package/skills/arktype/SKILL.md +211 -92
- package/skills/arktype/references/migrating.md +990 -255
- package/skills/arktype/references/precompile.md +8 -5
- package/out/chunk-EDEN5UWG.js +0 -4
|
@@ -2,7 +2,7 @@ import { type ArkErrorCode, type BaseNode, type BaseRoot, type RootUnit } from "
|
|
|
2
2
|
import { type FailureSite, type SiteContext, type UnionSite } from "@ark/schema/internal";
|
|
3
3
|
import { type Fn } from "@ark/util";
|
|
4
4
|
import type { IssueFeatures } from "./baking.ts";
|
|
5
|
-
declare const describingKeys: readonly ["expected", "actual", "
|
|
5
|
+
declare const describingKeys: readonly ["expected", "actual", "message"];
|
|
6
6
|
export declare const assertDescribed: (root: BaseRoot) => void;
|
|
7
7
|
export declare const addIssueFeatures: (features: IssueFeatures, units: readonly RootUnit[], written: readonly BaseNode[]) => void;
|
|
8
8
|
export declare const failureSites: WeakSet<object>;
|
|
@@ -10,13 +10,15 @@ export declare const issueSite: <site extends object>(site: site) => site;
|
|
|
10
10
|
export declare const isInlineSite: (site: object) => site is IssueContext;
|
|
11
11
|
export declare const isLiteralSite: (value: unknown, emitted: string) => boolean;
|
|
12
12
|
export declare const withoutStrings: (code: string) => string;
|
|
13
|
-
export declare const writeSiteOf: ({ code, description, message,
|
|
13
|
+
export declare const writeSiteOf: ({ code, description, message, c }: IssueContext, emit: (s: string) => string, writer?: string, missing?: string) => string;
|
|
14
14
|
export declare const missingDescriptionOf: (site: object) => string | undefined;
|
|
15
15
|
export interface TextContext {
|
|
16
16
|
code: ArkErrorCode;
|
|
17
17
|
description?: string | undefined;
|
|
18
18
|
/** a required key's: its value's brief, which the missing key expects */
|
|
19
19
|
missingValueDescription?: string | undefined;
|
|
20
|
+
/** a required key's: its value's meta, whose message the missing key says */
|
|
21
|
+
valueMeta?: ArkEnv.meta | undefined;
|
|
20
22
|
meta?: ArkEnv.meta | undefined;
|
|
21
23
|
}
|
|
22
24
|
type DescribingKey = (typeof describingKeys)[number];
|
|
@@ -26,9 +28,10 @@ export declare class ConfiguredWriter {
|
|
|
26
28
|
constructor(code: ArkErrorCode, k: DescribingKey);
|
|
27
29
|
}
|
|
28
30
|
export type Writer = string | Fn | ConfiguredWriter | undefined;
|
|
31
|
+
type Custom = 1 | 2;
|
|
29
32
|
export interface IssueContext extends SiteContext {
|
|
30
33
|
message?: string;
|
|
31
|
-
|
|
34
|
+
c?: Custom | undefined;
|
|
32
35
|
written?: {
|
|
33
36
|
context: object;
|
|
34
37
|
writers: Writer[];
|
|
@@ -39,6 +39,8 @@ export declare const holeNameIn: (json: unknown, seen?: Set<object>) => string |
|
|
|
39
39
|
export interface HoleCell {
|
|
40
40
|
name: string;
|
|
41
41
|
text?: string | undefined;
|
|
42
|
+
imports?: Record<string, string[]> | undefined;
|
|
43
|
+
rejects?: string | undefined;
|
|
42
44
|
}
|
|
43
45
|
export interface HoleCells {
|
|
44
46
|
comparedIds: ReadonlySet<string>;
|
package/out/type.d.ts
CHANGED
|
@@ -7,10 +7,49 @@ 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";
|
|
10
11
|
import type { ArgTwoOperator, IndexZeroOperator, TupleInfixOperator, validatePredicate } from "./parser/tupleExpressions.ts";
|
|
11
|
-
import { type InternalScope, type ModuleParser, type Scope, type ScopeParser } from "./scope.ts";
|
|
12
|
+
import { type bindThis, type InternalScope, type ModuleParser, type Scope, type ScopeParser } from "./scope.ts";
|
|
12
13
|
import type { BaseType } from "./variants/base.ts";
|
|
13
14
|
import type { instantiateType } from "./variants/instantiate.ts";
|
|
15
|
+
/**
|
|
16
|
+
* What the arguments of `type`'s second signature are checked against, wherever
|
|
17
|
+
* that has to be computed from them.
|
|
18
|
+
*
|
|
19
|
+
* It's an interface with annotated variance for the reason
|
|
20
|
+
* `validateDefinitionArgument` goes through one: completing a string
|
|
21
|
+
* argument has TypeScript infer from each parameter's type to itself, and an
|
|
22
|
+
* alias met there with a type parameter among its arguments has its variance
|
|
23
|
+
* measured. `validateParameterString`, `parseValidGenericParams` and
|
|
24
|
+
* `type.infer` each reach the whole string parser that way, at 450-670ms a
|
|
25
|
+
* completion on TypeScript 6. Indexed by a key that's deferred until `zero` is
|
|
26
|
+
* known, nothing in here is visited.
|
|
27
|
+
*
|
|
28
|
+
* The rest parameter's tuples are properties too, rather than written around
|
|
29
|
+
* an indexed property in the signature. The first call of that form then costs
|
|
30
|
+
* fewer instantiations than it did without any of this (about 2,500 against
|
|
31
|
+
* 3,000 for `type("string", "|>", "unknown")`, and against 13,500 with a morph),
|
|
32
|
+
* where a tuple in the signature costs more (3,600). Each later call costs 20 to
|
|
33
|
+
* 95 more, the price of the interface. Their elements are indexed again because
|
|
34
|
+
* TypeScript also infers to a tuple's element type from the string being
|
|
35
|
+
* completed.
|
|
36
|
+
*/
|
|
37
|
+
export interface ValidatedArgs<in out zero, in out one, in out rest extends array, in out $> {
|
|
38
|
+
params: zero extends ParameterString ? validateParameterString<zero, $> : never;
|
|
39
|
+
body: zero extends ParameterString ? validateDefinition<one, $, baseGenericConstraints<parseValidGenericParams<zero, $>>> : never;
|
|
40
|
+
predicate: validatePredicate<type.infer<zero, $>, distill.In<type.infer<zero, $>>>;
|
|
41
|
+
morph: Morph<distill.Out<type.infer<zero, $>>, unknown>;
|
|
42
|
+
operand: validateDefinition<rest[0], $, bindThis<rest[0]>>;
|
|
43
|
+
predicateRest: [
|
|
44
|
+
ValidatedArgs<zero, one, rest, $>[zero extends unknown ? "predicate" : never]
|
|
45
|
+
];
|
|
46
|
+
morphRest: [
|
|
47
|
+
ValidatedArgs<zero, one, rest, $>[zero extends unknown ? "morph" : never]
|
|
48
|
+
];
|
|
49
|
+
operandRest: [
|
|
50
|
+
ValidatedArgs<zero, one, rest, $>[zero extends unknown ? "operand" : never]
|
|
51
|
+
];
|
|
52
|
+
}
|
|
14
53
|
/** The convenience properties attached to `type` */
|
|
15
54
|
export type TypeParserAttachments = Omit<TypeParser, never>;
|
|
16
55
|
export interface TypeParser<$ = {}> extends Ark.boundTypeAttachments<$> {
|
|
@@ -22,7 +61,7 @@ export interface TypeParser<$ = {}> extends Ark.boundTypeAttachments<$> {
|
|
|
22
61
|
<const def, r = type.instantiate<def, $>>(def: type.validate<def, $>): r extends infer _ ? _ : never;
|
|
23
62
|
/**
|
|
24
63
|
* Create a {@link Generic} from a parameter string and body definition, or a
|
|
25
|
-
* {@link Type} from a [tuple expression](
|
|
64
|
+
* {@link Type} from a [tuple expression](https://arktype.io/docs/expressions)
|
|
26
65
|
* spread as this function's arguments.
|
|
27
66
|
*
|
|
28
67
|
* @param params A string like "<t, n extends number>" specifying the
|
|
@@ -35,9 +74,7 @@ export interface TypeParser<$ = {}> extends Ark.boundTypeAttachments<$> {
|
|
|
35
74
|
* @example const BoxOf = type("<t extends string | number>", { contents: "t" })
|
|
36
75
|
* @example type("string", "|", { foo: "number" })
|
|
37
76
|
*/
|
|
38
|
-
<const zero, const one, const rest extends array, r = zero extends ParameterString ? Generic<parseValidGenericParams<zero, $>, one, $> : type.instantiate<[zero, one, ...rest], $>>(_0: zero extends ParameterString ?
|
|
39
|
-
validatePredicate<type.infer<zero, $>, distill.In<type.infer<zero, $>>>
|
|
40
|
-
] : one extends "=>" ? [Morph<distill.Out<type.infer<zero, $>>, unknown>] : one extends "|>" ? [type.validate<rest[0], $>] : one extends "@" ? [TypeMeta.MappableInput, NodeSelector?] : [type.validate<rest[0], $>] : []): r extends infer _ ? _ : never;
|
|
77
|
+
<const zero, const one, const rest extends array, r = zero extends ParameterString ? Generic<parseValidGenericParams<zero, $>, one, $> : type.instantiate<[zero, one, ...rest], $>>(_0: zero extends ParameterString ? ValidatedArgs<zero, one, rest, $>[zero extends unknown ? "params" : never] : zero extends IndexZeroOperator ? zero : type.validate<zero, $>, _1: zero extends ParameterString ? ValidatedArgs<zero, one, rest, $>[zero extends unknown ? "body" : never] : zero extends "keyof" ? type.validate<one, $> : zero extends "instanceof" ? conform<one, Constructor> : zero extends "===" ? conform<one, unknown> : conform<one, ArgTwoOperator>, ..._2: zero extends ParameterString ? [] : zero extends "===" ? rest : zero extends "instanceof" ? conform<rest, readonly Constructor[]> : one extends TupleInfixOperator ? one extends ":" ? ValidatedArgs<zero, one, rest, $>[zero extends unknown ? "predicateRest" : never] : one extends "=>" ? ValidatedArgs<zero, one, rest, $>[zero extends unknown ? "morphRest" : never] : one extends "@" ? [TypeMeta.MappableInput, NodeSelector?] : ValidatedArgs<zero, one, rest, $>[zero extends unknown ? "operandRest" : never] : []): r extends infer _ ? _ : never;
|
|
41
78
|
/**
|
|
42
79
|
* An alias of the {@link ArkErrors} class, an instance of which is returned when a {@link Type}
|
|
43
80
|
* is invoked with invalid input.
|
package/package.json
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arktype",
|
|
3
3
|
"description": "TypeScript's 1:1 validator, optimized from editor to runtime",
|
|
4
|
-
"
|
|
5
|
-
|
|
4
|
+
"keywords": [
|
|
5
|
+
"typescript",
|
|
6
|
+
"validation",
|
|
7
|
+
"validator",
|
|
8
|
+
"schema",
|
|
9
|
+
"runtime",
|
|
10
|
+
"types",
|
|
11
|
+
"inference",
|
|
12
|
+
"type-safe",
|
|
13
|
+
"parser",
|
|
14
|
+
"standard-schema",
|
|
15
|
+
"json-schema",
|
|
16
|
+
"precompile"
|
|
17
|
+
],
|
|
18
|
+
"version": "3.0.0-beta.1",
|
|
19
|
+
"arkAotVersion": "0.0.1-beta.1",
|
|
6
20
|
"license": "MIT",
|
|
21
|
+
"homepage": "https://arktype.io",
|
|
7
22
|
"repository": {
|
|
8
23
|
"type": "git",
|
|
9
24
|
"url": "https://github.com/arktypeio/arktype.git",
|
|
@@ -128,6 +143,34 @@
|
|
|
128
143
|
"ark-ts": "./index.ts",
|
|
129
144
|
"default": "./out/index.js"
|
|
130
145
|
},
|
|
146
|
+
"./internal/runtime.ts": {
|
|
147
|
+
"ark-ts": "./runtime.ts",
|
|
148
|
+
"default": "./out/runtime.js"
|
|
149
|
+
},
|
|
150
|
+
"./internal/runtime.js": {
|
|
151
|
+
"ark-ts": "./runtime.ts",
|
|
152
|
+
"default": "./out/runtime.js"
|
|
153
|
+
},
|
|
154
|
+
"./internal/runtimeExports.ts": {
|
|
155
|
+
"ark-ts": "./runtimeExports.ts",
|
|
156
|
+
"types": "./out/runtimeExports.d.ts",
|
|
157
|
+
"default": "./out/runtime.js"
|
|
158
|
+
},
|
|
159
|
+
"./internal/runtimeExports.js": {
|
|
160
|
+
"ark-ts": "./runtimeExports.ts",
|
|
161
|
+
"types": "./out/runtimeExports.d.ts",
|
|
162
|
+
"default": "./out/runtime.js"
|
|
163
|
+
},
|
|
164
|
+
"./internal/checkers.ts": {
|
|
165
|
+
"ark-ts": "./checkers.ts",
|
|
166
|
+
"types": "./out/checkers.d.ts",
|
|
167
|
+
"default": "./out/runtime.js"
|
|
168
|
+
},
|
|
169
|
+
"./internal/checkers.js": {
|
|
170
|
+
"ark-ts": "./checkers.ts",
|
|
171
|
+
"types": "./out/checkers.d.ts",
|
|
172
|
+
"default": "./out/runtime.js"
|
|
173
|
+
},
|
|
131
174
|
"./internal/*.ts": {
|
|
132
175
|
"ark-ts": "./*.ts",
|
|
133
176
|
"types": "./out/*.d.ts",
|
|
@@ -144,10 +187,10 @@
|
|
|
144
187
|
"skills"
|
|
145
188
|
],
|
|
146
189
|
"dependencies": {
|
|
147
|
-
"@ark/util": "0.57.0-beta.
|
|
148
|
-
"@ark/schema": "0.57.0-beta.
|
|
149
|
-
"arkregex": "0.0.16-beta.
|
|
150
|
-
"arksets": "0.0.1-beta.
|
|
190
|
+
"@ark/util": "0.57.0-beta.1",
|
|
191
|
+
"@ark/schema": "0.57.0-beta.1",
|
|
192
|
+
"arkregex": "0.0.16-beta.1",
|
|
193
|
+
"arksets": "0.0.1-beta.1"
|
|
151
194
|
},
|
|
152
195
|
"publishConfig": {
|
|
153
196
|
"access": "public"
|