typesea 0.1.0
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/CHANGELOG.md +9 -0
- package/LICENSE +21 -0
- package/README.md +320 -0
- package/dist/adapters/index.d.ts +152 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +396 -0
- package/dist/aot/index.d.ts +33 -0
- package/dist/aot/index.d.ts.map +1 -0
- package/dist/aot/index.js +295 -0
- package/dist/async/index.d.ts +111 -0
- package/dist/async/index.d.ts.map +1 -0
- package/dist/async/index.js +221 -0
- package/dist/builders/composite.d.ts +31 -0
- package/dist/builders/composite.d.ts.map +1 -0
- package/dist/builders/composite.js +165 -0
- package/dist/builders/index.d.ts +11 -0
- package/dist/builders/index.d.ts.map +1 -0
- package/dist/builders/index.js +9 -0
- package/dist/builders/modifier.d.ts +26 -0
- package/dist/builders/modifier.d.ts.map +1 -0
- package/dist/builders/modifier.js +67 -0
- package/dist/builders/object/guard.d.ts +62 -0
- package/dist/builders/object/guard.d.ts.map +1 -0
- package/dist/builders/object/guard.js +113 -0
- package/dist/builders/object/index.d.ts +7 -0
- package/dist/builders/object/index.d.ts.map +1 -0
- package/dist/builders/object/index.js +5 -0
- package/dist/builders/object/schema.d.ts +44 -0
- package/dist/builders/object/schema.d.ts.map +1 -0
- package/dist/builders/object/schema.js +257 -0
- package/dist/builders/object/types.d.ts +63 -0
- package/dist/builders/object/types.d.ts.map +1 -0
- package/dist/builders/object/types.js +5 -0
- package/dist/builders/scalar.d.ts +39 -0
- package/dist/builders/scalar.d.ts.map +1 -0
- package/dist/builders/scalar.js +63 -0
- package/dist/builders/table.d.ts +53 -0
- package/dist/builders/table.d.ts.map +1 -0
- package/dist/builders/table.js +48 -0
- package/dist/builders/types.d.ts +26 -0
- package/dist/builders/types.d.ts.map +1 -0
- package/dist/builders/types.js +5 -0
- package/dist/compile/check-composite.d.ts +34 -0
- package/dist/compile/check-composite.d.ts.map +1 -0
- package/dist/compile/check-composite.js +117 -0
- package/dist/compile/check-scalar.d.ts +24 -0
- package/dist/compile/check-scalar.d.ts.map +1 -0
- package/dist/compile/check-scalar.js +73 -0
- package/dist/compile/check.d.ts +15 -0
- package/dist/compile/check.d.ts.map +1 -0
- package/dist/compile/check.js +98 -0
- package/dist/compile/context.d.ts +35 -0
- package/dist/compile/context.d.ts.map +1 -0
- package/dist/compile/context.js +72 -0
- package/dist/compile/graph-predicate.d.ts +19 -0
- package/dist/compile/graph-predicate.d.ts.map +1 -0
- package/dist/compile/graph-predicate.js +460 -0
- package/dist/compile/guard.d.ts +41 -0
- package/dist/compile/guard.d.ts.map +1 -0
- package/dist/compile/guard.js +180 -0
- package/dist/compile/index.d.ts +8 -0
- package/dist/compile/index.d.ts.map +1 -0
- package/dist/compile/index.js +6 -0
- package/dist/compile/issue.d.ts +18 -0
- package/dist/compile/issue.d.ts.map +1 -0
- package/dist/compile/issue.js +28 -0
- package/dist/compile/names.d.ts +16 -0
- package/dist/compile/names.d.ts.map +1 -0
- package/dist/compile/names.js +82 -0
- package/dist/compile/predicate.d.ts +23 -0
- package/dist/compile/predicate.d.ts.map +1 -0
- package/dist/compile/predicate.js +317 -0
- package/dist/compile/runtime.d.ts +55 -0
- package/dist/compile/runtime.d.ts.map +1 -0
- package/dist/compile/runtime.js +63 -0
- package/dist/compile/source.d.ts +11 -0
- package/dist/compile/source.d.ts.map +1 -0
- package/dist/compile/source.js +51 -0
- package/dist/compile/types.d.ts +52 -0
- package/dist/compile/types.d.ts.map +1 -0
- package/dist/compile/types.js +5 -0
- package/dist/decoder/index.d.ts +106 -0
- package/dist/decoder/index.d.ts.map +1 -0
- package/dist/decoder/index.js +262 -0
- package/dist/evaluate/check-composite.d.ts +39 -0
- package/dist/evaluate/check-composite.d.ts.map +1 -0
- package/dist/evaluate/check-composite.js +184 -0
- package/dist/evaluate/check-scalar.d.ts +20 -0
- package/dist/evaluate/check-scalar.d.ts.map +1 -0
- package/dist/evaluate/check-scalar.js +81 -0
- package/dist/evaluate/check.d.ts +11 -0
- package/dist/evaluate/check.d.ts.map +1 -0
- package/dist/evaluate/check.js +126 -0
- package/dist/evaluate/index.d.ts +7 -0
- package/dist/evaluate/index.d.ts.map +1 -0
- package/dist/evaluate/index.js +6 -0
- package/dist/evaluate/issue.d.ts +10 -0
- package/dist/evaluate/issue.d.ts.map +1 -0
- package/dist/evaluate/issue.js +11 -0
- package/dist/evaluate/predicate.d.ts +26 -0
- package/dist/evaluate/predicate.d.ts.map +1 -0
- package/dist/evaluate/predicate.js +37 -0
- package/dist/evaluate/shared.d.ts +59 -0
- package/dist/evaluate/shared.d.ts.map +1 -0
- package/dist/evaluate/shared.js +96 -0
- package/dist/evaluate/state.d.ts +65 -0
- package/dist/evaluate/state.d.ts.map +1 -0
- package/dist/evaluate/state.js +66 -0
- package/dist/guard/base.d.ts +72 -0
- package/dist/guard/base.d.ts.map +1 -0
- package/dist/guard/base.js +136 -0
- package/dist/guard/error.d.ts +19 -0
- package/dist/guard/error.d.ts.map +1 -0
- package/dist/guard/error.js +22 -0
- package/dist/guard/index.d.ts +10 -0
- package/dist/guard/index.d.ts.map +1 -0
- package/dist/guard/index.js +8 -0
- package/dist/guard/number.d.ts +32 -0
- package/dist/guard/number.d.ts.map +1 -0
- package/dist/guard/number.js +71 -0
- package/dist/guard/props.d.ts +18 -0
- package/dist/guard/props.d.ts.map +1 -0
- package/dist/guard/props.js +35 -0
- package/dist/guard/read.d.ts +42 -0
- package/dist/guard/read.d.ts.map +1 -0
- package/dist/guard/read.js +114 -0
- package/dist/guard/registry.d.ts +15 -0
- package/dist/guard/registry.d.ts.map +1 -0
- package/dist/guard/registry.js +21 -0
- package/dist/guard/string.d.ts +36 -0
- package/dist/guard/string.d.ts.map +1 -0
- package/dist/guard/string.js +95 -0
- package/dist/guard/types.d.ts +103 -0
- package/dist/guard/types.d.ts.map +1 -0
- package/dist/guard/types.js +5 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/internal/index.d.ts +34 -0
- package/dist/internal/index.d.ts.map +1 -0
- package/dist/internal/index.js +56 -0
- package/dist/ir/builder.d.ts +173 -0
- package/dist/ir/builder.d.ts.map +1 -0
- package/dist/ir/builder.js +481 -0
- package/dist/ir/freeze.d.ts +10 -0
- package/dist/ir/freeze.d.ts.map +1 -0
- package/dist/ir/freeze.js +102 -0
- package/dist/ir/index.d.ts +9 -0
- package/dist/ir/index.d.ts.map +1 -0
- package/dist/ir/index.js +7 -0
- package/dist/ir/regexp.d.ts +6 -0
- package/dist/ir/regexp.d.ts.map +1 -0
- package/dist/ir/regexp.js +12 -0
- package/dist/ir/types.d.ts +215 -0
- package/dist/ir/types.d.ts.map +1 -0
- package/dist/ir/types.js +5 -0
- package/dist/ir/validate.d.ts +10 -0
- package/dist/ir/validate.d.ts.map +1 -0
- package/dist/ir/validate.js +271 -0
- package/dist/issue/index.d.ts +44 -0
- package/dist/issue/index.d.ts.map +1 -0
- package/dist/issue/index.js +152 -0
- package/dist/json-schema/emit-combinator.d.ts +28 -0
- package/dist/json-schema/emit-combinator.d.ts.map +1 -0
- package/dist/json-schema/emit-combinator.js +96 -0
- package/dist/json-schema/emit-composite.d.ts +28 -0
- package/dist/json-schema/emit-composite.d.ts.map +1 -0
- package/dist/json-schema/emit-composite.js +127 -0
- package/dist/json-schema/emit-scalar.d.ts +25 -0
- package/dist/json-schema/emit-scalar.d.ts.map +1 -0
- package/dist/json-schema/emit-scalar.js +104 -0
- package/dist/json-schema/emit-types.d.ts +12 -0
- package/dist/json-schema/emit-types.d.ts.map +1 -0
- package/dist/json-schema/emit-types.js +5 -0
- package/dist/json-schema/emit.d.ts +12 -0
- package/dist/json-schema/emit.d.ts.map +1 -0
- package/dist/json-schema/emit.js +62 -0
- package/dist/json-schema/freeze.d.ts +14 -0
- package/dist/json-schema/freeze.d.ts.map +1 -0
- package/dist/json-schema/freeze.js +114 -0
- package/dist/json-schema/index.d.ts +20 -0
- package/dist/json-schema/index.d.ts.map +1 -0
- package/dist/json-schema/index.js +76 -0
- package/dist/json-schema/issue.d.ts +11 -0
- package/dist/json-schema/issue.d.ts.map +1 -0
- package/dist/json-schema/issue.js +14 -0
- package/dist/json-schema/read.d.ts +29 -0
- package/dist/json-schema/read.d.ts.map +1 -0
- package/dist/json-schema/read.js +87 -0
- package/dist/json-schema/types.d.ts +106 -0
- package/dist/json-schema/types.d.ts.map +1 -0
- package/dist/json-schema/types.js +5 -0
- package/dist/kind/index.d.ts +119 -0
- package/dist/kind/index.d.ts.map +1 -0
- package/dist/kind/index.js +94 -0
- package/dist/lower/index.d.ts +7 -0
- package/dist/lower/index.d.ts.map +1 -0
- package/dist/lower/index.js +199 -0
- package/dist/message/index.d.ts +51 -0
- package/dist/message/index.d.ts.map +1 -0
- package/dist/message/index.js +269 -0
- package/dist/optimize/compact.d.ts +10 -0
- package/dist/optimize/compact.d.ts.map +1 -0
- package/dist/optimize/compact.js +60 -0
- package/dist/optimize/fold-boolean.d.ts +15 -0
- package/dist/optimize/fold-boolean.d.ts.map +1 -0
- package/dist/optimize/fold-boolean.js +75 -0
- package/dist/optimize/fold-common.d.ts +45 -0
- package/dist/optimize/fold-common.d.ts.map +1 -0
- package/dist/optimize/fold-common.js +71 -0
- package/dist/optimize/fold-scalar.d.ts +59 -0
- package/dist/optimize/fold-scalar.d.ts.map +1 -0
- package/dist/optimize/fold-scalar.js +174 -0
- package/dist/optimize/fold.d.ts +10 -0
- package/dist/optimize/fold.d.ts.map +1 -0
- package/dist/optimize/fold.js +103 -0
- package/dist/optimize/index.d.ts +10 -0
- package/dist/optimize/index.d.ts.map +1 -0
- package/dist/optimize/index.js +23 -0
- package/dist/optimize/map-node.d.ts +21 -0
- package/dist/optimize/map-node.d.ts.map +1 -0
- package/dist/optimize/map-node.js +222 -0
- package/dist/optimize/remap.d.ts +30 -0
- package/dist/optimize/remap.d.ts.map +1 -0
- package/dist/optimize/remap.js +46 -0
- package/dist/optimize/rewrite.d.ts +22 -0
- package/dist/optimize/rewrite.d.ts.map +1 -0
- package/dist/optimize/rewrite.js +34 -0
- package/dist/plan/cache.d.ts +20 -0
- package/dist/plan/cache.d.ts.map +1 -0
- package/dist/plan/cache.js +122 -0
- package/dist/plan/index.d.ts +8 -0
- package/dist/plan/index.d.ts.map +1 -0
- package/dist/plan/index.js +6 -0
- package/dist/plan/predicate.d.ts +27 -0
- package/dist/plan/predicate.d.ts.map +1 -0
- package/dist/plan/predicate.js +415 -0
- package/dist/plan/schema-predicate.d.ts +15 -0
- package/dist/plan/schema-predicate.d.ts.map +1 -0
- package/dist/plan/schema-predicate.js +277 -0
- package/dist/plan/types.d.ts +18 -0
- package/dist/plan/types.d.ts.map +1 -0
- package/dist/plan/types.js +5 -0
- package/dist/result/index.d.ts +27 -0
- package/dist/result/index.d.ts.map +1 -0
- package/dist/result/index.js +20 -0
- package/dist/schema/common.d.ts +30 -0
- package/dist/schema/common.d.ts.map +1 -0
- package/dist/schema/common.js +102 -0
- package/dist/schema/freeze.d.ts +10 -0
- package/dist/schema/freeze.d.ts.map +1 -0
- package/dist/schema/freeze.js +163 -0
- package/dist/schema/index.d.ts +11 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +9 -0
- package/dist/schema/lazy.d.ts +10 -0
- package/dist/schema/lazy.d.ts.map +1 -0
- package/dist/schema/lazy.js +25 -0
- package/dist/schema/literal.d.ts +10 -0
- package/dist/schema/literal.d.ts.map +1 -0
- package/dist/schema/literal.js +17 -0
- package/dist/schema/types.d.ts +243 -0
- package/dist/schema/types.d.ts.map +1 -0
- package/dist/schema/types.js +9 -0
- package/dist/schema/validate.d.ts +10 -0
- package/dist/schema/validate.d.ts.map +1 -0
- package/dist/schema/validate.js +268 -0
- package/docs/api.md +301 -0
- package/docs/engine-notes.md +153 -0
- package/docs/index.html +1242 -0
- package/package.json +68 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file check-composite.ts
|
|
3
|
+
* @brief Composite diagnostic schema interpreters.
|
|
4
|
+
*/
|
|
5
|
+
import { ObjectModeTag, PresenceTag, SchemaTag } from "../kind/index.js";
|
|
6
|
+
import { pushIssue } from "./issue.js";
|
|
7
|
+
import { actualType, findDiscriminatedUnionCase, hasObjectKey, isDataPropertyDescriptor, isPlainRecord, isStrictTrue, literalToExpected, readOwnDataProperty } from "./shared.js";
|
|
8
|
+
/**
|
|
9
|
+
* @brief collect array issues.
|
|
10
|
+
*/
|
|
11
|
+
export function collectArrayIssues(item, value, path, issues, state, collectChild) {
|
|
12
|
+
if (!Array.isArray(value)) {
|
|
13
|
+
pushIssue(path, issues, "expected_array", "array", actualType(value));
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
17
|
+
const itemProperty = readArrayIndexDataProperty(value, index);
|
|
18
|
+
path.push(index);
|
|
19
|
+
if (itemProperty === null) {
|
|
20
|
+
pushIssue(path, issues, "expected_array", "data property", "accessor");
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
collectChild(item, itemProperty === undefined ? undefined : itemProperty.value, path, issues, state);
|
|
24
|
+
}
|
|
25
|
+
path.pop();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @brief collect tuple issues.
|
|
30
|
+
*/
|
|
31
|
+
export function collectTupleIssues(items, value, path, issues, state, collectChild) {
|
|
32
|
+
if (!Array.isArray(value)) {
|
|
33
|
+
pushIssue(path, issues, "expected_tuple", "tuple", actualType(value));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (value.length !== items.length) {
|
|
37
|
+
pushIssue(path, issues, "expected_tuple_length", `length ${String(items.length)}`, `length ${String(value.length)}`);
|
|
38
|
+
}
|
|
39
|
+
const count = value.length < items.length ? value.length : items.length;
|
|
40
|
+
for (let index = 0; index < count; index += 1) {
|
|
41
|
+
const item = items[index];
|
|
42
|
+
if (item === undefined) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const itemValue = readArrayIndexDataProperty(value, index);
|
|
46
|
+
path.push(index);
|
|
47
|
+
if (itemValue === null) {
|
|
48
|
+
pushIssue(path, issues, "expected_tuple", "data property", "accessor");
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
collectChild(item, itemValue === undefined ? undefined : itemValue.value, path, issues, state);
|
|
52
|
+
}
|
|
53
|
+
path.pop();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* @brief read array index data property.
|
|
58
|
+
* @details Reads an array element through its descriptor so validation does not execute getters.
|
|
59
|
+
* @returns Data descriptor for elements, undefined for holes, and null for accessors.
|
|
60
|
+
*/
|
|
61
|
+
function readArrayIndexDataProperty(value, index) {
|
|
62
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, String(index));
|
|
63
|
+
if (descriptor === undefined) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
if (!isDataPropertyDescriptor(descriptor)) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
return descriptor;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @brief collect record issues.
|
|
73
|
+
*/
|
|
74
|
+
export function collectRecordIssues(item, value, path, issues, state, collectChild) {
|
|
75
|
+
if (!isPlainRecord(value)) {
|
|
76
|
+
pushIssue(path, issues, "expected_record", "record", actualType(value));
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const keys = Object.keys(value);
|
|
80
|
+
for (let index = 0; index < keys.length; index += 1) {
|
|
81
|
+
const key = keys[index];
|
|
82
|
+
if (key === undefined) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
const property = readOwnDataProperty(value, key);
|
|
86
|
+
path.push(key);
|
|
87
|
+
if (property === undefined) {
|
|
88
|
+
pushIssue(path, issues, "expected_record", "data property", "accessor or missing");
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
collectChild(item, property.value, path, issues, state);
|
|
92
|
+
}
|
|
93
|
+
path.pop();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* @brief collect object issues.
|
|
98
|
+
*/
|
|
99
|
+
export function collectObjectIssues(schema, value, path, issues, state, collectChild) {
|
|
100
|
+
if (!isPlainRecord(value)) {
|
|
101
|
+
pushIssue(path, issues, "expected_object", "object", actualType(value));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const record = value;
|
|
105
|
+
const entries = schema.entries;
|
|
106
|
+
for (let index = 0; index < entries.length; index += 1) {
|
|
107
|
+
const entry = entries[index];
|
|
108
|
+
if (entry === undefined) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const property = readOwnDataProperty(record, entry.key);
|
|
112
|
+
path.push(entry.key);
|
|
113
|
+
if (property === undefined) {
|
|
114
|
+
if (entry.presence === PresenceTag.Optional &&
|
|
115
|
+
!Object.prototype.hasOwnProperty.call(record, entry.key)) {
|
|
116
|
+
path.pop();
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
if (entry.presence === PresenceTag.Required) {
|
|
120
|
+
pushIssue(path, issues, "expected_required_key", "present key", "missing");
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
pushIssue(path, issues, "expected_object", "data property", "accessor");
|
|
124
|
+
}
|
|
125
|
+
path.pop();
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
collectChild(entry.schema, property.value, path, issues, state);
|
|
129
|
+
path.pop();
|
|
130
|
+
}
|
|
131
|
+
if (schema.mode === ObjectModeTag.Strict) {
|
|
132
|
+
const keys = Reflect.ownKeys(record);
|
|
133
|
+
for (let index = 0; index < keys.length; index += 1) {
|
|
134
|
+
const key = keys[index];
|
|
135
|
+
if (key !== undefined &&
|
|
136
|
+
(typeof key !== "string" || !hasObjectKey(schema.keyLookup, key))) {
|
|
137
|
+
path.push(typeof key === "string" ? key : String(key));
|
|
138
|
+
pushIssue(path, issues, "unrecognized_key", "known key", "extra key");
|
|
139
|
+
path.pop();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* @brief collect discriminated union issues.
|
|
146
|
+
*/
|
|
147
|
+
export function collectDiscriminatedUnionIssues(key, cases, value, path, issues, state, collectChild) {
|
|
148
|
+
if (!isPlainRecord(value)) {
|
|
149
|
+
pushIssue(path, issues, "expected_object", "object", actualType(value));
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const discriminantProperty = readOwnDataProperty(value, key);
|
|
153
|
+
if (discriminantProperty === undefined) {
|
|
154
|
+
path.push(key);
|
|
155
|
+
pushIssue(path, issues, "expected_discriminant", "data property", "missing or accessor");
|
|
156
|
+
path.pop();
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const discriminant = discriminantProperty.value;
|
|
160
|
+
if (typeof discriminant !== "string") {
|
|
161
|
+
path.push(key);
|
|
162
|
+
pushIssue(path, issues, "expected_discriminant", "string discriminant", actualType(discriminant));
|
|
163
|
+
path.pop();
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const selected = findDiscriminatedUnionCase(cases, discriminant);
|
|
167
|
+
if (selected === undefined) {
|
|
168
|
+
path.push(key);
|
|
169
|
+
pushIssue(path, issues, "expected_discriminant", "known discriminant", literalToExpected(discriminant));
|
|
170
|
+
path.pop();
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
collectChild(selected, value, path, issues, state);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* @brief collect refine issues.
|
|
177
|
+
*/
|
|
178
|
+
export function collectRefineIssues(inner, predicate, name, value, path, issues, state, collectChild) {
|
|
179
|
+
const before = issues.length;
|
|
180
|
+
collectChild(inner, value, path, issues, state);
|
|
181
|
+
if (issues.length === before && !isStrictTrue(predicate(value))) {
|
|
182
|
+
pushIssue(path, issues, "expected_refinement", name, actualType(value));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file check-scalar.ts
|
|
3
|
+
* @brief Scalar diagnostic schema interpreters.
|
|
4
|
+
*/
|
|
5
|
+
import { SchemaTag } from "../kind/index.js";
|
|
6
|
+
import type { Issue, PathSegment } from "../issue/index.js";
|
|
7
|
+
import { type Schema } from "../schema/index.js";
|
|
8
|
+
/**
|
|
9
|
+
* @brief collect string issues.
|
|
10
|
+
*/
|
|
11
|
+
export declare function collectStringIssues(schema: Extract<Schema, {
|
|
12
|
+
readonly tag: typeof SchemaTag.String;
|
|
13
|
+
}>, value: unknown, path: PathSegment[], issues: Issue[]): void;
|
|
14
|
+
/**
|
|
15
|
+
* @brief collect number issues.
|
|
16
|
+
*/
|
|
17
|
+
export declare function collectNumberIssues(schema: Extract<Schema, {
|
|
18
|
+
readonly tag: typeof SchemaTag.Number;
|
|
19
|
+
}>, value: unknown, path: PathSegment[], issues: Issue[]): void;
|
|
20
|
+
//# sourceMappingURL=check-scalar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-scalar.d.ts","sourceRoot":"","sources":["../../src/evaluate/check-scalar.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEL,SAAS,EAEV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAEL,KAAK,MAAM,EACZ,MAAM,oBAAoB,CAAC;AAI5B;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,OAAO,SAAS,CAAC,MAAM,CAAA;CAAE,CAAC,EAClE,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,WAAW,EAAE,EACnB,MAAM,EAAE,KAAK,EAAE,GACd,IAAI,CAgDN;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,GAAG,EAAE,OAAO,SAAS,CAAC,MAAM,CAAA;CAAE,CAAC,EAClE,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,WAAW,EAAE,EACnB,MAAM,EAAE,KAAK,EAAE,GACd,IAAI,CAyCN"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file check-scalar.ts
|
|
3
|
+
* @brief Scalar diagnostic schema interpreters.
|
|
4
|
+
*/
|
|
5
|
+
import { NumberCheckTag, SchemaTag, StringCheckTag } from "../kind/index.js";
|
|
6
|
+
import { UUID_PATTERN } from "../schema/index.js";
|
|
7
|
+
import { pushIssue } from "./issue.js";
|
|
8
|
+
import { actualType } from "./shared.js";
|
|
9
|
+
/**
|
|
10
|
+
* @brief collect string issues.
|
|
11
|
+
*/
|
|
12
|
+
export function collectStringIssues(schema, value, path, issues) {
|
|
13
|
+
if (typeof value !== "string") {
|
|
14
|
+
pushIssue(path, issues, "expected_string", "string", actualType(value));
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const checks = schema.checks;
|
|
18
|
+
for (let index = 0; index < checks.length; index += 1) {
|
|
19
|
+
const check = checks[index];
|
|
20
|
+
if (check === undefined) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
switch (check.tag) {
|
|
24
|
+
case StringCheckTag.Min:
|
|
25
|
+
if (value.length < check.value) {
|
|
26
|
+
pushIssue(path, issues, "expected_min_length", `length >= ${String(check.value)}`, `length ${String(value.length)}`);
|
|
27
|
+
}
|
|
28
|
+
break;
|
|
29
|
+
case StringCheckTag.Max:
|
|
30
|
+
if (value.length > check.value) {
|
|
31
|
+
pushIssue(path, issues, "expected_max_length", `length <= ${String(check.value)}`, `length ${String(value.length)}`);
|
|
32
|
+
}
|
|
33
|
+
break;
|
|
34
|
+
case StringCheckTag.Regex:
|
|
35
|
+
check.regex.lastIndex = 0;
|
|
36
|
+
if (!check.regex.test(value)) {
|
|
37
|
+
pushIssue(path, issues, "expected_pattern", check.name, "string");
|
|
38
|
+
}
|
|
39
|
+
break;
|
|
40
|
+
case StringCheckTag.Uuid:
|
|
41
|
+
UUID_PATTERN.lastIndex = 0;
|
|
42
|
+
if (!UUID_PATTERN.test(value)) {
|
|
43
|
+
pushIssue(path, issues, "expected_pattern", "uuid", "string");
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @brief collect number issues.
|
|
51
|
+
*/
|
|
52
|
+
export function collectNumberIssues(schema, value, path, issues) {
|
|
53
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
54
|
+
pushIssue(path, issues, "expected_number", "number", actualType(value));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const checks = schema.checks;
|
|
58
|
+
for (let index = 0; index < checks.length; index += 1) {
|
|
59
|
+
const check = checks[index];
|
|
60
|
+
if (check === undefined) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
switch (check.tag) {
|
|
64
|
+
case NumberCheckTag.Integer:
|
|
65
|
+
if (!Number.isInteger(value)) {
|
|
66
|
+
pushIssue(path, issues, "expected_integer", "integer", "number");
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
case NumberCheckTag.Gte:
|
|
70
|
+
if (value < check.value) {
|
|
71
|
+
pushIssue(path, issues, "expected_gte", `>= ${String(check.value)}`, String(value));
|
|
72
|
+
}
|
|
73
|
+
break;
|
|
74
|
+
case NumberCheckTag.Lte:
|
|
75
|
+
if (value > check.value) {
|
|
76
|
+
pushIssue(path, issues, "expected_lte", `<= ${String(check.value)}`, String(value));
|
|
77
|
+
}
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file check.ts
|
|
3
|
+
* @brief Diagnostic schema interpreter dispatcher.
|
|
4
|
+
*/
|
|
5
|
+
import type { CheckResult } from "../issue/index.js";
|
|
6
|
+
import { type Schema } from "../schema/index.js";
|
|
7
|
+
/**
|
|
8
|
+
* @brief check schema.
|
|
9
|
+
*/
|
|
10
|
+
export declare function checkSchema<TValue>(schema: Schema, value: unknown): CheckResult<TValue>;
|
|
11
|
+
//# sourceMappingURL=check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/evaluate/check.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAsB,MAAM,mBAAmB,CAAC;AAGzE,OAAO,EAEL,KAAK,MAAM,EACZ,MAAM,oBAAoB,CAAC;AA0B5B;;GAEG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAChC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,GACb,WAAW,CAAC,MAAM,CAAC,CAWrB"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file check.ts
|
|
3
|
+
* @brief Diagnostic schema interpreter dispatcher.
|
|
4
|
+
*/
|
|
5
|
+
import { SchemaTag } from "../kind/index.js";
|
|
6
|
+
import { freezeIssueArray } from "../issue/index.js";
|
|
7
|
+
import { err, ok } from "../result/index.js";
|
|
8
|
+
import { resolveLazySchema } from "../schema/index.js";
|
|
9
|
+
import { collectArrayIssues, collectDiscriminatedUnionIssues, collectObjectIssues, collectRecordIssues, collectRefineIssues, collectTupleIssues } from "./check-composite.js";
|
|
10
|
+
import { collectNumberIssues, collectStringIssues } from "./check-scalar.js";
|
|
11
|
+
import { pushIssue } from "./issue.js";
|
|
12
|
+
import { isSchemaWithState, isUnionSchema } from "./predicate.js";
|
|
13
|
+
import { actualType, literalToExpected } from "./shared.js";
|
|
14
|
+
import { enterValidation, leaveValidation, makeValidationState } from "./state.js";
|
|
15
|
+
/**
|
|
16
|
+
* @brief check schema.
|
|
17
|
+
*/
|
|
18
|
+
export function checkSchema(schema, value) {
|
|
19
|
+
if (isSchemaWithState(schema, value, makeValidationState())) {
|
|
20
|
+
return ok(value);
|
|
21
|
+
}
|
|
22
|
+
const issues = [];
|
|
23
|
+
const path = [];
|
|
24
|
+
collectIssues(schema, value, path, issues, makeValidationState());
|
|
25
|
+
if (issues.length === 0) {
|
|
26
|
+
pushIssue(path, issues, "expected_refinement", "matching schema", actualType(value));
|
|
27
|
+
}
|
|
28
|
+
return err(freezeIssueArray(issues));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @brief collect issues.
|
|
32
|
+
*/
|
|
33
|
+
function collectIssues(schema, value, path, issues, state) {
|
|
34
|
+
const entered = enterValidation(schema, value, state);
|
|
35
|
+
if (entered === "cycle") {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (entered === "budget") {
|
|
39
|
+
pushIssue(path, issues, "expected_depth_limit", `depth <= ${String(state.maxDepth)}`, "depth or work limit exceeded");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
collectIssuesInner(schema, value, path, issues, state);
|
|
43
|
+
leaveValidation(schema, value, state);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @brief collect issues inner.
|
|
47
|
+
*/
|
|
48
|
+
function collectIssuesInner(schema, value, path, issues, state) {
|
|
49
|
+
switch (schema.tag) {
|
|
50
|
+
case SchemaTag.Unknown:
|
|
51
|
+
return;
|
|
52
|
+
case SchemaTag.Never:
|
|
53
|
+
pushIssue(path, issues, "expected_never", "never", actualType(value));
|
|
54
|
+
return;
|
|
55
|
+
case SchemaTag.String:
|
|
56
|
+
collectStringIssues(schema, value, path, issues);
|
|
57
|
+
return;
|
|
58
|
+
case SchemaTag.Number:
|
|
59
|
+
collectNumberIssues(schema, value, path, issues);
|
|
60
|
+
return;
|
|
61
|
+
case SchemaTag.BigInt:
|
|
62
|
+
if (typeof value !== "bigint") {
|
|
63
|
+
pushIssue(path, issues, "expected_bigint", "bigint", actualType(value));
|
|
64
|
+
}
|
|
65
|
+
return;
|
|
66
|
+
case SchemaTag.Symbol:
|
|
67
|
+
if (typeof value !== "symbol") {
|
|
68
|
+
pushIssue(path, issues, "expected_symbol", "symbol", actualType(value));
|
|
69
|
+
}
|
|
70
|
+
return;
|
|
71
|
+
case SchemaTag.Boolean:
|
|
72
|
+
if (typeof value !== "boolean") {
|
|
73
|
+
pushIssue(path, issues, "expected_boolean", "boolean", actualType(value));
|
|
74
|
+
}
|
|
75
|
+
return;
|
|
76
|
+
case SchemaTag.Literal:
|
|
77
|
+
if (!Object.is(value, schema.value)) {
|
|
78
|
+
pushIssue(path, issues, "expected_literal", literalToExpected(schema.value), actualType(value));
|
|
79
|
+
}
|
|
80
|
+
return;
|
|
81
|
+
case SchemaTag.Array:
|
|
82
|
+
collectArrayIssues(schema.item, value, path, issues, state, collectIssues);
|
|
83
|
+
return;
|
|
84
|
+
case SchemaTag.Tuple:
|
|
85
|
+
collectTupleIssues(schema.items, value, path, issues, state, collectIssues);
|
|
86
|
+
return;
|
|
87
|
+
case SchemaTag.Record:
|
|
88
|
+
collectRecordIssues(schema.value, value, path, issues, state, collectIssues);
|
|
89
|
+
return;
|
|
90
|
+
case SchemaTag.Object:
|
|
91
|
+
collectObjectIssues(schema, value, path, issues, state, collectIssues);
|
|
92
|
+
return;
|
|
93
|
+
case SchemaTag.Union:
|
|
94
|
+
if (!isUnionSchema(schema.options, value, state)) {
|
|
95
|
+
pushIssue(path, issues, "expected_union", "union", actualType(value));
|
|
96
|
+
}
|
|
97
|
+
return;
|
|
98
|
+
case SchemaTag.Intersection:
|
|
99
|
+
collectIssues(schema.left, value, path, issues, state);
|
|
100
|
+
collectIssues(schema.right, value, path, issues, state);
|
|
101
|
+
return;
|
|
102
|
+
case SchemaTag.Optional:
|
|
103
|
+
case SchemaTag.Undefinedable:
|
|
104
|
+
if (value !== undefined) {
|
|
105
|
+
collectIssues(schema.inner, value, path, issues, state);
|
|
106
|
+
}
|
|
107
|
+
return;
|
|
108
|
+
case SchemaTag.Nullable:
|
|
109
|
+
if (value !== null) {
|
|
110
|
+
collectIssues(schema.inner, value, path, issues, state);
|
|
111
|
+
}
|
|
112
|
+
return;
|
|
113
|
+
case SchemaTag.DiscriminatedUnion:
|
|
114
|
+
collectDiscriminatedUnionIssues(schema.key, schema.cases, value, path, issues, state, collectIssues);
|
|
115
|
+
return;
|
|
116
|
+
case SchemaTag.Brand:
|
|
117
|
+
collectIssues(schema.inner, value, path, issues, state);
|
|
118
|
+
return;
|
|
119
|
+
case SchemaTag.Lazy:
|
|
120
|
+
collectIssues(resolveLazySchema(schema, state.resolving), value, path, issues, state);
|
|
121
|
+
return;
|
|
122
|
+
case SchemaTag.Refine:
|
|
123
|
+
collectRefineIssues(schema.inner, schema.predicate, schema.name, value, path, issues, state, collectIssues);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/evaluate/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file issue.ts
|
|
3
|
+
* @brief Runtime validation issue construction.
|
|
4
|
+
*/
|
|
5
|
+
import type { Issue, PathSegment } from "../issue/index.js";
|
|
6
|
+
/**
|
|
7
|
+
* @brief push issue.
|
|
8
|
+
*/
|
|
9
|
+
export declare function pushIssue(path: PathSegment[], issues: Issue[], code: Issue["code"], expected: string | undefined, actual: string | undefined): void;
|
|
10
|
+
//# sourceMappingURL=issue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issue.d.ts","sourceRoot":"","sources":["../../src/evaluate/issue.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG5D;;GAEG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,WAAW,EAAE,EACnB,MAAM,EAAE,KAAK,EAAE,EACf,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EACnB,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB,IAAI,CAEN"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file issue.ts
|
|
3
|
+
* @brief Runtime validation issue construction.
|
|
4
|
+
*/
|
|
5
|
+
import { makeIssue } from "../issue/index.js";
|
|
6
|
+
/**
|
|
7
|
+
* @brief push issue.
|
|
8
|
+
*/
|
|
9
|
+
export function pushIssue(path, issues, code, expected, actual) {
|
|
10
|
+
issues.push(makeIssue(path.slice(), code, expected, actual, undefined));
|
|
11
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file predicate.ts
|
|
3
|
+
* @brief Compatibility entry points for IR-backed predicate execution.
|
|
4
|
+
*/
|
|
5
|
+
import type { Schema } from "../schema/index.js";
|
|
6
|
+
import type { ValidationState } from "./state.js";
|
|
7
|
+
/**
|
|
8
|
+
* @brief is schema.
|
|
9
|
+
* @details Executes the schema through its optimized Sea-of-Nodes validation plan.
|
|
10
|
+
* @returns True when the input satisfies the schema.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isSchema(schema: Schema, value: unknown): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* @brief is schema with state.
|
|
15
|
+
* @details Shares recursion and cycle tracking with nested IR nodes.
|
|
16
|
+
* @returns True when the input satisfies the schema under the borrowed state.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isSchemaWithState(schema: Schema, value: unknown, state: ValidationState): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* @brief is union schema.
|
|
21
|
+
* @details Preserves the historical helper used by diagnostic generation while
|
|
22
|
+
* routing each union option through IR-backed validation.
|
|
23
|
+
* @returns True when at least one option accepts the value.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isUnionSchema(options: readonly Schema[], value: unknown, state: ValidationState): boolean;
|
|
26
|
+
//# sourceMappingURL=predicate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"predicate.d.ts","sourceRoot":"","sources":["../../src/evaluate/predicate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,eAAe,GACrB,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,eAAe,GACrB,OAAO,CAST"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file predicate.ts
|
|
3
|
+
* @brief Compatibility entry points for IR-backed predicate execution.
|
|
4
|
+
*/
|
|
5
|
+
import { executeSchemaPredicate, executeSchemaPredicateWithState } from "../plan/index.js";
|
|
6
|
+
/**
|
|
7
|
+
* @brief is schema.
|
|
8
|
+
* @details Executes the schema through its optimized Sea-of-Nodes validation plan.
|
|
9
|
+
* @returns True when the input satisfies the schema.
|
|
10
|
+
*/
|
|
11
|
+
export function isSchema(schema, value) {
|
|
12
|
+
return executeSchemaPredicate(schema, value);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @brief is schema with state.
|
|
16
|
+
* @details Shares recursion and cycle tracking with nested IR nodes.
|
|
17
|
+
* @returns True when the input satisfies the schema under the borrowed state.
|
|
18
|
+
*/
|
|
19
|
+
export function isSchemaWithState(schema, value, state) {
|
|
20
|
+
return executeSchemaPredicateWithState(schema, value, state);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @brief is union schema.
|
|
24
|
+
* @details Preserves the historical helper used by diagnostic generation while
|
|
25
|
+
* routing each union option through IR-backed validation.
|
|
26
|
+
* @returns True when at least one option accepts the value.
|
|
27
|
+
*/
|
|
28
|
+
export function isUnionSchema(options, value, state) {
|
|
29
|
+
for (let index = 0; index < options.length; index += 1) {
|
|
30
|
+
const option = options[index];
|
|
31
|
+
if (option !== undefined &&
|
|
32
|
+
executeSchemaPredicateWithState(option, value, state)) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file shared.ts
|
|
3
|
+
* @brief Shared scalar helpers for schema evaluation.
|
|
4
|
+
*/
|
|
5
|
+
import type { DiscriminatedUnionCase, LiteralValue, ObjectKeyLookup, Schema } from "../schema/index.js";
|
|
6
|
+
/**
|
|
7
|
+
* @brief unknown record.
|
|
8
|
+
*/
|
|
9
|
+
export type UnknownRecord = Readonly<Record<string, unknown>>;
|
|
10
|
+
/**
|
|
11
|
+
* @brief data property descriptor.
|
|
12
|
+
* @details Defines the subset of descriptors whose value is stable for one validation read.
|
|
13
|
+
* @invariant Accessor descriptors never match this contract.
|
|
14
|
+
*/
|
|
15
|
+
export interface DataPropertyDescriptor {
|
|
16
|
+
/**
|
|
17
|
+
* @brief value.
|
|
18
|
+
* @details The captured data slot is unknown until the schema-specific validator consumes it.
|
|
19
|
+
* @invariant Accessing this field does not execute user getter code.
|
|
20
|
+
*/
|
|
21
|
+
readonly value: unknown;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @brief has object key.
|
|
25
|
+
*/
|
|
26
|
+
export declare function hasObjectKey(keyLookup: ObjectKeyLookup, key: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* @brief read own data property.
|
|
29
|
+
* @details Reads one own property through its descriptor so getters are not executed.
|
|
30
|
+
* @returns Own data descriptor, or undefined for missing/accessor properties.
|
|
31
|
+
*/
|
|
32
|
+
export declare function readOwnDataProperty(record: UnknownRecord, key: string): DataPropertyDescriptor | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* @brief find discriminated union case.
|
|
35
|
+
*/
|
|
36
|
+
export declare function findDiscriminatedUnionCase(cases: readonly DiscriminatedUnionCase[], value: string): Schema | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* @brief is strict true.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isStrictTrue(value: unknown): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* @brief is plain record.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isPlainRecord(value: unknown): value is UnknownRecord;
|
|
45
|
+
/**
|
|
46
|
+
* @brief is data property descriptor.
|
|
47
|
+
* @details Checks that a descriptor contains a data value instead of getter/setter code.
|
|
48
|
+
* @returns True when the descriptor has a stable value slot.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isDataPropertyDescriptor(descriptor: PropertyDescriptor): descriptor is DataPropertyDescriptor;
|
|
51
|
+
/**
|
|
52
|
+
* @brief actual type.
|
|
53
|
+
*/
|
|
54
|
+
export declare function actualType(value: unknown): string;
|
|
55
|
+
/**
|
|
56
|
+
* @brief literal to expected.
|
|
57
|
+
*/
|
|
58
|
+
export declare function literalToExpected(value: LiteralValue): string;
|
|
59
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/evaluate/shared.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACV,sBAAsB,EACtB,YAAY,EACZ,eAAe,EACf,MAAM,EACP,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAE9D;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IAErC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAE7E;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,MAAM,GACV,sBAAsB,GAAG,SAAS,CAMpC;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,SAAS,sBAAsB,EAAE,EACxC,KAAK,EAAE,MAAM,GACZ,MAAM,GAAG,SAAS,CAQpB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEpD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEpE;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,kBAAkB,GAC7B,UAAU,IAAI,sBAAsB,CAEtC;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAiBjD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAiB7D"}
|