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.
- package/dist/cjs/main.js +135 -20
- package/dist/cjs/nodes/branches.js +7 -7
- package/dist/cjs/nodes/compose.js +3 -2
- package/dist/cjs/nodes/discriminate.js +5 -4
- package/dist/cjs/nodes/functors.js +3 -3
- package/dist/cjs/nodes/node.js +1 -1
- package/dist/cjs/nodes/predicate.js +19 -14
- package/dist/cjs/nodes/rules/collapsibleSet.js +3 -4
- package/dist/cjs/nodes/rules/objectKind.js +78 -0
- package/dist/cjs/nodes/rules/range.js +2 -2
- package/dist/cjs/nodes/rules/rules.js +5 -5
- package/dist/cjs/parse/definition.js +26 -6
- package/dist/cjs/parse/string/ast.js +1 -1
- package/dist/cjs/parse/string/shift/operator/bounds.js +1 -1
- package/dist/cjs/parse/tuple/keyof.js +6 -7
- package/dist/cjs/parse/tuple/morph.js +2 -2
- package/dist/cjs/parse/tuple/tuple.js +1 -1
- package/dist/cjs/traverse/problems.js +18 -32
- package/dist/cjs/traverse/traverse.js +12 -12
- package/dist/cjs/utils/domains.js +10 -47
- package/dist/cjs/utils/generics.js +1 -3
- package/dist/cjs/utils/objectKinds.js +64 -0
- package/dist/cjs/utils/size.js +16 -0
- package/dist/mjs/main.js +134 -19
- package/dist/mjs/nodes/branches.js +7 -7
- package/dist/mjs/nodes/compose.js +3 -2
- package/dist/mjs/nodes/discriminate.js +6 -5
- package/dist/mjs/nodes/functors.js +3 -3
- package/dist/mjs/nodes/node.js +1 -1
- package/dist/mjs/nodes/predicate.js +20 -15
- package/dist/mjs/nodes/rules/collapsibleSet.js +3 -4
- package/dist/mjs/nodes/rules/{subdomain.js → objectKind.js} +10 -10
- package/dist/mjs/nodes/rules/range.js +1 -1
- package/dist/mjs/nodes/rules/rules.js +5 -5
- package/dist/mjs/parse/definition.js +27 -7
- package/dist/mjs/parse/string/ast.js +1 -1
- package/dist/mjs/parse/string/shift/operator/bounds.js +1 -1
- package/dist/mjs/parse/tuple/keyof.js +6 -7
- package/dist/mjs/parse/tuple/morph.js +2 -2
- package/dist/mjs/parse/tuple/tuple.js +1 -1
- package/dist/mjs/traverse/problems.js +18 -31
- package/dist/mjs/traverse/traverse.js +12 -12
- package/dist/mjs/utils/domains.js +9 -42
- package/dist/mjs/utils/generics.js +0 -1
- package/dist/mjs/utils/objectKinds.js +48 -0
- package/dist/mjs/utils/size.js +2 -0
- package/dist/tsconfig.temp.tsbuildinfo +1 -1
- package/dist/types/main.d.ts +82 -15
- package/dist/types/nodes/branches.d.ts +4 -4
- package/dist/types/nodes/compose.d.ts +12 -5
- package/dist/types/nodes/discriminate.d.ts +3 -2
- package/dist/types/nodes/infer.d.ts +11 -10
- package/dist/types/nodes/predicate.d.ts +2 -2
- package/dist/types/nodes/rules/objectKind.d.ts +15 -0
- package/dist/types/nodes/rules/range.d.ts +1 -1
- package/dist/types/nodes/rules/rules.d.ts +4 -4
- package/dist/types/parse/definition.d.ts +6 -5
- package/dist/types/parse/record.d.ts +2 -2
- package/dist/types/parse/string/ast.d.ts +7 -5
- package/dist/types/parse/string/reduce/shared.d.ts +1 -1
- package/dist/types/parse/string/shift/operator/bounds.d.ts +1 -1
- package/dist/types/parse/tuple/keyof.d.ts +8 -0
- package/dist/types/parse/tuple/tuple.d.ts +6 -12
- package/dist/types/traverse/problems.d.ts +25 -41
- package/dist/types/traverse/traverse.d.ts +24 -4
- package/dist/types/utils/domains.d.ts +11 -37
- package/dist/types/utils/generics.d.ts +2 -2
- package/dist/types/utils/objectKinds.d.ts +83 -0
- package/dist/types/utils/size.d.ts +3 -0
- package/package.json +4 -4
- package/dist/cjs/nodes/rules/subdomain.js +0 -78
- 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.
|
|
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
|
|
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
|
|
90
|
-
"
|
|
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>;
|