@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,35 +0,0 @@
1
- import { WorkflowVariableRawTextArea } from '../variable';
2
- declare const _default: {
3
- title: string;
4
- type: string;
5
- group: string;
6
- description: string;
7
- fieldset: {
8
- sql: {
9
- type: string;
10
- required: boolean;
11
- title: string;
12
- description: string;
13
- 'x-decorator': string;
14
- 'x-component': string;
15
- 'x-component-props': {
16
- rows: number;
17
- className: string;
18
- };
19
- };
20
- };
21
- scope: {};
22
- components: {
23
- WorkflowVariableRawTextArea: typeof WorkflowVariableRawTextArea;
24
- };
25
- useVariables({ key, title }: {
26
- key: any;
27
- title: any;
28
- }, { types, fieldNames }: {
29
- types: any;
30
- fieldNames?: import("@nocobase/client").FieldNames;
31
- }): {
32
- [x: string]: any;
33
- };
34
- };
35
- export default _default;
@@ -1,52 +0,0 @@
1
- import { SchemaInitializerItemType, useCollectionDataSource } from '@nocobase/client';
2
- declare const _default: {
3
- title: string;
4
- type: string;
5
- description: string;
6
- fieldset: {
7
- collection: {
8
- title: string;
9
- description: string;
10
- "x-reactions": any[];
11
- type: string;
12
- required: boolean;
13
- 'x-decorator': string;
14
- 'x-component': string;
15
- 'x-component-props': {
16
- className: string;
17
- };
18
- };
19
- appends: {
20
- title: string;
21
- type: string;
22
- description: string;
23
- 'x-decorator': string;
24
- 'x-component': string;
25
- 'x-component-props': {
26
- title: string;
27
- multiple: boolean;
28
- useCollection(): any;
29
- };
30
- 'x-reactions': {
31
- dependencies: string[];
32
- fulfill: {
33
- state: {
34
- visible: string;
35
- };
36
- };
37
- }[];
38
- };
39
- };
40
- scope: {
41
- useCollectionDataSource: typeof useCollectionDataSource;
42
- };
43
- components: {};
44
- useVariables(config: any, options: any): import("../variable").VariableOption[];
45
- useInitializers(config: any): SchemaInitializerItemType | null;
46
- initializers: {};
47
- useActionTriggerable: boolean;
48
- };
49
- export default _default;
50
- export declare function useTriggerWorkflowsActionProps(): {
51
- onClick(): Promise<void>;
52
- };
@@ -1,7 +0,0 @@
1
- import { BaseFieldOptions, DataTypes, Field } from '@nocobase/database';
2
- export interface ExpressionFieldOptions extends BaseFieldOptions {
3
- type: 'expression';
4
- }
5
- export declare class ExpressionField extends Field {
6
- get dataType(): DataTypes.TextDataTypeConstructor;
7
- }
@@ -1,32 +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 expression_field_exports = {};
19
- __export(expression_field_exports, {
20
- ExpressionField: () => ExpressionField
21
- });
22
- module.exports = __toCommonJS(expression_field_exports);
23
- var import_database = require("@nocobase/database");
24
- class ExpressionField extends import_database.Field {
25
- get dataType() {
26
- return import_database.DataTypes.TEXT;
27
- }
28
- }
29
- // Annotate the CommonJS export names for ESM import in node:
30
- 0 && (module.exports = {
31
- ExpressionField
32
- });
@@ -1 +0,0 @@
1
- export default function (plugin: any): void;
@@ -1,28 +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 fields_exports = {};
19
- __export(fields_exports, {
20
- default: () => fields_default
21
- });
22
- module.exports = __toCommonJS(fields_exports);
23
- var import_expression_field = require("./expression-field");
24
- function fields_default(plugin) {
25
- plugin.db.registerFieldTypes({
26
- expression: import_expression_field.ExpressionField
27
- });
28
- }
@@ -1,54 +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 aggregate_exports = {};
19
- __export(aggregate_exports, {
20
- default: () => aggregate_default
21
- });
22
- module.exports = __toCommonJS(aggregate_exports);
23
- var import_database = require("@nocobase/database");
24
- var import_constants = require("../constants");
25
- const aggregators = {
26
- count: "count",
27
- sum: "sum",
28
- avg: "avg",
29
- min: "min",
30
- max: "max"
31
- };
32
- var aggregate_default = {
33
- async run(node, input, processor) {
34
- const { aggregator, associated, collection, association = {}, params = {} } = node.config;
35
- const options = processor.getParsedValue(params, node.id);
36
- const { database } = node.constructor;
37
- const repo = associated ? database.getRepository(
38
- `${association == null ? void 0 : association.associatedCollection}.${association.name}`,
39
- processor.getParsedValue(association == null ? void 0 : association.associatedKey, node.id)
40
- ) : database.getRepository(collection);
41
- if (!options.dataType && aggregator === "avg") {
42
- options.dataType = import_database.DataTypes.DOUBLE;
43
- }
44
- const result = await repo.aggregate({
45
- ...options,
46
- method: aggregators[aggregator],
47
- transaction: processor.transaction
48
- });
49
- return {
50
- result: options.dataType === import_database.DataTypes.DOUBLE ? Number(result) : result,
51
- status: import_constants.JOB_STATUS.RESOLVED
52
- };
53
- }
54
- };
@@ -1,3 +0,0 @@
1
- import { Instruction } from '.';
2
- declare const _default: Instruction;
3
- export default _default;
@@ -1,6 +0,0 @@
1
- import { Registry } from '@nocobase/utils';
2
- import { Instruction } from '.';
3
- type Comparer = (a: any, b: any) => boolean;
4
- export declare const calculators: Registry<Comparer>;
5
- declare const _default: Instruction;
6
- export default _default;
@@ -1,8 +0,0 @@
1
- import type { FlowNodeModel } from '../types';
2
- declare const _default: {
3
- run(node: FlowNodeModel, input: any, processor: any): Promise<{
4
- result: object;
5
- status: number;
6
- }>;
7
- };
8
- export default _default;
@@ -1,15 +0,0 @@
1
- /// <reference types="node" />
2
- import Plugin from '..';
3
- import Processor from '../Processor';
4
- import { Instruction } from '.';
5
- export default class implements Instruction {
6
- protected plugin: Plugin;
7
- timers: Map<number, NodeJS.Timeout>;
8
- constructor(plugin: Plugin);
9
- load: () => Promise<void>;
10
- unload: () => void;
11
- schedule(job: any): void;
12
- trigger(job: any): Promise<void>;
13
- run: (node: any, prevJob: any, processor: Processor) => Promise<any>;
14
- resume: (node: any, prevJob: any, processor: Processor) => Promise<any>;
15
- }
@@ -1,104 +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 delay_exports = {};
19
- __export(delay_exports, {
20
- default: () => delay_default
21
- });
22
- module.exports = __toCommonJS(delay_exports);
23
- var import_constants = require("../constants");
24
- class delay_default {
25
- constructor(plugin) {
26
- this.plugin = plugin;
27
- plugin.app.on("beforeStart", this.load);
28
- plugin.app.on("beforeStop", this.unload);
29
- }
30
- timers = /* @__PURE__ */ new Map();
31
- load = async () => {
32
- const { model } = this.plugin.db.getCollection("jobs");
33
- const jobs = await model.findAll({
34
- where: {
35
- status: import_constants.JOB_STATUS.PENDING
36
- },
37
- include: [
38
- {
39
- association: "execution",
40
- attributes: [],
41
- where: {
42
- status: import_constants.EXECUTION_STATUS.STARTED
43
- },
44
- required: true
45
- },
46
- {
47
- association: "node",
48
- attributes: ["config"],
49
- where: {
50
- type: "delay"
51
- },
52
- required: true
53
- }
54
- ]
55
- });
56
- jobs.forEach((job) => {
57
- this.schedule(job);
58
- });
59
- };
60
- unload = () => {
61
- for (const timer of this.timers.values()) {
62
- clearTimeout(timer);
63
- }
64
- this.timers = /* @__PURE__ */ new Map();
65
- };
66
- schedule(job) {
67
- const now = /* @__PURE__ */ new Date();
68
- const createdAt = Date.parse(job.createdAt);
69
- const delay = createdAt + job.node.config.duration - now.getTime();
70
- if (delay > 0) {
71
- const trigger = this.trigger.bind(this, job);
72
- this.timers.set(job.id, setTimeout(trigger, delay));
73
- } else {
74
- this.trigger(job);
75
- }
76
- }
77
- async trigger(job) {
78
- if (!job.execution) {
79
- job.execution = await job.getExecution();
80
- }
81
- if (job.execution.status === import_constants.EXECUTION_STATUS.STARTED) {
82
- this.plugin.resume(job);
83
- }
84
- if (this.timers.get(job.id)) {
85
- this.timers.delete(job.id);
86
- }
87
- }
88
- run = async (node, prevJob, processor) => {
89
- const job = await processor.saveJob({
90
- status: import_constants.JOB_STATUS.PENDING,
91
- result: null,
92
- nodeId: node.id,
93
- upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
94
- });
95
- job.node = node;
96
- this.schedule(job);
97
- return processor.exit();
98
- };
99
- resume = async (node, prevJob, processor) => {
100
- const { endStatus } = node.config;
101
- prevJob.set("status", endStatus);
102
- return prevJob;
103
- };
104
- }
@@ -1,8 +0,0 @@
1
- import type { FlowNodeModel } from '../types';
2
- declare const _default: {
3
- run(node: FlowNodeModel, input: any, processor: any): Promise<{
4
- result: any;
5
- status: number;
6
- }>;
7
- };
8
- export default _default;
@@ -1,15 +0,0 @@
1
- import Processor from '../Processor';
2
- import type { FlowNodeModel, JobModel } from '../types';
3
- declare const _default: {
4
- run(node: FlowNodeModel, prevJob: JobModel, processor: Processor): Promise<{
5
- status: number;
6
- result: number;
7
- }>;
8
- resume(node: FlowNodeModel, branchJob: any, processor: Processor): Promise<any>;
9
- getScope(node: any, index: any, processor: any): {
10
- item: any;
11
- index: any;
12
- length: number;
13
- };
14
- };
15
- export default _default;
@@ -1,94 +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 loop_exports = {};
19
- __export(loop_exports, {
20
- default: () => loop_default
21
- });
22
- module.exports = __toCommonJS(loop_exports);
23
- var import_constants = require("../constants");
24
- function getTargetLength(target) {
25
- let length = 0;
26
- if (typeof target === "number") {
27
- if (target < 0) {
28
- throw new Error("Loop target in number type must be greater than 0");
29
- }
30
- length = Math.floor(target);
31
- } else {
32
- const targets = (Array.isArray(target) ? target : [target]).filter((t) => t != null);
33
- length = targets.length;
34
- }
35
- return length;
36
- }
37
- var loop_default = {
38
- async run(node, prevJob, processor) {
39
- const [branch] = processor.getBranches(node);
40
- const target = processor.getParsedValue(node.config.target, node.id);
41
- const length = getTargetLength(target);
42
- if (!branch || !length) {
43
- return {
44
- status: import_constants.JOB_STATUS.RESOLVED,
45
- result: 0
46
- };
47
- }
48
- const job = await processor.saveJob({
49
- status: import_constants.JOB_STATUS.PENDING,
50
- // save loop index
51
- result: 0,
52
- nodeId: node.id,
53
- upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
54
- });
55
- await processor.run(branch, job);
56
- return null;
57
- },
58
- async resume(node, branchJob, processor) {
59
- const job = processor.findBranchParentJob(branchJob, node);
60
- const loop = processor.nodesMap.get(job.nodeId);
61
- const [branch] = processor.getBranches(node);
62
- const { result, status } = job;
63
- if (status !== import_constants.JOB_STATUS.PENDING) {
64
- return processor.exit();
65
- }
66
- const nextIndex = result + 1;
67
- const target = processor.getParsedValue(loop.config.target, node.id);
68
- if (branchJob.status > import_constants.JOB_STATUS.PENDING) {
69
- job.set({ result: nextIndex });
70
- const length = getTargetLength(target);
71
- if (nextIndex < length) {
72
- await processor.saveJob(job);
73
- await processor.run(branch, job);
74
- return null;
75
- }
76
- }
77
- job.set({
78
- status: branchJob.status
79
- });
80
- return job;
81
- },
82
- getScope(node, index, processor) {
83
- const target = processor.getParsedValue(node.config.target, node.id);
84
- const targets = (Array.isArray(target) ? target : [target]).filter((t) => t != null);
85
- const length = getTargetLength(target);
86
- const item = typeof target === "number" ? index : targets[index];
87
- const result = {
88
- item,
89
- index,
90
- length
91
- };
92
- return result;
93
- }
94
- };
@@ -1,2 +0,0 @@
1
- import { Context } from '@nocobase/actions';
2
- export declare function submit(context: Context, next: any): Promise<never>;
@@ -1,94 +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 actions_exports = {};
19
- __export(actions_exports, {
20
- submit: () => submit
21
- });
22
- module.exports = __toCommonJS(actions_exports);
23
- var import_actions = require("@nocobase/actions");
24
- var import_constants = require("../../constants");
25
- async function submit(context, next) {
26
- var _a, _b, _c;
27
- const repository = import_actions.utils.getRepositoryFromParams(context);
28
- const { filterByTk, values } = context.action.params;
29
- const { currentUser } = context.state;
30
- if (!currentUser) {
31
- return context.throw(401);
32
- }
33
- const plugin = context.app.pm.get("workflow");
34
- const instruction = plugin.instructions.get("manual");
35
- const userJob = await repository.findOne({
36
- filterByTk,
37
- // filter: {
38
- // userId: currentUser?.id
39
- // },
40
- appends: ["job", "node", "execution", "workflow"],
41
- context
42
- });
43
- if (!userJob) {
44
- return context.throw(404);
45
- }
46
- const { forms = {} } = userJob.node.config;
47
- const [formKey] = Object.keys(values.result ?? {}).filter((key) => key !== "_");
48
- const actionKey = (_a = values.result) == null ? void 0 : _a._;
49
- const actionItem = (_c = (_b = forms[formKey]) == null ? void 0 : _b.actions) == null ? void 0 : _c.find((item) => item.key === actionKey);
50
- if (userJob.status !== import_constants.JOB_STATUS.PENDING || userJob.job.status !== import_constants.JOB_STATUS.PENDING || userJob.execution.status !== import_constants.EXECUTION_STATUS.STARTED || !userJob.workflow.enabled || !actionKey || (actionItem == null ? void 0 : actionItem.status) == null) {
51
- return context.throw(400);
52
- }
53
- userJob.execution.workflow = userJob.workflow;
54
- const processor = plugin.createProcessor(userJob.execution);
55
- await processor.prepare();
56
- const assignees = processor.getParsedValue(userJob.node.config.assignees ?? [], userJob.nodeId);
57
- if (!assignees.includes(currentUser.id) || userJob.userId !== currentUser.id) {
58
- return context.throw(403);
59
- }
60
- const presetValues = processor.getParsedValue(actionItem.values ?? {}, userJob.nodeId, {
61
- // @deprecated
62
- currentUser: currentUser.toJSON(),
63
- // @deprecated
64
- currentRecord: values.result[formKey],
65
- // @deprecated
66
- currentTime: /* @__PURE__ */ new Date(),
67
- $user: currentUser.toJSON(),
68
- $nForm: values.result[formKey],
69
- $nDate: {
70
- now: /* @__PURE__ */ new Date()
71
- }
72
- });
73
- userJob.set({
74
- status: actionItem.status,
75
- result: actionItem.status > import_constants.JOB_STATUS.PENDING ? { [formKey]: Object.assign(values.result[formKey], presetValues), _: actionKey } : Object.assign(userJob.result ?? {}, values.result)
76
- });
77
- const handler = instruction.formTypes.get(forms[formKey].type);
78
- if (handler && userJob.status) {
79
- await handler.call(instruction, userJob, forms[formKey], processor);
80
- }
81
- await userJob.save({ transaction: processor.transaction });
82
- await processor.exit();
83
- context.body = userJob;
84
- context.status = 202;
85
- await next();
86
- userJob.job.execution = userJob.execution;
87
- userJob.job.latestUserJob = userJob;
88
- processor.logger.info(`manual node (${userJob.nodeId}) action trigger execution (${userJob.execution.id}) to resume`);
89
- plugin.resume(userJob.job);
90
- }
91
- // Annotate the CommonJS export names for ESM import in node:
92
- 0 && (module.exports = {
93
- submit
94
- });
@@ -1,19 +0,0 @@
1
- declare const _default: {
2
- name: string;
3
- fields: ({
4
- type: string;
5
- name: string;
6
- through: string;
7
- target?: undefined;
8
- foreignKey?: undefined;
9
- onDelete?: undefined;
10
- } | {
11
- type: string;
12
- name: string;
13
- target: string;
14
- foreignKey: string;
15
- onDelete: string;
16
- through?: undefined;
17
- })[];
18
- };
19
- export default _default;
@@ -1,39 +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 jobs_exports = {};
19
- __export(jobs_exports, {
20
- default: () => jobs_default
21
- });
22
- module.exports = __toCommonJS(jobs_exports);
23
- var jobs_default = {
24
- name: "jobs",
25
- fields: [
26
- {
27
- type: "belongsToMany",
28
- name: "users",
29
- through: "users_jobs"
30
- },
31
- {
32
- type: "hasMany",
33
- name: "usersJobs",
34
- target: "users_jobs",
35
- foreignKey: "jobId",
36
- onDelete: "CASCADE"
37
- }
38
- ]
39
- };
@@ -1,15 +0,0 @@
1
- declare const _default: {
2
- name: string;
3
- fields: ({
4
- type: string;
5
- name: string;
6
- through: string;
7
- target?: undefined;
8
- } | {
9
- type: string;
10
- name: string;
11
- target: string;
12
- through?: undefined;
13
- })[];
14
- };
15
- export default _default;