@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.
- package/dist/client/WorkflowPane.d.ts +2 -0
- package/dist/client/components/index.d.ts +5 -0
- package/dist/client/hooks/useTriggerWorkflowActionProps.d.ts +3 -0
- package/dist/client/index.d.ts +14 -6
- package/dist/client/index.js +136 -186
- package/dist/client/nodes/calculation.d.ts +8 -62
- package/dist/client/nodes/condition.d.ts +9 -9
- package/dist/client/nodes/create.d.ts +3 -5
- package/dist/client/nodes/destroy.d.ts +3 -4
- package/dist/client/nodes/index.d.ts +2 -6
- package/dist/client/nodes/query.d.ts +3 -5
- package/dist/client/nodes/update.d.ts +4 -4
- package/dist/client/triggers/collection.d.ts +3 -4
- package/dist/client/triggers/index.d.ts +2 -11
- package/dist/client/triggers/schedule/index.d.ts +3 -4
- package/dist/client/utils.d.ts +1 -0
- package/dist/externalVersion.js +11 -13
- package/dist/locale/en-US.json +1 -32
- package/dist/locale/es-ES.json +1 -32
- package/dist/locale/fr-FR.json +1 -32
- package/dist/locale/ja-JP.json +0 -5
- package/dist/locale/pt-BR.json +1 -32
- package/dist/locale/ru-RU.json +0 -5
- package/dist/locale/tr-TR.json +0 -5
- package/dist/locale/zh-CN.json +42 -114
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/server/Plugin.d.ts +12 -2
- package/dist/server/Plugin.js +31 -7
- package/dist/server/Processor.d.ts +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +2 -0
- package/dist/server/instructions/CalculationInstruction.d.ts +15 -0
- package/dist/server/instructions/{calculation.js → CalculationInstruction.js} +13 -6
- package/dist/server/instructions/ConditionInstruction.d.ts +19 -0
- package/dist/server/instructions/{condition.js → ConditionInstruction.js} +11 -7
- package/dist/server/instructions/CreateInstruction.d.ts +10 -0
- package/dist/server/instructions/{create.js → CreateInstruction.js} +13 -6
- package/dist/server/instructions/DestroyInstruction.d.ts +10 -0
- package/dist/server/instructions/{destroy.js → DestroyInstruction.js} +13 -6
- package/dist/server/instructions/{update.d.ts → QueryInstruction.d.ts} +5 -4
- package/dist/server/instructions/{query.js → QueryInstruction.js} +13 -6
- package/dist/server/instructions/{aggregate.d.ts → UpdateInstruction.d.ts} +5 -4
- package/dist/server/instructions/{update.js → UpdateInstruction.js} +13 -6
- package/dist/server/instructions/index.d.ts +10 -14
- package/dist/server/instructions/index.js +9 -39
- package/dist/server/migrations/20231122143143-split-to-plugins.d.ts +4 -0
- package/dist/server/migrations/20231122143143-split-to-plugins.js +87 -0
- package/dist/server/triggers/{collection.d.ts → CollectionTrigger.d.ts} +1 -1
- package/dist/server/triggers/{collection.js → CollectionTrigger.js} +15 -5
- package/dist/server/triggers/{schedule.d.ts → ScheduleTrigger.d.ts} +2 -1
- package/dist/server/triggers/{schedule.js → ScheduleTrigger.js} +5 -5
- package/dist/server/triggers/index.d.ts +2 -6
- package/dist/server/triggers/index.js +1 -21
- package/package.json +3 -2
- package/dist/client/WorkflowProvider.d.ts +0 -5
- package/dist/client/components/Duration.d.ts +0 -5
- package/dist/client/components/DynamicExpression.d.ts +0 -6
- package/dist/client/components/NullRender.d.ts +0 -1
- package/dist/client/interfaces/expression.d.ts +0 -3
- package/dist/client/nodes/aggregate.d.ts +0 -196
- package/dist/client/nodes/delay.d.ts +0 -35
- package/dist/client/nodes/loop.d.ts +0 -33
- package/dist/client/nodes/manual/AssigneesSelect.d.ts +0 -6
- package/dist/client/nodes/manual/DetailsBlockProvider.d.ts +0 -2
- package/dist/client/nodes/manual/FormBlockInitializer.d.ts +0 -2
- package/dist/client/nodes/manual/FormBlockProvider.d.ts +0 -2
- package/dist/client/nodes/manual/ModeConfig.d.ts +0 -5
- package/dist/client/nodes/manual/SchemaConfig.d.ts +0 -49
- package/dist/client/nodes/manual/WorkflowTodo.d.ts +0 -5
- package/dist/client/nodes/manual/WorkflowTodoBlockInitializer.d.ts +0 -2
- package/dist/client/nodes/manual/forms/create.d.ts +0 -3
- package/dist/client/nodes/manual/forms/custom.d.ts +0 -5
- package/dist/client/nodes/manual/forms/update.d.ts +0 -3
- package/dist/client/nodes/manual/index.d.ts +0 -86
- package/dist/client/nodes/manual/utils.d.ts +0 -2
- package/dist/client/nodes/parallel.d.ts +0 -32
- package/dist/client/nodes/request.d.ts +0 -183
- package/dist/client/nodes/sql.d.ts +0 -35
- package/dist/client/triggers/form.d.ts +0 -52
- package/dist/server/fields/expression-field.d.ts +0 -7
- package/dist/server/fields/expression-field.js +0 -32
- package/dist/server/fields/index.d.ts +0 -1
- package/dist/server/fields/index.js +0 -28
- package/dist/server/instructions/aggregate.js +0 -54
- package/dist/server/instructions/calculation.d.ts +0 -3
- package/dist/server/instructions/condition.d.ts +0 -6
- package/dist/server/instructions/create.d.ts +0 -8
- package/dist/server/instructions/delay.d.ts +0 -15
- package/dist/server/instructions/delay.js +0 -104
- package/dist/server/instructions/destroy.d.ts +0 -8
- package/dist/server/instructions/loop.d.ts +0 -15
- package/dist/server/instructions/loop.js +0 -94
- package/dist/server/instructions/manual/actions.d.ts +0 -2
- package/dist/server/instructions/manual/actions.js +0 -94
- package/dist/server/instructions/manual/collecions/jobs.d.ts +0 -19
- package/dist/server/instructions/manual/collecions/jobs.js +0 -39
- package/dist/server/instructions/manual/collecions/users.d.ts +0 -15
- package/dist/server/instructions/manual/collecions/users.js +0 -37
- package/dist/server/instructions/manual/collecions/users_jobs.d.ts +0 -3
- package/dist/server/instructions/manual/collecions/users_jobs.js +0 -70
- package/dist/server/instructions/manual/forms/create.d.ts +0 -5
- package/dist/server/instructions/manual/forms/create.js +0 -41
- package/dist/server/instructions/manual/forms/index.d.ts +0 -6
- package/dist/server/instructions/manual/forms/index.js +0 -38
- package/dist/server/instructions/manual/forms/update.d.ts +0 -6
- package/dist/server/instructions/manual/forms/update.js +0 -41
- package/dist/server/instructions/manual/index.d.ts +0 -29
- package/dist/server/instructions/manual/index.js +0 -179
- package/dist/server/instructions/parallel.d.ts +0 -12
- package/dist/server/instructions/parallel.js +0 -124
- package/dist/server/instructions/query.d.ts +0 -9
- package/dist/server/instructions/request.d.ts +0 -18
- package/dist/server/instructions/request.js +0 -92
- package/dist/server/instructions/sql.d.ts +0 -12
- package/dist/server/instructions/sql.js +0 -43
- package/dist/server/triggers/form.d.ts +0 -11
- package/dist/server/triggers/form.js +0 -116
|
@@ -1,37 +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 users_exports = {};
|
|
19
|
-
__export(users_exports, {
|
|
20
|
-
default: () => users_default
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(users_exports);
|
|
23
|
-
var users_default = {
|
|
24
|
-
name: "users",
|
|
25
|
-
fields: [
|
|
26
|
-
{
|
|
27
|
-
type: "belongsToMany",
|
|
28
|
-
name: "jobs",
|
|
29
|
-
through: "users_jobs"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
type: "hasMany",
|
|
33
|
-
name: "usersJobs",
|
|
34
|
-
target: "users_jobs"
|
|
35
|
-
}
|
|
36
|
-
]
|
|
37
|
-
};
|
|
@@ -1,70 +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 users_jobs_exports = {};
|
|
19
|
-
__export(users_jobs_exports, {
|
|
20
|
-
default: () => users_jobs_default
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(users_jobs_exports);
|
|
23
|
-
var users_jobs_default = {
|
|
24
|
-
namespace: "workflow.executionLogs",
|
|
25
|
-
name: "users_jobs",
|
|
26
|
-
duplicator: "optional",
|
|
27
|
-
fields: [
|
|
28
|
-
{
|
|
29
|
-
type: "bigInt",
|
|
30
|
-
name: "id",
|
|
31
|
-
primaryKey: true,
|
|
32
|
-
autoIncrement: true
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
type: "belongsTo",
|
|
36
|
-
name: "job",
|
|
37
|
-
target: "jobs",
|
|
38
|
-
foreignKey: "jobId",
|
|
39
|
-
primaryKey: false
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
type: "belongsTo",
|
|
43
|
-
name: "user",
|
|
44
|
-
target: "users",
|
|
45
|
-
foreignKey: "userId",
|
|
46
|
-
primaryKey: false
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
type: "belongsTo",
|
|
50
|
-
name: "execution"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
type: "belongsTo",
|
|
54
|
-
name: "node",
|
|
55
|
-
target: "flow_nodes"
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
type: "belongsTo",
|
|
59
|
-
name: "workflow"
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
type: "integer",
|
|
63
|
-
name: "status"
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
type: "jsonb",
|
|
67
|
-
name: "result"
|
|
68
|
-
}
|
|
69
|
-
]
|
|
70
|
-
};
|
|
@@ -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,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,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
|
-
}
|