@tachybase/plugin-workflow-approval 0.23.8
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/.turbo/turbo-build.log +14 -0
- package/LICENSE +201 -0
- package/README.md +1 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/h5/ApprovalBlockInitializer.d.ts +8 -0
- package/dist/client/h5/ApprovalSettings.d.ts +2 -0
- package/dist/client/h5/collection/ApprovalTodos.d.ts +105 -0
- package/dist/client/h5/collection/Approvals.collection.d.ts +85 -0
- package/dist/client/h5/collection/FlowNodes.collection.d.ts +38 -0
- package/dist/client/h5/collection/UserJobs.collection.d.ts +141 -0
- package/dist/client/h5/collection/Workflows.collection.d.ts +30 -0
- package/dist/client/h5/collection/approvalCarbonCopy.collection.d.ts +156 -0
- package/dist/client/h5/collection/notice.collection.d.ts +131 -0
- package/dist/client/h5/component/ApprovalProcess.view.d.ts +2 -0
- package/dist/client/h5/component/ApprovalReachDataType.d.ts +2 -0
- package/dist/client/h5/component/ApprovalTemplateType.d.ts +2 -0
- package/dist/client/h5/constants.d.ts +159 -0
- package/dist/client/h5/context/ApprovalExecution.d.ts +3 -0
- package/dist/client/h5/context/FormBlock.d.ts +2 -0
- package/dist/client/h5/context/SchemaComponent.d.ts +5 -0
- package/dist/client/h5/context/WithActionEnabled.d.ts +3 -0
- package/dist/client/h5/index.d.ts +6 -0
- package/dist/client/h5/initiations/InitiationsBlock.d.ts +5 -0
- package/dist/client/h5/initiations/component/ApprovalItem.d.ts +2 -0
- package/dist/client/h5/initiations/component/ApprovalStatus.d.ts +2 -0
- package/dist/client/h5/initiations/component/InitiationsItem.d.ts +3 -0
- package/dist/client/h5/initiations/component/UserInitiationsItem.d.ts +3 -0
- package/dist/client/h5/initiations/component/ViewActionInitiationsContent.d.ts +10 -0
- package/dist/client/h5/initiations/component/ViewActionUserInitiationsContent.d.ts +3 -0
- package/dist/client/h5/initiations/config/LauncherActionConfig.d.ts +2 -0
- package/dist/client/h5/initiations/config/LauncherActionConfigComponent.d.ts +2 -0
- package/dist/client/h5/initiations/hook/useActionResubmit.d.ts +3 -0
- package/dist/client/h5/initiations/hook/useCreateSubmit.d.ts +3 -0
- package/dist/client/h5/initiations/hook/useDestroyAction.d.ts +3 -0
- package/dist/client/h5/initiations/hook/useFormBlockProps.d.ts +3 -0
- package/dist/client/h5/initiations/hook/useUpadteSubmit.d.ts +3 -0
- package/dist/client/h5/initiations/hook/useWithdrawAction.d.ts +3 -0
- package/dist/client/h5/initiations/provider/ActionBar.d.ts +1 -0
- package/dist/client/h5/initiations/provider/ActionResubmit.provider.d.ts +1 -0
- package/dist/client/h5/initiations/provider/ApplyActionStatus.d.ts +3 -0
- package/dist/client/h5/initiations/provider/Resubmit.provider.d.ts +10 -0
- package/dist/client/h5/initiations/provider/WithdrawAction.d.ts +3 -0
- package/dist/client/h5/locale.d.ts +7 -0
- package/dist/client/h5/todos/TodosBlock.d.ts +3 -0
- package/dist/client/h5/todos/component/TabApplicantType.d.ts +2 -0
- package/dist/client/h5/todos/component/TabApprovalItem.d.ts +3 -0
- package/dist/client/h5/todos/component/TabApprovalType.d.ts +2 -0
- package/dist/client/h5/todos/component/TabDuplicateItem.d.ts +3 -0
- package/dist/client/h5/todos/component/TabExecutedItem.d.ts +3 -0
- package/dist/client/h5/todos/component/TabPendingItem.d.ts +3 -0
- package/dist/client/h5/todos/component/TabProcessedItem.d.ts +3 -0
- package/dist/client/h5/todos/component/ViewActionTodosContent.d.ts +3 -0
- package/dist/client/h5/todos/component/ViewTodosDetailsContent.d.ts +2 -0
- package/dist/client/h5/todos/component/ViewTodosUserJobsContent.d.ts +6 -0
- package/dist/client/h5/todos/component/ViewTodosWorkflowNoticeContent.d.ts +3 -0
- package/dist/client/h5/todos/componentSchema.d.ts +32 -0
- package/dist/client/h5/todos/hook/useApprovalDetailBlockProps.d.ts +3 -0
- package/dist/client/h5/todos/hook/useApprovalFormBlockProps.d.ts +3 -0
- package/dist/client/h5/todos/hook/useDestroyAction.d.ts +3 -0
- package/dist/client/h5/todos/hook/useFormBlockProps.d.ts +9 -0
- package/dist/client/h5/todos/hook/usePropsNoticeDetail.d.ts +3 -0
- package/dist/client/h5/todos/hook/useSubmit.d.ts +6 -0
- package/dist/client/h5/todos/interface/interface.d.ts +139 -0
- package/dist/client/h5/todos/provider/ActionBarProvider.d.ts +3 -0
- package/dist/client/h5/todos/provider/ApplyActionStatus.d.ts +3 -0
- package/dist/client/h5/todos/provider/ApprovalAction.d.ts +9 -0
- package/dist/client/h5/todos/provider/ApprovalFormBlock.d.ts +2 -0
- package/dist/client/h5/todos/provider/FormBlockProvider.d.ts +2 -0
- package/dist/client/h5/todos/provider/ManualActionStatusProvider.d.ts +6 -0
- package/dist/client/h5/todos/provider/WithdrawAction.d.ts +3 -0
- package/dist/client/h5/todos/provider/todosContext.d.ts +2 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/index.js +183 -0
- package/dist/client/pc/collections/approvalCarbonCopy.d.ts +156 -0
- package/dist/client/pc/collections/approvalRecords.d.ts +131 -0
- package/dist/client/pc/collections/approvals.d.ts +109 -0
- package/dist/client/pc/collections/flowNodes.d.ts +38 -0
- package/dist/client/pc/collections/workflows.d.ts +41 -0
- package/dist/client/pc/common/FormBlock.provider.d.ts +2 -0
- package/dist/client/pc/configuration/Approval.setting.d.ts +8 -0
- package/dist/client/pc/configuration/ApprovalPane.component.d.ts +2 -0
- package/dist/client/pc/configuration/ApprovalPane.schema.d.ts +651 -0
- package/dist/client/pc/configuration/instruction-approval/Approval.node.d.ts +152 -0
- package/dist/client/pc/configuration/instruction-approval/ApprovalNode.component.d.ts +4 -0
- package/dist/client/pc/configuration/instruction-approval/ApproverConfig.context.d.ts +1 -0
- package/dist/client/pc/configuration/instruction-approval/approval-config/SkipApproval.schema.d.ts +14 -0
- package/dist/client/pc/configuration/instruction-approval/approval-config/SkipApproval.view.d.ts +2 -0
- package/dist/client/pc/configuration/instruction-approval/approval-config/VC.AssigneesAddition.d.ts +2 -0
- package/dist/client/pc/configuration/instruction-approval/approval-config/VC.AssigneesSelect.d.ts +2 -0
- package/dist/client/pc/configuration/instruction-approval/approval-config/VC.ContentTooltip.d.ts +5 -0
- package/dist/client/pc/configuration/instruction-approval/approval-config/VC.NegotiationConfig.d.ts +5 -0
- package/dist/client/pc/configuration/instruction-approval/approval-config/VC.SchemaConfigButtonApprover.d.ts +2 -0
- package/dist/client/pc/configuration/instruction-approval/approver-interface/ApprovalUpdateForm.provider.d.ts +1 -0
- package/dist/client/pc/configuration/instruction-approval/approver-interface/ApproverAddBlock.initializer.d.ts +2 -0
- package/dist/client/pc/configuration/instruction-approval/approver-interface/ApproverBlock.view.d.ts +5 -0
- package/dist/client/pc/configuration/instruction-approval/approver-interface/ApproverInterface.schema.d.ts +2 -0
- package/dist/client/pc/configuration/instruction-approval/approver-interface/Iz.ApproverActionConfig.d.ts +2 -0
- package/dist/client/pc/configuration/instruction-approval/approver-interface/Pd.ActionBarProvider.d.ts +1 -0
- package/dist/client/pc/configuration/instruction-approval/approver-interface/Pd.ApprovalActionProvider.d.ts +1 -0
- package/dist/client/pc/configuration/instruction-approval/approver-interface/Pd.SchemaConfigButtonContext.d.ts +1 -0
- package/dist/client/pc/configuration/instruction-approval/approver-interface/VC.ApprovalActionConfig.d.ts +2 -0
- package/dist/client/pc/configuration/instruction-approval/approver-interface/VC.ApprovalFormBlockProvider.d.ts +2 -0
- package/dist/client/pc/configuration/instruction-approval/approver-interface/VC.ApproverAddBlock.d.ts +2 -0
- package/dist/client/pc/configuration/instruction-approval/approver-interface/VC.ApproverAddBlockKit.d.ts +2 -0
- package/dist/client/pc/configuration/instruction-approval/approver-interface/useApprovalFormBlockProps.d.ts +3 -0
- package/dist/client/pc/configuration/instruction-approval/forms/AddActionButton.setting.d.ts +2 -0
- package/dist/client/pc/configuration/instruction-approval/forms/Approval.options.d.ts +42 -0
- package/dist/client/pc/configuration/instruction-approval/forms/FormBlock.factory.d.ts +6 -0
- package/dist/client/pc/configuration/instruction-approval/forms/update.d.ts +28 -0
- package/dist/client/pc/configuration/instruction-approval/kit.d.ts +5 -0
- package/dist/client/pc/configuration/instruction-approval/utils.d.ts +1 -0
- package/dist/client/pc/configuration/instruction-carbon-copy/ApprovalCarbonCopy.instruction.d.ts +76 -0
- package/dist/client/pc/configuration/instruction-carbon-copy/config-items/AddNotifiedPerson.view.d.ts +2 -0
- package/dist/client/pc/configuration/instruction-carbon-copy/config-items/ConfigButtonNotice.view.d.ts +2 -0
- package/dist/client/pc/configuration/instruction-carbon-copy/config-items/SelectNotifiedPerson.view.d.ts +2 -0
- package/dist/client/pc/configuration/instruction-carbon-copy/kit.d.ts +5 -0
- package/dist/client/pc/configuration/instruction-carbon-copy/show-interface/CarbonCopyDetail.block.d.ts +2 -0
- package/dist/client/pc/configuration/instruction-carbon-copy/show-interface/CarbonCopyDetail.initializer.d.ts +2 -0
- package/dist/client/pc/configuration/instruction-carbon-copy/show-interface/CarbonCopyDetail.schema.d.ts +6 -0
- package/dist/client/pc/configuration/instruction-carbon-copy/show-interface/CarbonCopyDetailContainer.schema.d.ts +2 -0
- package/dist/client/pc/configuration/instruction-carbon-copy/show-interface/style.d.ts +3 -0
- package/dist/client/pc/configuration/instruction-carbon-copy/style.d.ts +5 -0
- package/dist/client/pc/configuration/plugin.d.ts +5 -0
- package/dist/client/pc/configuration/trigger/Approval.trigger.d.ts +121 -0
- package/dist/client/pc/configuration/trigger/ConfigButton.view.d.ts +2 -0
- package/dist/client/pc/configuration/trigger/launcher-interface/LauncherActionConfig.component.d.ts +3 -0
- package/dist/client/pc/configuration/trigger/launcher-interface/LauncherActionConfig.initializer.d.ts +2 -0
- package/dist/client/pc/configuration/trigger/launcher-interface/LauncherAddBlockButton.initializer.d.ts +2 -0
- package/dist/client/pc/configuration/trigger/launcher-interface/LauncherBlockButton.component.d.ts +2 -0
- package/dist/client/pc/configuration/trigger/launcher-interface/LauncherInterface.schema.d.ts +2 -0
- package/dist/client/pc/configuration/trigger/launcher-interface/SchemaAddBlock.component.d.ts +5 -0
- package/dist/client/pc/configuration/trigger/plugin.d.ts +6 -0
- package/dist/client/pc/constants.d.ts +91 -0
- package/dist/client/pc/index.d.ts +5 -0
- package/dist/client/pc/locale.d.ts +7 -0
- package/dist/client/pc/usage/block/ApprovalBlock.initializer.d.ts +70 -0
- package/dist/client/pc/usage/block/BlockInitItem.provider.d.ts +5 -0
- package/dist/client/pc/usage/block/BlockInitItem.schema.d.ts +21 -0
- package/dist/client/pc/usage/block/BlockInitItem.view.d.ts +2 -0
- package/dist/client/pc/usage/block/InitiateApplication.component.d.ts +6 -0
- package/dist/client/pc/usage/block/carbon-copy/CarbonCopyBlock.provider.d.ts +5 -0
- package/dist/client/pc/usage/block/carbon-copy/CarbonCopyCenter.schema.d.ts +2 -0
- package/dist/client/pc/usage/block/common/ApprovalExecution.provider.d.ts +6 -0
- package/dist/client/pc/usage/block/common/FlowContext.provider.d.ts +6 -0
- package/dist/client/pc/usage/block/common/FuzzySearch.component.d.ts +2 -0
- package/dist/client/pc/usage/block/common/SchemaComponent.provider.d.ts +5 -0
- package/dist/client/pc/usage/block/common/useHandleRefresh.d.ts +3 -0
- package/dist/client/pc/usage/block/initiations/ApprovalStatus.context.d.ts +2 -0
- package/dist/client/pc/usage/block/initiations/CheckContent.component.d.ts +2 -0
- package/dist/client/pc/usage/block/initiations/CheckContent.provider.d.ts +2 -0
- package/dist/client/pc/usage/block/initiations/CheckContent.schema.d.ts +45 -0
- package/dist/client/pc/usage/block/initiations/CheckContent.view.d.ts +2 -0
- package/dist/client/pc/usage/block/initiations/CheckLink.schema.d.ts +24 -0
- package/dist/client/pc/usage/block/initiations/CheckLink.view.d.ts +2 -0
- package/dist/client/pc/usage/block/initiations/TableInitiated.d.ts +6 -0
- package/dist/client/pc/usage/block/initiations/TableInitiated.schema.d.ts +182 -0
- package/dist/client/pc/usage/block/initiations/WithdrawAction.provider.d.ts +3 -0
- package/dist/client/pc/usage/block/initiations/apply-button/ActionBar.provider.d.ts +1 -0
- package/dist/client/pc/usage/block/initiations/apply-button/ActionStatus.provider.d.ts +3 -0
- package/dist/client/pc/usage/block/initiations/apply-button/ActionWithdraw.provider.d.ts +1 -0
- package/dist/client/pc/usage/block/initiations/apply-button/ApplyButton.component.d.ts +2 -0
- package/dist/client/pc/usage/block/initiations/apply-button/ApplyButton.provider.d.ts +2 -0
- package/dist/client/pc/usage/block/initiations/apply-button/ApplyButton.view.d.ts +2 -0
- package/dist/client/pc/usage/block/initiations/apply-button/hooks/useActionResubmit.d.ts +3 -0
- package/dist/client/pc/usage/block/initiations/apply-button/hooks/useSubmitCreate.d.ts +3 -0
- package/dist/client/pc/usage/block/initiations/apply-button/hooks/useWithdrawAction.d.ts +3 -0
- package/dist/client/pc/usage/block/initiations/hooks/useActionResubmit.d.ts +3 -0
- package/dist/client/pc/usage/block/initiations/hooks/useDestroyAction.d.ts +3 -0
- package/dist/client/pc/usage/block/initiations/hooks/useFormBlockProps.d.ts +3 -0
- package/dist/client/pc/usage/block/initiations/hooks/useSubmitUpdate.d.ts +3 -0
- package/dist/client/pc/usage/block/initiations/hooks/useWithdrawAction.d.ts +3 -0
- package/dist/client/pc/usage/block/initiations/providers/ActionBar.provider.d.ts +1 -0
- package/dist/client/pc/usage/block/initiations/providers/ActionResubmit.provider.d.ts +1 -0
- package/dist/client/pc/usage/block/initiations/providers/ApplyActionStatus.provider.d.ts +2 -0
- package/dist/client/pc/usage/block/initiations/providers/Record.provider.d.ts +2 -0
- package/dist/client/pc/usage/block/plugin.d.ts +5 -0
- package/dist/client/pc/usage/block/todos/CheckContent.component.d.ts +2 -0
- package/dist/client/pc/usage/block/todos/CheckContent.provider.d.ts +2 -0
- package/dist/client/pc/usage/block/todos/CheckContent.schema.d.ts +40 -0
- package/dist/client/pc/usage/block/todos/CheckContent.view.d.ts +2 -0
- package/dist/client/pc/usage/block/todos/CheckLink.schema.d.ts +19 -0
- package/dist/client/pc/usage/block/todos/CheckLink.view.d.ts +2 -0
- package/dist/client/pc/usage/block/todos/TableTodos.d.ts +6 -0
- package/dist/client/pc/usage/block/todos/TableTodos.schema.d.ts +195 -0
- package/dist/client/pc/usage/block/todos/hooks/useApprovalDetailBlockProps.d.ts +3 -0
- package/dist/client/pc/usage/block/todos/hooks/useApprovalFormBlockProps.d.ts +3 -0
- package/dist/client/pc/usage/block/todos/hooks/useSubmit.d.ts +3 -0
- package/dist/client/pc/usage/block/todos/providers/ActionBar.provider.d.ts +2 -0
- package/dist/client/pc/usage/block/todos/providers/ApprovalAction.provider.d.ts +10 -0
- package/dist/client/pc/usage/block/todos/providers/ApprovalExecutions.provider.d.ts +28 -0
- package/dist/client/pc/usage/block/todos/providers/ApprovalFormBlock.provider.d.ts +2 -0
- package/dist/client/pc/usage/block/todos/providers/ApprovalUpdateForm.provider.d.ts +1 -0
- package/dist/client/pc/usage/common/ApprovalData.provider.d.ts +5 -0
- package/dist/client/pc/usage/common/ApprovalProcess.view.d.ts +2 -0
- package/dist/client/pc/usage/common/Resubmit.provider.d.ts +10 -0
- package/dist/client/pc/usage/common/WithActionEnabled.provider.d.ts +3 -0
- package/dist/client/pc/usage/common/approval-columns/approvalStatus.column.d.ts +3 -0
- package/dist/client/pc/usage/common/approval-columns/lastNode.column.d.ts +2 -0
- package/dist/client/pc/usage/common/approval-columns/node.column.d.ts +1 -0
- package/dist/client/pc/usage/common/approval-columns/status.column.d.ts +3 -0
- package/dist/client/pc/usage/common/approval-columns/summary.column.d.ts +2 -0
- package/dist/client/pc/usage/common/approval-columns/user.column.d.ts +1 -0
- package/dist/client/pc/usage/common/approval-columns/workflow.column.d.ts +2 -0
- package/dist/client/pc/usage/common/notice-columns/column.action.d.ts +2 -0
- package/dist/client/pc/usage/common/notice-columns/column.node.d.ts +1 -0
- package/dist/client/pc/usage/common/notice-columns/column.status.d.ts +8 -0
- package/dist/client/pc/usage/common/notice-columns/column.user.d.ts +1 -0
- package/dist/client/pc/usage/common/notice-columns/column.workflow.d.ts +2 -0
- package/dist/client/pc/usage/common/notice-show-detail/NoticeDetail.provider.d.ts +5 -0
- package/dist/client/pc/usage/common/notice-show-detail/NoticeDetail.schema.d.ts +2 -0
- package/dist/client/pc/usage/common/notice-show-detail/contexts/MyComponent.context.d.ts +9 -0
- package/dist/client/pc/usage/common/notice-show-detail/contexts/WorkflowNotice.context.d.ts +4 -0
- package/dist/client/pc/usage/common/notice-show-detail/hooks/usePropsNoticeDetail.d.ts +3 -0
- package/dist/client/pc/usage/common/plugin.d.ts +4 -0
- package/dist/client/pc/usage/common/process-columns/index.d.ts +44 -0
- package/dist/client/pc/usage/common/process-columns/renderDetail.d.ts +2 -0
- package/dist/client/pc/usage/common/process-columns/renderStatus.d.ts +2 -0
- package/dist/client/pc/usage/common/process-columns/renderTaskNode.d.ts +2 -0
- package/dist/client/pc/usage/common/style.d.ts +4 -0
- package/dist/client/pc/usage/common/tools.d.ts +1 -0
- package/dist/client/pc/usage/plugin.d.ts +5 -0
- package/dist/client/pc/usage/record-block/RecordApprovals.decorator.d.ts +5 -0
- package/dist/client/pc/usage/record-block/RecordApprovals.initializer.d.ts +2 -0
- package/dist/client/pc/usage/record-block/RecordApprovals.schema.d.ts +110 -0
- package/dist/client/pc/usage/record-block/RecordApprovals.view.d.ts +2 -0
- package/dist/client/pc/usage/record-block/plugin.d.ts +6 -0
- package/dist/common/collection-name.d.ts +4 -0
- package/dist/common/collection-name.js +36 -0
- package/dist/externalVersion.js +19 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +39 -0
- package/dist/locale/en-US.json +311 -0
- package/dist/locale/zh-CN.json +388 -0
- package/dist/server/actions/approvalCarbonCopy.d.ts +3 -0
- package/dist/server/actions/approvalCarbonCopy.js +71 -0
- package/dist/server/actions/approvalRecords.d.ts +4 -0
- package/dist/server/actions/approvalRecords.js +111 -0
- package/dist/server/actions/approvals.d.ts +8 -0
- package/dist/server/actions/approvals.js +275 -0
- package/dist/server/actions/index.d.ts +3 -0
- package/dist/server/actions/index.js +48 -0
- package/dist/server/actions/workflows.d.ts +3 -0
- package/dist/server/actions/workflows.js +49 -0
- package/dist/server/collections/approvalCarbonCopy.d.ts +2 -0
- package/dist/server/collections/approvalCarbonCopy.js +87 -0
- package/dist/server/collections/approvalExecutions.d.ts +2 -0
- package/dist/server/collections/approvalExecutions.js +70 -0
- package/dist/server/collections/approvalRecords.d.ts +2 -0
- package/dist/server/collections/approvalRecords.js +88 -0
- package/dist/server/collections/approvals.d.ts +2 -0
- package/dist/server/collections/approvals.js +96 -0
- package/dist/server/constants/error-code.d.ts +22 -0
- package/dist/server/constants/error-code.js +48 -0
- package/dist/server/constants/status.d.ts +20 -0
- package/dist/server/constants/status.js +46 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +33 -0
- package/dist/server/instructions/Approval.d.ts +9 -0
- package/dist/server/instructions/Approval.js +220 -0
- package/dist/server/instructions/ApprovalCarbonCopy.d.ts +8 -0
- package/dist/server/instructions/ApprovalCarbonCopy.js +99 -0
- package/dist/server/instructions/tools.d.ts +11 -0
- package/dist/server/instructions/tools.js +139 -0
- package/dist/server/plugin.d.ts +12 -0
- package/dist/server/plugin.js +89 -0
- package/dist/server/tools.d.ts +11 -0
- package/dist/server/tools.js +70 -0
- package/dist/server/triggers/Approval.d.ts +23 -0
- package/dist/server/triggers/Approval.js +313 -0
- package/dist/server/triggers/tools.d.ts +12 -0
- package/dist/server/triggers/tools.js +44 -0
- package/dist/server/utils.d.ts +1 -0
- package/dist/server/utils.js +39 -0
- package/package.json +45 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,139 @@
|
|
|
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 tools_exports = {};
|
|
19
|
+
__export(tools_exports, {
|
|
20
|
+
ApprovalJobStatusMap: () => ApprovalJobStatusMap,
|
|
21
|
+
getNegotiationMode: () => getNegotiationMode,
|
|
22
|
+
parseAssignees: () => parseAssignees
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(tools_exports);
|
|
25
|
+
var import_module_workflow = require("@tachybase/module-workflow");
|
|
26
|
+
var import_status = require("../constants/status");
|
|
27
|
+
const NEGOTIATION_MODE = {
|
|
28
|
+
SINGLE: Symbol("single"),
|
|
29
|
+
ALL: Symbol("all"),
|
|
30
|
+
ANY: Symbol("any"),
|
|
31
|
+
PERCENTAGE: Symbol("percentage")
|
|
32
|
+
};
|
|
33
|
+
const JobStatusMap = {
|
|
34
|
+
[import_status.APPROVAL_ACTION_STATUS.PENDING]: import_module_workflow.JOB_STATUS.PENDING,
|
|
35
|
+
[import_status.APPROVAL_ACTION_STATUS.APPROVED]: import_module_workflow.JOB_STATUS.RESOLVED,
|
|
36
|
+
[import_status.APPROVAL_ACTION_STATUS.REJECTED]: import_module_workflow.JOB_STATUS.REJECTED,
|
|
37
|
+
[import_status.APPROVAL_ACTION_STATUS.RETURNED]: import_module_workflow.JOB_STATUS.RETRY_NEEDED
|
|
38
|
+
};
|
|
39
|
+
const ApprovalJobStatusMap = {
|
|
40
|
+
[import_module_workflow.JOB_STATUS.PENDING]: import_status.APPROVAL_ACTION_STATUS.PENDING,
|
|
41
|
+
[import_module_workflow.JOB_STATUS.RESOLVED]: import_status.APPROVAL_ACTION_STATUS.APPROVED,
|
|
42
|
+
[import_module_workflow.JOB_STATUS.REJECTED]: import_status.APPROVAL_ACTION_STATUS.REJECTED,
|
|
43
|
+
[import_module_workflow.JOB_STATUS.RETRY_NEEDED]: import_status.APPROVAL_ACTION_STATUS.RETURNED,
|
|
44
|
+
[import_module_workflow.JOB_STATUS.CANCELED]: import_status.APPROVAL_ACTION_STATUS.CANCELED
|
|
45
|
+
};
|
|
46
|
+
const Modes = {
|
|
47
|
+
[NEGOTIATION_MODE.SINGLE]: {
|
|
48
|
+
getStatus(distribution, assignees, mode) {
|
|
49
|
+
const done = distribution.find((item) => item.status !== import_status.APPROVAL_ACTION_STATUS.PENDING && item.count > 0);
|
|
50
|
+
return done ? JobStatusMap[done.status] : null;
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
[NEGOTIATION_MODE.ALL]: {
|
|
54
|
+
getStatus(distribution, assignees, mode) {
|
|
55
|
+
const rejected = distribution.find(
|
|
56
|
+
(item) => [import_status.APPROVAL_ACTION_STATUS.REJECTED, import_status.APPROVAL_ACTION_STATUS.RETURNED].includes(item.status)
|
|
57
|
+
);
|
|
58
|
+
if (rejected && rejected.count) {
|
|
59
|
+
return JobStatusMap[rejected.status];
|
|
60
|
+
}
|
|
61
|
+
const approved = distribution.find((item) => item.status === import_status.APPROVAL_ACTION_STATUS.APPROVED);
|
|
62
|
+
if (approved && approved.count === assignees.length) {
|
|
63
|
+
return import_module_workflow.JOB_STATUS.RESOLVED;
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
[NEGOTIATION_MODE.ANY]: {
|
|
69
|
+
getStatus(distribution, assignees, mode) {
|
|
70
|
+
const returned = distribution.find((item) => item.status === import_status.APPROVAL_ACTION_STATUS.RETURNED);
|
|
71
|
+
if (returned && returned.count) {
|
|
72
|
+
return import_module_workflow.JOB_STATUS.RETRY_NEEDED;
|
|
73
|
+
}
|
|
74
|
+
const approved = distribution.find((item) => item.status === import_status.APPROVAL_ACTION_STATUS.APPROVED);
|
|
75
|
+
if (approved && approved.count) {
|
|
76
|
+
return import_status.APPROVAL_ACTION_STATUS.APPROVED;
|
|
77
|
+
}
|
|
78
|
+
const rejectedCount = distribution.reduce(
|
|
79
|
+
(count, item) => item.status === import_status.APPROVAL_ACTION_STATUS.REJECTED ? count + item.count : count,
|
|
80
|
+
0
|
|
81
|
+
);
|
|
82
|
+
if (rejectedCount === assignees.length) {
|
|
83
|
+
return import_module_workflow.JOB_STATUS.REJECTED;
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
[NEGOTIATION_MODE.PERCENTAGE]: {
|
|
89
|
+
getStatus(distribution, assignees, mode) {
|
|
90
|
+
const returned = distribution.find((item) => item.status === import_status.APPROVAL_ACTION_STATUS.RETURNED);
|
|
91
|
+
if (returned && returned.count) {
|
|
92
|
+
return import_module_workflow.JOB_STATUS.RETRY_NEEDED;
|
|
93
|
+
}
|
|
94
|
+
const approved = distribution.find((item) => item.status === import_status.APPROVAL_ACTION_STATUS.APPROVED);
|
|
95
|
+
if (approved && approved.count / assignees.length > mode) {
|
|
96
|
+
return import_module_workflow.JOB_STATUS.RESOLVED;
|
|
97
|
+
}
|
|
98
|
+
const rejected = distribution.find((item) => item.status === import_status.APPROVAL_ACTION_STATUS.REJECTED);
|
|
99
|
+
if (rejected && rejected.count / assignees.length >= 1 - mode) {
|
|
100
|
+
return import_module_workflow.JOB_STATUS.REJECTED;
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
function getNegotiationMode(mode) {
|
|
107
|
+
switch (true) {
|
|
108
|
+
case mode === 1:
|
|
109
|
+
return Modes[NEGOTIATION_MODE.ALL];
|
|
110
|
+
case (0 < mode && mode < 1):
|
|
111
|
+
return Modes[NEGOTIATION_MODE.PERCENTAGE];
|
|
112
|
+
default:
|
|
113
|
+
return Modes[NEGOTIATION_MODE.SINGLE];
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async function parseAssignees(node, processor) {
|
|
117
|
+
const configAssignees = processor.getParsedValue(node.config.assignees ?? [], node.id).flat().filter(Boolean);
|
|
118
|
+
const assignees = /* @__PURE__ */ new Set();
|
|
119
|
+
const UserRepo = processor.options.plugin.app.db.getRepository("users");
|
|
120
|
+
for (const item of configAssignees) {
|
|
121
|
+
if (typeof item === "object") {
|
|
122
|
+
const result = await UserRepo.find({
|
|
123
|
+
...item,
|
|
124
|
+
fields: ["id"],
|
|
125
|
+
transaction: processor.transaction
|
|
126
|
+
});
|
|
127
|
+
result.forEach((item2) => assignees.add(item2.id));
|
|
128
|
+
} else {
|
|
129
|
+
assignees.add(item);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return [...assignees];
|
|
133
|
+
}
|
|
134
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
135
|
+
0 && (module.exports = {
|
|
136
|
+
ApprovalJobStatusMap,
|
|
137
|
+
getNegotiationMode,
|
|
138
|
+
parseAssignees
|
|
139
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Plugin } from '@tachybase/server';
|
|
2
|
+
export declare class PluginWorkflowApproval extends Plugin {
|
|
3
|
+
workflow: any;
|
|
4
|
+
afterAdd(): void;
|
|
5
|
+
beforeLoad(): void;
|
|
6
|
+
load(): Promise<void>;
|
|
7
|
+
install(options: any): Promise<void>;
|
|
8
|
+
afterEnable(): Promise<void>;
|
|
9
|
+
afterDisable(): Promise<void>;
|
|
10
|
+
remove(): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export default PluginWorkflowApproval;
|
|
@@ -0,0 +1,89 @@
|
|
|
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 plugin_exports = {};
|
|
29
|
+
__export(plugin_exports, {
|
|
30
|
+
PluginWorkflowApproval: () => PluginWorkflowApproval,
|
|
31
|
+
default: () => plugin_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
34
|
+
var import_path = __toESM(require("path"));
|
|
35
|
+
var import_module_workflow = require("@tachybase/module-workflow");
|
|
36
|
+
var import_server = require("@tachybase/server");
|
|
37
|
+
var import_collection_name = require("../common/collection-name");
|
|
38
|
+
var import_actions = require("./actions");
|
|
39
|
+
var import_Approval = __toESM(require("./instructions/Approval"));
|
|
40
|
+
var import_ApprovalCarbonCopy = __toESM(require("./instructions/ApprovalCarbonCopy"));
|
|
41
|
+
var import_Approval2 = __toESM(require("./triggers/Approval"));
|
|
42
|
+
class PluginWorkflowApproval extends import_server.Plugin {
|
|
43
|
+
workflow;
|
|
44
|
+
afterAdd() {
|
|
45
|
+
}
|
|
46
|
+
beforeLoad() {
|
|
47
|
+
this.app.on("afterLoadPlugin", (plugin) => {
|
|
48
|
+
if (!(plugin instanceof import_module_workflow.PluginWorkflow)) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
this.workflow = plugin;
|
|
52
|
+
plugin.triggers.register("approval", new import_Approval2.default(plugin));
|
|
53
|
+
plugin.instructions.register("approval", new import_Approval.default(plugin));
|
|
54
|
+
plugin.instructions.register(import_collection_name.COLLECTION_NAME_APPROVAL_CARBON_COPY, new import_ApprovalCarbonCopy.default(plugin));
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async load() {
|
|
58
|
+
const { db } = this;
|
|
59
|
+
db.addMigrations({
|
|
60
|
+
namespace: "approval",
|
|
61
|
+
directory: import_path.default.resolve(__dirname, "migrations"),
|
|
62
|
+
context: {
|
|
63
|
+
plugin: this
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
await db.import({
|
|
67
|
+
directory: import_path.default.resolve(__dirname, "collections")
|
|
68
|
+
});
|
|
69
|
+
(0, import_actions.init)(this);
|
|
70
|
+
this.app.acl.allow("workflows", ["listApprovalFlows"], "loggedIn");
|
|
71
|
+
this.app.acl.allow("approvals", "*", "loggedIn");
|
|
72
|
+
this.app.acl.allow("approvalExecutions", ["get"], "loggedIn");
|
|
73
|
+
this.app.acl.allow("approvalRecords", ["get", "list", "listCentralized", "submit"], "loggedIn");
|
|
74
|
+
this.app.acl.allow(import_collection_name.COLLECTION_NAME_APPROVAL_CARBON_COPY, ["get", "list", "listCentralized", "submit"], "loggedIn");
|
|
75
|
+
}
|
|
76
|
+
async install(options) {
|
|
77
|
+
}
|
|
78
|
+
async afterEnable() {
|
|
79
|
+
}
|
|
80
|
+
async afterDisable() {
|
|
81
|
+
}
|
|
82
|
+
async remove() {
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
var plugin_default = PluginWorkflowApproval;
|
|
86
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
87
|
+
0 && (module.exports = {
|
|
88
|
+
PluginWorkflowApproval
|
|
89
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface ParamsType {
|
|
2
|
+
summaryConfig: Array<string>;
|
|
3
|
+
data: object;
|
|
4
|
+
}
|
|
5
|
+
export declare function getSummary(params: ParamsType): object;
|
|
6
|
+
export declare function parsePerson({ node, processor, keyName }: {
|
|
7
|
+
node: any;
|
|
8
|
+
processor: any;
|
|
9
|
+
keyName: any;
|
|
10
|
+
}): Promise<unknown[]>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
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 tools_exports = {};
|
|
29
|
+
__export(tools_exports, {
|
|
30
|
+
getSummary: () => getSummary,
|
|
31
|
+
parsePerson: () => parsePerson
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(tools_exports);
|
|
34
|
+
var import_lodash = __toESM(require("lodash"));
|
|
35
|
+
function getSummary(params) {
|
|
36
|
+
const { summaryConfig = [], data } = params;
|
|
37
|
+
const result = summaryConfig.reduce((summary, key) => {
|
|
38
|
+
const value = import_lodash.default.get(data, key);
|
|
39
|
+
const realValue = Object.prototype.toString.call(value) === "[object Object]" ? value == null ? void 0 : value["name"] : value;
|
|
40
|
+
return {
|
|
41
|
+
...summary,
|
|
42
|
+
[key]: realValue
|
|
43
|
+
};
|
|
44
|
+
}, {});
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
async function parsePerson({ node, processor, keyName }) {
|
|
48
|
+
var _a;
|
|
49
|
+
const configPerson = processor.getParsedValue(((_a = node.config) == null ? void 0 : _a[keyName]) ?? [], node.id).flat().filter(Boolean);
|
|
50
|
+
const targetPerson = /* @__PURE__ */ new Set();
|
|
51
|
+
const UserRepo = processor.options.plugin.app.db.getRepository("users");
|
|
52
|
+
for (const item of configPerson) {
|
|
53
|
+
if (typeof item === "object") {
|
|
54
|
+
const users = await UserRepo.find({
|
|
55
|
+
...item,
|
|
56
|
+
fields: ["id"],
|
|
57
|
+
transaction: processor.transaction
|
|
58
|
+
});
|
|
59
|
+
users.forEach((userData) => targetPerson.add(userData.id));
|
|
60
|
+
} else {
|
|
61
|
+
targetPerson.add(item);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return [...targetPerson];
|
|
65
|
+
}
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
getSummary,
|
|
69
|
+
parsePerson
|
|
70
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Trigger } from '@tachybase/module-workflow';
|
|
2
|
+
export default class ApprovalTrigger extends Trigger {
|
|
3
|
+
static TYPE: string;
|
|
4
|
+
sync: boolean;
|
|
5
|
+
triggerHandler: (approval: any, { transaction }: {
|
|
6
|
+
transaction: any;
|
|
7
|
+
}) => Promise<void>;
|
|
8
|
+
onExecutionCreate: (execution: any, { transaction }: {
|
|
9
|
+
transaction: any;
|
|
10
|
+
}) => Promise<void>;
|
|
11
|
+
onExecutionUpdate: (execution: any, { transaction }: {
|
|
12
|
+
transaction: any;
|
|
13
|
+
}) => Promise<void>;
|
|
14
|
+
middleware: (context: any, next: any) => Promise<any>;
|
|
15
|
+
constructor(workflow: any);
|
|
16
|
+
workflowTriggerAction(context: any, next: any): Promise<any>;
|
|
17
|
+
collectionTriggerAction(context: any): Promise<void>;
|
|
18
|
+
on(workflow: any): void;
|
|
19
|
+
off(workflow: any): void;
|
|
20
|
+
duplicateConfig(workflow: any, { transaction }: {
|
|
21
|
+
transaction: any;
|
|
22
|
+
}): Promise<any>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,313 @@
|
|
|
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 Approval_exports = {};
|
|
19
|
+
__export(Approval_exports, {
|
|
20
|
+
default: () => ApprovalTrigger
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(Approval_exports);
|
|
23
|
+
var import_data_source = require("@tachybase/data-source");
|
|
24
|
+
var import_database = require("@tachybase/database");
|
|
25
|
+
var import_module_workflow = require("@tachybase/module-workflow");
|
|
26
|
+
var import_lodash = require("lodash");
|
|
27
|
+
var import_sequelize = require("sequelize");
|
|
28
|
+
var import_status = require("../constants/status");
|
|
29
|
+
var import_tools = require("../tools");
|
|
30
|
+
var import_tools2 = require("./tools");
|
|
31
|
+
class ApprovalTrigger extends import_module_workflow.Trigger {
|
|
32
|
+
static TYPE = "approval";
|
|
33
|
+
sync = false;
|
|
34
|
+
triggerHandler = async (approval, { transaction }) => {
|
|
35
|
+
const workflow = await approval.getWorkflow({
|
|
36
|
+
where: {
|
|
37
|
+
id: approval.get("workflowId"),
|
|
38
|
+
type: ApprovalTrigger.TYPE,
|
|
39
|
+
enabled: true,
|
|
40
|
+
"config.collection": approval.collectionName
|
|
41
|
+
},
|
|
42
|
+
transaction
|
|
43
|
+
});
|
|
44
|
+
const isChangedStatus = approval.changed("status");
|
|
45
|
+
const isAllowStatusList = [import_status.APPROVAL_STATUS.DRAFT, import_status.APPROVAL_STATUS.SUBMITTED, import_status.APPROVAL_STATUS.RESUBMIT].includes(
|
|
46
|
+
approval.status
|
|
47
|
+
);
|
|
48
|
+
const previousApprovalStatus = approval.previous("status");
|
|
49
|
+
const currentApprovalStatus = approval.status;
|
|
50
|
+
const forbiddenList = [[import_status.APPROVAL_STATUS.SUBMITTED, import_status.APPROVAL_STATUS.DRAFT]];
|
|
51
|
+
const isForbiddenWhenStatusChange = forbiddenList.some(
|
|
52
|
+
([prev, curr]) => prev === previousApprovalStatus && curr === currentApprovalStatus
|
|
53
|
+
);
|
|
54
|
+
if (!workflow || !isChangedStatus || !isAllowStatusList || isForbiddenWhenStatusChange) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const [dataSourceName, collectionName] = (0, import_data_source.parseCollectionName)(approval.collectionName);
|
|
58
|
+
const { repository } = this.workflow.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager.getCollection(collectionName);
|
|
59
|
+
const data = await repository.findOne({
|
|
60
|
+
filterByTk: approval.get("dataKey"),
|
|
61
|
+
appends: workflow.config.appends,
|
|
62
|
+
transaction: this.workflow.useDataSourceTransaction(dataSourceName, transaction)
|
|
63
|
+
});
|
|
64
|
+
this.workflow.trigger(
|
|
65
|
+
workflow,
|
|
66
|
+
{
|
|
67
|
+
data: (0, import_module_workflow.toJSON)(data),
|
|
68
|
+
approvalId: approval.id,
|
|
69
|
+
applicantRoleName: approval.applicantRoleName,
|
|
70
|
+
summary: (0, import_tools.getSummary)({
|
|
71
|
+
summaryConfig: workflow.config.summary,
|
|
72
|
+
data
|
|
73
|
+
}),
|
|
74
|
+
collectionName: approval.collectionName
|
|
75
|
+
},
|
|
76
|
+
{ transaction }
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
onExecutionCreate = async (execution, { transaction }) => {
|
|
80
|
+
const workflow = await execution.getWorkflow({ transaction });
|
|
81
|
+
if (workflow.type !== ApprovalTrigger.TYPE) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const { approvalId, data, summary, collectionName } = execution.context;
|
|
85
|
+
const ApprovalExecutionRepo = this.workflow.db.getRepository("approvalExecutions");
|
|
86
|
+
const approvalExecution = await ApprovalExecutionRepo.create({
|
|
87
|
+
values: {
|
|
88
|
+
approvalId,
|
|
89
|
+
executionId: execution.id,
|
|
90
|
+
status: execution.status,
|
|
91
|
+
snapshot: data,
|
|
92
|
+
summary,
|
|
93
|
+
collectionName
|
|
94
|
+
},
|
|
95
|
+
transaction
|
|
96
|
+
});
|
|
97
|
+
const ApprovalsRepo = this.workflow.db.getRepository("approvals");
|
|
98
|
+
await ApprovalsRepo.update({
|
|
99
|
+
filterByTk: approvalId,
|
|
100
|
+
values: { latestExecutionId: approvalExecution.id },
|
|
101
|
+
transaction
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
onExecutionUpdate = async (execution, { transaction }) => {
|
|
105
|
+
if (!execution.workflow) {
|
|
106
|
+
execution.workflow = await execution.getWorkflow({ transaction });
|
|
107
|
+
}
|
|
108
|
+
if (!execution.status || execution.workflow.type !== ApprovalTrigger.TYPE) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const approvalExecution = await this.workflow.db.getRepository("approvalExecutions").findOne({
|
|
112
|
+
filter: {
|
|
113
|
+
executionId: execution.id,
|
|
114
|
+
approvalId: execution.context.approvalId
|
|
115
|
+
},
|
|
116
|
+
appends: ["approval"],
|
|
117
|
+
transaction
|
|
118
|
+
});
|
|
119
|
+
const { approval } = approvalExecution;
|
|
120
|
+
if (![import_status.APPROVAL_STATUS.SUBMITTED, import_status.APPROVAL_STATUS.PROCESSING].includes(approval.status)) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
let status = import_status.APPROVAL_STATUS.APPROVED;
|
|
124
|
+
if (execution.status === import_module_workflow.EXECUTION_STATUS.RESOLVED) {
|
|
125
|
+
const [approvalNodeJob] = await execution.getJobs({
|
|
126
|
+
where: {
|
|
127
|
+
status: {
|
|
128
|
+
[import_sequelize.Op.ne]: import_module_workflow.JOB_STATUS.PENDING
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
include: [
|
|
132
|
+
{
|
|
133
|
+
association: "node",
|
|
134
|
+
where: {
|
|
135
|
+
type: "approval"
|
|
136
|
+
},
|
|
137
|
+
required: true
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
order: [["updatedAt", "DESC"]],
|
|
141
|
+
limit: 1,
|
|
142
|
+
transaction
|
|
143
|
+
});
|
|
144
|
+
if (approvalNodeJob && import_tools2.ApprovalJobStatusMap[approvalNodeJob.result] != null) {
|
|
145
|
+
status = import_tools2.ApprovalJobStatusMap[approvalNodeJob.result];
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
if (import_tools2.ExecutionStatusMap[execution.status] != null) {
|
|
149
|
+
status = import_tools2.ExecutionStatusMap[execution.status];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
await approval.update({ status }, { transaction });
|
|
153
|
+
await approvalExecution.update({ status: execution.status }, { transaction });
|
|
154
|
+
};
|
|
155
|
+
middleware = async (context, next) => {
|
|
156
|
+
if (!context.action) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const {
|
|
160
|
+
resourceName,
|
|
161
|
+
actionName,
|
|
162
|
+
params: { triggerWorkflows }
|
|
163
|
+
} = context.action;
|
|
164
|
+
if (resourceName === "workflows" && actionName === "trigger") {
|
|
165
|
+
return this.workflowTriggerAction(context, next);
|
|
166
|
+
}
|
|
167
|
+
await next();
|
|
168
|
+
if (!triggerWorkflows || !["create", "update"].includes(actionName)) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
this.collectionTriggerAction(context);
|
|
172
|
+
};
|
|
173
|
+
constructor(workflow) {
|
|
174
|
+
super(workflow);
|
|
175
|
+
const { db } = workflow.app;
|
|
176
|
+
db.on("approvals.afterSave", this.triggerHandler);
|
|
177
|
+
db.on("executions.afterCreate", this.onExecutionCreate);
|
|
178
|
+
db.on("executions.afterUpdate", this.onExecutionUpdate);
|
|
179
|
+
workflow.app.use(this.middleware, { tag: "workflow-trigger", after: "dataSource" });
|
|
180
|
+
}
|
|
181
|
+
async workflowTriggerAction(context, next) {
|
|
182
|
+
const { triggerWorkflows, values } = context.action.params;
|
|
183
|
+
if (!triggerWorkflows) {
|
|
184
|
+
return context.throw(400);
|
|
185
|
+
}
|
|
186
|
+
const triggers = triggerWorkflows.split(",").map((trigger) => trigger.split("!"));
|
|
187
|
+
const workflowRepo = this.workflow.db.getRepository("workflows");
|
|
188
|
+
const workflows = await workflowRepo.find({
|
|
189
|
+
filter: {
|
|
190
|
+
type: ApprovalTrigger.TYPE,
|
|
191
|
+
key: triggers.map((trigger) => trigger[0]),
|
|
192
|
+
current: true,
|
|
193
|
+
enabled: true
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
context.status = 202;
|
|
197
|
+
await next();
|
|
198
|
+
workflows.forEach(async (workflow) => {
|
|
199
|
+
const trigger = triggers.find((trigger2) => trigger2[0] === workflow.key);
|
|
200
|
+
const [dataSourceName, collectionName] = (0, import_data_source.parseCollectionName)(workflow.config.collection);
|
|
201
|
+
const collecton = this.workflow.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager.getCollection(collectionName);
|
|
202
|
+
const data = await collecton.repository.create({
|
|
203
|
+
values: {
|
|
204
|
+
...trigger[1] ? (0, import_lodash.get)(values, trigger[1]) : values
|
|
205
|
+
// createdBy: currentUser.id,
|
|
206
|
+
// updatedById: currentUser.id,
|
|
207
|
+
},
|
|
208
|
+
context
|
|
209
|
+
});
|
|
210
|
+
const approvalRepo = this.workflow.db.getRepository("approvals");
|
|
211
|
+
await approvalRepo.create({
|
|
212
|
+
values: {
|
|
213
|
+
collectionName: workflow.config.collection,
|
|
214
|
+
data: (0, import_module_workflow.toJSON)(data),
|
|
215
|
+
dataKey: data.get(collecton.filterTargetKey),
|
|
216
|
+
status: import_status.APPROVAL_STATUS.SUBMITTED,
|
|
217
|
+
// createdBy: currentUser.id,
|
|
218
|
+
// updatedById: currentUser.id,
|
|
219
|
+
workflowId: workflow.id,
|
|
220
|
+
workflowKey: workflow.key,
|
|
221
|
+
summary: (0, import_tools.getSummary)({
|
|
222
|
+
summaryConfig: workflow.config.summary,
|
|
223
|
+
data
|
|
224
|
+
})
|
|
225
|
+
},
|
|
226
|
+
context
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
async collectionTriggerAction(context) {
|
|
231
|
+
const { triggerWorkflows = "" } = context.action.params;
|
|
232
|
+
const dataSourceHeader = context.get("x-data-source") || "main";
|
|
233
|
+
const approvalRepo = this.workflow.db.getRepository("approvals");
|
|
234
|
+
const triggers = triggerWorkflows.split(",").map((trigger) => trigger.split("!"));
|
|
235
|
+
const triggersKeysMap = new Map(triggers);
|
|
236
|
+
const workflows = Array.from(this.workflow.enabledCache.values()).filter(
|
|
237
|
+
(item) => item.type === ApprovalTrigger.TYPE && triggersKeysMap.has(item.key)
|
|
238
|
+
);
|
|
239
|
+
for (const workflow of workflows) {
|
|
240
|
+
const [dataSourceName, collectionName] = (0, import_data_source.parseCollectionName)(workflow.config.collection);
|
|
241
|
+
const trigger = triggers.find((trigger2) => trigger2[0] === workflow.key);
|
|
242
|
+
const { body: data } = context;
|
|
243
|
+
if (!data) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (dataSourceName !== dataSourceHeader) {
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
(Array.isArray(data) ? data : [data]).forEach(async (row) => {
|
|
250
|
+
let dataCurrent = {};
|
|
251
|
+
if (row.id) {
|
|
252
|
+
const { repository } = this.workflow.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager.getCollection(collectionName);
|
|
253
|
+
dataCurrent = await repository.findOne({
|
|
254
|
+
filterByTk: data.id,
|
|
255
|
+
appends: [...workflow.config.appends]
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
let payload = row;
|
|
259
|
+
if (trigger[1]) {
|
|
260
|
+
const paths = trigger[1].split(".");
|
|
261
|
+
for await (const field of paths) {
|
|
262
|
+
if (payload.get(field)) {
|
|
263
|
+
payload = payload.get(field);
|
|
264
|
+
} else {
|
|
265
|
+
const association = (0, import_database.modelAssociationByKey)(payload, field);
|
|
266
|
+
payload = await payload[association.accessors.get]();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
const collection = context.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager.getCollection(collectionName);
|
|
271
|
+
if (!collection || collection.model !== payload.constructor) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
await approvalRepo.create({
|
|
275
|
+
values: {
|
|
276
|
+
collectionName: workflow.config.collection,
|
|
277
|
+
data: (0, import_module_workflow.toJSON)(payload),
|
|
278
|
+
dataKey: payload.get(collection.filterTargetKey),
|
|
279
|
+
status: import_status.APPROVAL_STATUS.SUBMITTED,
|
|
280
|
+
// createdBy: currentUser.id,
|
|
281
|
+
// updatedBy: currentUser.id,
|
|
282
|
+
workflowId: workflow.id,
|
|
283
|
+
workflowKey: workflow.key,
|
|
284
|
+
applicantRoleName: context.state.currentRole,
|
|
285
|
+
summary: (0, import_tools.getSummary)({
|
|
286
|
+
summaryConfig: workflow.config.summary,
|
|
287
|
+
data: dataCurrent
|
|
288
|
+
})
|
|
289
|
+
},
|
|
290
|
+
context
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
on(workflow) {
|
|
296
|
+
}
|
|
297
|
+
off(workflow) {
|
|
298
|
+
}
|
|
299
|
+
async duplicateConfig(workflow, { transaction }) {
|
|
300
|
+
const { db } = this.workflow;
|
|
301
|
+
const uiSchemaRepo = db.getRepository("uiSchemas");
|
|
302
|
+
if (!workflow.config.applyForm) {
|
|
303
|
+
return workflow.config;
|
|
304
|
+
}
|
|
305
|
+
const result = await uiSchemaRepo.duplicate(workflow.config.applyForm, {
|
|
306
|
+
transaction
|
|
307
|
+
});
|
|
308
|
+
return {
|
|
309
|
+
...workflow.config,
|
|
310
|
+
applyForm: result["x-uid"]
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
}
|