@nocobase/plugin-workflow 2.2.0-beta.9 → 3.0.0-alpha.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.
- package/client-v2.d.ts +2 -0
- package/client-v2.js +1 -0
- package/dist/client/119.e7dbd037d52d1286.js +10 -0
- package/dist/client/142.fb4936d78fc80007.js +10 -0
- package/dist/client/159.cc9a0f2d92cab2c1.js +10 -0
- package/dist/client/276.69fb2aea13bc7c37.js +10 -0
- package/dist/client/346.66d060d37843d3d1.js +10 -0
- package/dist/client/382.d37fba14a6b91b0b.js +10 -0
- package/dist/client/394.a37310b78419ad7a.js +10 -0
- package/dist/client/438.8bd46a04ca080a4e.js +10 -0
- package/dist/client/509.3a4ac27f10833c75.js +10 -0
- package/dist/client/54.d81b710f7b4c1cd5.js +10 -0
- package/dist/client/618.1aa6c21d0f2840cb.js +10 -0
- package/dist/client/635.ff6085589e23d39b.js +10 -0
- package/dist/client/67.5eb8767a709f27d9.js +10 -0
- package/dist/client/719.f011fde3ad54571e.js +10 -0
- package/dist/client/728.711fd4f1ed7d4e6a.js +10 -0
- package/dist/client/739.49407722fca8d236.js +10 -0
- package/dist/client/759.13aab01e6912ed8d.js +10 -0
- package/dist/client/772.1ebaef11a0ac8688.js +10 -0
- package/dist/client/782.47792ce10fc0d5fb.js +10 -0
- package/dist/client/828.d03ecfc4ac66e0f8.js +10 -0
- package/dist/client/87.b62b1123d4d560fb.js +10 -0
- package/dist/client/938.26493fc09ba1ccbc.js +10 -0
- package/dist/client/964.5ab736effd480a42.js +10 -0
- package/dist/client/972.dd7f074d5f12e171.js +10 -0
- package/dist/client/AddNodeContext.d.ts +1 -9
- package/dist/client/BranchContext.d.ts +2 -10
- package/dist/client/FlowContext.d.ts +10 -5
- package/dist/client/NodeClipboardContext.d.ts +12 -2
- package/dist/client/NodeDragContext.d.ts +14 -2
- package/dist/client/RemoveNodeContext.d.ts +16 -2
- package/dist/client/WorkflowTasks.d.ts +26 -3
- package/dist/client/index.d.ts +2 -2
- package/dist/client/index.js +1 -1
- package/dist/client/nodeVariableUtils.d.ts +7 -6
- package/dist/client/nodes/calculation.d.ts +3 -75
- package/dist/client/nodes/condition.d.ts +7 -111
- package/dist/client/nodes/create.d.ts +3 -124
- package/dist/client/nodes/destroy.d.ts +2 -57
- package/dist/client/nodes/end.d.ts +2 -23
- package/dist/client/nodes/index.d.ts +2 -91
- package/dist/client/nodes/multi-conditions.d.ts +10 -48
- package/dist/client/nodes/output.d.ts +2 -44
- package/dist/client/nodes/query.d.ts +3 -255
- package/dist/client/nodes/update.d.ts +2 -117
- package/dist/client/style.d.ts +7 -27
- package/dist/client/triggers/collection.d.ts +3 -181
- package/dist/client/triggers/index.d.ts +2 -36
- package/dist/client/triggers/schedule/index.d.ts +8 -65
- package/dist/client/utils.d.ts +4 -5
- package/dist/client/variable.d.ts +7 -53
- package/dist/client-v2/119.81195bcd0d451279.js +10 -0
- package/dist/client-v2/142.a8c8df2a9abb43c5.js +10 -0
- package/dist/client-v2/159.cb221540c286cd32.js +10 -0
- package/dist/client-v2/276.7f746d899e221e2f.js +10 -0
- package/dist/client-v2/326.bdc99ad8e7590970.js +10 -0
- package/dist/client-v2/346.8c038b3c99d4fdc9.js +10 -0
- package/dist/client-v2/382.05f5482bb512b179.js +10 -0
- package/dist/client-v2/387.e002f8eb34aa77e3.js +10 -0
- package/dist/client-v2/394.515ed058e7f72797.js +10 -0
- package/dist/client-v2/438.1459f1a7cd19ea4f.js +10 -0
- package/dist/client-v2/513.18e257b3025d7692.js +10 -0
- package/dist/client-v2/54.d3daf06e53092726.js +10 -0
- package/dist/client-v2/635.14a6f21cf4f16345.js +10 -0
- package/dist/client-v2/677.7007f4a6a4640165.js +10 -0
- package/dist/client-v2/719.05cf070ef89a78f4.js +10 -0
- package/dist/client-v2/728.4e8322ff8fce87b9.js +10 -0
- package/dist/client-v2/739.5b60845103064f8d.js +10 -0
- package/dist/client-v2/759.7b162ad3adf450f1.js +10 -0
- package/dist/client-v2/772.8e5148d8c1518449.js +10 -0
- package/dist/client-v2/938.717e47af39485b29.js +10 -0
- package/dist/client-v2/ExecutionCanvas.d.ts +15 -0
- package/dist/client-v2/canvas/AddNodeContext.d.ts +35 -0
- package/dist/client-v2/canvas/AddNodeContext.shared.d.ts +33 -0
- package/dist/client-v2/canvas/AddNodeSlot.d.ts +20 -0
- package/dist/client-v2/canvas/Branch.d.ts +32 -0
- package/dist/client-v2/canvas/BranchContext.d.ts +29 -0
- package/dist/client-v2/canvas/BranchRenderContext.d.ts +14 -0
- package/dist/client-v2/canvas/CanvasContent.d.ts +20 -0
- package/dist/client-v2/canvas/DownstreamBranchIndex.d.ts +20 -0
- package/dist/client-v2/canvas/Instruction.d.ts +139 -0
- package/dist/{client/triggers/schedule/EndsByField.d.ts → client-v2/canvas/JobButton.d.ts} +3 -3
- package/dist/client-v2/canvas/Node.d.ts +38 -0
- package/dist/client-v2/canvas/NodeClipboardContext.d.ts +64 -0
- package/dist/client-v2/canvas/NodeConfigDrawer.d.ts +27 -0
- package/dist/client-v2/canvas/NodeDragContext.d.ts +83 -0
- package/dist/client-v2/canvas/RemoveNodeContext.d.ts +45 -0
- package/dist/client-v2/canvas/WorkflowTypedVariableInput.d.ts +16 -0
- package/dist/client-v2/canvas/WorkflowVariableInput.d.ts +47 -0
- package/dist/client-v2/canvas/WorkflowVariableJsonTextArea.d.ts +15 -0
- package/dist/client-v2/canvas/WorkflowVariableTag.d.ts +22 -0
- package/dist/client-v2/canvas/WorkflowVariableTextArea.d.ts +23 -0
- package/dist/client-v2/canvas/adaptVariableOptionToMetaTree.d.ts +48 -0
- package/dist/client-v2/canvas/addNodeController.d.ts +70 -0
- package/dist/client-v2/canvas/collectionFieldOptions.d.ts +57 -0
- package/dist/client-v2/canvas/contexts.d.ts +86 -0
- package/dist/client-v2/canvas/dropImpact.d.ts +28 -0
- package/dist/client-v2/canvas/instructionAvailability.d.ts +26 -0
- package/dist/client-v2/canvas/nodeRenderDispatch.d.ts +79 -0
- package/dist/client-v2/canvas/nodeTree.d.ts +21 -0
- package/dist/client-v2/canvas/nodeVariableUtils.d.ts +14 -0
- package/dist/client-v2/canvas/removeNodeUtils.d.ts +31 -0
- package/dist/client-v2/canvas/style.d.ts +35 -0
- package/dist/client-v2/canvas/textAreaInsertion.d.ts +14 -0
- package/dist/client-v2/canvas/useWorkflowInstruction.d.ts +23 -0
- package/dist/client-v2/canvas/useWorkflowVariableOptions.d.ts +40 -0
- package/dist/client-v2/canvas/workflowVariableConverters.d.ts +13 -0
- package/dist/client-v2/components/Calculation.d.ts +18 -0
- package/dist/client-v2/components/ExecutionStatusIcon.d.ts +18 -0
- package/dist/{client/triggers/schedule/RepeatField.d.ts → client-v2/components/ExecutionStatusTag.d.ts} +3 -4
- package/dist/client-v2/components/ExecutionViewHeader.d.ts +29 -0
- package/dist/client-v2/components/ExecutionsDropdown.d.ts +25 -0
- package/dist/client-v2/components/FilterDynamicComponent.d.ts +28 -0
- package/dist/client-v2/components/HideVariableContext.d.ts +11 -0
- package/dist/client-v2/components/JobResultModal.d.ts +11 -0
- package/dist/client-v2/components/RadioWithTooltip.d.ts +23 -0
- package/dist/client-v2/components/SyncModeSelect.d.ts +16 -0
- package/dist/{client/triggers/schedule/OnField.d.ts → client-v2/components/SyncModeTag.d.ts} +3 -3
- package/dist/client-v2/components/TestRunButton.d.ts +36 -0
- package/dist/client-v2/components/TimeoutInput.d.ts +15 -0
- package/dist/client-v2/components/WorkflowCanvasHeader.d.ts +17 -0
- package/dist/client-v2/components/WorkflowDetailsModal.d.ts +25 -0
- package/dist/client-v2/components/WorkflowEnabledSwitch.d.ts +16 -0
- package/dist/client-v2/components/WorkflowMenu.d.ts +17 -0
- package/dist/client-v2/components/WorkflowRevisionsDropdown.d.ts +15 -0
- package/dist/client-v2/components/WorkflowVariableWrapper.d.ts +25 -0
- package/dist/client-v2/components/collection/AppendsSelect.d.ts +15 -0
- package/dist/client-v2/components/collection/AssignedFieldsEditor.d.ts +24 -0
- package/dist/client-v2/components/collection/CollectionCascader.d.ts +15 -0
- package/dist/client-v2/components/collection/FieldsSelect.d.ts +16 -0
- package/dist/client-v2/components/collection/PaginationFields.d.ts +14 -0
- package/dist/client-v2/components/collection/SortFieldsInput.d.ts +19 -0
- package/dist/client-v2/components/collection/TriggerCollectionRecordSelect.d.ts +15 -0
- package/dist/client-v2/components/collection/index.d.ts +16 -0
- package/dist/client-v2/components/collection/utils.d.ts +42 -0
- package/dist/client-v2/components/formatResultForDisplay.d.ts +17 -0
- package/dist/client-v2/components/jobStatus.d.ts +27 -0
- package/dist/client-v2/components/renderEngineReference.d.ts +10 -0
- package/dist/client-v2/components/workflowCanvas.d.ts +41 -0
- package/dist/client-v2/constants.d.ts +19 -0
- package/dist/client-v2/hooks/useWorkflowRuntimePaths.d.ts +16 -0
- package/dist/client-v2/index.d.ts +48 -0
- package/dist/client-v2/index.js +10 -0
- package/dist/client-v2/legacySettingsRedirect.d.ts +15 -0
- package/dist/client-v2/locale.d.ts +41 -0
- package/dist/{client → client-v2}/models/NodeDetailsGridModel.d.ts +1 -1
- package/dist/{client → client-v2}/models/NodeDetailsModel.d.ts +1 -1
- package/dist/{client → client-v2}/models/NodeValueModel.d.ts +1 -1
- package/dist/{client → client-v2}/models/TaskCardCommonItemModel.d.ts +1 -1
- package/dist/client-v2/models/WorkflowTasksTopbarActionModel.d.ts +18 -0
- package/dist/{client → client-v2}/models/index.d.ts +2 -0
- package/dist/client-v2/models/triggerWorkflows.d.ts +43 -0
- package/dist/client-v2/nodes/calculation.d.ts +38 -0
- package/dist/client-v2/nodes/collectionNode.d.ts +29 -0
- package/dist/client-v2/nodes/components/calculation.d.ts +11 -0
- package/dist/client-v2/nodes/components/collection.d.ts +15 -0
- package/dist/client-v2/nodes/components/condition.d.ts +25 -0
- package/dist/client-v2/nodes/components/conditionShared.d.ts +20 -0
- package/dist/client-v2/nodes/components/create.d.ts +12 -0
- package/dist/client-v2/nodes/components/destroy.d.ts +12 -0
- package/dist/{client/triggers/schedule/ScheduleConfig.d.ts → client-v2/nodes/components/end.d.ts} +1 -1
- package/dist/client-v2/nodes/components/filter.d.ts +17 -0
- package/dist/client-v2/nodes/components/multi-conditions.d.ts +13 -0
- package/dist/client-v2/nodes/components/multiConditionsShared.d.ts +20 -0
- package/dist/client-v2/nodes/components/output.d.ts +10 -0
- package/dist/client-v2/nodes/components/query.d.ts +12 -0
- package/dist/client-v2/nodes/components/update.d.ts +12 -0
- package/dist/client-v2/nodes/condition.d.ts +46 -0
- package/dist/client-v2/nodes/create.d.ts +30 -0
- package/dist/client-v2/nodes/destroy.d.ts +24 -0
- package/dist/client-v2/nodes/end.d.ts +21 -0
- package/dist/client-v2/nodes/multi-conditions.d.ts +34 -0
- package/dist/client-v2/nodes/output.d.ts +29 -0
- package/dist/client-v2/nodes/query.d.ts +32 -0
- package/dist/client-v2/nodes/update.d.ts +25 -0
- package/dist/client-v2/pages/ExecutionHistoryDrawer.d.ts +13 -0
- package/dist/client-v2/pages/ExecutionViewPage.d.ts +10 -0
- package/dist/client-v2/pages/WorkflowCanvasPage.d.ts +10 -0
- package/dist/client-v2/pages/WorkflowCategoryTabs.d.ts +25 -0
- package/dist/client-v2/pages/WorkflowFormDrawer.d.ts +40 -0
- package/dist/client-v2/pages/WorkflowPane.d.ts +10 -0
- package/dist/client-v2/pages/WorkflowTasksPage.d.ts +10 -0
- package/dist/client-v2/plugin.d.ts +119 -0
- package/dist/client-v2/taskCenter.d.ts +105 -0
- package/dist/client-v2/triggers/ExecuteWorkflowButton.d.ts +35 -0
- package/dist/client-v2/triggers/TriggerConfig.d.ts +22 -0
- package/dist/client-v2/triggers/TriggerExecutionButton.d.ts +13 -0
- package/dist/client-v2/triggers/collection/CollectionConfig.d.ts +14 -0
- package/dist/client-v2/triggers/collection/TriggerCollectionConfig.d.ts +11 -0
- package/dist/client-v2/triggers/collection/constants.d.ts +28 -0
- package/dist/client-v2/triggers/collection/index.d.ts +40 -0
- package/dist/client-v2/triggers/index.d.ts +63 -0
- package/dist/client-v2/triggers/schedule/EndsByField.d.ts +17 -0
- package/dist/client-v2/triggers/schedule/OnField.d.ts +20 -0
- package/dist/client-v2/triggers/schedule/RepeatField.d.ts +23 -0
- package/dist/client-v2/triggers/schedule/ScheduleConfig.d.ts +17 -0
- package/dist/client-v2/triggers/schedule/ScheduleModes.d.ts +41 -0
- package/dist/{client → client-v2}/triggers/schedule/TriggerScheduleConfig.d.ts +1 -0
- package/dist/{client → client-v2}/triggers/schedule/constants.d.ts +8 -5
- package/dist/client-v2/triggers/schedule/index.d.ts +40 -0
- package/dist/client-v2/triggers/schedule/locale/Cron.zh-CN.d.ts +11 -0
- package/dist/client-v2/utils/contextSingleton.d.ts +9 -0
- package/dist/common/collections/userWorkflowTaskStats.d.ts +54 -0
- package/dist/common/collections/userWorkflowTaskStats.js +87 -0
- package/dist/common/collections/workflows.d.ts +16 -0
- package/dist/common/collections/workflows.js +5 -0
- package/dist/common/defaultWorkflowFilter.d.ts +21 -0
- package/dist/common/defaultWorkflowFilter.js +38 -0
- package/dist/common/executionStatus.d.ts +44 -0
- package/dist/common/executionStatus.js +133 -0
- package/dist/externalVersion.js +16 -13
- package/dist/locale/de-DE.json +15 -1
- package/dist/locale/en-US.json +30 -1
- package/dist/locale/es-ES.json +15 -1
- package/dist/locale/fr-FR.json +15 -1
- package/dist/locale/hu-HU.json +15 -1
- package/dist/locale/id-ID.json +15 -1
- package/dist/locale/it-IT.json +15 -1
- package/dist/locale/ja-JP.json +15 -1
- package/dist/locale/ko-KR.json +15 -1
- package/dist/locale/nl-NL.json +15 -1
- package/dist/locale/pt-BR.json +15 -1
- package/dist/locale/ru-RU.json +15 -1
- package/dist/locale/tr-TR.json +15 -1
- package/dist/locale/uk-UA.json +15 -1
- package/dist/locale/vi-VN.json +15 -1
- package/dist/locale/zh-CN.json +29 -1
- package/dist/locale/zh-TW.json +21 -1
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/joi/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/node_modules/nodejs-snowflake/package.json +1 -1
- package/dist/server/Dispatcher.d.ts +27 -15
- package/dist/server/Dispatcher.js +199 -161
- package/dist/server/ExecutionTimeoutManager.js +2 -1
- package/dist/server/Plugin.d.ts +58 -12
- package/dist/server/Plugin.js +355 -15
- package/dist/server/Processor.d.ts +1 -7
- package/dist/server/Processor.js +11 -7
- package/dist/server/actions/executions.js +3 -6
- package/dist/server/actions/index.js +3 -1
- package/dist/server/actions/jobs.js +1 -2
- package/dist/server/actions/userWorkflowTaskStats.d.ts +10 -0
- package/dist/server/actions/userWorkflowTaskStats.js +112 -0
- package/dist/server/actions/workflows.d.ts +1 -0
- package/dist/server/actions/workflows.js +34 -2
- package/dist/server/collections/userWorkflowTaskStats.d.ts +11 -0
- package/dist/server/collections/userWorkflowTaskStats.js +43 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/triggers/CollectionTrigger.d.ts +1 -1
- package/dist/server/triggers/CollectionTrigger.js +3 -0
- package/dist/server/triggers/ScheduleTrigger/StaticScheduleTrigger.d.ts +1 -1
- package/dist/server/triggers/index.d.ts +1 -1
- package/dist/server/types/Execution.d.ts +2 -0
- package/dist/server/types/Job.d.ts +5 -0
- package/dist/server/types/Workflow.d.ts +1 -0
- package/dist/server/utils.d.ts +2 -1
- package/dist/server/utils.js +19 -1
- package/dist/swagger/index.d.ts +69 -1
- package/dist/swagger/index.js +65 -3
- package/package.json +4 -2
- package/dist/client/618.c91be3f6e4d73501.js +0 -10
- package/dist/client/67.61e70b8b777f8638.js +0 -10
- package/dist/client/964.5e11e1820fece37b.js +0 -10
- package/dist/client/triggers/schedule/ScheduleModes.d.ts +0 -170
- package/dist/client/triggers/schedule/locale/Cron.zh-CN.d.ts +0 -42
|
@@ -40,6 +40,7 @@ __export(workflows_exports, {
|
|
|
40
40
|
create: () => create,
|
|
41
41
|
destroy: () => destroy,
|
|
42
42
|
execute: () => execute,
|
|
43
|
+
list: () => list,
|
|
43
44
|
revision: () => revision,
|
|
44
45
|
sync: () => sync,
|
|
45
46
|
update: () => update
|
|
@@ -72,9 +73,14 @@ function validateWorkflow(context, plugin, { type, config }) {
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
}
|
|
76
|
+
async function list(context, next) {
|
|
77
|
+
return import_actions.default.list(context, next);
|
|
78
|
+
}
|
|
75
79
|
async function create(context, next) {
|
|
76
80
|
const plugin = context.app.pm.get(import_Plugin.default);
|
|
77
|
-
const
|
|
81
|
+
const values = { ...context.action.params.values || {} };
|
|
82
|
+
delete values.invalid;
|
|
83
|
+
context.action.mergeParams({ values }, { values: "overwrite" });
|
|
78
84
|
validateWorkflow(context, plugin, values);
|
|
79
85
|
return import_actions.default.create(context, next);
|
|
80
86
|
}
|
|
@@ -100,6 +106,7 @@ async function update(context, next) {
|
|
|
100
106
|
return import_actions.default.update(context, next);
|
|
101
107
|
}
|
|
102
108
|
async function destroy(context, next) {
|
|
109
|
+
const plugin = context.app.pm.get(import_Plugin.default);
|
|
103
110
|
const repository = import_actions.utils.getRepositoryFromParams(context);
|
|
104
111
|
const { filterByTk, filter } = context.action.params;
|
|
105
112
|
await context.db.sequelize.transaction(async (transaction) => {
|
|
@@ -110,6 +117,15 @@ async function destroy(context, next) {
|
|
|
110
117
|
transaction
|
|
111
118
|
});
|
|
112
119
|
const ids = new Set(items.map((item) => item.id));
|
|
120
|
+
const affectedKeys = Array.from(new Set(items.map((item) => item.get("key"))));
|
|
121
|
+
const affectedTaskStats = affectedKeys.length ? await context.db.getRepository("userWorkflowTaskStats").find({
|
|
122
|
+
filter: {
|
|
123
|
+
workflowKey: affectedKeys
|
|
124
|
+
},
|
|
125
|
+
fields: ["userId"],
|
|
126
|
+
transaction
|
|
127
|
+
}) : [];
|
|
128
|
+
const affectedUserIds = Array.from(new Set(affectedTaskStats.map((item) => item.get("userId"))));
|
|
113
129
|
const keysSet = new Set(items.filter((item) => item.current).map((item) => item.key));
|
|
114
130
|
const revisions = await repository.find({
|
|
115
131
|
filter: {
|
|
@@ -132,6 +148,13 @@ async function destroy(context, next) {
|
|
|
132
148
|
},
|
|
133
149
|
transaction
|
|
134
150
|
});
|
|
151
|
+
if (affectedKeys.length) {
|
|
152
|
+
await plugin.repairTaskStats({
|
|
153
|
+
workflowKeys: affectedKeys,
|
|
154
|
+
...affectedUserIds.length ? { userIds: affectedUserIds } : {},
|
|
155
|
+
transaction
|
|
156
|
+
});
|
|
157
|
+
}
|
|
135
158
|
context.body = deleted;
|
|
136
159
|
});
|
|
137
160
|
next();
|
|
@@ -139,10 +162,12 @@ async function destroy(context, next) {
|
|
|
139
162
|
async function revision(context, next) {
|
|
140
163
|
const repository = import_actions.utils.getRepositoryFromParams(context);
|
|
141
164
|
const { filterByTk, filter = {}, values = {} } = context.action.params;
|
|
165
|
+
const revisionValues = { ...values };
|
|
166
|
+
delete revisionValues.invalid;
|
|
142
167
|
context.body = await repository.revision({
|
|
143
168
|
filterByTk,
|
|
144
169
|
filter,
|
|
145
|
-
values,
|
|
170
|
+
values: revisionValues,
|
|
146
171
|
context
|
|
147
172
|
});
|
|
148
173
|
await next();
|
|
@@ -184,6 +209,12 @@ async function execute(context, next) {
|
|
|
184
209
|
let processor;
|
|
185
210
|
try {
|
|
186
211
|
processor = await plugin.execute(workflow, values, { manually: true });
|
|
212
|
+
if (processor === null) {
|
|
213
|
+
context.body = {
|
|
214
|
+
execution: null
|
|
215
|
+
};
|
|
216
|
+
return next();
|
|
217
|
+
}
|
|
187
218
|
if (!processor) {
|
|
188
219
|
return context.throw(400, "workflow not triggered");
|
|
189
220
|
}
|
|
@@ -220,6 +251,7 @@ async function execute(context, next) {
|
|
|
220
251
|
create,
|
|
221
252
|
destroy,
|
|
222
253
|
execute,
|
|
254
|
+
list,
|
|
223
255
|
revision,
|
|
224
256
|
sync,
|
|
225
257
|
update
|
|
@@ -0,0 +1,11 @@
|
|
|
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 { CollectionOptions } from '@nocobase/database';
|
|
10
|
+
declare const _default: CollectionOptions;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,43 @@
|
|
|
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 userWorkflowTaskStats_exports = {};
|
|
38
|
+
__export(userWorkflowTaskStats_exports, {
|
|
39
|
+
default: () => userWorkflowTaskStats_default
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(userWorkflowTaskStats_exports);
|
|
42
|
+
var import_userWorkflowTaskStats = __toESM(require("../../common/collections/userWorkflowTaskStats"));
|
|
43
|
+
var userWorkflowTaskStats_default = import_userWorkflowTaskStats.default;
|
package/dist/server/index.d.ts
CHANGED
|
@@ -17,4 +17,5 @@ export type { EventOptions } from './Dispatcher';
|
|
|
17
17
|
export { default as Processor } from './Processor';
|
|
18
18
|
export type { BackgroundAbortHandle, ProcessorOptions, ScopeTransaction } from './Processor';
|
|
19
19
|
export { default } from './Plugin';
|
|
20
|
+
export type { RepairTaskStatsOptions, TaskStatsProvider, TaskStatsRow } from './Plugin';
|
|
20
21
|
export * from './types';
|
|
@@ -30,7 +30,7 @@ export default class CollectionTrigger extends Trigger {
|
|
|
30
30
|
code?: string;
|
|
31
31
|
};
|
|
32
32
|
prepare(workflow: WorkflowModel, data: Model | Record<string, any> | string | number, options: any): Promise<{
|
|
33
|
-
data: any
|
|
33
|
+
data: string | number | Record<string, any> | Model<any, any>;
|
|
34
34
|
}>;
|
|
35
35
|
on(workflow: WorkflowModel): void;
|
|
36
36
|
off(workflow: WorkflowModel): void;
|
|
@@ -305,6 +305,9 @@ class CollectionTrigger extends import__.default {
|
|
|
305
305
|
// }
|
|
306
306
|
async execute(workflow, values, options) {
|
|
307
307
|
const ctx = await this.prepare(workflow, values == null ? void 0 : values.data, options);
|
|
308
|
+
if (!ctx) {
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
308
311
|
const [dataSourceName] = (0, import_data_source_manager.parseCollectionName)(workflow.config.collection);
|
|
309
312
|
const { transaction } = options;
|
|
310
313
|
return this.workflow.trigger(workflow, ctx, {
|
|
@@ -20,5 +20,5 @@ export default class StaticScheduleTrigger {
|
|
|
20
20
|
trigger(workflow: WorkflowModel, time: number): Promise<void>;
|
|
21
21
|
on(workflow: any): void;
|
|
22
22
|
off(workflow: any): void;
|
|
23
|
-
execute(workflow: any, values: any, options: any): void | Promise<import("../..").Processor>;
|
|
23
|
+
execute(workflow: any, values: any, options: any): void | Promise<void | import("../..").Processor>;
|
|
24
24
|
}
|
|
@@ -26,6 +26,6 @@ export declare abstract class Trigger {
|
|
|
26
26
|
[key: string]: string;
|
|
27
27
|
};
|
|
28
28
|
sync?: boolean;
|
|
29
|
-
execute?(workflow: WorkflowModel, values: any, options: Transactionable): void | Processor | Promise<void | Processor>;
|
|
29
|
+
execute?(workflow: WorkflowModel, values: any, options: Transactionable): void | Processor | null | Promise<void | Processor | null>;
|
|
30
30
|
}
|
|
31
31
|
export default Trigger;
|
|
@@ -12,11 +12,13 @@ import WorkflowModel from './Workflow';
|
|
|
12
12
|
export default class ExecutionModel extends Model {
|
|
13
13
|
static readonly database: Database;
|
|
14
14
|
id: number;
|
|
15
|
+
workflowId: number;
|
|
15
16
|
title: string;
|
|
16
17
|
context: any;
|
|
17
18
|
status: number;
|
|
18
19
|
reason?: string | null;
|
|
19
20
|
dispatched: boolean;
|
|
21
|
+
manually?: boolean | null;
|
|
20
22
|
parentExecutionId?: number | null;
|
|
21
23
|
stack?: Array<number | string>;
|
|
22
24
|
startedAt?: Date | null;
|
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { BelongsToGetAssociationMixin, Model } from '@nocobase/database';
|
|
10
10
|
import FlowNodeModel from './FlowNode';
|
|
11
|
+
import ExecutionModel from './Execution';
|
|
11
12
|
export default class JobModel extends Model {
|
|
12
13
|
id: number;
|
|
14
|
+
executionId: number;
|
|
15
|
+
workflowId?: number;
|
|
13
16
|
status: number;
|
|
14
17
|
result?: any;
|
|
15
18
|
meta?: any;
|
|
@@ -20,4 +23,6 @@ export default class JobModel extends Model {
|
|
|
20
23
|
nodeId: number;
|
|
21
24
|
node?: FlowNodeModel;
|
|
22
25
|
getNode: BelongsToGetAssociationMixin<FlowNodeModel>;
|
|
26
|
+
execution?: ExecutionModel;
|
|
27
|
+
getExecution: BelongsToGetAssociationMixin<ExecutionModel>;
|
|
23
28
|
}
|
package/dist/server/utils.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ type AbortOptions = Transactionable & {
|
|
|
16
16
|
reason?: (typeof EXECUTION_REASON)[keyof typeof EXECUTION_REASON];
|
|
17
17
|
};
|
|
18
18
|
export declare function getExecutionLockKey(executionId: number | string): string;
|
|
19
|
+
export declare function getJobLockKey(jobId: number | string): string;
|
|
19
20
|
export declare function isLockAcquireError(error: unknown): boolean;
|
|
20
21
|
export declare function validateCollectionField(collection: string, dataSourceManager: DataSourceManager): Record<string, string> | null;
|
|
21
22
|
export declare function getExecutionStatusName(status: number | null | undefined): string;
|
|
@@ -32,5 +33,5 @@ export declare function getWorkflowExecutionLogMeta(workflow: WorkflowModel, pro
|
|
|
32
33
|
lastJobStatus: number;
|
|
33
34
|
};
|
|
34
35
|
export declare function abortExecution(plugin: PluginWorkflowServer, execution: ExecutionModel, options?: AbortOptions): Promise<boolean>;
|
|
35
|
-
export declare function toJSON(data:
|
|
36
|
+
export declare function toJSON<T>(data: T): T;
|
|
36
37
|
export {};
|
package/dist/server/utils.js
CHANGED
|
@@ -29,6 +29,7 @@ __export(utils_exports, {
|
|
|
29
29
|
abortExecution: () => abortExecution,
|
|
30
30
|
getExecutionLockKey: () => getExecutionLockKey,
|
|
31
31
|
getExecutionStatusName: () => getExecutionStatusName,
|
|
32
|
+
getJobLockKey: () => getJobLockKey,
|
|
32
33
|
getWorkflowExecutionLogMeta: () => getWorkflowExecutionLogMeta,
|
|
33
34
|
isLockAcquireError: () => isLockAcquireError,
|
|
34
35
|
toJSON: () => toJSON,
|
|
@@ -41,6 +42,9 @@ var import_constants = require("./constants");
|
|
|
41
42
|
function getExecutionLockKey(executionId) {
|
|
42
43
|
return `workflow:execution:${executionId}`;
|
|
43
44
|
}
|
|
45
|
+
function getJobLockKey(jobId) {
|
|
46
|
+
return `workflow:job:${jobId}`;
|
|
47
|
+
}
|
|
44
48
|
function isLockAcquireError(error) {
|
|
45
49
|
return error instanceof Error && error.constructor.name === "LockAcquireError";
|
|
46
50
|
}
|
|
@@ -164,6 +168,16 @@ async function abortExecution(plugin, execution, options = {}) {
|
|
|
164
168
|
throw error;
|
|
165
169
|
}
|
|
166
170
|
}
|
|
171
|
+
function getHiddenFieldNames(model) {
|
|
172
|
+
const { collection } = model.constructor;
|
|
173
|
+
if (!(collection == null ? void 0 : collection.fields)) {
|
|
174
|
+
return [];
|
|
175
|
+
}
|
|
176
|
+
return Array.from(collection.fields.values()).filter((field) => {
|
|
177
|
+
var _a;
|
|
178
|
+
return (_a = field == null ? void 0 : field.options) == null ? void 0 : _a.hidden;
|
|
179
|
+
}).map((field) => field.options.name).filter((name) => typeof name === "string");
|
|
180
|
+
}
|
|
167
181
|
function toJSON(data) {
|
|
168
182
|
if (Array.isArray(data)) {
|
|
169
183
|
return data.map(toJSON);
|
|
@@ -171,7 +185,10 @@ function toJSON(data) {
|
|
|
171
185
|
if (!(data instanceof import_database.Model) || !data) {
|
|
172
186
|
return data;
|
|
173
187
|
}
|
|
174
|
-
const result = data.get();
|
|
188
|
+
const result = { ...data.get() };
|
|
189
|
+
for (const fieldName of getHiddenFieldNames(data)) {
|
|
190
|
+
delete result[fieldName];
|
|
191
|
+
}
|
|
175
192
|
Object.keys(data.constructor.associations).forEach((key) => {
|
|
176
193
|
if (result[key] != null && typeof result[key] === "object") {
|
|
177
194
|
result[key] = toJSON(result[key]);
|
|
@@ -184,6 +201,7 @@ function toJSON(data) {
|
|
|
184
201
|
abortExecution,
|
|
185
202
|
getExecutionLockKey,
|
|
186
203
|
getExecutionStatusName,
|
|
204
|
+
getJobLockKey,
|
|
187
205
|
getWorkflowExecutionLogMeta,
|
|
188
206
|
isLockAcquireError,
|
|
189
207
|
toJSON,
|
package/dist/swagger/index.d.ts
CHANGED
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
* flow_nodes — Update / delete / move / duplicate / test nodes
|
|
16
16
|
* executions — Execution record queries, cancellation and deletion
|
|
17
17
|
* jobs — Node job queries and resuming paused executions
|
|
18
|
-
* userWorkflowTasks — Current-user's pending workflow tasks
|
|
18
|
+
* userWorkflowTasks — Current-user's pending workflow tasks grouped by type
|
|
19
|
+
* userWorkflowTaskStats — Current-user's pending workflow tasks grouped by workflow
|
|
19
20
|
*
|
|
20
21
|
* API conventions:
|
|
21
22
|
* Base URL : /api
|
|
@@ -428,6 +429,7 @@ declare const _default: {
|
|
|
428
429
|
properties: {
|
|
429
430
|
execution: {
|
|
430
431
|
type: string;
|
|
432
|
+
nullable: boolean;
|
|
431
433
|
properties: {
|
|
432
434
|
id: {
|
|
433
435
|
type: string;
|
|
@@ -1175,6 +1177,72 @@ declare const _default: {
|
|
|
1175
1177
|
};
|
|
1176
1178
|
};
|
|
1177
1179
|
};
|
|
1180
|
+
'/userWorkflowTaskStats:listMine': {
|
|
1181
|
+
get: {
|
|
1182
|
+
tags: string[];
|
|
1183
|
+
summary: string;
|
|
1184
|
+
description: string;
|
|
1185
|
+
parameters: ({
|
|
1186
|
+
name: string;
|
|
1187
|
+
in: string;
|
|
1188
|
+
schema: {
|
|
1189
|
+
type: string;
|
|
1190
|
+
default?: undefined;
|
|
1191
|
+
maximum?: undefined;
|
|
1192
|
+
};
|
|
1193
|
+
} | {
|
|
1194
|
+
name: string;
|
|
1195
|
+
in: string;
|
|
1196
|
+
schema: {
|
|
1197
|
+
type: string;
|
|
1198
|
+
default: number;
|
|
1199
|
+
maximum?: undefined;
|
|
1200
|
+
};
|
|
1201
|
+
} | {
|
|
1202
|
+
name: string;
|
|
1203
|
+
in: string;
|
|
1204
|
+
schema: {
|
|
1205
|
+
type: string;
|
|
1206
|
+
default: number;
|
|
1207
|
+
maximum: number;
|
|
1208
|
+
};
|
|
1209
|
+
})[];
|
|
1210
|
+
responses: {
|
|
1211
|
+
200: {
|
|
1212
|
+
description: string;
|
|
1213
|
+
content: {
|
|
1214
|
+
'application/json': {
|
|
1215
|
+
schema: {
|
|
1216
|
+
type: string;
|
|
1217
|
+
items: {
|
|
1218
|
+
type: string;
|
|
1219
|
+
properties: {
|
|
1220
|
+
workflowKey: {
|
|
1221
|
+
type: string;
|
|
1222
|
+
};
|
|
1223
|
+
title: {
|
|
1224
|
+
type: string;
|
|
1225
|
+
};
|
|
1226
|
+
stats: {
|
|
1227
|
+
type: string;
|
|
1228
|
+
properties: {
|
|
1229
|
+
pending: {
|
|
1230
|
+
type: string;
|
|
1231
|
+
};
|
|
1232
|
+
all: {
|
|
1233
|
+
type: string;
|
|
1234
|
+
};
|
|
1235
|
+
};
|
|
1236
|
+
};
|
|
1237
|
+
};
|
|
1238
|
+
};
|
|
1239
|
+
};
|
|
1240
|
+
};
|
|
1241
|
+
};
|
|
1242
|
+
};
|
|
1243
|
+
};
|
|
1244
|
+
};
|
|
1245
|
+
};
|
|
1178
1246
|
};
|
|
1179
1247
|
components: {
|
|
1180
1248
|
schemas: {
|
package/dist/swagger/index.js
CHANGED
|
@@ -40,7 +40,8 @@ var swagger_default = {
|
|
|
40
40
|
{ name: "flow_nodes", description: "Flow node management: update, delete, move, duplicate, test" },
|
|
41
41
|
{ name: "executions", description: "Execution record management: list, get, cancel, delete" },
|
|
42
42
|
{ name: "jobs", description: "Node job management: list, get, resume" },
|
|
43
|
-
{ name: "userWorkflowTasks", description: "Current-user workflow task queries" }
|
|
43
|
+
{ name: "userWorkflowTasks", description: "Current-user workflow task queries" },
|
|
44
|
+
{ name: "userWorkflowTaskStats", description: "Current-user workflow task stats grouped by workflow" }
|
|
44
45
|
],
|
|
45
46
|
paths: {
|
|
46
47
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -394,7 +395,8 @@ var swagger_default = {
|
|
|
394
395
|
"**autoRevision:** When set to `1`, if the workflow has never been executed",
|
|
395
396
|
"(`executed === 0`), a new revision is created automatically after execution.",
|
|
396
397
|
"",
|
|
397
|
-
"**Returns:** `{ execution: { id, status }, newVersionId? }
|
|
398
|
+
"**Returns:** `{ execution: { id, status } | null, newVersionId? }`.",
|
|
399
|
+
"`execution` is `null` when the request is valid but no execution is started."
|
|
398
400
|
].join("\n"),
|
|
399
401
|
parameters: [
|
|
400
402
|
{
|
|
@@ -433,6 +435,7 @@ var swagger_default = {
|
|
|
433
435
|
properties: {
|
|
434
436
|
execution: {
|
|
435
437
|
type: "object",
|
|
438
|
+
nullable: true,
|
|
436
439
|
properties: {
|
|
437
440
|
id: { type: "integer", description: "Execution ID" },
|
|
438
441
|
status: { type: "integer", description: "Execution status code" }
|
|
@@ -449,7 +452,7 @@ var swagger_default = {
|
|
|
449
452
|
}
|
|
450
453
|
},
|
|
451
454
|
400: {
|
|
452
|
-
description: "Bad Request. Request body or `filterByTk` is missing/invalid
|
|
455
|
+
description: "Bad Request. Request body or `filterByTk` is missing/invalid."
|
|
453
456
|
},
|
|
454
457
|
404: { description: "Not Found. Workflow does not exist." }
|
|
455
458
|
}
|
|
@@ -1218,6 +1221,65 @@ var swagger_default = {
|
|
|
1218
1221
|
}
|
|
1219
1222
|
}
|
|
1220
1223
|
}
|
|
1224
|
+
},
|
|
1225
|
+
"/userWorkflowTaskStats:listMine": {
|
|
1226
|
+
get: {
|
|
1227
|
+
tags: ["userWorkflowTaskStats"],
|
|
1228
|
+
summary: "List my workflow task stats by workflow",
|
|
1229
|
+
description: [
|
|
1230
|
+
"Get current-user task statistics grouped by `workflowKey`, with the title of the current workflow version.",
|
|
1231
|
+
"",
|
|
1232
|
+
"Pass `type` to limit the result to one task type. Without it, the response sums all task types."
|
|
1233
|
+
].join("\n"),
|
|
1234
|
+
parameters: [
|
|
1235
|
+
{
|
|
1236
|
+
name: "type",
|
|
1237
|
+
in: "query",
|
|
1238
|
+
schema: { type: "string" }
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
name: "search",
|
|
1242
|
+
in: "query",
|
|
1243
|
+
schema: { type: "string" }
|
|
1244
|
+
},
|
|
1245
|
+
{
|
|
1246
|
+
name: "page",
|
|
1247
|
+
in: "query",
|
|
1248
|
+
schema: { type: "integer", default: 1 }
|
|
1249
|
+
},
|
|
1250
|
+
{
|
|
1251
|
+
name: "pageSize",
|
|
1252
|
+
in: "query",
|
|
1253
|
+
schema: { type: "integer", default: 200, maximum: 200 }
|
|
1254
|
+
}
|
|
1255
|
+
],
|
|
1256
|
+
responses: {
|
|
1257
|
+
200: {
|
|
1258
|
+
description: "OK",
|
|
1259
|
+
content: {
|
|
1260
|
+
"application/json": {
|
|
1261
|
+
schema: {
|
|
1262
|
+
type: "array",
|
|
1263
|
+
items: {
|
|
1264
|
+
type: "object",
|
|
1265
|
+
properties: {
|
|
1266
|
+
workflowKey: { type: "string" },
|
|
1267
|
+
title: { type: "string" },
|
|
1268
|
+
stats: {
|
|
1269
|
+
type: "object",
|
|
1270
|
+
properties: {
|
|
1271
|
+
pending: { type: "integer" },
|
|
1272
|
+
all: { type: "integer" }
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1221
1283
|
}
|
|
1222
1284
|
},
|
|
1223
1285
|
// ───────────────────────────────────────────────────────────────────────────
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"description": "A powerful BPM tool that provides foundational support for business automation, with the capability to extend unlimited triggers and nodes.",
|
|
7
7
|
"description.zh-CN": "一个强大的 BPM 工具,为业务自动化提供基础支持,并且可任意扩展更多的触发器和节点。",
|
|
8
8
|
"description.ru-RU": "Мощный инструмент BPM, обеспечивающий базовую поддержку автоматизации бизнес-процессов с возможностью неограниченного расширения триггеров и узлов.",
|
|
9
|
-
"version": "
|
|
9
|
+
"version": "3.0.0-alpha.1",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"main": "./dist/server/index.js",
|
|
12
12
|
"homepage": "https://docs.nocobase.com/handbook/workflow",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"@formily/core": "2.x",
|
|
19
19
|
"@formily/react": "2.x",
|
|
20
20
|
"@types/ejs": "^3.1.1",
|
|
21
|
+
"ahooks": "^3.7.2",
|
|
21
22
|
"antd": "5.x",
|
|
22
23
|
"classnames": "^2.3.1",
|
|
23
24
|
"cron-parser": "4.4.0",
|
|
@@ -36,6 +37,7 @@
|
|
|
36
37
|
"peerDependencies": {
|
|
37
38
|
"@nocobase/actions": "2.x",
|
|
38
39
|
"@nocobase/client": "2.x",
|
|
40
|
+
"@nocobase/client-v2": "2.x",
|
|
39
41
|
"@nocobase/database": "2.x",
|
|
40
42
|
"@nocobase/evaluators": "2.x",
|
|
41
43
|
"@nocobase/logger": "2.x",
|
|
@@ -49,7 +51,7 @@
|
|
|
49
51
|
"@nocobase/test": "2.x",
|
|
50
52
|
"@nocobase/utils": "2.x"
|
|
51
53
|
},
|
|
52
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "22d8be8ece179cfa5c8a4ebb2c896c92bd418e03",
|
|
53
55
|
"keywords": [
|
|
54
56
|
"Workflow"
|
|
55
57
|
]
|
|
@@ -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
|
-
|
|
10
|
-
"use strict";(self.webpackChunk_nocobase_plugin_workflow=self.webpackChunk_nocobase_plugin_workflow||[]).push([["618"],{5705:function(e,t,r){r.r(t),r.d(t,{WorkflowPane:function(){return eC}});var n,o,i=r(9155),c=r.n(i),a=r(2059),l=r(9452),u=r(5230),s=r(3342),p=r(4421);function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function d(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}var f=function(e){var t,r=e.request,n=(e.filter,function(e,t){if(null==e)return{};var r,n,o,i={};if("u">typeof Reflect&&Reflect.ownKeys){for(o=0,r=Reflect.ownKeys(Object(e));o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n]);return i}if(i=function(e,t){if(null==e)return{};var r,n,o={},i=Object.getOwnPropertyNames(e);for(n=0;n<i.length;n++)r=i[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,t),Object.getOwnPropertySymbols)for(o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n]);return i}(e,["request","filter"])),o=(0,s.useRecord)(),i=d(m({},n),{request:d(m({},r),{params:d(m({disableDefaultAppends:!0},null==r?void 0:r.params),{filter:d(m({},null==r||null==(t=r.params)?void 0:t.filter),{key:o.key})})})});return c().createElement(s.ResourceActionProvider,i)},y=r(5953),b=r(4442),v=r(6072),g=function(){var e=(0,y.useTranslation)().t,t=(0,s.useRecord)().id,r=(0,s.useActionContext)().setVisible,n=(0,s.useGetAriaLabelOfAction)("Configure").getAriaLabel;return c().createElement(b.Link,{"aria-label":n(),to:(0,v.Yz)(t),onClick:function(){return r(!1)}},e("Configure"))};function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function x(e){var t,r,n,o=e.component,a=e.children,l=function(e,t){if(null==e)return{};var r,n,o,i={};if("u">typeof Reflect&&Reflect.ownKeys){for(o=0,r=Reflect.ownKeys(Object(e));o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n]);return i}if(i=function(e,t){if(null==e)return{};var r,n,o={},i=Object.getOwnPropertyNames(e);for(n=0;n<i.length;n++)r=i[n],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r]);return o}(e,t),Object.getOwnPropertySymbols)for(o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)n=r[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n]);return i}(e,["component","children"]),p=function(e){if(Array.isArray(e))return e}(t=(0,i.useState)(!1))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],i=!0,c=!1;try{for(n=n.call(e);!(i=(t=n.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){c=!0,r=e}finally{try{i||null==n.return||n.return()}finally{if(c)throw r}}return o}}(t)||function(e){if(e){if("string"==typeof e)return h(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return h(e,2)}}(t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),m=p[0],d=p[1],f=(0,u.useFieldSchema)();return c().createElement(s.ActionContextProvider,{value:{visible:m,setVisible:d,fieldSchema:f}},c().createElement(void 0===o?"div":o,(r=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},l),n=n={onClick:function(){d(!0)}},Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(n)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}),r),a),c().createElement(s.SchemaComponent,{schema:f,onlyRenderProperties:!0}))}var O=r(3872),w=r(6481),C=r(7428),A=r(5827),S=r(2662);function P(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}var j={title:{"x-component":"CollectionField","x-decorator":"FormItem"},type:{"x-decorator":"FormItem",title:'{{t("Trigger type", { ns: "'.concat(O.CU,'" })}}'),"x-component":"Select","x-component-props":{optionRender:"{{TriggerOptionRender}}",popupMatchSelectWidth:!0,listHeight:300},enum:"{{useTriggersOptions()}}",required:!0},sync:{type:"boolean",title:'{{ t("Execute mode", { ns: "'.concat(O.CU,'" }) }}'),description:'{{ t("Execute workflow asynchronously or synchronously based on trigger type, and could not be changed after created.", { ns: "'.concat(O.CU,'" }) }}'),"x-decorator":"FormItem","x-component":"SyncOptionSelect","x-component-props":{options:[{label:'{{ t("Asynchronously", { ns: "'.concat(O.CU,'" }) }}'),value:!1,tooltip:'{{ t("Will be executed in the background as a queued task.", { ns: "'.concat(O.CU,'" }) }}')},{label:'{{ t("Synchronously", { ns: "'.concat(O.CU,'" }) }}'),value:!0,tooltip:'{{ t("For user actions that require immediate feedback. Can not use asynchronous nodes in such mode, and it is not recommended to perform time-consuming operations under synchronous mode.", { ns: "'.concat(O.CU,'" }) }}')}]}},triggerPreset:{type:"void","x-component":"TriggerPresetFieldset"},enabled:{"x-component":"CollectionField","x-decorator":"FormItem"},description:{"x-component":"CollectionField","x-decorator":"FormItem"},categories:{type:"array",title:'{{ t("Category", { ns: "'.concat(O.CU,'" }) }}'),"x-decorator":"FormItem","x-component":"CollectionField","x-collection-field":"workflows.categories"},options:{type:"object","x-decorator":"FormItem",title:'{{ t("Advance options", { ns: "'.concat(O.CU,'" }) }}'),"x-component":"Fieldset",properties:{timeout:{type:"number",title:'{{ t("Timeout settings", { ns: "'.concat(O.CU,'" }) }}'),description:'{{ t("0 means unlimited. If you set any other value and the execution is still not completed when the timeout is reached, the execution plan will be terminated and the remaining nodes will not be executed. Time spent in queue is not counted; timing starts only after it first enters a processor.", { ns: "'.concat(O.CU,'" }) }}'),"x-decorator":"FormItem","x-component":"TimeoutInput",default:0},stackLimit:{type:"number",title:'{{ t("Maximum number of cycling triggers", { ns: "'.concat(O.CU,'" }) }}'),description:'{{ t("The triggers of same workflow by some node (create, update and sub-flow etc.) more than this number will be ignored. Large number may cause performance issues. Please use with caution.", { ns: "'.concat(O.CU,'" }) }}'),"x-decorator":"FormItem",default:1,"x-component":"InputNumber","x-component-props":{min:1,precision:0,className:"auto-width"}},deleteExecutionOnStatus:{type:"array",title:'{{ t("Auto delete history when execution is on end status", { ns: "'.concat(O.CU,'" }) }}'),"x-decorator":"FormItem","x-component":"Select","x-component-props":{multiple:!0,optionRender:S.Qg,tagRender:S.lP},enum:C.$A.filter(function(e){return!!e.value})}}}},E={name:"workflow",type:"void",properties:{provider:{type:"void","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:A.A,resourceName:"workflows",request:{resource:"workflows",action:"list",params:{filter:{current:!0},sort:["-createdAt"],except:["config"]}}},"x-component":"CategoryTabs",properties:{main:{type:"void","x-component":"CardItem",properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{filter:{type:"void",title:'{{ t("Filter") }}',default:{$and:[{title:{$includes:""}}]},"x-action":"filter","x-component":"Filter.Action","x-use-component-props":"useResourceFilterActionProps","x-component-props":{icon:"FilterOutlined",nonfilterable:["id","description","categories"]},"x-align":"left"},refresher:{type:"void",title:'{{ t("Refresh") }}',"x-component":"Action","x-use-component-props":"useRefreshActionProps","x-component-props":{icon:"ReloadOutlined"}},sync:{type:"void",title:'{{t("Sync", { ns: "'.concat(O.CU,'" })}}'),"x-decorator":"Tooltip","x-decorator-props":{title:'{{ t("Sync enabled status of all workflows from database", { ns: "'.concat(O.CU,'" }) }}')},"x-component":"Action","x-component-props":{icon:"SyncOutlined",useAction:"{{ useSyncAction }}"},"x-reactions":["{{useWorkflowSyncReaction}}"]},delete:{type:"void",title:'{{t("Delete")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ cm.useBulkDestroyAction }}",confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},create:{type:"void",title:'{{t("Add new")}}',"x-component":"Action","x-component-props":{type:"primary",icon:"PlusOutlined"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{initialValue:{current:!0}},title:'{{t("Add new")}}',properties:{title:j.title,type:j.type,triggerPreset:j.triggerPreset,sync:j.sync,categories:j.categories,description:j.description,options:j.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useCreateAction }}"}}}}}}}}}},table:{type:"array","x-component":"Table.Void","x-component-props":{rowKey:"id",rowSelection:{type:"checkbox"},useDataSource:"{{cm.useDataSourceFromRAC }}"},properties:{title:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{ t("Title") }}',properties:{title:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},categories:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{ t("Category", { ns: "'.concat(O.CU,'" }) }}'),properties:{categories:{type:"array","x-component":"EnumerationField","x-component-props":{multiple:!0,fieldNames:{label:"title",value:"id",color:"color"}}}}},type:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{ t("Trigger type", { ns: "'.concat(O.CU,'" }) }}'),properties:{type:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},sync:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{ t("Execute mode", { ns: "'.concat(O.CU,'" }) }}'),properties:{sync:{type:"boolean","x-component":"CollectionField","x-read-pretty":!0}}},enabled:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{ t("Enabled", { ns: "'.concat(O.CU,'" }) }}'),properties:{enabled:{type:"boolean","x-component":"WorkflowEnabledSwitch",default:!1}}},"stats.executed":{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",title:'{{ t("Executed", { ns: "'.concat(O.CU,'" }) }}'),properties:{"stats.executed":{type:"number","x-decorator":"OpenDrawer","x-decorator-props":{component:function(e){var t=(0,s.useCollectionRecordData)();return c().createElement("a",P({"aria-label":"executed-".concat(t.title)},e))}},"x-component":"InputNumber","x-read-pretty":!0,properties:{drawer:w.M}}}},actions:{type:"void",title:'{{ t("Actions") }}',"x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{configure:{type:"void","x-component":"WorkflowLink"},update:{type:"void",title:'{{ t("Edit") }}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{ t("Edit") }}',properties:{title:j.title,type:(n=P({},j.type),o=o={"x-disabled":!0},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(o)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(o,e))}),n),sync:j.sync,categories:j.categories,description:j.description,options:j.options,footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ cm.useUpdateAction }}"}}}}}}}},revision:{type:"void",title:'{{t("Duplicate", { ns: "'.concat(O.CU,'" })}}'),"x-component":"Action.Link","x-component-props":{openSize:"small"},properties:{modal:{type:"void",title:'{{t("Duplicate to new workflow", { ns: "'.concat(O.CU,'" })}}'),"x-decorator":"FormV2","x-use-decorator-props":"useDuplicateWorkflowFormProps","x-component":"Action.Modal",properties:{title:j.title,description:j.description,footer:{type:"void","x-component":"Action.Modal.Footer",properties:{submit:{type:"void",title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useRevisionAction }}"}},cancel:{type:"void",title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}}}}}}}},delete:{type:"void",title:'{{ t("Delete") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete record')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{ cm.useDestroyActionAndRefreshCM }}"}}}}}}}}}}}}}},k=r(5324),F=r(9603),D=r(512);function T(e){var t=e.data,r=t.label,n=t.color,o=t.options,i=(0,s.useCompile)();return c().createElement(a.Space,{direction:"vertical"},c().createElement(a.Tag,{color:n},i(r)),c().createElement(a.Typography.Text,{type:"secondary",style:{whiteSpace:"normal"}},i(o.description)))}var I=r(7375),R=r(6799),U=r(166),V=r(6773);function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function N(e,t,r,n,o,i,c){try{var a=e[i](c),l=a.value}catch(e){r(e);return}a.done?t(l):Promise.resolve(l).then(n,o)}function q(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function c(e){N(i,n,o,c,a,"next",e)}function a(e){N(i,n,o,c,a,"throw",e)}c(void 0)})}}function L(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}function W(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}function $(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],c=!0,a=!1;try{for(o=o.call(e);!(c=(r=o.next()).done)&&(i.push(r.value),!t||i.length!==t);c=!0);}catch(e){a=!0,n=e}finally{try{c||null==o.return||o.return()}finally{if(a)throw n}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return M(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return M(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function B(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(c,"next",{value:l(0)}),a(c,"throw",{value:l(1)}),a(c,"return",{value:l(2)}),"function"==typeof Symbol&&a(c,Symbol.iterator,{value:function(){return this}}),c;function l(a){return function(l){var u=[a,l];if(r)throw TypeError("Generator is already executing.");for(;c&&(c=0,u[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,n=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function z(){var e,t,r=(e=["\n .ant-tabs-nav-list > :first-child {\n border: none;\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return z=function(){return r},r}function K(e){var t=(0,R.useDraggable)({id:e.id,data:e.data}),r=t.attributes,n=t.listeners,o=t.setNodeRef;return c().createElement("div",L({ref:o},n,r),c().createElement("div",null,e.children))}function _(e){var t=(0,R.useDroppable)({id:e.id,data:e.data}),r=t.isOver,n=t.setNodeRef;return c().createElement("div",{ref:n,style:r?{color:"green"}:void 0},e.children)}var G=(0,u.observer)(function(e){var t=e.item;return c().createElement(_,{id:t.id.toString(),data:t},c().createElement("div",null,c().createElement(K,{id:t.id.toString(),data:t},c().createElement(H,{item:t}))))},{displayName:"TabTitle"}),H=function(e){var t=e.item,r=(0,y.useTranslation)().t,n=(0,s.useCompile)();return c().createElement(a.Space,null,c().createElement(a.Badge,{color:t.color}),r(n(t.title)))},Q=(0,u.observer)(function(e){var t=$((0,i.useState)(null),2),r=t[0],n=t[1],o=(0,i.useContext)(Y).refresh,a=(0,s.useAPIClient)(),l=(0,R.useSensor)(R.MouseSensor,{activationConstraint:{distance:10}}),u=(0,R.useSensors)(l);return c().createElement(R.DndContext,{sensors:u,onDragEnd:function(e){return q(function(){var t,r;return B(this,function(i){switch(i.label){case 0:if(t=e.active,r=e.over,setTimeout(function(){n(null)}),!(r&&r.id!==t.id))return[3,2];return[4,a.resource("workflowCategories").move({sourceId:t.id,targetId:r.id})];case 1:i.sent(),o(),i.label=2;case 2:return[2]}})})()},onDragStart:function(e){var t;n(null==(t=e.active)?void 0:t.data.current)}},e.children,c().createElement(R.DragOverlay,null,r?c().createElement("span",{style:{whiteSpace:"nowrap"}},c().createElement(H,{item:r})):null))},{displayName:"DndProvider"}),Y=(0,i.createContext)({});function J(e){var t=e.values,r=e.onEdit,n=e.onRemove,o=(0,s.useCompile)(),l=(0,i.useCallback)(function(e){switch(e.key){case"edit":r(t);break;case"delete":n(t.id)}},[r,n,t]);return c().createElement(a.Dropdown,{menu:{items:[{key:"edit",label:(0,O.vV)("Edit category")},{key:"delete",label:(0,O.vV)("Delete category")}],onClick:l}},c().createElement(I.MenuOutlined,{role:"button","aria-label":o(t.title),style:{padding:8,margin:"-8px"}}))}function X(){var e,t=(0,s.useResourceActionContext)(),r=t.run,n=t.setState,o=t.defaultRequest,p=$((0,i.useState)({tab:"all"}),2),m=p[0],d=p[1],f=$((0,i.useState)(m.tab),2),y=f[0],b=f[1],v=(0,s.useCompile)(),g=(0,s.useAPIClient)(),h=(0,u.useFieldSchema)(),x=a.App.useApp().modal,w=(0,s.useRequest)({resource:"workflowCategories",action:"list",params:{paginate:!1,sort:["sort"]}}),C=w.data,A=w.refresh,S=$((0,i.useState)(!1),2),P=S[0],j=S[1],E=(0,i.useMemo)(function(){return(0,l.createForm)()},[]),k=(0,i.useCallback)(function(e){j(!0);var t=(0,V.cloneDeep)(e);E.setValues(t)},[E]),F=(0,i.useCallback)(function(){j(!1),E.reset()},[E]),D=(0,i.useCallback)(function(e){x.confirm({title:v("{{t('Delete category')}}"),content:v("{{t('Are you sure you want to delete it?')}}"),onOk:function(){return q(function(){return B(this,function(t){switch(t.label){case 0:return[4,g.resource("workflowCategories").destroy({filter:{id:e}})];case 1:return t.sent(),e===+m.tab&&d({tab:"all"}),A(),r(),[2]}})})()}})},[m.tab]),T=(0,i.useMemo)(function(){if(!(null==C?void 0:C.data))return[];var e=C.data.sort(function(e,t){return e.sort-t.sort}).concat().map(function(e){return W(L({},e),{schema:h.properties.main})});return e.find(function(e){return"all"===e.id})||e.unshift({title:'{{t("All", { ns: "'.concat(O.CU,'" })}}'),id:"all",sort:0,closable:!1,schema:h.properties.main}),e.map(function(e){return{label:"all"!==e.id?c().createElement("div",{"data-no-dnd":"true"},c().createElement(G,{item:e})):v(e.title),key:String(e.id),closable:e.closable,closeIcon:c().createElement(J,{values:e,onEdit:k,onRemove:D}),children:c().createElement(a.Card,{variant:"borderless",style:{borderRadius:"0 0.5em 0.5em 0.5em"}},c().createElement(u.RecursionField,{name:y,schema:e.schema,onlyRenderProperties:!0}))}})},[v,null==C?void 0:C.data,y,k,D,h.properties.main]),I=(0,i.useCallback)(function(e){if(d({tab:e}),b((0,U.uid)()),"all"!==e){var t,i={$and:[null==o||null==(t=o.params)?void 0:t.filter,{"categories.id":e}]};r({filter:i}),null==n||n({categories:[+e],params:[{filter:i}]})}else r(),null==n||n({categories:[],params:[]})},[null==o||null==(e=o.params)?void 0:e.filter,r,n]);return((0,i.useEffect)(function(){"all"!==m.tab&&I(m.tab)},[m.tab,I]),C)?c().createElement(Y.Provider,{value:{refresh:A}},c().createElement(Q,null,c().createElement(a.Tabs,{addIcon:c().createElement(s.SchemaComponent,{components:{AddCategory:er},schema:{type:"void",properties:{addCategories:{type:"void",title:'{{ t("Add category", { ns: "'.concat(O.CU,'" }) }}'),"x-component":"AddCategory","x-component-props":{type:"primary"}}}}}),onChange:I,defaultActiveKey:m.tab||"all",type:"editable-card",destroyInactiveTabPane:!0,tabBarStyle:{marginBottom:"0px"},className:(0,s.css)(z()),items:T})),c().createElement(s.ActionContextProvider,{value:{visible:P,setVisible:F,openSize:"small"}},c().createElement(s.SchemaComponent,{scope:{useFormProviderProps:ee,useCancelAction:s.useCancelAction,useEditSubmit:Z},schema:{name:(0,U.uid)(),type:"void","x-decorator":"FormV2","x-decorator-props":{form:E},title:'{{ t("Edit category", { ns: "'.concat(O.CU,'" }) }}'),"x-component":"Action.Modal","x-component-props":{delay:0},properties:{title:{type:"string",title:'{{t("Title")}}',required:!0,"x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useEditSubmit }}",style:{marginLeft:"8px"}}}}}}}}))):null}function Z(){var e=(0,u.useForm)(),t=(0,s.useActionContext)(),r=(0,s.useResourceActionContext)(),n=(0,i.useContext)(Y).refresh,o=(0,s.useAPIClient)();return{run:function(){return q(function(){var i;return B(this,function(c){switch(c.label){case 0:return[4,e.submit()];case 1:return c.sent(),[4,o.resource("workflowCategories").update({filterByTk:null==(i=e.values)?void 0:i.id,values:e.values})];case 2:return c.sent(),t.setVisible(!1),[4,e.reset()];case 3:return c.sent(),null==n||n(),null==r||r.refresh(),[2]}})})()}}}function ee(){return{form:(0,u.useForm)()}}function et(){var e=(0,u.useForm)(),t=(0,s.useActionContext)().setVisible,r=(0,i.useContext)(Y).refresh,n=(0,s.useAPIClient)();return{run:function(){return q(function(){var o;return B(this,function(i){switch(i.label){case 0:return[4,e.submit()];case 1:return i.sent(),o=(0,V.cloneDeep)(e.values),[4,n.resource("workflowCategories").create({values:o})];case 2:return i.sent(),t(!1),e.reset(),r(),[2]}})})()}}}function er(e){var t=$((0,i.useState)(!1),2),r=t[0],n=t[1],o=(0,y.useTranslation)().t,a=(0,i.useMemo)(function(){return(0,l.createForm)()},[]);return c().createElement(s.ActionContextProvider,{value:{visible:r,setVisible:n,openSize:"small"}},c().createElement("div",{onClick:function(){return n(!0)},title:o("Add category")},c().createElement(I.PlusOutlined,null)),c().createElement(s.SchemaComponent,{schema:{name:"modal",type:"void","x-decorator":"FormV2","x-decorator-props":{form:a},title:'{{ t("Add category") }}',"x-component":"Action.Modal","x-component-props":W(L({},e),{delay:0}),properties:{title:{type:"string",title:'{{t("Title")}}',required:!0,"x-decorator":"FormItem","x-component":"Input"},color:{type:"string",title:'{{t("Color")}}',required:!1,"x-decorator":"FormItem","x-component":"ColorSelect"},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-component-props":{useAction:"{{ useCancelAction }}"}},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useCreateSubmit }}",style:{marginLeft:"8px"}}}}}}},scope:{useCancelAction:s.useCancelAction,useCreateSubmit:et}}))}function en(e){var t=e.value,r=e.multiple,n=e.fieldNames,o=void 0===n?s.defaultFieldNames:n,i=(0,s.useCompile)();return(r?null!=t?t:[]:t?[t]:[]).map(function(e){return c().createElement(a.Tag,{key:e[o.value],color:e[o.color]},i(e[o.label]))})}var eo=r(2815);function ei(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var ec=[{value:1e3,label:"Seconds"},{value:6e4,label:"Minutes"},{value:36e5,label:"Hours"},{value:864e5,label:"Days"}];function ea(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:15552e6;return Math.min(Math.max(e,0),t)}function el(e){var t,r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6e4;return e&&null!=(t=null==(r=ec.findLast(function(t){return e%t.value==0}))?void 0:r.value)?t:n}var eu=(0,u.connect)(function(e){var t,r,n=ea(Number(null!=(r=e.value)?r:0)),o=function(e){if(Array.isArray(e))return e}(t=c().useState(function(){return el(n)}))||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],i=!0,c=!1;try{for(n=n.call(e);!(i=(t=n.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){c=!0,r=e}finally{try{i||null==n.return||n.return()}finally{if(c)throw r}}return o}}(t)||function(e){if(e){if("string"==typeof e)return ei(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return ei(e,2)}}(t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),i=o[0],l=o[1];c().useEffect(function(){0!==n&&l(function(e){return el(n,e)})},[n]);var u=0===n?0:n/i,s=15552e6/i;return c().createElement(a.Space.Compact,null,c().createElement(a.InputNumber,{min:0,max:s,precision:0,value:u,onChange:function(t){var r;return null==(r=e.onChange)?void 0:r.call(e,ea(Number(t)||0,s)*i)},className:"auto-width"}),c().createElement(a.Select,{value:i,options:ec.map(function(e){var t,r;return t=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},e),r=r={label:(0,O.vV)(e.label)},Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}),t}),onChange:function(t){var r,n,o=ea(Number(null!=(r=e.value)?r:0)),c=0===o?0:o/i;l(t),null==(n=e.onChange)||n.call(e,ea(c*t))},className:"auto-width"}))},(0,u.mapProps)(function(e){return e}),(0,u.mapReadPretty)(function(e){var t,r=Number(null!=(t=e.value)?t:0);if(0===r)return c().createElement(c().Fragment,null,(0,O.vV)("Unlimited"));var n=el(r),o=ec.find(function(e){return e.value===n});return c().createElement(c().Fragment,null,r/n," ",o?(0,O.vV)(o.label):"")}));function es(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function ep(e,t,r,n,o,i,c){try{var a=e[i](c),l=a.value}catch(e){r(e);return}a.done?t(l):Promise.resolve(l).then(n,o)}function em(e){return function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function c(e){ep(i,n,o,c,a,"next",e)}function a(e){ep(i,n,o,c,a,"throw",e)}c(void 0)})}}function ed(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],c=!0,a=!1;try{for(o=o.call(e);!(c=(r=o.next()).done)&&(i.push(r.value),!t||i.length!==t);c=!0);}catch(e){a=!0,n=e}finally{try{c||null==o.return||o.return()}finally{if(a)throw n}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return es(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return es(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ef(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(c,"next",{value:l(0)}),a(c,"throw",{value:l(1)}),a(c,"return",{value:l(2)}),"function"==typeof Symbol&&a(c,Symbol.iterator,{value:function(){return this}}),c;function l(a){return function(l){var u=[a,l];if(r)throw TypeError("Generator is already executing.");for(;c&&(c=0,u[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,n=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function ey(e){var t=(0,u.useField)(),r=(0,s.useRecord)(),n=(0,s.usePlugin)(k.default);return(0,u.useFormEffects)(function(e){(0,l.onFieldChange)("type",function(e){var o=r.id||!e.value;if(e.value){var i=n.triggers.get(e.value);null!=i.sync?(o=!0,t.setValue(i.sync)):t.setInitialValue(!1)}t.setPattern(o?"disabled":"editable")})}),(0,i.useEffect)(function(){if(r.id){t.setPattern("disabled");var o,i=n.triggers.get(r.type);null!=i.sync?t.setValue(i.sync):t.setInitialValue(null!=(o=e.value)&&o)}},[r.id,t,n.triggers,r.type,e.value]),c().createElement(F.$i,e)}function eb(e){var t=(0,s.useApp)();e.visible=!!((0,s.usePlugin)("multi-app-share-collection")||"main"!==t.name)}function ev(){var e=a.App.useApp().message,t=(0,y.useTranslation)().t,r=(0,s.useResourceContext)().resource;return{run:function(){return em(function(){return ef(this,function(n){switch(n.label){case 0:return[4,r.sync()];case 1:return n.sent(),e.success(t("Operation succeeded")),[2]}})})()}}}function eg(){var e=a.App.useApp().message,t=(0,y.useTranslation)().t,r=(0,s.useResourceActionContext)().refresh,n=(0,s.useResourceContext)(),o=n.resource,i=n.targetKey,c=(0,s.useActionContext)().setVisible,l=(0,s.useRecord)()[i],p=(0,u.useForm)(),m=(0,u.useField)();return{run:function(){return em(function(){return ef(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,4,5]),[4,p.submit()];case 1:return n.sent(),m.data=m.data||{},m.data.loading=!0,[4,o.revision({filterByTk:l,values:p.values})];case 2:return n.sent(),e.success(t("Operation succeeded")),r(),c(!1),[3,5];case 3:return console.error(n.sent()),[3,5];case 4:return m.data&&(m.data.loading=!1),[7];case 5:return[2]}})})()}}}function eh(e){var t,r;return{title:null!=(t=e.title)?t:"",description:null!=(r=e.description)?r:""}}function ex(){var e,t=null!=(e=(0,s.useRecord)())?e:{},r=t.title,n=t.description,o=(0,s.useActionContext)(),c=o.visible,a=o.setFormValueChanged,u=(0,i.useMemo)(function(){return(0,l.createForm)({initialValues:eh({title:r,description:n})})},[n,r]);return(0,i.useEffect)(function(){if(c){var e=eh({title:r,description:n});u.setInitialValues(e),u.setValues(e),u.reset(),null==a||a(!1)}},[n,u,a,r,c]),{form:u}}function eO(){var e=(0,s.usePlugin)(k.default),t=ed((0,i.useState)(null),2),r=t[0],n=t[1],o=(0,u.useForm)();(0,u.useFormEffects)(function(){(0,l.onFieldValueChange)("type",function(e){var t;n(null!=(t=e.value)?t:null),o.clearFormGraph("config.*")})});var a=r?e.triggers.get(r):null;return(null==a?void 0:a.presetFieldset)?c().createElement(s.SchemaComponent,{key:r,components:a.components,scope:a.scope,schema:{type:"void",properties:{config:{type:"object","x-decorator":"FormItem",title:'{{t("Trigger configuration", { ns: "'.concat(O.CU,'" })}}'),"x-component":"Fieldset",properties:a.presetFieldset}}}}):null}function ew(){var e=a.App.useApp().message,t=(0,y.useTranslation)().t,r=(0,s.useRecord)(),n=(0,s.useResourceContext)().resource,o=(0,s.useResourceActionContext)().refresh,l=ed((0,i.useState)(!1),2),u=l[0],p=l[1],m=(0,i.useCallback)(function(i){return em(function(){return ef(this,function(c){switch(c.label){case 0:if(!(null==r?void 0:r.id))return[2];p(!0),c.label=1;case 1:return c.trys.push([1,3,4,5]),[4,n.update({filterByTk:r.id,values:{enabled:i}})];case 2:return c.sent(),setTimeout(function(){return null==o?void 0:o()},0),[3,5];case 3:return console.error(c.sent()),e.error(t("Operation failed")),[3,5];case 4:return p(!1),[7];case 5:return[2]}})})()},[e,r,o,n,t]);return c().createElement(a.Switch,{checked:!!(null==r?void 0:r.enabled),size:"small",disabled:u||!(null==r?void 0:r.id),loading:u,onClick:function(e,t){var r;return null==t||null==(r=t.stopPropagation)?void 0:r.call(t)},onChange:m})}function eC(){var e,t,r=(0,i.useContext)(s.SchemaComponentContext),n=(0,s.usePlugin)(k.default).useTriggersOptions;return c().createElement(s.SchemaComponentContext.Provider,{value:(e=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({},r),t=t={designable:!1},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t.push.apply(t,r)}return t})(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e)},c().createElement(s.SchemaComponent,{schema:E,components:{CollectionProvider:s.CollectionProvider,WorkflowLink:g,ExecutionResourceProvider:f,ExecutionLink:p.d,OpenDrawer:x,SyncOptionSelect:ey,ExecutionStatusColumn:S.t_,Tooltip:a.Tooltip,CategoryTabs:X,EnumerationField:en,WorkflowEnabledSwitch:ew,TriggerPresetFieldset:eO,TimeoutInput:eu},scope:{useTriggersOptions:n,useWorkflowSyncReaction:eb,useSyncAction:ev,useResourceFilterActionProps:eo.A,useRefreshActionProps:D.t,useRevisionAction:eg,useDuplicateWorkflowFormProps:ex,TriggerOptionRender:T,ExecutionStatusOptions:C.$A}}))}}}]);
|