@featurevisor/core 4.12.0 → 4.14.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/lib/builder/applyContextToDatafile.js +21 -1
- package/lib/builder/applyContextToDatafile.js.map +1 -1
- package/lib/builder/buildDatafile.d.ts +15 -1
- package/lib/builder/buildDatafile.js +48 -13
- package/lib/builder/buildDatafile.js.map +1 -1
- package/lib/builder/buildProject.js +9 -0
- package/lib/builder/buildProject.js.map +1 -1
- package/lib/builder/environments.d.ts +1 -2
- package/lib/builder/hashes.d.ts +9 -0
- package/lib/builder/hashes.js +16 -0
- package/lib/builder/hashes.js.map +1 -1
- package/lib/builder/schemas.d.ts +76 -0
- package/lib/builder/schemas.js +406 -0
- package/lib/builder/schemas.js.map +1 -0
- package/lib/catalog.d.ts +2 -0
- package/lib/catalog.js +3 -0
- package/lib/catalog.js.map +1 -1
- package/lib/cli/options.js +31 -4
- package/lib/cli/options.js.map +1 -1
- package/lib/config/allowedConditions.d.ts +6 -3
- package/lib/config/allowedConditions.js +9 -2
- package/lib/config/allowedConditions.js.map +1 -1
- package/lib/convert/check.js +5 -1
- package/lib/convert/check.js.map +1 -1
- package/lib/convert/plan.js +8 -2
- package/lib/convert/plan.js.map +1 -1
- package/lib/datasource/conditionLocations.d.ts +1 -1
- package/lib/datasource/conditionLocations.js +26 -0
- package/lib/datasource/conditionLocations.js.map +1 -1
- package/lib/datasource/datasource.d.ts +2 -0
- package/lib/datasource/datasource.js +5 -3
- package/lib/datasource/datasource.js.map +1 -1
- package/lib/datasource/expressions.d.ts +1 -1
- package/lib/datasource/testSpecs.js +3 -3
- package/lib/datasource/testSpecs.js.map +1 -1
- package/lib/diff/conditions.js +1 -1
- package/lib/diff/conditions.js.map +1 -1
- package/lib/diff/index.js +68 -1
- package/lib/diff/index.js.map +1 -1
- package/lib/diff/schemaWidening.d.ts +15 -0
- package/lib/diff/schemaWidening.js +275 -0
- package/lib/diff/schemaWidening.js.map +1 -0
- package/lib/find-usage/index.d.ts +16 -2
- package/lib/find-usage/index.js +114 -10
- package/lib/find-usage/index.js.map +1 -1
- package/lib/formatter/expressions.js +5 -2
- package/lib/formatter/expressions.js.map +1 -1
- package/lib/formatter/layout.d.ts +3 -2
- package/lib/formatter/layout.js +23 -4
- package/lib/formatter/layout.js.map +1 -1
- package/lib/formatter/style.d.ts +20 -2
- package/lib/formatter/style.js +49 -4
- package/lib/formatter/style.js.map +1 -1
- package/lib/generate-code/index.d.ts +4 -0
- package/lib/generate-code/index.js +10 -0
- package/lib/generate-code/index.js.map +1 -1
- package/lib/generate-code/typescript.d.ts +5 -0
- package/lib/generate-code/typescript.js +265 -25
- package/lib/generate-code/typescript.js.map +1 -1
- package/lib/generate-code/widenMutations.d.ts +9 -0
- package/lib/generate-code/widenMutations.js +134 -0
- package/lib/generate-code/widenMutations.js.map +1 -0
- package/lib/linter/composedOverrideSchema.js +3 -0
- package/lib/linter/composedOverrideSchema.js.map +1 -1
- package/lib/linter/conditionKinds.d.ts +1 -1
- package/lib/linter/conditionKinds.js +4 -0
- package/lib/linter/conditionKinds.js.map +1 -1
- package/lib/linter/conditionSchema.d.ts +21 -1
- package/lib/linter/conditionSchema.js +261 -135
- package/lib/linter/conditionSchema.js.map +1 -1
- package/lib/linter/contextWarnings.js +2 -0
- package/lib/linter/contextWarnings.js.map +1 -1
- package/lib/linter/diagnostics.d.ts +10 -3
- package/lib/linter/diagnostics.js +16 -2
- package/lib/linter/diagnostics.js.map +1 -1
- package/lib/linter/expressionDiagnostics.js +2 -2
- package/lib/linter/expressionDiagnostics.js.map +1 -1
- package/lib/linter/featureSchema.d.ts +10 -9
- package/lib/linter/featureSchema.js +60 -158
- package/lib/linter/featureSchema.js.map +1 -1
- package/lib/linter/lintProject.js +229 -2
- package/lib/linter/lintProject.js.map +1 -1
- package/lib/linter/messageWarnings.d.ts +16 -0
- package/lib/linter/messageWarnings.js +181 -0
- package/lib/linter/messageWarnings.js.map +1 -0
- package/lib/linter/regexSafety.d.ts +17 -2
- package/lib/linter/regexSafety.js +257 -13
- package/lib/linter/regexSafety.js.map +1 -1
- package/lib/linter/reservedNames.d.ts +21 -0
- package/lib/linter/reservedNames.js +79 -0
- package/lib/linter/reservedNames.js.map +1 -1
- package/lib/linter/schema.d.ts +45 -3
- package/lib/linter/schema.js +341 -35
- package/lib/linter/schema.js.map +1 -1
- package/lib/linter/schemaAnnotations.d.ts +34 -0
- package/lib/linter/schemaAnnotations.js +409 -0
- package/lib/linter/schemaAnnotations.js.map +1 -0
- package/lib/linter/schemaEngine.d.ts +7 -0
- package/lib/linter/schemaEngine.js +80 -0
- package/lib/linter/schemaEngine.js.map +1 -0
- package/lib/linter/schemaFormats.d.ts +6 -0
- package/lib/linter/schemaFormats.js +20 -0
- package/lib/linter/schemaFormats.js.map +1 -1
- package/lib/linter/schemaMutations.d.ts +38 -0
- package/lib/linter/schemaMutations.js +617 -0
- package/lib/linter/schemaMutations.js.map +1 -0
- package/lib/linter/schemaPatterns.d.ts +26 -0
- package/lib/linter/schemaPatterns.js +316 -0
- package/lib/linter/schemaPatterns.js.map +1 -0
- package/lib/linter/schemaReferences.d.ts +18 -0
- package/lib/linter/schemaReferences.js +43 -0
- package/lib/linter/schemaReferences.js.map +1 -0
- package/lib/linter/targetSchema.d.ts +3 -0
- package/lib/linter/targetSchema.js +3 -0
- package/lib/linter/targetSchema.js.map +1 -1
- package/lib/linter/testSchema.d.ts +1 -1
- package/lib/linter/testSchema.js +70 -11
- package/lib/linter/testSchema.js.map +1 -1
- package/lib/linter/variableSchema.d.ts +5 -5
- package/lib/linter/variableSchema.js +5 -5
- package/lib/linter/variableSchema.js.map +1 -1
- package/lib/linter/warningCodes.d.ts +1 -1
- package/lib/linter/warningCodes.js +4 -0
- package/lib/linter/warningCodes.js.map +1 -1
- package/lib/list/index.js +45 -4
- package/lib/list/index.js.map +1 -1
- package/lib/list/matrix.d.ts +6 -1
- package/lib/list/matrix.js +31 -0
- package/lib/list/matrix.js.map +1 -1
- package/lib/promoter/index.js +15 -0
- package/lib/promoter/index.js.map +1 -1
- package/lib/rewrite/conditions.d.ts +2 -1
- package/lib/rewrite/conditions.js +1 -0
- package/lib/rewrite/conditions.js.map +1 -1
- package/lib/schemaNodes.d.ts +50 -0
- package/lib/schemaNodes.js +146 -0
- package/lib/schemaNodes.js.map +1 -0
- package/lib/targeting.d.ts +28 -1
- package/lib/targeting.js +111 -0
- package/lib/targeting.js.map +1 -1
- package/lib/tester/segments.d.ts +3 -0
- package/lib/tester/testProject.d.ts +1 -1
- package/lib/tester/testProject.js +16 -3
- package/lib/tester/testProject.js.map +1 -1
- package/lib/tester/testSchema.d.ts +9 -0
- package/lib/tester/testSchema.js +130 -0
- package/lib/tester/testSchema.js.map +1 -0
- package/package.json +7 -6
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Schema } from "@featurevisor/types";
|
|
2
|
+
type Path = (string | number)[];
|
|
3
|
+
export interface AnnotationFinding {
|
|
4
|
+
path: Path;
|
|
5
|
+
message: string;
|
|
6
|
+
/** A `default` its field's own rules reject, which mutation lint words its own way. */
|
|
7
|
+
failingDefault?: true;
|
|
8
|
+
}
|
|
9
|
+
export interface AnnotationFindings {
|
|
10
|
+
errors: AnnotationFinding[];
|
|
11
|
+
/** Choices of one field where some have a `title` and others do not, `option_without_title`. */
|
|
12
|
+
warnings: AnnotationFinding[];
|
|
13
|
+
}
|
|
14
|
+
/** Annotations Featurevisor uses itself, which no vocabulary can declare. */
|
|
15
|
+
export declare const FIELD_BUILT_INS: readonly string[];
|
|
16
|
+
/** What every choice can carry, `title`, and the name `options` gives the choice's own value. */
|
|
17
|
+
export declare const OPTION_BUILT_INS: readonly string[];
|
|
18
|
+
/**
|
|
19
|
+
* The built in names each schema that files reference as a vocabulary may
|
|
20
|
+
* require without listing them, by key: those of annotations for an
|
|
21
|
+
* `annotationsSchema`, those of a choice for an `optionSchema`, through any
|
|
22
|
+
* chain of references. A vocabulary written inline is read where it sits.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getVocabularyBuiltIns(schemasByKey: Record<string, Schema>): Record<string, readonly string[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Checks a schema file's annotations against its vocabularies and the built in
|
|
27
|
+
* annotations: `annotationsSchema` for fields and objects, `optionSchema` for
|
|
28
|
+
* choices, `default` and `examples` against the field's own rules, `order` against its
|
|
29
|
+
* fields, and the keys of `options` against its `enum`. It warns when some of
|
|
30
|
+
* a field's choices have a `title` and others do not. Referenced schemas are
|
|
31
|
+
* checked in their own files, with their own vocabularies.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getSchemaAnnotationFindings(root: unknown, schemas: Record<string, Schema>): AnnotationFindings;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OPTION_BUILT_INS = exports.FIELD_BUILT_INS = void 0;
|
|
4
|
+
exports.getVocabularyBuiltIns = getVocabularyBuiltIns;
|
|
5
|
+
exports.getSchemaAnnotationFindings = getSchemaAnnotationFindings;
|
|
6
|
+
const schemaNodes_1 = require("../schemaNodes");
|
|
7
|
+
const featureSchema_1 = require("./featureSchema");
|
|
8
|
+
/** Annotations Featurevisor uses itself, which no vocabulary can declare. */
|
|
9
|
+
exports.FIELD_BUILT_INS = [
|
|
10
|
+
"title",
|
|
11
|
+
"default",
|
|
12
|
+
"examples",
|
|
13
|
+
"order",
|
|
14
|
+
"options",
|
|
15
|
+
];
|
|
16
|
+
/** What every choice can carry, `title`, and the name `options` gives the choice's own value. */
|
|
17
|
+
exports.OPTION_BUILT_INS = ["title", "value"];
|
|
18
|
+
/**
|
|
19
|
+
* The built in names each schema that files reference as a vocabulary may
|
|
20
|
+
* require without listing them, by key: those of annotations for an
|
|
21
|
+
* `annotationsSchema`, those of a choice for an `optionSchema`, through any
|
|
22
|
+
* chain of references. A vocabulary written inline is read where it sits.
|
|
23
|
+
*/
|
|
24
|
+
function getVocabularyBuiltIns(schemasByKey) {
|
|
25
|
+
const found = {};
|
|
26
|
+
const add = (vocabulary, names) => {
|
|
27
|
+
const seen = new Set();
|
|
28
|
+
let current = vocabulary;
|
|
29
|
+
while ((0, schemaNodes_1.isSchemaNode)(current) && typeof current.schema === "string") {
|
|
30
|
+
const key = current.schema;
|
|
31
|
+
if (seen.has(key))
|
|
32
|
+
break;
|
|
33
|
+
seen.add(key);
|
|
34
|
+
found[key] = found[key] || new Set();
|
|
35
|
+
names.forEach((name) => found[key].add(name));
|
|
36
|
+
current = (0, schemaNodes_1.hasOwn)(schemasByKey, key) ? schemasByKey[key] : undefined;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const visit = (node) => {
|
|
40
|
+
if (!(0, schemaNodes_1.isSchemaNode)(node))
|
|
41
|
+
return;
|
|
42
|
+
add(node.optionSchema, exports.OPTION_BUILT_INS);
|
|
43
|
+
(0, schemaNodes_1.forEachSchemaChild)(node, visit);
|
|
44
|
+
};
|
|
45
|
+
for (const schema of Object.values(schemasByKey)) {
|
|
46
|
+
if (!(0, schemaNodes_1.isSchemaNode)(schema))
|
|
47
|
+
continue;
|
|
48
|
+
add(schema.annotationsSchema, exports.FIELD_BUILT_INS);
|
|
49
|
+
visit(schema);
|
|
50
|
+
}
|
|
51
|
+
return Object.fromEntries(Object.entries(found).map(([key, names]) => [key, [...names]]));
|
|
52
|
+
}
|
|
53
|
+
/** How a value is shown in a message, and how a choice's value is written as a key of `options`: itself for text, its JSON text otherwise. */
|
|
54
|
+
function show(value) {
|
|
55
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Checks a schema file's annotations against its vocabularies and the built in
|
|
59
|
+
* annotations: `annotationsSchema` for fields and objects, `optionSchema` for
|
|
60
|
+
* choices, `default` and `examples` against the field's own rules, `order` against its
|
|
61
|
+
* fields, and the keys of `options` against its `enum`. It warns when some of
|
|
62
|
+
* a field's choices have a `title` and others do not. Referenced schemas are
|
|
63
|
+
* checked in their own files, with their own vocabularies.
|
|
64
|
+
*/
|
|
65
|
+
function getSchemaAnnotationFindings(root, schemas) {
|
|
66
|
+
const errors = [];
|
|
67
|
+
const warnings = [];
|
|
68
|
+
if (!(0, schemaNodes_1.isSchemaNode)(root))
|
|
69
|
+
return { errors, warnings };
|
|
70
|
+
const vocabulary = (owner, at, field, reserved) => {
|
|
71
|
+
const given = owner[field];
|
|
72
|
+
if (given === undefined)
|
|
73
|
+
return undefined;
|
|
74
|
+
const resolved = (0, schemaNodes_1.resolveSchemaNode)(given, schemas);
|
|
75
|
+
if (!resolved || resolved.type !== "object") {
|
|
76
|
+
errors.push({
|
|
77
|
+
path: [...at, field],
|
|
78
|
+
message: `\`${field}\` must be an object schema, whose properties are the names ${field === "annotationsSchema" ? "annotations" : "a choice"} can have.`,
|
|
79
|
+
});
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
const properties = (0, schemaNodes_1.isSchemaNode)(resolved.properties) ? resolved.properties : {};
|
|
83
|
+
for (const name of reserved) {
|
|
84
|
+
if (!(0, schemaNodes_1.hasOwn)(properties, name))
|
|
85
|
+
continue;
|
|
86
|
+
errors.push({
|
|
87
|
+
// A vocabulary written inline is reported where the name is, and a referenced one at the reference.
|
|
88
|
+
path: (0, schemaNodes_1.isSchemaNode)(given) && given.schema === undefined
|
|
89
|
+
? [...at, field, "properties", name]
|
|
90
|
+
: [...at, field],
|
|
91
|
+
message: name === "value"
|
|
92
|
+
? "`value` holds each choice's own value, so `optionSchema` cannot declare it."
|
|
93
|
+
: `\`${name}\` is built in, so \`${field}\` cannot declare it.`,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
return resolved;
|
|
97
|
+
};
|
|
98
|
+
const fieldVocabulary = vocabulary(root, [], "annotationsSchema", exports.FIELD_BUILT_INS);
|
|
99
|
+
/** One name a vocabulary declares, checked against its rules. */
|
|
100
|
+
const checkNamed = (vocab, field, name, value, path) => {
|
|
101
|
+
const what = field === "annotationsSchema" ? "annotation" : "choice field";
|
|
102
|
+
if (!vocab) {
|
|
103
|
+
errors.push({
|
|
104
|
+
path,
|
|
105
|
+
message: `\`${name}\` is not a built in ${what}, and ${field === "optionSchema" ? "its list" : "this schema"} has no \`${field}\` to declare it.`,
|
|
106
|
+
});
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const properties = (0, schemaNodes_1.isSchemaNode)(vocab.properties) ? vocab.properties : {};
|
|
110
|
+
const rule = (0, schemaNodes_1.hasOwn)(properties, name) ? properties[name] : vocab.additionalProperties;
|
|
111
|
+
if (rule === undefined) {
|
|
112
|
+
const known = Object.keys(properties);
|
|
113
|
+
errors.push({
|
|
114
|
+
path,
|
|
115
|
+
message: `Unknown ${what} \`${name}\`. \`${field}\` declares ${known.length > 0 ? known.map((key) => `\`${key}\``).join(", ") : "none"}.`,
|
|
116
|
+
});
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (rule !== true && !(0, featureSchema_1.valueMatchesSchema)(rule, value, schemas)) {
|
|
120
|
+
errors.push({
|
|
121
|
+
path,
|
|
122
|
+
message: `\`${name}\` does not match what \`${field}\` declares for it.`,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
const checkTitle = (value, path) => {
|
|
127
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
128
|
+
errors.push({ path, message: "`title` must be text." });
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
/** A choice's own annotations: its `title` and what the `optionSchema` of its list declares. */
|
|
132
|
+
const checkChoice = (entry, path, optionVocabulary) => {
|
|
133
|
+
for (const [name, value] of Object.entries(entry)) {
|
|
134
|
+
if (name === "title")
|
|
135
|
+
checkTitle(value, [...path, name]);
|
|
136
|
+
else if (name === "value") {
|
|
137
|
+
errors.push({
|
|
138
|
+
path: [...path, name],
|
|
139
|
+
message: "`value` is the choice's own value, so a choice cannot set it.",
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
else
|
|
143
|
+
checkNamed(optionVocabulary, "optionSchema", name, value, [...path, name]);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
/** Warns when some choices have a `title` and others do not. */
|
|
147
|
+
const checkTitles = (choices, path) => {
|
|
148
|
+
const untitled = choices.filter((choice) => !((0, schemaNodes_1.isSchemaNode)(choice.entry) && typeof choice.entry.title === "string"));
|
|
149
|
+
if (untitled.length === 0 || untitled.length === choices.length)
|
|
150
|
+
return;
|
|
151
|
+
warnings.push({
|
|
152
|
+
path,
|
|
153
|
+
message: `Some choices have a \`title\` and ${untitled.map((choice) => show(choice.value)).join(", ")} ${untitled.length === 1 ? "has" : "have"} none, so a list would show titles beside raw values. Give every choice a title, or none.`,
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
const checkDefault = (node, value, at) => {
|
|
157
|
+
if (!(0, featureSchema_1.valueMatchesSchema)(node, value, schemas)) {
|
|
158
|
+
errors.push({
|
|
159
|
+
path: at,
|
|
160
|
+
message: `Default ${show(value)} does not pass the field's own rules.`,
|
|
161
|
+
failingDefault: true,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
const checkExamples = (node, value, at) => {
|
|
166
|
+
if (!Array.isArray(value)) {
|
|
167
|
+
errors.push({ path: at, message: "`examples` must be a list of values." });
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
value.forEach((example, index) => {
|
|
171
|
+
if (!(0, featureSchema_1.valueMatchesSchema)(node, example, schemas)) {
|
|
172
|
+
errors.push({
|
|
173
|
+
path: [...at, index],
|
|
174
|
+
message: `Example ${show(example)} does not pass the field's own rules.`,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
const checkOrder = (node, value, at) => {
|
|
180
|
+
const object = (0, schemaNodes_1.resolveSchemaNode)(node, schemas);
|
|
181
|
+
const properties = object && (0, schemaNodes_1.isSchemaNode)(object.properties) ? object.properties : undefined;
|
|
182
|
+
if (!properties) {
|
|
183
|
+
errors.push({
|
|
184
|
+
path: at,
|
|
185
|
+
message: "`order` lists an object's fields, and this node has no `properties`.",
|
|
186
|
+
});
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (!Array.isArray(value)) {
|
|
190
|
+
errors.push({ path: at, message: "`order` must be a list of field names." });
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const seen = new Set();
|
|
194
|
+
value.forEach((field, index) => {
|
|
195
|
+
if (typeof field !== "string" || !(0, schemaNodes_1.hasOwn)(properties, field)) {
|
|
196
|
+
errors.push({
|
|
197
|
+
path: [...at, index],
|
|
198
|
+
message: `\`order\` names ${show(field)}, which is not a field here. Fields: ${Object.keys(properties).join(", ")}.`,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
else if (seen.has(field)) {
|
|
202
|
+
errors.push({ path: [...at, index], message: `\`order\` names ${field} twice.` });
|
|
203
|
+
}
|
|
204
|
+
seen.add(field);
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
const checkOptions = (node, value, at, optionVocabulary) => {
|
|
208
|
+
if (!Array.isArray(node.enum)) {
|
|
209
|
+
errors.push({
|
|
210
|
+
path: at,
|
|
211
|
+
message: "`options` goes beside an `enum`, keyed by its values. A `oneOf` of consts gives each choice its annotations in its own branch.",
|
|
212
|
+
});
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (!(0, schemaNodes_1.isSchemaNode)(value)) {
|
|
216
|
+
errors.push({
|
|
217
|
+
path: at,
|
|
218
|
+
message: "`options` must be a map from each choice's value to what it carries.",
|
|
219
|
+
});
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
const values = node.enum;
|
|
223
|
+
const named = new Map();
|
|
224
|
+
for (const choice of values) {
|
|
225
|
+
const key = show(choice);
|
|
226
|
+
named.set(key, [...(named.get(key) || []), choice]);
|
|
227
|
+
}
|
|
228
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
229
|
+
const choices = named.get(key);
|
|
230
|
+
if (!choices) {
|
|
231
|
+
errors.push({
|
|
232
|
+
path: [...at, key],
|
|
233
|
+
message: `${key} is not one of the \`enum\`'s values: ${values.map(show).join(", ")}.`,
|
|
234
|
+
});
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
if (choices.length > 1) {
|
|
238
|
+
errors.push({
|
|
239
|
+
path: [...at, key],
|
|
240
|
+
message: `${key} names ${choices.map((choice) => JSON.stringify(choice)).join(" and ")} at once, so it cannot say which.`,
|
|
241
|
+
});
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (!(0, schemaNodes_1.isSchemaNode)(entry)) {
|
|
245
|
+
errors.push({
|
|
246
|
+
path: [...at, key],
|
|
247
|
+
message: "A choice's entry must be a map, such as `{ title: ... }`.",
|
|
248
|
+
});
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
checkChoice(entry, [...at, key], optionVocabulary);
|
|
252
|
+
}
|
|
253
|
+
checkTitles(values.map((choice) => ({
|
|
254
|
+
value: choice,
|
|
255
|
+
entry: (0, schemaNodes_1.hasOwn)(value, show(choice)) ? value[show(choice)] : undefined,
|
|
256
|
+
})), at);
|
|
257
|
+
};
|
|
258
|
+
/** A field's or an object's own annotations, with the `optionSchema` its `options` follow. */
|
|
259
|
+
const checkField = (node, annotations, path, optionVocabulary) => {
|
|
260
|
+
for (const [name, value] of Object.entries(annotations)) {
|
|
261
|
+
const at = [...path, name];
|
|
262
|
+
if (name === "title")
|
|
263
|
+
checkTitle(value, at);
|
|
264
|
+
else if (name === "default")
|
|
265
|
+
checkDefault(node, value, at);
|
|
266
|
+
else if (name === "examples")
|
|
267
|
+
checkExamples(node, value, at);
|
|
268
|
+
else if (name === "order")
|
|
269
|
+
checkOrder(node, value, at);
|
|
270
|
+
else if (name === "options")
|
|
271
|
+
checkOptions(node, value, at, optionVocabulary);
|
|
272
|
+
else
|
|
273
|
+
checkNamed(fieldVocabulary, "annotationsSchema", name, value, at);
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
/** The names a vocabulary lists in `required`, which every node or choice it covers must carry. */
|
|
277
|
+
const requiredOf = (vocab) => vocab && Array.isArray(vocab.required)
|
|
278
|
+
? vocab.required.filter((name) => typeof name === "string")
|
|
279
|
+
: [];
|
|
280
|
+
const requiredAnnotations = requiredOf(fieldVocabulary);
|
|
281
|
+
/** The annotation names a node carries, its own and, beside a reference, the referenced schema's. */
|
|
282
|
+
const carried = (node, seen = new Set()) => {
|
|
283
|
+
const names = new Set((0, schemaNodes_1.isSchemaNode)(node.annotations) ? Object.keys(node.annotations) : []);
|
|
284
|
+
if (typeof node.schema === "string" && !seen.has(node.schema)) {
|
|
285
|
+
seen.add(node.schema);
|
|
286
|
+
const referenced = schemas[node.schema];
|
|
287
|
+
if ((0, schemaNodes_1.isSchemaNode)(referenced))
|
|
288
|
+
for (const name of carried(referenced, seen))
|
|
289
|
+
names.add(name);
|
|
290
|
+
}
|
|
291
|
+
return names;
|
|
292
|
+
};
|
|
293
|
+
const requires = (field, missing) => `\`${field}\` requires ${missing.map((name) => `\`${name}\``).join(" and ")}`;
|
|
294
|
+
/**
|
|
295
|
+
* Walks the file. `reachable` is whether a handle can reach the node, as
|
|
296
|
+
* `field` and `fields` do, which a required annotation covers: the schema, and
|
|
297
|
+
* every field, item and value below it, never inside a `oneOf`. `list` is
|
|
298
|
+
* the `optionSchema` of the list of choices a `const` branch belongs to.
|
|
299
|
+
*/
|
|
300
|
+
const visit = (node, path, choice, reachable, list) => {
|
|
301
|
+
if (!(0, schemaNodes_1.isSchemaNode)(node))
|
|
302
|
+
return;
|
|
303
|
+
// An `optionSchema` sits beside the choices it describes, where `options` goes, and nothing inherits it.
|
|
304
|
+
const choiceList = (0, schemaNodes_1.isChoiceList)(node, schemas);
|
|
305
|
+
let optionVocabulary;
|
|
306
|
+
if (node.optionSchema !== undefined) {
|
|
307
|
+
if (Array.isArray(node.enum) || choiceList) {
|
|
308
|
+
optionVocabulary = vocabulary(node, path, "optionSchema", exports.OPTION_BUILT_INS);
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
errors.push({
|
|
312
|
+
path: [...path, "optionSchema"],
|
|
313
|
+
message: "`optionSchema` goes beside the choices it describes, an `enum` or a `oneOf` of consts, and this node has neither." +
|
|
314
|
+
(typeof node.schema === "string"
|
|
315
|
+
? " A referenced schema's choices follow its own."
|
|
316
|
+
: ""),
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
const requiredOptionFields = requiredOf(optionVocabulary);
|
|
321
|
+
if (reachable && requiredAnnotations.length > 0) {
|
|
322
|
+
const names = carried(node);
|
|
323
|
+
const missing = requiredAnnotations.filter((name) => !names.has(name));
|
|
324
|
+
if (missing.length > 0) {
|
|
325
|
+
errors.push({
|
|
326
|
+
path: node.annotations === undefined ? path : [...path, "annotations"],
|
|
327
|
+
message: `${requires("annotationsSchema", missing)}, which this node does not have.`,
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
// Every value of an enum is a choice, which carries what `optionSchema` requires through its entry.
|
|
332
|
+
if (Array.isArray(node.enum) && requiredOptionFields.length > 0) {
|
|
333
|
+
const options = (0, schemaNodes_1.isSchemaNode)(node.annotations) && (0, schemaNodes_1.isSchemaNode)(node.annotations.options)
|
|
334
|
+
? node.annotations.options
|
|
335
|
+
: undefined;
|
|
336
|
+
node.enum.forEach((value, index) => {
|
|
337
|
+
const key = show(value);
|
|
338
|
+
const entry = options && (0, schemaNodes_1.hasOwn)(options, key) ? options[key] : undefined;
|
|
339
|
+
if (!(0, schemaNodes_1.isSchemaNode)(entry)) {
|
|
340
|
+
errors.push({
|
|
341
|
+
path: [...path, "enum", index],
|
|
342
|
+
message: `${requires("optionSchema", requiredOptionFields)}, and the choice ${show(value)} has no entry in \`options\`.`,
|
|
343
|
+
});
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
const missing = requiredOptionFields.filter((name) => !(0, schemaNodes_1.hasOwn)(entry, name));
|
|
347
|
+
if (missing.length > 0) {
|
|
348
|
+
errors.push({
|
|
349
|
+
path: [...path, "annotations", "options", key],
|
|
350
|
+
message: `${requires("optionSchema", missing)}, which this choice does not have.`,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
if (node.annotations !== undefined) {
|
|
356
|
+
const at = [...path, "annotations"];
|
|
357
|
+
if (!(0, schemaNodes_1.isSchemaNode)(node.annotations)) {
|
|
358
|
+
errors.push({ path: at, message: "`annotations` must be a map of names to values." });
|
|
359
|
+
}
|
|
360
|
+
else if (choice)
|
|
361
|
+
checkChoice(node.annotations, at, list);
|
|
362
|
+
else
|
|
363
|
+
checkField(node, node.annotations, at, optionVocabulary);
|
|
364
|
+
}
|
|
365
|
+
(0, schemaNodes_1.forEachSchemaChild)(node, (child, part) => {
|
|
366
|
+
if (part[0] === "oneOf")
|
|
367
|
+
return;
|
|
368
|
+
visit(child, [...path, ...part], false, reachable, undefined);
|
|
369
|
+
});
|
|
370
|
+
if (Array.isArray(node.oneOf)) {
|
|
371
|
+
// The branches of a list of choices carry what a choice carries, and any other branch a field's annotations.
|
|
372
|
+
if (choiceList) {
|
|
373
|
+
const choices = node.oneOf.map((branch) => ({
|
|
374
|
+
value: (0, schemaNodes_1.resolveSchemaNode)(branch, schemas)?.const,
|
|
375
|
+
entry: (0, schemaNodes_1.isSchemaNode)(branch) ? branch.annotations : undefined,
|
|
376
|
+
}));
|
|
377
|
+
choices.forEach((current, index) => {
|
|
378
|
+
const earlier = choices.findIndex((other) => JSON.stringify(other.value) === JSON.stringify(current.value));
|
|
379
|
+
if (earlier < index) {
|
|
380
|
+
errors.push({
|
|
381
|
+
path: [...path, "oneOf", index],
|
|
382
|
+
message: `${show(current.value)} is a choice already, at \`oneOf[${earlier}]\`.`,
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
checkTitles(choices, [...path, "oneOf"]);
|
|
387
|
+
if (requiredOptionFields.length > 0) {
|
|
388
|
+
node.oneOf.forEach((branch, index) => {
|
|
389
|
+
if (!(0, schemaNodes_1.isSchemaNode)(branch))
|
|
390
|
+
return;
|
|
391
|
+
const names = carried(branch);
|
|
392
|
+
const missing = requiredOptionFields.filter((name) => !names.has(name));
|
|
393
|
+
if (missing.length > 0) {
|
|
394
|
+
errors.push({
|
|
395
|
+
path: [...path, "oneOf", index],
|
|
396
|
+
message: `${requires("optionSchema", missing)}, which this choice does not have.`,
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
// `field` stops at a `oneOf`, so nothing inside one is a node a handle reaches.
|
|
403
|
+
node.oneOf.forEach((branch, index) => visit(branch, [...path, "oneOf", index], choiceList, false, choiceList ? optionVocabulary : undefined));
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
visit(root, [], false, true, undefined);
|
|
407
|
+
return { errors, warnings };
|
|
408
|
+
}
|
|
409
|
+
//# sourceMappingURL=schemaAnnotations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaAnnotations.js","sourceRoot":"","sources":["../../src/linter/schemaAnnotations.ts"],"names":[],"mappings":";;;AA6CA,sDA2BC;AAeD,kEAoYC;AAzdD,gDAOwB;AACxB,mDAAqD;AAkBrD,6EAA6E;AAChE,QAAA,eAAe,GAAsB;IAChD,OAAO;IACP,SAAS;IACT,UAAU;IACV,OAAO;IACP,SAAS;CACV,CAAC;AACF,iGAAiG;AACpF,QAAA,gBAAgB,GAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAEtE;;;;;GAKG;AACH,SAAgB,qBAAqB,CACnC,YAAoC;IAEpC,MAAM,KAAK,GAAgC,EAAE,CAAC;IAC9C,MAAM,GAAG,GAAG,CAAC,UAAmB,EAAE,KAAwB,EAAE,EAAE;QAC5D,MAAM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AAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CACnC,KAAK,CACH,MAAM,EACN,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,EACzB,UAAU,EACV,KAAK,EACL,UAAU,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,CAC1C,CACF,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;IAEF,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;IACxC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Schema } from "@featurevisor/types";
|
|
2
|
+
/**
|
|
3
|
+
* Whether a value meets a schema node's rules, by `@featurevisor/schemas`'s own
|
|
4
|
+
* engine, so lint and applications never answer otherwise. Mutations and issue
|
|
5
|
+
* entries do not apply, since lint checks a schema's base rules.
|
|
6
|
+
*/
|
|
7
|
+
export declare function validatesWithEngine(node: unknown, value: unknown, schemasByKey?: Record<string, Schema>): boolean;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validatesWithEngine = validatesWithEngine;
|
|
4
|
+
const schemas_1 = require("@featurevisor/schemas");
|
|
5
|
+
const schemaNodes_1 = require("../schemaNodes");
|
|
6
|
+
const schemaPatterns_1 = require("./schemaPatterns");
|
|
7
|
+
/** The key the node being checked goes under, which no schema file can have. */
|
|
8
|
+
const NODE = "\u0000node";
|
|
9
|
+
const engines = new WeakMap();
|
|
10
|
+
const noSchemas = {};
|
|
11
|
+
/**
|
|
12
|
+
* A node as the package reads it in lint. Variables can be `json`, a string
|
|
13
|
+
* holding JSON, which schema files cannot. A pattern that compiles only
|
|
14
|
+
* without the u flag reads as its rewrite, which lint warns about, and one
|
|
15
|
+
* that does not compile is left out, since it has an error of its own and
|
|
16
|
+
* values are not blamed for it.
|
|
17
|
+
*/
|
|
18
|
+
function forEngine(node) {
|
|
19
|
+
if (!(0, schemaNodes_1.isSchemaNode)(node))
|
|
20
|
+
return node;
|
|
21
|
+
const copy = {};
|
|
22
|
+
for (const [key, value] of Object.entries((0, schemaNodes_1.mapSchemaChildren)(node, forEngine))) {
|
|
23
|
+
if (key === "type" && value === "json")
|
|
24
|
+
copy[key] = "string";
|
|
25
|
+
else if (key === "pattern" && typeof value === "string") {
|
|
26
|
+
const unicode = (0, schemaPatterns_1.toUnicodePattern)(value);
|
|
27
|
+
if (unicode !== undefined)
|
|
28
|
+
copy[key] = unicode;
|
|
29
|
+
}
|
|
30
|
+
else
|
|
31
|
+
copy[key] = value;
|
|
32
|
+
}
|
|
33
|
+
return copy;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The validator applications use, over a project's schemas as lint reads them.
|
|
37
|
+
* It stands in for an SDK instance with only what the package reads: entries,
|
|
38
|
+
* and conditions, which never match, so values meet a schema's base rules.
|
|
39
|
+
*/
|
|
40
|
+
function engineFor(schemasByKey) {
|
|
41
|
+
const existing = engines.get(schemasByKey);
|
|
42
|
+
if (existing)
|
|
43
|
+
return existing;
|
|
44
|
+
const entries = {};
|
|
45
|
+
for (const key of Object.keys(schemasByKey))
|
|
46
|
+
entries[key] = forEngine(schemasByKey[key]);
|
|
47
|
+
const api = {
|
|
48
|
+
getEntry: (section, key) => section === "schemas" && (0, schemaNodes_1.hasOwn)(entries, key) ? entries[key] : undefined,
|
|
49
|
+
getEntryKeys: (section) => (section === "schemas" ? Object.keys(entries) : []),
|
|
50
|
+
matchConditions: () => false,
|
|
51
|
+
// Lint checks a schema's base rules, so no condition matches and no module runs.
|
|
52
|
+
evaluate: (request, callback) => callback({ context: request.context || {}, matchConditions: () => false }),
|
|
53
|
+
getRevision: () => "lint",
|
|
54
|
+
reportDiagnostic: () => { },
|
|
55
|
+
};
|
|
56
|
+
const f = {
|
|
57
|
+
addModule: (module) => module.setup?.(api),
|
|
58
|
+
on: () => () => { },
|
|
59
|
+
getContext: () => ({}),
|
|
60
|
+
};
|
|
61
|
+
const engine = { entries, s: (0, schemas_1.createSchemas)(f) };
|
|
62
|
+
engines.set(schemasByKey, engine);
|
|
63
|
+
return engine;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Whether a value meets a schema node's rules, by `@featurevisor/schemas`'s own
|
|
67
|
+
* engine, so lint and applications never answer otherwise. Mutations and issue
|
|
68
|
+
* entries do not apply, since lint checks a schema's base rules.
|
|
69
|
+
*/
|
|
70
|
+
function validatesWithEngine(node, value, schemasByKey = noSchemas) {
|
|
71
|
+
const engine = engineFor(schemasByKey);
|
|
72
|
+
engine.entries[NODE] = forEngine(node);
|
|
73
|
+
try {
|
|
74
|
+
return engine.s.isValid(NODE, value) === true;
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
delete engine.entries[NODE];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=schemaEngine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemaEngine.js","sourceRoot":"","sources":["../../src/linter/schemaEngine.ts"],"names":[],"mappings":";;AA4EA,kDAYC;AAtFD,mDAAoE;AAEpE,gDAAyE;AACzE,qDAAoD;AAEpD,gFAAgF;AAChF,MAAM,IAAI,GAAG,YAAY,CAAC;AAO1B,MAAM,OAAO,GAAG,IAAI,OAAO,EAAkB,CAAC;AAC9C,MAAM,SAAS,GAA2B,EAAE,CAAC;AAE7C;;;;;;GAMG;AACH,SAAS,SAAS,CAAC,IAAa;IAC9B,IAAI,CAAC,IAAA,0BAAY,EAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACrC,MAAM,IAAI,GAA4B,EAAE,CAAC;IACzC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAA,+B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types";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* A string's length in code points, as JSON Schema counts `minLength` and
|
|
5
|
+
* `maxLength`, so an emoji counts one. JavaScript's `length` counts UTF-16 code
|
|
6
|
+
* units, which counts most emoji as two.
|
|
7
|
+
*/
|
|
8
|
+
export declare function codePointLength(value: string): number;
|
|
3
9
|
/** Types shared by attributes, reusable schemas and variables, in authoring order. */
|
|
4
10
|
export declare const SCHEMA_TYPES: readonly ["boolean", "string", "integer", "number", "object", "array"];
|
|
5
11
|
/** Semantic string formats. Each one drives operator rules, so unknown formats are errors. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.schemaFormatZodSchema = exports.REMOVED_SCHEMA_TYPES = exports.SCHEMA_FORMATS = exports.SCHEMA_TYPES = void 0;
|
|
4
|
+
exports.codePointLength = codePointLength;
|
|
4
5
|
exports.isRemovedSchemaType = isRemovedSchemaType;
|
|
5
6
|
exports.schemaTypeZodSchema = schemaTypeZodSchema;
|
|
6
7
|
exports.refineRemovedSchemaType = refineRemovedSchemaType;
|
|
@@ -9,6 +10,25 @@ exports.formatValueMessage = formatValueMessage;
|
|
|
9
10
|
exports.getSchemaKind = getSchemaKind;
|
|
10
11
|
const zod_1 = require("zod");
|
|
11
12
|
const sdk_1 = require("@featurevisor/sdk");
|
|
13
|
+
/**
|
|
14
|
+
* A string's length in code points, as JSON Schema counts `minLength` and
|
|
15
|
+
* `maxLength`, so an emoji counts one. JavaScript's `length` counts UTF-16 code
|
|
16
|
+
* units, which counts most emoji as two.
|
|
17
|
+
*/
|
|
18
|
+
function codePointLength(value) {
|
|
19
|
+
let length = value.length;
|
|
20
|
+
for (let index = 0; index < value.length - 1; index++) {
|
|
21
|
+
const code = value.charCodeAt(index);
|
|
22
|
+
if (code >= 0xd800 && code <= 0xdbff) {
|
|
23
|
+
const next = value.charCodeAt(index + 1);
|
|
24
|
+
if (next >= 0xdc00 && next <= 0xdfff) {
|
|
25
|
+
length--;
|
|
26
|
+
index++;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return length;
|
|
31
|
+
}
|
|
12
32
|
/** Types shared by attributes, reusable schemas and variables, in authoring order. */
|
|
13
33
|
exports.SCHEMA_TYPES = ["boolean", "string", "integer", "number", "object", "array"];
|
|
14
34
|
/** Semantic string formats. Each one drives operator rules, so unknown formats are errors. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemaFormats.js","sourceRoot":"","sources":["../../src/linter/schemaFormats.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"schemaFormats.js","sourceRoot":"","sources":["../../src/linter/schemaFormats.ts"],"names":[],"mappings":";;;AASA,0CAaC;AAeD,kDAIC;AAGD,kDAQC;AAUD,0DAWC;AAGD,gDAKC;AAED,gDAIC;AAiBD,sCAOC;AA9GD,6BAAwB;AACxB,2CAAyE;AAEzE;;;;GAIG;AACH,SAAgB,eAAe,CAAC,KAAa;IAC3C,IAAI,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAC1B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;QACtD,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;YACrC,MAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;YACzC,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;gBACrC,MAAM,EAAE,CAAC;gBACT,KAAK,EAAE,CAAC;YACV,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;A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