@nocobase/plugin-flow-engine 2.1.0-beta.2 → 2.1.0-beta.21
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/LICENSE +201 -661
- package/README.md +79 -9
- package/dist/ai/ai-employees/nathan/index.d.ts +10 -0
- package/dist/ai/ai-employees/nathan/index.js +41 -0
- package/dist/ai/ai-employees/nathan/prompt.md +132 -0
- package/dist/ai/ai-employees/nathan/skills/frontend-developer/SKILLS.md +69 -0
- package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextApis.js +2 -2
- package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextEnvs.js +2 -2
- package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextVars.js +2 -2
- package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/lintAndTestJS.js +2 -2
- package/dist/ai/docs/runjs/context/block-model.md +35 -35
- package/dist/ai/docs/runjs/context/collection-field.md +53 -51
- package/dist/ai/docs/runjs/context/collection.md +39 -39
- package/dist/ai/docs/runjs/context/data-source-manager.md +40 -30
- package/dist/ai/docs/runjs/context/data-source.md +52 -44
- package/dist/ai/docs/runjs/context/element.md +44 -38
- package/dist/ai/docs/runjs/context/exit-all.md +37 -35
- package/dist/ai/docs/runjs/context/exit.md +38 -35
- package/dist/ai/docs/runjs/context/filter-manager.md +36 -30
- package/dist/ai/docs/runjs/context/form.md +57 -57
- package/dist/ai/docs/runjs/context/get-model.md +22 -21
- package/dist/ai/docs/runjs/context/get-value.md +20 -19
- package/dist/ai/docs/runjs/context/get-var.md +61 -55
- package/dist/ai/docs/runjs/context/i18n.md +17 -14
- package/dist/ai/docs/runjs/context/import-async.md +333 -45
- package/dist/ai/docs/runjs/context/init-resource.md +20 -20
- package/dist/ai/docs/runjs/context/libs.md +31 -31
- package/dist/ai/docs/runjs/context/location.md +34 -31
- package/dist/ai/docs/runjs/context/logger.md +41 -40
- package/dist/ai/docs/runjs/context/make-resource.md +27 -26
- package/dist/ai/docs/runjs/context/message.md +42 -41
- package/dist/ai/docs/runjs/context/modal.md +44 -44
- package/dist/ai/docs/runjs/context/model.md +36 -33
- package/dist/ai/docs/runjs/context/notification.md +41 -40
- package/dist/ai/docs/runjs/context/off.md +14 -14
- package/dist/ai/docs/runjs/context/on.md +30 -29
- package/dist/ai/docs/runjs/context/open-view.md +40 -40
- package/dist/ai/docs/runjs/context/render.md +37 -32
- package/dist/ai/docs/runjs/context/request.md +46 -45
- package/dist/ai/docs/runjs/context/require-async.md +28 -25
- package/dist/ai/docs/runjs/context/resource.md +34 -34
- package/dist/ai/docs/runjs/context/route.md +36 -34
- package/dist/ai/docs/runjs/context/router.md +43 -31
- package/dist/ai/docs/runjs/context/set-value.md +18 -17
- package/dist/ai/docs/runjs/context/sql.md +7 -15
- package/dist/ai/docs/runjs/context/t.md +20 -17
- package/dist/ai/docs/runjs/context/view.md +49 -46
- package/dist/ai/docs/runjs/document.md +1 -0
- package/dist/ai/docs/runjs/import-modules.md +32 -32
- package/dist/ai/docs/runjs/index.md +13 -13
- package/dist/ai/docs/runjs/jsx.md +19 -19
- package/dist/ai/docs/runjs/model/form-block-model.md +1 -3
- package/dist/ai/docs/runjs/render.md +15 -15
- package/dist/ai/docs/runjs/resource/api-resource.md +53 -53
- package/dist/ai/docs/runjs/resource/multi-record-resource.md +64 -64
- package/dist/ai/docs/runjs/resource/single-record-resource.md +55 -55
- package/dist/ai/docs/runjs/resource/sql-resource.md +57 -57
- package/dist/ai/docs/runjs/window.md +5 -5
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +12 -11
- package/dist/locale/en-US.json +1 -0
- package/dist/locale/index.d.ts +2 -0
- package/dist/locale/zh-CN.json +1 -0
- package/dist/node_modules/ses/dist/ses.cjs +1 -1
- package/dist/node_modules/ses/package.json +1 -1
- package/dist/node_modules/zod/index.cjs +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/collections/flowsql.js +1 -0
- package/dist/server/flow-surfaces/action-scope.d.ts +39 -0
- package/dist/server/flow-surfaces/action-scope.js +156 -0
- package/dist/server/flow-surfaces/apply/compiler.d.ts +13 -0
- package/dist/server/flow-surfaces/apply/compiler.js +971 -0
- 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/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 +187 -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/association-interfaces.d.ts +10 -0
- package/dist/server/flow-surfaces/association-interfaces.js +39 -0
- package/dist/server/flow-surfaces/association-title-field.d.ts +20 -0
- package/dist/server/flow-surfaces/association-title-field.js +192 -0
- package/dist/server/flow-surfaces/blueprint/compile-blocks.d.ts +14 -0
- package/dist/server/flow-surfaces/blueprint/compile-blocks.js +1074 -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/defaults.d.ts +26 -0
- package/dist/server/flow-surfaces/blueprint/defaults.js +133 -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 +416 -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 +201 -0
- package/dist/server/flow-surfaces/blueprint/public-types.js +24 -0
- package/dist/server/flow-surfaces/builder.d.ts +237 -0
- package/dist/server/flow-surfaces/builder.js +1129 -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 +79 -0
- package/dist/server/flow-surfaces/catalog.js +3693 -0
- package/dist/server/flow-surfaces/chart-config.d.ts +121 -0
- package/dist/server/flow-surfaces/chart-config.js +1394 -0
- package/dist/server/flow-surfaces/compose-compiler.d.ts +116 -0
- package/dist/server/flow-surfaces/compose-compiler.js +175 -0
- package/dist/server/flow-surfaces/compose-runtime.d.ts +93 -0
- package/dist/server/flow-surfaces/compose-runtime.js +375 -0
- package/dist/server/flow-surfaces/configure-options.d.ts +23 -0
- package/dist/server/flow-surfaces/configure-options.js +893 -0
- package/dist/server/flow-surfaces/constants.d.ts +351 -0
- package/dist/server/flow-surfaces/constants.js +104 -0
- package/dist/server/flow-surfaces/context.d.ts +72 -0
- package/dist/server/flow-surfaces/context.js +556 -0
- package/dist/server/flow-surfaces/contract-guard.d.ts +19 -0
- package/dist/server/flow-surfaces/contract-guard.js +402 -0
- package/dist/server/flow-surfaces/core-field-default-bindings.d.ts +12 -0
- package/dist/server/flow-surfaces/core-field-default-bindings.js +157 -0
- package/dist/server/flow-surfaces/default-action-popup.d.ts +63 -0
- package/dist/server/flow-surfaces/default-action-popup.js +322 -0
- package/dist/server/flow-surfaces/default-block-actions.d.ts +32 -0
- package/dist/server/flow-surfaces/default-block-actions.js +209 -0
- package/dist/server/flow-surfaces/errors.d.ts +47 -0
- package/dist/server/flow-surfaces/errors.js +145 -0
- package/dist/server/flow-surfaces/executor.d.ts +23 -0
- package/dist/server/flow-surfaces/executor.js +132 -0
- package/dist/server/flow-surfaces/field-binding-registry.d.ts +24 -0
- package/dist/server/flow-surfaces/field-binding-registry.js +396 -0
- package/dist/server/flow-surfaces/field-semantics.d.ts +15 -0
- package/dist/server/flow-surfaces/field-semantics.js +84 -0
- package/dist/server/flow-surfaces/field-type-resolver.d.ts +46 -0
- package/dist/server/flow-surfaces/field-type-resolver.js +322 -0
- package/dist/server/flow-surfaces/filter-group.d.ts +15 -0
- package/dist/server/flow-surfaces/filter-group.js +94 -0
- package/dist/server/flow-surfaces/index.d.ts +11 -0
- package/dist/server/flow-surfaces/index.js +302 -0
- package/dist/server/flow-surfaces/locator.d.ts +28 -0
- package/dist/server/flow-surfaces/locator.js +240 -0
- package/dist/server/flow-surfaces/node-use-sets.d.ts +15 -0
- package/dist/server/flow-surfaces/node-use-sets.js +135 -0
- package/dist/server/flow-surfaces/payload-shape.d.ts +9 -0
- package/dist/server/flow-surfaces/payload-shape.js +61 -0
- package/dist/server/flow-surfaces/placement.d.ts +33 -0
- package/dist/server/flow-surfaces/placement.js +198 -0
- 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 +88 -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/public-data-surface-default-filter.d.ts +24 -0
- package/dist/server/flow-surfaces/public-data-surface-default-filter.js +152 -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 +156 -0
- package/dist/server/flow-surfaces/reaction/registry.js +206 -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/route-sync.d.ts +47 -0
- package/dist/server/flow-surfaces/route-sync.js +392 -0
- package/dist/server/flow-surfaces/service-helpers.d.ts +42 -0
- package/dist/server/flow-surfaces/service-helpers.js +310 -0
- package/dist/server/flow-surfaces/service-utils.d.ts +120 -0
- package/dist/server/flow-surfaces/service-utils.js +863 -0
- package/dist/server/flow-surfaces/service.d.ts +830 -0
- package/dist/server/flow-surfaces/service.js +15043 -0
- package/dist/server/flow-surfaces/support-matrix.d.ts +31 -0
- package/dist/server/flow-surfaces/support-matrix.js +282 -0
- package/dist/server/flow-surfaces/surface-context.d.ts +52 -0
- package/dist/server/flow-surfaces/surface-context.js +440 -0
- 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-display.d.ts +20 -0
- package/dist/server/flow-surfaces/template-display.js +289 -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 +288 -0
- package/dist/server/flow-surfaces/types.js +24 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +7 -2
- package/dist/server/plugin.d.ts +0 -1
- package/dist/server/plugin.js +9 -34
- package/dist/server/repository.js +0 -5
- package/dist/server/variables/resolve.d.ts +21 -0
- package/dist/server/variables/resolve.js +79 -0
- package/dist/swagger/flow-surfaces.d.ts +6135 -0
- package/dist/swagger/flow-surfaces.examples.d.ts +1577 -0
- package/dist/swagger/flow-surfaces.examples.js +1816 -0
- package/dist/swagger/flow-surfaces.js +5384 -0
- 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 +6140 -0
- package/dist/swagger/index.js +50 -0
- package/package.json +3 -3
- /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextApis.d.ts +0 -0
- /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextEnvs.d.ts +0 -0
- /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextVars.d.ts +0 -0
- /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/lintAndTestJS.d.ts +0 -0
|
@@ -0,0 +1,1074 @@
|
|
|
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_default_block_actions = require("../default-block-actions");
|
|
47
|
+
var import_public_data_surface_default_filter = require("../public-data-surface-default-filter");
|
|
48
|
+
var import_defaults = require("./defaults");
|
|
49
|
+
var import_private_utils = require("./private-utils");
|
|
50
|
+
var import_field_type_resolver = require("../field-type-resolver");
|
|
51
|
+
const APPLY_BLUEPRINT_BLOCK_TYPE_ENUM = [
|
|
52
|
+
"table",
|
|
53
|
+
"calendar",
|
|
54
|
+
"kanban",
|
|
55
|
+
"createForm",
|
|
56
|
+
"editForm",
|
|
57
|
+
"details",
|
|
58
|
+
"filterForm",
|
|
59
|
+
"list",
|
|
60
|
+
"gridCard",
|
|
61
|
+
"markdown",
|
|
62
|
+
"iframe",
|
|
63
|
+
"chart",
|
|
64
|
+
"actionPanel",
|
|
65
|
+
"jsBlock",
|
|
66
|
+
"tree"
|
|
67
|
+
];
|
|
68
|
+
const APPLY_BLUEPRINT_BLOCK_ALLOWED_KEYS = [
|
|
69
|
+
"key",
|
|
70
|
+
"type",
|
|
71
|
+
"title",
|
|
72
|
+
"collection",
|
|
73
|
+
"dataSourceKey",
|
|
74
|
+
"associationPathName",
|
|
75
|
+
"binding",
|
|
76
|
+
"associationField",
|
|
77
|
+
"resource",
|
|
78
|
+
"template",
|
|
79
|
+
"settings",
|
|
80
|
+
"fields",
|
|
81
|
+
"fieldGroups",
|
|
82
|
+
"fieldsLayout",
|
|
83
|
+
"defaultFilter",
|
|
84
|
+
"actions",
|
|
85
|
+
"recordActions",
|
|
86
|
+
"script",
|
|
87
|
+
"chart"
|
|
88
|
+
];
|
|
89
|
+
const APPLY_BLUEPRINT_FIELD_ALLOWED_KEYS = [
|
|
90
|
+
"key",
|
|
91
|
+
"field",
|
|
92
|
+
"associationPathName",
|
|
93
|
+
"renderer",
|
|
94
|
+
"type",
|
|
95
|
+
"fieldType",
|
|
96
|
+
"fields",
|
|
97
|
+
"selectorFields",
|
|
98
|
+
"titleField",
|
|
99
|
+
"openMode",
|
|
100
|
+
"popupSize",
|
|
101
|
+
"pageSize",
|
|
102
|
+
"showIndex",
|
|
103
|
+
"label",
|
|
104
|
+
"target",
|
|
105
|
+
"settings",
|
|
106
|
+
"popup",
|
|
107
|
+
"script",
|
|
108
|
+
"chart"
|
|
109
|
+
];
|
|
110
|
+
const APPLY_BLUEPRINT_FIELD_GROUP_ALLOWED_KEYS = ["key", "title", "fields"];
|
|
111
|
+
const APPLY_BLUEPRINT_ACTION_ALLOWED_KEYS = ["key", "type", "title", "settings", "popup", "script", "chart"];
|
|
112
|
+
const APPLY_BLUEPRINT_POPUP_ALLOWED_KEYS = [
|
|
113
|
+
"title",
|
|
114
|
+
"mode",
|
|
115
|
+
"template",
|
|
116
|
+
"tryTemplate",
|
|
117
|
+
"defaultType",
|
|
118
|
+
"saveAsTemplate",
|
|
119
|
+
"blocks",
|
|
120
|
+
"layout"
|
|
121
|
+
];
|
|
122
|
+
const APPLY_BLUEPRINT_POPUP_SAVE_AS_TEMPLATE_ALLOWED_KEYS = ["name", "description", "local"];
|
|
123
|
+
const APPLY_BLUEPRINT_LAYOUT_ALLOWED_KEYS = ["rows"];
|
|
124
|
+
const APPLY_BLUEPRINT_LAYOUT_CELL_ALLOWED_KEYS = ["key", "span"];
|
|
125
|
+
const APPLY_BLUEPRINT_BLOCK_RESOURCE_ALLOWED_KEYS = [
|
|
126
|
+
"binding",
|
|
127
|
+
"dataSourceKey",
|
|
128
|
+
"collectionName",
|
|
129
|
+
"associationField",
|
|
130
|
+
"associationName",
|
|
131
|
+
"associationPathName",
|
|
132
|
+
"sourceId",
|
|
133
|
+
"filterByTk"
|
|
134
|
+
];
|
|
135
|
+
const APPLY_BLUEPRINT_BLOCK_RESOURCE_RAW_ONLY_KEYS = [
|
|
136
|
+
"associationName",
|
|
137
|
+
"associationPathName",
|
|
138
|
+
"sourceId",
|
|
139
|
+
"filterByTk"
|
|
140
|
+
];
|
|
141
|
+
const APPLY_BLUEPRINT_BLOCK_RESOURCE_SHORTHAND_KEYS = [
|
|
142
|
+
"collection",
|
|
143
|
+
"dataSourceKey",
|
|
144
|
+
"associationPathName",
|
|
145
|
+
"binding",
|
|
146
|
+
"associationField"
|
|
147
|
+
];
|
|
148
|
+
const APPLY_BLUEPRINT_RECORD_CAPABLE_BLOCK_TYPES = /* @__PURE__ */ new Set(["table", "details", "list", "gridCard"]);
|
|
149
|
+
const APPLY_BLUEPRINT_FIELD_GRID_BLOCK_TYPES = /* @__PURE__ */ new Set(["createForm", "editForm", "details", "filterForm"]);
|
|
150
|
+
const APPLY_BLUEPRINT_FIELD_GROUP_BLOCK_TYPES = /* @__PURE__ */ new Set(["createForm", "editForm", "details"]);
|
|
151
|
+
const APPLY_BLUEPRINT_AUTO_PROMOTED_RECORD_ACTION_TYPES = /* @__PURE__ */ new Set([
|
|
152
|
+
"view",
|
|
153
|
+
"edit",
|
|
154
|
+
"delete",
|
|
155
|
+
"updateRecord",
|
|
156
|
+
"duplicate"
|
|
157
|
+
]);
|
|
158
|
+
const APPLY_BLUEPRINT_DEFAULT_POPUP_ACTION_TYPES = /* @__PURE__ */ new Set(["addNew", "view", "edit"]);
|
|
159
|
+
const APPLY_BLUEPRINT_BLOCK_TYPES = new Set(APPLY_BLUEPRINT_BLOCK_TYPE_ENUM);
|
|
160
|
+
const APPLY_BLUEPRINT_ADD_CHILD_RECORD_ACTION_ERROR = "type 'addChild' must be authored under recordActions and is only valid when the live target catalog.recordActions exposes it for a tree collection table with treeTable enabled";
|
|
161
|
+
function assertNoBlockLevelLayout(input, context) {
|
|
162
|
+
if (Object.prototype.hasOwnProperty.call(input, "layout")) {
|
|
163
|
+
(0, import_errors.throwBadRequest)(`${context}.layout is not supported; layout is only allowed on tabs[] and popup`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function assertApplyBlueprintFieldsLayoutHost(block, context) {
|
|
167
|
+
if (!Object.prototype.hasOwnProperty.call(block, "fieldsLayout")) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if ((0, import_private_utils.readOptionalString)(block.type) === "kanban") {
|
|
171
|
+
(0, import_errors.throwBadRequest)(`${context}.fieldsLayout is not supported on kanban main blocks; use fields[] only`);
|
|
172
|
+
}
|
|
173
|
+
if (APPLY_BLUEPRINT_FIELD_GRID_BLOCK_TYPES.has((0, import_private_utils.readOptionalString)(block.type) || "")) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
(0, import_errors.throwBadRequest)(`${context}.fieldsLayout is only supported on createForm, editForm, details or filterForm`);
|
|
177
|
+
}
|
|
178
|
+
function assertApplyBlueprintCalendarMainContent(block, context) {
|
|
179
|
+
if ((0, import_private_utils.readOptionalString)(block.type) !== "calendar") {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (Object.prototype.hasOwnProperty.call(block, "fields")) {
|
|
183
|
+
(0, import_errors.throwBadRequest)(
|
|
184
|
+
`${context}.fields is not supported on calendar main blocks; add event fields under the quick-create or event-view popup host instead`
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
if (Object.prototype.hasOwnProperty.call(block, "fieldGroups")) {
|
|
188
|
+
(0, import_errors.throwBadRequest)(
|
|
189
|
+
`${context}.fieldGroups is not supported on calendar main blocks; add grouped fields under the quick-create or event-view popup host instead`
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
if (Object.prototype.hasOwnProperty.call(block, "recordActions")) {
|
|
193
|
+
(0, import_errors.throwBadRequest)(
|
|
194
|
+
`${context}.recordActions is not supported on calendar main blocks; configure event actions inside the event-view popup host instead`
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function assertApplyBlueprintKanbanMainContent(block, context) {
|
|
199
|
+
if ((0, import_private_utils.readOptionalString)(block.type) !== "kanban") {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (Object.prototype.hasOwnProperty.call(block, "fieldGroups")) {
|
|
203
|
+
(0, import_errors.throwBadRequest)(`${context}.fieldGroups is not supported on kanban main blocks; use fields instead`);
|
|
204
|
+
}
|
|
205
|
+
if (Object.prototype.hasOwnProperty.call(block, "recordActions")) {
|
|
206
|
+
(0, import_errors.throwBadRequest)(`${context}.recordActions is not supported on kanban main blocks in v1`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function assertApplyBlueprintTreeMainContent(block, context) {
|
|
210
|
+
if ((0, import_private_utils.readOptionalString)(block.type) !== "tree") {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (Object.prototype.hasOwnProperty.call(block, "fields")) {
|
|
214
|
+
(0, import_errors.throwBadRequest)(`${context}.fields is not supported on tree blocks`);
|
|
215
|
+
}
|
|
216
|
+
if (Object.prototype.hasOwnProperty.call(block, "fieldGroups")) {
|
|
217
|
+
(0, import_errors.throwBadRequest)(`${context}.fieldGroups is not supported on tree blocks`);
|
|
218
|
+
}
|
|
219
|
+
if (Object.prototype.hasOwnProperty.call(block, "actions")) {
|
|
220
|
+
(0, import_errors.throwBadRequest)(`${context}.actions is not supported on tree blocks`);
|
|
221
|
+
}
|
|
222
|
+
if (Object.prototype.hasOwnProperty.call(block, "recordActions")) {
|
|
223
|
+
(0, import_errors.throwBadRequest)(`${context}.recordActions is not supported on tree blocks`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function assertApplyBlueprintBlockType(type, context) {
|
|
227
|
+
if (!type) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (type === "form") {
|
|
231
|
+
(0, import_errors.throwBadRequest)(`${context}.type 'form' is unsupported in applyBlueprint; use 'editForm' or 'createForm'`);
|
|
232
|
+
}
|
|
233
|
+
if (!APPLY_BLUEPRINT_BLOCK_TYPES.has(type)) {
|
|
234
|
+
(0, import_errors.throwBadRequest)(
|
|
235
|
+
`${context}.type '${type}' is unsupported in applyBlueprint; supported types: ${APPLY_BLUEPRINT_BLOCK_TYPE_ENUM.join(
|
|
236
|
+
", "
|
|
237
|
+
)}`
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function normalizeEditPopupBlocks(input, context) {
|
|
242
|
+
input.forEach((block, index) => {
|
|
243
|
+
const blockType = (0, import_private_utils.readOptionalString)(block == null ? void 0 : block.type);
|
|
244
|
+
if (blockType === "form") {
|
|
245
|
+
(0, import_errors.throwBadRequest)(`${context}.blocks[${index}].type 'form' is unsupported in applyBlueprint; use 'editForm'`);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
const editFormBlocks = input.filter((block) => (0, import_private_utils.readOptionalString)(block == null ? void 0 : block.type) === "editForm");
|
|
249
|
+
if (!editFormBlocks.length) {
|
|
250
|
+
(0, import_errors.throwBadRequest)(`${context} custom edit popup must contain exactly one editForm block`);
|
|
251
|
+
}
|
|
252
|
+
if (editFormBlocks.length > 1) {
|
|
253
|
+
(0, import_errors.throwBadRequest)(`${context} custom edit popup must contain exactly one editForm block`);
|
|
254
|
+
}
|
|
255
|
+
return input.map((block, index) => {
|
|
256
|
+
const blockType = (0, import_private_utils.readOptionalString)(block == null ? void 0 : block.type);
|
|
257
|
+
if (blockType !== "editForm") {
|
|
258
|
+
return block;
|
|
259
|
+
}
|
|
260
|
+
if (!import_lodash.default.isPlainObject(block)) {
|
|
261
|
+
return block;
|
|
262
|
+
}
|
|
263
|
+
if (!import_lodash.default.isUndefined(block.resource)) {
|
|
264
|
+
if (import_lodash.default.isPlainObject(block.resource)) {
|
|
265
|
+
const binding = "binding" in block.resource ? (0, import_private_utils.readOptionalString)(block.resource.binding) : void 0;
|
|
266
|
+
if (!binding) {
|
|
267
|
+
(0, import_errors.throwBadRequest)(
|
|
268
|
+
`${context}.blocks[${index}].resource must use binding='currentRecord' or be omitted in a custom edit popup`
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
if (binding !== "currentRecord") {
|
|
272
|
+
(0, import_errors.throwBadRequest)(
|
|
273
|
+
`${context}.blocks[${index}].resource.binding must be 'currentRecord' in a custom edit popup`
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return block;
|
|
278
|
+
}
|
|
279
|
+
const shorthandBinding = (0, import_private_utils.readOptionalString)(block.binding);
|
|
280
|
+
if (!import_lodash.default.isUndefined(shorthandBinding)) {
|
|
281
|
+
if (shorthandBinding !== "currentRecord") {
|
|
282
|
+
(0, import_errors.throwBadRequest)(`${context}.blocks[${index}].binding must be 'currentRecord' in a custom edit popup`);
|
|
283
|
+
}
|
|
284
|
+
return block;
|
|
285
|
+
}
|
|
286
|
+
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);
|
|
287
|
+
if (hasRawShorthandResource) {
|
|
288
|
+
(0, import_errors.throwBadRequest)(
|
|
289
|
+
`${context}.blocks[${index}] must use binding='currentRecord' or omit resource entirely in a custom edit popup`
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
return {
|
|
293
|
+
...block,
|
|
294
|
+
resource: {
|
|
295
|
+
binding: "currentRecord"
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
function readAssociationFieldFromSingleSegmentPath(value, context) {
|
|
301
|
+
const associationPathName = (0, import_private_utils.readOptionalString)(value);
|
|
302
|
+
if (!associationPathName) {
|
|
303
|
+
return void 0;
|
|
304
|
+
}
|
|
305
|
+
const segments = associationPathName.split(".").map((segment) => segment.trim()).filter(Boolean);
|
|
306
|
+
if (!segments.length) {
|
|
307
|
+
(0, import_errors.throwBadRequest)(`${context}.associationPathName must be a non-empty association field path`);
|
|
308
|
+
}
|
|
309
|
+
if (segments.length > 1) {
|
|
310
|
+
(0, import_errors.throwBadRequest)(
|
|
311
|
+
`${context}.associationPathName '${associationPathName}' must be a single association field name when used with ${context}.binding; prefer ${context}.associationField for popup relation tables`
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
return segments[0];
|
|
315
|
+
}
|
|
316
|
+
function normalizeAssociatedRecordsBindingFromAssociationPath(input, context) {
|
|
317
|
+
const binding = (0, import_private_utils.readOptionalString)(input.binding);
|
|
318
|
+
const associationLeaf = readAssociationFieldFromSingleSegmentPath(input.associationPathName, context);
|
|
319
|
+
if (!binding || !associationLeaf) {
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
if (binding !== "currentRecord" && binding !== "associatedRecords") {
|
|
323
|
+
(0, import_errors.throwBadRequest)(
|
|
324
|
+
`${context} cannot mix ${context}.binding='${binding}' with ${context}.associationPathName; use associatedRecords + associationField on popup collection blocks`
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
const associationField = (0, import_private_utils.readOptionalString)(input.associationField);
|
|
328
|
+
if (associationField && associationField !== associationLeaf) {
|
|
329
|
+
(0, import_errors.throwBadRequest)(
|
|
330
|
+
`${context}.associationField '${associationField}' conflicts with ${context}.associationPathName '${(0, import_private_utils.readOptionalString)(
|
|
331
|
+
input.associationPathName
|
|
332
|
+
)}'`
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
return {
|
|
336
|
+
binding: "associatedRecords",
|
|
337
|
+
associationField: associationField || associationLeaf
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
function readApplyBlueprintActionType(input) {
|
|
341
|
+
if (typeof input === "string") {
|
|
342
|
+
return (0, import_private_utils.readString)(input);
|
|
343
|
+
}
|
|
344
|
+
if (import_lodash.default.isPlainObject(input)) {
|
|
345
|
+
return (0, import_private_utils.readOptionalString)(input.type);
|
|
346
|
+
}
|
|
347
|
+
return void 0;
|
|
348
|
+
}
|
|
349
|
+
function splitApplyBlueprintBlockActionsByScope(block, context) {
|
|
350
|
+
const rawActions = readOptionalItems(block.actions, `${context}.actions`);
|
|
351
|
+
const rawRecordActions = readOptionalItems(block.recordActions, `${context}.recordActions`);
|
|
352
|
+
const blockType = (0, import_private_utils.readOptionalString)(block.type);
|
|
353
|
+
if (!blockType || !APPLY_BLUEPRINT_RECORD_CAPABLE_BLOCK_TYPES.has(blockType)) {
|
|
354
|
+
return {
|
|
355
|
+
actions: rawActions,
|
|
356
|
+
recordActions: rawRecordActions
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
const promotedRecordActions = [];
|
|
360
|
+
const remainingActions = [];
|
|
361
|
+
rawActions.forEach((action, index) => {
|
|
362
|
+
const actionType = readApplyBlueprintActionType(action);
|
|
363
|
+
if (actionType === "addChild") {
|
|
364
|
+
(0, import_errors.throwBadRequest)(`${context}.actions[${index}] ${APPLY_BLUEPRINT_ADD_CHILD_RECORD_ACTION_ERROR}`);
|
|
365
|
+
}
|
|
366
|
+
if (actionType && APPLY_BLUEPRINT_AUTO_PROMOTED_RECORD_ACTION_TYPES.has(actionType)) {
|
|
367
|
+
promotedRecordActions.push(action);
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
remainingActions.push(action);
|
|
371
|
+
});
|
|
372
|
+
return {
|
|
373
|
+
actions: remainingActions,
|
|
374
|
+
recordActions: [...rawRecordActions, ...promotedRecordActions]
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
function resolveAssetSettings(settings, spec, assets, context) {
|
|
378
|
+
const nextSettings = (0, import_private_utils.cloneOptionalPlainObject)(settings, `${context}.settings`) || {};
|
|
379
|
+
const mergeAsset = (bucket, assetKey) => {
|
|
380
|
+
const normalizedKey = (0, import_private_utils.readOptionalString)(assetKey);
|
|
381
|
+
if (!normalizedKey) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
const registry = assets[bucket] || {};
|
|
385
|
+
const asset = registry[normalizedKey];
|
|
386
|
+
if (!import_lodash.default.isPlainObject(asset)) {
|
|
387
|
+
(0, import_errors.throwBadRequest)(`${context} ${bucket.slice(0, -1)} asset '${normalizedKey}' is not defined in assets.${bucket}`);
|
|
388
|
+
}
|
|
389
|
+
import_lodash.default.merge(nextSettings, import_lodash.default.cloneDeep(asset));
|
|
390
|
+
};
|
|
391
|
+
mergeAsset("charts", spec.chart);
|
|
392
|
+
mergeAsset("scripts", spec.script);
|
|
393
|
+
return nextSettings;
|
|
394
|
+
}
|
|
395
|
+
function readOptionalItems(value, context) {
|
|
396
|
+
return (0, import_private_utils.readOptionalArray)(value, context) || [];
|
|
397
|
+
}
|
|
398
|
+
function ensureOptionalTemplate(value, context) {
|
|
399
|
+
return (0, import_private_utils.cloneOptionalPlainObject)(value, context);
|
|
400
|
+
}
|
|
401
|
+
function resolvePopupTitleSettings(settings, title) {
|
|
402
|
+
if (!title) {
|
|
403
|
+
return settings;
|
|
404
|
+
}
|
|
405
|
+
const nextSettings = import_lodash.default.cloneDeep(settings || {});
|
|
406
|
+
if (import_lodash.default.isUndefined(import_lodash.default.get(nextSettings, ["openView", "title"]))) {
|
|
407
|
+
import_lodash.default.set(nextSettings, ["openView", "title"], title);
|
|
408
|
+
}
|
|
409
|
+
return nextSettings;
|
|
410
|
+
}
|
|
411
|
+
function normalizeBlockResourceObject(input, context) {
|
|
412
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(input, context, APPLY_BLUEPRINT_BLOCK_RESOURCE_ALLOWED_KEYS);
|
|
413
|
+
const hasBinding = Object.prototype.hasOwnProperty.call(input, "binding");
|
|
414
|
+
if (hasBinding) {
|
|
415
|
+
const normalizedAssociatedRecords = normalizeAssociatedRecordsBindingFromAssociationPath(input, context);
|
|
416
|
+
const mixedRawKeys = APPLY_BLUEPRINT_BLOCK_RESOURCE_RAW_ONLY_KEYS.filter(
|
|
417
|
+
(key) => Object.prototype.hasOwnProperty.call(input, key) && !(normalizedAssociatedRecords && key === "associationPathName")
|
|
418
|
+
);
|
|
419
|
+
if (mixedRawKeys.length) {
|
|
420
|
+
(0, import_errors.throwBadRequest)(
|
|
421
|
+
`${context} cannot mix binding with ${mixedRawKeys.map((key) => `${context}.${key}`).join(", ")}`
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
425
|
+
binding: (normalizedAssociatedRecords == null ? void 0 : normalizedAssociatedRecords.binding) || (0, import_private_utils.assertNonEmptyString)(input.binding, `${context}.binding`),
|
|
426
|
+
dataSourceKey: (0, import_private_utils.readOptionalString)(input.dataSourceKey),
|
|
427
|
+
collectionName: (0, import_private_utils.readOptionalString)(input.collectionName),
|
|
428
|
+
associationField: (normalizedAssociatedRecords == null ? void 0 : normalizedAssociatedRecords.associationField) || (0, import_private_utils.readOptionalString)(input.associationField)
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
if (Object.prototype.hasOwnProperty.call(input, "associationField")) {
|
|
432
|
+
(0, import_errors.throwBadRequest)(`${context}.associationField only works when ${context}.binding is provided`);
|
|
433
|
+
}
|
|
434
|
+
const collectionName = (0, import_private_utils.readOptionalString)(input.collectionName);
|
|
435
|
+
const normalized = (0, import_service_utils.buildDefinedPayload)({
|
|
436
|
+
dataSourceKey: (0, import_private_utils.readOptionalString)(input.dataSourceKey) || (collectionName ? "main" : void 0),
|
|
437
|
+
collectionName,
|
|
438
|
+
associationName: (0, import_private_utils.readOptionalString)(input.associationName),
|
|
439
|
+
associationPathName: (0, import_private_utils.readOptionalString)(input.associationPathName),
|
|
440
|
+
sourceId: input.sourceId,
|
|
441
|
+
filterByTk: input.filterByTk
|
|
442
|
+
});
|
|
443
|
+
if (!Object.keys(normalized).length) {
|
|
444
|
+
(0, import_errors.throwBadRequest)(`${context} cannot be empty`);
|
|
445
|
+
}
|
|
446
|
+
return normalized;
|
|
447
|
+
}
|
|
448
|
+
function buildBlockResource(block, context) {
|
|
449
|
+
if (!import_lodash.default.isUndefined(block.resource)) {
|
|
450
|
+
if (!import_lodash.default.isPlainObject(block.resource)) {
|
|
451
|
+
(0, import_errors.throwBadRequest)(`${context}.resource must be an object`);
|
|
452
|
+
}
|
|
453
|
+
const mixedShorthandKeys = APPLY_BLUEPRINT_BLOCK_RESOURCE_SHORTHAND_KEYS.filter(
|
|
454
|
+
(key) => Object.prototype.hasOwnProperty.call(block, key)
|
|
455
|
+
);
|
|
456
|
+
if (mixedShorthandKeys.length) {
|
|
457
|
+
(0, import_errors.throwBadRequest)(
|
|
458
|
+
`${context} cannot mix resource with ${mixedShorthandKeys.map((key) => `${context}.${key}`).join(", ")}`
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
return normalizeBlockResourceObject(block.resource, `${context}.resource`);
|
|
462
|
+
}
|
|
463
|
+
const binding = (0, import_private_utils.readOptionalString)(block.binding);
|
|
464
|
+
if (binding) {
|
|
465
|
+
const normalizedAssociatedRecords = normalizeAssociatedRecordsBindingFromAssociationPath(
|
|
466
|
+
block,
|
|
467
|
+
context
|
|
468
|
+
);
|
|
469
|
+
if (Object.prototype.hasOwnProperty.call(block, "associationPathName") && !normalizedAssociatedRecords) {
|
|
470
|
+
(0, import_errors.throwBadRequest)(`${context} cannot mix ${context}.binding with ${context}.associationPathName`);
|
|
471
|
+
}
|
|
472
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
473
|
+
binding: (normalizedAssociatedRecords == null ? void 0 : normalizedAssociatedRecords.binding) || binding,
|
|
474
|
+
dataSourceKey: (0, import_private_utils.readOptionalString)(block.dataSourceKey),
|
|
475
|
+
collectionName: (0, import_private_utils.readOptionalString)(block.collection),
|
|
476
|
+
associationField: (normalizedAssociatedRecords == null ? void 0 : normalizedAssociatedRecords.associationField) || (0, import_private_utils.readOptionalString)(block.associationField)
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
if (Object.prototype.hasOwnProperty.call(block, "associationField")) {
|
|
480
|
+
(0, import_errors.throwBadRequest)(`${context}.associationField only works when ${context}.binding is provided`);
|
|
481
|
+
}
|
|
482
|
+
const collectionName = (0, import_private_utils.readOptionalString)(block.collection);
|
|
483
|
+
if (!collectionName) {
|
|
484
|
+
return void 0;
|
|
485
|
+
}
|
|
486
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
487
|
+
dataSourceKey: (0, import_private_utils.readOptionalString)(block.dataSourceKey) || "main",
|
|
488
|
+
collectionName,
|
|
489
|
+
associationPathName: (0, import_private_utils.readOptionalString)(block.associationPathName)
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
function ensureLayoutRows(layout, context) {
|
|
493
|
+
if (import_lodash.default.isUndefined(layout)) {
|
|
494
|
+
return void 0;
|
|
495
|
+
}
|
|
496
|
+
if (!import_lodash.default.isPlainObject(layout)) {
|
|
497
|
+
(0, import_errors.throwBadRequest)(`${context} must be an object`);
|
|
498
|
+
}
|
|
499
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(layout, context, APPLY_BLUEPRINT_LAYOUT_ALLOWED_KEYS);
|
|
500
|
+
if (!Array.isArray(layout.rows) || !layout.rows.length) {
|
|
501
|
+
(0, import_errors.throwBadRequest)(`${context}.rows must be a non-empty array`);
|
|
502
|
+
}
|
|
503
|
+
return layout.rows.map((row, rowIndex) => {
|
|
504
|
+
if (!Array.isArray(row) || !row.length) {
|
|
505
|
+
(0, import_errors.throwBadRequest)(`${context}.rows[${rowIndex}] must be a non-empty array`);
|
|
506
|
+
}
|
|
507
|
+
row.forEach((item, itemIndex) => {
|
|
508
|
+
if (typeof item === "string") {
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
if (!import_lodash.default.isPlainObject(item)) {
|
|
512
|
+
(0, import_errors.throwBadRequest)(`${context}.rows[${rowIndex}][${itemIndex}] must be a string or object`);
|
|
513
|
+
}
|
|
514
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(
|
|
515
|
+
item,
|
|
516
|
+
`${context}.rows[${rowIndex}][${itemIndex}]`,
|
|
517
|
+
APPLY_BLUEPRINT_LAYOUT_CELL_ALLOWED_KEYS
|
|
518
|
+
);
|
|
519
|
+
});
|
|
520
|
+
return row;
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
function autoLayoutFromBlockKeys(blockKeys) {
|
|
524
|
+
return {
|
|
525
|
+
rows: blockKeys.map((key) => [key])
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
function collectReferencedBlockKeys(layout, context) {
|
|
529
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
530
|
+
const rows = ensureLayoutRows(layout, context) || [];
|
|
531
|
+
rows.forEach((row, rowIndex) => {
|
|
532
|
+
row.forEach((cell, itemIndex) => {
|
|
533
|
+
if (typeof cell === "string") {
|
|
534
|
+
const key2 = (0, import_private_utils.readString)(cell);
|
|
535
|
+
if (key2) {
|
|
536
|
+
referenced.add(key2);
|
|
537
|
+
}
|
|
538
|
+
return;
|
|
539
|
+
}
|
|
540
|
+
const key = (0, import_private_utils.assertNonEmptyString)(cell.key, `${context}.rows[${rowIndex}][${itemIndex}].key`);
|
|
541
|
+
if (key) {
|
|
542
|
+
referenced.add(key);
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
});
|
|
546
|
+
return referenced;
|
|
547
|
+
}
|
|
548
|
+
function compileLayout(layout, blockKeysByLocalKey, context) {
|
|
549
|
+
return compileScopedLayout(layout, blockKeysByLocalKey, context, "block");
|
|
550
|
+
}
|
|
551
|
+
function resolveScopedLayoutKey(rawKey, keysByLocalKey, context, kind) {
|
|
552
|
+
const resolved = keysByLocalKey.get(rawKey) || [...keysByLocalKey.values()].find((value) => value === rawKey);
|
|
553
|
+
if (!resolved) {
|
|
554
|
+
(0, import_errors.throwBadRequest)(`${context} references unknown ${kind} '${rawKey}'`);
|
|
555
|
+
}
|
|
556
|
+
return resolved;
|
|
557
|
+
}
|
|
558
|
+
function compileScopedLayout(layout, keysByLocalKey, context, kind) {
|
|
559
|
+
const rows = ensureLayoutRows(layout, context);
|
|
560
|
+
if (!rows) {
|
|
561
|
+
return void 0;
|
|
562
|
+
}
|
|
563
|
+
return {
|
|
564
|
+
rows: rows.map((row, rowIndex) => {
|
|
565
|
+
return row.map((item, itemIndex) => {
|
|
566
|
+
const cellContext = `${context}.rows[${rowIndex}][${itemIndex}]`;
|
|
567
|
+
if (typeof item === "string") {
|
|
568
|
+
const itemKey = (0, import_private_utils.readString)(item);
|
|
569
|
+
return resolveScopedLayoutKey(itemKey, keysByLocalKey, cellContext, kind);
|
|
570
|
+
}
|
|
571
|
+
const rawKey = (0, import_private_utils.assertNonEmptyString)(item.key, `${cellContext}.key`);
|
|
572
|
+
const resolved = resolveScopedLayoutKey(rawKey, keysByLocalKey, cellContext, kind);
|
|
573
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
574
|
+
key: resolved,
|
|
575
|
+
span: import_lodash.default.isUndefined(item.span) ? void 0 : import_lodash.default.isNumber(item.span) ? item.span : (0, import_errors.throwBadRequest)(`${cellContext}.span must be a number`)
|
|
576
|
+
});
|
|
577
|
+
});
|
|
578
|
+
})
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
function buildCompactFieldLayoutRow(keys, blockType) {
|
|
582
|
+
const normalizedKeys = keys.filter(Boolean);
|
|
583
|
+
if (!normalizedKeys.length) {
|
|
584
|
+
return [];
|
|
585
|
+
}
|
|
586
|
+
if (blockType === "filterForm") {
|
|
587
|
+
const span = normalizedKeys.length === 1 ? 24 : normalizedKeys.length === 2 ? 12 : 8;
|
|
588
|
+
return normalizedKeys.map((key) => ({ key, span }));
|
|
589
|
+
}
|
|
590
|
+
if (normalizedKeys.length === 1) {
|
|
591
|
+
return [{ key: normalizedKeys[0], span: 24 }];
|
|
592
|
+
}
|
|
593
|
+
return normalizedKeys.map((key) => ({ key, span: 12 }));
|
|
594
|
+
}
|
|
595
|
+
function buildAutoCompiledFieldsLayout(fields, blockType) {
|
|
596
|
+
if (!APPLY_BLUEPRINT_FIELD_GRID_BLOCK_TYPES.has(blockType || "") || !fields.length) {
|
|
597
|
+
return void 0;
|
|
598
|
+
}
|
|
599
|
+
const rows = [];
|
|
600
|
+
const chunkSize = blockType === "filterForm" ? 3 : 2;
|
|
601
|
+
let pendingKeys = [];
|
|
602
|
+
const flushPending = () => {
|
|
603
|
+
if (!pendingKeys.length) {
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
rows.push(buildCompactFieldLayoutRow(pendingKeys, blockType));
|
|
607
|
+
pendingKeys = [];
|
|
608
|
+
};
|
|
609
|
+
fields.forEach((field) => {
|
|
610
|
+
const key = (0, import_private_utils.readOptionalString)(field == null ? void 0 : field.key);
|
|
611
|
+
if (!key) {
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
if ((0, import_private_utils.readOptionalString)(field == null ? void 0 : field.type) === "divider") {
|
|
615
|
+
flushPending();
|
|
616
|
+
rows.push([{ key, span: 24 }]);
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
pendingKeys.push(key);
|
|
620
|
+
if (pendingKeys.length >= chunkSize) {
|
|
621
|
+
flushPending();
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
flushPending();
|
|
625
|
+
return rows.length ? { rows } : void 0;
|
|
626
|
+
}
|
|
627
|
+
function compileFieldGroups(fieldGroups, context) {
|
|
628
|
+
const expanded = [];
|
|
629
|
+
fieldGroups.forEach((group, groupIndex) => {
|
|
630
|
+
const groupContext = `${context}[${groupIndex}]`;
|
|
631
|
+
if (!import_lodash.default.isPlainObject(group)) {
|
|
632
|
+
(0, import_errors.throwBadRequest)(`${groupContext} must be an object`);
|
|
633
|
+
}
|
|
634
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(group, groupContext, APPLY_BLUEPRINT_FIELD_GROUP_ALLOWED_KEYS);
|
|
635
|
+
const title = (0, import_private_utils.assertNonEmptyString)(group.title, `${groupContext}.title`);
|
|
636
|
+
const groupFields = readOptionalItems(group.fields, `${groupContext}.fields`);
|
|
637
|
+
if (!groupFields.length) {
|
|
638
|
+
(0, import_errors.throwBadRequest)(`${groupContext}.fields must be a non-empty array`);
|
|
639
|
+
}
|
|
640
|
+
const groupLocalKey = (0, import_private_utils.normalizeBlueprintLocalKey)(
|
|
641
|
+
group.key,
|
|
642
|
+
title || `group_${groupIndex + 1}`,
|
|
643
|
+
`${groupContext}.key`
|
|
644
|
+
);
|
|
645
|
+
expanded.push({
|
|
646
|
+
key: `${groupLocalKey}_divider`,
|
|
647
|
+
type: "divider",
|
|
648
|
+
settings: {
|
|
649
|
+
label: title,
|
|
650
|
+
orientation: "left"
|
|
651
|
+
}
|
|
652
|
+
});
|
|
653
|
+
expanded.push(...groupFields);
|
|
654
|
+
});
|
|
655
|
+
return expanded;
|
|
656
|
+
}
|
|
657
|
+
function resolveBlockFieldInputs(block, context) {
|
|
658
|
+
const hasFields = Object.prototype.hasOwnProperty.call(block, "fields");
|
|
659
|
+
const hasFieldGroups = Object.prototype.hasOwnProperty.call(block, "fieldGroups");
|
|
660
|
+
if (hasFields && hasFieldGroups) {
|
|
661
|
+
(0, import_errors.throwBadRequest)(`${context} cannot mix fields with fieldGroups`);
|
|
662
|
+
}
|
|
663
|
+
if (!hasFieldGroups) {
|
|
664
|
+
return readOptionalItems(block.fields, `${context}.fields`);
|
|
665
|
+
}
|
|
666
|
+
const blockType = (0, import_private_utils.readOptionalString)(block.type);
|
|
667
|
+
if (!APPLY_BLUEPRINT_FIELD_GROUP_BLOCK_TYPES.has(blockType || "")) {
|
|
668
|
+
(0, import_errors.throwBadRequest)(`${context}.fieldGroups is only supported on createForm, editForm or details`);
|
|
669
|
+
}
|
|
670
|
+
if (Object.prototype.hasOwnProperty.call(block, "fieldsLayout")) {
|
|
671
|
+
(0, import_errors.throwBadRequest)(`${context}.fieldsLayout cannot be combined with ${context}.fieldGroups`);
|
|
672
|
+
}
|
|
673
|
+
const fieldGroups = (0, import_private_utils.readOptionalArray)(
|
|
674
|
+
block.fieldGroups,
|
|
675
|
+
`${context}.fieldGroups`
|
|
676
|
+
);
|
|
677
|
+
if (!(fieldGroups == null ? void 0 : fieldGroups.length)) {
|
|
678
|
+
(0, import_errors.throwBadRequest)(`${context}.fieldGroups must be a non-empty array`);
|
|
679
|
+
}
|
|
680
|
+
return compileFieldGroups(fieldGroups, `${context}.fieldGroups`);
|
|
681
|
+
}
|
|
682
|
+
function resolveApplyBlueprintFieldLocalKey(input, index, context) {
|
|
683
|
+
if (typeof input === "string") {
|
|
684
|
+
return (0, import_private_utils.assertNonEmptyString)(input, `${context}[${index}]`);
|
|
685
|
+
}
|
|
686
|
+
if (!import_lodash.default.isPlainObject(input)) {
|
|
687
|
+
(0, import_errors.throwBadRequest)(`${context}[${index}] must be a string or object`);
|
|
688
|
+
}
|
|
689
|
+
const fieldPath = (0, import_private_utils.readOptionalString)(input.field);
|
|
690
|
+
const syntheticType = (0, import_private_utils.readOptionalString)(input.type);
|
|
691
|
+
if (!fieldPath && !syntheticType) {
|
|
692
|
+
(0, import_errors.throwBadRequest)(`${context}[${index}] requires field or type`);
|
|
693
|
+
}
|
|
694
|
+
if (fieldPath && syntheticType) {
|
|
695
|
+
(0, import_errors.throwBadRequest)(`${context}[${index}] cannot mix field with synthetic type`);
|
|
696
|
+
}
|
|
697
|
+
return (0, import_private_utils.normalizeBlueprintLocalKey)(
|
|
698
|
+
input.key,
|
|
699
|
+
fieldPath || (syntheticType ? `${syntheticType}_${index + 1}` : `field_${index + 1}`),
|
|
700
|
+
`${context}[${index}].key`
|
|
701
|
+
);
|
|
702
|
+
}
|
|
703
|
+
function buildCompiledFieldKeyMap(inputs, compiledFields, context) {
|
|
704
|
+
const fieldKeysByLocalKey = /* @__PURE__ */ new Map();
|
|
705
|
+
inputs.forEach((input, index) => {
|
|
706
|
+
var _a;
|
|
707
|
+
const localKey = resolveApplyBlueprintFieldLocalKey(input, index, context);
|
|
708
|
+
const compiledKey = (0, import_private_utils.readOptionalString)((_a = compiledFields[index]) == null ? void 0 : _a.key);
|
|
709
|
+
if (!compiledKey) {
|
|
710
|
+
(0, import_errors.throwBadRequest)(`${context}[${index}] key '${localKey}' is missing after field key compilation`);
|
|
711
|
+
}
|
|
712
|
+
if (fieldKeysByLocalKey.has(localKey)) {
|
|
713
|
+
(0, import_errors.throwBadRequest)(`${context}[${index}] key '${localKey}' is duplicated`);
|
|
714
|
+
}
|
|
715
|
+
fieldKeysByLocalKey.set(localKey, compiledKey);
|
|
716
|
+
});
|
|
717
|
+
return fieldKeysByLocalKey;
|
|
718
|
+
}
|
|
719
|
+
function shouldAttachDefaultPopupMetadata(popup, itemType, options = {}) {
|
|
720
|
+
return !import_lodash.default.isUndefined(popup) || options.autoRelationField || APPLY_BLUEPRINT_DEFAULT_POPUP_ACTION_TYPES.has(itemType || "");
|
|
721
|
+
}
|
|
722
|
+
function attachCompiledPopupDefaults(popup, metadata) {
|
|
723
|
+
return (0, import_defaults.attachFlowSurfaceApplyBlueprintPopupDefaults)(popup, metadata);
|
|
724
|
+
}
|
|
725
|
+
function compilePopup(popup, scopePrefix, assets, context, defaults, options = {}) {
|
|
726
|
+
if (import_lodash.default.isUndefined(popup)) {
|
|
727
|
+
return {};
|
|
728
|
+
}
|
|
729
|
+
if (!import_lodash.default.isPlainObject(popup)) {
|
|
730
|
+
(0, import_errors.throwBadRequest)(`${context} must be an object`);
|
|
731
|
+
}
|
|
732
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(popup, context, APPLY_BLUEPRINT_POPUP_ALLOWED_KEYS);
|
|
733
|
+
const popupTitle = (0, import_private_utils.readOptionalString)(popup.title);
|
|
734
|
+
const template = ensureOptionalTemplate(popup.template, `${context}.template`);
|
|
735
|
+
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`);
|
|
736
|
+
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'`);
|
|
737
|
+
const saveAsTemplate = import_lodash.default.isUndefined(popup.saveAsTemplate) ? void 0 : import_lodash.default.isPlainObject(popup.saveAsTemplate) ? ((0, import_private_utils.assertOnlyAllowedKeys)(
|
|
738
|
+
popup.saveAsTemplate,
|
|
739
|
+
`${context}.saveAsTemplate`,
|
|
740
|
+
APPLY_BLUEPRINT_POPUP_SAVE_AS_TEMPLATE_ALLOWED_KEYS
|
|
741
|
+
), {
|
|
742
|
+
name: (0, import_private_utils.assertNonEmptyString)(popup.saveAsTemplate.name, `${context}.saveAsTemplate.name`),
|
|
743
|
+
description: (0, import_private_utils.assertNonEmptyString)(popup.saveAsTemplate.description, `${context}.saveAsTemplate.description`),
|
|
744
|
+
local: (0, import_private_utils.readOptionalString)(popup.saveAsTemplate.local)
|
|
745
|
+
}) : (0, import_errors.throwBadRequest)(`${context}.saveAsTemplate must be an object`);
|
|
746
|
+
if (saveAsTemplate && template) {
|
|
747
|
+
(0, import_errors.throwBadRequest)(`${context}.saveAsTemplate cannot be combined with ${context}.template`);
|
|
748
|
+
}
|
|
749
|
+
if (template) {
|
|
750
|
+
return {
|
|
751
|
+
popup: {
|
|
752
|
+
template
|
|
753
|
+
},
|
|
754
|
+
popupTitle
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
const rawPopupBlocks = readOptionalItems(popup.blocks, `${context}.blocks`);
|
|
758
|
+
const popupBlocks = options.ownerActionType === "edit" && rawPopupBlocks.length ? normalizeEditPopupBlocks(rawPopupBlocks, context) : rawPopupBlocks;
|
|
759
|
+
if (saveAsTemplate && !popupBlocks.length && tryTemplate !== true) {
|
|
760
|
+
(0, import_errors.throwBadRequest)(`${context}.saveAsTemplate requires explicit popup.blocks`);
|
|
761
|
+
}
|
|
762
|
+
const compiledBlocks = popupBlocks.length ? compileBlocks(
|
|
763
|
+
popupBlocks,
|
|
764
|
+
scopePrefix,
|
|
765
|
+
assets,
|
|
766
|
+
`${context}.blocks`,
|
|
767
|
+
defaults,
|
|
768
|
+
collectReferencedBlockKeys(popup.layout, `${context}.layout`)
|
|
769
|
+
) : { blocks: [], blockKeysByLocalKey: /* @__PURE__ */ new Map() };
|
|
770
|
+
const layout = popupBlocks.length || popup.layout ? compileLayout(
|
|
771
|
+
popup.layout || autoLayoutFromBlockKeys(compiledBlocks.blocks.map((block) => block.key)),
|
|
772
|
+
compiledBlocks.blockKeysByLocalKey,
|
|
773
|
+
`${context}.layout`
|
|
774
|
+
) : void 0;
|
|
775
|
+
const popupMode = (0, import_private_utils.readOptionalString)(popup.mode);
|
|
776
|
+
if (popupMode && popupMode !== "replace" && popupMode !== "append") {
|
|
777
|
+
(0, import_errors.throwBadRequest)(`${context}.mode must be 'replace' or 'append'`);
|
|
778
|
+
}
|
|
779
|
+
const compiledPopup = (0, import_service_utils.buildDefinedPayload)({
|
|
780
|
+
mode: popupMode || (popupBlocks.length || template || layout ? "replace" : void 0),
|
|
781
|
+
template,
|
|
782
|
+
...tryTemplate ? { tryTemplate: true } : {},
|
|
783
|
+
...defaultType ? { defaultType } : {},
|
|
784
|
+
...saveAsTemplate ? { saveAsTemplate } : {},
|
|
785
|
+
blocks: compiledBlocks.blocks.length ? compiledBlocks.blocks : void 0,
|
|
786
|
+
layout
|
|
787
|
+
});
|
|
788
|
+
return {
|
|
789
|
+
popup: Object.keys(compiledPopup).length ? compiledPopup : {},
|
|
790
|
+
popupTitle
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
function resolveTargetBlockKey(value, localBlockKeys, context) {
|
|
794
|
+
if (import_lodash.default.isUndefined(value) || value === null || value === "") {
|
|
795
|
+
return void 0;
|
|
796
|
+
}
|
|
797
|
+
if (typeof value === "string") {
|
|
798
|
+
const normalized = (0, import_private_utils.readString)(value);
|
|
799
|
+
return localBlockKeys.get(normalized) || normalized;
|
|
800
|
+
}
|
|
801
|
+
(0, import_errors.throwBadRequest)(`${context} must be a string block key`);
|
|
802
|
+
}
|
|
803
|
+
function compileField(input, index, scopePrefix, assets, localBlockKeys, context, popupDefaultsMetadata, defaults) {
|
|
804
|
+
if (typeof input === "string") {
|
|
805
|
+
const fieldPath2 = (0, import_private_utils.assertNonEmptyString)(input, `${context}[${index}]`);
|
|
806
|
+
return {
|
|
807
|
+
key: (0, import_service_utils.normalizeFlowSurfaceComposeKey)((0, import_private_utils.buildScopedKey)(scopePrefix, fieldPath2), `${context}[${index}]`),
|
|
808
|
+
fieldPath: fieldPath2,
|
|
809
|
+
__autoPopupForRelationField: true,
|
|
810
|
+
...popupDefaultsMetadata ? { [import_defaults.FLOW_SURFACE_APPLY_BLUEPRINT_POPUP_DEFAULTS_KEY]: import_lodash.default.cloneDeep(popupDefaultsMetadata) } : {}
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
if (!import_lodash.default.isPlainObject(input)) {
|
|
814
|
+
(0, import_errors.throwBadRequest)(`${context}[${index}] must be a string or object`);
|
|
815
|
+
}
|
|
816
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(input, `${context}[${index}]`, APPLY_BLUEPRINT_FIELD_ALLOWED_KEYS);
|
|
817
|
+
(0, import_field_type_resolver.assertNoInternalFieldKeys)(input, `${context}[${index}]`);
|
|
818
|
+
(0, import_field_type_resolver.assertNoInternalFieldKeys)(input.settings, `${context}[${index}].settings`);
|
|
819
|
+
const fieldPath = (0, import_private_utils.readOptionalString)(input.field);
|
|
820
|
+
const syntheticType = (0, import_private_utils.readOptionalString)(input.type);
|
|
821
|
+
const fieldType = (0, import_field_type_resolver.normalizePublicFieldType)(input.fieldType, `${context}[${index}]`);
|
|
822
|
+
const fields = (0, import_field_type_resolver.normalizePublicFieldNameList)(input.fields, `${context}[${index}].fields`);
|
|
823
|
+
const selectorFields = (0, import_field_type_resolver.normalizePublicFieldNameList)(
|
|
824
|
+
input.selectorFields,
|
|
825
|
+
`${context}[${index}].selectorFields`
|
|
826
|
+
);
|
|
827
|
+
if (!fieldPath && !syntheticType) {
|
|
828
|
+
(0, import_errors.throwBadRequest)(`${context}[${index}] requires field or type`);
|
|
829
|
+
}
|
|
830
|
+
if (fieldPath && syntheticType) {
|
|
831
|
+
(0, import_errors.throwBadRequest)(`${context}[${index}] cannot mix field with synthetic type`);
|
|
832
|
+
}
|
|
833
|
+
const localKey = (0, import_private_utils.normalizeBlueprintLocalKey)(
|
|
834
|
+
input.key,
|
|
835
|
+
fieldPath || (syntheticType ? `${syntheticType}_${index + 1}` : `field_${index + 1}`),
|
|
836
|
+
`${context}[${index}].key`
|
|
837
|
+
);
|
|
838
|
+
const key = (0, import_service_utils.normalizeFlowSurfaceComposeKey)((0, import_private_utils.buildScopedKey)(scopePrefix, localKey), `${context}[${index}]`);
|
|
839
|
+
let settings = resolveAssetSettings(input.settings, input, assets, `${context}[${index}]`);
|
|
840
|
+
if ((0, import_private_utils.readOptionalString)(input.label) && import_lodash.default.isUndefined(settings.label)) {
|
|
841
|
+
settings.label = (0, import_private_utils.readOptionalString)(input.label);
|
|
842
|
+
}
|
|
843
|
+
const popupResult = compilePopup(input.popup, `${key}.popup`, assets, `${context}[${index}].popup`, defaults);
|
|
844
|
+
settings = resolvePopupTitleSettings(settings, popupResult.popupTitle);
|
|
845
|
+
const popup = shouldAttachDefaultPopupMetadata(input.popup, void 0) ? attachCompiledPopupDefaults(popupResult.popup, popupDefaultsMetadata) : popupResult.popup;
|
|
846
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
847
|
+
key,
|
|
848
|
+
fieldPath,
|
|
849
|
+
associationPathName: (0, import_private_utils.readOptionalString)(input.associationPathName),
|
|
850
|
+
renderer: (0, import_private_utils.readOptionalString)(input.renderer),
|
|
851
|
+
type: syntheticType,
|
|
852
|
+
fieldType,
|
|
853
|
+
fields,
|
|
854
|
+
selectorFields,
|
|
855
|
+
titleField: (0, import_private_utils.readOptionalString)(input.titleField),
|
|
856
|
+
openMode: (0, import_private_utils.readOptionalString)(input.openMode),
|
|
857
|
+
popupSize: (0, import_private_utils.readOptionalString)(input.popupSize),
|
|
858
|
+
pageSize: input.pageSize,
|
|
859
|
+
showIndex: input.showIndex,
|
|
860
|
+
target: resolveTargetBlockKey(input.target, localBlockKeys, `${context}[${index}].target`),
|
|
861
|
+
settings: Object.keys(settings).length ? settings : void 0,
|
|
862
|
+
popup
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
function compileAction(input, index, scopePrefix, assets, context, popupDefaultsMetadata, defaults) {
|
|
866
|
+
if (typeof input === "string") {
|
|
867
|
+
const type2 = (0, import_private_utils.assertNonEmptyString)(input, `${context}[${index}]`);
|
|
868
|
+
return {
|
|
869
|
+
key: (0, import_service_utils.normalizeFlowSurfaceComposeKey)((0, import_private_utils.buildScopedKey)(scopePrefix, `${type2}_${index + 1}`), `${context}[${index}]`),
|
|
870
|
+
type: type2,
|
|
871
|
+
...APPLY_BLUEPRINT_DEFAULT_POPUP_ACTION_TYPES.has(type2) ? { popup: attachCompiledPopupDefaults(void 0, popupDefaultsMetadata) } : {}
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
if (!import_lodash.default.isPlainObject(input)) {
|
|
875
|
+
(0, import_errors.throwBadRequest)(`${context}[${index}] must be a string or object`);
|
|
876
|
+
}
|
|
877
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(input, `${context}[${index}]`, APPLY_BLUEPRINT_ACTION_ALLOWED_KEYS);
|
|
878
|
+
const type = (0, import_private_utils.assertNonEmptyString)(input.type, `${context}[${index}].type`);
|
|
879
|
+
const localKey = (0, import_private_utils.normalizeBlueprintLocalKey)(input.key, `${type}_${index + 1}`, `${context}[${index}].key`);
|
|
880
|
+
const key = (0, import_service_utils.normalizeFlowSurfaceComposeKey)((0, import_private_utils.buildScopedKey)(scopePrefix, localKey), `${context}[${index}]`);
|
|
881
|
+
let settings = resolveAssetSettings(input.settings, input, assets, `${context}[${index}]`);
|
|
882
|
+
if ((0, import_private_utils.readOptionalString)(input.title) && import_lodash.default.isUndefined(settings.title)) {
|
|
883
|
+
settings.title = (0, import_private_utils.readOptionalString)(input.title);
|
|
884
|
+
}
|
|
885
|
+
const popupResult = compilePopup(input.popup, `${key}.popup`, assets, `${context}[${index}].popup`, defaults, {
|
|
886
|
+
ownerActionType: type
|
|
887
|
+
});
|
|
888
|
+
settings = resolvePopupTitleSettings(settings, popupResult.popupTitle);
|
|
889
|
+
const popup = shouldAttachDefaultPopupMetadata(input.popup, type) ? attachCompiledPopupDefaults(popupResult.popup, popupDefaultsMetadata) : popupResult.popup;
|
|
890
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
891
|
+
key,
|
|
892
|
+
type,
|
|
893
|
+
settings: Object.keys(settings).length ? settings : void 0,
|
|
894
|
+
popup
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
function compileInjectedDefaultAction(descriptor, scopePrefix, context, index, popupDefaultsMetadata) {
|
|
898
|
+
const descriptorPopup = descriptor.popup ? import_lodash.default.cloneDeep(descriptor.popup) : void 0;
|
|
899
|
+
const popup = shouldAttachDefaultPopupMetadata(descriptorPopup, descriptor.type) ? attachCompiledPopupDefaults(descriptorPopup, popupDefaultsMetadata) : void 0;
|
|
900
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
901
|
+
key: (0, import_service_utils.normalizeFlowSurfaceComposeKey)(
|
|
902
|
+
(0, import_private_utils.buildScopedKey)(scopePrefix, `${descriptor.type}_default_${index + 1}`),
|
|
903
|
+
`${context}[${index}]`
|
|
904
|
+
),
|
|
905
|
+
type: descriptor.type,
|
|
906
|
+
popup
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
function compileBlocks(input, scopePrefix, assets, context, defaults, requiredExplicitBlockKeys = /* @__PURE__ */ new Set()) {
|
|
910
|
+
const blockKeysByLocalKey = /* @__PURE__ */ new Map();
|
|
911
|
+
const referencedBlockKeys = new Set(requiredExplicitBlockKeys);
|
|
912
|
+
const rawBlocks = import_lodash.default.castArray(input || []);
|
|
913
|
+
const popupDefaultsMetadata = (0, import_defaults.buildFlowSurfaceApplyBlueprintPopupDefaultsMetadata)(defaults);
|
|
914
|
+
rawBlocks.forEach((block, index) => {
|
|
915
|
+
if (!import_lodash.default.isPlainObject(block)) {
|
|
916
|
+
(0, import_errors.throwBadRequest)(`${context}[${index}] must be an object`);
|
|
917
|
+
}
|
|
918
|
+
assertApplyBlueprintCalendarMainContent(block, `${context}[${index}]`);
|
|
919
|
+
assertApplyBlueprintKanbanMainContent(block, `${context}[${index}]`);
|
|
920
|
+
assertApplyBlueprintTreeMainContent(block, `${context}[${index}]`);
|
|
921
|
+
const fields = resolveBlockFieldInputs(block, `${context}[${index}]`);
|
|
922
|
+
fields.forEach((field, fieldIndex) => {
|
|
923
|
+
if (typeof (field == null ? void 0 : field.target) !== "string" || !field.target.trim()) {
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
referencedBlockKeys.add(
|
|
927
|
+
(0, import_service_utils.normalizeFlowSurfaceComposeKey)(field.target, `${context}[${index}].fields[${fieldIndex}].target`)
|
|
928
|
+
);
|
|
929
|
+
});
|
|
930
|
+
});
|
|
931
|
+
rawBlocks.forEach((block, index) => {
|
|
932
|
+
if (!import_lodash.default.isPlainObject(block)) {
|
|
933
|
+
(0, import_errors.throwBadRequest)(`${context}[${index}] must be an object`);
|
|
934
|
+
}
|
|
935
|
+
assertNoBlockLevelLayout(block, `${context}[${index}]`);
|
|
936
|
+
assertApplyBlueprintFieldsLayoutHost(block, `${context}[${index}]`);
|
|
937
|
+
(0, import_private_utils.assertOnlyAllowedKeys)(block, `${context}[${index}]`, APPLY_BLUEPRINT_BLOCK_ALLOWED_KEYS);
|
|
938
|
+
assertApplyBlueprintBlockType((0, import_private_utils.readOptionalString)(block.type), `${context}[${index}]`);
|
|
939
|
+
assertApplyBlueprintCalendarMainContent(block, `${context}[${index}]`);
|
|
940
|
+
assertApplyBlueprintKanbanMainContent(block, `${context}[${index}]`);
|
|
941
|
+
assertApplyBlueprintTreeMainContent(block, `${context}[${index}]`);
|
|
942
|
+
const explicitKey = (0, import_private_utils.readString)(block.key);
|
|
943
|
+
const fallback = block.type ? `${block.type}_${index + 1}` : `block_${index + 1}`;
|
|
944
|
+
const localKey = (0, import_private_utils.normalizeBlueprintLocalKey)(block.key, fallback, `${context}[${index}].key`);
|
|
945
|
+
if (!explicitKey && referencedBlockKeys.has(localKey)) {
|
|
946
|
+
(0, import_errors.throwBadRequest)(
|
|
947
|
+
`${context}[${index}] must provide key explicitly because it is referenced by layout or field.target`
|
|
948
|
+
);
|
|
949
|
+
}
|
|
950
|
+
if (blockKeysByLocalKey.has(localKey)) {
|
|
951
|
+
(0, import_errors.throwBadRequest)(`${context}[${index}] key '${localKey}' is duplicated`);
|
|
952
|
+
}
|
|
953
|
+
const key = (0, import_service_utils.normalizeFlowSurfaceComposeKey)((0, import_private_utils.buildScopedKey)(scopePrefix, localKey), `${context}[${index}]`);
|
|
954
|
+
blockKeysByLocalKey.set(localKey, key);
|
|
955
|
+
});
|
|
956
|
+
const blocks = rawBlocks.map((block, index) => {
|
|
957
|
+
const blockContext = `${context}[${index}]`;
|
|
958
|
+
const localKey = (0, import_private_utils.normalizeBlueprintLocalKey)(
|
|
959
|
+
block.key,
|
|
960
|
+
block.type ? `${block.type}_${index + 1}` : `block_${index + 1}`,
|
|
961
|
+
`${blockContext}.key`
|
|
962
|
+
);
|
|
963
|
+
const key = blockKeysByLocalKey.get(localKey);
|
|
964
|
+
if (!key) {
|
|
965
|
+
(0, import_errors.throwBadRequest)(`${blockContext} key '${localKey}' is missing after block key compilation`);
|
|
966
|
+
}
|
|
967
|
+
const settings = resolveAssetSettings(block.settings, block, assets, blockContext);
|
|
968
|
+
if ((0, import_private_utils.readOptionalString)(block.title) && import_lodash.default.isUndefined(settings.title)) {
|
|
969
|
+
settings.title = (0, import_private_utils.readOptionalString)(block.title);
|
|
970
|
+
}
|
|
971
|
+
const blockType = (0, import_private_utils.readOptionalString)(block.type);
|
|
972
|
+
const template = ensureOptionalTemplate(block.template, `${blockContext}.template`);
|
|
973
|
+
const blockDefaultFilter = (0, import_public_data_surface_default_filter.normalizeFlowSurfacePublicBlockDefaultFilter)("applyBlueprint", block.defaultFilter, {
|
|
974
|
+
blockType,
|
|
975
|
+
template,
|
|
976
|
+
path: blockContext
|
|
977
|
+
});
|
|
978
|
+
if (!import_lodash.default.isUndefined(blockDefaultFilter)) {
|
|
979
|
+
(0, import_public_data_surface_default_filter.assertFlowSurfaceConcreteDefaultFilterItem)("applyBlueprint", blockDefaultFilter, {
|
|
980
|
+
path: blockContext
|
|
981
|
+
});
|
|
982
|
+
}
|
|
983
|
+
const fieldInputs = resolveBlockFieldInputs(block, blockContext);
|
|
984
|
+
const fields = fieldInputs.map(
|
|
985
|
+
(field, fieldIndex) => compileField(
|
|
986
|
+
field,
|
|
987
|
+
fieldIndex,
|
|
988
|
+
key,
|
|
989
|
+
assets,
|
|
990
|
+
blockKeysByLocalKey,
|
|
991
|
+
`${blockContext}.fields`,
|
|
992
|
+
popupDefaultsMetadata,
|
|
993
|
+
defaults
|
|
994
|
+
)
|
|
995
|
+
);
|
|
996
|
+
const fieldsLayout = Object.prototype.hasOwnProperty.call(block, "fieldsLayout") ? compileScopedLayout(
|
|
997
|
+
import_lodash.default.isUndefined(block.fieldsLayout) ? void 0 : import_lodash.default.isPlainObject(block.fieldsLayout) ? block.fieldsLayout : (0, import_errors.throwBadRequest)(`${blockContext}.fieldsLayout must be an object`),
|
|
998
|
+
buildCompiledFieldKeyMap(fieldInputs, fields, `${blockContext}.fields`),
|
|
999
|
+
`${blockContext}.fieldsLayout`,
|
|
1000
|
+
"field"
|
|
1001
|
+
) : buildAutoCompiledFieldsLayout(fields, (0, import_private_utils.readOptionalString)(block.type));
|
|
1002
|
+
const { actions, recordActions } = splitApplyBlueprintBlockActionsByScope(block, blockContext);
|
|
1003
|
+
const explicitActions = actions.map(
|
|
1004
|
+
(action, actionIndex) => compileAction(action, actionIndex, key, assets, `${blockContext}.actions`, popupDefaultsMetadata, defaults)
|
|
1005
|
+
);
|
|
1006
|
+
const explicitRecordActions = recordActions.map(
|
|
1007
|
+
(action, actionIndex) => compileAction(action, actionIndex, key, assets, `${blockContext}.recordActions`, popupDefaultsMetadata, defaults)
|
|
1008
|
+
);
|
|
1009
|
+
const injectedActionIndexes = {
|
|
1010
|
+
actions: explicitActions.length,
|
|
1011
|
+
recordActions: explicitRecordActions.length
|
|
1012
|
+
};
|
|
1013
|
+
const mergedActions = (0, import_default_block_actions.mergeFlowSurfaceDefaultBlockActions)({
|
|
1014
|
+
blockType,
|
|
1015
|
+
template,
|
|
1016
|
+
actions: explicitActions,
|
|
1017
|
+
recordActions: explicitRecordActions,
|
|
1018
|
+
createAction: (descriptor) => compileInjectedDefaultAction(
|
|
1019
|
+
descriptor,
|
|
1020
|
+
key,
|
|
1021
|
+
`${blockContext}.${descriptor.scope}`,
|
|
1022
|
+
injectedActionIndexes[descriptor.scope]++,
|
|
1023
|
+
popupDefaultsMetadata
|
|
1024
|
+
)
|
|
1025
|
+
});
|
|
1026
|
+
const actionsWithDefaultFilter = (0, import_public_data_surface_default_filter.backfillFlowSurfaceFilterActionDefaultFilter)(
|
|
1027
|
+
mergedActions.actions,
|
|
1028
|
+
blockDefaultFilter
|
|
1029
|
+
);
|
|
1030
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
1031
|
+
key,
|
|
1032
|
+
type: blockType,
|
|
1033
|
+
resource: buildBlockResource(block, blockContext),
|
|
1034
|
+
template,
|
|
1035
|
+
settings: Object.keys(settings).length ? settings : void 0,
|
|
1036
|
+
fields: blockType === "calendar" || blockType === "tree" ? void 0 : fields,
|
|
1037
|
+
fieldsLayout: blockType === "calendar" || blockType === "kanban" || blockType === "tree" ? void 0 : fieldsLayout,
|
|
1038
|
+
actions: blockType === "tree" ? void 0 : actionsWithDefaultFilter,
|
|
1039
|
+
recordActions: blockType === "calendar" || blockType === "kanban" || blockType === "tree" ? void 0 : mergedActions.recordActions
|
|
1040
|
+
});
|
|
1041
|
+
});
|
|
1042
|
+
return {
|
|
1043
|
+
blocks,
|
|
1044
|
+
blockKeysByLocalKey
|
|
1045
|
+
};
|
|
1046
|
+
}
|
|
1047
|
+
function compileTabComposeValues(tab, document, tabIndex, options) {
|
|
1048
|
+
const tabPublicPath = (0, import_private_utils.buildApplyBlueprintTabPublicPath)(tabIndex);
|
|
1049
|
+
const blocksPath = `${tabPublicPath}.blocks`;
|
|
1050
|
+
const layoutPath = `${tabPublicPath}.layout`;
|
|
1051
|
+
const compiledBlocks = compileBlocks(
|
|
1052
|
+
tab.blocks,
|
|
1053
|
+
tab.key,
|
|
1054
|
+
document.assets,
|
|
1055
|
+
blocksPath,
|
|
1056
|
+
document.defaults,
|
|
1057
|
+
collectReferencedBlockKeys(tab.layout, layoutPath)
|
|
1058
|
+
);
|
|
1059
|
+
const layout = compileLayout(
|
|
1060
|
+
tab.layout || autoLayoutFromBlockKeys(compiledBlocks.blocks.map((block) => block.key)),
|
|
1061
|
+
compiledBlocks.blockKeysByLocalKey,
|
|
1062
|
+
layoutPath
|
|
1063
|
+
);
|
|
1064
|
+
return (0, import_service_utils.buildDefinedPayload)({
|
|
1065
|
+
mode: options.mode,
|
|
1066
|
+
blocks: compiledBlocks.blocks,
|
|
1067
|
+
layout
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1071
|
+
0 && (module.exports = {
|
|
1072
|
+
collectReferencedBlockKeys,
|
|
1073
|
+
compileTabComposeValues
|
|
1074
|
+
});
|