@oomol-lab/open-flow 0.1.0-alpha.0
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/LICENSE +201 -0
- package/NOTICE +47 -0
- package/README.md +18 -0
- package/dist/browser/_virtual_open-flow-twemoji-DJwKsM_w.js +5067 -0
- package/dist/browser/addNodeOptions-DqoIueCR.js +33746 -0
- package/dist/browser/assets/font-00b26ac825e20950.woff2 +0 -0
- package/dist/browser/assets/font-036d4e95149b69ff.woff2 +0 -0
- package/dist/browser/assets/font-07d8e303ce4fc12b.ttf +0 -0
- package/dist/browser/assets/font-08ce98e51b04d589.ttf +0 -0
- package/dist/browser/assets/font-0cdd387c9590a1a9.woff2 +0 -0
- package/dist/browser/assets/font-0d85ae7cc30f2379.ttf +0 -0
- package/dist/browser/assets/font-0f60d1b897938ec9.woff2 +0 -0
- package/dist/browser/assets/font-11e4dc8a6471ff6d.woff +0 -0
- package/dist/browser/assets/font-138ac28d1663b303.ttf +0 -0
- package/dist/browser/assets/font-1ae6bd7475590e97.woff +0 -0
- package/dist/browser/assets/font-1c67f068fea8bb09.ttf +0 -0
- package/dist/browser/assets/font-1e6f9579e90e2cac.ttf +0 -0
- package/dist/browser/assets/font-1ece03f79f95277d.ttf +0 -0
- package/dist/browser/assets/font-2014c523c3210bcc.woff +0 -0
- package/dist/browser/assets/font-30da91e84c893f87.woff +0 -0
- package/dist/browser/assets/font-3398dd02302557a7.woff +0 -0
- package/dist/browser/assets/font-3931dd81faed86ba.ttf +0 -0
- package/dist/browser/assets/font-500e04d54f0d5166.ttf +0 -0
- package/dist/browser/assets/font-51814d270d06ff02.woff2 +0 -0
- package/dist/browser/assets/font-5d53e70ad607c235.woff2 +0 -0
- package/dist/browser/assets/font-5e28753be717dac9.woff +0 -0
- package/dist/browser/assets/font-68534840bcfdd2bf.ttf +0 -0
- package/dist/browser/assets/font-68e8c73ef42afd3c.woff2 +0 -0
- package/dist/browser/assets/font-6ab6b62e9b62dae2.woff +0 -0
- package/dist/browser/assets/font-6b47c40166b6dbe2.woff2 +0 -0
- package/dist/browser/assets/font-70ee1f64a20f2048.ttf +0 -0
- package/dist/browser/assets/font-71d517d67827787c.woff2 +0 -0
- package/dist/browser/assets/font-73d591271b160496.woff2 +0 -0
- package/dist/browser/assets/font-74444efd593c005e.woff2 +0 -0
- package/dist/browser/assets/font-7af58c5ec8f132a2.woff2 +0 -0
- package/dist/browser/assets/font-850c0af5c2238497.woff +0 -0
- package/dist/browser/assets/font-8a8d244581371912.woff +0 -0
- package/dist/browser/assets/font-9163df9c7122432e.ttf +0 -0
- package/dist/browser/assets/font-91ee67500cc0129a.woff +0 -0
- package/dist/browser/assets/font-95b6d2f1a50173bf.ttf +0 -0
- package/dist/browser/assets/font-97479ca6cce906ab.woff2 +0 -0
- package/dist/browser/assets/font-99cd42a3c072d918.woff2 +0 -0
- package/dist/browser/assets/font-99f9c6750b489c94.woff +0 -0
- package/dist/browser/assets/font-9be7ceb88004ab8a.woff +0 -0
- package/dist/browser/assets/font-a4af7d414440a1c1.woff2 +0 -0
- package/dist/browser/assets/font-a6b2099fb555c60e.ttf +0 -0
- package/dist/browser/assets/font-a6f7ec0d846ac7ad.woff +0 -0
- package/dist/browser/assets/font-c2342cd8b869e017.woff2 +0 -0
- package/dist/browser/assets/font-c6368d87e8a1a3a5.woff +0 -0
- package/dist/browser/assets/font-c647367d1dd4e162.ttf +0 -0
- package/dist/browser/assets/font-c76c5d696297d51b.woff +0 -0
- package/dist/browser/assets/font-c943cc986384f59e.woff +0 -0
- package/dist/browser/assets/font-d0332f52868370fd.ttf +0 -0
- package/dist/browser/assets/font-d04c54219f9eaec6.woff2 +0 -0
- package/dist/browser/assets/font-d96cdf2b3bdd4d64.woff +0 -0
- package/dist/browser/assets/font-dc47344dbb6cb5b6.woff2 +0 -0
- package/dist/browser/assets/font-de7701e42cf1f4cf.woff2 +0 -0
- package/dist/browser/assets/font-e14fed02b1aba7ce.woff +0 -0
- package/dist/browser/assets/font-e99ae51144bf1232.woff2 +0 -0
- package/dist/browser/assets/font-ece03cfd83e22c21.woff +0 -0
- package/dist/browser/assets/font-ed0b74372feefcbb.ttf +0 -0
- package/dist/browser/assets/font-f01f3e87d9c6a61c.ttf +0 -0
- package/dist/browser/assets/font-f1d6ef86f3b11a52.woff +0 -0
- package/dist/browser/assets/font-f36ea897e19f4a2e.ttf +0 -0
- package/dist/browser/assets/font-f9377ab0271cda59.ttf +0 -0
- package/dist/browser/carbon-nMY84Amv.js +53 -0
- package/dist/browser/composite-7VwgfnXx.js +6088 -0
- package/dist/browser/createResourceDialog-ByuJWdSL.js +439 -0
- package/dist/browser/dist-7oZK9QXZ.js +50088 -0
- package/dist/browser/dist-B9OV3YTx.js +881 -0
- package/dist/browser/dist-BLk5M0uK.js +1816 -0
- package/dist/browser/dist-BbyiRq3c.js +3285 -0
- package/dist/browser/dist-CIq6ue3I.js +6646 -0
- package/dist/browser/dist-CLZJNoWB.js +89 -0
- package/dist/browser/dist-CvcmLAMW.js +1620 -0
- package/dist/browser/dist-DL0SDskM.js +2327 -0
- package/dist/browser/dist-Djd02JSy.js +1247 -0
- package/dist/browser/dist-aWSZx4q1.js +850 -0
- package/dist/browser/dist-n-z5HtaO.js +4 -0
- package/dist/browser/dist-o4dBuwiG.js +320 -0
- package/dist/browser/dist-zyY--HOV.js +1543 -0
- package/dist/browser/esm-DXw7EADW.js +218 -0
- package/dist/browser/favicon.svg +7 -0
- package/dist/browser/flowWorkspace-DwVMpcar.js +22092 -0
- package/dist/browser/lib-S4ccuMeT.js +7857 -0
- package/dist/browser/licenses.md +4973 -0
- package/dist/browser/markdownContent-ZZFfSRqO.js +44545 -0
- package/dist/browser/project-change.d.ts +311 -0
- package/dist/browser/project-change.js +259 -0
- package/dist/browser/project-notifications.d.ts +12 -0
- package/dist/browser/rolldown-runtime-CEFd7nDs.js +30 -0
- package/dist/browser/workbench-contract.d.ts +28 -0
- package/dist/browser/workbench.css +2 -0
- package/dist/browser/workbench.css.d.ts +1 -0
- package/dist/browser/workbench.d.ts +14 -0
- package/dist/browser/workbench.js +3364 -0
- package/dist/common/connector-action.d.ts +20 -0
- package/dist/common/connector-action.js +106 -0
- package/dist/common/connector-proxy.d.ts +14 -0
- package/dist/common/connector-proxy.js +0 -0
- package/dist/common/control-api-conformance.d.ts +13 -0
- package/dist/common/control-api-conformance.js +518 -0
- package/dist/common/control-api-errors.d.ts +121 -0
- package/dist/common/control-api.d.ts +349 -0
- package/dist/common/control-api.js +884 -0
- package/dist/common/cron-trigger.d.ts +21 -0
- package/dist/common/cron-trigger.js +834 -0
- package/dist/common/engine-contract.d.ts +7 -0
- package/dist/common/favicon.svg +7 -0
- package/dist/common/integration-trigger.d.ts +111 -0
- package/dist/common/integration-trigger.js +290 -0
- package/dist/common/licenses.md +27 -0
- package/dist/common/poll-trigger.d.ts +69 -0
- package/dist/common/poll-trigger.js +155 -0
- package/dist/common/project-encoding.d.ts +11 -0
- package/dist/common/project-encoding.js +242 -0
- package/dist/common/project-notifications.d.ts +12 -0
- package/dist/common/project-semantics.d.ts +55 -0
- package/dist/common/project-semantics.js +8687 -0
- package/dist/common/provider-triggers.d.ts +6 -0
- package/dist/common/provider-triggers.js +4614 -0
- package/dist/common/run-events.d.ts +9 -0
- package/dist/common/run-events.js +192 -0
- package/dist/common/run-lifecycle.d.ts +69 -0
- package/dist/common/run-lifecycle.js +169 -0
- package/dist/common/runtime-contract.d.ts +53 -0
- package/dist/common/runtime-contract.js +151 -0
- package/dist/common/scheduler.d.ts +99 -0
- package/dist/common/scheduler.js +379 -0
- package/dist/common/webhook-trigger.d.ts +22 -0
- package/dist/common/webhook-trigger.js +270 -0
- package/dist/index.d.ts +66 -0
- package/package.json +102 -0
|
@@ -0,0 +1,3364 @@
|
|
|
1
|
+
import { Gr as e, Ur as t, Zr as n, li as r, ni as i, ri as a } from "./composite-7VwgfnXx.js";
|
|
2
|
+
import { $i as o, Qi as s, _ as c, _a as l, a as u, c as d, d as f, ea as p, f as m, i as h, l as g, m as _, n as ee, o as v, p as y, ra as b, t as te, ta as ne, u as x, va as re, ya as S } from "./addNodeOptions-DqoIueCR.js";
|
|
3
|
+
import { Suspense as ie, lazy as ae, useEffect as C, useRef as oe, useState as se } from "react";
|
|
4
|
+
import { jsx as w, jsxs as ce } from "react/jsx-runtime";
|
|
5
|
+
//#region src/workbench/browser/runtime/navigation.ts
|
|
6
|
+
function le(e, t) {
|
|
7
|
+
return t == null ? "design" : e == "design" && t?.draft == null && t != null ? "publications" : e;
|
|
8
|
+
}
|
|
9
|
+
var ue = class {
|
|
10
|
+
#e;
|
|
11
|
+
#t;
|
|
12
|
+
#n;
|
|
13
|
+
#r;
|
|
14
|
+
#i;
|
|
15
|
+
#a;
|
|
16
|
+
#o;
|
|
17
|
+
#s;
|
|
18
|
+
#c;
|
|
19
|
+
constructor(e, t, n) {
|
|
20
|
+
this.#r = r("design"), this.#i = 0, this.#a = !1, this.#o = !1, this.#s = !1, this.#c = [], this.$ = { view: this.#r }, this.#l = () => {
|
|
21
|
+
this.#o && !this.#s && this.#d(this.#r.value, !0);
|
|
22
|
+
}, this.#t = t, this.#e = n, this.#n = e, this.#r.set(t.view);
|
|
23
|
+
}
|
|
24
|
+
async start() {
|
|
25
|
+
let e = this.#t, t = ++this.#i;
|
|
26
|
+
this.#s = !0, this.#c.push(this.#n.workspace.$.projectId.reaction(this.#l), this.#n.workspace.$.targetFlow.reaction(this.#l)), await this.#n.start(e.projectId, e.flowId), !(this.#a || t != this.#i) && (this.#d(e.view, !0), this.#s = !1, this.#o = !0);
|
|
27
|
+
}
|
|
28
|
+
dispose() {
|
|
29
|
+
this.#a = !0;
|
|
30
|
+
for (let e of this.#c) e();
|
|
31
|
+
this.#r.dispose();
|
|
32
|
+
}
|
|
33
|
+
open(e) {
|
|
34
|
+
this.#i += 1, this.#s = !1, this.#d(e, !1);
|
|
35
|
+
}
|
|
36
|
+
async createProject(e) {
|
|
37
|
+
let t = ++this.#i;
|
|
38
|
+
this.#s = !0;
|
|
39
|
+
try {
|
|
40
|
+
let n = await this.#n.createProject(e);
|
|
41
|
+
return n && t == this.#i && this.#d("design", !1), n;
|
|
42
|
+
} finally {
|
|
43
|
+
t == this.#i && (this.#s = !1);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async createFlow(e) {
|
|
47
|
+
let t = ++this.#i;
|
|
48
|
+
this.#s = !0;
|
|
49
|
+
try {
|
|
50
|
+
let n = await this.#n.workspace.createResource("flow", e);
|
|
51
|
+
return n && t == this.#i && this.#d("design", !1), n;
|
|
52
|
+
} finally {
|
|
53
|
+
t == this.#i && (this.#s = !1);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
selectFlow(e) {
|
|
57
|
+
if (this.#i += 1, this.#s = !0, !this.#n.workspace.selectTarget({
|
|
58
|
+
id: e.flowId,
|
|
59
|
+
kind: "flow"
|
|
60
|
+
})) {
|
|
61
|
+
this.#s = !1;
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this.#n.runRequests.dismissInputs(), this.#d(e.draft == null ? "publications" : "design", !1), this.#s = !1;
|
|
65
|
+
}
|
|
66
|
+
async selectProject(e) {
|
|
67
|
+
let t = ++this.#i;
|
|
68
|
+
this.#s = !0;
|
|
69
|
+
let n = this.#n.selectProject(e);
|
|
70
|
+
this.#d("design", !1);
|
|
71
|
+
try {
|
|
72
|
+
await n;
|
|
73
|
+
} finally {
|
|
74
|
+
t == this.#i && (this.#s = !1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
openProject() {
|
|
78
|
+
if (this.#i += 1, this.#s = !0, !this.#n.workspace.selectTarget(void 0)) {
|
|
79
|
+
this.#s = !1;
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
this.#n.runRequests.dismissInputs(), this.#d("design", !1), this.#s = !1;
|
|
83
|
+
}
|
|
84
|
+
async openProjects() {
|
|
85
|
+
let e = ++this.#i;
|
|
86
|
+
this.#s = !0;
|
|
87
|
+
let t = this.#n.start();
|
|
88
|
+
this.#d("design", !1);
|
|
89
|
+
try {
|
|
90
|
+
await t;
|
|
91
|
+
} finally {
|
|
92
|
+
e == this.#i && (this.#s = !1);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async apply(e) {
|
|
96
|
+
de(e, this.#t) || (this.#t = e, await this.#u(e));
|
|
97
|
+
}
|
|
98
|
+
#l;
|
|
99
|
+
async #u(e) {
|
|
100
|
+
let t = ++this.#i;
|
|
101
|
+
this.#s = !0;
|
|
102
|
+
try {
|
|
103
|
+
if (e.projectId == null) await this.#n.start();
|
|
104
|
+
else if (e.projectId != this.#n.workspace.$.projectId.value) await this.#n.selectProject(e.projectId, e.flowId);
|
|
105
|
+
else if (e.flowId == null) this.#n.workspace.selectTarget(void 0);
|
|
106
|
+
else if (e.flowId != null && e.flowId != this.#n.workspace.$.targetFlow.value?.flowId) {
|
|
107
|
+
let t = this.#n.workspace.$.flows.value.find((t) => t.flowId == e.flowId);
|
|
108
|
+
this.#n.workspace.selectTarget(t == null ? void 0 : {
|
|
109
|
+
id: t.flowId,
|
|
110
|
+
kind: "flow"
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
t == this.#i && this.#d(e.view, !0);
|
|
114
|
+
} finally {
|
|
115
|
+
t == this.#i && (this.#s = !1, this.#o = !0);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
#d(e, t) {
|
|
119
|
+
let n = this.#n.workspace.$.targetFlow.value, r = le(e, n), i = {
|
|
120
|
+
flowId: n?.flowId,
|
|
121
|
+
projectId: this.#n.workspace.$.projectId.value,
|
|
122
|
+
view: r
|
|
123
|
+
};
|
|
124
|
+
de(i, this.#t) || (this.#t = i, this.#e(i, { replace: t })), this.#r.set(r);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
function de(e, t) {
|
|
128
|
+
return e.projectId == t.projectId && e.flowId == t.flowId && e.view == t.view;
|
|
129
|
+
}
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/workbench/browser/runtime/publications/publicationStore.ts
|
|
132
|
+
var T = {
|
|
133
|
+
activities: [],
|
|
134
|
+
activitiesLoadFailed: !1,
|
|
135
|
+
activitiesLoading: !1,
|
|
136
|
+
activitiesLoadingMore: !1,
|
|
137
|
+
bindings: [],
|
|
138
|
+
detailLoading: !1,
|
|
139
|
+
loadFailed: !1,
|
|
140
|
+
loading: !1,
|
|
141
|
+
loadMoreFailed: !1,
|
|
142
|
+
loadingMore: !1,
|
|
143
|
+
publications: [],
|
|
144
|
+
publishing: !1
|
|
145
|
+
}, fe = 20, E = 50;
|
|
146
|
+
function D(e, t) {
|
|
147
|
+
return e?.projectId == t.projectId && e.flowId == t.flowId;
|
|
148
|
+
}
|
|
149
|
+
var pe = class {
|
|
150
|
+
#e;
|
|
151
|
+
#t;
|
|
152
|
+
#n;
|
|
153
|
+
#r = new p();
|
|
154
|
+
#i = new p();
|
|
155
|
+
#a = new p();
|
|
156
|
+
#o = new p();
|
|
157
|
+
#s;
|
|
158
|
+
#c = r(T);
|
|
159
|
+
#l;
|
|
160
|
+
#u;
|
|
161
|
+
constructor(e, t, n, r = () => crypto.randomUUID(), i = l()) {
|
|
162
|
+
this.#e = e, this.#t = r, this.#n = i, this.#s = n, this.#l = t, this.$ = {
|
|
163
|
+
activities: a(this.#c, (e) => e.activities),
|
|
164
|
+
activitiesLoadFailed: a(this.#c, (e) => e.activitiesLoadFailed),
|
|
165
|
+
activitiesLoading: a(this.#c, (e) => e.activitiesLoading),
|
|
166
|
+
activitiesLoadingMore: a(this.#c, (e) => e.activitiesLoadingMore),
|
|
167
|
+
activitiesNextCursor: a(this.#c, (e) => e.activitiesNextCursor),
|
|
168
|
+
bindings: a(this.#c, (e) => e.bindings),
|
|
169
|
+
changingTriggerId: a(this.#c, (e) => e.changingTriggerId),
|
|
170
|
+
detail: a(this.#c, (e) => e.detail),
|
|
171
|
+
detailLoading: a(this.#c, (e) => e.detailLoading),
|
|
172
|
+
live: a(this.#c, (e) => e.live),
|
|
173
|
+
loadFailed: a(this.#c, (e) => e.loadFailed),
|
|
174
|
+
loading: a(this.#c, (e) => e.loading),
|
|
175
|
+
loadMoreFailed: a(this.#c, (e) => e.loadMoreFailed),
|
|
176
|
+
loadingMore: a(this.#c, (e) => e.loadingMore),
|
|
177
|
+
nextCursor: a(this.#c, (e) => e.nextCursor),
|
|
178
|
+
publications: a(this.#c, (e) => e.publications),
|
|
179
|
+
publishing: a(this.#c, (e) => e.publishing),
|
|
180
|
+
rollingBackPublicationId: a(this.#c, (e) => e.rollingBackPublicationId),
|
|
181
|
+
selectedTriggerId: a(this.#c, (e) => e.selectedTriggerId),
|
|
182
|
+
testingTriggerId: a(this.#c, (e) => e.testingTriggerId),
|
|
183
|
+
testResult: a(this.#c, (e) => e.testResult),
|
|
184
|
+
total: a(this.#c, (e) => e.total)
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
dispose() {
|
|
188
|
+
this.#r.invalidate(), this.#i.invalidate(), this.#a.invalidate(), this.#o.invalidate();
|
|
189
|
+
for (let e of Object.values(this.$)) e.dispose();
|
|
190
|
+
this.#c.dispose();
|
|
191
|
+
}
|
|
192
|
+
reset() {
|
|
193
|
+
this.#r.invalidate(), this.#i.invalidate(), this.#a.invalidate(), this.#o.invalidate(), this.#u = void 0, this.#c.set(T);
|
|
194
|
+
}
|
|
195
|
+
async load(e, t) {
|
|
196
|
+
let n = {
|
|
197
|
+
flowId: t,
|
|
198
|
+
projectId: e
|
|
199
|
+
}, r = this.#r.begin();
|
|
200
|
+
D(this.#c.value.target, n) || (this.#u = void 0), this.#s(void 0), this.#c.set({
|
|
201
|
+
...T,
|
|
202
|
+
loading: !0,
|
|
203
|
+
target: n
|
|
204
|
+
});
|
|
205
|
+
try {
|
|
206
|
+
let [e, t, i] = await this.#p(n);
|
|
207
|
+
if (!r()) return;
|
|
208
|
+
this.#h({
|
|
209
|
+
bindings: i,
|
|
210
|
+
live: e,
|
|
211
|
+
loading: !1,
|
|
212
|
+
nextCursor: t.nextCursor,
|
|
213
|
+
publications: t.publications,
|
|
214
|
+
total: t.total
|
|
215
|
+
});
|
|
216
|
+
} catch (e) {
|
|
217
|
+
if (!r()) return;
|
|
218
|
+
this.#h({
|
|
219
|
+
loadFailed: !0,
|
|
220
|
+
loading: !1
|
|
221
|
+
}), this.#s(o(e, this.#n.t));
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
async loadMore() {
|
|
225
|
+
let { loadingMore: e, nextCursor: t, target: n } = this.#c.value;
|
|
226
|
+
if (e || t == null || n == null) return;
|
|
227
|
+
let r = this.#r.capture();
|
|
228
|
+
this.#h({
|
|
229
|
+
loadMoreFailed: !1,
|
|
230
|
+
loadingMore: !0
|
|
231
|
+
});
|
|
232
|
+
try {
|
|
233
|
+
let e = await this.#e.listPublications(n.projectId, n.flowId, {
|
|
234
|
+
cursor: t,
|
|
235
|
+
limit: E
|
|
236
|
+
});
|
|
237
|
+
if (!r()) return;
|
|
238
|
+
let i = new Set(this.#c.value.publications.map((e) => e.publicationId));
|
|
239
|
+
this.#h({
|
|
240
|
+
loadingMore: !1,
|
|
241
|
+
loadMoreFailed: !1,
|
|
242
|
+
nextCursor: e.nextCursor,
|
|
243
|
+
publications: [...this.#c.value.publications, ...e.publications.filter((e) => !i.has(e.publicationId))]
|
|
244
|
+
});
|
|
245
|
+
} catch (e) {
|
|
246
|
+
if (!r()) return;
|
|
247
|
+
this.#h({
|
|
248
|
+
loadMoreFailed: !0,
|
|
249
|
+
loadingMore: !1
|
|
250
|
+
}), this.#s(o(e, this.#n.t));
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
async publish() {
|
|
254
|
+
let e = this.#l.$.projectId.value, t = this.#l.$.targetFlow.value;
|
|
255
|
+
if (e == null || t?.draft == null || this.#c.value.changingTriggerId != null || this.#c.value.publishing || this.#c.value.rollingBackPublicationId != null) return !1;
|
|
256
|
+
let n = {
|
|
257
|
+
flowId: t.flowId,
|
|
258
|
+
projectId: e
|
|
259
|
+
}, r = t.live?.publication.publicationId ?? null, i = JSON.stringify({
|
|
260
|
+
expectedLivePublicationId: r,
|
|
261
|
+
flowId: t.flowId,
|
|
262
|
+
kind: "publish",
|
|
263
|
+
projectId: e,
|
|
264
|
+
revisionId: t.draft.revisionId
|
|
265
|
+
}), a = this.#u?.signature == i ? this.#u : {
|
|
266
|
+
key: this.#t(),
|
|
267
|
+
signature: i
|
|
268
|
+
}, s = this.#i.begin();
|
|
269
|
+
this.#u = a, this.#s(void 0), this.#m(n, { publishing: !0 });
|
|
270
|
+
try {
|
|
271
|
+
return await this.#e.publishFlow(e, t.draft.revisionId, t.flowId, r, { idempotencyKey: a.key }), !s() || (await this.#d(n), !s()) ? !1 : (this.#u = void 0, this.#s({
|
|
272
|
+
kind: "success",
|
|
273
|
+
message: this.#n.t("notice.published", { name: t.draft.name })
|
|
274
|
+
}), !0);
|
|
275
|
+
} catch (e) {
|
|
276
|
+
return s() ? (e instanceof S && e.code == "live.conflict" && await this.#f(n), this.#s(o(e, this.#n.t)), !1) : !1;
|
|
277
|
+
} finally {
|
|
278
|
+
s() && this.#h({ publishing: !1 });
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
async rollback(e) {
|
|
282
|
+
let { live: t, rollingBackPublicationId: n, target: r } = this.#c.value, i = t?.publication?.publicationId;
|
|
283
|
+
if (r == null || i == null || this.#c.value.changingTriggerId != null || n != null || this.#c.value.publishing || e.projectId != r.projectId || e.flowId != r.flowId) return !1;
|
|
284
|
+
let a = JSON.stringify({
|
|
285
|
+
currentPublicationId: i,
|
|
286
|
+
flowId: r.flowId,
|
|
287
|
+
kind: "rollback",
|
|
288
|
+
projectId: r.projectId,
|
|
289
|
+
targetPublicationId: e.publicationId
|
|
290
|
+
}), s = this.#u?.signature == a ? this.#u : {
|
|
291
|
+
key: this.#t(),
|
|
292
|
+
signature: a
|
|
293
|
+
}, c = this.#i.begin();
|
|
294
|
+
this.#u = s, this.#s(void 0), this.#h({ rollingBackPublicationId: e.publicationId });
|
|
295
|
+
try {
|
|
296
|
+
return await this.#e.rollbackFlow(r.projectId, r.flowId, e.publicationId, i, { idempotencyKey: s.key }), !c() || (await this.#d(r), !c()) ? !1 : (this.#u = void 0, this.#s({
|
|
297
|
+
kind: "success",
|
|
298
|
+
message: this.#n.t("notice.rolledBack", { revision: e.revisionId })
|
|
299
|
+
}), !0);
|
|
300
|
+
} catch (e) {
|
|
301
|
+
return c() ? (e instanceof S && e.code == "live.conflict" && await this.#f(r), this.#s(o(e, this.#n.t)), !1) : !1;
|
|
302
|
+
} finally {
|
|
303
|
+
c() && this.#h({ rollingBackPublicationId: void 0 });
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
closeTrigger() {
|
|
307
|
+
this.#a.invalidate(), this.#o.invalidate(), this.#h({
|
|
308
|
+
activities: [],
|
|
309
|
+
activitiesLoadFailed: !1,
|
|
310
|
+
activitiesLoading: !1,
|
|
311
|
+
activitiesLoadingMore: !1,
|
|
312
|
+
activitiesNextCursor: void 0,
|
|
313
|
+
detail: void 0,
|
|
314
|
+
detailLoading: !1,
|
|
315
|
+
selectedTriggerId: void 0,
|
|
316
|
+
testingTriggerId: void 0,
|
|
317
|
+
testResult: void 0
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
async openTrigger(e) {
|
|
321
|
+
let t = this.#c.value.target;
|
|
322
|
+
if (t == null) return;
|
|
323
|
+
let n = this.#a.begin();
|
|
324
|
+
this.#o.invalidate(), this.#h({
|
|
325
|
+
activities: [],
|
|
326
|
+
activitiesLoadFailed: !1,
|
|
327
|
+
activitiesLoading: !0,
|
|
328
|
+
activitiesLoadingMore: !1,
|
|
329
|
+
activitiesNextCursor: void 0,
|
|
330
|
+
detail: void 0,
|
|
331
|
+
detailLoading: !0,
|
|
332
|
+
selectedTriggerId: e,
|
|
333
|
+
testingTriggerId: void 0,
|
|
334
|
+
testResult: void 0
|
|
335
|
+
});
|
|
336
|
+
let [r, i] = await Promise.allSettled([this.#e.getFlowTriggerBinding(t.projectId, t.flowId, e), this.#e.listFlowTriggerActivities(t.projectId, t.flowId, e, { limit: fe })]);
|
|
337
|
+
if (n()) {
|
|
338
|
+
if (r.status == "rejected") {
|
|
339
|
+
this.#h({
|
|
340
|
+
activitiesLoading: !1,
|
|
341
|
+
detailLoading: !1
|
|
342
|
+
}), this.#s(o(r.reason, this.#n.t));
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
this.#h({
|
|
346
|
+
detail: r.value,
|
|
347
|
+
detailLoading: !1
|
|
348
|
+
}), i.status == "fulfilled" ? this.#h({
|
|
349
|
+
activities: i.value.activities,
|
|
350
|
+
activitiesLoadFailed: !1,
|
|
351
|
+
activitiesLoading: !1,
|
|
352
|
+
activitiesNextCursor: i.value.nextCursor
|
|
353
|
+
}) : (this.#h({
|
|
354
|
+
activitiesLoadFailed: !0,
|
|
355
|
+
activitiesLoading: !1
|
|
356
|
+
}), this.#s(o(i.reason, this.#n.t)));
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
async loadMoreTriggerActivities() {
|
|
360
|
+
let { activitiesLoadingMore: e, activitiesNextCursor: t, selectedTriggerId: n, target: r } = this.#c.value;
|
|
361
|
+
if (e || t == null || n == null || r == null) return;
|
|
362
|
+
let i = this.#a.capture();
|
|
363
|
+
this.#h({
|
|
364
|
+
activitiesLoadFailed: !1,
|
|
365
|
+
activitiesLoadingMore: !0
|
|
366
|
+
});
|
|
367
|
+
try {
|
|
368
|
+
let e = await this.#e.listFlowTriggerActivities(r.projectId, r.flowId, n, {
|
|
369
|
+
cursor: t,
|
|
370
|
+
limit: fe
|
|
371
|
+
});
|
|
372
|
+
if (!i() || this.#c.value.selectedTriggerId != n) return;
|
|
373
|
+
let a = new Set(this.#c.value.activities.map((e) => e.activityId));
|
|
374
|
+
this.#h({
|
|
375
|
+
activities: [...this.#c.value.activities, ...e.activities.filter((e) => !a.has(e.activityId))],
|
|
376
|
+
activitiesLoadFailed: !1,
|
|
377
|
+
activitiesLoadingMore: !1,
|
|
378
|
+
activitiesNextCursor: e.nextCursor
|
|
379
|
+
});
|
|
380
|
+
} catch (e) {
|
|
381
|
+
if (!i() || this.#c.value.selectedTriggerId != n) return;
|
|
382
|
+
this.#h({
|
|
383
|
+
activitiesLoadFailed: !0,
|
|
384
|
+
activitiesLoadingMore: !1
|
|
385
|
+
}), this.#s(o(e, this.#n.t));
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
async testTrigger() {
|
|
389
|
+
let { detail: e, selectedTriggerId: t, target: n, testingTriggerId: r } = this.#c.value;
|
|
390
|
+
if (e?.binding.kind != "poll" || e.binding.currentPublicationId == null || t == null || n == null || r != null) return !1;
|
|
391
|
+
let i = this.#o.begin();
|
|
392
|
+
this.#h({
|
|
393
|
+
testingTriggerId: t,
|
|
394
|
+
testResult: void 0
|
|
395
|
+
});
|
|
396
|
+
try {
|
|
397
|
+
let e = await this.#e.testFlowPollTrigger(n.projectId, n.flowId, t);
|
|
398
|
+
return !i() || this.#c.value.selectedTriggerId != t ? !1 : (this.#h({ testResult: e }), !0);
|
|
399
|
+
} catch (e) {
|
|
400
|
+
return i() && this.#c.value.selectedTriggerId == t && this.#s(o(e, this.#n.t)), !1;
|
|
401
|
+
} finally {
|
|
402
|
+
i() && this.#c.value.selectedTriggerId == t && this.#h({ testingTriggerId: void 0 });
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
async toggleTrigger(e) {
|
|
406
|
+
let t = this.#c.value.target;
|
|
407
|
+
if (t == null || this.#c.value.changingTriggerId != null || this.#c.value.publishing || this.#c.value.rollingBackPublicationId != null) return !1;
|
|
408
|
+
let n = this.#i.begin();
|
|
409
|
+
this.#h({ changingTriggerId: e.triggerNodeId });
|
|
410
|
+
try {
|
|
411
|
+
if (e.operatorState == "active" ? await this.#e.pauseFlowTrigger(t.projectId, t.flowId, e.triggerNodeId) : await this.#e.resumeFlowTrigger(t.projectId, t.flowId, e.triggerNodeId), !n()) return !1;
|
|
412
|
+
let r = await this.#e.listFlowTriggerBindings(t.projectId, t.flowId);
|
|
413
|
+
return n() ? (this.#h({ bindings: r }), this.#c.value.selectedTriggerId == e.triggerNodeId && this.openTrigger(e.triggerNodeId), this.#s({
|
|
414
|
+
kind: "success",
|
|
415
|
+
message: this.#n.t(e.operatorState == "active" ? "notice.triggerPaused" : "notice.triggerResumed")
|
|
416
|
+
}), !0) : !1;
|
|
417
|
+
} catch (e) {
|
|
418
|
+
return n() && this.#s(o(e, this.#n.t)), !1;
|
|
419
|
+
} finally {
|
|
420
|
+
n() && this.#h({ changingTriggerId: void 0 });
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
async #d(e) {
|
|
424
|
+
let [t, n, r] = await this.#p(e);
|
|
425
|
+
await this.#l.refreshFlows(), D(this.#c.value.target, e) && this.#h({
|
|
426
|
+
bindings: r,
|
|
427
|
+
live: t,
|
|
428
|
+
loadFailed: !1,
|
|
429
|
+
nextCursor: n.nextCursor,
|
|
430
|
+
publications: n.publications,
|
|
431
|
+
total: n.total
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
async #f(e) {
|
|
435
|
+
try {
|
|
436
|
+
await this.#d(e), this.#u = void 0;
|
|
437
|
+
} catch {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
async #p(e) {
|
|
442
|
+
return await Promise.all([
|
|
443
|
+
this.#e.getLive(e.projectId, e.flowId),
|
|
444
|
+
this.#e.listPublications(e.projectId, e.flowId, {
|
|
445
|
+
includeTotal: !0,
|
|
446
|
+
limit: E
|
|
447
|
+
}),
|
|
448
|
+
this.#e.listFlowTriggerBindings(e.projectId, e.flowId)
|
|
449
|
+
]);
|
|
450
|
+
}
|
|
451
|
+
#m(e, t) {
|
|
452
|
+
D(this.#c.value.target, e) ? this.#h(t) : this.#c.set({
|
|
453
|
+
...T,
|
|
454
|
+
...t,
|
|
455
|
+
target: e
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
#h(e) {
|
|
459
|
+
this.#c.set({
|
|
460
|
+
...this.#c.value,
|
|
461
|
+
...e
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
}, O = { starting: !1 };
|
|
465
|
+
function me(e) {
|
|
466
|
+
switch (e.kind) {
|
|
467
|
+
case "condition": return { [e.node.input.handle]: e.node.input };
|
|
468
|
+
case "subflow": return e.definition?.inputs ?? {};
|
|
469
|
+
case "task": return e.definition?.inputs ?? {};
|
|
470
|
+
case "value": return {};
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
function he(e) {
|
|
474
|
+
return e.node.name == null ? e.kind == "task" || e.kind == "subflow" ? e.definition?.name ?? e.id : e.id : e.node.name;
|
|
475
|
+
}
|
|
476
|
+
function ge(e, t, n) {
|
|
477
|
+
let r = s(e), i = r.graph({
|
|
478
|
+
id: t,
|
|
479
|
+
kind: "flow"
|
|
480
|
+
});
|
|
481
|
+
return i == null ? [] : Object.entries(i.nodes).toSorted(([e], [t]) => e.localeCompare(t)).flatMap(([e, t]) => {
|
|
482
|
+
let i = r.resolveNode(e, t);
|
|
483
|
+
if (i.kind == "trigger") return [];
|
|
484
|
+
let a = Object.entries(me(i)).filter(([e, t]) => i.node.inputs[e] == null && !Object.hasOwn(t, "value")).toSorted(([e], [t]) => e.localeCompare(t)).map(([e, t]) => Object.assign({
|
|
485
|
+
handle: e,
|
|
486
|
+
jsonSchema: t.jsonSchema,
|
|
487
|
+
nullable: t.nullable
|
|
488
|
+
}, t.description == null ? {} : { description: t.description }));
|
|
489
|
+
return a.length == 0 ? [] : [{
|
|
490
|
+
editor: new c(a, n),
|
|
491
|
+
nodeId: e,
|
|
492
|
+
title: he(i)
|
|
493
|
+
}];
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
var _e = class {
|
|
497
|
+
#e;
|
|
498
|
+
#t;
|
|
499
|
+
#n;
|
|
500
|
+
#r = new p();
|
|
501
|
+
#i = new p();
|
|
502
|
+
#a;
|
|
503
|
+
#o;
|
|
504
|
+
#s = r(O);
|
|
505
|
+
#c;
|
|
506
|
+
constructor(e, t, n, r = l(), i = () => crypto.randomUUID()) {
|
|
507
|
+
this.#e = e, this.#a = t, this.#o = n, this.#n = r, this.#t = i, this.$ = {
|
|
508
|
+
inputRequest: a(this.#s, (e) => e.inputRequest),
|
|
509
|
+
starting: a(this.#s, (e) => e.starting),
|
|
510
|
+
submitting: a(this.#s, (e) => e.submitting)
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
dispose() {
|
|
514
|
+
this.#r.invalidate(), this.#i.invalidate(), this.#d();
|
|
515
|
+
for (let e of Object.values(this.$)) e.dispose();
|
|
516
|
+
this.#s.dispose();
|
|
517
|
+
}
|
|
518
|
+
reset() {
|
|
519
|
+
this.#r.invalidate(), this.#i.invalidate(), this.#c = void 0;
|
|
520
|
+
let e = this.#s.value.inputRequest;
|
|
521
|
+
this.#s.set(O), this.#d(e);
|
|
522
|
+
}
|
|
523
|
+
async requestDraft(e, t, n) {
|
|
524
|
+
return this.#i.invalidate(), t.draft == null ? "unavailable" : await this.#l("draft", e, t, n, t.draft.revisionId);
|
|
525
|
+
}
|
|
526
|
+
async requestLive(e, t) {
|
|
527
|
+
let n = t.live?.publication.revisionId;
|
|
528
|
+
if (n == null) return "unavailable";
|
|
529
|
+
let r = this.#i.begin();
|
|
530
|
+
this.#o(void 0), this.#f({ starting: !0 });
|
|
531
|
+
try {
|
|
532
|
+
let i = await this.#e.getRevision(e, n);
|
|
533
|
+
return r() ? await this.#l("live", e, t, i, n) : "unavailable";
|
|
534
|
+
} catch (e) {
|
|
535
|
+
return r() && this.#o(o(e, this.#n.t)), "unavailable";
|
|
536
|
+
} finally {
|
|
537
|
+
r() && this.#f({ starting: !1 });
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
dismissInputs() {
|
|
541
|
+
let e = this.#s.value.inputRequest;
|
|
542
|
+
this.#f({ inputRequest: void 0 }), this.#d(e);
|
|
543
|
+
}
|
|
544
|
+
async confirmInputs() {
|
|
545
|
+
let e = this.#s.value.inputRequest;
|
|
546
|
+
if (e == null) return !1;
|
|
547
|
+
if (!e.valid.value) return this.#f({ inputRequest: {
|
|
548
|
+
...e,
|
|
549
|
+
attempted: !0
|
|
550
|
+
} }), !1;
|
|
551
|
+
let t = Object.fromEntries(e.groups.map((e) => [e.nodeId, e.editor.values()])), n = await this.#u(e.source, e.projectId, e.flow, e.revisionId, t);
|
|
552
|
+
return n && this.#s.value.inputRequest === e && this.dismissInputs(), n;
|
|
553
|
+
}
|
|
554
|
+
async #l(e, t, n, r, a) {
|
|
555
|
+
let o = this.#s.value.inputRequest;
|
|
556
|
+
this.#f({ inputRequest: void 0 }), this.#d(o);
|
|
557
|
+
let s = ge(r, n.flowId, this.#n.lang$);
|
|
558
|
+
if (s.length == 0) return await this.#u(e, t, n, a) ? "started" : "unavailable";
|
|
559
|
+
let c = i((e) => s.every((t) => e(t.editor.valid$)));
|
|
560
|
+
return this.#f({ inputRequest: {
|
|
561
|
+
attempted: !1,
|
|
562
|
+
flow: n,
|
|
563
|
+
groups: s,
|
|
564
|
+
projectId: t,
|
|
565
|
+
revisionId: a,
|
|
566
|
+
source: e,
|
|
567
|
+
valid: c
|
|
568
|
+
} }), "input";
|
|
569
|
+
}
|
|
570
|
+
async #u(e, t, n, r, i = {}) {
|
|
571
|
+
if (e == "draft" && n.draft == null || e == "live" && n.live == null) return !1;
|
|
572
|
+
let a = this.#r.capture(), s = this.#a.prepareStart();
|
|
573
|
+
this.#o(void 0), this.#f({
|
|
574
|
+
starting: !0,
|
|
575
|
+
submitting: e
|
|
576
|
+
});
|
|
577
|
+
let c = JSON.stringify({
|
|
578
|
+
flowId: n.flowId,
|
|
579
|
+
inputs: i,
|
|
580
|
+
projectId: t,
|
|
581
|
+
revisionId: r,
|
|
582
|
+
source: e
|
|
583
|
+
}), l = this.#c?.signature == c ? this.#c : {
|
|
584
|
+
key: this.#t(),
|
|
585
|
+
signature: c
|
|
586
|
+
};
|
|
587
|
+
this.#c = l;
|
|
588
|
+
try {
|
|
589
|
+
let o = e == "draft" ? await this.#e.createDraftRun(t, r, n.flowId, {
|
|
590
|
+
idempotencyKey: l.key,
|
|
591
|
+
inputs: i
|
|
592
|
+
}) : await this.#e.createLiveRun(t, n.flowId, {
|
|
593
|
+
idempotencyKey: l.key,
|
|
594
|
+
inputs: i
|
|
595
|
+
});
|
|
596
|
+
return !a() || !s() ? !1 : (this.#c = void 0, this.#a.follow(o, s));
|
|
597
|
+
} catch (e) {
|
|
598
|
+
return a() && s() && this.#o(o(e, this.#n.t)), !1;
|
|
599
|
+
} finally {
|
|
600
|
+
a() && this.#f({
|
|
601
|
+
starting: !1,
|
|
602
|
+
submitting: void 0
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
#d(e = this.#s.value.inputRequest) {
|
|
607
|
+
if (e != null) {
|
|
608
|
+
e.valid.dispose();
|
|
609
|
+
for (let t of e.groups) t.editor.dispose();
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
#f(e) {
|
|
613
|
+
this.#s.set({
|
|
614
|
+
...this.#s.value,
|
|
615
|
+
...e
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
}, k = {
|
|
619
|
+
actions: {},
|
|
620
|
+
catalogs: {}
|
|
621
|
+
};
|
|
622
|
+
function A(e) {
|
|
623
|
+
return Object.entries(e).map(([e, t]) => ({
|
|
624
|
+
description: t.description,
|
|
625
|
+
handle: e,
|
|
626
|
+
jsonSchema: t.jsonSchema
|
|
627
|
+
}));
|
|
628
|
+
}
|
|
629
|
+
function j(e, t) {
|
|
630
|
+
return {
|
|
631
|
+
connector: e,
|
|
632
|
+
description: e.defaultConnection == null ? t("addNode.connectorNeedsConnection", {
|
|
633
|
+
description: e.description,
|
|
634
|
+
service: e.serviceName
|
|
635
|
+
}) : e.description,
|
|
636
|
+
group: t("addNode.connectorActions"),
|
|
637
|
+
icon: e.icon ?? ":carbon:connection-signal:",
|
|
638
|
+
id: `connector:${e.actionId}`,
|
|
639
|
+
inputs: A(e.inputs),
|
|
640
|
+
kind: "connector",
|
|
641
|
+
label: e.name,
|
|
642
|
+
outputs: A(e.outputs)
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
function ve(e, t) {
|
|
646
|
+
let n = /* @__PURE__ */ new Map();
|
|
647
|
+
for (let t of e) {
|
|
648
|
+
let e = n.get(t.serviceId) ?? [];
|
|
649
|
+
e.push(t), n.set(t.serviceId, e);
|
|
650
|
+
}
|
|
651
|
+
return [...n.values()].toSorted((e, t) => e[0].serviceName.localeCompare(t[0].serviceName)).map((e) => {
|
|
652
|
+
let n = e[0], r = e.map((e) => {
|
|
653
|
+
let n = j(e, t);
|
|
654
|
+
return {
|
|
655
|
+
description: n.description,
|
|
656
|
+
label: n.label,
|
|
657
|
+
option: n
|
|
658
|
+
};
|
|
659
|
+
});
|
|
660
|
+
return {
|
|
661
|
+
choices: r,
|
|
662
|
+
description: t(r.length == 1 ? "addNode.connectorActionCountOne" : "addNode.connectorActionCount", { count: r.length }),
|
|
663
|
+
group: t("addNode.connectorActions"),
|
|
664
|
+
icon: n.icon ?? ":carbon:connection-signal:",
|
|
665
|
+
id: `connector-provider:${n.serviceId}`,
|
|
666
|
+
inputs: [],
|
|
667
|
+
kind: "connector-group",
|
|
668
|
+
label: n.serviceName,
|
|
669
|
+
outputs: [],
|
|
670
|
+
serviceId: n.serviceId
|
|
671
|
+
};
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
function ye(e, t) {
|
|
675
|
+
return {
|
|
676
|
+
choices: [],
|
|
677
|
+
description: t("addNode.connectorBrowseActions"),
|
|
678
|
+
group: t("addNode.connectorActions"),
|
|
679
|
+
icon: e.icon ?? ":carbon:connection-signal:",
|
|
680
|
+
id: `connector-provider:${e.serviceId}`,
|
|
681
|
+
inputs: [],
|
|
682
|
+
kind: "connector-group",
|
|
683
|
+
label: e.serviceName,
|
|
684
|
+
outputs: [],
|
|
685
|
+
serviceId: e.serviceId
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
function M(e) {
|
|
689
|
+
if (e?.kind != "task" || e.node.task != null) return;
|
|
690
|
+
let t = e.definition;
|
|
691
|
+
if (!(t == null || !("executor" in t) || t.executor.kind != "connector")) return {
|
|
692
|
+
actionId: t.executor.action,
|
|
693
|
+
connectionId: t.executor.connectionId,
|
|
694
|
+
nodeId: e.id,
|
|
695
|
+
taskId: e.node.taskId
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
var be = class {
|
|
699
|
+
#e;
|
|
700
|
+
#t;
|
|
701
|
+
#n;
|
|
702
|
+
#r;
|
|
703
|
+
#i;
|
|
704
|
+
#a;
|
|
705
|
+
#o;
|
|
706
|
+
#s;
|
|
707
|
+
#c;
|
|
708
|
+
#l;
|
|
709
|
+
#u;
|
|
710
|
+
#d;
|
|
711
|
+
#f;
|
|
712
|
+
#p;
|
|
713
|
+
constructor(e, t, n, o, s = l()) {
|
|
714
|
+
this.#r = /* @__PURE__ */ new Map(), this.#i = /* @__PURE__ */ new Set(), this.#a = new p(), this.#l = r(k), this.#p = !1, this.browseAddNodeOptions = async (e) => {
|
|
715
|
+
if (this.#p) return;
|
|
716
|
+
let t = this.#u.$.projectId.value;
|
|
717
|
+
if (t == null) return;
|
|
718
|
+
let n = this.#f ?? await this.#e.listConnectorProviders(t, e);
|
|
719
|
+
if (!(e.aborted || this.#p || t != this.#u.$.projectId.value)) return this.#f = n, n.toSorted((e, t) => e.serviceName.localeCompare(t.serviceName)).map((e) => ye(e, this.#t.t));
|
|
720
|
+
}, this.provideAddNodeOptionChoices = async (e, t) => {
|
|
721
|
+
if (this.#p) return;
|
|
722
|
+
let n = this.#u.$.projectId.value, r = this.#f?.find((t) => `connector-provider:${t.serviceId}` == e);
|
|
723
|
+
if (n == null || r == null) return;
|
|
724
|
+
let i = this.#r.get(r.serviceId) ?? await this.#e.listConnectorActions(n, r.serviceId, t);
|
|
725
|
+
if (t.aborted || this.#p || n != this.#u.$.projectId.value) return;
|
|
726
|
+
let a = i.map((e) => Object.assign({}, e, e.icon == null && r.icon != null ? { icon: r.icon } : {}, { serviceName: r.serviceName }));
|
|
727
|
+
return this.#r.set(r.serviceId, a), this.#v({ actions: {
|
|
728
|
+
...this.#l.value.actions,
|
|
729
|
+
...Object.fromEntries(a.map((e) => [e.actionId, e]))
|
|
730
|
+
} }), a.map((e) => j(e, this.#t.t));
|
|
731
|
+
}, this.provideAddNodeOptions = async (e, t) => {
|
|
732
|
+
if (this.#p) return;
|
|
733
|
+
let n = this.#u.$.projectId.value;
|
|
734
|
+
if (n == null) return;
|
|
735
|
+
let r = e.trim(), i = r.length == 0 ? Object.values(this.#l.value.actions) : await this.#e.searchConnectorActions(n, r, t);
|
|
736
|
+
if (t.aborted || this.#p || n != this.#u.$.projectId.value) return;
|
|
737
|
+
let a = { ...this.#l.value.actions };
|
|
738
|
+
for (let e of i) a[e.actionId] = e;
|
|
739
|
+
if (this.#v({ actions: a }), r.length != 0) return i.map((e) => j(e, this.#t.t));
|
|
740
|
+
let o = new Map(i.map((e) => [e.actionId, e]));
|
|
741
|
+
for (let e of this.#u.$.revision.value?.connectorActionIds ?? []) {
|
|
742
|
+
let t = a[e];
|
|
743
|
+
t != null && o.set(e, t);
|
|
744
|
+
}
|
|
745
|
+
return ve([...o.values()], this.#t.t);
|
|
746
|
+
}, this.#e = e, this.#n = o, this.#u = t, this.#c = n, this.#t = s;
|
|
747
|
+
let c = a(this.#l, (e) => e.actions), u = a(this.#l, (e) => e.catalogs);
|
|
748
|
+
this.#s = i((e) => {
|
|
749
|
+
let n = M(e(t.$.selection)), r = e(this.#l);
|
|
750
|
+
if (n == null) return { authorizationPending: !1 };
|
|
751
|
+
let i = r.actions[n.actionId], a = i == null ? void 0 : r.catalogs[i.serviceId], o = n.connectionId == null ? void 0 : a?.byId.get(n.connectionId);
|
|
752
|
+
return o == null && i?.defaultConnection?.connectionId == n.connectionId && (o = i.defaultConnection), {
|
|
753
|
+
action: i,
|
|
754
|
+
actionError: r.actionError?.actionId == n.actionId ? r.actionError.message : void 0,
|
|
755
|
+
activeConnections: a?.active,
|
|
756
|
+
authorizationPending: i != null && r.authorizationServiceId == i.serviceId,
|
|
757
|
+
connection: o,
|
|
758
|
+
connectionError: i != null && r.connectionError?.serviceId == i.serviceId ? r.connectionError.message : void 0
|
|
759
|
+
};
|
|
760
|
+
}), this.$ = {
|
|
761
|
+
actionLoading: a(this.#l, (e) => e.actionLoading),
|
|
762
|
+
actions: c,
|
|
763
|
+
catalogs: u,
|
|
764
|
+
connectionLoading: a(this.#l, (e) => e.connectionLoading),
|
|
765
|
+
selectedAction: a(this.#s, (e) => e.action),
|
|
766
|
+
selectedActionError: a(this.#s, (e) => e.actionError),
|
|
767
|
+
selectedActiveConnections: a(this.#s, (e) => e.activeConnections),
|
|
768
|
+
selectedAuthorizationPending: a(this.#s, (e) => e.authorizationPending),
|
|
769
|
+
selectedConnection: a(this.#s, (e) => e.connection),
|
|
770
|
+
selectedConnectionError: a(this.#s, (e) => e.connectionError)
|
|
771
|
+
}, this.#o = t.$.revision.reaction(() => void this.#b());
|
|
772
|
+
}
|
|
773
|
+
dispose() {
|
|
774
|
+
this.#p = !0, this.#a.invalidate(), this.#o();
|
|
775
|
+
for (let e of Object.values(this.$)) e.dispose();
|
|
776
|
+
this.#s.dispose(), this.#l.dispose();
|
|
777
|
+
}
|
|
778
|
+
reset() {
|
|
779
|
+
this.#p || (this.#a.invalidate(), this.#d = void 0, this.#r.clear(), this.#f = void 0, this.#i.clear(), this.#l.set(k));
|
|
780
|
+
}
|
|
781
|
+
async refresh(e = !1) {
|
|
782
|
+
if (this.#p) return;
|
|
783
|
+
let t = this.#a.begin(), n = this.#u.$.projectId.value, r = M(this.#u.$.selection.value);
|
|
784
|
+
if (n == null || r == null) {
|
|
785
|
+
(this.#l.value.actionLoading != null || this.#l.value.connectionLoading != null) && this.#v({
|
|
786
|
+
actionLoading: void 0,
|
|
787
|
+
connectionLoading: void 0
|
|
788
|
+
});
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
this.#v({
|
|
792
|
+
actionError: void 0,
|
|
793
|
+
actionLoading: r.actionId,
|
|
794
|
+
connectionError: void 0,
|
|
795
|
+
connectionLoading: void 0
|
|
796
|
+
});
|
|
797
|
+
try {
|
|
798
|
+
let i = await this.#m(n, r.actionId, e);
|
|
799
|
+
if (!this.#y(t, n)) return;
|
|
800
|
+
this.#v({ actions: {
|
|
801
|
+
...this.#l.value.actions,
|
|
802
|
+
[i.actionId]: i
|
|
803
|
+
} }), await this.#h(n, r, i.serviceId, e, t);
|
|
804
|
+
} catch (e) {
|
|
805
|
+
this.#y(t, n) && this.#v({ actionError: {
|
|
806
|
+
actionId: r.actionId,
|
|
807
|
+
message: o(e, this.#t.t).message
|
|
808
|
+
} });
|
|
809
|
+
} finally {
|
|
810
|
+
this.#y(t, n) && this.#l.value.actionLoading == r.actionId && this.#v({ actionLoading: void 0 });
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
async connect(e) {
|
|
814
|
+
if (this.#p) return;
|
|
815
|
+
let t = this.#u.$.projectId.value;
|
|
816
|
+
if (t == null) return;
|
|
817
|
+
let n = this.#l.value.catalogs[e];
|
|
818
|
+
try {
|
|
819
|
+
if (!await this.#n.openExternalPage(() => this.#e.createConnectorConnectionPage(t, e, this.#n.returnUrl))) {
|
|
820
|
+
this.#c({
|
|
821
|
+
kind: "error",
|
|
822
|
+
message: this.#t.t("notice.connectionPopupBlocked")
|
|
823
|
+
});
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
if (this.#p || t != this.#u.$.projectId.value) return;
|
|
827
|
+
this.#d = {
|
|
828
|
+
connectionIds: new Set(n?.all.map((e) => e.connectionId)),
|
|
829
|
+
serviceId: e
|
|
830
|
+
}, this.#v({ authorizationServiceId: e });
|
|
831
|
+
} catch (e) {
|
|
832
|
+
this.#p || this.#c(o(e, this.#t.t));
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
async setConnection(e, t) {
|
|
836
|
+
return await this.#u.setConnectorConnection(e, t);
|
|
837
|
+
}
|
|
838
|
+
async refreshAfterAuthorization() {
|
|
839
|
+
if (this.#p || this.#d == null) return;
|
|
840
|
+
let e = this.#d.serviceId;
|
|
841
|
+
this.#r.delete(e), this.#v({ authorizationServiceId: void 0 }), this.$.selectedAction.value?.serviceId == e && await this.refresh(!0), !this.#p && this.#d?.serviceId == e && (this.#d = void 0);
|
|
842
|
+
}
|
|
843
|
+
async #m(e, t, n) {
|
|
844
|
+
let r = this.#l.value.actions[t];
|
|
845
|
+
return !n && r != null ? r : await this.#e.getConnectorAction(e, t);
|
|
846
|
+
}
|
|
847
|
+
async #h(e, t, n, r, i) {
|
|
848
|
+
this.#v({ connectionLoading: n });
|
|
849
|
+
try {
|
|
850
|
+
let a = await this.#g(e, n, r, i);
|
|
851
|
+
if (a == null || !this.#y(i, e)) return;
|
|
852
|
+
await this.#_(t, n, a);
|
|
853
|
+
} finally {
|
|
854
|
+
this.#y(i, e) && this.#l.value.connectionLoading == n && this.#v({ connectionLoading: void 0 });
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
async #g(e, t, n, r) {
|
|
858
|
+
let i = this.#l.value.catalogs[t];
|
|
859
|
+
if (!n && i != null) return i;
|
|
860
|
+
let a;
|
|
861
|
+
try {
|
|
862
|
+
a = await this.#e.listConnectorConnections(e, t);
|
|
863
|
+
} catch (n) {
|
|
864
|
+
this.#y(r, e) && this.#v({ connectionError: {
|
|
865
|
+
message: o(n, this.#t.t).message,
|
|
866
|
+
serviceId: t
|
|
867
|
+
} });
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
if (!this.#y(r, e)) return;
|
|
871
|
+
let s = u(a);
|
|
872
|
+
return this.#v({ catalogs: {
|
|
873
|
+
...this.#l.value.catalogs,
|
|
874
|
+
[t]: s
|
|
875
|
+
} }), s;
|
|
876
|
+
}
|
|
877
|
+
async #_(e, t, n) {
|
|
878
|
+
let r = this.#d?.serviceId == t ? this.#d : void 0, i = r == null ? [] : n.active.filter((e) => !r.connectionIds.has(e.connectionId)), a = i.length == 1 ? i[0] : n.preferred, o = this.#u.$.revision.value?.task(e.taskId);
|
|
879
|
+
a != null && this.#u.$.selectedNodeIds.value.includes(e.nodeId) && o != null && "executor" in o && o.executor.kind == "connector" && o.executor.connectionId == null && await this.#u.setConnectorConnection(e.taskId, a.connectionId);
|
|
880
|
+
}
|
|
881
|
+
#v(e) {
|
|
882
|
+
this.#p || this.#l.set({
|
|
883
|
+
...this.#l.value,
|
|
884
|
+
...e
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
#y(e, t) {
|
|
888
|
+
return !this.#p && e() && t == this.#u.$.projectId.value;
|
|
889
|
+
}
|
|
890
|
+
async #b() {
|
|
891
|
+
if (this.#p) return;
|
|
892
|
+
let e = this.#a.capture(), t = this.#u.$.projectId.value, n = this.#u.$.revision.value;
|
|
893
|
+
if (t == null || n == null) return;
|
|
894
|
+
let r = [...n.connectorActionIds].filter((e) => this.#l.value.actions[e] == null && !this.#i.has(e));
|
|
895
|
+
if (r.length != 0) {
|
|
896
|
+
for (let e of r) this.#i.add(e);
|
|
897
|
+
try {
|
|
898
|
+
let n = await Promise.all(r.map((e) => this.#e.getConnectorAction(t, e)));
|
|
899
|
+
if (!this.#y(e, t)) return;
|
|
900
|
+
let i = { ...this.#l.value.actions };
|
|
901
|
+
for (let e of n) i[e.actionId] = e;
|
|
902
|
+
this.#v({ actions: i });
|
|
903
|
+
} catch {
|
|
904
|
+
return;
|
|
905
|
+
} finally {
|
|
906
|
+
for (let e of r) this.#i.delete(e);
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
}, N = { catalogs: {} }, P = 4, F = "trigger:";
|
|
911
|
+
function I(e, t) {
|
|
912
|
+
if (e?.kind != "trigger") return;
|
|
913
|
+
let n = e.trigger;
|
|
914
|
+
if (n.kind != "poll" && n.kind != "integration") return;
|
|
915
|
+
let r = t.$.revision.value?.binding(n.bindingId);
|
|
916
|
+
return {
|
|
917
|
+
...r?.kind == "connection" ? { connectionId: r.target } : {},
|
|
918
|
+
provider: n.definition.provider,
|
|
919
|
+
triggerId: e.id
|
|
920
|
+
};
|
|
921
|
+
}
|
|
922
|
+
function L(e, t, n, r) {
|
|
923
|
+
return {
|
|
924
|
+
description: n,
|
|
925
|
+
group: r,
|
|
926
|
+
id: `trigger:${e.key}:${t}`,
|
|
927
|
+
inputs: [],
|
|
928
|
+
kind: "trigger",
|
|
929
|
+
label: e.displayName,
|
|
930
|
+
outputs: [{
|
|
931
|
+
handle: "payload",
|
|
932
|
+
jsonSchema: e.payloadSchema
|
|
933
|
+
}],
|
|
934
|
+
trigger: {
|
|
935
|
+
connectionId: t,
|
|
936
|
+
definition: e,
|
|
937
|
+
kind: "catalog"
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
}
|
|
941
|
+
function R(e, t) {
|
|
942
|
+
return {
|
|
943
|
+
choices: [],
|
|
944
|
+
description: t.t("addNode.triggerChooseConnection"),
|
|
945
|
+
group: t.t("addNode.triggers"),
|
|
946
|
+
id: `${F}${e.key}`,
|
|
947
|
+
inputs: [],
|
|
948
|
+
kind: "trigger",
|
|
949
|
+
label: e.displayName,
|
|
950
|
+
outputs: []
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
function z(e, t, n) {
|
|
954
|
+
let r = n.t("addNode.triggers"), i = t.preferred;
|
|
955
|
+
return i == null ? t.active.length > 0 ? t.active.map((t) => L(e, t.connectionId, t.displayName, r)) : [{
|
|
956
|
+
description: n.t("addNode.triggerNeedsConnection", { provider: e.provider }),
|
|
957
|
+
group: r,
|
|
958
|
+
id: `${F}${e.key}:connect`,
|
|
959
|
+
inputs: [],
|
|
960
|
+
kind: "trigger",
|
|
961
|
+
label: n.t("addNode.triggerAddConnection"),
|
|
962
|
+
outputs: [],
|
|
963
|
+
trigger: {
|
|
964
|
+
kind: "connect",
|
|
965
|
+
provider: e.provider
|
|
966
|
+
}
|
|
967
|
+
}] : [L(e, i.connectionId, i.displayName, r)];
|
|
968
|
+
}
|
|
969
|
+
function xe(e, t, n) {
|
|
970
|
+
let r = t.preferred;
|
|
971
|
+
if (r != null) return L(e, r.connectionId, r.displayName, n.t("addNode.triggers"));
|
|
972
|
+
let i = R(e, n), a = z(e, t, n);
|
|
973
|
+
return {
|
|
974
|
+
...i,
|
|
975
|
+
description: t.active.length == 0 ? n.t("addNode.triggerNeedsConnection", { provider: e.provider }) : i.description,
|
|
976
|
+
outputs: t.active.length == 0 ? [] : [{
|
|
977
|
+
handle: "payload",
|
|
978
|
+
jsonSchema: e.payloadSchema
|
|
979
|
+
}],
|
|
980
|
+
choices: a.map((n) => ({
|
|
981
|
+
description: t.active.length == 0 ? e.provider : void 0,
|
|
982
|
+
label: n.label,
|
|
983
|
+
option: n
|
|
984
|
+
}))
|
|
985
|
+
};
|
|
986
|
+
}
|
|
987
|
+
var Se = class {
|
|
988
|
+
#e;
|
|
989
|
+
#t;
|
|
990
|
+
#n;
|
|
991
|
+
#r;
|
|
992
|
+
#i;
|
|
993
|
+
#a;
|
|
994
|
+
#o;
|
|
995
|
+
#s;
|
|
996
|
+
#c;
|
|
997
|
+
#l;
|
|
998
|
+
#u;
|
|
999
|
+
constructor(e, t, n, o, s = l()) {
|
|
1000
|
+
this.#t = new AbortController(), this.#a = new p(), this.#c = r(N), this.#u = !1, this.browseAddNodeOptions = async (e) => {
|
|
1001
|
+
let t = this.#l.$.projectId.value;
|
|
1002
|
+
if (e.aborted || this.#u || t == null || this.#l.$.target.value?.kind != "flow") return [];
|
|
1003
|
+
let n = await this.#d();
|
|
1004
|
+
if (!(e.aborted || this.#u || t != this.#l.$.projectId.value)) return [...n.values()].map((e) => R(e, this.#i));
|
|
1005
|
+
}, this.provideAddNodeOptions = async (e, t) => {
|
|
1006
|
+
let n = this.#l.$.projectId.value;
|
|
1007
|
+
if (t.aborted || this.#u || n == null || this.#l.$.target.value?.kind != "flow") return [];
|
|
1008
|
+
let r = e.trim().toLowerCase();
|
|
1009
|
+
if (r.length == 0) return [];
|
|
1010
|
+
let i = await this.#d();
|
|
1011
|
+
if (t.aborted || this.#u || n != this.#l.$.projectId.value) return;
|
|
1012
|
+
let a = [...i.values()].filter((e) => [
|
|
1013
|
+
e.description,
|
|
1014
|
+
e.displayName,
|
|
1015
|
+
e.key,
|
|
1016
|
+
e.name,
|
|
1017
|
+
e.provider,
|
|
1018
|
+
e.type
|
|
1019
|
+
].some((e) => e.toLowerCase().includes(r))), o = [...new Set(a.map((e) => e.provider))].filter((e) => this.#c.value.catalogs[e] == null);
|
|
1020
|
+
for (let e = 0; e < o.length; e += P) {
|
|
1021
|
+
let r = await Promise.all(o.slice(e, e + P).map(async (e) => [e, u(await this.#n.listConnectorConnections(n, e, t))]));
|
|
1022
|
+
if (t.aborted || this.#u || n != this.#l.$.projectId.value) return;
|
|
1023
|
+
this.#f({ catalogs: {
|
|
1024
|
+
...this.#c.value.catalogs,
|
|
1025
|
+
...Object.fromEntries(r)
|
|
1026
|
+
} });
|
|
1027
|
+
}
|
|
1028
|
+
return a.map((e) => xe(e, this.#c.value.catalogs[e.provider], this.#i));
|
|
1029
|
+
}, this.provideAddNodeOptionChoices = async (e, t) => {
|
|
1030
|
+
let n = this.#l.$.projectId.value, r = e.startsWith(F) ? e.slice(8) : void 0;
|
|
1031
|
+
if (t.aborted || this.#u || n == null || r == null || this.#l.$.target.value?.kind != "flow") return;
|
|
1032
|
+
let i = (await this.#d()).get(r);
|
|
1033
|
+
if (t.aborted || this.#u || n != this.#l.$.projectId.value || i == null) return;
|
|
1034
|
+
let a = this.#c.value.catalogs[i.provider];
|
|
1035
|
+
if (a == null) {
|
|
1036
|
+
if (a = u(await this.#n.listConnectorConnections(n, i.provider, t)), t.aborted || this.#u || n != this.#l.$.projectId.value) return;
|
|
1037
|
+
this.#f({ catalogs: {
|
|
1038
|
+
...this.#c.value.catalogs,
|
|
1039
|
+
[i.provider]: a
|
|
1040
|
+
} });
|
|
1041
|
+
}
|
|
1042
|
+
return z(i, a, this.#i);
|
|
1043
|
+
}, this.#n = e, this.#r = o, this.#i = s, this.#s = n, this.#l = t, this.#o = i((e) => {
|
|
1044
|
+
let n = e(t.$.selection), r = I(n, t), i = e(this.#c);
|
|
1045
|
+
if (n?.kind != "trigger") return { authorizationPending: !1 };
|
|
1046
|
+
let a = n.trigger;
|
|
1047
|
+
if (a.kind != "poll" && a.kind != "integration") return { authorizationPending: !1 };
|
|
1048
|
+
let o = r == null ? void 0 : i.catalogs[r.provider], s = i.connectionError;
|
|
1049
|
+
return {
|
|
1050
|
+
activeConnections: o?.active,
|
|
1051
|
+
authorizationPending: i.authorizationProvider == r?.provider,
|
|
1052
|
+
connection: r?.connectionId == null ? void 0 : o?.byId.get(r.connectionId),
|
|
1053
|
+
connectionError: s != null && s.provider == r?.provider ? s.message : void 0,
|
|
1054
|
+
definition: a.definition
|
|
1055
|
+
};
|
|
1056
|
+
}), this.$ = {
|
|
1057
|
+
connectionLoading: a(this.#c, (e) => e.connectionLoading),
|
|
1058
|
+
selectedActiveConnections: a(this.#o, (e) => e.activeConnections),
|
|
1059
|
+
selectedAuthorizationPending: a(this.#o, (e) => e.authorizationPending),
|
|
1060
|
+
selectedConnection: a(this.#o, (e) => e.connection),
|
|
1061
|
+
selectedConnectionError: a(this.#o, (e) => e.connectionError),
|
|
1062
|
+
selectedDefinition: a(this.#o, (e) => e.definition)
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
dispose() {
|
|
1066
|
+
this.#u = !0, this.#t.abort(), this.#a.invalidate();
|
|
1067
|
+
for (let e of Object.values(this.$)) e.dispose();
|
|
1068
|
+
this.#o.dispose(), this.#c.dispose();
|
|
1069
|
+
}
|
|
1070
|
+
reset() {
|
|
1071
|
+
this.#u || (this.#t.abort(), this.#t = new AbortController(), this.#e = void 0, this.#a.invalidate(), this.#c.set(N));
|
|
1072
|
+
}
|
|
1073
|
+
async refresh(e = !1) {
|
|
1074
|
+
let t = this.#a.begin(), n = this.#l.$.projectId.value, r = I(this.#l.$.selection.value, this.#l);
|
|
1075
|
+
if (!this.#u) {
|
|
1076
|
+
if (n == null || r == null) {
|
|
1077
|
+
this.#c.value.connectionLoading != null && this.#f({ connectionLoading: void 0 });
|
|
1078
|
+
return;
|
|
1079
|
+
}
|
|
1080
|
+
if (!(!e && this.#c.value.catalogs[r.provider] != null)) {
|
|
1081
|
+
this.#f({
|
|
1082
|
+
connectionError: void 0,
|
|
1083
|
+
connectionLoading: r.provider
|
|
1084
|
+
});
|
|
1085
|
+
try {
|
|
1086
|
+
let e = u(await this.#n.listConnectorConnections(n, r.provider));
|
|
1087
|
+
if (!this.#p(t, n)) return;
|
|
1088
|
+
this.#f({ catalogs: {
|
|
1089
|
+
...this.#c.value.catalogs,
|
|
1090
|
+
[r.provider]: e
|
|
1091
|
+
} });
|
|
1092
|
+
} catch (e) {
|
|
1093
|
+
this.#p(t, n) && this.#f({ connectionError: {
|
|
1094
|
+
message: o(e, this.#i.t).message,
|
|
1095
|
+
provider: r.provider
|
|
1096
|
+
} });
|
|
1097
|
+
} finally {
|
|
1098
|
+
this.#p(t, n) && this.#c.value.connectionLoading == r.provider && this.#f({ connectionLoading: void 0 });
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
}
|
|
1103
|
+
async connect(e) {
|
|
1104
|
+
let t = this.#l.$.projectId.value;
|
|
1105
|
+
if (!(this.#u || t == null)) try {
|
|
1106
|
+
if (!await this.#r.openExternalPage(() => this.#n.createConnectorConnectionPage(t, e, this.#r.returnUrl))) {
|
|
1107
|
+
this.#s({
|
|
1108
|
+
kind: "error",
|
|
1109
|
+
message: this.#i.t("notice.connectionPopupBlocked")
|
|
1110
|
+
});
|
|
1111
|
+
return;
|
|
1112
|
+
}
|
|
1113
|
+
!this.#u && t == this.#l.$.projectId.value && this.#f({ authorizationProvider: e });
|
|
1114
|
+
} catch (e) {
|
|
1115
|
+
this.#u || this.#s(o(e, this.#i.t));
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
async setConnection(e, t) {
|
|
1119
|
+
return await this.#l.setTriggerConnection(e, t);
|
|
1120
|
+
}
|
|
1121
|
+
async saveSettings(e, t) {
|
|
1122
|
+
return await this.#l.saveTriggerSettings(e, t);
|
|
1123
|
+
}
|
|
1124
|
+
async refreshAfterAuthorization() {
|
|
1125
|
+
let e = this.#c.value.authorizationProvider;
|
|
1126
|
+
if (this.#u || e == null) return;
|
|
1127
|
+
let t = { ...this.#c.value.catalogs };
|
|
1128
|
+
delete t[e], this.#f({
|
|
1129
|
+
authorizationProvider: void 0,
|
|
1130
|
+
catalogs: t
|
|
1131
|
+
}), I(this.#l.$.selection.value, this.#l)?.provider == e && await this.refresh(!0);
|
|
1132
|
+
}
|
|
1133
|
+
#d() {
|
|
1134
|
+
if (this.#e != null) return this.#e;
|
|
1135
|
+
let e = this.#n.listTriggerDefinitions(this.#t.signal).then((e) => new Map(e.map((e) => [e.key, e])));
|
|
1136
|
+
return this.#e = e, e.catch(() => {
|
|
1137
|
+
this.#e == e && (this.#e = void 0);
|
|
1138
|
+
}), e;
|
|
1139
|
+
}
|
|
1140
|
+
#f(e) {
|
|
1141
|
+
this.#u || this.#c.set({
|
|
1142
|
+
...this.#c.value,
|
|
1143
|
+
...e
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
#p(e, t) {
|
|
1147
|
+
return !this.#u && e() && t == this.#l.$.projectId.value;
|
|
1148
|
+
}
|
|
1149
|
+
};
|
|
1150
|
+
//#endregion
|
|
1151
|
+
//#region src/project/common/edgeChanges.ts
|
|
1152
|
+
function B(e, t, n) {
|
|
1153
|
+
let r = {
|
|
1154
|
+
source: n.source,
|
|
1155
|
+
sourceHandle: n.sourceHandle,
|
|
1156
|
+
target: n.target,
|
|
1157
|
+
targetHandle: n.targetHandle
|
|
1158
|
+
}, i = V(e, t)?.nodes[n.target], a = i != null && "inputs" in i ? i.inputs[n.targetHandle] : void 0;
|
|
1159
|
+
return a?.kind == "sources" && a.sources.some((e) => e.kind == "node" && e.nodeId == n.source && e.output == n.sourceHandle) ? [] : [{
|
|
1160
|
+
edge: r,
|
|
1161
|
+
kind: "graph.edge.connect",
|
|
1162
|
+
target: t
|
|
1163
|
+
}];
|
|
1164
|
+
}
|
|
1165
|
+
function Ce(e, t, n) {
|
|
1166
|
+
let r = {
|
|
1167
|
+
source: n.source,
|
|
1168
|
+
sourceHandle: n.sourceHandle,
|
|
1169
|
+
target: n.target,
|
|
1170
|
+
targetHandle: n.targetHandle
|
|
1171
|
+
}, i = V(e, t)?.nodes[n.target], a = i != null && "inputs" in i ? i.inputs[n.targetHandle] : void 0;
|
|
1172
|
+
return a?.kind != "sources" || !a.sources.some((e) => e.kind == "node" && e.nodeId == n.source && e.output == n.sourceHandle) ? [] : [{
|
|
1173
|
+
edge: r,
|
|
1174
|
+
kind: "graph.edge.disconnect",
|
|
1175
|
+
target: t
|
|
1176
|
+
}];
|
|
1177
|
+
}
|
|
1178
|
+
function V(e, t) {
|
|
1179
|
+
return t.kind == "flow" ? e.document.flows[t.id]?.graph : e.document.subflows[t.id]?.graph;
|
|
1180
|
+
}
|
|
1181
|
+
//#endregion
|
|
1182
|
+
//#region src/project/common/flowChanges.ts
|
|
1183
|
+
function we(e, t) {
|
|
1184
|
+
return [{
|
|
1185
|
+
flow: {
|
|
1186
|
+
graph: { nodes: {} },
|
|
1187
|
+
name: t
|
|
1188
|
+
},
|
|
1189
|
+
flowId: e,
|
|
1190
|
+
kind: "flow.create"
|
|
1191
|
+
}];
|
|
1192
|
+
}
|
|
1193
|
+
function Te(e, t) {
|
|
1194
|
+
return [{
|
|
1195
|
+
flowId: e,
|
|
1196
|
+
kind: "flow.rename",
|
|
1197
|
+
name: t
|
|
1198
|
+
}];
|
|
1199
|
+
}
|
|
1200
|
+
function Ee(e) {
|
|
1201
|
+
return [{
|
|
1202
|
+
flowId: e,
|
|
1203
|
+
kind: "flow.delete"
|
|
1204
|
+
}];
|
|
1205
|
+
}
|
|
1206
|
+
//#endregion
|
|
1207
|
+
//#region src/project/common/moduleChanges.ts
|
|
1208
|
+
async function De(e) {
|
|
1209
|
+
try {
|
|
1210
|
+
let { parse: t } = await import("./lib-S4ccuMeT.js"), n = t(e, {
|
|
1211
|
+
errorRecovery: !0,
|
|
1212
|
+
sourceType: "module"
|
|
1213
|
+
}).program, r = /* @__PURE__ */ new Set();
|
|
1214
|
+
for (let e of n.body) {
|
|
1215
|
+
if (e.type != "ImportDeclaration") continue;
|
|
1216
|
+
let t = /^\.\/(.+)\.mjs$/.exec(e.source.value);
|
|
1217
|
+
t?.[1] != null && r.add(t[1]);
|
|
1218
|
+
}
|
|
1219
|
+
return [...r].toSorted();
|
|
1220
|
+
} catch {
|
|
1221
|
+
return [];
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
function Oe(e, t, n) {
|
|
1225
|
+
return [{
|
|
1226
|
+
imports: n,
|
|
1227
|
+
kind: "module.source.replace",
|
|
1228
|
+
moduleId: e,
|
|
1229
|
+
source: t
|
|
1230
|
+
}];
|
|
1231
|
+
}
|
|
1232
|
+
//#endregion
|
|
1233
|
+
//#region src/project/common/nodeChanges.ts
|
|
1234
|
+
function ke(e, t, n, r = {
|
|
1235
|
+
imports: [],
|
|
1236
|
+
source: "export default function run(input) {\n return { result: input.value }\n}\n"
|
|
1237
|
+
}, i = {
|
|
1238
|
+
inputs: { value: {
|
|
1239
|
+
jsonSchema: {},
|
|
1240
|
+
nullable: !0,
|
|
1241
|
+
value: null
|
|
1242
|
+
} },
|
|
1243
|
+
outputs: { result: {
|
|
1244
|
+
jsonSchema: {},
|
|
1245
|
+
nullable: !0
|
|
1246
|
+
} }
|
|
1247
|
+
}) {
|
|
1248
|
+
return [{
|
|
1249
|
+
kind: "module.create",
|
|
1250
|
+
module: {
|
|
1251
|
+
...r,
|
|
1252
|
+
name: n
|
|
1253
|
+
},
|
|
1254
|
+
moduleId: t.moduleId
|
|
1255
|
+
}, {
|
|
1256
|
+
kind: "graph.node.create",
|
|
1257
|
+
node: {
|
|
1258
|
+
concurrency: 1,
|
|
1259
|
+
inputs: G(i.inputs),
|
|
1260
|
+
kind: "task",
|
|
1261
|
+
name: n,
|
|
1262
|
+
task: {
|
|
1263
|
+
inputs: i.inputs,
|
|
1264
|
+
moduleId: t.moduleId,
|
|
1265
|
+
name: n,
|
|
1266
|
+
outputs: i.outputs
|
|
1267
|
+
}
|
|
1268
|
+
},
|
|
1269
|
+
nodeId: t.nodeId,
|
|
1270
|
+
target: e
|
|
1271
|
+
}];
|
|
1272
|
+
}
|
|
1273
|
+
function H(e, t, n) {
|
|
1274
|
+
return [{
|
|
1275
|
+
kind: "task.create",
|
|
1276
|
+
task: n,
|
|
1277
|
+
taskId: t.taskId
|
|
1278
|
+
}, {
|
|
1279
|
+
kind: "graph.node.create",
|
|
1280
|
+
node: {
|
|
1281
|
+
concurrency: 1,
|
|
1282
|
+
inputs: G(n.inputs),
|
|
1283
|
+
kind: "task",
|
|
1284
|
+
name: n.name,
|
|
1285
|
+
taskId: t.taskId
|
|
1286
|
+
},
|
|
1287
|
+
nodeId: t.nodeId,
|
|
1288
|
+
target: e
|
|
1289
|
+
}];
|
|
1290
|
+
}
|
|
1291
|
+
function Ae(e, t, n, r, i, a = {}) {
|
|
1292
|
+
let o = a.inputs ?? {};
|
|
1293
|
+
return H(e, t, {
|
|
1294
|
+
executor: {
|
|
1295
|
+
kind: "llm",
|
|
1296
|
+
mode: r
|
|
1297
|
+
},
|
|
1298
|
+
inputs: {
|
|
1299
|
+
messages: {
|
|
1300
|
+
jsonSchema: {
|
|
1301
|
+
items: { type: "object" },
|
|
1302
|
+
type: "array"
|
|
1303
|
+
},
|
|
1304
|
+
nullable: !0,
|
|
1305
|
+
value: K(o, "messages", null)
|
|
1306
|
+
},
|
|
1307
|
+
input: {
|
|
1308
|
+
jsonSchema: { type: "string" },
|
|
1309
|
+
nullable: !1,
|
|
1310
|
+
value: K(o, "input", "Alex")
|
|
1311
|
+
},
|
|
1312
|
+
template: {
|
|
1313
|
+
jsonSchema: {
|
|
1314
|
+
items: { type: "object" },
|
|
1315
|
+
minItems: 1,
|
|
1316
|
+
type: "array"
|
|
1317
|
+
},
|
|
1318
|
+
nullable: !1,
|
|
1319
|
+
value: K(o, "template", [{
|
|
1320
|
+
content: "Hello, I'm {{input}}",
|
|
1321
|
+
role: "user"
|
|
1322
|
+
}])
|
|
1323
|
+
},
|
|
1324
|
+
model: {
|
|
1325
|
+
jsonSchema: { type: "object" },
|
|
1326
|
+
nullable: !1,
|
|
1327
|
+
value: K(o, "model", { model: "deepseek-v4-flash" })
|
|
1328
|
+
}
|
|
1329
|
+
},
|
|
1330
|
+
name: n,
|
|
1331
|
+
outputs: { output: a.output ?? {
|
|
1332
|
+
description: i,
|
|
1333
|
+
jsonSchema: r == "chat" ? { type: "string" } : {},
|
|
1334
|
+
nullable: !1
|
|
1335
|
+
} }
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1338
|
+
function je(e, t, n) {
|
|
1339
|
+
return [{
|
|
1340
|
+
kind: "graph.node.create",
|
|
1341
|
+
node: {
|
|
1342
|
+
cases: [{
|
|
1343
|
+
expressions: [{
|
|
1344
|
+
input: "value",
|
|
1345
|
+
operator: "isTrue"
|
|
1346
|
+
}],
|
|
1347
|
+
output: "true",
|
|
1348
|
+
relation: "all"
|
|
1349
|
+
}],
|
|
1350
|
+
concurrency: 1,
|
|
1351
|
+
defaultOutput: "false",
|
|
1352
|
+
input: {
|
|
1353
|
+
handle: "value",
|
|
1354
|
+
jsonSchema: {},
|
|
1355
|
+
nullable: !0,
|
|
1356
|
+
value: null
|
|
1357
|
+
},
|
|
1358
|
+
inputs: { value: {
|
|
1359
|
+
kind: "value",
|
|
1360
|
+
value: null
|
|
1361
|
+
} },
|
|
1362
|
+
kind: "condition",
|
|
1363
|
+
name: n
|
|
1364
|
+
},
|
|
1365
|
+
nodeId: t,
|
|
1366
|
+
target: e
|
|
1367
|
+
}];
|
|
1368
|
+
}
|
|
1369
|
+
function Me(e, t, n) {
|
|
1370
|
+
return [{
|
|
1371
|
+
kind: "graph.node.create",
|
|
1372
|
+
node: {
|
|
1373
|
+
concurrency: 1,
|
|
1374
|
+
inputs: {},
|
|
1375
|
+
kind: "value",
|
|
1376
|
+
name: n,
|
|
1377
|
+
values: { value: {
|
|
1378
|
+
jsonSchema: {},
|
|
1379
|
+
nullable: !0,
|
|
1380
|
+
value: null
|
|
1381
|
+
} }
|
|
1382
|
+
},
|
|
1383
|
+
nodeId: t,
|
|
1384
|
+
target: e
|
|
1385
|
+
}];
|
|
1386
|
+
}
|
|
1387
|
+
function U(e, t, n) {
|
|
1388
|
+
return [{
|
|
1389
|
+
kind: "graph.node.create",
|
|
1390
|
+
node: n,
|
|
1391
|
+
nodeId: t,
|
|
1392
|
+
target: e
|
|
1393
|
+
}];
|
|
1394
|
+
}
|
|
1395
|
+
function Ne(e, t, n, r) {
|
|
1396
|
+
let i = r.name ?? n.displayName, a = n.type == "poll" ? {
|
|
1397
|
+
bindingId: t.bindingId,
|
|
1398
|
+
config: r.config,
|
|
1399
|
+
definition: n,
|
|
1400
|
+
kind: "poll",
|
|
1401
|
+
name: i,
|
|
1402
|
+
pollTimes: r.schedule ?? [{
|
|
1403
|
+
type: "every",
|
|
1404
|
+
unit: "minute",
|
|
1405
|
+
value: 5
|
|
1406
|
+
}]
|
|
1407
|
+
} : {
|
|
1408
|
+
bindingId: t.bindingId,
|
|
1409
|
+
config: r.config,
|
|
1410
|
+
definition: n,
|
|
1411
|
+
kind: "integration",
|
|
1412
|
+
name: i
|
|
1413
|
+
};
|
|
1414
|
+
return [{
|
|
1415
|
+
binding: {
|
|
1416
|
+
kind: "connection",
|
|
1417
|
+
target: r.connectionId
|
|
1418
|
+
},
|
|
1419
|
+
bindingId: t.bindingId,
|
|
1420
|
+
kind: "binding.create"
|
|
1421
|
+
}, {
|
|
1422
|
+
kind: "graph.node.create",
|
|
1423
|
+
node: a,
|
|
1424
|
+
nodeId: t.nodeId,
|
|
1425
|
+
target: e
|
|
1426
|
+
}];
|
|
1427
|
+
}
|
|
1428
|
+
function Pe(e, t, n) {
|
|
1429
|
+
let r = W(e, t)?.nodes;
|
|
1430
|
+
if (r == null) return [];
|
|
1431
|
+
let i = new Set(n), a = n.flatMap((e) => {
|
|
1432
|
+
let n = r[e];
|
|
1433
|
+
return n == null ? [] : [{
|
|
1434
|
+
kind: "graph.node.delete",
|
|
1435
|
+
nodeId: e,
|
|
1436
|
+
target: t
|
|
1437
|
+
}, ...n.kind == "task" && n.task != null ? [{
|
|
1438
|
+
kind: "module.delete",
|
|
1439
|
+
moduleId: n.task.moduleId
|
|
1440
|
+
}] : []];
|
|
1441
|
+
});
|
|
1442
|
+
if (t.kind == "subflow") return a;
|
|
1443
|
+
let o = new Set(n.flatMap((e) => {
|
|
1444
|
+
let t = r[e];
|
|
1445
|
+
return t?.kind == "poll" || t?.kind == "integration" ? [t.bindingId] : [];
|
|
1446
|
+
}));
|
|
1447
|
+
for (let n of o) Object.entries(e.document.flows).some(([e, r]) => Object.entries(r.graph.nodes).some(([r, a]) => !(e == t.id && i.has(r)) && (a.kind == "poll" || a.kind == "integration") && a.bindingId == n)) || a.push({
|
|
1448
|
+
bindingId: n,
|
|
1449
|
+
kind: "binding.delete"
|
|
1450
|
+
});
|
|
1451
|
+
return a;
|
|
1452
|
+
}
|
|
1453
|
+
function Fe(e, t, n, r) {
|
|
1454
|
+
let i = W(e, t)?.nodes[n];
|
|
1455
|
+
if (i == null || !("inputs" in i)) return;
|
|
1456
|
+
let { concurrency: a, name: o, timeoutMs: s, ...c } = i;
|
|
1457
|
+
return q(t, n, {
|
|
1458
|
+
...c,
|
|
1459
|
+
...r
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1462
|
+
function Ie(e, t, n, r, i) {
|
|
1463
|
+
return Le(e, t, n, { [r]: i });
|
|
1464
|
+
}
|
|
1465
|
+
function Le(e, t, n, r) {
|
|
1466
|
+
let i = W(e, t)?.nodes[n];
|
|
1467
|
+
if (i == null || !("inputs" in i)) return;
|
|
1468
|
+
let a = { ...i.inputs };
|
|
1469
|
+
for (let [e, t] of Object.entries(r)) t === void 0 ? delete a[e] : a[e] = {
|
|
1470
|
+
kind: "value",
|
|
1471
|
+
value: t
|
|
1472
|
+
};
|
|
1473
|
+
return q(t, n, {
|
|
1474
|
+
...i,
|
|
1475
|
+
inputs: a
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
function Re(e, t, n) {
|
|
1479
|
+
let r = e.document.tasks[t];
|
|
1480
|
+
if (!(r == null || !("executor" in r) || r.executor.kind != "connector")) return [{
|
|
1481
|
+
kind: "task.replace",
|
|
1482
|
+
task: {
|
|
1483
|
+
...r,
|
|
1484
|
+
executor: {
|
|
1485
|
+
...r.executor,
|
|
1486
|
+
connectionId: n
|
|
1487
|
+
}
|
|
1488
|
+
},
|
|
1489
|
+
taskId: t
|
|
1490
|
+
}];
|
|
1491
|
+
}
|
|
1492
|
+
function ze(e, t, n, r) {
|
|
1493
|
+
let i = e.document.flows[t.id]?.graph.nodes[n];
|
|
1494
|
+
if (i == null) return;
|
|
1495
|
+
let a = {
|
|
1496
|
+
...r.description == null ? {} : { description: r.description },
|
|
1497
|
+
name: r.name
|
|
1498
|
+
}, o;
|
|
1499
|
+
switch (r.kind) {
|
|
1500
|
+
case "webhook":
|
|
1501
|
+
if (i.kind != "webhook") return;
|
|
1502
|
+
o = Object.keys(r.options).length == 0 ? {
|
|
1503
|
+
...a,
|
|
1504
|
+
inputsDef: r.inputs,
|
|
1505
|
+
kind: "webhook"
|
|
1506
|
+
} : {
|
|
1507
|
+
...a,
|
|
1508
|
+
inputsDef: r.inputs,
|
|
1509
|
+
kind: "webhook",
|
|
1510
|
+
options: r.options
|
|
1511
|
+
};
|
|
1512
|
+
break;
|
|
1513
|
+
case "cron":
|
|
1514
|
+
if (i.kind != "cron") return;
|
|
1515
|
+
o = {
|
|
1516
|
+
...a,
|
|
1517
|
+
cronTimes: r.schedule,
|
|
1518
|
+
kind: "cron"
|
|
1519
|
+
};
|
|
1520
|
+
break;
|
|
1521
|
+
case "poll":
|
|
1522
|
+
if (i.kind != "poll") return;
|
|
1523
|
+
o = {
|
|
1524
|
+
...i,
|
|
1525
|
+
...a,
|
|
1526
|
+
config: r.config,
|
|
1527
|
+
pollTimes: r.schedule
|
|
1528
|
+
};
|
|
1529
|
+
break;
|
|
1530
|
+
case "integration":
|
|
1531
|
+
if (i.kind != "integration") return;
|
|
1532
|
+
o = {
|
|
1533
|
+
...i,
|
|
1534
|
+
...a,
|
|
1535
|
+
config: r.config
|
|
1536
|
+
};
|
|
1537
|
+
}
|
|
1538
|
+
return q(t, n, o);
|
|
1539
|
+
}
|
|
1540
|
+
function Be(e, t, n, r, i) {
|
|
1541
|
+
let a = e.document.flows[t.id]?.graph.nodes[n];
|
|
1542
|
+
if (a == null || a.kind != "integration" && a.kind != "poll") return;
|
|
1543
|
+
let o = { ...a.config };
|
|
1544
|
+
return i === void 0 ? delete o[r] : o[r] = i, q(t, n, {
|
|
1545
|
+
...a,
|
|
1546
|
+
config: o
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1549
|
+
function Ve(e, t, n, r) {
|
|
1550
|
+
let i = e.document.flows[t.id]?.graph.nodes[n];
|
|
1551
|
+
if (i != null) switch (i.kind) {
|
|
1552
|
+
case "cron": return q(t, n, {
|
|
1553
|
+
...i,
|
|
1554
|
+
cronTimes: r
|
|
1555
|
+
});
|
|
1556
|
+
case "poll": return q(t, n, {
|
|
1557
|
+
...i,
|
|
1558
|
+
pollTimes: r
|
|
1559
|
+
});
|
|
1560
|
+
case "integration":
|
|
1561
|
+
case "webhook": return;
|
|
1562
|
+
default: return;
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
function He(e, t, n, r) {
|
|
1566
|
+
let i = e.document.flows[t.id]?.graph.nodes[n];
|
|
1567
|
+
if (!(i == null || i.kind != "poll" && i.kind != "integration") && e.document.bindings[i.bindingId]?.kind == "connection") return [{
|
|
1568
|
+
binding: {
|
|
1569
|
+
kind: "connection",
|
|
1570
|
+
target: r
|
|
1571
|
+
},
|
|
1572
|
+
bindingId: i.bindingId,
|
|
1573
|
+
kind: "binding.replace"
|
|
1574
|
+
}];
|
|
1575
|
+
}
|
|
1576
|
+
function W(e, t) {
|
|
1577
|
+
return t.kind == "flow" ? e.document.flows[t.id]?.graph : e.document.subflows[t.id]?.graph;
|
|
1578
|
+
}
|
|
1579
|
+
function G(e) {
|
|
1580
|
+
return Object.fromEntries(Object.entries(e).flatMap(([e, t]) => Object.hasOwn(t, "value") ? [[e, {
|
|
1581
|
+
kind: "value",
|
|
1582
|
+
value: t.value
|
|
1583
|
+
}]] : []));
|
|
1584
|
+
}
|
|
1585
|
+
function K(e, t, n) {
|
|
1586
|
+
return e != null && Object.hasOwn(e, t) ? e[t] : n;
|
|
1587
|
+
}
|
|
1588
|
+
function q(e, t, n) {
|
|
1589
|
+
return [{
|
|
1590
|
+
kind: "graph.node.replace",
|
|
1591
|
+
node: n,
|
|
1592
|
+
nodeId: t,
|
|
1593
|
+
target: e
|
|
1594
|
+
}];
|
|
1595
|
+
}
|
|
1596
|
+
//#endregion
|
|
1597
|
+
//#region src/workbench/browser/runtime/designer/diagnostics.ts
|
|
1598
|
+
function Ue(e, t) {
|
|
1599
|
+
return t == e || t.startsWith(`${e}/`);
|
|
1600
|
+
}
|
|
1601
|
+
function We(e, t) {
|
|
1602
|
+
return t.kind == "flow" ? t.id : e.flowIdsUsingSubflow(t.id)[0];
|
|
1603
|
+
}
|
|
1604
|
+
function Ge(e, t, n, r) {
|
|
1605
|
+
if (e == null || t == null || n == null) return [];
|
|
1606
|
+
if (r != null) return Xe(t, r, n.diagnostics);
|
|
1607
|
+
let i = `/document/${t.kind == "flow" ? "flows" : "subflows"}/${t.id}`;
|
|
1608
|
+
return n.diagnostics.filter((e) => Ue(i, e.path));
|
|
1609
|
+
}
|
|
1610
|
+
function Ke(e) {
|
|
1611
|
+
return e.startsWith("/modules/") ? "code" : /\/graph\/nodes\/[^/]+\/task(?:\/|$)/.test(e) ? "task" : e.includes("/graph/nodes/") ? "node" : e.startsWith("/document/tasks/") ? "task" : e.startsWith("/document/flows/") ? "flow" : "project";
|
|
1612
|
+
}
|
|
1613
|
+
function qe(e, t) {
|
|
1614
|
+
return t.startsWith("/inputs/") ? "inputs" : e.kind == "task" && t.startsWith("/task") ? "task" : e.kind == "condition" && (t.startsWith("/cases/") || t.startsWith("/input") || t.startsWith("/defaultOutput")) ? "condition" : "node";
|
|
1615
|
+
}
|
|
1616
|
+
function Je(e, t, n) {
|
|
1617
|
+
if (e == null || t == null) return;
|
|
1618
|
+
let r = `/document/${t.kind == "flow" ? "flows" : "subflows"}/${t.id}/graph/nodes/`;
|
|
1619
|
+
if (n.path.startsWith(r)) {
|
|
1620
|
+
let i = n.path.slice(r.length), a = i.indexOf("/"), o = a < 0 ? i : i.slice(0, a), s = e.node(t, o);
|
|
1621
|
+
return s == null ? void 0 : {
|
|
1622
|
+
nodeId: o,
|
|
1623
|
+
section: qe(s.node, a < 0 ? "" : i.slice(a))
|
|
1624
|
+
};
|
|
1625
|
+
}
|
|
1626
|
+
let i = /^\/document\/tasks\/([^/]+)(.*)$/.exec(n.path);
|
|
1627
|
+
if (i != null) {
|
|
1628
|
+
let n = e.findTaskNode(t, /* @__PURE__ */ new Set([i[1]]));
|
|
1629
|
+
return n == null ? void 0 : {
|
|
1630
|
+
nodeId: n,
|
|
1631
|
+
section: i[2].startsWith("/executor") ? "account" : "task"
|
|
1632
|
+
};
|
|
1633
|
+
}
|
|
1634
|
+
let a = /^\/modules\/([^/]+)\/source$/.exec(n.path);
|
|
1635
|
+
if (a != null) {
|
|
1636
|
+
let n = e.findModuleNode(t, a[1]);
|
|
1637
|
+
if (n != null) return {
|
|
1638
|
+
nodeId: n,
|
|
1639
|
+
section: "module"
|
|
1640
|
+
};
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
function Ye(e, t, n) {
|
|
1644
|
+
return n?.diagnostics.map((n) => ({
|
|
1645
|
+
diagnostic: n,
|
|
1646
|
+
location: Je(e, t, n),
|
|
1647
|
+
scope: Ke(n.path)
|
|
1648
|
+
})) ?? [];
|
|
1649
|
+
}
|
|
1650
|
+
function Xe(e, t, n) {
|
|
1651
|
+
let r = `/document/${e.kind == "flow" ? "flows" : "subflows"}/${e.id}/graph/nodes/${t.id}`, i = [r];
|
|
1652
|
+
if (t.kind == "task") {
|
|
1653
|
+
t.node.task == null ? i.push(`/document/tasks/${t.node.taskId}`) : i.push(`${r}/task`);
|
|
1654
|
+
let e = t.definition != null && "moduleId" in t.definition ? t.definition.moduleId : void 0;
|
|
1655
|
+
e != null && i.push(`/modules/${e}`);
|
|
1656
|
+
} else t.kind == "subflow" && i.push(`/document/subflows/${t.node.subflowId}`);
|
|
1657
|
+
return n.filter((e) => i.some((t) => Ue(t, e.path)));
|
|
1658
|
+
}
|
|
1659
|
+
//#endregion
|
|
1660
|
+
//#region src/workbench/browser/runtime/designer/projectChanges.ts
|
|
1661
|
+
function J(e, n) {
|
|
1662
|
+
return {
|
|
1663
|
+
...e,
|
|
1664
|
+
content: t(e.content, n)
|
|
1665
|
+
};
|
|
1666
|
+
}
|
|
1667
|
+
function Ze(e, t, n) {
|
|
1668
|
+
return e == "flow" ? we(t, n) : [{
|
|
1669
|
+
kind: "subflow.create",
|
|
1670
|
+
subflow: {
|
|
1671
|
+
graph: { nodes: {} },
|
|
1672
|
+
inputs: { value: {
|
|
1673
|
+
jsonSchema: {},
|
|
1674
|
+
nullable: !0,
|
|
1675
|
+
value: null
|
|
1676
|
+
} },
|
|
1677
|
+
name: n,
|
|
1678
|
+
outputs: { result: {
|
|
1679
|
+
jsonSchema: {},
|
|
1680
|
+
nullable: !0,
|
|
1681
|
+
sources: [{
|
|
1682
|
+
input: "value",
|
|
1683
|
+
kind: "flow"
|
|
1684
|
+
}]
|
|
1685
|
+
} }
|
|
1686
|
+
},
|
|
1687
|
+
subflowId: t
|
|
1688
|
+
}];
|
|
1689
|
+
}
|
|
1690
|
+
function Qe(e, t, n, r, i) {
|
|
1691
|
+
switch (r.kind) {
|
|
1692
|
+
case "code": return ke(t, {
|
|
1693
|
+
moduleId: i(),
|
|
1694
|
+
nodeId: n
|
|
1695
|
+
}, r.name);
|
|
1696
|
+
case "llm": return Ae(t, {
|
|
1697
|
+
nodeId: n,
|
|
1698
|
+
taskId: i()
|
|
1699
|
+
}, r.name, r.mode, r.outputDescription);
|
|
1700
|
+
case "connector": return H(t, {
|
|
1701
|
+
nodeId: n,
|
|
1702
|
+
taskId: i()
|
|
1703
|
+
}, {
|
|
1704
|
+
executor: {
|
|
1705
|
+
action: r.action.actionId,
|
|
1706
|
+
...r.action.defaultConnection == null ? {} : { connectionId: r.action.defaultConnection.connectionId },
|
|
1707
|
+
kind: "connector"
|
|
1708
|
+
},
|
|
1709
|
+
inputs: r.action.inputs,
|
|
1710
|
+
name: r.action.name,
|
|
1711
|
+
outputs: r.action.outputs
|
|
1712
|
+
});
|
|
1713
|
+
case "condition": return je(t, n, r.name);
|
|
1714
|
+
case "value": return Me(t, n, r.name);
|
|
1715
|
+
case "subflow": {
|
|
1716
|
+
let i = e.subflow(r.subflowId);
|
|
1717
|
+
return i == null ? void 0 : dt(t, n, r.subflowId, i.inputs);
|
|
1718
|
+
}
|
|
1719
|
+
case "webhook": return t.kind == "flow" ? U(t, n, {
|
|
1720
|
+
inputsDef: [],
|
|
1721
|
+
kind: "webhook",
|
|
1722
|
+
name: r.name
|
|
1723
|
+
}) : void 0;
|
|
1724
|
+
case "cron": return t.kind == "flow" ? U(t, n, {
|
|
1725
|
+
cronTimes: [{
|
|
1726
|
+
type: "every",
|
|
1727
|
+
unit: "hour",
|
|
1728
|
+
value: 1
|
|
1729
|
+
}],
|
|
1730
|
+
kind: "cron",
|
|
1731
|
+
name: r.name
|
|
1732
|
+
}) : void 0;
|
|
1733
|
+
case "provider-trigger": return t.kind == "flow" ? Ne(t, {
|
|
1734
|
+
bindingId: i(),
|
|
1735
|
+
nodeId: n
|
|
1736
|
+
}, r.definition, {
|
|
1737
|
+
config: {},
|
|
1738
|
+
connectionId: r.connectionId
|
|
1739
|
+
}) : void 0;
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
function $e(e, t, n) {
|
|
1743
|
+
return Pe(e.revision.content, t, n);
|
|
1744
|
+
}
|
|
1745
|
+
function et(e, t, n) {
|
|
1746
|
+
let r = e.graph(t)?.nodes ?? {}, i = Object.fromEntries(n.flatMap((e) => r[e] == null ? [] : [[e, r[e]]]));
|
|
1747
|
+
return {
|
|
1748
|
+
modules: Object.fromEntries(Object.values(i).flatMap((t) => {
|
|
1749
|
+
if (t.kind != "task" || t.task == null) return [];
|
|
1750
|
+
let n = e.revision.content.modules[t.task.moduleId];
|
|
1751
|
+
return n == null ? [] : [[t.task.moduleId, n]];
|
|
1752
|
+
})),
|
|
1753
|
+
nodes: i
|
|
1754
|
+
};
|
|
1755
|
+
}
|
|
1756
|
+
function tt(e, t, n, r) {
|
|
1757
|
+
if (e.graph(t) == null) return {
|
|
1758
|
+
changes: [],
|
|
1759
|
+
nodeIds: [],
|
|
1760
|
+
sourceIds: []
|
|
1761
|
+
};
|
|
1762
|
+
let i = Object.entries(n.nodes).filter(([, e]) => (t.kind == "flow" || "inputs" in e) && (e.kind != "task" || e.task == null || n.modules[e.task.moduleId] != null)), a = i.map(([e]) => e), o = new Map(a.map((e) => [e, r()])), s = [];
|
|
1763
|
+
for (let [a, c] of i) {
|
|
1764
|
+
let i = o.get(a);
|
|
1765
|
+
if (!("inputs" in c)) {
|
|
1766
|
+
if (c.kind == "poll" || c.kind == "integration") {
|
|
1767
|
+
let n = e.binding(c.bindingId);
|
|
1768
|
+
if (n == null) continue;
|
|
1769
|
+
let a = r();
|
|
1770
|
+
s.push({
|
|
1771
|
+
binding: n,
|
|
1772
|
+
bindingId: a,
|
|
1773
|
+
kind: "binding.create"
|
|
1774
|
+
}), s.push({
|
|
1775
|
+
kind: "graph.node.create",
|
|
1776
|
+
node: {
|
|
1777
|
+
...c,
|
|
1778
|
+
bindingId: a,
|
|
1779
|
+
name: `${c.name} copy`
|
|
1780
|
+
},
|
|
1781
|
+
nodeId: i,
|
|
1782
|
+
target: t
|
|
1783
|
+
});
|
|
1784
|
+
} else s.push({
|
|
1785
|
+
kind: "graph.node.create",
|
|
1786
|
+
node: {
|
|
1787
|
+
...c,
|
|
1788
|
+
name: `${c.name} copy`
|
|
1789
|
+
},
|
|
1790
|
+
nodeId: i,
|
|
1791
|
+
target: t
|
|
1792
|
+
});
|
|
1793
|
+
continue;
|
|
1794
|
+
}
|
|
1795
|
+
let l = {};
|
|
1796
|
+
for (let [e, t] of Object.entries(c.inputs)) {
|
|
1797
|
+
if (t.kind == "value") {
|
|
1798
|
+
l[e] = t;
|
|
1799
|
+
continue;
|
|
1800
|
+
}
|
|
1801
|
+
let n = [];
|
|
1802
|
+
for (let e of t.sources) {
|
|
1803
|
+
if (e.kind != "node") {
|
|
1804
|
+
n.push(e);
|
|
1805
|
+
continue;
|
|
1806
|
+
}
|
|
1807
|
+
let t = o.get(e.nodeId);
|
|
1808
|
+
t != null && n.push({
|
|
1809
|
+
...e,
|
|
1810
|
+
nodeId: t
|
|
1811
|
+
});
|
|
1812
|
+
}
|
|
1813
|
+
n.length > 0 && (l[e] = {
|
|
1814
|
+
kind: "sources",
|
|
1815
|
+
sources: n
|
|
1816
|
+
});
|
|
1817
|
+
}
|
|
1818
|
+
let u = {
|
|
1819
|
+
...c,
|
|
1820
|
+
inputs: l,
|
|
1821
|
+
...c.name == null ? {} : { name: `${c.name} copy` }
|
|
1822
|
+
};
|
|
1823
|
+
if (c.kind == "task" && c.task != null) {
|
|
1824
|
+
let e = r(), t = n.modules[c.task.moduleId];
|
|
1825
|
+
s.push({
|
|
1826
|
+
kind: "module.create",
|
|
1827
|
+
module: {
|
|
1828
|
+
...t,
|
|
1829
|
+
name: `${t.name} copy`
|
|
1830
|
+
},
|
|
1831
|
+
moduleId: e
|
|
1832
|
+
}), u = {
|
|
1833
|
+
...c,
|
|
1834
|
+
inputs: l,
|
|
1835
|
+
...c.name == null ? {} : { name: `${c.name} copy` },
|
|
1836
|
+
task: {
|
|
1837
|
+
...c.task,
|
|
1838
|
+
moduleId: e,
|
|
1839
|
+
name: `${c.task.name} copy`
|
|
1840
|
+
}
|
|
1841
|
+
};
|
|
1842
|
+
}
|
|
1843
|
+
s.push({
|
|
1844
|
+
kind: "graph.node.create",
|
|
1845
|
+
node: u,
|
|
1846
|
+
nodeId: i,
|
|
1847
|
+
target: t
|
|
1848
|
+
});
|
|
1849
|
+
}
|
|
1850
|
+
return {
|
|
1851
|
+
changes: s,
|
|
1852
|
+
nodeIds: [...o.values()],
|
|
1853
|
+
sourceIds: a
|
|
1854
|
+
};
|
|
1855
|
+
}
|
|
1856
|
+
function nt(e, t, n, r) {
|
|
1857
|
+
return Fe(e.revision.content, t, n, r);
|
|
1858
|
+
}
|
|
1859
|
+
function rt(e, t, n, r) {
|
|
1860
|
+
let i = e.node(t, n)?.node;
|
|
1861
|
+
if (i == null) return;
|
|
1862
|
+
let { description: a, ...o } = i;
|
|
1863
|
+
return Y(t, n, r == null ? o : {
|
|
1864
|
+
...o,
|
|
1865
|
+
description: r
|
|
1866
|
+
});
|
|
1867
|
+
}
|
|
1868
|
+
function it(e, t, n, r, i) {
|
|
1869
|
+
return Ie(e.revision.content, t, n, r, i);
|
|
1870
|
+
}
|
|
1871
|
+
function at(e, t, n, r) {
|
|
1872
|
+
let i = e.node(t, n)?.node;
|
|
1873
|
+
if (i?.kind != "condition") return;
|
|
1874
|
+
let { defaultOutput: a, ...o } = i;
|
|
1875
|
+
return Y(t, n, {
|
|
1876
|
+
...o,
|
|
1877
|
+
...r
|
|
1878
|
+
});
|
|
1879
|
+
}
|
|
1880
|
+
function ot(e, t, n, r) {
|
|
1881
|
+
let i = e.node(t, n)?.node;
|
|
1882
|
+
if (i?.kind == "value") return Y(t, n, {
|
|
1883
|
+
...i,
|
|
1884
|
+
values: Object.fromEntries(r.map((e) => [e.handle, {
|
|
1885
|
+
...e.description == null ? {} : { description: e.description },
|
|
1886
|
+
jsonSchema: e.jsonSchema ?? {},
|
|
1887
|
+
nullable: e.nullable ?? !1,
|
|
1888
|
+
...Object.hasOwn(e, "value") ? { value: e.value } : {}
|
|
1889
|
+
}]))
|
|
1890
|
+
});
|
|
1891
|
+
}
|
|
1892
|
+
function st(e, t, n, r) {
|
|
1893
|
+
let i = e.graph(t)?.nodes[n];
|
|
1894
|
+
if (i?.kind == "task") switch (r.kind) {
|
|
1895
|
+
case "code": return i.task == null ? void 0 : mt(e, t, n, {
|
|
1896
|
+
...i.task,
|
|
1897
|
+
inputs: r.inputs,
|
|
1898
|
+
name: r.name,
|
|
1899
|
+
outputs: r.outputs
|
|
1900
|
+
});
|
|
1901
|
+
case "llm": return i.task != null || e.task(i.taskId)?.executor.kind != "llm" ? void 0 : [{
|
|
1902
|
+
kind: "task.replace",
|
|
1903
|
+
task: {
|
|
1904
|
+
executor: {
|
|
1905
|
+
kind: "llm",
|
|
1906
|
+
mode: r.mode
|
|
1907
|
+
},
|
|
1908
|
+
inputs: r.inputs,
|
|
1909
|
+
name: r.name,
|
|
1910
|
+
outputs: r.outputs
|
|
1911
|
+
},
|
|
1912
|
+
taskId: i.taskId
|
|
1913
|
+
}];
|
|
1914
|
+
case "connector": {
|
|
1915
|
+
if (i.task != null) return;
|
|
1916
|
+
let t = e.task(i.taskId);
|
|
1917
|
+
return t?.executor.kind == "connector" ? [{
|
|
1918
|
+
kind: "task.replace",
|
|
1919
|
+
task: {
|
|
1920
|
+
executor: t.executor,
|
|
1921
|
+
inputs: r.inputs,
|
|
1922
|
+
name: r.name,
|
|
1923
|
+
outputs: r.outputs
|
|
1924
|
+
},
|
|
1925
|
+
taskId: i.taskId
|
|
1926
|
+
}] : void 0;
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
function ct(e, t, n, r) {
|
|
1931
|
+
let i = e.graph(t)?.nodes[n];
|
|
1932
|
+
if (i?.kind == "task" && i.task != null) return mt(e, t, n, {
|
|
1933
|
+
...i.task,
|
|
1934
|
+
...r
|
|
1935
|
+
});
|
|
1936
|
+
}
|
|
1937
|
+
function lt(e, t, n, r) {
|
|
1938
|
+
let i = e.trigger(t.id, n);
|
|
1939
|
+
if (i == null || i.kind != "webhook") return;
|
|
1940
|
+
let { options: a, ...o } = i;
|
|
1941
|
+
return Y(t, n, Object.keys(r.options).length == 0 ? {
|
|
1942
|
+
...o,
|
|
1943
|
+
inputsDef: r.inputs
|
|
1944
|
+
} : {
|
|
1945
|
+
...i,
|
|
1946
|
+
inputsDef: r.inputs,
|
|
1947
|
+
options: r.options
|
|
1948
|
+
});
|
|
1949
|
+
}
|
|
1950
|
+
function ut(e, t, n) {
|
|
1951
|
+
if (e.subflow(t) != null) return [{
|
|
1952
|
+
definition: n,
|
|
1953
|
+
kind: "subflow.definition.replace",
|
|
1954
|
+
subflowId: t
|
|
1955
|
+
}];
|
|
1956
|
+
}
|
|
1957
|
+
function dt(e, t, n, r) {
|
|
1958
|
+
return [{
|
|
1959
|
+
kind: "graph.node.create",
|
|
1960
|
+
node: {
|
|
1961
|
+
concurrency: 1,
|
|
1962
|
+
inputs: ft(r),
|
|
1963
|
+
kind: "subflow",
|
|
1964
|
+
subflowId: n
|
|
1965
|
+
},
|
|
1966
|
+
nodeId: t,
|
|
1967
|
+
target: e
|
|
1968
|
+
}];
|
|
1969
|
+
}
|
|
1970
|
+
function ft(e) {
|
|
1971
|
+
return Object.fromEntries(Object.entries(e).flatMap(([e, t]) => Object.hasOwn(t, "value") ? [[e, {
|
|
1972
|
+
kind: "value",
|
|
1973
|
+
value: t.value
|
|
1974
|
+
}]] : []));
|
|
1975
|
+
}
|
|
1976
|
+
function pt(e, t) {
|
|
1977
|
+
let n = Object.keys(e).filter((e) => !Object.hasOwn(t, e)), r = Object.keys(t).filter((t) => !Object.hasOwn(e, t));
|
|
1978
|
+
return n.length == 1 && r.length == 1 ? [n[0], r[0]] : void 0;
|
|
1979
|
+
}
|
|
1980
|
+
function mt(e, t, n, r) {
|
|
1981
|
+
let i = e.graph(t), a = i?.nodes[n];
|
|
1982
|
+
if (i == null || a?.kind != "task" || a.task == null) return;
|
|
1983
|
+
let o = pt(a.task.inputs, r.inputs), s = pt(a.task.outputs, r.outputs), c = new Set(Object.keys(r.outputs)), l = [];
|
|
1984
|
+
for (let [e, u] of Object.entries(i.nodes)) {
|
|
1985
|
+
if (!("inputs" in u)) continue;
|
|
1986
|
+
let i = e == n, d = { ...u.inputs };
|
|
1987
|
+
if (e == n) {
|
|
1988
|
+
o != null && Object.hasOwn(d, o[0]) && (d[o[1]] = d[o[0]], delete d[o[0]]);
|
|
1989
|
+
for (let e of Object.keys(d)) Object.hasOwn(r.inputs, e) || delete d[e];
|
|
1990
|
+
}
|
|
1991
|
+
for (let [e, t] of Object.entries(d)) {
|
|
1992
|
+
if (t.kind != "sources") continue;
|
|
1993
|
+
let r = t.sources.flatMap((e) => e.kind != "node" || e.nodeId != n ? [e] : s != null && e.output == s[0] ? [{
|
|
1994
|
+
...e,
|
|
1995
|
+
output: s[1]
|
|
1996
|
+
}] : c.has(e.output) ? [e] : []);
|
|
1997
|
+
r.length == t.sources.length && r.every((e, n) => e === t.sources[n]) || (i = !0, r.length == 0 ? delete d[e] : d[e] = {
|
|
1998
|
+
kind: "sources",
|
|
1999
|
+
sources: r
|
|
2000
|
+
});
|
|
2001
|
+
}
|
|
2002
|
+
if (!i) continue;
|
|
2003
|
+
let f = e == n ? {
|
|
2004
|
+
...a,
|
|
2005
|
+
inputs: d,
|
|
2006
|
+
task: r
|
|
2007
|
+
} : {
|
|
2008
|
+
...u,
|
|
2009
|
+
inputs: d
|
|
2010
|
+
};
|
|
2011
|
+
l.push({
|
|
2012
|
+
kind: "graph.node.replace",
|
|
2013
|
+
node: f,
|
|
2014
|
+
nodeId: e,
|
|
2015
|
+
target: t
|
|
2016
|
+
});
|
|
2017
|
+
}
|
|
2018
|
+
return l;
|
|
2019
|
+
}
|
|
2020
|
+
function Y(e, t, n) {
|
|
2021
|
+
return [{
|
|
2022
|
+
kind: "graph.node.replace",
|
|
2023
|
+
node: n,
|
|
2024
|
+
nodeId: t,
|
|
2025
|
+
target: e
|
|
2026
|
+
}];
|
|
2027
|
+
}
|
|
2028
|
+
//#endregion
|
|
2029
|
+
//#region src/workbench/browser/runtime/designer/remoteChangeTargets.ts
|
|
2030
|
+
function ht(e, t) {
|
|
2031
|
+
return e.kind == t.kind && e.id == t.id;
|
|
2032
|
+
}
|
|
2033
|
+
function X(e, t, n, r) {
|
|
2034
|
+
for (let [i, a] of Object.entries(t.graph(n)?.nodes ?? {})) r(a) && e.add(i);
|
|
2035
|
+
}
|
|
2036
|
+
function gt(e, t, n, r) {
|
|
2037
|
+
let i = /* @__PURE__ */ new Set();
|
|
2038
|
+
for (let a of r) switch (a.kind) {
|
|
2039
|
+
case "graph.node.create":
|
|
2040
|
+
case "graph.node.replace":
|
|
2041
|
+
ht(a.target, n) && i.add(a.nodeId);
|
|
2042
|
+
break;
|
|
2043
|
+
case "task.replace":
|
|
2044
|
+
X(i, e, n, (e) => e.kind == "task" && e.task == null && e.taskId == a.taskId), X(i, t, n, (e) => e.kind == "task" && e.task == null && e.taskId == a.taskId);
|
|
2045
|
+
break;
|
|
2046
|
+
case "module.source.replace":
|
|
2047
|
+
X(i, e, n, (e) => e.kind == "task" && e.task?.moduleId == a.moduleId), X(i, t, n, (e) => e.kind == "task" && e.task?.moduleId == a.moduleId);
|
|
2048
|
+
break;
|
|
2049
|
+
case "subflow.definition.replace": X(i, e, n, (e) => e.kind == "subflow" && e.subflowId == a.subflowId), X(i, t, n, (e) => e.kind == "subflow" && e.subflowId == a.subflowId);
|
|
2050
|
+
}
|
|
2051
|
+
return new Set([...i].filter((e) => t.selection(n, e) != null));
|
|
2052
|
+
}
|
|
2053
|
+
//#endregion
|
|
2054
|
+
//#region src/workbench/browser/runtime/stores/draftChanges.ts
|
|
2055
|
+
function _t(e) {
|
|
2056
|
+
if (e.length != 1) return;
|
|
2057
|
+
let t = e[0];
|
|
2058
|
+
switch (t.kind) {
|
|
2059
|
+
case "binding.replace": return `${t.kind}:${t.bindingId}`;
|
|
2060
|
+
case "flow.rename": return `${t.kind}:${t.flowId}`;
|
|
2061
|
+
case "graph.node.replace": return `${t.kind}:${t.target.kind}:${t.target.id}:${t.nodeId}`;
|
|
2062
|
+
case "module.rename":
|
|
2063
|
+
case "module.source.replace": return `${t.kind}:${t.moduleId}`;
|
|
2064
|
+
case "subflow.definition.replace": return `${t.kind}:${t.subflowId}`;
|
|
2065
|
+
case "task.replace": return `${t.kind}:${t.taskId}`;
|
|
2066
|
+
default: return;
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
function vt(e, t, n) {
|
|
2070
|
+
let r = new Map(e.map((e) => [e.flowId, e])), i = new Map(t.map((e) => [e.flowId, e]));
|
|
2071
|
+
return [...i.keys()].toSorted().map((e) => {
|
|
2072
|
+
let t = r.get(e), a = i.get(e), o = t?.live ?? null;
|
|
2073
|
+
return {
|
|
2074
|
+
draft: {
|
|
2075
|
+
closureDigest: a.closureDigest,
|
|
2076
|
+
name: a.name,
|
|
2077
|
+
revisionDigest: n.digest,
|
|
2078
|
+
revisionId: n.revisionId
|
|
2079
|
+
},
|
|
2080
|
+
flowId: e,
|
|
2081
|
+
hasUnpublishedChanges: o == null || o.publication.closureDigest != a.closureDigest,
|
|
2082
|
+
live: o
|
|
2083
|
+
};
|
|
2084
|
+
});
|
|
2085
|
+
}
|
|
2086
|
+
var yt = class {
|
|
2087
|
+
#e;
|
|
2088
|
+
#t;
|
|
2089
|
+
#n;
|
|
2090
|
+
#r;
|
|
2091
|
+
#i = 0;
|
|
2092
|
+
#a;
|
|
2093
|
+
#o = [];
|
|
2094
|
+
#s = Promise.resolve();
|
|
2095
|
+
constructor(e, t, n, r) {
|
|
2096
|
+
this.#e = e, this.#r = t, this.#n = n, this.#t = r;
|
|
2097
|
+
}
|
|
2098
|
+
get committed() {
|
|
2099
|
+
return this.#a;
|
|
2100
|
+
}
|
|
2101
|
+
get changing() {
|
|
2102
|
+
return this.#i > 0;
|
|
2103
|
+
}
|
|
2104
|
+
get pendingCount() {
|
|
2105
|
+
return this.#o.length;
|
|
2106
|
+
}
|
|
2107
|
+
reset(e) {
|
|
2108
|
+
this.#a = e, this.#o = [], this.#s = Promise.resolve();
|
|
2109
|
+
}
|
|
2110
|
+
replaceCommitted(e) {
|
|
2111
|
+
this.#a = e;
|
|
2112
|
+
}
|
|
2113
|
+
project(e) {
|
|
2114
|
+
return this.#o.reduce((e, t) => J(e, t.changes), e);
|
|
2115
|
+
}
|
|
2116
|
+
enqueue(e) {
|
|
2117
|
+
let t = this.#s.then(e);
|
|
2118
|
+
return this.#s = t, t;
|
|
2119
|
+
}
|
|
2120
|
+
async change(e, t, n, r = !0) {
|
|
2121
|
+
this.#t.beforeChange(r);
|
|
2122
|
+
let i = this.#t.flows();
|
|
2123
|
+
this.#t.apply(J(t, n), i, i);
|
|
2124
|
+
let a = _t(n), o = this.#o.at(-1), s = a != null && o != null && !o.started && _t(o.changes) == a ? o : void 0;
|
|
2125
|
+
if (s != null) return s.changes = n, await s.result;
|
|
2126
|
+
let c = {
|
|
2127
|
+
...e,
|
|
2128
|
+
changes: n,
|
|
2129
|
+
started: !1
|
|
2130
|
+
};
|
|
2131
|
+
this.#a ??= t, this.#o.push(c), this.#i += 1;
|
|
2132
|
+
let l = this.#s.then(() => (c.started = !0, this.#c(c)));
|
|
2133
|
+
c.result = l, this.#s = l.then(() => void 0);
|
|
2134
|
+
try {
|
|
2135
|
+
return await l;
|
|
2136
|
+
} finally {
|
|
2137
|
+
--this.#i, this.#i == 0 && this.#t.finishChanges();
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
async #c(e) {
|
|
2141
|
+
let t = !1;
|
|
2142
|
+
for (; this.#t.current(e);) {
|
|
2143
|
+
let n = this.#a;
|
|
2144
|
+
if (n == null) return;
|
|
2145
|
+
try {
|
|
2146
|
+
let t = await this.#e.changeDraft(e.projectId, n.revisionId, e.changes);
|
|
2147
|
+
if (!this.#t.current(e)) return;
|
|
2148
|
+
if (t.revision.parentRevisionId != n.revisionId) throw Error("Invalid Draft change response.");
|
|
2149
|
+
let r = this.#l(e, n, t);
|
|
2150
|
+
return this.#o.length == 0 && this.#t.check(), r;
|
|
2151
|
+
} catch (n) {
|
|
2152
|
+
if (n instanceof S && n.code == "project.revision-conflict") {
|
|
2153
|
+
if (!t && await this.#t.recover(e)) {
|
|
2154
|
+
t = !0;
|
|
2155
|
+
continue;
|
|
2156
|
+
}
|
|
2157
|
+
t && await this.#t.recover(e), this.#u(e), this.#t.current(e) && this.#r({
|
|
2158
|
+
kind: "error",
|
|
2159
|
+
message: this.#n.t("notice.draftConflict")
|
|
2160
|
+
});
|
|
2161
|
+
} else this.#u(e), this.#t.current(e) && this.#r(o(n, this.#n.t));
|
|
2162
|
+
return;
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
#l(e, t, n) {
|
|
2167
|
+
let r = {
|
|
2168
|
+
...n.revision,
|
|
2169
|
+
content: J(t, e.changes).content
|
|
2170
|
+
};
|
|
2171
|
+
this.#o = this.#o.filter((t) => t !== e), this.#a = r;
|
|
2172
|
+
let i = this.#t.flows(), a = vt(i, n.draftFlows, r), o = this.#t.diagnostics(), s = this.#o.length == 0 && o != null && a.find((e) => e.flowId == o.flowId)?.draft?.closureDigest == o.closureDigest;
|
|
2173
|
+
return this.#t.apply(this.project(r), a, i, s), this.#t.headChanged(e.projectId, r.revisionId), r;
|
|
2174
|
+
}
|
|
2175
|
+
#u(e) {
|
|
2176
|
+
if (this.#o = this.#o.filter((t) => t !== e), !this.#t.current(e) || this.#a == null) return;
|
|
2177
|
+
let t = this.#t.flows();
|
|
2178
|
+
this.#t.apply(this.project(this.#a), t, t);
|
|
2179
|
+
}
|
|
2180
|
+
}, bt = class {
|
|
2181
|
+
#e;
|
|
2182
|
+
#t;
|
|
2183
|
+
#n;
|
|
2184
|
+
#r;
|
|
2185
|
+
#i = Promise.resolve();
|
|
2186
|
+
#a;
|
|
2187
|
+
#o = !1;
|
|
2188
|
+
#s = [];
|
|
2189
|
+
constructor(e, t, n, r) {
|
|
2190
|
+
this.#e = e, this.#n = t, this.#r = n, this.#t = r;
|
|
2191
|
+
}
|
|
2192
|
+
reset(e) {
|
|
2193
|
+
this.#a = e, this.#s = [];
|
|
2194
|
+
}
|
|
2195
|
+
dispose() {
|
|
2196
|
+
this.#o = !0, this.#s = [];
|
|
2197
|
+
}
|
|
2198
|
+
async change(e, t, n, r) {
|
|
2199
|
+
if (this.#o || this.#a == null) return;
|
|
2200
|
+
let i = r(t.value);
|
|
2201
|
+
if (i === t.value) return;
|
|
2202
|
+
let a = {
|
|
2203
|
+
current: n,
|
|
2204
|
+
projectId: e,
|
|
2205
|
+
update: r
|
|
2206
|
+
};
|
|
2207
|
+
this.#s.push(a), this.#r({
|
|
2208
|
+
...t,
|
|
2209
|
+
value: i
|
|
2210
|
+
}), this.#i = this.#i.then(async () => {
|
|
2211
|
+
if (this.#o || !n()) return;
|
|
2212
|
+
let t = this.#a, i = r(t.value);
|
|
2213
|
+
if (i === t.value) {
|
|
2214
|
+
this.#c(a, t);
|
|
2215
|
+
return;
|
|
2216
|
+
}
|
|
2217
|
+
try {
|
|
2218
|
+
let r = await this.#e.updatePresentation(e, t.revision, i);
|
|
2219
|
+
if (this.#o || !n()) return;
|
|
2220
|
+
this.#c(a, r);
|
|
2221
|
+
} catch (r) {
|
|
2222
|
+
if (this.#o || !n()) return;
|
|
2223
|
+
if (r instanceof S && r.code == "project.presentation-conflict") try {
|
|
2224
|
+
let t = await this.#e.getPresentation(e);
|
|
2225
|
+
if (this.#o || !n()) return;
|
|
2226
|
+
this.#c(a, t), this.#n({
|
|
2227
|
+
kind: "error",
|
|
2228
|
+
message: this.#t.t("notice.layoutConflict")
|
|
2229
|
+
});
|
|
2230
|
+
} catch (e) {
|
|
2231
|
+
!this.#o && n() && this.#n(o(e, this.#t.t));
|
|
2232
|
+
}
|
|
2233
|
+
else this.#c(a, t), this.#n(o(r, this.#t.t));
|
|
2234
|
+
}
|
|
2235
|
+
}), await this.#i;
|
|
2236
|
+
}
|
|
2237
|
+
#c(e, t) {
|
|
2238
|
+
this.#s = this.#s.filter((t) => t !== e), this.#a = t;
|
|
2239
|
+
let n = this.#s.reduce((e, t) => t.update(e), t.value);
|
|
2240
|
+
this.#r(n === t.value ? t : {
|
|
2241
|
+
...t,
|
|
2242
|
+
value: n
|
|
2243
|
+
});
|
|
2244
|
+
}
|
|
2245
|
+
}, Z = 50, xt = {
|
|
2246
|
+
failed: !1,
|
|
2247
|
+
loaded: !1,
|
|
2248
|
+
loading: !0,
|
|
2249
|
+
loadingMore: !1,
|
|
2250
|
+
loadMoreFailed: !1,
|
|
2251
|
+
projects: []
|
|
2252
|
+
}, St = class {
|
|
2253
|
+
#e;
|
|
2254
|
+
#t;
|
|
2255
|
+
#n = new p();
|
|
2256
|
+
#r;
|
|
2257
|
+
#i = r(xt);
|
|
2258
|
+
#a = !1;
|
|
2259
|
+
constructor(e, t, n) {
|
|
2260
|
+
this.#e = e, this.#t = n, this.#r = t, this.$ = {
|
|
2261
|
+
failed: a(this.#i, (e) => e.failed),
|
|
2262
|
+
loading: a(this.#i, (e) => e.loading),
|
|
2263
|
+
loadingMore: a(this.#i, (e) => e.loadingMore),
|
|
2264
|
+
loadMoreFailed: a(this.#i, (e) => e.loadMoreFailed),
|
|
2265
|
+
nextCursor: a(this.#i, (e) => e.nextCursor),
|
|
2266
|
+
projects: a(this.#i, (e) => e.projects),
|
|
2267
|
+
total: a(this.#i, (e) => e.total)
|
|
2268
|
+
};
|
|
2269
|
+
}
|
|
2270
|
+
get loaded() {
|
|
2271
|
+
return this.#i.value.loaded;
|
|
2272
|
+
}
|
|
2273
|
+
dispose() {
|
|
2274
|
+
this.#a = !0, this.#n.invalidate();
|
|
2275
|
+
for (let e of Object.values(this.$)) e.dispose();
|
|
2276
|
+
this.#i.dispose();
|
|
2277
|
+
}
|
|
2278
|
+
beginSelection() {
|
|
2279
|
+
let e = this.#n.begin();
|
|
2280
|
+
return this.#o({ loading: !1 }), e;
|
|
2281
|
+
}
|
|
2282
|
+
capture() {
|
|
2283
|
+
return this.#n.capture();
|
|
2284
|
+
}
|
|
2285
|
+
project(e) {
|
|
2286
|
+
return this.#i.value.projects.find((t) => t.projectId == e);
|
|
2287
|
+
}
|
|
2288
|
+
async reload() {
|
|
2289
|
+
let e = this.#n.begin();
|
|
2290
|
+
this.#o({
|
|
2291
|
+
failed: !1,
|
|
2292
|
+
loaded: !1,
|
|
2293
|
+
loading: !0,
|
|
2294
|
+
loadingMore: !1,
|
|
2295
|
+
loadMoreFailed: !1,
|
|
2296
|
+
nextCursor: void 0,
|
|
2297
|
+
projects: [],
|
|
2298
|
+
total: void 0
|
|
2299
|
+
});
|
|
2300
|
+
try {
|
|
2301
|
+
let t = await this.#e.listProjects({
|
|
2302
|
+
includeTotal: !0,
|
|
2303
|
+
limit: Z
|
|
2304
|
+
});
|
|
2305
|
+
if (!e()) return;
|
|
2306
|
+
this.#o({
|
|
2307
|
+
loaded: !0,
|
|
2308
|
+
loading: !1,
|
|
2309
|
+
nextCursor: t.nextCursor,
|
|
2310
|
+
projects: t.projects,
|
|
2311
|
+
total: t.total
|
|
2312
|
+
});
|
|
2313
|
+
} catch (t) {
|
|
2314
|
+
if (!e()) return;
|
|
2315
|
+
this.#o({
|
|
2316
|
+
failed: !0,
|
|
2317
|
+
loading: !1
|
|
2318
|
+
}), this.#r(o(t, this.#t.t));
|
|
2319
|
+
}
|
|
2320
|
+
}
|
|
2321
|
+
async loadMore() {
|
|
2322
|
+
let { loadingMore: e, nextCursor: t } = this.#i.value;
|
|
2323
|
+
if (e || t == null) return;
|
|
2324
|
+
let n = this.#n.capture();
|
|
2325
|
+
this.#o({
|
|
2326
|
+
loadingMore: !0,
|
|
2327
|
+
loadMoreFailed: !1
|
|
2328
|
+
});
|
|
2329
|
+
try {
|
|
2330
|
+
let e = await this.#e.listProjects({
|
|
2331
|
+
cursor: t,
|
|
2332
|
+
limit: Z
|
|
2333
|
+
});
|
|
2334
|
+
if (!n()) return;
|
|
2335
|
+
let r = new Set(this.#i.value.projects.map((e) => e.projectId));
|
|
2336
|
+
this.#o({
|
|
2337
|
+
loadingMore: !1,
|
|
2338
|
+
nextCursor: e.nextCursor,
|
|
2339
|
+
projects: [...this.#i.value.projects, ...e.projects.filter((e) => !r.has(e.projectId))]
|
|
2340
|
+
});
|
|
2341
|
+
} catch (e) {
|
|
2342
|
+
if (!n()) return;
|
|
2343
|
+
this.#o({
|
|
2344
|
+
loadingMore: !1,
|
|
2345
|
+
loadMoreFailed: !0
|
|
2346
|
+
}), this.#r(o(e, this.#t.t));
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
async create(e) {
|
|
2350
|
+
let t = await this.#e.createProject(e);
|
|
2351
|
+
if (!this.#a) return this.#o({
|
|
2352
|
+
projects: [...this.#i.value.projects, t],
|
|
2353
|
+
total: this.#i.value.total == null ? void 0 : this.#i.value.total + 1
|
|
2354
|
+
}), t;
|
|
2355
|
+
}
|
|
2356
|
+
include(e) {
|
|
2357
|
+
this.project(e.projectId) ?? this.#o({ projects: [...this.#i.value.projects, e] });
|
|
2358
|
+
}
|
|
2359
|
+
remove(e) {
|
|
2360
|
+
this.#o({
|
|
2361
|
+
projects: this.#i.value.projects.filter((t) => t.projectId != e),
|
|
2362
|
+
total: this.#i.value.total == null ? void 0 : this.#i.value.total - 1
|
|
2363
|
+
});
|
|
2364
|
+
}
|
|
2365
|
+
advanceHead(e, t) {
|
|
2366
|
+
this.#o({ projects: this.#i.value.projects.map((n) => n.projectId == e ? {
|
|
2367
|
+
...n,
|
|
2368
|
+
draftRevisionId: t
|
|
2369
|
+
} : n) });
|
|
2370
|
+
}
|
|
2371
|
+
#o(e) {
|
|
2372
|
+
this.#a || this.#i.set({
|
|
2373
|
+
...this.#i.value,
|
|
2374
|
+
...e
|
|
2375
|
+
});
|
|
2376
|
+
}
|
|
2377
|
+
}, Ct = {
|
|
2378
|
+
checkLoading: !1,
|
|
2379
|
+
flows: [],
|
|
2380
|
+
selectedNodeIds: [],
|
|
2381
|
+
workspaceLoadFailed: !1,
|
|
2382
|
+
workspaceLoading: !1
|
|
2383
|
+
};
|
|
2384
|
+
function wt(e) {
|
|
2385
|
+
return e.workspaceLoading ? "loading" : e.busy == "designer" ? "saving" : e.draft == null ? "noDraft" : "saved";
|
|
2386
|
+
}
|
|
2387
|
+
function Q(e, t) {
|
|
2388
|
+
if (t.phase != null) return t.phase;
|
|
2389
|
+
let n = e?.content.modules[t.moduleId];
|
|
2390
|
+
return n == null ? "failed" : t.source == n.source ? "saved" : "dirty";
|
|
2391
|
+
}
|
|
2392
|
+
function $(e, t, n) {
|
|
2393
|
+
if (e == null || t == null || n.length != 1) return;
|
|
2394
|
+
let r = e.node(t, n[0]);
|
|
2395
|
+
if (!(r?.kind != "task" || r.definition == null || !("moduleId" in r.definition) || r.module == null)) return {
|
|
2396
|
+
moduleId: r.definition.moduleId,
|
|
2397
|
+
source: r.module.source
|
|
2398
|
+
};
|
|
2399
|
+
}
|
|
2400
|
+
var Tt = class {
|
|
2401
|
+
#e;
|
|
2402
|
+
#t = r(Ct);
|
|
2403
|
+
#n;
|
|
2404
|
+
constructor(e, t) {
|
|
2405
|
+
let n = a(this.#t, (e) => e.busy), r = a(this.#t, (e) => e.checkLoading), o = a(this.#t, (e) => e.diagnosticFocus), c = a(this.#t, (e) => e.diagnostics), l = a(this.#t, (e) => e.draft), u = a(this.#t, (e) => e.flows), d = a(this.#t, (e) => {
|
|
2406
|
+
if (e.moduleEditor == null) return;
|
|
2407
|
+
let { phase: t, ...n } = e.moduleEditor;
|
|
2408
|
+
return {
|
|
2409
|
+
...n,
|
|
2410
|
+
status: Q(e.draft, e.moduleEditor)
|
|
2411
|
+
};
|
|
2412
|
+
}), f = a(this.#t, (e) => e.nodeFocus), p = a(this.#t, (e) => e.presentation), m = a(this.#t, (e) => e.projectId), h = a(this.#t, (e) => e.draft == null ? void 0 : s(e.draft)), g = a(this.#t, (e) => e.selectedNodeIds), _ = a(this.#t, (e) => e.target), v = a(this.#t, (e) => e.workspaceLoadFailed), y = a(this.#t, (e) => e.workspaceLoading);
|
|
2413
|
+
this.#e = a(this.#t, (e) => ({
|
|
2414
|
+
revision: e.draft == null ? void 0 : s(e.draft),
|
|
2415
|
+
target: e.target
|
|
2416
|
+
}), { equal: (e, t) => e.revision === t.revision && e.target === t.target });
|
|
2417
|
+
let b = a(this.#t, (e) => {
|
|
2418
|
+
if (e.draft != null && e.target != null && e.selectedNodeIds.length == 1) return s(e.draft).selection(e.target, e.selectedNodeIds[0]);
|
|
2419
|
+
});
|
|
2420
|
+
this.$ = {
|
|
2421
|
+
addNodeOptions: i((t) => {
|
|
2422
|
+
let { revision: n, target: r } = t(this.#e);
|
|
2423
|
+
return ee(n?.revision, r, t(e.t$));
|
|
2424
|
+
}),
|
|
2425
|
+
busy: n,
|
|
2426
|
+
checkLoading: r,
|
|
2427
|
+
diagnosticFocus: o,
|
|
2428
|
+
diagnosticItems: a(this.#t, (e) => Ye(e.draft == null ? void 0 : s(e.draft), e.target, e.diagnostics)),
|
|
2429
|
+
diagnostics: c,
|
|
2430
|
+
draft: l,
|
|
2431
|
+
flows: u,
|
|
2432
|
+
inspectorDiagnostics: a(this.#t, (e) => Ge(e.draft == null ? void 0 : s(e.draft), e.target, e.diagnostics, b.value)),
|
|
2433
|
+
moduleDiagnostics: a(this.#t, (e) => {
|
|
2434
|
+
let t = e.moduleEditor?.moduleId;
|
|
2435
|
+
return t == null ? [] : e.diagnostics?.diagnostics.filter((e) => e.path.startsWith(`/modules/${t}/source`)) ?? [];
|
|
2436
|
+
}),
|
|
2437
|
+
moduleEditor: d,
|
|
2438
|
+
nodeFocus: f,
|
|
2439
|
+
presentation: p,
|
|
2440
|
+
project: i((e) => {
|
|
2441
|
+
let n = e(m);
|
|
2442
|
+
return n == null ? void 0 : e(t.$.projects).find((e) => e.projectId == n);
|
|
2443
|
+
}),
|
|
2444
|
+
projectId: m,
|
|
2445
|
+
projectLoadFailed: t.$.failed,
|
|
2446
|
+
projectLoadMoreFailed: t.$.loadMoreFailed,
|
|
2447
|
+
projectLoading: t.$.loading,
|
|
2448
|
+
projectLoadingMore: t.$.loadingMore,
|
|
2449
|
+
projectNextCursor: t.$.nextCursor,
|
|
2450
|
+
projectTotal: t.$.total,
|
|
2451
|
+
projects: t.$.projects,
|
|
2452
|
+
revision: h,
|
|
2453
|
+
selection: b,
|
|
2454
|
+
selectedNodeIds: g,
|
|
2455
|
+
status: a(this.#t, wt),
|
|
2456
|
+
target: _,
|
|
2457
|
+
targetFlow: a(this.#t, (e) => e.target?.kind == "flow" ? e.flows.find((t) => t.flowId == e.target?.id) : void 0),
|
|
2458
|
+
targetName: a(this.#t, (e) => {
|
|
2459
|
+
if (e.target == null) return;
|
|
2460
|
+
if (e.draft == null) return e.target.id;
|
|
2461
|
+
let t = s(e.draft);
|
|
2462
|
+
return (e.target.kind == "flow" ? t.flow(e.target.id)?.name : t.subflow(e.target.id)?.name) ?? e.target.id;
|
|
2463
|
+
}),
|
|
2464
|
+
workspaceLoadFailed: v,
|
|
2465
|
+
workspaceLoading: y
|
|
2466
|
+
}, this.#n = new Set(Object.values(t.$));
|
|
2467
|
+
}
|
|
2468
|
+
get value() {
|
|
2469
|
+
return this.#t.value;
|
|
2470
|
+
}
|
|
2471
|
+
set(e) {
|
|
2472
|
+
this.#t.set({
|
|
2473
|
+
...this.#t.value,
|
|
2474
|
+
...e
|
|
2475
|
+
});
|
|
2476
|
+
}
|
|
2477
|
+
dispose() {
|
|
2478
|
+
for (let e of Object.values(this.$)) this.#n.has(e) || e.dispose();
|
|
2479
|
+
this.#e.dispose(), this.#t.dispose();
|
|
2480
|
+
}
|
|
2481
|
+
}, Et = 250;
|
|
2482
|
+
function Dt(e, t, n, r) {
|
|
2483
|
+
if (r == null) return;
|
|
2484
|
+
if (r.kind == "subflow") {
|
|
2485
|
+
if (e.subflow(r.id) != null) return r;
|
|
2486
|
+
let n = d(t, null);
|
|
2487
|
+
return n == null ? void 0 : {
|
|
2488
|
+
id: n.flowId,
|
|
2489
|
+
kind: "flow"
|
|
2490
|
+
};
|
|
2491
|
+
}
|
|
2492
|
+
if (e.flow(r.id) != null) return r;
|
|
2493
|
+
let i = new Set(e.flowIds), a = n.filter((e) => e.draft != null).map((e) => e.flowId), o = a.indexOf(r.id), s = (o < 0 ? a : [...a.slice(o + 1), ...a.slice(0, o).toReversed()]).find((e) => i.has(e)) ?? t.find((e) => e.draft != null && i.has(e.flowId))?.flowId ?? i.values().next().value;
|
|
2494
|
+
return s == null ? void 0 : {
|
|
2495
|
+
id: s,
|
|
2496
|
+
kind: "flow"
|
|
2497
|
+
};
|
|
2498
|
+
}
|
|
2499
|
+
var Ot = class {
|
|
2500
|
+
#e;
|
|
2501
|
+
#t;
|
|
2502
|
+
#n = new p();
|
|
2503
|
+
#r;
|
|
2504
|
+
#i;
|
|
2505
|
+
#a;
|
|
2506
|
+
#o;
|
|
2507
|
+
#s;
|
|
2508
|
+
#c;
|
|
2509
|
+
#l;
|
|
2510
|
+
#u;
|
|
2511
|
+
#d = 0;
|
|
2512
|
+
#f = 0;
|
|
2513
|
+
#p;
|
|
2514
|
+
#m = 0;
|
|
2515
|
+
#h = !1;
|
|
2516
|
+
#g = !1;
|
|
2517
|
+
#_ = !1;
|
|
2518
|
+
#v = !1;
|
|
2519
|
+
#y = 0;
|
|
2520
|
+
#b;
|
|
2521
|
+
constructor(e, t, n = () => crypto.randomUUID(), r = l(), i = () => {}) {
|
|
2522
|
+
this.#e = e, this.#c = t, this.#i = n, this.#r = r, this.#s = i, this.#o = new St(e, t, r), this.#l = new Tt(r, this.#o), this.#t = new yt(e, t, r, {
|
|
2523
|
+
apply: (e, t, n, r) => this.#C(e, t, n, r),
|
|
2524
|
+
beforeChange: (e) => {
|
|
2525
|
+
this.#j(), this.#h = !1, e && (this.#z({ busy: "designer" }), this.#c(void 0));
|
|
2526
|
+
},
|
|
2527
|
+
check: () => void this.#T(),
|
|
2528
|
+
current: (e) => this.#R(e),
|
|
2529
|
+
diagnostics: () => this.#l.value.diagnostics,
|
|
2530
|
+
finishChanges: () => {
|
|
2531
|
+
!this.#_ && this.#l.value.busy == "designer" && this.#z({ busy: void 0 });
|
|
2532
|
+
},
|
|
2533
|
+
flows: () => this.#l.value.flows,
|
|
2534
|
+
headChanged: (e, t) => this.#M(e, t),
|
|
2535
|
+
recover: (e) => this.#D(e, !0)
|
|
2536
|
+
}), this.#a = new bt(e, t, (e) => this.#z({ presentation: e }), r), this.$ = this.#l.$;
|
|
2537
|
+
}
|
|
2538
|
+
dispose() {
|
|
2539
|
+
this.#j(), this.#_ = !0, this.#n.invalidate(), this.#a.dispose(), this.#b?.(), this.#l.dispose(), this.#o.dispose();
|
|
2540
|
+
}
|
|
2541
|
+
async start(e, t) {
|
|
2542
|
+
if (e != null) {
|
|
2543
|
+
await this.selectProject(e, t);
|
|
2544
|
+
return;
|
|
2545
|
+
}
|
|
2546
|
+
await this.selectProject(void 0) && (this.#o.loaded && !this.#o.$.failed.value || await this.reloadProjects());
|
|
2547
|
+
}
|
|
2548
|
+
async reloadProjects() {
|
|
2549
|
+
await this.#o.reload();
|
|
2550
|
+
}
|
|
2551
|
+
async loadMoreProjects() {
|
|
2552
|
+
await this.#o.loadMore();
|
|
2553
|
+
}
|
|
2554
|
+
async selectProject(e, t) {
|
|
2555
|
+
if (!this.#P()) return !1;
|
|
2556
|
+
this.#j();
|
|
2557
|
+
let n = this.#o.beginSelection();
|
|
2558
|
+
if (this.#n.invalidate(), this.#t.reset(), this.#a.reset(), this.#f = 0, this.#h = !1, this.#g = !1, this.#v = !1, this.#b?.(), this.#b = void 0, this.#z({
|
|
2559
|
+
checkLoading: !1,
|
|
2560
|
+
diagnosticFocus: void 0,
|
|
2561
|
+
diagnostics: void 0,
|
|
2562
|
+
draft: void 0,
|
|
2563
|
+
flows: [],
|
|
2564
|
+
moduleEditor: void 0,
|
|
2565
|
+
nodeFocus: void 0,
|
|
2566
|
+
presentation: void 0,
|
|
2567
|
+
projectId: e,
|
|
2568
|
+
selectedNodeIds: [],
|
|
2569
|
+
target: t == null ? void 0 : {
|
|
2570
|
+
id: t,
|
|
2571
|
+
kind: "flow"
|
|
2572
|
+
},
|
|
2573
|
+
workspaceLoadFailed: !1,
|
|
2574
|
+
workspaceLoading: e != null
|
|
2575
|
+
}), e == null) return !0;
|
|
2576
|
+
try {
|
|
2577
|
+
let r = this.#o.project(e), [i, a, o, s] = await Promise.all([
|
|
2578
|
+
r ?? this.#e.getProject(e),
|
|
2579
|
+
this.#e.getDraft(e),
|
|
2580
|
+
this.#e.listFlows(e),
|
|
2581
|
+
this.#e.getPresentation(e)
|
|
2582
|
+
]);
|
|
2583
|
+
if (!n()) return !1;
|
|
2584
|
+
let c = t == null ? void 0 : o.find((e) => e.flowId == t), l = c == null ? void 0 : {
|
|
2585
|
+
id: c.flowId,
|
|
2586
|
+
kind: "flow"
|
|
2587
|
+
};
|
|
2588
|
+
this.#t.reset(a), this.#a.reset(s), this.#o.include(i), this.#z({
|
|
2589
|
+
draft: a,
|
|
2590
|
+
flows: o,
|
|
2591
|
+
presentation: s,
|
|
2592
|
+
target: l,
|
|
2593
|
+
workspaceLoadFailed: !1,
|
|
2594
|
+
workspaceLoading: !1
|
|
2595
|
+
}), this.#T(), this.#b = this.#e.watchProject(e, (e) => {
|
|
2596
|
+
!this.#_ && e != this.#t.committed?.revisionId && this.#E(e);
|
|
2597
|
+
}, this.#s);
|
|
2598
|
+
} catch (e) {
|
|
2599
|
+
return n() ? (this.#z({
|
|
2600
|
+
workspaceLoadFailed: !0,
|
|
2601
|
+
workspaceLoading: !1
|
|
2602
|
+
}), this.#c(o(e, this.#r.t)), !1) : !1;
|
|
2603
|
+
}
|
|
2604
|
+
return !0;
|
|
2605
|
+
}
|
|
2606
|
+
selectTarget(e) {
|
|
2607
|
+
return this.#P() ? (this.#j(), this.#z({
|
|
2608
|
+
diagnosticFocus: void 0,
|
|
2609
|
+
diagnostics: void 0,
|
|
2610
|
+
moduleEditor: void 0,
|
|
2611
|
+
nodeFocus: void 0,
|
|
2612
|
+
selectedNodeIds: [],
|
|
2613
|
+
target: e
|
|
2614
|
+
}), this.#T(), !0) : !1;
|
|
2615
|
+
}
|
|
2616
|
+
selectNodes(e) {
|
|
2617
|
+
return e.length == this.#l.value.selectedNodeIds.length && e.every((e, t) => e == this.#l.value.selectedNodeIds[t]) ? !0 : this.#P() ? (this.#j(), this.#z({
|
|
2618
|
+
diagnosticFocus: void 0,
|
|
2619
|
+
moduleEditor: $(this.#l.value.draft == null ? void 0 : s(this.#l.value.draft), this.#l.value.target, e),
|
|
2620
|
+
nodeFocus: void 0,
|
|
2621
|
+
selectedNodeIds: e
|
|
2622
|
+
}), !0) : !1;
|
|
2623
|
+
}
|
|
2624
|
+
async createProject(e) {
|
|
2625
|
+
if (this.#P()) {
|
|
2626
|
+
this.#z({ busy: "project" }), this.#c(void 0);
|
|
2627
|
+
try {
|
|
2628
|
+
return await this.#o.create(e);
|
|
2629
|
+
} catch (e) {
|
|
2630
|
+
this.#_ || this.#c(o(e, this.#r.t));
|
|
2631
|
+
} finally {
|
|
2632
|
+
this.#z({ busy: void 0 });
|
|
2633
|
+
}
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
async deleteProject(e) {
|
|
2637
|
+
if (!this.#P()) return !1;
|
|
2638
|
+
let t = this.#o.project(e);
|
|
2639
|
+
if (t == null || t.status == "retiring") return !1;
|
|
2640
|
+
this.#z({ busy: "project" }), this.#c(void 0);
|
|
2641
|
+
try {
|
|
2642
|
+
return await this.#e.deleteProject(e), !this.#_ && (this.#o.remove(e), this.#c({
|
|
2643
|
+
kind: "success",
|
|
2644
|
+
message: this.#r.t("notice.projectDeleteAccepted", { name: t.name })
|
|
2645
|
+
}), !0);
|
|
2646
|
+
} catch (e) {
|
|
2647
|
+
return this.#_ || this.#c(o(e, this.#r.t)), !1;
|
|
2648
|
+
} finally {
|
|
2649
|
+
this.#z({ busy: void 0 });
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
async createResource(e, t) {
|
|
2653
|
+
if (!this.#P() || this.#l.value.draft == null) return !1;
|
|
2654
|
+
let n = this.#i();
|
|
2655
|
+
this.#z({ busy: "resource" }), this.#c(void 0);
|
|
2656
|
+
let r = await this.#S(Ze(e, n, t), !1);
|
|
2657
|
+
return this.#z({ busy: void 0 }), r != null && (this.selectTarget({
|
|
2658
|
+
id: n,
|
|
2659
|
+
kind: e
|
|
2660
|
+
}), this.#c({
|
|
2661
|
+
kind: "success",
|
|
2662
|
+
message: this.#r.t("notice.createdInDraft", { name: t })
|
|
2663
|
+
}), !0);
|
|
2664
|
+
}
|
|
2665
|
+
async renameFlow(e, t) {
|
|
2666
|
+
let n = this.$.revision.value?.flow(e), r = t.trim();
|
|
2667
|
+
if (n == null || r.length == 0) return !1;
|
|
2668
|
+
if (n.name == r) return !0;
|
|
2669
|
+
this.#z({ busy: "resource" }), this.#c(void 0);
|
|
2670
|
+
let i = await this.#S(Te(e, r), !1);
|
|
2671
|
+
return this.#z({ busy: void 0 }), i != null && (this.#c({
|
|
2672
|
+
kind: "success",
|
|
2673
|
+
message: this.#r.t("notice.flowRenamed", { name: r })
|
|
2674
|
+
}), !0);
|
|
2675
|
+
}
|
|
2676
|
+
async deleteFlow(e) {
|
|
2677
|
+
let t = this.#l.value.flows.find((t) => t.flowId == e);
|
|
2678
|
+
if (t?.draft == null || this.#l.value.target?.kind == "flow" && this.#l.value.target.id == e && !this.#P()) return !1;
|
|
2679
|
+
this.#z({ busy: "resource" }), this.#c(void 0);
|
|
2680
|
+
let n = await this.#S(Ee(e), !1);
|
|
2681
|
+
return this.#z({ busy: void 0 }), n != null && (this.#c({
|
|
2682
|
+
kind: "success",
|
|
2683
|
+
message: this.#r.t("notice.flowDeleted", { name: t.draft.name })
|
|
2684
|
+
}), !0);
|
|
2685
|
+
}
|
|
2686
|
+
async addNode(e, t, n) {
|
|
2687
|
+
if (!this.#P()) return;
|
|
2688
|
+
let r = this.#l.value.draft, i = this.#l.value.target;
|
|
2689
|
+
if (r == null || i == null) return;
|
|
2690
|
+
let a = this.#i();
|
|
2691
|
+
if (e.kind == "comment") return await this.#x(i, a, t);
|
|
2692
|
+
let o = s(r), c = te(e, o, i, this.#r.t);
|
|
2693
|
+
if (c == null) return;
|
|
2694
|
+
let l = Qe(o, i, a, c, this.#i);
|
|
2695
|
+
if (l == null) return;
|
|
2696
|
+
let u = n == null ? l : [...l, ...B(J(r, l).content, i, n(a))], d = this.#S(u);
|
|
2697
|
+
this.selectNodes([a]);
|
|
2698
|
+
let f = this.moveNodes({ [a]: t });
|
|
2699
|
+
if (await d != null) return await f, a;
|
|
2700
|
+
}
|
|
2701
|
+
async connect(e) {
|
|
2702
|
+
let t = this.$.revision.value, n = this.#l.value.target;
|
|
2703
|
+
if (t == null || n == null) return;
|
|
2704
|
+
let r = B(t.revision.content, n, e);
|
|
2705
|
+
r.length > 0 && await this.#S(r);
|
|
2706
|
+
}
|
|
2707
|
+
async disconnect(e) {
|
|
2708
|
+
let t = this.$.revision.value, n = this.#l.value.target;
|
|
2709
|
+
if (t == null || n == null) return;
|
|
2710
|
+
let r = Ce(t.revision.content, n, e);
|
|
2711
|
+
r.length > 0 && await this.#S(r);
|
|
2712
|
+
}
|
|
2713
|
+
async deleteSelectedNodes() {
|
|
2714
|
+
if (!this.#P()) return;
|
|
2715
|
+
let e = this.$.revision.value, t = this.#l.value.target;
|
|
2716
|
+
if (e == null || t == null || this.#l.value.selectedNodeIds.length == 0) return;
|
|
2717
|
+
let n = h(this.#l.value.presentation?.value ?? {}, t), r = new Set(this.#l.value.selectedNodeIds.filter((e) => n.has(e))), i = $e(e, t, this.#l.value.selectedNodeIds), a = i.length == 0 ? void 0 : this.#S(i), o = r.size == 0 ? void 0 : this.#w((e) => g(e, t, r));
|
|
2718
|
+
this.selectNodes([]), (a == null || await a != null) && await o;
|
|
2719
|
+
}
|
|
2720
|
+
copySelectedNodes() {
|
|
2721
|
+
let e = this.$.revision.value, t = this.#l.value.target;
|
|
2722
|
+
if (e == null || t == null || this.#l.value.selectedNodeIds.length == 0) return;
|
|
2723
|
+
let n = new Set(this.#l.value.selectedNodeIds);
|
|
2724
|
+
this.#u = {
|
|
2725
|
+
comments: this.#N().nodes.flatMap((e) => e.kind == "comment" && n.has(e.id) ? [{
|
|
2726
|
+
content: e.content,
|
|
2727
|
+
position: e.position,
|
|
2728
|
+
sourceId: e.id,
|
|
2729
|
+
title: e.title
|
|
2730
|
+
}] : []),
|
|
2731
|
+
nodes: et(e, t, this.#l.value.selectedNodeIds)
|
|
2732
|
+
};
|
|
2733
|
+
}
|
|
2734
|
+
async pasteNodes() {
|
|
2735
|
+
if (!this.#P()) return;
|
|
2736
|
+
let e = this.$.revision.value, t = this.#l.value.target;
|
|
2737
|
+
if (e == null || t == null || this.#u == null) return;
|
|
2738
|
+
let n = tt(e, t, this.#u.nodes, this.#i), r = n.changes.length == 0 ? void 0 : this.#S(n.changes), i = this.#u.comments.map((e) => ({
|
|
2739
|
+
...e,
|
|
2740
|
+
nodeId: this.#i()
|
|
2741
|
+
}));
|
|
2742
|
+
if (n.nodeIds.length == 0 && i.length == 0) return;
|
|
2743
|
+
let a = new Map(this.#N().nodes.map((e) => [e.id, e])), o = Object.fromEntries(n.sourceIds.map((e, t) => {
|
|
2744
|
+
let r = a.get(e);
|
|
2745
|
+
return [n.nodeIds[t], {
|
|
2746
|
+
x: (r?.position.x ?? 80) + 40,
|
|
2747
|
+
y: (r?.position.y ?? 80) + 40
|
|
2748
|
+
}];
|
|
2749
|
+
})), s = this.#w((e) => {
|
|
2750
|
+
let n = m(e, t, o);
|
|
2751
|
+
for (let e of i) n = x(n, t, e.nodeId, {
|
|
2752
|
+
content: e.content,
|
|
2753
|
+
position: {
|
|
2754
|
+
x: e.position.x + 40,
|
|
2755
|
+
y: e.position.y + 40
|
|
2756
|
+
},
|
|
2757
|
+
title: this.#r.t("addNode.commentCopy", { title: e.title })
|
|
2758
|
+
});
|
|
2759
|
+
return n;
|
|
2760
|
+
});
|
|
2761
|
+
this.selectNodes([...n.nodeIds, ...i.map((e) => e.nodeId)]), (r == null || await r != null) && await s;
|
|
2762
|
+
}
|
|
2763
|
+
async duplicateSelectedNodes() {
|
|
2764
|
+
this.copySelectedNodes(), await this.pasteNodes();
|
|
2765
|
+
}
|
|
2766
|
+
async saveNodeSettings(e, t) {
|
|
2767
|
+
let n = this.$.revision.value, r = this.#l.value.target;
|
|
2768
|
+
if (n == null || r == null) return !1;
|
|
2769
|
+
let i = nt(n, r, e, t);
|
|
2770
|
+
return i != null && await this.#S(i) != null;
|
|
2771
|
+
}
|
|
2772
|
+
async saveNodeDescription(e, t) {
|
|
2773
|
+
let n = this.$.revision.value, r = this.#l.value.target;
|
|
2774
|
+
if (n == null || r == null) return !1;
|
|
2775
|
+
let i = rt(n, r, e, t);
|
|
2776
|
+
return i != null && await this.#S(i) != null;
|
|
2777
|
+
}
|
|
2778
|
+
async setInputValue(e, t, n) {
|
|
2779
|
+
let r = this.$.revision.value, i = this.#l.value.target;
|
|
2780
|
+
if (r == null || i == null) return !1;
|
|
2781
|
+
let a = it(r, i, e, t, n);
|
|
2782
|
+
return a != null && await this.#S(a) != null;
|
|
2783
|
+
}
|
|
2784
|
+
async saveCondition(e, t) {
|
|
2785
|
+
let n = this.$.revision.value, r = this.#l.value.target;
|
|
2786
|
+
if (n == null || r == null) return !1;
|
|
2787
|
+
let i = at(n, r, e, t);
|
|
2788
|
+
return i != null && await this.#S(i) != null;
|
|
2789
|
+
}
|
|
2790
|
+
async saveValue(e, t) {
|
|
2791
|
+
let n = this.$.revision.value, r = this.#l.value.target;
|
|
2792
|
+
if (n == null || r == null) return !1;
|
|
2793
|
+
let i = ot(n, r, e, t);
|
|
2794
|
+
return i != null && await this.#S(i) != null;
|
|
2795
|
+
}
|
|
2796
|
+
async saveComment(e, t) {
|
|
2797
|
+
let n = this.#l.value.target;
|
|
2798
|
+
if (n == null) return;
|
|
2799
|
+
let r = this.#N().nodes.find((t) => t.id == e)?.position;
|
|
2800
|
+
r != null && await this.#w((i) => x(i, n, e, {
|
|
2801
|
+
...t,
|
|
2802
|
+
position: r
|
|
2803
|
+
}));
|
|
2804
|
+
}
|
|
2805
|
+
async saveTaskSettings(e, t) {
|
|
2806
|
+
let n = this.$.revision.value, r = this.#l.value.target;
|
|
2807
|
+
if (n == null || r == null) return !1;
|
|
2808
|
+
let i = st(n, r, e, t);
|
|
2809
|
+
return i != null && await this.#S(i) != null;
|
|
2810
|
+
}
|
|
2811
|
+
async saveCodeTaskPorts(e, t) {
|
|
2812
|
+
let n = this.$.revision.value, r = this.#l.value.target;
|
|
2813
|
+
if (n == null || r == null) return !1;
|
|
2814
|
+
let i = ct(n, r, e, t);
|
|
2815
|
+
return i != null && await this.#S(i) != null;
|
|
2816
|
+
}
|
|
2817
|
+
async setConnectorConnection(e, t) {
|
|
2818
|
+
let n = this.$.revision.value;
|
|
2819
|
+
if (n == null) return !1;
|
|
2820
|
+
let r = Re(n.revision.content, e, t);
|
|
2821
|
+
return r != null && await this.#S(r) != null;
|
|
2822
|
+
}
|
|
2823
|
+
async saveTriggerSettings(e, t) {
|
|
2824
|
+
let n = this.$.revision.value, r = this.#l.value.target;
|
|
2825
|
+
if (n == null || r?.kind != "flow") return !1;
|
|
2826
|
+
let i = ze(n.revision.content, r, e, t);
|
|
2827
|
+
return i != null && await this.#S(i) != null;
|
|
2828
|
+
}
|
|
2829
|
+
async saveTriggerConfig(e, t, n) {
|
|
2830
|
+
let r = this.$.revision.value, i = this.#l.value.target;
|
|
2831
|
+
if (r == null || i?.kind != "flow") return !1;
|
|
2832
|
+
let a = Be(r.revision.content, i, e, t, n);
|
|
2833
|
+
return a != null && await this.#S(a) != null;
|
|
2834
|
+
}
|
|
2835
|
+
async saveTriggerSchedule(e, t) {
|
|
2836
|
+
let n = this.$.revision.value, r = this.#l.value.target;
|
|
2837
|
+
if (n == null || r?.kind != "flow") return !1;
|
|
2838
|
+
let i = Ve(n.revision.content, r, e, t);
|
|
2839
|
+
return i != null && await this.#S(i) != null;
|
|
2840
|
+
}
|
|
2841
|
+
async saveWebhook(e, t) {
|
|
2842
|
+
let n = this.$.revision.value, r = this.#l.value.target;
|
|
2843
|
+
if (n == null || r?.kind != "flow") return !1;
|
|
2844
|
+
let i = lt(n, r, e, t);
|
|
2845
|
+
return i != null && await this.#S(i) != null;
|
|
2846
|
+
}
|
|
2847
|
+
async setTriggerConnection(e, t) {
|
|
2848
|
+
let n = this.$.revision.value, r = this.#l.value.target;
|
|
2849
|
+
if (n == null || r?.kind != "flow") return !1;
|
|
2850
|
+
let i = He(n.revision.content, r, e, t);
|
|
2851
|
+
return i != null && await this.#S(i) != null;
|
|
2852
|
+
}
|
|
2853
|
+
async saveSubflowSettings(e, t) {
|
|
2854
|
+
let n = this.$.revision.value;
|
|
2855
|
+
if (n == null) return !1;
|
|
2856
|
+
let r = ut(n, e, t);
|
|
2857
|
+
return r != null && await this.#S(r) != null;
|
|
2858
|
+
}
|
|
2859
|
+
updateModuleSource(e) {
|
|
2860
|
+
let t = this.#l.value.moduleEditor;
|
|
2861
|
+
t != null && t.source != e && this.#z({ moduleEditor: {
|
|
2862
|
+
...t,
|
|
2863
|
+
phase: void 0,
|
|
2864
|
+
source: e
|
|
2865
|
+
} });
|
|
2866
|
+
}
|
|
2867
|
+
discardModuleChanges() {
|
|
2868
|
+
let e = this.#l.value.moduleEditor;
|
|
2869
|
+
if (e == null) return;
|
|
2870
|
+
let t = this.#l.value.draft?.content.modules[e.moduleId];
|
|
2871
|
+
if (t == null) {
|
|
2872
|
+
this.#z({ moduleEditor: void 0 });
|
|
2873
|
+
return;
|
|
2874
|
+
}
|
|
2875
|
+
this.#z({ moduleEditor: {
|
|
2876
|
+
moduleId: e.moduleId,
|
|
2877
|
+
source: t.source
|
|
2878
|
+
} });
|
|
2879
|
+
}
|
|
2880
|
+
async saveModuleEditor() {
|
|
2881
|
+
let e = this.#l.value.moduleEditor;
|
|
2882
|
+
if (e == null || e.phase == "saving") return !1;
|
|
2883
|
+
this.#z({ moduleEditor: {
|
|
2884
|
+
...e,
|
|
2885
|
+
phase: "saving"
|
|
2886
|
+
} });
|
|
2887
|
+
let t = await De(e.source);
|
|
2888
|
+
if (this.#_) return !1;
|
|
2889
|
+
let n = await this.#S(Oe(e.moduleId, e.source, t));
|
|
2890
|
+
return !this.#_ && this.#l.value.moduleEditor?.moduleId == e.moduleId && this.#z({ moduleEditor: {
|
|
2891
|
+
...this.#l.value.moduleEditor,
|
|
2892
|
+
phase: n == null ? "failed" : void 0
|
|
2893
|
+
} }), n != null;
|
|
2894
|
+
}
|
|
2895
|
+
async moveNodes(e) {
|
|
2896
|
+
let t = this.#l.value.target;
|
|
2897
|
+
t != null && await this.#w((n) => m(n, t, e));
|
|
2898
|
+
}
|
|
2899
|
+
async moveViewport(e) {
|
|
2900
|
+
let t = this.#l.value.target;
|
|
2901
|
+
if (t == null) return;
|
|
2902
|
+
let n = this.#N().viewport;
|
|
2903
|
+
(n.x != e.x || n.y != e.y || n.zoom != e.zoom) && this.#j(), await this.#w((n) => f(n, t, e));
|
|
2904
|
+
}
|
|
2905
|
+
async check() {
|
|
2906
|
+
await this.#T();
|
|
2907
|
+
}
|
|
2908
|
+
async refreshFlows() {
|
|
2909
|
+
let e = this.#l.value.projectId;
|
|
2910
|
+
if (e == null) return;
|
|
2911
|
+
let t = this.#o.capture(), n = await this.#e.listFlows(e);
|
|
2912
|
+
t() && e == this.#l.value.projectId && this.#z({ flows: n });
|
|
2913
|
+
}
|
|
2914
|
+
locateNode(e) {
|
|
2915
|
+
let t = this.$.revision.value, n = this.#l.value.target;
|
|
2916
|
+
return t == null || n == null || t.node(n, e) == null || !this.selectNodes([e]) ? !1 : (this.#z({ nodeFocus: {
|
|
2917
|
+
nodeId: e,
|
|
2918
|
+
requestId: ++this.#y
|
|
2919
|
+
} }), !0);
|
|
2920
|
+
}
|
|
2921
|
+
locateDiagnostic(e) {
|
|
2922
|
+
return e.location == null || !this.selectNodes([e.location.nodeId]) ? !1 : (this.#z({ diagnosticFocus: {
|
|
2923
|
+
...e.location,
|
|
2924
|
+
diagnostic: e.diagnostic,
|
|
2925
|
+
requestId: ++this.#d
|
|
2926
|
+
} }), !0);
|
|
2927
|
+
}
|
|
2928
|
+
async #x(e, t, n) {
|
|
2929
|
+
let r = Math.max(0, ...this.#N().nodes.flatMap((e) => {
|
|
2930
|
+
if (e.kind != "comment") return [];
|
|
2931
|
+
let t = /#(\d+)$/.exec(e.title);
|
|
2932
|
+
return t == null ? [] : [Number(t[1])];
|
|
2933
|
+
})), i = this.#w((i) => x(i, e, t, {
|
|
2934
|
+
content: "",
|
|
2935
|
+
position: n,
|
|
2936
|
+
title: this.#r.t("addNode.commentName", { number: r + 1 })
|
|
2937
|
+
}));
|
|
2938
|
+
if (this.selectNodes([t]), await i, !this.#_) return t;
|
|
2939
|
+
}
|
|
2940
|
+
async #S(e, t = !0) {
|
|
2941
|
+
let n = this.#l.value.projectId, r = this.#l.value.draft;
|
|
2942
|
+
if (n != null && r != null) return await this.#t.change({
|
|
2943
|
+
current: this.#n.capture(),
|
|
2944
|
+
projectId: n
|
|
2945
|
+
}, r, e, t);
|
|
2946
|
+
}
|
|
2947
|
+
#C(e, t, n, r = !1) {
|
|
2948
|
+
let i = this.#l.value.draft, { revision: a, selectedNodeIds: o, target: s } = this.#F(e, t, n), c = this.#l.value.moduleEditor;
|
|
2949
|
+
return this.#z({
|
|
2950
|
+
diagnostics: r ? this.#l.value.diagnostics : void 0,
|
|
2951
|
+
draft: e,
|
|
2952
|
+
flows: t,
|
|
2953
|
+
moduleEditor: c != null && i != null && Q(i, c) != "saved" ? c : $(a, s, o),
|
|
2954
|
+
selectedNodeIds: o,
|
|
2955
|
+
target: s
|
|
2956
|
+
}), a;
|
|
2957
|
+
}
|
|
2958
|
+
async #w(e) {
|
|
2959
|
+
if (this.#_) return;
|
|
2960
|
+
let t = this.#l.value.projectId, n = this.#l.value.presentation;
|
|
2961
|
+
t != null && n != null && await this.#a.change(t, n, this.#o.capture(), e);
|
|
2962
|
+
}
|
|
2963
|
+
async #T() {
|
|
2964
|
+
if (this.#_) return;
|
|
2965
|
+
let e = this.#l.value.projectId, t = this.#l.value.draft, n = this.#l.value.target;
|
|
2966
|
+
if (e == null || t == null || n == null) {
|
|
2967
|
+
n ?? this.#z({
|
|
2968
|
+
checkLoading: !1,
|
|
2969
|
+
diagnostics: void 0
|
|
2970
|
+
});
|
|
2971
|
+
return;
|
|
2972
|
+
}
|
|
2973
|
+
let r = We(s(t), n);
|
|
2974
|
+
if (r == null) {
|
|
2975
|
+
this.#z({
|
|
2976
|
+
checkLoading: !1,
|
|
2977
|
+
diagnostics: void 0
|
|
2978
|
+
});
|
|
2979
|
+
return;
|
|
2980
|
+
}
|
|
2981
|
+
this.#z({
|
|
2982
|
+
checkLoading: !0,
|
|
2983
|
+
diagnosticFocus: void 0
|
|
2984
|
+
});
|
|
2985
|
+
try {
|
|
2986
|
+
let n = await this.#e.checkFlow(e, t.revisionId, r);
|
|
2987
|
+
!this.#_ && e == this.#l.value.projectId && t.revisionId == this.#l.value.draft?.revisionId && this.#z({ diagnostics: n });
|
|
2988
|
+
} catch (n) {
|
|
2989
|
+
!this.#_ && e == this.#l.value.projectId && t.revisionId == this.#l.value.draft?.revisionId && this.#c(o(n, this.#r.t));
|
|
2990
|
+
} finally {
|
|
2991
|
+
!this.#_ && e == this.#l.value.projectId && t.revisionId == this.#l.value.draft?.revisionId && this.#z({ checkLoading: !1 });
|
|
2992
|
+
}
|
|
2993
|
+
}
|
|
2994
|
+
async #E(e) {
|
|
2995
|
+
if (this.#_) return;
|
|
2996
|
+
let t = this.#l.value.projectId;
|
|
2997
|
+
if (t == null || (this.#f += 1, e != null && (this.#g = !0, this.#t.changing || (this.#h = !0)), this.#v)) return;
|
|
2998
|
+
this.#v = !0;
|
|
2999
|
+
let n = {
|
|
3000
|
+
current: this.#n.capture(),
|
|
3001
|
+
projectId: t
|
|
3002
|
+
};
|
|
3003
|
+
await this.#t.enqueue(async () => {
|
|
3004
|
+
let e;
|
|
3005
|
+
do {
|
|
3006
|
+
e = this.#f;
|
|
3007
|
+
let t = this.#h, r = this.#m, i = this.#g;
|
|
3008
|
+
this.#h = !1, this.#g = !1, await this.#D(n, !1, i, t, r);
|
|
3009
|
+
} while (this.#R(n) && e != this.#f);
|
|
3010
|
+
}), this.#R(n) && (this.#v = !1);
|
|
3011
|
+
}
|
|
3012
|
+
async #D(e, t, n = !1, r = !1, i = this.#m) {
|
|
3013
|
+
try {
|
|
3014
|
+
let t = r ? this.#l.value.target : void 0, a = this.#t.committed;
|
|
3015
|
+
if (a == null) return !1;
|
|
3016
|
+
let o = await this.#e.syncDraft(e.projectId, a.revisionId);
|
|
3017
|
+
if (!this.#R(e)) return !1;
|
|
3018
|
+
if (o.kind == "changes" && o.revisions.length == 0) return !0;
|
|
3019
|
+
let c;
|
|
3020
|
+
try {
|
|
3021
|
+
c = this.#O(a, o);
|
|
3022
|
+
} catch {
|
|
3023
|
+
if (o = await this.#e.syncDraft(e.projectId), !this.#R(e)) return !1;
|
|
3024
|
+
c = this.#O(a, o);
|
|
3025
|
+
}
|
|
3026
|
+
if (c.revisionId == a.revisionId) return !0;
|
|
3027
|
+
let l = o.kind == "changes" && t != null ? gt(s(a), s(c), t, o.revisions.flatMap((e) => e.operations)) : void 0;
|
|
3028
|
+
o.kind == "snapshot" && this.#j();
|
|
3029
|
+
let u = this.#l.value.flows, d = vt(u, o.draftFlows, c), f = this.#l.value.diagnostics, p = this.#t.pendingCount == 0 && f != null && d.find((e) => e.flowId == f.flowId)?.draft?.closureDigest == f.closureDigest, m = this.#I(c, d, p);
|
|
3030
|
+
return this.#M(e.projectId, c.revisionId), o.kind == "changes" && o.revisions.length > 0 && t != null && l != null && i == this.#m && this.#k(e, t, l, i), n && (this.#c({
|
|
3031
|
+
kind: m ? "error" : "success",
|
|
3032
|
+
message: this.#r.t(m ? "notice.moduleUpdated" : "notice.draftUpdated")
|
|
3033
|
+
}), p || this.#T()), !0;
|
|
3034
|
+
} catch (n) {
|
|
3035
|
+
return t && this.#R(e) && this.#c(o(n, this.#r.t)), !1;
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
3038
|
+
#O(e, t) {
|
|
3039
|
+
if (t.kind == "snapshot") return t.draft;
|
|
3040
|
+
let n = e;
|
|
3041
|
+
for (let e of t.revisions) {
|
|
3042
|
+
if (e.revision.parentRevisionId != n.revisionId) throw Error("Invalid Draft revision chain.");
|
|
3043
|
+
n = {
|
|
3044
|
+
...e.revision,
|
|
3045
|
+
content: J(n, e.operations).content
|
|
3046
|
+
};
|
|
3047
|
+
}
|
|
3048
|
+
return n;
|
|
3049
|
+
}
|
|
3050
|
+
#k(e, t, n, r) {
|
|
3051
|
+
let i = this.#l.value;
|
|
3052
|
+
if (!this.#R(e) || r != this.#m || i.target?.kind != t.kind || i.target.id != t.id) return;
|
|
3053
|
+
let a = this.#p;
|
|
3054
|
+
if (a != null) {
|
|
3055
|
+
if (a.projectId != e.projectId || a.target.kind != t.kind || a.target.id != t.id) {
|
|
3056
|
+
this.#j();
|
|
3057
|
+
return;
|
|
3058
|
+
}
|
|
3059
|
+
for (let e of n) a.targets.add(e);
|
|
3060
|
+
globalThis.clearTimeout(a.timer), a.timer = globalThis.setTimeout(() => this.#A(), Et);
|
|
3061
|
+
return;
|
|
3062
|
+
}
|
|
3063
|
+
n.size == 0 || i.selectedNodeIds.length > 0 || (this.#p = {
|
|
3064
|
+
current: e.current,
|
|
3065
|
+
generation: r,
|
|
3066
|
+
projectId: e.projectId,
|
|
3067
|
+
target: t,
|
|
3068
|
+
targets: new Set(n),
|
|
3069
|
+
timer: globalThis.setTimeout(() => this.#A(), Et),
|
|
3070
|
+
viewport: this.#N().viewport
|
|
3071
|
+
});
|
|
3072
|
+
}
|
|
3073
|
+
#A() {
|
|
3074
|
+
let e = this.#p;
|
|
3075
|
+
if (this.#p = void 0, e == null || !e.current() || e.generation != this.#m) return;
|
|
3076
|
+
let t = this.#l.value;
|
|
3077
|
+
if (t.projectId != e.projectId || t.target?.kind != e.target.kind || t.target.id != e.target.id || t.selectedNodeIds.length > 0) return;
|
|
3078
|
+
let n = this.#N().viewport;
|
|
3079
|
+
if (n.x != e.viewport.x || n.y != e.viewport.y || n.zoom != e.viewport.zoom || t.draft == null) return;
|
|
3080
|
+
let r = s(t.draft), i = [...e.targets].filter((t) => r.selection(e.target, t) != null);
|
|
3081
|
+
i.length == 1 && this.#z({ nodeFocus: {
|
|
3082
|
+
nodeId: i[0],
|
|
3083
|
+
requestId: ++this.#y
|
|
3084
|
+
} });
|
|
3085
|
+
}
|
|
3086
|
+
#j() {
|
|
3087
|
+
this.#m += 1, this.#p != null && globalThis.clearTimeout(this.#p.timer), this.#p = void 0;
|
|
3088
|
+
}
|
|
3089
|
+
#M(e, t) {
|
|
3090
|
+
this.#o.advanceHead(e, t);
|
|
3091
|
+
}
|
|
3092
|
+
#N() {
|
|
3093
|
+
let e = this.#l.value;
|
|
3094
|
+
return v(e.draft, e.target, e.presentation?.value, e.diagnostics?.diagnostics, {}, {}, this.#r.t);
|
|
3095
|
+
}
|
|
3096
|
+
#P() {
|
|
3097
|
+
let e = this.#l.value.moduleEditor;
|
|
3098
|
+
return e == null || Q(this.#l.value.draft, e) == "saved" || (this.#c({
|
|
3099
|
+
kind: "error",
|
|
3100
|
+
message: this.#r.t("notice.unsavedCode")
|
|
3101
|
+
}), !1);
|
|
3102
|
+
}
|
|
3103
|
+
#F(e, t, n) {
|
|
3104
|
+
let r = s(e), i = Dt(r, t, n, this.#l.value.target);
|
|
3105
|
+
return {
|
|
3106
|
+
revision: r,
|
|
3107
|
+
selectedNodeIds: this.#l.value.selectedNodeIds.filter((e) => i != null && r.selection(i, e) != null),
|
|
3108
|
+
target: i
|
|
3109
|
+
};
|
|
3110
|
+
}
|
|
3111
|
+
#I(e, t, n) {
|
|
3112
|
+
this.#t.replaceCommitted(e);
|
|
3113
|
+
let r = this.#t.project(e), i = this.#l.value.moduleEditor, a = i != null && Q(this.#l.value.draft, i) != "saved", o = this.#l.value.flows, s = this.#F(r, t, o), c = new Set(o.map((e) => e.flowId)), l = this.#l.value.target == null ? t.filter((e) => e.draft != null && s.revision.flow(e.flowId) != null && !c.has(e.flowId)) : [], u = l.length == 1 ? {
|
|
3114
|
+
id: l[0].flowId,
|
|
3115
|
+
kind: "flow"
|
|
3116
|
+
} : s.target;
|
|
3117
|
+
return this.#z({
|
|
3118
|
+
diagnostics: n ? this.#l.value.diagnostics : void 0,
|
|
3119
|
+
draft: r,
|
|
3120
|
+
flows: t,
|
|
3121
|
+
moduleEditor: this.#L(s.revision, u, s.selectedNodeIds),
|
|
3122
|
+
selectedNodeIds: s.selectedNodeIds,
|
|
3123
|
+
target: u
|
|
3124
|
+
}), a;
|
|
3125
|
+
}
|
|
3126
|
+
#L(e, t, n) {
|
|
3127
|
+
let r = this.#l.value.moduleEditor;
|
|
3128
|
+
return r == null || Q(this.#l.value.draft, r) == "saved" ? $(e, t, n) : {
|
|
3129
|
+
...r,
|
|
3130
|
+
phase: "failed"
|
|
3131
|
+
};
|
|
3132
|
+
}
|
|
3133
|
+
#R(e) {
|
|
3134
|
+
return !this.#_ && e.projectId == this.#l.value.projectId && e.current();
|
|
3135
|
+
}
|
|
3136
|
+
#z(e) {
|
|
3137
|
+
this.#_ || this.#l.set(e);
|
|
3138
|
+
}
|
|
3139
|
+
};
|
|
3140
|
+
//#endregion
|
|
3141
|
+
//#region src/workbench/browser/runtime/stores/workbenchStore.ts
|
|
3142
|
+
function kt(e) {
|
|
3143
|
+
return new Map(e.nodes.map((e) => [e.id, e]));
|
|
3144
|
+
}
|
|
3145
|
+
function At(e, t) {
|
|
3146
|
+
return e == null || t == null ? [] : s(e).designerInputs(t);
|
|
3147
|
+
}
|
|
3148
|
+
function jt(e, t, n, r, i) {
|
|
3149
|
+
if (e == null || t?.kind != "flow" || n?.revisionId != e.revisionId || n.flowId != t.id) return /* @__PURE__ */ new Map();
|
|
3150
|
+
let a = r.find((e) => e.kind == "run.started" && e.payload.flowId == t.id)?.payload.scopeId;
|
|
3151
|
+
return typeof a == "string" ? new Map(r.flatMap((e) => {
|
|
3152
|
+
let n = e.payload.nodeId;
|
|
3153
|
+
return e.payload.scopeId == a && e.payload.flowId == t.id && typeof n == "string" && i.has(n) ? [[e.sequence, n]] : [];
|
|
3154
|
+
})) : /* @__PURE__ */ new Map();
|
|
3155
|
+
}
|
|
3156
|
+
var Mt = {
|
|
3157
|
+
openExternalPage: async () => !1,
|
|
3158
|
+
returnUrl: ""
|
|
3159
|
+
}, Nt = class {
|
|
3160
|
+
#e;
|
|
3161
|
+
#t;
|
|
3162
|
+
#n;
|
|
3163
|
+
#r;
|
|
3164
|
+
constructor(e, t, n = () => crypto.randomUUID(), o = l(), s = Mt) {
|
|
3165
|
+
this.#e = new p(), this.#n = r(), this.#r = !1, this.provideAddNodeOptions = async (e, t) => await this.#i([this.triggers.provideAddNodeOptions(e, t), this.connectors.provideAddNodeOptions(e, t)], t), this.browseAddNodeOptions = async (e) => await this.#i([this.triggers.browseAddNodeOptions(e), this.connectors.browseAddNodeOptions(e)], e), this.provideAddNodeOptionChoices = async (e, t) => await (e.startsWith("trigger:") ? this.triggers.provideAddNodeOptionChoices(e, t) : this.connectors.provideAddNodeOptionChoices(e, t)), this.#t = o;
|
|
3166
|
+
let c = (e) => {
|
|
3167
|
+
this.#r || this.#n.set(e);
|
|
3168
|
+
};
|
|
3169
|
+
this.runs = new _(e, c, o), this.workspace = new Ot(e, c, n, o, (t) => void this.#a(e, t)), this.connectors = new be(e, this.workspace, c, s, o), this.triggers = new Se(e, this.workspace, c, s, o), this.publications = new pe(e, this.workspace, c, n, o), this.runRequests = new _e(e, this.runs, c, o, n);
|
|
3170
|
+
let u = /* @__PURE__ */ new Map(), d, f = i((e) => {
|
|
3171
|
+
let t = e(this.workspace.$.draft);
|
|
3172
|
+
d != t?.projectId && (u.clear(), d = t?.projectId);
|
|
3173
|
+
let n = e(this.workspace.$.target), r = e(this.workspace.$.presentation)?.value, i = e(this.workspace.$.diagnostics)?.diagnostics, a = e(this.connectors.$.actions), s = e(this.connectors.$.catalogs), c = e(o.t$), l = e(this.runs.$.run), f = e(this.runs.$.events), p = n == null ? "" : `${n.kind}:${n.id}`, m = [
|
|
3174
|
+
...At(t, n),
|
|
3175
|
+
r == null || n == null ? void 0 : y(r, n),
|
|
3176
|
+
i,
|
|
3177
|
+
a,
|
|
3178
|
+
s,
|
|
3179
|
+
c,
|
|
3180
|
+
l,
|
|
3181
|
+
f,
|
|
3182
|
+
...l == null ? [] : [t?.revisionId]
|
|
3183
|
+
], h = u.get(p);
|
|
3184
|
+
if (h != null && h.inputs.length == m.length && h.inputs.every((e, t) => e === m[t])) return h.graph;
|
|
3185
|
+
let g = v(t, n, r, i, a, s, c, l, f);
|
|
3186
|
+
return u.set(p, {
|
|
3187
|
+
graph: g,
|
|
3188
|
+
inputs: m
|
|
3189
|
+
}), g;
|
|
3190
|
+
}), m = a(f, kt);
|
|
3191
|
+
this.$ = {
|
|
3192
|
+
busy: i((e) => {
|
|
3193
|
+
let t = e(this.workspace.$.busy);
|
|
3194
|
+
if (t != null) return t;
|
|
3195
|
+
if (e(this.runRequests.$.starting)) return "run";
|
|
3196
|
+
if (e(this.runs.$.cancelingRunId) != null) return "cancel";
|
|
3197
|
+
if (e(this.publications.$.publishing)) return "publish";
|
|
3198
|
+
if (e(this.publications.$.rollingBackPublicationId) != null) return "rollback";
|
|
3199
|
+
if (e(this.publications.$.changingTriggerId) != null) return "trigger";
|
|
3200
|
+
}),
|
|
3201
|
+
designer: f,
|
|
3202
|
+
designerNodeById: m,
|
|
3203
|
+
notice: this.#n,
|
|
3204
|
+
runEventNodes: i((e) => jt(e(this.workspace.$.draft), e(this.workspace.$.target), e(this.runs.$.run), e(this.runs.$.events), e(m))),
|
|
3205
|
+
selectedDesignerNode: i((e) => {
|
|
3206
|
+
let t = e(this.workspace.$.selectedNodeIds);
|
|
3207
|
+
return t.length == 1 ? e(m).get(t[0]) : void 0;
|
|
3208
|
+
})
|
|
3209
|
+
};
|
|
3210
|
+
}
|
|
3211
|
+
dispose() {
|
|
3212
|
+
this.#r = !0, this.#e.invalidate();
|
|
3213
|
+
for (let e of Object.values(this.$)) e.dispose();
|
|
3214
|
+
this.connectors.dispose(), this.publications.dispose(), this.runRequests.dispose(), this.runs.dispose(), this.triggers.dispose(), this.workspace.dispose();
|
|
3215
|
+
}
|
|
3216
|
+
async start(e, t) {
|
|
3217
|
+
this.#e.invalidate(), this.connectors.reset(), this.triggers.reset(), this.publications.reset(), this.runRequests.reset(), this.runs.reset(), await this.workspace.start(e, t);
|
|
3218
|
+
}
|
|
3219
|
+
async retryProjects() {
|
|
3220
|
+
await this.workspace.reloadProjects();
|
|
3221
|
+
}
|
|
3222
|
+
dismissNotice() {
|
|
3223
|
+
this.#r || this.#n.set(void 0);
|
|
3224
|
+
}
|
|
3225
|
+
async selectProject(e, t) {
|
|
3226
|
+
return this.#r || (this.#e.invalidate(), this.#n.set(void 0), !await this.workspace.selectProject(e, t)) ? !1 : (this.connectors.reset(), this.triggers.reset(), this.publications.reset(), this.runRequests.reset(), this.runs.reset(), !0);
|
|
3227
|
+
}
|
|
3228
|
+
async createProject(e) {
|
|
3229
|
+
let t = await this.workspace.createProject(e);
|
|
3230
|
+
return this.#r || t == null ? !1 : (await this.selectProject(t.projectId), this.#r || this.#n.set({
|
|
3231
|
+
kind: "success",
|
|
3232
|
+
message: this.#t.t("notice.created", { name: t.name })
|
|
3233
|
+
}), !0);
|
|
3234
|
+
}
|
|
3235
|
+
selectNodes(e) {
|
|
3236
|
+
this.workspace.selectNodes(e) && (this.connectors.refresh(), this.triggers.refresh());
|
|
3237
|
+
}
|
|
3238
|
+
locateRunEvent(e) {
|
|
3239
|
+
let t = this.$.runEventNodes.value.get(e);
|
|
3240
|
+
return t != null && this.workspace.locateNode(t);
|
|
3241
|
+
}
|
|
3242
|
+
async addNode(e, t, n) {
|
|
3243
|
+
if (e.kind == "trigger" && "trigger" in e && e.trigger.kind == "connect") {
|
|
3244
|
+
await this.triggers.connect(e.trigger.provider);
|
|
3245
|
+
return;
|
|
3246
|
+
}
|
|
3247
|
+
let r = await this.workspace.addNode(e, t, n);
|
|
3248
|
+
return r != null && e.kind == "connector" && this.connectors.refresh(), r != null && e.kind == "trigger" && this.triggers.refresh(), r;
|
|
3249
|
+
}
|
|
3250
|
+
async #i(e, t) {
|
|
3251
|
+
let n = await Promise.allSettled(e);
|
|
3252
|
+
if (t.aborted || this.#r) return;
|
|
3253
|
+
let r = n.filter((e) => e.status == "rejected");
|
|
3254
|
+
if (r.length > 0 && r.length == n.length) throw r[0].reason;
|
|
3255
|
+
return r.length > 0 && this.#n.set(o(r[0].reason, this.#t.t)), n.flatMap((e) => e.status == "fulfilled" ? e.value ?? [] : []);
|
|
3256
|
+
}
|
|
3257
|
+
async refreshSelectedConnector(e = !1) {
|
|
3258
|
+
await this.connectors.refresh(e);
|
|
3259
|
+
}
|
|
3260
|
+
async requestDraftRun() {
|
|
3261
|
+
let e = this.workspace.$.projectId.value, t = this.workspace.$.targetFlow.value, n = this.workspace.$.draft.value;
|
|
3262
|
+
return e == null || t == null || n == null ? "unavailable" : await this.runRequests.requestDraft(e, t, n);
|
|
3263
|
+
}
|
|
3264
|
+
async requestLiveRun() {
|
|
3265
|
+
let e = this.workspace.$.projectId.value, t = this.workspace.$.targetFlow.value;
|
|
3266
|
+
return e == null || t == null ? "unavailable" : await this.runRequests.requestLive(e, t);
|
|
3267
|
+
}
|
|
3268
|
+
async #a(e, t) {
|
|
3269
|
+
let n = this.workspace.$.target.value;
|
|
3270
|
+
if (this.#r || this.runRequests.$.submitting.value != null || this.workspace.$.projectId.value != t.projectId || n?.kind != "flow" || n.id != t.flowId) return;
|
|
3271
|
+
let r = this.#e.begin();
|
|
3272
|
+
try {
|
|
3273
|
+
let n = await e.getRun(t.projectId, t.runId), i = this.workspace.$.target.value;
|
|
3274
|
+
if (!r() || this.#r || this.workspace.$.projectId.value != t.projectId || i?.kind != "flow" || i.id != t.flowId || n.projectId != t.projectId || n.flowId != t.flowId || n.runId != t.runId) return;
|
|
3275
|
+
this.runs.followExternal(n);
|
|
3276
|
+
} catch {
|
|
3277
|
+
return;
|
|
3278
|
+
}
|
|
3279
|
+
}
|
|
3280
|
+
}, Pt = ae(() => import("./flowWorkspace-DwVMpcar.js"));
|
|
3281
|
+
function Ft({ host: e, store: t }) {
|
|
3282
|
+
let r = n(t.$.notice);
|
|
3283
|
+
return C(() => e.notify(r), [e, r]), C(() => () => e.notify(void 0), [e]), null;
|
|
3284
|
+
}
|
|
3285
|
+
function It({ language: e, navigation: t, onLanguageChange: r, store: i, theme: a }) {
|
|
3286
|
+
let o = n(i.workspace.$.projectId), s = n(i.workspace.$.target);
|
|
3287
|
+
return /* @__PURE__ */ w("div", {
|
|
3288
|
+
className: "app-shell",
|
|
3289
|
+
children: o == null ? /* @__PURE__ */ w(b, {
|
|
3290
|
+
language: e,
|
|
3291
|
+
onCreateProject: (e) => t.createProject(e),
|
|
3292
|
+
onLanguageChange: r,
|
|
3293
|
+
onSelectProject: (e) => void t.selectProject(e),
|
|
3294
|
+
store: i
|
|
3295
|
+
}) : s == null ? /* @__PURE__ */ w(ne, {
|
|
3296
|
+
language: e,
|
|
3297
|
+
onCreateFlow: (e) => t.createFlow(e),
|
|
3298
|
+
onLanguageChange: r,
|
|
3299
|
+
onOpenProjects: () => void t.openProjects(),
|
|
3300
|
+
onSelectFlow: (e) => t.selectFlow(e),
|
|
3301
|
+
store: i
|
|
3302
|
+
}) : /* @__PURE__ */ w(ie, {
|
|
3303
|
+
fallback: /* @__PURE__ */ w("main", {
|
|
3304
|
+
"aria-busy": "true",
|
|
3305
|
+
className: "workspace"
|
|
3306
|
+
}),
|
|
3307
|
+
children: /* @__PURE__ */ w(Pt, {
|
|
3308
|
+
language: e,
|
|
3309
|
+
navigation: t,
|
|
3310
|
+
onLanguageChange: r,
|
|
3311
|
+
store: i,
|
|
3312
|
+
theme: a
|
|
3313
|
+
})
|
|
3314
|
+
})
|
|
3315
|
+
});
|
|
3316
|
+
}
|
|
3317
|
+
function Lt({ host: t, language: n, location: r, onLanguageChange: i, onNavigate: a, preferences: o, theme: s }) {
|
|
3318
|
+
let c = oe(a);
|
|
3319
|
+
c.current = a;
|
|
3320
|
+
let [{ i18n: u, navigation: d, store: f }] = se(() => {
|
|
3321
|
+
let e = l(n), i = new Nt(new re((e, n) => t.request(e, n), (e, n) => t.subscribeProject(e, n)), o, () => crypto.randomUUID(), e, t);
|
|
3322
|
+
return {
|
|
3323
|
+
i18n: e,
|
|
3324
|
+
navigation: new ue(i, r, (e, t) => c.current(e, t)),
|
|
3325
|
+
store: i
|
|
3326
|
+
};
|
|
3327
|
+
});
|
|
3328
|
+
return C(() => {
|
|
3329
|
+
d.start();
|
|
3330
|
+
let e = () => {
|
|
3331
|
+
f.connectors.refreshAfterAuthorization(), f.triggers.refreshAfterAuthorization();
|
|
3332
|
+
};
|
|
3333
|
+
return globalThis.addEventListener("focus", e), () => {
|
|
3334
|
+
globalThis.removeEventListener("focus", e), d.dispose(), f.dispose(), u.dispose();
|
|
3335
|
+
};
|
|
3336
|
+
}, [
|
|
3337
|
+
u,
|
|
3338
|
+
d,
|
|
3339
|
+
f
|
|
3340
|
+
]), C(() => void d.apply(r), [r, d]), C(() => {
|
|
3341
|
+
u.lang != n && u.switchLang(n);
|
|
3342
|
+
}, [u, n]), /* @__PURE__ */ w(e, {
|
|
3343
|
+
i18n: u,
|
|
3344
|
+
children: /* @__PURE__ */ ce("div", {
|
|
3345
|
+
className: "open-flow-workbench",
|
|
3346
|
+
"data-theme": s,
|
|
3347
|
+
children: [/* @__PURE__ */ w(Ft, {
|
|
3348
|
+
host: t,
|
|
3349
|
+
store: f
|
|
3350
|
+
}), /* @__PURE__ */ w(It, {
|
|
3351
|
+
language: n,
|
|
3352
|
+
navigation: d,
|
|
3353
|
+
onLanguageChange: i,
|
|
3354
|
+
store: f,
|
|
3355
|
+
theme: s
|
|
3356
|
+
})]
|
|
3357
|
+
})
|
|
3358
|
+
});
|
|
3359
|
+
}
|
|
3360
|
+
function Rt({ sessionKey: e, ...t }) {
|
|
3361
|
+
return /* @__PURE__ */ w(Lt, { ...t }, e);
|
|
3362
|
+
}
|
|
3363
|
+
//#endregion
|
|
3364
|
+
export { Rt as OpenFlowWorkbench };
|