@nocobase/plugin-workflow 0.13.0-alpha.4 → 0.13.0-alpha.6

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.
Files changed (72) hide show
  1. package/dist/client/index.js +132 -9332
  2. package/dist/index.js +37 -16
  3. package/dist/locale/en-US.js +22 -4
  4. package/dist/locale/es-ES.js +22 -4
  5. package/dist/locale/fr-FR.js +22 -4
  6. package/dist/locale/ja-JP.js +22 -4
  7. package/dist/locale/pt-BR.js +22 -4
  8. package/dist/locale/ru-RU.js +22 -4
  9. package/dist/locale/tr-TR.js +22 -4
  10. package/dist/locale/zh-CN.js +22 -4
  11. package/dist/node_modules/cron-parser/lib/parser.js +1 -1
  12. package/dist/node_modules/cron-parser/package.json +1 -1
  13. package/dist/node_modules/lru-cache/index-cjs.js +1 -1
  14. package/dist/node_modules/lru-cache/package.json +1 -1
  15. package/dist/server/Plugin.js +70 -55
  16. package/dist/server/Processor.js +42 -25
  17. package/dist/server/actions/executions.js +41 -14
  18. package/dist/server/actions/index.js +39 -34
  19. package/dist/server/actions/nodes.js +48 -28
  20. package/dist/server/actions/workflows.js +50 -20
  21. package/dist/server/collections/executions.js +22 -4
  22. package/dist/server/collections/flow_nodes.js +22 -4
  23. package/dist/server/collections/jobs.js +22 -4
  24. package/dist/server/collections/workflows.js +22 -4
  25. package/dist/server/constants.js +30 -6
  26. package/dist/server/fields/expression-field.js +29 -8
  27. package/dist/server/fields/index.js +24 -7
  28. package/dist/server/functions/index.js +22 -4
  29. package/dist/server/index.js +45 -39
  30. package/dist/server/instructions/aggregate.js +30 -13
  31. package/dist/server/instructions/calculation.js +30 -13
  32. package/dist/server/instructions/condition.js +36 -17
  33. package/dist/server/instructions/create.js +26 -9
  34. package/dist/server/instructions/delay.js +27 -10
  35. package/dist/server/instructions/destroy.js +24 -7
  36. package/dist/server/instructions/index.js +35 -12
  37. package/dist/server/instructions/loop.js +27 -10
  38. package/dist/server/instructions/manual/actions.js +31 -10
  39. package/dist/server/instructions/manual/collecions/jobs.js +22 -4
  40. package/dist/server/instructions/manual/collecions/users.js +22 -4
  41. package/dist/server/instructions/manual/collecions/users_jobs.js +22 -4
  42. package/dist/server/instructions/manual/forms/create.js +22 -4
  43. package/dist/server/instructions/manual/forms/index.js +36 -14
  44. package/dist/server/instructions/manual/forms/update.js +22 -4
  45. package/dist/server/instructions/manual/index.js +60 -41
  46. package/dist/server/instructions/parallel.js +47 -28
  47. package/dist/server/instructions/query.js +31 -14
  48. package/dist/server/instructions/request.js +39 -16
  49. package/dist/server/instructions/sql.js +25 -8
  50. package/dist/server/instructions/update.js +24 -7
  51. package/dist/server/migrations/20221129153547-calculation-variables.js +24 -7
  52. package/dist/server/migrations/20230221032941-change-request-body-type.js +28 -7
  53. package/dist/server/migrations/20230221071831-calculation-expression.js +24 -7
  54. package/dist/server/migrations/20230221121203-condition-calculation.js +62 -7
  55. package/dist/server/migrations/20230221162902-jsonb-to-json.js +29 -12
  56. package/dist/server/migrations/20230411034722-manual-multi-form.js +38 -15
  57. package/dist/server/migrations/20230612021134-manual-collection-block.js +26 -9
  58. package/dist/server/migrations/20230710115902-manual-action-values.js +24 -7
  59. package/dist/server/migrations/20230809113132-workflow-options.js +24 -7
  60. package/dist/server/triggers/collection.js +26 -9
  61. package/dist/server/triggers/form.js +28 -11
  62. package/dist/server/triggers/index.js +42 -17
  63. package/dist/server/triggers/schedule.js +56 -31
  64. package/dist/server/types/Execution.js +24 -7
  65. package/dist/server/types/FlowNode.js +24 -7
  66. package/dist/server/types/Job.js +24 -7
  67. package/dist/server/types/Workflow.js +24 -7
  68. package/dist/server/types/index.js +15 -2
  69. package/dist/server/utils.js +26 -4
  70. package/dist/swagger/index.d.ts +103 -53
  71. package/dist/swagger/index.js +144 -71
  72. package/package.json +2 -2
@@ -1,22 +1,43 @@
1
- 'use strict';
2
-
3
- var actions = require('@nocobase/actions');
4
- var utils = require('@nocobase/utils');
5
- var constants = require('../../constants');
6
- var jobsCollection = require('./collecions/jobs');
7
- var usersCollection = require('./collecions/users');
8
- var usersJobsCollection = require('./collecions/users_jobs');
9
- var actions$1 = require('./actions');
10
- var initFormTypes = require('./forms');
11
-
12
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
-
14
- var actions__default = /*#__PURE__*/_interopDefault(actions);
15
- var jobsCollection__default = /*#__PURE__*/_interopDefault(jobsCollection);
16
- var usersCollection__default = /*#__PURE__*/_interopDefault(usersCollection);
17
- var usersJobsCollection__default = /*#__PURE__*/_interopDefault(usersJobsCollection);
18
- var initFormTypes__default = /*#__PURE__*/_interopDefault(initFormTypes);
19
-
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var manual_exports = {};
29
+ __export(manual_exports, {
30
+ default: () => manual_default
31
+ });
32
+ module.exports = __toCommonJS(manual_exports);
33
+ var import_actions = __toESM(require("@nocobase/actions"));
34
+ var import_utils = require("@nocobase/utils");
35
+ var import_constants = require("../../constants");
36
+ var import_jobs = __toESM(require("./collecions/jobs"));
37
+ var import_users = __toESM(require("./collecions/users"));
38
+ var import_users_jobs = __toESM(require("./collecions/users_jobs"));
39
+ var import_actions2 = require("./actions");
40
+ var import_forms = __toESM(require("./forms"));
20
41
  const MULTIPLE_ASSIGNED_MODE = {
21
42
  SINGLE: Symbol("single"),
22
43
  ALL: Symbol("all"),
@@ -27,17 +48,17 @@ const MULTIPLE_ASSIGNED_MODE = {
27
48
  const Modes = {
28
49
  [MULTIPLE_ASSIGNED_MODE.SINGLE]: {
29
50
  getStatus(distribution, assignees) {
30
- const done = distribution.find((item) => item.status !== constants.JOB_STATUS.PENDING && item.count > 0);
51
+ const done = distribution.find((item) => item.status !== import_constants.JOB_STATUS.PENDING && item.count > 0);
31
52
  return done ? done.status : null;
32
53
  }
33
54
  },
34
55
  [MULTIPLE_ASSIGNED_MODE.ALL]: {
35
56
  getStatus(distribution, assignees) {
36
- const resolved = distribution.find((item) => item.status === constants.JOB_STATUS.RESOLVED);
57
+ const resolved = distribution.find((item) => item.status === import_constants.JOB_STATUS.RESOLVED);
37
58
  if (resolved && resolved.count === assignees.length) {
38
- return constants.JOB_STATUS.RESOLVED;
59
+ return import_constants.JOB_STATUS.RESOLVED;
39
60
  }
40
- const rejected = distribution.find((item) => item.status < constants.JOB_STATUS.PENDING);
61
+ const rejected = distribution.find((item) => item.status < import_constants.JOB_STATUS.PENDING);
41
62
  if (rejected && rejected.count) {
42
63
  return rejected.status;
43
64
  }
@@ -46,16 +67,16 @@ const Modes = {
46
67
  },
47
68
  [MULTIPLE_ASSIGNED_MODE.ANY]: {
48
69
  getStatus(distribution, assignees) {
49
- const resolved = distribution.find((item) => item.status === constants.JOB_STATUS.RESOLVED);
70
+ const resolved = distribution.find((item) => item.status === import_constants.JOB_STATUS.RESOLVED);
50
71
  if (resolved && resolved.count) {
51
- return constants.JOB_STATUS.RESOLVED;
72
+ return import_constants.JOB_STATUS.RESOLVED;
52
73
  }
53
74
  const rejectedCount = distribution.reduce(
54
- (count, item) => item.status < constants.JOB_STATUS.PENDING ? count + item.count : count,
75
+ (count, item) => item.status < import_constants.JOB_STATUS.PENDING ? count + item.count : count,
55
76
  0
56
77
  );
57
78
  if (rejectedCount === assignees.length) {
58
- return constants.JOB_STATUS.REJECTED;
79
+ return import_constants.JOB_STATUS.REJECTED;
59
80
  }
60
81
  return null;
61
82
  }
@@ -78,9 +99,9 @@ function getMode(mode) {
78
99
  class manual_default {
79
100
  constructor(plugin) {
80
101
  this.plugin = plugin;
81
- plugin.db.collection(usersJobsCollection__default.default);
82
- plugin.db.extendCollection(usersCollection__default.default);
83
- plugin.db.extendCollection(jobsCollection__default.default);
102
+ plugin.db.collection(import_users_jobs.default);
103
+ plugin.db.extendCollection(import_users.default);
104
+ plugin.db.extendCollection(import_jobs.default);
84
105
  plugin.app.resource({
85
106
  name: "users_jobs",
86
107
  actions: {
@@ -93,24 +114,24 @@ class manual_default {
93
114
  {
94
115
  "workflow.enabled": false,
95
116
  status: {
96
- $ne: constants.JOB_STATUS.PENDING
117
+ $ne: import_constants.JOB_STATUS.PENDING
97
118
  }
98
119
  }
99
120
  ]
100
121
  },
101
- handler: actions__default.default.list
122
+ handler: import_actions.default.list
102
123
  },
103
- submit: actions$1.submit
124
+ submit: import_actions2.submit
104
125
  }
105
126
  });
106
- initFormTypes__default.default(this);
127
+ (0, import_forms.default)(this);
107
128
  }
108
- formTypes = new utils.Registry();
129
+ formTypes = new import_utils.Registry();
109
130
  async run(node, prevJob, processor) {
110
131
  const { mode, ...config } = node.config;
111
132
  const assignees = [...new Set(processor.getParsedValue(config.assignees, node.id) || [])];
112
133
  const job = await processor.saveJob({
113
- status: constants.JOB_STATUS.PENDING,
134
+ status: import_constants.JOB_STATUS.PENDING,
114
135
  result: mode ? [] : null,
115
136
  nodeId: node.id,
116
137
  upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
@@ -123,7 +144,7 @@ class manual_default {
123
144
  nodeId: node.id,
124
145
  executionId: job.executionId,
125
146
  workflowId: node.workflowId,
126
- status: constants.JOB_STATUS.PENDING
147
+ status: import_constants.JOB_STATUS.PENDING
127
148
  })),
128
149
  {
129
150
  transaction: processor.transaction
@@ -143,10 +164,10 @@ class manual_default {
143
164
  transaction: processor.transaction
144
165
  });
145
166
  const submitted = distribution.reduce(
146
- (count, item) => item.status !== constants.JOB_STATUS.PENDING ? count + item.count : count,
167
+ (count, item) => item.status !== import_constants.JOB_STATUS.PENDING ? count + item.count : count,
147
168
  0
148
169
  );
149
- const status = job.status || (getMode(mode).getStatus(distribution, assignees) ?? constants.JOB_STATUS.PENDING);
170
+ const status = job.status || (getMode(mode).getStatus(distribution, assignees) ?? import_constants.JOB_STATUS.PENDING);
150
171
  const result = mode ? (submitted || 0) / assignees.length : ((_a = job.latestUserJob) == null ? void 0 : _a.result) ?? job.result;
151
172
  processor.logger.debug(`manual resume job and next status: ${status}`);
152
173
  job.set({
@@ -156,5 +177,3 @@ class manual_default {
156
177
  return job;
157
178
  }
158
179
  }
159
-
160
- module.exports = manual_default;
@@ -1,9 +1,27 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var constants = require('../constants');
6
-
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var parallel_exports = {};
19
+ __export(parallel_exports, {
20
+ PARALLEL_MODE: () => PARALLEL_MODE,
21
+ default: () => parallel_default
22
+ });
23
+ module.exports = __toCommonJS(parallel_exports);
24
+ var import_constants = require("../constants");
7
25
  const PARALLEL_MODE = {
8
26
  ALL: "all",
9
27
  ANY: "any",
@@ -12,46 +30,46 @@ const PARALLEL_MODE = {
12
30
  const Modes = {
13
31
  [PARALLEL_MODE.ALL]: {
14
32
  next(previous) {
15
- return previous.status >= constants.JOB_STATUS.PENDING;
33
+ return previous.status >= import_constants.JOB_STATUS.PENDING;
16
34
  },
17
35
  getStatus(result) {
18
- const failedStatus = result.find((status) => status != null && status < constants.JOB_STATUS.PENDING);
36
+ const failedStatus = result.find((status) => status != null && status < import_constants.JOB_STATUS.PENDING);
19
37
  if (typeof failedStatus !== "undefined") {
20
38
  return failedStatus;
21
39
  }
22
- if (result.every((status) => status != null && status === constants.JOB_STATUS.RESOLVED)) {
23
- return constants.JOB_STATUS.RESOLVED;
40
+ if (result.every((status) => status != null && status === import_constants.JOB_STATUS.RESOLVED)) {
41
+ return import_constants.JOB_STATUS.RESOLVED;
24
42
  }
25
- return constants.JOB_STATUS.PENDING;
43
+ return import_constants.JOB_STATUS.PENDING;
26
44
  }
27
45
  },
28
46
  [PARALLEL_MODE.ANY]: {
29
47
  next(previous) {
30
- return previous.status <= constants.JOB_STATUS.PENDING;
48
+ return previous.status <= import_constants.JOB_STATUS.PENDING;
31
49
  },
32
50
  getStatus(result) {
33
- if (result.some((status) => status != null && status === constants.JOB_STATUS.RESOLVED)) {
34
- return constants.JOB_STATUS.RESOLVED;
51
+ if (result.some((status) => status != null && status === import_constants.JOB_STATUS.RESOLVED)) {
52
+ return import_constants.JOB_STATUS.RESOLVED;
35
53
  }
36
- if (result.some((status) => status != null ? status === constants.JOB_STATUS.PENDING : true)) {
37
- return constants.JOB_STATUS.PENDING;
54
+ if (result.some((status) => status != null ? status === import_constants.JOB_STATUS.PENDING : true)) {
55
+ return import_constants.JOB_STATUS.PENDING;
38
56
  }
39
- return constants.JOB_STATUS.FAILED;
57
+ return import_constants.JOB_STATUS.FAILED;
40
58
  }
41
59
  },
42
60
  [PARALLEL_MODE.RACE]: {
43
61
  next(previous) {
44
- return previous.status === constants.JOB_STATUS.PENDING;
62
+ return previous.status === import_constants.JOB_STATUS.PENDING;
45
63
  },
46
64
  getStatus(result) {
47
- if (result.some((status) => status != null && status === constants.JOB_STATUS.RESOLVED)) {
48
- return constants.JOB_STATUS.RESOLVED;
65
+ if (result.some((status) => status != null && status === import_constants.JOB_STATUS.RESOLVED)) {
66
+ return import_constants.JOB_STATUS.RESOLVED;
49
67
  }
50
- const failedStatus = result.find((status) => status != null && status < constants.JOB_STATUS.PENDING);
68
+ const failedStatus = result.find((status) => status != null && status < import_constants.JOB_STATUS.PENDING);
51
69
  if (typeof failedStatus !== "undefined") {
52
70
  return failedStatus;
53
71
  }
54
- return constants.JOB_STATUS.PENDING;
72
+ return import_constants.JOB_STATUS.PENDING;
55
73
  }
56
74
  }
57
75
  };
@@ -59,7 +77,7 @@ var parallel_default = {
59
77
  async run(node, prevJob, processor) {
60
78
  const branches = processor.getBranches(node);
61
79
  const job = await processor.saveJob({
62
- status: constants.JOB_STATUS.PENDING,
80
+ status: import_constants.JOB_STATUS.PENDING,
63
81
  result: Array(branches.length).fill(null),
64
82
  nodeId: node.id,
65
83
  upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
@@ -80,7 +98,7 @@ var parallel_default = {
80
98
  async resume(node, branchJob, processor) {
81
99
  const job = processor.findBranchParentJob(branchJob, node);
82
100
  const { result, status } = job;
83
- if (status !== constants.JOB_STATUS.PENDING) {
101
+ if (status !== import_constants.JOB_STATUS.PENDING) {
84
102
  return processor.exit();
85
103
  }
86
104
  const jobNode = processor.nodesMap.get(branchJob.nodeId);
@@ -93,13 +111,14 @@ var parallel_default = {
93
111
  result: newResult,
94
112
  status: Modes[mode].getStatus(newResult)
95
113
  });
96
- if (job.status === constants.JOB_STATUS.PENDING) {
114
+ if (job.status === import_constants.JOB_STATUS.PENDING) {
97
115
  await job.save({ transaction: processor.transaction });
98
116
  return processor.exit();
99
117
  }
100
118
  return job;
101
119
  }
102
120
  };
103
-
104
- exports.PARALLEL_MODE = PARALLEL_MODE;
105
- exports.default = parallel_default;
121
+ // Annotate the CommonJS export names for ESM import in node:
122
+ 0 && (module.exports = {
123
+ PARALLEL_MODE
124
+ });
@@ -1,16 +1,35 @@
1
- 'use strict';
2
-
3
- var actions = require('@nocobase/actions');
4
- var constants = require('../constants');
5
- var utils = require('../utils');
6
-
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var query_exports = {};
19
+ __export(query_exports, {
20
+ default: () => query_default
21
+ });
22
+ module.exports = __toCommonJS(query_exports);
23
+ var import_actions = require("@nocobase/actions");
24
+ var import_constants = require("../constants");
25
+ var import_utils = require("../utils");
7
26
  var query_default = {
8
27
  async run(node, input, processor) {
9
28
  const { collection, multiple, params = {}, failOnEmpty = false } = node.config;
10
29
  const repo = node.constructor.database.getRepository(collection);
11
30
  const {
12
- page = actions.DEFAULT_PAGE,
13
- pageSize = actions.DEFAULT_PER_PAGE,
31
+ page = import_actions.DEFAULT_PAGE,
32
+ pageSize = import_actions.DEFAULT_PER_PAGE,
14
33
  sort = [],
15
34
  ...options
16
35
  } = processor.getParsedValue(params, node.id);
@@ -23,7 +42,7 @@ var query_default = {
23
42
  ) : options.appends;
24
43
  const result = await (multiple ? repo.find : repo.findOne).call(repo, {
25
44
  ...options,
26
- ...actions.utils.pageArgsToLimitArgs(page, pageSize),
45
+ ...import_actions.utils.pageArgsToLimitArgs(page, pageSize),
27
46
  sort: sort.filter((item) => item.field).map((item) => {
28
47
  var _a;
29
48
  return `${((_a = item.direction) == null ? void 0 : _a.toLowerCase()) === "desc" ? "-" : ""}${item.field}`;
@@ -34,14 +53,12 @@ var query_default = {
34
53
  if (failOnEmpty && (multiple ? !result.length : !result)) {
35
54
  return {
36
55
  result,
37
- status: constants.JOB_STATUS.FAILED
56
+ status: import_constants.JOB_STATUS.FAILED
38
57
  };
39
58
  }
40
59
  return {
41
- result: utils.toJSON(result),
42
- status: constants.JOB_STATUS.RESOLVED
60
+ result: (0, import_utils.toJSON)(result),
61
+ status: import_constants.JOB_STATUS.RESOLVED
43
62
  };
44
63
  }
45
64
  };
46
-
47
- module.exports = query_default;
@@ -1,12 +1,37 @@
1
- 'use strict';
2
-
3
- var axios = require('axios');
4
- var constants = require('../constants');
5
-
6
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
-
8
- var axios__default = /*#__PURE__*/_interopDefault(axios);
9
-
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var request_exports = {};
29
+ __export(request_exports, {
30
+ default: () => request_default
31
+ });
32
+ module.exports = __toCommonJS(request_exports);
33
+ var import_axios = __toESM(require("axios"));
34
+ var import_constants = require("../constants");
10
35
  async function request(config) {
11
36
  const { url, method = "POST", data, timeout = 5e3 } = config;
12
37
  const headers = (config.headers ?? []).reduce((result, header) => {
@@ -20,7 +45,7 @@ async function request(config) {
20
45
  {}
21
46
  );
22
47
  headers["Content-Type"] = "application/json";
23
- return axios__default.default.request({
48
+ return import_axios.default.request({
24
49
  url,
25
50
  method,
26
51
  headers,
@@ -35,19 +60,19 @@ class request_default {
35
60
  }
36
61
  async run(node, prevJob, processor) {
37
62
  const job = await processor.saveJob({
38
- status: constants.JOB_STATUS.PENDING,
63
+ status: import_constants.JOB_STATUS.PENDING,
39
64
  nodeId: node.id,
40
65
  upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
41
66
  });
42
67
  const config = processor.getParsedValue(node.config, node.id);
43
68
  request(config).then((response) => {
44
69
  job.set({
45
- status: constants.JOB_STATUS.RESOLVED,
70
+ status: import_constants.JOB_STATUS.RESOLVED,
46
71
  result: response.data
47
72
  });
48
73
  }).catch((error) => {
49
74
  job.set({
50
- status: constants.JOB_STATUS.FAILED,
75
+ status: import_constants.JOB_STATUS.FAILED,
51
76
  result: error.isAxiosError ? error.toJSON() : error.message
52
77
  });
53
78
  }).finally(() => {
@@ -60,10 +85,8 @@ class request_default {
60
85
  async resume(node, job, processor) {
61
86
  const { ignoreFail } = node.config;
62
87
  if (ignoreFail) {
63
- job.set("status", constants.JOB_STATUS.RESOLVED);
88
+ job.set("status", import_constants.JOB_STATUS.RESOLVED);
64
89
  }
65
90
  return job;
66
91
  }
67
92
  }
68
-
69
- module.exports = request_default;
@@ -1,14 +1,33 @@
1
- 'use strict';
2
-
3
- var __ = require('..');
4
-
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var sql_exports = {};
19
+ __export(sql_exports, {
20
+ default: () => sql_default
21
+ });
22
+ module.exports = __toCommonJS(sql_exports);
23
+ var import__ = require("..");
5
24
  var sql_default = {
6
25
  async run(node, input, processor) {
7
26
  const { sequelize } = node.constructor.database;
8
27
  const sql = processor.getParsedValue(node.config.sql ?? "", node.id).trim();
9
28
  if (!sql) {
10
29
  return {
11
- status: __.JOB_STATUS.RESOLVED
30
+ status: import__.JOB_STATUS.RESOLVED
12
31
  };
13
32
  }
14
33
  const result = await sequelize.query(sql, {
@@ -18,9 +37,7 @@ var sql_default = {
18
37
  });
19
38
  return {
20
39
  result,
21
- status: __.JOB_STATUS.RESOLVED
40
+ status: import__.JOB_STATUS.RESOLVED
22
41
  };
23
42
  }
24
43
  };
25
-
26
- module.exports = sql_default;
@@ -1,7 +1,26 @@
1
- 'use strict';
2
-
3
- var constants = require('../constants');
4
-
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var update_exports = {};
19
+ __export(update_exports, {
20
+ default: () => update_default
21
+ });
22
+ module.exports = __toCommonJS(update_exports);
23
+ var import_constants = require("../constants");
5
24
  var update_default = {
6
25
  async run(node, input, processor) {
7
26
  const { collection, params = {} } = node.config;
@@ -16,9 +35,7 @@ var update_default = {
16
35
  });
17
36
  return {
18
37
  result: result.length ?? result,
19
- status: constants.JOB_STATUS.RESOLVED
38
+ status: import_constants.JOB_STATUS.RESOLVED
20
39
  };
21
40
  }
22
41
  };
23
-
24
- module.exports = update_default;
@@ -1,7 +1,26 @@
1
- 'use strict';
2
-
3
- var server = require('@nocobase/server');
4
-
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var calculation_variables_exports = {};
19
+ __export(calculation_variables_exports, {
20
+ default: () => calculation_variables_default
21
+ });
22
+ module.exports = __toCommonJS(calculation_variables_exports);
23
+ var import_server = require("@nocobase/server");
5
24
  const VTypes = {
6
25
  constant(operand) {
7
26
  return operand.value;
@@ -29,7 +48,7 @@ function migrateConfig(config) {
29
48
  }
30
49
  return Object.keys(config).reduce((memo, key) => ({ ...memo, [key]: migrateConfig(config[key]) }), {});
31
50
  }
32
- class calculation_variables_default extends server.Migration {
51
+ class calculation_variables_default extends import_server.Migration {
33
52
  async up() {
34
53
  const match = await this.app.version.satisfies("<=0.8.0-alpha.13");
35
54
  if (!match) {
@@ -61,5 +80,3 @@ class calculation_variables_default extends server.Migration {
61
80
  async down() {
62
81
  }
63
82
  }
64
-
65
- module.exports = calculation_variables_default;
@@ -1,7 +1,26 @@
1
- 'use strict';
2
-
3
- var server = require('@nocobase/server');
4
-
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+ var change_request_body_type_exports = {};
19
+ __export(change_request_body_type_exports, {
20
+ default: () => change_request_body_type_default
21
+ });
22
+ module.exports = __toCommonJS(change_request_body_type_exports);
23
+ var import_server = require("@nocobase/server");
5
24
  const EJS_RE = /"?<%=\s*(ctx|node)([\w\.\[\]-]+)\s*.*%>"?/;
6
25
  function migrateData(input) {
7
26
  if (typeof input !== "string") {
@@ -10,6 +29,10 @@ function migrateData(input) {
10
29
  if (!input) {
11
30
  return null;
12
31
  }
32
+ const typeMap = {
33
+ ctx: "$context",
34
+ node: "$jobsMapByNodeId"
35
+ };
13
36
  return input.replace(EJS_RE, (_, type, path) => {
14
37
  if (type === "ctx") {
15
38
  return `"{{$context${path}}}"`;
@@ -20,7 +43,7 @@ function migrateData(input) {
20
43
  return _;
21
44
  });
22
45
  }
23
- class change_request_body_type_default extends server.Migration {
46
+ class change_request_body_type_default extends import_server.Migration {
24
47
  async up() {
25
48
  const match = await this.app.version.satisfies("<0.9.0-alpha.3");
26
49
  if (!match) {
@@ -67,5 +90,3 @@ class change_request_body_type_default extends server.Migration {
67
90
  async down() {
68
91
  }
69
92
  }
70
-
71
- module.exports = change_request_body_type_default;