@nocobase/plugin-flow-engine 2.2.0-alpha.1 → 2.2.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.js +1 -1
- package/dist/externalVersion.js +9 -9
- package/dist/locale/en-US.json +1 -0
- package/dist/locale/index.d.ts +2 -0
- package/dist/locale/zh-CN.json +1 -0
- package/dist/node_modules/@ant-design/icons-svg/package.json +1 -1
- package/dist/node_modules/acorn/package.json +1 -1
- package/dist/node_modules/acorn-jsx/package.json +1 -1
- package/dist/node_modules/acorn-walk/package.json +1 -1
- package/dist/node_modules/ses/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/flow-surfaces/{runjs-authoring/blocked-global-stop/index.d.ts → approval/authoring-validation.d.ts} +1 -2
- package/dist/server/flow-surfaces/approval/authoring-validation.js +1151 -0
- package/dist/server/flow-surfaces/approval/blueprint-service.js +2 -0
- package/dist/server/flow-surfaces/authoring-validation.js +452 -39
- package/dist/server/flow-surfaces/blueprint/export-document.d.ts +50 -0
- package/dist/server/flow-surfaces/blueprint/export-document.js +2505 -0
- package/dist/server/flow-surfaces/builder.js +16 -1
- package/dist/server/flow-surfaces/catalog.js +3 -1
- package/dist/server/flow-surfaces/configure-options.js +4 -3
- package/dist/server/flow-surfaces/constants.d.ts +9 -2
- package/dist/server/flow-surfaces/constants.js +1 -0
- package/dist/server/flow-surfaces/contract-guard.js +24 -2
- package/dist/server/flow-surfaces/default-action-popup.d.ts +2 -0
- package/dist/server/flow-surfaces/default-action-popup.js +27 -13
- package/dist/server/flow-surfaces/filter-group.d.ts +19 -2
- package/dist/server/flow-surfaces/filter-group.js +232 -3
- package/dist/server/flow-surfaces/planning/compiler.d.ts +1 -0
- package/dist/server/flow-surfaces/planning/compiler.js +205 -82
- package/dist/server/flow-surfaces/planning/key-registry.d.ts +1 -1
- package/dist/server/flow-surfaces/planning/runtime.js +1 -0
- package/dist/server/flow-surfaces/planning/step-link.d.ts +1 -1
- package/dist/server/flow-surfaces/planning/step-link.js +22 -3
- package/dist/server/flow-surfaces/public-data-surface-default-filter.js +0 -9
- package/dist/server/flow-surfaces/reaction/field-value.d.ts +9 -0
- package/dist/server/flow-surfaces/reaction/field-value.js +51 -2
- package/dist/server/flow-surfaces/reaction/linkage.d.ts +6 -1
- package/dist/server/flow-surfaces/reaction/linkage.js +18 -3
- package/dist/server/flow-surfaces/reaction/meta.js +19 -1
- package/dist/server/flow-surfaces/reaction/types.d.ts +19 -0
- package/dist/server/flow-surfaces/relation-backing-foreign-key.d.ts +10 -0
- package/dist/server/flow-surfaces/relation-backing-foreign-key.js +79 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/source.d.ts +1 -0
- package/dist/server/flow-surfaces/runjs-authoring/ast/source.js +20 -0
- package/dist/server/flow-surfaces/runjs-authoring/rules.js +0 -2
- package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.d.ts +0 -1
- package/dist/server/flow-surfaces/runjs-authoring/runtime/constants.js +11 -19
- package/dist/server/flow-surfaces/runjs-authoring/runtime/types.d.ts +0 -12
- package/dist/server/flow-surfaces/runjs-authoring/scan/filter.js +12 -2
- package/dist/server/flow-surfaces/runjs-authoring/scan/index.d.ts +0 -14
- package/dist/server/flow-surfaces/runjs-authoring/scan/index.js +10 -8
- package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.d.ts +0 -14
- package/dist/server/flow-surfaces/runjs-authoring/scan/source-patterns.js +18 -73
- package/dist/server/flow-surfaces/runjs-authoring/types.d.ts +1 -1
- package/dist/server/flow-surfaces/runjs-authoring/validators/index.js +9 -53
- package/dist/server/flow-surfaces/service.d.ts +42 -0
- package/dist/server/flow-surfaces/service.js +727 -93
- package/dist/server/variables/registry.js +3 -0
- package/dist/swagger/flow-surfaces.d.ts +180 -0
- package/dist/swagger/flow-surfaces.examples.d.ts +8 -0
- package/dist/swagger/flow-surfaces.examples.js +8 -0
- package/dist/swagger/flow-surfaces.js +160 -4
- package/dist/swagger/index.d.ts +180 -0
- package/package.json +2 -2
- package/dist/server/flow-surfaces/runjs-authoring/blocked-global-stop/index.js +0 -40
|
@@ -56,6 +56,7 @@ var import_executor = require("./executor");
|
|
|
56
56
|
var import_reference_guards = require("./reference-guards");
|
|
57
57
|
var import_key_registry = require("./planning/key-registry");
|
|
58
58
|
var import_blueprint = require("./blueprint");
|
|
59
|
+
var import_export_document = require("./blueprint/export-document");
|
|
59
60
|
var import_compile_blocks = require("./blueprint/compile-blocks");
|
|
60
61
|
var import_default_block_actions = require("./default-block-actions");
|
|
61
62
|
var import_template_reference = require("./template-reference");
|
|
@@ -96,6 +97,7 @@ var import_meta = require("./reaction/meta");
|
|
|
96
97
|
var import_resolver = require("./reaction/resolver");
|
|
97
98
|
var import_association_title_field = require("./association-title-field");
|
|
98
99
|
var import_default_action_popup = require("./default-action-popup");
|
|
100
|
+
var import_relation_backing_foreign_key = require("./relation-backing-foreign-key");
|
|
99
101
|
var import_defaults = require("./blueprint/defaults");
|
|
100
102
|
var import_service_utils = require("./service-utils");
|
|
101
103
|
var import_field_type_resolver = require("./field-type-resolver");
|
|
@@ -229,9 +231,11 @@ function isFlowSurfaceChartRepairError(error) {
|
|
|
229
231
|
var _a, _b;
|
|
230
232
|
return error instanceof import_errors.FlowSurfaceBadRequestError && ((_b = (_a = error.options) == null ? void 0 : _a.details) == null ? void 0 : _b.repairHint) === FLOW_SURFACE_CHART_REPAIR_HINT;
|
|
231
233
|
}
|
|
234
|
+
const FLOW_SURFACE_EXPORT_BLUEPRINT_ROOT_ONLY_MESSAGE = "exportBlueprint v1 only supports root page export";
|
|
232
235
|
const FORM_BLOCK_USES = /* @__PURE__ */ new Set(["FormBlockModel", "CreateFormModel", "EditFormModel", ...import_approval.APPROVAL_FORM_BLOCK_USES]);
|
|
233
236
|
const AUTO_SUBMIT_FORM_BLOCK_USES = /* @__PURE__ */ new Set(["CreateFormModel", "EditFormModel"]);
|
|
234
237
|
const FLOW_SURFACE_DEFAULT_ACTION_SETTINGS_KEYS = /* @__PURE__ */ new Set(["filter"]);
|
|
238
|
+
const ACTION_BUTTON_GENERAL_SETTING_KEYS = ["title", "tooltip", "icon", "iconOnly", "type", "danger", "color"];
|
|
235
239
|
const DETAILS_BLOCK_USES = /* @__PURE__ */ new Set(["DetailsBlockModel", ...import_approval.APPROVAL_DETAILS_BLOCK_USES]);
|
|
236
240
|
const SIMPLE_FORM_BLOCK_USES = /* @__PURE__ */ new Set([
|
|
237
241
|
"FormBlockModel",
|
|
@@ -685,6 +689,7 @@ function assertNoFlowSurfaceIdTitleFieldSettings(value, options = {}) {
|
|
|
685
689
|
};
|
|
686
690
|
visit(value, options.basePath || []);
|
|
687
691
|
}
|
|
692
|
+
const DEFAULT_ADMIN_UI_LAYOUT_UID = "admin-layout-model";
|
|
688
693
|
class FlowSurfacesService {
|
|
689
694
|
constructor(plugin) {
|
|
690
695
|
this.plugin = plugin;
|
|
@@ -1026,6 +1031,101 @@ class FlowSurfacesService {
|
|
|
1026
1031
|
...extras
|
|
1027
1032
|
};
|
|
1028
1033
|
}
|
|
1034
|
+
hasDesktopRouteUiLayoutsRelation() {
|
|
1035
|
+
var _a, _b;
|
|
1036
|
+
try {
|
|
1037
|
+
return !!this.db.getCollection("uiLayouts") && !!((_b = (_a = this.db.getCollection("desktopRoutes")) == null ? void 0 : _a.getField) == null ? void 0 : _b.call(_a, "uiLayouts"));
|
|
1038
|
+
} catch (error) {
|
|
1039
|
+
return false;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
normalizeDesktopRouteRelationId(routeId) {
|
|
1043
|
+
return import_lodash.default.isNil(routeId) ? void 0 : routeId;
|
|
1044
|
+
}
|
|
1045
|
+
async readDesktopRouteUiLayoutUids(routeId, transaction) {
|
|
1046
|
+
const relationRouteId = this.normalizeDesktopRouteRelationId(routeId);
|
|
1047
|
+
if (import_lodash.default.isUndefined(relationRouteId) || !this.hasDesktopRouteUiLayoutsRelation()) {
|
|
1048
|
+
return [];
|
|
1049
|
+
}
|
|
1050
|
+
const uiLayouts = await this.db.getRepository("desktopRoutes.uiLayouts", relationRouteId).find({
|
|
1051
|
+
fields: ["uid"],
|
|
1052
|
+
transaction
|
|
1053
|
+
});
|
|
1054
|
+
return import_lodash.default.uniq(
|
|
1055
|
+
uiLayouts.map((uiLayout) => {
|
|
1056
|
+
var _a;
|
|
1057
|
+
return String(((_a = uiLayout == null ? void 0 : uiLayout.get) == null ? void 0 : _a.call(uiLayout, "uid")) || (uiLayout == null ? void 0 : uiLayout.uid) || "").trim();
|
|
1058
|
+
}).filter(Boolean)
|
|
1059
|
+
);
|
|
1060
|
+
}
|
|
1061
|
+
async resolveDefaultDesktopRouteUiLayoutUids(transaction) {
|
|
1062
|
+
if (!this.hasDesktopRouteUiLayoutsRelation()) {
|
|
1063
|
+
return [];
|
|
1064
|
+
}
|
|
1065
|
+
const defaultLayout = await this.db.getRepository("uiLayouts").findOne({
|
|
1066
|
+
filter: {
|
|
1067
|
+
uid: DEFAULT_ADMIN_UI_LAYOUT_UID,
|
|
1068
|
+
enabled: true
|
|
1069
|
+
},
|
|
1070
|
+
transaction
|
|
1071
|
+
});
|
|
1072
|
+
return defaultLayout ? [DEFAULT_ADMIN_UI_LAYOUT_UID] : [];
|
|
1073
|
+
}
|
|
1074
|
+
async resolveInheritedDesktopRouteUiLayoutUids(parentRoute, transaction) {
|
|
1075
|
+
const parentRouteId = this.readRouteField(parentRoute, "id");
|
|
1076
|
+
if (!import_lodash.default.isNil(parentRouteId)) {
|
|
1077
|
+
const parentLayoutUids = await this.readDesktopRouteUiLayoutUids(parentRouteId, transaction);
|
|
1078
|
+
if (parentLayoutUids.length) {
|
|
1079
|
+
return parentLayoutUids;
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
return this.resolveDefaultDesktopRouteUiLayoutUids(transaction);
|
|
1083
|
+
}
|
|
1084
|
+
async setDesktopRouteUiLayouts(routeId, uiLayoutUids, transaction) {
|
|
1085
|
+
const relationRouteId = this.normalizeDesktopRouteRelationId(routeId);
|
|
1086
|
+
if (import_lodash.default.isUndefined(relationRouteId) || !uiLayoutUids.length || !this.hasDesktopRouteUiLayoutsRelation()) {
|
|
1087
|
+
return;
|
|
1088
|
+
}
|
|
1089
|
+
await this.db.getRepository("desktopRoutes.uiLayouts", relationRouteId).set({
|
|
1090
|
+
tk: uiLayoutUids,
|
|
1091
|
+
transaction
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
async attachDesktopRouteUiLayoutsToRouteAndChildren(routeId, uiLayoutUids, transaction) {
|
|
1095
|
+
if (import_lodash.default.isNil(routeId) || !uiLayoutUids.length || !this.hasDesktopRouteUiLayoutsRelation()) {
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
await this.setDesktopRouteUiLayouts(routeId, uiLayoutUids, transaction);
|
|
1099
|
+
const children = await this.db.getRepository("desktopRoutes").find({
|
|
1100
|
+
fields: ["id"],
|
|
1101
|
+
filter: {
|
|
1102
|
+
parentId: routeId
|
|
1103
|
+
},
|
|
1104
|
+
transaction
|
|
1105
|
+
});
|
|
1106
|
+
for (const child of children) {
|
|
1107
|
+
await this.attachDesktopRouteUiLayoutsToRouteAndChildren(
|
|
1108
|
+
this.readRouteField(child, "id"),
|
|
1109
|
+
uiLayoutUids,
|
|
1110
|
+
transaction
|
|
1111
|
+
);
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
async ensureDesktopRouteUiLayouts(route, transaction) {
|
|
1115
|
+
const routeId = this.readRouteField(route, "id");
|
|
1116
|
+
if (import_lodash.default.isNil(routeId) || !this.hasDesktopRouteUiLayoutsRelation()) {
|
|
1117
|
+
return [];
|
|
1118
|
+
}
|
|
1119
|
+
const existingLayoutUids = await this.readDesktopRouteUiLayoutUids(routeId, transaction);
|
|
1120
|
+
if (existingLayoutUids.length) {
|
|
1121
|
+
return existingLayoutUids;
|
|
1122
|
+
}
|
|
1123
|
+
const parentRouteId = this.readRouteField(route, "parentId");
|
|
1124
|
+
const parentRoute = import_lodash.default.isNil(parentRouteId) ? null : await this.findMenuRouteById(parentRouteId, transaction);
|
|
1125
|
+
const inheritedLayoutUids = await this.resolveInheritedDesktopRouteUiLayoutUids(parentRoute, transaction);
|
|
1126
|
+
await this.setDesktopRouteUiLayouts(routeId, inheritedLayoutUids, transaction);
|
|
1127
|
+
return inheritedLayoutUids;
|
|
1128
|
+
}
|
|
1029
1129
|
isValidMenuIconName(value) {
|
|
1030
1130
|
const normalized = String(value || "").trim();
|
|
1031
1131
|
return !!normalized && ANT_DESIGN_ICON_NAMES.has(normalized);
|
|
@@ -1107,7 +1207,7 @@ class FlowSurfacesService {
|
|
|
1107
1207
|
this.assertVisibleNavigationIcon("createMenu", "values", values);
|
|
1108
1208
|
const schemaUid = values.schemaUid || (0, import_utils.uid)();
|
|
1109
1209
|
const desktopRoutes = this.db.getRepository("desktopRoutes");
|
|
1110
|
-
await desktopRoutes.create({
|
|
1210
|
+
const route = await desktopRoutes.create({
|
|
1111
1211
|
values: {
|
|
1112
1212
|
type: "group",
|
|
1113
1213
|
sort: this.allocateRouteSortValue(),
|
|
@@ -1120,10 +1220,11 @@ class FlowSurfacesService {
|
|
|
1120
1220
|
},
|
|
1121
1221
|
transaction
|
|
1122
1222
|
});
|
|
1123
|
-
|
|
1124
|
-
|
|
1223
|
+
await this.attachDesktopRouteUiLayoutsToRouteAndChildren(
|
|
1224
|
+
this.readRouteField(route, "id"),
|
|
1225
|
+
await this.resolveInheritedDesktopRouteUiLayoutUids(parentRoute, transaction),
|
|
1125
1226
|
transaction
|
|
1126
|
-
|
|
1227
|
+
);
|
|
1127
1228
|
return this.buildMenuResult(route);
|
|
1128
1229
|
}
|
|
1129
1230
|
async createFlowMenuItem(values, transaction) {
|
|
@@ -1138,7 +1239,7 @@ class FlowSurfacesService {
|
|
|
1138
1239
|
const title = values.title || pageSchemaUid;
|
|
1139
1240
|
const tabTitle = values.tabTitle || "Untitled";
|
|
1140
1241
|
const desktopRoutes = this.db.getRepository("desktopRoutes");
|
|
1141
|
-
await desktopRoutes.create({
|
|
1242
|
+
const createdRoute = await desktopRoutes.create({
|
|
1142
1243
|
values: {
|
|
1143
1244
|
type: "flowPage",
|
|
1144
1245
|
sort: this.allocateRouteSortValue(),
|
|
@@ -1173,6 +1274,11 @@ class FlowSurfacesService {
|
|
|
1173
1274
|
},
|
|
1174
1275
|
transaction
|
|
1175
1276
|
});
|
|
1277
|
+
await this.attachDesktopRouteUiLayoutsToRouteAndChildren(
|
|
1278
|
+
this.readRouteField(createdRoute, "id"),
|
|
1279
|
+
await this.resolveInheritedDesktopRouteUiLayoutUids(parentRoute, transaction),
|
|
1280
|
+
transaction
|
|
1281
|
+
);
|
|
1176
1282
|
const route = await desktopRoutes.findOne({
|
|
1177
1283
|
filter: { schemaUid: pageSchemaUid },
|
|
1178
1284
|
appends: ["children"],
|
|
@@ -1945,6 +2051,9 @@ class FlowSurfacesService {
|
|
|
1945
2051
|
if (!(popupProfile == null ? void 0 : popupProfile.currentCollection)) {
|
|
1946
2052
|
return popupProfile == null ? void 0 : popupProfile.filterByTk;
|
|
1947
2053
|
}
|
|
2054
|
+
if (popupProfile.popupKind === "recordPopup" && popupProfile.popupHostUse && POPUP_HOST_DEFAULT_RECORD_CONTEXT_ACTION_USES.has(popupProfile.popupHostUse)) {
|
|
2055
|
+
return "{{ctx.view.inputArgs.filterByTk}}";
|
|
2056
|
+
}
|
|
1948
2057
|
if (popupProfile.popupKind !== "associationPopup") {
|
|
1949
2058
|
return popupProfile.filterByTk;
|
|
1950
2059
|
}
|
|
@@ -2300,10 +2409,18 @@ class FlowSurfacesService {
|
|
|
2300
2409
|
if (!sameCurrentCollection || !(0, import_service_helpers.hasConfiguredFlowContextValue)(normalized.filterByTk)) {
|
|
2301
2410
|
return false;
|
|
2302
2411
|
}
|
|
2412
|
+
const expectedFilterByTk = this.resolvePopupCurrentRecordResourceFilterByTk(input.popupProfile, {
|
|
2413
|
+
usePopupInputArgsWhenSourceIdInferred: true
|
|
2414
|
+
});
|
|
2415
|
+
const matchesCurrentRecordFilterByTk = this.isPopupCurrentRecordFilterByTkMatch(
|
|
2416
|
+
input.popupProfile,
|
|
2417
|
+
normalized.filterByTk,
|
|
2418
|
+
expectedFilterByTk
|
|
2419
|
+
);
|
|
2303
2420
|
if (input.popupProfile.hasAssociationContext) {
|
|
2304
|
-
return
|
|
2421
|
+
return matchesCurrentRecordFilterByTk && normalized.associationName === input.popupProfile.associationName && this.isSameConfiguredFlowContextValue(normalized.sourceId, input.popupProfile.sourceId);
|
|
2305
2422
|
}
|
|
2306
|
-
return
|
|
2423
|
+
return matchesCurrentRecordFilterByTk && !(0, import_service_helpers.hasConfiguredFlowContextValue)(normalized.associationName) && !(0, import_service_helpers.hasConfiguredFlowContextValue)(normalized.sourceId);
|
|
2307
2424
|
}
|
|
2308
2425
|
if (input.binding === "associatedRecords") {
|
|
2309
2426
|
if (!(0, import_service_helpers.hasConfiguredFlowContextValue)(normalized.collectionName) || !(0, import_service_helpers.hasConfiguredFlowContextValue)(normalized.associationName) || !(0, import_service_helpers.hasConfiguredFlowContextValue)(normalized.sourceId) || (0, import_service_helpers.hasConfiguredFlowContextValue)(normalized.filterByTk)) {
|
|
@@ -2346,6 +2463,12 @@ class FlowSurfacesService {
|
|
|
2346
2463
|
}
|
|
2347
2464
|
return import_lodash.default.isEqual(this.normalizeFlowContextTemplateValue(left), this.normalizeFlowContextTemplateValue(right));
|
|
2348
2465
|
}
|
|
2466
|
+
isPopupCurrentRecordFilterByTkMatch(popupProfile, filterByTk, expectedFilterByTk) {
|
|
2467
|
+
if (this.isSameConfiguredFlowContextValue(filterByTk, expectedFilterByTk)) {
|
|
2468
|
+
return true;
|
|
2469
|
+
}
|
|
2470
|
+
return popupProfile.popupKind === "associationPopup" && this.isSameConfiguredFlowContextValue(filterByTk, popupProfile.filterByTk);
|
|
2471
|
+
}
|
|
2349
2472
|
isPopupAssociatedRecordsSourceIdMatch(popupProfile, associationField, sourceId) {
|
|
2350
2473
|
var _a, _b;
|
|
2351
2474
|
if (!(0, import_service_helpers.hasConfiguredFlowContextValue)(sourceId)) {
|
|
@@ -2621,6 +2744,28 @@ class FlowSurfacesService {
|
|
|
2621
2744
|
}
|
|
2622
2745
|
return capability;
|
|
2623
2746
|
}
|
|
2747
|
+
async getLiveFieldValueCapability(writeTarget, resolvedTarget, node, options = {}) {
|
|
2748
|
+
const context = await this.context(
|
|
2749
|
+
{
|
|
2750
|
+
target: writeTarget
|
|
2751
|
+
},
|
|
2752
|
+
options
|
|
2753
|
+
);
|
|
2754
|
+
const { capabilities } = (0, import_meta.buildReactionMetaCapabilities)({
|
|
2755
|
+
resolvedTarget: {
|
|
2756
|
+
...resolvedTarget,
|
|
2757
|
+
node
|
|
2758
|
+
},
|
|
2759
|
+
context
|
|
2760
|
+
});
|
|
2761
|
+
const capability = capabilities.find((item) => item.kind === "fieldValue");
|
|
2762
|
+
if (!capability) {
|
|
2763
|
+
(0, import_errors.throwBadRequest)(
|
|
2764
|
+
`flowSurfaces reaction target '${resolvedTarget.use || resolvedTarget.target.uid}' does not support fieldValue`
|
|
2765
|
+
);
|
|
2766
|
+
}
|
|
2767
|
+
return capability;
|
|
2768
|
+
}
|
|
2624
2769
|
async getReactionMeta(values, options = {}) {
|
|
2625
2770
|
(0, import_payload_shape.validateFlowSurfacePayloadShape)("getReactionMeta", values, "values");
|
|
2626
2771
|
const { writeTarget, node, resolvedTarget } = await this.resolveReactionRequest("getReactionMeta", values == null ? void 0 : values.target, {
|
|
@@ -2666,6 +2811,8 @@ class FlowSurfacesService {
|
|
|
2666
2811
|
},
|
|
2667
2812
|
rules: Array.isArray(values == null ? void 0 : values.rules) ? values.rules : []
|
|
2668
2813
|
});
|
|
2814
|
+
const liveCapability = await this.getLiveFieldValueCapability(writeTarget, resolvedTarget, node, options);
|
|
2815
|
+
(0, import_field_value.validateFieldValueRulesAgainstCapability)(result.normalizedRules, liveCapability);
|
|
2669
2816
|
await this.persistReactionSlot(storageNode, capability.resolvedSlot, result.canonicalRules, options);
|
|
2670
2817
|
return result;
|
|
2671
2818
|
}
|
|
@@ -2873,6 +3020,41 @@ class FlowSurfacesService {
|
|
|
2873
3020
|
const publicNode = this.stripInternalSurfaceMetaFromNodeTree(import_lodash.default.cloneDeep(rawNode));
|
|
2874
3021
|
return this.buildSurfaceReadPayload(target, resolved, publicNode, options);
|
|
2875
3022
|
}
|
|
3023
|
+
async exportBlueprint(input, options = {}) {
|
|
3024
|
+
const request = this.normalizeExportBlueprintRequest(input);
|
|
3025
|
+
const resolved = await this.locator.resolve(request.target, options);
|
|
3026
|
+
if (resolved.kind !== "page" || !resolved.pageRoute) {
|
|
3027
|
+
(0, import_errors.throwBadRequest)(FLOW_SURFACE_EXPORT_BLUEPRINT_ROOT_ONLY_MESSAGE);
|
|
3028
|
+
}
|
|
3029
|
+
const pageSchemaUid = this.resolveExportBlueprintPageSchemaUid(request.target, resolved);
|
|
3030
|
+
await this.assertExportBlueprintRootTarget(request.target, resolved, pageSchemaUid, options.transaction);
|
|
3031
|
+
const rawNode = await this.decorateTemplateReadbackTree(
|
|
3032
|
+
this.normalizePopupTreeShape(
|
|
3033
|
+
await this.loadResolvedNode(resolved, options.transaction, {
|
|
3034
|
+
persistCalendarPopupHosts: false
|
|
3035
|
+
})
|
|
3036
|
+
),
|
|
3037
|
+
options.transaction
|
|
3038
|
+
);
|
|
3039
|
+
if (!(rawNode == null ? void 0 : rawNode.uid)) {
|
|
3040
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces exportBlueprint target '${pageSchemaUid}' could not resolve a readable page tree`);
|
|
3041
|
+
}
|
|
3042
|
+
const pageRoute = resolved.pageRoute ? await this.routeSync.hydrateRoute(resolved.pageRoute, options.transaction) : void 0;
|
|
3043
|
+
const result = (0, import_export_document.exportFlowSurfaceBlueprintDocument)({
|
|
3044
|
+
page: rawNode,
|
|
3045
|
+
pageRoute,
|
|
3046
|
+
target: {
|
|
3047
|
+
pageSchemaUid
|
|
3048
|
+
},
|
|
3049
|
+
unsupportedPolicy: request.unsupportedPolicy
|
|
3050
|
+
});
|
|
3051
|
+
return {
|
|
3052
|
+
...result,
|
|
3053
|
+
document: (0, import_blueprint.prepareFlowSurfaceApplyBlueprintDocument)(
|
|
3054
|
+
result.document
|
|
3055
|
+
)
|
|
3056
|
+
};
|
|
3057
|
+
}
|
|
2876
3058
|
getDeclaredKeyPersistenceDeps() {
|
|
2877
3059
|
return {
|
|
2878
3060
|
findModelById: (uid2, findOptions) => this.repository.findModelById(uid2, findOptions),
|
|
@@ -4474,10 +4656,16 @@ class FlowSurfacesService {
|
|
|
4474
4656
|
return this.buildPopupTemplateOpenView(template, "reference", templateTargetUid, options);
|
|
4475
4657
|
}
|
|
4476
4658
|
shouldHydrateDetachedPopupTemplateBlockResourceContext(blockNode, context) {
|
|
4477
|
-
if (!this.isCollectionBlockUse(blockNode == null ? void 0 : blockNode.use)
|
|
4659
|
+
if (!this.isCollectionBlockUse(blockNode == null ? void 0 : blockNode.use)) {
|
|
4478
4660
|
return false;
|
|
4479
4661
|
}
|
|
4480
4662
|
const init = import_lodash.default.get(blockNode, ["stepParams", "resourceSettings", "init"]) || {};
|
|
4663
|
+
if (this.resolveDetachedPopupTemplateBlockCurrentRecordFilterByTk(init, context)) {
|
|
4664
|
+
return true;
|
|
4665
|
+
}
|
|
4666
|
+
if (!context.associationName || !context.sourceId) {
|
|
4667
|
+
return false;
|
|
4668
|
+
}
|
|
4481
4669
|
const popupDataSourceKey = context.dataSourceKey || "main";
|
|
4482
4670
|
const blockDataSourceKey = init.dataSourceKey || "main";
|
|
4483
4671
|
if (!context.collectionName || blockDataSourceKey !== popupDataSourceKey || init.collectionName !== context.collectionName) {
|
|
@@ -4492,6 +4680,28 @@ class FlowSurfacesService {
|
|
|
4492
4680
|
}
|
|
4493
4681
|
return blockAssociationName !== context.associationName || !this.isSameConfiguredFlowContextValue(init.sourceId, context.sourceId);
|
|
4494
4682
|
}
|
|
4683
|
+
resolveDetachedPopupTemplateBlockCurrentRecordFilterByTk(init, context) {
|
|
4684
|
+
if (!(0, import_service_helpers.hasConfiguredFlowContextValue)(init.filterByTk)) {
|
|
4685
|
+
return void 0;
|
|
4686
|
+
}
|
|
4687
|
+
if (this.isSameConfiguredFlowContextValue(init.filterByTk, "{{ctx.view.inputArgs.filterByTk}}")) {
|
|
4688
|
+
return void 0;
|
|
4689
|
+
}
|
|
4690
|
+
const popupDataSourceKey = context.dataSourceKey || "main";
|
|
4691
|
+
const blockDataSourceKey = init.dataSourceKey || "main";
|
|
4692
|
+
if (!context.collectionName || blockDataSourceKey !== popupDataSourceKey || init.collectionName !== context.collectionName) {
|
|
4693
|
+
return void 0;
|
|
4694
|
+
}
|
|
4695
|
+
if (context.filterByTk && this.isSameConfiguredFlowContextValue(init.filterByTk, context.filterByTk)) {
|
|
4696
|
+
return "{{ctx.view.inputArgs.filterByTk}}";
|
|
4697
|
+
}
|
|
4698
|
+
const collection = this.getCollection(popupDataSourceKey, context.collectionName);
|
|
4699
|
+
const filterTargetKey = this.getCollectionFilterTargetKey(collection);
|
|
4700
|
+
if (this.isSameConfiguredFlowContextValue(init.filterByTk, `{{ctx.record.${filterTargetKey}}}`)) {
|
|
4701
|
+
return "{{ctx.view.inputArgs.filterByTk}}";
|
|
4702
|
+
}
|
|
4703
|
+
return void 0;
|
|
4704
|
+
}
|
|
4495
4705
|
collectDetachedPopupTemplateBlockResourceContextPatches(node, context, patches = []) {
|
|
4496
4706
|
if (!node || typeof node !== "object") {
|
|
4497
4707
|
return patches;
|
|
@@ -4499,6 +4709,7 @@ class FlowSurfacesService {
|
|
|
4499
4709
|
if (node.uid && this.shouldHydrateDetachedPopupTemplateBlockResourceContext(node, context)) {
|
|
4500
4710
|
const nextStepParams = import_lodash.default.cloneDeep(node.stepParams || {});
|
|
4501
4711
|
const currentInit = import_lodash.default.get(nextStepParams, ["resourceSettings", "init"]) || {};
|
|
4712
|
+
const filterByTk = this.resolveDetachedPopupTemplateBlockCurrentRecordFilterByTk(currentInit, context);
|
|
4502
4713
|
import_lodash.default.set(
|
|
4503
4714
|
nextStepParams,
|
|
4504
4715
|
["resourceSettings", "init"],
|
|
@@ -4506,8 +4717,11 @@ class FlowSurfacesService {
|
|
|
4506
4717
|
...currentInit,
|
|
4507
4718
|
dataSourceKey: context.dataSourceKey || currentInit.dataSourceKey || "main",
|
|
4508
4719
|
collectionName: context.collectionName || currentInit.collectionName,
|
|
4509
|
-
associationName
|
|
4510
|
-
|
|
4720
|
+
...context.associationName && context.sourceId ? {
|
|
4721
|
+
associationName: context.associationName,
|
|
4722
|
+
sourceId: context.sourceId
|
|
4723
|
+
} : {},
|
|
4724
|
+
...filterByTk ? { filterByTk } : {}
|
|
4511
4725
|
})
|
|
4512
4726
|
);
|
|
4513
4727
|
patches.push({
|
|
@@ -5767,7 +5981,7 @@ class FlowSurfacesService {
|
|
|
5767
5981
|
(0, import_errors.throwBadRequest)("flowSurfaces updateMenu requires menuRouteId");
|
|
5768
5982
|
}
|
|
5769
5983
|
const route = await this.assertMenuRouteUpdatable(menuRouteId, options.transaction);
|
|
5770
|
-
await this.assertMenuParentIsGroup(values.parentMenuRouteId, options.transaction);
|
|
5984
|
+
const nextParentRoute = await this.assertMenuParentIsGroup(values.parentMenuRouteId, options.transaction);
|
|
5771
5985
|
await this.assertMenuParentNotSelfOrDescendant(route, values.parentMenuRouteId, options.transaction);
|
|
5772
5986
|
const nextOptions = { ...this.readRouteOptions(route) };
|
|
5773
5987
|
const updateValues = {};
|
|
@@ -5798,6 +6012,13 @@ class FlowSurfacesService {
|
|
|
5798
6012
|
});
|
|
5799
6013
|
}
|
|
5800
6014
|
const updated = await this.findMenuRouteById(menuRouteId, options.transaction);
|
|
6015
|
+
if (updated && Object.prototype.hasOwnProperty.call(values, "parentMenuRouteId")) {
|
|
6016
|
+
await this.attachDesktopRouteUiLayoutsToRouteAndChildren(
|
|
6017
|
+
this.readRouteField(updated, "id"),
|
|
6018
|
+
await this.resolveInheritedDesktopRouteUiLayoutUids(nextParentRoute, options.transaction),
|
|
6019
|
+
options.transaction
|
|
6020
|
+
);
|
|
6021
|
+
}
|
|
5801
6022
|
return this.buildMenuResult(updated);
|
|
5802
6023
|
}
|
|
5803
6024
|
async initializeFlowPageForRoute(route, values, transaction) {
|
|
@@ -5805,6 +6026,7 @@ class FlowSurfacesService {
|
|
|
5805
6026
|
const pageSchemaUid = this.readRouteField(route, "schemaUid");
|
|
5806
6027
|
const structure = await this.loadRouteBackedPageStructure(route, transaction);
|
|
5807
6028
|
let tabRoute = structure.tabRoutes[0];
|
|
6029
|
+
const routeUiLayoutUids = await this.ensureDesktopRouteUiLayouts(route, transaction);
|
|
5808
6030
|
const routeOptions = this.readRouteOptions(route);
|
|
5809
6031
|
if (!routeOptions[FLOW_SURFACE_MENU_BINDABLE_OPTION_KEY]) {
|
|
5810
6032
|
(0, import_errors.throwBadRequest)(`flowSurfaces createPage only accepts a bindable menu route created by createMenu(type="item")`);
|
|
@@ -5826,7 +6048,7 @@ class FlowSurfacesService {
|
|
|
5826
6048
|
const tabSchemaUid2 = values.tabSchemaUid || (0, import_utils.uid)();
|
|
5827
6049
|
const tabSchemaName2 = values.tabSchemaName || (0, import_utils.uid)();
|
|
5828
6050
|
const tabTitle = values.tabTitle || "Untitled";
|
|
5829
|
-
await this.db.getRepository("desktopRoutes").create({
|
|
6051
|
+
tabRoute = await this.db.getRepository("desktopRoutes").create({
|
|
5830
6052
|
values: {
|
|
5831
6053
|
type: "tabs",
|
|
5832
6054
|
sort: this.allocateRouteSortValue(1),
|
|
@@ -5843,10 +6065,7 @@ class FlowSurfacesService {
|
|
|
5843
6065
|
},
|
|
5844
6066
|
transaction
|
|
5845
6067
|
});
|
|
5846
|
-
|
|
5847
|
-
filter: { schemaUid: tabSchemaUid2 },
|
|
5848
|
-
transaction
|
|
5849
|
-
});
|
|
6068
|
+
await this.setDesktopRouteUiLayouts(this.readRouteField(tabRoute, "id"), routeUiLayoutUids, transaction);
|
|
5850
6069
|
} else {
|
|
5851
6070
|
await this.db.getRepository("desktopRoutes").update({
|
|
5852
6071
|
filterByTk: String(this.readRouteField(tabRoute, "id")),
|
|
@@ -5870,6 +6089,9 @@ class FlowSurfacesService {
|
|
|
5870
6089
|
transaction
|
|
5871
6090
|
});
|
|
5872
6091
|
}
|
|
6092
|
+
if (tabRoute) {
|
|
6093
|
+
await this.setDesktopRouteUiLayouts(this.readRouteField(tabRoute, "id"), routeUiLayoutUids, transaction);
|
|
6094
|
+
}
|
|
5873
6095
|
await this.ensureFlowRoutePageSchemaShell(pageSchemaUid, transaction);
|
|
5874
6096
|
await this.db.getRepository("desktopRoutes").update({
|
|
5875
6097
|
filterByTk: String(routeId),
|
|
@@ -6009,6 +6231,11 @@ class FlowSurfacesService {
|
|
|
6009
6231
|
},
|
|
6010
6232
|
transaction: options.transaction
|
|
6011
6233
|
});
|
|
6234
|
+
await this.setDesktopRouteUiLayouts(
|
|
6235
|
+
route.get("id"),
|
|
6236
|
+
await this.ensureDesktopRouteUiLayouts(pageRoute, options.transaction),
|
|
6237
|
+
options.transaction
|
|
6238
|
+
);
|
|
6012
6239
|
const gridUid = await this.ensureGridChild(tabSchemaUid, "BlockGridModel", options.transaction);
|
|
6013
6240
|
const result = {
|
|
6014
6241
|
pageUid: pageTarget.uid,
|
|
@@ -6679,11 +6906,6 @@ class FlowSurfacesService {
|
|
|
6679
6906
|
requiredFieldCount: options.requiredFieldCount
|
|
6680
6907
|
}
|
|
6681
6908
|
);
|
|
6682
|
-
if (!(0, import_service_utils.hasOwnDefined)(normalizedSettings, "filterableFieldNames")) {
|
|
6683
|
-
normalizedSettings.filterableFieldNames = (0, import_public_data_surface_default_filter.resolveFlowSurfaceDefaultFilterFieldNames)(
|
|
6684
|
-
normalizedSettings.defaultFilter
|
|
6685
|
-
);
|
|
6686
|
-
}
|
|
6687
6909
|
}
|
|
6688
6910
|
return normalizedSettings;
|
|
6689
6911
|
}
|
|
@@ -11417,6 +11639,7 @@ class FlowSurfacesService {
|
|
|
11417
11639
|
}
|
|
11418
11640
|
if (this.isAIEmployeeActionUse(current == null ? void 0 : current.use) && this.hasAIEmployeePublicSettings(normalizedValues)) {
|
|
11419
11641
|
const enabledPackages = await this.resolveEnabledPluginPackages(options);
|
|
11642
|
+
const hasRawAIEmployeeStepTasks = import_lodash.default.has(normalizedValues, ["stepParams", ...AI_EMPLOYEE_TASK_STEP_PARAMS_PATH]);
|
|
11420
11643
|
const aiEmployeeSettingsPayload = await this.normalizeAIEmployeeActionPublicSettings(
|
|
11421
11644
|
"updateSettings",
|
|
11422
11645
|
import_lodash.default.pick(normalizedValues, AI_EMPLOYEE_PUBLIC_SETTING_KEYS),
|
|
@@ -11429,7 +11652,8 @@ class FlowSurfacesService {
|
|
|
11429
11652
|
promptContext: {
|
|
11430
11653
|
kind: "target",
|
|
11431
11654
|
targetUid: (current == null ? void 0 : current.uid) || writeTarget.uid
|
|
11432
|
-
}
|
|
11655
|
+
},
|
|
11656
|
+
skipExistingTaskWorkContextRebase: hasRawAIEmployeeStepTasks
|
|
11433
11657
|
}
|
|
11434
11658
|
);
|
|
11435
11659
|
AI_EMPLOYEE_PUBLIC_SETTING_KEYS.forEach((key) => {
|
|
@@ -11511,6 +11735,7 @@ class FlowSurfacesService {
|
|
|
11511
11735
|
normalizedValues,
|
|
11512
11736
|
nextPayload
|
|
11513
11737
|
);
|
|
11738
|
+
this.syncActionButtonSettingsForUpdateSettings(current, normalizedValues, nextPayload);
|
|
11514
11739
|
this.syncActionTriggerWorkflowsForUpdateSettings(current, normalizedValues, nextPayload);
|
|
11515
11740
|
const popupActionContext = options.popupActionContext || await this.resolveRecordContextPopupActionContextForHost(current, options.transaction);
|
|
11516
11741
|
await this.normalizeOpenViewForUpdateSettings(
|
|
@@ -11562,6 +11787,12 @@ class FlowSurfacesService {
|
|
|
11562
11787
|
if (Object.keys(nextPayload).length === 1) {
|
|
11563
11788
|
return { uid: current.uid };
|
|
11564
11789
|
}
|
|
11790
|
+
await this.assertNoDuplicateAIEmployeeActionForUpdateSettings(
|
|
11791
|
+
options.openViewActionName || "updateSettings",
|
|
11792
|
+
current,
|
|
11793
|
+
effectiveNode,
|
|
11794
|
+
options.transaction
|
|
11795
|
+
);
|
|
11565
11796
|
if (target.kind === "tab" && target.tabRoute) {
|
|
11566
11797
|
await this.routeSync.persistTabSettings(target, current, nextPayload, options.transaction);
|
|
11567
11798
|
return {
|
|
@@ -11972,17 +12203,6 @@ class FlowSurfacesService {
|
|
|
11972
12203
|
const filterValue = this.normalizeEffectivePublicDataSurfaceDefaultFilter(normalizedFilterValue, {
|
|
11973
12204
|
requiredFieldCount: options.requiredFieldCount
|
|
11974
12205
|
});
|
|
11975
|
-
if (!hasPropsFilterableFieldNames && !hasStepFilterableFieldNames) {
|
|
11976
|
-
const filterableFieldNames = (0, import_public_data_surface_default_filter.resolveFlowSurfaceDefaultFilterFieldNames)(filterValue);
|
|
11977
|
-
if (filterableFieldNames.length) {
|
|
11978
|
-
nextProps.filterableFieldNames = filterableFieldNames;
|
|
11979
|
-
import_lodash.default.set(
|
|
11980
|
-
nextStepParams,
|
|
11981
|
-
["filterSettings", "filterableFieldNames", "filterableFieldNames"],
|
|
11982
|
-
import_lodash.default.cloneDeep(filterableFieldNames)
|
|
11983
|
-
);
|
|
11984
|
-
}
|
|
11985
|
-
}
|
|
11986
12206
|
nextProps.defaultFilterValue = import_lodash.default.cloneDeep(filterValue);
|
|
11987
12207
|
nextProps.filterValue = import_lodash.default.cloneDeep(filterValue);
|
|
11988
12208
|
import_lodash.default.set(nextStepParams, ["filterSettings", "defaultFilter", "defaultFilter"], import_lodash.default.cloneDeep(filterValue));
|
|
@@ -12029,6 +12249,65 @@ class FlowSurfacesService {
|
|
|
12029
12249
|
nextPayload.stepParams = nextStepParams;
|
|
12030
12250
|
}
|
|
12031
12251
|
}
|
|
12252
|
+
syncActionButtonSettingsForUpdateSettings(current, normalizedValues, nextPayload) {
|
|
12253
|
+
if (!this.supportsActionButtonSettingsSync(current)) {
|
|
12254
|
+
return;
|
|
12255
|
+
}
|
|
12256
|
+
const requestedProps = this.pickRequestedActionButtonSettings(normalizedValues.props);
|
|
12257
|
+
const requestedButtonGeneral = this.pickRequestedActionButtonSettings(
|
|
12258
|
+
import_lodash.default.get(normalizedValues, ["stepParams", "buttonSettings", "general"])
|
|
12259
|
+
);
|
|
12260
|
+
const hasRequestedProps = Object.keys(requestedProps).length > 0;
|
|
12261
|
+
const hasRequestedButtonGeneral = Object.keys(requestedButtonGeneral).length > 0;
|
|
12262
|
+
if (!hasRequestedProps && !hasRequestedButtonGeneral) {
|
|
12263
|
+
return;
|
|
12264
|
+
}
|
|
12265
|
+
const hasRequestedTitle = Object.prototype.hasOwnProperty.call(requestedProps, "title") || Object.prototype.hasOwnProperty.call(requestedButtonGeneral, "title");
|
|
12266
|
+
const shouldStripImplicitTitle = (requestedProps.iconOnly === true || requestedButtonGeneral.iconOnly === true) && !hasRequestedTitle;
|
|
12267
|
+
const nextProps = import_lodash.default.cloneDeep(
|
|
12268
|
+
import_lodash.default.isPlainObject(nextPayload.props) ? nextPayload.props : import_lodash.default.isPlainObject(current == null ? void 0 : current.props) ? current.props : {}
|
|
12269
|
+
);
|
|
12270
|
+
const nextStepParams = import_lodash.default.cloneDeep(
|
|
12271
|
+
import_lodash.default.isPlainObject(nextPayload.stepParams) ? nextPayload.stepParams : import_lodash.default.isPlainObject(current == null ? void 0 : current.stepParams) ? current.stepParams : {}
|
|
12272
|
+
);
|
|
12273
|
+
Object.entries(requestedProps).forEach(([key, value]) => {
|
|
12274
|
+
if (Object.prototype.hasOwnProperty.call(requestedButtonGeneral, key)) {
|
|
12275
|
+
return;
|
|
12276
|
+
}
|
|
12277
|
+
import_lodash.default.set(nextStepParams, ["buttonSettings", "general", key], import_lodash.default.cloneDeep(value));
|
|
12278
|
+
});
|
|
12279
|
+
Object.entries(requestedButtonGeneral).forEach(([key, value]) => {
|
|
12280
|
+
if (Object.prototype.hasOwnProperty.call(requestedProps, key)) {
|
|
12281
|
+
return;
|
|
12282
|
+
}
|
|
12283
|
+
nextProps[key] = import_lodash.default.cloneDeep(value);
|
|
12284
|
+
});
|
|
12285
|
+
if (shouldStripImplicitTitle) {
|
|
12286
|
+
delete nextProps.title;
|
|
12287
|
+
if (import_lodash.default.isPlainObject(import_lodash.default.get(nextStepParams, ["buttonSettings", "general"]))) {
|
|
12288
|
+
delete nextStepParams.buttonSettings.general.title;
|
|
12289
|
+
}
|
|
12290
|
+
}
|
|
12291
|
+
nextPayload.props = nextProps;
|
|
12292
|
+
nextPayload.stepParams = nextStepParams;
|
|
12293
|
+
}
|
|
12294
|
+
supportsActionButtonSettingsSync(current) {
|
|
12295
|
+
var _a, _b, _c, _d, _e, _f;
|
|
12296
|
+
const contract = (0, import_catalog.getNodeContract)(current == null ? void 0 : current.use);
|
|
12297
|
+
return ((_b = (_a = contract.domains.props) == null ? void 0 : _a.allowedKeys) == null ? void 0 : _b.includes("iconOnly")) && ((_f = (_e = (_d = (_c = contract.domains.stepParams) == null ? void 0 : _c.groups) == null ? void 0 : _d.buttonSettings) == null ? void 0 : _e.allowedPaths) == null ? void 0 : _f.includes("general.iconOnly"));
|
|
12298
|
+
}
|
|
12299
|
+
pickRequestedActionButtonSettings(input) {
|
|
12300
|
+
const picked = {};
|
|
12301
|
+
if (!import_lodash.default.isPlainObject(input)) {
|
|
12302
|
+
return picked;
|
|
12303
|
+
}
|
|
12304
|
+
ACTION_BUTTON_GENERAL_SETTING_KEYS.forEach((key) => {
|
|
12305
|
+
if (Object.prototype.hasOwnProperty.call(input, key) && !import_lodash.default.isUndefined(input[key])) {
|
|
12306
|
+
picked[key] = import_lodash.default.cloneDeep(input[key]);
|
|
12307
|
+
}
|
|
12308
|
+
});
|
|
12309
|
+
return picked;
|
|
12310
|
+
}
|
|
12032
12311
|
syncCreatedFieldWrapperTitleFieldStepParams(node) {
|
|
12033
12312
|
const mirror = (UPDATE_SETTINGS_STEP_PARAM_MIRRORS_BY_USE[(node == null ? void 0 : node.use) || ""] || []).find(
|
|
12034
12313
|
(item) => item.domain === "props" && item.key === "titleField"
|
|
@@ -13694,6 +13973,111 @@ class FlowSurfacesService {
|
|
|
13694
13973
|
}
|
|
13695
13974
|
return target;
|
|
13696
13975
|
}
|
|
13976
|
+
normalizeExportBlueprintRequest(input) {
|
|
13977
|
+
if (!import_lodash.default.isPlainObject(input)) {
|
|
13978
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces exportBlueprint payload must be an object`);
|
|
13979
|
+
}
|
|
13980
|
+
const unsupportedKeys = Object.keys(input).filter((key) => key !== "target" && key !== "options");
|
|
13981
|
+
if (unsupportedKeys.length) {
|
|
13982
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces exportBlueprint only accepts target and options`);
|
|
13983
|
+
}
|
|
13984
|
+
if (!import_lodash.default.isPlainObject(input.target)) {
|
|
13985
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces exportBlueprint requires target`);
|
|
13986
|
+
}
|
|
13987
|
+
const targetInput = input.target;
|
|
13988
|
+
const target = (0, import_service_utils.buildDefinedPayload)({
|
|
13989
|
+
uid: this.normalizeExportBlueprintLocatorValue(targetInput.uid, "uid"),
|
|
13990
|
+
pageSchemaUid: this.normalizeExportBlueprintLocatorValue(targetInput.pageSchemaUid, "pageSchemaUid"),
|
|
13991
|
+
tabSchemaUid: this.normalizeExportBlueprintLocatorValue(targetInput.tabSchemaUid, "tabSchemaUid"),
|
|
13992
|
+
routeId: this.normalizeExportBlueprintLocatorValue(targetInput.routeId, "routeId")
|
|
13993
|
+
});
|
|
13994
|
+
const unsupportedTargetKeys = Object.keys(targetInput).filter(
|
|
13995
|
+
(key) => !["uid", "pageSchemaUid", "tabSchemaUid", "routeId"].includes(key)
|
|
13996
|
+
);
|
|
13997
|
+
if (unsupportedTargetKeys.length) {
|
|
13998
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces exportBlueprint target only accepts uid, pageSchemaUid, tabSchemaUid or routeId`);
|
|
13999
|
+
}
|
|
14000
|
+
if (!Object.keys(target).length) {
|
|
14001
|
+
(0, import_errors.throwBadRequest)(
|
|
14002
|
+
`flowSurfaces exportBlueprint target requires one of uid, pageSchemaUid, tabSchemaUid or routeId`
|
|
14003
|
+
);
|
|
14004
|
+
}
|
|
14005
|
+
if (Object.keys(target).length > 1) {
|
|
14006
|
+
(0, import_errors.throwBadRequest)(
|
|
14007
|
+
`flowSurfaces exportBlueprint target only accepts exactly one locator: uid, pageSchemaUid, tabSchemaUid or routeId`
|
|
14008
|
+
);
|
|
14009
|
+
}
|
|
14010
|
+
if (target.tabSchemaUid) {
|
|
14011
|
+
(0, import_errors.throwBadRequest)(FLOW_SURFACE_EXPORT_BLUEPRINT_ROOT_ONLY_MESSAGE);
|
|
14012
|
+
}
|
|
14013
|
+
return {
|
|
14014
|
+
target,
|
|
14015
|
+
unsupportedPolicy: this.normalizeExportBlueprintUnsupportedPolicy(input.options)
|
|
14016
|
+
};
|
|
14017
|
+
}
|
|
14018
|
+
normalizeExportBlueprintUnsupportedPolicy(input) {
|
|
14019
|
+
if (import_lodash.default.isUndefined(input)) {
|
|
14020
|
+
return "error";
|
|
14021
|
+
}
|
|
14022
|
+
if (!import_lodash.default.isPlainObject(input)) {
|
|
14023
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces exportBlueprint options must be an object`);
|
|
14024
|
+
}
|
|
14025
|
+
const options = input;
|
|
14026
|
+
const unsupportedKeys = Object.keys(options).filter((key) => key !== "unsupported");
|
|
14027
|
+
if (unsupportedKeys.length) {
|
|
14028
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces exportBlueprint options only accepts unsupported`);
|
|
14029
|
+
}
|
|
14030
|
+
const policy = options.unsupported;
|
|
14031
|
+
if (import_lodash.default.isUndefined(policy)) {
|
|
14032
|
+
return "error";
|
|
14033
|
+
}
|
|
14034
|
+
if (policy === "error" || policy === "warn") {
|
|
14035
|
+
return policy;
|
|
14036
|
+
}
|
|
14037
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces exportBlueprint options.unsupported must be 'error' or 'warn'`);
|
|
14038
|
+
}
|
|
14039
|
+
normalizeExportBlueprintLocatorValue(value, key) {
|
|
14040
|
+
if (import_lodash.default.isNil(value)) {
|
|
14041
|
+
return void 0;
|
|
14042
|
+
}
|
|
14043
|
+
if (typeof value !== "string" && typeof value !== "number") {
|
|
14044
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces exportBlueprint target.${key} must be a string`);
|
|
14045
|
+
}
|
|
14046
|
+
const normalized = String(value).trim();
|
|
14047
|
+
return normalized || void 0;
|
|
14048
|
+
}
|
|
14049
|
+
readRouteString(route, key) {
|
|
14050
|
+
var _a;
|
|
14051
|
+
const routeRecord = route;
|
|
14052
|
+
const value = ((_a = routeRecord == null ? void 0 : routeRecord.get) == null ? void 0 : _a.call(routeRecord, key)) ?? (routeRecord == null ? void 0 : routeRecord[key]);
|
|
14053
|
+
const normalized = typeof value === "string" ? value.trim() : "";
|
|
14054
|
+
return normalized || void 0;
|
|
14055
|
+
}
|
|
14056
|
+
resolveExportBlueprintPageSchemaUid(target, resolved) {
|
|
14057
|
+
const pageSchemaUid = this.readRouteString(resolved.pageRoute, "schemaUid") || (target.pageSchemaUid ? String(target.pageSchemaUid).trim() : "");
|
|
14058
|
+
if (!pageSchemaUid) {
|
|
14059
|
+
(0, import_errors.throwBadRequest)(FLOW_SURFACE_EXPORT_BLUEPRINT_ROOT_ONLY_MESSAGE);
|
|
14060
|
+
}
|
|
14061
|
+
return pageSchemaUid;
|
|
14062
|
+
}
|
|
14063
|
+
async assertExportBlueprintRootTarget(target, resolved, pageSchemaUid, transaction) {
|
|
14064
|
+
const targetUid = target.uid ? String(target.uid).trim() : "";
|
|
14065
|
+
if (!targetUid) {
|
|
14066
|
+
return;
|
|
14067
|
+
}
|
|
14068
|
+
if (targetUid === pageSchemaUid) {
|
|
14069
|
+
return;
|
|
14070
|
+
}
|
|
14071
|
+
const rootPageModel = await this.repository.findModelByParentId(pageSchemaUid, {
|
|
14072
|
+
transaction,
|
|
14073
|
+
subKey: "page",
|
|
14074
|
+
includeAsyncNode: false
|
|
14075
|
+
});
|
|
14076
|
+
if ((rootPageModel == null ? void 0 : rootPageModel.uid) && targetUid === String(rootPageModel.uid).trim()) {
|
|
14077
|
+
return;
|
|
14078
|
+
}
|
|
14079
|
+
(0, import_errors.throwBadRequest)(FLOW_SURFACE_EXPORT_BLUEPRINT_ROOT_ONLY_MESSAGE);
|
|
14080
|
+
}
|
|
13697
14081
|
normalizeContextPath(path) {
|
|
13698
14082
|
if (import_lodash.default.isUndefined(path) || import_lodash.default.isNull(path)) {
|
|
13699
14083
|
return void 0;
|
|
@@ -17448,19 +17832,21 @@ class FlowSurfacesService {
|
|
|
17448
17832
|
}
|
|
17449
17833
|
return JSON.stringify(value);
|
|
17450
17834
|
}
|
|
17451
|
-
buildAIEmployeeActionDedupIdentity(values) {
|
|
17835
|
+
buildAIEmployeeActionDedupIdentity(values, defaultActionWorkContext) {
|
|
17452
17836
|
var _a, _b, _c, _d, _e, _f;
|
|
17453
17837
|
const username = String(((_b = (_a = values == null ? void 0 : values.props) == null ? void 0 : _a.aiEmployee) == null ? void 0 : _b.username) || "").trim();
|
|
17454
17838
|
if (!username) {
|
|
17455
17839
|
return "";
|
|
17456
17840
|
}
|
|
17841
|
+
const workContext = this.normalizeAIEmployeeActionWorkContextForDedupIdentity(
|
|
17842
|
+
(_d = (_c = values == null ? void 0 : values.props) == null ? void 0 : _c.context) == null ? void 0 : _d.workContext,
|
|
17843
|
+
defaultActionWorkContext
|
|
17844
|
+
);
|
|
17457
17845
|
return this.stableSerializeAIEmployeeValue({
|
|
17458
17846
|
username,
|
|
17459
|
-
auto: typeof ((
|
|
17460
|
-
workContext
|
|
17461
|
-
tasks: this.normalizeAIEmployeeTasksForDedupIdentity(
|
|
17462
|
-
import_lodash.default.get(values, ["stepParams", ...AI_EMPLOYEE_TASK_STEP_PARAMS_PATH])
|
|
17463
|
-
),
|
|
17847
|
+
auto: typeof ((_e = values == null ? void 0 : values.props) == null ? void 0 : _e.auto) === "boolean" ? values.props.auto : false,
|
|
17848
|
+
workContext,
|
|
17849
|
+
tasks: this.normalizeAIEmployeeTasksForDedupIdentity(this.readAIEmployeePersistedTasks(values), workContext),
|
|
17464
17850
|
style: {
|
|
17465
17851
|
...AI_EMPLOYEE_DEFAULT_STYLE,
|
|
17466
17852
|
...import_lodash.default.isPlainObject((_f = values == null ? void 0 : values.props) == null ? void 0 : _f.style) ? import_lodash.default.pick(values.props.style, AI_EMPLOYEE_STYLE_PUBLIC_KEYS) : {}
|
|
@@ -17468,11 +17854,35 @@ class FlowSurfacesService {
|
|
|
17468
17854
|
});
|
|
17469
17855
|
}
|
|
17470
17856
|
normalizeAIEmployeeWorkContextForDedupIdentity(value) {
|
|
17471
|
-
return import_lodash.default.castArray(value || []).map(
|
|
17472
|
-
(
|
|
17473
|
-
|
|
17857
|
+
return import_lodash.default.castArray(value || []).map((item) => {
|
|
17858
|
+
if (!import_lodash.default.isPlainObject(item)) {
|
|
17859
|
+
return item;
|
|
17860
|
+
}
|
|
17861
|
+
const output = import_lodash.default.pick(item, AI_EMPLOYEE_WORK_CONTEXT_PUBLIC_KEYS);
|
|
17862
|
+
if (!Object.prototype.hasOwnProperty.call(output, "type") || import_lodash.default.isUndefined(output.type) || output.type === null) {
|
|
17863
|
+
output.type = "flow-model";
|
|
17864
|
+
}
|
|
17865
|
+
return output;
|
|
17866
|
+
});
|
|
17867
|
+
}
|
|
17868
|
+
normalizeAIEmployeeActionWorkContextForDedupIdentity(value, defaultWorkContext) {
|
|
17869
|
+
if (!Array.isArray(value)) {
|
|
17870
|
+
return import_lodash.default.cloneDeep(defaultWorkContext || []);
|
|
17871
|
+
}
|
|
17872
|
+
return this.normalizeAIEmployeeWorkContextForDedupIdentity(value);
|
|
17873
|
+
}
|
|
17874
|
+
normalizeAIEmployeeDefaultActionWorkContextForSelfUid(selfUid) {
|
|
17875
|
+
const uid2 = String(selfUid || "").trim();
|
|
17876
|
+
return uid2 ? [{ type: "flow-model", uid: uid2 }] : [];
|
|
17474
17877
|
}
|
|
17475
|
-
|
|
17878
|
+
normalizeAIEmployeeTaskWorkContextForDedupIdentity(value, defaultWorkContext) {
|
|
17879
|
+
const normalized = this.normalizeAIEmployeeWorkContextForDedupIdentity(value);
|
|
17880
|
+
if (Array.isArray(defaultWorkContext) && !normalized.length) {
|
|
17881
|
+
return import_lodash.default.cloneDeep(defaultWorkContext);
|
|
17882
|
+
}
|
|
17883
|
+
return normalized;
|
|
17884
|
+
}
|
|
17885
|
+
normalizeAIEmployeeTasksForDedupIdentity(value, defaultWorkContext) {
|
|
17476
17886
|
return import_lodash.default.castArray(value || []).map((task) => {
|
|
17477
17887
|
if (!import_lodash.default.isPlainObject(task)) {
|
|
17478
17888
|
return task;
|
|
@@ -17481,9 +17891,19 @@ class FlowSurfacesService {
|
|
|
17481
17891
|
if (import_lodash.default.isPlainObject(output.message)) {
|
|
17482
17892
|
output.message = import_lodash.default.pick(output.message, AI_EMPLOYEE_TASK_MESSAGE_PUBLIC_KEYS);
|
|
17483
17893
|
if (Object.prototype.hasOwnProperty.call(output.message, "workContext")) {
|
|
17484
|
-
output.message.workContext = this.
|
|
17894
|
+
output.message.workContext = this.normalizeAIEmployeeTaskWorkContextForDedupIdentity(
|
|
17895
|
+
output.message.workContext,
|
|
17896
|
+
defaultWorkContext
|
|
17897
|
+
);
|
|
17485
17898
|
}
|
|
17486
17899
|
}
|
|
17900
|
+
if (!import_lodash.default.isPlainObject(output.message) && Array.isArray(defaultWorkContext)) {
|
|
17901
|
+
output.message = {
|
|
17902
|
+
workContext: import_lodash.default.cloneDeep(defaultWorkContext)
|
|
17903
|
+
};
|
|
17904
|
+
} else if (import_lodash.default.isPlainObject(output.message) && !Object.prototype.hasOwnProperty.call(output.message, "workContext")) {
|
|
17905
|
+
output.message.workContext = import_lodash.default.cloneDeep(defaultWorkContext || []);
|
|
17906
|
+
}
|
|
17487
17907
|
if (import_lodash.default.isPlainObject(output.model)) {
|
|
17488
17908
|
output.model = import_lodash.default.pick(output.model, AI_EMPLOYEE_TASK_MODEL_PUBLIC_KEYS);
|
|
17489
17909
|
}
|
|
@@ -17493,25 +17913,38 @@ class FlowSurfacesService {
|
|
|
17493
17913
|
return output;
|
|
17494
17914
|
});
|
|
17495
17915
|
}
|
|
17496
|
-
async assertNoDuplicateAIEmployeeAction(actionName, parentUid, values, transaction) {
|
|
17916
|
+
async assertNoDuplicateAIEmployeeAction(actionName, parentUid, values, transaction, excludeUid) {
|
|
17497
17917
|
var _a;
|
|
17498
|
-
const identity = this.buildAIEmployeeActionDedupIdentity(values);
|
|
17499
|
-
if (!identity) {
|
|
17500
|
-
return;
|
|
17501
|
-
}
|
|
17502
17918
|
const parentNode = await this.repository.findModelById(parentUid, {
|
|
17503
17919
|
transaction,
|
|
17504
17920
|
includeAsyncNode: true
|
|
17505
17921
|
});
|
|
17506
|
-
const
|
|
17922
|
+
const defaultActionWorkContext = this.normalizeAIEmployeeDefaultActionWorkContextForSelfUid(
|
|
17923
|
+
await this.resolveAIEmployeeActionSelfUidFromParentNode(parentNode, transaction)
|
|
17924
|
+
);
|
|
17925
|
+
const identity = this.buildAIEmployeeActionDedupIdentity(values, defaultActionWorkContext);
|
|
17926
|
+
if (!identity) {
|
|
17927
|
+
return;
|
|
17928
|
+
}
|
|
17929
|
+
let duplicate;
|
|
17930
|
+
for (const action of import_lodash.default.castArray(((_a = parentNode == null ? void 0 : parentNode.subModels) == null ? void 0 : _a.actions) || [])) {
|
|
17507
17931
|
if (!this.isAIEmployeeActionUse(action == null ? void 0 : action.use)) {
|
|
17508
|
-
|
|
17932
|
+
continue;
|
|
17509
17933
|
}
|
|
17510
|
-
|
|
17511
|
-
|
|
17512
|
-
|
|
17513
|
-
|
|
17514
|
-
|
|
17934
|
+
if (excludeUid && String((action == null ? void 0 : action.uid) || "") === excludeUid) {
|
|
17935
|
+
continue;
|
|
17936
|
+
}
|
|
17937
|
+
if (this.buildAIEmployeeActionDedupIdentity(
|
|
17938
|
+
{
|
|
17939
|
+
props: action.props,
|
|
17940
|
+
stepParams: action.stepParams
|
|
17941
|
+
},
|
|
17942
|
+
defaultActionWorkContext
|
|
17943
|
+
) === identity) {
|
|
17944
|
+
duplicate = action;
|
|
17945
|
+
break;
|
|
17946
|
+
}
|
|
17947
|
+
}
|
|
17515
17948
|
if (!(duplicate == null ? void 0 : duplicate.uid)) {
|
|
17516
17949
|
return;
|
|
17517
17950
|
}
|
|
@@ -17526,6 +17959,25 @@ class FlowSurfacesService {
|
|
|
17526
17959
|
}
|
|
17527
17960
|
);
|
|
17528
17961
|
}
|
|
17962
|
+
async assertNoDuplicateAIEmployeeActionForUpdateSettings(actionName, current, effectiveNode, transaction) {
|
|
17963
|
+
if (!this.isAIEmployeeActionUse(current == null ? void 0 : current.use)) {
|
|
17964
|
+
return;
|
|
17965
|
+
}
|
|
17966
|
+
const parentUid = String((current == null ? void 0 : current.parentId) || "").trim() || ((current == null ? void 0 : current.uid) ? await this.locator.findParentUid(current.uid, transaction).catch(() => "") : "");
|
|
17967
|
+
if (!parentUid) {
|
|
17968
|
+
return;
|
|
17969
|
+
}
|
|
17970
|
+
await this.assertNoDuplicateAIEmployeeAction(
|
|
17971
|
+
actionName,
|
|
17972
|
+
parentUid,
|
|
17973
|
+
{
|
|
17974
|
+
props: effectiveNode == null ? void 0 : effectiveNode.props,
|
|
17975
|
+
stepParams: effectiveNode == null ? void 0 : effectiveNode.stepParams
|
|
17976
|
+
},
|
|
17977
|
+
transaction,
|
|
17978
|
+
String((current == null ? void 0 : current.uid) || "")
|
|
17979
|
+
);
|
|
17980
|
+
}
|
|
17529
17981
|
hasAIEmployeePublicSettings(settings) {
|
|
17530
17982
|
return import_lodash.default.isPlainObject(settings) && AI_EMPLOYEE_PUBLIC_SETTING_KEYS.some((key) => Object.prototype.hasOwnProperty.call(settings, key));
|
|
17531
17983
|
}
|
|
@@ -17580,11 +18032,24 @@ class FlowSurfacesService {
|
|
|
17580
18032
|
var _a;
|
|
17581
18033
|
const stepTasks = import_lodash.default.get(current, ["stepParams", ...AI_EMPLOYEE_TASK_STEP_PARAMS_PATH]);
|
|
17582
18034
|
if (Array.isArray(stepTasks)) {
|
|
17583
|
-
return stepTasks;
|
|
18035
|
+
return this.normalizeAIEmployeeLegacyInheritedTaskWorkContext(stepTasks);
|
|
17584
18036
|
}
|
|
17585
|
-
const legacyPropsTasks = (_a = current == null ? void 0 : current.props) == null ? void 0 : _a.tasks;
|
|
18037
|
+
const legacyPropsTasks = this.normalizeAIEmployeeLegacyInheritedTaskWorkContext((_a = current == null ? void 0 : current.props) == null ? void 0 : _a.tasks);
|
|
17586
18038
|
return Array.isArray(legacyPropsTasks) ? legacyPropsTasks : [];
|
|
17587
18039
|
}
|
|
18040
|
+
normalizeAIEmployeeLegacyInheritedTaskWorkContext(tasks) {
|
|
18041
|
+
if (!Array.isArray(tasks)) {
|
|
18042
|
+
return tasks;
|
|
18043
|
+
}
|
|
18044
|
+
return tasks.map((task) => {
|
|
18045
|
+
if (!import_lodash.default.isPlainObject(task) || !import_lodash.default.isPlainObject(task.message) || task.message.workContext !== null) {
|
|
18046
|
+
return task;
|
|
18047
|
+
}
|
|
18048
|
+
const nextTask = import_lodash.default.cloneDeep(task);
|
|
18049
|
+
delete nextTask.message.workContext;
|
|
18050
|
+
return nextTask;
|
|
18051
|
+
});
|
|
18052
|
+
}
|
|
17588
18053
|
buildAIEmployeeTaskStepParams(tasks) {
|
|
17589
18054
|
const stepParams = {};
|
|
17590
18055
|
import_lodash.default.set(stepParams, AI_EMPLOYEE_TASK_STEP_PARAMS_PATH, import_lodash.default.cloneDeep(tasks));
|
|
@@ -17613,7 +18078,7 @@ class FlowSurfacesService {
|
|
|
17613
18078
|
if (!this.isAIEmployeeActionUse(current == null ? void 0 : current.use)) {
|
|
17614
18079
|
return;
|
|
17615
18080
|
}
|
|
17616
|
-
const legacyPropsTasks = (_a = current == null ? void 0 : current.props) == null ? void 0 : _a.tasks;
|
|
18081
|
+
const legacyPropsTasks = this.normalizeAIEmployeeLegacyInheritedTaskWorkContext((_a = current == null ? void 0 : current.props) == null ? void 0 : _a.tasks);
|
|
17617
18082
|
const hasLegacyPropsTasks = Array.isArray(legacyPropsTasks);
|
|
17618
18083
|
const hasNextStepTasks = import_lodash.default.has(nextPayload, ["stepParams", ...AI_EMPLOYEE_TASK_STEP_PARAMS_PATH]);
|
|
17619
18084
|
const currentStepTasks = import_lodash.default.get(current, ["stepParams", ...AI_EMPLOYEE_TASK_STEP_PARAMS_PATH]);
|
|
@@ -17785,6 +18250,20 @@ class FlowSurfacesService {
|
|
|
17785
18250
|
};
|
|
17786
18251
|
});
|
|
17787
18252
|
}
|
|
18253
|
+
normalizeAIEmployeeEffectiveActionWorkContext(actionName, settings, currentProps, options) {
|
|
18254
|
+
var _a;
|
|
18255
|
+
const hasSettingsWorkContext = Object.prototype.hasOwnProperty.call(settings, "workContext");
|
|
18256
|
+
const currentWorkContext = (_a = currentProps == null ? void 0 : currentProps.context) == null ? void 0 : _a.workContext;
|
|
18257
|
+
if (!hasSettingsWorkContext && !Array.isArray(currentWorkContext) && !options.requireUsername && !options.selfUid) {
|
|
18258
|
+
return void 0;
|
|
18259
|
+
}
|
|
18260
|
+
const rawWorkContext = hasSettingsWorkContext ? settings.workContext : Array.isArray(currentWorkContext) ? currentWorkContext : [{ type: "flow-model", target: "self" }];
|
|
18261
|
+
return this.normalizeAIEmployeeWorkContext(actionName, rawWorkContext, {
|
|
18262
|
+
selfUid: options.selfUid,
|
|
18263
|
+
keyMap: options.keyMap,
|
|
18264
|
+
path: "settings.workContext"
|
|
18265
|
+
});
|
|
18266
|
+
}
|
|
17788
18267
|
normalizeAIEmployeeTaskModel(actionName, path, value) {
|
|
17789
18268
|
if (import_lodash.default.isUndefined(value) || value === null) {
|
|
17790
18269
|
return value;
|
|
@@ -18100,6 +18579,7 @@ ${AI_EMPLOYEE_CURRENT_RECORD_PROMPT_VARIABLE}` : AI_EMPLOYEE_CURRENT_RECORD_PROM
|
|
|
18100
18579
|
);
|
|
18101
18580
|
}
|
|
18102
18581
|
async normalizeAIEmployeeStepParamTasksForUpdateSettings(current, nextPayload, writeTarget, options) {
|
|
18582
|
+
var _a, _b, _c, _d;
|
|
18103
18583
|
if (!this.isAIEmployeeActionUse(current == null ? void 0 : current.use) || !import_lodash.default.has(nextPayload, ["stepParams", ...AI_EMPLOYEE_TASK_STEP_PARAMS_PATH])) {
|
|
18104
18584
|
return;
|
|
18105
18585
|
}
|
|
@@ -18108,15 +18588,63 @@ ${AI_EMPLOYEE_CURRENT_RECORD_PROMPT_VARIABLE}` : AI_EMPLOYEE_CURRENT_RECORD_PROM
|
|
|
18108
18588
|
return;
|
|
18109
18589
|
}
|
|
18110
18590
|
const actionName = options.openViewActionName || "updateSettings";
|
|
18111
|
-
const
|
|
18591
|
+
const selfUid = await this.resolveAIEmployeeActionSelfUid(current || { uid: writeTarget.uid }, options.transaction);
|
|
18592
|
+
const currentPropsForDefault = import_lodash.default.mergeWith(
|
|
18593
|
+
{},
|
|
18594
|
+
import_lodash.default.isPlainObject(current == null ? void 0 : current.props) ? current.props : {},
|
|
18595
|
+
import_lodash.default.isPlainObject(nextPayload.props) ? nextPayload.props : {},
|
|
18596
|
+
(_currentValue, nextValue) => {
|
|
18597
|
+
if (Array.isArray(nextValue)) {
|
|
18598
|
+
return import_lodash.default.cloneDeep(nextValue);
|
|
18599
|
+
}
|
|
18600
|
+
return void 0;
|
|
18601
|
+
}
|
|
18602
|
+
);
|
|
18603
|
+
const defaultWorkContext = this.normalizeAIEmployeeEffectiveActionWorkContext(
|
|
18112
18604
|
actionName,
|
|
18113
|
-
|
|
18114
|
-
|
|
18605
|
+
{},
|
|
18606
|
+
currentPropsForDefault,
|
|
18115
18607
|
{
|
|
18116
|
-
selfUid
|
|
18117
|
-
|
|
18608
|
+
selfUid,
|
|
18609
|
+
requireUsername: true
|
|
18118
18610
|
}
|
|
18119
18611
|
);
|
|
18612
|
+
const currentTasks = this.readAIEmployeePersistedTasks(current);
|
|
18613
|
+
const previousActionWorkContext = this.normalizeAIEmployeeActionWorkContextForDedupIdentity(
|
|
18614
|
+
(_b = (_a = current == null ? void 0 : current.props) == null ? void 0 : _a.context) == null ? void 0 : _b.workContext,
|
|
18615
|
+
this.normalizeAIEmployeeDefaultActionWorkContextForSelfUid(selfUid)
|
|
18616
|
+
);
|
|
18617
|
+
const nextActionWorkContext = this.normalizeAIEmployeeActionWorkContextForDedupIdentity(
|
|
18618
|
+
(_c = currentPropsForDefault == null ? void 0 : currentPropsForDefault.context) == null ? void 0 : _c.workContext,
|
|
18619
|
+
defaultWorkContext
|
|
18620
|
+
);
|
|
18621
|
+
if (Array.isArray(defaultWorkContext) && !import_lodash.default.isEqual((_d = currentPropsForDefault == null ? void 0 : currentPropsForDefault.context) == null ? void 0 : _d.workContext, defaultWorkContext)) {
|
|
18622
|
+
nextPayload.props = import_lodash.default.mergeWith(
|
|
18623
|
+
{},
|
|
18624
|
+
currentPropsForDefault,
|
|
18625
|
+
{
|
|
18626
|
+
context: {
|
|
18627
|
+
workContext: import_lodash.default.cloneDeep(defaultWorkContext)
|
|
18628
|
+
}
|
|
18629
|
+
},
|
|
18630
|
+
(_currentValue, nextValue) => {
|
|
18631
|
+
if (Array.isArray(nextValue)) {
|
|
18632
|
+
return import_lodash.default.cloneDeep(nextValue);
|
|
18633
|
+
}
|
|
18634
|
+
return void 0;
|
|
18635
|
+
}
|
|
18636
|
+
);
|
|
18637
|
+
}
|
|
18638
|
+
const currentTasksForNormalization = this.rebaseAIEmployeeInheritedTaskWorkContext(
|
|
18639
|
+
currentTasks,
|
|
18640
|
+
previousActionWorkContext,
|
|
18641
|
+
nextActionWorkContext
|
|
18642
|
+
);
|
|
18643
|
+
const normalizedTasks = this.normalizeAIEmployeeTasks(actionName, tasks, currentTasksForNormalization, {
|
|
18644
|
+
selfUid,
|
|
18645
|
+
defaultWorkContext,
|
|
18646
|
+
path: "stepParams.shortcutSettings.editTasks.tasks"
|
|
18647
|
+
});
|
|
18120
18648
|
import_lodash.default.set(nextPayload, ["stepParams", ...AI_EMPLOYEE_TASK_STEP_PARAMS_PATH], normalizedTasks);
|
|
18121
18649
|
}
|
|
18122
18650
|
normalizeAIEmployeeTaskMessage(actionName, path, value, existing, options) {
|
|
@@ -18145,13 +18673,18 @@ ${AI_EMPLOYEE_CURRENT_RECORD_PROMPT_VARIABLE}` : AI_EMPLOYEE_CURRENT_RECORD_PROM
|
|
|
18145
18673
|
if (Object.prototype.hasOwnProperty.call(nextMessage, "user") && typeof nextMessage.user !== "string") {
|
|
18146
18674
|
(0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} ${path}.user must be a string`);
|
|
18147
18675
|
}
|
|
18148
|
-
if (
|
|
18676
|
+
if (value.workContext === null) {
|
|
18677
|
+
delete nextMessage.workContext;
|
|
18678
|
+
} else if (Object.prototype.hasOwnProperty.call(value, "workContext")) {
|
|
18149
18679
|
nextMessage.workContext = this.normalizeAIEmployeeWorkContext(actionName, value.workContext, {
|
|
18150
18680
|
selfUid: options.selfUid,
|
|
18151
18681
|
keyMap: options.keyMap,
|
|
18152
18682
|
path: `${path}.workContext`
|
|
18153
18683
|
});
|
|
18154
18684
|
}
|
|
18685
|
+
if (!Object.prototype.hasOwnProperty.call(nextMessage, "workContext") && this.shouldMaterializeAIEmployeeTaskDefaultWorkContext(options.defaultWorkContext)) {
|
|
18686
|
+
nextMessage.workContext = import_lodash.default.cloneDeep(options.defaultWorkContext);
|
|
18687
|
+
}
|
|
18155
18688
|
return nextMessage;
|
|
18156
18689
|
}
|
|
18157
18690
|
normalizeAIEmployeeTaskPatch(actionName, patch, existing, options) {
|
|
@@ -18175,7 +18708,8 @@ ${AI_EMPLOYEE_CURRENT_RECORD_PROMPT_VARIABLE}` : AI_EMPLOYEE_CURRENT_RECORD_PROM
|
|
|
18175
18708
|
if (key === "message") {
|
|
18176
18709
|
next.message = this.normalizeAIEmployeeTaskMessage(actionName, `${options.path}.message`, value, next.message, {
|
|
18177
18710
|
selfUid: options.selfUid,
|
|
18178
|
-
keyMap: options.keyMap
|
|
18711
|
+
keyMap: options.keyMap,
|
|
18712
|
+
defaultWorkContext: options.defaultWorkContext
|
|
18179
18713
|
});
|
|
18180
18714
|
return;
|
|
18181
18715
|
}
|
|
@@ -18225,6 +18759,9 @@ ${AI_EMPLOYEE_CURRENT_RECORD_PROMPT_VARIABLE}` : AI_EMPLOYEE_CURRENT_RECORD_PROM
|
|
|
18225
18759
|
if (!import_lodash.default.isPlainObject(next.message)) {
|
|
18226
18760
|
next.message = {};
|
|
18227
18761
|
}
|
|
18762
|
+
if (!Object.prototype.hasOwnProperty.call(next.message, "workContext") && this.shouldMaterializeAIEmployeeTaskDefaultWorkContext(options.defaultWorkContext)) {
|
|
18763
|
+
next.message.workContext = import_lodash.default.cloneDeep(options.defaultWorkContext);
|
|
18764
|
+
}
|
|
18228
18765
|
if (import_lodash.default.isPlainObject(next.skillSettings)) {
|
|
18229
18766
|
if (Array.isArray(next.skillSettings.skills) && !Object.prototype.hasOwnProperty.call(next.skillSettings, "skillsVersion")) {
|
|
18230
18767
|
next.skillSettings.skillsVersion = 2;
|
|
@@ -18251,10 +18788,52 @@ ${AI_EMPLOYEE_CURRENT_RECORD_PROMPT_VARIABLE}` : AI_EMPLOYEE_CURRENT_RECORD_PROM
|
|
|
18251
18788
|
nextTasks[index] = this.normalizeAIEmployeeTaskPatch(actionName, task, existingTasks[index], {
|
|
18252
18789
|
selfUid: options.selfUid,
|
|
18253
18790
|
keyMap: options.keyMap,
|
|
18254
|
-
path: `${options.path}[${index}]
|
|
18791
|
+
path: `${options.path}[${index}]`,
|
|
18792
|
+
defaultWorkContext: options.defaultWorkContext
|
|
18255
18793
|
});
|
|
18256
18794
|
});
|
|
18257
|
-
return nextTasks;
|
|
18795
|
+
return this.withAIEmployeeTaskDefaultWorkContext(nextTasks, options.defaultWorkContext);
|
|
18796
|
+
}
|
|
18797
|
+
withAIEmployeeTaskDefaultWorkContext(tasks, defaultWorkContext) {
|
|
18798
|
+
const nextTasks = Array.isArray(tasks) ? import_lodash.default.cloneDeep(tasks) : [];
|
|
18799
|
+
if (!this.shouldMaterializeAIEmployeeTaskDefaultWorkContext(defaultWorkContext)) {
|
|
18800
|
+
return nextTasks;
|
|
18801
|
+
}
|
|
18802
|
+
return nextTasks.map((task) => {
|
|
18803
|
+
if (!import_lodash.default.isPlainObject(task)) {
|
|
18804
|
+
return task;
|
|
18805
|
+
}
|
|
18806
|
+
const nextTask = import_lodash.default.cloneDeep(task);
|
|
18807
|
+
if (!import_lodash.default.isPlainObject(nextTask.message)) {
|
|
18808
|
+
nextTask.message = {
|
|
18809
|
+
workContext: import_lodash.default.cloneDeep(defaultWorkContext)
|
|
18810
|
+
};
|
|
18811
|
+
} else if (!Object.prototype.hasOwnProperty.call(nextTask.message, "workContext")) {
|
|
18812
|
+
nextTask.message.workContext = import_lodash.default.cloneDeep(defaultWorkContext);
|
|
18813
|
+
}
|
|
18814
|
+
return nextTask;
|
|
18815
|
+
});
|
|
18816
|
+
}
|
|
18817
|
+
shouldMaterializeAIEmployeeTaskDefaultWorkContext(defaultWorkContext) {
|
|
18818
|
+
return Array.isArray(defaultWorkContext) && defaultWorkContext.length > 0;
|
|
18819
|
+
}
|
|
18820
|
+
rebaseAIEmployeeInheritedTaskWorkContext(currentTasks, previousActionWorkContext, nextActionWorkContext) {
|
|
18821
|
+
const tasks = this.normalizeAIEmployeeLegacyInheritedTaskWorkContext(currentTasks) || [];
|
|
18822
|
+
if (!previousActionWorkContext.length || import_lodash.default.isEqual(previousActionWorkContext, nextActionWorkContext)) {
|
|
18823
|
+
return tasks;
|
|
18824
|
+
}
|
|
18825
|
+
return tasks.map((task) => {
|
|
18826
|
+
const nextTask = import_lodash.default.cloneDeep(task);
|
|
18827
|
+
if (import_lodash.default.isPlainObject(nextTask == null ? void 0 : nextTask.message)) {
|
|
18828
|
+
const currentTaskWorkContext = this.normalizeAIEmployeeWorkContextForDedupIdentity(
|
|
18829
|
+
nextTask.message.workContext
|
|
18830
|
+
);
|
|
18831
|
+
if (import_lodash.default.isEqual(currentTaskWorkContext, previousActionWorkContext)) {
|
|
18832
|
+
delete nextTask.message.workContext;
|
|
18833
|
+
}
|
|
18834
|
+
}
|
|
18835
|
+
return nextTask;
|
|
18836
|
+
});
|
|
18258
18837
|
}
|
|
18259
18838
|
normalizeAIEmployeeActionSettingsReferences(actionName, settings, options) {
|
|
18260
18839
|
if (!this.hasAIEmployeePublicSettings(settings)) {
|
|
@@ -18268,15 +18847,22 @@ ${AI_EMPLOYEE_CURRENT_RECORD_PROMPT_VARIABLE}` : AI_EMPLOYEE_CURRENT_RECORD_PROM
|
|
|
18268
18847
|
});
|
|
18269
18848
|
}
|
|
18270
18849
|
if (Object.prototype.hasOwnProperty.call(nextSettings, "tasks")) {
|
|
18850
|
+
const defaultWorkContext = this.normalizeAIEmployeeEffectiveActionWorkContext(
|
|
18851
|
+
actionName,
|
|
18852
|
+
nextSettings,
|
|
18853
|
+
{},
|
|
18854
|
+
options
|
|
18855
|
+
);
|
|
18271
18856
|
nextSettings.tasks = this.normalizeAIEmployeeTasks(actionName, nextSettings.tasks, [], {
|
|
18272
18857
|
...options,
|
|
18273
|
-
path: "settings.tasks"
|
|
18858
|
+
path: "settings.tasks",
|
|
18859
|
+
defaultWorkContext
|
|
18274
18860
|
});
|
|
18275
18861
|
}
|
|
18276
18862
|
return nextSettings;
|
|
18277
18863
|
}
|
|
18278
18864
|
async normalizeAIEmployeeActionPublicSettings(actionName, settings, options) {
|
|
18279
|
-
var _a, _b;
|
|
18865
|
+
var _a, _b, _c, _d;
|
|
18280
18866
|
this.assertAIEmployeePluginEnabled(actionName, options.enabledPackages);
|
|
18281
18867
|
if (!import_lodash.default.isPlainObject(settings)) {
|
|
18282
18868
|
(0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} AI employee settings must be an object`);
|
|
@@ -18296,6 +18882,17 @@ ${AI_EMPLOYEE_CURRENT_RECORD_PROMPT_VARIABLE}` : AI_EMPLOYEE_CURRENT_RECORD_PROM
|
|
|
18296
18882
|
}
|
|
18297
18883
|
const props = {};
|
|
18298
18884
|
const stepParams = {};
|
|
18885
|
+
const effectiveActionWorkContext = this.normalizeAIEmployeeEffectiveActionWorkContext(
|
|
18886
|
+
actionName,
|
|
18887
|
+
settings,
|
|
18888
|
+
currentProps,
|
|
18889
|
+
options
|
|
18890
|
+
);
|
|
18891
|
+
const previousActionWorkContext = this.normalizeAIEmployeeActionWorkContextForDedupIdentity(
|
|
18892
|
+
(_c = currentProps == null ? void 0 : currentProps.context) == null ? void 0 : _c.workContext,
|
|
18893
|
+
this.normalizeAIEmployeeDefaultActionWorkContextForSelfUid(options.selfUid)
|
|
18894
|
+
);
|
|
18895
|
+
const nextActionWorkContext = this.normalizeAIEmployeeWorkContextForDedupIdentity(effectiveActionWorkContext);
|
|
18299
18896
|
if (effectiveUsername && (hasUsername || options.requireUsername)) {
|
|
18300
18897
|
props.aiEmployee = {
|
|
18301
18898
|
...import_lodash.default.isPlainObject(currentProps.aiEmployee) ? import_lodash.default.cloneDeep(currentProps.aiEmployee) : {},
|
|
@@ -18309,28 +18906,25 @@ ${AI_EMPLOYEE_CURRENT_RECORD_PROMPT_VARIABLE}` : AI_EMPLOYEE_CURRENT_RECORD_PROM
|
|
|
18309
18906
|
}
|
|
18310
18907
|
props.auto = auto;
|
|
18311
18908
|
}
|
|
18312
|
-
if (Object.prototype.hasOwnProperty.call(settings, "workContext") || options.requireUsername) {
|
|
18313
|
-
const rawWorkContext = Object.prototype.hasOwnProperty.call(settings, "workContext") ? settings.workContext : [{ type: "flow-model", target: "self" }];
|
|
18909
|
+
if (Array.isArray(effectiveActionWorkContext) && (Object.prototype.hasOwnProperty.call(settings, "workContext") || options.requireUsername || !import_lodash.default.isEqual((_d = currentProps == null ? void 0 : currentProps.context) == null ? void 0 : _d.workContext, effectiveActionWorkContext))) {
|
|
18314
18910
|
props.context = {
|
|
18315
18911
|
...import_lodash.default.isPlainObject(currentProps.context) ? import_lodash.default.cloneDeep(currentProps.context) : {},
|
|
18316
|
-
workContext:
|
|
18317
|
-
selfUid: options.selfUid,
|
|
18318
|
-
keyMap: options.keyMap,
|
|
18319
|
-
path: "settings.workContext"
|
|
18320
|
-
})
|
|
18912
|
+
workContext: import_lodash.default.cloneDeep(effectiveActionWorkContext)
|
|
18321
18913
|
};
|
|
18322
18914
|
}
|
|
18323
18915
|
if (Object.prototype.hasOwnProperty.call(settings, "tasks")) {
|
|
18324
|
-
const
|
|
18325
|
-
|
|
18326
|
-
|
|
18327
|
-
|
|
18328
|
-
|
|
18329
|
-
selfUid: options.selfUid,
|
|
18330
|
-
keyMap: options.keyMap,
|
|
18331
|
-
path: "settings.tasks"
|
|
18332
|
-
}
|
|
18916
|
+
const currentTasks = this.readAIEmployeePersistedTasks(options.current);
|
|
18917
|
+
const currentTasksForNormalization = this.rebaseAIEmployeeInheritedTaskWorkContext(
|
|
18918
|
+
currentTasks,
|
|
18919
|
+
previousActionWorkContext,
|
|
18920
|
+
nextActionWorkContext
|
|
18333
18921
|
);
|
|
18922
|
+
const normalizedTasks = this.normalizeAIEmployeeTasks(actionName, settings.tasks, currentTasksForNormalization, {
|
|
18923
|
+
selfUid: options.selfUid,
|
|
18924
|
+
keyMap: options.keyMap,
|
|
18925
|
+
path: "settings.tasks",
|
|
18926
|
+
defaultWorkContext: effectiveActionWorkContext
|
|
18927
|
+
});
|
|
18334
18928
|
const validation = options.promptContext && normalizedTasks.length ? await this.buildAIEmployeePromptValidationContext(
|
|
18335
18929
|
actionName,
|
|
18336
18930
|
[
|
|
@@ -18351,6 +18945,17 @@ ${AI_EMPLOYEE_CURRENT_RECORD_PROMPT_VARIABLE}` : AI_EMPLOYEE_CURRENT_RECORD_PROM
|
|
|
18351
18945
|
const tasks = this.appendAIEmployeeCurrentRecordPromptVariableToTasks(normalizedTasks, validation);
|
|
18352
18946
|
this.assertAIEmployeeTaskPromptVariablesAllowed(actionName, tasks, validation);
|
|
18353
18947
|
import_lodash.default.merge(stepParams, this.buildAIEmployeeTaskStepParams(tasks));
|
|
18948
|
+
} else if (!options.skipExistingTaskWorkContextRebase && Object.prototype.hasOwnProperty.call(settings, "workContext") && !import_lodash.default.isEqual(previousActionWorkContext, nextActionWorkContext)) {
|
|
18949
|
+
const currentTasks = this.readAIEmployeePersistedTasks(options.current);
|
|
18950
|
+
const rebasedTasks = this.rebaseAIEmployeeInheritedTaskWorkContext(
|
|
18951
|
+
currentTasks,
|
|
18952
|
+
previousActionWorkContext,
|
|
18953
|
+
nextActionWorkContext
|
|
18954
|
+
);
|
|
18955
|
+
const tasks = this.withAIEmployeeTaskDefaultWorkContext(rebasedTasks, effectiveActionWorkContext);
|
|
18956
|
+
if (tasks.length) {
|
|
18957
|
+
import_lodash.default.merge(stepParams, this.buildAIEmployeeTaskStepParams(tasks));
|
|
18958
|
+
}
|
|
18354
18959
|
}
|
|
18355
18960
|
if (Object.prototype.hasOwnProperty.call(settings, "style") || options.requireUsername) {
|
|
18356
18961
|
const style = Object.prototype.hasOwnProperty.call(settings, "style") ? settings.style : {};
|
|
@@ -18392,7 +18997,16 @@ ${AI_EMPLOYEE_CURRENT_RECORD_PROMPT_VARIABLE}` : AI_EMPLOYEE_CURRENT_RECORD_PROM
|
|
|
18392
18997
|
transaction,
|
|
18393
18998
|
includeAsyncNode: true
|
|
18394
18999
|
});
|
|
18395
|
-
|
|
19000
|
+
return await this.resolveAIEmployeeActionSelfUidFromParentNode(parentNode, transaction) || parentUid;
|
|
19001
|
+
}
|
|
19002
|
+
async resolveAIEmployeeActionSelfUidFromParentNode(parentNode, transaction) {
|
|
19003
|
+
const parentUid = String((parentNode == null ? void 0 : parentNode.uid) || "").trim();
|
|
19004
|
+
if (!parentUid) {
|
|
19005
|
+
return "";
|
|
19006
|
+
}
|
|
19007
|
+
if (["TableActionsColumnModel", "ListItemModel", "GridCardItemModel", "CommentItemModel"].includes(
|
|
19008
|
+
String((parentNode == null ? void 0 : parentNode.use) || "")
|
|
19009
|
+
)) {
|
|
18396
19010
|
const ownerUid = String((parentNode == null ? void 0 : parentNode.parentId) || "").trim() || ((parentNode == null ? void 0 : parentNode.uid) ? await this.locator.findParentUid(parentNode.uid, transaction).catch(() => "") : "");
|
|
18397
19011
|
return ownerUid || parentUid;
|
|
18398
19012
|
}
|
|
@@ -18441,13 +19055,14 @@ ${AI_EMPLOYEE_CURRENT_RECORD_PROMPT_VARIABLE}` : AI_EMPLOYEE_CURRENT_RECORD_PROM
|
|
|
18441
19055
|
}
|
|
18442
19056
|
const normalizedDefaultFilter = (0, import_service_utils.hasOwnDefined)(changes, "defaultFilter") ? this.normalizeFilterActionDefaultFilterValue(changes.defaultFilter) : void 0;
|
|
18443
19057
|
const stepParams = {};
|
|
18444
|
-
if ((0, import_service_utils.hasDefinedValue)(changes, ["title", "tooltip", "icon", "type", "danger", "color", "linkageRules"])) {
|
|
19058
|
+
if ((0, import_service_utils.hasDefinedValue)(changes, ["title", "tooltip", "icon", "iconOnly", "type", "danger", "color", "linkageRules"])) {
|
|
18445
19059
|
stepParams.buttonSettings = {
|
|
18446
|
-
...(0, import_service_utils.hasDefinedValue)(changes, ["title", "tooltip", "icon", "type", "danger", "color"]) ? {
|
|
19060
|
+
...(0, import_service_utils.hasDefinedValue)(changes, ["title", "tooltip", "icon", "iconOnly", "type", "danger", "color"]) ? {
|
|
18447
19061
|
general: (0, import_service_utils.buildDefinedPayload)({
|
|
18448
19062
|
title: changes.title,
|
|
18449
19063
|
tooltip: changes.tooltip,
|
|
18450
19064
|
icon: changes.icon,
|
|
19065
|
+
iconOnly: changes.iconOnly,
|
|
18451
19066
|
type: changes.type,
|
|
18452
19067
|
danger: changes.danger,
|
|
18453
19068
|
color: changes.color
|
|
@@ -18657,6 +19272,7 @@ ${AI_EMPLOYEE_CURRENT_RECORD_PROMPT_VARIABLE}` : AI_EMPLOYEE_CURRENT_RECORD_PROM
|
|
|
18657
19272
|
title: changes.title,
|
|
18658
19273
|
tooltip: changes.tooltip,
|
|
18659
19274
|
icon: changes.icon,
|
|
19275
|
+
iconOnly: changes.iconOnly,
|
|
18660
19276
|
type: changes.type,
|
|
18661
19277
|
htmlType: changes.htmlType,
|
|
18662
19278
|
position: changes.position,
|
|
@@ -18786,6 +19402,11 @@ ${AI_EMPLOYEE_CURRENT_RECORD_PROMPT_VARIABLE}` : AI_EMPLOYEE_CURRENT_RECORD_PROM
|
|
|
18786
19402
|
useStrictOnly: input.useStrictOnly
|
|
18787
19403
|
});
|
|
18788
19404
|
}
|
|
19405
|
+
isCollectionTitleField(collection, fieldName) {
|
|
19406
|
+
const normalizedFieldName = String(fieldName || "").trim();
|
|
19407
|
+
const titleFieldName = String((0, import_service_helpers.getCollectionTitleFieldName)(collection) || "").trim();
|
|
19408
|
+
return !!normalizedFieldName && normalizedFieldName === titleFieldName;
|
|
19409
|
+
}
|
|
18789
19410
|
resolveAssociationLeafDisplaySemantics(field, dataSourceKey, enabledPackages) {
|
|
18790
19411
|
const registeredBinding = this.resolveRegisteredFieldBinding({
|
|
18791
19412
|
containerUse: "DetailsItemModel",
|
|
@@ -18821,6 +19442,9 @@ ${AI_EMPLOYEE_CURRENT_RECORD_PROMPT_VARIABLE}` : AI_EMPLOYEE_CURRENT_RECORD_PROM
|
|
|
18821
19442
|
}
|
|
18822
19443
|
buildFieldMenuDirectCandidates(input) {
|
|
18823
19444
|
const collection = this.getCollection(input.resourceInit.dataSourceKey, input.resourceInit.collectionName);
|
|
19445
|
+
const explicitDefaultFieldPaths = (0, import_default_action_popup.collectFlowSurfaceDefaultActionPopupFieldGroupFieldPaths)(
|
|
19446
|
+
input.defaultFieldGroups
|
|
19447
|
+
);
|
|
18824
19448
|
return (0, import_service_helpers.getCollectionFields)(collection).flatMap((field) => {
|
|
18825
19449
|
var _a;
|
|
18826
19450
|
const fieldName = (0, import_service_helpers.getFieldName)(field);
|
|
@@ -18831,6 +19455,9 @@ ${AI_EMPLOYEE_CURRENT_RECORD_PROMPT_VARIABLE}` : AI_EMPLOYEE_CURRENT_RECORD_PROM
|
|
|
18831
19455
|
if (input.generatedPopupOnly && !(0, import_default_action_popup.isFlowSurfaceDefaultActionPopupBusinessField)(field)) {
|
|
18832
19456
|
return [];
|
|
18833
19457
|
}
|
|
19458
|
+
if ((0, import_relation_backing_foreign_key.isRelationBackingForeignKeyField)(collection, field) && !explicitDefaultFieldPaths.has(fieldName)) {
|
|
19459
|
+
return [];
|
|
19460
|
+
}
|
|
18834
19461
|
if (input.mode === "table" && ((_a = field == null ? void 0 : field.options) == null ? void 0 : _a.treeChildren)) {
|
|
18835
19462
|
return [];
|
|
18836
19463
|
}
|
|
@@ -18918,6 +19545,9 @@ ${AI_EMPLOYEE_CURRENT_RECORD_PROMPT_VARIABLE}` : AI_EMPLOYEE_CURRENT_RECORD_PROM
|
|
|
18918
19545
|
if (!targetFieldName) {
|
|
18919
19546
|
continue;
|
|
18920
19547
|
}
|
|
19548
|
+
if ((0, import_relation_backing_foreign_key.isRelationBackingForeignKeyField)(targetCollection, targetField) && !this.isCollectionTitleField(targetCollection, targetFieldName)) {
|
|
19549
|
+
continue;
|
|
19550
|
+
}
|
|
18921
19551
|
nextCandidates.push({
|
|
18922
19552
|
field: targetField,
|
|
18923
19553
|
fieldPath: `${associationPathName}.${targetFieldName}`,
|
|
@@ -19092,7 +19722,7 @@ ${AI_EMPLOYEE_CURRENT_RECORD_PROMPT_VARIABLE}` : AI_EMPLOYEE_CURRENT_RECORD_PROM
|
|
|
19092
19722
|
const getFields = (targetCollection) => (0, import_service_helpers.getCollectionFields)(targetCollection);
|
|
19093
19723
|
const isFilterFieldVisible = (field) => (0, import_service_helpers.getFieldFilterable)(field) !== false && !!(0, import_service_helpers.getFieldInterface)(field);
|
|
19094
19724
|
const directFields = getFields(collection).filter(
|
|
19095
|
-
(field) => ["FilterFormBlockModel", "FilterFormGridModel", "FilterFormItemModel"].includes(input.ownerUse) ? isFilterFieldVisible(field) : !!(0, import_service_helpers.getFieldInterface)(field)
|
|
19725
|
+
(field) => !(0, import_relation_backing_foreign_key.isRelationBackingForeignKeyField)(collection, field) && (["FilterFormBlockModel", "FilterFormGridModel", "FilterFormItemModel"].includes(input.ownerUse) ? isFilterFieldVisible(field) : !!(0, import_service_helpers.getFieldInterface)(field))
|
|
19096
19726
|
);
|
|
19097
19727
|
if (!directFields.length && !collection) {
|
|
19098
19728
|
return [];
|
|
@@ -19106,9 +19736,13 @@ ${AI_EMPLOYEE_CURRENT_RECORD_PROMPT_VARIABLE}` : AI_EMPLOYEE_CURRENT_RECORD_PROM
|
|
|
19106
19736
|
if (!(0, import_service_helpers.isAssociationField)(field) || !targetCollection) {
|
|
19107
19737
|
return [];
|
|
19108
19738
|
}
|
|
19109
|
-
return getFields(targetCollection).filter(
|
|
19110
|
-
|
|
19111
|
-
|
|
19739
|
+
return getFields(targetCollection).filter((targetField) => {
|
|
19740
|
+
const targetFieldName = (0, import_service_helpers.getFieldName)(targetField);
|
|
19741
|
+
if ((0, import_relation_backing_foreign_key.isRelationBackingForeignKeyField)(targetCollection, targetField) && !this.isCollectionTitleField(targetCollection, targetFieldName)) {
|
|
19742
|
+
return false;
|
|
19743
|
+
}
|
|
19744
|
+
return ["FilterFormBlockModel", "FilterFormGridModel", "FilterFormItemModel"].includes(input.ownerUse) ? isFilterFieldVisible(targetField) : !!(0, import_service_helpers.getFieldInterface)(targetField);
|
|
19745
|
+
}).map((targetField) => ({
|
|
19112
19746
|
field: targetField,
|
|
19113
19747
|
fieldPath: `${(0, import_service_helpers.getFieldName)(field)}.${(0, import_service_helpers.getFieldName)(targetField)}`,
|
|
19114
19748
|
associationPathName: (0, import_service_helpers.getFieldName)(field),
|