@nocobase/plugin-flow-engine 2.1.0-alpha.25 → 2.1.0-alpha.27

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.
Files changed (40) hide show
  1. package/dist/ai/ai-employees/nathan/index.js +1 -0
  2. package/dist/ai/ai-employees/nathan/prompt.md +46 -10
  3. package/dist/ai/ai-employees/nathan/skills/frontend-developer/SKILLS.md +20 -3
  4. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/lintAndTestJS.js +4 -2
  5. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/patchJSCode.d.ts +10 -0
  6. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/patchJSCode.js +65 -0
  7. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/readJSCode.d.ts +10 -0
  8. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/readJSCode.js +61 -0
  9. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/writeJSCode.d.ts +10 -0
  10. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/writeJSCode.js +65 -0
  11. package/dist/externalVersion.js +10 -10
  12. package/dist/node_modules/ses/package.json +1 -1
  13. package/dist/node_modules/zod/package.json +1 -1
  14. package/dist/server/flow-surfaces/blueprint/compile-blocks.js +66 -9
  15. package/dist/server/flow-surfaces/blueprint/normalize-document.js +5 -14
  16. package/dist/server/flow-surfaces/blueprint/private-utils.d.ts +0 -1
  17. package/dist/server/flow-surfaces/blueprint/private-utils.js +0 -3
  18. package/dist/server/flow-surfaces/blueprint/public-types.d.ts +0 -1
  19. package/dist/server/flow-surfaces/builder.js +18 -0
  20. package/dist/server/flow-surfaces/catalog.js +19 -24
  21. package/dist/server/flow-surfaces/compose-compiler.d.ts +1 -2
  22. package/dist/server/flow-surfaces/compose-compiler.js +0 -1
  23. package/dist/server/flow-surfaces/compose-runtime.d.ts +1 -0
  24. package/dist/server/flow-surfaces/compose-runtime.js +2 -1
  25. package/dist/server/flow-surfaces/configure-options.js +12 -5
  26. package/dist/server/flow-surfaces/contract-guard.js +11 -3
  27. package/dist/server/flow-surfaces/field-binding-registry.js +1 -1
  28. package/dist/server/flow-surfaces/field-type-resolver.d.ts +0 -1
  29. package/dist/server/flow-surfaces/field-type-resolver.js +3 -13
  30. package/dist/server/flow-surfaces/public-compatibility.d.ts +16 -0
  31. package/dist/server/flow-surfaces/public-compatibility.js +139 -0
  32. package/dist/server/flow-surfaces/service-helpers.js +2 -2
  33. package/dist/server/flow-surfaces/service-utils.d.ts +1 -1
  34. package/dist/server/flow-surfaces/service-utils.js +21 -6
  35. package/dist/server/flow-surfaces/service.d.ts +23 -3
  36. package/dist/server/flow-surfaces/service.js +720 -167
  37. package/dist/swagger/flow-surfaces.d.ts +0 -29
  38. package/dist/swagger/flow-surfaces.js +8 -17
  39. package/dist/swagger/index.d.ts +0 -29
  40. package/package.json +2 -2
@@ -56,7 +56,6 @@ var import_reference_guards = require("./reference-guards");
56
56
  var import_key_registry = require("./planning/key-registry");
57
57
  var import_blueprint = require("./blueprint");
58
58
  var import_compile_blocks = require("./blueprint/compile-blocks");
59
- var import_private_utils = require("./blueprint/private-utils");
60
59
  var import_default_block_actions = require("./default-block-actions");
61
60
  var import_public_data_surface_default_filter = require("./public-data-surface-default-filter");
62
61
  var import_runtime = require("./planning/runtime");
@@ -77,6 +76,7 @@ var import_route_sync = require("./route-sync");
77
76
  var import_surface_context = require("./surface-context");
78
77
  var import_context = require("./context");
79
78
  var import_configure_options = require("./configure-options");
79
+ var import_public_compatibility = require("./public-compatibility");
80
80
  var import_service_helpers = require("./service-helpers");
81
81
  var import_errors2 = require("./reaction/errors");
82
82
  var import_template_display = require("./template-display");
@@ -166,6 +166,7 @@ const FILTER_TARGET_BLOCK_USES = /* @__PURE__ */ new Set([
166
166
  "MapBlockModel",
167
167
  "CommentsBlockModel"
168
168
  ]);
169
+ const TREE_CONNECT_TARGET_BLOCK_USES = new Set(FILTER_TARGET_BLOCK_USES);
169
170
  const EDITABLE_FIELD_WRAPPER_USES = /* @__PURE__ */ new Set(["FormItemModel", "FilterFormItemModel", "PatternFormItemModel"]);
170
171
  const DISPLAY_FIELD_WRAPPER_USES = /* @__PURE__ */ new Set([
171
172
  "DetailsItemModel",
@@ -261,6 +262,7 @@ const APPROVAL_CONFIRM_ACTION_USES = /* @__PURE__ */ new Set([
261
262
  "ApplyFormWithdrawModel"
262
263
  ]);
263
264
  const APPROVAL_ASSIGN_ACTION_USES = /* @__PURE__ */ new Set(["ApplyFormSubmitModel", "ApplyFormSaveDraftModel"]);
265
+ const UPDATE_ASSIGN_ACTION_USES = /* @__PURE__ */ new Set(["UpdateRecordActionModel", "BulkUpdateActionModel"]);
264
266
  const APPROVAL_COMMENT_ACTION_USES = /* @__PURE__ */ new Set([
265
267
  "ProcessFormApproveModel",
266
268
  "ProcessFormRejectModel",
@@ -287,6 +289,15 @@ const POPUP_RECORD_ACTION_CONTAINER_USES = /* @__PURE__ */ new Set([
287
289
  "GridCardItemModel"
288
290
  ]);
289
291
  const POPUP_UNSUPPORTED_COLLECTION_SCENES = /* @__PURE__ */ new Set(["select", "subForm", "bulkEditForm"]);
292
+ const POPUP_ASSOCIATED_RECORDS_BLOCK_USES = /* @__PURE__ */ new Set([
293
+ "TableBlockModel",
294
+ "CalendarBlockModel",
295
+ "KanbanBlockModel",
296
+ "ListBlockModel",
297
+ "GridCardBlockModel",
298
+ "MapBlockModel",
299
+ "CommentsBlockModel"
300
+ ]);
290
301
  const POPUP_COLLECTION_BLOCK_SCENES = {
291
302
  CreateFormModel: ["new"],
292
303
  EditFormModel: ["one", "many"],
@@ -305,6 +316,15 @@ const POPUP_COLLECTION_BLOCK_SCENES = {
305
316
  FilterFormBlockModel: ["filter"],
306
317
  FormBlockModel: []
307
318
  };
319
+ const UPDATE_ACTION_ASSIGN_SETTINGS_ASSIGNED_VALUES_PATH = [
320
+ "stepParams",
321
+ "assignSettings",
322
+ "assignFieldValues",
323
+ "assignedValues"
324
+ ];
325
+ const UPDATE_ACTION_APPLY_ASSIGNED_VALUES_PATH = ["stepParams", "apply", "apply", "assignedValues"];
326
+ const UPDATE_ACTION_ASSIGN_SETTINGS_STEP_PATH = ["assignSettings", "assignFieldValues", "assignedValues"];
327
+ const UPDATE_ACTION_APPLY_STEP_PATH = ["apply", "apply", "assignedValues"];
308
328
  const TABLE_COLUMN_STEP_PARAM_MIRRORS = [
309
329
  { domain: "props", key: "title", stepParamsPath: ["tableColumnSettings", "title", "title"] },
310
330
  { domain: "props", key: "tooltip", stepParamsPath: ["tableColumnSettings", "tooltip", "tooltip"] },
@@ -993,8 +1013,7 @@ class FlowSurfacesService {
993
1013
  fieldTypes: relationFieldTypes,
994
1014
  current: (0, import_service_utils.buildDefinedPayload)({
995
1015
  fieldType: (0, import_field_type_resolver.getPublicFieldTypeForUse)(((_g = (_f = innerField == null ? void 0 : innerField.stepParams) == null ? void 0 : _f.fieldBinding) == null ? void 0 : _g.use) || (innerField == null ? void 0 : innerField.use)),
996
- fields: this.collectRelationNestedFieldPaths(innerField),
997
- selectorFields: this.collectRelationSelectorFieldPaths(innerField),
1016
+ fields: this.collectRelationFieldPaths(innerField),
998
1017
  titleField: ((_h = innerField == null ? void 0 : innerField.props) == null ? void 0 : _h.titleField) || ((_i = node == null ? void 0 : node.props) == null ? void 0 : _i.titleField)
999
1018
  }),
1000
1019
  defaults: (0, import_service_utils.buildDefinedPayload)({
@@ -1013,12 +1032,11 @@ class FlowSurfacesService {
1013
1032
  const defaults = {
1014
1033
  titleField: defaultTitleField
1015
1034
  };
1016
- if (["subForm", "subFormList", "subDetails", "subDetailsList", "subTable", "popupSubTable"].includes(fieldType) && defaultTitleField) {
1035
+ if (["picker", "subForm", "subFormList", "subDetails", "subDetailsList", "subTable", "popupSubTable"].includes(
1036
+ fieldType
1037
+ ) && defaultTitleField) {
1017
1038
  defaults.fields = [defaultTitleField];
1018
1039
  }
1019
- if (fieldType === "picker" && defaultTitleField) {
1020
- defaults.selectorFields = [defaultTitleField];
1021
- }
1022
1040
  return {
1023
1041
  fieldType,
1024
1042
  defaults: (0, import_service_utils.buildDefinedPayload)(defaults)
@@ -1026,30 +1044,42 @@ class FlowSurfacesService {
1026
1044
  });
1027
1045
  }
1028
1046
  collectRelationNestedFieldPaths(fieldNode) {
1029
- var _a, _b, _c, _d, _e, _f, _g;
1047
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1030
1048
  const fieldUse = String(((_b = (_a = fieldNode == null ? void 0 : fieldNode.stepParams) == null ? void 0 : _a.fieldBinding) == null ? void 0 : _b.use) || (fieldNode == null ? void 0 : fieldNode.use) || "").trim();
1049
+ const relationFieldInit = ((_d = (_c = fieldNode == null ? void 0 : fieldNode.stepParams) == null ? void 0 : _c.fieldSettings) == null ? void 0 : _d.init) || {};
1050
+ const relationFieldPath = (0, import_service_helpers.normalizeFieldPath)(relationFieldInit.fieldPath, relationFieldInit.associationPathName);
1051
+ const toPublicFieldPath = (fieldPath) => {
1052
+ const normalized = String(fieldPath || "").trim();
1053
+ if (!normalized || !relationFieldPath || !normalized.startsWith(`${relationFieldPath}.`)) {
1054
+ return normalized;
1055
+ }
1056
+ return normalized.slice(relationFieldPath.length + 1);
1057
+ };
1031
1058
  if (["SubTableFieldModel", "DisplaySubTableFieldModel"].includes(fieldUse)) {
1032
- return import_lodash.default.castArray(((_c = fieldNode == null ? void 0 : fieldNode.subModels) == null ? void 0 : _c.columns) || []).map((item) => {
1059
+ return import_lodash.default.castArray(((_e = fieldNode == null ? void 0 : fieldNode.subModels) == null ? void 0 : _e.columns) || []).map((item) => {
1033
1060
  var _a2, _b2, _c2;
1034
1061
  return (_c2 = (_b2 = (_a2 = item == null ? void 0 : item.stepParams) == null ? void 0 : _a2.fieldSettings) == null ? void 0 : _b2.init) == null ? void 0 : _c2.fieldPath;
1035
- }).filter(Boolean);
1062
+ }).map(toPublicFieldPath).filter(Boolean);
1036
1063
  }
1037
1064
  if (fieldUse === "PopupSubTableFieldModel") {
1038
- return import_lodash.default.castArray(((_d = fieldNode == null ? void 0 : fieldNode.subModels) == null ? void 0 : _d.subTableColumns) || []).filter((item) => (item == null ? void 0 : item.use) === "TableColumnModel").map((item) => {
1065
+ return import_lodash.default.castArray(((_f = fieldNode == null ? void 0 : fieldNode.subModels) == null ? void 0 : _f.subTableColumns) || []).filter((item) => (item == null ? void 0 : item.use) === "TableColumnModel").map((item) => {
1039
1066
  var _a2, _b2, _c2;
1040
1067
  return (_c2 = (_b2 = (_a2 = item == null ? void 0 : item.stepParams) == null ? void 0 : _a2.fieldSettings) == null ? void 0 : _b2.init) == null ? void 0 : _c2.fieldPath;
1041
- }).filter(Boolean);
1068
+ }).map(toPublicFieldPath).filter(Boolean);
1042
1069
  }
1043
1070
  if (["SubFormFieldModel", "SubFormListFieldModel", "DisplaySubItemFieldModel", "DisplaySubListFieldModel"].includes(
1044
1071
  fieldUse
1045
1072
  )) {
1046
- return import_lodash.default.castArray(((_g = (_f = (_e = fieldNode == null ? void 0 : fieldNode.subModels) == null ? void 0 : _e.grid) == null ? void 0 : _f.subModels) == null ? void 0 : _g.items) || []).map((item) => {
1073
+ return import_lodash.default.castArray(((_i = (_h = (_g = fieldNode == null ? void 0 : fieldNode.subModels) == null ? void 0 : _g.grid) == null ? void 0 : _h.subModels) == null ? void 0 : _i.items) || []).map((item) => {
1047
1074
  var _a2, _b2, _c2;
1048
1075
  return (_c2 = (_b2 = (_a2 = item == null ? void 0 : item.stepParams) == null ? void 0 : _a2.fieldSettings) == null ? void 0 : _b2.init) == null ? void 0 : _c2.fieldPath;
1049
- }).filter(Boolean);
1076
+ }).map(toPublicFieldPath).filter(Boolean);
1050
1077
  }
1051
1078
  return void 0;
1052
1079
  }
1080
+ collectRelationFieldPaths(fieldNode) {
1081
+ return this.collectRelationNestedFieldPaths(fieldNode) || this.collectRelationSelectorFieldPaths(fieldNode);
1082
+ }
1053
1083
  collectRelationSelectorFieldPaths(fieldNode) {
1054
1084
  var _a, _b, _c, _d, _e, _f;
1055
1085
  const fieldUse = String(((_b = (_a = fieldNode == null ? void 0 : fieldNode.stepParams) == null ? void 0 : _a.fieldBinding) == null ? void 0 : _b.use) || (fieldNode == null ? void 0 : fieldNode.use) || "").trim();
@@ -1057,7 +1087,7 @@ class FlowSurfacesService {
1057
1087
  return void 0;
1058
1088
  }
1059
1089
  const table = import_lodash.default.castArray(((_e = (_d = (_c = fieldNode == null ? void 0 : fieldNode.subModels) == null ? void 0 : _c["grid-block"]) == null ? void 0 : _d.subModels) == null ? void 0 : _e.items) || []).find(
1060
- (item) => (item == null ? void 0 : item.use) === "TableBlockModel"
1090
+ (item) => (item == null ? void 0 : item.use) === "TableSelectModel" || (item == null ? void 0 : item.use) === "TableBlockModel"
1061
1091
  );
1062
1092
  return import_lodash.default.castArray(((_f = table == null ? void 0 : table.subModels) == null ? void 0 : _f.columns) || []).map((item) => {
1063
1093
  var _a2, _b2, _c2;
@@ -1100,6 +1130,9 @@ class FlowSurfacesService {
1100
1130
  isPopupCollectionBlockSceneUnsupported(scene) {
1101
1131
  return POPUP_UNSUPPORTED_COLLECTION_SCENES.has(scene);
1102
1132
  }
1133
+ supportsPopupAssociatedRecordsBinding(blockUse) {
1134
+ return POPUP_ASSOCIATED_RECORDS_BLOCK_USES.has(blockUse);
1135
+ }
1103
1136
  isPopupCollectionBlockVisibleForScene(blockUse, popupProfile) {
1104
1137
  const blockScenes = this.getPopupCollectionBlockScenes(blockUse);
1105
1138
  if (this.isPopupCollectionBlockSceneUnsupported(popupProfile.scene)) {
@@ -1272,7 +1305,7 @@ class FlowSurfacesService {
1272
1305
  collectionName: popupProfile.collectionName
1273
1306
  });
1274
1307
  }
1275
- if (popupProfile.hasCurrentRecord && associationFields.length) {
1308
+ if (this.supportsPopupAssociatedRecordsBinding(blockUse) && popupProfile.hasCurrentRecord && associationFields.length) {
1276
1309
  bindings.push({
1277
1310
  key: "associatedRecords",
1278
1311
  label: "Associated records",
@@ -1516,7 +1549,17 @@ class FlowSurfacesService {
1516
1549
  );
1517
1550
  }
1518
1551
  const resourceBindings = this.buildPopupBlockResourceBindings(input.blockUse, input.popupProfile);
1519
- const requestedBinding = ((_b = input.semanticResource) == null ? void 0 : _b.binding) || this.classifyPopupRawResourceInit(input.popupProfile, input.resourceInit || {});
1552
+ let requestedBinding = ((_b = input.semanticResource) == null ? void 0 : _b.binding) || this.classifyPopupRawResourceInit(input.popupProfile, input.resourceInit || {});
1553
+ const useLegacyAssociationPopupCurrentRecord = this.shouldUseLegacyAssociationPopupCurrentRecordBinding({
1554
+ blockUse: input.blockUse,
1555
+ popupProfile: input.popupProfile,
1556
+ requestedBinding,
1557
+ semanticResource: input.semanticResource,
1558
+ resourceInit: input.resourceInit || {}
1559
+ });
1560
+ if (useLegacyAssociationPopupCurrentRecord) {
1561
+ requestedBinding = "currentRecord";
1562
+ }
1520
1563
  if (!this.isCatalogBlockVisibleForPopupProfile(input.blockUse, input.popupProfile) && requestedBinding && !["currentCollection", "otherRecords"].includes(requestedBinding)) {
1521
1564
  (0, import_errors.throwBadRequest)(
1522
1565
  `flowSurfaces ${input.actionName} block '${blockKey}' is not available in ${this.describePopupKind(
@@ -1538,6 +1581,17 @@ class FlowSurfacesService {
1538
1581
  resource: input.semanticResource
1539
1582
  });
1540
1583
  }
1584
+ if (useLegacyAssociationPopupCurrentRecord) {
1585
+ return this.compilePopupSemanticResourceInit({
1586
+ actionName: input.actionName,
1587
+ blockUse: input.blockUse,
1588
+ popupProfile: input.popupProfile,
1589
+ resourceBindings,
1590
+ resource: {
1591
+ binding: "currentRecord"
1592
+ }
1593
+ });
1594
+ }
1541
1595
  return this.assertPopupRawResourceInit({
1542
1596
  actionName: input.actionName,
1543
1597
  blockUse: input.blockUse,
@@ -1546,6 +1600,25 @@ class FlowSurfacesService {
1546
1600
  resourceInit: input.resourceInit || {}
1547
1601
  });
1548
1602
  }
1603
+ shouldUseLegacyAssociationPopupCurrentRecordBinding(input) {
1604
+ return !input.semanticResource && input.requestedBinding === "currentCollection" && this.shouldNormalizeLegacyAssociationPopupRecordBlockResource({
1605
+ blockUse: input.blockUse,
1606
+ popupProfile: input.popupProfile,
1607
+ resourceInit: input.resourceInit
1608
+ });
1609
+ }
1610
+ shouldNormalizeLegacyAssociationPopupRecordBlockResource(input) {
1611
+ if (!["DetailsBlockModel", "EditFormModel"].includes(input.blockUse)) {
1612
+ return false;
1613
+ }
1614
+ if (input.popupProfile.popupKind !== "associationPopup" || !input.popupProfile.hasCurrentRecord || !input.popupProfile.hasAssociationContext) {
1615
+ return false;
1616
+ }
1617
+ const normalized = (0, import_service_utils.normalizeSimpleResourceInit)(input.resourceInit) || {};
1618
+ const popupDataSourceKey = input.popupProfile.dataSourceKey || "main";
1619
+ const resourceDataSourceKey = normalized.dataSourceKey || "main";
1620
+ return !!input.popupProfile.collectionName && resourceDataSourceKey === popupDataSourceKey && normalized.collectionName === input.popupProfile.collectionName && !(0, import_service_helpers.hasConfiguredFlowContextValue)(normalized.filterByTk) && !(0, import_service_helpers.hasConfiguredFlowContextValue)(normalized.associationName) && !(0, import_service_helpers.hasConfiguredFlowContextValue)(normalized.sourceId);
1621
+ }
1549
1622
  compilePopupSemanticResourceInit(input) {
1550
1623
  const binding = input.resource.binding;
1551
1624
  const supportedBinding = input.resourceBindings.find((item) => item.key === binding);
@@ -2410,19 +2483,6 @@ class FlowSurfacesService {
2410
2483
  `flowSurfaces applyBlueprint navigation.group.title '${groupTitle}' matches ${matchedRoutes.length} existing menu groups; pass navigation.group.routeId explicitly`
2411
2484
  );
2412
2485
  }
2413
- const reusedMetadataFields = import_private_utils.APPLY_BLUEPRINT_CREATE_MENU_GROUP_METADATA_KEYS.filter(
2414
- (key) => {
2415
- var _a2, _b;
2416
- return !import_lodash.default.isUndefined((_b = (_a2 = document.navigation) == null ? void 0 : _a2.group) == null ? void 0 : _b[key]);
2417
- }
2418
- );
2419
- if (reusedMetadataFields.length) {
2420
- (0, import_errors.throwBadRequest)(
2421
- `flowSurfaces applyBlueprint navigation.group.title '${groupTitle}' matched an existing menu group; do not also pass ${reusedMetadataFields.map((key) => `navigation.group.${key}`).join(
2422
- ", "
2423
- )} when reusing by title. Same-title reuse is title-only. Keep only navigation.group.title or use navigation.group.routeId for exact targeting, and call flowSurfaces:updateMenu separately if existing group metadata must change`
2424
- );
2425
- }
2426
2486
  const routeId = this.readRouteField(matchedRoutes[0], "id");
2427
2487
  if (import_lodash.default.isNil(routeId) || routeId === "") {
2428
2488
  (0, import_errors.throwBadRequest)(
@@ -3821,6 +3881,7 @@ class FlowSurfacesService {
3821
3881
  }
3822
3882
  await this.applyInlineNodeSettings(actionName, targetUid, settings, options);
3823
3883
  },
3884
+ resolveBlockSettings: (settings, state) => this.resolveComposeBlockSettings(settings, state.keyMap),
3824
3885
  createField: async (payload) => this.addField(payload, {
3825
3886
  ...options,
3826
3887
  popupTemplateAliasSession
@@ -3882,83 +3943,89 @@ class FlowSurfacesService {
3882
3943
  if (!import_lodash.default.isPlainObject(values.changes) || !Object.keys(values.changes).length) {
3883
3944
  (0, import_errors.throwBadRequest)("flowSurfaces configure requires a non-empty changes object");
3884
3945
  }
3885
- (0, import_service_utils.ensureNoRawSimpleChangeKeys)(values.changes);
3946
+ let changes = values.changes;
3947
+ (0, import_service_utils.ensureNoRawSimpleChangeKeys)(changes);
3886
3948
  const resolved = await this.locator.resolve(target, options);
3887
3949
  const current = await this.loadResolvedNode(resolved, options.transaction);
3950
+ changes = (0, import_public_compatibility.normalizeFlowSurfacePublicSortingAlias)({
3951
+ context: "flowSurfaces configure changes",
3952
+ use: current == null ? void 0 : current.use,
3953
+ settings: changes
3954
+ });
3888
3955
  if (resolved.kind === "page" && resolved.pageRoute) {
3889
- return this.configurePage(target, values.changes, options);
3956
+ return this.configurePage(target, changes, options);
3890
3957
  }
3891
3958
  if (resolved.kind === "tab" && resolved.tabRoute) {
3892
- return this.configureTab(target, values.changes, options);
3959
+ return this.configureTab(target, changes, options);
3893
3960
  }
3894
3961
  if ((current == null ? void 0 : current.use) === "TableBlockModel") {
3895
- return this.configureTableBlock(target, values.changes, options);
3962
+ return this.configureTableBlock(target, changes, options);
3896
3963
  }
3897
3964
  if ((current == null ? void 0 : current.use) === "CalendarBlockModel") {
3898
- return this.configureCalendarBlock(target, current, values.changes, options);
3965
+ return this.configureCalendarBlock(target, current, changes, options);
3899
3966
  }
3900
3967
  if ((current == null ? void 0 : current.use) === "TreeBlockModel") {
3901
- return this.configureTreeBlock(target, current, values.changes, options);
3968
+ return this.configureTreeBlock(target, current, changes, options);
3902
3969
  }
3903
3970
  if ((current == null ? void 0 : current.use) === "KanbanBlockModel") {
3904
- return this.configureKanbanBlock(target, current, values.changes, options);
3971
+ return this.configureKanbanBlock(target, current, changes, options);
3905
3972
  }
3906
3973
  if (SIMPLE_FORM_BLOCK_USES.has((current == null ? void 0 : current.use) || "")) {
3907
- return this.configureFormBlock(target, current.use, values.changes, options);
3974
+ return this.configureFormBlock(target, current.use, changes, options);
3908
3975
  }
3909
3976
  if (DETAILS_BLOCK_USES.has((current == null ? void 0 : current.use) || "")) {
3910
- return this.configureDetailsBlock(target, values.changes, options);
3977
+ return this.configureDetailsBlock(target, changes, options);
3911
3978
  }
3912
3979
  if ((current == null ? void 0 : current.use) === "FilterFormBlockModel") {
3913
- return this.configureFilterFormBlock(target, values.changes, options);
3980
+ return this.configureFilterFormBlock(target, changes, options);
3914
3981
  }
3915
3982
  if (LIST_BLOCK_USES.has((current == null ? void 0 : current.use) || "")) {
3916
- return this.configureListBlock(target, values.changes, options);
3983
+ return this.configureListBlock(target, changes, options);
3917
3984
  }
3918
3985
  if (GRID_CARD_BLOCK_USES.has((current == null ? void 0 : current.use) || "")) {
3919
- return this.configureGridCardBlock(target, values.changes, options);
3986
+ return this.configureGridCardBlock(target, changes, options);
3920
3987
  }
3921
3988
  if (import_node_use_sets.JS_BLOCK_USES.has((current == null ? void 0 : current.use) || "")) {
3922
- return this.configureJSBlock(target, values.changes, options);
3989
+ return this.configureJSBlock(target, changes, options);
3923
3990
  }
3924
3991
  if ((current == null ? void 0 : current.use) === "MarkdownBlockModel") {
3925
- return this.configureMarkdownBlock(target, values.changes, options);
3992
+ return this.configureMarkdownBlock(target, changes, options);
3926
3993
  }
3927
3994
  if ((current == null ? void 0 : current.use) === "IframeBlockModel") {
3928
- return this.configureIframeBlock(target, values.changes, options);
3995
+ return this.configureIframeBlock(target, changes, options);
3929
3996
  }
3930
3997
  if ((current == null ? void 0 : current.use) === "ChartBlockModel") {
3931
- return this.configureChartBlock(target, values.changes, options);
3998
+ return this.configureChartBlock(target, changes, options);
3932
3999
  }
3933
4000
  if ((current == null ? void 0 : current.use) === "ActionPanelBlockModel") {
3934
- return this.configureActionPanelBlock(target, values.changes, options);
4001
+ return this.configureActionPanelBlock(target, changes, options);
3935
4002
  }
3936
4003
  if ((current == null ? void 0 : current.use) === "MapBlockModel") {
3937
- return this.configureMapBlock(target, values.changes, options);
4004
+ return this.configureMapBlock(target, changes, options);
3938
4005
  }
3939
4006
  if ((current == null ? void 0 : current.use) === "CommentsBlockModel") {
3940
- return this.configureCommentsBlock(target, values.changes, options);
4007
+ return this.configureCommentsBlock(target, changes, options);
3941
4008
  }
3942
4009
  if ((current == null ? void 0 : current.use) === "TableActionsColumnModel") {
3943
- return this.configureActionColumn(target, values.changes, options);
4010
+ return this.configureActionColumn(target, changes, options);
3944
4011
  }
3945
4012
  if (import_node_use_sets.FIELD_WRAPPER_USES.has((current == null ? void 0 : current.use) || "")) {
3946
- return this.configureFieldWrapper(target, current, values.changes, options);
4013
+ return this.configureFieldWrapper(target, current, changes, options);
3947
4014
  }
3948
4015
  if (import_node_use_sets.STANDALONE_FIELD_NODE_USES.has((current == null ? void 0 : current.use) || "")) {
3949
4016
  if ((current == null ? void 0 : current.use) === "JSColumnModel") {
3950
- return this.configureJSColumn(target, values.changes, options);
4017
+ return this.configureJSColumn(target, changes, options);
3951
4018
  }
3952
4019
  if ((current == null ? void 0 : current.use) === "DividerItemModel") {
3953
- return this.configureDividerItem(target, values.changes, options);
4020
+ return this.configureDividerItem(target, changes, options);
3954
4021
  }
3955
- return this.configureJSItem(target, values.changes, options);
4022
+ return this.configureJSItem(target, changes, options);
3956
4023
  }
3957
4024
  if ((0, import_service_utils.isFieldNodeUse)(current == null ? void 0 : current.use)) {
3958
- return this.configureFieldNode(target, values.changes, options);
4025
+ return this.configureFieldNode(target, changes, options);
3959
4026
  }
3960
4027
  if (import_node_use_sets.ACTION_BUTTON_USES.has((current == null ? void 0 : current.use) || "")) {
3961
- return this.configureActionNode(target, current.use, values.changes, {
4028
+ return this.configureActionNode(target, current.use, changes, {
3962
4029
  ...options,
3963
4030
  current
3964
4031
  });
@@ -5061,7 +5128,6 @@ class FlowSurfacesService {
5061
5128
  ...fieldSpec.type ? { type: fieldSpec.type } : {},
5062
5129
  ...fieldSpec.fieldType ? { fieldType: fieldSpec.fieldType } : {},
5063
5130
  ...!import_lodash.default.isUndefined(fieldSpec.fields) ? { fields: fieldSpec.fields } : {},
5064
- ...!import_lodash.default.isUndefined(fieldSpec.selectorFields) ? { selectorFields: fieldSpec.selectorFields } : {},
5065
5131
  ...fieldSpec.titleField ? { titleField: fieldSpec.titleField } : {},
5066
5132
  ...fieldSpec.openMode ? { openMode: fieldSpec.openMode } : {},
5067
5133
  ...fieldSpec.popupSize ? { popupSize: fieldSpec.popupSize } : {},
@@ -5303,7 +5369,6 @@ class FlowSurfacesService {
5303
5369
  dataSourceKey: resolvedField.dataSourceKey,
5304
5370
  getCollection: (dataSourceKey, collectionName) => this.getCollection(dataSourceKey, collectionName),
5305
5371
  fields: values.fields,
5306
- selectorFields: values.selectorFields,
5307
5372
  titleField: values.titleField,
5308
5373
  openMode: values.openMode,
5309
5374
  popupSize: values.popupSize,
@@ -5472,6 +5537,7 @@ class FlowSurfacesService {
5472
5537
  fieldUid: tree.innerUid,
5473
5538
  fieldUse: boundFieldCapability.fieldUse,
5474
5539
  targetCollection: relationFieldTypeResolution.targetCollection,
5540
+ relationFieldInit: normalizedFieldBinding,
5475
5541
  fields: relationFieldTypeResolution.fields,
5476
5542
  selectorFields: relationFieldTypeResolution.selectorFields,
5477
5543
  titleField: relationFieldTypeResolution.titleField,
@@ -6783,6 +6849,27 @@ class FlowSurfacesService {
6783
6849
  (0, import_service_utils.rethrowInlineConfigurationError)(error, `flowSurfaces ${actionName} settings invalid`);
6784
6850
  }
6785
6851
  }
6852
+ resolveComposeBlockSettings(settings, keyMap) {
6853
+ if (!import_lodash.default.isPlainObject(settings == null ? void 0 : settings.connectFields) || !Array.isArray(settings.connectFields.targets)) {
6854
+ return settings;
6855
+ }
6856
+ const nextSettings = import_lodash.default.cloneDeep(settings);
6857
+ nextSettings.connectFields = {
6858
+ ...nextSettings.connectFields,
6859
+ targets: import_lodash.default.castArray(nextSettings.connectFields.targets).map((target) => {
6860
+ if (!import_lodash.default.isPlainObject(target) || import_lodash.default.isUndefined(target.target) || target.target === null || target.target === "") {
6861
+ return target;
6862
+ }
6863
+ const nextTarget = {
6864
+ ...target,
6865
+ targetId: (0, import_compose_compiler.resolveComposeTargetKey)(String(target.target), keyMap, "tree connectFields")
6866
+ };
6867
+ delete nextTarget.target;
6868
+ return nextTarget;
6869
+ })
6870
+ };
6871
+ return nextSettings;
6872
+ }
6786
6873
  async applyInlineFieldPopup(actionName, result, popup, options) {
6787
6874
  popup = this.prepareInlinePopupTemplateAliases(actionName, popup, options.popupTemplateAliasSession);
6788
6875
  const fieldHostUid = result.fieldUid || result.uid;
@@ -7830,6 +7917,9 @@ class FlowSurfacesService {
7830
7917
  if (typeof normalizedValues[domain] === "undefined") {
7831
7918
  return;
7832
7919
  }
7920
+ if (domain === "flowRegistry") {
7921
+ this.assertNoTreeConnectFieldsFlowRegistry(current, normalizedValues[domain], "updateSettings");
7922
+ }
7833
7923
  if (!contract.editableDomains.includes(domain)) {
7834
7924
  (0, import_errors.throwBadRequest)(`flowSurfaces updateSettings domain '${domain}' is not editable`);
7835
7925
  }
@@ -7847,6 +7937,11 @@ class FlowSurfacesService {
7847
7937
  });
7848
7938
  this.syncFilterActionSettingsForUpdateSettings(current, normalizedValues, nextPayload);
7849
7939
  this.syncMirroredStepParamsForUpdateSettings(current, nextPayload);
7940
+ const updateActionAssignedValues = this.syncUpdateActionAssignedValuesForUpdateSettings(
7941
+ current,
7942
+ normalizedValues,
7943
+ nextPayload
7944
+ );
7850
7945
  const popupActionContext = options.popupActionContext || await this.resolveRecordContextPopupActionContextForHost(current, options.transaction);
7851
7946
  await this.normalizeOpenViewForUpdateSettings(
7852
7947
  options.openViewActionName || "updateSettings",
@@ -7861,7 +7956,6 @@ class FlowSurfacesService {
7861
7956
  this.syncChartConfigureForUpdateSettings(current, nextPayload);
7862
7957
  await this.validateChartConfigureForUpdateSettings(current, nextPayload, options.transaction);
7863
7958
  this.syncCanonicalBlockHeaderForUpdateSettings(current, nextPayload);
7864
- this.syncMapHeightChromeForUpdateSettings(current, nextPayload);
7865
7959
  this.syncChartCardRuntimeStepParamsForUpdateSettings(
7866
7960
  current,
7867
7961
  nextPayload,
@@ -7900,6 +7994,9 @@ class FlowSurfacesService {
7900
7994
  };
7901
7995
  }
7902
7996
  await this.repository.patch(nextPayload, { transaction: options.transaction });
7997
+ if (!import_lodash.default.isUndefined(updateActionAssignedValues)) {
7998
+ await this.syncUpdateActionAssignFormItems(current.uid, updateActionAssignedValues, options.transaction);
7999
+ }
7903
8000
  if (!import_lodash.default.isUndefined((_a = nextPayload.stepParams) == null ? void 0 : _a.fieldSettings)) {
7904
8001
  await this.syncFieldBindingSettingsForNode(current, effectiveNode, options.transaction);
7905
8002
  } else if (current.use === "FilterFormItemModel") {
@@ -8022,6 +8119,173 @@ class FlowSurfacesService {
8022
8119
  nextPayload.stepParams = nextStepParams;
8023
8120
  }
8024
8121
  }
8122
+ syncUpdateActionAssignedValuesForUpdateSettings(current, values, nextPayload) {
8123
+ if (!UPDATE_ASSIGN_ACTION_USES.has(current == null ? void 0 : current.use)) {
8124
+ return void 0;
8125
+ }
8126
+ const hasAssignSettingsAssignedValues = import_lodash.default.has(values, UPDATE_ACTION_ASSIGN_SETTINGS_ASSIGNED_VALUES_PATH);
8127
+ const hasApplyAssignedValues = import_lodash.default.has(values, UPDATE_ACTION_APPLY_ASSIGNED_VALUES_PATH);
8128
+ if (!hasAssignSettingsAssignedValues && !hasApplyAssignedValues) {
8129
+ return void 0;
8130
+ }
8131
+ const nextStepParams = import_lodash.default.cloneDeep(nextPayload.stepParams ?? (current == null ? void 0 : current.stepParams) ?? {});
8132
+ const clearsAssignSettingsAssignedValues = hasAssignSettingsAssignedValues && import_lodash.default.isPlainObject(import_lodash.default.get(values, UPDATE_ACTION_ASSIGN_SETTINGS_ASSIGNED_VALUES_PATH)) && !Object.keys(import_lodash.default.get(values, UPDATE_ACTION_ASSIGN_SETTINGS_ASSIGNED_VALUES_PATH)).length;
8133
+ const clearsApplyAssignedValues = hasApplyAssignedValues && import_lodash.default.isPlainObject(import_lodash.default.get(values, UPDATE_ACTION_APPLY_ASSIGNED_VALUES_PATH)) && !Object.keys(import_lodash.default.get(values, UPDATE_ACTION_APPLY_ASSIGNED_VALUES_PATH)).length;
8134
+ const assignSettingsAssignedValues = clearsAssignSettingsAssignedValues ? {} : import_lodash.default.cloneDeep(import_lodash.default.get(nextStepParams, UPDATE_ACTION_ASSIGN_SETTINGS_STEP_PATH));
8135
+ const applyAssignedValues = clearsApplyAssignedValues ? {} : import_lodash.default.cloneDeep(import_lodash.default.get(nextStepParams, UPDATE_ACTION_APPLY_STEP_PATH));
8136
+ if (hasAssignSettingsAssignedValues && hasApplyAssignedValues && !import_lodash.default.isEqual(assignSettingsAssignedValues, applyAssignedValues)) {
8137
+ (0, import_errors.throwBadRequest)(
8138
+ "flowSurfaces updateSettings update action values 'stepParams.assignSettings.assignFieldValues.assignedValues' and 'stepParams.apply.apply.assignedValues' must match"
8139
+ );
8140
+ }
8141
+ const assignedValues = hasAssignSettingsAssignedValues ? assignSettingsAssignedValues : applyAssignedValues;
8142
+ if (!import_lodash.default.isPlainObject(assignedValues)) {
8143
+ (0, import_errors.throwBadRequest)(
8144
+ "flowSurfaces updateSettings update action values 'stepParams.assignSettings.assignFieldValues.assignedValues' requires an object payload"
8145
+ );
8146
+ }
8147
+ import_lodash.default.set(nextStepParams, UPDATE_ACTION_ASSIGN_SETTINGS_STEP_PATH, import_lodash.default.cloneDeep(assignedValues));
8148
+ import_lodash.default.set(nextStepParams, UPDATE_ACTION_APPLY_STEP_PATH, import_lodash.default.cloneDeep(assignedValues));
8149
+ nextPayload.stepParams = nextStepParams;
8150
+ return assignedValues;
8151
+ }
8152
+ async syncUpdateActionAssignFormItems(actionUid, assignedValues, transaction) {
8153
+ var _a, _b, _c, _d, _e, _f;
8154
+ const actionNode = await this.repository.findModelById(actionUid, {
8155
+ transaction,
8156
+ includeAsyncNode: true
8157
+ });
8158
+ if (!UPDATE_ASSIGN_ACTION_USES.has(actionNode == null ? void 0 : actionNode.use)) {
8159
+ return;
8160
+ }
8161
+ const resourceContext = await this.locator.resolveCollectionContext(actionUid, transaction).catch(() => null);
8162
+ const resourceInit = (resourceContext == null ? void 0 : resourceContext.resourceInit) || {};
8163
+ const dataSourceKey = resourceInit.dataSourceKey || "main";
8164
+ const collectionName = resourceInit.collectionName;
8165
+ const assignFormUid = await this.ensureUpdateActionAssignForm(actionNode, resourceInit, transaction);
8166
+ const assignFormGridUid = await this.ensureUpdateActionAssignFormGrid(assignFormUid, transaction);
8167
+ const refreshedGrid = await this.repository.findModelById(assignFormGridUid, {
8168
+ transaction,
8169
+ includeAsyncNode: true
8170
+ });
8171
+ const existingItems = import_lodash.default.castArray(((_a = refreshedGrid == null ? void 0 : refreshedGrid.subModels) == null ? void 0 : _a.items) || []);
8172
+ const existingItemsByFieldPath = /* @__PURE__ */ new Map();
8173
+ existingItems.forEach((item) => {
8174
+ var _a2, _b2, _c2;
8175
+ const fieldPath = String(((_c2 = (_b2 = (_a2 = item == null ? void 0 : item.stepParams) == null ? void 0 : _a2.fieldSettings) == null ? void 0 : _b2.init) == null ? void 0 : _c2.fieldPath) || "").trim();
8176
+ if (fieldPath && !existingItemsByFieldPath.has(fieldPath)) {
8177
+ existingItemsByFieldPath.set(fieldPath, item);
8178
+ }
8179
+ });
8180
+ const nextFieldPaths = new Set(Object.keys(assignedValues || {}).filter((fieldPath) => String(fieldPath).trim()));
8181
+ const keptFieldPaths = /* @__PURE__ */ new Set();
8182
+ for (const staleItem of existingItems) {
8183
+ const fieldPath = String(((_d = (_c = (_b = staleItem == null ? void 0 : staleItem.stepParams) == null ? void 0 : _b.fieldSettings) == null ? void 0 : _c.init) == null ? void 0 : _d.fieldPath) || "").trim();
8184
+ if (!fieldPath || !nextFieldPaths.has(fieldPath) || keptFieldPaths.has(fieldPath)) {
8185
+ await this.repository.remove(staleItem.uid, { transaction });
8186
+ continue;
8187
+ }
8188
+ keptFieldPaths.add(fieldPath);
8189
+ }
8190
+ for (const fieldPath of nextFieldPaths) {
8191
+ const existingItem = existingItemsByFieldPath.get(fieldPath);
8192
+ await this.repository.upsertModel(
8193
+ this.buildUpdateActionAssignFormItemTree({
8194
+ existingItem,
8195
+ uid: existingItem == null ? void 0 : existingItem.uid,
8196
+ fieldUid: (_f = (_e = existingItem == null ? void 0 : existingItem.subModels) == null ? void 0 : _e.field) == null ? void 0 : _f.uid,
8197
+ parentId: assignFormGridUid,
8198
+ dataSourceKey,
8199
+ collectionName,
8200
+ fieldPath,
8201
+ value: assignedValues[fieldPath]
8202
+ }),
8203
+ { transaction }
8204
+ );
8205
+ }
8206
+ }
8207
+ async ensureUpdateActionAssignForm(actionNode, resourceInit, transaction) {
8208
+ var _a;
8209
+ const existing = (_a = actionNode == null ? void 0 : actionNode.subModels) == null ? void 0 : _a.assignForm;
8210
+ if (existing == null ? void 0 : existing.uid) {
8211
+ return existing.uid;
8212
+ }
8213
+ const assignFormUid = (0, import_utils.uid)();
8214
+ await this.repository.upsertModel(
8215
+ {
8216
+ uid: assignFormUid,
8217
+ parentId: actionNode.uid,
8218
+ subKey: "assignForm",
8219
+ subType: "object",
8220
+ use: "AssignFormModel",
8221
+ stepParams: {
8222
+ resourceSettings: {
8223
+ init: import_lodash.default.cloneDeep(resourceInit || {})
8224
+ }
8225
+ }
8226
+ },
8227
+ { transaction }
8228
+ );
8229
+ return assignFormUid;
8230
+ }
8231
+ async ensureUpdateActionAssignFormGrid(assignFormUid, transaction) {
8232
+ return this.ensureGridChild(assignFormUid, "AssignFormGridModel", transaction);
8233
+ }
8234
+ buildUpdateActionAssignFormItemTree(input) {
8235
+ var _a;
8236
+ const init = import_lodash.default.pickBy(
8237
+ {
8238
+ dataSourceKey: input.dataSourceKey,
8239
+ collectionName: input.collectionName,
8240
+ fieldPath: input.fieldPath
8241
+ },
8242
+ (value) => !import_lodash.default.isUndefined(value)
8243
+ );
8244
+ const fieldUse = this.resolveUpdateActionAssignFormFieldUse(
8245
+ input.dataSourceKey,
8246
+ input.collectionName,
8247
+ input.fieldPath
8248
+ );
8249
+ const existingItem = input.existingItem || {};
8250
+ const existingField = ((_a = existingItem == null ? void 0 : existingItem.subModels) == null ? void 0 : _a.field) || {};
8251
+ const itemStepParams = import_lodash.default.cloneDeep(existingItem.stepParams || {});
8252
+ import_lodash.default.set(itemStepParams, ["fieldSettings", "init"], init);
8253
+ import_lodash.default.set(itemStepParams, ["fieldSettings", "assignValue", "value"], import_lodash.default.cloneDeep(input.value));
8254
+ const fieldStepParams = import_lodash.default.cloneDeep(existingField.stepParams || {});
8255
+ import_lodash.default.set(fieldStepParams, ["fieldSettings", "init"], init);
8256
+ return {
8257
+ uid: input.uid || (0, import_utils.uid)(),
8258
+ parentId: input.parentId,
8259
+ subKey: "items",
8260
+ subType: "array",
8261
+ use: "AssignFormItemModel",
8262
+ stepParams: itemStepParams,
8263
+ subModels: {
8264
+ field: {
8265
+ uid: input.fieldUid || (0, import_utils.uid)(),
8266
+ use: existingField.use || fieldUse,
8267
+ stepParams: fieldStepParams
8268
+ }
8269
+ }
8270
+ };
8271
+ }
8272
+ resolveUpdateActionAssignFormFieldUse(dataSourceKey, collectionName, fieldPath) {
8273
+ const collection = collectionName ? this.getCollection(dataSourceKey, collectionName) : null;
8274
+ const field = (0, import_service_helpers.resolveFieldFromCollection)(collection, fieldPath);
8275
+ if (field) {
8276
+ const registeredBinding = this.resolveRegisteredFieldBinding({
8277
+ containerUse: "AssignFormGridModel",
8278
+ field,
8279
+ dataSourceKey,
8280
+ useStrictOnly: true
8281
+ });
8282
+ if (registeredBinding == null ? void 0 : registeredBinding.modelClassName) {
8283
+ return registeredBinding.modelClassName;
8284
+ }
8285
+ return (0, import_service_helpers.inferFieldMenuEditableFieldUse)((0, import_service_helpers.getFieldInterface)(field)) || "InputFieldModel";
8286
+ }
8287
+ return "InputFieldModel";
8288
+ }
8025
8289
  normalizeCanonicalBlockHeaderWriteForUpdateSettings(current, values) {
8026
8290
  const semanticUse = (0, import_approval.normalizeApprovalSemanticUse)(current == null ? void 0 : current.use);
8027
8291
  if (!CANONICAL_BLOCK_HEADER_USES.has(semanticUse)) {
@@ -8052,6 +8316,7 @@ class FlowSurfacesService {
8052
8316
  import_lodash.default.set(values, titleDescriptionPath, normalizedTitleDescription);
8053
8317
  }
8054
8318
  syncCanonicalBlockHeaderForUpdateSettings(current, nextPayload) {
8319
+ var _a;
8055
8320
  const semanticUse = (0, import_approval.normalizeApprovalSemanticUse)(current == null ? void 0 : current.use);
8056
8321
  if (!CANONICAL_BLOCK_HEADER_USES.has(semanticUse)) {
8057
8322
  return;
@@ -8062,11 +8327,19 @@ class FlowSurfacesService {
8062
8327
  const nextStepParams = import_lodash.default.cloneDeep(nextPayload.stepParams ?? (current == null ? void 0 : current.stepParams) ?? {});
8063
8328
  const nextCardSettings = import_lodash.default.cloneDeep(import_lodash.default.get(nextStepParams, ["cardSettings"]) || {});
8064
8329
  const normalizedTitleDescription = (0, import_service_utils.normalizeBlockTitleDescription)(import_lodash.default.get(nextCardSettings, ["titleDescription"]));
8330
+ const normalizedBlockHeight = (_a = (0, import_service_utils.normalizeChartCardSettings)({
8331
+ blockHeight: import_lodash.default.get(nextCardSettings, ["blockHeight"])
8332
+ })) == null ? void 0 : _a.blockHeight;
8065
8333
  if (normalizedTitleDescription) {
8066
8334
  import_lodash.default.set(nextCardSettings, ["titleDescription"], normalizedTitleDescription);
8067
8335
  } else {
8068
8336
  import_lodash.default.unset(nextCardSettings, ["titleDescription"]);
8069
8337
  }
8338
+ if (normalizedBlockHeight) {
8339
+ import_lodash.default.set(nextCardSettings, ["blockHeight"], normalizedBlockHeight);
8340
+ } else {
8341
+ import_lodash.default.unset(nextCardSettings, ["blockHeight"]);
8342
+ }
8070
8343
  if (import_lodash.default.isEmpty(nextCardSettings)) {
8071
8344
  import_lodash.default.unset(nextStepParams, ["cardSettings"]);
8072
8345
  } else {
@@ -8100,28 +8373,6 @@ class FlowSurfacesService {
8100
8373
  );
8101
8374
  }
8102
8375
  }
8103
- syncMapHeightChromeForUpdateSettings(current, nextPayload) {
8104
- if ((current == null ? void 0 : current.use) !== "MapBlockModel") {
8105
- return;
8106
- }
8107
- const nextProps = import_lodash.default.isPlainObject(nextPayload.props) ? nextPayload.props : void 0;
8108
- if (!nextProps) {
8109
- return;
8110
- }
8111
- const nextDecoratorProps = import_lodash.default.cloneDeep(nextPayload.decoratorProps ?? (current == null ? void 0 : current.decoratorProps) ?? {});
8112
- let changed = false;
8113
- if (Object.prototype.hasOwnProperty.call(nextProps, "height") && nextDecoratorProps.height !== nextProps.height) {
8114
- nextDecoratorProps.height = nextProps.height;
8115
- changed = true;
8116
- }
8117
- if (Object.prototype.hasOwnProperty.call(nextProps, "heightMode") && nextDecoratorProps.heightMode !== nextProps.heightMode) {
8118
- nextDecoratorProps.heightMode = nextProps.heightMode;
8119
- changed = true;
8120
- }
8121
- if (changed) {
8122
- nextPayload.decoratorProps = (0, import_service_utils.buildDefinedPayload)(nextDecoratorProps);
8123
- }
8124
- }
8125
8376
  async normalizeOpenViewForUpdateSettings(actionName, current, nextPayload, options = {}) {
8126
8377
  const openViewPaths = [
8127
8378
  ["popupSettings", "openView"],
@@ -8389,6 +8640,7 @@ class FlowSurfacesService {
8389
8640
  (0, import_errors.throwBadRequest)(`flowSurfaces setEventFlows is not supported on '${(current == null ? void 0 : current.use) || target.uid}'`);
8390
8641
  }
8391
8642
  const flows = values.flowRegistry || values.flows || {};
8643
+ this.assertNoTreeConnectFieldsFlowRegistry(current, flows, "setEventFlows");
8392
8644
  this.contractGuard.validateFlowRegistry(current, flows);
8393
8645
  if (target.kind === "tab" && target.tabRoute) {
8394
8646
  await this.routeSync.persistTabSettings(
@@ -8504,10 +8756,13 @@ class FlowSurfacesService {
8504
8756
  });
8505
8757
  this.assertRemoveNodeResolvedTarget(resolved, node);
8506
8758
  if ((node == null ? void 0 : node.use) === "FilterFormItemModel") {
8507
- await this.removeFilterFormConnectConfig(resolved.uid, options.transaction);
8759
+ await this.removeFilterSourceBindings(resolved.uid, options.transaction);
8760
+ }
8761
+ if ((node == null ? void 0 : node.use) === "TreeBlockModel") {
8762
+ await this.removeFilterSourceBindings(resolved.uid, options.transaction);
8508
8763
  }
8509
8764
  if (FILTER_TARGET_BLOCK_USES.has((node == null ? void 0 : node.use) || "")) {
8510
- await this.removeFilterFormTargetBindings(resolved.uid, options.transaction);
8765
+ await this.removeFilterTargetBindings(resolved.uid, options.transaction);
8511
8766
  }
8512
8767
  const approvalRoot = await this.findApprovalSurfaceRootForNode(resolved.uid, options.transaction);
8513
8768
  await this.removeNodeTreeWithBindings(resolved.uid, options.transaction);
@@ -9976,10 +10231,13 @@ class FlowSurfacesService {
9976
10231
  }
9977
10232
  }
9978
10233
  if (node.use === "FilterFormItemModel") {
9979
- await this.removeFilterFormConnectConfig(node.uid, transaction);
10234
+ await this.removeFilterSourceBindings(node.uid, transaction);
10235
+ }
10236
+ if (node.use === "TreeBlockModel") {
10237
+ await this.removeFilterSourceBindings(node.uid, transaction);
9980
10238
  }
9981
10239
  if (FILTER_TARGET_BLOCK_USES.has(node.use || "")) {
9982
- await this.removeFilterFormTargetBindings(node.uid, transaction);
10240
+ await this.removeFilterTargetBindings(node.uid, transaction);
9983
10241
  }
9984
10242
  }
9985
10243
  async configurePage(target, changes, options) {
@@ -10047,15 +10305,11 @@ class FlowSurfacesService {
10047
10305
  }
10048
10306
  async configureTableBlock(target, changes, options) {
10049
10307
  const allowedKeys = (0, import_configure_options.getConfigureOptionKeysForUse)("TableBlockModel");
10050
- const cardSettings = (0, import_service_utils.buildBlockTitleDescriptionFromSemanticChanges)(changes);
10308
+ const cardSettings = (0, import_service_utils.buildBlockCardSettingsFromSemanticChanges)(changes);
10051
10309
  (0, import_service_utils.assertSupportedSimpleChanges)("table", changes, allowedKeys);
10052
10310
  return this.updateSettings(
10053
10311
  {
10054
10312
  target,
10055
- decoratorProps: (0, import_service_utils.buildDefinedPayload)({
10056
- height: changes.height,
10057
- heightMode: (0, import_service_utils.normalizePublicBlockHeightMode)(changes.heightMode)
10058
- }),
10059
10313
  stepParams: {
10060
10314
  ...cardSettings ? { cardSettings } : {},
10061
10315
  ...changes.resource ? {
@@ -10096,7 +10350,7 @@ class FlowSurfacesService {
10096
10350
  async configureCalendarBlock(target, current, changes, options) {
10097
10351
  var _a;
10098
10352
  const allowedKeys = (0, import_configure_options.getConfigureOptionKeysForUse)("CalendarBlockModel");
10099
- const cardSettings = (0, import_service_utils.buildBlockTitleDescriptionFromSemanticChanges)(changes);
10353
+ const cardSettings = (0, import_service_utils.buildBlockCardSettingsFromSemanticChanges)(changes);
10100
10354
  (0, import_service_utils.assertSupportedSimpleChanges)("calendar", changes, allowedKeys);
10101
10355
  this.validateCalendarSettingValues("configure", {
10102
10356
  defaultView: changes.defaultView,
@@ -10149,10 +10403,6 @@ class FlowSurfacesService {
10149
10403
  quickCreatePopupSettings,
10150
10404
  eventPopupSettings
10151
10405
  }),
10152
- decoratorProps: (0, import_service_utils.buildDefinedPayload)({
10153
- height: changes.height,
10154
- heightMode: (0, import_service_utils.normalizePublicBlockHeightMode)(changes.heightMode)
10155
- }),
10156
10406
  stepParams: {
10157
10407
  ...cardSettings ? { cardSettings } : {},
10158
10408
  ...changes.resource ? {
@@ -10199,14 +10449,14 @@ class FlowSurfacesService {
10199
10449
  async configureTreeBlock(target, current, changes, options) {
10200
10450
  var _a, _b;
10201
10451
  const allowedKeys = (0, import_configure_options.getConfigureOptionKeysForUse)("TreeBlockModel");
10202
- const cardSettings = (0, import_service_utils.buildBlockTitleDescriptionFromSemanticChanges)(changes);
10452
+ const cardSettings = (0, import_service_utils.buildBlockCardSettingsFromSemanticChanges)(changes);
10203
10453
  (0, import_service_utils.assertSupportedSimpleChanges)("tree", changes, allowedKeys);
10204
10454
  const nextFieldNames = import_lodash.default.isPlainObject(changes.fieldNames) ? import_lodash.default.merge({}, ((_a = current == null ? void 0 : current.props) == null ? void 0 : _a.fieldNames) || {}, changes.fieldNames) : import_lodash.default.cloneDeep(((_b = current == null ? void 0 : current.props) == null ? void 0 : _b.fieldNames) || {});
10205
10455
  if ((0, import_service_utils.hasOwnDefined)(changes, "titleField")) {
10206
10456
  nextFieldNames.title = String(changes.titleField || "").trim();
10207
10457
  }
10208
10458
  const hasFieldNamesPatch = (0, import_service_utils.hasOwnDefined)(changes, "titleField") || import_lodash.default.isPlainObject(changes.fieldNames);
10209
- return this.updateSettings(
10459
+ const result = await this.updateSettings(
10210
10460
  {
10211
10461
  target,
10212
10462
  props: (0, import_service_utils.buildDefinedPayload)({
@@ -10216,10 +10466,6 @@ class FlowSurfacesService {
10216
10466
  ...hasFieldNamesPatch ? { fieldNames: nextFieldNames } : {},
10217
10467
  ...(0, import_service_utils.hasOwnDefined)(changes, "pageSize") ? { pageSize: changes.pageSize } : {}
10218
10468
  }),
10219
- decoratorProps: (0, import_service_utils.buildDefinedPayload)({
10220
- height: changes.height,
10221
- heightMode: (0, import_service_utils.normalizePublicBlockHeightMode)(changes.heightMode)
10222
- }),
10223
10469
  stepParams: {
10224
10470
  ...cardSettings ? { cardSettings } : {},
10225
10471
  ...changes.resource ? {
@@ -10250,11 +10496,43 @@ class FlowSurfacesService {
10250
10496
  },
10251
10497
  options
10252
10498
  );
10499
+ if ((0, import_service_utils.hasOwnDefined)(changes, "connectFields")) {
10500
+ const effectiveTreeNode = changes.resource || hasFieldNamesPatch || (0, import_service_utils.hasDefinedValue)(changes, [
10501
+ "searchable",
10502
+ "defaultExpandAll",
10503
+ "includeDescendants",
10504
+ "titleField",
10505
+ "pageSize",
10506
+ "dataScope",
10507
+ "sorting"
10508
+ ]) ? await this.repository.findModelById(current.uid, {
10509
+ transaction: options.transaction,
10510
+ includeAsyncNode: true
10511
+ }) : current;
10512
+ await this.persistTreeConnectFields(
10513
+ effectiveTreeNode,
10514
+ changes.connectFields,
10515
+ "configure tree",
10516
+ options.transaction
10517
+ );
10518
+ return {
10519
+ ...result,
10520
+ updated: import_lodash.default.uniq([...result.updated || [], "connectFields"])
10521
+ };
10522
+ }
10523
+ if ((0, import_service_utils.hasOwnDefined)(changes, "resource")) {
10524
+ await this.removeFilterSourceBindings(current.uid, options.transaction);
10525
+ return {
10526
+ ...result,
10527
+ updated: import_lodash.default.uniq([...result.updated || [], "connectFields"])
10528
+ };
10529
+ }
10530
+ return result;
10253
10531
  }
10254
10532
  async configureKanbanBlock(target, current, changes, options) {
10255
10533
  var _a;
10256
10534
  const allowedKeys = (0, import_configure_options.getConfigureOptionKeysForUse)("KanbanBlockModel");
10257
- const blockCardSettings = (0, import_service_utils.buildBlockTitleDescriptionFromSemanticChanges)(changes);
10535
+ const blockCardSettings = (0, import_service_utils.buildBlockCardSettingsFromSemanticChanges)(changes);
10258
10536
  (0, import_service_utils.assertSupportedSimpleChanges)("kanban", changes, allowedKeys);
10259
10537
  if (!import_lodash.default.isUndefined(changes.dragEnabled) && !import_lodash.default.isBoolean(changes.dragEnabled)) {
10260
10538
  (0, import_errors.throwBadRequest)("flowSurfaces configure kanban dragEnabled must be a boolean");
@@ -10533,15 +10811,11 @@ class FlowSurfacesService {
10533
10811
  } : {}
10534
10812
  });
10535
10813
  const updated = /* @__PURE__ */ new Set();
10536
- if (Object.keys(blockProps).length || Object.keys(blockStepParams).length || (0, import_service_utils.hasDefinedValue)(changes, ["height", "heightMode"])) {
10814
+ if (Object.keys(blockProps).length || Object.keys(blockStepParams).length) {
10537
10815
  const blockResult = await this.updateSettings(
10538
10816
  {
10539
10817
  target,
10540
10818
  props: blockProps,
10541
- decoratorProps: (0, import_service_utils.buildDefinedPayload)({
10542
- height: changes.height,
10543
- heightMode: (0, import_service_utils.normalizePublicBlockHeightMode)(changes.heightMode)
10544
- }),
10545
10819
  stepParams: blockStepParams
10546
10820
  },
10547
10821
  options
@@ -10718,16 +10992,12 @@ class FlowSurfacesService {
10718
10992
  }
10719
10993
  async configureListBlock(target, changes, options) {
10720
10994
  const allowedKeys = (0, import_configure_options.getConfigureOptionKeysForUse)("ListBlockModel");
10721
- const cardSettings = (0, import_service_utils.buildBlockTitleDescriptionFromSemanticChanges)(changes);
10995
+ const cardSettings = (0, import_service_utils.buildBlockCardSettingsFromSemanticChanges)(changes);
10722
10996
  (0, import_service_utils.assertSupportedSimpleChanges)("list", changes, allowedKeys);
10723
10997
  const layoutValue = (0, import_service_utils.normalizeSimpleLayoutValue)(changes.layout);
10724
10998
  return this.updateSettings(
10725
10999
  {
10726
11000
  target,
10727
- decoratorProps: (0, import_service_utils.buildDefinedPayload)({
10728
- height: changes.height,
10729
- heightMode: (0, import_service_utils.normalizePublicBlockHeightMode)(changes.heightMode)
10730
- }),
10731
11001
  stepParams: {
10732
11002
  ...cardSettings ? { cardSettings } : {},
10733
11003
  ...changes.resource ? {
@@ -10750,17 +11020,13 @@ class FlowSurfacesService {
10750
11020
  }
10751
11021
  async configureGridCardBlock(target, changes, options) {
10752
11022
  const allowedKeys = (0, import_configure_options.getConfigureOptionKeysForUse)("GridCardBlockModel");
10753
- const cardSettings = (0, import_service_utils.buildBlockTitleDescriptionFromSemanticChanges)(changes);
11023
+ const cardSettings = (0, import_service_utils.buildBlockCardSettingsFromSemanticChanges)(changes);
10754
11024
  (0, import_service_utils.assertSupportedSimpleChanges)("gridCard", changes, allowedKeys);
10755
11025
  const layoutValue = (0, import_service_utils.normalizeSimpleLayoutValue)(changes.layout);
10756
11026
  const columns = (0, import_service_utils.normalizeGridCardColumns)(changes.columns);
10757
11027
  return this.updateSettings(
10758
11028
  {
10759
11029
  target,
10760
- decoratorProps: (0, import_service_utils.buildDefinedPayload)({
10761
- height: changes.height,
10762
- heightMode: (0, import_service_utils.normalizePublicBlockHeightMode)(changes.heightMode)
10763
- }),
10764
11030
  stepParams: {
10765
11031
  ...cardSettings ? { cardSettings } : {},
10766
11032
  ...changes.resource ? {
@@ -10929,15 +11195,11 @@ class FlowSurfacesService {
10929
11195
  }
10930
11196
  async configureMapBlock(target, changes, options) {
10931
11197
  const allowedKeys = (0, import_configure_options.getConfigureOptionKeysForUse)("MapBlockModel");
10932
- const cardSettings = (0, import_service_utils.buildBlockTitleDescriptionFromSemanticChanges)(changes);
11198
+ const cardSettings = (0, import_service_utils.buildBlockCardSettingsFromSemanticChanges)(changes);
10933
11199
  (0, import_service_utils.assertSupportedSimpleChanges)("map", changes, allowedKeys);
10934
11200
  return this.updateSettings(
10935
11201
  {
10936
11202
  target,
10937
- decoratorProps: (0, import_service_utils.buildDefinedPayload)({
10938
- height: changes.height,
10939
- heightMode: (0, import_service_utils.normalizePublicBlockHeightMode)(changes.heightMode)
10940
- }),
10941
11203
  stepParams: (0, import_service_utils.buildDefinedPayload)({
10942
11204
  ...cardSettings ? { cardSettings } : {},
10943
11205
  ...changes.resource ? {
@@ -11129,7 +11391,6 @@ class FlowSurfacesService {
11129
11391
  "version",
11130
11392
  "fieldType",
11131
11393
  "fields",
11132
- "selectorFields",
11133
11394
  "openMode",
11134
11395
  "popupSize",
11135
11396
  "pageSize",
@@ -11244,7 +11505,7 @@ class FlowSurfacesService {
11244
11505
  let effectiveInnerFieldUse = innerField == null ? void 0 : innerField.use;
11245
11506
  let fieldTypeResolution;
11246
11507
  let relationTitleFieldToApply;
11247
- if ((0, import_service_utils.hasOwnDefined)(changes, "fieldType") || (0, import_service_utils.hasOwnDefined)(changes, "fields") || (0, import_service_utils.hasOwnDefined)(changes, "selectorFields") || (0, import_service_utils.hasOwnDefined)(changes, "titleField") || (0, import_service_utils.hasOwnDefined)(changes, "openMode") || (0, import_service_utils.hasOwnDefined)(changes, "popupSize") || (0, import_service_utils.hasOwnDefined)(changes, "pageSize") || (0, import_service_utils.hasOwnDefined)(changes, "showIndex")) {
11508
+ if ((0, import_service_utils.hasOwnDefined)(changes, "fieldType") || (0, import_service_utils.hasOwnDefined)(changes, "fields") || (0, import_service_utils.hasOwnDefined)(changes, "titleField") || (0, import_service_utils.hasOwnDefined)(changes, "openMode") || (0, import_service_utils.hasOwnDefined)(changes, "popupSize") || (0, import_service_utils.hasOwnDefined)(changes, "pageSize") || (0, import_service_utils.hasOwnDefined)(changes, "showIndex")) {
11248
11509
  if (!innerUid) {
11249
11510
  (0, import_errors.throwConflict)(
11250
11511
  `flowSurfaces configure field wrapper '${current == null ? void 0 : current.use}' cannot resolve inner field`,
@@ -11263,7 +11524,6 @@ class FlowSurfacesService {
11263
11524
  dataSourceKey: (_l = fieldSource.fieldSettingsInit) == null ? void 0 : _l.dataSourceKey,
11264
11525
  getCollection: (dataSourceKey, collectionName) => this.getCollection(dataSourceKey, collectionName),
11265
11526
  fields: changes.fields,
11266
- selectorFields: changes.selectorFields,
11267
11527
  titleField: (0, import_service_utils.hasOwnDefined)(wrapperChanges, "titleField") ? wrapperChanges.titleField : void 0,
11268
11528
  openMode: (0, import_service_utils.hasOwnDefined)(changes, "openMode") ? changes.openMode : void 0,
11269
11529
  popupSize: (0, import_service_utils.hasOwnDefined)(changes, "popupSize") ? changes.popupSize : void 0,
@@ -11292,8 +11552,9 @@ class FlowSurfacesService {
11292
11552
  fieldUid: innerUid,
11293
11553
  fieldUse: normalizedFieldComponentUse,
11294
11554
  targetCollection: fieldTypeResolution.targetCollection,
11555
+ relationFieldInit: fieldSource.fieldSettingsInit,
11295
11556
  fields: (0, import_service_utils.hasOwnDefined)(changes, "fields") || shouldApplyFieldTypeDefaults ? fieldTypeResolution.fields : void 0,
11296
- selectorFields: (0, import_service_utils.hasOwnDefined)(changes, "selectorFields") || shouldApplyFieldTypeDefaults ? fieldTypeResolution.selectorFields : void 0,
11557
+ selectorFields: (0, import_service_utils.hasOwnDefined)(changes, "fields") || shouldApplyFieldTypeDefaults ? fieldTypeResolution.selectorFields : void 0,
11297
11558
  titleField: relationTitleFieldToApply,
11298
11559
  openMode: fieldTypeResolution.openMode,
11299
11560
  popupSize: fieldTypeResolution.popupSize,
@@ -11513,6 +11774,12 @@ class FlowSurfacesService {
11513
11774
  }
11514
11775
  return import_lodash.default.cloneDeep(value);
11515
11776
  }
11777
+ normalizeActionAssignValues(actionName, value) {
11778
+ if (!import_lodash.default.isPlainObject(value)) {
11779
+ (0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} assignValues must be an object`);
11780
+ }
11781
+ return import_lodash.default.cloneDeep(value);
11782
+ }
11516
11783
  async configureActionNode(target, use, changes, options) {
11517
11784
  changes = await this.normalizeActionPanelActionChanges(changes, options);
11518
11785
  const allowedKeys = (0, import_configure_options.getConfigureOptionKeysForUse)(use);
@@ -11600,7 +11867,7 @@ class FlowSurfacesService {
11600
11867
  stepParams.submitSettings = {
11601
11868
  confirm: (0, import_service_utils.normalizeSimpleConfirm)(changes.confirm)
11602
11869
  };
11603
- } else if (["UpdateRecordActionModel", "BulkUpdateActionModel"].includes(use)) {
11870
+ } else if (UPDATE_ASSIGN_ACTION_USES.has(use)) {
11604
11871
  stepParams.assignSettings = {
11605
11872
  confirm: (0, import_service_utils.normalizeSimpleConfirm)(changes.confirm)
11606
11873
  };
@@ -11609,25 +11876,26 @@ class FlowSurfacesService {
11609
11876
  }
11610
11877
  }
11611
11878
  if ((0, import_service_utils.hasOwnDefined)(changes, "assignValues")) {
11879
+ const assignValues = this.normalizeActionAssignValues("configure", changes.assignValues);
11612
11880
  if (APPROVAL_ASSIGN_ACTION_USES.has(use)) {
11613
11881
  stepParams.clickSettings = {
11614
11882
  ...stepParams.clickSettings || {},
11615
11883
  assignFieldValues: {
11616
- assignedValues: changes.assignValues
11884
+ assignedValues: assignValues
11617
11885
  }
11618
11886
  };
11619
- } else if (!["UpdateRecordActionModel", "BulkUpdateActionModel"].includes(use)) {
11887
+ } else if (!UPDATE_ASSIGN_ACTION_USES.has(use)) {
11620
11888
  (0, import_errors.throwBadRequest)(`flowSurfaces configure action '${use}' does not support assignValues`);
11621
11889
  } else {
11622
11890
  stepParams.assignSettings = {
11623
11891
  ...stepParams.assignSettings || {},
11624
11892
  assignFieldValues: {
11625
- assignedValues: changes.assignValues
11893
+ assignedValues: assignValues
11626
11894
  }
11627
11895
  };
11628
11896
  stepParams.apply = {
11629
11897
  apply: {
11630
- assignedValues: changes.assignValues
11898
+ assignedValues: assignValues
11631
11899
  }
11632
11900
  };
11633
11901
  }
@@ -11643,7 +11911,7 @@ class FlowSurfacesService {
11643
11911
  };
11644
11912
  }
11645
11913
  if ((0, import_service_utils.hasOwnDefined)(changes, "updateMode")) {
11646
- if (!["UpdateRecordActionModel", "BulkUpdateActionModel"].includes(use)) {
11914
+ if (!UPDATE_ASSIGN_ACTION_USES.has(use)) {
11647
11915
  (0, import_errors.throwBadRequest)(`flowSurfaces configure action '${use}' does not support updateMode`);
11648
11916
  }
11649
11917
  stepParams.assignSettings = {
@@ -12233,6 +12501,222 @@ class FlowSurfacesService {
12233
12501
  }
12234
12502
  return null;
12235
12503
  }
12504
+ assertNoTreeConnectFieldsFlowRegistry(node, flowRegistry, actionName) {
12505
+ if ((node == null ? void 0 : node.use) !== "TreeBlockModel" || !import_lodash.default.isPlainObject(flowRegistry) || !Object.prototype.hasOwnProperty.call(flowRegistry, "connectFields")) {
12506
+ return;
12507
+ }
12508
+ (0, import_errors.throwBadRequest)(
12509
+ `flowSurfaces ${actionName} tree connectFields is not a flowRegistry key; use configure changes.connectFields`
12510
+ );
12511
+ }
12512
+ normalizeTreeConnectFields(value, actionName) {
12513
+ if (!import_lodash.default.isPlainObject(value)) {
12514
+ (0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} tree connectFields must be an object`);
12515
+ }
12516
+ if (!Array.isArray(value.targets)) {
12517
+ (0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} tree connectFields.targets must be an array`);
12518
+ }
12519
+ const seenTargetBlockUids = /* @__PURE__ */ new Set();
12520
+ return value.targets.map((target, targetIndex) => {
12521
+ if (!import_lodash.default.isPlainObject(target)) {
12522
+ (0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} tree connectFields.targets[${targetIndex}] must be an object`);
12523
+ }
12524
+ const targetBlockUid = String(target.targetId || target.targetBlockUid || "").trim();
12525
+ if (!targetBlockUid) {
12526
+ (0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} tree connectFields.targets[${targetIndex}] requires targetId`);
12527
+ }
12528
+ if (seenTargetBlockUids.has(targetBlockUid)) {
12529
+ (0, import_errors.throwBadRequest)(
12530
+ `flowSurfaces ${actionName} tree connectFields.targets[${targetIndex}] duplicate targetId '${targetBlockUid}'`
12531
+ );
12532
+ }
12533
+ seenTargetBlockUids.add(targetBlockUid);
12534
+ let filterPaths;
12535
+ if ((0, import_service_utils.hasOwnDefined)(target, "filterPaths")) {
12536
+ if (!Array.isArray(target.filterPaths) || !target.filterPaths.length) {
12537
+ (0, import_errors.throwBadRequest)(
12538
+ `flowSurfaces ${actionName} tree connectFields.targets[${targetIndex}].filterPaths must be a non-empty string array`
12539
+ );
12540
+ }
12541
+ filterPaths = target.filterPaths.map((path, pathIndex) => {
12542
+ if (typeof path !== "string" || !path.trim()) {
12543
+ (0, import_errors.throwBadRequest)(
12544
+ `flowSurfaces ${actionName} tree connectFields.targets[${targetIndex}].filterPaths[${pathIndex}] must be a non-empty string`
12545
+ );
12546
+ }
12547
+ return (0, import_service_helpers.normalizeFieldPath)(path);
12548
+ });
12549
+ }
12550
+ return {
12551
+ targetBlockUid,
12552
+ ...filterPaths ? { filterPaths } : {}
12553
+ };
12554
+ });
12555
+ }
12556
+ getDataBlockResourceInit(blockNode) {
12557
+ if ((blockNode == null ? void 0 : blockNode.use) === "ChartBlockModel") {
12558
+ return (0, import_chart_config.getChartBuilderResourceInit)(import_lodash.default.get(blockNode, ["stepParams", "chartSettings", "configure"]));
12559
+ }
12560
+ const init = import_lodash.default.cloneDeep(import_lodash.default.get(blockNode, ["stepParams", "resourceSettings", "init"]) || {});
12561
+ if (init.collectionName && !init.dataSourceKey) {
12562
+ init.dataSourceKey = "main";
12563
+ }
12564
+ return init;
12565
+ }
12566
+ getTreeSelectedKeyFieldPath(treeNode, treeCollection) {
12567
+ const configuredKey = String(import_lodash.default.get(treeNode, ["props", "fieldNames", "key"]) || "").trim();
12568
+ return configuredKey ? (0, import_service_helpers.normalizeFieldPath)(configuredKey) : this.getCollectionFilterTargetKey(treeCollection);
12569
+ }
12570
+ normalizeTreeConnectFilterPaths(input) {
12571
+ var _a, _b, _c, _d, _e, _f, _g;
12572
+ const treeDataSourceKey = String(((_a = input.treeResourceInit) == null ? void 0 : _a.dataSourceKey) || "main").trim();
12573
+ const treeCollectionName = String(((_b = input.treeResourceInit) == null ? void 0 : _b.collectionName) || "").trim();
12574
+ const targetDataSourceKey = String(((_c = input.targetResourceInit) == null ? void 0 : _c.dataSourceKey) || "main").trim();
12575
+ const targetCollectionName = String(((_d = input.targetResourceInit) == null ? void 0 : _d.collectionName) || "").trim();
12576
+ if (!treeCollectionName) {
12577
+ (0, import_errors.throwBadRequest)(
12578
+ `flowSurfaces ${input.actionName} tree block '${((_e = input.treeNode) == null ? void 0 : _e.uid) || "unknown"}' requires resource.collectionName`
12579
+ );
12580
+ }
12581
+ if (!targetCollectionName) {
12582
+ (0, import_errors.throwBadRequest)(
12583
+ `flowSurfaces ${input.actionName} tree connectFields target '${((_f = input.targetNode) == null ? void 0 : _f.uid) || "unknown"}' requires resource.collectionName`
12584
+ );
12585
+ }
12586
+ const targetCollection = this.getCollection(targetDataSourceKey, targetCollectionName);
12587
+ if (!targetCollection) {
12588
+ (0, import_errors.throwBadRequest)(
12589
+ `flowSurfaces ${input.actionName} tree connectFields target collection '${targetDataSourceKey}.${targetCollectionName}' not found`
12590
+ );
12591
+ }
12592
+ const treeCollection = this.getCollection(treeDataSourceKey, treeCollectionName);
12593
+ if (!treeCollection) {
12594
+ (0, import_errors.throwBadRequest)(
12595
+ `flowSurfaces ${input.actionName} tree connectFields source collection '${treeDataSourceKey}.${treeCollectionName}' not found`
12596
+ );
12597
+ }
12598
+ const isSameCollection = treeDataSourceKey === targetDataSourceKey && treeCollectionName === targetCollectionName;
12599
+ const normalizedPaths = input.filterPaths && input.filterPaths.length ? input.filterPaths : isSameCollection ? [this.getCollectionFilterTargetKey(targetCollection)] : void 0;
12600
+ if (!(normalizedPaths == null ? void 0 : normalizedPaths.length)) {
12601
+ (0, import_errors.throwBadRequest)(
12602
+ `flowSurfaces ${input.actionName} tree connectFields target '${((_g = input.targetNode) == null ? void 0 : _g.uid) || "unknown"}' requires filterPaths when target collection differs from tree collection`
12603
+ );
12604
+ }
12605
+ const filterTargetKey = this.getCollectionFilterTargetKey(targetCollection);
12606
+ const treeKeyFieldPath = this.getTreeSelectedKeyFieldPath(input.treeNode, treeCollection);
12607
+ const treeKeyField = this.resolveTreeConnectComparableField(treeCollection, treeKeyFieldPath);
12608
+ const treeKeyKind = this.normalizeTreeConnectValueKind(treeKeyField);
12609
+ return normalizedPaths.map((fieldPath) => {
12610
+ const normalizedFieldPath = (0, import_service_helpers.normalizeFieldPath)(fieldPath);
12611
+ const isBuiltInTargetPath = normalizedFieldPath === "id" || normalizedFieldPath === filterTargetKey;
12612
+ const targetField = this.resolveTreeConnectComparableField(targetCollection, normalizedFieldPath);
12613
+ if (!isBuiltInTargetPath && !targetField) {
12614
+ (0, import_errors.throwBadRequest)(
12615
+ `flowSurfaces ${input.actionName} tree connectFields filterPaths '${normalizedFieldPath}' does not exist on target collection '${targetDataSourceKey}.${targetCollectionName}'`
12616
+ );
12617
+ }
12618
+ const targetKind = this.normalizeTreeConnectValueKind(targetField);
12619
+ if (treeKeyKind && targetKind && treeKeyKind !== targetKind) {
12620
+ (0, import_errors.throwBadRequest)(
12621
+ `flowSurfaces ${input.actionName} tree connectFields filterPaths '${normalizedFieldPath}' is not type-compatible with tree selected key '${treeKeyFieldPath}'`
12622
+ );
12623
+ }
12624
+ return normalizedFieldPath;
12625
+ });
12626
+ }
12627
+ resolveTreeConnectComparableField(collection, fieldPath) {
12628
+ const normalizedFieldPath = (0, import_service_helpers.normalizeFieldPath)(fieldPath);
12629
+ const resolvedField = (0, import_service_helpers.resolveFieldFromCollection)(collection, normalizedFieldPath);
12630
+ if (resolvedField) {
12631
+ return resolvedField;
12632
+ }
12633
+ if (normalizedFieldPath === "id") {
12634
+ return {
12635
+ name: "id",
12636
+ type: "bigInt",
12637
+ interface: "integer"
12638
+ };
12639
+ }
12640
+ return null;
12641
+ }
12642
+ normalizeTreeConnectValueKind(field) {
12643
+ const fieldType = String((0, import_service_helpers.getFieldType)(field) || "").trim().toLowerCase();
12644
+ const fieldInterface = String((0, import_service_helpers.getFieldInterface)(field) || "").trim().toLowerCase();
12645
+ if (["bigint", "integer", "int", "number", "float", "double", "decimal", "real"].includes(fieldType) || ["bigint", "integer", "number", "percent"].includes(fieldInterface)) {
12646
+ return "number";
12647
+ }
12648
+ if (["string", "text", "uid", "uuid", "varchar", "char"].includes(fieldType) || ["input", "textarea", "select", "radiogroup", "url", "email", "phone"].includes(fieldInterface)) {
12649
+ return "string";
12650
+ }
12651
+ if (["date", "datetime", "time"].includes(fieldType) || ["date", "datetime", "time"].includes(fieldInterface)) {
12652
+ return "date";
12653
+ }
12654
+ if (fieldType === "boolean" || fieldInterface === "boolean") {
12655
+ return "boolean";
12656
+ }
12657
+ return void 0;
12658
+ }
12659
+ async persistTreeConnectFields(treeNode, connectFields, actionName, transaction) {
12660
+ if ((treeNode == null ? void 0 : treeNode.use) !== "TreeBlockModel" || !(treeNode == null ? void 0 : treeNode.uid)) {
12661
+ (0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} connectFields is only supported on tree blocks`);
12662
+ }
12663
+ const targets = this.normalizeTreeConnectFields(connectFields, actionName);
12664
+ const blockGrid = await this.findOwningBlockGrid(treeNode.uid, transaction);
12665
+ if (!(blockGrid == null ? void 0 : blockGrid.uid)) {
12666
+ (0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} tree block '${treeNode.uid}' is not under a block grid`);
12667
+ }
12668
+ const treeResourceInit = this.getDataBlockResourceInit(treeNode);
12669
+ const nextBindings = [];
12670
+ for (const target of targets) {
12671
+ if (target.targetBlockUid === treeNode.uid) {
12672
+ (0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} tree connectFields targetId cannot be the tree block itself`);
12673
+ }
12674
+ const targetNode = await this.repository.findModelById(target.targetBlockUid, {
12675
+ transaction,
12676
+ includeAsyncNode: true
12677
+ });
12678
+ if (!(targetNode == null ? void 0 : targetNode.uid)) {
12679
+ (0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} tree connectFields targetId '${target.targetBlockUid}' not found`);
12680
+ }
12681
+ if (!TREE_CONNECT_TARGET_BLOCK_USES.has(targetNode.use || "")) {
12682
+ (0, import_errors.throwBadRequest)(
12683
+ `flowSurfaces ${actionName} target '${target.targetBlockUid}' does not support tree connectFields`
12684
+ );
12685
+ }
12686
+ const targetGrid = await this.findOwningBlockGrid(targetNode.uid, transaction);
12687
+ if ((targetGrid == null ? void 0 : targetGrid.uid) !== blockGrid.uid) {
12688
+ (0, import_errors.throwBadRequest)(
12689
+ `flowSurfaces ${actionName} tree connectFields target '${target.targetBlockUid}' must be in the same block grid`
12690
+ );
12691
+ }
12692
+ const targetResourceInit = this.getDataBlockResourceInit(targetNode);
12693
+ nextBindings.push({
12694
+ filterId: treeNode.uid,
12695
+ targetId: targetNode.uid,
12696
+ filterPaths: this.normalizeTreeConnectFilterPaths({
12697
+ actionName,
12698
+ treeNode,
12699
+ treeResourceInit,
12700
+ targetNode,
12701
+ targetResourceInit,
12702
+ filterPaths: target.filterPaths
12703
+ })
12704
+ });
12705
+ }
12706
+ const currentConfigs = import_lodash.default.castArray(blockGrid.filterManager || []);
12707
+ const nextConfigs = currentConfigs.filter((config) => (config == null ? void 0 : config.filterId) !== treeNode.uid);
12708
+ nextConfigs.push(...nextBindings);
12709
+ if (import_lodash.default.isEqual(nextConfigs, currentConfigs)) {
12710
+ return;
12711
+ }
12712
+ await this.repository.patch(
12713
+ {
12714
+ uid: blockGrid.uid,
12715
+ filterManager: nextConfigs
12716
+ },
12717
+ { transaction }
12718
+ );
12719
+ }
12236
12720
  isFilterFormFieldPathAvailableForResource(resourceInit, fieldPath, associationPathName) {
12237
12721
  if (!(resourceInit == null ? void 0 : resourceInit.dataSourceKey) || !(resourceInit == null ? void 0 : resourceInit.collectionName) || !fieldPath) {
12238
12722
  return false;
@@ -12263,7 +12747,7 @@ class FlowSurfacesService {
12263
12747
  { transaction }
12264
12748
  );
12265
12749
  }
12266
- async removeFilterFormConnectConfig(filterModelUid, transaction) {
12750
+ async removeFilterSourceBindings(filterModelUid, transaction) {
12267
12751
  const blockGrid = await this.findOwningBlockGrid(filterModelUid, transaction);
12268
12752
  if (!(blockGrid == null ? void 0 : blockGrid.uid)) {
12269
12753
  return;
@@ -12281,7 +12765,7 @@ class FlowSurfacesService {
12281
12765
  { transaction }
12282
12766
  );
12283
12767
  }
12284
- async removeFilterFormTargetBindings(targetBlockUid, transaction) {
12768
+ async removeFilterTargetBindings(targetBlockUid, transaction) {
12285
12769
  const blockGrid = await this.findOwningBlockGrid(targetBlockUid, transaction);
12286
12770
  if (!(blockGrid == null ? void 0 : blockGrid.uid)) {
12287
12771
  return;
@@ -12382,7 +12866,7 @@ class FlowSurfacesService {
12382
12866
  const fieldInit = import_lodash.default.get(node, ["stepParams", "fieldSettings", "init"]) || {};
12383
12867
  const defaultTargetUid = import_lodash.default.get(node, ["stepParams", "filterFormItemSettings", "init", "defaultTargetUid"]);
12384
12868
  if (!(fieldInit == null ? void 0 : fieldInit.fieldPath) || !defaultTargetUid) {
12385
- await this.removeFilterFormConnectConfig(node.uid, transaction);
12869
+ await this.removeFilterSourceBindings(node.uid, transaction);
12386
12870
  return;
12387
12871
  }
12388
12872
  const parentUid = await this.locator.findParentUid(node.uid, transaction);
@@ -12397,7 +12881,7 @@ class FlowSurfacesService {
12397
12881
  if (!options.skipIfTargetUnavailable) {
12398
12882
  throw error;
12399
12883
  }
12400
- await this.removeFilterFormConnectConfig(node.uid, transaction);
12884
+ await this.removeFilterSourceBindings(node.uid, transaction);
12401
12885
  return null;
12402
12886
  });
12403
12887
  if (!target) {
@@ -12408,7 +12892,7 @@ class FlowSurfacesService {
12408
12892
  fieldInit.fieldPath,
12409
12893
  fieldInit.associationPathName
12410
12894
  )) {
12411
- await this.removeFilterFormConnectConfig(node.uid, transaction);
12895
+ await this.removeFilterSourceBindings(node.uid, transaction);
12412
12896
  return;
12413
12897
  }
12414
12898
  await this.persistFilterFormConnectConfig(
@@ -14348,18 +14832,36 @@ class FlowSurfacesService {
14348
14832
  }
14349
14833
  return field;
14350
14834
  }
14351
- buildRelationTargetFieldInit(collection, fieldPath) {
14835
+ buildRelationTargetFieldInit(input) {
14836
+ var _a, _b, _c, _d, _e, _f;
14837
+ const relationFieldPath = (0, import_service_helpers.normalizeFieldPath)(
14838
+ (_a = input.relationFieldInit) == null ? void 0 : _a.fieldPath,
14839
+ (_b = input.relationFieldInit) == null ? void 0 : _b.associationPathName
14840
+ );
14841
+ if (!relationFieldPath) {
14842
+ return (0, import_service_utils.buildDefinedPayload)({
14843
+ dataSourceKey: ((_c = input.targetCollection) == null ? void 0 : _c.dataSourceKey) || "main",
14844
+ collectionName: (0, import_service_helpers.getCollectionName)(input.targetCollection),
14845
+ fieldPath: input.targetFieldPath
14846
+ });
14847
+ }
14848
+ const targetAssociationPath = input.targetFieldPath.includes(".") ? input.targetFieldPath.split(".").slice(0, -1).join(".") : void 0;
14352
14849
  return (0, import_service_utils.buildDefinedPayload)({
14353
- dataSourceKey: (collection == null ? void 0 : collection.dataSourceKey) || "main",
14354
- collectionName: (0, import_service_helpers.getCollectionName)(collection),
14355
- fieldPath
14850
+ dataSourceKey: ((_d = input.relationFieldInit) == null ? void 0 : _d.dataSourceKey) || ((_e = input.targetCollection) == null ? void 0 : _e.dataSourceKey) || "main",
14851
+ collectionName: ((_f = input.relationFieldInit) == null ? void 0 : _f.collectionName) || (0, import_service_helpers.getCollectionName)(input.targetCollection),
14852
+ fieldPath: `${relationFieldPath}.${input.targetFieldPath}`,
14853
+ associationPathName: targetAssociationPath ? `${relationFieldPath}.${targetAssociationPath}` : void 0
14356
14854
  });
14357
14855
  }
14358
14856
  buildRelationTargetTableColumnNode(input) {
14359
14857
  const field = this.getCollectionFieldOrBadRequest(input.collection, input.fieldPath, "fieldType.fields");
14360
14858
  const fieldUse = input.columnUse === "SubTableColumnModel" ? (0, import_service_helpers.inferFieldMenuEditableFieldUse)((0, import_service_helpers.getFieldInterface)(field)) || "InputFieldModel" : (0, import_service_helpers.inferAssociationLeafDisplayFieldUse)((0, import_service_helpers.getFieldInterface)(field)) || "DisplayTextFieldModel";
14361
14859
  const title = (0, import_service_helpers.getFieldTitle)(field);
14362
- const fieldInit = this.buildRelationTargetFieldInit(input.collection, input.fieldPath);
14860
+ const fieldInit = this.buildRelationTargetFieldInit({
14861
+ targetCollection: input.collection,
14862
+ targetFieldPath: input.fieldPath,
14863
+ relationFieldInit: input.relationFieldInit
14864
+ });
14363
14865
  return {
14364
14866
  uid: (0, import_utils.uid)(),
14365
14867
  use: input.columnUse,
@@ -14403,7 +14905,11 @@ class FlowSurfacesService {
14403
14905
  const field = this.getCollectionFieldOrBadRequest(input.collection, input.fieldPath, "fieldType.fields");
14404
14906
  const fieldUse = input.wrapperUse === "FormItemModel" ? (0, import_service_helpers.inferFieldMenuEditableFieldUse)((0, import_service_helpers.getFieldInterface)(field)) || "InputFieldModel" : (0, import_service_helpers.inferAssociationLeafDisplayFieldUse)((0, import_service_helpers.getFieldInterface)(field)) || "DisplayTextFieldModel";
14405
14907
  const title = (0, import_service_helpers.getFieldTitle)(field);
14406
- const fieldInit = this.buildRelationTargetFieldInit(input.collection, input.fieldPath);
14908
+ const fieldInit = this.buildRelationTargetFieldInit({
14909
+ targetCollection: input.collection,
14910
+ targetFieldPath: input.fieldPath,
14911
+ relationFieldInit: input.relationFieldInit
14912
+ });
14407
14913
  return {
14408
14914
  uid: (0, import_utils.uid)(),
14409
14915
  use: input.wrapperUse,
@@ -14547,7 +15053,8 @@ class FlowSurfacesService {
14547
15053
  (fieldPath) => this.buildRelationTargetTableColumnNode({
14548
15054
  collection: input.targetCollection,
14549
15055
  fieldPath,
14550
- columnUse: input.fieldUse === "SubTableFieldModel" ? "SubTableColumnModel" : "TableColumnModel"
15056
+ columnUse: input.fieldUse === "SubTableFieldModel" ? "SubTableColumnModel" : "TableColumnModel",
15057
+ relationFieldInit: input.relationFieldInit
14551
15058
  })
14552
15059
  ),
14553
15060
  transaction: input.transaction
@@ -14569,7 +15076,8 @@ class FlowSurfacesService {
14569
15076
  (fieldPath) => this.buildRelationTargetTableColumnNode({
14570
15077
  collection: input.targetCollection,
14571
15078
  fieldPath,
14572
- columnUse: "TableColumnModel"
15079
+ columnUse: "TableColumnModel",
15080
+ relationFieldInit: input.relationFieldInit
14573
15081
  })
14574
15082
  )
14575
15083
  ],
@@ -14590,7 +15098,8 @@ class FlowSurfacesService {
14590
15098
  (fieldPath) => this.buildRelationTargetGridItemNode({
14591
15099
  collection: input.targetCollection,
14592
15100
  fieldPath,
14593
- wrapperUse
15101
+ wrapperUse,
15102
+ relationFieldInit: input.relationFieldInit
14594
15103
  })
14595
15104
  ),
14596
15105
  transaction: input.transaction
@@ -14599,10 +15108,12 @@ class FlowSurfacesService {
14599
15108
  }
14600
15109
  if (input.fieldUse === "RecordPickerFieldModel") {
14601
15110
  await this.applyRecordPickerFieldTypeSettings(input);
15111
+ } else if (input.fieldUse === "PopupSubTableFieldModel") {
15112
+ await this.ensureRelationSelectorGridTable(input);
14602
15113
  }
14603
15114
  }
14604
15115
  async applyRecordPickerFieldTypeSettings(input) {
14605
- var _a, _b, _c;
15116
+ var _a;
14606
15117
  const fieldNode = await this.repository.findModelById(input.fieldUid, {
14607
15118
  transaction: input.transaction,
14608
15119
  includeAsyncNode: true
@@ -14627,6 +15138,10 @@ class FlowSurfacesService {
14627
15138
  { transaction: input.transaction }
14628
15139
  );
14629
15140
  }
15141
+ await this.ensureRelationSelectorGridTable(input);
15142
+ }
15143
+ async ensureRelationSelectorGridTable(input) {
15144
+ var _a, _b, _c;
14630
15145
  if (!input.selectorFields) {
14631
15146
  return;
14632
15147
  }
@@ -14643,6 +15158,7 @@ class FlowSurfacesService {
14643
15158
  parentId: input.fieldUid,
14644
15159
  subKey: "grid-block",
14645
15160
  subType: "object",
15161
+ async: true,
14646
15162
  use: "BlockGridModel"
14647
15163
  },
14648
15164
  { transaction: input.transaction }
@@ -14655,30 +15171,67 @@ class FlowSurfacesService {
14655
15171
  if (!(grid == null ? void 0 : grid.uid)) {
14656
15172
  return;
14657
15173
  }
14658
- const existingTable = import_lodash.default.castArray(((_b = grid == null ? void 0 : grid.subModels) == null ? void 0 : _b.items) || []).find(
14659
- (item) => (item == null ? void 0 : item.use) === "TableBlockModel"
14660
- );
15174
+ const gridItems = import_lodash.default.castArray(((_a = grid == null ? void 0 : grid.subModels) == null ? void 0 : _a.items) || []);
15175
+ const existingTable = gridItems.find((item) => (item == null ? void 0 : item.use) === "TableSelectModel") || gridItems.find((item) => (item == null ? void 0 : item.use) === "TableBlockModel");
14661
15176
  const tableUid = (existingTable == null ? void 0 : existingTable.uid) || (0, import_utils.uid)();
14662
- if (!(existingTable == null ? void 0 : existingTable.uid)) {
14663
- await this.repository.upsertModel(
14664
- {
14665
- uid: tableUid,
14666
- parentId: grid.uid,
14667
- subKey: "items",
14668
- subType: "array",
14669
- use: "TableBlockModel",
14670
- stepParams: {
14671
- resourceSettings: {
14672
- init: {
14673
- dataSourceKey: ((_c = input.targetCollection) == null ? void 0 : _c.dataSourceKey) || "main",
14674
- collectionName: (0, import_service_helpers.getCollectionName)(input.targetCollection)
14675
- }
15177
+ for (const item of gridItems) {
15178
+ if ((item == null ? void 0 : item.uid) && item.uid !== tableUid) {
15179
+ await this.removeNodeTreeWithBindings(item.uid, input.transaction);
15180
+ }
15181
+ }
15182
+ await this.repository.upsertModel(
15183
+ {
15184
+ ...import_lodash.default.omit(import_lodash.default.cloneDeep(existingTable || {}), [
15185
+ "uid",
15186
+ "use",
15187
+ "subModels",
15188
+ "sortIndex",
15189
+ "parentId",
15190
+ "subKey",
15191
+ "subType"
15192
+ ]),
15193
+ uid: tableUid,
15194
+ parentId: grid.uid,
15195
+ subKey: "items",
15196
+ subType: "array",
15197
+ use: "TableSelectModel",
15198
+ stepParams: import_lodash.default.merge({}, import_lodash.default.cloneDeep((existingTable == null ? void 0 : existingTable.stepParams) || {}), {
15199
+ resourceSettings: {
15200
+ init: {
15201
+ dataSourceKey: ((_b = input.targetCollection) == null ? void 0 : _b.dataSourceKey) || "main",
15202
+ collectionName: (0, import_service_helpers.getCollectionName)(input.targetCollection)
14676
15203
  }
14677
15204
  }
15205
+ })
15206
+ },
15207
+ { transaction: input.transaction }
15208
+ );
15209
+ const layout = {
15210
+ rows: {
15211
+ row1: [[tableUid]]
15212
+ },
15213
+ sizes: {
15214
+ row1: [24]
15215
+ },
15216
+ rowOrder: ["row1"]
15217
+ };
15218
+ await this.repository.patch(
15219
+ {
15220
+ uid: grid.uid,
15221
+ props: {
15222
+ ...grid.props || {},
15223
+ ...layout
14678
15224
  },
14679
- { transaction: input.transaction }
14680
- );
14681
- }
15225
+ stepParams: {
15226
+ ...grid.stepParams || {},
15227
+ [GRID_SETTINGS_FLOW_KEY]: {
15228
+ ...((_c = grid.stepParams) == null ? void 0 : _c[GRID_SETTINGS_FLOW_KEY]) || {},
15229
+ [GRID_SETTINGS_LAYOUT_STEP_KEY]: layout
15230
+ }
15231
+ }
15232
+ },
15233
+ { transaction: input.transaction }
15234
+ );
14682
15235
  await this.replaceFieldSubModelArray({
14683
15236
  parentUid: tableUid,
14684
15237
  subKey: "columns",