@tachybase/plugin-workflow-approval 0.23.58 → 1.0.18

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.
@@ -23,6 +23,10 @@ export declare const getSchemaCheckContent: (params: any) => {
23
23
  noForm: boolean;
24
24
  };
25
25
  };
26
+ timeline: {
27
+ type: string;
28
+ 'x-component': string;
29
+ };
26
30
  };
27
31
  };
28
32
  } & ({
@@ -20,6 +20,10 @@ export declare const getSchemaActionTodosContent: (params: any) => {
20
20
  noForm: boolean;
21
21
  };
22
22
  };
23
+ timeline: {
24
+ type: string;
25
+ 'x-component': string;
26
+ };
23
27
  };
24
28
  };
25
29
  } & ({
@@ -0,0 +1,4 @@
1
+ export declare const ApprovalProcessTimeLine: (props: any) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const Process: ({ dataSource }: {
3
+ dataSource?: any[];
4
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1,18 +1,18 @@
1
1
  module.exports = {
2
- "@tachybase/client": "0.23.58",
3
- "@tachybase/module-workflow": "0.23.58",
4
- "@tachybase/server": "0.23.58",
2
+ "@tachybase/client": "1.0.18",
3
+ "@tachybase/module-workflow": "1.0.18",
4
+ "@tachybase/server": "1.0.18",
5
5
  "lodash": "4.17.21",
6
6
  "react": "18.3.1",
7
- "@tachybase/schema": "0.23.58",
7
+ "@tachybase/schema": "1.0.18",
8
8
  "antd": "5.22.5",
9
- "@tachybase/actions": "0.23.58",
10
- "@tachybase/database": "0.23.58",
11
- "@tachybase/data-source": "0.23.58",
12
- "@tachybase/module-ui-schema": "0.23.58",
13
- "@tachybase/utils": "0.23.58",
9
+ "@tachybase/actions": "1.0.18",
10
+ "@tachybase/database": "1.0.18",
11
+ "@tachybase/data-source": "1.0.18",
12
+ "@tachybase/module-ui-schema": "1.0.18",
13
+ "@tachybase/utils": "1.0.18",
14
14
  "sequelize": "6.37.5",
15
- "@tachybase/components": "0.23.58",
15
+ "@tachybase/components": "1.0.18",
16
16
  "@ant-design/icons": "5.3.7",
17
17
  "ahooks": "3.8.4",
18
18
  "react-router-dom": "6.28.1"
@@ -384,6 +384,7 @@
384
384
  "Workflow todos": "工作流待办",
385
385
  "Workflow will be triggered before deleting succeeded.": "删除成功之前触发工作流。",
386
386
  "Workflow will be triggered before or after submitting succeeded based on workflow type.": "工作流会基于其类型在提交成功之前或之后触发。",
387
+ "Workflow will be triggered before or after submitting succeeded.": "工作流会在提交成功之前或之后触发。",
387
388
  "Workflow will be triggered directly once the button clicked, without data saving.": "按钮点击后直接触发工作流,但不会保存数据。",
388
389
  "comment": "备注",
389
390
  "concat": "连接",
@@ -39,7 +39,7 @@ var import_status = require("../constants/status");
39
39
  var import_tools = require("../tools");
40
40
  const approvals = {
41
41
  async create(context, next) {
42
- const { status, collectionName, data, workflowKey } = context.action.params.values ?? {};
42
+ const { status, collectionName, data, workflowId, workflowKey } = context.action.params.values ?? {};
43
43
  const [dataSourceName, cName] = (0, import_data_source.parseCollectionName)(collectionName);
44
44
  const dataSource = context.app.dataSourceManager.dataSources.get(dataSourceName);
45
45
  if (!dataSource) {
@@ -49,12 +49,19 @@ const approvals = {
49
49
  if (!collection) {
50
50
  return context.throw(400, `Collection "${cName}" not found`);
51
51
  }
52
- const workflow = await context.db.getRepository("workflows").findOne({
53
- filter: {
54
- key: workflowKey,
55
- enabled: true
56
- }
57
- });
52
+ let workflow;
53
+ if (workflowKey) {
54
+ workflow = await context.db.getRepository("workflows").findOne({
55
+ filter: {
56
+ key: workflowKey,
57
+ enabled: true
58
+ }
59
+ });
60
+ } else {
61
+ workflow = await context.db.getRepository("workflows").findOne({
62
+ filterByTk: workflowId
63
+ });
64
+ }
58
65
  if (!workflow) {
59
66
  return context.throw(400, "Current workflow not found or disabled, please refresh and try again");
60
67
  }
@@ -14,7 +14,7 @@ export default class ApprovalTrigger extends Trigger {
14
14
  middleware: (context: any, next: any) => Promise<any>;
15
15
  constructor(workflow: any);
16
16
  workflowTriggerAction(context: any, next: any): Promise<any>;
17
- collectionTriggerAction(context: any): Promise<void>;
17
+ collectionTriggerAction(context: any, workflowList: any): Promise<void>;
18
18
  on(workflow: any): void;
19
19
  off(workflow: any): void;
20
20
  duplicateConfig(workflow: any, { transaction }: {
@@ -49,10 +49,8 @@ const _ApprovalTrigger = class _ApprovalTrigger extends import_module_workflow.T
49
49
  const previousApprovalStatus = approval.previous("status");
50
50
  const currentApprovalStatus = approval.status;
51
51
  const forbiddenList = [
52
- [import_status.APPROVAL_STATUS.SUBMITTED, import_status.APPROVAL_STATUS.DRAFT],
52
+ [import_status.APPROVAL_STATUS.SUBMITTED, import_status.APPROVAL_STATUS.DRAFT]
53
53
  // 撤回情况
54
- [void 0, import_status.APPROVAL_STATUS.DRAFT]
55
- // 保存草稿情况
56
54
  ];
57
55
  const isForbiddenWhenStatusChange = forbiddenList.some(
58
56
  ([prev, curr]) => prev === previousApprovalStatus && curr === currentApprovalStatus
@@ -165,8 +163,11 @@ const _ApprovalTrigger = class _ApprovalTrigger extends import_module_workflow.T
165
163
  const {
166
164
  resourceName,
167
165
  actionName,
168
- params: { triggerWorkflows }
166
+ params: { triggerWorkflows, beforeWorkflows }
169
167
  } = context.action;
168
+ if (beforeWorkflows) {
169
+ this.collectionTriggerAction(context, beforeWorkflows);
170
+ }
170
171
  if (resourceName === "workflows" && actionName === "trigger") {
171
172
  return this.workflowTriggerAction(context, next);
172
173
  }
@@ -174,7 +175,7 @@ const _ApprovalTrigger = class _ApprovalTrigger extends import_module_workflow.T
174
175
  if (!triggerWorkflows || !["create", "update"].includes(actionName)) {
175
176
  return;
176
177
  }
177
- this.collectionTriggerAction(context);
178
+ this.collectionTriggerAction(context, triggerWorkflows);
178
179
  };
179
180
  const { db } = workflow.app;
180
181
  db.on("approvals.afterSave", this.triggerHandler);
@@ -231,11 +232,10 @@ const _ApprovalTrigger = class _ApprovalTrigger extends import_module_workflow.T
231
232
  });
232
233
  });
233
234
  }
234
- async collectionTriggerAction(context) {
235
- const { triggerWorkflows = "" } = context.action.params;
235
+ async collectionTriggerAction(context, workflowList) {
236
236
  const dataSourceHeader = context.get("x-data-source") || "main";
237
237
  const approvalRepo = this.workflow.db.getRepository("approvals");
238
- const triggers = triggerWorkflows.split(",").map((trigger) => trigger.split("!"));
238
+ const triggers = workflowList.split(",").map((trigger) => trigger.split("!"));
239
239
  const triggersKeysMap = new Map(triggers);
240
240
  const workflows = Array.from(this.workflow.enabledCache.values()).filter(
241
241
  (item) => item.type === _ApprovalTrigger.TYPE && triggersKeysMap.has(item.key)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tachybase/plugin-workflow-approval",
3
3
  "displayName": "Approval",
4
- "version": "0.23.58",
4
+ "version": "1.0.18",
5
5
  "description": "Approval base in Workflow",
6
6
  "keywords": [
7
7
  "Approval",
@@ -25,16 +25,17 @@
25
25
  "sequelize": "^6.37.5"
26
26
  },
27
27
  "peerDependencies": {
28
- "@tachybase/actions": "0.23.58",
29
- "@tachybase/client": "0.23.58",
30
- "@tachybase/data-source": "0.23.58",
31
- "@tachybase/database": "0.23.58",
32
- "@tachybase/module-workflow": "0.23.58",
33
- "@tachybase/schema": "0.23.58",
34
- "@tachybase/components": "0.23.58",
35
- "@tachybase/server": "0.23.58",
36
- "@tachybase/utils": "0.23.58",
37
- "@tachybase/test": "0.23.58"
28
+ "@tachybase/actions": "1.0.18",
29
+ "@tachybase/components": "1.0.18",
30
+ "@tachybase/client": "1.0.18",
31
+ "@tachybase/module-ui-schema": "1.0.18",
32
+ "@tachybase/data-source": "1.0.18",
33
+ "@tachybase/database": "1.0.18",
34
+ "@tachybase/module-workflow": "1.0.18",
35
+ "@tachybase/schema": "1.0.18",
36
+ "@tachybase/server": "1.0.18",
37
+ "@tachybase/test": "1.0.18",
38
+ "@tachybase/utils": "1.0.18"
38
39
  },
39
40
  "description.zh-CN": "审批系统是一个强大的BPM工具,为业务流程自动化提供基础支持,同时具备高度灵活性和可扩展性,确保审批流程的效率和合规性,助力企业释放创新潜力。",
40
41
  "displayName.zh-CN": "审批",