@oomol-lab/open-flow 0.1.0-beta.90 → 0.1.0-beta.91
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/browser/{FlowCanvas-C4iuvVKB.js → FlowCanvas-CZEphIhX.js} +169 -2324
- package/dist/browser/{createResourceDialog-BstGO0m4.js → createResourceDialog-CJbZa2gA.js} +2 -2
- package/dist/browser/{dialog-Bi-MVTGj.js → dialog-E1WkapJU.js} +10 -2
- package/dist/browser/{exportPng-DMsB9ku_.js → exportPng-c4or5th8.js} +2 -2
- package/dist/browser/{flowChanges-SKYJBr6X.js → flowChanges-DsLZdENA.js} +20 -37
- package/dist/browser/{flowWorkspace-4UHRaHcz.js → flowWorkspace-CxLQWUdj.js} +54 -19
- package/dist/browser/{markdownContent-B75ojl0E.js → markdownContent-BsdTdwBU.js} +1 -1
- package/dist/browser/preview.js +231 -68
- package/dist/browser/workbench.js +6 -6
- package/dist/browser/{workbenchSelect-CHOeceKA.js → workbenchSelect-BfQfMWuY.js} +1 -1
- package/dist/browser/{wrapLayout-DU5HG1qH.js → wrapLayout-ZOG4AikN.js} +2493 -200
- package/dist/command/index.js +58 -55
- package/dist/common/control-api-conformance.js +896 -8
- package/dist/common/control-api.js +896 -8
- package/dist/common/control-requests.js +17 -6
- package/dist/common/decision.js +10 -2
- package/dist/common/flow-authoring.js +896 -8
- package/dist/common/flow-change.js +896 -8
- package/dist/common/flow-encoding.js +896 -8
- package/dist/common/flow-semantics.js +10 -2
- package/dist/common/integration-trigger.js +10 -2
- package/dist/common/licenses.md +2 -0
- package/dist/common/mcp.js +896 -8
- package/dist/common/openapi.js +10 -2
- package/dist/common/poll-trigger.js +10 -2
- package/dist/common/provider-triggers.js +1 -1
- package/dist/common/scheduler.js +10 -2
- package/dist/common/webhook-trigger.js +890 -2
- package/dist/common/workflow.js +14 -3
- package/dist/render/browser/runtime.js +966 -59
- package/dist/render/node/index.js +792 -4
- package/package.json +1 -1
- package/src/control/common/authoringTools.ts +4 -2
- package/src/flow/common/schemaComparer.ts +12 -2
- package/src/json-schema-subset/checker/equals.ts +3 -0
- package/src/trigger/providers/catalog.generated.json +9 -1
- package/src/workflow/common/workflow.ts +4 -3
|
@@ -1075,7 +1075,7 @@ var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
1075
1075
|
};
|
|
1076
1076
|
var COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
|
|
1077
1077
|
var COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
|
|
1078
|
-
var validate = ((schema, value, _ctx) => {
|
|
1078
|
+
var validate$1 = ((schema, value, _ctx) => {
|
|
1079
1079
|
const validator = schema._zod.bag.validator;
|
|
1080
1080
|
if (validator !== void 0) {
|
|
1081
1081
|
if (validator(value) !== COMPILE_INVALID) return true;
|
|
@@ -5109,7 +5109,7 @@ var ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
|
5109
5109
|
own(this, "spa", value);
|
|
5110
5110
|
},
|
|
5111
5111
|
validate(data, params) {
|
|
5112
|
-
return validate(this, data, params);
|
|
5112
|
+
return validate$1(this, data, params);
|
|
5113
5113
|
},
|
|
5114
5114
|
validateAsync(data, params) {
|
|
5115
5115
|
return validateAsync$1(this, data, params);
|
|
@@ -5935,6 +5935,136 @@ var connectorProxyExecutorSchema = strictObject({
|
|
|
5935
5935
|
bodyFormat: _enum(["none", "json"]).default("none")
|
|
5936
5936
|
}).extend({ kind: literal("connector-proxy") });
|
|
5937
5937
|
//#endregion
|
|
5938
|
+
//#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/deep-compare-strict.js
|
|
5939
|
+
function deepCompareStrict(a, b) {
|
|
5940
|
+
const typeofa = typeof a;
|
|
5941
|
+
if (typeofa !== typeof b) return false;
|
|
5942
|
+
if (Array.isArray(a)) {
|
|
5943
|
+
if (!Array.isArray(b)) return false;
|
|
5944
|
+
const length = a.length;
|
|
5945
|
+
if (length !== b.length) return false;
|
|
5946
|
+
for (let i = 0; i < length; i++) if (!deepCompareStrict(a[i], b[i])) return false;
|
|
5947
|
+
return true;
|
|
5948
|
+
}
|
|
5949
|
+
if (typeofa === "object") {
|
|
5950
|
+
if (!a || !b) return a === b;
|
|
5951
|
+
const aKeys = Object.keys(a);
|
|
5952
|
+
const bKeys = Object.keys(b);
|
|
5953
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
5954
|
+
for (const k of aKeys) if (!deepCompareStrict(a[k], b[k])) return false;
|
|
5955
|
+
return true;
|
|
5956
|
+
}
|
|
5957
|
+
return a === b;
|
|
5958
|
+
}
|
|
5959
|
+
//#endregion
|
|
5960
|
+
//#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/pointer.js
|
|
5961
|
+
function encodePointer(p) {
|
|
5962
|
+
return encodeURI(escapePointer(p));
|
|
5963
|
+
}
|
|
5964
|
+
function escapePointer(p) {
|
|
5965
|
+
return p.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
5966
|
+
}
|
|
5967
|
+
//#endregion
|
|
5968
|
+
//#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/dereference.js
|
|
5969
|
+
var schemaArrayKeyword = {
|
|
5970
|
+
prefixItems: true,
|
|
5971
|
+
items: true,
|
|
5972
|
+
allOf: true,
|
|
5973
|
+
anyOf: true,
|
|
5974
|
+
oneOf: true
|
|
5975
|
+
};
|
|
5976
|
+
var schemaMapKeyword = {
|
|
5977
|
+
$defs: true,
|
|
5978
|
+
definitions: true,
|
|
5979
|
+
properties: true,
|
|
5980
|
+
patternProperties: true,
|
|
5981
|
+
dependentSchemas: true
|
|
5982
|
+
};
|
|
5983
|
+
var ignoredKeyword = {
|
|
5984
|
+
id: true,
|
|
5985
|
+
$id: true,
|
|
5986
|
+
$ref: true,
|
|
5987
|
+
$schema: true,
|
|
5988
|
+
$anchor: true,
|
|
5989
|
+
$vocabulary: true,
|
|
5990
|
+
$comment: true,
|
|
5991
|
+
default: true,
|
|
5992
|
+
enum: true,
|
|
5993
|
+
const: true,
|
|
5994
|
+
required: true,
|
|
5995
|
+
type: true,
|
|
5996
|
+
maximum: true,
|
|
5997
|
+
minimum: true,
|
|
5998
|
+
exclusiveMaximum: true,
|
|
5999
|
+
exclusiveMinimum: true,
|
|
6000
|
+
multipleOf: true,
|
|
6001
|
+
maxLength: true,
|
|
6002
|
+
minLength: true,
|
|
6003
|
+
pattern: true,
|
|
6004
|
+
format: true,
|
|
6005
|
+
maxItems: true,
|
|
6006
|
+
minItems: true,
|
|
6007
|
+
uniqueItems: true,
|
|
6008
|
+
maxProperties: true,
|
|
6009
|
+
minProperties: true
|
|
6010
|
+
};
|
|
6011
|
+
var initialBaseURI = typeof self !== "undefined" && self.location && self.location.origin !== "null" ? new URL(self.location.origin + self.location.pathname + location.search) : new URL("https://github.com/cfworker");
|
|
6012
|
+
function dereference(schema, lookup = Object.create(null), baseURI = initialBaseURI, basePointer = "") {
|
|
6013
|
+
if (schema && typeof schema === "object" && !Array.isArray(schema)) {
|
|
6014
|
+
const id = schema.$id || schema.id;
|
|
6015
|
+
if (id) {
|
|
6016
|
+
const url = new URL(id, baseURI.href);
|
|
6017
|
+
if (url.hash.length > 1) lookup[url.href] = schema;
|
|
6018
|
+
else {
|
|
6019
|
+
url.hash = "";
|
|
6020
|
+
if (basePointer === "") baseURI = url;
|
|
6021
|
+
else dereference(schema, lookup, baseURI);
|
|
6022
|
+
}
|
|
6023
|
+
}
|
|
6024
|
+
} else if (schema !== true && schema !== false) return lookup;
|
|
6025
|
+
const schemaURI = baseURI.href + (basePointer ? "#" + basePointer : "");
|
|
6026
|
+
if (lookup[schemaURI] !== void 0) throw new Error(`Duplicate schema URI "${schemaURI}".`);
|
|
6027
|
+
lookup[schemaURI] = schema;
|
|
6028
|
+
if (schema === true || schema === false) return lookup;
|
|
6029
|
+
if (schema.__absolute_uri__ === void 0) Object.defineProperty(schema, "__absolute_uri__", {
|
|
6030
|
+
enumerable: false,
|
|
6031
|
+
value: schemaURI
|
|
6032
|
+
});
|
|
6033
|
+
if (schema.$ref && schema.__absolute_ref__ === void 0) {
|
|
6034
|
+
const url = new URL(schema.$ref, baseURI.href);
|
|
6035
|
+
url.hash = url.hash;
|
|
6036
|
+
Object.defineProperty(schema, "__absolute_ref__", {
|
|
6037
|
+
enumerable: false,
|
|
6038
|
+
value: url.href
|
|
6039
|
+
});
|
|
6040
|
+
}
|
|
6041
|
+
if (schema.$recursiveRef && schema.__absolute_recursive_ref__ === void 0) {
|
|
6042
|
+
const url = new URL(schema.$recursiveRef, baseURI.href);
|
|
6043
|
+
url.hash = url.hash;
|
|
6044
|
+
Object.defineProperty(schema, "__absolute_recursive_ref__", {
|
|
6045
|
+
enumerable: false,
|
|
6046
|
+
value: url.href
|
|
6047
|
+
});
|
|
6048
|
+
}
|
|
6049
|
+
if (schema.$anchor) {
|
|
6050
|
+
const url = new URL("#" + schema.$anchor, baseURI.href);
|
|
6051
|
+
lookup[url.href] = schema;
|
|
6052
|
+
}
|
|
6053
|
+
for (let key in schema) {
|
|
6054
|
+
if (ignoredKeyword[key]) continue;
|
|
6055
|
+
const keyBase = `${basePointer}/${encodePointer(key)}`;
|
|
6056
|
+
const subSchema = schema[key];
|
|
6057
|
+
if (Array.isArray(subSchema)) {
|
|
6058
|
+
if (schemaArrayKeyword[key]) {
|
|
6059
|
+
const length = subSchema.length;
|
|
6060
|
+
for (let i = 0; i < length; i++) dereference(subSchema[i], lookup, baseURI, `${keyBase}/${i}`);
|
|
6061
|
+
}
|
|
6062
|
+
} else if (schemaMapKeyword[key]) for (let subKey in subSchema) dereference(subSchema[subKey], lookup, baseURI, `${keyBase}/${encodePointer(subKey)}`);
|
|
6063
|
+
else dereference(subSchema, lookup, baseURI, keyBase);
|
|
6064
|
+
}
|
|
6065
|
+
return lookup;
|
|
6066
|
+
}
|
|
6067
|
+
//#endregion
|
|
5938
6068
|
//#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/format.js
|
|
5939
6069
|
var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
5940
6070
|
var DAYS = [
|
|
@@ -6035,6 +6165,656 @@ function regex(str) {
|
|
|
6035
6165
|
}
|
|
6036
6166
|
}
|
|
6037
6167
|
//#endregion
|
|
6168
|
+
//#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/ucs2-length.js
|
|
6169
|
+
function ucs2length(s) {
|
|
6170
|
+
let result = 0;
|
|
6171
|
+
let length = s.length;
|
|
6172
|
+
let index = 0;
|
|
6173
|
+
let charCode;
|
|
6174
|
+
while (index < length) {
|
|
6175
|
+
result++;
|
|
6176
|
+
charCode = s.charCodeAt(index++);
|
|
6177
|
+
if (charCode >= 55296 && charCode <= 56319 && index < length) {
|
|
6178
|
+
charCode = s.charCodeAt(index);
|
|
6179
|
+
if ((charCode & 64512) == 56320) index++;
|
|
6180
|
+
}
|
|
6181
|
+
}
|
|
6182
|
+
return result;
|
|
6183
|
+
}
|
|
6184
|
+
//#endregion
|
|
6185
|
+
//#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/validate.js
|
|
6186
|
+
function validate(instance, schema, draft = "2019-09", lookup = dereference(schema), shortCircuit = true, recursiveAnchor = null, instanceLocation = "#", schemaLocation = "#", evaluated = Object.create(null)) {
|
|
6187
|
+
if (schema === true) return {
|
|
6188
|
+
valid: true,
|
|
6189
|
+
errors: []
|
|
6190
|
+
};
|
|
6191
|
+
if (schema === false) return {
|
|
6192
|
+
valid: false,
|
|
6193
|
+
errors: [{
|
|
6194
|
+
instanceLocation,
|
|
6195
|
+
keyword: "false",
|
|
6196
|
+
keywordLocation: instanceLocation,
|
|
6197
|
+
error: "False boolean schema."
|
|
6198
|
+
}]
|
|
6199
|
+
};
|
|
6200
|
+
const rawInstanceType = typeof instance;
|
|
6201
|
+
let instanceType;
|
|
6202
|
+
switch (rawInstanceType) {
|
|
6203
|
+
case "boolean":
|
|
6204
|
+
case "number":
|
|
6205
|
+
case "string":
|
|
6206
|
+
instanceType = rawInstanceType;
|
|
6207
|
+
break;
|
|
6208
|
+
case "object":
|
|
6209
|
+
if (instance === null) instanceType = "null";
|
|
6210
|
+
else if (Array.isArray(instance)) instanceType = "array";
|
|
6211
|
+
else instanceType = "object";
|
|
6212
|
+
break;
|
|
6213
|
+
default: throw new Error(`Instances of "${rawInstanceType}" type are not supported.`);
|
|
6214
|
+
}
|
|
6215
|
+
const { $ref, $recursiveRef, $recursiveAnchor, type: $type, const: $const, enum: $enum, required: $required, not: $not, anyOf: $anyOf, allOf: $allOf, oneOf: $oneOf, if: $if, then: $then, else: $else, format: $format, properties: $properties, patternProperties: $patternProperties, additionalProperties: $additionalProperties, unevaluatedProperties: $unevaluatedProperties, minProperties: $minProperties, maxProperties: $maxProperties, propertyNames: $propertyNames, dependentRequired: $dependentRequired, dependentSchemas: $dependentSchemas, dependencies: $dependencies, prefixItems: $prefixItems, items: $items, additionalItems: $additionalItems, unevaluatedItems: $unevaluatedItems, contains: $contains, minContains: $minContains, maxContains: $maxContains, minItems: $minItems, maxItems: $maxItems, uniqueItems: $uniqueItems, minimum: $minimum, maximum: $maximum, exclusiveMinimum: $exclusiveMinimum, exclusiveMaximum: $exclusiveMaximum, multipleOf: $multipleOf, minLength: $minLength, maxLength: $maxLength, pattern: $pattern, __absolute_ref__, __absolute_recursive_ref__ } = schema;
|
|
6216
|
+
const errors = [];
|
|
6217
|
+
if ($recursiveAnchor === true && recursiveAnchor === null) recursiveAnchor = schema;
|
|
6218
|
+
if ($recursiveRef === "#") {
|
|
6219
|
+
const refSchema = recursiveAnchor === null ? lookup[__absolute_recursive_ref__] : recursiveAnchor;
|
|
6220
|
+
const keywordLocation = `${schemaLocation}/$recursiveRef`;
|
|
6221
|
+
const result = validate(instance, recursiveAnchor === null ? schema : recursiveAnchor, draft, lookup, shortCircuit, refSchema, instanceLocation, keywordLocation, evaluated);
|
|
6222
|
+
if (!result.valid) errors.push({
|
|
6223
|
+
instanceLocation,
|
|
6224
|
+
keyword: "$recursiveRef",
|
|
6225
|
+
keywordLocation,
|
|
6226
|
+
error: "A subschema had errors."
|
|
6227
|
+
}, ...result.errors);
|
|
6228
|
+
}
|
|
6229
|
+
if ($ref !== void 0) {
|
|
6230
|
+
const refSchema = lookup[__absolute_ref__ || $ref];
|
|
6231
|
+
if (refSchema === void 0) {
|
|
6232
|
+
let message = `Unresolved $ref "${$ref}".`;
|
|
6233
|
+
if (__absolute_ref__ && __absolute_ref__ !== $ref) message += ` Absolute URI "${__absolute_ref__}".`;
|
|
6234
|
+
message += `\nKnown schemas:\n- ${Object.keys(lookup).join("\n- ")}`;
|
|
6235
|
+
throw new Error(message);
|
|
6236
|
+
}
|
|
6237
|
+
const keywordLocation = `${schemaLocation}/$ref`;
|
|
6238
|
+
const result = validate(instance, refSchema, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, keywordLocation, evaluated);
|
|
6239
|
+
if (!result.valid) errors.push({
|
|
6240
|
+
instanceLocation,
|
|
6241
|
+
keyword: "$ref",
|
|
6242
|
+
keywordLocation,
|
|
6243
|
+
error: "A subschema had errors."
|
|
6244
|
+
}, ...result.errors);
|
|
6245
|
+
if (draft === "4" || draft === "7") return {
|
|
6246
|
+
valid: errors.length === 0,
|
|
6247
|
+
errors
|
|
6248
|
+
};
|
|
6249
|
+
}
|
|
6250
|
+
if (Array.isArray($type)) {
|
|
6251
|
+
let length = $type.length;
|
|
6252
|
+
let valid = false;
|
|
6253
|
+
for (let i = 0; i < length; i++) if (instanceType === $type[i] || $type[i] === "integer" && instanceType === "number" && instance % 1 === 0 && instance === instance) {
|
|
6254
|
+
valid = true;
|
|
6255
|
+
break;
|
|
6256
|
+
}
|
|
6257
|
+
if (!valid) errors.push({
|
|
6258
|
+
instanceLocation,
|
|
6259
|
+
keyword: "type",
|
|
6260
|
+
keywordLocation: `${schemaLocation}/type`,
|
|
6261
|
+
error: `Instance type "${instanceType}" is invalid. Expected "${$type.join("\", \"")}".`
|
|
6262
|
+
});
|
|
6263
|
+
} else if ($type === "integer") {
|
|
6264
|
+
if (instanceType !== "number" || instance % 1 || instance !== instance) errors.push({
|
|
6265
|
+
instanceLocation,
|
|
6266
|
+
keyword: "type",
|
|
6267
|
+
keywordLocation: `${schemaLocation}/type`,
|
|
6268
|
+
error: `Instance type "${instanceType}" is invalid. Expected "${$type}".`
|
|
6269
|
+
});
|
|
6270
|
+
} else if ($type !== void 0 && instanceType !== $type) errors.push({
|
|
6271
|
+
instanceLocation,
|
|
6272
|
+
keyword: "type",
|
|
6273
|
+
keywordLocation: `${schemaLocation}/type`,
|
|
6274
|
+
error: `Instance type "${instanceType}" is invalid. Expected "${$type}".`
|
|
6275
|
+
});
|
|
6276
|
+
if ($const !== void 0) {
|
|
6277
|
+
if (instanceType === "object" || instanceType === "array") {
|
|
6278
|
+
if (!deepCompareStrict(instance, $const)) errors.push({
|
|
6279
|
+
instanceLocation,
|
|
6280
|
+
keyword: "const",
|
|
6281
|
+
keywordLocation: `${schemaLocation}/const`,
|
|
6282
|
+
error: `Instance does not match ${JSON.stringify($const)}.`
|
|
6283
|
+
});
|
|
6284
|
+
} else if (instance !== $const) errors.push({
|
|
6285
|
+
instanceLocation,
|
|
6286
|
+
keyword: "const",
|
|
6287
|
+
keywordLocation: `${schemaLocation}/const`,
|
|
6288
|
+
error: `Instance does not match ${JSON.stringify($const)}.`
|
|
6289
|
+
});
|
|
6290
|
+
}
|
|
6291
|
+
if ($enum !== void 0) {
|
|
6292
|
+
if (instanceType === "object" || instanceType === "array") {
|
|
6293
|
+
if (!$enum.some((value) => deepCompareStrict(instance, value))) errors.push({
|
|
6294
|
+
instanceLocation,
|
|
6295
|
+
keyword: "enum",
|
|
6296
|
+
keywordLocation: `${schemaLocation}/enum`,
|
|
6297
|
+
error: `Instance does not match any of ${JSON.stringify($enum)}.`
|
|
6298
|
+
});
|
|
6299
|
+
} else if (!$enum.some((value) => instance === value)) errors.push({
|
|
6300
|
+
instanceLocation,
|
|
6301
|
+
keyword: "enum",
|
|
6302
|
+
keywordLocation: `${schemaLocation}/enum`,
|
|
6303
|
+
error: `Instance does not match any of ${JSON.stringify($enum)}.`
|
|
6304
|
+
});
|
|
6305
|
+
}
|
|
6306
|
+
if ($not !== void 0) {
|
|
6307
|
+
const keywordLocation = `${schemaLocation}/not`;
|
|
6308
|
+
if (validate(instance, $not, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, keywordLocation).valid) errors.push({
|
|
6309
|
+
instanceLocation,
|
|
6310
|
+
keyword: "not",
|
|
6311
|
+
keywordLocation,
|
|
6312
|
+
error: "Instance matched \"not\" schema."
|
|
6313
|
+
});
|
|
6314
|
+
}
|
|
6315
|
+
let subEvaluateds = [];
|
|
6316
|
+
if ($anyOf !== void 0) {
|
|
6317
|
+
const keywordLocation = `${schemaLocation}/anyOf`;
|
|
6318
|
+
const errorsLength = errors.length;
|
|
6319
|
+
let anyValid = false;
|
|
6320
|
+
for (let i = 0; i < $anyOf.length; i++) {
|
|
6321
|
+
const subSchema = $anyOf[i];
|
|
6322
|
+
const subEvaluated = Object.create(evaluated);
|
|
6323
|
+
const result = validate(instance, subSchema, draft, lookup, shortCircuit, $recursiveAnchor === true ? recursiveAnchor : null, instanceLocation, `${keywordLocation}/${i}`, subEvaluated);
|
|
6324
|
+
errors.push(...result.errors);
|
|
6325
|
+
anyValid = anyValid || result.valid;
|
|
6326
|
+
if (result.valid) subEvaluateds.push(subEvaluated);
|
|
6327
|
+
}
|
|
6328
|
+
if (anyValid) errors.length = errorsLength;
|
|
6329
|
+
else errors.splice(errorsLength, 0, {
|
|
6330
|
+
instanceLocation,
|
|
6331
|
+
keyword: "anyOf",
|
|
6332
|
+
keywordLocation,
|
|
6333
|
+
error: "Instance does not match any subschemas."
|
|
6334
|
+
});
|
|
6335
|
+
}
|
|
6336
|
+
if ($allOf !== void 0) {
|
|
6337
|
+
const keywordLocation = `${schemaLocation}/allOf`;
|
|
6338
|
+
const errorsLength = errors.length;
|
|
6339
|
+
let allValid = true;
|
|
6340
|
+
for (let i = 0; i < $allOf.length; i++) {
|
|
6341
|
+
const subSchema = $allOf[i];
|
|
6342
|
+
const subEvaluated = Object.create(evaluated);
|
|
6343
|
+
const result = validate(instance, subSchema, draft, lookup, shortCircuit, $recursiveAnchor === true ? recursiveAnchor : null, instanceLocation, `${keywordLocation}/${i}`, subEvaluated);
|
|
6344
|
+
errors.push(...result.errors);
|
|
6345
|
+
allValid = allValid && result.valid;
|
|
6346
|
+
if (result.valid) subEvaluateds.push(subEvaluated);
|
|
6347
|
+
}
|
|
6348
|
+
if (allValid) errors.length = errorsLength;
|
|
6349
|
+
else errors.splice(errorsLength, 0, {
|
|
6350
|
+
instanceLocation,
|
|
6351
|
+
keyword: "allOf",
|
|
6352
|
+
keywordLocation,
|
|
6353
|
+
error: `Instance does not match every subschema.`
|
|
6354
|
+
});
|
|
6355
|
+
}
|
|
6356
|
+
if ($oneOf !== void 0) {
|
|
6357
|
+
const keywordLocation = `${schemaLocation}/oneOf`;
|
|
6358
|
+
const errorsLength = errors.length;
|
|
6359
|
+
const matches = $oneOf.filter((subSchema, i) => {
|
|
6360
|
+
const subEvaluated = Object.create(evaluated);
|
|
6361
|
+
const result = validate(instance, subSchema, draft, lookup, shortCircuit, $recursiveAnchor === true ? recursiveAnchor : null, instanceLocation, `${keywordLocation}/${i}`, subEvaluated);
|
|
6362
|
+
errors.push(...result.errors);
|
|
6363
|
+
if (result.valid) subEvaluateds.push(subEvaluated);
|
|
6364
|
+
return result.valid;
|
|
6365
|
+
}).length;
|
|
6366
|
+
if (matches === 1) errors.length = errorsLength;
|
|
6367
|
+
else errors.splice(errorsLength, 0, {
|
|
6368
|
+
instanceLocation,
|
|
6369
|
+
keyword: "oneOf",
|
|
6370
|
+
keywordLocation,
|
|
6371
|
+
error: `Instance does not match exactly one subschema (${matches} matches).`
|
|
6372
|
+
});
|
|
6373
|
+
}
|
|
6374
|
+
if (instanceType === "object" || instanceType === "array") Object.assign(evaluated, ...subEvaluateds);
|
|
6375
|
+
if ($if !== void 0) {
|
|
6376
|
+
const keywordLocation = `${schemaLocation}/if`;
|
|
6377
|
+
if (validate(instance, $if, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, keywordLocation, evaluated).valid) {
|
|
6378
|
+
if ($then !== void 0) {
|
|
6379
|
+
const thenResult = validate(instance, $then, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, `${schemaLocation}/then`, evaluated);
|
|
6380
|
+
if (!thenResult.valid) errors.push({
|
|
6381
|
+
instanceLocation,
|
|
6382
|
+
keyword: "if",
|
|
6383
|
+
keywordLocation,
|
|
6384
|
+
error: `Instance does not match "then" schema.`
|
|
6385
|
+
}, ...thenResult.errors);
|
|
6386
|
+
}
|
|
6387
|
+
} else if ($else !== void 0) {
|
|
6388
|
+
const elseResult = validate(instance, $else, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, `${schemaLocation}/else`, evaluated);
|
|
6389
|
+
if (!elseResult.valid) errors.push({
|
|
6390
|
+
instanceLocation,
|
|
6391
|
+
keyword: "if",
|
|
6392
|
+
keywordLocation,
|
|
6393
|
+
error: `Instance does not match "else" schema.`
|
|
6394
|
+
}, ...elseResult.errors);
|
|
6395
|
+
}
|
|
6396
|
+
}
|
|
6397
|
+
if (instanceType === "object") {
|
|
6398
|
+
if ($required !== void 0) {
|
|
6399
|
+
for (const key of $required) if (!(key in instance)) errors.push({
|
|
6400
|
+
instanceLocation,
|
|
6401
|
+
keyword: "required",
|
|
6402
|
+
keywordLocation: `${schemaLocation}/required`,
|
|
6403
|
+
error: `Instance does not have required property "${key}".`
|
|
6404
|
+
});
|
|
6405
|
+
}
|
|
6406
|
+
const keys = Object.keys(instance);
|
|
6407
|
+
if ($minProperties !== void 0 && keys.length < $minProperties) errors.push({
|
|
6408
|
+
instanceLocation,
|
|
6409
|
+
keyword: "minProperties",
|
|
6410
|
+
keywordLocation: `${schemaLocation}/minProperties`,
|
|
6411
|
+
error: `Instance does not have at least ${$minProperties} properties.`
|
|
6412
|
+
});
|
|
6413
|
+
if ($maxProperties !== void 0 && keys.length > $maxProperties) errors.push({
|
|
6414
|
+
instanceLocation,
|
|
6415
|
+
keyword: "maxProperties",
|
|
6416
|
+
keywordLocation: `${schemaLocation}/maxProperties`,
|
|
6417
|
+
error: `Instance does not have at least ${$maxProperties} properties.`
|
|
6418
|
+
});
|
|
6419
|
+
if ($propertyNames !== void 0) {
|
|
6420
|
+
const keywordLocation = `${schemaLocation}/propertyNames`;
|
|
6421
|
+
for (const key in instance) {
|
|
6422
|
+
const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;
|
|
6423
|
+
const result = validate(key, $propertyNames, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, keywordLocation);
|
|
6424
|
+
if (!result.valid) errors.push({
|
|
6425
|
+
instanceLocation,
|
|
6426
|
+
keyword: "propertyNames",
|
|
6427
|
+
keywordLocation,
|
|
6428
|
+
error: `Property name "${key}" does not match schema.`
|
|
6429
|
+
}, ...result.errors);
|
|
6430
|
+
}
|
|
6431
|
+
}
|
|
6432
|
+
if ($dependentRequired !== void 0) {
|
|
6433
|
+
const keywordLocation = `${schemaLocation}/dependantRequired`;
|
|
6434
|
+
for (const key in $dependentRequired) if (key in instance) {
|
|
6435
|
+
const required = $dependentRequired[key];
|
|
6436
|
+
for (const dependantKey of required) if (!(dependantKey in instance)) errors.push({
|
|
6437
|
+
instanceLocation,
|
|
6438
|
+
keyword: "dependentRequired",
|
|
6439
|
+
keywordLocation,
|
|
6440
|
+
error: `Instance has "${key}" but does not have "${dependantKey}".`
|
|
6441
|
+
});
|
|
6442
|
+
}
|
|
6443
|
+
}
|
|
6444
|
+
if ($dependentSchemas !== void 0) for (const key in $dependentSchemas) {
|
|
6445
|
+
const keywordLocation = `${schemaLocation}/dependentSchemas`;
|
|
6446
|
+
if (key in instance) {
|
|
6447
|
+
const result = validate(instance, $dependentSchemas[key], draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, `${keywordLocation}/${encodePointer(key)}`, evaluated);
|
|
6448
|
+
if (!result.valid) errors.push({
|
|
6449
|
+
instanceLocation,
|
|
6450
|
+
keyword: "dependentSchemas",
|
|
6451
|
+
keywordLocation,
|
|
6452
|
+
error: `Instance has "${key}" but does not match dependant schema.`
|
|
6453
|
+
}, ...result.errors);
|
|
6454
|
+
}
|
|
6455
|
+
}
|
|
6456
|
+
if ($dependencies !== void 0) {
|
|
6457
|
+
const keywordLocation = `${schemaLocation}/dependencies`;
|
|
6458
|
+
for (const key in $dependencies) if (key in instance) {
|
|
6459
|
+
const propsOrSchema = $dependencies[key];
|
|
6460
|
+
if (Array.isArray(propsOrSchema)) {
|
|
6461
|
+
for (const dependantKey of propsOrSchema) if (!(dependantKey in instance)) errors.push({
|
|
6462
|
+
instanceLocation,
|
|
6463
|
+
keyword: "dependencies",
|
|
6464
|
+
keywordLocation,
|
|
6465
|
+
error: `Instance has "${key}" but does not have "${dependantKey}".`
|
|
6466
|
+
});
|
|
6467
|
+
} else {
|
|
6468
|
+
const result = validate(instance, propsOrSchema, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, `${keywordLocation}/${encodePointer(key)}`);
|
|
6469
|
+
if (!result.valid) errors.push({
|
|
6470
|
+
instanceLocation,
|
|
6471
|
+
keyword: "dependencies",
|
|
6472
|
+
keywordLocation,
|
|
6473
|
+
error: `Instance has "${key}" but does not match dependant schema.`
|
|
6474
|
+
}, ...result.errors);
|
|
6475
|
+
}
|
|
6476
|
+
}
|
|
6477
|
+
}
|
|
6478
|
+
const thisEvaluated = Object.create(null);
|
|
6479
|
+
let stop = false;
|
|
6480
|
+
if ($properties !== void 0) {
|
|
6481
|
+
const keywordLocation = `${schemaLocation}/properties`;
|
|
6482
|
+
for (const key in $properties) {
|
|
6483
|
+
if (!(key in instance)) continue;
|
|
6484
|
+
const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;
|
|
6485
|
+
const result = validate(instance[key], $properties[key], draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, `${keywordLocation}/${encodePointer(key)}`);
|
|
6486
|
+
if (result.valid) evaluated[key] = thisEvaluated[key] = true;
|
|
6487
|
+
else {
|
|
6488
|
+
stop = shortCircuit;
|
|
6489
|
+
errors.push({
|
|
6490
|
+
instanceLocation,
|
|
6491
|
+
keyword: "properties",
|
|
6492
|
+
keywordLocation,
|
|
6493
|
+
error: `Property "${key}" does not match schema.`
|
|
6494
|
+
}, ...result.errors);
|
|
6495
|
+
if (stop) break;
|
|
6496
|
+
}
|
|
6497
|
+
}
|
|
6498
|
+
}
|
|
6499
|
+
if (!stop && $patternProperties !== void 0) {
|
|
6500
|
+
const keywordLocation = `${schemaLocation}/patternProperties`;
|
|
6501
|
+
for (const pattern in $patternProperties) {
|
|
6502
|
+
const regex = new RegExp(pattern, "u");
|
|
6503
|
+
const subSchema = $patternProperties[pattern];
|
|
6504
|
+
for (const key in instance) {
|
|
6505
|
+
if (!regex.test(key)) continue;
|
|
6506
|
+
const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;
|
|
6507
|
+
const result = validate(instance[key], subSchema, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, `${keywordLocation}/${encodePointer(pattern)}`);
|
|
6508
|
+
if (result.valid) evaluated[key] = thisEvaluated[key] = true;
|
|
6509
|
+
else {
|
|
6510
|
+
stop = shortCircuit;
|
|
6511
|
+
errors.push({
|
|
6512
|
+
instanceLocation,
|
|
6513
|
+
keyword: "patternProperties",
|
|
6514
|
+
keywordLocation,
|
|
6515
|
+
error: `Property "${key}" matches pattern "${pattern}" but does not match associated schema.`
|
|
6516
|
+
}, ...result.errors);
|
|
6517
|
+
}
|
|
6518
|
+
}
|
|
6519
|
+
}
|
|
6520
|
+
}
|
|
6521
|
+
if (!stop && $additionalProperties !== void 0) {
|
|
6522
|
+
const keywordLocation = `${schemaLocation}/additionalProperties`;
|
|
6523
|
+
for (const key in instance) {
|
|
6524
|
+
if (thisEvaluated[key]) continue;
|
|
6525
|
+
const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;
|
|
6526
|
+
const result = validate(instance[key], $additionalProperties, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, keywordLocation);
|
|
6527
|
+
if (result.valid) evaluated[key] = true;
|
|
6528
|
+
else {
|
|
6529
|
+
stop = shortCircuit;
|
|
6530
|
+
errors.push({
|
|
6531
|
+
instanceLocation,
|
|
6532
|
+
keyword: "additionalProperties",
|
|
6533
|
+
keywordLocation,
|
|
6534
|
+
error: `Property "${key}" does not match additional properties schema.`
|
|
6535
|
+
}, ...result.errors);
|
|
6536
|
+
}
|
|
6537
|
+
}
|
|
6538
|
+
} else if (!stop && $unevaluatedProperties !== void 0) {
|
|
6539
|
+
const keywordLocation = `${schemaLocation}/unevaluatedProperties`;
|
|
6540
|
+
for (const key in instance) if (!evaluated[key]) {
|
|
6541
|
+
const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;
|
|
6542
|
+
const result = validate(instance[key], $unevaluatedProperties, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, keywordLocation);
|
|
6543
|
+
if (result.valid) evaluated[key] = true;
|
|
6544
|
+
else errors.push({
|
|
6545
|
+
instanceLocation,
|
|
6546
|
+
keyword: "unevaluatedProperties",
|
|
6547
|
+
keywordLocation,
|
|
6548
|
+
error: `Property "${key}" does not match unevaluated properties schema.`
|
|
6549
|
+
}, ...result.errors);
|
|
6550
|
+
}
|
|
6551
|
+
}
|
|
6552
|
+
} else if (instanceType === "array") {
|
|
6553
|
+
if ($maxItems !== void 0 && instance.length > $maxItems) errors.push({
|
|
6554
|
+
instanceLocation,
|
|
6555
|
+
keyword: "maxItems",
|
|
6556
|
+
keywordLocation: `${schemaLocation}/maxItems`,
|
|
6557
|
+
error: `Array has too many items (${instance.length} > ${$maxItems}).`
|
|
6558
|
+
});
|
|
6559
|
+
if ($minItems !== void 0 && instance.length < $minItems) errors.push({
|
|
6560
|
+
instanceLocation,
|
|
6561
|
+
keyword: "minItems",
|
|
6562
|
+
keywordLocation: `${schemaLocation}/minItems`,
|
|
6563
|
+
error: `Array has too few items (${instance.length} < ${$minItems}).`
|
|
6564
|
+
});
|
|
6565
|
+
const length = instance.length;
|
|
6566
|
+
let i = 0;
|
|
6567
|
+
let stop = false;
|
|
6568
|
+
if ($prefixItems !== void 0) {
|
|
6569
|
+
const keywordLocation = `${schemaLocation}/prefixItems`;
|
|
6570
|
+
const length2 = Math.min($prefixItems.length, length);
|
|
6571
|
+
for (; i < length2; i++) {
|
|
6572
|
+
const result = validate(instance[i], $prefixItems[i], draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, `${keywordLocation}/${i}`);
|
|
6573
|
+
evaluated[i] = true;
|
|
6574
|
+
if (!result.valid) {
|
|
6575
|
+
stop = shortCircuit;
|
|
6576
|
+
errors.push({
|
|
6577
|
+
instanceLocation,
|
|
6578
|
+
keyword: "prefixItems",
|
|
6579
|
+
keywordLocation,
|
|
6580
|
+
error: `Items did not match schema.`
|
|
6581
|
+
}, ...result.errors);
|
|
6582
|
+
if (stop) break;
|
|
6583
|
+
}
|
|
6584
|
+
}
|
|
6585
|
+
}
|
|
6586
|
+
if ($items !== void 0) {
|
|
6587
|
+
const keywordLocation = `${schemaLocation}/items`;
|
|
6588
|
+
if (Array.isArray($items)) {
|
|
6589
|
+
const length2 = Math.min($items.length, length);
|
|
6590
|
+
for (; i < length2; i++) {
|
|
6591
|
+
const result = validate(instance[i], $items[i], draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, `${keywordLocation}/${i}`);
|
|
6592
|
+
evaluated[i] = true;
|
|
6593
|
+
if (!result.valid) {
|
|
6594
|
+
stop = shortCircuit;
|
|
6595
|
+
errors.push({
|
|
6596
|
+
instanceLocation,
|
|
6597
|
+
keyword: "items",
|
|
6598
|
+
keywordLocation,
|
|
6599
|
+
error: `Items did not match schema.`
|
|
6600
|
+
}, ...result.errors);
|
|
6601
|
+
if (stop) break;
|
|
6602
|
+
}
|
|
6603
|
+
}
|
|
6604
|
+
} else for (; i < length; i++) {
|
|
6605
|
+
const result = validate(instance[i], $items, draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, keywordLocation);
|
|
6606
|
+
evaluated[i] = true;
|
|
6607
|
+
if (!result.valid) {
|
|
6608
|
+
stop = shortCircuit;
|
|
6609
|
+
errors.push({
|
|
6610
|
+
instanceLocation,
|
|
6611
|
+
keyword: "items",
|
|
6612
|
+
keywordLocation,
|
|
6613
|
+
error: `Items did not match schema.`
|
|
6614
|
+
}, ...result.errors);
|
|
6615
|
+
if (stop) break;
|
|
6616
|
+
}
|
|
6617
|
+
}
|
|
6618
|
+
if (!stop && $additionalItems !== void 0) {
|
|
6619
|
+
const keywordLocation = `${schemaLocation}/additionalItems`;
|
|
6620
|
+
for (; i < length; i++) {
|
|
6621
|
+
const result = validate(instance[i], $additionalItems, draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, keywordLocation);
|
|
6622
|
+
evaluated[i] = true;
|
|
6623
|
+
if (!result.valid) {
|
|
6624
|
+
stop = shortCircuit;
|
|
6625
|
+
errors.push({
|
|
6626
|
+
instanceLocation,
|
|
6627
|
+
keyword: "additionalItems",
|
|
6628
|
+
keywordLocation,
|
|
6629
|
+
error: `Items did not match additional items schema.`
|
|
6630
|
+
}, ...result.errors);
|
|
6631
|
+
}
|
|
6632
|
+
}
|
|
6633
|
+
}
|
|
6634
|
+
}
|
|
6635
|
+
if ($contains !== void 0) {
|
|
6636
|
+
if (length === 0 && $minContains === void 0) errors.push({
|
|
6637
|
+
instanceLocation,
|
|
6638
|
+
keyword: "contains",
|
|
6639
|
+
keywordLocation: `${schemaLocation}/contains`,
|
|
6640
|
+
error: `Array is empty. It must contain at least one item matching the schema.`
|
|
6641
|
+
});
|
|
6642
|
+
else if ($minContains !== void 0 && length < $minContains) errors.push({
|
|
6643
|
+
instanceLocation,
|
|
6644
|
+
keyword: "minContains",
|
|
6645
|
+
keywordLocation: `${schemaLocation}/minContains`,
|
|
6646
|
+
error: `Array has less items (${length}) than minContains (${$minContains}).`
|
|
6647
|
+
});
|
|
6648
|
+
else {
|
|
6649
|
+
const keywordLocation = `${schemaLocation}/contains`;
|
|
6650
|
+
const errorsLength = errors.length;
|
|
6651
|
+
let contained = 0;
|
|
6652
|
+
for (let j = 0; j < length; j++) {
|
|
6653
|
+
const result = validate(instance[j], $contains, draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${j}`, keywordLocation);
|
|
6654
|
+
if (result.valid) {
|
|
6655
|
+
evaluated[j] = true;
|
|
6656
|
+
contained++;
|
|
6657
|
+
} else errors.push(...result.errors);
|
|
6658
|
+
}
|
|
6659
|
+
if (contained >= ($minContains || 0)) errors.length = errorsLength;
|
|
6660
|
+
if ($minContains === void 0 && $maxContains === void 0 && contained === 0) errors.splice(errorsLength, 0, {
|
|
6661
|
+
instanceLocation,
|
|
6662
|
+
keyword: "contains",
|
|
6663
|
+
keywordLocation,
|
|
6664
|
+
error: `Array does not contain item matching schema.`
|
|
6665
|
+
});
|
|
6666
|
+
else if ($minContains !== void 0 && contained < $minContains) errors.push({
|
|
6667
|
+
instanceLocation,
|
|
6668
|
+
keyword: "minContains",
|
|
6669
|
+
keywordLocation: `${schemaLocation}/minContains`,
|
|
6670
|
+
error: `Array must contain at least ${$minContains} items matching schema. Only ${contained} items were found.`
|
|
6671
|
+
});
|
|
6672
|
+
else if ($maxContains !== void 0 && contained > $maxContains) errors.push({
|
|
6673
|
+
instanceLocation,
|
|
6674
|
+
keyword: "maxContains",
|
|
6675
|
+
keywordLocation: `${schemaLocation}/maxContains`,
|
|
6676
|
+
error: `Array may contain at most ${$maxContains} items matching schema. ${contained} items were found.`
|
|
6677
|
+
});
|
|
6678
|
+
}
|
|
6679
|
+
}
|
|
6680
|
+
if (!stop && $unevaluatedItems !== void 0) {
|
|
6681
|
+
const keywordLocation = `${schemaLocation}/unevaluatedItems`;
|
|
6682
|
+
for (; i < length; i++) {
|
|
6683
|
+
if (evaluated[i]) continue;
|
|
6684
|
+
const result = validate(instance[i], $unevaluatedItems, draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, keywordLocation);
|
|
6685
|
+
evaluated[i] = true;
|
|
6686
|
+
if (!result.valid) errors.push({
|
|
6687
|
+
instanceLocation,
|
|
6688
|
+
keyword: "unevaluatedItems",
|
|
6689
|
+
keywordLocation,
|
|
6690
|
+
error: `Items did not match unevaluated items schema.`
|
|
6691
|
+
}, ...result.errors);
|
|
6692
|
+
}
|
|
6693
|
+
}
|
|
6694
|
+
if ($uniqueItems) for (let j = 0; j < length; j++) {
|
|
6695
|
+
const a = instance[j];
|
|
6696
|
+
const ao = typeof a === "object" && a !== null;
|
|
6697
|
+
for (let k = 0; k < length; k++) {
|
|
6698
|
+
if (j === k) continue;
|
|
6699
|
+
const b = instance[k];
|
|
6700
|
+
if (a === b || ao && typeof b === "object" && b !== null && deepCompareStrict(a, b)) {
|
|
6701
|
+
errors.push({
|
|
6702
|
+
instanceLocation,
|
|
6703
|
+
keyword: "uniqueItems",
|
|
6704
|
+
keywordLocation: `${schemaLocation}/uniqueItems`,
|
|
6705
|
+
error: `Duplicate items at indexes ${j} and ${k}.`
|
|
6706
|
+
});
|
|
6707
|
+
j = Number.MAX_SAFE_INTEGER;
|
|
6708
|
+
k = Number.MAX_SAFE_INTEGER;
|
|
6709
|
+
}
|
|
6710
|
+
}
|
|
6711
|
+
}
|
|
6712
|
+
} else if (instanceType === "number") {
|
|
6713
|
+
if (draft === "4") {
|
|
6714
|
+
if ($minimum !== void 0 && ($exclusiveMinimum === true && instance <= $minimum || instance < $minimum)) errors.push({
|
|
6715
|
+
instanceLocation,
|
|
6716
|
+
keyword: "minimum",
|
|
6717
|
+
keywordLocation: `${schemaLocation}/minimum`,
|
|
6718
|
+
error: `${instance} is less than ${$exclusiveMinimum ? "or equal to " : ""} ${$minimum}.`
|
|
6719
|
+
});
|
|
6720
|
+
if ($maximum !== void 0 && ($exclusiveMaximum === true && instance >= $maximum || instance > $maximum)) errors.push({
|
|
6721
|
+
instanceLocation,
|
|
6722
|
+
keyword: "maximum",
|
|
6723
|
+
keywordLocation: `${schemaLocation}/maximum`,
|
|
6724
|
+
error: `${instance} is greater than ${$exclusiveMaximum ? "or equal to " : ""} ${$maximum}.`
|
|
6725
|
+
});
|
|
6726
|
+
} else {
|
|
6727
|
+
if ($minimum !== void 0 && instance < $minimum) errors.push({
|
|
6728
|
+
instanceLocation,
|
|
6729
|
+
keyword: "minimum",
|
|
6730
|
+
keywordLocation: `${schemaLocation}/minimum`,
|
|
6731
|
+
error: `${instance} is less than ${$minimum}.`
|
|
6732
|
+
});
|
|
6733
|
+
if ($maximum !== void 0 && instance > $maximum) errors.push({
|
|
6734
|
+
instanceLocation,
|
|
6735
|
+
keyword: "maximum",
|
|
6736
|
+
keywordLocation: `${schemaLocation}/maximum`,
|
|
6737
|
+
error: `${instance} is greater than ${$maximum}.`
|
|
6738
|
+
});
|
|
6739
|
+
if ($exclusiveMinimum !== void 0 && instance <= $exclusiveMinimum) errors.push({
|
|
6740
|
+
instanceLocation,
|
|
6741
|
+
keyword: "exclusiveMinimum",
|
|
6742
|
+
keywordLocation: `${schemaLocation}/exclusiveMinimum`,
|
|
6743
|
+
error: `${instance} is less than ${$exclusiveMinimum}.`
|
|
6744
|
+
});
|
|
6745
|
+
if ($exclusiveMaximum !== void 0 && instance >= $exclusiveMaximum) errors.push({
|
|
6746
|
+
instanceLocation,
|
|
6747
|
+
keyword: "exclusiveMaximum",
|
|
6748
|
+
keywordLocation: `${schemaLocation}/exclusiveMaximum`,
|
|
6749
|
+
error: `${instance} is greater than or equal to ${$exclusiveMaximum}.`
|
|
6750
|
+
});
|
|
6751
|
+
}
|
|
6752
|
+
if ($multipleOf !== void 0) {
|
|
6753
|
+
const remainder = instance % $multipleOf;
|
|
6754
|
+
if (Math.abs(0 - remainder) >= 1.1920929e-7 && Math.abs($multipleOf - remainder) >= 1.1920929e-7) errors.push({
|
|
6755
|
+
instanceLocation,
|
|
6756
|
+
keyword: "multipleOf",
|
|
6757
|
+
keywordLocation: `${schemaLocation}/multipleOf`,
|
|
6758
|
+
error: `${instance} is not a multiple of ${$multipleOf}.`
|
|
6759
|
+
});
|
|
6760
|
+
}
|
|
6761
|
+
} else if (instanceType === "string") {
|
|
6762
|
+
const length = $minLength === void 0 && $maxLength === void 0 ? 0 : ucs2length(instance);
|
|
6763
|
+
if ($minLength !== void 0 && length < $minLength) errors.push({
|
|
6764
|
+
instanceLocation,
|
|
6765
|
+
keyword: "minLength",
|
|
6766
|
+
keywordLocation: `${schemaLocation}/minLength`,
|
|
6767
|
+
error: `String is too short (${length} < ${$minLength}).`
|
|
6768
|
+
});
|
|
6769
|
+
if ($maxLength !== void 0 && length > $maxLength) errors.push({
|
|
6770
|
+
instanceLocation,
|
|
6771
|
+
keyword: "maxLength",
|
|
6772
|
+
keywordLocation: `${schemaLocation}/maxLength`,
|
|
6773
|
+
error: `String is too long (${length} > ${$maxLength}).`
|
|
6774
|
+
});
|
|
6775
|
+
if ($pattern !== void 0 && !new RegExp($pattern, "u").test(instance)) errors.push({
|
|
6776
|
+
instanceLocation,
|
|
6777
|
+
keyword: "pattern",
|
|
6778
|
+
keywordLocation: `${schemaLocation}/pattern`,
|
|
6779
|
+
error: `String does not match pattern.`
|
|
6780
|
+
});
|
|
6781
|
+
if ($format !== void 0 && format[$format] && !format[$format](instance)) errors.push({
|
|
6782
|
+
instanceLocation,
|
|
6783
|
+
keyword: "format",
|
|
6784
|
+
keywordLocation: `${schemaLocation}/format`,
|
|
6785
|
+
error: `String does not match format "${$format}".`
|
|
6786
|
+
});
|
|
6787
|
+
}
|
|
6788
|
+
return {
|
|
6789
|
+
valid: errors.length === 0,
|
|
6790
|
+
errors
|
|
6791
|
+
};
|
|
6792
|
+
}
|
|
6793
|
+
//#endregion
|
|
6794
|
+
//#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/validator.js
|
|
6795
|
+
var Validator = class {
|
|
6796
|
+
schema;
|
|
6797
|
+
draft;
|
|
6798
|
+
shortCircuit;
|
|
6799
|
+
lookup;
|
|
6800
|
+
constructor(schema, draft = "2019-09", shortCircuit = true) {
|
|
6801
|
+
this.schema = schema;
|
|
6802
|
+
this.draft = draft;
|
|
6803
|
+
this.shortCircuit = shortCircuit;
|
|
6804
|
+
this.lookup = dereference(schema);
|
|
6805
|
+
}
|
|
6806
|
+
validate(instance) {
|
|
6807
|
+
return validate(instance, this.schema, this.draft, this.lookup, this.shortCircuit);
|
|
6808
|
+
}
|
|
6809
|
+
addSchema(schema, id) {
|
|
6810
|
+
if (id) schema = {
|
|
6811
|
+
...schema,
|
|
6812
|
+
$id: id
|
|
6813
|
+
};
|
|
6814
|
+
dereference(schema, this.lookup);
|
|
6815
|
+
}
|
|
6816
|
+
};
|
|
6817
|
+
//#endregion
|
|
6038
6818
|
//#region src/json-schema-subset/utils.ts
|
|
6039
6819
|
var nextId = 0;
|
|
6040
6820
|
function createId() {
|
|
@@ -7988,6 +8768,7 @@ function schemaEqualsChecker(extendsContext) {
|
|
|
7988
8768
|
if (value1 === null || value2 === null) return false;
|
|
7989
8769
|
if (typeof value1 !== "object") return false;
|
|
7990
8770
|
if (typeof value1 !== typeof value2) return false;
|
|
8771
|
+
if (extendsContext.isExtendsSchema(value1) || extendsContext.isExtendsSchema(value2)) return extendsContext.equals(value1, value2);
|
|
7991
8772
|
if (isCompiledSchema(value1) && isCompiledSchema(value2)) return isCompiledSchemaEquals(value1, value2);
|
|
7992
8773
|
return isObjectLikeEquals(value1, value2);
|
|
7993
8774
|
}
|
|
@@ -8717,10 +9498,17 @@ var SingleSelectSchema = class SingleSelectSchema extends SpecialSchema {
|
|
|
8717
9498
|
}
|
|
8718
9499
|
constructor(id, value, context) {
|
|
8719
9500
|
if (!SingleSelectSchema.isMatch(value)) throw new TypeError("Invalid single-select schema.");
|
|
8720
|
-
|
|
9501
|
+
const validator = new Validator(structuredClone(value), "7");
|
|
9502
|
+
super(id, { enum: value.enum.filter((item) => validator.validate(item).valid) }, context);
|
|
8721
9503
|
}
|
|
8722
9504
|
compareImpl(other) {
|
|
8723
|
-
if (
|
|
9505
|
+
if (this.value.enum.length == 0) return [(other instanceof SingleSelectSchema ? other.value.enum.length == 0 : isCompiledSchema(other) && getKind(other) === CompiledKind.Never) ? ExpressionSingleResult.Equals : ExpressionSingleResult.ContainedBy];
|
|
9506
|
+
if (isStringLikeSchema(other)) {
|
|
9507
|
+
const validator = new Validator(structuredClone(other), "7");
|
|
9508
|
+
const accepted = this.value.enum.filter((item) => validator.validate(item).valid).length;
|
|
9509
|
+
if (accepted == this.value.enum.length) return [ExpressionSingleResult.ContainedBy];
|
|
9510
|
+
return [accepted == 0 ? ExpressionSingleResult.Rejection : ExpressionSingleResult.Intersection];
|
|
9511
|
+
}
|
|
8724
9512
|
if (other instanceof SingleSelectSchema) {
|
|
8725
9513
|
const f = new Set(this.value.enum);
|
|
8726
9514
|
let result = ExpressionSingleResult.Equals;
|