arktype 1.0.16-alpha → 1.0.18-alpha
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/README.md +3 -3
- package/dist/cjs/main.js +38 -0
- package/dist/cjs/nodes/branch.js +140 -0
- package/dist/cjs/nodes/compose.js +157 -0
- package/dist/{nodes → cjs/nodes}/discriminate.js +92 -100
- package/dist/cjs/nodes/node.js +139 -0
- package/dist/cjs/nodes/predicate.js +86 -0
- package/dist/cjs/nodes/rules/class.js +25 -0
- package/dist/cjs/nodes/rules/collapsibleSet.js +48 -0
- package/dist/cjs/nodes/rules/divisor.js +29 -0
- package/dist/cjs/nodes/rules/props.js +160 -0
- package/dist/cjs/nodes/rules/range.js +105 -0
- package/dist/cjs/nodes/rules/regex.js +26 -0
- package/dist/cjs/nodes/rules/rules.js +123 -0
- package/dist/cjs/parse/ast/ast.js +4 -0
- package/dist/cjs/parse/ast/bound.js +16 -0
- package/dist/cjs/parse/ast/config.js +13 -0
- package/dist/cjs/parse/ast/distributableFunction.js +48 -0
- package/dist/cjs/parse/ast/divisor.js +9 -0
- package/dist/cjs/parse/ast/intersection.js +30 -0
- package/dist/cjs/parse/ast/keyof.js +111 -0
- package/dist/cjs/parse/ast/morph.js +58 -0
- package/dist/cjs/parse/ast/narrow.js +22 -0
- package/dist/cjs/parse/ast/node.js +4 -0
- package/dist/cjs/parse/ast/tuple.js +94 -0
- package/dist/cjs/parse/ast/union.js +9 -0
- package/dist/cjs/parse/ast/utils.js +4 -0
- package/dist/cjs/parse/definition.js +61 -0
- package/dist/cjs/parse/record.js +37 -0
- package/dist/cjs/parse/string/reduce/dynamic.js +167 -0
- package/dist/cjs/parse/string/reduce/shared.js +23 -0
- package/dist/cjs/parse/string/reduce/static.js +4 -0
- package/dist/cjs/parse/string/shift/operand/enclosed.js +54 -0
- package/dist/cjs/parse/string/shift/operand/operand.js +11 -0
- package/dist/cjs/parse/string/shift/operand/unenclosed.js +53 -0
- package/dist/cjs/parse/string/shift/operator/bounds.js +87 -0
- package/dist/cjs/parse/string/shift/operator/divisor.js +35 -0
- package/dist/cjs/parse/string/shift/operator/operator.js +26 -0
- package/dist/cjs/parse/string/shift/scanner.js +114 -0
- package/dist/cjs/parse/string/string.js +43 -0
- package/dist/cjs/scopes/ark.js +45 -0
- package/dist/cjs/scopes/cache.js +52 -0
- package/dist/cjs/scopes/expressions.js +29 -0
- package/dist/cjs/scopes/jsObjects.js +93 -0
- package/dist/cjs/scopes/scope.js +323 -0
- package/dist/cjs/scopes/tsKeywords.js +113 -0
- package/dist/cjs/scopes/type.js +50 -0
- package/dist/cjs/scopes/validation/creditCard.js +47 -0
- package/dist/cjs/scopes/validation/date.js +62 -0
- package/dist/cjs/scopes/validation/validation.js +108 -0
- package/dist/cjs/traverse/problems.js +281 -0
- package/dist/cjs/traverse/traverse.js +390 -0
- package/dist/cjs/utils/chainableNoOpProxy.js +23 -0
- package/dist/cjs/utils/data.js +53 -0
- package/dist/cjs/utils/domains.js +30 -0
- package/dist/cjs/utils/errors.js +26 -0
- package/dist/cjs/utils/freeze.js +15 -0
- package/dist/cjs/utils/generics.js +63 -0
- package/dist/cjs/utils/numericLiterals.js +75 -0
- package/dist/cjs/utils/objectKinds.js +69 -0
- package/dist/cjs/utils/paths.js +32 -0
- package/dist/cjs/utils/serialize.js +74 -0
- package/dist/cjs/utils/unionToTuple.js +4 -0
- package/dist/mjs/main.js +8 -0
- package/dist/mjs/nodes/branch.js +123 -0
- package/dist/mjs/nodes/compose.js +135 -0
- package/dist/mjs/nodes/discriminate.js +247 -0
- package/dist/mjs/nodes/node.js +117 -0
- package/dist/mjs/nodes/predicate.js +69 -0
- package/dist/mjs/nodes/rules/class.js +11 -0
- package/dist/mjs/nodes/rules/collapsibleSet.js +34 -0
- package/dist/mjs/nodes/rules/divisor.js +15 -0
- package/dist/mjs/nodes/rules/props.js +142 -0
- package/dist/mjs/nodes/rules/range.js +86 -0
- package/dist/mjs/nodes/rules/regex.js +11 -0
- package/dist/mjs/nodes/rules/rules.js +106 -0
- package/dist/mjs/package.json +3 -0
- package/dist/mjs/parse/ast/ast.js +1 -0
- package/dist/mjs/parse/ast/bound.js +2 -0
- package/dist/mjs/parse/ast/config.js +9 -0
- package/dist/mjs/parse/ast/distributableFunction.js +34 -0
- package/dist/mjs/parse/ast/divisor.js +1 -0
- package/dist/mjs/parse/ast/intersection.js +16 -0
- package/dist/mjs/parse/ast/keyof.js +103 -0
- package/dist/mjs/parse/ast/morph.js +44 -0
- package/dist/mjs/parse/ast/narrow.js +14 -0
- package/dist/mjs/parse/ast/node.js +1 -0
- package/dist/mjs/parse/ast/tuple.js +80 -0
- package/dist/mjs/parse/ast/union.js +1 -0
- package/dist/mjs/parse/ast/utils.js +1 -0
- package/dist/mjs/parse/definition.js +46 -0
- package/dist/mjs/parse/record.js +29 -0
- package/dist/mjs/parse/string/reduce/dynamic.js +159 -0
- package/dist/mjs/parse/string/reduce/shared.js +6 -0
- package/dist/mjs/parse/string/reduce/static.js +1 -0
- package/dist/mjs/parse/string/shift/operand/enclosed.js +39 -0
- package/dist/mjs/parse/string/shift/operand/operand.js +3 -0
- package/dist/mjs/parse/string/shift/operand/unenclosed.js +36 -0
- package/dist/mjs/parse/string/shift/operator/bounds.js +70 -0
- package/dist/mjs/parse/string/shift/operator/divisor.js +21 -0
- package/dist/mjs/parse/string/shift/operator/operator.js +13 -0
- package/dist/mjs/parse/string/shift/scanner.js +106 -0
- package/dist/mjs/parse/string/string.js +28 -0
- package/dist/mjs/scopes/ark.js +28 -0
- package/dist/mjs/scopes/cache.js +38 -0
- package/dist/{scopes → mjs/scopes}/expressions.js +9 -20
- package/dist/mjs/scopes/jsObjects.js +82 -0
- package/dist/mjs/scopes/scope.js +303 -0
- package/dist/mjs/scopes/tsKeywords.js +116 -0
- package/dist/mjs/scopes/type.js +35 -0
- package/dist/{scopes → mjs/scopes}/validation/creditCard.js +11 -15
- package/dist/{scopes → mjs/scopes}/validation/date.js +16 -21
- package/dist/mjs/scopes/validation/validation.js +112 -0
- package/dist/mjs/traverse/problems.js +260 -0
- package/dist/mjs/traverse/traverse.js +373 -0
- package/dist/{utils → mjs/utils}/chainableNoOpProxy.js +2 -6
- package/dist/mjs/utils/data.js +38 -0
- package/dist/mjs/utils/domains.js +15 -0
- package/dist/mjs/utils/errors.js +10 -0
- package/dist/mjs/utils/freeze.js +7 -0
- package/dist/mjs/utils/generics.js +38 -0
- package/dist/mjs/utils/numericLiterals.js +72 -0
- package/dist/mjs/utils/objectKinds.js +55 -0
- package/dist/{utils → mjs/utils}/paths.js +3 -8
- package/dist/mjs/utils/serialize.js +58 -0
- package/dist/mjs/utils/unionToTuple.js +1 -0
- package/dist/tsconfig.temp.tsbuildinfo +1 -1
- package/package.json +14 -6
- package/dist/main.js +0 -29
- package/dist/nodes/branch.js +0 -135
- package/dist/nodes/compose.js +0 -99
- package/dist/nodes/node.js +0 -134
- package/dist/nodes/predicate.js +0 -88
- package/dist/nodes/rules/class.js +0 -23
- package/dist/nodes/rules/collapsibleSet.js +0 -34
- package/dist/nodes/rules/divisor.js +0 -19
- package/dist/nodes/rules/props.js +0 -130
- package/dist/nodes/rules/range.js +0 -108
- package/dist/nodes/rules/regex.js +0 -17
- package/dist/nodes/rules/rules.js +0 -102
- package/dist/parse/ast/ast.js +0 -2
- package/dist/parse/ast/bound.js +0 -7
- package/dist/parse/ast/config.js +0 -14
- package/dist/parse/ast/distributableFunction.js +0 -40
- package/dist/parse/ast/divisor.js +0 -5
- package/dist/parse/ast/intersection.js +0 -21
- package/dist/parse/ast/keyof.js +0 -107
- package/dist/parse/ast/morph.js +0 -50
- package/dist/parse/ast/narrow.js +0 -17
- package/dist/parse/ast/node.js +0 -2
- package/dist/parse/ast/tuple.js +0 -72
- package/dist/parse/ast/union.js +0 -5
- package/dist/parse/ast/utils.js +0 -2
- package/dist/parse/definition.js +0 -47
- package/dist/parse/record.js +0 -31
- package/dist/parse/string/reduce/dynamic.js +0 -159
- package/dist/parse/string/reduce/shared.js +0 -13
- package/dist/parse/string/reduce/static.js +0 -2
- package/dist/parse/string/shift/operand/enclosed.js +0 -37
- package/dist/parse/string/shift/operand/operand.js +0 -15
- package/dist/parse/string/shift/operand/unenclosed.js +0 -45
- package/dist/parse/string/shift/operator/bounds.js +0 -83
- package/dist/parse/string/shift/operator/divisor.js +0 -23
- package/dist/parse/string/shift/operator/operator.js +0 -34
- package/dist/parse/string/shift/scanner.js +0 -97
- package/dist/parse/string/string.js +0 -35
- package/dist/scopes/ark.js +0 -27
- package/dist/scopes/cache.js +0 -28
- package/dist/scopes/jsObjects.js +0 -20
- package/dist/scopes/scope.js +0 -184
- package/dist/scopes/tsKeywords.js +0 -49
- package/dist/scopes/type.js +0 -40
- package/dist/scopes/validation/validation.js +0 -74
- package/dist/traverse/problems.js +0 -234
- package/dist/traverse/traverse.js +0 -330
- package/dist/utils/data.js +0 -39
- package/dist/utils/domains.js +0 -27
- package/dist/utils/errors.js +0 -17
- package/dist/utils/freeze.js +0 -16
- package/dist/utils/generics.js +0 -53
- package/dist/utils/numericLiterals.js +0 -88
- package/dist/utils/objectKinds.js +0 -69
- package/dist/utils/serialize.js +0 -71
- package/dist/utils/unionToTuple.js +0 -2
- /package/dist/{package.json → cjs/package.json} +0 -0
- /package/dist/{main.d.ts → types/main.d.ts} +0 -0
- /package/dist/{nodes → types/nodes}/branch.d.ts +0 -0
- /package/dist/{nodes → types/nodes}/compose.d.ts +0 -0
- /package/dist/{nodes → types/nodes}/discriminate.d.ts +0 -0
- /package/dist/{nodes → types/nodes}/node.d.ts +0 -0
- /package/dist/{nodes → types/nodes}/predicate.d.ts +0 -0
- /package/dist/{nodes → types/nodes}/rules/class.d.ts +0 -0
- /package/dist/{nodes → types/nodes}/rules/collapsibleSet.d.ts +0 -0
- /package/dist/{nodes → types/nodes}/rules/divisor.d.ts +0 -0
- /package/dist/{nodes → types/nodes}/rules/props.d.ts +0 -0
- /package/dist/{nodes → types/nodes}/rules/range.d.ts +0 -0
- /package/dist/{nodes → types/nodes}/rules/regex.d.ts +0 -0
- /package/dist/{nodes → types/nodes}/rules/rules.d.ts +0 -0
- /package/dist/{parse → types/parse}/ast/ast.d.ts +0 -0
- /package/dist/{parse → types/parse}/ast/bound.d.ts +0 -0
- /package/dist/{parse → types/parse}/ast/config.d.ts +0 -0
- /package/dist/{parse → types/parse}/ast/distributableFunction.d.ts +0 -0
- /package/dist/{parse → types/parse}/ast/divisor.d.ts +0 -0
- /package/dist/{parse → types/parse}/ast/intersection.d.ts +0 -0
- /package/dist/{parse → types/parse}/ast/keyof.d.ts +0 -0
- /package/dist/{parse → types/parse}/ast/morph.d.ts +0 -0
- /package/dist/{parse → types/parse}/ast/narrow.d.ts +0 -0
- /package/dist/{parse → types/parse}/ast/node.d.ts +0 -0
- /package/dist/{parse → types/parse}/ast/tuple.d.ts +0 -0
- /package/dist/{parse → types/parse}/ast/union.d.ts +0 -0
- /package/dist/{parse → types/parse}/ast/utils.d.ts +0 -0
- /package/dist/{parse → types/parse}/definition.d.ts +0 -0
- /package/dist/{parse → types/parse}/record.d.ts +0 -0
- /package/dist/{parse → types/parse}/string/reduce/dynamic.d.ts +0 -0
- /package/dist/{parse → types/parse}/string/reduce/shared.d.ts +0 -0
- /package/dist/{parse → types/parse}/string/reduce/static.d.ts +0 -0
- /package/dist/{parse → types/parse}/string/shift/operand/enclosed.d.ts +0 -0
- /package/dist/{parse → types/parse}/string/shift/operand/operand.d.ts +0 -0
- /package/dist/{parse → types/parse}/string/shift/operand/unenclosed.d.ts +0 -0
- /package/dist/{parse → types/parse}/string/shift/operator/bounds.d.ts +0 -0
- /package/dist/{parse → types/parse}/string/shift/operator/divisor.d.ts +0 -0
- /package/dist/{parse → types/parse}/string/shift/operator/operator.d.ts +0 -0
- /package/dist/{parse → types/parse}/string/shift/scanner.d.ts +0 -0
- /package/dist/{parse → types/parse}/string/string.d.ts +0 -0
- /package/dist/{scopes → types/scopes}/ark.d.ts +0 -0
- /package/dist/{scopes → types/scopes}/cache.d.ts +0 -0
- /package/dist/{scopes → types/scopes}/expressions.d.ts +0 -0
- /package/dist/{scopes → types/scopes}/jsObjects.d.ts +0 -0
- /package/dist/{scopes → types/scopes}/scope.d.ts +0 -0
- /package/dist/{scopes → types/scopes}/tsKeywords.d.ts +0 -0
- /package/dist/{scopes → types/scopes}/type.d.ts +0 -0
- /package/dist/{scopes → types/scopes}/validation/creditCard.d.ts +0 -0
- /package/dist/{scopes → types/scopes}/validation/date.d.ts +0 -0
- /package/dist/{scopes → types/scopes}/validation/validation.d.ts +0 -0
- /package/dist/{traverse → types/traverse}/problems.d.ts +0 -0
- /package/dist/{traverse → types/traverse}/traverse.d.ts +0 -0
- /package/dist/{utils → types/utils}/chainableNoOpProxy.d.ts +0 -0
- /package/dist/{utils → types/utils}/data.d.ts +0 -0
- /package/dist/{utils → types/utils}/domains.d.ts +0 -0
- /package/dist/{utils → types/utils}/errors.d.ts +0 -0
- /package/dist/{utils → types/utils}/freeze.d.ts +0 -0
- /package/dist/{utils → types/utils}/generics.d.ts +0 -0
- /package/dist/{utils → types/utils}/numericLiterals.d.ts +0 -0
- /package/dist/{utils → types/utils}/objectKinds.d.ts +0 -0
- /package/dist/{utils → types/utils}/paths.d.ts +0 -0
- /package/dist/{utils → types/utils}/serialize.d.ts +0 -0
- /package/dist/{utils → types/utils}/unionToTuple.d.ts +0 -0
package/dist/utils/serialize.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deserializePrimitive = exports.serializePrimitive = exports.stringify = exports.snapshot = void 0;
|
|
4
|
-
const domains_js_1 = require("./domains.js");
|
|
5
|
-
const generics_js_1 = require("./generics.js");
|
|
6
|
-
const numericLiterals_js_1 = require("./numericLiterals.js");
|
|
7
|
-
const snapshot = (data, opts = {}) => serializeRecurse(data, opts, []);
|
|
8
|
-
exports.snapshot = snapshot;
|
|
9
|
-
const stringify = (data, indent) => {
|
|
10
|
-
switch ((0, domains_js_1.domainOf)(data)) {
|
|
11
|
-
case "object":
|
|
12
|
-
return JSON.stringify(serializeRecurse(data, stringifyOpts, []), null, indent);
|
|
13
|
-
case "symbol":
|
|
14
|
-
return stringifyOpts.onSymbol(data);
|
|
15
|
-
default:
|
|
16
|
-
return (0, exports.serializePrimitive)(data);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
exports.stringify = stringify;
|
|
20
|
-
const stringifyOpts = {
|
|
21
|
-
onCycle: () => "(cycle)",
|
|
22
|
-
onSymbol: (v) => `(symbol${v.description && ` ${v.description}`})`,
|
|
23
|
-
onFunction: (v) => `(function${v.name && ` ${v.name}`})`
|
|
24
|
-
};
|
|
25
|
-
const serializeRecurse = (data, context, seen) => {
|
|
26
|
-
switch ((0, domains_js_1.domainOf)(data)) {
|
|
27
|
-
case "object":
|
|
28
|
-
if (typeof data === "function") {
|
|
29
|
-
return stringifyOpts.onFunction(data);
|
|
30
|
-
}
|
|
31
|
-
if (seen.includes(data)) {
|
|
32
|
-
return "(cycle)";
|
|
33
|
-
}
|
|
34
|
-
const nextSeen = [...seen, data];
|
|
35
|
-
if (Array.isArray(data)) {
|
|
36
|
-
return data.map((item) => serializeRecurse(item, context, nextSeen));
|
|
37
|
-
}
|
|
38
|
-
const result = {};
|
|
39
|
-
for (const k in data) {
|
|
40
|
-
result[k] = serializeRecurse(data[k], context, nextSeen);
|
|
41
|
-
}
|
|
42
|
-
return result;
|
|
43
|
-
case "symbol":
|
|
44
|
-
return stringifyOpts.onSymbol(data);
|
|
45
|
-
case "bigint":
|
|
46
|
-
return `${data}n`;
|
|
47
|
-
case "undefined":
|
|
48
|
-
return "undefined";
|
|
49
|
-
default:
|
|
50
|
-
return data;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const serializePrimitive = (value) => (typeof value === "string"
|
|
54
|
-
? `'${value}'`
|
|
55
|
-
: typeof value === "bigint"
|
|
56
|
-
? `${value}n`
|
|
57
|
-
: `${value}`);
|
|
58
|
-
exports.serializePrimitive = serializePrimitive;
|
|
59
|
-
const deserializePrimitive = (serialized) => ((0, generics_js_1.isKeyOf)(serialized, serializedKeywords)
|
|
60
|
-
? serializedKeywords[serialized]
|
|
61
|
-
: serialized[0] === "'"
|
|
62
|
-
? serialized.slice(1, -1)
|
|
63
|
-
: (0, numericLiterals_js_1.tryParseWellFormedBigint)(serialized) ??
|
|
64
|
-
(0, numericLiterals_js_1.tryParseWellFormedNumber)(serialized, true));
|
|
65
|
-
exports.deserializePrimitive = deserializePrimitive;
|
|
66
|
-
const serializedKeywords = {
|
|
67
|
-
true: true,
|
|
68
|
-
false: false,
|
|
69
|
-
undefined,
|
|
70
|
-
null: null
|
|
71
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|