arktype 2.0.0-rc.15 → 2.0.0-rc.17

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 (55) hide show
  1. package/out/{keywords/inference.d.ts → attributes.d.ts} +143 -54
  2. package/out/attributes.js +2 -0
  3. package/out/keywords/constructors/Array.d.ts +1 -1
  4. package/out/keywords/constructors/Date.d.ts +23 -18
  5. package/out/keywords/constructors/FormData.d.ts +1 -1
  6. package/out/keywords/keywords.d.ts +4 -4
  7. package/out/keywords/number/epoch.d.ts +2 -1
  8. package/out/keywords/number/number.d.ts +28 -28
  9. package/out/keywords/string/alpha.d.ts +2 -2
  10. package/out/keywords/string/alphanumeric.d.ts +2 -2
  11. package/out/keywords/string/base64.d.ts +3 -3
  12. package/out/keywords/string/capitalize.d.ts +2 -2
  13. package/out/keywords/string/creditCard.d.ts +2 -2
  14. package/out/keywords/string/date.d.ts +4 -4
  15. package/out/keywords/string/digits.d.ts +2 -2
  16. package/out/keywords/string/email.d.ts +2 -2
  17. package/out/keywords/string/integer.d.ts +2 -2
  18. package/out/keywords/string/ip.d.ts +4 -4
  19. package/out/keywords/string/json.d.ts +2 -2
  20. package/out/keywords/string/lower.d.ts +2 -2
  21. package/out/keywords/string/normalize.d.ts +5 -5
  22. package/out/keywords/string/numeric.d.ts +2 -2
  23. package/out/keywords/string/semver.d.ts +2 -2
  24. package/out/keywords/string/string.d.ts +26 -7
  25. package/out/keywords/string/trim.d.ts +2 -2
  26. package/out/keywords/string/upper.d.ts +2 -2
  27. package/out/keywords/string/url.d.ts +2 -2
  28. package/out/keywords/string/uuid.d.ts +10 -10
  29. package/out/keywords/ts.d.ts +1 -1
  30. package/out/methods/array.d.ts +6 -6
  31. package/out/methods/base.d.ts +16 -27
  32. package/out/methods/date.d.ts +5 -5
  33. package/out/methods/instantiate.d.ts +1 -1
  34. package/out/methods/morph.d.ts +1 -1
  35. package/out/methods/number.d.ts +6 -6
  36. package/out/methods/object.d.ts +3 -3
  37. package/out/methods/string.d.ts +7 -7
  38. package/out/parser/ast/bounds.d.ts +1 -1
  39. package/out/parser/ast/infer.d.ts +8 -7
  40. package/out/parser/objectLiteral.d.ts +1 -1
  41. package/out/parser/reduce/dynamic.d.ts +1 -1
  42. package/out/parser/reduce/shared.d.ts +1 -1
  43. package/out/parser/reduce/static.d.ts +1 -1
  44. package/out/parser/shift/operand/date.d.ts +1 -1
  45. package/out/parser/shift/operand/enclosed.d.ts +2 -2
  46. package/out/parser/shift/operator/bounds.d.ts +1 -1
  47. package/out/parser/shift/operator/default.d.ts +1 -1
  48. package/out/parser/tuple.d.ts +4 -4
  49. package/out/scope.d.ts +6 -1
  50. package/out/scope.js +3 -1
  51. package/out/type.d.ts +1 -1
  52. package/package.json +3 -3
  53. package/out/keywords/inference.js +0 -2
  54. package/out/keywords/string/brands.d.ts +0 -17
  55. package/out/keywords/string/brands.js +0 -1
@@ -1,7 +1,7 @@
1
+ import type { Nominal, To, of } from "../../attributes.ts";
1
2
  import type { Module, Submodule } from "../../module.ts";
2
- import type { Predicate, To, of } from "../inference.ts";
3
3
  declare namespace string {
4
- type json = of<string, Predicate<"json">>;
4
+ type json = of<string, Nominal<"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
+ import type { Nominal, of, To } from "../../attributes.ts";
1
2
  import type { Module, Submodule } from "../../module.ts";
2
- import type { of, Predicate, To } from "../inference.ts";
3
3
  declare namespace string {
4
- type lowercase = of<string, Predicate<"lowercase">>;
4
+ type lowercase = of<string, Nominal<"lowercase">>;
5
5
  }
6
6
  export declare const lower: lower.module;
7
7
  export declare namespace lower {
@@ -1,12 +1,12 @@
1
+ import type { Nominal, of, To } from "../../attributes.ts";
1
2
  import type { Module, Submodule } from "../../module.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, 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">>;
6
+ type NFC = of<string, Nominal<"normalized.NFC">>;
7
+ type NFD = of<string, Nominal<"normalized.NFD">>;
8
+ type NFKC = of<string, Nominal<"normalized.NFKC">>;
9
+ type NFKD = of<string, Nominal<"normalized.NFKD">>;
10
10
  }
11
11
  }
12
12
  export declare const normalizedForms: readonly ["NFC", "NFD", "NFKC", "NFKD"];
@@ -1,7 +1,7 @@
1
+ import type { Nominal, of, To } from "../../attributes.ts";
1
2
  import type { Module, Submodule } from "../../module.ts";
2
- import type { of, Predicate, To } from "../inference.ts";
3
3
  declare namespace string {
4
- type numeric = of<string, Predicate<"numeric">>;
4
+ type numeric = of<string, Nominal<"numeric">>;
5
5
  }
6
6
  export declare const numeric: stringNumeric.module;
7
7
  export declare namespace stringNumeric {
@@ -1,6 +1,6 @@
1
- import type { Predicate, of } from "../inference.ts";
1
+ import type { Nominal, of } from "../../attributes.ts";
2
2
  declare namespace string {
3
- type semver = of<string, Predicate<"semver">>;
3
+ type semver = of<string, Nominal<"semver">>;
4
4
  }
5
5
  export declare const semver: import("@ark/schema").IntersectionNode;
6
6
  export type semver = string.semver;
@@ -1,5 +1,6 @@
1
+ import type { satisfy } from "@ark/util";
2
+ import type { Anonymous, AtLeastLength, AtMostLength, AttributeKind, Attributes, Default, ExactlyLength, LengthAttributeKind, LessThanLength, MoreThanLength, Nominal, Optional, brand, constraint, of } from "../../attributes.ts";
1
3
  import type { Module, Submodule } from "../../module.ts";
2
- import type { AtLeastLength, AtMostLength, Default, ExactlyLength, LessThanLength, MoreThanLength, Narrowed, Optional, Predicate, constraint, of } from "../inference.ts";
3
4
  import { alpha } from "./alpha.ts";
4
5
  import { alphanumeric } from "./alphanumeric.ts";
5
6
  import { base64 } from "./base64.ts";
@@ -20,7 +21,6 @@ import { upper } from "./upper.ts";
20
21
  import { url } from "./url.ts";
21
22
  import { uuid } from "./uuid.ts";
22
23
  export declare const string: Module<{
23
- root: unknown;
24
24
  trim: Submodule<trim.submodule>;
25
25
  normalize: Submodule<{
26
26
  root: unknown;
@@ -43,6 +43,7 @@ export declare const string: Module<{
43
43
  }>;
44
44
  alpha: unknown;
45
45
  alphanumeric: unknown;
46
+ root: unknown;
46
47
  url: Submodule<url.submodule>;
47
48
  json: Submodule<stringJson.submodule>;
48
49
  base64: Submodule<{
@@ -82,12 +83,16 @@ export declare namespace string {
82
83
  type lessThanLength<rule> = of<string, LessThanLength<rule>>;
83
84
  type exactlyLength<rule> = of<string, ExactlyLength<rule>>;
84
85
  type matching<rule> = of<string, Matching<rule>>;
85
- type narrowed = of<string, Narrowed>;
86
+ type anonymous = of<string, Anonymous>;
86
87
  type optional = of<string, Optional>;
87
88
  type defaultsTo<rule> = of<string, Default<rule>>;
88
- type branded<rule> = of<string, Predicate<rule>>;
89
- type is<attributes> = of<string, attributes>;
90
- 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;
89
+ type nominal<rule> = of<string, Nominal<rule>>;
90
+ type is<attributes extends Attributes> = of<string, attributes>;
91
+ type AttributableKind = satisfy<AttributeKind, "matching" | LengthAttributeKind>;
92
+ type withSingleAttribute<kind extends AttributableKind, value extends Attributes[kind]> = raw.withSingleAttribute<kind, value>;
93
+ namespace raw {
94
+ type withSingleAttribute<kind, value> = kind extends "nominal" ? nominal<value> : kind extends "matching" ? matching<value> : kind extends "atLeastLength" ? atLeastLength<value> : kind extends "atMostLength" ? atMostLength<value> : kind extends "moreThanLength" ? moreThanLength<value> : kind extends "lessThanLength" ? lessThanLength<value> : kind extends "optional" ? optional : kind extends "defaultsTo" ? defaultsTo<value> : never;
95
+ }
91
96
  type module = Module<string.submodule>;
92
97
  type submodule = Submodule<$>;
93
98
  type $ = {
@@ -112,5 +117,19 @@ export declare namespace string {
112
117
  lower: lower.submodule;
113
118
  upper: upper.submodule;
114
119
  };
120
+ type branded<rule> = brand<string, Nominal<rule>>;
121
+ namespace branded {
122
+ type atLeastLength<rule> = brand<string, AtLeastLength<rule>>;
123
+ type moreThanLength<rule> = brand<string, MoreThanLength<rule>>;
124
+ type atMostLength<rule> = brand<string, AtMostLength<rule>>;
125
+ type lessThanLength<rule> = brand<string, LessThanLength<rule>>;
126
+ type exactlyLength<rule> = brand<string, ExactlyLength<rule>>;
127
+ type matching<rule> = brand<string, Matching<rule>>;
128
+ type anonymous = brand<string, Anonymous>;
129
+ type is<attributes extends Attributes> = brand<string, attributes>;
130
+ type withSingleAttribute<kind extends AttributableKind, value extends Attributes[kind]> = raw.withSingleAttribute<kind, value>;
131
+ namespace raw {
132
+ type withSingleAttribute<kind, value> = kind extends "nominal" ? branded<value> : kind extends "matching" ? matching<value> : kind extends "atLeastLength" ? atLeastLength<value> : kind extends "atMostLength" ? atMostLength<value> : kind extends "moreThanLength" ? moreThanLength<value> : kind extends "lessThanLength" ? lessThanLength<value> : never;
133
+ }
134
+ }
115
135
  }
116
- export type { brandedString } from "./brands.ts";
@@ -1,7 +1,7 @@
1
+ import type { Nominal, of, To } from "../../attributes.ts";
1
2
  import type { Module, Submodule } from "../../module.ts";
2
- import type { of, Predicate, To } from "../inference.ts";
3
3
  declare namespace string {
4
- type trimmed = of<string, Predicate<"trimmed">>;
4
+ type trimmed = of<string, Nominal<"trimmed">>;
5
5
  }
6
6
  export declare const trim: trim.module;
7
7
  export declare namespace trim {
@@ -1,7 +1,7 @@
1
+ import type { Nominal, of, To } from "../../attributes.ts";
1
2
  import type { Module, Submodule } from "../../module.ts";
2
- import type { of, Predicate, To } from "../inference.ts";
3
3
  declare namespace string {
4
- type uppercase = of<string, Predicate<"uppercase">>;
4
+ type uppercase = of<string, Nominal<"uppercase">>;
5
5
  }
6
6
  export declare const upper: upper.module;
7
7
  export declare namespace upper {
@@ -1,7 +1,7 @@
1
+ import type { Nominal, of, To } from "../../attributes.ts";
1
2
  import type { Module, Submodule } from "../../module.ts";
2
- import type { of, Predicate, To } from "../inference.ts";
3
3
  declare namespace string {
4
- type url = of<string, Predicate<"url">>;
4
+ type url = of<string, Nominal<"url">>;
5
5
  }
6
6
  export declare const url: url.module;
7
7
  export declare namespace url {
@@ -1,5 +1,5 @@
1
+ import type { Nominal, of } from "../../attributes.ts";
1
2
  import type { Module, Submodule } from "../../module.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, Predicate<"uuid">>;
15
+ type uuid = of<string, Nominal<"uuid">>;
16
16
  namespace uuid {
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">>;
17
+ type v1 = of<string, Nominal<"uuid.v1">>;
18
+ type v2 = of<string, Nominal<"uuid.v2">>;
19
+ type v3 = of<string, Nominal<"uuid.v3">>;
20
+ type v4 = of<string, Nominal<"uuid.v4">>;
21
+ type v5 = of<string, Nominal<"uuid.v5">>;
22
+ type v6 = of<string, Nominal<"uuid.v6">>;
23
+ type v7 = of<string, Nominal<"uuid.v7">>;
24
+ type v8 = of<string, Nominal<"uuid.v8">>;
25
25
  }
26
26
  }
27
27
  export declare namespace uuid {
@@ -1,6 +1,6 @@
1
1
  import { Hkt, type Json, type Key, type omit, type pick, type show } from "@ark/util";
2
+ import type { To } from "../attributes.ts";
2
3
  import type { Module, Submodule } from "../module.ts";
3
- import type { To } from "./inference.ts";
4
4
  export declare const arkTsKeywords: arkTsKeywords;
5
5
  export type arkTsKeywords = Module<arkTsKeywords.$>;
6
6
  export declare namespace arkTsKeywords {
@@ -1,13 +1,13 @@
1
1
  import type { ExactLength, ExclusiveNumericRangeSchema, exclusivizeRangeSchema, InclusiveNumericRangeSchema } from "@ark/schema";
2
- import type { applyConstraintSchema } from "../keywords/inference.ts";
2
+ import type { associateAttributesFromSchema } from "../attributes.ts";
3
3
  import type { ObjectType } from "./object.ts";
4
4
  interface Type<
5
5
  /** @ts-ignore cast variance */
6
6
  out t extends readonly unknown[] = readonly unknown[], $ = {}> extends ObjectType<t, $> {
7
- atLeastLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "minLength", schema>, $>;
8
- atMostLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "maxLength", schema>, $>;
9
- moreThanLength<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "minLength", exclusivizeRangeSchema<schema>>, $>;
10
- lessThanLength<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "maxLength", exclusivizeRangeSchema<schema>>, $>;
11
- exactlyLength<const schema extends ExactLength.Schema>(schema: schema): Type<applyConstraintSchema<t, "exactLength", schema>, $>;
7
+ atLeastLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<associateAttributesFromSchema<t, "minLength", schema>, $>;
8
+ atMostLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<associateAttributesFromSchema<t, "maxLength", schema>, $>;
9
+ moreThanLength<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<associateAttributesFromSchema<t, "minLength", exclusivizeRangeSchema<schema>>, $>;
10
+ lessThanLength<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<associateAttributesFromSchema<t, "maxLength", exclusivizeRangeSchema<schema>>, $>;
11
+ exactlyLength<const schema extends ExactLength.Schema>(schema: schema): Type<associateAttributesFromSchema<t, "exactLength", schema>, $>;
12
12
  }
13
13
  export type { Type as ArrayType };
@@ -1,35 +1,20 @@
1
- import type { ArkErrors, BaseRoot, Disjoint, JsonSchema, MetaSchema, Morph, PredicateCast, Predicate as PredicateFn, UndeclaredKeyBehavior } from "@ark/schema";
1
+ import type { ArkErrors, BaseRoot, Disjoint, JsonSchema, MetaSchema, Morph, Predicate, PredicateCast, StandardSchema, UndeclaredKeyBehavior } from "@ark/schema";
2
2
  import type { anyOrNever, array, Callable, ErrorMessage, inferred, Json, unset } from "@ark/util";
3
+ import type { associateAttributes, associateAttributesFromSchema, brandAttributes, Default, DefaultFor, distill, inferIntersection, inferMorphOut, inferPipes, InferredMorph, Nominal, Optional, Out, To } from "../attributes.ts";
3
4
  import type { ArkAmbient } from "../config.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
- interface Type<out t = unknown, $ = {}> extends Callable<(data: unknown) => distill.Out<t> | ArkErrors> {
10
+ interface Type<out t = unknown, $ = {}> extends Callable<(data: unknown) => distill.Out<t> | ArkErrors, StandardSchema.ConstantProps> {
11
11
  [inferred]: t;
12
- /**
13
- * The top-level generic parameter accepted by the `Type`.\
14
- * Potentially includes morphs and subtype constraints not reflected
15
- * in the types fully-inferred input (via `inferIn`) or output (via `infer` or `inferOut`).
16
- * @example type A = type.infer<[typeof T.t, '[]']>
17
- */
18
12
  t: t;
19
- /**
20
- * A type representing the output the `Type` will return (after morphs are applied to valid input)
21
- * @example export type MyType = typeof MyType.infer
22
- * @example export interface MyType extends Identity<typeof MyType.infer> {}
23
- */
24
13
  infer: this["inferOut"];
25
- inferBrandableIn: distill.brandable.In<t>;
26
- inferBrandableOut: distill.brandable.Out<t>;
14
+ inferInWithAttributes: distill.withAttributes.In<t>;
15
+ inferOutWithAttributes: distill.withAttributes.Out<t>;
27
16
  inferIntrospectableOut: distill.introspectable.Out<t>;
28
17
  inferOut: distill.Out<t>;
29
- /**
30
- * A type representing the input the `Type` will accept (before morphs are applied)
31
- * @example export type MyTypeInput = typeof MyType.inferIn
32
- */
33
18
  inferIn: distill.In<t>;
34
19
  inferredOutIsIntrospectable: t extends InferredMorph<any, infer o> ? [
35
20
  o
@@ -57,7 +42,6 @@ interface Type<out t = unknown, $ = {}> extends Callable<(data: unknown) => dist
57
42
  */
58
43
  allows(data: unknown): data is this["inferIn"];
59
44
  traverse(data: unknown): this["infer"] | ArkErrors;
60
- brandable(): this;
61
45
  configure(meta: MetaSchema): this;
62
46
  describe(description: string): this;
63
47
  /**
@@ -84,12 +68,15 @@ interface Type<out t = unknown, $ = {}> extends Callable<(data: unknown) => dist
84
68
  * Cast the way this `Type` is inferred (has no effect at runtime).
85
69
  * const branded = type(/^a/).as<`a${string}`>() // Type<`a${string}`>
86
70
  */
87
- as<t = unset>(...args: validateChainedAsArgs<t>): instantiateType<t, $>;
71
+ as<castTo = unset>(...args: validateChainedAsArgs<castTo>): instantiateType<castTo, $>;
72
+ brand<const name extends string, r = brandAttributes<t, Nominal<name>>>(name: name): instantiateType<r, $>;
73
+ brandAttributes(): instantiateType<distill.brand<t>, $>;
74
+ unbrandAttributes(): instantiateType<distill.unbrand<t>, $>;
88
75
  /**
89
76
  * A `Type` representing the deeply-extracted input of the `Type` (before morphs are applied).
90
77
  * @example const inputT = T.in
91
78
  */
92
- get in(): instantiateType<this["inferBrandableIn"], $>;
79
+ get in(): instantiateType<this["inferInWithAttributes"], $>;
93
80
  /**
94
81
  * A `Type` representing the deeply-extracted output of the `Type` (after morphs are applied).\
95
82
  * **IMPORTANT**: If your type includes morphs, their output will likely be unknown
@@ -121,8 +108,8 @@ interface Type<out t = unknown, $ = {}> extends Callable<(data: unknown) => dist
121
108
  * @example const foo = type("string").narrow((s): s is `foo${string}` => s.startsWith('foo') || ctx.mustBe('string starting with "foo"')) // Type<"foo${string}">
122
109
  * @example const unique = type('string[]').narrow((a, ctx) => new Set(a).size === a.length || ctx.mustBe('array with unique elements'))
123
110
  */
124
- 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, $>;
125
- 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, $>;
111
+ narrow<narrowed extends this["infer"] = never, r = [narrowed] extends [never] ? t extends InferredMorph<infer i, infer o> ? o extends To ? (In: i) => To<associateAttributesFromSchema<o[1], "predicate", Predicate>> : (In: i) => Out<associateAttributesFromSchema<o[1], "predicate", Predicate>> : associateAttributesFromSchema<t, "predicate", Predicate> : t extends InferredMorph<infer i, infer o> ? o extends To ? (In: i) => To<narrowed> : (In: i) => Out<narrowed> : narrowed>(predicate: Predicate<this["infer"]> | PredicateCast<this["infer"], narrowed>): instantiateType<r, $>;
112
+ satisfying<narrowed extends this["inferIn"] = never, r = [narrowed] extends [never] ? associateAttributesFromSchema<t, "predicate", Predicate> : t extends InferredMorph<any, infer o> ? (In: narrowed) => o : narrowed>(predicate: Predicate<this["inferIn"]> | PredicateCast<this["inferIn"], narrowed>): instantiateType<r, $>;
126
113
  /**
127
114
  * Create a `Type` for array with elements of this `Type`
128
115
  * @example const T = type(/^foo/); const array = T.array() // Type<string[]>
@@ -142,7 +129,7 @@ interface Type<out t = unknown, $ = {}> extends Callable<(data: unknown) => dist
142
129
  extract<const def, r = type.infer<def, $>>(r: type.validate<def, $>): instantiateType<Extract<t, r>, $>;
143
130
  exclude<const def, r = type.infer<def, $>>(r: type.validate<def, $>): instantiateType<Exclude<t, r>, $>;
144
131
  distribute<mapOut, reduceOut = mapOut[]>(mapBranch: (branch: Type, i: number, branches: array<Type>) => mapOut, reduceMapped?: (mappedBranches: mapOut[]) => reduceOut): reduceOut;
145
- optional<r = applyAttribute<t, Optional>>(): instantiateType<r, $>;
132
+ optional<r = associateAttributes<t, Optional>>(): instantiateType<r, $>;
146
133
  /**
147
134
  * Add a default value for this `Type` when it is used as a property.\
148
135
  * Default value should be a valid input value for this `Type, or a function that returns a valid input value.\
@@ -151,7 +138,9 @@ interface Type<out t = unknown, $ = {}> extends Callable<(data: unknown) => dist
151
138
  * @example const withFactory = type({ foo: type("number[]").default(() => [1])) }); withFactory({baz: 'a'}) // { foo: [1], baz: 'a' }
152
139
  * @example const withMorph = type({ foo: type("string.numeric.parse").default("123") }); withMorph({}) // { foo: 123 }
153
140
  */
154
- default<const value extends this["inferIn"], r = applyAttribute<t, Default<value>>>(value: DefaultFor<value>): instantiateType<r, $>;
141
+ default<const value extends this["inferIn"], r = associateAttributes<t, Default<value>>>(value: DefaultFor<value>): instantiateType<r, $>;
142
+ "~validate": StandardSchema.Validator<this["inferOut"]>;
143
+ "~types": StandardSchema.Types<this["inferIn"], this["inferOut"]>;
155
144
  /** @deprecated */
156
145
  apply: Function["apply"];
157
146
  /** @deprecated */
@@ -1,11 +1,11 @@
1
1
  import type { ExclusiveDateRangeSchema, exclusivizeRangeSchema, InclusiveDateRangeSchema } from "@ark/schema";
2
- import type { applyConstraintSchema } from "../keywords/inference.ts";
2
+ import type { associateAttributesFromSchema } from "../attributes.ts";
3
3
  import type { ObjectType } from "./object.ts";
4
4
  /** @ts-ignore cast variance */
5
5
  interface Type<out t extends globalThis.Date = globalThis.Date, $ = {}> extends ObjectType<t, $> {
6
- atOrAfter<const schema extends InclusiveDateRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "after", schema>, $>;
7
- atOrBefore<const schema extends InclusiveDateRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "before", schema>, $>;
8
- laterThan<const schema extends ExclusiveDateRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "after", exclusivizeRangeSchema<schema>>, $>;
9
- earlierThan<const schema extends ExclusiveDateRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "before", exclusivizeRangeSchema<schema>>, $>;
6
+ atOrAfter<const schema extends InclusiveDateRangeSchema>(schema: schema): Type<associateAttributesFromSchema<t, "after", schema>, $>;
7
+ atOrBefore<const schema extends InclusiveDateRangeSchema>(schema: schema): Type<associateAttributesFromSchema<t, "before", schema>, $>;
8
+ laterThan<const schema extends ExclusiveDateRangeSchema>(schema: schema): Type<associateAttributesFromSchema<t, "after", exclusivizeRangeSchema<schema>>, $>;
9
+ earlierThan<const schema extends ExclusiveDateRangeSchema>(schema: schema): Type<associateAttributesFromSchema<t, "before", exclusivizeRangeSchema<schema>>, $>;
10
10
  }
11
11
  export type { Type as DateType };
@@ -1,5 +1,5 @@
1
1
  import type { anyOrNever, array } from "@ark/util";
2
- import type { InferredMorph } from "../keywords/inference.ts";
2
+ import type { InferredMorph } from "../attributes.ts";
3
3
  import type { ArrayType } from "./array.ts";
4
4
  import type { BaseType } from "./base.ts";
5
5
  import type { DateType } from "./date.ts";
@@ -1,4 +1,4 @@
1
- import type { inferPipe } from "../keywords/inference.ts";
1
+ import type { inferPipe } from "../attributes.ts";
2
2
  import type { type } from "../keywords/keywords.ts";
3
3
  import type { BaseType } from "./base.ts";
4
4
  /** @ts-ignore cast variance */
@@ -1,12 +1,12 @@
1
1
  import type { Divisor, ExclusiveNumericRangeSchema, exclusivizeRangeSchema, InclusiveNumericRangeSchema } from "@ark/schema";
2
- import type { applyConstraintSchema } from "../keywords/inference.ts";
2
+ import type { associateAttributesFromSchema } from "../attributes.ts";
3
3
  import type { BaseType } from "./base.ts";
4
4
  /** @ts-ignore cast variance */
5
5
  interface Type<out t extends number = number, $ = {}> extends BaseType<t, $> {
6
- divisibleBy<const schema extends Divisor.Schema>(schema: schema): Type<applyConstraintSchema<t, "divisor", schema>, $>;
7
- atLeast<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "min", schema>, $>;
8
- atMost<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "max", schema>, $>;
9
- moreThan<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "min", exclusivizeRangeSchema<schema>>, $>;
10
- lessThan<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "max", exclusivizeRangeSchema<schema>>, $>;
6
+ divisibleBy<const schema extends Divisor.Schema>(schema: schema): Type<associateAttributesFromSchema<t, "divisor", schema>, $>;
7
+ atLeast<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<associateAttributesFromSchema<t, "min", schema>, $>;
8
+ atMost<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<associateAttributesFromSchema<t, "max", schema>, $>;
9
+ moreThan<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<associateAttributesFromSchema<t, "min", exclusivizeRangeSchema<schema>>, $>;
10
+ lessThan<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<associateAttributesFromSchema<t, "max", exclusivizeRangeSchema<schema>>, $>;
11
11
  }
12
12
  export type { Type as NumberType };
@@ -1,6 +1,6 @@
1
1
  import type { BaseMappedPropInner, OptionalMappedPropInner, Prop } from "@ark/schema";
2
2
  import type { arkGet, arkIndexableOf, arkKeyOf, array, ErrorType, inferred, intersectUnion, Json, Key, listable, merge, optionalKeyOf, show, toArkKey } from "@ark/util";
3
- import type { applyAttribute, Default, of, Optional } from "../keywords/inference.ts";
3
+ import type { associateAttributes, Attributes, Default, of, Optional } from "../attributes.ts";
4
4
  import type { type } from "../keywords/keywords.ts";
5
5
  import type { ArrayType } from "./array.ts";
6
6
  import type { BaseType } from "./base.ts";
@@ -61,7 +61,7 @@ interface Type<out t extends object = object, $ = {}> extends BaseType<t, $> {
61
61
  props: array<typePropOf<t, $>>;
62
62
  }
63
63
  type typePropOf<o, $> = keyof o extends infer k ? k extends keyof o ? typeProp<o, k, $> : never : never;
64
- type typeProp<o, k extends keyof o, $, t = o[k] & ({} | null)> = t extends of<infer base, infer attributes> ? attributes extends Default<infer defaultValue> ? DefaultedTypeProp<k & Key, keyof attributes extends keyof Default ? base : of<base, Omit<attributes, keyof Default>>, defaultValue, $> : attributes extends Optional ? BaseTypeProp<"optional", k & Key, keyof attributes extends keyof Optional ? base : of<base, Omit<attributes, keyof Optional>>, $> : never : BaseTypeProp<k extends optionalKeyOf<o> ? "optional" : "required", k & Key, t, $>;
64
+ type typeProp<o, k extends keyof o, $, t = o[k] & ({} | null)> = t extends of<infer base, infer attributes> ? attributes extends Default<infer defaultValue> ? DefaultedTypeProp<k & Key, keyof attributes extends keyof Default ? base : of<base, Omit<attributes, keyof Default> extends (infer attributes extends Attributes) ? attributes : never>, defaultValue, $> : attributes extends Optional ? BaseTypeProp<"optional", k & Key, keyof attributes extends keyof Optional ? base : of<base, Omit<attributes, keyof Default> extends (infer attributes extends Attributes) ? attributes : never>, $> : never : BaseTypeProp<k extends optionalKeyOf<o> ? "optional" : "required", k & Key, t, $>;
65
65
  export interface BaseTypeProp<kind extends Prop.Kind = Prop.Kind, k extends Key = Key,
66
66
  /** @ts-ignore cast variance */
67
67
  out v = unknown, $ = {}> {
@@ -98,7 +98,7 @@ type fromTypeProps<t, props extends array<MappedTypeProp>> = show<{
98
98
  [prop in props[number] as Extract<applyHomomorphicOptionality<t, prop>, {
99
99
  kind: "optional";
100
100
  default: unknown;
101
- }>["key"]]: applyAttribute<prop["value"][inferred], Default<prop["default" & keyof prop]>>;
101
+ }>["key"]]: associateAttributes<prop["value"][inferred], Default<prop["default" & keyof prop]>>;
102
102
  }>;
103
103
  type applyHomomorphicOptionality<t, prop extends MappedTypeProp> = prop["kind"] extends string ? prop : prop & {
104
104
  kind: prop["key"] extends optionalKeyOf<t> ? "optional" : "required";
@@ -1,13 +1,13 @@
1
1
  import type { ExactLength, ExclusiveNumericRangeSchema, exclusivizeRangeSchema, InclusiveNumericRangeSchema, Pattern } from "@ark/schema";
2
- import type { applyConstraintSchema } from "../keywords/inference.ts";
2
+ import type { associateAttributesFromSchema } from "../attributes.ts";
3
3
  import type { BaseType } from "./base.ts";
4
4
  /** @ts-ignore cast variance */
5
5
  interface Type<out t extends string = string, $ = {}> extends BaseType<t, $> {
6
- matching<const schema extends Pattern.Schema>(schema: schema): Type<applyConstraintSchema<t, "pattern", schema>, $>;
7
- atLeastLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "minLength", schema>, $>;
8
- atMostLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "maxLength", schema>, $>;
9
- moreThanLength<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "minLength", exclusivizeRangeSchema<schema>>, $>;
10
- lessThanLength<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<applyConstraintSchema<t, "maxLength", exclusivizeRangeSchema<schema>>, $>;
11
- exactlyLength<const schema extends ExactLength.Schema>(schema: schema): Type<applyConstraintSchema<t, "exactLength", schema>, $>;
6
+ matching<const schema extends Pattern.Schema>(schema: schema): Type<associateAttributesFromSchema<t, "pattern", schema>, $>;
7
+ atLeastLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<associateAttributesFromSchema<t, "minLength", schema>, $>;
8
+ atMostLength<const schema extends InclusiveNumericRangeSchema>(schema: schema): Type<associateAttributesFromSchema<t, "maxLength", schema>, $>;
9
+ moreThanLength<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<associateAttributesFromSchema<t, "minLength", exclusivizeRangeSchema<schema>>, $>;
10
+ lessThanLength<const schema extends ExclusiveNumericRangeSchema>(schema: schema): Type<associateAttributesFromSchema<t, "maxLength", exclusivizeRangeSchema<schema>>, $>;
11
+ exactlyLength<const schema extends ExactLength.Schema>(schema: schema): Type<associateAttributesFromSchema<t, "exactLength", schema>, $>;
12
12
  }
13
13
  export type { Type as StringType };
@@ -1,6 +1,6 @@
1
1
  import type { writeUnboundableMessage } from "@ark/schema";
2
2
  import type { ErrorMessage, array, typeToString } from "@ark/util";
3
- import type { LimitLiteral } from "../../keywords/inference.ts";
3
+ import type { LimitLiteral } from "../../attributes.ts";
4
4
  import type { Comparator } from "../reduce/shared.ts";
5
5
  import type { BoundExpressionKind, writeInvalidLimitMessage } from "../shift/operator/bounds.ts";
6
6
  import type { inferAstIn } from "./infer.ts";
@@ -1,11 +1,11 @@
1
1
  import type { GenericAst } from "@ark/schema";
2
2
  import type { Hkt, arkKeyOf, array } from "@ark/util";
3
+ import type { After, AtLeast, AtLeastLength, AtMost, AtMostLength, AtOrAfter, AtOrBefore, Before, Default, DivisibleBy, ExactlyLength, LessThan, LessThanLength, LimitLiteral, MoreThan, MoreThanLength, Nominal, Optional, associateAttributes, brandAttributes, distill, inferIntersection, normalizeLimit } from "../../attributes.ts";
3
4
  import type { Date } from "../../keywords/constructors/Date.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";
8
- import type { Comparator, MinComparator } from "../reduce/shared.ts";
8
+ import type { Comparator } from "../reduce/shared.ts";
9
9
  import type { Scanner } from "../shift/scanner.ts";
10
10
  export type inferAstRoot<ast, $, args> = ast extends array ? inferExpression<ast, $, args> : never;
11
11
  export type inferAstIn<ast, $, args> = distill.In<inferAstRoot<ast, $, args>>;
@@ -26,11 +26,12 @@ 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>, 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
- 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
- rule: normalizeLimit<limit>;
32
- exclusive: comparator extends ">" | "<" ? true : false;
33
- }> : 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 ? associateAttributes<inferExpression<ast[0], $, args>, Default<defaultValue>> : never : ast[1] extends "#" ? brandAttributes<inferExpression<ast[0], $, args>, Nominal<ast[2]>> : ast[1] extends Comparator ? ast[0] extends LimitLiteral ? attachBoundAttributes<inferExpression<ast[2], $, args>, ast[1], ast[0]> : attachBoundAttributes<inferExpression<ast[0], $, args>, ast[1], ast[2] & LimitLiteral> : ast[1] extends "%" ? associateAttributes<inferExpression<ast[0], $, args>, DivisibleBy<ast[2]>> : ast[1] extends "?" ? associateAttributes<inferExpression<ast[0], $, args>, Optional> : ast[0] extends "keyof" ? arkKeyOf<inferExpression<ast[1], $, args>> : never : never;
30
+ export type attachBoundAttributes<inWithAttributes, comparator extends Comparator, limit extends LimitLiteral> = distill.In<inWithAttributes> extends infer In ? comparator extends "==" ? In extends number ? limit : In extends Date ? Date.nominal<normalizeLimit<limit>> : associateAttributes<inWithAttributes, ExactlyLength<limit>> : associateAttributes<inWithAttributes, boundToAttributes<In, comparator, limit>> : never;
31
+ export type boundToAttributes<In, comparator extends Comparator, limit extends LimitLiteral> = In extends string | array ? lengthBoundToAttributes<comparator, limit & number> : In extends Date ? dateBoundToAttributes<comparator, normalizeLimit<limit>> : numericBoundToAttributes<comparator, limit & number>;
32
+ type lengthBoundToAttributes<comparator extends Comparator, limit extends number> = comparator extends "<" ? LessThanLength<limit> : comparator extends "<=" ? AtMostLength<limit> : comparator extends ">" ? MoreThanLength<limit> : AtLeastLength<limit>;
33
+ type dateBoundToAttributes<comparator extends Comparator, limit extends string | number> = comparator extends "<" ? Before<limit> : comparator extends "<=" ? AtOrBefore<limit> : comparator extends ">" ? After<limit> : AtOrAfter<limit>;
34
+ type numericBoundToAttributes<comparator extends Comparator, limit extends number> = comparator extends "<" ? LessThan<limit> : comparator extends "<=" ? AtMost<limit> : comparator extends ">" ? MoreThan<limit> : AtLeast<limit>;
34
35
  export type PrefixOperator = "keyof" | "instanceof" | "===" | "node";
35
36
  export type PrefixExpression<operator extends PrefixOperator = PrefixOperator, operand = unknown> = [operator, operand];
36
37
  export type PostfixExpression<operator extends Scanner.PostfixToken = Scanner.PostfixToken, operand = unknown> = readonly [operand, operator];
@@ -1,6 +1,6 @@
1
1
  import { type BaseParseContext, type BaseRoot, type Index, type Optional, type Required, type UndeclaredKeyBehavior, type writeInvalidPropertyKeyMessage } from "@ark/schema";
2
2
  import { type anyOrNever, type Dict, type ErrorMessage, type ErrorType, type EscapeToken, type Key, type listable, type merge, type show } from "@ark/util";
3
- import type { of } from "../keywords/inference.ts";
3
+ import type { of } from "../attributes.ts";
4
4
  import type { astToString } from "./ast/utils.ts";
5
5
  import type { validateString } from "./ast/validate.ts";
6
6
  import type { inferDefinition, validateDefinition } from "./definition.ts";
@@ -1,6 +1,6 @@
1
1
  import type { BaseParseContext, BaseRoot } from "@ark/schema";
2
2
  import { type requireKeys } from "@ark/util";
3
- import type { LimitLiteral } from "../../keywords/inference.ts";
3
+ import type { LimitLiteral } from "../../attributes.ts";
4
4
  import type { Scanner } from "../shift/scanner.ts";
5
5
  import { type Comparator, type MinComparator, type OpenLeftBound, type StringifiablePrefixOperator } from "./shared.ts";
6
6
  type BranchState = {
@@ -1,4 +1,4 @@
1
- import type { LimitLiteral } from "../../keywords/inference.ts";
1
+ import type { LimitLiteral } from "../../attributes.ts";
2
2
  export type StringifiablePrefixOperator = "keyof";
3
3
  export declare const minComparators: {
4
4
  readonly ">": true;
@@ -1,5 +1,5 @@
1
1
  import type { Completion, ErrorMessage, defined } from "@ark/util";
2
- import type { LimitLiteral } from "../../keywords/inference.ts";
2
+ import type { LimitLiteral } from "../../attributes.ts";
3
3
  import type { Scanner } from "../shift/scanner.ts";
4
4
  import type { Comparator, InvertedComparators, MaxComparator, MinComparator, OpenLeftBound, StringifiablePrefixOperator, writeMultipleLeftBoundsMessage, writeOpenRangeMessage, writeUnclosedGroupMessage, writeUnmatchedGroupCloseMessage, writeUnpairableComparatorMessage } from "./shared.ts";
5
5
  export type StaticState = {
@@ -1,4 +1,4 @@
1
- import type { DateLiteral } from "../../../keywords/inference.ts";
1
+ import type { DateLiteral } from "../../../attributes.ts";
2
2
  export declare const isDateLiteral: (value: unknown) => value is DateLiteral;
3
3
  export declare const isValidDate: (d: Date) => boolean;
4
4
  export declare const extractDateLiteralSource: <literal extends DateLiteral>(literal: literal) => extractDateLiteralSource<literal>;
@@ -1,5 +1,5 @@
1
+ import type { string } from "../../../attributes.ts";
1
2
  import type { Date } from "../../../keywords/constructors/Date.ts";
2
- import type { string } from "../../../keywords/inference.ts";
3
3
  import type { InferredAst } from "../../ast/infer.ts";
4
4
  import type { DynamicState } from "../../reduce/dynamic.ts";
5
5
  import type { StaticState, state } from "../../reduce/static.ts";
@@ -8,7 +8,7 @@ export type StringLiteral<Text extends string = string> = DoubleQuotedStringLite
8
8
  export type DoubleQuotedStringLiteral<Text extends string = string> = `"${Text}"`;
9
9
  export type SingleQuotedStringLiteral<Text extends string = string> = `'${Text}'`;
10
10
  export declare const parseEnclosed: (s: DynamicState, enclosing: EnclosingStartToken) => void;
11
- export type parseEnclosed<s extends StaticState, enclosingStart extends EnclosingStartToken, unscanned extends string> = Scanner.shiftUntil<unscanned, EnclosingTokens[enclosingStart]> extends (Scanner.shiftResult<infer scanned, infer nextUnscanned>) ? nextUnscanned extends "" ? state.error<writeUnterminatedEnclosedMessage<scanned, enclosingStart>> : state.setRoot<s, InferredAst<enclosingStart extends EnclosingQuote ? scanned : enclosingStart extends "/" ? string.matching<scanned> : Date.literal<scanned>, `${enclosingStart}${scanned}${EnclosingTokens[enclosingStart]}`>, nextUnscanned extends Scanner.shift<string, infer unscanned> ? unscanned : ""> : never;
11
+ export type parseEnclosed<s extends StaticState, enclosingStart extends EnclosingStartToken, unscanned extends string> = Scanner.shiftUntil<unscanned, EnclosingTokens[enclosingStart]> extends (Scanner.shiftResult<infer scanned, infer nextUnscanned>) ? nextUnscanned extends "" ? state.error<writeUnterminatedEnclosedMessage<scanned, enclosingStart>> : state.setRoot<s, InferredAst<enclosingStart extends EnclosingQuote ? scanned : enclosingStart extends "/" ? string.matching<scanned> : Date.nominal<scanned>, `${enclosingStart}${scanned}${EnclosingTokens[enclosingStart]}`>, nextUnscanned extends Scanner.shift<string, infer unscanned> ? unscanned : ""> : never;
12
12
  export declare const enclosingQuote: {
13
13
  readonly "'": 1;
14
14
  readonly '"': 1;
@@ -1,6 +1,6 @@
1
1
  import { type BaseRoot, type BoundKind } from "@ark/schema";
2
2
  import { type keySet } from "@ark/util";
3
- import type { DateLiteral } from "../../../keywords/inference.ts";
3
+ import type { DateLiteral } from "../../../attributes.ts";
4
4
  import type { InferredAst } from "../../ast/infer.ts";
5
5
  import type { astToString } from "../../ast/utils.ts";
6
6
  import type { DynamicState, DynamicStateWithRoot } from "../../reduce/dynamic.ts";
@@ -1,6 +1,6 @@
1
1
  import type { BaseRoot } from "@ark/schema";
2
2
  import type { BigintLiteral, ErrorMessage, NumberLiteral, trim } from "@ark/util";
3
- import type { DateLiteral } from "../../../keywords/inference.ts";
3
+ import type { DateLiteral } from "../../../attributes.ts";
4
4
  import type { DynamicStateWithRoot } from "../../reduce/dynamic.ts";
5
5
  import type { StringLiteral } from "../operand/enclosed.ts";
6
6
  type UnitLiteralKeyword = "null" | "undefined" | "true" | "false";