@nocobase/plugin-flow-engine 2.1.0-beta.20 → 2.1.0-beta.22
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/externalVersion.js +10 -10
- package/dist/node_modules/ses/package.json +1 -1
- package/dist/node_modules/zod/package.json +1 -1
- package/dist/server/flow-surfaces/apply/compiler.js +4 -2
- package/dist/server/flow-surfaces/association-interfaces.d.ts +10 -0
- package/dist/server/flow-surfaces/association-interfaces.js +39 -0
- package/dist/server/flow-surfaces/blueprint/compile-blocks.js +108 -6
- package/dist/server/flow-surfaces/blueprint/public-types.d.ts +9 -1
- package/dist/server/flow-surfaces/builder.d.ts +27 -1
- package/dist/server/flow-surfaces/builder.js +54 -4
- package/dist/server/flow-surfaces/catalog.d.ts +1 -0
- package/dist/server/flow-surfaces/catalog.js +146 -36
- package/dist/server/flow-surfaces/compose-compiler.d.ts +9 -1
- package/dist/server/flow-surfaces/compose-compiler.js +8 -0
- package/dist/server/flow-surfaces/compose-runtime.d.ts +1 -0
- package/dist/server/flow-surfaces/compose-runtime.js +2 -1
- package/dist/server/flow-surfaces/configure-options.js +50 -6
- package/dist/server/flow-surfaces/default-action-popup.js +2 -2
- package/dist/server/flow-surfaces/field-binding-registry.d.ts +1 -0
- package/dist/server/flow-surfaces/field-binding-registry.js +6 -1
- package/dist/server/flow-surfaces/field-semantics.d.ts +1 -1
- package/dist/server/flow-surfaces/field-semantics.js +4 -3
- package/dist/server/flow-surfaces/field-type-resolver.d.ts +46 -0
- package/dist/server/flow-surfaces/field-type-resolver.js +322 -0
- package/dist/server/flow-surfaces/node-use-sets.js +1 -0
- package/dist/server/flow-surfaces/service-helpers.js +2 -2
- package/dist/server/flow-surfaces/service-utils.d.ts +14 -1
- package/dist/server/flow-surfaces/service-utils.js +79 -6
- package/dist/server/flow-surfaces/service.d.ts +28 -4
- package/dist/server/flow-surfaces/service.js +1158 -116
- package/dist/server/flow-surfaces/support-matrix.js +11 -0
- package/dist/swagger/flow-surfaces.d.ts +173 -2
- package/dist/swagger/flow-surfaces.examples.d.ts +20 -15
- package/dist/swagger/flow-surfaces.examples.js +22 -11
- package/dist/swagger/flow-surfaces.js +72 -10
- package/dist/swagger/index.d.ts +173 -2
- package/package.json +2 -2
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
export declare const FLOW_SURFACE_PUBLIC_RELATION_FIELD_TYPES: readonly ["text", "select", "picker", "subForm", "subFormList", "subDetails", "subDetailsList", "subTable", "popupSubTable"];
|
|
10
|
+
export type FlowSurfacePublicRelationFieldType = (typeof FLOW_SURFACE_PUBLIC_RELATION_FIELD_TYPES)[number];
|
|
11
|
+
export declare const FLOW_SURFACE_RESERVED_RELATION_FIELD_TYPES: readonly ["cascade", "upload", "preview"];
|
|
12
|
+
export declare const FLOW_SURFACE_PUBLIC_FIELD_TYPE_SET: Set<string>;
|
|
13
|
+
export declare const FLOW_SURFACE_INTERNAL_FIELD_KEYS: string[];
|
|
14
|
+
export declare function assertNoInternalFieldKeys(input: Record<string, any> | undefined, context: string): void;
|
|
15
|
+
export declare function normalizePublicFieldType(value: any, context: string): FlowSurfacePublicRelationFieldType | undefined;
|
|
16
|
+
export declare function normalizePublicFieldNameList(value: any, context: string): string[] | undefined;
|
|
17
|
+
export declare function getPublicFieldTypeForUse(use?: string): FlowSurfacePublicRelationFieldType | undefined;
|
|
18
|
+
export declare function resolveRelationFieldType(input: {
|
|
19
|
+
fieldType: any;
|
|
20
|
+
containerUse: string;
|
|
21
|
+
field: any;
|
|
22
|
+
dataSourceKey: string;
|
|
23
|
+
getCollection: (dataSourceKey: string, collectionName: string) => any;
|
|
24
|
+
fields?: any;
|
|
25
|
+
selectorFields?: any;
|
|
26
|
+
titleField?: any;
|
|
27
|
+
openMode?: any;
|
|
28
|
+
popupSize?: any;
|
|
29
|
+
pageSize?: any;
|
|
30
|
+
showIndex?: any;
|
|
31
|
+
applyDefaults?: boolean;
|
|
32
|
+
context: string;
|
|
33
|
+
}): {
|
|
34
|
+
fieldType: "select" | "subForm" | "text" | "picker" | "subFormList" | "subDetails" | "subDetailsList" | "subTable" | "popupSubTable";
|
|
35
|
+
fieldUse: string;
|
|
36
|
+
cardinality: "single" | "multi";
|
|
37
|
+
targetCollection: any;
|
|
38
|
+
fields: any[];
|
|
39
|
+
selectorFields: any[];
|
|
40
|
+
titleField: any;
|
|
41
|
+
openMode: any;
|
|
42
|
+
popupSize: any;
|
|
43
|
+
pageSize: any;
|
|
44
|
+
showIndex: any;
|
|
45
|
+
};
|
|
46
|
+
export declare function usesNestedRelationFields(fieldUse?: string): boolean;
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var __create = Object.create;
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
14
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
15
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
+
var __export = (target, all) => {
|
|
17
|
+
for (var name in all)
|
|
18
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
19
|
+
};
|
|
20
|
+
var __copyProps = (to, from, except, desc) => {
|
|
21
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
22
|
+
for (let key of __getOwnPropNames(from))
|
|
23
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
24
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
25
|
+
}
|
|
26
|
+
return to;
|
|
27
|
+
};
|
|
28
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
29
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
30
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
31
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
32
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
33
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
34
|
+
mod
|
|
35
|
+
));
|
|
36
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
|
+
var field_type_resolver_exports = {};
|
|
38
|
+
__export(field_type_resolver_exports, {
|
|
39
|
+
FLOW_SURFACE_INTERNAL_FIELD_KEYS: () => FLOW_SURFACE_INTERNAL_FIELD_KEYS,
|
|
40
|
+
FLOW_SURFACE_PUBLIC_FIELD_TYPE_SET: () => FLOW_SURFACE_PUBLIC_FIELD_TYPE_SET,
|
|
41
|
+
FLOW_SURFACE_PUBLIC_RELATION_FIELD_TYPES: () => FLOW_SURFACE_PUBLIC_RELATION_FIELD_TYPES,
|
|
42
|
+
FLOW_SURFACE_RESERVED_RELATION_FIELD_TYPES: () => FLOW_SURFACE_RESERVED_RELATION_FIELD_TYPES,
|
|
43
|
+
assertNoInternalFieldKeys: () => assertNoInternalFieldKeys,
|
|
44
|
+
getPublicFieldTypeForUse: () => getPublicFieldTypeForUse,
|
|
45
|
+
normalizePublicFieldNameList: () => normalizePublicFieldNameList,
|
|
46
|
+
normalizePublicFieldType: () => normalizePublicFieldType,
|
|
47
|
+
resolveRelationFieldType: () => resolveRelationFieldType,
|
|
48
|
+
usesNestedRelationFields: () => usesNestedRelationFields
|
|
49
|
+
});
|
|
50
|
+
module.exports = __toCommonJS(field_type_resolver_exports);
|
|
51
|
+
var import_lodash = __toESM(require("lodash"));
|
|
52
|
+
var import_errors = require("./errors");
|
|
53
|
+
var import_association_interfaces = require("./association-interfaces");
|
|
54
|
+
var import_field_semantics = require("./field-semantics");
|
|
55
|
+
var import_service_helpers = require("./service-helpers");
|
|
56
|
+
var import_association_title_field = require("./association-title-field");
|
|
57
|
+
const FLOW_SURFACE_PUBLIC_RELATION_FIELD_TYPES = [
|
|
58
|
+
"text",
|
|
59
|
+
"select",
|
|
60
|
+
"picker",
|
|
61
|
+
"subForm",
|
|
62
|
+
"subFormList",
|
|
63
|
+
"subDetails",
|
|
64
|
+
"subDetailsList",
|
|
65
|
+
"subTable",
|
|
66
|
+
"popupSubTable"
|
|
67
|
+
];
|
|
68
|
+
const FLOW_SURFACE_RESERVED_RELATION_FIELD_TYPES = ["cascade", "upload", "preview"];
|
|
69
|
+
const FLOW_SURFACE_PUBLIC_FIELD_TYPE_SET = /* @__PURE__ */ new Set([
|
|
70
|
+
...FLOW_SURFACE_PUBLIC_RELATION_FIELD_TYPES,
|
|
71
|
+
...FLOW_SURFACE_RESERVED_RELATION_FIELD_TYPES
|
|
72
|
+
]);
|
|
73
|
+
const FLOW_SURFACE_INTERNAL_FIELD_KEYS = [
|
|
74
|
+
"fieldComponent",
|
|
75
|
+
"fieldModel",
|
|
76
|
+
"componentFields",
|
|
77
|
+
"use",
|
|
78
|
+
"fieldUse",
|
|
79
|
+
"subModels",
|
|
80
|
+
"props",
|
|
81
|
+
"stepParams"
|
|
82
|
+
];
|
|
83
|
+
const FIELD_USE_TO_PUBLIC_FIELD_TYPE = {
|
|
84
|
+
DisplayTextFieldModel: "text",
|
|
85
|
+
RecordSelectFieldModel: "select",
|
|
86
|
+
RecordPickerFieldModel: "picker",
|
|
87
|
+
SubFormFieldModel: "subForm",
|
|
88
|
+
SubFormListFieldModel: "subFormList",
|
|
89
|
+
DisplaySubItemFieldModel: "subDetails",
|
|
90
|
+
DisplaySubListFieldModel: "subDetailsList",
|
|
91
|
+
DisplaySubTableFieldModel: "subTable",
|
|
92
|
+
SubTableFieldModel: "subTable",
|
|
93
|
+
PopupSubTableFieldModel: "popupSubTable"
|
|
94
|
+
};
|
|
95
|
+
const FIELD_TYPES_WITH_FIELDS = /* @__PURE__ */ new Set([
|
|
96
|
+
"subForm",
|
|
97
|
+
"subFormList",
|
|
98
|
+
"subDetails",
|
|
99
|
+
"subDetailsList",
|
|
100
|
+
"subTable",
|
|
101
|
+
"popupSubTable"
|
|
102
|
+
]);
|
|
103
|
+
const FIELD_TYPES_WITH_SELECTOR_FIELDS = /* @__PURE__ */ new Set(["picker"]);
|
|
104
|
+
const FIELD_TYPES_WITH_TABLE_PROPS = /* @__PURE__ */ new Set(["subTable", "popupSubTable"]);
|
|
105
|
+
function assertNoInternalFieldKeys(input, context) {
|
|
106
|
+
if (!import_lodash.default.isPlainObject(input)) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const forbidden = FLOW_SURFACE_INTERNAL_FIELD_KEYS.filter((key) => Object.prototype.hasOwnProperty.call(input, key));
|
|
110
|
+
if (forbidden.length) {
|
|
111
|
+
(0, import_errors.throwBadRequest)(`${context} does not accept internal field keys: ${forbidden.join(", ")}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function normalizePublicFieldType(value, context) {
|
|
115
|
+
if (import_lodash.default.isUndefined(value) || import_lodash.default.isNull(value) || value === "") {
|
|
116
|
+
return void 0;
|
|
117
|
+
}
|
|
118
|
+
const normalized = String(value || "").trim();
|
|
119
|
+
if (!normalized) {
|
|
120
|
+
return void 0;
|
|
121
|
+
}
|
|
122
|
+
if (FLOW_SURFACE_RESERVED_RELATION_FIELD_TYPES.includes(normalized)) {
|
|
123
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${context} fieldType '${normalized}' is reserved for plugin-specific field types`);
|
|
124
|
+
}
|
|
125
|
+
if (!FLOW_SURFACE_PUBLIC_RELATION_FIELD_TYPES.includes(normalized)) {
|
|
126
|
+
(0, import_errors.throwBadRequest)(
|
|
127
|
+
`flowSurfaces ${context} fieldType '${normalized}' is not supported; supported fieldTypes: ${FLOW_SURFACE_PUBLIC_RELATION_FIELD_TYPES.join(
|
|
128
|
+
", "
|
|
129
|
+
)}`
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
return normalized;
|
|
133
|
+
}
|
|
134
|
+
function normalizePublicFieldNameList(value, context) {
|
|
135
|
+
if (import_lodash.default.isUndefined(value)) {
|
|
136
|
+
return void 0;
|
|
137
|
+
}
|
|
138
|
+
if (!Array.isArray(value)) {
|
|
139
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${context} must be an array of field names`);
|
|
140
|
+
}
|
|
141
|
+
return value.map((item, index) => {
|
|
142
|
+
const normalized = String(item || "").trim();
|
|
143
|
+
if (!normalized) {
|
|
144
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${context}[${index + 1}] cannot be empty`);
|
|
145
|
+
}
|
|
146
|
+
return normalized;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function getPublicFieldTypeForUse(use) {
|
|
150
|
+
return FIELD_USE_TO_PUBLIC_FIELD_TYPE[String(use || "").trim()];
|
|
151
|
+
}
|
|
152
|
+
function getAssociationCardinality(field) {
|
|
153
|
+
const fieldInterface = String((0, import_service_helpers.getFieldInterface)(field) || "").trim();
|
|
154
|
+
if (import_association_interfaces.SINGLE_VALUE_ASSOCIATION_INTERFACES.has(fieldInterface)) {
|
|
155
|
+
return "single";
|
|
156
|
+
}
|
|
157
|
+
if (import_association_interfaces.MULTI_VALUE_ASSOCIATION_INTERFACES.has(fieldInterface)) {
|
|
158
|
+
return "multi";
|
|
159
|
+
}
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
function pickCollectionFallbackFieldName(collection) {
|
|
163
|
+
var _a;
|
|
164
|
+
const safeTitleFieldName = (_a = (0, import_association_title_field.resolveCollectionSafeTitleField)(collection)) == null ? void 0 : _a.fieldName;
|
|
165
|
+
if (safeTitleFieldName && (0, import_service_helpers.resolveFieldFromCollection)(collection, safeTitleFieldName)) {
|
|
166
|
+
return safeTitleFieldName;
|
|
167
|
+
}
|
|
168
|
+
const primaryField = (0, import_service_helpers.getCollectionFields)(collection).find(
|
|
169
|
+
(field) => {
|
|
170
|
+
var _a2;
|
|
171
|
+
return !!(field == null ? void 0 : field.primaryKey) || !!((_a2 = field == null ? void 0 : field.options) == null ? void 0 : _a2.primaryKey);
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
return (0, import_service_helpers.getFieldName)(primaryField) || "id";
|
|
175
|
+
}
|
|
176
|
+
function assertTargetFieldNamesExist(targetCollection, fields, context) {
|
|
177
|
+
fields.forEach((fieldName) => {
|
|
178
|
+
if (!(0, import_service_helpers.resolveFieldFromCollection)(targetCollection, fieldName)) {
|
|
179
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${context} field '${fieldName}' does not exist on relation target collection`);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
function resolveRelationFieldType(input) {
|
|
184
|
+
const fieldType = normalizePublicFieldType(input.fieldType, input.context);
|
|
185
|
+
if (!fieldType) {
|
|
186
|
+
return void 0;
|
|
187
|
+
}
|
|
188
|
+
if (!(0, import_service_helpers.isAssociationField)(input.field)) {
|
|
189
|
+
throw new import_errors.FlowSurfaceBadRequestError("flowSurfaces fieldType is only supported for relation fields");
|
|
190
|
+
}
|
|
191
|
+
const targetCollection = (0, import_service_helpers.resolveFieldTargetCollection)(
|
|
192
|
+
input.field,
|
|
193
|
+
input.dataSourceKey || "main",
|
|
194
|
+
input.getCollection
|
|
195
|
+
);
|
|
196
|
+
if (!targetCollection) {
|
|
197
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${input.context} fieldType '${fieldType}' cannot resolve relation target collection`);
|
|
198
|
+
}
|
|
199
|
+
const cardinality = getAssociationCardinality(input.field);
|
|
200
|
+
if (!cardinality) {
|
|
201
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${input.context} fieldType '${fieldType}' is not supported for this relation field`);
|
|
202
|
+
}
|
|
203
|
+
const containerKind = (0, import_field_semantics.normalizeFieldContainerKind)(input.containerUse);
|
|
204
|
+
let fieldUse;
|
|
205
|
+
switch (fieldType) {
|
|
206
|
+
case "text":
|
|
207
|
+
fieldUse = containerKind === "form" ? "RecordSelectFieldModel" : "DisplayTextFieldModel";
|
|
208
|
+
break;
|
|
209
|
+
case "select":
|
|
210
|
+
fieldUse = "RecordSelectFieldModel";
|
|
211
|
+
break;
|
|
212
|
+
case "picker":
|
|
213
|
+
fieldUse = "RecordPickerFieldModel";
|
|
214
|
+
break;
|
|
215
|
+
case "subForm":
|
|
216
|
+
if (cardinality !== "single") {
|
|
217
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${input.context} fieldType 'subForm' only supports single relation fields`);
|
|
218
|
+
}
|
|
219
|
+
fieldUse = "SubFormFieldModel";
|
|
220
|
+
break;
|
|
221
|
+
case "subFormList":
|
|
222
|
+
if (cardinality !== "multi") {
|
|
223
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${input.context} fieldType 'subFormList' only supports multi relation fields`);
|
|
224
|
+
}
|
|
225
|
+
fieldUse = "SubFormListFieldModel";
|
|
226
|
+
break;
|
|
227
|
+
case "subDetails":
|
|
228
|
+
if (cardinality !== "single") {
|
|
229
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${input.context} fieldType 'subDetails' only supports single relation fields`);
|
|
230
|
+
}
|
|
231
|
+
fieldUse = "DisplaySubItemFieldModel";
|
|
232
|
+
break;
|
|
233
|
+
case "subDetailsList":
|
|
234
|
+
if (cardinality !== "multi") {
|
|
235
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${input.context} fieldType 'subDetailsList' only supports multi relation fields`);
|
|
236
|
+
}
|
|
237
|
+
fieldUse = "DisplaySubListFieldModel";
|
|
238
|
+
break;
|
|
239
|
+
case "subTable":
|
|
240
|
+
if (cardinality !== "multi") {
|
|
241
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${input.context} fieldType 'subTable' only supports multi relation fields`);
|
|
242
|
+
}
|
|
243
|
+
fieldUse = containerKind === "form" ? "SubTableFieldModel" : "DisplaySubTableFieldModel";
|
|
244
|
+
break;
|
|
245
|
+
case "popupSubTable":
|
|
246
|
+
if (cardinality !== "multi") {
|
|
247
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${input.context} fieldType 'popupSubTable' only supports multi relation fields`);
|
|
248
|
+
}
|
|
249
|
+
fieldUse = "PopupSubTableFieldModel";
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
const explicitFields = normalizePublicFieldNameList(input.fields, `${input.context}.fields`);
|
|
253
|
+
const explicitSelectorFields = normalizePublicFieldNameList(input.selectorFields, `${input.context}.selectorFields`);
|
|
254
|
+
if (explicitFields && explicitSelectorFields) {
|
|
255
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${input.context} cannot mix fields and selectorFields on the same field`);
|
|
256
|
+
}
|
|
257
|
+
if (explicitFields && !FIELD_TYPES_WITH_FIELDS.has(fieldType)) {
|
|
258
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${input.context} fieldType '${fieldType}' does not support fields`);
|
|
259
|
+
}
|
|
260
|
+
if (explicitSelectorFields && !FIELD_TYPES_WITH_SELECTOR_FIELDS.has(fieldType)) {
|
|
261
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${input.context} fieldType '${fieldType}' does not support selectorFields`);
|
|
262
|
+
}
|
|
263
|
+
if ((!import_lodash.default.isUndefined(input.openMode) || !import_lodash.default.isUndefined(input.popupSize)) && fieldType !== "picker") {
|
|
264
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${input.context} fieldType '${fieldType}' does not support openMode or popupSize`);
|
|
265
|
+
}
|
|
266
|
+
if ((!import_lodash.default.isUndefined(input.pageSize) || !import_lodash.default.isUndefined(input.showIndex)) && !FIELD_TYPES_WITH_TABLE_PROPS.has(fieldType)) {
|
|
267
|
+
(0, import_errors.throwBadRequest)(`flowSurfaces ${input.context} fieldType '${fieldType}' does not support pageSize or showIndex`);
|
|
268
|
+
}
|
|
269
|
+
const shouldApplyDefaults = input.applyDefaults !== false;
|
|
270
|
+
const defaultTargetField = shouldApplyDefaults ? pickCollectionFallbackFieldName(targetCollection) : void 0;
|
|
271
|
+
const fields = explicitFields ?? (shouldApplyDefaults && usesNestedRelationFields(fieldUse) ? [defaultTargetField] : void 0);
|
|
272
|
+
const selectorFields = explicitSelectorFields ?? (shouldApplyDefaults && fieldType === "picker" && import_lodash.default.isUndefined(input.selectorFields) ? [defaultTargetField] : void 0);
|
|
273
|
+
const titleField = import_lodash.default.isUndefined(input.titleField) ? defaultTargetField : String(input.titleField || "").trim() || void 0;
|
|
274
|
+
if (fields == null ? void 0 : fields.length) {
|
|
275
|
+
assertTargetFieldNamesExist(targetCollection, fields, `${input.context}.fields`);
|
|
276
|
+
}
|
|
277
|
+
if (selectorFields == null ? void 0 : selectorFields.length) {
|
|
278
|
+
assertTargetFieldNamesExist(targetCollection, selectorFields, `${input.context}.selectorFields`);
|
|
279
|
+
}
|
|
280
|
+
if (titleField && !(0, import_service_helpers.resolveFieldFromCollection)(targetCollection, titleField)) {
|
|
281
|
+
(0, import_errors.throwBadRequest)(
|
|
282
|
+
`flowSurfaces ${input.context}.titleField '${titleField}' does not exist on relation target collection`
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
return {
|
|
286
|
+
fieldType,
|
|
287
|
+
fieldUse,
|
|
288
|
+
cardinality,
|
|
289
|
+
targetCollection,
|
|
290
|
+
fields,
|
|
291
|
+
selectorFields,
|
|
292
|
+
titleField,
|
|
293
|
+
openMode: input.openMode,
|
|
294
|
+
popupSize: input.popupSize,
|
|
295
|
+
pageSize: input.pageSize,
|
|
296
|
+
showIndex: input.showIndex
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
function usesNestedRelationFields(fieldUse) {
|
|
300
|
+
return [
|
|
301
|
+
"SubTableFieldModel",
|
|
302
|
+
"PopupSubTableFieldModel",
|
|
303
|
+
"DisplaySubTableFieldModel",
|
|
304
|
+
"SubFormFieldModel",
|
|
305
|
+
"SubFormListFieldModel",
|
|
306
|
+
"DisplaySubItemFieldModel",
|
|
307
|
+
"DisplaySubListFieldModel"
|
|
308
|
+
].includes(String(fieldUse || "").trim());
|
|
309
|
+
}
|
|
310
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
311
|
+
0 && (module.exports = {
|
|
312
|
+
FLOW_SURFACE_INTERNAL_FIELD_KEYS,
|
|
313
|
+
FLOW_SURFACE_PUBLIC_FIELD_TYPE_SET,
|
|
314
|
+
FLOW_SURFACE_PUBLIC_RELATION_FIELD_TYPES,
|
|
315
|
+
FLOW_SURFACE_RESERVED_RELATION_FIELD_TYPES,
|
|
316
|
+
assertNoInternalFieldKeys,
|
|
317
|
+
getPublicFieldTypeForUse,
|
|
318
|
+
normalizePublicFieldNameList,
|
|
319
|
+
normalizePublicFieldType,
|
|
320
|
+
resolveRelationFieldType,
|
|
321
|
+
usesNestedRelationFields
|
|
322
|
+
});
|
|
@@ -155,8 +155,8 @@ function getFieldName(field) {
|
|
|
155
155
|
return (field == null ? void 0 : field.name) || ((_a = field == null ? void 0 : field.options) == null ? void 0 : _a.name);
|
|
156
156
|
}
|
|
157
157
|
function getFieldTitle(field) {
|
|
158
|
-
var _a;
|
|
159
|
-
return (field == null ? void 0 : field.title) || ((
|
|
158
|
+
var _a, _b, _c, _d;
|
|
159
|
+
return ((_a = field == null ? void 0 : field.uiSchema) == null ? void 0 : _a.title) || ((_c = (_b = field == null ? void 0 : field.options) == null ? void 0 : _b.uiSchema) == null ? void 0 : _c.title) || (field == null ? void 0 : field.title) || ((_d = field == null ? void 0 : field.options) == null ? void 0 : _d.title) || getFieldName(field);
|
|
160
160
|
}
|
|
161
161
|
function resolveAssociationNameFromField(field, fallbackCollection) {
|
|
162
162
|
const resourceName = typeof (field == null ? void 0 : field.resourceName) === "string" ? field.resourceName.trim() : "";
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import _ from 'lodash';
|
|
10
10
|
import { FLOW_SURFACE_APPLY_BLUEPRINT_POPUP_DEFAULTS_KEY, type FlowSurfaceApplyBlueprintPopupDefaultsMetadata } from './blueprint/defaults';
|
|
11
11
|
import type { FlowSurfaceNodeSpec, FlowSurfaceNodeSubModel } from './types';
|
|
12
|
+
import { type FlowSurfacePublicRelationFieldType } from './field-type-resolver';
|
|
12
13
|
export declare function buildDefinedPayload(payload: Record<string, any>): _.Dictionary<any>;
|
|
13
14
|
export declare function normalizeFlowSurfaceComposeKey(key: any, context: string): string;
|
|
14
15
|
export declare function assertFlowSurfaceComposeUniqueKeys(items: Array<{
|
|
@@ -20,6 +21,7 @@ export declare function normalizeBlockTitleDescription(titleDescription: any): a
|
|
|
20
21
|
export declare function buildBlockTitleDescriptionFromSemanticChanges(changes: Record<string, any>): {
|
|
21
22
|
titleDescription: _.Dictionary<any>;
|
|
22
23
|
};
|
|
24
|
+
export declare function buildBlockCardSettingsFromSemanticChanges(changes: Record<string, any>): {};
|
|
23
25
|
export declare function buildChartCardSettingsFromSemanticChanges(currentCardSettings: any, changes: Record<string, any>): any;
|
|
24
26
|
export declare function buildPopupTabTree(options: {
|
|
25
27
|
tabUid?: string;
|
|
@@ -65,6 +67,14 @@ export type NormalizedComposeFieldSpec = {
|
|
|
65
67
|
associationPathName?: string;
|
|
66
68
|
renderer?: string;
|
|
67
69
|
type?: string;
|
|
70
|
+
fieldType?: FlowSurfacePublicRelationFieldType;
|
|
71
|
+
fields?: string[];
|
|
72
|
+
selectorFields?: string[];
|
|
73
|
+
titleField?: string;
|
|
74
|
+
openMode?: string;
|
|
75
|
+
popupSize?: string;
|
|
76
|
+
pageSize?: number;
|
|
77
|
+
showIndex?: boolean;
|
|
68
78
|
target?: string;
|
|
69
79
|
settings: Record<string, any>;
|
|
70
80
|
popup?: Record<string, any>;
|
|
@@ -72,6 +82,9 @@ export type NormalizedComposeFieldSpec = {
|
|
|
72
82
|
[FLOW_SURFACE_APPLY_BLUEPRINT_POPUP_DEFAULTS_KEY]?: FlowSurfaceApplyBlueprintPopupDefaultsMetadata;
|
|
73
83
|
};
|
|
74
84
|
export declare function normalizeComposeFieldSpec(input: any, index: number): NormalizedComposeFieldSpec;
|
|
85
|
+
export declare function resolveRequestedFieldComponent(values: Record<string, any> | undefined): any;
|
|
86
|
+
export declare function resolveRequestedFieldUse(values: Record<string, any> | undefined): any;
|
|
87
|
+
export declare function resolveRequestedFieldUseAlias(values: Record<string, any> | undefined): string;
|
|
75
88
|
export declare function normalizeComposeActionSpec(input: any, index: number): {
|
|
76
89
|
popup?: any;
|
|
77
90
|
key: string;
|
|
@@ -99,7 +112,7 @@ export declare function splitComposeFieldChanges(changes: Record<string, any>, w
|
|
|
99
112
|
wrapperChanges: _.Dictionary<any>;
|
|
100
113
|
fieldChanges: _.Dictionary<any>;
|
|
101
114
|
};
|
|
102
|
-
export declare function getCatalogRecordActionContainerUse(use?: string): "DetailsBlockModel" | "
|
|
115
|
+
export declare function getCatalogRecordActionContainerUse(use?: string): "DetailsBlockModel" | "ListItemModel" | "GridCardItemModel" | "TableActionsColumnModel";
|
|
103
116
|
export declare function normalizeRowSpans(spans?: Array<number | undefined>): number[];
|
|
104
117
|
export declare function normalizePublicBlockHeightMode(input: any): string;
|
|
105
118
|
export declare function normalizeStoredChartCardHeightMode(input: any): string;
|
|
@@ -38,6 +38,7 @@ var service_utils_exports = {};
|
|
|
38
38
|
__export(service_utils_exports, {
|
|
39
39
|
assertFlowSurfaceComposeUniqueKeys: () => assertFlowSurfaceComposeUniqueKeys,
|
|
40
40
|
assertSupportedSimpleChanges: () => assertSupportedSimpleChanges,
|
|
41
|
+
buildBlockCardSettingsFromSemanticChanges: () => buildBlockCardSettingsFromSemanticChanges,
|
|
41
42
|
buildBlockTitleDescriptionFromSemanticChanges: () => buildBlockTitleDescriptionFromSemanticChanges,
|
|
42
43
|
buildChartCardSettingsFromSemanticChanges: () => buildChartCardSettingsFromSemanticChanges,
|
|
43
44
|
buildDefaultFieldState: () => buildDefaultFieldState,
|
|
@@ -72,6 +73,9 @@ __export(service_utils_exports, {
|
|
|
72
73
|
normalizeSimpleLayoutValue: () => normalizeSimpleLayoutValue,
|
|
73
74
|
normalizeSimpleResourceInit: () => normalizeSimpleResourceInit,
|
|
74
75
|
normalizeStoredChartCardHeightMode: () => normalizeStoredChartCardHeightMode,
|
|
76
|
+
resolveRequestedFieldComponent: () => resolveRequestedFieldComponent,
|
|
77
|
+
resolveRequestedFieldUse: () => resolveRequestedFieldUse,
|
|
78
|
+
resolveRequestedFieldUseAlias: () => resolveRequestedFieldUseAlias,
|
|
75
79
|
rethrowInlineConfigurationError: () => rethrowInlineConfigurationError,
|
|
76
80
|
splitComposeFieldChanges: () => splitComposeFieldChanges,
|
|
77
81
|
toFlowSurfaceBatchItemError: () => toFlowSurfaceBatchItemError
|
|
@@ -84,6 +88,7 @@ var import_defaults = require("./blueprint/defaults");
|
|
|
84
88
|
var import_errors = require("./errors");
|
|
85
89
|
var import_service_helpers = require("./service-helpers");
|
|
86
90
|
var import_key_registry = require("./planning/key-registry");
|
|
91
|
+
var import_field_type_resolver = require("./field-type-resolver");
|
|
87
92
|
function buildDefinedPayload(payload) {
|
|
88
93
|
return import_lodash.default.pickBy(payload, (value) => !import_lodash.default.isUndefined(value));
|
|
89
94
|
}
|
|
@@ -176,6 +181,25 @@ function buildBlockTitleDescriptionFromSemanticChanges(changes) {
|
|
|
176
181
|
})
|
|
177
182
|
};
|
|
178
183
|
}
|
|
184
|
+
function buildBlockCardSettingsFromSemanticChanges(changes) {
|
|
185
|
+
const nextCardSettings = buildBlockTitleDescriptionFromSemanticChanges(changes) || {};
|
|
186
|
+
const hasHeightPatch = hasOwnDefined(changes, "height") || hasOwnDefined(changes, "heightMode");
|
|
187
|
+
if (hasHeightPatch) {
|
|
188
|
+
const nextHeightMode = hasOwnDefined(changes, "heightMode") ? normalizePublicBlockHeightMode(changes.heightMode) : hasOwnDefined(changes, "height") ? "specifyValue" : void 0;
|
|
189
|
+
if (nextHeightMode) {
|
|
190
|
+
import_lodash.default.set(nextCardSettings, ["blockHeight", "heightMode"], nextHeightMode);
|
|
191
|
+
if (nextHeightMode === "specifyValue" && hasOwnDefined(changes, "height")) {
|
|
192
|
+
import_lodash.default.set(nextCardSettings, ["blockHeight", "height"], changes.height);
|
|
193
|
+
} else {
|
|
194
|
+
import_lodash.default.unset(nextCardSettings, ["blockHeight", "height"]);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (import_lodash.default.isEmpty(import_lodash.default.get(nextCardSettings, ["blockHeight"]))) {
|
|
199
|
+
import_lodash.default.unset(nextCardSettings, ["blockHeight"]);
|
|
200
|
+
}
|
|
201
|
+
return Object.keys(nextCardSettings).length ? nextCardSettings : void 0;
|
|
202
|
+
}
|
|
179
203
|
function buildChartCardSettingsFromSemanticChanges(currentCardSettings, changes) {
|
|
180
204
|
const nextCardSettings = import_lodash.default.cloneDeep(currentCardSettings || {});
|
|
181
205
|
const currentTitleDescription = import_lodash.default.get(currentCardSettings, ["titleDescription"]);
|
|
@@ -299,7 +323,18 @@ function hasDefinedValue(input, keys) {
|
|
|
299
323
|
return keys.some((key) => hasOwnDefined(input, key));
|
|
300
324
|
}
|
|
301
325
|
function ensureNoRawSimpleChangeKeys(changes) {
|
|
302
|
-
const rawKeys = [
|
|
326
|
+
const rawKeys = [
|
|
327
|
+
"props",
|
|
328
|
+
"decoratorProps",
|
|
329
|
+
"stepParams",
|
|
330
|
+
"flowRegistry",
|
|
331
|
+
"use",
|
|
332
|
+
"fieldUse",
|
|
333
|
+
"fieldComponent",
|
|
334
|
+
"fieldModel",
|
|
335
|
+
"componentFields",
|
|
336
|
+
"subModels"
|
|
337
|
+
];
|
|
303
338
|
const forbidden = Object.keys(changes).filter((key) => rawKeys.includes(key));
|
|
304
339
|
if (forbidden.length) {
|
|
305
340
|
(0, import_errors.throwBadRequest)(
|
|
@@ -346,12 +381,22 @@ function normalizeComposeFieldSpec(input, index) {
|
|
|
346
381
|
if (!import_lodash.default.isPlainObject(input)) {
|
|
347
382
|
(0, import_errors.throwBadRequest)(`flowSurfaces compose field #${index + 1} must be a string or object`);
|
|
348
383
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
384
|
+
(0, import_field_type_resolver.assertNoInternalFieldKeys)(input, `flowSurfaces compose field #${index + 1}`);
|
|
385
|
+
(0, import_field_type_resolver.assertNoInternalFieldKeys)(input.settings, `flowSurfaces compose field #${index + 1}.settings`);
|
|
352
386
|
const semanticType = String(input.type || "").trim() || void 0;
|
|
353
387
|
const fieldPath = String(input.fieldPath || "").trim();
|
|
354
388
|
const renderer = typeof input.renderer === "undefined" ? void 0 : String(input.renderer || "").trim();
|
|
389
|
+
const fieldType = (0, import_field_type_resolver.normalizePublicFieldType)(input.fieldType, `compose field #${index + 1}`);
|
|
390
|
+
const fields = (0, import_field_type_resolver.normalizePublicFieldNameList)(input.fields, `compose field #${index + 1}.fields`);
|
|
391
|
+
const selectorFields = (0, import_field_type_resolver.normalizePublicFieldNameList)(
|
|
392
|
+
input.selectorFields,
|
|
393
|
+
`compose field #${index + 1}.selectorFields`
|
|
394
|
+
);
|
|
395
|
+
const titleField = typeof input.titleField === "undefined" ? void 0 : String(input.titleField || "").trim();
|
|
396
|
+
const openMode = typeof input.openMode === "undefined" ? void 0 : String(input.openMode || "").trim();
|
|
397
|
+
const popupSize = typeof input.popupSize === "undefined" ? void 0 : String(input.popupSize || "").trim();
|
|
398
|
+
const pageSize = typeof input.pageSize === "undefined" ? void 0 : Number(input.pageSize);
|
|
399
|
+
const showIndex = typeof input.showIndex === "undefined" ? void 0 : !!input.showIndex;
|
|
355
400
|
if (!import_lodash.default.isUndefined(input.popup) && !import_lodash.default.isPlainObject(input.popup)) {
|
|
356
401
|
(0, import_errors.throwBadRequest)(`flowSurfaces compose field #${index + 1} popup must be an object`);
|
|
357
402
|
}
|
|
@@ -376,6 +421,14 @@ function normalizeComposeFieldSpec(input, index) {
|
|
|
376
421
|
associationPathName: String(input.associationPathName || "").trim() || void 0,
|
|
377
422
|
...renderer ? { renderer } : {},
|
|
378
423
|
...semanticType ? { type: semanticType } : {},
|
|
424
|
+
...fieldType ? { fieldType } : {},
|
|
425
|
+
...!import_lodash.default.isUndefined(fields) ? { fields } : {},
|
|
426
|
+
...!import_lodash.default.isUndefined(selectorFields) ? { selectorFields } : {},
|
|
427
|
+
...titleField ? { titleField } : {},
|
|
428
|
+
...openMode ? { openMode } : {},
|
|
429
|
+
...popupSize ? { popupSize } : {},
|
|
430
|
+
...!import_lodash.default.isUndefined(pageSize) && Number.isFinite(pageSize) ? { pageSize } : {},
|
|
431
|
+
...!import_lodash.default.isUndefined(showIndex) ? { showIndex } : {},
|
|
379
432
|
target: typeof input.target === "string" ? String(input.target || "").trim() || void 0 : void 0,
|
|
380
433
|
settings: import_lodash.default.isPlainObject(input.settings) ? input.settings : {},
|
|
381
434
|
popup: import_lodash.default.isPlainObject(input.popup) ? input.popup : void 0,
|
|
@@ -383,6 +436,16 @@ function normalizeComposeFieldSpec(input, index) {
|
|
|
383
436
|
...popupDefaultsMetadata ? { [import_defaults.FLOW_SURFACE_APPLY_BLUEPRINT_POPUP_DEFAULTS_KEY]: popupDefaultsMetadata } : {}
|
|
384
437
|
};
|
|
385
438
|
}
|
|
439
|
+
function resolveRequestedFieldComponent(values) {
|
|
440
|
+
return void 0;
|
|
441
|
+
}
|
|
442
|
+
function resolveRequestedFieldUse(values) {
|
|
443
|
+
return resolveRequestedFieldComponent(values) || resolveRequestedFieldUseAlias(values);
|
|
444
|
+
}
|
|
445
|
+
function resolveRequestedFieldUseAlias(values) {
|
|
446
|
+
const legacyFieldUse = String((values == null ? void 0 : values.fieldUse) || "").trim();
|
|
447
|
+
return legacyFieldUse || void 0;
|
|
448
|
+
}
|
|
386
449
|
function normalizeComposeActionSpec(input, index) {
|
|
387
450
|
if (typeof input === "string") {
|
|
388
451
|
const type2 = String(input || "").trim();
|
|
@@ -595,13 +658,19 @@ function splitComposeFieldChanges(changes, wrapperUse) {
|
|
|
595
658
|
"disabled",
|
|
596
659
|
"maxCount",
|
|
597
660
|
"pattern",
|
|
598
|
-
"titleField",
|
|
599
661
|
"dataIndex",
|
|
600
662
|
"editable",
|
|
601
663
|
"labelWidth",
|
|
602
664
|
"labelWrap",
|
|
603
665
|
"name",
|
|
604
|
-
"
|
|
666
|
+
"fieldType",
|
|
667
|
+
"fields",
|
|
668
|
+
"selectorFields",
|
|
669
|
+
"titleField",
|
|
670
|
+
"openMode",
|
|
671
|
+
"popupSize",
|
|
672
|
+
"pageSize",
|
|
673
|
+
"showIndex",
|
|
605
674
|
...wrapperUse === "TableColumnModel" ? ["title"] : []
|
|
606
675
|
]);
|
|
607
676
|
const fieldChanges = import_lodash.default.pick(changes, [
|
|
@@ -771,6 +840,7 @@ function getFieldBindingDefaultProps(containerUse, fieldUse, field) {
|
|
|
771
840
|
0 && (module.exports = {
|
|
772
841
|
assertFlowSurfaceComposeUniqueKeys,
|
|
773
842
|
assertSupportedSimpleChanges,
|
|
843
|
+
buildBlockCardSettingsFromSemanticChanges,
|
|
774
844
|
buildBlockTitleDescriptionFromSemanticChanges,
|
|
775
845
|
buildChartCardSettingsFromSemanticChanges,
|
|
776
846
|
buildDefaultFieldState,
|
|
@@ -805,6 +875,9 @@ function getFieldBindingDefaultProps(containerUse, fieldUse, field) {
|
|
|
805
875
|
normalizeSimpleLayoutValue,
|
|
806
876
|
normalizeSimpleResourceInit,
|
|
807
877
|
normalizeStoredChartCardHeightMode,
|
|
878
|
+
resolveRequestedFieldComponent,
|
|
879
|
+
resolveRequestedFieldUse,
|
|
880
|
+
resolveRequestedFieldUseAlias,
|
|
808
881
|
rethrowInlineConfigurationError,
|
|
809
882
|
splitComposeFieldChanges,
|
|
810
883
|
toFlowSurfaceBatchItemError
|