arktype 2.0.0-rc.1 → 2.0.0-rc.10
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/out/config.d.ts +1 -1
- package/out/generic.d.ts +47 -48
- package/out/generic.js +6 -8
- package/out/index.d.ts +4 -4
- package/out/index.js +2 -2
- package/out/keywords/builtins.js +2 -2
- package/out/keywords/constructors/Array.d.ts +2 -2
- package/out/keywords/constructors/Array.js +7 -7
- package/out/keywords/constructors/Date.d.ts +32 -0
- package/out/keywords/constructors/FormData.d.ts +2 -2
- package/out/keywords/constructors/FormData.js +8 -8
- package/out/keywords/constructors/TypedArray.js +2 -2
- package/out/keywords/constructors/constructors.d.ts +0 -1
- package/out/keywords/constructors/constructors.js +2 -2
- package/out/keywords/inference.d.ts +227 -0
- package/out/keywords/keywords.d.ts +61 -0
- package/out/keywords/{ark.js → keywords.js} +10 -8
- package/out/keywords/number/epoch.d.ts +1 -2
- package/out/keywords/number/epoch.js +2 -2
- package/out/keywords/number/integer.js +2 -2
- package/out/keywords/number/number.d.ts +32 -6
- package/out/keywords/number/number.js +17 -5
- package/out/keywords/string/alpha.d.ts +1 -1
- package/out/keywords/string/alphanumeric.d.ts +1 -1
- package/out/keywords/string/capitalize.d.ts +2 -2
- package/out/keywords/string/capitalize.js +4 -4
- package/out/keywords/string/creditCard.d.ts +1 -1
- package/out/keywords/string/creditCard.js +2 -2
- package/out/keywords/string/date.d.ts +4 -8
- package/out/keywords/string/date.js +16 -16
- package/out/keywords/string/digits.d.ts +1 -1
- package/out/keywords/string/email.d.ts +1 -1
- package/out/keywords/string/integer.d.ts +2 -2
- package/out/keywords/string/integer.js +7 -7
- package/out/keywords/string/ip.d.ts +2 -2
- package/out/keywords/string/ip.js +5 -5
- package/out/keywords/string/json.d.ts +3 -2
- package/out/keywords/string/json.js +24 -16
- package/out/keywords/string/lower.d.ts +2 -2
- package/out/keywords/string/lower.js +4 -4
- package/out/keywords/string/normalize.d.ts +23 -27
- package/out/keywords/string/normalize.js +14 -14
- package/out/keywords/string/numeric.d.ts +2 -2
- package/out/keywords/string/numeric.js +7 -7
- package/out/keywords/string/semver.d.ts +1 -1
- package/out/keywords/string/string.d.ts +39 -42
- package/out/keywords/string/string.js +3 -3
- package/out/keywords/string/trim.d.ts +2 -2
- package/out/keywords/string/trim.js +4 -4
- package/out/keywords/string/upper.d.ts +2 -2
- package/out/keywords/string/upper.js +4 -4
- package/out/keywords/string/url.d.ts +2 -2
- package/out/keywords/string/url.js +8 -8
- package/out/keywords/string/uuid.d.ts +11 -11
- package/out/keywords/string/uuid.js +3 -3
- package/out/keywords/ts.d.ts +11 -0
- package/out/keywords/ts.js +7 -3
- package/out/keywords/utils.d.ts +1 -1
- package/out/keywords/utils.js +1 -1
- package/out/{subtypes → methods}/array.d.ts +6 -6
- package/out/methods/base.d.ts +96 -0
- package/out/{subtypes → methods}/date.d.ts +5 -5
- package/out/{subtypes → methods}/instantiate.d.ts +5 -4
- package/out/methods/morph.d.ts +12 -0
- package/out/{subtypes → methods}/number.d.ts +6 -6
- package/out/methods/object.d.ts +81 -0
- package/out/{subtypes → methods}/string.d.ts +7 -7
- package/out/{subtypes → methods}/validator.d.ts +2 -2
- package/out/module.d.ts +2 -2
- package/out/parser/{semantic → ast}/bounds.d.ts +3 -3
- package/out/parser/ast/default.d.ts +8 -0
- package/out/parser/{semantic → ast}/infer.d.ts +11 -11
- package/out/parser/{semantic → ast}/utils.d.ts +1 -1
- package/out/parser/{semantic → ast}/validate.d.ts +6 -6
- package/out/parser/definition.d.ts +8 -9
- package/out/parser/objectLiteral.d.ts +11 -37
- package/out/parser/objectLiteral.js +6 -24
- package/out/parser/{string/reduce → reduce}/dynamic.d.ts +5 -7
- package/out/parser/{string/reduce → reduce}/dynamic.js +5 -6
- package/out/parser/{string/reduce → reduce}/shared.d.ts +1 -1
- package/out/parser/{string/reduce → reduce}/static.d.ts +1 -1
- package/out/parser/{string/shift → shift}/operand/date.d.ts +3 -1
- package/out/parser/{string/shift → shift}/operand/enclosed.d.ts +3 -2
- package/out/parser/{string/shift → shift}/operand/enclosed.js +7 -3
- package/out/parser/{string/shift → shift}/operand/unenclosed.d.ts +3 -3
- package/out/parser/{string/shift → shift}/operand/unenclosed.js +7 -3
- package/out/parser/{string/shift → shift}/operator/bounds.d.ts +3 -3
- package/out/parser/{string/shift → shift}/operator/default.d.ts +3 -6
- package/out/parser/{string/shift → shift}/operator/default.js +1 -6
- package/out/parser/{string/shift → shift}/scanner.d.ts +3 -1
- package/out/parser/{string/shift → shift}/scanner.js +5 -3
- package/out/parser/{string/string.d.ts → string.d.ts} +6 -7
- package/out/parser/{string/string.js → string.js} +2 -0
- package/out/parser/tuple.d.ts +54 -43
- package/out/parser/tuple.js +36 -30
- package/out/scope.d.ts +32 -39
- package/out/scope.js +43 -35
- package/out/type.d.ts +24 -21
- package/out/type.js +14 -10
- package/package.json +3 -3
- package/out/intersect.d.ts +0 -28
- package/out/keys.d.ts +0 -16
- package/out/keywords/ark.d.ts +0 -39
- package/out/keywords/ast.d.ts +0 -193
- package/out/parser/semantic/default.d.ts +0 -9
- package/out/parser/semantic/default.js +0 -1
- package/out/subtypes/base.d.ts +0 -85
- package/out/subtypes/morph.d.ts +0 -13
- package/out/subtypes/object.d.ts +0 -33
- /package/out/{intersect.js → keywords/constructors/Date.js} +0 -0
- /package/out/keywords/{ast.js → inference.js} +0 -0
- /package/out/{subtypes → methods}/array.js +0 -0
- /package/out/{subtypes → methods}/base.js +0 -0
- /package/out/{subtypes → methods}/date.js +0 -0
- /package/out/{subtypes → methods}/instantiate.js +0 -0
- /package/out/{subtypes → methods}/morph.js +0 -0
- /package/out/{subtypes → methods}/number.js +0 -0
- /package/out/{subtypes → methods}/object.js +0 -0
- /package/out/{subtypes → methods}/string.js +0 -0
- /package/out/{subtypes → methods}/validator.js +0 -0
- /package/out/parser/{semantic → ast}/bounds.js +0 -0
- /package/out/{keys.js → parser/ast/default.js} +0 -0
- /package/out/parser/{semantic → ast}/divisor.d.ts +0 -0
- /package/out/parser/{semantic → ast}/divisor.js +0 -0
- /package/out/parser/{semantic → ast}/infer.js +0 -0
- /package/out/parser/{semantic → ast}/keyof.d.ts +0 -0
- /package/out/parser/{semantic → ast}/keyof.js +0 -0
- /package/out/parser/{semantic → ast}/utils.js +0 -0
- /package/out/parser/{semantic → ast}/validate.js +0 -0
- /package/out/parser/{string/reduce → reduce}/shared.js +0 -0
- /package/out/parser/{string/reduce → reduce}/static.js +0 -0
- /package/out/parser/{string/shift → shift}/operand/date.js +0 -0
- /package/out/parser/{string/shift → shift}/operand/genericArgs.d.ts +0 -0
- /package/out/parser/{string/shift → shift}/operand/genericArgs.js +0 -0
- /package/out/parser/{string/shift → shift}/operand/operand.d.ts +0 -0
- /package/out/parser/{string/shift → shift}/operand/operand.js +0 -0
- /package/out/parser/{string/shift → shift}/operator/bounds.js +0 -0
- /package/out/parser/{string/shift → shift}/operator/divisor.d.ts +0 -0
- /package/out/parser/{string/shift → shift}/operator/divisor.js +0 -0
- /package/out/parser/{string/shift → shift}/operator/operator.d.ts +0 -0
- /package/out/parser/{string/shift → shift}/operator/operator.js +0 -0
package/out/keywords/ast.d.ts
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import type { ArkError, ArkErrors, Constraint, constraintKindOf, Morph, NodeSchema } from "@ark/schema";
|
|
2
|
-
import { type anyOrNever, type array, type conform, type equals, type leftIfEqual, type Primitive, type show } from "@ark/util";
|
|
3
|
-
import type { inferPipe } from "../intersect.ts";
|
|
4
|
-
import type { Type } from "../type.ts";
|
|
5
|
-
import type { type } from "./ark.ts";
|
|
6
|
-
import type { arkPrototypes } from "./constructors/constructors.ts";
|
|
7
|
-
import type { number } from "./number/number.ts";
|
|
8
|
-
import type { string } from "./string/string.ts";
|
|
9
|
-
export type { arkPrototypes as object } from "./constructors/constructors.ts";
|
|
10
|
-
export type { number } from "./number/number.ts";
|
|
11
|
-
export type { string } from "./string/string.ts";
|
|
12
|
-
export type Comparator = "<" | "<=" | ">" | ">=" | "==";
|
|
13
|
-
export type RegexLiteral<source extends string = string> = `/${source}/`;
|
|
14
|
-
export type DateLiteral<source extends string = string> = `d"${source}"` | `d'${source}'`;
|
|
15
|
-
export type ConstraintSet = Record<PropertyKey, 1>;
|
|
16
|
-
export type Constraints = Record<string, ConstraintSet>;
|
|
17
|
-
export declare const constrained: " arkConstrained";
|
|
18
|
-
export type constrained = typeof constrained;
|
|
19
|
-
export type constrain<base, constraints extends Constraints> = base & {
|
|
20
|
-
[constrained]: constraints;
|
|
21
|
-
};
|
|
22
|
-
export type LimitLiteral = number | DateLiteral;
|
|
23
|
-
export type normalizeLimit<limit> = limit extends DateLiteral<infer source> ? source : limit extends number | string ? limit : never;
|
|
24
|
-
type constraint<rule> = {
|
|
25
|
-
[k in rule & PropertyKey]: 1;
|
|
26
|
-
};
|
|
27
|
-
export type AtLeast<rule> = {
|
|
28
|
-
atLeast: constraint<rule>;
|
|
29
|
-
};
|
|
30
|
-
export type AtMost<rule> = {
|
|
31
|
-
atMost: constraint<rule>;
|
|
32
|
-
};
|
|
33
|
-
export type MoreThan<rule> = {
|
|
34
|
-
moreThan: constraint<rule>;
|
|
35
|
-
};
|
|
36
|
-
export type LessThan<rule> = {
|
|
37
|
-
lessThan: constraint<rule>;
|
|
38
|
-
};
|
|
39
|
-
export type Literal<rule> = {
|
|
40
|
-
literal: constraint<rule>;
|
|
41
|
-
};
|
|
42
|
-
export type DivisibleBy<rule> = {
|
|
43
|
-
divisibleBy: constraint<rule>;
|
|
44
|
-
};
|
|
45
|
-
export type Length<rule> = {
|
|
46
|
-
length: constraint<rule>;
|
|
47
|
-
};
|
|
48
|
-
export type Matching<rule> = {
|
|
49
|
-
matching: constraint<rule>;
|
|
50
|
-
};
|
|
51
|
-
export type Narrowed = {
|
|
52
|
-
predicate: {
|
|
53
|
-
[k in "?"]: 1;
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
export type Branded<rule> = {
|
|
57
|
-
predicate: constraint<rule>;
|
|
58
|
-
};
|
|
59
|
-
export type primitiveConstraintKindOf<In> = Extract<Constraint.PrimitiveKind, constraintKindOf<In>>;
|
|
60
|
-
export type AtLeastLength<rule> = {
|
|
61
|
-
atLeastLength: constraint<rule>;
|
|
62
|
-
};
|
|
63
|
-
export type AtMostLength<rule> = {
|
|
64
|
-
atMostLength: constraint<rule>;
|
|
65
|
-
};
|
|
66
|
-
export type MoreThanLength<rule> = {
|
|
67
|
-
moreThanLength: constraint<rule>;
|
|
68
|
-
};
|
|
69
|
-
export type LessThanLength<rule> = {
|
|
70
|
-
lessThanLength: constraint<rule>;
|
|
71
|
-
};
|
|
72
|
-
export type ExactlyLength<rule> = {
|
|
73
|
-
atLeastLength: constraint<rule>;
|
|
74
|
-
atMostLength: constraint<rule>;
|
|
75
|
-
};
|
|
76
|
-
export type AtOrAfter<rule> = {
|
|
77
|
-
atOrAfter: constraint<rule>;
|
|
78
|
-
};
|
|
79
|
-
export type AtOrBefore<rule> = {
|
|
80
|
-
atOrBefore: constraint<rule>;
|
|
81
|
-
};
|
|
82
|
-
export type After<rule> = {
|
|
83
|
-
after: constraint<rule>;
|
|
84
|
-
};
|
|
85
|
-
export type Before<rule> = {
|
|
86
|
-
before: constraint<rule>;
|
|
87
|
-
};
|
|
88
|
-
export declare namespace Date {
|
|
89
|
-
type atOrAfter<rule> = constrain<Date, AtOrAfter<rule>>;
|
|
90
|
-
type after<rule> = constrain<Date, After<rule>>;
|
|
91
|
-
type atOrBefore<rule> = constrain<Date, AtOrBefore<rule>>;
|
|
92
|
-
type before<rule> = constrain<Date, Before<rule>>;
|
|
93
|
-
type narrowed = constrain<Date, Narrowed>;
|
|
94
|
-
type branded<rule> = constrain<Date, Branded<rule>>;
|
|
95
|
-
type literal<rule> = constrain<Date, Literal<rule>>;
|
|
96
|
-
type is<constraints extends Constraints> = constrain<Date, constraints>;
|
|
97
|
-
type parseConstraint<kind extends Constraint.PrimitiveKind, schema extends NodeSchema<kind>> = normalizePrimitiveConstraintRoot<schema> extends infer rule ? kind extends "after" ? schema extends {
|
|
98
|
-
exclusive: true;
|
|
99
|
-
} ? after<normalizeLimit<rule>> : atOrAfter<normalizeLimit<rule>> : kind extends "before" ? schema extends {
|
|
100
|
-
exclusive: true;
|
|
101
|
-
} ? before<normalizeLimit<rule>> : atOrBefore<normalizeLimit<rule>> : narrowed : never;
|
|
102
|
-
}
|
|
103
|
-
export type applyConstraint<t, kind extends Constraint.PrimitiveKind, schema extends NodeSchema<kind>> = t extends MorphAst<infer i, infer o> ? (In: leftIfEqual<i, _applyConstraint<i, kind, schema>>) => o : leftIfEqual<t, _applyConstraint<t, kind, schema>>;
|
|
104
|
-
type _applyConstraint<t, kind extends Constraint.PrimitiveKind, schema extends NodeSchema<kind>> = schemaToConstraint<kind, schema> extends infer constraint ? parseConstraints<t> extends ([
|
|
105
|
-
infer base,
|
|
106
|
-
infer constraints extends Constraints
|
|
107
|
-
]) ? [
|
|
108
|
-
number,
|
|
109
|
-
base
|
|
110
|
-
] extends [base, number] ? number.is<constraint & constraints> : [string, base] extends [base, string] ? string.is<constraint & constraints> : [Date, base] extends [base, Date] ? Date.is<constraint & constraints> : constrain<base, constraints & constraint> : [number, t] extends [t, number] ? number.parseConstraint<kind, schema> : [string, t] extends [t, string] ? string.parseConstraint<kind, schema> : [Date, t] extends [t, Date] ? Date.parseConstraint<kind, schema> : constrain<t, conform<constraint, Constraints>> : never;
|
|
111
|
-
export type parseConstraints<t> = t extends constrain<infer base, infer constraints> ? equals<t, number & {
|
|
112
|
-
[constrained]: constraints;
|
|
113
|
-
}> extends true ? [
|
|
114
|
-
number,
|
|
115
|
-
constraints
|
|
116
|
-
] : equals<t, string & {
|
|
117
|
-
[constrained]: constraints;
|
|
118
|
-
}> extends true ? [
|
|
119
|
-
string,
|
|
120
|
-
constraints
|
|
121
|
-
] : equals<t, Date & {
|
|
122
|
-
[constrained]: constraints;
|
|
123
|
-
}> extends true ? [
|
|
124
|
-
Date,
|
|
125
|
-
constraints
|
|
126
|
-
] : [base, constraints] : null;
|
|
127
|
-
export type normalizePrimitiveConstraintRoot<schema extends NodeSchema<Constraint.PrimitiveKind>> = "rule" extends keyof schema ? conform<schema["rule"], PropertyKey> : conform<schema, PropertyKey>;
|
|
128
|
-
export type schemaToConstraint<kind extends Constraint.PrimitiveKind, schema extends NodeSchema<kind>> = normalizePrimitiveConstraintRoot<schema> extends infer rule ? kind extends "pattern" ? Matching<rule> : kind extends "divisor" ? DivisibleBy<rule> : kind extends "exactLength" ? Length<rule> : kind extends "min" ? schema extends {
|
|
129
|
-
exclusive: true;
|
|
130
|
-
} ? MoreThan<rule> : AtLeast<rule> : kind extends "max" ? schema extends {
|
|
131
|
-
exclusive: true;
|
|
132
|
-
} ? LessThan<rule> : AtMost<rule> : kind extends "minLength" ? schema extends {
|
|
133
|
-
exclusive: true;
|
|
134
|
-
} ? MoreThanLength<rule> : AtLeastLength<rule> : kind extends "maxLength" ? schema extends {
|
|
135
|
-
exclusive: true;
|
|
136
|
-
} ? LessThanLength<rule> : AtMostLength<rule> : kind extends "exactLength" ? ExactlyLength<rule> : kind extends "after" ? schema extends {
|
|
137
|
-
exclusive: true;
|
|
138
|
-
} ? After<normalizeLimit<rule>> : AtOrAfter<normalizeLimit<rule>> : kind extends "before" ? schema extends {
|
|
139
|
-
exclusive: true;
|
|
140
|
-
} ? Before<normalizeLimit<rule>> : AtOrBefore<normalizeLimit<rule>> : Narrowed : never;
|
|
141
|
-
export type distillIn<t> = finalizeDistillation<t, _distill<t, "in", "base">>;
|
|
142
|
-
export type distillOut<t> = finalizeDistillation<t, _distill<t, "out", "base">>;
|
|
143
|
-
export type distillConstrainableIn<t> = finalizeDistillation<t, _distill<t, "in", "constrainable">>;
|
|
144
|
-
export type distillConstrainableOut<t> = finalizeDistillation<t, _distill<t, "out", "constrainable">>;
|
|
145
|
-
export type distillValidatedOut<t> = finalizeDistillation<t, _distill<t, "validatedOut", "constrainable">>;
|
|
146
|
-
type finalizeDistillation<t, distilled> = equals<t, distilled> extends true ? t : distilled;
|
|
147
|
-
export type includesMorphs<t> = [
|
|
148
|
-
_distill<t, "in", "constrainable">,
|
|
149
|
-
_distill<t, "out", "constrainable">
|
|
150
|
-
] extends ([
|
|
151
|
-
_distill<t, "out", "constrainable">,
|
|
152
|
-
_distill<t, "in", "constrainable">
|
|
153
|
-
]) ? false : true;
|
|
154
|
-
type IoKind = "in" | "out" | "validatedOut";
|
|
155
|
-
type DistilledKind = "base" | "constrainable";
|
|
156
|
-
type _distill<t, io extends IoKind, distilledKind extends DistilledKind> = t extends undefined ? t : [t] extends [anyOrNever] ? t : parseConstraints<t> extends ([
|
|
157
|
-
infer base,
|
|
158
|
-
infer constraints extends Constraints
|
|
159
|
-
]) ? distilledKind extends "base" ? _distill<base, io, distilledKind> : constrain<_distill<base, io, distilledKind>, constraints> : t extends TerminallyInferredObjectKind | Primitive ? t : unknown extends t ? unknown : t extends MorphAst<infer i, infer o> ? io extends "in" ? _distill<i, io, distilledKind> : io extends "validatedOut" ? o extends To<infer validatedOut> ? _distill<validatedOut, io, distilledKind> : unknown : _distill<o[1], io, distilledKind> : t extends DefaultableAst<infer t> ? _distill<t, io, distilledKind> : t extends array ? distillArray<t, io, distilledKind, []> : t extends Function ? t : {
|
|
160
|
-
[k in keyof t]: t[k];
|
|
161
|
-
} extends t ? io extends "in" ? show<{
|
|
162
|
-
[k in keyof t as k extends defaultableKeyOf<t> ? never : k]: _distill<t[k], io, distilledKind>;
|
|
163
|
-
} & {
|
|
164
|
-
[k in defaultableKeyOf<t>]?: _distill<t[k], io, distilledKind>;
|
|
165
|
-
}> : {
|
|
166
|
-
[k in keyof t]: _distill<t[k], io, distilledKind>;
|
|
167
|
-
} : t;
|
|
168
|
-
export type defaultableKeyOf<t> = {
|
|
169
|
-
[k in keyof t]: [t[k]] extends [anyOrNever] ? never : t[k] extends DefaultableAst ? k : never;
|
|
170
|
-
}[keyof t];
|
|
171
|
-
type distillArray<t extends array, io extends IoKind, constraints extends DistilledKind, prefix extends array> = _distillArray<t, io, constraints, prefix> extends infer result ? t extends unknown[] ? result : Readonly<t> : never;
|
|
172
|
-
type _distillArray<t extends array, io extends IoKind, constraints extends DistilledKind, prefix extends array> = t extends readonly [infer head, ...infer tail] ? _distillArray<tail, io, constraints, [
|
|
173
|
-
...prefix,
|
|
174
|
-
_distill<head, io, constraints>
|
|
175
|
-
]> : [...prefix, ...distillPostfix<t, io, constraints>];
|
|
176
|
-
type distillPostfix<t extends array, io extends IoKind, constraints extends DistilledKind, postfix extends array = []> = t extends readonly [...infer init, infer last] ? distillPostfix<init, io, constraints, [
|
|
177
|
-
_distill<last, io, constraints>,
|
|
178
|
-
...postfix
|
|
179
|
-
]> : [...{
|
|
180
|
-
[i in keyof t]: _distill<t[i], io, constraints>;
|
|
181
|
-
}, ...postfix];
|
|
182
|
-
/** Objects we don't want to expand during inference like Date or Promise */
|
|
183
|
-
type TerminallyInferredObjectKind = arkPrototypes.instanceOfExcluding<"Array" | "Function"> | ArkEnv.prototypes;
|
|
184
|
-
export type inferPredicate<t, predicate> = predicate extends (data: any, ...args: any[]) => data is infer narrowed ? t extends constrain<unknown, infer constraints> ? applyConstraint<constrain<narrowed, constraints>, "predicate", any> : applyConstraint<narrowed, "predicate", any> : applyConstraint<t, "predicate", any>;
|
|
185
|
-
export type constrainWithPredicate<t> = t extends constrain<unknown, infer constraints> ? applyConstraint<constrain<t, constraints>, "predicate", any> : applyConstraint<t, "predicate", any>;
|
|
186
|
-
export type inferPipes<t, pipes extends Morph[]> = pipes extends [infer head extends Morph, ...infer tail extends Morph[]] ? inferPipes<pipes[0] extends type.cast<infer tPipe> ? inferPipe<t, tPipe> : inferMorphOut<head> extends infer out ? (In: distillConstrainableIn<t>) => Out<out> : never, tail> : t;
|
|
187
|
-
export type inferMorphOut<morph extends Morph> = Exclude<ReturnType<morph>, ArkError | ArkErrors>;
|
|
188
|
-
export type Out<o = any> = ["=>", o, boolean];
|
|
189
|
-
export type To<o = any> = ["=>", o, true];
|
|
190
|
-
export type MorphAst<i = any, o extends Out = Out> = (In: i) => o;
|
|
191
|
-
export type Default<v = any> = ["=", v];
|
|
192
|
-
export type DefaultableAst<t = any, v = any> = (In?: t) => Default<v>;
|
|
193
|
-
export type termOrType<t> = t | Type<t, any>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ErrorMessage } from "@ark/util";
|
|
2
|
-
import type { inferAmbient } from "../../type.ts";
|
|
3
|
-
import type { UnitLiteral } from "../string/shift/operator/default.ts";
|
|
4
|
-
import type { inferAstOut } from "./infer.ts";
|
|
5
|
-
import type { astToString } from "./utils.ts";
|
|
6
|
-
import type { validateAst } from "./validate.ts";
|
|
7
|
-
export type validateDefault<baseAst, unitLiteral extends UnitLiteral, $, args> = validateAst<baseAst, $, args> extends infer e extends ErrorMessage ? e : inferAmbient<unitLiteral> extends inferAstOut<baseAst, $, args> ? undefined : ErrorMessage<writeUnassignableDefaultValueMessage<astToString<baseAst>, unitLiteral>>;
|
|
8
|
-
export declare const writeUnassignableDefaultValueMessage: <key extends string, message extends string>(key: key, message: message) => string;
|
|
9
|
-
export type writeUnassignableDefaultValueMessage<baseDef extends string, defaultValue extends string> = `Default value ${defaultValue} is not assignable to ${baseDef}`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const writeUnassignableDefaultValueMessage = (key, message) => `Default value at ${key} ${message}`;
|
package/out/subtypes/base.d.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import type { ArkErrors, BaseRoot, Disjoint, JsonSchema, MetaSchema, Morph, UndeclaredKeyBehavior } from "@ark/schema";
|
|
2
|
-
import type { anyOrNever, array, Callable, ErrorMessage, inferred, Json, unset } from "@ark/util";
|
|
3
|
-
import type { inferIntersection } from "../intersect.ts";
|
|
4
|
-
import type { distillConstrainableIn, distillConstrainableOut, distillIn, distillOut, distillValidatedOut, inferMorphOut, inferPipes } from "../keywords/ast.ts";
|
|
5
|
-
import type { Scope } from "../scope.ts";
|
|
6
|
-
import type { inferTypeRoot, validateTypeRoot } from "../type.ts";
|
|
7
|
-
import type { ArrayType } from "./array.ts";
|
|
8
|
-
import type { instantiateType } from "./instantiate.ts";
|
|
9
|
-
/** @ts-ignore cast variance */
|
|
10
|
-
interface Type<out t = unknown, $ = {}> extends Callable<(data: unknown) => distillOut<t> | ArkErrors> {
|
|
11
|
-
t: t;
|
|
12
|
-
tIn: distillConstrainableIn<t>;
|
|
13
|
-
tOut: distillConstrainableOut<t>;
|
|
14
|
-
tValidatedOut: distillValidatedOut<t>;
|
|
15
|
-
infer: distillOut<t>;
|
|
16
|
-
inferIn: distillIn<t>;
|
|
17
|
-
[inferred]: t;
|
|
18
|
-
json: Json;
|
|
19
|
-
toJsonSchema(): JsonSchema;
|
|
20
|
-
description: string;
|
|
21
|
-
expression: string;
|
|
22
|
-
internal: BaseRoot;
|
|
23
|
-
$: Scope<$>;
|
|
24
|
-
assert(data: unknown): this["infer"];
|
|
25
|
-
allows(data: unknown): data is this["inferIn"];
|
|
26
|
-
traverse(data: unknown): distillOut<t> | ArkErrors;
|
|
27
|
-
configure(meta: MetaSchema): this;
|
|
28
|
-
describe(description: string): this;
|
|
29
|
-
onUndeclaredKey(behavior: UndeclaredKeyBehavior): this;
|
|
30
|
-
onDeepUndeclaredKey(behavior: UndeclaredKeyBehavior): this;
|
|
31
|
-
from(literal: this["inferIn"]): this["infer"];
|
|
32
|
-
as<t = unset>(...args: validateChainedAsArgs<t>): instantiateType<t, $>;
|
|
33
|
-
get in(): instantiateType<this["tIn"], $>;
|
|
34
|
-
get out(): instantiateType<this["tValidatedOut"], $>;
|
|
35
|
-
intersect<const def, r = inferTypeRoot<def, $>>(def: validateTypeRoot<def, $>): instantiateType<inferIntersection<t, r>, $> | Disjoint;
|
|
36
|
-
and<const def, r = inferTypeRoot<def, $>>(def: validateTypeRoot<def, $>): instantiateType<inferIntersection<t, r>, $>;
|
|
37
|
-
or<const def, r = inferTypeRoot<def, $>>(def: validateTypeRoot<def, $>): instantiateType<t | r, $>;
|
|
38
|
-
array(): ArrayType<t[], $>;
|
|
39
|
-
pipe: ChainedPipes<t, $>;
|
|
40
|
-
equals<def>(def: validateTypeRoot<def, $>): this is instantiateType<inferTypeRoot<def, $>, $>;
|
|
41
|
-
extract<def>(r: validateTypeRoot<def, $>): instantiateType<Extract<t, inferTypeRoot<def, $>>, $>;
|
|
42
|
-
exclude<def>(r: validateTypeRoot<def, $>): instantiateType<Exclude<t, inferTypeRoot<def, $>>, $>;
|
|
43
|
-
extends<def>(other: validateTypeRoot<def, $>): this is instantiateType<inferTypeRoot<def, $>, $>;
|
|
44
|
-
overlaps<def>(r: validateTypeRoot<def, $>): boolean;
|
|
45
|
-
distribute<mapOut, reduceOut = mapOut[]>(mapBranch: (branch: Type, i: number, branches: array<Type>) => mapOut, reduceMapped?: (mappedBranches: mapOut[]) => reduceOut): reduceOut;
|
|
46
|
-
/** @deprecated */
|
|
47
|
-
apply: Function["apply"];
|
|
48
|
-
/** @deprecated */
|
|
49
|
-
bind: Function["bind"];
|
|
50
|
-
/** @deprecated */
|
|
51
|
-
call: Function["call"];
|
|
52
|
-
/** @deprecated */
|
|
53
|
-
caller: Function;
|
|
54
|
-
/** @deprecated */
|
|
55
|
-
length: number;
|
|
56
|
-
/** @deprecated */
|
|
57
|
-
name: string;
|
|
58
|
-
/** @deprecated */
|
|
59
|
-
prototype: Function["prototype"];
|
|
60
|
-
/** @deprecated */
|
|
61
|
-
arguments: Function["arguments"];
|
|
62
|
-
/** @deprecated */
|
|
63
|
-
Symbol: never;
|
|
64
|
-
}
|
|
65
|
-
interface ChainedPipeSignature<t, $> {
|
|
66
|
-
<a extends Morph<distillOut<t>>, r = instantiateType<inferPipes<t, [a]>, $>>(a: a): r;
|
|
67
|
-
<a extends Morph<distillOut<t>>, b extends Morph<inferMorphOut<a>>, r = instantiateType<inferPipes<t, [a, b]>, $>>(a: a, b: b): r;
|
|
68
|
-
<a extends Morph<distillOut<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, r = instantiateType<inferPipes<t, [a, b, c]>, $>>(a: a, b: b, c: c): r;
|
|
69
|
-
<a extends Morph<distillOut<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, r = instantiateType<inferPipes<t, [a, b, c, d]>, $>>(a: a, b: b, c: c, d: d): r;
|
|
70
|
-
<a extends Morph<distillOut<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, r = instantiateType<inferPipes<t, [a, b, c, d, e]>, $>>(a: a, b: b, c: c, d: d, e: e): r;
|
|
71
|
-
<a extends Morph<distillOut<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, r = instantiateType<inferPipes<t, [a, b, c, d, e, f]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f): r;
|
|
72
|
-
<a extends Morph<distillOut<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, g extends Morph<inferMorphOut<f>>, r = instantiateType<inferPipes<t, [a, b, c, d, e, f, g]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f, g: g): r;
|
|
73
|
-
}
|
|
74
|
-
export interface ChainedPipes<t, $> extends ChainedPipeSignature<t, $> {
|
|
75
|
-
try: ChainedPipeSignature<t, $>;
|
|
76
|
-
}
|
|
77
|
-
type validateChainedAsArgs<t> = [
|
|
78
|
-
t
|
|
79
|
-
] extends [unset] ? [
|
|
80
|
-
t
|
|
81
|
-
] extends [anyOrNever] ? [
|
|
82
|
-
] : [
|
|
83
|
-
ErrorMessage<"as requires an explicit type parameter like myType.as<t>()">
|
|
84
|
-
] : [];
|
|
85
|
-
export type { Type as BaseType };
|
package/out/subtypes/morph.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Predicate, PredicateCast } from "@ark/schema";
|
|
2
|
-
import type { inferPipe } from "../intersect.ts";
|
|
3
|
-
import type { applyConstraint, Out, To } from "../keywords/ast.ts";
|
|
4
|
-
import type { inferTypeRoot, validateTypeRoot } from "../type.ts";
|
|
5
|
-
import type { BaseType } from "./base.ts";
|
|
6
|
-
/** @ts-ignore cast variance */
|
|
7
|
-
interface Type<out t = unknown, $ = {}> extends BaseType<t, $> {
|
|
8
|
-
to<const def, r = inferTypeRoot<def, $>>(def: validateTypeRoot<def, $>): Type<inferPipe<t, r>, $>;
|
|
9
|
-
narrow<narrowed extends this["infer"] = never>(predicate: Predicate<this["infer"]> | PredicateCast<this["infer"], narrowed>): Type<([
|
|
10
|
-
narrowed
|
|
11
|
-
] extends [never] ? applyConstraint<this["tOut"], "predicate", Predicate> : narrowed) extends infer o ? this["tValidatedOut"] extends this["tOut"] ? (In: this["tIn"]) => To<o> : (In: this["tIn"]) => Out<o> : never, $>;
|
|
12
|
-
}
|
|
13
|
-
export type { Type as MorphType };
|
package/out/subtypes/object.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { array, ErrorType, merge } from "@ark/util";
|
|
2
|
-
import type { arkKeyOf, getArkKey, toArkKey } from "../keys.ts";
|
|
3
|
-
import type { type } from "../keywords/ark.ts";
|
|
4
|
-
import type { inferTypeRoot, validateTypeRoot } from "../type.ts";
|
|
5
|
-
import type { ArrayType } from "./array.ts";
|
|
6
|
-
import type { instantiateType } from "./instantiate.ts";
|
|
7
|
-
import type { ValidatorType } from "./validator.ts";
|
|
8
|
-
/** @ts-ignore cast variance */
|
|
9
|
-
interface Type<out t extends object = object, $ = {}> extends ValidatorType<t, $> {
|
|
10
|
-
readonly(): t extends array ? ArrayType<{
|
|
11
|
-
readonly [i in keyof t]: t[i];
|
|
12
|
-
}, $> : Type<{
|
|
13
|
-
readonly [k in keyof t]: t[k];
|
|
14
|
-
}, $>;
|
|
15
|
-
keyof(): instantiateType<keyof t, $>;
|
|
16
|
-
get<k1 extends arkKeyOf<t>, r = instantiateType<getArkKey<t, k1>, $>>(k1: k1 | type.cast<k1>): r;
|
|
17
|
-
get<k1 extends arkKeyOf<t>, k2 extends arkKeyOf<getArkKey<t, k1>>, r = instantiateType<getArkKey<getArkKey<t, k1>, k2>, $>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>): r;
|
|
18
|
-
get<k1 extends arkKeyOf<t>, k2 extends arkKeyOf<getArkKey<t, k1>>, k3 extends arkKeyOf<getArkKey<getArkKey<t, k1>, k2>>, r = instantiateType<getArkKey<getArkKey<getArkKey<t, k1>, k2>, k3>, $>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>, k3: k3 | type.cast<k3>): r;
|
|
19
|
-
pick<const key extends arkKeyOf<t> = never>(...keys: (key | type.cast<key>)[]): Type<{
|
|
20
|
-
[k in keyof t as Extract<toArkKey<t, k>, key>]: t[k];
|
|
21
|
-
}, $>;
|
|
22
|
-
omit<const key extends arkKeyOf<t> = never>(...keys: (key | type.cast<key>)[]): Type<{
|
|
23
|
-
[k in keyof t as Exclude<toArkKey<t, k>, key>]: t[k];
|
|
24
|
-
}, $>;
|
|
25
|
-
merge<const def, r = inferTypeRoot<def, $>>(def: validateTypeRoot<def, $> & (r extends object ? unknown : ErrorType<"Merged type must be an object", [actual: r]>)): Type<merge<t, r & object>, $>;
|
|
26
|
-
required(): Type<{
|
|
27
|
-
[k in keyof t]-?: t[k];
|
|
28
|
-
}, $>;
|
|
29
|
-
partial(): Type<{
|
|
30
|
-
[k in keyof t]?: t[k];
|
|
31
|
-
}, $>;
|
|
32
|
-
}
|
|
33
|
-
export type { Type as ObjectType };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|