@flowgram.ai/runtime-js 0.4.13 → 0.4.15
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/esm/index.js +261 -124
- package/dist/esm/index.js.map +1 -1
- package/dist/index.js +267 -130
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -28,8 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
30
|
// src/index.ts
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
33
|
TaskCancelAPI: () => TaskCancelAPI,
|
|
34
34
|
TaskReportAPI: () => TaskReportAPI,
|
|
35
35
|
TaskResultAPI: () => TaskResultAPI,
|
|
@@ -37,7 +37,7 @@ __export(src_exports, {
|
|
|
37
37
|
TaskValidateAPI: () => TaskValidateAPI,
|
|
38
38
|
WorkflowRuntimeAPIs: () => WorkflowRuntimeAPIs
|
|
39
39
|
});
|
|
40
|
-
module.exports = __toCommonJS(
|
|
40
|
+
module.exports = __toCommonJS(index_exports);
|
|
41
41
|
|
|
42
42
|
// ../interface/dist/esm/index.js
|
|
43
43
|
var import_zod = __toESM(require("zod"), 1);
|
|
@@ -228,6 +228,8 @@ var WorkflowVariableType = /* @__PURE__ */ ((WorkflowVariableType2) => {
|
|
|
228
228
|
WorkflowVariableType2["Boolean"] = "boolean";
|
|
229
229
|
WorkflowVariableType2["Object"] = "object";
|
|
230
230
|
WorkflowVariableType2["Array"] = "array";
|
|
231
|
+
WorkflowVariableType2["Map"] = "map";
|
|
232
|
+
WorkflowVariableType2["DateTime"] = "date-time";
|
|
231
233
|
WorkflowVariableType2["Null"] = "null";
|
|
232
234
|
return WorkflowVariableType2;
|
|
233
235
|
})(WorkflowVariableType || {});
|
|
@@ -248,23 +250,23 @@ var FlowGramNode = /* @__PURE__ */ ((FlowGramNode22) => {
|
|
|
248
250
|
FlowGramNode22["Continue"] = "continue";
|
|
249
251
|
return FlowGramNode22;
|
|
250
252
|
})(FlowGramNode || {});
|
|
251
|
-
var
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
return
|
|
267
|
-
})(
|
|
253
|
+
var ConditionOperator = /* @__PURE__ */ ((ConditionOperator22) => {
|
|
254
|
+
ConditionOperator22["EQ"] = "eq";
|
|
255
|
+
ConditionOperator22["NEQ"] = "neq";
|
|
256
|
+
ConditionOperator22["GT"] = "gt";
|
|
257
|
+
ConditionOperator22["GTE"] = "gte";
|
|
258
|
+
ConditionOperator22["LT"] = "lt";
|
|
259
|
+
ConditionOperator22["LTE"] = "lte";
|
|
260
|
+
ConditionOperator22["IN"] = "in";
|
|
261
|
+
ConditionOperator22["NIN"] = "nin";
|
|
262
|
+
ConditionOperator22["CONTAINS"] = "contains";
|
|
263
|
+
ConditionOperator22["NOT_CONTAINS"] = "not_contains";
|
|
264
|
+
ConditionOperator22["IS_EMPTY"] = "is_empty";
|
|
265
|
+
ConditionOperator22["IS_NOT_EMPTY"] = "is_not_empty";
|
|
266
|
+
ConditionOperator22["IS_TRUE"] = "is_true";
|
|
267
|
+
ConditionOperator22["IS_FALSE"] = "is_false";
|
|
268
|
+
return ConditionOperator22;
|
|
269
|
+
})(ConditionOperator || {});
|
|
268
270
|
var HTTPBodyType = /* @__PURE__ */ ((HTTPBodyType2) => {
|
|
269
271
|
HTTPBodyType2["None"] = "none";
|
|
270
272
|
HTTPBodyType2["FormData"] = "form-data";
|
|
@@ -321,6 +323,13 @@ var WorkflowRuntimeType;
|
|
|
321
323
|
return WorkflowVariableType.Null;
|
|
322
324
|
}
|
|
323
325
|
if (typeof value === "string") {
|
|
326
|
+
const iso8601Regex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z?$/;
|
|
327
|
+
if (iso8601Regex.test(value)) {
|
|
328
|
+
const date = new Date(value);
|
|
329
|
+
if (!isNaN(date.getTime())) {
|
|
330
|
+
return WorkflowVariableType.DateTime;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
324
333
|
return WorkflowVariableType.String;
|
|
325
334
|
}
|
|
326
335
|
if (typeof value === "boolean") {
|
|
@@ -347,11 +356,11 @@ var WorkflowRuntimeType;
|
|
|
347
356
|
}
|
|
348
357
|
return workflowType === type;
|
|
349
358
|
};
|
|
350
|
-
WorkflowRuntimeType2.isTypeEqual = (
|
|
351
|
-
if (
|
|
359
|
+
WorkflowRuntimeType2.isTypeEqual = (typeA, typeB) => {
|
|
360
|
+
if (typeA === WorkflowVariableType.Number && typeB === WorkflowVariableType.Integer || typeA === WorkflowVariableType.Integer && typeB === WorkflowVariableType.Number) {
|
|
352
361
|
return true;
|
|
353
362
|
}
|
|
354
|
-
return
|
|
363
|
+
return typeA === typeB;
|
|
355
364
|
};
|
|
356
365
|
WorkflowRuntimeType2.getArrayItemsType = (types) => {
|
|
357
366
|
const expectedType = types[0];
|
|
@@ -1086,66 +1095,80 @@ var ContinueExecutor = class {
|
|
|
1086
1095
|
};
|
|
1087
1096
|
|
|
1088
1097
|
// src/nodes/condition/index.ts
|
|
1089
|
-
var
|
|
1098
|
+
var import_lodash_es11 = require("lodash-es");
|
|
1090
1099
|
|
|
1091
1100
|
// src/nodes/condition/rules.ts
|
|
1092
1101
|
var conditionRules = {
|
|
1093
1102
|
[WorkflowVariableType.String]: {
|
|
1094
|
-
[
|
|
1095
|
-
[
|
|
1096
|
-
[
|
|
1097
|
-
[
|
|
1098
|
-
[
|
|
1099
|
-
[
|
|
1100
|
-
[
|
|
1101
|
-
[
|
|
1103
|
+
[ConditionOperator.EQ]: WorkflowVariableType.String,
|
|
1104
|
+
[ConditionOperator.NEQ]: WorkflowVariableType.String,
|
|
1105
|
+
[ConditionOperator.CONTAINS]: WorkflowVariableType.String,
|
|
1106
|
+
[ConditionOperator.NOT_CONTAINS]: WorkflowVariableType.String,
|
|
1107
|
+
[ConditionOperator.IN]: WorkflowVariableType.Array,
|
|
1108
|
+
[ConditionOperator.NIN]: WorkflowVariableType.Array,
|
|
1109
|
+
[ConditionOperator.IS_EMPTY]: WorkflowVariableType.String,
|
|
1110
|
+
[ConditionOperator.IS_NOT_EMPTY]: WorkflowVariableType.String
|
|
1102
1111
|
},
|
|
1103
1112
|
[WorkflowVariableType.Number]: {
|
|
1104
|
-
[
|
|
1105
|
-
[
|
|
1106
|
-
[
|
|
1107
|
-
[
|
|
1108
|
-
[
|
|
1109
|
-
[
|
|
1110
|
-
[
|
|
1111
|
-
[
|
|
1112
|
-
[
|
|
1113
|
-
[
|
|
1113
|
+
[ConditionOperator.EQ]: WorkflowVariableType.Number,
|
|
1114
|
+
[ConditionOperator.NEQ]: WorkflowVariableType.Number,
|
|
1115
|
+
[ConditionOperator.GT]: WorkflowVariableType.Number,
|
|
1116
|
+
[ConditionOperator.GTE]: WorkflowVariableType.Number,
|
|
1117
|
+
[ConditionOperator.LT]: WorkflowVariableType.Number,
|
|
1118
|
+
[ConditionOperator.LTE]: WorkflowVariableType.Number,
|
|
1119
|
+
[ConditionOperator.IN]: WorkflowVariableType.Array,
|
|
1120
|
+
[ConditionOperator.NIN]: WorkflowVariableType.Array,
|
|
1121
|
+
[ConditionOperator.IS_EMPTY]: WorkflowVariableType.Null,
|
|
1122
|
+
[ConditionOperator.IS_NOT_EMPTY]: WorkflowVariableType.Null
|
|
1114
1123
|
},
|
|
1115
1124
|
[WorkflowVariableType.Integer]: {
|
|
1116
|
-
[
|
|
1117
|
-
[
|
|
1118
|
-
[
|
|
1119
|
-
[
|
|
1120
|
-
[
|
|
1121
|
-
[
|
|
1122
|
-
[
|
|
1123
|
-
[
|
|
1124
|
-
[
|
|
1125
|
-
[
|
|
1125
|
+
[ConditionOperator.EQ]: WorkflowVariableType.Integer,
|
|
1126
|
+
[ConditionOperator.NEQ]: WorkflowVariableType.Integer,
|
|
1127
|
+
[ConditionOperator.GT]: WorkflowVariableType.Integer,
|
|
1128
|
+
[ConditionOperator.GTE]: WorkflowVariableType.Integer,
|
|
1129
|
+
[ConditionOperator.LT]: WorkflowVariableType.Integer,
|
|
1130
|
+
[ConditionOperator.LTE]: WorkflowVariableType.Integer,
|
|
1131
|
+
[ConditionOperator.IN]: WorkflowVariableType.Array,
|
|
1132
|
+
[ConditionOperator.NIN]: WorkflowVariableType.Array,
|
|
1133
|
+
[ConditionOperator.IS_EMPTY]: WorkflowVariableType.Null,
|
|
1134
|
+
[ConditionOperator.IS_NOT_EMPTY]: WorkflowVariableType.Null
|
|
1126
1135
|
},
|
|
1127
1136
|
[WorkflowVariableType.Boolean]: {
|
|
1128
|
-
[
|
|
1129
|
-
[
|
|
1130
|
-
[
|
|
1131
|
-
[
|
|
1132
|
-
[
|
|
1133
|
-
[
|
|
1134
|
-
[
|
|
1135
|
-
[
|
|
1137
|
+
[ConditionOperator.EQ]: WorkflowVariableType.Boolean,
|
|
1138
|
+
[ConditionOperator.NEQ]: WorkflowVariableType.Boolean,
|
|
1139
|
+
[ConditionOperator.IS_TRUE]: WorkflowVariableType.Null,
|
|
1140
|
+
[ConditionOperator.IS_FALSE]: WorkflowVariableType.Null,
|
|
1141
|
+
[ConditionOperator.IN]: WorkflowVariableType.Array,
|
|
1142
|
+
[ConditionOperator.NIN]: WorkflowVariableType.Array,
|
|
1143
|
+
[ConditionOperator.IS_EMPTY]: WorkflowVariableType.Null,
|
|
1144
|
+
[ConditionOperator.IS_NOT_EMPTY]: WorkflowVariableType.Null
|
|
1136
1145
|
},
|
|
1137
1146
|
[WorkflowVariableType.Object]: {
|
|
1138
|
-
[
|
|
1139
|
-
[
|
|
1147
|
+
[ConditionOperator.IS_EMPTY]: WorkflowVariableType.Null,
|
|
1148
|
+
[ConditionOperator.IS_NOT_EMPTY]: WorkflowVariableType.Null
|
|
1149
|
+
},
|
|
1150
|
+
[WorkflowVariableType.Map]: {
|
|
1151
|
+
[ConditionOperator.IS_EMPTY]: WorkflowVariableType.Null,
|
|
1152
|
+
[ConditionOperator.IS_NOT_EMPTY]: WorkflowVariableType.Null
|
|
1153
|
+
},
|
|
1154
|
+
[WorkflowVariableType.DateTime]: {
|
|
1155
|
+
[ConditionOperator.EQ]: WorkflowVariableType.DateTime,
|
|
1156
|
+
[ConditionOperator.NEQ]: WorkflowVariableType.DateTime,
|
|
1157
|
+
[ConditionOperator.GT]: WorkflowVariableType.DateTime,
|
|
1158
|
+
[ConditionOperator.GTE]: WorkflowVariableType.DateTime,
|
|
1159
|
+
[ConditionOperator.LT]: WorkflowVariableType.DateTime,
|
|
1160
|
+
[ConditionOperator.LTE]: WorkflowVariableType.DateTime,
|
|
1161
|
+
[ConditionOperator.IS_EMPTY]: WorkflowVariableType.Null,
|
|
1162
|
+
[ConditionOperator.IS_NOT_EMPTY]: WorkflowVariableType.Null
|
|
1140
1163
|
},
|
|
1141
1164
|
[WorkflowVariableType.Array]: {
|
|
1142
|
-
[
|
|
1143
|
-
[
|
|
1165
|
+
[ConditionOperator.IS_EMPTY]: WorkflowVariableType.Null,
|
|
1166
|
+
[ConditionOperator.IS_NOT_EMPTY]: WorkflowVariableType.Null
|
|
1144
1167
|
},
|
|
1145
1168
|
[WorkflowVariableType.Null]: {
|
|
1146
|
-
[
|
|
1147
|
-
[
|
|
1148
|
-
[
|
|
1169
|
+
[ConditionOperator.EQ]: WorkflowVariableType.Null,
|
|
1170
|
+
[ConditionOperator.IS_EMPTY]: WorkflowVariableType.Null,
|
|
1171
|
+
[ConditionOperator.IS_NOT_EMPTY]: WorkflowVariableType.Null
|
|
1149
1172
|
}
|
|
1150
1173
|
};
|
|
1151
1174
|
|
|
@@ -1154,34 +1177,34 @@ var import_lodash_es3 = require("lodash-es");
|
|
|
1154
1177
|
var conditionStringHandler = (condition) => {
|
|
1155
1178
|
const { operator } = condition;
|
|
1156
1179
|
const leftValue = condition.leftValue;
|
|
1157
|
-
if (operator ===
|
|
1180
|
+
if (operator === ConditionOperator.EQ) {
|
|
1158
1181
|
const rightValue = condition.rightValue;
|
|
1159
1182
|
return leftValue === rightValue;
|
|
1160
1183
|
}
|
|
1161
|
-
if (operator ===
|
|
1184
|
+
if (operator === ConditionOperator.NEQ) {
|
|
1162
1185
|
const rightValue = condition.rightValue;
|
|
1163
1186
|
return leftValue !== rightValue;
|
|
1164
1187
|
}
|
|
1165
|
-
if (operator ===
|
|
1188
|
+
if (operator === ConditionOperator.CONTAINS) {
|
|
1166
1189
|
const rightValue = condition.rightValue;
|
|
1167
1190
|
return leftValue.includes(rightValue);
|
|
1168
1191
|
}
|
|
1169
|
-
if (operator ===
|
|
1192
|
+
if (operator === ConditionOperator.NOT_CONTAINS) {
|
|
1170
1193
|
const rightValue = condition.rightValue;
|
|
1171
1194
|
return !leftValue.includes(rightValue);
|
|
1172
1195
|
}
|
|
1173
|
-
if (operator ===
|
|
1196
|
+
if (operator === ConditionOperator.IN) {
|
|
1174
1197
|
const rightValue = condition.rightValue;
|
|
1175
1198
|
return rightValue.includes(leftValue);
|
|
1176
1199
|
}
|
|
1177
|
-
if (operator ===
|
|
1200
|
+
if (operator === ConditionOperator.NIN) {
|
|
1178
1201
|
const rightValue = condition.rightValue;
|
|
1179
1202
|
return !rightValue.includes(leftValue);
|
|
1180
1203
|
}
|
|
1181
|
-
if (operator ===
|
|
1204
|
+
if (operator === ConditionOperator.IS_EMPTY) {
|
|
1182
1205
|
return (0, import_lodash_es3.isNil)(leftValue);
|
|
1183
1206
|
}
|
|
1184
|
-
if (operator ===
|
|
1207
|
+
if (operator === ConditionOperator.IS_NOT_EMPTY) {
|
|
1185
1208
|
return !(0, import_lodash_es3.isNil)(leftValue);
|
|
1186
1209
|
}
|
|
1187
1210
|
return false;
|
|
@@ -1192,10 +1215,10 @@ var import_lodash_es4 = require("lodash-es");
|
|
|
1192
1215
|
var conditionObjectHandler = (condition) => {
|
|
1193
1216
|
const { operator } = condition;
|
|
1194
1217
|
const leftValue = condition.leftValue;
|
|
1195
|
-
if (operator ===
|
|
1218
|
+
if (operator === ConditionOperator.IS_EMPTY) {
|
|
1196
1219
|
return (0, import_lodash_es4.isNil)(leftValue);
|
|
1197
1220
|
}
|
|
1198
|
-
if (operator ===
|
|
1221
|
+
if (operator === ConditionOperator.IS_NOT_EMPTY) {
|
|
1199
1222
|
return !(0, import_lodash_es4.isNil)(leftValue);
|
|
1200
1223
|
}
|
|
1201
1224
|
return false;
|
|
@@ -1206,42 +1229,42 @@ var import_lodash_es5 = require("lodash-es");
|
|
|
1206
1229
|
var conditionNumberHandler = (condition) => {
|
|
1207
1230
|
const { operator } = condition;
|
|
1208
1231
|
const leftValue = condition.leftValue;
|
|
1209
|
-
if (operator ===
|
|
1232
|
+
if (operator === ConditionOperator.EQ) {
|
|
1210
1233
|
const rightValue = condition.rightValue;
|
|
1211
1234
|
return leftValue === rightValue;
|
|
1212
1235
|
}
|
|
1213
|
-
if (operator ===
|
|
1236
|
+
if (operator === ConditionOperator.NEQ) {
|
|
1214
1237
|
const rightValue = condition.rightValue;
|
|
1215
1238
|
return leftValue !== rightValue;
|
|
1216
1239
|
}
|
|
1217
|
-
if (operator ===
|
|
1240
|
+
if (operator === ConditionOperator.GT) {
|
|
1218
1241
|
const rightValue = condition.rightValue;
|
|
1219
1242
|
return leftValue > rightValue;
|
|
1220
1243
|
}
|
|
1221
|
-
if (operator ===
|
|
1244
|
+
if (operator === ConditionOperator.GTE) {
|
|
1222
1245
|
const rightValue = condition.rightValue;
|
|
1223
1246
|
return leftValue >= rightValue;
|
|
1224
1247
|
}
|
|
1225
|
-
if (operator ===
|
|
1248
|
+
if (operator === ConditionOperator.LT) {
|
|
1226
1249
|
const rightValue = condition.rightValue;
|
|
1227
1250
|
return leftValue < rightValue;
|
|
1228
1251
|
}
|
|
1229
|
-
if (operator ===
|
|
1252
|
+
if (operator === ConditionOperator.LTE) {
|
|
1230
1253
|
const rightValue = condition.rightValue;
|
|
1231
1254
|
return leftValue <= rightValue;
|
|
1232
1255
|
}
|
|
1233
|
-
if (operator ===
|
|
1256
|
+
if (operator === ConditionOperator.IN) {
|
|
1234
1257
|
const rightValue = condition.rightValue;
|
|
1235
1258
|
return rightValue.includes(leftValue);
|
|
1236
1259
|
}
|
|
1237
|
-
if (operator ===
|
|
1260
|
+
if (operator === ConditionOperator.NIN) {
|
|
1238
1261
|
const rightValue = condition.rightValue;
|
|
1239
1262
|
return !rightValue.includes(leftValue);
|
|
1240
1263
|
}
|
|
1241
|
-
if (operator ===
|
|
1264
|
+
if (operator === ConditionOperator.IS_EMPTY) {
|
|
1242
1265
|
return (0, import_lodash_es5.isNil)(leftValue);
|
|
1243
1266
|
}
|
|
1244
|
-
if (operator ===
|
|
1267
|
+
if (operator === ConditionOperator.IS_NOT_EMPTY) {
|
|
1245
1268
|
return !(0, import_lodash_es5.isNil)(leftValue);
|
|
1246
1269
|
}
|
|
1247
1270
|
return false;
|
|
@@ -1252,64 +1275,119 @@ var import_lodash_es6 = require("lodash-es");
|
|
|
1252
1275
|
var conditionNullHandler = (condition) => {
|
|
1253
1276
|
const { operator } = condition;
|
|
1254
1277
|
const leftValue = condition.leftValue;
|
|
1255
|
-
if (operator ===
|
|
1278
|
+
if (operator === ConditionOperator.EQ) {
|
|
1256
1279
|
return (0, import_lodash_es6.isNil)(leftValue) && (0, import_lodash_es6.isNil)(condition.rightValue);
|
|
1257
1280
|
}
|
|
1258
|
-
if (operator ===
|
|
1281
|
+
if (operator === ConditionOperator.IS_EMPTY) {
|
|
1259
1282
|
return (0, import_lodash_es6.isNil)(leftValue);
|
|
1260
1283
|
}
|
|
1261
|
-
if (operator ===
|
|
1284
|
+
if (operator === ConditionOperator.IS_NOT_EMPTY) {
|
|
1262
1285
|
return !(0, import_lodash_es6.isNil)(leftValue);
|
|
1263
1286
|
}
|
|
1264
1287
|
return false;
|
|
1265
1288
|
};
|
|
1266
1289
|
|
|
1267
|
-
// src/nodes/condition/handlers/
|
|
1290
|
+
// src/nodes/condition/handlers/map.ts
|
|
1268
1291
|
var import_lodash_es7 = require("lodash-es");
|
|
1292
|
+
var conditionMapHandler = (condition) => {
|
|
1293
|
+
const { operator } = condition;
|
|
1294
|
+
const leftValue = condition.leftValue;
|
|
1295
|
+
if (operator === ConditionOperator.IS_EMPTY) {
|
|
1296
|
+
return (0, import_lodash_es7.isNil)(leftValue);
|
|
1297
|
+
}
|
|
1298
|
+
if (operator === ConditionOperator.IS_NOT_EMPTY) {
|
|
1299
|
+
return !(0, import_lodash_es7.isNil)(leftValue);
|
|
1300
|
+
}
|
|
1301
|
+
return false;
|
|
1302
|
+
};
|
|
1303
|
+
|
|
1304
|
+
// src/nodes/condition/handlers/datetime.ts
|
|
1305
|
+
var import_lodash_es8 = require("lodash-es");
|
|
1306
|
+
var parseDateTime = (value) => {
|
|
1307
|
+
if (value instanceof Date) {
|
|
1308
|
+
return value;
|
|
1309
|
+
}
|
|
1310
|
+
return new Date(value);
|
|
1311
|
+
};
|
|
1312
|
+
var conditionDateTimeHandler = (condition) => {
|
|
1313
|
+
const { operator } = condition;
|
|
1314
|
+
const leftValue = condition.leftValue;
|
|
1315
|
+
if (operator === ConditionOperator.IS_EMPTY) {
|
|
1316
|
+
return (0, import_lodash_es8.isNil)(leftValue);
|
|
1317
|
+
}
|
|
1318
|
+
if (operator === ConditionOperator.IS_NOT_EMPTY) {
|
|
1319
|
+
return !(0, import_lodash_es8.isNil)(leftValue);
|
|
1320
|
+
}
|
|
1321
|
+
const leftTime = parseDateTime(leftValue).getTime();
|
|
1322
|
+
const rightValue = condition.rightValue;
|
|
1323
|
+
const rightTime = parseDateTime(rightValue).getTime();
|
|
1324
|
+
if (operator === ConditionOperator.EQ) {
|
|
1325
|
+
return leftTime === rightTime;
|
|
1326
|
+
}
|
|
1327
|
+
if (operator === ConditionOperator.NEQ) {
|
|
1328
|
+
return leftTime !== rightTime;
|
|
1329
|
+
}
|
|
1330
|
+
if (operator === ConditionOperator.GT) {
|
|
1331
|
+
return leftTime > rightTime;
|
|
1332
|
+
}
|
|
1333
|
+
if (operator === ConditionOperator.GTE) {
|
|
1334
|
+
return leftTime >= rightTime;
|
|
1335
|
+
}
|
|
1336
|
+
if (operator === ConditionOperator.LT) {
|
|
1337
|
+
return leftTime < rightTime;
|
|
1338
|
+
}
|
|
1339
|
+
if (operator === ConditionOperator.LTE) {
|
|
1340
|
+
return leftTime <= rightTime;
|
|
1341
|
+
}
|
|
1342
|
+
return false;
|
|
1343
|
+
};
|
|
1344
|
+
|
|
1345
|
+
// src/nodes/condition/handlers/boolean.ts
|
|
1346
|
+
var import_lodash_es9 = require("lodash-es");
|
|
1269
1347
|
var conditionBooleanHandler = (condition) => {
|
|
1270
1348
|
const { operator } = condition;
|
|
1271
1349
|
const leftValue = condition.leftValue;
|
|
1272
|
-
if (operator ===
|
|
1350
|
+
if (operator === ConditionOperator.EQ) {
|
|
1273
1351
|
const rightValue = condition.rightValue;
|
|
1274
1352
|
return leftValue === rightValue;
|
|
1275
1353
|
}
|
|
1276
|
-
if (operator ===
|
|
1354
|
+
if (operator === ConditionOperator.NEQ) {
|
|
1277
1355
|
const rightValue = condition.rightValue;
|
|
1278
1356
|
return leftValue !== rightValue;
|
|
1279
1357
|
}
|
|
1280
|
-
if (operator ===
|
|
1358
|
+
if (operator === ConditionOperator.IS_TRUE) {
|
|
1281
1359
|
return leftValue === true;
|
|
1282
1360
|
}
|
|
1283
|
-
if (operator ===
|
|
1361
|
+
if (operator === ConditionOperator.IS_FALSE) {
|
|
1284
1362
|
return leftValue === false;
|
|
1285
1363
|
}
|
|
1286
|
-
if (operator ===
|
|
1364
|
+
if (operator === ConditionOperator.IN) {
|
|
1287
1365
|
const rightValue = condition.rightValue;
|
|
1288
1366
|
return rightValue.includes(leftValue);
|
|
1289
1367
|
}
|
|
1290
|
-
if (operator ===
|
|
1368
|
+
if (operator === ConditionOperator.NIN) {
|
|
1291
1369
|
const rightValue = condition.rightValue;
|
|
1292
1370
|
return !rightValue.includes(leftValue);
|
|
1293
1371
|
}
|
|
1294
|
-
if (operator ===
|
|
1295
|
-
return (0,
|
|
1372
|
+
if (operator === ConditionOperator.IS_EMPTY) {
|
|
1373
|
+
return (0, import_lodash_es9.isNil)(leftValue);
|
|
1296
1374
|
}
|
|
1297
|
-
if (operator ===
|
|
1298
|
-
return !(0,
|
|
1375
|
+
if (operator === ConditionOperator.IS_NOT_EMPTY) {
|
|
1376
|
+
return !(0, import_lodash_es9.isNil)(leftValue);
|
|
1299
1377
|
}
|
|
1300
1378
|
return false;
|
|
1301
1379
|
};
|
|
1302
1380
|
|
|
1303
1381
|
// src/nodes/condition/handlers/array.ts
|
|
1304
|
-
var
|
|
1382
|
+
var import_lodash_es10 = require("lodash-es");
|
|
1305
1383
|
var conditionArrayHandler = (condition) => {
|
|
1306
1384
|
const { operator } = condition;
|
|
1307
1385
|
const leftValue = condition.leftValue;
|
|
1308
|
-
if (operator ===
|
|
1309
|
-
return (0,
|
|
1386
|
+
if (operator === ConditionOperator.IS_EMPTY) {
|
|
1387
|
+
return (0, import_lodash_es10.isNil)(leftValue);
|
|
1310
1388
|
}
|
|
1311
|
-
if (operator ===
|
|
1312
|
-
return !(0,
|
|
1389
|
+
if (operator === ConditionOperator.IS_NOT_EMPTY) {
|
|
1390
|
+
return !(0, import_lodash_es10.isNil)(leftValue);
|
|
1313
1391
|
}
|
|
1314
1392
|
return false;
|
|
1315
1393
|
};
|
|
@@ -1321,7 +1399,9 @@ var conditionHandlers = {
|
|
|
1321
1399
|
[WorkflowVariableType.Integer]: conditionNumberHandler,
|
|
1322
1400
|
[WorkflowVariableType.Boolean]: conditionBooleanHandler,
|
|
1323
1401
|
[WorkflowVariableType.Object]: conditionObjectHandler,
|
|
1402
|
+
[WorkflowVariableType.Map]: conditionMapHandler,
|
|
1324
1403
|
[WorkflowVariableType.Array]: conditionArrayHandler,
|
|
1404
|
+
[WorkflowVariableType.DateTime]: conditionDateTimeHandler,
|
|
1325
1405
|
[WorkflowVariableType.Null]: conditionNullHandler
|
|
1326
1406
|
};
|
|
1327
1407
|
|
|
@@ -1340,7 +1420,10 @@ var ConditionExecutor = class {
|
|
|
1340
1420
|
const parsedConditions = conditions.map((item) => this.parseCondition(item, context)).filter((item) => this.checkCondition(item));
|
|
1341
1421
|
const activatedCondition = parsedConditions.find((item) => this.handleCondition(item));
|
|
1342
1422
|
if (!activatedCondition) {
|
|
1343
|
-
|
|
1423
|
+
return {
|
|
1424
|
+
outputs: {},
|
|
1425
|
+
branch: "else"
|
|
1426
|
+
};
|
|
1344
1427
|
}
|
|
1345
1428
|
return {
|
|
1346
1429
|
outputs: {},
|
|
@@ -1353,7 +1436,11 @@ var ConditionExecutor = class {
|
|
|
1353
1436
|
const parsedLeft = context.runtime.state.parseRef(left);
|
|
1354
1437
|
const leftValue = parsedLeft?.value ?? null;
|
|
1355
1438
|
const leftType = parsedLeft?.type ?? WorkflowVariableType.Null;
|
|
1356
|
-
const
|
|
1439
|
+
const expectedRightType = this.getRuleType({ leftType, operator });
|
|
1440
|
+
const parsedRight = Boolean(right) ? context.runtime.state.parseFlowValue({
|
|
1441
|
+
flowValue: right,
|
|
1442
|
+
declareType: expectedRightType
|
|
1443
|
+
}) : null;
|
|
1357
1444
|
const rightValue = parsedRight?.value ?? null;
|
|
1358
1445
|
const rightType = parsedRight?.type ?? WorkflowVariableType.Null;
|
|
1359
1446
|
return {
|
|
@@ -1367,11 +1454,11 @@ var ConditionExecutor = class {
|
|
|
1367
1454
|
}
|
|
1368
1455
|
checkCondition(condition) {
|
|
1369
1456
|
const rule = conditionRules[condition.leftType];
|
|
1370
|
-
if ((0,
|
|
1457
|
+
if ((0, import_lodash_es11.isNil)(rule)) {
|
|
1371
1458
|
throw new Error(`Condition left type "${condition.leftType}" is not supported`);
|
|
1372
1459
|
}
|
|
1373
1460
|
const ruleType = rule[condition.operator];
|
|
1374
|
-
if ((0,
|
|
1461
|
+
if ((0, import_lodash_es11.isNil)(ruleType)) {
|
|
1375
1462
|
throw new Error(
|
|
1376
1463
|
`Condition left type "${condition.leftType}" has no operator "${condition.operator}"`
|
|
1377
1464
|
);
|
|
@@ -1389,6 +1476,18 @@ var ConditionExecutor = class {
|
|
|
1389
1476
|
const isActive = handler(condition);
|
|
1390
1477
|
return isActive;
|
|
1391
1478
|
}
|
|
1479
|
+
getRuleType(params) {
|
|
1480
|
+
const { leftType, operator } = params;
|
|
1481
|
+
const rule = conditionRules[leftType];
|
|
1482
|
+
if ((0, import_lodash_es11.isNil)(rule)) {
|
|
1483
|
+
return WorkflowVariableType.Null;
|
|
1484
|
+
}
|
|
1485
|
+
const ruleType = rule[operator];
|
|
1486
|
+
if ((0, import_lodash_es11.isNil)(ruleType)) {
|
|
1487
|
+
return WorkflowVariableType.Null;
|
|
1488
|
+
}
|
|
1489
|
+
return ruleType;
|
|
1490
|
+
}
|
|
1392
1491
|
};
|
|
1393
1492
|
|
|
1394
1493
|
// src/nodes/code/index.ts
|
|
@@ -1921,7 +2020,7 @@ var WorkflowRuntimeCache = class {
|
|
|
1921
2020
|
};
|
|
1922
2021
|
|
|
1923
2022
|
// src/domain/variable/variable-store/index.ts
|
|
1924
|
-
var
|
|
2023
|
+
var import_lodash_es12 = require("lodash-es");
|
|
1925
2024
|
|
|
1926
2025
|
// src/domain/variable/variable-value-object/index.ts
|
|
1927
2026
|
var WorkflowRuntimeVariable;
|
|
@@ -1990,7 +2089,7 @@ var WorkflowRuntimeVariableStore = class {
|
|
|
1990
2089
|
variable.value = value;
|
|
1991
2090
|
return;
|
|
1992
2091
|
}
|
|
1993
|
-
(0,
|
|
2092
|
+
(0, import_lodash_es12.set)(variable.value, variablePath, value);
|
|
1994
2093
|
}
|
|
1995
2094
|
getValue(params) {
|
|
1996
2095
|
const { nodeID, variableKey, variablePath } = params;
|
|
@@ -2005,7 +2104,7 @@ var WorkflowRuntimeVariableStore = class {
|
|
|
2005
2104
|
itemsType: variable.itemsType
|
|
2006
2105
|
};
|
|
2007
2106
|
}
|
|
2008
|
-
const value = (0,
|
|
2107
|
+
const value = (0, import_lodash_es12.get)(variable.value, variablePath);
|
|
2009
2108
|
const type = WorkflowRuntimeType.getWorkflowType(value);
|
|
2010
2109
|
if (!type) {
|
|
2011
2110
|
return null;
|
|
@@ -2130,13 +2229,14 @@ var WorkflowRuntimeStatusCenter = class {
|
|
|
2130
2229
|
};
|
|
2131
2230
|
|
|
2132
2231
|
// src/domain/state/index.ts
|
|
2133
|
-
var
|
|
2232
|
+
var import_lodash_es13 = require("lodash-es");
|
|
2134
2233
|
var WorkflowRuntimeState = class {
|
|
2135
2234
|
constructor(variableStore) {
|
|
2136
2235
|
this.variableStore = variableStore;
|
|
2137
2236
|
this.id = uuid();
|
|
2138
2237
|
}
|
|
2139
|
-
init() {
|
|
2238
|
+
init(schema) {
|
|
2239
|
+
this.setGlobalVariable(schema?.globalVariable);
|
|
2140
2240
|
this.executedNodes = /* @__PURE__ */ new Set();
|
|
2141
2241
|
}
|
|
2142
2242
|
dispose() {
|
|
@@ -2153,16 +2253,17 @@ var WorkflowRuntimeState = class {
|
|
|
2153
2253
|
setNodeOutputs(params) {
|
|
2154
2254
|
const { node, outputs } = params;
|
|
2155
2255
|
const outputsDeclare = node.declare.outputs;
|
|
2156
|
-
if (!outputsDeclare) {
|
|
2256
|
+
if (outputsDeclare?.type !== "object" || !outputsDeclare.properties) {
|
|
2157
2257
|
return;
|
|
2158
2258
|
}
|
|
2159
|
-
Object.entries(
|
|
2160
|
-
|
|
2161
|
-
if (!typeInfo) {
|
|
2259
|
+
Object.entries(outputsDeclare.properties).forEach(([key, typeInfo]) => {
|
|
2260
|
+
if (!key || !typeInfo) {
|
|
2162
2261
|
return;
|
|
2163
2262
|
}
|
|
2164
2263
|
const type = typeInfo.type;
|
|
2165
2264
|
const itemsType = typeInfo.items?.type;
|
|
2265
|
+
const defaultValue = this.parseJSONContent(typeInfo.default, type);
|
|
2266
|
+
const value = outputs[key] ?? defaultValue;
|
|
2166
2267
|
this.variableStore.setVariable({
|
|
2167
2268
|
nodeID: node.id,
|
|
2168
2269
|
key,
|
|
@@ -2177,18 +2278,18 @@ var WorkflowRuntimeState = class {
|
|
|
2177
2278
|
if (!declare || !values) {
|
|
2178
2279
|
return {};
|
|
2179
2280
|
}
|
|
2180
|
-
return Object.entries(values).reduce((prev, [key,
|
|
2281
|
+
return Object.entries(values).reduce((prev, [key, flowValue]) => {
|
|
2181
2282
|
const typeInfo = declare.properties?.[key];
|
|
2182
2283
|
if (!typeInfo) {
|
|
2183
2284
|
return prev;
|
|
2184
2285
|
}
|
|
2185
|
-
const
|
|
2186
|
-
const result = this.
|
|
2286
|
+
const declareType = typeInfo.type;
|
|
2287
|
+
const result = this.parseFlowValue({ flowValue, declareType });
|
|
2187
2288
|
if (!result) {
|
|
2188
2289
|
return prev;
|
|
2189
2290
|
}
|
|
2190
2291
|
const { value, type } = result;
|
|
2191
|
-
if (!WorkflowRuntimeType.isTypeEqual(type,
|
|
2292
|
+
if (!WorkflowRuntimeType.isTypeEqual(type, declareType)) {
|
|
2192
2293
|
return prev;
|
|
2193
2294
|
}
|
|
2194
2295
|
prev[key] = value;
|
|
@@ -2239,14 +2340,15 @@ var WorkflowRuntimeState = class {
|
|
|
2239
2340
|
value: parsedValue
|
|
2240
2341
|
};
|
|
2241
2342
|
}
|
|
2242
|
-
|
|
2343
|
+
parseFlowValue(params) {
|
|
2344
|
+
const { flowValue, declareType } = params;
|
|
2243
2345
|
if (!flowValue?.type) {
|
|
2244
2346
|
throw new Error(`Invalid flow value type: ${flowValue.type}`);
|
|
2245
2347
|
}
|
|
2246
2348
|
if (flowValue.type === "constant") {
|
|
2247
|
-
const value = flowValue.content;
|
|
2248
|
-
const type = WorkflowRuntimeType.getWorkflowType(value);
|
|
2249
|
-
if ((0,
|
|
2349
|
+
const value = this.parseJSONContent(flowValue.content, declareType);
|
|
2350
|
+
const type = declareType ?? WorkflowRuntimeType.getWorkflowType(value);
|
|
2351
|
+
if ((0, import_lodash_es13.isNil)(value) || !type) {
|
|
2250
2352
|
return null;
|
|
2251
2353
|
}
|
|
2252
2354
|
return {
|
|
@@ -2268,6 +2370,41 @@ var WorkflowRuntimeState = class {
|
|
|
2268
2370
|
addExecutedNode(node) {
|
|
2269
2371
|
this.executedNodes.add(node.id);
|
|
2270
2372
|
}
|
|
2373
|
+
parseJSONContent(jsonContent, declareType) {
|
|
2374
|
+
const JSONTypes = [
|
|
2375
|
+
WorkflowVariableType.Object,
|
|
2376
|
+
WorkflowVariableType.Array,
|
|
2377
|
+
WorkflowVariableType.Map
|
|
2378
|
+
];
|
|
2379
|
+
if (declareType && JSONTypes.includes(declareType) && typeof jsonContent === "string") {
|
|
2380
|
+
try {
|
|
2381
|
+
return JSON.parse(jsonContent);
|
|
2382
|
+
} catch (e) {
|
|
2383
|
+
return jsonContent;
|
|
2384
|
+
}
|
|
2385
|
+
}
|
|
2386
|
+
return jsonContent;
|
|
2387
|
+
}
|
|
2388
|
+
setGlobalVariable(globalVariableDeclare) {
|
|
2389
|
+
if (globalVariableDeclare?.type !== "object" || !globalVariableDeclare.properties) {
|
|
2390
|
+
return;
|
|
2391
|
+
}
|
|
2392
|
+
Object.entries(globalVariableDeclare.properties).forEach(([key, typeInfo]) => {
|
|
2393
|
+
if (!key || !typeInfo) {
|
|
2394
|
+
return;
|
|
2395
|
+
}
|
|
2396
|
+
const type = typeInfo.type;
|
|
2397
|
+
const itemsType = typeInfo.items?.type;
|
|
2398
|
+
const defaultValue = this.parseJSONContent(typeInfo.default, type);
|
|
2399
|
+
this.variableStore.setVariable({
|
|
2400
|
+
nodeID: "global",
|
|
2401
|
+
key,
|
|
2402
|
+
value: defaultValue,
|
|
2403
|
+
type,
|
|
2404
|
+
itemsType
|
|
2405
|
+
});
|
|
2406
|
+
});
|
|
2407
|
+
}
|
|
2271
2408
|
};
|
|
2272
2409
|
|
|
2273
2410
|
// src/domain/snapshot/snapshot-entity/index.ts
|
|
@@ -2743,7 +2880,7 @@ var WorkflowRuntimeContext = class _WorkflowRuntimeContext {
|
|
|
2743
2880
|
this.cache.init();
|
|
2744
2881
|
this.document.init(schema);
|
|
2745
2882
|
this.variableStore.init();
|
|
2746
|
-
this.state.init();
|
|
2883
|
+
this.state.init(schema);
|
|
2747
2884
|
this.ioCenter.init(inputs);
|
|
2748
2885
|
this.snapshotCenter.init();
|
|
2749
2886
|
this.statusCenter.init();
|
|
@@ -2929,7 +3066,7 @@ var WorkflowRuntimeEngine = class {
|
|
|
2929
3066
|
}
|
|
2930
3067
|
const targetPort = node.ports.outputs.find((port) => port.id === branch);
|
|
2931
3068
|
if (!targetPort) {
|
|
2932
|
-
throw new Error(`
|
|
3069
|
+
throw new Error(`Branch "${branch}" not found`);
|
|
2933
3070
|
}
|
|
2934
3071
|
const nextNodeIDs = new Set(targetPort.edges.map((edge) => edge.to.id));
|
|
2935
3072
|
const nextNodes = allNextNodes.filter((nextNode) => nextNodeIDs.has(nextNode.id));
|
|
@@ -2954,7 +3091,7 @@ var WorkflowRuntimeEngine = class {
|
|
|
2954
3091
|
return;
|
|
2955
3092
|
}
|
|
2956
3093
|
if (nextNodes.length === 0) {
|
|
2957
|
-
throw new Error(`Node ${node.id} has no next nodes`);
|
|
3094
|
+
throw new Error(`Node "${node.id}" has no next nodes`);
|
|
2958
3095
|
}
|
|
2959
3096
|
await Promise.all(
|
|
2960
3097
|
nextNodes.map(
|