@notmrabhi/flowforge 0.1.105 → 0.1.106

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.
@@ -1,371 +0,0 @@
1
- const j = {
2
- triggerToCategory: {},
3
- schedulerEventTypes: [],
4
- conditionPathPrefix: "",
5
- defaultWorkflowCategory: "",
6
- endEventIds: {
7
- success: "endEventSuccess",
8
- failure: "endEventFailure",
9
- rejected: "endEventRejected"
10
- },
11
- endEventNames: {
12
- success: "Success",
13
- failure: "Failure",
14
- rejected: "Rejected"
15
- },
16
- startEventId: "startEvent",
17
- triggerConfigDefaults: {}
18
- };
19
- function S(e) {
20
- if (!e || typeof e != "object") return {};
21
- const t = {};
22
- return Object.keys(e).forEach((s) => {
23
- s.startsWith("_") || (t[s] = e[s]);
24
- }), t;
25
- }
26
- const k = /* @__PURE__ */ new Set([
27
- "start",
28
- "end",
29
- "triggerFixed",
30
- "addTrigger",
31
- "addStep"
32
- ]), K = (e) => !!e && !k.has(String(e.kind ?? ""));
33
- function C(e, t) {
34
- return e == null ? "" : String(e).replace(
35
- /\$\{(\w+)\}/g,
36
- (s, i) => Object.prototype.hasOwnProperty.call(t, i) ? String(t[i]) : s
37
- );
38
- }
39
- function W(e, t) {
40
- var n, v, o, c, p;
41
- if (!e || typeof e != "object") return "";
42
- const { from: s, key: i, value: r } = e;
43
- return s === "literal" ? r === void 0 ? "" : String(r) : s === "task" ? String(((n = t.task) == null ? void 0 : n[i ?? ""]) ?? "") : s === "ctx" ? String(((v = t.ctx) == null ? void 0 : v[i ?? ""]) ?? "") : s === "slot" ? String(((o = t.slot) == null ? void 0 : o[i ?? ""]) ?? "") : s === "formData" ? String(((p = (c = t.slot) == null ? void 0 : c.formData) == null ? void 0 : p[i ?? ""]) ?? "") : "";
44
- }
45
- function B(e, t) {
46
- var i, r, n;
47
- const s = e == null ? void 0 : e.source;
48
- if (!s) return "";
49
- if (s.type === "literal")
50
- return typeof s.value == "string" ? s.value : JSON.stringify(s.value ?? "");
51
- if (s.type === "json" || s.type === "taskConfig") {
52
- const v = s.shape || {}, o = {};
53
- return Object.keys(v).forEach((c) => {
54
- o[c] = W(v[c], t);
55
- }), JSON.stringify(o);
56
- }
57
- if (s.type === "formData") {
58
- if (s.passthrough) {
59
- const v = new Set(s.exclude || []), o = {}, c = ((i = t.slot) == null ? void 0 : i.formData) ?? {};
60
- Object.keys(c).forEach((h) => {
61
- h.startsWith("_") || v.has(h) || (o[h] = c[h]);
62
- });
63
- const p = s.wrapKey ? { [s.wrapKey]: o } : o;
64
- return JSON.stringify(p);
65
- }
66
- return String(((n = (r = t.slot) == null ? void 0 : r.formData) == null ? void 0 : n[s.key ?? ""]) ?? "");
67
- }
68
- return "";
69
- }
70
- function V(e, t) {
71
- if (!(!e || typeof e != "object" || !t))
72
- return t.split(".").reduce((s, i) => {
73
- if (!(s == null || typeof s != "object"))
74
- return s[i];
75
- }, e);
76
- }
77
- function J(e, t, s) {
78
- var $;
79
- const i = e.operatorMap || {}, r = e.valuesField || "groups", n = (a) => {
80
- const u = i[String((a == null ? void 0 : a.operator) ?? "")] ?? "==", g = `${s}.${(a == null ? void 0 : a.key) ?? (a == null ? void 0 : a.field) ?? ""}`, m = `'${String((a == null ? void 0 : a.value) ?? "")}'`;
81
- return u.startsWith(".") ? `${g}${u}(${m})` : u.startsWith("!.") ? `!${g}${u.slice(1)}(${m})` : `${g} ${u} ${m}`;
82
- }, v = (a) => {
83
- var l, b;
84
- const u = Array.isArray(a) ? a : [];
85
- if (u.length === 0) return null;
86
- const g = u.map(n), y = ((l = u[0]) == null ? void 0 : l.connector) === "or" || ((b = u[0]) == null ? void 0 : b.logicalOperator) === "OR" ? "||" : "&&";
87
- return g.join(` ${y} `);
88
- }, o = [];
89
- let c = 1;
90
- const p = (a, u) => {
91
- o.push({
92
- id: `rule${c}`,
93
- inputEntries: [
94
- {
95
- id: `rule${c}InputEntry1`,
96
- text: a ? `\${(${a})}` : ""
97
- }
98
- ],
99
- outputEntries: [
100
- {
101
- id: `rule${c}OutputEntry1`,
102
- text: `"${u}"`
103
- }
104
- ]
105
- }), c += 1;
106
- }, h = Array.isArray(($ = t == null ? void 0 : t.formData) == null ? void 0 : $.groupBlocks) ? t.formData.groupBlocks : [];
107
- if (h.length > 0)
108
- return h.forEach((a) => {
109
- const u = Array.isArray(a == null ? void 0 : a[r]) ? a[r] : [], g = v(a == null ? void 0 : a.conditions);
110
- u.forEach((m) => p(g, m));
111
- }), o;
112
- const d = (t == null ? void 0 : t.formData) ?? {}, E = d._conditionConfig ?? d.conditionConfig, w = [];
113
- if (E && typeof E == "object" && Object.keys(E).forEach((a) => {
114
- const u = E[a], g = v(u);
115
- g && w.push(g);
116
- const m = Object.prototype.hasOwnProperty.call(d, a) ? d[a] : V(d, a);
117
- Array.isArray(m) ? m.forEach((y) => {
118
- const l = typeof y == "object" && y !== null ? y.value ?? y.label ?? y : y;
119
- p(g, l);
120
- }) : m != null && m !== "" ? p(g, m) : g && p(g, "");
121
- }), e.fallback === "negation") {
122
- const a = e.fallbackField || "fallback", u = d[a], g = Array.isArray(u) ? u : u != null && u !== "" ? [u] : [];
123
- if (g.length > 0) {
124
- const m = w.length > 0 ? `!(${w.map((y) => `(${y})`).join(" || ")})` : null;
125
- g.forEach((y) => {
126
- const l = typeof y == "object" && y !== null ? y.value ?? y.label ?? y : y;
127
- p(m, l);
128
- });
129
- }
130
- }
131
- return o;
132
- }
133
- function M(e, t, s) {
134
- var h;
135
- const i = e.operatorMap || {}, r = e.pathPrefix ?? s, n = e.conditionsField || "conditions", v = (h = t == null ? void 0 : t.formData) == null ? void 0 : h[n], o = Array.isArray(v) ? v : [];
136
- if (o.length === 0) return "";
137
- const c = (d) => {
138
- const E = i[String((d == null ? void 0 : d.operator) ?? "")] ?? "==", w = `${r}.${(d == null ? void 0 : d.key) ?? (d == null ? void 0 : d.field) ?? ""}`, $ = `'${String((d == null ? void 0 : d.value) ?? "")}'`;
139
- return E.startsWith("!.") ? `!${w}${E.slice(1)}(${$})` : E.startsWith(".") ? `${w}${E}(${$})` : `${w} ${E} ${$}`;
140
- };
141
- let p = c(o[0]);
142
- for (let d = 1; d < o.length; d += 1) {
143
- const E = o[d - 1], w = (E == null ? void 0 : E.connector) === "or" || (E == null ? void 0 : E.logicalOperator) === "OR";
144
- p += ` ${w ? "||" : "&&"} ${c(o[d])}`;
145
- }
146
- return p;
147
- }
148
- function G(e, t, s) {
149
- return {
150
- mappings: [],
151
- name: e.tableName,
152
- decision: {
153
- id: e.tableName,
154
- name: e.tableName,
155
- decisionTable: {
156
- id: `decisionTable_${e.tableName}`,
157
- hitPolicy: e.hitPolicy || "FIRST",
158
- inputs: [
159
- {
160
- id: `input_${e.tableName}`,
161
- inputExpression: {
162
- id: `inputExpr_${e.tableName}`,
163
- typeRef: "string",
164
- text: e.inputExpr
165
- }
166
- }
167
- ],
168
- outputs: (e.outputs || []).map((i) => ({
169
- id: i.id,
170
- label: i.label,
171
- typeRef: i.typeRef || "string",
172
- name: i.name
173
- })),
174
- rules: J(e, t, s)
175
- }
176
- }
177
- };
178
- }
179
- function U(e, t, s, i) {
180
- var g, m, y;
181
- const r = (g = t == null ? void 0 : t.ui) == null ? void 0 : g.bpmnEmit;
182
- if (!r)
183
- return {
184
- serviceTasks: [
185
- {
186
- id: e.id,
187
- name: (t == null ? void 0 : t.name) || e.descriptorType,
188
- configuration: Array.isArray(t == null ? void 0 : t.configuration) ? t.configuration : [],
189
- // Strip display-only keys (_optionLabels, _conditionConfig) — the
190
- // backend wants the clean task input only.
191
- input: S(e.formData)
192
- }
193
- ],
194
- gateways: [],
195
- callActivities: [],
196
- templateFlows: [],
197
- dmn: null,
198
- bpmnEntry: e.id,
199
- bpmnExit: e.id,
200
- outgoingConditions: {},
201
- endsNeeded: /* @__PURE__ */ new Set()
202
- };
203
- const n = {
204
- id: e.id,
205
- endFailure: i.endEventIds.failure,
206
- endRejected: i.endEventIds.rejected,
207
- endSuccess: i.endEventIds.success
208
- };
209
- if (r.conditionEmit) {
210
- const l = M(r.conditionEmit, e, i.conditionPathPrefix);
211
- n.pass = l ? `\${${l}}` : "", n.fail = l ? `\${!(${l})}` : "";
212
- }
213
- const v = { task: t, slot: e, ctx: s }, o = (r.serviceTasks || []).map((l) => ({
214
- id: C(l.idTemplate, n),
215
- name: l.name,
216
- flowableClass: l.flowableClass,
217
- extensionElements: {
218
- fields: (l.extensionFields || []).map((b) => ({
219
- name: b.name,
220
- stringValue: B(b, v)
221
- }))
222
- }
223
- }));
224
- let c = null;
225
- const p = [];
226
- r.gateway && (c = C(r.gateway.idTemplate, n), n.gateway = c, p.push({ id: c, name: r.gateway.name }));
227
- const h = /* @__PURE__ */ new Set(), d = (r.templateFlows || []).map((l) => {
228
- const b = C(l.from, n), x = C(l.to, n);
229
- return x === i.endEventIds.failure && h.add(i.endEventIds.failure), x === i.endEventIds.rejected && h.add(i.endEventIds.rejected), {
230
- id: l.idTemplate ? C(l.idTemplate, n) : `${b}-to-${x}`,
231
- sourceRef: b,
232
- targetRef: x,
233
- conditionExpression: l.condition ? C(l.condition, n) : null
234
- };
235
- }), E = [], w = r.dmnEmit ? G(r.dmnEmit, e, i.conditionPathPrefix) : null, $ = ((m = o[0]) == null ? void 0 : m.id) ?? e.id, a = c ?? ((y = o[o.length - 1]) == null ? void 0 : y.id) ?? e.id, u = {};
236
- return Object.keys(r.outgoingConditions || {}).forEach((l) => {
237
- u[l] = C(
238
- r.outgoingConditions[l],
239
- n
240
- );
241
- }), {
242
- serviceTasks: o,
243
- gateways: p,
244
- callActivities: E,
245
- templateFlows: d,
246
- dmn: w,
247
- bpmnEntry: $,
248
- bpmnExit: a,
249
- outgoingConditions: u,
250
- endsNeeded: h
251
- };
252
- }
253
- function H(e) {
254
- var N, A, R, F;
255
- const { state: t, tasksByKey: s, context: i, config: r } = e, n = {
256
- ...j,
257
- ...r ?? {},
258
- triggerToCategory: { ...j.triggerToCategory, ...(r == null ? void 0 : r.triggerToCategory) ?? {} },
259
- schedulerEventTypes: (r == null ? void 0 : r.schedulerEventTypes) ?? j.schedulerEventTypes,
260
- endEventIds: { ...j.endEventIds, ...(r == null ? void 0 : r.endEventIds) ?? {} },
261
- endEventNames: { ...j.endEventNames, ...(r == null ? void 0 : r.endEventNames) ?? {} },
262
- triggerConfigDefaults: (r == null ? void 0 : r.triggerConfigDefaults) ?? j.triggerConfigDefaults
263
- }, v = Array.isArray(t == null ? void 0 : t.slots) ? t.slots : [], o = v.find((f) => f.kind === "triggerFixed"), c = (N = o == null ? void 0 : o.nodeData) == null ? void 0 : N.eventType, p = ((A = o == null ? void 0 : o.nodeData) == null ? void 0 : A.type) || "event", h = (R = o == null ? void 0 : o.nodeData) == null ? void 0 : R.sources, d = Array.isArray(h) ? h.map(
264
- (f) => typeof f == "string" ? f : (f == null ? void 0 : f.value) ?? (f == null ? void 0 : f.key) ?? ""
265
- ).filter(Boolean) : [], E = n.triggerToCategory[c ?? ""] ?? n.defaultWorkflowCategory, $ = !!c && n.schedulerEventTypes.includes(c) ? ["SCHEDULER"] : d, u = v.filter(K).map((f) => ({
266
- slot: f,
267
- emit: U(f, s[f.descriptorType ?? ""] ?? {}, i, n)
268
- })), g = [], m = [], y = [], l = [], b = [], x = /* @__PURE__ */ new Set();
269
- u.forEach(({ emit: f }) => {
270
- g.push(...f.serviceTasks), m.push(...f.gateways), y.push(...f.callActivities), l.push(...f.templateFlows), f.dmn && b.push(f.dmn), f.endsNeeded.forEach((I) => x.add(I));
271
- });
272
- const T = [];
273
- if (u.length > 0) {
274
- T.push({
275
- id: `${n.startEventId}-to-${u[0].emit.bpmnEntry}`,
276
- sourceRef: n.startEventId,
277
- targetRef: u[0].emit.bpmnEntry,
278
- conditionExpression: null
279
- });
280
- for (let I = 0; I < u.length - 1; I += 1) {
281
- const D = u[I].emit, O = u[I + 1].emit, L = D.outgoingConditions.success ?? D.outgoingConditions.pass ?? D.outgoingConditions.approved ?? null;
282
- T.push({
283
- id: `${D.bpmnExit}-to-${O.bpmnEntry}`,
284
- sourceRef: D.bpmnExit,
285
- targetRef: O.bpmnEntry,
286
- conditionExpression: L
287
- });
288
- }
289
- const f = u[u.length - 1].emit;
290
- T.push({
291
- id: `${f.bpmnExit}-to-${n.endEventIds.success}`,
292
- sourceRef: f.bpmnExit,
293
- targetRef: n.endEventIds.success,
294
- conditionExpression: null
295
- });
296
- } else
297
- T.push({
298
- id: `${n.startEventId}-to-${n.endEventIds.success}`,
299
- sourceRef: n.startEventId,
300
- targetRef: n.endEventIds.success,
301
- conditionExpression: null
302
- });
303
- const _ = [
304
- {
305
- id: n.endEventIds.success,
306
- name: n.endEventNames.success,
307
- executionListener: null
308
- },
309
- ...x.has(n.endEventIds.failure) ? [{ id: n.endEventIds.failure, name: n.endEventNames.failure }] : [],
310
- ...x.has(n.endEventIds.rejected) ? [{ id: n.endEventIds.rejected, name: n.endEventNames.rejected }] : []
311
- ], P = {
312
- id: n.startEventId,
313
- name: "Start",
314
- ...p === "event" ? {
315
- messageEventDefinition: {
316
- messageRef: `msg_${(c || "EVENT").toLowerCase()}_${$.length > 0 ? $.join("_").toLowerCase() : "default"}_${i.customerKey}`
317
- }
318
- } : {}
319
- };
320
- return {
321
- canvasState: {
322
- slots: v,
323
- branches: (t == null ? void 0 : t.branches) ?? {}
324
- },
325
- bpmn: {
326
- customerId: `${i.customerKey}`,
327
- workflowCategory: E,
328
- sources: $,
329
- process: {
330
- name: i.workflowName,
331
- isExecutable: "true"
332
- },
333
- startEvent: P,
334
- endEvent: _,
335
- sequenceFlows: [...T, ...l],
336
- exclusiveGateways: m,
337
- serviceTasks: g,
338
- callActivities: y
339
- },
340
- ...p === "event" ? {
341
- message: {
342
- id: `msg_${(c || "event").toLowerCase()}_${$.length > 0 ? $.join("_").toLowerCase() : "default"}_${i.customerKey}`,
343
- name: `msg_${(c || "event").toLowerCase()}_${$.length > 0 ? $.join("_").toLowerCase() : "default"}_${i.customerKey}`
344
- },
345
- dmns: b
346
- } : {
347
- // Non-event trigger (e.g. scheduler). The saved config lives in the
348
- // trigger slot's formData under the trigger TYPE key — dotted field
349
- // ids like `scheduler.timeZone` get nested under `scheduler` on save.
350
- // eventType/`type` is the trigger TYPE ('scheduler'), NOT the workflow
351
- // category. Host-supplied defaults fill the canonical shape; saved
352
- // values override; internal `_*` keys are stripped.
353
- eventConfig: [
354
- {
355
- eventType: p,
356
- config: {
357
- type: p,
358
- ...n.triggerConfigDefaults[p] ?? {},
359
- ...S(
360
- (F = o == null ? void 0 : o.formData) == null ? void 0 : F[p]
361
- )
362
- }
363
- }
364
- ]
365
- }
366
- };
367
- }
368
- export {
369
- H as b
370
- };
371
- //# sourceMappingURL=buildBackendPayload-c7Arn1ji.js.map