@nocobase/plugin-workflow-manual 1.2.13-alpha → 1.3.0-alpha.20240710084543
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/package.json +2 -2
- package/dist/client/WorkflowTodo.d.ts +0 -13
- package/dist/client/WorkflowTodoBlockInitializer.d.ts +0 -10
- package/dist/client/index.d.ts +0 -14
- package/dist/client/index.js +0 -22
- package/dist/client/instruction/AssigneesSelect.d.ts +0 -14
- package/dist/client/instruction/FormBlockInitializer.d.ts +0 -10
- package/dist/client/instruction/FormBlockProvider.d.ts +0 -10
- package/dist/client/instruction/ModeConfig.d.ts +0 -13
- package/dist/client/instruction/SchemaConfig.d.ts +0 -68
- package/dist/client/instruction/createManualFormBlockUISchema.d.ts +0 -65
- package/dist/client/instruction/forms/create.d.ts +0 -11
- package/dist/client/instruction/forms/custom.d.ts +0 -18
- package/dist/client/instruction/forms/update.d.ts +0 -11
- package/dist/client/instruction/index.d.ts +0 -99
- package/dist/client/instruction/utils.d.ts +0 -9
- package/dist/externalVersion.js +0 -29
- package/dist/index.d.ts +0 -10
- package/dist/index.js +0 -48
- package/dist/locale/en-US.json +0 -30
- package/dist/locale/index.d.ts +0 -12
- package/dist/locale/index.js +0 -51
- package/dist/locale/ko_KR.json +0 -32
- package/dist/locale/zh-CN.json +0 -32
- package/dist/server/ManualInstruction.d.ts +0 -36
- package/dist/server/ManualInstruction.js +0 -164
- package/dist/server/Plugin.d.ts +0 -12
- package/dist/server/Plugin.js +0 -77
- package/dist/server/actions.d.ts +0 -10
- package/dist/server/actions.js +0 -113
- package/dist/server/collections/1-users_jobs.d.ts +0 -10
- package/dist/server/collections/1-users_jobs.js +0 -82
- package/dist/server/collections/2-jobs.d.ts +0 -14
- package/dist/server/collections/2-jobs.js +0 -49
- package/dist/server/collections/3-users.d.ts +0 -14
- package/dist/server/collections/3-users.js +0 -47
- package/dist/server/forms/create.d.ts +0 -14
- package/dist/server/forms/create.js +0 -50
- package/dist/server/forms/index.d.ts +0 -14
- package/dist/server/forms/index.js +0 -47
- package/dist/server/forms/update.d.ts +0 -15
- package/dist/server/forms/update.js +0 -50
- package/dist/server/index.d.ts +0 -9
- package/dist/server/index.js +0 -42
- package/dist/server/migrations/20240325213145-fix-schema.d.ts +0 -13
- package/dist/server/migrations/20240325213145-fix-schema.js +0 -98
package/dist/locale/index.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
export declare const NAMESPACE = "workflow-manual";
|
|
10
|
-
export declare function useLang(key: string, options?: {}): string;
|
|
11
|
-
export declare const lang: typeof useLang;
|
|
12
|
-
export declare function usePluginTranslation(options?: any): import("react-i18next").UseTranslationResponse<"workflow-manual", undefined>;
|
package/dist/locale/index.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __export = (target, all) => {
|
|
15
|
-
for (var name in all)
|
|
16
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
-
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
-
for (let key of __getOwnPropNames(from))
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
-
}
|
|
24
|
-
return to;
|
|
25
|
-
};
|
|
26
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
-
var locale_exports = {};
|
|
28
|
-
__export(locale_exports, {
|
|
29
|
-
NAMESPACE: () => NAMESPACE,
|
|
30
|
-
lang: () => lang,
|
|
31
|
-
useLang: () => useLang,
|
|
32
|
-
usePluginTranslation: () => usePluginTranslation
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(locale_exports);
|
|
35
|
-
var import_react_i18next = require("react-i18next");
|
|
36
|
-
const NAMESPACE = "workflow-manual";
|
|
37
|
-
function useLang(key, options = {}) {
|
|
38
|
-
const { t } = usePluginTranslation(options);
|
|
39
|
-
return t(key);
|
|
40
|
-
}
|
|
41
|
-
const lang = useLang;
|
|
42
|
-
function usePluginTranslation(options) {
|
|
43
|
-
return (0, import_react_i18next.useTranslation)(NAMESPACE, options);
|
|
44
|
-
}
|
|
45
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
-
0 && (module.exports = {
|
|
47
|
-
NAMESPACE,
|
|
48
|
-
lang,
|
|
49
|
-
useLang,
|
|
50
|
-
usePluginTranslation
|
|
51
|
-
});
|
package/dist/locale/ko_KR.json
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"Manual": "수동",
|
|
3
|
-
"Could be used for manually submitting data, and determine whether to continue or exit. Workflow will generate a todo item for assigned user when it reaches a manual node, and continue processing after user submits the form.":
|
|
4
|
-
"수동으로 데이터를 제출하고 계속 진행할지 종료할지를 결정하는 데 사용될 수 있습니다. 워크플로우가 수동 노드에 도달하면 지정된 사용자에 대해 할 일 항목을 생성하고 사용자가 양식을 제출한 후 처리를 계속합니다.",
|
|
5
|
-
"Values preset in this form will override user submitted ones when continue or reject.":
|
|
6
|
-
"이 양식에 사전 설정된 값은 계속 또는 거부될 때 사용자가 제출한 값이 덮어씁니다.",
|
|
7
|
-
"Assignee": "담당자",
|
|
8
|
-
"Assignees": "담당자",
|
|
9
|
-
"User interface": "사용자 인터페이스",
|
|
10
|
-
"Configure user interface": "사용자 인터페이스 구성",
|
|
11
|
-
"View user interface": "사용자 인터페이스 보기",
|
|
12
|
-
"Separately": "별도로",
|
|
13
|
-
"Each user has own task": "각 사용자는 고유한 작업을 갖습니다.",
|
|
14
|
-
"Collaboratively": "협력하여",
|
|
15
|
-
"Everyone shares one task": "모두가 하나의 작업을 공유합니다.",
|
|
16
|
-
"Negotiation": "협상",
|
|
17
|
-
"All pass": "모두 통과",
|
|
18
|
-
"Everyone should pass": "모든 사람이 통과해야 합니다.",
|
|
19
|
-
"Any pass": "어떤 통과",
|
|
20
|
-
"Anyone pass": "누구든 통과하면 됩니다.",
|
|
21
|
-
"Field name existed in form": "양식에 이미 존재하는 필드 이름",
|
|
22
|
-
"Continue the process": "프로세스 계속 진행",
|
|
23
|
-
"Terminate the process": "프로세스 종료",
|
|
24
|
-
"Save temporarily": "임시로 저장",
|
|
25
|
-
"Custom form": "사용자 정의 양식",
|
|
26
|
-
"Data record": "데이터 레코드",
|
|
27
|
-
"Create record form": "레코드 생성 양식",
|
|
28
|
-
"Update record form": "레코드 업데이트 양식",
|
|
29
|
-
"Filter settings": "필터 설정",
|
|
30
|
-
"Workflow todos": "워크플로우 할 일",
|
|
31
|
-
"Task node": "작업 노드"
|
|
32
|
-
}
|
package/dist/locale/zh-CN.json
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"Manual": "人工处理",
|
|
3
|
-
"Could be used for manually submitting data, and determine whether to continue or exit. Workflow will generate a todo item for assigned user when it reaches a manual node, and continue processing after user submits the form.": "可用于人工提交数据,并决定是否继续或退出流程。工作流在执行到人工节点时会为被指派的用户生成待办事项,直到用户提交对应表单后继续处理该流程。",
|
|
4
|
-
"Values preset in this form will override user submitted ones when continue or reject.": "表单中预设的字段值会在用户提交继续或拒绝时覆盖相应字段的值。",
|
|
5
|
-
"Assignee": "负责人",
|
|
6
|
-
"Assignees": "负责人",
|
|
7
|
-
"User interface": "操作界面",
|
|
8
|
-
"Configure user interface": "配置界面",
|
|
9
|
-
"View user interface": "查看界面",
|
|
10
|
-
"Separately": "分别处理",
|
|
11
|
-
"Each user has own task": "每个人处理各自的任务",
|
|
12
|
-
"Collaboratively": "协作处理",
|
|
13
|
-
"Everyone shares one task": "所有人共享同一个任务",
|
|
14
|
-
"Negotiation": "协商机制",
|
|
15
|
-
"All pass": "全部通过",
|
|
16
|
-
"Everyone should pass": "每个人通过才通过",
|
|
17
|
-
"Any pass": "任意通过",
|
|
18
|
-
"Anyone pass": "任何一人通过即通过",
|
|
19
|
-
"Field name existed in form": "表单中已有对应标识的字段",
|
|
20
|
-
"Continue the process": "继续流程",
|
|
21
|
-
"Terminate the process": "终止流程",
|
|
22
|
-
"Save temporarily": "暂存",
|
|
23
|
-
"Custom form": "自定义表单",
|
|
24
|
-
"Data record": "数据记录",
|
|
25
|
-
"Create record form": "新增数据表单",
|
|
26
|
-
"Update record form": "更新数据表单",
|
|
27
|
-
"Filter settings": "筛选设置",
|
|
28
|
-
"Workflow todos": "工作流待办",
|
|
29
|
-
"Task node": "任务节点",
|
|
30
|
-
"Unprocessed": "未处理",
|
|
31
|
-
"Please check one of your update record form, and add at least one filter condition in form settings.": "请检查您的其中的更新数据表单,并在表单设置中至少添加一个筛选条件。"
|
|
32
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { Registry } from '@nocobase/utils';
|
|
10
|
-
import WorkflowPlugin, { Processor, Instruction } from '@nocobase/plugin-workflow';
|
|
11
|
-
import { FormHandler } from './forms';
|
|
12
|
-
type FormType = {
|
|
13
|
-
type: 'custom' | 'create' | 'update';
|
|
14
|
-
actions: number[];
|
|
15
|
-
options: {
|
|
16
|
-
[key: string]: any;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export interface ManualConfig {
|
|
20
|
-
schema: {
|
|
21
|
-
[key: string]: any;
|
|
22
|
-
};
|
|
23
|
-
forms: {
|
|
24
|
-
[key: string]: FormType;
|
|
25
|
-
};
|
|
26
|
-
assignees?: (number | string)[];
|
|
27
|
-
mode?: number;
|
|
28
|
-
}
|
|
29
|
-
export default class extends Instruction {
|
|
30
|
-
workflow: WorkflowPlugin;
|
|
31
|
-
formTypes: Registry<FormHandler>;
|
|
32
|
-
constructor(workflow: WorkflowPlugin);
|
|
33
|
-
run(node: any, prevJob: any, processor: Processor): Promise<any>;
|
|
34
|
-
resume(node: any, job: any, processor: Processor): Promise<any>;
|
|
35
|
-
}
|
|
36
|
-
export {};
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __export = (target, all) => {
|
|
17
|
-
for (var name in all)
|
|
18
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from))
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
-
mod
|
|
35
|
-
));
|
|
36
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
-
var ManualInstruction_exports = {};
|
|
38
|
-
__export(ManualInstruction_exports, {
|
|
39
|
-
default: () => ManualInstruction_default
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(ManualInstruction_exports);
|
|
42
|
-
var import_utils = require("@nocobase/utils");
|
|
43
|
-
var import_plugin_workflow = require("@nocobase/plugin-workflow");
|
|
44
|
-
var import_forms = __toESM(require("./forms"));
|
|
45
|
-
const MULTIPLE_ASSIGNED_MODE = {
|
|
46
|
-
SINGLE: Symbol("single"),
|
|
47
|
-
ALL: Symbol("all"),
|
|
48
|
-
ANY: Symbol("any"),
|
|
49
|
-
ALL_PERCENTAGE: Symbol("all percentage"),
|
|
50
|
-
ANY_PERCENTAGE: Symbol("any percentage")
|
|
51
|
-
};
|
|
52
|
-
const Modes = {
|
|
53
|
-
[MULTIPLE_ASSIGNED_MODE.SINGLE]: {
|
|
54
|
-
getStatus(distribution, assignees) {
|
|
55
|
-
const done = distribution.find((item) => item.status !== import_plugin_workflow.JOB_STATUS.PENDING && item.count > 0);
|
|
56
|
-
return done ? done.status : null;
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
[MULTIPLE_ASSIGNED_MODE.ALL]: {
|
|
60
|
-
getStatus(distribution, assignees) {
|
|
61
|
-
const resolved = distribution.find((item) => item.status === import_plugin_workflow.JOB_STATUS.RESOLVED);
|
|
62
|
-
if (resolved && resolved.count === assignees.length) {
|
|
63
|
-
return import_plugin_workflow.JOB_STATUS.RESOLVED;
|
|
64
|
-
}
|
|
65
|
-
const rejected = distribution.find((item) => item.status < import_plugin_workflow.JOB_STATUS.PENDING);
|
|
66
|
-
if (rejected && rejected.count) {
|
|
67
|
-
return rejected.status;
|
|
68
|
-
}
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
[MULTIPLE_ASSIGNED_MODE.ANY]: {
|
|
73
|
-
getStatus(distribution, assignees) {
|
|
74
|
-
const resolved = distribution.find((item) => item.status === import_plugin_workflow.JOB_STATUS.RESOLVED);
|
|
75
|
-
if (resolved && resolved.count) {
|
|
76
|
-
return import_plugin_workflow.JOB_STATUS.RESOLVED;
|
|
77
|
-
}
|
|
78
|
-
const rejectedCount = distribution.reduce(
|
|
79
|
-
(count, item) => item.status < import_plugin_workflow.JOB_STATUS.PENDING ? count + item.count : count,
|
|
80
|
-
0
|
|
81
|
-
);
|
|
82
|
-
if (rejectedCount === assignees.length) {
|
|
83
|
-
return import_plugin_workflow.JOB_STATUS.REJECTED;
|
|
84
|
-
}
|
|
85
|
-
return null;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
function getMode(mode) {
|
|
90
|
-
switch (true) {
|
|
91
|
-
case mode === 1:
|
|
92
|
-
return Modes[MULTIPLE_ASSIGNED_MODE.ALL];
|
|
93
|
-
case mode === -1:
|
|
94
|
-
return Modes[MULTIPLE_ASSIGNED_MODE.ANY];
|
|
95
|
-
case mode > 0:
|
|
96
|
-
return Modes[MULTIPLE_ASSIGNED_MODE.ALL_PERCENTAGE];
|
|
97
|
-
case mode < 0:
|
|
98
|
-
return Modes[MULTIPLE_ASSIGNED_MODE.ANY_PERCENTAGE];
|
|
99
|
-
default:
|
|
100
|
-
return Modes[MULTIPLE_ASSIGNED_MODE.SINGLE];
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
class ManualInstruction_default extends import_plugin_workflow.Instruction {
|
|
104
|
-
constructor(workflow) {
|
|
105
|
-
super(workflow);
|
|
106
|
-
this.workflow = workflow;
|
|
107
|
-
(0, import_forms.default)(this);
|
|
108
|
-
}
|
|
109
|
-
formTypes = new import_utils.Registry();
|
|
110
|
-
async run(node, prevJob, processor) {
|
|
111
|
-
const { mode, ...config } = node.config;
|
|
112
|
-
const assignees = [...new Set(processor.getParsedValue(config.assignees, node.id).flat().filter(Boolean))];
|
|
113
|
-
const job = await processor.saveJob({
|
|
114
|
-
status: assignees.length ? import_plugin_workflow.JOB_STATUS.PENDING : import_plugin_workflow.JOB_STATUS.RESOLVED,
|
|
115
|
-
result: mode ? [] : null,
|
|
116
|
-
nodeId: node.id,
|
|
117
|
-
nodeKey: node.key,
|
|
118
|
-
upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
|
|
119
|
-
});
|
|
120
|
-
if (!assignees.length) {
|
|
121
|
-
return job;
|
|
122
|
-
}
|
|
123
|
-
const UserJobModel = this.workflow.app.db.getModel("users_jobs");
|
|
124
|
-
await UserJobModel.bulkCreate(
|
|
125
|
-
assignees.map((userId) => ({
|
|
126
|
-
userId,
|
|
127
|
-
jobId: job.id,
|
|
128
|
-
nodeId: node.id,
|
|
129
|
-
executionId: job.executionId,
|
|
130
|
-
workflowId: node.workflowId,
|
|
131
|
-
status: import_plugin_workflow.JOB_STATUS.PENDING
|
|
132
|
-
})),
|
|
133
|
-
{
|
|
134
|
-
// transaction: processor.transaction,
|
|
135
|
-
}
|
|
136
|
-
);
|
|
137
|
-
return job;
|
|
138
|
-
}
|
|
139
|
-
async resume(node, job, processor) {
|
|
140
|
-
var _a;
|
|
141
|
-
const { mode } = node.config;
|
|
142
|
-
const assignees = [...new Set(processor.getParsedValue(node.config.assignees, node.id).flat().filter(Boolean))];
|
|
143
|
-
const UserJobModel = this.workflow.app.db.getModel("users_jobs");
|
|
144
|
-
const distribution = await UserJobModel.count({
|
|
145
|
-
where: {
|
|
146
|
-
jobId: job.id
|
|
147
|
-
},
|
|
148
|
-
group: ["status"]
|
|
149
|
-
// transaction: processor.transaction,
|
|
150
|
-
});
|
|
151
|
-
const submitted = distribution.reduce(
|
|
152
|
-
(count, item) => item.status !== import_plugin_workflow.JOB_STATUS.PENDING ? count + item.count : count,
|
|
153
|
-
0
|
|
154
|
-
);
|
|
155
|
-
const status = job.status || (getMode(mode).getStatus(distribution, assignees) ?? import_plugin_workflow.JOB_STATUS.PENDING);
|
|
156
|
-
const result = mode ? (submitted || 0) / assignees.length : ((_a = job.latestUserJob) == null ? void 0 : _a.result) ?? job.result;
|
|
157
|
-
processor.logger.debug(`manual resume job and next status: ${status}`);
|
|
158
|
-
job.set({
|
|
159
|
-
status,
|
|
160
|
-
result
|
|
161
|
-
});
|
|
162
|
-
return job;
|
|
163
|
-
}
|
|
164
|
-
}
|
package/dist/server/Plugin.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { Plugin } from '@nocobase/server';
|
|
10
|
-
export default class extends Plugin {
|
|
11
|
-
load(): Promise<void>;
|
|
12
|
-
}
|
package/dist/server/Plugin.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __export = (target, all) => {
|
|
17
|
-
for (var name in all)
|
|
18
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from))
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
-
mod
|
|
35
|
-
));
|
|
36
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
-
var Plugin_exports = {};
|
|
38
|
-
__export(Plugin_exports, {
|
|
39
|
-
default: () => Plugin_default
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(Plugin_exports);
|
|
42
|
-
var import_server = require("@nocobase/server");
|
|
43
|
-
var import_actions = __toESM(require("@nocobase/actions"));
|
|
44
|
-
var import_plugin_workflow = __toESM(require("@nocobase/plugin-workflow"));
|
|
45
|
-
var import_path = __toESM(require("path"));
|
|
46
|
-
var import_actions2 = require("./actions");
|
|
47
|
-
var import_ManualInstruction = __toESM(require("./ManualInstruction"));
|
|
48
|
-
class Plugin_default extends import_server.Plugin {
|
|
49
|
-
async load() {
|
|
50
|
-
await this.importCollections(import_path.default.resolve(__dirname, "collections"));
|
|
51
|
-
this.app.resource({
|
|
52
|
-
name: "users_jobs",
|
|
53
|
-
actions: {
|
|
54
|
-
list: {
|
|
55
|
-
filter: {
|
|
56
|
-
$or: [
|
|
57
|
-
{
|
|
58
|
-
"workflow.enabled": true
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
"workflow.enabled": false,
|
|
62
|
-
status: {
|
|
63
|
-
$ne: import_plugin_workflow.JOB_STATUS.PENDING
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
},
|
|
68
|
-
handler: import_actions.default.list
|
|
69
|
-
},
|
|
70
|
-
submit: import_actions2.submit
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
this.app.acl.allow("users_jobs", ["list", "get", "submit"], "loggedIn");
|
|
74
|
-
const workflowPlugin = this.app.pm.get(import_plugin_workflow.default);
|
|
75
|
-
workflowPlugin.registerInstruction("manual", import_ManualInstruction.default);
|
|
76
|
-
}
|
|
77
|
-
}
|
package/dist/server/actions.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
import { Context } from '@nocobase/actions';
|
|
10
|
-
export declare function submit(context: Context, next: any): Promise<never>;
|
package/dist/server/actions.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __create = Object.create;
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __export = (target, all) => {
|
|
17
|
-
for (var name in all)
|
|
18
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
-
};
|
|
20
|
-
var __copyProps = (to, from, except, desc) => {
|
|
21
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
-
for (let key of __getOwnPropNames(from))
|
|
23
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
-
}
|
|
26
|
-
return to;
|
|
27
|
-
};
|
|
28
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
-
mod
|
|
35
|
-
));
|
|
36
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
-
var actions_exports = {};
|
|
38
|
-
__export(actions_exports, {
|
|
39
|
-
submit: () => submit
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(actions_exports);
|
|
42
|
-
var import_actions = require("@nocobase/actions");
|
|
43
|
-
var import_plugin_workflow = __toESM(require("@nocobase/plugin-workflow"));
|
|
44
|
-
async function submit(context, next) {
|
|
45
|
-
var _a, _b, _c;
|
|
46
|
-
const repository = import_actions.utils.getRepositoryFromParams(context);
|
|
47
|
-
const { filterByTk, values } = context.action.params;
|
|
48
|
-
const { currentUser } = context.state;
|
|
49
|
-
if (!currentUser) {
|
|
50
|
-
return context.throw(401);
|
|
51
|
-
}
|
|
52
|
-
const plugin = context.app.getPlugin(import_plugin_workflow.default);
|
|
53
|
-
const instruction = plugin.instructions.get("manual");
|
|
54
|
-
const userJob = await repository.findOne({
|
|
55
|
-
filterByTk,
|
|
56
|
-
// filter: {
|
|
57
|
-
// userId: currentUser?.id
|
|
58
|
-
// },
|
|
59
|
-
appends: ["job", "node", "execution", "workflow"],
|
|
60
|
-
context
|
|
61
|
-
});
|
|
62
|
-
if (!userJob) {
|
|
63
|
-
return context.throw(404);
|
|
64
|
-
}
|
|
65
|
-
const { forms = {} } = userJob.node.config;
|
|
66
|
-
const [formKey] = Object.keys(values.result ?? {}).filter((key) => key !== "_");
|
|
67
|
-
const actionKey = (_a = values.result) == null ? void 0 : _a._;
|
|
68
|
-
const actionItem = (_c = (_b = forms[formKey]) == null ? void 0 : _b.actions) == null ? void 0 : _c.find((item) => item.key === actionKey);
|
|
69
|
-
if (userJob.status !== import_plugin_workflow.JOB_STATUS.PENDING || userJob.job.status !== import_plugin_workflow.JOB_STATUS.PENDING || userJob.execution.status !== import_plugin_workflow.EXECUTION_STATUS.STARTED || !userJob.workflow.enabled || !actionKey || (actionItem == null ? void 0 : actionItem.status) == null) {
|
|
70
|
-
return context.throw(400);
|
|
71
|
-
}
|
|
72
|
-
userJob.execution.workflow = userJob.workflow;
|
|
73
|
-
const processor = plugin.createProcessor(userJob.execution);
|
|
74
|
-
await processor.prepare();
|
|
75
|
-
const assignees = processor.getParsedValue(userJob.node.config.assignees ?? [], userJob.nodeId).flat().filter(Boolean);
|
|
76
|
-
if (!assignees.includes(currentUser.id) || userJob.userId !== currentUser.id) {
|
|
77
|
-
return context.throw(403);
|
|
78
|
-
}
|
|
79
|
-
const presetValues = processor.getParsedValue(actionItem.values ?? {}, userJob.nodeId, {
|
|
80
|
-
// @deprecated
|
|
81
|
-
currentUser,
|
|
82
|
-
// @deprecated
|
|
83
|
-
currentRecord: values.result[formKey],
|
|
84
|
-
// @deprecated
|
|
85
|
-
currentTime: /* @__PURE__ */ new Date(),
|
|
86
|
-
$user: currentUser,
|
|
87
|
-
$nForm: values.result[formKey],
|
|
88
|
-
$nDate: {
|
|
89
|
-
now: /* @__PURE__ */ new Date()
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
userJob.set({
|
|
93
|
-
status: actionItem.status,
|
|
94
|
-
result: actionItem.status > import_plugin_workflow.JOB_STATUS.PENDING ? { [formKey]: Object.assign(values.result[formKey], presetValues), _: actionKey } : Object.assign(userJob.result ?? {}, values.result)
|
|
95
|
-
});
|
|
96
|
-
const handler = instruction.formTypes.get(forms[formKey].type);
|
|
97
|
-
if (handler && userJob.status) {
|
|
98
|
-
await handler.call(instruction, userJob, forms[formKey], processor);
|
|
99
|
-
}
|
|
100
|
-
await userJob.save();
|
|
101
|
-
await processor.exit();
|
|
102
|
-
context.body = userJob;
|
|
103
|
-
context.status = 202;
|
|
104
|
-
await next();
|
|
105
|
-
userJob.job.execution = userJob.execution;
|
|
106
|
-
userJob.job.latestUserJob = userJob;
|
|
107
|
-
processor.logger.info(`manual node (${userJob.nodeId}) action trigger execution (${userJob.execution.id}) to resume`);
|
|
108
|
-
plugin.resume(userJob.job);
|
|
109
|
-
}
|
|
110
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
111
|
-
0 && (module.exports = {
|
|
112
|
-
submit
|
|
113
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
declare const _default: import("@nocobase/database").CollectionOptions;
|
|
10
|
-
export default _default;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __export = (target, all) => {
|
|
15
|
-
for (var name in all)
|
|
16
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
-
};
|
|
18
|
-
var __copyProps = (to, from, except, desc) => {
|
|
19
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
-
for (let key of __getOwnPropNames(from))
|
|
21
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
-
}
|
|
24
|
-
return to;
|
|
25
|
-
};
|
|
26
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
-
var users_jobs_exports = {};
|
|
28
|
-
__export(users_jobs_exports, {
|
|
29
|
-
default: () => users_jobs_default
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(users_jobs_exports);
|
|
32
|
-
var import_database = require("@nocobase/database");
|
|
33
|
-
var users_jobs_default = (0, import_database.defineCollection)({
|
|
34
|
-
name: "users_jobs",
|
|
35
|
-
dumpRules: {
|
|
36
|
-
group: "log"
|
|
37
|
-
},
|
|
38
|
-
shared: true,
|
|
39
|
-
fields: [
|
|
40
|
-
{
|
|
41
|
-
type: "bigInt",
|
|
42
|
-
name: "id",
|
|
43
|
-
primaryKey: true,
|
|
44
|
-
autoIncrement: true
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
type: "belongsTo",
|
|
48
|
-
name: "job",
|
|
49
|
-
target: "jobs",
|
|
50
|
-
foreignKey: "jobId",
|
|
51
|
-
primaryKey: false
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
type: "belongsTo",
|
|
55
|
-
name: "user",
|
|
56
|
-
target: "users",
|
|
57
|
-
foreignKey: "userId",
|
|
58
|
-
primaryKey: false
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
type: "belongsTo",
|
|
62
|
-
name: "execution"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
type: "belongsTo",
|
|
66
|
-
name: "node",
|
|
67
|
-
target: "flow_nodes"
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
type: "belongsTo",
|
|
71
|
-
name: "workflow"
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
type: "integer",
|
|
75
|
-
name: "status"
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
type: "jsonb",
|
|
79
|
-
name: "result"
|
|
80
|
-
}
|
|
81
|
-
]
|
|
82
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is part of the NocoBase (R) project.
|
|
3
|
-
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
-
* Authors: NocoBase Team.
|
|
5
|
-
*
|
|
6
|
-
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
-
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
-
*/
|
|
9
|
-
declare const _default: {
|
|
10
|
-
collectionOptions: import("@nocobase/database").CollectionOptions;
|
|
11
|
-
mergeOptions: import("deepmerge").Options;
|
|
12
|
-
extend: boolean;
|
|
13
|
-
};
|
|
14
|
-
export default _default;
|