next-workflow-builder 0.4.6 → 0.5.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/dist/{chunk-X5GOM4L4.js → chunk-5H76TY4T.js} +1 -1
- package/dist/{chunk-BL6QJDNB.js → chunk-CKE7ETZL.js} +1 -1
- package/dist/{chunk-MIBRBQIJ.js → chunk-EMCA7GLF.js} +145 -2
- package/dist/{chunk-KZNRU3LB.js → chunk-J72T2LRL.js} +1 -1
- package/dist/{chunk-F6HAK4HT.js → chunk-JUV5RBYM.js} +2 -2
- package/dist/{chunk-PGG52OSJ.js → chunk-PEVVELQ6.js} +1 -1
- package/dist/client/index.js +247 -190
- package/dist/{condition-IWTKYMBN.js → condition-VHC4KYLI.js} +5 -5
- package/dist/{database-query-C4GDVVDK.js → database-query-BYPF5CDB.js} +3 -3
- package/dist/{http-request-T2UP7JLH.js → http-request-4OT32ZXA.js} +1 -1
- package/dist/{loop-2237QQBO.js → loop-S5H7DSCB.js} +5 -5
- package/dist/{merge-Q5YUAT6F.js → merge-X5JAIZSZ.js} +5 -5
- package/dist/next/index.js +15 -2
- package/dist/server/api/index.js +55 -343
- package/dist/server/index.js +5 -5
- package/dist/{switch-H2N4F2YX.js → switch-WZBVDWWR.js} +5 -5
- package/package.json +1 -1
|
@@ -1038,6 +1038,142 @@ ${code}
|
|
|
1038
1038
|
`;
|
|
1039
1039
|
}
|
|
1040
1040
|
|
|
1041
|
+
// src/plugins/condition/operators.ts
|
|
1042
|
+
var DATA_TYPE_OPTIONS = [
|
|
1043
|
+
{ value: "string", label: "String" },
|
|
1044
|
+
{ value: "number", label: "Number" },
|
|
1045
|
+
{ value: "boolean", label: "Boolean" },
|
|
1046
|
+
{ value: "datetime", label: "Date & Time" }
|
|
1047
|
+
];
|
|
1048
|
+
var OPERATORS = {
|
|
1049
|
+
string: [
|
|
1050
|
+
{ value: "exists", label: "exists", unary: true },
|
|
1051
|
+
{ value: "doesNotExist", label: "does not exist", unary: true },
|
|
1052
|
+
{ value: "isEmpty", label: "is empty", unary: true },
|
|
1053
|
+
{ value: "isNotEmpty", label: "is not empty", unary: true },
|
|
1054
|
+
{ value: "equals", label: "equals", unary: false },
|
|
1055
|
+
{ value: "notEquals", label: "does not equal", unary: false },
|
|
1056
|
+
{ value: "contains", label: "contains", unary: false },
|
|
1057
|
+
{ value: "doesNotContain", label: "does not contain", unary: false },
|
|
1058
|
+
{ value: "startsWith", label: "starts with", unary: false },
|
|
1059
|
+
{ value: "doesNotStartWith", label: "does not start with", unary: false },
|
|
1060
|
+
{ value: "endsWith", label: "ends with", unary: false },
|
|
1061
|
+
{ value: "doesNotEndWith", label: "does not end with", unary: false },
|
|
1062
|
+
{ value: "matchesRegex", label: "matches regex", unary: false },
|
|
1063
|
+
{ value: "doesNotMatchRegex", label: "does not match regex", unary: false }
|
|
1064
|
+
],
|
|
1065
|
+
number: [
|
|
1066
|
+
{ value: "equals", label: "equals", unary: false },
|
|
1067
|
+
{ value: "notEquals", label: "does not equal", unary: false },
|
|
1068
|
+
{ value: "greaterThan", label: "greater than", unary: false },
|
|
1069
|
+
{ value: "lessThan", label: "less than", unary: false },
|
|
1070
|
+
{ value: "greaterThanOrEqual", label: "greater than or equal", unary: false },
|
|
1071
|
+
{ value: "lessThanOrEqual", label: "less than or equal", unary: false }
|
|
1072
|
+
],
|
|
1073
|
+
boolean: [
|
|
1074
|
+
{ value: "isTrue", label: "is true", unary: true },
|
|
1075
|
+
{ value: "isFalse", label: "is false", unary: true },
|
|
1076
|
+
{ value: "exists", label: "exists", unary: true },
|
|
1077
|
+
{ value: "doesNotExist", label: "does not exist", unary: true }
|
|
1078
|
+
],
|
|
1079
|
+
datetime: [
|
|
1080
|
+
{ value: "isBefore", label: "is before", unary: false },
|
|
1081
|
+
{ value: "isAfter", label: "is after", unary: false },
|
|
1082
|
+
{ value: "equals", label: "equals", unary: false }
|
|
1083
|
+
]
|
|
1084
|
+
};
|
|
1085
|
+
function evaluateOperator(dataType, operator, leftValue, rightValue) {
|
|
1086
|
+
switch (operator) {
|
|
1087
|
+
case "exists":
|
|
1088
|
+
return leftValue !== null && leftValue !== void 0;
|
|
1089
|
+
case "doesNotExist":
|
|
1090
|
+
return leftValue === null || leftValue === void 0;
|
|
1091
|
+
case "isEmpty":
|
|
1092
|
+
return leftValue === null || leftValue === void 0 || String(leftValue) === "";
|
|
1093
|
+
case "isNotEmpty":
|
|
1094
|
+
return leftValue !== null && leftValue !== void 0 && String(leftValue) !== "";
|
|
1095
|
+
case "isTrue":
|
|
1096
|
+
return Boolean(leftValue) === true;
|
|
1097
|
+
case "isFalse":
|
|
1098
|
+
return Boolean(leftValue) === false;
|
|
1099
|
+
}
|
|
1100
|
+
switch (dataType) {
|
|
1101
|
+
case "string": {
|
|
1102
|
+
const left = String(leftValue ?? "");
|
|
1103
|
+
const right = String(rightValue ?? "");
|
|
1104
|
+
switch (operator) {
|
|
1105
|
+
case "equals":
|
|
1106
|
+
return left === right;
|
|
1107
|
+
case "notEquals":
|
|
1108
|
+
return left !== right;
|
|
1109
|
+
case "contains":
|
|
1110
|
+
return left.includes(right);
|
|
1111
|
+
case "doesNotContain":
|
|
1112
|
+
return !left.includes(right);
|
|
1113
|
+
case "startsWith":
|
|
1114
|
+
return left.startsWith(right);
|
|
1115
|
+
case "doesNotStartWith":
|
|
1116
|
+
return !left.startsWith(right);
|
|
1117
|
+
case "endsWith":
|
|
1118
|
+
return left.endsWith(right);
|
|
1119
|
+
case "doesNotEndWith":
|
|
1120
|
+
return !left.endsWith(right);
|
|
1121
|
+
case "matchesRegex":
|
|
1122
|
+
try {
|
|
1123
|
+
return new RegExp(right).test(left);
|
|
1124
|
+
} catch {
|
|
1125
|
+
return false;
|
|
1126
|
+
}
|
|
1127
|
+
case "doesNotMatchRegex":
|
|
1128
|
+
try {
|
|
1129
|
+
return !new RegExp(right).test(left);
|
|
1130
|
+
} catch {
|
|
1131
|
+
return false;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
break;
|
|
1135
|
+
}
|
|
1136
|
+
case "number": {
|
|
1137
|
+
const left = Number(leftValue);
|
|
1138
|
+
const right = Number(rightValue);
|
|
1139
|
+
if (Number.isNaN(left) || Number.isNaN(right)) return false;
|
|
1140
|
+
switch (operator) {
|
|
1141
|
+
case "equals":
|
|
1142
|
+
return left === right;
|
|
1143
|
+
case "notEquals":
|
|
1144
|
+
return left !== right;
|
|
1145
|
+
case "greaterThan":
|
|
1146
|
+
return left > right;
|
|
1147
|
+
case "lessThan":
|
|
1148
|
+
return left < right;
|
|
1149
|
+
case "greaterThanOrEqual":
|
|
1150
|
+
return left >= right;
|
|
1151
|
+
case "lessThanOrEqual":
|
|
1152
|
+
return left <= right;
|
|
1153
|
+
}
|
|
1154
|
+
break;
|
|
1155
|
+
}
|
|
1156
|
+
case "boolean":
|
|
1157
|
+
break;
|
|
1158
|
+
case "datetime": {
|
|
1159
|
+
const left = new Date(leftValue).getTime();
|
|
1160
|
+
const right = new Date(rightValue).getTime();
|
|
1161
|
+
if (Number.isNaN(left) || Number.isNaN(right)) return false;
|
|
1162
|
+
switch (operator) {
|
|
1163
|
+
case "isBefore":
|
|
1164
|
+
return left < right;
|
|
1165
|
+
case "isAfter":
|
|
1166
|
+
return left > right;
|
|
1167
|
+
case "equals":
|
|
1168
|
+
return left === right;
|
|
1169
|
+
}
|
|
1170
|
+
break;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
console.warn(`[Condition] Unknown operator "${operator}" for data type "${dataType}"`);
|
|
1174
|
+
return false;
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1041
1177
|
// src/plugins/condition/index.tsx
|
|
1042
1178
|
import { GitBranch } from "lucide-react";
|
|
1043
1179
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -1049,10 +1185,14 @@ var conditionAction = {
|
|
|
1049
1185
|
icon: /* @__PURE__ */ jsx(GitBranch, { className: "size-12 text-pink-300", strokeWidth: 1.5 }),
|
|
1050
1186
|
codeGenerator: `export async function conditionStep(input: {
|
|
1051
1187
|
condition: boolean;
|
|
1188
|
+
dataType?: string;
|
|
1189
|
+
operator?: string;
|
|
1190
|
+
leftValue?: unknown;
|
|
1191
|
+
rightValue?: unknown;
|
|
1052
1192
|
}) {
|
|
1053
1193
|
"use step";
|
|
1054
|
-
|
|
1055
|
-
// Evaluate condition
|
|
1194
|
+
|
|
1195
|
+
// Evaluate structured condition
|
|
1056
1196
|
return { condition: input.condition };
|
|
1057
1197
|
}`
|
|
1058
1198
|
};
|
|
@@ -1156,6 +1296,9 @@ export {
|
|
|
1156
1296
|
sanitizeVarName,
|
|
1157
1297
|
generateWorkflowCode,
|
|
1158
1298
|
generateWorkflowModule,
|
|
1299
|
+
DATA_TYPE_OPTIONS,
|
|
1300
|
+
OPERATORS,
|
|
1301
|
+
evaluateOperator,
|
|
1159
1302
|
conditionAction,
|
|
1160
1303
|
databaseQueryAction,
|
|
1161
1304
|
httpRequestAction
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
workflowExecutions,
|
|
10
10
|
workflowExecutionsRelations,
|
|
11
11
|
workflows
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-PEVVELQ6.js";
|
|
13
13
|
|
|
14
14
|
// src/server/auth/index.ts
|
|
15
15
|
import { betterAuth } from "better-auth";
|
|
@@ -19,7 +19,7 @@ import { eq } from "drizzle-orm";
|
|
|
19
19
|
|
|
20
20
|
// src/server/auth/config-store.ts
|
|
21
21
|
function getAuthConfig() {
|
|
22
|
-
const authOptions = process.env.
|
|
22
|
+
const authOptions = process.env.NWB_AUTH_OPTIONS ? JSON.parse(process.env.NWB_AUTH_OPTIONS) : void 0;
|
|
23
23
|
return {
|
|
24
24
|
hasRealProviders: Object.keys(authOptions?.socialProviders ?? {})?.length > 0,
|
|
25
25
|
authOptions
|
|
@@ -162,7 +162,7 @@ var schema = {
|
|
|
162
162
|
apiKeys,
|
|
163
163
|
integrations
|
|
164
164
|
};
|
|
165
|
-
var connectionString = process.env.
|
|
165
|
+
var connectionString = process.env.NWB_DATABASE_URL || process.env.DATABASE_URL || "postgres://localhost:5432/workflow";
|
|
166
166
|
var migrationClient = postgres(connectionString, { max: 1 });
|
|
167
167
|
var globalForDb = globalThis;
|
|
168
168
|
var queryClient = globalForDb.queryClient ?? postgres(connectionString, { max: 10 });
|