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/cjs/scopes/scope.js
DELETED
|
@@ -1,323 +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
|
-
compileScopeOptions: ()=>compileScopeOptions,
|
|
13
|
-
isConfigTuple: ()=>isConfigTuple,
|
|
14
|
-
Scope: ()=>Scope,
|
|
15
|
-
scope: ()=>scope,
|
|
16
|
-
rootScope: ()=>rootScope,
|
|
17
|
-
rootType: ()=>rootType,
|
|
18
|
-
writeShallowCycleErrorMessage: ()=>writeShallowCycleErrorMessage,
|
|
19
|
-
writeDuplicateAliasesMessage: ()=>writeDuplicateAliasesMessage
|
|
20
|
-
});
|
|
21
|
-
const _nodeJs = require("../nodes/node.js");
|
|
22
|
-
const _definitionJs = require("../parse/definition.js");
|
|
23
|
-
const _problemsJs = require("../traverse/problems.js");
|
|
24
|
-
const _chainableNoOpProxyJs = require("../utils/chainableNoOpProxy.js");
|
|
25
|
-
const _errorsJs = require("../utils/errors.js");
|
|
26
|
-
const _freezeJs = require("../utils/freeze.js");
|
|
27
|
-
const _genericsJs = require("../utils/generics.js");
|
|
28
|
-
const _pathsJs = require("../utils/paths.js");
|
|
29
|
-
const _cacheJs = require("./cache.js");
|
|
30
|
-
const _typeJs = require("./type.js");
|
|
31
|
-
function _checkPrivateRedeclaration(obj, privateCollection) {
|
|
32
|
-
if (privateCollection.has(obj)) {
|
|
33
|
-
throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function _classApplyDescriptorGet(receiver, descriptor) {
|
|
37
|
-
if (descriptor.get) {
|
|
38
|
-
return descriptor.get.call(receiver);
|
|
39
|
-
}
|
|
40
|
-
return descriptor.value;
|
|
41
|
-
}
|
|
42
|
-
function _classApplyDescriptorSet(receiver, descriptor, value) {
|
|
43
|
-
if (descriptor.set) {
|
|
44
|
-
descriptor.set.call(receiver, value);
|
|
45
|
-
} else {
|
|
46
|
-
if (!descriptor.writable) {
|
|
47
|
-
throw new TypeError("attempted to set read only private field");
|
|
48
|
-
}
|
|
49
|
-
descriptor.value = value;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function _classExtractFieldDescriptor(receiver, privateMap, action) {
|
|
53
|
-
if (!privateMap.has(receiver)) {
|
|
54
|
-
throw new TypeError("attempted to " + action + " private field on non-instance");
|
|
55
|
-
}
|
|
56
|
-
return privateMap.get(receiver);
|
|
57
|
-
}
|
|
58
|
-
function _classPrivateFieldGet(receiver, privateMap) {
|
|
59
|
-
var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get");
|
|
60
|
-
return _classApplyDescriptorGet(receiver, descriptor);
|
|
61
|
-
}
|
|
62
|
-
function _classPrivateFieldInit(obj, privateMap, value) {
|
|
63
|
-
_checkPrivateRedeclaration(obj, privateMap);
|
|
64
|
-
privateMap.set(obj, value);
|
|
65
|
-
}
|
|
66
|
-
function _classPrivateFieldSet(receiver, privateMap, value) {
|
|
67
|
-
var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set");
|
|
68
|
-
_classApplyDescriptorSet(receiver, descriptor, value);
|
|
69
|
-
return value;
|
|
70
|
-
}
|
|
71
|
-
function _classPrivateMethodGet(receiver, privateSet, fn) {
|
|
72
|
-
if (!privateSet.has(receiver)) {
|
|
73
|
-
throw new TypeError("attempted to get private field on non-instance");
|
|
74
|
-
}
|
|
75
|
-
return fn;
|
|
76
|
-
}
|
|
77
|
-
function _classPrivateMethodInit(obj, privateSet) {
|
|
78
|
-
_checkPrivateRedeclaration(obj, privateSet);
|
|
79
|
-
privateSet.add(obj);
|
|
80
|
-
}
|
|
81
|
-
function _defineProperty(obj, key, value) {
|
|
82
|
-
if (key in obj) {
|
|
83
|
-
Object.defineProperty(obj, key, {
|
|
84
|
-
value: value,
|
|
85
|
-
enumerable: true,
|
|
86
|
-
configurable: true,
|
|
87
|
-
writable: true
|
|
88
|
-
});
|
|
89
|
-
} else {
|
|
90
|
-
obj[key] = value;
|
|
91
|
-
}
|
|
92
|
-
return obj;
|
|
93
|
-
}
|
|
94
|
-
const compileScopeOptions = (opts)=>({
|
|
95
|
-
codes: (0, _problemsJs.compileProblemWriters)(opts.codes),
|
|
96
|
-
keys: opts.keys ?? "loose"
|
|
97
|
-
});
|
|
98
|
-
let anonymousScopeCount = 0;
|
|
99
|
-
const scopeRegistry = {};
|
|
100
|
-
const spaceRegistry = {};
|
|
101
|
-
const isConfigTuple = (def)=>Array.isArray(def) && def[1] === ":";
|
|
102
|
-
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();
|
|
103
|
-
class Scope {
|
|
104
|
-
getAnonymousQualifiedName(base) {
|
|
105
|
-
let increment = 0;
|
|
106
|
-
let id = base;
|
|
107
|
-
while(this.isResolvable(id)){
|
|
108
|
-
id = `${base}${increment++}`;
|
|
109
|
-
}
|
|
110
|
-
return `${this.name}.${id}`;
|
|
111
|
-
}
|
|
112
|
-
addAnonymousTypeReference(referencedType, ctx) {
|
|
113
|
-
var _ctx_type;
|
|
114
|
-
(_ctx_type = ctx.type).includesMorph || (_ctx_type.includesMorph = referencedType.includesMorph);
|
|
115
|
-
return referencedType.node;
|
|
116
|
-
}
|
|
117
|
-
get infer() {
|
|
118
|
-
return _chainableNoOpProxyJs.chainableNoOpProxy;
|
|
119
|
-
}
|
|
120
|
-
compile() {
|
|
121
|
-
if (!spaceRegistry[this.name]) {
|
|
122
|
-
for(const name in this.aliases){
|
|
123
|
-
this.resolve(name);
|
|
124
|
-
}
|
|
125
|
-
spaceRegistry[this.name] = _classPrivateFieldGet(this, _exports).root;
|
|
126
|
-
}
|
|
127
|
-
return _classPrivateFieldGet(this, _exports).root;
|
|
128
|
-
}
|
|
129
|
-
addParsedReferenceIfResolvable(name, ctx) {
|
|
130
|
-
var _ctx_type;
|
|
131
|
-
const resolution = _classPrivateMethodGet(this, _resolveRecurse, resolveRecurse).call(this, name, "undefined", [
|
|
132
|
-
name
|
|
133
|
-
]);
|
|
134
|
-
if (!resolution) {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
(_ctx_type = ctx.type).includesMorph || (_ctx_type.includesMorph = resolution.includesMorph);
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
resolve(name) {
|
|
141
|
-
return _classPrivateMethodGet(this, _resolveRecurse, resolveRecurse).call(this, name, "throw", [
|
|
142
|
-
name
|
|
143
|
-
]);
|
|
144
|
-
}
|
|
145
|
-
resolveNode(node) {
|
|
146
|
-
return typeof node === "string" ? this.resolveNode(this.resolve(node).node) : node;
|
|
147
|
-
}
|
|
148
|
-
resolveTypeNode(node) {
|
|
149
|
-
const resolution = this.resolveNode(node);
|
|
150
|
-
return (0, _nodeJs.isConfigNode)(resolution) ? resolution.node : resolution;
|
|
151
|
-
}
|
|
152
|
-
isResolvable(name) {
|
|
153
|
-
return _classPrivateFieldGet(this, _resolutions).has(name) || this.aliases[name];
|
|
154
|
-
}
|
|
155
|
-
constructor(aliases, opts = {}){
|
|
156
|
-
_classPrivateMethodInit(this, _register);
|
|
157
|
-
_classPrivateMethodInit(this, _cacheSpaces);
|
|
158
|
-
_classPrivateMethodInit(this, _initializeContext);
|
|
159
|
-
_classPrivateMethodInit(this, _resolveRecurse);
|
|
160
|
-
_defineProperty(this, "aliases", void 0);
|
|
161
|
-
_defineProperty(this, "name", void 0);
|
|
162
|
-
_defineProperty(this, "config", void 0);
|
|
163
|
-
_defineProperty(this, "parseCache", void 0);
|
|
164
|
-
_classPrivateFieldInit(this, _resolutions, {
|
|
165
|
-
writable: true,
|
|
166
|
-
value: void 0
|
|
167
|
-
});
|
|
168
|
-
_classPrivateFieldInit(this, _exports, {
|
|
169
|
-
writable: true,
|
|
170
|
-
value: void 0
|
|
171
|
-
});
|
|
172
|
-
_defineProperty(this, "expressions", void 0);
|
|
173
|
-
_defineProperty(this, "intersection", void 0);
|
|
174
|
-
_defineProperty(this, "union", void 0);
|
|
175
|
-
_defineProperty(this, "arrayOf", void 0);
|
|
176
|
-
_defineProperty(this, "keyOf", void 0);
|
|
177
|
-
_defineProperty(this, "valueOf", void 0);
|
|
178
|
-
_defineProperty(this, "instanceOf", void 0);
|
|
179
|
-
_defineProperty(this, "narrow", void 0);
|
|
180
|
-
_defineProperty(this, "morph", void 0);
|
|
181
|
-
_defineProperty(this, "type", void 0);
|
|
182
|
-
this.aliases = aliases;
|
|
183
|
-
this.parseCache = new _cacheJs.FreezingCache();
|
|
184
|
-
_classPrivateFieldSet(this, _resolutions, new _cacheJs.Cache());
|
|
185
|
-
_classPrivateFieldSet(this, _exports, new _cacheJs.Cache());
|
|
186
|
-
this.expressions = {
|
|
187
|
-
intersection: (l, r, opts)=>this.type([
|
|
188
|
-
l,
|
|
189
|
-
"&",
|
|
190
|
-
r
|
|
191
|
-
], opts),
|
|
192
|
-
union: (l, r, opts)=>this.type([
|
|
193
|
-
l,
|
|
194
|
-
"|",
|
|
195
|
-
r
|
|
196
|
-
], opts),
|
|
197
|
-
arrayOf: (def, opts)=>this.type([
|
|
198
|
-
def,
|
|
199
|
-
"[]"
|
|
200
|
-
], opts),
|
|
201
|
-
keyOf: (def, opts)=>this.type([
|
|
202
|
-
"keyof",
|
|
203
|
-
def
|
|
204
|
-
], opts),
|
|
205
|
-
node: (def, opts)=>this.type([
|
|
206
|
-
"node",
|
|
207
|
-
def
|
|
208
|
-
], opts),
|
|
209
|
-
instanceOf: (def, opts)=>this.type([
|
|
210
|
-
"instanceof",
|
|
211
|
-
def
|
|
212
|
-
], opts),
|
|
213
|
-
valueOf: (def, opts)=>this.type([
|
|
214
|
-
"===",
|
|
215
|
-
def
|
|
216
|
-
], opts),
|
|
217
|
-
narrow: (def, fn, opts)=>this.type([
|
|
218
|
-
def,
|
|
219
|
-
"=>",
|
|
220
|
-
fn
|
|
221
|
-
], opts),
|
|
222
|
-
morph: (def, fn, opts)=>this.type([
|
|
223
|
-
def,
|
|
224
|
-
"|>",
|
|
225
|
-
fn
|
|
226
|
-
], opts)
|
|
227
|
-
};
|
|
228
|
-
this.intersection = this.expressions.intersection;
|
|
229
|
-
this.union = this.expressions.union;
|
|
230
|
-
this.arrayOf = this.expressions.arrayOf;
|
|
231
|
-
this.keyOf = this.expressions.keyOf;
|
|
232
|
-
this.valueOf = this.expressions.valueOf;
|
|
233
|
-
this.instanceOf = this.expressions.instanceOf;
|
|
234
|
-
this.narrow = this.expressions.narrow;
|
|
235
|
-
this.morph = this.expressions.morph;
|
|
236
|
-
this.type = Object.assign((def, config = {})=>{
|
|
237
|
-
const t = (0, _typeJs.initializeType)("λtype", def, config, this);
|
|
238
|
-
const ctx = _classPrivateMethodGet(this, _initializeContext, initializeContext).call(this, t);
|
|
239
|
-
const root = (0, _definitionJs.parseDefinition)(def, ctx);
|
|
240
|
-
t.node = (0, _freezeJs.deepFreeze)((0, _genericsJs.hasKeys)(config) ? {
|
|
241
|
-
config,
|
|
242
|
-
node: this.resolveTypeNode(root)
|
|
243
|
-
} : root);
|
|
244
|
-
t.flat = (0, _freezeJs.deepFreeze)((0, _nodeJs.flattenType)(t));
|
|
245
|
-
return t;
|
|
246
|
-
}, {
|
|
247
|
-
from: this.expressions.node
|
|
248
|
-
});
|
|
249
|
-
this.name = _classPrivateMethodGet(this, _register, register).call(this, opts);
|
|
250
|
-
if (opts.standard !== false) {
|
|
251
|
-
_classPrivateMethodGet(this, _cacheSpaces, cacheSpaces).call(this, [
|
|
252
|
-
spaceRegistry["standard"]
|
|
253
|
-
], "imports");
|
|
254
|
-
}
|
|
255
|
-
if (opts.imports) {
|
|
256
|
-
_classPrivateMethodGet(this, _cacheSpaces, cacheSpaces).call(this, opts.imports, "imports");
|
|
257
|
-
}
|
|
258
|
-
if (opts.includes) {
|
|
259
|
-
_classPrivateMethodGet(this, _cacheSpaces, cacheSpaces).call(this, opts.includes, "includes");
|
|
260
|
-
}
|
|
261
|
-
this.config = compileScopeOptions(opts);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
function register(opts) {
|
|
265
|
-
const name = opts.name ? scopeRegistry[opts.name] ? (0, _errorsJs.throwParseError)(`A scope named '${opts.name}' already exists`) : opts.name : `scope${++anonymousScopeCount}`;
|
|
266
|
-
scopeRegistry[name] = this;
|
|
267
|
-
return name;
|
|
268
|
-
}
|
|
269
|
-
function cacheSpaces(spaces, kind) {
|
|
270
|
-
for (const space of spaces){
|
|
271
|
-
for(const name in space){
|
|
272
|
-
if (_classPrivateFieldGet(this, _resolutions).has(name) || name in this.aliases) {
|
|
273
|
-
(0, _errorsJs.throwParseError)(writeDuplicateAliasesMessage(name));
|
|
274
|
-
}
|
|
275
|
-
_classPrivateFieldGet(this, _resolutions).set(name, space[name]);
|
|
276
|
-
if (kind === "includes") {
|
|
277
|
-
_classPrivateFieldGet(this, _exports).set(name, space[name]);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
function initializeContext(type) {
|
|
283
|
-
return {
|
|
284
|
-
type,
|
|
285
|
-
path: new _pathsJs.Path()
|
|
286
|
-
};
|
|
287
|
-
}
|
|
288
|
-
function resolveRecurse(name, onUnresolvable, seen) {
|
|
289
|
-
const maybeCacheResult = _classPrivateFieldGet(this, _resolutions).get(name);
|
|
290
|
-
if (maybeCacheResult) {
|
|
291
|
-
return maybeCacheResult;
|
|
292
|
-
}
|
|
293
|
-
const aliasDef = this.aliases[name];
|
|
294
|
-
if (!aliasDef) {
|
|
295
|
-
return onUnresolvable === "throw" ? (0, _errorsJs.throwInternalError)(`Unexpectedly failed to resolve alias '${name}'`) : undefined;
|
|
296
|
-
}
|
|
297
|
-
const t = (0, _typeJs.initializeType)(name, aliasDef, {}, this);
|
|
298
|
-
const ctx = _classPrivateMethodGet(this, _initializeContext, initializeContext).call(this, t);
|
|
299
|
-
_classPrivateFieldGet(this, _resolutions).set(name, t);
|
|
300
|
-
_classPrivateFieldGet(this, _exports).set(name, t);
|
|
301
|
-
let node = (0, _definitionJs.parseDefinition)(aliasDef, ctx);
|
|
302
|
-
if (typeof node === "string") {
|
|
303
|
-
if (seen.includes(node)) {
|
|
304
|
-
return (0, _errorsJs.throwParseError)(writeShallowCycleErrorMessage(name, seen));
|
|
305
|
-
}
|
|
306
|
-
seen.push(node);
|
|
307
|
-
node = _classPrivateMethodGet(this, _resolveRecurse, resolveRecurse).call(this, node, "throw", seen).node;
|
|
308
|
-
}
|
|
309
|
-
t.node = (0, _freezeJs.deepFreeze)(node);
|
|
310
|
-
t.flat = (0, _freezeJs.deepFreeze)((0, _nodeJs.flattenType)(t));
|
|
311
|
-
return t;
|
|
312
|
-
}
|
|
313
|
-
const scope = (aliases, opts = {})=>new Scope(aliases, opts);
|
|
314
|
-
const rootScope = scope({}, {
|
|
315
|
-
name: "root",
|
|
316
|
-
standard: false
|
|
317
|
-
});
|
|
318
|
-
const rootType = rootScope.type;
|
|
319
|
-
const writeShallowCycleErrorMessage = (name, seen)=>`Alias '${name}' has a shallow resolution cycle: ${[
|
|
320
|
-
...seen,
|
|
321
|
-
name
|
|
322
|
-
].join("=>")}`;
|
|
323
|
-
const writeDuplicateAliasesMessage = (name)=>`Alias '${name}' is already defined`;
|
|
@@ -1,113 +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
|
-
tsKeywordsScope: ()=>tsKeywordsScope,
|
|
13
|
-
tsKeywords: ()=>tsKeywords
|
|
14
|
-
});
|
|
15
|
-
const _scopeJs = require("./scope.js");
|
|
16
|
-
const always = {
|
|
17
|
-
bigint: true,
|
|
18
|
-
boolean: true,
|
|
19
|
-
null: true,
|
|
20
|
-
number: true,
|
|
21
|
-
object: true,
|
|
22
|
-
string: true,
|
|
23
|
-
symbol: true,
|
|
24
|
-
undefined: true
|
|
25
|
-
};
|
|
26
|
-
const tsKeywordsScope = (0, _scopeJs.scope)({
|
|
27
|
-
any: [
|
|
28
|
-
"node",
|
|
29
|
-
always
|
|
30
|
-
],
|
|
31
|
-
bigint: [
|
|
32
|
-
"node",
|
|
33
|
-
{
|
|
34
|
-
bigint: true
|
|
35
|
-
}
|
|
36
|
-
],
|
|
37
|
-
boolean: [
|
|
38
|
-
"node",
|
|
39
|
-
{
|
|
40
|
-
boolean: true
|
|
41
|
-
}
|
|
42
|
-
],
|
|
43
|
-
false: [
|
|
44
|
-
"node",
|
|
45
|
-
{
|
|
46
|
-
boolean: {
|
|
47
|
-
value: false
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
],
|
|
51
|
-
never: [
|
|
52
|
-
"node",
|
|
53
|
-
{}
|
|
54
|
-
],
|
|
55
|
-
null: [
|
|
56
|
-
"node",
|
|
57
|
-
{
|
|
58
|
-
null: true
|
|
59
|
-
}
|
|
60
|
-
],
|
|
61
|
-
number: [
|
|
62
|
-
"node",
|
|
63
|
-
{
|
|
64
|
-
number: true
|
|
65
|
-
}
|
|
66
|
-
],
|
|
67
|
-
object: [
|
|
68
|
-
"node",
|
|
69
|
-
{
|
|
70
|
-
object: true
|
|
71
|
-
}
|
|
72
|
-
],
|
|
73
|
-
string: [
|
|
74
|
-
"node",
|
|
75
|
-
{
|
|
76
|
-
string: true
|
|
77
|
-
}
|
|
78
|
-
],
|
|
79
|
-
symbol: [
|
|
80
|
-
"node",
|
|
81
|
-
{
|
|
82
|
-
symbol: true
|
|
83
|
-
}
|
|
84
|
-
],
|
|
85
|
-
true: [
|
|
86
|
-
"node",
|
|
87
|
-
{
|
|
88
|
-
boolean: {
|
|
89
|
-
value: true
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
],
|
|
93
|
-
unknown: [
|
|
94
|
-
"node",
|
|
95
|
-
always
|
|
96
|
-
],
|
|
97
|
-
void: [
|
|
98
|
-
"node",
|
|
99
|
-
{
|
|
100
|
-
undefined: true
|
|
101
|
-
}
|
|
102
|
-
],
|
|
103
|
-
undefined: [
|
|
104
|
-
"node",
|
|
105
|
-
{
|
|
106
|
-
undefined: true
|
|
107
|
-
}
|
|
108
|
-
]
|
|
109
|
-
}, {
|
|
110
|
-
name: "ts",
|
|
111
|
-
standard: false
|
|
112
|
-
});
|
|
113
|
-
const tsKeywords = tsKeywordsScope.compile();
|
package/dist/cjs/scopes/type.js
DELETED
|
@@ -1,50 +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
|
-
initializeType: ()=>initializeType,
|
|
13
|
-
isType: ()=>isType,
|
|
14
|
-
isAnonymousName: ()=>isAnonymousName
|
|
15
|
-
});
|
|
16
|
-
const _traverseJs = require("../traverse/traverse.js");
|
|
17
|
-
const _chainableNoOpProxyJs = require("../utils/chainableNoOpProxy.js");
|
|
18
|
-
const initializeType = (name, definition, config, scope)=>{
|
|
19
|
-
const root = {
|
|
20
|
-
// temporarily initialize node/flat to aliases that will be included in
|
|
21
|
-
// the final type in case of cyclic resolutions
|
|
22
|
-
node: name,
|
|
23
|
-
flat: [
|
|
24
|
-
[
|
|
25
|
-
"alias",
|
|
26
|
-
name
|
|
27
|
-
]
|
|
28
|
-
],
|
|
29
|
-
allows: (data)=>!namedTraverse(data).problems,
|
|
30
|
-
assert: (data)=>{
|
|
31
|
-
const result = namedTraverse(data);
|
|
32
|
-
return result.problems ? result.problems.throw() : result.data;
|
|
33
|
-
},
|
|
34
|
-
infer: _chainableNoOpProxyJs.chainableNoOpProxy,
|
|
35
|
-
inferIn: _chainableNoOpProxyJs.chainableNoOpProxy,
|
|
36
|
-
qualifiedName: isAnonymousName(name) ? scope.getAnonymousQualifiedName(name) : `${scope.name}.${name}`,
|
|
37
|
-
definition,
|
|
38
|
-
scope,
|
|
39
|
-
includesMorph: false,
|
|
40
|
-
config
|
|
41
|
-
};
|
|
42
|
-
// define within a key to dynamically assign a name to the function
|
|
43
|
-
const namedTraverse = {
|
|
44
|
-
[name]: (data)=>(0, _traverseJs.traverseRoot)(namedTraverse, data)
|
|
45
|
-
}[name];
|
|
46
|
-
const t = Object.assign(namedTraverse, root);
|
|
47
|
-
return t;
|
|
48
|
-
};
|
|
49
|
-
const isType = (value)=>value?.infer === _chainableNoOpProxyJs.chainableNoOpProxy;
|
|
50
|
-
const isAnonymousName = (name)=>name[0] === "λ";
|
|
@@ -1,47 +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
|
-
isLuhnValid: ()=>isLuhnValid,
|
|
13
|
-
creditCard: ()=>creditCard
|
|
14
|
-
});
|
|
15
|
-
const _scopeJs = require("../scope.js");
|
|
16
|
-
const isLuhnValid = (creditCardInput)=>{
|
|
17
|
-
const sanitized = creditCardInput.replace(/[- ]+/g, "");
|
|
18
|
-
let sum = 0;
|
|
19
|
-
let digit;
|
|
20
|
-
let tmpNum;
|
|
21
|
-
let shouldDouble;
|
|
22
|
-
for(let i = sanitized.length - 1; i >= 0; i--){
|
|
23
|
-
digit = sanitized.substring(i, i + 1);
|
|
24
|
-
tmpNum = parseInt(digit, 10);
|
|
25
|
-
if (shouldDouble) {
|
|
26
|
-
tmpNum *= 2;
|
|
27
|
-
if (tmpNum >= 10) {
|
|
28
|
-
sum += tmpNum % 10 + 1;
|
|
29
|
-
} else {
|
|
30
|
-
sum += tmpNum;
|
|
31
|
-
}
|
|
32
|
-
} else {
|
|
33
|
-
sum += tmpNum;
|
|
34
|
-
}
|
|
35
|
-
shouldDouble = !shouldDouble;
|
|
36
|
-
}
|
|
37
|
-
return !!(sum % 10 === 0 ? sanitized : false);
|
|
38
|
-
};
|
|
39
|
-
// https://github.com/validatorjs/validator.js/blob/master/src/lib/isCreditCard.js
|
|
40
|
-
const creditCardMatcher = /^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/;
|
|
41
|
-
const creditCard = (0, _scopeJs.rootType)([
|
|
42
|
-
creditCardMatcher,
|
|
43
|
-
"=>",
|
|
44
|
-
(s, problems)=>isLuhnValid(s) || !problems.mustBe("a valid credit card number")
|
|
45
|
-
], {
|
|
46
|
-
mustBe: "a valid credit card number"
|
|
47
|
-
});
|
|
@@ -1,62 +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
|
-
tryParseDate: ()=>tryParseDate,
|
|
13
|
-
parsedDate: ()=>parsedDate
|
|
14
|
-
});
|
|
15
|
-
const _scopeJs = require("../scope.js");
|
|
16
|
-
const _tsKeywordsJs = require("../tsKeywords.js");
|
|
17
|
-
const dayDelimiterMatcher = /^[./-]$/;
|
|
18
|
-
// ISO 8601 date/time modernized from https://github.com/validatorjs/validator.js/blob/master/src/lib/isISO8601.js
|
|
19
|
-
// Based on https://tc39.es/ecma262/#sec-date-time-string-format, the T
|
|
20
|
-
// delimiter for date/time is mandatory. Regex from validator.js strict matcher:
|
|
21
|
-
const iso8601Matcher = /^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
|
|
22
|
-
const isValidDateInstance = (date)=>!isNaN(date);
|
|
23
|
-
const writeFormattedMustBe = (format)=>`a ${format}-formatted date`;
|
|
24
|
-
const tryParseDate = (data, opts)=>{
|
|
25
|
-
if (!opts?.format) {
|
|
26
|
-
const result = new Date(data);
|
|
27
|
-
return isValidDateInstance(result) ? result : "a valid date";
|
|
28
|
-
}
|
|
29
|
-
if (opts.format === "iso8601") {
|
|
30
|
-
return iso8601Matcher.test(data) ? new Date(data) : writeFormattedMustBe("iso8601");
|
|
31
|
-
}
|
|
32
|
-
const dataParts = data.split(dayDelimiterMatcher);
|
|
33
|
-
// will be the first delimiter matched, if there is one
|
|
34
|
-
const delimiter = data[dataParts[0].length];
|
|
35
|
-
const formatParts = delimiter ? opts.format.split(delimiter) : [
|
|
36
|
-
opts.format
|
|
37
|
-
];
|
|
38
|
-
if (dataParts.length !== formatParts.length) {
|
|
39
|
-
return writeFormattedMustBe(opts.format);
|
|
40
|
-
}
|
|
41
|
-
const parsedParts = {};
|
|
42
|
-
for(let i = 0; i < formatParts.length; i++){
|
|
43
|
-
if (dataParts[i].length !== formatParts[i].length && // if format is "m" or "d", data is allowed to be 1 or 2 characters
|
|
44
|
-
!(formatParts[i].length === 1 && dataParts[i].length === 2)) {
|
|
45
|
-
return writeFormattedMustBe(opts.format);
|
|
46
|
-
}
|
|
47
|
-
parsedParts[formatParts[i][0]] = dataParts[i];
|
|
48
|
-
}
|
|
49
|
-
const date = new Date(`${parsedParts.m}/${parsedParts.d}/${parsedParts.y}`);
|
|
50
|
-
if (`${date.getDate()}` === parsedParts.d) {
|
|
51
|
-
return date;
|
|
52
|
-
}
|
|
53
|
-
return writeFormattedMustBe(opts.format);
|
|
54
|
-
};
|
|
55
|
-
const parsedDate = (0, _scopeJs.rootType)([
|
|
56
|
-
_tsKeywordsJs.tsKeywords.string,
|
|
57
|
-
"|>",
|
|
58
|
-
(s, problems)=>{
|
|
59
|
-
const result = tryParseDate(s);
|
|
60
|
-
return typeof result === "string" ? problems.mustBe(result) : result;
|
|
61
|
-
}
|
|
62
|
-
]);
|
|
@@ -1,108 +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
|
-
validationScope: ()=>validationScope,
|
|
13
|
-
validation: ()=>validation
|
|
14
|
-
});
|
|
15
|
-
const _numericLiteralsJs = require("../../utils/numericLiterals.js");
|
|
16
|
-
const _scopeJs = require("../scope.js");
|
|
17
|
-
const _tsKeywordsJs = require("../tsKeywords.js");
|
|
18
|
-
const _creditCardJs = require("./creditCard.js");
|
|
19
|
-
const _dateJs = require("./date.js");
|
|
20
|
-
// Non-trivial expressions should have an explanation or attribution
|
|
21
|
-
const parsedNumber = (0, _scopeJs.rootType)([
|
|
22
|
-
_numericLiteralsJs.wellFormedNumberMatcher,
|
|
23
|
-
"|>",
|
|
24
|
-
(s)=>parseFloat(s)
|
|
25
|
-
], {
|
|
26
|
-
mustBe: "a well-formed numeric string"
|
|
27
|
-
});
|
|
28
|
-
const parsedInteger = (0, _scopeJs.rootType)([
|
|
29
|
-
_tsKeywordsJs.tsKeywords.string,
|
|
30
|
-
"|>",
|
|
31
|
-
(s, problems)=>{
|
|
32
|
-
if (!(0, _numericLiteralsJs.isWellFormedInteger)(s)) {
|
|
33
|
-
return problems.mustBe("a well-formed integer string");
|
|
34
|
-
}
|
|
35
|
-
const parsed = parseInt(s);
|
|
36
|
-
return Number.isSafeInteger(parsed) ? parsed : problems.mustBe("an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER");
|
|
37
|
-
}
|
|
38
|
-
]);
|
|
39
|
-
// https://www.regular-expressions.info/email.html
|
|
40
|
-
const email = (0, _scopeJs.rootType)(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/, {
|
|
41
|
-
mustBe: "a valid email"
|
|
42
|
-
});
|
|
43
|
-
// https://github.com/validatorjs/validator.js/blob/master/src/lib/isUUID.js
|
|
44
|
-
const uuid = (0, _scopeJs.rootType)(/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/, {
|
|
45
|
-
mustBe: "a valid UUID"
|
|
46
|
-
});
|
|
47
|
-
// https://semver.org/
|
|
48
|
-
const semver = (0, _scopeJs.rootType)(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/, {
|
|
49
|
-
mustBe: "a valid semantic version (see https://semver.org/)"
|
|
50
|
-
});
|
|
51
|
-
const json = (0, _scopeJs.rootType)([
|
|
52
|
-
_tsKeywordsJs.tsKeywords.string,
|
|
53
|
-
"|>",
|
|
54
|
-
(s)=>JSON.parse(s)
|
|
55
|
-
], {
|
|
56
|
-
mustBe: "a JSON-parsable string"
|
|
57
|
-
});
|
|
58
|
-
const validationScope = (0, _scopeJs.scope)({
|
|
59
|
-
// Character sets
|
|
60
|
-
alpha: [
|
|
61
|
-
/^[A-Za-z]*$/,
|
|
62
|
-
":",
|
|
63
|
-
{
|
|
64
|
-
mustBe: "only letters"
|
|
65
|
-
}
|
|
66
|
-
],
|
|
67
|
-
alphanumeric: [
|
|
68
|
-
/^[A-Za-z\d]*$/,
|
|
69
|
-
":",
|
|
70
|
-
{
|
|
71
|
-
mustBe: "only letters and digits"
|
|
72
|
-
}
|
|
73
|
-
],
|
|
74
|
-
lowercase: [
|
|
75
|
-
/^[a-z]*$/,
|
|
76
|
-
":",
|
|
77
|
-
{
|
|
78
|
-
mustBe: "only lowercase letters"
|
|
79
|
-
}
|
|
80
|
-
],
|
|
81
|
-
uppercase: [
|
|
82
|
-
/^[A-Z]*$/,
|
|
83
|
-
":",
|
|
84
|
-
{
|
|
85
|
-
mustBe: "only uppercase letters"
|
|
86
|
-
}
|
|
87
|
-
],
|
|
88
|
-
creditCard: _creditCardJs.creditCard,
|
|
89
|
-
email,
|
|
90
|
-
uuid,
|
|
91
|
-
parsedNumber,
|
|
92
|
-
parsedInteger,
|
|
93
|
-
parsedDate: _dateJs.parsedDate,
|
|
94
|
-
semver,
|
|
95
|
-
json,
|
|
96
|
-
integer: [
|
|
97
|
-
"node",
|
|
98
|
-
{
|
|
99
|
-
number: {
|
|
100
|
-
divisor: 1
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
]
|
|
104
|
-
}, {
|
|
105
|
-
name: "validation",
|
|
106
|
-
standard: false
|
|
107
|
-
});
|
|
108
|
-
const validation = validationScope.compile();
|