next-workflow-builder 0.3.1 → 0.4.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/README.md +4 -0
- package/dist/client/index.js +3 -1
- package/dist/loop-YPEZHNH2.js +37 -0
- package/dist/merge-T3RP6SKV.js +107 -0
- package/dist/server/api/index.js +15 -0
- package/dist/switch-GNPFCPCA.js +68 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -160,6 +160,10 @@ For full documentation including configuration, authentication, database setup,
|
|
|
160
160
|
- [Database](https://next-workflow-builder.vercel.app/docs/database)
|
|
161
161
|
- [Deployment](https://next-workflow-builder.vercel.app/docs/deployment)
|
|
162
162
|
|
|
163
|
+
## Changelog
|
|
164
|
+
|
|
165
|
+
Full [Changelog](CHANGELOG.md) file
|
|
166
|
+
|
|
163
167
|
## License
|
|
164
168
|
|
|
165
169
|
Apache-2.0
|
package/dist/client/index.js
CHANGED
|
@@ -12634,7 +12634,9 @@ var SYSTEM_ACTION_LABELS = {
|
|
|
12634
12634
|
"Database Query": "Database",
|
|
12635
12635
|
Condition: "Condition",
|
|
12636
12636
|
"Execute Code": "System",
|
|
12637
|
-
Loop: "Loop"
|
|
12637
|
+
Loop: "Loop",
|
|
12638
|
+
Switch: "Switch",
|
|
12639
|
+
Merge: "Merge"
|
|
12638
12640
|
};
|
|
12639
12641
|
var getIntegrationFromActionType = (actionType) => {
|
|
12640
12642
|
if (SYSTEM_ACTION_LABELS[actionType]) {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
withStepLogging
|
|
3
|
+
} from "./chunk-3MSAF2TH.js";
|
|
4
|
+
|
|
5
|
+
// src/plugins/loop/loop.ts
|
|
6
|
+
import "server-only";
|
|
7
|
+
function evaluateLoop(input) {
|
|
8
|
+
const items = Array.isArray(input.items) ? input.items : [];
|
|
9
|
+
const batchSize = Math.max(1, input.batchSize || 1);
|
|
10
|
+
const currentBatchIndex = input.currentBatchIndex ?? 0;
|
|
11
|
+
const totalItems = items.length;
|
|
12
|
+
const totalBatches = Math.ceil(totalItems / batchSize);
|
|
13
|
+
const startIndex = currentBatchIndex * batchSize;
|
|
14
|
+
const endIndex = Math.min(startIndex + batchSize, totalItems);
|
|
15
|
+
const currentBatch = items.slice(startIndex, endIndex);
|
|
16
|
+
const currentItem = currentBatch[0];
|
|
17
|
+
const hasMore = currentBatchIndex < totalBatches - 1;
|
|
18
|
+
return {
|
|
19
|
+
hasMore,
|
|
20
|
+
currentBatchIndex,
|
|
21
|
+
currentBatch,
|
|
22
|
+
currentItem,
|
|
23
|
+
currentIndex: startIndex,
|
|
24
|
+
totalItems,
|
|
25
|
+
totalBatches,
|
|
26
|
+
items,
|
|
27
|
+
batchSize
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
async function loopStep(input) {
|
|
31
|
+
"use step";
|
|
32
|
+
return withStepLogging(input, () => Promise.resolve(evaluateLoop(input)));
|
|
33
|
+
}
|
|
34
|
+
loopStep.maxRetries = 0;
|
|
35
|
+
export {
|
|
36
|
+
loopStep
|
|
37
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import "./chunk-7MUXUHEL.js";
|
|
2
|
+
import "./chunk-TFNZVQEH.js";
|
|
3
|
+
import "./chunk-P3DTV3QS.js";
|
|
4
|
+
import "./chunk-5YYA34YV.js";
|
|
5
|
+
import "./chunk-OQHML4II.js";
|
|
6
|
+
import "./chunk-DJ7ANVJ3.js";
|
|
7
|
+
import "./chunk-BNYDOC3I.js";
|
|
8
|
+
import "./chunk-Z3BJJYHM.js";
|
|
9
|
+
import "./chunk-O3I2INCD.js";
|
|
10
|
+
import {
|
|
11
|
+
withStepLogging
|
|
12
|
+
} from "./chunk-3MSAF2TH.js";
|
|
13
|
+
|
|
14
|
+
// src/plugins/merge/merge.ts
|
|
15
|
+
import "server-only";
|
|
16
|
+
function getField(item, field) {
|
|
17
|
+
if (item && typeof item === "object") {
|
|
18
|
+
return item[field];
|
|
19
|
+
}
|
|
20
|
+
return void 0;
|
|
21
|
+
}
|
|
22
|
+
function mergeAppend(items1, items2) {
|
|
23
|
+
const merged = [...items1, ...items2];
|
|
24
|
+
return { merged, totalItems: merged.length };
|
|
25
|
+
}
|
|
26
|
+
function mergeByPosition(items1, items2, unmatchedHandling) {
|
|
27
|
+
const maxLength = Math.max(items1.length, items2.length);
|
|
28
|
+
const useNull = unmatchedHandling !== "discard";
|
|
29
|
+
const merged = [];
|
|
30
|
+
for (let i = 0; i < maxLength; i++) {
|
|
31
|
+
const item1 = items1[i];
|
|
32
|
+
const item2 = items2[i];
|
|
33
|
+
if (!useNull && (item1 === void 0 || item2 === void 0)) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
merged.push({
|
|
37
|
+
...item1 && typeof item1 === "object" ? item1 : { input1: item1 ?? null },
|
|
38
|
+
...item2 && typeof item2 === "object" ? item2 : { input2: item2 ?? null }
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return { merged, totalItems: merged.length };
|
|
42
|
+
}
|
|
43
|
+
function mergeByFields(items1, items2, field1, field2, joinType) {
|
|
44
|
+
const map2 = /* @__PURE__ */ new Map();
|
|
45
|
+
for (const item of items2) {
|
|
46
|
+
const key = getField(item, field2);
|
|
47
|
+
if (!map2.has(key)) {
|
|
48
|
+
map2.set(key, []);
|
|
49
|
+
}
|
|
50
|
+
map2.get(key).push(item);
|
|
51
|
+
}
|
|
52
|
+
const merged = [];
|
|
53
|
+
const matchedKeys2 = /* @__PURE__ */ new Set();
|
|
54
|
+
for (const item1 of items1) {
|
|
55
|
+
const key = getField(item1, field1);
|
|
56
|
+
const matches = map2.get(key);
|
|
57
|
+
if (matches && matches.length > 0) {
|
|
58
|
+
matchedKeys2.add(key);
|
|
59
|
+
for (const item2 of matches) {
|
|
60
|
+
merged.push({
|
|
61
|
+
...typeof item1 === "object" ? item1 : {},
|
|
62
|
+
...typeof item2 === "object" ? item2 : {}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
} else if (joinType === "leftOuter" || joinType === "fullOuter") {
|
|
66
|
+
merged.push({ ...typeof item1 === "object" ? item1 : {} });
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (joinType === "rightOuter" || joinType === "fullOuter") {
|
|
70
|
+
for (const item2 of items2) {
|
|
71
|
+
const key = getField(item2, field2);
|
|
72
|
+
if (!matchedKeys2.has(key)) {
|
|
73
|
+
merged.push({ ...typeof item2 === "object" ? item2 : {} });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return { merged, totalItems: merged.length };
|
|
78
|
+
}
|
|
79
|
+
function evaluateMerge(input) {
|
|
80
|
+
const items1 = Array.isArray(input.input1) ? input.input1 : [];
|
|
81
|
+
const items2 = Array.isArray(input.input2) ? input.input2 : [];
|
|
82
|
+
const mode = input.mode || "append";
|
|
83
|
+
switch (mode) {
|
|
84
|
+
case "append":
|
|
85
|
+
return mergeAppend(items1, items2);
|
|
86
|
+
case "combineByPosition":
|
|
87
|
+
return mergeByPosition(items1, items2, input.unmatchedHandling || "useNull");
|
|
88
|
+
case "combineByFields":
|
|
89
|
+
return mergeByFields(
|
|
90
|
+
items1,
|
|
91
|
+
items2,
|
|
92
|
+
input.matchField1 || "id",
|
|
93
|
+
input.matchField2 || "id",
|
|
94
|
+
input.joinType || "inner"
|
|
95
|
+
);
|
|
96
|
+
default:
|
|
97
|
+
return mergeAppend(items1, items2);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
async function mergeStep(input) {
|
|
101
|
+
"use step";
|
|
102
|
+
return withStepLogging(input, () => Promise.resolve(evaluateMerge(input)));
|
|
103
|
+
}
|
|
104
|
+
mergeStep.maxRetries = 0;
|
|
105
|
+
export {
|
|
106
|
+
mergeStep
|
|
107
|
+
};
|
package/dist/server/api/index.js
CHANGED
|
@@ -428,6 +428,21 @@ var SYSTEM_ACTIONS = {
|
|
|
428
428
|
// biome-ignore lint/suspicious/noExplicitAny: Dynamic module import
|
|
429
429
|
importer: () => import("../../condition-JZJH7YSJ.js"),
|
|
430
430
|
stepFunction: "conditionStep"
|
|
431
|
+
},
|
|
432
|
+
Loop: {
|
|
433
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic module import
|
|
434
|
+
importer: () => import("../../loop-YPEZHNH2.js"),
|
|
435
|
+
stepFunction: "loopStep"
|
|
436
|
+
},
|
|
437
|
+
Switch: {
|
|
438
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic module import
|
|
439
|
+
importer: () => import("../../switch-GNPFCPCA.js"),
|
|
440
|
+
stepFunction: "switchStep"
|
|
441
|
+
},
|
|
442
|
+
Merge: {
|
|
443
|
+
// biome-ignore lint/suspicious/noExplicitAny: Dynamic module import
|
|
444
|
+
importer: () => import("../../merge-T3RP6SKV.js"),
|
|
445
|
+
stepFunction: "mergeStep"
|
|
431
446
|
}
|
|
432
447
|
};
|
|
433
448
|
function replaceTemplateVariable(match, nodeId, rest, outputs, evalContext, varCounter) {
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import "./chunk-7MUXUHEL.js";
|
|
2
|
+
import "./chunk-TFNZVQEH.js";
|
|
3
|
+
import "./chunk-P3DTV3QS.js";
|
|
4
|
+
import "./chunk-5YYA34YV.js";
|
|
5
|
+
import "./chunk-OQHML4II.js";
|
|
6
|
+
import "./chunk-DJ7ANVJ3.js";
|
|
7
|
+
import "./chunk-BNYDOC3I.js";
|
|
8
|
+
import "./chunk-Z3BJJYHM.js";
|
|
9
|
+
import "./chunk-O3I2INCD.js";
|
|
10
|
+
import {
|
|
11
|
+
withStepLogging
|
|
12
|
+
} from "./chunk-3MSAF2TH.js";
|
|
13
|
+
|
|
14
|
+
// src/plugins/switch/switch.ts
|
|
15
|
+
import "server-only";
|
|
16
|
+
function buildRoutes(input) {
|
|
17
|
+
const routes = [];
|
|
18
|
+
for (let i = 0; i < 4; i++) {
|
|
19
|
+
const name = input[`routeName${i}`];
|
|
20
|
+
const condition = input[`routeCondition${i}`];
|
|
21
|
+
const caseValue = input[`routeCaseValue${i}`];
|
|
22
|
+
routes.push({
|
|
23
|
+
name: name || `Route ${i + 1}`,
|
|
24
|
+
condition,
|
|
25
|
+
caseValue
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return routes;
|
|
29
|
+
}
|
|
30
|
+
function evaluateSwitch(input) {
|
|
31
|
+
const mode = input.mode || "rules";
|
|
32
|
+
const routes = buildRoutes(input);
|
|
33
|
+
if (mode === "rules") {
|
|
34
|
+
for (let i = 0; i < routes.length; i++) {
|
|
35
|
+
if (routes[i].condition === true) {
|
|
36
|
+
return {
|
|
37
|
+
matchedRouteIndex: i,
|
|
38
|
+
matchedRouteName: routes[i].name,
|
|
39
|
+
isDefault: false
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
const switchValue = String(input.switchValue ?? "");
|
|
45
|
+
for (let i = 0; i < routes.length; i++) {
|
|
46
|
+
if (routes[i].caseValue !== void 0 && String(routes[i].caseValue) === switchValue) {
|
|
47
|
+
return {
|
|
48
|
+
matchedRouteIndex: i,
|
|
49
|
+
matchedRouteName: routes[i].name,
|
|
50
|
+
isDefault: false
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
matchedRouteIndex: -1,
|
|
57
|
+
matchedRouteName: "Default",
|
|
58
|
+
isDefault: true
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
async function switchStep(input) {
|
|
62
|
+
"use step";
|
|
63
|
+
return withStepLogging(input, () => Promise.resolve(evaluateSwitch(input)));
|
|
64
|
+
}
|
|
65
|
+
switchStep.maxRetries = 0;
|
|
66
|
+
export {
|
|
67
|
+
switchStep
|
|
68
|
+
};
|