@nocobase/plugin-flow-engine 2.1.0-alpha.18 → 2.1.0-alpha.19
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/dist/externalVersion.js +11 -11
- package/dist/node_modules/ses/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/flow-surfaces/action-scope.js +3 -1
- package/dist/server/flow-surfaces/apply/compiler.js +84 -5
- package/dist/server/flow-surfaces/approval/blueprint-service.d.ts +84 -0
- package/dist/server/flow-surfaces/approval/blueprint-service.js +589 -0
- package/dist/server/flow-surfaces/approval/blueprint.d.ts +21 -0
- package/dist/server/flow-surfaces/approval/blueprint.js +190 -0
- package/dist/server/flow-surfaces/approval/builder.d.ts +225 -0
- package/dist/server/flow-surfaces/approval/builder.js +384 -0
- package/dist/server/flow-surfaces/approval/catalog-specs.d.ts +33 -0
- package/dist/server/flow-surfaces/approval/catalog-specs.js +156 -0
- package/dist/server/flow-surfaces/approval/index.d.ts +14 -0
- package/dist/server/flow-surfaces/approval/index.js +40 -0
- package/dist/server/flow-surfaces/approval/runtime-config.d.ts +44 -0
- package/dist/server/flow-surfaces/approval/runtime-config.js +299 -0
- package/dist/server/flow-surfaces/approval/semantic-use.d.ts +23 -0
- package/dist/server/flow-surfaces/approval/semantic-use.js +155 -0
- package/dist/server/flow-surfaces/blueprint/compile-blocks.js +36 -2
- package/dist/server/flow-surfaces/blueprint/public-types.d.ts +7 -0
- package/dist/server/flow-surfaces/builder.d.ts +2 -0
- package/dist/server/flow-surfaces/builder.js +83 -10
- package/dist/server/flow-surfaces/catalog.d.ts +10 -0
- package/dist/server/flow-surfaces/catalog.js +368 -9
- package/dist/server/flow-surfaces/chart-config.d.ts +1 -1
- package/dist/server/flow-surfaces/compose-compiler.d.ts +1 -0
- package/dist/server/flow-surfaces/compose-compiler.js +2 -1
- package/dist/server/flow-surfaces/configure-options.js +61 -3
- package/dist/server/flow-surfaces/constants.d.ts +342 -5
- package/dist/server/flow-surfaces/constants.js +59 -125
- package/dist/server/flow-surfaces/default-action-popup.d.ts +1 -0
- package/dist/server/flow-surfaces/default-action-popup.js +6 -2
- package/dist/server/flow-surfaces/field-semantics.js +2 -1
- package/dist/server/flow-surfaces/index.js +21 -273
- package/dist/server/flow-surfaces/locator.js +8 -6
- package/dist/server/flow-surfaces/node-use-sets.js +15 -3
- package/dist/server/flow-surfaces/placement.js +11 -7
- package/dist/server/flow-surfaces/planning/action-specs.d.ts +1 -1
- package/dist/server/flow-surfaces/planning/compiler.d.ts +1 -1
- package/dist/server/flow-surfaces/planning/key-kind.js +7 -5
- package/dist/server/flow-surfaces/reaction/registry.d.ts +13 -0
- package/dist/server/flow-surfaces/reaction/registry.js +13 -0
- package/dist/server/flow-surfaces/service-utils.d.ts +10 -14
- package/dist/server/flow-surfaces/service-utils.js +4 -2
- package/dist/server/flow-surfaces/service.d.ts +63 -1
- package/dist/server/flow-surfaces/service.js +1058 -109
- package/dist/server/flow-surfaces/surface-context.d.ts +1 -0
- package/dist/server/flow-surfaces/surface-context.js +99 -19
- package/dist/server/flow-surfaces/types.d.ts +4 -1
- package/dist/swagger/flow-surfaces.d.ts +406 -2
- package/dist/swagger/flow-surfaces.examples.d.ts +164 -0
- package/dist/swagger/flow-surfaces.examples.js +184 -0
- package/dist/swagger/flow-surfaces.js +390 -76
- package/dist/swagger/index.d.ts +406 -2
- package/package.json +2 -2
|
@@ -0,0 +1,299 @@
|
|
|
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 runtime_config_exports = {};
|
|
38
|
+
__export(runtime_config_exports, {
|
|
39
|
+
APPROVAL_SINGLETON_ACTION_USES: () => APPROVAL_SINGLETON_ACTION_USES,
|
|
40
|
+
APPROVAL_SURFACE_ROOT_USES: () => APPROVAL_SURFACE_ROOT_USES,
|
|
41
|
+
FlowSurfaceApprovalRuntimeConfigService: () => FlowSurfaceApprovalRuntimeConfigService
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(runtime_config_exports);
|
|
44
|
+
var import_lodash = __toESM(require("lodash"));
|
|
45
|
+
var import_service_utils = require("../service-utils");
|
|
46
|
+
var import_errors = require("../errors");
|
|
47
|
+
const APPROVAL_SURFACE_ROOT_USES = /* @__PURE__ */ new Set([
|
|
48
|
+
"TriggerChildPageModel",
|
|
49
|
+
"ApprovalChildPageModel",
|
|
50
|
+
"ApplyTaskCardDetailsModel",
|
|
51
|
+
"ApprovalTaskCardDetailsModel"
|
|
52
|
+
]);
|
|
53
|
+
const APPROVAL_SINGLETON_ACTION_USES = /* @__PURE__ */ new Set([
|
|
54
|
+
"ApplyFormSubmitModel",
|
|
55
|
+
"ApplyFormSaveDraftModel",
|
|
56
|
+
"ApplyFormWithdrawModel",
|
|
57
|
+
"ProcessFormApproveModel",
|
|
58
|
+
"ProcessFormRejectModel",
|
|
59
|
+
"ProcessFormReturnModel",
|
|
60
|
+
"ProcessFormDelegateModel",
|
|
61
|
+
"ProcessFormAddAssigneeModel"
|
|
62
|
+
]);
|
|
63
|
+
const APPROVAL_PROCESS_ACTION_STATUS_BY_USE = {
|
|
64
|
+
ProcessFormApproveModel: 2,
|
|
65
|
+
ProcessFormRejectModel: -1,
|
|
66
|
+
ProcessFormReturnModel: 1,
|
|
67
|
+
ProcessFormDelegateModel: 8,
|
|
68
|
+
ProcessFormAddAssigneeModel: 99
|
|
69
|
+
};
|
|
70
|
+
const APPROVAL_PROCESS_ACTION_STATUS_ORDER = [2, -1, 1, 8, 99];
|
|
71
|
+
class FlowSurfaceApprovalRuntimeConfigService {
|
|
72
|
+
constructor(deps) {
|
|
73
|
+
this.deps = deps;
|
|
74
|
+
}
|
|
75
|
+
getRepositoryIfAvailable(resourceName) {
|
|
76
|
+
try {
|
|
77
|
+
return this.deps.db.getRepository(resourceName);
|
|
78
|
+
} catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
readModelField(model, fieldName) {
|
|
83
|
+
var _a;
|
|
84
|
+
return ((_a = model == null ? void 0 : model.get) == null ? void 0 : _a.call(model, fieldName)) ?? (model == null ? void 0 : model[fieldName]);
|
|
85
|
+
}
|
|
86
|
+
readApprovalConfig(model) {
|
|
87
|
+
return import_lodash.default.cloneDeep(this.readModelField(model, "config") || {});
|
|
88
|
+
}
|
|
89
|
+
collectApprovalActionNodes(node, carry = []) {
|
|
90
|
+
if (!(node == null ? void 0 : node.uid)) {
|
|
91
|
+
return carry;
|
|
92
|
+
}
|
|
93
|
+
if (APPROVAL_SINGLETON_ACTION_USES.has(node.use || "")) {
|
|
94
|
+
carry.push(node);
|
|
95
|
+
}
|
|
96
|
+
Object.values(node.subModels || {}).forEach((subModel) => {
|
|
97
|
+
import_lodash.default.castArray(subModel).forEach((child) => this.collectApprovalActionNodes(child, carry));
|
|
98
|
+
});
|
|
99
|
+
return carry;
|
|
100
|
+
}
|
|
101
|
+
async findApprovalSurfaceRootForNode(uid, transaction) {
|
|
102
|
+
let cursor = String(uid || "").trim();
|
|
103
|
+
const visited = /* @__PURE__ */ new Set();
|
|
104
|
+
while (cursor && !visited.has(cursor)) {
|
|
105
|
+
visited.add(cursor);
|
|
106
|
+
const node = await this.deps.repository.findModelById(cursor, {
|
|
107
|
+
transaction,
|
|
108
|
+
includeAsyncNode: true
|
|
109
|
+
});
|
|
110
|
+
if (!(node == null ? void 0 : node.uid)) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
if (APPROVAL_SURFACE_ROOT_USES.has(node.use || "")) {
|
|
114
|
+
return node;
|
|
115
|
+
}
|
|
116
|
+
cursor = String(
|
|
117
|
+
node.parentId || await this.deps.locator.findParentUid(node.uid, transaction).catch(() => "") || ""
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
async findApprovalWorkflowBySurfaceRootUid(rootUid, transaction) {
|
|
123
|
+
const workflowsRepository = this.getRepositoryIfAvailable("workflows");
|
|
124
|
+
if (!workflowsRepository) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
const workflows = await workflowsRepository.find({
|
|
128
|
+
filter: {
|
|
129
|
+
type: "approval"
|
|
130
|
+
},
|
|
131
|
+
transaction
|
|
132
|
+
});
|
|
133
|
+
return workflows.find((workflow) => this.readApprovalConfig(workflow).approvalUid === rootUid) || null;
|
|
134
|
+
}
|
|
135
|
+
async findApprovalNodeBySurfaceRootUid(rootUid, transaction) {
|
|
136
|
+
const nodesRepository = this.getRepositoryIfAvailable("flow_nodes");
|
|
137
|
+
if (!nodesRepository) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
const nodes = await nodesRepository.find({
|
|
141
|
+
filter: {
|
|
142
|
+
type: "approval"
|
|
143
|
+
},
|
|
144
|
+
transaction
|
|
145
|
+
});
|
|
146
|
+
return nodes.find((node) => this.readApprovalConfig(node).approvalUid === rootUid) || null;
|
|
147
|
+
}
|
|
148
|
+
async patchApprovalRuntimeConfig(resourceName, model, nextConfig, transaction) {
|
|
149
|
+
const currentConfig = this.readApprovalConfig(model);
|
|
150
|
+
if (import_lodash.default.isEqual(currentConfig, nextConfig)) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
await this.deps.db.getRepository(resourceName).update({
|
|
154
|
+
filterByTk: this.readModelField(model, "id"),
|
|
155
|
+
values: {
|
|
156
|
+
config: nextConfig
|
|
157
|
+
},
|
|
158
|
+
transaction
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
getApprovalActionStepValue(actionNode, fieldName) {
|
|
162
|
+
const clickSettings = import_lodash.default.get(actionNode, ["stepParams", "clickSettings"]);
|
|
163
|
+
return import_lodash.default.get(clickSettings, ["saveResource", fieldName]) ?? import_lodash.default.get(clickSettings, fieldName);
|
|
164
|
+
}
|
|
165
|
+
buildApprovalReturnRuntimeConfig(actionNode) {
|
|
166
|
+
const settings = this.getApprovalActionStepValue(actionNode, "approvalReturnNodeSettings") || {};
|
|
167
|
+
const type = String((settings == null ? void 0 : settings.type) || "start").trim();
|
|
168
|
+
if (type === "any") {
|
|
169
|
+
return {
|
|
170
|
+
returnTo: -1,
|
|
171
|
+
returnToNodeVariable: null
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
if (type === "count") {
|
|
175
|
+
const count = Number(settings == null ? void 0 : settings.count);
|
|
176
|
+
return {
|
|
177
|
+
returnTo: Number.isFinite(count) && count > 0 ? count : 1,
|
|
178
|
+
returnToNodeVariable: null
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
if (type === "specific") {
|
|
182
|
+
const target = String((settings == null ? void 0 : settings.target) || "").trim();
|
|
183
|
+
return {
|
|
184
|
+
returnTo: target || null,
|
|
185
|
+
returnToNodeVariable: target ? `{{$jobsMapByNodeKey.${target}}}` : null
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
returnTo: null,
|
|
190
|
+
returnToNodeVariable: null
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
buildApprovalReassignRuntimeConfig(actionNode) {
|
|
194
|
+
const assigneesScope = this.getApprovalActionStepValue(actionNode, "assigneesScope") || {};
|
|
195
|
+
const assignees = import_lodash.default.castArray((assigneesScope == null ? void 0 : assigneesScope.assignees) || []).filter((item) => !import_lodash.default.isUndefined(item) && !import_lodash.default.isNull(item) && item !== "").map(
|
|
196
|
+
(item) => import_lodash.default.isPlainObject(item) && !Object.prototype.hasOwnProperty.call(item, "filter") ? { filter: item } : item
|
|
197
|
+
);
|
|
198
|
+
return {
|
|
199
|
+
assignees,
|
|
200
|
+
options: (0, import_service_utils.buildDefinedPayload)({
|
|
201
|
+
extraFieldKey: assigneesScope == null ? void 0 : assigneesScope.extraFieldKey
|
|
202
|
+
})
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
async syncApprovalWorkflowRuntimeConfig(root, transaction) {
|
|
206
|
+
const workflow = await this.findApprovalWorkflowBySurfaceRootUid(root.uid, transaction);
|
|
207
|
+
if (!workflow) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const currentConfig = this.readApprovalConfig(workflow);
|
|
211
|
+
const actions = this.collectApprovalActionNodes(root);
|
|
212
|
+
await this.patchApprovalRuntimeConfig(
|
|
213
|
+
"workflows",
|
|
214
|
+
workflow,
|
|
215
|
+
{
|
|
216
|
+
...currentConfig,
|
|
217
|
+
withdrawable: actions.some((action) => action.use === "ApplyFormWithdrawModel")
|
|
218
|
+
},
|
|
219
|
+
transaction
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
async syncApprovalNodeRuntimeConfig(root, transaction) {
|
|
223
|
+
const node = await this.findApprovalNodeBySurfaceRootUid(root.uid, transaction);
|
|
224
|
+
if (!node) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const currentConfig = this.readApprovalConfig(node);
|
|
228
|
+
const actionNodes = this.collectApprovalActionNodes(root);
|
|
229
|
+
const statusSet = new Set(
|
|
230
|
+
actionNodes.map((action) => APPROVAL_PROCESS_ACTION_STATUS_BY_USE[action.use || ""]).filter((status) => !import_lodash.default.isUndefined(status))
|
|
231
|
+
);
|
|
232
|
+
const nextConfig = {
|
|
233
|
+
...currentConfig,
|
|
234
|
+
actions: APPROVAL_PROCESS_ACTION_STATUS_ORDER.filter((status) => statusSet.has(status))
|
|
235
|
+
};
|
|
236
|
+
const returnAction = actionNodes.find((action) => action.use === "ProcessFormReturnModel");
|
|
237
|
+
Object.assign(
|
|
238
|
+
nextConfig,
|
|
239
|
+
returnAction ? this.buildApprovalReturnRuntimeConfig(returnAction) : {
|
|
240
|
+
returnTo: null,
|
|
241
|
+
returnToNodeVariable: null
|
|
242
|
+
}
|
|
243
|
+
);
|
|
244
|
+
const delegateAction = actionNodes.find((action) => action.use === "ProcessFormDelegateModel");
|
|
245
|
+
const delegateConfig = delegateAction ? this.buildApprovalReassignRuntimeConfig(delegateAction) : null;
|
|
246
|
+
nextConfig.toDelegateReassignees = (delegateConfig == null ? void 0 : delegateConfig.assignees) || [];
|
|
247
|
+
nextConfig.toDelegateReassigneesOptions = (delegateConfig == null ? void 0 : delegateConfig.options) || {};
|
|
248
|
+
const addAssigneeAction = actionNodes.find((action) => action.use === "ProcessFormAddAssigneeModel");
|
|
249
|
+
const addAssigneeConfig = addAssigneeAction ? this.buildApprovalReassignRuntimeConfig(addAssigneeAction) : null;
|
|
250
|
+
nextConfig.toAddReassignees = (addAssigneeConfig == null ? void 0 : addAssigneeConfig.assignees) || [];
|
|
251
|
+
nextConfig.toAddReassigneesOptions = (addAssigneeConfig == null ? void 0 : addAssigneeConfig.options) || {};
|
|
252
|
+
await this.patchApprovalRuntimeConfig("flow_nodes", node, nextConfig, transaction);
|
|
253
|
+
}
|
|
254
|
+
async syncApprovalRuntimeConfigForSurfaceRoot(root, transaction) {
|
|
255
|
+
if (!(root == null ? void 0 : root.uid)) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const currentRoot = await this.deps.repository.findModelById(root.uid, {
|
|
259
|
+
transaction,
|
|
260
|
+
includeAsyncNode: true
|
|
261
|
+
});
|
|
262
|
+
if (!(currentRoot == null ? void 0 : currentRoot.uid)) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (currentRoot.use === "TriggerChildPageModel") {
|
|
266
|
+
await this.syncApprovalWorkflowRuntimeConfig(currentRoot, transaction);
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (currentRoot.use === "ApprovalChildPageModel") {
|
|
270
|
+
await this.syncApprovalNodeRuntimeConfig(currentRoot, transaction);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
async syncApprovalRuntimeConfigForNode(uid, transaction) {
|
|
274
|
+
const root = await this.findApprovalSurfaceRootForNode(uid, transaction);
|
|
275
|
+
if (root) {
|
|
276
|
+
await this.syncApprovalRuntimeConfigForSurfaceRoot(root, transaction);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
async assertApprovalActionSingleton(parentUid, actionUse, transaction) {
|
|
280
|
+
var _a;
|
|
281
|
+
if (!APPROVAL_SINGLETON_ACTION_USES.has(actionUse)) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
const parent = await this.deps.repository.findModelById(parentUid, {
|
|
285
|
+
transaction,
|
|
286
|
+
includeAsyncNode: true
|
|
287
|
+
});
|
|
288
|
+
const existing = import_lodash.default.castArray(((_a = parent == null ? void 0 : parent.subModels) == null ? void 0 : _a.actions) || []).find((action) => (action == null ? void 0 : action.use) === actionUse);
|
|
289
|
+
if (existing == null ? void 0 : existing.uid) {
|
|
290
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces addAction approval action '${actionUse}' already exists in '${parent.use}'`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
295
|
+
0 && (module.exports = {
|
|
296
|
+
APPROVAL_SINGLETON_ACTION_USES,
|
|
297
|
+
APPROVAL_SURFACE_ROOT_USES,
|
|
298
|
+
FlowSurfaceApprovalRuntimeConfigService
|
|
299
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export declare const APPROVAL_PAGE_MODEL_USES: readonly ["TriggerChildPageModel", "ApprovalChildPageModel"];
|
|
10
|
+
export declare const APPROVAL_TAB_MODEL_USES: readonly ["TriggerChildPageTabModel", "ApprovalChildPageTabModel"];
|
|
11
|
+
export declare const APPROVAL_BLOCK_GRID_USES: readonly ["TriggerBlockGridModel", "ApprovalBlockGridModel"];
|
|
12
|
+
export declare const APPROVAL_FORM_GRID_USES: readonly ["PatternFormGridModel"];
|
|
13
|
+
export declare const APPROVAL_TASK_CARD_GRID_USES: readonly ["ApplyTaskCardGridModel", "ApprovalTaskCardGridModel"];
|
|
14
|
+
export declare const APPROVAL_DETAILS_GRID_USES: readonly ["ApprovalDetailsGridModel", "ApplyTaskCardGridModel", "ApprovalTaskCardGridModel"];
|
|
15
|
+
export declare const APPROVAL_FORM_BLOCK_USES: readonly ["ApplyFormModel", "ProcessFormModel"];
|
|
16
|
+
export declare const APPROVAL_DETAILS_BLOCK_USES: readonly ["ApprovalDetailsModel", "ApplyTaskCardDetailsModel", "ApprovalTaskCardDetailsModel"];
|
|
17
|
+
export declare const APPROVAL_FIELD_WRAPPER_USES: readonly ["PatternFormItemModel", "ApprovalDetailsItemModel", "ApplyTaskCardDetailsItemModel", "ApprovalTaskCardDetailsItemModel"];
|
|
18
|
+
export declare const APPROVAL_ACTION_CONTAINER_USES: readonly ["ApplyFormModel", "ProcessFormModel"];
|
|
19
|
+
export declare function normalizeApprovalSemanticUse(use?: string): string;
|
|
20
|
+
export declare function getApprovalDefaultGridUse(use?: string): string;
|
|
21
|
+
export declare function getApprovalFieldWrapperUse(containerUse?: string): string;
|
|
22
|
+
export declare function isApprovalFormContainerUse(use?: string): boolean;
|
|
23
|
+
export declare function isApprovalTaskCardGridUse(use?: string): boolean;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
27
|
+
var semantic_use_exports = {};
|
|
28
|
+
__export(semantic_use_exports, {
|
|
29
|
+
APPROVAL_ACTION_CONTAINER_USES: () => APPROVAL_ACTION_CONTAINER_USES,
|
|
30
|
+
APPROVAL_BLOCK_GRID_USES: () => APPROVAL_BLOCK_GRID_USES,
|
|
31
|
+
APPROVAL_DETAILS_BLOCK_USES: () => APPROVAL_DETAILS_BLOCK_USES,
|
|
32
|
+
APPROVAL_DETAILS_GRID_USES: () => APPROVAL_DETAILS_GRID_USES,
|
|
33
|
+
APPROVAL_FIELD_WRAPPER_USES: () => APPROVAL_FIELD_WRAPPER_USES,
|
|
34
|
+
APPROVAL_FORM_BLOCK_USES: () => APPROVAL_FORM_BLOCK_USES,
|
|
35
|
+
APPROVAL_FORM_GRID_USES: () => APPROVAL_FORM_GRID_USES,
|
|
36
|
+
APPROVAL_PAGE_MODEL_USES: () => APPROVAL_PAGE_MODEL_USES,
|
|
37
|
+
APPROVAL_TAB_MODEL_USES: () => APPROVAL_TAB_MODEL_USES,
|
|
38
|
+
APPROVAL_TASK_CARD_GRID_USES: () => APPROVAL_TASK_CARD_GRID_USES,
|
|
39
|
+
getApprovalDefaultGridUse: () => getApprovalDefaultGridUse,
|
|
40
|
+
getApprovalFieldWrapperUse: () => getApprovalFieldWrapperUse,
|
|
41
|
+
isApprovalFormContainerUse: () => isApprovalFormContainerUse,
|
|
42
|
+
isApprovalTaskCardGridUse: () => isApprovalTaskCardGridUse,
|
|
43
|
+
normalizeApprovalSemanticUse: () => normalizeApprovalSemanticUse
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(semantic_use_exports);
|
|
46
|
+
const APPROVAL_PAGE_MODEL_USES = ["TriggerChildPageModel", "ApprovalChildPageModel"];
|
|
47
|
+
const APPROVAL_TAB_MODEL_USES = ["TriggerChildPageTabModel", "ApprovalChildPageTabModel"];
|
|
48
|
+
const APPROVAL_BLOCK_GRID_USES = ["TriggerBlockGridModel", "ApprovalBlockGridModel"];
|
|
49
|
+
const APPROVAL_FORM_GRID_USES = ["PatternFormGridModel"];
|
|
50
|
+
const APPROVAL_TASK_CARD_GRID_USES = ["ApplyTaskCardGridModel", "ApprovalTaskCardGridModel"];
|
|
51
|
+
const APPROVAL_DETAILS_GRID_USES = ["ApprovalDetailsGridModel", ...APPROVAL_TASK_CARD_GRID_USES];
|
|
52
|
+
const APPROVAL_FORM_BLOCK_USES = ["ApplyFormModel", "ProcessFormModel"];
|
|
53
|
+
const APPROVAL_DETAILS_BLOCK_USES = [
|
|
54
|
+
"ApprovalDetailsModel",
|
|
55
|
+
"ApplyTaskCardDetailsModel",
|
|
56
|
+
"ApprovalTaskCardDetailsModel"
|
|
57
|
+
];
|
|
58
|
+
const APPROVAL_FIELD_WRAPPER_USES = [
|
|
59
|
+
"PatternFormItemModel",
|
|
60
|
+
"ApprovalDetailsItemModel",
|
|
61
|
+
"ApplyTaskCardDetailsItemModel",
|
|
62
|
+
"ApprovalTaskCardDetailsItemModel"
|
|
63
|
+
];
|
|
64
|
+
const APPROVAL_ACTION_CONTAINER_USES = ["ApplyFormModel", "ProcessFormModel"];
|
|
65
|
+
const APPROVAL_FORM_CONTAINER_USE_SET = /* @__PURE__ */ new Set([
|
|
66
|
+
...APPROVAL_FORM_BLOCK_USES,
|
|
67
|
+
...APPROVAL_FORM_GRID_USES,
|
|
68
|
+
"PatternFormItemModel"
|
|
69
|
+
]);
|
|
70
|
+
const APPROVAL_SEMANTIC_USE_ALIASES = {
|
|
71
|
+
TriggerChildPageModel: "ChildPageModel",
|
|
72
|
+
ApprovalChildPageModel: "ChildPageModel",
|
|
73
|
+
TriggerChildPageTabModel: "ChildPageTabModel",
|
|
74
|
+
ApprovalChildPageTabModel: "ChildPageTabModel",
|
|
75
|
+
TriggerBlockGridModel: "BlockGridModel",
|
|
76
|
+
ApprovalBlockGridModel: "BlockGridModel",
|
|
77
|
+
PatternFormGridModel: "FormGridModel",
|
|
78
|
+
ApprovalDetailsGridModel: "DetailsGridModel",
|
|
79
|
+
ApplyTaskCardGridModel: "DetailsGridModel",
|
|
80
|
+
ApprovalTaskCardGridModel: "DetailsGridModel",
|
|
81
|
+
ApplyFormModel: "FormBlockModel",
|
|
82
|
+
ProcessFormModel: "FormBlockModel",
|
|
83
|
+
ApprovalDetailsModel: "DetailsBlockModel",
|
|
84
|
+
ApplyTaskCardDetailsModel: "DetailsBlockModel",
|
|
85
|
+
ApprovalTaskCardDetailsModel: "DetailsBlockModel",
|
|
86
|
+
PatternFormItemModel: "FormItemModel",
|
|
87
|
+
ApprovalDetailsItemModel: "DetailsItemModel",
|
|
88
|
+
ApplyTaskCardDetailsItemModel: "DetailsItemModel",
|
|
89
|
+
ApprovalTaskCardDetailsItemModel: "DetailsItemModel",
|
|
90
|
+
PatternFormAssociationFieldGroupModel: "FormAssociationFieldGroupModel",
|
|
91
|
+
ApprovalDetailsAssociationFieldGroupModel: "DetailsAssociationFieldGroupModel",
|
|
92
|
+
ApplyTaskCardDetailsAssociationFieldGroupModel: "DetailsAssociationFieldGroupModel",
|
|
93
|
+
ApprovalTaskCardDetailsAssociationFieldGroupModel: "DetailsAssociationFieldGroupModel"
|
|
94
|
+
};
|
|
95
|
+
const APPROVAL_DEFAULT_GRID_USE_BY_OWNER_USE = {
|
|
96
|
+
TriggerChildPageTabModel: "TriggerBlockGridModel",
|
|
97
|
+
ApprovalChildPageTabModel: "ApprovalBlockGridModel",
|
|
98
|
+
ApplyFormModel: "PatternFormGridModel",
|
|
99
|
+
ProcessFormModel: "PatternFormGridModel",
|
|
100
|
+
ApprovalDetailsModel: "ApprovalDetailsGridModel",
|
|
101
|
+
ApplyTaskCardDetailsModel: "ApplyTaskCardGridModel",
|
|
102
|
+
ApprovalTaskCardDetailsModel: "ApprovalTaskCardGridModel"
|
|
103
|
+
};
|
|
104
|
+
const APPROVAL_FIELD_WRAPPER_USE_BY_CONTAINER_USE = {
|
|
105
|
+
ApplyFormModel: "PatternFormItemModel",
|
|
106
|
+
ProcessFormModel: "PatternFormItemModel",
|
|
107
|
+
PatternFormGridModel: "PatternFormItemModel",
|
|
108
|
+
ApprovalDetailsModel: "ApprovalDetailsItemModel",
|
|
109
|
+
ApprovalDetailsGridModel: "ApprovalDetailsItemModel",
|
|
110
|
+
ApplyTaskCardDetailsModel: "ApplyTaskCardDetailsItemModel",
|
|
111
|
+
ApplyTaskCardGridModel: "ApplyTaskCardDetailsItemModel",
|
|
112
|
+
ApprovalTaskCardDetailsModel: "ApprovalTaskCardDetailsItemModel",
|
|
113
|
+
ApprovalTaskCardGridModel: "ApprovalTaskCardDetailsItemModel"
|
|
114
|
+
};
|
|
115
|
+
function normalizeApprovalSemanticUse(use) {
|
|
116
|
+
const normalized = String(use || "").trim();
|
|
117
|
+
if (!normalized) {
|
|
118
|
+
return normalized;
|
|
119
|
+
}
|
|
120
|
+
return APPROVAL_SEMANTIC_USE_ALIASES[normalized] || normalized;
|
|
121
|
+
}
|
|
122
|
+
function getApprovalDefaultGridUse(use) {
|
|
123
|
+
const normalized = String(use || "").trim();
|
|
124
|
+
return normalized ? APPROVAL_DEFAULT_GRID_USE_BY_OWNER_USE[normalized] : void 0;
|
|
125
|
+
}
|
|
126
|
+
function getApprovalFieldWrapperUse(containerUse) {
|
|
127
|
+
const normalized = String(containerUse || "").trim();
|
|
128
|
+
return normalized ? APPROVAL_FIELD_WRAPPER_USE_BY_CONTAINER_USE[normalized] : void 0;
|
|
129
|
+
}
|
|
130
|
+
function isApprovalFormContainerUse(use) {
|
|
131
|
+
return APPROVAL_FORM_CONTAINER_USE_SET.has(String(use || "").trim());
|
|
132
|
+
}
|
|
133
|
+
function isApprovalTaskCardGridUse(use) {
|
|
134
|
+
return APPROVAL_TASK_CARD_GRID_USES.includes(
|
|
135
|
+
String(use || "").trim()
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
139
|
+
0 && (module.exports = {
|
|
140
|
+
APPROVAL_ACTION_CONTAINER_USES,
|
|
141
|
+
APPROVAL_BLOCK_GRID_USES,
|
|
142
|
+
APPROVAL_DETAILS_BLOCK_USES,
|
|
143
|
+
APPROVAL_DETAILS_GRID_USES,
|
|
144
|
+
APPROVAL_FIELD_WRAPPER_USES,
|
|
145
|
+
APPROVAL_FORM_BLOCK_USES,
|
|
146
|
+
APPROVAL_FORM_GRID_USES,
|
|
147
|
+
APPROVAL_PAGE_MODEL_USES,
|
|
148
|
+
APPROVAL_TAB_MODEL_USES,
|
|
149
|
+
APPROVAL_TASK_CARD_GRID_USES,
|
|
150
|
+
getApprovalDefaultGridUse,
|
|
151
|
+
getApprovalFieldWrapperUse,
|
|
152
|
+
isApprovalFormContainerUse,
|
|
153
|
+
isApprovalTaskCardGridUse,
|
|
154
|
+
normalizeApprovalSemanticUse
|
|
155
|
+
});
|
|
@@ -90,7 +90,17 @@ const APPLY_BLUEPRINT_FIELD_ALLOWED_KEYS = [
|
|
|
90
90
|
"chart"
|
|
91
91
|
];
|
|
92
92
|
const APPLY_BLUEPRINT_ACTION_ALLOWED_KEYS = ["key", "type", "title", "settings", "popup", "script", "chart"];
|
|
93
|
-
const APPLY_BLUEPRINT_POPUP_ALLOWED_KEYS = [
|
|
93
|
+
const APPLY_BLUEPRINT_POPUP_ALLOWED_KEYS = [
|
|
94
|
+
"title",
|
|
95
|
+
"mode",
|
|
96
|
+
"template",
|
|
97
|
+
"tryTemplate",
|
|
98
|
+
"defaultType",
|
|
99
|
+
"saveAsTemplate",
|
|
100
|
+
"blocks",
|
|
101
|
+
"layout"
|
|
102
|
+
];
|
|
103
|
+
const APPLY_BLUEPRINT_POPUP_SAVE_AS_TEMPLATE_ALLOWED_KEYS = ["name", "description", "local"];
|
|
94
104
|
const APPLY_BLUEPRINT_LAYOUT_ALLOWED_KEYS = ["rows"];
|
|
95
105
|
const APPLY_BLUEPRINT_LAYOUT_CELL_ALLOWED_KEYS = ["key", "span"];
|
|
96
106
|
const APPLY_BLUEPRINT_BLOCK_RESOURCE_ALLOWED_KEYS = [
|
|
@@ -489,6 +499,23 @@ function compilePopup(popup, scopePrefix, assets, context, options = {}) {
|
|
|
489
499
|
(0, import_private_utils.assertOnlyAllowedKeys)(popup, context, APPLY_BLUEPRINT_POPUP_ALLOWED_KEYS);
|
|
490
500
|
const popupTitle = (0, import_private_utils.readOptionalString)(popup.title);
|
|
491
501
|
const template = ensureOptionalTemplate(popup.template, `${context}.template`);
|
|
502
|
+
const tryTemplate = import_lodash.default.isUndefined(popup.tryTemplate) ? void 0 : import_lodash.default.isBoolean(popup.tryTemplate) ? popup.tryTemplate : (0, import_errors.throwBadRequest)(`${context}.tryTemplate must be a boolean`);
|
|
503
|
+
const defaultType = import_lodash.default.isUndefined(popup.defaultType) ? void 0 : popup.defaultType === "view" || popup.defaultType === "edit" ? popup.defaultType : (0, import_errors.throwBadRequest)(`${context}.defaultType must be 'view' or 'edit'`);
|
|
504
|
+
const saveAsTemplate = import_lodash.default.isUndefined(popup.saveAsTemplate) ? void 0 : import_lodash.default.isPlainObject(popup.saveAsTemplate) ? ((0, import_private_utils.assertOnlyAllowedKeys)(
|
|
505
|
+
popup.saveAsTemplate,
|
|
506
|
+
`${context}.saveAsTemplate`,
|
|
507
|
+
APPLY_BLUEPRINT_POPUP_SAVE_AS_TEMPLATE_ALLOWED_KEYS
|
|
508
|
+
), {
|
|
509
|
+
name: (0, import_private_utils.assertNonEmptyString)(popup.saveAsTemplate.name, `${context}.saveAsTemplate.name`),
|
|
510
|
+
description: (0, import_private_utils.assertNonEmptyString)(popup.saveAsTemplate.description, `${context}.saveAsTemplate.description`),
|
|
511
|
+
local: (0, import_private_utils.readOptionalString)(popup.saveAsTemplate.local)
|
|
512
|
+
}) : (0, import_errors.throwBadRequest)(`${context}.saveAsTemplate must be an object`);
|
|
513
|
+
if (saveAsTemplate && template) {
|
|
514
|
+
(0, import_errors.throwBadRequest)(`${context}.saveAsTemplate cannot be combined with ${context}.template`);
|
|
515
|
+
}
|
|
516
|
+
if (saveAsTemplate && !import_lodash.default.isUndefined(tryTemplate)) {
|
|
517
|
+
(0, import_errors.throwBadRequest)(`${context}.saveAsTemplate cannot be combined with ${context}.tryTemplate`);
|
|
518
|
+
}
|
|
492
519
|
if (template) {
|
|
493
520
|
return {
|
|
494
521
|
popup: {
|
|
@@ -499,6 +526,9 @@ function compilePopup(popup, scopePrefix, assets, context, options = {}) {
|
|
|
499
526
|
}
|
|
500
527
|
const rawPopupBlocks = readOptionalItems(popup.blocks, `${context}.blocks`);
|
|
501
528
|
const popupBlocks = options.ownerActionType === "edit" && rawPopupBlocks.length ? normalizeEditPopupBlocks(rawPopupBlocks, context) : rawPopupBlocks;
|
|
529
|
+
if (saveAsTemplate && !popupBlocks.length) {
|
|
530
|
+
(0, import_errors.throwBadRequest)(`${context}.saveAsTemplate requires explicit popup.blocks`);
|
|
531
|
+
}
|
|
502
532
|
const compiledBlocks = popupBlocks.length ? compileBlocks(
|
|
503
533
|
popupBlocks,
|
|
504
534
|
scopePrefix,
|
|
@@ -518,6 +548,9 @@ function compilePopup(popup, scopePrefix, assets, context, options = {}) {
|
|
|
518
548
|
const compiledPopup = (0, import_service_utils.buildDefinedPayload)({
|
|
519
549
|
mode: popupMode || (popupBlocks.length || template || layout ? "replace" : void 0),
|
|
520
550
|
template,
|
|
551
|
+
...tryTemplate ? { tryTemplate: true } : {},
|
|
552
|
+
...defaultType ? { defaultType } : {},
|
|
553
|
+
...saveAsTemplate ? { saveAsTemplate } : {},
|
|
521
554
|
blocks: compiledBlocks.blocks.length ? compiledBlocks.blocks : void 0,
|
|
522
555
|
layout
|
|
523
556
|
});
|
|
@@ -541,7 +574,8 @@ function compileField(input, index, scopePrefix, assets, localBlockKeys, context
|
|
|
541
574
|
const fieldPath2 = (0, import_private_utils.assertNonEmptyString)(input, `${context}[${index}]`);
|
|
542
575
|
return {
|
|
543
576
|
key: (0, import_service_utils.normalizeFlowSurfaceComposeKey)((0, import_private_utils.buildScopedKey)(scopePrefix, fieldPath2), `${context}[${index}]`),
|
|
544
|
-
fieldPath: fieldPath2
|
|
577
|
+
fieldPath: fieldPath2,
|
|
578
|
+
__autoPopupForRelationField: true
|
|
545
579
|
};
|
|
546
580
|
}
|
|
547
581
|
if (!import_lodash.default.isPlainObject(input)) {
|
|
@@ -69,6 +69,13 @@ export type FlowSurfaceApplyBlueprintPopup = {
|
|
|
69
69
|
title?: string;
|
|
70
70
|
mode?: 'replace' | 'append';
|
|
71
71
|
template?: Record<string, any>;
|
|
72
|
+
tryTemplate?: boolean;
|
|
73
|
+
defaultType?: 'view' | 'edit';
|
|
74
|
+
saveAsTemplate?: {
|
|
75
|
+
name: string;
|
|
76
|
+
description: string;
|
|
77
|
+
local?: string;
|
|
78
|
+
};
|
|
72
79
|
blocks?: FlowSurfaceApplyBlueprintBlockSpec[];
|
|
73
80
|
layout?: FlowSurfaceApplyBlueprintLayout;
|
|
74
81
|
};
|
|
@@ -80,10 +80,12 @@ export declare function buildSyntheticRootPageTabModel(options: {
|
|
|
80
80
|
export declare function buildBlockTree(options: {
|
|
81
81
|
type?: string;
|
|
82
82
|
use?: string;
|
|
83
|
+
containerUse?: string;
|
|
83
84
|
resourceInit?: Record<string, any>;
|
|
84
85
|
props?: Record<string, any>;
|
|
85
86
|
decoratorProps?: Record<string, any>;
|
|
86
87
|
stepParams?: Record<string, any>;
|
|
88
|
+
flowRegistry?: Record<string, any>;
|
|
87
89
|
}): FlowSurfaceNodeSpec;
|
|
88
90
|
export declare function buildPopupPageTree(options: {
|
|
89
91
|
pageUid?: string;
|