arktype 1.0.28-alpha → 1.1.0-dev-2
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/main.d.ts +11 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +8 -0
- package/dist/main.js.map +1 -0
- package/dist/match.d.ts +46 -0
- package/dist/match.d.ts.map +1 -0
- package/dist/match.js +23 -0
- package/dist/match.js.map +1 -0
- package/dist/parser/definition.d.ts +32 -0
- package/dist/parser/definition.d.ts.map +1 -0
- package/dist/parser/definition.js +29 -0
- package/dist/parser/definition.js.map +1 -0
- package/dist/parser/generic.d.ts +44 -0
- package/dist/parser/generic.d.ts.map +1 -0
- package/dist/parser/generic.js +46 -0
- package/dist/parser/generic.js.map +1 -0
- package/dist/parser/objectLiteral.d.ts +24 -0
- package/dist/parser/objectLiteral.d.ts.map +1 -0
- package/dist/parser/objectLiteral.js +38 -0
- package/dist/parser/objectLiteral.js.map +1 -0
- package/dist/parser/semantic/bounds.d.ts +13 -0
- package/dist/parser/semantic/bounds.d.ts.map +1 -0
- package/dist/parser/semantic/bounds.js +2 -0
- package/dist/parser/semantic/bounds.js.map +1 -0
- package/dist/parser/semantic/divisor.d.ts +9 -0
- package/dist/parser/semantic/divisor.d.ts.map +1 -0
- package/dist/parser/semantic/divisor.js +2 -0
- package/dist/parser/semantic/divisor.js.map +1 -0
- package/dist/parser/semantic/intersections.d.ts +15 -0
- package/dist/parser/semantic/intersections.d.ts.map +1 -0
- package/dist/parser/semantic/intersections.js +2 -0
- package/dist/parser/semantic/intersections.js.map +1 -0
- package/dist/parser/semantic/semantic.d.ts +22 -0
- package/dist/parser/semantic/semantic.d.ts.map +1 -0
- package/dist/parser/semantic/semantic.js +2 -0
- package/dist/parser/semantic/semantic.js.map +1 -0
- package/dist/parser/semantic/utils.d.ts +8 -0
- package/dist/parser/semantic/utils.d.ts.map +1 -0
- package/dist/parser/semantic/utils.js +2 -0
- package/dist/parser/semantic/utils.js.map +1 -0
- package/dist/parser/semantic/validate.d.ts +24 -0
- package/dist/parser/semantic/validate.d.ts.map +1 -0
- package/dist/parser/semantic/validate.js +2 -0
- package/dist/parser/semantic/validate.js.map +1 -0
- package/dist/parser/shared.d.ts +48 -0
- package/dist/parser/shared.d.ts.map +1 -0
- package/dist/parser/shared.js +41 -0
- package/dist/parser/shared.js.map +1 -0
- package/dist/parser/string/reduce/dynamic.d.ts +40 -0
- package/dist/parser/string/reduce/dynamic.d.ts.map +1 -0
- package/dist/parser/string/reduce/dynamic.js +122 -0
- package/dist/parser/string/reduce/dynamic.js.map +1 -0
- package/dist/parser/string/reduce/shared.d.ts +29 -0
- package/dist/parser/string/reduce/shared.d.ts.map +1 -0
- package/dist/parser/string/reduce/shared.js +7 -0
- package/dist/parser/string/reduce/shared.js.map +1 -0
- package/dist/parser/string/reduce/static.d.ts +177 -0
- package/dist/parser/string/reduce/static.d.ts.map +1 -0
- package/dist/parser/string/reduce/static.js +2 -0
- package/dist/parser/string/reduce/static.js.map +1 -0
- package/dist/parser/string/shift/operand/date.d.ts +11 -0
- package/dist/parser/string/shift/operand/date.d.ts.map +1 -0
- package/dist/parser/string/shift/operand/date.js +26 -0
- package/dist/parser/string/shift/operand/date.js.map +1 -0
- package/dist/parser/string/shift/operand/enclosed.d.ts +49 -0
- package/dist/parser/string/shift/operand/enclosed.d.ts.map +1 -0
- package/dist/parser/string/shift/operand/enclosed.js +50 -0
- package/dist/parser/string/shift/operand/enclosed.js.map +1 -0
- package/dist/parser/string/shift/operand/operand.d.ts +9 -0
- package/dist/parser/string/shift/operand/operand.d.ts.map +1 -0
- package/dist/parser/string/shift/operand/operand.js +17 -0
- package/dist/parser/string/shift/operand/operand.js.map +1 -0
- package/dist/parser/string/shift/operand/unenclosed.d.ts +36 -0
- package/dist/parser/string/shift/operand/unenclosed.d.ts.map +1 -0
- package/dist/parser/string/shift/operand/unenclosed.js +68 -0
- package/dist/parser/string/shift/operand/unenclosed.js.map +1 -0
- package/dist/parser/string/shift/operator/bounds.d.ts +55 -0
- package/dist/parser/string/shift/operator/bounds.d.ts.map +1 -0
- package/dist/parser/string/shift/operator/bounds.js +95 -0
- package/dist/parser/string/shift/operator/bounds.js.map +1 -0
- package/dist/parser/string/shift/operator/divisor.d.ts +9 -0
- package/dist/parser/string/shift/operator/divisor.d.ts.map +1 -0
- package/dist/parser/string/shift/operator/divisor.js +13 -0
- package/dist/parser/string/shift/operator/divisor.js.map +1 -0
- package/dist/parser/string/shift/operator/operator.d.ts +13 -0
- package/dist/parser/string/shift/operator/operator.d.ts.map +1 -0
- package/dist/parser/string/shift/operator/operator.js +29 -0
- package/dist/parser/string/shift/operator/operator.js.map +1 -0
- package/dist/parser/string/shift/scanner.d.ts +71 -0
- package/dist/parser/string/shift/scanner.d.ts.map +1 -0
- package/dist/parser/string/shift/scanner.js +99 -0
- package/dist/parser/string/shift/scanner.js.map +1 -0
- package/dist/parser/string/string.d.ts +26 -0
- package/dist/parser/string/string.d.ts.map +1 -0
- package/dist/parser/string/string.js +31 -0
- package/dist/parser/string/string.js.map +1 -0
- package/dist/parser/tuple.d.ts +73 -0
- package/dist/parser/tuple.d.ts.map +1 -0
- package/dist/parser/tuple.js +134 -0
- package/dist/parser/tuple.js.map +1 -0
- package/dist/scope.d.ts +159 -0
- package/dist/scope.d.ts.map +1 -0
- package/dist/scope.js +248 -0
- package/dist/scope.js.map +1 -0
- package/dist/scopes/ark.d.ts +38 -0
- package/dist/scopes/ark.d.ts.map +1 -0
- package/dist/scopes/ark.js +24 -0
- package/dist/scopes/ark.js.map +1 -0
- package/dist/scopes/jsObjects.d.ts +19 -0
- package/dist/scopes/jsObjects.d.ts.map +1 -0
- package/dist/scopes/jsObjects.js +15 -0
- package/dist/scopes/jsObjects.js.map +1 -0
- package/dist/scopes/parsing.d.ts +18 -0
- package/dist/scopes/parsing.d.ts.map +1 -0
- package/dist/scopes/parsing.js +61 -0
- package/dist/scopes/parsing.js.map +1 -0
- package/dist/scopes/tsGenerics.d.ts +17 -0
- package/dist/scopes/tsGenerics.d.ts.map +1 -0
- package/dist/scopes/tsGenerics.js +13 -0
- package/dist/scopes/tsGenerics.js.map +1 -0
- package/dist/scopes/tsKeywords.d.ts +24 -0
- package/dist/scopes/tsKeywords.d.ts.map +1 -0
- package/dist/scopes/tsKeywords.js +20 -0
- package/dist/scopes/tsKeywords.js.map +1 -0
- package/dist/scopes/utils/creditCard.d.ts +3 -0
- package/dist/scopes/utils/creditCard.d.ts.map +1 -0
- package/dist/{mjs/scopes/validation → scopes/utils}/creditCard.js +14 -12
- package/dist/scopes/utils/creditCard.js.map +1 -0
- package/dist/{types/scopes/validation → scopes/utils}/date.d.ts +3 -2
- package/dist/scopes/utils/date.d.ts.map +1 -0
- package/dist/{mjs/scopes/validation → scopes/utils}/date.js +24 -19
- package/dist/scopes/utils/date.js.map +1 -0
- package/dist/scopes/validation.d.ts +20 -0
- package/dist/scopes/validation.d.ts.map +1 -0
- package/dist/scopes/validation.js +57 -0
- package/dist/scopes/validation.js.map +1 -0
- package/dist/type.d.ts +101 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/type.js +138 -0
- package/dist/type.js.map +1 -0
- package/main.ts +20 -0
- package/match.ts +137 -0
- package/package.json +41 -108
- package/parser/definition.ts +156 -0
- package/parser/generic.ts +208 -0
- package/parser/objectLiteral.ts +120 -0
- package/parser/semantic/bounds.ts +63 -0
- package/parser/semantic/divisor.ts +13 -0
- package/parser/semantic/intersections.ts +47 -0
- package/parser/semantic/semantic.ts +107 -0
- package/parser/semantic/utils.ts +26 -0
- package/parser/semantic/validate.ts +105 -0
- package/parser/shared.ts +141 -0
- package/parser/string/reduce/dynamic.ts +181 -0
- package/parser/string/reduce/shared.ts +73 -0
- package/parser/string/reduce/static.ts +300 -0
- package/parser/string/shift/operand/date.ts +57 -0
- package/parser/string/shift/operand/enclosed.ts +119 -0
- package/parser/string/shift/operand/operand.ts +48 -0
- package/parser/string/shift/operand/unenclosed.ts +282 -0
- package/parser/string/shift/operator/bounds.ts +229 -0
- package/parser/string/shift/operator/divisor.ts +36 -0
- package/parser/string/shift/operator/operator.ts +82 -0
- package/parser/string/shift/scanner.ts +209 -0
- package/parser/string/string.ts +93 -0
- package/parser/tuple.ts +475 -0
- package/scope.ts +573 -0
- package/scopes/ark.ts +64 -0
- package/scopes/jsObjects.ts +29 -0
- package/scopes/parsing.ts +81 -0
- package/scopes/tsGenerics.ts +28 -0
- package/scopes/tsKeywords.ts +39 -0
- package/scopes/utils/creditCard.ts +37 -0
- package/scopes/utils/date.ts +108 -0
- package/scopes/validation.ts +81 -0
- package/type.ts +403 -0
- package/LICENSE +0 -7
- package/README.md +0 -351
- package/dist/cjs/main.js +0 -38
- package/dist/cjs/nodes/branch.js +0 -140
- package/dist/cjs/nodes/compose.js +0 -163
- package/dist/cjs/nodes/discriminate.js +0 -265
- package/dist/cjs/nodes/node.js +0 -139
- package/dist/cjs/nodes/predicate.js +0 -86
- package/dist/cjs/nodes/rules/class.js +0 -25
- package/dist/cjs/nodes/rules/collapsibleSet.js +0 -48
- package/dist/cjs/nodes/rules/divisor.js +0 -29
- package/dist/cjs/nodes/rules/props.js +0 -167
- package/dist/cjs/nodes/rules/range.js +0 -105
- package/dist/cjs/nodes/rules/regex.js +0 -26
- package/dist/cjs/nodes/rules/rules.js +0 -123
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/parse/ast/ast.js +0 -4
- package/dist/cjs/parse/ast/bound.js +0 -16
- package/dist/cjs/parse/ast/config.js +0 -13
- package/dist/cjs/parse/ast/distributableFunction.js +0 -48
- package/dist/cjs/parse/ast/divisor.js +0 -9
- package/dist/cjs/parse/ast/intersection.js +0 -30
- package/dist/cjs/parse/ast/keyof.js +0 -111
- package/dist/cjs/parse/ast/morph.js +0 -58
- package/dist/cjs/parse/ast/narrow.js +0 -22
- package/dist/cjs/parse/ast/node.js +0 -4
- package/dist/cjs/parse/ast/tuple.js +0 -94
- package/dist/cjs/parse/ast/union.js +0 -9
- package/dist/cjs/parse/ast/utils.js +0 -4
- package/dist/cjs/parse/definition.js +0 -61
- package/dist/cjs/parse/record.js +0 -37
- package/dist/cjs/parse/string/reduce/dynamic.js +0 -167
- package/dist/cjs/parse/string/reduce/shared.js +0 -23
- package/dist/cjs/parse/string/reduce/static.js +0 -4
- package/dist/cjs/parse/string/shift/operand/enclosed.js +0 -54
- package/dist/cjs/parse/string/shift/operand/operand.js +0 -11
- package/dist/cjs/parse/string/shift/operand/unenclosed.js +0 -53
- package/dist/cjs/parse/string/shift/operator/bounds.js +0 -87
- package/dist/cjs/parse/string/shift/operator/divisor.js +0 -35
- package/dist/cjs/parse/string/shift/operator/operator.js +0 -26
- package/dist/cjs/parse/string/shift/scanner.js +0 -114
- package/dist/cjs/parse/string/string.js +0 -43
- package/dist/cjs/scopes/ark.js +0 -45
- package/dist/cjs/scopes/cache.js +0 -52
- package/dist/cjs/scopes/expressions.js +0 -29
- package/dist/cjs/scopes/jsObjects.js +0 -93
- package/dist/cjs/scopes/scope.js +0 -323
- package/dist/cjs/scopes/tsKeywords.js +0 -113
- package/dist/cjs/scopes/type.js +0 -50
- package/dist/cjs/scopes/validation/creditCard.js +0 -47
- package/dist/cjs/scopes/validation/date.js +0 -62
- package/dist/cjs/scopes/validation/validation.js +0 -108
- package/dist/cjs/traverse/problems.js +0 -281
- package/dist/cjs/traverse/traverse.js +0 -390
- package/dist/cjs/utils/chainableNoOpProxy.js +0 -23
- package/dist/cjs/utils/data.js +0 -53
- package/dist/cjs/utils/domains.js +0 -30
- package/dist/cjs/utils/errors.js +0 -26
- package/dist/cjs/utils/freeze.js +0 -15
- package/dist/cjs/utils/generics.js +0 -63
- package/dist/cjs/utils/numericLiterals.js +0 -75
- package/dist/cjs/utils/objectKinds.js +0 -69
- package/dist/cjs/utils/paths.js +0 -32
- package/dist/cjs/utils/serialize.js +0 -74
- package/dist/cjs/utils/unionToTuple.js +0 -4
- package/dist/mjs/main.js +0 -8
- package/dist/mjs/nodes/branch.js +0 -123
- package/dist/mjs/nodes/compose.js +0 -141
- package/dist/mjs/nodes/discriminate.js +0 -250
- package/dist/mjs/nodes/node.js +0 -117
- package/dist/mjs/nodes/predicate.js +0 -69
- package/dist/mjs/nodes/rules/class.js +0 -11
- package/dist/mjs/nodes/rules/collapsibleSet.js +0 -34
- package/dist/mjs/nodes/rules/divisor.js +0 -15
- package/dist/mjs/nodes/rules/props.js +0 -149
- package/dist/mjs/nodes/rules/range.js +0 -86
- package/dist/mjs/nodes/rules/regex.js +0 -11
- package/dist/mjs/nodes/rules/rules.js +0 -106
- package/dist/mjs/package.json +0 -3
- package/dist/mjs/parse/ast/ast.js +0 -1
- package/dist/mjs/parse/ast/bound.js +0 -2
- package/dist/mjs/parse/ast/config.js +0 -9
- package/dist/mjs/parse/ast/distributableFunction.js +0 -34
- package/dist/mjs/parse/ast/divisor.js +0 -1
- package/dist/mjs/parse/ast/intersection.js +0 -16
- package/dist/mjs/parse/ast/keyof.js +0 -103
- package/dist/mjs/parse/ast/morph.js +0 -44
- package/dist/mjs/parse/ast/narrow.js +0 -14
- package/dist/mjs/parse/ast/node.js +0 -1
- package/dist/mjs/parse/ast/tuple.js +0 -80
- package/dist/mjs/parse/ast/union.js +0 -1
- package/dist/mjs/parse/ast/utils.js +0 -1
- package/dist/mjs/parse/definition.js +0 -46
- package/dist/mjs/parse/record.js +0 -29
- package/dist/mjs/parse/string/reduce/dynamic.js +0 -159
- package/dist/mjs/parse/string/reduce/shared.js +0 -6
- package/dist/mjs/parse/string/reduce/static.js +0 -1
- package/dist/mjs/parse/string/shift/operand/enclosed.js +0 -39
- package/dist/mjs/parse/string/shift/operand/operand.js +0 -3
- package/dist/mjs/parse/string/shift/operand/unenclosed.js +0 -36
- package/dist/mjs/parse/string/shift/operator/bounds.js +0 -70
- package/dist/mjs/parse/string/shift/operator/divisor.js +0 -21
- package/dist/mjs/parse/string/shift/operator/operator.js +0 -13
- package/dist/mjs/parse/string/shift/scanner.js +0 -106
- package/dist/mjs/parse/string/string.js +0 -28
- package/dist/mjs/scopes/ark.js +0 -28
- package/dist/mjs/scopes/cache.js +0 -38
- package/dist/mjs/scopes/expressions.js +0 -89
- package/dist/mjs/scopes/jsObjects.js +0 -82
- package/dist/mjs/scopes/scope.js +0 -303
- package/dist/mjs/scopes/tsKeywords.js +0 -116
- package/dist/mjs/scopes/type.js +0 -35
- package/dist/mjs/scopes/validation/validation.js +0 -112
- package/dist/mjs/traverse/problems.js +0 -260
- package/dist/mjs/traverse/traverse.js +0 -373
- package/dist/mjs/utils/chainableNoOpProxy.js +0 -15
- package/dist/mjs/utils/data.js +0 -38
- package/dist/mjs/utils/domains.js +0 -15
- package/dist/mjs/utils/errors.js +0 -10
- package/dist/mjs/utils/freeze.js +0 -7
- package/dist/mjs/utils/generics.js +0 -38
- package/dist/mjs/utils/numericLiterals.js +0 -72
- package/dist/mjs/utils/objectKinds.js +0 -55
- package/dist/mjs/utils/paths.js +0 -18
- package/dist/mjs/utils/serialize.js +0 -58
- package/dist/mjs/utils/unionToTuple.js +0 -1
- package/dist/tsconfig.temp.tsbuildinfo +0 -1
- package/dist/types/main.d.ts +0 -15
- package/dist/types/nodes/branch.d.ts +0 -29
- package/dist/types/nodes/compose.d.ts +0 -98
- package/dist/types/nodes/discriminate.d.ts +0 -26
- package/dist/types/nodes/node.d.ts +0 -69
- package/dist/types/nodes/predicate.d.ts +0 -18
- package/dist/types/nodes/rules/class.d.ts +0 -4
- package/dist/types/nodes/rules/collapsibleSet.d.ts +0 -4
- package/dist/types/nodes/rules/divisor.d.ts +0 -3
- package/dist/types/nodes/rules/props.d.ts +0 -43
- package/dist/types/nodes/rules/range.d.ts +0 -34
- package/dist/types/nodes/rules/regex.d.ts +0 -5
- package/dist/types/nodes/rules/rules.d.ts +0 -33
- package/dist/types/parse/ast/ast.d.ts +0 -24
- package/dist/types/parse/ast/bound.d.ts +0 -27
- package/dist/types/parse/ast/config.d.ts +0 -15
- package/dist/types/parse/ast/distributableFunction.d.ts +0 -18
- package/dist/types/parse/ast/divisor.d.ts +0 -13
- package/dist/types/parse/ast/intersection.d.ts +0 -31
- package/dist/types/parse/ast/keyof.d.ts +0 -10
- package/dist/types/parse/ast/morph.d.ts +0 -18
- package/dist/types/parse/ast/narrow.d.ts +0 -21
- package/dist/types/parse/ast/node.d.ts +0 -35
- package/dist/types/parse/ast/tuple.d.ts +0 -41
- package/dist/types/parse/ast/union.d.ts +0 -17
- package/dist/types/parse/ast/utils.d.ts +0 -7
- package/dist/types/parse/definition.d.ts +0 -30
- package/dist/types/parse/record.d.ts +0 -26
- package/dist/types/parse/string/reduce/dynamic.d.ts +0 -34
- package/dist/types/parse/string/reduce/shared.d.ts +0 -25
- package/dist/types/parse/string/reduce/static.d.ts +0 -130
- package/dist/types/parse/string/shift/operand/enclosed.d.ts +0 -28
- package/dist/types/parse/string/shift/operand/operand.d.ts +0 -9
- package/dist/types/parse/string/shift/operand/unenclosed.d.ts +0 -18
- package/dist/types/parse/string/shift/operator/bounds.d.ts +0 -21
- package/dist/types/parse/string/shift/operator/divisor.d.ts +0 -13
- package/dist/types/parse/string/shift/operator/operator.d.ts +0 -13
- package/dist/types/parse/string/shift/scanner.d.ts +0 -89
- package/dist/types/parse/string/string.d.ts +0 -25
- package/dist/types/scopes/ark.d.ts +0 -209
- package/dist/types/scopes/cache.d.ts +0 -14
- package/dist/types/scopes/expressions.d.ts +0 -136
- package/dist/types/scopes/jsObjects.d.ts +0 -26
- package/dist/types/scopes/scope.d.ts +0 -99
- package/dist/types/scopes/tsKeywords.d.ts +0 -50
- package/dist/types/scopes/type.d.ts +0 -67
- package/dist/types/scopes/validation/creditCard.d.ts +0 -2
- package/dist/types/scopes/validation/validation.d.ts +0 -49
- package/dist/types/traverse/problems.d.ts +0 -88
- package/dist/types/traverse/traverse.d.ts +0 -55
- package/dist/types/utils/chainableNoOpProxy.d.ts +0 -14
- package/dist/types/utils/data.d.ts +0 -13
- package/dist/types/utils/domains.d.ts +0 -32
- package/dist/types/utils/errors.d.ts +0 -6
- package/dist/types/utils/freeze.d.ts +0 -2
- package/dist/types/utils/generics.d.ts +0 -125
- package/dist/types/utils/numericLiterals.d.ts +0 -46
- package/dist/types/utils/objectKinds.d.ts +0 -84
- package/dist/types/utils/paths.d.ts +0 -9
- package/dist/types/utils/serialize.d.ts +0 -37
- package/dist/types/utils/unionToTuple.d.ts +0 -11
package/dist/mjs/scopes/ark.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { jsObjects, jsObjectsScope } from "./jsObjects.js";
|
|
2
|
-
import { rootScope, scope } from "./scope.js";
|
|
3
|
-
import { tsKeywords, tsKeywordsScope } from "./tsKeywords.js";
|
|
4
|
-
import { validation, validationScope } from "./validation/validation.js";
|
|
5
|
-
export const arkScope = scope({}, {
|
|
6
|
-
name: "standard",
|
|
7
|
-
includes: [
|
|
8
|
-
tsKeywords,
|
|
9
|
-
jsObjects,
|
|
10
|
-
validation
|
|
11
|
-
],
|
|
12
|
-
standard: false
|
|
13
|
-
});
|
|
14
|
-
export const ark = arkScope.compile();
|
|
15
|
-
export const scopes = {
|
|
16
|
-
root: rootScope,
|
|
17
|
-
tsKeywords: tsKeywordsScope,
|
|
18
|
-
jsObjects: jsObjectsScope,
|
|
19
|
-
validation: validationScope,
|
|
20
|
-
ark: arkScope
|
|
21
|
-
};
|
|
22
|
-
export const spaces = {
|
|
23
|
-
tsKeywords,
|
|
24
|
-
jsObjects,
|
|
25
|
-
validation,
|
|
26
|
-
ark
|
|
27
|
-
};
|
|
28
|
-
export const type = arkScope.type;
|
package/dist/mjs/scopes/cache.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
function _defineProperty(obj, key, value) {
|
|
2
|
-
if (key in obj) {
|
|
3
|
-
Object.defineProperty(obj, key, {
|
|
4
|
-
value: value,
|
|
5
|
-
enumerable: true,
|
|
6
|
-
configurable: true,
|
|
7
|
-
writable: true
|
|
8
|
-
});
|
|
9
|
-
} else {
|
|
10
|
-
obj[key] = value;
|
|
11
|
-
}
|
|
12
|
-
return obj;
|
|
13
|
-
}
|
|
14
|
-
import { deepFreeze } from "../utils/freeze.js";
|
|
15
|
-
export class Cache {
|
|
16
|
-
get root() {
|
|
17
|
-
return this.cache;
|
|
18
|
-
}
|
|
19
|
-
has(name) {
|
|
20
|
-
return name in this.cache;
|
|
21
|
-
}
|
|
22
|
-
get(name) {
|
|
23
|
-
return this.cache[name];
|
|
24
|
-
}
|
|
25
|
-
set(name, item) {
|
|
26
|
-
this.cache[name] = item;
|
|
27
|
-
return item;
|
|
28
|
-
}
|
|
29
|
-
constructor(){
|
|
30
|
-
_defineProperty(this, "cache", {});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
export class FreezingCache extends Cache {
|
|
34
|
-
set(name, item) {
|
|
35
|
-
this.cache[name] = deepFreeze(item);
|
|
36
|
-
return item;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { scopes } from "./ark.js";
|
|
2
|
-
/**
|
|
3
|
-
* @operator {@link intersection | &}
|
|
4
|
-
* @docgenTable
|
|
5
|
-
* @string "L&R"
|
|
6
|
-
* @tuple [L, "&", R]
|
|
7
|
-
* @helper intersection(L,R)
|
|
8
|
-
* @example string
|
|
9
|
-
* const intersection = type("/@arktype\.io$/ & email")
|
|
10
|
-
* @example tuple
|
|
11
|
-
* const tupleIntersection = type(["/@arktype\.io$/", "&", "email"])
|
|
12
|
-
* @example helper
|
|
13
|
-
* const helperIntersection = intersection("/@arktype\.io$/","email")
|
|
14
|
-
*/ export const intersection = scopes.ark.intersection;
|
|
15
|
-
/**
|
|
16
|
-
* @operator {@link union | |}
|
|
17
|
-
* @docgenTable
|
|
18
|
-
* @string "L|R"
|
|
19
|
-
* @tuple [L, "|" , R]
|
|
20
|
-
* @helper union(L,R)
|
|
21
|
-
* @example string
|
|
22
|
-
* const union = type("string|number")
|
|
23
|
-
* @example tuple
|
|
24
|
-
* const tupleUnion = type(["string", "|", "number"])
|
|
25
|
-
* @example helper
|
|
26
|
-
* const helperUnion = union("string", "number")
|
|
27
|
-
*/ export const union = scopes.ark.union;
|
|
28
|
-
/**
|
|
29
|
-
* @operator {@link arrayOf}
|
|
30
|
-
* @docgenTable
|
|
31
|
-
* @string "T[]"
|
|
32
|
-
* @tuple [T, "[]"]
|
|
33
|
-
* @helper arrayOf(T)
|
|
34
|
-
* @example string
|
|
35
|
-
* const numberArray = type("number[]")
|
|
36
|
-
* @example tuple
|
|
37
|
-
* const tupleArray = type(["number", "[]"])
|
|
38
|
-
* @example helper
|
|
39
|
-
* const helperArray = arrayOf("number")
|
|
40
|
-
*/ export const arrayOf = scopes.ark.arrayOf;
|
|
41
|
-
/**
|
|
42
|
-
* @operator {@link keyOf}
|
|
43
|
-
* @docgenTable
|
|
44
|
-
* @tuple "["keyOf", T]"
|
|
45
|
-
* @helper keyOf(T)
|
|
46
|
-
* @example tuple
|
|
47
|
-
* const tupleKeyOf = type(["keyOf", {a:"string"}])
|
|
48
|
-
* @example helper
|
|
49
|
-
* const helperKeyOf = keyOf({a:"string"})
|
|
50
|
-
*/ export const keyOf = scopes.ark.keyOf;
|
|
51
|
-
/**
|
|
52
|
-
* @operator {@link instanceOf}
|
|
53
|
-
* @docgenTable
|
|
54
|
-
* @tuple ["instanceOf", T]
|
|
55
|
-
* @helper instanceOf(T)
|
|
56
|
-
* @example tuple
|
|
57
|
-
* const tupleInstanceOf = type(["instanceOf", Date])
|
|
58
|
-
* @example helper
|
|
59
|
-
* const helperInstanceOf = instanceOf(Date)
|
|
60
|
-
*/ export const instanceOf = scopes.ark.instanceOf;
|
|
61
|
-
/**
|
|
62
|
-
* @operator {@link valueOf | ===}
|
|
63
|
-
* @docgenTable
|
|
64
|
-
* @tuple ["===", T]
|
|
65
|
-
* @helper valueOf(T)
|
|
66
|
-
* @example tuple
|
|
67
|
-
* const tupleValueOf = type(["valueOf", {a:"string"}])
|
|
68
|
-
* @example helper
|
|
69
|
-
* const helperValueOf = valueOf({a:"string"})
|
|
70
|
-
*/ export const valueOf = scopes.ark.valueOf;
|
|
71
|
-
/**
|
|
72
|
-
* @operator {@link narrow | =>}
|
|
73
|
-
* @docgenTable
|
|
74
|
-
* @tuple ["type", "=>" , condition]
|
|
75
|
-
* @example tuple
|
|
76
|
-
* const narrow = type( ["number", "=>" , (n) => n % 2 === 0])
|
|
77
|
-
* @example
|
|
78
|
-
* const isEven = (x: unknown): x is number => x % 2 === 0
|
|
79
|
-
*/ export const narrow = scopes.ark.narrow;
|
|
80
|
-
/**
|
|
81
|
-
* @operator {@link morph | |>}
|
|
82
|
-
* @docgenTable
|
|
83
|
-
* @tuple [inputType, "|>", (data) => output]
|
|
84
|
-
* @helper morph(inputType, (data) => output)
|
|
85
|
-
* @example tuple
|
|
86
|
-
* const tupleMorph = type( ["string", "|>" , (data) => `morphed ${data}`])
|
|
87
|
-
* @example helper
|
|
88
|
-
* const helperMorph = morph("string", (data) => `morphed ${data}`)
|
|
89
|
-
*/ export const morph = scopes.ark.morph;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { scope } from "./scope.js";
|
|
2
|
-
/**
|
|
3
|
-
* @docgenScope
|
|
4
|
-
* @docgenTable
|
|
5
|
-
*/ export const jsObjectsScope = scope({
|
|
6
|
-
Function: [
|
|
7
|
-
"node",
|
|
8
|
-
{
|
|
9
|
-
object: {
|
|
10
|
-
class: Function
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
],
|
|
14
|
-
Date: [
|
|
15
|
-
"node",
|
|
16
|
-
{
|
|
17
|
-
object: {
|
|
18
|
-
class: Date
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
],
|
|
22
|
-
Error: [
|
|
23
|
-
"node",
|
|
24
|
-
{
|
|
25
|
-
object: {
|
|
26
|
-
class: Error
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
],
|
|
30
|
-
Map: [
|
|
31
|
-
"node",
|
|
32
|
-
{
|
|
33
|
-
object: {
|
|
34
|
-
class: Map
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
],
|
|
38
|
-
RegExp: [
|
|
39
|
-
"node",
|
|
40
|
-
{
|
|
41
|
-
object: {
|
|
42
|
-
class: RegExp
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
],
|
|
46
|
-
Set: [
|
|
47
|
-
"node",
|
|
48
|
-
{
|
|
49
|
-
object: {
|
|
50
|
-
class: Set
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
],
|
|
54
|
-
WeakMap: [
|
|
55
|
-
"node",
|
|
56
|
-
{
|
|
57
|
-
object: {
|
|
58
|
-
class: WeakMap
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
],
|
|
62
|
-
WeakSet: [
|
|
63
|
-
"node",
|
|
64
|
-
{
|
|
65
|
-
object: {
|
|
66
|
-
class: WeakSet
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
],
|
|
70
|
-
Promise: [
|
|
71
|
-
"node",
|
|
72
|
-
{
|
|
73
|
-
object: {
|
|
74
|
-
class: Promise
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
]
|
|
78
|
-
}, {
|
|
79
|
-
name: "jsObjects",
|
|
80
|
-
standard: false
|
|
81
|
-
});
|
|
82
|
-
export const jsObjects = jsObjectsScope.compile();
|
package/dist/mjs/scopes/scope.js
DELETED
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
function _checkPrivateRedeclaration(obj, privateCollection) {
|
|
2
|
-
if (privateCollection.has(obj)) {
|
|
3
|
-
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
4
|
-
}
|
|
5
|
-
}
|
|
6
|
-
function _classApplyDescriptorGet(receiver, descriptor) {
|
|
7
|
-
if (descriptor.get) {
|
|
8
|
-
return descriptor.get.call(receiver);
|
|
9
|
-
}
|
|
10
|
-
return descriptor.value;
|
|
11
|
-
}
|
|
12
|
-
function _classApplyDescriptorSet(receiver, descriptor, value) {
|
|
13
|
-
if (descriptor.set) {
|
|
14
|
-
descriptor.set.call(receiver, value);
|
|
15
|
-
} else {
|
|
16
|
-
if (!descriptor.writable) {
|
|
17
|
-
throw new TypeError("attempted to set read only private field");
|
|
18
|
-
}
|
|
19
|
-
descriptor.value = value;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function _classExtractFieldDescriptor(receiver, privateMap, action) {
|
|
23
|
-
if (!privateMap.has(receiver)) {
|
|
24
|
-
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
25
|
-
}
|
|
26
|
-
return privateMap.get(receiver);
|
|
27
|
-
}
|
|
28
|
-
function _classPrivateFieldGet(receiver, privateMap) {
|
|
29
|
-
var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
|
|
30
|
-
return _classApplyDescriptorGet(receiver, descriptor);
|
|
31
|
-
}
|
|
32
|
-
function _classPrivateFieldInit(obj, privateMap, value) {
|
|
33
|
-
_checkPrivateRedeclaration(obj, privateMap);
|
|
34
|
-
privateMap.set(obj, value);
|
|
35
|
-
}
|
|
36
|
-
function _classPrivateFieldSet(receiver, privateMap, value) {
|
|
37
|
-
var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
|
|
38
|
-
_classApplyDescriptorSet(receiver, descriptor, value);
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
function _classPrivateMethodGet(receiver, privateSet, fn) {
|
|
42
|
-
if (!privateSet.has(receiver)) {
|
|
43
|
-
throw new TypeError("attempted to get private field on non-instance");
|
|
44
|
-
}
|
|
45
|
-
return fn;
|
|
46
|
-
}
|
|
47
|
-
function _classPrivateMethodInit(obj, privateSet) {
|
|
48
|
-
_checkPrivateRedeclaration(obj, privateSet);
|
|
49
|
-
privateSet.add(obj);
|
|
50
|
-
}
|
|
51
|
-
function _defineProperty(obj, key, value) {
|
|
52
|
-
if (key in obj) {
|
|
53
|
-
Object.defineProperty(obj, key, {
|
|
54
|
-
value: value,
|
|
55
|
-
enumerable: true,
|
|
56
|
-
configurable: true,
|
|
57
|
-
writable: true
|
|
58
|
-
});
|
|
59
|
-
} else {
|
|
60
|
-
obj[key] = value;
|
|
61
|
-
}
|
|
62
|
-
return obj;
|
|
63
|
-
}
|
|
64
|
-
import { flattenType, isConfigNode } from "../nodes/node.js";
|
|
65
|
-
import { parseDefinition } from "../parse/definition.js";
|
|
66
|
-
import { compileProblemWriters } from "../traverse/problems.js";
|
|
67
|
-
import { chainableNoOpProxy } from "../utils/chainableNoOpProxy.js";
|
|
68
|
-
import { throwInternalError, throwParseError } from "../utils/errors.js";
|
|
69
|
-
import { deepFreeze } from "../utils/freeze.js";
|
|
70
|
-
import { hasKeys } from "../utils/generics.js";
|
|
71
|
-
import { Path } from "../utils/paths.js";
|
|
72
|
-
import { Cache, FreezingCache } from "./cache.js";
|
|
73
|
-
import { initializeType } from "./type.js";
|
|
74
|
-
export const compileScopeOptions = (opts)=>({
|
|
75
|
-
codes: compileProblemWriters(opts.codes),
|
|
76
|
-
keys: opts.keys ?? "loose"
|
|
77
|
-
});
|
|
78
|
-
let anonymousScopeCount = 0;
|
|
79
|
-
const scopeRegistry = {};
|
|
80
|
-
const spaceRegistry = {};
|
|
81
|
-
export const isConfigTuple = (def)=>Array.isArray(def) && def[1] === ":";
|
|
82
|
-
var _resolutions = /*#__PURE__*/ new WeakMap(), _exports = /*#__PURE__*/ new WeakMap(), _register = /*#__PURE__*/ new WeakSet(), _cacheSpaces = /*#__PURE__*/ new WeakSet(), _initializeContext = /*#__PURE__*/ new WeakSet(), _resolveRecurse = /*#__PURE__*/ new WeakSet();
|
|
83
|
-
export class Scope {
|
|
84
|
-
getAnonymousQualifiedName(base) {
|
|
85
|
-
let increment = 0;
|
|
86
|
-
let id = base;
|
|
87
|
-
while(this.isResolvable(id)){
|
|
88
|
-
id = `${base}${increment++}`;
|
|
89
|
-
}
|
|
90
|
-
return `${this.name}.${id}`;
|
|
91
|
-
}
|
|
92
|
-
addAnonymousTypeReference(referencedType, ctx) {
|
|
93
|
-
var _ctx_type;
|
|
94
|
-
(_ctx_type = ctx.type).includesMorph || (_ctx_type.includesMorph = referencedType.includesMorph);
|
|
95
|
-
return referencedType.node;
|
|
96
|
-
}
|
|
97
|
-
get infer() {
|
|
98
|
-
return chainableNoOpProxy;
|
|
99
|
-
}
|
|
100
|
-
compile() {
|
|
101
|
-
if (!spaceRegistry[this.name]) {
|
|
102
|
-
for(const name in this.aliases){
|
|
103
|
-
this.resolve(name);
|
|
104
|
-
}
|
|
105
|
-
spaceRegistry[this.name] = _classPrivateFieldGet(this, _exports).root;
|
|
106
|
-
}
|
|
107
|
-
return _classPrivateFieldGet(this, _exports).root;
|
|
108
|
-
}
|
|
109
|
-
addParsedReferenceIfResolvable(name, ctx) {
|
|
110
|
-
var _ctx_type;
|
|
111
|
-
const resolution = _classPrivateMethodGet(this, _resolveRecurse, resolveRecurse).call(this, name, "undefined", [
|
|
112
|
-
name
|
|
113
|
-
]);
|
|
114
|
-
if (!resolution) {
|
|
115
|
-
return false;
|
|
116
|
-
}
|
|
117
|
-
(_ctx_type = ctx.type).includesMorph || (_ctx_type.includesMorph = resolution.includesMorph);
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
resolve(name) {
|
|
121
|
-
return _classPrivateMethodGet(this, _resolveRecurse, resolveRecurse).call(this, name, "throw", [
|
|
122
|
-
name
|
|
123
|
-
]);
|
|
124
|
-
}
|
|
125
|
-
resolveNode(node) {
|
|
126
|
-
return typeof node === "string" ? this.resolveNode(this.resolve(node).node) : node;
|
|
127
|
-
}
|
|
128
|
-
resolveTypeNode(node) {
|
|
129
|
-
const resolution = this.resolveNode(node);
|
|
130
|
-
return isConfigNode(resolution) ? resolution.node : resolution;
|
|
131
|
-
}
|
|
132
|
-
isResolvable(name) {
|
|
133
|
-
return _classPrivateFieldGet(this, _resolutions).has(name) || this.aliases[name];
|
|
134
|
-
}
|
|
135
|
-
constructor(aliases, opts = {}){
|
|
136
|
-
_classPrivateMethodInit(this, _register);
|
|
137
|
-
_classPrivateMethodInit(this, _cacheSpaces);
|
|
138
|
-
_classPrivateMethodInit(this, _initializeContext);
|
|
139
|
-
_classPrivateMethodInit(this, _resolveRecurse);
|
|
140
|
-
_defineProperty(this, "aliases", void 0);
|
|
141
|
-
_defineProperty(this, "name", void 0);
|
|
142
|
-
_defineProperty(this, "config", void 0);
|
|
143
|
-
_defineProperty(this, "parseCache", void 0);
|
|
144
|
-
_classPrivateFieldInit(this, _resolutions, {
|
|
145
|
-
writable: true,
|
|
146
|
-
value: void 0
|
|
147
|
-
});
|
|
148
|
-
_classPrivateFieldInit(this, _exports, {
|
|
149
|
-
writable: true,
|
|
150
|
-
value: void 0
|
|
151
|
-
});
|
|
152
|
-
_defineProperty(this, "expressions", void 0);
|
|
153
|
-
_defineProperty(this, "intersection", void 0);
|
|
154
|
-
_defineProperty(this, "union", void 0);
|
|
155
|
-
_defineProperty(this, "arrayOf", void 0);
|
|
156
|
-
_defineProperty(this, "keyOf", void 0);
|
|
157
|
-
_defineProperty(this, "valueOf", void 0);
|
|
158
|
-
_defineProperty(this, "instanceOf", void 0);
|
|
159
|
-
_defineProperty(this, "narrow", void 0);
|
|
160
|
-
_defineProperty(this, "morph", void 0);
|
|
161
|
-
_defineProperty(this, "type", void 0);
|
|
162
|
-
this.aliases = aliases;
|
|
163
|
-
this.parseCache = new FreezingCache();
|
|
164
|
-
_classPrivateFieldSet(this, _resolutions, new Cache());
|
|
165
|
-
_classPrivateFieldSet(this, _exports, new Cache());
|
|
166
|
-
this.expressions = {
|
|
167
|
-
intersection: (l, r, opts)=>this.type([
|
|
168
|
-
l,
|
|
169
|
-
"&",
|
|
170
|
-
r
|
|
171
|
-
], opts),
|
|
172
|
-
union: (l, r, opts)=>this.type([
|
|
173
|
-
l,
|
|
174
|
-
"|",
|
|
175
|
-
r
|
|
176
|
-
], opts),
|
|
177
|
-
arrayOf: (def, opts)=>this.type([
|
|
178
|
-
def,
|
|
179
|
-
"[]"
|
|
180
|
-
], opts),
|
|
181
|
-
keyOf: (def, opts)=>this.type([
|
|
182
|
-
"keyof",
|
|
183
|
-
def
|
|
184
|
-
], opts),
|
|
185
|
-
node: (def, opts)=>this.type([
|
|
186
|
-
"node",
|
|
187
|
-
def
|
|
188
|
-
], opts),
|
|
189
|
-
instanceOf: (def, opts)=>this.type([
|
|
190
|
-
"instanceof",
|
|
191
|
-
def
|
|
192
|
-
], opts),
|
|
193
|
-
valueOf: (def, opts)=>this.type([
|
|
194
|
-
"===",
|
|
195
|
-
def
|
|
196
|
-
], opts),
|
|
197
|
-
narrow: (def, fn, opts)=>this.type([
|
|
198
|
-
def,
|
|
199
|
-
"=>",
|
|
200
|
-
fn
|
|
201
|
-
], opts),
|
|
202
|
-
morph: (def, fn, opts)=>this.type([
|
|
203
|
-
def,
|
|
204
|
-
"|>",
|
|
205
|
-
fn
|
|
206
|
-
], opts)
|
|
207
|
-
};
|
|
208
|
-
this.intersection = this.expressions.intersection;
|
|
209
|
-
this.union = this.expressions.union;
|
|
210
|
-
this.arrayOf = this.expressions.arrayOf;
|
|
211
|
-
this.keyOf = this.expressions.keyOf;
|
|
212
|
-
this.valueOf = this.expressions.valueOf;
|
|
213
|
-
this.instanceOf = this.expressions.instanceOf;
|
|
214
|
-
this.narrow = this.expressions.narrow;
|
|
215
|
-
this.morph = this.expressions.morph;
|
|
216
|
-
this.type = Object.assign((def, config = {})=>{
|
|
217
|
-
const t = initializeType("λtype", def, config, this);
|
|
218
|
-
const ctx = _classPrivateMethodGet(this, _initializeContext, initializeContext).call(this, t);
|
|
219
|
-
const root = parseDefinition(def, ctx);
|
|
220
|
-
t.node = deepFreeze(hasKeys(config) ? {
|
|
221
|
-
config,
|
|
222
|
-
node: this.resolveTypeNode(root)
|
|
223
|
-
} : root);
|
|
224
|
-
t.flat = deepFreeze(flattenType(t));
|
|
225
|
-
return t;
|
|
226
|
-
}, {
|
|
227
|
-
from: this.expressions.node
|
|
228
|
-
});
|
|
229
|
-
this.name = _classPrivateMethodGet(this, _register, register).call(this, opts);
|
|
230
|
-
if (opts.standard !== false) {
|
|
231
|
-
_classPrivateMethodGet(this, _cacheSpaces, cacheSpaces).call(this, [
|
|
232
|
-
spaceRegistry["standard"]
|
|
233
|
-
], "imports");
|
|
234
|
-
}
|
|
235
|
-
if (opts.imports) {
|
|
236
|
-
_classPrivateMethodGet(this, _cacheSpaces, cacheSpaces).call(this, opts.imports, "imports");
|
|
237
|
-
}
|
|
238
|
-
if (opts.includes) {
|
|
239
|
-
_classPrivateMethodGet(this, _cacheSpaces, cacheSpaces).call(this, opts.includes, "includes");
|
|
240
|
-
}
|
|
241
|
-
this.config = compileScopeOptions(opts);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
function register(opts) {
|
|
245
|
-
const name = opts.name ? scopeRegistry[opts.name] ? throwParseError(`A scope named '${opts.name}' already exists`) : opts.name : `scope${++anonymousScopeCount}`;
|
|
246
|
-
scopeRegistry[name] = this;
|
|
247
|
-
return name;
|
|
248
|
-
}
|
|
249
|
-
function cacheSpaces(spaces, kind) {
|
|
250
|
-
for (const space of spaces){
|
|
251
|
-
for(const name in space){
|
|
252
|
-
if (_classPrivateFieldGet(this, _resolutions).has(name) || name in this.aliases) {
|
|
253
|
-
throwParseError(writeDuplicateAliasesMessage(name));
|
|
254
|
-
}
|
|
255
|
-
_classPrivateFieldGet(this, _resolutions).set(name, space[name]);
|
|
256
|
-
if (kind === "includes") {
|
|
257
|
-
_classPrivateFieldGet(this, _exports).set(name, space[name]);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
function initializeContext(type) {
|
|
263
|
-
return {
|
|
264
|
-
type,
|
|
265
|
-
path: new Path()
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
function resolveRecurse(name, onUnresolvable, seen) {
|
|
269
|
-
const maybeCacheResult = _classPrivateFieldGet(this, _resolutions).get(name);
|
|
270
|
-
if (maybeCacheResult) {
|
|
271
|
-
return maybeCacheResult;
|
|
272
|
-
}
|
|
273
|
-
const aliasDef = this.aliases[name];
|
|
274
|
-
if (!aliasDef) {
|
|
275
|
-
return onUnresolvable === "throw" ? throwInternalError(`Unexpectedly failed to resolve alias '${name}'`) : undefined;
|
|
276
|
-
}
|
|
277
|
-
const t = initializeType(name, aliasDef, {}, this);
|
|
278
|
-
const ctx = _classPrivateMethodGet(this, _initializeContext, initializeContext).call(this, t);
|
|
279
|
-
_classPrivateFieldGet(this, _resolutions).set(name, t);
|
|
280
|
-
_classPrivateFieldGet(this, _exports).set(name, t);
|
|
281
|
-
let node = parseDefinition(aliasDef, ctx);
|
|
282
|
-
if (typeof node === "string") {
|
|
283
|
-
if (seen.includes(node)) {
|
|
284
|
-
return throwParseError(writeShallowCycleErrorMessage(name, seen));
|
|
285
|
-
}
|
|
286
|
-
seen.push(node);
|
|
287
|
-
node = _classPrivateMethodGet(this, _resolveRecurse, resolveRecurse).call(this, node, "throw", seen).node;
|
|
288
|
-
}
|
|
289
|
-
t.node = deepFreeze(node);
|
|
290
|
-
t.flat = deepFreeze(flattenType(t));
|
|
291
|
-
return t;
|
|
292
|
-
}
|
|
293
|
-
export const scope = (aliases, opts = {})=>new Scope(aliases, opts);
|
|
294
|
-
export const rootScope = scope({}, {
|
|
295
|
-
name: "root",
|
|
296
|
-
standard: false
|
|
297
|
-
});
|
|
298
|
-
export const rootType = rootScope.type;
|
|
299
|
-
export const writeShallowCycleErrorMessage = (name, seen)=>`Alias '${name}' has a shallow resolution cycle: ${[
|
|
300
|
-
...seen,
|
|
301
|
-
name
|
|
302
|
-
].join("=>")}`;
|
|
303
|
-
export const writeDuplicateAliasesMessage = (name)=>`Alias '${name}' is already defined`;
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { scope } from "./scope.js";
|
|
2
|
-
const always = {
|
|
3
|
-
bigint: true,
|
|
4
|
-
boolean: true,
|
|
5
|
-
null: true,
|
|
6
|
-
number: true,
|
|
7
|
-
object: true,
|
|
8
|
-
string: true,
|
|
9
|
-
symbol: true,
|
|
10
|
-
undefined: true
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* @keywords keywords: {"any": "any",
|
|
14
|
-
"bigint": "a bigint",
|
|
15
|
-
"boolean": "a boolean",
|
|
16
|
-
"false": "false",
|
|
17
|
-
"never": "never",
|
|
18
|
-
"null": "null",
|
|
19
|
-
"number": "a number",
|
|
20
|
-
"object": "an object",
|
|
21
|
-
"string": "a string",
|
|
22
|
-
"symbol": "a symbol",
|
|
23
|
-
"true": "true",
|
|
24
|
-
"unknown": "unknown",
|
|
25
|
-
"void": "void",
|
|
26
|
-
"undefined": "undefined"}
|
|
27
|
-
* @docgenScope
|
|
28
|
-
* @docgenTable
|
|
29
|
-
*/ export const tsKeywordsScope = scope({
|
|
30
|
-
any: [
|
|
31
|
-
"node",
|
|
32
|
-
always
|
|
33
|
-
],
|
|
34
|
-
bigint: [
|
|
35
|
-
"node",
|
|
36
|
-
{
|
|
37
|
-
bigint: true
|
|
38
|
-
}
|
|
39
|
-
],
|
|
40
|
-
boolean: [
|
|
41
|
-
"node",
|
|
42
|
-
{
|
|
43
|
-
boolean: true
|
|
44
|
-
}
|
|
45
|
-
],
|
|
46
|
-
false: [
|
|
47
|
-
"node",
|
|
48
|
-
{
|
|
49
|
-
boolean: {
|
|
50
|
-
value: false
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
],
|
|
54
|
-
never: [
|
|
55
|
-
"node",
|
|
56
|
-
{}
|
|
57
|
-
],
|
|
58
|
-
null: [
|
|
59
|
-
"node",
|
|
60
|
-
{
|
|
61
|
-
null: true
|
|
62
|
-
}
|
|
63
|
-
],
|
|
64
|
-
number: [
|
|
65
|
-
"node",
|
|
66
|
-
{
|
|
67
|
-
number: true
|
|
68
|
-
}
|
|
69
|
-
],
|
|
70
|
-
object: [
|
|
71
|
-
"node",
|
|
72
|
-
{
|
|
73
|
-
object: true
|
|
74
|
-
}
|
|
75
|
-
],
|
|
76
|
-
string: [
|
|
77
|
-
"node",
|
|
78
|
-
{
|
|
79
|
-
string: true
|
|
80
|
-
}
|
|
81
|
-
],
|
|
82
|
-
symbol: [
|
|
83
|
-
"node",
|
|
84
|
-
{
|
|
85
|
-
symbol: true
|
|
86
|
-
}
|
|
87
|
-
],
|
|
88
|
-
true: [
|
|
89
|
-
"node",
|
|
90
|
-
{
|
|
91
|
-
boolean: {
|
|
92
|
-
value: true
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
],
|
|
96
|
-
unknown: [
|
|
97
|
-
"node",
|
|
98
|
-
always
|
|
99
|
-
],
|
|
100
|
-
void: [
|
|
101
|
-
"node",
|
|
102
|
-
{
|
|
103
|
-
undefined: true
|
|
104
|
-
}
|
|
105
|
-
],
|
|
106
|
-
undefined: [
|
|
107
|
-
"node",
|
|
108
|
-
{
|
|
109
|
-
undefined: true
|
|
110
|
-
}
|
|
111
|
-
]
|
|
112
|
-
}, {
|
|
113
|
-
name: "ts",
|
|
114
|
-
standard: false
|
|
115
|
-
});
|
|
116
|
-
export const tsKeywords = tsKeywordsScope.compile();
|
package/dist/mjs/scopes/type.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { traverseRoot } from "../traverse/traverse.js";
|
|
2
|
-
import { chainableNoOpProxy } from "../utils/chainableNoOpProxy.js";
|
|
3
|
-
export const initializeType = (name, definition, config, scope)=>{
|
|
4
|
-
const root = {
|
|
5
|
-
// temporarily initialize node/flat to aliases that will be included in
|
|
6
|
-
// the final type in case of cyclic resolutions
|
|
7
|
-
node: name,
|
|
8
|
-
flat: [
|
|
9
|
-
[
|
|
10
|
-
"alias",
|
|
11
|
-
name
|
|
12
|
-
]
|
|
13
|
-
],
|
|
14
|
-
allows: (data)=>!namedTraverse(data).problems,
|
|
15
|
-
assert: (data)=>{
|
|
16
|
-
const result = namedTraverse(data);
|
|
17
|
-
return result.problems ? result.problems.throw() : result.data;
|
|
18
|
-
},
|
|
19
|
-
infer: chainableNoOpProxy,
|
|
20
|
-
inferIn: chainableNoOpProxy,
|
|
21
|
-
qualifiedName: isAnonymousName(name) ? scope.getAnonymousQualifiedName(name) : `${scope.name}.${name}`,
|
|
22
|
-
definition,
|
|
23
|
-
scope,
|
|
24
|
-
includesMorph: false,
|
|
25
|
-
config
|
|
26
|
-
};
|
|
27
|
-
// define within a key to dynamically assign a name to the function
|
|
28
|
-
const namedTraverse = {
|
|
29
|
-
[name]: (data)=>traverseRoot(namedTraverse, data)
|
|
30
|
-
}[name];
|
|
31
|
-
const t = Object.assign(namedTraverse, root);
|
|
32
|
-
return t;
|
|
33
|
-
};
|
|
34
|
-
export const isType = (value)=>value?.infer === chainableNoOpProxy;
|
|
35
|
-
export const isAnonymousName = (name)=>name[0] === "λ";
|