arktype 2.0.0-dev.1 → 2.0.0-dev.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/__tests__/array.test.ts +270 -151
  2. package/__tests__/badDefinitionType.test.ts +10 -3
  3. package/__tests__/basis.test.ts +6 -2
  4. package/__tests__/bounds.test.ts +282 -352
  5. package/__tests__/cast.test.ts +7 -2
  6. package/__tests__/completions.test.ts +8 -3
  7. package/__tests__/config.test.ts +95 -167
  8. package/__tests__/dateLiteral.test.ts +8 -4
  9. package/__tests__/declared.test.ts +7 -6
  10. package/__tests__/discrimination.test.ts +1 -1
  11. package/__tests__/divisor.test.ts +46 -22
  12. package/__tests__/enclosed.test.ts +39 -25
  13. package/__tests__/examples.test.ts +56 -56
  14. package/__tests__/expressions.test.ts +184 -112
  15. package/__tests__/generic.test.ts +307 -288
  16. package/__tests__/group.test.ts +67 -54
  17. package/__tests__/imports.test.ts +62 -49
  18. package/__tests__/instanceof.test.ts +25 -23
  19. package/__tests__/intersection.test.ts +52 -48
  20. package/__tests__/keyTraversal.test.ts +77 -73
  21. package/__tests__/keyof.test.ts +68 -52
  22. package/__tests__/keywords.test.ts +164 -138
  23. package/__tests__/literal.test.ts +60 -21
  24. package/__tests__/match.bench.ts +31 -0
  25. package/__tests__/match.test.ts +222 -22
  26. package/__tests__/narrow.test.ts +52 -54
  27. package/__tests__/objectLiteral.test.ts +347 -205
  28. package/__tests__/operator.bench.ts +4 -4
  29. package/__tests__/pipe.test.ts +501 -0
  30. package/__tests__/realWorld.test.ts +63 -0
  31. package/__tests__/regex.test.ts +17 -7
  32. package/__tests__/scope.bench.ts +1 -1
  33. package/__tests__/scope.test.ts +257 -23
  34. package/__tests__/serialization.test.ts +19 -0
  35. package/__tests__/string.test.ts +11 -7
  36. package/__tests__/submodule.test.ts +26 -39
  37. package/__tests__/this.test.ts +83 -57
  38. package/__tests__/thunk.test.ts +13 -7
  39. package/__tests__/traverse.test.ts +76 -54
  40. package/__tests__/tsGenerics.test.ts +12 -12
  41. package/__tests__/type.test.ts +36 -0
  42. package/__tests__/typeReference.test.ts +7 -7
  43. package/__tests__/unenclosed.test.ts +116 -100
  44. package/__tests__/union.test.ts +171 -104
  45. package/ark.ts +21 -65
  46. package/generic.ts +69 -0
  47. package/main.ts +6 -18
  48. package/match.ts +195 -93
  49. package/module.ts +15 -0
  50. package/out/ark.d.ts +15 -39
  51. package/out/ark.js +9 -18
  52. package/out/ark.js.map +1 -1
  53. package/out/generic.d.ts +21 -0
  54. package/out/generic.js +24 -0
  55. package/out/generic.js.map +1 -0
  56. package/out/main.d.ts +6 -7
  57. package/out/main.js +4 -3
  58. package/out/main.js.map +1 -1
  59. package/out/match.d.ts +57 -34
  60. package/out/match.js +51 -17
  61. package/out/match.js.map +1 -1
  62. package/out/module.d.ts +10 -0
  63. package/out/module.js +3 -0
  64. package/out/module.js.map +1 -0
  65. package/out/parser/definition.d.ts +11 -13
  66. package/out/parser/definition.js +10 -13
  67. package/out/parser/definition.js.map +1 -1
  68. package/out/parser/generic.d.ts +5 -7
  69. package/out/parser/generic.js +7 -11
  70. package/out/parser/generic.js.map +1 -1
  71. package/out/parser/objectLiteral.d.ts +45 -14
  72. package/out/parser/objectLiteral.js +61 -52
  73. package/out/parser/objectLiteral.js.map +1 -1
  74. package/out/parser/semantic/bounds.d.ts +10 -8
  75. package/out/parser/semantic/bounds.js +0 -1
  76. package/out/parser/semantic/bounds.js.map +1 -1
  77. package/out/parser/semantic/divisor.d.ts +5 -7
  78. package/out/parser/semantic/divisor.js +0 -1
  79. package/out/parser/semantic/infer.d.ts +24 -0
  80. package/out/parser/semantic/infer.js +1 -0
  81. package/out/parser/semantic/infer.js.map +1 -0
  82. package/out/parser/semantic/utils.d.ts +3 -7
  83. package/out/parser/semantic/utils.js +0 -1
  84. package/out/parser/semantic/validate.d.ts +15 -14
  85. package/out/parser/semantic/validate.js +1 -1
  86. package/out/parser/semantic/validate.js.map +1 -1
  87. package/out/parser/string/reduce/dynamic.d.ts +13 -13
  88. package/out/parser/string/reduce/dynamic.js +31 -26
  89. package/out/parser/string/reduce/dynamic.js.map +1 -1
  90. package/out/parser/string/reduce/shared.d.ts +6 -20
  91. package/out/parser/string/reduce/shared.js +0 -1
  92. package/out/parser/string/reduce/shared.js.map +1 -1
  93. package/out/parser/string/reduce/static.d.ts +27 -24
  94. package/out/parser/string/reduce/static.js +0 -1
  95. package/out/parser/string/shift/operand/date.d.ts +3 -3
  96. package/out/parser/string/shift/operand/date.js +4 -7
  97. package/out/parser/string/shift/operand/date.js.map +1 -1
  98. package/out/parser/string/shift/operand/enclosed.d.ts +4 -19
  99. package/out/parser/string/shift/operand/enclosed.js +12 -13
  100. package/out/parser/string/shift/operand/enclosed.js.map +1 -1
  101. package/out/parser/string/shift/operand/genericArgs.d.ts +9 -10
  102. package/out/parser/string/shift/operand/genericArgs.js +6 -10
  103. package/out/parser/string/shift/operand/genericArgs.js.map +1 -1
  104. package/out/parser/string/shift/operand/operand.d.ts +3 -4
  105. package/out/parser/string/shift/operand/operand.js +8 -12
  106. package/out/parser/string/shift/operand/operand.js.map +1 -1
  107. package/out/parser/string/shift/operand/unenclosed.d.ts +15 -22
  108. package/out/parser/string/shift/operand/unenclosed.js +24 -36
  109. package/out/parser/string/shift/operand/unenclosed.js.map +1 -1
  110. package/out/parser/string/shift/operator/bounds.d.ts +9 -13
  111. package/out/parser/string/shift/operator/bounds.js +43 -54
  112. package/out/parser/string/shift/operator/bounds.js.map +1 -1
  113. package/out/parser/string/shift/operator/divisor.d.ts +2 -4
  114. package/out/parser/string/shift/operator/divisor.js +1 -3
  115. package/out/parser/string/shift/operator/divisor.js.map +1 -1
  116. package/out/parser/string/shift/operator/operator.d.ts +2 -3
  117. package/out/parser/string/shift/operator/operator.js +12 -19
  118. package/out/parser/string/shift/operator/operator.js.map +1 -1
  119. package/out/parser/string/shift/scanner.d.ts +2 -2
  120. package/out/parser/string/shift/scanner.js +14 -16
  121. package/out/parser/string/shift/scanner.js.map +1 -1
  122. package/out/parser/string/string.d.ts +8 -6
  123. package/out/parser/string/string.js +1 -3
  124. package/out/parser/string/string.js.map +1 -1
  125. package/out/parser/tuple.d.ts +102 -43
  126. package/out/parser/tuple.js +119 -87
  127. package/out/parser/tuple.js.map +1 -1
  128. package/out/scope.d.ts +43 -120
  129. package/out/scope.js +39 -209
  130. package/out/scope.js.map +1 -1
  131. package/out/type.d.ts +43 -64
  132. package/out/type.js +30 -131
  133. package/out/type.js.map +1 -1
  134. package/package.json +7 -3
  135. package/parser/definition.ts +77 -93
  136. package/parser/generic.ts +38 -40
  137. package/parser/objectLiteral.ts +172 -136
  138. package/parser/semantic/bounds.ts +33 -32
  139. package/parser/semantic/divisor.ts +8 -10
  140. package/parser/semantic/infer.ts +141 -0
  141. package/parser/semantic/utils.ts +12 -23
  142. package/parser/semantic/validate.ts +81 -73
  143. package/parser/string/reduce/dynamic.ts +67 -55
  144. package/parser/string/reduce/shared.ts +1 -3
  145. package/parser/string/reduce/static.ts +67 -69
  146. package/parser/string/shift/operand/date.ts +15 -14
  147. package/parser/string/shift/operand/enclosed.ts +30 -25
  148. package/parser/string/shift/operand/genericArgs.ts +46 -45
  149. package/parser/string/shift/operand/operand.ts +32 -38
  150. package/parser/string/shift/operand/unenclosed.ts +107 -158
  151. package/parser/string/shift/operator/bounds.ts +118 -112
  152. package/parser/string/shift/operator/divisor.ts +14 -17
  153. package/parser/string/shift/operator/operator.ts +35 -46
  154. package/parser/string/shift/scanner.ts +51 -50
  155. package/parser/string/string.ts +30 -35
  156. package/parser/tuple.ts +375 -307
  157. package/scope.ts +170 -453
  158. package/type.ts +193 -274
  159. package/__tests__/astUtils.test.ts +0 -17
  160. package/__tests__/cyclic.test.ts +0 -144
  161. package/__tests__/jsdoc.test.ts +0 -64
  162. package/__tests__/morph.test.ts +0 -409
  163. package/__tests__/nodeDefinitions.test.ts +0 -190
  164. package/__tests__/typeMethods.test.ts +0 -69
  165. package/out/ark.d.ts.map +0 -1
  166. package/out/arkConfig.d.ts +0 -2
  167. package/out/arkConfig.d.ts.map +0 -1
  168. package/out/arkConfig.js +0 -10
  169. package/out/arkConfig.js.map +0 -1
  170. package/out/main.d.ts.map +0 -1
  171. package/out/match.d.ts.map +0 -1
  172. package/out/parser/definition.d.ts.map +0 -1
  173. package/out/parser/generic.d.ts.map +0 -1
  174. package/out/parser/objectLiteral.d.ts.map +0 -1
  175. package/out/parser/semantic/bounds.d.ts.map +0 -1
  176. package/out/parser/semantic/divisor.d.ts.map +0 -1
  177. package/out/parser/semantic/intersections.d.ts +0 -14
  178. package/out/parser/semantic/intersections.d.ts.map +0 -1
  179. package/out/parser/semantic/intersections.js +0 -2
  180. package/out/parser/semantic/intersections.js.map +0 -1
  181. package/out/parser/semantic/semantic.d.ts +0 -33
  182. package/out/parser/semantic/semantic.d.ts.map +0 -1
  183. package/out/parser/semantic/semantic.js +0 -2
  184. package/out/parser/semantic/semantic.js.map +0 -1
  185. package/out/parser/semantic/utils.d.ts.map +0 -1
  186. package/out/parser/semantic/validate.d.ts.map +0 -1
  187. package/out/parser/shared.d.ts +0 -54
  188. package/out/parser/shared.d.ts.map +0 -1
  189. package/out/parser/shared.js +0 -47
  190. package/out/parser/shared.js.map +0 -1
  191. package/out/parser/string/reduce/dynamic.d.ts.map +0 -1
  192. package/out/parser/string/reduce/shared.d.ts.map +0 -1
  193. package/out/parser/string/reduce/static.d.ts.map +0 -1
  194. package/out/parser/string/shift/operand/date.d.ts.map +0 -1
  195. package/out/parser/string/shift/operand/enclosed.d.ts.map +0 -1
  196. package/out/parser/string/shift/operand/genericArgs.d.ts.map +0 -1
  197. package/out/parser/string/shift/operand/operand.d.ts.map +0 -1
  198. package/out/parser/string/shift/operand/unenclosed.d.ts.map +0 -1
  199. package/out/parser/string/shift/operator/bounds.d.ts.map +0 -1
  200. package/out/parser/string/shift/operator/divisor.d.ts.map +0 -1
  201. package/out/parser/string/shift/operator/operator.d.ts.map +0 -1
  202. package/out/parser/string/shift/scanner.d.ts.map +0 -1
  203. package/out/parser/string/string.d.ts.map +0 -1
  204. package/out/parser/tuple.d.ts.map +0 -1
  205. package/out/scope.d.ts.map +0 -1
  206. package/out/test.d.ts +0 -2
  207. package/out/test.d.ts.map +0 -1
  208. package/out/test.js +0 -7
  209. package/out/test.js.map +0 -1
  210. package/out/tsconfig.build.tsbuildinfo +0 -1
  211. package/out/type.d.ts.map +0 -1
  212. package/out/util.d.ts +0 -19
  213. package/out/util.d.ts.map +0 -1
  214. package/out/util.js +0 -7
  215. package/out/util.js.map +0 -1
  216. package/parser/semantic/intersections.ts +0 -46
  217. package/parser/semantic/semantic.ts +0 -144
  218. package/parser/shared.ts +0 -152
  219. package/util.ts +0 -36
package/out/scope.d.ts CHANGED
@@ -1,35 +1,15 @@
1
- import { type ArkErrorCode, type KeyCheckKind, type TypeNode, type extractIn, type extractOut } from "@arktype/schema";
2
- import { type Dict, type evaluate, type isAny, type nominal } from "@arktype/util";
1
+ import { type ArkConfig, type GenericProps, type PreparsedNodeResolution, type PrivateDeclaration, type RawSchema, type RawSchemaResolutions, RawSchemaScope, type SchemaScope, type UnknownSchema, type ambient, type arkKind, type destructuredExportContext, type destructuredImportContext, type exportedNameOf, type writeDuplicateAliasError } from "@arktype/schema";
2
+ import { type isAnyOrNever, type keyError, type nominal, type show } from "@arktype/util";
3
3
  import type { type } from "./ark.js";
4
+ import { Generic } from "./generic.js";
4
5
  import { type MatchParser } from "./match.js";
6
+ import type { Module } from "./module.js";
5
7
  import { type inferDefinition, type validateDefinition } from "./parser/definition.js";
6
- import { parseGenericParams, type GenericDeclaration, type GenericParamsParseError } from "./parser/generic.js";
7
- import { Type, type DeclarationParser, type DefinitionParser, type Generic, type GenericProps, type TypeConfig, type TypeParser } from "./type.js";
8
- import { type arkKind } from "./util.js";
9
- export type ScopeParser<parent, ambient> = {
10
- <const def>(def: validateScope<def, parent & ambient>): Scope<{
11
- exports: inferBootstrapped<{
12
- exports: bootstrapExports<def>;
13
- locals: bootstrapLocals<def> & parent;
14
- ambient: ambient;
15
- }>;
16
- locals: inferBootstrapped<{
17
- exports: bootstrapLocals<def>;
18
- locals: bootstrapExports<def> & parent;
19
- ambient: ambient;
20
- }>;
21
- ambient: ambient;
22
- }>;
23
- };
24
- export type ScopeConfig = {
25
- ambient?: Scope | null;
26
- codes?: Record<ArkErrorCode, {
27
- mustBe?: string;
28
- }>;
29
- keys?: KeyCheckKind;
30
- };
31
- type validateScope<def, $> = {
32
- [k in keyof def]: parseScopeKey<k>["params"] extends [] ? def[k] extends Type | PreparsedResolution ? def[k] : validateDefinition<def[k], $ & bootstrap<def>, {}> : parseScopeKey<k>["params"] extends GenericParamsParseError ? parseScopeKey<k>["params"][0] : validateDefinition<def[k], $ & bootstrap<def>, {
8
+ import { type GenericDeclaration, type GenericParamsParseError, parseGenericParams } from "./parser/generic.js";
9
+ import { type DeclarationParser, type DefinitionParser, RawTypeParser, type Type, type TypeParser } from "./type.js";
10
+ export type ScopeParser = <const def>(def: validateScope<def>, config?: ArkConfig) => Scope<inferBootstrapped<bootstrapAliases<def>>>;
11
+ type validateScope<def> = {
12
+ [k in keyof def]: k extends symbol ? unknown : parseScopeKey<k>["params"] extends [] ? def[k] extends Type | PreparsedResolution ? def[k] : k extends PrivateDeclaration<infer name extends keyof def & string> ? keyError<writeDuplicateAliasError<name>> : validateDefinition<def[k], ambient & bootstrapAliases<def>, {}> : parseScopeKey<k>["params"] extends GenericParamsParseError ? parseScopeKey<k>["params"][0] : validateDefinition<def[k], ambient & bootstrapAliases<def>, {
33
13
  [param in parseScopeKey<k>["params"][number]]: unknown;
34
14
  }>;
35
15
  };
@@ -40,120 +20,63 @@ export type bindThis<def> = {
40
20
  type Def<def = {}> = nominal<def, "unparsed">;
41
21
  /** sentinel indicating a scope that will be associated with a generic has not yet been parsed */
42
22
  export type UnparsedScope = "$";
43
- type bootstrap<def> = bootstrapLocals<def> & bootstrapExports<def>;
44
- type bootstrapLocals<def> = bootstrapAliases<{
45
- [k in keyof def & PrivateDeclaration as extractPrivateKey<k>]: def[k];
46
- }>;
47
- type bootstrapExports<def> = bootstrapAliases<{
48
- [k in Exclude<keyof def, PrivateDeclaration>]: def[k];
49
- }>;
50
23
  /** These are legal as values of a scope but not as definitions in other contexts */
51
- type PreparsedResolution = Module | GenericProps;
24
+ type PreparsedResolution = PreparsedNodeResolution;
52
25
  type bootstrapAliases<def> = {
53
26
  [k in Exclude<keyof def, GenericDeclaration | symbol>]: def[k] extends PreparsedResolution ? def[k] : def[k] extends (() => infer thunkReturn extends PreparsedResolution) ? thunkReturn : Def<def[k]>;
54
27
  } & {
55
- [k in keyof def & GenericDeclaration as extractGenericName<k>]: Generic<parseGenericParams<extractGenericParameters<k>>, def[k], UnparsedScope>;
28
+ [k in keyof def & GenericDeclaration as extractGenericName<k>]: GenericProps<parseGenericParams<extractGenericParameters<k>>, def[k], UnparsedScope>;
56
29
  };
57
- type inferBootstrapped<r extends Resolutions> = evaluate<{
58
- [name in keyof r["exports"]]: r["exports"][name] extends Def<infer def> ? inferDefinition<def, $<r>, {}> : r["exports"][name] extends GenericProps<infer params, infer def> ? Generic<params, def, $<r>> : r["exports"][name];
30
+ type inferBootstrapped<$> = show<{
31
+ [name in keyof $]: $[name] extends Def<infer def> ? inferDefinition<def, $ & ambient, {}> : $[name] extends GenericProps<infer params, infer def> ? Generic<params, def, $> : $[name];
59
32
  }>;
60
33
  type extractGenericName<k> = k extends GenericDeclaration<infer name> ? name : never;
61
34
  type extractGenericParameters<k> = k extends GenericDeclaration<string, infer params> ? params : never;
62
- type extractPrivateKey<k> = k extends PrivateDeclaration<infer key> ? key : never;
63
- type PrivateDeclaration<key extends string = string> = `#${key}`;
64
- export type resolve<reference extends keyof $ | keyof args, $, args> = (reference extends keyof args ? args[reference] : $[reference & keyof $]) extends infer resolution ? [resolution] extends [never] ? never : isAny<resolution> extends true ? any : resolution extends Def<infer def> ? inferDefinition<def, $, args> : resolution : never;
35
+ export type resolve<reference extends keyof $ | keyof args, $, args> = (reference extends keyof args ? args[reference] : $[reference & keyof $]) extends infer resolution ? isAnyOrNever<resolution> extends true ? resolution : resolution extends Def<infer def> ? inferDefinition<def, $, args> : resolution : never;
65
36
  export type moduleKeyOf<$> = {
66
- [k in keyof $]: $[k] extends Module ? k & string : never;
37
+ [k in keyof $]: $[k] extends {
38
+ [arkKind]: "module";
39
+ } ? k & string : never;
67
40
  }[keyof $];
68
- export type tryInferSubmoduleReference<$, token> = token extends `${infer submodule extends moduleKeyOf<$>}.${infer subalias}` ? subalias extends keyof $[submodule] ? $[submodule][subalias] extends Type<infer t> ? t : never : never : never;
69
- type $<r extends Resolutions> = r["exports"] & r["locals"] & r["ambient"];
70
- type exportedName<r extends Resolutions> = keyof r["exports"] & string;
71
- export type Module<r extends Resolutions = any> = {
72
- [k in exportedName<r> | arkKind]: k extends string ? [r["exports"][k]] extends [never] ? Type<never, $<r>> : isAny<r["exports"][k]> extends true ? Type<any, $<r>> : r["exports"][k] extends PreparsedResolution ? r["exports"][k] : Type<r["exports"][k], $<r>> : type.cast<"module">;
73
- };
74
- export type Resolutions = {
75
- exports: unknown;
76
- locals: unknown;
77
- ambient: unknown;
78
- };
79
- export type ParseContext = {
80
- baseName: string;
81
- path: string[];
82
- scope: Scope;
83
- args: Record<string, TypeNode> | undefined;
84
- };
85
- type ParseContextInput = Pick<ParseContext, "baseName" | "args">;
86
- export declare class Scope<r extends Resolutions = any> {
87
- infer: extractOut<r["exports"]>;
88
- inferIn: extractIn<r["exports"]>;
89
- config: TypeConfig;
41
+ export type tryInferSubmoduleReference<$, token> = token extends `${infer submodule extends moduleKeyOf<$>}.${infer subalias}` ? subalias extends keyof $[submodule] ? $[submodule][subalias] extends type.cast<infer t> ? t : never : never : never;
42
+ export interface ParseContext {
43
+ $: RawScope;
44
+ args?: Record<string, UnknownSchema>;
45
+ }
46
+ export declare const scope: ScopeParser;
47
+ export interface Scope<$ = any> extends SchemaScope<$> {
48
+ type: TypeParser<$>;
49
+ match: MatchParser<$>;
50
+ declare: DeclarationParser<$>;
51
+ define: DefinitionParser<$>;
52
+ import<names extends exportedNameOf<$>[]>(...names: names): Module<show<destructuredImportContext<$, names>>>;
53
+ export<names extends exportedNameOf<$>[]>(...names: names): Module<show<destructuredExportContext<$, names>>>;
54
+ }
55
+ export declare class RawScope<$ extends RawSchemaResolutions = RawSchemaResolutions> extends RawSchemaScope<$> {
90
56
  private parseCache;
91
- private resolutions;
92
- /** The set of names defined at the root-level of the scope mapped to their
93
- * corresponding definitions.**/
94
- aliases: Record<string, unknown>;
95
- private exportedNames;
96
- private ambient;
97
- constructor(def: Dict, config: ScopeConfig);
98
- static root: ScopeParser<{}, {}>;
99
- type: TypeParser<$<r>>;
100
- match: MatchParser<$<r>>;
101
- declare: DeclarationParser<$<r>>;
102
- scope: ScopeParser<r["exports"], r["ambient"]>;
103
- define: DefinitionParser<$<r>>;
104
- toAmbient(): Scope<{
105
- exports: r["exports"];
106
- locals: r["locals"];
107
- ambient: r["exports"];
108
- }>;
109
- get<name extends keyof r["exports"] & string>(name: name): Type<r["exports"][name], $<r>>;
110
- private createRootContext;
111
- parseDefinition(def: unknown, input: ParseContextInput): TypeNode;
112
- parse(def: unknown, ctx: ParseContext): TypeNode;
113
- parseString(def: string, ctx: ParseContext): TypeNode;
114
- maybeResolve(name: string): TypeNode | Generic | undefined;
115
- /** If name is a valid reference to a submodule alias, return its resolution */
116
- private maybeResolveSubalias;
117
- maybeResolveNode(name: string): TypeNode | undefined;
118
- import<names extends exportedName<r>[]>(...names: names): destructuredImportContext<r, names extends [] ? keyof r["exports"] & string : names[number]>;
119
- compile(): string;
120
- bindThis(): {
121
- this: import("@arktype/schema").IntersectionNode<unknown>;
57
+ constructor(def: Record<string, unknown>, config?: ArkConfig);
58
+ type: RawTypeParser;
59
+ match: MatchParser<$>;
60
+ declare: () => {
61
+ type: RawTypeParser;
122
62
  };
123
- private exportedResolutions;
124
- private exportCache;
125
- export<names extends exportedName<r>[]>(...names: names): Module<names extends [] ? r : destructuredExportContext<r, names[number]>>;
63
+ define: (def: unknown) => unknown;
64
+ preparseRoot(def: unknown): unknown;
65
+ parseRoot(def: unknown): RawSchema;
66
+ parse(def: unknown, ctx: ParseContext): RawSchema;
67
+ parseString(def: string, ctx: ParseContext): RawSchema;
126
68
  }
127
- type destructuredExportContext<r extends Resolutions, name extends exportedName<r>> = {
128
- exports: {
129
- [k in name]: r["exports"][k];
130
- };
131
- locals: r["locals"] & {
132
- [k in Exclude<keyof r["exports"], name>]: r["exports"][k];
133
- };
134
- ambient: r["ambient"];
135
- };
136
- type destructuredImportContext<r extends Resolutions, name extends exportedName<r>> = {
137
- [k in name as `#${k & string}`]: type.cast<r["exports"][k]>;
138
- };
139
69
  export declare const writeShallowCycleErrorMessage: (name: string, seen: string[]) => string;
140
- export declare const writeDuplicateNameMessage: <name extends string>(name: name) => `Duplicate name '${name}'`;
141
- type writeDuplicateNameMessage<name extends string> = `Duplicate name '${name}'`;
142
70
  export type ParsedScopeKey = {
143
- isLocal: boolean;
144
71
  name: string;
145
72
  params: string[];
146
73
  };
147
74
  export declare const parseScopeKey: (k: string) => ParsedScopeKey;
148
- type parseScopeKey<k> = k extends PrivateDeclaration<infer inner> ? parsePossibleGenericDeclaration<inner, true> : parsePossibleGenericDeclaration<k, false>;
149
- type parsePossibleGenericDeclaration<k, isLocal extends boolean> = k extends GenericDeclaration<infer name, infer paramString> ? {
150
- isLocal: isLocal;
75
+ export type parseScopeKey<k> = k extends GenericDeclaration<infer name, infer paramString> ? {
151
76
  name: name;
152
77
  params: parseGenericParams<paramString>;
153
78
  } : {
154
- isLocal: isLocal;
155
79
  name: k;
156
80
  params: [];
157
81
  };
158
82
  export {};
159
- //# sourceMappingURL=scope.d.ts.map
package/out/scope.js CHANGED
@@ -1,243 +1,75 @@
1
- import { BaseType, keywords } from "@arktype/schema";
2
- import { domainOf, hasDomain, isThunk, map, throwParseError } from "@arktype/util";
1
+ import { RawSchemaScope, hasArkKind } from "@arktype/schema";
2
+ import { domainOf, hasDomain, isThunk, throwParseError } from "@arktype/util";
3
+ import { Generic } from "./generic.js";
3
4
  import { createMatchParser } from "./match.js";
4
5
  import { parseObject, writeBadDefinitionTypeMessage } from "./parser/definition.js";
5
6
  import { parseGenericParams } from "./parser/generic.js";
6
7
  import { DynamicState } from "./parser/string/reduce/dynamic.js";
7
- import { writeMissingSubmoduleAccessMessage, writeNonSubmoduleDotMessage, writeUnresolvableMessage } from "./parser/string/shift/operand/unenclosed.js";
8
8
  import { fullStringParse } from "./parser/string/string.js";
9
- import { Type, createTypeParser, generic, validateUninstantiatedGeneric } from "./type.js";
10
- import { addArkKind, hasArkKind } from "./util.js";
11
- export class Scope {
12
- config;
9
+ import { RawTypeParser } from "./type.js";
10
+ export const scope = ((def, config = {}) => new RawScope(def, config));
11
+ export class RawScope extends RawSchemaScope {
13
12
  parseCache = {};
14
- resolutions;
15
- /** The set of names defined at the root-level of the scope mapped to their
16
- * corresponding definitions.**/
17
- aliases = {};
18
- exportedNames = [];
19
- ambient;
20
13
  constructor(def, config) {
14
+ const aliases = {};
21
15
  for (const k in def) {
22
16
  const parsedKey = parseScopeKey(k);
23
- this.aliases[parsedKey.name] = parsedKey.params.length
24
- ? generic(parsedKey.params, def[k], this)
25
- : def[k];
26
- if (!parsedKey.isLocal) {
27
- this.exportedNames.push(parsedKey.name);
28
- }
29
- }
30
- this.ambient = config.ambient ?? null;
31
- if (this.ambient) {
32
- // ensure exportedResolutions is populated
33
- this.ambient.export();
34
- this.resolutions = { ...this.ambient.exportedResolutions };
17
+ aliases[parsedKey.name] =
18
+ parsedKey.params.length ?
19
+ // TODO: this
20
+ new Generic(parsedKey.params, def[k], {})
21
+ : def[k];
35
22
  }
36
- else {
37
- this.resolutions = {};
38
- }
39
- this.config = config;
23
+ super(aliases, config);
40
24
  }
41
- static root = (aliases) => {
42
- return new Scope(aliases, {});
43
- };
44
- type = createTypeParser(this);
25
+ type = new RawTypeParser(this);
45
26
  match = createMatchParser(this);
46
- // TODO: decide if this API will be used for non-validated types
47
- declare = () => ({ type: this.type });
48
- scope = ((def, config = {}) => {
49
- return new Scope(def, {
50
- ambient: this.ambient,
51
- ...this.config,
52
- ...config
53
- });
54
- });
55
- define = (def) => def;
56
- toAmbient() {
57
- // TODO: private?
58
- return new Scope(this.aliases, {
59
- ambient: this,
60
- ...this.config
61
- });
62
- }
63
- // TODO: name?
64
- get(name) {
65
- return this.export()[name];
66
- }
67
- createRootContext(input) {
68
- return {
69
- path: [],
70
- scope: this,
71
- ...input
72
- };
73
- }
74
- parseDefinition(def, input) {
75
- return this.parse(def, this.createRootContext(input));
27
+ declare = (() => ({
28
+ type: this.type
29
+ })).bind(this);
30
+ define = ((def) => def).bind(this);
31
+ preparseRoot(def) {
32
+ if (isThunk(def) && !hasArkKind(def, "generic"))
33
+ return def();
34
+ return def;
35
+ }
36
+ parseRoot(def) {
37
+ // args: { this: {} as RawSchema },
38
+ return this.parse(def, {
39
+ $: this,
40
+ args: {}
41
+ // type parsing can bypass nodes if it hits the cache,
42
+ // so bind it directly (could be optimized)
43
+ }).bindScope(this);
76
44
  }
77
45
  parse(def, ctx) {
78
46
  if (typeof def === "string") {
79
- if (ctx.args !== undefined) {
47
+ if (ctx.args && Object.keys(ctx.args).every(k => !def.includes(k))) {
80
48
  // we can only rely on the cache if there are no contextual
81
49
  // resolutions like "this" or generic args
82
50
  return this.parseString(def, ctx);
83
51
  }
84
- if (!this.parseCache[def]) {
52
+ if (!this.parseCache[def])
85
53
  this.parseCache[def] = this.parseString(def, ctx);
86
- }
87
54
  return this.parseCache[def];
88
55
  }
89
- return hasDomain(def, "object")
90
- ? parseObject(def, ctx)
56
+ return hasDomain(def, "object") ?
57
+ parseObject(def, ctx)
91
58
  : throwParseError(writeBadDefinitionTypeMessage(domainOf(def)));
92
59
  }
93
60
  parseString(def, ctx) {
94
- return (this.maybeResolveNode(def) ??
61
+ return (this.maybeResolveSchema(def) ??
95
62
  ((def.endsWith("[]") &&
96
- this.maybeResolveNode(def.slice(0, -2))?.array()) ||
63
+ this.maybeResolveSchema(def.slice(0, -2))?.array()) ||
97
64
  fullStringParse(new DynamicState(def, ctx))));
98
65
  }
99
- maybeResolve(name) {
100
- const cached = this.resolutions[name];
101
- if (cached) {
102
- return cached;
103
- }
104
- let def = this.aliases[name];
105
- if (!def) {
106
- return this.maybeResolveSubalias(name);
107
- }
108
- if (isThunk(def) && !hasArkKind(def, "generic")) {
109
- def = def();
110
- }
111
- // TODO: initialize here?
112
- const resolution = hasArkKind(def, "generic")
113
- ? validateUninstantiatedGeneric(def)
114
- : hasArkKind(def, "module")
115
- ? throwParseError(writeMissingSubmoduleAccessMessage(name))
116
- : this.parseDefinition(def, this.createRootContext({ baseName: name, args: {} }));
117
- this.resolutions[name] = resolution;
118
- return resolution;
119
- }
120
- /** If name is a valid reference to a submodule alias, return its resolution */
121
- maybeResolveSubalias(name) {
122
- const dotIndex = name.indexOf(".");
123
- if (dotIndex === -1) {
124
- return;
125
- }
126
- const dotPrefix = name.slice(0, dotIndex);
127
- const prefixDef = this.aliases[dotPrefix];
128
- if (hasArkKind(prefixDef, "module")) {
129
- const resolution = prefixDef[name.slice(dotIndex + 1)]?.root;
130
- // if the first part of name is a submodule but the suffix is
131
- // unresolvable, we can throw immediately
132
- if (!resolution) {
133
- return throwParseError(writeUnresolvableMessage(name));
134
- }
135
- this.resolutions[name] = resolution;
136
- return resolution;
137
- }
138
- if (prefixDef !== undefined) {
139
- return throwParseError(writeNonSubmoduleDotMessage(dotPrefix));
140
- }
141
- // if the name includes ".", but the prefix is not an alias, it
142
- // might be something like a decimal literal, so just fall through to return
143
- }
144
- maybeResolveNode(name) {
145
- const result = this.maybeResolve(name);
146
- return result instanceof BaseType ? result : undefined;
147
- }
148
- import(...names) {
149
- return addArkKind(map(this.export(...names), (alias, value) => [
150
- `#${alias}`,
151
- value
152
- ]), "module");
153
- }
154
- compile() {
155
- return "";
156
- // this.export()
157
- // const references: Set<Root> = new Set()
158
- // for (const k in this.exportedResolutions!) {
159
- // const resolution = this.exportedResolutions[k]
160
- // if (hasArkKind(resolution, "node") && !references.has(resolution)) {
161
- // for (const reference of resolution.references) {
162
- // references.add(reference)
163
- // }
164
- // }
165
- // }
166
- // return [...references]
167
- // .map(
168
- // (ref) => `const ${ref.alias} = (${In}) => {
169
- // ${ref.condition}
170
- // return true
171
- // }`
172
- // )
173
- // .join("\n")
174
- }
175
- bindThis() {
176
- // TODO: fix
177
- return { this: keywords.unknown };
178
- }
179
- exportedResolutions;
180
- exportCache;
181
- export(...names) {
182
- if (!this.exportCache) {
183
- this.exportCache = {};
184
- for (const name of this.exportedNames) {
185
- let def = this.aliases[name];
186
- if (hasArkKind(def, "generic")) {
187
- this.exportCache[name] = def;
188
- continue;
189
- }
190
- // TODO: thunk generics?
191
- // handle generics before invoking thunks, since they use
192
- // varargs they will incorrectly be considered thunks
193
- if (isThunk(def)) {
194
- def = def();
195
- }
196
- if (hasArkKind(def, "module")) {
197
- this.exportCache[name] = def;
198
- }
199
- else {
200
- this.exportCache[name] = new Type(this.maybeResolve(name), this);
201
- }
202
- }
203
- this.exportedResolutions = resolutionsOfModule(this.exportCache);
204
- Object.assign(this.resolutions, this.exportedResolutions);
205
- }
206
- const namesToExport = names.length ? names : this.exportedNames;
207
- return addArkKind(map(namesToExport, (_, name) => [name, this.exportCache[name]]), "module");
208
- }
209
66
  }
210
- const resolutionsOfModule = (typeSet) => {
211
- const result = {};
212
- for (const k in typeSet) {
213
- const v = typeSet[k];
214
- if (hasArkKind(v, "module")) {
215
- const innerResolutions = resolutionsOfModule(v);
216
- const prefixedResolutions = map(innerResolutions, (innerK, innerV) => [
217
- `${k}.${innerK}`,
218
- innerV
219
- ]);
220
- Object.assign(result, prefixedResolutions);
221
- }
222
- else if (hasArkKind(v, "generic")) {
223
- result[k] = v;
224
- }
225
- else {
226
- result[k] = v.root;
227
- }
228
- }
229
- return result;
230
- };
231
67
  export const writeShallowCycleErrorMessage = (name, seen) => `Alias '${name}' has a shallow resolution cycle: ${[...seen, name].join(":")}`;
232
- export const writeDuplicateNameMessage = (name) => `Duplicate name '${name}'`;
233
68
  export const parseScopeKey = (k) => {
234
- const isLocal = k[0] === "#";
235
- const name = isLocal ? k.slice(1) : k;
236
69
  const firstParamIndex = k.indexOf("<");
237
70
  if (firstParamIndex === -1) {
238
71
  return {
239
- isLocal,
240
- name,
72
+ name: k,
241
73
  params: []
242
74
  };
243
75
  }
@@ -245,9 +77,7 @@ export const parseScopeKey = (k) => {
245
77
  throwParseError(`'>' must be the last character of a generic declaration in a scope`);
246
78
  }
247
79
  return {
248
- isLocal,
249
- name: name.slice(0, firstParamIndex),
80
+ name: k.slice(0, firstParamIndex),
250
81
  params: parseGenericParams(k.slice(firstParamIndex + 1, -1))
251
82
  };
252
83
  };
253
- //# sourceMappingURL=scope.js.map
package/out/scope.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"scope.js","sourceRoot":"","sources":["../scope.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,QAAQ,EACR,QAAQ,EAMR,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACN,QAAQ,EACR,SAAS,EACT,OAAO,EACP,GAAG,EACH,eAAe,EAKf,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,iBAAiB,EAAoB,MAAM,YAAY,CAAA;AAChE,OAAO,EACN,WAAW,EACX,6BAA6B,EAG7B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACN,kBAAkB,EAGlB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAA;AAChE,OAAO,EACN,kCAAkC,EAClC,2BAA2B,EAC3B,wBAAwB,EACxB,MAAM,6CAA6C,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,EACN,IAAI,EACJ,gBAAgB,EAChB,OAAO,EACP,6BAA6B,EAO7B,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,UAAU,EAAE,UAAU,EA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