arktype 2.0.0-rc.12 → 2.0.0-rc.13

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.
Files changed (34) hide show
  1. package/out/keywords/constructors/Date.d.ts +3 -3
  2. package/out/keywords/inference.d.ts +27 -21
  3. package/out/keywords/inference.js +1 -1
  4. package/out/keywords/number/number.d.ts +3 -3
  5. package/out/keywords/string/alpha.d.ts +2 -2
  6. package/out/keywords/string/alphanumeric.d.ts +2 -2
  7. package/out/keywords/string/brands.d.ts +17 -0
  8. package/out/keywords/string/capitalize.d.ts +2 -2
  9. package/out/keywords/string/creditCard.d.ts +2 -2
  10. package/out/keywords/string/date.d.ts +4 -4
  11. package/out/keywords/string/digits.d.ts +2 -2
  12. package/out/keywords/string/email.d.ts +2 -2
  13. package/out/keywords/string/integer.d.ts +2 -2
  14. package/out/keywords/string/ip.d.ts +4 -4
  15. package/out/keywords/string/json.d.ts +2 -2
  16. package/out/keywords/string/lower.d.ts +2 -2
  17. package/out/keywords/string/normalize.d.ts +5 -5
  18. package/out/keywords/string/numeric.d.ts +2 -2
  19. package/out/keywords/string/semver.d.ts +2 -2
  20. package/out/keywords/string/string.d.ts +4 -3
  21. package/out/keywords/string/trim.d.ts +2 -2
  22. package/out/keywords/string/upper.d.ts +2 -2
  23. package/out/keywords/string/url.d.ts +2 -2
  24. package/out/keywords/string/uuid.d.ts +10 -10
  25. package/out/methods/base.d.ts +16 -14
  26. package/out/methods/instantiate.d.ts +3 -3
  27. package/out/methods/morph.d.ts +2 -6
  28. package/out/methods/number.d.ts +2 -2
  29. package/out/methods/object.d.ts +5 -5
  30. package/out/methods/string.d.ts +2 -2
  31. package/out/parser/ast/infer.d.ts +2 -2
  32. package/package.json +3 -3
  33. package/out/methods/validator.d.ts +0 -11
  34. /package/out/{methods/validator.js → keywords/string/brands.js} +0 -0
@@ -1,4 +1,4 @@
1
- import type { Branded, constraint, Default, Literal, Narrowed, normalizeLimit, of, Optional } from "../inference.ts";
1
+ import type { constraint, Default, Literal, Narrowed, normalizeLimit, of, Optional, Predicate } from "../inference.ts";
2
2
  export type AtOrAfter<rule> = {
3
3
  atOrAfter: constraint<rule>;
4
4
  };
@@ -19,7 +19,7 @@ export declare namespace Date {
19
19
  type narrowed = of<Date, Narrowed>;
20
20
  type optional = of<Date, Optional>;
21
21
  type defaultsTo<rule> = of<Date, Default<rule>>;
22
- type branded<rule> = of<Date, Branded<rule>>;
22
+ type branded<rule> = of<Date, Predicate<rule>>;
23
23
  type literal<rule> = of<Date, Literal<rule>>;
24
24
  type is<attributes> = of<Date, attributes>;
25
25
  type afterSchemaToConstraint<schema, rule> = schema extends {
@@ -28,5 +28,5 @@ export declare namespace Date {
28
28
  type beforeSchemaToConstraint<schema, rule> = schema extends {
29
29
  exclusive: true;
30
30
  } ? Before<normalizeLimit<rule>> : AtOrBefore<normalizeLimit<rule>>;
31
- type applyAttribute<attribute> = attribute extends After<infer rule> ? after<rule> : attribute extends Before<infer rule> ? before<rule> : attribute extends AtOrAfter<infer rule> ? atOrAfter<rule> : attribute extends AtOrBefore<infer rule> ? atOrBefore<rule> : attribute extends Optional ? optional : attribute extends Default<infer rule> ? defaultsTo<rule> : attribute extends Branded<infer rule> ? branded<rule> : never;
31
+ type applyAttribute<attribute> = attribute extends After<infer rule> ? after<rule> : attribute extends Before<infer rule> ? before<rule> : attribute extends AtOrAfter<infer rule> ? atOrAfter<rule> : attribute extends AtOrBefore<infer rule> ? atOrBefore<rule> : attribute extends Optional ? optional : attribute extends Default<infer rule> ? defaultsTo<rule> : attribute extends Predicate<infer rule> ? branded<rule> : never;
32
32
  }
@@ -5,26 +5,33 @@ import type { arkPrototypes } from "./constructors/constructors.ts";
5
5
  import type { Date } from "./constructors/Date.ts";
6
6
  import type { type } from "./keywords.ts";
7
7
  import type { DivisibleBy, number } from "./number/number.ts";
8
- import type { Matching, string } from "./string/string.ts";
8
+ import type { brandedString, Matching, string } from "./string/string.ts";
9
9
  export type { arkPrototypes as object } from "./constructors/constructors.ts";
10
10
  export type { number } from "./number/number.ts";
11
11
  export type { string } from "./string/string.ts";
12
12
  export type Comparator = "<" | "<=" | ">" | ">=" | "==";
13
13
  export type RegexLiteral<source extends string = string> = `/${source}/`;
14
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
- default?: unknown;
18
- };
19
15
  export interface BaseAttributes {
20
- predicate?: dict<1>;
16
+ predicate?: dict;
21
17
  default?: unknown;
22
- optional?: 1;
18
+ optional?: true;
23
19
  }
24
- export declare const attributes: " arkAttributes";
25
- export type attributes = typeof attributes;
20
+ export declare const ofKey: " of";
21
+ export type ofKey = typeof ofKey;
26
22
  export type of<base, attributes> = base & {
27
- [attributes]: [base, attributes];
23
+ [ofKey]: {
24
+ base: base;
25
+ attributes: attributes;
26
+ };
27
+ };
28
+ export type brand<base, attributes> = base & {
29
+ [ofKey]: {
30
+ base: base;
31
+ attributes: attributes & {
32
+ brand: true;
33
+ };
34
+ };
28
35
  };
29
36
  export type LimitLiteral = number | DateLiteral;
30
37
  export type normalizeLimit<limit> = limit extends DateLiteral<infer source> ? source : limit extends number | string ? limit : never;
@@ -39,8 +46,8 @@ export type Narrowed = {
39
46
  "?": 1;
40
47
  };
41
48
  };
42
- export type Branded<rule> = {
43
- predicate: constraint<rule>;
49
+ export type Predicate<name> = {
50
+ predicate: constraint<name>;
44
51
  };
45
52
  export type primitiveConstraintKindOf<In> = Extract<Constraint.PrimitiveKind, constraintKindOf<In>>;
46
53
  export type AtLeastLength<rule> = {
@@ -64,7 +71,7 @@ export type applyAttribute<t, attribute> = t extends InferredMorph<infer i, infe
64
71
  type _applyAttribute<t, attribute> = t extends null | undefined ? t : t extends of<infer base, infer attributes> ? [
65
72
  number,
66
73
  base
67
- ] extends [base, number] ? number.is<attribute & attributes> : [string, base] extends [base, string] ? string.is<attribute & attributes> : [Date, base] extends [base, Date] ? Date.is<attribute & attributes> : of<base, attributes & attribute> : [number, t] extends [t, number] ? number.applyAttribute<attribute> : [string, t] extends [t, string] ? string.applyAttribute<attribute> : [Date, t] extends [t, Date] ? Date.applyAttribute<attribute> : of<t, conform<attribute, Constraints>>;
74
+ ] extends [base, number] ? number.is<attribute & attributes> : [string, base] extends [base, string] ? "brand" extends keyof attributes | keyof attribute ? brandedString.is<attribute & attributes> : string.is<attribute & attributes> : [Date, base] extends [base, Date] ? Date.is<attribute & attributes> : of<base, attributes & attribute> : [number, t] extends [t, number] ? number.applyAttribute<attribute> : [string, t] extends [t, string] ? "brand" extends keyof attribute ? brandedString.applyBrand<attribute> : string.applyAttribute<attribute> : [Date, t] extends [t, Date] ? Date.applyAttribute<attribute> : of<t, attribute>;
68
75
  export type normalizePrimitiveConstraintRoot<schema extends NodeSchema<Constraint.PrimitiveKind>> = "rule" extends keyof schema ? conform<schema["rule"], PropertyKey> : conform<schema, PropertyKey>;
69
76
  type minLengthSchemaToConstraint<schema, rule> = schema extends {
70
77
  exclusive: true;
@@ -110,7 +117,7 @@ export declare namespace distill {
110
117
  }
111
118
  }
112
119
  type finalizeDistillation<t, distilled> = equals<t, distilled> extends true ? t : distilled;
113
- type _distill<t, opts extends distill.Options> = t extends undefined ? t : [t] extends [anyOrNever] ? t : t extends of<infer base, infer attributes> ? opts["branded"] extends true ? of<_distill<base, opts>, attributes> : _distill<base, opts> : unknown extends t ? unknown : t extends TerminallyInferredObject | Primitive ? t : t extends InferredMorph<infer i, infer o> ? opts["branded"] extends true ? distillIo<i, o, opts> : distillUnbrandedIo<t, i, o, opts> : t extends array ? distillArray<t, opts> : t extends Function ? t : isSafelyMappable<t> extends true ? distillMappable<t, opts> : t;
120
+ type _distill<t, opts extends distill.Options> = t extends undefined ? t : [t] extends [anyOrNever] ? t : t extends of<infer base, infer attributes> ? opts["branded"] extends true ? of<_distill<base, opts>, attributes> : "brand" extends keyof attributes ? brand<_distill<base, opts>, attributes> : _distill<base, opts> : unknown extends t ? unknown : t extends TerminallyInferredObject | Primitive ? t : t extends InferredMorph<infer i, infer o> ? distillIo<i, o, opts> : t extends array ? distillArray<t, opts> : t extends Function ? t : isSafelyMappable<t> extends true ? distillMappable<t, opts> : t;
114
121
  type distillMappable<o, opts extends distill.Options> = opts["endpoint"] extends "in" ? show<{
115
122
  [k in keyof o as k extends inferredOptionalOrDefaultKeyOf<o> ? never : k]: _distill<o[k], opts>;
116
123
  } & {
@@ -120,18 +127,17 @@ type distillMappable<o, opts extends distill.Options> = opts["endpoint"] extends
120
127
  } & {
121
128
  [k in keyof o as k extends inferredOptionalKeyOf<o> ? k : never]?: _distill<o[k], opts>;
122
129
  }>;
123
- type distillUnbrandedIo<t extends InferredMorph, i, o extends Out, opts extends distill.Options> = t extends (InferredMorph<of<infer constrainedIn, any>, Out<of<infer constrainedOut, any>>>) ? distillIo<constrainedIn, o extends To ? To<constrainedOut> : Out<constrainedOut>, opts> : t extends InferredMorph<of<infer constrainedIn, any>> ? distillIo<constrainedIn, o, opts> : t extends InferredMorph<any, Out<of<infer constrainedOut, any>>> ? distillIo<i, o extends To ? To<constrainedOut> : Out<constrainedOut>, opts> : distillIo<i, o, opts>;
124
130
  type distillIo<i, o extends Out, opts extends distill.Options> = opts["endpoint"] extends "in" ? _distill<i, opts> : opts["endpoint"] extends "out.introspectable" ? o extends To<infer validatedOut> ? _distill<validatedOut, opts> : unknown : opts["endpoint"] extends "out" ? _distill<o[1], opts> : _distill<o[1], opts> extends infer r ? o extends To ? (In: i) => To<r> : (In: i) => Out<r> : never;
125
131
  type inferredOptionalOrDefaultKeyOf<o> = inferredDefaultKeyOf<o> | inferredOptionalKeyOf<o>;
126
- type inOfValueExtends<v, t> = [
132
+ type inExtends<v, t> = [
127
133
  v
128
- ] extends [anyOrNever] ? false : [v] extends [t] ? true : [v] extends [InferredMorph<infer i>] ? inOfValueExtends<i, t> : false;
129
- type inferredDefaultKeyOf<o> = keyof o extends infer k ? k extends keyof o ? inOfValueExtends<o[k], InferredDefault> extends true ? k : never : never : never;
130
- type inferredOptionalKeyOf<o> = keyof o extends infer k ? k extends keyof o ? inOfValueExtends<o[k], InferredOptional> extends true ? k : never : never : never;
134
+ ] extends [anyOrNever] ? false : [v] extends [t] ? true : [v] extends [InferredMorph<infer i>] ? inExtends<i, t> : false;
135
+ type inferredDefaultKeyOf<o> = keyof o extends infer k ? k extends keyof o ? inExtends<o[k], InferredDefault> extends true ? k : never : never : never;
136
+ type inferredOptionalKeyOf<o> = keyof o extends infer k ? k extends keyof o ? inExtends<o[k], InferredOptional> extends true ? k : never : never : never;
131
137
  type distillArray<t extends array, opts extends distill.Options> = t[number][] extends t ? alignReadonly<_distill<t[number], opts>[], t> : distillNonArraykeys<t, alignReadonly<_distillArray<[...t], opts, []>, t>, opts>;
132
138
  type alignReadonly<result extends unknown[], original extends array> = original extends unknown[] ? result : Readonly<result>;
133
- type distillNonArraykeys<originalArray extends array, distilledArray, opts extends distill.Options> = keyof originalArray extends keyof distilledArray | attributes ? distilledArray : distilledArray & _distill<{
134
- [k in keyof originalArray as k extends (keyof distilledArray | (opts["branded"] extends true ? never : attributes)) ? never : k]: originalArray[k];
139
+ type distillNonArraykeys<originalArray extends array, distilledArray, opts extends distill.Options> = keyof originalArray extends keyof distilledArray | ofKey ? distilledArray : distilledArray & _distill<{
140
+ [k in keyof originalArray as k extends (keyof distilledArray | (opts["branded"] extends true ? never : ofKey)) ? never : k]: originalArray[k];
135
141
  }, opts>;
136
142
  type _distillArray<t extends array, opts extends distill.Options, prefix extends array> = t extends readonly [infer head, ...infer tail] ? _distillArray<tail, opts, [...prefix, _distill<head, opts>]> : [...prefix, ...distillPostfix<t, opts>];
137
143
  type distillPostfix<t extends array, opts extends distill.Options, postfix extends array = []> = t extends readonly [...infer init, infer last] ? distillPostfix<init, opts, [_distill<last, opts>, ...postfix]> : [...{
@@ -1,2 +1,2 @@
1
1
  import { noSuggest } from "@ark/util";
2
- export const attributes = noSuggest("arkAttributes");
2
+ export const ofKey = noSuggest("of");
@@ -1,5 +1,5 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
- import type { BaseAttributes, Branded, constraint, Default, Narrowed, of, Optional } from "../inference.ts";
2
+ import type { BaseAttributes, constraint, Default, Narrowed, of, Optional, Predicate } from "../inference.ts";
3
3
  import { epoch } from "./epoch.ts";
4
4
  import { integer } from "./integer.ts";
5
5
  export declare const number: number.module;
@@ -27,7 +27,7 @@ export declare namespace number {
27
27
  type narrowed = of<number, Narrowed>;
28
28
  type optional = of<number, Optional>;
29
29
  type defaultsTo<rule> = of<number, Default<rule>>;
30
- type branded<rule> = of<number, Branded<rule>>;
30
+ type branded<rule> = of<number, Predicate<rule>>;
31
31
  interface ownConstraints extends AtLeast<number>, MoreThan<number>, LessThan<number>, AtMost<number>, DivisibleBy<number> {
32
32
  }
33
33
  interface Attributes extends BaseAttributes, Partial<ownConstraints> {
@@ -43,7 +43,7 @@ export declare namespace number {
43
43
  type maxSchemaToConstraint<schema, rule> = schema extends {
44
44
  exclusive: true;
45
45
  } ? LessThan<rule> : AtMost<rule>;
46
- type applyAttribute<attribute> = attribute extends MoreThan<infer rule> ? moreThan<rule> : attribute extends AtLeast<infer rule> ? atLeast<rule> : attribute extends AtMost<infer rule> ? atMost<rule> : attribute extends LessThan<infer rule> ? lessThan<rule> : attribute extends DivisibleBy<infer rule> ? divisibleBy<rule> : attribute extends Optional ? optional : attribute extends Default<infer rule> ? defaultsTo<rule> : attribute extends Branded<infer rule> ? branded<rule> : never;
46
+ type applyAttribute<attribute> = attribute extends MoreThan<infer rule> ? moreThan<rule> : attribute extends AtLeast<infer rule> ? atLeast<rule> : attribute extends AtMost<infer rule> ? atMost<rule> : attribute extends LessThan<infer rule> ? lessThan<rule> : attribute extends DivisibleBy<infer rule> ? divisibleBy<rule> : attribute extends Optional ? optional : attribute extends Default<infer rule> ? defaultsTo<rule> : attribute extends Predicate<infer rule> ? branded<rule> : never;
47
47
  type module = Module<submodule>;
48
48
  type submodule = Submodule<$>;
49
49
  type $ = {
@@ -1,6 +1,6 @@
1
- import type { Branded, of } from "../inference.ts";
1
+ import type { Predicate, of } from "../inference.ts";
2
2
  declare namespace string {
3
- type alpha = of<string, Branded<"alpha">>;
3
+ type alpha = of<string, Predicate<"alpha">>;
4
4
  }
5
5
  export declare const alpha: import("@ark/schema").IntersectionNode;
6
6
  export type alpha = string.alpha;
@@ -1,6 +1,6 @@
1
- import type { Branded, of } from "../inference.ts";
1
+ import type { Predicate, of } from "../inference.ts";
2
2
  declare namespace string {
3
- type alphanumeric = of<string, Branded<"alphanumeric">>;
3
+ type alphanumeric = of<string, Predicate<"alphanumeric">>;
4
4
  }
5
5
  export declare const alphanumeric: import("@ark/schema").IntersectionNode;
6
6
  export type alphanumeric = string.alphanumeric;
@@ -0,0 +1,17 @@
1
+ import type { AtLeastLength, AtMostLength, Default, ExactlyLength, LessThanLength, MoreThanLength, Narrowed, Optional, Predicate, brand } from "../inference.ts";
2
+ import type { Matching } from "./string.ts";
3
+ declare namespace string {
4
+ type atLeastLength<rule> = brand<string, AtLeastLength<rule>>;
5
+ type moreThanLength<rule> = brand<string, MoreThanLength<rule>>;
6
+ type atMostLength<rule> = brand<string, AtMostLength<rule>>;
7
+ type lessThanLength<rule> = brand<string, LessThanLength<rule>>;
8
+ type exactlyLength<rule> = brand<string, ExactlyLength<rule>>;
9
+ type matching<rule> = brand<string, Matching<rule>>;
10
+ type narrowed = brand<string, Narrowed>;
11
+ type optional = brand<string, Optional>;
12
+ type defaultsTo<rule> = brand<string, Default<rule>>;
13
+ type branded<rule> = brand<string, Predicate<rule>>;
14
+ type is<attributes> = brand<string, attributes>;
15
+ type applyBrand<attribute> = attribute extends ExactlyLength<infer rule> ? exactlyLength<rule> : attribute extends MoreThanLength<infer rule> ? moreThanLength<rule> : attribute extends AtLeastLength<infer rule> ? atLeastLength<rule> : attribute extends AtMostLength<infer rule> ? atMostLength<rule> : attribute extends LessThanLength<infer rule> ? lessThanLength<rule> : attribute extends Matching<infer rule> ? matching<rule> : attribute extends Optional ? optional : attribute extends Default<infer rule> ? defaultsTo<rule> : attribute extends Predicate<infer rule> ? branded<rule> : never;
16
+ }
17
+ export type { string as brandedString };
@@ -1,7 +1,7 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
- import type { Branded, of, To } from "../inference.ts";
2
+ import type { of, Predicate, To } from "../inference.ts";
3
3
  declare namespace string {
4
- type capitalized = of<string, Branded<"capitalized">>;
4
+ type capitalized = of<string, Predicate<"capitalized">>;
5
5
  }
6
6
  export declare const capitalize: capitalize.module;
7
7
  export declare namespace capitalize {
@@ -1,7 +1,7 @@
1
- import type { Branded, of } from "../inference.ts";
1
+ import type { Predicate, of } from "../inference.ts";
2
2
  export declare const isLuhnValid: (creditCardInput: string) => boolean;
3
3
  declare namespace string {
4
- type creditCard = of<string, Branded<"creditCard">>;
4
+ type creditCard = of<string, Predicate<"creditCard">>;
5
5
  }
6
6
  export declare const creditCard: import("@ark/schema").BaseRoot<import("@ark/schema").InternalRootDeclaration>;
7
7
  export type creditCard = string.creditCard;
@@ -1,5 +1,5 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
- import type { Branded, To, of } from "../inference.ts";
2
+ import type { Predicate, To, of } from "../inference.ts";
3
3
  type DayDelimiter = "." | "/" | "-";
4
4
  type DayPart = DayPatterns[PartKey];
5
5
  type PartKey = keyof DayPatterns;
@@ -21,10 +21,10 @@ export type DateOptions = {
21
21
  export declare const iso8601Matcher: RegExp;
22
22
  export declare const tryParseDatePattern: (data: string, opts?: DateOptions) => Date | string;
23
23
  declare namespace string {
24
- type date = of<string, Branded<"date">>;
24
+ type date = of<string, Predicate<"date">>;
25
25
  namespace date {
26
- type epoch = of<string, Branded<"date.epoch">>;
27
- type iso = of<string, Branded<"date.iso">>;
26
+ type epoch = of<string, Predicate<"date.epoch">>;
27
+ type iso = of<string, Predicate<"date.iso">>;
28
28
  }
29
29
  }
30
30
  export declare const stringDate: stringDate.module;
@@ -1,6 +1,6 @@
1
- import type { Branded, of } from "../inference.ts";
1
+ import type { Predicate, of } from "../inference.ts";
2
2
  declare namespace string {
3
- type digits = of<string, Branded<"digits">>;
3
+ type digits = of<string, Predicate<"digits">>;
4
4
  }
5
5
  export declare const digits: import("@ark/schema").IntersectionNode;
6
6
  export type digits = string.digits;
@@ -1,6 +1,6 @@
1
- import type { Branded, of } from "../inference.ts";
1
+ import type { Predicate, of } from "../inference.ts";
2
2
  declare namespace string {
3
- type email = of<string, Branded<"email">>;
3
+ type email = of<string, Predicate<"email">>;
4
4
  }
5
5
  export declare const email: import("@ark/schema").IntersectionNode;
6
6
  export type email = string.email;
@@ -1,8 +1,8 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
- import type { Branded, of, To } from "../inference.ts";
2
+ import type { of, Predicate, To } from "../inference.ts";
3
3
  import type { number } from "../number/number.ts";
4
4
  declare namespace string {
5
- type integer = of<string, Branded<"integer">>;
5
+ type integer = of<string, Predicate<"integer">>;
6
6
  }
7
7
  export declare const integer: stringInteger.module;
8
8
  export declare namespace stringInteger {
@@ -1,10 +1,10 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
- import type { Branded, of } from "../inference.ts";
2
+ import type { Predicate, of } from "../inference.ts";
3
3
  declare namespace string {
4
- type ip = of<string, Branded<"ip">>;
4
+ type ip = of<string, Predicate<"ip">>;
5
5
  namespace ip {
6
- type v4 = of<string, Branded<"ip.v4">>;
7
- type v6 = of<string, Branded<"ip.v6">>;
6
+ type v4 = of<string, Predicate<"ip.v4">>;
7
+ type v6 = of<string, Predicate<"ip.v6">>;
8
8
  }
9
9
  }
10
10
  export declare const ip: ip.module;
@@ -1,7 +1,7 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
- import type { Branded, To, of } from "../inference.ts";
2
+ import type { Predicate, To, of } from "../inference.ts";
3
3
  declare namespace string {
4
- type json = of<string, Branded<"json">>;
4
+ type json = of<string, Predicate<"json">>;
5
5
  }
6
6
  export declare const writeJsonSyntaxErrorProblem: (error: unknown) => string;
7
7
  export declare const json: stringJson.module;
@@ -1,7 +1,7 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
- import type { Branded, of, To } from "../inference.ts";
2
+ import type { of, Predicate, To } from "../inference.ts";
3
3
  declare namespace string {
4
- type lowercase = of<string, Branded<"lowercase">>;
4
+ type lowercase = of<string, Predicate<"lowercase">>;
5
5
  }
6
6
  export declare const lower: lower.module;
7
7
  export declare namespace lower {
@@ -1,12 +1,12 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
- import type { Branded, of, To } from "../inference.ts";
2
+ import type { of, Predicate, To } from "../inference.ts";
3
3
  declare namespace string {
4
4
  type normalized = normalized.NFC;
5
5
  namespace normalized {
6
- type NFC = of<string, Branded<"normalized.NFC">>;
7
- type NFD = of<string, Branded<"normalized.NFD">>;
8
- type NFKC = of<string, Branded<"normalized.NFKC">>;
9
- type NFKD = of<string, Branded<"normalized.NFKD">>;
6
+ type NFC = of<string, Predicate<"normalized.NFC">>;
7
+ type NFD = of<string, Predicate<"normalized.NFD">>;
8
+ type NFKC = of<string, Predicate<"normalized.NFKC">>;
9
+ type NFKD = of<string, Predicate<"normalized.NFKD">>;
10
10
  }
11
11
  }
12
12
  export declare const normalizedForms: readonly ["NFC", "NFD", "NFKC", "NFKD"];
@@ -1,7 +1,7 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
- import type { Branded, of, To } from "../inference.ts";
2
+ import type { of, Predicate, To } from "../inference.ts";
3
3
  declare namespace string {
4
- type numeric = of<string, Branded<"numeric">>;
4
+ type numeric = of<string, Predicate<"numeric">>;
5
5
  }
6
6
  export declare const numeric: stringNumeric.module;
7
7
  export declare namespace stringNumeric {
@@ -1,6 +1,6 @@
1
- import type { Branded, of } from "../inference.ts";
1
+ import type { Predicate, of } from "../inference.ts";
2
2
  declare namespace string {
3
- type semver = of<string, Branded<"semver">>;
3
+ type semver = of<string, Predicate<"semver">>;
4
4
  }
5
5
  export declare const semver: import("@ark/schema").IntersectionNode;
6
6
  export type semver = string.semver;
@@ -1,5 +1,5 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
- import type { AtLeastLength, AtMostLength, Branded, Default, ExactlyLength, LessThanLength, MoreThanLength, Narrowed, Optional, constraint, of } from "../inference.ts";
2
+ import type { AtLeastLength, AtMostLength, Default, ExactlyLength, LessThanLength, MoreThanLength, Narrowed, Optional, Predicate, constraint, of } from "../inference.ts";
3
3
  import { alpha } from "./alpha.ts";
4
4
  import { alphanumeric } from "./alphanumeric.ts";
5
5
  import { capitalize } from "./capitalize.ts";
@@ -80,9 +80,9 @@ export declare namespace string {
80
80
  type narrowed = of<string, Narrowed>;
81
81
  type optional = of<string, Optional>;
82
82
  type defaultsTo<rule> = of<string, Default<rule>>;
83
- type branded<rule> = of<string, Branded<rule>>;
83
+ type branded<rule> = of<string, Predicate<rule>>;
84
84
  type is<attributes> = of<string, attributes>;
85
- type applyAttribute<attribute> = attribute extends ExactlyLength<infer rule> ? exactlyLength<rule> : attribute extends MoreThanLength<infer rule> ? moreThanLength<rule> : attribute extends AtLeastLength<infer rule> ? atLeastLength<rule> : attribute extends AtMostLength<infer rule> ? atMostLength<rule> : attribute extends LessThanLength<infer rule> ? lessThanLength<rule> : attribute extends Matching<infer rule> ? matching<rule> : attribute extends Optional ? optional : attribute extends Default<infer rule> ? defaultsTo<rule> : attribute extends Branded<infer rule> ? branded<rule> : never;
85
+ type applyAttribute<attribute> = attribute extends ExactlyLength<infer rule> ? exactlyLength<rule> : attribute extends MoreThanLength<infer rule> ? moreThanLength<rule> : attribute extends AtLeastLength<infer rule> ? atLeastLength<rule> : attribute extends AtMostLength<infer rule> ? atMostLength<rule> : attribute extends LessThanLength<infer rule> ? lessThanLength<rule> : attribute extends Matching<infer rule> ? matching<rule> : attribute extends Optional ? optional : attribute extends Default<infer rule> ? defaultsTo<rule> : attribute extends Predicate<infer rule> ? branded<rule> : never;
86
86
  type module = Module<string.submodule>;
87
87
  type submodule = Submodule<$>;
88
88
  type $ = {
@@ -107,3 +107,4 @@ export declare namespace string {
107
107
  upper: upper.submodule;
108
108
  };
109
109
  }
110
+ export type { brandedString } from "./brands.ts";
@@ -1,7 +1,7 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
- import type { Branded, of, To } from "../inference.ts";
2
+ import type { of, Predicate, To } from "../inference.ts";
3
3
  declare namespace string {
4
- type trimmed = of<string, Branded<"trimmed">>;
4
+ type trimmed = of<string, Predicate<"trimmed">>;
5
5
  }
6
6
  export declare const trim: trim.module;
7
7
  export declare namespace trim {
@@ -1,7 +1,7 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
- import type { Branded, of, To } from "../inference.ts";
2
+ import type { of, Predicate, To } from "../inference.ts";
3
3
  declare namespace string {
4
- type uppercase = of<string, Branded<"uppercase">>;
4
+ type uppercase = of<string, Predicate<"uppercase">>;
5
5
  }
6
6
  export declare const upper: upper.module;
7
7
  export declare namespace upper {
@@ -1,7 +1,7 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
- import type { Branded, of, To } from "../inference.ts";
2
+ import type { of, Predicate, To } from "../inference.ts";
3
3
  declare namespace string {
4
- type url = of<string, Branded<"url">>;
4
+ type url = of<string, Predicate<"url">>;
5
5
  }
6
6
  export declare const url: url.module;
7
7
  export declare namespace url {
@@ -1,5 +1,5 @@
1
1
  import type { Module, Submodule } from "../../module.ts";
2
- import type { Branded, of } from "../inference.ts";
2
+ import type { Predicate, of } from "../inference.ts";
3
3
  export declare const uuid: Module<{
4
4
  root: import("./string.ts").string.matching<string> | "00000000-0000-0000-0000-000000000000" | "ffffffff-ffff-ffff-ffff-ffffffffffff";
5
5
  v4: unknown;
@@ -12,16 +12,16 @@ export declare const uuid: Module<{
12
12
  v8: unknown;
13
13
  }>;
14
14
  declare namespace string {
15
- type uuid = of<string, Branded<"uuid">>;
15
+ type uuid = of<string, Predicate<"uuid">>;
16
16
  namespace uuid {
17
- type v1 = of<string, Branded<"uuid.v1">>;
18
- type v2 = of<string, Branded<"uuid.v2">>;
19
- type v3 = of<string, Branded<"uuid.v3">>;
20
- type v4 = of<string, Branded<"uuid.v4">>;
21
- type v5 = of<string, Branded<"uuid.v5">>;
22
- type v6 = of<string, Branded<"uuid.v6">>;
23
- type v7 = of<string, Branded<"uuid.v7">>;
24
- type v8 = of<string, Branded<"uuid.v8">>;
17
+ type v1 = of<string, Predicate<"uuid.v1">>;
18
+ type v2 = of<string, Predicate<"uuid.v2">>;
19
+ type v3 = of<string, Predicate<"uuid.v3">>;
20
+ type v4 = of<string, Predicate<"uuid.v4">>;
21
+ type v5 = of<string, Predicate<"uuid.v5">>;
22
+ type v6 = of<string, Predicate<"uuid.v6">>;
23
+ type v7 = of<string, Predicate<"uuid.v7">>;
24
+ type v8 = of<string, Predicate<"uuid.v8">>;
25
25
  }
26
26
  }
27
27
  export declare namespace uuid {
@@ -1,13 +1,14 @@
1
- import type { ArkErrors, BaseRoot, Disjoint, JsonSchema, MetaSchema, Morph, UndeclaredKeyBehavior } from "@ark/schema";
1
+ import type { ArkErrors, BaseRoot, Disjoint, JsonSchema, MetaSchema, Morph, PredicateCast, Predicate as PredicateFn, UndeclaredKeyBehavior } from "@ark/schema";
2
2
  import type { anyOrNever, array, Callable, ErrorMessage, inferred, Json, unset } from "@ark/util";
3
3
  import type { ArkAmbient } from "../config.ts";
4
- import type { applyAttribute, Branded, Default, DefaultFor, distill, inferIntersection, inferMorphOut, inferPipes, InferredMorph, Optional, To } from "../keywords/inference.ts";
4
+ import type { applyAttribute, applyConstraintSchema, Default, DefaultFor, distill, inferIntersection, inferMorphOut, inferPipes, InferredMorph, Optional, Out, To } from "../keywords/inference.ts";
5
5
  import type { type } from "../keywords/keywords.ts";
6
6
  import type { Scope } from "../scope.ts";
7
7
  import type { ArrayType } from "./array.ts";
8
8
  import type { instantiateType } from "./instantiate.ts";
9
9
  /** @ts-ignore cast variance */
10
10
  interface Type<out t = unknown, $ = {}> extends Callable<(data: unknown) => distill.Out<t> | ArkErrors> {
11
+ [inferred]: t;
11
12
  t: t;
12
13
  infer: this["inferOut"];
13
14
  inferBrandableIn: distill.brandable.In<t>;
@@ -17,8 +18,7 @@ interface Type<out t = unknown, $ = {}> extends Callable<(data: unknown) => dist
17
18
  inferIn: distill.In<t>;
18
19
  inferredOutIsIntrospectable: t extends InferredMorph<any, infer o> ? [
19
20
  o
20
- ] extends [anyOrNever] ? true : o extends To ? true : false : true;
21
- [inferred]: t;
21
+ ] extends [anyOrNever] ? true : o extends To ? true : false : unknown extends t ? boolean : true;
22
22
  json: Json;
23
23
  toJSON(): Json;
24
24
  meta: ArkAmbient.meta;
@@ -31,30 +31,32 @@ interface Type<out t = unknown, $ = {}> extends Callable<(data: unknown) => dist
31
31
  assert(data: unknown): this["infer"];
32
32
  allows(data: unknown): data is this["inferIn"];
33
33
  traverse(data: unknown): this["infer"] | ArkErrors;
34
+ brandable(): this;
34
35
  configure(meta: MetaSchema): this;
35
36
  describe(description: string): this;
36
37
  onUndeclaredKey(behavior: UndeclaredKeyBehavior): this;
37
38
  onDeepUndeclaredKey(behavior: UndeclaredKeyBehavior): this;
38
39
  from(literal: this["inferIn"]): this["infer"];
39
40
  as<t = unset>(...args: validateChainedAsArgs<t>): instantiateType<t, $>;
40
- brand<const name extends string, r = applyAttribute<t, Branded<name>> extends infer r ? instantiateType<r, $> : never>(name: name): r;
41
41
  get in(): instantiateType<this["inferBrandableIn"], $>;
42
42
  get out(): instantiateType<this["inferIntrospectableOut"], $>;
43
- intersect<const def>(def: type.validate<def, $>): type.infer<def, $> extends infer r ? instantiateType<inferIntersection<t, r>, $> | Disjoint : never;
44
- and<const def>(def: type.validate<def, $>): type.infer<def, $> extends infer r ? instantiateType<inferIntersection<t, r>, $> : never;
45
- or<const def>(def: type.validate<def, $>): type.infer<def, $> extends infer r ? instantiateType<t | r, $> : never;
43
+ intersect<const def, r = type.infer<def, $>>(def: type.validate<def, $>): instantiateType<inferIntersection<t, r>, $> | Disjoint;
44
+ and<const def, r = type.infer<def, $>>(def: type.validate<def, $>): instantiateType<inferIntersection<t, r>, $>;
45
+ or<const def, r = type.infer<def, $>>(def: type.validate<def, $>): instantiateType<t | r, $>;
46
+ narrow<narrowed extends this["infer"] = never, r = [narrowed] extends [never] ? t extends InferredMorph<infer i, infer o> ? o extends To ? (In: i) => To<applyConstraintSchema<o[1], "predicate", PredicateFn>> : (In: i) => Out<applyConstraintSchema<o[1], "predicate", PredicateFn>> : applyConstraintSchema<t, "predicate", PredicateFn> : t extends InferredMorph<infer i, infer o> ? o extends To ? (In: i) => To<narrowed> : (In: i) => Out<narrowed> : narrowed>(predicate: PredicateFn<this["infer"]> | PredicateCast<this["infer"], narrowed>): instantiateType<r, $>;
47
+ satisfying<narrowed extends this["inferIn"] = never, r = [narrowed] extends [never] ? applyConstraintSchema<t, "predicate", PredicateFn> : t extends InferredMorph<any, infer o> ? (In: narrowed) => o : narrowed>(predicate: PredicateFn<this["inferIn"]> | PredicateCast<this["inferIn"], narrowed>): instantiateType<r, $>;
46
48
  array(): ArrayType<t[], $>;
47
49
  pipe: ChainedPipes<t, $>;
48
50
  equals<const def>(def: type.validate<def, $>): boolean;
49
- ifEquals<const def>(def: type.validate<def, $>): type.infer<def, $> extends infer r ? instantiateType<r, $> | undefined : never;
51
+ ifEquals<const def, r = type.infer<def, $>>(def: type.validate<def, $>): instantiateType<r, $> | undefined;
50
52
  extends<const def>(other: type.validate<def, $>): boolean;
51
- ifExtends<const def>(other: type.validate<def, $>): type.infer<def, $> extends infer r ? instantiateType<r, $> | undefined : never;
53
+ ifExtends<const def, r = type.infer<def, $>>(other: type.validate<def, $>): instantiateType<r, $> | undefined;
52
54
  overlaps<const def>(r: type.validate<def, $>): boolean;
53
- extract<const def>(r: type.validate<def, $>): type.infer<def, $> extends infer r ? instantiateType<Extract<t, r>, $> : never;
54
- exclude<const def>(r: type.validate<def, $>): type.infer<def, $> extends infer r ? instantiateType<Exclude<t, r>, $> : never;
55
- distribute<mapOut, reduceOut = mapOut[]>(mapBranch: (branch: Type, i: number, branches: array<Type>) => mapOut, reduceMapped?: (mappedBranches: mapOut[]) => reduceOut): NoInfer<reduceOut>;
55
+ extract<const def, r = type.infer<def, $>>(r: type.validate<def, $>): instantiateType<Extract<t, r>, $>;
56
+ exclude<const def, r = type.infer<def, $>>(r: type.validate<def, $>): instantiateType<Exclude<t, r>, $>;
57
+ distribute<mapOut, reduceOut = mapOut[]>(mapBranch: (branch: Type, i: number, branches: array<Type>) => mapOut, reduceMapped?: (mappedBranches: mapOut[]) => reduceOut): reduceOut;
56
58
  optional<r = applyAttribute<t, Optional>>(): instantiateType<r, $>;
57
- default<const value extends this["inferIn"], r = applyAttribute<t, Default<value>>>(value: DefaultFor<value>): NoInfer<instantiateType<r, $>> extends infer result ? result : never;
59
+ default<const value extends this["inferIn"], r = applyAttribute<t, Default<value>>>(value: DefaultFor<value>): instantiateType<r, $>;
58
60
  /** @deprecated */
59
61
  apply: Function["apply"];
60
62
  /** @deprecated */
@@ -7,11 +7,11 @@ import type { MorphType } from "./morph.ts";
7
7
  import type { NumberType } from "./number.ts";
8
8
  import type { ObjectType } from "./object.ts";
9
9
  import type { StringType } from "./string.ts";
10
- import type { ValidatorType } from "./validator.ts";
11
- export type instantiateType<t, $> = [
10
+ export type instantiateType<t, $> = NoInfer<_instantiateType<t, $>> extends infer r ? r : never;
11
+ export type _instantiateType<t, $> = [
12
12
  Extract<t, InferredMorph>
13
13
  ] extends [anyOrNever] ? [
14
14
  t
15
15
  ] extends [anyOrNever] ? BaseType<t, $> : [t] extends [string] ? StringType<t, $> : [t] extends [number] ? NumberType<t, $> : [t] extends [object] ? [
16
16
  t
17
- ] extends [array] ? ArrayType<t, $> : [t] extends [Date] ? DateType<t, $> : ObjectType<t, $> : unknown extends t ? BaseType<unknown, $> : ValidatorType<t, $> : MorphType<t, $>;
17
+ ] extends [array] ? ArrayType<t, $> : [t] extends [Date] ? DateType<t, $> : ObjectType<t, $> : BaseType<t, $> : MorphType<t, $>;
@@ -1,12 +1,8 @@
1
- import type { Predicate, PredicateCast } from "@ark/schema";
2
- import type { applyConstraintSchema, inferPipe, Out, To } from "../keywords/inference.ts";
1
+ import type { inferPipe } from "../keywords/inference.ts";
3
2
  import type { type } from "../keywords/keywords.ts";
4
3
  import type { BaseType } from "./base.ts";
5
4
  /** @ts-ignore cast variance */
6
5
  interface Type<out t = unknown, $ = {}> extends BaseType<t, $> {
7
- to<const def, r = type.infer<def, $>>(def: type.validate<def, $>): Type<inferPipe<t, NoInfer<r>>, $>;
8
- narrow<narrowed extends this["infer"] = never>(predicate: Predicate<this["infer"]> | PredicateCast<this["infer"], narrowed>): Type<([
9
- narrowed
10
- ] extends [never] ? applyConstraintSchema<this["inferBrandableOut"], "predicate", Predicate> : narrowed) extends infer o ? this["inferredOutIsIntrospectable"] extends true ? (In: this["inferBrandableIn"]) => To<o> : (In: this["inferBrandableIn"]) => Out<o> : never, $>;
6
+ to<const def, r = type.infer<def, $>>(def: type.validate<def, $>): Type<inferPipe<t, r>, $>;
11
7
  }
12
8
  export type { Type as MorphType };
@@ -1,8 +1,8 @@
1
1
  import type { Divisor, ExclusiveNumericRangeSchema, exclusivizeRangeSchema, InclusiveNumericRangeSchema } from "@ark/schema";
2
2
  import type { applyConstraintSchema } from "../keywords/inference.ts";
3
- import type { ValidatorType } from "./validator.ts";
3
+ import type { BaseType } from "./base.ts";
4
4
  /** @ts-ignore cast variance */
5
- interface Type<out t extends number = number, $ = {}> extends ValidatorType<t, $> {
5
+ interface Type<out t extends number = number, $ = {}> extends BaseType<t, $> {
6
6
  divisibleBy<const schema extends Divisor.Schema>(schema: schema): Type<applyConstraintSchema<t, "divisor", schema>, $>;
7
7
  atLeast<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "min", schema>, $>;
8
8
  atMost<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "max", schema>, $>;
@@ -3,26 +3,26 @@ import type { arkGet, arkIndexableOf, arkKeyOf, array, ErrorType, inferred, inte
3
3
  import type { applyAttribute, Default, of, Optional } from "../keywords/inference.ts";
4
4
  import type { type } from "../keywords/keywords.ts";
5
5
  import type { ArrayType } from "./array.ts";
6
+ import type { BaseType } from "./base.ts";
6
7
  import type { instantiateType } from "./instantiate.ts";
7
- import type { ValidatorType } from "./validator.ts";
8
8
  /** @ts-ignore cast variance */
9
- interface Type<out t extends object = object, $ = {}> extends ValidatorType<t, $> {
9
+ interface Type<out t extends object = object, $ = {}> extends BaseType<t, $> {
10
10
  readonly(): t extends array ? ArrayType<{
11
11
  readonly [i in keyof t]: t[i];
12
12
  }, $> : Type<{
13
13
  readonly [k in keyof t]: t[k];
14
14
  }, $>;
15
15
  keyof(): instantiateType<arkKeyOf<t>, $>;
16
- get<const k1 extends arkIndexableOf<t>>(k1: k1 | type.cast<k1>): instantiateType<arkGet<t, k1>, $> extends infer r ? r : never;
16
+ get<const k1 extends arkIndexableOf<t>, r = arkGet<t, k1>>(k1: k1 | type.cast<k1>): instantiateType<r, $>;
17
17
  get<const k1 extends arkIndexableOf<t>, const k2 extends arkIndexableOf<arkGet<t, k1>>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>): instantiateType<arkGet<arkGet<t, k1>, k2>, $> extends infer r ? r : never;
18
- get<const k1 extends arkIndexableOf<t>, const k2 extends arkIndexableOf<arkGet<t, k1>>, const k3 extends arkIndexableOf<arkGet<arkGet<t, k1>, k2>>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>, k3: k3 | type.cast<k3>): instantiateType<arkGet<arkGet<arkGet<t, k1>, k2>, k3>, $> extends infer r ? r : never;
18
+ get<const k1 extends arkIndexableOf<t>, const k2 extends arkIndexableOf<arkGet<t, k1>>, const k3 extends arkIndexableOf<arkGet<arkGet<t, k1>, k2>>, r = arkGet<arkGet<arkGet<t, k1>, k2>, k3>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>, k3: k3 | type.cast<k3>): instantiateType<r, $>;
19
19
  pick<const key extends arkKeyOf<t> = never>(...keys: (key | type.cast<key>)[]): Type<{
20
20
  [k in keyof t as Extract<toArkKey<t, k>, key>]: t[k];
21
21
  }, $>;
22
22
  omit<const key extends arkKeyOf<t> = never>(...keys: (key | type.cast<key>)[]): Type<{
23
23
  [k in keyof t as Exclude<toArkKey<t, k>, key>]: t[k];
24
24
  }, $>;
25
- merge<const def, r = type.infer<def, $>>(def: type.validate<def, $> & (r extends object ? unknown : ErrorType<"Merged type must be an object", [actual: r]>)): Type<merge<t, NoInfer<r & object>>, $>;
25
+ merge<const def, r = type.infer<def, $>>(def: type.validate<def, $> & (r extends object ? unknown : ErrorType<"Merged type must be an object", [actual: r]>)): Type<merge<t, r & object>, $>;
26
26
  required(): Type<{
27
27
  [k in keyof t]-?: t[k];
28
28
  }, $>;
@@ -1,8 +1,8 @@
1
1
  import type { ExactLength, ExclusiveNumericRangeSchema, exclusivizeRangeSchema, InclusiveNumericRangeSchema, Pattern } from "@ark/schema";
2
2
  import type { applyConstraintSchema } from "../keywords/inference.ts";
3
- import type { ValidatorType } from "./validator.ts";
3
+ import type { BaseType } from "./base.ts";
4
4
  /** @ts-ignore cast variance */
5
- interface Type<out t extends string = string, $ = {}> extends ValidatorType<t, $> {
5
+ interface Type<out t extends string = string, $ = {}> extends BaseType<t, $> {
6
6
  matching<const schema extends Pattern.Schema>(schema: schema): Type<applyConstraintSchema<t, "pattern", schema>, $>;
7
7
  atLeastLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "minLength", schema>, $>;
8
8
  atMostLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "maxLength", schema>, $>;
@@ -1,7 +1,7 @@
1
1
  import type { GenericAst } from "@ark/schema";
2
2
  import type { Hkt, arkKeyOf, array } from "@ark/util";
3
3
  import type { Date } from "../../keywords/constructors/Date.ts";
4
- import type { Branded, Default, LimitLiteral, Optional, applyAttribute, applyConstraintSchema, distill, inferIntersection, normalizeLimit } from "../../keywords/inference.ts";
4
+ import type { Default, LimitLiteral, Optional, Predicate, applyAttribute, applyConstraintSchema, distill, inferIntersection, normalizeLimit } from "../../keywords/inference.ts";
5
5
  import type { type } from "../../keywords/keywords.ts";
6
6
  import type { UnparsedScope } from "../../scope.ts";
7
7
  import type { inferDefinition } from "../definition.ts";
@@ -26,7 +26,7 @@ export type inferExpression<ast, $, args> = ast extends array ? ast extends Infe
26
26
  [i in keyof argAsts]: inferExpression<argAsts[i], $, args>;
27
27
  }> : inferDefinition<g["bodyDef"], resolveScope<g["$"], $>, {
28
28
  [i in keyof g["names"] & `${number}` as g["names"][i]]: inferExpression<argAsts[i & keyof argAsts], resolveScope<g["arg$"], $>, args>;
29
- }> : ast[1] extends "[]" ? inferExpression<ast[0], $, args>[] : ast[1] extends "|" ? inferExpression<ast[0], $, args> | inferExpression<ast[2], $, args> : ast[1] extends "&" ? inferIntersection<inferExpression<ast[0], $, args>, inferExpression<ast[2], $, args>> : ast[1] extends "=" ? type.infer<ast[2]> extends infer defaultValue ? applyAttribute<inferExpression<ast[0], $, args>, Default<defaultValue>> : never : ast[1] extends "#" ? applyAttribute<inferExpression<ast[0], $, args>, Branded<ast[2]>> : ast[1] extends Comparator ? ast[0] extends LimitLiteral ? brandBound<inferExpression<ast[2], $, args>, ast[1], ast[0]> : brandBound<inferExpression<ast[0], $, args>, ast[1], ast[2] & LimitLiteral> : ast[1] extends "%" ? applyConstraintSchema<inferExpression<ast[0], $, args>, "divisor", ast[2] & number> : ast[1] extends "?" ? applyAttribute<inferExpression<ast[0], $, args>, Optional> : ast[0] extends "keyof" ? arkKeyOf<inferExpression<ast[1], $, args>> : never : never;
29
+ }> : ast[1] extends "[]" ? inferExpression<ast[0], $, args>[] : ast[1] extends "|" ? inferExpression<ast[0], $, args> | inferExpression<ast[2], $, args> : ast[1] extends "&" ? inferIntersection<inferExpression<ast[0], $, args>, inferExpression<ast[2], $, args>> : ast[1] extends "=" ? type.infer<ast[2]> extends infer defaultValue ? applyAttribute<inferExpression<ast[0], $, args>, Default<defaultValue>> : never : ast[1] extends "#" ? applyAttribute<inferExpression<ast[0], $, args>, Predicate<ast[2]>> : ast[1] extends Comparator ? ast[0] extends LimitLiteral ? brandBound<inferExpression<ast[2], $, args>, ast[1], ast[0]> : brandBound<inferExpression<ast[0], $, args>, ast[1], ast[2] & LimitLiteral> : ast[1] extends "%" ? applyConstraintSchema<inferExpression<ast[0], $, args>, "divisor", ast[2] & number> : ast[1] extends "?" ? applyAttribute<inferExpression<ast[0], $, args>, Optional> : ast[0] extends "keyof" ? arkKeyOf<inferExpression<ast[1], $, args>> : never : never;
30
30
  export type brandBound<brandableIn, comparator extends Comparator, limit extends LimitLiteral> = distill.In<brandableIn> extends infer In ? comparator extends "==" ? In extends number ? limit : In extends Date ? Date.literal<normalizeLimit<limit>> : applyConstraintSchema<brandableIn, "exactLength", limit & number> : applyConstraintSchema<brandableIn, In extends number ? comparator extends MinComparator ? "min" : "max" : In extends string | array ? comparator extends MinComparator ? "minLength" : "maxLength" : comparator extends MinComparator ? "after" : "before", {
31
31
  rule: normalizeLimit<limit>;
32
32
  exclusive: comparator extends ">" | "<" ? true : false;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arktype",
3
3
  "description": "TypeScript's 1:1 validator, optimized from editor to runtime",
4
- "version": "2.0.0-rc.12",
4
+ "version": "2.0.0-rc.13",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "David Blass",
@@ -34,8 +34,8 @@
34
34
  "out"
35
35
  ],
36
36
  "dependencies": {
37
- "@ark/util": "0.14.0",
38
- "@ark/schema": "0.14.0"
37
+ "@ark/util": "0.15.0",
38
+ "@ark/schema": "0.15.0"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
@@ -1,11 +0,0 @@
1
- import type { Predicate, PredicateCast } from "@ark/schema";
2
- import type { applyConstraintSchema } from "../keywords/inference.ts";
3
- import type { BaseType } from "./base.ts";
4
- import type { instantiateType } from "./instantiate.ts";
5
- /** @ts-ignore cast variance */
6
- interface Type<out t = unknown, $ = {}> extends BaseType<t, $> {
7
- narrow<narrowed extends this["infer"] = never>(predicate: Predicate<this["infer"]> | PredicateCast<this["infer"], narrowed>): instantiateType<[
8
- narrowed
9
- ] extends [never] ? applyConstraintSchema<t, "predicate", Predicate> : narrowed, $>;
10
- }
11
- export type { Type as ValidatorType };