arktype 2.0.0-dev.5 → 2.0.0-dev.6

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 (376) hide show
  1. package/__tests__/array.test.ts +70 -38
  2. package/__tests__/badDefinitionType.test.ts +9 -2
  3. package/__tests__/basis.test.ts +6 -2
  4. package/__tests__/bounds.test.ts +49 -218
  5. package/__tests__/cast.test.ts +7 -2
  6. package/__tests__/completions.test.ts +8 -3
  7. package/__tests__/config.test.ts +8 -2
  8. package/__tests__/cyclic.test.ts +141 -137
  9. package/__tests__/dateLiteral.test.ts +6 -2
  10. package/__tests__/declared.test.ts +2 -2
  11. package/__tests__/divisor.test.ts +28 -12
  12. package/__tests__/enclosed.test.ts +32 -23
  13. package/__tests__/examples.test.ts +56 -56
  14. package/__tests__/expressions.test.ts +184 -106
  15. package/__tests__/generic.test.ts +307 -287
  16. package/__tests__/group.test.ts +59 -51
  17. package/__tests__/imports.test.ts +44 -37
  18. package/__tests__/instanceof.test.ts +14 -12
  19. package/__tests__/intersection.test.ts +16 -36
  20. package/__tests__/keyTraversal.test.ts +6 -1
  21. package/__tests__/keyof.test.ts +57 -43
  22. package/__tests__/keywords.test.ts +144 -135
  23. package/__tests__/literal.test.ts +12 -7
  24. package/__tests__/match.test.ts +234 -236
  25. package/__tests__/morph.test.ts +169 -153
  26. package/__tests__/narrow.test.ts +14 -9
  27. package/__tests__/objectLiteral.test.ts +172 -184
  28. package/__tests__/realWorld.test.ts +60 -59
  29. package/__tests__/regex.test.ts +17 -7
  30. package/__tests__/scope.test.ts +59 -14
  31. package/__tests__/serialization.test.ts +19 -0
  32. package/__tests__/string.test.ts +11 -7
  33. package/__tests__/submodule.test.ts +24 -37
  34. package/__tests__/this.test.ts +83 -57
  35. package/__tests__/thunk.test.ts +13 -7
  36. package/__tests__/traverse.test.ts +22 -12
  37. package/__tests__/tsGenerics.test.ts +12 -12
  38. package/__tests__/type.test.ts +38 -0
  39. package/__tests__/typeReference.test.ts +5 -5
  40. package/__tests__/unenclosed.test.ts +106 -96
  41. package/__tests__/union.test.ts +207 -212
  42. package/ark.ts +44 -0
  43. package/generic.ts +67 -0
  44. package/main.ts +6 -17
  45. package/match.ts +41 -51
  46. package/module.ts +15 -0
  47. package/out/ark.d.ts +12 -40
  48. package/out/ark.d.ts.map +1 -1
  49. package/out/ark.js +9 -20
  50. package/out/ark.js.map +1 -1
  51. package/out/base.d.ts +198 -122
  52. package/out/base.d.ts.map +1 -1
  53. package/out/base.js +317 -271
  54. package/out/base.js.map +1 -1
  55. package/out/builtins/builtins.d.ts +21 -17
  56. package/out/builtins/builtins.js +15 -12
  57. package/out/builtins/jsObjects.d.ts +17 -17
  58. package/out/builtins/jsObjects.js +18 -15
  59. package/out/builtins/parsing.d.ts +13 -13
  60. package/out/builtins/parsing.js +57 -54
  61. package/out/builtins/tsGenerics.d.ts +2 -2
  62. package/out/builtins/tsGenerics.js +2 -2
  63. package/out/builtins/tsKeywords.d.ts +21 -21
  64. package/out/builtins/tsKeywords.js +23 -20
  65. package/out/builtins/utils/creditCard.d.ts +3 -3
  66. package/out/builtins/utils/creditCard.js +31 -32
  67. package/out/builtins/utils/date.d.ts +39 -20
  68. package/out/builtins/utils/date.js +51 -48
  69. package/out/builtins/validation.d.ts +17 -17
  70. package/out/builtins/validation.js +66 -62
  71. package/out/config.d.ts +9 -6
  72. package/out/config.js +17 -16
  73. package/out/constraints/ast.d.ts +263 -152
  74. package/out/constraints/ast.js +2 -2
  75. package/out/constraints/constraint.d.ts +196 -66
  76. package/out/constraints/constraint.js +21 -17
  77. package/out/constraints/predicate.d.ts +60 -42
  78. package/out/constraints/predicate.js +48 -43
  79. package/out/constraints/props/index.d.ts +35 -29
  80. package/out/constraints/props/index.js +54 -46
  81. package/out/constraints/props/optional.d.ts +31 -28
  82. package/out/constraints/props/optional.js +54 -53
  83. package/out/constraints/props/prop.d.ts +42 -39
  84. package/out/constraints/props/prop.js +104 -102
  85. package/out/constraints/props/props.d.ts +35 -32
  86. package/out/constraints/props/props.js +117 -102
  87. package/out/constraints/props/props.js.map +1 -1
  88. package/out/constraints/props/required.d.ts +40 -37
  89. package/out/constraints/props/required.js +78 -73
  90. package/out/constraints/props/sequence.d.ts +74 -56
  91. package/out/constraints/props/sequence.js +371 -322
  92. package/out/constraints/props/shared.d.ts +3 -3
  93. package/out/constraints/props/shared.js +4 -4
  94. package/out/constraints/refinements/after.d.ts +26 -18
  95. package/out/constraints/refinements/after.js +34 -33
  96. package/out/constraints/refinements/before.d.ts +26 -18
  97. package/out/constraints/refinements/before.js +41 -39
  98. package/out/constraints/refinements/divisor.d.ts +47 -37
  99. package/out/constraints/refinements/divisor.js +48 -37
  100. package/out/constraints/refinements/exactLength.d.ts +40 -36
  101. package/out/constraints/refinements/exactLength.js +50 -42
  102. package/out/constraints/refinements/kinds.d.ts +25 -25
  103. package/out/constraints/refinements/kinds.js +16 -16
  104. package/out/constraints/refinements/length.d.ts +45 -39
  105. package/out/constraints/refinements/length.js +51 -43
  106. package/out/constraints/refinements/max.d.ts +24 -17
  107. package/out/constraints/refinements/max.js +33 -29
  108. package/out/constraints/refinements/maxLength.d.ts +25 -17
  109. package/out/constraints/refinements/maxLength.js +34 -32
  110. package/out/constraints/refinements/min.d.ts +24 -17
  111. package/out/constraints/refinements/min.js +26 -23
  112. package/out/constraints/refinements/minLength.d.ts +25 -17
  113. package/out/constraints/refinements/minLength.js +31 -30
  114. package/out/constraints/refinements/range.d.ts +107 -78
  115. package/out/constraints/refinements/range.js +83 -66
  116. package/out/constraints/refinements/regex.d.ts +42 -38
  117. package/out/constraints/refinements/regex.js +35 -34
  118. package/out/constraints/refinements/shared.d.ts +20 -5
  119. package/out/constraints/refinements/shared.js +9 -9
  120. package/out/generic.d.ts +22 -0
  121. package/out/generic.d.ts.map +1 -0
  122. package/out/generic.js +23 -0
  123. package/out/generic.js.map +1 -0
  124. package/out/inference.d.ts +132 -35
  125. package/out/inference.js +2 -2
  126. package/out/keywords/ark.d.ts +60 -50
  127. package/out/keywords/ark.js +25 -25
  128. package/out/keywords/internal.d.ts +11 -11
  129. package/out/keywords/internal.js +13 -10
  130. package/out/keywords/jsObject.d.ts +18 -18
  131. package/out/keywords/jsObject.js +18 -15
  132. package/out/keywords/parsing.d.ts +14 -14
  133. package/out/keywords/parsing.js +53 -50
  134. package/out/keywords/root.d.ts +6 -6
  135. package/out/keywords/root.js +4 -4
  136. package/out/keywords/tsGenerics.d.ts +2 -2
  137. package/out/keywords/tsGenerics.js +2 -2
  138. package/out/keywords/tsPrimitive.d.ts +22 -22
  139. package/out/keywords/tsPrimitive.js +25 -22
  140. package/out/keywords/utils/creditCard.d.ts +11 -8
  141. package/out/keywords/utils/creditCard.js +31 -32
  142. package/out/keywords/utils/date.d.ts +43 -23
  143. package/out/keywords/utils/date.js +51 -48
  144. package/out/keywords/validation.d.ts +18 -18
  145. package/out/keywords/validation.js +67 -63
  146. package/out/kinds.d.ts +97 -67
  147. package/out/kinds.js +28 -28
  148. package/out/main.d.ts +6 -7
  149. package/out/main.d.ts.map +1 -1
  150. package/out/main.js +4 -2
  151. package/out/main.js.map +1 -1
  152. package/out/match.d.ts +6 -10
  153. package/out/match.d.ts.map +1 -1
  154. package/out/match.js +1 -1
  155. package/out/match.js.map +1 -1
  156. package/out/module.d.ts +11 -0
  157. package/out/module.d.ts.map +1 -0
  158. package/out/module.js +4 -0
  159. package/out/module.js.map +1 -0
  160. package/out/parse.d.ts +28 -22
  161. package/out/parse.js +157 -144
  162. package/out/parser/definition.d.ts +8 -10
  163. package/out/parser/definition.d.ts.map +1 -1
  164. package/out/parser/definition.js +5 -6
  165. package/out/parser/definition.js.map +1 -1
  166. package/out/parser/generic.d.ts +3 -4
  167. package/out/parser/generic.d.ts.map +1 -1
  168. package/out/parser/generic.js +6 -8
  169. package/out/parser/generic.js.map +1 -1
  170. package/out/parser/objectLiteral.d.ts +5 -6
  171. package/out/parser/objectLiteral.d.ts.map +1 -1
  172. package/out/parser/objectLiteral.js +10 -15
  173. package/out/parser/objectLiteral.js.map +1 -1
  174. package/out/parser/semantic/bounds.d.ts +4 -3
  175. package/out/parser/semantic/bounds.d.ts.map +1 -1
  176. package/out/parser/semantic/bounds.js.map +1 -1
  177. package/out/parser/semantic/divisor.d.ts +4 -3
  178. package/out/parser/semantic/divisor.d.ts.map +1 -1
  179. package/out/parser/semantic/infer.d.ts +7 -10
  180. package/out/parser/semantic/infer.d.ts.map +1 -1
  181. package/out/parser/semantic/utils.d.ts.map +1 -1
  182. package/out/parser/semantic/validate.d.ts +13 -11
  183. package/out/parser/semantic/validate.d.ts.map +1 -1
  184. package/out/parser/semantic/validate.js +1 -0
  185. package/out/parser/semantic/validate.js.map +1 -1
  186. package/out/parser/string/reduce/dynamic.d.ts +7 -8
  187. package/out/parser/string/reduce/dynamic.d.ts.map +1 -1
  188. package/out/parser/string/reduce/dynamic.js +26 -22
  189. package/out/parser/string/reduce/dynamic.js.map +1 -1
  190. package/out/parser/string/reduce/shared.d.ts +2 -2
  191. package/out/parser/string/reduce/shared.d.ts.map +1 -1
  192. package/out/parser/string/reduce/static.d.ts +8 -5
  193. package/out/parser/string/reduce/static.d.ts.map +1 -1
  194. package/out/parser/string/shift/operand/date.d.ts +1 -1
  195. package/out/parser/string/shift/operand/date.d.ts.map +1 -1
  196. package/out/parser/string/shift/operand/date.js +2 -2
  197. package/out/parser/string/shift/operand/date.js.map +1 -1
  198. package/out/parser/string/shift/operand/enclosed.d.ts +1 -1
  199. package/out/parser/string/shift/operand/enclosed.d.ts.map +1 -1
  200. package/out/parser/string/shift/operand/enclosed.js +1 -1
  201. package/out/parser/string/shift/operand/enclosed.js.map +1 -1
  202. package/out/parser/string/shift/operand/genericArgs.d.ts +8 -8
  203. package/out/parser/string/shift/operand/genericArgs.d.ts.map +1 -1
  204. package/out/parser/string/shift/operand/genericArgs.js +6 -8
  205. package/out/parser/string/shift/operand/genericArgs.js.map +1 -1
  206. package/out/parser/string/shift/operand/operand.d.ts +3 -3
  207. package/out/parser/string/shift/operand/operand.d.ts.map +1 -1
  208. package/out/parser/string/shift/operand/operand.js +8 -11
  209. package/out/parser/string/shift/operand/operand.js.map +1 -1
  210. package/out/parser/string/shift/operand/unenclosed.d.ts +10 -16
  211. package/out/parser/string/shift/operand/unenclosed.d.ts.map +1 -1
  212. package/out/parser/string/shift/operand/unenclosed.js +19 -24
  213. package/out/parser/string/shift/operand/unenclosed.js.map +1 -1
  214. package/out/parser/string/shift/operator/bounds.d.ts +6 -8
  215. package/out/parser/string/shift/operator/bounds.d.ts.map +1 -1
  216. package/out/parser/string/shift/operator/bounds.js +20 -29
  217. package/out/parser/string/shift/operator/bounds.js.map +1 -1
  218. package/out/parser/string/shift/operator/divisor.d.ts +1 -2
  219. package/out/parser/string/shift/operator/divisor.d.ts.map +1 -1
  220. package/out/parser/string/shift/operator/divisor.js.map +1 -1
  221. package/out/parser/string/shift/operator/operator.d.ts +1 -1
  222. package/out/parser/string/shift/operator/operator.d.ts.map +1 -1
  223. package/out/parser/string/shift/operator/operator.js +12 -18
  224. package/out/parser/string/shift/operator/operator.js.map +1 -1
  225. package/out/parser/string/shift/scanner.d.ts +2 -1
  226. package/out/parser/string/shift/scanner.d.ts.map +1 -1
  227. package/out/parser/string/shift/scanner.js +12 -11
  228. package/out/parser/string/shift/scanner.js.map +1 -1
  229. package/out/parser/string/string.d.ts +7 -4
  230. package/out/parser/string/string.d.ts.map +1 -1
  231. package/out/parser/string/string.js.map +1 -1
  232. package/out/parser/tuple.d.ts +27 -30
  233. package/out/parser/tuple.d.ts.map +1 -1
  234. package/out/parser/tuple.js +33 -35
  235. package/out/parser/tuple.js.map +1 -1
  236. package/out/schema.d.ts +171 -40
  237. package/out/schema.js +2 -2
  238. package/out/schemaScope.d.ts +170 -100
  239. package/out/schemaScope.js +231 -208
  240. package/out/scope.d.ts +43 -187
  241. package/out/scope.d.ts.map +1 -1
  242. package/out/scope.js +56 -326
  243. package/out/scope.js.map +1 -1
  244. package/out/shared/compile.d.ts +19 -19
  245. package/out/shared/compile.js +77 -65
  246. package/out/shared/context.d.ts +51 -26
  247. package/out/shared/context.js +50 -45
  248. package/out/shared/declare.d.ts +61 -45
  249. package/out/shared/declare.js +2 -2
  250. package/out/shared/disjoint.d.ts +85 -73
  251. package/out/shared/disjoint.js +108 -80
  252. package/out/shared/disjoint.js.map +1 -1
  253. package/out/shared/errors.d.ts +85 -45
  254. package/out/shared/errors.js +101 -101
  255. package/out/shared/implement.d.ts +351 -158
  256. package/out/shared/implement.js +61 -62
  257. package/out/shared/implement.js.map +1 -1
  258. package/out/shared/inference.d.ts +5 -5
  259. package/out/shared/inference.js +2 -2
  260. package/out/shared/intersections.d.ts +57 -12
  261. package/out/shared/intersections.js +2 -2
  262. package/out/shared/traversal.d.ts +57 -39
  263. package/out/shared/traversal.js +95 -95
  264. package/out/shared/utils.d.ts +23 -7
  265. package/out/shared/utils.d.ts.map +1 -1
  266. package/out/shared/utils.js +14 -9
  267. package/out/shared/utils.js.map +1 -1
  268. package/out/type.d.ts +24 -32
  269. package/out/type.d.ts.map +1 -1
  270. package/out/type.js +2 -51
  271. package/out/type.js.map +1 -1
  272. package/out/types/basis.d.ts +44 -21
  273. package/out/types/basis.js +13 -13
  274. package/out/types/discriminate.d.ts +33 -19
  275. package/out/types/discriminate.js +116 -110
  276. package/out/types/domain.d.ts +54 -37
  277. package/out/types/domain.js +39 -36
  278. package/out/types/intersection.d.ts +121 -61
  279. package/out/types/intersection.js +355 -326
  280. package/out/types/morph.d.ts +148 -70
  281. package/out/types/morph.js +97 -93
  282. package/out/types/proto.d.ts +48 -39
  283. package/out/types/proto.js +58 -46
  284. package/out/types/type.d.ts +137 -55
  285. package/out/types/type.d.ts.map +1 -1
  286. package/out/types/type.js +121 -109
  287. package/out/types/type.js.map +1 -1
  288. package/out/types/union.d.ts +66 -43
  289. package/out/types/union.js +299 -257
  290. package/out/types/unit.d.ts +41 -36
  291. package/out/types/unit.js +53 -45
  292. package/out/util.d.ts +30 -21
  293. package/out/util.js +8 -7
  294. package/package.json +3 -2
  295. package/parser/definition.ts +64 -81
  296. package/parser/generic.ts +35 -36
  297. package/parser/objectLiteral.ts +78 -92
  298. package/parser/semantic/bounds.ts +25 -33
  299. package/parser/semantic/divisor.ts +7 -11
  300. package/parser/semantic/infer.ts +69 -80
  301. package/parser/semantic/utils.ts +10 -13
  302. package/parser/semantic/validate.ts +81 -71
  303. package/parser/string/reduce/dynamic.ts +42 -39
  304. package/parser/string/reduce/shared.ts +1 -1
  305. package/parser/string/reduce/static.ts +50 -52
  306. package/parser/string/shift/operand/date.ts +5 -5
  307. package/parser/string/shift/operand/enclosed.ts +12 -13
  308. package/parser/string/shift/operand/genericArgs.ts +45 -44
  309. package/parser/string/shift/operand/operand.ts +32 -37
  310. package/parser/string/shift/operand/unenclosed.ts +99 -134
  311. package/parser/string/shift/operator/bounds.ts +78 -75
  312. package/parser/string/shift/operator/divisor.ts +11 -13
  313. package/parser/string/shift/operator/operator.ts +35 -46
  314. package/parser/string/shift/scanner.ts +39 -36
  315. package/parser/string/string.ts +26 -30
  316. package/parser/tuple.ts +206 -248
  317. package/scope.ts +185 -704
  318. package/type.ts +101 -140
  319. package/__tests__/errors.test.ts +0 -115
  320. package/__tests__/schema.bench.ts +0 -14
  321. package/__tests__/schema.test.ts +0 -60
  322. package/__tests__/typeMethods.test.ts +0 -68
  323. package/__tests__/unit.test.ts +0 -61
  324. package/base.ts +0 -520
  325. package/config.ts +0 -25
  326. package/constraints/ast.ts +0 -288
  327. package/constraints/constraint.ts +0 -91
  328. package/constraints/predicate.ts +0 -102
  329. package/constraints/props/index.ts +0 -93
  330. package/constraints/props/prop.ts +0 -146
  331. package/constraints/props/props.ts +0 -148
  332. package/constraints/props/sequence.ts +0 -473
  333. package/constraints/props/shared.ts +0 -5
  334. package/constraints/refinements/after.ts +0 -68
  335. package/constraints/refinements/before.ts +0 -75
  336. package/constraints/refinements/divisor.ts +0 -76
  337. package/constraints/refinements/exactLength.ts +0 -75
  338. package/constraints/refinements/kinds.ts +0 -31
  339. package/constraints/refinements/max.ts +0 -61
  340. package/constraints/refinements/maxLength.ts +0 -66
  341. package/constraints/refinements/min.ts +0 -54
  342. package/constraints/refinements/minLength.ts +0 -63
  343. package/constraints/refinements/range.ts +0 -181
  344. package/constraints/refinements/regex.ts +0 -59
  345. package/keywords/ark.ts +0 -101
  346. package/keywords/internal.ts +0 -29
  347. package/keywords/jsObject.ts +0 -39
  348. package/keywords/parsing.ts +0 -87
  349. package/keywords/root.ts +0 -9
  350. package/keywords/tsGenerics.ts +0 -28
  351. package/keywords/tsPrimitive.ts +0 -52
  352. package/keywords/utils/creditCard.ts +0 -37
  353. package/keywords/utils/date.ts +0 -112
  354. package/keywords/validation.ts +0 -115
  355. package/kinds.ts +0 -115
  356. package/parse.ts +0 -221
  357. package/schema.ts +0 -263
  358. package/shared/compile.ts +0 -92
  359. package/shared/declare.ts +0 -75
  360. package/shared/disjoint.ts +0 -203
  361. package/shared/errors.ts +0 -204
  362. package/shared/implement.ts +0 -327
  363. package/shared/inference.ts +0 -9
  364. package/shared/intersections.ts +0 -53
  365. package/shared/traversal.ts +0 -146
  366. package/shared/utils.ts +0 -30
  367. package/types/basis.ts +0 -62
  368. package/types/discriminate.ts +0 -168
  369. package/types/domain.ts +0 -79
  370. package/types/intersection.ts +0 -539
  371. package/types/morph.ts +0 -263
  372. package/types/proto.ts +0 -89
  373. package/types/type.ts +0 -319
  374. package/types/union.ts +0 -451
  375. package/types/unit.ts +0 -78
  376. package/util.ts +0 -39
package/out/scope.js CHANGED
@@ -1,120 +1,70 @@
1
- import { CompiledFunction, domainOf, hasDomain, isArray, isThunk, morph, throwInternalError, throwParseError } from "@arktype/util";
2
- import { typeKindOfSchema } from "./base.js";
3
- import { globalConfig, mergeConfigs } from "./config.js";
4
- import { nodesByKind } from "./kinds.js";
1
+ import { RawSchemaScope, hasArkKind } from "@arktype/schema";
2
+ import { domainOf, hasDomain, isThunk, throwParseError } from "@arktype/util";
3
+ import { Generic } from "./generic.js";
5
4
  import { createMatchParser } from "./match.js";
6
- import { parseAttachments } from "./parse.js";
7
5
  import { parseObject, writeBadDefinitionTypeMessage } from "./parser/definition.js";
8
6
  import { parseGenericParams } from "./parser/generic.js";
9
7
  import { DynamicState } from "./parser/string/reduce/dynamic.js";
10
- import { writeMissingSubmoduleAccessMessage, writeNonSubmoduleDotMessage, writeUnresolvableMessage } from "./parser/string/shift/operand/unenclosed.js";
11
8
  import { fullStringParse } from "./parser/string/string.js";
12
- import { NodeCompiler } from "./shared/compile.js";
13
- import { isNodeKind } from "./shared/implement.js";
14
- import { createTypeParser, generic, validateUninstantiatedGeneric } from "./type.js";
15
- import { BaseType } from "./types/type.js";
16
- import { addArkKind, hasArkKind } from "./util.js";
17
- export const defaultConfig = Object.assign(morph(nodesByKind, (kind, node) => [kind, node.implementation.defaults]), {
18
- prereducedAliases: false,
19
- ambient: null,
20
- registerKeywords: false
21
- });
22
- const nonInheritedKeys = [
23
- "registerKeywords",
24
- "prereducedAliases"
25
- ];
26
- const extendConfig = (base, extension) => {
27
- if (!extension)
28
- return base;
29
- const result = mergeConfigs(base, extension);
30
- nonInheritedKeys.forEach((k) => {
31
- if (!(k in extension))
32
- delete result[k];
33
- });
34
- return result;
35
- };
36
- const resolveConfig = (scopeConfig) => extendConfig(defaultConfig, scopeConfig);
37
- export class Scope {
38
- config;
39
- resolvedConfig;
9
+ export const scope = ((def, config = {}) => new RawScope(def, config));
10
+ export class RawScope extends RawSchemaScope {
40
11
  parseCache = {};
41
- resolutions;
42
- nodeCache = {};
43
- referencesByName = {};
44
- references = [];
45
- json = {};
46
- resolved = false;
47
- // these allow builtin types to be accessed during parsing without cyclic imports
48
- // they are populated as each scope is parsed with `registerKeywords` in its config
49
- /** @internal */
50
- static keywords = {};
51
- /** @internal */
52
- get keywords() {
53
- return Scope.keywords;
54
- }
55
- /** The set of names defined at the root-level of the scope mapped to their
56
- * corresponding definitions.**/
57
- aliases = {};
58
- exportedNames = [];
59
12
  constructor(def, config) {
60
- this.config = extendConfig(globalConfig, config);
61
- this.resolvedConfig = resolveConfig(this.config);
13
+ const aliases = {};
62
14
  for (const k in def) {
63
15
  const parsedKey = parseScopeKey(k);
64
- this.aliases[parsedKey.name] = parsedKey.params.length
65
- ? generic(parsedKey.params, def[k], this)
66
- : def[k];
67
- if (!parsedKey.isLocal) {
68
- this.exportedNames.push(parsedKey.name);
69
- }
70
- }
71
- if (this.config.ambient) {
72
- // ensure exportedResolutions is populated
73
- this.config.ambient.export();
74
- this.resolutions = { ...this.config.ambient.exportedResolutions };
75
- }
76
- else {
77
- this.resolutions = {};
78
- }
79
- this.node("union", {
80
- branches: [
81
- "string",
82
- "number",
83
- "object",
84
- "bigint",
85
- "symbol",
86
- { unit: true },
87
- { unit: false },
88
- { unit: null },
89
- { unit: undefined }
90
- ]
91
- }, { reduceTo: this.node("intersection", {}, { prereduced: true }) });
92
- }
93
- type = createTypeParser(this);
94
- schema = this.rawSchema.bind(this);
95
- rawSchema(schema) {
96
- return ["schema", schema];
16
+ aliases[parsedKey.name] =
17
+ parsedKey.params.length ?
18
+ // TODO: this
19
+ new Generic(parsedKey.params, def[k], {})
20
+ : def[k];
21
+ }
22
+ super(aliases, config);
23
+ }
24
+ type(...args) {
25
+ if (args.length === 1) {
26
+ // treat as a simple definition
27
+ return this.parseRoot(args[0]);
28
+ }
29
+ if (args.length === 2 &&
30
+ typeof args[0] === "string" &&
31
+ args[0][0] === "<" &&
32
+ args[0].at(-1) === ">") {
33
+ // if there are exactly two args, the first of which looks like <${string}>,
34
+ // treat as a generic
35
+ const params = parseGenericParams(args[0].slice(1, -1));
36
+ const def = args[1];
37
+ // TODO: validateUninstantiatedGeneric, remove this cast
38
+ return new Generic(params, def, this);
39
+ }
40
+ // otherwise, treat as a tuple expression. technically, this also allows
41
+ // non-expression tuple definitions to be parsed, but it's not a supported
42
+ // part of the API as specified by the associated types
43
+ return this.parseRoot(args);
97
44
  }
98
45
  match = createMatchParser(this);
99
- declare = () => ({ type: this.type });
100
- scope = ((def, config = {}) => new Scope({ ...this.import(), ...def }, extendConfig(this.config, config)));
101
- define = (def) => def;
102
- toAmbient() {
103
- ;
104
- this.config = {
105
- ...this.config,
106
- ambient: this
107
- };
108
- return this;
46
+ declare() {
47
+ return { type: this.type.bind(this) };
48
+ }
49
+ define(def) {
50
+ return def;
109
51
  }
110
- // TODO: name?
111
- get(name) {
112
- return this.export()[name];
52
+ preparseRoot(def) {
53
+ if (isThunk(def) && !hasArkKind(def, "generic")) {
54
+ return def();
55
+ }
56
+ return def;
57
+ }
58
+ parseRoot(def, opts) {
59
+ return this.parse(def, {
60
+ args: { this: {} },
61
+ $: this,
62
+ ...opts
63
+ }).bindScope(this);
113
64
  }
114
65
  parse(def, ctx) {
115
66
  if (typeof def === "string") {
116
- if (ctx.args !== undefined) {
117
- // TODO: allow caching with this by serializing it?
67
+ if (ctx.args && Object.keys(ctx.args).every((k) => !def.includes(k))) {
118
68
  // we can only rely on the cache if there are no contextual
119
69
  // resolutions like "this" or generic args
120
70
  return this.parseString(def, ctx);
@@ -124,242 +74,23 @@ export class Scope {
124
74
  }
125
75
  return this.parseCache[def];
126
76
  }
127
- return hasDomain(def, "object")
128
- ? parseObject(def, ctx)
77
+ return hasDomain(def, "object") ?
78
+ parseObject(def, ctx)
129
79
  : throwParseError(writeBadDefinitionTypeMessage(domainOf(def)));
130
80
  }
131
- parseTypeRoot(def, input) {
132
- const result = this.parse(def, {
133
- args: { this: {} },
134
- baseName: "type",
135
- path: [],
136
- $: this,
137
- ...input
138
- }).bindScope(this);
139
- this.bindCompiledScope(result.contributesReferences);
140
- return result;
141
- }
142
81
  parseString(def, ctx) {
143
82
  return (this.maybeResolveNode(def) ??
144
83
  ((def.endsWith("[]") &&
145
84
  this.maybeResolveNode(def.slice(0, -2))?.array()) ||
146
85
  fullStringParse(new DynamicState(def, ctx))));
147
86
  }
148
- maybeResolve(name) {
149
- const cached = this.resolutions[name];
150
- if (cached) {
151
- return cached;
152
- }
153
- let def = this.aliases[name];
154
- if (!def)
155
- return this.maybeResolveSubalias(name);
156
- if (isThunk(def) && !hasArkKind(def, "generic")) {
157
- def = def();
158
- }
159
- // TODO: initialize here?
160
- const resolution = hasArkKind(def, "generic")
161
- ? validateUninstantiatedGeneric(def)
162
- : hasArkKind(def, "module")
163
- ? throwParseError(writeMissingSubmoduleAccessMessage(name))
164
- : this.parseTypeRoot(def, { baseName: name, args: {} });
165
- this.resolutions[name] = resolution;
166
- return resolution;
167
- }
168
- /** If name is a valid reference to a submodule alias, return its resolution */
169
- maybeResolveSubalias(name) {
170
- const dotIndex = name.indexOf(".");
171
- if (dotIndex === -1) {
172
- return;
173
- }
174
- const dotPrefix = name.slice(0, dotIndex);
175
- const prefixDef = this.aliases[dotPrefix];
176
- if (hasArkKind(prefixDef, "module")) {
177
- const resolution = prefixDef[name.slice(dotIndex + 1)];
178
- // if the first part of name is a submodule but the suffix is
179
- // unresolvable, we can throw immediately
180
- if (!resolution) {
181
- return throwParseError(writeUnresolvableMessage(name));
182
- }
183
- this.resolutions[name] = resolution;
184
- return resolution;
185
- }
186
- if (prefixDef !== undefined) {
187
- return throwParseError(writeNonSubmoduleDotMessage(dotPrefix));
188
- }
189
- // if the name includes ".", but the prefix is not an alias, it
190
- // might be something like a decimal literal, so just fall through to return
191
- }
192
- maybeResolveNode(name) {
193
- const result = this.maybeResolve(name);
194
- return result instanceof BaseType ? result : undefined;
195
- }
196
- import(...names) {
197
- return addArkKind(morph(this.export(...names), (alias, value) => [
198
- `#${alias}`,
199
- value
200
- ]), "module");
201
- }
202
- exportedResolutions;
203
- exportCache;
204
- export(...names) {
205
- if (!this.exportCache) {
206
- this.exportCache = {};
207
- for (const name of this.exportedNames) {
208
- let def = this.aliases[name];
209
- if (hasArkKind(def, "generic")) {
210
- this.exportCache[name] = def;
211
- continue;
212
- }
213
- // TODO: thunk generics?
214
- // handle generics before invoking thunks, since they use
215
- // varargs they will incorrectly be considered thunks
216
- if (isThunk(def)) {
217
- def = def();
218
- }
219
- if (hasArkKind(def, "module")) {
220
- this.exportCache[name] = def;
221
- }
222
- else {
223
- this.exportCache[name] = this.parseTypeRoot(def, {
224
- baseName: name,
225
- args: {}
226
- });
227
- }
228
- }
229
- this.exportedResolutions = resolutionsOfModule(this.exportCache);
230
- // TODO: add generic json
231
- this.json = morph(this.exportedResolutions, (k, v) => hasArkKind(v, "node") ? [k, v.json] : []);
232
- Object.assign(this.resolutions, this.exportedResolutions);
233
- if (this.config.registerKeywords)
234
- Object.assign(Scope.keywords, this.exportedResolutions);
235
- this.references = Object.values(this.referencesByName);
236
- this.bindCompiledScope(this.references);
237
- this.resolved = true;
238
- }
239
- const namesToExport = names.length ? names : this.exportedNames;
240
- return addArkKind(morph(namesToExport, (_, name) => [
241
- name,
242
- this.exportCache[name]
243
- ]), "module");
244
- }
245
- parseUnits(...values) {
246
- const uniqueValues = [];
247
- for (const value of values) {
248
- if (!uniqueValues.includes(value)) {
249
- uniqueValues.push(value);
250
- }
251
- }
252
- const branches = uniqueValues.map((unit) => this.node("unit", { unit }));
253
- return branches.length === 1
254
- ? branches[0]
255
- : this.node(branches, { root: true, prereduced: true });
256
- }
257
- node = this.internalNodeParser.bind(this);
258
- internalNodeParser(schemaOrKind, schemaOrOpts, constraintOpts) {
259
- const kindArg = isNodeKind(schemaOrKind) ? schemaOrKind : undefined;
260
- let schema = kindArg ? schemaOrOpts : schemaOrKind;
261
- const opts = kindArg
262
- ? constraintOpts
263
- : schemaOrOpts;
264
- if (opts?.alias && opts.alias in this.resolutions) {
265
- return throwInternalError(`Unexpected attempt to recreate existing alias ${opts.alias}`);
266
- }
267
- let kind = kindArg ?? typeKindOfSchema(schema);
268
- if (kind === "union" && isArray(schema) && schema.length === 1) {
269
- schema = schema[0];
270
- kind = typeKindOfSchema(schema);
271
- }
272
- if (opts?.allowedKinds && !opts.allowedKinds.includes(kind)) {
273
- return throwParseError(`Schema of kind ${kind} should be one of ${opts.allowedKinds}`);
274
- }
275
- const node = parseAttachments(kind, schema, {
276
- $: this,
277
- prereduced: opts?.prereduced ?? false,
278
- raw: schema,
279
- ...opts
280
- });
281
- if (opts?.root) {
282
- if (this.resolved) {
283
- // this node was not part of the original scope, so compile an anonymous scope
284
- // including only its references
285
- this.bindCompiledScope(node.contributesReferences);
286
- }
287
- else {
288
- // we're still parsing the scope itself, so defer compilation but
289
- // add the node as a reference
290
- Object.assign(this.referencesByName, node.contributesReferencesByName);
291
- }
292
- }
293
- return node;
294
- }
295
- bindCompiledScope(references) {
296
- const compiledTraversals = this.compileScope(references);
297
- for (const node of references) {
298
- if (node.jit) {
299
- // if node has already been bound to another scope or anonymous type, don't rebind it
300
- continue;
301
- }
302
- node.jit = true;
303
- node.traverseAllows =
304
- compiledTraversals[`${node.reference}Allows`].bind(compiledTraversals);
305
- if (node.isType() && !node.includesContextDependentPredicate) {
306
- // if the reference doesn't require context, we can assign over
307
- // it directly to avoid having to initialize it
308
- node.allows = node.traverseAllows;
309
- }
310
- node.traverseApply =
311
- compiledTraversals[`${node.reference}Apply`].bind(compiledTraversals);
312
- }
313
- }
314
- compileScope(references) {
315
- return new CompiledFunction()
316
- .block(`return`, (js) => {
317
- references.forEach((node) => {
318
- const allowsCompiler = new NodeCompiler("Allows").indent();
319
- node.compile(allowsCompiler);
320
- const applyCompiler = new NodeCompiler("Apply").indent();
321
- node.compile(applyCompiler);
322
- js.line(allowsCompiler.writeMethod(`${node.reference}Allows`) +
323
- ",\n" +
324
- applyCompiler.writeMethod(`${node.reference}Apply`) +
325
- ",");
326
- });
327
- return js;
328
- })
329
- .compile()();
330
- }
331
87
  }
332
- const resolutionsOfModule = (typeSet) => {
333
- const result = {};
334
- for (const k in typeSet) {
335
- const v = typeSet[k];
336
- if (hasArkKind(v, "module")) {
337
- const innerResolutions = resolutionsOfModule(v);
338
- const prefixedResolutions = morph(innerResolutions, (innerK, innerV) => [
339
- `${k}.${innerK}`,
340
- innerV
341
- ]);
342
- Object.assign(result, prefixedResolutions);
343
- }
344
- else if (hasArkKind(v, "generic")) {
345
- result[k] = v;
346
- }
347
- else {
348
- result[k] = v;
349
- }
350
- }
351
- return result;
352
- };
353
88
  export const writeShallowCycleErrorMessage = (name, seen) => `Alias '${name}' has a shallow resolution cycle: ${[...seen, name].join(":")}`;
354
- export const writeDuplicateNameMessage = (name) => `Duplicate name '${name}'`;
355
89
  export const parseScopeKey = (k) => {
356
- const isLocal = k[0] === "#";
357
- const name = isLocal ? k.slice(1) : k;
358
90
  const firstParamIndex = k.indexOf("<");
359
91
  if (firstParamIndex === -1) {
360
92
  return {
361
- isLocal,
362
- name,
93
+ name: k,
363
94
  params: []
364
95
  };
365
96
  }
@@ -367,8 +98,7 @@ export const parseScopeKey = (k) => {
367
98
  throwParseError(`'>' must be the last character of a generic declaration in a scope`);
368
99
  }
369
100
  return {
370
- isLocal,
371
- name: name.slice(0, firstParamIndex),
101
+ name: k.slice(0, firstParamIndex),
372
102
  params: parseGenericParams(k.slice(firstParamIndex + 1, -1))
373
103
  };
374
104
  };
package/out/scope.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"scope.js","sourceRoot":"","sources":["../scope.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,OAAO,EACP,OAAO,EACP,KAAK,EACL,kBAAkB,EAClB,eAAe,EAQf,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,gBAAgB,EAAoB,MAAM,WAAW,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAKxD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,iBAAiB,EAAoB,MAAM,YAAY,CAAA;AAChE,OAAO,EAAE,gBAAgB,EAA2B,MAAM,YAAY,CAAA;AACtE,OAAO,EACN,WAAW,EACX,6BAA6B,EAG7B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACN,kBAAkB,EAGlB,MAAM,qBAAqB,CAAA;AAC5B,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AA;IACF,CAAC;IACD,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QACtB,eAAe,CACd,oEAAoE,CACpE,CAAA;IACF,CAAC;IACD,OAAO;QACN,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,CAAC;QACjC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC,KAAK,CAAC,eAAe,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;KAC5D,CAAA;AACF,CAAC,CAAA"}
@@ -1,22 +1,22 @@
1
- import { CompiledFunction } from "@arktype/util";
2
- import type { Node, UnknownNode } from "../base.js";
3
- import type { Discriminant } from "../types/discriminate.js";
4
- import type { PrimitiveKind } from "./implement.js";
5
- import type { TraversalKind } from "./traversal.js";
1
+ import { CompiledFunction } from "@arktype/util"
2
+ import type { Node, UnknownNode } from "../base.js"
3
+ import type { Discriminant } from "../types/discriminate.js"
4
+ import type { PrimitiveKind } from "./implement.js"
5
+ import type { TraversalKind } from "./traversal.js"
6
6
  export type InvokeOptions = {
7
- arg?: string;
8
- kind?: TraversalKind;
9
- };
7
+ arg?: string
8
+ kind?: TraversalKind
9
+ }
10
10
  export declare class NodeCompiler extends CompiledFunction<["data", "ctx"]> {
11
- traversalKind: TraversalKind;
12
- path: string[];
13
- discriminants: Discriminant[];
14
- constructor(traversalKind: TraversalKind);
15
- invoke(node: UnknownNode, opts?: InvokeOptions): string;
16
- requiresContextFor(node: UnknownNode): boolean;
17
- checkReferenceKey(keyExpression: string, node: UnknownNode): this;
18
- check(node: UnknownNode, opts?: InvokeOptions): this;
19
- compilePrimitive(node: Node<PrimitiveKind>): this;
20
- writeMethod(name: string): string;
11
+ traversalKind: TraversalKind
12
+ path: string[]
13
+ discriminants: Discriminant[]
14
+ constructor(traversalKind: TraversalKind)
15
+ invoke(node: UnknownNode, opts?: InvokeOptions): string
16
+ requiresContextFor(node: UnknownNode): boolean
17
+ checkReferenceKey(keyExpression: string, node: UnknownNode): this
18
+ check(node: UnknownNode, opts?: InvokeOptions): this
19
+ compilePrimitive(node: Node<PrimitiveKind>): this
20
+ writeMethod(name: string): string
21
21
  }
22
- //# sourceMappingURL=compile.d.ts.map
22
+ //# sourceMappingURL=compile.d.ts.map
@@ -1,67 +1,79 @@
1
- import { CompiledFunction, compileSerializedValue } from "@arktype/util";
1
+ import { CompiledFunction, compileSerializedValue } from "@arktype/util"
2
2
  export class NodeCompiler extends CompiledFunction {
3
- traversalKind;
4
- path = [];
5
- discriminants = [];
6
- constructor(traversalKind) {
7
- super("data", "ctx");
8
- this.traversalKind = traversalKind;
9
- }
10
- invoke(node, opts) {
11
- const invokedKind = opts?.kind ?? this.traversalKind;
12
- const method = `${node.reference}${invokedKind}`;
13
- const arg = opts?.arg ?? this.data;
14
- if (this.requiresContextFor(node)) {
15
- return `this.${method}(${arg}, ${this.ctx})`;
16
- }
17
- return `this.${method}(${arg})`;
18
- }
19
- requiresContextFor(node) {
20
- return (this.traversalKind === "Apply" || node.includesContextDependentPredicate);
21
- }
22
- checkReferenceKey(keyExpression, node) {
23
- const requiresContext = this.requiresContextFor(node);
24
- if (requiresContext) {
25
- this.line(`${this.ctx}.path.push(${keyExpression})`);
26
- }
27
- this.check(node, {
28
- arg: `${this.data}${this.index(keyExpression)}`
29
- });
30
- if (requiresContext) {
31
- this.line(`${this.ctx}.path.pop()`);
32
- }
33
- return this;
34
- }
35
- check(node, opts) {
36
- return this.traversalKind === "Allows"
37
- ? this.if(`!${this.invoke(node, opts)}`, () => this.return(false))
38
- : this.line(this.invoke(node, opts));
39
- }
40
- compilePrimitive(node) {
41
- const pathString = this.path.join();
42
- if (node.kind === "domain" &&
43
- node.domain === "object" &&
44
- this.discriminants.some((d) => d.path.join().startsWith(pathString))) {
45
- // if we've already checked a path at least as long as the current one,
46
- // we don't need to revalidate that we're in an object
47
- return this;
48
- }
49
- if ((node.kind === "domain" || node.kind === "unit") &&
50
- this.discriminants.some((d) => d.path.join() === pathString &&
51
- (node.kind === "domain"
52
- ? d.kind === "domain" || d.kind === "value"
53
- : d.kind === "value"))) {
54
- // if the discriminant has already checked the domain at the current path
55
- // (or an exact value, implying a domain), we don't need to recheck it
56
- return this;
57
- }
58
- if (this.traversalKind === "Allows") {
59
- return this.return(node.compiledCondition);
60
- }
61
- return this.if(node.compiledNegation, () => this.line(`${this.ctx}.error(${node.compiledErrorContext})`));
62
- }
63
- writeMethod(name) {
64
- return `${name}(${this.argNames.join(", ")}){\n${this.body} }\n`;
65
- }
3
+ traversalKind
4
+ path = []
5
+ discriminants = []
6
+ constructor(traversalKind) {
7
+ super("data", "ctx")
8
+ this.traversalKind = traversalKind
9
+ }
10
+ invoke(node, opts) {
11
+ const invokedKind = opts?.kind ?? this.traversalKind
12
+ const method = `${node.reference}${invokedKind}`
13
+ const arg = opts?.arg ?? this.data
14
+ if (this.requiresContextFor(node)) {
15
+ return `this.${method}(${arg}, ${this.ctx})`
16
+ }
17
+ return `this.${method}(${arg})`
18
+ }
19
+ requiresContextFor(node) {
20
+ return (
21
+ this.traversalKind === "Apply" ||
22
+ node.includesContextDependentPredicate
23
+ )
24
+ }
25
+ checkReferenceKey(keyExpression, node) {
26
+ const requiresContext = this.requiresContextFor(node)
27
+ if (requiresContext) {
28
+ this.line(`${this.ctx}.path.push(${keyExpression})`)
29
+ }
30
+ this.check(node, {
31
+ arg: `${this.data}${this.index(keyExpression)}`
32
+ })
33
+ if (requiresContext) {
34
+ this.line(`${this.ctx}.path.pop()`)
35
+ }
36
+ return this
37
+ }
38
+ check(node, opts) {
39
+ return this.traversalKind === "Allows"
40
+ ? this.if(`!${this.invoke(node, opts)}`, () => this.return(false))
41
+ : this.line(this.invoke(node, opts))
42
+ }
43
+ compilePrimitive(node) {
44
+ const pathString = this.path.join()
45
+ if (
46
+ node.kind === "domain" &&
47
+ node.domain === "object" &&
48
+ this.discriminants.some((d) => d.path.join().startsWith(pathString))
49
+ ) {
50
+ // if we've already checked a path at least as long as the current one,
51
+ // we don't need to revalidate that we're in an object
52
+ return this
53
+ }
54
+ if (
55
+ (node.kind === "domain" || node.kind === "unit") &&
56
+ this.discriminants.some(
57
+ (d) =>
58
+ d.path.join() === pathString &&
59
+ (node.kind === "domain"
60
+ ? d.kind === "domain" || d.kind === "value"
61
+ : d.kind === "value")
62
+ )
63
+ ) {
64
+ // if the discriminant has already checked the domain at the current path
65
+ // (or an exact value, implying a domain), we don't need to recheck it
66
+ return this
67
+ }
68
+ if (this.traversalKind === "Allows") {
69
+ return this.return(node.compiledCondition)
70
+ }
71
+ return this.if(node.compiledNegation, () =>
72
+ this.line(`${this.ctx}.error(${node.compiledErrorContext})`)
73
+ )
74
+ }
75
+ writeMethod(name) {
76
+ return `${name}(${this.argNames.join(", ")}){\n${this.body} }\n`
77
+ }
66
78
  }
67
- //# sourceMappingURL=compile.js.map
79
+ //# sourceMappingURL=compile.js.map