@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
package/dist/common/scheduler.js
CHANGED
|
@@ -2267,6 +2267,70 @@ var $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
|
|
|
2267
2267
|
});
|
|
2268
2268
|
};
|
|
2269
2269
|
});
|
|
2270
|
+
function discriminatorMap(def) {
|
|
2271
|
+
const map = /* @__PURE__ */ new Map();
|
|
2272
|
+
for (const option of def.options) {
|
|
2273
|
+
const values = option._zod.propValues?.[def.discriminator];
|
|
2274
|
+
if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
|
|
2275
|
+
for (const value of values) if (map.has(value)) {
|
|
2276
|
+
if (value !== void 0) throw new Error(`Duplicate discriminator value "${String(value)}"`);
|
|
2277
|
+
map.set(value, null);
|
|
2278
|
+
} else map.set(value, option);
|
|
2279
|
+
}
|
|
2280
|
+
return map;
|
|
2281
|
+
}
|
|
2282
|
+
var $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
2283
|
+
def.inclusive = false;
|
|
2284
|
+
$ZodUnion.init(inst, def);
|
|
2285
|
+
const _super = inst._zod.parse;
|
|
2286
|
+
defineLazyInternal(inst, "propValues", (zod) => {
|
|
2287
|
+
const propValues = {};
|
|
2288
|
+
let undefinedCount = 0;
|
|
2289
|
+
for (const option of zod.def.options) {
|
|
2290
|
+
const pv = option._zod.propValues;
|
|
2291
|
+
if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${zod.def.options.indexOf(option)}"`);
|
|
2292
|
+
if (pv[zod.def.discriminator]?.has(void 0)) undefinedCount++;
|
|
2293
|
+
for (const [k, v] of Object.entries(pv)) {
|
|
2294
|
+
if (!Object.prototype.hasOwnProperty.call(propValues, k)) assignProp(propValues, k, /* @__PURE__ */ new Set());
|
|
2295
|
+
for (const val of v) propValues[k].add(val);
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
if (!zod.def.unionFallback && undefinedCount > 1) propValues[zod.def.discriminator]?.delete(void 0);
|
|
2299
|
+
return propValues;
|
|
2300
|
+
});
|
|
2301
|
+
def.options.forEach((option, i) => {
|
|
2302
|
+
const propShape = rawShape(option._zod.def);
|
|
2303
|
+
if (propShape && !Object.prototype.hasOwnProperty.call(propShape, def.discriminator)) throw new Error(`Invalid discriminated union option at index "${i}"`);
|
|
2304
|
+
});
|
|
2305
|
+
const disc = cached(() => discriminatorMap(def));
|
|
2306
|
+
inst._zod.parse = (payload, ctx) => {
|
|
2307
|
+
const input = payload.value;
|
|
2308
|
+
if (!isObject$1(input)) {
|
|
2309
|
+
payload.issues.push({
|
|
2310
|
+
code: "invalid_type",
|
|
2311
|
+
expected: "object",
|
|
2312
|
+
input,
|
|
2313
|
+
inst
|
|
2314
|
+
});
|
|
2315
|
+
return payload;
|
|
2316
|
+
}
|
|
2317
|
+
const value = input?.[def.discriminator];
|
|
2318
|
+
const opt = disc.value.get(value);
|
|
2319
|
+
if (opt && (value !== void 0 || ctx.direction !== "backward")) return opt._zod.run(payload, ctx);
|
|
2320
|
+
if (def.unionFallback || ctx.direction === "backward") return _super(payload, ctx);
|
|
2321
|
+
payload.issues.push({
|
|
2322
|
+
code: "invalid_union",
|
|
2323
|
+
errors: [],
|
|
2324
|
+
note: "No matching discriminator",
|
|
2325
|
+
discriminator: def.discriminator,
|
|
2326
|
+
options: Array.from(disc.value.keys()).filter((value) => disc.value.get(value) !== null),
|
|
2327
|
+
input,
|
|
2328
|
+
path: [def.discriminator],
|
|
2329
|
+
inst
|
|
2330
|
+
});
|
|
2331
|
+
return payload;
|
|
2332
|
+
};
|
|
2333
|
+
});
|
|
2270
2334
|
var $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (inst, def) => {
|
|
2271
2335
|
$ZodType.init(inst, def);
|
|
2272
2336
|
inst._zod.parse = (payload, ctx) => {
|
|
@@ -5315,6 +5379,18 @@ function union(options, params) {
|
|
|
5315
5379
|
...normalizeParams(params)
|
|
5316
5380
|
});
|
|
5317
5381
|
}
|
|
5382
|
+
var ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("ZodDiscriminatedUnion", (inst, def) => {
|
|
5383
|
+
ZodUnion.init(inst, def);
|
|
5384
|
+
$ZodDiscriminatedUnion.init(inst, def);
|
|
5385
|
+
});
|
|
5386
|
+
function discriminatedUnion(discriminator, options, params) {
|
|
5387
|
+
return new ZodDiscriminatedUnion({
|
|
5388
|
+
type: "union",
|
|
5389
|
+
options,
|
|
5390
|
+
discriminator,
|
|
5391
|
+
...normalizeParams(params)
|
|
5392
|
+
});
|
|
5393
|
+
}
|
|
5318
5394
|
var ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
|
|
5319
5395
|
$ZodIntersection.init(inst, def);
|
|
5320
5396
|
ZodType.init(inst, def);
|
|
@@ -6504,865 +6580,76 @@ function dequal(foo, bar) {
|
|
|
6504
6580
|
return foo !== foo && bar !== bar;
|
|
6505
6581
|
}
|
|
6506
6582
|
//#endregion
|
|
6507
|
-
//#region src/
|
|
6508
|
-
var
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
type: literal("every"),
|
|
6514
|
-
unit: _enum([
|
|
6515
|
-
"day",
|
|
6516
|
-
"hour",
|
|
6517
|
-
"minute",
|
|
6518
|
-
"month",
|
|
6519
|
-
"week"
|
|
6520
|
-
]),
|
|
6521
|
-
value: number()
|
|
6522
|
-
})]));
|
|
6523
|
-
//#endregion
|
|
6524
|
-
//#region src/flow/common/webhookMethod.ts
|
|
6525
|
-
var webhookMethods = [
|
|
6526
|
-
"GET",
|
|
6527
|
-
"POST",
|
|
6528
|
-
"PUT",
|
|
6529
|
-
"PATCH",
|
|
6530
|
-
"DELETE"
|
|
6531
|
-
];
|
|
6532
|
-
function webhookSupportsBody(method) {
|
|
6533
|
-
return method !== "GET";
|
|
6583
|
+
//#region src/json-schema-subset/utils.ts
|
|
6584
|
+
var nextId = 0;
|
|
6585
|
+
function createId() {
|
|
6586
|
+
const id = nextId;
|
|
6587
|
+
nextId += 1;
|
|
6588
|
+
return id;
|
|
6534
6589
|
}
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
|
|
6541
|
-
|
|
6542
|
-
|
|
6543
|
-
}
|
|
6544
|
-
|
|
6545
|
-
|
|
6546
|
-
|
|
6547
|
-
|
|
6548
|
-
|
|
6549
|
-
|
|
6550
|
-
|
|
6551
|
-
|
|
6552
|
-
|
|
6553
|
-
|
|
6554
|
-
}
|
|
6555
|
-
|
|
6556
|
-
|
|
6557
|
-
|
|
6590
|
+
function deepFreeze(target) {
|
|
6591
|
+
if (typeof target === "object" && target !== null && !Object.isFrozen(target)) {
|
|
6592
|
+
for (const key of Object.getOwnPropertyNames(target)) deepFreeze(Reflect.get(target, key));
|
|
6593
|
+
Object.freeze(target);
|
|
6594
|
+
}
|
|
6595
|
+
return target;
|
|
6596
|
+
}
|
|
6597
|
+
function pick(target, keys) {
|
|
6598
|
+
const newTarget = {};
|
|
6599
|
+
for (const key of keys) if (key in target) newTarget[key] = target[key];
|
|
6600
|
+
return newTarget;
|
|
6601
|
+
}
|
|
6602
|
+
function deepCopy(value) {
|
|
6603
|
+
if (typeof value !== "object" || value === null) return value;
|
|
6604
|
+
else if (Array.isArray(value)) {
|
|
6605
|
+
const array = [];
|
|
6606
|
+
for (const [i, element] of value.entries()) array[i] = deepCopy(element);
|
|
6607
|
+
return array;
|
|
6608
|
+
} else {
|
|
6609
|
+
const newObject = {};
|
|
6610
|
+
for (const key in value) newObject[key] = deepCopy(value[key]);
|
|
6611
|
+
return newObject;
|
|
6612
|
+
}
|
|
6613
|
+
}
|
|
6614
|
+
function isDeepEquals(value1, value2) {
|
|
6615
|
+
if (value1 === value2) return true;
|
|
6616
|
+
if (value1 === null) return false;
|
|
6617
|
+
if (typeof value1 !== "object") return false;
|
|
6618
|
+
if (typeof value1 !== typeof value2) return false;
|
|
6619
|
+
if (Array.isArray(value1)) {
|
|
6620
|
+
if (!Array.isArray(value2)) return false;
|
|
6621
|
+
if (value1.length !== value2.length) return false;
|
|
6622
|
+
for (const [i, value1Element] of value1.entries()) if (!isDeepEquals(value1Element, value2[i])) return false;
|
|
6623
|
+
} else {
|
|
6624
|
+
if (Array.isArray(value2)) return false;
|
|
6625
|
+
for (const key in value1) {
|
|
6626
|
+
if (!(key in value2)) return false;
|
|
6627
|
+
if (!isDeepEquals(value1[key], value2[key])) return false;
|
|
6628
|
+
}
|
|
6629
|
+
for (const key in value2) if (!(key in value1)) return false;
|
|
6630
|
+
}
|
|
6631
|
+
return true;
|
|
6632
|
+
}
|
|
6633
|
+
//#endregion
|
|
6634
|
+
//#region src/json-schema-subset/expression/result.ts
|
|
6635
|
+
var ExpressionSingleResult = Object.freeze({
|
|
6636
|
+
Equals: 0,
|
|
6637
|
+
Containing: 1,
|
|
6638
|
+
ContainedBy: 2,
|
|
6639
|
+
Rejection: 3,
|
|
6640
|
+
Intersection: 4
|
|
6558
6641
|
});
|
|
6559
|
-
var
|
|
6560
|
-
|
|
6561
|
-
|
|
6562
|
-
|
|
6563
|
-
|
|
6564
|
-
|
|
6565
|
-
|
|
6566
|
-
]
|
|
6567
|
-
|
|
6568
|
-
|
|
6569
|
-
|
|
6570
|
-
})]);
|
|
6571
|
-
var mapping = union([fixedInput, object({
|
|
6572
|
-
kind: literal("sources"),
|
|
6573
|
-
sources: array(source)
|
|
6574
|
-
})]);
|
|
6575
|
-
var inputs = record(text, mapping);
|
|
6576
|
-
var ports = {
|
|
6577
|
-
inputs: array(union([input, group])),
|
|
6578
|
-
outputs: array(union([port, group]))
|
|
6579
|
-
};
|
|
6580
|
-
var capability = union([
|
|
6581
|
-
strictObject({
|
|
6582
|
-
kind: literal("connector"),
|
|
6583
|
-
action: text,
|
|
6584
|
-
connectionId: text.optional(),
|
|
6585
|
-
connections: array(strictObject({
|
|
6586
|
-
connectionId: text,
|
|
6587
|
-
alias: text.optional()
|
|
6588
|
-
}))
|
|
6589
|
-
}),
|
|
6590
|
-
strictObject({
|
|
6591
|
-
kind: literal("connector"),
|
|
6592
|
-
mode: literal("shared")
|
|
6593
|
-
}),
|
|
6594
|
-
strictObject({
|
|
6595
|
-
kind: literal("connector"),
|
|
6596
|
-
mode: literal("independent"),
|
|
6597
|
-
actions: array(strictObject({
|
|
6598
|
-
action: text,
|
|
6599
|
-
connectionId: text.optional()
|
|
6600
|
-
}))
|
|
6601
|
-
}),
|
|
6602
|
-
strictObject({
|
|
6603
|
-
kind: literal("connector"),
|
|
6604
|
-
actionHints: array(text).optional(),
|
|
6605
|
-
connectionHints: array(strictObject({
|
|
6606
|
-
action: text,
|
|
6607
|
-
connectionId: text,
|
|
6608
|
-
alias: text.optional()
|
|
6609
|
-
})).optional()
|
|
6610
|
-
})
|
|
6611
|
-
]);
|
|
6612
|
-
var inline = object({
|
|
6613
|
-
...ports,
|
|
6614
|
-
name: text,
|
|
6615
|
-
moduleId: text,
|
|
6616
|
-
capabilities: array(capability).optional()
|
|
6617
|
-
});
|
|
6618
|
-
var agentValue = union([object({
|
|
6619
|
-
kind: literal("value"),
|
|
6620
|
-
value: json
|
|
6621
|
-
}), object({
|
|
6622
|
-
kind: literal("input"),
|
|
6623
|
-
input: text
|
|
6624
|
-
})]);
|
|
6625
|
-
var agentInput$1 = union([agentValue, object({ kind: literal("model") })]);
|
|
6626
|
-
var managed = object({
|
|
6627
|
-
...ports,
|
|
6628
|
-
name: text,
|
|
6629
|
-
executor: union([
|
|
6630
|
-
object({
|
|
6631
|
-
kind: literal("connector"),
|
|
6632
|
-
action: text,
|
|
6633
|
-
connectionId: text.optional()
|
|
6634
|
-
}),
|
|
6635
|
-
object({
|
|
6636
|
-
kind: literal("openapi"),
|
|
6637
|
-
sourceUrl: text,
|
|
6638
|
-
method: text,
|
|
6639
|
-
path: text,
|
|
6640
|
-
serverUrl: text,
|
|
6641
|
-
document: json,
|
|
6642
|
-
auth: array(object({
|
|
6643
|
-
id: text,
|
|
6644
|
-
type: _enum([
|
|
6645
|
-
"bearer",
|
|
6646
|
-
"basic",
|
|
6647
|
-
"apiKey"
|
|
6648
|
-
]),
|
|
6649
|
-
name: text.optional(),
|
|
6650
|
-
in: _enum(["header", "query"]).optional()
|
|
6651
|
-
}))
|
|
6652
|
-
}),
|
|
6653
|
-
object({
|
|
6654
|
-
kind: literal("llm"),
|
|
6655
|
-
mode: _enum(["chat", "json"])
|
|
6656
|
-
}),
|
|
6657
|
-
object({
|
|
6658
|
-
kind: literal("agent"),
|
|
6659
|
-
code: boolean().optional(),
|
|
6660
|
-
model: text,
|
|
6661
|
-
prompt: text,
|
|
6662
|
-
maxRounds: number(),
|
|
6663
|
-
tools: array(object({
|
|
6664
|
-
id: text,
|
|
6665
|
-
name: text,
|
|
6666
|
-
description: text,
|
|
6667
|
-
action: text,
|
|
6668
|
-
connectionId: text.optional(),
|
|
6669
|
-
approval: boolean(),
|
|
6670
|
-
inputs: array(input.extend({ source: agentInput$1 }))
|
|
6671
|
-
})),
|
|
6672
|
-
notification: object({
|
|
6673
|
-
taskId: text,
|
|
6674
|
-
messageHandle: text,
|
|
6675
|
-
inputs: record(text, agentValue)
|
|
6676
|
-
}).optional()
|
|
6677
|
-
})
|
|
6678
|
-
])
|
|
6679
|
-
});
|
|
6680
|
-
var operand = union([object({
|
|
6681
|
-
kind: literal("value"),
|
|
6682
|
-
value: json.optional(),
|
|
6683
|
-
jsonSchema: json.optional()
|
|
6684
|
-
}), object({
|
|
6685
|
-
kind: literal("source"),
|
|
6686
|
-
source
|
|
6687
|
-
})]);
|
|
6688
|
-
var condition = {
|
|
6689
|
-
matchMode: _enum(["first", "all"]),
|
|
6690
|
-
cases: array(object({
|
|
6691
|
-
description: text.optional(),
|
|
6692
|
-
output: text,
|
|
6693
|
-
groups: array(object({ expressions: array(object({
|
|
6694
|
-
left: operand,
|
|
6695
|
-
operator: _enum([
|
|
6696
|
-
"!=",
|
|
6697
|
-
"<",
|
|
6698
|
-
"<=",
|
|
6699
|
-
"==",
|
|
6700
|
-
">",
|
|
6701
|
-
">=",
|
|
6702
|
-
"contains",
|
|
6703
|
-
"endsWith",
|
|
6704
|
-
"hasKey",
|
|
6705
|
-
"hasValue",
|
|
6706
|
-
"isEmpty",
|
|
6707
|
-
"isFalse",
|
|
6708
|
-
"isNotEmpty",
|
|
6709
|
-
"isNotNull",
|
|
6710
|
-
"isNull",
|
|
6711
|
-
"isTrue",
|
|
6712
|
-
"notContains",
|
|
6713
|
-
"notHasKey",
|
|
6714
|
-
"notHasValue",
|
|
6715
|
-
"startsWith"
|
|
6716
|
-
]),
|
|
6717
|
-
right: operand.optional()
|
|
6718
|
-
})) }))
|
|
6719
|
-
}))
|
|
6720
|
-
};
|
|
6721
|
-
var wait = {
|
|
6722
|
-
inputDefinitions: array(input),
|
|
6723
|
-
prompt: text
|
|
6724
|
-
};
|
|
6725
|
-
var webhookOptions = object({
|
|
6726
|
-
allowedMethods: never().optional(),
|
|
6727
|
-
allowedOrigins: strings.optional(),
|
|
6728
|
-
noResponseBody: never().optional(),
|
|
6729
|
-
responseData: text.optional(),
|
|
6730
|
-
responseHeaders: record(text, text).optional(),
|
|
6731
|
-
responseStatusCode: number().int().min(200).max(599).optional()
|
|
6732
|
-
});
|
|
6733
|
-
var webhook = {
|
|
6734
|
-
bodyFields: array(input),
|
|
6735
|
-
method: _enum(webhookMethods),
|
|
6736
|
-
options: webhookOptions.optional()
|
|
6737
|
-
};
|
|
6738
|
-
var definition = {
|
|
6739
|
-
configInputs: ports.inputs,
|
|
6740
|
-
definitionVersion: literal(2),
|
|
6741
|
-
description: text,
|
|
6742
|
-
displayName: text,
|
|
6743
|
-
key: text,
|
|
6744
|
-
name: text,
|
|
6745
|
-
outputs: array(port).refine((definitions) => new Set(definitions.map((output) => output.handle)).size === definitions.length, "Duplicate Trigger output handle."),
|
|
6746
|
-
provider: text
|
|
6747
|
-
};
|
|
6748
|
-
var endpoint = object({
|
|
6749
|
-
body: object({
|
|
6750
|
-
allowArray: boolean(),
|
|
6751
|
-
allowEmpty: boolean(),
|
|
6752
|
-
formats: array(_enum([
|
|
6753
|
-
"form",
|
|
6754
|
-
"json",
|
|
6755
|
-
"multipart",
|
|
6756
|
-
"text"
|
|
6757
|
-
]))
|
|
6758
|
-
}),
|
|
6759
|
-
methods: array(_enum([
|
|
6760
|
-
"DELETE",
|
|
6761
|
-
"GET",
|
|
6762
|
-
"HEAD",
|
|
6763
|
-
"PATCH",
|
|
6764
|
-
"POST",
|
|
6765
|
-
"PUT"
|
|
6766
|
-
])),
|
|
6767
|
-
successStatus: number()
|
|
6768
|
-
});
|
|
6769
|
-
var sourceFlowIds = array(text.min(1)).refine((ids) => new Set(ids).size === ids.length, "Duplicate source Flow ID.");
|
|
6770
|
-
var trigger = {
|
|
6771
|
-
name: text,
|
|
6772
|
-
description: text.optional(),
|
|
6773
|
-
icon: text.optional()
|
|
6774
|
-
};
|
|
6775
|
-
var base = {
|
|
6776
|
-
maxExecutions: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
6777
|
-
inputs,
|
|
6778
|
-
name: text.optional(),
|
|
6779
|
-
description: text.optional(),
|
|
6780
|
-
icon: text.optional(),
|
|
6781
|
-
timeoutMs: number().optional()
|
|
6782
|
-
};
|
|
6783
|
-
var node = union([
|
|
6784
|
-
object({
|
|
6785
|
-
...base,
|
|
6786
|
-
inputs: record(text, never()),
|
|
6787
|
-
kind: literal("condition"),
|
|
6788
|
-
...condition
|
|
6789
|
-
}),
|
|
6790
|
-
object({
|
|
6791
|
-
...base,
|
|
6792
|
-
inputs: unknown().transform(() => ({})).default({}),
|
|
6793
|
-
kind: literal("value"),
|
|
6794
|
-
values: array(input)
|
|
6795
|
-
}),
|
|
6796
|
-
object({
|
|
6797
|
-
...base,
|
|
6798
|
-
kind: literal("subflow"),
|
|
6799
|
-
subflowId: text
|
|
6800
|
-
}),
|
|
6801
|
-
object({
|
|
6802
|
-
...base,
|
|
6803
|
-
kind: literal("task"),
|
|
6804
|
-
task: inline,
|
|
6805
|
-
additionalInputs: array(input).optional()
|
|
6806
|
-
}),
|
|
6807
|
-
object({
|
|
6808
|
-
...base,
|
|
6809
|
-
kind: literal("task"),
|
|
6810
|
-
taskId: text,
|
|
6811
|
-
additionalInputs: array(input).optional()
|
|
6812
|
-
}),
|
|
6813
|
-
strictObject({
|
|
6814
|
-
...base,
|
|
6815
|
-
kind: literal("approval"),
|
|
6816
|
-
...wait
|
|
6817
|
-
}).omit({ timeoutMs: true }),
|
|
6818
|
-
strictObject({
|
|
6819
|
-
...base,
|
|
6820
|
-
kind: literal("wait"),
|
|
6821
|
-
...wait
|
|
6822
|
-
}).omit({ timeoutMs: true }),
|
|
6823
|
-
object({
|
|
6824
|
-
...trigger,
|
|
6825
|
-
kind: literal("manual")
|
|
6826
|
-
}),
|
|
6827
|
-
strictObject({
|
|
6828
|
-
...trigger,
|
|
6829
|
-
kind: literal("error"),
|
|
6830
|
-
sourceFlowIds: sourceFlowIds.optional()
|
|
6831
|
-
}),
|
|
6832
|
-
object({
|
|
6833
|
-
...trigger,
|
|
6834
|
-
kind: literal("webhook"),
|
|
6835
|
-
...webhook
|
|
6836
|
-
}),
|
|
6837
|
-
object({
|
|
6838
|
-
...trigger,
|
|
6839
|
-
kind: literal("cron"),
|
|
6840
|
-
cronTimes: triggerScheduleSchema
|
|
6841
|
-
}),
|
|
6842
|
-
object({
|
|
6843
|
-
...trigger,
|
|
6844
|
-
kind: literal("poll"),
|
|
6845
|
-
connectionId: text.min(1).optional(),
|
|
6846
|
-
config: record(text, fixedInput),
|
|
6847
|
-
definition: object({
|
|
6848
|
-
...definition,
|
|
6849
|
-
type: literal("poll")
|
|
6850
|
-
}),
|
|
6851
|
-
pollTimes: triggerScheduleSchema
|
|
6852
|
-
}),
|
|
6853
|
-
object({
|
|
6854
|
-
...trigger,
|
|
6855
|
-
kind: literal("integration"),
|
|
6856
|
-
connectionId: text.min(1).optional(),
|
|
6857
|
-
config: record(text, fixedInput),
|
|
6858
|
-
definition: object({
|
|
6859
|
-
...definition,
|
|
6860
|
-
type: literal("integration"),
|
|
6861
|
-
endpoint
|
|
6862
|
-
})
|
|
6863
|
-
})
|
|
6864
|
-
]);
|
|
6865
|
-
var target = union([object({ kind: literal("flow") }), object({
|
|
6866
|
-
kind: literal("subflow"),
|
|
6867
|
-
id: text
|
|
6868
|
-
})]);
|
|
6869
|
-
var edge = object({
|
|
6870
|
-
source: text,
|
|
6871
|
-
target: text,
|
|
6872
|
-
sourceHandle: text.optional()
|
|
6873
|
-
});
|
|
6874
|
-
var at = {
|
|
6875
|
-
nodeId: text,
|
|
6876
|
-
target
|
|
6877
|
-
};
|
|
6878
|
-
var subflow = object({
|
|
6879
|
-
name: text,
|
|
6880
|
-
inputs: array(input),
|
|
6881
|
-
outputs: array(port.extend({ sources: array(union([nodeSource, flowSource])) }))
|
|
6882
|
-
});
|
|
6883
|
-
var graph = object({
|
|
6884
|
-
nodes: record(text, node),
|
|
6885
|
-
edges: array(edge).default([])
|
|
6886
|
-
});
|
|
6887
|
-
var binding = object({
|
|
6888
|
-
kind: literal("variable"),
|
|
6889
|
-
target: text
|
|
6890
|
-
});
|
|
6891
|
-
var module = object({
|
|
6892
|
-
name: text,
|
|
6893
|
-
imports: strings,
|
|
6894
|
-
source: text
|
|
6895
|
-
});
|
|
6896
|
-
var document = object({
|
|
6897
|
-
bindings: record(text, binding),
|
|
6898
|
-
graph,
|
|
6899
|
-
subflows: record(text, subflow.extend({ graph })),
|
|
6900
|
-
tasks: record(text, managed)
|
|
6901
|
-
});
|
|
6902
|
-
object({
|
|
6903
|
-
modelVersion: union([
|
|
6904
|
-
literal(2),
|
|
6905
|
-
literal(4),
|
|
6906
|
-
literal(5)
|
|
6907
|
-
]),
|
|
6908
|
-
document,
|
|
6909
|
-
modules: record(text, module)
|
|
6910
|
-
}).extend({
|
|
6911
|
-
kind: literal("open-flow-flow-revision"),
|
|
6912
|
-
version: literal(1)
|
|
6913
|
-
});
|
|
6914
|
-
var shapes = {
|
|
6915
|
-
"graph.trigger.sources.set": {
|
|
6916
|
-
nodeId: text,
|
|
6917
|
-
before: sourceFlowIds.optional(),
|
|
6918
|
-
value: sourceFlowIds.optional()
|
|
6919
|
-
},
|
|
6920
|
-
"binding.create": {
|
|
6921
|
-
bindingId: text,
|
|
6922
|
-
binding
|
|
6923
|
-
},
|
|
6924
|
-
"binding.delete": { bindingId: text },
|
|
6925
|
-
"binding.target.set": {
|
|
6926
|
-
bindingId: text,
|
|
6927
|
-
before: text,
|
|
6928
|
-
value: text
|
|
6929
|
-
},
|
|
6930
|
-
"graph.edge.connect": {
|
|
6931
|
-
target,
|
|
6932
|
-
edge
|
|
6933
|
-
},
|
|
6934
|
-
"graph.edge.disconnect": {
|
|
6935
|
-
target,
|
|
6936
|
-
edge
|
|
6937
|
-
},
|
|
6938
|
-
"graph.node.create": {
|
|
6939
|
-
...at,
|
|
6940
|
-
node
|
|
6941
|
-
},
|
|
6942
|
-
"graph.node.delete": at,
|
|
6943
|
-
"graph.node.field.set": union([
|
|
6944
|
-
object({
|
|
6945
|
-
...at,
|
|
6946
|
-
kind: literal("graph.node.field.set"),
|
|
6947
|
-
field: literal("connectionId"),
|
|
6948
|
-
before: text.min(1).optional(),
|
|
6949
|
-
value: text.min(1).optional()
|
|
6950
|
-
}),
|
|
6951
|
-
object({
|
|
6952
|
-
...at,
|
|
6953
|
-
kind: literal("graph.node.field.set"),
|
|
6954
|
-
field: _enum([
|
|
6955
|
-
"description",
|
|
6956
|
-
"icon",
|
|
6957
|
-
"name"
|
|
6958
|
-
]),
|
|
6959
|
-
before: text.optional(),
|
|
6960
|
-
value: text.optional()
|
|
6961
|
-
}),
|
|
6962
|
-
object({
|
|
6963
|
-
...at,
|
|
6964
|
-
kind: literal("graph.node.field.set"),
|
|
6965
|
-
field: literal("maxExecutions"),
|
|
6966
|
-
before: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
6967
|
-
value: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional()
|
|
6968
|
-
}),
|
|
6969
|
-
object({
|
|
6970
|
-
...at,
|
|
6971
|
-
kind: literal("graph.node.field.set"),
|
|
6972
|
-
field: literal("timeoutMs"),
|
|
6973
|
-
before: number().optional(),
|
|
6974
|
-
value: number().optional()
|
|
6975
|
-
})
|
|
6976
|
-
]),
|
|
6977
|
-
"graph.node.input.set": {
|
|
6978
|
-
...at,
|
|
6979
|
-
handle: text,
|
|
6980
|
-
before: mapping.optional(),
|
|
6981
|
-
value: mapping.optional()
|
|
6982
|
-
},
|
|
6983
|
-
"graph.node.additional-inputs.set": {
|
|
6984
|
-
...at,
|
|
6985
|
-
before: array(input).optional(),
|
|
6986
|
-
value: array(input).optional()
|
|
6987
|
-
},
|
|
6988
|
-
"graph.node.condition.set": {
|
|
6989
|
-
...at,
|
|
6990
|
-
before: object(condition),
|
|
6991
|
-
value: object(condition)
|
|
6992
|
-
},
|
|
6993
|
-
"graph.node.values.set": {
|
|
6994
|
-
...at,
|
|
6995
|
-
before: array(input),
|
|
6996
|
-
value: array(input)
|
|
6997
|
-
},
|
|
6998
|
-
"graph.node.resolution.set": {
|
|
6999
|
-
...at,
|
|
7000
|
-
target: object({ kind: literal("flow") }),
|
|
7001
|
-
before: object(wait),
|
|
7002
|
-
value: object(wait)
|
|
7003
|
-
},
|
|
7004
|
-
"graph.node.webhook.set": {
|
|
7005
|
-
...at,
|
|
7006
|
-
target: object({ kind: literal("flow") }),
|
|
7007
|
-
before: object(webhook),
|
|
7008
|
-
value: object(webhook)
|
|
7009
|
-
},
|
|
7010
|
-
"graph.node.task.ports.set": {
|
|
7011
|
-
...at,
|
|
7012
|
-
before: object(ports),
|
|
7013
|
-
value: object(ports)
|
|
7014
|
-
},
|
|
7015
|
-
"graph.node.task.name.set": {
|
|
7016
|
-
...at,
|
|
7017
|
-
before: text,
|
|
7018
|
-
value: text
|
|
7019
|
-
},
|
|
7020
|
-
"graph.node.task.capabilities.set": {
|
|
7021
|
-
...at,
|
|
7022
|
-
before: array(capability).optional(),
|
|
7023
|
-
value: array(capability).optional()
|
|
7024
|
-
},
|
|
7025
|
-
"graph.trigger.config.set": {
|
|
7026
|
-
nodeId: text,
|
|
7027
|
-
name: text,
|
|
7028
|
-
before: fixedInput.optional(),
|
|
7029
|
-
value: fixedInput.optional()
|
|
7030
|
-
},
|
|
7031
|
-
"graph.trigger.schedule.set": {
|
|
7032
|
-
nodeId: text,
|
|
7033
|
-
before: triggerScheduleSchema,
|
|
7034
|
-
value: triggerScheduleSchema
|
|
7035
|
-
},
|
|
7036
|
-
"module.create": {
|
|
7037
|
-
moduleId: text,
|
|
7038
|
-
module
|
|
7039
|
-
},
|
|
7040
|
-
"module.delete": { moduleId: text },
|
|
7041
|
-
"module.rename": {
|
|
7042
|
-
moduleId: text,
|
|
7043
|
-
before: text,
|
|
7044
|
-
name: text
|
|
7045
|
-
},
|
|
7046
|
-
"module.source.replace": {
|
|
7047
|
-
moduleId: text,
|
|
7048
|
-
beforeImports: strings,
|
|
7049
|
-
beforeSource: text,
|
|
7050
|
-
imports: strings,
|
|
7051
|
-
source: text
|
|
7052
|
-
},
|
|
7053
|
-
"subflow.create": {
|
|
7054
|
-
subflowId: text,
|
|
7055
|
-
subflow: subflow.extend({ graph })
|
|
7056
|
-
},
|
|
7057
|
-
"subflow.definition.set": {
|
|
7058
|
-
subflowId: text,
|
|
7059
|
-
before: subflow,
|
|
7060
|
-
definition: subflow
|
|
7061
|
-
},
|
|
7062
|
-
"subflow.delete": { subflowId: text },
|
|
7063
|
-
"task.create": {
|
|
7064
|
-
taskId: text,
|
|
7065
|
-
task: managed
|
|
7066
|
-
},
|
|
7067
|
-
"task.delete": { taskId: text },
|
|
7068
|
-
"task.connector.connection.set": {
|
|
7069
|
-
taskId: text,
|
|
7070
|
-
before: text.optional(),
|
|
7071
|
-
value: text.optional()
|
|
7072
|
-
},
|
|
7073
|
-
"task.openapi.set": {
|
|
7074
|
-
taskId: text,
|
|
7075
|
-
before: managed,
|
|
7076
|
-
value: managed
|
|
7077
|
-
},
|
|
7078
|
-
"task.agent.set": {
|
|
7079
|
-
taskId: text,
|
|
7080
|
-
before: managed,
|
|
7081
|
-
value: managed
|
|
7082
|
-
},
|
|
7083
|
-
"task.llm.mode.set": {
|
|
7084
|
-
taskId: text,
|
|
7085
|
-
before: _enum(["chat", "json"]),
|
|
7086
|
-
value: _enum(["chat", "json"])
|
|
7087
|
-
},
|
|
7088
|
-
"task.name.set": {
|
|
7089
|
-
taskId: text,
|
|
7090
|
-
before: text,
|
|
7091
|
-
value: text
|
|
7092
|
-
}
|
|
7093
|
-
};
|
|
7094
|
-
array(union([...new Map(Object.entries(shapes).map(([kind, shape]) => [kind, shape instanceof ZodType ? shape : object({
|
|
7095
|
-
kind: literal(kind),
|
|
7096
|
-
...shape
|
|
7097
|
-
})])).values()])).min(1);
|
|
7098
|
-
//#endregion
|
|
7099
|
-
//#region src/flow/common/condition.ts
|
|
7100
|
-
var otherwiseOutput = "otherwise";
|
|
7101
|
-
var conditionOperators = [
|
|
7102
|
-
"==",
|
|
7103
|
-
"!=",
|
|
7104
|
-
"<",
|
|
7105
|
-
"<=",
|
|
7106
|
-
">",
|
|
7107
|
-
">=",
|
|
7108
|
-
"contains",
|
|
7109
|
-
"notContains",
|
|
7110
|
-
"startsWith",
|
|
7111
|
-
"endsWith",
|
|
7112
|
-
"hasKey",
|
|
7113
|
-
"notHasKey",
|
|
7114
|
-
"hasValue",
|
|
7115
|
-
"notHasValue",
|
|
7116
|
-
"isEmpty",
|
|
7117
|
-
"isNotEmpty",
|
|
7118
|
-
"isNull",
|
|
7119
|
-
"isNotNull",
|
|
7120
|
-
"isTrue",
|
|
7121
|
-
"isFalse"
|
|
7122
|
-
];
|
|
7123
|
-
var unaryOperator = (operator) => operator.startsWith("is");
|
|
7124
|
-
var operandHandle = (caseIndex, groupIndex, expressionIndex, side) => `${caseIndex}/${groupIndex}/${expressionIndex}/${side}`;
|
|
7125
|
-
/** Derived addresses let operand bindings use the ordinary input analysis and editor. Never persisted as node inputs. */
|
|
7126
|
-
function conditionOperands(node) {
|
|
7127
|
-
return node.cases.flatMap((item, c) => item.groups.flatMap((group, g) => group.expressions.flatMap((expression, e) => [{
|
|
7128
|
-
handle: operandHandle(c, g, e, "left"),
|
|
7129
|
-
operand: expression.left,
|
|
7130
|
-
expression,
|
|
7131
|
-
side: "left"
|
|
7132
|
-
}, ...!unaryOperator(expression.operator) ? [{
|
|
7133
|
-
handle: operandHandle(c, g, e, "right"),
|
|
7134
|
-
operand: expression.right ?? { kind: "value" },
|
|
7135
|
-
expression,
|
|
7136
|
-
side: "right"
|
|
7137
|
-
}] : []])));
|
|
7138
|
-
}
|
|
7139
|
-
function nodeInputMappings(node) {
|
|
7140
|
-
if (node.kind != "condition") return "inputs" in node ? node.inputs : {};
|
|
7141
|
-
return Object.fromEntries(conditionOperands(node).flatMap(({ handle, operand }) => operand.kind == "source" ? [[handle, {
|
|
7142
|
-
kind: "sources",
|
|
7143
|
-
sources: [operand.source]
|
|
7144
|
-
}]] : operand.value === void 0 ? [] : [[handle, {
|
|
7145
|
-
kind: "value",
|
|
7146
|
-
value: operand.value
|
|
7147
|
-
}]]));
|
|
7148
|
-
}
|
|
7149
|
-
function conditionInputPorts(node) {
|
|
7150
|
-
return Object.fromEntries(conditionOperands(node).map(({ handle, operand }) => [handle, {
|
|
7151
|
-
jsonSchema: operand.kind === "value" ? operand.jsonSchema ?? {} : {},
|
|
7152
|
-
nullable: operand.kind === "value" ? operand.value === null : true
|
|
7153
|
-
}]));
|
|
7154
|
-
}
|
|
7155
|
-
function valueType(value) {
|
|
7156
|
-
return value === null ? "null" : Array.isArray(value) ? "array" : typeof value;
|
|
7157
|
-
}
|
|
7158
|
-
function operatorsForType(type) {
|
|
7159
|
-
if (type == null) return conditionOperators;
|
|
7160
|
-
return [
|
|
7161
|
-
"==",
|
|
7162
|
-
"!=",
|
|
7163
|
-
...{
|
|
7164
|
-
number: [
|
|
7165
|
-
"<",
|
|
7166
|
-
"<=",
|
|
7167
|
-
">",
|
|
7168
|
-
">="
|
|
7169
|
-
],
|
|
7170
|
-
integer: [
|
|
7171
|
-
"<",
|
|
7172
|
-
"<=",
|
|
7173
|
-
">",
|
|
7174
|
-
">="
|
|
7175
|
-
],
|
|
7176
|
-
string: [
|
|
7177
|
-
"contains",
|
|
7178
|
-
"notContains",
|
|
7179
|
-
"startsWith",
|
|
7180
|
-
"endsWith",
|
|
7181
|
-
"isEmpty",
|
|
7182
|
-
"isNotEmpty"
|
|
7183
|
-
],
|
|
7184
|
-
array: [
|
|
7185
|
-
"contains",
|
|
7186
|
-
"notContains",
|
|
7187
|
-
"isEmpty",
|
|
7188
|
-
"isNotEmpty"
|
|
7189
|
-
],
|
|
7190
|
-
object: [
|
|
7191
|
-
"hasKey",
|
|
7192
|
-
"notHasKey",
|
|
7193
|
-
"hasValue",
|
|
7194
|
-
"notHasValue",
|
|
7195
|
-
"isEmpty",
|
|
7196
|
-
"isNotEmpty"
|
|
7197
|
-
],
|
|
7198
|
-
boolean: ["isTrue", "isFalse"],
|
|
7199
|
-
null: []
|
|
7200
|
-
}[type] ?? [],
|
|
7201
|
-
"isNull",
|
|
7202
|
-
"isNotNull"
|
|
7203
|
-
];
|
|
7204
|
-
}
|
|
7205
|
-
var normalized = (type) => type == "integer" ? "number" : type;
|
|
7206
|
-
function comparisonIssue(operator, leftType, rightType) {
|
|
7207
|
-
if (leftType != null && !operatorsForType(leftType).includes(operator)) return {
|
|
7208
|
-
target: "operator",
|
|
7209
|
-
message: `Operator ${operator} is not compatible with ${leftType}.`
|
|
7210
|
-
};
|
|
7211
|
-
if (unaryOperator(operator) || rightType == null) return;
|
|
7212
|
-
const required = [
|
|
7213
|
-
"<",
|
|
7214
|
-
"<=",
|
|
7215
|
-
">",
|
|
7216
|
-
">="
|
|
7217
|
-
].includes(operator) ? "number" : [
|
|
7218
|
-
"startsWith",
|
|
7219
|
-
"endsWith",
|
|
7220
|
-
"hasKey",
|
|
7221
|
-
"notHasKey"
|
|
7222
|
-
].includes(operator) || ["contains", "notContains"].includes(operator) && leftType == "string" ? "string" : ["==", "!="].includes(operator) ? normalized(leftType) : void 0;
|
|
7223
|
-
if (required != null && required != normalized(rightType)) return {
|
|
7224
|
-
target: "right",
|
|
7225
|
-
message: `Operator ${operator} requires a ${required} right operand.`
|
|
7226
|
-
};
|
|
7227
|
-
}
|
|
7228
|
-
function compareCondition(operator, left, right) {
|
|
7229
|
-
if (!unaryOperator(operator) && right === void 0) throw new Error("Condition right operand is missing.");
|
|
7230
|
-
const issue = comparisonIssue(operator, valueType(left), right === void 0 ? void 0 : valueType(right));
|
|
7231
|
-
if (issue != null) throw new Error(issue.message);
|
|
7232
|
-
switch (operator) {
|
|
7233
|
-
case "==": return dequal(left, right);
|
|
7234
|
-
case "!=": return !dequal(left, right);
|
|
7235
|
-
case "<": return left < right;
|
|
7236
|
-
case "<=": return left <= right;
|
|
7237
|
-
case ">": return left > right;
|
|
7238
|
-
case ">=": return left >= right;
|
|
7239
|
-
case "contains":
|
|
7240
|
-
case "notContains": {
|
|
7241
|
-
const contains = typeof left == "string" ? left.includes(right) : left.some((item) => dequal(item, right));
|
|
7242
|
-
return operator == "contains" ? contains : !contains;
|
|
7243
|
-
}
|
|
7244
|
-
case "startsWith": return left.startsWith(right);
|
|
7245
|
-
case "endsWith": return left.endsWith(right);
|
|
7246
|
-
case "hasKey":
|
|
7247
|
-
case "notHasKey": {
|
|
7248
|
-
const has = Object.hasOwn(left, right);
|
|
7249
|
-
return operator == "hasKey" ? has : !has;
|
|
7250
|
-
}
|
|
7251
|
-
case "hasValue":
|
|
7252
|
-
case "notHasValue": {
|
|
7253
|
-
const has = Object.values(left).some((item) => dequal(item, right));
|
|
7254
|
-
return operator == "hasValue" ? has : !has;
|
|
7255
|
-
}
|
|
7256
|
-
case "isEmpty":
|
|
7257
|
-
case "isNotEmpty": {
|
|
7258
|
-
const empty = typeof left == "string" || Array.isArray(left) ? left.length == 0 : Object.keys(left).length == 0;
|
|
7259
|
-
return operator == "isEmpty" ? empty : !empty;
|
|
7260
|
-
}
|
|
7261
|
-
case "isNull": return left === null;
|
|
7262
|
-
case "isNotNull": return left !== null;
|
|
7263
|
-
case "isTrue": return left === true;
|
|
7264
|
-
case "isFalse": return left === false;
|
|
7265
|
-
}
|
|
7266
|
-
}
|
|
7267
|
-
function selectConditionBranches(node, values) {
|
|
7268
|
-
for (const { handle } of conditionOperands(node)) if (!Object.hasOwn(values, handle)) throw new Error(`Condition operand ${handle} is missing.`);
|
|
7269
|
-
const results = node.cases.map((item, c) => {
|
|
7270
|
-
if (item.groups.length == 0) throw new Error("Condition Case requires a group.");
|
|
7271
|
-
return item.groups.map((group, g) => {
|
|
7272
|
-
if (group.expressions.length == 0) throw new Error("Condition group requires an expression.");
|
|
7273
|
-
return group.expressions.map((expression, e) => {
|
|
7274
|
-
const left = values[operandHandle(c, g, e, "left")];
|
|
7275
|
-
const right = unaryOperator(expression.operator) ? void 0 : values[operandHandle(c, g, e, "right")];
|
|
7276
|
-
const issue = comparisonIssue(expression.operator, valueType(left), right === void 0 ? void 0 : valueType(right));
|
|
7277
|
-
if (issue != null || !unaryOperator(expression.operator) && right === void 0) throw new Error(issue?.message ?? "Condition right operand is missing.");
|
|
7278
|
-
return () => compareCondition(expression.operator, left, right);
|
|
7279
|
-
});
|
|
7280
|
-
});
|
|
7281
|
-
});
|
|
7282
|
-
const selected = [];
|
|
7283
|
-
for (const [index, groups] of results.entries()) {
|
|
7284
|
-
if (!groups.some((expressions) => expressions.every((evaluate) => evaluate()))) continue;
|
|
7285
|
-
selected.push(node.cases[index].output);
|
|
7286
|
-
if (node.matchMode == "first") break;
|
|
7287
|
-
}
|
|
7288
|
-
return selected.length == 0 ? [otherwiseOutput] : selected;
|
|
7289
|
-
}
|
|
7290
|
-
//#endregion
|
|
7291
|
-
//#region src/flow/common/change.ts
|
|
7292
|
-
function portsByHandle(ports) {
|
|
7293
|
-
return Object.fromEntries(ports.flatMap((port) => "handle" in port ? [[port.handle, port]] : []));
|
|
7294
|
-
}
|
|
7295
|
-
//#endregion
|
|
7296
|
-
//#region src/json-schema-subset/utils.ts
|
|
7297
|
-
var nextId = 0;
|
|
7298
|
-
function createId() {
|
|
7299
|
-
const id = nextId;
|
|
7300
|
-
nextId += 1;
|
|
7301
|
-
return id;
|
|
7302
|
-
}
|
|
7303
|
-
function deepFreeze(target) {
|
|
7304
|
-
if (typeof target === "object" && target !== null && !Object.isFrozen(target)) {
|
|
7305
|
-
for (const key of Object.getOwnPropertyNames(target)) deepFreeze(Reflect.get(target, key));
|
|
7306
|
-
Object.freeze(target);
|
|
7307
|
-
}
|
|
7308
|
-
return target;
|
|
7309
|
-
}
|
|
7310
|
-
function pick(target, keys) {
|
|
7311
|
-
const newTarget = {};
|
|
7312
|
-
for (const key of keys) if (key in target) newTarget[key] = target[key];
|
|
7313
|
-
return newTarget;
|
|
7314
|
-
}
|
|
7315
|
-
function deepCopy(value) {
|
|
7316
|
-
if (typeof value !== "object" || value === null) return value;
|
|
7317
|
-
else if (Array.isArray(value)) {
|
|
7318
|
-
const array = [];
|
|
7319
|
-
for (const [i, element] of value.entries()) array[i] = deepCopy(element);
|
|
7320
|
-
return array;
|
|
7321
|
-
} else {
|
|
7322
|
-
const newObject = {};
|
|
7323
|
-
for (const key in value) newObject[key] = deepCopy(value[key]);
|
|
7324
|
-
return newObject;
|
|
7325
|
-
}
|
|
7326
|
-
}
|
|
7327
|
-
function isDeepEquals(value1, value2) {
|
|
7328
|
-
if (value1 === value2) return true;
|
|
7329
|
-
if (value1 === null) return false;
|
|
7330
|
-
if (typeof value1 !== "object") return false;
|
|
7331
|
-
if (typeof value1 !== typeof value2) return false;
|
|
7332
|
-
if (Array.isArray(value1)) {
|
|
7333
|
-
if (!Array.isArray(value2)) return false;
|
|
7334
|
-
if (value1.length !== value2.length) return false;
|
|
7335
|
-
for (const [i, value1Element] of value1.entries()) if (!isDeepEquals(value1Element, value2[i])) return false;
|
|
7336
|
-
} else {
|
|
7337
|
-
if (Array.isArray(value2)) return false;
|
|
7338
|
-
for (const key in value1) {
|
|
7339
|
-
if (!(key in value2)) return false;
|
|
7340
|
-
if (!isDeepEquals(value1[key], value2[key])) return false;
|
|
7341
|
-
}
|
|
7342
|
-
for (const key in value2) if (!(key in value1)) return false;
|
|
7343
|
-
}
|
|
7344
|
-
return true;
|
|
7345
|
-
}
|
|
7346
|
-
//#endregion
|
|
7347
|
-
//#region src/json-schema-subset/expression/result.ts
|
|
7348
|
-
var ExpressionSingleResult = Object.freeze({
|
|
7349
|
-
Equals: 0,
|
|
7350
|
-
Containing: 1,
|
|
7351
|
-
ContainedBy: 2,
|
|
7352
|
-
Rejection: 3,
|
|
7353
|
-
Intersection: 4
|
|
7354
|
-
});
|
|
7355
|
-
var ExpressionEquals = toExpression(ExpressionSingleResult.Equals);
|
|
7356
|
-
var ExpressionContaining = toExpression(ExpressionSingleResult.Containing);
|
|
7357
|
-
var ExpressionContainedBy = toExpression(ExpressionSingleResult.ContainedBy);
|
|
7358
|
-
var ExpressionRejection = toExpression(ExpressionSingleResult.Rejection);
|
|
7359
|
-
var ExpressionIntersection = toExpression(ExpressionSingleResult.Intersection);
|
|
7360
|
-
var ExpressionMaskList = deepFreeze([
|
|
7361
|
-
[ExpressionSingleResult.Equals, ExpressionEquals],
|
|
7362
|
-
[ExpressionSingleResult.Containing, ExpressionContaining],
|
|
7363
|
-
[ExpressionSingleResult.ContainedBy, ExpressionContainedBy],
|
|
7364
|
-
[ExpressionSingleResult.Rejection, ExpressionRejection],
|
|
7365
|
-
[ExpressionSingleResult.Intersection, ExpressionIntersection]
|
|
6642
|
+
var ExpressionEquals = toExpression(ExpressionSingleResult.Equals);
|
|
6643
|
+
var ExpressionContaining = toExpression(ExpressionSingleResult.Containing);
|
|
6644
|
+
var ExpressionContainedBy = toExpression(ExpressionSingleResult.ContainedBy);
|
|
6645
|
+
var ExpressionRejection = toExpression(ExpressionSingleResult.Rejection);
|
|
6646
|
+
var ExpressionIntersection = toExpression(ExpressionSingleResult.Intersection);
|
|
6647
|
+
var ExpressionMaskList = deepFreeze([
|
|
6648
|
+
[ExpressionSingleResult.Equals, ExpressionEquals],
|
|
6649
|
+
[ExpressionSingleResult.Containing, ExpressionContaining],
|
|
6650
|
+
[ExpressionSingleResult.ContainedBy, ExpressionContainedBy],
|
|
6651
|
+
[ExpressionSingleResult.Rejection, ExpressionRejection],
|
|
6652
|
+
[ExpressionSingleResult.Intersection, ExpressionIntersection]
|
|
7366
6653
|
]);
|
|
7367
6654
|
var ExpressionAny = (() => {
|
|
7368
6655
|
let expression = 0;
|
|
@@ -8896,1184 +8183,2098 @@ function splitRangeGreaterBranch(range1, range2) {
|
|
|
8896
8183
|
fromLeft: true,
|
|
8897
8184
|
range: range1
|
|
8898
8185
|
}
|
|
8899
|
-
};
|
|
8186
|
+
};
|
|
8187
|
+
}
|
|
8188
|
+
if (max2.num <= max1.num) {
|
|
8189
|
+
let hasRight = true;
|
|
8190
|
+
let isRightRangeOverride = false;
|
|
8191
|
+
if (max1.num === max2.num) {
|
|
8192
|
+
const exclusive1 = max2.exclusive;
|
|
8193
|
+
const exclusive2 = max1.exclusive;
|
|
8194
|
+
hasRight = exclusive1 !== exclusive2;
|
|
8195
|
+
isRightRangeOverride = !exclusive1 && exclusive2;
|
|
8196
|
+
}
|
|
8197
|
+
if (!isRightRangeOverride) {
|
|
8198
|
+
let right;
|
|
8199
|
+
if (hasRight) right = {
|
|
8200
|
+
fromLeft: true,
|
|
8201
|
+
range: [reversalExclusive(max2), max1]
|
|
8202
|
+
};
|
|
8203
|
+
return {
|
|
8204
|
+
left: {
|
|
8205
|
+
fromLeft: false,
|
|
8206
|
+
range: [min2, reversalExclusive(min1)]
|
|
8207
|
+
},
|
|
8208
|
+
center: [min1, max2],
|
|
8209
|
+
right
|
|
8210
|
+
};
|
|
8211
|
+
}
|
|
8212
|
+
}
|
|
8213
|
+
return {
|
|
8214
|
+
left: {
|
|
8215
|
+
fromLeft: false,
|
|
8216
|
+
range: [min2, reversalExclusive(min1)]
|
|
8217
|
+
},
|
|
8218
|
+
center: [min1, max1],
|
|
8219
|
+
right: {
|
|
8220
|
+
fromLeft: false,
|
|
8221
|
+
range: [reversalExclusive(max1), max2]
|
|
8222
|
+
}
|
|
8223
|
+
};
|
|
8224
|
+
}
|
|
8225
|
+
function splitRangeEqualsBranch(range1, range2) {
|
|
8226
|
+
const [min1, max1] = range1;
|
|
8227
|
+
const [min2, max2] = range2;
|
|
8228
|
+
const exclusive1 = min1.exclusive;
|
|
8229
|
+
const exclusive2 = min2.exclusive;
|
|
8230
|
+
let left;
|
|
8231
|
+
let centerBegin = min1;
|
|
8232
|
+
if (!exclusive1 && exclusive2) {
|
|
8233
|
+
centerBegin = min2;
|
|
8234
|
+
left = {
|
|
8235
|
+
fromLeft: true,
|
|
8236
|
+
range: [min1, reversalExclusive(min2)]
|
|
8237
|
+
};
|
|
8238
|
+
} else if (exclusive1 && !exclusive2) left = {
|
|
8239
|
+
fromLeft: false,
|
|
8240
|
+
range: [min2, reversalExclusive(min1)]
|
|
8241
|
+
};
|
|
8242
|
+
if (max1.num <= max2.num) {
|
|
8243
|
+
let hasRight = true;
|
|
8244
|
+
let isLeftRangeOverride = false;
|
|
8245
|
+
if (max1.num === max2.num) {
|
|
8246
|
+
const maxExclusive1 = max1.exclusive;
|
|
8247
|
+
const maxExclusive2 = max2.exclusive;
|
|
8248
|
+
hasRight = maxExclusive1 !== maxExclusive2;
|
|
8249
|
+
isLeftRangeOverride = !maxExclusive1 && maxExclusive2;
|
|
8250
|
+
}
|
|
8251
|
+
if (!isLeftRangeOverride) {
|
|
8252
|
+
let right;
|
|
8253
|
+
if (hasRight) right = {
|
|
8254
|
+
fromLeft: false,
|
|
8255
|
+
range: [reversalExclusive(max1), max2]
|
|
8256
|
+
};
|
|
8257
|
+
return {
|
|
8258
|
+
left,
|
|
8259
|
+
center: [centerBegin, max1],
|
|
8260
|
+
right
|
|
8261
|
+
};
|
|
8262
|
+
}
|
|
8263
|
+
}
|
|
8264
|
+
return {
|
|
8265
|
+
left,
|
|
8266
|
+
center: [centerBegin, max2],
|
|
8267
|
+
right: {
|
|
8268
|
+
fromLeft: true,
|
|
8269
|
+
range: [reversalExclusive(max2), max1]
|
|
8270
|
+
}
|
|
8271
|
+
};
|
|
8272
|
+
}
|
|
8273
|
+
function reversalExclusive(point) {
|
|
8274
|
+
return {
|
|
8275
|
+
num: point.num,
|
|
8276
|
+
exclusive: !point.exclusive
|
|
8277
|
+
};
|
|
8278
|
+
}
|
|
8279
|
+
//#endregion
|
|
8280
|
+
//#region src/json-schema-subset/checker/range.ts
|
|
8281
|
+
var createRangeSplitter = (undefinedMin) => (min1 = undefinedMin, max1 = Number.POSITIVE_INFINITY, min2 = undefinedMin, max2 = Number.POSITIVE_INFINITY) => {
|
|
8282
|
+
const { left, center, right } = splitRange$3([{
|
|
8283
|
+
num: min1,
|
|
8284
|
+
exclusive: false
|
|
8285
|
+
}, {
|
|
8286
|
+
num: max1,
|
|
8287
|
+
exclusive: false
|
|
8288
|
+
}], [{
|
|
8289
|
+
num: min2,
|
|
8290
|
+
exclusive: false
|
|
8291
|
+
}, {
|
|
8292
|
+
num: max2,
|
|
8293
|
+
exclusive: false
|
|
8294
|
+
}]);
|
|
8295
|
+
let leftItem;
|
|
8296
|
+
let rightItem;
|
|
8297
|
+
let intersectionItem;
|
|
8298
|
+
if (left) leftItem = {
|
|
8299
|
+
min: left.range[0].num,
|
|
8300
|
+
max: left.range[1].num,
|
|
8301
|
+
isFrom1: left.fromLeft
|
|
8302
|
+
};
|
|
8303
|
+
if (right) rightItem = {
|
|
8304
|
+
min: right.range[0].num,
|
|
8305
|
+
max: right.range[1].num,
|
|
8306
|
+
isFrom1: right.fromLeft
|
|
8307
|
+
};
|
|
8308
|
+
if (center) intersectionItem = {
|
|
8309
|
+
min: center[0].num,
|
|
8310
|
+
max: center[1].num
|
|
8311
|
+
};
|
|
8312
|
+
return {
|
|
8313
|
+
left: leftItem,
|
|
8314
|
+
right: rightItem,
|
|
8315
|
+
intersection: intersectionItem
|
|
8316
|
+
};
|
|
8317
|
+
};
|
|
8318
|
+
function toExpressionSingleResult({ left, right, intersection }) {
|
|
8319
|
+
if (!intersection) return ExpressionSingleResult.Rejection;
|
|
8320
|
+
let extra1 = false;
|
|
8321
|
+
let extra2 = false;
|
|
8322
|
+
if (left) {
|
|
8323
|
+
if (left.isFrom1) extra1 = true;
|
|
8324
|
+
else extra2 = true;
|
|
8325
|
+
}
|
|
8326
|
+
if (right) {
|
|
8327
|
+
if (right.isFrom1) extra1 = true;
|
|
8328
|
+
else extra2 = true;
|
|
8329
|
+
}
|
|
8330
|
+
if (extra1 && extra2) return ExpressionSingleResult.Intersection;
|
|
8331
|
+
if (extra1) return ExpressionSingleResult.Containing;
|
|
8332
|
+
if (extra2) return ExpressionSingleResult.ContainedBy;
|
|
8333
|
+
return ExpressionSingleResult.Equals;
|
|
8334
|
+
}
|
|
8335
|
+
//#endregion
|
|
8336
|
+
//#region src/json-schema-subset/checker/array.ts
|
|
8337
|
+
var splitRange$2 = createRangeSplitter(0);
|
|
8338
|
+
var quantum$1 = makeQuantum([
|
|
8339
|
+
"hasCommon",
|
|
8340
|
+
"hasExtra1",
|
|
8341
|
+
"hasExtra2",
|
|
8342
|
+
"hasRejection",
|
|
8343
|
+
"hasCommonBroken"
|
|
8344
|
+
]);
|
|
8345
|
+
function calculateArray({ calculate }, schema1, schema2) {
|
|
8346
|
+
const splitResult = splitRange$2(schema1.minItems, schema1.maxItems, schema2.minItems, schema2.maxItems);
|
|
8347
|
+
const splitExpression = toExpressionSingleResult(splitResult);
|
|
8348
|
+
if (splitExpression === ExpressionSingleResult.Rejection) return ExpressionRejection;
|
|
8349
|
+
const [items1, additionalItems1] = normalizeArray(schema1);
|
|
8350
|
+
const [items2, additionalItems2] = normalizeArray(schema2);
|
|
8351
|
+
const itemsLength = Math.max(items1.length, items2.length) + 1;
|
|
8352
|
+
const length = Math.min(itemsLength, splitResult.intersection.max);
|
|
8353
|
+
const quantumVariable = quantum$1.variable({});
|
|
8354
|
+
const minItems = Math.min(schema1.minItems ?? 0, schema2.minItems ?? 0);
|
|
8355
|
+
for (let i = 0; i < length; i++) {
|
|
8356
|
+
const expression = calculate(items1[i] ?? additionalItems1, items2[i] ?? additionalItems2);
|
|
8357
|
+
quantumVariable.push(expression, (singleExpression, variable) => {
|
|
8358
|
+
switch (singleExpression) {
|
|
8359
|
+
case ExpressionSingleResult.Equals:
|
|
8360
|
+
if (!variable.hasRejection) variable.hasCommon = true;
|
|
8361
|
+
break;
|
|
8362
|
+
case ExpressionSingleResult.Containing:
|
|
8363
|
+
if (!variable.hasRejection) variable.hasCommon = true;
|
|
8364
|
+
variable.hasExtra1 = true;
|
|
8365
|
+
break;
|
|
8366
|
+
case ExpressionSingleResult.ContainedBy:
|
|
8367
|
+
if (!variable.hasRejection) variable.hasCommon = true;
|
|
8368
|
+
variable.hasExtra2 = true;
|
|
8369
|
+
break;
|
|
8370
|
+
case ExpressionSingleResult.Intersection:
|
|
8371
|
+
if (!variable.hasRejection) variable.hasCommon = true;
|
|
8372
|
+
variable.hasExtra1 = true;
|
|
8373
|
+
variable.hasExtra2 = true;
|
|
8374
|
+
break;
|
|
8375
|
+
case ExpressionSingleResult.Rejection:
|
|
8376
|
+
if (i < minItems) variable.hasCommonBroken = true;
|
|
8377
|
+
variable.hasRejection = true;
|
|
8378
|
+
variable.hasExtra1 = true;
|
|
8379
|
+
variable.hasExtra2 = true;
|
|
8380
|
+
}
|
|
8381
|
+
});
|
|
8900
8382
|
}
|
|
8901
|
-
|
|
8902
|
-
|
|
8903
|
-
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
|
|
8907
|
-
|
|
8908
|
-
|
|
8383
|
+
quantumVariable.update((variable) => {
|
|
8384
|
+
switch (splitExpression) {
|
|
8385
|
+
case ExpressionSingleResult.Containing:
|
|
8386
|
+
variable.hasExtra1 = true;
|
|
8387
|
+
break;
|
|
8388
|
+
case ExpressionSingleResult.ContainedBy:
|
|
8389
|
+
variable.hasExtra2 = true;
|
|
8390
|
+
break;
|
|
8391
|
+
case ExpressionSingleResult.Intersection:
|
|
8392
|
+
variable.hasExtra1 = true;
|
|
8393
|
+
variable.hasExtra2 = true;
|
|
8909
8394
|
}
|
|
8910
|
-
if (!
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
|
|
8915
|
-
|
|
8916
|
-
return {
|
|
8917
|
-
left: {
|
|
8918
|
-
fromLeft: false,
|
|
8919
|
-
range: [min2, reversalExclusive(min1)]
|
|
8920
|
-
},
|
|
8921
|
-
center: [min1, max2],
|
|
8922
|
-
right
|
|
8923
|
-
};
|
|
8395
|
+
if (schema1.uniqueItems && !schema2.uniqueItems && (schema2.maxItems ?? Number.POSITIVE_INFINITY) > 1) variable.hasExtra2 = true;
|
|
8396
|
+
else if (!schema1.uniqueItems && schema2.uniqueItems && (schema1.maxItems ?? Number.POSITIVE_INFINITY) > 1) variable.hasExtra1 = true;
|
|
8397
|
+
if (schema1.maxItems === 0 || schema2.maxItems === 0) {
|
|
8398
|
+
variable.hasCommon = true;
|
|
8399
|
+
if (schema1.maxItems !== 0) variable.hasExtra1 = true;
|
|
8400
|
+
if (schema2.maxItems !== 0) variable.hasExtra2 = true;
|
|
8924
8401
|
}
|
|
8402
|
+
});
|
|
8403
|
+
let expression = 0;
|
|
8404
|
+
for (const { hasExtra1, hasExtra2, hasCommon, hasCommonBroken } of quantumVariable) {
|
|
8405
|
+
let finalHasCommon = hasCommon;
|
|
8406
|
+
if (hasCommonBroken) finalHasCommon = false;
|
|
8407
|
+
if (!finalHasCommon) expression |= ExpressionRejection;
|
|
8408
|
+
else if (hasExtra1 && hasExtra2) expression |= ExpressionIntersection;
|
|
8409
|
+
else if (hasExtra1) expression |= ExpressionContaining;
|
|
8410
|
+
else if (hasExtra2) expression |= ExpressionContainedBy;
|
|
8411
|
+
else expression |= ExpressionEquals;
|
|
8925
8412
|
}
|
|
8926
|
-
return
|
|
8927
|
-
left: {
|
|
8928
|
-
fromLeft: false,
|
|
8929
|
-
range: [min2, reversalExclusive(min1)]
|
|
8930
|
-
},
|
|
8931
|
-
center: [min1, max1],
|
|
8932
|
-
right: {
|
|
8933
|
-
fromLeft: false,
|
|
8934
|
-
range: [reversalExclusive(max1), max2]
|
|
8935
|
-
}
|
|
8936
|
-
};
|
|
8413
|
+
return expression;
|
|
8937
8414
|
}
|
|
8938
|
-
function
|
|
8939
|
-
|
|
8940
|
-
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
} else if (exclusive1 && !exclusive2) left = {
|
|
8952
|
-
fromLeft: false,
|
|
8953
|
-
range: [min2, reversalExclusive(min1)]
|
|
8415
|
+
function normalizeArray({ items, additionalItems }) {
|
|
8416
|
+
if (Array.isArray(items)) return [items, additionalItems ?? ANY];
|
|
8417
|
+
else return [[], items ?? ANY];
|
|
8418
|
+
}
|
|
8419
|
+
//#endregion
|
|
8420
|
+
//#region src/json-schema-subset/checker/cache.ts
|
|
8421
|
+
function wrapEqualsCheckerWithCache(check) {
|
|
8422
|
+
const map = /* @__PURE__ */ new Map();
|
|
8423
|
+
return (value1, value2) => {
|
|
8424
|
+
const isObject1 = isCompiledObject(value1);
|
|
8425
|
+
if (isObject1 !== isCompiledObject(value2)) return false;
|
|
8426
|
+
if (!isObject1) return value1 === value2;
|
|
8427
|
+
return getWithCache(map, value1, value2, check);
|
|
8954
8428
|
};
|
|
8955
|
-
|
|
8956
|
-
|
|
8957
|
-
|
|
8958
|
-
|
|
8959
|
-
|
|
8960
|
-
|
|
8961
|
-
|
|
8962
|
-
|
|
8429
|
+
}
|
|
8430
|
+
function wrapSchemaCalculatorWithCache(check) {
|
|
8431
|
+
const map = /* @__PURE__ */ new Map();
|
|
8432
|
+
return (schema1, schema2) => getWithCache(map, schema1, schema2, check);
|
|
8433
|
+
}
|
|
8434
|
+
function getWithCache(map, node1, node2, check) {
|
|
8435
|
+
const key = `${getId(node1)}/${getId(node2)}`;
|
|
8436
|
+
let result = map.get(key);
|
|
8437
|
+
if (result === void 0) map.set(key, result = check(node1, node2));
|
|
8438
|
+
return result;
|
|
8439
|
+
}
|
|
8440
|
+
//#endregion
|
|
8441
|
+
//#region src/json-schema-subset/checker/enumAndConst.ts
|
|
8442
|
+
function calculateEnumAndEnum(context, schema1, schema2) {
|
|
8443
|
+
const enumList1 = normalizeEnumList(schema1);
|
|
8444
|
+
const enumList2 = normalizeEnumList(schema2);
|
|
8445
|
+
let foundExtra1 = false;
|
|
8446
|
+
let foundExtra2 = false;
|
|
8447
|
+
let foundIntersection = false;
|
|
8448
|
+
for (const enum1 of enumList1) {
|
|
8449
|
+
if (hasEqualsEnum(context, enumList2, enum1)) foundIntersection = true;
|
|
8450
|
+
else foundExtra1 = true;
|
|
8451
|
+
if (foundExtra1 && foundIntersection) break;
|
|
8452
|
+
}
|
|
8453
|
+
for (const enum2 of enumList2) {
|
|
8454
|
+
if (hasEqualsEnum(context, enumList1, enum2)) foundIntersection = true;
|
|
8455
|
+
else foundExtra2 = true;
|
|
8456
|
+
if (foundExtra2 && foundIntersection) break;
|
|
8457
|
+
}
|
|
8458
|
+
if (!foundIntersection) return ExpressionRejection;
|
|
8459
|
+
if (foundExtra1 && foundExtra2) return ExpressionIntersection;
|
|
8460
|
+
if (foundExtra1) return ExpressionContaining;
|
|
8461
|
+
if (foundExtra2) return ExpressionContainedBy;
|
|
8462
|
+
return ExpressionEquals;
|
|
8463
|
+
}
|
|
8464
|
+
function calculateEnumAndSchema(enumSchema, schema) {
|
|
8465
|
+
let hasValid = false;
|
|
8466
|
+
let hasInvalid = false;
|
|
8467
|
+
for (const enumValue of normalizeEnumList(enumSchema)) {
|
|
8468
|
+
switch (valid(schema, enumValue)) {
|
|
8469
|
+
case ValidResult.Valid:
|
|
8470
|
+
hasValid = true;
|
|
8471
|
+
break;
|
|
8472
|
+
case ValidResult.Invalid:
|
|
8473
|
+
hasInvalid = true;
|
|
8474
|
+
break;
|
|
8475
|
+
case ValidResult.Unknown: return ExpressionAny;
|
|
8963
8476
|
}
|
|
8964
|
-
if (
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
|
|
8968
|
-
|
|
8969
|
-
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
8973
|
-
|
|
8974
|
-
|
|
8477
|
+
if (hasValid && hasInvalid) break;
|
|
8478
|
+
}
|
|
8479
|
+
if (hasValid && hasInvalid) return ExpressionIntersection;
|
|
8480
|
+
if (hasValid) return ExpressionEquals | ExpressionContainedBy;
|
|
8481
|
+
if (hasInvalid) return ExpressionRejection;
|
|
8482
|
+
if (getKind(schema) === CompiledKind.Never) return ExpressionEquals;
|
|
8483
|
+
return ExpressionContainedBy;
|
|
8484
|
+
}
|
|
8485
|
+
function normalizeEnumList({ const: constValue, enum: enumList }) {
|
|
8486
|
+
if (constValue !== void 0) return [constValue];
|
|
8487
|
+
if (enumList) return enumList;
|
|
8488
|
+
throw new Error("invalid branch");
|
|
8489
|
+
}
|
|
8490
|
+
function hasEqualsEnum({ isEquals }, enumList, checkedEnum) {
|
|
8491
|
+
for (const searchedEnum of enumList) if (isEquals(searchedEnum, checkedEnum)) return true;
|
|
8492
|
+
return false;
|
|
8493
|
+
}
|
|
8494
|
+
//#endregion
|
|
8495
|
+
//#region src/json-schema-subset/checker/equals.ts
|
|
8496
|
+
function schemaEqualsChecker(extendsContext) {
|
|
8497
|
+
function isSchemaEquals(schema1, schema2) {
|
|
8498
|
+
const isExtends1 = extendsContext.isExtendsSchema(schema1);
|
|
8499
|
+
const isExtends2 = extendsContext.isExtendsSchema(schema2);
|
|
8500
|
+
if (isExtends1 || isExtends2) return extendsContext.equals(schema1, schema2);
|
|
8501
|
+
else return isCompiledSchemaEquals(schema1, schema2);
|
|
8502
|
+
}
|
|
8503
|
+
const equalsMap = /* @__PURE__ */ new Map();
|
|
8504
|
+
function isCompiledSchemaEquals(schema1, schema2) {
|
|
8505
|
+
const id1 = getId(schema1);
|
|
8506
|
+
const id2 = getId(schema2);
|
|
8507
|
+
if (id1 === id2) return true;
|
|
8508
|
+
const key = `${id1}/${id2}`;
|
|
8509
|
+
let isEquals = equalsMap.get(key);
|
|
8510
|
+
if (isEquals === void 0) {
|
|
8511
|
+
isEquals = isObjectLikeEquals(schema1, schema2);
|
|
8512
|
+
equalsMap.set(key, isEquals);
|
|
8975
8513
|
}
|
|
8514
|
+
return isEquals;
|
|
8976
8515
|
}
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
8516
|
+
function isObjectLikeEquals(object1, object2) {
|
|
8517
|
+
if (Array.isArray(object1)) {
|
|
8518
|
+
if (!Array.isArray(object2)) return false;
|
|
8519
|
+
if (object1.length !== object2.length) return false;
|
|
8520
|
+
for (const [i, value1Element] of object1.entries()) if (!isValueEquals(value1Element, object2[i])) return false;
|
|
8521
|
+
} else {
|
|
8522
|
+
if (Array.isArray(object2)) return false;
|
|
8523
|
+
for (const key in object1) {
|
|
8524
|
+
if (!(key in object2)) return false;
|
|
8525
|
+
if (!isValueEquals(Reflect.get(object1, key), Reflect.get(object2, key))) return false;
|
|
8526
|
+
}
|
|
8527
|
+
for (const key in object2) if (!(key in object1)) return false;
|
|
8983
8528
|
}
|
|
8984
|
-
|
|
8529
|
+
return true;
|
|
8530
|
+
}
|
|
8531
|
+
function isValueEquals(value1, value2) {
|
|
8532
|
+
if (value1 === value2) return true;
|
|
8533
|
+
if (value1 === null) return false;
|
|
8534
|
+
if (typeof value1 !== "object") return false;
|
|
8535
|
+
if (typeof value1 !== typeof value2) return false;
|
|
8536
|
+
if (isCompiledSchema(value1) && isCompiledSchema(value2)) return isCompiledSchemaEquals(value1, value2);
|
|
8537
|
+
return isObjectLikeEquals(value1, value2);
|
|
8538
|
+
}
|
|
8539
|
+
return isSchemaEquals;
|
|
8985
8540
|
}
|
|
8986
|
-
|
|
8541
|
+
//#endregion
|
|
8542
|
+
//#region src/json-schema-subset/checker/numeric/integerNormalizer.ts
|
|
8543
|
+
function normalizeInteger(schema) {
|
|
8544
|
+
const floatRange = pickRange(schema);
|
|
8545
|
+
const multipleOf = schema.multipleOf ?? 1;
|
|
8546
|
+
const range = cutRange(floatRange, multipleOf);
|
|
8547
|
+
if (!range) return null;
|
|
8987
8548
|
return {
|
|
8988
|
-
|
|
8989
|
-
|
|
8549
|
+
multipleOf,
|
|
8550
|
+
range
|
|
8990
8551
|
};
|
|
8991
8552
|
}
|
|
8992
|
-
|
|
8993
|
-
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8553
|
+
function isPointRange([point1, point2]) {
|
|
8554
|
+
if (point1.num !== point2.num) return false;
|
|
8555
|
+
if (point1.exclusive) return false;
|
|
8556
|
+
if (point2.exclusive) return false;
|
|
8557
|
+
return true;
|
|
8558
|
+
}
|
|
8559
|
+
function cutRange(range, multipleOf) {
|
|
8560
|
+
if (!range) return;
|
|
8561
|
+
const [originMin, originMax] = range;
|
|
8562
|
+
let min = nextInteger(originMin.num, multipleOf);
|
|
8563
|
+
let max = previousInteger(originMax.num, multipleOf);
|
|
8564
|
+
if (min === originMin.num && originMin.exclusive) min += multipleOf;
|
|
8565
|
+
if (max === originMax.num && originMax.exclusive) max -= multipleOf;
|
|
8566
|
+
if (min > max) return;
|
|
8567
|
+
if (min === max) {
|
|
8568
|
+
if (min === Number.POSITIVE_INFINITY) return;
|
|
8569
|
+
if (min === Number.NEGATIVE_INFINITY) return;
|
|
8570
|
+
}
|
|
8571
|
+
return [{
|
|
8572
|
+
num: min,
|
|
8997
8573
|
exclusive: false
|
|
8998
8574
|
}, {
|
|
8999
|
-
num:
|
|
9000
|
-
exclusive: false
|
|
9001
|
-
}], [{
|
|
9002
|
-
num: min2,
|
|
8575
|
+
num: max,
|
|
9003
8576
|
exclusive: false
|
|
9004
|
-
}
|
|
9005
|
-
|
|
8577
|
+
}];
|
|
8578
|
+
}
|
|
8579
|
+
function nextInteger(float, multipleOf) {
|
|
8580
|
+
return Math.ceil(float / multipleOf) * multipleOf;
|
|
8581
|
+
}
|
|
8582
|
+
function previousInteger(float, multipleOf) {
|
|
8583
|
+
return Math.floor(float / multipleOf) * multipleOf;
|
|
8584
|
+
}
|
|
8585
|
+
//#endregion
|
|
8586
|
+
//#region src/json-schema-subset/checker/numeric/float.ts
|
|
8587
|
+
function calculateFloat(schema1, schema2) {
|
|
8588
|
+
const { left, right, center } = splitRange$3(pickRange(schema1), pickRange(schema2));
|
|
8589
|
+
if (!center) return ExpressionRejection;
|
|
8590
|
+
let extraLeft = false;
|
|
8591
|
+
let extraRight = false;
|
|
8592
|
+
if (left) {
|
|
8593
|
+
if (left.fromLeft) extraLeft = true;
|
|
8594
|
+
else extraRight = true;
|
|
8595
|
+
}
|
|
8596
|
+
if (right) {
|
|
8597
|
+
if (right.fromLeft) extraLeft = true;
|
|
8598
|
+
else extraRight = true;
|
|
8599
|
+
}
|
|
8600
|
+
if (extraLeft && extraRight) return ExpressionIntersection;
|
|
8601
|
+
if (extraLeft) return ExpressionContaining;
|
|
8602
|
+
if (extraRight) return ExpressionContainedBy;
|
|
8603
|
+
return ExpressionEquals;
|
|
8604
|
+
}
|
|
8605
|
+
function calculateFloatAndInteger(schema1, schema2) {
|
|
8606
|
+
const floatRange = pickRange(schema1);
|
|
8607
|
+
const integer = normalizeInteger(schema2);
|
|
8608
|
+
if (!integer) return ExpressionContaining;
|
|
8609
|
+
const result = splitRange$3(floatRange, integer.range);
|
|
8610
|
+
const intCenter = cutRange(result.center, integer.multipleOf);
|
|
8611
|
+
const leftIntRange = unwrapAndCutRange(result.left, integer.multipleOf);
|
|
8612
|
+
const rightIntRange = unwrapAndCutRange(result.right, integer.multipleOf);
|
|
8613
|
+
if (!result.center) return ExpressionRejection;
|
|
8614
|
+
let extraFloat = false;
|
|
8615
|
+
let extraInteger = false;
|
|
8616
|
+
if (result.left?.fromLeft) extraFloat = true;
|
|
8617
|
+
if (result.right?.fromLeft) extraFloat = true;
|
|
8618
|
+
if (!intCenter || !isPointRange(result.center)) extraFloat = true;
|
|
8619
|
+
if (leftIntRange) extraInteger = true;
|
|
8620
|
+
if (rightIntRange) extraInteger = true;
|
|
8621
|
+
if (extraFloat && extraInteger) return ExpressionIntersection;
|
|
8622
|
+
if (extraFloat) return ExpressionContaining;
|
|
8623
|
+
if (extraInteger) return ExpressionContainedBy;
|
|
8624
|
+
return ExpressionEquals;
|
|
8625
|
+
}
|
|
8626
|
+
function pickRange(schema) {
|
|
8627
|
+
let point1;
|
|
8628
|
+
let point2;
|
|
8629
|
+
if (schema.exclusiveMinimum !== void 0) point1 = {
|
|
8630
|
+
num: schema.exclusiveMinimum,
|
|
8631
|
+
exclusive: true
|
|
8632
|
+
};
|
|
8633
|
+
else if (schema.minimum !== void 0) point1 = {
|
|
8634
|
+
num: schema.minimum,
|
|
9006
8635
|
exclusive: false
|
|
9007
|
-
}]);
|
|
9008
|
-
let leftItem;
|
|
9009
|
-
let rightItem;
|
|
9010
|
-
let intersectionItem;
|
|
9011
|
-
if (left) leftItem = {
|
|
9012
|
-
min: left.range[0].num,
|
|
9013
|
-
max: left.range[1].num,
|
|
9014
|
-
isFrom1: left.fromLeft
|
|
9015
8636
|
};
|
|
9016
|
-
|
|
9017
|
-
|
|
9018
|
-
|
|
9019
|
-
isFrom1: right.fromLeft
|
|
8637
|
+
else point1 = {
|
|
8638
|
+
num: Number.NEGATIVE_INFINITY,
|
|
8639
|
+
exclusive: true
|
|
9020
8640
|
};
|
|
9021
|
-
if (
|
|
9022
|
-
|
|
9023
|
-
|
|
8641
|
+
if (schema.exclusiveMaximum !== void 0) point2 = {
|
|
8642
|
+
num: schema.exclusiveMaximum,
|
|
8643
|
+
exclusive: true
|
|
9024
8644
|
};
|
|
9025
|
-
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
intersection: intersectionItem
|
|
8645
|
+
else if (schema.maximum !== void 0) point2 = {
|
|
8646
|
+
num: schema.maximum,
|
|
8647
|
+
exclusive: false
|
|
9029
8648
|
};
|
|
9030
|
-
|
|
9031
|
-
|
|
9032
|
-
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
8649
|
+
else point2 = {
|
|
8650
|
+
num: Number.POSITIVE_INFINITY,
|
|
8651
|
+
exclusive: true
|
|
8652
|
+
};
|
|
8653
|
+
return [point1, point2];
|
|
8654
|
+
}
|
|
8655
|
+
function unwrapAndCutRange(side, multipleOf) {
|
|
8656
|
+
if (!side) return;
|
|
8657
|
+
if (side.fromLeft) return;
|
|
8658
|
+
return cutRange(side.range, multipleOf);
|
|
8659
|
+
}
|
|
8660
|
+
//#endregion
|
|
8661
|
+
//#region src/json-schema-subset/checker/numeric/integer.ts
|
|
8662
|
+
function calculateInteger(schema1, schema2) {
|
|
8663
|
+
const integer1 = normalizeInteger(schema1);
|
|
8664
|
+
const integer2 = normalizeInteger(schema2);
|
|
8665
|
+
if (!integer1 && !integer2) return ExpressionEquals;
|
|
8666
|
+
if (!integer1) return ExpressionContainedBy;
|
|
8667
|
+
if (!integer2) return ExpressionContaining;
|
|
8668
|
+
const { range: range1, multipleOf: multipleOf1 } = integer1;
|
|
8669
|
+
const { range: range2, multipleOf: multipleOf2 } = integer2;
|
|
8670
|
+
const result = splitRange$3(range1, range2);
|
|
8671
|
+
let centerRange;
|
|
8672
|
+
let lcm = 0;
|
|
8673
|
+
if (result.center) {
|
|
8674
|
+
lcm = getLCM(multipleOf1, multipleOf2);
|
|
8675
|
+
centerRange = cutRange(result.center, lcm);
|
|
9038
8676
|
}
|
|
9039
|
-
if (
|
|
9040
|
-
|
|
9041
|
-
|
|
8677
|
+
if (!centerRange) return ExpressionRejection;
|
|
8678
|
+
let extraLeft = false;
|
|
8679
|
+
let extraRight = false;
|
|
8680
|
+
const { left, right } = result;
|
|
8681
|
+
if (left && cutRange(left.range, left.fromLeft ? multipleOf1 : multipleOf2)) {
|
|
8682
|
+
if (left.fromLeft) extraLeft = true;
|
|
8683
|
+
else extraRight = true;
|
|
9042
8684
|
}
|
|
9043
|
-
if (
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
|
|
8685
|
+
if (right && cutRange(right.range, right.fromLeft ? multipleOf1 : multipleOf2)) {
|
|
8686
|
+
if (right.fromLeft) extraLeft = true;
|
|
8687
|
+
else extraRight = true;
|
|
8688
|
+
}
|
|
8689
|
+
extraLeft = extraLeft || hasExtraIntegersOnCenter(integer1, centerRange, lcm);
|
|
8690
|
+
extraRight = extraRight || hasExtraIntegersOnCenter(integer2, centerRange, lcm);
|
|
8691
|
+
if (extraLeft && extraRight) return ExpressionIntersection;
|
|
8692
|
+
if (extraLeft) return ExpressionContaining;
|
|
8693
|
+
if (extraRight) return ExpressionContainedBy;
|
|
8694
|
+
return ExpressionEquals;
|
|
8695
|
+
}
|
|
8696
|
+
function hasExtraIntegersOnCenter({ range, multipleOf }, lcmCenterRange, lcm) {
|
|
8697
|
+
const result = splitRange$3(range, lcmCenterRange);
|
|
8698
|
+
if (cutRange(result.left?.range, multipleOf)) return true;
|
|
8699
|
+
if (cutRange(result.right?.range, multipleOf)) return true;
|
|
8700
|
+
const center = cutRange(result.center, multipleOf);
|
|
8701
|
+
if (!center) return false;
|
|
8702
|
+
const lcmCenterLength = rangeLength(lcmCenterRange);
|
|
8703
|
+
if (rangeLength(center) > lcmCenterLength) return true;
|
|
8704
|
+
if (lcmCenterLength === 1) return false;
|
|
8705
|
+
if (multipleOf < lcm) return true;
|
|
8706
|
+
return false;
|
|
8707
|
+
}
|
|
8708
|
+
/** Returns the least common multiple. */
|
|
8709
|
+
function getLCM(a, b) {
|
|
8710
|
+
return a * b / getGCD(a, b);
|
|
8711
|
+
}
|
|
8712
|
+
/** @returns The greatest common divisor. */
|
|
8713
|
+
function getGCD(a, b) {
|
|
8714
|
+
if (a === 0) return b;
|
|
8715
|
+
return getGCD(b % a, a);
|
|
8716
|
+
}
|
|
8717
|
+
function rangeLength(range) {
|
|
8718
|
+
if (!range) return 0;
|
|
8719
|
+
const [point1, point2] = range;
|
|
8720
|
+
return point2.num - point1.num + 1;
|
|
9047
8721
|
}
|
|
9048
8722
|
//#endregion
|
|
9049
|
-
//#region src/json-schema-subset/checker/
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9056
|
-
|
|
9057
|
-
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
const
|
|
9061
|
-
if (
|
|
9062
|
-
|
|
9063
|
-
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
|
|
9067
|
-
const
|
|
9068
|
-
|
|
9069
|
-
|
|
9070
|
-
|
|
9071
|
-
|
|
9072
|
-
|
|
9073
|
-
|
|
9074
|
-
|
|
9075
|
-
|
|
9076
|
-
|
|
9077
|
-
|
|
9078
|
-
|
|
9079
|
-
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
|
|
9083
|
-
|
|
9084
|
-
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
|
|
9091
|
-
|
|
9092
|
-
|
|
9093
|
-
|
|
9094
|
-
|
|
8723
|
+
//#region src/json-schema-subset/checker/numeric/checker.ts
|
|
8724
|
+
function calculateNumeric(schema1, schema2) {
|
|
8725
|
+
if (isUndefinedNumber(schema1) || isUndefinedNumber(schema2)) return ExpressionAny;
|
|
8726
|
+
const isFloat1 = isFloat(schema1);
|
|
8727
|
+
const isFloat2 = isFloat(schema2);
|
|
8728
|
+
if (isFloat1 && isFloat2) return calculateFloat(schema1, schema2);
|
|
8729
|
+
else if (isFloat1) return calculateFloatAndInteger(schema1, schema2);
|
|
8730
|
+
else if (isFloat2) return swap(calculateFloatAndInteger(schema2, schema1));
|
|
8731
|
+
else return calculateInteger(schema1, schema2);
|
|
8732
|
+
}
|
|
8733
|
+
function isUndefinedNumber(schema) {
|
|
8734
|
+
const { multipleOf } = schema;
|
|
8735
|
+
if (multipleOf === void 0) return false;
|
|
8736
|
+
if (!Number.isInteger(multipleOf)) return true;
|
|
8737
|
+
if (multipleOf < 0) return true;
|
|
8738
|
+
return false;
|
|
8739
|
+
}
|
|
8740
|
+
function isFloat(schema) {
|
|
8741
|
+
const { multipleOf } = schema;
|
|
8742
|
+
if (multipleOf !== void 0 && Number.isInteger(multipleOf)) return false;
|
|
8743
|
+
if (schema.type === "integer") return false;
|
|
8744
|
+
return true;
|
|
8745
|
+
}
|
|
8746
|
+
//#endregion
|
|
8747
|
+
//#region src/json-schema-subset/checker/object.ts
|
|
8748
|
+
var splitRange$1 = createRangeSplitter(0);
|
|
8749
|
+
var quantum = makeQuantum([
|
|
8750
|
+
"hasCommonInRequired",
|
|
8751
|
+
"hasCommonOutRequired",
|
|
8752
|
+
"hasExtra1",
|
|
8753
|
+
"hasExtra2",
|
|
8754
|
+
"hasRejection"
|
|
8755
|
+
]);
|
|
8756
|
+
function calculateObject(context, schema1, schema2) {
|
|
8757
|
+
if (isPropertiesCountCannotMatch(schema1, schema2)) return ExpressionRejection;
|
|
8758
|
+
const splitRequiredResult = splitRequired(schema1, schema2);
|
|
8759
|
+
if (!splitRequiredResult) return ExpressionRejection;
|
|
8760
|
+
const getProperty1 = createPropertySchemaGetter(schema1);
|
|
8761
|
+
const getProperty2 = createPropertySchemaGetter(schema2);
|
|
8762
|
+
const calculateKey = (key) => {
|
|
8763
|
+
const propertySchema1 = getProperty1(key);
|
|
8764
|
+
const propertySchema2 = getProperty2(key);
|
|
8765
|
+
if (areNotBothNever(propertySchema1, propertySchema2)) return context.calculate(propertySchema1, propertySchema2);
|
|
8766
|
+
else return 0;
|
|
8767
|
+
};
|
|
8768
|
+
const { commonRequired, extraRequired1, extraRequired2 } = splitRequiredResult;
|
|
8769
|
+
const quantumVariable = quantum.variable({});
|
|
8770
|
+
for (const requiredKey of [...commonRequired].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateCommonRequiredExpression);
|
|
8771
|
+
for (const requiredKey of [...extraRequired1].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateExtraRequiredExpression1);
|
|
8772
|
+
for (const requiredKey of [...extraRequired2].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateExtraRequiredExpression2);
|
|
8773
|
+
const { hasOptional1, hasOptional2 } = splitRequiredResult;
|
|
8774
|
+
if (hasOptional1 || hasOptional2) {
|
|
8775
|
+
const calculator = calculateOptionalExpression(hasOptional1, hasOptional2);
|
|
8776
|
+
for (const optionalKey of [...getOptionalKeys(schema1, schema2)].toSorted()) {
|
|
8777
|
+
const expression = calculateKey(optionalKey);
|
|
8778
|
+
if (expression !== 0) quantumVariable.push(expression, calculator);
|
|
8779
|
+
}
|
|
8780
|
+
const additionalProperties1 = schema1.additionalProperties ?? ANY;
|
|
8781
|
+
const additionalProperties2 = schema2.additionalProperties ?? ANY;
|
|
8782
|
+
if (areNotBothNever(additionalProperties1, additionalProperties2)) {
|
|
8783
|
+
const expression = context.calculate(additionalProperties1, additionalProperties2);
|
|
8784
|
+
quantumVariable.push(expression, calculator);
|
|
8785
|
+
}
|
|
9095
8786
|
}
|
|
9096
8787
|
quantumVariable.update((variable) => {
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
break;
|
|
9101
|
-
case ExpressionSingleResult.ContainedBy:
|
|
9102
|
-
variable.hasExtra2 = true;
|
|
9103
|
-
break;
|
|
9104
|
-
case ExpressionSingleResult.Intersection:
|
|
9105
|
-
variable.hasExtra1 = true;
|
|
9106
|
-
variable.hasExtra2 = true;
|
|
9107
|
-
}
|
|
9108
|
-
if (schema1.uniqueItems && !schema2.uniqueItems && (schema2.maxItems ?? Number.POSITIVE_INFINITY) > 1) variable.hasExtra2 = true;
|
|
9109
|
-
else if (!schema1.uniqueItems && schema2.uniqueItems && (schema1.maxItems ?? Number.POSITIVE_INFINITY) > 1) variable.hasExtra1 = true;
|
|
9110
|
-
if (schema1.maxItems === 0 || schema2.maxItems === 0) {
|
|
9111
|
-
variable.hasCommon = true;
|
|
9112
|
-
if (schema1.maxItems !== 0) variable.hasExtra1 = true;
|
|
9113
|
-
if (schema2.maxItems !== 0) variable.hasExtra2 = true;
|
|
8788
|
+
if (!variable.hasRejection) {
|
|
8789
|
+
if (extraRequired1.size > 0) variable.hasExtra2 = true;
|
|
8790
|
+
if (extraRequired2.size > 0) variable.hasExtra1 = true;
|
|
9114
8791
|
}
|
|
9115
8792
|
});
|
|
8793
|
+
const { requiredKeysCount } = splitRequiredResult;
|
|
9116
8794
|
let expression = 0;
|
|
9117
|
-
for (const { hasExtra1, hasExtra2,
|
|
9118
|
-
|
|
9119
|
-
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
|
|
9124
|
-
else expression |= ExpressionEquals;
|
|
9125
|
-
}
|
|
8795
|
+
for (const { hasExtra1, hasExtra2, hasCommonInRequired, hasCommonOutRequired, hasRejection } of quantumVariable) if (!hasCommonInRequired && requiredKeysCount > 0) expression |= ExpressionRejection;
|
|
8796
|
+
else if (!hasCommonOutRequired && requiredKeysCount === 0) expression |= ExpressionRejection;
|
|
8797
|
+
else if (hasRejection) expression |= ExpressionRejection;
|
|
8798
|
+
else if (hasExtra1 && hasExtra2) expression |= ExpressionIntersection;
|
|
8799
|
+
else if (hasExtra1) expression |= ExpressionContaining;
|
|
8800
|
+
else if (hasExtra2) expression |= ExpressionContainedBy;
|
|
8801
|
+
else expression |= ExpressionEquals;
|
|
9126
8802
|
return expression;
|
|
9127
8803
|
}
|
|
9128
|
-
function
|
|
9129
|
-
|
|
9130
|
-
else return [[], items ?? ANY];
|
|
8804
|
+
function isPropertiesCountCannotMatch(schema1, schema2) {
|
|
8805
|
+
return toExpressionSingleResult(splitRange$1(schema1.minProperties, schema1.maxProperties, schema2.minProperties, schema2.maxProperties)) === ExpressionSingleResult.Rejection;
|
|
9131
8806
|
}
|
|
9132
|
-
|
|
9133
|
-
|
|
9134
|
-
|
|
9135
|
-
const
|
|
9136
|
-
|
|
9137
|
-
|
|
9138
|
-
|
|
9139
|
-
|
|
9140
|
-
|
|
8807
|
+
function splitRequired(schema1, schema2) {
|
|
8808
|
+
const extraRequired1 = new Set(schema1.required);
|
|
8809
|
+
const extraRequired2 = new Set(schema2.required);
|
|
8810
|
+
const commonRequired = /* @__PURE__ */ new Set();
|
|
8811
|
+
const wholeRequired = /* @__PURE__ */ new Set();
|
|
8812
|
+
const requiredCount1 = extraRequired1.size;
|
|
8813
|
+
const requiredCount2 = extraRequired2.size;
|
|
8814
|
+
for (const key of extraRequired1) {
|
|
8815
|
+
if (extraRequired2.has(key)) commonRequired.add(key);
|
|
8816
|
+
wholeRequired.add(key);
|
|
8817
|
+
}
|
|
8818
|
+
for (const key of extraRequired2) {
|
|
8819
|
+
if (extraRequired1.has(key)) commonRequired.add(key);
|
|
8820
|
+
wholeRequired.add(key);
|
|
8821
|
+
}
|
|
8822
|
+
const requiredKeysCount = wholeRequired.size;
|
|
8823
|
+
for (const key of commonRequired) {
|
|
8824
|
+
extraRequired1.delete(key);
|
|
8825
|
+
extraRequired2.delete(key);
|
|
8826
|
+
}
|
|
8827
|
+
const maxProperties1 = schema1.maxProperties ?? Number.MAX_SAFE_INTEGER;
|
|
8828
|
+
const maxProperties2 = schema2.maxProperties ?? Number.MAX_SAFE_INTEGER;
|
|
8829
|
+
if (requiredKeysCount > maxProperties1 || requiredKeysCount > maxProperties2) return null;
|
|
8830
|
+
return {
|
|
8831
|
+
requiredKeysCount,
|
|
8832
|
+
extraRequired1,
|
|
8833
|
+
extraRequired2,
|
|
8834
|
+
commonRequired,
|
|
8835
|
+
hasOptional1: maxProperties1 > requiredCount1,
|
|
8836
|
+
hasOptional2: maxProperties2 > requiredCount2
|
|
9141
8837
|
};
|
|
9142
8838
|
}
|
|
9143
|
-
function
|
|
9144
|
-
const
|
|
9145
|
-
|
|
9146
|
-
|
|
9147
|
-
|
|
9148
|
-
const
|
|
9149
|
-
|
|
9150
|
-
if (
|
|
9151
|
-
|
|
8839
|
+
function getOptionalKeys(schema1, schema2) {
|
|
8840
|
+
const optionalKeys = new Set(schema1.required);
|
|
8841
|
+
const properties1 = schema1.properties;
|
|
8842
|
+
const properties2 = schema2.properties;
|
|
8843
|
+
const required1 = schema1.required;
|
|
8844
|
+
const required2 = schema2.required;
|
|
8845
|
+
if (properties1) for (const key in properties1) optionalKeys.add(key);
|
|
8846
|
+
if (properties2) for (const key in properties2) optionalKeys.add(key);
|
|
8847
|
+
if (required1) for (const key of required1) optionalKeys.delete(key);
|
|
8848
|
+
if (required2) for (const key of required2) optionalKeys.delete(key);
|
|
8849
|
+
return optionalKeys;
|
|
9152
8850
|
}
|
|
9153
|
-
|
|
9154
|
-
|
|
9155
|
-
|
|
9156
|
-
|
|
9157
|
-
|
|
9158
|
-
|
|
9159
|
-
|
|
9160
|
-
|
|
9161
|
-
|
|
9162
|
-
|
|
9163
|
-
|
|
9164
|
-
|
|
8851
|
+
var calculateCommonRequiredExpression = (singleExpression, variable) => {
|
|
8852
|
+
switch (singleExpression) {
|
|
8853
|
+
case ExpressionSingleResult.Equals:
|
|
8854
|
+
variable.hasCommonInRequired = true;
|
|
8855
|
+
break;
|
|
8856
|
+
case ExpressionSingleResult.Containing:
|
|
8857
|
+
variable.hasExtra1 = true;
|
|
8858
|
+
variable.hasCommonInRequired = true;
|
|
8859
|
+
break;
|
|
8860
|
+
case ExpressionSingleResult.ContainedBy:
|
|
8861
|
+
variable.hasExtra2 = true;
|
|
8862
|
+
variable.hasCommonInRequired = true;
|
|
8863
|
+
break;
|
|
8864
|
+
case ExpressionSingleResult.Intersection:
|
|
8865
|
+
variable.hasExtra1 = true;
|
|
8866
|
+
variable.hasExtra2 = true;
|
|
8867
|
+
variable.hasCommonInRequired = true;
|
|
8868
|
+
break;
|
|
8869
|
+
case ExpressionSingleResult.Rejection: variable.hasRejection = true;
|
|
9165
8870
|
}
|
|
9166
|
-
|
|
9167
|
-
|
|
9168
|
-
|
|
9169
|
-
|
|
8871
|
+
};
|
|
8872
|
+
var calculateExtraRequiredExpression1 = (singleExpression, variable) => {
|
|
8873
|
+
switch (singleExpression) {
|
|
8874
|
+
case ExpressionSingleResult.Equals:
|
|
8875
|
+
case ExpressionSingleResult.ContainedBy:
|
|
8876
|
+
variable.hasCommonInRequired = true;
|
|
8877
|
+
break;
|
|
8878
|
+
case ExpressionSingleResult.Intersection:
|
|
8879
|
+
case ExpressionSingleResult.Containing:
|
|
8880
|
+
variable.hasExtra1 = true;
|
|
8881
|
+
variable.hasCommonInRequired = true;
|
|
8882
|
+
break;
|
|
8883
|
+
case ExpressionSingleResult.Rejection: variable.hasRejection = true;
|
|
9170
8884
|
}
|
|
9171
|
-
|
|
9172
|
-
|
|
9173
|
-
|
|
9174
|
-
|
|
9175
|
-
|
|
9176
|
-
|
|
9177
|
-
|
|
9178
|
-
|
|
9179
|
-
|
|
9180
|
-
|
|
9181
|
-
|
|
9182
|
-
|
|
9183
|
-
|
|
9184
|
-
|
|
9185
|
-
|
|
9186
|
-
|
|
9187
|
-
|
|
9188
|
-
|
|
9189
|
-
|
|
9190
|
-
|
|
8885
|
+
};
|
|
8886
|
+
var calculateExtraRequiredExpression2 = (singleExpression, variable) => {
|
|
8887
|
+
switch (singleExpression) {
|
|
8888
|
+
case ExpressionSingleResult.Equals:
|
|
8889
|
+
case ExpressionSingleResult.Containing:
|
|
8890
|
+
variable.hasCommonInRequired = true;
|
|
8891
|
+
break;
|
|
8892
|
+
case ExpressionSingleResult.Intersection:
|
|
8893
|
+
case ExpressionSingleResult.ContainedBy:
|
|
8894
|
+
variable.hasExtra2 = true;
|
|
8895
|
+
variable.hasCommonInRequired = true;
|
|
8896
|
+
break;
|
|
8897
|
+
case ExpressionSingleResult.Rejection: variable.hasRejection = true;
|
|
8898
|
+
}
|
|
8899
|
+
};
|
|
8900
|
+
var calculateOptionalExpression = (hasOptional1, hasOptional2) => (singleExpression, variable) => {
|
|
8901
|
+
if (variable.hasRejection) return;
|
|
8902
|
+
let foundExtraPossibility1 = false;
|
|
8903
|
+
let foundExtraPossibility2 = false;
|
|
8904
|
+
let foundCommonPossibility = false;
|
|
8905
|
+
switch (singleExpression) {
|
|
8906
|
+
case ExpressionSingleResult.Equals:
|
|
8907
|
+
foundCommonPossibility = true;
|
|
8908
|
+
break;
|
|
8909
|
+
case ExpressionSingleResult.Containing:
|
|
8910
|
+
foundExtraPossibility1 = true;
|
|
8911
|
+
foundCommonPossibility = true;
|
|
8912
|
+
break;
|
|
8913
|
+
case ExpressionSingleResult.ContainedBy:
|
|
8914
|
+
foundExtraPossibility2 = true;
|
|
8915
|
+
foundCommonPossibility = true;
|
|
8916
|
+
break;
|
|
8917
|
+
case ExpressionSingleResult.Intersection:
|
|
8918
|
+
foundExtraPossibility1 = true;
|
|
8919
|
+
foundExtraPossibility2 = true;
|
|
8920
|
+
foundCommonPossibility = true;
|
|
8921
|
+
break;
|
|
8922
|
+
case ExpressionSingleResult.Rejection:
|
|
8923
|
+
foundExtraPossibility1 = true;
|
|
8924
|
+
foundExtraPossibility2 = true;
|
|
9191
8925
|
}
|
|
9192
|
-
if (
|
|
9193
|
-
if (
|
|
9194
|
-
if (
|
|
9195
|
-
|
|
9196
|
-
|
|
9197
|
-
|
|
9198
|
-
|
|
9199
|
-
|
|
9200
|
-
|
|
9201
|
-
|
|
8926
|
+
if (hasOptional1 && foundExtraPossibility1) variable.hasExtra1 = true;
|
|
8927
|
+
if (hasOptional2 && foundExtraPossibility2) variable.hasExtra2 = true;
|
|
8928
|
+
if (hasOptional1 && hasOptional2 && foundCommonPossibility) variable.hasCommonOutRequired = true;
|
|
8929
|
+
};
|
|
8930
|
+
function createPropertySchemaGetter(schema) {
|
|
8931
|
+
const properties = schema.properties;
|
|
8932
|
+
const propertyNames = schema.propertyNames;
|
|
8933
|
+
const additionalProperties = schema.additionalProperties;
|
|
8934
|
+
const patternProperties = [];
|
|
8935
|
+
if (schema.patternProperties) for (const pattern in schema.patternProperties) {
|
|
8936
|
+
const valueSchema = schema.patternProperties[pattern];
|
|
8937
|
+
const regExp = new RegExp(pattern, "i");
|
|
8938
|
+
patternProperties.push({
|
|
8939
|
+
pattern: regExp,
|
|
8940
|
+
schema: valueSchema
|
|
8941
|
+
});
|
|
8942
|
+
}
|
|
8943
|
+
return (key) => {
|
|
8944
|
+
if (propertyNames && valid(propertyNames, key) === ValidResult.Invalid) return NEVER;
|
|
8945
|
+
for (const { pattern, schema: patternSchema } of patternProperties) if (pattern.test(key)) return patternSchema;
|
|
8946
|
+
const propertySchema = (properties && properties[key]) ?? additionalProperties;
|
|
8947
|
+
if (!propertySchema) return ANY;
|
|
8948
|
+
return propertySchema;
|
|
8949
|
+
};
|
|
9202
8950
|
}
|
|
9203
|
-
function
|
|
9204
|
-
|
|
9205
|
-
|
|
8951
|
+
function areNotBothNever(schema1, schema2) {
|
|
8952
|
+
const kind1 = getKind(schema1);
|
|
8953
|
+
const kind2 = getKind(schema2);
|
|
8954
|
+
return kind1 !== CompiledKind.Never || kind2 !== CompiledKind.Never;
|
|
9206
8955
|
}
|
|
9207
8956
|
//#endregion
|
|
9208
|
-
//#region src/json-schema-subset/checker/
|
|
9209
|
-
|
|
9210
|
-
|
|
9211
|
-
|
|
9212
|
-
|
|
9213
|
-
|
|
9214
|
-
|
|
9215
|
-
|
|
9216
|
-
|
|
9217
|
-
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
|
|
9221
|
-
|
|
9222
|
-
|
|
9223
|
-
|
|
9224
|
-
|
|
9225
|
-
|
|
9226
|
-
|
|
9227
|
-
|
|
9228
|
-
|
|
9229
|
-
|
|
9230
|
-
if (Array.isArray(object1)) {
|
|
9231
|
-
if (!Array.isArray(object2)) return false;
|
|
9232
|
-
if (object1.length !== object2.length) return false;
|
|
9233
|
-
for (const [i, value1Element] of object1.entries()) if (!isValueEquals(value1Element, object2[i])) return false;
|
|
9234
|
-
} else {
|
|
9235
|
-
if (Array.isArray(object2)) return false;
|
|
9236
|
-
for (const key in object1) {
|
|
9237
|
-
if (!(key in object2)) return false;
|
|
9238
|
-
if (!isValueEquals(Reflect.get(object1, key), Reflect.get(object2, key))) return false;
|
|
9239
|
-
}
|
|
9240
|
-
for (const key in object2) if (!(key in object1)) return false;
|
|
9241
|
-
}
|
|
9242
|
-
return true;
|
|
9243
|
-
}
|
|
9244
|
-
function isValueEquals(value1, value2) {
|
|
9245
|
-
if (value1 === value2) return true;
|
|
9246
|
-
if (value1 === null) return false;
|
|
9247
|
-
if (typeof value1 !== "object") return false;
|
|
9248
|
-
if (typeof value1 !== typeof value2) return false;
|
|
9249
|
-
if (isCompiledSchema(value1) && isCompiledSchema(value2)) return isCompiledSchemaEquals(value1, value2);
|
|
9250
|
-
return isObjectLikeEquals(value1, value2);
|
|
8957
|
+
//#region src/json-schema-subset/checker/string.ts
|
|
8958
|
+
var splitRange = createRangeSplitter(0);
|
|
8959
|
+
function calculateString(schema1, schema2) {
|
|
8960
|
+
if (schema2.format && !schema1.format) return ExpressionContaining;
|
|
8961
|
+
if (schema1.format && schema2.format && schema1.format !== schema2.format) return ExpressionAny;
|
|
8962
|
+
const expression = toExpressionSingleResult(splitRange(schema1.minLength, schema1.maxLength, schema2.minLength, schema2.maxLength));
|
|
8963
|
+
const hasPattern1 = !!schema1.pattern;
|
|
8964
|
+
const hasPattern2 = !!schema2.pattern;
|
|
8965
|
+
switch (expression) {
|
|
8966
|
+
case ExpressionSingleResult.Rejection: return ExpressionRejection;
|
|
8967
|
+
case ExpressionSingleResult.Containing: return hasPattern1 ? ExpressionAny : ExpressionContaining;
|
|
8968
|
+
case ExpressionSingleResult.ContainedBy: return hasPattern2 ? ExpressionAny : ExpressionContainedBy;
|
|
8969
|
+
case ExpressionSingleResult.Equals:
|
|
8970
|
+
if (hasPattern1 && hasPattern2) return schema1.pattern === schema2.pattern ? ExpressionEquals : ExpressionAny;
|
|
8971
|
+
if (hasPattern1) return ExpressionEquals | ExpressionContainedBy;
|
|
8972
|
+
if (hasPattern2) return ExpressionEquals | ExpressionContaining;
|
|
8973
|
+
return ExpressionEquals;
|
|
8974
|
+
case ExpressionSingleResult.Intersection:
|
|
8975
|
+
if (hasPattern1 && hasPattern2) return ExpressionAny;
|
|
8976
|
+
if (hasPattern1) return ExpressionIntersection | ExpressionRejection | ExpressionContainedBy;
|
|
8977
|
+
if (hasPattern2) return ExpressionIntersection | ExpressionRejection | ExpressionContaining;
|
|
8978
|
+
return ExpressionIntersection;
|
|
9251
8979
|
}
|
|
9252
|
-
return isSchemaEquals;
|
|
9253
8980
|
}
|
|
9254
8981
|
//#endregion
|
|
9255
|
-
//#region src/json-schema-subset/checker/
|
|
9256
|
-
function
|
|
9257
|
-
const
|
|
9258
|
-
const
|
|
9259
|
-
const
|
|
9260
|
-
|
|
8982
|
+
//#region src/json-schema-subset/checker/checker.ts
|
|
8983
|
+
function checkWithResult(extendsContext, schema1, schema2) {
|
|
8984
|
+
const context = {};
|
|
8985
|
+
const errorPaths = [];
|
|
8986
|
+
const calculate = wrapSchemaCalculatorWithCache(calculator(extendsContext, context));
|
|
8987
|
+
const describe = describer();
|
|
8988
|
+
const equals = schemaEqualsChecker(extendsContext);
|
|
8989
|
+
context.isEquals = wrapEqualsCheckerWithCache(isDeepEquals);
|
|
8990
|
+
context.calculate = expression({
|
|
8991
|
+
describe,
|
|
8992
|
+
equals,
|
|
8993
|
+
calculate,
|
|
8994
|
+
observeCalculation: (left, right, result, swapped) => {
|
|
8995
|
+
if (!isDecisiveMismatch(swapped ? swap(result) : result)) return;
|
|
8996
|
+
const errorPath = swapped ? findMismatchPath(right, left) : findMismatchPath(left, right);
|
|
8997
|
+
if (errorPath) errorPaths.push(errorPath);
|
|
8998
|
+
}
|
|
8999
|
+
});
|
|
9000
|
+
Object.freeze(context);
|
|
9001
|
+
const comparisonExpression = context.calculate(schema1, schema2);
|
|
9261
9002
|
return {
|
|
9262
|
-
|
|
9263
|
-
|
|
9003
|
+
errorPath: errorPaths[0],
|
|
9004
|
+
expression: comparisonExpression
|
|
9264
9005
|
};
|
|
9265
9006
|
}
|
|
9266
|
-
|
|
9267
|
-
|
|
9268
|
-
|
|
9269
|
-
|
|
9270
|
-
|
|
9271
|
-
|
|
9272
|
-
|
|
9273
|
-
|
|
9274
|
-
|
|
9275
|
-
|
|
9276
|
-
|
|
9277
|
-
|
|
9278
|
-
|
|
9279
|
-
|
|
9280
|
-
|
|
9281
|
-
|
|
9282
|
-
|
|
9007
|
+
var describer = () => (schema) => {
|
|
9008
|
+
let description;
|
|
9009
|
+
switch (getKind(schema)) {
|
|
9010
|
+
case CompiledKind.Not:
|
|
9011
|
+
description = {
|
|
9012
|
+
kind: ExpressionKind.Not,
|
|
9013
|
+
expression: schema.not
|
|
9014
|
+
};
|
|
9015
|
+
break;
|
|
9016
|
+
case CompiledKind.Combination:
|
|
9017
|
+
if ("allOf" in schema) description = {
|
|
9018
|
+
kind: ExpressionKind.AllOf,
|
|
9019
|
+
expressions: rejectInSchemaList(schema.allOf, CompiledKind.Any)
|
|
9020
|
+
};
|
|
9021
|
+
else if ("anyOf" in schema) description = {
|
|
9022
|
+
kind: ExpressionKind.AnyOf,
|
|
9023
|
+
expressions: rejectInSchemaList(schema.anyOf, CompiledKind.Never)
|
|
9024
|
+
};
|
|
9025
|
+
else if ("oneOf" in schema) description = {
|
|
9026
|
+
kind: ExpressionKind.OneOf,
|
|
9027
|
+
expressions: rejectInSchemaList(schema.oneOf, CompiledKind.Never)
|
|
9028
|
+
};
|
|
9029
|
+
else throw new Error(`invalid combination JSON Schema: ${JSON.stringify(schema)}`);
|
|
9030
|
+
break;
|
|
9031
|
+
default: description = { kind: ExpressionKind.Leaf };
|
|
9283
9032
|
}
|
|
9284
|
-
return
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
|
|
9288
|
-
|
|
9289
|
-
|
|
9290
|
-
|
|
9291
|
-
|
|
9292
|
-
|
|
9293
|
-
return Math.ceil(float / multipleOf) * multipleOf;
|
|
9294
|
-
}
|
|
9295
|
-
function previousInteger(float, multipleOf) {
|
|
9296
|
-
return Math.floor(float / multipleOf) * multipleOf;
|
|
9297
|
-
}
|
|
9298
|
-
//#endregion
|
|
9299
|
-
//#region src/json-schema-subset/checker/numeric/float.ts
|
|
9300
|
-
function calculateFloat(schema1, schema2) {
|
|
9301
|
-
const { left, right, center } = splitRange$3(pickRange(schema1), pickRange(schema2));
|
|
9302
|
-
if (!center) return ExpressionRejection;
|
|
9303
|
-
let extraLeft = false;
|
|
9304
|
-
let extraRight = false;
|
|
9305
|
-
if (left) {
|
|
9306
|
-
if (left.fromLeft) extraLeft = true;
|
|
9307
|
-
else extraRight = true;
|
|
9033
|
+
return description;
|
|
9034
|
+
};
|
|
9035
|
+
var calculator = (extendsContext, context) => (schema1, schema2) => {
|
|
9036
|
+
const kind1 = getKind(schema1);
|
|
9037
|
+
const kind2 = getKind(schema2);
|
|
9038
|
+
if (kind1 === CompiledKind.Extends || kind2 === CompiledKind.Extends) return extendsContext.calculate(schema1, schema2);
|
|
9039
|
+
switch (kind1) {
|
|
9040
|
+
case CompiledKind.Any: return kind2 === CompiledKind.Any ? ExpressionEquals : ExpressionContaining;
|
|
9041
|
+
case CompiledKind.Never: return kind2 === CompiledKind.Never ? ExpressionEquals : ExpressionContainedBy;
|
|
9308
9042
|
}
|
|
9309
|
-
|
|
9310
|
-
|
|
9311
|
-
|
|
9043
|
+
switch (kind2) {
|
|
9044
|
+
case CompiledKind.Any: return ExpressionContainedBy;
|
|
9045
|
+
case CompiledKind.Never: return ExpressionContaining;
|
|
9312
9046
|
}
|
|
9313
|
-
if (
|
|
9314
|
-
if (
|
|
9315
|
-
if (
|
|
9316
|
-
return
|
|
9317
|
-
|
|
9318
|
-
|
|
9319
|
-
|
|
9320
|
-
|
|
9321
|
-
|
|
9322
|
-
|
|
9323
|
-
|
|
9324
|
-
|
|
9325
|
-
|
|
9326
|
-
|
|
9327
|
-
|
|
9328
|
-
|
|
9329
|
-
if (result.left?.fromLeft) extraFloat = true;
|
|
9330
|
-
if (result.right?.fromLeft) extraFloat = true;
|
|
9331
|
-
if (!intCenter || !isPointRange(result.center)) extraFloat = true;
|
|
9332
|
-
if (leftIntRange) extraInteger = true;
|
|
9333
|
-
if (rightIntRange) extraInteger = true;
|
|
9334
|
-
if (extraFloat && extraInteger) return ExpressionIntersection;
|
|
9335
|
-
if (extraFloat) return ExpressionContaining;
|
|
9336
|
-
if (extraInteger) return ExpressionContainedBy;
|
|
9337
|
-
return ExpressionEquals;
|
|
9047
|
+
if (kind1 === CompiledKind.EnumOrConst && kind2 === CompiledKind.EnumOrConst) return calculateEnumAndEnum(context, schema1, schema2);
|
|
9048
|
+
if (kind1 === CompiledKind.EnumOrConst) return calculateEnumAndSchema(schema1, schema2);
|
|
9049
|
+
if (kind2 === CompiledKind.EnumOrConst) return swap(calculateEnumAndSchema(schema2, schema1));
|
|
9050
|
+
if (kind1 !== kind2) return ExpressionRejection;
|
|
9051
|
+
switch (kind1) {
|
|
9052
|
+
case CompiledKind.Null: return ExpressionEquals;
|
|
9053
|
+
case CompiledKind.Numeric: return calculateNumeric(schema1, schema2);
|
|
9054
|
+
case CompiledKind.String: return calculateString(schema1, schema2);
|
|
9055
|
+
case CompiledKind.Boolean: return ExpressionEquals;
|
|
9056
|
+
case CompiledKind.Object: return calculateObject(context, schema1, schema2);
|
|
9057
|
+
case CompiledKind.Array: return calculateArray(context, schema1, schema2);
|
|
9058
|
+
default: throw new Error(`invalid kind ${kind1}`);
|
|
9059
|
+
}
|
|
9060
|
+
};
|
|
9061
|
+
function rejectInSchemaList(schemaList, kind) {
|
|
9062
|
+
return schemaList.filter((e) => getKind(e) !== kind);
|
|
9338
9063
|
}
|
|
9339
|
-
function
|
|
9340
|
-
|
|
9341
|
-
let point2;
|
|
9342
|
-
if (schema.exclusiveMinimum !== void 0) point1 = {
|
|
9343
|
-
num: schema.exclusiveMinimum,
|
|
9344
|
-
exclusive: true
|
|
9345
|
-
};
|
|
9346
|
-
else if (schema.minimum !== void 0) point1 = {
|
|
9347
|
-
num: schema.minimum,
|
|
9348
|
-
exclusive: false
|
|
9349
|
-
};
|
|
9350
|
-
else point1 = {
|
|
9351
|
-
num: Number.NEGATIVE_INFINITY,
|
|
9352
|
-
exclusive: true
|
|
9353
|
-
};
|
|
9354
|
-
if (schema.exclusiveMaximum !== void 0) point2 = {
|
|
9355
|
-
num: schema.exclusiveMaximum,
|
|
9356
|
-
exclusive: true
|
|
9357
|
-
};
|
|
9358
|
-
else if (schema.maximum !== void 0) point2 = {
|
|
9359
|
-
num: schema.maximum,
|
|
9360
|
-
exclusive: false
|
|
9361
|
-
};
|
|
9362
|
-
else point2 = {
|
|
9363
|
-
num: Number.POSITIVE_INFINITY,
|
|
9364
|
-
exclusive: true
|
|
9365
|
-
};
|
|
9366
|
-
return [point1, point2];
|
|
9064
|
+
function isDecisiveMismatch(result) {
|
|
9065
|
+
return !hasEquals(result) && !hasContainedBy(result) && (hasContaining(result) || hasIntersection(result) || hasRejection(result));
|
|
9367
9066
|
}
|
|
9368
|
-
function
|
|
9369
|
-
|
|
9370
|
-
if (
|
|
9371
|
-
|
|
9067
|
+
function findMismatchPath(source, target) {
|
|
9068
|
+
const targetPath = getPath(target);
|
|
9069
|
+
if (!targetPath) return void 0;
|
|
9070
|
+
const sourceKind = getKind(source);
|
|
9071
|
+
const targetKind = getKind(target);
|
|
9072
|
+
if (sourceKind !== targetKind) return [...targetPath, "type"];
|
|
9073
|
+
const sourceSchema = source;
|
|
9074
|
+
const targetSchema = target;
|
|
9075
|
+
switch (targetKind) {
|
|
9076
|
+
case CompiledKind.String:
|
|
9077
|
+
if ((sourceSchema.minLength ?? 0) < (targetSchema.minLength ?? 0)) return [...targetPath, "minLength"];
|
|
9078
|
+
if ((sourceSchema.maxLength ?? Number.POSITIVE_INFINITY) > (targetSchema.maxLength ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxLength"];
|
|
9079
|
+
if (sourceSchema.pattern !== targetSchema.pattern && targetSchema.pattern) return [...targetPath, "pattern"];
|
|
9080
|
+
if (sourceSchema.format !== targetSchema.format && targetSchema.format) return [...targetPath, "format"];
|
|
9081
|
+
break;
|
|
9082
|
+
case CompiledKind.Numeric:
|
|
9083
|
+
if ((sourceSchema.minimum ?? sourceSchema.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) < (targetSchema.minimum ?? targetSchema.exclusiveMinimum ?? Number.NEGATIVE_INFINITY)) return [...targetPath, targetSchema.exclusiveMinimum == null ? "minimum" : "exclusiveMinimum"];
|
|
9084
|
+
if ((sourceSchema.maximum ?? sourceSchema.exclusiveMaximum ?? Number.POSITIVE_INFINITY) > (targetSchema.maximum ?? targetSchema.exclusiveMaximum ?? Number.POSITIVE_INFINITY)) return [...targetPath, targetSchema.exclusiveMaximum == null ? "maximum" : "exclusiveMaximum"];
|
|
9085
|
+
if (sourceSchema.multipleOf !== targetSchema.multipleOf && targetSchema.multipleOf != null) return [...targetPath, "multipleOf"];
|
|
9086
|
+
break;
|
|
9087
|
+
case CompiledKind.Array:
|
|
9088
|
+
if ((sourceSchema.minItems ?? 0) < (targetSchema.minItems ?? 0)) return [...targetPath, "minItems"];
|
|
9089
|
+
if ((sourceSchema.maxItems ?? Number.POSITIVE_INFINITY) > (targetSchema.maxItems ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxItems"];
|
|
9090
|
+
if (!sourceSchema.uniqueItems && targetSchema.uniqueItems) return [...targetPath, "uniqueItems"];
|
|
9091
|
+
break;
|
|
9092
|
+
case CompiledKind.Object: {
|
|
9093
|
+
const sourceRequired = new Set(sourceSchema.required ?? []);
|
|
9094
|
+
if ((targetSchema.required ?? []).some((key) => !sourceRequired.has(key))) return [...targetPath, "required"];
|
|
9095
|
+
if ((sourceSchema.minProperties ?? 0) < (targetSchema.minProperties ?? 0)) return [...targetPath, "minProperties"];
|
|
9096
|
+
if ((sourceSchema.maxProperties ?? Number.POSITIVE_INFINITY) > (targetSchema.maxProperties ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxProperties"];
|
|
9097
|
+
break;
|
|
9098
|
+
}
|
|
9099
|
+
case CompiledKind.EnumOrConst: return [...targetPath, targetSchema.const == null ? "enum" : "const"];
|
|
9100
|
+
}
|
|
9101
|
+
return targetPath;
|
|
9372
9102
|
}
|
|
9373
9103
|
//#endregion
|
|
9374
|
-
//#region src/json-schema-subset/
|
|
9375
|
-
|
|
9376
|
-
|
|
9377
|
-
|
|
9378
|
-
if (!integer1 && !integer2) return ExpressionEquals;
|
|
9379
|
-
if (!integer1) return ExpressionContainedBy;
|
|
9380
|
-
if (!integer2) return ExpressionContaining;
|
|
9381
|
-
const { range: range1, multipleOf: multipleOf1 } = integer1;
|
|
9382
|
-
const { range: range2, multipleOf: multipleOf2 } = integer2;
|
|
9383
|
-
const result = splitRange$3(range1, range2);
|
|
9384
|
-
let centerRange;
|
|
9385
|
-
let lcm = 0;
|
|
9386
|
-
if (result.center) {
|
|
9387
|
-
lcm = getLCM(multipleOf1, multipleOf2);
|
|
9388
|
-
centerRange = cutRange(result.center, lcm);
|
|
9104
|
+
//#region src/json-schema-subset/extends/extendsContext.ts
|
|
9105
|
+
var ExtendsContext = class ExtendsContext {
|
|
9106
|
+
constructor(extendsSchemaClasses = []) {
|
|
9107
|
+
this.extendsSchemaClasses = Object.freeze([...extendsSchemaClasses]);
|
|
9389
9108
|
}
|
|
9390
|
-
|
|
9391
|
-
|
|
9392
|
-
|
|
9393
|
-
const { left, right } = result;
|
|
9394
|
-
if (left && cutRange(left.range, left.fromLeft ? multipleOf1 : multipleOf2)) {
|
|
9395
|
-
if (left.fromLeft) extraLeft = true;
|
|
9396
|
-
else extraRight = true;
|
|
9109
|
+
tryCompiledExtendsSchema(target, payload) {
|
|
9110
|
+
for (const extendsSchemaClass of this.extendsSchemaClasses) if (extendsSchemaClass.isMatch(target)) return new extendsSchemaClass(createId(), target, payload);
|
|
9111
|
+
return null;
|
|
9397
9112
|
}
|
|
9398
|
-
|
|
9399
|
-
|
|
9400
|
-
|
|
9113
|
+
isExtendsSchema(target) {
|
|
9114
|
+
for (const extendsSchemaClass of this.extendsSchemaClasses) if (target instanceof extendsSchemaClass) return true;
|
|
9115
|
+
return false;
|
|
9401
9116
|
}
|
|
9402
|
-
|
|
9403
|
-
|
|
9404
|
-
|
|
9405
|
-
|
|
9406
|
-
|
|
9407
|
-
|
|
9408
|
-
|
|
9409
|
-
|
|
9410
|
-
|
|
9411
|
-
|
|
9412
|
-
|
|
9413
|
-
|
|
9414
|
-
|
|
9415
|
-
|
|
9416
|
-
|
|
9417
|
-
|
|
9418
|
-
|
|
9419
|
-
|
|
9117
|
+
calculate(schema1, schema2) {
|
|
9118
|
+
const shouldSwap = !(schema1 instanceof this.findMatchedClass(schema1, schema2));
|
|
9119
|
+
let expressionResult = 0;
|
|
9120
|
+
let result;
|
|
9121
|
+
if (shouldSwap) result = schema2.compare(schema1);
|
|
9122
|
+
else result = schema1.compare(schema2);
|
|
9123
|
+
for (let expression of result) {
|
|
9124
|
+
if (shouldSwap) expression = ExtendsContext.swap(expression);
|
|
9125
|
+
expressionResult |= toExpression(expression);
|
|
9126
|
+
}
|
|
9127
|
+
return expressionResult;
|
|
9128
|
+
}
|
|
9129
|
+
equals(schema1, schema2) {
|
|
9130
|
+
if (!(schema1 instanceof this.findMatchedClass(schema1, schema2))) return schema2.equals(schema1);
|
|
9131
|
+
else return schema1.equals(schema2);
|
|
9132
|
+
}
|
|
9133
|
+
findMatchedClass(schema1, schema2) {
|
|
9134
|
+
for (const schemaClass of this.extendsSchemaClasses) {
|
|
9135
|
+
if (schema1 instanceof schemaClass) return schemaClass;
|
|
9136
|
+
if (schema2 instanceof schemaClass) return schemaClass;
|
|
9137
|
+
}
|
|
9138
|
+
throw new Error("Invalid schema");
|
|
9139
|
+
}
|
|
9140
|
+
static swap(expression) {
|
|
9141
|
+
switch (expression) {
|
|
9142
|
+
case ExpressionSingleResult.Containing: return ExpressionSingleResult.ContainedBy;
|
|
9143
|
+
case ExpressionSingleResult.ContainedBy: return ExpressionSingleResult.Containing;
|
|
9144
|
+
default: return expression;
|
|
9145
|
+
}
|
|
9146
|
+
}
|
|
9147
|
+
};
|
|
9148
|
+
//#endregion
|
|
9149
|
+
//#region src/json-schema-subset/preprocessing.ts
|
|
9150
|
+
function preprocessSchema(schema, compile, printWarnLog = false) {
|
|
9151
|
+
const schemaResult = compile(schema);
|
|
9152
|
+
if (Array.isArray(schemaResult)) {
|
|
9153
|
+
const errorItems = [];
|
|
9154
|
+
collectWithPathPrefix(errorItems, schemaResult, "$");
|
|
9155
|
+
throw new SchemaError(errorItems);
|
|
9156
|
+
}
|
|
9157
|
+
const { schema: compiledSchema, warns } = schemaResult;
|
|
9158
|
+
if (printWarnLog && warns.length > 0) {
|
|
9159
|
+
console.warn(`found ${warns.length} warns after compile schema`);
|
|
9160
|
+
for (const warn of warns) console.warn(stringifySchemaError(warn));
|
|
9161
|
+
}
|
|
9162
|
+
return compiledSchema;
|
|
9420
9163
|
}
|
|
9421
|
-
|
|
9422
|
-
|
|
9423
|
-
|
|
9164
|
+
function preprocessSchemasPair(schema1, schema2, compile, printWarnLog = false) {
|
|
9165
|
+
const schemaResult1 = compile(schema1);
|
|
9166
|
+
const schemaResult2 = compile(schema2);
|
|
9167
|
+
if (Array.isArray(schemaResult1) || Array.isArray(schemaResult2)) {
|
|
9168
|
+
const errorItems = [];
|
|
9169
|
+
if (Array.isArray(schemaResult1)) collectWithPathPrefix(errorItems, schemaResult1, "$1");
|
|
9170
|
+
if (Array.isArray(schemaResult2)) collectWithPathPrefix(errorItems, schemaResult2, "$2");
|
|
9171
|
+
throw new SchemaError(errorItems);
|
|
9172
|
+
}
|
|
9173
|
+
const { schema: compiledSchema1, warns: superWarns } = schemaResult1;
|
|
9174
|
+
const { schema: compiledSchema2, warns: subWarns } = schemaResult2;
|
|
9175
|
+
if (printWarnLog) {
|
|
9176
|
+
if (superWarns.length > 0) console.warn(`found ${superWarns.length} warns after compile superSchema`);
|
|
9177
|
+
for (const warn of superWarns) console.warn(stringifySchemaError(warn));
|
|
9178
|
+
if (subWarns.length > 0) console.warn(`found ${subWarns.length} warns after compile subSchema`);
|
|
9179
|
+
for (const warn of subWarns) console.warn(stringifySchemaError(warn));
|
|
9180
|
+
}
|
|
9181
|
+
return [compiledSchema1, compiledSchema2];
|
|
9424
9182
|
}
|
|
9425
|
-
|
|
9426
|
-
|
|
9427
|
-
|
|
9428
|
-
|
|
9183
|
+
function collectWithPathPrefix(errorItems, compiledItems, prefix) {
|
|
9184
|
+
for (const compiledItem of compiledItems) {
|
|
9185
|
+
const replacedItem = {
|
|
9186
|
+
...compiledItem,
|
|
9187
|
+
path: [prefix, ...compiledItem.path]
|
|
9188
|
+
};
|
|
9189
|
+
errorItems.push(replacedItem);
|
|
9190
|
+
}
|
|
9429
9191
|
}
|
|
9430
|
-
|
|
9431
|
-
|
|
9432
|
-
|
|
9433
|
-
|
|
9192
|
+
//#endregion
|
|
9193
|
+
//#region src/json-schema-subset/global.ts
|
|
9194
|
+
var SubsetCompareResult = Object.freeze({
|
|
9195
|
+
True: 0,
|
|
9196
|
+
False: 1,
|
|
9197
|
+
Unknown: 2
|
|
9198
|
+
});
|
|
9199
|
+
function makeSubsetCompare({ extendsSchemaClasses, delegate } = {}) {
|
|
9200
|
+
const extendsContext = new ExtendsContext(extendsSchemaClasses);
|
|
9201
|
+
return Object.freeze({
|
|
9202
|
+
compile: (schema, payload, printWarnLog) => {
|
|
9203
|
+
const compiler = (candidate) => compile(candidate, extendsContext, payload, delegate);
|
|
9204
|
+
return preprocessSchema(schema, compiler, printWarnLog);
|
|
9205
|
+
},
|
|
9206
|
+
isSubset: (superSchema, subSchema, printWarnLog = false) => {
|
|
9207
|
+
const compiler = (candidate) => compile(candidate, extendsContext, void 0, delegate);
|
|
9208
|
+
const [schema1, schema2] = preprocessSchemasPair(superSchema, subSchema, compiler, printWarnLog);
|
|
9209
|
+
const { errorPath, expression } = checkWithResult(extendsContext, schema1, schema2);
|
|
9210
|
+
const foundTrueExpression = hasEquals(expression) || hasContainedBy(expression);
|
|
9211
|
+
const foundFalseExpression = hasContaining(expression) || hasIntersection(expression) || hasRejection(expression);
|
|
9212
|
+
if (foundTrueExpression && !foundFalseExpression) return { result: SubsetCompareResult.True };
|
|
9213
|
+
if (!foundTrueExpression && foundFalseExpression) return {
|
|
9214
|
+
errorPath,
|
|
9215
|
+
result: SubsetCompareResult.False
|
|
9216
|
+
};
|
|
9217
|
+
return { result: SubsetCompareResult.Unknown };
|
|
9218
|
+
}
|
|
9219
|
+
});
|
|
9434
9220
|
}
|
|
9435
9221
|
//#endregion
|
|
9436
|
-
//#region
|
|
9437
|
-
|
|
9438
|
-
|
|
9439
|
-
|
|
9440
|
-
|
|
9441
|
-
|
|
9442
|
-
|
|
9443
|
-
|
|
9444
|
-
|
|
9222
|
+
//#region ../../node_modules/.bun/@wopjs+cast@0.1.16/node_modules/@wopjs/cast/dist/index.mjs
|
|
9223
|
+
var isString = (x) => typeof x === "string";
|
|
9224
|
+
var isArray = Array.isArray;
|
|
9225
|
+
var isObject = (x) => x !== null && typeof x === "object";
|
|
9226
|
+
var isPlainObject = (x) => isObject(x) && !isArray(x);
|
|
9227
|
+
var toPlainObject = (x) => isPlainObject(x) ? x : void 0;
|
|
9228
|
+
//#endregion
|
|
9229
|
+
//#region src/manifest/common/schemaComparer.ts
|
|
9230
|
+
function isStringLikeSchema(value) {
|
|
9231
|
+
return toPlainObject(value)?.type === "string";
|
|
9445
9232
|
}
|
|
9446
|
-
function
|
|
9447
|
-
const
|
|
9448
|
-
|
|
9449
|
-
if (!
|
|
9450
|
-
if (multipleOf < 0) return true;
|
|
9451
|
-
return false;
|
|
9233
|
+
function assertSchemaCompareContext(value) {
|
|
9234
|
+
const context = toPlainObject(value);
|
|
9235
|
+
const error = toPlainObject(context?.error);
|
|
9236
|
+
if (context == null || error == null || context.packageId != null && !isString(context.packageId) || error.message != null && !isString(error.message)) throw new TypeError("Invalid schema comparison context.");
|
|
9452
9237
|
}
|
|
9453
|
-
function
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
return true;
|
|
9238
|
+
function parseSchemaCompareContext(value) {
|
|
9239
|
+
if (value == null) return { error: {} };
|
|
9240
|
+
assertSchemaCompareContext(value);
|
|
9241
|
+
return value;
|
|
9458
9242
|
}
|
|
9459
|
-
|
|
9460
|
-
|
|
9461
|
-
|
|
9462
|
-
|
|
9463
|
-
|
|
9464
|
-
|
|
9465
|
-
|
|
9466
|
-
|
|
9467
|
-
|
|
9468
|
-
|
|
9469
|
-
|
|
9470
|
-
|
|
9471
|
-
|
|
9472
|
-
|
|
9473
|
-
|
|
9474
|
-
|
|
9475
|
-
|
|
9476
|
-
const
|
|
9477
|
-
|
|
9478
|
-
|
|
9479
|
-
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
|
|
9483
|
-
|
|
9484
|
-
|
|
9485
|
-
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9243
|
+
var SpecialSchema = class SpecialSchema {
|
|
9244
|
+
static setError(fromSchema, toSchema, message) {
|
|
9245
|
+
if (fromSchema instanceof SpecialSchema) fromSchema.context.error.message = message;
|
|
9246
|
+
else if (toSchema instanceof SpecialSchema) toSchema.context.error.message = message;
|
|
9247
|
+
}
|
|
9248
|
+
constructor(id, value, context) {
|
|
9249
|
+
this.id = id;
|
|
9250
|
+
this.value = value;
|
|
9251
|
+
this.context = parseSchemaCompareContext(context);
|
|
9252
|
+
}
|
|
9253
|
+
compare(other) {
|
|
9254
|
+
if (isCompiledSchema(other) && getKind(other) === CompiledKind.Any) return [ExpressionSingleResult.ContainedBy];
|
|
9255
|
+
return this.compareImpl(other);
|
|
9256
|
+
}
|
|
9257
|
+
};
|
|
9258
|
+
var SingleSelectSchema = class SingleSelectSchema extends SpecialSchema {
|
|
9259
|
+
static isMatch(value) {
|
|
9260
|
+
const enumValues = toPlainObject(value)?.enum;
|
|
9261
|
+
return Array.isArray(enumValues) && enumValues.every((v) => isString(v));
|
|
9262
|
+
}
|
|
9263
|
+
constructor(id, value, context) {
|
|
9264
|
+
if (!SingleSelectSchema.isMatch(value)) throw new TypeError("Invalid single-select schema.");
|
|
9265
|
+
super(id, value, context);
|
|
9266
|
+
}
|
|
9267
|
+
compareImpl(other) {
|
|
9268
|
+
if (isStringLikeSchema(other)) return [ExpressionSingleResult.ContainedBy];
|
|
9269
|
+
if (other instanceof SingleSelectSchema) {
|
|
9270
|
+
const f = new Set(this.value.enum);
|
|
9271
|
+
let result = ExpressionSingleResult.Equals;
|
|
9272
|
+
for (const v of other.value.enum) {
|
|
9273
|
+
if (!f.has(v)) result = ExpressionSingleResult.ContainedBy;
|
|
9274
|
+
f.delete(v);
|
|
9275
|
+
}
|
|
9276
|
+
if (f.size === 0) return [result];
|
|
9277
|
+
if (f.size === this.value.enum.length) return [ExpressionSingleResult.Rejection];
|
|
9278
|
+
return [ExpressionSingleResult.Intersection];
|
|
9492
9279
|
}
|
|
9493
|
-
|
|
9494
|
-
|
|
9495
|
-
|
|
9496
|
-
|
|
9497
|
-
|
|
9280
|
+
return [ExpressionSingleResult.Rejection];
|
|
9281
|
+
}
|
|
9282
|
+
equals(other) {
|
|
9283
|
+
if (other instanceof SingleSelectSchema) {
|
|
9284
|
+
const f = new Set(this.value.enum);
|
|
9285
|
+
for (const v of other.value.enum) {
|
|
9286
|
+
if (!f.has(v)) return false;
|
|
9287
|
+
f.delete(v);
|
|
9288
|
+
}
|
|
9289
|
+
return f.size === 0;
|
|
9498
9290
|
}
|
|
9291
|
+
return false;
|
|
9499
9292
|
}
|
|
9500
|
-
|
|
9501
|
-
|
|
9502
|
-
|
|
9503
|
-
|
|
9293
|
+
};
|
|
9294
|
+
var BinarySchema = class BinarySchema extends SpecialSchema {
|
|
9295
|
+
static isMatch(value) {
|
|
9296
|
+
return toPlainObject(value)?.contentMediaType === "oomol/bin";
|
|
9297
|
+
}
|
|
9298
|
+
constructor(id, value, context) {
|
|
9299
|
+
if (!BinarySchema.isMatch(value)) throw new TypeError("Invalid binary schema.");
|
|
9300
|
+
super(id, value, context);
|
|
9301
|
+
}
|
|
9302
|
+
compareImpl(other) {
|
|
9303
|
+
if (other instanceof BinarySchema) return [ExpressionSingleResult.Equals];
|
|
9304
|
+
else {
|
|
9305
|
+
SpecialSchema.setError(this, other, "edgeError.binDiffType");
|
|
9306
|
+
return [ExpressionSingleResult.Rejection];
|
|
9504
9307
|
}
|
|
9505
|
-
});
|
|
9506
|
-
const { requiredKeysCount } = splitRequiredResult;
|
|
9507
|
-
let expression = 0;
|
|
9508
|
-
for (const { hasExtra1, hasExtra2, hasCommonInRequired, hasCommonOutRequired, hasRejection } of quantumVariable) if (!hasCommonInRequired && requiredKeysCount > 0) expression |= ExpressionRejection;
|
|
9509
|
-
else if (!hasCommonOutRequired && requiredKeysCount === 0) expression |= ExpressionRejection;
|
|
9510
|
-
else if (hasRejection) expression |= ExpressionRejection;
|
|
9511
|
-
else if (hasExtra1 && hasExtra2) expression |= ExpressionIntersection;
|
|
9512
|
-
else if (hasExtra1) expression |= ExpressionContaining;
|
|
9513
|
-
else if (hasExtra2) expression |= ExpressionContainedBy;
|
|
9514
|
-
else expression |= ExpressionEquals;
|
|
9515
|
-
return expression;
|
|
9516
|
-
}
|
|
9517
|
-
function isPropertiesCountCannotMatch(schema1, schema2) {
|
|
9518
|
-
return toExpressionSingleResult(splitRange$1(schema1.minProperties, schema1.maxProperties, schema2.minProperties, schema2.maxProperties)) === ExpressionSingleResult.Rejection;
|
|
9519
|
-
}
|
|
9520
|
-
function splitRequired(schema1, schema2) {
|
|
9521
|
-
const extraRequired1 = new Set(schema1.required);
|
|
9522
|
-
const extraRequired2 = new Set(schema2.required);
|
|
9523
|
-
const commonRequired = /* @__PURE__ */ new Set();
|
|
9524
|
-
const wholeRequired = /* @__PURE__ */ new Set();
|
|
9525
|
-
const requiredCount1 = extraRequired1.size;
|
|
9526
|
-
const requiredCount2 = extraRequired2.size;
|
|
9527
|
-
for (const key of extraRequired1) {
|
|
9528
|
-
if (extraRequired2.has(key)) commonRequired.add(key);
|
|
9529
|
-
wholeRequired.add(key);
|
|
9530
9308
|
}
|
|
9531
|
-
|
|
9532
|
-
|
|
9533
|
-
wholeRequired.add(key);
|
|
9309
|
+
equals(other) {
|
|
9310
|
+
return other instanceof BinarySchema;
|
|
9534
9311
|
}
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9312
|
+
};
|
|
9313
|
+
var ArtifactSchema = class ArtifactSchema extends SpecialSchema {
|
|
9314
|
+
static isMatch(value) {
|
|
9315
|
+
return toPlainObject(value)?.contentMediaType === "oomol/artifact";
|
|
9539
9316
|
}
|
|
9540
|
-
|
|
9541
|
-
|
|
9542
|
-
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
|
|
9546
|
-
|
|
9547
|
-
|
|
9548
|
-
|
|
9549
|
-
|
|
9550
|
-
|
|
9317
|
+
constructor(id, value, context) {
|
|
9318
|
+
if (!ArtifactSchema.isMatch(value)) throw new TypeError("Invalid Artifact schema.");
|
|
9319
|
+
super(id, value, context);
|
|
9320
|
+
}
|
|
9321
|
+
compareImpl(other) {
|
|
9322
|
+
if (other instanceof ArtifactSchema) return [ExpressionSingleResult.Equals];
|
|
9323
|
+
SpecialSchema.setError(this, other, "edgeError.artifactDiffType");
|
|
9324
|
+
return [ExpressionSingleResult.Rejection];
|
|
9325
|
+
}
|
|
9326
|
+
equals(other) {
|
|
9327
|
+
return other instanceof ArtifactSchema;
|
|
9328
|
+
}
|
|
9329
|
+
};
|
|
9330
|
+
function createSchemaComparer() {
|
|
9331
|
+
return makeSubsetCompare({ extendsSchemaClasses: [
|
|
9332
|
+
SingleSelectSchema,
|
|
9333
|
+
BinarySchema,
|
|
9334
|
+
ArtifactSchema
|
|
9335
|
+
] });
|
|
9551
9336
|
}
|
|
9552
|
-
|
|
9553
|
-
|
|
9554
|
-
|
|
9555
|
-
|
|
9556
|
-
|
|
9557
|
-
const required2 = schema2.required;
|
|
9558
|
-
if (properties1) for (const key in properties1) optionalKeys.add(key);
|
|
9559
|
-
if (properties2) for (const key in properties2) optionalKeys.add(key);
|
|
9560
|
-
if (required1) for (const key of required1) optionalKeys.delete(key);
|
|
9561
|
-
if (required2) for (const key of required2) optionalKeys.delete(key);
|
|
9562
|
-
return optionalKeys;
|
|
9337
|
+
createSchemaComparer();
|
|
9338
|
+
//#endregion
|
|
9339
|
+
//#region src/flow/common/schema.ts
|
|
9340
|
+
function schemaObject(schema) {
|
|
9341
|
+
return schema != null && typeof schema == "object" && !Array.isArray(schema) ? schema : void 0;
|
|
9563
9342
|
}
|
|
9564
|
-
var
|
|
9565
|
-
|
|
9566
|
-
|
|
9567
|
-
|
|
9568
|
-
|
|
9569
|
-
|
|
9570
|
-
|
|
9571
|
-
|
|
9572
|
-
|
|
9573
|
-
|
|
9574
|
-
|
|
9575
|
-
|
|
9576
|
-
|
|
9577
|
-
|
|
9578
|
-
|
|
9579
|
-
|
|
9580
|
-
|
|
9581
|
-
|
|
9582
|
-
|
|
9343
|
+
var validators = /* @__PURE__ */ new WeakMap();
|
|
9344
|
+
function matchesSchema(value, schema) {
|
|
9345
|
+
return schemaValidationErrors(value, schema).length == 0;
|
|
9346
|
+
}
|
|
9347
|
+
function schemaValidationErrors(value, schema) {
|
|
9348
|
+
if (typeof schema == "boolean") return schema ? [] : ["The schema does not allow any value."];
|
|
9349
|
+
const source = schemaObject(schema);
|
|
9350
|
+
if (source == null || source.properties != null && schemaObject(source.properties) == null) return ["Invalid output schema."];
|
|
9351
|
+
try {
|
|
9352
|
+
let validator = validators.get(source);
|
|
9353
|
+
if (validator == null) {
|
|
9354
|
+
const declaration = typeof source.$schema == "string" ? source.$schema : "";
|
|
9355
|
+
const draft = declaration.includes("draft-04") ? "4" : declaration.includes("draft-07") ? "7" : declaration.includes("2020-12") ? "2020-12" : "2019-09";
|
|
9356
|
+
validator = new Validator(structuredClone(source), draft);
|
|
9357
|
+
validators.set(source, validator);
|
|
9358
|
+
}
|
|
9359
|
+
const result = validator.validate(value);
|
|
9360
|
+
return result.valid ? [] : result.errors.map((issue) => `${issue.instanceLocation || "/"}: ${issue.error}`);
|
|
9361
|
+
} catch {
|
|
9362
|
+
return ["Output schema validation failed."];
|
|
9583
9363
|
}
|
|
9364
|
+
}
|
|
9365
|
+
//#endregion
|
|
9366
|
+
//#region src/decision/common/decision.ts
|
|
9367
|
+
var decisionLimits = {
|
|
9368
|
+
choice: 255,
|
|
9369
|
+
score: 10
|
|
9584
9370
|
};
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
|
|
9590
|
-
|
|
9591
|
-
|
|
9592
|
-
|
|
9593
|
-
|
|
9594
|
-
|
|
9595
|
-
|
|
9596
|
-
|
|
9371
|
+
/** Ordered prefixes are shared by authoring, schemas, validation, and execution. */
|
|
9372
|
+
function limitDecisionQuestion(question) {
|
|
9373
|
+
if (question.type === "noul" || question.criteria.length <= decisionLimits[question.type]) return question;
|
|
9374
|
+
if (question.type === "choice") return {
|
|
9375
|
+
...question,
|
|
9376
|
+
criteria: question.criteria.slice(0, decisionLimits.choice)
|
|
9377
|
+
};
|
|
9378
|
+
return {
|
|
9379
|
+
...question,
|
|
9380
|
+
criteria: question.criteria.slice(0, decisionLimits.score)
|
|
9381
|
+
};
|
|
9382
|
+
}
|
|
9383
|
+
function limitDecisionQuestions(questions) {
|
|
9384
|
+
const limited = questions.map(limitDecisionQuestion);
|
|
9385
|
+
return limited.every((question, i) => question === questions[i]) ? questions : limited;
|
|
9386
|
+
}
|
|
9387
|
+
/** Loading an oversized task also updates its previously generated output schemas. */
|
|
9388
|
+
function limitDecisionTask(task) {
|
|
9389
|
+
if (task.executor.kind !== "decision") return task;
|
|
9390
|
+
const original = task.executor.questions;
|
|
9391
|
+
const questions = limitDecisionQuestions(original);
|
|
9392
|
+
if (questions === original) return task;
|
|
9393
|
+
const outputs = task.outputs.map((port) => {
|
|
9394
|
+
if (!("handle" in port)) return port;
|
|
9395
|
+
const index = original.findIndex((question) => question.name === port.handle);
|
|
9396
|
+
if (index < 0 || original[index] === questions[index] || !dequal(port.jsonSchema, answerSchema(original[index]))) return port;
|
|
9397
|
+
return {
|
|
9398
|
+
...port,
|
|
9399
|
+
jsonSchema: decisionAnswerSchema(questions[index])
|
|
9400
|
+
};
|
|
9401
|
+
});
|
|
9402
|
+
return {
|
|
9403
|
+
...task,
|
|
9404
|
+
executor: {
|
|
9405
|
+
...task.executor,
|
|
9406
|
+
questions
|
|
9407
|
+
},
|
|
9408
|
+
outputs
|
|
9409
|
+
};
|
|
9410
|
+
}
|
|
9411
|
+
var probability = {
|
|
9412
|
+
type: "number",
|
|
9413
|
+
minimum: 0,
|
|
9414
|
+
maximum: 1
|
|
9415
|
+
};
|
|
9416
|
+
function decisionAnswerSchema(question) {
|
|
9417
|
+
return answerSchema(limitDecisionQuestion(question));
|
|
9418
|
+
}
|
|
9419
|
+
function answerSchema(question) {
|
|
9420
|
+
const properties = { type: { const: question.type } };
|
|
9421
|
+
if (question.type === "noul") properties.noul = probability;
|
|
9422
|
+
else {
|
|
9423
|
+
const keys = question.type === "choice" ? question.criteria.map((item) => item.name) : question.criteria.map((_, index) => String(index));
|
|
9424
|
+
properties.confidence = probability;
|
|
9425
|
+
properties.probabilities = {
|
|
9426
|
+
type: "object",
|
|
9427
|
+
properties: Object.fromEntries(keys.map((key) => [key, probability])),
|
|
9428
|
+
required: keys,
|
|
9429
|
+
additionalProperties: false
|
|
9430
|
+
};
|
|
9431
|
+
if (question.type === "choice") properties.choice = {
|
|
9432
|
+
type: "string",
|
|
9433
|
+
...keys.length ? { enum: keys } : {}
|
|
9434
|
+
};
|
|
9435
|
+
else {
|
|
9436
|
+
properties.score = {
|
|
9437
|
+
type: "number",
|
|
9438
|
+
minimum: 0,
|
|
9439
|
+
maximum: Math.max(0, keys.length - 1)
|
|
9440
|
+
};
|
|
9441
|
+
properties.legend = {
|
|
9442
|
+
type: "object",
|
|
9443
|
+
properties: Object.fromEntries(keys.map((key) => [key, { type: "string" }])),
|
|
9444
|
+
required: keys,
|
|
9445
|
+
additionalProperties: false
|
|
9446
|
+
};
|
|
9447
|
+
}
|
|
9597
9448
|
}
|
|
9449
|
+
return {
|
|
9450
|
+
type: "object",
|
|
9451
|
+
properties,
|
|
9452
|
+
required: Object.keys(properties)
|
|
9453
|
+
};
|
|
9454
|
+
}
|
|
9455
|
+
//#endregion
|
|
9456
|
+
//#region src/flow/common/triggerScheduleSchema.ts
|
|
9457
|
+
var triggerScheduleSchema = array(union([object({
|
|
9458
|
+
type: literal("cron"),
|
|
9459
|
+
expression: string(),
|
|
9460
|
+
timezone: string()
|
|
9461
|
+
}), object({
|
|
9462
|
+
type: literal("every"),
|
|
9463
|
+
unit: _enum([
|
|
9464
|
+
"day",
|
|
9465
|
+
"hour",
|
|
9466
|
+
"minute",
|
|
9467
|
+
"month",
|
|
9468
|
+
"week"
|
|
9469
|
+
]),
|
|
9470
|
+
value: number()
|
|
9471
|
+
})]));
|
|
9472
|
+
//#endregion
|
|
9473
|
+
//#region src/flow/common/webhookMethod.ts
|
|
9474
|
+
var webhookMethods = [
|
|
9475
|
+
"GET",
|
|
9476
|
+
"POST",
|
|
9477
|
+
"PUT",
|
|
9478
|
+
"PATCH",
|
|
9479
|
+
"DELETE"
|
|
9480
|
+
];
|
|
9481
|
+
function webhookSupportsBody(method) {
|
|
9482
|
+
return method !== "GET";
|
|
9483
|
+
}
|
|
9484
|
+
var text = string();
|
|
9485
|
+
var json = json$1();
|
|
9486
|
+
var strings = array(text);
|
|
9487
|
+
var port = object({
|
|
9488
|
+
description: text.optional(),
|
|
9489
|
+
jsonSchema: json,
|
|
9490
|
+
nullable: boolean(),
|
|
9491
|
+
handle: text
|
|
9492
|
+
});
|
|
9493
|
+
var input = port.extend({ value: json.optional() });
|
|
9494
|
+
var group = object({
|
|
9495
|
+
collapsed: boolean().optional(),
|
|
9496
|
+
group: text
|
|
9497
|
+
});
|
|
9498
|
+
var nodeSource = object({
|
|
9499
|
+
kind: literal("node"),
|
|
9500
|
+
nodeId: text,
|
|
9501
|
+
output: text,
|
|
9502
|
+
field: text.optional()
|
|
9503
|
+
});
|
|
9504
|
+
var flowSource = object({
|
|
9505
|
+
kind: literal("flow"),
|
|
9506
|
+
input: text
|
|
9507
|
+
});
|
|
9508
|
+
var source = union([
|
|
9509
|
+
nodeSource,
|
|
9510
|
+
flowSource,
|
|
9511
|
+
object({
|
|
9512
|
+
kind: literal("binding"),
|
|
9513
|
+
bindingId: text
|
|
9514
|
+
})
|
|
9515
|
+
]);
|
|
9516
|
+
var fixedInput = union([object({ kind: literal("unset") }), object({
|
|
9517
|
+
kind: literal("value"),
|
|
9518
|
+
value: json
|
|
9519
|
+
})]);
|
|
9520
|
+
var mapping = union([fixedInput, object({
|
|
9521
|
+
kind: literal("sources"),
|
|
9522
|
+
sources: array(source)
|
|
9523
|
+
})]);
|
|
9524
|
+
var inputs = record(text, mapping);
|
|
9525
|
+
var ports = {
|
|
9526
|
+
inputs: array(union([input, group])),
|
|
9527
|
+
outputs: array(union([port, group]))
|
|
9528
|
+
};
|
|
9529
|
+
var capability = union([
|
|
9530
|
+
strictObject({
|
|
9531
|
+
kind: literal("connector"),
|
|
9532
|
+
action: text,
|
|
9533
|
+
connectionId: text.optional(),
|
|
9534
|
+
connections: array(strictObject({
|
|
9535
|
+
connectionId: text,
|
|
9536
|
+
alias: text.optional()
|
|
9537
|
+
}))
|
|
9538
|
+
}),
|
|
9539
|
+
strictObject({
|
|
9540
|
+
kind: literal("connector"),
|
|
9541
|
+
mode: literal("shared")
|
|
9542
|
+
}),
|
|
9543
|
+
strictObject({
|
|
9544
|
+
kind: literal("connector"),
|
|
9545
|
+
mode: literal("independent"),
|
|
9546
|
+
actions: array(strictObject({
|
|
9547
|
+
action: text,
|
|
9548
|
+
connectionId: text.optional()
|
|
9549
|
+
}))
|
|
9550
|
+
}),
|
|
9551
|
+
strictObject({
|
|
9552
|
+
kind: literal("connector"),
|
|
9553
|
+
actionHints: array(text).optional(),
|
|
9554
|
+
connectionHints: array(strictObject({
|
|
9555
|
+
action: text,
|
|
9556
|
+
connectionId: text,
|
|
9557
|
+
alias: text.optional()
|
|
9558
|
+
})).optional()
|
|
9559
|
+
})
|
|
9560
|
+
]);
|
|
9561
|
+
var inline = object({
|
|
9562
|
+
...ports,
|
|
9563
|
+
name: text,
|
|
9564
|
+
moduleId: text,
|
|
9565
|
+
capabilities: array(capability).optional()
|
|
9566
|
+
});
|
|
9567
|
+
var agentValue = union([object({
|
|
9568
|
+
kind: literal("value"),
|
|
9569
|
+
value: json
|
|
9570
|
+
}), object({
|
|
9571
|
+
kind: literal("input"),
|
|
9572
|
+
input: text
|
|
9573
|
+
})]);
|
|
9574
|
+
var agentInput$1 = union([agentValue, object({ kind: literal("model") })]);
|
|
9575
|
+
var decisionQuestion = discriminatedUnion("type", [
|
|
9576
|
+
strictObject({
|
|
9577
|
+
name: text,
|
|
9578
|
+
instructions: text,
|
|
9579
|
+
type: literal("noul"),
|
|
9580
|
+
criteria: strictObject({
|
|
9581
|
+
true: text.optional(),
|
|
9582
|
+
false: text.optional()
|
|
9583
|
+
}).optional()
|
|
9584
|
+
}),
|
|
9585
|
+
strictObject({
|
|
9586
|
+
name: text,
|
|
9587
|
+
instructions: text,
|
|
9588
|
+
type: literal("choice"),
|
|
9589
|
+
criteria: array(strictObject({
|
|
9590
|
+
name: text,
|
|
9591
|
+
description: text
|
|
9592
|
+
}))
|
|
9593
|
+
}),
|
|
9594
|
+
strictObject({
|
|
9595
|
+
name: text,
|
|
9596
|
+
instructions: text,
|
|
9597
|
+
type: literal("score"),
|
|
9598
|
+
criteria: strings
|
|
9599
|
+
})
|
|
9600
|
+
]);
|
|
9601
|
+
var managed = object({
|
|
9602
|
+
...ports,
|
|
9603
|
+
name: text,
|
|
9604
|
+
executor: union([
|
|
9605
|
+
object({
|
|
9606
|
+
kind: literal("connector"),
|
|
9607
|
+
action: text,
|
|
9608
|
+
connectionId: text.optional()
|
|
9609
|
+
}),
|
|
9610
|
+
object({
|
|
9611
|
+
kind: literal("openapi"),
|
|
9612
|
+
sourceUrl: text,
|
|
9613
|
+
method: text,
|
|
9614
|
+
path: text,
|
|
9615
|
+
serverUrl: text,
|
|
9616
|
+
document: json,
|
|
9617
|
+
auth: array(object({
|
|
9618
|
+
id: text,
|
|
9619
|
+
type: _enum([
|
|
9620
|
+
"bearer",
|
|
9621
|
+
"basic",
|
|
9622
|
+
"apiKey"
|
|
9623
|
+
]),
|
|
9624
|
+
name: text.optional(),
|
|
9625
|
+
in: _enum(["header", "query"]).optional()
|
|
9626
|
+
}))
|
|
9627
|
+
}),
|
|
9628
|
+
strictObject({
|
|
9629
|
+
kind: literal("decision"),
|
|
9630
|
+
questions: array(decisionQuestion)
|
|
9631
|
+
}),
|
|
9632
|
+
object({
|
|
9633
|
+
kind: literal("llm"),
|
|
9634
|
+
mode: _enum(["chat", "json"])
|
|
9635
|
+
}),
|
|
9636
|
+
object({
|
|
9637
|
+
kind: literal("agent"),
|
|
9638
|
+
code: boolean().optional(),
|
|
9639
|
+
model: text,
|
|
9640
|
+
prompt: text,
|
|
9641
|
+
maxRounds: number(),
|
|
9642
|
+
tools: array(object({
|
|
9643
|
+
id: text,
|
|
9644
|
+
name: text,
|
|
9645
|
+
description: text,
|
|
9646
|
+
action: text,
|
|
9647
|
+
connectionId: text.optional(),
|
|
9648
|
+
approval: boolean(),
|
|
9649
|
+
inputs: array(input.extend({ source: agentInput$1 }))
|
|
9650
|
+
})),
|
|
9651
|
+
notification: object({
|
|
9652
|
+
taskId: text,
|
|
9653
|
+
messageHandle: text,
|
|
9654
|
+
inputs: record(text, agentValue)
|
|
9655
|
+
}).optional()
|
|
9656
|
+
})
|
|
9657
|
+
])
|
|
9658
|
+
}).transform(limitDecisionTask);
|
|
9659
|
+
var operand = union([object({
|
|
9660
|
+
kind: literal("value"),
|
|
9661
|
+
value: json.optional(),
|
|
9662
|
+
jsonSchema: json.optional()
|
|
9663
|
+
}), object({
|
|
9664
|
+
kind: literal("source"),
|
|
9665
|
+
source
|
|
9666
|
+
})]);
|
|
9667
|
+
var condition = {
|
|
9668
|
+
matchMode: _enum(["first", "all"]),
|
|
9669
|
+
cases: array(object({
|
|
9670
|
+
description: text.optional(),
|
|
9671
|
+
output: text,
|
|
9672
|
+
groups: array(object({ expressions: array(object({
|
|
9673
|
+
left: operand,
|
|
9674
|
+
operator: _enum([
|
|
9675
|
+
"!=",
|
|
9676
|
+
"<",
|
|
9677
|
+
"<=",
|
|
9678
|
+
"==",
|
|
9679
|
+
">",
|
|
9680
|
+
">=",
|
|
9681
|
+
"contains",
|
|
9682
|
+
"endsWith",
|
|
9683
|
+
"hasKey",
|
|
9684
|
+
"hasValue",
|
|
9685
|
+
"isEmpty",
|
|
9686
|
+
"isFalse",
|
|
9687
|
+
"isNotEmpty",
|
|
9688
|
+
"isNotNull",
|
|
9689
|
+
"isNull",
|
|
9690
|
+
"isTrue",
|
|
9691
|
+
"notContains",
|
|
9692
|
+
"notHasKey",
|
|
9693
|
+
"notHasValue",
|
|
9694
|
+
"startsWith"
|
|
9695
|
+
]),
|
|
9696
|
+
right: operand.optional()
|
|
9697
|
+
})) }))
|
|
9698
|
+
}))
|
|
9598
9699
|
};
|
|
9599
|
-
var
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
case ExpressionSingleResult.Containing:
|
|
9603
|
-
variable.hasCommonInRequired = true;
|
|
9604
|
-
break;
|
|
9605
|
-
case ExpressionSingleResult.Intersection:
|
|
9606
|
-
case ExpressionSingleResult.ContainedBy:
|
|
9607
|
-
variable.hasExtra2 = true;
|
|
9608
|
-
variable.hasCommonInRequired = true;
|
|
9609
|
-
break;
|
|
9610
|
-
case ExpressionSingleResult.Rejection: variable.hasRejection = true;
|
|
9611
|
-
}
|
|
9700
|
+
var wait = {
|
|
9701
|
+
inputDefinitions: array(input),
|
|
9702
|
+
prompt: text
|
|
9612
9703
|
};
|
|
9613
|
-
var
|
|
9614
|
-
|
|
9615
|
-
|
|
9616
|
-
|
|
9617
|
-
|
|
9618
|
-
|
|
9619
|
-
|
|
9620
|
-
|
|
9621
|
-
|
|
9622
|
-
|
|
9623
|
-
|
|
9624
|
-
|
|
9625
|
-
break;
|
|
9626
|
-
case ExpressionSingleResult.ContainedBy:
|
|
9627
|
-
foundExtraPossibility2 = true;
|
|
9628
|
-
foundCommonPossibility = true;
|
|
9629
|
-
break;
|
|
9630
|
-
case ExpressionSingleResult.Intersection:
|
|
9631
|
-
foundExtraPossibility1 = true;
|
|
9632
|
-
foundExtraPossibility2 = true;
|
|
9633
|
-
foundCommonPossibility = true;
|
|
9634
|
-
break;
|
|
9635
|
-
case ExpressionSingleResult.Rejection:
|
|
9636
|
-
foundExtraPossibility1 = true;
|
|
9637
|
-
foundExtraPossibility2 = true;
|
|
9638
|
-
}
|
|
9639
|
-
if (hasOptional1 && foundExtraPossibility1) variable.hasExtra1 = true;
|
|
9640
|
-
if (hasOptional2 && foundExtraPossibility2) variable.hasExtra2 = true;
|
|
9641
|
-
if (hasOptional1 && hasOptional2 && foundCommonPossibility) variable.hasCommonOutRequired = true;
|
|
9704
|
+
var webhookOptions = object({
|
|
9705
|
+
allowedMethods: never().optional(),
|
|
9706
|
+
allowedOrigins: strings.optional(),
|
|
9707
|
+
noResponseBody: never().optional(),
|
|
9708
|
+
responseData: text.optional(),
|
|
9709
|
+
responseHeaders: record(text, text).optional(),
|
|
9710
|
+
responseStatusCode: number().int().min(200).max(599).optional()
|
|
9711
|
+
});
|
|
9712
|
+
var webhook = {
|
|
9713
|
+
bodyFields: array(input),
|
|
9714
|
+
method: _enum(webhookMethods),
|
|
9715
|
+
options: webhookOptions.optional()
|
|
9642
9716
|
};
|
|
9643
|
-
|
|
9644
|
-
|
|
9645
|
-
|
|
9646
|
-
|
|
9647
|
-
|
|
9648
|
-
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
pattern: regExp,
|
|
9653
|
-
schema: valueSchema
|
|
9654
|
-
});
|
|
9655
|
-
}
|
|
9656
|
-
return (key) => {
|
|
9657
|
-
if (propertyNames && valid(propertyNames, key) === ValidResult.Invalid) return NEVER;
|
|
9658
|
-
for (const { pattern, schema: patternSchema } of patternProperties) if (pattern.test(key)) return patternSchema;
|
|
9659
|
-
const propertySchema = (properties && properties[key]) ?? additionalProperties;
|
|
9660
|
-
if (!propertySchema) return ANY;
|
|
9661
|
-
return propertySchema;
|
|
9662
|
-
};
|
|
9663
|
-
}
|
|
9664
|
-
function areNotBothNever(schema1, schema2) {
|
|
9665
|
-
const kind1 = getKind(schema1);
|
|
9666
|
-
const kind2 = getKind(schema2);
|
|
9667
|
-
return kind1 !== CompiledKind.Never || kind2 !== CompiledKind.Never;
|
|
9668
|
-
}
|
|
9669
|
-
//#endregion
|
|
9670
|
-
//#region src/json-schema-subset/checker/string.ts
|
|
9671
|
-
var splitRange = createRangeSplitter(0);
|
|
9672
|
-
function calculateString(schema1, schema2) {
|
|
9673
|
-
if (schema2.format && !schema1.format) return ExpressionContaining;
|
|
9674
|
-
if (schema1.format && schema2.format && schema1.format !== schema2.format) return ExpressionAny;
|
|
9675
|
-
const expression = toExpressionSingleResult(splitRange(schema1.minLength, schema1.maxLength, schema2.minLength, schema2.maxLength));
|
|
9676
|
-
const hasPattern1 = !!schema1.pattern;
|
|
9677
|
-
const hasPattern2 = !!schema2.pattern;
|
|
9678
|
-
switch (expression) {
|
|
9679
|
-
case ExpressionSingleResult.Rejection: return ExpressionRejection;
|
|
9680
|
-
case ExpressionSingleResult.Containing: return hasPattern1 ? ExpressionAny : ExpressionContaining;
|
|
9681
|
-
case ExpressionSingleResult.ContainedBy: return hasPattern2 ? ExpressionAny : ExpressionContainedBy;
|
|
9682
|
-
case ExpressionSingleResult.Equals:
|
|
9683
|
-
if (hasPattern1 && hasPattern2) return schema1.pattern === schema2.pattern ? ExpressionEquals : ExpressionAny;
|
|
9684
|
-
if (hasPattern1) return ExpressionEquals | ExpressionContainedBy;
|
|
9685
|
-
if (hasPattern2) return ExpressionEquals | ExpressionContaining;
|
|
9686
|
-
return ExpressionEquals;
|
|
9687
|
-
case ExpressionSingleResult.Intersection:
|
|
9688
|
-
if (hasPattern1 && hasPattern2) return ExpressionAny;
|
|
9689
|
-
if (hasPattern1) return ExpressionIntersection | ExpressionRejection | ExpressionContainedBy;
|
|
9690
|
-
if (hasPattern2) return ExpressionIntersection | ExpressionRejection | ExpressionContaining;
|
|
9691
|
-
return ExpressionIntersection;
|
|
9692
|
-
}
|
|
9693
|
-
}
|
|
9694
|
-
//#endregion
|
|
9695
|
-
//#region src/json-schema-subset/checker/checker.ts
|
|
9696
|
-
function checkWithResult(extendsContext, schema1, schema2) {
|
|
9697
|
-
const context = {};
|
|
9698
|
-
const errorPaths = [];
|
|
9699
|
-
const calculate = wrapSchemaCalculatorWithCache(calculator(extendsContext, context));
|
|
9700
|
-
const describe = describer();
|
|
9701
|
-
const equals = schemaEqualsChecker(extendsContext);
|
|
9702
|
-
context.isEquals = wrapEqualsCheckerWithCache(isDeepEquals);
|
|
9703
|
-
context.calculate = expression({
|
|
9704
|
-
describe,
|
|
9705
|
-
equals,
|
|
9706
|
-
calculate,
|
|
9707
|
-
observeCalculation: (left, right, result, swapped) => {
|
|
9708
|
-
if (!isDecisiveMismatch(swapped ? swap(result) : result)) return;
|
|
9709
|
-
const errorPath = swapped ? findMismatchPath(right, left) : findMismatchPath(left, right);
|
|
9710
|
-
if (errorPath) errorPaths.push(errorPath);
|
|
9711
|
-
}
|
|
9712
|
-
});
|
|
9713
|
-
Object.freeze(context);
|
|
9714
|
-
const comparisonExpression = context.calculate(schema1, schema2);
|
|
9715
|
-
return {
|
|
9716
|
-
errorPath: errorPaths[0],
|
|
9717
|
-
expression: comparisonExpression
|
|
9718
|
-
};
|
|
9719
|
-
}
|
|
9720
|
-
var describer = () => (schema) => {
|
|
9721
|
-
let description;
|
|
9722
|
-
switch (getKind(schema)) {
|
|
9723
|
-
case CompiledKind.Not:
|
|
9724
|
-
description = {
|
|
9725
|
-
kind: ExpressionKind.Not,
|
|
9726
|
-
expression: schema.not
|
|
9727
|
-
};
|
|
9728
|
-
break;
|
|
9729
|
-
case CompiledKind.Combination:
|
|
9730
|
-
if ("allOf" in schema) description = {
|
|
9731
|
-
kind: ExpressionKind.AllOf,
|
|
9732
|
-
expressions: rejectInSchemaList(schema.allOf, CompiledKind.Any)
|
|
9733
|
-
};
|
|
9734
|
-
else if ("anyOf" in schema) description = {
|
|
9735
|
-
kind: ExpressionKind.AnyOf,
|
|
9736
|
-
expressions: rejectInSchemaList(schema.anyOf, CompiledKind.Never)
|
|
9737
|
-
};
|
|
9738
|
-
else if ("oneOf" in schema) description = {
|
|
9739
|
-
kind: ExpressionKind.OneOf,
|
|
9740
|
-
expressions: rejectInSchemaList(schema.oneOf, CompiledKind.Never)
|
|
9741
|
-
};
|
|
9742
|
-
else throw new Error(`invalid combination JSON Schema: ${JSON.stringify(schema)}`);
|
|
9743
|
-
break;
|
|
9744
|
-
default: description = { kind: ExpressionKind.Leaf };
|
|
9745
|
-
}
|
|
9746
|
-
return description;
|
|
9717
|
+
var definition = {
|
|
9718
|
+
configInputs: ports.inputs,
|
|
9719
|
+
definitionVersion: literal(2),
|
|
9720
|
+
description: text,
|
|
9721
|
+
displayName: text,
|
|
9722
|
+
key: text,
|
|
9723
|
+
name: text,
|
|
9724
|
+
outputs: array(port).refine((definitions) => new Set(definitions.map((output) => output.handle)).size === definitions.length, "Duplicate Trigger output handle."),
|
|
9725
|
+
provider: text
|
|
9747
9726
|
};
|
|
9748
|
-
var
|
|
9749
|
-
|
|
9750
|
-
|
|
9751
|
-
|
|
9752
|
-
|
|
9753
|
-
|
|
9754
|
-
|
|
9755
|
-
|
|
9756
|
-
|
|
9757
|
-
|
|
9758
|
-
|
|
9759
|
-
|
|
9760
|
-
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
|
|
9766
|
-
|
|
9767
|
-
|
|
9768
|
-
|
|
9769
|
-
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
|
|
9727
|
+
var endpoint = object({
|
|
9728
|
+
body: object({
|
|
9729
|
+
allowArray: boolean(),
|
|
9730
|
+
allowEmpty: boolean(),
|
|
9731
|
+
formats: array(_enum([
|
|
9732
|
+
"form",
|
|
9733
|
+
"json",
|
|
9734
|
+
"multipart",
|
|
9735
|
+
"text"
|
|
9736
|
+
]))
|
|
9737
|
+
}),
|
|
9738
|
+
methods: array(_enum([
|
|
9739
|
+
"DELETE",
|
|
9740
|
+
"GET",
|
|
9741
|
+
"HEAD",
|
|
9742
|
+
"PATCH",
|
|
9743
|
+
"POST",
|
|
9744
|
+
"PUT"
|
|
9745
|
+
])),
|
|
9746
|
+
successStatus: number()
|
|
9747
|
+
});
|
|
9748
|
+
var sourceFlowIds = array(text.min(1)).refine((ids) => new Set(ids).size === ids.length, "Duplicate source Flow ID.");
|
|
9749
|
+
var trigger = {
|
|
9750
|
+
name: text,
|
|
9751
|
+
description: text.optional(),
|
|
9752
|
+
icon: text.optional()
|
|
9753
|
+
};
|
|
9754
|
+
var base = {
|
|
9755
|
+
maxExecutions: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
9756
|
+
inputs,
|
|
9757
|
+
name: text.optional(),
|
|
9758
|
+
description: text.optional(),
|
|
9759
|
+
icon: text.optional(),
|
|
9760
|
+
timeoutMs: number().optional()
|
|
9761
|
+
};
|
|
9762
|
+
var node = union([
|
|
9763
|
+
object({
|
|
9764
|
+
...base,
|
|
9765
|
+
inputs: record(text, never()),
|
|
9766
|
+
kind: literal("condition"),
|
|
9767
|
+
...condition
|
|
9768
|
+
}),
|
|
9769
|
+
object({
|
|
9770
|
+
...base,
|
|
9771
|
+
inputs: unknown().transform(() => ({})).default({}),
|
|
9772
|
+
kind: literal("value"),
|
|
9773
|
+
values: array(input)
|
|
9774
|
+
}),
|
|
9775
|
+
object({
|
|
9776
|
+
...base,
|
|
9777
|
+
kind: literal("subflow"),
|
|
9778
|
+
subflowId: text
|
|
9779
|
+
}),
|
|
9780
|
+
object({
|
|
9781
|
+
...base,
|
|
9782
|
+
kind: literal("task"),
|
|
9783
|
+
task: inline,
|
|
9784
|
+
additionalInputs: array(input).optional()
|
|
9785
|
+
}),
|
|
9786
|
+
object({
|
|
9787
|
+
...base,
|
|
9788
|
+
kind: literal("task"),
|
|
9789
|
+
taskId: text,
|
|
9790
|
+
additionalInputs: array(input).optional()
|
|
9791
|
+
}),
|
|
9792
|
+
strictObject({
|
|
9793
|
+
...base,
|
|
9794
|
+
kind: literal("approval"),
|
|
9795
|
+
...wait
|
|
9796
|
+
}).omit({ timeoutMs: true }),
|
|
9797
|
+
strictObject({
|
|
9798
|
+
...base,
|
|
9799
|
+
kind: literal("wait"),
|
|
9800
|
+
...wait
|
|
9801
|
+
}).omit({ timeoutMs: true }),
|
|
9802
|
+
object({
|
|
9803
|
+
...trigger,
|
|
9804
|
+
kind: literal("manual")
|
|
9805
|
+
}),
|
|
9806
|
+
strictObject({
|
|
9807
|
+
...trigger,
|
|
9808
|
+
kind: literal("error"),
|
|
9809
|
+
sourceFlowIds: sourceFlowIds.optional()
|
|
9810
|
+
}),
|
|
9811
|
+
object({
|
|
9812
|
+
...trigger,
|
|
9813
|
+
kind: literal("webhook"),
|
|
9814
|
+
...webhook
|
|
9815
|
+
}),
|
|
9816
|
+
object({
|
|
9817
|
+
...trigger,
|
|
9818
|
+
kind: literal("cron"),
|
|
9819
|
+
cronTimes: triggerScheduleSchema
|
|
9820
|
+
}),
|
|
9821
|
+
object({
|
|
9822
|
+
...trigger,
|
|
9823
|
+
kind: literal("poll"),
|
|
9824
|
+
connectionId: text.min(1).optional(),
|
|
9825
|
+
config: record(text, fixedInput),
|
|
9826
|
+
definition: object({
|
|
9827
|
+
...definition,
|
|
9828
|
+
type: literal("poll")
|
|
9829
|
+
}),
|
|
9830
|
+
pollTimes: triggerScheduleSchema
|
|
9831
|
+
}),
|
|
9832
|
+
object({
|
|
9833
|
+
...trigger,
|
|
9834
|
+
kind: literal("integration"),
|
|
9835
|
+
connectionId: text.min(1).optional(),
|
|
9836
|
+
config: record(text, fixedInput),
|
|
9837
|
+
definition: object({
|
|
9838
|
+
...definition,
|
|
9839
|
+
type: literal("integration"),
|
|
9840
|
+
endpoint
|
|
9841
|
+
})
|
|
9842
|
+
})
|
|
9843
|
+
]);
|
|
9844
|
+
var target = union([object({ kind: literal("flow") }), object({
|
|
9845
|
+
kind: literal("subflow"),
|
|
9846
|
+
id: text
|
|
9847
|
+
})]);
|
|
9848
|
+
var edge = object({
|
|
9849
|
+
source: text,
|
|
9850
|
+
target: text,
|
|
9851
|
+
sourceHandle: text.optional()
|
|
9852
|
+
});
|
|
9853
|
+
var at = {
|
|
9854
|
+
nodeId: text,
|
|
9855
|
+
target
|
|
9773
9856
|
};
|
|
9774
|
-
|
|
9775
|
-
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
|
|
9783
|
-
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
|
|
9788
|
-
|
|
9789
|
-
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
|
|
9793
|
-
|
|
9794
|
-
|
|
9795
|
-
|
|
9796
|
-
|
|
9797
|
-
|
|
9798
|
-
|
|
9799
|
-
|
|
9800
|
-
|
|
9801
|
-
|
|
9802
|
-
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9810
|
-
|
|
9811
|
-
|
|
9812
|
-
|
|
9813
|
-
|
|
9814
|
-
|
|
9815
|
-
}
|
|
9816
|
-
|
|
9817
|
-
|
|
9818
|
-
|
|
9819
|
-
|
|
9820
|
-
|
|
9821
|
-
|
|
9822
|
-
|
|
9823
|
-
|
|
9824
|
-
|
|
9825
|
-
}
|
|
9826
|
-
|
|
9827
|
-
|
|
9828
|
-
|
|
9829
|
-
}
|
|
9830
|
-
|
|
9831
|
-
|
|
9832
|
-
|
|
9833
|
-
|
|
9834
|
-
|
|
9835
|
-
|
|
9836
|
-
|
|
9837
|
-
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
|
|
9842
|
-
|
|
9843
|
-
|
|
9844
|
-
|
|
9845
|
-
|
|
9846
|
-
|
|
9847
|
-
|
|
9848
|
-
|
|
9849
|
-
|
|
9850
|
-
|
|
9851
|
-
|
|
9852
|
-
|
|
9853
|
-
|
|
9854
|
-
|
|
9855
|
-
|
|
9856
|
-
|
|
9857
|
-
|
|
9858
|
-
|
|
9857
|
+
var subflow = object({
|
|
9858
|
+
name: text,
|
|
9859
|
+
inputs: array(input),
|
|
9860
|
+
outputs: array(port.extend({ sources: array(union([nodeSource, flowSource])) }))
|
|
9861
|
+
});
|
|
9862
|
+
var graph = object({
|
|
9863
|
+
nodes: record(text, node),
|
|
9864
|
+
edges: array(edge).default([])
|
|
9865
|
+
});
|
|
9866
|
+
var binding = object({
|
|
9867
|
+
kind: literal("variable"),
|
|
9868
|
+
target: text
|
|
9869
|
+
});
|
|
9870
|
+
var module = object({
|
|
9871
|
+
name: text,
|
|
9872
|
+
imports: strings,
|
|
9873
|
+
source: text
|
|
9874
|
+
});
|
|
9875
|
+
var document = object({
|
|
9876
|
+
bindings: record(text, binding),
|
|
9877
|
+
graph,
|
|
9878
|
+
subflows: record(text, subflow.extend({ graph })),
|
|
9879
|
+
tasks: record(text, managed)
|
|
9880
|
+
});
|
|
9881
|
+
object({
|
|
9882
|
+
modelVersion: union([
|
|
9883
|
+
literal(2),
|
|
9884
|
+
literal(4),
|
|
9885
|
+
literal(5)
|
|
9886
|
+
]),
|
|
9887
|
+
document,
|
|
9888
|
+
modules: record(text, module)
|
|
9889
|
+
}).extend({
|
|
9890
|
+
kind: literal("open-flow-flow-revision"),
|
|
9891
|
+
version: literal(1)
|
|
9892
|
+
});
|
|
9893
|
+
var shapes = {
|
|
9894
|
+
"graph.trigger.sources.set": {
|
|
9895
|
+
nodeId: text,
|
|
9896
|
+
before: sourceFlowIds.optional(),
|
|
9897
|
+
value: sourceFlowIds.optional()
|
|
9898
|
+
},
|
|
9899
|
+
"binding.create": {
|
|
9900
|
+
bindingId: text,
|
|
9901
|
+
binding
|
|
9902
|
+
},
|
|
9903
|
+
"binding.delete": { bindingId: text },
|
|
9904
|
+
"binding.target.set": {
|
|
9905
|
+
bindingId: text,
|
|
9906
|
+
before: text,
|
|
9907
|
+
value: text
|
|
9908
|
+
},
|
|
9909
|
+
"graph.edge.connect": {
|
|
9910
|
+
target,
|
|
9911
|
+
edge
|
|
9912
|
+
},
|
|
9913
|
+
"graph.edge.disconnect": {
|
|
9914
|
+
target,
|
|
9915
|
+
edge
|
|
9916
|
+
},
|
|
9917
|
+
"graph.node.create": {
|
|
9918
|
+
...at,
|
|
9919
|
+
node
|
|
9920
|
+
},
|
|
9921
|
+
"graph.node.delete": at,
|
|
9922
|
+
"graph.node.field.set": union([
|
|
9923
|
+
object({
|
|
9924
|
+
...at,
|
|
9925
|
+
kind: literal("graph.node.field.set"),
|
|
9926
|
+
field: literal("connectionId"),
|
|
9927
|
+
before: text.min(1).optional(),
|
|
9928
|
+
value: text.min(1).optional()
|
|
9929
|
+
}),
|
|
9930
|
+
object({
|
|
9931
|
+
...at,
|
|
9932
|
+
kind: literal("graph.node.field.set"),
|
|
9933
|
+
field: _enum([
|
|
9934
|
+
"description",
|
|
9935
|
+
"icon",
|
|
9936
|
+
"name"
|
|
9937
|
+
]),
|
|
9938
|
+
before: text.optional(),
|
|
9939
|
+
value: text.optional()
|
|
9940
|
+
}),
|
|
9941
|
+
object({
|
|
9942
|
+
...at,
|
|
9943
|
+
kind: literal("graph.node.field.set"),
|
|
9944
|
+
field: literal("maxExecutions"),
|
|
9945
|
+
before: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
9946
|
+
value: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional()
|
|
9947
|
+
}),
|
|
9948
|
+
object({
|
|
9949
|
+
...at,
|
|
9950
|
+
kind: literal("graph.node.field.set"),
|
|
9951
|
+
field: literal("timeoutMs"),
|
|
9952
|
+
before: number().optional(),
|
|
9953
|
+
value: number().optional()
|
|
9954
|
+
})
|
|
9955
|
+
]),
|
|
9956
|
+
"graph.node.input.set": {
|
|
9957
|
+
...at,
|
|
9958
|
+
handle: text,
|
|
9959
|
+
before: mapping.optional(),
|
|
9960
|
+
value: mapping.optional()
|
|
9961
|
+
},
|
|
9962
|
+
"graph.node.additional-inputs.set": {
|
|
9963
|
+
...at,
|
|
9964
|
+
before: array(input).optional(),
|
|
9965
|
+
value: array(input).optional()
|
|
9966
|
+
},
|
|
9967
|
+
"graph.node.condition.set": {
|
|
9968
|
+
...at,
|
|
9969
|
+
before: object(condition),
|
|
9970
|
+
value: object(condition)
|
|
9971
|
+
},
|
|
9972
|
+
"graph.node.values.set": {
|
|
9973
|
+
...at,
|
|
9974
|
+
before: array(input),
|
|
9975
|
+
value: array(input)
|
|
9976
|
+
},
|
|
9977
|
+
"graph.node.resolution.set": {
|
|
9978
|
+
...at,
|
|
9979
|
+
target: object({ kind: literal("flow") }),
|
|
9980
|
+
before: object(wait),
|
|
9981
|
+
value: object(wait)
|
|
9982
|
+
},
|
|
9983
|
+
"graph.node.webhook.set": {
|
|
9984
|
+
...at,
|
|
9985
|
+
target: object({ kind: literal("flow") }),
|
|
9986
|
+
before: object(webhook),
|
|
9987
|
+
value: object(webhook)
|
|
9988
|
+
},
|
|
9989
|
+
"graph.node.task.ports.set": {
|
|
9990
|
+
...at,
|
|
9991
|
+
before: object(ports),
|
|
9992
|
+
value: object(ports)
|
|
9993
|
+
},
|
|
9994
|
+
"graph.node.task.name.set": {
|
|
9995
|
+
...at,
|
|
9996
|
+
before: text,
|
|
9997
|
+
value: text
|
|
9998
|
+
},
|
|
9999
|
+
"graph.node.task.capabilities.set": {
|
|
10000
|
+
...at,
|
|
10001
|
+
before: array(capability).optional(),
|
|
10002
|
+
value: array(capability).optional()
|
|
10003
|
+
},
|
|
10004
|
+
"graph.trigger.config.set": {
|
|
10005
|
+
nodeId: text,
|
|
10006
|
+
name: text,
|
|
10007
|
+
before: fixedInput.optional(),
|
|
10008
|
+
value: fixedInput.optional()
|
|
10009
|
+
},
|
|
10010
|
+
"graph.trigger.schedule.set": {
|
|
10011
|
+
nodeId: text,
|
|
10012
|
+
before: triggerScheduleSchema,
|
|
10013
|
+
value: triggerScheduleSchema
|
|
10014
|
+
},
|
|
10015
|
+
"module.create": {
|
|
10016
|
+
moduleId: text,
|
|
10017
|
+
module
|
|
10018
|
+
},
|
|
10019
|
+
"module.delete": { moduleId: text },
|
|
10020
|
+
"module.rename": {
|
|
10021
|
+
moduleId: text,
|
|
10022
|
+
before: text,
|
|
10023
|
+
name: text
|
|
10024
|
+
},
|
|
10025
|
+
"module.source.replace": {
|
|
10026
|
+
moduleId: text,
|
|
10027
|
+
beforeImports: strings,
|
|
10028
|
+
beforeSource: text,
|
|
10029
|
+
imports: strings,
|
|
10030
|
+
source: text
|
|
10031
|
+
},
|
|
10032
|
+
"subflow.create": {
|
|
10033
|
+
subflowId: text,
|
|
10034
|
+
subflow: subflow.extend({ graph })
|
|
10035
|
+
},
|
|
10036
|
+
"subflow.definition.set": {
|
|
10037
|
+
subflowId: text,
|
|
10038
|
+
before: subflow,
|
|
10039
|
+
definition: subflow
|
|
10040
|
+
},
|
|
10041
|
+
"subflow.delete": { subflowId: text },
|
|
10042
|
+
"task.create": {
|
|
10043
|
+
taskId: text,
|
|
10044
|
+
task: managed
|
|
10045
|
+
},
|
|
10046
|
+
"task.delete": { taskId: text },
|
|
10047
|
+
"task.connector.connection.set": {
|
|
10048
|
+
taskId: text,
|
|
10049
|
+
before: text.optional(),
|
|
10050
|
+
value: text.optional()
|
|
10051
|
+
},
|
|
10052
|
+
"task.decision.set": {
|
|
10053
|
+
taskId: text,
|
|
10054
|
+
before: managed,
|
|
10055
|
+
value: managed
|
|
10056
|
+
},
|
|
10057
|
+
"task.openapi.set": {
|
|
10058
|
+
taskId: text,
|
|
10059
|
+
before: managed,
|
|
10060
|
+
value: managed
|
|
10061
|
+
},
|
|
10062
|
+
"task.agent.set": {
|
|
10063
|
+
taskId: text,
|
|
10064
|
+
before: managed,
|
|
10065
|
+
value: managed
|
|
10066
|
+
},
|
|
10067
|
+
"task.llm.mode.set": {
|
|
10068
|
+
taskId: text,
|
|
10069
|
+
before: _enum(["chat", "json"]),
|
|
10070
|
+
value: _enum(["chat", "json"])
|
|
10071
|
+
},
|
|
10072
|
+
"task.name.set": {
|
|
10073
|
+
taskId: text,
|
|
10074
|
+
before: text,
|
|
10075
|
+
value: text
|
|
9859
10076
|
}
|
|
9860
10077
|
};
|
|
10078
|
+
array(union([...new Map(Object.entries(shapes).map(([kind, shape]) => [kind, shape instanceof ZodType ? shape : object({
|
|
10079
|
+
kind: literal(kind),
|
|
10080
|
+
...shape
|
|
10081
|
+
})])).values()])).min(1);
|
|
9861
10082
|
//#endregion
|
|
9862
|
-
//#region src/
|
|
9863
|
-
|
|
9864
|
-
|
|
9865
|
-
|
|
9866
|
-
|
|
9867
|
-
|
|
9868
|
-
|
|
9869
|
-
|
|
9870
|
-
|
|
9871
|
-
|
|
9872
|
-
|
|
9873
|
-
|
|
9874
|
-
|
|
9875
|
-
|
|
9876
|
-
|
|
9877
|
-
|
|
9878
|
-
|
|
9879
|
-
|
|
9880
|
-
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9886
|
-
|
|
9887
|
-
|
|
9888
|
-
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
|
|
9894
|
-
|
|
9895
|
-
}
|
|
9896
|
-
|
|
9897
|
-
|
|
9898
|
-
|
|
9899
|
-
|
|
9900
|
-
|
|
9901
|
-
};
|
|
9902
|
-
errorItems.push(replacedItem);
|
|
9903
|
-
}
|
|
10083
|
+
//#region src/flow/common/condition.ts
|
|
10084
|
+
var otherwiseOutput = "otherwise";
|
|
10085
|
+
var conditionOperators = [
|
|
10086
|
+
"==",
|
|
10087
|
+
"!=",
|
|
10088
|
+
"<",
|
|
10089
|
+
"<=",
|
|
10090
|
+
">",
|
|
10091
|
+
">=",
|
|
10092
|
+
"contains",
|
|
10093
|
+
"notContains",
|
|
10094
|
+
"startsWith",
|
|
10095
|
+
"endsWith",
|
|
10096
|
+
"hasKey",
|
|
10097
|
+
"notHasKey",
|
|
10098
|
+
"hasValue",
|
|
10099
|
+
"notHasValue",
|
|
10100
|
+
"isEmpty",
|
|
10101
|
+
"isNotEmpty",
|
|
10102
|
+
"isNull",
|
|
10103
|
+
"isNotNull",
|
|
10104
|
+
"isTrue",
|
|
10105
|
+
"isFalse"
|
|
10106
|
+
];
|
|
10107
|
+
var unaryOperator = (operator) => operator.startsWith("is");
|
|
10108
|
+
var operandHandle = (caseIndex, groupIndex, expressionIndex, side) => `${caseIndex}/${groupIndex}/${expressionIndex}/${side}`;
|
|
10109
|
+
/** Derived addresses let operand bindings use the ordinary input analysis and editor. Never persisted as node inputs. */
|
|
10110
|
+
function conditionOperands(node) {
|
|
10111
|
+
return node.cases.flatMap((item, c) => item.groups.flatMap((group, g) => group.expressions.flatMap((expression, e) => [{
|
|
10112
|
+
handle: operandHandle(c, g, e, "left"),
|
|
10113
|
+
operand: expression.left,
|
|
10114
|
+
expression,
|
|
10115
|
+
side: "left"
|
|
10116
|
+
}, ...!unaryOperator(expression.operator) ? [{
|
|
10117
|
+
handle: operandHandle(c, g, e, "right"),
|
|
10118
|
+
operand: expression.right ?? { kind: "value" },
|
|
10119
|
+
expression,
|
|
10120
|
+
side: "right"
|
|
10121
|
+
}] : []])));
|
|
9904
10122
|
}
|
|
9905
|
-
|
|
9906
|
-
|
|
9907
|
-
|
|
9908
|
-
|
|
9909
|
-
|
|
9910
|
-
|
|
9911
|
-
|
|
9912
|
-
|
|
9913
|
-
|
|
9914
|
-
return Object.freeze({
|
|
9915
|
-
compile: (schema, payload, printWarnLog) => {
|
|
9916
|
-
const compiler = (candidate) => compile(candidate, extendsContext, payload, delegate);
|
|
9917
|
-
return preprocessSchema(schema, compiler, printWarnLog);
|
|
9918
|
-
},
|
|
9919
|
-
isSubset: (superSchema, subSchema, printWarnLog = false) => {
|
|
9920
|
-
const compiler = (candidate) => compile(candidate, extendsContext, void 0, delegate);
|
|
9921
|
-
const [schema1, schema2] = preprocessSchemasPair(superSchema, subSchema, compiler, printWarnLog);
|
|
9922
|
-
const { errorPath, expression } = checkWithResult(extendsContext, schema1, schema2);
|
|
9923
|
-
const foundTrueExpression = hasEquals(expression) || hasContainedBy(expression);
|
|
9924
|
-
const foundFalseExpression = hasContaining(expression) || hasIntersection(expression) || hasRejection(expression);
|
|
9925
|
-
if (foundTrueExpression && !foundFalseExpression) return { result: SubsetCompareResult.True };
|
|
9926
|
-
if (!foundTrueExpression && foundFalseExpression) return {
|
|
9927
|
-
errorPath,
|
|
9928
|
-
result: SubsetCompareResult.False
|
|
9929
|
-
};
|
|
9930
|
-
return { result: SubsetCompareResult.Unknown };
|
|
9931
|
-
}
|
|
9932
|
-
});
|
|
10123
|
+
function nodeInputMappings(node) {
|
|
10124
|
+
if (node.kind != "condition") return "inputs" in node ? node.inputs : {};
|
|
10125
|
+
return Object.fromEntries(conditionOperands(node).flatMap(({ handle, operand }) => operand.kind == "source" ? [[handle, {
|
|
10126
|
+
kind: "sources",
|
|
10127
|
+
sources: [operand.source]
|
|
10128
|
+
}]] : operand.value === void 0 ? [] : [[handle, {
|
|
10129
|
+
kind: "value",
|
|
10130
|
+
value: operand.value
|
|
10131
|
+
}]]));
|
|
9933
10132
|
}
|
|
9934
|
-
|
|
9935
|
-
|
|
9936
|
-
|
|
9937
|
-
|
|
9938
|
-
|
|
9939
|
-
var isPlainObject = (x) => isObject(x) && !isArray(x);
|
|
9940
|
-
var toPlainObject = (x) => isPlainObject(x) ? x : void 0;
|
|
9941
|
-
//#endregion
|
|
9942
|
-
//#region src/manifest/common/schemaComparer.ts
|
|
9943
|
-
function isStringLikeSchema(value) {
|
|
9944
|
-
return toPlainObject(value)?.type === "string";
|
|
10133
|
+
function conditionInputPorts(node) {
|
|
10134
|
+
return Object.fromEntries(conditionOperands(node).map(({ handle, operand }) => [handle, {
|
|
10135
|
+
jsonSchema: operand.kind === "value" ? operand.jsonSchema ?? {} : {},
|
|
10136
|
+
nullable: operand.kind === "value" ? operand.value === null : true
|
|
10137
|
+
}]));
|
|
9945
10138
|
}
|
|
9946
|
-
function
|
|
9947
|
-
|
|
9948
|
-
const error = toPlainObject(context?.error);
|
|
9949
|
-
if (context == null || error == null || context.packageId != null && !isString(context.packageId) || error.message != null && !isString(error.message)) throw new TypeError("Invalid schema comparison context.");
|
|
10139
|
+
function valueType(value) {
|
|
10140
|
+
return value === null ? "null" : Array.isArray(value) ? "array" : typeof value;
|
|
9950
10141
|
}
|
|
9951
|
-
function
|
|
9952
|
-
if (
|
|
9953
|
-
|
|
9954
|
-
|
|
10142
|
+
function operatorsForType(type) {
|
|
10143
|
+
if (type == null) return conditionOperators;
|
|
10144
|
+
return [
|
|
10145
|
+
"==",
|
|
10146
|
+
"!=",
|
|
10147
|
+
...{
|
|
10148
|
+
number: [
|
|
10149
|
+
"<",
|
|
10150
|
+
"<=",
|
|
10151
|
+
">",
|
|
10152
|
+
">="
|
|
10153
|
+
],
|
|
10154
|
+
integer: [
|
|
10155
|
+
"<",
|
|
10156
|
+
"<=",
|
|
10157
|
+
">",
|
|
10158
|
+
">="
|
|
10159
|
+
],
|
|
10160
|
+
string: [
|
|
10161
|
+
"contains",
|
|
10162
|
+
"notContains",
|
|
10163
|
+
"startsWith",
|
|
10164
|
+
"endsWith",
|
|
10165
|
+
"isEmpty",
|
|
10166
|
+
"isNotEmpty"
|
|
10167
|
+
],
|
|
10168
|
+
array: [
|
|
10169
|
+
"contains",
|
|
10170
|
+
"notContains",
|
|
10171
|
+
"isEmpty",
|
|
10172
|
+
"isNotEmpty"
|
|
10173
|
+
],
|
|
10174
|
+
object: [
|
|
10175
|
+
"hasKey",
|
|
10176
|
+
"notHasKey",
|
|
10177
|
+
"hasValue",
|
|
10178
|
+
"notHasValue",
|
|
10179
|
+
"isEmpty",
|
|
10180
|
+
"isNotEmpty"
|
|
10181
|
+
],
|
|
10182
|
+
boolean: ["isTrue", "isFalse"],
|
|
10183
|
+
null: []
|
|
10184
|
+
}[type] ?? [],
|
|
10185
|
+
"isNull",
|
|
10186
|
+
"isNotNull"
|
|
10187
|
+
];
|
|
9955
10188
|
}
|
|
9956
|
-
var
|
|
9957
|
-
|
|
9958
|
-
|
|
9959
|
-
|
|
9960
|
-
|
|
9961
|
-
|
|
9962
|
-
|
|
9963
|
-
|
|
9964
|
-
|
|
9965
|
-
|
|
9966
|
-
|
|
9967
|
-
|
|
9968
|
-
|
|
9969
|
-
|
|
9970
|
-
|
|
9971
|
-
|
|
9972
|
-
|
|
9973
|
-
|
|
9974
|
-
|
|
9975
|
-
|
|
9976
|
-
|
|
9977
|
-
|
|
9978
|
-
|
|
9979
|
-
|
|
9980
|
-
|
|
9981
|
-
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
|
|
9990
|
-
|
|
9991
|
-
|
|
10189
|
+
var normalized = (type) => type == "integer" ? "number" : type;
|
|
10190
|
+
function comparisonIssue(operator, leftType, rightType) {
|
|
10191
|
+
if (leftType != null && !operatorsForType(leftType).includes(operator)) return {
|
|
10192
|
+
target: "operator",
|
|
10193
|
+
message: `Operator ${operator} is not compatible with ${leftType}.`
|
|
10194
|
+
};
|
|
10195
|
+
if (unaryOperator(operator) || rightType == null) return;
|
|
10196
|
+
const required = [
|
|
10197
|
+
"<",
|
|
10198
|
+
"<=",
|
|
10199
|
+
">",
|
|
10200
|
+
">="
|
|
10201
|
+
].includes(operator) ? "number" : [
|
|
10202
|
+
"startsWith",
|
|
10203
|
+
"endsWith",
|
|
10204
|
+
"hasKey",
|
|
10205
|
+
"notHasKey"
|
|
10206
|
+
].includes(operator) || ["contains", "notContains"].includes(operator) && leftType == "string" ? "string" : ["==", "!="].includes(operator) ? normalized(leftType) : void 0;
|
|
10207
|
+
if (required != null && required != normalized(rightType)) return {
|
|
10208
|
+
target: "right",
|
|
10209
|
+
message: `Operator ${operator} requires a ${required} right operand.`
|
|
10210
|
+
};
|
|
10211
|
+
}
|
|
10212
|
+
function compareCondition(operator, left, right) {
|
|
10213
|
+
if (!unaryOperator(operator) && right === void 0) throw new Error("Condition right operand is missing.");
|
|
10214
|
+
const issue = comparisonIssue(operator, valueType(left), right === void 0 ? void 0 : valueType(right));
|
|
10215
|
+
if (issue != null) throw new Error(issue.message);
|
|
10216
|
+
switch (operator) {
|
|
10217
|
+
case "==": return dequal(left, right);
|
|
10218
|
+
case "!=": return !dequal(left, right);
|
|
10219
|
+
case "<": return left < right;
|
|
10220
|
+
case "<=": return left <= right;
|
|
10221
|
+
case ">": return left > right;
|
|
10222
|
+
case ">=": return left >= right;
|
|
10223
|
+
case "contains":
|
|
10224
|
+
case "notContains": {
|
|
10225
|
+
const contains = typeof left == "string" ? left.includes(right) : left.some((item) => dequal(item, right));
|
|
10226
|
+
return operator == "contains" ? contains : !contains;
|
|
9992
10227
|
}
|
|
9993
|
-
return
|
|
9994
|
-
|
|
9995
|
-
|
|
9996
|
-
|
|
9997
|
-
const
|
|
9998
|
-
|
|
9999
|
-
if (!f.has(v)) return false;
|
|
10000
|
-
f.delete(v);
|
|
10001
|
-
}
|
|
10002
|
-
return f.size === 0;
|
|
10228
|
+
case "startsWith": return left.startsWith(right);
|
|
10229
|
+
case "endsWith": return left.endsWith(right);
|
|
10230
|
+
case "hasKey":
|
|
10231
|
+
case "notHasKey": {
|
|
10232
|
+
const has = Object.hasOwn(left, right);
|
|
10233
|
+
return operator == "hasKey" ? has : !has;
|
|
10003
10234
|
}
|
|
10004
|
-
|
|
10005
|
-
|
|
10006
|
-
|
|
10007
|
-
|
|
10008
|
-
static isMatch(value) {
|
|
10009
|
-
return toPlainObject(value)?.contentMediaType === "oomol/bin";
|
|
10010
|
-
}
|
|
10011
|
-
constructor(id, value, context) {
|
|
10012
|
-
if (!BinarySchema.isMatch(value)) throw new TypeError("Invalid binary schema.");
|
|
10013
|
-
super(id, value, context);
|
|
10014
|
-
}
|
|
10015
|
-
compareImpl(other) {
|
|
10016
|
-
if (other instanceof BinarySchema) return [ExpressionSingleResult.Equals];
|
|
10017
|
-
else {
|
|
10018
|
-
SpecialSchema.setError(this, other, "edgeError.binDiffType");
|
|
10019
|
-
return [ExpressionSingleResult.Rejection];
|
|
10235
|
+
case "hasValue":
|
|
10236
|
+
case "notHasValue": {
|
|
10237
|
+
const has = Object.values(left).some((item) => dequal(item, right));
|
|
10238
|
+
return operator == "hasValue" ? has : !has;
|
|
10020
10239
|
}
|
|
10240
|
+
case "isEmpty":
|
|
10241
|
+
case "isNotEmpty": {
|
|
10242
|
+
const empty = typeof left == "string" || Array.isArray(left) ? left.length == 0 : Object.keys(left).length == 0;
|
|
10243
|
+
return operator == "isEmpty" ? empty : !empty;
|
|
10244
|
+
}
|
|
10245
|
+
case "isNull": return left === null;
|
|
10246
|
+
case "isNotNull": return left !== null;
|
|
10247
|
+
case "isTrue": return left === true;
|
|
10248
|
+
case "isFalse": return left === false;
|
|
10021
10249
|
}
|
|
10022
|
-
|
|
10023
|
-
|
|
10024
|
-
}
|
|
10025
|
-
|
|
10026
|
-
|
|
10027
|
-
|
|
10028
|
-
|
|
10029
|
-
|
|
10030
|
-
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
|
|
10039
|
-
|
|
10040
|
-
|
|
10250
|
+
}
|
|
10251
|
+
function selectConditionBranches(node, values) {
|
|
10252
|
+
for (const { handle } of conditionOperands(node)) if (!Object.hasOwn(values, handle)) throw new Error(`Condition operand ${handle} is missing.`);
|
|
10253
|
+
const results = node.cases.map((item, c) => {
|
|
10254
|
+
if (item.groups.length == 0) throw new Error("Condition Case requires a group.");
|
|
10255
|
+
return item.groups.map((group, g) => {
|
|
10256
|
+
if (group.expressions.length == 0) throw new Error("Condition group requires an expression.");
|
|
10257
|
+
return group.expressions.map((expression, e) => {
|
|
10258
|
+
const left = values[operandHandle(c, g, e, "left")];
|
|
10259
|
+
const right = unaryOperator(expression.operator) ? void 0 : values[operandHandle(c, g, e, "right")];
|
|
10260
|
+
const issue = comparisonIssue(expression.operator, valueType(left), right === void 0 ? void 0 : valueType(right));
|
|
10261
|
+
if (issue != null || !unaryOperator(expression.operator) && right === void 0) throw new Error(issue?.message ?? "Condition right operand is missing.");
|
|
10262
|
+
return () => compareCondition(expression.operator, left, right);
|
|
10263
|
+
});
|
|
10264
|
+
});
|
|
10265
|
+
});
|
|
10266
|
+
const selected = [];
|
|
10267
|
+
for (const [index, groups] of results.entries()) {
|
|
10268
|
+
if (!groups.some((expressions) => expressions.every((evaluate) => evaluate()))) continue;
|
|
10269
|
+
selected.push(node.cases[index].output);
|
|
10270
|
+
if (node.matchMode == "first") break;
|
|
10041
10271
|
}
|
|
10042
|
-
|
|
10043
|
-
function createSchemaComparer() {
|
|
10044
|
-
return makeSubsetCompare({ extendsSchemaClasses: [
|
|
10045
|
-
SingleSelectSchema,
|
|
10046
|
-
BinarySchema,
|
|
10047
|
-
ArtifactSchema
|
|
10048
|
-
] });
|
|
10272
|
+
return selected.length == 0 ? [otherwiseOutput] : selected;
|
|
10049
10273
|
}
|
|
10050
|
-
createSchemaComparer();
|
|
10051
10274
|
//#endregion
|
|
10052
|
-
//#region src/flow/common/
|
|
10053
|
-
function
|
|
10054
|
-
return
|
|
10055
|
-
}
|
|
10056
|
-
var validators = /* @__PURE__ */ new WeakMap();
|
|
10057
|
-
function matchesSchema(value, schema) {
|
|
10058
|
-
return schemaValidationErrors(value, schema).length == 0;
|
|
10059
|
-
}
|
|
10060
|
-
function schemaValidationErrors(value, schema) {
|
|
10061
|
-
if (typeof schema == "boolean") return schema ? [] : ["The schema does not allow any value."];
|
|
10062
|
-
const source = schemaObject(schema);
|
|
10063
|
-
if (source == null || source.properties != null && schemaObject(source.properties) == null) return ["Invalid output schema."];
|
|
10064
|
-
try {
|
|
10065
|
-
let validator = validators.get(source);
|
|
10066
|
-
if (validator == null) {
|
|
10067
|
-
const declaration = typeof source.$schema == "string" ? source.$schema : "";
|
|
10068
|
-
const draft = declaration.includes("draft-04") ? "4" : declaration.includes("draft-07") ? "7" : declaration.includes("2020-12") ? "2020-12" : "2019-09";
|
|
10069
|
-
validator = new Validator(structuredClone(source), draft);
|
|
10070
|
-
validators.set(source, validator);
|
|
10071
|
-
}
|
|
10072
|
-
const result = validator.validate(value);
|
|
10073
|
-
return result.valid ? [] : result.errors.map((issue) => `${issue.instanceLocation || "/"}: ${issue.error}`);
|
|
10074
|
-
} catch {
|
|
10075
|
-
return ["Output schema validation failed."];
|
|
10076
|
-
}
|
|
10275
|
+
//#region src/flow/common/change.ts
|
|
10276
|
+
function portsByHandle(ports) {
|
|
10277
|
+
return Object.fromEntries(ports.flatMap((port) => "handle" in port ? [[port.handle, port]] : []));
|
|
10077
10278
|
}
|
|
10078
10279
|
//#endregion
|
|
10079
10280
|
//#region src/flow/common/agent.ts
|