arktype 0.1.2 → 0.1.4

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 (72) hide show
  1. package/dist/cjs/main.js +135 -20
  2. package/dist/cjs/nodes/branches.js +7 -7
  3. package/dist/cjs/nodes/compose.js +3 -2
  4. package/dist/cjs/nodes/discriminate.js +5 -4
  5. package/dist/cjs/nodes/functors.js +3 -3
  6. package/dist/cjs/nodes/node.js +1 -1
  7. package/dist/cjs/nodes/predicate.js +19 -14
  8. package/dist/cjs/nodes/rules/collapsibleSet.js +3 -4
  9. package/dist/cjs/nodes/rules/objectKind.js +78 -0
  10. package/dist/cjs/nodes/rules/range.js +2 -2
  11. package/dist/cjs/nodes/rules/rules.js +5 -5
  12. package/dist/cjs/parse/definition.js +26 -6
  13. package/dist/cjs/parse/string/ast.js +1 -1
  14. package/dist/cjs/parse/string/shift/operator/bounds.js +1 -1
  15. package/dist/cjs/parse/tuple/keyof.js +6 -7
  16. package/dist/cjs/parse/tuple/morph.js +2 -2
  17. package/dist/cjs/parse/tuple/tuple.js +1 -1
  18. package/dist/cjs/traverse/problems.js +18 -32
  19. package/dist/cjs/traverse/traverse.js +12 -12
  20. package/dist/cjs/utils/domains.js +10 -47
  21. package/dist/cjs/utils/generics.js +1 -3
  22. package/dist/cjs/utils/objectKinds.js +64 -0
  23. package/dist/cjs/utils/size.js +16 -0
  24. package/dist/mjs/main.js +134 -19
  25. package/dist/mjs/nodes/branches.js +7 -7
  26. package/dist/mjs/nodes/compose.js +3 -2
  27. package/dist/mjs/nodes/discriminate.js +6 -5
  28. package/dist/mjs/nodes/functors.js +3 -3
  29. package/dist/mjs/nodes/node.js +1 -1
  30. package/dist/mjs/nodes/predicate.js +20 -15
  31. package/dist/mjs/nodes/rules/collapsibleSet.js +3 -4
  32. package/dist/mjs/nodes/rules/{subdomain.js → objectKind.js} +10 -10
  33. package/dist/mjs/nodes/rules/range.js +1 -1
  34. package/dist/mjs/nodes/rules/rules.js +5 -5
  35. package/dist/mjs/parse/definition.js +27 -7
  36. package/dist/mjs/parse/string/ast.js +1 -1
  37. package/dist/mjs/parse/string/shift/operator/bounds.js +1 -1
  38. package/dist/mjs/parse/tuple/keyof.js +6 -7
  39. package/dist/mjs/parse/tuple/morph.js +2 -2
  40. package/dist/mjs/parse/tuple/tuple.js +1 -1
  41. package/dist/mjs/traverse/problems.js +18 -31
  42. package/dist/mjs/traverse/traverse.js +12 -12
  43. package/dist/mjs/utils/domains.js +9 -42
  44. package/dist/mjs/utils/generics.js +0 -1
  45. package/dist/mjs/utils/objectKinds.js +48 -0
  46. package/dist/mjs/utils/size.js +2 -0
  47. package/dist/tsconfig.temp.tsbuildinfo +1 -1
  48. package/dist/types/main.d.ts +82 -15
  49. package/dist/types/nodes/branches.d.ts +4 -4
  50. package/dist/types/nodes/compose.d.ts +12 -5
  51. package/dist/types/nodes/discriminate.d.ts +3 -2
  52. package/dist/types/nodes/infer.d.ts +11 -10
  53. package/dist/types/nodes/predicate.d.ts +2 -2
  54. package/dist/types/nodes/rules/objectKind.d.ts +15 -0
  55. package/dist/types/nodes/rules/range.d.ts +1 -1
  56. package/dist/types/nodes/rules/rules.d.ts +4 -4
  57. package/dist/types/parse/definition.d.ts +6 -5
  58. package/dist/types/parse/record.d.ts +2 -2
  59. package/dist/types/parse/string/ast.d.ts +7 -5
  60. package/dist/types/parse/string/reduce/shared.d.ts +1 -1
  61. package/dist/types/parse/string/shift/operator/bounds.d.ts +1 -1
  62. package/dist/types/parse/tuple/keyof.d.ts +8 -0
  63. package/dist/types/parse/tuple/tuple.d.ts +6 -12
  64. package/dist/types/traverse/problems.d.ts +25 -41
  65. package/dist/types/traverse/traverse.d.ts +24 -4
  66. package/dist/types/utils/domains.d.ts +11 -37
  67. package/dist/types/utils/generics.d.ts +2 -2
  68. package/dist/types/utils/objectKinds.d.ts +83 -0
  69. package/dist/types/utils/size.d.ts +3 -0
  70. package/package.json +4 -4
  71. package/dist/cjs/nodes/rules/subdomain.js +0 -78
  72. package/dist/types/nodes/rules/subdomain.d.ts +0 -15
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arktype",
3
3
  "description": "Isomorphic type syntax for TS/JS",
4
- "version": "0.1.2",
4
+ "version": "0.1.4",
5
5
  "author": {
6
6
  "name": "David Blass",
7
7
  "email": "david@arktype.io",
@@ -83,11 +83,11 @@
83
83
  },
84
84
  "scripts": {
85
85
  "//temporarily disabled pr checks": "pnpm testRepo",
86
- "prChecks": "pnpm install && pnpm build && pnpm typecheck && pnpm lint && pnpm test && pnpm buildDocs",
86
+ "prChecks": "pnpm install && pnpm build && pnpm typecheck && pnpm lint && pnpm test && pnpm docgen && pnpm buildSite",
87
87
  "typecheck": "tsc --noEmit",
88
88
  "build": "ts-node ./dev/scripts/build.ts",
89
- "buildRepo": "pnpm build && pnpm buildDocs",
90
- "buildDocs": "pnpm docgen && cd dev/arktype.io && pnpm install && pnpm build",
89
+ "buildRepo": "pnpm build && pnpm docgen && pnpm buildSite",
90
+ "buildSite": "cd dev/arktype.io && pnpm install && pnpm build",
91
91
  "docgen": "ts-node ./dev/scripts/docgen.ts",
92
92
  "test": "ts-node ./dev/attest/cli.ts --cmd mocha",
93
93
  "testCov": "c8 pnpm test",
@@ -1,78 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
6
- for(var name in all)Object.defineProperty(target, name, {
7
- enumerable: true,
8
- get: all[name]
9
- });
10
- }
11
- _export(exports, {
12
- subdomainIntersection: ()=>subdomainIntersection,
13
- subdomainPathSegments: ()=>subdomainPathSegments,
14
- flattenSubdomain: ()=>flattenSubdomain
15
- });
16
- const _errorsTs = require("../../utils/errors.js");
17
- const _composeTs = require("../compose.js");
18
- const _nodeTs = require("../node.js");
19
- const subdomainIntersection = (0, _composeTs.composeIntersection)((l, r, state)=>{
20
- if (typeof l === "string") {
21
- if (typeof r === "string") {
22
- return l === r ? (0, _composeTs.equality)() : state.addDisjoint("subdomain", l, r);
23
- }
24
- return l === r[0] ? r : state.addDisjoint("subdomain", l, r[0]);
25
- }
26
- if (typeof r === "string") {
27
- return l[0] === r ? l : state.addDisjoint("subdomain", l[0], r);
28
- }
29
- if (l[0] !== r[0]) {
30
- return state.addDisjoint("subdomain", l[0], r[0]);
31
- }
32
- const result = [
33
- l[0]
34
- ];
35
- let lImpliesR = true;
36
- let rImpliesL = true;
37
- for(let i = 1; i < l.length; i++){
38
- const lNode = l[i];
39
- const rNode = r[i];
40
- state.path.push(subdomainParameterToPathSegment(l[0], i));
41
- const parameterResult = (0, _nodeTs.nodeIntersection)(lNode, rNode, state);
42
- state.path.pop();
43
- if ((0, _composeTs.isEquality)(parameterResult)) {
44
- result[i] = lNode;
45
- } else if (parameterResult === l) {
46
- result[i] = lNode;
47
- rImpliesL = false;
48
- } else if (parameterResult === r) {
49
- result[i] = rNode;
50
- lImpliesR = false;
51
- } else if ((0, _composeTs.isDisjoint)(parameterResult)) {
52
- return parameterResult;
53
- } else {
54
- result[i] = parameterResult;
55
- lImpliesR = false;
56
- rImpliesL = false;
57
- }
58
- }
59
- return lImpliesR ? rImpliesL ? (0, _composeTs.equality)() : l : rImpliesL ? r : result;
60
- });
61
- const subdomainParameterToPathSegment = (subdomain, i)=>subdomain === "Array" ? "${number}" : subdomain === "Set" ? "${item}" : subdomain === "Map" ? i === 1 ? "${key}" : "${value}" : (0, _errorsTs.throwInternalError)(`Unexpected parameterized subdomain '${subdomain}'`);
62
- const subdomainPathSegments = {
63
- "${number}": true,
64
- "${item}": true,
65
- "${key}": true,
66
- "${value}": true
67
- };
68
- const flattenSubdomain = (entries, rule, ctx)=>entries.push([
69
- "subdomain",
70
- typeof rule === "string" ? rule : rule[0] === "Map" ? [
71
- rule[0],
72
- (0, _nodeTs.flattenNode)(rule[1], ctx),
73
- (0, _nodeTs.flattenNode)(rule[2], ctx)
74
- ] : [
75
- rule[0],
76
- (0, _nodeTs.flattenNode)(rule[1], ctx)
77
- ]
78
- ]);
@@ -1,15 +0,0 @@
1
- import type { Subdomain } from "../../utils/domains.js";
2
- import type { Dict } from "../../utils/generics.js";
3
- import type { TraversalNode, TypeNode } from "../node.js";
4
- import type { FlattenAndPushRule } from "./rules.js";
5
- export type SubdomainRule<$ = Dict> = Subdomain | readonly ["Array", TypeNode<$>] | readonly ["Array", TypeNode<$>] | readonly ["Set", TypeNode<$>] | readonly ["Map", TypeNode<$>, TypeNode<$>];
6
- export type TraversalSubdomainRule = Subdomain | readonly ["Array", TraversalNode] | readonly ["Array", TraversalNode] | readonly ["Set", TraversalNode] | readonly ["Map", TraversalNode, TraversalNode];
7
- export declare const subdomainIntersection: import("../compose.js").Intersector<SubdomainRule<Dict> | undefined>;
8
- export declare const subdomainPathSegments: {
9
- readonly "${number}": true;
10
- readonly "${item}": true;
11
- readonly "${key}": true;
12
- readonly "${value}": true;
13
- };
14
- export type SubdomainPathSegment = keyof typeof subdomainPathSegments;
15
- export declare const flattenSubdomain: FlattenAndPushRule<SubdomainRule>;