@tachybase/plugin-workflow-approval 1.5.1 → 1.6.1

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 (35) hide show
  1. package/dist/client/base/ApprovalPane.schema.d.ts +81 -11
  2. package/dist/client/common/components/ApprovalsSummary.d.ts +11 -0
  3. package/dist/client/common/components/SimpleTable.d.ts +24 -0
  4. package/dist/client/common/components/WorkflowApproval.d.ts +4 -0
  5. package/dist/client/common/components/index.d.ts +5 -0
  6. package/dist/client/common/tools/cleanAssociationIds.d.ts +9 -0
  7. package/dist/client/index.js +34 -70
  8. package/dist/client/user-interface/h5/common/approval-columns/summary.column.d.ts +7 -0
  9. package/dist/client/user-interface/h5/common/processSummary.d.ts +14 -0
  10. package/dist/client/user-interface/h5/todos/component/TabApprovalItem.d.ts +1 -1
  11. package/dist/common/constants.d.ts +6 -0
  12. package/dist/common/constants.js +14 -2
  13. package/dist/common/interface.d.js +15 -0
  14. package/dist/common/utils.d.ts +2 -0
  15. package/dist/common/utils.js +46 -0
  16. package/dist/externalVersion.js +10 -9
  17. package/dist/locale/en-US.json +3 -1
  18. package/dist/locale/zh-CN.json +2 -1
  19. package/dist/server/actions/approvalCarbonCopy.d.ts +1 -1
  20. package/dist/server/actions/approvalCarbonCopy.js +7 -7
  21. package/dist/server/actions/approvalRecords.d.ts +2 -2
  22. package/dist/server/actions/approvalRecords.js +19 -19
  23. package/dist/server/actions/approvals.d.ts +6 -6
  24. package/dist/server/actions/approvals.js +65 -82
  25. package/dist/server/actions/index.js +1 -1
  26. package/dist/server/actions/workflows.d.ts +1 -1
  27. package/dist/server/actions/workflows.js +3 -3
  28. package/dist/server/plugin.js +0 -3
  29. package/dist/server/tools.d.ts +4 -7
  30. package/dist/server/tools.js +253 -12
  31. package/dist/server/triggers/Approval.d.ts +3 -3
  32. package/dist/server/triggers/Approval.js +32 -22
  33. package/dist/server/utils.d.ts +2 -2
  34. package/dist/server/utils.js +4 -4
  35. package/package.json +9 -9
@@ -0,0 +1,7 @@
1
+ import '../../style/style.css';
2
+ interface ApprovalsSummaryProps {
3
+ value: any;
4
+ collectionName?: string;
5
+ }
6
+ export declare const ApprovalsSummary: (props: ApprovalsSummaryProps) => import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,14 @@
1
+ interface SummaryItem {
2
+ label: string;
3
+ value: string | number | null | undefined;
4
+ }
5
+ /**
6
+ * 处理 summary 数据,兼容新旧两种格式
7
+ * @param summary - 可能是旧格式的对象或新格式的数组
8
+ * @param collectionName - 集合名称
9
+ * @param cm - CollectionManager 实例
10
+ * @param compile - 编译函数
11
+ * @returns 统一格式的 summary 数组
12
+ */
13
+ export declare function processSummary(summary: any, collectionName: string, cm: any, compile: (value: any) => string): SummaryItem[];
14
+ export {};
@@ -1,2 +1,2 @@
1
1
  export declare const TabApprovalItem: import("react").MemoExoticComponent<import("@tachybase/schema").ReactFC<unknown>>;
2
- export declare const changeWorkflowNoticeService: (api: any, t: any, cm: any, compile: any, input: any, setData: any, params: any, filter: any, user: any) => void;
2
+ export declare const changeWorkflowNoticeService: (api: any, t: any, cm: any, compile: any, input: any, setData: any, params: any, filter: any, user: any, page: any, setTotal: any) => void;
@@ -5,3 +5,9 @@ export declare const COLLECTION_WORKFLOWS_NAME = "workflows";
5
5
  export declare const NAMESPACE = "workflow-approval";
6
6
  export declare const PLUGIN_NAME_APPROVAL = "approval";
7
7
  export declare const INSTRUCTION_TYPE_NAME_APPROVAL = "approval";
8
+ export declare const SUMMARY_TYPE: {
9
+ readonly LITERAL: "literal";
10
+ readonly TABLE: "table";
11
+ readonly DATE: "date";
12
+ readonly ARRAY: "array";
13
+ };
@@ -23,7 +23,8 @@ __export(constants_exports, {
23
23
  INSTRUCTION_TYPE_NAME_APPROVAL: () => INSTRUCTION_TYPE_NAME_APPROVAL,
24
24
  NAMESPACE: () => NAMESPACE,
25
25
  NOTICE_INSTRUCTION_NAMESPACE: () => NOTICE_INSTRUCTION_NAMESPACE,
26
- PLUGIN_NAME_APPROVAL: () => PLUGIN_NAME_APPROVAL
26
+ PLUGIN_NAME_APPROVAL: () => PLUGIN_NAME_APPROVAL,
27
+ SUMMARY_TYPE: () => SUMMARY_TYPE
27
28
  });
28
29
  module.exports = __toCommonJS(constants_exports);
29
30
  const NOTICE_INSTRUCTION_NAMESPACE = "notice";
@@ -33,6 +34,16 @@ const COLLECTION_WORKFLOWS_NAME = "workflows";
33
34
  const NAMESPACE = "workflow-approval";
34
35
  const PLUGIN_NAME_APPROVAL = "approval";
35
36
  const INSTRUCTION_TYPE_NAME_APPROVAL = "approval";
37
+ const SUMMARY_TYPE = {
38
+ LITERAL: "literal",
39
+ // 单个值
40
+ TABLE: "table",
41
+ // 表格
42
+ DATE: "date",
43
+ // 日期
44
+ ARRAY: "array"
45
+ // 数组
46
+ };
36
47
  // Annotate the CommonJS export names for ESM import in node:
37
48
  0 && (module.exports = {
38
49
  COLLECTION_NAME_APPROVAL_CARBON_COPY,
@@ -41,5 +52,6 @@ const INSTRUCTION_TYPE_NAME_APPROVAL = "approval";
41
52
  INSTRUCTION_TYPE_NAME_APPROVAL,
42
53
  NAMESPACE,
43
54
  NOTICE_INSTRUCTION_NAMESPACE,
44
- PLUGIN_NAME_APPROVAL
55
+ PLUGIN_NAME_APPROVAL,
56
+ SUMMARY_TYPE
45
57
  });
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+ var interface_d_exports = {};
15
+ module.exports = __toCommonJS(interface_d_exports);
@@ -0,0 +1,2 @@
1
+ export declare function isUTCString(str?: string): boolean;
2
+ export declare function isDateType(value: any): boolean;
@@ -0,0 +1,46 @@
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 utils_exports = {};
19
+ __export(utils_exports, {
20
+ isDateType: () => isDateType,
21
+ isUTCString: () => isUTCString
22
+ });
23
+ module.exports = __toCommonJS(utils_exports);
24
+ const utcRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
25
+ function isUTCString(str = "") {
26
+ return utcRegex.test(str);
27
+ }
28
+ function isDateType(value) {
29
+ if (typeof value !== "string") {
30
+ return false;
31
+ }
32
+ if (isUTCString(value)) {
33
+ return true;
34
+ }
35
+ const dateRegex = /^\d{4}-\d{2}-\d{2}/;
36
+ if (dateRegex.test(value)) {
37
+ const date = new Date(value);
38
+ return !isNaN(date.getTime());
39
+ }
40
+ return false;
41
+ }
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ isDateType,
45
+ isUTCString
46
+ });
@@ -1,16 +1,17 @@
1
1
  module.exports = {
2
- "@tachybase/client": "1.5.1",
3
- "@tachybase/module-workflow": "1.5.1",
4
- "@tego/server": "1.3.52",
2
+ "@tachybase/client": "1.6.1",
3
+ "@tego/server": "1.6.0-alpha.9",
4
+ "@tachybase/module-workflow": "1.6.1",
5
5
  "lodash": "4.17.21",
6
6
  "react": "18.3.1",
7
- "@tachybase/schema": "1.3.52",
7
+ "@tachybase/schema": "1.6.0-alpha.9",
8
8
  "antd": "5.22.5",
9
- "@tachybase/module-ui-schema": "1.5.1",
9
+ "@tachybase/module-ui-schema": "1.6.1",
10
10
  "sequelize": "6.37.5",
11
- "@tego/client": "1.3.52",
12
- "@ant-design/icons": "5.6.1",
11
+ "@tego/client": "1.6.0-alpha.9",
12
+ "react-i18next": "16.2.1",
13
+ "react-router-dom": "6.28.1",
14
+ "@ant-design/icons": "6.1.0",
13
15
  "dayjs": "1.11.13",
14
- "ahooks": "3.9.0",
15
- "react-router-dom": "6.28.1"
16
+ "ahooks": "3.9.0"
16
17
  };
@@ -183,6 +183,7 @@
183
183
  "Negotiation": "Negotiation",
184
184
  "Negotiation mode": "Negotiation mode",
185
185
  "New Initiate Request": "New Initiate Request",
186
+ "No data yet": "No data yet",
186
187
  "No end": "No end",
187
188
  "No limit": "No limit",
188
189
  "No repeat": "No repeat",
@@ -195,7 +196,7 @@
195
196
  "Notice Center": "Notice Center",
196
197
  "Notice blocks": "Notice blocks",
197
198
  "Null": "Null",
198
- "Off": "Off",
199
+ "Off": "Disabled",
199
200
  "On": "On",
200
201
  "On going": "On going",
201
202
  "Only support standard JSON data": "Only support standard JSON data",
@@ -285,6 +286,7 @@
285
286
  "Unprocessed": "Unprocessed",
286
287
  "Update record": "Update record",
287
288
  "Update record form": "Update record form",
289
+ "Updated time": "Updated time",
288
290
  "Usage of SQL query result is not supported yet.": "Usage of SQL query result is not supported yet.",
289
291
  "Use a collection to match form data.": "Use a collection to match form data.",
290
292
  "Use variable": "Use variable",
@@ -234,7 +234,7 @@
234
234
  "Notice": "通知",
235
235
  "Notice Center": "通知中心",
236
236
  "Notice blocks": "通知卡片",
237
- "Off": "停用",
237
+ "Off": "禁用",
238
238
  "On": "启用",
239
239
  "On going": "进行中",
240
240
  "Only support standard JSON data": "仅支持标准 JSON 数据",
@@ -357,6 +357,7 @@
357
357
  "Update record": "更新数据",
358
358
  "Update record form": "更新数据表单",
359
359
  "Update records of a collection. You can use variables from upstream nodes as query conditions and field values.": "更新一个数据表中的数据。可以使用上游节点里的变量作为查询条件和数据值。",
360
+ "Updated time": "更新时间",
360
361
  "Use transaction": "启用事务",
361
362
  "Use variable": "使用变量",
362
363
  "Used to store expressions for use in workflows so that different expressions can be called for different data.": "用于存储表达式,在工作流中使用,以便针对不同的数据调用不同的表达式。",
@@ -1,3 +1,3 @@
1
1
  export declare const approvalCarbonCopy: {
2
- listCentralized(context: any, next: any): Promise<void>;
2
+ listCentralized(ctx: any, next: any): Promise<void>;
3
3
  };
@@ -25,15 +25,15 @@ var import_server = require("@tego/server");
25
25
  var import_status = require("../constants/status");
26
26
  var import_utils = require("../utils");
27
27
  const approvalCarbonCopy = {
28
- async listCentralized(context, next) {
29
- const centralizedApprovalFlow = await context.db.getRepository(import_module_workflow.COLLECTION_WORKFLOWS_NAME).find({
28
+ async listCentralized(ctx, next) {
29
+ const centralizedApprovalFlow = await ctx.db.getRepository(import_module_workflow.COLLECTION_WORKFLOWS_NAME).find({
30
30
  filter: {
31
31
  type: "approval",
32
32
  "config.centralized": true
33
33
  },
34
34
  fields: ["id"]
35
35
  });
36
- context.action.mergeParams({
36
+ ctx.action.mergeParams({
37
37
  filter: {
38
38
  workflowId: centralizedApprovalFlow.map((item) => item.id),
39
39
  approval: {
@@ -43,10 +43,10 @@ const approvalCarbonCopy = {
43
43
  }
44
44
  }
45
45
  });
46
- await import_server.actions.list(context, next);
47
- if (context.body.rows) {
48
- context.body.rows = (0, import_utils.findUniqueObjects)(
49
- context.body.rows,
46
+ await import_server.actions.list(ctx, next);
47
+ if (ctx.body.rows) {
48
+ ctx.body.rows = (0, import_utils.findUniqueObjects)(
49
+ ctx.body.rows,
50
50
  ["userId", "approvalId"],
51
51
  "createdAt",
52
52
  (a, b) => new Date(a).getTime() - new Date(b).getTime()
@@ -1,4 +1,4 @@
1
1
  export declare const approvalRecords: {
2
- listCentralized(context: any, next: any): Promise<void>;
3
- submit(context: any, next: any): Promise<any>;
2
+ listCentralized(ctx: any, next: any): Promise<void>;
3
+ submit(ctx: any, next: any): Promise<any>;
4
4
  };
@@ -25,29 +25,29 @@ var import_server = require("@tego/server");
25
25
  var import_error_code = require("../constants/error-code");
26
26
  var import_status = require("../constants/status");
27
27
  const approvalRecords = {
28
- async listCentralized(context, next) {
29
- const centralizedApprovalFlow = await context.db.getRepository("workflows").find({
28
+ async listCentralized(ctx, next) {
29
+ const centralizedApprovalFlow = await ctx.db.getRepository("workflows").find({
30
30
  filter: {
31
31
  type: "approval",
32
32
  "config.centralized": true
33
33
  },
34
34
  fields: ["id"]
35
35
  });
36
- context.action.mergeParams({
36
+ ctx.action.mergeParams({
37
37
  filter: {
38
38
  workflowId: centralizedApprovalFlow.map((item) => item.id)
39
39
  }
40
40
  });
41
- return import_server.actions.list(context, next);
41
+ return import_server.actions.list(ctx, next);
42
42
  },
43
- async submit(context, next) {
43
+ async submit(ctx, next) {
44
44
  var _a, _b;
45
- const repository = import_server.utils.getRepositoryFromParams(context);
46
- const { filterByTk, values } = context.action.params;
45
+ const repository = import_server.utils.getRepositoryFromParams(ctx);
46
+ const { filterByTk, values } = ctx.action.params;
47
47
  const { data, status, needUpdateRecord } = values || {};
48
- const { currentUser } = context.state;
48
+ const { currentUser } = ctx.state;
49
49
  if (!currentUser) {
50
- return context.throw(401);
50
+ return ctx.throw(401);
51
51
  }
52
52
  const approvalRecord = await repository.findOne({
53
53
  filterByTk,
@@ -55,22 +55,22 @@ const approvalRecords = {
55
55
  userId: currentUser == null ? void 0 : currentUser.id
56
56
  },
57
57
  appends: ["job", "node", "execution", "workflow", "approval"],
58
- context
58
+ context: ctx
59
59
  });
60
60
  if (!approvalRecord) {
61
- return context.throw(404);
61
+ return ctx.throw(404);
62
62
  }
63
63
  switch (true) {
64
64
  // case !approvalRecord.workflow.enabled:
65
- // return context.throw(400, ERROR_CODE_MAP['not_enable_workflow']);
65
+ // return ctx.throw(400, ERROR_CODE_MAP['not_enable_workflow']);
66
66
  case ((_a = approvalRecord.execution) == null ? void 0 : _a.status):
67
- return context.throw(400, import_error_code.ERROR_CODE_MAP["execution_finished"]);
67
+ return ctx.throw(400, import_error_code.ERROR_CODE_MAP["execution_finished"]);
68
68
  case ((_b = approvalRecord.job) == null ? void 0 : _b.status):
69
- return context.throw(400, import_error_code.ERROR_CODE_MAP["job_finished"]);
69
+ return ctx.throw(400, import_error_code.ERROR_CODE_MAP["job_finished"]);
70
70
  case approvalRecord.status !== import_status.APPROVAL_ACTION_STATUS.PENDING:
71
- return context.throw(400, import_error_code.ERROR_CODE_MAP["not_approval_pending"]);
71
+ return ctx.throw(400, import_error_code.ERROR_CODE_MAP["not_approval_pending"]);
72
72
  case (!needUpdateRecord && !(approvalRecord.node.config.actions ?? []).includes(status)):
73
- return context.throw(400, import_error_code.ERROR_CODE_MAP["not_need_update"]);
73
+ return ctx.throw(400, import_error_code.ERROR_CODE_MAP["not_need_update"]);
74
74
  default:
75
75
  break;
76
76
  }
@@ -81,13 +81,13 @@ const approvalRecords = {
81
81
  summary: approvalRecord.approval.summary,
82
82
  collectionName: approvalRecord.approval.collectionName
83
83
  });
84
- context.body = approvalRecord.get();
85
- context.status = 202;
84
+ ctx.body = approvalRecord.get();
85
+ ctx.status = 202;
86
86
  await next();
87
87
  approvalRecord.execution.workflow = approvalRecord.workflow;
88
88
  approvalRecord.job.execution = approvalRecord.execution;
89
89
  approvalRecord.job.latestUserJob = approvalRecord.get();
90
- const workflow = context.app.getPlugin(import_module_workflow.PluginWorkflow);
90
+ const workflow = ctx.tego.pm.get(import_module_workflow.PluginWorkflow);
91
91
  const processor = workflow.createProcessor(approvalRecord.execution);
92
92
  processor.logger.info(
93
93
  `approval node (${approvalRecord.nodeId}) action trigger execution (${approvalRecord.execution.id}) to resume`
@@ -1,8 +1,8 @@
1
1
  export declare const approvals: {
2
- create(context: any, next: any): Promise<any>;
3
- update(context: any, next: any): Promise<void>;
4
- destroy(context: any, next: any): Promise<any>;
5
- withdraw(context: any, next: any): Promise<any>;
6
- listCentralized(context: any, next: any): Promise<void>;
7
- reminder(context: any, next: any): Promise<any>;
2
+ create(ctx: any, next: any): Promise<any>;
3
+ update(ctx: any, next: any): Promise<void>;
4
+ destroy(ctx: any, next: any): Promise<any>;
5
+ withdraw(ctx: any, next: any): Promise<any>;
6
+ listCentralized(ctx: any, next: any): Promise<void>;
7
+ reminder(ctx: any, next: any): Promise<any>;
8
8
  };