@nocobase/plugin-workflow 0.17.0-alpha.2 → 0.17.0-alpha.4

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 (133) hide show
  1. package/dist/client/WorkflowPane.d.ts +2 -0
  2. package/dist/client/components/index.d.ts +5 -0
  3. package/dist/client/hooks/useTriggerWorkflowActionProps.d.ts +3 -0
  4. package/dist/client/index.d.ts +14 -6
  5. package/dist/client/index.js +136 -186
  6. package/dist/client/nodes/calculation.d.ts +8 -62
  7. package/dist/client/nodes/condition.d.ts +9 -9
  8. package/dist/client/nodes/create.d.ts +3 -5
  9. package/dist/client/nodes/destroy.d.ts +3 -4
  10. package/dist/client/nodes/index.d.ts +2 -6
  11. package/dist/client/nodes/query.d.ts +3 -5
  12. package/dist/client/nodes/update.d.ts +4 -4
  13. package/dist/client/triggers/collection.d.ts +3 -4
  14. package/dist/client/triggers/index.d.ts +2 -11
  15. package/dist/client/triggers/schedule/index.d.ts +3 -4
  16. package/dist/client/utils.d.ts +1 -0
  17. package/dist/externalVersion.js +11 -13
  18. package/dist/locale/{en-US.js → en-US.json} +41 -94
  19. package/dist/locale/es-ES.json +98 -0
  20. package/dist/locale/fr-FR.json +98 -0
  21. package/dist/locale/ja-JP.json +82 -0
  22. package/dist/locale/pt-BR.json +98 -0
  23. package/dist/locale/ru-RU.json +82 -0
  24. package/dist/locale/tr-TR.json +82 -0
  25. package/dist/locale/zh-CN.json +176 -0
  26. package/dist/node_modules/cron-parser/package.json +1 -1
  27. package/dist/node_modules/lru-cache/package.json +1 -1
  28. package/dist/server/Plugin.d.ts +12 -2
  29. package/dist/server/Plugin.js +31 -7
  30. package/dist/server/Processor.d.ts +1 -1
  31. package/dist/server/index.d.ts +1 -1
  32. package/dist/server/index.js +2 -0
  33. package/dist/server/instructions/CalculationInstruction.d.ts +15 -0
  34. package/dist/server/instructions/{calculation.js → CalculationInstruction.js} +13 -6
  35. package/dist/server/instructions/ConditionInstruction.d.ts +19 -0
  36. package/dist/server/instructions/{condition.js → ConditionInstruction.js} +11 -7
  37. package/dist/server/instructions/CreateInstruction.d.ts +10 -0
  38. package/dist/server/instructions/{create.js → CreateInstruction.js} +13 -6
  39. package/dist/server/instructions/DestroyInstruction.d.ts +10 -0
  40. package/dist/server/instructions/{destroy.js → DestroyInstruction.js} +13 -6
  41. package/dist/server/instructions/{update.d.ts → QueryInstruction.d.ts} +5 -4
  42. package/dist/server/instructions/{query.js → QueryInstruction.js} +13 -6
  43. package/dist/server/instructions/{aggregate.d.ts → UpdateInstruction.d.ts} +5 -4
  44. package/dist/server/instructions/{update.js → UpdateInstruction.js} +13 -6
  45. package/dist/server/instructions/index.d.ts +10 -14
  46. package/dist/server/instructions/index.js +9 -39
  47. package/dist/server/migrations/20231122143143-split-to-plugins.d.ts +4 -0
  48. package/dist/server/migrations/20231122143143-split-to-plugins.js +87 -0
  49. package/dist/server/triggers/{collection.d.ts → CollectionTrigger.d.ts} +1 -1
  50. package/dist/server/triggers/{collection.js → CollectionTrigger.js} +15 -5
  51. package/dist/server/triggers/{schedule.d.ts → ScheduleTrigger.d.ts} +2 -1
  52. package/dist/server/triggers/{schedule.js → ScheduleTrigger.js} +5 -5
  53. package/dist/server/triggers/index.d.ts +2 -6
  54. package/dist/server/triggers/index.js +1 -21
  55. package/package.json +3 -2
  56. package/dist/client/WorkflowProvider.d.ts +0 -5
  57. package/dist/client/components/Duration.d.ts +0 -5
  58. package/dist/client/components/DynamicExpression.d.ts +0 -6
  59. package/dist/client/components/NullRender.d.ts +0 -1
  60. package/dist/client/interfaces/expression.d.ts +0 -3
  61. package/dist/client/nodes/aggregate.d.ts +0 -196
  62. package/dist/client/nodes/delay.d.ts +0 -35
  63. package/dist/client/nodes/loop.d.ts +0 -33
  64. package/dist/client/nodes/manual/AssigneesSelect.d.ts +0 -6
  65. package/dist/client/nodes/manual/DetailsBlockProvider.d.ts +0 -2
  66. package/dist/client/nodes/manual/FormBlockInitializer.d.ts +0 -2
  67. package/dist/client/nodes/manual/FormBlockProvider.d.ts +0 -2
  68. package/dist/client/nodes/manual/ModeConfig.d.ts +0 -5
  69. package/dist/client/nodes/manual/SchemaConfig.d.ts +0 -49
  70. package/dist/client/nodes/manual/WorkflowTodo.d.ts +0 -5
  71. package/dist/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +0 -2
  72. package/dist/client/nodes/manual/forms/create.d.ts +0 -3
  73. package/dist/client/nodes/manual/forms/custom.d.ts +0 -5
  74. package/dist/client/nodes/manual/forms/update.d.ts +0 -3
  75. package/dist/client/nodes/manual/index.d.ts +0 -86
  76. package/dist/client/nodes/manual/utils.d.ts +0 -2
  77. package/dist/client/nodes/parallel.d.ts +0 -32
  78. package/dist/client/nodes/request.d.ts +0 -183
  79. package/dist/client/nodes/sql.d.ts +0 -35
  80. package/dist/client/triggers/form.d.ts +0 -52
  81. package/dist/locale/en-US.d.ts +0 -130
  82. package/dist/locale/es-ES.d.ts +0 -130
  83. package/dist/locale/es-ES.js +0 -151
  84. package/dist/locale/fr-FR.d.ts +0 -130
  85. package/dist/locale/fr-FR.js +0 -151
  86. package/dist/locale/ja-JP.d.ts +0 -88
  87. package/dist/locale/ja-JP.js +0 -109
  88. package/dist/locale/pt-BR.d.ts +0 -130
  89. package/dist/locale/pt-BR.js +0 -151
  90. package/dist/locale/ru-RU.d.ts +0 -88
  91. package/dist/locale/ru-RU.js +0 -109
  92. package/dist/locale/tr-TR.d.ts +0 -88
  93. package/dist/locale/tr-TR.js +0 -109
  94. package/dist/locale/zh-CN.d.ts +0 -249
  95. package/dist/locale/zh-CN.js +0 -270
  96. package/dist/server/fields/expression-field.d.ts +0 -7
  97. package/dist/server/fields/expression-field.js +0 -32
  98. package/dist/server/fields/index.d.ts +0 -1
  99. package/dist/server/fields/index.js +0 -28
  100. package/dist/server/instructions/aggregate.js +0 -54
  101. package/dist/server/instructions/calculation.d.ts +0 -3
  102. package/dist/server/instructions/condition.d.ts +0 -6
  103. package/dist/server/instructions/create.d.ts +0 -8
  104. package/dist/server/instructions/delay.d.ts +0 -15
  105. package/dist/server/instructions/delay.js +0 -104
  106. package/dist/server/instructions/destroy.d.ts +0 -8
  107. package/dist/server/instructions/loop.d.ts +0 -15
  108. package/dist/server/instructions/loop.js +0 -94
  109. package/dist/server/instructions/manual/actions.d.ts +0 -2
  110. package/dist/server/instructions/manual/actions.js +0 -94
  111. package/dist/server/instructions/manual/collecions/jobs.d.ts +0 -19
  112. package/dist/server/instructions/manual/collecions/jobs.js +0 -39
  113. package/dist/server/instructions/manual/collecions/users.d.ts +0 -15
  114. package/dist/server/instructions/manual/collecions/users.js +0 -37
  115. package/dist/server/instructions/manual/collecions/users_jobs.d.ts +0 -3
  116. package/dist/server/instructions/manual/collecions/users_jobs.js +0 -70
  117. package/dist/server/instructions/manual/forms/create.d.ts +0 -5
  118. package/dist/server/instructions/manual/forms/create.js +0 -41
  119. package/dist/server/instructions/manual/forms/index.d.ts +0 -6
  120. package/dist/server/instructions/manual/forms/index.js +0 -38
  121. package/dist/server/instructions/manual/forms/update.d.ts +0 -6
  122. package/dist/server/instructions/manual/forms/update.js +0 -41
  123. package/dist/server/instructions/manual/index.d.ts +0 -29
  124. package/dist/server/instructions/manual/index.js +0 -179
  125. package/dist/server/instructions/parallel.d.ts +0 -12
  126. package/dist/server/instructions/parallel.js +0 -124
  127. package/dist/server/instructions/query.d.ts +0 -9
  128. package/dist/server/instructions/request.d.ts +0 -18
  129. package/dist/server/instructions/request.js +0 -92
  130. package/dist/server/instructions/sql.d.ts +0 -12
  131. package/dist/server/instructions/sql.js +0 -43
  132. package/dist/server/triggers/form.d.ts +0 -11
  133. package/dist/server/triggers/form.js +0 -116
@@ -1,5 +0,0 @@
1
- import { Processor } from '../../..';
2
- import ManualInstruction from '..';
3
- export default function (this: ManualInstruction, instance: any, { collection }: {
4
- collection: any;
5
- }, processor: Processor): Promise<void>;
@@ -1,41 +0,0 @@
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 create_exports = {};
19
- __export(create_exports, {
20
- default: () => create_default
21
- });
22
- module.exports = __toCommonJS(create_exports);
23
- async function create_default(instance, { collection }, processor) {
24
- const repo = this.plugin.db.getRepository(collection);
25
- if (!repo) {
26
- throw new Error(`collection ${collection} for create data on manual node not found`);
27
- }
28
- const { _, ...form } = instance.result;
29
- const [values] = Object.values(form);
30
- await repo.create({
31
- values: {
32
- ...values ?? {},
33
- createdBy: instance.userId,
34
- updatedBy: instance.userId
35
- },
36
- context: {
37
- executionId: processor.execution.id
38
- },
39
- transaction: processor.transaction
40
- });
41
- }
@@ -1,6 +0,0 @@
1
- import { Processor } from '../../..';
2
- import ManualInstruction from '..';
3
- export type FormHandler = (this: ManualInstruction, instance: any, formConfig: any, processor: Processor) => Promise<void>;
4
- export default function ({ formTypes }: {
5
- formTypes: any;
6
- }): void;
@@ -1,38 +0,0 @@
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 forms_exports = {};
29
- __export(forms_exports, {
30
- default: () => forms_default
31
- });
32
- module.exports = __toCommonJS(forms_exports);
33
- var import_create = __toESM(require("./create"));
34
- var import_update = __toESM(require("./update"));
35
- function forms_default({ formTypes }) {
36
- formTypes.register("create", import_create.default);
37
- formTypes.register("update", import_update.default);
38
- }
@@ -1,6 +0,0 @@
1
- import { Processor } from '../../..';
2
- import ManualInstruction from '..';
3
- export default function (this: ManualInstruction, instance: any, { collection, filter }: {
4
- collection: any;
5
- filter?: {};
6
- }, processor: Processor): Promise<void>;
@@ -1,41 +0,0 @@
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
- async function update_default(instance, { collection, filter = {} }, processor) {
24
- const repo = this.plugin.db.getRepository(collection);
25
- if (!repo) {
26
- throw new Error(`collection ${collection} for update data on manual node not found`);
27
- }
28
- const { _, ...form } = instance.result;
29
- const [values] = Object.values(form);
30
- await repo.update({
31
- filter: processor.getParsedValue(filter, instance.nodeId),
32
- values: {
33
- ...values ?? {},
34
- updatedBy: instance.userId
35
- },
36
- context: {
37
- executionId: processor.execution.id
38
- },
39
- transaction: processor.transaction
40
- });
41
- }
@@ -1,29 +0,0 @@
1
- import { Registry } from '@nocobase/utils';
2
- import Plugin, { Processor } from '../..';
3
- import { Instruction } from '..';
4
- import { FormHandler } from './forms';
5
- type FormType = {
6
- type: 'custom' | 'create' | 'update';
7
- actions: number[];
8
- options: {
9
- [key: string]: any;
10
- };
11
- };
12
- export interface ManualConfig {
13
- schema: {
14
- [key: string]: any;
15
- };
16
- forms: {
17
- [key: string]: FormType;
18
- };
19
- assignees?: (number | string)[];
20
- mode?: number;
21
- }
22
- export default class implements Instruction {
23
- protected plugin: Plugin;
24
- formTypes: Registry<FormHandler>;
25
- constructor(plugin: Plugin);
26
- run(node: any, prevJob: any, processor: Processor): Promise<any>;
27
- resume(node: any, job: any, processor: Processor): Promise<any>;
28
- }
29
- export {};
@@ -1,179 +0,0 @@
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"));
41
- const MULTIPLE_ASSIGNED_MODE = {
42
- SINGLE: Symbol("single"),
43
- ALL: Symbol("all"),
44
- ANY: Symbol("any"),
45
- ALL_PERCENTAGE: Symbol("all percentage"),
46
- ANY_PERCENTAGE: Symbol("any percentage")
47
- };
48
- const Modes = {
49
- [MULTIPLE_ASSIGNED_MODE.SINGLE]: {
50
- getStatus(distribution, assignees) {
51
- const done = distribution.find((item) => item.status !== import_constants.JOB_STATUS.PENDING && item.count > 0);
52
- return done ? done.status : null;
53
- }
54
- },
55
- [MULTIPLE_ASSIGNED_MODE.ALL]: {
56
- getStatus(distribution, assignees) {
57
- const resolved = distribution.find((item) => item.status === import_constants.JOB_STATUS.RESOLVED);
58
- if (resolved && resolved.count === assignees.length) {
59
- return import_constants.JOB_STATUS.RESOLVED;
60
- }
61
- const rejected = distribution.find((item) => item.status < import_constants.JOB_STATUS.PENDING);
62
- if (rejected && rejected.count) {
63
- return rejected.status;
64
- }
65
- return null;
66
- }
67
- },
68
- [MULTIPLE_ASSIGNED_MODE.ANY]: {
69
- getStatus(distribution, assignees) {
70
- const resolved = distribution.find((item) => item.status === import_constants.JOB_STATUS.RESOLVED);
71
- if (resolved && resolved.count) {
72
- return import_constants.JOB_STATUS.RESOLVED;
73
- }
74
- const rejectedCount = distribution.reduce(
75
- (count, item) => item.status < import_constants.JOB_STATUS.PENDING ? count + item.count : count,
76
- 0
77
- );
78
- if (rejectedCount === assignees.length) {
79
- return import_constants.JOB_STATUS.REJECTED;
80
- }
81
- return null;
82
- }
83
- }
84
- };
85
- function getMode(mode) {
86
- switch (true) {
87
- case mode === 1:
88
- return Modes[MULTIPLE_ASSIGNED_MODE.ALL];
89
- case mode === -1:
90
- return Modes[MULTIPLE_ASSIGNED_MODE.ANY];
91
- case mode > 0:
92
- return Modes[MULTIPLE_ASSIGNED_MODE.ALL_PERCENTAGE];
93
- case mode < 0:
94
- return Modes[MULTIPLE_ASSIGNED_MODE.ANY_PERCENTAGE];
95
- default:
96
- return Modes[MULTIPLE_ASSIGNED_MODE.SINGLE];
97
- }
98
- }
99
- class manual_default {
100
- constructor(plugin) {
101
- this.plugin = plugin;
102
- plugin.db.collection(import_users_jobs.default);
103
- plugin.db.extendCollection(import_users.default);
104
- plugin.db.extendCollection(import_jobs.default);
105
- plugin.app.resource({
106
- name: "users_jobs",
107
- actions: {
108
- list: {
109
- filter: {
110
- $or: [
111
- {
112
- "workflow.enabled": true
113
- },
114
- {
115
- "workflow.enabled": false,
116
- status: {
117
- $ne: import_constants.JOB_STATUS.PENDING
118
- }
119
- }
120
- ]
121
- },
122
- handler: import_actions.default.list
123
- },
124
- submit: import_actions2.submit
125
- }
126
- });
127
- (0, import_forms.default)(this);
128
- }
129
- formTypes = new import_utils.Registry();
130
- async run(node, prevJob, processor) {
131
- const { mode, ...config } = node.config;
132
- const assignees = [...new Set(processor.getParsedValue(config.assignees, node.id) || [])];
133
- const job = await processor.saveJob({
134
- status: import_constants.JOB_STATUS.PENDING,
135
- result: mode ? [] : null,
136
- nodeId: node.id,
137
- upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
138
- });
139
- const UserJobModel = processor.options.plugin.db.getModel("users_jobs");
140
- await UserJobModel.bulkCreate(
141
- assignees.map((userId) => ({
142
- userId,
143
- jobId: job.id,
144
- nodeId: node.id,
145
- executionId: job.executionId,
146
- workflowId: node.workflowId,
147
- status: import_constants.JOB_STATUS.PENDING
148
- })),
149
- {
150
- transaction: processor.transaction
151
- }
152
- );
153
- return job;
154
- }
155
- async resume(node, job, processor) {
156
- var _a;
157
- const { assignees = [], mode } = node.config;
158
- const UserJobModel = processor.options.plugin.db.getModel("users_jobs");
159
- const distribution = await UserJobModel.count({
160
- where: {
161
- jobId: job.id
162
- },
163
- group: ["status"],
164
- transaction: processor.transaction
165
- });
166
- const submitted = distribution.reduce(
167
- (count, item) => item.status !== import_constants.JOB_STATUS.PENDING ? count + item.count : count,
168
- 0
169
- );
170
- const status = job.status || (getMode(mode).getStatus(distribution, assignees) ?? import_constants.JOB_STATUS.PENDING);
171
- const result = mode ? (submitted || 0) / assignees.length : ((_a = job.latestUserJob) == null ? void 0 : _a.result) ?? job.result;
172
- processor.logger.debug(`manual resume job and next status: ${status}`);
173
- job.set({
174
- status,
175
- result
176
- });
177
- return job;
178
- }
179
- }
@@ -1,12 +0,0 @@
1
- import Processor from '../Processor';
2
- import type { FlowNodeModel, JobModel } from '../types';
3
- export declare const PARALLEL_MODE: {
4
- readonly ALL: "all";
5
- readonly ANY: "any";
6
- readonly RACE: "race";
7
- };
8
- declare const _default: {
9
- run(node: FlowNodeModel, prevJob: JobModel, processor: Processor): Promise<any>;
10
- resume(node: FlowNodeModel, branchJob: any, processor: Processor): Promise<any>;
11
- };
12
- export default _default;
@@ -1,124 +0,0 @@
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");
25
- const PARALLEL_MODE = {
26
- ALL: "all",
27
- ANY: "any",
28
- RACE: "race"
29
- };
30
- const Modes = {
31
- [PARALLEL_MODE.ALL]: {
32
- next(previous) {
33
- return previous.status >= import_constants.JOB_STATUS.PENDING;
34
- },
35
- getStatus(result) {
36
- const failedStatus = result.find((status) => status != null && status < import_constants.JOB_STATUS.PENDING);
37
- if (typeof failedStatus !== "undefined") {
38
- return failedStatus;
39
- }
40
- if (result.every((status) => status != null && status === import_constants.JOB_STATUS.RESOLVED)) {
41
- return import_constants.JOB_STATUS.RESOLVED;
42
- }
43
- return import_constants.JOB_STATUS.PENDING;
44
- }
45
- },
46
- [PARALLEL_MODE.ANY]: {
47
- next(previous) {
48
- return previous.status <= import_constants.JOB_STATUS.PENDING;
49
- },
50
- getStatus(result) {
51
- if (result.some((status) => status != null && status === import_constants.JOB_STATUS.RESOLVED)) {
52
- return import_constants.JOB_STATUS.RESOLVED;
53
- }
54
- if (result.some((status) => status != null ? status === import_constants.JOB_STATUS.PENDING : true)) {
55
- return import_constants.JOB_STATUS.PENDING;
56
- }
57
- return import_constants.JOB_STATUS.FAILED;
58
- }
59
- },
60
- [PARALLEL_MODE.RACE]: {
61
- next(previous) {
62
- return previous.status === import_constants.JOB_STATUS.PENDING;
63
- },
64
- getStatus(result) {
65
- if (result.some((status) => status != null && status === import_constants.JOB_STATUS.RESOLVED)) {
66
- return import_constants.JOB_STATUS.RESOLVED;
67
- }
68
- const failedStatus = result.find((status) => status != null && status < import_constants.JOB_STATUS.PENDING);
69
- if (typeof failedStatus !== "undefined") {
70
- return failedStatus;
71
- }
72
- return import_constants.JOB_STATUS.PENDING;
73
- }
74
- }
75
- };
76
- var parallel_default = {
77
- async run(node, prevJob, processor) {
78
- const branches = processor.getBranches(node);
79
- const job = await processor.saveJob({
80
- status: import_constants.JOB_STATUS.PENDING,
81
- result: Array(branches.length).fill(null),
82
- nodeId: node.id,
83
- upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
84
- });
85
- const { mode = PARALLEL_MODE.ALL } = node.config;
86
- await branches.reduce(
87
- (promise, branch, i) => promise.then(async (previous) => {
88
- if (i && !Modes[mode].next(previous)) {
89
- return previous;
90
- }
91
- await processor.run(branch, job);
92
- return processor.findBranchLastJob(branch, job);
93
- }),
94
- Promise.resolve()
95
- );
96
- return null;
97
- },
98
- async resume(node, branchJob, processor) {
99
- const job = processor.findBranchParentJob(branchJob, node);
100
- const { result, status } = job;
101
- if (status !== import_constants.JOB_STATUS.PENDING) {
102
- return processor.exit();
103
- }
104
- const jobNode = processor.nodesMap.get(branchJob.nodeId);
105
- const branchStartNode = processor.findBranchStartNode(jobNode, node);
106
- const branches = processor.getBranches(node);
107
- const branchIndex = branches.indexOf(branchStartNode);
108
- const { mode = PARALLEL_MODE.ALL } = node.config || {};
109
- const newResult = [...result.slice(0, branchIndex), branchJob.status, ...result.slice(branchIndex + 1)];
110
- job.set({
111
- result: newResult,
112
- status: Modes[mode].getStatus(newResult)
113
- });
114
- if (job.status === import_constants.JOB_STATUS.PENDING) {
115
- await job.save({ transaction: processor.transaction });
116
- return processor.exit();
117
- }
118
- return job;
119
- }
120
- };
121
- // Annotate the CommonJS export names for ESM import in node:
122
- 0 && (module.exports = {
123
- PARALLEL_MODE
124
- });
@@ -1,9 +0,0 @@
1
- import Processor from '../Processor';
2
- import type { FlowNodeModel } from '../types';
3
- declare const _default: {
4
- run(node: FlowNodeModel, input: any, processor: Processor): Promise<{
5
- result: any;
6
- status: number;
7
- }>;
8
- };
9
- export default _default;
@@ -1,18 +0,0 @@
1
- import { AxiosRequestConfig } from 'axios';
2
- import { Instruction } from './index';
3
- import Processor from '../Processor';
4
- import type { FlowNodeModel } from '../types';
5
- export interface Header {
6
- name: string;
7
- value: string;
8
- }
9
- export type RequestConfig = Pick<AxiosRequestConfig, 'url' | 'method' | 'params' | 'data' | 'timeout'> & {
10
- headers: Array<Header>;
11
- ignoreFail: boolean;
12
- };
13
- export default class implements Instruction {
14
- plugin: any;
15
- constructor(plugin: any);
16
- run(node: FlowNodeModel, prevJob: any, processor: Processor): Promise<any>;
17
- resume(node: FlowNodeModel, job: any, processor: Processor): Promise<any>;
18
- }
@@ -1,92 +0,0 @@
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");
35
- async function request(config) {
36
- const { url, method = "POST", data, timeout = 5e3 } = config;
37
- const headers = (config.headers ?? []).reduce((result, header) => {
38
- if (header.name.toLowerCase() === "content-type") {
39
- return result;
40
- }
41
- return Object.assign(result, { [header.name]: header.value });
42
- }, {});
43
- const params = (config.params ?? []).reduce(
44
- (result, param) => Object.assign(result, { [param.name]: param.value }),
45
- {}
46
- );
47
- headers["Content-Type"] = "application/json";
48
- return import_axios.default.request({
49
- url,
50
- method,
51
- headers,
52
- params,
53
- data,
54
- timeout
55
- });
56
- }
57
- class request_default {
58
- constructor(plugin) {
59
- this.plugin = plugin;
60
- }
61
- async run(node, prevJob, processor) {
62
- const job = await processor.saveJob({
63
- status: import_constants.JOB_STATUS.PENDING,
64
- nodeId: node.id,
65
- upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
66
- });
67
- const config = processor.getParsedValue(node.config, node.id);
68
- request(config).then((response) => {
69
- job.set({
70
- status: import_constants.JOB_STATUS.RESOLVED,
71
- result: response.data
72
- });
73
- }).catch((error) => {
74
- job.set({
75
- status: import_constants.JOB_STATUS.FAILED,
76
- result: error.isAxiosError ? error.toJSON() : error.message
77
- });
78
- }).finally(() => {
79
- processor.logger.info(`request (#${node.id}) response received, status: ${job.get("status")}`);
80
- this.plugin.resume(job);
81
- });
82
- processor.logger.info(`request (#${node.id}) sent to "${config.url}", waiting for response...`);
83
- return processor.exit();
84
- }
85
- async resume(node, job, processor) {
86
- const { ignoreFail } = node.config;
87
- if (ignoreFail) {
88
- job.set("status", import_constants.JOB_STATUS.RESOLVED);
89
- }
90
- return job;
91
- }
92
- }
@@ -1,12 +0,0 @@
1
- import { Processor } from '..';
2
- import type { FlowNodeModel } from '../types';
3
- declare const _default: {
4
- run(node: FlowNodeModel, input: any, processor: Processor): Promise<{
5
- status: number;
6
- result?: undefined;
7
- } | {
8
- result: [unknown[], unknown];
9
- status: number;
10
- }>;
11
- };
12
- export default _default;
@@ -1,43 +0,0 @@
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("..");
24
- var sql_default = {
25
- async run(node, input, processor) {
26
- const { sequelize } = node.constructor.database;
27
- const sql = processor.getParsedValue(node.config.sql ?? "", node.id).trim();
28
- if (!sql) {
29
- return {
30
- status: import__.JOB_STATUS.RESOLVED
31
- };
32
- }
33
- const result = await sequelize.query(sql, {
34
- transaction: processor.transaction
35
- // plain: true,
36
- // model: db.getCollection(node.config.collection).model
37
- });
38
- return {
39
- result,
40
- status: import__.JOB_STATUS.RESOLVED
41
- };
42
- }
43
- };