@nocobase/plugin-flow-engine 2.1.0-alpha.15 → 2.1.0-alpha.16
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 +10 -10
- package/dist/node_modules/ses/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/flow-surfaces/{compiler.d.ts → apply/compiler.d.ts} +1 -10
- package/dist/server/flow-surfaces/{compiler.js → apply/compiler.js} +41 -280
- package/dist/server/flow-surfaces/apply/layout.d.ts +34 -0
- package/dist/server/flow-surfaces/apply/layout.js +175 -0
- package/dist/server/flow-surfaces/apply/matching.d.ts +16 -0
- package/dist/server/flow-surfaces/apply/matching.js +181 -0
- package/dist/server/flow-surfaces/association-title-field.d.ts +20 -0
- package/dist/server/flow-surfaces/association-title-field.js +158 -0
- package/dist/server/flow-surfaces/blueprint/compile-blocks.d.ts +14 -0
- package/dist/server/flow-surfaces/blueprint/compile-blocks.js +706 -0
- package/dist/server/flow-surfaces/blueprint/compile-plan.d.ts +13 -0
- package/dist/server/flow-surfaces/blueprint/compile-plan.js +308 -0
- package/dist/server/flow-surfaces/blueprint/compile-reaction.d.ts +11 -0
- package/dist/server/flow-surfaces/blueprint/compile-reaction.js +72 -0
- package/dist/server/flow-surfaces/blueprint/index.d.ts +12 -0
- package/dist/server/flow-surfaces/blueprint/index.js +44 -0
- package/dist/server/flow-surfaces/blueprint/normalize-document.d.ts +10 -0
- package/dist/server/flow-surfaces/blueprint/normalize-document.js +296 -0
- package/dist/server/flow-surfaces/blueprint/private-utils.d.ts +26 -0
- package/dist/server/flow-surfaces/blueprint/private-utils.js +182 -0
- package/dist/server/flow-surfaces/blueprint/public-types.d.ts +153 -0
- package/dist/server/flow-surfaces/blueprint/public-types.js +24 -0
- package/dist/server/flow-surfaces/catalog-smart.d.ts +18 -0
- package/dist/server/flow-surfaces/catalog-smart.js +239 -0
- package/dist/server/flow-surfaces/catalog-smart.projector.d.ts +15 -0
- package/dist/server/flow-surfaces/catalog-smart.projector.js +157 -0
- package/dist/server/flow-surfaces/catalog-smart.types.d.ts +99 -0
- package/dist/server/flow-surfaces/catalog-smart.types.js +24 -0
- package/dist/server/flow-surfaces/catalog.d.ts +3 -0
- package/dist/server/flow-surfaces/catalog.js +163 -34
- package/dist/server/flow-surfaces/compose-compiler.d.ts +104 -0
- package/dist/server/flow-surfaces/compose-compiler.js +162 -0
- package/dist/server/flow-surfaces/compose-runtime.d.ts +89 -0
- package/dist/server/flow-surfaces/compose-runtime.js +338 -0
- package/dist/server/flow-surfaces/configure-options.js +12 -3
- package/dist/server/flow-surfaces/constants.d.ts +3 -2
- package/dist/server/flow-surfaces/constants.js +36 -3
- package/dist/server/flow-surfaces/default-action-popup.d.ts +52 -0
- package/dist/server/flow-surfaces/default-action-popup.js +258 -0
- package/dist/server/flow-surfaces/executor.d.ts +10 -0
- package/dist/server/flow-surfaces/executor.js +59 -24
- package/dist/server/flow-surfaces/field-binding-registry.d.ts +23 -0
- package/dist/server/flow-surfaces/field-binding-registry.js +391 -0
- package/dist/server/flow-surfaces/field-semantics.d.ts +1 -1
- package/dist/server/flow-surfaces/index.js +75 -0
- package/dist/server/flow-surfaces/node-use-sets.d.ts +15 -0
- package/dist/server/flow-surfaces/node-use-sets.js +114 -0
- package/dist/server/flow-surfaces/payload-shape.d.ts +9 -0
- package/dist/server/flow-surfaces/payload-shape.js +64 -0
- package/dist/server/flow-surfaces/placement.js +2 -6
- package/dist/server/flow-surfaces/planning/action-specs.d.ts +179 -0
- package/dist/server/flow-surfaces/planning/action-specs.js +190 -0
- package/dist/server/flow-surfaces/planning/compiler.d.ts +37 -0
- package/dist/server/flow-surfaces/planning/compiler.js +376 -0
- package/dist/server/flow-surfaces/planning/context.d.ts +30 -0
- package/dist/server/flow-surfaces/planning/context.js +139 -0
- package/dist/server/flow-surfaces/planning/created-keys.d.ts +34 -0
- package/dist/server/flow-surfaces/planning/created-keys.js +375 -0
- package/dist/server/flow-surfaces/planning/key-kind.d.ts +11 -0
- package/dist/server/flow-surfaces/planning/key-kind.js +86 -0
- package/dist/server/flow-surfaces/planning/key-persistence.d.ts +34 -0
- package/dist/server/flow-surfaces/planning/key-persistence.js +148 -0
- package/dist/server/flow-surfaces/planning/key-registry.d.ts +40 -0
- package/dist/server/flow-surfaces/planning/key-registry.js +206 -0
- package/dist/server/flow-surfaces/planning/runtime.d.ts +37 -0
- package/dist/server/flow-surfaces/planning/runtime.js +259 -0
- package/dist/server/flow-surfaces/planning/step-link.d.ts +14 -0
- package/dist/server/flow-surfaces/planning/step-link.js +104 -0
- package/dist/server/flow-surfaces/planning/types.d.ts +55 -0
- package/dist/server/flow-surfaces/planning/types.js +24 -0
- package/dist/server/flow-surfaces/reaction/errors.d.ts +20 -0
- package/dist/server/flow-surfaces/reaction/errors.js +69 -0
- package/dist/server/flow-surfaces/reaction/field-value.d.ts +34 -0
- package/dist/server/flow-surfaces/reaction/field-value.js +181 -0
- package/dist/server/flow-surfaces/reaction/fingerprint.d.ts +16 -0
- package/dist/server/flow-surfaces/reaction/fingerprint.js +71 -0
- package/dist/server/flow-surfaces/reaction/linkage.d.ts +136 -0
- package/dist/server/flow-surfaces/reaction/linkage.js +882 -0
- package/dist/server/flow-surfaces/reaction/meta.d.ts +11 -0
- package/dist/server/flow-surfaces/reaction/meta.js +451 -0
- package/dist/server/flow-surfaces/reaction/registry.d.ts +136 -0
- package/dist/server/flow-surfaces/reaction/registry.js +186 -0
- package/dist/server/flow-surfaces/reaction/resolver.d.ts +22 -0
- package/dist/server/flow-surfaces/reaction/resolver.js +202 -0
- package/dist/server/flow-surfaces/reaction/types.d.ts +241 -0
- package/dist/server/flow-surfaces/reaction/types.js +24 -0
- package/dist/server/flow-surfaces/reaction/utils.d.ts +17 -0
- package/dist/server/flow-surfaces/reaction/utils.js +67 -0
- package/dist/server/flow-surfaces/reaction/value-expr.d.ts +15 -0
- package/dist/server/flow-surfaces/reaction/value-expr.js +209 -0
- package/dist/server/flow-surfaces/reference-guards.d.ts +19 -0
- package/dist/server/flow-surfaces/reference-guards.js +103 -0
- package/dist/server/flow-surfaces/service-helpers.d.ts +42 -0
- package/dist/server/flow-surfaces/service-helpers.js +377 -0
- package/dist/server/flow-surfaces/service-utils.d.ts +105 -0
- package/dist/server/flow-surfaces/service-utils.js +760 -0
- package/dist/server/flow-surfaces/service.d.ts +189 -103
- package/dist/server/flow-surfaces/service.js +3975 -1770
- package/dist/server/flow-surfaces/template-compatibility.d.ts +42 -0
- package/dist/server/flow-surfaces/template-compatibility.js +189 -0
- package/dist/server/flow-surfaces/template-service-utils.d.ts +62 -0
- package/dist/server/flow-surfaces/template-service-utils.js +281 -0
- package/dist/server/flow-surfaces/types.d.ts +129 -37
- package/dist/swagger/flow-surfaces.d.ts +3773 -1581
- package/dist/swagger/flow-surfaces.examples.d.ts +1215 -0
- package/dist/swagger/flow-surfaces.examples.js +1363 -0
- package/dist/swagger/flow-surfaces.js +2209 -1684
- package/dist/swagger/flow-surfaces.template-action-docs.d.ts +62 -0
- package/dist/swagger/flow-surfaces.template-action-docs.js +121 -0
- package/dist/swagger/flow-surfaces.template-schemas.d.ts +239 -0
- package/dist/swagger/flow-surfaces.template-schemas.js +255 -0
- package/dist/swagger/index.d.ts +3773 -1581
- package/package.json +2 -2
|
@@ -0,0 +1,706 @@
|
|
|
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 compile_blocks_exports = {};
|
|
38
|
+
__export(compile_blocks_exports, {
|
|
39
|
+
collectReferencedBlockKeys: () => collectReferencedBlockKeys,
|
|
40
|
+
compileTabComposeValues: () => compileTabComposeValues
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(compile_blocks_exports);
|
|
43
|
+
var import_lodash = __toESM(require("lodash"));
|
|
44
|
+
var import_errors = require("../errors");
|
|
45
|
+
var import_service_utils = require("../service-utils");
|
|
46
|
+
var import_private_utils = require("./private-utils");
|
|
47
|
+
const APPLY_BLUEPRINT_BLOCK_TYPE_ENUM = [
|
|
48
|
+
"table",
|
|
49
|
+
"createForm",
|
|
50
|
+
"editForm",
|
|
51
|
+
"details",
|
|
52
|
+
"filterForm",
|
|
53
|
+
"list",
|
|
54
|
+
"gridCard",
|
|
55
|
+
"markdown",
|
|
56
|
+
"iframe",
|
|
57
|
+
"chart",
|
|
58
|
+
"actionPanel",
|
|
59
|
+
"jsBlock"
|
|
60
|
+
];
|
|
61
|
+
const APPLY_BLUEPRINT_BLOCK_ALLOWED_KEYS = [
|
|
62
|
+
"key",
|
|
63
|
+
"type",
|
|
64
|
+
"title",
|
|
65
|
+
"collection",
|
|
66
|
+
"dataSourceKey",
|
|
67
|
+
"associationPathName",
|
|
68
|
+
"binding",
|
|
69
|
+
"associationField",
|
|
70
|
+
"resource",
|
|
71
|
+
"template",
|
|
72
|
+
"settings",
|
|
73
|
+
"fields",
|
|
74
|
+
"actions",
|
|
75
|
+
"recordActions",
|
|
76
|
+
"script",
|
|
77
|
+
"chart"
|
|
78
|
+
];
|
|
79
|
+
const APPLY_BLUEPRINT_FIELD_ALLOWED_KEYS = [
|
|
80
|
+
"key",
|
|
81
|
+
"field",
|
|
82
|
+
"associationPathName",
|
|
83
|
+
"renderer",
|
|
84
|
+
"type",
|
|
85
|
+
"label",
|
|
86
|
+
"target",
|
|
87
|
+
"settings",
|
|
88
|
+
"popup",
|
|
89
|
+
"script",
|
|
90
|
+
"chart"
|
|
91
|
+
];
|
|
92
|
+
const APPLY_BLUEPRINT_ACTION_ALLOWED_KEYS = ["key", "type", "title", "settings", "popup", "script", "chart"];
|
|
93
|
+
const APPLY_BLUEPRINT_POPUP_ALLOWED_KEYS = ["title", "mode", "template", "blocks", "layout"];
|
|
94
|
+
const APPLY_BLUEPRINT_LAYOUT_ALLOWED_KEYS = ["rows"];
|
|
95
|
+
const APPLY_BLUEPRINT_LAYOUT_CELL_ALLOWED_KEYS = ["key", "span"];
|
|
96
|
+
const APPLY_BLUEPRINT_BLOCK_RESOURCE_ALLOWED_KEYS = [
|
|
97
|
+
"binding",
|
|
98
|
+
"dataSourceKey",
|
|
99
|
+
"collectionName",
|
|
100
|
+
"associationField",
|
|
101
|
+
"associationName",
|
|
102
|
+
"associationPathName",
|
|
103
|
+
"sourceId",
|
|
104
|
+
"filterByTk"
|
|
105
|
+
];
|
|
106
|
+
const APPLY_BLUEPRINT_BLOCK_RESOURCE_RAW_ONLY_KEYS = [
|
|
107
|
+
"associationName",
|
|
108
|
+
"associationPathName",
|
|
109
|
+
"sourceId",
|
|
110
|
+
"filterByTk"
|
|
111
|
+
];
|
|
112
|
+
const APPLY_BLUEPRINT_BLOCK_RESOURCE_SHORTHAND_KEYS = [
|
|
113
|
+
"collection",
|
|
114
|
+
"dataSourceKey",
|
|
115
|
+
"associationPathName",
|
|
116
|
+
"binding",
|
|
117
|
+
"associationField"
|
|
118
|
+
];
|
|
119
|
+
const APPLY_BLUEPRINT_RECORD_CAPABLE_BLOCK_TYPES = /* @__PURE__ */ new Set(["table", "details", "list", "gridCard"]);
|
|
120
|
+
const APPLY_BLUEPRINT_RECORD_ACTION_TYPES = /* @__PURE__ */ new Set([
|
|
121
|
+
"view",
|
|
122
|
+
"edit",
|
|
123
|
+
"delete",
|
|
124
|
+
"updateRecord",
|
|
125
|
+
"duplicate",
|
|
126
|
+
"addChild"
|
|
127
|
+
]);
|
|
128
|
+
const APPLY_BLUEPRINT_BLOCK_TYPES = new Set(APPLY_BLUEPRINT_BLOCK_TYPE_ENUM);
|
|
129
|
+
function assertNoBlockLevelLayout(input, context) {
|
|
130
|
+
if (Object.prototype.hasOwnProperty.call(input, "layout")) {
|
|
131
|
+
(0, import_errors.throwBadRequest)(`${context}.layout is not supported; layout is only allowed on tabs[] and popup`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function assertApplyBlueprintBlockType(type, context) {
|
|
135
|
+
if (!type) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (type === "form") {
|
|
139
|
+
(0, import_errors.throwBadRequest)(`${context}.type 'form' is unsupported in applyBlueprint; use 'editForm' or 'createForm'`);
|
|
140
|
+
}
|
|
141
|
+
if (!APPLY_BLUEPRINT_BLOCK_TYPES.has(type)) {
|
|
142
|
+
(0, import_errors.throwBadRequest)(
|
|
143
|
+
`${context}.type '${type}' is unsupported in applyBlueprint; supported types: ${APPLY_BLUEPRINT_BLOCK_TYPE_ENUM.join(
|
|
144
|
+
", "
|
|
145
|
+
)}`
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function normalizeEditPopupBlocks(input, context) {
|
|
150
|
+
input.forEach((block, index) => {
|
|
151
|
+
const blockType = (0, import_private_utils.readOptionalString)(block == null ? void 0 : block.type);
|
|
152
|
+
if (blockType === "form") {
|
|
153
|
+
(0, import_errors.throwBadRequest)(`${context}.blocks[${index}].type 'form' is unsupported in applyBlueprint; use 'editForm'`);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
const editFormBlocks = input.filter((block) => (0, import_private_utils.readOptionalString)(block == null ? void 0 : block.type) === "editForm");
|
|
157
|
+
if (!editFormBlocks.length) {
|
|
158
|
+
(0, import_errors.throwBadRequest)(`${context} custom edit popup must contain exactly one editForm block`);
|
|
159
|
+
}
|
|
160
|
+
if (editFormBlocks.length > 1) {
|
|
161
|
+
(0, import_errors.throwBadRequest)(`${context} custom edit popup must contain exactly one editForm block`);
|
|
162
|
+
}
|
|
163
|
+
return input.map((block, index) => {
|
|
164
|
+
const blockType = (0, import_private_utils.readOptionalString)(block == null ? void 0 : block.type);
|
|
165
|
+
if (blockType !== "editForm") {
|
|
166
|
+
return block;
|
|
167
|
+
}
|
|
168
|
+
if (!import_lodash.default.isPlainObject(block)) {
|
|
169
|
+
return block;
|
|
170
|
+
}
|
|
171
|
+
if (!import_lodash.default.isUndefined(block.resource)) {
|
|
172
|
+
if (import_lodash.default.isPlainObject(block.resource)) {
|
|
173
|
+
const binding = "binding" in block.resource ? (0, import_private_utils.readOptionalString)(block.resource.binding) : void 0;
|
|
174
|
+
if (!binding) {
|
|
175
|
+
(0, import_errors.throwBadRequest)(
|
|
176
|
+
`${context}.blocks[${index}].resource must use binding='currentRecord' or be omitted in a custom edit popup`
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
if (binding !== "currentRecord") {
|
|
180
|
+
(0, import_errors.throwBadRequest)(
|
|
181
|
+
`${context}.blocks[${index}].resource.binding must be 'currentRecord' in a custom edit popup`
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return block;
|
|
186
|
+
}
|
|
187
|
+
const shorthandBinding = (0, import_private_utils.readOptionalString)(block.binding);
|
|
188
|
+
if (!import_lodash.default.isUndefined(shorthandBinding)) {
|
|
189
|
+
if (shorthandBinding !== "currentRecord") {
|
|
190
|
+
(0, import_errors.throwBadRequest)(`${context}.blocks[${index}].binding must be 'currentRecord' in a custom edit popup`);
|
|
191
|
+
}
|
|
192
|
+
return block;
|
|
193
|
+
}
|
|
194
|
+
const hasRawShorthandResource = !import_lodash.default.isUndefined(block.collection) || !import_lodash.default.isUndefined(block.dataSourceKey) || !import_lodash.default.isUndefined(block.associationPathName) || !import_lodash.default.isUndefined(block.associationField);
|
|
195
|
+
if (hasRawShorthandResource) {
|
|
196
|
+
(0, import_errors.throwBadRequest)(
|
|
197
|
+
`${context}.blocks[${index}] must use binding='currentRecord' or omit resource entirely in a custom edit popup`
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
...block,
|
|
202
|
+
resource: {
|
|
203
|
+
binding: "currentRecord"
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
function readAssociationFieldFromSingleSegmentPath(value, context) {
|
|
209
|
+
const associationPathName = (0, import_private_utils.readOptionalString)(value);
|
|
210
|
+
if (!associationPathName) {
|
|
211
|
+
return void 0;
|
|
212
|
+
}
|
|
213
|
+
const segments = associationPathName.split(".").map((segment) => segment.trim()).filter(Boolean);
|
|
214
|
+
if (!segments.length) {
|
|
215
|
+
(0, import_errors.throwBadRequest)(`${context}.associationPathName must be a non-empty association field path`);
|
|
216
|
+
}
|
|
217
|
+
if (segments.length > 1) {
|
|
218
|
+
(0, import_errors.throwBadRequest)(
|
|
219
|
+
`${context}.associationPathName '${associationPathName}' must be a single association field name when used with ${context}.binding; prefer ${context}.associationField for popup relation tables`
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
return segments[0];
|
|
223
|
+
}
|
|
224
|
+
function normalizeAssociatedRecordsBindingFromAssociationPath(input, context) {
|
|
225
|
+
const binding = (0, import_private_utils.readOptionalString)(input.binding);
|
|
226
|
+
const associationLeaf = readAssociationFieldFromSingleSegmentPath(input.associationPathName, context);
|
|
227
|
+
if (!binding || !associationLeaf) {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
if (binding !== "currentRecord" && binding !== "associatedRecords") {
|
|
231
|
+
(0, import_errors.throwBadRequest)(
|
|
232
|
+
`${context} cannot mix ${context}.binding='${binding}' with ${context}.associationPathName; use associatedRecords + associationField on popup collection blocks`
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
const associationField = (0, import_private_utils.readOptionalString)(input.associationField);
|
|
236
|
+
if (associationField && associationField !== associationLeaf) {
|
|
237
|
+
(0, import_errors.throwBadRequest)(
|
|
238
|
+
`${context}.associationField '${associationField}' conflicts with ${context}.associationPathName '${(0, import_private_utils.readOptionalString)(
|
|
239
|
+
input.associationPathName
|
|
240
|
+
)}'`
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
return {
|
|
244
|
+
binding: "associatedRecords",
|
|
245
|
+
associationField: associationField || associationLeaf
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function readApplyBlueprintActionType(input) {
|
|
249
|
+
if (typeof input === "string") {
|
|
250
|
+
return (0, import_private_utils.readString)(input);
|
|
251
|
+
}
|
|
252
|
+
if (import_lodash.default.isPlainObject(input)) {
|
|
253
|
+
return (0, import_private_utils.readOptionalString)(input.type);
|
|
254
|
+
}
|
|
255
|
+
return void 0;
|
|
256
|
+
}
|
|
257
|
+
function splitApplyBlueprintBlockActionsByScope(block, context) {
|
|
258
|
+
const rawActions = readOptionalItems(block.actions, `${context}.actions`);
|
|
259
|
+
const rawRecordActions = readOptionalItems(block.recordActions, `${context}.recordActions`);
|
|
260
|
+
const blockType = (0, import_private_utils.readOptionalString)(block.type);
|
|
261
|
+
if (!blockType || !APPLY_BLUEPRINT_RECORD_CAPABLE_BLOCK_TYPES.has(blockType)) {
|
|
262
|
+
return {
|
|
263
|
+
actions: rawActions,
|
|
264
|
+
recordActions: rawRecordActions
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
const promotedRecordActions = [];
|
|
268
|
+
const remainingActions = [];
|
|
269
|
+
rawActions.forEach((action) => {
|
|
270
|
+
const actionType = readApplyBlueprintActionType(action);
|
|
271
|
+
if (actionType && APPLY_BLUEPRINT_RECORD_ACTION_TYPES.has(actionType)) {
|
|
272
|
+
promotedRecordActions.push(action);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
remainingActions.push(action);
|
|
276
|
+
});
|
|
277
|
+
return {
|
|
278
|
+
actions: remainingActions,
|
|
279
|
+
recordActions: [...rawRecordActions, ...promotedRecordActions]
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
function resolveAssetSettings(settings, spec, assets, context) {
|
|
283
|
+
const nextSettings = (0, import_private_utils.cloneOptionalPlainObject)(settings, `${context}.settings`) || {};
|
|
284
|
+
const mergeAsset = (bucket, assetKey) => {
|
|
285
|
+
const normalizedKey = (0, import_private_utils.readOptionalString)(assetKey);
|
|
286
|
+
if (!normalizedKey) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
const registry = assets[bucket] || {};
|
|
290
|
+
const asset = registry[normalizedKey];
|
|
291
|
+
if (!import_lodash.default.isPlainObject(asset)) {
|
|
292
|
+
(0, import_errors.throwBadRequest)(`${context} ${bucket.slice(0, -1)} asset '${normalizedKey}' is not defined in assets.${bucket}`);
|
|
293
|
+
}
|
|
294
|
+
import_lodash.default.merge(nextSettings, import_lodash.default.cloneDeep(asset));
|
|
295
|
+
};
|
|
296
|
+
mergeAsset("charts", spec.chart);
|
|
297
|
+
mergeAsset("scripts", spec.script);
|
|
298
|
+
return nextSettings;
|
|
299
|
+
}
|
|
300
|
+
function readOptionalItems(value, context) {
|
|
301
|
+
return (0, import_private_utils.readOptionalArray)(value, context) || [];
|
|
302
|
+
}
|
|
303
|
+
function ensureOptionalTemplate(value, context) {
|
|
304
|
+
return (0, import_private_utils.cloneOptionalPlainObject)(value, context);
|
|
305
|
+
}
|
|
306
|
+
function resolvePopupTitleSettings(settings, title) {
|
|
307
|
+
if (!title) {
|
|
308
|
+
return settings;
|
|
309
|
+
}
|
|
310
|
+
const nextSettings = import_lodash.default.cloneDeep(settings || {});
|
|
311
|
+
if (import_lodash.default.isUndefined(import_lodash.default.get(nextSettings, ["openView", "title"]))) {
|
|
312
|
+
import_lodash.default.set(nextSettings, ["openView", "title"], title);
|
|
313
|
+
}
|
|
314
|
+
return nextSettings;
|
|
315
|
+
}
|
|
316
|
+
function normalizeBlockResourceObject(input, context) {
|
|
317
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(input, context, APPLY_BLUEPRINT_BLOCK_RESOURCE_ALLOWED_KEYS);
|
|
318
|
+
const hasBinding = Object.prototype.hasOwnProperty.call(input, "binding");
|
|
319
|
+
if (hasBinding) {
|
|
320
|
+
const normalizedAssociatedRecords = normalizeAssociatedRecordsBindingFromAssociationPath(input, context);
|
|
321
|
+
const mixedRawKeys = APPLY_BLUEPRINT_BLOCK_RESOURCE_RAW_ONLY_KEYS.filter(
|
|
322
|
+
(key) => Object.prototype.hasOwnProperty.call(input, key) && !(normalizedAssociatedRecords && key === "associationPathName")
|
|
323
|
+
);
|
|
324
|
+
if (mixedRawKeys.length) {
|
|
325
|
+
(0, import_errors.throwBadRequest)(
|
|
326
|
+
`${context} cannot mix binding with ${mixedRawKeys.map((key) => `${context}.${key}`).join(", ")}`
|
|
327
|
+
);
|
|
328
|
+
}
|
|
329
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
330
|
+
binding: (normalizedAssociatedRecords == null ? void 0 : normalizedAssociatedRecords.binding) || (0, import_private_utils.assertNonEmptyString)(input.binding, `${context}.binding`),
|
|
331
|
+
dataSourceKey: (0, import_private_utils.readOptionalString)(input.dataSourceKey),
|
|
332
|
+
collectionName: (0, import_private_utils.readOptionalString)(input.collectionName),
|
|
333
|
+
associationField: (normalizedAssociatedRecords == null ? void 0 : normalizedAssociatedRecords.associationField) || (0, import_private_utils.readOptionalString)(input.associationField)
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
if (Object.prototype.hasOwnProperty.call(input, "associationField")) {
|
|
337
|
+
(0, import_errors.throwBadRequest)(`${context}.associationField only works when ${context}.binding is provided`);
|
|
338
|
+
}
|
|
339
|
+
const collectionName = (0, import_private_utils.readOptionalString)(input.collectionName);
|
|
340
|
+
const normalized = (0, import_service_utils.buildDefinedPayload)({
|
|
341
|
+
dataSourceKey: (0, import_private_utils.readOptionalString)(input.dataSourceKey) || (collectionName ? "main" : void 0),
|
|
342
|
+
collectionName,
|
|
343
|
+
associationName: (0, import_private_utils.readOptionalString)(input.associationName),
|
|
344
|
+
associationPathName: (0, import_private_utils.readOptionalString)(input.associationPathName),
|
|
345
|
+
sourceId: input.sourceId,
|
|
346
|
+
filterByTk: input.filterByTk
|
|
347
|
+
});
|
|
348
|
+
if (!Object.keys(normalized).length) {
|
|
349
|
+
(0, import_errors.throwBadRequest)(`${context} cannot be empty`);
|
|
350
|
+
}
|
|
351
|
+
return normalized;
|
|
352
|
+
}
|
|
353
|
+
function buildBlockResource(block, context) {
|
|
354
|
+
if (!import_lodash.default.isUndefined(block.resource)) {
|
|
355
|
+
if (!import_lodash.default.isPlainObject(block.resource)) {
|
|
356
|
+
(0, import_errors.throwBadRequest)(`${context}.resource must be an object`);
|
|
357
|
+
}
|
|
358
|
+
const mixedShorthandKeys = APPLY_BLUEPRINT_BLOCK_RESOURCE_SHORTHAND_KEYS.filter(
|
|
359
|
+
(key) => Object.prototype.hasOwnProperty.call(block, key)
|
|
360
|
+
);
|
|
361
|
+
if (mixedShorthandKeys.length) {
|
|
362
|
+
(0, import_errors.throwBadRequest)(
|
|
363
|
+
`${context} cannot mix resource with ${mixedShorthandKeys.map((key) => `${context}.${key}`).join(", ")}`
|
|
364
|
+
);
|
|
365
|
+
}
|
|
366
|
+
return normalizeBlockResourceObject(block.resource, `${context}.resource`);
|
|
367
|
+
}
|
|
368
|
+
const binding = (0, import_private_utils.readOptionalString)(block.binding);
|
|
369
|
+
if (binding) {
|
|
370
|
+
const normalizedAssociatedRecords = normalizeAssociatedRecordsBindingFromAssociationPath(
|
|
371
|
+
block,
|
|
372
|
+
context
|
|
373
|
+
);
|
|
374
|
+
if (Object.prototype.hasOwnProperty.call(block, "associationPathName") && !normalizedAssociatedRecords) {
|
|
375
|
+
(0, import_errors.throwBadRequest)(`${context} cannot mix ${context}.binding with ${context}.associationPathName`);
|
|
376
|
+
}
|
|
377
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
378
|
+
binding: (normalizedAssociatedRecords == null ? void 0 : normalizedAssociatedRecords.binding) || binding,
|
|
379
|
+
dataSourceKey: (0, import_private_utils.readOptionalString)(block.dataSourceKey),
|
|
380
|
+
collectionName: (0, import_private_utils.readOptionalString)(block.collection),
|
|
381
|
+
associationField: (normalizedAssociatedRecords == null ? void 0 : normalizedAssociatedRecords.associationField) || (0, import_private_utils.readOptionalString)(block.associationField)
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
if (Object.prototype.hasOwnProperty.call(block, "associationField")) {
|
|
385
|
+
(0, import_errors.throwBadRequest)(`${context}.associationField only works when ${context}.binding is provided`);
|
|
386
|
+
}
|
|
387
|
+
const collectionName = (0, import_private_utils.readOptionalString)(block.collection);
|
|
388
|
+
if (!collectionName) {
|
|
389
|
+
return void 0;
|
|
390
|
+
}
|
|
391
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
392
|
+
dataSourceKey: (0, import_private_utils.readOptionalString)(block.dataSourceKey) || "main",
|
|
393
|
+
collectionName,
|
|
394
|
+
associationPathName: (0, import_private_utils.readOptionalString)(block.associationPathName)
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
function ensureLayoutRows(layout, context) {
|
|
398
|
+
if (import_lodash.default.isUndefined(layout)) {
|
|
399
|
+
return void 0;
|
|
400
|
+
}
|
|
401
|
+
if (!import_lodash.default.isPlainObject(layout)) {
|
|
402
|
+
(0, import_errors.throwBadRequest)(`${context} must be an object`);
|
|
403
|
+
}
|
|
404
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(layout, context, APPLY_BLUEPRINT_LAYOUT_ALLOWED_KEYS);
|
|
405
|
+
if (!Array.isArray(layout.rows) || !layout.rows.length) {
|
|
406
|
+
(0, import_errors.throwBadRequest)(`${context}.rows must be a non-empty array`);
|
|
407
|
+
}
|
|
408
|
+
return layout.rows.map((row, rowIndex) => {
|
|
409
|
+
if (!Array.isArray(row) || !row.length) {
|
|
410
|
+
(0, import_errors.throwBadRequest)(`${context}.rows[${rowIndex}] must be a non-empty array`);
|
|
411
|
+
}
|
|
412
|
+
row.forEach((item, itemIndex) => {
|
|
413
|
+
if (typeof item === "string") {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
if (!import_lodash.default.isPlainObject(item)) {
|
|
417
|
+
(0, import_errors.throwBadRequest)(`${context}.rows[${rowIndex}][${itemIndex}] must be a string or object`);
|
|
418
|
+
}
|
|
419
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(
|
|
420
|
+
item,
|
|
421
|
+
`${context}.rows[${rowIndex}][${itemIndex}]`,
|
|
422
|
+
APPLY_BLUEPRINT_LAYOUT_CELL_ALLOWED_KEYS
|
|
423
|
+
);
|
|
424
|
+
});
|
|
425
|
+
return row;
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
function autoLayoutFromBlockKeys(blockKeys) {
|
|
429
|
+
return {
|
|
430
|
+
rows: blockKeys.map((key) => [key])
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
function collectReferencedBlockKeys(layout, context) {
|
|
434
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
435
|
+
const rows = ensureLayoutRows(layout, context) || [];
|
|
436
|
+
rows.forEach((row, rowIndex) => {
|
|
437
|
+
row.forEach((cell, itemIndex) => {
|
|
438
|
+
if (typeof cell === "string") {
|
|
439
|
+
const key2 = (0, import_private_utils.readString)(cell);
|
|
440
|
+
if (key2) {
|
|
441
|
+
referenced.add(key2);
|
|
442
|
+
}
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
const key = (0, import_private_utils.assertNonEmptyString)(cell.key, `${context}.rows[${rowIndex}][${itemIndex}].key`);
|
|
446
|
+
if (key) {
|
|
447
|
+
referenced.add(key);
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
});
|
|
451
|
+
return referenced;
|
|
452
|
+
}
|
|
453
|
+
function compileLayout(layout, blockKeysByLocalKey, context) {
|
|
454
|
+
const rows = ensureLayoutRows(layout, context);
|
|
455
|
+
if (!rows) {
|
|
456
|
+
return void 0;
|
|
457
|
+
}
|
|
458
|
+
return {
|
|
459
|
+
rows: rows.map((row, rowIndex) => {
|
|
460
|
+
return row.map((item, itemIndex) => {
|
|
461
|
+
if (typeof item === "string") {
|
|
462
|
+
const itemKey = (0, import_private_utils.readString)(item);
|
|
463
|
+
const resolved2 = blockKeysByLocalKey.get(itemKey) || [...blockKeysByLocalKey.values()].find((value) => value === itemKey);
|
|
464
|
+
if (!resolved2) {
|
|
465
|
+
(0, import_errors.throwBadRequest)(`${context}.rows[${rowIndex}][${itemIndex}] references unknown block '${item}'`);
|
|
466
|
+
}
|
|
467
|
+
return resolved2;
|
|
468
|
+
}
|
|
469
|
+
const rawKey = (0, import_private_utils.assertNonEmptyString)(item.key, `${context}.rows[${rowIndex}][${itemIndex}].key`);
|
|
470
|
+
const resolved = blockKeysByLocalKey.get(rawKey) || [...blockKeysByLocalKey.values()].find((value) => value === rawKey) || rawKey;
|
|
471
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
472
|
+
key: resolved,
|
|
473
|
+
span: import_lodash.default.isUndefined(item.span) ? void 0 : import_lodash.default.isNumber(item.span) ? item.span : (0, import_errors.throwBadRequest)(`${context}.rows[${rowIndex}][${itemIndex}].span must be a number`)
|
|
474
|
+
});
|
|
475
|
+
});
|
|
476
|
+
})
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
function compilePopup(popup, scopePrefix, assets, context, options = {}) {
|
|
480
|
+
if (import_lodash.default.isUndefined(popup)) {
|
|
481
|
+
return {};
|
|
482
|
+
}
|
|
483
|
+
if (!import_lodash.default.isPlainObject(popup)) {
|
|
484
|
+
(0, import_errors.throwBadRequest)(`${context} must be an object`);
|
|
485
|
+
}
|
|
486
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(popup, context, APPLY_BLUEPRINT_POPUP_ALLOWED_KEYS);
|
|
487
|
+
const popupTitle = (0, import_private_utils.readOptionalString)(popup.title);
|
|
488
|
+
const template = ensureOptionalTemplate(popup.template, `${context}.template`);
|
|
489
|
+
const rawPopupBlocks = readOptionalItems(popup.blocks, `${context}.blocks`);
|
|
490
|
+
const popupBlocks = options.ownerActionType === "edit" && rawPopupBlocks.length ? normalizeEditPopupBlocks(rawPopupBlocks, context) : rawPopupBlocks;
|
|
491
|
+
const compiledBlocks = popupBlocks.length ? compileBlocks(
|
|
492
|
+
popupBlocks,
|
|
493
|
+
scopePrefix,
|
|
494
|
+
assets,
|
|
495
|
+
`${context}.blocks`,
|
|
496
|
+
collectReferencedBlockKeys(popup.layout, `${context}.layout`)
|
|
497
|
+
) : { blocks: [], blockKeysByLocalKey: /* @__PURE__ */ new Map() };
|
|
498
|
+
const layout = popupBlocks.length || popup.layout ? compileLayout(
|
|
499
|
+
popup.layout || autoLayoutFromBlockKeys(compiledBlocks.blocks.map((block) => block.key)),
|
|
500
|
+
compiledBlocks.blockKeysByLocalKey,
|
|
501
|
+
`${context}.layout`
|
|
502
|
+
) : void 0;
|
|
503
|
+
const popupMode = (0, import_private_utils.readOptionalString)(popup.mode);
|
|
504
|
+
if (popupMode && popupMode !== "replace" && popupMode !== "append") {
|
|
505
|
+
(0, import_errors.throwBadRequest)(`${context}.mode must be 'replace' or 'append'`);
|
|
506
|
+
}
|
|
507
|
+
const compiledPopup = (0, import_service_utils.buildDefinedPayload)({
|
|
508
|
+
mode: popupMode || (popupBlocks.length || template || layout ? "replace" : void 0),
|
|
509
|
+
template,
|
|
510
|
+
blocks: compiledBlocks.blocks.length ? compiledBlocks.blocks : void 0,
|
|
511
|
+
layout
|
|
512
|
+
});
|
|
513
|
+
return {
|
|
514
|
+
popup: Object.keys(compiledPopup).length ? compiledPopup : {},
|
|
515
|
+
popupTitle
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
function resolveTargetBlockKey(value, localBlockKeys, context) {
|
|
519
|
+
if (import_lodash.default.isUndefined(value) || value === null || value === "") {
|
|
520
|
+
return void 0;
|
|
521
|
+
}
|
|
522
|
+
if (typeof value === "string") {
|
|
523
|
+
const normalized = (0, import_private_utils.readString)(value);
|
|
524
|
+
return localBlockKeys.get(normalized) || normalized;
|
|
525
|
+
}
|
|
526
|
+
(0, import_errors.throwBadRequest)(`${context} must be a string block key`);
|
|
527
|
+
}
|
|
528
|
+
function compileField(input, index, scopePrefix, assets, localBlockKeys, context) {
|
|
529
|
+
if (typeof input === "string") {
|
|
530
|
+
const fieldPath2 = (0, import_private_utils.assertNonEmptyString)(input, `${context}[${index}]`);
|
|
531
|
+
return {
|
|
532
|
+
key: (0, import_service_utils.normalizeFlowSurfaceComposeKey)((0, import_private_utils.buildScopedKey)(scopePrefix, fieldPath2), `${context}[${index}]`),
|
|
533
|
+
fieldPath: fieldPath2
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
if (!import_lodash.default.isPlainObject(input)) {
|
|
537
|
+
(0, import_errors.throwBadRequest)(`${context}[${index}] must be a string or object`);
|
|
538
|
+
}
|
|
539
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(input, `${context}[${index}]`, APPLY_BLUEPRINT_FIELD_ALLOWED_KEYS);
|
|
540
|
+
const fieldPath = (0, import_private_utils.readOptionalString)(input.field);
|
|
541
|
+
const syntheticType = (0, import_private_utils.readOptionalString)(input.type);
|
|
542
|
+
if (!fieldPath && !syntheticType) {
|
|
543
|
+
(0, import_errors.throwBadRequest)(`${context}[${index}] requires field or type`);
|
|
544
|
+
}
|
|
545
|
+
if (fieldPath && syntheticType) {
|
|
546
|
+
(0, import_errors.throwBadRequest)(`${context}[${index}] cannot mix field with synthetic type`);
|
|
547
|
+
}
|
|
548
|
+
const localKey = (0, import_private_utils.normalizeBlueprintLocalKey)(
|
|
549
|
+
input.key,
|
|
550
|
+
fieldPath || (syntheticType ? `${syntheticType}_${index + 1}` : `field_${index + 1}`),
|
|
551
|
+
`${context}[${index}].key`
|
|
552
|
+
);
|
|
553
|
+
const key = (0, import_service_utils.normalizeFlowSurfaceComposeKey)((0, import_private_utils.buildScopedKey)(scopePrefix, localKey), `${context}[${index}]`);
|
|
554
|
+
let settings = resolveAssetSettings(input.settings, input, assets, `${context}[${index}]`);
|
|
555
|
+
if ((0, import_private_utils.readOptionalString)(input.label) && import_lodash.default.isUndefined(settings.label)) {
|
|
556
|
+
settings.label = (0, import_private_utils.readOptionalString)(input.label);
|
|
557
|
+
}
|
|
558
|
+
const popupResult = compilePopup(input.popup, `${key}.popup`, assets, `${context}[${index}].popup`);
|
|
559
|
+
settings = resolvePopupTitleSettings(settings, popupResult.popupTitle);
|
|
560
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
561
|
+
key,
|
|
562
|
+
fieldPath,
|
|
563
|
+
associationPathName: (0, import_private_utils.readOptionalString)(input.associationPathName),
|
|
564
|
+
renderer: (0, import_private_utils.readOptionalString)(input.renderer),
|
|
565
|
+
type: syntheticType,
|
|
566
|
+
target: resolveTargetBlockKey(input.target, localBlockKeys, `${context}[${index}].target`),
|
|
567
|
+
settings: Object.keys(settings).length ? settings : void 0,
|
|
568
|
+
popup: popupResult.popup
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
function compileAction(input, index, scopePrefix, assets, context) {
|
|
572
|
+
if (typeof input === "string") {
|
|
573
|
+
const type2 = (0, import_private_utils.assertNonEmptyString)(input, `${context}[${index}]`);
|
|
574
|
+
return {
|
|
575
|
+
key: (0, import_service_utils.normalizeFlowSurfaceComposeKey)((0, import_private_utils.buildScopedKey)(scopePrefix, `${type2}_${index + 1}`), `${context}[${index}]`),
|
|
576
|
+
type: type2
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
if (!import_lodash.default.isPlainObject(input)) {
|
|
580
|
+
(0, import_errors.throwBadRequest)(`${context}[${index}] must be a string or object`);
|
|
581
|
+
}
|
|
582
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(input, `${context}[${index}]`, APPLY_BLUEPRINT_ACTION_ALLOWED_KEYS);
|
|
583
|
+
const type = (0, import_private_utils.assertNonEmptyString)(input.type, `${context}[${index}].type`);
|
|
584
|
+
const localKey = (0, import_private_utils.normalizeBlueprintLocalKey)(input.key, `${type}_${index + 1}`, `${context}[${index}].key`);
|
|
585
|
+
const key = (0, import_service_utils.normalizeFlowSurfaceComposeKey)((0, import_private_utils.buildScopedKey)(scopePrefix, localKey), `${context}[${index}]`);
|
|
586
|
+
let settings = resolveAssetSettings(input.settings, input, assets, `${context}[${index}]`);
|
|
587
|
+
if ((0, import_private_utils.readOptionalString)(input.title) && import_lodash.default.isUndefined(settings.title)) {
|
|
588
|
+
settings.title = (0, import_private_utils.readOptionalString)(input.title);
|
|
589
|
+
}
|
|
590
|
+
const popupResult = compilePopup(input.popup, `${key}.popup`, assets, `${context}[${index}].popup`, {
|
|
591
|
+
ownerActionType: type
|
|
592
|
+
});
|
|
593
|
+
settings = resolvePopupTitleSettings(settings, popupResult.popupTitle);
|
|
594
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
595
|
+
key,
|
|
596
|
+
type,
|
|
597
|
+
settings: Object.keys(settings).length ? settings : void 0,
|
|
598
|
+
popup: popupResult.popup
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
function compileBlocks(input, scopePrefix, assets, context, requiredExplicitBlockKeys = /* @__PURE__ */ new Set()) {
|
|
602
|
+
const blockKeysByLocalKey = /* @__PURE__ */ new Map();
|
|
603
|
+
const referencedBlockKeys = new Set(requiredExplicitBlockKeys);
|
|
604
|
+
const rawBlocks = import_lodash.default.castArray(input || []);
|
|
605
|
+
rawBlocks.forEach((block, index) => {
|
|
606
|
+
if (!import_lodash.default.isPlainObject(block)) {
|
|
607
|
+
(0, import_errors.throwBadRequest)(`${context}[${index}] must be an object`);
|
|
608
|
+
}
|
|
609
|
+
const fields = readOptionalItems(block == null ? void 0 : block.fields, `${context}[${index}].fields`);
|
|
610
|
+
fields.forEach((field, fieldIndex) => {
|
|
611
|
+
if (typeof (field == null ? void 0 : field.target) !== "string" || !field.target.trim()) {
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
referencedBlockKeys.add(
|
|
615
|
+
(0, import_service_utils.normalizeFlowSurfaceComposeKey)(field.target, `${context}[${index}].fields[${fieldIndex}].target`)
|
|
616
|
+
);
|
|
617
|
+
});
|
|
618
|
+
});
|
|
619
|
+
rawBlocks.forEach((block, index) => {
|
|
620
|
+
if (!import_lodash.default.isPlainObject(block)) {
|
|
621
|
+
(0, import_errors.throwBadRequest)(`${context}[${index}] must be an object`);
|
|
622
|
+
}
|
|
623
|
+
assertNoBlockLevelLayout(block, `${context}[${index}]`);
|
|
624
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(block, `${context}[${index}]`, APPLY_BLUEPRINT_BLOCK_ALLOWED_KEYS);
|
|
625
|
+
assertApplyBlueprintBlockType((0, import_private_utils.readOptionalString)(block.type), `${context}[${index}]`);
|
|
626
|
+
const explicitKey = (0, import_private_utils.readString)(block.key);
|
|
627
|
+
const fallback = block.type ? `${block.type}_${index + 1}` : `block_${index + 1}`;
|
|
628
|
+
const localKey = (0, import_private_utils.normalizeBlueprintLocalKey)(block.key, fallback, `${context}[${index}].key`);
|
|
629
|
+
if (!explicitKey && referencedBlockKeys.has(localKey)) {
|
|
630
|
+
(0, import_errors.throwBadRequest)(
|
|
631
|
+
`${context}[${index}] must provide key explicitly because it is referenced by layout or field.target`
|
|
632
|
+
);
|
|
633
|
+
}
|
|
634
|
+
if (blockKeysByLocalKey.has(localKey)) {
|
|
635
|
+
(0, import_errors.throwBadRequest)(`${context}[${index}] key '${localKey}' is duplicated`);
|
|
636
|
+
}
|
|
637
|
+
const key = (0, import_service_utils.normalizeFlowSurfaceComposeKey)((0, import_private_utils.buildScopedKey)(scopePrefix, localKey), `${context}[${index}]`);
|
|
638
|
+
blockKeysByLocalKey.set(localKey, key);
|
|
639
|
+
});
|
|
640
|
+
const blocks = rawBlocks.map((block, index) => {
|
|
641
|
+
const blockContext = `${context}[${index}]`;
|
|
642
|
+
const localKey = (0, import_private_utils.normalizeBlueprintLocalKey)(
|
|
643
|
+
block.key,
|
|
644
|
+
block.type ? `${block.type}_${index + 1}` : `block_${index + 1}`,
|
|
645
|
+
`${blockContext}.key`
|
|
646
|
+
);
|
|
647
|
+
const key = blockKeysByLocalKey.get(localKey);
|
|
648
|
+
if (!key) {
|
|
649
|
+
(0, import_errors.throwBadRequest)(`${blockContext} key '${localKey}' is missing after block key compilation`);
|
|
650
|
+
}
|
|
651
|
+
const settings = resolveAssetSettings(block.settings, block, assets, blockContext);
|
|
652
|
+
if ((0, import_private_utils.readOptionalString)(block.title) && import_lodash.default.isUndefined(settings.title)) {
|
|
653
|
+
settings.title = (0, import_private_utils.readOptionalString)(block.title);
|
|
654
|
+
}
|
|
655
|
+
const template = ensureOptionalTemplate(block.template, `${blockContext}.template`);
|
|
656
|
+
const fields = readOptionalItems(block.fields, `${blockContext}.fields`);
|
|
657
|
+
const { actions, recordActions } = splitApplyBlueprintBlockActionsByScope(block, blockContext);
|
|
658
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
659
|
+
key,
|
|
660
|
+
type: (0, import_private_utils.readOptionalString)(block.type),
|
|
661
|
+
resource: buildBlockResource(block, blockContext),
|
|
662
|
+
template,
|
|
663
|
+
settings: Object.keys(settings).length ? settings : void 0,
|
|
664
|
+
fields: fields.map(
|
|
665
|
+
(field, fieldIndex) => compileField(field, fieldIndex, key, assets, blockKeysByLocalKey, `${blockContext}.fields`)
|
|
666
|
+
),
|
|
667
|
+
actions: actions.map(
|
|
668
|
+
(action, actionIndex) => compileAction(action, actionIndex, key, assets, `${blockContext}.actions`)
|
|
669
|
+
),
|
|
670
|
+
recordActions: recordActions.map(
|
|
671
|
+
(action, actionIndex) => compileAction(action, actionIndex, key, assets, `${blockContext}.recordActions`)
|
|
672
|
+
)
|
|
673
|
+
});
|
|
674
|
+
});
|
|
675
|
+
return {
|
|
676
|
+
blocks,
|
|
677
|
+
blockKeysByLocalKey
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
function compileTabComposeValues(tab, document, tabIndex, options) {
|
|
681
|
+
const tabPublicPath = (0, import_private_utils.buildApplyBlueprintTabPublicPath)(tabIndex);
|
|
682
|
+
const blocksPath = `${tabPublicPath}.blocks`;
|
|
683
|
+
const layoutPath = `${tabPublicPath}.layout`;
|
|
684
|
+
const compiledBlocks = compileBlocks(
|
|
685
|
+
tab.blocks,
|
|
686
|
+
tab.key,
|
|
687
|
+
document.assets,
|
|
688
|
+
blocksPath,
|
|
689
|
+
collectReferencedBlockKeys(tab.layout, layoutPath)
|
|
690
|
+
);
|
|
691
|
+
const layout = compileLayout(
|
|
692
|
+
tab.layout || autoLayoutFromBlockKeys(compiledBlocks.blocks.map((block) => block.key)),
|
|
693
|
+
compiledBlocks.blockKeysByLocalKey,
|
|
694
|
+
layoutPath
|
|
695
|
+
);
|
|
696
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
697
|
+
mode: options.mode,
|
|
698
|
+
blocks: compiledBlocks.blocks,
|
|
699
|
+
layout
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
703
|
+
0 && (module.exports = {
|
|
704
|
+
collectReferencedBlockKeys,
|
|
705
|
+
compileTabComposeValues
|
|
706
|
+
});
|