@nocobase/plugin-workflow 0.17.0-alpha.3 → 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 (118) 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.json +1 -32
  19. package/dist/locale/es-ES.json +1 -32
  20. package/dist/locale/fr-FR.json +1 -32
  21. package/dist/locale/ja-JP.json +0 -5
  22. package/dist/locale/pt-BR.json +1 -32
  23. package/dist/locale/ru-RU.json +0 -5
  24. package/dist/locale/tr-TR.json +0 -5
  25. package/dist/locale/zh-CN.json +42 -114
  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/server/fields/expression-field.d.ts +0 -7
  82. package/dist/server/fields/expression-field.js +0 -32
  83. package/dist/server/fields/index.d.ts +0 -1
  84. package/dist/server/fields/index.js +0 -28
  85. package/dist/server/instructions/aggregate.js +0 -54
  86. package/dist/server/instructions/calculation.d.ts +0 -3
  87. package/dist/server/instructions/condition.d.ts +0 -6
  88. package/dist/server/instructions/create.d.ts +0 -8
  89. package/dist/server/instructions/delay.d.ts +0 -15
  90. package/dist/server/instructions/delay.js +0 -104
  91. package/dist/server/instructions/destroy.d.ts +0 -8
  92. package/dist/server/instructions/loop.d.ts +0 -15
  93. package/dist/server/instructions/loop.js +0 -94
  94. package/dist/server/instructions/manual/actions.d.ts +0 -2
  95. package/dist/server/instructions/manual/actions.js +0 -94
  96. package/dist/server/instructions/manual/collecions/jobs.d.ts +0 -19
  97. package/dist/server/instructions/manual/collecions/jobs.js +0 -39
  98. package/dist/server/instructions/manual/collecions/users.d.ts +0 -15
  99. package/dist/server/instructions/manual/collecions/users.js +0 -37
  100. package/dist/server/instructions/manual/collecions/users_jobs.d.ts +0 -3
  101. package/dist/server/instructions/manual/collecions/users_jobs.js +0 -70
  102. package/dist/server/instructions/manual/forms/create.d.ts +0 -5
  103. package/dist/server/instructions/manual/forms/create.js +0 -41
  104. package/dist/server/instructions/manual/forms/index.d.ts +0 -6
  105. package/dist/server/instructions/manual/forms/index.js +0 -38
  106. package/dist/server/instructions/manual/forms/update.d.ts +0 -6
  107. package/dist/server/instructions/manual/forms/update.js +0 -41
  108. package/dist/server/instructions/manual/index.d.ts +0 -29
  109. package/dist/server/instructions/manual/index.js +0 -179
  110. package/dist/server/instructions/parallel.d.ts +0 -12
  111. package/dist/server/instructions/parallel.js +0 -124
  112. package/dist/server/instructions/query.d.ts +0 -9
  113. package/dist/server/instructions/request.d.ts +0 -18
  114. package/dist/server/instructions/request.js +0 -92
  115. package/dist/server/instructions/sql.d.ts +0 -12
  116. package/dist/server/instructions/sql.js +0 -43
  117. package/dist/server/triggers/form.d.ts +0 -11
  118. package/dist/server/triggers/form.js +0 -116
@@ -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
- };
@@ -1,11 +0,0 @@
1
- import { Trigger } from '.';
2
- import Plugin from '..';
3
- import { WorkflowModel } from '../types';
4
- export default class FormTrigger extends Trigger {
5
- constructor(plugin: Plugin);
6
- triggerAction(context: any, next: any): Promise<any>;
7
- middleware: (context: any, next: any) => Promise<any>;
8
- private trigger;
9
- on(workflow: WorkflowModel): void;
10
- off(workflow: WorkflowModel): void;
11
- }
@@ -1,116 +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 form_exports = {};
19
- __export(form_exports, {
20
- default: () => FormTrigger
21
- });
22
- module.exports = __toCommonJS(form_exports);
23
- var import_lodash = require("lodash");
24
- var import__ = require(".");
25
- var import_database = require("@nocobase/database");
26
- var import_utils = require("../utils");
27
- class FormTrigger extends import__.Trigger {
28
- constructor(plugin) {
29
- super(plugin);
30
- plugin.app.resourcer.use(this.middleware);
31
- }
32
- async triggerAction(context, next) {
33
- const { triggerWorkflows } = context.action.params;
34
- if (!triggerWorkflows) {
35
- return context.throw(400);
36
- }
37
- context.status = 202;
38
- await next();
39
- this.trigger(context);
40
- }
41
- middleware = async (context, next) => {
42
- const {
43
- resourceName,
44
- actionName,
45
- params: { triggerWorkflows }
46
- } = context.action;
47
- if (resourceName === "workflows" && actionName === "trigger") {
48
- return this.triggerAction(context, next);
49
- }
50
- await next();
51
- if (!triggerWorkflows) {
52
- return;
53
- }
54
- if (!["create", "update"].includes(actionName)) {
55
- return;
56
- }
57
- this.trigger(context);
58
- };
59
- async trigger(context) {
60
- const { triggerWorkflows = "", values } = context.action.params;
61
- const { currentUser } = context.state;
62
- const triggers = triggerWorkflows.split(",").map((trigger) => trigger.split("!"));
63
- const workflowRepo = this.plugin.db.getRepository("workflows");
64
- const workflows = await workflowRepo.find({
65
- filter: {
66
- key: triggers.map((trigger) => trigger[0]),
67
- current: true,
68
- type: "form",
69
- enabled: true
70
- }
71
- });
72
- workflows.forEach((workflow) => {
73
- var _a;
74
- const trigger = triggers.find((trigger2) => trigger2[0] == workflow.key);
75
- if ((_a = context.body) == null ? void 0 : _a.data) {
76
- const { data } = context.body;
77
- (Array.isArray(data) ? data : [data]).forEach(async (row) => {
78
- let payload = row;
79
- if (trigger[1]) {
80
- const paths = trigger[1].split(".");
81
- for await (const field of paths) {
82
- if (payload.get(field)) {
83
- payload = payload.get(field);
84
- } else {
85
- const association = (0, import_database.modelAssociationByKey)(payload, field);
86
- payload = await payload[association.accessors.get]();
87
- }
88
- }
89
- }
90
- const { collection, appends = [] } = workflow.config;
91
- const model = payload.constructor;
92
- if (collection !== model.collection.name) {
93
- return;
94
- }
95
- if (appends.length) {
96
- payload = await model.collection.repository.findOne({
97
- filterByTk: payload.get(model.primaryKeyAttribute),
98
- appends
99
- });
100
- }
101
- this.plugin.trigger(workflow, { data: (0, import_utils.toJSON)(payload), user: (0, import_utils.toJSON)(currentUser) });
102
- });
103
- } else {
104
- const data = trigger[1] ? (0, import_lodash.get)(values, trigger[1]) : values;
105
- this.plugin.trigger(workflow, {
106
- data,
107
- user: currentUser
108
- });
109
- }
110
- });
111
- }
112
- on(workflow) {
113
- }
114
- off(workflow) {
115
- }
116
- }