@oomol-lab/open-flow 0.1.0-beta.61 → 0.1.0-beta.63
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-BAJXbzNH.js} +20 -7
- package/dist/browser/flow-authoring.js +8 -7
- package/dist/browser/flow-change-schema.d.ts +1 -0
- package/dist/browser/flow-change.d.ts +1 -0
- package/dist/browser/flow-change.js +8 -7
- package/dist/browser/{flowChanges-DSA0FxxN.js → flowChanges-DpZOQuJE.js} +3001 -2588
- package/dist/browser/{flowRunInputEditorStore-Dsxyfwae.js → flowRunInputEditorStore-B2Rw4VsT.js} +1 -1
- package/dist/browser/{flowWorkspace-0sUJ5JhQ.js → flowWorkspace-B7a5NNA_.js} +217 -83
- package/dist/browser/{icons-DVJvrj1H.js → icons-Db2Jb2iX.js} +2907 -2887
- package/dist/browser/preview.css +5 -6
- package/dist/browser/preview.js +889 -541
- package/dist/browser/{typeScriptSession-fXPMFGjW.js → typeScriptSession-D0bjYDeg.js} +1 -1
- package/dist/browser/ui.css +4 -5
- package/dist/browser/ui.js +2 -2
- package/dist/browser/{value-DL_poNiC.js → value-BADHeZ9I.js} +12 -1
- package/dist/browser/workbench-contract.d.ts +10 -0
- package/dist/browser/workbench.css +9 -26
- package/dist/browser/workbench.d.ts +5 -3
- package/dist/browser/workbench.js +272 -178
- package/dist/browser/{workbenchSelect-cr4-mKq3.js → workbenchSelect-C-jf6NIM.js} +1 -1
- package/dist/command/index.js +45 -44
- package/dist/common/authoring.d.ts +1 -1
- package/dist/common/authoringSchema.d.ts +1 -0
- package/dist/common/connector-action.d.ts +1 -0
- package/dist/common/connector-action.js +15 -12
- package/dist/common/control-api-conformance.js +1371 -1207
- package/dist/common/control-api-errors.d.ts +0 -4
- package/dist/common/control-api.d.ts +18 -11
- package/dist/common/control-api.js +2053 -2274
- package/dist/common/control-requests.d.ts +6 -0
- package/dist/common/control-requests.js +64 -33
- package/dist/common/decision.js +8 -7
- package/dist/common/flow-connectionUsage.d.ts +1 -0
- package/dist/common/flow-encoding.d.ts +1 -0
- package/dist/common/flow-encoding.js +202 -10
- package/dist/common/flow-semantics.js +64 -46
- package/dist/common/flow-workflowFile.d.ts +23 -0
- package/dist/common/integration-trigger.js +8 -7
- package/dist/common/liveDetails.d.ts +138 -0
- package/dist/common/localization.d.ts +1 -0
- package/dist/common/localization.js +12 -1
- package/dist/common/mcp.d.ts +55 -26
- package/dist/common/mcp.js +377 -245
- package/dist/common/openapi.js +8 -7
- package/dist/common/poll-trigger.js +8 -7
- package/dist/common/runtime-contract.js +1 -1
- package/dist/common/scheduler.d.ts +22 -2
- package/dist/common/scheduler.js +354 -83
- package/dist/common/trigger-config.d.ts +2 -0
- package/dist/common/webhook-trigger.js +8 -7
- package/dist/index.d.ts +2 -2
- package/package.json +1 -1
- package/skills/open-flow/SKILL.md +6 -3
- package/skills/open-flow/references/flow-authoring.md +48 -24
- package/dist/common/publicationResources.d.ts +0 -29
|
@@ -1,36 +1,3 @@
|
|
|
1
|
-
//#region ../../node_modules/.bun/dequal@2.0.3/node_modules/dequal/lite/index.mjs
|
|
2
|
-
var has = Object.prototype.hasOwnProperty;
|
|
3
|
-
function dequal(foo, bar) {
|
|
4
|
-
var ctor, len;
|
|
5
|
-
if (foo === bar) return true;
|
|
6
|
-
if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
|
|
7
|
-
if (ctor === Date) return foo.getTime() === bar.getTime();
|
|
8
|
-
if (ctor === RegExp) return foo.toString() === bar.toString();
|
|
9
|
-
if (ctor === Array) {
|
|
10
|
-
if ((len = foo.length) === bar.length) while (len-- && dequal(foo[len], bar[len]));
|
|
11
|
-
return len === -1;
|
|
12
|
-
}
|
|
13
|
-
if (!ctor || typeof foo === "object") {
|
|
14
|
-
len = 0;
|
|
15
|
-
for (ctor in foo) {
|
|
16
|
-
if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
|
|
17
|
-
if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
|
|
18
|
-
}
|
|
19
|
-
return Object.keys(bar).length === len;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return foo !== foo && bar !== bar;
|
|
23
|
-
}
|
|
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
1
|
//#region ../../node_modules/.bun/zod@4.6.5/node_modules/zod/v4/core/util.js
|
|
35
2
|
function getEnumValues(entries) {
|
|
36
3
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
@@ -5371,7 +5338,7 @@ var ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
|
|
|
5371
5338
|
return required(ZodNonOptional, this, args[0]);
|
|
5372
5339
|
}
|
|
5373
5340
|
});
|
|
5374
|
-
function object
|
|
5341
|
+
function object(shape, params) {
|
|
5375
5342
|
return new ZodObject({
|
|
5376
5343
|
type: "object",
|
|
5377
5344
|
shape: shape ?? {},
|
|
@@ -5431,7 +5398,7 @@ var ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def) => {
|
|
|
5431
5398
|
inst.keyType = def.keyType;
|
|
5432
5399
|
inst.valueType = def.valueType;
|
|
5433
5400
|
});
|
|
5434
|
-
function record$
|
|
5401
|
+
function record$2(keyType, valueType, params) {
|
|
5435
5402
|
if (!valueType || !valueType._zod) return new ZodRecord({
|
|
5436
5403
|
type: "record",
|
|
5437
5404
|
keyType: string$1(),
|
|
@@ -5679,7 +5646,7 @@ function refine(fn, _params = {}) {
|
|
|
5679
5646
|
function superRefine(fn, params) {
|
|
5680
5647
|
return /* @__PURE__ */ _superRefine(fn, params);
|
|
5681
5648
|
}
|
|
5682
|
-
function json$
|
|
5649
|
+
function json$3(params) {
|
|
5683
5650
|
const jsonSchema = lazy(() => {
|
|
5684
5651
|
return union([
|
|
5685
5652
|
string$1(params),
|
|
@@ -5687,7 +5654,7 @@ function json$4(params) {
|
|
|
5687
5654
|
boolean(),
|
|
5688
5655
|
_null(),
|
|
5689
5656
|
array(jsonSchema),
|
|
5690
|
-
record$
|
|
5657
|
+
record$2(string$1(), jsonSchema)
|
|
5691
5658
|
]);
|
|
5692
5659
|
});
|
|
5693
5660
|
return jsonSchema;
|
|
@@ -5699,27 +5666,6 @@ function preprocess(fn, schema) {
|
|
|
5699
5666
|
out: schema
|
|
5700
5667
|
});
|
|
5701
5668
|
}
|
|
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$1({
|
|
5709
|
-
type: literal("cron"),
|
|
5710
|
-
expression: string$1(),
|
|
5711
|
-
timezone: string$1()
|
|
5712
|
-
}), object$1({
|
|
5713
|
-
type: literal("every"),
|
|
5714
|
-
unit: _enum([
|
|
5715
|
-
"day",
|
|
5716
|
-
"hour",
|
|
5717
|
-
"minute",
|
|
5718
|
-
"month",
|
|
5719
|
-
"week"
|
|
5720
|
-
]),
|
|
5721
|
-
value: number()
|
|
5722
|
-
})]));
|
|
5723
5669
|
//#endregion
|
|
5724
5670
|
//#region src/flow/common/webhookMethod.ts
|
|
5725
5671
|
var webhookMethods = [
|
|
@@ -5732,702 +5678,148 @@ var webhookMethods = [
|
|
|
5732
5678
|
function webhookSupportsBody(method) {
|
|
5733
5679
|
return method !== "GET";
|
|
5734
5680
|
}
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
var
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
var
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
})
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5681
|
+
//#endregion
|
|
5682
|
+
//#region ../../node_modules/.bun/dequal@2.0.3/node_modules/dequal/lite/index.mjs
|
|
5683
|
+
var has = Object.prototype.hasOwnProperty;
|
|
5684
|
+
function dequal(foo, bar) {
|
|
5685
|
+
var ctor, len;
|
|
5686
|
+
if (foo === bar) return true;
|
|
5687
|
+
if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
|
|
5688
|
+
if (ctor === Date) return foo.getTime() === bar.getTime();
|
|
5689
|
+
if (ctor === RegExp) return foo.toString() === bar.toString();
|
|
5690
|
+
if (ctor === Array) {
|
|
5691
|
+
if ((len = foo.length) === bar.length) while (len-- && dequal(foo[len], bar[len]));
|
|
5692
|
+
return len === -1;
|
|
5693
|
+
}
|
|
5694
|
+
if (!ctor || typeof foo === "object") {
|
|
5695
|
+
len = 0;
|
|
5696
|
+
for (ctor in foo) {
|
|
5697
|
+
if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
|
|
5698
|
+
if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
|
|
5699
|
+
}
|
|
5700
|
+
return Object.keys(bar).length === len;
|
|
5701
|
+
}
|
|
5702
|
+
}
|
|
5703
|
+
return foo !== foo && bar !== bar;
|
|
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/condition.ts
|
|
5716
|
+
var unaryOperator = (operator) => operator.startsWith("is");
|
|
5717
|
+
var operandHandle = (caseIndex, groupIndex, expressionIndex, side) => `${caseIndex}/${groupIndex}/${expressionIndex}/${side}`;
|
|
5718
|
+
/** Derived addresses let operand bindings use the ordinary input analysis and editor. Never persisted as node inputs. */
|
|
5719
|
+
function conditionOperands(node) {
|
|
5720
|
+
return node.cases.flatMap((item, c) => item.groups.flatMap((group, g) => group.expressions.flatMap((expression, e) => [{
|
|
5721
|
+
handle: operandHandle(c, g, e, "left"),
|
|
5722
|
+
operand: expression.left,
|
|
5723
|
+
expression,
|
|
5724
|
+
side: "left"
|
|
5725
|
+
}, ...!unaryOperator(expression.operator) ? [{
|
|
5726
|
+
handle: operandHandle(c, g, e, "right"),
|
|
5727
|
+
operand: expression.right ?? { kind: "value" },
|
|
5728
|
+
expression,
|
|
5729
|
+
side: "right"
|
|
5730
|
+
}] : []])));
|
|
5731
|
+
}
|
|
5732
|
+
function conditionInputPorts(node) {
|
|
5733
|
+
return Object.fromEntries(conditionOperands(node).map(({ handle, operand }) => [handle, {
|
|
5734
|
+
jsonSchema: operand.kind === "value" ? operand.jsonSchema ?? {} : {},
|
|
5735
|
+
nullable: operand.kind === "value" ? operand.value === null : true
|
|
5736
|
+
}]));
|
|
5737
|
+
}
|
|
5738
|
+
//#endregion
|
|
5739
|
+
//#region src/flow/common/change.ts
|
|
5740
|
+
var schemaKeywords = /* @__PURE__ */ new Set([
|
|
5741
|
+
"const",
|
|
5742
|
+
"enum",
|
|
5743
|
+
"exclusiveMaximum",
|
|
5744
|
+
"exclusiveMinimum",
|
|
5745
|
+
"maximum",
|
|
5746
|
+
"maxItems",
|
|
5747
|
+
"maxLength",
|
|
5748
|
+
"maxProperties",
|
|
5749
|
+
"minimum",
|
|
5750
|
+
"minItems",
|
|
5751
|
+
"minLength",
|
|
5752
|
+
"minProperties",
|
|
5753
|
+
"multipleOf",
|
|
5754
|
+
"pattern",
|
|
5755
|
+
"required",
|
|
5756
|
+
"type"
|
|
5802
5757
|
]);
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
}
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
}
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
}))
|
|
5869
|
-
}),
|
|
5870
|
-
strictObject({
|
|
5871
|
-
kind: literal("decision"),
|
|
5872
|
-
questions: array(decisionQuestion)
|
|
5873
|
-
}),
|
|
5874
|
-
object$1({
|
|
5875
|
-
kind: literal("llm"),
|
|
5876
|
-
mode: _enum(["chat", "json"])
|
|
5877
|
-
}),
|
|
5878
|
-
object$1({
|
|
5879
|
-
kind: literal("agent"),
|
|
5880
|
-
code: boolean().optional(),
|
|
5881
|
-
model: text,
|
|
5882
|
-
prompt: text,
|
|
5883
|
-
maxRounds: number(),
|
|
5884
|
-
tools: array(object$1({
|
|
5885
|
-
id: text,
|
|
5886
|
-
name: text,
|
|
5887
|
-
description: text,
|
|
5888
|
-
action: text,
|
|
5889
|
-
connectionId: text.optional(),
|
|
5890
|
-
approval: boolean(),
|
|
5891
|
-
inputs: array(input.extend({ source: agentInput }))
|
|
5892
|
-
})),
|
|
5893
|
-
notification: object$1({
|
|
5894
|
-
action: text,
|
|
5895
|
-
connectionId: text.optional(),
|
|
5896
|
-
inputDefinitions: array(input),
|
|
5897
|
-
messageHandle: text,
|
|
5898
|
-
inputs: record$3(text, agentValue)
|
|
5899
|
-
}).optional()
|
|
5900
|
-
})
|
|
5901
|
-
])
|
|
5902
|
-
});
|
|
5903
|
-
var managed = managedFields.transform(limitDecisionTask);
|
|
5904
|
-
var operand$1 = union([object$1({
|
|
5905
|
-
kind: literal("value"),
|
|
5906
|
-
value: json$3.optional(),
|
|
5907
|
-
jsonSchema: json$3.optional()
|
|
5908
|
-
}), object$1({
|
|
5909
|
-
kind: literal("source"),
|
|
5910
|
-
source
|
|
5911
|
-
})]);
|
|
5912
|
-
var condition = {
|
|
5913
|
-
matchMode: _enum(["first", "all"]),
|
|
5914
|
-
cases: array(object$1({
|
|
5915
|
-
description: text.optional(),
|
|
5916
|
-
output: text,
|
|
5917
|
-
groups: array(object$1({ expressions: array(object$1({
|
|
5918
|
-
left: operand$1,
|
|
5919
|
-
operator: _enum([
|
|
5920
|
-
"!=",
|
|
5921
|
-
"<",
|
|
5922
|
-
"<=",
|
|
5923
|
-
"==",
|
|
5924
|
-
">",
|
|
5925
|
-
">=",
|
|
5926
|
-
"contains",
|
|
5927
|
-
"endsWith",
|
|
5928
|
-
"hasKey",
|
|
5929
|
-
"hasValue",
|
|
5930
|
-
"isEmpty",
|
|
5931
|
-
"isFalse",
|
|
5932
|
-
"isNotEmpty",
|
|
5933
|
-
"isNotNull",
|
|
5934
|
-
"isNull",
|
|
5935
|
-
"isTrue",
|
|
5936
|
-
"notContains",
|
|
5937
|
-
"notHasKey",
|
|
5938
|
-
"notHasValue",
|
|
5939
|
-
"startsWith"
|
|
5940
|
-
]),
|
|
5941
|
-
right: operand$1.optional()
|
|
5942
|
-
})) }))
|
|
5943
|
-
}))
|
|
5944
|
-
};
|
|
5945
|
-
var wait = {
|
|
5946
|
-
inputDefinitions: array(input),
|
|
5947
|
-
prompt: text
|
|
5948
|
-
};
|
|
5949
|
-
var webhookOptions = object$1({
|
|
5950
|
-
allowedMethods: never().optional(),
|
|
5951
|
-
allowedOrigins: strings$1.optional(),
|
|
5952
|
-
noResponseBody: never().optional(),
|
|
5953
|
-
responseData: text.optional(),
|
|
5954
|
-
responseHeaders: record$3(text, text).optional(),
|
|
5955
|
-
responseStatusCode: number().int().min(200).max(599).optional()
|
|
5956
|
-
});
|
|
5957
|
-
var webhook = {
|
|
5958
|
-
bodyFields: array(input),
|
|
5959
|
-
method: _enum(webhookMethods),
|
|
5960
|
-
options: webhookOptions.optional()
|
|
5961
|
-
};
|
|
5962
|
-
var definition = {
|
|
5963
|
-
configInputs: ports$1.inputs,
|
|
5964
|
-
definitionVersion: literal(2),
|
|
5965
|
-
description: text,
|
|
5966
|
-
displayName: text,
|
|
5967
|
-
key: text,
|
|
5968
|
-
name: text,
|
|
5969
|
-
outputs: array(port$1).refine((definitions) => new Set(definitions.map((output) => output.handle)).size === definitions.length, "Duplicate Trigger output handle."),
|
|
5970
|
-
provider: text
|
|
5971
|
-
};
|
|
5972
|
-
var endpoint = object$1({
|
|
5973
|
-
body: object$1({
|
|
5974
|
-
allowArray: boolean(),
|
|
5975
|
-
allowEmpty: boolean(),
|
|
5976
|
-
formats: array(_enum([
|
|
5977
|
-
"form",
|
|
5978
|
-
"json",
|
|
5979
|
-
"multipart",
|
|
5980
|
-
"text"
|
|
5981
|
-
]))
|
|
5982
|
-
}),
|
|
5983
|
-
methods: array(_enum([
|
|
5984
|
-
"DELETE",
|
|
5985
|
-
"GET",
|
|
5986
|
-
"HEAD",
|
|
5987
|
-
"PATCH",
|
|
5988
|
-
"POST",
|
|
5989
|
-
"PUT"
|
|
5990
|
-
])),
|
|
5991
|
-
successStatus: number()
|
|
5992
|
-
});
|
|
5993
|
-
var sourceFlowIds = array(text.min(1)).refine((ids) => new Set(ids).size === ids.length, "Duplicate source Flow ID.");
|
|
5994
|
-
var trigger = {
|
|
5995
|
-
name: text,
|
|
5996
|
-
description: text.optional(),
|
|
5997
|
-
icon: text.optional()
|
|
5998
|
-
};
|
|
5999
|
-
var base = {
|
|
6000
|
-
maxExecutions: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
6001
|
-
inputs,
|
|
6002
|
-
name: text.optional(),
|
|
6003
|
-
description: text.optional(),
|
|
6004
|
-
icon: text.optional(),
|
|
6005
|
-
timeoutMs: number().optional()
|
|
6006
|
-
};
|
|
6007
|
-
var node = union([
|
|
6008
|
-
object$1({
|
|
6009
|
-
...base,
|
|
6010
|
-
inputs: record$3(text, never()),
|
|
6011
|
-
kind: literal("condition"),
|
|
6012
|
-
...condition
|
|
6013
|
-
}),
|
|
6014
|
-
object$1({
|
|
6015
|
-
...base,
|
|
6016
|
-
inputs: unknown().transform(() => ({})).default({}),
|
|
6017
|
-
kind: literal("value"),
|
|
6018
|
-
values: array(input)
|
|
6019
|
-
}),
|
|
6020
|
-
object$1({
|
|
6021
|
-
...base,
|
|
6022
|
-
kind: literal("task"),
|
|
6023
|
-
task: union([inline, managed]),
|
|
6024
|
-
additionalInputs: array(input).optional()
|
|
6025
|
-
}),
|
|
6026
|
-
strictObject({
|
|
6027
|
-
...base,
|
|
6028
|
-
kind: literal("approval"),
|
|
6029
|
-
...wait
|
|
6030
|
-
}).omit({ timeoutMs: true }),
|
|
6031
|
-
strictObject({
|
|
6032
|
-
...base,
|
|
6033
|
-
kind: literal("wait"),
|
|
6034
|
-
...wait
|
|
6035
|
-
}).omit({ timeoutMs: true }),
|
|
6036
|
-
object$1({
|
|
6037
|
-
...trigger,
|
|
6038
|
-
kind: literal("manual")
|
|
6039
|
-
}),
|
|
6040
|
-
strictObject({
|
|
6041
|
-
...trigger,
|
|
6042
|
-
kind: literal("error"),
|
|
6043
|
-
sourceFlowIds: sourceFlowIds.optional()
|
|
6044
|
-
}),
|
|
6045
|
-
object$1({
|
|
6046
|
-
...trigger,
|
|
6047
|
-
kind: literal("webhook"),
|
|
6048
|
-
...webhook
|
|
6049
|
-
}),
|
|
6050
|
-
object$1({
|
|
6051
|
-
...trigger,
|
|
6052
|
-
kind: literal("cron"),
|
|
6053
|
-
cronTimes: triggerScheduleSchema
|
|
6054
|
-
}),
|
|
6055
|
-
object$1({
|
|
6056
|
-
...trigger,
|
|
6057
|
-
kind: literal("poll"),
|
|
6058
|
-
connectionId: text.min(1).optional(),
|
|
6059
|
-
config: record$3(text, fixedInput),
|
|
6060
|
-
definition: object$1({
|
|
6061
|
-
...definition,
|
|
6062
|
-
type: literal("poll")
|
|
6063
|
-
}),
|
|
6064
|
-
pollTimes: triggerScheduleSchema
|
|
6065
|
-
}),
|
|
6066
|
-
object$1({
|
|
6067
|
-
...trigger,
|
|
6068
|
-
kind: literal("integration"),
|
|
6069
|
-
connectionId: text.min(1).optional(),
|
|
6070
|
-
config: record$3(text, fixedInput),
|
|
6071
|
-
definition: object$1({
|
|
6072
|
-
...definition,
|
|
6073
|
-
type: literal("integration"),
|
|
6074
|
-
endpoint
|
|
6075
|
-
})
|
|
6076
|
-
})
|
|
6077
|
-
]);
|
|
6078
|
-
/** Configuration schemas shared by the node authoring boundary. */
|
|
6079
|
-
var authoringDefinitionSchemas = {
|
|
6080
|
-
input,
|
|
6081
|
-
port: port$1,
|
|
6082
|
-
ports: ports$1,
|
|
6083
|
-
condition: strictObject(condition),
|
|
6084
|
-
wait: strictObject(wait),
|
|
6085
|
-
webhook: strictObject(webhook),
|
|
6086
|
-
schedule: triggerScheduleSchema,
|
|
6087
|
-
capabilities: array(capability),
|
|
6088
|
-
connector: managedFields.shape.executor.options[0].omit({ kind: true }).strict(),
|
|
6089
|
-
openapi: managedFields.shape.executor.options[1].omit({ kind: true }).strict(),
|
|
6090
|
-
decision: managedFields.shape.executor.options[2].omit({ kind: true }).strict(),
|
|
6091
|
-
llm: managedFields.shape.executor.options[3].omit({ kind: true }).strict(),
|
|
6092
|
-
agent: managedFields.shape.executor.options[4].omit({
|
|
6093
|
-
kind: true,
|
|
6094
|
-
notification: true
|
|
6095
|
-
}).strict()
|
|
6096
|
-
};
|
|
6097
|
-
var edge = object$1({
|
|
6098
|
-
source: text,
|
|
6099
|
-
target: text,
|
|
6100
|
-
sourceHandle: text.optional()
|
|
6101
|
-
});
|
|
6102
|
-
var at = {
|
|
6103
|
-
nodeId: text,
|
|
6104
|
-
target: never().optional()
|
|
6105
|
-
};
|
|
6106
|
-
var graph = object$1({
|
|
6107
|
-
nodes: record$3(text, node),
|
|
6108
|
-
edges: array(edge).default([])
|
|
6109
|
-
});
|
|
6110
|
-
var binding = object$1({
|
|
6111
|
-
kind: literal("variable"),
|
|
6112
|
-
target: text
|
|
6113
|
-
});
|
|
6114
|
-
var module = object$1({
|
|
6115
|
-
name: text,
|
|
6116
|
-
imports: strings$1,
|
|
6117
|
-
source: text
|
|
6118
|
-
});
|
|
6119
|
-
var document = preprocess(rejectRetiredDefinitions, object$1({
|
|
6120
|
-
bindings: record$3(text, binding),
|
|
6121
|
-
graph
|
|
6122
|
-
}));
|
|
6123
|
-
var revision = object$1({
|
|
6124
|
-
modelVersion: union([
|
|
6125
|
-
literal(2),
|
|
6126
|
-
literal(4),
|
|
6127
|
-
literal(5),
|
|
6128
|
-
literal(6)
|
|
6129
|
-
]),
|
|
6130
|
-
document,
|
|
6131
|
-
modules: record$3(text, module)
|
|
6132
|
-
});
|
|
6133
|
-
revision.extend({
|
|
6134
|
-
kind: literal("open-flow-flow-revision"),
|
|
6135
|
-
version: literal(1)
|
|
6136
|
-
});
|
|
6137
|
-
function rejectRetiredDefinitions(value) {
|
|
6138
|
-
const candidate = record$2(value);
|
|
6139
|
-
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.");
|
|
6140
|
-
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.");
|
|
6141
|
-
const subflows = candidate.subflows;
|
|
6142
|
-
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.");
|
|
6143
|
-
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.");
|
|
6144
|
-
return value;
|
|
6145
|
-
}
|
|
6146
|
-
function record$2(value) {
|
|
6147
|
-
return value != null && typeof value == "object" && !Array.isArray(value) ? value : {};
|
|
6148
|
-
}
|
|
6149
|
-
function decodeRevisionContent(value) {
|
|
6150
|
-
checkJsonDepth(value);
|
|
6151
|
-
const content = revision.parse(value);
|
|
6152
|
-
checkModelVersion(content);
|
|
6153
|
-
assertOpenApiAuthBindings(content.document);
|
|
6154
|
-
return content;
|
|
6155
|
-
}
|
|
6156
|
-
var shapes = {
|
|
6157
|
-
"graph.trigger.sources.set": {
|
|
6158
|
-
nodeId: text,
|
|
6159
|
-
before: sourceFlowIds.optional(),
|
|
6160
|
-
value: sourceFlowIds.optional()
|
|
6161
|
-
},
|
|
6162
|
-
"binding.create": {
|
|
6163
|
-
bindingId: text,
|
|
6164
|
-
binding
|
|
6165
|
-
},
|
|
6166
|
-
"binding.delete": { bindingId: text },
|
|
6167
|
-
"binding.target.set": {
|
|
6168
|
-
bindingId: text,
|
|
6169
|
-
before: text,
|
|
6170
|
-
value: text
|
|
6171
|
-
},
|
|
6172
|
-
"graph.edge.connect": {
|
|
6173
|
-
edge,
|
|
6174
|
-
target: never().optional()
|
|
6175
|
-
},
|
|
6176
|
-
"graph.edge.disconnect": {
|
|
6177
|
-
edge,
|
|
6178
|
-
target: never().optional()
|
|
6179
|
-
},
|
|
6180
|
-
"graph.node.create": {
|
|
6181
|
-
...at,
|
|
6182
|
-
node
|
|
6183
|
-
},
|
|
6184
|
-
"graph.node.replace": {
|
|
6185
|
-
...at,
|
|
6186
|
-
before: node,
|
|
6187
|
-
node
|
|
6188
|
-
},
|
|
6189
|
-
"graph.node.delete": at,
|
|
6190
|
-
"graph.node.field.set": union([
|
|
6191
|
-
object$1({
|
|
6192
|
-
...at,
|
|
6193
|
-
kind: literal("graph.node.field.set"),
|
|
6194
|
-
field: literal("connectionId"),
|
|
6195
|
-
before: text.min(1).optional(),
|
|
6196
|
-
value: text.min(1).optional()
|
|
6197
|
-
}),
|
|
6198
|
-
object$1({
|
|
6199
|
-
...at,
|
|
6200
|
-
kind: literal("graph.node.field.set"),
|
|
6201
|
-
field: _enum([
|
|
6202
|
-
"description",
|
|
6203
|
-
"icon",
|
|
6204
|
-
"name"
|
|
6205
|
-
]),
|
|
6206
|
-
before: text.optional(),
|
|
6207
|
-
value: text.optional()
|
|
6208
|
-
}),
|
|
6209
|
-
object$1({
|
|
6210
|
-
...at,
|
|
6211
|
-
kind: literal("graph.node.field.set"),
|
|
6212
|
-
field: literal("maxExecutions"),
|
|
6213
|
-
before: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
6214
|
-
value: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional()
|
|
6215
|
-
}),
|
|
6216
|
-
object$1({
|
|
6217
|
-
...at,
|
|
6218
|
-
kind: literal("graph.node.field.set"),
|
|
6219
|
-
field: literal("timeoutMs"),
|
|
6220
|
-
before: number().optional(),
|
|
6221
|
-
value: number().optional()
|
|
6222
|
-
})
|
|
6223
|
-
]),
|
|
6224
|
-
"graph.node.input.set": {
|
|
6225
|
-
...at,
|
|
6226
|
-
handle: text,
|
|
6227
|
-
before: mapping.optional(),
|
|
6228
|
-
value: mapping.optional()
|
|
6229
|
-
},
|
|
6230
|
-
"graph.node.additional-inputs.set": {
|
|
6231
|
-
...at,
|
|
6232
|
-
before: array(input).optional(),
|
|
6233
|
-
value: array(input).optional()
|
|
6234
|
-
},
|
|
6235
|
-
"graph.node.condition.set": {
|
|
6236
|
-
...at,
|
|
6237
|
-
before: object$1(condition),
|
|
6238
|
-
value: object$1(condition)
|
|
6239
|
-
},
|
|
6240
|
-
"graph.node.values.set": {
|
|
6241
|
-
...at,
|
|
6242
|
-
before: array(input),
|
|
6243
|
-
value: array(input)
|
|
6244
|
-
},
|
|
6245
|
-
"graph.node.resolution.set": {
|
|
6246
|
-
...at,
|
|
6247
|
-
before: object$1(wait),
|
|
6248
|
-
value: object$1(wait)
|
|
6249
|
-
},
|
|
6250
|
-
"graph.node.webhook.set": {
|
|
6251
|
-
...at,
|
|
6252
|
-
before: object$1(webhook),
|
|
6253
|
-
value: object$1(webhook)
|
|
6254
|
-
},
|
|
6255
|
-
"graph.node.task.ports.set": {
|
|
6256
|
-
...at,
|
|
6257
|
-
before: object$1(ports$1),
|
|
6258
|
-
value: object$1(ports$1)
|
|
6259
|
-
},
|
|
6260
|
-
"graph.node.task.name.set": {
|
|
6261
|
-
...at,
|
|
6262
|
-
before: text,
|
|
6263
|
-
value: text
|
|
6264
|
-
},
|
|
6265
|
-
"graph.node.task.capabilities.set": {
|
|
6266
|
-
...at,
|
|
6267
|
-
before: array(capability).optional(),
|
|
6268
|
-
value: array(capability).optional()
|
|
6269
|
-
},
|
|
6270
|
-
"graph.trigger.config.set": {
|
|
6271
|
-
nodeId: text,
|
|
6272
|
-
name: text,
|
|
6273
|
-
before: fixedInput.optional(),
|
|
6274
|
-
value: fixedInput.optional()
|
|
6275
|
-
},
|
|
6276
|
-
"graph.trigger.schedule.set": {
|
|
6277
|
-
nodeId: text,
|
|
6278
|
-
before: triggerScheduleSchema,
|
|
6279
|
-
value: triggerScheduleSchema
|
|
6280
|
-
},
|
|
6281
|
-
"module.create": {
|
|
6282
|
-
moduleId: text,
|
|
6283
|
-
module
|
|
6284
|
-
},
|
|
6285
|
-
"module.delete": { moduleId: text },
|
|
6286
|
-
"module.rename": {
|
|
6287
|
-
moduleId: text,
|
|
6288
|
-
before: text,
|
|
6289
|
-
name: text
|
|
6290
|
-
},
|
|
6291
|
-
"module.source.replace": {
|
|
6292
|
-
moduleId: text,
|
|
6293
|
-
beforeImports: strings$1,
|
|
6294
|
-
beforeSource: text,
|
|
6295
|
-
imports: strings$1,
|
|
6296
|
-
source: text
|
|
6297
|
-
},
|
|
6298
|
-
"graph.node.task.set": {
|
|
6299
|
-
...at,
|
|
6300
|
-
before: union([inline, managed]),
|
|
6301
|
-
value: union([inline, managed])
|
|
6302
|
-
}
|
|
6303
|
-
};
|
|
6304
|
-
array(union([...new Map(Object.entries(shapes).map(([kind, shape]) => [kind, shape instanceof ZodType ? shape : object$1({
|
|
6305
|
-
kind: literal(kind),
|
|
6306
|
-
...shape
|
|
6307
|
-
})])).values()])).min(1);
|
|
6308
|
-
function checkModelVersion(content) {
|
|
6309
|
-
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.");
|
|
6310
|
-
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.");
|
|
6311
|
-
}
|
|
6312
|
-
//#endregion
|
|
6313
|
-
//#region src/flow/common/condition.ts
|
|
6314
|
-
var unaryOperator = (operator) => operator.startsWith("is");
|
|
6315
|
-
var operandHandle = (caseIndex, groupIndex, expressionIndex, side) => `${caseIndex}/${groupIndex}/${expressionIndex}/${side}`;
|
|
6316
|
-
/** Derived addresses let operand bindings use the ordinary input analysis and editor. Never persisted as node inputs. */
|
|
6317
|
-
function conditionOperands(node) {
|
|
6318
|
-
return node.cases.flatMap((item, c) => item.groups.flatMap((group, g) => group.expressions.flatMap((expression, e) => [{
|
|
6319
|
-
handle: operandHandle(c, g, e, "left"),
|
|
6320
|
-
operand: expression.left,
|
|
6321
|
-
expression,
|
|
6322
|
-
side: "left"
|
|
6323
|
-
}, ...!unaryOperator(expression.operator) ? [{
|
|
6324
|
-
handle: operandHandle(c, g, e, "right"),
|
|
6325
|
-
operand: expression.right ?? { kind: "value" },
|
|
6326
|
-
expression,
|
|
6327
|
-
side: "right"
|
|
6328
|
-
}] : []])));
|
|
6329
|
-
}
|
|
6330
|
-
function nodeInputMappings(node) {
|
|
6331
|
-
if (node.kind != "condition") return "inputs" in node ? node.inputs : {};
|
|
6332
|
-
return Object.fromEntries(conditionOperands(node).flatMap(({ handle, operand }) => operand.kind == "source" ? [[handle, {
|
|
6333
|
-
kind: "sources",
|
|
6334
|
-
sources: [operand.source]
|
|
6335
|
-
}]] : operand.value === void 0 ? [] : [[handle, {
|
|
6336
|
-
kind: "value",
|
|
6337
|
-
value: operand.value
|
|
6338
|
-
}]]));
|
|
6339
|
-
}
|
|
6340
|
-
function conditionInputPorts(node) {
|
|
6341
|
-
return Object.fromEntries(conditionOperands(node).map(({ handle, operand }) => [handle, {
|
|
6342
|
-
jsonSchema: operand.kind === "value" ? operand.jsonSchema ?? {} : {},
|
|
6343
|
-
nullable: operand.kind === "value" ? operand.value === null : true
|
|
6344
|
-
}]));
|
|
6345
|
-
}
|
|
6346
|
-
//#endregion
|
|
6347
|
-
//#region src/flow/common/change.ts
|
|
6348
|
-
var schemaKeywords = /* @__PURE__ */ new Set([
|
|
6349
|
-
"const",
|
|
6350
|
-
"enum",
|
|
6351
|
-
"exclusiveMaximum",
|
|
6352
|
-
"exclusiveMinimum",
|
|
6353
|
-
"maximum",
|
|
6354
|
-
"maxItems",
|
|
6355
|
-
"maxLength",
|
|
6356
|
-
"maxProperties",
|
|
6357
|
-
"minimum",
|
|
6358
|
-
"minItems",
|
|
6359
|
-
"minLength",
|
|
6360
|
-
"minProperties",
|
|
6361
|
-
"multipleOf",
|
|
6362
|
-
"pattern",
|
|
6363
|
-
"required",
|
|
6364
|
-
"type"
|
|
6365
|
-
]);
|
|
6366
|
-
function isSchemaKeyword(value) {
|
|
6367
|
-
return schemaKeywords.has(value);
|
|
6368
|
-
}
|
|
6369
|
-
function portsByHandle(ports) {
|
|
6370
|
-
return Object.fromEntries(ports.flatMap((port) => "handle" in port ? [[port.handle, port]] : []));
|
|
6371
|
-
}
|
|
6372
|
-
//#endregion
|
|
6373
|
-
//#region src/json-schema-subset/utils.ts
|
|
6374
|
-
var nextId = 0;
|
|
6375
|
-
function createId() {
|
|
6376
|
-
const id = nextId;
|
|
6377
|
-
nextId += 1;
|
|
6378
|
-
return id;
|
|
6379
|
-
}
|
|
6380
|
-
function deepFreeze(target) {
|
|
6381
|
-
if (typeof target === "object" && target !== null && !Object.isFrozen(target)) {
|
|
6382
|
-
for (const key of Object.getOwnPropertyNames(target)) deepFreeze(Reflect.get(target, key));
|
|
6383
|
-
Object.freeze(target);
|
|
6384
|
-
}
|
|
6385
|
-
return target;
|
|
6386
|
-
}
|
|
6387
|
-
function pick(target, keys) {
|
|
6388
|
-
const newTarget = {};
|
|
6389
|
-
for (const key of keys) if (key in target) newTarget[key] = target[key];
|
|
6390
|
-
return newTarget;
|
|
6391
|
-
}
|
|
6392
|
-
function deepCopy(value) {
|
|
6393
|
-
if (typeof value !== "object" || value === null) return value;
|
|
6394
|
-
else if (Array.isArray(value)) {
|
|
6395
|
-
const array = [];
|
|
6396
|
-
for (const [i, element] of value.entries()) array[i] = deepCopy(element);
|
|
6397
|
-
return array;
|
|
6398
|
-
} else {
|
|
6399
|
-
const newObject = {};
|
|
6400
|
-
for (const key in value) newObject[key] = deepCopy(value[key]);
|
|
6401
|
-
return newObject;
|
|
6402
|
-
}
|
|
6403
|
-
}
|
|
6404
|
-
function isDeepEquals(value1, value2) {
|
|
6405
|
-
if (value1 === value2) return true;
|
|
6406
|
-
if (value1 === null) return false;
|
|
6407
|
-
if (typeof value1 !== "object") return false;
|
|
6408
|
-
if (typeof value1 !== typeof value2) return false;
|
|
6409
|
-
if (Array.isArray(value1)) {
|
|
6410
|
-
if (!Array.isArray(value2)) return false;
|
|
6411
|
-
if (value1.length !== value2.length) return false;
|
|
6412
|
-
for (const [i, value1Element] of value1.entries()) if (!isDeepEquals(value1Element, value2[i])) return false;
|
|
6413
|
-
} else {
|
|
6414
|
-
if (Array.isArray(value2)) return false;
|
|
6415
|
-
for (const key in value1) {
|
|
6416
|
-
if (!(key in value2)) return false;
|
|
6417
|
-
if (!isDeepEquals(value1[key], value2[key])) return false;
|
|
6418
|
-
}
|
|
6419
|
-
for (const key in value2) if (!(key in value1)) return false;
|
|
6420
|
-
}
|
|
6421
|
-
return true;
|
|
6422
|
-
}
|
|
6423
|
-
//#endregion
|
|
6424
|
-
//#region src/json-schema-subset/expression/result.ts
|
|
6425
|
-
var ExpressionSingleResult = Object.freeze({
|
|
6426
|
-
Equals: 0,
|
|
6427
|
-
Containing: 1,
|
|
6428
|
-
ContainedBy: 2,
|
|
6429
|
-
Rejection: 3,
|
|
6430
|
-
Intersection: 4
|
|
5758
|
+
function isSchemaKeyword(value) {
|
|
5759
|
+
return schemaKeywords.has(value);
|
|
5760
|
+
}
|
|
5761
|
+
function portsByHandle(ports) {
|
|
5762
|
+
return Object.fromEntries(ports.flatMap((port) => "handle" in port ? [[port.handle, port]] : []));
|
|
5763
|
+
}
|
|
5764
|
+
//#endregion
|
|
5765
|
+
//#region src/json-schema-subset/utils.ts
|
|
5766
|
+
var nextId = 0;
|
|
5767
|
+
function createId() {
|
|
5768
|
+
const id = nextId;
|
|
5769
|
+
nextId += 1;
|
|
5770
|
+
return id;
|
|
5771
|
+
}
|
|
5772
|
+
function deepFreeze(target) {
|
|
5773
|
+
if (typeof target === "object" && target !== null && !Object.isFrozen(target)) {
|
|
5774
|
+
for (const key of Object.getOwnPropertyNames(target)) deepFreeze(Reflect.get(target, key));
|
|
5775
|
+
Object.freeze(target);
|
|
5776
|
+
}
|
|
5777
|
+
return target;
|
|
5778
|
+
}
|
|
5779
|
+
function pick(target, keys) {
|
|
5780
|
+
const newTarget = {};
|
|
5781
|
+
for (const key of keys) if (key in target) newTarget[key] = target[key];
|
|
5782
|
+
return newTarget;
|
|
5783
|
+
}
|
|
5784
|
+
function deepCopy(value) {
|
|
5785
|
+
if (typeof value !== "object" || value === null) return value;
|
|
5786
|
+
else if (Array.isArray(value)) {
|
|
5787
|
+
const array = [];
|
|
5788
|
+
for (const [i, element] of value.entries()) array[i] = deepCopy(element);
|
|
5789
|
+
return array;
|
|
5790
|
+
} else {
|
|
5791
|
+
const newObject = {};
|
|
5792
|
+
for (const key in value) newObject[key] = deepCopy(value[key]);
|
|
5793
|
+
return newObject;
|
|
5794
|
+
}
|
|
5795
|
+
}
|
|
5796
|
+
function isDeepEquals(value1, value2) {
|
|
5797
|
+
if (value1 === value2) return true;
|
|
5798
|
+
if (value1 === null) return false;
|
|
5799
|
+
if (typeof value1 !== "object") return false;
|
|
5800
|
+
if (typeof value1 !== typeof value2) return false;
|
|
5801
|
+
if (Array.isArray(value1)) {
|
|
5802
|
+
if (!Array.isArray(value2)) return false;
|
|
5803
|
+
if (value1.length !== value2.length) return false;
|
|
5804
|
+
for (const [i, value1Element] of value1.entries()) if (!isDeepEquals(value1Element, value2[i])) return false;
|
|
5805
|
+
} else {
|
|
5806
|
+
if (Array.isArray(value2)) return false;
|
|
5807
|
+
for (const key in value1) {
|
|
5808
|
+
if (!(key in value2)) return false;
|
|
5809
|
+
if (!isDeepEquals(value1[key], value2[key])) return false;
|
|
5810
|
+
}
|
|
5811
|
+
for (const key in value2) if (!(key in value1)) return false;
|
|
5812
|
+
}
|
|
5813
|
+
return true;
|
|
5814
|
+
}
|
|
5815
|
+
//#endregion
|
|
5816
|
+
//#region src/json-schema-subset/expression/result.ts
|
|
5817
|
+
var ExpressionSingleResult = Object.freeze({
|
|
5818
|
+
Equals: 0,
|
|
5819
|
+
Containing: 1,
|
|
5820
|
+
ContainedBy: 2,
|
|
5821
|
+
Rejection: 3,
|
|
5822
|
+
Intersection: 4
|
|
6431
5823
|
});
|
|
6432
5824
|
var ExpressionEquals = toExpression(ExpressionSingleResult.Equals);
|
|
6433
5825
|
var ExpressionContaining = toExpression(ExpressionSingleResult.Containing);
|
|
@@ -7319,10 +6711,10 @@ function compileEnumAndConst(context, enumList, constValue, schema) {
|
|
|
7319
6711
|
}
|
|
7320
6712
|
if (compiledEnum.length === 0) recordWarn(context, "all of elements from list is rejected by currently schema object", "enum");
|
|
7321
6713
|
}
|
|
7322
|
-
if (constValue && valid(schema, constValue) === ValidResult.Invalid) isNever = true;
|
|
6714
|
+
if (constValue !== void 0 && valid(schema, constValue) === ValidResult.Invalid) isNever = true;
|
|
7323
6715
|
if (compiledEnum) {
|
|
7324
6716
|
if (compiledEnum.length === 0) isNever = true;
|
|
7325
|
-
else if (constValue) {
|
|
6717
|
+
else if (constValue !== void 0) {
|
|
7326
6718
|
let foundEquals = false;
|
|
7327
6719
|
for (const enumValue of compiledEnum) if (isDeepEquals(enumValue, constValue)) {
|
|
7328
6720
|
foundEquals = true;
|
|
@@ -7335,7 +6727,7 @@ function compileEnumAndConst(context, enumList, constValue, schema) {
|
|
|
7335
6727
|
const compiledSchema = {};
|
|
7336
6728
|
if (schema.type) compiledSchema.type = schema.type;
|
|
7337
6729
|
if (compiledEnum) compiledSchema.enum = compiledEnum;
|
|
7338
|
-
if (constValue) compiledSchema.const = wrapCompiledValue(deepCopy(constValue));
|
|
6730
|
+
if (constValue !== void 0) compiledSchema.const = wrapCompiledValue(deepCopy(constValue));
|
|
7339
6731
|
return wrapCompiledSchema(kind, compiledSchema, context.delegate, context.path);
|
|
7340
6732
|
}
|
|
7341
6733
|
//#endregion
|
|
@@ -7730,7 +7122,7 @@ function compileSchema(context, schema) {
|
|
|
7730
7122
|
let targetSchema = schema;
|
|
7731
7123
|
let shouldHandleEnumAndConst = false;
|
|
7732
7124
|
const { enum: enumList, const: constValue } = schema;
|
|
7733
|
-
if (enumList || constValue) {
|
|
7125
|
+
if (enumList || constValue !== void 0) {
|
|
7734
7126
|
const { enum: _0, const: _1, ...rest } = schema;
|
|
7735
7127
|
targetSchema = rest;
|
|
7736
7128
|
shouldHandleEnumAndConst = true;
|
|
@@ -8320,7 +7712,7 @@ function schemaEqualsChecker(extendsContext) {
|
|
|
8320
7712
|
}
|
|
8321
7713
|
function isValueEquals(value1, value2) {
|
|
8322
7714
|
if (value1 === value2) return true;
|
|
8323
|
-
if (value1 === null) return false;
|
|
7715
|
+
if (value1 === null || value2 === null) return false;
|
|
8324
7716
|
if (typeof value1 !== "object") return false;
|
|
8325
7717
|
if (typeof value1 !== typeof value2) return false;
|
|
8326
7718
|
if (isCompiledSchema(value1) && isCompiledSchema(value2)) return isCompiledSchemaEquals(value1, value2);
|
|
@@ -8476,1096 +7868,1353 @@ function calculateInteger(schema1, schema2) {
|
|
|
8476
7868
|
if (right.fromLeft) extraLeft = true;
|
|
8477
7869
|
else extraRight = true;
|
|
8478
7870
|
}
|
|
8479
|
-
extraLeft = extraLeft || hasExtraIntegersOnCenter(integer1, centerRange, lcm);
|
|
8480
|
-
extraRight = extraRight || hasExtraIntegersOnCenter(integer2, centerRange, lcm);
|
|
8481
|
-
if (extraLeft && extraRight) return ExpressionIntersection;
|
|
8482
|
-
if (extraLeft) return ExpressionContaining;
|
|
8483
|
-
if (extraRight) return ExpressionContainedBy;
|
|
8484
|
-
return ExpressionEquals;
|
|
8485
|
-
}
|
|
8486
|
-
function hasExtraIntegersOnCenter({ range, multipleOf }, lcmCenterRange, lcm) {
|
|
8487
|
-
const result = splitRange$3(range, lcmCenterRange);
|
|
8488
|
-
if (cutRange(result.left?.range, multipleOf)) return true;
|
|
8489
|
-
if (cutRange(result.right?.range, multipleOf)) return true;
|
|
8490
|
-
const center = cutRange(result.center, multipleOf);
|
|
8491
|
-
if (!center) return false;
|
|
8492
|
-
const lcmCenterLength = rangeLength(lcmCenterRange);
|
|
8493
|
-
if (rangeLength(center) > lcmCenterLength) return true;
|
|
8494
|
-
if (lcmCenterLength === 1) return false;
|
|
8495
|
-
if (multipleOf < lcm) return true;
|
|
8496
|
-
return false;
|
|
8497
|
-
}
|
|
8498
|
-
/** Returns the least common multiple. */
|
|
8499
|
-
function getLCM(a, b) {
|
|
8500
|
-
return a * b / getGCD(a, b);
|
|
7871
|
+
extraLeft = extraLeft || hasExtraIntegersOnCenter(integer1, centerRange, lcm);
|
|
7872
|
+
extraRight = extraRight || hasExtraIntegersOnCenter(integer2, centerRange, lcm);
|
|
7873
|
+
if (extraLeft && extraRight) return ExpressionIntersection;
|
|
7874
|
+
if (extraLeft) return ExpressionContaining;
|
|
7875
|
+
if (extraRight) return ExpressionContainedBy;
|
|
7876
|
+
return ExpressionEquals;
|
|
7877
|
+
}
|
|
7878
|
+
function hasExtraIntegersOnCenter({ range, multipleOf }, lcmCenterRange, lcm) {
|
|
7879
|
+
const result = splitRange$3(range, lcmCenterRange);
|
|
7880
|
+
if (cutRange(result.left?.range, multipleOf)) return true;
|
|
7881
|
+
if (cutRange(result.right?.range, multipleOf)) return true;
|
|
7882
|
+
const center = cutRange(result.center, multipleOf);
|
|
7883
|
+
if (!center) return false;
|
|
7884
|
+
const lcmCenterLength = rangeLength(lcmCenterRange);
|
|
7885
|
+
if (rangeLength(center) > lcmCenterLength) return true;
|
|
7886
|
+
if (lcmCenterLength === 1) return false;
|
|
7887
|
+
if (multipleOf < lcm) return true;
|
|
7888
|
+
return false;
|
|
7889
|
+
}
|
|
7890
|
+
/** Returns the least common multiple. */
|
|
7891
|
+
function getLCM(a, b) {
|
|
7892
|
+
return a * b / getGCD(a, b);
|
|
7893
|
+
}
|
|
7894
|
+
/** @returns The greatest common divisor. */
|
|
7895
|
+
function getGCD(a, b) {
|
|
7896
|
+
if (a === 0) return b;
|
|
7897
|
+
return getGCD(b % a, a);
|
|
7898
|
+
}
|
|
7899
|
+
function rangeLength(range) {
|
|
7900
|
+
if (!range) return 0;
|
|
7901
|
+
const [point1, point2] = range;
|
|
7902
|
+
return point2.num - point1.num + 1;
|
|
7903
|
+
}
|
|
7904
|
+
//#endregion
|
|
7905
|
+
//#region src/json-schema-subset/checker/numeric/checker.ts
|
|
7906
|
+
function calculateNumeric(schema1, schema2) {
|
|
7907
|
+
if (isUndefinedNumber(schema1) || isUndefinedNumber(schema2)) return ExpressionAny;
|
|
7908
|
+
const isFloat1 = isFloat(schema1);
|
|
7909
|
+
const isFloat2 = isFloat(schema2);
|
|
7910
|
+
if (isFloat1 && isFloat2) return calculateFloat(schema1, schema2);
|
|
7911
|
+
else if (isFloat1) return calculateFloatAndInteger(schema1, schema2);
|
|
7912
|
+
else if (isFloat2) return swap(calculateFloatAndInteger(schema2, schema1));
|
|
7913
|
+
else return calculateInteger(schema1, schema2);
|
|
7914
|
+
}
|
|
7915
|
+
function isUndefinedNumber(schema) {
|
|
7916
|
+
const { multipleOf } = schema;
|
|
7917
|
+
if (multipleOf === void 0) return false;
|
|
7918
|
+
if (!Number.isInteger(multipleOf)) return true;
|
|
7919
|
+
if (multipleOf < 0) return true;
|
|
7920
|
+
return false;
|
|
7921
|
+
}
|
|
7922
|
+
function isFloat(schema) {
|
|
7923
|
+
const { multipleOf } = schema;
|
|
7924
|
+
if (multipleOf !== void 0 && Number.isInteger(multipleOf)) return false;
|
|
7925
|
+
if (schema.type === "integer") return false;
|
|
7926
|
+
return true;
|
|
7927
|
+
}
|
|
7928
|
+
//#endregion
|
|
7929
|
+
//#region src/json-schema-subset/checker/object.ts
|
|
7930
|
+
var splitRange$1 = createRangeSplitter(0);
|
|
7931
|
+
var quantum = makeQuantum([
|
|
7932
|
+
"hasCommonInRequired",
|
|
7933
|
+
"hasCommonOutRequired",
|
|
7934
|
+
"hasExtra1",
|
|
7935
|
+
"hasExtra2",
|
|
7936
|
+
"hasRejection"
|
|
7937
|
+
]);
|
|
7938
|
+
function calculateObject(context, schema1, schema2) {
|
|
7939
|
+
if (isPropertiesCountCannotMatch(schema1, schema2)) return ExpressionRejection;
|
|
7940
|
+
const splitRequiredResult = splitRequired(schema1, schema2);
|
|
7941
|
+
if (!splitRequiredResult) return ExpressionRejection;
|
|
7942
|
+
const getProperty1 = createPropertySchemaGetter(schema1);
|
|
7943
|
+
const getProperty2 = createPropertySchemaGetter(schema2);
|
|
7944
|
+
const calculateKey = (key) => {
|
|
7945
|
+
const propertySchema1 = getProperty1(key);
|
|
7946
|
+
const propertySchema2 = getProperty2(key);
|
|
7947
|
+
if (areNotBothNever(propertySchema1, propertySchema2)) return context.calculate(propertySchema1, propertySchema2);
|
|
7948
|
+
else return 0;
|
|
7949
|
+
};
|
|
7950
|
+
const { commonRequired, extraRequired1, extraRequired2 } = splitRequiredResult;
|
|
7951
|
+
const quantumVariable = quantum.variable({});
|
|
7952
|
+
for (const requiredKey of [...commonRequired].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateCommonRequiredExpression);
|
|
7953
|
+
for (const requiredKey of [...extraRequired1].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateExtraRequiredExpression1);
|
|
7954
|
+
for (const requiredKey of [...extraRequired2].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateExtraRequiredExpression2);
|
|
7955
|
+
const { hasOptional1, hasOptional2 } = splitRequiredResult;
|
|
7956
|
+
if (hasOptional1 || hasOptional2) {
|
|
7957
|
+
const calculator = calculateOptionalExpression(hasOptional1, hasOptional2);
|
|
7958
|
+
for (const optionalKey of [...getOptionalKeys(schema1, schema2)].toSorted()) {
|
|
7959
|
+
const expression = calculateKey(optionalKey);
|
|
7960
|
+
if (expression !== 0) quantumVariable.push(expression, calculator);
|
|
7961
|
+
}
|
|
7962
|
+
const additionalProperties1 = schema1.additionalProperties ?? ANY;
|
|
7963
|
+
const additionalProperties2 = schema2.additionalProperties ?? ANY;
|
|
7964
|
+
if (areNotBothNever(additionalProperties1, additionalProperties2)) {
|
|
7965
|
+
const expression = context.calculate(additionalProperties1, additionalProperties2);
|
|
7966
|
+
quantumVariable.push(expression, calculator);
|
|
7967
|
+
}
|
|
7968
|
+
}
|
|
7969
|
+
quantumVariable.update((variable) => {
|
|
7970
|
+
if (!variable.hasRejection) {
|
|
7971
|
+
if (extraRequired1.size > 0) variable.hasExtra2 = true;
|
|
7972
|
+
if (extraRequired2.size > 0) variable.hasExtra1 = true;
|
|
7973
|
+
}
|
|
7974
|
+
});
|
|
7975
|
+
const { requiredKeysCount } = splitRequiredResult;
|
|
7976
|
+
let expression = 0;
|
|
7977
|
+
for (const { hasExtra1, hasExtra2, hasCommonInRequired, hasCommonOutRequired, hasRejection } of quantumVariable) if (!hasCommonInRequired && requiredKeysCount > 0) expression |= ExpressionRejection;
|
|
7978
|
+
else if (!hasCommonOutRequired && requiredKeysCount === 0) expression |= ExpressionRejection;
|
|
7979
|
+
else if (hasRejection) expression |= ExpressionRejection;
|
|
7980
|
+
else if (hasExtra1 && hasExtra2) expression |= ExpressionIntersection;
|
|
7981
|
+
else if (hasExtra1) expression |= ExpressionContaining;
|
|
7982
|
+
else if (hasExtra2) expression |= ExpressionContainedBy;
|
|
7983
|
+
else expression |= ExpressionEquals;
|
|
7984
|
+
return expression;
|
|
7985
|
+
}
|
|
7986
|
+
function isPropertiesCountCannotMatch(schema1, schema2) {
|
|
7987
|
+
return toExpressionSingleResult(splitRange$1(schema1.minProperties, schema1.maxProperties, schema2.minProperties, schema2.maxProperties)) === ExpressionSingleResult.Rejection;
|
|
7988
|
+
}
|
|
7989
|
+
function splitRequired(schema1, schema2) {
|
|
7990
|
+
const extraRequired1 = new Set(schema1.required);
|
|
7991
|
+
const extraRequired2 = new Set(schema2.required);
|
|
7992
|
+
const commonRequired = /* @__PURE__ */ new Set();
|
|
7993
|
+
const wholeRequired = /* @__PURE__ */ new Set();
|
|
7994
|
+
const requiredCount1 = extraRequired1.size;
|
|
7995
|
+
const requiredCount2 = extraRequired2.size;
|
|
7996
|
+
for (const key of extraRequired1) {
|
|
7997
|
+
if (extraRequired2.has(key)) commonRequired.add(key);
|
|
7998
|
+
wholeRequired.add(key);
|
|
7999
|
+
}
|
|
8000
|
+
for (const key of extraRequired2) {
|
|
8001
|
+
if (extraRequired1.has(key)) commonRequired.add(key);
|
|
8002
|
+
wholeRequired.add(key);
|
|
8003
|
+
}
|
|
8004
|
+
const requiredKeysCount = wholeRequired.size;
|
|
8005
|
+
for (const key of commonRequired) {
|
|
8006
|
+
extraRequired1.delete(key);
|
|
8007
|
+
extraRequired2.delete(key);
|
|
8008
|
+
}
|
|
8009
|
+
const maxProperties1 = schema1.maxProperties ?? Number.MAX_SAFE_INTEGER;
|
|
8010
|
+
const maxProperties2 = schema2.maxProperties ?? Number.MAX_SAFE_INTEGER;
|
|
8011
|
+
if (requiredKeysCount > maxProperties1 || requiredKeysCount > maxProperties2) return null;
|
|
8012
|
+
return {
|
|
8013
|
+
requiredKeysCount,
|
|
8014
|
+
extraRequired1,
|
|
8015
|
+
extraRequired2,
|
|
8016
|
+
commonRequired,
|
|
8017
|
+
hasOptional1: maxProperties1 > requiredCount1,
|
|
8018
|
+
hasOptional2: maxProperties2 > requiredCount2
|
|
8019
|
+
};
|
|
8020
|
+
}
|
|
8021
|
+
function getOptionalKeys(schema1, schema2) {
|
|
8022
|
+
const optionalKeys = new Set(schema1.required);
|
|
8023
|
+
const properties1 = schema1.properties;
|
|
8024
|
+
const properties2 = schema2.properties;
|
|
8025
|
+
const required1 = schema1.required;
|
|
8026
|
+
const required2 = schema2.required;
|
|
8027
|
+
if (properties1) for (const key in properties1) optionalKeys.add(key);
|
|
8028
|
+
if (properties2) for (const key in properties2) optionalKeys.add(key);
|
|
8029
|
+
if (required1) for (const key of required1) optionalKeys.delete(key);
|
|
8030
|
+
if (required2) for (const key of required2) optionalKeys.delete(key);
|
|
8031
|
+
return optionalKeys;
|
|
8032
|
+
}
|
|
8033
|
+
var calculateCommonRequiredExpression = (singleExpression, variable) => {
|
|
8034
|
+
switch (singleExpression) {
|
|
8035
|
+
case ExpressionSingleResult.Equals:
|
|
8036
|
+
variable.hasCommonInRequired = true;
|
|
8037
|
+
break;
|
|
8038
|
+
case ExpressionSingleResult.Containing:
|
|
8039
|
+
variable.hasExtra1 = true;
|
|
8040
|
+
variable.hasCommonInRequired = true;
|
|
8041
|
+
break;
|
|
8042
|
+
case ExpressionSingleResult.ContainedBy:
|
|
8043
|
+
variable.hasExtra2 = true;
|
|
8044
|
+
variable.hasCommonInRequired = true;
|
|
8045
|
+
break;
|
|
8046
|
+
case ExpressionSingleResult.Intersection:
|
|
8047
|
+
variable.hasExtra1 = true;
|
|
8048
|
+
variable.hasExtra2 = true;
|
|
8049
|
+
variable.hasCommonInRequired = true;
|
|
8050
|
+
break;
|
|
8051
|
+
case ExpressionSingleResult.Rejection: variable.hasRejection = true;
|
|
8052
|
+
}
|
|
8053
|
+
};
|
|
8054
|
+
var calculateExtraRequiredExpression1 = (singleExpression, variable) => {
|
|
8055
|
+
switch (singleExpression) {
|
|
8056
|
+
case ExpressionSingleResult.Equals:
|
|
8057
|
+
case ExpressionSingleResult.ContainedBy:
|
|
8058
|
+
variable.hasCommonInRequired = true;
|
|
8059
|
+
break;
|
|
8060
|
+
case ExpressionSingleResult.Intersection:
|
|
8061
|
+
case ExpressionSingleResult.Containing:
|
|
8062
|
+
variable.hasExtra1 = true;
|
|
8063
|
+
variable.hasCommonInRequired = true;
|
|
8064
|
+
break;
|
|
8065
|
+
case ExpressionSingleResult.Rejection: variable.hasRejection = true;
|
|
8066
|
+
}
|
|
8067
|
+
};
|
|
8068
|
+
var calculateExtraRequiredExpression2 = (singleExpression, variable) => {
|
|
8069
|
+
switch (singleExpression) {
|
|
8070
|
+
case ExpressionSingleResult.Equals:
|
|
8071
|
+
case ExpressionSingleResult.Containing:
|
|
8072
|
+
variable.hasCommonInRequired = true;
|
|
8073
|
+
break;
|
|
8074
|
+
case ExpressionSingleResult.Intersection:
|
|
8075
|
+
case ExpressionSingleResult.ContainedBy:
|
|
8076
|
+
variable.hasExtra2 = true;
|
|
8077
|
+
variable.hasCommonInRequired = true;
|
|
8078
|
+
break;
|
|
8079
|
+
case ExpressionSingleResult.Rejection: variable.hasRejection = true;
|
|
8080
|
+
}
|
|
8081
|
+
};
|
|
8082
|
+
var calculateOptionalExpression = (hasOptional1, hasOptional2) => (singleExpression, variable) => {
|
|
8083
|
+
if (variable.hasRejection) return;
|
|
8084
|
+
let foundExtraPossibility1 = false;
|
|
8085
|
+
let foundExtraPossibility2 = false;
|
|
8086
|
+
let foundCommonPossibility = false;
|
|
8087
|
+
switch (singleExpression) {
|
|
8088
|
+
case ExpressionSingleResult.Equals:
|
|
8089
|
+
foundCommonPossibility = true;
|
|
8090
|
+
break;
|
|
8091
|
+
case ExpressionSingleResult.Containing:
|
|
8092
|
+
foundExtraPossibility1 = true;
|
|
8093
|
+
foundCommonPossibility = true;
|
|
8094
|
+
break;
|
|
8095
|
+
case ExpressionSingleResult.ContainedBy:
|
|
8096
|
+
foundExtraPossibility2 = true;
|
|
8097
|
+
foundCommonPossibility = true;
|
|
8098
|
+
break;
|
|
8099
|
+
case ExpressionSingleResult.Intersection:
|
|
8100
|
+
foundExtraPossibility1 = true;
|
|
8101
|
+
foundExtraPossibility2 = true;
|
|
8102
|
+
foundCommonPossibility = true;
|
|
8103
|
+
break;
|
|
8104
|
+
case ExpressionSingleResult.Rejection:
|
|
8105
|
+
foundExtraPossibility1 = true;
|
|
8106
|
+
foundExtraPossibility2 = true;
|
|
8107
|
+
}
|
|
8108
|
+
if (hasOptional1 && foundExtraPossibility1) variable.hasExtra1 = true;
|
|
8109
|
+
if (hasOptional2 && foundExtraPossibility2) variable.hasExtra2 = true;
|
|
8110
|
+
if (hasOptional1 && hasOptional2 && foundCommonPossibility) variable.hasCommonOutRequired = true;
|
|
8111
|
+
};
|
|
8112
|
+
function createPropertySchemaGetter(schema) {
|
|
8113
|
+
const properties = schema.properties;
|
|
8114
|
+
const propertyNames = schema.propertyNames;
|
|
8115
|
+
const additionalProperties = schema.additionalProperties;
|
|
8116
|
+
const patternProperties = [];
|
|
8117
|
+
if (schema.patternProperties) for (const pattern in schema.patternProperties) {
|
|
8118
|
+
const valueSchema = schema.patternProperties[pattern];
|
|
8119
|
+
const regExp = new RegExp(pattern, "i");
|
|
8120
|
+
patternProperties.push({
|
|
8121
|
+
pattern: regExp,
|
|
8122
|
+
schema: valueSchema
|
|
8123
|
+
});
|
|
8124
|
+
}
|
|
8125
|
+
return (key) => {
|
|
8126
|
+
if (propertyNames && valid(propertyNames, key) === ValidResult.Invalid) return NEVER;
|
|
8127
|
+
for (const { pattern, schema: patternSchema } of patternProperties) if (pattern.test(key)) return patternSchema;
|
|
8128
|
+
const propertySchema = (properties && properties[key]) ?? additionalProperties;
|
|
8129
|
+
if (!propertySchema) return ANY;
|
|
8130
|
+
return propertySchema;
|
|
8131
|
+
};
|
|
8501
8132
|
}
|
|
8502
|
-
|
|
8503
|
-
|
|
8504
|
-
|
|
8505
|
-
return
|
|
8133
|
+
function areNotBothNever(schema1, schema2) {
|
|
8134
|
+
const kind1 = getKind(schema1);
|
|
8135
|
+
const kind2 = getKind(schema2);
|
|
8136
|
+
return kind1 !== CompiledKind.Never || kind2 !== CompiledKind.Never;
|
|
8506
8137
|
}
|
|
8507
|
-
|
|
8508
|
-
|
|
8509
|
-
|
|
8510
|
-
|
|
8138
|
+
//#endregion
|
|
8139
|
+
//#region src/json-schema-subset/checker/string.ts
|
|
8140
|
+
var splitRange = createRangeSplitter(0);
|
|
8141
|
+
function calculateString(schema1, schema2) {
|
|
8142
|
+
if (schema2.format && !schema1.format) return ExpressionContaining;
|
|
8143
|
+
if (schema1.format && schema2.format && schema1.format !== schema2.format) return ExpressionAny;
|
|
8144
|
+
const expression = toExpressionSingleResult(splitRange(schema1.minLength, schema1.maxLength, schema2.minLength, schema2.maxLength));
|
|
8145
|
+
const hasPattern1 = !!schema1.pattern;
|
|
8146
|
+
const hasPattern2 = !!schema2.pattern;
|
|
8147
|
+
switch (expression) {
|
|
8148
|
+
case ExpressionSingleResult.Rejection: return ExpressionRejection;
|
|
8149
|
+
case ExpressionSingleResult.Containing: return hasPattern1 ? ExpressionAny : ExpressionContaining;
|
|
8150
|
+
case ExpressionSingleResult.ContainedBy: return hasPattern2 ? ExpressionAny : ExpressionContainedBy;
|
|
8151
|
+
case ExpressionSingleResult.Equals:
|
|
8152
|
+
if (hasPattern1 && hasPattern2) return schema1.pattern === schema2.pattern ? ExpressionEquals : ExpressionAny;
|
|
8153
|
+
if (hasPattern1) return ExpressionEquals | ExpressionContainedBy;
|
|
8154
|
+
if (hasPattern2) return ExpressionEquals | ExpressionContaining;
|
|
8155
|
+
return ExpressionEquals;
|
|
8156
|
+
case ExpressionSingleResult.Intersection:
|
|
8157
|
+
if (hasPattern1 && hasPattern2) return ExpressionAny;
|
|
8158
|
+
if (hasPattern1) return ExpressionIntersection | ExpressionRejection | ExpressionContainedBy;
|
|
8159
|
+
if (hasPattern2) return ExpressionIntersection | ExpressionRejection | ExpressionContaining;
|
|
8160
|
+
return ExpressionIntersection;
|
|
8161
|
+
}
|
|
8511
8162
|
}
|
|
8512
8163
|
//#endregion
|
|
8513
|
-
//#region src/json-schema-subset/checker/
|
|
8514
|
-
function
|
|
8515
|
-
|
|
8516
|
-
const
|
|
8517
|
-
const
|
|
8518
|
-
|
|
8519
|
-
|
|
8520
|
-
|
|
8521
|
-
|
|
8164
|
+
//#region src/json-schema-subset/checker/checker.ts
|
|
8165
|
+
function checkWithResult(extendsContext, schema1, schema2) {
|
|
8166
|
+
const context = {};
|
|
8167
|
+
const errorPaths = [];
|
|
8168
|
+
const calculate = wrapSchemaCalculatorWithCache(calculator(extendsContext, context));
|
|
8169
|
+
const describe = describer();
|
|
8170
|
+
const equals = schemaEqualsChecker(extendsContext);
|
|
8171
|
+
context.isEquals = wrapEqualsCheckerWithCache(isDeepEquals);
|
|
8172
|
+
context.calculate = expression$1({
|
|
8173
|
+
describe,
|
|
8174
|
+
equals,
|
|
8175
|
+
calculate,
|
|
8176
|
+
observeCalculation: (left, right, result, swapped) => {
|
|
8177
|
+
if (!isDecisiveMismatch(swapped ? swap(result) : result)) return;
|
|
8178
|
+
const errorPath = swapped ? findMismatchPath(right, left) : findMismatchPath(left, right);
|
|
8179
|
+
if (errorPath) errorPaths.push(errorPath);
|
|
8180
|
+
}
|
|
8181
|
+
});
|
|
8182
|
+
Object.freeze(context);
|
|
8183
|
+
const comparisonExpression = context.calculate(schema1, schema2);
|
|
8184
|
+
return {
|
|
8185
|
+
errorPath: errorPaths[0],
|
|
8186
|
+
expression: comparisonExpression
|
|
8187
|
+
};
|
|
8522
8188
|
}
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8189
|
+
var describer = () => (schema) => {
|
|
8190
|
+
let description;
|
|
8191
|
+
switch (getKind(schema)) {
|
|
8192
|
+
case CompiledKind.Not:
|
|
8193
|
+
description = {
|
|
8194
|
+
kind: ExpressionKind.Not,
|
|
8195
|
+
expression: schema.not
|
|
8196
|
+
};
|
|
8197
|
+
break;
|
|
8198
|
+
case CompiledKind.Combination:
|
|
8199
|
+
if ("allOf" in schema) description = {
|
|
8200
|
+
kind: ExpressionKind.AllOf,
|
|
8201
|
+
expressions: rejectInSchemaList(schema.allOf, CompiledKind.Any)
|
|
8202
|
+
};
|
|
8203
|
+
else if ("anyOf" in schema) description = {
|
|
8204
|
+
kind: ExpressionKind.AnyOf,
|
|
8205
|
+
expressions: rejectInSchemaList(schema.anyOf, CompiledKind.Never)
|
|
8206
|
+
};
|
|
8207
|
+
else if ("oneOf" in schema) description = {
|
|
8208
|
+
kind: ExpressionKind.OneOf,
|
|
8209
|
+
expressions: rejectInSchemaList(schema.oneOf, CompiledKind.Never)
|
|
8210
|
+
};
|
|
8211
|
+
else throw new Error(`invalid combination JSON Schema: ${JSON.stringify(schema)}`);
|
|
8212
|
+
break;
|
|
8213
|
+
default: description = { kind: ExpressionKind.Leaf };
|
|
8214
|
+
}
|
|
8215
|
+
return description;
|
|
8216
|
+
};
|
|
8217
|
+
var calculator = (extendsContext, context) => (schema1, schema2) => {
|
|
8218
|
+
const kind1 = getKind(schema1);
|
|
8219
|
+
const kind2 = getKind(schema2);
|
|
8220
|
+
if (kind1 === CompiledKind.Extends || kind2 === CompiledKind.Extends) return extendsContext.calculate(schema1, schema2);
|
|
8221
|
+
switch (kind1) {
|
|
8222
|
+
case CompiledKind.Any: return kind2 === CompiledKind.Any ? ExpressionEquals : ExpressionContaining;
|
|
8223
|
+
case CompiledKind.Never: return kind2 === CompiledKind.Never ? ExpressionEquals : ExpressionContainedBy;
|
|
8224
|
+
}
|
|
8225
|
+
switch (kind2) {
|
|
8226
|
+
case CompiledKind.Any: return ExpressionContainedBy;
|
|
8227
|
+
case CompiledKind.Never: return ExpressionContaining;
|
|
8228
|
+
}
|
|
8229
|
+
if (kind1 === CompiledKind.EnumOrConst && kind2 === CompiledKind.EnumOrConst) return calculateEnumAndEnum(context, schema1, schema2);
|
|
8230
|
+
if (kind1 === CompiledKind.EnumOrConst) return calculateEnumAndSchema(schema1, schema2);
|
|
8231
|
+
if (kind2 === CompiledKind.EnumOrConst) return swap(calculateEnumAndSchema(schema2, schema1));
|
|
8232
|
+
if (kind1 !== kind2) return ExpressionRejection;
|
|
8233
|
+
switch (kind1) {
|
|
8234
|
+
case CompiledKind.Null: return ExpressionEquals;
|
|
8235
|
+
case CompiledKind.Numeric: return calculateNumeric(schema1, schema2);
|
|
8236
|
+
case CompiledKind.String: return calculateString(schema1, schema2);
|
|
8237
|
+
case CompiledKind.Boolean: return ExpressionEquals;
|
|
8238
|
+
case CompiledKind.Object: return calculateObject(context, schema1, schema2);
|
|
8239
|
+
case CompiledKind.Array: return calculateArray(context, schema1, schema2);
|
|
8240
|
+
default: throw new Error(`invalid kind ${kind1}`);
|
|
8241
|
+
}
|
|
8242
|
+
};
|
|
8243
|
+
function rejectInSchemaList(schemaList, kind) {
|
|
8244
|
+
return schemaList.filter((e) => getKind(e) !== kind);
|
|
8529
8245
|
}
|
|
8530
|
-
function
|
|
8531
|
-
|
|
8532
|
-
|
|
8533
|
-
|
|
8534
|
-
|
|
8246
|
+
function isDecisiveMismatch(result) {
|
|
8247
|
+
return !hasEquals(result) && !hasContainedBy(result) && (hasContaining(result) || hasIntersection(result) || hasRejection(result));
|
|
8248
|
+
}
|
|
8249
|
+
function findMismatchPath(source, target) {
|
|
8250
|
+
const targetPath = getPath(target);
|
|
8251
|
+
if (!targetPath) return void 0;
|
|
8252
|
+
const sourceKind = getKind(source);
|
|
8253
|
+
const targetKind = getKind(target);
|
|
8254
|
+
if (sourceKind !== targetKind) return [...targetPath, "type"];
|
|
8255
|
+
const sourceSchema = source;
|
|
8256
|
+
const targetSchema = target;
|
|
8257
|
+
switch (targetKind) {
|
|
8258
|
+
case CompiledKind.String:
|
|
8259
|
+
if ((sourceSchema.minLength ?? 0) < (targetSchema.minLength ?? 0)) return [...targetPath, "minLength"];
|
|
8260
|
+
if ((sourceSchema.maxLength ?? Number.POSITIVE_INFINITY) > (targetSchema.maxLength ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxLength"];
|
|
8261
|
+
if (sourceSchema.pattern !== targetSchema.pattern && targetSchema.pattern) return [...targetPath, "pattern"];
|
|
8262
|
+
if (sourceSchema.format !== targetSchema.format && targetSchema.format) return [...targetPath, "format"];
|
|
8263
|
+
break;
|
|
8264
|
+
case CompiledKind.Numeric:
|
|
8265
|
+
if ((sourceSchema.minimum ?? sourceSchema.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) < (targetSchema.minimum ?? targetSchema.exclusiveMinimum ?? Number.NEGATIVE_INFINITY)) return [...targetPath, targetSchema.exclusiveMinimum == null ? "minimum" : "exclusiveMinimum"];
|
|
8266
|
+
if ((sourceSchema.maximum ?? sourceSchema.exclusiveMaximum ?? Number.POSITIVE_INFINITY) > (targetSchema.maximum ?? targetSchema.exclusiveMaximum ?? Number.POSITIVE_INFINITY)) return [...targetPath, targetSchema.exclusiveMaximum == null ? "maximum" : "exclusiveMaximum"];
|
|
8267
|
+
if (sourceSchema.multipleOf !== targetSchema.multipleOf && targetSchema.multipleOf != null) return [...targetPath, "multipleOf"];
|
|
8268
|
+
break;
|
|
8269
|
+
case CompiledKind.Array:
|
|
8270
|
+
if ((sourceSchema.minItems ?? 0) < (targetSchema.minItems ?? 0)) return [...targetPath, "minItems"];
|
|
8271
|
+
if ((sourceSchema.maxItems ?? Number.POSITIVE_INFINITY) > (targetSchema.maxItems ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxItems"];
|
|
8272
|
+
if (!sourceSchema.uniqueItems && targetSchema.uniqueItems) return [...targetPath, "uniqueItems"];
|
|
8273
|
+
break;
|
|
8274
|
+
case CompiledKind.Object: {
|
|
8275
|
+
const sourceRequired = new Set(sourceSchema.required ?? []);
|
|
8276
|
+
if ((targetSchema.required ?? []).some((key) => !sourceRequired.has(key))) return [...targetPath, "required"];
|
|
8277
|
+
if ((sourceSchema.minProperties ?? 0) < (targetSchema.minProperties ?? 0)) return [...targetPath, "minProperties"];
|
|
8278
|
+
if ((sourceSchema.maxProperties ?? Number.POSITIVE_INFINITY) > (targetSchema.maxProperties ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxProperties"];
|
|
8279
|
+
break;
|
|
8280
|
+
}
|
|
8281
|
+
case CompiledKind.EnumOrConst: return [...targetPath, targetSchema.const === void 0 ? "enum" : "const"];
|
|
8282
|
+
}
|
|
8283
|
+
return targetPath;
|
|
8535
8284
|
}
|
|
8536
8285
|
//#endregion
|
|
8537
|
-
//#region src/json-schema-subset/
|
|
8538
|
-
var
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
|
|
8558
|
-
|
|
8559
|
-
const quantumVariable = quantum.variable({});
|
|
8560
|
-
for (const requiredKey of [...commonRequired].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateCommonRequiredExpression);
|
|
8561
|
-
for (const requiredKey of [...extraRequired1].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateExtraRequiredExpression1);
|
|
8562
|
-
for (const requiredKey of [...extraRequired2].toSorted()) quantumVariable.push(calculateKey(requiredKey), calculateExtraRequiredExpression2);
|
|
8563
|
-
const { hasOptional1, hasOptional2 } = splitRequiredResult;
|
|
8564
|
-
if (hasOptional1 || hasOptional2) {
|
|
8565
|
-
const calculator = calculateOptionalExpression(hasOptional1, hasOptional2);
|
|
8566
|
-
for (const optionalKey of [...getOptionalKeys(schema1, schema2)].toSorted()) {
|
|
8567
|
-
const expression = calculateKey(optionalKey);
|
|
8568
|
-
if (expression !== 0) quantumVariable.push(expression, calculator);
|
|
8286
|
+
//#region src/json-schema-subset/extends/extendsContext.ts
|
|
8287
|
+
var ExtendsContext = class ExtendsContext {
|
|
8288
|
+
constructor(extendsSchemaClasses = []) {
|
|
8289
|
+
this.extendsSchemaClasses = Object.freeze([...extendsSchemaClasses]);
|
|
8290
|
+
}
|
|
8291
|
+
tryCompiledExtendsSchema(target, payload) {
|
|
8292
|
+
for (const extendsSchemaClass of this.extendsSchemaClasses) if (extendsSchemaClass.isMatch(target)) return new extendsSchemaClass(createId(), target, payload);
|
|
8293
|
+
return null;
|
|
8294
|
+
}
|
|
8295
|
+
isExtendsSchema(target) {
|
|
8296
|
+
for (const extendsSchemaClass of this.extendsSchemaClasses) if (target instanceof extendsSchemaClass) return true;
|
|
8297
|
+
return false;
|
|
8298
|
+
}
|
|
8299
|
+
calculate(schema1, schema2) {
|
|
8300
|
+
const shouldSwap = !(schema1 instanceof this.findMatchedClass(schema1, schema2));
|
|
8301
|
+
let expressionResult = 0;
|
|
8302
|
+
let result;
|
|
8303
|
+
if (shouldSwap) result = schema2.compare(schema1);
|
|
8304
|
+
else result = schema1.compare(schema2);
|
|
8305
|
+
for (let expression of result) {
|
|
8306
|
+
if (shouldSwap) expression = ExtendsContext.swap(expression);
|
|
8307
|
+
expressionResult |= toExpression(expression);
|
|
8569
8308
|
}
|
|
8570
|
-
|
|
8571
|
-
|
|
8572
|
-
|
|
8573
|
-
|
|
8574
|
-
|
|
8309
|
+
return expressionResult;
|
|
8310
|
+
}
|
|
8311
|
+
equals(schema1, schema2) {
|
|
8312
|
+
if (!(schema1 instanceof this.findMatchedClass(schema1, schema2))) return schema2.equals(schema1);
|
|
8313
|
+
else return schema1.equals(schema2);
|
|
8314
|
+
}
|
|
8315
|
+
findMatchedClass(schema1, schema2) {
|
|
8316
|
+
for (const schemaClass of this.extendsSchemaClasses) {
|
|
8317
|
+
if (schema1 instanceof schemaClass) return schemaClass;
|
|
8318
|
+
if (schema2 instanceof schemaClass) return schemaClass;
|
|
8575
8319
|
}
|
|
8320
|
+
throw new Error("Invalid schema");
|
|
8576
8321
|
}
|
|
8577
|
-
|
|
8578
|
-
|
|
8579
|
-
|
|
8580
|
-
|
|
8322
|
+
static swap(expression) {
|
|
8323
|
+
switch (expression) {
|
|
8324
|
+
case ExpressionSingleResult.Containing: return ExpressionSingleResult.ContainedBy;
|
|
8325
|
+
case ExpressionSingleResult.ContainedBy: return ExpressionSingleResult.Containing;
|
|
8326
|
+
default: return expression;
|
|
8581
8327
|
}
|
|
8582
|
-
}
|
|
8583
|
-
|
|
8584
|
-
|
|
8585
|
-
|
|
8586
|
-
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8592
|
-
|
|
8593
|
-
}
|
|
8594
|
-
|
|
8595
|
-
|
|
8328
|
+
}
|
|
8329
|
+
};
|
|
8330
|
+
//#endregion
|
|
8331
|
+
//#region src/json-schema-subset/preprocessing.ts
|
|
8332
|
+
function preprocessSchema(schema, compile, printWarnLog = false) {
|
|
8333
|
+
const schemaResult = compile(schema);
|
|
8334
|
+
if (Array.isArray(schemaResult)) {
|
|
8335
|
+
const errorItems = [];
|
|
8336
|
+
collectWithPathPrefix(errorItems, schemaResult, "$");
|
|
8337
|
+
throw new SchemaError(errorItems);
|
|
8338
|
+
}
|
|
8339
|
+
const { schema: compiledSchema, warns } = schemaResult;
|
|
8340
|
+
if (printWarnLog && warns.length > 0) {
|
|
8341
|
+
console.warn(`found ${warns.length} warns after compile schema`);
|
|
8342
|
+
for (const warn of warns) console.warn(stringifySchemaError(warn));
|
|
8343
|
+
}
|
|
8344
|
+
return compiledSchema;
|
|
8596
8345
|
}
|
|
8597
|
-
function
|
|
8598
|
-
const
|
|
8599
|
-
const
|
|
8600
|
-
|
|
8601
|
-
|
|
8602
|
-
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
if (extraRequired2.has(key)) commonRequired.add(key);
|
|
8606
|
-
wholeRequired.add(key);
|
|
8346
|
+
function preprocessSchemasPair(schema1, schema2, compile, printWarnLog = false) {
|
|
8347
|
+
const schemaResult1 = compile(schema1);
|
|
8348
|
+
const schemaResult2 = compile(schema2);
|
|
8349
|
+
if (Array.isArray(schemaResult1) || Array.isArray(schemaResult2)) {
|
|
8350
|
+
const errorItems = [];
|
|
8351
|
+
if (Array.isArray(schemaResult1)) collectWithPathPrefix(errorItems, schemaResult1, "$1");
|
|
8352
|
+
if (Array.isArray(schemaResult2)) collectWithPathPrefix(errorItems, schemaResult2, "$2");
|
|
8353
|
+
throw new SchemaError(errorItems);
|
|
8607
8354
|
}
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8355
|
+
const { schema: compiledSchema1, warns: superWarns } = schemaResult1;
|
|
8356
|
+
const { schema: compiledSchema2, warns: subWarns } = schemaResult2;
|
|
8357
|
+
if (printWarnLog) {
|
|
8358
|
+
if (superWarns.length > 0) console.warn(`found ${superWarns.length} warns after compile superSchema`);
|
|
8359
|
+
for (const warn of superWarns) console.warn(stringifySchemaError(warn));
|
|
8360
|
+
if (subWarns.length > 0) console.warn(`found ${subWarns.length} warns after compile subSchema`);
|
|
8361
|
+
for (const warn of subWarns) console.warn(stringifySchemaError(warn));
|
|
8611
8362
|
}
|
|
8612
|
-
|
|
8613
|
-
|
|
8614
|
-
|
|
8615
|
-
|
|
8363
|
+
return [compiledSchema1, compiledSchema2];
|
|
8364
|
+
}
|
|
8365
|
+
function collectWithPathPrefix(errorItems, compiledItems, prefix) {
|
|
8366
|
+
for (const compiledItem of compiledItems) {
|
|
8367
|
+
const replacedItem = {
|
|
8368
|
+
...compiledItem,
|
|
8369
|
+
path: [prefix, ...compiledItem.path]
|
|
8370
|
+
};
|
|
8371
|
+
errorItems.push(replacedItem);
|
|
8616
8372
|
}
|
|
8617
|
-
const maxProperties1 = schema1.maxProperties ?? Number.MAX_SAFE_INTEGER;
|
|
8618
|
-
const maxProperties2 = schema2.maxProperties ?? Number.MAX_SAFE_INTEGER;
|
|
8619
|
-
if (requiredKeysCount > maxProperties1 || requiredKeysCount > maxProperties2) return null;
|
|
8620
|
-
return {
|
|
8621
|
-
requiredKeysCount,
|
|
8622
|
-
extraRequired1,
|
|
8623
|
-
extraRequired2,
|
|
8624
|
-
commonRequired,
|
|
8625
|
-
hasOptional1: maxProperties1 > requiredCount1,
|
|
8626
|
-
hasOptional2: maxProperties2 > requiredCount2
|
|
8627
|
-
};
|
|
8628
8373
|
}
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8374
|
+
//#endregion
|
|
8375
|
+
//#region src/json-schema-subset/global.ts
|
|
8376
|
+
var SubsetCompareResult = Object.freeze({
|
|
8377
|
+
True: 0,
|
|
8378
|
+
False: 1,
|
|
8379
|
+
Unknown: 2
|
|
8380
|
+
});
|
|
8381
|
+
function makeSubsetCompare({ extendsSchemaClasses, delegate } = {}) {
|
|
8382
|
+
const extendsContext = new ExtendsContext(extendsSchemaClasses);
|
|
8383
|
+
return Object.freeze({
|
|
8384
|
+
compile: (schema, payload, printWarnLog) => {
|
|
8385
|
+
const compiler = (candidate) => compile(candidate, extendsContext, payload, delegate);
|
|
8386
|
+
return preprocessSchema(schema, compiler, printWarnLog);
|
|
8387
|
+
},
|
|
8388
|
+
isSubset: (superSchema, subSchema, printWarnLog = false) => {
|
|
8389
|
+
const compiler = (candidate) => compile(candidate, extendsContext, void 0, delegate);
|
|
8390
|
+
const [schema1, schema2] = preprocessSchemasPair(superSchema, subSchema, compiler, printWarnLog);
|
|
8391
|
+
const { errorPath, expression } = checkWithResult(extendsContext, schema1, schema2);
|
|
8392
|
+
const foundTrueExpression = hasEquals(expression) || hasContainedBy(expression);
|
|
8393
|
+
const foundFalseExpression = hasContaining(expression) || hasIntersection(expression) || hasRejection(expression);
|
|
8394
|
+
if (foundTrueExpression && !foundFalseExpression) return { result: SubsetCompareResult.True };
|
|
8395
|
+
if (!foundTrueExpression && foundFalseExpression) return {
|
|
8396
|
+
errorPath,
|
|
8397
|
+
result: SubsetCompareResult.False
|
|
8398
|
+
};
|
|
8399
|
+
return { result: SubsetCompareResult.Unknown };
|
|
8400
|
+
}
|
|
8401
|
+
});
|
|
8640
8402
|
}
|
|
8641
|
-
|
|
8642
|
-
|
|
8643
|
-
|
|
8644
|
-
|
|
8645
|
-
|
|
8646
|
-
|
|
8647
|
-
|
|
8648
|
-
|
|
8649
|
-
|
|
8650
|
-
|
|
8651
|
-
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8655
|
-
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8659
|
-
|
|
8403
|
+
//#endregion
|
|
8404
|
+
//#region ../../node_modules/.bun/@wopjs+cast@0.1.16/node_modules/@wopjs/cast/dist/index.mjs
|
|
8405
|
+
var isString = (x) => typeof x === "string";
|
|
8406
|
+
var isArray = Array.isArray;
|
|
8407
|
+
var isObject = (x) => x !== null && typeof x === "object";
|
|
8408
|
+
var isPlainObject = (x) => isObject(x) && !isArray(x);
|
|
8409
|
+
var toPlainObject = (x) => isPlainObject(x) ? x : void 0;
|
|
8410
|
+
//#endregion
|
|
8411
|
+
//#region src/flow/common/schemaComparer.ts
|
|
8412
|
+
function isStringLikeSchema(value) {
|
|
8413
|
+
return toPlainObject(value)?.type === "string";
|
|
8414
|
+
}
|
|
8415
|
+
function assertSchemaCompareContext(value) {
|
|
8416
|
+
const context = toPlainObject(value);
|
|
8417
|
+
const error = toPlainObject(context?.error);
|
|
8418
|
+
if (context == null || error == null || context.packageId != null && !isString(context.packageId) || error.message != null && !isString(error.message)) throw new TypeError("Invalid schema comparison context.");
|
|
8419
|
+
}
|
|
8420
|
+
function parseSchemaCompareContext(value) {
|
|
8421
|
+
if (value == null) return { error: {} };
|
|
8422
|
+
assertSchemaCompareContext(value);
|
|
8423
|
+
return value;
|
|
8424
|
+
}
|
|
8425
|
+
var SpecialSchema = class SpecialSchema {
|
|
8426
|
+
static setError(fromSchema, toSchema, message) {
|
|
8427
|
+
if (fromSchema instanceof SpecialSchema) fromSchema.context.error.message = message;
|
|
8428
|
+
else if (toSchema instanceof SpecialSchema) toSchema.context.error.message = message;
|
|
8660
8429
|
}
|
|
8661
|
-
|
|
8662
|
-
|
|
8663
|
-
|
|
8664
|
-
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
case ExpressionSingleResult.Containing:
|
|
8670
|
-
variable.hasExtra1 = true;
|
|
8671
|
-
variable.hasCommonInRequired = true;
|
|
8672
|
-
break;
|
|
8673
|
-
case ExpressionSingleResult.Rejection: variable.hasRejection = true;
|
|
8430
|
+
constructor(id, value, context) {
|
|
8431
|
+
this.id = id;
|
|
8432
|
+
this.value = value;
|
|
8433
|
+
this.context = parseSchemaCompareContext(context);
|
|
8434
|
+
}
|
|
8435
|
+
compare(other) {
|
|
8436
|
+
if (isCompiledSchema(other) && getKind(other) === CompiledKind.Any) return [ExpressionSingleResult.ContainedBy];
|
|
8437
|
+
return this.compareImpl(other);
|
|
8674
8438
|
}
|
|
8675
8439
|
};
|
|
8676
|
-
var
|
|
8677
|
-
|
|
8678
|
-
|
|
8679
|
-
|
|
8680
|
-
|
|
8681
|
-
|
|
8682
|
-
|
|
8683
|
-
|
|
8684
|
-
|
|
8685
|
-
|
|
8686
|
-
|
|
8687
|
-
|
|
8440
|
+
var SingleSelectSchema = class SingleSelectSchema extends SpecialSchema {
|
|
8441
|
+
static isMatch(value) {
|
|
8442
|
+
const enumValues = toPlainObject(value)?.enum;
|
|
8443
|
+
return Array.isArray(enumValues) && enumValues.every((v) => isString(v));
|
|
8444
|
+
}
|
|
8445
|
+
constructor(id, value, context) {
|
|
8446
|
+
if (!SingleSelectSchema.isMatch(value)) throw new TypeError("Invalid single-select schema.");
|
|
8447
|
+
super(id, value, context);
|
|
8448
|
+
}
|
|
8449
|
+
compareImpl(other) {
|
|
8450
|
+
if (isStringLikeSchema(other)) return [ExpressionSingleResult.ContainedBy];
|
|
8451
|
+
if (other instanceof SingleSelectSchema) {
|
|
8452
|
+
const f = new Set(this.value.enum);
|
|
8453
|
+
let result = ExpressionSingleResult.Equals;
|
|
8454
|
+
for (const v of other.value.enum) {
|
|
8455
|
+
if (!f.has(v)) result = ExpressionSingleResult.ContainedBy;
|
|
8456
|
+
f.delete(v);
|
|
8457
|
+
}
|
|
8458
|
+
if (f.size === 0) return [result];
|
|
8459
|
+
if (f.size === this.value.enum.length) return [ExpressionSingleResult.Rejection];
|
|
8460
|
+
return [ExpressionSingleResult.Intersection];
|
|
8461
|
+
}
|
|
8462
|
+
return [ExpressionSingleResult.Rejection];
|
|
8688
8463
|
}
|
|
8689
|
-
|
|
8690
|
-
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
case ExpressionSingleResult.Containing:
|
|
8700
|
-
foundExtraPossibility1 = true;
|
|
8701
|
-
foundCommonPossibility = true;
|
|
8702
|
-
break;
|
|
8703
|
-
case ExpressionSingleResult.ContainedBy:
|
|
8704
|
-
foundExtraPossibility2 = true;
|
|
8705
|
-
foundCommonPossibility = true;
|
|
8706
|
-
break;
|
|
8707
|
-
case ExpressionSingleResult.Intersection:
|
|
8708
|
-
foundExtraPossibility1 = true;
|
|
8709
|
-
foundExtraPossibility2 = true;
|
|
8710
|
-
foundCommonPossibility = true;
|
|
8711
|
-
break;
|
|
8712
|
-
case ExpressionSingleResult.Rejection:
|
|
8713
|
-
foundExtraPossibility1 = true;
|
|
8714
|
-
foundExtraPossibility2 = true;
|
|
8464
|
+
equals(other) {
|
|
8465
|
+
if (other instanceof SingleSelectSchema) {
|
|
8466
|
+
const f = new Set(this.value.enum);
|
|
8467
|
+
for (const v of other.value.enum) {
|
|
8468
|
+
if (!f.has(v)) return false;
|
|
8469
|
+
f.delete(v);
|
|
8470
|
+
}
|
|
8471
|
+
return f.size === 0;
|
|
8472
|
+
}
|
|
8473
|
+
return false;
|
|
8715
8474
|
}
|
|
8716
|
-
if (hasOptional1 && foundExtraPossibility1) variable.hasExtra1 = true;
|
|
8717
|
-
if (hasOptional2 && foundExtraPossibility2) variable.hasExtra2 = true;
|
|
8718
|
-
if (hasOptional1 && hasOptional2 && foundCommonPossibility) variable.hasCommonOutRequired = true;
|
|
8719
8475
|
};
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
const additionalProperties = schema.additionalProperties;
|
|
8724
|
-
const patternProperties = [];
|
|
8725
|
-
if (schema.patternProperties) for (const pattern in schema.patternProperties) {
|
|
8726
|
-
const valueSchema = schema.patternProperties[pattern];
|
|
8727
|
-
const regExp = new RegExp(pattern, "i");
|
|
8728
|
-
patternProperties.push({
|
|
8729
|
-
pattern: regExp,
|
|
8730
|
-
schema: valueSchema
|
|
8731
|
-
});
|
|
8476
|
+
var BinarySchema = class BinarySchema extends SpecialSchema {
|
|
8477
|
+
static isMatch(value) {
|
|
8478
|
+
return toPlainObject(value)?.contentMediaType === "oomol/bin";
|
|
8732
8479
|
}
|
|
8733
|
-
|
|
8734
|
-
if (
|
|
8735
|
-
|
|
8736
|
-
const propertySchema = (properties && properties[key]) ?? additionalProperties;
|
|
8737
|
-
if (!propertySchema) return ANY;
|
|
8738
|
-
return propertySchema;
|
|
8739
|
-
};
|
|
8740
|
-
}
|
|
8741
|
-
function areNotBothNever(schema1, schema2) {
|
|
8742
|
-
const kind1 = getKind(schema1);
|
|
8743
|
-
const kind2 = getKind(schema2);
|
|
8744
|
-
return kind1 !== CompiledKind.Never || kind2 !== CompiledKind.Never;
|
|
8745
|
-
}
|
|
8746
|
-
//#endregion
|
|
8747
|
-
//#region src/json-schema-subset/checker/string.ts
|
|
8748
|
-
var splitRange = createRangeSplitter(0);
|
|
8749
|
-
function calculateString(schema1, schema2) {
|
|
8750
|
-
if (schema2.format && !schema1.format) return ExpressionContaining;
|
|
8751
|
-
if (schema1.format && schema2.format && schema1.format !== schema2.format) return ExpressionAny;
|
|
8752
|
-
const expression = toExpressionSingleResult(splitRange(schema1.minLength, schema1.maxLength, schema2.minLength, schema2.maxLength));
|
|
8753
|
-
const hasPattern1 = !!schema1.pattern;
|
|
8754
|
-
const hasPattern2 = !!schema2.pattern;
|
|
8755
|
-
switch (expression) {
|
|
8756
|
-
case ExpressionSingleResult.Rejection: return ExpressionRejection;
|
|
8757
|
-
case ExpressionSingleResult.Containing: return hasPattern1 ? ExpressionAny : ExpressionContaining;
|
|
8758
|
-
case ExpressionSingleResult.ContainedBy: return hasPattern2 ? ExpressionAny : ExpressionContainedBy;
|
|
8759
|
-
case ExpressionSingleResult.Equals:
|
|
8760
|
-
if (hasPattern1 && hasPattern2) return schema1.pattern === schema2.pattern ? ExpressionEquals : ExpressionAny;
|
|
8761
|
-
if (hasPattern1) return ExpressionEquals | ExpressionContainedBy;
|
|
8762
|
-
if (hasPattern2) return ExpressionEquals | ExpressionContaining;
|
|
8763
|
-
return ExpressionEquals;
|
|
8764
|
-
case ExpressionSingleResult.Intersection:
|
|
8765
|
-
if (hasPattern1 && hasPattern2) return ExpressionAny;
|
|
8766
|
-
if (hasPattern1) return ExpressionIntersection | ExpressionRejection | ExpressionContainedBy;
|
|
8767
|
-
if (hasPattern2) return ExpressionIntersection | ExpressionRejection | ExpressionContaining;
|
|
8768
|
-
return ExpressionIntersection;
|
|
8480
|
+
constructor(id, value, context) {
|
|
8481
|
+
if (!BinarySchema.isMatch(value)) throw new TypeError("Invalid binary schema.");
|
|
8482
|
+
super(id, value, context);
|
|
8769
8483
|
}
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
|
|
8774
|
-
|
|
8775
|
-
const errorPaths = [];
|
|
8776
|
-
const calculate = wrapSchemaCalculatorWithCache(calculator(extendsContext, context));
|
|
8777
|
-
const describe = describer();
|
|
8778
|
-
const equals = schemaEqualsChecker(extendsContext);
|
|
8779
|
-
context.isEquals = wrapEqualsCheckerWithCache(isDeepEquals);
|
|
8780
|
-
context.calculate = expression$1({
|
|
8781
|
-
describe,
|
|
8782
|
-
equals,
|
|
8783
|
-
calculate,
|
|
8784
|
-
observeCalculation: (left, right, result, swapped) => {
|
|
8785
|
-
if (!isDecisiveMismatch(swapped ? swap(result) : result)) return;
|
|
8786
|
-
const errorPath = swapped ? findMismatchPath(right, left) : findMismatchPath(left, right);
|
|
8787
|
-
if (errorPath) errorPaths.push(errorPath);
|
|
8484
|
+
compareImpl(other) {
|
|
8485
|
+
if (other instanceof BinarySchema) return [ExpressionSingleResult.Equals];
|
|
8486
|
+
else {
|
|
8487
|
+
SpecialSchema.setError(this, other, "edgeError.binDiffType");
|
|
8488
|
+
return [ExpressionSingleResult.Rejection];
|
|
8788
8489
|
}
|
|
8789
|
-
});
|
|
8790
|
-
Object.freeze(context);
|
|
8791
|
-
const comparisonExpression = context.calculate(schema1, schema2);
|
|
8792
|
-
return {
|
|
8793
|
-
errorPath: errorPaths[0],
|
|
8794
|
-
expression: comparisonExpression
|
|
8795
|
-
};
|
|
8796
|
-
}
|
|
8797
|
-
var describer = () => (schema) => {
|
|
8798
|
-
let description;
|
|
8799
|
-
switch (getKind(schema)) {
|
|
8800
|
-
case CompiledKind.Not:
|
|
8801
|
-
description = {
|
|
8802
|
-
kind: ExpressionKind.Not,
|
|
8803
|
-
expression: schema.not
|
|
8804
|
-
};
|
|
8805
|
-
break;
|
|
8806
|
-
case CompiledKind.Combination:
|
|
8807
|
-
if ("allOf" in schema) description = {
|
|
8808
|
-
kind: ExpressionKind.AllOf,
|
|
8809
|
-
expressions: rejectInSchemaList(schema.allOf, CompiledKind.Any)
|
|
8810
|
-
};
|
|
8811
|
-
else if ("anyOf" in schema) description = {
|
|
8812
|
-
kind: ExpressionKind.AnyOf,
|
|
8813
|
-
expressions: rejectInSchemaList(schema.anyOf, CompiledKind.Never)
|
|
8814
|
-
};
|
|
8815
|
-
else if ("oneOf" in schema) description = {
|
|
8816
|
-
kind: ExpressionKind.OneOf,
|
|
8817
|
-
expressions: rejectInSchemaList(schema.oneOf, CompiledKind.Never)
|
|
8818
|
-
};
|
|
8819
|
-
else throw new Error(`invalid combination JSON Schema: ${JSON.stringify(schema)}`);
|
|
8820
|
-
break;
|
|
8821
|
-
default: description = { kind: ExpressionKind.Leaf };
|
|
8822
8490
|
}
|
|
8823
|
-
|
|
8491
|
+
equals(other) {
|
|
8492
|
+
return other instanceof BinarySchema;
|
|
8493
|
+
}
|
|
8824
8494
|
};
|
|
8825
|
-
var
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
if (kind1 === CompiledKind.Extends || kind2 === CompiledKind.Extends) return extendsContext.calculate(schema1, schema2);
|
|
8829
|
-
switch (kind1) {
|
|
8830
|
-
case CompiledKind.Any: return kind2 === CompiledKind.Any ? ExpressionEquals : ExpressionContaining;
|
|
8831
|
-
case CompiledKind.Never: return kind2 === CompiledKind.Never ? ExpressionEquals : ExpressionContainedBy;
|
|
8495
|
+
var ArtifactSchema = class ArtifactSchema extends SpecialSchema {
|
|
8496
|
+
static isMatch(value) {
|
|
8497
|
+
return toPlainObject(value)?.contentMediaType === "oomol/artifact";
|
|
8832
8498
|
}
|
|
8833
|
-
|
|
8834
|
-
|
|
8835
|
-
|
|
8499
|
+
constructor(id, value, context) {
|
|
8500
|
+
if (!ArtifactSchema.isMatch(value)) throw new TypeError("Invalid Artifact schema.");
|
|
8501
|
+
super(id, value, context);
|
|
8836
8502
|
}
|
|
8837
|
-
|
|
8838
|
-
|
|
8839
|
-
|
|
8840
|
-
|
|
8841
|
-
|
|
8842
|
-
|
|
8843
|
-
|
|
8844
|
-
case CompiledKind.String: return calculateString(schema1, schema2);
|
|
8845
|
-
case CompiledKind.Boolean: return ExpressionEquals;
|
|
8846
|
-
case CompiledKind.Object: return calculateObject(context, schema1, schema2);
|
|
8847
|
-
case CompiledKind.Array: return calculateArray(context, schema1, schema2);
|
|
8848
|
-
default: throw new Error(`invalid kind ${kind1}`);
|
|
8503
|
+
compareImpl(other) {
|
|
8504
|
+
if (other instanceof ArtifactSchema) return [ExpressionSingleResult.Equals];
|
|
8505
|
+
SpecialSchema.setError(this, other, "edgeError.artifactDiffType");
|
|
8506
|
+
return [ExpressionSingleResult.Rejection];
|
|
8507
|
+
}
|
|
8508
|
+
equals(other) {
|
|
8509
|
+
return other instanceof ArtifactSchema;
|
|
8849
8510
|
}
|
|
8850
8511
|
};
|
|
8851
|
-
function
|
|
8852
|
-
return
|
|
8512
|
+
function createSchemaComparer() {
|
|
8513
|
+
return makeSubsetCompare({ extendsSchemaClasses: [
|
|
8514
|
+
SingleSelectSchema,
|
|
8515
|
+
BinarySchema,
|
|
8516
|
+
ArtifactSchema
|
|
8517
|
+
] });
|
|
8853
8518
|
}
|
|
8854
|
-
|
|
8855
|
-
|
|
8519
|
+
createSchemaComparer();
|
|
8520
|
+
//#endregion
|
|
8521
|
+
//#region src/decision/common/decision.ts
|
|
8522
|
+
var decisionLimits = {
|
|
8523
|
+
choice: 255,
|
|
8524
|
+
score: 10
|
|
8525
|
+
};
|
|
8526
|
+
/** Ordered prefixes are shared by authoring, schemas, validation, and execution. */
|
|
8527
|
+
function limitDecisionQuestion(question) {
|
|
8528
|
+
if (question.type === "noul" || question.criteria.length <= decisionLimits[question.type]) return question;
|
|
8529
|
+
if (question.type === "choice") return {
|
|
8530
|
+
...question,
|
|
8531
|
+
criteria: question.criteria.slice(0, decisionLimits.choice)
|
|
8532
|
+
};
|
|
8533
|
+
return {
|
|
8534
|
+
...question,
|
|
8535
|
+
criteria: question.criteria.slice(0, decisionLimits.score)
|
|
8536
|
+
};
|
|
8537
|
+
}
|
|
8538
|
+
function limitDecisionQuestions(questions) {
|
|
8539
|
+
const limited = questions.map(limitDecisionQuestion);
|
|
8540
|
+
return limited.every((question, i) => question === questions[i]) ? questions : limited;
|
|
8541
|
+
}
|
|
8542
|
+
/** Loading an oversized task also updates its previously generated output schemas. */
|
|
8543
|
+
function limitDecisionTask(task) {
|
|
8544
|
+
if (task.executor.kind !== "decision") return task;
|
|
8545
|
+
const original = task.executor.questions;
|
|
8546
|
+
const questions = limitDecisionQuestions(original);
|
|
8547
|
+
if (questions === original) return task;
|
|
8548
|
+
const outputs = task.outputs.map((port) => {
|
|
8549
|
+
if (!("handle" in port)) return port;
|
|
8550
|
+
const index = original.findIndex((question) => question.name === port.handle);
|
|
8551
|
+
if (index < 0 || original[index] === questions[index] || !dequal(port.jsonSchema, answerSchema(original[index]))) return port;
|
|
8552
|
+
return {
|
|
8553
|
+
...port,
|
|
8554
|
+
jsonSchema: decisionAnswerSchema(questions[index])
|
|
8555
|
+
};
|
|
8556
|
+
});
|
|
8557
|
+
return {
|
|
8558
|
+
...task,
|
|
8559
|
+
executor: {
|
|
8560
|
+
...task.executor,
|
|
8561
|
+
questions
|
|
8562
|
+
},
|
|
8563
|
+
outputs
|
|
8564
|
+
};
|
|
8565
|
+
}
|
|
8566
|
+
var probability = {
|
|
8567
|
+
type: "number",
|
|
8568
|
+
minimum: 0,
|
|
8569
|
+
maximum: 1
|
|
8570
|
+
};
|
|
8571
|
+
function decisionAnswerSchema(question) {
|
|
8572
|
+
return answerSchema(limitDecisionQuestion(question));
|
|
8856
8573
|
}
|
|
8857
|
-
function
|
|
8858
|
-
const
|
|
8859
|
-
if (
|
|
8860
|
-
|
|
8861
|
-
|
|
8862
|
-
|
|
8863
|
-
|
|
8864
|
-
|
|
8865
|
-
|
|
8866
|
-
|
|
8867
|
-
|
|
8868
|
-
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
|
|
8873
|
-
|
|
8874
|
-
|
|
8875
|
-
|
|
8876
|
-
|
|
8877
|
-
|
|
8878
|
-
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
8882
|
-
|
|
8883
|
-
|
|
8884
|
-
|
|
8885
|
-
if ((sourceSchema.minProperties ?? 0) < (targetSchema.minProperties ?? 0)) return [...targetPath, "minProperties"];
|
|
8886
|
-
if ((sourceSchema.maxProperties ?? Number.POSITIVE_INFINITY) > (targetSchema.maxProperties ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxProperties"];
|
|
8887
|
-
break;
|
|
8574
|
+
function answerSchema(question) {
|
|
8575
|
+
const properties = { type: { const: question.type } };
|
|
8576
|
+
if (question.type === "noul") properties.noul = probability;
|
|
8577
|
+
else {
|
|
8578
|
+
const keys = question.type === "choice" ? question.criteria.map((item) => item.name) : question.criteria.map((_, index) => String(index));
|
|
8579
|
+
properties.confidence = probability;
|
|
8580
|
+
properties.probabilities = {
|
|
8581
|
+
type: "object",
|
|
8582
|
+
properties: Object.fromEntries(keys.map((key) => [key, probability])),
|
|
8583
|
+
required: keys,
|
|
8584
|
+
additionalProperties: false
|
|
8585
|
+
};
|
|
8586
|
+
if (question.type === "choice") properties.choice = {
|
|
8587
|
+
type: "string",
|
|
8588
|
+
...keys.length ? { enum: keys } : {}
|
|
8589
|
+
};
|
|
8590
|
+
else {
|
|
8591
|
+
properties.score = {
|
|
8592
|
+
type: "number",
|
|
8593
|
+
minimum: 0,
|
|
8594
|
+
maximum: Math.max(0, keys.length - 1)
|
|
8595
|
+
};
|
|
8596
|
+
properties.legend = {
|
|
8597
|
+
type: "object",
|
|
8598
|
+
properties: Object.fromEntries(keys.map((key) => [key, { type: "string" }])),
|
|
8599
|
+
required: keys,
|
|
8600
|
+
additionalProperties: false
|
|
8601
|
+
};
|
|
8888
8602
|
}
|
|
8889
|
-
case CompiledKind.EnumOrConst: return [...targetPath, targetSchema.const == null ? "enum" : "const"];
|
|
8890
8603
|
}
|
|
8891
|
-
return
|
|
8604
|
+
return {
|
|
8605
|
+
type: "object",
|
|
8606
|
+
properties,
|
|
8607
|
+
required: Object.keys(properties)
|
|
8608
|
+
};
|
|
8609
|
+
}
|
|
8610
|
+
function checkJsonDepth(value, depth = 0) {
|
|
8611
|
+
if (depth > 64) throw new TypeError("Value exceeds the maximum JSON depth.");
|
|
8612
|
+
if (value != null && typeof value == "object") for (const child of Object.values(value)) checkJsonDepth(child, depth + 1);
|
|
8892
8613
|
}
|
|
8893
8614
|
//#endregion
|
|
8894
|
-
//#region src/
|
|
8895
|
-
var
|
|
8896
|
-
|
|
8897
|
-
|
|
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
|
-
|
|
8615
|
+
//#region src/flow/common/triggerScheduleSchema.ts
|
|
8616
|
+
var triggerScheduleSchema = array(union([object({
|
|
8617
|
+
type: literal("cron"),
|
|
8618
|
+
expression: string$1(),
|
|
8619
|
+
timezone: string$1()
|
|
8620
|
+
}), object({
|
|
8621
|
+
type: literal("every"),
|
|
8622
|
+
unit: _enum([
|
|
8623
|
+
"day",
|
|
8624
|
+
"hour",
|
|
8625
|
+
"minute",
|
|
8626
|
+
"month",
|
|
8627
|
+
"week"
|
|
8628
|
+
]),
|
|
8629
|
+
value: number()
|
|
8630
|
+
})]));
|
|
8631
|
+
var text = string$1();
|
|
8632
|
+
var json$2 = json$3();
|
|
8633
|
+
var strings$1 = array(text);
|
|
8634
|
+
var port$1 = object({
|
|
8635
|
+
description: text.optional(),
|
|
8636
|
+
jsonSchema: json$2,
|
|
8637
|
+
nullable: boolean(),
|
|
8638
|
+
handle: text
|
|
8639
|
+
});
|
|
8640
|
+
var input = port$1.extend({ value: json$2.optional() });
|
|
8641
|
+
var group = object({
|
|
8642
|
+
collapsed: boolean().optional(),
|
|
8643
|
+
group: text
|
|
8644
|
+
});
|
|
8645
|
+
var source = union([object({
|
|
8646
|
+
kind: literal("node"),
|
|
8647
|
+
nodeId: text,
|
|
8648
|
+
output: text,
|
|
8649
|
+
field: text.optional()
|
|
8650
|
+
}), object({
|
|
8651
|
+
kind: literal("binding"),
|
|
8652
|
+
bindingId: text
|
|
8653
|
+
})]);
|
|
8654
|
+
var fixedInput = union([object({ kind: literal("unset") }), object({
|
|
8655
|
+
kind: literal("value"),
|
|
8656
|
+
value: json$2
|
|
8657
|
+
})]);
|
|
8658
|
+
var mapping = union([fixedInput, object({
|
|
8659
|
+
kind: literal("sources"),
|
|
8660
|
+
sources: array(source)
|
|
8661
|
+
})]);
|
|
8662
|
+
var inputs = record$2(text, mapping);
|
|
8663
|
+
var ports$1 = {
|
|
8664
|
+
inputs: array(union([input, group])),
|
|
8665
|
+
outputs: array(union([port$1, group]))
|
|
8666
|
+
};
|
|
8667
|
+
var capability = union([
|
|
8668
|
+
strictObject({
|
|
8669
|
+
kind: literal("connector"),
|
|
8670
|
+
action: text,
|
|
8671
|
+
connectionId: text.optional(),
|
|
8672
|
+
connections: array(strictObject({
|
|
8673
|
+
connectionId: text,
|
|
8674
|
+
alias: text.optional()
|
|
8675
|
+
}))
|
|
8676
|
+
}),
|
|
8677
|
+
strictObject({
|
|
8678
|
+
kind: literal("connector"),
|
|
8679
|
+
mode: literal("shared")
|
|
8680
|
+
}),
|
|
8681
|
+
strictObject({
|
|
8682
|
+
kind: literal("connector"),
|
|
8683
|
+
mode: literal("independent"),
|
|
8684
|
+
actions: array(strictObject({
|
|
8685
|
+
action: text,
|
|
8686
|
+
connectionId: text.optional()
|
|
8687
|
+
}))
|
|
8688
|
+
}),
|
|
8689
|
+
strictObject({
|
|
8690
|
+
kind: literal("connector"),
|
|
8691
|
+
actionHints: array(text).optional(),
|
|
8692
|
+
connectionHints: array(strictObject({
|
|
8693
|
+
action: text,
|
|
8694
|
+
connectionId: text,
|
|
8695
|
+
alias: text.optional()
|
|
8696
|
+
})).optional()
|
|
8697
|
+
})
|
|
8698
|
+
]);
|
|
8699
|
+
var inline = object({
|
|
8700
|
+
...ports$1,
|
|
8701
|
+
name: text,
|
|
8702
|
+
moduleId: text,
|
|
8703
|
+
capabilities: array(capability).optional()
|
|
8704
|
+
});
|
|
8705
|
+
var agentValue = union([object({
|
|
8706
|
+
kind: literal("value"),
|
|
8707
|
+
value: json$2
|
|
8708
|
+
}), object({
|
|
8709
|
+
kind: literal("input"),
|
|
8710
|
+
input: text
|
|
8711
|
+
})]);
|
|
8712
|
+
var agentInput = union([agentValue, object({ kind: literal("model") })]);
|
|
8713
|
+
var decisionQuestion = discriminatedUnion("type", [
|
|
8714
|
+
strictObject({
|
|
8715
|
+
name: text,
|
|
8716
|
+
instructions: text,
|
|
8717
|
+
type: literal("noul"),
|
|
8718
|
+
criteria: strictObject({
|
|
8719
|
+
true: text.optional(),
|
|
8720
|
+
false: text.optional()
|
|
8721
|
+
}).optional()
|
|
8722
|
+
}),
|
|
8723
|
+
strictObject({
|
|
8724
|
+
name: text,
|
|
8725
|
+
instructions: text,
|
|
8726
|
+
type: literal("choice"),
|
|
8727
|
+
criteria: array(strictObject({
|
|
8728
|
+
name: text,
|
|
8729
|
+
description: text
|
|
8730
|
+
}))
|
|
8731
|
+
}),
|
|
8732
|
+
strictObject({
|
|
8733
|
+
name: text,
|
|
8734
|
+
instructions: text,
|
|
8735
|
+
type: literal("score"),
|
|
8736
|
+
criteria: strings$1
|
|
8737
|
+
})
|
|
8738
|
+
]);
|
|
8739
|
+
var managedFields = object({
|
|
8740
|
+
...ports$1,
|
|
8741
|
+
name: text,
|
|
8742
|
+
executor: union([
|
|
8743
|
+
object({
|
|
8744
|
+
kind: literal("connector"),
|
|
8745
|
+
action: text,
|
|
8746
|
+
connectionId: text.optional(),
|
|
8747
|
+
outputMode: literal("value").optional()
|
|
8748
|
+
}),
|
|
8749
|
+
object({
|
|
8750
|
+
kind: literal("openapi"),
|
|
8751
|
+
sourceUrl: text,
|
|
8752
|
+
method: text,
|
|
8753
|
+
path: text,
|
|
8754
|
+
serverUrl: text,
|
|
8755
|
+
document: json$2,
|
|
8756
|
+
auth: array(object({
|
|
8757
|
+
id: text,
|
|
8758
|
+
type: _enum([
|
|
8759
|
+
"bearer",
|
|
8760
|
+
"basic",
|
|
8761
|
+
"apiKey"
|
|
8762
|
+
]),
|
|
8763
|
+
name: text.optional(),
|
|
8764
|
+
in: _enum(["header", "query"]).optional()
|
|
8765
|
+
}))
|
|
8766
|
+
}),
|
|
8767
|
+
strictObject({
|
|
8768
|
+
kind: literal("decision"),
|
|
8769
|
+
questions: array(decisionQuestion)
|
|
8770
|
+
}),
|
|
8771
|
+
object({
|
|
8772
|
+
kind: literal("llm"),
|
|
8773
|
+
mode: _enum(["chat", "json"])
|
|
8774
|
+
}),
|
|
8775
|
+
object({
|
|
8776
|
+
kind: literal("agent"),
|
|
8777
|
+
code: boolean().optional(),
|
|
8778
|
+
model: text,
|
|
8779
|
+
prompt: text,
|
|
8780
|
+
maxRounds: number(),
|
|
8781
|
+
tools: array(object({
|
|
8782
|
+
id: text,
|
|
8783
|
+
name: text,
|
|
8784
|
+
description: text,
|
|
8785
|
+
action: text,
|
|
8786
|
+
connectionId: text.optional(),
|
|
8787
|
+
approval: boolean(),
|
|
8788
|
+
inputs: array(input.extend({ source: agentInput }))
|
|
8789
|
+
})),
|
|
8790
|
+
notification: object({
|
|
8791
|
+
action: text,
|
|
8792
|
+
connectionId: text.optional(),
|
|
8793
|
+
inputDefinitions: array(input),
|
|
8794
|
+
messageHandle: text,
|
|
8795
|
+
inputs: record$2(text, agentValue)
|
|
8796
|
+
}).optional()
|
|
8797
|
+
})
|
|
8798
|
+
])
|
|
8799
|
+
});
|
|
8800
|
+
var managed = managedFields.transform(limitDecisionTask);
|
|
8801
|
+
var operand$1 = union([object({
|
|
8802
|
+
kind: literal("value"),
|
|
8803
|
+
value: json$2.optional(),
|
|
8804
|
+
jsonSchema: json$2.optional()
|
|
8805
|
+
}), object({
|
|
8806
|
+
kind: literal("source"),
|
|
8807
|
+
source
|
|
8808
|
+
})]);
|
|
8809
|
+
var condition = {
|
|
8810
|
+
matchMode: _enum(["first", "all"]),
|
|
8811
|
+
cases: array(object({
|
|
8812
|
+
description: text.optional(),
|
|
8813
|
+
output: text,
|
|
8814
|
+
groups: array(object({ expressions: array(object({
|
|
8815
|
+
left: operand$1,
|
|
8816
|
+
operator: _enum([
|
|
8817
|
+
"!=",
|
|
8818
|
+
"<",
|
|
8819
|
+
"<=",
|
|
8820
|
+
"==",
|
|
8821
|
+
">",
|
|
8822
|
+
">=",
|
|
8823
|
+
"contains",
|
|
8824
|
+
"endsWith",
|
|
8825
|
+
"hasKey",
|
|
8826
|
+
"hasValue",
|
|
8827
|
+
"isEmpty",
|
|
8828
|
+
"isFalse",
|
|
8829
|
+
"isNotEmpty",
|
|
8830
|
+
"isNotNull",
|
|
8831
|
+
"isNull",
|
|
8832
|
+
"isTrue",
|
|
8833
|
+
"notContains",
|
|
8834
|
+
"notHasKey",
|
|
8835
|
+
"notHasValue",
|
|
8836
|
+
"startsWith"
|
|
8837
|
+
]),
|
|
8838
|
+
right: operand$1.optional()
|
|
8839
|
+
})) }))
|
|
8840
|
+
}))
|
|
8937
8841
|
};
|
|
8938
|
-
|
|
8939
|
-
|
|
8940
|
-
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
8949
|
-
console.warn(`found ${warns.length} warns after compile schema`);
|
|
8950
|
-
for (const warn of warns) console.warn(stringifySchemaError(warn));
|
|
8951
|
-
}
|
|
8952
|
-
return compiledSchema;
|
|
8953
|
-
}
|
|
8954
|
-
function preprocessSchemasPair(schema1, schema2, compile, printWarnLog = false) {
|
|
8955
|
-
const schemaResult1 = compile(schema1);
|
|
8956
|
-
const schemaResult2 = compile(schema2);
|
|
8957
|
-
if (Array.isArray(schemaResult1) || Array.isArray(schemaResult2)) {
|
|
8958
|
-
const errorItems = [];
|
|
8959
|
-
if (Array.isArray(schemaResult1)) collectWithPathPrefix(errorItems, schemaResult1, "$1");
|
|
8960
|
-
if (Array.isArray(schemaResult2)) collectWithPathPrefix(errorItems, schemaResult2, "$2");
|
|
8961
|
-
throw new SchemaError(errorItems);
|
|
8962
|
-
}
|
|
8963
|
-
const { schema: compiledSchema1, warns: superWarns } = schemaResult1;
|
|
8964
|
-
const { schema: compiledSchema2, warns: subWarns } = schemaResult2;
|
|
8965
|
-
if (printWarnLog) {
|
|
8966
|
-
if (superWarns.length > 0) console.warn(`found ${superWarns.length} warns after compile superSchema`);
|
|
8967
|
-
for (const warn of superWarns) console.warn(stringifySchemaError(warn));
|
|
8968
|
-
if (subWarns.length > 0) console.warn(`found ${subWarns.length} warns after compile subSchema`);
|
|
8969
|
-
for (const warn of subWarns) console.warn(stringifySchemaError(warn));
|
|
8970
|
-
}
|
|
8971
|
-
return [compiledSchema1, compiledSchema2];
|
|
8972
|
-
}
|
|
8973
|
-
function collectWithPathPrefix(errorItems, compiledItems, prefix) {
|
|
8974
|
-
for (const compiledItem of compiledItems) {
|
|
8975
|
-
const replacedItem = {
|
|
8976
|
-
...compiledItem,
|
|
8977
|
-
path: [prefix, ...compiledItem.path]
|
|
8978
|
-
};
|
|
8979
|
-
errorItems.push(replacedItem);
|
|
8980
|
-
}
|
|
8981
|
-
}
|
|
8982
|
-
//#endregion
|
|
8983
|
-
//#region src/json-schema-subset/global.ts
|
|
8984
|
-
var SubsetCompareResult = Object.freeze({
|
|
8985
|
-
True: 0,
|
|
8986
|
-
False: 1,
|
|
8987
|
-
Unknown: 2
|
|
8842
|
+
var wait = {
|
|
8843
|
+
inputDefinitions: array(input),
|
|
8844
|
+
prompt: text
|
|
8845
|
+
};
|
|
8846
|
+
var webhookOptions = object({
|
|
8847
|
+
allowedMethods: never().optional(),
|
|
8848
|
+
allowedOrigins: strings$1.optional(),
|
|
8849
|
+
noResponseBody: never().optional(),
|
|
8850
|
+
responseData: text.optional(),
|
|
8851
|
+
responseHeaders: record$2(text, text).optional(),
|
|
8852
|
+
responseStatusCode: number().int().min(200).max(599).optional()
|
|
8988
8853
|
});
|
|
8989
|
-
|
|
8990
|
-
|
|
8991
|
-
|
|
8992
|
-
|
|
8993
|
-
const compiler = (candidate) => compile(candidate, extendsContext, payload, delegate);
|
|
8994
|
-
return preprocessSchema(schema, compiler, printWarnLog);
|
|
8995
|
-
},
|
|
8996
|
-
isSubset: (superSchema, subSchema, printWarnLog = false) => {
|
|
8997
|
-
const compiler = (candidate) => compile(candidate, extendsContext, void 0, delegate);
|
|
8998
|
-
const [schema1, schema2] = preprocessSchemasPair(superSchema, subSchema, compiler, printWarnLog);
|
|
8999
|
-
const { errorPath, expression } = checkWithResult(extendsContext, schema1, schema2);
|
|
9000
|
-
const foundTrueExpression = hasEquals(expression) || hasContainedBy(expression);
|
|
9001
|
-
const foundFalseExpression = hasContaining(expression) || hasIntersection(expression) || hasRejection(expression);
|
|
9002
|
-
if (foundTrueExpression && !foundFalseExpression) return { result: SubsetCompareResult.True };
|
|
9003
|
-
if (!foundTrueExpression && foundFalseExpression) return {
|
|
9004
|
-
errorPath,
|
|
9005
|
-
result: SubsetCompareResult.False
|
|
9006
|
-
};
|
|
9007
|
-
return { result: SubsetCompareResult.Unknown };
|
|
9008
|
-
}
|
|
9009
|
-
});
|
|
9010
|
-
}
|
|
9011
|
-
//#endregion
|
|
9012
|
-
//#region ../../node_modules/.bun/@wopjs+cast@0.1.16/node_modules/@wopjs/cast/dist/index.mjs
|
|
9013
|
-
var isString = (x) => typeof x === "string";
|
|
9014
|
-
var isArray = Array.isArray;
|
|
9015
|
-
var isObject = (x) => x !== null && typeof x === "object";
|
|
9016
|
-
var isPlainObject = (x) => isObject(x) && !isArray(x);
|
|
9017
|
-
var toPlainObject = (x) => isPlainObject(x) ? x : void 0;
|
|
9018
|
-
//#endregion
|
|
9019
|
-
//#region src/flow/common/schemaComparer.ts
|
|
9020
|
-
function isStringLikeSchema(value) {
|
|
9021
|
-
return toPlainObject(value)?.type === "string";
|
|
9022
|
-
}
|
|
9023
|
-
function assertSchemaCompareContext(value) {
|
|
9024
|
-
const context = toPlainObject(value);
|
|
9025
|
-
const error = toPlainObject(context?.error);
|
|
9026
|
-
if (context == null || error == null || context.packageId != null && !isString(context.packageId) || error.message != null && !isString(error.message)) throw new TypeError("Invalid schema comparison context.");
|
|
9027
|
-
}
|
|
9028
|
-
function parseSchemaCompareContext(value) {
|
|
9029
|
-
if (value == null) return { error: {} };
|
|
9030
|
-
assertSchemaCompareContext(value);
|
|
9031
|
-
return value;
|
|
9032
|
-
}
|
|
9033
|
-
var SpecialSchema = class SpecialSchema {
|
|
9034
|
-
static setError(fromSchema, toSchema, message) {
|
|
9035
|
-
if (fromSchema instanceof SpecialSchema) fromSchema.context.error.message = message;
|
|
9036
|
-
else if (toSchema instanceof SpecialSchema) toSchema.context.error.message = message;
|
|
9037
|
-
}
|
|
9038
|
-
constructor(id, value, context) {
|
|
9039
|
-
this.id = id;
|
|
9040
|
-
this.value = value;
|
|
9041
|
-
this.context = parseSchemaCompareContext(context);
|
|
9042
|
-
}
|
|
9043
|
-
compare(other) {
|
|
9044
|
-
if (isCompiledSchema(other) && getKind(other) === CompiledKind.Any) return [ExpressionSingleResult.ContainedBy];
|
|
9045
|
-
return this.compareImpl(other);
|
|
9046
|
-
}
|
|
8854
|
+
var webhook = {
|
|
8855
|
+
bodyFields: array(input),
|
|
8856
|
+
method: _enum(webhookMethods),
|
|
8857
|
+
options: webhookOptions.optional()
|
|
9047
8858
|
};
|
|
9048
|
-
var
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9056
|
-
|
|
9057
|
-
compareImpl(other) {
|
|
9058
|
-
if (isStringLikeSchema(other)) return [ExpressionSingleResult.ContainedBy];
|
|
9059
|
-
if (other instanceof SingleSelectSchema) {
|
|
9060
|
-
const f = new Set(this.value.enum);
|
|
9061
|
-
let result = ExpressionSingleResult.Equals;
|
|
9062
|
-
for (const v of other.value.enum) {
|
|
9063
|
-
if (!f.has(v)) result = ExpressionSingleResult.ContainedBy;
|
|
9064
|
-
f.delete(v);
|
|
9065
|
-
}
|
|
9066
|
-
if (f.size === 0) return [result];
|
|
9067
|
-
if (f.size === this.value.enum.length) return [ExpressionSingleResult.Rejection];
|
|
9068
|
-
return [ExpressionSingleResult.Intersection];
|
|
9069
|
-
}
|
|
9070
|
-
return [ExpressionSingleResult.Rejection];
|
|
9071
|
-
}
|
|
9072
|
-
equals(other) {
|
|
9073
|
-
if (other instanceof SingleSelectSchema) {
|
|
9074
|
-
const f = new Set(this.value.enum);
|
|
9075
|
-
for (const v of other.value.enum) {
|
|
9076
|
-
if (!f.has(v)) return false;
|
|
9077
|
-
f.delete(v);
|
|
9078
|
-
}
|
|
9079
|
-
return f.size === 0;
|
|
9080
|
-
}
|
|
9081
|
-
return false;
|
|
9082
|
-
}
|
|
8859
|
+
var definition = {
|
|
8860
|
+
configInputs: ports$1.inputs,
|
|
8861
|
+
definitionVersion: literal(2),
|
|
8862
|
+
description: text,
|
|
8863
|
+
displayName: text,
|
|
8864
|
+
key: text,
|
|
8865
|
+
name: text,
|
|
8866
|
+
outputs: array(port$1).refine((definitions) => new Set(definitions.map((output) => output.handle)).size === definitions.length, "Duplicate Trigger output handle."),
|
|
8867
|
+
provider: text
|
|
9083
8868
|
};
|
|
9084
|
-
var
|
|
9085
|
-
|
|
9086
|
-
|
|
9087
|
-
|
|
9088
|
-
|
|
9089
|
-
|
|
9090
|
-
|
|
9091
|
-
|
|
9092
|
-
|
|
9093
|
-
|
|
9094
|
-
|
|
9095
|
-
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
|
|
9100
|
-
|
|
9101
|
-
|
|
8869
|
+
var endpoint = object({
|
|
8870
|
+
body: object({
|
|
8871
|
+
allowArray: boolean(),
|
|
8872
|
+
allowEmpty: boolean(),
|
|
8873
|
+
formats: array(_enum([
|
|
8874
|
+
"form",
|
|
8875
|
+
"json",
|
|
8876
|
+
"multipart",
|
|
8877
|
+
"text"
|
|
8878
|
+
]))
|
|
8879
|
+
}),
|
|
8880
|
+
methods: array(_enum([
|
|
8881
|
+
"DELETE",
|
|
8882
|
+
"GET",
|
|
8883
|
+
"HEAD",
|
|
8884
|
+
"PATCH",
|
|
8885
|
+
"POST",
|
|
8886
|
+
"PUT"
|
|
8887
|
+
])),
|
|
8888
|
+
successStatus: number()
|
|
8889
|
+
});
|
|
8890
|
+
var sourceFlowIds = array(text.min(1)).refine((ids) => new Set(ids).size === ids.length, "Duplicate source Flow ID.");
|
|
8891
|
+
var trigger = {
|
|
8892
|
+
name: text,
|
|
8893
|
+
description: text.optional(),
|
|
8894
|
+
icon: text.optional()
|
|
9102
8895
|
};
|
|
9103
|
-
var
|
|
9104
|
-
|
|
9105
|
-
|
|
9106
|
-
|
|
9107
|
-
|
|
9108
|
-
|
|
9109
|
-
|
|
9110
|
-
}
|
|
9111
|
-
compareImpl(other) {
|
|
9112
|
-
if (other instanceof ArtifactSchema) return [ExpressionSingleResult.Equals];
|
|
9113
|
-
SpecialSchema.setError(this, other, "edgeError.artifactDiffType");
|
|
9114
|
-
return [ExpressionSingleResult.Rejection];
|
|
9115
|
-
}
|
|
9116
|
-
equals(other) {
|
|
9117
|
-
return other instanceof ArtifactSchema;
|
|
9118
|
-
}
|
|
8896
|
+
var base = {
|
|
8897
|
+
maxExecutions: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
8898
|
+
inputs,
|
|
8899
|
+
name: text.optional(),
|
|
8900
|
+
description: text.optional(),
|
|
8901
|
+
icon: text.optional(),
|
|
8902
|
+
timeoutMs: number().optional()
|
|
9119
8903
|
};
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
|
|
9126
|
-
}
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
|
|
9130
|
-
|
|
9131
|
-
|
|
9132
|
-
|
|
8904
|
+
var node = union([
|
|
8905
|
+
object({
|
|
8906
|
+
...base,
|
|
8907
|
+
inputs: record$2(text, never()),
|
|
8908
|
+
kind: literal("condition"),
|
|
8909
|
+
...condition
|
|
8910
|
+
}),
|
|
8911
|
+
object({
|
|
8912
|
+
...base,
|
|
8913
|
+
inputs: unknown().transform(() => ({})).default({}),
|
|
8914
|
+
kind: literal("value"),
|
|
8915
|
+
values: array(input)
|
|
8916
|
+
}),
|
|
8917
|
+
object({
|
|
8918
|
+
...base,
|
|
8919
|
+
kind: literal("task"),
|
|
8920
|
+
task: union([inline, managed]),
|
|
8921
|
+
additionalInputs: array(input).optional()
|
|
8922
|
+
}),
|
|
8923
|
+
strictObject({
|
|
8924
|
+
...base,
|
|
8925
|
+
kind: literal("approval"),
|
|
8926
|
+
...wait
|
|
8927
|
+
}).omit({ timeoutMs: true }),
|
|
8928
|
+
strictObject({
|
|
8929
|
+
...base,
|
|
8930
|
+
kind: literal("wait"),
|
|
8931
|
+
...wait
|
|
8932
|
+
}).omit({ timeoutMs: true }),
|
|
8933
|
+
object({
|
|
8934
|
+
...trigger,
|
|
8935
|
+
kind: literal("manual")
|
|
8936
|
+
}),
|
|
8937
|
+
strictObject({
|
|
8938
|
+
...trigger,
|
|
8939
|
+
kind: literal("error"),
|
|
8940
|
+
sourceFlowIds: sourceFlowIds.optional()
|
|
8941
|
+
}),
|
|
8942
|
+
object({
|
|
8943
|
+
...trigger,
|
|
8944
|
+
kind: literal("webhook"),
|
|
8945
|
+
...webhook
|
|
8946
|
+
}),
|
|
8947
|
+
object({
|
|
8948
|
+
...trigger,
|
|
8949
|
+
kind: literal("cron"),
|
|
8950
|
+
cronTimes: triggerScheduleSchema
|
|
8951
|
+
}),
|
|
8952
|
+
object({
|
|
8953
|
+
...trigger,
|
|
8954
|
+
kind: literal("poll"),
|
|
8955
|
+
connectionId: text.min(1).optional(),
|
|
8956
|
+
config: record$2(text, fixedInput),
|
|
8957
|
+
definition: object({
|
|
8958
|
+
...definition,
|
|
8959
|
+
type: literal("poll")
|
|
8960
|
+
}),
|
|
8961
|
+
pollTimes: triggerScheduleSchema
|
|
8962
|
+
}),
|
|
8963
|
+
object({
|
|
8964
|
+
...trigger,
|
|
8965
|
+
kind: literal("integration"),
|
|
8966
|
+
connectionId: text.min(1).optional(),
|
|
8967
|
+
config: record$2(text, fixedInput),
|
|
8968
|
+
definition: object({
|
|
8969
|
+
...definition,
|
|
8970
|
+
type: literal("integration"),
|
|
8971
|
+
endpoint
|
|
8972
|
+
})
|
|
8973
|
+
})
|
|
8974
|
+
]);
|
|
8975
|
+
/** Configuration schemas shared by the node authoring boundary. */
|
|
8976
|
+
var authoringDefinitionSchemas = {
|
|
8977
|
+
input,
|
|
8978
|
+
port: port$1,
|
|
8979
|
+
ports: ports$1,
|
|
8980
|
+
condition: strictObject(condition),
|
|
8981
|
+
wait: strictObject(wait),
|
|
8982
|
+
webhook: strictObject(webhook),
|
|
8983
|
+
schedule: triggerScheduleSchema,
|
|
8984
|
+
capabilities: array(capability),
|
|
8985
|
+
connector: managedFields.shape.executor.options[0].omit({ kind: true }).strict(),
|
|
8986
|
+
openapi: managedFields.shape.executor.options[1].omit({ kind: true }).strict(),
|
|
8987
|
+
decision: managedFields.shape.executor.options[2].omit({ kind: true }).strict(),
|
|
8988
|
+
llm: managedFields.shape.executor.options[3].omit({ kind: true }).strict(),
|
|
8989
|
+
agent: managedFields.shape.executor.options[4].omit({
|
|
8990
|
+
kind: true,
|
|
8991
|
+
notification: true
|
|
8992
|
+
}).strict()
|
|
9133
8993
|
};
|
|
9134
|
-
|
|
9135
|
-
|
|
9136
|
-
|
|
9137
|
-
|
|
9138
|
-
|
|
9139
|
-
|
|
9140
|
-
|
|
9141
|
-
|
|
9142
|
-
...question,
|
|
9143
|
-
criteria: question.criteria.slice(0, decisionLimits.score)
|
|
9144
|
-
};
|
|
9145
|
-
}
|
|
9146
|
-
function limitDecisionQuestions(questions) {
|
|
9147
|
-
const limited = questions.map(limitDecisionQuestion);
|
|
9148
|
-
return limited.every((question, i) => question === questions[i]) ? questions : limited;
|
|
9149
|
-
}
|
|
9150
|
-
/** Loading an oversized task also updates its previously generated output schemas. */
|
|
9151
|
-
function limitDecisionTask(task) {
|
|
9152
|
-
if (task.executor.kind !== "decision") return task;
|
|
9153
|
-
const original = task.executor.questions;
|
|
9154
|
-
const questions = limitDecisionQuestions(original);
|
|
9155
|
-
if (questions === original) return task;
|
|
9156
|
-
const outputs = task.outputs.map((port) => {
|
|
9157
|
-
if (!("handle" in port)) return port;
|
|
9158
|
-
const index = original.findIndex((question) => question.name === port.handle);
|
|
9159
|
-
if (index < 0 || original[index] === questions[index] || !dequal(port.jsonSchema, answerSchema(original[index]))) return port;
|
|
9160
|
-
return {
|
|
9161
|
-
...port,
|
|
9162
|
-
jsonSchema: decisionAnswerSchema(questions[index])
|
|
9163
|
-
};
|
|
9164
|
-
});
|
|
9165
|
-
return {
|
|
9166
|
-
...task,
|
|
9167
|
-
executor: {
|
|
9168
|
-
...task.executor,
|
|
9169
|
-
questions
|
|
9170
|
-
},
|
|
9171
|
-
outputs
|
|
9172
|
-
};
|
|
9173
|
-
}
|
|
9174
|
-
var probability = {
|
|
9175
|
-
type: "number",
|
|
9176
|
-
minimum: 0,
|
|
9177
|
-
maximum: 1
|
|
8994
|
+
var edge = object({
|
|
8995
|
+
source: text,
|
|
8996
|
+
target: text,
|
|
8997
|
+
sourceHandle: text.optional()
|
|
8998
|
+
});
|
|
8999
|
+
var at = {
|
|
9000
|
+
nodeId: text,
|
|
9001
|
+
target: never().optional()
|
|
9178
9002
|
};
|
|
9179
|
-
|
|
9180
|
-
|
|
9003
|
+
var graph = object({
|
|
9004
|
+
nodes: record$2(text, node),
|
|
9005
|
+
edges: array(edge).default([])
|
|
9006
|
+
});
|
|
9007
|
+
var binding$1 = object({
|
|
9008
|
+
kind: literal("variable"),
|
|
9009
|
+
target: text
|
|
9010
|
+
});
|
|
9011
|
+
var module = object({
|
|
9012
|
+
name: text,
|
|
9013
|
+
imports: strings$1,
|
|
9014
|
+
source: text
|
|
9015
|
+
});
|
|
9016
|
+
var document = preprocess(rejectRetiredDefinitions, object({
|
|
9017
|
+
bindings: record$2(text, binding$1),
|
|
9018
|
+
graph
|
|
9019
|
+
}));
|
|
9020
|
+
var revision = object({
|
|
9021
|
+
modelVersion: union([
|
|
9022
|
+
literal(2),
|
|
9023
|
+
literal(4),
|
|
9024
|
+
literal(5),
|
|
9025
|
+
literal(6)
|
|
9026
|
+
]),
|
|
9027
|
+
document,
|
|
9028
|
+
modules: record$2(text, module)
|
|
9029
|
+
});
|
|
9030
|
+
revision.extend({
|
|
9031
|
+
kind: literal("open-flow-flow-revision"),
|
|
9032
|
+
version: literal(1)
|
|
9033
|
+
});
|
|
9034
|
+
function rejectRetiredDefinitions(value) {
|
|
9035
|
+
const candidate = record$1(value);
|
|
9036
|
+
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.");
|
|
9037
|
+
if (Object.values(record$1(record$1(candidate.graph).nodes)).some((candidateNode) => Object.hasOwn(record$1(candidateNode), "taskId"))) throw new TypeError("Task references are no longer supported.");
|
|
9038
|
+
const subflows = candidate.subflows;
|
|
9039
|
+
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.");
|
|
9040
|
+
if (Object.values(record$1(record$1(candidate.graph).nodes)).some((candidateNode) => record$1(candidateNode).kind === "subflow")) throw new TypeError("Subflow nodes are no longer supported.");
|
|
9041
|
+
return value;
|
|
9181
9042
|
}
|
|
9182
|
-
function
|
|
9183
|
-
|
|
9184
|
-
if (question.type === "noul") properties.noul = probability;
|
|
9185
|
-
else {
|
|
9186
|
-
const keys = question.type === "choice" ? question.criteria.map((item) => item.name) : question.criteria.map((_, index) => String(index));
|
|
9187
|
-
properties.confidence = probability;
|
|
9188
|
-
properties.probabilities = {
|
|
9189
|
-
type: "object",
|
|
9190
|
-
properties: Object.fromEntries(keys.map((key) => [key, probability])),
|
|
9191
|
-
required: keys,
|
|
9192
|
-
additionalProperties: false
|
|
9193
|
-
};
|
|
9194
|
-
if (question.type === "choice") properties.choice = {
|
|
9195
|
-
type: "string",
|
|
9196
|
-
...keys.length ? { enum: keys } : {}
|
|
9197
|
-
};
|
|
9198
|
-
else {
|
|
9199
|
-
properties.score = {
|
|
9200
|
-
type: "number",
|
|
9201
|
-
minimum: 0,
|
|
9202
|
-
maximum: Math.max(0, keys.length - 1)
|
|
9203
|
-
};
|
|
9204
|
-
properties.legend = {
|
|
9205
|
-
type: "object",
|
|
9206
|
-
properties: Object.fromEntries(keys.map((key) => [key, { type: "string" }])),
|
|
9207
|
-
required: keys,
|
|
9208
|
-
additionalProperties: false
|
|
9209
|
-
};
|
|
9210
|
-
}
|
|
9211
|
-
}
|
|
9212
|
-
return {
|
|
9213
|
-
type: "object",
|
|
9214
|
-
properties,
|
|
9215
|
-
required: Object.keys(properties)
|
|
9216
|
-
};
|
|
9043
|
+
function record$1(value) {
|
|
9044
|
+
return value != null && typeof value == "object" && !Array.isArray(value) ? value : {};
|
|
9217
9045
|
}
|
|
9218
|
-
|
|
9219
|
-
|
|
9220
|
-
|
|
9221
|
-
|
|
9222
|
-
|
|
9223
|
-
|
|
9224
|
-
|
|
9225
|
-
|
|
9226
|
-
|
|
9227
|
-
|
|
9228
|
-
|
|
9229
|
-
|
|
9230
|
-
"revisionId",
|
|
9231
|
-
"publicationId"
|
|
9232
|
-
],
|
|
9233
|
-
properties: {
|
|
9234
|
-
flowId: { type: "string" },
|
|
9235
|
-
name: { type: "string" },
|
|
9236
|
-
revisionId: { type: "string" },
|
|
9237
|
-
publicationId: { type: ["string", "null"] }
|
|
9238
|
-
}
|
|
9239
|
-
}
|
|
9046
|
+
function decodeRevisionContent(value) {
|
|
9047
|
+
checkJsonDepth(value);
|
|
9048
|
+
const content = revision.parse(value);
|
|
9049
|
+
checkModelVersion(content);
|
|
9050
|
+
assertOpenApiAuthBindings(content.document);
|
|
9051
|
+
return content;
|
|
9052
|
+
}
|
|
9053
|
+
var shapes = {
|
|
9054
|
+
"graph.trigger.sources.set": {
|
|
9055
|
+
nodeId: text,
|
|
9056
|
+
before: sourceFlowIds.optional(),
|
|
9057
|
+
value: sourceFlowIds.optional()
|
|
9240
9058
|
},
|
|
9241
|
-
{
|
|
9242
|
-
|
|
9243
|
-
|
|
9244
|
-
jsonSchema: {
|
|
9245
|
-
type: "object",
|
|
9246
|
-
additionalProperties: false,
|
|
9247
|
-
required: [
|
|
9248
|
-
"runId",
|
|
9249
|
-
"status",
|
|
9250
|
-
"startedAt",
|
|
9251
|
-
"finishedAt"
|
|
9252
|
-
],
|
|
9253
|
-
properties: {
|
|
9254
|
-
runId: { type: "string" },
|
|
9255
|
-
status: { enum: ["failed", "indeterminate"] },
|
|
9256
|
-
startedAt: { type: ["string", "null"] },
|
|
9257
|
-
finishedAt: { type: "string" }
|
|
9258
|
-
}
|
|
9259
|
-
}
|
|
9059
|
+
"binding.create": {
|
|
9060
|
+
bindingId: text,
|
|
9061
|
+
binding: binding$1
|
|
9260
9062
|
},
|
|
9261
|
-
{
|
|
9262
|
-
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
|
|
9266
|
-
additionalProperties: false,
|
|
9267
|
-
required: ["code", "message"],
|
|
9268
|
-
properties: {
|
|
9269
|
-
code: { type: "string" },
|
|
9270
|
-
message: { type: "string" },
|
|
9271
|
-
nodeId: { type: "string" },
|
|
9272
|
-
jobId: { type: "string" },
|
|
9273
|
-
path: {
|
|
9274
|
-
type: "array",
|
|
9275
|
-
items: { type: "string" }
|
|
9276
|
-
}
|
|
9277
|
-
}
|
|
9278
|
-
}
|
|
9279
|
-
}
|
|
9280
|
-
];
|
|
9281
|
-
var webhookOutputs = [
|
|
9282
|
-
{
|
|
9283
|
-
handle: "headers",
|
|
9284
|
-
jsonSchema: {
|
|
9285
|
-
type: "object",
|
|
9286
|
-
additionalProperties: { type: "string" }
|
|
9287
|
-
},
|
|
9288
|
-
nullable: false
|
|
9063
|
+
"binding.delete": { bindingId: text },
|
|
9064
|
+
"binding.target.set": {
|
|
9065
|
+
bindingId: text,
|
|
9066
|
+
before: text,
|
|
9067
|
+
value: text
|
|
9289
9068
|
},
|
|
9290
|
-
{
|
|
9291
|
-
|
|
9292
|
-
|
|
9293
|
-
type: "object",
|
|
9294
|
-
additionalProperties: {
|
|
9295
|
-
type: ["string", "array"],
|
|
9296
|
-
items: { type: "string" }
|
|
9297
|
-
}
|
|
9298
|
-
},
|
|
9299
|
-
nullable: false
|
|
9069
|
+
"graph.edge.connect": {
|
|
9070
|
+
edge,
|
|
9071
|
+
target: never().optional()
|
|
9300
9072
|
},
|
|
9301
|
-
{
|
|
9302
|
-
|
|
9303
|
-
|
|
9304
|
-
type: "object",
|
|
9305
|
-
additionalProperties: true
|
|
9306
|
-
},
|
|
9307
|
-
nullable: false
|
|
9073
|
+
"graph.edge.disconnect": {
|
|
9074
|
+
edge,
|
|
9075
|
+
target: never().optional()
|
|
9308
9076
|
},
|
|
9309
|
-
{
|
|
9310
|
-
|
|
9311
|
-
|
|
9312
|
-
nullable: false
|
|
9313
|
-
}
|
|
9314
|
-
];
|
|
9315
|
-
var cronOutputs = [{
|
|
9316
|
-
handle: "scheduledAt",
|
|
9317
|
-
jsonSchema: {
|
|
9318
|
-
type: "string",
|
|
9319
|
-
format: "date-time"
|
|
9077
|
+
"graph.node.create": {
|
|
9078
|
+
...at,
|
|
9079
|
+
node
|
|
9320
9080
|
},
|
|
9321
|
-
|
|
9322
|
-
|
|
9323
|
-
|
|
9324
|
-
|
|
9325
|
-
|
|
9326
|
-
|
|
9327
|
-
|
|
9328
|
-
|
|
9329
|
-
|
|
9330
|
-
|
|
9331
|
-
|
|
9332
|
-
|
|
9333
|
-
|
|
9334
|
-
required: trigger.bodyFields.filter((field) => !field.nullable && !Object.hasOwn(field, "value")).map((field) => field.handle)
|
|
9335
|
-
} }) : port);
|
|
9336
|
-
}
|
|
9337
|
-
}
|
|
9338
|
-
function triggerOutputPorts(trigger) {
|
|
9339
|
-
return Object.fromEntries(triggerOutputDefinitions(trigger).map(({ handle, ...port }) => [handle, port]));
|
|
9340
|
-
}
|
|
9341
|
-
//#endregion
|
|
9342
|
-
//#region src/flow/common/graph.ts
|
|
9343
|
-
function nodeInputPorts(node) {
|
|
9344
|
-
switch (node.kind) {
|
|
9345
|
-
case "condition": return conditionInputPorts(node);
|
|
9346
|
-
case "value": return {};
|
|
9347
|
-
case "task": return portsByHandle([...node.task.inputs, ...node.additionalInputs ?? []]);
|
|
9348
|
-
case "approval":
|
|
9349
|
-
case "wait": return portsByHandle(node.inputDefinitions);
|
|
9350
|
-
case "cron":
|
|
9351
|
-
case "integration":
|
|
9352
|
-
case "poll":
|
|
9353
|
-
case "error":
|
|
9354
|
-
case "manual":
|
|
9355
|
-
case "webhook": return {};
|
|
9356
|
-
}
|
|
9357
|
-
}
|
|
9358
|
-
function resolutionActions(node) {
|
|
9359
|
-
return node.kind == "wait" ? ["continue"] : ["approve", "reject"];
|
|
9360
|
-
}
|
|
9361
|
-
var objectPort = (properties) => ({
|
|
9362
|
-
nullable: false,
|
|
9363
|
-
jsonSchema: {
|
|
9364
|
-
type: "object",
|
|
9365
|
-
properties,
|
|
9366
|
-
required: Object.keys(properties),
|
|
9367
|
-
additionalProperties: false
|
|
9368
|
-
}
|
|
9369
|
-
});
|
|
9370
|
-
function resolutionOutputPorts(node) {
|
|
9371
|
-
const actions = resolutionActions(node);
|
|
9372
|
-
const inputs = {
|
|
9373
|
-
type: "object",
|
|
9374
|
-
properties: Object.fromEntries(node.inputDefinitions.map((port) => [port.handle, {}])),
|
|
9375
|
-
required: node.inputDefinitions.map((port) => port.handle),
|
|
9376
|
-
additionalProperties: false
|
|
9377
|
-
};
|
|
9378
|
-
return {
|
|
9379
|
-
pending: objectPort({
|
|
9380
|
-
inputs,
|
|
9381
|
-
prompt: { type: "string" },
|
|
9382
|
-
...Object.fromEntries(actions.map((action) => [`${action}Url`, { type: "string" }])),
|
|
9383
|
-
expiresAt: { type: "string" }
|
|
9081
|
+
"graph.node.replace": {
|
|
9082
|
+
...at,
|
|
9083
|
+
before: node,
|
|
9084
|
+
node
|
|
9085
|
+
},
|
|
9086
|
+
"graph.node.delete": at,
|
|
9087
|
+
"graph.node.field.set": union([
|
|
9088
|
+
object({
|
|
9089
|
+
...at,
|
|
9090
|
+
kind: literal("graph.node.field.set"),
|
|
9091
|
+
field: literal("connectionId"),
|
|
9092
|
+
before: text.min(1).optional(),
|
|
9093
|
+
value: text.min(1).optional()
|
|
9384
9094
|
}),
|
|
9385
|
-
|
|
9386
|
-
|
|
9387
|
-
|
|
9388
|
-
|
|
9389
|
-
|
|
9390
|
-
|
|
9391
|
-
|
|
9392
|
-
|
|
9393
|
-
|
|
9394
|
-
|
|
9395
|
-
|
|
9396
|
-
|
|
9397
|
-
|
|
9398
|
-
|
|
9399
|
-
|
|
9400
|
-
|
|
9401
|
-
|
|
9402
|
-
|
|
9403
|
-
|
|
9404
|
-
|
|
9405
|
-
|
|
9095
|
+
object({
|
|
9096
|
+
...at,
|
|
9097
|
+
kind: literal("graph.node.field.set"),
|
|
9098
|
+
field: _enum([
|
|
9099
|
+
"description",
|
|
9100
|
+
"icon",
|
|
9101
|
+
"name"
|
|
9102
|
+
]),
|
|
9103
|
+
before: text.optional(),
|
|
9104
|
+
value: text.optional()
|
|
9105
|
+
}),
|
|
9106
|
+
object({
|
|
9107
|
+
...at,
|
|
9108
|
+
kind: literal("graph.node.field.set"),
|
|
9109
|
+
field: literal("maxExecutions"),
|
|
9110
|
+
before: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
|
|
9111
|
+
value: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional()
|
|
9112
|
+
}),
|
|
9113
|
+
object({
|
|
9114
|
+
...at,
|
|
9115
|
+
kind: literal("graph.node.field.set"),
|
|
9116
|
+
field: literal("timeoutMs"),
|
|
9117
|
+
before: number().optional(),
|
|
9118
|
+
value: number().optional()
|
|
9119
|
+
})
|
|
9120
|
+
]),
|
|
9121
|
+
"graph.node.input.set": {
|
|
9122
|
+
...at,
|
|
9123
|
+
handle: text,
|
|
9124
|
+
before: mapping.optional(),
|
|
9125
|
+
value: mapping.optional()
|
|
9126
|
+
},
|
|
9127
|
+
"graph.node.additional-inputs.set": {
|
|
9128
|
+
...at,
|
|
9129
|
+
before: array(input).optional(),
|
|
9130
|
+
value: array(input).optional()
|
|
9131
|
+
},
|
|
9132
|
+
"graph.node.condition.set": {
|
|
9133
|
+
...at,
|
|
9134
|
+
before: object(condition),
|
|
9135
|
+
value: object(condition)
|
|
9136
|
+
},
|
|
9137
|
+
"graph.node.values.set": {
|
|
9138
|
+
...at,
|
|
9139
|
+
before: array(input),
|
|
9140
|
+
value: array(input)
|
|
9141
|
+
},
|
|
9142
|
+
"graph.node.resolution.set": {
|
|
9143
|
+
...at,
|
|
9144
|
+
before: object(wait),
|
|
9145
|
+
value: object(wait)
|
|
9146
|
+
},
|
|
9147
|
+
"graph.node.webhook.set": {
|
|
9148
|
+
...at,
|
|
9149
|
+
before: object(webhook),
|
|
9150
|
+
value: object(webhook)
|
|
9151
|
+
},
|
|
9152
|
+
"graph.node.task.ports.set": {
|
|
9153
|
+
...at,
|
|
9154
|
+
before: object(ports$1),
|
|
9155
|
+
value: object(ports$1)
|
|
9156
|
+
},
|
|
9157
|
+
"graph.node.task.name.set": {
|
|
9158
|
+
...at,
|
|
9159
|
+
before: text,
|
|
9160
|
+
value: text
|
|
9161
|
+
},
|
|
9162
|
+
"graph.node.task.capabilities.set": {
|
|
9163
|
+
...at,
|
|
9164
|
+
before: array(capability).optional(),
|
|
9165
|
+
value: array(capability).optional()
|
|
9166
|
+
},
|
|
9167
|
+
"graph.trigger.config.set": {
|
|
9168
|
+
nodeId: text,
|
|
9169
|
+
name: text,
|
|
9170
|
+
before: fixedInput.optional(),
|
|
9171
|
+
value: fixedInput.optional()
|
|
9172
|
+
},
|
|
9173
|
+
"graph.trigger.schedule.set": {
|
|
9174
|
+
nodeId: text,
|
|
9175
|
+
before: triggerScheduleSchema,
|
|
9176
|
+
value: triggerScheduleSchema
|
|
9177
|
+
},
|
|
9178
|
+
"module.create": {
|
|
9179
|
+
moduleId: text,
|
|
9180
|
+
module
|
|
9181
|
+
},
|
|
9182
|
+
"module.delete": { moduleId: text },
|
|
9183
|
+
"module.rename": {
|
|
9184
|
+
moduleId: text,
|
|
9185
|
+
before: text,
|
|
9186
|
+
name: text
|
|
9187
|
+
},
|
|
9188
|
+
"module.source.replace": {
|
|
9189
|
+
moduleId: text,
|
|
9190
|
+
beforeImports: strings$1,
|
|
9191
|
+
beforeSource: text,
|
|
9192
|
+
imports: strings$1,
|
|
9193
|
+
source: text
|
|
9194
|
+
},
|
|
9195
|
+
"graph.node.task.set": {
|
|
9196
|
+
...at,
|
|
9197
|
+
before: union([inline, managed]),
|
|
9198
|
+
value: union([inline, managed])
|
|
9406
9199
|
}
|
|
9407
|
-
}
|
|
9408
|
-
|
|
9409
|
-
|
|
9410
|
-
|
|
9411
|
-
|
|
9412
|
-
|
|
9413
|
-
|
|
9414
|
-
|
|
9415
|
-
...value.jsonSchema === void 0 ? {} : { schema: value.jsonSchema }
|
|
9416
|
-
};
|
|
9417
|
-
const expression = (value) => ({
|
|
9418
|
-
left: operand(value.left),
|
|
9419
|
-
operator: value.operator,
|
|
9420
|
-
...value.right === void 0 ? {} : { right: operand(value.right) }
|
|
9421
|
-
});
|
|
9422
|
-
return {
|
|
9423
|
-
match: node.matchMode,
|
|
9424
|
-
branches: node.cases.map((branch) => {
|
|
9425
|
-
const groups = branch.groups.map((group) => group.expressions.length == 1 ? expression(group.expressions[0]) : { all: group.expressions.map(expression) });
|
|
9426
|
-
return {
|
|
9427
|
-
name: branch.output,
|
|
9428
|
-
...branch.description === void 0 ? {} : { description: branch.description },
|
|
9429
|
-
when: groups.length == 1 ? groups[0] : { any: groups }
|
|
9430
|
-
};
|
|
9431
|
-
})
|
|
9432
|
-
};
|
|
9433
|
-
}
|
|
9434
|
-
//#endregion
|
|
9435
|
-
//#region src/control/common/authoringFields.ts
|
|
9436
|
-
/** Business field contracts, independent of storage handles and presentation groups. */
|
|
9437
|
-
function fieldsView(ports) {
|
|
9438
|
-
return Object.fromEntries(ports.flatMap((port) => "handle" in port ? [[port.handle, {
|
|
9439
|
-
schema: port.jsonSchema,
|
|
9440
|
-
nullable: port.nullable,
|
|
9441
|
-
...port.description == null ? {} : { description: port.description },
|
|
9442
|
-
...Object.hasOwn(port, "value") ? { default: port.value } : {}
|
|
9443
|
-
}]] : []));
|
|
9200
|
+
};
|
|
9201
|
+
array(union([...new Map(Object.entries(shapes).map(([kind, shape]) => [kind, shape instanceof ZodType ? shape : object({
|
|
9202
|
+
kind: literal(kind),
|
|
9203
|
+
...shape
|
|
9204
|
+
})])).values()])).min(1);
|
|
9205
|
+
function checkModelVersion(content) {
|
|
9206
|
+
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.");
|
|
9207
|
+
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.");
|
|
9444
9208
|
}
|
|
9445
9209
|
//#endregion
|
|
9446
9210
|
//#region src/control/common/authoringLlm.ts
|
|
9447
9211
|
var authoringLlmConfiguration = strictObject({
|
|
9448
9212
|
mode: _enum(["chat", "json"]),
|
|
9449
|
-
resultSchema: json$
|
|
9450
|
-
model: json$
|
|
9451
|
-
template: json$
|
|
9452
|
-
messages: json$
|
|
9453
|
-
});
|
|
9454
|
-
var defaults = {
|
|
9455
|
-
model: "model",
|
|
9456
|
-
template: "template",
|
|
9457
|
-
messages: "messages"
|
|
9458
|
-
};
|
|
9459
|
-
/** Read defaults only. Node bindings remain independently visible and editable. */
|
|
9460
|
-
function llmConfigurationView(task) {
|
|
9461
|
-
if (task.executor.kind != "llm") throw new TypeError("Expected an LLM task.");
|
|
9462
|
-
const config = {
|
|
9463
|
-
mode: task.executor.mode,
|
|
9464
|
-
resultSchema: task.outputs.find((port) => "handle" in port)?.jsonSchema ?? {}
|
|
9465
|
-
};
|
|
9466
|
-
for (const [name, handle] of Object.entries(defaults)) {
|
|
9467
|
-
const port = task.inputs.find((candidate) => "handle" in candidate && candidate.handle == handle);
|
|
9468
|
-
if (port != null && Object.hasOwn(port, "value")) config[name] = port.value;
|
|
9469
|
-
}
|
|
9470
|
-
return config;
|
|
9471
|
-
}
|
|
9472
|
-
//#endregion
|
|
9473
|
-
//#region src/openapi/common/openapi.ts
|
|
9474
|
-
var methods = [
|
|
9475
|
-
"get",
|
|
9476
|
-
"put",
|
|
9477
|
-
"post",
|
|
9478
|
-
"delete",
|
|
9479
|
-
"options",
|
|
9480
|
-
"head",
|
|
9481
|
-
"patch",
|
|
9482
|
-
"trace"
|
|
9483
|
-
];
|
|
9484
|
-
function object(value) {
|
|
9485
|
-
if (value == null || typeof value != "object" || Array.isArray(value)) throw new Error("Expected an OpenAPI object.");
|
|
9486
|
-
return value;
|
|
9487
|
-
}
|
|
9488
|
-
function parseOpenApi(value) {
|
|
9489
|
-
const doc = object(value);
|
|
9490
|
-
if (typeof doc.openapi != "string" || !/^3\.[01]\.\d+$/.test(doc.openapi)) throw new Error("Only OpenAPI 3.0 and 3.1 JSON documents are supported.");
|
|
9491
|
-
object(doc.paths);
|
|
9492
|
-
return doc;
|
|
9493
|
-
}
|
|
9494
|
-
function pointer(doc, ref) {
|
|
9495
|
-
if (!ref.startsWith("#/")) throw new Error("External OpenAPI references are not supported.");
|
|
9496
|
-
let value = doc;
|
|
9497
|
-
for (const key of decodeURIComponent(ref.slice(2)).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~"))) {
|
|
9498
|
-
const source = object(value);
|
|
9499
|
-
if (!Object.hasOwn(source, key)) throw new Error("An OpenAPI reference is missing.");
|
|
9500
|
-
value = source[key];
|
|
9501
|
-
}
|
|
9502
|
-
return value;
|
|
9503
|
-
}
|
|
9504
|
-
function resolved(doc, value) {
|
|
9505
|
-
let result = object(value);
|
|
9506
|
-
const seen = /* @__PURE__ */ new Set();
|
|
9507
|
-
while (typeof result.$ref == "string") {
|
|
9508
|
-
if (seen.has(result.$ref)) throw new Error("Circular non-schema reference is unsupported.");
|
|
9509
|
-
seen.add(result.$ref);
|
|
9510
|
-
const { $ref, ...siblings } = result;
|
|
9511
|
-
result = {
|
|
9512
|
-
...object(pointer(doc, $ref)),
|
|
9513
|
-
...siblings
|
|
9514
|
-
};
|
|
9515
|
-
}
|
|
9516
|
-
return result;
|
|
9517
|
-
}
|
|
9518
|
-
function operation(doc, path, method) {
|
|
9519
|
-
const item = resolved(doc, object(doc.paths)[path]);
|
|
9520
|
-
if (!methods.includes(method) || item[method] == null) throw new Error("The selected operation is no longer available.");
|
|
9521
|
-
return {
|
|
9522
|
-
item,
|
|
9523
|
-
op: object(item[method])
|
|
9524
|
-
};
|
|
9525
|
-
}
|
|
9526
|
-
function securityOptions(value, path, method) {
|
|
9527
|
-
const doc = parseOpenApi(value);
|
|
9528
|
-
const { op } = operation(doc, path, method);
|
|
9529
|
-
const requirements = op.security ?? doc.security ?? [];
|
|
9530
|
-
if (!Array.isArray(requirements)) throw new Error("Invalid security requirements.");
|
|
9531
|
-
if (!requirements.length) return [{
|
|
9532
|
-
label: "None",
|
|
9533
|
-
auth: []
|
|
9534
|
-
}];
|
|
9535
|
-
return requirements.map((entry) => {
|
|
9536
|
-
const names = Object.keys(object(entry));
|
|
9537
|
-
const label = names.join(" + ") || "None";
|
|
9538
|
-
try {
|
|
9539
|
-
if (!names.length) return {
|
|
9540
|
-
label,
|
|
9541
|
-
auth: []
|
|
9542
|
-
};
|
|
9543
|
-
const schemes = object(object(doc.components).securitySchemes);
|
|
9544
|
-
return {
|
|
9545
|
-
label,
|
|
9546
|
-
auth: names.map((id) => {
|
|
9547
|
-
const scheme = resolved(doc, schemes[id]);
|
|
9548
|
-
if (scheme.type == "http" && ["bearer", "basic"].includes(String(scheme.scheme).toLowerCase())) return {
|
|
9549
|
-
id,
|
|
9550
|
-
type: String(scheme.scheme).toLowerCase()
|
|
9551
|
-
};
|
|
9552
|
-
if (scheme.type == "apiKey" && (scheme.in == "header" || scheme.in == "query") && typeof scheme.name == "string") return {
|
|
9553
|
-
id,
|
|
9554
|
-
type: "apiKey",
|
|
9555
|
-
name: scheme.name,
|
|
9556
|
-
in: scheme.in
|
|
9557
|
-
};
|
|
9558
|
-
throw new Error("This security scheme is unsupported. Supply an access token using manual Bearer authentication if applicable.");
|
|
9559
|
-
})
|
|
9560
|
-
};
|
|
9561
|
-
} catch (error) {
|
|
9562
|
-
return {
|
|
9563
|
-
label,
|
|
9564
|
-
error: error.message
|
|
9565
|
-
};
|
|
9566
|
-
}
|
|
9567
|
-
});
|
|
9568
|
-
}
|
|
9213
|
+
resultSchema: json$3(),
|
|
9214
|
+
model: json$3().optional().describe("Default model settings: {model, temperature?, top_p?, max_tokens?}. A bound model input takes precedence."),
|
|
9215
|
+
template: json$3().optional().describe("Default message templates: [{role: \"system\" | \"user\" | \"assistant\", content: \"Text with {{namedInput}}\"}]."),
|
|
9216
|
+
messages: json$3().optional().describe("Default conversation history, prepended without template interpolation; an array of {role, content} or null.")
|
|
9217
|
+
});
|
|
9569
9218
|
//#endregion
|
|
9570
9219
|
//#region src/control/common/authoringOpenApi.ts
|
|
9571
9220
|
var authenticationSchema = union([
|
|
@@ -9577,45 +9226,18 @@ var authenticationSchema = union([
|
|
|
9577
9226
|
in: _enum(["header", "query"])
|
|
9578
9227
|
})
|
|
9579
9228
|
]);
|
|
9580
|
-
strictObject({
|
|
9229
|
+
var authoringOpenApiSchema = strictObject({
|
|
9581
9230
|
sourceUrl: string$1().min(1),
|
|
9582
9231
|
path: string$1().min(1),
|
|
9583
9232
|
method: string$1().min(1),
|
|
9584
9233
|
serverUrl: string$1().optional(),
|
|
9585
9234
|
authentication: authenticationSchema.optional().describe("Omit to use the operation default. Bind credentials through the advertised node inputs.")
|
|
9586
9235
|
});
|
|
9587
|
-
function openApiAuthenticationChoices(config) {
|
|
9588
|
-
try {
|
|
9589
|
-
return securityOptions(config.document, config.path, config.method).map(({ label, auth, error }) => Object.assign({ label }, auth == null ? { error } : { authentication: { schemes: auth.map((item) => item.id) } }));
|
|
9590
|
-
} catch (error) {
|
|
9591
|
-
return [{
|
|
9592
|
-
label: "Saved operation",
|
|
9593
|
-
error: error.message
|
|
9594
|
-
}];
|
|
9595
|
-
}
|
|
9596
|
-
}
|
|
9597
|
-
function authenticationView(config) {
|
|
9598
|
-
const schemes = config.auth.map((item) => item.id);
|
|
9599
|
-
if (!openApiAuthenticationChoices(config).some((option) => "authentication" in option && dequal(option.authentication?.schemes, schemes)) && config.auth.length == 1) {
|
|
9600
|
-
const { id: _id, ...manual } = config.auth[0];
|
|
9601
|
-
return manual;
|
|
9602
|
-
}
|
|
9603
|
-
return { schemes };
|
|
9604
|
-
}
|
|
9605
|
-
function openApiConfigView(config) {
|
|
9606
|
-
return {
|
|
9607
|
-
sourceUrl: config.sourceUrl,
|
|
9608
|
-
path: config.path,
|
|
9609
|
-
method: config.method,
|
|
9610
|
-
serverUrl: config.serverUrl,
|
|
9611
|
-
authentication: authenticationView(config)
|
|
9612
|
-
};
|
|
9613
|
-
}
|
|
9614
9236
|
//#endregion
|
|
9615
9237
|
//#region src/control/common/authoringSchema.ts
|
|
9616
9238
|
var id$1 = string$1().min(1);
|
|
9617
|
-
var json$
|
|
9618
|
-
var patch = record$
|
|
9239
|
+
var json$1 = json$3();
|
|
9240
|
+
var patch = record$2(id$1, json$1);
|
|
9619
9241
|
var type = _enum([
|
|
9620
9242
|
"manual",
|
|
9621
9243
|
"webhook",
|
|
@@ -9650,7 +9272,7 @@ var authoringSourceSchema = union([
|
|
|
9650
9272
|
variable$1,
|
|
9651
9273
|
strictObject({
|
|
9652
9274
|
kind: literal("value"),
|
|
9653
|
-
value: json$
|
|
9275
|
+
value: json$1
|
|
9654
9276
|
}),
|
|
9655
9277
|
strictObject({ kind: literal("unset") }),
|
|
9656
9278
|
strictObject({ kind: literal("default") }),
|
|
@@ -9662,8 +9284,8 @@ var authoringSourceSchema = union([
|
|
|
9662
9284
|
var operand = union([
|
|
9663
9285
|
strictObject({
|
|
9664
9286
|
kind: literal("value"),
|
|
9665
|
-
value: json$
|
|
9666
|
-
schema: json$
|
|
9287
|
+
value: json$1.optional(),
|
|
9288
|
+
schema: json$1.optional()
|
|
9667
9289
|
}),
|
|
9668
9290
|
output,
|
|
9669
9291
|
variable$1
|
|
@@ -9671,25 +9293,25 @@ var operand = union([
|
|
|
9671
9293
|
var agentTool = authoringDefinitionSchemas.agent.shape.tools.element.omit({
|
|
9672
9294
|
id: true,
|
|
9673
9295
|
inputs: true
|
|
9674
|
-
}).extend({ inputs: record$
|
|
9296
|
+
}).extend({ inputs: record$2(id$1, authoringDefinitionSchemas.agent.shape.tools.element.shape.inputs.element.shape.source).optional().describe("Action input sources by name. The tool resolves types from the Action. New inputs default to model-provided; existing sources are preserved when omitted.") }).strict();
|
|
9675
9297
|
var notification = strictObject({
|
|
9676
9298
|
...authoringDefinitionSchemas.connector.shape,
|
|
9677
9299
|
messageHandle: id$1,
|
|
9678
|
-
inputs: record$
|
|
9300
|
+
inputs: record$2(id$1, union([strictObject({
|
|
9679
9301
|
kind: literal("value"),
|
|
9680
|
-
value: json$
|
|
9302
|
+
value: json$1
|
|
9681
9303
|
}), strictObject({
|
|
9682
9304
|
kind: literal("input"),
|
|
9683
9305
|
input: id$1
|
|
9684
9306
|
})]))
|
|
9685
9307
|
});
|
|
9686
9308
|
var field = strictObject({
|
|
9687
|
-
schema: json$
|
|
9309
|
+
schema: json$1.optional(),
|
|
9688
9310
|
nullable: boolean().optional(),
|
|
9689
9311
|
description: string$1().optional()
|
|
9690
9312
|
});
|
|
9691
|
-
var inputFields = record$
|
|
9692
|
-
var outputFields = record$
|
|
9313
|
+
var inputFields = record$2(id$1, field.extend({ default: json$1.optional() })).describe("Optional business input constraints by name. A binding to a new Code, Agent, LLM, Wait or Approval input automatically declares an input accepting any JSON. Existing constraints are preserved. Omitted schema accepts any JSON; omitted nullable is true. Use default for inherited values; input.set supplies data.");
|
|
9314
|
+
var outputFields = record$2(id$1, field).describe("Code return fields by name. Omitted schema accepts any JSON; omitted nullable is true.");
|
|
9693
9315
|
var expression = strictObject({
|
|
9694
9316
|
left: operand,
|
|
9695
9317
|
operator: authoringDefinitionSchemas.condition.shape.cases.element.shape.groups.element.shape.expressions.element.shape.operator,
|
|
@@ -9701,36 +9323,53 @@ var when = union([
|
|
|
9701
9323
|
all,
|
|
9702
9324
|
strictObject({ any: array(union([expression, all])) })
|
|
9703
9325
|
]);
|
|
9704
|
-
|
|
9705
|
-
|
|
9706
|
-
|
|
9707
|
-
|
|
9708
|
-
|
|
9709
|
-
|
|
9710
|
-
|
|
9711
|
-
|
|
9712
|
-
|
|
9713
|
-
|
|
9714
|
-
|
|
9715
|
-
|
|
9716
|
-
|
|
9717
|
-
|
|
9718
|
-
|
|
9719
|
-
|
|
9720
|
-
|
|
9721
|
-
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9725
|
-
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
|
|
9729
|
-
|
|
9730
|
-
|
|
9731
|
-
|
|
9732
|
-
|
|
9733
|
-
})
|
|
9326
|
+
var authoringConfigurations = {
|
|
9327
|
+
manual: strictObject({}),
|
|
9328
|
+
error: strictObject({ sourceFlowIds: array(id$1).optional() }),
|
|
9329
|
+
webhook: authoringDefinitionSchemas.webhook.omit({ bodyFields: true }).extend({ body: inputFields }).strict(),
|
|
9330
|
+
cron: strictObject({ schedule: authoringDefinitionSchemas.schedule }),
|
|
9331
|
+
poll: strictObject({
|
|
9332
|
+
key: id$1,
|
|
9333
|
+
connectionId: id$1.optional(),
|
|
9334
|
+
schedule: authoringDefinitionSchemas.schedule
|
|
9335
|
+
}),
|
|
9336
|
+
integration: strictObject({
|
|
9337
|
+
key: id$1,
|
|
9338
|
+
connectionId: id$1.optional()
|
|
9339
|
+
}),
|
|
9340
|
+
code: strictObject({
|
|
9341
|
+
inputs: inputFields,
|
|
9342
|
+
outputs: outputFields,
|
|
9343
|
+
capabilities: authoringDefinitionSchemas.capabilities.optional()
|
|
9344
|
+
}),
|
|
9345
|
+
connector: authoringDefinitionSchemas.connector.omit({ outputMode: true }).strict(),
|
|
9346
|
+
openapi: authoringOpenApiSchema,
|
|
9347
|
+
agent: authoringDefinitionSchemas.agent.omit({
|
|
9348
|
+
prompt: true,
|
|
9349
|
+
tools: true
|
|
9350
|
+
}).extend({
|
|
9351
|
+
inputs: inputFields,
|
|
9352
|
+
resultSchema: json$1.describe("JSON schema of the final result. Defaults to text. The tool manages the output definition; references can omit port."),
|
|
9353
|
+
tools: array(agentTool),
|
|
9354
|
+
notification: notification.optional()
|
|
9355
|
+
}).strict(),
|
|
9356
|
+
llm: authoringLlmConfiguration.extend({ inputs: inputFields }),
|
|
9357
|
+
decision: authoringDefinitionSchemas.decision,
|
|
9358
|
+
condition: strictObject({
|
|
9359
|
+
match: _enum(["first", "all"]),
|
|
9360
|
+
branches: array(strictObject({
|
|
9361
|
+
name: id$1,
|
|
9362
|
+
description: string$1().optional(),
|
|
9363
|
+
when
|
|
9364
|
+
}))
|
|
9365
|
+
}),
|
|
9366
|
+
value: strictObject({
|
|
9367
|
+
values: patch,
|
|
9368
|
+
outputs: outputFields
|
|
9369
|
+
}),
|
|
9370
|
+
wait: strictObject({ inputs: inputFields }),
|
|
9371
|
+
approval: strictObject({ inputs: inputFields })
|
|
9372
|
+
};
|
|
9734
9373
|
var updates = strictObject({
|
|
9735
9374
|
name: id$1.optional(),
|
|
9736
9375
|
description: string$1().optional(),
|
|
@@ -9746,7 +9385,7 @@ var authoringEditSchema = discriminatedUnion("op", [
|
|
|
9746
9385
|
type,
|
|
9747
9386
|
name: id$1,
|
|
9748
9387
|
config: patch.optional(),
|
|
9749
|
-
inputs: record$
|
|
9388
|
+
inputs: record$2(id$1, authoringSourceSchema).optional().describe("Input data sources, applied after creation, as input.set operations. Execution edges are separate."),
|
|
9750
9389
|
code: string$1().optional(),
|
|
9751
9390
|
prompt: string$1().optional()
|
|
9752
9391
|
}),
|
|
@@ -9816,7 +9455,7 @@ strictObject({
|
|
|
9816
9455
|
type: type.optional(),
|
|
9817
9456
|
action: id$1.optional()
|
|
9818
9457
|
}).refine((v) => v.type == null || v.action == null, "Choose type or action.");
|
|
9819
|
-
var authoringDiagnosticSchema = object
|
|
9458
|
+
var authoringDiagnosticSchema = object({
|
|
9820
9459
|
code: id$1,
|
|
9821
9460
|
message: string$1(),
|
|
9822
9461
|
nodes: array(id$1),
|
|
@@ -9824,24 +9463,24 @@ var authoringDiagnosticSchema = object$1({
|
|
|
9824
9463
|
line: number().optional(),
|
|
9825
9464
|
column: number().optional()
|
|
9826
9465
|
});
|
|
9827
|
-
var authoringCheckResponse = object
|
|
9466
|
+
var authoringCheckResponse = object({
|
|
9828
9467
|
flowId: id$1,
|
|
9829
9468
|
revisionId: id$1,
|
|
9830
9469
|
valid: boolean(),
|
|
9831
9470
|
diagnostics: array(authoringDiagnosticSchema),
|
|
9832
9471
|
version: literal(1)
|
|
9833
9472
|
});
|
|
9834
|
-
var authoringEditResponse = object
|
|
9473
|
+
var authoringEditResponse = object({
|
|
9835
9474
|
flowId: id$1,
|
|
9836
9475
|
saved: literal(true),
|
|
9837
9476
|
revision: id$1,
|
|
9838
|
-
nodes: record$
|
|
9839
|
-
changes: array(object
|
|
9477
|
+
nodes: record$2(id$1, id$1),
|
|
9478
|
+
changes: array(object({
|
|
9840
9479
|
index: int(),
|
|
9841
9480
|
op: id$1,
|
|
9842
9481
|
node: id$1.optional()
|
|
9843
9482
|
})),
|
|
9844
|
-
validation: object
|
|
9483
|
+
validation: object({
|
|
9845
9484
|
status: _enum([
|
|
9846
9485
|
"valid",
|
|
9847
9486
|
"invalid",
|
|
@@ -9851,21 +9490,21 @@ var authoringEditResponse = object$1({
|
|
|
9851
9490
|
}),
|
|
9852
9491
|
version: literal(1)
|
|
9853
9492
|
});
|
|
9854
|
-
var authoringReadResponse = object
|
|
9493
|
+
var authoringReadResponse = object({
|
|
9855
9494
|
flowId: id$1,
|
|
9856
9495
|
revision: id$1,
|
|
9857
|
-
data: object
|
|
9858
|
-
nodes: array(record$
|
|
9859
|
-
edges: array(json$
|
|
9860
|
-
text: record$
|
|
9496
|
+
data: object({
|
|
9497
|
+
nodes: array(record$2(string$1(), json$1)).optional(),
|
|
9498
|
+
edges: array(json$1).optional(),
|
|
9499
|
+
text: record$2(string$1(), json$1).optional()
|
|
9861
9500
|
}),
|
|
9862
9501
|
version: literal(1)
|
|
9863
9502
|
});
|
|
9864
|
-
var authoringSearchResponse = object
|
|
9503
|
+
var authoringSearchResponse = object({
|
|
9865
9504
|
flowId: id$1,
|
|
9866
9505
|
revision: id$1,
|
|
9867
|
-
data: object
|
|
9868
|
-
matches: array(object
|
|
9506
|
+
data: object({
|
|
9507
|
+
matches: array(object({
|
|
9869
9508
|
node: id$1,
|
|
9870
9509
|
field: id$1,
|
|
9871
9510
|
line: int().optional(),
|
|
@@ -9877,168 +9516,36 @@ var authoringSearchResponse = object$1({
|
|
|
9877
9516
|
version: literal(1)
|
|
9878
9517
|
});
|
|
9879
9518
|
//#endregion
|
|
9880
|
-
//#region src/control/common/
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
|
|
9884
|
-
|
|
9885
|
-
|
|
9519
|
+
//#region src/control/common/authoringFields.ts
|
|
9520
|
+
/** Business field contracts, independent of storage handles and presentation groups. */
|
|
9521
|
+
function fieldsView(ports) {
|
|
9522
|
+
return Object.fromEntries(ports.flatMap((port) => "handle" in port ? [[port.handle, {
|
|
9523
|
+
schema: port.jsonSchema,
|
|
9524
|
+
nullable: port.nullable,
|
|
9525
|
+
...port.description == null ? {} : { description: port.description },
|
|
9526
|
+
...Object.hasOwn(port, "value") ? { default: port.value } : {}
|
|
9527
|
+
}]] : []));
|
|
9886
9528
|
}
|
|
9887
9529
|
//#endregion
|
|
9888
|
-
//#region src/control/common/
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
|
|
9893
|
-
|
|
9894
|
-
|
|
9895
|
-
|
|
9896
|
-
|
|
9897
|
-
}
|
|
9898
|
-
};
|
|
9899
|
-
function fail(code, message, details = {}) {
|
|
9900
|
-
throw new AuthoringError(code, message, details);
|
|
9901
|
-
}
|
|
9902
|
-
function nodeAt(content, ref) {
|
|
9903
|
-
return (Object.hasOwn(content.document.graph.nodes, ref) ? content.document.graph.nodes[ref] : void 0) ?? fail("node.not-found", `Node ${JSON.stringify(ref)} does not exist.`, { node: ref });
|
|
9904
|
-
}
|
|
9905
|
-
function taskAt(node) {
|
|
9906
|
-
return node.kind == "task" ? node.task : void 0;
|
|
9907
|
-
}
|
|
9908
|
-
var llmReservedInputs = [
|
|
9909
|
-
"model",
|
|
9910
|
-
"template",
|
|
9911
|
-
"messages"
|
|
9912
|
-
];
|
|
9913
|
-
function inputDefinitions(node) {
|
|
9914
|
-
if (node.kind == "condition") return {};
|
|
9915
|
-
if (node.kind == "poll" || node.kind == "integration") return Object.fromEntries(node.definition.configInputs.flatMap((port) => "handle" in port ? [[port.handle, port]] : []));
|
|
9916
|
-
return nodeInputPorts(node);
|
|
9917
|
-
}
|
|
9918
|
-
function inputMappings(node) {
|
|
9919
|
-
return node.kind == "condition" ? {} : node.kind == "poll" || node.kind == "integration" ? node.config : nodeInputMappings(node);
|
|
9920
|
-
}
|
|
9921
|
-
function typeOf(node) {
|
|
9922
|
-
const task = taskAt(node);
|
|
9923
|
-
return node.kind != "task" ? node.kind : task != null && "executor" in task ? task.executor.kind : "code";
|
|
9924
|
-
}
|
|
9925
|
-
function outwardSource(content, value) {
|
|
9926
|
-
if (Array.isArray(value)) return value.map((v) => outwardSource(content, v));
|
|
9927
|
-
if (value == null || typeof value != "object") return value;
|
|
9928
|
-
const v = record$1(value);
|
|
9929
|
-
if (v.kind == "node" && typeof v.nodeId == "string" && typeof v.output == "string") return {
|
|
9930
|
-
kind: "output",
|
|
9931
|
-
node: v.nodeId,
|
|
9932
|
-
port: v.output,
|
|
9933
|
-
...v.field == null ? {} : { field: v.field }
|
|
9934
|
-
};
|
|
9935
|
-
if (v.kind == "binding" && typeof v.bindingId == "string") return {
|
|
9936
|
-
kind: "variable",
|
|
9937
|
-
name: content.document.bindings[v.bindingId]?.target ?? "[missing variable]"
|
|
9938
|
-
};
|
|
9939
|
-
if (v.kind == "value") return value;
|
|
9940
|
-
return Object.fromEntries(Object.entries(v).map(([k, item]) => [k, outwardSource(content, item)]));
|
|
9941
|
-
}
|
|
9942
|
-
function authoringEdges(edges) {
|
|
9943
|
-
return edges.map((edge) => edge.sourceHandle == null ? {
|
|
9944
|
-
source: edge.source,
|
|
9945
|
-
target: edge.target
|
|
9946
|
-
} : {
|
|
9947
|
-
source: edge.source,
|
|
9948
|
-
target: edge.target,
|
|
9949
|
-
branch: edge.sourceHandle
|
|
9950
|
-
});
|
|
9951
|
-
}
|
|
9952
|
-
function authoringNode(content, ref) {
|
|
9953
|
-
const node = nodeAt(content, ref), type = typeOf(node), task = taskAt(node);
|
|
9954
|
-
let config = {};
|
|
9955
|
-
const texts = {};
|
|
9956
|
-
if (task != null && "executor" in task) {
|
|
9957
|
-
const { kind: _, ...executor } = task.executor;
|
|
9958
|
-
config = { ...executor };
|
|
9959
|
-
if (task.executor.kind == "agent") {
|
|
9960
|
-
const { prompt, tools, notification, ...rest } = task.executor;
|
|
9961
|
-
const { kind: _agentKind, ...settings } = rest;
|
|
9962
|
-
config = {
|
|
9963
|
-
...settings,
|
|
9964
|
-
inputs: fieldsView([...task.inputs, ...node.kind == "task" ? node.additionalInputs ?? [] : []]),
|
|
9965
|
-
resultSchema: task.outputs.find((port) => "handle" in port)?.jsonSchema ?? { type: "string" },
|
|
9966
|
-
tools: outwardAgentTools(tools)
|
|
9967
|
-
};
|
|
9968
|
-
texts.prompt = prompt;
|
|
9969
|
-
if (notification != null) {
|
|
9970
|
-
const { inputDefinitions: _definitions, ...noticeSettings } = notification;
|
|
9971
|
-
config.notification = noticeSettings;
|
|
9972
|
-
}
|
|
9973
|
-
} else if (task.executor.kind == "llm") config = {
|
|
9974
|
-
...llmConfigurationView(task),
|
|
9975
|
-
inputs: fieldsView([...task.inputs, ...node.kind == "task" ? node.additionalInputs ?? [] : []].filter((port) => !("handle" in port) || !llmReservedInputs.includes(port.handle)))
|
|
9976
|
-
};
|
|
9977
|
-
else if (task.executor.kind == "openapi") config = { ...openApiConfigView(task.executor) };
|
|
9978
|
-
} else if (node.kind == "task" && "moduleId" in node.task) {
|
|
9979
|
-
config = {
|
|
9980
|
-
inputs: fieldsView([...node.task.inputs, ...node.additionalInputs ?? []]),
|
|
9981
|
-
outputs: fieldsView(node.task.outputs),
|
|
9982
|
-
...node.task.capabilities == null ? {} : { capabilities: node.task.capabilities }
|
|
9530
|
+
//#region src/control/common/authoringTriggers.ts
|
|
9531
|
+
/** Shared business configuration for authoring and published entry inspection. */
|
|
9532
|
+
function triggerConfiguration(node) {
|
|
9533
|
+
switch (node.kind) {
|
|
9534
|
+
case "manual": return {};
|
|
9535
|
+
case "webhook": return {
|
|
9536
|
+
body: fieldsView(node.bodyFields),
|
|
9537
|
+
method: node.method,
|
|
9538
|
+
...node.options == null ? {} : { options: node.options }
|
|
9983
9539
|
};
|
|
9984
|
-
|
|
9985
|
-
|
|
9986
|
-
case "condition":
|
|
9987
|
-
config = { ...conditionConfigurationView(node, (value) => outwardSource(content, value)) };
|
|
9988
|
-
break;
|
|
9989
|
-
case "value":
|
|
9990
|
-
config = {
|
|
9991
|
-
values: Object.fromEntries(node.values.filter((port) => Object.hasOwn(port, "value")).map((port) => [port.handle, port.value])),
|
|
9992
|
-
outputs: fieldsView(node.values.map(({ value: _value, ...port }) => port))
|
|
9993
|
-
};
|
|
9994
|
-
break;
|
|
9995
|
-
case "wait":
|
|
9996
|
-
case "approval":
|
|
9997
|
-
config = { inputs: fieldsView(node.inputDefinitions) };
|
|
9998
|
-
texts.prompt = node.prompt;
|
|
9999
|
-
break;
|
|
10000
|
-
case "webhook":
|
|
10001
|
-
config = {
|
|
10002
|
-
body: fieldsView(node.bodyFields),
|
|
10003
|
-
method: node.method,
|
|
10004
|
-
...node.options == null ? {} : { options: node.options }
|
|
10005
|
-
};
|
|
10006
|
-
break;
|
|
10007
|
-
case "cron":
|
|
10008
|
-
config = { schedule: node.cronTimes };
|
|
10009
|
-
break;
|
|
10010
|
-
case "error":
|
|
10011
|
-
config = node.sourceFlowIds == null ? {} : { sourceFlowIds: node.sourceFlowIds };
|
|
10012
|
-
break;
|
|
9540
|
+
case "cron": return { schedule: node.cronTimes };
|
|
9541
|
+
case "error": return node.sourceFlowIds == null ? {} : { sourceFlowIds: node.sourceFlowIds };
|
|
10013
9542
|
case "poll":
|
|
10014
|
-
case "integration":
|
|
9543
|
+
case "integration": return {
|
|
10015
9544
|
key: node.definition.key,
|
|
10016
9545
|
...node.connectionId == null ? {} : { connectionId: node.connectionId },
|
|
10017
9546
|
...node.kind == "poll" ? { schedule: node.pollTimes } : {}
|
|
10018
9547
|
};
|
|
10019
9548
|
}
|
|
10020
|
-
const edges = authoringEdges(content.document.graph.edges);
|
|
10021
|
-
return {
|
|
10022
|
-
ref,
|
|
10023
|
-
type,
|
|
10024
|
-
name: node.name ?? ref,
|
|
10025
|
-
readOnly: false,
|
|
10026
|
-
...node.description == null ? {} : { description: node.description },
|
|
10027
|
-
...node.icon == null ? {} : { icon: node.icon },
|
|
10028
|
-
..."timeoutMs" in node && node.timeoutMs != null ? { timeoutMs: node.timeoutMs } : {},
|
|
10029
|
-
..."maxExecutions" in node && node.maxExecutions != null ? { maxExecutions: node.maxExecutions } : {},
|
|
10030
|
-
config: json$1(config),
|
|
10031
|
-
texts: Object.fromEntries(Object.entries(texts).map(([field, text]) => [field, {
|
|
10032
|
-
lines: text.split("\n").length,
|
|
10033
|
-
characters: text.length
|
|
10034
|
-
}])),
|
|
10035
|
-
inputs: outwardSource(content, inputMappings(node)),
|
|
10036
|
-
inputPorts: fieldsView(Object.entries(inputDefinitions(node)).map(([handle, port]) => Object.assign({}, port, { handle }))),
|
|
10037
|
-
outputPorts: fieldsView(Object.entries(nodeOutputPorts(node)).map(([handle, port]) => Object.assign({}, port, { handle }))),
|
|
10038
|
-
...task != null && "executor" in task && task.executor.kind == "openapi" ? { authenticationChoices: openApiAuthenticationChoices(task.executor) } : {},
|
|
10039
|
-
incoming: edges.filter((e) => e.target == ref),
|
|
10040
|
-
outgoing: edges.filter((e) => e.source == ref)
|
|
10041
|
-
};
|
|
10042
9549
|
}
|
|
10043
9550
|
//#endregion
|
|
10044
9551
|
//#region src/control/common/errors.ts
|
|
@@ -10074,7 +9581,6 @@ var controlErrorCode = {
|
|
|
10074
9581
|
publicationConflict: "publication.conflict",
|
|
10075
9582
|
publicationNotFound: "publication.not-found",
|
|
10076
9583
|
publicationUnsupported: "publication.unsupported",
|
|
10077
|
-
resourceNotFound: "resource.not-found",
|
|
10078
9584
|
publishOperationNotFound: "publication.operation-not-found",
|
|
10079
9585
|
routeNotFound: "route.not-found",
|
|
10080
9586
|
runConflict: "run.conflict",
|
|
@@ -10123,7 +9629,6 @@ var controlErrorMetadata = {
|
|
|
10123
9629
|
[controlErrorCode.publicationConflict]: { status: 409 },
|
|
10124
9630
|
[controlErrorCode.publicationNotFound]: { status: 404 },
|
|
10125
9631
|
[controlErrorCode.publicationUnsupported]: { status: 409 },
|
|
10126
|
-
[controlErrorCode.resourceNotFound]: { status: 404 },
|
|
10127
9632
|
[controlErrorCode.publishOperationNotFound]: { status: 404 },
|
|
10128
9633
|
[controlErrorCode.routeNotFound]: { status: 404 },
|
|
10129
9634
|
[controlErrorCode.runConflict]: { status: 409 },
|
|
@@ -10175,28 +9680,164 @@ function exact(value, keys) {
|
|
|
10175
9680
|
invalidResponse([missing.length > 0 ? `Missing fields: ${missing.join(", ")}.` : "", unexpected.length > 0 ? `Unexpected fields: ${unexpected.join(", ")}.` : ""].filter(Boolean).join(" "));
|
|
10176
9681
|
}
|
|
10177
9682
|
}
|
|
10178
|
-
function integer(value) {
|
|
10179
|
-
return Number.isSafeInteger(value) ? value : invalidResponse("Expected a safe integer.");
|
|
10180
|
-
}
|
|
10181
|
-
function jsonValue(value) {
|
|
10182
|
-
if (value === null || typeof value == "boolean" || typeof value == "string") return value;
|
|
10183
|
-
if (typeof value == "number" && Number.isFinite(value)) return value;
|
|
10184
|
-
if (Array.isArray(value)) return value.map(jsonValue);
|
|
9683
|
+
function integer(value) {
|
|
9684
|
+
return Number.isSafeInteger(value) ? value : invalidResponse("Expected a safe integer.");
|
|
9685
|
+
}
|
|
9686
|
+
function jsonValue(value) {
|
|
9687
|
+
if (value === null || typeof value == "boolean" || typeof value == "string") return value;
|
|
9688
|
+
if (typeof value == "number" && Number.isFinite(value)) return value;
|
|
9689
|
+
if (Array.isArray(value)) return value.map(jsonValue);
|
|
9690
|
+
const source = record(value);
|
|
9691
|
+
return Object.fromEntries(Object.entries(source).map(([key, item]) => [key, jsonValue(item)]));
|
|
9692
|
+
}
|
|
9693
|
+
function optionalString(value) {
|
|
9694
|
+
if (value == null) return;
|
|
9695
|
+
return string(value);
|
|
9696
|
+
}
|
|
9697
|
+
//#endregion
|
|
9698
|
+
//#region src/control/common/publicationDecoders.ts
|
|
9699
|
+
function publication(value) {
|
|
9700
|
+
const source = record(value);
|
|
9701
|
+
const liveEnd = source.liveEnd == null ? void 0 : record(source.liveEnd);
|
|
9702
|
+
if (liveEnd != null && typeof liveEnd.enabled != "boolean") return invalidResponse();
|
|
9703
|
+
const operation = source.operation;
|
|
9704
|
+
const sourcePublicationId = source.sourcePublicationId;
|
|
9705
|
+
if (source.version != 1) return invalidResponse();
|
|
9706
|
+
if (operation != "publish" && operation != "rollback") return invalidResponse();
|
|
9707
|
+
if (sourcePublicationId != null && typeof sourcePublicationId != "string") return invalidResponse();
|
|
9708
|
+
return {
|
|
9709
|
+
...liveEnd == null ? {} : { liveEnd: {
|
|
9710
|
+
enabled: liveEnd.enabled,
|
|
9711
|
+
endedAt: string(liveEnd.endedAt)
|
|
9712
|
+
} },
|
|
9713
|
+
actorId: string(source.actorId),
|
|
9714
|
+
closureDigest: string(source.closureDigest),
|
|
9715
|
+
createdAt: string(source.createdAt),
|
|
9716
|
+
engineContract: string(source.engineContract),
|
|
9717
|
+
flowId: string(source.flowId),
|
|
9718
|
+
modelVersion: integer(source.modelVersion),
|
|
9719
|
+
operation,
|
|
9720
|
+
publicationId: string(source.publicationId),
|
|
9721
|
+
sharedAccessDigest: string(source.sharedAccessDigest),
|
|
9722
|
+
revisionDigest: string(source.revisionDigest),
|
|
9723
|
+
revisionId: string(source.revisionId),
|
|
9724
|
+
...sourcePublicationId == null ? {} : { sourcePublicationId },
|
|
9725
|
+
version: 1
|
|
9726
|
+
};
|
|
9727
|
+
}
|
|
9728
|
+
function publishOperation(value) {
|
|
9729
|
+
const source = record(value);
|
|
9730
|
+
const status = source.status;
|
|
9731
|
+
const common = {
|
|
9732
|
+
createdAt: string(source.createdAt),
|
|
9733
|
+
flowId: string(source.flowId),
|
|
9734
|
+
operationId: string(source.operationId),
|
|
9735
|
+
revisionId: string(source.revisionId),
|
|
9736
|
+
updatedAt: string(source.updatedAt),
|
|
9737
|
+
version: 1
|
|
9738
|
+
};
|
|
9739
|
+
if (source.version != 1) return invalidResponse();
|
|
9740
|
+
switch (status) {
|
|
9741
|
+
case "pending":
|
|
9742
|
+
exact(source, [
|
|
9743
|
+
"createdAt",
|
|
9744
|
+
"flowId",
|
|
9745
|
+
"operationId",
|
|
9746
|
+
"revisionId",
|
|
9747
|
+
"status",
|
|
9748
|
+
"updatedAt",
|
|
9749
|
+
"version"
|
|
9750
|
+
]);
|
|
9751
|
+
return {
|
|
9752
|
+
...common,
|
|
9753
|
+
status
|
|
9754
|
+
};
|
|
9755
|
+
case "succeeded":
|
|
9756
|
+
exact(source, [
|
|
9757
|
+
"createdAt",
|
|
9758
|
+
"flowId",
|
|
9759
|
+
"operationId",
|
|
9760
|
+
"publicationId",
|
|
9761
|
+
"revisionId",
|
|
9762
|
+
"status",
|
|
9763
|
+
"updatedAt",
|
|
9764
|
+
"version"
|
|
9765
|
+
]);
|
|
9766
|
+
return {
|
|
9767
|
+
...common,
|
|
9768
|
+
publicationId: string(source.publicationId),
|
|
9769
|
+
status
|
|
9770
|
+
};
|
|
9771
|
+
case "failed": {
|
|
9772
|
+
exact(source, [
|
|
9773
|
+
"createdAt",
|
|
9774
|
+
"flowId",
|
|
9775
|
+
"issue",
|
|
9776
|
+
"operationId",
|
|
9777
|
+
"revisionId",
|
|
9778
|
+
"status",
|
|
9779
|
+
"updatedAt",
|
|
9780
|
+
"version"
|
|
9781
|
+
]);
|
|
9782
|
+
const issue = record(source.issue);
|
|
9783
|
+
const nodeId = issue.nodeId;
|
|
9784
|
+
exact(issue, [
|
|
9785
|
+
"code",
|
|
9786
|
+
"message",
|
|
9787
|
+
...nodeId == null ? [] : ["nodeId"]
|
|
9788
|
+
]);
|
|
9789
|
+
return {
|
|
9790
|
+
...common,
|
|
9791
|
+
issue: {
|
|
9792
|
+
code: string(issue.code),
|
|
9793
|
+
message: string(issue.message),
|
|
9794
|
+
...nodeId == null ? {} : { nodeId: string(nodeId) }
|
|
9795
|
+
},
|
|
9796
|
+
status
|
|
9797
|
+
};
|
|
9798
|
+
}
|
|
9799
|
+
default: return invalidResponse();
|
|
9800
|
+
}
|
|
9801
|
+
}
|
|
9802
|
+
function live(value) {
|
|
10185
9803
|
const source = record(value);
|
|
10186
|
-
|
|
9804
|
+
const status = source.status;
|
|
9805
|
+
const candidate = source.publication;
|
|
9806
|
+
if (source.version != 1 || typeof source.hasUnpublishedChanges != "boolean") return invalidResponse();
|
|
9807
|
+
if (status != "not-published" && status != "runnable" && status != "suspended") return invalidResponse();
|
|
9808
|
+
if (status == "not-published" && candidate !== null) return invalidResponse();
|
|
9809
|
+
if (status != "not-published" && candidate === null) return invalidResponse();
|
|
9810
|
+
return {
|
|
9811
|
+
flowId: string(source.flowId),
|
|
9812
|
+
hasUnpublishedChanges: source.hasUnpublishedChanges,
|
|
9813
|
+
publication: candidate === null ? null : publication(candidate),
|
|
9814
|
+
revision: integer(source.revision),
|
|
9815
|
+
status,
|
|
9816
|
+
version: 1
|
|
9817
|
+
};
|
|
10187
9818
|
}
|
|
10188
|
-
function
|
|
10189
|
-
|
|
10190
|
-
|
|
9819
|
+
function publicationPage(value) {
|
|
9820
|
+
const source = record(value);
|
|
9821
|
+
const nextCursor = source.nextCursor;
|
|
9822
|
+
const total = source.total;
|
|
9823
|
+
if (source.version != 1 || !Array.isArray(source.publications)) return invalidResponse();
|
|
9824
|
+
if (nextCursor != null && typeof nextCursor != "string") return invalidResponse();
|
|
9825
|
+
if (total != null && !Number.isSafeInteger(total)) return invalidResponse();
|
|
9826
|
+
return {
|
|
9827
|
+
...nextCursor == null ? {} : { nextCursor },
|
|
9828
|
+
publications: source.publications.map(publication),
|
|
9829
|
+
...total == null ? {} : { total },
|
|
9830
|
+
version: 1
|
|
9831
|
+
};
|
|
10191
9832
|
}
|
|
10192
9833
|
//#endregion
|
|
10193
9834
|
//#region src/trigger/common/configSchema.ts
|
|
10194
9835
|
var configInputsSchema = array(union([strictObject({
|
|
10195
9836
|
handle: string$1().min(1),
|
|
10196
9837
|
description: string$1().optional(),
|
|
10197
|
-
jsonSchema: json$
|
|
9838
|
+
jsonSchema: json$3(),
|
|
10198
9839
|
nullable: boolean(),
|
|
10199
|
-
value: json$
|
|
9840
|
+
value: json$3().optional()
|
|
10200
9841
|
}), strictObject({
|
|
10201
9842
|
group: string$1(),
|
|
10202
9843
|
collapsed: boolean().optional()
|
|
@@ -10372,69 +10013,122 @@ function pollTriggerTestResult(value) {
|
|
|
10372
10013
|
};
|
|
10373
10014
|
}
|
|
10374
10015
|
//#endregion
|
|
10375
|
-
//#region src/control/common/
|
|
10376
|
-
|
|
10377
|
-
|
|
10378
|
-
|
|
10379
|
-
|
|
10016
|
+
//#region src/control/common/liveDetails.ts
|
|
10017
|
+
var metadata = {
|
|
10018
|
+
nodeId: string$1().min(1),
|
|
10019
|
+
name: string$1(),
|
|
10020
|
+
description: string$1().optional()
|
|
10021
|
+
};
|
|
10022
|
+
var binding = unknown().transform(triggerBinding);
|
|
10023
|
+
var provider = {
|
|
10024
|
+
provider: string$1().min(1),
|
|
10025
|
+
inputs: record$2(string$1(), discriminatedUnion("kind", [strictObject({
|
|
10026
|
+
kind: literal("value"),
|
|
10027
|
+
value: json$3()
|
|
10028
|
+
}), strictObject({ kind: literal("unset") })]))
|
|
10029
|
+
};
|
|
10030
|
+
var entrySchema = discriminatedUnion("type", [
|
|
10031
|
+
strictObject({
|
|
10032
|
+
...metadata,
|
|
10033
|
+
type: literal("manual"),
|
|
10034
|
+
config: authoringConfigurations.manual
|
|
10035
|
+
}),
|
|
10036
|
+
strictObject({
|
|
10037
|
+
...metadata,
|
|
10038
|
+
type: literal("webhook"),
|
|
10039
|
+
config: authoringConfigurations.webhook,
|
|
10040
|
+
binding
|
|
10041
|
+
}),
|
|
10042
|
+
strictObject({
|
|
10043
|
+
...metadata,
|
|
10044
|
+
type: literal("cron"),
|
|
10045
|
+
config: authoringConfigurations.cron,
|
|
10046
|
+
binding
|
|
10047
|
+
}),
|
|
10048
|
+
strictObject({
|
|
10049
|
+
...metadata,
|
|
10050
|
+
type: literal("error"),
|
|
10051
|
+
config: authoringConfigurations.error,
|
|
10052
|
+
binding
|
|
10053
|
+
}),
|
|
10054
|
+
strictObject({
|
|
10055
|
+
...metadata,
|
|
10056
|
+
...provider,
|
|
10057
|
+
type: literal("poll"),
|
|
10058
|
+
config: authoringConfigurations.poll,
|
|
10059
|
+
binding
|
|
10060
|
+
}),
|
|
10061
|
+
strictObject({
|
|
10062
|
+
...metadata,
|
|
10063
|
+
...provider,
|
|
10064
|
+
type: literal("integration"),
|
|
10065
|
+
config: authoringConfigurations.integration,
|
|
10066
|
+
binding
|
|
10067
|
+
})
|
|
10068
|
+
]);
|
|
10069
|
+
/** Project only the selected published definition and its current bindings. */
|
|
10070
|
+
function liveEntries(content, current, bindings) {
|
|
10071
|
+
const byNode = new Map(bindings.filter((item) => item.flowId == current.flowId && item.currentPublicationId == current.publicationId && item.currentRevisionId == current.revisionId).map((item) => [item.triggerNodeId, item]));
|
|
10072
|
+
return decodeEntries(Object.entries(content.document.graph.nodes).toSorted(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).flatMap(([nodeId, node]) => {
|
|
10073
|
+
if (node.kind != "manual" && node.kind != "webhook" && node.kind != "cron" && node.kind != "error" && node.kind != "poll" && node.kind != "integration") return [];
|
|
10074
|
+
const config = triggerConfiguration(node);
|
|
10380
10075
|
return [{
|
|
10381
|
-
|
|
10382
|
-
|
|
10076
|
+
nodeId,
|
|
10077
|
+
name: node.name,
|
|
10383
10078
|
type: node.kind,
|
|
10384
|
-
|
|
10385
|
-
|
|
10386
|
-
|
|
10387
|
-
|
|
10079
|
+
...node.description == null ? {} : { description: node.description },
|
|
10080
|
+
config: node.kind == "webhook" && !webhookSupportsBody(node.method) ? {
|
|
10081
|
+
...config,
|
|
10082
|
+
body: {}
|
|
10083
|
+
} : config,
|
|
10084
|
+
...node.kind == "manual" ? {} : { binding: byNode.get(nodeId) },
|
|
10085
|
+
...node.kind == "poll" || node.kind == "integration" ? {
|
|
10086
|
+
provider: node.definition.provider,
|
|
10087
|
+
inputs: node.config
|
|
10088
|
+
} : {}
|
|
10388
10089
|
}];
|
|
10389
|
-
});
|
|
10390
|
-
}
|
|
10391
|
-
function context(source) {
|
|
10392
|
-
if (source.version != 1 || source.status != "live" && source.status != "historical") return invalidResponse();
|
|
10393
|
-
if (source.status == "live" ? typeof source.enabled != "boolean" : source.enabled !== void 0) return invalidResponse();
|
|
10394
|
-
return {
|
|
10395
|
-
flowId: string(source.flowId),
|
|
10396
|
-
publicationId: string(source.publicationId),
|
|
10397
|
-
revisionId: string(source.revisionId),
|
|
10398
|
-
status: source.status,
|
|
10399
|
-
...source.enabled == null ? {} : { enabled: source.enabled },
|
|
10400
|
-
version: 1
|
|
10401
|
-
};
|
|
10402
|
-
}
|
|
10403
|
-
function resource(value, scope) {
|
|
10404
|
-
const source = record(value);
|
|
10405
|
-
const type = source.type;
|
|
10406
|
-
if (source.kind != "trigger" || type != "webhook" && type != "cron" && type != "poll" && type != "integration" && type != "error") return invalidResponse();
|
|
10407
|
-
if (source.description != null && typeof source.description != "string") return invalidResponse();
|
|
10408
|
-
const resourceId = string(source.resourceId);
|
|
10409
|
-
const runtime = source.runtime == null ? void 0 : triggerBinding(source.runtime);
|
|
10410
|
-
if (runtime != null && (scope.status != "live" || runtime.flowId != scope.flowId || runtime.currentPublicationId != scope.publicationId || runtime.currentRevisionId != scope.revisionId || runtime.triggerNodeId != resourceId || runtime.kind != type)) return invalidResponse();
|
|
10411
|
-
return {
|
|
10412
|
-
resourceId,
|
|
10413
|
-
kind: "trigger",
|
|
10414
|
-
type,
|
|
10415
|
-
name: string(source.name),
|
|
10416
|
-
...source.description == null ? {} : { description: source.description },
|
|
10417
|
-
config: jsonValue(source.config),
|
|
10418
|
-
inputs: jsonValue(source.inputs),
|
|
10419
|
-
...runtime == null ? {} : { runtime }
|
|
10420
|
-
};
|
|
10090
|
+
}), current);
|
|
10421
10091
|
}
|
|
10422
|
-
function
|
|
10092
|
+
function decodeLiveDetails(value) {
|
|
10423
10093
|
const source = record(value);
|
|
10424
|
-
const
|
|
10425
|
-
if (!Array.isArray(source.
|
|
10094
|
+
const flowId = string(source.flowId);
|
|
10095
|
+
if (source.version != 1 || !Array.isArray(source.entries)) return invalidResponse();
|
|
10096
|
+
if (source.publication === null) {
|
|
10097
|
+
if (source.status != "not-published" || source.entries.length != 0 || Object.hasOwn(source, "enabled")) return invalidResponse();
|
|
10098
|
+
return {
|
|
10099
|
+
flowId,
|
|
10100
|
+
publication: null,
|
|
10101
|
+
status: "not-published",
|
|
10102
|
+
entries: [],
|
|
10103
|
+
version: 1
|
|
10104
|
+
};
|
|
10105
|
+
}
|
|
10106
|
+
const current = publication(source.publication);
|
|
10107
|
+
const status = source.status;
|
|
10108
|
+
if (current.flowId != flowId || typeof source.enabled != "boolean") return invalidResponse();
|
|
10109
|
+
if (status != "runnable" && status != "suspended") return invalidResponse();
|
|
10110
|
+
if (!source.enabled && source.status == "runnable") return invalidResponse();
|
|
10426
10111
|
return {
|
|
10427
|
-
|
|
10428
|
-
|
|
10112
|
+
flowId,
|
|
10113
|
+
publication: current,
|
|
10114
|
+
status,
|
|
10115
|
+
enabled: source.enabled,
|
|
10116
|
+
entries: decodeEntries(source.entries, current),
|
|
10117
|
+
version: 1
|
|
10429
10118
|
};
|
|
10430
10119
|
}
|
|
10431
|
-
|
|
10432
|
-
|
|
10433
|
-
const
|
|
10434
|
-
return
|
|
10435
|
-
|
|
10436
|
-
|
|
10437
|
-
|
|
10120
|
+
/** Both producers and consumers enforce the same published-entry invariants. */
|
|
10121
|
+
function decodeEntries(values, current) {
|
|
10122
|
+
const parsed = array(entrySchema).safeParse(values);
|
|
10123
|
+
if (!parsed.success) return invalidResponse();
|
|
10124
|
+
const ids = /* @__PURE__ */ new Set();
|
|
10125
|
+
for (const entry of parsed.data) {
|
|
10126
|
+
if (ids.has(entry.nodeId)) return invalidResponse();
|
|
10127
|
+
ids.add(entry.nodeId);
|
|
10128
|
+
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();
|
|
10129
|
+
if (entry.type == "webhook" && (!entry.binding.endpointUrl || !webhookSupportsBody(entry.config.method) && Object.keys(entry.config.body).length > 0)) return invalidResponse();
|
|
10130
|
+
}
|
|
10131
|
+
return parsed.data;
|
|
10438
10132
|
}
|
|
10439
10133
|
//#endregion
|
|
10440
10134
|
//#region src/control/common/providerIconSprite.ts
|
|
@@ -10471,6 +10165,24 @@ function providerIconAppearance(metadata, position) {
|
|
|
10471
10165
|
};
|
|
10472
10166
|
}
|
|
10473
10167
|
//#endregion
|
|
10168
|
+
//#region src/flow/common/workflowFile.ts
|
|
10169
|
+
var envelope = strictObject({
|
|
10170
|
+
kind: literal("open-flow-workflow"),
|
|
10171
|
+
version: literal(1),
|
|
10172
|
+
name: string$1().optional(),
|
|
10173
|
+
content: unknown(),
|
|
10174
|
+
presentation: record$2(string$1(), json$3()).optional()
|
|
10175
|
+
});
|
|
10176
|
+
/** Structural decoding only: incomplete drafts are supported, repair is never attempted. */
|
|
10177
|
+
function decodeWorkflowFile(value) {
|
|
10178
|
+
checkJsonDepth(value, -1);
|
|
10179
|
+
const file = envelope.parse(value);
|
|
10180
|
+
return {
|
|
10181
|
+
...file,
|
|
10182
|
+
content: decodeRevisionContent(file.content)
|
|
10183
|
+
};
|
|
10184
|
+
}
|
|
10185
|
+
//#endregion
|
|
10474
10186
|
//#region src/flow/common/encoding.ts
|
|
10475
10187
|
var encoder$1 = new TextEncoder();
|
|
10476
10188
|
function canonicalText(value) {
|
|
@@ -10825,41 +10537,231 @@ function connectorActionMetadata(value) {
|
|
|
10825
10537
|
serviceName: string(source.serviceName)
|
|
10826
10538
|
};
|
|
10827
10539
|
}
|
|
10828
|
-
function connectorAction(value) {
|
|
10829
|
-
const { defaultConnection, ...metadata } = record(value);
|
|
10830
|
-
const action = connectorActionMetadata(metadata);
|
|
10831
|
-
if (defaultConnection == null) return action;
|
|
10832
|
-
const preferred = connection(defaultConnection);
|
|
10833
|
-
if (preferred.serviceId != action.serviceId || preferred.status != "active") return invalidResponse();
|
|
10834
|
-
return {
|
|
10835
|
-
...action,
|
|
10836
|
-
defaultConnection: preferred
|
|
10837
|
-
};
|
|
10540
|
+
function connectorAction(value) {
|
|
10541
|
+
const { defaultConnection, ...metadata } = record(value);
|
|
10542
|
+
const action = connectorActionMetadata(metadata);
|
|
10543
|
+
if (defaultConnection == null) return action;
|
|
10544
|
+
const preferred = connection(defaultConnection);
|
|
10545
|
+
if (preferred.serviceId != action.serviceId || preferred.status != "active") return invalidResponse();
|
|
10546
|
+
return {
|
|
10547
|
+
...action,
|
|
10548
|
+
defaultConnection: preferred
|
|
10549
|
+
};
|
|
10550
|
+
}
|
|
10551
|
+
function connectorProvider(value) {
|
|
10552
|
+
const source = record(value);
|
|
10553
|
+
const homepageUrl = source.homepageUrl;
|
|
10554
|
+
const icon = source.icon;
|
|
10555
|
+
if (source.noSetup !== void 0 && typeof source.noSetup != "boolean") return invalidResponse();
|
|
10556
|
+
exact(source, [
|
|
10557
|
+
...Object.hasOwn(source, "noSetup") ? ["noSetup"] : [],
|
|
10558
|
+
"serviceId",
|
|
10559
|
+
"serviceName",
|
|
10560
|
+
...homepageUrl == null ? [] : ["homepageUrl"],
|
|
10561
|
+
...icon == null ? [] : ["icon"],
|
|
10562
|
+
..."iconSprite" in source ? ["iconSprite"] : [],
|
|
10563
|
+
..."iconSpritePosition" in source ? ["iconSpritePosition"] : []
|
|
10564
|
+
]);
|
|
10565
|
+
if (homepageUrl != null && typeof homepageUrl != "string" || icon != null && typeof icon != "string") return invalidResponse();
|
|
10566
|
+
return {
|
|
10567
|
+
...homepageUrl == null ? {} : { homepageUrl },
|
|
10568
|
+
...icon == null ? {} : { icon },
|
|
10569
|
+
...providerIconAppearance(source.iconSprite, source.iconSpritePosition),
|
|
10570
|
+
serviceId: string(source.serviceId),
|
|
10571
|
+
serviceName: string(source.serviceName),
|
|
10572
|
+
...source.noSetup === void 0 ? {} : { noSetup: source.noSetup }
|
|
10573
|
+
};
|
|
10574
|
+
}
|
|
10575
|
+
//#endregion
|
|
10576
|
+
//#region src/trigger/common/contract.ts
|
|
10577
|
+
var errorOutputs = [
|
|
10578
|
+
{
|
|
10579
|
+
handle: "workflow",
|
|
10580
|
+
nullable: false,
|
|
10581
|
+
jsonSchema: {
|
|
10582
|
+
type: "object",
|
|
10583
|
+
additionalProperties: false,
|
|
10584
|
+
required: [
|
|
10585
|
+
"flowId",
|
|
10586
|
+
"name",
|
|
10587
|
+
"revisionId",
|
|
10588
|
+
"publicationId"
|
|
10589
|
+
],
|
|
10590
|
+
properties: {
|
|
10591
|
+
flowId: { type: "string" },
|
|
10592
|
+
name: { type: "string" },
|
|
10593
|
+
revisionId: { type: "string" },
|
|
10594
|
+
publicationId: { type: ["string", "null"] }
|
|
10595
|
+
}
|
|
10596
|
+
}
|
|
10597
|
+
},
|
|
10598
|
+
{
|
|
10599
|
+
handle: "execution",
|
|
10600
|
+
nullable: false,
|
|
10601
|
+
jsonSchema: {
|
|
10602
|
+
type: "object",
|
|
10603
|
+
additionalProperties: false,
|
|
10604
|
+
required: [
|
|
10605
|
+
"runId",
|
|
10606
|
+
"status",
|
|
10607
|
+
"startedAt",
|
|
10608
|
+
"finishedAt"
|
|
10609
|
+
],
|
|
10610
|
+
properties: {
|
|
10611
|
+
runId: { type: "string" },
|
|
10612
|
+
status: { enum: ["failed", "indeterminate"] },
|
|
10613
|
+
startedAt: { type: ["string", "null"] },
|
|
10614
|
+
finishedAt: { type: "string" }
|
|
10615
|
+
}
|
|
10616
|
+
}
|
|
10617
|
+
},
|
|
10618
|
+
{
|
|
10619
|
+
handle: "error",
|
|
10620
|
+
nullable: false,
|
|
10621
|
+
jsonSchema: {
|
|
10622
|
+
type: "object",
|
|
10623
|
+
additionalProperties: false,
|
|
10624
|
+
required: ["code", "message"],
|
|
10625
|
+
properties: {
|
|
10626
|
+
code: { type: "string" },
|
|
10627
|
+
message: { type: "string" },
|
|
10628
|
+
nodeId: { type: "string" },
|
|
10629
|
+
jobId: { type: "string" },
|
|
10630
|
+
path: {
|
|
10631
|
+
type: "array",
|
|
10632
|
+
items: { type: "string" }
|
|
10633
|
+
}
|
|
10634
|
+
}
|
|
10635
|
+
}
|
|
10636
|
+
}
|
|
10637
|
+
];
|
|
10638
|
+
var webhookOutputs = [
|
|
10639
|
+
{
|
|
10640
|
+
handle: "headers",
|
|
10641
|
+
jsonSchema: {
|
|
10642
|
+
type: "object",
|
|
10643
|
+
additionalProperties: { type: "string" }
|
|
10644
|
+
},
|
|
10645
|
+
nullable: false
|
|
10646
|
+
},
|
|
10647
|
+
{
|
|
10648
|
+
handle: "query",
|
|
10649
|
+
jsonSchema: {
|
|
10650
|
+
type: "object",
|
|
10651
|
+
additionalProperties: {
|
|
10652
|
+
type: ["string", "array"],
|
|
10653
|
+
items: { type: "string" }
|
|
10654
|
+
}
|
|
10655
|
+
},
|
|
10656
|
+
nullable: false
|
|
10657
|
+
},
|
|
10658
|
+
{
|
|
10659
|
+
handle: "body",
|
|
10660
|
+
jsonSchema: {
|
|
10661
|
+
type: "object",
|
|
10662
|
+
additionalProperties: true
|
|
10663
|
+
},
|
|
10664
|
+
nullable: false
|
|
10665
|
+
},
|
|
10666
|
+
{
|
|
10667
|
+
handle: "webhookUrl",
|
|
10668
|
+
jsonSchema: { type: "string" },
|
|
10669
|
+
nullable: false
|
|
10670
|
+
}
|
|
10671
|
+
];
|
|
10672
|
+
var cronOutputs = [{
|
|
10673
|
+
handle: "scheduledAt",
|
|
10674
|
+
jsonSchema: {
|
|
10675
|
+
type: "string",
|
|
10676
|
+
format: "date-time"
|
|
10677
|
+
},
|
|
10678
|
+
nullable: false
|
|
10679
|
+
}];
|
|
10680
|
+
function triggerOutputDefinitions(trigger) {
|
|
10681
|
+
switch (trigger.kind) {
|
|
10682
|
+
case "error": return errorOutputs;
|
|
10683
|
+
case "manual": return [];
|
|
10684
|
+
case "cron": return cronOutputs;
|
|
10685
|
+
case "poll":
|
|
10686
|
+
case "integration": return trigger.definition.outputs;
|
|
10687
|
+
case "webhook": return webhookOutputs.filter((port) => port.handle !== "body" || webhookSupportsBody(trigger.method)).map((port) => port.handle === "body" ? Object.assign({}, port, { jsonSchema: {
|
|
10688
|
+
type: "object",
|
|
10689
|
+
additionalProperties: false,
|
|
10690
|
+
properties: Object.fromEntries(trigger.bodyFields.map((field) => [field.handle, field.jsonSchema])),
|
|
10691
|
+
required: trigger.bodyFields.filter((field) => !field.nullable && !Object.hasOwn(field, "value")).map((field) => field.handle)
|
|
10692
|
+
} }) : port);
|
|
10693
|
+
}
|
|
10694
|
+
}
|
|
10695
|
+
function triggerOutputPorts(trigger) {
|
|
10696
|
+
return Object.fromEntries(triggerOutputDefinitions(trigger).map(({ handle, ...port }) => [handle, port]));
|
|
10838
10697
|
}
|
|
10839
|
-
|
|
10840
|
-
|
|
10841
|
-
|
|
10842
|
-
|
|
10843
|
-
|
|
10844
|
-
|
|
10845
|
-
|
|
10846
|
-
"
|
|
10847
|
-
"
|
|
10848
|
-
|
|
10849
|
-
|
|
10850
|
-
|
|
10851
|
-
|
|
10852
|
-
|
|
10853
|
-
|
|
10698
|
+
//#endregion
|
|
10699
|
+
//#region src/flow/common/graph.ts
|
|
10700
|
+
function nodeInputPorts(node) {
|
|
10701
|
+
switch (node.kind) {
|
|
10702
|
+
case "condition": return conditionInputPorts(node);
|
|
10703
|
+
case "value": return {};
|
|
10704
|
+
case "task": return portsByHandle([...node.task.inputs, ...node.additionalInputs ?? []]);
|
|
10705
|
+
case "approval":
|
|
10706
|
+
case "wait": return portsByHandle(node.inputDefinitions);
|
|
10707
|
+
case "cron":
|
|
10708
|
+
case "integration":
|
|
10709
|
+
case "poll":
|
|
10710
|
+
case "error":
|
|
10711
|
+
case "manual":
|
|
10712
|
+
case "webhook": return {};
|
|
10713
|
+
}
|
|
10714
|
+
}
|
|
10715
|
+
function resolutionActions(node) {
|
|
10716
|
+
return node.kind == "wait" ? ["continue"] : ["approve", "reject"];
|
|
10717
|
+
}
|
|
10718
|
+
var objectPort = (properties) => ({
|
|
10719
|
+
nullable: false,
|
|
10720
|
+
jsonSchema: {
|
|
10721
|
+
type: "object",
|
|
10722
|
+
properties,
|
|
10723
|
+
required: Object.keys(properties),
|
|
10724
|
+
additionalProperties: false
|
|
10725
|
+
}
|
|
10726
|
+
});
|
|
10727
|
+
function resolutionOutputPorts(node) {
|
|
10728
|
+
const actions = resolutionActions(node);
|
|
10729
|
+
const inputs = {
|
|
10730
|
+
type: "object",
|
|
10731
|
+
properties: Object.fromEntries(node.inputDefinitions.map((port) => [port.handle, {}])),
|
|
10732
|
+
required: node.inputDefinitions.map((port) => port.handle),
|
|
10733
|
+
additionalProperties: false
|
|
10734
|
+
};
|
|
10854
10735
|
return {
|
|
10855
|
-
|
|
10856
|
-
|
|
10857
|
-
|
|
10858
|
-
|
|
10859
|
-
|
|
10860
|
-
|
|
10736
|
+
pending: objectPort({
|
|
10737
|
+
inputs,
|
|
10738
|
+
prompt: { type: "string" },
|
|
10739
|
+
...Object.fromEntries(actions.map((action) => [`${action}Url`, { type: "string" }])),
|
|
10740
|
+
expiresAt: { type: "string" }
|
|
10741
|
+
}),
|
|
10742
|
+
...Object.fromEntries(actions.map((action) => [action, objectPort({
|
|
10743
|
+
inputs,
|
|
10744
|
+
action: { const: action },
|
|
10745
|
+
resolvedAt: { type: "string" },
|
|
10746
|
+
comment: { type: ["string", "null"] }
|
|
10747
|
+
})]))
|
|
10861
10748
|
};
|
|
10862
10749
|
}
|
|
10750
|
+
function nodeOutputPorts(node) {
|
|
10751
|
+
switch (node.kind) {
|
|
10752
|
+
case "condition": return {};
|
|
10753
|
+
case "value": return portsByHandle(node.values);
|
|
10754
|
+
case "task": return portsByHandle(node.task.outputs);
|
|
10755
|
+
case "approval":
|
|
10756
|
+
case "wait": return resolutionOutputPorts(node);
|
|
10757
|
+
case "cron":
|
|
10758
|
+
case "integration":
|
|
10759
|
+
case "poll":
|
|
10760
|
+
case "error":
|
|
10761
|
+
case "manual":
|
|
10762
|
+
case "webhook": return triggerOutputPorts(node);
|
|
10763
|
+
}
|
|
10764
|
+
}
|
|
10863
10765
|
//#endregion
|
|
10864
10766
|
//#region src/control/common/flowInspection.ts
|
|
10865
10767
|
async function inspectFlowDraft(flow, readDraft) {
|
|
@@ -11171,7 +11073,7 @@ var resultQuerySchema = strictObject({
|
|
|
11171
11073
|
});
|
|
11172
11074
|
//#endregion
|
|
11173
11075
|
//#region src/control/common/results.ts
|
|
11174
|
-
var json = json$
|
|
11076
|
+
var json = json$3();
|
|
11175
11077
|
var entry = strictObject({
|
|
11176
11078
|
pointer: string$1(),
|
|
11177
11079
|
type: _enum([
|
|
@@ -11603,142 +11505,6 @@ function variableReferences(input) {
|
|
|
11603
11505
|
};
|
|
11604
11506
|
}
|
|
11605
11507
|
//#endregion
|
|
11606
|
-
//#region src/control/common/publicationDecoders.ts
|
|
11607
|
-
function publication(value) {
|
|
11608
|
-
const source = record(value);
|
|
11609
|
-
const liveEnd = source.liveEnd == null ? void 0 : record(source.liveEnd);
|
|
11610
|
-
if (liveEnd != null && typeof liveEnd.enabled != "boolean") return invalidResponse();
|
|
11611
|
-
const operation = source.operation;
|
|
11612
|
-
const sourcePublicationId = source.sourcePublicationId;
|
|
11613
|
-
if (source.version != 1) return invalidResponse();
|
|
11614
|
-
if (operation != "publish" && operation != "rollback") return invalidResponse();
|
|
11615
|
-
if (sourcePublicationId != null && typeof sourcePublicationId != "string") return invalidResponse();
|
|
11616
|
-
return {
|
|
11617
|
-
...liveEnd == null ? {} : { liveEnd: {
|
|
11618
|
-
enabled: liveEnd.enabled,
|
|
11619
|
-
endedAt: string(liveEnd.endedAt)
|
|
11620
|
-
} },
|
|
11621
|
-
actorId: string(source.actorId),
|
|
11622
|
-
closureDigest: string(source.closureDigest),
|
|
11623
|
-
createdAt: string(source.createdAt),
|
|
11624
|
-
engineContract: string(source.engineContract),
|
|
11625
|
-
flowId: string(source.flowId),
|
|
11626
|
-
modelVersion: integer(source.modelVersion),
|
|
11627
|
-
operation,
|
|
11628
|
-
publicationId: string(source.publicationId),
|
|
11629
|
-
sharedAccessDigest: string(source.sharedAccessDigest),
|
|
11630
|
-
revisionDigest: string(source.revisionDigest),
|
|
11631
|
-
revisionId: string(source.revisionId),
|
|
11632
|
-
...sourcePublicationId == null ? {} : { sourcePublicationId },
|
|
11633
|
-
version: 1
|
|
11634
|
-
};
|
|
11635
|
-
}
|
|
11636
|
-
function publishOperation(value) {
|
|
11637
|
-
const source = record(value);
|
|
11638
|
-
const status = source.status;
|
|
11639
|
-
const common = {
|
|
11640
|
-
createdAt: string(source.createdAt),
|
|
11641
|
-
flowId: string(source.flowId),
|
|
11642
|
-
operationId: string(source.operationId),
|
|
11643
|
-
revisionId: string(source.revisionId),
|
|
11644
|
-
updatedAt: string(source.updatedAt),
|
|
11645
|
-
version: 1
|
|
11646
|
-
};
|
|
11647
|
-
if (source.version != 1) return invalidResponse();
|
|
11648
|
-
switch (status) {
|
|
11649
|
-
case "pending":
|
|
11650
|
-
exact(source, [
|
|
11651
|
-
"createdAt",
|
|
11652
|
-
"flowId",
|
|
11653
|
-
"operationId",
|
|
11654
|
-
"revisionId",
|
|
11655
|
-
"status",
|
|
11656
|
-
"updatedAt",
|
|
11657
|
-
"version"
|
|
11658
|
-
]);
|
|
11659
|
-
return {
|
|
11660
|
-
...common,
|
|
11661
|
-
status
|
|
11662
|
-
};
|
|
11663
|
-
case "succeeded":
|
|
11664
|
-
exact(source, [
|
|
11665
|
-
"createdAt",
|
|
11666
|
-
"flowId",
|
|
11667
|
-
"operationId",
|
|
11668
|
-
"publicationId",
|
|
11669
|
-
"revisionId",
|
|
11670
|
-
"status",
|
|
11671
|
-
"updatedAt",
|
|
11672
|
-
"version"
|
|
11673
|
-
]);
|
|
11674
|
-
return {
|
|
11675
|
-
...common,
|
|
11676
|
-
publicationId: string(source.publicationId),
|
|
11677
|
-
status
|
|
11678
|
-
};
|
|
11679
|
-
case "failed": {
|
|
11680
|
-
exact(source, [
|
|
11681
|
-
"createdAt",
|
|
11682
|
-
"flowId",
|
|
11683
|
-
"issue",
|
|
11684
|
-
"operationId",
|
|
11685
|
-
"revisionId",
|
|
11686
|
-
"status",
|
|
11687
|
-
"updatedAt",
|
|
11688
|
-
"version"
|
|
11689
|
-
]);
|
|
11690
|
-
const issue = record(source.issue);
|
|
11691
|
-
const nodeId = issue.nodeId;
|
|
11692
|
-
exact(issue, [
|
|
11693
|
-
"code",
|
|
11694
|
-
"message",
|
|
11695
|
-
...nodeId == null ? [] : ["nodeId"]
|
|
11696
|
-
]);
|
|
11697
|
-
return {
|
|
11698
|
-
...common,
|
|
11699
|
-
issue: {
|
|
11700
|
-
code: string(issue.code),
|
|
11701
|
-
message: string(issue.message),
|
|
11702
|
-
...nodeId == null ? {} : { nodeId: string(nodeId) }
|
|
11703
|
-
},
|
|
11704
|
-
status
|
|
11705
|
-
};
|
|
11706
|
-
}
|
|
11707
|
-
default: return invalidResponse();
|
|
11708
|
-
}
|
|
11709
|
-
}
|
|
11710
|
-
function live(value) {
|
|
11711
|
-
const source = record(value);
|
|
11712
|
-
const status = source.status;
|
|
11713
|
-
const candidate = source.publication;
|
|
11714
|
-
if (source.version != 1 || typeof source.hasUnpublishedChanges != "boolean") return invalidResponse();
|
|
11715
|
-
if (status != "not-published" && status != "runnable" && status != "suspended") return invalidResponse();
|
|
11716
|
-
if (status == "not-published" && candidate !== null) return invalidResponse();
|
|
11717
|
-
if (status != "not-published" && candidate === null) return invalidResponse();
|
|
11718
|
-
return {
|
|
11719
|
-
flowId: string(source.flowId),
|
|
11720
|
-
hasUnpublishedChanges: source.hasUnpublishedChanges,
|
|
11721
|
-
publication: candidate === null ? null : publication(candidate),
|
|
11722
|
-
revision: integer(source.revision),
|
|
11723
|
-
status,
|
|
11724
|
-
version: 1
|
|
11725
|
-
};
|
|
11726
|
-
}
|
|
11727
|
-
function publicationPage(value) {
|
|
11728
|
-
const source = record(value);
|
|
11729
|
-
const nextCursor = source.nextCursor;
|
|
11730
|
-
const total = source.total;
|
|
11731
|
-
if (source.version != 1 || !Array.isArray(source.publications)) return invalidResponse();
|
|
11732
|
-
if (nextCursor != null && typeof nextCursor != "string") return invalidResponse();
|
|
11733
|
-
if (total != null && !Number.isSafeInteger(total)) return invalidResponse();
|
|
11734
|
-
return {
|
|
11735
|
-
...nextCursor == null ? {} : { nextCursor },
|
|
11736
|
-
publications: source.publications.map(publication),
|
|
11737
|
-
...total == null ? {} : { total },
|
|
11738
|
-
version: 1
|
|
11739
|
-
};
|
|
11740
|
-
}
|
|
11741
|
-
//#endregion
|
|
11742
11508
|
//#region src/control/common/revisionDecoders.ts
|
|
11743
11509
|
function revisionMetadata(value) {
|
|
11744
11510
|
const source = record(value);
|
|
@@ -12327,6 +12093,26 @@ var ControlClient = class {
|
|
|
12327
12093
|
exact(source, ["version"]);
|
|
12328
12094
|
if (source.version != 1) return invalidResponse();
|
|
12329
12095
|
}
|
|
12096
|
+
async exportFlow(flowId) {
|
|
12097
|
+
const value = await this.request(`/v1/flows/${segment(flowId)}/export`);
|
|
12098
|
+
try {
|
|
12099
|
+
return decodeWorkflowFile(value);
|
|
12100
|
+
} catch {
|
|
12101
|
+
return invalidResponse();
|
|
12102
|
+
}
|
|
12103
|
+
}
|
|
12104
|
+
async importFlow(file, options = {}) {
|
|
12105
|
+
return flow(await this.request("/v1/flows/import", {
|
|
12106
|
+
method: "POST",
|
|
12107
|
+
headers: { "Idempotency-Key": options.idempotencyKey ?? `flow-${randomId()}` },
|
|
12108
|
+
body: JSON.stringify({
|
|
12109
|
+
file,
|
|
12110
|
+
name: options.name,
|
|
12111
|
+
teamId: options.teamId,
|
|
12112
|
+
version: 1
|
|
12113
|
+
})
|
|
12114
|
+
}));
|
|
12115
|
+
}
|
|
12330
12116
|
async createFlow(name, idempotencyKey = `flow-${randomId()}`, teamId) {
|
|
12331
12117
|
return flow(await this.request("/v1/flows", {
|
|
12332
12118
|
body: JSON.stringify({
|
|
@@ -12680,21 +12466,14 @@ var ControlClient = class {
|
|
|
12680
12466
|
method: "POST"
|
|
12681
12467
|
}));
|
|
12682
12468
|
}
|
|
12469
|
+
async getLiveDetails(flowId, signal) {
|
|
12470
|
+
const details = decodeLiveDetails(await this.request(`/v1/flows/${segment(flowId)}/live/details`, { signal }));
|
|
12471
|
+
if (details.flowId != flowId) return invalidResponse();
|
|
12472
|
+
return details;
|
|
12473
|
+
}
|
|
12683
12474
|
async getLive(flowId, signal) {
|
|
12684
12475
|
return live(await this.request(`/v1/flows/${segment(flowId)}/live`, { signal }));
|
|
12685
12476
|
}
|
|
12686
|
-
async listPublicationResources(flowId, publicationId) {
|
|
12687
|
-
const query = publicationId == null ? "" : `?publicationId=${encodeURIComponent(publicationId)}`;
|
|
12688
|
-
const result = decodePublicationResources(await this.request(`/v1/flows/${segment(flowId)}/resources${query}`));
|
|
12689
|
-
if (result.flowId != flowId || publicationId != null && result.publicationId != publicationId) return invalidResponse();
|
|
12690
|
-
return result;
|
|
12691
|
-
}
|
|
12692
|
-
async getPublicationResource(flowId, resourceId, publicationId) {
|
|
12693
|
-
const query = publicationId == null ? "" : `?publicationId=${encodeURIComponent(publicationId)}`;
|
|
12694
|
-
const result = decodePublicationResource(await this.request(`/v1/flows/${segment(flowId)}/resources/${segment(resourceId)}${query}`));
|
|
12695
|
-
if (result.flowId != flowId || result.resource.resourceId != resourceId || publicationId != null && result.publicationId != publicationId) return invalidResponse();
|
|
12696
|
-
return result;
|
|
12697
|
-
}
|
|
12698
12477
|
async listPublications(flowId, options = {}, signal) {
|
|
12699
12478
|
const parameters = new URLSearchParams();
|
|
12700
12479
|
if (options.cursor != null) parameters.set("cursor", options.cursor);
|
|
@@ -12858,4 +12637,4 @@ var ControlClient = class {
|
|
|
12858
12637
|
}
|
|
12859
12638
|
};
|
|
12860
12639
|
//#endregion
|
|
12861
|
-
export { ApiError, ControlClient, actionSummary, controlErrorCode, controlErrorMetadata, connectorAccess as decodeConnectorAccess, connectorAccessSnapshot as decodeConnectorAccessSnapshot, decodeEventSource, decodeEventSources, decodeResultList, decodeResultRead, decodeRunEvent, decodeTriggerCatalog, flowInspection, inspectFlowDraft, isRunTerminalEvent, nodeDetails, parseProviderAccessSource, parseResultQuery, providerAccessBindingId, providerIconAppearance,
|
|
12640
|
+
export { ApiError, ControlClient, actionSummary, controlErrorCode, controlErrorMetadata, connectorAccess as decodeConnectorAccess, connectorAccessSnapshot as decodeConnectorAccessSnapshot, decodeEventSource, decodeEventSources, decodeResultList, decodeResultRead, decodeRunEvent, decodeTriggerCatalog, flowInspection, inspectFlowDraft, isRunTerminalEvent, liveEntries, nodeDetails, parseProviderAccessSource, parseResultQuery, providerAccessBindingId, providerIconAppearance, readResult, searchTriggerKeys };
|