@nocobase/plugin-flow-engine 2.1.0-beta.20 → 2.1.0-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/externalVersion.js +10 -10
  2. package/dist/node_modules/ses/package.json +1 -1
  3. package/dist/node_modules/zod/package.json +1 -1
  4. package/dist/server/flow-surfaces/apply/compiler.js +4 -2
  5. package/dist/server/flow-surfaces/association-interfaces.d.ts +10 -0
  6. package/dist/server/flow-surfaces/association-interfaces.js +39 -0
  7. package/dist/server/flow-surfaces/blueprint/compile-blocks.js +50 -5
  8. package/dist/server/flow-surfaces/blueprint/public-types.d.ts +9 -1
  9. package/dist/server/flow-surfaces/builder.d.ts +27 -1
  10. package/dist/server/flow-surfaces/builder.js +36 -4
  11. package/dist/server/flow-surfaces/catalog.d.ts +1 -0
  12. package/dist/server/flow-surfaces/catalog.js +129 -13
  13. package/dist/server/flow-surfaces/compose-compiler.d.ts +8 -0
  14. package/dist/server/flow-surfaces/compose-compiler.js +8 -0
  15. package/dist/server/flow-surfaces/configure-options.js +39 -6
  16. package/dist/server/flow-surfaces/default-action-popup.js +2 -2
  17. package/dist/server/flow-surfaces/field-binding-registry.d.ts +1 -0
  18. package/dist/server/flow-surfaces/field-binding-registry.js +5 -0
  19. package/dist/server/flow-surfaces/field-semantics.d.ts +1 -1
  20. package/dist/server/flow-surfaces/field-semantics.js +4 -3
  21. package/dist/server/flow-surfaces/field-type-resolver.d.ts +46 -0
  22. package/dist/server/flow-surfaces/field-type-resolver.js +322 -0
  23. package/dist/server/flow-surfaces/node-use-sets.js +1 -0
  24. package/dist/server/flow-surfaces/service-utils.d.ts +13 -1
  25. package/dist/server/flow-surfaces/service-utils.js +58 -6
  26. package/dist/server/flow-surfaces/service.d.ts +17 -1
  27. package/dist/server/flow-surfaces/service.js +820 -53
  28. package/dist/server/flow-surfaces/support-matrix.js +11 -0
  29. package/dist/swagger/flow-surfaces.d.ts +173 -2
  30. package/dist/swagger/flow-surfaces.examples.d.ts +20 -15
  31. package/dist/swagger/flow-surfaces.examples.js +22 -11
  32. package/dist/swagger/flow-surfaces.js +72 -10
  33. package/dist/swagger/index.d.ts +173 -2
  34. package/package.json +2 -2
@@ -64,6 +64,7 @@ var import_created_keys = require("./planning/created-keys");
64
64
  var import_key_persistence = require("./planning/key-persistence");
65
65
  var import_payload_shape = require("./payload-shape");
66
66
  var import_field_semantics = require("./field-semantics");
67
+ var import_association_interfaces = require("./association-interfaces");
67
68
  var import_field_binding_registry = require("./field-binding-registry");
68
69
  var import_node_use_sets = require("./node-use-sets");
69
70
  var import_chart_config = require("./chart-config");
@@ -89,6 +90,7 @@ var import_association_title_field = require("./association-title-field");
89
90
  var import_default_action_popup = require("./default-action-popup");
90
91
  var import_defaults = require("./blueprint/defaults");
91
92
  var import_service_utils = require("./service-utils");
93
+ var import_field_type_resolver = require("./field-type-resolver");
92
94
  var import_template_compatibility = require("./template-compatibility");
93
95
  var import_template_service_utils = require("./template-service-utils");
94
96
  const FORM_BLOCK_USES = /* @__PURE__ */ new Set(["FormBlockModel", "CreateFormModel", "EditFormModel", ...import_approval.APPROVAL_FORM_BLOCK_USES]);
@@ -128,6 +130,7 @@ const KANBAN_POPUP_ACTION_KEYS = Object.keys(KANBAN_POPUP_ACTION_UID_SUFFIX_BY_K
128
130
  const CANONICAL_BLOCK_HEADER_USES = /* @__PURE__ */ new Set([
129
131
  "TableBlockModel",
130
132
  "CalendarBlockModel",
133
+ "TreeBlockModel",
131
134
  "KanbanBlockModel",
132
135
  "FormBlockModel",
133
136
  "CreateFormModel",
@@ -154,6 +157,7 @@ const OPEN_VIEW_SUPPORTED_MODES = /* @__PURE__ */ new Set(["drawer", "dialog", "
154
157
  const FILTER_TARGET_BLOCK_USES = /* @__PURE__ */ new Set([
155
158
  "TableBlockModel",
156
159
  "CalendarBlockModel",
160
+ "TreeBlockModel",
157
161
  "KanbanBlockModel",
158
162
  "DetailsBlockModel",
159
163
  "ListBlockModel",
@@ -293,6 +297,7 @@ const POPUP_COLLECTION_BLOCK_SCENES = {
293
297
  CommentsBlockModel: ["one", "many"],
294
298
  TableBlockModel: ["many"],
295
299
  CalendarBlockModel: ["many"],
300
+ TreeBlockModel: ["filter"],
296
301
  KanbanBlockModel: ["many"],
297
302
  ListBlockModel: ["many"],
298
303
  GridCardBlockModel: ["many"],
@@ -951,8 +956,8 @@ class FlowSurfacesService {
951
956
  return this.patchResolvedNodeConfigureOptions(node, projected, enabledPackages);
952
957
  }
953
958
  patchResolvedNodeConfigureOptions(node, projected, enabledPackages) {
954
- var _a, _b, _c;
955
- if (!((_a = projected == null ? void 0 : projected.configureOptions) == null ? void 0 : _a.fieldComponent) || !(node == null ? void 0 : node.use)) {
959
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
960
+ if (!((_a = projected == null ? void 0 : projected.configureOptions) == null ? void 0 : _a.fieldType) || !(node == null ? void 0 : node.use)) {
956
961
  return projected;
957
962
  }
958
963
  try {
@@ -967,20 +972,98 @@ class FlowSurfacesService {
967
972
  if (!(supportedFieldUses == null ? void 0 : supportedFieldUses.size)) {
968
973
  return projected;
969
974
  }
975
+ const supportedFieldTypes = Array.from(supportedFieldUses).map((use) => (0, import_field_type_resolver.getPublicFieldTypeForUse)(use)).filter(Boolean);
970
976
  const configureOptions = import_lodash.default.cloneDeep(projected.configureOptions || {});
971
- configureOptions.fieldComponent = {
972
- type: ((_c = configureOptions.fieldComponent) == null ? void 0 : _c.type) || "string",
973
- ...configureOptions.fieldComponent || {},
974
- enum: Array.from(supportedFieldUses)
977
+ configureOptions.fieldType = {
978
+ type: ((_c = configureOptions.fieldType) == null ? void 0 : _c.type) || "string",
979
+ ...configureOptions.fieldType || {},
980
+ enum: Array.from(new Set(supportedFieldTypes))
975
981
  };
982
+ const innerField = ((_d = node == null ? void 0 : node.subModels) == null ? void 0 : _d.field) || node;
983
+ const relationFieldTypes = Array.from(new Set(supportedFieldTypes));
984
+ const defaultTitleField = this.getAssociationDefaultTitleFieldName(
985
+ fieldSource.field,
986
+ (_e = fieldSource.fieldSettingsInit) == null ? void 0 : _e.dataSourceKey
987
+ );
976
988
  return {
977
989
  ...projected,
978
- configureOptions
990
+ configureOptions,
991
+ relation: {
992
+ ...projected.relation,
993
+ fieldTypes: relationFieldTypes,
994
+ current: (0, import_service_utils.buildDefinedPayload)({
995
+ 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),
998
+ 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
+ }),
1000
+ defaults: (0, import_service_utils.buildDefinedPayload)({
1001
+ titleField: defaultTitleField
1002
+ }),
1003
+ candidates: this.buildRelationFieldTypeCandidates(relationFieldTypes, defaultTitleField),
1004
+ configureOptions
1005
+ }
979
1006
  };
980
1007
  } catch {
981
1008
  return projected;
982
1009
  }
983
1010
  }
1011
+ buildRelationFieldTypeCandidates(fieldTypes, defaultTitleField) {
1012
+ return fieldTypes.map((fieldType) => {
1013
+ const defaults = {
1014
+ titleField: defaultTitleField
1015
+ };
1016
+ if (["subForm", "subFormList", "subDetails", "subDetailsList", "subTable", "popupSubTable"].includes(fieldType) && defaultTitleField) {
1017
+ defaults.fields = [defaultTitleField];
1018
+ }
1019
+ if (fieldType === "picker" && defaultTitleField) {
1020
+ defaults.selectorFields = [defaultTitleField];
1021
+ }
1022
+ return {
1023
+ fieldType,
1024
+ defaults: (0, import_service_utils.buildDefinedPayload)(defaults)
1025
+ };
1026
+ });
1027
+ }
1028
+ collectRelationNestedFieldPaths(fieldNode) {
1029
+ var _a, _b, _c, _d, _e, _f, _g;
1030
+ 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();
1031
+ 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) => {
1033
+ var _a2, _b2, _c2;
1034
+ 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);
1036
+ }
1037
+ 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) => {
1039
+ var _a2, _b2, _c2;
1040
+ 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);
1042
+ }
1043
+ if (["SubFormFieldModel", "SubFormListFieldModel", "DisplaySubItemFieldModel", "DisplaySubListFieldModel"].includes(
1044
+ fieldUse
1045
+ )) {
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) => {
1047
+ var _a2, _b2, _c2;
1048
+ 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);
1050
+ }
1051
+ return void 0;
1052
+ }
1053
+ collectRelationSelectorFieldPaths(fieldNode) {
1054
+ var _a, _b, _c, _d, _e, _f;
1055
+ 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();
1056
+ if (fieldUse !== "RecordPickerFieldModel") {
1057
+ return void 0;
1058
+ }
1059
+ 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"
1061
+ );
1062
+ return import_lodash.default.castArray(((_f = table == null ? void 0 : table.subModels) == null ? void 0 : _f.columns) || []).map((item) => {
1063
+ var _a2, _b2, _c2;
1064
+ 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;
1065
+ }).filter(Boolean);
1066
+ }
984
1067
  projectCatalogItem(item, expand) {
985
1068
  return (0, import_catalog_smart.projectCatalogItem)(item, expand, {
986
1069
  getEditableDomains: this.getEditableDomains.bind(this),
@@ -3814,6 +3897,9 @@ class FlowSurfacesService {
3814
3897
  if ((current == null ? void 0 : current.use) === "CalendarBlockModel") {
3815
3898
  return this.configureCalendarBlock(target, current, values.changes, options);
3816
3899
  }
3900
+ if ((current == null ? void 0 : current.use) === "TreeBlockModel") {
3901
+ return this.configureTreeBlock(target, current, values.changes, options);
3902
+ }
3817
3903
  if ((current == null ? void 0 : current.use) === "KanbanBlockModel") {
3818
3904
  return this.configureKanbanBlock(target, current, values.changes, options);
3819
3905
  }
@@ -3872,7 +3958,10 @@ class FlowSurfacesService {
3872
3958
  return this.configureFieldNode(target, values.changes, options);
3873
3959
  }
3874
3960
  if (import_node_use_sets.ACTION_BUTTON_USES.has((current == null ? void 0 : current.use) || "")) {
3875
- return this.configureActionNode(target, current.use, values.changes, options);
3961
+ return this.configureActionNode(target, current.use, values.changes, {
3962
+ ...options,
3963
+ current
3964
+ });
3876
3965
  }
3877
3966
  (0, import_errors.throwBadRequest)(`flowSurfaces configure does not support configureOptions on '${(current == null ? void 0 : current.use) || resolved.uid}'`);
3878
3967
  }
@@ -4808,7 +4897,7 @@ class FlowSurfacesService {
4808
4897
  };
4809
4898
  }
4810
4899
  async addBlock(values, options = {}) {
4811
- var _a, _b, _c, _d, _e;
4900
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
4812
4901
  const templateRef = import_lodash.default.isUndefined(values == null ? void 0 : values.template) ? void 0 : this.normalizeFlowTemplateReference("addBlock", values.template, {
4813
4902
  allowUsage: true,
4814
4903
  expectedType: "block"
@@ -4838,6 +4927,7 @@ class FlowSurfacesService {
4838
4927
  (0, import_errors.throwBadRequest)("flowSurfaces addBlock does not allow resource and resourceInit at the same time");
4839
4928
  }
4840
4929
  const enabledPackages = await this.resolveEnabledPluginPackages(options);
4930
+ const hasInlineFields = Object.prototype.hasOwnProperty.call(values || {}, "fields") || Object.prototype.hasOwnProperty.call(values || {}, "fieldsLayout");
4841
4931
  let resolvedTarget = await this.locator.resolve(target, options);
4842
4932
  let targetNode = await this.loadResolvedNode(resolvedTarget, options.transaction);
4843
4933
  const targetOpenView = this.resolvePopupHostOpenView(targetNode);
@@ -4872,6 +4962,16 @@ class FlowSurfacesService {
4872
4962
  requireCreateSupported: true
4873
4963
  }
4874
4964
  );
4965
+ const inlineFields = hasInlineFields ? this.normalizeComposeBlock(
4966
+ {
4967
+ key: String((values == null ? void 0 : values.key) || catalogItem.key || (values == null ? void 0 : values.type) || (values == null ? void 0 : values.use) || "addBlock_inline").trim() || "addBlock_inline",
4968
+ type: catalogItem.key || values.type,
4969
+ fields: values.fields,
4970
+ fieldsLayout: values.fieldsLayout
4971
+ },
4972
+ 0,
4973
+ enabledPackages
4974
+ ) : null;
4875
4975
  const resolvedResourceInit = await this.resolvePopupCollectionBlockResourceInit({
4876
4976
  actionName: "addBlock",
4877
4977
  blockUse: catalogItem.use,
@@ -4945,6 +5045,73 @@ class FlowSurfacesService {
4945
5045
  } : {}
4946
5046
  };
4947
5047
  await this.applyInlineNodeSettings("addBlock", created, inlineSettings, options);
5048
+ if ((_f = inlineFields == null ? void 0 : inlineFields.fields) == null ? void 0 : _f.length) {
5049
+ const fieldTargetUid = this.resolveComposeFieldContainerUid(inlineFields, result);
5050
+ const createdByKey = {};
5051
+ for (const fieldSpec of inlineFields.fields) {
5052
+ const createdField = await this.addField(
5053
+ {
5054
+ target: {
5055
+ uid: fieldTargetUid
5056
+ },
5057
+ ...fieldSpec.key ? { key: fieldSpec.key } : {},
5058
+ ...fieldSpec.fieldPath ? { fieldPath: fieldSpec.fieldPath } : {},
5059
+ ...fieldSpec.associationPathName ? { associationPathName: fieldSpec.associationPathName } : {},
5060
+ ...fieldSpec.renderer ? { renderer: fieldSpec.renderer } : {},
5061
+ ...fieldSpec.type ? { type: fieldSpec.type } : {},
5062
+ ...fieldSpec.fieldType ? { fieldType: fieldSpec.fieldType } : {},
5063
+ ...!import_lodash.default.isUndefined(fieldSpec.fields) ? { fields: fieldSpec.fields } : {},
5064
+ ...!import_lodash.default.isUndefined(fieldSpec.selectorFields) ? { selectorFields: fieldSpec.selectorFields } : {},
5065
+ ...fieldSpec.titleField ? { titleField: fieldSpec.titleField } : {},
5066
+ ...fieldSpec.openMode ? { openMode: fieldSpec.openMode } : {},
5067
+ ...fieldSpec.popupSize ? { popupSize: fieldSpec.popupSize } : {},
5068
+ ...!import_lodash.default.isUndefined(fieldSpec.pageSize) ? { pageSize: fieldSpec.pageSize } : {},
5069
+ ...!import_lodash.default.isUndefined(fieldSpec.showIndex) ? { showIndex: fieldSpec.showIndex } : {},
5070
+ ...fieldSpec.popup ? { popup: fieldSpec.popup } : {},
5071
+ ...fieldSpec.__autoPopupForRelationField ? { __autoPopupForRelationField: true } : {},
5072
+ ...fieldSpec[import_defaults.FLOW_SURFACE_APPLY_BLUEPRINT_POPUP_DEFAULTS_KEY] ? {
5073
+ [import_defaults.FLOW_SURFACE_APPLY_BLUEPRINT_POPUP_DEFAULTS_KEY]: fieldSpec[import_defaults.FLOW_SURFACE_APPLY_BLUEPRINT_POPUP_DEFAULTS_KEY]
5074
+ } : {}
5075
+ },
5076
+ {
5077
+ transaction: options.transaction,
5078
+ enabledPackages
5079
+ }
5080
+ );
5081
+ if (fieldSpec.settings && Object.keys(fieldSpec.settings).length) {
5082
+ await this.applyInlineFieldSettings("addBlock field", createdField, fieldSpec.settings, {
5083
+ transaction: options.transaction
5084
+ });
5085
+ }
5086
+ const layoutUid = createdField.wrapperUid || createdField.uid;
5087
+ if (layoutUid && fieldSpec.key) {
5088
+ createdByKey[fieldSpec.key] = { uid: layoutUid };
5089
+ }
5090
+ }
5091
+ if (inlineFields.fieldsLayout && Object.keys(createdByKey).length) {
5092
+ const layoutHost = await this.repository.findModelById(created, {
5093
+ transaction: options.transaction,
5094
+ includeAsyncNode: true
5095
+ });
5096
+ const layoutItems = import_lodash.default.castArray(
5097
+ ((_i = (_h = (_g = layoutHost == null ? void 0 : layoutHost.subModels) == null ? void 0 : _g.grid) == null ? void 0 : _h.subModels) == null ? void 0 : _i.items) || ((_j = layoutHost == null ? void 0 : layoutHost.subModels) == null ? void 0 : _j.items) || []
5098
+ );
5099
+ const layoutPayload = this.buildComposeLayoutPayload({
5100
+ layout: inlineFields.fieldsLayout,
5101
+ createdByKey,
5102
+ finalItems: layoutItems
5103
+ });
5104
+ await this.setLayout(
5105
+ {
5106
+ target: {
5107
+ uid: created
5108
+ },
5109
+ ...layoutPayload
5110
+ },
5111
+ options
5112
+ );
5113
+ }
5114
+ }
4948
5115
  if (!options.skipDefaultBlockActions) {
4949
5116
  await this.applyDefaultActionsForCreatedBlock(
4950
5117
  {
@@ -4991,6 +5158,8 @@ class FlowSurfacesService {
4991
5158
  return result2;
4992
5159
  }
4993
5160
  const target = await this.prepareWriteTarget("addField", values == null ? void 0 : values.target, values, options);
5161
+ (0, import_field_type_resolver.assertNoInternalFieldKeys)(values, "flowSurfaces addField");
5162
+ (0, import_field_type_resolver.assertNoInternalFieldKeys)(values == null ? void 0 : values.settings, "flowSurfaces addField.settings");
4994
5163
  (0, import_service_utils.ensureNoRawDirectAddKeys)("addField", values, [
4995
5164
  "wrapperProps",
4996
5165
  "fieldProps",
@@ -5007,6 +5176,8 @@ class FlowSurfacesService {
5007
5176
  const enabledPackages = await this.resolveEnabledPluginPackages(options);
5008
5177
  const isFilterFormItem = container.wrapperUse === "FilterFormItemModel";
5009
5178
  const isApprovalFormTarget = (0, import_approval.isApprovalFormContainerUse)(container.ownerUse);
5179
+ const requestedLegacyFieldUse = (0, import_service_utils.resolveRequestedFieldUseAlias)(values);
5180
+ let requestedFieldUse = (0, import_service_utils.resolveRequestedFieldUse)(values);
5010
5181
  const requestedStandaloneType = typeof values.type === "string" && values.type.trim().length ? values.type.trim() : void 0;
5011
5182
  const fieldCapability = (0, import_catalog.resolveSupportedFieldCapability)({
5012
5183
  containerUse: container.ownerUse,
@@ -5017,6 +5188,9 @@ class FlowSurfacesService {
5017
5188
  enabledPackages
5018
5189
  });
5019
5190
  if (fieldCapability.standaloneUse) {
5191
+ if ((0, import_service_utils.hasOwnDefined)(values, "fieldType")) {
5192
+ (0, import_errors.throwBadRequest)("flowSurfaces fieldType is only supported for relation fields");
5193
+ }
5020
5194
  if (inlinePopup) {
5021
5195
  (0, import_errors.throwBadRequest)(`flowSurfaces addField type '${values.type}' does not support popup`);
5022
5196
  }
@@ -5122,6 +5296,32 @@ class FlowSurfacesService {
5122
5296
  associationPathName: resolvedField.associationPathName,
5123
5297
  field: resolvedField.field
5124
5298
  });
5299
+ const relationFieldTypeResolution = (0, import_field_type_resolver.resolveRelationFieldType)({
5300
+ fieldType: values.fieldType,
5301
+ containerUse: container.ownerUse,
5302
+ field: resolvedField.field,
5303
+ dataSourceKey: resolvedField.dataSourceKey,
5304
+ getCollection: (dataSourceKey, collectionName) => this.getCollection(dataSourceKey, collectionName),
5305
+ fields: values.fields,
5306
+ selectorFields: values.selectorFields,
5307
+ titleField: values.titleField,
5308
+ openMode: values.openMode,
5309
+ popupSize: values.popupSize,
5310
+ pageSize: values.pageSize,
5311
+ showIndex: values.showIndex,
5312
+ context: "addField"
5313
+ });
5314
+ if (relationFieldTypeResolution) {
5315
+ if (values.renderer) {
5316
+ (0, import_errors.throwBadRequest)(`flowSurfaces addField fieldType cannot be combined with renderer`);
5317
+ }
5318
+ if (requestedLegacyFieldUse && requestedLegacyFieldUse !== relationFieldTypeResolution.fieldUse) {
5319
+ (0, import_errors.throwBadRequest)(
5320
+ `flowSurfaces fieldUse '${requestedLegacyFieldUse}' does not match fieldType '${relationFieldTypeResolution.fieldType}'`
5321
+ );
5322
+ }
5323
+ requestedFieldUse = relationFieldTypeResolution.fieldUse;
5324
+ }
5125
5325
  const filterFormInit = isFilterFormItem ? {
5126
5326
  filterField: (0, import_service_helpers.buildFilterFieldMeta)(resolvedField.field),
5127
5327
  ...(selectedFilterTarget == null ? void 0 : selectedFilterTarget.ownerUid) ? { defaultTargetUid: selectedFilterTarget.ownerUid } : {}
@@ -5129,25 +5329,29 @@ class FlowSurfacesService {
5129
5329
  let capabilityField = preferredCapabilityField;
5130
5330
  let boundFieldCapability;
5131
5331
  if ((fieldMenuCandidate == null ? void 0 : fieldMenuCandidate.explicitWrapperUse) && (fieldMenuCandidate == null ? void 0 : fieldMenuCandidate.explicitFieldUse) && !values.renderer) {
5132
- if ((0, import_service_utils.hasOwnDefined)(values, "fieldUse") && values.fieldUse !== fieldMenuCandidate.explicitFieldUse) {
5332
+ if (requestedLegacyFieldUse && requestedLegacyFieldUse !== fieldMenuCandidate.explicitFieldUse) {
5133
5333
  (0, import_errors.throwBadRequest)(
5134
- `flowSurfaces fieldUse '${values.fieldUse}' does not match inferred fieldUse '${fieldMenuCandidate.explicitFieldUse}' under '${container.ownerUse}'`
5334
+ `flowSurfaces fieldUse '${requestedLegacyFieldUse}' does not match inferred fieldUse '${fieldMenuCandidate.explicitFieldUse}' under '${container.ownerUse}'`
5135
5335
  );
5136
5336
  }
5137
- boundFieldCapability = {
5138
- wrapperUse: fieldMenuCandidate.explicitWrapperUse,
5139
- fieldUse: fieldMenuCandidate.explicitFieldUse,
5140
- inferredFieldUse: fieldMenuCandidate.explicitFieldUse,
5141
- standaloneUse: void 0,
5142
- renderer: void 0
5143
- };
5144
- capabilityField = resolvedField.field;
5145
- } else {
5337
+ if (!relationFieldTypeResolution) {
5338
+ boundFieldCapability = {
5339
+ wrapperUse: fieldMenuCandidate.explicitWrapperUse,
5340
+ fieldUse: fieldMenuCandidate.explicitFieldUse,
5341
+ inferredFieldUse: fieldMenuCandidate.explicitFieldUse,
5342
+ standaloneUse: void 0,
5343
+ renderer: void 0
5344
+ };
5345
+ capabilityField = resolvedField.field;
5346
+ }
5347
+ }
5348
+ if (!boundFieldCapability) {
5146
5349
  try {
5147
5350
  boundFieldCapability = (0, import_catalog.resolveSupportedFieldCapability)({
5148
5351
  containerUse: container.ownerUse,
5149
5352
  field: capabilityField,
5150
- requestedFieldUse: values.fieldUse,
5353
+ requestedFieldUse,
5354
+ requestedFieldUseMode: relationFieldTypeResolution ? "fieldType" : "fieldUse",
5151
5355
  requestedWrapperUse: container.wrapperUse,
5152
5356
  requestedRenderer: values.renderer,
5153
5357
  enabledPackages,
@@ -5155,12 +5359,13 @@ class FlowSurfacesService {
5155
5359
  getCollection: (dataSourceKey, collectionName) => this.getCollection(dataSourceKey, collectionName)
5156
5360
  });
5157
5361
  } catch (error) {
5158
- if ((0, import_service_utils.hasOwnDefined)(values, "fieldUse") && capabilityField !== resolvedField.field && error instanceof import_errors.FlowSurfaceBadRequestError) {
5362
+ if (requestedFieldUse && capabilityField !== resolvedField.field && error instanceof import_errors.FlowSurfaceBadRequestError) {
5159
5363
  capabilityField = resolvedField.field;
5160
5364
  boundFieldCapability = (0, import_catalog.resolveSupportedFieldCapability)({
5161
5365
  containerUse: container.ownerUse,
5162
5366
  field: capabilityField,
5163
- requestedFieldUse: values.fieldUse,
5367
+ requestedFieldUse,
5368
+ requestedFieldUseMode: relationFieldTypeResolution ? "fieldType" : "fieldUse",
5164
5369
  requestedWrapperUse: container.wrapperUse,
5165
5370
  requestedRenderer: values.renderer,
5166
5371
  enabledPackages,
@@ -5194,9 +5399,17 @@ class FlowSurfacesService {
5194
5399
  boundFieldCapability.fieldUse,
5195
5400
  capabilityField
5196
5401
  );
5197
- const defaultTitleField = titleFieldSyncDecision.titleField ?? normalizedFieldBinding.defaultTitleField ?? (fieldMenuCandidate == null ? void 0 : fieldMenuCandidate.defaultTitleField);
5402
+ const defaultTitleField = (relationFieldTypeResolution == null ? void 0 : relationFieldTypeResolution.titleField) ?? titleFieldSyncDecision.titleField ?? normalizedFieldBinding.defaultTitleField ?? (fieldMenuCandidate == null ? void 0 : fieldMenuCandidate.defaultTitleField);
5198
5403
  const wrapperShouldPersistTitleField = !import_lodash.default.isUndefined(defaultTitleField) && TITLE_FIELD_SUPPORTED_WRAPPER_USES.has(boundFieldCapability.wrapperUse || "");
5199
- const fieldShouldPersistTitleField = !import_lodash.default.isUndefined(defaultTitleField);
5404
+ const fieldShouldPersistTitleField = !import_lodash.default.isUndefined(defaultTitleField) && this.supportsFieldTitleFieldProp(boundFieldCapability.fieldUse);
5405
+ const normalizedDefaultFieldProps = this.normalizeFieldPropsForUse(
5406
+ boundFieldCapability.fieldUse,
5407
+ defaultFieldState.fieldProps || {}
5408
+ );
5409
+ const normalizedInlineFieldProps = this.normalizeFieldPropsForUse(
5410
+ boundFieldCapability.fieldUse,
5411
+ values.fieldProps || {}
5412
+ );
5200
5413
  const tree = (0, import_builder.buildFieldTree)({
5201
5414
  wrapperUse: boundFieldCapability.wrapperUse,
5202
5415
  fieldUse: boundFieldCapability.fieldUse,
@@ -5213,9 +5426,9 @@ class FlowSurfacesService {
5213
5426
  ),
5214
5427
  fieldProps: import_lodash.default.merge(
5215
5428
  {},
5216
- defaultFieldState.fieldProps || {},
5429
+ normalizedDefaultFieldProps,
5217
5430
  fieldShouldPersistTitleField ? { titleField: defaultTitleField } : {},
5218
- values.fieldProps || {}
5431
+ normalizedInlineFieldProps
5219
5432
  )
5220
5433
  });
5221
5434
  this.contractGuard.validateNodeTreeAgainstContract(tree.model);
@@ -5254,6 +5467,21 @@ class FlowSurfacesService {
5254
5467
  associationPathName: normalizedFieldBinding.associationPathName,
5255
5468
  fieldPath: normalizedFieldBinding.fieldPath
5256
5469
  };
5470
+ if (relationFieldTypeResolution) {
5471
+ await this.applyResolvedRelationFieldType({
5472
+ fieldUid: tree.innerUid,
5473
+ fieldUse: boundFieldCapability.fieldUse,
5474
+ targetCollection: relationFieldTypeResolution.targetCollection,
5475
+ fields: relationFieldTypeResolution.fields,
5476
+ selectorFields: relationFieldTypeResolution.selectorFields,
5477
+ titleField: relationFieldTypeResolution.titleField,
5478
+ openMode: relationFieldTypeResolution.openMode,
5479
+ popupSize: relationFieldTypeResolution.popupSize,
5480
+ pageSize: relationFieldTypeResolution.pageSize,
5481
+ showIndex: relationFieldTypeResolution.showIndex,
5482
+ transaction: options.transaction
5483
+ });
5484
+ }
5257
5485
  await this.applyInlineFieldSettings("addField", result, inlineSettings, options);
5258
5486
  await this.applyInlineFieldPopup("addField", result, inlinePopup, {
5259
5487
  ...options,
@@ -9374,6 +9602,7 @@ class FlowSurfacesService {
9374
9602
  );
9375
9603
  const hasFields = Object.prototype.hasOwnProperty.call(input, "fields");
9376
9604
  const hasFieldGroups = Object.prototype.hasOwnProperty.call(input, "fieldGroups");
9605
+ const hasActions = Object.prototype.hasOwnProperty.call(input, "actions");
9377
9606
  const hasRecordActions = Object.prototype.hasOwnProperty.call(input, "recordActions");
9378
9607
  if (type === "calendar") {
9379
9608
  if (hasFields) {
@@ -9409,6 +9638,23 @@ class FlowSurfacesService {
9409
9638
  );
9410
9639
  }
9411
9640
  }
9641
+ if (type === "tree") {
9642
+ if (hasFields) {
9643
+ (0, import_errors.throwBadRequest)(`flowSurfaces compose block #${index + 1} tree does not support fields[]`);
9644
+ }
9645
+ if (hasFieldGroups) {
9646
+ (0, import_errors.throwBadRequest)(`flowSurfaces compose block #${index + 1} tree does not support fieldGroups[]`);
9647
+ }
9648
+ if (hasActions) {
9649
+ (0, import_errors.throwBadRequest)(`flowSurfaces compose block #${index + 1} tree does not support actions[]`);
9650
+ }
9651
+ if (hasRecordActions) {
9652
+ (0, import_errors.throwBadRequest)(`flowSurfaces compose block #${index + 1} tree does not support recordActions[]`);
9653
+ }
9654
+ if (Object.prototype.hasOwnProperty.call(input, "fieldsLayout")) {
9655
+ (0, import_errors.throwBadRequest)(`flowSurfaces compose block #${index + 1} tree does not support fieldsLayout`);
9656
+ }
9657
+ }
9412
9658
  if (hasFields && hasFieldGroups) {
9413
9659
  (0, import_errors.throwBadRequest)(`flowSurfaces compose block #${index + 1} cannot mix fields with fieldGroups`);
9414
9660
  }
@@ -9950,6 +10196,61 @@ class FlowSurfacesService {
9950
10196
  await this.ensureCalendarBlockPopupHosts(reloaded, options.transaction);
9951
10197
  return result;
9952
10198
  }
10199
+ async configureTreeBlock(target, current, changes, options) {
10200
+ var _a, _b;
10201
+ const allowedKeys = (0, import_configure_options.getConfigureOptionKeysForUse)("TreeBlockModel");
10202
+ const cardSettings = (0, import_service_utils.buildBlockTitleDescriptionFromSemanticChanges)(changes);
10203
+ (0, import_service_utils.assertSupportedSimpleChanges)("tree", changes, allowedKeys);
10204
+ 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
+ if ((0, import_service_utils.hasOwnDefined)(changes, "titleField")) {
10206
+ nextFieldNames.title = String(changes.titleField || "").trim();
10207
+ }
10208
+ const hasFieldNamesPatch = (0, import_service_utils.hasOwnDefined)(changes, "titleField") || import_lodash.default.isPlainObject(changes.fieldNames);
10209
+ return this.updateSettings(
10210
+ {
10211
+ target,
10212
+ props: (0, import_service_utils.buildDefinedPayload)({
10213
+ ...(0, import_service_utils.hasOwnDefined)(changes, "searchable") ? { searchable: changes.searchable !== false } : {},
10214
+ ...(0, import_service_utils.hasOwnDefined)(changes, "defaultExpandAll") ? { defaultExpandAll: changes.defaultExpandAll === true } : {},
10215
+ ...(0, import_service_utils.hasOwnDefined)(changes, "includeDescendants") ? { includeDescendants: changes.includeDescendants !== false } : {},
10216
+ ...hasFieldNamesPatch ? { fieldNames: nextFieldNames } : {},
10217
+ ...(0, import_service_utils.hasOwnDefined)(changes, "pageSize") ? { pageSize: changes.pageSize } : {}
10218
+ }),
10219
+ decoratorProps: (0, import_service_utils.buildDefinedPayload)({
10220
+ height: changes.height,
10221
+ heightMode: (0, import_service_utils.normalizePublicBlockHeightMode)(changes.heightMode)
10222
+ }),
10223
+ stepParams: {
10224
+ ...cardSettings ? { cardSettings } : {},
10225
+ ...changes.resource ? {
10226
+ resourceSettings: {
10227
+ init: (0, import_service_utils.normalizeSimpleResourceInit)(changes.resource)
10228
+ }
10229
+ } : {},
10230
+ ...(0, import_service_utils.hasDefinedValue)(changes, [
10231
+ "searchable",
10232
+ "defaultExpandAll",
10233
+ "includeDescendants",
10234
+ "titleField",
10235
+ "pageSize",
10236
+ "dataScope",
10237
+ "sorting"
10238
+ ]) ? {
10239
+ treeSettings: (0, import_service_utils.buildDefinedPayload)({
10240
+ ...(0, import_service_utils.hasOwnDefined)(changes, "searchable") ? { searchable: { searchable: changes.searchable !== false } } : {},
10241
+ ...(0, import_service_utils.hasOwnDefined)(changes, "defaultExpandAll") ? { defaultExpandAll: { defaultExpandAll: changes.defaultExpandAll === true } } : {},
10242
+ ...(0, import_service_utils.hasOwnDefined)(changes, "includeDescendants") ? { includeDescendants: { includeDescendants: changes.includeDescendants !== false } } : {},
10243
+ ...(0, import_service_utils.hasOwnDefined)(changes, "titleField") ? { titleField: { titleField: nextFieldNames.title } } : {},
10244
+ ...(0, import_service_utils.hasOwnDefined)(changes, "pageSize") ? { pageSize: { pageSize: changes.pageSize } } : {},
10245
+ ...(0, import_service_utils.hasOwnDefined)(changes, "dataScope") ? { dataScope: { filter: changes.dataScope } } : {},
10246
+ ...(0, import_service_utils.hasOwnDefined)(changes, "sorting") ? { defaultSorting: { sort: changes.sorting } } : {}
10247
+ })
10248
+ } : {}
10249
+ }
10250
+ },
10251
+ options
10252
+ );
10253
+ }
9953
10254
  async configureKanbanBlock(target, current, changes, options) {
9954
10255
  var _a;
9955
10256
  const allowedKeys = (0, import_configure_options.getConfigureOptionKeysForUse)("KanbanBlockModel");
@@ -10818,10 +11119,22 @@ class FlowSurfacesService {
10818
11119
  );
10819
11120
  }
10820
11121
  async configureFieldWrapper(target, current, changes, options) {
10821
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
11122
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
10822
11123
  const enabledPackages = await this.resolveEnabledPluginPackages(options);
10823
11124
  (0, import_service_utils.assertSupportedSimpleChanges)("field wrapper", changes, (0, import_configure_options.getConfigureOptionKeysForUse)(current == null ? void 0 : current.use));
10824
- const rawWrapperChanges = import_lodash.default.omit(changes, ["clickToOpen", "openView", "code", "version", "fieldComponent"]);
11125
+ const rawWrapperChanges = import_lodash.default.omit(changes, [
11126
+ "clickToOpen",
11127
+ "openView",
11128
+ "code",
11129
+ "version",
11130
+ "fieldType",
11131
+ "fields",
11132
+ "selectorFields",
11133
+ "openMode",
11134
+ "popupSize",
11135
+ "pageSize",
11136
+ "showIndex"
11137
+ ]);
10825
11138
  const wrapperChanges = (current == null ? void 0 : current.use) === "TableColumnModel" && !(0, import_service_utils.hasOwnDefined)(rawWrapperChanges, "title") && (0, import_service_utils.hasOwnDefined)(rawWrapperChanges, "label") ? {
10826
11139
  ...rawWrapperChanges,
10827
11140
  title: rawWrapperChanges.label
@@ -10855,6 +11168,8 @@ class FlowSurfacesService {
10855
11168
  });
10856
11169
  const shouldSyncTitleField = titleFieldSyncDecision.shouldSync;
10857
11170
  const syncedTitleField = titleFieldSyncDecision.titleField;
11171
+ const shouldPatchTableColumnTitle = (current == null ? void 0 : current.use) === "TableColumnModel" && (0, import_service_utils.hasOwnDefined)(wrapperChanges, "title");
11172
+ const shouldPatchFieldSettings = (0, import_service_utils.hasDefinedValue)(wrapperChanges, ["fieldPath", "associationPathName"]) || shouldPatchTableColumnTitle;
10858
11173
  if (Object.keys(wrapperChanges).length) {
10859
11174
  await this.updateSettings(
10860
11175
  {
@@ -10889,8 +11204,8 @@ class FlowSurfacesService {
10889
11204
  labelWidth: wrapperChanges.labelWidth,
10890
11205
  labelWrap: wrapperChanges.labelWrap
10891
11206
  }),
10892
- stepParams: (0, import_service_utils.hasDefinedValue)(wrapperChanges, ["fieldPath", "associationPathName"]) || (current == null ? void 0 : current.use) === "TableColumnModel" && (0, import_service_utils.hasOwnDefined)(wrapperChanges, "title") ? (0, import_service_utils.buildDefinedPayload)({
10893
- ...(current == null ? void 0 : current.use) === "TableColumnModel" && (0, import_service_utils.hasOwnDefined)(wrapperChanges, "title") ? {
11207
+ stepParams: shouldPatchFieldSettings ? (0, import_service_utils.buildDefinedPayload)({
11208
+ ...shouldPatchTableColumnTitle ? {
10894
11209
  tableColumnSettings: {
10895
11210
  title: {
10896
11211
  title: wrapperChanges.title
@@ -10926,24 +11241,69 @@ class FlowSurfacesService {
10926
11241
  );
10927
11242
  }
10928
11243
  }
10929
- if ((0, import_service_utils.hasOwnDefined)(changes, "fieldComponent")) {
11244
+ let effectiveInnerFieldUse = innerField == null ? void 0 : innerField.use;
11245
+ let fieldTypeResolution;
11246
+ 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")) {
10930
11248
  if (!innerUid) {
10931
11249
  (0, import_errors.throwConflict)(
10932
11250
  `flowSurfaces configure field wrapper '${current == null ? void 0 : current.use}' cannot resolve inner field`,
10933
11251
  "FLOW_SURFACE_INNER_FIELD_MISSING"
10934
11252
  );
10935
11253
  }
11254
+ const fieldSource = this.resolveFieldComponentFieldSource(current, normalizedBinding);
11255
+ const currentPublicFieldType = (0, import_field_type_resolver.getPublicFieldTypeForUse)(
11256
+ ((_k = (_j = innerField == null ? void 0 : innerField.stepParams) == null ? void 0 : _j.fieldBinding) == null ? void 0 : _k.use) || (innerField == null ? void 0 : innerField.use)
11257
+ );
11258
+ const shouldApplyResolverDefaults = (0, import_service_utils.hasOwnDefined)(changes, "fieldType") && changes.fieldType !== currentPublicFieldType;
11259
+ fieldTypeResolution = (0, import_field_type_resolver.resolveRelationFieldType)({
11260
+ fieldType: (0, import_service_utils.hasOwnDefined)(changes, "fieldType") ? changes.fieldType : currentPublicFieldType,
11261
+ containerUse: current == null ? void 0 : current.use,
11262
+ field: fieldSource.field,
11263
+ dataSourceKey: (_l = fieldSource.fieldSettingsInit) == null ? void 0 : _l.dataSourceKey,
11264
+ getCollection: (dataSourceKey, collectionName) => this.getCollection(dataSourceKey, collectionName),
11265
+ fields: changes.fields,
11266
+ selectorFields: changes.selectorFields,
11267
+ titleField: (0, import_service_utils.hasOwnDefined)(wrapperChanges, "titleField") ? wrapperChanges.titleField : void 0,
11268
+ openMode: (0, import_service_utils.hasOwnDefined)(changes, "openMode") ? changes.openMode : void 0,
11269
+ popupSize: (0, import_service_utils.hasOwnDefined)(changes, "popupSize") ? changes.popupSize : void 0,
11270
+ pageSize: (0, import_service_utils.hasOwnDefined)(changes, "pageSize") ? changes.pageSize : void 0,
11271
+ showIndex: (0, import_service_utils.hasOwnDefined)(changes, "showIndex") ? changes.showIndex : void 0,
11272
+ applyDefaults: shouldApplyResolverDefaults,
11273
+ context: "configure"
11274
+ });
11275
+ if (!fieldTypeResolution) {
11276
+ (0, import_errors.throwBadRequest)("flowSurfaces configure fieldType is required when configuring relation fields");
11277
+ }
11278
+ const shouldApplyFieldTypeDefaults = shouldApplyResolverDefaults;
11279
+ const shouldApplyRelationTitleField = (0, import_service_utils.hasOwnDefined)(wrapperChanges, "titleField") || shouldApplyFieldTypeDefaults;
11280
+ relationTitleFieldToApply = shouldApplyRelationTitleField ? fieldTypeResolution.titleField : void 0;
10936
11281
  const normalizedFieldComponentUse = await this.rebuildFieldSubModelOnServer({
10937
11282
  wrapperNode: current,
10938
11283
  innerField,
10939
- targetFieldUse: changes.fieldComponent,
11284
+ targetFieldUse: fieldTypeResolution.fieldUse,
10940
11285
  normalizedBinding,
10941
11286
  enabledPackages,
10942
11287
  transaction: options.transaction
10943
11288
  });
10944
- await this.syncFieldComponentStepParams(current, normalizedFieldComponentUse, options.transaction);
11289
+ effectiveInnerFieldUse = normalizedFieldComponentUse;
11290
+ await this.syncFieldTypeStepParams(current, normalizedFieldComponentUse, options.transaction);
11291
+ await this.applyResolvedRelationFieldType({
11292
+ fieldUid: innerUid,
11293
+ fieldUse: normalizedFieldComponentUse,
11294
+ targetCollection: fieldTypeResolution.targetCollection,
11295
+ 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,
11297
+ titleField: relationTitleFieldToApply,
11298
+ openMode: fieldTypeResolution.openMode,
11299
+ popupSize: fieldTypeResolution.popupSize,
11300
+ pageSize: fieldTypeResolution.pageSize,
11301
+ showIndex: fieldTypeResolution.showIndex,
11302
+ transaction: options.transaction
11303
+ });
10945
11304
  }
10946
- if (shouldSyncTitleField) {
11305
+ const effectiveSyncedTitleField = relationTitleFieldToApply ?? syncedTitleField;
11306
+ if ((shouldSyncTitleField || !import_lodash.default.isUndefined(relationTitleFieldToApply)) && this.supportsFieldTitleFieldProp(effectiveInnerFieldUse)) {
10947
11307
  if (!innerUid) {
10948
11308
  (0, import_errors.throwConflict)(
10949
11309
  `flowSurfaces configure field wrapper '${current == null ? void 0 : current.use}' cannot resolve inner field`,
@@ -10956,7 +11316,7 @@ class FlowSurfacesService {
10956
11316
  uid: innerUid
10957
11317
  },
10958
11318
  props: {
10959
- titleField: syncedTitleField
11319
+ titleField: effectiveSyncedTitleField
10960
11320
  }
10961
11321
  },
10962
11322
  options
@@ -11024,6 +11384,7 @@ class FlowSurfacesService {
11024
11384
  });
11025
11385
  const shouldSyncTitleField = titleFieldSyncDecision.shouldSync;
11026
11386
  const syncedTitleField = titleFieldSyncDecision.titleField;
11387
+ const canSyncInnerTitleField = this.supportsFieldTitleFieldProp(current == null ? void 0 : current.use);
11027
11388
  if ((parentWrapper == null ? void 0 : parentWrapper.uid) && canSyncWrapperTitleField && shouldSyncTitleField) {
11028
11389
  await this.updateSettings(
11029
11390
  {
@@ -11086,7 +11447,7 @@ class FlowSurfacesService {
11086
11447
  quickCreate: changes.quickCreate,
11087
11448
  displayStyle: changes.displayStyle,
11088
11449
  options: changes.options,
11089
- ...shouldSyncTitleField ? { titleField: syncedTitleField } : {},
11450
+ ...shouldSyncTitleField && canSyncInnerTitleField ? { titleField: syncedTitleField } : {},
11090
11451
  ...(0, import_service_utils.hasOwnDefined)(changes, "clickToOpen") || !import_lodash.default.isUndefined(changes.openView) ? { clickToOpen: effectiveClickToOpen } : {}
11091
11452
  }),
11092
11453
  stepParams: (0, import_service_utils.buildDefinedPayload)({
@@ -11153,6 +11514,7 @@ class FlowSurfacesService {
11153
11514
  return import_lodash.default.cloneDeep(value);
11154
11515
  }
11155
11516
  async configureActionNode(target, use, changes, options) {
11517
+ changes = await this.normalizeActionPanelActionChanges(changes, options);
11156
11518
  const allowedKeys = (0, import_configure_options.getConfigureOptionKeysForUse)(use);
11157
11519
  (0, import_service_utils.assertSupportedSimpleChanges)("action", changes, allowedKeys);
11158
11520
  const normalizedDefaultFilter = (0, import_service_utils.hasOwnDefined)(changes, "defaultFilter") ? this.normalizeFilterActionDefaultFilterValue(changes.defaultFilter) : void 0;
@@ -11375,6 +11737,21 @@ class FlowSurfacesService {
11375
11737
  }
11376
11738
  );
11377
11739
  }
11740
+ async normalizeActionPanelActionChanges(changes, options) {
11741
+ var _a;
11742
+ if (!(0, import_service_utils.hasOwnDefined)(changes, "type") || !((_a = options.current) == null ? void 0 : _a.uid)) {
11743
+ return changes;
11744
+ }
11745
+ const parentUid = options.current.parentId || await this.locator.findParentUid(options.current.uid, options.transaction);
11746
+ const parentNode = parentUid ? await this.repository.findModelById(parentUid, {
11747
+ transaction: options.transaction,
11748
+ includeAsyncNode: true
11749
+ }) : null;
11750
+ if ((parentNode == null ? void 0 : parentNode.use) !== "ActionPanelBlockModel") {
11751
+ return changes;
11752
+ }
11753
+ return import_lodash.default.omit(changes, ["type"]);
11754
+ }
11378
11755
  async buildFieldCatalog(target, options = {}) {
11379
11756
  const resolved = await this.locator.resolve(target, { transaction: options.transaction });
11380
11757
  const container = await this.surfaceContext.resolveFieldContainer(resolved.uid, options.transaction).catch(() => null);
@@ -11532,7 +11909,7 @@ class FlowSurfacesService {
11532
11909
  continue;
11533
11910
  }
11534
11911
  const fieldInterface = String((0, import_service_helpers.getFieldInterface)(field) || "").trim();
11535
- if (import_field_semantics.MULTI_VALUE_ASSOCIATION_INTERFACES.has(fieldInterface)) {
11912
+ if (import_association_interfaces.MULTI_VALUE_ASSOCIATION_INTERFACES.has(fieldInterface)) {
11536
11913
  continue;
11537
11914
  }
11538
11915
  const associationFieldName = (0, import_service_helpers.getFieldName)(field);
@@ -13730,6 +14107,19 @@ class FlowSurfacesService {
13730
14107
  );
13731
14108
  return (0, import_service_helpers.resolveFieldFromCollection)(targetCollection, titleFieldName) || input.field;
13732
14109
  }
14110
+ supportsFieldTitleFieldProp(use) {
14111
+ return (0, import_configure_options.getConfigureOptionKeysForUse)(use).includes("titleField");
14112
+ }
14113
+ normalizeFieldPropsForUse(use, props) {
14114
+ const normalizedProps = import_lodash.default.cloneDeep(props || {});
14115
+ if (this.supportsFieldTitleFieldProp(use)) {
14116
+ return normalizedProps;
14117
+ }
14118
+ if (Object.prototype.hasOwnProperty.call(normalizedProps, "titleField")) {
14119
+ delete normalizedProps.titleField;
14120
+ }
14121
+ return normalizedProps;
14122
+ }
13733
14123
  async ensureGridChild(parentUid, use, transaction) {
13734
14124
  const existing = await this.repository.findModelByParentId(parentUid, {
13735
14125
  transaction,
@@ -13909,7 +14299,7 @@ class FlowSurfacesService {
13909
14299
  );
13910
14300
  const associationInterface = (0, import_service_helpers.getFieldInterface)(parsed.associationField);
13911
14301
  const leafField = (0, import_service_helpers.resolveFieldFromCollection)(parsed.leafCollection, parsed.leafFieldPath);
13912
- const shouldBindAssociationValue = DISPLAY_FIELD_WRAPPER_USES.has(input.wrapperUse || "") && !!parsed.associationPathName && parsed.fieldPath !== parsed.associationPathName && import_field_semantics.MULTI_VALUE_ASSOCIATION_INTERFACES.has(associationInterface || "");
14302
+ const shouldBindAssociationValue = DISPLAY_FIELD_WRAPPER_USES.has(input.wrapperUse || "") && !!parsed.associationPathName && parsed.fieldPath !== parsed.associationPathName && import_association_interfaces.MULTI_VALUE_ASSOCIATION_INTERFACES.has(associationInterface || "");
13913
14303
  if (shouldBindAssociationValue) {
13914
14304
  const associationFieldPath = parsed.associationPathName;
13915
14305
  if (!associationFieldPath) {
@@ -13951,6 +14341,357 @@ class FlowSurfacesService {
13951
14341
  usesAssociationValueBinding: false
13952
14342
  };
13953
14343
  }
14344
+ getCollectionFieldOrBadRequest(collection, fieldPath, context) {
14345
+ const field = (0, import_service_helpers.resolveFieldFromCollection)(collection, fieldPath);
14346
+ if (!field) {
14347
+ (0, import_errors.throwBadRequest)(`flowSurfaces ${context} field '${fieldPath}' does not exist on relation target collection`);
14348
+ }
14349
+ return field;
14350
+ }
14351
+ buildRelationTargetFieldInit(collection, fieldPath) {
14352
+ 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
14356
+ });
14357
+ }
14358
+ buildRelationTargetTableColumnNode(input) {
14359
+ const field = this.getCollectionFieldOrBadRequest(input.collection, input.fieldPath, "fieldType.fields");
14360
+ 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
+ const title = (0, import_service_helpers.getFieldTitle)(field);
14362
+ const fieldInit = this.buildRelationTargetFieldInit(input.collection, input.fieldPath);
14363
+ return {
14364
+ uid: (0, import_utils.uid)(),
14365
+ use: input.columnUse,
14366
+ props: (0, import_service_utils.buildDefinedPayload)({
14367
+ title,
14368
+ dataIndex: (0, import_service_helpers.getFieldName)(field)
14369
+ }),
14370
+ stepParams: {
14371
+ fieldSettings: {
14372
+ init: fieldInit
14373
+ },
14374
+ ...input.columnUse === "TableColumnModel" ? {
14375
+ tableColumnSettings: {
14376
+ title: {
14377
+ title
14378
+ }
14379
+ }
14380
+ } : {}
14381
+ },
14382
+ subModels: {
14383
+ field: {
14384
+ uid: (0, import_utils.uid)(),
14385
+ use: fieldUse,
14386
+ props: this.normalizeFieldPropsForUse(
14387
+ fieldUse,
14388
+ (0, import_service_utils.getFieldBindingDefaultProps)("TableColumnModel", fieldUse, field)
14389
+ ),
14390
+ stepParams: {
14391
+ fieldSettings: {
14392
+ init: fieldInit
14393
+ },
14394
+ fieldBinding: {
14395
+ use: fieldUse
14396
+ }
14397
+ }
14398
+ }
14399
+ }
14400
+ };
14401
+ }
14402
+ buildRelationTargetGridItemNode(input) {
14403
+ const field = this.getCollectionFieldOrBadRequest(input.collection, input.fieldPath, "fieldType.fields");
14404
+ 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
+ const title = (0, import_service_helpers.getFieldTitle)(field);
14406
+ const fieldInit = this.buildRelationTargetFieldInit(input.collection, input.fieldPath);
14407
+ return {
14408
+ uid: (0, import_utils.uid)(),
14409
+ use: input.wrapperUse,
14410
+ props: (0, import_service_utils.buildDefinedPayload)({
14411
+ label: title
14412
+ }),
14413
+ stepParams: {
14414
+ fieldSettings: {
14415
+ init: fieldInit
14416
+ }
14417
+ },
14418
+ subModels: {
14419
+ field: {
14420
+ uid: (0, import_utils.uid)(),
14421
+ use: fieldUse,
14422
+ props: this.normalizeFieldPropsForUse(
14423
+ fieldUse,
14424
+ (0, import_service_utils.getFieldBindingDefaultProps)(input.wrapperUse, fieldUse, field)
14425
+ ),
14426
+ stepParams: {
14427
+ fieldSettings: {
14428
+ init: fieldInit
14429
+ },
14430
+ fieldBinding: {
14431
+ use: fieldUse
14432
+ }
14433
+ }
14434
+ }
14435
+ }
14436
+ };
14437
+ }
14438
+ async replaceFieldSubModelArray(input) {
14439
+ var _a, _b;
14440
+ const parentNode = await this.repository.findModelById(input.parentUid, {
14441
+ transaction: input.transaction,
14442
+ includeAsyncNode: true
14443
+ });
14444
+ const keptChildren = [];
14445
+ for (const child of import_lodash.default.castArray(((_a = parentNode == null ? void 0 : parentNode.subModels) == null ? void 0 : _a[input.subKey]) || [])) {
14446
+ if (!(child == null ? void 0 : child.uid)) {
14447
+ continue;
14448
+ }
14449
+ if ((_b = input.keepUses) == null ? void 0 : _b.includes(child.use)) {
14450
+ keptChildren.push(child);
14451
+ continue;
14452
+ }
14453
+ await this.removeNodeTreeWithBindings(child.uid, input.transaction);
14454
+ }
14455
+ for (const child of keptChildren.reverse()) {
14456
+ await this.repository.attach(
14457
+ child.uid,
14458
+ {
14459
+ parentId: input.parentUid,
14460
+ subKey: input.subKey,
14461
+ subType: "array",
14462
+ position: "first"
14463
+ },
14464
+ { transaction: input.transaction }
14465
+ );
14466
+ }
14467
+ for (const child of input.children) {
14468
+ await this.repository.upsertModel(
14469
+ {
14470
+ parentId: input.parentUid,
14471
+ subKey: input.subKey,
14472
+ subType: "array",
14473
+ ...child
14474
+ },
14475
+ { transaction: input.transaction }
14476
+ );
14477
+ }
14478
+ }
14479
+ buildPopupSubTableActionsColumnNode(existing) {
14480
+ var _a, _b;
14481
+ const defaultActionColumn = import_lodash.default.cloneDeep(
14482
+ (_b = (_a = (0, import_builder.getStandaloneFieldDefaults)("PopupSubTableFieldModel").subModels) == null ? void 0 : _a.subTableColumns) == null ? void 0 : _b[0]
14483
+ );
14484
+ return {
14485
+ ...defaultActionColumn || {
14486
+ use: "PopupSubTableActionsColumnModel"
14487
+ },
14488
+ ...existing || {},
14489
+ uid: (existing == null ? void 0 : existing.uid) || (defaultActionColumn == null ? void 0 : defaultActionColumn.uid) || (0, import_utils.uid)()
14490
+ };
14491
+ }
14492
+ async ensureFieldGridSubModel(input) {
14493
+ var _a;
14494
+ const fieldNode = await this.repository.findModelById(input.fieldUid, {
14495
+ transaction: input.transaction,
14496
+ includeAsyncNode: true
14497
+ });
14498
+ const existingGrid = (_a = fieldNode == null ? void 0 : fieldNode.subModels) == null ? void 0 : _a.grid;
14499
+ if (existingGrid == null ? void 0 : existingGrid.uid) {
14500
+ return existingGrid.uid;
14501
+ }
14502
+ const gridUid = (0, import_utils.uid)();
14503
+ await this.repository.upsertModel(
14504
+ {
14505
+ uid: gridUid,
14506
+ parentId: input.fieldUid,
14507
+ subKey: "grid",
14508
+ subType: "object",
14509
+ use: input.gridUse
14510
+ },
14511
+ { transaction: input.transaction }
14512
+ );
14513
+ return gridUid;
14514
+ }
14515
+ async applyResolvedRelationFieldType(input) {
14516
+ var _a;
14517
+ if (input.titleField || !import_lodash.default.isUndefined(input.pageSize) || !import_lodash.default.isUndefined(input.showIndex)) {
14518
+ const fieldNode = await this.repository.findModelById(input.fieldUid, {
14519
+ transaction: input.transaction,
14520
+ includeAsyncNode: true
14521
+ });
14522
+ const props = (0, import_service_utils.buildDefinedPayload)({
14523
+ ...input.titleField && this.supportsFieldTitleFieldProp(input.fieldUse) ? { titleField: input.titleField } : {},
14524
+ pageSize: input.pageSize,
14525
+ showIndex: input.showIndex
14526
+ });
14527
+ if (Object.keys(props).length) {
14528
+ await this.repository.patch(
14529
+ {
14530
+ uid: input.fieldUid,
14531
+ props: {
14532
+ ...(fieldNode == null ? void 0 : fieldNode.props) || {},
14533
+ ...props
14534
+ }
14535
+ },
14536
+ { transaction: input.transaction }
14537
+ );
14538
+ }
14539
+ }
14540
+ const fields = input.fields;
14541
+ if ((0, import_field_type_resolver.usesNestedRelationFields)(input.fieldUse) && fields) {
14542
+ if (["SubTableFieldModel", "DisplaySubTableFieldModel"].includes(input.fieldUse)) {
14543
+ await this.replaceFieldSubModelArray({
14544
+ parentUid: input.fieldUid,
14545
+ subKey: "columns",
14546
+ children: fields.map(
14547
+ (fieldPath) => this.buildRelationTargetTableColumnNode({
14548
+ collection: input.targetCollection,
14549
+ fieldPath,
14550
+ columnUse: input.fieldUse === "SubTableFieldModel" ? "SubTableColumnModel" : "TableColumnModel"
14551
+ })
14552
+ ),
14553
+ transaction: input.transaction
14554
+ });
14555
+ } else if (input.fieldUse === "PopupSubTableFieldModel") {
14556
+ const fieldNode = await this.repository.findModelById(input.fieldUid, {
14557
+ transaction: input.transaction,
14558
+ includeAsyncNode: true
14559
+ });
14560
+ const existingActionsColumn = import_lodash.default.castArray(((_a = fieldNode == null ? void 0 : fieldNode.subModels) == null ? void 0 : _a.subTableColumns) || []).find(
14561
+ (item) => (item == null ? void 0 : item.use) === "PopupSubTableActionsColumnModel"
14562
+ );
14563
+ await this.replaceFieldSubModelArray({
14564
+ parentUid: input.fieldUid,
14565
+ subKey: "subTableColumns",
14566
+ children: [
14567
+ this.buildPopupSubTableActionsColumnNode(existingActionsColumn),
14568
+ ...fields.map(
14569
+ (fieldPath) => this.buildRelationTargetTableColumnNode({
14570
+ collection: input.targetCollection,
14571
+ fieldPath,
14572
+ columnUse: "TableColumnModel"
14573
+ })
14574
+ )
14575
+ ],
14576
+ transaction: input.transaction
14577
+ });
14578
+ } else {
14579
+ const gridUse = ["SubFormFieldModel", "SubFormListFieldModel"].includes(input.fieldUse) ? "FormGridModel" : "DetailsGridModel";
14580
+ const wrapperUse = ["SubFormFieldModel", "SubFormListFieldModel"].includes(input.fieldUse) ? "FormItemModel" : "DetailsItemModel";
14581
+ const gridUid = await this.ensureFieldGridSubModel({
14582
+ fieldUid: input.fieldUid,
14583
+ gridUse,
14584
+ transaction: input.transaction
14585
+ });
14586
+ await this.replaceFieldSubModelArray({
14587
+ parentUid: gridUid,
14588
+ subKey: "items",
14589
+ children: fields.map(
14590
+ (fieldPath) => this.buildRelationTargetGridItemNode({
14591
+ collection: input.targetCollection,
14592
+ fieldPath,
14593
+ wrapperUse
14594
+ })
14595
+ ),
14596
+ transaction: input.transaction
14597
+ });
14598
+ }
14599
+ }
14600
+ if (input.fieldUse === "RecordPickerFieldModel") {
14601
+ await this.applyRecordPickerFieldTypeSettings(input);
14602
+ }
14603
+ }
14604
+ async applyRecordPickerFieldTypeSettings(input) {
14605
+ var _a, _b, _c;
14606
+ const fieldNode = await this.repository.findModelById(input.fieldUid, {
14607
+ transaction: input.transaction,
14608
+ includeAsyncNode: true
14609
+ });
14610
+ const openView = (0, import_service_utils.buildDefinedPayload)({
14611
+ mode: input.openMode,
14612
+ size: input.popupSize,
14613
+ pageModelClass: "ChildPageModel",
14614
+ dataSourceKey: ((_a = input.targetCollection) == null ? void 0 : _a.dataSourceKey) || "main",
14615
+ collectionName: (0, import_service_helpers.getCollectionName)(input.targetCollection)
14616
+ });
14617
+ if (Object.keys(openView).length > 2) {
14618
+ await this.repository.patch(
14619
+ {
14620
+ uid: input.fieldUid,
14621
+ stepParams: import_lodash.default.merge({}, (fieldNode == null ? void 0 : fieldNode.stepParams) || {}, {
14622
+ popupSettings: {
14623
+ openView
14624
+ }
14625
+ })
14626
+ },
14627
+ { transaction: input.transaction }
14628
+ );
14629
+ }
14630
+ if (!input.selectorFields) {
14631
+ return;
14632
+ }
14633
+ let grid = await this.repository.findModelByParentId(input.fieldUid, {
14634
+ transaction: input.transaction,
14635
+ subKey: "grid-block",
14636
+ includeAsyncNode: true
14637
+ });
14638
+ if (!(grid == null ? void 0 : grid.uid)) {
14639
+ const gridUid = (0, import_utils.uid)();
14640
+ await this.repository.upsertModel(
14641
+ {
14642
+ uid: gridUid,
14643
+ parentId: input.fieldUid,
14644
+ subKey: "grid-block",
14645
+ subType: "object",
14646
+ use: "BlockGridModel"
14647
+ },
14648
+ { transaction: input.transaction }
14649
+ );
14650
+ grid = await this.repository.findModelById(gridUid, {
14651
+ transaction: input.transaction,
14652
+ includeAsyncNode: true
14653
+ });
14654
+ }
14655
+ if (!(grid == null ? void 0 : grid.uid)) {
14656
+ return;
14657
+ }
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
+ );
14661
+ 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
+ }
14676
+ }
14677
+ }
14678
+ },
14679
+ { transaction: input.transaction }
14680
+ );
14681
+ }
14682
+ await this.replaceFieldSubModelArray({
14683
+ parentUid: tableUid,
14684
+ subKey: "columns",
14685
+ children: input.selectorFields.map(
14686
+ (fieldPath) => this.buildRelationTargetTableColumnNode({
14687
+ collection: input.targetCollection,
14688
+ fieldPath,
14689
+ columnUse: "TableColumnModel"
14690
+ })
14691
+ ),
14692
+ transaction: input.transaction
14693
+ });
14694
+ }
13954
14695
  buildExactFieldSettingsInitPayload(input) {
13955
14696
  return (0, import_service_utils.buildDefinedPayload)({
13956
14697
  dataSourceKey: input.dataSourceKey,
@@ -14058,7 +14799,7 @@ class FlowSurfacesService {
14058
14799
  const targetFieldUse = input.targetFieldUse;
14059
14800
  const normalizedTargetUse = String(targetFieldUse || "").trim();
14060
14801
  if (!normalizedTargetUse) {
14061
- (0, import_errors.throwBadRequest)("flowSurfaces configure fieldComponent cannot be empty");
14802
+ (0, import_errors.throwBadRequest)("flowSurfaces configure fieldType cannot be empty");
14062
14803
  }
14063
14804
  const normalizedWrapperUse = String(wrapperUse || "").trim();
14064
14805
  const containerUse = normalizedWrapperUse === "FormAssociationItemModel" ? "DetailsItemModel" : normalizedWrapperUse;
@@ -14073,7 +14814,7 @@ class FlowSurfacesService {
14073
14814
  });
14074
14815
  if (!(supportedFieldUses == null ? void 0 : supportedFieldUses.has(normalizedTargetUse))) {
14075
14816
  (0, import_errors.throwBadRequest)(
14076
- `flowSurfaces configure field wrapper '${normalizedWrapperUse}' does not support fieldComponent '${normalizedTargetUse}'`
14817
+ `flowSurfaces configure field wrapper '${normalizedWrapperUse}' does not support fieldType '${normalizedTargetUse}'`
14077
14818
  );
14078
14819
  }
14079
14820
  return normalizedTargetUse;
@@ -14084,7 +14825,7 @@ class FlowSurfacesService {
14084
14825
  });
14085
14826
  if (!(contract == null ? void 0 : contract.fieldUse)) {
14086
14827
  (0, import_errors.throwBadRequest)(
14087
- `flowSurfaces configure field wrapper '${normalizedWrapperUse}' does not support fieldComponent '${normalizedTargetUse}'`
14828
+ `flowSurfaces configure field wrapper '${normalizedWrapperUse}' does not support fieldType '${normalizedTargetUse}'`
14088
14829
  );
14089
14830
  }
14090
14831
  return contract.fieldUse;
@@ -14100,7 +14841,7 @@ class FlowSurfacesService {
14100
14841
  });
14101
14842
  if (!(supportedFieldUses == null ? void 0 : supportedFieldUses.has(normalizedTargetUse))) {
14102
14843
  (0, import_errors.throwBadRequest)(
14103
- `flowSurfaces configure field wrapper '${normalizedWrapperUse}' does not support fieldComponent '${normalizedTargetUse}'`
14844
+ `flowSurfaces configure field wrapper '${normalizedWrapperUse}' does not support fieldType '${normalizedTargetUse}'`
14104
14845
  );
14105
14846
  }
14106
14847
  return normalizedTargetUse;
@@ -14111,19 +14852,22 @@ class FlowSurfacesService {
14111
14852
  });
14112
14853
  if (!(contract == null ? void 0 : contract.fieldUse)) {
14113
14854
  (0, import_errors.throwBadRequest)(
14114
- `flowSurfaces configure field wrapper '${normalizedWrapperUse}' does not support fieldComponent '${normalizedTargetUse}'`
14855
+ `flowSurfaces configure field wrapper '${normalizedWrapperUse}' does not support fieldType '${normalizedTargetUse}'`
14115
14856
  );
14116
14857
  }
14117
14858
  return contract.fieldUse;
14118
14859
  }
14119
- (0, import_errors.throwBadRequest)(`flowSurfaces configure field wrapper '${normalizedWrapperUse}' does not support fieldComponent`);
14860
+ (0, import_errors.throwBadRequest)(`flowSurfaces configure field wrapper '${normalizedWrapperUse}' does not support fieldType`);
14120
14861
  }
14121
- async syncFieldComponentStepParams(wrapperNode, targetFieldUse, transaction) {
14862
+ async syncFieldTypeStepParams(wrapperNode, targetFieldUse, transaction) {
14122
14863
  const flowDomain = this.inferFieldComponentFlowDomain(wrapperNode == null ? void 0 : wrapperNode.use);
14123
14864
  if (!flowDomain || !(wrapperNode == null ? void 0 : wrapperNode.uid)) {
14124
14865
  return;
14125
14866
  }
14126
- const nextStepParams = import_lodash.default.merge({}, wrapperNode.stepParams || {}, {
14867
+ const latestWrapper = await this.repository.findModelById(wrapperNode.uid, {
14868
+ transaction
14869
+ });
14870
+ const nextStepParams = import_lodash.default.merge({}, (latestWrapper == null ? void 0 : latestWrapper.stepParams) || wrapperNode.stepParams || {}, {
14127
14871
  [flowDomain.flowKey]: {
14128
14872
  [flowDomain.stepKey]: {
14129
14873
  use: targetFieldUse
@@ -14139,7 +14883,7 @@ class FlowSurfacesService {
14139
14883
  );
14140
14884
  }
14141
14885
  async rebuildFieldSubModelOnServer(input) {
14142
- var _a, _b, _c, _d, _e;
14886
+ var _a, _b, _c, _d, _e, _f;
14143
14887
  const innerField = input.innerField;
14144
14888
  if (!(innerField == null ? void 0 : innerField.uid)) {
14145
14889
  (0, import_errors.throwConflict)(
@@ -14155,16 +14899,38 @@ class FlowSurfacesService {
14155
14899
  dataSourceKey: (_c = fieldSource.fieldSettingsInit) == null ? void 0 : _c.dataSourceKey,
14156
14900
  enabledPackages: input.enabledPackages
14157
14901
  });
14902
+ if (innerField.use === normalizedTargetUse) {
14903
+ await this.repository.patch(
14904
+ {
14905
+ uid: innerField.uid,
14906
+ stepParams: import_lodash.default.merge({}, innerField.stepParams || {}, {
14907
+ fieldBinding: {
14908
+ use: normalizedTargetUse
14909
+ },
14910
+ fieldSettings: {
14911
+ init: fieldSource.fieldSettingsInit
14912
+ }
14913
+ })
14914
+ },
14915
+ { transaction: input.transaction }
14916
+ );
14917
+ return normalizedTargetUse;
14918
+ }
14158
14919
  const defaultProps = (0, import_service_utils.getFieldBindingDefaultProps)((_d = input.wrapperNode) == null ? void 0 : _d.use, normalizedTargetUse, fieldSource.field);
14920
+ const fieldDefaults = (0, import_builder.getStandaloneFieldDefaults)(normalizedTargetUse);
14159
14921
  const shouldPreservePatternFormField = ((_e = input.wrapperNode) == null ? void 0 : _e.use) === "PatternFormItemModel";
14922
+ const preservedPopupPageSubModel = ((_f = input.innerField) == null ? void 0 : _f.subModels) && Object.prototype.hasOwnProperty.call(input.innerField.subModels, "page") ? {
14923
+ page: import_lodash.default.cloneDeep(input.innerField.subModels.page)
14924
+ } : {};
14925
+ const nextSubModels = {
14926
+ ...fieldDefaults.subModels ? import_lodash.default.cloneDeep(fieldDefaults.subModels) : {},
14927
+ ...preservedPopupPageSubModel
14928
+ };
14160
14929
  const nextFieldNode = {
14161
14930
  uid: innerField.uid,
14162
14931
  use: shouldPreservePatternFormField ? "PatternFormFieldModel" : normalizedTargetUse,
14163
14932
  props: import_lodash.default.pickBy(
14164
- {
14165
- ...innerField.props || {},
14166
- ...defaultProps
14167
- },
14933
+ this.normalizeFieldPropsForUse(normalizedTargetUse, { ...innerField.props || {}, ...defaultProps }),
14168
14934
  (value) => !import_lodash.default.isUndefined(value)
14169
14935
  ),
14170
14936
  decoratorProps: import_lodash.default.cloneDeep(innerField.decoratorProps || {}),
@@ -14176,7 +14942,8 @@ class FlowSurfacesService {
14176
14942
  fieldSettings: {
14177
14943
  init: fieldSource.fieldSettingsInit
14178
14944
  }
14179
- })
14945
+ }),
14946
+ subModels: nextSubModels
14180
14947
  };
14181
14948
  await this.repository.patch(nextFieldNode, { transaction: input.transaction });
14182
14949
  return normalizedTargetUse;