@nocobase/plugin-flow-engine 2.1.0-beta.2 → 2.1.0-beta.20
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 +969 -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-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 +1029 -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 +193 -0
- package/dist/server/flow-surfaces/blueprint/public-types.js +24 -0
- package/dist/server/flow-surfaces/builder.d.ts +211 -0
- package/dist/server/flow-surfaces/builder.js +1097 -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 +78 -0
- package/dist/server/flow-surfaces/catalog.js +3577 -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 +108 -0
- package/dist/server/flow-surfaces/compose-compiler.js +167 -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 +860 -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 +23 -0
- package/dist/server/flow-surfaces/field-binding-registry.js +391 -0
- package/dist/server/flow-surfaces/field-semantics.d.ts +15 -0
- package/dist/server/flow-surfaces/field-semantics.js +83 -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 +134 -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 +108 -0
- package/dist/server/flow-surfaces/service-utils.js +811 -0
- package/dist/server/flow-surfaces/service.d.ts +814 -0
- package/dist/server/flow-surfaces/service.js +14276 -0
- package/dist/server/flow-surfaces/support-matrix.d.ts +31 -0
- package/dist/server/flow-surfaces/support-matrix.js +271 -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 +5964 -0
- package/dist/swagger/flow-surfaces.examples.d.ts +1572 -0
- package/dist/swagger/flow-surfaces.examples.js +1805 -0
- package/dist/swagger/flow-surfaces.js +5322 -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 +5969 -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,969 @@
|
|
|
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 compiler_exports = {};
|
|
38
|
+
__export(compiler_exports, {
|
|
39
|
+
compileApplySpec: () => compileApplySpec
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(compiler_exports);
|
|
42
|
+
var import_lodash = __toESM(require("lodash"));
|
|
43
|
+
var import_catalog = require("../catalog");
|
|
44
|
+
var import_placement = require("../placement");
|
|
45
|
+
var import_errors = require("../errors");
|
|
46
|
+
var import_node_use_sets = require("../node-use-sets");
|
|
47
|
+
var import_layout = require("./layout");
|
|
48
|
+
var import_matching = require("./matching");
|
|
49
|
+
function makeOpRef(path) {
|
|
50
|
+
const normalized = String(path || "").trim();
|
|
51
|
+
const [step, ...rest] = normalized.split(".");
|
|
52
|
+
return {
|
|
53
|
+
step,
|
|
54
|
+
...rest.length ? { path: rest.join(".") } : {}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const FORM_GRID_USES = /* @__PURE__ */ new Set(["FormGridModel", "AssignFormGridModel"]);
|
|
58
|
+
const ACTION_USES = new Set(Array.from(import_catalog.ACTION_KEY_BY_USE.keys()));
|
|
59
|
+
const BLOCK_USES = new Set(Array.from(import_catalog.BLOCK_KEY_BY_USE.keys()));
|
|
60
|
+
const STANDALONE_FIELD_USES = import_node_use_sets.CREATABLE_STANDALONE_FIELD_USES;
|
|
61
|
+
const FORM_BLOCK_USES = import_placement.FLOW_SURFACE_FORM_BLOCK_USES;
|
|
62
|
+
const DETAILS_BLOCK_USES = import_placement.FLOW_SURFACE_DETAILS_BLOCK_USES;
|
|
63
|
+
const FILTER_FORM_BLOCK_USES = import_placement.FLOW_SURFACE_FILTER_FORM_BLOCK_USES;
|
|
64
|
+
const RECORD_ACTION_INTERNAL_CONTAINER_USES = /* @__PURE__ */ new Set([
|
|
65
|
+
"TableActionsColumnModel",
|
|
66
|
+
"ListItemModel",
|
|
67
|
+
"GridCardItemModel"
|
|
68
|
+
]);
|
|
69
|
+
const APPLY_POPUP_ALLOWED_KEYS = /* @__PURE__ */ new Set(["template", "tryTemplate", "defaultType"]);
|
|
70
|
+
function compileApplySpec(target, currentTree, spec) {
|
|
71
|
+
if (!(currentTree == null ? void 0 : currentTree.uid) || !(currentTree == null ? void 0 : currentTree.use)) {
|
|
72
|
+
throw new import_errors.FlowSurfaceBadRequestError("flowSurfaces apply requires an existing target subtree");
|
|
73
|
+
}
|
|
74
|
+
const ops = [];
|
|
75
|
+
const state = {
|
|
76
|
+
seq: 0,
|
|
77
|
+
clientKeyToUid: {}
|
|
78
|
+
};
|
|
79
|
+
if (currentTree.use === "RootPageModel") {
|
|
80
|
+
syncRoutePageNode(ops, state, target, currentTree, spec);
|
|
81
|
+
return {
|
|
82
|
+
ops,
|
|
83
|
+
clientKeyToUid: state.clientKeyToUid
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (currentTree.use === "ChildPageModel") {
|
|
87
|
+
syncExistingNode(
|
|
88
|
+
ops,
|
|
89
|
+
state,
|
|
90
|
+
{
|
|
91
|
+
uidRef: currentTree.uid,
|
|
92
|
+
use: currentTree.use
|
|
93
|
+
},
|
|
94
|
+
currentTree,
|
|
95
|
+
{
|
|
96
|
+
uid: currentTree.uid,
|
|
97
|
+
use: currentTree.use,
|
|
98
|
+
props: spec.props,
|
|
99
|
+
decoratorProps: spec.decoratorProps,
|
|
100
|
+
stepParams: spec.stepParams,
|
|
101
|
+
flowRegistry: spec.flowRegistry,
|
|
102
|
+
subModels: spec.subModels
|
|
103
|
+
},
|
|
104
|
+
{ uid: currentTree.uid }
|
|
105
|
+
);
|
|
106
|
+
return {
|
|
107
|
+
ops,
|
|
108
|
+
clientKeyToUid: state.clientKeyToUid
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
if (currentTree.use === "RootPageTabModel") {
|
|
112
|
+
syncRouteTabNode(ops, state, target, currentTree, spec);
|
|
113
|
+
return {
|
|
114
|
+
ops,
|
|
115
|
+
clientKeyToUid: state.clientKeyToUid
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
if (currentTree.use === "ChildPageTabModel") {
|
|
119
|
+
syncTabNode(ops, state, { uid: currentTree.uid }, currentTree, spec);
|
|
120
|
+
return {
|
|
121
|
+
ops,
|
|
122
|
+
clientKeyToUid: state.clientKeyToUid
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const rootSpec = {
|
|
126
|
+
uid: currentTree.uid,
|
|
127
|
+
use: currentTree.use,
|
|
128
|
+
popup: spec.popup,
|
|
129
|
+
props: spec.props,
|
|
130
|
+
decoratorProps: spec.decoratorProps,
|
|
131
|
+
stepParams: spec.stepParams,
|
|
132
|
+
flowRegistry: spec.flowRegistry,
|
|
133
|
+
subModels: spec.subModels
|
|
134
|
+
};
|
|
135
|
+
syncExistingNode(
|
|
136
|
+
ops,
|
|
137
|
+
state,
|
|
138
|
+
{
|
|
139
|
+
uidRef: currentTree.uid,
|
|
140
|
+
use: currentTree.use
|
|
141
|
+
},
|
|
142
|
+
currentTree,
|
|
143
|
+
rootSpec,
|
|
144
|
+
target
|
|
145
|
+
);
|
|
146
|
+
return {
|
|
147
|
+
ops,
|
|
148
|
+
clientKeyToUid: state.clientKeyToUid
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function syncExistingNode(ops, state, nodeRef, currentNode, desiredNode, explicitTarget) {
|
|
152
|
+
const popupAwareDesiredNode = withApplyPopupOpenViewForExistingNode(
|
|
153
|
+
desiredNode,
|
|
154
|
+
`flowSurfaces apply node '${desiredNode.use}'`
|
|
155
|
+
);
|
|
156
|
+
emitDomainSettingOps(ops, nodeRef, currentNode, popupAwareDesiredNode, explicitTarget);
|
|
157
|
+
const childSync = syncChildren(ops, state, nodeRef, currentNode, popupAwareDesiredNode);
|
|
158
|
+
(0, import_layout.emitLayoutOp)(ops, explicitTarget || { uid: nodeRef.uidRef }, currentNode, popupAwareDesiredNode, childSync);
|
|
159
|
+
}
|
|
160
|
+
function syncCreatedNode(ops, state, nodeRef, desiredNode) {
|
|
161
|
+
emitDomainSettingOps(ops, nodeRef, null, desiredNode);
|
|
162
|
+
const childSync = syncChildren(ops, state, nodeRef, null, desiredNode);
|
|
163
|
+
(0, import_layout.emitLayoutOp)(ops, { uid: nodeRef.uidRef }, null, desiredNode, childSync);
|
|
164
|
+
}
|
|
165
|
+
function syncRoutePageNode(ops, state, target, currentNode, desiredNode) {
|
|
166
|
+
const pageTarget = { uid: String(target.uid || currentNode.uid || "").trim() };
|
|
167
|
+
syncPageNode(ops, state, pageTarget, currentNode, desiredNode);
|
|
168
|
+
}
|
|
169
|
+
function syncPageNode(ops, state, pageTarget, currentNode, desiredNode) {
|
|
170
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
171
|
+
emitDomainSettingOps(
|
|
172
|
+
ops,
|
|
173
|
+
{
|
|
174
|
+
uidRef: currentNode.uid,
|
|
175
|
+
use: currentNode.use
|
|
176
|
+
},
|
|
177
|
+
currentNode,
|
|
178
|
+
{
|
|
179
|
+
uid: currentNode.uid,
|
|
180
|
+
use: currentNode.use,
|
|
181
|
+
props: desiredNode.props,
|
|
182
|
+
decoratorProps: desiredNode.decoratorProps,
|
|
183
|
+
stepParams: desiredNode.stepParams,
|
|
184
|
+
flowRegistry: desiredNode.flowRegistry
|
|
185
|
+
},
|
|
186
|
+
pageTarget
|
|
187
|
+
);
|
|
188
|
+
if (!(0, import_matching.hasExplicitSubModelKey)(desiredNode, "tabs")) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
const hasTabsSpec = Object.prototype.hasOwnProperty.call(desiredNode.subModels || {}, "tabs");
|
|
192
|
+
if (!hasTabsSpec) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const desiredTabs = (0, import_matching.normalizeChildren)((_a = desiredNode.subModels) == null ? void 0 : _a.tabs);
|
|
196
|
+
const currentTabs = (0, import_matching.normalizeChildren)((_b = currentNode.subModels) == null ? void 0 : _b.tabs);
|
|
197
|
+
const tabMatchPlan = (0, import_matching.planArrayChildMatches)(currentTabs, desiredTabs, currentNode.use, "tabs");
|
|
198
|
+
const desiredRefs = [];
|
|
199
|
+
for (const [desiredIndex, desiredTab] of desiredTabs.entries()) {
|
|
200
|
+
const currentMatch = tabMatchPlan.matchesByDesiredIndex.get(desiredIndex);
|
|
201
|
+
if (currentMatch) {
|
|
202
|
+
bindClientKey(state, desiredTab.clientKey, currentMatch.uid);
|
|
203
|
+
desiredRefs.push({
|
|
204
|
+
uidRef: currentMatch.uid,
|
|
205
|
+
use: currentMatch.use
|
|
206
|
+
});
|
|
207
|
+
syncRouteTabNode(ops, state, { uid: currentMatch.uid }, currentMatch, desiredTab);
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
const opId = nextOpId(state, "addTab");
|
|
211
|
+
ops.push({
|
|
212
|
+
opId,
|
|
213
|
+
type: "addTab",
|
|
214
|
+
values: {
|
|
215
|
+
target: pageTarget,
|
|
216
|
+
...desiredTab.clientKey ? { clientKey: desiredTab.clientKey } : {},
|
|
217
|
+
title: ((_e = (_d = (_c = desiredTab == null ? void 0 : desiredTab.stepParams) == null ? void 0 : _c.pageTabSettings) == null ? void 0 : _d.tab) == null ? void 0 : _e.title) || ((_f = desiredTab == null ? void 0 : desiredTab.props) == null ? void 0 : _f.title) || ((_h = (_g = desiredTab == null ? void 0 : desiredTab.props) == null ? void 0 : _g.route) == null ? void 0 : _h.title) || "Untitled",
|
|
218
|
+
icon: ((_k = (_j = (_i = desiredTab == null ? void 0 : desiredTab.stepParams) == null ? void 0 : _i.pageTabSettings) == null ? void 0 : _j.tab) == null ? void 0 : _k.icon) || ((_l = desiredTab == null ? void 0 : desiredTab.props) == null ? void 0 : _l.icon),
|
|
219
|
+
documentTitle: (_o = (_n = (_m = desiredTab == null ? void 0 : desiredTab.stepParams) == null ? void 0 : _m.pageTabSettings) == null ? void 0 : _n.tab) == null ? void 0 : _o.documentTitle,
|
|
220
|
+
flowRegistry: desiredTab == null ? void 0 : desiredTab.flowRegistry
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
const createdRef = {
|
|
224
|
+
uidRef: makeOpRef(`${opId}.tabSchemaUid`),
|
|
225
|
+
use: "RootPageTabModel",
|
|
226
|
+
sourceOpId: opId
|
|
227
|
+
};
|
|
228
|
+
desiredRefs.push(createdRef);
|
|
229
|
+
syncCreatedNode(ops, state, createdRef, desiredTab);
|
|
230
|
+
}
|
|
231
|
+
for (const currentTab of currentTabs) {
|
|
232
|
+
if (!tabMatchPlan.matchedCurrentUids.has(currentTab.uid)) {
|
|
233
|
+
ops.push({
|
|
234
|
+
type: "removeTab",
|
|
235
|
+
values: {
|
|
236
|
+
uid: currentTab.uid
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
(0, import_layout.emitMoveTabOps)(ops, desiredRefs);
|
|
242
|
+
}
|
|
243
|
+
function syncRouteTabNode(ops, state, target, currentNode, desiredNode) {
|
|
244
|
+
const tabTarget = { uid: String(target.uid || currentNode.uid || "").trim() };
|
|
245
|
+
syncTabNode(ops, state, tabTarget, currentNode, desiredNode);
|
|
246
|
+
}
|
|
247
|
+
function syncTabNode(ops, state, tabTarget, currentNode, desiredNode) {
|
|
248
|
+
var _a, _b;
|
|
249
|
+
emitDomainSettingOps(
|
|
250
|
+
ops,
|
|
251
|
+
{
|
|
252
|
+
uidRef: currentNode.uid,
|
|
253
|
+
use: currentNode.use
|
|
254
|
+
},
|
|
255
|
+
currentNode,
|
|
256
|
+
{
|
|
257
|
+
uid: currentNode.uid,
|
|
258
|
+
use: currentNode.use,
|
|
259
|
+
props: desiredNode.props,
|
|
260
|
+
decoratorProps: desiredNode.decoratorProps,
|
|
261
|
+
stepParams: desiredNode.stepParams,
|
|
262
|
+
flowRegistry: desiredNode.flowRegistry
|
|
263
|
+
},
|
|
264
|
+
tabTarget
|
|
265
|
+
);
|
|
266
|
+
if (!(0, import_matching.hasExplicitSubModelKey)(desiredNode, "grid")) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const hasGridSpec = Object.prototype.hasOwnProperty.call(desiredNode.subModels || {}, "grid");
|
|
270
|
+
if (!hasGridSpec) {
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
const desiredGrid = (0, import_matching.normalizeChildren)((_a = desiredNode.subModels) == null ? void 0 : _a.grid)[0];
|
|
274
|
+
const currentGrid = (0, import_matching.normalizeChildren)((_b = currentNode.subModels) == null ? void 0 : _b.grid)[0];
|
|
275
|
+
if (!desiredGrid || !currentGrid) {
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
syncExistingNode(
|
|
279
|
+
ops,
|
|
280
|
+
state,
|
|
281
|
+
{
|
|
282
|
+
uidRef: currentGrid.uid,
|
|
283
|
+
use: currentGrid.use
|
|
284
|
+
},
|
|
285
|
+
currentGrid,
|
|
286
|
+
desiredGrid,
|
|
287
|
+
{ uid: currentGrid.uid }
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
function syncChildren(ops, state, parentRef, currentParent, desiredParent) {
|
|
291
|
+
const result = {
|
|
292
|
+
childClientKeyRefs: {},
|
|
293
|
+
finalItemRefs: [],
|
|
294
|
+
itemsChanged: false,
|
|
295
|
+
itemsSpecified: false
|
|
296
|
+
};
|
|
297
|
+
const desiredSubModels = desiredParent.subModels;
|
|
298
|
+
if (!desiredSubModels) {
|
|
299
|
+
return result;
|
|
300
|
+
}
|
|
301
|
+
const currentSubModels = (currentParent == null ? void 0 : currentParent.subModels) || {};
|
|
302
|
+
const subKeys = Object.keys(desiredSubModels);
|
|
303
|
+
for (const subKey of subKeys) {
|
|
304
|
+
const desiredRaw = desiredSubModels[subKey];
|
|
305
|
+
const currentRaw = currentSubModels[subKey];
|
|
306
|
+
const desiredChildren = (0, import_matching.normalizeChildren)(desiredRaw);
|
|
307
|
+
const currentChildren = (0, import_matching.normalizeChildren)(currentRaw);
|
|
308
|
+
const isArraySubModel = Array.isArray(desiredRaw) || Array.isArray(currentRaw);
|
|
309
|
+
if (parentRef.use === "ChildPageModel" && subKey === "tabs") {
|
|
310
|
+
const tabSync = syncPopupTabs(ops, state, parentRef, currentChildren, desiredChildren);
|
|
311
|
+
if (tabSync.itemsSpecified) {
|
|
312
|
+
result.finalItemRefs = tabSync.finalItemRefs;
|
|
313
|
+
result.itemsChanged = tabSync.itemsChanged;
|
|
314
|
+
result.itemsSpecified = true;
|
|
315
|
+
}
|
|
316
|
+
Object.assign(result.childClientKeyRefs, tabSync.childClientKeyRefs);
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
if (!isArraySubModel) {
|
|
320
|
+
const desiredChild = desiredChildren[0];
|
|
321
|
+
const currentChild = currentChildren[0];
|
|
322
|
+
if (!desiredChild && currentChild) {
|
|
323
|
+
ops.push({
|
|
324
|
+
type: "removeNode",
|
|
325
|
+
target: { uid: currentChild.uid }
|
|
326
|
+
});
|
|
327
|
+
continue;
|
|
328
|
+
}
|
|
329
|
+
if (!desiredChild) {
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
if (currentChild && (0, import_matching.matchesObjectChild)(currentChild, desiredChild)) {
|
|
333
|
+
bindClientKey(state, desiredChild.clientKey, currentChild.uid);
|
|
334
|
+
if (desiredChild.clientKey) {
|
|
335
|
+
result.childClientKeyRefs[desiredChild.clientKey] = currentChild.uid;
|
|
336
|
+
}
|
|
337
|
+
syncExistingNode(
|
|
338
|
+
ops,
|
|
339
|
+
state,
|
|
340
|
+
{
|
|
341
|
+
uidRef: currentChild.uid,
|
|
342
|
+
use: currentChild.use
|
|
343
|
+
},
|
|
344
|
+
currentChild,
|
|
345
|
+
desiredChild
|
|
346
|
+
);
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
if (currentChild) {
|
|
350
|
+
ops.push({
|
|
351
|
+
type: "removeNode",
|
|
352
|
+
target: { uid: currentChild.uid }
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
const defaultRef = getDefaultChildRef(parentRef, subKey, desiredChild.use);
|
|
356
|
+
if (defaultRef) {
|
|
357
|
+
if (desiredChild.clientKey) {
|
|
358
|
+
result.childClientKeyRefs[desiredChild.clientKey] = defaultRef.uidRef;
|
|
359
|
+
}
|
|
360
|
+
syncCreatedNode(ops, state, defaultRef, desiredChild);
|
|
361
|
+
} else {
|
|
362
|
+
const createdRef = createDesiredChild(ops, state, parentRef, subKey, desiredChild, currentParent);
|
|
363
|
+
if (desiredChild.clientKey) {
|
|
364
|
+
result.childClientKeyRefs[desiredChild.clientKey] = createdRef.uidRef;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
const childMatchPlan = (0, import_matching.planArrayChildMatches)(currentChildren, desiredChildren, parentRef.use, subKey);
|
|
370
|
+
const desiredRefs = [];
|
|
371
|
+
for (const [desiredIndex, desiredChild] of desiredChildren.entries()) {
|
|
372
|
+
const currentMatch = childMatchPlan.matchesByDesiredIndex.get(desiredIndex);
|
|
373
|
+
if (currentMatch) {
|
|
374
|
+
const currentRef = {
|
|
375
|
+
uidRef: currentMatch.uid,
|
|
376
|
+
use: currentMatch.use
|
|
377
|
+
};
|
|
378
|
+
bindClientKey(state, desiredChild.clientKey, currentMatch.uid);
|
|
379
|
+
if (desiredChild.clientKey) {
|
|
380
|
+
result.childClientKeyRefs[desiredChild.clientKey] = currentRef.uidRef;
|
|
381
|
+
}
|
|
382
|
+
desiredRefs.push(currentRef);
|
|
383
|
+
syncExistingNode(ops, state, currentRef, currentMatch, desiredChild);
|
|
384
|
+
continue;
|
|
385
|
+
}
|
|
386
|
+
const defaultRef = getDefaultChildRef(parentRef, subKey, desiredChild.use);
|
|
387
|
+
if (defaultRef) {
|
|
388
|
+
if (desiredChild.clientKey) {
|
|
389
|
+
result.childClientKeyRefs[desiredChild.clientKey] = defaultRef.uidRef;
|
|
390
|
+
}
|
|
391
|
+
desiredRefs.push(defaultRef);
|
|
392
|
+
syncCreatedNode(ops, state, defaultRef, desiredChild);
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
const createdRef = createDesiredChild(ops, state, parentRef, subKey, desiredChild, currentParent);
|
|
396
|
+
if (desiredChild.clientKey) {
|
|
397
|
+
result.childClientKeyRefs[desiredChild.clientKey] = createdRef.uidRef;
|
|
398
|
+
}
|
|
399
|
+
desiredRefs.push(createdRef);
|
|
400
|
+
}
|
|
401
|
+
for (const currentChild of currentChildren) {
|
|
402
|
+
if (!childMatchPlan.matchedCurrentUids.has(currentChild.uid)) {
|
|
403
|
+
ops.push({
|
|
404
|
+
type: "removeNode",
|
|
405
|
+
target: { uid: currentChild.uid }
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
(0, import_layout.emitMoveOps)(ops, desiredRefs);
|
|
410
|
+
if (subKey === "items") {
|
|
411
|
+
result.finalItemRefs = desiredRefs;
|
|
412
|
+
result.itemsChanged = (0, import_layout.didItemRefsChange)(currentChildren, desiredRefs);
|
|
413
|
+
result.itemsSpecified = true;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return result;
|
|
417
|
+
}
|
|
418
|
+
function createDesiredChild(ops, state, parentRef, subKey, desiredChild, currentParent) {
|
|
419
|
+
if (desiredChild.use === "ChildPageModel" && (0, import_placement.isPopupHostUse)(parentRef.use)) {
|
|
420
|
+
compilePopupPageSpec(ops, state, parentRef, desiredChild);
|
|
421
|
+
return {
|
|
422
|
+
uidRef: parentRef.uidRef,
|
|
423
|
+
use: desiredChild.use,
|
|
424
|
+
sourceOpId: parentRef.sourceOpId
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
if ((isFieldWrapperNode(desiredChild.use) || STANDALONE_FIELD_USES.has(desiredChild.use)) && isFieldContainer(parentRef.use, subKey)) {
|
|
428
|
+
return createFieldNode(ops, state, parentRef, desiredChild);
|
|
429
|
+
}
|
|
430
|
+
if (subKey === "actions" && isActionContainer(parentRef.use)) {
|
|
431
|
+
if (!ACTION_USES.has(desiredChild.use)) {
|
|
432
|
+
throw new import_errors.FlowSurfaceBadRequestError(
|
|
433
|
+
`flowSurfaces apply action '${desiredChild.use}' is not a public capability`
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
return createActionNode(ops, state, parentRef, desiredChild, currentParent);
|
|
437
|
+
}
|
|
438
|
+
if (isBlockContainer(parentRef.use, subKey)) {
|
|
439
|
+
if (!BLOCK_USES.has(desiredChild.use)) {
|
|
440
|
+
throw new import_errors.FlowSurfaceBadRequestError(`flowSurfaces apply block '${desiredChild.use}' is not a public capability`);
|
|
441
|
+
}
|
|
442
|
+
return createBlockNode(ops, state, parentRef, desiredChild);
|
|
443
|
+
}
|
|
444
|
+
if (isFieldContainer(parentRef.use, subKey) && !import_node_use_sets.FIELD_WRAPPER_USES.has(desiredChild.use) && !STANDALONE_FIELD_USES.has(desiredChild.use)) {
|
|
445
|
+
throw new import_errors.FlowSurfaceBadRequestError(
|
|
446
|
+
`flowSurfaces apply field wrapper '${desiredChild.use}' is not a public capability`
|
|
447
|
+
);
|
|
448
|
+
}
|
|
449
|
+
throw new import_errors.FlowSurfaceBadRequestError(
|
|
450
|
+
`flowSurfaces apply cannot create '${desiredChild.use}' under '${parentRef.use}.${subKey}'`
|
|
451
|
+
);
|
|
452
|
+
}
|
|
453
|
+
function createBlockNode(ops, state, parentRef, desiredNode) {
|
|
454
|
+
const blockCatalogItem = (0, import_catalog.resolveSupportedBlockCatalogItem)(
|
|
455
|
+
{
|
|
456
|
+
use: desiredNode.use
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
requireCreateSupported: true
|
|
460
|
+
}
|
|
461
|
+
);
|
|
462
|
+
const opId = nextOpId(state, "addBlock");
|
|
463
|
+
ops.push({
|
|
464
|
+
opId,
|
|
465
|
+
type: "addBlock",
|
|
466
|
+
values: {
|
|
467
|
+
target: {
|
|
468
|
+
uid: parentRef.uidRef
|
|
469
|
+
},
|
|
470
|
+
...desiredNode.clientKey ? { clientKey: desiredNode.clientKey } : {},
|
|
471
|
+
type: blockCatalogItem.key,
|
|
472
|
+
resourceInit: extractResourceInit(desiredNode)
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
const ref = {
|
|
476
|
+
uidRef: makeOpRef(`${opId}.uid`),
|
|
477
|
+
use: desiredNode.use,
|
|
478
|
+
sourceOpId: opId
|
|
479
|
+
};
|
|
480
|
+
syncCreatedNode(ops, state, ref, desiredNode);
|
|
481
|
+
return ref;
|
|
482
|
+
}
|
|
483
|
+
function normalizeApplyPopup(desiredNode, context) {
|
|
484
|
+
var _a;
|
|
485
|
+
if (import_lodash.default.isUndefined(desiredNode.popup)) {
|
|
486
|
+
return void 0;
|
|
487
|
+
}
|
|
488
|
+
if (!import_lodash.default.isPlainObject(desiredNode.popup)) {
|
|
489
|
+
throw new import_errors.FlowSurfaceBadRequestError(`${context} popup must be an object`);
|
|
490
|
+
}
|
|
491
|
+
const invalidKeys = Object.keys(desiredNode.popup).filter((key) => !APPLY_POPUP_ALLOWED_KEYS.has(key));
|
|
492
|
+
if (invalidKeys.length) {
|
|
493
|
+
throw new import_errors.FlowSurfaceBadRequestError(
|
|
494
|
+
`${context} popup only supports ${Array.from(APPLY_POPUP_ALLOWED_KEYS).join(", ")} in flowSurfaces apply`
|
|
495
|
+
);
|
|
496
|
+
}
|
|
497
|
+
const hasPopupPageSpec = !!(0, import_matching.normalizeChildren)((_a = desiredNode.subModels) == null ? void 0 : _a.page)[0];
|
|
498
|
+
if (hasPopupPageSpec) {
|
|
499
|
+
throw new import_errors.FlowSurfaceBadRequestError(
|
|
500
|
+
`${context} cannot mix popup template semantics with explicit popup subtree content in flowSurfaces apply`
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
const nextPopup = import_lodash.default.cloneDeep(desiredNode.popup);
|
|
504
|
+
if (!import_lodash.default.isUndefined(nextPopup.tryTemplate) && typeof nextPopup.tryTemplate !== "boolean") {
|
|
505
|
+
throw new import_errors.FlowSurfaceBadRequestError(`${context} popup.tryTemplate must be a boolean`);
|
|
506
|
+
}
|
|
507
|
+
if (!import_lodash.default.isUndefined(nextPopup.defaultType) && nextPopup.defaultType !== "view" && nextPopup.defaultType !== "edit") {
|
|
508
|
+
throw new import_errors.FlowSurfaceBadRequestError(`${context} popup.defaultType must be 'view' or 'edit'`);
|
|
509
|
+
}
|
|
510
|
+
if (import_lodash.default.isUndefined(nextPopup.template) && nextPopup.tryTemplate !== true && import_lodash.default.isUndefined(nextPopup.defaultType)) {
|
|
511
|
+
return void 0;
|
|
512
|
+
}
|
|
513
|
+
if (!(0, import_placement.isPopupHostUse)(desiredNode.use)) {
|
|
514
|
+
throw new import_errors.FlowSurfaceBadRequestError(
|
|
515
|
+
`${context} popup is only supported on popup-capable action or field nodes in flowSurfaces apply`
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
return nextPopup;
|
|
519
|
+
}
|
|
520
|
+
function buildApplyPopupStepParams(use, popup) {
|
|
521
|
+
if (!popup) {
|
|
522
|
+
return void 0;
|
|
523
|
+
}
|
|
524
|
+
if (use === "UploadActionModel") {
|
|
525
|
+
return {
|
|
526
|
+
selectExitRecordSettings: {
|
|
527
|
+
openView: popup
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
return {
|
|
532
|
+
popupSettings: {
|
|
533
|
+
openView: popup
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
function withApplyPopupOpenViewForExistingNode(desiredNode, context) {
|
|
538
|
+
const popup = normalizeApplyPopup(desiredNode, context);
|
|
539
|
+
if (!popup) {
|
|
540
|
+
return desiredNode;
|
|
541
|
+
}
|
|
542
|
+
return {
|
|
543
|
+
...desiredNode,
|
|
544
|
+
stepParams: import_lodash.default.merge({}, desiredNode.stepParams || {}, buildApplyPopupStepParams(desiredNode.use, popup))
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
function createActionNode(ops, state, parentRef, desiredNode, currentParent) {
|
|
548
|
+
const popup = normalizeApplyPopup(desiredNode, `flowSurfaces apply action '${desiredNode.use}'`);
|
|
549
|
+
const actionCatalogItem = (0, import_catalog.resolveSupportedActionCatalogItem)(
|
|
550
|
+
{
|
|
551
|
+
use: desiredNode.use,
|
|
552
|
+
containerUse: parentRef.use
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
requireCreateSupported: true
|
|
556
|
+
}
|
|
557
|
+
);
|
|
558
|
+
const opType = actionCatalogItem.scope === "record" ? "addRecordAction" : "addAction";
|
|
559
|
+
const targetUidRef = actionCatalogItem.scope === "record" ? resolveRecordActionCreateTargetUidRef(parentRef, currentParent) : parentRef.uidRef;
|
|
560
|
+
const opId = nextOpId(state, opType);
|
|
561
|
+
ops.push({
|
|
562
|
+
opId,
|
|
563
|
+
type: opType,
|
|
564
|
+
values: {
|
|
565
|
+
target: {
|
|
566
|
+
uid: targetUidRef
|
|
567
|
+
},
|
|
568
|
+
...desiredNode.clientKey ? { clientKey: desiredNode.clientKey } : {},
|
|
569
|
+
type: actionCatalogItem.key,
|
|
570
|
+
resourceInit: extractResourceInit(desiredNode),
|
|
571
|
+
...popup ? { popup } : {}
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
const ref = {
|
|
575
|
+
uidRef: makeOpRef(`${opId}.uid`),
|
|
576
|
+
use: desiredNode.use,
|
|
577
|
+
sourceOpId: opId
|
|
578
|
+
};
|
|
579
|
+
syncCreatedNode(ops, state, ref, desiredNode);
|
|
580
|
+
return ref;
|
|
581
|
+
}
|
|
582
|
+
function createFieldNode(ops, state, parentRef, desiredNode) {
|
|
583
|
+
var _a;
|
|
584
|
+
const popup = normalizeApplyPopup(desiredNode, `flowSurfaces apply field '${desiredNode.use}'`);
|
|
585
|
+
const standaloneType = desiredNode.use === "JSColumnModel" ? "jsColumn" : desiredNode.use === "JSItemModel" ? "jsItem" : desiredNode.use === "DividerItemModel" ? "divider" : void 0;
|
|
586
|
+
if (standaloneType) {
|
|
587
|
+
if (popup) {
|
|
588
|
+
throw new import_errors.FlowSurfaceBadRequestError(
|
|
589
|
+
`flowSurfaces apply field '${desiredNode.use}' popup is not supported for standalone field types`
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
const opId2 = nextOpId(state, "addField");
|
|
593
|
+
ops.push({
|
|
594
|
+
opId: opId2,
|
|
595
|
+
type: "addField",
|
|
596
|
+
values: {
|
|
597
|
+
target: {
|
|
598
|
+
uid: parentRef.uidRef
|
|
599
|
+
},
|
|
600
|
+
...desiredNode.clientKey ? { clientKey: desiredNode.clientKey } : {},
|
|
601
|
+
type: standaloneType
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
const ref2 = {
|
|
605
|
+
uidRef: makeOpRef(`${opId2}.uid`),
|
|
606
|
+
use: desiredNode.use,
|
|
607
|
+
sourceOpId: opId2
|
|
608
|
+
};
|
|
609
|
+
syncCreatedNode(ops, state, ref2, desiredNode);
|
|
610
|
+
return ref2;
|
|
611
|
+
}
|
|
612
|
+
const innerField = (0, import_matching.normalizeChildren)((_a = desiredNode.subModels) == null ? void 0 : _a.field)[0];
|
|
613
|
+
const requestedRenderer = (innerField == null ? void 0 : innerField.use) === "JSFieldModel" || (innerField == null ? void 0 : innerField.use) === "JSEditableFieldModel" ? "js" : void 0;
|
|
614
|
+
const fieldCapability = (0, import_catalog.resolveSupportedFieldCapability)({
|
|
615
|
+
containerUse: parentRef.use,
|
|
616
|
+
requestedWrapperUse: desiredNode.use,
|
|
617
|
+
requestedFieldUse: innerField == null ? void 0 : innerField.use,
|
|
618
|
+
requestedRenderer,
|
|
619
|
+
allowUnresolvedFieldUse: true
|
|
620
|
+
});
|
|
621
|
+
const fieldInit = import_lodash.default.get(innerField, ["stepParams", "fieldSettings", "init"]) || import_lodash.default.get(desiredNode, ["stepParams", "fieldSettings", "init"]);
|
|
622
|
+
const defaultTargetUid = import_lodash.default.get(desiredNode, ["stepParams", "filterFormItemSettings", "init", "defaultTargetUid"]);
|
|
623
|
+
if (!(fieldInit == null ? void 0 : fieldInit.fieldPath)) {
|
|
624
|
+
throw new import_errors.FlowSurfaceBadRequestError(
|
|
625
|
+
`flowSurfaces apply field '${desiredNode.use}' requires stepParams.fieldSettings.init.fieldPath`
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
const opId = nextOpId(state, "addField");
|
|
629
|
+
ops.push({
|
|
630
|
+
opId,
|
|
631
|
+
type: "addField",
|
|
632
|
+
values: {
|
|
633
|
+
target: {
|
|
634
|
+
uid: parentRef.uidRef
|
|
635
|
+
},
|
|
636
|
+
...desiredNode.clientKey ? { clientKey: desiredNode.clientKey } : {},
|
|
637
|
+
fieldPath: fieldInit.fieldPath,
|
|
638
|
+
associationPathName: fieldInit.associationPathName,
|
|
639
|
+
dataSourceKey: fieldInit.dataSourceKey,
|
|
640
|
+
collectionName: fieldInit.collectionName,
|
|
641
|
+
...requestedRenderer ? { renderer: requestedRenderer } : {},
|
|
642
|
+
...fieldCapability.fieldUse ? { fieldUse: fieldCapability.fieldUse } : {},
|
|
643
|
+
...defaultTargetUid ? { defaultTargetUid } : {},
|
|
644
|
+
...popup ? { popup } : {}
|
|
645
|
+
}
|
|
646
|
+
});
|
|
647
|
+
const ref = {
|
|
648
|
+
uidRef: makeOpRef(`${opId}.wrapperUid`),
|
|
649
|
+
use: desiredNode.use,
|
|
650
|
+
sourceOpId: opId
|
|
651
|
+
};
|
|
652
|
+
syncCreatedNode(ops, state, ref, desiredNode);
|
|
653
|
+
return ref;
|
|
654
|
+
}
|
|
655
|
+
function compilePopupPageSpec(ops, state, hostRef, pageSpec) {
|
|
656
|
+
var _a, _b, _c;
|
|
657
|
+
const tabSpec = (0, import_matching.normalizeChildren)((_a = pageSpec.subModels) == null ? void 0 : _a.tabs)[0];
|
|
658
|
+
const gridSpec = (0, import_matching.normalizeChildren)((_b = tabSpec == null ? void 0 : tabSpec.subModels) == null ? void 0 : _b.grid)[0];
|
|
659
|
+
const popupItems = (0, import_matching.normalizeChildren)((_c = gridSpec == null ? void 0 : gridSpec.subModels) == null ? void 0 : _c.items);
|
|
660
|
+
if (!tabSpec || !gridSpec) {
|
|
661
|
+
throw new import_errors.FlowSurfaceBadRequestError(
|
|
662
|
+
`flowSurfaces apply popup page creation under '${hostRef.use}' requires popup page -> tab -> grid`
|
|
663
|
+
);
|
|
664
|
+
}
|
|
665
|
+
const { childRefs, childClientKeyRefs, popupGridUidRef, popupPageRef, popupTabRef, placeholderRef } = bootstrapPopupShellCreation(ops, state, hostRef, pageSpec, tabSpec, popupItems);
|
|
666
|
+
if (popupPageRef) {
|
|
667
|
+
emitDomainSettingOps(ops, popupPageRef, null, pageSpec);
|
|
668
|
+
}
|
|
669
|
+
if (popupTabRef) {
|
|
670
|
+
emitDomainSettingOps(ops, popupTabRef, null, tabSpec);
|
|
671
|
+
}
|
|
672
|
+
if (popupGridUidRef) {
|
|
673
|
+
emitDomainSettingOps(
|
|
674
|
+
ops,
|
|
675
|
+
{
|
|
676
|
+
uidRef: popupGridUidRef,
|
|
677
|
+
use: gridSpec.use
|
|
678
|
+
},
|
|
679
|
+
null,
|
|
680
|
+
gridSpec
|
|
681
|
+
);
|
|
682
|
+
if (placeholderRef) {
|
|
683
|
+
ops.push({
|
|
684
|
+
type: "removeNode",
|
|
685
|
+
values: {
|
|
686
|
+
target: {
|
|
687
|
+
uid: placeholderRef.uidRef
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
(0, import_layout.emitLayoutOp)(ops, { uid: popupGridUidRef }, null, gridSpec, {
|
|
693
|
+
childClientKeyRefs,
|
|
694
|
+
finalItemRefs: childRefs,
|
|
695
|
+
itemsChanged: true,
|
|
696
|
+
itemsSpecified: true
|
|
697
|
+
});
|
|
698
|
+
(0, import_layout.emitMoveOps)(ops, childRefs);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
function bootstrapPopupShellCreation(ops, state, hostRef, pageSpec, tabSpec, popupItems) {
|
|
702
|
+
const result = {
|
|
703
|
+
childRefs: [],
|
|
704
|
+
childClientKeyRefs: {},
|
|
705
|
+
popupGridUidRef: null,
|
|
706
|
+
popupPageRef: null,
|
|
707
|
+
popupTabRef: null,
|
|
708
|
+
placeholderRef: null
|
|
709
|
+
};
|
|
710
|
+
const bindPopupShellRefs = (created) => {
|
|
711
|
+
result.popupPageRef = {
|
|
712
|
+
uidRef: makeOpRef(`${created.sourceOpId}.popupPageUid`),
|
|
713
|
+
use: pageSpec.use
|
|
714
|
+
};
|
|
715
|
+
result.popupTabRef = {
|
|
716
|
+
uidRef: makeOpRef(`${created.sourceOpId}.popupTabUid`),
|
|
717
|
+
use: tabSpec.use,
|
|
718
|
+
sourceOpId: created.sourceOpId
|
|
719
|
+
};
|
|
720
|
+
result.popupGridUidRef = makeOpRef(`${created.sourceOpId}.popupGridUid`);
|
|
721
|
+
};
|
|
722
|
+
if (!popupItems.length) {
|
|
723
|
+
result.placeholderRef = createBlockNode(ops, state, hostRef, {
|
|
724
|
+
use: "MarkdownBlockModel"
|
|
725
|
+
});
|
|
726
|
+
bindPopupShellRefs(result.placeholderRef);
|
|
727
|
+
return result;
|
|
728
|
+
}
|
|
729
|
+
popupItems.forEach((itemSpec, index) => {
|
|
730
|
+
if (index === 0) {
|
|
731
|
+
const created2 = createBlockNode(ops, state, hostRef, itemSpec);
|
|
732
|
+
result.childRefs.push(created2);
|
|
733
|
+
if (itemSpec.clientKey) {
|
|
734
|
+
result.childClientKeyRefs[itemSpec.clientKey] = created2.uidRef;
|
|
735
|
+
}
|
|
736
|
+
bindPopupShellRefs(created2);
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
const popupGridRef = {
|
|
740
|
+
uidRef: result.popupGridUidRef,
|
|
741
|
+
use: "BlockGridModel"
|
|
742
|
+
};
|
|
743
|
+
const created = createBlockNode(ops, state, popupGridRef, itemSpec);
|
|
744
|
+
if (itemSpec.clientKey) {
|
|
745
|
+
result.childClientKeyRefs[itemSpec.clientKey] = created.uidRef;
|
|
746
|
+
}
|
|
747
|
+
result.childRefs.push(created);
|
|
748
|
+
});
|
|
749
|
+
return result;
|
|
750
|
+
}
|
|
751
|
+
function emitDomainSettingOps(ops, nodeRef, currentNode, desiredNode, explicitTarget) {
|
|
752
|
+
const props = (0, import_layout.omitLayoutProps)(desiredNode.props);
|
|
753
|
+
const currentProps = (0, import_layout.omitLayoutProps)(currentNode == null ? void 0 : currentNode.props);
|
|
754
|
+
const values = {};
|
|
755
|
+
if (!import_lodash.default.isNil(props) && !import_lodash.default.isEqual(props, currentProps)) {
|
|
756
|
+
values.props = props;
|
|
757
|
+
}
|
|
758
|
+
if (!import_lodash.default.isNil(desiredNode.decoratorProps) && !import_lodash.default.isEqual(desiredNode.decoratorProps, currentNode == null ? void 0 : currentNode.decoratorProps)) {
|
|
759
|
+
values.decoratorProps = desiredNode.decoratorProps;
|
|
760
|
+
}
|
|
761
|
+
if (!import_lodash.default.isNil(desiredNode.stepParams) && !import_lodash.default.isEqual(desiredNode.stepParams, currentNode == null ? void 0 : currentNode.stepParams)) {
|
|
762
|
+
values.stepParams = desiredNode.stepParams;
|
|
763
|
+
}
|
|
764
|
+
if (Object.keys(values).length) {
|
|
765
|
+
ops.push({
|
|
766
|
+
type: "updateSettings",
|
|
767
|
+
target: explicitTarget || { uid: nodeRef.uidRef },
|
|
768
|
+
values
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
if (!import_lodash.default.isNil(desiredNode.flowRegistry) && !import_lodash.default.isEqual(desiredNode.flowRegistry, currentNode == null ? void 0 : currentNode.flowRegistry)) {
|
|
772
|
+
ops.push({
|
|
773
|
+
type: "setEventFlows",
|
|
774
|
+
target: explicitTarget || { uid: nodeRef.uidRef },
|
|
775
|
+
values: {
|
|
776
|
+
flowRegistry: desiredNode.flowRegistry
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
function getDefaultChildRef(parentRef, subKey, childUse) {
|
|
782
|
+
if (!parentRef.sourceOpId || !childUse) {
|
|
783
|
+
return null;
|
|
784
|
+
}
|
|
785
|
+
if (FORM_BLOCK_USES.has(parentRef.use) && subKey === "grid" && FORM_GRID_USES.has(childUse)) {
|
|
786
|
+
return {
|
|
787
|
+
uidRef: makeOpRef(`${parentRef.sourceOpId}.gridUid`),
|
|
788
|
+
use: childUse
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
if (DETAILS_BLOCK_USES.has(parentRef.use) && subKey === "grid" && childUse === "DetailsGridModel") {
|
|
792
|
+
return {
|
|
793
|
+
uidRef: makeOpRef(`${parentRef.sourceOpId}.gridUid`),
|
|
794
|
+
use: childUse
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
if (FILTER_FORM_BLOCK_USES.has(parentRef.use) && subKey === "grid" && childUse === "FilterFormGridModel") {
|
|
798
|
+
return {
|
|
799
|
+
uidRef: makeOpRef(`${parentRef.sourceOpId}.gridUid`),
|
|
800
|
+
use: childUse
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
if (parentRef.use === "ChildPageTabModel" && subKey === "grid" && childUse === "BlockGridModel") {
|
|
804
|
+
return {
|
|
805
|
+
uidRef: makeOpRef(`${parentRef.sourceOpId}.popupGridUid`),
|
|
806
|
+
use: childUse
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
if (parentRef.use === "TableBlockModel" && subKey === "columns" && childUse === "TableActionsColumnModel") {
|
|
810
|
+
return {
|
|
811
|
+
uidRef: makeOpRef(`${parentRef.sourceOpId}.actionsColumnUid`),
|
|
812
|
+
use: childUse,
|
|
813
|
+
sourceOpId: parentRef.sourceOpId,
|
|
814
|
+
ownerUidRef: parentRef.uidRef
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
if (parentRef.use === "ListBlockModel" && subKey === "item" && childUse === "ListItemModel") {
|
|
818
|
+
return {
|
|
819
|
+
uidRef: makeOpRef(`${parentRef.sourceOpId}.itemUid`),
|
|
820
|
+
use: childUse,
|
|
821
|
+
sourceOpId: parentRef.sourceOpId,
|
|
822
|
+
ownerUidRef: parentRef.uidRef
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
if (parentRef.use === "GridCardBlockModel" && subKey === "item" && childUse === "GridCardItemModel") {
|
|
826
|
+
return {
|
|
827
|
+
uidRef: makeOpRef(`${parentRef.sourceOpId}.itemUid`),
|
|
828
|
+
use: childUse,
|
|
829
|
+
sourceOpId: parentRef.sourceOpId,
|
|
830
|
+
ownerUidRef: parentRef.uidRef
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
if (parentRef.use === "ListItemModel" && subKey === "grid" && childUse === "DetailsGridModel") {
|
|
834
|
+
return {
|
|
835
|
+
uidRef: makeOpRef(`${parentRef.sourceOpId}.gridUid`),
|
|
836
|
+
use: childUse
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
if (parentRef.use === "GridCardItemModel" && subKey === "grid" && childUse === "DetailsGridModel") {
|
|
840
|
+
return {
|
|
841
|
+
uidRef: makeOpRef(`${parentRef.sourceOpId}.gridUid`),
|
|
842
|
+
use: childUse
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
if (import_node_use_sets.FIELD_WRAPPER_USES.has(parentRef.use) && subKey === "field") {
|
|
846
|
+
return {
|
|
847
|
+
uidRef: makeOpRef(`${parentRef.sourceOpId}.fieldUid`),
|
|
848
|
+
use: childUse
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
if (parentRef.use === "RootPageTabModel" && subKey === "grid" && childUse === "BlockGridModel") {
|
|
852
|
+
return {
|
|
853
|
+
uidRef: makeOpRef(`${parentRef.sourceOpId}.gridUid`),
|
|
854
|
+
use: childUse
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
return null;
|
|
858
|
+
}
|
|
859
|
+
function resolveRecordActionCreateTargetUidRef(parentRef, currentParent) {
|
|
860
|
+
if (!RECORD_ACTION_INTERNAL_CONTAINER_USES.has(parentRef.use)) {
|
|
861
|
+
return parentRef.uidRef;
|
|
862
|
+
}
|
|
863
|
+
const ownerUidRef = parentRef.ownerUidRef ?? (currentParent == null ? void 0 : currentParent.parentId);
|
|
864
|
+
if (ownerUidRef) {
|
|
865
|
+
return ownerUidRef;
|
|
866
|
+
}
|
|
867
|
+
throw new import_errors.FlowSurfaceBadRequestError(
|
|
868
|
+
`flowSurfaces apply cannot resolve owning surface for record action container '${parentRef.use}'`
|
|
869
|
+
);
|
|
870
|
+
}
|
|
871
|
+
function isFieldWrapperNode(use) {
|
|
872
|
+
return (0, import_placement.isFieldWrapperUse)(use);
|
|
873
|
+
}
|
|
874
|
+
function isFieldContainer(parentUse, subKey) {
|
|
875
|
+
return (0, import_placement.isFieldContainerUse)(parentUse, subKey);
|
|
876
|
+
}
|
|
877
|
+
function isBlockContainer(parentUse, subKey) {
|
|
878
|
+
return (0, import_placement.isBlockContainerUse)(parentUse, subKey);
|
|
879
|
+
}
|
|
880
|
+
function isActionContainer(parentUse) {
|
|
881
|
+
return (0, import_placement.isActionContainerUse)(parentUse);
|
|
882
|
+
}
|
|
883
|
+
function extractResourceInit(node) {
|
|
884
|
+
return import_lodash.default.get(node, ["stepParams", "resourceSettings", "init"]);
|
|
885
|
+
}
|
|
886
|
+
function nextOpId(state, prefix) {
|
|
887
|
+
state.seq += 1;
|
|
888
|
+
return `${prefix}_${state.seq}`;
|
|
889
|
+
}
|
|
890
|
+
function bindClientKey(state, clientKey, uid) {
|
|
891
|
+
if (!clientKey || typeof uid !== "string") {
|
|
892
|
+
return;
|
|
893
|
+
}
|
|
894
|
+
state.clientKeyToUid[clientKey] = uid;
|
|
895
|
+
}
|
|
896
|
+
function syncPopupTabs(ops, state, popupPageRef, currentTabs, desiredTabs) {
|
|
897
|
+
const result = {
|
|
898
|
+
childClientKeyRefs: {},
|
|
899
|
+
finalItemRefs: [],
|
|
900
|
+
itemsChanged: false,
|
|
901
|
+
itemsSpecified: false
|
|
902
|
+
};
|
|
903
|
+
const tabMatchPlan = (0, import_matching.planArrayChildMatches)(currentTabs, desiredTabs, popupPageRef.use, "tabs");
|
|
904
|
+
const desiredRefs = [];
|
|
905
|
+
for (const [desiredIndex, desiredTab] of desiredTabs.entries()) {
|
|
906
|
+
const currentMatch = tabMatchPlan.matchesByDesiredIndex.get(desiredIndex);
|
|
907
|
+
if (currentMatch) {
|
|
908
|
+
const currentRef = {
|
|
909
|
+
uidRef: currentMatch.uid,
|
|
910
|
+
use: currentMatch.use
|
|
911
|
+
};
|
|
912
|
+
bindClientKey(state, desiredTab.clientKey, currentMatch.uid);
|
|
913
|
+
if (desiredTab.clientKey) {
|
|
914
|
+
result.childClientKeyRefs[desiredTab.clientKey] = currentRef.uidRef;
|
|
915
|
+
}
|
|
916
|
+
desiredRefs.push(currentRef);
|
|
917
|
+
syncTabNode(ops, state, { uid: currentMatch.uid }, currentMatch, desiredTab);
|
|
918
|
+
continue;
|
|
919
|
+
}
|
|
920
|
+
const createdRef = createPopupTabNode(ops, state, popupPageRef, desiredTab);
|
|
921
|
+
if (desiredTab.clientKey) {
|
|
922
|
+
result.childClientKeyRefs[desiredTab.clientKey] = createdRef.uidRef;
|
|
923
|
+
}
|
|
924
|
+
desiredRefs.push(createdRef);
|
|
925
|
+
}
|
|
926
|
+
for (const currentTab of currentTabs) {
|
|
927
|
+
if (!tabMatchPlan.matchedCurrentUids.has(currentTab.uid)) {
|
|
928
|
+
ops.push({
|
|
929
|
+
type: "removePopupTab",
|
|
930
|
+
values: {
|
|
931
|
+
target: {
|
|
932
|
+
uid: currentTab.uid
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
(0, import_layout.emitMovePopupTabOps)(ops, desiredRefs);
|
|
939
|
+
return result;
|
|
940
|
+
}
|
|
941
|
+
function createPopupTabNode(ops, state, popupPageRef, desiredNode) {
|
|
942
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
943
|
+
const opId = nextOpId(state, "addPopupTab");
|
|
944
|
+
ops.push({
|
|
945
|
+
opId,
|
|
946
|
+
type: "addPopupTab",
|
|
947
|
+
values: {
|
|
948
|
+
target: {
|
|
949
|
+
uid: popupPageRef.uidRef
|
|
950
|
+
},
|
|
951
|
+
...desiredNode.clientKey ? { clientKey: desiredNode.clientKey } : {},
|
|
952
|
+
title: ((_c = (_b = (_a = desiredNode == null ? void 0 : desiredNode.stepParams) == null ? void 0 : _a.pageTabSettings) == null ? void 0 : _b.tab) == null ? void 0 : _c.title) || ((_d = desiredNode == null ? void 0 : desiredNode.props) == null ? void 0 : _d.title) || ((_f = (_e = desiredNode == null ? void 0 : desiredNode.props) == null ? void 0 : _e.route) == null ? void 0 : _f.title) || "Untitled",
|
|
953
|
+
icon: ((_i = (_h = (_g = desiredNode == null ? void 0 : desiredNode.stepParams) == null ? void 0 : _g.pageTabSettings) == null ? void 0 : _h.tab) == null ? void 0 : _i.icon) || ((_j = desiredNode == null ? void 0 : desiredNode.props) == null ? void 0 : _j.icon),
|
|
954
|
+
documentTitle: (_m = (_l = (_k = desiredNode == null ? void 0 : desiredNode.stepParams) == null ? void 0 : _k.pageTabSettings) == null ? void 0 : _l.tab) == null ? void 0 : _m.documentTitle,
|
|
955
|
+
flowRegistry: desiredNode == null ? void 0 : desiredNode.flowRegistry
|
|
956
|
+
}
|
|
957
|
+
});
|
|
958
|
+
const ref = {
|
|
959
|
+
uidRef: makeOpRef(`${opId}.popupTabUid`),
|
|
960
|
+
use: "ChildPageTabModel",
|
|
961
|
+
sourceOpId: opId
|
|
962
|
+
};
|
|
963
|
+
syncCreatedNode(ops, state, ref, desiredNode);
|
|
964
|
+
return ref;
|
|
965
|
+
}
|
|
966
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
967
|
+
0 && (module.exports = {
|
|
968
|
+
compileApplySpec
|
|
969
|
+
});
|