@oomol-lab/open-flow 0.1.0-beta.61 → 0.1.0-beta.62
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-D71fO68i.js → createResourceDialog-DZgJsr3e.js} +2 -2
- package/dist/browser/{flowChanges-DSA0FxxN.js → flowChanges-CzYIVevI.js} +2244 -2172
- package/dist/browser/{flowWorkspace-0sUJ5JhQ.js → flowWorkspace-BgZaFKZm.js} +179 -57
- package/dist/browser/{icons-DVJvrj1H.js → icons-CajfDpy_.js} +2879 -2879
- package/dist/browser/preview.js +453 -140
- package/dist/browser/workbench.css +4 -20
- package/dist/browser/workbench.js +78 -11
- package/dist/browser/{workbenchSelect-cr4-mKq3.js → workbenchSelect-H9wzEFkH.js} +1 -1
- package/dist/command/index.js +37 -37
- package/dist/common/authoring.d.ts +1 -1
- package/dist/common/control-api-conformance.js +2149 -2084
- package/dist/common/control-api-errors.d.ts +0 -4
- package/dist/common/control-api.d.ts +10 -11
- package/dist/common/control-api.js +2495 -2755
- package/dist/common/control-requests.js +23 -15
- package/dist/common/liveDetails.d.ts +138 -0
- package/dist/common/mcp.d.ts +1 -33
- package/dist/common/mcp.js +287 -238
- package/package.json +1 -1
- package/skills/open-flow/SKILL.md +6 -3
- package/skills/open-flow/references/flow-authoring.md +28 -24
- package/dist/common/publicationResources.d.ts +0 -29
|
@@ -22,15 +22,6 @@ function dequal(foo, bar) {
|
|
|
22
22
|
return foo !== foo && bar !== bar;
|
|
23
23
|
}
|
|
24
24
|
//#endregion
|
|
25
|
-
//#region src/openapi/common/authBindings.ts
|
|
26
|
-
/** Never allow credentials to enter a Revision as literal node inputs. */
|
|
27
|
-
function assertOpenApiAuthBindings(document) {
|
|
28
|
-
for (const node of Object.values(document.graph.nodes)) {
|
|
29
|
-
if (node.kind != "task" || !("executor" in node.task) || node.task.executor.kind != "openapi") continue;
|
|
30
|
-
for (const [handle, mapping] of Object.entries(node.inputs)) if (handle.startsWith("auth.") && mapping.kind == "value") throw new TypeError("OpenAPI authentication accepts deployment variables and upstream outputs only.");
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
//#endregion
|
|
34
25
|
//#region ../../node_modules/.bun/zod@4.6.5/node_modules/zod/v4/core/util.js
|
|
35
26
|
function getEnumValues(entries) {
|
|
36
27
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
@@ -5699,27 +5690,6 @@ function preprocess(fn, schema) {
|
|
|
5699
5690
|
out: schema
|
|
5700
5691
|
});
|
|
5701
5692
|
}
|
|
5702
|
-
function checkJsonDepth(value, depth = 0) {
|
|
5703
|
-
if (depth > 64) throw new TypeError("Value exceeds the maximum JSON depth.");
|
|
5704
|
-
if (value != null && typeof value == "object") for (const child of Object.values(value)) checkJsonDepth(child, depth + 1);
|
|
5705
|
-
}
|
|
5706
|
-
//#endregion
|
|
5707
|
-
//#region src/flow/common/triggerScheduleSchema.ts
|
|
5708
|
-
var triggerScheduleSchema = array(union([object({
|
|
5709
|
-
type: literal("cron"),
|
|
5710
|
-
expression: string$1(),
|
|
5711
|
-
timezone: string$1()
|
|
5712
|
-
}), object({
|
|
5713
|
-
type: literal("every"),
|
|
5714
|
-
unit: _enum([
|
|
5715
|
-
"day",
|
|
5716
|
-
"hour",
|
|
5717
|
-
"minute",
|
|
5718
|
-
"month",
|
|
5719
|
-
"week"
|
|
5720
|
-
]),
|
|
5721
|
-
value: number()
|
|
5722
|
-
})]));
|
|
5723
5693
|
//#endregion
|
|
5724
5694
|
//#region src/flow/common/webhookMethod.ts
|
|
5725
5695
|
var webhookMethods = [
|
|
@@ -5729,677 +5699,112 @@ var webhookMethods = [
|
|
|
5729
5699
|
"PATCH",
|
|
5730
5700
|
"DELETE"
|
|
5731
5701
|
];
|
|
5732
|
-
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
var
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
var inputs = record$3(text, mapping);
|
|
5764
|
-
var ports$1 = {
|
|
5765
|
-
inputs: array(union([input, group])),
|
|
5766
|
-
outputs: array(union([port$1, group]))
|
|
5767
|
-
};
|
|
5768
|
-
var capability = union([
|
|
5769
|
-
strictObject({
|
|
5770
|
-
kind: literal("connector"),
|
|
5771
|
-
action: text,
|
|
5772
|
-
connectionId: text.optional(),
|
|
5773
|
-
connections: array(strictObject({
|
|
5774
|
-
connectionId: text,
|
|
5775
|
-
alias: text.optional()
|
|
5776
|
-
}))
|
|
5777
|
-
}),
|
|
5778
|
-
strictObject({
|
|
5779
|
-
kind: literal("connector"),
|
|
5780
|
-
mode: literal("shared")
|
|
5781
|
-
}),
|
|
5782
|
-
strictObject({
|
|
5783
|
-
kind: literal("connector"),
|
|
5784
|
-
mode: literal("independent"),
|
|
5785
|
-
actions: array(strictObject({
|
|
5786
|
-
action: text,
|
|
5787
|
-
connectionId: text.optional()
|
|
5788
|
-
}))
|
|
5789
|
-
}),
|
|
5790
|
-
strictObject({
|
|
5791
|
-
kind: literal("connector"),
|
|
5792
|
-
actionHints: array(text).optional(),
|
|
5793
|
-
connectionHints: array(strictObject({
|
|
5794
|
-
action: text,
|
|
5795
|
-
connectionId: text,
|
|
5796
|
-
alias: text.optional()
|
|
5797
|
-
})).optional()
|
|
5798
|
-
})
|
|
5702
|
+
function webhookSupportsBody(method) {
|
|
5703
|
+
return method !== "GET";
|
|
5704
|
+
}
|
|
5705
|
+
//#endregion
|
|
5706
|
+
//#region src/openapi/common/authBindings.ts
|
|
5707
|
+
/** Never allow credentials to enter a Revision as literal node inputs. */
|
|
5708
|
+
function assertOpenApiAuthBindings(document) {
|
|
5709
|
+
for (const node of Object.values(document.graph.nodes)) {
|
|
5710
|
+
if (node.kind != "task" || !("executor" in node.task) || node.task.executor.kind != "openapi") continue;
|
|
5711
|
+
for (const [handle, mapping] of Object.entries(node.inputs)) if (handle.startsWith("auth.") && mapping.kind == "value") throw new TypeError("OpenAPI authentication accepts deployment variables and upstream outputs only.");
|
|
5712
|
+
}
|
|
5713
|
+
}
|
|
5714
|
+
//#endregion
|
|
5715
|
+
//#region src/flow/common/change.ts
|
|
5716
|
+
var schemaKeywords = /* @__PURE__ */ new Set([
|
|
5717
|
+
"const",
|
|
5718
|
+
"enum",
|
|
5719
|
+
"exclusiveMaximum",
|
|
5720
|
+
"exclusiveMinimum",
|
|
5721
|
+
"maximum",
|
|
5722
|
+
"maxItems",
|
|
5723
|
+
"maxLength",
|
|
5724
|
+
"maxProperties",
|
|
5725
|
+
"minimum",
|
|
5726
|
+
"minItems",
|
|
5727
|
+
"minLength",
|
|
5728
|
+
"minProperties",
|
|
5729
|
+
"multipleOf",
|
|
5730
|
+
"pattern",
|
|
5731
|
+
"required",
|
|
5732
|
+
"type"
|
|
5799
5733
|
]);
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5734
|
+
function isSchemaKeyword(value) {
|
|
5735
|
+
return schemaKeywords.has(value);
|
|
5736
|
+
}
|
|
5737
|
+
//#endregion
|
|
5738
|
+
//#region src/json-schema-subset/utils.ts
|
|
5739
|
+
var nextId = 0;
|
|
5740
|
+
function createId() {
|
|
5741
|
+
const id = nextId;
|
|
5742
|
+
nextId += 1;
|
|
5743
|
+
return id;
|
|
5744
|
+
}
|
|
5745
|
+
function deepFreeze(target) {
|
|
5746
|
+
if (typeof target === "object" && target !== null && !Object.isFrozen(target)) {
|
|
5747
|
+
for (const key of Object.getOwnPropertyNames(target)) deepFreeze(Reflect.get(target, key));
|
|
5748
|
+
Object.freeze(target);
|
|
5749
|
+
}
|
|
5750
|
+
return target;
|
|
5751
|
+
}
|
|
5752
|
+
function pick(target, keys) {
|
|
5753
|
+
const newTarget = {};
|
|
5754
|
+
for (const key of keys) if (key in target) newTarget[key] = target[key];
|
|
5755
|
+
return newTarget;
|
|
5756
|
+
}
|
|
5757
|
+
function deepCopy(value) {
|
|
5758
|
+
if (typeof value !== "object" || value === null) return value;
|
|
5759
|
+
else if (Array.isArray(value)) {
|
|
5760
|
+
const array = [];
|
|
5761
|
+
for (const [i, element] of value.entries()) array[i] = deepCopy(element);
|
|
5762
|
+
return array;
|
|
5763
|
+
} else {
|
|
5764
|
+
const newObject = {};
|
|
5765
|
+
for (const key in value) newObject[key] = deepCopy(value[key]);
|
|
5766
|
+
return newObject;
|
|
5767
|
+
}
|
|
5768
|
+
}
|
|
5769
|
+
function isDeepEquals(value1, value2) {
|
|
5770
|
+
if (value1 === value2) return true;
|
|
5771
|
+
if (value1 === null) return false;
|
|
5772
|
+
if (typeof value1 !== "object") return false;
|
|
5773
|
+
if (typeof value1 !== typeof value2) return false;
|
|
5774
|
+
if (Array.isArray(value1)) {
|
|
5775
|
+
if (!Array.isArray(value2)) return false;
|
|
5776
|
+
if (value1.length !== value2.length) return false;
|
|
5777
|
+
for (const [i, value1Element] of value1.entries()) if (!isDeepEquals(value1Element, value2[i])) return false;
|
|
5778
|
+
} else {
|
|
5779
|
+
if (Array.isArray(value2)) return false;
|
|
5780
|
+
for (const key in value1) {
|
|
5781
|
+
if (!(key in value2)) return false;
|
|
5782
|
+
if (!isDeepEquals(value1[key], value2[key])) return false;
|
|
5783
|
+
}
|
|
5784
|
+
for (const key in value2) if (!(key in value1)) return false;
|
|
5785
|
+
}
|
|
5786
|
+
return true;
|
|
5787
|
+
}
|
|
5788
|
+
//#endregion
|
|
5789
|
+
//#region src/json-schema-subset/expression/result.ts
|
|
5790
|
+
var ExpressionSingleResult = Object.freeze({
|
|
5791
|
+
Equals: 0,
|
|
5792
|
+
Containing: 1,
|
|
5793
|
+
ContainedBy: 2,
|
|
5794
|
+
Rejection: 3,
|
|
5795
|
+
Intersection: 4
|
|
5805
5796
|
});
|
|
5806
|
-
var
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
instructions: text,
|
|
5818
|
-
type: literal("noul"),
|
|
5819
|
-
criteria: strictObject({
|
|
5820
|
-
true: text.optional(),
|
|
5821
|
-
false: text.optional()
|
|
5822
|
-
}).optional()
|
|
5823
|
-
}),
|
|
5824
|
-
strictObject({
|
|
5825
|
-
name: text,
|
|
5826
|
-
instructions: text,
|
|
5827
|
-
type: literal("choice"),
|
|
5828
|
-
criteria: array(strictObject({
|
|
5829
|
-
name: text,
|
|
5830
|
-
description: text
|
|
5831
|
-
}))
|
|
5832
|
-
}),
|
|
5833
|
-
strictObject({
|
|
5834
|
-
name: text,
|
|
5835
|
-
instructions: text,
|
|
5836
|
-
type: literal("score"),
|
|
5837
|
-
criteria: strings$1
|
|
5838
|
-
})
|
|
5839
|
-
]);
|
|
5840
|
-
var managedFields = object({
|
|
5841
|
-
...ports$1,
|
|
5842
|
-
name: text,
|
|
5843
|
-
executor: union([
|
|
5844
|
-
object({
|
|
5845
|
-
kind: literal("connector"),
|
|
5846
|
-
action: text,
|
|
5847
|
-
connectionId: text.optional()
|
|
5848
|
-
}),
|
|
5849
|
-
object({
|
|
5850
|
-
kind: literal("openapi"),
|
|
5851
|
-
sourceUrl: text,
|
|
5852
|
-
method: text,
|
|
5853
|
-
path: text,
|
|
5854
|
-
serverUrl: text,
|
|
5855
|
-
document: json$3,
|
|
5856
|
-
auth: array(object({
|
|
5857
|
-
id: text,
|
|
5858
|
-
type: _enum([
|
|
5859
|
-
"bearer",
|
|
5860
|
-
"basic",
|
|
5861
|
-
"apiKey"
|
|
5862
|
-
]),
|
|
5863
|
-
name: text.optional(),
|
|
5864
|
-
in: _enum(["header", "query"]).optional()
|
|
5865
|
-
}))
|
|
5866
|
-
}),
|
|
5867
|
-
strictObject({
|
|
5868
|
-
kind: literal("decision"),
|
|
5869
|
-
questions: array(decisionQuestion)
|
|
5870
|
-
}),
|
|
5871
|
-
object({
|
|
5872
|
-
kind: literal("llm"),
|
|
5873
|
-
mode: _enum(["chat", "json"])
|
|
5874
|
-
}),
|
|
5875
|
-
object({
|
|
5876
|
-
kind: literal("agent"),
|
|
5877
|
-
code: boolean().optional(),
|
|
5878
|
-
model: text,
|
|
5879
|
-
prompt: text,
|
|
5880
|
-
maxRounds: number(),
|
|
5881
|
-
tools: array(object({
|
|
5882
|
-
id: text,
|
|
5883
|
-
name: text,
|
|
5884
|
-
description: text,
|
|
5885
|
-
action: text,
|
|
5886
|
-
connectionId: text.optional(),
|
|
5887
|
-
approval: boolean(),
|
|
5888
|
-
inputs: array(input.extend({ source: agentInput }))
|
|
5889
|
-
})),
|
|
5890
|
-
notification: object({
|
|
5891
|
-
action: text,
|
|
5892
|
-
connectionId: text.optional(),
|
|
5893
|
-
inputDefinitions: array(input),
|
|
5894
|
-
messageHandle: text,
|
|
5895
|
-
inputs: record$3(text, agentValue)
|
|
5896
|
-
}).optional()
|
|
5897
|
-
})
|
|
5898
|
-
])
|
|
5899
|
-
});
|
|
5900
|
-
var managed = managedFields.transform(limitDecisionTask);
|
|
5901
|
-
var operand$1 = union([object({
|
|
5902
|
-
kind: literal("value"),
|
|
5903
|
-
value: json$3.optional(),
|
|
5904
|
-
jsonSchema: json$3.optional()
|
|
5905
|
-
}), object({
|
|
5906
|
-
kind: literal("source"),
|
|
5907
|
-
source
|
|
5908
|
-
})]);
|
|
5909
|
-
var condition = {
|
|
5910
|
-
matchMode: _enum(["first", "all"]),
|
|
5911
|
-
cases: array(object({
|
|
5912
|
-
description: text.optional(),
|
|
5913
|
-
output: text,
|
|
5914
|
-
groups: array(object({ expressions: array(object({
|
|
5915
|
-
left: operand$1,
|
|
5916
|
-
operator: _enum([
|
|
5917
|
-
"!=",
|
|
5918
|
-
"<",
|
|
5919
|
-
"<=",
|
|
5920
|
-
"==",
|
|
5921
|
-
">",
|
|
5922
|
-
">=",
|
|
5923
|
-
"contains",
|
|
5924
|
-
"endsWith",
|
|
5925
|
-
"hasKey",
|
|
5926
|
-
"hasValue",
|
|
5927
|
-
"isEmpty",
|
|
5928
|
-
"isFalse",
|
|
5929
|
-
"isNotEmpty",
|
|
5930
|
-
"isNotNull",
|
|
5931
|
-
"isNull",
|
|
5932
|
-
"isTrue",
|
|
5933
|
-
"notContains",
|
|
5934
|
-
"notHasKey",
|
|
5935
|
-
"notHasValue",
|
|
5936
|
-
"startsWith"
|
|
5937
|
-
]),
|
|
5938
|
-
right: operand$1.optional()
|
|
5939
|
-
})) }))
|
|
5940
|
-
}))
|
|
5941
|
-
};
|
|
5942
|
-
var wait = {
|
|
5943
|
-
inputDefinitions: array(input),
|
|
5944
|
-
prompt: text
|
|
5945
|
-
};
|
|
5946
|
-
var webhookOptions = object({
|
|
5947
|
-
allowedMethods: never().optional(),
|
|
5948
|
-
allowedOrigins: strings$1.optional(),
|
|
5949
|
-
noResponseBody: never().optional(),
|
|
5950
|
-
responseData: text.optional(),
|
|
5951
|
-
responseHeaders: record$3(text, text).optional(),
|
|
5952
|
-
responseStatusCode: number().int().min(200).max(599).optional()
|
|
5953
|
-
});
|
|
5954
|
-
var webhook = {
|
|
5955
|
-
bodyFields: array(input),
|
|
5956
|
-
method: _enum(webhookMethods),
|
|
5957
|
-
options: webhookOptions.optional()
|
|
5958
|
-
};
|
|
5959
|
-
var definition = {
|
|
5960
|
-
configInputs: ports$1.inputs,
|
|
5961
|
-
definitionVersion: literal(2),
|
|
5962
|
-
description: text,
|
|
5963
|
-
displayName: text,
|
|
5964
|
-
key: text,
|
|
5965
|
-
name: text,
|
|
5966
|
-
outputs: array(port$1).refine((definitions) => new Set(definitions.map((output) => output.handle)).size === definitions.length, "Duplicate Trigger output handle."),
|
|
5967
|
-
provider: text
|
|
5968
|
-
};
|
|
5969
|
-
var endpoint = object({
|
|
5970
|
-
body: object({
|
|
5971
|
-
allowArray: boolean(),
|
|
5972
|
-
allowEmpty: boolean(),
|
|
5973
|
-
formats: array(_enum([
|
|
5974
|
-
"form",
|
|
5975
|
-
"json",
|
|
5976
|
-
"multipart",
|
|
5977
|
-
"text"
|
|
5978
|
-
]))
|
|
5979
|
-
}),
|
|
5980
|
-
methods: array(_enum([
|
|
5981
|
-
"DELETE",
|
|
5982
|
-
"GET",
|
|
5983
|
-
"HEAD",
|
|
5984
|
-
"PATCH",
|
|
5985
|
-
"POST",
|
|
5986
|
-
"PUT"
|
|
5987
|
-
])),
|
|
5988
|
-
successStatus: number()
|
|
5989
|
-
});
|
|
5990
|
-
var sourceFlowIds = array(text.min(1)).refine((ids) => new Set(ids).size === ids.length, "Duplicate source Flow ID.");
|
|
5991
|
-
var trigger = {
|
|
5992
|
-
name: text,
|
|
5993
|
-
description: text.optional(),
|
|
5994
|
-
icon: text.optional()
|
|
5995
|
-
};
|
|
5996
|
-
var base = {
|
|
5997
|
-
maxExecutions: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
5998
|
-
inputs,
|
|
5999
|
-
name: text.optional(),
|
|
6000
|
-
description: text.optional(),
|
|
6001
|
-
icon: text.optional(),
|
|
6002
|
-
timeoutMs: number().optional()
|
|
6003
|
-
};
|
|
6004
|
-
var node = union([
|
|
6005
|
-
object({
|
|
6006
|
-
...base,
|
|
6007
|
-
inputs: record$3(text, never()),
|
|
6008
|
-
kind: literal("condition"),
|
|
6009
|
-
...condition
|
|
6010
|
-
}),
|
|
6011
|
-
object({
|
|
6012
|
-
...base,
|
|
6013
|
-
inputs: unknown().transform(() => ({})).default({}),
|
|
6014
|
-
kind: literal("value"),
|
|
6015
|
-
values: array(input)
|
|
6016
|
-
}),
|
|
6017
|
-
object({
|
|
6018
|
-
...base,
|
|
6019
|
-
kind: literal("task"),
|
|
6020
|
-
task: union([inline, managed]),
|
|
6021
|
-
additionalInputs: array(input).optional()
|
|
6022
|
-
}),
|
|
6023
|
-
strictObject({
|
|
6024
|
-
...base,
|
|
6025
|
-
kind: literal("approval"),
|
|
6026
|
-
...wait
|
|
6027
|
-
}).omit({ timeoutMs: true }),
|
|
6028
|
-
strictObject({
|
|
6029
|
-
...base,
|
|
6030
|
-
kind: literal("wait"),
|
|
6031
|
-
...wait
|
|
6032
|
-
}).omit({ timeoutMs: true }),
|
|
6033
|
-
object({
|
|
6034
|
-
...trigger,
|
|
6035
|
-
kind: literal("manual")
|
|
6036
|
-
}),
|
|
6037
|
-
strictObject({
|
|
6038
|
-
...trigger,
|
|
6039
|
-
kind: literal("error"),
|
|
6040
|
-
sourceFlowIds: sourceFlowIds.optional()
|
|
6041
|
-
}),
|
|
6042
|
-
object({
|
|
6043
|
-
...trigger,
|
|
6044
|
-
kind: literal("webhook"),
|
|
6045
|
-
...webhook
|
|
6046
|
-
}),
|
|
6047
|
-
object({
|
|
6048
|
-
...trigger,
|
|
6049
|
-
kind: literal("cron"),
|
|
6050
|
-
cronTimes: triggerScheduleSchema
|
|
6051
|
-
}),
|
|
6052
|
-
object({
|
|
6053
|
-
...trigger,
|
|
6054
|
-
kind: literal("poll"),
|
|
6055
|
-
connectionId: text.min(1).optional(),
|
|
6056
|
-
config: record$3(text, fixedInput),
|
|
6057
|
-
definition: object({
|
|
6058
|
-
...definition,
|
|
6059
|
-
type: literal("poll")
|
|
6060
|
-
}),
|
|
6061
|
-
pollTimes: triggerScheduleSchema
|
|
6062
|
-
}),
|
|
6063
|
-
object({
|
|
6064
|
-
...trigger,
|
|
6065
|
-
kind: literal("integration"),
|
|
6066
|
-
connectionId: text.min(1).optional(),
|
|
6067
|
-
config: record$3(text, fixedInput),
|
|
6068
|
-
definition: object({
|
|
6069
|
-
...definition,
|
|
6070
|
-
type: literal("integration"),
|
|
6071
|
-
endpoint
|
|
6072
|
-
})
|
|
6073
|
-
})
|
|
6074
|
-
]);
|
|
6075
|
-
/** Configuration schemas shared by the node authoring boundary. */
|
|
6076
|
-
var authoringDefinitionSchemas = {
|
|
6077
|
-
input,
|
|
6078
|
-
port: port$1,
|
|
6079
|
-
ports: ports$1,
|
|
6080
|
-
condition: strictObject(condition),
|
|
6081
|
-
wait: strictObject(wait),
|
|
6082
|
-
webhook: strictObject(webhook),
|
|
6083
|
-
schedule: triggerScheduleSchema,
|
|
6084
|
-
capabilities: array(capability),
|
|
6085
|
-
connector: managedFields.shape.executor.options[0].omit({ kind: true }).strict(),
|
|
6086
|
-
openapi: managedFields.shape.executor.options[1].omit({ kind: true }).strict(),
|
|
6087
|
-
decision: managedFields.shape.executor.options[2].omit({ kind: true }).strict(),
|
|
6088
|
-
llm: managedFields.shape.executor.options[3].omit({ kind: true }).strict(),
|
|
6089
|
-
agent: managedFields.shape.executor.options[4].omit({
|
|
6090
|
-
kind: true,
|
|
6091
|
-
notification: true
|
|
6092
|
-
}).strict()
|
|
6093
|
-
};
|
|
6094
|
-
var edge = object({
|
|
6095
|
-
source: text,
|
|
6096
|
-
target: text,
|
|
6097
|
-
sourceHandle: text.optional()
|
|
6098
|
-
});
|
|
6099
|
-
var at = {
|
|
6100
|
-
nodeId: text,
|
|
6101
|
-
target: never().optional()
|
|
6102
|
-
};
|
|
6103
|
-
var graph = object({
|
|
6104
|
-
nodes: record$3(text, node),
|
|
6105
|
-
edges: array(edge).default([])
|
|
6106
|
-
});
|
|
6107
|
-
var binding = object({
|
|
6108
|
-
kind: literal("variable"),
|
|
6109
|
-
target: text
|
|
6110
|
-
});
|
|
6111
|
-
var module = object({
|
|
6112
|
-
name: text,
|
|
6113
|
-
imports: strings$1,
|
|
6114
|
-
source: text
|
|
6115
|
-
});
|
|
6116
|
-
var document = preprocess(rejectRetiredDefinitions, object({
|
|
6117
|
-
bindings: record$3(text, binding),
|
|
6118
|
-
graph
|
|
6119
|
-
}));
|
|
6120
|
-
var revision = object({
|
|
6121
|
-
modelVersion: union([
|
|
6122
|
-
literal(2),
|
|
6123
|
-
literal(4),
|
|
6124
|
-
literal(5),
|
|
6125
|
-
literal(6)
|
|
6126
|
-
]),
|
|
6127
|
-
document,
|
|
6128
|
-
modules: record$3(text, module)
|
|
6129
|
-
});
|
|
6130
|
-
revision.extend({
|
|
6131
|
-
kind: literal("open-flow-flow-revision"),
|
|
6132
|
-
version: literal(1)
|
|
6133
|
-
});
|
|
6134
|
-
function rejectRetiredDefinitions(value) {
|
|
6135
|
-
const candidate = record$2(value);
|
|
6136
|
-
if (candidate.tasks !== void 0 && (candidate.tasks === null || typeof candidate.tasks !== "object" || Array.isArray(candidate.tasks) || Object.keys(candidate.tasks).length > 0)) throw new TypeError("Independent Task definitions are no longer supported.");
|
|
6137
|
-
if (Object.values(record$2(record$2(candidate.graph).nodes)).some((candidateNode) => Object.hasOwn(record$2(candidateNode), "taskId"))) throw new TypeError("Task references are no longer supported.");
|
|
6138
|
-
const subflows = candidate.subflows;
|
|
6139
|
-
if (subflows !== void 0 && (subflows === null || typeof subflows !== "object" || Array.isArray(subflows) || Object.keys(subflows).length > 0)) throw new TypeError("Subflows are no longer supported.");
|
|
6140
|
-
if (Object.values(record$2(record$2(candidate.graph).nodes)).some((candidateNode) => record$2(candidateNode).kind === "subflow")) throw new TypeError("Subflow nodes are no longer supported.");
|
|
6141
|
-
return value;
|
|
6142
|
-
}
|
|
6143
|
-
function record$2(value) {
|
|
6144
|
-
return value != null && typeof value == "object" && !Array.isArray(value) ? value : {};
|
|
6145
|
-
}
|
|
6146
|
-
function decodeRevisionContent(value) {
|
|
6147
|
-
checkJsonDepth(value);
|
|
6148
|
-
const content = revision.parse(value);
|
|
6149
|
-
checkModelVersion(content);
|
|
6150
|
-
assertOpenApiAuthBindings(content.document);
|
|
6151
|
-
return content;
|
|
6152
|
-
}
|
|
6153
|
-
var shapes = {
|
|
6154
|
-
"graph.trigger.sources.set": {
|
|
6155
|
-
nodeId: text,
|
|
6156
|
-
before: sourceFlowIds.optional(),
|
|
6157
|
-
value: sourceFlowIds.optional()
|
|
6158
|
-
},
|
|
6159
|
-
"binding.create": {
|
|
6160
|
-
bindingId: text,
|
|
6161
|
-
binding
|
|
6162
|
-
},
|
|
6163
|
-
"binding.delete": { bindingId: text },
|
|
6164
|
-
"binding.target.set": {
|
|
6165
|
-
bindingId: text,
|
|
6166
|
-
before: text,
|
|
6167
|
-
value: text
|
|
6168
|
-
},
|
|
6169
|
-
"graph.edge.connect": {
|
|
6170
|
-
edge,
|
|
6171
|
-
target: never().optional()
|
|
6172
|
-
},
|
|
6173
|
-
"graph.edge.disconnect": {
|
|
6174
|
-
edge,
|
|
6175
|
-
target: never().optional()
|
|
6176
|
-
},
|
|
6177
|
-
"graph.node.create": {
|
|
6178
|
-
...at,
|
|
6179
|
-
node
|
|
6180
|
-
},
|
|
6181
|
-
"graph.node.replace": {
|
|
6182
|
-
...at,
|
|
6183
|
-
before: node,
|
|
6184
|
-
node
|
|
6185
|
-
},
|
|
6186
|
-
"graph.node.delete": at,
|
|
6187
|
-
"graph.node.field.set": union([
|
|
6188
|
-
object({
|
|
6189
|
-
...at,
|
|
6190
|
-
kind: literal("graph.node.field.set"),
|
|
6191
|
-
field: literal("connectionId"),
|
|
6192
|
-
before: text.min(1).optional(),
|
|
6193
|
-
value: text.min(1).optional()
|
|
6194
|
-
}),
|
|
6195
|
-
object({
|
|
6196
|
-
...at,
|
|
6197
|
-
kind: literal("graph.node.field.set"),
|
|
6198
|
-
field: _enum([
|
|
6199
|
-
"description",
|
|
6200
|
-
"icon",
|
|
6201
|
-
"name"
|
|
6202
|
-
]),
|
|
6203
|
-
before: text.optional(),
|
|
6204
|
-
value: text.optional()
|
|
6205
|
-
}),
|
|
6206
|
-
object({
|
|
6207
|
-
...at,
|
|
6208
|
-
kind: literal("graph.node.field.set"),
|
|
6209
|
-
field: literal("maxExecutions"),
|
|
6210
|
-
before: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
6211
|
-
value: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional()
|
|
6212
|
-
}),
|
|
6213
|
-
object({
|
|
6214
|
-
...at,
|
|
6215
|
-
kind: literal("graph.node.field.set"),
|
|
6216
|
-
field: literal("timeoutMs"),
|
|
6217
|
-
before: number().optional(),
|
|
6218
|
-
value: number().optional()
|
|
6219
|
-
})
|
|
6220
|
-
]),
|
|
6221
|
-
"graph.node.input.set": {
|
|
6222
|
-
...at,
|
|
6223
|
-
handle: text,
|
|
6224
|
-
before: mapping.optional(),
|
|
6225
|
-
value: mapping.optional()
|
|
6226
|
-
},
|
|
6227
|
-
"graph.node.additional-inputs.set": {
|
|
6228
|
-
...at,
|
|
6229
|
-
before: array(input).optional(),
|
|
6230
|
-
value: array(input).optional()
|
|
6231
|
-
},
|
|
6232
|
-
"graph.node.condition.set": {
|
|
6233
|
-
...at,
|
|
6234
|
-
before: object(condition),
|
|
6235
|
-
value: object(condition)
|
|
6236
|
-
},
|
|
6237
|
-
"graph.node.values.set": {
|
|
6238
|
-
...at,
|
|
6239
|
-
before: array(input),
|
|
6240
|
-
value: array(input)
|
|
6241
|
-
},
|
|
6242
|
-
"graph.node.resolution.set": {
|
|
6243
|
-
...at,
|
|
6244
|
-
before: object(wait),
|
|
6245
|
-
value: object(wait)
|
|
6246
|
-
},
|
|
6247
|
-
"graph.node.webhook.set": {
|
|
6248
|
-
...at,
|
|
6249
|
-
before: object(webhook),
|
|
6250
|
-
value: object(webhook)
|
|
6251
|
-
},
|
|
6252
|
-
"graph.node.task.ports.set": {
|
|
6253
|
-
...at,
|
|
6254
|
-
before: object(ports$1),
|
|
6255
|
-
value: object(ports$1)
|
|
6256
|
-
},
|
|
6257
|
-
"graph.node.task.name.set": {
|
|
6258
|
-
...at,
|
|
6259
|
-
before: text,
|
|
6260
|
-
value: text
|
|
6261
|
-
},
|
|
6262
|
-
"graph.node.task.capabilities.set": {
|
|
6263
|
-
...at,
|
|
6264
|
-
before: array(capability).optional(),
|
|
6265
|
-
value: array(capability).optional()
|
|
6266
|
-
},
|
|
6267
|
-
"graph.trigger.config.set": {
|
|
6268
|
-
nodeId: text,
|
|
6269
|
-
name: text,
|
|
6270
|
-
before: fixedInput.optional(),
|
|
6271
|
-
value: fixedInput.optional()
|
|
6272
|
-
},
|
|
6273
|
-
"graph.trigger.schedule.set": {
|
|
6274
|
-
nodeId: text,
|
|
6275
|
-
before: triggerScheduleSchema,
|
|
6276
|
-
value: triggerScheduleSchema
|
|
6277
|
-
},
|
|
6278
|
-
"module.create": {
|
|
6279
|
-
moduleId: text,
|
|
6280
|
-
module
|
|
6281
|
-
},
|
|
6282
|
-
"module.delete": { moduleId: text },
|
|
6283
|
-
"module.rename": {
|
|
6284
|
-
moduleId: text,
|
|
6285
|
-
before: text,
|
|
6286
|
-
name: text
|
|
6287
|
-
},
|
|
6288
|
-
"module.source.replace": {
|
|
6289
|
-
moduleId: text,
|
|
6290
|
-
beforeImports: strings$1,
|
|
6291
|
-
beforeSource: text,
|
|
6292
|
-
imports: strings$1,
|
|
6293
|
-
source: text
|
|
6294
|
-
},
|
|
6295
|
-
"graph.node.task.set": {
|
|
6296
|
-
...at,
|
|
6297
|
-
before: union([inline, managed]),
|
|
6298
|
-
value: union([inline, managed])
|
|
6299
|
-
}
|
|
6300
|
-
};
|
|
6301
|
-
array(union([...new Map(Object.entries(shapes).map(([kind, shape]) => [kind, shape instanceof ZodType ? shape : object({
|
|
6302
|
-
kind: literal(kind),
|
|
6303
|
-
...shape
|
|
6304
|
-
})])).values()])).min(1);
|
|
6305
|
-
function checkModelVersion(content) {
|
|
6306
|
-
if (content.modelVersion < 6 && Object.values(content.document.graph.nodes).some((candidateNode) => candidateNode.kind == "task" && "executor" in candidateNode.task)) throw new TypeError("Node-owned managed Tasks require Flow model version 6.");
|
|
6307
|
-
if (content.modelVersion < 5 && Object.values(content.document.graph.nodes).some((itemNode) => itemNode.kind == "error")) throw new TypeError("Error workflows require Flow model version 5.");
|
|
6308
|
-
}
|
|
6309
|
-
//#endregion
|
|
6310
|
-
//#region src/flow/common/change.ts
|
|
6311
|
-
var schemaKeywords = /* @__PURE__ */ new Set([
|
|
6312
|
-
"const",
|
|
6313
|
-
"enum",
|
|
6314
|
-
"exclusiveMaximum",
|
|
6315
|
-
"exclusiveMinimum",
|
|
6316
|
-
"maximum",
|
|
6317
|
-
"maxItems",
|
|
6318
|
-
"maxLength",
|
|
6319
|
-
"maxProperties",
|
|
6320
|
-
"minimum",
|
|
6321
|
-
"minItems",
|
|
6322
|
-
"minLength",
|
|
6323
|
-
"minProperties",
|
|
6324
|
-
"multipleOf",
|
|
6325
|
-
"pattern",
|
|
6326
|
-
"required",
|
|
6327
|
-
"type"
|
|
6328
|
-
]);
|
|
6329
|
-
function isSchemaKeyword(value) {
|
|
6330
|
-
return schemaKeywords.has(value);
|
|
6331
|
-
}
|
|
6332
|
-
//#endregion
|
|
6333
|
-
//#region src/json-schema-subset/utils.ts
|
|
6334
|
-
var nextId = 0;
|
|
6335
|
-
function createId() {
|
|
6336
|
-
const id = nextId;
|
|
6337
|
-
nextId += 1;
|
|
6338
|
-
return id;
|
|
6339
|
-
}
|
|
6340
|
-
function deepFreeze(target) {
|
|
6341
|
-
if (typeof target === "object" && target !== null && !Object.isFrozen(target)) {
|
|
6342
|
-
for (const key of Object.getOwnPropertyNames(target)) deepFreeze(Reflect.get(target, key));
|
|
6343
|
-
Object.freeze(target);
|
|
6344
|
-
}
|
|
6345
|
-
return target;
|
|
6346
|
-
}
|
|
6347
|
-
function pick(target, keys) {
|
|
6348
|
-
const newTarget = {};
|
|
6349
|
-
for (const key of keys) if (key in target) newTarget[key] = target[key];
|
|
6350
|
-
return newTarget;
|
|
6351
|
-
}
|
|
6352
|
-
function deepCopy(value) {
|
|
6353
|
-
if (typeof value !== "object" || value === null) return value;
|
|
6354
|
-
else if (Array.isArray(value)) {
|
|
6355
|
-
const array = [];
|
|
6356
|
-
for (const [i, element] of value.entries()) array[i] = deepCopy(element);
|
|
6357
|
-
return array;
|
|
6358
|
-
} else {
|
|
6359
|
-
const newObject = {};
|
|
6360
|
-
for (const key in value) newObject[key] = deepCopy(value[key]);
|
|
6361
|
-
return newObject;
|
|
6362
|
-
}
|
|
6363
|
-
}
|
|
6364
|
-
function isDeepEquals(value1, value2) {
|
|
6365
|
-
if (value1 === value2) return true;
|
|
6366
|
-
if (value1 === null) return false;
|
|
6367
|
-
if (typeof value1 !== "object") return false;
|
|
6368
|
-
if (typeof value1 !== typeof value2) return false;
|
|
6369
|
-
if (Array.isArray(value1)) {
|
|
6370
|
-
if (!Array.isArray(value2)) return false;
|
|
6371
|
-
if (value1.length !== value2.length) return false;
|
|
6372
|
-
for (const [i, value1Element] of value1.entries()) if (!isDeepEquals(value1Element, value2[i])) return false;
|
|
6373
|
-
} else {
|
|
6374
|
-
if (Array.isArray(value2)) return false;
|
|
6375
|
-
for (const key in value1) {
|
|
6376
|
-
if (!(key in value2)) return false;
|
|
6377
|
-
if (!isDeepEquals(value1[key], value2[key])) return false;
|
|
6378
|
-
}
|
|
6379
|
-
for (const key in value2) if (!(key in value1)) return false;
|
|
6380
|
-
}
|
|
6381
|
-
return true;
|
|
6382
|
-
}
|
|
6383
|
-
//#endregion
|
|
6384
|
-
//#region src/json-schema-subset/expression/result.ts
|
|
6385
|
-
var ExpressionSingleResult = Object.freeze({
|
|
6386
|
-
Equals: 0,
|
|
6387
|
-
Containing: 1,
|
|
6388
|
-
ContainedBy: 2,
|
|
6389
|
-
Rejection: 3,
|
|
6390
|
-
Intersection: 4
|
|
6391
|
-
});
|
|
6392
|
-
var ExpressionEquals = toExpression(ExpressionSingleResult.Equals);
|
|
6393
|
-
var ExpressionContaining = toExpression(ExpressionSingleResult.Containing);
|
|
6394
|
-
var ExpressionContainedBy = toExpression(ExpressionSingleResult.ContainedBy);
|
|
6395
|
-
var ExpressionRejection = toExpression(ExpressionSingleResult.Rejection);
|
|
6396
|
-
var ExpressionIntersection = toExpression(ExpressionSingleResult.Intersection);
|
|
6397
|
-
var ExpressionMaskList = deepFreeze([
|
|
6398
|
-
[ExpressionSingleResult.Equals, ExpressionEquals],
|
|
6399
|
-
[ExpressionSingleResult.Containing, ExpressionContaining],
|
|
6400
|
-
[ExpressionSingleResult.ContainedBy, ExpressionContainedBy],
|
|
6401
|
-
[ExpressionSingleResult.Rejection, ExpressionRejection],
|
|
6402
|
-
[ExpressionSingleResult.Intersection, ExpressionIntersection]
|
|
5797
|
+
var ExpressionEquals = toExpression(ExpressionSingleResult.Equals);
|
|
5798
|
+
var ExpressionContaining = toExpression(ExpressionSingleResult.Containing);
|
|
5799
|
+
var ExpressionContainedBy = toExpression(ExpressionSingleResult.ContainedBy);
|
|
5800
|
+
var ExpressionRejection = toExpression(ExpressionSingleResult.Rejection);
|
|
5801
|
+
var ExpressionIntersection = toExpression(ExpressionSingleResult.Intersection);
|
|
5802
|
+
var ExpressionMaskList = deepFreeze([
|
|
5803
|
+
[ExpressionSingleResult.Equals, ExpressionEquals],
|
|
5804
|
+
[ExpressionSingleResult.Containing, ExpressionContaining],
|
|
5805
|
+
[ExpressionSingleResult.ContainedBy, ExpressionContainedBy],
|
|
5806
|
+
[ExpressionSingleResult.Rejection, ExpressionRejection],
|
|
5807
|
+
[ExpressionSingleResult.Intersection, ExpressionIntersection]
|
|
6403
5808
|
]);
|
|
6404
5809
|
var ExpressionAny = (() => {
|
|
6405
5810
|
let expression = 0;
|
|
@@ -7933,1247 +7338,1845 @@ function splitRangeGreaterBranch(range1, range2) {
|
|
|
7933
7338
|
fromLeft: true,
|
|
7934
7339
|
range: range1
|
|
7935
7340
|
}
|
|
7936
|
-
};
|
|
7341
|
+
};
|
|
7342
|
+
}
|
|
7343
|
+
if (max2.num <= max1.num) {
|
|
7344
|
+
let hasRight = true;
|
|
7345
|
+
let isRightRangeOverride = false;
|
|
7346
|
+
if (max1.num === max2.num) {
|
|
7347
|
+
const exclusive1 = max2.exclusive;
|
|
7348
|
+
const exclusive2 = max1.exclusive;
|
|
7349
|
+
hasRight = exclusive1 !== exclusive2;
|
|
7350
|
+
isRightRangeOverride = !exclusive1 && exclusive2;
|
|
7351
|
+
}
|
|
7352
|
+
if (!isRightRangeOverride) {
|
|
7353
|
+
let right;
|
|
7354
|
+
if (hasRight) right = {
|
|
7355
|
+
fromLeft: true,
|
|
7356
|
+
range: [reversalExclusive(max2), max1]
|
|
7357
|
+
};
|
|
7358
|
+
return {
|
|
7359
|
+
left: {
|
|
7360
|
+
fromLeft: false,
|
|
7361
|
+
range: [min2, reversalExclusive(min1)]
|
|
7362
|
+
},
|
|
7363
|
+
center: [min1, max2],
|
|
7364
|
+
right
|
|
7365
|
+
};
|
|
7366
|
+
}
|
|
7367
|
+
}
|
|
7368
|
+
return {
|
|
7369
|
+
left: {
|
|
7370
|
+
fromLeft: false,
|
|
7371
|
+
range: [min2, reversalExclusive(min1)]
|
|
7372
|
+
},
|
|
7373
|
+
center: [min1, max1],
|
|
7374
|
+
right: {
|
|
7375
|
+
fromLeft: false,
|
|
7376
|
+
range: [reversalExclusive(max1), max2]
|
|
7377
|
+
}
|
|
7378
|
+
};
|
|
7379
|
+
}
|
|
7380
|
+
function splitRangeEqualsBranch(range1, range2) {
|
|
7381
|
+
const [min1, max1] = range1;
|
|
7382
|
+
const [min2, max2] = range2;
|
|
7383
|
+
const exclusive1 = min1.exclusive;
|
|
7384
|
+
const exclusive2 = min2.exclusive;
|
|
7385
|
+
let left;
|
|
7386
|
+
let centerBegin = min1;
|
|
7387
|
+
if (!exclusive1 && exclusive2) {
|
|
7388
|
+
centerBegin = min2;
|
|
7389
|
+
left = {
|
|
7390
|
+
fromLeft: true,
|
|
7391
|
+
range: [min1, reversalExclusive(min2)]
|
|
7392
|
+
};
|
|
7393
|
+
} else if (exclusive1 && !exclusive2) left = {
|
|
7394
|
+
fromLeft: false,
|
|
7395
|
+
range: [min2, reversalExclusive(min1)]
|
|
7396
|
+
};
|
|
7397
|
+
if (max1.num <= max2.num) {
|
|
7398
|
+
let hasRight = true;
|
|
7399
|
+
let isLeftRangeOverride = false;
|
|
7400
|
+
if (max1.num === max2.num) {
|
|
7401
|
+
const maxExclusive1 = max1.exclusive;
|
|
7402
|
+
const maxExclusive2 = max2.exclusive;
|
|
7403
|
+
hasRight = maxExclusive1 !== maxExclusive2;
|
|
7404
|
+
isLeftRangeOverride = !maxExclusive1 && maxExclusive2;
|
|
7405
|
+
}
|
|
7406
|
+
if (!isLeftRangeOverride) {
|
|
7407
|
+
let right;
|
|
7408
|
+
if (hasRight) right = {
|
|
7409
|
+
fromLeft: false,
|
|
7410
|
+
range: [reversalExclusive(max1), max2]
|
|
7411
|
+
};
|
|
7412
|
+
return {
|
|
7413
|
+
left,
|
|
7414
|
+
center: [centerBegin, max1],
|
|
7415
|
+
right
|
|
7416
|
+
};
|
|
7417
|
+
}
|
|
7418
|
+
}
|
|
7419
|
+
return {
|
|
7420
|
+
left,
|
|
7421
|
+
center: [centerBegin, max2],
|
|
7422
|
+
right: {
|
|
7423
|
+
fromLeft: true,
|
|
7424
|
+
range: [reversalExclusive(max2), max1]
|
|
7425
|
+
}
|
|
7426
|
+
};
|
|
7427
|
+
}
|
|
7428
|
+
function reversalExclusive(point) {
|
|
7429
|
+
return {
|
|
7430
|
+
num: point.num,
|
|
7431
|
+
exclusive: !point.exclusive
|
|
7432
|
+
};
|
|
7433
|
+
}
|
|
7434
|
+
//#endregion
|
|
7435
|
+
//#region src/json-schema-subset/checker/range.ts
|
|
7436
|
+
var createRangeSplitter = (undefinedMin) => (min1 = undefinedMin, max1 = Number.POSITIVE_INFINITY, min2 = undefinedMin, max2 = Number.POSITIVE_INFINITY) => {
|
|
7437
|
+
const { left, center, right } = splitRange$3([{
|
|
7438
|
+
num: min1,
|
|
7439
|
+
exclusive: false
|
|
7440
|
+
}, {
|
|
7441
|
+
num: max1,
|
|
7442
|
+
exclusive: false
|
|
7443
|
+
}], [{
|
|
7444
|
+
num: min2,
|
|
7445
|
+
exclusive: false
|
|
7446
|
+
}, {
|
|
7447
|
+
num: max2,
|
|
7448
|
+
exclusive: false
|
|
7449
|
+
}]);
|
|
7450
|
+
let leftItem;
|
|
7451
|
+
let rightItem;
|
|
7452
|
+
let intersectionItem;
|
|
7453
|
+
if (left) leftItem = {
|
|
7454
|
+
min: left.range[0].num,
|
|
7455
|
+
max: left.range[1].num,
|
|
7456
|
+
isFrom1: left.fromLeft
|
|
7457
|
+
};
|
|
7458
|
+
if (right) rightItem = {
|
|
7459
|
+
min: right.range[0].num,
|
|
7460
|
+
max: right.range[1].num,
|
|
7461
|
+
isFrom1: right.fromLeft
|
|
7462
|
+
};
|
|
7463
|
+
if (center) intersectionItem = {
|
|
7464
|
+
min: center[0].num,
|
|
7465
|
+
max: center[1].num
|
|
7466
|
+
};
|
|
7467
|
+
return {
|
|
7468
|
+
left: leftItem,
|
|
7469
|
+
right: rightItem,
|
|
7470
|
+
intersection: intersectionItem
|
|
7471
|
+
};
|
|
7472
|
+
};
|
|
7473
|
+
function toExpressionSingleResult({ left, right, intersection }) {
|
|
7474
|
+
if (!intersection) return ExpressionSingleResult.Rejection;
|
|
7475
|
+
let extra1 = false;
|
|
7476
|
+
let extra2 = false;
|
|
7477
|
+
if (left) {
|
|
7478
|
+
if (left.isFrom1) extra1 = true;
|
|
7479
|
+
else extra2 = true;
|
|
7480
|
+
}
|
|
7481
|
+
if (right) {
|
|
7482
|
+
if (right.isFrom1) extra1 = true;
|
|
7483
|
+
else extra2 = true;
|
|
7484
|
+
}
|
|
7485
|
+
if (extra1 && extra2) return ExpressionSingleResult.Intersection;
|
|
7486
|
+
if (extra1) return ExpressionSingleResult.Containing;
|
|
7487
|
+
if (extra2) return ExpressionSingleResult.ContainedBy;
|
|
7488
|
+
return ExpressionSingleResult.Equals;
|
|
7489
|
+
}
|
|
7490
|
+
//#endregion
|
|
7491
|
+
//#region src/json-schema-subset/checker/array.ts
|
|
7492
|
+
var splitRange$2 = createRangeSplitter(0);
|
|
7493
|
+
var quantum$1 = makeQuantum([
|
|
7494
|
+
"hasCommon",
|
|
7495
|
+
"hasExtra1",
|
|
7496
|
+
"hasExtra2",
|
|
7497
|
+
"hasRejection",
|
|
7498
|
+
"hasCommonBroken"
|
|
7499
|
+
]);
|
|
7500
|
+
function calculateArray({ calculate }, schema1, schema2) {
|
|
7501
|
+
const splitResult = splitRange$2(schema1.minItems, schema1.maxItems, schema2.minItems, schema2.maxItems);
|
|
7502
|
+
const splitExpression = toExpressionSingleResult(splitResult);
|
|
7503
|
+
if (splitExpression === ExpressionSingleResult.Rejection) return ExpressionRejection;
|
|
7504
|
+
const [items1, additionalItems1] = normalizeArray(schema1);
|
|
7505
|
+
const [items2, additionalItems2] = normalizeArray(schema2);
|
|
7506
|
+
const itemsLength = Math.max(items1.length, items2.length) + 1;
|
|
7507
|
+
const length = Math.min(itemsLength, splitResult.intersection.max);
|
|
7508
|
+
const quantumVariable = quantum$1.variable({});
|
|
7509
|
+
const minItems = Math.min(schema1.minItems ?? 0, schema2.minItems ?? 0);
|
|
7510
|
+
for (let i = 0; i < length; i++) {
|
|
7511
|
+
const expression = calculate(items1[i] ?? additionalItems1, items2[i] ?? additionalItems2);
|
|
7512
|
+
quantumVariable.push(expression, (singleExpression, variable) => {
|
|
7513
|
+
switch (singleExpression) {
|
|
7514
|
+
case ExpressionSingleResult.Equals:
|
|
7515
|
+
if (!variable.hasRejection) variable.hasCommon = true;
|
|
7516
|
+
break;
|
|
7517
|
+
case ExpressionSingleResult.Containing:
|
|
7518
|
+
if (!variable.hasRejection) variable.hasCommon = true;
|
|
7519
|
+
variable.hasExtra1 = true;
|
|
7520
|
+
break;
|
|
7521
|
+
case ExpressionSingleResult.ContainedBy:
|
|
7522
|
+
if (!variable.hasRejection) variable.hasCommon = true;
|
|
7523
|
+
variable.hasExtra2 = true;
|
|
7524
|
+
break;
|
|
7525
|
+
case ExpressionSingleResult.Intersection:
|
|
7526
|
+
if (!variable.hasRejection) variable.hasCommon = true;
|
|
7527
|
+
variable.hasExtra1 = true;
|
|
7528
|
+
variable.hasExtra2 = true;
|
|
7529
|
+
break;
|
|
7530
|
+
case ExpressionSingleResult.Rejection:
|
|
7531
|
+
if (i < minItems) variable.hasCommonBroken = true;
|
|
7532
|
+
variable.hasRejection = true;
|
|
7533
|
+
variable.hasExtra1 = true;
|
|
7534
|
+
variable.hasExtra2 = true;
|
|
7535
|
+
}
|
|
7536
|
+
});
|
|
7937
7537
|
}
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
|
|
7538
|
+
quantumVariable.update((variable) => {
|
|
7539
|
+
switch (splitExpression) {
|
|
7540
|
+
case ExpressionSingleResult.Containing:
|
|
7541
|
+
variable.hasExtra1 = true;
|
|
7542
|
+
break;
|
|
7543
|
+
case ExpressionSingleResult.ContainedBy:
|
|
7544
|
+
variable.hasExtra2 = true;
|
|
7545
|
+
break;
|
|
7546
|
+
case ExpressionSingleResult.Intersection:
|
|
7547
|
+
variable.hasExtra1 = true;
|
|
7548
|
+
variable.hasExtra2 = true;
|
|
7946
7549
|
}
|
|
7947
|
-
if (!
|
|
7948
|
-
|
|
7949
|
-
|
|
7950
|
-
|
|
7951
|
-
|
|
7952
|
-
|
|
7953
|
-
return {
|
|
7954
|
-
left: {
|
|
7955
|
-
fromLeft: false,
|
|
7956
|
-
range: [min2, reversalExclusive(min1)]
|
|
7957
|
-
},
|
|
7958
|
-
center: [min1, max2],
|
|
7959
|
-
right
|
|
7960
|
-
};
|
|
7550
|
+
if (schema1.uniqueItems && !schema2.uniqueItems && (schema2.maxItems ?? Number.POSITIVE_INFINITY) > 1) variable.hasExtra2 = true;
|
|
7551
|
+
else if (!schema1.uniqueItems && schema2.uniqueItems && (schema1.maxItems ?? Number.POSITIVE_INFINITY) > 1) variable.hasExtra1 = true;
|
|
7552
|
+
if (schema1.maxItems === 0 || schema2.maxItems === 0) {
|
|
7553
|
+
variable.hasCommon = true;
|
|
7554
|
+
if (schema1.maxItems !== 0) variable.hasExtra1 = true;
|
|
7555
|
+
if (schema2.maxItems !== 0) variable.hasExtra2 = true;
|
|
7961
7556
|
}
|
|
7557
|
+
});
|
|
7558
|
+
let expression = 0;
|
|
7559
|
+
for (const { hasExtra1, hasExtra2, hasCommon, hasCommonBroken } of quantumVariable) {
|
|
7560
|
+
let finalHasCommon = hasCommon;
|
|
7561
|
+
if (hasCommonBroken) finalHasCommon = false;
|
|
7562
|
+
if (!finalHasCommon) expression |= ExpressionRejection;
|
|
7563
|
+
else if (hasExtra1 && hasExtra2) expression |= ExpressionIntersection;
|
|
7564
|
+
else if (hasExtra1) expression |= ExpressionContaining;
|
|
7565
|
+
else if (hasExtra2) expression |= ExpressionContainedBy;
|
|
7566
|
+
else expression |= ExpressionEquals;
|
|
7962
7567
|
}
|
|
7963
|
-
return
|
|
7964
|
-
left: {
|
|
7965
|
-
fromLeft: false,
|
|
7966
|
-
range: [min2, reversalExclusive(min1)]
|
|
7967
|
-
},
|
|
7968
|
-
center: [min1, max1],
|
|
7969
|
-
right: {
|
|
7970
|
-
fromLeft: false,
|
|
7971
|
-
range: [reversalExclusive(max1), max2]
|
|
7972
|
-
}
|
|
7973
|
-
};
|
|
7568
|
+
return expression;
|
|
7974
7569
|
}
|
|
7975
|
-
function
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
} else if (exclusive1 && !exclusive2) left = {
|
|
7989
|
-
fromLeft: false,
|
|
7990
|
-
range: [min2, reversalExclusive(min1)]
|
|
7570
|
+
function normalizeArray({ items, additionalItems }) {
|
|
7571
|
+
if (Array.isArray(items)) return [items, additionalItems ?? ANY];
|
|
7572
|
+
else return [[], items ?? ANY];
|
|
7573
|
+
}
|
|
7574
|
+
//#endregion
|
|
7575
|
+
//#region src/json-schema-subset/checker/cache.ts
|
|
7576
|
+
function wrapEqualsCheckerWithCache(check) {
|
|
7577
|
+
const map = /* @__PURE__ */ new Map();
|
|
7578
|
+
return (value1, value2) => {
|
|
7579
|
+
const isObject1 = isCompiledObject(value1);
|
|
7580
|
+
if (isObject1 !== isCompiledObject(value2)) return false;
|
|
7581
|
+
if (!isObject1) return value1 === value2;
|
|
7582
|
+
return getWithCache(map, value1, value2, check);
|
|
7991
7583
|
};
|
|
7992
|
-
|
|
7993
|
-
|
|
7994
|
-
|
|
7995
|
-
|
|
7996
|
-
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
7584
|
+
}
|
|
7585
|
+
function wrapSchemaCalculatorWithCache(check) {
|
|
7586
|
+
const map = /* @__PURE__ */ new Map();
|
|
7587
|
+
return (schema1, schema2) => getWithCache(map, schema1, schema2, check);
|
|
7588
|
+
}
|
|
7589
|
+
function getWithCache(map, node1, node2, check) {
|
|
7590
|
+
const key = `${getId(node1)}/${getId(node2)}`;
|
|
7591
|
+
let result = map.get(key);
|
|
7592
|
+
if (result === void 0) map.set(key, result = check(node1, node2));
|
|
7593
|
+
return result;
|
|
7594
|
+
}
|
|
7595
|
+
//#endregion
|
|
7596
|
+
//#region src/json-schema-subset/checker/enumAndConst.ts
|
|
7597
|
+
function calculateEnumAndEnum(context, schema1, schema2) {
|
|
7598
|
+
const enumList1 = normalizeEnumList(schema1);
|
|
7599
|
+
const enumList2 = normalizeEnumList(schema2);
|
|
7600
|
+
let foundExtra1 = false;
|
|
7601
|
+
let foundExtra2 = false;
|
|
7602
|
+
let foundIntersection = false;
|
|
7603
|
+
for (const enum1 of enumList1) {
|
|
7604
|
+
if (hasEqualsEnum(context, enumList2, enum1)) foundIntersection = true;
|
|
7605
|
+
else foundExtra1 = true;
|
|
7606
|
+
if (foundExtra1 && foundIntersection) break;
|
|
7607
|
+
}
|
|
7608
|
+
for (const enum2 of enumList2) {
|
|
7609
|
+
if (hasEqualsEnum(context, enumList1, enum2)) foundIntersection = true;
|
|
7610
|
+
else foundExtra2 = true;
|
|
7611
|
+
if (foundExtra2 && foundIntersection) break;
|
|
7612
|
+
}
|
|
7613
|
+
if (!foundIntersection) return ExpressionRejection;
|
|
7614
|
+
if (foundExtra1 && foundExtra2) return ExpressionIntersection;
|
|
7615
|
+
if (foundExtra1) return ExpressionContaining;
|
|
7616
|
+
if (foundExtra2) return ExpressionContainedBy;
|
|
7617
|
+
return ExpressionEquals;
|
|
7618
|
+
}
|
|
7619
|
+
function calculateEnumAndSchema(enumSchema, schema) {
|
|
7620
|
+
let hasValid = false;
|
|
7621
|
+
let hasInvalid = false;
|
|
7622
|
+
for (const enumValue of normalizeEnumList(enumSchema)) {
|
|
7623
|
+
switch (valid(schema, enumValue)) {
|
|
7624
|
+
case ValidResult.Valid:
|
|
7625
|
+
hasValid = true;
|
|
7626
|
+
break;
|
|
7627
|
+
case ValidResult.Invalid:
|
|
7628
|
+
hasInvalid = true;
|
|
7629
|
+
break;
|
|
7630
|
+
case ValidResult.Unknown: return ExpressionAny;
|
|
8000
7631
|
}
|
|
8001
|
-
if (
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
|
|
8006
|
-
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
|
|
8011
|
-
|
|
7632
|
+
if (hasValid && hasInvalid) break;
|
|
7633
|
+
}
|
|
7634
|
+
if (hasValid && hasInvalid) return ExpressionIntersection;
|
|
7635
|
+
if (hasValid) return ExpressionEquals | ExpressionContainedBy;
|
|
7636
|
+
if (hasInvalid) return ExpressionRejection;
|
|
7637
|
+
if (getKind(schema) === CompiledKind.Never) return ExpressionEquals;
|
|
7638
|
+
return ExpressionContainedBy;
|
|
7639
|
+
}
|
|
7640
|
+
function normalizeEnumList({ const: constValue, enum: enumList }) {
|
|
7641
|
+
if (constValue !== void 0) return [constValue];
|
|
7642
|
+
if (enumList) return enumList;
|
|
7643
|
+
throw new Error("invalid branch");
|
|
7644
|
+
}
|
|
7645
|
+
function hasEqualsEnum({ isEquals }, enumList, checkedEnum) {
|
|
7646
|
+
for (const searchedEnum of enumList) if (isEquals(searchedEnum, checkedEnum)) return true;
|
|
7647
|
+
return false;
|
|
7648
|
+
}
|
|
7649
|
+
//#endregion
|
|
7650
|
+
//#region src/json-schema-subset/checker/equals.ts
|
|
7651
|
+
function schemaEqualsChecker(extendsContext) {
|
|
7652
|
+
function isSchemaEquals(schema1, schema2) {
|
|
7653
|
+
const isExtends1 = extendsContext.isExtendsSchema(schema1);
|
|
7654
|
+
const isExtends2 = extendsContext.isExtendsSchema(schema2);
|
|
7655
|
+
if (isExtends1 || isExtends2) return extendsContext.equals(schema1, schema2);
|
|
7656
|
+
else return isCompiledSchemaEquals(schema1, schema2);
|
|
7657
|
+
}
|
|
7658
|
+
const equalsMap = /* @__PURE__ */ new Map();
|
|
7659
|
+
function isCompiledSchemaEquals(schema1, schema2) {
|
|
7660
|
+
const id1 = getId(schema1);
|
|
7661
|
+
const id2 = getId(schema2);
|
|
7662
|
+
if (id1 === id2) return true;
|
|
7663
|
+
const key = `${id1}/${id2}`;
|
|
7664
|
+
let isEquals = equalsMap.get(key);
|
|
7665
|
+
if (isEquals === void 0) {
|
|
7666
|
+
isEquals = isObjectLikeEquals(schema1, schema2);
|
|
7667
|
+
equalsMap.set(key, isEquals);
|
|
8012
7668
|
}
|
|
7669
|
+
return isEquals;
|
|
8013
7670
|
}
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
|
|
7671
|
+
function isObjectLikeEquals(object1, object2) {
|
|
7672
|
+
if (Array.isArray(object1)) {
|
|
7673
|
+
if (!Array.isArray(object2)) return false;
|
|
7674
|
+
if (object1.length !== object2.length) return false;
|
|
7675
|
+
for (const [i, value1Element] of object1.entries()) if (!isValueEquals(value1Element, object2[i])) return false;
|
|
7676
|
+
} else {
|
|
7677
|
+
if (Array.isArray(object2)) return false;
|
|
7678
|
+
for (const key in object1) {
|
|
7679
|
+
if (!(key in object2)) return false;
|
|
7680
|
+
if (!isValueEquals(Reflect.get(object1, key), Reflect.get(object2, key))) return false;
|
|
7681
|
+
}
|
|
7682
|
+
for (const key in object2) if (!(key in object1)) return false;
|
|
8020
7683
|
}
|
|
8021
|
-
|
|
7684
|
+
return true;
|
|
7685
|
+
}
|
|
7686
|
+
function isValueEquals(value1, value2) {
|
|
7687
|
+
if (value1 === value2) return true;
|
|
7688
|
+
if (value1 === null) return false;
|
|
7689
|
+
if (typeof value1 !== "object") return false;
|
|
7690
|
+
if (typeof value1 !== typeof value2) return false;
|
|
7691
|
+
if (isCompiledSchema(value1) && isCompiledSchema(value2)) return isCompiledSchemaEquals(value1, value2);
|
|
7692
|
+
return isObjectLikeEquals(value1, value2);
|
|
7693
|
+
}
|
|
7694
|
+
return isSchemaEquals;
|
|
8022
7695
|
}
|
|
8023
|
-
|
|
7696
|
+
//#endregion
|
|
7697
|
+
//#region src/json-schema-subset/checker/numeric/integerNormalizer.ts
|
|
7698
|
+
function normalizeInteger(schema) {
|
|
7699
|
+
const floatRange = pickRange(schema);
|
|
7700
|
+
const multipleOf = schema.multipleOf ?? 1;
|
|
7701
|
+
const range = cutRange(floatRange, multipleOf);
|
|
7702
|
+
if (!range) return null;
|
|
8024
7703
|
return {
|
|
8025
|
-
|
|
8026
|
-
|
|
7704
|
+
multipleOf,
|
|
7705
|
+
range
|
|
8027
7706
|
};
|
|
8028
7707
|
}
|
|
8029
|
-
|
|
8030
|
-
|
|
8031
|
-
|
|
8032
|
-
|
|
8033
|
-
|
|
7708
|
+
function isPointRange([point1, point2]) {
|
|
7709
|
+
if (point1.num !== point2.num) return false;
|
|
7710
|
+
if (point1.exclusive) return false;
|
|
7711
|
+
if (point2.exclusive) return false;
|
|
7712
|
+
return true;
|
|
7713
|
+
}
|
|
7714
|
+
function cutRange(range, multipleOf) {
|
|
7715
|
+
if (!range) return;
|
|
7716
|
+
const [originMin, originMax] = range;
|
|
7717
|
+
let min = nextInteger(originMin.num, multipleOf);
|
|
7718
|
+
let max = previousInteger(originMax.num, multipleOf);
|
|
7719
|
+
if (min === originMin.num && originMin.exclusive) min += multipleOf;
|
|
7720
|
+
if (max === originMax.num && originMax.exclusive) max -= multipleOf;
|
|
7721
|
+
if (min > max) return;
|
|
7722
|
+
if (min === max) {
|
|
7723
|
+
if (min === Number.POSITIVE_INFINITY) return;
|
|
7724
|
+
if (min === Number.NEGATIVE_INFINITY) return;
|
|
7725
|
+
}
|
|
7726
|
+
return [{
|
|
7727
|
+
num: min,
|
|
8034
7728
|
exclusive: false
|
|
8035
7729
|
}, {
|
|
8036
|
-
num:
|
|
8037
|
-
exclusive: false
|
|
8038
|
-
}], [{
|
|
8039
|
-
num: min2,
|
|
7730
|
+
num: max,
|
|
8040
7731
|
exclusive: false
|
|
8041
|
-
}
|
|
8042
|
-
|
|
7732
|
+
}];
|
|
7733
|
+
}
|
|
7734
|
+
function nextInteger(float, multipleOf) {
|
|
7735
|
+
return Math.ceil(float / multipleOf) * multipleOf;
|
|
7736
|
+
}
|
|
7737
|
+
function previousInteger(float, multipleOf) {
|
|
7738
|
+
return Math.floor(float / multipleOf) * multipleOf;
|
|
7739
|
+
}
|
|
7740
|
+
//#endregion
|
|
7741
|
+
//#region src/json-schema-subset/checker/numeric/float.ts
|
|
7742
|
+
function calculateFloat(schema1, schema2) {
|
|
7743
|
+
const { left, right, center } = splitRange$3(pickRange(schema1), pickRange(schema2));
|
|
7744
|
+
if (!center) return ExpressionRejection;
|
|
7745
|
+
let extraLeft = false;
|
|
7746
|
+
let extraRight = false;
|
|
7747
|
+
if (left) {
|
|
7748
|
+
if (left.fromLeft) extraLeft = true;
|
|
7749
|
+
else extraRight = true;
|
|
7750
|
+
}
|
|
7751
|
+
if (right) {
|
|
7752
|
+
if (right.fromLeft) extraLeft = true;
|
|
7753
|
+
else extraRight = true;
|
|
7754
|
+
}
|
|
7755
|
+
if (extraLeft && extraRight) return ExpressionIntersection;
|
|
7756
|
+
if (extraLeft) return ExpressionContaining;
|
|
7757
|
+
if (extraRight) return ExpressionContainedBy;
|
|
7758
|
+
return ExpressionEquals;
|
|
7759
|
+
}
|
|
7760
|
+
function calculateFloatAndInteger(schema1, schema2) {
|
|
7761
|
+
const floatRange = pickRange(schema1);
|
|
7762
|
+
const integer = normalizeInteger(schema2);
|
|
7763
|
+
if (!integer) return ExpressionContaining;
|
|
7764
|
+
const result = splitRange$3(floatRange, integer.range);
|
|
7765
|
+
const intCenter = cutRange(result.center, integer.multipleOf);
|
|
7766
|
+
const leftIntRange = unwrapAndCutRange(result.left, integer.multipleOf);
|
|
7767
|
+
const rightIntRange = unwrapAndCutRange(result.right, integer.multipleOf);
|
|
7768
|
+
if (!result.center) return ExpressionRejection;
|
|
7769
|
+
let extraFloat = false;
|
|
7770
|
+
let extraInteger = false;
|
|
7771
|
+
if (result.left?.fromLeft) extraFloat = true;
|
|
7772
|
+
if (result.right?.fromLeft) extraFloat = true;
|
|
7773
|
+
if (!intCenter || !isPointRange(result.center)) extraFloat = true;
|
|
7774
|
+
if (leftIntRange) extraInteger = true;
|
|
7775
|
+
if (rightIntRange) extraInteger = true;
|
|
7776
|
+
if (extraFloat && extraInteger) return ExpressionIntersection;
|
|
7777
|
+
if (extraFloat) return ExpressionContaining;
|
|
7778
|
+
if (extraInteger) return ExpressionContainedBy;
|
|
7779
|
+
return ExpressionEquals;
|
|
7780
|
+
}
|
|
7781
|
+
function pickRange(schema) {
|
|
7782
|
+
let point1;
|
|
7783
|
+
let point2;
|
|
7784
|
+
if (schema.exclusiveMinimum !== void 0) point1 = {
|
|
7785
|
+
num: schema.exclusiveMinimum,
|
|
7786
|
+
exclusive: true
|
|
7787
|
+
};
|
|
7788
|
+
else if (schema.minimum !== void 0) point1 = {
|
|
7789
|
+
num: schema.minimum,
|
|
8043
7790
|
exclusive: false
|
|
8044
|
-
}]);
|
|
8045
|
-
let leftItem;
|
|
8046
|
-
let rightItem;
|
|
8047
|
-
let intersectionItem;
|
|
8048
|
-
if (left) leftItem = {
|
|
8049
|
-
min: left.range[0].num,
|
|
8050
|
-
max: left.range[1].num,
|
|
8051
|
-
isFrom1: left.fromLeft
|
|
8052
7791
|
};
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
isFrom1: right.fromLeft
|
|
7792
|
+
else point1 = {
|
|
7793
|
+
num: Number.NEGATIVE_INFINITY,
|
|
7794
|
+
exclusive: true
|
|
8057
7795
|
};
|
|
8058
|
-
if (
|
|
8059
|
-
|
|
8060
|
-
|
|
7796
|
+
if (schema.exclusiveMaximum !== void 0) point2 = {
|
|
7797
|
+
num: schema.exclusiveMaximum,
|
|
7798
|
+
exclusive: true
|
|
8061
7799
|
};
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
intersection: intersectionItem
|
|
7800
|
+
else if (schema.maximum !== void 0) point2 = {
|
|
7801
|
+
num: schema.maximum,
|
|
7802
|
+
exclusive: false
|
|
8066
7803
|
};
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
|
|
7804
|
+
else point2 = {
|
|
7805
|
+
num: Number.POSITIVE_INFINITY,
|
|
7806
|
+
exclusive: true
|
|
7807
|
+
};
|
|
7808
|
+
return [point1, point2];
|
|
7809
|
+
}
|
|
7810
|
+
function unwrapAndCutRange(side, multipleOf) {
|
|
7811
|
+
if (!side) return;
|
|
7812
|
+
if (side.fromLeft) return;
|
|
7813
|
+
return cutRange(side.range, multipleOf);
|
|
7814
|
+
}
|
|
7815
|
+
//#endregion
|
|
7816
|
+
//#region src/json-schema-subset/checker/numeric/integer.ts
|
|
7817
|
+
function calculateInteger(schema1, schema2) {
|
|
7818
|
+
const integer1 = normalizeInteger(schema1);
|
|
7819
|
+
const integer2 = normalizeInteger(schema2);
|
|
7820
|
+
if (!integer1 && !integer2) return ExpressionEquals;
|
|
7821
|
+
if (!integer1) return ExpressionContainedBy;
|
|
7822
|
+
if (!integer2) return ExpressionContaining;
|
|
7823
|
+
const { range: range1, multipleOf: multipleOf1 } = integer1;
|
|
7824
|
+
const { range: range2, multipleOf: multipleOf2 } = integer2;
|
|
7825
|
+
const result = splitRange$3(range1, range2);
|
|
7826
|
+
let centerRange;
|
|
7827
|
+
let lcm = 0;
|
|
7828
|
+
if (result.center) {
|
|
7829
|
+
lcm = getLCM(multipleOf1, multipleOf2);
|
|
7830
|
+
centerRange = cutRange(result.center, lcm);
|
|
8075
7831
|
}
|
|
8076
|
-
if (
|
|
8077
|
-
|
|
8078
|
-
|
|
7832
|
+
if (!centerRange) return ExpressionRejection;
|
|
7833
|
+
let extraLeft = false;
|
|
7834
|
+
let extraRight = false;
|
|
7835
|
+
const { left, right } = result;
|
|
7836
|
+
if (left && cutRange(left.range, left.fromLeft ? multipleOf1 : multipleOf2)) {
|
|
7837
|
+
if (left.fromLeft) extraLeft = true;
|
|
7838
|
+
else extraRight = true;
|
|
8079
7839
|
}
|
|
8080
|
-
if (
|
|
8081
|
-
|
|
8082
|
-
|
|
8083
|
-
|
|
7840
|
+
if (right && cutRange(right.range, right.fromLeft ? multipleOf1 : multipleOf2)) {
|
|
7841
|
+
if (right.fromLeft) extraLeft = true;
|
|
7842
|
+
else extraRight = true;
|
|
7843
|
+
}
|
|
7844
|
+
extraLeft = extraLeft || hasExtraIntegersOnCenter(integer1, centerRange, lcm);
|
|
7845
|
+
extraRight = extraRight || hasExtraIntegersOnCenter(integer2, centerRange, lcm);
|
|
7846
|
+
if (extraLeft && extraRight) return ExpressionIntersection;
|
|
7847
|
+
if (extraLeft) return ExpressionContaining;
|
|
7848
|
+
if (extraRight) return ExpressionContainedBy;
|
|
7849
|
+
return ExpressionEquals;
|
|
7850
|
+
}
|
|
7851
|
+
function hasExtraIntegersOnCenter({ range, multipleOf }, lcmCenterRange, lcm) {
|
|
7852
|
+
const result = splitRange$3(range, lcmCenterRange);
|
|
7853
|
+
if (cutRange(result.left?.range, multipleOf)) return true;
|
|
7854
|
+
if (cutRange(result.right?.range, multipleOf)) return true;
|
|
7855
|
+
const center = cutRange(result.center, multipleOf);
|
|
7856
|
+
if (!center) return false;
|
|
7857
|
+
const lcmCenterLength = rangeLength(lcmCenterRange);
|
|
7858
|
+
if (rangeLength(center) > lcmCenterLength) return true;
|
|
7859
|
+
if (lcmCenterLength === 1) return false;
|
|
7860
|
+
if (multipleOf < lcm) return true;
|
|
7861
|
+
return false;
|
|
7862
|
+
}
|
|
7863
|
+
/** Returns the least common multiple. */
|
|
7864
|
+
function getLCM(a, b) {
|
|
7865
|
+
return a * b / getGCD(a, b);
|
|
7866
|
+
}
|
|
7867
|
+
/** @returns The greatest common divisor. */
|
|
7868
|
+
function getGCD(a, b) {
|
|
7869
|
+
if (a === 0) return b;
|
|
7870
|
+
return getGCD(b % a, a);
|
|
7871
|
+
}
|
|
7872
|
+
function rangeLength(range) {
|
|
7873
|
+
if (!range) return 0;
|
|
7874
|
+
const [point1, point2] = range;
|
|
7875
|
+
return point2.num - point1.num + 1;
|
|
8084
7876
|
}
|
|
8085
7877
|
//#endregion
|
|
8086
|
-
//#region src/json-schema-subset/checker/
|
|
8087
|
-
|
|
8088
|
-
|
|
8089
|
-
|
|
8090
|
-
|
|
8091
|
-
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
const
|
|
8098
|
-
if (
|
|
8099
|
-
|
|
8100
|
-
|
|
8101
|
-
|
|
8102
|
-
|
|
8103
|
-
|
|
8104
|
-
const
|
|
8105
|
-
|
|
8106
|
-
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
|
|
8112
|
-
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
|
|
8116
|
-
|
|
8117
|
-
|
|
8118
|
-
|
|
8119
|
-
|
|
8120
|
-
|
|
8121
|
-
|
|
8122
|
-
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8126
|
-
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
|
|
8130
|
-
|
|
8131
|
-
|
|
7878
|
+
//#region src/json-schema-subset/checker/numeric/checker.ts
|
|
7879
|
+
function calculateNumeric(schema1, schema2) {
|
|
7880
|
+
if (isUndefinedNumber(schema1) || isUndefinedNumber(schema2)) return ExpressionAny;
|
|
7881
|
+
const isFloat1 = isFloat(schema1);
|
|
7882
|
+
const isFloat2 = isFloat(schema2);
|
|
7883
|
+
if (isFloat1 && isFloat2) return calculateFloat(schema1, schema2);
|
|
7884
|
+
else if (isFloat1) return calculateFloatAndInteger(schema1, schema2);
|
|
7885
|
+
else if (isFloat2) return swap(calculateFloatAndInteger(schema2, schema1));
|
|
7886
|
+
else return calculateInteger(schema1, schema2);
|
|
7887
|
+
}
|
|
7888
|
+
function isUndefinedNumber(schema) {
|
|
7889
|
+
const { multipleOf } = schema;
|
|
7890
|
+
if (multipleOf === void 0) return false;
|
|
7891
|
+
if (!Number.isInteger(multipleOf)) return true;
|
|
7892
|
+
if (multipleOf < 0) return true;
|
|
7893
|
+
return false;
|
|
7894
|
+
}
|
|
7895
|
+
function isFloat(schema) {
|
|
7896
|
+
const { multipleOf } = schema;
|
|
7897
|
+
if (multipleOf !== void 0 && Number.isInteger(multipleOf)) return false;
|
|
7898
|
+
if (schema.type === "integer") return false;
|
|
7899
|
+
return true;
|
|
7900
|
+
}
|
|
7901
|
+
//#endregion
|
|
7902
|
+
//#region src/json-schema-subset/checker/object.ts
|
|
7903
|
+
var splitRange$1 = createRangeSplitter(0);
|
|
7904
|
+
var quantum = makeQuantum([
|
|
7905
|
+
"hasCommonInRequired",
|
|
7906
|
+
"hasCommonOutRequired",
|
|
7907
|
+
"hasExtra1",
|
|
7908
|
+
"hasExtra2",
|
|
7909
|
+
"hasRejection"
|
|
7910
|
+
]);
|
|
7911
|
+
function calculateObject(context, schema1, schema2) {
|
|
7912
|
+
if (isPropertiesCountCannotMatch(schema1, schema2)) return ExpressionRejection;
|
|
7913
|
+
const splitRequiredResult = splitRequired(schema1, schema2);
|
|
7914
|
+
if (!splitRequiredResult) return ExpressionRejection;
|
|
7915
|
+
const getProperty1 = createPropertySchemaGetter(schema1);
|
|
7916
|
+
const getProperty2 = createPropertySchemaGetter(schema2);
|
|
7917
|
+
const calculateKey = (key) => {
|
|
7918
|
+
const propertySchema1 = getProperty1(key);
|
|
7919
|
+
const propertySchema2 = getProperty2(key);
|
|
7920
|
+
if (areNotBothNever(propertySchema1, propertySchema2)) return context.calculate(propertySchema1, propertySchema2);
|
|
7921
|
+
else return 0;
|
|
7922
|
+
};
|
|
7923
|
+
const { commonRequired, extraRequired1, extraRequired2 } = splitRequiredResult;
|
|
7924
|
+
const quantumVariable = quantum.variable({});
|
|
7925
|
+
for (const requiredKey of [...commonRequired].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateCommonRequiredExpression);
|
|
7926
|
+
for (const requiredKey of [...extraRequired1].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateExtraRequiredExpression1);
|
|
7927
|
+
for (const requiredKey of [...extraRequired2].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateExtraRequiredExpression2);
|
|
7928
|
+
const { hasOptional1, hasOptional2 } = splitRequiredResult;
|
|
7929
|
+
if (hasOptional1 || hasOptional2) {
|
|
7930
|
+
const calculator = calculateOptionalExpression(hasOptional1, hasOptional2);
|
|
7931
|
+
for (const optionalKey of [...getOptionalKeys(schema1, schema2)].toSorted()) {
|
|
7932
|
+
const expression = calculateKey(optionalKey);
|
|
7933
|
+
if (expression !== 0) quantumVariable.push(expression, calculator);
|
|
7934
|
+
}
|
|
7935
|
+
const additionalProperties1 = schema1.additionalProperties ?? ANY;
|
|
7936
|
+
const additionalProperties2 = schema2.additionalProperties ?? ANY;
|
|
7937
|
+
if (areNotBothNever(additionalProperties1, additionalProperties2)) {
|
|
7938
|
+
const expression = context.calculate(additionalProperties1, additionalProperties2);
|
|
7939
|
+
quantumVariable.push(expression, calculator);
|
|
7940
|
+
}
|
|
8132
7941
|
}
|
|
8133
7942
|
quantumVariable.update((variable) => {
|
|
8134
|
-
|
|
8135
|
-
|
|
8136
|
-
|
|
8137
|
-
break;
|
|
8138
|
-
case ExpressionSingleResult.ContainedBy:
|
|
8139
|
-
variable.hasExtra2 = true;
|
|
8140
|
-
break;
|
|
8141
|
-
case ExpressionSingleResult.Intersection:
|
|
8142
|
-
variable.hasExtra1 = true;
|
|
8143
|
-
variable.hasExtra2 = true;
|
|
8144
|
-
}
|
|
8145
|
-
if (schema1.uniqueItems && !schema2.uniqueItems && (schema2.maxItems ?? Number.POSITIVE_INFINITY) > 1) variable.hasExtra2 = true;
|
|
8146
|
-
else if (!schema1.uniqueItems && schema2.uniqueItems && (schema1.maxItems ?? Number.POSITIVE_INFINITY) > 1) variable.hasExtra1 = true;
|
|
8147
|
-
if (schema1.maxItems === 0 || schema2.maxItems === 0) {
|
|
8148
|
-
variable.hasCommon = true;
|
|
8149
|
-
if (schema1.maxItems !== 0) variable.hasExtra1 = true;
|
|
8150
|
-
if (schema2.maxItems !== 0) variable.hasExtra2 = true;
|
|
7943
|
+
if (!variable.hasRejection) {
|
|
7944
|
+
if (extraRequired1.size > 0) variable.hasExtra2 = true;
|
|
7945
|
+
if (extraRequired2.size > 0) variable.hasExtra1 = true;
|
|
8151
7946
|
}
|
|
8152
7947
|
});
|
|
7948
|
+
const { requiredKeysCount } = splitRequiredResult;
|
|
8153
7949
|
let expression = 0;
|
|
8154
|
-
for (const { hasExtra1, hasExtra2,
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
else expression |= ExpressionEquals;
|
|
8162
|
-
}
|
|
7950
|
+
for (const { hasExtra1, hasExtra2, hasCommonInRequired, hasCommonOutRequired, hasRejection } of quantumVariable) if (!hasCommonInRequired && requiredKeysCount > 0) expression |= ExpressionRejection;
|
|
7951
|
+
else if (!hasCommonOutRequired && requiredKeysCount === 0) expression |= ExpressionRejection;
|
|
7952
|
+
else if (hasRejection) expression |= ExpressionRejection;
|
|
7953
|
+
else if (hasExtra1 && hasExtra2) expression |= ExpressionIntersection;
|
|
7954
|
+
else if (hasExtra1) expression |= ExpressionContaining;
|
|
7955
|
+
else if (hasExtra2) expression |= ExpressionContainedBy;
|
|
7956
|
+
else expression |= ExpressionEquals;
|
|
8163
7957
|
return expression;
|
|
8164
7958
|
}
|
|
8165
|
-
function
|
|
8166
|
-
|
|
8167
|
-
else return [[], items ?? ANY];
|
|
7959
|
+
function isPropertiesCountCannotMatch(schema1, schema2) {
|
|
7960
|
+
return toExpressionSingleResult(splitRange$1(schema1.minProperties, schema1.maxProperties, schema2.minProperties, schema2.maxProperties)) === ExpressionSingleResult.Rejection;
|
|
8168
7961
|
}
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
const
|
|
8173
|
-
|
|
8174
|
-
|
|
8175
|
-
|
|
8176
|
-
|
|
8177
|
-
|
|
7962
|
+
function splitRequired(schema1, schema2) {
|
|
7963
|
+
const extraRequired1 = new Set(schema1.required);
|
|
7964
|
+
const extraRequired2 = new Set(schema2.required);
|
|
7965
|
+
const commonRequired = /* @__PURE__ */ new Set();
|
|
7966
|
+
const wholeRequired = /* @__PURE__ */ new Set();
|
|
7967
|
+
const requiredCount1 = extraRequired1.size;
|
|
7968
|
+
const requiredCount2 = extraRequired2.size;
|
|
7969
|
+
for (const key of extraRequired1) {
|
|
7970
|
+
if (extraRequired2.has(key)) commonRequired.add(key);
|
|
7971
|
+
wholeRequired.add(key);
|
|
7972
|
+
}
|
|
7973
|
+
for (const key of extraRequired2) {
|
|
7974
|
+
if (extraRequired1.has(key)) commonRequired.add(key);
|
|
7975
|
+
wholeRequired.add(key);
|
|
7976
|
+
}
|
|
7977
|
+
const requiredKeysCount = wholeRequired.size;
|
|
7978
|
+
for (const key of commonRequired) {
|
|
7979
|
+
extraRequired1.delete(key);
|
|
7980
|
+
extraRequired2.delete(key);
|
|
7981
|
+
}
|
|
7982
|
+
const maxProperties1 = schema1.maxProperties ?? Number.MAX_SAFE_INTEGER;
|
|
7983
|
+
const maxProperties2 = schema2.maxProperties ?? Number.MAX_SAFE_INTEGER;
|
|
7984
|
+
if (requiredKeysCount > maxProperties1 || requiredKeysCount > maxProperties2) return null;
|
|
7985
|
+
return {
|
|
7986
|
+
requiredKeysCount,
|
|
7987
|
+
extraRequired1,
|
|
7988
|
+
extraRequired2,
|
|
7989
|
+
commonRequired,
|
|
7990
|
+
hasOptional1: maxProperties1 > requiredCount1,
|
|
7991
|
+
hasOptional2: maxProperties2 > requiredCount2
|
|
8178
7992
|
};
|
|
8179
7993
|
}
|
|
8180
|
-
function
|
|
8181
|
-
const
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
const
|
|
8186
|
-
|
|
8187
|
-
if (
|
|
8188
|
-
|
|
7994
|
+
function getOptionalKeys(schema1, schema2) {
|
|
7995
|
+
const optionalKeys = new Set(schema1.required);
|
|
7996
|
+
const properties1 = schema1.properties;
|
|
7997
|
+
const properties2 = schema2.properties;
|
|
7998
|
+
const required1 = schema1.required;
|
|
7999
|
+
const required2 = schema2.required;
|
|
8000
|
+
if (properties1) for (const key in properties1) optionalKeys.add(key);
|
|
8001
|
+
if (properties2) for (const key in properties2) optionalKeys.add(key);
|
|
8002
|
+
if (required1) for (const key of required1) optionalKeys.delete(key);
|
|
8003
|
+
if (required2) for (const key of required2) optionalKeys.delete(key);
|
|
8004
|
+
return optionalKeys;
|
|
8189
8005
|
}
|
|
8190
|
-
|
|
8191
|
-
|
|
8192
|
-
|
|
8193
|
-
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8006
|
+
var calculateCommonRequiredExpression = (singleExpression, variable) => {
|
|
8007
|
+
switch (singleExpression) {
|
|
8008
|
+
case ExpressionSingleResult.Equals:
|
|
8009
|
+
variable.hasCommonInRequired = true;
|
|
8010
|
+
break;
|
|
8011
|
+
case ExpressionSingleResult.Containing:
|
|
8012
|
+
variable.hasExtra1 = true;
|
|
8013
|
+
variable.hasCommonInRequired = true;
|
|
8014
|
+
break;
|
|
8015
|
+
case ExpressionSingleResult.ContainedBy:
|
|
8016
|
+
variable.hasExtra2 = true;
|
|
8017
|
+
variable.hasCommonInRequired = true;
|
|
8018
|
+
break;
|
|
8019
|
+
case ExpressionSingleResult.Intersection:
|
|
8020
|
+
variable.hasExtra1 = true;
|
|
8021
|
+
variable.hasExtra2 = true;
|
|
8022
|
+
variable.hasCommonInRequired = true;
|
|
8023
|
+
break;
|
|
8024
|
+
case ExpressionSingleResult.Rejection: variable.hasRejection = true;
|
|
8202
8025
|
}
|
|
8203
|
-
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
|
|
8026
|
+
};
|
|
8027
|
+
var calculateExtraRequiredExpression1 = (singleExpression, variable) => {
|
|
8028
|
+
switch (singleExpression) {
|
|
8029
|
+
case ExpressionSingleResult.Equals:
|
|
8030
|
+
case ExpressionSingleResult.ContainedBy:
|
|
8031
|
+
variable.hasCommonInRequired = true;
|
|
8032
|
+
break;
|
|
8033
|
+
case ExpressionSingleResult.Intersection:
|
|
8034
|
+
case ExpressionSingleResult.Containing:
|
|
8035
|
+
variable.hasExtra1 = true;
|
|
8036
|
+
variable.hasCommonInRequired = true;
|
|
8037
|
+
break;
|
|
8038
|
+
case ExpressionSingleResult.Rejection: variable.hasRejection = true;
|
|
8207
8039
|
}
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
|
|
8214
|
-
|
|
8215
|
-
|
|
8216
|
-
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8220
|
-
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
|
|
8224
|
-
|
|
8225
|
-
|
|
8226
|
-
|
|
8227
|
-
|
|
8040
|
+
};
|
|
8041
|
+
var calculateExtraRequiredExpression2 = (singleExpression, variable) => {
|
|
8042
|
+
switch (singleExpression) {
|
|
8043
|
+
case ExpressionSingleResult.Equals:
|
|
8044
|
+
case ExpressionSingleResult.Containing:
|
|
8045
|
+
variable.hasCommonInRequired = true;
|
|
8046
|
+
break;
|
|
8047
|
+
case ExpressionSingleResult.Intersection:
|
|
8048
|
+
case ExpressionSingleResult.ContainedBy:
|
|
8049
|
+
variable.hasExtra2 = true;
|
|
8050
|
+
variable.hasCommonInRequired = true;
|
|
8051
|
+
break;
|
|
8052
|
+
case ExpressionSingleResult.Rejection: variable.hasRejection = true;
|
|
8053
|
+
}
|
|
8054
|
+
};
|
|
8055
|
+
var calculateOptionalExpression = (hasOptional1, hasOptional2) => (singleExpression, variable) => {
|
|
8056
|
+
if (variable.hasRejection) return;
|
|
8057
|
+
let foundExtraPossibility1 = false;
|
|
8058
|
+
let foundExtraPossibility2 = false;
|
|
8059
|
+
let foundCommonPossibility = false;
|
|
8060
|
+
switch (singleExpression) {
|
|
8061
|
+
case ExpressionSingleResult.Equals:
|
|
8062
|
+
foundCommonPossibility = true;
|
|
8063
|
+
break;
|
|
8064
|
+
case ExpressionSingleResult.Containing:
|
|
8065
|
+
foundExtraPossibility1 = true;
|
|
8066
|
+
foundCommonPossibility = true;
|
|
8067
|
+
break;
|
|
8068
|
+
case ExpressionSingleResult.ContainedBy:
|
|
8069
|
+
foundExtraPossibility2 = true;
|
|
8070
|
+
foundCommonPossibility = true;
|
|
8071
|
+
break;
|
|
8072
|
+
case ExpressionSingleResult.Intersection:
|
|
8073
|
+
foundExtraPossibility1 = true;
|
|
8074
|
+
foundExtraPossibility2 = true;
|
|
8075
|
+
foundCommonPossibility = true;
|
|
8076
|
+
break;
|
|
8077
|
+
case ExpressionSingleResult.Rejection:
|
|
8078
|
+
foundExtraPossibility1 = true;
|
|
8079
|
+
foundExtraPossibility2 = true;
|
|
8228
8080
|
}
|
|
8229
|
-
if (
|
|
8230
|
-
if (
|
|
8231
|
-
if (
|
|
8232
|
-
|
|
8233
|
-
|
|
8234
|
-
|
|
8235
|
-
|
|
8236
|
-
|
|
8237
|
-
|
|
8238
|
-
|
|
8081
|
+
if (hasOptional1 && foundExtraPossibility1) variable.hasExtra1 = true;
|
|
8082
|
+
if (hasOptional2 && foundExtraPossibility2) variable.hasExtra2 = true;
|
|
8083
|
+
if (hasOptional1 && hasOptional2 && foundCommonPossibility) variable.hasCommonOutRequired = true;
|
|
8084
|
+
};
|
|
8085
|
+
function createPropertySchemaGetter(schema) {
|
|
8086
|
+
const properties = schema.properties;
|
|
8087
|
+
const propertyNames = schema.propertyNames;
|
|
8088
|
+
const additionalProperties = schema.additionalProperties;
|
|
8089
|
+
const patternProperties = [];
|
|
8090
|
+
if (schema.patternProperties) for (const pattern in schema.patternProperties) {
|
|
8091
|
+
const valueSchema = schema.patternProperties[pattern];
|
|
8092
|
+
const regExp = new RegExp(pattern, "i");
|
|
8093
|
+
patternProperties.push({
|
|
8094
|
+
pattern: regExp,
|
|
8095
|
+
schema: valueSchema
|
|
8096
|
+
});
|
|
8097
|
+
}
|
|
8098
|
+
return (key) => {
|
|
8099
|
+
if (propertyNames && valid(propertyNames, key) === ValidResult.Invalid) return NEVER;
|
|
8100
|
+
for (const { pattern, schema: patternSchema } of patternProperties) if (pattern.test(key)) return patternSchema;
|
|
8101
|
+
const propertySchema = (properties && properties[key]) ?? additionalProperties;
|
|
8102
|
+
if (!propertySchema) return ANY;
|
|
8103
|
+
return propertySchema;
|
|
8104
|
+
};
|
|
8239
8105
|
}
|
|
8240
|
-
function
|
|
8241
|
-
|
|
8242
|
-
|
|
8106
|
+
function areNotBothNever(schema1, schema2) {
|
|
8107
|
+
const kind1 = getKind(schema1);
|
|
8108
|
+
const kind2 = getKind(schema2);
|
|
8109
|
+
return kind1 !== CompiledKind.Never || kind2 !== CompiledKind.Never;
|
|
8243
8110
|
}
|
|
8244
8111
|
//#endregion
|
|
8245
|
-
//#region src/json-schema-subset/checker/
|
|
8246
|
-
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
|
|
8251
|
-
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
if (Array.isArray(object1)) {
|
|
8268
|
-
if (!Array.isArray(object2)) return false;
|
|
8269
|
-
if (object1.length !== object2.length) return false;
|
|
8270
|
-
for (const [i, value1Element] of object1.entries()) if (!isValueEquals(value1Element, object2[i])) return false;
|
|
8271
|
-
} else {
|
|
8272
|
-
if (Array.isArray(object2)) return false;
|
|
8273
|
-
for (const key in object1) {
|
|
8274
|
-
if (!(key in object2)) return false;
|
|
8275
|
-
if (!isValueEquals(Reflect.get(object1, key), Reflect.get(object2, key))) return false;
|
|
8276
|
-
}
|
|
8277
|
-
for (const key in object2) if (!(key in object1)) return false;
|
|
8278
|
-
}
|
|
8279
|
-
return true;
|
|
8280
|
-
}
|
|
8281
|
-
function isValueEquals(value1, value2) {
|
|
8282
|
-
if (value1 === value2) return true;
|
|
8283
|
-
if (value1 === null) return false;
|
|
8284
|
-
if (typeof value1 !== "object") return false;
|
|
8285
|
-
if (typeof value1 !== typeof value2) return false;
|
|
8286
|
-
if (isCompiledSchema(value1) && isCompiledSchema(value2)) return isCompiledSchemaEquals(value1, value2);
|
|
8287
|
-
return isObjectLikeEquals(value1, value2);
|
|
8112
|
+
//#region src/json-schema-subset/checker/string.ts
|
|
8113
|
+
var splitRange = createRangeSplitter(0);
|
|
8114
|
+
function calculateString(schema1, schema2) {
|
|
8115
|
+
if (schema2.format && !schema1.format) return ExpressionContaining;
|
|
8116
|
+
if (schema1.format && schema2.format && schema1.format !== schema2.format) return ExpressionAny;
|
|
8117
|
+
const expression = toExpressionSingleResult(splitRange(schema1.minLength, schema1.maxLength, schema2.minLength, schema2.maxLength));
|
|
8118
|
+
const hasPattern1 = !!schema1.pattern;
|
|
8119
|
+
const hasPattern2 = !!schema2.pattern;
|
|
8120
|
+
switch (expression) {
|
|
8121
|
+
case ExpressionSingleResult.Rejection: return ExpressionRejection;
|
|
8122
|
+
case ExpressionSingleResult.Containing: return hasPattern1 ? ExpressionAny : ExpressionContaining;
|
|
8123
|
+
case ExpressionSingleResult.ContainedBy: return hasPattern2 ? ExpressionAny : ExpressionContainedBy;
|
|
8124
|
+
case ExpressionSingleResult.Equals:
|
|
8125
|
+
if (hasPattern1 && hasPattern2) return schema1.pattern === schema2.pattern ? ExpressionEquals : ExpressionAny;
|
|
8126
|
+
if (hasPattern1) return ExpressionEquals | ExpressionContainedBy;
|
|
8127
|
+
if (hasPattern2) return ExpressionEquals | ExpressionContaining;
|
|
8128
|
+
return ExpressionEquals;
|
|
8129
|
+
case ExpressionSingleResult.Intersection:
|
|
8130
|
+
if (hasPattern1 && hasPattern2) return ExpressionAny;
|
|
8131
|
+
if (hasPattern1) return ExpressionIntersection | ExpressionRejection | ExpressionContainedBy;
|
|
8132
|
+
if (hasPattern2) return ExpressionIntersection | ExpressionRejection | ExpressionContaining;
|
|
8133
|
+
return ExpressionIntersection;
|
|
8288
8134
|
}
|
|
8289
|
-
return isSchemaEquals;
|
|
8290
8135
|
}
|
|
8291
8136
|
//#endregion
|
|
8292
|
-
//#region src/json-schema-subset/checker/
|
|
8293
|
-
function
|
|
8294
|
-
const
|
|
8295
|
-
const
|
|
8296
|
-
const
|
|
8297
|
-
|
|
8137
|
+
//#region src/json-schema-subset/checker/checker.ts
|
|
8138
|
+
function checkWithResult(extendsContext, schema1, schema2) {
|
|
8139
|
+
const context = {};
|
|
8140
|
+
const errorPaths = [];
|
|
8141
|
+
const calculate = wrapSchemaCalculatorWithCache(calculator(extendsContext, context));
|
|
8142
|
+
const describe = describer();
|
|
8143
|
+
const equals = schemaEqualsChecker(extendsContext);
|
|
8144
|
+
context.isEquals = wrapEqualsCheckerWithCache(isDeepEquals);
|
|
8145
|
+
context.calculate = expression$1({
|
|
8146
|
+
describe,
|
|
8147
|
+
equals,
|
|
8148
|
+
calculate,
|
|
8149
|
+
observeCalculation: (left, right, result, swapped) => {
|
|
8150
|
+
if (!isDecisiveMismatch(swapped ? swap(result) : result)) return;
|
|
8151
|
+
const errorPath = swapped ? findMismatchPath(right, left) : findMismatchPath(left, right);
|
|
8152
|
+
if (errorPath) errorPaths.push(errorPath);
|
|
8153
|
+
}
|
|
8154
|
+
});
|
|
8155
|
+
Object.freeze(context);
|
|
8156
|
+
const comparisonExpression = context.calculate(schema1, schema2);
|
|
8298
8157
|
return {
|
|
8299
|
-
|
|
8300
|
-
|
|
8158
|
+
errorPath: errorPaths[0],
|
|
8159
|
+
expression: comparisonExpression
|
|
8301
8160
|
};
|
|
8302
8161
|
}
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
|
|
8306
|
-
|
|
8307
|
-
|
|
8308
|
-
|
|
8309
|
-
|
|
8310
|
-
|
|
8311
|
-
|
|
8312
|
-
|
|
8313
|
-
|
|
8314
|
-
|
|
8315
|
-
|
|
8316
|
-
|
|
8317
|
-
|
|
8318
|
-
|
|
8319
|
-
|
|
8162
|
+
var describer = () => (schema) => {
|
|
8163
|
+
let description;
|
|
8164
|
+
switch (getKind(schema)) {
|
|
8165
|
+
case CompiledKind.Not:
|
|
8166
|
+
description = {
|
|
8167
|
+
kind: ExpressionKind.Not,
|
|
8168
|
+
expression: schema.not
|
|
8169
|
+
};
|
|
8170
|
+
break;
|
|
8171
|
+
case CompiledKind.Combination:
|
|
8172
|
+
if ("allOf" in schema) description = {
|
|
8173
|
+
kind: ExpressionKind.AllOf,
|
|
8174
|
+
expressions: rejectInSchemaList(schema.allOf, CompiledKind.Any)
|
|
8175
|
+
};
|
|
8176
|
+
else if ("anyOf" in schema) description = {
|
|
8177
|
+
kind: ExpressionKind.AnyOf,
|
|
8178
|
+
expressions: rejectInSchemaList(schema.anyOf, CompiledKind.Never)
|
|
8179
|
+
};
|
|
8180
|
+
else if ("oneOf" in schema) description = {
|
|
8181
|
+
kind: ExpressionKind.OneOf,
|
|
8182
|
+
expressions: rejectInSchemaList(schema.oneOf, CompiledKind.Never)
|
|
8183
|
+
};
|
|
8184
|
+
else throw new Error(`invalid combination JSON Schema: ${JSON.stringify(schema)}`);
|
|
8185
|
+
break;
|
|
8186
|
+
default: description = { kind: ExpressionKind.Leaf };
|
|
8320
8187
|
}
|
|
8321
|
-
return
|
|
8322
|
-
|
|
8323
|
-
|
|
8324
|
-
|
|
8325
|
-
|
|
8326
|
-
|
|
8327
|
-
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
return Math.ceil(float / multipleOf) * multipleOf;
|
|
8331
|
-
}
|
|
8332
|
-
function previousInteger(float, multipleOf) {
|
|
8333
|
-
return Math.floor(float / multipleOf) * multipleOf;
|
|
8334
|
-
}
|
|
8335
|
-
//#endregion
|
|
8336
|
-
//#region src/json-schema-subset/checker/numeric/float.ts
|
|
8337
|
-
function calculateFloat(schema1, schema2) {
|
|
8338
|
-
const { left, right, center } = splitRange$3(pickRange(schema1), pickRange(schema2));
|
|
8339
|
-
if (!center) return ExpressionRejection;
|
|
8340
|
-
let extraLeft = false;
|
|
8341
|
-
let extraRight = false;
|
|
8342
|
-
if (left) {
|
|
8343
|
-
if (left.fromLeft) extraLeft = true;
|
|
8344
|
-
else extraRight = true;
|
|
8188
|
+
return description;
|
|
8189
|
+
};
|
|
8190
|
+
var calculator = (extendsContext, context) => (schema1, schema2) => {
|
|
8191
|
+
const kind1 = getKind(schema1);
|
|
8192
|
+
const kind2 = getKind(schema2);
|
|
8193
|
+
if (kind1 === CompiledKind.Extends || kind2 === CompiledKind.Extends) return extendsContext.calculate(schema1, schema2);
|
|
8194
|
+
switch (kind1) {
|
|
8195
|
+
case CompiledKind.Any: return kind2 === CompiledKind.Any ? ExpressionEquals : ExpressionContaining;
|
|
8196
|
+
case CompiledKind.Never: return kind2 === CompiledKind.Never ? ExpressionEquals : ExpressionContainedBy;
|
|
8345
8197
|
}
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
|
|
8198
|
+
switch (kind2) {
|
|
8199
|
+
case CompiledKind.Any: return ExpressionContainedBy;
|
|
8200
|
+
case CompiledKind.Never: return ExpressionContaining;
|
|
8349
8201
|
}
|
|
8350
|
-
if (
|
|
8351
|
-
if (
|
|
8352
|
-
if (
|
|
8353
|
-
return
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
|
|
8361
|
-
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
if (result.left?.fromLeft) extraFloat = true;
|
|
8367
|
-
if (result.right?.fromLeft) extraFloat = true;
|
|
8368
|
-
if (!intCenter || !isPointRange(result.center)) extraFloat = true;
|
|
8369
|
-
if (leftIntRange) extraInteger = true;
|
|
8370
|
-
if (rightIntRange) extraInteger = true;
|
|
8371
|
-
if (extraFloat && extraInteger) return ExpressionIntersection;
|
|
8372
|
-
if (extraFloat) return ExpressionContaining;
|
|
8373
|
-
if (extraInteger) return ExpressionContainedBy;
|
|
8374
|
-
return ExpressionEquals;
|
|
8202
|
+
if (kind1 === CompiledKind.EnumOrConst && kind2 === CompiledKind.EnumOrConst) return calculateEnumAndEnum(context, schema1, schema2);
|
|
8203
|
+
if (kind1 === CompiledKind.EnumOrConst) return calculateEnumAndSchema(schema1, schema2);
|
|
8204
|
+
if (kind2 === CompiledKind.EnumOrConst) return swap(calculateEnumAndSchema(schema2, schema1));
|
|
8205
|
+
if (kind1 !== kind2) return ExpressionRejection;
|
|
8206
|
+
switch (kind1) {
|
|
8207
|
+
case CompiledKind.Null: return ExpressionEquals;
|
|
8208
|
+
case CompiledKind.Numeric: return calculateNumeric(schema1, schema2);
|
|
8209
|
+
case CompiledKind.String: return calculateString(schema1, schema2);
|
|
8210
|
+
case CompiledKind.Boolean: return ExpressionEquals;
|
|
8211
|
+
case CompiledKind.Object: return calculateObject(context, schema1, schema2);
|
|
8212
|
+
case CompiledKind.Array: return calculateArray(context, schema1, schema2);
|
|
8213
|
+
default: throw new Error(`invalid kind ${kind1}`);
|
|
8214
|
+
}
|
|
8215
|
+
};
|
|
8216
|
+
function rejectInSchemaList(schemaList, kind) {
|
|
8217
|
+
return schemaList.filter((e) => getKind(e) !== kind);
|
|
8375
8218
|
}
|
|
8376
|
-
function
|
|
8377
|
-
|
|
8378
|
-
let point2;
|
|
8379
|
-
if (schema.exclusiveMinimum !== void 0) point1 = {
|
|
8380
|
-
num: schema.exclusiveMinimum,
|
|
8381
|
-
exclusive: true
|
|
8382
|
-
};
|
|
8383
|
-
else if (schema.minimum !== void 0) point1 = {
|
|
8384
|
-
num: schema.minimum,
|
|
8385
|
-
exclusive: false
|
|
8386
|
-
};
|
|
8387
|
-
else point1 = {
|
|
8388
|
-
num: Number.NEGATIVE_INFINITY,
|
|
8389
|
-
exclusive: true
|
|
8390
|
-
};
|
|
8391
|
-
if (schema.exclusiveMaximum !== void 0) point2 = {
|
|
8392
|
-
num: schema.exclusiveMaximum,
|
|
8393
|
-
exclusive: true
|
|
8394
|
-
};
|
|
8395
|
-
else if (schema.maximum !== void 0) point2 = {
|
|
8396
|
-
num: schema.maximum,
|
|
8397
|
-
exclusive: false
|
|
8398
|
-
};
|
|
8399
|
-
else point2 = {
|
|
8400
|
-
num: Number.POSITIVE_INFINITY,
|
|
8401
|
-
exclusive: true
|
|
8402
|
-
};
|
|
8403
|
-
return [point1, point2];
|
|
8219
|
+
function isDecisiveMismatch(result) {
|
|
8220
|
+
return !hasEquals(result) && !hasContainedBy(result) && (hasContaining(result) || hasIntersection(result) || hasRejection(result));
|
|
8404
8221
|
}
|
|
8405
|
-
function
|
|
8406
|
-
|
|
8407
|
-
if (
|
|
8408
|
-
|
|
8222
|
+
function findMismatchPath(source, target) {
|
|
8223
|
+
const targetPath = getPath(target);
|
|
8224
|
+
if (!targetPath) return void 0;
|
|
8225
|
+
const sourceKind = getKind(source);
|
|
8226
|
+
const targetKind = getKind(target);
|
|
8227
|
+
if (sourceKind !== targetKind) return [...targetPath, "type"];
|
|
8228
|
+
const sourceSchema = source;
|
|
8229
|
+
const targetSchema = target;
|
|
8230
|
+
switch (targetKind) {
|
|
8231
|
+
case CompiledKind.String:
|
|
8232
|
+
if ((sourceSchema.minLength ?? 0) < (targetSchema.minLength ?? 0)) return [...targetPath, "minLength"];
|
|
8233
|
+
if ((sourceSchema.maxLength ?? Number.POSITIVE_INFINITY) > (targetSchema.maxLength ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxLength"];
|
|
8234
|
+
if (sourceSchema.pattern !== targetSchema.pattern && targetSchema.pattern) return [...targetPath, "pattern"];
|
|
8235
|
+
if (sourceSchema.format !== targetSchema.format && targetSchema.format) return [...targetPath, "format"];
|
|
8236
|
+
break;
|
|
8237
|
+
case CompiledKind.Numeric:
|
|
8238
|
+
if ((sourceSchema.minimum ?? sourceSchema.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) < (targetSchema.minimum ?? targetSchema.exclusiveMinimum ?? Number.NEGATIVE_INFINITY)) return [...targetPath, targetSchema.exclusiveMinimum == null ? "minimum" : "exclusiveMinimum"];
|
|
8239
|
+
if ((sourceSchema.maximum ?? sourceSchema.exclusiveMaximum ?? Number.POSITIVE_INFINITY) > (targetSchema.maximum ?? targetSchema.exclusiveMaximum ?? Number.POSITIVE_INFINITY)) return [...targetPath, targetSchema.exclusiveMaximum == null ? "maximum" : "exclusiveMaximum"];
|
|
8240
|
+
if (sourceSchema.multipleOf !== targetSchema.multipleOf && targetSchema.multipleOf != null) return [...targetPath, "multipleOf"];
|
|
8241
|
+
break;
|
|
8242
|
+
case CompiledKind.Array:
|
|
8243
|
+
if ((sourceSchema.minItems ?? 0) < (targetSchema.minItems ?? 0)) return [...targetPath, "minItems"];
|
|
8244
|
+
if ((sourceSchema.maxItems ?? Number.POSITIVE_INFINITY) > (targetSchema.maxItems ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxItems"];
|
|
8245
|
+
if (!sourceSchema.uniqueItems && targetSchema.uniqueItems) return [...targetPath, "uniqueItems"];
|
|
8246
|
+
break;
|
|
8247
|
+
case CompiledKind.Object: {
|
|
8248
|
+
const sourceRequired = new Set(sourceSchema.required ?? []);
|
|
8249
|
+
if ((targetSchema.required ?? []).some((key) => !sourceRequired.has(key))) return [...targetPath, "required"];
|
|
8250
|
+
if ((sourceSchema.minProperties ?? 0) < (targetSchema.minProperties ?? 0)) return [...targetPath, "minProperties"];
|
|
8251
|
+
if ((sourceSchema.maxProperties ?? Number.POSITIVE_INFINITY) > (targetSchema.maxProperties ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxProperties"];
|
|
8252
|
+
break;
|
|
8253
|
+
}
|
|
8254
|
+
case CompiledKind.EnumOrConst: return [...targetPath, targetSchema.const == null ? "enum" : "const"];
|
|
8255
|
+
}
|
|
8256
|
+
return targetPath;
|
|
8409
8257
|
}
|
|
8410
8258
|
//#endregion
|
|
8411
|
-
//#region src/json-schema-subset/
|
|
8412
|
-
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
if (!integer1 && !integer2) return ExpressionEquals;
|
|
8416
|
-
if (!integer1) return ExpressionContainedBy;
|
|
8417
|
-
if (!integer2) return ExpressionContaining;
|
|
8418
|
-
const { range: range1, multipleOf: multipleOf1 } = integer1;
|
|
8419
|
-
const { range: range2, multipleOf: multipleOf2 } = integer2;
|
|
8420
|
-
const result = splitRange$3(range1, range2);
|
|
8421
|
-
let centerRange;
|
|
8422
|
-
let lcm = 0;
|
|
8423
|
-
if (result.center) {
|
|
8424
|
-
lcm = getLCM(multipleOf1, multipleOf2);
|
|
8425
|
-
centerRange = cutRange(result.center, lcm);
|
|
8259
|
+
//#region src/json-schema-subset/extends/extendsContext.ts
|
|
8260
|
+
var ExtendsContext = class ExtendsContext {
|
|
8261
|
+
constructor(extendsSchemaClasses = []) {
|
|
8262
|
+
this.extendsSchemaClasses = Object.freeze([...extendsSchemaClasses]);
|
|
8426
8263
|
}
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
|
|
8430
|
-
const { left, right } = result;
|
|
8431
|
-
if (left && cutRange(left.range, left.fromLeft ? multipleOf1 : multipleOf2)) {
|
|
8432
|
-
if (left.fromLeft) extraLeft = true;
|
|
8433
|
-
else extraRight = true;
|
|
8264
|
+
tryCompiledExtendsSchema(target, payload) {
|
|
8265
|
+
for (const extendsSchemaClass of this.extendsSchemaClasses) if (extendsSchemaClass.isMatch(target)) return new extendsSchemaClass(createId(), target, payload);
|
|
8266
|
+
return null;
|
|
8434
8267
|
}
|
|
8435
|
-
|
|
8436
|
-
|
|
8437
|
-
|
|
8268
|
+
isExtendsSchema(target) {
|
|
8269
|
+
for (const extendsSchemaClass of this.extendsSchemaClasses) if (target instanceof extendsSchemaClass) return true;
|
|
8270
|
+
return false;
|
|
8438
8271
|
}
|
|
8439
|
-
|
|
8440
|
-
|
|
8441
|
-
|
|
8442
|
-
|
|
8443
|
-
|
|
8444
|
-
|
|
8445
|
-
|
|
8446
|
-
|
|
8447
|
-
|
|
8448
|
-
|
|
8449
|
-
|
|
8450
|
-
|
|
8451
|
-
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
|
|
8455
|
-
|
|
8456
|
-
|
|
8272
|
+
calculate(schema1, schema2) {
|
|
8273
|
+
const shouldSwap = !(schema1 instanceof this.findMatchedClass(schema1, schema2));
|
|
8274
|
+
let expressionResult = 0;
|
|
8275
|
+
let result;
|
|
8276
|
+
if (shouldSwap) result = schema2.compare(schema1);
|
|
8277
|
+
else result = schema1.compare(schema2);
|
|
8278
|
+
for (let expression of result) {
|
|
8279
|
+
if (shouldSwap) expression = ExtendsContext.swap(expression);
|
|
8280
|
+
expressionResult |= toExpression(expression);
|
|
8281
|
+
}
|
|
8282
|
+
return expressionResult;
|
|
8283
|
+
}
|
|
8284
|
+
equals(schema1, schema2) {
|
|
8285
|
+
if (!(schema1 instanceof this.findMatchedClass(schema1, schema2))) return schema2.equals(schema1);
|
|
8286
|
+
else return schema1.equals(schema2);
|
|
8287
|
+
}
|
|
8288
|
+
findMatchedClass(schema1, schema2) {
|
|
8289
|
+
for (const schemaClass of this.extendsSchemaClasses) {
|
|
8290
|
+
if (schema1 instanceof schemaClass) return schemaClass;
|
|
8291
|
+
if (schema2 instanceof schemaClass) return schemaClass;
|
|
8292
|
+
}
|
|
8293
|
+
throw new Error("Invalid schema");
|
|
8294
|
+
}
|
|
8295
|
+
static swap(expression) {
|
|
8296
|
+
switch (expression) {
|
|
8297
|
+
case ExpressionSingleResult.Containing: return ExpressionSingleResult.ContainedBy;
|
|
8298
|
+
case ExpressionSingleResult.ContainedBy: return ExpressionSingleResult.Containing;
|
|
8299
|
+
default: return expression;
|
|
8300
|
+
}
|
|
8301
|
+
}
|
|
8302
|
+
};
|
|
8303
|
+
//#endregion
|
|
8304
|
+
//#region src/json-schema-subset/preprocessing.ts
|
|
8305
|
+
function preprocessSchema(schema, compile, printWarnLog = false) {
|
|
8306
|
+
const schemaResult = compile(schema);
|
|
8307
|
+
if (Array.isArray(schemaResult)) {
|
|
8308
|
+
const errorItems = [];
|
|
8309
|
+
collectWithPathPrefix(errorItems, schemaResult, "$");
|
|
8310
|
+
throw new SchemaError(errorItems);
|
|
8311
|
+
}
|
|
8312
|
+
const { schema: compiledSchema, warns } = schemaResult;
|
|
8313
|
+
if (printWarnLog && warns.length > 0) {
|
|
8314
|
+
console.warn(`found ${warns.length} warns after compile schema`);
|
|
8315
|
+
for (const warn of warns) console.warn(stringifySchemaError(warn));
|
|
8316
|
+
}
|
|
8317
|
+
return compiledSchema;
|
|
8457
8318
|
}
|
|
8458
|
-
|
|
8459
|
-
|
|
8460
|
-
|
|
8319
|
+
function preprocessSchemasPair(schema1, schema2, compile, printWarnLog = false) {
|
|
8320
|
+
const schemaResult1 = compile(schema1);
|
|
8321
|
+
const schemaResult2 = compile(schema2);
|
|
8322
|
+
if (Array.isArray(schemaResult1) || Array.isArray(schemaResult2)) {
|
|
8323
|
+
const errorItems = [];
|
|
8324
|
+
if (Array.isArray(schemaResult1)) collectWithPathPrefix(errorItems, schemaResult1, "$1");
|
|
8325
|
+
if (Array.isArray(schemaResult2)) collectWithPathPrefix(errorItems, schemaResult2, "$2");
|
|
8326
|
+
throw new SchemaError(errorItems);
|
|
8327
|
+
}
|
|
8328
|
+
const { schema: compiledSchema1, warns: superWarns } = schemaResult1;
|
|
8329
|
+
const { schema: compiledSchema2, warns: subWarns } = schemaResult2;
|
|
8330
|
+
if (printWarnLog) {
|
|
8331
|
+
if (superWarns.length > 0) console.warn(`found ${superWarns.length} warns after compile superSchema`);
|
|
8332
|
+
for (const warn of superWarns) console.warn(stringifySchemaError(warn));
|
|
8333
|
+
if (subWarns.length > 0) console.warn(`found ${subWarns.length} warns after compile subSchema`);
|
|
8334
|
+
for (const warn of subWarns) console.warn(stringifySchemaError(warn));
|
|
8335
|
+
}
|
|
8336
|
+
return [compiledSchema1, compiledSchema2];
|
|
8461
8337
|
}
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
|
|
8338
|
+
function collectWithPathPrefix(errorItems, compiledItems, prefix) {
|
|
8339
|
+
for (const compiledItem of compiledItems) {
|
|
8340
|
+
const replacedItem = {
|
|
8341
|
+
...compiledItem,
|
|
8342
|
+
path: [prefix, ...compiledItem.path]
|
|
8343
|
+
};
|
|
8344
|
+
errorItems.push(replacedItem);
|
|
8345
|
+
}
|
|
8466
8346
|
}
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8347
|
+
//#endregion
|
|
8348
|
+
//#region src/json-schema-subset/global.ts
|
|
8349
|
+
var SubsetCompareResult = Object.freeze({
|
|
8350
|
+
True: 0,
|
|
8351
|
+
False: 1,
|
|
8352
|
+
Unknown: 2
|
|
8353
|
+
});
|
|
8354
|
+
function makeSubsetCompare({ extendsSchemaClasses, delegate } = {}) {
|
|
8355
|
+
const extendsContext = new ExtendsContext(extendsSchemaClasses);
|
|
8356
|
+
return Object.freeze({
|
|
8357
|
+
compile: (schema, payload, printWarnLog) => {
|
|
8358
|
+
const compiler = (candidate) => compile(candidate, extendsContext, payload, delegate);
|
|
8359
|
+
return preprocessSchema(schema, compiler, printWarnLog);
|
|
8360
|
+
},
|
|
8361
|
+
isSubset: (superSchema, subSchema, printWarnLog = false) => {
|
|
8362
|
+
const compiler = (candidate) => compile(candidate, extendsContext, void 0, delegate);
|
|
8363
|
+
const [schema1, schema2] = preprocessSchemasPair(superSchema, subSchema, compiler, printWarnLog);
|
|
8364
|
+
const { errorPath, expression } = checkWithResult(extendsContext, schema1, schema2);
|
|
8365
|
+
const foundTrueExpression = hasEquals(expression) || hasContainedBy(expression);
|
|
8366
|
+
const foundFalseExpression = hasContaining(expression) || hasIntersection(expression) || hasRejection(expression);
|
|
8367
|
+
if (foundTrueExpression && !foundFalseExpression) return { result: SubsetCompareResult.True };
|
|
8368
|
+
if (!foundTrueExpression && foundFalseExpression) return {
|
|
8369
|
+
errorPath,
|
|
8370
|
+
result: SubsetCompareResult.False
|
|
8371
|
+
};
|
|
8372
|
+
return { result: SubsetCompareResult.Unknown };
|
|
8373
|
+
}
|
|
8374
|
+
});
|
|
8471
8375
|
}
|
|
8472
8376
|
//#endregion
|
|
8473
|
-
//#region
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
|
|
8377
|
+
//#region ../../node_modules/.bun/@wopjs+cast@0.1.16/node_modules/@wopjs/cast/dist/index.mjs
|
|
8378
|
+
var isString = (x) => typeof x === "string";
|
|
8379
|
+
var isArray = Array.isArray;
|
|
8380
|
+
var isObject = (x) => x !== null && typeof x === "object";
|
|
8381
|
+
var isPlainObject = (x) => isObject(x) && !isArray(x);
|
|
8382
|
+
var toPlainObject = (x) => isPlainObject(x) ? x : void 0;
|
|
8383
|
+
//#endregion
|
|
8384
|
+
//#region src/flow/common/schemaComparer.ts
|
|
8385
|
+
function isStringLikeSchema(value) {
|
|
8386
|
+
return toPlainObject(value)?.type === "string";
|
|
8482
8387
|
}
|
|
8483
|
-
function
|
|
8484
|
-
const
|
|
8485
|
-
|
|
8486
|
-
if (!
|
|
8487
|
-
if (multipleOf < 0) return true;
|
|
8488
|
-
return false;
|
|
8388
|
+
function assertSchemaCompareContext(value) {
|
|
8389
|
+
const context = toPlainObject(value);
|
|
8390
|
+
const error = toPlainObject(context?.error);
|
|
8391
|
+
if (context == null || error == null || context.packageId != null && !isString(context.packageId) || error.message != null && !isString(error.message)) throw new TypeError("Invalid schema comparison context.");
|
|
8489
8392
|
}
|
|
8490
|
-
function
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
return true;
|
|
8393
|
+
function parseSchemaCompareContext(value) {
|
|
8394
|
+
if (value == null) return { error: {} };
|
|
8395
|
+
assertSchemaCompareContext(value);
|
|
8396
|
+
return value;
|
|
8495
8397
|
}
|
|
8496
|
-
|
|
8497
|
-
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
|
|
8506
|
-
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
|
|
8511
|
-
|
|
8512
|
-
|
|
8513
|
-
const
|
|
8514
|
-
|
|
8515
|
-
|
|
8516
|
-
|
|
8517
|
-
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8398
|
+
var SpecialSchema = class SpecialSchema {
|
|
8399
|
+
static setError(fromSchema, toSchema, message) {
|
|
8400
|
+
if (fromSchema instanceof SpecialSchema) fromSchema.context.error.message = message;
|
|
8401
|
+
else if (toSchema instanceof SpecialSchema) toSchema.context.error.message = message;
|
|
8402
|
+
}
|
|
8403
|
+
constructor(id, value, context) {
|
|
8404
|
+
this.id = id;
|
|
8405
|
+
this.value = value;
|
|
8406
|
+
this.context = parseSchemaCompareContext(context);
|
|
8407
|
+
}
|
|
8408
|
+
compare(other) {
|
|
8409
|
+
if (isCompiledSchema(other) && getKind(other) === CompiledKind.Any) return [ExpressionSingleResult.ContainedBy];
|
|
8410
|
+
return this.compareImpl(other);
|
|
8411
|
+
}
|
|
8412
|
+
};
|
|
8413
|
+
var SingleSelectSchema = class SingleSelectSchema extends SpecialSchema {
|
|
8414
|
+
static isMatch(value) {
|
|
8415
|
+
const enumValues = toPlainObject(value)?.enum;
|
|
8416
|
+
return Array.isArray(enumValues) && enumValues.every((v) => isString(v));
|
|
8417
|
+
}
|
|
8418
|
+
constructor(id, value, context) {
|
|
8419
|
+
if (!SingleSelectSchema.isMatch(value)) throw new TypeError("Invalid single-select schema.");
|
|
8420
|
+
super(id, value, context);
|
|
8421
|
+
}
|
|
8422
|
+
compareImpl(other) {
|
|
8423
|
+
if (isStringLikeSchema(other)) return [ExpressionSingleResult.ContainedBy];
|
|
8424
|
+
if (other instanceof SingleSelectSchema) {
|
|
8425
|
+
const f = new Set(this.value.enum);
|
|
8426
|
+
let result = ExpressionSingleResult.Equals;
|
|
8427
|
+
for (const v of other.value.enum) {
|
|
8428
|
+
if (!f.has(v)) result = ExpressionSingleResult.ContainedBy;
|
|
8429
|
+
f.delete(v);
|
|
8430
|
+
}
|
|
8431
|
+
if (f.size === 0) return [result];
|
|
8432
|
+
if (f.size === this.value.enum.length) return [ExpressionSingleResult.Rejection];
|
|
8433
|
+
return [ExpressionSingleResult.Intersection];
|
|
8529
8434
|
}
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
|
|
8435
|
+
return [ExpressionSingleResult.Rejection];
|
|
8436
|
+
}
|
|
8437
|
+
equals(other) {
|
|
8438
|
+
if (other instanceof SingleSelectSchema) {
|
|
8439
|
+
const f = new Set(this.value.enum);
|
|
8440
|
+
for (const v of other.value.enum) {
|
|
8441
|
+
if (!f.has(v)) return false;
|
|
8442
|
+
f.delete(v);
|
|
8443
|
+
}
|
|
8444
|
+
return f.size === 0;
|
|
8535
8445
|
}
|
|
8446
|
+
return false;
|
|
8536
8447
|
}
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8448
|
+
};
|
|
8449
|
+
var BinarySchema = class BinarySchema extends SpecialSchema {
|
|
8450
|
+
static isMatch(value) {
|
|
8451
|
+
return toPlainObject(value)?.contentMediaType === "oomol/bin";
|
|
8452
|
+
}
|
|
8453
|
+
constructor(id, value, context) {
|
|
8454
|
+
if (!BinarySchema.isMatch(value)) throw new TypeError("Invalid binary schema.");
|
|
8455
|
+
super(id, value, context);
|
|
8456
|
+
}
|
|
8457
|
+
compareImpl(other) {
|
|
8458
|
+
if (other instanceof BinarySchema) return [ExpressionSingleResult.Equals];
|
|
8459
|
+
else {
|
|
8460
|
+
SpecialSchema.setError(this, other, "edgeError.binDiffType");
|
|
8461
|
+
return [ExpressionSingleResult.Rejection];
|
|
8541
8462
|
}
|
|
8463
|
+
}
|
|
8464
|
+
equals(other) {
|
|
8465
|
+
return other instanceof BinarySchema;
|
|
8466
|
+
}
|
|
8467
|
+
};
|
|
8468
|
+
var ArtifactSchema = class ArtifactSchema extends SpecialSchema {
|
|
8469
|
+
static isMatch(value) {
|
|
8470
|
+
return toPlainObject(value)?.contentMediaType === "oomol/artifact";
|
|
8471
|
+
}
|
|
8472
|
+
constructor(id, value, context) {
|
|
8473
|
+
if (!ArtifactSchema.isMatch(value)) throw new TypeError("Invalid Artifact schema.");
|
|
8474
|
+
super(id, value, context);
|
|
8475
|
+
}
|
|
8476
|
+
compareImpl(other) {
|
|
8477
|
+
if (other instanceof ArtifactSchema) return [ExpressionSingleResult.Equals];
|
|
8478
|
+
SpecialSchema.setError(this, other, "edgeError.artifactDiffType");
|
|
8479
|
+
return [ExpressionSingleResult.Rejection];
|
|
8480
|
+
}
|
|
8481
|
+
equals(other) {
|
|
8482
|
+
return other instanceof ArtifactSchema;
|
|
8483
|
+
}
|
|
8484
|
+
};
|
|
8485
|
+
function createSchemaComparer() {
|
|
8486
|
+
return makeSubsetCompare({ extendsSchemaClasses: [
|
|
8487
|
+
SingleSelectSchema,
|
|
8488
|
+
BinarySchema,
|
|
8489
|
+
ArtifactSchema
|
|
8490
|
+
] });
|
|
8491
|
+
}
|
|
8492
|
+
createSchemaComparer();
|
|
8493
|
+
//#endregion
|
|
8494
|
+
//#region src/decision/common/decision.ts
|
|
8495
|
+
var decisionLimits = {
|
|
8496
|
+
choice: 255,
|
|
8497
|
+
score: 10
|
|
8498
|
+
};
|
|
8499
|
+
/** Ordered prefixes are shared by authoring, schemas, validation, and execution. */
|
|
8500
|
+
function limitDecisionQuestion(question) {
|
|
8501
|
+
if (question.type === "noul" || question.criteria.length <= decisionLimits[question.type]) return question;
|
|
8502
|
+
if (question.type === "choice") return {
|
|
8503
|
+
...question,
|
|
8504
|
+
criteria: question.criteria.slice(0, decisionLimits.choice)
|
|
8505
|
+
};
|
|
8506
|
+
return {
|
|
8507
|
+
...question,
|
|
8508
|
+
criteria: question.criteria.slice(0, decisionLimits.score)
|
|
8509
|
+
};
|
|
8510
|
+
}
|
|
8511
|
+
function limitDecisionQuestions(questions) {
|
|
8512
|
+
const limited = questions.map(limitDecisionQuestion);
|
|
8513
|
+
return limited.every((question, i) => question === questions[i]) ? questions : limited;
|
|
8514
|
+
}
|
|
8515
|
+
/** Loading an oversized task also updates its previously generated output schemas. */
|
|
8516
|
+
function limitDecisionTask(task) {
|
|
8517
|
+
if (task.executor.kind !== "decision") return task;
|
|
8518
|
+
const original = task.executor.questions;
|
|
8519
|
+
const questions = limitDecisionQuestions(original);
|
|
8520
|
+
if (questions === original) return task;
|
|
8521
|
+
const outputs = task.outputs.map((port) => {
|
|
8522
|
+
if (!("handle" in port)) return port;
|
|
8523
|
+
const index = original.findIndex((question) => question.name === port.handle);
|
|
8524
|
+
if (index < 0 || original[index] === questions[index] || !dequal(port.jsonSchema, answerSchema(original[index]))) return port;
|
|
8525
|
+
return {
|
|
8526
|
+
...port,
|
|
8527
|
+
jsonSchema: decisionAnswerSchema(questions[index])
|
|
8528
|
+
};
|
|
8542
8529
|
});
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
|
|
8551
|
-
else expression |= ExpressionEquals;
|
|
8552
|
-
return expression;
|
|
8530
|
+
return {
|
|
8531
|
+
...task,
|
|
8532
|
+
executor: {
|
|
8533
|
+
...task.executor,
|
|
8534
|
+
questions
|
|
8535
|
+
},
|
|
8536
|
+
outputs
|
|
8537
|
+
};
|
|
8553
8538
|
}
|
|
8554
|
-
|
|
8555
|
-
|
|
8539
|
+
var probability = {
|
|
8540
|
+
type: "number",
|
|
8541
|
+
minimum: 0,
|
|
8542
|
+
maximum: 1
|
|
8543
|
+
};
|
|
8544
|
+
function decisionAnswerSchema(question) {
|
|
8545
|
+
return answerSchema(limitDecisionQuestion(question));
|
|
8556
8546
|
}
|
|
8557
|
-
function
|
|
8558
|
-
const
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
-
|
|
8562
|
-
|
|
8563
|
-
|
|
8564
|
-
|
|
8565
|
-
|
|
8566
|
-
|
|
8567
|
-
|
|
8568
|
-
|
|
8569
|
-
if (
|
|
8570
|
-
|
|
8571
|
-
|
|
8572
|
-
|
|
8573
|
-
|
|
8574
|
-
|
|
8575
|
-
|
|
8547
|
+
function answerSchema(question) {
|
|
8548
|
+
const properties = { type: { const: question.type } };
|
|
8549
|
+
if (question.type === "noul") properties.noul = probability;
|
|
8550
|
+
else {
|
|
8551
|
+
const keys = question.type === "choice" ? question.criteria.map((item) => item.name) : question.criteria.map((_, index) => String(index));
|
|
8552
|
+
properties.confidence = probability;
|
|
8553
|
+
properties.probabilities = {
|
|
8554
|
+
type: "object",
|
|
8555
|
+
properties: Object.fromEntries(keys.map((key) => [key, probability])),
|
|
8556
|
+
required: keys,
|
|
8557
|
+
additionalProperties: false
|
|
8558
|
+
};
|
|
8559
|
+
if (question.type === "choice") properties.choice = {
|
|
8560
|
+
type: "string",
|
|
8561
|
+
...keys.length ? { enum: keys } : {}
|
|
8562
|
+
};
|
|
8563
|
+
else {
|
|
8564
|
+
properties.score = {
|
|
8565
|
+
type: "number",
|
|
8566
|
+
minimum: 0,
|
|
8567
|
+
maximum: Math.max(0, keys.length - 1)
|
|
8568
|
+
};
|
|
8569
|
+
properties.legend = {
|
|
8570
|
+
type: "object",
|
|
8571
|
+
properties: Object.fromEntries(keys.map((key) => [key, { type: "string" }])),
|
|
8572
|
+
required: keys,
|
|
8573
|
+
additionalProperties: false
|
|
8574
|
+
};
|
|
8575
|
+
}
|
|
8576
8576
|
}
|
|
8577
|
-
const maxProperties1 = schema1.maxProperties ?? Number.MAX_SAFE_INTEGER;
|
|
8578
|
-
const maxProperties2 = schema2.maxProperties ?? Number.MAX_SAFE_INTEGER;
|
|
8579
|
-
if (requiredKeysCount > maxProperties1 || requiredKeysCount > maxProperties2) return null;
|
|
8580
8577
|
return {
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
commonRequired,
|
|
8585
|
-
hasOptional1: maxProperties1 > requiredCount1,
|
|
8586
|
-
hasOptional2: maxProperties2 > requiredCount2
|
|
8578
|
+
type: "object",
|
|
8579
|
+
properties,
|
|
8580
|
+
required: Object.keys(properties)
|
|
8587
8581
|
};
|
|
8588
8582
|
}
|
|
8589
|
-
function
|
|
8590
|
-
|
|
8591
|
-
const
|
|
8592
|
-
const properties2 = schema2.properties;
|
|
8593
|
-
const required1 = schema1.required;
|
|
8594
|
-
const required2 = schema2.required;
|
|
8595
|
-
if (properties1) for (const key in properties1) optionalKeys.add(key);
|
|
8596
|
-
if (properties2) for (const key in properties2) optionalKeys.add(key);
|
|
8597
|
-
if (required1) for (const key of required1) optionalKeys.delete(key);
|
|
8598
|
-
if (required2) for (const key of required2) optionalKeys.delete(key);
|
|
8599
|
-
return optionalKeys;
|
|
8583
|
+
function checkJsonDepth(value, depth = 0) {
|
|
8584
|
+
if (depth > 64) throw new TypeError("Value exceeds the maximum JSON depth.");
|
|
8585
|
+
if (value != null && typeof value == "object") for (const child of Object.values(value)) checkJsonDepth(child, depth + 1);
|
|
8600
8586
|
}
|
|
8601
|
-
|
|
8602
|
-
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
|
|
8612
|
-
|
|
8613
|
-
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
|
|
8619
|
-
|
|
8620
|
-
|
|
8587
|
+
//#endregion
|
|
8588
|
+
//#region src/flow/common/triggerScheduleSchema.ts
|
|
8589
|
+
var triggerScheduleSchema = array(union([object({
|
|
8590
|
+
type: literal("cron"),
|
|
8591
|
+
expression: string$1(),
|
|
8592
|
+
timezone: string$1()
|
|
8593
|
+
}), object({
|
|
8594
|
+
type: literal("every"),
|
|
8595
|
+
unit: _enum([
|
|
8596
|
+
"day",
|
|
8597
|
+
"hour",
|
|
8598
|
+
"minute",
|
|
8599
|
+
"month",
|
|
8600
|
+
"week"
|
|
8601
|
+
]),
|
|
8602
|
+
value: number()
|
|
8603
|
+
})]));
|
|
8604
|
+
var text = string$1();
|
|
8605
|
+
var json$3 = json$4();
|
|
8606
|
+
var strings$1 = array(text);
|
|
8607
|
+
var port$1 = object({
|
|
8608
|
+
description: text.optional(),
|
|
8609
|
+
jsonSchema: json$3,
|
|
8610
|
+
nullable: boolean(),
|
|
8611
|
+
handle: text
|
|
8612
|
+
});
|
|
8613
|
+
var input = port$1.extend({ value: json$3.optional() });
|
|
8614
|
+
var group = object({
|
|
8615
|
+
collapsed: boolean().optional(),
|
|
8616
|
+
group: text
|
|
8617
|
+
});
|
|
8618
|
+
var source = union([object({
|
|
8619
|
+
kind: literal("node"),
|
|
8620
|
+
nodeId: text,
|
|
8621
|
+
output: text,
|
|
8622
|
+
field: text.optional()
|
|
8623
|
+
}), object({
|
|
8624
|
+
kind: literal("binding"),
|
|
8625
|
+
bindingId: text
|
|
8626
|
+
})]);
|
|
8627
|
+
var fixedInput = union([object({ kind: literal("unset") }), object({
|
|
8628
|
+
kind: literal("value"),
|
|
8629
|
+
value: json$3
|
|
8630
|
+
})]);
|
|
8631
|
+
var mapping = union([fixedInput, object({
|
|
8632
|
+
kind: literal("sources"),
|
|
8633
|
+
sources: array(source)
|
|
8634
|
+
})]);
|
|
8635
|
+
var inputs = record$3(text, mapping);
|
|
8636
|
+
var ports$1 = {
|
|
8637
|
+
inputs: array(union([input, group])),
|
|
8638
|
+
outputs: array(union([port$1, group]))
|
|
8621
8639
|
};
|
|
8622
|
-
var
|
|
8623
|
-
|
|
8624
|
-
|
|
8625
|
-
|
|
8626
|
-
|
|
8627
|
-
|
|
8628
|
-
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8640
|
+
var capability = union([
|
|
8641
|
+
strictObject({
|
|
8642
|
+
kind: literal("connector"),
|
|
8643
|
+
action: text,
|
|
8644
|
+
connectionId: text.optional(),
|
|
8645
|
+
connections: array(strictObject({
|
|
8646
|
+
connectionId: text,
|
|
8647
|
+
alias: text.optional()
|
|
8648
|
+
}))
|
|
8649
|
+
}),
|
|
8650
|
+
strictObject({
|
|
8651
|
+
kind: literal("connector"),
|
|
8652
|
+
mode: literal("shared")
|
|
8653
|
+
}),
|
|
8654
|
+
strictObject({
|
|
8655
|
+
kind: literal("connector"),
|
|
8656
|
+
mode: literal("independent"),
|
|
8657
|
+
actions: array(strictObject({
|
|
8658
|
+
action: text,
|
|
8659
|
+
connectionId: text.optional()
|
|
8660
|
+
}))
|
|
8661
|
+
}),
|
|
8662
|
+
strictObject({
|
|
8663
|
+
kind: literal("connector"),
|
|
8664
|
+
actionHints: array(text).optional(),
|
|
8665
|
+
connectionHints: array(strictObject({
|
|
8666
|
+
action: text,
|
|
8667
|
+
connectionId: text,
|
|
8668
|
+
alias: text.optional()
|
|
8669
|
+
})).optional()
|
|
8670
|
+
})
|
|
8671
|
+
]);
|
|
8672
|
+
var inline = object({
|
|
8673
|
+
...ports$1,
|
|
8674
|
+
name: text,
|
|
8675
|
+
moduleId: text,
|
|
8676
|
+
capabilities: array(capability).optional()
|
|
8677
|
+
});
|
|
8678
|
+
var agentValue = union([object({
|
|
8679
|
+
kind: literal("value"),
|
|
8680
|
+
value: json$3
|
|
8681
|
+
}), object({
|
|
8682
|
+
kind: literal("input"),
|
|
8683
|
+
input: text
|
|
8684
|
+
})]);
|
|
8685
|
+
var agentInput = union([agentValue, object({ kind: literal("model") })]);
|
|
8686
|
+
var decisionQuestion = discriminatedUnion("type", [
|
|
8687
|
+
strictObject({
|
|
8688
|
+
name: text,
|
|
8689
|
+
instructions: text,
|
|
8690
|
+
type: literal("noul"),
|
|
8691
|
+
criteria: strictObject({
|
|
8692
|
+
true: text.optional(),
|
|
8693
|
+
false: text.optional()
|
|
8694
|
+
}).optional()
|
|
8695
|
+
}),
|
|
8696
|
+
strictObject({
|
|
8697
|
+
name: text,
|
|
8698
|
+
instructions: text,
|
|
8699
|
+
type: literal("choice"),
|
|
8700
|
+
criteria: array(strictObject({
|
|
8701
|
+
name: text,
|
|
8702
|
+
description: text
|
|
8703
|
+
}))
|
|
8704
|
+
}),
|
|
8705
|
+
strictObject({
|
|
8706
|
+
name: text,
|
|
8707
|
+
instructions: text,
|
|
8708
|
+
type: literal("score"),
|
|
8709
|
+
criteria: strings$1
|
|
8710
|
+
})
|
|
8711
|
+
]);
|
|
8712
|
+
var managedFields = object({
|
|
8713
|
+
...ports$1,
|
|
8714
|
+
name: text,
|
|
8715
|
+
executor: union([
|
|
8716
|
+
object({
|
|
8717
|
+
kind: literal("connector"),
|
|
8718
|
+
action: text,
|
|
8719
|
+
connectionId: text.optional()
|
|
8720
|
+
}),
|
|
8721
|
+
object({
|
|
8722
|
+
kind: literal("openapi"),
|
|
8723
|
+
sourceUrl: text,
|
|
8724
|
+
method: text,
|
|
8725
|
+
path: text,
|
|
8726
|
+
serverUrl: text,
|
|
8727
|
+
document: json$3,
|
|
8728
|
+
auth: array(object({
|
|
8729
|
+
id: text,
|
|
8730
|
+
type: _enum([
|
|
8731
|
+
"bearer",
|
|
8732
|
+
"basic",
|
|
8733
|
+
"apiKey"
|
|
8734
|
+
]),
|
|
8735
|
+
name: text.optional(),
|
|
8736
|
+
in: _enum(["header", "query"]).optional()
|
|
8737
|
+
}))
|
|
8738
|
+
}),
|
|
8739
|
+
strictObject({
|
|
8740
|
+
kind: literal("decision"),
|
|
8741
|
+
questions: array(decisionQuestion)
|
|
8742
|
+
}),
|
|
8743
|
+
object({
|
|
8744
|
+
kind: literal("llm"),
|
|
8745
|
+
mode: _enum(["chat", "json"])
|
|
8746
|
+
}),
|
|
8747
|
+
object({
|
|
8748
|
+
kind: literal("agent"),
|
|
8749
|
+
code: boolean().optional(),
|
|
8750
|
+
model: text,
|
|
8751
|
+
prompt: text,
|
|
8752
|
+
maxRounds: number(),
|
|
8753
|
+
tools: array(object({
|
|
8754
|
+
id: text,
|
|
8755
|
+
name: text,
|
|
8756
|
+
description: text,
|
|
8757
|
+
action: text,
|
|
8758
|
+
connectionId: text.optional(),
|
|
8759
|
+
approval: boolean(),
|
|
8760
|
+
inputs: array(input.extend({ source: agentInput }))
|
|
8761
|
+
})),
|
|
8762
|
+
notification: object({
|
|
8763
|
+
action: text,
|
|
8764
|
+
connectionId: text.optional(),
|
|
8765
|
+
inputDefinitions: array(input),
|
|
8766
|
+
messageHandle: text,
|
|
8767
|
+
inputs: record$3(text, agentValue)
|
|
8768
|
+
}).optional()
|
|
8769
|
+
})
|
|
8770
|
+
])
|
|
8771
|
+
});
|
|
8772
|
+
var managed = managedFields.transform(limitDecisionTask);
|
|
8773
|
+
var operand$1 = union([object({
|
|
8774
|
+
kind: literal("value"),
|
|
8775
|
+
value: json$3.optional(),
|
|
8776
|
+
jsonSchema: json$3.optional()
|
|
8777
|
+
}), object({
|
|
8778
|
+
kind: literal("source"),
|
|
8779
|
+
source
|
|
8780
|
+
})]);
|
|
8781
|
+
var condition = {
|
|
8782
|
+
matchMode: _enum(["first", "all"]),
|
|
8783
|
+
cases: array(object({
|
|
8784
|
+
description: text.optional(),
|
|
8785
|
+
output: text,
|
|
8786
|
+
groups: array(object({ expressions: array(object({
|
|
8787
|
+
left: operand$1,
|
|
8788
|
+
operator: _enum([
|
|
8789
|
+
"!=",
|
|
8790
|
+
"<",
|
|
8791
|
+
"<=",
|
|
8792
|
+
"==",
|
|
8793
|
+
">",
|
|
8794
|
+
">=",
|
|
8795
|
+
"contains",
|
|
8796
|
+
"endsWith",
|
|
8797
|
+
"hasKey",
|
|
8798
|
+
"hasValue",
|
|
8799
|
+
"isEmpty",
|
|
8800
|
+
"isFalse",
|
|
8801
|
+
"isNotEmpty",
|
|
8802
|
+
"isNotNull",
|
|
8803
|
+
"isNull",
|
|
8804
|
+
"isTrue",
|
|
8805
|
+
"notContains",
|
|
8806
|
+
"notHasKey",
|
|
8807
|
+
"notHasValue",
|
|
8808
|
+
"startsWith"
|
|
8809
|
+
]),
|
|
8810
|
+
right: operand$1.optional()
|
|
8811
|
+
})) }))
|
|
8812
|
+
}))
|
|
8635
8813
|
};
|
|
8636
|
-
var
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
case ExpressionSingleResult.Containing:
|
|
8640
|
-
variable.hasCommonInRequired = true;
|
|
8641
|
-
break;
|
|
8642
|
-
case ExpressionSingleResult.Intersection:
|
|
8643
|
-
case ExpressionSingleResult.ContainedBy:
|
|
8644
|
-
variable.hasExtra2 = true;
|
|
8645
|
-
variable.hasCommonInRequired = true;
|
|
8646
|
-
break;
|
|
8647
|
-
case ExpressionSingleResult.Rejection: variable.hasRejection = true;
|
|
8648
|
-
}
|
|
8814
|
+
var wait = {
|
|
8815
|
+
inputDefinitions: array(input),
|
|
8816
|
+
prompt: text
|
|
8649
8817
|
};
|
|
8650
|
-
var
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8655
|
-
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8660
|
-
|
|
8661
|
-
|
|
8662
|
-
break;
|
|
8663
|
-
case ExpressionSingleResult.ContainedBy:
|
|
8664
|
-
foundExtraPossibility2 = true;
|
|
8665
|
-
foundCommonPossibility = true;
|
|
8666
|
-
break;
|
|
8667
|
-
case ExpressionSingleResult.Intersection:
|
|
8668
|
-
foundExtraPossibility1 = true;
|
|
8669
|
-
foundExtraPossibility2 = true;
|
|
8670
|
-
foundCommonPossibility = true;
|
|
8671
|
-
break;
|
|
8672
|
-
case ExpressionSingleResult.Rejection:
|
|
8673
|
-
foundExtraPossibility1 = true;
|
|
8674
|
-
foundExtraPossibility2 = true;
|
|
8675
|
-
}
|
|
8676
|
-
if (hasOptional1 && foundExtraPossibility1) variable.hasExtra1 = true;
|
|
8677
|
-
if (hasOptional2 && foundExtraPossibility2) variable.hasExtra2 = true;
|
|
8678
|
-
if (hasOptional1 && hasOptional2 && foundCommonPossibility) variable.hasCommonOutRequired = true;
|
|
8818
|
+
var webhookOptions = object({
|
|
8819
|
+
allowedMethods: never().optional(),
|
|
8820
|
+
allowedOrigins: strings$1.optional(),
|
|
8821
|
+
noResponseBody: never().optional(),
|
|
8822
|
+
responseData: text.optional(),
|
|
8823
|
+
responseHeaders: record$3(text, text).optional(),
|
|
8824
|
+
responseStatusCode: number().int().min(200).max(599).optional()
|
|
8825
|
+
});
|
|
8826
|
+
var webhook = {
|
|
8827
|
+
bodyFields: array(input),
|
|
8828
|
+
method: _enum(webhookMethods),
|
|
8829
|
+
options: webhookOptions.optional()
|
|
8679
8830
|
};
|
|
8680
|
-
|
|
8681
|
-
|
|
8682
|
-
|
|
8683
|
-
|
|
8684
|
-
|
|
8685
|
-
|
|
8686
|
-
|
|
8687
|
-
|
|
8688
|
-
|
|
8689
|
-
pattern: regExp,
|
|
8690
|
-
schema: valueSchema
|
|
8691
|
-
});
|
|
8692
|
-
}
|
|
8693
|
-
return (key) => {
|
|
8694
|
-
if (propertyNames && valid(propertyNames, key) === ValidResult.Invalid) return NEVER;
|
|
8695
|
-
for (const { pattern, schema: patternSchema } of patternProperties) if (pattern.test(key)) return patternSchema;
|
|
8696
|
-
const propertySchema = (properties && properties[key]) ?? additionalProperties;
|
|
8697
|
-
if (!propertySchema) return ANY;
|
|
8698
|
-
return propertySchema;
|
|
8699
|
-
};
|
|
8700
|
-
}
|
|
8701
|
-
function areNotBothNever(schema1, schema2) {
|
|
8702
|
-
const kind1 = getKind(schema1);
|
|
8703
|
-
const kind2 = getKind(schema2);
|
|
8704
|
-
return kind1 !== CompiledKind.Never || kind2 !== CompiledKind.Never;
|
|
8705
|
-
}
|
|
8706
|
-
//#endregion
|
|
8707
|
-
//#region src/json-schema-subset/checker/string.ts
|
|
8708
|
-
var splitRange = createRangeSplitter(0);
|
|
8709
|
-
function calculateString(schema1, schema2) {
|
|
8710
|
-
if (schema2.format && !schema1.format) return ExpressionContaining;
|
|
8711
|
-
if (schema1.format && schema2.format && schema1.format !== schema2.format) return ExpressionAny;
|
|
8712
|
-
const expression = toExpressionSingleResult(splitRange(schema1.minLength, schema1.maxLength, schema2.minLength, schema2.maxLength));
|
|
8713
|
-
const hasPattern1 = !!schema1.pattern;
|
|
8714
|
-
const hasPattern2 = !!schema2.pattern;
|
|
8715
|
-
switch (expression) {
|
|
8716
|
-
case ExpressionSingleResult.Rejection: return ExpressionRejection;
|
|
8717
|
-
case ExpressionSingleResult.Containing: return hasPattern1 ? ExpressionAny : ExpressionContaining;
|
|
8718
|
-
case ExpressionSingleResult.ContainedBy: return hasPattern2 ? ExpressionAny : ExpressionContainedBy;
|
|
8719
|
-
case ExpressionSingleResult.Equals:
|
|
8720
|
-
if (hasPattern1 && hasPattern2) return schema1.pattern === schema2.pattern ? ExpressionEquals : ExpressionAny;
|
|
8721
|
-
if (hasPattern1) return ExpressionEquals | ExpressionContainedBy;
|
|
8722
|
-
if (hasPattern2) return ExpressionEquals | ExpressionContaining;
|
|
8723
|
-
return ExpressionEquals;
|
|
8724
|
-
case ExpressionSingleResult.Intersection:
|
|
8725
|
-
if (hasPattern1 && hasPattern2) return ExpressionAny;
|
|
8726
|
-
if (hasPattern1) return ExpressionIntersection | ExpressionRejection | ExpressionContainedBy;
|
|
8727
|
-
if (hasPattern2) return ExpressionIntersection | ExpressionRejection | ExpressionContaining;
|
|
8728
|
-
return ExpressionIntersection;
|
|
8729
|
-
}
|
|
8730
|
-
}
|
|
8731
|
-
//#endregion
|
|
8732
|
-
//#region src/json-schema-subset/checker/checker.ts
|
|
8733
|
-
function checkWithResult(extendsContext, schema1, schema2) {
|
|
8734
|
-
const context = {};
|
|
8735
|
-
const errorPaths = [];
|
|
8736
|
-
const calculate = wrapSchemaCalculatorWithCache(calculator(extendsContext, context));
|
|
8737
|
-
const describe = describer();
|
|
8738
|
-
const equals = schemaEqualsChecker(extendsContext);
|
|
8739
|
-
context.isEquals = wrapEqualsCheckerWithCache(isDeepEquals);
|
|
8740
|
-
context.calculate = expression$1({
|
|
8741
|
-
describe,
|
|
8742
|
-
equals,
|
|
8743
|
-
calculate,
|
|
8744
|
-
observeCalculation: (left, right, result, swapped) => {
|
|
8745
|
-
if (!isDecisiveMismatch(swapped ? swap(result) : result)) return;
|
|
8746
|
-
const errorPath = swapped ? findMismatchPath(right, left) : findMismatchPath(left, right);
|
|
8747
|
-
if (errorPath) errorPaths.push(errorPath);
|
|
8748
|
-
}
|
|
8749
|
-
});
|
|
8750
|
-
Object.freeze(context);
|
|
8751
|
-
const comparisonExpression = context.calculate(schema1, schema2);
|
|
8752
|
-
return {
|
|
8753
|
-
errorPath: errorPaths[0],
|
|
8754
|
-
expression: comparisonExpression
|
|
8755
|
-
};
|
|
8756
|
-
}
|
|
8757
|
-
var describer = () => (schema) => {
|
|
8758
|
-
let description;
|
|
8759
|
-
switch (getKind(schema)) {
|
|
8760
|
-
case CompiledKind.Not:
|
|
8761
|
-
description = {
|
|
8762
|
-
kind: ExpressionKind.Not,
|
|
8763
|
-
expression: schema.not
|
|
8764
|
-
};
|
|
8765
|
-
break;
|
|
8766
|
-
case CompiledKind.Combination:
|
|
8767
|
-
if ("allOf" in schema) description = {
|
|
8768
|
-
kind: ExpressionKind.AllOf,
|
|
8769
|
-
expressions: rejectInSchemaList(schema.allOf, CompiledKind.Any)
|
|
8770
|
-
};
|
|
8771
|
-
else if ("anyOf" in schema) description = {
|
|
8772
|
-
kind: ExpressionKind.AnyOf,
|
|
8773
|
-
expressions: rejectInSchemaList(schema.anyOf, CompiledKind.Never)
|
|
8774
|
-
};
|
|
8775
|
-
else if ("oneOf" in schema) description = {
|
|
8776
|
-
kind: ExpressionKind.OneOf,
|
|
8777
|
-
expressions: rejectInSchemaList(schema.oneOf, CompiledKind.Never)
|
|
8778
|
-
};
|
|
8779
|
-
else throw new Error(`invalid combination JSON Schema: ${JSON.stringify(schema)}`);
|
|
8780
|
-
break;
|
|
8781
|
-
default: description = { kind: ExpressionKind.Leaf };
|
|
8782
|
-
}
|
|
8783
|
-
return description;
|
|
8831
|
+
var definition = {
|
|
8832
|
+
configInputs: ports$1.inputs,
|
|
8833
|
+
definitionVersion: literal(2),
|
|
8834
|
+
description: text,
|
|
8835
|
+
displayName: text,
|
|
8836
|
+
key: text,
|
|
8837
|
+
name: text,
|
|
8838
|
+
outputs: array(port$1).refine((definitions) => new Set(definitions.map((output) => output.handle)).size === definitions.length, "Duplicate Trigger output handle."),
|
|
8839
|
+
provider: text
|
|
8784
8840
|
};
|
|
8785
|
-
var
|
|
8786
|
-
|
|
8787
|
-
|
|
8788
|
-
|
|
8789
|
-
|
|
8790
|
-
|
|
8791
|
-
|
|
8792
|
-
|
|
8793
|
-
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
|
|
8797
|
-
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
|
|
8805
|
-
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8841
|
+
var endpoint = object({
|
|
8842
|
+
body: object({
|
|
8843
|
+
allowArray: boolean(),
|
|
8844
|
+
allowEmpty: boolean(),
|
|
8845
|
+
formats: array(_enum([
|
|
8846
|
+
"form",
|
|
8847
|
+
"json",
|
|
8848
|
+
"multipart",
|
|
8849
|
+
"text"
|
|
8850
|
+
]))
|
|
8851
|
+
}),
|
|
8852
|
+
methods: array(_enum([
|
|
8853
|
+
"DELETE",
|
|
8854
|
+
"GET",
|
|
8855
|
+
"HEAD",
|
|
8856
|
+
"PATCH",
|
|
8857
|
+
"POST",
|
|
8858
|
+
"PUT"
|
|
8859
|
+
])),
|
|
8860
|
+
successStatus: number()
|
|
8861
|
+
});
|
|
8862
|
+
var sourceFlowIds = array(text.min(1)).refine((ids) => new Set(ids).size === ids.length, "Duplicate source Flow ID.");
|
|
8863
|
+
var trigger = {
|
|
8864
|
+
name: text,
|
|
8865
|
+
description: text.optional(),
|
|
8866
|
+
icon: text.optional()
|
|
8810
8867
|
};
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
const targetPath = getPath(target);
|
|
8819
|
-
if (!targetPath) return void 0;
|
|
8820
|
-
const sourceKind = getKind(source);
|
|
8821
|
-
const targetKind = getKind(target);
|
|
8822
|
-
if (sourceKind !== targetKind) return [...targetPath, "type"];
|
|
8823
|
-
const sourceSchema = source;
|
|
8824
|
-
const targetSchema = target;
|
|
8825
|
-
switch (targetKind) {
|
|
8826
|
-
case CompiledKind.String:
|
|
8827
|
-
if ((sourceSchema.minLength ?? 0) < (targetSchema.minLength ?? 0)) return [...targetPath, "minLength"];
|
|
8828
|
-
if ((sourceSchema.maxLength ?? Number.POSITIVE_INFINITY) > (targetSchema.maxLength ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxLength"];
|
|
8829
|
-
if (sourceSchema.pattern !== targetSchema.pattern && targetSchema.pattern) return [...targetPath, "pattern"];
|
|
8830
|
-
if (sourceSchema.format !== targetSchema.format && targetSchema.format) return [...targetPath, "format"];
|
|
8831
|
-
break;
|
|
8832
|
-
case CompiledKind.Numeric:
|
|
8833
|
-
if ((sourceSchema.minimum ?? sourceSchema.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) < (targetSchema.minimum ?? targetSchema.exclusiveMinimum ?? Number.NEGATIVE_INFINITY)) return [...targetPath, targetSchema.exclusiveMinimum == null ? "minimum" : "exclusiveMinimum"];
|
|
8834
|
-
if ((sourceSchema.maximum ?? sourceSchema.exclusiveMaximum ?? Number.POSITIVE_INFINITY) > (targetSchema.maximum ?? targetSchema.exclusiveMaximum ?? Number.POSITIVE_INFINITY)) return [...targetPath, targetSchema.exclusiveMaximum == null ? "maximum" : "exclusiveMaximum"];
|
|
8835
|
-
if (sourceSchema.multipleOf !== targetSchema.multipleOf && targetSchema.multipleOf != null) return [...targetPath, "multipleOf"];
|
|
8836
|
-
break;
|
|
8837
|
-
case CompiledKind.Array:
|
|
8838
|
-
if ((sourceSchema.minItems ?? 0) < (targetSchema.minItems ?? 0)) return [...targetPath, "minItems"];
|
|
8839
|
-
if ((sourceSchema.maxItems ?? Number.POSITIVE_INFINITY) > (targetSchema.maxItems ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxItems"];
|
|
8840
|
-
if (!sourceSchema.uniqueItems && targetSchema.uniqueItems) return [...targetPath, "uniqueItems"];
|
|
8841
|
-
break;
|
|
8842
|
-
case CompiledKind.Object: {
|
|
8843
|
-
const sourceRequired = new Set(sourceSchema.required ?? []);
|
|
8844
|
-
if ((targetSchema.required ?? []).some((key) => !sourceRequired.has(key))) return [...targetPath, "required"];
|
|
8845
|
-
if ((sourceSchema.minProperties ?? 0) < (targetSchema.minProperties ?? 0)) return [...targetPath, "minProperties"];
|
|
8846
|
-
if ((sourceSchema.maxProperties ?? Number.POSITIVE_INFINITY) > (targetSchema.maxProperties ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxProperties"];
|
|
8847
|
-
break;
|
|
8848
|
-
}
|
|
8849
|
-
case CompiledKind.EnumOrConst: return [...targetPath, targetSchema.const == null ? "enum" : "const"];
|
|
8850
|
-
}
|
|
8851
|
-
return targetPath;
|
|
8852
|
-
}
|
|
8853
|
-
//#endregion
|
|
8854
|
-
//#region src/json-schema-subset/extends/extendsContext.ts
|
|
8855
|
-
var ExtendsContext = class ExtendsContext {
|
|
8856
|
-
constructor(extendsSchemaClasses = []) {
|
|
8857
|
-
this.extendsSchemaClasses = Object.freeze([...extendsSchemaClasses]);
|
|
8858
|
-
}
|
|
8859
|
-
tryCompiledExtendsSchema(target, payload) {
|
|
8860
|
-
for (const extendsSchemaClass of this.extendsSchemaClasses) if (extendsSchemaClass.isMatch(target)) return new extendsSchemaClass(createId(), target, payload);
|
|
8861
|
-
return null;
|
|
8862
|
-
}
|
|
8863
|
-
isExtendsSchema(target) {
|
|
8864
|
-
for (const extendsSchemaClass of this.extendsSchemaClasses) if (target instanceof extendsSchemaClass) return true;
|
|
8865
|
-
return false;
|
|
8866
|
-
}
|
|
8867
|
-
calculate(schema1, schema2) {
|
|
8868
|
-
const shouldSwap = !(schema1 instanceof this.findMatchedClass(schema1, schema2));
|
|
8869
|
-
let expressionResult = 0;
|
|
8870
|
-
let result;
|
|
8871
|
-
if (shouldSwap) result = schema2.compare(schema1);
|
|
8872
|
-
else result = schema1.compare(schema2);
|
|
8873
|
-
for (let expression of result) {
|
|
8874
|
-
if (shouldSwap) expression = ExtendsContext.swap(expression);
|
|
8875
|
-
expressionResult |= toExpression(expression);
|
|
8876
|
-
}
|
|
8877
|
-
return expressionResult;
|
|
8878
|
-
}
|
|
8879
|
-
equals(schema1, schema2) {
|
|
8880
|
-
if (!(schema1 instanceof this.findMatchedClass(schema1, schema2))) return schema2.equals(schema1);
|
|
8881
|
-
else return schema1.equals(schema2);
|
|
8882
|
-
}
|
|
8883
|
-
findMatchedClass(schema1, schema2) {
|
|
8884
|
-
for (const schemaClass of this.extendsSchemaClasses) {
|
|
8885
|
-
if (schema1 instanceof schemaClass) return schemaClass;
|
|
8886
|
-
if (schema2 instanceof schemaClass) return schemaClass;
|
|
8887
|
-
}
|
|
8888
|
-
throw new Error("Invalid schema");
|
|
8889
|
-
}
|
|
8890
|
-
static swap(expression) {
|
|
8891
|
-
switch (expression) {
|
|
8892
|
-
case ExpressionSingleResult.Containing: return ExpressionSingleResult.ContainedBy;
|
|
8893
|
-
case ExpressionSingleResult.ContainedBy: return ExpressionSingleResult.Containing;
|
|
8894
|
-
default: return expression;
|
|
8895
|
-
}
|
|
8896
|
-
}
|
|
8868
|
+
var base = {
|
|
8869
|
+
maxExecutions: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
8870
|
+
inputs,
|
|
8871
|
+
name: text.optional(),
|
|
8872
|
+
description: text.optional(),
|
|
8873
|
+
icon: text.optional(),
|
|
8874
|
+
timeoutMs: number().optional()
|
|
8897
8875
|
};
|
|
8898
|
-
|
|
8899
|
-
|
|
8900
|
-
|
|
8901
|
-
|
|
8902
|
-
|
|
8903
|
-
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
|
|
8907
|
-
|
|
8908
|
-
|
|
8909
|
-
|
|
8910
|
-
|
|
8911
|
-
|
|
8912
|
-
|
|
8913
|
-
|
|
8914
|
-
|
|
8915
|
-
|
|
8916
|
-
|
|
8917
|
-
|
|
8918
|
-
|
|
8919
|
-
|
|
8920
|
-
|
|
8921
|
-
|
|
8922
|
-
|
|
8923
|
-
|
|
8924
|
-
|
|
8925
|
-
|
|
8926
|
-
|
|
8927
|
-
|
|
8928
|
-
|
|
8929
|
-
|
|
8930
|
-
}
|
|
8931
|
-
|
|
8932
|
-
|
|
8933
|
-
|
|
8934
|
-
|
|
8935
|
-
|
|
8936
|
-
|
|
8937
|
-
|
|
8938
|
-
|
|
8939
|
-
|
|
8940
|
-
}
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8876
|
+
var node = union([
|
|
8877
|
+
object({
|
|
8878
|
+
...base,
|
|
8879
|
+
inputs: record$3(text, never()),
|
|
8880
|
+
kind: literal("condition"),
|
|
8881
|
+
...condition
|
|
8882
|
+
}),
|
|
8883
|
+
object({
|
|
8884
|
+
...base,
|
|
8885
|
+
inputs: unknown().transform(() => ({})).default({}),
|
|
8886
|
+
kind: literal("value"),
|
|
8887
|
+
values: array(input)
|
|
8888
|
+
}),
|
|
8889
|
+
object({
|
|
8890
|
+
...base,
|
|
8891
|
+
kind: literal("task"),
|
|
8892
|
+
task: union([inline, managed]),
|
|
8893
|
+
additionalInputs: array(input).optional()
|
|
8894
|
+
}),
|
|
8895
|
+
strictObject({
|
|
8896
|
+
...base,
|
|
8897
|
+
kind: literal("approval"),
|
|
8898
|
+
...wait
|
|
8899
|
+
}).omit({ timeoutMs: true }),
|
|
8900
|
+
strictObject({
|
|
8901
|
+
...base,
|
|
8902
|
+
kind: literal("wait"),
|
|
8903
|
+
...wait
|
|
8904
|
+
}).omit({ timeoutMs: true }),
|
|
8905
|
+
object({
|
|
8906
|
+
...trigger,
|
|
8907
|
+
kind: literal("manual")
|
|
8908
|
+
}),
|
|
8909
|
+
strictObject({
|
|
8910
|
+
...trigger,
|
|
8911
|
+
kind: literal("error"),
|
|
8912
|
+
sourceFlowIds: sourceFlowIds.optional()
|
|
8913
|
+
}),
|
|
8914
|
+
object({
|
|
8915
|
+
...trigger,
|
|
8916
|
+
kind: literal("webhook"),
|
|
8917
|
+
...webhook
|
|
8918
|
+
}),
|
|
8919
|
+
object({
|
|
8920
|
+
...trigger,
|
|
8921
|
+
kind: literal("cron"),
|
|
8922
|
+
cronTimes: triggerScheduleSchema
|
|
8923
|
+
}),
|
|
8924
|
+
object({
|
|
8925
|
+
...trigger,
|
|
8926
|
+
kind: literal("poll"),
|
|
8927
|
+
connectionId: text.min(1).optional(),
|
|
8928
|
+
config: record$3(text, fixedInput),
|
|
8929
|
+
definition: object({
|
|
8930
|
+
...definition,
|
|
8931
|
+
type: literal("poll")
|
|
8932
|
+
}),
|
|
8933
|
+
pollTimes: triggerScheduleSchema
|
|
8934
|
+
}),
|
|
8935
|
+
object({
|
|
8936
|
+
...trigger,
|
|
8937
|
+
kind: literal("integration"),
|
|
8938
|
+
connectionId: text.min(1).optional(),
|
|
8939
|
+
config: record$3(text, fixedInput),
|
|
8940
|
+
definition: object({
|
|
8941
|
+
...definition,
|
|
8942
|
+
type: literal("integration"),
|
|
8943
|
+
endpoint
|
|
8944
|
+
})
|
|
8945
|
+
})
|
|
8946
|
+
]);
|
|
8947
|
+
/** Configuration schemas shared by the node authoring boundary. */
|
|
8948
|
+
var authoringDefinitionSchemas = {
|
|
8949
|
+
input,
|
|
8950
|
+
port: port$1,
|
|
8951
|
+
ports: ports$1,
|
|
8952
|
+
condition: strictObject(condition),
|
|
8953
|
+
wait: strictObject(wait),
|
|
8954
|
+
webhook: strictObject(webhook),
|
|
8955
|
+
schedule: triggerScheduleSchema,
|
|
8956
|
+
capabilities: array(capability),
|
|
8957
|
+
connector: managedFields.shape.executor.options[0].omit({ kind: true }).strict(),
|
|
8958
|
+
openapi: managedFields.shape.executor.options[1].omit({ kind: true }).strict(),
|
|
8959
|
+
decision: managedFields.shape.executor.options[2].omit({ kind: true }).strict(),
|
|
8960
|
+
llm: managedFields.shape.executor.options[3].omit({ kind: true }).strict(),
|
|
8961
|
+
agent: managedFields.shape.executor.options[4].omit({
|
|
8962
|
+
kind: true,
|
|
8963
|
+
notification: true
|
|
8964
|
+
}).strict()
|
|
8965
|
+
};
|
|
8966
|
+
var edge = object({
|
|
8967
|
+
source: text,
|
|
8968
|
+
target: text,
|
|
8969
|
+
sourceHandle: text.optional()
|
|
8970
|
+
});
|
|
8971
|
+
var at = {
|
|
8972
|
+
nodeId: text,
|
|
8973
|
+
target: never().optional()
|
|
8974
|
+
};
|
|
8975
|
+
var graph = object({
|
|
8976
|
+
nodes: record$3(text, node),
|
|
8977
|
+
edges: array(edge).default([])
|
|
8978
|
+
});
|
|
8979
|
+
var binding$1 = object({
|
|
8980
|
+
kind: literal("variable"),
|
|
8981
|
+
target: text
|
|
8982
|
+
});
|
|
8983
|
+
var module = object({
|
|
8984
|
+
name: text,
|
|
8985
|
+
imports: strings$1,
|
|
8986
|
+
source: text
|
|
8948
8987
|
});
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
8953
|
-
|
|
8954
|
-
|
|
8955
|
-
|
|
8956
|
-
|
|
8957
|
-
|
|
8958
|
-
|
|
8959
|
-
|
|
8960
|
-
|
|
8961
|
-
|
|
8962
|
-
|
|
8963
|
-
|
|
8964
|
-
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
|
|
8968
|
-
|
|
8969
|
-
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
8973
|
-
|
|
8974
|
-
|
|
8975
|
-
var isObject = (x) => x !== null && typeof x === "object";
|
|
8976
|
-
var isPlainObject = (x) => isObject(x) && !isArray(x);
|
|
8977
|
-
var toPlainObject = (x) => isPlainObject(x) ? x : void 0;
|
|
8978
|
-
//#endregion
|
|
8979
|
-
//#region src/flow/common/schemaComparer.ts
|
|
8980
|
-
function isStringLikeSchema(value) {
|
|
8981
|
-
return toPlainObject(value)?.type === "string";
|
|
8988
|
+
var document = preprocess(rejectRetiredDefinitions, object({
|
|
8989
|
+
bindings: record$3(text, binding$1),
|
|
8990
|
+
graph
|
|
8991
|
+
}));
|
|
8992
|
+
var revision = object({
|
|
8993
|
+
modelVersion: union([
|
|
8994
|
+
literal(2),
|
|
8995
|
+
literal(4),
|
|
8996
|
+
literal(5),
|
|
8997
|
+
literal(6)
|
|
8998
|
+
]),
|
|
8999
|
+
document,
|
|
9000
|
+
modules: record$3(text, module)
|
|
9001
|
+
});
|
|
9002
|
+
revision.extend({
|
|
9003
|
+
kind: literal("open-flow-flow-revision"),
|
|
9004
|
+
version: literal(1)
|
|
9005
|
+
});
|
|
9006
|
+
function rejectRetiredDefinitions(value) {
|
|
9007
|
+
const candidate = record$2(value);
|
|
9008
|
+
if (candidate.tasks !== void 0 && (candidate.tasks === null || typeof candidate.tasks !== "object" || Array.isArray(candidate.tasks) || Object.keys(candidate.tasks).length > 0)) throw new TypeError("Independent Task definitions are no longer supported.");
|
|
9009
|
+
if (Object.values(record$2(record$2(candidate.graph).nodes)).some((candidateNode) => Object.hasOwn(record$2(candidateNode), "taskId"))) throw new TypeError("Task references are no longer supported.");
|
|
9010
|
+
const subflows = candidate.subflows;
|
|
9011
|
+
if (subflows !== void 0 && (subflows === null || typeof subflows !== "object" || Array.isArray(subflows) || Object.keys(subflows).length > 0)) throw new TypeError("Subflows are no longer supported.");
|
|
9012
|
+
if (Object.values(record$2(record$2(candidate.graph).nodes)).some((candidateNode) => record$2(candidateNode).kind === "subflow")) throw new TypeError("Subflow nodes are no longer supported.");
|
|
9013
|
+
return value;
|
|
8982
9014
|
}
|
|
8983
|
-
function
|
|
8984
|
-
|
|
8985
|
-
const error = toPlainObject(context?.error);
|
|
8986
|
-
if (context == null || error == null || context.packageId != null && !isString(context.packageId) || error.message != null && !isString(error.message)) throw new TypeError("Invalid schema comparison context.");
|
|
9015
|
+
function record$2(value) {
|
|
9016
|
+
return value != null && typeof value == "object" && !Array.isArray(value) ? value : {};
|
|
8987
9017
|
}
|
|
8988
|
-
function
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
9018
|
+
function decodeRevisionContent(value) {
|
|
9019
|
+
checkJsonDepth(value);
|
|
9020
|
+
const content = revision.parse(value);
|
|
9021
|
+
checkModelVersion(content);
|
|
9022
|
+
assertOpenApiAuthBindings(content.document);
|
|
9023
|
+
return content;
|
|
8992
9024
|
}
|
|
8993
|
-
var
|
|
8994
|
-
|
|
8995
|
-
|
|
8996
|
-
|
|
8997
|
-
|
|
8998
|
-
|
|
8999
|
-
|
|
9000
|
-
|
|
9001
|
-
|
|
9002
|
-
}
|
|
9003
|
-
|
|
9004
|
-
|
|
9005
|
-
|
|
9006
|
-
|
|
9007
|
-
|
|
9008
|
-
|
|
9009
|
-
|
|
9010
|
-
|
|
9011
|
-
|
|
9012
|
-
}
|
|
9013
|
-
|
|
9014
|
-
|
|
9015
|
-
|
|
9016
|
-
}
|
|
9017
|
-
|
|
9018
|
-
|
|
9019
|
-
|
|
9020
|
-
|
|
9021
|
-
|
|
9022
|
-
|
|
9023
|
-
|
|
9024
|
-
|
|
9025
|
-
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
|
|
9032
|
-
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9056
|
-
|
|
9057
|
-
|
|
9058
|
-
|
|
9059
|
-
|
|
9060
|
-
|
|
9061
|
-
|
|
9062
|
-
|
|
9063
|
-
|
|
9064
|
-
|
|
9065
|
-
|
|
9066
|
-
}
|
|
9067
|
-
|
|
9068
|
-
|
|
9069
|
-
|
|
9070
|
-
|
|
9071
|
-
|
|
9072
|
-
|
|
9073
|
-
|
|
9074
|
-
|
|
9075
|
-
|
|
9076
|
-
|
|
9077
|
-
|
|
9025
|
+
var shapes = {
|
|
9026
|
+
"graph.trigger.sources.set": {
|
|
9027
|
+
nodeId: text,
|
|
9028
|
+
before: sourceFlowIds.optional(),
|
|
9029
|
+
value: sourceFlowIds.optional()
|
|
9030
|
+
},
|
|
9031
|
+
"binding.create": {
|
|
9032
|
+
bindingId: text,
|
|
9033
|
+
binding: binding$1
|
|
9034
|
+
},
|
|
9035
|
+
"binding.delete": { bindingId: text },
|
|
9036
|
+
"binding.target.set": {
|
|
9037
|
+
bindingId: text,
|
|
9038
|
+
before: text,
|
|
9039
|
+
value: text
|
|
9040
|
+
},
|
|
9041
|
+
"graph.edge.connect": {
|
|
9042
|
+
edge,
|
|
9043
|
+
target: never().optional()
|
|
9044
|
+
},
|
|
9045
|
+
"graph.edge.disconnect": {
|
|
9046
|
+
edge,
|
|
9047
|
+
target: never().optional()
|
|
9048
|
+
},
|
|
9049
|
+
"graph.node.create": {
|
|
9050
|
+
...at,
|
|
9051
|
+
node
|
|
9052
|
+
},
|
|
9053
|
+
"graph.node.replace": {
|
|
9054
|
+
...at,
|
|
9055
|
+
before: node,
|
|
9056
|
+
node
|
|
9057
|
+
},
|
|
9058
|
+
"graph.node.delete": at,
|
|
9059
|
+
"graph.node.field.set": union([
|
|
9060
|
+
object({
|
|
9061
|
+
...at,
|
|
9062
|
+
kind: literal("graph.node.field.set"),
|
|
9063
|
+
field: literal("connectionId"),
|
|
9064
|
+
before: text.min(1).optional(),
|
|
9065
|
+
value: text.min(1).optional()
|
|
9066
|
+
}),
|
|
9067
|
+
object({
|
|
9068
|
+
...at,
|
|
9069
|
+
kind: literal("graph.node.field.set"),
|
|
9070
|
+
field: _enum([
|
|
9071
|
+
"description",
|
|
9072
|
+
"icon",
|
|
9073
|
+
"name"
|
|
9074
|
+
]),
|
|
9075
|
+
before: text.optional(),
|
|
9076
|
+
value: text.optional()
|
|
9077
|
+
}),
|
|
9078
|
+
object({
|
|
9079
|
+
...at,
|
|
9080
|
+
kind: literal("graph.node.field.set"),
|
|
9081
|
+
field: literal("maxExecutions"),
|
|
9082
|
+
before: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
9083
|
+
value: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional()
|
|
9084
|
+
}),
|
|
9085
|
+
object({
|
|
9086
|
+
...at,
|
|
9087
|
+
kind: literal("graph.node.field.set"),
|
|
9088
|
+
field: literal("timeoutMs"),
|
|
9089
|
+
before: number().optional(),
|
|
9090
|
+
value: number().optional()
|
|
9091
|
+
})
|
|
9092
|
+
]),
|
|
9093
|
+
"graph.node.input.set": {
|
|
9094
|
+
...at,
|
|
9095
|
+
handle: text,
|
|
9096
|
+
before: mapping.optional(),
|
|
9097
|
+
value: mapping.optional()
|
|
9098
|
+
},
|
|
9099
|
+
"graph.node.additional-inputs.set": {
|
|
9100
|
+
...at,
|
|
9101
|
+
before: array(input).optional(),
|
|
9102
|
+
value: array(input).optional()
|
|
9103
|
+
},
|
|
9104
|
+
"graph.node.condition.set": {
|
|
9105
|
+
...at,
|
|
9106
|
+
before: object(condition),
|
|
9107
|
+
value: object(condition)
|
|
9108
|
+
},
|
|
9109
|
+
"graph.node.values.set": {
|
|
9110
|
+
...at,
|
|
9111
|
+
before: array(input),
|
|
9112
|
+
value: array(input)
|
|
9113
|
+
},
|
|
9114
|
+
"graph.node.resolution.set": {
|
|
9115
|
+
...at,
|
|
9116
|
+
before: object(wait),
|
|
9117
|
+
value: object(wait)
|
|
9118
|
+
},
|
|
9119
|
+
"graph.node.webhook.set": {
|
|
9120
|
+
...at,
|
|
9121
|
+
before: object(webhook),
|
|
9122
|
+
value: object(webhook)
|
|
9123
|
+
},
|
|
9124
|
+
"graph.node.task.ports.set": {
|
|
9125
|
+
...at,
|
|
9126
|
+
before: object(ports$1),
|
|
9127
|
+
value: object(ports$1)
|
|
9128
|
+
},
|
|
9129
|
+
"graph.node.task.name.set": {
|
|
9130
|
+
...at,
|
|
9131
|
+
before: text,
|
|
9132
|
+
value: text
|
|
9133
|
+
},
|
|
9134
|
+
"graph.node.task.capabilities.set": {
|
|
9135
|
+
...at,
|
|
9136
|
+
before: array(capability).optional(),
|
|
9137
|
+
value: array(capability).optional()
|
|
9138
|
+
},
|
|
9139
|
+
"graph.trigger.config.set": {
|
|
9140
|
+
nodeId: text,
|
|
9141
|
+
name: text,
|
|
9142
|
+
before: fixedInput.optional(),
|
|
9143
|
+
value: fixedInput.optional()
|
|
9144
|
+
},
|
|
9145
|
+
"graph.trigger.schedule.set": {
|
|
9146
|
+
nodeId: text,
|
|
9147
|
+
before: triggerScheduleSchema,
|
|
9148
|
+
value: triggerScheduleSchema
|
|
9149
|
+
},
|
|
9150
|
+
"module.create": {
|
|
9151
|
+
moduleId: text,
|
|
9152
|
+
module
|
|
9153
|
+
},
|
|
9154
|
+
"module.delete": { moduleId: text },
|
|
9155
|
+
"module.rename": {
|
|
9156
|
+
moduleId: text,
|
|
9157
|
+
before: text,
|
|
9158
|
+
name: text
|
|
9159
|
+
},
|
|
9160
|
+
"module.source.replace": {
|
|
9161
|
+
moduleId: text,
|
|
9162
|
+
beforeImports: strings$1,
|
|
9163
|
+
beforeSource: text,
|
|
9164
|
+
imports: strings$1,
|
|
9165
|
+
source: text
|
|
9166
|
+
},
|
|
9167
|
+
"graph.node.task.set": {
|
|
9168
|
+
...at,
|
|
9169
|
+
before: union([inline, managed]),
|
|
9170
|
+
value: union([inline, managed])
|
|
9078
9171
|
}
|
|
9079
9172
|
};
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
|
|
9083
|
-
|
|
9084
|
-
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
createSchemaComparer();
|
|
9088
|
-
//#endregion
|
|
9089
|
-
//#region src/decision/common/decision.ts
|
|
9090
|
-
var decisionLimits = {
|
|
9091
|
-
choice: 255,
|
|
9092
|
-
score: 10
|
|
9093
|
-
};
|
|
9094
|
-
/** Ordered prefixes are shared by authoring, schemas, validation, and execution. */
|
|
9095
|
-
function limitDecisionQuestion(question) {
|
|
9096
|
-
if (question.type === "noul" || question.criteria.length <= decisionLimits[question.type]) return question;
|
|
9097
|
-
if (question.type === "choice") return {
|
|
9098
|
-
...question,
|
|
9099
|
-
criteria: question.criteria.slice(0, decisionLimits.choice)
|
|
9100
|
-
};
|
|
9101
|
-
return {
|
|
9102
|
-
...question,
|
|
9103
|
-
criteria: question.criteria.slice(0, decisionLimits.score)
|
|
9104
|
-
};
|
|
9105
|
-
}
|
|
9106
|
-
function limitDecisionQuestions(questions) {
|
|
9107
|
-
const limited = questions.map(limitDecisionQuestion);
|
|
9108
|
-
return limited.every((question, i) => question === questions[i]) ? questions : limited;
|
|
9109
|
-
}
|
|
9110
|
-
/** Loading an oversized task also updates its previously generated output schemas. */
|
|
9111
|
-
function limitDecisionTask(task) {
|
|
9112
|
-
if (task.executor.kind !== "decision") return task;
|
|
9113
|
-
const original = task.executor.questions;
|
|
9114
|
-
const questions = limitDecisionQuestions(original);
|
|
9115
|
-
if (questions === original) return task;
|
|
9116
|
-
const outputs = task.outputs.map((port) => {
|
|
9117
|
-
if (!("handle" in port)) return port;
|
|
9118
|
-
const index = original.findIndex((question) => question.name === port.handle);
|
|
9119
|
-
if (index < 0 || original[index] === questions[index] || !dequal(port.jsonSchema, answerSchema(original[index]))) return port;
|
|
9120
|
-
return {
|
|
9121
|
-
...port,
|
|
9122
|
-
jsonSchema: decisionAnswerSchema(questions[index])
|
|
9123
|
-
};
|
|
9124
|
-
});
|
|
9125
|
-
return {
|
|
9126
|
-
...task,
|
|
9127
|
-
executor: {
|
|
9128
|
-
...task.executor,
|
|
9129
|
-
questions
|
|
9130
|
-
},
|
|
9131
|
-
outputs
|
|
9132
|
-
};
|
|
9133
|
-
}
|
|
9134
|
-
var probability = {
|
|
9135
|
-
type: "number",
|
|
9136
|
-
minimum: 0,
|
|
9137
|
-
maximum: 1
|
|
9138
|
-
};
|
|
9139
|
-
function decisionAnswerSchema(question) {
|
|
9140
|
-
return answerSchema(limitDecisionQuestion(question));
|
|
9141
|
-
}
|
|
9142
|
-
function answerSchema(question) {
|
|
9143
|
-
const properties = { type: { const: question.type } };
|
|
9144
|
-
if (question.type === "noul") properties.noul = probability;
|
|
9145
|
-
else {
|
|
9146
|
-
const keys = question.type === "choice" ? question.criteria.map((item) => item.name) : question.criteria.map((_, index) => String(index));
|
|
9147
|
-
properties.confidence = probability;
|
|
9148
|
-
properties.probabilities = {
|
|
9149
|
-
type: "object",
|
|
9150
|
-
properties: Object.fromEntries(keys.map((key) => [key, probability])),
|
|
9151
|
-
required: keys,
|
|
9152
|
-
additionalProperties: false
|
|
9153
|
-
};
|
|
9154
|
-
if (question.type === "choice") properties.choice = {
|
|
9155
|
-
type: "string",
|
|
9156
|
-
...keys.length ? { enum: keys } : {}
|
|
9157
|
-
};
|
|
9158
|
-
else {
|
|
9159
|
-
properties.score = {
|
|
9160
|
-
type: "number",
|
|
9161
|
-
minimum: 0,
|
|
9162
|
-
maximum: Math.max(0, keys.length - 1)
|
|
9163
|
-
};
|
|
9164
|
-
properties.legend = {
|
|
9165
|
-
type: "object",
|
|
9166
|
-
properties: Object.fromEntries(keys.map((key) => [key, { type: "string" }])),
|
|
9167
|
-
required: keys,
|
|
9168
|
-
additionalProperties: false
|
|
9169
|
-
};
|
|
9170
|
-
}
|
|
9171
|
-
}
|
|
9172
|
-
return {
|
|
9173
|
-
type: "object",
|
|
9174
|
-
properties,
|
|
9175
|
-
required: Object.keys(properties)
|
|
9176
|
-
};
|
|
9173
|
+
array(union([...new Map(Object.entries(shapes).map(([kind, shape]) => [kind, shape instanceof ZodType ? shape : object({
|
|
9174
|
+
kind: literal(kind),
|
|
9175
|
+
...shape
|
|
9176
|
+
})])).values()])).min(1);
|
|
9177
|
+
function checkModelVersion(content) {
|
|
9178
|
+
if (content.modelVersion < 6 && Object.values(content.document.graph.nodes).some((candidateNode) => candidateNode.kind == "task" && "executor" in candidateNode.task)) throw new TypeError("Node-owned managed Tasks require Flow model version 6.");
|
|
9179
|
+
if (content.modelVersion < 5 && Object.values(content.document.graph.nodes).some((itemNode) => itemNode.kind == "error")) throw new TypeError("Error workflows require Flow model version 5.");
|
|
9177
9180
|
}
|
|
9178
9181
|
//#endregion
|
|
9179
9182
|
//#region src/control/common/authoringLlm.ts
|
|
@@ -9195,7 +9198,7 @@ var authenticationSchema = union([
|
|
|
9195
9198
|
in: _enum(["header", "query"])
|
|
9196
9199
|
})
|
|
9197
9200
|
]);
|
|
9198
|
-
strictObject({
|
|
9201
|
+
var authoringOpenApiSchema = strictObject({
|
|
9199
9202
|
sourceUrl: string$1().min(1),
|
|
9200
9203
|
path: string$1().min(1),
|
|
9201
9204
|
method: string$1().min(1),
|
|
@@ -9292,36 +9295,53 @@ var when = union([
|
|
|
9292
9295
|
all,
|
|
9293
9296
|
strictObject({ any: array(union([expression, all])) })
|
|
9294
9297
|
]);
|
|
9295
|
-
|
|
9296
|
-
|
|
9297
|
-
|
|
9298
|
-
|
|
9299
|
-
|
|
9300
|
-
|
|
9301
|
-
|
|
9302
|
-
|
|
9303
|
-
|
|
9304
|
-
|
|
9305
|
-
|
|
9306
|
-
|
|
9307
|
-
|
|
9308
|
-
|
|
9309
|
-
|
|
9310
|
-
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
|
|
9319
|
-
|
|
9320
|
-
|
|
9321
|
-
|
|
9322
|
-
|
|
9323
|
-
|
|
9324
|
-
})
|
|
9298
|
+
var authoringConfigurations = {
|
|
9299
|
+
manual: strictObject({}),
|
|
9300
|
+
error: strictObject({ sourceFlowIds: array(id$1).optional() }),
|
|
9301
|
+
webhook: authoringDefinitionSchemas.webhook.omit({ bodyFields: true }).extend({ body: inputFields }).strict(),
|
|
9302
|
+
cron: strictObject({ schedule: authoringDefinitionSchemas.schedule }),
|
|
9303
|
+
poll: strictObject({
|
|
9304
|
+
key: id$1,
|
|
9305
|
+
connectionId: id$1.optional(),
|
|
9306
|
+
schedule: authoringDefinitionSchemas.schedule
|
|
9307
|
+
}),
|
|
9308
|
+
integration: strictObject({
|
|
9309
|
+
key: id$1,
|
|
9310
|
+
connectionId: id$1.optional()
|
|
9311
|
+
}),
|
|
9312
|
+
code: strictObject({
|
|
9313
|
+
inputs: inputFields,
|
|
9314
|
+
outputs: outputFields,
|
|
9315
|
+
capabilities: authoringDefinitionSchemas.capabilities.optional()
|
|
9316
|
+
}),
|
|
9317
|
+
connector: authoringDefinitionSchemas.connector.strict(),
|
|
9318
|
+
openapi: authoringOpenApiSchema,
|
|
9319
|
+
agent: authoringDefinitionSchemas.agent.omit({
|
|
9320
|
+
prompt: true,
|
|
9321
|
+
tools: true
|
|
9322
|
+
}).extend({
|
|
9323
|
+
inputs: inputFields,
|
|
9324
|
+
resultSchema: json$2.describe("JSON schema of the final result. Defaults to text. The tool manages the output definition; references can omit port."),
|
|
9325
|
+
tools: array(agentTool),
|
|
9326
|
+
notification: notification.optional()
|
|
9327
|
+
}).strict(),
|
|
9328
|
+
llm: authoringLlmConfiguration.extend({ inputs: inputFields }),
|
|
9329
|
+
decision: authoringDefinitionSchemas.decision,
|
|
9330
|
+
condition: strictObject({
|
|
9331
|
+
match: _enum(["first", "all"]),
|
|
9332
|
+
branches: array(strictObject({
|
|
9333
|
+
name: id$1,
|
|
9334
|
+
description: string$1().optional(),
|
|
9335
|
+
when
|
|
9336
|
+
}))
|
|
9337
|
+
}),
|
|
9338
|
+
value: strictObject({
|
|
9339
|
+
values: patch,
|
|
9340
|
+
outputs: outputFields
|
|
9341
|
+
}),
|
|
9342
|
+
wait: strictObject({ inputs: inputFields }),
|
|
9343
|
+
approval: strictObject({ inputs: inputFields })
|
|
9344
|
+
};
|
|
9325
9345
|
var updates = strictObject({
|
|
9326
9346
|
name: id$1.optional(),
|
|
9327
9347
|
description: string$1().optional(),
|
|
@@ -9501,7 +9521,6 @@ var controlErrorCode = {
|
|
|
9501
9521
|
publicationConflict: "publication.conflict",
|
|
9502
9522
|
publicationNotFound: "publication.not-found",
|
|
9503
9523
|
publicationUnsupported: "publication.unsupported",
|
|
9504
|
-
resourceNotFound: "resource.not-found",
|
|
9505
9524
|
publishOperationNotFound: "publication.operation-not-found",
|
|
9506
9525
|
routeNotFound: "route.not-found",
|
|
9507
9526
|
runConflict: "run.conflict",
|
|
@@ -9518,7 +9537,7 @@ var controlErrorCode = {
|
|
|
9518
9537
|
variableLimitReached: "variable.limit-reached",
|
|
9519
9538
|
variableNotFound: "variable.not-found"
|
|
9520
9539
|
};
|
|
9521
|
-
controlErrorCode.eventSourceInvalid, controlErrorCode.eventSourceIdentityUnavailable, controlErrorCode.eventSourceNotFound, controlErrorCode.eventSourceConflict, controlErrorCode.authenticationRequired, controlErrorCode.authorizationDenied, controlErrorCode.bindingUnresolved, controlErrorCode.connectorActionNotFound, controlErrorCode.connectorAccessConflict, controlErrorCode.connectorAccessInvalid, controlErrorCode.connectorAccessRequired, controlErrorCode.connectorAccessUnsupported, controlErrorCode.connectorUnconfigured, controlErrorCode.connectorUnavailable, controlErrorCode.connectorConsoleUnconfigured, controlErrorCode.engineUnavailable, controlErrorCode.engineUnsupported, controlErrorCode.flowInvalid, controlErrorCode.flowRepairRequired, controlErrorCode.flowUpgradeRequired, controlErrorCode.flowNotFound, controlErrorCode.flowBusy, controlErrorCode.flowConflict, controlErrorCode.flowPresentationConflict, controlErrorCode.flowRevisionConflict, controlErrorCode.liveConflict, controlErrorCode.liveNotFound, controlErrorCode.pageInvalidCursor, controlErrorCode.publicationConflict, controlErrorCode.publicationNotFound, controlErrorCode.publicationUnsupported, controlErrorCode.
|
|
9540
|
+
controlErrorCode.eventSourceInvalid, controlErrorCode.eventSourceIdentityUnavailable, controlErrorCode.eventSourceNotFound, controlErrorCode.eventSourceConflict, controlErrorCode.authenticationRequired, controlErrorCode.authorizationDenied, controlErrorCode.bindingUnresolved, controlErrorCode.connectorActionNotFound, controlErrorCode.connectorAccessConflict, controlErrorCode.connectorAccessInvalid, controlErrorCode.connectorAccessRequired, controlErrorCode.connectorAccessUnsupported, controlErrorCode.connectorUnconfigured, controlErrorCode.connectorUnavailable, controlErrorCode.connectorConsoleUnconfigured, controlErrorCode.engineUnavailable, controlErrorCode.engineUnsupported, controlErrorCode.flowInvalid, controlErrorCode.flowRepairRequired, controlErrorCode.flowUpgradeRequired, controlErrorCode.flowNotFound, controlErrorCode.flowBusy, controlErrorCode.flowConflict, controlErrorCode.flowPresentationConflict, controlErrorCode.flowRevisionConflict, controlErrorCode.liveConflict, controlErrorCode.liveNotFound, controlErrorCode.pageInvalidCursor, controlErrorCode.publicationConflict, controlErrorCode.publicationNotFound, controlErrorCode.publicationUnsupported, controlErrorCode.publishOperationNotFound, controlErrorCode.routeNotFound, controlErrorCode.runConflict, controlErrorCode.runEventsExpired, controlErrorCode.runInvalid, controlErrorCode.runNotFound, controlErrorCode.runNotTerminal, controlErrorCode.runOverloaded, controlErrorCode.runWaitNotFound, controlErrorCode.triggerKeyInvalid, controlErrorCode.triggerKeyNotFound, controlErrorCode.triggerNotFound, controlErrorCode.variableInvalid, controlErrorCode.variableLimitReached, controlErrorCode.variableNotFound;
|
|
9522
9541
|
var ApiError = class extends Error {
|
|
9523
9542
|
constructor(status, code, message, details) {
|
|
9524
9543
|
super(message);
|
|
@@ -9554,19 +9573,155 @@ function exact(value, keys) {
|
|
|
9554
9573
|
invalidResponse([missing.length > 0 ? `Missing fields: ${missing.join(", ")}.` : "", unexpected.length > 0 ? `Unexpected fields: ${unexpected.join(", ")}.` : ""].filter(Boolean).join(" "));
|
|
9555
9574
|
}
|
|
9556
9575
|
}
|
|
9557
|
-
function integer(value) {
|
|
9558
|
-
return Number.isSafeInteger(value) ? value : invalidResponse("Expected a safe integer.");
|
|
9559
|
-
}
|
|
9560
|
-
function jsonValue(value) {
|
|
9561
|
-
if (value === null || typeof value == "boolean" || typeof value == "string") return value;
|
|
9562
|
-
if (typeof value == "number" && Number.isFinite(value)) return value;
|
|
9563
|
-
if (Array.isArray(value)) return value.map(jsonValue);
|
|
9576
|
+
function integer(value) {
|
|
9577
|
+
return Number.isSafeInteger(value) ? value : invalidResponse("Expected a safe integer.");
|
|
9578
|
+
}
|
|
9579
|
+
function jsonValue(value) {
|
|
9580
|
+
if (value === null || typeof value == "boolean" || typeof value == "string") return value;
|
|
9581
|
+
if (typeof value == "number" && Number.isFinite(value)) return value;
|
|
9582
|
+
if (Array.isArray(value)) return value.map(jsonValue);
|
|
9583
|
+
const source = record$1(value);
|
|
9584
|
+
return Object.fromEntries(Object.entries(source).map(([key, item]) => [key, jsonValue(item)]));
|
|
9585
|
+
}
|
|
9586
|
+
function optionalString(value) {
|
|
9587
|
+
if (value == null) return;
|
|
9588
|
+
return string(value);
|
|
9589
|
+
}
|
|
9590
|
+
//#endregion
|
|
9591
|
+
//#region src/control/common/publicationDecoders.ts
|
|
9592
|
+
function publication(value) {
|
|
9593
|
+
const source = record$1(value);
|
|
9594
|
+
const liveEnd = source.liveEnd == null ? void 0 : record$1(source.liveEnd);
|
|
9595
|
+
if (liveEnd != null && typeof liveEnd.enabled != "boolean") return invalidResponse();
|
|
9596
|
+
const operation = source.operation;
|
|
9597
|
+
const sourcePublicationId = source.sourcePublicationId;
|
|
9598
|
+
if (source.version != 1) return invalidResponse();
|
|
9599
|
+
if (operation != "publish" && operation != "rollback") return invalidResponse();
|
|
9600
|
+
if (sourcePublicationId != null && typeof sourcePublicationId != "string") return invalidResponse();
|
|
9601
|
+
return {
|
|
9602
|
+
...liveEnd == null ? {} : { liveEnd: {
|
|
9603
|
+
enabled: liveEnd.enabled,
|
|
9604
|
+
endedAt: string(liveEnd.endedAt)
|
|
9605
|
+
} },
|
|
9606
|
+
actorId: string(source.actorId),
|
|
9607
|
+
closureDigest: string(source.closureDigest),
|
|
9608
|
+
createdAt: string(source.createdAt),
|
|
9609
|
+
engineContract: string(source.engineContract),
|
|
9610
|
+
flowId: string(source.flowId),
|
|
9611
|
+
modelVersion: integer(source.modelVersion),
|
|
9612
|
+
operation,
|
|
9613
|
+
publicationId: string(source.publicationId),
|
|
9614
|
+
sharedAccessDigest: string(source.sharedAccessDigest),
|
|
9615
|
+
revisionDigest: string(source.revisionDigest),
|
|
9616
|
+
revisionId: string(source.revisionId),
|
|
9617
|
+
...sourcePublicationId == null ? {} : { sourcePublicationId },
|
|
9618
|
+
version: 1
|
|
9619
|
+
};
|
|
9620
|
+
}
|
|
9621
|
+
function publishOperation(value) {
|
|
9622
|
+
const source = record$1(value);
|
|
9623
|
+
const status = source.status;
|
|
9624
|
+
const common = {
|
|
9625
|
+
createdAt: string(source.createdAt),
|
|
9626
|
+
flowId: string(source.flowId),
|
|
9627
|
+
operationId: string(source.operationId),
|
|
9628
|
+
revisionId: string(source.revisionId),
|
|
9629
|
+
updatedAt: string(source.updatedAt),
|
|
9630
|
+
version: 1
|
|
9631
|
+
};
|
|
9632
|
+
if (source.version != 1) return invalidResponse();
|
|
9633
|
+
switch (status) {
|
|
9634
|
+
case "pending":
|
|
9635
|
+
exact(source, [
|
|
9636
|
+
"createdAt",
|
|
9637
|
+
"flowId",
|
|
9638
|
+
"operationId",
|
|
9639
|
+
"revisionId",
|
|
9640
|
+
"status",
|
|
9641
|
+
"updatedAt",
|
|
9642
|
+
"version"
|
|
9643
|
+
]);
|
|
9644
|
+
return {
|
|
9645
|
+
...common,
|
|
9646
|
+
status
|
|
9647
|
+
};
|
|
9648
|
+
case "succeeded":
|
|
9649
|
+
exact(source, [
|
|
9650
|
+
"createdAt",
|
|
9651
|
+
"flowId",
|
|
9652
|
+
"operationId",
|
|
9653
|
+
"publicationId",
|
|
9654
|
+
"revisionId",
|
|
9655
|
+
"status",
|
|
9656
|
+
"updatedAt",
|
|
9657
|
+
"version"
|
|
9658
|
+
]);
|
|
9659
|
+
return {
|
|
9660
|
+
...common,
|
|
9661
|
+
publicationId: string(source.publicationId),
|
|
9662
|
+
status
|
|
9663
|
+
};
|
|
9664
|
+
case "failed": {
|
|
9665
|
+
exact(source, [
|
|
9666
|
+
"createdAt",
|
|
9667
|
+
"flowId",
|
|
9668
|
+
"issue",
|
|
9669
|
+
"operationId",
|
|
9670
|
+
"revisionId",
|
|
9671
|
+
"status",
|
|
9672
|
+
"updatedAt",
|
|
9673
|
+
"version"
|
|
9674
|
+
]);
|
|
9675
|
+
const issue = record$1(source.issue);
|
|
9676
|
+
const nodeId = issue.nodeId;
|
|
9677
|
+
exact(issue, [
|
|
9678
|
+
"code",
|
|
9679
|
+
"message",
|
|
9680
|
+
...nodeId == null ? [] : ["nodeId"]
|
|
9681
|
+
]);
|
|
9682
|
+
return {
|
|
9683
|
+
...common,
|
|
9684
|
+
issue: {
|
|
9685
|
+
code: string(issue.code),
|
|
9686
|
+
message: string(issue.message),
|
|
9687
|
+
...nodeId == null ? {} : { nodeId: string(nodeId) }
|
|
9688
|
+
},
|
|
9689
|
+
status
|
|
9690
|
+
};
|
|
9691
|
+
}
|
|
9692
|
+
default: return invalidResponse();
|
|
9693
|
+
}
|
|
9694
|
+
}
|
|
9695
|
+
function live(value) {
|
|
9564
9696
|
const source = record$1(value);
|
|
9565
|
-
|
|
9697
|
+
const status = source.status;
|
|
9698
|
+
const candidate = source.publication;
|
|
9699
|
+
if (source.version != 1 || typeof source.hasUnpublishedChanges != "boolean") return invalidResponse();
|
|
9700
|
+
if (status != "not-published" && status != "runnable" && status != "suspended") return invalidResponse();
|
|
9701
|
+
if (status == "not-published" && candidate !== null) return invalidResponse();
|
|
9702
|
+
if (status != "not-published" && candidate === null) return invalidResponse();
|
|
9703
|
+
return {
|
|
9704
|
+
flowId: string(source.flowId),
|
|
9705
|
+
hasUnpublishedChanges: source.hasUnpublishedChanges,
|
|
9706
|
+
publication: candidate === null ? null : publication(candidate),
|
|
9707
|
+
revision: integer(source.revision),
|
|
9708
|
+
status,
|
|
9709
|
+
version: 1
|
|
9710
|
+
};
|
|
9566
9711
|
}
|
|
9567
|
-
function
|
|
9568
|
-
|
|
9569
|
-
|
|
9712
|
+
function publicationPage(value) {
|
|
9713
|
+
const source = record$1(value);
|
|
9714
|
+
const nextCursor = source.nextCursor;
|
|
9715
|
+
const total = source.total;
|
|
9716
|
+
if (source.version != 1 || !Array.isArray(source.publications)) return invalidResponse();
|
|
9717
|
+
if (nextCursor != null && typeof nextCursor != "string") return invalidResponse();
|
|
9718
|
+
if (total != null && !Number.isSafeInteger(total)) return invalidResponse();
|
|
9719
|
+
return {
|
|
9720
|
+
...nextCursor == null ? {} : { nextCursor },
|
|
9721
|
+
publications: source.publications.map(publication),
|
|
9722
|
+
...total == null ? {} : { total },
|
|
9723
|
+
version: 1
|
|
9724
|
+
};
|
|
9570
9725
|
}
|
|
9571
9726
|
//#endregion
|
|
9572
9727
|
//#region src/trigger/common/configSchema.ts
|
|
@@ -9751,54 +9906,99 @@ function pollTriggerTestResult(value) {
|
|
|
9751
9906
|
};
|
|
9752
9907
|
}
|
|
9753
9908
|
//#endregion
|
|
9754
|
-
//#region src/control/common/
|
|
9755
|
-
|
|
9756
|
-
|
|
9757
|
-
|
|
9758
|
-
|
|
9759
|
-
|
|
9760
|
-
|
|
9761
|
-
|
|
9762
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
9765
|
-
|
|
9766
|
-
}
|
|
9767
|
-
|
|
9768
|
-
|
|
9769
|
-
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
|
|
9775
|
-
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
|
|
9780
|
-
|
|
9781
|
-
|
|
9782
|
-
|
|
9783
|
-
|
|
9784
|
-
|
|
9785
|
-
}
|
|
9786
|
-
|
|
9909
|
+
//#region src/control/common/liveDetails.ts
|
|
9910
|
+
var metadata = {
|
|
9911
|
+
nodeId: string$1().min(1),
|
|
9912
|
+
name: string$1(),
|
|
9913
|
+
description: string$1().optional()
|
|
9914
|
+
};
|
|
9915
|
+
var binding = unknown().transform(triggerBinding);
|
|
9916
|
+
var provider = {
|
|
9917
|
+
provider: string$1().min(1),
|
|
9918
|
+
inputs: record$3(string$1(), discriminatedUnion("kind", [strictObject({
|
|
9919
|
+
kind: literal("value"),
|
|
9920
|
+
value: json$4()
|
|
9921
|
+
}), strictObject({ kind: literal("unset") })]))
|
|
9922
|
+
};
|
|
9923
|
+
var entrySchema = discriminatedUnion("type", [
|
|
9924
|
+
strictObject({
|
|
9925
|
+
...metadata,
|
|
9926
|
+
type: literal("manual"),
|
|
9927
|
+
config: authoringConfigurations.manual
|
|
9928
|
+
}),
|
|
9929
|
+
strictObject({
|
|
9930
|
+
...metadata,
|
|
9931
|
+
type: literal("webhook"),
|
|
9932
|
+
config: authoringConfigurations.webhook,
|
|
9933
|
+
binding
|
|
9934
|
+
}),
|
|
9935
|
+
strictObject({
|
|
9936
|
+
...metadata,
|
|
9937
|
+
type: literal("cron"),
|
|
9938
|
+
config: authoringConfigurations.cron,
|
|
9939
|
+
binding
|
|
9940
|
+
}),
|
|
9941
|
+
strictObject({
|
|
9942
|
+
...metadata,
|
|
9943
|
+
type: literal("error"),
|
|
9944
|
+
config: authoringConfigurations.error,
|
|
9945
|
+
binding
|
|
9946
|
+
}),
|
|
9947
|
+
strictObject({
|
|
9948
|
+
...metadata,
|
|
9949
|
+
...provider,
|
|
9950
|
+
type: literal("poll"),
|
|
9951
|
+
config: authoringConfigurations.poll,
|
|
9952
|
+
binding
|
|
9953
|
+
}),
|
|
9954
|
+
strictObject({
|
|
9955
|
+
...metadata,
|
|
9956
|
+
...provider,
|
|
9957
|
+
type: literal("integration"),
|
|
9958
|
+
config: authoringConfigurations.integration,
|
|
9959
|
+
binding
|
|
9960
|
+
})
|
|
9961
|
+
]);
|
|
9962
|
+
function decodeLiveDetails(value) {
|
|
9787
9963
|
const source = record$1(value);
|
|
9788
|
-
const
|
|
9789
|
-
if (!Array.isArray(source.
|
|
9964
|
+
const flowId = string(source.flowId);
|
|
9965
|
+
if (source.version != 1 || !Array.isArray(source.entries)) return invalidResponse();
|
|
9966
|
+
if (source.publication === null) {
|
|
9967
|
+
if (source.status != "not-published" || source.entries.length != 0 || Object.hasOwn(source, "enabled")) return invalidResponse();
|
|
9968
|
+
return {
|
|
9969
|
+
flowId,
|
|
9970
|
+
publication: null,
|
|
9971
|
+
status: "not-published",
|
|
9972
|
+
entries: [],
|
|
9973
|
+
version: 1
|
|
9974
|
+
};
|
|
9975
|
+
}
|
|
9976
|
+
const current = publication(source.publication);
|
|
9977
|
+
const status = source.status;
|
|
9978
|
+
if (current.flowId != flowId || typeof source.enabled != "boolean") return invalidResponse();
|
|
9979
|
+
if (status != "runnable" && status != "suspended") return invalidResponse();
|
|
9980
|
+
if (!source.enabled && source.status == "runnable") return invalidResponse();
|
|
9790
9981
|
return {
|
|
9791
|
-
|
|
9792
|
-
|
|
9982
|
+
flowId,
|
|
9983
|
+
publication: current,
|
|
9984
|
+
status,
|
|
9985
|
+
enabled: source.enabled,
|
|
9986
|
+
entries: decodeEntries(source.entries, current),
|
|
9987
|
+
version: 1
|
|
9793
9988
|
};
|
|
9794
9989
|
}
|
|
9795
|
-
|
|
9796
|
-
|
|
9797
|
-
const
|
|
9798
|
-
return
|
|
9799
|
-
|
|
9800
|
-
|
|
9801
|
-
|
|
9990
|
+
/** Both producers and consumers enforce the same published-entry invariants. */
|
|
9991
|
+
function decodeEntries(values, current) {
|
|
9992
|
+
const parsed = array(entrySchema).safeParse(values);
|
|
9993
|
+
if (!parsed.success) return invalidResponse();
|
|
9994
|
+
const ids = /* @__PURE__ */ new Set();
|
|
9995
|
+
for (const entry of parsed.data) {
|
|
9996
|
+
if (ids.has(entry.nodeId)) return invalidResponse();
|
|
9997
|
+
ids.add(entry.nodeId);
|
|
9998
|
+
if (entry.type != "manual" && (entry.binding.flowId != current.flowId || entry.binding.triggerNodeId != entry.nodeId || entry.binding.kind != entry.type || entry.binding.currentPublicationId != current.publicationId || entry.binding.currentRevisionId != current.revisionId)) return invalidResponse();
|
|
9999
|
+
if (entry.type == "webhook" && (!entry.binding.endpointUrl || !webhookSupportsBody(entry.config.method) && Object.keys(entry.config.body).length > 0)) return invalidResponse();
|
|
10000
|
+
}
|
|
10001
|
+
return parsed.data;
|
|
9802
10002
|
}
|
|
9803
10003
|
//#endregion
|
|
9804
10004
|
//#region src/control/common/providerIconSprite.ts
|
|
@@ -10633,142 +10833,6 @@ function variableReferences(input) {
|
|
|
10633
10833
|
};
|
|
10634
10834
|
}
|
|
10635
10835
|
//#endregion
|
|
10636
|
-
//#region src/control/common/publicationDecoders.ts
|
|
10637
|
-
function publication(value) {
|
|
10638
|
-
const source = record$1(value);
|
|
10639
|
-
const liveEnd = source.liveEnd == null ? void 0 : record$1(source.liveEnd);
|
|
10640
|
-
if (liveEnd != null && typeof liveEnd.enabled != "boolean") return invalidResponse();
|
|
10641
|
-
const operation = source.operation;
|
|
10642
|
-
const sourcePublicationId = source.sourcePublicationId;
|
|
10643
|
-
if (source.version != 1) return invalidResponse();
|
|
10644
|
-
if (operation != "publish" && operation != "rollback") return invalidResponse();
|
|
10645
|
-
if (sourcePublicationId != null && typeof sourcePublicationId != "string") return invalidResponse();
|
|
10646
|
-
return {
|
|
10647
|
-
...liveEnd == null ? {} : { liveEnd: {
|
|
10648
|
-
enabled: liveEnd.enabled,
|
|
10649
|
-
endedAt: string(liveEnd.endedAt)
|
|
10650
|
-
} },
|
|
10651
|
-
actorId: string(source.actorId),
|
|
10652
|
-
closureDigest: string(source.closureDigest),
|
|
10653
|
-
createdAt: string(source.createdAt),
|
|
10654
|
-
engineContract: string(source.engineContract),
|
|
10655
|
-
flowId: string(source.flowId),
|
|
10656
|
-
modelVersion: integer(source.modelVersion),
|
|
10657
|
-
operation,
|
|
10658
|
-
publicationId: string(source.publicationId),
|
|
10659
|
-
sharedAccessDigest: string(source.sharedAccessDigest),
|
|
10660
|
-
revisionDigest: string(source.revisionDigest),
|
|
10661
|
-
revisionId: string(source.revisionId),
|
|
10662
|
-
...sourcePublicationId == null ? {} : { sourcePublicationId },
|
|
10663
|
-
version: 1
|
|
10664
|
-
};
|
|
10665
|
-
}
|
|
10666
|
-
function publishOperation(value) {
|
|
10667
|
-
const source = record$1(value);
|
|
10668
|
-
const status = source.status;
|
|
10669
|
-
const common = {
|
|
10670
|
-
createdAt: string(source.createdAt),
|
|
10671
|
-
flowId: string(source.flowId),
|
|
10672
|
-
operationId: string(source.operationId),
|
|
10673
|
-
revisionId: string(source.revisionId),
|
|
10674
|
-
updatedAt: string(source.updatedAt),
|
|
10675
|
-
version: 1
|
|
10676
|
-
};
|
|
10677
|
-
if (source.version != 1) return invalidResponse();
|
|
10678
|
-
switch (status) {
|
|
10679
|
-
case "pending":
|
|
10680
|
-
exact(source, [
|
|
10681
|
-
"createdAt",
|
|
10682
|
-
"flowId",
|
|
10683
|
-
"operationId",
|
|
10684
|
-
"revisionId",
|
|
10685
|
-
"status",
|
|
10686
|
-
"updatedAt",
|
|
10687
|
-
"version"
|
|
10688
|
-
]);
|
|
10689
|
-
return {
|
|
10690
|
-
...common,
|
|
10691
|
-
status
|
|
10692
|
-
};
|
|
10693
|
-
case "succeeded":
|
|
10694
|
-
exact(source, [
|
|
10695
|
-
"createdAt",
|
|
10696
|
-
"flowId",
|
|
10697
|
-
"operationId",
|
|
10698
|
-
"publicationId",
|
|
10699
|
-
"revisionId",
|
|
10700
|
-
"status",
|
|
10701
|
-
"updatedAt",
|
|
10702
|
-
"version"
|
|
10703
|
-
]);
|
|
10704
|
-
return {
|
|
10705
|
-
...common,
|
|
10706
|
-
publicationId: string(source.publicationId),
|
|
10707
|
-
status
|
|
10708
|
-
};
|
|
10709
|
-
case "failed": {
|
|
10710
|
-
exact(source, [
|
|
10711
|
-
"createdAt",
|
|
10712
|
-
"flowId",
|
|
10713
|
-
"issue",
|
|
10714
|
-
"operationId",
|
|
10715
|
-
"revisionId",
|
|
10716
|
-
"status",
|
|
10717
|
-
"updatedAt",
|
|
10718
|
-
"version"
|
|
10719
|
-
]);
|
|
10720
|
-
const issue = record$1(source.issue);
|
|
10721
|
-
const nodeId = issue.nodeId;
|
|
10722
|
-
exact(issue, [
|
|
10723
|
-
"code",
|
|
10724
|
-
"message",
|
|
10725
|
-
...nodeId == null ? [] : ["nodeId"]
|
|
10726
|
-
]);
|
|
10727
|
-
return {
|
|
10728
|
-
...common,
|
|
10729
|
-
issue: {
|
|
10730
|
-
code: string(issue.code),
|
|
10731
|
-
message: string(issue.message),
|
|
10732
|
-
...nodeId == null ? {} : { nodeId: string(nodeId) }
|
|
10733
|
-
},
|
|
10734
|
-
status
|
|
10735
|
-
};
|
|
10736
|
-
}
|
|
10737
|
-
default: return invalidResponse();
|
|
10738
|
-
}
|
|
10739
|
-
}
|
|
10740
|
-
function live(value) {
|
|
10741
|
-
const source = record$1(value);
|
|
10742
|
-
const status = source.status;
|
|
10743
|
-
const candidate = source.publication;
|
|
10744
|
-
if (source.version != 1 || typeof source.hasUnpublishedChanges != "boolean") return invalidResponse();
|
|
10745
|
-
if (status != "not-published" && status != "runnable" && status != "suspended") return invalidResponse();
|
|
10746
|
-
if (status == "not-published" && candidate !== null) return invalidResponse();
|
|
10747
|
-
if (status != "not-published" && candidate === null) return invalidResponse();
|
|
10748
|
-
return {
|
|
10749
|
-
flowId: string(source.flowId),
|
|
10750
|
-
hasUnpublishedChanges: source.hasUnpublishedChanges,
|
|
10751
|
-
publication: candidate === null ? null : publication(candidate),
|
|
10752
|
-
revision: integer(source.revision),
|
|
10753
|
-
status,
|
|
10754
|
-
version: 1
|
|
10755
|
-
};
|
|
10756
|
-
}
|
|
10757
|
-
function publicationPage(value) {
|
|
10758
|
-
const source = record$1(value);
|
|
10759
|
-
const nextCursor = source.nextCursor;
|
|
10760
|
-
const total = source.total;
|
|
10761
|
-
if (source.version != 1 || !Array.isArray(source.publications)) return invalidResponse();
|
|
10762
|
-
if (nextCursor != null && typeof nextCursor != "string") return invalidResponse();
|
|
10763
|
-
if (total != null && !Number.isSafeInteger(total)) return invalidResponse();
|
|
10764
|
-
return {
|
|
10765
|
-
...nextCursor == null ? {} : { nextCursor },
|
|
10766
|
-
publications: source.publications.map(publication),
|
|
10767
|
-
...total == null ? {} : { total },
|
|
10768
|
-
version: 1
|
|
10769
|
-
};
|
|
10770
|
-
}
|
|
10771
|
-
//#endregion
|
|
10772
10836
|
//#region src/control/common/revisionDecoders.ts
|
|
10773
10837
|
function revisionMetadata(value) {
|
|
10774
10838
|
const source = record$1(value);
|
|
@@ -11707,21 +11771,14 @@ var ControlClient = class {
|
|
|
11707
11771
|
method: "POST"
|
|
11708
11772
|
}));
|
|
11709
11773
|
}
|
|
11774
|
+
async getLiveDetails(flowId, signal) {
|
|
11775
|
+
const details = decodeLiveDetails(await this.request(`/v1/flows/${segment(flowId)}/live/details`, { signal }));
|
|
11776
|
+
if (details.flowId != flowId) return invalidResponse();
|
|
11777
|
+
return details;
|
|
11778
|
+
}
|
|
11710
11779
|
async getLive(flowId, signal) {
|
|
11711
11780
|
return live(await this.request(`/v1/flows/${segment(flowId)}/live`, { signal }));
|
|
11712
11781
|
}
|
|
11713
|
-
async listPublicationResources(flowId, publicationId) {
|
|
11714
|
-
const query = publicationId == null ? "" : `?publicationId=${encodeURIComponent(publicationId)}`;
|
|
11715
|
-
const result = decodePublicationResources(await this.request(`/v1/flows/${segment(flowId)}/resources${query}`));
|
|
11716
|
-
if (result.flowId != flowId || publicationId != null && result.publicationId != publicationId) return invalidResponse();
|
|
11717
|
-
return result;
|
|
11718
|
-
}
|
|
11719
|
-
async getPublicationResource(flowId, resourceId, publicationId) {
|
|
11720
|
-
const query = publicationId == null ? "" : `?publicationId=${encodeURIComponent(publicationId)}`;
|
|
11721
|
-
const result = decodePublicationResource(await this.request(`/v1/flows/${segment(flowId)}/resources/${segment(resourceId)}${query}`));
|
|
11722
|
-
if (result.flowId != flowId || result.resource.resourceId != resourceId || publicationId != null && result.publicationId != publicationId) return invalidResponse();
|
|
11723
|
-
return result;
|
|
11724
|
-
}
|
|
11725
11782
|
async listPublications(flowId, options = {}, signal) {
|
|
11726
11783
|
const parameters = new URLSearchParams();
|
|
11727
11784
|
if (options.cursor != null) parameters.set("cursor", options.cursor);
|
|
@@ -13007,12 +13064,20 @@ var triggerControlApiConformanceCases = [{
|
|
|
13007
13064
|
equal(binding.currentPublicationId, publicationId, "Trigger Publication");
|
|
13008
13065
|
equal(binding.operatorState, void 0, "No individual Trigger control state");
|
|
13009
13066
|
}
|
|
13067
|
+
const online = await client(harness).getLiveDetails(flowId);
|
|
13068
|
+
equal(online.publication?.publicationId, publicationId, "Online Publication");
|
|
13069
|
+
equal(online.entries.map((entry) => entry.type), ["cron", "webhook"], "Online entries");
|
|
13070
|
+
const onlineWebhook = online.entries.find((entry) => entry.type == "webhook");
|
|
13071
|
+
if (onlineWebhook?.type != "webhook") fail("Missing online Webhook.");
|
|
13072
|
+
equal(onlineWebhook.config.method, "POST", "Online request method");
|
|
13073
|
+
equal(onlineWebhook.config.body, {}, "Online request fields");
|
|
13010
13074
|
const webhookPath = `${base}/webhook`;
|
|
13011
13075
|
const endpointUrl = requiredString(record((await json(await request(harness, webhookPath), 200, "Read Webhook")).binding, "Webhook").endpointUrl, "Webhook endpoint");
|
|
13012
13076
|
for (const action of ["pause", "resume"]) equal((await request(harness, `${webhookPath}/${action}`, {
|
|
13013
13077
|
body: JSON.stringify({ version: 1 }),
|
|
13014
13078
|
method: "POST"
|
|
13015
13079
|
})).status, 404, "Individual Trigger control is unavailable");
|
|
13080
|
+
equal(onlineWebhook.binding.endpointUrl, endpointUrl, "Online endpoint shares binding authority");
|
|
13016
13081
|
const enable = (enabled) => request(harness, `/v1/flows/${flowId}/enabled`, {
|
|
13017
13082
|
method: "PUT",
|
|
13018
13083
|
body: JSON.stringify({
|