@thatopen/services 0.26.1 → 0.27.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/dist/cli.js +918 -864
- package/dist/cli.js.map +1 -1
- package/dist/core/history.d.ts +70 -1
- package/dist/index.cjs.js +3 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +458 -377
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -7142,7 +7142,13 @@ class FlowDoc {
|
|
|
7142
7142
|
const response = await this.client.downloadHiddenFile(version2.deltaId);
|
|
7143
7143
|
return await response.blob();
|
|
7144
7144
|
}
|
|
7145
|
-
/**
|
|
7145
|
+
/**
|
|
7146
|
+
* The visible model .frag AS LAST FULLY EXPORTED — the first commit, or the
|
|
7147
|
+
* last explicit publish. Ordinary syncs only add hidden deltas, so this is
|
|
7148
|
+
* NOT necessarily the head: anything computed on it (a clash run) is as of
|
|
7149
|
+
* the last `full: true` version. For the model at a specific version, read
|
|
7150
|
+
* {@link modelParts} and compose.
|
|
7151
|
+
*/
|
|
7146
7152
|
async model() {
|
|
7147
7153
|
const file = await this.#modelFile();
|
|
7148
7154
|
if (!file) {
|
|
@@ -7153,6 +7159,69 @@ class FlowDoc {
|
|
|
7153
7159
|
const response = await this.client.downloadFile(file.id);
|
|
7154
7160
|
return await response.blob();
|
|
7155
7161
|
}
|
|
7162
|
+
/**
|
|
7163
|
+
* The ordered recipe for the model AT a version: the baseline full export
|
|
7164
|
+
* at-or-before it, then one step per later version up to it — each step's
|
|
7165
|
+
* delta .frag (absent on geometry-less versions) and the element uniqueIds
|
|
7166
|
+
* it removed. The consumer composes with its geometry engine: load the
|
|
7167
|
+
* baseline, then per step replace elements by uniqueId from the delta and
|
|
7168
|
+
* drop the removed. Composing is NOT done here: writing a merged .frag
|
|
7169
|
+
* takes the fragments engine, which this package deliberately does not
|
|
7170
|
+
* carry.
|
|
7171
|
+
*
|
|
7172
|
+
* UniqueIds are the native application's own stable element ids (a Revit
|
|
7173
|
+
* UniqueId survives syncs, machines and full exports), which is what makes
|
|
7174
|
+
* replace-by-uniqueId the whole composition rule.
|
|
7175
|
+
*
|
|
7176
|
+
* When the baseline is NEWER than the asked version (somebody published
|
|
7177
|
+
* after it), the visible file no longer shows that moment: `baseline`
|
|
7178
|
+
* then carries the older version's `storageVersion` when the history
|
|
7179
|
+
* recorded one, so the consumer can download that stored file version
|
|
7180
|
+
* instead of the current one.
|
|
7181
|
+
*/
|
|
7182
|
+
async modelParts(options) {
|
|
7183
|
+
const timeline = await this.timeline();
|
|
7184
|
+
if (timeline.length === 0) {
|
|
7185
|
+
throw new Error(
|
|
7186
|
+
`Document ${this.source}-${this.docId} has no history yet.`
|
|
7187
|
+
);
|
|
7188
|
+
}
|
|
7189
|
+
const at = options?.at;
|
|
7190
|
+
const targetIndex = at ? timeline.findIndex((v) => v.guid === at) : timeline.length - 1;
|
|
7191
|
+
if (targetIndex < 0) {
|
|
7192
|
+
throw new Error(`No version ${at} in this document's timeline.`);
|
|
7193
|
+
}
|
|
7194
|
+
let baselineIndex = 0;
|
|
7195
|
+
for (let i = targetIndex; i >= 0; i--) {
|
|
7196
|
+
if (timeline[i].full) {
|
|
7197
|
+
baselineIndex = i;
|
|
7198
|
+
break;
|
|
7199
|
+
}
|
|
7200
|
+
}
|
|
7201
|
+
const file = await this.#modelFile();
|
|
7202
|
+
if (!file) {
|
|
7203
|
+
throw new Error(
|
|
7204
|
+
`Document ${this.source}-${this.docId} has no model file yet.`
|
|
7205
|
+
);
|
|
7206
|
+
}
|
|
7207
|
+
const baselineVersion = timeline[baselineIndex];
|
|
7208
|
+
const rewrittenAfter = timeline.slice(targetIndex + 1).some((v) => v.full);
|
|
7209
|
+
const steps = timeline.slice(baselineIndex + 1, targetIndex + 1).map((version2) => ({
|
|
7210
|
+
guid: version2.guid,
|
|
7211
|
+
...version2.deltaId ? { deltaId: version2.deltaId } : {},
|
|
7212
|
+
removedUniqueIds: version2.changes.filter((change) => change.type === "delete").map((change) => change.uniqueId)
|
|
7213
|
+
}));
|
|
7214
|
+
return {
|
|
7215
|
+
baseline: {
|
|
7216
|
+
fileId: file.id,
|
|
7217
|
+
guid: baselineVersion.guid,
|
|
7218
|
+
current: !rewrittenAfter,
|
|
7219
|
+
...baselineVersion.version !== void 0 ? { storageVersion: baselineVersion.version } : {}
|
|
7220
|
+
},
|
|
7221
|
+
steps,
|
|
7222
|
+
at: timeline[targetIndex].guid
|
|
7223
|
+
};
|
|
7224
|
+
}
|
|
7156
7225
|
/** The document folder's item id — the id the CDE knows this document by. */
|
|
7157
7226
|
async folderId() {
|
|
7158
7227
|
return await this.#folder(false);
|
|
@@ -7202,6 +7271,27 @@ class FlowDoc {
|
|
|
7202
7271
|
views: [view]
|
|
7203
7272
|
});
|
|
7204
7273
|
}
|
|
7274
|
+
/**
|
|
7275
|
+
* Makes sure the folder carries a descriptor, WRITING one when it predates
|
|
7276
|
+
* them: the visible model .frag becomes the 'frag' view. The explicit form
|
|
7277
|
+
* of what {@link addView} does implicitly — reads like `descriptor()` never
|
|
7278
|
+
* write, so migrating an old folder is this deliberate call. Returns the
|
|
7279
|
+
* descriptor either way, or null when there is nothing to describe yet (no
|
|
7280
|
+
* model file).
|
|
7281
|
+
*/
|
|
7282
|
+
async ensureDescriptor() {
|
|
7283
|
+
const folderId = await this.#folder(false);
|
|
7284
|
+
const existing = await this.#documents.descriptor(folderId);
|
|
7285
|
+
if (existing) return existing;
|
|
7286
|
+
const model = await this.#modelFile();
|
|
7287
|
+
if (!model) return null;
|
|
7288
|
+
const descriptor = {
|
|
7289
|
+
name: model.name.replace(/\.frag$/, ""),
|
|
7290
|
+
views: [{ fileId: model.id, format: "frag" }]
|
|
7291
|
+
};
|
|
7292
|
+
await this.#documents.setDescriptor(folderId, descriptor);
|
|
7293
|
+
return await this.#documents.descriptor(folderId);
|
|
7294
|
+
}
|
|
7205
7295
|
// ─── Ownership (element locks) ─────────────────────────────────────────────
|
|
7206
7296
|
/**
|
|
7207
7297
|
* Who currently holds which elements, read from the lock registry the
|
|
@@ -25972,8 +26062,8 @@ var scope = {};
|
|
|
25972
26062
|
var util = {};
|
|
25973
26063
|
Object.defineProperty(util, "__esModule", { value: true });
|
|
25974
26064
|
util.checkStrictMode = util.getErrorPath = util.Type = util.useFunc = util.setEvaluated = util.evaluatedPropsToName = util.mergeEvaluated = util.eachItem = util.unescapeJsonPointer = util.escapeJsonPointer = util.escapeFragment = util.unescapeFragment = util.schemaRefOrVal = util.schemaHasRulesButRef = util.schemaHasRules = util.checkUnknownRules = util.alwaysValidSchema = util.toHash = void 0;
|
|
25975
|
-
const codegen_1$
|
|
25976
|
-
const code_1$
|
|
26065
|
+
const codegen_1$v = codegen;
|
|
26066
|
+
const code_1$a = code$1;
|
|
25977
26067
|
function toHash(arr) {
|
|
25978
26068
|
const hash = {};
|
|
25979
26069
|
for (const item of arr)
|
|
@@ -26026,9 +26116,9 @@ function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword2, $data) {
|
|
|
26026
26116
|
if (typeof schema == "number" || typeof schema == "boolean")
|
|
26027
26117
|
return schema;
|
|
26028
26118
|
if (typeof schema == "string")
|
|
26029
|
-
return (0, codegen_1$
|
|
26119
|
+
return (0, codegen_1$v._)`${schema}`;
|
|
26030
26120
|
}
|
|
26031
|
-
return (0, codegen_1$
|
|
26121
|
+
return (0, codegen_1$v._)`${topSchemaRef}${schemaPath}${(0, codegen_1$v.getProperty)(keyword2)}`;
|
|
26032
26122
|
}
|
|
26033
26123
|
util.schemaRefOrVal = schemaRefOrVal;
|
|
26034
26124
|
function unescapeFragment(str) {
|
|
@@ -26060,20 +26150,20 @@ function eachItem(xs, f) {
|
|
|
26060
26150
|
util.eachItem = eachItem;
|
|
26061
26151
|
function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues: mergeValues2, resultToName }) {
|
|
26062
26152
|
return (gen, from, to, toName) => {
|
|
26063
|
-
const res = to === void 0 ? from : to instanceof codegen_1$
|
|
26064
|
-
return toName === codegen_1$
|
|
26153
|
+
const res = to === void 0 ? from : to instanceof codegen_1$v.Name ? (from instanceof codegen_1$v.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1$v.Name ? (mergeToName(gen, to, from), from) : mergeValues2(from, to);
|
|
26154
|
+
return toName === codegen_1$v.Name && !(res instanceof codegen_1$v.Name) ? resultToName(gen, res) : res;
|
|
26065
26155
|
};
|
|
26066
26156
|
}
|
|
26067
26157
|
util.mergeEvaluated = {
|
|
26068
26158
|
props: makeMergeEvaluated({
|
|
26069
|
-
mergeNames: (gen, from, to) => gen.if((0, codegen_1$
|
|
26070
|
-
gen.if((0, codegen_1$
|
|
26159
|
+
mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => {
|
|
26160
|
+
gen.if((0, codegen_1$v._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1$v._)`${to} || {}`).code((0, codegen_1$v._)`Object.assign(${to}, ${from})`));
|
|
26071
26161
|
}),
|
|
26072
|
-
mergeToName: (gen, from, to) => gen.if((0, codegen_1$
|
|
26162
|
+
mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => {
|
|
26073
26163
|
if (from === true) {
|
|
26074
26164
|
gen.assign(to, true);
|
|
26075
26165
|
} else {
|
|
26076
|
-
gen.assign(to, (0, codegen_1$
|
|
26166
|
+
gen.assign(to, (0, codegen_1$v._)`${to} || {}`);
|
|
26077
26167
|
setEvaluated(gen, to, from);
|
|
26078
26168
|
}
|
|
26079
26169
|
}),
|
|
@@ -26081,8 +26171,8 @@ util.mergeEvaluated = {
|
|
|
26081
26171
|
resultToName: evaluatedPropsToName
|
|
26082
26172
|
}),
|
|
26083
26173
|
items: makeMergeEvaluated({
|
|
26084
|
-
mergeNames: (gen, from, to) => gen.if((0, codegen_1$
|
|
26085
|
-
mergeToName: (gen, from, to) => gen.if((0, codegen_1$
|
|
26174
|
+
mergeNames: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1$v._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
|
|
26175
|
+
mergeToName: (gen, from, to) => gen.if((0, codegen_1$v._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1$v._)`${to} > ${from} ? ${to} : ${from}`)),
|
|
26086
26176
|
mergeValues: (from, to) => from === true ? true : Math.max(from, to),
|
|
26087
26177
|
resultToName: (gen, items2) => gen.var("items", items2)
|
|
26088
26178
|
})
|
|
@@ -26090,21 +26180,21 @@ util.mergeEvaluated = {
|
|
|
26090
26180
|
function evaluatedPropsToName(gen, ps) {
|
|
26091
26181
|
if (ps === true)
|
|
26092
26182
|
return gen.var("props", true);
|
|
26093
|
-
const props = gen.var("props", (0, codegen_1$
|
|
26183
|
+
const props = gen.var("props", (0, codegen_1$v._)`{}`);
|
|
26094
26184
|
if (ps !== void 0)
|
|
26095
26185
|
setEvaluated(gen, props, ps);
|
|
26096
26186
|
return props;
|
|
26097
26187
|
}
|
|
26098
26188
|
util.evaluatedPropsToName = evaluatedPropsToName;
|
|
26099
26189
|
function setEvaluated(gen, props, ps) {
|
|
26100
|
-
Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$
|
|
26190
|
+
Object.keys(ps).forEach((p) => gen.assign((0, codegen_1$v._)`${props}${(0, codegen_1$v.getProperty)(p)}`, true));
|
|
26101
26191
|
}
|
|
26102
26192
|
util.setEvaluated = setEvaluated;
|
|
26103
26193
|
const snippets = {};
|
|
26104
26194
|
function useFunc(gen, f) {
|
|
26105
26195
|
return gen.scopeValue("func", {
|
|
26106
26196
|
ref: f,
|
|
26107
|
-
code: snippets[f.code] || (snippets[f.code] = new code_1$
|
|
26197
|
+
code: snippets[f.code] || (snippets[f.code] = new code_1$a._Code(f.code))
|
|
26108
26198
|
});
|
|
26109
26199
|
}
|
|
26110
26200
|
util.useFunc = useFunc;
|
|
@@ -26114,11 +26204,11 @@ var Type;
|
|
|
26114
26204
|
Type2[Type2["Str"] = 1] = "Str";
|
|
26115
26205
|
})(Type || (util.Type = Type = {}));
|
|
26116
26206
|
function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
|
|
26117
|
-
if (dataProp instanceof codegen_1$
|
|
26207
|
+
if (dataProp instanceof codegen_1$v.Name) {
|
|
26118
26208
|
const isNumber = dataPropType === Type.Num;
|
|
26119
|
-
return jsPropertySyntax ? isNumber ? (0, codegen_1$
|
|
26209
|
+
return jsPropertySyntax ? isNumber ? (0, codegen_1$v._)`"[" + ${dataProp} + "]"` : (0, codegen_1$v._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1$v._)`"/" + ${dataProp}` : (0, codegen_1$v._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
|
|
26120
26210
|
}
|
|
26121
|
-
return jsPropertySyntax ? (0, codegen_1$
|
|
26211
|
+
return jsPropertySyntax ? (0, codegen_1$v.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
|
|
26122
26212
|
}
|
|
26123
26213
|
util.getErrorPath = getErrorPath;
|
|
26124
26214
|
function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
|
|
@@ -26132,35 +26222,35 @@ function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
|
|
|
26132
26222
|
util.checkStrictMode = checkStrictMode;
|
|
26133
26223
|
var names$1 = {};
|
|
26134
26224
|
Object.defineProperty(names$1, "__esModule", { value: true });
|
|
26135
|
-
const codegen_1$
|
|
26225
|
+
const codegen_1$u = codegen;
|
|
26136
26226
|
const names = {
|
|
26137
26227
|
// validation function arguments
|
|
26138
|
-
data: new codegen_1$
|
|
26228
|
+
data: new codegen_1$u.Name("data"),
|
|
26139
26229
|
// data passed to validation function
|
|
26140
26230
|
// args passed from referencing schema
|
|
26141
|
-
valCxt: new codegen_1$
|
|
26231
|
+
valCxt: new codegen_1$u.Name("valCxt"),
|
|
26142
26232
|
// validation/data context - should not be used directly, it is destructured to the names below
|
|
26143
|
-
instancePath: new codegen_1$
|
|
26144
|
-
parentData: new codegen_1$
|
|
26145
|
-
parentDataProperty: new codegen_1$
|
|
26146
|
-
rootData: new codegen_1$
|
|
26233
|
+
instancePath: new codegen_1$u.Name("instancePath"),
|
|
26234
|
+
parentData: new codegen_1$u.Name("parentData"),
|
|
26235
|
+
parentDataProperty: new codegen_1$u.Name("parentDataProperty"),
|
|
26236
|
+
rootData: new codegen_1$u.Name("rootData"),
|
|
26147
26237
|
// root data - same as the data passed to the first/top validation function
|
|
26148
|
-
dynamicAnchors: new codegen_1$
|
|
26238
|
+
dynamicAnchors: new codegen_1$u.Name("dynamicAnchors"),
|
|
26149
26239
|
// used to support recursiveRef and dynamicRef
|
|
26150
26240
|
// function scoped variables
|
|
26151
|
-
vErrors: new codegen_1$
|
|
26241
|
+
vErrors: new codegen_1$u.Name("vErrors"),
|
|
26152
26242
|
// null or array of validation errors
|
|
26153
|
-
errors: new codegen_1$
|
|
26243
|
+
errors: new codegen_1$u.Name("errors"),
|
|
26154
26244
|
// counter of validation errors
|
|
26155
|
-
this: new codegen_1$
|
|
26245
|
+
this: new codegen_1$u.Name("this"),
|
|
26156
26246
|
// "globals"
|
|
26157
|
-
self: new codegen_1$
|
|
26158
|
-
scope: new codegen_1$
|
|
26247
|
+
self: new codegen_1$u.Name("self"),
|
|
26248
|
+
scope: new codegen_1$u.Name("scope"),
|
|
26159
26249
|
// JTD serialize/parse name for JSON string and position
|
|
26160
|
-
json: new codegen_1$
|
|
26161
|
-
jsonPos: new codegen_1$
|
|
26162
|
-
jsonLen: new codegen_1$
|
|
26163
|
-
jsonPart: new codegen_1$
|
|
26250
|
+
json: new codegen_1$u.Name("json"),
|
|
26251
|
+
jsonPos: new codegen_1$u.Name("jsonPos"),
|
|
26252
|
+
jsonLen: new codegen_1$u.Name("jsonLen"),
|
|
26253
|
+
jsonPart: new codegen_1$u.Name("jsonPart")
|
|
26164
26254
|
};
|
|
26165
26255
|
names$1.default = names;
|
|
26166
26256
|
(function(exports) {
|
|
@@ -26280,55 +26370,49 @@ names$1.default = names;
|
|
|
26280
26370
|
keyValues.push([E.propertyName, propertyName]);
|
|
26281
26371
|
}
|
|
26282
26372
|
})(errors);
|
|
26283
|
-
|
|
26284
|
-
|
|
26285
|
-
|
|
26286
|
-
|
|
26287
|
-
|
|
26288
|
-
|
|
26289
|
-
|
|
26290
|
-
|
|
26291
|
-
|
|
26292
|
-
const
|
|
26293
|
-
|
|
26294
|
-
|
|
26295
|
-
|
|
26296
|
-
|
|
26297
|
-
|
|
26298
|
-
|
|
26299
|
-
|
|
26300
|
-
gen.return(names_12.default.data);
|
|
26301
|
-
} else {
|
|
26302
|
-
gen.assign((0, codegen_12._)`${validateName}.errors`, null);
|
|
26303
|
-
gen.return(true);
|
|
26304
|
-
}
|
|
26305
|
-
}
|
|
26306
|
-
boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
|
|
26307
|
-
function boolOrEmptySchema(it, valid) {
|
|
26308
|
-
const { gen, schema } = it;
|
|
26309
|
-
if (schema === false) {
|
|
26310
|
-
gen.var(valid, false);
|
|
26311
|
-
falseSchemaError(it);
|
|
26312
|
-
} else {
|
|
26313
|
-
gen.var(valid, true);
|
|
26314
|
-
}
|
|
26373
|
+
Object.defineProperty(boolSchema, "__esModule", { value: true });
|
|
26374
|
+
boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
|
|
26375
|
+
const errors_1$3 = errors;
|
|
26376
|
+
const codegen_1$t = codegen;
|
|
26377
|
+
const names_1$6 = names$1;
|
|
26378
|
+
const boolError = {
|
|
26379
|
+
message: "boolean schema is false"
|
|
26380
|
+
};
|
|
26381
|
+
function topBoolOrEmptySchema(it) {
|
|
26382
|
+
const { gen, schema, validateName } = it;
|
|
26383
|
+
if (schema === false) {
|
|
26384
|
+
falseSchemaError(it, false);
|
|
26385
|
+
} else if (typeof schema == "object" && schema.$async === true) {
|
|
26386
|
+
gen.return(names_1$6.default.data);
|
|
26387
|
+
} else {
|
|
26388
|
+
gen.assign((0, codegen_1$t._)`${validateName}.errors`, null);
|
|
26389
|
+
gen.return(true);
|
|
26315
26390
|
}
|
|
26316
|
-
|
|
26317
|
-
|
|
26318
|
-
|
|
26319
|
-
|
|
26320
|
-
|
|
26321
|
-
|
|
26322
|
-
|
|
26323
|
-
|
|
26324
|
-
|
|
26325
|
-
schemaValue: false,
|
|
26326
|
-
params: {},
|
|
26327
|
-
it
|
|
26328
|
-
};
|
|
26329
|
-
(0, errors_12.reportError)(cxt, boolError, void 0, overrideAllErrors);
|
|
26391
|
+
}
|
|
26392
|
+
boolSchema.topBoolOrEmptySchema = topBoolOrEmptySchema;
|
|
26393
|
+
function boolOrEmptySchema(it, valid) {
|
|
26394
|
+
const { gen, schema } = it;
|
|
26395
|
+
if (schema === false) {
|
|
26396
|
+
gen.var(valid, false);
|
|
26397
|
+
falseSchemaError(it);
|
|
26398
|
+
} else {
|
|
26399
|
+
gen.var(valid, true);
|
|
26330
26400
|
}
|
|
26331
|
-
|
|
26401
|
+
}
|
|
26402
|
+
boolSchema.boolOrEmptySchema = boolOrEmptySchema;
|
|
26403
|
+
function falseSchemaError(it, overrideAllErrors) {
|
|
26404
|
+
const { gen, data } = it;
|
|
26405
|
+
const cxt = {
|
|
26406
|
+
gen,
|
|
26407
|
+
keyword: "false schema",
|
|
26408
|
+
data,
|
|
26409
|
+
schema: false,
|
|
26410
|
+
schemaCode: false,
|
|
26411
|
+
schemaValue: false,
|
|
26412
|
+
params: {},
|
|
26413
|
+
it
|
|
26414
|
+
};
|
|
26415
|
+
(0, errors_1$3.reportError)(cxt, boolError, void 0, overrideAllErrors);
|
|
26332
26416
|
}
|
|
26333
26417
|
var dataType = {};
|
|
26334
26418
|
var rules = {};
|
|
@@ -26376,10 +26460,10 @@ applicability.shouldUseRule = shouldUseRule;
|
|
|
26376
26460
|
Object.defineProperty(dataType, "__esModule", { value: true });
|
|
26377
26461
|
dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = dataType.coerceAndCheckDataType = dataType.getJSONTypes = dataType.getSchemaTypes = dataType.DataType = void 0;
|
|
26378
26462
|
const rules_1 = rules;
|
|
26379
|
-
const applicability_1 = applicability;
|
|
26380
|
-
const errors_1 = errors;
|
|
26381
|
-
const codegen_1$
|
|
26382
|
-
const util_1$
|
|
26463
|
+
const applicability_1$1 = applicability;
|
|
26464
|
+
const errors_1$2 = errors;
|
|
26465
|
+
const codegen_1$s = codegen;
|
|
26466
|
+
const util_1$r = util;
|
|
26383
26467
|
var DataType;
|
|
26384
26468
|
(function(DataType2) {
|
|
26385
26469
|
DataType2[DataType2["Correct"] = 0] = "Correct";
|
|
@@ -26411,7 +26495,7 @@ dataType.getJSONTypes = getJSONTypes;
|
|
|
26411
26495
|
function coerceAndCheckDataType(it, types2) {
|
|
26412
26496
|
const { gen, data, opts } = it;
|
|
26413
26497
|
const coerceTo = coerceToTypes(types2, opts.coerceTypes);
|
|
26414
|
-
const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types2[0]));
|
|
26498
|
+
const checkTypes = types2.length > 0 && !(coerceTo.length === 0 && types2.length === 1 && (0, applicability_1$1.schemaHasRulesForType)(it, types2[0]));
|
|
26415
26499
|
if (checkTypes) {
|
|
26416
26500
|
const wrongType = checkDataTypes(types2, data, opts.strictNumbers, DataType.Wrong);
|
|
26417
26501
|
gen.if(wrongType, () => {
|
|
@@ -26430,12 +26514,12 @@ function coerceToTypes(types2, coerceTypes) {
|
|
|
26430
26514
|
}
|
|
26431
26515
|
function coerceData(it, types2, coerceTo) {
|
|
26432
26516
|
const { gen, data, opts } = it;
|
|
26433
|
-
const dataType2 = gen.let("dataType", (0, codegen_1$
|
|
26434
|
-
const coerced = gen.let("coerced", (0, codegen_1$
|
|
26517
|
+
const dataType2 = gen.let("dataType", (0, codegen_1$s._)`typeof ${data}`);
|
|
26518
|
+
const coerced = gen.let("coerced", (0, codegen_1$s._)`undefined`);
|
|
26435
26519
|
if (opts.coerceTypes === "array") {
|
|
26436
|
-
gen.if((0, codegen_1$
|
|
26520
|
+
gen.if((0, codegen_1$s._)`${dataType2} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1$s._)`${data}[0]`).assign(dataType2, (0, codegen_1$s._)`typeof ${data}`).if(checkDataTypes(types2, data, opts.strictNumbers), () => gen.assign(coerced, data)));
|
|
26437
26521
|
}
|
|
26438
|
-
gen.if((0, codegen_1$
|
|
26522
|
+
gen.if((0, codegen_1$s._)`${coerced} !== undefined`);
|
|
26439
26523
|
for (const t of coerceTo) {
|
|
26440
26524
|
if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") {
|
|
26441
26525
|
coerceSpecificType(t);
|
|
@@ -26444,63 +26528,63 @@ function coerceData(it, types2, coerceTo) {
|
|
|
26444
26528
|
gen.else();
|
|
26445
26529
|
reportTypeError(it);
|
|
26446
26530
|
gen.endIf();
|
|
26447
|
-
gen.if((0, codegen_1$
|
|
26531
|
+
gen.if((0, codegen_1$s._)`${coerced} !== undefined`, () => {
|
|
26448
26532
|
gen.assign(data, coerced);
|
|
26449
26533
|
assignParentData(it, coerced);
|
|
26450
26534
|
});
|
|
26451
26535
|
function coerceSpecificType(t) {
|
|
26452
26536
|
switch (t) {
|
|
26453
26537
|
case "string":
|
|
26454
|
-
gen.elseIf((0, codegen_1$
|
|
26538
|
+
gen.elseIf((0, codegen_1$s._)`${dataType2} == "number" || ${dataType2} == "boolean"`).assign(coerced, (0, codegen_1$s._)`"" + ${data}`).elseIf((0, codegen_1$s._)`${data} === null`).assign(coerced, (0, codegen_1$s._)`""`);
|
|
26455
26539
|
return;
|
|
26456
26540
|
case "number":
|
|
26457
|
-
gen.elseIf((0, codegen_1$
|
|
26458
|
-
|| (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$
|
|
26541
|
+
gen.elseIf((0, codegen_1$s._)`${dataType2} == "boolean" || ${data} === null
|
|
26542
|
+
|| (${dataType2} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1$s._)`+${data}`);
|
|
26459
26543
|
return;
|
|
26460
26544
|
case "integer":
|
|
26461
|
-
gen.elseIf((0, codegen_1$
|
|
26462
|
-
|| (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$
|
|
26545
|
+
gen.elseIf((0, codegen_1$s._)`${dataType2} === "boolean" || ${data} === null
|
|
26546
|
+
|| (${dataType2} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1$s._)`+${data}`);
|
|
26463
26547
|
return;
|
|
26464
26548
|
case "boolean":
|
|
26465
|
-
gen.elseIf((0, codegen_1$
|
|
26549
|
+
gen.elseIf((0, codegen_1$s._)`${data} === "false" || ${data} === 0 || ${data} === null`).assign(coerced, false).elseIf((0, codegen_1$s._)`${data} === "true" || ${data} === 1`).assign(coerced, true);
|
|
26466
26550
|
return;
|
|
26467
26551
|
case "null":
|
|
26468
|
-
gen.elseIf((0, codegen_1$
|
|
26552
|
+
gen.elseIf((0, codegen_1$s._)`${data} === "" || ${data} === 0 || ${data} === false`);
|
|
26469
26553
|
gen.assign(coerced, null);
|
|
26470
26554
|
return;
|
|
26471
26555
|
case "array":
|
|
26472
|
-
gen.elseIf((0, codegen_1$
|
|
26473
|
-
|| ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$
|
|
26556
|
+
gen.elseIf((0, codegen_1$s._)`${dataType2} === "string" || ${dataType2} === "number"
|
|
26557
|
+
|| ${dataType2} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1$s._)`[${data}]`);
|
|
26474
26558
|
}
|
|
26475
26559
|
}
|
|
26476
26560
|
}
|
|
26477
26561
|
function assignParentData({ gen, parentData, parentDataProperty }, expr) {
|
|
26478
|
-
gen.if((0, codegen_1$
|
|
26562
|
+
gen.if((0, codegen_1$s._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1$s._)`${parentData}[${parentDataProperty}]`, expr));
|
|
26479
26563
|
}
|
|
26480
26564
|
function checkDataType(dataType2, data, strictNums, correct = DataType.Correct) {
|
|
26481
|
-
const EQ = correct === DataType.Correct ? codegen_1$
|
|
26565
|
+
const EQ = correct === DataType.Correct ? codegen_1$s.operators.EQ : codegen_1$s.operators.NEQ;
|
|
26482
26566
|
let cond;
|
|
26483
26567
|
switch (dataType2) {
|
|
26484
26568
|
case "null":
|
|
26485
|
-
return (0, codegen_1$
|
|
26569
|
+
return (0, codegen_1$s._)`${data} ${EQ} null`;
|
|
26486
26570
|
case "array":
|
|
26487
|
-
cond = (0, codegen_1$
|
|
26571
|
+
cond = (0, codegen_1$s._)`Array.isArray(${data})`;
|
|
26488
26572
|
break;
|
|
26489
26573
|
case "object":
|
|
26490
|
-
cond = (0, codegen_1$
|
|
26574
|
+
cond = (0, codegen_1$s._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
|
|
26491
26575
|
break;
|
|
26492
26576
|
case "integer":
|
|
26493
|
-
cond = numCond((0, codegen_1$
|
|
26577
|
+
cond = numCond((0, codegen_1$s._)`!(${data} % 1) && !isNaN(${data})`);
|
|
26494
26578
|
break;
|
|
26495
26579
|
case "number":
|
|
26496
26580
|
cond = numCond();
|
|
26497
26581
|
break;
|
|
26498
26582
|
default:
|
|
26499
|
-
return (0, codegen_1$
|
|
26583
|
+
return (0, codegen_1$s._)`typeof ${data} ${EQ} ${dataType2}`;
|
|
26500
26584
|
}
|
|
26501
|
-
return correct === DataType.Correct ? cond : (0, codegen_1$
|
|
26502
|
-
function numCond(_cond = codegen_1$
|
|
26503
|
-
return (0, codegen_1$
|
|
26585
|
+
return correct === DataType.Correct ? cond : (0, codegen_1$s.not)(cond);
|
|
26586
|
+
function numCond(_cond = codegen_1$s.nil) {
|
|
26587
|
+
return (0, codegen_1$s.and)((0, codegen_1$s._)`typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_1$s._)`isFinite(${data})` : codegen_1$s.nil);
|
|
26504
26588
|
}
|
|
26505
26589
|
}
|
|
26506
26590
|
dataType.checkDataType = checkDataType;
|
|
@@ -26509,35 +26593,35 @@ function checkDataTypes(dataTypes, data, strictNums, correct) {
|
|
|
26509
26593
|
return checkDataType(dataTypes[0], data, strictNums, correct);
|
|
26510
26594
|
}
|
|
26511
26595
|
let cond;
|
|
26512
|
-
const types2 = (0, util_1$
|
|
26596
|
+
const types2 = (0, util_1$r.toHash)(dataTypes);
|
|
26513
26597
|
if (types2.array && types2.object) {
|
|
26514
|
-
const notObj = (0, codegen_1$
|
|
26515
|
-
cond = types2.null ? notObj : (0, codegen_1$
|
|
26598
|
+
const notObj = (0, codegen_1$s._)`typeof ${data} != "object"`;
|
|
26599
|
+
cond = types2.null ? notObj : (0, codegen_1$s._)`!${data} || ${notObj}`;
|
|
26516
26600
|
delete types2.null;
|
|
26517
26601
|
delete types2.array;
|
|
26518
26602
|
delete types2.object;
|
|
26519
26603
|
} else {
|
|
26520
|
-
cond = codegen_1$
|
|
26604
|
+
cond = codegen_1$s.nil;
|
|
26521
26605
|
}
|
|
26522
26606
|
if (types2.number)
|
|
26523
26607
|
delete types2.integer;
|
|
26524
26608
|
for (const t in types2)
|
|
26525
|
-
cond = (0, codegen_1$
|
|
26609
|
+
cond = (0, codegen_1$s.and)(cond, checkDataType(t, data, strictNums, correct));
|
|
26526
26610
|
return cond;
|
|
26527
26611
|
}
|
|
26528
26612
|
dataType.checkDataTypes = checkDataTypes;
|
|
26529
26613
|
const typeError = {
|
|
26530
26614
|
message: ({ schema }) => `must be ${schema}`,
|
|
26531
|
-
params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$
|
|
26615
|
+
params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1$s._)`{type: ${schema}}` : (0, codegen_1$s._)`{type: ${schemaValue}}`
|
|
26532
26616
|
};
|
|
26533
26617
|
function reportTypeError(it) {
|
|
26534
26618
|
const cxt = getTypeErrorContext(it);
|
|
26535
|
-
(0, errors_1.reportError)(cxt, typeError);
|
|
26619
|
+
(0, errors_1$2.reportError)(cxt, typeError);
|
|
26536
26620
|
}
|
|
26537
26621
|
dataType.reportTypeError = reportTypeError;
|
|
26538
26622
|
function getTypeErrorContext(it) {
|
|
26539
26623
|
const { gen, data, schema } = it;
|
|
26540
|
-
const schemaCode = (0, util_1$
|
|
26624
|
+
const schemaCode = (0, util_1$r.schemaRefOrVal)(it, schema, "type");
|
|
26541
26625
|
return {
|
|
26542
26626
|
gen,
|
|
26543
26627
|
keyword: "type",
|
|
@@ -26551,60 +26635,54 @@ function getTypeErrorContext(it) {
|
|
|
26551
26635
|
};
|
|
26552
26636
|
}
|
|
26553
26637
|
var defaults = {};
|
|
26554
|
-
|
|
26555
|
-
|
|
26556
|
-
|
|
26557
|
-
|
|
26558
|
-
|
|
26559
|
-
|
|
26560
|
-
|
|
26561
|
-
|
|
26562
|
-
|
|
26563
|
-
|
|
26564
|
-
|
|
26565
|
-
|
|
26566
|
-
|
|
26567
|
-
|
|
26568
|
-
|
|
26569
|
-
|
|
26570
|
-
|
|
26638
|
+
Object.defineProperty(defaults, "__esModule", { value: true });
|
|
26639
|
+
defaults.assignDefaults = void 0;
|
|
26640
|
+
const codegen_1$r = codegen;
|
|
26641
|
+
const util_1$q = util;
|
|
26642
|
+
function assignDefaults(it, ty) {
|
|
26643
|
+
const { properties: properties2, items: items2 } = it.schema;
|
|
26644
|
+
if (ty === "object" && properties2) {
|
|
26645
|
+
for (const key in properties2) {
|
|
26646
|
+
assignDefault(it, key, properties2[key].default);
|
|
26647
|
+
}
|
|
26648
|
+
} else if (ty === "array" && Array.isArray(items2)) {
|
|
26649
|
+
items2.forEach((sch, i) => assignDefault(it, i, sch.default));
|
|
26650
|
+
}
|
|
26651
|
+
}
|
|
26652
|
+
defaults.assignDefaults = assignDefaults;
|
|
26653
|
+
function assignDefault(it, prop, defaultValue) {
|
|
26654
|
+
const { gen, compositeRule, data, opts } = it;
|
|
26655
|
+
if (defaultValue === void 0)
|
|
26656
|
+
return;
|
|
26657
|
+
const childData = (0, codegen_1$r._)`${data}${(0, codegen_1$r.getProperty)(prop)}`;
|
|
26658
|
+
if (compositeRule) {
|
|
26659
|
+
(0, util_1$q.checkStrictMode)(it, `default is ignored for: ${childData}`);
|
|
26660
|
+
return;
|
|
26571
26661
|
}
|
|
26572
|
-
|
|
26573
|
-
|
|
26574
|
-
|
|
26575
|
-
if (defaultValue === void 0)
|
|
26576
|
-
return;
|
|
26577
|
-
const childData = (0, codegen_12._)`${data}${(0, codegen_12.getProperty)(prop)}`;
|
|
26578
|
-
if (compositeRule) {
|
|
26579
|
-
(0, util_12.checkStrictMode)(it, `default is ignored for: ${childData}`);
|
|
26580
|
-
return;
|
|
26581
|
-
}
|
|
26582
|
-
let condition = (0, codegen_12._)`${childData} === undefined`;
|
|
26583
|
-
if (opts.useDefaults === "empty") {
|
|
26584
|
-
condition = (0, codegen_12._)`${condition} || ${childData} === null || ${childData} === ""`;
|
|
26585
|
-
}
|
|
26586
|
-
gen.if(condition, (0, codegen_12._)`${childData} = ${(0, codegen_12.stringify)(defaultValue)}`);
|
|
26662
|
+
let condition = (0, codegen_1$r._)`${childData} === undefined`;
|
|
26663
|
+
if (opts.useDefaults === "empty") {
|
|
26664
|
+
condition = (0, codegen_1$r._)`${condition} || ${childData} === null || ${childData} === ""`;
|
|
26587
26665
|
}
|
|
26588
|
-
|
|
26666
|
+
gen.if(condition, (0, codegen_1$r._)`${childData} = ${(0, codegen_1$r.stringify)(defaultValue)}`);
|
|
26589
26667
|
}
|
|
26590
26668
|
var keyword = {};
|
|
26591
26669
|
var code = {};
|
|
26592
26670
|
Object.defineProperty(code, "__esModule", { value: true });
|
|
26593
26671
|
code.validateUnion = code.validateArray = code.usePattern = code.callValidateCode = code.schemaProperties = code.allSchemaProperties = code.noPropertyInData = code.propertyInData = code.isOwnProperty = code.hasPropFunc = code.reportMissingProp = code.checkMissingProp = code.checkReportMissingProp = void 0;
|
|
26594
|
-
const codegen_1$
|
|
26595
|
-
const util_1$
|
|
26596
|
-
const names_1$
|
|
26672
|
+
const codegen_1$q = codegen;
|
|
26673
|
+
const util_1$p = util;
|
|
26674
|
+
const names_1$5 = names$1;
|
|
26597
26675
|
const util_2$1 = util;
|
|
26598
26676
|
function checkReportMissingProp(cxt, prop) {
|
|
26599
26677
|
const { gen, data, it } = cxt;
|
|
26600
26678
|
gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
|
|
26601
|
-
cxt.setParams({ missingProperty: (0, codegen_1$
|
|
26679
|
+
cxt.setParams({ missingProperty: (0, codegen_1$q._)`${prop}` }, true);
|
|
26602
26680
|
cxt.error();
|
|
26603
26681
|
});
|
|
26604
26682
|
}
|
|
26605
26683
|
code.checkReportMissingProp = checkReportMissingProp;
|
|
26606
26684
|
function checkMissingProp({ gen, data, it: { opts } }, properties2, missing) {
|
|
26607
|
-
return (0, codegen_1$
|
|
26685
|
+
return (0, codegen_1$q.or)(...properties2.map((prop) => (0, codegen_1$q.and)(noPropertyInData(gen, data, prop, opts.ownProperties), (0, codegen_1$q._)`${missing} = ${prop}`)));
|
|
26608
26686
|
}
|
|
26609
26687
|
code.checkMissingProp = checkMissingProp;
|
|
26610
26688
|
function reportMissingProp(cxt, missing) {
|
|
@@ -26616,22 +26694,22 @@ function hasPropFunc(gen) {
|
|
|
26616
26694
|
return gen.scopeValue("func", {
|
|
26617
26695
|
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
26618
26696
|
ref: Object.prototype.hasOwnProperty,
|
|
26619
|
-
code: (0, codegen_1$
|
|
26697
|
+
code: (0, codegen_1$q._)`Object.prototype.hasOwnProperty`
|
|
26620
26698
|
});
|
|
26621
26699
|
}
|
|
26622
26700
|
code.hasPropFunc = hasPropFunc;
|
|
26623
26701
|
function isOwnProperty(gen, data, property) {
|
|
26624
|
-
return (0, codegen_1$
|
|
26702
|
+
return (0, codegen_1$q._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
|
|
26625
26703
|
}
|
|
26626
26704
|
code.isOwnProperty = isOwnProperty;
|
|
26627
26705
|
function propertyInData(gen, data, property, ownProperties) {
|
|
26628
|
-
const cond = (0, codegen_1$
|
|
26629
|
-
return ownProperties ? (0, codegen_1$
|
|
26706
|
+
const cond = (0, codegen_1$q._)`${data}${(0, codegen_1$q.getProperty)(property)} !== undefined`;
|
|
26707
|
+
return ownProperties ? (0, codegen_1$q._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond;
|
|
26630
26708
|
}
|
|
26631
26709
|
code.propertyInData = propertyInData;
|
|
26632
26710
|
function noPropertyInData(gen, data, property, ownProperties) {
|
|
26633
|
-
const cond = (0, codegen_1$
|
|
26634
|
-
return ownProperties ? (0, codegen_1$
|
|
26711
|
+
const cond = (0, codegen_1$q._)`${data}${(0, codegen_1$q.getProperty)(property)} === undefined`;
|
|
26712
|
+
return ownProperties ? (0, codegen_1$q.or)(cond, (0, codegen_1$q.not)(isOwnProperty(gen, data, property))) : cond;
|
|
26635
26713
|
}
|
|
26636
26714
|
code.noPropertyInData = noPropertyInData;
|
|
26637
26715
|
function allSchemaProperties(schemaMap) {
|
|
@@ -26639,24 +26717,24 @@ function allSchemaProperties(schemaMap) {
|
|
|
26639
26717
|
}
|
|
26640
26718
|
code.allSchemaProperties = allSchemaProperties;
|
|
26641
26719
|
function schemaProperties(it, schemaMap) {
|
|
26642
|
-
return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$
|
|
26720
|
+
return allSchemaProperties(schemaMap).filter((p) => !(0, util_1$p.alwaysValidSchema)(it, schemaMap[p]));
|
|
26643
26721
|
}
|
|
26644
26722
|
code.schemaProperties = schemaProperties;
|
|
26645
26723
|
function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
|
|
26646
|
-
const dataAndSchema = passSchema ? (0, codegen_1$
|
|
26724
|
+
const dataAndSchema = passSchema ? (0, codegen_1$q._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
|
|
26647
26725
|
const valCxt = [
|
|
26648
|
-
[names_1$
|
|
26649
|
-
[names_1$
|
|
26650
|
-
[names_1$
|
|
26651
|
-
[names_1$
|
|
26726
|
+
[names_1$5.default.instancePath, (0, codegen_1$q.strConcat)(names_1$5.default.instancePath, errorPath)],
|
|
26727
|
+
[names_1$5.default.parentData, it.parentData],
|
|
26728
|
+
[names_1$5.default.parentDataProperty, it.parentDataProperty],
|
|
26729
|
+
[names_1$5.default.rootData, names_1$5.default.rootData]
|
|
26652
26730
|
];
|
|
26653
26731
|
if (it.opts.dynamicRef)
|
|
26654
|
-
valCxt.push([names_1$
|
|
26655
|
-
const args = (0, codegen_1$
|
|
26656
|
-
return context !== codegen_1$
|
|
26732
|
+
valCxt.push([names_1$5.default.dynamicAnchors, names_1$5.default.dynamicAnchors]);
|
|
26733
|
+
const args = (0, codegen_1$q._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
|
|
26734
|
+
return context !== codegen_1$q.nil ? (0, codegen_1$q._)`${func}.call(${context}, ${args})` : (0, codegen_1$q._)`${func}(${args})`;
|
|
26657
26735
|
}
|
|
26658
26736
|
code.callValidateCode = callValidateCode;
|
|
26659
|
-
const newRegExp = (0, codegen_1$
|
|
26737
|
+
const newRegExp = (0, codegen_1$q._)`new RegExp`;
|
|
26660
26738
|
function usePattern({ gen, it: { opts } }, pattern2) {
|
|
26661
26739
|
const u = opts.unicodeRegExp ? "u" : "";
|
|
26662
26740
|
const { regExp } = opts.code;
|
|
@@ -26664,7 +26742,7 @@ function usePattern({ gen, it: { opts } }, pattern2) {
|
|
|
26664
26742
|
return gen.scopeValue("pattern", {
|
|
26665
26743
|
key: rx.toString(),
|
|
26666
26744
|
ref: rx,
|
|
26667
|
-
code: (0, codegen_1$
|
|
26745
|
+
code: (0, codegen_1$q._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2$1.useFunc)(gen, regExp)}(${pattern2}, ${u})`
|
|
26668
26746
|
});
|
|
26669
26747
|
}
|
|
26670
26748
|
code.usePattern = usePattern;
|
|
@@ -26680,14 +26758,14 @@ function validateArray(cxt) {
|
|
|
26680
26758
|
validateItems(() => gen.break());
|
|
26681
26759
|
return valid;
|
|
26682
26760
|
function validateItems(notValid) {
|
|
26683
|
-
const len = gen.const("len", (0, codegen_1$
|
|
26761
|
+
const len = gen.const("len", (0, codegen_1$q._)`${data}.length`);
|
|
26684
26762
|
gen.forRange("i", 0, len, (i) => {
|
|
26685
26763
|
cxt.subschema({
|
|
26686
26764
|
keyword: keyword2,
|
|
26687
26765
|
dataProp: i,
|
|
26688
|
-
dataPropType: util_1$
|
|
26766
|
+
dataPropType: util_1$p.Type.Num
|
|
26689
26767
|
}, valid);
|
|
26690
|
-
gen.if((0, codegen_1$
|
|
26768
|
+
gen.if((0, codegen_1$q.not)(valid), notValid);
|
|
26691
26769
|
});
|
|
26692
26770
|
}
|
|
26693
26771
|
}
|
|
@@ -26696,7 +26774,7 @@ function validateUnion(cxt) {
|
|
|
26696
26774
|
const { gen, schema, keyword: keyword2, it } = cxt;
|
|
26697
26775
|
if (!Array.isArray(schema))
|
|
26698
26776
|
throw new Error("ajv implementation error");
|
|
26699
|
-
const alwaysValid = schema.some((sch) => (0, util_1$
|
|
26777
|
+
const alwaysValid = schema.some((sch) => (0, util_1$p.alwaysValidSchema)(it, sch));
|
|
26700
26778
|
if (alwaysValid && !it.opts.unevaluated)
|
|
26701
26779
|
return;
|
|
26702
26780
|
const valid = gen.let("valid", false);
|
|
@@ -26707,214 +26785,202 @@ function validateUnion(cxt) {
|
|
|
26707
26785
|
schemaProp: i,
|
|
26708
26786
|
compositeRule: true
|
|
26709
26787
|
}, schValid);
|
|
26710
|
-
gen.assign(valid, (0, codegen_1$
|
|
26788
|
+
gen.assign(valid, (0, codegen_1$q._)`${valid} || ${schValid}`);
|
|
26711
26789
|
const merged = cxt.mergeValidEvaluated(schCxt, schValid);
|
|
26712
26790
|
if (!merged)
|
|
26713
|
-
gen.if((0, codegen_1$
|
|
26791
|
+
gen.if((0, codegen_1$q.not)(valid));
|
|
26714
26792
|
}));
|
|
26715
26793
|
cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
|
|
26716
26794
|
}
|
|
26717
26795
|
code.validateUnion = validateUnion;
|
|
26718
|
-
|
|
26719
|
-
|
|
26720
|
-
|
|
26721
|
-
|
|
26722
|
-
|
|
26723
|
-
|
|
26724
|
-
|
|
26725
|
-
const
|
|
26726
|
-
const
|
|
26727
|
-
const
|
|
26728
|
-
|
|
26729
|
-
|
|
26730
|
-
|
|
26731
|
-
|
|
26732
|
-
|
|
26733
|
-
|
|
26734
|
-
|
|
26735
|
-
|
|
26736
|
-
|
|
26737
|
-
|
|
26738
|
-
|
|
26739
|
-
|
|
26740
|
-
|
|
26741
|
-
|
|
26742
|
-
|
|
26743
|
-
}
|
|
26744
|
-
|
|
26745
|
-
|
|
26746
|
-
|
|
26747
|
-
|
|
26748
|
-
|
|
26749
|
-
|
|
26750
|
-
|
|
26751
|
-
|
|
26752
|
-
|
|
26753
|
-
|
|
26754
|
-
|
|
26755
|
-
|
|
26756
|
-
|
|
26757
|
-
|
|
26758
|
-
|
|
26759
|
-
|
|
26760
|
-
|
|
26761
|
-
const ruleErrs = def2.async ? validateAsync() : validateSync();
|
|
26762
|
-
if (def2.modifying)
|
|
26763
|
-
modifyData(cxt);
|
|
26764
|
-
reportErrs(() => addErrs(cxt, ruleErrs));
|
|
26765
|
-
}
|
|
26766
|
-
}
|
|
26767
|
-
function validateAsync() {
|
|
26768
|
-
const ruleErrs = gen.let("ruleErrs", null);
|
|
26769
|
-
gen.try(() => assignValid((0, codegen_12._)`await `), (e) => gen.assign(valid, false).if((0, codegen_12._)`${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_12._)`${e}.errors`), () => gen.throw(e)));
|
|
26770
|
-
return ruleErrs;
|
|
26771
|
-
}
|
|
26772
|
-
function validateSync() {
|
|
26773
|
-
const validateErrs = (0, codegen_12._)`${validateRef}.errors`;
|
|
26774
|
-
gen.assign(validateErrs, null);
|
|
26775
|
-
assignValid(codegen_12.nil);
|
|
26776
|
-
return validateErrs;
|
|
26777
|
-
}
|
|
26778
|
-
function assignValid(_await = def2.async ? (0, codegen_12._)`await ` : codegen_12.nil) {
|
|
26779
|
-
const passCxt = it.opts.passContext ? names_12.default.this : names_12.default.self;
|
|
26780
|
-
const passSchema = !("compile" in def2 && !$data || def2.schema === false);
|
|
26781
|
-
gen.assign(valid, (0, codegen_12._)`${_await}${(0, code_12.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
|
|
26782
|
-
}
|
|
26783
|
-
function reportErrs(errors2) {
|
|
26784
|
-
var _a2;
|
|
26785
|
-
gen.if((0, codegen_12.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
|
|
26796
|
+
Object.defineProperty(keyword, "__esModule", { value: true });
|
|
26797
|
+
keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
|
|
26798
|
+
const codegen_1$p = codegen;
|
|
26799
|
+
const names_1$4 = names$1;
|
|
26800
|
+
const code_1$9 = code;
|
|
26801
|
+
const errors_1$1 = errors;
|
|
26802
|
+
function macroKeywordCode(cxt, def2) {
|
|
26803
|
+
const { gen, keyword: keyword2, schema, parentSchema, it } = cxt;
|
|
26804
|
+
const macroSchema = def2.macro.call(it.self, schema, parentSchema, it);
|
|
26805
|
+
const schemaRef = useKeyword(gen, keyword2, macroSchema);
|
|
26806
|
+
if (it.opts.validateSchema !== false)
|
|
26807
|
+
it.self.validateSchema(macroSchema, true);
|
|
26808
|
+
const valid = gen.name("valid");
|
|
26809
|
+
cxt.subschema({
|
|
26810
|
+
schema: macroSchema,
|
|
26811
|
+
schemaPath: codegen_1$p.nil,
|
|
26812
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}`,
|
|
26813
|
+
topSchemaRef: schemaRef,
|
|
26814
|
+
compositeRule: true
|
|
26815
|
+
}, valid);
|
|
26816
|
+
cxt.pass(valid, () => cxt.error(true));
|
|
26817
|
+
}
|
|
26818
|
+
keyword.macroKeywordCode = macroKeywordCode;
|
|
26819
|
+
function funcKeywordCode(cxt, def2) {
|
|
26820
|
+
var _a;
|
|
26821
|
+
const { gen, keyword: keyword2, schema, parentSchema, $data, it } = cxt;
|
|
26822
|
+
checkAsyncKeyword(it, def2);
|
|
26823
|
+
const validate2 = !$data && def2.compile ? def2.compile.call(it.self, schema, parentSchema, it) : def2.validate;
|
|
26824
|
+
const validateRef = useKeyword(gen, keyword2, validate2);
|
|
26825
|
+
const valid = gen.let("valid");
|
|
26826
|
+
cxt.block$data(valid, validateKeyword);
|
|
26827
|
+
cxt.ok((_a = def2.valid) !== null && _a !== void 0 ? _a : valid);
|
|
26828
|
+
function validateKeyword() {
|
|
26829
|
+
if (def2.errors === false) {
|
|
26830
|
+
assignValid();
|
|
26831
|
+
if (def2.modifying)
|
|
26832
|
+
modifyData(cxt);
|
|
26833
|
+
reportErrs(() => cxt.error());
|
|
26834
|
+
} else {
|
|
26835
|
+
const ruleErrs = def2.async ? validateAsync() : validateSync();
|
|
26836
|
+
if (def2.modifying)
|
|
26837
|
+
modifyData(cxt);
|
|
26838
|
+
reportErrs(() => addErrs(cxt, ruleErrs));
|
|
26786
26839
|
}
|
|
26787
26840
|
}
|
|
26788
|
-
|
|
26789
|
-
|
|
26790
|
-
|
|
26791
|
-
|
|
26792
|
-
}
|
|
26793
|
-
function
|
|
26794
|
-
const
|
|
26795
|
-
gen.
|
|
26796
|
-
|
|
26797
|
-
|
|
26798
|
-
|
|
26799
|
-
|
|
26800
|
-
|
|
26801
|
-
|
|
26802
|
-
|
|
26803
|
-
}
|
|
26804
|
-
function
|
|
26805
|
-
|
|
26806
|
-
|
|
26807
|
-
|
|
26808
|
-
|
|
26809
|
-
|
|
26810
|
-
|
|
26811
|
-
}
|
|
26812
|
-
|
|
26813
|
-
|
|
26814
|
-
|
|
26815
|
-
|
|
26816
|
-
|
|
26817
|
-
|
|
26818
|
-
|
|
26819
|
-
|
|
26820
|
-
|
|
26821
|
-
|
|
26822
|
-
|
|
26823
|
-
|
|
26824
|
-
|
|
26825
|
-
|
|
26826
|
-
|
|
26827
|
-
|
|
26828
|
-
|
|
26829
|
-
|
|
26841
|
+
function validateAsync() {
|
|
26842
|
+
const ruleErrs = gen.let("ruleErrs", null);
|
|
26843
|
+
gen.try(() => assignValid((0, codegen_1$p._)`await `), (e) => gen.assign(valid, false).if((0, codegen_1$p._)`${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_1$p._)`${e}.errors`), () => gen.throw(e)));
|
|
26844
|
+
return ruleErrs;
|
|
26845
|
+
}
|
|
26846
|
+
function validateSync() {
|
|
26847
|
+
const validateErrs = (0, codegen_1$p._)`${validateRef}.errors`;
|
|
26848
|
+
gen.assign(validateErrs, null);
|
|
26849
|
+
assignValid(codegen_1$p.nil);
|
|
26850
|
+
return validateErrs;
|
|
26851
|
+
}
|
|
26852
|
+
function assignValid(_await = def2.async ? (0, codegen_1$p._)`await ` : codegen_1$p.nil) {
|
|
26853
|
+
const passCxt = it.opts.passContext ? names_1$4.default.this : names_1$4.default.self;
|
|
26854
|
+
const passSchema = !("compile" in def2 && !$data || def2.schema === false);
|
|
26855
|
+
gen.assign(valid, (0, codegen_1$p._)`${_await}${(0, code_1$9.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def2.modifying);
|
|
26856
|
+
}
|
|
26857
|
+
function reportErrs(errors2) {
|
|
26858
|
+
var _a2;
|
|
26859
|
+
gen.if((0, codegen_1$p.not)((_a2 = def2.valid) !== null && _a2 !== void 0 ? _a2 : valid), errors2);
|
|
26860
|
+
}
|
|
26861
|
+
}
|
|
26862
|
+
keyword.funcKeywordCode = funcKeywordCode;
|
|
26863
|
+
function modifyData(cxt) {
|
|
26864
|
+
const { gen, data, it } = cxt;
|
|
26865
|
+
gen.if(it.parentData, () => gen.assign(data, (0, codegen_1$p._)`${it.parentData}[${it.parentDataProperty}]`));
|
|
26866
|
+
}
|
|
26867
|
+
function addErrs(cxt, errs) {
|
|
26868
|
+
const { gen } = cxt;
|
|
26869
|
+
gen.if((0, codegen_1$p._)`Array.isArray(${errs})`, () => {
|
|
26870
|
+
gen.assign(names_1$4.default.vErrors, (0, codegen_1$p._)`${names_1$4.default.vErrors} === null ? ${errs} : ${names_1$4.default.vErrors}.concat(${errs})`).assign(names_1$4.default.errors, (0, codegen_1$p._)`${names_1$4.default.vErrors}.length`);
|
|
26871
|
+
(0, errors_1$1.extendErrors)(cxt);
|
|
26872
|
+
}, () => cxt.error());
|
|
26873
|
+
}
|
|
26874
|
+
function checkAsyncKeyword({ schemaEnv }, def2) {
|
|
26875
|
+
if (def2.async && !schemaEnv.$async)
|
|
26876
|
+
throw new Error("async keyword in sync schema");
|
|
26877
|
+
}
|
|
26878
|
+
function useKeyword(gen, keyword2, result) {
|
|
26879
|
+
if (result === void 0)
|
|
26880
|
+
throw new Error(`keyword "${keyword2}" failed to compile`);
|
|
26881
|
+
return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : { ref: result, code: (0, codegen_1$p.stringify)(result) });
|
|
26882
|
+
}
|
|
26883
|
+
function validSchemaType(schema, schemaType, allowUndefined = false) {
|
|
26884
|
+
return !schemaType.length || schemaType.some((st) => st === "array" ? Array.isArray(schema) : st === "object" ? schema && typeof schema == "object" && !Array.isArray(schema) : typeof schema == st || allowUndefined && typeof schema == "undefined");
|
|
26885
|
+
}
|
|
26886
|
+
keyword.validSchemaType = validSchemaType;
|
|
26887
|
+
function validateKeywordUsage({ schema, opts, self: self2, errSchemaPath }, def2, keyword2) {
|
|
26888
|
+
if (Array.isArray(def2.keyword) ? !def2.keyword.includes(keyword2) : def2.keyword !== keyword2) {
|
|
26889
|
+
throw new Error("ajv implementation error");
|
|
26890
|
+
}
|
|
26891
|
+
const deps = def2.dependencies;
|
|
26892
|
+
if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) {
|
|
26893
|
+
throw new Error(`parent schema must have dependencies of ${keyword2}: ${deps.join(",")}`);
|
|
26894
|
+
}
|
|
26895
|
+
if (def2.validateSchema) {
|
|
26896
|
+
const valid = def2.validateSchema(schema[keyword2]);
|
|
26897
|
+
if (!valid) {
|
|
26898
|
+
const msg = `keyword "${keyword2}" value is invalid at path "${errSchemaPath}": ` + self2.errorsText(def2.validateSchema.errors);
|
|
26899
|
+
if (opts.validateSchema === "log")
|
|
26900
|
+
self2.logger.error(msg);
|
|
26901
|
+
else
|
|
26902
|
+
throw new Error(msg);
|
|
26830
26903
|
}
|
|
26831
26904
|
}
|
|
26832
|
-
keyword.validateKeywordUsage = validateKeywordUsage;
|
|
26833
|
-
return keyword;
|
|
26834
26905
|
}
|
|
26906
|
+
keyword.validateKeywordUsage = validateKeywordUsage;
|
|
26835
26907
|
var subschema = {};
|
|
26836
|
-
|
|
26837
|
-
|
|
26838
|
-
|
|
26839
|
-
|
|
26840
|
-
|
|
26841
|
-
|
|
26842
|
-
|
|
26843
|
-
|
|
26844
|
-
|
|
26845
|
-
|
|
26846
|
-
|
|
26847
|
-
|
|
26848
|
-
|
|
26849
|
-
|
|
26850
|
-
|
|
26851
|
-
|
|
26852
|
-
|
|
26853
|
-
|
|
26854
|
-
|
|
26855
|
-
|
|
26856
|
-
|
|
26857
|
-
|
|
26858
|
-
|
|
26859
|
-
}
|
|
26860
|
-
if (schema !== void 0) {
|
|
26861
|
-
if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
|
|
26862
|
-
throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
|
|
26863
|
-
}
|
|
26864
|
-
return {
|
|
26865
|
-
schema,
|
|
26866
|
-
schemaPath,
|
|
26867
|
-
topSchemaRef,
|
|
26868
|
-
errSchemaPath
|
|
26869
|
-
};
|
|
26908
|
+
Object.defineProperty(subschema, "__esModule", { value: true });
|
|
26909
|
+
subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
|
|
26910
|
+
const codegen_1$o = codegen;
|
|
26911
|
+
const util_1$o = util;
|
|
26912
|
+
function getSubschema(it, { keyword: keyword2, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
|
|
26913
|
+
if (keyword2 !== void 0 && schema !== void 0) {
|
|
26914
|
+
throw new Error('both "keyword" and "schema" passed, only one allowed');
|
|
26915
|
+
}
|
|
26916
|
+
if (keyword2 !== void 0) {
|
|
26917
|
+
const sch = it.schema[keyword2];
|
|
26918
|
+
return schemaProp === void 0 ? {
|
|
26919
|
+
schema: sch,
|
|
26920
|
+
schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}`,
|
|
26921
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}`
|
|
26922
|
+
} : {
|
|
26923
|
+
schema: sch[schemaProp],
|
|
26924
|
+
schemaPath: (0, codegen_1$o._)`${it.schemaPath}${(0, codegen_1$o.getProperty)(keyword2)}${(0, codegen_1$o.getProperty)(schemaProp)}`,
|
|
26925
|
+
errSchemaPath: `${it.errSchemaPath}/${keyword2}/${(0, util_1$o.escapeFragment)(schemaProp)}`
|
|
26926
|
+
};
|
|
26927
|
+
}
|
|
26928
|
+
if (schema !== void 0) {
|
|
26929
|
+
if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) {
|
|
26930
|
+
throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');
|
|
26870
26931
|
}
|
|
26871
|
-
|
|
26872
|
-
|
|
26873
|
-
|
|
26874
|
-
|
|
26875
|
-
|
|
26876
|
-
|
|
26877
|
-
|
|
26878
|
-
|
|
26879
|
-
|
|
26880
|
-
|
|
26881
|
-
|
|
26882
|
-
|
|
26883
|
-
|
|
26884
|
-
|
|
26885
|
-
|
|
26886
|
-
|
|
26887
|
-
|
|
26888
|
-
|
|
26889
|
-
|
|
26890
|
-
|
|
26891
|
-
|
|
26892
|
-
|
|
26893
|
-
|
|
26894
|
-
|
|
26895
|
-
|
|
26896
|
-
|
|
26897
|
-
|
|
26898
|
-
subschema2.
|
|
26899
|
-
|
|
26900
|
-
|
|
26901
|
-
|
|
26902
|
-
|
|
26903
|
-
|
|
26904
|
-
|
|
26905
|
-
|
|
26906
|
-
|
|
26907
|
-
|
|
26908
|
-
|
|
26909
|
-
|
|
26910
|
-
|
|
26911
|
-
|
|
26912
|
-
|
|
26913
|
-
|
|
26914
|
-
|
|
26915
|
-
|
|
26916
|
-
|
|
26917
|
-
|
|
26932
|
+
return {
|
|
26933
|
+
schema,
|
|
26934
|
+
schemaPath,
|
|
26935
|
+
topSchemaRef,
|
|
26936
|
+
errSchemaPath
|
|
26937
|
+
};
|
|
26938
|
+
}
|
|
26939
|
+
throw new Error('either "keyword" or "schema" must be passed');
|
|
26940
|
+
}
|
|
26941
|
+
subschema.getSubschema = getSubschema;
|
|
26942
|
+
function extendSubschemaData(subschema2, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName }) {
|
|
26943
|
+
if (data !== void 0 && dataProp !== void 0) {
|
|
26944
|
+
throw new Error('both "data" and "dataProp" passed, only one allowed');
|
|
26945
|
+
}
|
|
26946
|
+
const { gen } = it;
|
|
26947
|
+
if (dataProp !== void 0) {
|
|
26948
|
+
const { errorPath, dataPathArr, opts } = it;
|
|
26949
|
+
const nextData = gen.let("data", (0, codegen_1$o._)`${it.data}${(0, codegen_1$o.getProperty)(dataProp)}`, true);
|
|
26950
|
+
dataContextProps(nextData);
|
|
26951
|
+
subschema2.errorPath = (0, codegen_1$o.str)`${errorPath}${(0, util_1$o.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
|
|
26952
|
+
subschema2.parentDataProperty = (0, codegen_1$o._)`${dataProp}`;
|
|
26953
|
+
subschema2.dataPathArr = [...dataPathArr, subschema2.parentDataProperty];
|
|
26954
|
+
}
|
|
26955
|
+
if (data !== void 0) {
|
|
26956
|
+
const nextData = data instanceof codegen_1$o.Name ? data : gen.let("data", data, true);
|
|
26957
|
+
dataContextProps(nextData);
|
|
26958
|
+
if (propertyName !== void 0)
|
|
26959
|
+
subschema2.propertyName = propertyName;
|
|
26960
|
+
}
|
|
26961
|
+
if (dataTypes)
|
|
26962
|
+
subschema2.dataTypes = dataTypes;
|
|
26963
|
+
function dataContextProps(_nextData) {
|
|
26964
|
+
subschema2.data = _nextData;
|
|
26965
|
+
subschema2.dataLevel = it.dataLevel + 1;
|
|
26966
|
+
subschema2.dataTypes = [];
|
|
26967
|
+
it.definedProperties = /* @__PURE__ */ new Set();
|
|
26968
|
+
subschema2.parentData = it.data;
|
|
26969
|
+
subschema2.dataNames = [...it.dataNames, _nextData];
|
|
26970
|
+
}
|
|
26971
|
+
}
|
|
26972
|
+
subschema.extendSubschemaData = extendSubschemaData;
|
|
26973
|
+
function extendSubschemaMode(subschema2, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
|
|
26974
|
+
if (compositeRule !== void 0)
|
|
26975
|
+
subschema2.compositeRule = compositeRule;
|
|
26976
|
+
if (createErrors !== void 0)
|
|
26977
|
+
subschema2.createErrors = createErrors;
|
|
26978
|
+
if (allErrors !== void 0)
|
|
26979
|
+
subschema2.allErrors = allErrors;
|
|
26980
|
+
subschema2.jtdDiscriminator = jtdDiscriminator;
|
|
26981
|
+
subschema2.jtdMetadata = jtdMetadata;
|
|
26982
|
+
}
|
|
26983
|
+
subschema.extendSubschemaMode = extendSubschemaMode;
|
|
26918
26984
|
var resolve$2 = {};
|
|
26919
26985
|
var fastDeepEqual = function equal(a, b) {
|
|
26920
26986
|
if (a === b) return true;
|
|
@@ -27029,7 +27095,7 @@ function escapeJsonPtr(str) {
|
|
|
27029
27095
|
var jsonSchemaTraverseExports = jsonSchemaTraverse.exports;
|
|
27030
27096
|
Object.defineProperty(resolve$2, "__esModule", { value: true });
|
|
27031
27097
|
resolve$2.getSchemaRefs = resolve$2.resolveUrl = resolve$2.normalizeId = resolve$2._getFullPath = resolve$2.getFullPath = resolve$2.inlineRef = void 0;
|
|
27032
|
-
const util_1$
|
|
27098
|
+
const util_1$n = util;
|
|
27033
27099
|
const equal$3 = fastDeepEqual;
|
|
27034
27100
|
const traverse = jsonSchemaTraverseExports;
|
|
27035
27101
|
const SIMPLE_INLINED = /* @__PURE__ */ new Set([
|
|
@@ -27088,7 +27154,7 @@ function countKeys(schema) {
|
|
|
27088
27154
|
if (SIMPLE_INLINED.has(key))
|
|
27089
27155
|
continue;
|
|
27090
27156
|
if (typeof schema[key] == "object") {
|
|
27091
|
-
(0, util_1$
|
|
27157
|
+
(0, util_1$n.eachItem)(schema[key], (sch) => count += countKeys(sch));
|
|
27092
27158
|
}
|
|
27093
27159
|
if (count === Infinity)
|
|
27094
27160
|
return Infinity;
|
|
@@ -27176,528 +27242,516 @@ function getSchemaRefs(schema, baseId) {
|
|
|
27176
27242
|
}
|
|
27177
27243
|
}
|
|
27178
27244
|
resolve$2.getSchemaRefs = getSchemaRefs;
|
|
27179
|
-
|
|
27180
|
-
|
|
27181
|
-
|
|
27182
|
-
|
|
27183
|
-
|
|
27184
|
-
|
|
27185
|
-
|
|
27186
|
-
|
|
27187
|
-
|
|
27188
|
-
|
|
27189
|
-
|
|
27190
|
-
|
|
27191
|
-
|
|
27192
|
-
|
|
27193
|
-
|
|
27194
|
-
|
|
27195
|
-
|
|
27196
|
-
|
|
27197
|
-
|
|
27198
|
-
|
|
27199
|
-
checkKeywords(it);
|
|
27200
|
-
if (schemaCxtHasRules(it)) {
|
|
27201
|
-
topSchemaObjCode(it);
|
|
27202
|
-
return;
|
|
27203
|
-
}
|
|
27245
|
+
Object.defineProperty(validate, "__esModule", { value: true });
|
|
27246
|
+
validate.getData = validate.KeywordCxt = validate.validateFunctionCode = void 0;
|
|
27247
|
+
const boolSchema_1 = boolSchema;
|
|
27248
|
+
const dataType_1$1 = dataType;
|
|
27249
|
+
const applicability_1 = applicability;
|
|
27250
|
+
const dataType_2 = dataType;
|
|
27251
|
+
const defaults_1 = defaults;
|
|
27252
|
+
const keyword_1 = keyword;
|
|
27253
|
+
const subschema_1 = subschema;
|
|
27254
|
+
const codegen_1$n = codegen;
|
|
27255
|
+
const names_1$3 = names$1;
|
|
27256
|
+
const resolve_1$2 = resolve$2;
|
|
27257
|
+
const util_1$m = util;
|
|
27258
|
+
const errors_1 = errors;
|
|
27259
|
+
function validateFunctionCode(it) {
|
|
27260
|
+
if (isSchemaObj(it)) {
|
|
27261
|
+
checkKeywords(it);
|
|
27262
|
+
if (schemaCxtHasRules(it)) {
|
|
27263
|
+
topSchemaObjCode(it);
|
|
27264
|
+
return;
|
|
27204
27265
|
}
|
|
27205
|
-
validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
|
|
27206
|
-
}
|
|
27207
|
-
validate.validateFunctionCode = validateFunctionCode;
|
|
27208
|
-
function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
|
|
27209
|
-
if (opts.code.es5) {
|
|
27210
|
-
gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${names_12.default.valCxt}`, schemaEnv.$async, () => {
|
|
27211
|
-
gen.code((0, codegen_12._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
|
|
27212
|
-
destructureValCxtES5(gen, opts);
|
|
27213
|
-
gen.code(body);
|
|
27214
|
-
});
|
|
27215
|
-
} else {
|
|
27216
|
-
gen.func(validateName, (0, codegen_12._)`${names_12.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
|
|
27217
|
-
}
|
|
27218
|
-
}
|
|
27219
|
-
function destructureValCxt(opts) {
|
|
27220
|
-
return (0, codegen_12._)`{${names_12.default.instancePath}="", ${names_12.default.parentData}, ${names_12.default.parentDataProperty}, ${names_12.default.rootData}=${names_12.default.data}${opts.dynamicRef ? (0, codegen_12._)`, ${names_12.default.dynamicAnchors}={}` : codegen_12.nil}}={}`;
|
|
27221
|
-
}
|
|
27222
|
-
function destructureValCxtES5(gen, opts) {
|
|
27223
|
-
gen.if(names_12.default.valCxt, () => {
|
|
27224
|
-
gen.var(names_12.default.instancePath, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.instancePath}`);
|
|
27225
|
-
gen.var(names_12.default.parentData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentData}`);
|
|
27226
|
-
gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.parentDataProperty}`);
|
|
27227
|
-
gen.var(names_12.default.rootData, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.rootData}`);
|
|
27228
|
-
if (opts.dynamicRef)
|
|
27229
|
-
gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`${names_12.default.valCxt}.${names_12.default.dynamicAnchors}`);
|
|
27230
|
-
}, () => {
|
|
27231
|
-
gen.var(names_12.default.instancePath, (0, codegen_12._)`""`);
|
|
27232
|
-
gen.var(names_12.default.parentData, (0, codegen_12._)`undefined`);
|
|
27233
|
-
gen.var(names_12.default.parentDataProperty, (0, codegen_12._)`undefined`);
|
|
27234
|
-
gen.var(names_12.default.rootData, names_12.default.data);
|
|
27235
|
-
if (opts.dynamicRef)
|
|
27236
|
-
gen.var(names_12.default.dynamicAnchors, (0, codegen_12._)`{}`);
|
|
27237
|
-
});
|
|
27238
27266
|
}
|
|
27239
|
-
|
|
27240
|
-
|
|
27241
|
-
|
|
27242
|
-
|
|
27243
|
-
|
|
27244
|
-
|
|
27245
|
-
gen.
|
|
27246
|
-
gen
|
|
27247
|
-
|
|
27248
|
-
resetEvaluated(it);
|
|
27249
|
-
typeAndKeywords(it);
|
|
27250
|
-
returnResults(it);
|
|
27267
|
+
validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
|
|
27268
|
+
}
|
|
27269
|
+
validate.validateFunctionCode = validateFunctionCode;
|
|
27270
|
+
function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
|
|
27271
|
+
if (opts.code.es5) {
|
|
27272
|
+
gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${names_1$3.default.valCxt}`, schemaEnv.$async, () => {
|
|
27273
|
+
gen.code((0, codegen_1$n._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
|
|
27274
|
+
destructureValCxtES5(gen, opts);
|
|
27275
|
+
gen.code(body);
|
|
27251
27276
|
});
|
|
27252
|
-
|
|
27253
|
-
|
|
27254
|
-
|
|
27255
|
-
|
|
27256
|
-
|
|
27257
|
-
|
|
27258
|
-
|
|
27259
|
-
|
|
27260
|
-
|
|
27261
|
-
|
|
27262
|
-
|
|
27263
|
-
|
|
27264
|
-
|
|
27265
|
-
if (
|
|
27266
|
-
|
|
27267
|
-
|
|
27268
|
-
|
|
27269
|
-
|
|
27270
|
-
|
|
27271
|
-
|
|
27272
|
-
(
|
|
27273
|
-
|
|
27274
|
-
|
|
27275
|
-
|
|
27276
|
-
|
|
27277
|
-
|
|
27278
|
-
|
|
27279
|
-
return true;
|
|
27280
|
-
return false;
|
|
27281
|
-
}
|
|
27282
|
-
function isSchemaObj(it) {
|
|
27283
|
-
return typeof it.schema != "boolean";
|
|
27284
|
-
}
|
|
27285
|
-
function subSchemaObjCode(it, valid) {
|
|
27286
|
-
const { schema, gen, opts } = it;
|
|
27277
|
+
} else {
|
|
27278
|
+
gen.func(validateName, (0, codegen_1$n._)`${names_1$3.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
|
|
27279
|
+
}
|
|
27280
|
+
}
|
|
27281
|
+
function destructureValCxt(opts) {
|
|
27282
|
+
return (0, codegen_1$n._)`{${names_1$3.default.instancePath}="", ${names_1$3.default.parentData}, ${names_1$3.default.parentDataProperty}, ${names_1$3.default.rootData}=${names_1$3.default.data}${opts.dynamicRef ? (0, codegen_1$n._)`, ${names_1$3.default.dynamicAnchors}={}` : codegen_1$n.nil}}={}`;
|
|
27283
|
+
}
|
|
27284
|
+
function destructureValCxtES5(gen, opts) {
|
|
27285
|
+
gen.if(names_1$3.default.valCxt, () => {
|
|
27286
|
+
gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.instancePath}`);
|
|
27287
|
+
gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentData}`);
|
|
27288
|
+
gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.parentDataProperty}`);
|
|
27289
|
+
gen.var(names_1$3.default.rootData, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.rootData}`);
|
|
27290
|
+
if (opts.dynamicRef)
|
|
27291
|
+
gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`${names_1$3.default.valCxt}.${names_1$3.default.dynamicAnchors}`);
|
|
27292
|
+
}, () => {
|
|
27293
|
+
gen.var(names_1$3.default.instancePath, (0, codegen_1$n._)`""`);
|
|
27294
|
+
gen.var(names_1$3.default.parentData, (0, codegen_1$n._)`undefined`);
|
|
27295
|
+
gen.var(names_1$3.default.parentDataProperty, (0, codegen_1$n._)`undefined`);
|
|
27296
|
+
gen.var(names_1$3.default.rootData, names_1$3.default.data);
|
|
27297
|
+
if (opts.dynamicRef)
|
|
27298
|
+
gen.var(names_1$3.default.dynamicAnchors, (0, codegen_1$n._)`{}`);
|
|
27299
|
+
});
|
|
27300
|
+
}
|
|
27301
|
+
function topSchemaObjCode(it) {
|
|
27302
|
+
const { schema, opts, gen } = it;
|
|
27303
|
+
validateFunction(it, () => {
|
|
27287
27304
|
if (opts.$comment && schema.$comment)
|
|
27288
27305
|
commentKeyword(it);
|
|
27289
|
-
|
|
27290
|
-
|
|
27291
|
-
|
|
27292
|
-
|
|
27293
|
-
|
|
27294
|
-
|
|
27295
|
-
|
|
27296
|
-
|
|
27297
|
-
|
|
27298
|
-
|
|
27299
|
-
|
|
27300
|
-
|
|
27301
|
-
|
|
27302
|
-
|
|
27303
|
-
|
|
27304
|
-
|
|
27305
|
-
|
|
27306
|
-
|
|
27307
|
-
|
|
27308
|
-
|
|
27309
|
-
|
|
27310
|
-
|
|
27311
|
-
|
|
27312
|
-
|
|
27313
|
-
|
|
27314
|
-
|
|
27315
|
-
(0, util_12.checkStrictMode)(it, "default is ignored in the schema root");
|
|
27306
|
+
checkNoDefault(it);
|
|
27307
|
+
gen.let(names_1$3.default.vErrors, null);
|
|
27308
|
+
gen.let(names_1$3.default.errors, 0);
|
|
27309
|
+
if (opts.unevaluated)
|
|
27310
|
+
resetEvaluated(it);
|
|
27311
|
+
typeAndKeywords(it);
|
|
27312
|
+
returnResults(it);
|
|
27313
|
+
});
|
|
27314
|
+
return;
|
|
27315
|
+
}
|
|
27316
|
+
function resetEvaluated(it) {
|
|
27317
|
+
const { gen, validateName } = it;
|
|
27318
|
+
it.evaluated = gen.const("evaluated", (0, codegen_1$n._)`${validateName}.evaluated`);
|
|
27319
|
+
gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.props`, (0, codegen_1$n._)`undefined`));
|
|
27320
|
+
gen.if((0, codegen_1$n._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1$n._)`${it.evaluated}.items`, (0, codegen_1$n._)`undefined`));
|
|
27321
|
+
}
|
|
27322
|
+
function funcSourceUrl(schema, opts) {
|
|
27323
|
+
const schId = typeof schema == "object" && schema[opts.schemaId];
|
|
27324
|
+
return schId && (opts.code.source || opts.code.process) ? (0, codegen_1$n._)`/*# sourceURL=${schId} */` : codegen_1$n.nil;
|
|
27325
|
+
}
|
|
27326
|
+
function subschemaCode(it, valid) {
|
|
27327
|
+
if (isSchemaObj(it)) {
|
|
27328
|
+
checkKeywords(it);
|
|
27329
|
+
if (schemaCxtHasRules(it)) {
|
|
27330
|
+
subSchemaObjCode(it, valid);
|
|
27331
|
+
return;
|
|
27316
27332
|
}
|
|
27317
27333
|
}
|
|
27318
|
-
|
|
27319
|
-
|
|
27320
|
-
|
|
27321
|
-
|
|
27322
|
-
|
|
27323
|
-
|
|
27324
|
-
if (
|
|
27325
|
-
|
|
27326
|
-
|
|
27327
|
-
|
|
27328
|
-
|
|
27329
|
-
|
|
27330
|
-
|
|
27331
|
-
|
|
27332
|
-
|
|
27333
|
-
|
|
27334
|
-
|
|
27335
|
-
|
|
27334
|
+
(0, boolSchema_1.boolOrEmptySchema)(it, valid);
|
|
27335
|
+
}
|
|
27336
|
+
function schemaCxtHasRules({ schema, self: self2 }) {
|
|
27337
|
+
if (typeof schema == "boolean")
|
|
27338
|
+
return !schema;
|
|
27339
|
+
for (const key in schema)
|
|
27340
|
+
if (self2.RULES.all[key])
|
|
27341
|
+
return true;
|
|
27342
|
+
return false;
|
|
27343
|
+
}
|
|
27344
|
+
function isSchemaObj(it) {
|
|
27345
|
+
return typeof it.schema != "boolean";
|
|
27346
|
+
}
|
|
27347
|
+
function subSchemaObjCode(it, valid) {
|
|
27348
|
+
const { schema, gen, opts } = it;
|
|
27349
|
+
if (opts.$comment && schema.$comment)
|
|
27350
|
+
commentKeyword(it);
|
|
27351
|
+
updateContext(it);
|
|
27352
|
+
checkAsyncSchema(it);
|
|
27353
|
+
const errsCount = gen.const("_errs", names_1$3.default.errors);
|
|
27354
|
+
typeAndKeywords(it, errsCount);
|
|
27355
|
+
gen.var(valid, (0, codegen_1$n._)`${errsCount} === ${names_1$3.default.errors}`);
|
|
27356
|
+
}
|
|
27357
|
+
function checkKeywords(it) {
|
|
27358
|
+
(0, util_1$m.checkUnknownRules)(it);
|
|
27359
|
+
checkRefsAndKeywords(it);
|
|
27360
|
+
}
|
|
27361
|
+
function typeAndKeywords(it, errsCount) {
|
|
27362
|
+
if (it.opts.jtd)
|
|
27363
|
+
return schemaKeywords(it, [], false, errsCount);
|
|
27364
|
+
const types2 = (0, dataType_1$1.getSchemaTypes)(it.schema);
|
|
27365
|
+
const checkedTypes = (0, dataType_1$1.coerceAndCheckDataType)(it, types2);
|
|
27366
|
+
schemaKeywords(it, types2, !checkedTypes, errsCount);
|
|
27367
|
+
}
|
|
27368
|
+
function checkRefsAndKeywords(it) {
|
|
27369
|
+
const { schema, errSchemaPath, opts, self: self2 } = it;
|
|
27370
|
+
if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1$m.schemaHasRulesButRef)(schema, self2.RULES)) {
|
|
27371
|
+
self2.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
|
|
27372
|
+
}
|
|
27373
|
+
}
|
|
27374
|
+
function checkNoDefault(it) {
|
|
27375
|
+
const { schema, opts } = it;
|
|
27376
|
+
if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) {
|
|
27377
|
+
(0, util_1$m.checkStrictMode)(it, "default is ignored in the schema root");
|
|
27378
|
+
}
|
|
27379
|
+
}
|
|
27380
|
+
function updateContext(it) {
|
|
27381
|
+
const schId = it.schema[it.opts.schemaId];
|
|
27382
|
+
if (schId)
|
|
27383
|
+
it.baseId = (0, resolve_1$2.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
|
|
27384
|
+
}
|
|
27385
|
+
function checkAsyncSchema(it) {
|
|
27386
|
+
if (it.schema.$async && !it.schemaEnv.$async)
|
|
27387
|
+
throw new Error("async schema in sync schema");
|
|
27388
|
+
}
|
|
27389
|
+
function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
|
|
27390
|
+
const msg = schema.$comment;
|
|
27391
|
+
if (opts.$comment === true) {
|
|
27392
|
+
gen.code((0, codegen_1$n._)`${names_1$3.default.self}.logger.log(${msg})`);
|
|
27393
|
+
} else if (typeof opts.$comment == "function") {
|
|
27394
|
+
const schemaPath = (0, codegen_1$n.str)`${errSchemaPath}/$comment`;
|
|
27395
|
+
const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
|
|
27396
|
+
gen.code((0, codegen_1$n._)`${names_1$3.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
|
|
27397
|
+
}
|
|
27398
|
+
}
|
|
27399
|
+
function returnResults(it) {
|
|
27400
|
+
const { gen, schemaEnv, validateName, ValidationError: ValidationError2, opts } = it;
|
|
27401
|
+
if (schemaEnv.$async) {
|
|
27402
|
+
gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === 0`, () => gen.return(names_1$3.default.data), () => gen.throw((0, codegen_1$n._)`new ${ValidationError2}(${names_1$3.default.vErrors})`));
|
|
27403
|
+
} else {
|
|
27404
|
+
gen.assign((0, codegen_1$n._)`${validateName}.errors`, names_1$3.default.vErrors);
|
|
27405
|
+
if (opts.unevaluated)
|
|
27406
|
+
assignEvaluated(it);
|
|
27407
|
+
gen.return((0, codegen_1$n._)`${names_1$3.default.errors} === 0`);
|
|
27408
|
+
}
|
|
27409
|
+
}
|
|
27410
|
+
function assignEvaluated({ gen, evaluated, props, items: items2 }) {
|
|
27411
|
+
if (props instanceof codegen_1$n.Name)
|
|
27412
|
+
gen.assign((0, codegen_1$n._)`${evaluated}.props`, props);
|
|
27413
|
+
if (items2 instanceof codegen_1$n.Name)
|
|
27414
|
+
gen.assign((0, codegen_1$n._)`${evaluated}.items`, items2);
|
|
27415
|
+
}
|
|
27416
|
+
function schemaKeywords(it, types2, typeErrors, errsCount) {
|
|
27417
|
+
const { gen, schema, data, allErrors, opts, self: self2 } = it;
|
|
27418
|
+
const { RULES } = self2;
|
|
27419
|
+
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1$m.schemaHasRulesButRef)(schema, RULES))) {
|
|
27420
|
+
gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
|
|
27421
|
+
return;
|
|
27336
27422
|
}
|
|
27337
|
-
|
|
27338
|
-
|
|
27339
|
-
|
|
27340
|
-
|
|
27341
|
-
|
|
27342
|
-
|
|
27343
|
-
|
|
27344
|
-
|
|
27345
|
-
|
|
27346
|
-
}
|
|
27347
|
-
}
|
|
27348
|
-
function assignEvaluated({ gen, evaluated, props, items: items2 }) {
|
|
27349
|
-
if (props instanceof codegen_12.Name)
|
|
27350
|
-
gen.assign((0, codegen_12._)`${evaluated}.props`, props);
|
|
27351
|
-
if (items2 instanceof codegen_12.Name)
|
|
27352
|
-
gen.assign((0, codegen_12._)`${evaluated}.items`, items2);
|
|
27353
|
-
}
|
|
27354
|
-
function schemaKeywords(it, types2, typeErrors, errsCount) {
|
|
27355
|
-
const { gen, schema, data, allErrors, opts, self: self2 } = it;
|
|
27356
|
-
const { RULES } = self2;
|
|
27357
|
-
if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_12.schemaHasRulesButRef)(schema, RULES))) {
|
|
27358
|
-
gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
|
|
27423
|
+
if (!opts.jtd)
|
|
27424
|
+
checkStrictTypes(it, types2);
|
|
27425
|
+
gen.block(() => {
|
|
27426
|
+
for (const group of RULES.rules)
|
|
27427
|
+
groupKeywords(group);
|
|
27428
|
+
groupKeywords(RULES.post);
|
|
27429
|
+
});
|
|
27430
|
+
function groupKeywords(group) {
|
|
27431
|
+
if (!(0, applicability_1.shouldUseGroup)(schema, group))
|
|
27359
27432
|
return;
|
|
27360
|
-
|
|
27361
|
-
|
|
27362
|
-
|
|
27363
|
-
|
|
27364
|
-
|
|
27365
|
-
|
|
27366
|
-
groupKeywords(RULES.post);
|
|
27367
|
-
});
|
|
27368
|
-
function groupKeywords(group) {
|
|
27369
|
-
if (!(0, applicability_12.shouldUseGroup)(schema, group))
|
|
27370
|
-
return;
|
|
27371
|
-
if (group.type) {
|
|
27372
|
-
gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
|
|
27373
|
-
iterateKeywords(it, group);
|
|
27374
|
-
if (types2.length === 1 && types2[0] === group.type && typeErrors) {
|
|
27375
|
-
gen.else();
|
|
27376
|
-
(0, dataType_2.reportTypeError)(it);
|
|
27377
|
-
}
|
|
27378
|
-
gen.endIf();
|
|
27379
|
-
} else {
|
|
27380
|
-
iterateKeywords(it, group);
|
|
27433
|
+
if (group.type) {
|
|
27434
|
+
gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
|
|
27435
|
+
iterateKeywords(it, group);
|
|
27436
|
+
if (types2.length === 1 && types2[0] === group.type && typeErrors) {
|
|
27437
|
+
gen.else();
|
|
27438
|
+
(0, dataType_2.reportTypeError)(it);
|
|
27381
27439
|
}
|
|
27382
|
-
|
|
27383
|
-
|
|
27440
|
+
gen.endIf();
|
|
27441
|
+
} else {
|
|
27442
|
+
iterateKeywords(it, group);
|
|
27384
27443
|
}
|
|
27444
|
+
if (!allErrors)
|
|
27445
|
+
gen.if((0, codegen_1$n._)`${names_1$3.default.errors} === ${errsCount || 0}`);
|
|
27385
27446
|
}
|
|
27386
|
-
|
|
27387
|
-
|
|
27388
|
-
|
|
27389
|
-
|
|
27390
|
-
|
|
27391
|
-
|
|
27392
|
-
|
|
27393
|
-
|
|
27394
|
-
|
|
27395
|
-
}
|
|
27396
|
-
});
|
|
27397
|
-
}
|
|
27398
|
-
function checkStrictTypes(it, types2) {
|
|
27399
|
-
if (it.schemaEnv.meta || !it.opts.strictTypes)
|
|
27400
|
-
return;
|
|
27401
|
-
checkContextTypes(it, types2);
|
|
27402
|
-
if (!it.opts.allowUnionTypes)
|
|
27403
|
-
checkMultipleTypes(it, types2);
|
|
27404
|
-
checkKeywordTypes(it, it.dataTypes);
|
|
27405
|
-
}
|
|
27406
|
-
function checkContextTypes(it, types2) {
|
|
27407
|
-
if (!types2.length)
|
|
27408
|
-
return;
|
|
27409
|
-
if (!it.dataTypes.length) {
|
|
27410
|
-
it.dataTypes = types2;
|
|
27411
|
-
return;
|
|
27412
|
-
}
|
|
27413
|
-
types2.forEach((t) => {
|
|
27414
|
-
if (!includesType(it.dataTypes, t)) {
|
|
27415
|
-
strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
|
|
27416
|
-
}
|
|
27417
|
-
});
|
|
27418
|
-
narrowSchemaTypes(it, types2);
|
|
27419
|
-
}
|
|
27420
|
-
function checkMultipleTypes(it, ts) {
|
|
27421
|
-
if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
|
|
27422
|
-
strictTypesError(it, "use allowUnionTypes to allow union type keyword");
|
|
27423
|
-
}
|
|
27424
|
-
}
|
|
27425
|
-
function checkKeywordTypes(it, ts) {
|
|
27426
|
-
const rules2 = it.self.RULES.all;
|
|
27427
|
-
for (const keyword2 in rules2) {
|
|
27428
|
-
const rule = rules2[keyword2];
|
|
27429
|
-
if (typeof rule == "object" && (0, applicability_12.shouldUseRule)(it.schema, rule)) {
|
|
27430
|
-
const { type: type2 } = rule.definition;
|
|
27431
|
-
if (type2.length && !type2.some((t) => hasApplicableType(ts, t))) {
|
|
27432
|
-
strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
|
|
27433
|
-
}
|
|
27434
|
-
}
|
|
27435
|
-
}
|
|
27436
|
-
}
|
|
27437
|
-
function hasApplicableType(schTs, kwdT) {
|
|
27438
|
-
return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
|
|
27439
|
-
}
|
|
27440
|
-
function includesType(ts, t) {
|
|
27441
|
-
return ts.includes(t) || t === "integer" && ts.includes("number");
|
|
27442
|
-
}
|
|
27443
|
-
function narrowSchemaTypes(it, withTypes) {
|
|
27444
|
-
const ts = [];
|
|
27445
|
-
for (const t of it.dataTypes) {
|
|
27446
|
-
if (includesType(withTypes, t))
|
|
27447
|
-
ts.push(t);
|
|
27448
|
-
else if (withTypes.includes("integer") && t === "number")
|
|
27449
|
-
ts.push("integer");
|
|
27450
|
-
}
|
|
27451
|
-
it.dataTypes = ts;
|
|
27452
|
-
}
|
|
27453
|
-
function strictTypesError(it, msg) {
|
|
27454
|
-
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
|
|
27455
|
-
msg += ` at "${schemaPath}" (strictTypes)`;
|
|
27456
|
-
(0, util_12.checkStrictMode)(it, msg, it.opts.strictTypes);
|
|
27457
|
-
}
|
|
27458
|
-
class KeywordCxt {
|
|
27459
|
-
constructor(it, def2, keyword2) {
|
|
27460
|
-
(0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
|
|
27461
|
-
this.gen = it.gen;
|
|
27462
|
-
this.allErrors = it.allErrors;
|
|
27463
|
-
this.keyword = keyword2;
|
|
27464
|
-
this.data = it.data;
|
|
27465
|
-
this.schema = it.schema[keyword2];
|
|
27466
|
-
this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
|
|
27467
|
-
this.schemaValue = (0, util_12.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
|
|
27468
|
-
this.schemaType = def2.schemaType;
|
|
27469
|
-
this.parentSchema = it.schema;
|
|
27470
|
-
this.params = {};
|
|
27471
|
-
this.it = it;
|
|
27472
|
-
this.def = def2;
|
|
27473
|
-
if (this.$data) {
|
|
27474
|
-
this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
|
|
27475
|
-
} else {
|
|
27476
|
-
this.schemaCode = this.schemaValue;
|
|
27477
|
-
if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
|
|
27478
|
-
throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
|
|
27479
|
-
}
|
|
27480
|
-
}
|
|
27481
|
-
if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
|
|
27482
|
-
this.errsCount = it.gen.const("_errs", names_12.default.errors);
|
|
27447
|
+
}
|
|
27448
|
+
function iterateKeywords(it, group) {
|
|
27449
|
+
const { gen, schema, opts: { useDefaults } } = it;
|
|
27450
|
+
if (useDefaults)
|
|
27451
|
+
(0, defaults_1.assignDefaults)(it, group.type);
|
|
27452
|
+
gen.block(() => {
|
|
27453
|
+
for (const rule of group.rules) {
|
|
27454
|
+
if ((0, applicability_1.shouldUseRule)(schema, rule)) {
|
|
27455
|
+
keywordCode(it, rule.keyword, rule.definition, group.type);
|
|
27483
27456
|
}
|
|
27484
27457
|
}
|
|
27485
|
-
|
|
27486
|
-
|
|
27458
|
+
});
|
|
27459
|
+
}
|
|
27460
|
+
function checkStrictTypes(it, types2) {
|
|
27461
|
+
if (it.schemaEnv.meta || !it.opts.strictTypes)
|
|
27462
|
+
return;
|
|
27463
|
+
checkContextTypes(it, types2);
|
|
27464
|
+
if (!it.opts.allowUnionTypes)
|
|
27465
|
+
checkMultipleTypes(it, types2);
|
|
27466
|
+
checkKeywordTypes(it, it.dataTypes);
|
|
27467
|
+
}
|
|
27468
|
+
function checkContextTypes(it, types2) {
|
|
27469
|
+
if (!types2.length)
|
|
27470
|
+
return;
|
|
27471
|
+
if (!it.dataTypes.length) {
|
|
27472
|
+
it.dataTypes = types2;
|
|
27473
|
+
return;
|
|
27474
|
+
}
|
|
27475
|
+
types2.forEach((t) => {
|
|
27476
|
+
if (!includesType(it.dataTypes, t)) {
|
|
27477
|
+
strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
|
|
27487
27478
|
}
|
|
27488
|
-
|
|
27489
|
-
|
|
27490
|
-
|
|
27491
|
-
|
|
27492
|
-
|
|
27493
|
-
|
|
27494
|
-
|
|
27495
|
-
|
|
27496
|
-
|
|
27497
|
-
|
|
27498
|
-
|
|
27499
|
-
|
|
27500
|
-
|
|
27501
|
-
|
|
27502
|
-
|
|
27503
|
-
|
|
27479
|
+
});
|
|
27480
|
+
narrowSchemaTypes(it, types2);
|
|
27481
|
+
}
|
|
27482
|
+
function checkMultipleTypes(it, ts) {
|
|
27483
|
+
if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) {
|
|
27484
|
+
strictTypesError(it, "use allowUnionTypes to allow union type keyword");
|
|
27485
|
+
}
|
|
27486
|
+
}
|
|
27487
|
+
function checkKeywordTypes(it, ts) {
|
|
27488
|
+
const rules2 = it.self.RULES.all;
|
|
27489
|
+
for (const keyword2 in rules2) {
|
|
27490
|
+
const rule = rules2[keyword2];
|
|
27491
|
+
if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) {
|
|
27492
|
+
const { type: type2 } = rule.definition;
|
|
27493
|
+
if (type2.length && !type2.some((t) => hasApplicableType(ts, t))) {
|
|
27494
|
+
strictTypesError(it, `missing type "${type2.join(",")}" for keyword "${keyword2}"`);
|
|
27495
|
+
}
|
|
27496
|
+
}
|
|
27497
|
+
}
|
|
27498
|
+
}
|
|
27499
|
+
function hasApplicableType(schTs, kwdT) {
|
|
27500
|
+
return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
|
|
27501
|
+
}
|
|
27502
|
+
function includesType(ts, t) {
|
|
27503
|
+
return ts.includes(t) || t === "integer" && ts.includes("number");
|
|
27504
|
+
}
|
|
27505
|
+
function narrowSchemaTypes(it, withTypes) {
|
|
27506
|
+
const ts = [];
|
|
27507
|
+
for (const t of it.dataTypes) {
|
|
27508
|
+
if (includesType(withTypes, t))
|
|
27509
|
+
ts.push(t);
|
|
27510
|
+
else if (withTypes.includes("integer") && t === "number")
|
|
27511
|
+
ts.push("integer");
|
|
27512
|
+
}
|
|
27513
|
+
it.dataTypes = ts;
|
|
27514
|
+
}
|
|
27515
|
+
function strictTypesError(it, msg) {
|
|
27516
|
+
const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
|
|
27517
|
+
msg += ` at "${schemaPath}" (strictTypes)`;
|
|
27518
|
+
(0, util_1$m.checkStrictMode)(it, msg, it.opts.strictTypes);
|
|
27519
|
+
}
|
|
27520
|
+
class KeywordCxt {
|
|
27521
|
+
constructor(it, def2, keyword2) {
|
|
27522
|
+
(0, keyword_1.validateKeywordUsage)(it, def2, keyword2);
|
|
27523
|
+
this.gen = it.gen;
|
|
27524
|
+
this.allErrors = it.allErrors;
|
|
27525
|
+
this.keyword = keyword2;
|
|
27526
|
+
this.data = it.data;
|
|
27527
|
+
this.schema = it.schema[keyword2];
|
|
27528
|
+
this.$data = def2.$data && it.opts.$data && this.schema && this.schema.$data;
|
|
27529
|
+
this.schemaValue = (0, util_1$m.schemaRefOrVal)(it, this.schema, keyword2, this.$data);
|
|
27530
|
+
this.schemaType = def2.schemaType;
|
|
27531
|
+
this.parentSchema = it.schema;
|
|
27532
|
+
this.params = {};
|
|
27533
|
+
this.it = it;
|
|
27534
|
+
this.def = def2;
|
|
27535
|
+
if (this.$data) {
|
|
27536
|
+
this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
|
|
27537
|
+
} else {
|
|
27538
|
+
this.schemaCode = this.schemaValue;
|
|
27539
|
+
if (!(0, keyword_1.validSchemaType)(this.schema, def2.schemaType, def2.allowUndefined)) {
|
|
27540
|
+
throw new Error(`${keyword2} value must be ${JSON.stringify(def2.schemaType)}`);
|
|
27504
27541
|
}
|
|
27505
27542
|
}
|
|
27506
|
-
|
|
27507
|
-
this.
|
|
27543
|
+
if ("code" in def2 ? def2.trackErrors : def2.errors !== false) {
|
|
27544
|
+
this.errsCount = it.gen.const("_errs", names_1$3.default.errors);
|
|
27508
27545
|
}
|
|
27509
|
-
|
|
27510
|
-
|
|
27511
|
-
|
|
27512
|
-
|
|
27513
|
-
|
|
27514
|
-
|
|
27515
|
-
|
|
27516
|
-
|
|
27546
|
+
}
|
|
27547
|
+
result(condition, successAction, failAction) {
|
|
27548
|
+
this.failResult((0, codegen_1$n.not)(condition), successAction, failAction);
|
|
27549
|
+
}
|
|
27550
|
+
failResult(condition, successAction, failAction) {
|
|
27551
|
+
this.gen.if(condition);
|
|
27552
|
+
if (failAction)
|
|
27553
|
+
failAction();
|
|
27554
|
+
else
|
|
27517
27555
|
this.error();
|
|
27556
|
+
if (successAction) {
|
|
27557
|
+
this.gen.else();
|
|
27558
|
+
successAction();
|
|
27559
|
+
if (this.allErrors)
|
|
27560
|
+
this.gen.endIf();
|
|
27561
|
+
} else {
|
|
27518
27562
|
if (this.allErrors)
|
|
27519
27563
|
this.gen.endIf();
|
|
27520
27564
|
else
|
|
27521
27565
|
this.gen.else();
|
|
27522
27566
|
}
|
|
27523
|
-
|
|
27524
|
-
|
|
27525
|
-
|
|
27526
|
-
|
|
27527
|
-
|
|
27528
|
-
|
|
27529
|
-
|
|
27530
|
-
if (errorParams) {
|
|
27531
|
-
this.setParams(errorParams);
|
|
27532
|
-
this._error(append, errorPaths);
|
|
27533
|
-
this.setParams({});
|
|
27534
|
-
return;
|
|
27535
|
-
}
|
|
27536
|
-
this._error(append, errorPaths);
|
|
27537
|
-
}
|
|
27538
|
-
_error(append, errorPaths) {
|
|
27539
|
-
(append ? errors_12.reportExtraError : errors_12.reportError)(this, this.def.error, errorPaths);
|
|
27540
|
-
}
|
|
27541
|
-
$dataError() {
|
|
27542
|
-
(0, errors_12.reportError)(this, this.def.$dataError || errors_12.keyword$DataError);
|
|
27543
|
-
}
|
|
27544
|
-
reset() {
|
|
27545
|
-
if (this.errsCount === void 0)
|
|
27546
|
-
throw new Error('add "trackErrors" to keyword definition');
|
|
27547
|
-
(0, errors_12.resetErrorsCount)(this.gen, this.errsCount);
|
|
27548
|
-
}
|
|
27549
|
-
ok(cond) {
|
|
27567
|
+
}
|
|
27568
|
+
pass(condition, failAction) {
|
|
27569
|
+
this.failResult((0, codegen_1$n.not)(condition), void 0, failAction);
|
|
27570
|
+
}
|
|
27571
|
+
fail(condition) {
|
|
27572
|
+
if (condition === void 0) {
|
|
27573
|
+
this.error();
|
|
27550
27574
|
if (!this.allErrors)
|
|
27551
|
-
this.gen.if(
|
|
27552
|
-
|
|
27553
|
-
setParams(obj, assign) {
|
|
27554
|
-
if (assign)
|
|
27555
|
-
Object.assign(this.params, obj);
|
|
27556
|
-
else
|
|
27557
|
-
this.params = obj;
|
|
27575
|
+
this.gen.if(false);
|
|
27576
|
+
return;
|
|
27558
27577
|
}
|
|
27559
|
-
|
|
27560
|
-
|
|
27561
|
-
|
|
27562
|
-
|
|
27563
|
-
|
|
27578
|
+
this.gen.if(condition);
|
|
27579
|
+
this.error();
|
|
27580
|
+
if (this.allErrors)
|
|
27581
|
+
this.gen.endIf();
|
|
27582
|
+
else
|
|
27583
|
+
this.gen.else();
|
|
27584
|
+
}
|
|
27585
|
+
fail$data(condition) {
|
|
27586
|
+
if (!this.$data)
|
|
27587
|
+
return this.fail(condition);
|
|
27588
|
+
const { schemaCode } = this;
|
|
27589
|
+
this.fail((0, codegen_1$n._)`${schemaCode} !== undefined && (${(0, codegen_1$n.or)(this.invalid$data(), condition)})`);
|
|
27590
|
+
}
|
|
27591
|
+
error(append, errorParams, errorPaths) {
|
|
27592
|
+
if (errorParams) {
|
|
27593
|
+
this.setParams(errorParams);
|
|
27594
|
+
this._error(append, errorPaths);
|
|
27595
|
+
this.setParams({});
|
|
27596
|
+
return;
|
|
27564
27597
|
}
|
|
27565
|
-
|
|
27566
|
-
|
|
27567
|
-
|
|
27568
|
-
|
|
27569
|
-
|
|
27570
|
-
|
|
27571
|
-
|
|
27572
|
-
|
|
27573
|
-
|
|
27574
|
-
|
|
27575
|
-
|
|
27576
|
-
|
|
27577
|
-
|
|
27578
|
-
|
|
27598
|
+
this._error(append, errorPaths);
|
|
27599
|
+
}
|
|
27600
|
+
_error(append, errorPaths) {
|
|
27601
|
+
(append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
|
|
27602
|
+
}
|
|
27603
|
+
$dataError() {
|
|
27604
|
+
(0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
|
|
27605
|
+
}
|
|
27606
|
+
reset() {
|
|
27607
|
+
if (this.errsCount === void 0)
|
|
27608
|
+
throw new Error('add "trackErrors" to keyword definition');
|
|
27609
|
+
(0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
|
|
27610
|
+
}
|
|
27611
|
+
ok(cond) {
|
|
27612
|
+
if (!this.allErrors)
|
|
27613
|
+
this.gen.if(cond);
|
|
27614
|
+
}
|
|
27615
|
+
setParams(obj, assign) {
|
|
27616
|
+
if (assign)
|
|
27617
|
+
Object.assign(this.params, obj);
|
|
27618
|
+
else
|
|
27619
|
+
this.params = obj;
|
|
27620
|
+
}
|
|
27621
|
+
block$data(valid, codeBlock, $dataValid = codegen_1$n.nil) {
|
|
27622
|
+
this.gen.block(() => {
|
|
27623
|
+
this.check$data(valid, $dataValid);
|
|
27624
|
+
codeBlock();
|
|
27625
|
+
});
|
|
27626
|
+
}
|
|
27627
|
+
check$data(valid = codegen_1$n.nil, $dataValid = codegen_1$n.nil) {
|
|
27628
|
+
if (!this.$data)
|
|
27629
|
+
return;
|
|
27630
|
+
const { gen, schemaCode, schemaType, def: def2 } = this;
|
|
27631
|
+
gen.if((0, codegen_1$n.or)((0, codegen_1$n._)`${schemaCode} === undefined`, $dataValid));
|
|
27632
|
+
if (valid !== codegen_1$n.nil)
|
|
27633
|
+
gen.assign(valid, true);
|
|
27634
|
+
if (schemaType.length || def2.validateSchema) {
|
|
27635
|
+
gen.elseIf(this.invalid$data());
|
|
27636
|
+
this.$dataError();
|
|
27637
|
+
if (valid !== codegen_1$n.nil)
|
|
27638
|
+
gen.assign(valid, false);
|
|
27579
27639
|
}
|
|
27580
|
-
|
|
27581
|
-
|
|
27582
|
-
|
|
27583
|
-
|
|
27584
|
-
|
|
27585
|
-
|
|
27586
|
-
|
|
27587
|
-
|
|
27588
|
-
|
|
27589
|
-
|
|
27590
|
-
return
|
|
27591
|
-
}
|
|
27592
|
-
function invalid$DataSchema() {
|
|
27593
|
-
if (def2.validateSchema) {
|
|
27594
|
-
const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
|
|
27595
|
-
return (0, codegen_12._)`!${validateSchemaRef}(${schemaCode})`;
|
|
27596
|
-
}
|
|
27597
|
-
return codegen_12.nil;
|
|
27598
|
-
}
|
|
27599
|
-
}
|
|
27600
|
-
subschema(appl, valid) {
|
|
27601
|
-
const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
|
|
27602
|
-
(0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
|
|
27603
|
-
(0, subschema_1.extendSubschemaMode)(subschema2, appl);
|
|
27604
|
-
const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
|
|
27605
|
-
subschemaCode(nextContext, valid);
|
|
27606
|
-
return nextContext;
|
|
27607
|
-
}
|
|
27608
|
-
mergeEvaluated(schemaCxt, toName) {
|
|
27609
|
-
const { it, gen } = this;
|
|
27610
|
-
if (!it.opts.unevaluated)
|
|
27611
|
-
return;
|
|
27612
|
-
if (it.props !== true && schemaCxt.props !== void 0) {
|
|
27613
|
-
it.props = util_12.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
|
|
27614
|
-
}
|
|
27615
|
-
if (it.items !== true && schemaCxt.items !== void 0) {
|
|
27616
|
-
it.items = util_12.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
|
|
27640
|
+
gen.else();
|
|
27641
|
+
}
|
|
27642
|
+
invalid$data() {
|
|
27643
|
+
const { gen, schemaCode, schemaType, def: def2, it } = this;
|
|
27644
|
+
return (0, codegen_1$n.or)(wrong$DataType(), invalid$DataSchema());
|
|
27645
|
+
function wrong$DataType() {
|
|
27646
|
+
if (schemaType.length) {
|
|
27647
|
+
if (!(schemaCode instanceof codegen_1$n.Name))
|
|
27648
|
+
throw new Error("ajv implementation error");
|
|
27649
|
+
const st = Array.isArray(schemaType) ? schemaType : [schemaType];
|
|
27650
|
+
return (0, codegen_1$n._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
|
|
27617
27651
|
}
|
|
27652
|
+
return codegen_1$n.nil;
|
|
27618
27653
|
}
|
|
27619
|
-
|
|
27620
|
-
|
|
27621
|
-
|
|
27622
|
-
|
|
27623
|
-
return true;
|
|
27654
|
+
function invalid$DataSchema() {
|
|
27655
|
+
if (def2.validateSchema) {
|
|
27656
|
+
const validateSchemaRef = gen.scopeValue("validate$data", { ref: def2.validateSchema });
|
|
27657
|
+
return (0, codegen_1$n._)`!${validateSchemaRef}(${schemaCode})`;
|
|
27624
27658
|
}
|
|
27659
|
+
return codegen_1$n.nil;
|
|
27625
27660
|
}
|
|
27626
27661
|
}
|
|
27627
|
-
|
|
27628
|
-
|
|
27629
|
-
|
|
27630
|
-
|
|
27631
|
-
|
|
27632
|
-
|
|
27633
|
-
|
|
27634
|
-
|
|
27635
|
-
|
|
27636
|
-
|
|
27637
|
-
|
|
27638
|
-
|
|
27639
|
-
|
|
27640
|
-
|
|
27641
|
-
const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
|
|
27642
|
-
function getData($data, { dataLevel, dataNames, dataPathArr }) {
|
|
27643
|
-
let jsonPointer;
|
|
27644
|
-
let data;
|
|
27645
|
-
if ($data === "")
|
|
27646
|
-
return names_12.default.rootData;
|
|
27647
|
-
if ($data[0] === "/") {
|
|
27648
|
-
if (!JSON_POINTER.test($data))
|
|
27649
|
-
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
27650
|
-
jsonPointer = $data;
|
|
27651
|
-
data = names_12.default.rootData;
|
|
27652
|
-
} else {
|
|
27653
|
-
const matches = RELATIVE_JSON_POINTER.exec($data);
|
|
27654
|
-
if (!matches)
|
|
27655
|
-
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
27656
|
-
const up = +matches[1];
|
|
27657
|
-
jsonPointer = matches[2];
|
|
27658
|
-
if (jsonPointer === "#") {
|
|
27659
|
-
if (up >= dataLevel)
|
|
27660
|
-
throw new Error(errorMsg("property/index", up));
|
|
27661
|
-
return dataPathArr[dataLevel - up];
|
|
27662
|
-
}
|
|
27663
|
-
if (up > dataLevel)
|
|
27664
|
-
throw new Error(errorMsg("data", up));
|
|
27665
|
-
data = dataNames[dataLevel - up];
|
|
27666
|
-
if (!jsonPointer)
|
|
27667
|
-
return data;
|
|
27662
|
+
subschema(appl, valid) {
|
|
27663
|
+
const subschema2 = (0, subschema_1.getSubschema)(this.it, appl);
|
|
27664
|
+
(0, subschema_1.extendSubschemaData)(subschema2, this.it, appl);
|
|
27665
|
+
(0, subschema_1.extendSubschemaMode)(subschema2, appl);
|
|
27666
|
+
const nextContext = { ...this.it, ...subschema2, items: void 0, props: void 0 };
|
|
27667
|
+
subschemaCode(nextContext, valid);
|
|
27668
|
+
return nextContext;
|
|
27669
|
+
}
|
|
27670
|
+
mergeEvaluated(schemaCxt, toName) {
|
|
27671
|
+
const { it, gen } = this;
|
|
27672
|
+
if (!it.opts.unevaluated)
|
|
27673
|
+
return;
|
|
27674
|
+
if (it.props !== true && schemaCxt.props !== void 0) {
|
|
27675
|
+
it.props = util_1$m.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
|
|
27668
27676
|
}
|
|
27669
|
-
|
|
27670
|
-
|
|
27671
|
-
|
|
27672
|
-
|
|
27673
|
-
|
|
27674
|
-
|
|
27675
|
-
|
|
27677
|
+
if (it.items !== true && schemaCxt.items !== void 0) {
|
|
27678
|
+
it.items = util_1$m.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
|
|
27679
|
+
}
|
|
27680
|
+
}
|
|
27681
|
+
mergeValidEvaluated(schemaCxt, valid) {
|
|
27682
|
+
const { it, gen } = this;
|
|
27683
|
+
if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
|
|
27684
|
+
gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_1$n.Name));
|
|
27685
|
+
return true;
|
|
27676
27686
|
}
|
|
27677
|
-
|
|
27678
|
-
|
|
27679
|
-
|
|
27687
|
+
}
|
|
27688
|
+
}
|
|
27689
|
+
validate.KeywordCxt = KeywordCxt;
|
|
27690
|
+
function keywordCode(it, keyword2, def2, ruleType) {
|
|
27691
|
+
const cxt = new KeywordCxt(it, def2, keyword2);
|
|
27692
|
+
if ("code" in def2) {
|
|
27693
|
+
def2.code(cxt, ruleType);
|
|
27694
|
+
} else if (cxt.$data && def2.validate) {
|
|
27695
|
+
(0, keyword_1.funcKeywordCode)(cxt, def2);
|
|
27696
|
+
} else if ("macro" in def2) {
|
|
27697
|
+
(0, keyword_1.macroKeywordCode)(cxt, def2);
|
|
27698
|
+
} else if (def2.compile || def2.validate) {
|
|
27699
|
+
(0, keyword_1.funcKeywordCode)(cxt, def2);
|
|
27700
|
+
}
|
|
27701
|
+
}
|
|
27702
|
+
const JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
|
|
27703
|
+
const RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
|
|
27704
|
+
function getData($data, { dataLevel, dataNames, dataPathArr }) {
|
|
27705
|
+
let jsonPointer;
|
|
27706
|
+
let data;
|
|
27707
|
+
if ($data === "")
|
|
27708
|
+
return names_1$3.default.rootData;
|
|
27709
|
+
if ($data[0] === "/") {
|
|
27710
|
+
if (!JSON_POINTER.test($data))
|
|
27711
|
+
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
27712
|
+
jsonPointer = $data;
|
|
27713
|
+
data = names_1$3.default.rootData;
|
|
27714
|
+
} else {
|
|
27715
|
+
const matches = RELATIVE_JSON_POINTER.exec($data);
|
|
27716
|
+
if (!matches)
|
|
27717
|
+
throw new Error(`Invalid JSON-pointer: ${$data}`);
|
|
27718
|
+
const up = +matches[1];
|
|
27719
|
+
jsonPointer = matches[2];
|
|
27720
|
+
if (jsonPointer === "#") {
|
|
27721
|
+
if (up >= dataLevel)
|
|
27722
|
+
throw new Error(errorMsg("property/index", up));
|
|
27723
|
+
return dataPathArr[dataLevel - up];
|
|
27724
|
+
}
|
|
27725
|
+
if (up > dataLevel)
|
|
27726
|
+
throw new Error(errorMsg("data", up));
|
|
27727
|
+
data = dataNames[dataLevel - up];
|
|
27728
|
+
if (!jsonPointer)
|
|
27729
|
+
return data;
|
|
27730
|
+
}
|
|
27731
|
+
let expr = data;
|
|
27732
|
+
const segments = jsonPointer.split("/");
|
|
27733
|
+
for (const segment of segments) {
|
|
27734
|
+
if (segment) {
|
|
27735
|
+
data = (0, codegen_1$n._)`${data}${(0, codegen_1$n.getProperty)((0, util_1$m.unescapeJsonPointer)(segment))}`;
|
|
27736
|
+
expr = (0, codegen_1$n._)`${expr} && ${data}`;
|
|
27680
27737
|
}
|
|
27681
27738
|
}
|
|
27682
|
-
|
|
27683
|
-
|
|
27739
|
+
return expr;
|
|
27740
|
+
function errorMsg(pointerType, up) {
|
|
27741
|
+
return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
|
|
27742
|
+
}
|
|
27684
27743
|
}
|
|
27744
|
+
validate.getData = getData;
|
|
27685
27745
|
var validation_error = {};
|
|
27686
|
-
|
|
27687
|
-
|
|
27688
|
-
|
|
27689
|
-
|
|
27690
|
-
|
|
27691
|
-
|
|
27692
|
-
constructor(errors2) {
|
|
27693
|
-
super("validation failed");
|
|
27694
|
-
this.errors = errors2;
|
|
27695
|
-
this.ajv = this.validation = true;
|
|
27696
|
-
}
|
|
27746
|
+
Object.defineProperty(validation_error, "__esModule", { value: true });
|
|
27747
|
+
class ValidationError extends Error {
|
|
27748
|
+
constructor(errors2) {
|
|
27749
|
+
super("validation failed");
|
|
27750
|
+
this.errors = errors2;
|
|
27751
|
+
this.ajv = this.validation = true;
|
|
27697
27752
|
}
|
|
27698
|
-
validation_error.default = ValidationError;
|
|
27699
|
-
return validation_error;
|
|
27700
27753
|
}
|
|
27754
|
+
validation_error.default = ValidationError;
|
|
27701
27755
|
var ref_error = {};
|
|
27702
27756
|
Object.defineProperty(ref_error, "__esModule", { value: true });
|
|
27703
27757
|
const resolve_1$1 = resolve$2;
|
|
@@ -27713,11 +27767,11 @@ var compile = {};
|
|
|
27713
27767
|
Object.defineProperty(compile, "__esModule", { value: true });
|
|
27714
27768
|
compile.resolveSchema = compile.getCompilingSchema = compile.resolveRef = compile.compileSchema = compile.SchemaEnv = void 0;
|
|
27715
27769
|
const codegen_1$m = codegen;
|
|
27716
|
-
const validation_error_1 =
|
|
27770
|
+
const validation_error_1 = validation_error;
|
|
27717
27771
|
const names_1$2 = names$1;
|
|
27718
27772
|
const resolve_1 = resolve$2;
|
|
27719
27773
|
const util_1$l = util;
|
|
27720
|
-
const validate_1$1 =
|
|
27774
|
+
const validate_1$1 = validate;
|
|
27721
27775
|
class SchemaEnv {
|
|
27722
27776
|
constructor(env) {
|
|
27723
27777
|
var _a;
|
|
@@ -29002,7 +29056,7 @@ uri$1.default = uri;
|
|
|
29002
29056
|
(function(exports) {
|
|
29003
29057
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29004
29058
|
exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
|
|
29005
|
-
var validate_12 =
|
|
29059
|
+
var validate_12 = validate;
|
|
29006
29060
|
Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
|
|
29007
29061
|
return validate_12.KeywordCxt;
|
|
29008
29062
|
} });
|
|
@@ -29025,7 +29079,7 @@ uri$1.default = uri;
|
|
|
29025
29079
|
Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function() {
|
|
29026
29080
|
return codegen_12.CodeGen;
|
|
29027
29081
|
} });
|
|
29028
|
-
const validation_error_12 =
|
|
29082
|
+
const validation_error_12 = validation_error;
|
|
29029
29083
|
const ref_error_12 = ref_error;
|
|
29030
29084
|
const rules_12 = rules;
|
|
29031
29085
|
const compile_12 = compile;
|
|
@@ -30613,7 +30667,7 @@ const def$a = {
|
|
|
30613
30667
|
additionalProperties.default = def$a;
|
|
30614
30668
|
var properties$1 = {};
|
|
30615
30669
|
Object.defineProperty(properties$1, "__esModule", { value: true });
|
|
30616
|
-
const validate_1 =
|
|
30670
|
+
const validate_1 = validate;
|
|
30617
30671
|
const code_1$2 = code;
|
|
30618
30672
|
const util_1$7 = util;
|
|
30619
30673
|
const additionalProperties_1$1 = additionalProperties;
|
|
@@ -31464,7 +31518,7 @@ const require$$3 = {
|
|
|
31464
31518
|
module2.exports.Ajv = Ajv2;
|
|
31465
31519
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31466
31520
|
exports.default = Ajv2;
|
|
31467
|
-
var validate_12 =
|
|
31521
|
+
var validate_12 = validate;
|
|
31468
31522
|
Object.defineProperty(exports, "KeywordCxt", { enumerable: true, get: function() {
|
|
31469
31523
|
return validate_12.KeywordCxt;
|
|
31470
31524
|
} });
|
|
@@ -31487,7 +31541,7 @@ const require$$3 = {
|
|
|
31487
31541
|
Object.defineProperty(exports, "CodeGen", { enumerable: true, get: function() {
|
|
31488
31542
|
return codegen_12.CodeGen;
|
|
31489
31543
|
} });
|
|
31490
|
-
var validation_error_12 =
|
|
31544
|
+
var validation_error_12 = validation_error;
|
|
31491
31545
|
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function() {
|
|
31492
31546
|
return validation_error_12.default;
|
|
31493
31547
|
} });
|