@oomol-lab/open-flow 0.1.0-beta.53 → 0.1.0-beta.55
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/{createResourceDialog-BsaBMf7_.js → createResourceDialog-4H5_lZ6s.js} +3 -3
- package/dist/browser/{main-BPABKzwN.js → dist-BFmpkX4P.js} +9 -1
- package/dist/browser/flow-authoring-node.d.ts +5 -0
- package/dist/browser/flow-authoring.d.ts +1 -1
- package/dist/browser/flow-authoring.js +9434 -9187
- package/dist/browser/flow-change.d.ts +6 -1
- package/dist/browser/flow-change.js +3108 -141
- package/dist/browser/{flowChanges-CcscgZsW.js → flowChanges-ZzG-f9cg.js} +1978 -5437
- package/dist/browser/{flowWorkspace-CoT_ewLX.js → flowWorkspace-ChpRaTMX.js} +3197 -310
- package/dist/browser/{icons-0s-Q_3lp.js → icons-CdAB9wyS.js} +4294 -54
- package/dist/browser/{markdownContent-D3FFc-u_.js → markdownContent-frwDfQQU.js} +1 -2
- package/dist/browser/preview.css +375 -322
- package/dist/browser/preview.js +5458 -1888
- package/dist/browser/theme.css +1 -0
- package/dist/browser/ui.css +30 -0
- package/dist/browser/ui.js +4 -3
- package/dist/browser/workbench.css +375 -322
- package/dist/browser/workbench.js +28 -16
- package/dist/browser/{workbenchSelect-BqUPacsr.js → workbenchSelect-BRZN4ish.js} +1 -1
- package/dist/common/authoringExamples.d.ts +3 -2
- package/dist/common/control-api-conformance.js +3410 -3285
- package/dist/common/control-api.js +3680 -3531
- package/dist/common/control-requests.js +2132 -1860
- package/dist/common/decision.d.ts +47 -0
- package/dist/common/decision.js +10153 -0
- package/dist/common/flow-encoding.js +3105 -124
- package/dist/common/flow-semantics.js +276 -2
- package/dist/common/integration-trigger.js +202 -1
- package/dist/common/mcp.js +3748 -3623
- package/dist/common/openapi.js +202 -1
- package/dist/common/poll-trigger.js +226 -1
- package/dist/common/run-events.js +1 -0
- package/dist/common/runtime-contract.d.ts +8 -0
- package/dist/common/scheduler.d.ts +1 -1
- package/dist/common/scheduler.js +2137 -1936
- package/dist/common/webhook-trigger.js +202 -1
- package/package.json +5 -1
- package/dist/browser/dist-BDBTOgS5.js +0 -9
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { o as __toESM, t as __commonJSMin } from "./rolldown-runtime-CEgmsyvS.js";
|
|
2
|
+
import { a as toPlainObject, i as isString } from "./dist-BFmpkX4P.js";
|
|
2
3
|
import * as React from "react";
|
|
3
4
|
import { createElement, forwardRef, useLayoutEffect, useMemo } from "react";
|
|
4
5
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -4575,6 +4576,10 @@ var triggerFocus = "trigger-focus";
|
|
|
4575
4576
|
var outsidePress = "outside-press";
|
|
4576
4577
|
var itemPress = "item-press";
|
|
4577
4578
|
var closePress = "close-press";
|
|
4579
|
+
var clearPress = "clear-press";
|
|
4580
|
+
var inputChange = "input-change";
|
|
4581
|
+
var inputClear = "input-clear";
|
|
4582
|
+
var inputPress = "input-press";
|
|
4578
4583
|
var focusOut = "focus-out";
|
|
4579
4584
|
var escapeKey = "escape-key";
|
|
4580
4585
|
var listNavigation = "list-navigation";
|
|
@@ -4621,6 +4626,14 @@ function createChangeEventDetails(reason, event, trigger, customProperties) {
|
|
|
4621
4626
|
...custom
|
|
4622
4627
|
};
|
|
4623
4628
|
}
|
|
4629
|
+
function createGenericEventDetails(reason, event, customProperties) {
|
|
4630
|
+
const custom = customProperties ?? EMPTY_OBJECT;
|
|
4631
|
+
return {
|
|
4632
|
+
reason,
|
|
4633
|
+
event: event ?? new Event("base-ui"),
|
|
4634
|
+
...custom
|
|
4635
|
+
};
|
|
4636
|
+
}
|
|
4624
4637
|
//#endregion
|
|
4625
4638
|
//#region ../../node_modules/.bun/@base-ui+react@1.4.1+fa6c2f29eeb10566/node_modules/@base-ui/react/esm/internals/useValueChanged.js
|
|
4626
4639
|
function useValueChanged(value, onChange) {
|
|
@@ -4967,6 +4980,76 @@ var createLucideIcon = (iconName, iconNode) => {
|
|
|
4967
4980
|
return Component;
|
|
4968
4981
|
};
|
|
4969
4982
|
//#endregion
|
|
4983
|
+
//#region ../../node_modules/.bun/lucide-react@0.468.0+f4eacebf2041cd4f/node_modules/lucide-react/dist/esm/icons/brain-circuit.js
|
|
4984
|
+
/**
|
|
4985
|
+
* @license lucide-react v0.468.0 - ISC
|
|
4986
|
+
*
|
|
4987
|
+
* This source code is licensed under the ISC license.
|
|
4988
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
4989
|
+
*/
|
|
4990
|
+
var BrainCircuit = createLucideIcon("BrainCircuit", [
|
|
4991
|
+
["path", {
|
|
4992
|
+
d: "M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",
|
|
4993
|
+
key: "l5xja"
|
|
4994
|
+
}],
|
|
4995
|
+
["path", {
|
|
4996
|
+
d: "M9 13a4.5 4.5 0 0 0 3-4",
|
|
4997
|
+
key: "10igwf"
|
|
4998
|
+
}],
|
|
4999
|
+
["path", {
|
|
5000
|
+
d: "M6.003 5.125A3 3 0 0 0 6.401 6.5",
|
|
5001
|
+
key: "105sqy"
|
|
5002
|
+
}],
|
|
5003
|
+
["path", {
|
|
5004
|
+
d: "M3.477 10.896a4 4 0 0 1 .585-.396",
|
|
5005
|
+
key: "ql3yin"
|
|
5006
|
+
}],
|
|
5007
|
+
["path", {
|
|
5008
|
+
d: "M6 18a4 4 0 0 1-1.967-.516",
|
|
5009
|
+
key: "2e4loj"
|
|
5010
|
+
}],
|
|
5011
|
+
["path", {
|
|
5012
|
+
d: "M12 13h4",
|
|
5013
|
+
key: "1ku699"
|
|
5014
|
+
}],
|
|
5015
|
+
["path", {
|
|
5016
|
+
d: "M12 18h6a2 2 0 0 1 2 2v1",
|
|
5017
|
+
key: "105ag5"
|
|
5018
|
+
}],
|
|
5019
|
+
["path", {
|
|
5020
|
+
d: "M12 8h8",
|
|
5021
|
+
key: "1lhi5i"
|
|
5022
|
+
}],
|
|
5023
|
+
["path", {
|
|
5024
|
+
d: "M16 8V5a2 2 0 0 1 2-2",
|
|
5025
|
+
key: "u6izg6"
|
|
5026
|
+
}],
|
|
5027
|
+
["circle", {
|
|
5028
|
+
cx: "16",
|
|
5029
|
+
cy: "13",
|
|
5030
|
+
r: ".5",
|
|
5031
|
+
key: "ry7gng"
|
|
5032
|
+
}],
|
|
5033
|
+
["circle", {
|
|
5034
|
+
cx: "18",
|
|
5035
|
+
cy: "3",
|
|
5036
|
+
r: ".5",
|
|
5037
|
+
key: "1aiba7"
|
|
5038
|
+
}],
|
|
5039
|
+
["circle", {
|
|
5040
|
+
cx: "20",
|
|
5041
|
+
cy: "21",
|
|
5042
|
+
r: ".5",
|
|
5043
|
+
key: "yhc1fs"
|
|
5044
|
+
}],
|
|
5045
|
+
["circle", {
|
|
5046
|
+
cx: "20",
|
|
5047
|
+
cy: "8",
|
|
5048
|
+
r: ".5",
|
|
5049
|
+
key: "1e43v0"
|
|
5050
|
+
}]
|
|
5051
|
+
]);
|
|
5052
|
+
//#endregion
|
|
4970
5053
|
//#region ../../node_modules/.bun/lucide-react@0.468.0+f4eacebf2041cd4f/node_modules/lucide-react/dist/esm/icons/check.js
|
|
4971
5054
|
/**
|
|
4972
5055
|
* @license lucide-react v0.468.0 - ISC
|
|
@@ -5150,7 +5233,7 @@ var platform$1 = getPlatform();
|
|
|
5150
5233
|
var userAgent = getUserAgent();
|
|
5151
5234
|
var isWebKit = typeof CSS === "undefined" || !CSS.supports ? false : CSS.supports("-webkit-backdrop-filter:none");
|
|
5152
5235
|
var isIOS = nav.platform === "MacIntel" && nav.maxTouchPoints > 1 ? true : /iP(hone|ad|od)|iOS/.test(nav.platform);
|
|
5153
|
-
hasNavigator && /firefox/i.test(userAgent);
|
|
5236
|
+
var isFirefox = hasNavigator && /firefox/i.test(userAgent);
|
|
5154
5237
|
var isSafari = hasNavigator && /apple/i.test(navigator.vendor);
|
|
5155
5238
|
hasNavigator && /Edg/i.test(userAgent);
|
|
5156
5239
|
var isAndroid = hasNavigator && /android/i.test(platform$1) || /android/i.test(userAgent);
|
|
@@ -14977,7 +15060,7 @@ var BIGINT_FORMAT_RANGES = {
|
|
|
14977
15060
|
int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
|
|
14978
15061
|
uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")]
|
|
14979
15062
|
};
|
|
14980
|
-
function pick(schema, mask) {
|
|
15063
|
+
function pick$1(schema, mask) {
|
|
14981
15064
|
const currDef = schema._zod.def;
|
|
14982
15065
|
const checks = currDef.checks;
|
|
14983
15066
|
if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
@@ -15622,7 +15705,7 @@ var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
15622
15705
|
};
|
|
15623
15706
|
var COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
|
|
15624
15707
|
var COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
|
|
15625
|
-
var validate = ((schema, value, _ctx) => {
|
|
15708
|
+
var validate$1 = ((schema, value, _ctx) => {
|
|
15626
15709
|
const validator = schema._zod.bag.validator;
|
|
15627
15710
|
if (validator !== void 0) {
|
|
15628
15711
|
if (validator(value) !== COMPILE_INVALID) return true;
|
|
@@ -15774,12 +15857,12 @@ var dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][
|
|
|
15774
15857
|
function anchor(source) {
|
|
15775
15858
|
return new RegExp(`^${source}$`);
|
|
15776
15859
|
}
|
|
15777
|
-
var date = /*@__PURE__*/ anchor(dateSource);
|
|
15860
|
+
var date$1 = /*@__PURE__*/ anchor(dateSource);
|
|
15778
15861
|
function timeSource(args) {
|
|
15779
15862
|
const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
|
|
15780
15863
|
return typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : args.seconds ? `${hhmm}:[0-5]\\d(?:\\.\\d+)?` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
15781
15864
|
}
|
|
15782
|
-
function time(args) {
|
|
15865
|
+
function time$1(args) {
|
|
15783
15866
|
return new RegExp(`^${timeSource(args)}$`);
|
|
15784
15867
|
}
|
|
15785
15868
|
function datetime(args) {
|
|
@@ -16437,11 +16520,11 @@ var $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def)
|
|
|
16437
16520
|
$ZodStringFormat.init(inst, def);
|
|
16438
16521
|
});
|
|
16439
16522
|
var $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
|
|
16440
|
-
def.pattern ?? (def.pattern = date);
|
|
16523
|
+
def.pattern ?? (def.pattern = date$1);
|
|
16441
16524
|
$ZodStringFormat.init(inst, def);
|
|
16442
16525
|
});
|
|
16443
16526
|
var $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def) => {
|
|
16444
|
-
def.pattern ?? (def.pattern = time(def));
|
|
16527
|
+
def.pattern ?? (def.pattern = time$1(def));
|
|
16445
16528
|
$ZodStringFormat.init(inst, def);
|
|
16446
16529
|
});
|
|
16447
16530
|
var $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def) => {
|
|
@@ -19632,7 +19715,7 @@ var ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
|
|
|
19632
19715
|
own(this, "spa", value);
|
|
19633
19716
|
},
|
|
19634
19717
|
validate(data, params) {
|
|
19635
|
-
return validate(this, data, params);
|
|
19718
|
+
return validate$1(this, data, params);
|
|
19636
19719
|
},
|
|
19637
19720
|
validateAsync(data, params) {
|
|
19638
19721
|
return validateAsync$1(this, data, params);
|
|
@@ -20083,7 +20166,7 @@ var ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
|
|
|
20083
20166
|
return merge(this, other);
|
|
20084
20167
|
},
|
|
20085
20168
|
pick(mask) {
|
|
20086
|
-
return pick(this, mask);
|
|
20169
|
+
return pick$1(this, mask);
|
|
20087
20170
|
},
|
|
20088
20171
|
omit(mask) {
|
|
20089
20172
|
return omit(this, mask);
|
|
@@ -20448,56 +20531,4116 @@ function dequal(foo, bar) {
|
|
|
20448
20531
|
}
|
|
20449
20532
|
return foo !== foo && bar !== bar;
|
|
20450
20533
|
}
|
|
20451
|
-
|
|
20452
|
-
|
|
20453
|
-
|
|
20534
|
+
//#endregion
|
|
20535
|
+
//#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/deep-compare-strict.js
|
|
20536
|
+
function deepCompareStrict(a, b) {
|
|
20537
|
+
const typeofa = typeof a;
|
|
20538
|
+
if (typeofa !== typeof b) return false;
|
|
20539
|
+
if (Array.isArray(a)) {
|
|
20540
|
+
if (!Array.isArray(b)) return false;
|
|
20541
|
+
const length = a.length;
|
|
20542
|
+
if (length !== b.length) return false;
|
|
20543
|
+
for (let i = 0; i < length; i++) if (!deepCompareStrict(a[i], b[i])) return false;
|
|
20544
|
+
return true;
|
|
20545
|
+
}
|
|
20546
|
+
if (typeofa === "object") {
|
|
20547
|
+
if (!a || !b) return a === b;
|
|
20548
|
+
const aKeys = Object.keys(a);
|
|
20549
|
+
const bKeys = Object.keys(b);
|
|
20550
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
20551
|
+
for (const k of aKeys) if (!deepCompareStrict(a[k], b[k])) return false;
|
|
20552
|
+
return true;
|
|
20553
|
+
}
|
|
20554
|
+
return a === b;
|
|
20454
20555
|
}
|
|
20455
20556
|
//#endregion
|
|
20456
|
-
//#region
|
|
20457
|
-
|
|
20458
|
-
|
|
20459
|
-
|
|
20460
|
-
|
|
20461
|
-
|
|
20462
|
-
|
|
20463
|
-
unit: _enum([
|
|
20464
|
-
"day",
|
|
20465
|
-
"hour",
|
|
20466
|
-
"minute",
|
|
20467
|
-
"month",
|
|
20468
|
-
"week"
|
|
20469
|
-
]),
|
|
20470
|
-
value: number()
|
|
20471
|
-
})]));
|
|
20557
|
+
//#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/pointer.js
|
|
20558
|
+
function encodePointer(p) {
|
|
20559
|
+
return encodeURI(escapePointer(p));
|
|
20560
|
+
}
|
|
20561
|
+
function escapePointer(p) {
|
|
20562
|
+
return p.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
20563
|
+
}
|
|
20472
20564
|
//#endregion
|
|
20473
|
-
//#region
|
|
20474
|
-
var
|
|
20475
|
-
|
|
20476
|
-
|
|
20477
|
-
|
|
20478
|
-
|
|
20479
|
-
|
|
20565
|
+
//#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/dereference.js
|
|
20566
|
+
var schemaArrayKeyword = {
|
|
20567
|
+
prefixItems: true,
|
|
20568
|
+
items: true,
|
|
20569
|
+
allOf: true,
|
|
20570
|
+
anyOf: true,
|
|
20571
|
+
oneOf: true
|
|
20572
|
+
};
|
|
20573
|
+
var schemaMapKeyword = {
|
|
20574
|
+
$defs: true,
|
|
20575
|
+
definitions: true,
|
|
20576
|
+
properties: true,
|
|
20577
|
+
patternProperties: true,
|
|
20578
|
+
dependentSchemas: true
|
|
20579
|
+
};
|
|
20580
|
+
var ignoredKeyword = {
|
|
20581
|
+
id: true,
|
|
20582
|
+
$id: true,
|
|
20583
|
+
$ref: true,
|
|
20584
|
+
$schema: true,
|
|
20585
|
+
$anchor: true,
|
|
20586
|
+
$vocabulary: true,
|
|
20587
|
+
$comment: true,
|
|
20588
|
+
default: true,
|
|
20589
|
+
enum: true,
|
|
20590
|
+
const: true,
|
|
20591
|
+
required: true,
|
|
20592
|
+
type: true,
|
|
20593
|
+
maximum: true,
|
|
20594
|
+
minimum: true,
|
|
20595
|
+
exclusiveMaximum: true,
|
|
20596
|
+
exclusiveMinimum: true,
|
|
20597
|
+
multipleOf: true,
|
|
20598
|
+
maxLength: true,
|
|
20599
|
+
minLength: true,
|
|
20600
|
+
pattern: true,
|
|
20601
|
+
format: true,
|
|
20602
|
+
maxItems: true,
|
|
20603
|
+
minItems: true,
|
|
20604
|
+
uniqueItems: true,
|
|
20605
|
+
maxProperties: true,
|
|
20606
|
+
minProperties: true
|
|
20607
|
+
};
|
|
20608
|
+
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");
|
|
20609
|
+
function dereference(schema, lookup = Object.create(null), baseURI = initialBaseURI, basePointer = "") {
|
|
20610
|
+
if (schema && typeof schema === "object" && !Array.isArray(schema)) {
|
|
20611
|
+
const id = schema.$id || schema.id;
|
|
20612
|
+
if (id) {
|
|
20613
|
+
const url = new URL(id, baseURI.href);
|
|
20614
|
+
if (url.hash.length > 1) lookup[url.href] = schema;
|
|
20615
|
+
else {
|
|
20616
|
+
url.hash = "";
|
|
20617
|
+
if (basePointer === "") baseURI = url;
|
|
20618
|
+
else dereference(schema, lookup, baseURI);
|
|
20619
|
+
}
|
|
20620
|
+
}
|
|
20621
|
+
} else if (schema !== true && schema !== false) return lookup;
|
|
20622
|
+
const schemaURI = baseURI.href + (basePointer ? "#" + basePointer : "");
|
|
20623
|
+
if (lookup[schemaURI] !== void 0) throw new Error(`Duplicate schema URI "${schemaURI}".`);
|
|
20624
|
+
lookup[schemaURI] = schema;
|
|
20625
|
+
if (schema === true || schema === false) return lookup;
|
|
20626
|
+
if (schema.__absolute_uri__ === void 0) Object.defineProperty(schema, "__absolute_uri__", {
|
|
20627
|
+
enumerable: false,
|
|
20628
|
+
value: schemaURI
|
|
20629
|
+
});
|
|
20630
|
+
if (schema.$ref && schema.__absolute_ref__ === void 0) {
|
|
20631
|
+
const url = new URL(schema.$ref, baseURI.href);
|
|
20632
|
+
url.hash = url.hash;
|
|
20633
|
+
Object.defineProperty(schema, "__absolute_ref__", {
|
|
20634
|
+
enumerable: false,
|
|
20635
|
+
value: url.href
|
|
20636
|
+
});
|
|
20637
|
+
}
|
|
20638
|
+
if (schema.$recursiveRef && schema.__absolute_recursive_ref__ === void 0) {
|
|
20639
|
+
const url = new URL(schema.$recursiveRef, baseURI.href);
|
|
20640
|
+
url.hash = url.hash;
|
|
20641
|
+
Object.defineProperty(schema, "__absolute_recursive_ref__", {
|
|
20642
|
+
enumerable: false,
|
|
20643
|
+
value: url.href
|
|
20644
|
+
});
|
|
20645
|
+
}
|
|
20646
|
+
if (schema.$anchor) {
|
|
20647
|
+
const url = new URL("#" + schema.$anchor, baseURI.href);
|
|
20648
|
+
lookup[url.href] = schema;
|
|
20649
|
+
}
|
|
20650
|
+
for (let key in schema) {
|
|
20651
|
+
if (ignoredKeyword[key]) continue;
|
|
20652
|
+
const keyBase = `${basePointer}/${encodePointer(key)}`;
|
|
20653
|
+
const subSchema = schema[key];
|
|
20654
|
+
if (Array.isArray(subSchema)) {
|
|
20655
|
+
if (schemaArrayKeyword[key]) {
|
|
20656
|
+
const length = subSchema.length;
|
|
20657
|
+
for (let i = 0; i < length; i++) dereference(subSchema[i], lookup, baseURI, `${keyBase}/${i}`);
|
|
20658
|
+
}
|
|
20659
|
+
} else if (schemaMapKeyword[key]) for (let subKey in subSchema) dereference(subSchema[subKey], lookup, baseURI, `${keyBase}/${encodePointer(subKey)}`);
|
|
20660
|
+
else dereference(subSchema, lookup, baseURI, keyBase);
|
|
20661
|
+
}
|
|
20662
|
+
return lookup;
|
|
20663
|
+
}
|
|
20664
|
+
//#endregion
|
|
20665
|
+
//#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/format.js
|
|
20666
|
+
var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
20667
|
+
var DAYS = [
|
|
20668
|
+
0,
|
|
20669
|
+
31,
|
|
20670
|
+
28,
|
|
20671
|
+
31,
|
|
20672
|
+
30,
|
|
20673
|
+
31,
|
|
20674
|
+
30,
|
|
20675
|
+
31,
|
|
20676
|
+
31,
|
|
20677
|
+
30,
|
|
20678
|
+
31,
|
|
20679
|
+
30,
|
|
20680
|
+
31
|
|
20480
20681
|
];
|
|
20481
|
-
|
|
20482
|
-
|
|
20682
|
+
var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
|
|
20683
|
+
var HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i;
|
|
20684
|
+
var URIREF = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
|
20685
|
+
var URITEMPLATE = /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i;
|
|
20686
|
+
var URL_ = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu;
|
|
20687
|
+
var UUID = /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
|
|
20688
|
+
var JSON_POINTER = /^(?:\/(?:[^~/]|~0|~1)*)*$/;
|
|
20689
|
+
var JSON_POINTER_URI_FRAGMENT = /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i;
|
|
20690
|
+
var RELATIVE_JSON_POINTER = /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;
|
|
20691
|
+
var EMAIL = (input) => {
|
|
20692
|
+
if (input[0] === "\"") return false;
|
|
20693
|
+
const [name, host, ...rest] = input.split("@");
|
|
20694
|
+
if (!name || !host || rest.length !== 0 || name.length > 64 || host.length > 253) return false;
|
|
20695
|
+
if (name[0] === "." || name.endsWith(".") || name.includes("..")) return false;
|
|
20696
|
+
if (!/^[a-z0-9.-]+$/i.test(host) || !/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(name)) return false;
|
|
20697
|
+
return host.split(".").every((part) => /^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(part));
|
|
20698
|
+
};
|
|
20699
|
+
var IPV4 = /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/;
|
|
20700
|
+
var IPV6 = /^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i;
|
|
20701
|
+
var DURATION = (input) => input.length > 1 && input.length < 80 && (/^P\d+([.,]\d+)?W$/.test(input) || /^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(input) && /^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(input));
|
|
20702
|
+
function bind(r) {
|
|
20703
|
+
return r.test.bind(r);
|
|
20704
|
+
}
|
|
20705
|
+
var format = {
|
|
20706
|
+
date,
|
|
20707
|
+
time: time.bind(void 0, false),
|
|
20708
|
+
"date-time": date_time,
|
|
20709
|
+
duration: DURATION,
|
|
20710
|
+
uri,
|
|
20711
|
+
"uri-reference": bind(URIREF),
|
|
20712
|
+
"uri-template": bind(URITEMPLATE),
|
|
20713
|
+
url: bind(URL_),
|
|
20714
|
+
email: EMAIL,
|
|
20715
|
+
hostname: bind(HOSTNAME),
|
|
20716
|
+
ipv4: bind(IPV4),
|
|
20717
|
+
ipv6: bind(IPV6),
|
|
20718
|
+
regex,
|
|
20719
|
+
uuid: bind(UUID),
|
|
20720
|
+
"json-pointer": bind(JSON_POINTER),
|
|
20721
|
+
"json-pointer-uri-fragment": bind(JSON_POINTER_URI_FRAGMENT),
|
|
20722
|
+
"relative-json-pointer": bind(RELATIVE_JSON_POINTER)
|
|
20723
|
+
};
|
|
20724
|
+
function isLeapYear(year) {
|
|
20725
|
+
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
20726
|
+
}
|
|
20727
|
+
function date(str) {
|
|
20728
|
+
const matches = str.match(DATE);
|
|
20729
|
+
if (!matches) return false;
|
|
20730
|
+
const year = +matches[1];
|
|
20731
|
+
const month = +matches[2];
|
|
20732
|
+
const day = +matches[3];
|
|
20733
|
+
return month >= 1 && month <= 12 && day >= 1 && day <= (month == 2 && isLeapYear(year) ? 29 : DAYS[month]);
|
|
20734
|
+
}
|
|
20735
|
+
function time(full, str) {
|
|
20736
|
+
const matches = str.match(TIME);
|
|
20737
|
+
if (!matches) return false;
|
|
20738
|
+
const hour = +matches[1];
|
|
20739
|
+
const minute = +matches[2];
|
|
20740
|
+
const second = +matches[3];
|
|
20741
|
+
const timeZone = !!matches[5];
|
|
20742
|
+
return (hour <= 23 && minute <= 59 && second <= 59 || hour == 23 && minute == 59 && second == 60) && (!full || timeZone);
|
|
20743
|
+
}
|
|
20744
|
+
var DATE_TIME_SEPARATOR = /t|\s/i;
|
|
20745
|
+
function date_time(str) {
|
|
20746
|
+
const dateTime = str.split(DATE_TIME_SEPARATOR);
|
|
20747
|
+
return dateTime.length == 2 && date(dateTime[0]) && time(true, dateTime[1]);
|
|
20748
|
+
}
|
|
20749
|
+
var NOT_URI_FRAGMENT = /\/|:/;
|
|
20750
|
+
var URI_PATTERN = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
|
20751
|
+
function uri(str) {
|
|
20752
|
+
return NOT_URI_FRAGMENT.test(str) && URI_PATTERN.test(str);
|
|
20753
|
+
}
|
|
20754
|
+
var Z_ANCHOR = /[^\\]\\Z/;
|
|
20755
|
+
function regex(str) {
|
|
20756
|
+
if (Z_ANCHOR.test(str)) return false;
|
|
20757
|
+
try {
|
|
20758
|
+
new RegExp(str, "u");
|
|
20759
|
+
return true;
|
|
20760
|
+
} catch (e) {
|
|
20761
|
+
return false;
|
|
20762
|
+
}
|
|
20483
20763
|
}
|
|
20484
|
-
|
|
20485
|
-
|
|
20486
|
-
|
|
20487
|
-
|
|
20488
|
-
|
|
20489
|
-
|
|
20490
|
-
|
|
20491
|
-
|
|
20764
|
+
//#endregion
|
|
20765
|
+
//#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/ucs2-length.js
|
|
20766
|
+
function ucs2length(s) {
|
|
20767
|
+
let result = 0;
|
|
20768
|
+
let length = s.length;
|
|
20769
|
+
let index = 0;
|
|
20770
|
+
let charCode;
|
|
20771
|
+
while (index < length) {
|
|
20772
|
+
result++;
|
|
20773
|
+
charCode = s.charCodeAt(index++);
|
|
20774
|
+
if (charCode >= 55296 && charCode <= 56319 && index < length) {
|
|
20775
|
+
charCode = s.charCodeAt(index);
|
|
20776
|
+
if ((charCode & 64512) == 56320) index++;
|
|
20777
|
+
}
|
|
20778
|
+
}
|
|
20779
|
+
return result;
|
|
20780
|
+
}
|
|
20781
|
+
//#endregion
|
|
20782
|
+
//#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/validate.js
|
|
20783
|
+
function validate(instance, schema, draft = "2019-09", lookup = dereference(schema), shortCircuit = true, recursiveAnchor = null, instanceLocation = "#", schemaLocation = "#", evaluated = Object.create(null)) {
|
|
20784
|
+
if (schema === true) return {
|
|
20785
|
+
valid: true,
|
|
20786
|
+
errors: []
|
|
20787
|
+
};
|
|
20788
|
+
if (schema === false) return {
|
|
20789
|
+
valid: false,
|
|
20790
|
+
errors: [{
|
|
20791
|
+
instanceLocation,
|
|
20792
|
+
keyword: "false",
|
|
20793
|
+
keywordLocation: instanceLocation,
|
|
20794
|
+
error: "False boolean schema."
|
|
20795
|
+
}]
|
|
20796
|
+
};
|
|
20797
|
+
const rawInstanceType = typeof instance;
|
|
20798
|
+
let instanceType;
|
|
20799
|
+
switch (rawInstanceType) {
|
|
20800
|
+
case "boolean":
|
|
20801
|
+
case "number":
|
|
20802
|
+
case "string":
|
|
20803
|
+
instanceType = rawInstanceType;
|
|
20804
|
+
break;
|
|
20805
|
+
case "object":
|
|
20806
|
+
if (instance === null) instanceType = "null";
|
|
20807
|
+
else if (Array.isArray(instance)) instanceType = "array";
|
|
20808
|
+
else instanceType = "object";
|
|
20809
|
+
break;
|
|
20810
|
+
default: throw new Error(`Instances of "${rawInstanceType}" type are not supported.`);
|
|
20811
|
+
}
|
|
20812
|
+
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;
|
|
20813
|
+
const errors = [];
|
|
20814
|
+
if ($recursiveAnchor === true && recursiveAnchor === null) recursiveAnchor = schema;
|
|
20815
|
+
if ($recursiveRef === "#") {
|
|
20816
|
+
const refSchema = recursiveAnchor === null ? lookup[__absolute_recursive_ref__] : recursiveAnchor;
|
|
20817
|
+
const keywordLocation = `${schemaLocation}/$recursiveRef`;
|
|
20818
|
+
const result = validate(instance, recursiveAnchor === null ? schema : recursiveAnchor, draft, lookup, shortCircuit, refSchema, instanceLocation, keywordLocation, evaluated);
|
|
20819
|
+
if (!result.valid) errors.push({
|
|
20820
|
+
instanceLocation,
|
|
20821
|
+
keyword: "$recursiveRef",
|
|
20822
|
+
keywordLocation,
|
|
20823
|
+
error: "A subschema had errors."
|
|
20824
|
+
}, ...result.errors);
|
|
20825
|
+
}
|
|
20826
|
+
if ($ref !== void 0) {
|
|
20827
|
+
const refSchema = lookup[__absolute_ref__ || $ref];
|
|
20828
|
+
if (refSchema === void 0) {
|
|
20829
|
+
let message = `Unresolved $ref "${$ref}".`;
|
|
20830
|
+
if (__absolute_ref__ && __absolute_ref__ !== $ref) message += ` Absolute URI "${__absolute_ref__}".`;
|
|
20831
|
+
message += `\nKnown schemas:\n- ${Object.keys(lookup).join("\n- ")}`;
|
|
20832
|
+
throw new Error(message);
|
|
20833
|
+
}
|
|
20834
|
+
const keywordLocation = `${schemaLocation}/$ref`;
|
|
20835
|
+
const result = validate(instance, refSchema, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, keywordLocation, evaluated);
|
|
20836
|
+
if (!result.valid) errors.push({
|
|
20837
|
+
instanceLocation,
|
|
20838
|
+
keyword: "$ref",
|
|
20839
|
+
keywordLocation,
|
|
20840
|
+
error: "A subschema had errors."
|
|
20841
|
+
}, ...result.errors);
|
|
20842
|
+
if (draft === "4" || draft === "7") return {
|
|
20843
|
+
valid: errors.length === 0,
|
|
20844
|
+
errors
|
|
20845
|
+
};
|
|
20846
|
+
}
|
|
20847
|
+
if (Array.isArray($type)) {
|
|
20848
|
+
let length = $type.length;
|
|
20849
|
+
let valid = false;
|
|
20850
|
+
for (let i = 0; i < length; i++) if (instanceType === $type[i] || $type[i] === "integer" && instanceType === "number" && instance % 1 === 0 && instance === instance) {
|
|
20851
|
+
valid = true;
|
|
20852
|
+
break;
|
|
20853
|
+
}
|
|
20854
|
+
if (!valid) errors.push({
|
|
20855
|
+
instanceLocation,
|
|
20856
|
+
keyword: "type",
|
|
20857
|
+
keywordLocation: `${schemaLocation}/type`,
|
|
20858
|
+
error: `Instance type "${instanceType}" is invalid. Expected "${$type.join("\", \"")}".`
|
|
20859
|
+
});
|
|
20860
|
+
} else if ($type === "integer") {
|
|
20861
|
+
if (instanceType !== "number" || instance % 1 || instance !== instance) errors.push({
|
|
20862
|
+
instanceLocation,
|
|
20863
|
+
keyword: "type",
|
|
20864
|
+
keywordLocation: `${schemaLocation}/type`,
|
|
20865
|
+
error: `Instance type "${instanceType}" is invalid. Expected "${$type}".`
|
|
20866
|
+
});
|
|
20867
|
+
} else if ($type !== void 0 && instanceType !== $type) errors.push({
|
|
20868
|
+
instanceLocation,
|
|
20869
|
+
keyword: "type",
|
|
20870
|
+
keywordLocation: `${schemaLocation}/type`,
|
|
20871
|
+
error: `Instance type "${instanceType}" is invalid. Expected "${$type}".`
|
|
20872
|
+
});
|
|
20873
|
+
if ($const !== void 0) {
|
|
20874
|
+
if (instanceType === "object" || instanceType === "array") {
|
|
20875
|
+
if (!deepCompareStrict(instance, $const)) errors.push({
|
|
20876
|
+
instanceLocation,
|
|
20877
|
+
keyword: "const",
|
|
20878
|
+
keywordLocation: `${schemaLocation}/const`,
|
|
20879
|
+
error: `Instance does not match ${JSON.stringify($const)}.`
|
|
20880
|
+
});
|
|
20881
|
+
} else if (instance !== $const) errors.push({
|
|
20882
|
+
instanceLocation,
|
|
20883
|
+
keyword: "const",
|
|
20884
|
+
keywordLocation: `${schemaLocation}/const`,
|
|
20885
|
+
error: `Instance does not match ${JSON.stringify($const)}.`
|
|
20886
|
+
});
|
|
20887
|
+
}
|
|
20888
|
+
if ($enum !== void 0) {
|
|
20889
|
+
if (instanceType === "object" || instanceType === "array") {
|
|
20890
|
+
if (!$enum.some((value) => deepCompareStrict(instance, value))) errors.push({
|
|
20891
|
+
instanceLocation,
|
|
20892
|
+
keyword: "enum",
|
|
20893
|
+
keywordLocation: `${schemaLocation}/enum`,
|
|
20894
|
+
error: `Instance does not match any of ${JSON.stringify($enum)}.`
|
|
20895
|
+
});
|
|
20896
|
+
} else if (!$enum.some((value) => instance === value)) errors.push({
|
|
20897
|
+
instanceLocation,
|
|
20898
|
+
keyword: "enum",
|
|
20899
|
+
keywordLocation: `${schemaLocation}/enum`,
|
|
20900
|
+
error: `Instance does not match any of ${JSON.stringify($enum)}.`
|
|
20901
|
+
});
|
|
20902
|
+
}
|
|
20903
|
+
if ($not !== void 0) {
|
|
20904
|
+
const keywordLocation = `${schemaLocation}/not`;
|
|
20905
|
+
if (validate(instance, $not, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, keywordLocation).valid) errors.push({
|
|
20906
|
+
instanceLocation,
|
|
20907
|
+
keyword: "not",
|
|
20908
|
+
keywordLocation,
|
|
20909
|
+
error: "Instance matched \"not\" schema."
|
|
20910
|
+
});
|
|
20911
|
+
}
|
|
20912
|
+
let subEvaluateds = [];
|
|
20913
|
+
if ($anyOf !== void 0) {
|
|
20914
|
+
const keywordLocation = `${schemaLocation}/anyOf`;
|
|
20915
|
+
const errorsLength = errors.length;
|
|
20916
|
+
let anyValid = false;
|
|
20917
|
+
for (let i = 0; i < $anyOf.length; i++) {
|
|
20918
|
+
const subSchema = $anyOf[i];
|
|
20919
|
+
const subEvaluated = Object.create(evaluated);
|
|
20920
|
+
const result = validate(instance, subSchema, draft, lookup, shortCircuit, $recursiveAnchor === true ? recursiveAnchor : null, instanceLocation, `${keywordLocation}/${i}`, subEvaluated);
|
|
20921
|
+
errors.push(...result.errors);
|
|
20922
|
+
anyValid = anyValid || result.valid;
|
|
20923
|
+
if (result.valid) subEvaluateds.push(subEvaluated);
|
|
20924
|
+
}
|
|
20925
|
+
if (anyValid) errors.length = errorsLength;
|
|
20926
|
+
else errors.splice(errorsLength, 0, {
|
|
20927
|
+
instanceLocation,
|
|
20928
|
+
keyword: "anyOf",
|
|
20929
|
+
keywordLocation,
|
|
20930
|
+
error: "Instance does not match any subschemas."
|
|
20931
|
+
});
|
|
20932
|
+
}
|
|
20933
|
+
if ($allOf !== void 0) {
|
|
20934
|
+
const keywordLocation = `${schemaLocation}/allOf`;
|
|
20935
|
+
const errorsLength = errors.length;
|
|
20936
|
+
let allValid = true;
|
|
20937
|
+
for (let i = 0; i < $allOf.length; i++) {
|
|
20938
|
+
const subSchema = $allOf[i];
|
|
20939
|
+
const subEvaluated = Object.create(evaluated);
|
|
20940
|
+
const result = validate(instance, subSchema, draft, lookup, shortCircuit, $recursiveAnchor === true ? recursiveAnchor : null, instanceLocation, `${keywordLocation}/${i}`, subEvaluated);
|
|
20941
|
+
errors.push(...result.errors);
|
|
20942
|
+
allValid = allValid && result.valid;
|
|
20943
|
+
if (result.valid) subEvaluateds.push(subEvaluated);
|
|
20944
|
+
}
|
|
20945
|
+
if (allValid) errors.length = errorsLength;
|
|
20946
|
+
else errors.splice(errorsLength, 0, {
|
|
20947
|
+
instanceLocation,
|
|
20948
|
+
keyword: "allOf",
|
|
20949
|
+
keywordLocation,
|
|
20950
|
+
error: `Instance does not match every subschema.`
|
|
20951
|
+
});
|
|
20952
|
+
}
|
|
20953
|
+
if ($oneOf !== void 0) {
|
|
20954
|
+
const keywordLocation = `${schemaLocation}/oneOf`;
|
|
20955
|
+
const errorsLength = errors.length;
|
|
20956
|
+
const matches = $oneOf.filter((subSchema, i) => {
|
|
20957
|
+
const subEvaluated = Object.create(evaluated);
|
|
20958
|
+
const result = validate(instance, subSchema, draft, lookup, shortCircuit, $recursiveAnchor === true ? recursiveAnchor : null, instanceLocation, `${keywordLocation}/${i}`, subEvaluated);
|
|
20959
|
+
errors.push(...result.errors);
|
|
20960
|
+
if (result.valid) subEvaluateds.push(subEvaluated);
|
|
20961
|
+
return result.valid;
|
|
20962
|
+
}).length;
|
|
20963
|
+
if (matches === 1) errors.length = errorsLength;
|
|
20964
|
+
else errors.splice(errorsLength, 0, {
|
|
20965
|
+
instanceLocation,
|
|
20966
|
+
keyword: "oneOf",
|
|
20967
|
+
keywordLocation,
|
|
20968
|
+
error: `Instance does not match exactly one subschema (${matches} matches).`
|
|
20969
|
+
});
|
|
20970
|
+
}
|
|
20971
|
+
if (instanceType === "object" || instanceType === "array") Object.assign(evaluated, ...subEvaluateds);
|
|
20972
|
+
if ($if !== void 0) {
|
|
20973
|
+
const keywordLocation = `${schemaLocation}/if`;
|
|
20974
|
+
if (validate(instance, $if, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, keywordLocation, evaluated).valid) {
|
|
20975
|
+
if ($then !== void 0) {
|
|
20976
|
+
const thenResult = validate(instance, $then, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, `${schemaLocation}/then`, evaluated);
|
|
20977
|
+
if (!thenResult.valid) errors.push({
|
|
20978
|
+
instanceLocation,
|
|
20979
|
+
keyword: "if",
|
|
20980
|
+
keywordLocation,
|
|
20981
|
+
error: `Instance does not match "then" schema.`
|
|
20982
|
+
}, ...thenResult.errors);
|
|
20983
|
+
}
|
|
20984
|
+
} else if ($else !== void 0) {
|
|
20985
|
+
const elseResult = validate(instance, $else, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, `${schemaLocation}/else`, evaluated);
|
|
20986
|
+
if (!elseResult.valid) errors.push({
|
|
20987
|
+
instanceLocation,
|
|
20988
|
+
keyword: "if",
|
|
20989
|
+
keywordLocation,
|
|
20990
|
+
error: `Instance does not match "else" schema.`
|
|
20991
|
+
}, ...elseResult.errors);
|
|
20992
|
+
}
|
|
20993
|
+
}
|
|
20994
|
+
if (instanceType === "object") {
|
|
20995
|
+
if ($required !== void 0) {
|
|
20996
|
+
for (const key of $required) if (!(key in instance)) errors.push({
|
|
20997
|
+
instanceLocation,
|
|
20998
|
+
keyword: "required",
|
|
20999
|
+
keywordLocation: `${schemaLocation}/required`,
|
|
21000
|
+
error: `Instance does not have required property "${key}".`
|
|
21001
|
+
});
|
|
21002
|
+
}
|
|
21003
|
+
const keys = Object.keys(instance);
|
|
21004
|
+
if ($minProperties !== void 0 && keys.length < $minProperties) errors.push({
|
|
21005
|
+
instanceLocation,
|
|
21006
|
+
keyword: "minProperties",
|
|
21007
|
+
keywordLocation: `${schemaLocation}/minProperties`,
|
|
21008
|
+
error: `Instance does not have at least ${$minProperties} properties.`
|
|
21009
|
+
});
|
|
21010
|
+
if ($maxProperties !== void 0 && keys.length > $maxProperties) errors.push({
|
|
21011
|
+
instanceLocation,
|
|
21012
|
+
keyword: "maxProperties",
|
|
21013
|
+
keywordLocation: `${schemaLocation}/maxProperties`,
|
|
21014
|
+
error: `Instance does not have at least ${$maxProperties} properties.`
|
|
21015
|
+
});
|
|
21016
|
+
if ($propertyNames !== void 0) {
|
|
21017
|
+
const keywordLocation = `${schemaLocation}/propertyNames`;
|
|
21018
|
+
for (const key in instance) {
|
|
21019
|
+
const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;
|
|
21020
|
+
const result = validate(key, $propertyNames, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, keywordLocation);
|
|
21021
|
+
if (!result.valid) errors.push({
|
|
21022
|
+
instanceLocation,
|
|
21023
|
+
keyword: "propertyNames",
|
|
21024
|
+
keywordLocation,
|
|
21025
|
+
error: `Property name "${key}" does not match schema.`
|
|
21026
|
+
}, ...result.errors);
|
|
21027
|
+
}
|
|
21028
|
+
}
|
|
21029
|
+
if ($dependentRequired !== void 0) {
|
|
21030
|
+
const keywordLocation = `${schemaLocation}/dependantRequired`;
|
|
21031
|
+
for (const key in $dependentRequired) if (key in instance) {
|
|
21032
|
+
const required = $dependentRequired[key];
|
|
21033
|
+
for (const dependantKey of required) if (!(dependantKey in instance)) errors.push({
|
|
21034
|
+
instanceLocation,
|
|
21035
|
+
keyword: "dependentRequired",
|
|
21036
|
+
keywordLocation,
|
|
21037
|
+
error: `Instance has "${key}" but does not have "${dependantKey}".`
|
|
21038
|
+
});
|
|
21039
|
+
}
|
|
21040
|
+
}
|
|
21041
|
+
if ($dependentSchemas !== void 0) for (const key in $dependentSchemas) {
|
|
21042
|
+
const keywordLocation = `${schemaLocation}/dependentSchemas`;
|
|
21043
|
+
if (key in instance) {
|
|
21044
|
+
const result = validate(instance, $dependentSchemas[key], draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, `${keywordLocation}/${encodePointer(key)}`, evaluated);
|
|
21045
|
+
if (!result.valid) errors.push({
|
|
21046
|
+
instanceLocation,
|
|
21047
|
+
keyword: "dependentSchemas",
|
|
21048
|
+
keywordLocation,
|
|
21049
|
+
error: `Instance has "${key}" but does not match dependant schema.`
|
|
21050
|
+
}, ...result.errors);
|
|
21051
|
+
}
|
|
21052
|
+
}
|
|
21053
|
+
if ($dependencies !== void 0) {
|
|
21054
|
+
const keywordLocation = `${schemaLocation}/dependencies`;
|
|
21055
|
+
for (const key in $dependencies) if (key in instance) {
|
|
21056
|
+
const propsOrSchema = $dependencies[key];
|
|
21057
|
+
if (Array.isArray(propsOrSchema)) {
|
|
21058
|
+
for (const dependantKey of propsOrSchema) if (!(dependantKey in instance)) errors.push({
|
|
21059
|
+
instanceLocation,
|
|
21060
|
+
keyword: "dependencies",
|
|
21061
|
+
keywordLocation,
|
|
21062
|
+
error: `Instance has "${key}" but does not have "${dependantKey}".`
|
|
21063
|
+
});
|
|
21064
|
+
} else {
|
|
21065
|
+
const result = validate(instance, propsOrSchema, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, `${keywordLocation}/${encodePointer(key)}`);
|
|
21066
|
+
if (!result.valid) errors.push({
|
|
21067
|
+
instanceLocation,
|
|
21068
|
+
keyword: "dependencies",
|
|
21069
|
+
keywordLocation,
|
|
21070
|
+
error: `Instance has "${key}" but does not match dependant schema.`
|
|
21071
|
+
}, ...result.errors);
|
|
21072
|
+
}
|
|
21073
|
+
}
|
|
21074
|
+
}
|
|
21075
|
+
const thisEvaluated = Object.create(null);
|
|
21076
|
+
let stop = false;
|
|
21077
|
+
if ($properties !== void 0) {
|
|
21078
|
+
const keywordLocation = `${schemaLocation}/properties`;
|
|
21079
|
+
for (const key in $properties) {
|
|
21080
|
+
if (!(key in instance)) continue;
|
|
21081
|
+
const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;
|
|
21082
|
+
const result = validate(instance[key], $properties[key], draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, `${keywordLocation}/${encodePointer(key)}`);
|
|
21083
|
+
if (result.valid) evaluated[key] = thisEvaluated[key] = true;
|
|
21084
|
+
else {
|
|
21085
|
+
stop = shortCircuit;
|
|
21086
|
+
errors.push({
|
|
21087
|
+
instanceLocation,
|
|
21088
|
+
keyword: "properties",
|
|
21089
|
+
keywordLocation,
|
|
21090
|
+
error: `Property "${key}" does not match schema.`
|
|
21091
|
+
}, ...result.errors);
|
|
21092
|
+
if (stop) break;
|
|
21093
|
+
}
|
|
21094
|
+
}
|
|
21095
|
+
}
|
|
21096
|
+
if (!stop && $patternProperties !== void 0) {
|
|
21097
|
+
const keywordLocation = `${schemaLocation}/patternProperties`;
|
|
21098
|
+
for (const pattern in $patternProperties) {
|
|
21099
|
+
const regex = new RegExp(pattern, "u");
|
|
21100
|
+
const subSchema = $patternProperties[pattern];
|
|
21101
|
+
for (const key in instance) {
|
|
21102
|
+
if (!regex.test(key)) continue;
|
|
21103
|
+
const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;
|
|
21104
|
+
const result = validate(instance[key], subSchema, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, `${keywordLocation}/${encodePointer(pattern)}`);
|
|
21105
|
+
if (result.valid) evaluated[key] = thisEvaluated[key] = true;
|
|
21106
|
+
else {
|
|
21107
|
+
stop = shortCircuit;
|
|
21108
|
+
errors.push({
|
|
21109
|
+
instanceLocation,
|
|
21110
|
+
keyword: "patternProperties",
|
|
21111
|
+
keywordLocation,
|
|
21112
|
+
error: `Property "${key}" matches pattern "${pattern}" but does not match associated schema.`
|
|
21113
|
+
}, ...result.errors);
|
|
21114
|
+
}
|
|
21115
|
+
}
|
|
21116
|
+
}
|
|
21117
|
+
}
|
|
21118
|
+
if (!stop && $additionalProperties !== void 0) {
|
|
21119
|
+
const keywordLocation = `${schemaLocation}/additionalProperties`;
|
|
21120
|
+
for (const key in instance) {
|
|
21121
|
+
if (thisEvaluated[key]) continue;
|
|
21122
|
+
const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;
|
|
21123
|
+
const result = validate(instance[key], $additionalProperties, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, keywordLocation);
|
|
21124
|
+
if (result.valid) evaluated[key] = true;
|
|
21125
|
+
else {
|
|
21126
|
+
stop = shortCircuit;
|
|
21127
|
+
errors.push({
|
|
21128
|
+
instanceLocation,
|
|
21129
|
+
keyword: "additionalProperties",
|
|
21130
|
+
keywordLocation,
|
|
21131
|
+
error: `Property "${key}" does not match additional properties schema.`
|
|
21132
|
+
}, ...result.errors);
|
|
21133
|
+
}
|
|
21134
|
+
}
|
|
21135
|
+
} else if (!stop && $unevaluatedProperties !== void 0) {
|
|
21136
|
+
const keywordLocation = `${schemaLocation}/unevaluatedProperties`;
|
|
21137
|
+
for (const key in instance) if (!evaluated[key]) {
|
|
21138
|
+
const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;
|
|
21139
|
+
const result = validate(instance[key], $unevaluatedProperties, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, keywordLocation);
|
|
21140
|
+
if (result.valid) evaluated[key] = true;
|
|
21141
|
+
else errors.push({
|
|
21142
|
+
instanceLocation,
|
|
21143
|
+
keyword: "unevaluatedProperties",
|
|
21144
|
+
keywordLocation,
|
|
21145
|
+
error: `Property "${key}" does not match unevaluated properties schema.`
|
|
21146
|
+
}, ...result.errors);
|
|
21147
|
+
}
|
|
21148
|
+
}
|
|
21149
|
+
} else if (instanceType === "array") {
|
|
21150
|
+
if ($maxItems !== void 0 && instance.length > $maxItems) errors.push({
|
|
21151
|
+
instanceLocation,
|
|
21152
|
+
keyword: "maxItems",
|
|
21153
|
+
keywordLocation: `${schemaLocation}/maxItems`,
|
|
21154
|
+
error: `Array has too many items (${instance.length} > ${$maxItems}).`
|
|
21155
|
+
});
|
|
21156
|
+
if ($minItems !== void 0 && instance.length < $minItems) errors.push({
|
|
21157
|
+
instanceLocation,
|
|
21158
|
+
keyword: "minItems",
|
|
21159
|
+
keywordLocation: `${schemaLocation}/minItems`,
|
|
21160
|
+
error: `Array has too few items (${instance.length} < ${$minItems}).`
|
|
21161
|
+
});
|
|
21162
|
+
const length = instance.length;
|
|
21163
|
+
let i = 0;
|
|
21164
|
+
let stop = false;
|
|
21165
|
+
if ($prefixItems !== void 0) {
|
|
21166
|
+
const keywordLocation = `${schemaLocation}/prefixItems`;
|
|
21167
|
+
const length2 = Math.min($prefixItems.length, length);
|
|
21168
|
+
for (; i < length2; i++) {
|
|
21169
|
+
const result = validate(instance[i], $prefixItems[i], draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, `${keywordLocation}/${i}`);
|
|
21170
|
+
evaluated[i] = true;
|
|
21171
|
+
if (!result.valid) {
|
|
21172
|
+
stop = shortCircuit;
|
|
21173
|
+
errors.push({
|
|
21174
|
+
instanceLocation,
|
|
21175
|
+
keyword: "prefixItems",
|
|
21176
|
+
keywordLocation,
|
|
21177
|
+
error: `Items did not match schema.`
|
|
21178
|
+
}, ...result.errors);
|
|
21179
|
+
if (stop) break;
|
|
21180
|
+
}
|
|
21181
|
+
}
|
|
21182
|
+
}
|
|
21183
|
+
if ($items !== void 0) {
|
|
21184
|
+
const keywordLocation = `${schemaLocation}/items`;
|
|
21185
|
+
if (Array.isArray($items)) {
|
|
21186
|
+
const length2 = Math.min($items.length, length);
|
|
21187
|
+
for (; i < length2; i++) {
|
|
21188
|
+
const result = validate(instance[i], $items[i], draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, `${keywordLocation}/${i}`);
|
|
21189
|
+
evaluated[i] = true;
|
|
21190
|
+
if (!result.valid) {
|
|
21191
|
+
stop = shortCircuit;
|
|
21192
|
+
errors.push({
|
|
21193
|
+
instanceLocation,
|
|
21194
|
+
keyword: "items",
|
|
21195
|
+
keywordLocation,
|
|
21196
|
+
error: `Items did not match schema.`
|
|
21197
|
+
}, ...result.errors);
|
|
21198
|
+
if (stop) break;
|
|
21199
|
+
}
|
|
21200
|
+
}
|
|
21201
|
+
} else for (; i < length; i++) {
|
|
21202
|
+
const result = validate(instance[i], $items, draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, keywordLocation);
|
|
21203
|
+
evaluated[i] = true;
|
|
21204
|
+
if (!result.valid) {
|
|
21205
|
+
stop = shortCircuit;
|
|
21206
|
+
errors.push({
|
|
21207
|
+
instanceLocation,
|
|
21208
|
+
keyword: "items",
|
|
21209
|
+
keywordLocation,
|
|
21210
|
+
error: `Items did not match schema.`
|
|
21211
|
+
}, ...result.errors);
|
|
21212
|
+
if (stop) break;
|
|
21213
|
+
}
|
|
21214
|
+
}
|
|
21215
|
+
if (!stop && $additionalItems !== void 0) {
|
|
21216
|
+
const keywordLocation = `${schemaLocation}/additionalItems`;
|
|
21217
|
+
for (; i < length; i++) {
|
|
21218
|
+
const result = validate(instance[i], $additionalItems, draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, keywordLocation);
|
|
21219
|
+
evaluated[i] = true;
|
|
21220
|
+
if (!result.valid) {
|
|
21221
|
+
stop = shortCircuit;
|
|
21222
|
+
errors.push({
|
|
21223
|
+
instanceLocation,
|
|
21224
|
+
keyword: "additionalItems",
|
|
21225
|
+
keywordLocation,
|
|
21226
|
+
error: `Items did not match additional items schema.`
|
|
21227
|
+
}, ...result.errors);
|
|
21228
|
+
}
|
|
21229
|
+
}
|
|
21230
|
+
}
|
|
21231
|
+
}
|
|
21232
|
+
if ($contains !== void 0) {
|
|
21233
|
+
if (length === 0 && $minContains === void 0) errors.push({
|
|
21234
|
+
instanceLocation,
|
|
21235
|
+
keyword: "contains",
|
|
21236
|
+
keywordLocation: `${schemaLocation}/contains`,
|
|
21237
|
+
error: `Array is empty. It must contain at least one item matching the schema.`
|
|
21238
|
+
});
|
|
21239
|
+
else if ($minContains !== void 0 && length < $minContains) errors.push({
|
|
21240
|
+
instanceLocation,
|
|
21241
|
+
keyword: "minContains",
|
|
21242
|
+
keywordLocation: `${schemaLocation}/minContains`,
|
|
21243
|
+
error: `Array has less items (${length}) than minContains (${$minContains}).`
|
|
21244
|
+
});
|
|
21245
|
+
else {
|
|
21246
|
+
const keywordLocation = `${schemaLocation}/contains`;
|
|
21247
|
+
const errorsLength = errors.length;
|
|
21248
|
+
let contained = 0;
|
|
21249
|
+
for (let j = 0; j < length; j++) {
|
|
21250
|
+
const result = validate(instance[j], $contains, draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${j}`, keywordLocation);
|
|
21251
|
+
if (result.valid) {
|
|
21252
|
+
evaluated[j] = true;
|
|
21253
|
+
contained++;
|
|
21254
|
+
} else errors.push(...result.errors);
|
|
21255
|
+
}
|
|
21256
|
+
if (contained >= ($minContains || 0)) errors.length = errorsLength;
|
|
21257
|
+
if ($minContains === void 0 && $maxContains === void 0 && contained === 0) errors.splice(errorsLength, 0, {
|
|
21258
|
+
instanceLocation,
|
|
21259
|
+
keyword: "contains",
|
|
21260
|
+
keywordLocation,
|
|
21261
|
+
error: `Array does not contain item matching schema.`
|
|
21262
|
+
});
|
|
21263
|
+
else if ($minContains !== void 0 && contained < $minContains) errors.push({
|
|
21264
|
+
instanceLocation,
|
|
21265
|
+
keyword: "minContains",
|
|
21266
|
+
keywordLocation: `${schemaLocation}/minContains`,
|
|
21267
|
+
error: `Array must contain at least ${$minContains} items matching schema. Only ${contained} items were found.`
|
|
21268
|
+
});
|
|
21269
|
+
else if ($maxContains !== void 0 && contained > $maxContains) errors.push({
|
|
21270
|
+
instanceLocation,
|
|
21271
|
+
keyword: "maxContains",
|
|
21272
|
+
keywordLocation: `${schemaLocation}/maxContains`,
|
|
21273
|
+
error: `Array may contain at most ${$maxContains} items matching schema. ${contained} items were found.`
|
|
21274
|
+
});
|
|
21275
|
+
}
|
|
21276
|
+
}
|
|
21277
|
+
if (!stop && $unevaluatedItems !== void 0) {
|
|
21278
|
+
const keywordLocation = `${schemaLocation}/unevaluatedItems`;
|
|
21279
|
+
for (; i < length; i++) {
|
|
21280
|
+
if (evaluated[i]) continue;
|
|
21281
|
+
const result = validate(instance[i], $unevaluatedItems, draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, keywordLocation);
|
|
21282
|
+
evaluated[i] = true;
|
|
21283
|
+
if (!result.valid) errors.push({
|
|
21284
|
+
instanceLocation,
|
|
21285
|
+
keyword: "unevaluatedItems",
|
|
21286
|
+
keywordLocation,
|
|
21287
|
+
error: `Items did not match unevaluated items schema.`
|
|
21288
|
+
}, ...result.errors);
|
|
21289
|
+
}
|
|
21290
|
+
}
|
|
21291
|
+
if ($uniqueItems) for (let j = 0; j < length; j++) {
|
|
21292
|
+
const a = instance[j];
|
|
21293
|
+
const ao = typeof a === "object" && a !== null;
|
|
21294
|
+
for (let k = 0; k < length; k++) {
|
|
21295
|
+
if (j === k) continue;
|
|
21296
|
+
const b = instance[k];
|
|
21297
|
+
if (a === b || ao && typeof b === "object" && b !== null && deepCompareStrict(a, b)) {
|
|
21298
|
+
errors.push({
|
|
21299
|
+
instanceLocation,
|
|
21300
|
+
keyword: "uniqueItems",
|
|
21301
|
+
keywordLocation: `${schemaLocation}/uniqueItems`,
|
|
21302
|
+
error: `Duplicate items at indexes ${j} and ${k}.`
|
|
21303
|
+
});
|
|
21304
|
+
j = Number.MAX_SAFE_INTEGER;
|
|
21305
|
+
k = Number.MAX_SAFE_INTEGER;
|
|
21306
|
+
}
|
|
21307
|
+
}
|
|
21308
|
+
}
|
|
21309
|
+
} else if (instanceType === "number") {
|
|
21310
|
+
if (draft === "4") {
|
|
21311
|
+
if ($minimum !== void 0 && ($exclusiveMinimum === true && instance <= $minimum || instance < $minimum)) errors.push({
|
|
21312
|
+
instanceLocation,
|
|
21313
|
+
keyword: "minimum",
|
|
21314
|
+
keywordLocation: `${schemaLocation}/minimum`,
|
|
21315
|
+
error: `${instance} is less than ${$exclusiveMinimum ? "or equal to " : ""} ${$minimum}.`
|
|
21316
|
+
});
|
|
21317
|
+
if ($maximum !== void 0 && ($exclusiveMaximum === true && instance >= $maximum || instance > $maximum)) errors.push({
|
|
21318
|
+
instanceLocation,
|
|
21319
|
+
keyword: "maximum",
|
|
21320
|
+
keywordLocation: `${schemaLocation}/maximum`,
|
|
21321
|
+
error: `${instance} is greater than ${$exclusiveMaximum ? "or equal to " : ""} ${$maximum}.`
|
|
21322
|
+
});
|
|
21323
|
+
} else {
|
|
21324
|
+
if ($minimum !== void 0 && instance < $minimum) errors.push({
|
|
21325
|
+
instanceLocation,
|
|
21326
|
+
keyword: "minimum",
|
|
21327
|
+
keywordLocation: `${schemaLocation}/minimum`,
|
|
21328
|
+
error: `${instance} is less than ${$minimum}.`
|
|
21329
|
+
});
|
|
21330
|
+
if ($maximum !== void 0 && instance > $maximum) errors.push({
|
|
21331
|
+
instanceLocation,
|
|
21332
|
+
keyword: "maximum",
|
|
21333
|
+
keywordLocation: `${schemaLocation}/maximum`,
|
|
21334
|
+
error: `${instance} is greater than ${$maximum}.`
|
|
21335
|
+
});
|
|
21336
|
+
if ($exclusiveMinimum !== void 0 && instance <= $exclusiveMinimum) errors.push({
|
|
21337
|
+
instanceLocation,
|
|
21338
|
+
keyword: "exclusiveMinimum",
|
|
21339
|
+
keywordLocation: `${schemaLocation}/exclusiveMinimum`,
|
|
21340
|
+
error: `${instance} is less than ${$exclusiveMinimum}.`
|
|
21341
|
+
});
|
|
21342
|
+
if ($exclusiveMaximum !== void 0 && instance >= $exclusiveMaximum) errors.push({
|
|
21343
|
+
instanceLocation,
|
|
21344
|
+
keyword: "exclusiveMaximum",
|
|
21345
|
+
keywordLocation: `${schemaLocation}/exclusiveMaximum`,
|
|
21346
|
+
error: `${instance} is greater than or equal to ${$exclusiveMaximum}.`
|
|
21347
|
+
});
|
|
21348
|
+
}
|
|
21349
|
+
if ($multipleOf !== void 0) {
|
|
21350
|
+
const remainder = instance % $multipleOf;
|
|
21351
|
+
if (Math.abs(0 - remainder) >= 1.1920929e-7 && Math.abs($multipleOf - remainder) >= 1.1920929e-7) errors.push({
|
|
21352
|
+
instanceLocation,
|
|
21353
|
+
keyword: "multipleOf",
|
|
21354
|
+
keywordLocation: `${schemaLocation}/multipleOf`,
|
|
21355
|
+
error: `${instance} is not a multiple of ${$multipleOf}.`
|
|
21356
|
+
});
|
|
21357
|
+
}
|
|
21358
|
+
} else if (instanceType === "string") {
|
|
21359
|
+
const length = $minLength === void 0 && $maxLength === void 0 ? 0 : ucs2length(instance);
|
|
21360
|
+
if ($minLength !== void 0 && length < $minLength) errors.push({
|
|
21361
|
+
instanceLocation,
|
|
21362
|
+
keyword: "minLength",
|
|
21363
|
+
keywordLocation: `${schemaLocation}/minLength`,
|
|
21364
|
+
error: `String is too short (${length} < ${$minLength}).`
|
|
21365
|
+
});
|
|
21366
|
+
if ($maxLength !== void 0 && length > $maxLength) errors.push({
|
|
21367
|
+
instanceLocation,
|
|
21368
|
+
keyword: "maxLength",
|
|
21369
|
+
keywordLocation: `${schemaLocation}/maxLength`,
|
|
21370
|
+
error: `String is too long (${length} > ${$maxLength}).`
|
|
21371
|
+
});
|
|
21372
|
+
if ($pattern !== void 0 && !new RegExp($pattern, "u").test(instance)) errors.push({
|
|
21373
|
+
instanceLocation,
|
|
21374
|
+
keyword: "pattern",
|
|
21375
|
+
keywordLocation: `${schemaLocation}/pattern`,
|
|
21376
|
+
error: `String does not match pattern.`
|
|
21377
|
+
});
|
|
21378
|
+
if ($format !== void 0 && format[$format] && !format[$format](instance)) errors.push({
|
|
21379
|
+
instanceLocation,
|
|
21380
|
+
keyword: "format",
|
|
21381
|
+
keywordLocation: `${schemaLocation}/format`,
|
|
21382
|
+
error: `String does not match format "${$format}".`
|
|
21383
|
+
});
|
|
21384
|
+
}
|
|
21385
|
+
return {
|
|
21386
|
+
valid: errors.length === 0,
|
|
21387
|
+
errors
|
|
21388
|
+
};
|
|
21389
|
+
}
|
|
21390
|
+
//#endregion
|
|
21391
|
+
//#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/validator.js
|
|
21392
|
+
var Validator = class {
|
|
21393
|
+
schema;
|
|
21394
|
+
draft;
|
|
21395
|
+
shortCircuit;
|
|
21396
|
+
lookup;
|
|
21397
|
+
constructor(schema, draft = "2019-09", shortCircuit = true) {
|
|
21398
|
+
this.schema = schema;
|
|
21399
|
+
this.draft = draft;
|
|
21400
|
+
this.shortCircuit = shortCircuit;
|
|
21401
|
+
this.lookup = dereference(schema);
|
|
21402
|
+
}
|
|
21403
|
+
validate(instance) {
|
|
21404
|
+
return validate(instance, this.schema, this.draft, this.lookup, this.shortCircuit);
|
|
21405
|
+
}
|
|
21406
|
+
addSchema(schema, id) {
|
|
21407
|
+
if (id) schema = {
|
|
21408
|
+
...schema,
|
|
21409
|
+
$id: id
|
|
21410
|
+
};
|
|
21411
|
+
dereference(schema, this.lookup);
|
|
21412
|
+
}
|
|
21413
|
+
};
|
|
21414
|
+
//#endregion
|
|
21415
|
+
//#region src/json-schema-subset/utils.ts
|
|
21416
|
+
var nextId = 0;
|
|
21417
|
+
function createId() {
|
|
21418
|
+
const id = nextId;
|
|
21419
|
+
nextId += 1;
|
|
21420
|
+
return id;
|
|
21421
|
+
}
|
|
21422
|
+
function deepFreeze(target) {
|
|
21423
|
+
if (typeof target === "object" && target !== null && !Object.isFrozen(target)) {
|
|
21424
|
+
for (const key of Object.getOwnPropertyNames(target)) deepFreeze(Reflect.get(target, key));
|
|
21425
|
+
Object.freeze(target);
|
|
21426
|
+
}
|
|
21427
|
+
return target;
|
|
21428
|
+
}
|
|
21429
|
+
function pick(target, keys) {
|
|
21430
|
+
const newTarget = {};
|
|
21431
|
+
for (const key of keys) if (key in target) newTarget[key] = target[key];
|
|
21432
|
+
return newTarget;
|
|
21433
|
+
}
|
|
21434
|
+
function deepCopy(value) {
|
|
21435
|
+
if (typeof value !== "object" || value === null) return value;
|
|
21436
|
+
else if (Array.isArray(value)) {
|
|
21437
|
+
const array = [];
|
|
21438
|
+
for (const [i, element] of value.entries()) array[i] = deepCopy(element);
|
|
21439
|
+
return array;
|
|
21440
|
+
} else {
|
|
21441
|
+
const newObject = {};
|
|
21442
|
+
for (const key in value) newObject[key] = deepCopy(value[key]);
|
|
21443
|
+
return newObject;
|
|
21444
|
+
}
|
|
21445
|
+
}
|
|
21446
|
+
function isDeepEquals(value1, value2) {
|
|
21447
|
+
if (value1 === value2) return true;
|
|
21448
|
+
if (value1 === null) return false;
|
|
21449
|
+
if (typeof value1 !== "object") return false;
|
|
21450
|
+
if (typeof value1 !== typeof value2) return false;
|
|
21451
|
+
if (Array.isArray(value1)) {
|
|
21452
|
+
if (!Array.isArray(value2)) return false;
|
|
21453
|
+
if (value1.length !== value2.length) return false;
|
|
21454
|
+
for (const [i, value1Element] of value1.entries()) if (!isDeepEquals(value1Element, value2[i])) return false;
|
|
21455
|
+
} else {
|
|
21456
|
+
if (Array.isArray(value2)) return false;
|
|
21457
|
+
for (const key in value1) {
|
|
21458
|
+
if (!(key in value2)) return false;
|
|
21459
|
+
if (!isDeepEquals(value1[key], value2[key])) return false;
|
|
21460
|
+
}
|
|
21461
|
+
for (const key in value2) if (!(key in value1)) return false;
|
|
21462
|
+
}
|
|
21463
|
+
return true;
|
|
21464
|
+
}
|
|
21465
|
+
//#endregion
|
|
21466
|
+
//#region src/json-schema-subset/expression/result.ts
|
|
21467
|
+
var ExpressionSingleResult = Object.freeze({
|
|
21468
|
+
Equals: 0,
|
|
21469
|
+
Containing: 1,
|
|
21470
|
+
ContainedBy: 2,
|
|
21471
|
+
Rejection: 3,
|
|
21472
|
+
Intersection: 4
|
|
20492
21473
|
});
|
|
20493
|
-
var
|
|
20494
|
-
var
|
|
20495
|
-
|
|
20496
|
-
|
|
21474
|
+
var ExpressionEquals = toExpression(ExpressionSingleResult.Equals);
|
|
21475
|
+
var ExpressionContaining = toExpression(ExpressionSingleResult.Containing);
|
|
21476
|
+
var ExpressionContainedBy = toExpression(ExpressionSingleResult.ContainedBy);
|
|
21477
|
+
var ExpressionRejection = toExpression(ExpressionSingleResult.Rejection);
|
|
21478
|
+
var ExpressionIntersection = toExpression(ExpressionSingleResult.Intersection);
|
|
21479
|
+
var ExpressionMaskList = deepFreeze([
|
|
21480
|
+
[ExpressionSingleResult.Equals, ExpressionEquals],
|
|
21481
|
+
[ExpressionSingleResult.Containing, ExpressionContaining],
|
|
21482
|
+
[ExpressionSingleResult.ContainedBy, ExpressionContainedBy],
|
|
21483
|
+
[ExpressionSingleResult.Rejection, ExpressionRejection],
|
|
21484
|
+
[ExpressionSingleResult.Intersection, ExpressionIntersection]
|
|
21485
|
+
]);
|
|
21486
|
+
var ExpressionAny = (() => {
|
|
21487
|
+
let expression = 0;
|
|
21488
|
+
for (const [_, mask] of ExpressionMaskList) expression |= mask;
|
|
21489
|
+
return expression;
|
|
21490
|
+
})();
|
|
21491
|
+
function hasEquals(expression) {
|
|
21492
|
+
return !!(expression & ExpressionEquals);
|
|
21493
|
+
}
|
|
21494
|
+
function hasContaining(expression) {
|
|
21495
|
+
return !!(expression & ExpressionContaining);
|
|
21496
|
+
}
|
|
21497
|
+
function hasContainedBy(expression) {
|
|
21498
|
+
return !!(expression & ExpressionContainedBy);
|
|
21499
|
+
}
|
|
21500
|
+
function hasRejection(expression) {
|
|
21501
|
+
return !!(expression & ExpressionRejection);
|
|
21502
|
+
}
|
|
21503
|
+
function hasIntersection(expression) {
|
|
21504
|
+
return !!(expression & ExpressionIntersection);
|
|
21505
|
+
}
|
|
21506
|
+
function toExpression(expression) {
|
|
21507
|
+
return 1 << expression;
|
|
21508
|
+
}
|
|
21509
|
+
//#endregion
|
|
21510
|
+
//#region src/json-schema-subset/expression/combination.ts
|
|
21511
|
+
function makeCombination(calculator) {
|
|
21512
|
+
let expression = 0;
|
|
21513
|
+
let count = 0;
|
|
21514
|
+
const quantum = { push: (newExpression) => {
|
|
21515
|
+
if (count === 0) expression = newExpression;
|
|
21516
|
+
else expression = forEach(expression, newExpression, calculator);
|
|
21517
|
+
count += 1;
|
|
21518
|
+
return expression;
|
|
21519
|
+
} };
|
|
21520
|
+
Object.defineProperties(quantum, {
|
|
21521
|
+
result: { get: () => expression },
|
|
21522
|
+
count: { get: () => count }
|
|
21523
|
+
});
|
|
21524
|
+
return quantum;
|
|
21525
|
+
}
|
|
21526
|
+
function forEach(e1, e2, calculator) {
|
|
21527
|
+
let expression = 0;
|
|
21528
|
+
for (const [singleResult1, mask1] of ExpressionMaskList) if (mask1 & e1) {
|
|
21529
|
+
for (const [singleResult2, mask2] of ExpressionMaskList) if (mask2 & e2) {
|
|
21530
|
+
expression |= calculator(singleResult1, singleResult2);
|
|
21531
|
+
if (expression === ExpressionAny) return expression;
|
|
21532
|
+
}
|
|
21533
|
+
}
|
|
21534
|
+
return expression;
|
|
21535
|
+
}
|
|
21536
|
+
//#endregion
|
|
21537
|
+
//#region src/json-schema-subset/expression/calculator.ts
|
|
21538
|
+
var CalculatorOperator = Object.freeze({
|
|
21539
|
+
Save: 0,
|
|
21540
|
+
OneOf: 1,
|
|
21541
|
+
AllOf: 2,
|
|
21542
|
+
AnyOf: 3,
|
|
21543
|
+
Not: 4,
|
|
21544
|
+
Swap: 5
|
|
20497
21545
|
});
|
|
20498
|
-
|
|
20499
|
-
|
|
20500
|
-
|
|
21546
|
+
function calculate(operator, expressions) {
|
|
21547
|
+
switch (operator) {
|
|
21548
|
+
case CalculatorOperator.Save: return expressions[0];
|
|
21549
|
+
case CalculatorOperator.OneOf: return calculateOneOf(expressions);
|
|
21550
|
+
case CalculatorOperator.AllOf:
|
|
21551
|
+
case CalculatorOperator.AnyOf: return calculateCombination(operator, expressions);
|
|
21552
|
+
case CalculatorOperator.Not:
|
|
21553
|
+
case CalculatorOperator.Swap: return calculateUnary(operator, expressions[0]);
|
|
21554
|
+
}
|
|
21555
|
+
}
|
|
21556
|
+
function swap(expression) {
|
|
21557
|
+
return calculateUnary(CalculatorOperator.Swap, expression);
|
|
21558
|
+
}
|
|
21559
|
+
/**
|
|
21560
|
+
* The oneOf operator is indivisible, so `a + b + c` must be evaluated as one expression.
|
|
21561
|
+
* 
|
|
21562
|
+
*/
|
|
21563
|
+
function calculateOneOf(expressions) {
|
|
21564
|
+
if (expressions.length === 1) return expressions[0];
|
|
21565
|
+
const unionSet = calculateCombination(CalculatorOperator.AnyOf, expressions);
|
|
21566
|
+
const intersectionList = [];
|
|
21567
|
+
for (let i = 0; i < expressions.length; ++i) for (let j = i + 1; j < expressions.length; ++j) {
|
|
21568
|
+
const left = expressions[i];
|
|
21569
|
+
const right = expressions[j];
|
|
21570
|
+
const intersection = calculateCombination(CalculatorOperator.AllOf, [left, right]);
|
|
21571
|
+
intersectionList.push(intersection);
|
|
21572
|
+
}
|
|
21573
|
+
const banZone = calculateCombination(CalculatorOperator.AnyOf, intersectionList);
|
|
21574
|
+
const enableZone = calculateUnary(CalculatorOperator.Not, banZone);
|
|
21575
|
+
return calculateCombination(CalculatorOperator.AllOf, [unionSet, enableZone]);
|
|
21576
|
+
}
|
|
21577
|
+
function calculateCombination(operator, expressions) {
|
|
21578
|
+
if (expressions.length < 0) throw new Error("invalid expressions: empty array");
|
|
21579
|
+
let combination;
|
|
21580
|
+
switch (operator) {
|
|
21581
|
+
case CalculatorOperator.AllOf:
|
|
21582
|
+
combination = makeCombination(calculateAllOf);
|
|
21583
|
+
break;
|
|
21584
|
+
case CalculatorOperator.AnyOf:
|
|
21585
|
+
combination = makeCombination(calculateAnyOf);
|
|
21586
|
+
break;
|
|
21587
|
+
default: throw new Error(`invalid operator ${operator}`);
|
|
21588
|
+
}
|
|
21589
|
+
for (const expression of expressions) combination.push(expression);
|
|
21590
|
+
return combination.result;
|
|
21591
|
+
}
|
|
21592
|
+
function calculateUnary(operator, expression) {
|
|
21593
|
+
let calculator;
|
|
21594
|
+
let result = 0;
|
|
21595
|
+
switch (operator) {
|
|
21596
|
+
case CalculatorOperator.Not:
|
|
21597
|
+
calculator = calculateNot;
|
|
21598
|
+
break;
|
|
21599
|
+
case CalculatorOperator.Swap:
|
|
21600
|
+
calculator = calculateSwap;
|
|
21601
|
+
break;
|
|
21602
|
+
default: throw new Error(`invalid operator ${operator}`);
|
|
21603
|
+
}
|
|
21604
|
+
for (const [singleExpression, maskExpression] of ExpressionMaskList) if (maskExpression & expression) result |= calculator(singleExpression);
|
|
21605
|
+
return result;
|
|
21606
|
+
}
|
|
21607
|
+
function calculateAllOf(e1, e2) {
|
|
21608
|
+
let result = 0;
|
|
21609
|
+
switch (e1) {
|
|
21610
|
+
case ExpressionSingleResult.Equals:
|
|
21611
|
+
switch (e2) {
|
|
21612
|
+
case ExpressionSingleResult.Equals:
|
|
21613
|
+
result = ExpressionEquals;
|
|
21614
|
+
break;
|
|
21615
|
+
case ExpressionSingleResult.Containing:
|
|
21616
|
+
result = ExpressionEquals;
|
|
21617
|
+
break;
|
|
21618
|
+
case ExpressionSingleResult.ContainedBy:
|
|
21619
|
+
result = ExpressionContainedBy;
|
|
21620
|
+
break;
|
|
21621
|
+
case ExpressionSingleResult.Rejection:
|
|
21622
|
+
result = 0;
|
|
21623
|
+
break;
|
|
21624
|
+
case ExpressionSingleResult.Intersection: result = ExpressionContainedBy;
|
|
21625
|
+
}
|
|
21626
|
+
break;
|
|
21627
|
+
case ExpressionSingleResult.Containing:
|
|
21628
|
+
switch (e2) {
|
|
21629
|
+
case ExpressionSingleResult.Equals:
|
|
21630
|
+
result = ExpressionEquals;
|
|
21631
|
+
break;
|
|
21632
|
+
case ExpressionSingleResult.Containing:
|
|
21633
|
+
result = ExpressionEquals | ExpressionContaining;
|
|
21634
|
+
break;
|
|
21635
|
+
case ExpressionSingleResult.ContainedBy:
|
|
21636
|
+
result = ExpressionContainedBy;
|
|
21637
|
+
break;
|
|
21638
|
+
case ExpressionSingleResult.Rejection:
|
|
21639
|
+
result = ExpressionRejection;
|
|
21640
|
+
break;
|
|
21641
|
+
case ExpressionSingleResult.Intersection: result = ExpressionIntersection | ExpressionContainedBy;
|
|
21642
|
+
}
|
|
21643
|
+
break;
|
|
21644
|
+
case ExpressionSingleResult.ContainedBy:
|
|
21645
|
+
switch (e2) {
|
|
21646
|
+
case ExpressionSingleResult.Equals:
|
|
21647
|
+
result = ExpressionContainedBy;
|
|
21648
|
+
break;
|
|
21649
|
+
case ExpressionSingleResult.Containing:
|
|
21650
|
+
result = ExpressionContainedBy;
|
|
21651
|
+
break;
|
|
21652
|
+
case ExpressionSingleResult.ContainedBy:
|
|
21653
|
+
result = ExpressionContainedBy;
|
|
21654
|
+
break;
|
|
21655
|
+
case ExpressionSingleResult.Rejection:
|
|
21656
|
+
result = 0;
|
|
21657
|
+
break;
|
|
21658
|
+
case ExpressionSingleResult.Intersection: result = ExpressionContainedBy;
|
|
21659
|
+
}
|
|
21660
|
+
break;
|
|
21661
|
+
case ExpressionSingleResult.Rejection:
|
|
21662
|
+
switch (e2) {
|
|
21663
|
+
case ExpressionSingleResult.Equals:
|
|
21664
|
+
result = 0;
|
|
21665
|
+
break;
|
|
21666
|
+
case ExpressionSingleResult.Containing:
|
|
21667
|
+
result = ExpressionRejection;
|
|
21668
|
+
break;
|
|
21669
|
+
case ExpressionSingleResult.ContainedBy:
|
|
21670
|
+
result = 0;
|
|
21671
|
+
break;
|
|
21672
|
+
case ExpressionSingleResult.Rejection:
|
|
21673
|
+
result = ExpressionRejection;
|
|
21674
|
+
break;
|
|
21675
|
+
case ExpressionSingleResult.Intersection: result = ExpressionRejection;
|
|
21676
|
+
}
|
|
21677
|
+
break;
|
|
21678
|
+
case ExpressionSingleResult.Intersection: switch (e2) {
|
|
21679
|
+
case ExpressionSingleResult.Equals:
|
|
21680
|
+
result = ExpressionContainedBy;
|
|
21681
|
+
break;
|
|
21682
|
+
case ExpressionSingleResult.Containing:
|
|
21683
|
+
result = ExpressionIntersection | ExpressionContainedBy;
|
|
21684
|
+
break;
|
|
21685
|
+
case ExpressionSingleResult.ContainedBy:
|
|
21686
|
+
result = ExpressionContainedBy;
|
|
21687
|
+
break;
|
|
21688
|
+
case ExpressionSingleResult.Rejection:
|
|
21689
|
+
result = ExpressionRejection;
|
|
21690
|
+
break;
|
|
21691
|
+
case ExpressionSingleResult.Intersection: result = ExpressionContainedBy | ExpressionRejection | ExpressionIntersection;
|
|
21692
|
+
}
|
|
21693
|
+
}
|
|
21694
|
+
return result;
|
|
21695
|
+
}
|
|
21696
|
+
function calculateAnyOf(e1, e2) {
|
|
21697
|
+
let result = 0;
|
|
21698
|
+
switch (e1) {
|
|
21699
|
+
case ExpressionSingleResult.Equals:
|
|
21700
|
+
switch (e2) {
|
|
21701
|
+
case ExpressionSingleResult.Equals:
|
|
21702
|
+
result = ExpressionEquals;
|
|
21703
|
+
break;
|
|
21704
|
+
case ExpressionSingleResult.Containing:
|
|
21705
|
+
result = ExpressionContaining;
|
|
21706
|
+
break;
|
|
21707
|
+
case ExpressionSingleResult.ContainedBy:
|
|
21708
|
+
result = ExpressionEquals;
|
|
21709
|
+
break;
|
|
21710
|
+
case ExpressionSingleResult.Rejection:
|
|
21711
|
+
result = ExpressionContaining;
|
|
21712
|
+
break;
|
|
21713
|
+
case ExpressionSingleResult.Intersection: result = ExpressionContaining;
|
|
21714
|
+
}
|
|
21715
|
+
break;
|
|
21716
|
+
case ExpressionSingleResult.Containing:
|
|
21717
|
+
switch (e2) {
|
|
21718
|
+
case ExpressionSingleResult.Equals:
|
|
21719
|
+
result = ExpressionContaining;
|
|
21720
|
+
break;
|
|
21721
|
+
case ExpressionSingleResult.Containing:
|
|
21722
|
+
result = ExpressionContaining;
|
|
21723
|
+
break;
|
|
21724
|
+
case ExpressionSingleResult.ContainedBy:
|
|
21725
|
+
result = ExpressionContaining;
|
|
21726
|
+
break;
|
|
21727
|
+
case ExpressionSingleResult.Rejection:
|
|
21728
|
+
result = ExpressionContaining;
|
|
21729
|
+
break;
|
|
21730
|
+
case ExpressionSingleResult.Intersection: result = ExpressionContaining;
|
|
21731
|
+
}
|
|
21732
|
+
break;
|
|
21733
|
+
case ExpressionSingleResult.ContainedBy:
|
|
21734
|
+
switch (e2) {
|
|
21735
|
+
case ExpressionSingleResult.Equals:
|
|
21736
|
+
result = ExpressionEquals;
|
|
21737
|
+
break;
|
|
21738
|
+
case ExpressionSingleResult.Containing:
|
|
21739
|
+
result = ExpressionContaining;
|
|
21740
|
+
break;
|
|
21741
|
+
case ExpressionSingleResult.ContainedBy:
|
|
21742
|
+
result = ExpressionEquals | ExpressionContainedBy;
|
|
21743
|
+
break;
|
|
21744
|
+
case ExpressionSingleResult.Rejection:
|
|
21745
|
+
result = ExpressionIntersection;
|
|
21746
|
+
break;
|
|
21747
|
+
case ExpressionSingleResult.Intersection: result = ExpressionContaining | ExpressionIntersection;
|
|
21748
|
+
}
|
|
21749
|
+
break;
|
|
21750
|
+
case ExpressionSingleResult.Rejection:
|
|
21751
|
+
switch (e2) {
|
|
21752
|
+
case ExpressionSingleResult.Equals:
|
|
21753
|
+
result = ExpressionContaining;
|
|
21754
|
+
break;
|
|
21755
|
+
case ExpressionSingleResult.Containing:
|
|
21756
|
+
result = ExpressionContaining;
|
|
21757
|
+
break;
|
|
21758
|
+
case ExpressionSingleResult.ContainedBy:
|
|
21759
|
+
result = ExpressionIntersection;
|
|
21760
|
+
break;
|
|
21761
|
+
case ExpressionSingleResult.Rejection:
|
|
21762
|
+
result = ExpressionRejection;
|
|
21763
|
+
break;
|
|
21764
|
+
case ExpressionSingleResult.Intersection: result = ExpressionIntersection;
|
|
21765
|
+
}
|
|
21766
|
+
break;
|
|
21767
|
+
case ExpressionSingleResult.Intersection: switch (e2) {
|
|
21768
|
+
case ExpressionSingleResult.Equals:
|
|
21769
|
+
result = ExpressionContaining;
|
|
21770
|
+
break;
|
|
21771
|
+
case ExpressionSingleResult.Containing:
|
|
21772
|
+
result = ExpressionContaining;
|
|
21773
|
+
break;
|
|
21774
|
+
case ExpressionSingleResult.ContainedBy:
|
|
21775
|
+
result = ExpressionContaining | ExpressionIntersection;
|
|
21776
|
+
break;
|
|
21777
|
+
case ExpressionSingleResult.Rejection:
|
|
21778
|
+
result = ExpressionIntersection;
|
|
21779
|
+
break;
|
|
21780
|
+
case ExpressionSingleResult.Intersection: result = ExpressionContaining | ExpressionIntersection;
|
|
21781
|
+
}
|
|
21782
|
+
}
|
|
21783
|
+
return result;
|
|
21784
|
+
}
|
|
21785
|
+
function calculateNot(expression) {
|
|
21786
|
+
let result = 0;
|
|
21787
|
+
switch (expression) {
|
|
21788
|
+
case ExpressionSingleResult.Equals:
|
|
21789
|
+
result = ExpressionRejection;
|
|
21790
|
+
break;
|
|
21791
|
+
case ExpressionSingleResult.Containing:
|
|
21792
|
+
result = ExpressionRejection;
|
|
21793
|
+
break;
|
|
21794
|
+
case ExpressionSingleResult.ContainedBy:
|
|
21795
|
+
result = ExpressionIntersection;
|
|
21796
|
+
break;
|
|
21797
|
+
case ExpressionSingleResult.Rejection:
|
|
21798
|
+
result = ExpressionEquals | ExpressionContaining;
|
|
21799
|
+
break;
|
|
21800
|
+
case ExpressionSingleResult.Intersection: result = ExpressionContainedBy | ExpressionIntersection;
|
|
21801
|
+
}
|
|
21802
|
+
return result;
|
|
21803
|
+
}
|
|
21804
|
+
function calculateSwap(expression) {
|
|
21805
|
+
let result = 0;
|
|
21806
|
+
switch (expression) {
|
|
21807
|
+
case ExpressionSingleResult.Equals:
|
|
21808
|
+
result = ExpressionEquals;
|
|
21809
|
+
break;
|
|
21810
|
+
case ExpressionSingleResult.Containing:
|
|
21811
|
+
result = ExpressionContainedBy;
|
|
21812
|
+
break;
|
|
21813
|
+
case ExpressionSingleResult.ContainedBy:
|
|
21814
|
+
result = ExpressionContaining;
|
|
21815
|
+
break;
|
|
21816
|
+
case ExpressionSingleResult.Rejection:
|
|
21817
|
+
result = ExpressionRejection;
|
|
21818
|
+
break;
|
|
21819
|
+
case ExpressionSingleResult.Intersection: result = ExpressionIntersection;
|
|
21820
|
+
}
|
|
21821
|
+
return result;
|
|
21822
|
+
}
|
|
21823
|
+
//#endregion
|
|
21824
|
+
//#region src/json-schema-subset/expression/types.ts
|
|
21825
|
+
var ExpressionKind = Object.freeze({
|
|
21826
|
+
Leaf: 0,
|
|
21827
|
+
Not: 1,
|
|
21828
|
+
AllOf: 2,
|
|
21829
|
+
AnyOf: 3,
|
|
21830
|
+
OneOf: 4
|
|
21831
|
+
});
|
|
21832
|
+
//#endregion
|
|
21833
|
+
//#region src/json-schema-subset/expression/expression.ts
|
|
21834
|
+
var expression = (delegate) => (e1, e2) => {
|
|
21835
|
+
const rootNode = {
|
|
21836
|
+
parent: null,
|
|
21837
|
+
swapped: false,
|
|
21838
|
+
expressions: null,
|
|
21839
|
+
calculation: {
|
|
21840
|
+
operator: CalculatorOperator.Save,
|
|
21841
|
+
results: [0],
|
|
21842
|
+
willSwap: false,
|
|
21843
|
+
count: 0
|
|
21844
|
+
}
|
|
21845
|
+
};
|
|
21846
|
+
const extendQueue = [{
|
|
21847
|
+
parent: {
|
|
21848
|
+
node: rootNode,
|
|
21849
|
+
index: 0
|
|
21850
|
+
},
|
|
21851
|
+
swapped: false,
|
|
21852
|
+
expressions: [e1, e2],
|
|
21853
|
+
calculation: null
|
|
21854
|
+
}];
|
|
21855
|
+
const calculateQueue = [];
|
|
21856
|
+
while (extendQueue.length > 0 || calculateQueue.length > 0) {
|
|
21857
|
+
while (extendQueue.length > 0) extendNode(extendQueue.pop());
|
|
21858
|
+
while (calculateQueue.length > 0) calculateNode(calculateQueue.pop());
|
|
21859
|
+
}
|
|
21860
|
+
function extendNode(node) {
|
|
21861
|
+
let result = ExpressionEquals;
|
|
21862
|
+
const [leftExpression, rightExpression] = node.expressions;
|
|
21863
|
+
if (!delegate.equals(leftExpression, rightExpression)) {
|
|
21864
|
+
const expression1 = delegate.describe(leftExpression);
|
|
21865
|
+
if (expression1.kind !== ExpressionKind.Leaf) {
|
|
21866
|
+
const [calculation, expressions] = expendExpression(expression1, false);
|
|
21867
|
+
node.expressions = null;
|
|
21868
|
+
node.calculation = calculation;
|
|
21869
|
+
for (const [index, childExpression] of expressions.entries()) extendQueue.push({
|
|
21870
|
+
parent: {
|
|
21871
|
+
node,
|
|
21872
|
+
index
|
|
21873
|
+
},
|
|
21874
|
+
swapped: node.swapped,
|
|
21875
|
+
expressions: [childExpression, rightExpression],
|
|
21876
|
+
calculation: null
|
|
21877
|
+
});
|
|
21878
|
+
return;
|
|
21879
|
+
}
|
|
21880
|
+
const expression2 = delegate.describe(rightExpression);
|
|
21881
|
+
if (expression2.kind !== ExpressionKind.Leaf) {
|
|
21882
|
+
const [calculation, expressions] = expendExpression(expression2, true);
|
|
21883
|
+
node.expressions = null;
|
|
21884
|
+
node.calculation = calculation;
|
|
21885
|
+
for (const [index, childExpression] of expressions.entries()) extendQueue.push({
|
|
21886
|
+
parent: {
|
|
21887
|
+
node,
|
|
21888
|
+
index
|
|
21889
|
+
},
|
|
21890
|
+
swapped: !node.swapped,
|
|
21891
|
+
expressions: [childExpression, leftExpression],
|
|
21892
|
+
calculation: null
|
|
21893
|
+
});
|
|
21894
|
+
return;
|
|
21895
|
+
}
|
|
21896
|
+
result = delegate.calculate(leftExpression, rightExpression);
|
|
21897
|
+
delegate.observeCalculation?.(leftExpression, rightExpression, result, node.swapped);
|
|
21898
|
+
if (result === 0) throw new Error("cannot response expression as none");
|
|
21899
|
+
}
|
|
21900
|
+
node.expressions = null;
|
|
21901
|
+
node.calculation = {
|
|
21902
|
+
operator: CalculatorOperator.Save,
|
|
21903
|
+
results: [result],
|
|
21904
|
+
willSwap: false,
|
|
21905
|
+
count: 0
|
|
21906
|
+
};
|
|
21907
|
+
calculateQueue.push(node);
|
|
21908
|
+
}
|
|
21909
|
+
function expendExpression(description, willSwap) {
|
|
21910
|
+
let operator = CalculatorOperator.Save;
|
|
21911
|
+
let expressions;
|
|
21912
|
+
switch (description.kind) {
|
|
21913
|
+
case ExpressionKind.Not:
|
|
21914
|
+
operator = CalculatorOperator.Not;
|
|
21915
|
+
expressions = [description.expression];
|
|
21916
|
+
break;
|
|
21917
|
+
case ExpressionKind.AllOf:
|
|
21918
|
+
operator = CalculatorOperator.AllOf;
|
|
21919
|
+
expressions = [...description.expressions];
|
|
21920
|
+
break;
|
|
21921
|
+
case ExpressionKind.AnyOf:
|
|
21922
|
+
operator = CalculatorOperator.AnyOf;
|
|
21923
|
+
expressions = [...description.expressions];
|
|
21924
|
+
break;
|
|
21925
|
+
case ExpressionKind.OneOf:
|
|
21926
|
+
operator = CalculatorOperator.OneOf;
|
|
21927
|
+
expressions = [...description.expressions];
|
|
21928
|
+
break;
|
|
21929
|
+
default: throw new Error(`invalid kind ${description.kind}`);
|
|
21930
|
+
}
|
|
21931
|
+
return [{
|
|
21932
|
+
operator,
|
|
21933
|
+
willSwap,
|
|
21934
|
+
count: 0,
|
|
21935
|
+
results: Array(expressions.length).fill(-1)
|
|
21936
|
+
}, expressions];
|
|
21937
|
+
}
|
|
21938
|
+
function calculateNode(node) {
|
|
21939
|
+
const calculation = node.calculation;
|
|
21940
|
+
const parent = node.parent;
|
|
21941
|
+
let result = calculate(calculation.operator, calculation.results);
|
|
21942
|
+
if (result === 0) result = ExpressionContainedBy;
|
|
21943
|
+
if (calculation.willSwap) result = swap(result);
|
|
21944
|
+
if (parent) {
|
|
21945
|
+
const parentCalculation = parent.node.calculation;
|
|
21946
|
+
const parentResults = parentCalculation.results;
|
|
21947
|
+
parentResults[parent.index] = result;
|
|
21948
|
+
parentCalculation.count += 1;
|
|
21949
|
+
if (parentCalculation.count >= parentResults.length) calculateQueue.push(parent.node);
|
|
21950
|
+
}
|
|
21951
|
+
}
|
|
21952
|
+
const result = rootNode.calculation.results[0];
|
|
21953
|
+
if (result === 0) throw new Error("cannot find result of root");
|
|
21954
|
+
return result;
|
|
21955
|
+
};
|
|
21956
|
+
//#endregion
|
|
21957
|
+
//#region src/json-schema-subset/error.ts
|
|
21958
|
+
var SchemaError = class extends Error {
|
|
21959
|
+
constructor(items = []) {
|
|
21960
|
+
super(createSchemaErrorMessage(items));
|
|
21961
|
+
this.name = "SchemaError";
|
|
21962
|
+
this.items = items;
|
|
21963
|
+
}
|
|
21964
|
+
};
|
|
21965
|
+
var SchemaErrorItemKind = Object.freeze({
|
|
21966
|
+
Compiled: 0,
|
|
21967
|
+
External: 1
|
|
21968
|
+
});
|
|
21969
|
+
function stringifySchemaError(errorItem) {
|
|
21970
|
+
switch (errorItem.kind) {
|
|
21971
|
+
case SchemaErrorItemKind.Compiled: {
|
|
21972
|
+
const { message, path } = errorItem;
|
|
21973
|
+
return `${message} (at ${path.length > 0 ? path.join(".") : "$root"})`;
|
|
21974
|
+
}
|
|
21975
|
+
case SchemaErrorItemKind.External: return String(errorItem.error);
|
|
21976
|
+
}
|
|
21977
|
+
}
|
|
21978
|
+
function createSchemaErrorMessage(items) {
|
|
21979
|
+
switch (items.length) {
|
|
21980
|
+
case 0: return "without any items";
|
|
21981
|
+
case 1: return stringifySchemaError(items[0]);
|
|
21982
|
+
default: return `${stringifySchemaError(items[0])} ... omit the rest ${items.length - 1} items`;
|
|
21983
|
+
}
|
|
21984
|
+
}
|
|
21985
|
+
//#endregion
|
|
21986
|
+
//#region src/json-schema-subset/compiler/common.ts
|
|
21987
|
+
var jsonSchemaKeys = /* @__PURE__ */ new Set([
|
|
21988
|
+
"type",
|
|
21989
|
+
"enum",
|
|
21990
|
+
"const",
|
|
21991
|
+
"multipleOf",
|
|
21992
|
+
"maximum",
|
|
21993
|
+
"exclusiveMaximum",
|
|
21994
|
+
"minimum",
|
|
21995
|
+
"exclusiveMinimum",
|
|
21996
|
+
"maxLength",
|
|
21997
|
+
"minLength",
|
|
21998
|
+
"pattern",
|
|
21999
|
+
"items",
|
|
22000
|
+
"additionalItems",
|
|
22001
|
+
"maxItems",
|
|
22002
|
+
"minItems",
|
|
22003
|
+
"uniqueItems",
|
|
22004
|
+
"contains",
|
|
22005
|
+
"maxProperties",
|
|
22006
|
+
"minProperties",
|
|
22007
|
+
"required",
|
|
22008
|
+
"properties",
|
|
22009
|
+
"patternProperties",
|
|
22010
|
+
"additionalProperties",
|
|
22011
|
+
"dependencies",
|
|
22012
|
+
"propertyNames",
|
|
22013
|
+
"if",
|
|
22014
|
+
"then",
|
|
22015
|
+
"else",
|
|
22016
|
+
"allOf",
|
|
22017
|
+
"anyOf",
|
|
22018
|
+
"oneOf",
|
|
22019
|
+
"not",
|
|
22020
|
+
"format",
|
|
22021
|
+
"contentMediaType",
|
|
22022
|
+
"contentEncoding",
|
|
22023
|
+
"definitions"
|
|
22024
|
+
]);
|
|
22025
|
+
function isJSONSchemaKey(key) {
|
|
22026
|
+
return jsonSchemaKeys.has(key);
|
|
22027
|
+
}
|
|
22028
|
+
function isLogicEmptyObject(object) {
|
|
22029
|
+
for (const key in object) if (isJSONSchemaKey(key)) return false;
|
|
22030
|
+
return true;
|
|
22031
|
+
}
|
|
22032
|
+
function joinPath(context, ...extraPath) {
|
|
22033
|
+
return {
|
|
22034
|
+
...context,
|
|
22035
|
+
path: [...context.path, ...extraPath]
|
|
22036
|
+
};
|
|
22037
|
+
}
|
|
22038
|
+
function unwrapJSONSchema7Definition(schema) {
|
|
22039
|
+
if (typeof schema === "boolean") throw new Error("JSONSchema7Definition cannot be boolean");
|
|
22040
|
+
return schema;
|
|
22041
|
+
}
|
|
22042
|
+
function recordError({ path, errors }, message, ...extraPath) {
|
|
22043
|
+
errors.push(createSchemaError(path, extraPath, message));
|
|
22044
|
+
}
|
|
22045
|
+
function recordWarn({ path, warns }, message, ...extraPath) {
|
|
22046
|
+
warns.push(createSchemaError(path, extraPath, message));
|
|
22047
|
+
}
|
|
22048
|
+
function createSchemaError(path, extraPath, message) {
|
|
22049
|
+
return {
|
|
22050
|
+
kind: SchemaErrorItemKind.Compiled,
|
|
22051
|
+
message,
|
|
22052
|
+
path: [...path, ...extraPath]
|
|
22053
|
+
};
|
|
22054
|
+
}
|
|
22055
|
+
//#endregion
|
|
22056
|
+
//#region src/json-schema-subset/compiler/utils.ts
|
|
22057
|
+
function cleanEmptyValues(origin) {
|
|
22058
|
+
for (const key in origin) {
|
|
22059
|
+
const value = origin[key];
|
|
22060
|
+
if (value === void 0) delete origin[key];
|
|
22061
|
+
else if (value && typeof value === "object") {
|
|
22062
|
+
if (Array.isArray(value)) {
|
|
22063
|
+
if (value.length === 0) delete origin[key];
|
|
22064
|
+
} else if (isEmptyObject(value)) delete origin[key];
|
|
22065
|
+
}
|
|
22066
|
+
}
|
|
22067
|
+
return origin;
|
|
22068
|
+
}
|
|
22069
|
+
function isEmptyObject(object) {
|
|
22070
|
+
for (const _ in object) return false;
|
|
22071
|
+
return true;
|
|
22072
|
+
}
|
|
22073
|
+
//#endregion
|
|
22074
|
+
//#region src/json-schema-subset/compiler/wrapper.ts
|
|
22075
|
+
var symbolID = Symbol("compiledId");
|
|
22076
|
+
var symbolKind = Symbol("compiledKind");
|
|
22077
|
+
var symbolPath = Symbol("compiledPath");
|
|
22078
|
+
var symbolValidatorLoader = Symbol("validatorLoader");
|
|
22079
|
+
var CompiledKind = Object.freeze({
|
|
22080
|
+
Extends: 0,
|
|
22081
|
+
Never: 1,
|
|
22082
|
+
Any: 2,
|
|
22083
|
+
Null: 3,
|
|
22084
|
+
String: 4,
|
|
22085
|
+
Numeric: 5,
|
|
22086
|
+
Boolean: 6,
|
|
22087
|
+
Object: 7,
|
|
22088
|
+
Array: 8,
|
|
22089
|
+
Not: 9,
|
|
22090
|
+
Combination: 10,
|
|
22091
|
+
EnumOrConst: 11
|
|
22092
|
+
});
|
|
22093
|
+
var ANY = deepFreeze(toCompiledSchema(CompiledKind.Any, createId(), {}, () => () => true));
|
|
22094
|
+
var NEVER = deepFreeze(toCompiledSchema(CompiledKind.Never, createId(), {
|
|
22095
|
+
type: "string",
|
|
22096
|
+
maxLength: 0,
|
|
22097
|
+
minLength: 1
|
|
22098
|
+
}, () => () => false));
|
|
22099
|
+
function isCompiledObject(value) {
|
|
22100
|
+
if (value === null || typeof value !== "object") return false;
|
|
22101
|
+
return symbolID in value;
|
|
22102
|
+
}
|
|
22103
|
+
function isCompiledSchema(object) {
|
|
22104
|
+
if (object === null || typeof object !== "object") return false;
|
|
22105
|
+
return symbolID in object && symbolKind in object;
|
|
22106
|
+
}
|
|
22107
|
+
function getKind(schema) {
|
|
22108
|
+
if (isCompiledSchema(schema)) return schema[symbolKind];
|
|
22109
|
+
else return CompiledKind.Extends;
|
|
22110
|
+
}
|
|
22111
|
+
function getId(schema) {
|
|
22112
|
+
if (isCompiledSchema(schema) || isCompiledObject(schema)) return schema[symbolID];
|
|
22113
|
+
else return schema.id;
|
|
22114
|
+
}
|
|
22115
|
+
function getPath(schema) {
|
|
22116
|
+
return isCompiledSchema(schema) ? schema[symbolPath] : void 0;
|
|
22117
|
+
}
|
|
22118
|
+
function wrapCompiledValue(value) {
|
|
22119
|
+
if (value === null || typeof value !== "object") return value;
|
|
22120
|
+
Object.defineProperty(value, symbolID, {
|
|
22121
|
+
value: createId(),
|
|
22122
|
+
configurable: false,
|
|
22123
|
+
writable: false,
|
|
22124
|
+
enumerable: false
|
|
22125
|
+
});
|
|
22126
|
+
return value;
|
|
22127
|
+
}
|
|
22128
|
+
function wrapCompiledSchema(kind, schema, delegate, path = []) {
|
|
22129
|
+
return toCompiledSchema(kind, createId(), schema, delegate && (() => {
|
|
22130
|
+
return delegate.compile(schema);
|
|
22131
|
+
}), path);
|
|
22132
|
+
}
|
|
22133
|
+
function toNever(schema) {
|
|
22134
|
+
return toCompiledSchema(CompiledKind.Never, createId(), { ...schema }, schema[symbolValidatorLoader], schema[symbolPath]);
|
|
22135
|
+
}
|
|
22136
|
+
function toCompiledSchema(kind, id, schema, validatorLoader, path = []) {
|
|
22137
|
+
let validator = null;
|
|
22138
|
+
Object.defineProperties(schema, {
|
|
22139
|
+
[symbolKind]: {
|
|
22140
|
+
value: kind,
|
|
22141
|
+
configurable: false,
|
|
22142
|
+
writable: false,
|
|
22143
|
+
enumerable: false
|
|
22144
|
+
},
|
|
22145
|
+
[symbolID]: {
|
|
22146
|
+
value: id,
|
|
22147
|
+
configurable: false,
|
|
22148
|
+
writable: false,
|
|
22149
|
+
enumerable: false
|
|
22150
|
+
},
|
|
22151
|
+
[symbolPath]: {
|
|
22152
|
+
value: path,
|
|
22153
|
+
configurable: false,
|
|
22154
|
+
writable: false,
|
|
22155
|
+
enumerable: false
|
|
22156
|
+
},
|
|
22157
|
+
[symbolValidatorLoader]: {
|
|
22158
|
+
value: validatorLoader,
|
|
22159
|
+
configurable: false,
|
|
22160
|
+
writable: false,
|
|
22161
|
+
enumerable: false
|
|
22162
|
+
},
|
|
22163
|
+
isValid: {
|
|
22164
|
+
configurable: false,
|
|
22165
|
+
enumerable: false,
|
|
22166
|
+
get: () => {
|
|
22167
|
+
if (validatorLoader) {
|
|
22168
|
+
if (!validator) validator = validatorLoader();
|
|
22169
|
+
return validator;
|
|
22170
|
+
} else return;
|
|
22171
|
+
}
|
|
22172
|
+
}
|
|
22173
|
+
});
|
|
22174
|
+
return schema;
|
|
22175
|
+
}
|
|
22176
|
+
//#endregion
|
|
22177
|
+
//#region src/json-schema-subset/compiler/array.ts
|
|
22178
|
+
function compileArraySchema(context, schema) {
|
|
22179
|
+
let items = compileItems(context, schema);
|
|
22180
|
+
let maxItems = getItemsLimit(context, "maxItems", schema);
|
|
22181
|
+
const minItems = getItemsLimit(context, "minItems", schema);
|
|
22182
|
+
const contains = compileContains(context, schema);
|
|
22183
|
+
const uniqueItems = schema.uniqueItems;
|
|
22184
|
+
let additionalItems;
|
|
22185
|
+
if (Array.isArray(items)) additionalItems = compileAdditionalItems(context, schema);
|
|
22186
|
+
else if (schema.additionalItems) recordWarn(context, "it is needless when items is not array", "additionalItems");
|
|
22187
|
+
if (!items || !contains || additionalItems === null) return null;
|
|
22188
|
+
let isNever = false;
|
|
22189
|
+
let updateMaxItems = false;
|
|
22190
|
+
if (Array.isArray(items)) {
|
|
22191
|
+
if (maxItems !== void 0 && maxItems <= items.length) {
|
|
22192
|
+
items = items.splice(maxItems);
|
|
22193
|
+
additionalItems = variableToNever(additionalItems, context.delegate);
|
|
22194
|
+
}
|
|
22195
|
+
const firstNeverItemIndex = items.findIndex((item) => getKind(item) === CompiledKind.Never);
|
|
22196
|
+
if (firstNeverItemIndex !== -1) {
|
|
22197
|
+
items = items.splice(firstNeverItemIndex);
|
|
22198
|
+
additionalItems = variableToNever(additionalItems, context.delegate);
|
|
22199
|
+
if (maxItems === void 0) {
|
|
22200
|
+
maxItems = items.length;
|
|
22201
|
+
updateMaxItems = true;
|
|
22202
|
+
}
|
|
22203
|
+
}
|
|
22204
|
+
if (minItems !== void 0 && items.length < minItems) {
|
|
22205
|
+
recordWarn(context, `length(${items.length}) of items if less than minItems(${minItems})`);
|
|
22206
|
+
isNever = true;
|
|
22207
|
+
}
|
|
22208
|
+
if (items.length === 0 && additionalItems && getKind(additionalItems) === CompiledKind.Never) isNever = true;
|
|
22209
|
+
} else if (getKind(items) === CompiledKind.Never) isNever = true;
|
|
22210
|
+
if (maxItems !== void 0 && minItems !== void 0 && maxItems < minItems) {
|
|
22211
|
+
if (!updateMaxItems) recordWarn(context, `maxItems(${maxItems}) is less than minItems(${minItems})`);
|
|
22212
|
+
isNever = true;
|
|
22213
|
+
}
|
|
22214
|
+
return wrapCompiledSchema(isNever ? CompiledKind.Never : CompiledKind.Array, cleanEmptyValues({
|
|
22215
|
+
type: "array",
|
|
22216
|
+
items,
|
|
22217
|
+
contains,
|
|
22218
|
+
uniqueItems,
|
|
22219
|
+
maxItems,
|
|
22220
|
+
minItems,
|
|
22221
|
+
additionalItems
|
|
22222
|
+
}), context.delegate, context.path);
|
|
22223
|
+
}
|
|
22224
|
+
function compileItems(context, { items }) {
|
|
22225
|
+
if (!items) return wrapCompiledSchema(CompiledKind.Any, {}, context.delegate, context.path);
|
|
22226
|
+
if (Array.isArray(items)) {
|
|
22227
|
+
const schemas = [];
|
|
22228
|
+
let hasAnyError = false;
|
|
22229
|
+
for (const [i, item] of items.entries()) {
|
|
22230
|
+
const schema = compileSchema(joinPath(context, "items", i), unwrapJSONSchema7Definition(item));
|
|
22231
|
+
if (!schema) {
|
|
22232
|
+
hasAnyError = true;
|
|
22233
|
+
continue;
|
|
22234
|
+
}
|
|
22235
|
+
schemas.push(schema);
|
|
22236
|
+
}
|
|
22237
|
+
if (hasAnyError) return null;
|
|
22238
|
+
return schemas;
|
|
22239
|
+
} else return compileSchema(joinPath(context, "items"), unwrapJSONSchema7Definition(items));
|
|
22240
|
+
}
|
|
22241
|
+
function getItemsLimit(context, name, schema) {
|
|
22242
|
+
const propertiesLimit = schema[name];
|
|
22243
|
+
if (propertiesLimit === void 0) return;
|
|
22244
|
+
if (Number.isNaN(propertiesLimit)) {
|
|
22245
|
+
recordWarn(context, "find NaN", name);
|
|
22246
|
+
return;
|
|
22247
|
+
}
|
|
22248
|
+
if (propertiesLimit < 0) {
|
|
22249
|
+
recordWarn(context, `find invalid number ${propertiesLimit}`, name);
|
|
22250
|
+
return;
|
|
22251
|
+
}
|
|
22252
|
+
return propertiesLimit;
|
|
22253
|
+
}
|
|
22254
|
+
function compileContains(context, { contains }) {
|
|
22255
|
+
if (!contains) return wrapCompiledSchema(CompiledKind.Any, {}, context.delegate, context.path);
|
|
22256
|
+
return compileSchema(joinPath(context, "contains"), unwrapJSONSchema7Definition(contains));
|
|
22257
|
+
}
|
|
22258
|
+
function compileAdditionalItems(context, { additionalItems }) {
|
|
22259
|
+
switch (typeof additionalItems) {
|
|
22260
|
+
case "boolean": if (additionalItems) return wrapCompiledSchema(CompiledKind.Any, {}, context.delegate, context.path);
|
|
22261
|
+
else return false;
|
|
22262
|
+
case "object": return compileSchema(joinPath(context, "additionalItems"), additionalItems);
|
|
22263
|
+
default: return wrapCompiledSchema(CompiledKind.Any, {}, context.delegate, context.path);
|
|
22264
|
+
}
|
|
22265
|
+
}
|
|
22266
|
+
function variableToNever(schema, delegate) {
|
|
22267
|
+
if (schema === void 0) return wrapCompiledSchema(CompiledKind.Never, {
|
|
22268
|
+
type: "string",
|
|
22269
|
+
maxLength: 0,
|
|
22270
|
+
minLength: 1
|
|
22271
|
+
}, delegate);
|
|
22272
|
+
else if (isCompiledSchema(schema)) return getKind(schema) === CompiledKind.Never ? schema : toNever(schema);
|
|
22273
|
+
else return schema;
|
|
22274
|
+
}
|
|
22275
|
+
//#endregion
|
|
22276
|
+
//#region src/json-schema-subset/compiler/combination.ts
|
|
22277
|
+
var COMBINATION_KEYS = Object.freeze([
|
|
22278
|
+
"allOf",
|
|
22279
|
+
"anyOf",
|
|
22280
|
+
"oneOf"
|
|
22281
|
+
]);
|
|
22282
|
+
function compileCombinationSchema(context, key, combinationList, delegate) {
|
|
22283
|
+
if (combinationList.length === 0) {
|
|
22284
|
+
recordError(context, "disable empty list", key);
|
|
22285
|
+
return null;
|
|
22286
|
+
}
|
|
22287
|
+
const compiledCombinationList = [];
|
|
22288
|
+
for (const [i, element] of combinationList.entries()) {
|
|
22289
|
+
const compiledSchema = compileSchema(joinPath(context, key, i), unwrapJSONSchema7Definition(element));
|
|
22290
|
+
if (compiledSchema) compiledCombinationList.push(compiledSchema);
|
|
22291
|
+
}
|
|
22292
|
+
if (compiledCombinationList.length < combinationList.length) return null;
|
|
22293
|
+
let anyCount = 0;
|
|
22294
|
+
let neverCount = 0;
|
|
22295
|
+
for (const compiledSchema of compiledCombinationList) switch (getKind(compiledSchema)) {
|
|
22296
|
+
case CompiledKind.Any:
|
|
22297
|
+
anyCount += 1;
|
|
22298
|
+
break;
|
|
22299
|
+
case CompiledKind.Never: neverCount += 1;
|
|
22300
|
+
}
|
|
22301
|
+
let kind = CompiledKind.Combination;
|
|
22302
|
+
switch (key) {
|
|
22303
|
+
case "allOf":
|
|
22304
|
+
if (neverCount > 0) kind = CompiledKind.Never;
|
|
22305
|
+
else if (anyCount === compiledCombinationList.length) kind = CompiledKind.Any;
|
|
22306
|
+
else if (!areAllTypesTheSame(compiledCombinationList)) kind = CompiledKind.Never;
|
|
22307
|
+
break;
|
|
22308
|
+
case "anyOf":
|
|
22309
|
+
if (anyCount > 0) kind = CompiledKind.Any;
|
|
22310
|
+
else if (neverCount === compiledCombinationList.length) kind = CompiledKind.Never;
|
|
22311
|
+
break;
|
|
22312
|
+
case "oneOf": if (anyCount > 1) kind = CompiledKind.Never;
|
|
22313
|
+
else if (neverCount === compiledCombinationList.length) kind = CompiledKind.Never;
|
|
22314
|
+
else if (anyCount === 1 && neverCount === compiledCombinationList.length - 1) kind = CompiledKind.Any;
|
|
22315
|
+
}
|
|
22316
|
+
return wrapCompiledSchema(kind, { [key]: compiledCombinationList }, delegate, context.path);
|
|
22317
|
+
}
|
|
22318
|
+
function areAllTypesTheSame(combinationList) {
|
|
22319
|
+
let lastKind = null;
|
|
22320
|
+
for (const schema of combinationList) {
|
|
22321
|
+
const kind = getKind(schema);
|
|
22322
|
+
switch (kind) {
|
|
22323
|
+
case CompiledKind.Any:
|
|
22324
|
+
case CompiledKind.Never: break;
|
|
22325
|
+
default: if (lastKind === null) lastKind = kind;
|
|
22326
|
+
else if (lastKind !== kind) return false;
|
|
22327
|
+
}
|
|
22328
|
+
}
|
|
22329
|
+
return true;
|
|
22330
|
+
}
|
|
22331
|
+
//#endregion
|
|
22332
|
+
//#region src/json-schema-subset/checker/validator.ts
|
|
22333
|
+
var ValidResult = Object.freeze({
|
|
22334
|
+
Valid: 0,
|
|
22335
|
+
Invalid: 1,
|
|
22336
|
+
Unknown: 2
|
|
22337
|
+
});
|
|
22338
|
+
function valid(compiledSchema, value) {
|
|
22339
|
+
const isValid = compiledSchema.isValid;
|
|
22340
|
+
if (isValid) {
|
|
22341
|
+
if (isValid(value) === true) return ValidResult.Valid;
|
|
22342
|
+
else return ValidResult.Invalid;
|
|
22343
|
+
} else return ValidResult.Unknown;
|
|
22344
|
+
}
|
|
22345
|
+
//#endregion
|
|
22346
|
+
//#region src/json-schema-subset/compiler/enumAndConst.ts
|
|
22347
|
+
function compileEnumAndConst(context, enumList, constValue, schema) {
|
|
22348
|
+
let compiledEnum;
|
|
22349
|
+
let isNever = false;
|
|
22350
|
+
if (enumList) {
|
|
22351
|
+
if (enumList.length === 0) {
|
|
22352
|
+
recordError(context, "disable empty list", "enum");
|
|
22353
|
+
return null;
|
|
22354
|
+
}
|
|
22355
|
+
compiledEnum = [];
|
|
22356
|
+
for (const [i, enumValue] of enumList.entries()) switch (valid(schema, enumValue)) {
|
|
22357
|
+
case ValidResult.Valid:
|
|
22358
|
+
compiledEnum.push(wrapCompiledValue(enumValue));
|
|
22359
|
+
break;
|
|
22360
|
+
case ValidResult.Invalid: recordWarn(context, "cannot pass JSON schema of currently schema object", "enum", i);
|
|
22361
|
+
}
|
|
22362
|
+
if (compiledEnum.length === 0) recordWarn(context, "all of elements from list is rejected by currently schema object", "enum");
|
|
22363
|
+
}
|
|
22364
|
+
if (constValue && valid(schema, constValue) === ValidResult.Invalid) isNever = true;
|
|
22365
|
+
if (compiledEnum) {
|
|
22366
|
+
if (compiledEnum.length === 0) isNever = true;
|
|
22367
|
+
else if (constValue) {
|
|
22368
|
+
let foundEquals = false;
|
|
22369
|
+
for (const enumValue of compiledEnum) if (isDeepEquals(enumValue, constValue)) {
|
|
22370
|
+
foundEquals = true;
|
|
22371
|
+
break;
|
|
22372
|
+
}
|
|
22373
|
+
if (!foundEquals) isNever = true;
|
|
22374
|
+
}
|
|
22375
|
+
}
|
|
22376
|
+
const kind = isNever ? CompiledKind.Never : CompiledKind.EnumOrConst;
|
|
22377
|
+
const compiledSchema = {};
|
|
22378
|
+
if (schema.type) compiledSchema.type = schema.type;
|
|
22379
|
+
if (compiledEnum) compiledSchema.enum = compiledEnum;
|
|
22380
|
+
if (constValue) compiledSchema.const = wrapCompiledValue(deepCopy(constValue));
|
|
22381
|
+
return wrapCompiledSchema(kind, compiledSchema, context.delegate, context.path);
|
|
22382
|
+
}
|
|
22383
|
+
//#endregion
|
|
22384
|
+
//#region src/json-schema-subset/compiler/object.ts
|
|
22385
|
+
var OBJECT_KEYS = /* @__PURE__ */ new Set([
|
|
22386
|
+
"type",
|
|
22387
|
+
"maxProperties",
|
|
22388
|
+
"minProperties",
|
|
22389
|
+
"required",
|
|
22390
|
+
"properties",
|
|
22391
|
+
"patternProperties",
|
|
22392
|
+
"additionalProperties",
|
|
22393
|
+
"dependencies",
|
|
22394
|
+
"propertyNames"
|
|
22395
|
+
]);
|
|
22396
|
+
function compileObjectSchema(context, schema) {
|
|
22397
|
+
const rejectKeys = Object.keys(schema).filter((k) => !OBJECT_KEYS.has(k) && isJSONSchemaKey(k));
|
|
22398
|
+
if (rejectKeys.length > 0) recordWarn(context, `type="object" will exclude other keys: ${rejectKeys.toSorted().join(", ")}`);
|
|
22399
|
+
const maxProperties = getPropertiesLimit(context, "maxProperties", schema);
|
|
22400
|
+
const minProperties = getPropertiesLimit(context, "minProperties", schema);
|
|
22401
|
+
const additionalPropertiesSchema = compileAdditionalProperties(context, schema);
|
|
22402
|
+
const patternProperties = compilePatternProperties(context, schema);
|
|
22403
|
+
const propertyNames = compilePropertyNames(context, schema);
|
|
22404
|
+
const dependentTuple = compileDependencies(context, schema);
|
|
22405
|
+
if (!additionalPropertiesSchema || !patternProperties || !propertyNames || !dependentTuple) return null;
|
|
22406
|
+
const properties = compileProperties(context, patternProperties, propertyNames, schema);
|
|
22407
|
+
if (!properties) return null;
|
|
22408
|
+
const required = compileRequired(context, createBanKeyChecker(additionalPropertiesSchema, patternProperties, propertyNames, properties), dependentTuple, schema);
|
|
22409
|
+
return wrapCompiledSchema(checkSchemaIsNever(context, additionalPropertiesSchema, properties, required, maxProperties, minProperties) ? CompiledKind.Never : CompiledKind.Object, cleanEmptyValues({
|
|
22410
|
+
type: "object",
|
|
22411
|
+
required,
|
|
22412
|
+
properties,
|
|
22413
|
+
minProperties,
|
|
22414
|
+
maxProperties,
|
|
22415
|
+
additionalProperties: additionalPropertiesSchema,
|
|
22416
|
+
patternProperties: unwrapPatternProperties(patternProperties),
|
|
22417
|
+
dependencies: mergeDependentTuple(dependentTuple, schema),
|
|
22418
|
+
propertyNames
|
|
22419
|
+
}), context.delegate, context.path);
|
|
22420
|
+
}
|
|
22421
|
+
function getPropertiesLimit(context, name, schema) {
|
|
22422
|
+
const propertiesLimit = schema[name];
|
|
22423
|
+
if (propertiesLimit === void 0) return;
|
|
22424
|
+
if (Number.isNaN(propertiesLimit)) {
|
|
22425
|
+
recordWarn(context, "find NaN", name);
|
|
22426
|
+
return;
|
|
22427
|
+
}
|
|
22428
|
+
if (propertiesLimit < 0) {
|
|
22429
|
+
recordWarn(context, `find invalid number ${propertiesLimit}`, name);
|
|
22430
|
+
return;
|
|
22431
|
+
}
|
|
22432
|
+
return propertiesLimit;
|
|
22433
|
+
}
|
|
22434
|
+
function compileAdditionalProperties(context, { additionalProperties }) {
|
|
22435
|
+
if (additionalProperties === false) return wrapCompiledSchema(CompiledKind.Never, {
|
|
22436
|
+
type: "string",
|
|
22437
|
+
maxLength: 0,
|
|
22438
|
+
minLength: 1
|
|
22439
|
+
}, context.delegate, context.path);
|
|
22440
|
+
if (typeof additionalProperties !== "object") return wrapCompiledSchema(CompiledKind.Any, {}, context.delegate, context.path);
|
|
22441
|
+
return compileSchema(joinPath(context, "additionalProperties"), unwrapJSONSchema7Definition(additionalProperties));
|
|
22442
|
+
}
|
|
22443
|
+
function compilePatternProperties(context, { patternProperties }) {
|
|
22444
|
+
let foundSubError = false;
|
|
22445
|
+
const target = {};
|
|
22446
|
+
for (const key in patternProperties) {
|
|
22447
|
+
const regExp = wrapRegExp(key);
|
|
22448
|
+
if (regExp instanceof Error) {
|
|
22449
|
+
recordWarn(context, `property name invalid. ${key}`, "patternProperties", key);
|
|
22450
|
+
continue;
|
|
22451
|
+
}
|
|
22452
|
+
const schema = unwrapJSONSchema7Definition(patternProperties[key]);
|
|
22453
|
+
const compiledSchema = compileSchema(joinPath(context, "patternProperties", key), schema);
|
|
22454
|
+
if (!compiledSchema) {
|
|
22455
|
+
foundSubError = true;
|
|
22456
|
+
continue;
|
|
22457
|
+
}
|
|
22458
|
+
target[key] = [compiledSchema, regExp];
|
|
22459
|
+
}
|
|
22460
|
+
if (foundSubError) return null;
|
|
22461
|
+
return target;
|
|
22462
|
+
}
|
|
22463
|
+
function compilePropertyNames(context, { propertyNames }) {
|
|
22464
|
+
if (!propertyNames) return wrapCompiledSchema(CompiledKind.Any, {}, context.delegate, context.path);
|
|
22465
|
+
propertyNames = unwrapJSONSchema7Definition(propertyNames);
|
|
22466
|
+
const schema = compileSchema(joinPath(context, "propertyNames"), propertyNames);
|
|
22467
|
+
if (!schema) return null;
|
|
22468
|
+
const kind = getKind(schema);
|
|
22469
|
+
if (kind !== CompiledKind.String && kind !== CompiledKind.Any) return toNever(schema);
|
|
22470
|
+
return schema;
|
|
22471
|
+
}
|
|
22472
|
+
function compileProperties(context, patternProperties, propertyNamesSchema, { properties }) {
|
|
22473
|
+
let foundSubError = false;
|
|
22474
|
+
if (!properties) return {};
|
|
22475
|
+
const target = {};
|
|
22476
|
+
for (const key in properties) {
|
|
22477
|
+
if (valid(propertyNamesSchema, key) === ValidResult.Invalid) {
|
|
22478
|
+
recordWarn(context, `key ${JSON.stringify(key)} cannot pass JSON schema from propertyNames`, "properties");
|
|
22479
|
+
continue;
|
|
22480
|
+
}
|
|
22481
|
+
const patternSchema = findPatternSchema(patternProperties, key);
|
|
22482
|
+
if (patternSchema && getKind(patternSchema) === CompiledKind.Never) {
|
|
22483
|
+
recordWarn(context, `key ${JSON.stringify(key)} matches a pattern that has a impossible(never) schema`, "properties");
|
|
22484
|
+
continue;
|
|
22485
|
+
}
|
|
22486
|
+
const schema = unwrapJSONSchema7Definition(properties[key]);
|
|
22487
|
+
const compiledSchema = compileSchema(joinPath(context, "properties", key), schema);
|
|
22488
|
+
if (!compiledSchema) {
|
|
22489
|
+
foundSubError = true;
|
|
22490
|
+
continue;
|
|
22491
|
+
}
|
|
22492
|
+
target[key] = compiledSchema;
|
|
22493
|
+
}
|
|
22494
|
+
if (foundSubError) return null;
|
|
22495
|
+
return target;
|
|
22496
|
+
}
|
|
22497
|
+
function compileDependencies(context, { dependencies }) {
|
|
22498
|
+
if (!dependencies) return [{}, {}];
|
|
22499
|
+
const dependentRequired = {};
|
|
22500
|
+
const dependentSchemas = {};
|
|
22501
|
+
for (const key in dependencies) {
|
|
22502
|
+
const dependency = unwrapJSONSchema7Definition(dependencies[key]);
|
|
22503
|
+
if (Array.isArray(dependency)) {
|
|
22504
|
+
const { keys, duplicated } = checkUniqueKeys(dependency);
|
|
22505
|
+
if (duplicated) recordWarn(context, `found duplicated property names: ${duplicated.join(", ")}`, "dependencies", key);
|
|
22506
|
+
dependentRequired[key] = keys;
|
|
22507
|
+
} else {
|
|
22508
|
+
const compiledSchema = compileSchema(joinPath(context, "dependencies", key), dependency);
|
|
22509
|
+
if (compiledSchema) {
|
|
22510
|
+
const kind = getKind(compiledSchema);
|
|
22511
|
+
if (kind === CompiledKind.Object || kind === CompiledKind.Any) dependentSchemas[key] = compiledSchema;
|
|
22512
|
+
else if (kind === CompiledKind.Extends) dependentSchemas[key] = NEVER;
|
|
22513
|
+
else dependentSchemas[key] = toNever(compiledSchema);
|
|
22514
|
+
}
|
|
22515
|
+
}
|
|
22516
|
+
}
|
|
22517
|
+
return [dependentRequired, dependentSchemas];
|
|
22518
|
+
}
|
|
22519
|
+
function createBanKeyChecker(additionalPropertiesSchema, patternProperties, propertyNamesSchema, properties) {
|
|
22520
|
+
return (key) => {
|
|
22521
|
+
if (valid(propertyNamesSchema, key) === ValidResult.Invalid) return true;
|
|
22522
|
+
const patternSchema = findPatternSchema(patternProperties, key);
|
|
22523
|
+
if (patternSchema && getKind(patternSchema) === CompiledKind.Never) return true;
|
|
22524
|
+
if (getKind(properties[key] ?? additionalPropertiesSchema) === CompiledKind.Never) return true;
|
|
22525
|
+
return false;
|
|
22526
|
+
};
|
|
22527
|
+
}
|
|
22528
|
+
function compileRequired(context, isBan, dependentTuple, { required }) {
|
|
22529
|
+
if (!required) return [];
|
|
22530
|
+
const uniqueCheckedResult = checkUniqueKeys(required);
|
|
22531
|
+
if (uniqueCheckedResult.duplicated) recordWarn(context, `found duplicated required keys: ${uniqueCheckedResult.duplicated.join(", ")}`, "required");
|
|
22532
|
+
const requiredKeys = [];
|
|
22533
|
+
const banKeys = [];
|
|
22534
|
+
for (const requiredKey of uniqueCheckedResult.keys) if (collectDependencies(dependentTuple, requiredKey).some((key) => isBan(key))) banKeys.push(requiredKey);
|
|
22535
|
+
else requiredKeys.push(requiredKey);
|
|
22536
|
+
if (banKeys.length > 0) recordWarn(context, `key ${banKeys.map((k) => JSON.stringify(k)).join(", ")} will ban by another condition`, "required");
|
|
22537
|
+
return requiredKeys;
|
|
22538
|
+
}
|
|
22539
|
+
function checkSchemaIsNever(context, additionalPropertiesSchema, properties, required, maxProperties, minProperties) {
|
|
22540
|
+
if (maxProperties !== void 0 && minProperties !== void 0 && maxProperties < minProperties) {
|
|
22541
|
+
recordWarn(context, `maxProperties(${maxProperties}) is less than minProperties(${minProperties})`);
|
|
22542
|
+
return true;
|
|
22543
|
+
}
|
|
22544
|
+
if (maxProperties !== void 0 && required.length > maxProperties) {
|
|
22545
|
+
recordWarn(context, `length(${required.length}) of required is greater than maxProperties(${maxProperties})`);
|
|
22546
|
+
return true;
|
|
22547
|
+
}
|
|
22548
|
+
if (minProperties !== void 0 && required.length < minProperties) {
|
|
22549
|
+
recordWarn(context, `length(${required.length}) of required is less than minProperties(${minProperties})`);
|
|
22550
|
+
return true;
|
|
22551
|
+
}
|
|
22552
|
+
if (getKind(additionalPropertiesSchema) !== CompiledKind.Never) return false;
|
|
22553
|
+
for (const key in properties) {
|
|
22554
|
+
const compiledSchema = properties[key];
|
|
22555
|
+
if (getKind(compiledSchema) !== CompiledKind.Never) return false;
|
|
22556
|
+
}
|
|
22557
|
+
return true;
|
|
22558
|
+
}
|
|
22559
|
+
function collectDependencies([dependentRequired, dependentSchemas], seedKey) {
|
|
22560
|
+
const queue = [seedKey];
|
|
22561
|
+
const collection = new Set(queue);
|
|
22562
|
+
while (queue.length > 0) {
|
|
22563
|
+
const key = queue.pop();
|
|
22564
|
+
const schema = dependentSchemas[key];
|
|
22565
|
+
const requiredKeys = dependentRequired[key];
|
|
22566
|
+
if (schema) {
|
|
22567
|
+
if (getKind(schema) === CompiledKind.Object) collectKeys(schema.required);
|
|
22568
|
+
}
|
|
22569
|
+
if (requiredKeys) collectKeys(requiredKeys);
|
|
22570
|
+
}
|
|
22571
|
+
function collectKeys(keys) {
|
|
22572
|
+
if (keys) {
|
|
22573
|
+
for (const key of keys) if (!collection.has(key)) {
|
|
22574
|
+
collection.add(key);
|
|
22575
|
+
queue.push(key);
|
|
22576
|
+
}
|
|
22577
|
+
}
|
|
22578
|
+
}
|
|
22579
|
+
return [...collection];
|
|
22580
|
+
}
|
|
22581
|
+
function checkUniqueKeys(keys) {
|
|
22582
|
+
const checking = /* @__PURE__ */ new Set();
|
|
22583
|
+
const duplicated = /* @__PURE__ */ new Set();
|
|
22584
|
+
for (const e of keys) if (checking.has(e)) duplicated.add(e);
|
|
22585
|
+
else checking.add(e);
|
|
22586
|
+
if (duplicated.size === 0) return {
|
|
22587
|
+
keys: [...keys],
|
|
22588
|
+
duplicated: null
|
|
22589
|
+
};
|
|
22590
|
+
else return {
|
|
22591
|
+
keys: [...checking],
|
|
22592
|
+
duplicated: [...duplicated]
|
|
22593
|
+
};
|
|
22594
|
+
}
|
|
22595
|
+
function findPatternSchema(patternProperties, checkedKey) {
|
|
22596
|
+
for (const key in patternProperties) {
|
|
22597
|
+
const [schema, regExp] = patternProperties[key];
|
|
22598
|
+
if (regExp.test(checkedKey)) return schema;
|
|
22599
|
+
}
|
|
22600
|
+
return null;
|
|
22601
|
+
}
|
|
22602
|
+
function wrapRegExp(pattern) {
|
|
22603
|
+
try {
|
|
22604
|
+
return new RegExp(pattern, "i");
|
|
22605
|
+
} catch (error) {
|
|
22606
|
+
if (error instanceof SyntaxError) return error;
|
|
22607
|
+
else throw error;
|
|
22608
|
+
}
|
|
22609
|
+
}
|
|
22610
|
+
function unwrapPatternProperties(patternProperties) {
|
|
22611
|
+
const target = {};
|
|
22612
|
+
for (const key in patternProperties) target[key] = patternProperties[key][0];
|
|
22613
|
+
return target;
|
|
22614
|
+
}
|
|
22615
|
+
function mergeDependentTuple([dependentRequired, dependentSchemas], { dependencies }) {
|
|
22616
|
+
const target = {};
|
|
22617
|
+
for (const key in dependencies) {
|
|
22618
|
+
const required = dependentRequired[key];
|
|
22619
|
+
const schema = dependentSchemas[key];
|
|
22620
|
+
target[key] = required || schema;
|
|
22621
|
+
}
|
|
22622
|
+
return target;
|
|
22623
|
+
}
|
|
22624
|
+
//#endregion
|
|
22625
|
+
//#region src/json-schema-subset/compiler/primitive.ts
|
|
22626
|
+
var NUMERIC_KEYS = /* @__PURE__ */ new Set([
|
|
22627
|
+
"type",
|
|
22628
|
+
"multipleOf",
|
|
22629
|
+
"maximum",
|
|
22630
|
+
"exclusiveMaximum",
|
|
22631
|
+
"minimum",
|
|
22632
|
+
"exclusiveMinimum"
|
|
22633
|
+
]);
|
|
22634
|
+
var STRING_KEYS = /* @__PURE__ */ new Set([
|
|
22635
|
+
"type",
|
|
22636
|
+
"format",
|
|
22637
|
+
"maxLength",
|
|
22638
|
+
"minLength",
|
|
22639
|
+
"pattern"
|
|
22640
|
+
]);
|
|
22641
|
+
function compilePrimitiveSchema(context, schema) {
|
|
22642
|
+
const { type } = schema;
|
|
22643
|
+
switch (type) {
|
|
22644
|
+
case "number":
|
|
22645
|
+
case "integer": return compileNumericSchema(context, schema);
|
|
22646
|
+
case "string": return compileStringSchema(context, schema);
|
|
22647
|
+
case "boolean":
|
|
22648
|
+
case "null": {
|
|
22649
|
+
const rejectKeys = Object.keys(schema).filter((k) => isJSONSchemaKey(k) && k !== "type");
|
|
22650
|
+
if (rejectKeys.length > 0) recordWarn(context, `key "type" will exclude other keys: ${rejectKeys.toSorted().join(", ")}`);
|
|
22651
|
+
return wrapCompiledSchema(type === "null" ? CompiledKind.Null : CompiledKind.Boolean, { type }, context.delegate, context.path);
|
|
22652
|
+
}
|
|
22653
|
+
default:
|
|
22654
|
+
recordError(context, `invalid type ${JSON.stringify(type)}`);
|
|
22655
|
+
return null;
|
|
22656
|
+
}
|
|
22657
|
+
}
|
|
22658
|
+
function compileNumericSchema(context, schema) {
|
|
22659
|
+
const rejectKeys = Object.keys(schema).filter((k) => !NUMERIC_KEYS.has(k) && isJSONSchemaKey(k));
|
|
22660
|
+
if (rejectKeys.length > 0) recordWarn(context, `type=${JSON.stringify(schema.type)} will exclude other keys: ${rejectKeys.toSorted().join(", ")}`);
|
|
22661
|
+
const compiledSchema = pick(schema, NUMERIC_KEYS);
|
|
22662
|
+
for (const key of NUMERIC_KEYS) {
|
|
22663
|
+
const value = compiledSchema[key];
|
|
22664
|
+
if (key !== "type" && value !== void 0 && Number.isNaN(value)) {
|
|
22665
|
+
recordWarn(context, "found NaN", key);
|
|
22666
|
+
delete compiledSchema[key];
|
|
22667
|
+
}
|
|
22668
|
+
}
|
|
22669
|
+
const { maximum, exclusiveMaximum, minimum, exclusiveMinimum } = compiledSchema;
|
|
22670
|
+
if (maximum !== void 0 && exclusiveMaximum !== void 0) {
|
|
22671
|
+
if (maximum === exclusiveMaximum) delete compiledSchema.maximum;
|
|
22672
|
+
else if (maximum < exclusiveMaximum) delete compiledSchema.exclusiveMaximum;
|
|
22673
|
+
else if (maximum > exclusiveMaximum) delete compiledSchema.maximum;
|
|
22674
|
+
}
|
|
22675
|
+
if (minimum !== void 0 && exclusiveMinimum !== void 0) {
|
|
22676
|
+
if (minimum === exclusiveMinimum) delete compiledSchema.minimum;
|
|
22677
|
+
else if (minimum < exclusiveMinimum) delete compiledSchema.exclusiveMinimum;
|
|
22678
|
+
else if (minimum > exclusiveMinimum) delete compiledSchema.minimum;
|
|
22679
|
+
}
|
|
22680
|
+
const { multipleOf } = compiledSchema;
|
|
22681
|
+
if (multipleOf === 0) {
|
|
22682
|
+
delete compiledSchema.multipleOf;
|
|
22683
|
+
compiledSchema.type = "number";
|
|
22684
|
+
recordWarn(context, "cannot be 0", "multipleOf");
|
|
22685
|
+
}
|
|
22686
|
+
let kind = CompiledKind.Numeric;
|
|
22687
|
+
if (!isNumericPossibleInvalid(compiledSchema)) kind = CompiledKind.Never;
|
|
22688
|
+
return wrapCompiledSchema(kind, compiledSchema, context.delegate, context.path);
|
|
22689
|
+
}
|
|
22690
|
+
function isNumericPossibleInvalid(compiledSchema) {
|
|
22691
|
+
const { maximum, exclusiveMaximum, minimum, exclusiveMinimum } = compiledSchema;
|
|
22692
|
+
if (maximum !== void 0 && minimum !== void 0) return maximum >= minimum;
|
|
22693
|
+
else if (exclusiveMaximum !== void 0 && minimum !== void 0) return exclusiveMaximum > minimum;
|
|
22694
|
+
else if (maximum !== void 0 && exclusiveMinimum !== void 0) return maximum > exclusiveMinimum;
|
|
22695
|
+
else if (exclusiveMaximum !== void 0 && exclusiveMinimum !== void 0) return exclusiveMaximum > exclusiveMinimum;
|
|
22696
|
+
else return true;
|
|
22697
|
+
}
|
|
22698
|
+
function compileStringSchema(context, schema) {
|
|
22699
|
+
const rejectKeys = Object.keys(schema).filter((k) => !STRING_KEYS.has(k) && isJSONSchemaKey(k));
|
|
22700
|
+
if (rejectKeys.length > 0) recordWarn(context, `type="string" will exclude other keys: ${rejectKeys.toSorted().join(", ")}`);
|
|
22701
|
+
const compiledSchema = pick(schema, STRING_KEYS);
|
|
22702
|
+
cleanInvalidLength(context, compiledSchema, "maxLength");
|
|
22703
|
+
cleanInvalidLength(context, compiledSchema, "minLength");
|
|
22704
|
+
const max = compiledSchema.maxLength;
|
|
22705
|
+
const min = compiledSchema.minLength;
|
|
22706
|
+
let kind = CompiledKind.String;
|
|
22707
|
+
if (max !== void 0) {
|
|
22708
|
+
if (max < 0) kind = CompiledKind.Never;
|
|
22709
|
+
else if (max !== void 0 && min !== void 0 && max < min) kind = CompiledKind.Never;
|
|
22710
|
+
}
|
|
22711
|
+
return wrapCompiledSchema(kind, compiledSchema, context.delegate, context.path);
|
|
22712
|
+
}
|
|
22713
|
+
function cleanInvalidLength(context, compiledSchema, key) {
|
|
22714
|
+
const length = compiledSchema[key];
|
|
22715
|
+
if (length !== void 0) {
|
|
22716
|
+
if (Number.isNaN(length)) {
|
|
22717
|
+
recordWarn(context, "found NaN", key);
|
|
22718
|
+
delete compiledSchema[key];
|
|
22719
|
+
}
|
|
22720
|
+
}
|
|
22721
|
+
}
|
|
22722
|
+
//#endregion
|
|
22723
|
+
//#region src/json-schema-subset/compiler/compiler.ts
|
|
22724
|
+
var emptyList = Object.freeze([]);
|
|
22725
|
+
function compile(schema, extendsContext, payload, delegate) {
|
|
22726
|
+
if (isCompiledSchema(schema)) return {
|
|
22727
|
+
schema,
|
|
22728
|
+
warns: emptyList
|
|
22729
|
+
};
|
|
22730
|
+
if (extendsContext.isExtendsSchema(schema)) return {
|
|
22731
|
+
schema,
|
|
22732
|
+
warns: emptyList
|
|
22733
|
+
};
|
|
22734
|
+
if (delegate) {
|
|
22735
|
+
const isSchemaResult = delegate.isSchema(schema);
|
|
22736
|
+
if (typeof isSchemaResult === "object") {
|
|
22737
|
+
const items = [];
|
|
22738
|
+
for (const error of isSchemaResult) items.push({
|
|
22739
|
+
kind: SchemaErrorItemKind.External,
|
|
22740
|
+
error
|
|
22741
|
+
});
|
|
22742
|
+
if (items.length > 0) return items;
|
|
22743
|
+
} else if (isSchemaResult === false) throw new Error("it is not a JSON Schema 7");
|
|
22744
|
+
}
|
|
22745
|
+
const context = {
|
|
22746
|
+
delegate,
|
|
22747
|
+
payload,
|
|
22748
|
+
extends: extendsContext,
|
|
22749
|
+
path: [],
|
|
22750
|
+
errors: [],
|
|
22751
|
+
warns: []
|
|
22752
|
+
};
|
|
22753
|
+
const compiledSchema = compileSchema(context, schema);
|
|
22754
|
+
if (compiledSchema) assertCondition(context.errors.length === 0, "found errors (it should be empty)");
|
|
22755
|
+
else {
|
|
22756
|
+
assertCondition(context.errors.length > 0, "cannot found any errors");
|
|
22757
|
+
return context.errors;
|
|
22758
|
+
}
|
|
22759
|
+
return {
|
|
22760
|
+
schema: compiledSchema,
|
|
22761
|
+
warns: context.warns
|
|
22762
|
+
};
|
|
22763
|
+
}
|
|
22764
|
+
function assertCondition(condition, message) {
|
|
22765
|
+
if (!condition) throw new Error(message);
|
|
22766
|
+
}
|
|
22767
|
+
function compileSchema(context, schema) {
|
|
22768
|
+
if (context.extends.isExtendsSchema(schema)) return schema;
|
|
22769
|
+
if (isCompiledSchema(schema)) return schema;
|
|
22770
|
+
const extendsSchema = context.extends.tryCompiledExtendsSchema(schema, context.payload);
|
|
22771
|
+
if (extendsSchema) return extendsSchema;
|
|
22772
|
+
let targetSchema = schema;
|
|
22773
|
+
let shouldHandleEnumAndConst = false;
|
|
22774
|
+
const { enum: enumList, const: constValue } = schema;
|
|
22775
|
+
if (enumList || constValue) {
|
|
22776
|
+
const { enum: _0, const: _1, ...rest } = schema;
|
|
22777
|
+
targetSchema = rest;
|
|
22778
|
+
shouldHandleEnumAndConst = true;
|
|
22779
|
+
}
|
|
22780
|
+
let compiledSchema = checkAndCompileSchema(context, targetSchema);
|
|
22781
|
+
if (compiledSchema && shouldHandleEnumAndConst) compiledSchema = compileEnumAndConst(context, enumList, constValue, compiledSchema);
|
|
22782
|
+
if (!compiledSchema) return null;
|
|
22783
|
+
return compiledSchema;
|
|
22784
|
+
}
|
|
22785
|
+
function checkAndCompileSchema(context, schema) {
|
|
22786
|
+
for (const key of COMBINATION_KEYS) {
|
|
22787
|
+
const combinationList = schema[key];
|
|
22788
|
+
if (combinationList) {
|
|
22789
|
+
const rejectKeys = Object.keys(schema).filter((k) => isJSONSchemaKey(k) && k !== key);
|
|
22790
|
+
if (rejectKeys.length > 0) recordWarn(context, `composition key ${JSON.stringify(key)} will exclude other keys: ${rejectKeys.toSorted().join(", ")}`);
|
|
22791
|
+
const compiledSchema = compileCombinationSchema(context, key, combinationList);
|
|
22792
|
+
if (!compiledSchema) return null;
|
|
22793
|
+
return compiledSchema;
|
|
22794
|
+
}
|
|
22795
|
+
}
|
|
22796
|
+
{
|
|
22797
|
+
const notSchema = unwrapJSONSchema7Definition(schema.not);
|
|
22798
|
+
if (notSchema) {
|
|
22799
|
+
const rejectKeys = Object.keys(schema).filter((k) => isJSONSchemaKey(k) && k !== "not");
|
|
22800
|
+
if (rejectKeys.length > 0) recordWarn(context, `key "not" will exclude other keys: ${rejectKeys.toSorted().join(", ")}`);
|
|
22801
|
+
const subSchema = compileSchema(joinPath(context, "not"), notSchema);
|
|
22802
|
+
if (!subSchema) return null;
|
|
22803
|
+
let kind = CompiledKind.Not;
|
|
22804
|
+
switch (getKind(subSchema)) {
|
|
22805
|
+
case CompiledKind.Never:
|
|
22806
|
+
kind = CompiledKind.Any;
|
|
22807
|
+
break;
|
|
22808
|
+
case CompiledKind.Any: kind = CompiledKind.Never;
|
|
22809
|
+
}
|
|
22810
|
+
return wrapCompiledSchema(kind, { not: subSchema }, context.delegate, context.path);
|
|
22811
|
+
}
|
|
22812
|
+
}
|
|
22813
|
+
if (schema.type) {
|
|
22814
|
+
const { type } = schema;
|
|
22815
|
+
if (Array.isArray(type)) {
|
|
22816
|
+
const { type: _type, ...rest } = schema;
|
|
22817
|
+
return compileCombinationSchema(context, "anyOf", type.map((item) => ({
|
|
22818
|
+
...rest,
|
|
22819
|
+
type: item
|
|
22820
|
+
})));
|
|
22821
|
+
}
|
|
22822
|
+
switch (type) {
|
|
22823
|
+
case "object": return compileObjectSchema(context, schema);
|
|
22824
|
+
case "array": return compileArraySchema(context, schema);
|
|
22825
|
+
default: return compilePrimitiveSchema(context, schema);
|
|
22826
|
+
}
|
|
22827
|
+
}
|
|
22828
|
+
if (isLogicEmptyObject(schema)) return wrapCompiledSchema(CompiledKind.Any, {}, context.delegate, context.path);
|
|
22829
|
+
recordError(context, "unrecognized");
|
|
22830
|
+
return null;
|
|
22831
|
+
}
|
|
22832
|
+
//#endregion
|
|
22833
|
+
//#region src/json-schema-subset/checker/tools/mark.ts
|
|
22834
|
+
var VariableBundleDescription = class {
|
|
22835
|
+
constructor(_keys) {
|
|
22836
|
+
const keys = Object.freeze(_keys.toSorted());
|
|
22837
|
+
if (keys.length > 32) throw new Error(`cannot define ${keys.length} keys which is greater than 32`);
|
|
22838
|
+
this.keys = keys;
|
|
22839
|
+
this.clazz = class extends VariableBundleImpls {
|
|
22840
|
+
constructor(int32) {
|
|
22841
|
+
super(keys, int32);
|
|
22842
|
+
}
|
|
22843
|
+
};
|
|
22844
|
+
for (const [i, key] of this.keys.entries()) {
|
|
22845
|
+
const mask = 1 << i;
|
|
22846
|
+
Object.defineProperty(this.clazz.prototype, key, {
|
|
22847
|
+
enumerable: true,
|
|
22848
|
+
get: function get() {
|
|
22849
|
+
return !!(this.int32 & mask);
|
|
22850
|
+
},
|
|
22851
|
+
set: function set(value) {
|
|
22852
|
+
if (value) this.int32 |= mask;
|
|
22853
|
+
else this.int32 &= ~mask;
|
|
22854
|
+
}
|
|
22855
|
+
});
|
|
22856
|
+
}
|
|
22857
|
+
}
|
|
22858
|
+
toBundle(variable) {
|
|
22859
|
+
let int32 = 0;
|
|
22860
|
+
if (typeof variable === "number") int32 = variable;
|
|
22861
|
+
else if (variable) {
|
|
22862
|
+
for (const [i, key] of this.keys.entries()) if (variable[key]) int32 |= 1 << i;
|
|
22863
|
+
}
|
|
22864
|
+
return new this.clazz(int32);
|
|
22865
|
+
}
|
|
22866
|
+
};
|
|
22867
|
+
var VariableBundleImpls = class {
|
|
22868
|
+
constructor(keys, int32) {
|
|
22869
|
+
this.keys = keys;
|
|
22870
|
+
this.int32 = int32;
|
|
22871
|
+
}
|
|
22872
|
+
toInt32() {
|
|
22873
|
+
return this.int32;
|
|
22874
|
+
}
|
|
22875
|
+
toString() {
|
|
22876
|
+
const object = {};
|
|
22877
|
+
for (const key of this.keys) object[key] = this[key];
|
|
22878
|
+
return JSON.stringify(object);
|
|
22879
|
+
}
|
|
22880
|
+
};
|
|
22881
|
+
//#endregion
|
|
22882
|
+
//#region src/json-schema-subset/checker/tools/quantum.ts
|
|
22883
|
+
function makeQuantum(keys) {
|
|
22884
|
+
return new QuantumImpls(keys);
|
|
22885
|
+
}
|
|
22886
|
+
var QuantumImpls = class {
|
|
22887
|
+
constructor(keys) {
|
|
22888
|
+
this.description = new VariableBundleDescription(keys);
|
|
22889
|
+
}
|
|
22890
|
+
get keys() {
|
|
22891
|
+
return this.description.keys;
|
|
22892
|
+
}
|
|
22893
|
+
variable(variable) {
|
|
22894
|
+
let int32;
|
|
22895
|
+
if (variable) int32 = this.description.toBundle(variable).toInt32();
|
|
22896
|
+
return new QuantumVariableImpls(this.description, int32);
|
|
22897
|
+
}
|
|
22898
|
+
};
|
|
22899
|
+
var QuantumVariableImpls = class {
|
|
22900
|
+
constructor(description, int32) {
|
|
22901
|
+
this.values = /* @__PURE__ */ new Set();
|
|
22902
|
+
this.description = description;
|
|
22903
|
+
if (int32 !== void 0) this.values.add(int32);
|
|
22904
|
+
}
|
|
22905
|
+
[Symbol.iterator]() {
|
|
22906
|
+
const iterator = this.values[Symbol.iterator]();
|
|
22907
|
+
return { next: () => {
|
|
22908
|
+
const result = iterator.next();
|
|
22909
|
+
if (result.done) return result;
|
|
22910
|
+
else return {
|
|
22911
|
+
done: false,
|
|
22912
|
+
value: this.description.toBundle(result.value)
|
|
22913
|
+
};
|
|
22914
|
+
} };
|
|
22915
|
+
}
|
|
22916
|
+
assign(other) {
|
|
22917
|
+
const { values } = other;
|
|
22918
|
+
for (const int32 of values) this.values.add(int32);
|
|
22919
|
+
return this;
|
|
22920
|
+
}
|
|
22921
|
+
push(expression, calculate) {
|
|
22922
|
+
const nextValues = /* @__PURE__ */ new Set();
|
|
22923
|
+
for (const int32 of this.values) for (const [singleExpression, mask] of ExpressionMaskList) if (expression & mask) {
|
|
22924
|
+
const variable = this.description.toBundle(int32);
|
|
22925
|
+
calculate(singleExpression, variable);
|
|
22926
|
+
nextValues.add(variable.toInt32());
|
|
22927
|
+
}
|
|
22928
|
+
this.values = nextValues;
|
|
22929
|
+
}
|
|
22930
|
+
update(invoker) {
|
|
22931
|
+
const nextValues = /* @__PURE__ */ new Set();
|
|
22932
|
+
for (const int32 of this.values) {
|
|
22933
|
+
const variable = this.description.toBundle(int32);
|
|
22934
|
+
invoker(variable);
|
|
22935
|
+
nextValues.add(variable.toInt32());
|
|
22936
|
+
}
|
|
22937
|
+
this.values = nextValues;
|
|
22938
|
+
}
|
|
22939
|
+
};
|
|
22940
|
+
//#endregion
|
|
22941
|
+
//#region src/json-schema-subset/checker/tools/range.ts
|
|
22942
|
+
function splitRange$3(range1, range2) {
|
|
22943
|
+
const [min1] = range1;
|
|
22944
|
+
const [min2] = range2;
|
|
22945
|
+
if (min1.num < min2.num) return splitRangeLessBranch(range1, range2);
|
|
22946
|
+
else if (min1.num > min2.num) return splitRangeGreaterBranch(range1, range2);
|
|
22947
|
+
else return splitRangeEqualsBranch(range1, range2);
|
|
22948
|
+
}
|
|
22949
|
+
function splitRangeLessBranch(range1, range2) {
|
|
22950
|
+
const [min1, max1] = range1;
|
|
22951
|
+
const [min2, max2] = range2;
|
|
22952
|
+
if (max1.num <= min2.num) {
|
|
22953
|
+
const exclusive1 = max1.exclusive;
|
|
22954
|
+
const exclusive2 = min2.exclusive;
|
|
22955
|
+
if (max1.num < min2.num || exclusive1 || exclusive2) return {
|
|
22956
|
+
left: {
|
|
22957
|
+
fromLeft: true,
|
|
22958
|
+
range: range1
|
|
22959
|
+
},
|
|
22960
|
+
right: {
|
|
22961
|
+
fromLeft: false,
|
|
22962
|
+
range: range2
|
|
22963
|
+
}
|
|
22964
|
+
};
|
|
22965
|
+
}
|
|
22966
|
+
if (max1.num <= max2.num) {
|
|
22967
|
+
let hasRight = true;
|
|
22968
|
+
let isLeftRangeOverride = false;
|
|
22969
|
+
if (max1.num === max2.num) {
|
|
22970
|
+
const exclusive1 = max1.exclusive;
|
|
22971
|
+
const exclusive2 = max2.exclusive;
|
|
22972
|
+
hasRight = exclusive1 !== exclusive2;
|
|
22973
|
+
isLeftRangeOverride = !exclusive1 && exclusive2;
|
|
22974
|
+
}
|
|
22975
|
+
if (!isLeftRangeOverride) {
|
|
22976
|
+
let right;
|
|
22977
|
+
if (hasRight) right = {
|
|
22978
|
+
fromLeft: false,
|
|
22979
|
+
range: [reversalExclusive(max1), max2]
|
|
22980
|
+
};
|
|
22981
|
+
return {
|
|
22982
|
+
left: {
|
|
22983
|
+
fromLeft: true,
|
|
22984
|
+
range: [min1, reversalExclusive(min2)]
|
|
22985
|
+
},
|
|
22986
|
+
center: [min2, max1],
|
|
22987
|
+
right
|
|
22988
|
+
};
|
|
22989
|
+
}
|
|
22990
|
+
}
|
|
22991
|
+
return {
|
|
22992
|
+
left: {
|
|
22993
|
+
fromLeft: true,
|
|
22994
|
+
range: [min1, reversalExclusive(min2)]
|
|
22995
|
+
},
|
|
22996
|
+
center: [min2, max2],
|
|
22997
|
+
right: {
|
|
22998
|
+
fromLeft: true,
|
|
22999
|
+
range: [reversalExclusive(max2), max1]
|
|
23000
|
+
}
|
|
23001
|
+
};
|
|
23002
|
+
}
|
|
23003
|
+
function splitRangeGreaterBranch(range1, range2) {
|
|
23004
|
+
const [min1, max1] = range1;
|
|
23005
|
+
const [min2, max2] = range2;
|
|
23006
|
+
if (min1.num >= max2.num) {
|
|
23007
|
+
const exclusive1 = max2.exclusive;
|
|
23008
|
+
const exclusive2 = min1.exclusive;
|
|
23009
|
+
if (min1.num > max2.num || exclusive1 || exclusive2) return {
|
|
23010
|
+
left: {
|
|
23011
|
+
fromLeft: false,
|
|
23012
|
+
range: range2
|
|
23013
|
+
},
|
|
23014
|
+
right: {
|
|
23015
|
+
fromLeft: true,
|
|
23016
|
+
range: range1
|
|
23017
|
+
}
|
|
23018
|
+
};
|
|
23019
|
+
}
|
|
23020
|
+
if (max2.num <= max1.num) {
|
|
23021
|
+
let hasRight = true;
|
|
23022
|
+
let isRightRangeOverride = false;
|
|
23023
|
+
if (max1.num === max2.num) {
|
|
23024
|
+
const exclusive1 = max2.exclusive;
|
|
23025
|
+
const exclusive2 = max1.exclusive;
|
|
23026
|
+
hasRight = exclusive1 !== exclusive2;
|
|
23027
|
+
isRightRangeOverride = !exclusive1 && exclusive2;
|
|
23028
|
+
}
|
|
23029
|
+
if (!isRightRangeOverride) {
|
|
23030
|
+
let right;
|
|
23031
|
+
if (hasRight) right = {
|
|
23032
|
+
fromLeft: true,
|
|
23033
|
+
range: [reversalExclusive(max2), max1]
|
|
23034
|
+
};
|
|
23035
|
+
return {
|
|
23036
|
+
left: {
|
|
23037
|
+
fromLeft: false,
|
|
23038
|
+
range: [min2, reversalExclusive(min1)]
|
|
23039
|
+
},
|
|
23040
|
+
center: [min1, max2],
|
|
23041
|
+
right
|
|
23042
|
+
};
|
|
23043
|
+
}
|
|
23044
|
+
}
|
|
23045
|
+
return {
|
|
23046
|
+
left: {
|
|
23047
|
+
fromLeft: false,
|
|
23048
|
+
range: [min2, reversalExclusive(min1)]
|
|
23049
|
+
},
|
|
23050
|
+
center: [min1, max1],
|
|
23051
|
+
right: {
|
|
23052
|
+
fromLeft: false,
|
|
23053
|
+
range: [reversalExclusive(max1), max2]
|
|
23054
|
+
}
|
|
23055
|
+
};
|
|
23056
|
+
}
|
|
23057
|
+
function splitRangeEqualsBranch(range1, range2) {
|
|
23058
|
+
const [min1, max1] = range1;
|
|
23059
|
+
const [min2, max2] = range2;
|
|
23060
|
+
const exclusive1 = min1.exclusive;
|
|
23061
|
+
const exclusive2 = min2.exclusive;
|
|
23062
|
+
let left;
|
|
23063
|
+
let centerBegin = min1;
|
|
23064
|
+
if (!exclusive1 && exclusive2) {
|
|
23065
|
+
centerBegin = min2;
|
|
23066
|
+
left = {
|
|
23067
|
+
fromLeft: true,
|
|
23068
|
+
range: [min1, reversalExclusive(min2)]
|
|
23069
|
+
};
|
|
23070
|
+
} else if (exclusive1 && !exclusive2) left = {
|
|
23071
|
+
fromLeft: false,
|
|
23072
|
+
range: [min2, reversalExclusive(min1)]
|
|
23073
|
+
};
|
|
23074
|
+
if (max1.num <= max2.num) {
|
|
23075
|
+
let hasRight = true;
|
|
23076
|
+
let isLeftRangeOverride = false;
|
|
23077
|
+
if (max1.num === max2.num) {
|
|
23078
|
+
const maxExclusive1 = max1.exclusive;
|
|
23079
|
+
const maxExclusive2 = max2.exclusive;
|
|
23080
|
+
hasRight = maxExclusive1 !== maxExclusive2;
|
|
23081
|
+
isLeftRangeOverride = !maxExclusive1 && maxExclusive2;
|
|
23082
|
+
}
|
|
23083
|
+
if (!isLeftRangeOverride) {
|
|
23084
|
+
let right;
|
|
23085
|
+
if (hasRight) right = {
|
|
23086
|
+
fromLeft: false,
|
|
23087
|
+
range: [reversalExclusive(max1), max2]
|
|
23088
|
+
};
|
|
23089
|
+
return {
|
|
23090
|
+
left,
|
|
23091
|
+
center: [centerBegin, max1],
|
|
23092
|
+
right
|
|
23093
|
+
};
|
|
23094
|
+
}
|
|
23095
|
+
}
|
|
23096
|
+
return {
|
|
23097
|
+
left,
|
|
23098
|
+
center: [centerBegin, max2],
|
|
23099
|
+
right: {
|
|
23100
|
+
fromLeft: true,
|
|
23101
|
+
range: [reversalExclusive(max2), max1]
|
|
23102
|
+
}
|
|
23103
|
+
};
|
|
23104
|
+
}
|
|
23105
|
+
function reversalExclusive(point) {
|
|
23106
|
+
return {
|
|
23107
|
+
num: point.num,
|
|
23108
|
+
exclusive: !point.exclusive
|
|
23109
|
+
};
|
|
23110
|
+
}
|
|
23111
|
+
//#endregion
|
|
23112
|
+
//#region src/json-schema-subset/checker/range.ts
|
|
23113
|
+
var createRangeSplitter = (undefinedMin) => (min1 = undefinedMin, max1 = Number.POSITIVE_INFINITY, min2 = undefinedMin, max2 = Number.POSITIVE_INFINITY) => {
|
|
23114
|
+
const { left, center, right } = splitRange$3([{
|
|
23115
|
+
num: min1,
|
|
23116
|
+
exclusive: false
|
|
23117
|
+
}, {
|
|
23118
|
+
num: max1,
|
|
23119
|
+
exclusive: false
|
|
23120
|
+
}], [{
|
|
23121
|
+
num: min2,
|
|
23122
|
+
exclusive: false
|
|
23123
|
+
}, {
|
|
23124
|
+
num: max2,
|
|
23125
|
+
exclusive: false
|
|
23126
|
+
}]);
|
|
23127
|
+
let leftItem;
|
|
23128
|
+
let rightItem;
|
|
23129
|
+
let intersectionItem;
|
|
23130
|
+
if (left) leftItem = {
|
|
23131
|
+
min: left.range[0].num,
|
|
23132
|
+
max: left.range[1].num,
|
|
23133
|
+
isFrom1: left.fromLeft
|
|
23134
|
+
};
|
|
23135
|
+
if (right) rightItem = {
|
|
23136
|
+
min: right.range[0].num,
|
|
23137
|
+
max: right.range[1].num,
|
|
23138
|
+
isFrom1: right.fromLeft
|
|
23139
|
+
};
|
|
23140
|
+
if (center) intersectionItem = {
|
|
23141
|
+
min: center[0].num,
|
|
23142
|
+
max: center[1].num
|
|
23143
|
+
};
|
|
23144
|
+
return {
|
|
23145
|
+
left: leftItem,
|
|
23146
|
+
right: rightItem,
|
|
23147
|
+
intersection: intersectionItem
|
|
23148
|
+
};
|
|
23149
|
+
};
|
|
23150
|
+
function toExpressionSingleResult({ left, right, intersection }) {
|
|
23151
|
+
if (!intersection) return ExpressionSingleResult.Rejection;
|
|
23152
|
+
let extra1 = false;
|
|
23153
|
+
let extra2 = false;
|
|
23154
|
+
if (left) {
|
|
23155
|
+
if (left.isFrom1) extra1 = true;
|
|
23156
|
+
else extra2 = true;
|
|
23157
|
+
}
|
|
23158
|
+
if (right) {
|
|
23159
|
+
if (right.isFrom1) extra1 = true;
|
|
23160
|
+
else extra2 = true;
|
|
23161
|
+
}
|
|
23162
|
+
if (extra1 && extra2) return ExpressionSingleResult.Intersection;
|
|
23163
|
+
if (extra1) return ExpressionSingleResult.Containing;
|
|
23164
|
+
if (extra2) return ExpressionSingleResult.ContainedBy;
|
|
23165
|
+
return ExpressionSingleResult.Equals;
|
|
23166
|
+
}
|
|
23167
|
+
//#endregion
|
|
23168
|
+
//#region src/json-schema-subset/checker/array.ts
|
|
23169
|
+
var splitRange$2 = createRangeSplitter(0);
|
|
23170
|
+
var quantum$1 = makeQuantum([
|
|
23171
|
+
"hasCommon",
|
|
23172
|
+
"hasExtra1",
|
|
23173
|
+
"hasExtra2",
|
|
23174
|
+
"hasRejection",
|
|
23175
|
+
"hasCommonBroken"
|
|
23176
|
+
]);
|
|
23177
|
+
function calculateArray({ calculate }, schema1, schema2) {
|
|
23178
|
+
const splitResult = splitRange$2(schema1.minItems, schema1.maxItems, schema2.minItems, schema2.maxItems);
|
|
23179
|
+
const splitExpression = toExpressionSingleResult(splitResult);
|
|
23180
|
+
if (splitExpression === ExpressionSingleResult.Rejection) return ExpressionRejection;
|
|
23181
|
+
const [items1, additionalItems1] = normalizeArray(schema1);
|
|
23182
|
+
const [items2, additionalItems2] = normalizeArray(schema2);
|
|
23183
|
+
const itemsLength = Math.max(items1.length, items2.length) + 1;
|
|
23184
|
+
const length = Math.min(itemsLength, splitResult.intersection.max);
|
|
23185
|
+
const quantumVariable = quantum$1.variable({});
|
|
23186
|
+
const minItems = Math.min(schema1.minItems ?? 0, schema2.minItems ?? 0);
|
|
23187
|
+
for (let i = 0; i < length; i++) {
|
|
23188
|
+
const expression = calculate(items1[i] ?? additionalItems1, items2[i] ?? additionalItems2);
|
|
23189
|
+
quantumVariable.push(expression, (singleExpression, variable) => {
|
|
23190
|
+
switch (singleExpression) {
|
|
23191
|
+
case ExpressionSingleResult.Equals:
|
|
23192
|
+
if (!variable.hasRejection) variable.hasCommon = true;
|
|
23193
|
+
break;
|
|
23194
|
+
case ExpressionSingleResult.Containing:
|
|
23195
|
+
if (!variable.hasRejection) variable.hasCommon = true;
|
|
23196
|
+
variable.hasExtra1 = true;
|
|
23197
|
+
break;
|
|
23198
|
+
case ExpressionSingleResult.ContainedBy:
|
|
23199
|
+
if (!variable.hasRejection) variable.hasCommon = true;
|
|
23200
|
+
variable.hasExtra2 = true;
|
|
23201
|
+
break;
|
|
23202
|
+
case ExpressionSingleResult.Intersection:
|
|
23203
|
+
if (!variable.hasRejection) variable.hasCommon = true;
|
|
23204
|
+
variable.hasExtra1 = true;
|
|
23205
|
+
variable.hasExtra2 = true;
|
|
23206
|
+
break;
|
|
23207
|
+
case ExpressionSingleResult.Rejection:
|
|
23208
|
+
if (i < minItems) variable.hasCommonBroken = true;
|
|
23209
|
+
variable.hasRejection = true;
|
|
23210
|
+
variable.hasExtra1 = true;
|
|
23211
|
+
variable.hasExtra2 = true;
|
|
23212
|
+
}
|
|
23213
|
+
});
|
|
23214
|
+
}
|
|
23215
|
+
quantumVariable.update((variable) => {
|
|
23216
|
+
switch (splitExpression) {
|
|
23217
|
+
case ExpressionSingleResult.Containing:
|
|
23218
|
+
variable.hasExtra1 = true;
|
|
23219
|
+
break;
|
|
23220
|
+
case ExpressionSingleResult.ContainedBy:
|
|
23221
|
+
variable.hasExtra2 = true;
|
|
23222
|
+
break;
|
|
23223
|
+
case ExpressionSingleResult.Intersection:
|
|
23224
|
+
variable.hasExtra1 = true;
|
|
23225
|
+
variable.hasExtra2 = true;
|
|
23226
|
+
}
|
|
23227
|
+
if (schema1.uniqueItems && !schema2.uniqueItems && (schema2.maxItems ?? Number.POSITIVE_INFINITY) > 1) variable.hasExtra2 = true;
|
|
23228
|
+
else if (!schema1.uniqueItems && schema2.uniqueItems && (schema1.maxItems ?? Number.POSITIVE_INFINITY) > 1) variable.hasExtra1 = true;
|
|
23229
|
+
if (schema1.maxItems === 0 || schema2.maxItems === 0) {
|
|
23230
|
+
variable.hasCommon = true;
|
|
23231
|
+
if (schema1.maxItems !== 0) variable.hasExtra1 = true;
|
|
23232
|
+
if (schema2.maxItems !== 0) variable.hasExtra2 = true;
|
|
23233
|
+
}
|
|
23234
|
+
});
|
|
23235
|
+
let expression = 0;
|
|
23236
|
+
for (const { hasExtra1, hasExtra2, hasCommon, hasCommonBroken } of quantumVariable) {
|
|
23237
|
+
let finalHasCommon = hasCommon;
|
|
23238
|
+
if (hasCommonBroken) finalHasCommon = false;
|
|
23239
|
+
if (!finalHasCommon) expression |= ExpressionRejection;
|
|
23240
|
+
else if (hasExtra1 && hasExtra2) expression |= ExpressionIntersection;
|
|
23241
|
+
else if (hasExtra1) expression |= ExpressionContaining;
|
|
23242
|
+
else if (hasExtra2) expression |= ExpressionContainedBy;
|
|
23243
|
+
else expression |= ExpressionEquals;
|
|
23244
|
+
}
|
|
23245
|
+
return expression;
|
|
23246
|
+
}
|
|
23247
|
+
function normalizeArray({ items, additionalItems }) {
|
|
23248
|
+
if (Array.isArray(items)) return [items, additionalItems ?? ANY];
|
|
23249
|
+
else return [[], items ?? ANY];
|
|
23250
|
+
}
|
|
23251
|
+
//#endregion
|
|
23252
|
+
//#region src/json-schema-subset/checker/cache.ts
|
|
23253
|
+
function wrapEqualsCheckerWithCache(check) {
|
|
23254
|
+
const map = /* @__PURE__ */ new Map();
|
|
23255
|
+
return (value1, value2) => {
|
|
23256
|
+
const isObject1 = isCompiledObject(value1);
|
|
23257
|
+
if (isObject1 !== isCompiledObject(value2)) return false;
|
|
23258
|
+
if (!isObject1) return value1 === value2;
|
|
23259
|
+
return getWithCache(map, value1, value2, check);
|
|
23260
|
+
};
|
|
23261
|
+
}
|
|
23262
|
+
function wrapSchemaCalculatorWithCache(check) {
|
|
23263
|
+
const map = /* @__PURE__ */ new Map();
|
|
23264
|
+
return (schema1, schema2) => getWithCache(map, schema1, schema2, check);
|
|
23265
|
+
}
|
|
23266
|
+
function getWithCache(map, node1, node2, check) {
|
|
23267
|
+
const key = `${getId(node1)}/${getId(node2)}`;
|
|
23268
|
+
let result = map.get(key);
|
|
23269
|
+
if (result === void 0) map.set(key, result = check(node1, node2));
|
|
23270
|
+
return result;
|
|
23271
|
+
}
|
|
23272
|
+
//#endregion
|
|
23273
|
+
//#region src/json-schema-subset/checker/enumAndConst.ts
|
|
23274
|
+
function calculateEnumAndEnum(context, schema1, schema2) {
|
|
23275
|
+
const enumList1 = normalizeEnumList(schema1);
|
|
23276
|
+
const enumList2 = normalizeEnumList(schema2);
|
|
23277
|
+
let foundExtra1 = false;
|
|
23278
|
+
let foundExtra2 = false;
|
|
23279
|
+
let foundIntersection = false;
|
|
23280
|
+
for (const enum1 of enumList1) {
|
|
23281
|
+
if (hasEqualsEnum(context, enumList2, enum1)) foundIntersection = true;
|
|
23282
|
+
else foundExtra1 = true;
|
|
23283
|
+
if (foundExtra1 && foundIntersection) break;
|
|
23284
|
+
}
|
|
23285
|
+
for (const enum2 of enumList2) {
|
|
23286
|
+
if (hasEqualsEnum(context, enumList1, enum2)) foundIntersection = true;
|
|
23287
|
+
else foundExtra2 = true;
|
|
23288
|
+
if (foundExtra2 && foundIntersection) break;
|
|
23289
|
+
}
|
|
23290
|
+
if (!foundIntersection) return ExpressionRejection;
|
|
23291
|
+
if (foundExtra1 && foundExtra2) return ExpressionIntersection;
|
|
23292
|
+
if (foundExtra1) return ExpressionContaining;
|
|
23293
|
+
if (foundExtra2) return ExpressionContainedBy;
|
|
23294
|
+
return ExpressionEquals;
|
|
23295
|
+
}
|
|
23296
|
+
function calculateEnumAndSchema(enumSchema, schema) {
|
|
23297
|
+
let hasValid = false;
|
|
23298
|
+
let hasInvalid = false;
|
|
23299
|
+
for (const enumValue of normalizeEnumList(enumSchema)) {
|
|
23300
|
+
switch (valid(schema, enumValue)) {
|
|
23301
|
+
case ValidResult.Valid:
|
|
23302
|
+
hasValid = true;
|
|
23303
|
+
break;
|
|
23304
|
+
case ValidResult.Invalid:
|
|
23305
|
+
hasInvalid = true;
|
|
23306
|
+
break;
|
|
23307
|
+
case ValidResult.Unknown: return ExpressionAny;
|
|
23308
|
+
}
|
|
23309
|
+
if (hasValid && hasInvalid) break;
|
|
23310
|
+
}
|
|
23311
|
+
if (hasValid && hasInvalid) return ExpressionIntersection;
|
|
23312
|
+
if (hasValid) return ExpressionEquals | ExpressionContainedBy;
|
|
23313
|
+
if (hasInvalid) return ExpressionRejection;
|
|
23314
|
+
if (getKind(schema) === CompiledKind.Never) return ExpressionEquals;
|
|
23315
|
+
return ExpressionContainedBy;
|
|
23316
|
+
}
|
|
23317
|
+
function normalizeEnumList({ const: constValue, enum: enumList }) {
|
|
23318
|
+
if (constValue !== void 0) return [constValue];
|
|
23319
|
+
if (enumList) return enumList;
|
|
23320
|
+
throw new Error("invalid branch");
|
|
23321
|
+
}
|
|
23322
|
+
function hasEqualsEnum({ isEquals }, enumList, checkedEnum) {
|
|
23323
|
+
for (const searchedEnum of enumList) if (isEquals(searchedEnum, checkedEnum)) return true;
|
|
23324
|
+
return false;
|
|
23325
|
+
}
|
|
23326
|
+
//#endregion
|
|
23327
|
+
//#region src/json-schema-subset/checker/equals.ts
|
|
23328
|
+
function schemaEqualsChecker(extendsContext) {
|
|
23329
|
+
function isSchemaEquals(schema1, schema2) {
|
|
23330
|
+
const isExtends1 = extendsContext.isExtendsSchema(schema1);
|
|
23331
|
+
const isExtends2 = extendsContext.isExtendsSchema(schema2);
|
|
23332
|
+
if (isExtends1 || isExtends2) return extendsContext.equals(schema1, schema2);
|
|
23333
|
+
else return isCompiledSchemaEquals(schema1, schema2);
|
|
23334
|
+
}
|
|
23335
|
+
const equalsMap = /* @__PURE__ */ new Map();
|
|
23336
|
+
function isCompiledSchemaEquals(schema1, schema2) {
|
|
23337
|
+
const id1 = getId(schema1);
|
|
23338
|
+
const id2 = getId(schema2);
|
|
23339
|
+
if (id1 === id2) return true;
|
|
23340
|
+
const key = `${id1}/${id2}`;
|
|
23341
|
+
let isEquals = equalsMap.get(key);
|
|
23342
|
+
if (isEquals === void 0) {
|
|
23343
|
+
isEquals = isObjectLikeEquals(schema1, schema2);
|
|
23344
|
+
equalsMap.set(key, isEquals);
|
|
23345
|
+
}
|
|
23346
|
+
return isEquals;
|
|
23347
|
+
}
|
|
23348
|
+
function isObjectLikeEquals(object1, object2) {
|
|
23349
|
+
if (Array.isArray(object1)) {
|
|
23350
|
+
if (!Array.isArray(object2)) return false;
|
|
23351
|
+
if (object1.length !== object2.length) return false;
|
|
23352
|
+
for (const [i, value1Element] of object1.entries()) if (!isValueEquals(value1Element, object2[i])) return false;
|
|
23353
|
+
} else {
|
|
23354
|
+
if (Array.isArray(object2)) return false;
|
|
23355
|
+
for (const key in object1) {
|
|
23356
|
+
if (!(key in object2)) return false;
|
|
23357
|
+
if (!isValueEquals(Reflect.get(object1, key), Reflect.get(object2, key))) return false;
|
|
23358
|
+
}
|
|
23359
|
+
for (const key in object2) if (!(key in object1)) return false;
|
|
23360
|
+
}
|
|
23361
|
+
return true;
|
|
23362
|
+
}
|
|
23363
|
+
function isValueEquals(value1, value2) {
|
|
23364
|
+
if (value1 === value2) return true;
|
|
23365
|
+
if (value1 === null) return false;
|
|
23366
|
+
if (typeof value1 !== "object") return false;
|
|
23367
|
+
if (typeof value1 !== typeof value2) return false;
|
|
23368
|
+
if (isCompiledSchema(value1) && isCompiledSchema(value2)) return isCompiledSchemaEquals(value1, value2);
|
|
23369
|
+
return isObjectLikeEquals(value1, value2);
|
|
23370
|
+
}
|
|
23371
|
+
return isSchemaEquals;
|
|
23372
|
+
}
|
|
23373
|
+
//#endregion
|
|
23374
|
+
//#region src/json-schema-subset/checker/numeric/integerNormalizer.ts
|
|
23375
|
+
function normalizeInteger(schema) {
|
|
23376
|
+
const floatRange = pickRange(schema);
|
|
23377
|
+
const multipleOf = schema.multipleOf ?? 1;
|
|
23378
|
+
const range = cutRange(floatRange, multipleOf);
|
|
23379
|
+
if (!range) return null;
|
|
23380
|
+
return {
|
|
23381
|
+
multipleOf,
|
|
23382
|
+
range
|
|
23383
|
+
};
|
|
23384
|
+
}
|
|
23385
|
+
function isPointRange([point1, point2]) {
|
|
23386
|
+
if (point1.num !== point2.num) return false;
|
|
23387
|
+
if (point1.exclusive) return false;
|
|
23388
|
+
if (point2.exclusive) return false;
|
|
23389
|
+
return true;
|
|
23390
|
+
}
|
|
23391
|
+
function cutRange(range, multipleOf) {
|
|
23392
|
+
if (!range) return;
|
|
23393
|
+
const [originMin, originMax] = range;
|
|
23394
|
+
let min = nextInteger(originMin.num, multipleOf);
|
|
23395
|
+
let max = previousInteger(originMax.num, multipleOf);
|
|
23396
|
+
if (min === originMin.num && originMin.exclusive) min += multipleOf;
|
|
23397
|
+
if (max === originMax.num && originMax.exclusive) max -= multipleOf;
|
|
23398
|
+
if (min > max) return;
|
|
23399
|
+
if (min === max) {
|
|
23400
|
+
if (min === Number.POSITIVE_INFINITY) return;
|
|
23401
|
+
if (min === Number.NEGATIVE_INFINITY) return;
|
|
23402
|
+
}
|
|
23403
|
+
return [{
|
|
23404
|
+
num: min,
|
|
23405
|
+
exclusive: false
|
|
23406
|
+
}, {
|
|
23407
|
+
num: max,
|
|
23408
|
+
exclusive: false
|
|
23409
|
+
}];
|
|
23410
|
+
}
|
|
23411
|
+
function nextInteger(float, multipleOf) {
|
|
23412
|
+
return Math.ceil(float / multipleOf) * multipleOf;
|
|
23413
|
+
}
|
|
23414
|
+
function previousInteger(float, multipleOf) {
|
|
23415
|
+
return Math.floor(float / multipleOf) * multipleOf;
|
|
23416
|
+
}
|
|
23417
|
+
//#endregion
|
|
23418
|
+
//#region src/json-schema-subset/checker/numeric/float.ts
|
|
23419
|
+
function calculateFloat(schema1, schema2) {
|
|
23420
|
+
const { left, right, center } = splitRange$3(pickRange(schema1), pickRange(schema2));
|
|
23421
|
+
if (!center) return ExpressionRejection;
|
|
23422
|
+
let extraLeft = false;
|
|
23423
|
+
let extraRight = false;
|
|
23424
|
+
if (left) {
|
|
23425
|
+
if (left.fromLeft) extraLeft = true;
|
|
23426
|
+
else extraRight = true;
|
|
23427
|
+
}
|
|
23428
|
+
if (right) {
|
|
23429
|
+
if (right.fromLeft) extraLeft = true;
|
|
23430
|
+
else extraRight = true;
|
|
23431
|
+
}
|
|
23432
|
+
if (extraLeft && extraRight) return ExpressionIntersection;
|
|
23433
|
+
if (extraLeft) return ExpressionContaining;
|
|
23434
|
+
if (extraRight) return ExpressionContainedBy;
|
|
23435
|
+
return ExpressionEquals;
|
|
23436
|
+
}
|
|
23437
|
+
function calculateFloatAndInteger(schema1, schema2) {
|
|
23438
|
+
const floatRange = pickRange(schema1);
|
|
23439
|
+
const integer = normalizeInteger(schema2);
|
|
23440
|
+
if (!integer) return ExpressionContaining;
|
|
23441
|
+
const result = splitRange$3(floatRange, integer.range);
|
|
23442
|
+
const intCenter = cutRange(result.center, integer.multipleOf);
|
|
23443
|
+
const leftIntRange = unwrapAndCutRange(result.left, integer.multipleOf);
|
|
23444
|
+
const rightIntRange = unwrapAndCutRange(result.right, integer.multipleOf);
|
|
23445
|
+
if (!result.center) return ExpressionRejection;
|
|
23446
|
+
let extraFloat = false;
|
|
23447
|
+
let extraInteger = false;
|
|
23448
|
+
if (result.left?.fromLeft) extraFloat = true;
|
|
23449
|
+
if (result.right?.fromLeft) extraFloat = true;
|
|
23450
|
+
if (!intCenter || !isPointRange(result.center)) extraFloat = true;
|
|
23451
|
+
if (leftIntRange) extraInteger = true;
|
|
23452
|
+
if (rightIntRange) extraInteger = true;
|
|
23453
|
+
if (extraFloat && extraInteger) return ExpressionIntersection;
|
|
23454
|
+
if (extraFloat) return ExpressionContaining;
|
|
23455
|
+
if (extraInteger) return ExpressionContainedBy;
|
|
23456
|
+
return ExpressionEquals;
|
|
23457
|
+
}
|
|
23458
|
+
function pickRange(schema) {
|
|
23459
|
+
let point1;
|
|
23460
|
+
let point2;
|
|
23461
|
+
if (schema.exclusiveMinimum !== void 0) point1 = {
|
|
23462
|
+
num: schema.exclusiveMinimum,
|
|
23463
|
+
exclusive: true
|
|
23464
|
+
};
|
|
23465
|
+
else if (schema.minimum !== void 0) point1 = {
|
|
23466
|
+
num: schema.minimum,
|
|
23467
|
+
exclusive: false
|
|
23468
|
+
};
|
|
23469
|
+
else point1 = {
|
|
23470
|
+
num: Number.NEGATIVE_INFINITY,
|
|
23471
|
+
exclusive: true
|
|
23472
|
+
};
|
|
23473
|
+
if (schema.exclusiveMaximum !== void 0) point2 = {
|
|
23474
|
+
num: schema.exclusiveMaximum,
|
|
23475
|
+
exclusive: true
|
|
23476
|
+
};
|
|
23477
|
+
else if (schema.maximum !== void 0) point2 = {
|
|
23478
|
+
num: schema.maximum,
|
|
23479
|
+
exclusive: false
|
|
23480
|
+
};
|
|
23481
|
+
else point2 = {
|
|
23482
|
+
num: Number.POSITIVE_INFINITY,
|
|
23483
|
+
exclusive: true
|
|
23484
|
+
};
|
|
23485
|
+
return [point1, point2];
|
|
23486
|
+
}
|
|
23487
|
+
function unwrapAndCutRange(side, multipleOf) {
|
|
23488
|
+
if (!side) return;
|
|
23489
|
+
if (side.fromLeft) return;
|
|
23490
|
+
return cutRange(side.range, multipleOf);
|
|
23491
|
+
}
|
|
23492
|
+
//#endregion
|
|
23493
|
+
//#region src/json-schema-subset/checker/numeric/integer.ts
|
|
23494
|
+
function calculateInteger(schema1, schema2) {
|
|
23495
|
+
const integer1 = normalizeInteger(schema1);
|
|
23496
|
+
const integer2 = normalizeInteger(schema2);
|
|
23497
|
+
if (!integer1 && !integer2) return ExpressionEquals;
|
|
23498
|
+
if (!integer1) return ExpressionContainedBy;
|
|
23499
|
+
if (!integer2) return ExpressionContaining;
|
|
23500
|
+
const { range: range1, multipleOf: multipleOf1 } = integer1;
|
|
23501
|
+
const { range: range2, multipleOf: multipleOf2 } = integer2;
|
|
23502
|
+
const result = splitRange$3(range1, range2);
|
|
23503
|
+
let centerRange;
|
|
23504
|
+
let lcm = 0;
|
|
23505
|
+
if (result.center) {
|
|
23506
|
+
lcm = getLCM(multipleOf1, multipleOf2);
|
|
23507
|
+
centerRange = cutRange(result.center, lcm);
|
|
23508
|
+
}
|
|
23509
|
+
if (!centerRange) return ExpressionRejection;
|
|
23510
|
+
let extraLeft = false;
|
|
23511
|
+
let extraRight = false;
|
|
23512
|
+
const { left, right } = result;
|
|
23513
|
+
if (left && cutRange(left.range, left.fromLeft ? multipleOf1 : multipleOf2)) {
|
|
23514
|
+
if (left.fromLeft) extraLeft = true;
|
|
23515
|
+
else extraRight = true;
|
|
23516
|
+
}
|
|
23517
|
+
if (right && cutRange(right.range, right.fromLeft ? multipleOf1 : multipleOf2)) {
|
|
23518
|
+
if (right.fromLeft) extraLeft = true;
|
|
23519
|
+
else extraRight = true;
|
|
23520
|
+
}
|
|
23521
|
+
extraLeft = extraLeft || hasExtraIntegersOnCenter(integer1, centerRange, lcm);
|
|
23522
|
+
extraRight = extraRight || hasExtraIntegersOnCenter(integer2, centerRange, lcm);
|
|
23523
|
+
if (extraLeft && extraRight) return ExpressionIntersection;
|
|
23524
|
+
if (extraLeft) return ExpressionContaining;
|
|
23525
|
+
if (extraRight) return ExpressionContainedBy;
|
|
23526
|
+
return ExpressionEquals;
|
|
23527
|
+
}
|
|
23528
|
+
function hasExtraIntegersOnCenter({ range, multipleOf }, lcmCenterRange, lcm) {
|
|
23529
|
+
const result = splitRange$3(range, lcmCenterRange);
|
|
23530
|
+
if (cutRange(result.left?.range, multipleOf)) return true;
|
|
23531
|
+
if (cutRange(result.right?.range, multipleOf)) return true;
|
|
23532
|
+
const center = cutRange(result.center, multipleOf);
|
|
23533
|
+
if (!center) return false;
|
|
23534
|
+
const lcmCenterLength = rangeLength(lcmCenterRange);
|
|
23535
|
+
if (rangeLength(center) > lcmCenterLength) return true;
|
|
23536
|
+
if (lcmCenterLength === 1) return false;
|
|
23537
|
+
if (multipleOf < lcm) return true;
|
|
23538
|
+
return false;
|
|
23539
|
+
}
|
|
23540
|
+
/** Returns the least common multiple. */
|
|
23541
|
+
function getLCM(a, b) {
|
|
23542
|
+
return a * b / getGCD(a, b);
|
|
23543
|
+
}
|
|
23544
|
+
/** @returns The greatest common divisor. */
|
|
23545
|
+
function getGCD(a, b) {
|
|
23546
|
+
if (a === 0) return b;
|
|
23547
|
+
return getGCD(b % a, a);
|
|
23548
|
+
}
|
|
23549
|
+
function rangeLength(range) {
|
|
23550
|
+
if (!range) return 0;
|
|
23551
|
+
const [point1, point2] = range;
|
|
23552
|
+
return point2.num - point1.num + 1;
|
|
23553
|
+
}
|
|
23554
|
+
//#endregion
|
|
23555
|
+
//#region src/json-schema-subset/checker/numeric/checker.ts
|
|
23556
|
+
function calculateNumeric(schema1, schema2) {
|
|
23557
|
+
if (isUndefinedNumber(schema1) || isUndefinedNumber(schema2)) return ExpressionAny;
|
|
23558
|
+
const isFloat1 = isFloat(schema1);
|
|
23559
|
+
const isFloat2 = isFloat(schema2);
|
|
23560
|
+
if (isFloat1 && isFloat2) return calculateFloat(schema1, schema2);
|
|
23561
|
+
else if (isFloat1) return calculateFloatAndInteger(schema1, schema2);
|
|
23562
|
+
else if (isFloat2) return swap(calculateFloatAndInteger(schema2, schema1));
|
|
23563
|
+
else return calculateInteger(schema1, schema2);
|
|
23564
|
+
}
|
|
23565
|
+
function isUndefinedNumber(schema) {
|
|
23566
|
+
const { multipleOf } = schema;
|
|
23567
|
+
if (multipleOf === void 0) return false;
|
|
23568
|
+
if (!Number.isInteger(multipleOf)) return true;
|
|
23569
|
+
if (multipleOf < 0) return true;
|
|
23570
|
+
return false;
|
|
23571
|
+
}
|
|
23572
|
+
function isFloat(schema) {
|
|
23573
|
+
const { multipleOf } = schema;
|
|
23574
|
+
if (multipleOf !== void 0 && Number.isInteger(multipleOf)) return false;
|
|
23575
|
+
if (schema.type === "integer") return false;
|
|
23576
|
+
return true;
|
|
23577
|
+
}
|
|
23578
|
+
//#endregion
|
|
23579
|
+
//#region src/json-schema-subset/checker/object.ts
|
|
23580
|
+
var splitRange$1 = createRangeSplitter(0);
|
|
23581
|
+
var quantum = makeQuantum([
|
|
23582
|
+
"hasCommonInRequired",
|
|
23583
|
+
"hasCommonOutRequired",
|
|
23584
|
+
"hasExtra1",
|
|
23585
|
+
"hasExtra2",
|
|
23586
|
+
"hasRejection"
|
|
23587
|
+
]);
|
|
23588
|
+
function calculateObject(context, schema1, schema2) {
|
|
23589
|
+
if (isPropertiesCountCannotMatch(schema1, schema2)) return ExpressionRejection;
|
|
23590
|
+
const splitRequiredResult = splitRequired(schema1, schema2);
|
|
23591
|
+
if (!splitRequiredResult) return ExpressionRejection;
|
|
23592
|
+
const getProperty1 = createPropertySchemaGetter(schema1);
|
|
23593
|
+
const getProperty2 = createPropertySchemaGetter(schema2);
|
|
23594
|
+
const calculateKey = (key) => {
|
|
23595
|
+
const propertySchema1 = getProperty1(key);
|
|
23596
|
+
const propertySchema2 = getProperty2(key);
|
|
23597
|
+
if (areNotBothNever(propertySchema1, propertySchema2)) return context.calculate(propertySchema1, propertySchema2);
|
|
23598
|
+
else return 0;
|
|
23599
|
+
};
|
|
23600
|
+
const { commonRequired, extraRequired1, extraRequired2 } = splitRequiredResult;
|
|
23601
|
+
const quantumVariable = quantum.variable({});
|
|
23602
|
+
for (const requiredKey of [...commonRequired].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateCommonRequiredExpression);
|
|
23603
|
+
for (const requiredKey of [...extraRequired1].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateExtraRequiredExpression1);
|
|
23604
|
+
for (const requiredKey of [...extraRequired2].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateExtraRequiredExpression2);
|
|
23605
|
+
const { hasOptional1, hasOptional2 } = splitRequiredResult;
|
|
23606
|
+
if (hasOptional1 || hasOptional2) {
|
|
23607
|
+
const calculator = calculateOptionalExpression(hasOptional1, hasOptional2);
|
|
23608
|
+
for (const optionalKey of [...getOptionalKeys(schema1, schema2)].toSorted()) {
|
|
23609
|
+
const expression = calculateKey(optionalKey);
|
|
23610
|
+
if (expression !== 0) quantumVariable.push(expression, calculator);
|
|
23611
|
+
}
|
|
23612
|
+
const additionalProperties1 = schema1.additionalProperties ?? ANY;
|
|
23613
|
+
const additionalProperties2 = schema2.additionalProperties ?? ANY;
|
|
23614
|
+
if (areNotBothNever(additionalProperties1, additionalProperties2)) {
|
|
23615
|
+
const expression = context.calculate(additionalProperties1, additionalProperties2);
|
|
23616
|
+
quantumVariable.push(expression, calculator);
|
|
23617
|
+
}
|
|
23618
|
+
}
|
|
23619
|
+
quantumVariable.update((variable) => {
|
|
23620
|
+
if (!variable.hasRejection) {
|
|
23621
|
+
if (extraRequired1.size > 0) variable.hasExtra2 = true;
|
|
23622
|
+
if (extraRequired2.size > 0) variable.hasExtra1 = true;
|
|
23623
|
+
}
|
|
23624
|
+
});
|
|
23625
|
+
const { requiredKeysCount } = splitRequiredResult;
|
|
23626
|
+
let expression = 0;
|
|
23627
|
+
for (const { hasExtra1, hasExtra2, hasCommonInRequired, hasCommonOutRequired, hasRejection } of quantumVariable) if (!hasCommonInRequired && requiredKeysCount > 0) expression |= ExpressionRejection;
|
|
23628
|
+
else if (!hasCommonOutRequired && requiredKeysCount === 0) expression |= ExpressionRejection;
|
|
23629
|
+
else if (hasRejection) expression |= ExpressionRejection;
|
|
23630
|
+
else if (hasExtra1 && hasExtra2) expression |= ExpressionIntersection;
|
|
23631
|
+
else if (hasExtra1) expression |= ExpressionContaining;
|
|
23632
|
+
else if (hasExtra2) expression |= ExpressionContainedBy;
|
|
23633
|
+
else expression |= ExpressionEquals;
|
|
23634
|
+
return expression;
|
|
23635
|
+
}
|
|
23636
|
+
function isPropertiesCountCannotMatch(schema1, schema2) {
|
|
23637
|
+
return toExpressionSingleResult(splitRange$1(schema1.minProperties, schema1.maxProperties, schema2.minProperties, schema2.maxProperties)) === ExpressionSingleResult.Rejection;
|
|
23638
|
+
}
|
|
23639
|
+
function splitRequired(schema1, schema2) {
|
|
23640
|
+
const extraRequired1 = new Set(schema1.required);
|
|
23641
|
+
const extraRequired2 = new Set(schema2.required);
|
|
23642
|
+
const commonRequired = /* @__PURE__ */ new Set();
|
|
23643
|
+
const wholeRequired = /* @__PURE__ */ new Set();
|
|
23644
|
+
const requiredCount1 = extraRequired1.size;
|
|
23645
|
+
const requiredCount2 = extraRequired2.size;
|
|
23646
|
+
for (const key of extraRequired1) {
|
|
23647
|
+
if (extraRequired2.has(key)) commonRequired.add(key);
|
|
23648
|
+
wholeRequired.add(key);
|
|
23649
|
+
}
|
|
23650
|
+
for (const key of extraRequired2) {
|
|
23651
|
+
if (extraRequired1.has(key)) commonRequired.add(key);
|
|
23652
|
+
wholeRequired.add(key);
|
|
23653
|
+
}
|
|
23654
|
+
const requiredKeysCount = wholeRequired.size;
|
|
23655
|
+
for (const key of commonRequired) {
|
|
23656
|
+
extraRequired1.delete(key);
|
|
23657
|
+
extraRequired2.delete(key);
|
|
23658
|
+
}
|
|
23659
|
+
const maxProperties1 = schema1.maxProperties ?? Number.MAX_SAFE_INTEGER;
|
|
23660
|
+
const maxProperties2 = schema2.maxProperties ?? Number.MAX_SAFE_INTEGER;
|
|
23661
|
+
if (requiredKeysCount > maxProperties1 || requiredKeysCount > maxProperties2) return null;
|
|
23662
|
+
return {
|
|
23663
|
+
requiredKeysCount,
|
|
23664
|
+
extraRequired1,
|
|
23665
|
+
extraRequired2,
|
|
23666
|
+
commonRequired,
|
|
23667
|
+
hasOptional1: maxProperties1 > requiredCount1,
|
|
23668
|
+
hasOptional2: maxProperties2 > requiredCount2
|
|
23669
|
+
};
|
|
23670
|
+
}
|
|
23671
|
+
function getOptionalKeys(schema1, schema2) {
|
|
23672
|
+
const optionalKeys = new Set(schema1.required);
|
|
23673
|
+
const properties1 = schema1.properties;
|
|
23674
|
+
const properties2 = schema2.properties;
|
|
23675
|
+
const required1 = schema1.required;
|
|
23676
|
+
const required2 = schema2.required;
|
|
23677
|
+
if (properties1) for (const key in properties1) optionalKeys.add(key);
|
|
23678
|
+
if (properties2) for (const key in properties2) optionalKeys.add(key);
|
|
23679
|
+
if (required1) for (const key of required1) optionalKeys.delete(key);
|
|
23680
|
+
if (required2) for (const key of required2) optionalKeys.delete(key);
|
|
23681
|
+
return optionalKeys;
|
|
23682
|
+
}
|
|
23683
|
+
var calculateCommonRequiredExpression = (singleExpression, variable) => {
|
|
23684
|
+
switch (singleExpression) {
|
|
23685
|
+
case ExpressionSingleResult.Equals:
|
|
23686
|
+
variable.hasCommonInRequired = true;
|
|
23687
|
+
break;
|
|
23688
|
+
case ExpressionSingleResult.Containing:
|
|
23689
|
+
variable.hasExtra1 = true;
|
|
23690
|
+
variable.hasCommonInRequired = true;
|
|
23691
|
+
break;
|
|
23692
|
+
case ExpressionSingleResult.ContainedBy:
|
|
23693
|
+
variable.hasExtra2 = true;
|
|
23694
|
+
variable.hasCommonInRequired = true;
|
|
23695
|
+
break;
|
|
23696
|
+
case ExpressionSingleResult.Intersection:
|
|
23697
|
+
variable.hasExtra1 = true;
|
|
23698
|
+
variable.hasExtra2 = true;
|
|
23699
|
+
variable.hasCommonInRequired = true;
|
|
23700
|
+
break;
|
|
23701
|
+
case ExpressionSingleResult.Rejection: variable.hasRejection = true;
|
|
23702
|
+
}
|
|
23703
|
+
};
|
|
23704
|
+
var calculateExtraRequiredExpression1 = (singleExpression, variable) => {
|
|
23705
|
+
switch (singleExpression) {
|
|
23706
|
+
case ExpressionSingleResult.Equals:
|
|
23707
|
+
case ExpressionSingleResult.ContainedBy:
|
|
23708
|
+
variable.hasCommonInRequired = true;
|
|
23709
|
+
break;
|
|
23710
|
+
case ExpressionSingleResult.Intersection:
|
|
23711
|
+
case ExpressionSingleResult.Containing:
|
|
23712
|
+
variable.hasExtra1 = true;
|
|
23713
|
+
variable.hasCommonInRequired = true;
|
|
23714
|
+
break;
|
|
23715
|
+
case ExpressionSingleResult.Rejection: variable.hasRejection = true;
|
|
23716
|
+
}
|
|
23717
|
+
};
|
|
23718
|
+
var calculateExtraRequiredExpression2 = (singleExpression, variable) => {
|
|
23719
|
+
switch (singleExpression) {
|
|
23720
|
+
case ExpressionSingleResult.Equals:
|
|
23721
|
+
case ExpressionSingleResult.Containing:
|
|
23722
|
+
variable.hasCommonInRequired = true;
|
|
23723
|
+
break;
|
|
23724
|
+
case ExpressionSingleResult.Intersection:
|
|
23725
|
+
case ExpressionSingleResult.ContainedBy:
|
|
23726
|
+
variable.hasExtra2 = true;
|
|
23727
|
+
variable.hasCommonInRequired = true;
|
|
23728
|
+
break;
|
|
23729
|
+
case ExpressionSingleResult.Rejection: variable.hasRejection = true;
|
|
23730
|
+
}
|
|
23731
|
+
};
|
|
23732
|
+
var calculateOptionalExpression = (hasOptional1, hasOptional2) => (singleExpression, variable) => {
|
|
23733
|
+
if (variable.hasRejection) return;
|
|
23734
|
+
let foundExtraPossibility1 = false;
|
|
23735
|
+
let foundExtraPossibility2 = false;
|
|
23736
|
+
let foundCommonPossibility = false;
|
|
23737
|
+
switch (singleExpression) {
|
|
23738
|
+
case ExpressionSingleResult.Equals:
|
|
23739
|
+
foundCommonPossibility = true;
|
|
23740
|
+
break;
|
|
23741
|
+
case ExpressionSingleResult.Containing:
|
|
23742
|
+
foundExtraPossibility1 = true;
|
|
23743
|
+
foundCommonPossibility = true;
|
|
23744
|
+
break;
|
|
23745
|
+
case ExpressionSingleResult.ContainedBy:
|
|
23746
|
+
foundExtraPossibility2 = true;
|
|
23747
|
+
foundCommonPossibility = true;
|
|
23748
|
+
break;
|
|
23749
|
+
case ExpressionSingleResult.Intersection:
|
|
23750
|
+
foundExtraPossibility1 = true;
|
|
23751
|
+
foundExtraPossibility2 = true;
|
|
23752
|
+
foundCommonPossibility = true;
|
|
23753
|
+
break;
|
|
23754
|
+
case ExpressionSingleResult.Rejection:
|
|
23755
|
+
foundExtraPossibility1 = true;
|
|
23756
|
+
foundExtraPossibility2 = true;
|
|
23757
|
+
}
|
|
23758
|
+
if (hasOptional1 && foundExtraPossibility1) variable.hasExtra1 = true;
|
|
23759
|
+
if (hasOptional2 && foundExtraPossibility2) variable.hasExtra2 = true;
|
|
23760
|
+
if (hasOptional1 && hasOptional2 && foundCommonPossibility) variable.hasCommonOutRequired = true;
|
|
23761
|
+
};
|
|
23762
|
+
function createPropertySchemaGetter(schema) {
|
|
23763
|
+
const properties = schema.properties;
|
|
23764
|
+
const propertyNames = schema.propertyNames;
|
|
23765
|
+
const additionalProperties = schema.additionalProperties;
|
|
23766
|
+
const patternProperties = [];
|
|
23767
|
+
if (schema.patternProperties) for (const pattern in schema.patternProperties) {
|
|
23768
|
+
const valueSchema = schema.patternProperties[pattern];
|
|
23769
|
+
const regExp = new RegExp(pattern, "i");
|
|
23770
|
+
patternProperties.push({
|
|
23771
|
+
pattern: regExp,
|
|
23772
|
+
schema: valueSchema
|
|
23773
|
+
});
|
|
23774
|
+
}
|
|
23775
|
+
return (key) => {
|
|
23776
|
+
if (propertyNames && valid(propertyNames, key) === ValidResult.Invalid) return NEVER;
|
|
23777
|
+
for (const { pattern, schema: patternSchema } of patternProperties) if (pattern.test(key)) return patternSchema;
|
|
23778
|
+
const propertySchema = (properties && properties[key]) ?? additionalProperties;
|
|
23779
|
+
if (!propertySchema) return ANY;
|
|
23780
|
+
return propertySchema;
|
|
23781
|
+
};
|
|
23782
|
+
}
|
|
23783
|
+
function areNotBothNever(schema1, schema2) {
|
|
23784
|
+
const kind1 = getKind(schema1);
|
|
23785
|
+
const kind2 = getKind(schema2);
|
|
23786
|
+
return kind1 !== CompiledKind.Never || kind2 !== CompiledKind.Never;
|
|
23787
|
+
}
|
|
23788
|
+
//#endregion
|
|
23789
|
+
//#region src/json-schema-subset/checker/string.ts
|
|
23790
|
+
var splitRange = createRangeSplitter(0);
|
|
23791
|
+
function calculateString(schema1, schema2) {
|
|
23792
|
+
if (schema2.format && !schema1.format) return ExpressionContaining;
|
|
23793
|
+
if (schema1.format && schema2.format && schema1.format !== schema2.format) return ExpressionAny;
|
|
23794
|
+
const expression = toExpressionSingleResult(splitRange(schema1.minLength, schema1.maxLength, schema2.minLength, schema2.maxLength));
|
|
23795
|
+
const hasPattern1 = !!schema1.pattern;
|
|
23796
|
+
const hasPattern2 = !!schema2.pattern;
|
|
23797
|
+
switch (expression) {
|
|
23798
|
+
case ExpressionSingleResult.Rejection: return ExpressionRejection;
|
|
23799
|
+
case ExpressionSingleResult.Containing: return hasPattern1 ? ExpressionAny : ExpressionContaining;
|
|
23800
|
+
case ExpressionSingleResult.ContainedBy: return hasPattern2 ? ExpressionAny : ExpressionContainedBy;
|
|
23801
|
+
case ExpressionSingleResult.Equals:
|
|
23802
|
+
if (hasPattern1 && hasPattern2) return schema1.pattern === schema2.pattern ? ExpressionEquals : ExpressionAny;
|
|
23803
|
+
if (hasPattern1) return ExpressionEquals | ExpressionContainedBy;
|
|
23804
|
+
if (hasPattern2) return ExpressionEquals | ExpressionContaining;
|
|
23805
|
+
return ExpressionEquals;
|
|
23806
|
+
case ExpressionSingleResult.Intersection:
|
|
23807
|
+
if (hasPattern1 && hasPattern2) return ExpressionAny;
|
|
23808
|
+
if (hasPattern1) return ExpressionIntersection | ExpressionRejection | ExpressionContainedBy;
|
|
23809
|
+
if (hasPattern2) return ExpressionIntersection | ExpressionRejection | ExpressionContaining;
|
|
23810
|
+
return ExpressionIntersection;
|
|
23811
|
+
}
|
|
23812
|
+
}
|
|
23813
|
+
//#endregion
|
|
23814
|
+
//#region src/json-schema-subset/checker/checker.ts
|
|
23815
|
+
function checkWithResult(extendsContext, schema1, schema2) {
|
|
23816
|
+
const context = {};
|
|
23817
|
+
const errorPaths = [];
|
|
23818
|
+
const calculate = wrapSchemaCalculatorWithCache(calculator(extendsContext, context));
|
|
23819
|
+
const describe = describer();
|
|
23820
|
+
const equals = schemaEqualsChecker(extendsContext);
|
|
23821
|
+
context.isEquals = wrapEqualsCheckerWithCache(isDeepEquals);
|
|
23822
|
+
context.calculate = expression({
|
|
23823
|
+
describe,
|
|
23824
|
+
equals,
|
|
23825
|
+
calculate,
|
|
23826
|
+
observeCalculation: (left, right, result, swapped) => {
|
|
23827
|
+
if (!isDecisiveMismatch(swapped ? swap(result) : result)) return;
|
|
23828
|
+
const errorPath = swapped ? findMismatchPath(right, left) : findMismatchPath(left, right);
|
|
23829
|
+
if (errorPath) errorPaths.push(errorPath);
|
|
23830
|
+
}
|
|
23831
|
+
});
|
|
23832
|
+
Object.freeze(context);
|
|
23833
|
+
const comparisonExpression = context.calculate(schema1, schema2);
|
|
23834
|
+
return {
|
|
23835
|
+
errorPath: errorPaths[0],
|
|
23836
|
+
expression: comparisonExpression
|
|
23837
|
+
};
|
|
23838
|
+
}
|
|
23839
|
+
var describer = () => (schema) => {
|
|
23840
|
+
let description;
|
|
23841
|
+
switch (getKind(schema)) {
|
|
23842
|
+
case CompiledKind.Not:
|
|
23843
|
+
description = {
|
|
23844
|
+
kind: ExpressionKind.Not,
|
|
23845
|
+
expression: schema.not
|
|
23846
|
+
};
|
|
23847
|
+
break;
|
|
23848
|
+
case CompiledKind.Combination:
|
|
23849
|
+
if ("allOf" in schema) description = {
|
|
23850
|
+
kind: ExpressionKind.AllOf,
|
|
23851
|
+
expressions: rejectInSchemaList(schema.allOf, CompiledKind.Any)
|
|
23852
|
+
};
|
|
23853
|
+
else if ("anyOf" in schema) description = {
|
|
23854
|
+
kind: ExpressionKind.AnyOf,
|
|
23855
|
+
expressions: rejectInSchemaList(schema.anyOf, CompiledKind.Never)
|
|
23856
|
+
};
|
|
23857
|
+
else if ("oneOf" in schema) description = {
|
|
23858
|
+
kind: ExpressionKind.OneOf,
|
|
23859
|
+
expressions: rejectInSchemaList(schema.oneOf, CompiledKind.Never)
|
|
23860
|
+
};
|
|
23861
|
+
else throw new Error(`invalid combination JSON Schema: ${JSON.stringify(schema)}`);
|
|
23862
|
+
break;
|
|
23863
|
+
default: description = { kind: ExpressionKind.Leaf };
|
|
23864
|
+
}
|
|
23865
|
+
return description;
|
|
23866
|
+
};
|
|
23867
|
+
var calculator = (extendsContext, context) => (schema1, schema2) => {
|
|
23868
|
+
const kind1 = getKind(schema1);
|
|
23869
|
+
const kind2 = getKind(schema2);
|
|
23870
|
+
if (kind1 === CompiledKind.Extends || kind2 === CompiledKind.Extends) return extendsContext.calculate(schema1, schema2);
|
|
23871
|
+
switch (kind1) {
|
|
23872
|
+
case CompiledKind.Any: return kind2 === CompiledKind.Any ? ExpressionEquals : ExpressionContaining;
|
|
23873
|
+
case CompiledKind.Never: return kind2 === CompiledKind.Never ? ExpressionEquals : ExpressionContainedBy;
|
|
23874
|
+
}
|
|
23875
|
+
switch (kind2) {
|
|
23876
|
+
case CompiledKind.Any: return ExpressionContainedBy;
|
|
23877
|
+
case CompiledKind.Never: return ExpressionContaining;
|
|
23878
|
+
}
|
|
23879
|
+
if (kind1 === CompiledKind.EnumOrConst && kind2 === CompiledKind.EnumOrConst) return calculateEnumAndEnum(context, schema1, schema2);
|
|
23880
|
+
if (kind1 === CompiledKind.EnumOrConst) return calculateEnumAndSchema(schema1, schema2);
|
|
23881
|
+
if (kind2 === CompiledKind.EnumOrConst) return swap(calculateEnumAndSchema(schema2, schema1));
|
|
23882
|
+
if (kind1 !== kind2) return ExpressionRejection;
|
|
23883
|
+
switch (kind1) {
|
|
23884
|
+
case CompiledKind.Null: return ExpressionEquals;
|
|
23885
|
+
case CompiledKind.Numeric: return calculateNumeric(schema1, schema2);
|
|
23886
|
+
case CompiledKind.String: return calculateString(schema1, schema2);
|
|
23887
|
+
case CompiledKind.Boolean: return ExpressionEquals;
|
|
23888
|
+
case CompiledKind.Object: return calculateObject(context, schema1, schema2);
|
|
23889
|
+
case CompiledKind.Array: return calculateArray(context, schema1, schema2);
|
|
23890
|
+
default: throw new Error(`invalid kind ${kind1}`);
|
|
23891
|
+
}
|
|
23892
|
+
};
|
|
23893
|
+
function rejectInSchemaList(schemaList, kind) {
|
|
23894
|
+
return schemaList.filter((e) => getKind(e) !== kind);
|
|
23895
|
+
}
|
|
23896
|
+
function isDecisiveMismatch(result) {
|
|
23897
|
+
return !hasEquals(result) && !hasContainedBy(result) && (hasContaining(result) || hasIntersection(result) || hasRejection(result));
|
|
23898
|
+
}
|
|
23899
|
+
function findMismatchPath(source, target) {
|
|
23900
|
+
const targetPath = getPath(target);
|
|
23901
|
+
if (!targetPath) return void 0;
|
|
23902
|
+
const sourceKind = getKind(source);
|
|
23903
|
+
const targetKind = getKind(target);
|
|
23904
|
+
if (sourceKind !== targetKind) return [...targetPath, "type"];
|
|
23905
|
+
const sourceSchema = source;
|
|
23906
|
+
const targetSchema = target;
|
|
23907
|
+
switch (targetKind) {
|
|
23908
|
+
case CompiledKind.String:
|
|
23909
|
+
if ((sourceSchema.minLength ?? 0) < (targetSchema.minLength ?? 0)) return [...targetPath, "minLength"];
|
|
23910
|
+
if ((sourceSchema.maxLength ?? Number.POSITIVE_INFINITY) > (targetSchema.maxLength ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxLength"];
|
|
23911
|
+
if (sourceSchema.pattern !== targetSchema.pattern && targetSchema.pattern) return [...targetPath, "pattern"];
|
|
23912
|
+
if (sourceSchema.format !== targetSchema.format && targetSchema.format) return [...targetPath, "format"];
|
|
23913
|
+
break;
|
|
23914
|
+
case CompiledKind.Numeric:
|
|
23915
|
+
if ((sourceSchema.minimum ?? sourceSchema.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) < (targetSchema.minimum ?? targetSchema.exclusiveMinimum ?? Number.NEGATIVE_INFINITY)) return [...targetPath, targetSchema.exclusiveMinimum == null ? "minimum" : "exclusiveMinimum"];
|
|
23916
|
+
if ((sourceSchema.maximum ?? sourceSchema.exclusiveMaximum ?? Number.POSITIVE_INFINITY) > (targetSchema.maximum ?? targetSchema.exclusiveMaximum ?? Number.POSITIVE_INFINITY)) return [...targetPath, targetSchema.exclusiveMaximum == null ? "maximum" : "exclusiveMaximum"];
|
|
23917
|
+
if (sourceSchema.multipleOf !== targetSchema.multipleOf && targetSchema.multipleOf != null) return [...targetPath, "multipleOf"];
|
|
23918
|
+
break;
|
|
23919
|
+
case CompiledKind.Array:
|
|
23920
|
+
if ((sourceSchema.minItems ?? 0) < (targetSchema.minItems ?? 0)) return [...targetPath, "minItems"];
|
|
23921
|
+
if ((sourceSchema.maxItems ?? Number.POSITIVE_INFINITY) > (targetSchema.maxItems ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxItems"];
|
|
23922
|
+
if (!sourceSchema.uniqueItems && targetSchema.uniqueItems) return [...targetPath, "uniqueItems"];
|
|
23923
|
+
break;
|
|
23924
|
+
case CompiledKind.Object: {
|
|
23925
|
+
const sourceRequired = new Set(sourceSchema.required ?? []);
|
|
23926
|
+
if ((targetSchema.required ?? []).some((key) => !sourceRequired.has(key))) return [...targetPath, "required"];
|
|
23927
|
+
if ((sourceSchema.minProperties ?? 0) < (targetSchema.minProperties ?? 0)) return [...targetPath, "minProperties"];
|
|
23928
|
+
if ((sourceSchema.maxProperties ?? Number.POSITIVE_INFINITY) > (targetSchema.maxProperties ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxProperties"];
|
|
23929
|
+
break;
|
|
23930
|
+
}
|
|
23931
|
+
case CompiledKind.EnumOrConst: return [...targetPath, targetSchema.const == null ? "enum" : "const"];
|
|
23932
|
+
}
|
|
23933
|
+
return targetPath;
|
|
23934
|
+
}
|
|
23935
|
+
//#endregion
|
|
23936
|
+
//#region src/json-schema-subset/extends/extendsContext.ts
|
|
23937
|
+
var ExtendsContext = class ExtendsContext {
|
|
23938
|
+
constructor(extendsSchemaClasses = []) {
|
|
23939
|
+
this.extendsSchemaClasses = Object.freeze([...extendsSchemaClasses]);
|
|
23940
|
+
}
|
|
23941
|
+
tryCompiledExtendsSchema(target, payload) {
|
|
23942
|
+
for (const extendsSchemaClass of this.extendsSchemaClasses) if (extendsSchemaClass.isMatch(target)) return new extendsSchemaClass(createId(), target, payload);
|
|
23943
|
+
return null;
|
|
23944
|
+
}
|
|
23945
|
+
isExtendsSchema(target) {
|
|
23946
|
+
for (const extendsSchemaClass of this.extendsSchemaClasses) if (target instanceof extendsSchemaClass) return true;
|
|
23947
|
+
return false;
|
|
23948
|
+
}
|
|
23949
|
+
calculate(schema1, schema2) {
|
|
23950
|
+
const shouldSwap = !(schema1 instanceof this.findMatchedClass(schema1, schema2));
|
|
23951
|
+
let expressionResult = 0;
|
|
23952
|
+
let result;
|
|
23953
|
+
if (shouldSwap) result = schema2.compare(schema1);
|
|
23954
|
+
else result = schema1.compare(schema2);
|
|
23955
|
+
for (let expression of result) {
|
|
23956
|
+
if (shouldSwap) expression = ExtendsContext.swap(expression);
|
|
23957
|
+
expressionResult |= toExpression(expression);
|
|
23958
|
+
}
|
|
23959
|
+
return expressionResult;
|
|
23960
|
+
}
|
|
23961
|
+
equals(schema1, schema2) {
|
|
23962
|
+
if (!(schema1 instanceof this.findMatchedClass(schema1, schema2))) return schema2.equals(schema1);
|
|
23963
|
+
else return schema1.equals(schema2);
|
|
23964
|
+
}
|
|
23965
|
+
findMatchedClass(schema1, schema2) {
|
|
23966
|
+
for (const schemaClass of this.extendsSchemaClasses) {
|
|
23967
|
+
if (schema1 instanceof schemaClass) return schemaClass;
|
|
23968
|
+
if (schema2 instanceof schemaClass) return schemaClass;
|
|
23969
|
+
}
|
|
23970
|
+
throw new Error("Invalid schema");
|
|
23971
|
+
}
|
|
23972
|
+
static swap(expression) {
|
|
23973
|
+
switch (expression) {
|
|
23974
|
+
case ExpressionSingleResult.Containing: return ExpressionSingleResult.ContainedBy;
|
|
23975
|
+
case ExpressionSingleResult.ContainedBy: return ExpressionSingleResult.Containing;
|
|
23976
|
+
default: return expression;
|
|
23977
|
+
}
|
|
23978
|
+
}
|
|
23979
|
+
};
|
|
23980
|
+
//#endregion
|
|
23981
|
+
//#region src/json-schema-subset/preprocessing.ts
|
|
23982
|
+
function preprocessSchema(schema, compile, printWarnLog = false) {
|
|
23983
|
+
const schemaResult = compile(schema);
|
|
23984
|
+
if (Array.isArray(schemaResult)) {
|
|
23985
|
+
const errorItems = [];
|
|
23986
|
+
collectWithPathPrefix(errorItems, schemaResult, "$");
|
|
23987
|
+
throw new SchemaError(errorItems);
|
|
23988
|
+
}
|
|
23989
|
+
const { schema: compiledSchema, warns } = schemaResult;
|
|
23990
|
+
if (printWarnLog && warns.length > 0) {
|
|
23991
|
+
console.warn(`found ${warns.length} warns after compile schema`);
|
|
23992
|
+
for (const warn of warns) console.warn(stringifySchemaError(warn));
|
|
23993
|
+
}
|
|
23994
|
+
return compiledSchema;
|
|
23995
|
+
}
|
|
23996
|
+
function preprocessSchemasPair(schema1, schema2, compile, printWarnLog = false) {
|
|
23997
|
+
const schemaResult1 = compile(schema1);
|
|
23998
|
+
const schemaResult2 = compile(schema2);
|
|
23999
|
+
if (Array.isArray(schemaResult1) || Array.isArray(schemaResult2)) {
|
|
24000
|
+
const errorItems = [];
|
|
24001
|
+
if (Array.isArray(schemaResult1)) collectWithPathPrefix(errorItems, schemaResult1, "$1");
|
|
24002
|
+
if (Array.isArray(schemaResult2)) collectWithPathPrefix(errorItems, schemaResult2, "$2");
|
|
24003
|
+
throw new SchemaError(errorItems);
|
|
24004
|
+
}
|
|
24005
|
+
const { schema: compiledSchema1, warns: superWarns } = schemaResult1;
|
|
24006
|
+
const { schema: compiledSchema2, warns: subWarns } = schemaResult2;
|
|
24007
|
+
if (printWarnLog) {
|
|
24008
|
+
if (superWarns.length > 0) console.warn(`found ${superWarns.length} warns after compile superSchema`);
|
|
24009
|
+
for (const warn of superWarns) console.warn(stringifySchemaError(warn));
|
|
24010
|
+
if (subWarns.length > 0) console.warn(`found ${subWarns.length} warns after compile subSchema`);
|
|
24011
|
+
for (const warn of subWarns) console.warn(stringifySchemaError(warn));
|
|
24012
|
+
}
|
|
24013
|
+
return [compiledSchema1, compiledSchema2];
|
|
24014
|
+
}
|
|
24015
|
+
function collectWithPathPrefix(errorItems, compiledItems, prefix) {
|
|
24016
|
+
for (const compiledItem of compiledItems) {
|
|
24017
|
+
const replacedItem = {
|
|
24018
|
+
...compiledItem,
|
|
24019
|
+
path: [prefix, ...compiledItem.path]
|
|
24020
|
+
};
|
|
24021
|
+
errorItems.push(replacedItem);
|
|
24022
|
+
}
|
|
24023
|
+
}
|
|
24024
|
+
//#endregion
|
|
24025
|
+
//#region src/json-schema-subset/global.ts
|
|
24026
|
+
var SubsetCompareResult = Object.freeze({
|
|
24027
|
+
True: 0,
|
|
24028
|
+
False: 1,
|
|
24029
|
+
Unknown: 2
|
|
24030
|
+
});
|
|
24031
|
+
function makeSubsetCompare({ extendsSchemaClasses, delegate } = {}) {
|
|
24032
|
+
const extendsContext = new ExtendsContext(extendsSchemaClasses);
|
|
24033
|
+
return Object.freeze({
|
|
24034
|
+
compile: (schema, payload, printWarnLog) => {
|
|
24035
|
+
const compiler = (candidate) => compile(candidate, extendsContext, payload, delegate);
|
|
24036
|
+
return preprocessSchema(schema, compiler, printWarnLog);
|
|
24037
|
+
},
|
|
24038
|
+
isSubset: (superSchema, subSchema, printWarnLog = false) => {
|
|
24039
|
+
const compiler = (candidate) => compile(candidate, extendsContext, void 0, delegate);
|
|
24040
|
+
const [schema1, schema2] = preprocessSchemasPair(superSchema, subSchema, compiler, printWarnLog);
|
|
24041
|
+
const { errorPath, expression } = checkWithResult(extendsContext, schema1, schema2);
|
|
24042
|
+
const foundTrueExpression = hasEquals(expression) || hasContainedBy(expression);
|
|
24043
|
+
const foundFalseExpression = hasContaining(expression) || hasIntersection(expression) || hasRejection(expression);
|
|
24044
|
+
if (foundTrueExpression && !foundFalseExpression) return { result: SubsetCompareResult.True };
|
|
24045
|
+
if (!foundTrueExpression && foundFalseExpression) return {
|
|
24046
|
+
errorPath,
|
|
24047
|
+
result: SubsetCompareResult.False
|
|
24048
|
+
};
|
|
24049
|
+
return { result: SubsetCompareResult.Unknown };
|
|
24050
|
+
}
|
|
24051
|
+
});
|
|
24052
|
+
}
|
|
24053
|
+
//#endregion
|
|
24054
|
+
//#region src/manifest/common/schemaComparer.ts
|
|
24055
|
+
function isStringLikeSchema(value) {
|
|
24056
|
+
return toPlainObject(value)?.type === "string";
|
|
24057
|
+
}
|
|
24058
|
+
function assertSchemaCompareContext(value) {
|
|
24059
|
+
const context = toPlainObject(value);
|
|
24060
|
+
const error = toPlainObject(context?.error);
|
|
24061
|
+
if (context == null || error == null || context.packageId != null && !isString(context.packageId) || error.message != null && !isString(error.message)) throw new TypeError("Invalid schema comparison context.");
|
|
24062
|
+
}
|
|
24063
|
+
function parseSchemaCompareContext(value) {
|
|
24064
|
+
if (value == null) return { error: {} };
|
|
24065
|
+
assertSchemaCompareContext(value);
|
|
24066
|
+
return value;
|
|
24067
|
+
}
|
|
24068
|
+
var SpecialSchema = class SpecialSchema {
|
|
24069
|
+
static setError(fromSchema, toSchema, message) {
|
|
24070
|
+
if (fromSchema instanceof SpecialSchema) fromSchema.context.error.message = message;
|
|
24071
|
+
else if (toSchema instanceof SpecialSchema) toSchema.context.error.message = message;
|
|
24072
|
+
}
|
|
24073
|
+
constructor(id, value, context) {
|
|
24074
|
+
this.id = id;
|
|
24075
|
+
this.value = value;
|
|
24076
|
+
this.context = parseSchemaCompareContext(context);
|
|
24077
|
+
}
|
|
24078
|
+
compare(other) {
|
|
24079
|
+
if (isCompiledSchema(other) && getKind(other) === CompiledKind.Any) return [ExpressionSingleResult.ContainedBy];
|
|
24080
|
+
return this.compareImpl(other);
|
|
24081
|
+
}
|
|
24082
|
+
};
|
|
24083
|
+
var SingleSelectSchema = class SingleSelectSchema extends SpecialSchema {
|
|
24084
|
+
static isMatch(value) {
|
|
24085
|
+
const enumValues = toPlainObject(value)?.enum;
|
|
24086
|
+
return Array.isArray(enumValues) && enumValues.every((v) => isString(v));
|
|
24087
|
+
}
|
|
24088
|
+
constructor(id, value, context) {
|
|
24089
|
+
if (!SingleSelectSchema.isMatch(value)) throw new TypeError("Invalid single-select schema.");
|
|
24090
|
+
super(id, value, context);
|
|
24091
|
+
}
|
|
24092
|
+
compareImpl(other) {
|
|
24093
|
+
if (isStringLikeSchema(other)) return [ExpressionSingleResult.ContainedBy];
|
|
24094
|
+
if (other instanceof SingleSelectSchema) {
|
|
24095
|
+
const f = new Set(this.value.enum);
|
|
24096
|
+
let result = ExpressionSingleResult.Equals;
|
|
24097
|
+
for (const v of other.value.enum) {
|
|
24098
|
+
if (!f.has(v)) result = ExpressionSingleResult.ContainedBy;
|
|
24099
|
+
f.delete(v);
|
|
24100
|
+
}
|
|
24101
|
+
if (f.size === 0) return [result];
|
|
24102
|
+
if (f.size === this.value.enum.length) return [ExpressionSingleResult.Rejection];
|
|
24103
|
+
return [ExpressionSingleResult.Intersection];
|
|
24104
|
+
}
|
|
24105
|
+
return [ExpressionSingleResult.Rejection];
|
|
24106
|
+
}
|
|
24107
|
+
equals(other) {
|
|
24108
|
+
if (other instanceof SingleSelectSchema) {
|
|
24109
|
+
const f = new Set(this.value.enum);
|
|
24110
|
+
for (const v of other.value.enum) {
|
|
24111
|
+
if (!f.has(v)) return false;
|
|
24112
|
+
f.delete(v);
|
|
24113
|
+
}
|
|
24114
|
+
return f.size === 0;
|
|
24115
|
+
}
|
|
24116
|
+
return false;
|
|
24117
|
+
}
|
|
24118
|
+
};
|
|
24119
|
+
var BinarySchema = class BinarySchema extends SpecialSchema {
|
|
24120
|
+
static isMatch(value) {
|
|
24121
|
+
return toPlainObject(value)?.contentMediaType === "oomol/bin";
|
|
24122
|
+
}
|
|
24123
|
+
constructor(id, value, context) {
|
|
24124
|
+
if (!BinarySchema.isMatch(value)) throw new TypeError("Invalid binary schema.");
|
|
24125
|
+
super(id, value, context);
|
|
24126
|
+
}
|
|
24127
|
+
compareImpl(other) {
|
|
24128
|
+
if (other instanceof BinarySchema) return [ExpressionSingleResult.Equals];
|
|
24129
|
+
else {
|
|
24130
|
+
SpecialSchema.setError(this, other, "edgeError.binDiffType");
|
|
24131
|
+
return [ExpressionSingleResult.Rejection];
|
|
24132
|
+
}
|
|
24133
|
+
}
|
|
24134
|
+
equals(other) {
|
|
24135
|
+
return other instanceof BinarySchema;
|
|
24136
|
+
}
|
|
24137
|
+
};
|
|
24138
|
+
var ArtifactSchema = class ArtifactSchema extends SpecialSchema {
|
|
24139
|
+
static isMatch(value) {
|
|
24140
|
+
return toPlainObject(value)?.contentMediaType === "oomol/artifact";
|
|
24141
|
+
}
|
|
24142
|
+
constructor(id, value, context) {
|
|
24143
|
+
if (!ArtifactSchema.isMatch(value)) throw new TypeError("Invalid Artifact schema.");
|
|
24144
|
+
super(id, value, context);
|
|
24145
|
+
}
|
|
24146
|
+
compareImpl(other) {
|
|
24147
|
+
if (other instanceof ArtifactSchema) return [ExpressionSingleResult.Equals];
|
|
24148
|
+
SpecialSchema.setError(this, other, "edgeError.artifactDiffType");
|
|
24149
|
+
return [ExpressionSingleResult.Rejection];
|
|
24150
|
+
}
|
|
24151
|
+
equals(other) {
|
|
24152
|
+
return other instanceof ArtifactSchema;
|
|
24153
|
+
}
|
|
24154
|
+
};
|
|
24155
|
+
function createSchemaComparer() {
|
|
24156
|
+
return makeSubsetCompare({ extendsSchemaClasses: [
|
|
24157
|
+
SingleSelectSchema,
|
|
24158
|
+
BinarySchema,
|
|
24159
|
+
ArtifactSchema
|
|
24160
|
+
] });
|
|
24161
|
+
}
|
|
24162
|
+
//#endregion
|
|
24163
|
+
//#region src/manifest/common/schemaCompare.ts
|
|
24164
|
+
var comparer = createSchemaComparer();
|
|
24165
|
+
function nullableSchema(schema, nullable) {
|
|
24166
|
+
return nullable ? { anyOf: [schema, { type: "null" }] } : schema;
|
|
24167
|
+
}
|
|
24168
|
+
function normalizeNullableSchemaPath(path, nullable) {
|
|
24169
|
+
if (path == null || !nullable || path.length === 0 || path[0] !== "anyOf") return path;
|
|
24170
|
+
return path[1] === 0 ? path.slice(2) : void 0;
|
|
24171
|
+
}
|
|
24172
|
+
function compareJSONSchema(fromSchema, toSchema) {
|
|
24173
|
+
try {
|
|
24174
|
+
const error = {};
|
|
24175
|
+
const fromResolved = resolveLocalRefs(fromSchema.schema);
|
|
24176
|
+
const toResolved = resolveLocalRefs(toSchema.schema);
|
|
24177
|
+
assertComparableSchema(fromResolved);
|
|
24178
|
+
assertComparableSchema(toResolved);
|
|
24179
|
+
const from = comparer.compile(nullableSchema(fromResolved, fromSchema.nullable), {
|
|
24180
|
+
...fromSchema,
|
|
24181
|
+
error
|
|
24182
|
+
});
|
|
24183
|
+
const to = comparer.compile(nullableSchema(toResolved, toSchema.nullable), {
|
|
24184
|
+
...toSchema,
|
|
24185
|
+
error
|
|
24186
|
+
});
|
|
24187
|
+
const { result, errorPath } = comparer.isSubset(from, to);
|
|
24188
|
+
if (result == SubsetCompareResult.True) return { kind: "compatible" };
|
|
24189
|
+
else return {
|
|
24190
|
+
kind: "incompatible",
|
|
24191
|
+
error: error.message,
|
|
24192
|
+
errorPath
|
|
24193
|
+
};
|
|
24194
|
+
} catch (error) {
|
|
24195
|
+
return {
|
|
24196
|
+
kind: "compare-error",
|
|
24197
|
+
message: error instanceof Error ? error.message : String(error)
|
|
24198
|
+
};
|
|
24199
|
+
}
|
|
24200
|
+
}
|
|
24201
|
+
var unsupportedComparisonKeywords = /* @__PURE__ */ new Set([
|
|
24202
|
+
"contains",
|
|
24203
|
+
"dependencies",
|
|
24204
|
+
"dependentRequired",
|
|
24205
|
+
"dependentSchemas",
|
|
24206
|
+
"else",
|
|
24207
|
+
"if",
|
|
24208
|
+
"maxContains",
|
|
24209
|
+
"minContains",
|
|
24210
|
+
"prefixItems",
|
|
24211
|
+
"then",
|
|
24212
|
+
"unevaluatedItems",
|
|
24213
|
+
"unevaluatedProperties"
|
|
24214
|
+
]);
|
|
24215
|
+
function assertComparableSchema(schema) {
|
|
24216
|
+
function visit(value, path) {
|
|
24217
|
+
if (value == null || typeof value != "object" || Array.isArray(value)) return;
|
|
24218
|
+
const source = value;
|
|
24219
|
+
for (const keyword of unsupportedComparisonKeywords) if (Object.hasOwn(source, keyword)) throw new TypeError(`Unsupported schema comparison keyword at ${schemaPath([...path, keyword])}.`);
|
|
24220
|
+
for (const keyword of [
|
|
24221
|
+
"additionalItems",
|
|
24222
|
+
"additionalProperties",
|
|
24223
|
+
"not",
|
|
24224
|
+
"propertyNames"
|
|
24225
|
+
]) visit(source[keyword], [...path, keyword]);
|
|
24226
|
+
const items = source.items;
|
|
24227
|
+
if (Array.isArray(items)) items.forEach((item, index) => visit(item, [
|
|
24228
|
+
...path,
|
|
24229
|
+
"items",
|
|
24230
|
+
index
|
|
24231
|
+
]));
|
|
24232
|
+
else visit(items, [...path, "items"]);
|
|
24233
|
+
for (const keyword of [
|
|
24234
|
+
"allOf",
|
|
24235
|
+
"anyOf",
|
|
24236
|
+
"oneOf"
|
|
24237
|
+
]) {
|
|
24238
|
+
const variants = source[keyword];
|
|
24239
|
+
if (Array.isArray(variants)) variants.forEach((item, index) => visit(item, [
|
|
24240
|
+
...path,
|
|
24241
|
+
keyword,
|
|
24242
|
+
index
|
|
24243
|
+
]));
|
|
24244
|
+
}
|
|
24245
|
+
for (const keyword of ["patternProperties", "properties"]) {
|
|
24246
|
+
const entries = source[keyword];
|
|
24247
|
+
if (entries == null || typeof entries != "object" || Array.isArray(entries)) continue;
|
|
24248
|
+
for (const [name, child] of Object.entries(entries)) visit(child, [
|
|
24249
|
+
...path,
|
|
24250
|
+
keyword,
|
|
24251
|
+
name
|
|
24252
|
+
]);
|
|
24253
|
+
}
|
|
24254
|
+
}
|
|
24255
|
+
visit(schema, []);
|
|
24256
|
+
}
|
|
24257
|
+
function schemaPath(path) {
|
|
24258
|
+
return path.length == 0 ? "#" : `#/${path.map((part) => String(part).replaceAll("~", "~0").replaceAll("/", "~1")).join("/")}`;
|
|
24259
|
+
}
|
|
24260
|
+
function resolveLocalRefs(schema) {
|
|
24261
|
+
function target(reference) {
|
|
24262
|
+
if (!reference.startsWith("#")) return;
|
|
24263
|
+
const pointer = decodeURIComponent(reference.slice(1));
|
|
24264
|
+
if (pointer == "") return schema;
|
|
24265
|
+
if (!pointer.startsWith("/")) return;
|
|
24266
|
+
let value = schema;
|
|
24267
|
+
for (const encoded of pointer.slice(1).split("/")) {
|
|
24268
|
+
if (value == null || typeof value != "object" || Array.isArray(value)) return;
|
|
24269
|
+
const token = encoded.replaceAll("~1", "/").replaceAll("~0", "~");
|
|
24270
|
+
if (!Object.hasOwn(value, token)) return;
|
|
24271
|
+
value = value[token];
|
|
24272
|
+
}
|
|
24273
|
+
return value;
|
|
24274
|
+
}
|
|
24275
|
+
function visit(value, references) {
|
|
24276
|
+
if (Array.isArray(value)) return value.map((item) => visit(item, references));
|
|
24277
|
+
if (value == null || typeof value != "object") return value;
|
|
24278
|
+
const source = value;
|
|
24279
|
+
const reference = typeof source.$ref == "string" && source.$ref.startsWith("#") ? source.$ref : void 0;
|
|
24280
|
+
if (reference != null) {
|
|
24281
|
+
if (references.has(reference)) throw new TypeError(`Cyclic local JSON Schema reference "${reference}".`);
|
|
24282
|
+
const resolved = target(reference);
|
|
24283
|
+
if (resolved === void 0) throw new TypeError(`Local JSON Schema reference "${reference}" does not exist.`);
|
|
24284
|
+
const nextReferences = new Set(references);
|
|
24285
|
+
nextReferences.add(reference);
|
|
24286
|
+
const siblings = Object.fromEntries(Object.entries(source).filter(([key]) => key != "$ref" && key != "$defs" && key != "definitions"));
|
|
24287
|
+
const result = visit(resolved, nextReferences);
|
|
24288
|
+
return Object.keys(siblings).length == 0 ? result : { allOf: [result, visit(siblings, references)] };
|
|
24289
|
+
}
|
|
24290
|
+
return Object.fromEntries(Object.entries(source).filter(([key]) => key != "$defs" && key != "definitions").map(([key, item]) => {
|
|
24291
|
+
switch (key) {
|
|
24292
|
+
case "additionalItems":
|
|
24293
|
+
case "additionalProperties":
|
|
24294
|
+
case "contains":
|
|
24295
|
+
case "else":
|
|
24296
|
+
case "if":
|
|
24297
|
+
case "not":
|
|
24298
|
+
case "propertyNames":
|
|
24299
|
+
case "then": return [key, visit(item, references)];
|
|
24300
|
+
case "items": return [key, Array.isArray(item) ? item.map((entry) => visit(entry, references)) : visit(item, references)];
|
|
24301
|
+
case "allOf":
|
|
24302
|
+
case "anyOf":
|
|
24303
|
+
case "oneOf": return [key, Array.isArray(item) ? item.map((entry) => visit(entry, references)) : item];
|
|
24304
|
+
case "patternProperties":
|
|
24305
|
+
case "properties":
|
|
24306
|
+
if (item == null || typeof item != "object" || Array.isArray(item)) return [key, item];
|
|
24307
|
+
return [key, Object.fromEntries(Object.entries(item).map(([name, entry]) => [name, visit(entry, references)]))];
|
|
24308
|
+
case "dependencies":
|
|
24309
|
+
if (item == null || typeof item != "object" || Array.isArray(item)) return [key, item];
|
|
24310
|
+
return [key, Object.fromEntries(Object.entries(item).map(([name, entry]) => [name, Array.isArray(entry) ? entry : visit(entry, references)]))];
|
|
24311
|
+
default: return [key, item];
|
|
24312
|
+
}
|
|
24313
|
+
}));
|
|
24314
|
+
}
|
|
24315
|
+
return visit(schema, /* @__PURE__ */ new Set());
|
|
24316
|
+
}
|
|
24317
|
+
//#endregion
|
|
24318
|
+
//#region src/flow/common/schema.ts
|
|
24319
|
+
function jsonEqual(left, right) {
|
|
24320
|
+
if (left === right) return true;
|
|
24321
|
+
if (left == null || right == null || typeof left != "object" || typeof right != "object") return false;
|
|
24322
|
+
if (Array.isArray(left) || Array.isArray(right)) return Array.isArray(left) && Array.isArray(right) && left.length == right.length && left.every((value, index) => jsonEqual(value, right[index]));
|
|
24323
|
+
const leftEntries = Object.entries(left);
|
|
24324
|
+
const rightRecord = right;
|
|
24325
|
+
return leftEntries.length == Object.keys(rightRecord).length && leftEntries.every(([key, value]) => Object.hasOwn(rightRecord, key) && jsonEqual(value, rightRecord[key]));
|
|
24326
|
+
}
|
|
24327
|
+
function schemaObject(schema) {
|
|
24328
|
+
return schema != null && typeof schema == "object" && !Array.isArray(schema) ? schema : void 0;
|
|
24329
|
+
}
|
|
24330
|
+
function schemaList(value) {
|
|
24331
|
+
return Array.isArray(value) ? value : void 0;
|
|
24332
|
+
}
|
|
24333
|
+
var validators = /* @__PURE__ */ new WeakMap();
|
|
24334
|
+
function matchesSchema(value, schema) {
|
|
24335
|
+
return schemaValidationErrors(value, schema).length == 0;
|
|
24336
|
+
}
|
|
24337
|
+
function schemaValidationErrors(value, schema) {
|
|
24338
|
+
if (typeof schema == "boolean") return schema ? [] : ["The schema does not allow any value."];
|
|
24339
|
+
const source = schemaObject(schema);
|
|
24340
|
+
if (source == null || source.properties != null && schemaObject(source.properties) == null) return ["Invalid output schema."];
|
|
24341
|
+
try {
|
|
24342
|
+
let validator = validators.get(source);
|
|
24343
|
+
if (validator == null) {
|
|
24344
|
+
const declaration = typeof source.$schema == "string" ? source.$schema : "";
|
|
24345
|
+
const draft = declaration.includes("draft-04") ? "4" : declaration.includes("draft-07") ? "7" : declaration.includes("2020-12") ? "2020-12" : "2019-09";
|
|
24346
|
+
validator = new Validator(structuredClone(source), draft);
|
|
24347
|
+
validators.set(source, validator);
|
|
24348
|
+
}
|
|
24349
|
+
const result = validator.validate(value);
|
|
24350
|
+
return result.valid ? [] : result.errors.map((issue) => `${issue.instanceLocation || "/"}: ${issue.error}`);
|
|
24351
|
+
} catch {
|
|
24352
|
+
return ["Output schema validation failed."];
|
|
24353
|
+
}
|
|
24354
|
+
}
|
|
24355
|
+
function compareSchemas(sourceSchema, targetSchema, sourceNullable = false, targetNullable = false) {
|
|
24356
|
+
if (targetSchema === true) return { kind: "compatible" };
|
|
24357
|
+
if (sourceSchema === false || targetSchema === false) return { kind: "incompatible" };
|
|
24358
|
+
const source = sourceSchema === true ? {} : schemaObject(sourceSchema);
|
|
24359
|
+
const target = schemaObject(targetSchema);
|
|
24360
|
+
if (source == null || target == null) return {
|
|
24361
|
+
kind: "compare-error",
|
|
24362
|
+
message: "Port schema must be an object or boolean."
|
|
24363
|
+
};
|
|
24364
|
+
const result = compareJSONSchema({
|
|
24365
|
+
nullable: sourceNullable,
|
|
24366
|
+
packageId: void 0,
|
|
24367
|
+
schema: source
|
|
24368
|
+
}, {
|
|
24369
|
+
nullable: targetNullable,
|
|
24370
|
+
packageId: void 0,
|
|
24371
|
+
schema: target
|
|
24372
|
+
});
|
|
24373
|
+
return result.kind == "incompatible" ? {
|
|
24374
|
+
...result,
|
|
24375
|
+
errorPath: normalizeNullableSchemaPath(result.errorPath, targetNullable)
|
|
24376
|
+
} : result;
|
|
24377
|
+
}
|
|
24378
|
+
function schemaValue(schema, path) {
|
|
24379
|
+
let value = schema;
|
|
24380
|
+
for (const part of path) {
|
|
24381
|
+
if (value == null || typeof value != "object") return;
|
|
24382
|
+
value = Array.isArray(value) ? value[Number(part)] : schemaObject(value)?.[String(part)];
|
|
24383
|
+
}
|
|
24384
|
+
return value;
|
|
24385
|
+
}
|
|
24386
|
+
function schemaMismatch(source, target, result) {
|
|
24387
|
+
if (source.nullable && !target.nullable) return { kind: "nullable" };
|
|
24388
|
+
if (result.error == "edgeError.binDiffType") return { kind: "binary" };
|
|
24389
|
+
if (result.error == "edgeError.artifactDiffType") return { kind: "artifact" };
|
|
24390
|
+
const sourceSchema = schemaObject(source.jsonSchema);
|
|
24391
|
+
const targetSchema = schemaObject(target.jsonSchema);
|
|
24392
|
+
const fallbackKeyword = result.errorPath == null && sourceSchema != null && targetSchema != null ? rootMismatchKeyword(sourceSchema, targetSchema) : void 0;
|
|
24393
|
+
const path = fallbackKeyword == null ? result.errorPath : [fallbackKeyword];
|
|
24394
|
+
const keyword = path?.at(-1);
|
|
24395
|
+
if (typeof keyword != "string" || !isSchemaKeyword(keyword)) return {
|
|
24396
|
+
kind: "schema",
|
|
24397
|
+
path
|
|
24398
|
+
};
|
|
24399
|
+
const ownerPath = path.slice(0, -1);
|
|
24400
|
+
return {
|
|
24401
|
+
kind: "keyword",
|
|
24402
|
+
keyword,
|
|
24403
|
+
path: ownerPath,
|
|
24404
|
+
source: schemaValue(source.jsonSchema, [...ownerPath, keyword]),
|
|
24405
|
+
target: schemaValue(target.jsonSchema, [...ownerPath, keyword])
|
|
24406
|
+
};
|
|
24407
|
+
}
|
|
24408
|
+
function rootMismatchKeyword(source, target) {
|
|
24409
|
+
if (!jsonEqual(source.type, target.type)) return "type";
|
|
24410
|
+
if (target.const !== void 0 && !jsonEqual(source.const, target.const)) return "const";
|
|
24411
|
+
if (target.enum !== void 0 && !jsonEqual(source.enum, target.enum)) return "enum";
|
|
24412
|
+
const sourceRequired = new Set(Array.isArray(source.required) ? source.required : []);
|
|
24413
|
+
if (Array.isArray(target.required) && target.required.some((name) => typeof name == "string" && !sourceRequired.has(name))) return "required";
|
|
24414
|
+
for (const keyword of schemaConstraintKeywords) if (target[keyword] !== void 0 && !jsonEqual(source[keyword], target[keyword])) return keyword;
|
|
24415
|
+
}
|
|
24416
|
+
var schemaConstraintKeywords = [
|
|
24417
|
+
"minLength",
|
|
24418
|
+
"maxLength",
|
|
24419
|
+
"pattern",
|
|
24420
|
+
"minimum",
|
|
24421
|
+
"exclusiveMinimum",
|
|
24422
|
+
"maximum",
|
|
24423
|
+
"exclusiveMaximum",
|
|
24424
|
+
"multipleOf",
|
|
24425
|
+
"minItems",
|
|
24426
|
+
"maxItems",
|
|
24427
|
+
"minProperties",
|
|
24428
|
+
"maxProperties"
|
|
24429
|
+
];
|
|
24430
|
+
function comparePorts(source, target) {
|
|
24431
|
+
const result = compareSchemas(source.jsonSchema, target.jsonSchema, source.nullable, target.nullable);
|
|
24432
|
+
return result.kind == "incompatible" ? {
|
|
24433
|
+
kind: "incompatible",
|
|
24434
|
+
mismatch: schemaMismatch(source, target, result)
|
|
24435
|
+
} : result;
|
|
24436
|
+
}
|
|
24437
|
+
function variableInputCompatible(jsonSchema) {
|
|
24438
|
+
const schema = schemaObject(jsonSchema);
|
|
24439
|
+
const types = schemaList(schema?.type);
|
|
24440
|
+
if (schema != null && types?.includes("string")) return compareSchemas({ type: "string" }, {
|
|
24441
|
+
...schema,
|
|
24442
|
+
type: "string"
|
|
24443
|
+
}).kind == "compatible";
|
|
24444
|
+
return compareSchemas({ type: "string" }, jsonSchema).kind == "compatible";
|
|
24445
|
+
}
|
|
24446
|
+
//#endregion
|
|
24447
|
+
//#region src/decision/common/decision.ts
|
|
24448
|
+
var decisionModel = "typesafe/jev";
|
|
24449
|
+
var decisionLimits = {
|
|
24450
|
+
choice: 255,
|
|
24451
|
+
score: 10
|
|
24452
|
+
};
|
|
24453
|
+
/** Ordered prefixes are shared by authoring, schemas, validation, and execution. */
|
|
24454
|
+
function limitDecisionQuestion(question) {
|
|
24455
|
+
if (question.type === "noul" || question.criteria.length <= decisionLimits[question.type]) return question;
|
|
24456
|
+
if (question.type === "choice") return {
|
|
24457
|
+
...question,
|
|
24458
|
+
criteria: question.criteria.slice(0, decisionLimits.choice)
|
|
24459
|
+
};
|
|
24460
|
+
return {
|
|
24461
|
+
...question,
|
|
24462
|
+
criteria: question.criteria.slice(0, decisionLimits.score)
|
|
24463
|
+
};
|
|
24464
|
+
}
|
|
24465
|
+
function limitDecisionQuestions(questions) {
|
|
24466
|
+
const limited = questions.map(limitDecisionQuestion);
|
|
24467
|
+
return limited.every((question, i) => question === questions[i]) ? questions : limited;
|
|
24468
|
+
}
|
|
24469
|
+
/** Loading an oversized task also updates its previously generated output schemas. */
|
|
24470
|
+
function limitDecisionTask(task) {
|
|
24471
|
+
if (task.executor.kind !== "decision") return task;
|
|
24472
|
+
const original = task.executor.questions;
|
|
24473
|
+
const questions = limitDecisionQuestions(original);
|
|
24474
|
+
if (questions === original) return task;
|
|
24475
|
+
const outputs = task.outputs.map((port) => {
|
|
24476
|
+
if (!("handle" in port)) return port;
|
|
24477
|
+
const index = original.findIndex((question) => question.name === port.handle);
|
|
24478
|
+
if (index < 0 || original[index] === questions[index] || !dequal(port.jsonSchema, answerSchema(original[index]))) return port;
|
|
24479
|
+
return {
|
|
24480
|
+
...port,
|
|
24481
|
+
jsonSchema: decisionAnswerSchema(questions[index])
|
|
24482
|
+
};
|
|
24483
|
+
});
|
|
24484
|
+
return {
|
|
24485
|
+
...task,
|
|
24486
|
+
executor: {
|
|
24487
|
+
...task.executor,
|
|
24488
|
+
questions
|
|
24489
|
+
},
|
|
24490
|
+
outputs
|
|
24491
|
+
};
|
|
24492
|
+
}
|
|
24493
|
+
var decisionStateSchema = { type: [
|
|
24494
|
+
"string",
|
|
24495
|
+
"object",
|
|
24496
|
+
"array"
|
|
24497
|
+
] };
|
|
24498
|
+
var probability = {
|
|
24499
|
+
type: "number",
|
|
24500
|
+
minimum: 0,
|
|
24501
|
+
maximum: 1
|
|
24502
|
+
};
|
|
24503
|
+
var defaultDecisionQuestion = (name = "decision1") => ({
|
|
24504
|
+
name,
|
|
24505
|
+
type: "noul",
|
|
24506
|
+
instructions: ""
|
|
24507
|
+
});
|
|
24508
|
+
function decisionQuestionIssues(questions) {
|
|
24509
|
+
questions = limitDecisionQuestions(questions);
|
|
24510
|
+
const issues = [];
|
|
24511
|
+
if (!questions.length) issues.push({
|
|
24512
|
+
field: "questions",
|
|
24513
|
+
message: "Add at least one question."
|
|
24514
|
+
});
|
|
24515
|
+
questions.forEach((question, index) => {
|
|
24516
|
+
const add = (field, message) => issues.push({
|
|
24517
|
+
question: index,
|
|
24518
|
+
field,
|
|
24519
|
+
message
|
|
24520
|
+
});
|
|
24521
|
+
if (!question.name.trim() || question.name === "__proto__" || questions.some((other, i) => i !== index && other.name === question.name)) add("name", "Question names must be non-empty and unique; __proto__ is reserved.");
|
|
24522
|
+
if (!question.instructions.trim()) add("instructions", "Describe the question to evaluate.");
|
|
24523
|
+
if (question.type === "choice") {
|
|
24524
|
+
if (!question.criteria.length) add("criteria", "Provide between 1 and 255 choices.");
|
|
24525
|
+
const names = question.criteria.map((item) => item.name);
|
|
24526
|
+
if (names.some((name) => !name.trim() || name === "__proto__") || new Set(names).size !== names.length) add("criteria", "Choice names must be non-empty and unique; __proto__ is reserved.");
|
|
24527
|
+
}
|
|
24528
|
+
if (question.type === "score" && (question.criteria.length < 2 || question.criteria.some((level) => !level.trim()))) add("criteria", "Provide between 2 and 10 non-empty levels, in increasing order.");
|
|
24529
|
+
});
|
|
24530
|
+
return issues;
|
|
24531
|
+
}
|
|
24532
|
+
function decisionAnswerSchema(question) {
|
|
24533
|
+
return answerSchema(limitDecisionQuestion(question));
|
|
24534
|
+
}
|
|
24535
|
+
function answerSchema(question) {
|
|
24536
|
+
const properties = { type: { const: question.type } };
|
|
24537
|
+
if (question.type === "noul") properties.noul = probability;
|
|
24538
|
+
else {
|
|
24539
|
+
const keys = question.type === "choice" ? question.criteria.map((item) => item.name) : question.criteria.map((_, index) => String(index));
|
|
24540
|
+
properties.confidence = probability;
|
|
24541
|
+
properties.probabilities = {
|
|
24542
|
+
type: "object",
|
|
24543
|
+
properties: Object.fromEntries(keys.map((key) => [key, probability])),
|
|
24544
|
+
required: keys,
|
|
24545
|
+
additionalProperties: false
|
|
24546
|
+
};
|
|
24547
|
+
if (question.type === "choice") properties.choice = {
|
|
24548
|
+
type: "string",
|
|
24549
|
+
...keys.length ? { enum: keys } : {}
|
|
24550
|
+
};
|
|
24551
|
+
else {
|
|
24552
|
+
properties.score = {
|
|
24553
|
+
type: "number",
|
|
24554
|
+
minimum: 0,
|
|
24555
|
+
maximum: Math.max(0, keys.length - 1)
|
|
24556
|
+
};
|
|
24557
|
+
properties.legend = {
|
|
24558
|
+
type: "object",
|
|
24559
|
+
properties: Object.fromEntries(keys.map((key) => [key, { type: "string" }])),
|
|
24560
|
+
required: keys,
|
|
24561
|
+
additionalProperties: false
|
|
24562
|
+
};
|
|
24563
|
+
}
|
|
24564
|
+
}
|
|
24565
|
+
return {
|
|
24566
|
+
type: "object",
|
|
24567
|
+
properties,
|
|
24568
|
+
required: Object.keys(properties)
|
|
24569
|
+
};
|
|
24570
|
+
}
|
|
24571
|
+
function decisionTask(questions = [defaultDecisionQuestion()], name = "AI Decision") {
|
|
24572
|
+
questions = limitDecisionQuestions(questions);
|
|
24573
|
+
const inputs = [{
|
|
24574
|
+
handle: "target",
|
|
24575
|
+
description: "Text, object, or array to evaluate across all questions.",
|
|
24576
|
+
jsonSchema: decisionStateSchema,
|
|
24577
|
+
nullable: false
|
|
24578
|
+
}];
|
|
24579
|
+
const outputs = questions.map((question) => ({
|
|
24580
|
+
handle: question.name,
|
|
24581
|
+
jsonSchema: decisionAnswerSchema(question),
|
|
24582
|
+
nullable: false
|
|
24583
|
+
}));
|
|
24584
|
+
return {
|
|
24585
|
+
name,
|
|
24586
|
+
executor: {
|
|
24587
|
+
kind: "decision",
|
|
24588
|
+
questions
|
|
24589
|
+
},
|
|
24590
|
+
inputs,
|
|
24591
|
+
outputs
|
|
24592
|
+
};
|
|
24593
|
+
}
|
|
24594
|
+
function checkJsonDepth(value, depth = 0) {
|
|
24595
|
+
if (depth > 64) throw new TypeError("Value exceeds the maximum JSON depth.");
|
|
24596
|
+
if (value != null && typeof value == "object") for (const child of Object.values(value)) checkJsonDepth(child, depth + 1);
|
|
24597
|
+
}
|
|
24598
|
+
//#endregion
|
|
24599
|
+
//#region src/flow/common/triggerScheduleSchema.ts
|
|
24600
|
+
var triggerScheduleSchema = array(union([object({
|
|
24601
|
+
type: literal("cron"),
|
|
24602
|
+
expression: string(),
|
|
24603
|
+
timezone: string()
|
|
24604
|
+
}), object({
|
|
24605
|
+
type: literal("every"),
|
|
24606
|
+
unit: _enum([
|
|
24607
|
+
"day",
|
|
24608
|
+
"hour",
|
|
24609
|
+
"minute",
|
|
24610
|
+
"month",
|
|
24611
|
+
"week"
|
|
24612
|
+
]),
|
|
24613
|
+
value: number()
|
|
24614
|
+
})]));
|
|
24615
|
+
//#endregion
|
|
24616
|
+
//#region src/flow/common/webhookMethod.ts
|
|
24617
|
+
var webhookMethods = [
|
|
24618
|
+
"GET",
|
|
24619
|
+
"POST",
|
|
24620
|
+
"PUT",
|
|
24621
|
+
"PATCH",
|
|
24622
|
+
"DELETE"
|
|
24623
|
+
];
|
|
24624
|
+
function webhookSupportsBody(method) {
|
|
24625
|
+
return method !== "GET";
|
|
24626
|
+
}
|
|
24627
|
+
var text = string();
|
|
24628
|
+
var json = json$1();
|
|
24629
|
+
var strings = array(text);
|
|
24630
|
+
var port = object({
|
|
24631
|
+
description: text.optional(),
|
|
24632
|
+
jsonSchema: json,
|
|
24633
|
+
nullable: boolean(),
|
|
24634
|
+
handle: text
|
|
24635
|
+
});
|
|
24636
|
+
var input = port.extend({ value: json.optional() });
|
|
24637
|
+
var group = object({
|
|
24638
|
+
collapsed: boolean().optional(),
|
|
24639
|
+
group: text
|
|
24640
|
+
});
|
|
24641
|
+
var nodeSource = object({
|
|
24642
|
+
kind: literal("node"),
|
|
24643
|
+
nodeId: text,
|
|
20501
24644
|
output: text,
|
|
20502
24645
|
field: text.optional()
|
|
20503
24646
|
});
|
|
@@ -20572,6 +24715,32 @@ var agentValue = union([object({
|
|
|
20572
24715
|
input: text
|
|
20573
24716
|
})]);
|
|
20574
24717
|
var agentInput = union([agentValue, object({ kind: literal("model") })]);
|
|
24718
|
+
var decisionQuestion = discriminatedUnion("type", [
|
|
24719
|
+
strictObject({
|
|
24720
|
+
name: text,
|
|
24721
|
+
instructions: text,
|
|
24722
|
+
type: literal("noul"),
|
|
24723
|
+
criteria: strictObject({
|
|
24724
|
+
true: text.optional(),
|
|
24725
|
+
false: text.optional()
|
|
24726
|
+
}).optional()
|
|
24727
|
+
}),
|
|
24728
|
+
strictObject({
|
|
24729
|
+
name: text,
|
|
24730
|
+
instructions: text,
|
|
24731
|
+
type: literal("choice"),
|
|
24732
|
+
criteria: array(strictObject({
|
|
24733
|
+
name: text,
|
|
24734
|
+
description: text
|
|
24735
|
+
}))
|
|
24736
|
+
}),
|
|
24737
|
+
strictObject({
|
|
24738
|
+
name: text,
|
|
24739
|
+
instructions: text,
|
|
24740
|
+
type: literal("score"),
|
|
24741
|
+
criteria: strings
|
|
24742
|
+
})
|
|
24743
|
+
]);
|
|
20575
24744
|
var managed = object({
|
|
20576
24745
|
...ports,
|
|
20577
24746
|
name: text,
|
|
@@ -20599,6 +24768,10 @@ var managed = object({
|
|
|
20599
24768
|
in: _enum(["header", "query"]).optional()
|
|
20600
24769
|
}))
|
|
20601
24770
|
}),
|
|
24771
|
+
strictObject({
|
|
24772
|
+
kind: literal("decision"),
|
|
24773
|
+
questions: array(decisionQuestion)
|
|
24774
|
+
}),
|
|
20602
24775
|
object({
|
|
20603
24776
|
kind: literal("llm"),
|
|
20604
24777
|
mode: _enum(["chat", "json"])
|
|
@@ -20625,7 +24798,7 @@ var managed = object({
|
|
|
20625
24798
|
}).optional()
|
|
20626
24799
|
})
|
|
20627
24800
|
])
|
|
20628
|
-
});
|
|
24801
|
+
}).transform(limitDecisionTask);
|
|
20629
24802
|
var operand = union([object({
|
|
20630
24803
|
kind: literal("value"),
|
|
20631
24804
|
value: json.optional(),
|
|
@@ -21027,6 +25200,11 @@ var shapes = {
|
|
|
21027
25200
|
before: text.optional(),
|
|
21028
25201
|
value: text.optional()
|
|
21029
25202
|
},
|
|
25203
|
+
"task.decision.set": {
|
|
25204
|
+
taskId: text,
|
|
25205
|
+
before: managed,
|
|
25206
|
+
value: managed
|
|
25207
|
+
},
|
|
21030
25208
|
"task.openapi.set": {
|
|
21031
25209
|
taskId: text,
|
|
21032
25210
|
before: managed,
|
|
@@ -21885,6 +26063,16 @@ function applyFlowChanges(content, operations) {
|
|
|
21885
26063
|
document.tasks = tasks;
|
|
21886
26064
|
break;
|
|
21887
26065
|
}
|
|
26066
|
+
case "task.decision.set": {
|
|
26067
|
+
const task = document.tasks[operation.taskId];
|
|
26068
|
+
if (task?.executor.kind != "decision" || operation.value.executor.kind != "decision") invalid("The AI Decision Task does not exist.");
|
|
26069
|
+
if (!dequal(task, operation.before)) invalid("The AI Decision Task changed before this operation was applied.");
|
|
26070
|
+
document.tasks = {
|
|
26071
|
+
...document.tasks,
|
|
26072
|
+
[operation.taskId]: operation.value
|
|
26073
|
+
};
|
|
26074
|
+
break;
|
|
26075
|
+
}
|
|
21888
26076
|
case "task.openapi.set": {
|
|
21889
26077
|
const task = document.tasks[operation.taskId];
|
|
21890
26078
|
if (task?.executor.kind != "openapi" || operation.value.executor.kind != "openapi") invalid("The OpenAPI Task does not exist.");
|
|
@@ -23083,6 +27271,51 @@ var TooltipProvider$1 = function TooltipProvider(props) {
|
|
|
23083
27271
|
};
|
|
23084
27272
|
if (process.env.NODE_ENV !== "production") TooltipProvider$1.displayName = "TooltipProvider";
|
|
23085
27273
|
//#endregion
|
|
27274
|
+
//#region ../../node_modules/.bun/@base-ui+react@1.4.1+fa6c2f29eeb10566/node_modules/@base-ui/react/esm/tooltip/store/TooltipHandle.js
|
|
27275
|
+
/**
|
|
27276
|
+
* A handle to control a tooltip imperatively and to associate detached triggers with it.
|
|
27277
|
+
*/
|
|
27278
|
+
var TooltipHandle = class {
|
|
27279
|
+
/**
|
|
27280
|
+
* Internal store holding the tooltip state.
|
|
27281
|
+
* @internal
|
|
27282
|
+
*/
|
|
27283
|
+
constructor() {
|
|
27284
|
+
this.store = new TooltipStore();
|
|
27285
|
+
}
|
|
27286
|
+
/**
|
|
27287
|
+
* Opens the tooltip and associates it with the trigger with the given ID.
|
|
27288
|
+
* The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
|
|
27289
|
+
*
|
|
27290
|
+
* This method should only be called in an event handler or an effect (not during rendering).
|
|
27291
|
+
*
|
|
27292
|
+
* @param triggerId ID of the trigger to associate with the tooltip.
|
|
27293
|
+
*/
|
|
27294
|
+
open(triggerId) {
|
|
27295
|
+
const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
|
|
27296
|
+
if (triggerId && !triggerElement) throw new Error(process.env.NODE_ENV !== "production" ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage(81, triggerId));
|
|
27297
|
+
this.store.setOpen(true, createChangeEventDetails(imperativeAction, void 0, triggerElement));
|
|
27298
|
+
}
|
|
27299
|
+
/**
|
|
27300
|
+
* Closes the tooltip.
|
|
27301
|
+
*/
|
|
27302
|
+
close() {
|
|
27303
|
+
this.store.setOpen(false, createChangeEventDetails(imperativeAction, void 0, void 0));
|
|
27304
|
+
}
|
|
27305
|
+
/**
|
|
27306
|
+
* Indicates whether the tooltip is currently open.
|
|
27307
|
+
*/
|
|
27308
|
+
get isOpen() {
|
|
27309
|
+
return this.store.state.open;
|
|
27310
|
+
}
|
|
27311
|
+
};
|
|
27312
|
+
/**
|
|
27313
|
+
* Creates a new handle to connect a Tooltip.Root with detached Tooltip.Trigger components.
|
|
27314
|
+
*/
|
|
27315
|
+
function createTooltipHandle$1() {
|
|
27316
|
+
return new TooltipHandle();
|
|
27317
|
+
}
|
|
27318
|
+
//#endregion
|
|
23086
27319
|
//#region src/ui/browser/tooltip.tsx
|
|
23087
27320
|
function TooltipProvider({ delay = 0, ...props }) {
|
|
23088
27321
|
return /* @__PURE__ */ jsx(TooltipProvider$1, {
|
|
@@ -23129,6 +27362,7 @@ function TooltipContent({ className, container, positionMethod, collisionBoundar
|
|
|
23129
27362
|
})
|
|
23130
27363
|
});
|
|
23131
27364
|
}
|
|
27365
|
+
var createTooltipHandle = createTooltipHandle$1;
|
|
23132
27366
|
//#endregion
|
|
23133
27367
|
//#region src/ui/browser/dialog.tsx
|
|
23134
27368
|
function Dialog(props) {
|
|
@@ -23387,6 +27621,12 @@ function glyph(name) {
|
|
|
23387
27621
|
}
|
|
23388
27622
|
}
|
|
23389
27623
|
function Icon({ name, size = 18, ...props }) {
|
|
27624
|
+
if (name === "decision") return /* @__PURE__ */ jsx(BrainCircuit, {
|
|
27625
|
+
"aria-hidden": "true",
|
|
27626
|
+
size,
|
|
27627
|
+
strokeWidth: 1.5,
|
|
27628
|
+
...props
|
|
27629
|
+
});
|
|
23390
27630
|
if (name === "comment") return /* @__PURE__ */ jsx(StickyNote, {
|
|
23391
27631
|
"aria-hidden": "true",
|
|
23392
27632
|
size,
|
|
@@ -23416,4 +27656,4 @@ function Icon({ name, size = 18, ...props }) {
|
|
|
23416
27656
|
});
|
|
23417
27657
|
}
|
|
23418
27658
|
//#endregion
|
|
23419
|
-
export {
|
|
27659
|
+
export { comparePorts as $, require_builtin_esm_external_require_react as $n, none as $r, inertValue as $t, nextNodeName as A, formatErrorMessage as Ai, useTriggerDataForwarding as An, ChevronDown as Ar, ARROW_DOWN as At, operatorsForType as B, FloatingTreeStore as Bn, createChangeEventDetails as Br, VERTICAL_KEYS as Bt, FieldDescription as C, EMPTY_OBJECT as Ci, useSyncedFloatingRootContext as Cn, contains as Cr, SelectSeparator as Ct, FlowChangeError as D, useButton as Di, PopupTriggerMap as Dn, isMac as Dr, IndexGuessBehavior as Dt, FieldLabel as E, useMergedRefs as Ei, popupStoreSelectors as En, isFirefox as Er, Separator as Et, comparisonIssue as F, useRefWithInit as Fi, FloatingNode as Fn, useAnimationsFinished as Fr, COMPOSITE_KEYS as Ft, webhookMethods as G, FocusGuard as Gn, escapeKey as Gr, useAnchoredPopupScrollLock as Gt, unaryOperator as H, CLICK_TRIGGER_IDENTIFIER as Hn, cancelOpen as Hr, isNativeInput as Ht, conditionInputPorts as I, getParentNode as Ii, FloatingTree as In, TransitionStatusDataAttributes as Ir, HOME as It, decisionModel as J, Store as Jn, inputChange as Jr, InternalBackdrop as Jt, webhookSupportsBody as K, addEventListener as Kn, focusOut as Kr, usePositioner as Kt, mapConditionSources as L, isElement as Li, useFloatingNodeId as Ln, transitionStatusMapping as Lr, HORIZONTAL_KEYS as Lt, normalizeNodeName as M, useIsoLayoutEffect as Mi, useDismiss as Mn, createLucideIcon as Mr, ARROW_LEFT as Mt, portsByHandle as N, SafeReact as Ni, useClick as Nn, useTransitionStatus as Nr, ARROW_RIGHT as Nt, applyFlowChanges as O, CompositeRootContext as Oi, useImplicitActiveTrigger as On, ownerDocument as Or, useCompositeListItem as Ot, resourceNameIssue as P, useStableCallback as Pi, FloatingFocusManager as Pn, useOpenChangeComplete as Pr, ARROW_UP as Pt, limitDecisionQuestions as Q, require_with_selector as Qn, listNavigation as Qr, CompositeList as Qt, nodeInputMappings as R, isHTMLElement as Ri, useFloatingParentNodeId as Rn, useOnMount as Rr, HORIZONTAL_KEYS_WITH_EXTRA_KEYS as Rt, Field as S, EMPTY_ARRAY as Si, useFocus as Sn, activeElement as Sr, SelectItem as St, FieldGroup as T, warn as Ti, createInitialPopupStoreState as Tn, isAndroid as Tr, SelectValue as Tt, valueType as U, DROPDOWN_COLLISION_AVOIDANCE as Un, clearPress as Ur, scrollIntoViewIfNeeded as Ut, otherwiseOutput as V, FloatingPortal as Vn, createGenericEventDetails as Vr, VERTICAL_KEYS_WITH_EXTRA_KEYS as Vt, decodeRevisionContent as W, POPUP_COLLISION_AVOIDANCE as Wn, closePress as Wr, useToolbarRootContext as Wt, decisionTask as X, fastComponent as Xn, inputPress as Xr, adaptiveOrigin as Xt, decisionQuestionIssues as Y, useStore as Yn, inputClear as Yr, useAnchorPositioning as Yt, defaultDecisionQuestion as Z, fastComponentRef as Zn, itemPress as Zr, useDirection as Zt, TooltipPositioner as _, buttonVariants as _i, useRole as _n, getMinListIndex as _r, union as _t, DialogDescription as a, useLabelableContext as ai, useOpenInteractionType as an, Timeout as ar, _enum as at, TooltipRoot as b, clsx as bi, useHoverReferenceInteraction as bn, stopEvent as br, SelectContent as bt, DialogTitle as c, useFieldRootContext as ci, stringifyAsLabel as cn, getTabbableAfterElement as cr, discriminatedUnion as ct, TooltipContent as d, DEFAULT_FIELD_STATE_ATTRIBUTES as di, defaultItemEquality as dn, createGridCellMap as dr, lazy$1 as dt, outsidePress as ei, getPseudoElementBounds as en, createSelector as er, matchesSchema as et, TooltipProvider as f, fieldValidityMapping as fi, findItemIndex as fn, findNonDisabledListIndex as fr, literal as ft, TooltipPopup as g, Button as gi, useTypeahead as gn, getMaxListIndex as gr, string as gt, TooltipArrow as h, useControlled as hi, safePolygon as hn, getGridNavigatedIndex as hr, strictObject as ht, DialogContent as i, triggerPress as ii, resolveAriaLabelledBy as in, Input as ir, dequal as it, nodeNameIssue as j, mergeProps$1 as ji, useTriggerRegistration as jn, Check as jr, ARROW_KEYS as jt, isSchemaKeyword as k, useCompositeRootContext as ki, useOpenStateTransitions as kn, useLabelableId as kr, ALL_KEYS as kt, DialogTrigger as l, useBaseUiId as li, stringifyAsValue as ln, getTabbableBeforeElement as lr, int as lt, createTooltipHandle as m, visuallyHiddenInput as mi, selectedValueIncludes as mn, getGridCellIndices as mr, record as mt, Dialog as n, triggerFocus as ni, pressableTriggerOpenStateMapping as nn, useOnFirstRender as nr, variableInputCompatible as nt, DialogFooter as o, useFormContext as oi, hasNullItemLabel as on, useTimeout as or, array as ot, TooltipTrigger as p, visuallyHidden as pi, removeItem as pn, getGridCellIndexOfCorner as pr, number as pt, decisionLimits as q, ReactStore as qn, imperativeAction as qr, getDisabledMountTransitionStyles as qt, DialogClose as r, triggerHover as ri, triggerOpenStateMapping as rn, Label as rr, format as rt, DialogHeader as s, useRegisterFieldControl as si, isGroupedItems as sn, getNextTabbable as sr, boolean as st, Icon as t, siblingOpen as ti, popupStateMapping as tn, useValueAsRef as tr, schemaObject as tt, Tooltip as u, useId$1 as ui, compareItemEquality as un, isOutsideEvent as ur, json$1 as ut, TooltipPortal as v, cn as vi, useListNavigation as vn, isIndexOutOfListBounds as vr, Select as vt, FieldError as w, NOOP as wi, useFloatingRootContext as wn, getTarget as wr, SelectTrigger as wt, Spinner as x, useRenderElement as xi, useHoverFloatingInteraction as xn, isInteractiveElement as xr, SelectGroup as xt, TooltipTrigger$1 as y, cva as yi, useInteractions as yn, isListIndexDisabled as yr, SelectChevron as yt, operandHandle as z, isLastTraversableNode as zi, useFloatingTree as zn, useValueChanged as zr, MODIFIER_KEYS as zt };
|