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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/ai/ai-employees/nathan/skills/frontend-developer/SKILLS.md +2 -2
  2. package/dist/externalVersion.js +10 -10
  3. package/dist/node_modules/ses/package.json +1 -1
  4. package/dist/node_modules/zod/package.json +1 -1
  5. package/dist/server/flow-surfaces/action-scope.d.ts +1 -0
  6. package/dist/server/flow-surfaces/action-scope.js +4 -0
  7. package/dist/server/flow-surfaces/apply/compiler.js +4 -2
  8. package/dist/server/flow-surfaces/association-interfaces.d.ts +10 -0
  9. package/dist/server/flow-surfaces/association-interfaces.js +39 -0
  10. package/dist/server/flow-surfaces/association-title-field.d.ts +1 -1
  11. package/dist/server/flow-surfaces/association-title-field.js +38 -4
  12. package/dist/server/flow-surfaces/blueprint/compile-blocks.js +72 -5
  13. package/dist/server/flow-surfaces/blueprint/public-types.d.ts +9 -1
  14. package/dist/server/flow-surfaces/builder.d.ts +27 -1
  15. package/dist/server/flow-surfaces/builder.js +105 -5
  16. package/dist/server/flow-surfaces/catalog.d.ts +2 -1
  17. package/dist/server/flow-surfaces/catalog.js +316 -119
  18. package/dist/server/flow-surfaces/compose-compiler.d.ts +8 -0
  19. package/dist/server/flow-surfaces/compose-compiler.js +9 -1
  20. package/dist/server/flow-surfaces/configure-options.js +72 -6
  21. package/dist/server/flow-surfaces/core-field-default-bindings.d.ts +12 -0
  22. package/dist/server/flow-surfaces/core-field-default-bindings.js +157 -0
  23. package/dist/server/flow-surfaces/default-action-popup.js +2 -2
  24. package/dist/server/flow-surfaces/default-block-actions.js +24 -0
  25. package/dist/server/flow-surfaces/field-binding-registry.d.ts +1 -0
  26. package/dist/server/flow-surfaces/field-binding-registry.js +5 -0
  27. package/dist/server/flow-surfaces/field-semantics.d.ts +1 -1
  28. package/dist/server/flow-surfaces/field-semantics.js +7 -4
  29. package/dist/server/flow-surfaces/field-type-resolver.d.ts +46 -0
  30. package/dist/server/flow-surfaces/field-type-resolver.js +322 -0
  31. package/dist/server/flow-surfaces/index.js +61 -2
  32. package/dist/server/flow-surfaces/node-use-sets.js +4 -0
  33. package/dist/server/flow-surfaces/placement.js +3 -0
  34. package/dist/server/flow-surfaces/public-data-surface-default-filter.d.ts +4 -0
  35. package/dist/server/flow-surfaces/public-data-surface-default-filter.js +45 -4
  36. package/dist/server/flow-surfaces/service-helpers.js +3 -70
  37. package/dist/server/flow-surfaces/service-utils.d.ts +13 -1
  38. package/dist/server/flow-surfaces/service-utils.js +58 -6
  39. package/dist/server/flow-surfaces/service.d.ts +59 -2
  40. package/dist/server/flow-surfaces/service.js +2269 -234
  41. package/dist/server/flow-surfaces/support-matrix.d.ts +1 -1
  42. package/dist/server/flow-surfaces/support-matrix.js +23 -0
  43. package/dist/server/flow-surfaces/surface-context.js +8 -5
  44. package/dist/swagger/flow-surfaces.d.ts +173 -2
  45. package/dist/swagger/flow-surfaces.examples.d.ts +59 -15
  46. package/dist/swagger/flow-surfaces.examples.js +69 -11
  47. package/dist/swagger/flow-surfaces.js +86 -17
  48. package/dist/swagger/index.d.ts +173 -2
  49. package/package.json +2 -2
@@ -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
+ });
@@ -51,8 +51,13 @@ const FLOW_SURFACE_LOCAL_TRANSLATIONS = {
51
51
  }
52
52
  };
53
53
  function getValues(ctx) {
54
- var _a, _b, _c;
55
- return ((_b = (_a = ctx.action) == null ? void 0 : _a.params) == null ? void 0 : _b.values) ?? ((_c = ctx.action) == null ? void 0 : _c.params) ?? {};
54
+ var _a, _b, _c, _d, _e;
55
+ const values = ((_b = (_a = ctx.action) == null ? void 0 : _a.params) == null ? void 0 : _b.values) ?? ((_c = ctx.action) == null ? void 0 : _c.params) ?? {};
56
+ const actionName = (_d = ctx.action) == null ? void 0 : _d.actionName;
57
+ if (isInvalidFlowSurfaceWritePayload(values) && actionName && !((_e = import_constants.FLOW_SURFACE_ACTION_DEFINITIONS[actionName]) == null ? void 0 : _e.read)) {
58
+ throw new import_errors.FlowSurfaceBadRequestError(getFlowSurfaceWritePayloadMessage(actionName));
59
+ }
60
+ return values;
56
61
  }
57
62
  function isImplicitEmptyValuesBag(value) {
58
63
  return !!value && typeof value === "object" && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype && Object.keys(value).length === 0;
@@ -119,6 +124,56 @@ function writeFlowSurfaceErrorResponse(ctx, error) {
119
124
  ctx.status = normalized.status;
120
125
  ctx.body = normalized.toResponseBody();
121
126
  }
127
+ function isFlowSurfaceWriteActionName(value) {
128
+ return Object.prototype.hasOwnProperty.call(import_constants.FLOW_SURFACE_ACTION_DEFINITIONS, value);
129
+ }
130
+ function getFlowSurfaceRequestActionName(ctx) {
131
+ var _a, _b;
132
+ const actionName = String(((_a = ctx.action) == null ? void 0 : _a.actionName) || "").trim();
133
+ if (isFlowSurfaceWriteActionName(actionName)) {
134
+ return actionName;
135
+ }
136
+ const path = String(ctx.path || ((_b = ctx.request) == null ? void 0 : _b.path) || "").trim();
137
+ const match = path.match(/(?:^|\/)flowSurfaces:([^/?#]+)$/);
138
+ const rawActionName = String((match == null ? void 0 : match[1]) || "").trim();
139
+ return isFlowSurfaceWriteActionName(rawActionName) ? rawActionName : void 0;
140
+ }
141
+ function isFlowSurfaceWriteRequest(ctx) {
142
+ var _a;
143
+ if (String(((_a = ctx.request) == null ? void 0 : _a.method) || "").toUpperCase() !== "POST") {
144
+ return false;
145
+ }
146
+ const actionName = getFlowSurfaceRequestActionName(ctx);
147
+ return !!actionName && import_constants.FLOW_SURFACE_ACTION_DEFINITIONS[actionName].read === false;
148
+ }
149
+ function isInvalidFlowSurfaceWritePayload(value) {
150
+ if (!value || typeof value !== "object") {
151
+ return true;
152
+ }
153
+ return Array.isArray(value);
154
+ }
155
+ function getFlowSurfaceWritePayloadMessage(actionName) {
156
+ const noun = actionName === "applyBlueprint" || actionName === "applyApprovalBlueprint" ? "payload" : "values";
157
+ return `flowSurfaces ${actionName} ${noun} must be an object`;
158
+ }
159
+ function isFlowSurfaceWriteBodyParserShapeError(error) {
160
+ const parserError = error;
161
+ return error instanceof SyntaxError && parserError.status === 400 && parserError.message === "invalid JSON, only supports object and array";
162
+ }
163
+ async function runFlowSurfaceWriteBodyParserErrorWrapper(ctx, next) {
164
+ try {
165
+ await next();
166
+ } catch (error) {
167
+ if (!isFlowSurfaceWriteRequest(ctx) || !isFlowSurfaceWriteBodyParserShapeError(error)) {
168
+ throw error;
169
+ }
170
+ const actionName = getFlowSurfaceRequestActionName(ctx);
171
+ if (!actionName) {
172
+ throw error;
173
+ }
174
+ writeFlowSurfaceErrorResponse(ctx, new import_errors.FlowSurfaceBadRequestError(getFlowSurfaceWritePayloadMessage(actionName)));
175
+ }
176
+ }
122
177
  function isAclPermissionDeniedForFlowSurfaces(ctx, error) {
123
178
  var _a, _b;
124
179
  const resourceName = ((_a = ctx.action) == null ? void 0 : _a.resourceName) ?? ((_b = ctx.permission) == null ? void 0 : _b.resourceName);
@@ -231,6 +286,10 @@ function registerFlowSurfacesResource(plugin) {
231
286
  after: "allow-manager",
232
287
  before: "core"
233
288
  });
289
+ plugin.app.use(runFlowSurfaceWriteBodyParserErrorWrapper, {
290
+ tag: "flow-surfaces-write-body-errors",
291
+ before: "bodyParser"
292
+ });
234
293
  plugin.app.resourceManager.define({
235
294
  name: "flowSurfaces",
236
295
  actions
@@ -39,6 +39,8 @@ var import_approval = require("./approval");
39
39
  const COLLECTION_BLOCK_USES = /* @__PURE__ */ new Set([
40
40
  "TableBlockModel",
41
41
  "CalendarBlockModel",
42
+ "TreeBlockModel",
43
+ "KanbanBlockModel",
42
44
  "CreateFormModel",
43
45
  "EditFormModel",
44
46
  "FormBlockModel",
@@ -109,6 +111,8 @@ const ACTION_BUTTON_USES = /* @__PURE__ */ new Set([
109
111
  "CalendarNavActionModel",
110
112
  "CalendarTitleActionModel",
111
113
  "CalendarViewSelectActionModel",
114
+ "KanbanQuickCreateActionModel",
115
+ "KanbanCardViewActionModel",
112
116
  "ApplyFormSubmitModel",
113
117
  "ApplyFormSaveDraftModel",
114
118
  "ApplyFormWithdrawModel",
@@ -58,6 +58,8 @@ const FLOW_SURFACE_POPUP_HOST_USES = /* @__PURE__ */ new Set([
58
58
  "PopupCollectionActionModel",
59
59
  "CalendarQuickCreateActionModel",
60
60
  "CalendarEventViewActionModel",
61
+ "KanbanQuickCreateActionModel",
62
+ "KanbanCardViewActionModel",
61
63
  "ClickableFieldModel",
62
64
  "DisplayTextFieldModel",
63
65
  "DisplayEnumFieldModel",
@@ -161,6 +163,7 @@ function isActionContainerUse(parentUse) {
161
163
  return [
162
164
  "TableBlockModel",
163
165
  "CalendarBlockModel",
166
+ "KanbanBlockModel",
164
167
  "TableActionsColumnModel",
165
168
  "ListBlockModel",
166
169
  "GridCardBlockModel",
@@ -7,12 +7,16 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  export declare const FLOW_SURFACE_PUBLIC_DATA_SURFACE_BLOCK_TYPES: Set<string>;
10
+ export declare const FLOW_SURFACE_PUBLIC_DATA_SURFACE_BLOCK_TYPE_LABEL = "table/list/gridCard/calendar/kanban";
10
11
  export declare function isFlowSurfacePublicDataSurfaceBlockType(blockType?: string): boolean;
11
12
  export declare function normalizeFlowSurfacePublicBlockDefaultFilter(actionName: string, defaultFilter: any, options: {
12
13
  blockType?: string;
13
14
  template?: unknown;
14
15
  path?: string;
15
16
  }): any;
17
+ export declare function assertFlowSurfaceConcreteDefaultFilterItem(actionName: string, defaultFilter: any, options?: {
18
+ path?: string;
19
+ }): void;
16
20
  export declare function backfillFlowSurfaceDefaultFilterSetting(settings: any, defaultFilter: any): any;
17
21
  export declare function backfillFlowSurfaceFilterActionDefaultFilter<T extends {
18
22
  type?: string;
@@ -37,6 +37,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
37
37
  var public_data_surface_default_filter_exports = {};
38
38
  __export(public_data_surface_default_filter_exports, {
39
39
  FLOW_SURFACE_PUBLIC_DATA_SURFACE_BLOCK_TYPES: () => FLOW_SURFACE_PUBLIC_DATA_SURFACE_BLOCK_TYPES,
40
+ FLOW_SURFACE_PUBLIC_DATA_SURFACE_BLOCK_TYPE_LABEL: () => FLOW_SURFACE_PUBLIC_DATA_SURFACE_BLOCK_TYPE_LABEL,
41
+ assertFlowSurfaceConcreteDefaultFilterItem: () => assertFlowSurfaceConcreteDefaultFilterItem,
40
42
  backfillFlowSurfaceDefaultFilterSetting: () => backfillFlowSurfaceDefaultFilterSetting,
41
43
  backfillFlowSurfaceFilterActionDefaultFilter: () => backfillFlowSurfaceFilterActionDefaultFilter,
42
44
  isFlowSurfacePublicDataSurfaceBlockType: () => isFlowSurfacePublicDataSurfaceBlockType,
@@ -46,7 +48,14 @@ module.exports = __toCommonJS(public_data_surface_default_filter_exports);
46
48
  var import_lodash = __toESM(require("lodash"));
47
49
  var import_errors = require("./errors");
48
50
  var import_filter_group = require("./filter-group");
49
- const FLOW_SURFACE_PUBLIC_DATA_SURFACE_BLOCK_TYPES = /* @__PURE__ */ new Set(["table", "list", "gridCard"]);
51
+ const FLOW_SURFACE_PUBLIC_DATA_SURFACE_BLOCK_TYPES = /* @__PURE__ */ new Set([
52
+ "table",
53
+ "list",
54
+ "gridCard",
55
+ "calendar",
56
+ "kanban"
57
+ ]);
58
+ const FLOW_SURFACE_PUBLIC_DATA_SURFACE_BLOCK_TYPE_LABEL = "table/list/gridCard/calendar/kanban";
50
59
  function isFlowSurfacePublicDataSurfaceBlockType(blockType) {
51
60
  return FLOW_SURFACE_PUBLIC_DATA_SURFACE_BLOCK_TYPES.has(String(blockType || "").trim());
52
61
  }
@@ -54,14 +63,44 @@ function normalizeFlowSurfacePublicBlockDefaultFilter(actionName, defaultFilter,
54
63
  if (import_lodash.default.isUndefined(defaultFilter)) {
55
64
  return void 0;
56
65
  }
57
- const fieldPath = options.path ? `${options.path}.defaultFilter` : "defaultFilter";
66
+ const fieldPath = buildFlowSurfaceDefaultFilterFieldPath(actionName, options.path);
58
67
  if (!isFlowSurfacePublicDataSurfaceBlockType(options.blockType) || !import_lodash.default.isUndefined(options.template)) {
59
- (0, import_errors.throwBadRequest)(`flowSurfaces ${actionName} ${fieldPath} is only supported on direct table/list/gridCard blocks`);
68
+ (0, import_errors.throwBadRequest)(
69
+ `flowSurfaces ${actionName} ${fieldPath} is only supported on direct ${FLOW_SURFACE_PUBLIC_DATA_SURFACE_BLOCK_TYPE_LABEL} blocks`
70
+ );
60
71
  }
61
- return (0, import_filter_group.normalizeFlowSurfaceFilterGroupValue)(
72
+ const normalized = (0, import_filter_group.normalizeFlowSurfaceFilterGroupValue)(
62
73
  defaultFilter,
63
74
  `flowSurfaces ${actionName} ${fieldPath} expects FilterGroup like ${import_filter_group.FLOW_SURFACE_FILTER_GROUP_EXAMPLE}`
64
75
  );
76
+ return normalized;
77
+ }
78
+ function assertFlowSurfaceConcreteDefaultFilterItem(actionName, defaultFilter, options = {}) {
79
+ const fieldPath = buildFlowSurfaceDefaultFilterFieldPath(actionName, options.path);
80
+ if (!hasConcreteFlowSurfaceFilterItem(defaultFilter)) {
81
+ (0, import_errors.throwBadRequest)(
82
+ `flowSurfaces ${actionName} ${fieldPath} must include at least one concrete filter item; empty defaultFilter groups such as {}, null, or { logic, items: [] } are not allowed`
83
+ );
84
+ }
85
+ }
86
+ function buildFlowSurfaceDefaultFilterFieldPath(actionName, path) {
87
+ if (!path) {
88
+ return "defaultFilter";
89
+ }
90
+ const prefix = `flowSurfaces ${actionName} `;
91
+ const normalizedPath = path.startsWith(prefix) ? path.slice(prefix.length) : path;
92
+ return normalizedPath.endsWith(".defaultFilter") ? normalizedPath : `${normalizedPath}.defaultFilter`;
93
+ }
94
+ function hasConcreteFlowSurfaceFilterItem(filter) {
95
+ if (!import_lodash.default.isPlainObject(filter) || !Array.isArray(filter.items)) {
96
+ return false;
97
+ }
98
+ return filter.items.some((item) => {
99
+ if (import_lodash.default.isPlainObject(item) && "logic" in item && "items" in item) {
100
+ return hasConcreteFlowSurfaceFilterItem(item);
101
+ }
102
+ return import_lodash.default.isPlainObject(item) && typeof item.path === "string" && typeof item.operator === "string";
103
+ });
65
104
  }
66
105
  function backfillFlowSurfaceDefaultFilterSetting(settings, defaultFilter) {
67
106
  if (import_lodash.default.isUndefined(defaultFilter)) {
@@ -104,6 +143,8 @@ function backfillFlowSurfaceFilterActionDefaultFilter(actions, defaultFilter) {
104
143
  // Annotate the CommonJS export names for ESM import in node:
105
144
  0 && (module.exports = {
106
145
  FLOW_SURFACE_PUBLIC_DATA_SURFACE_BLOCK_TYPES,
146
+ FLOW_SURFACE_PUBLIC_DATA_SURFACE_BLOCK_TYPE_LABEL,
147
+ assertFlowSurfaceConcreteDefaultFilterItem,
107
148
  backfillFlowSurfaceDefaultFilterSetting,
108
149
  backfillFlowSurfaceFilterActionDefaultFilter,
109
150
  isFlowSurfacePublicDataSurfaceBlockType,
@@ -66,6 +66,7 @@ __export(service_helpers_exports, {
66
66
  });
67
67
  module.exports = __toCommonJS(service_helpers_exports);
68
68
  var import_lodash = __toESM(require("lodash"));
69
+ var import_core_field_default_bindings = require("./core-field-default-bindings");
69
70
  const FLOW_SURFACE_TEMPLATE_DEFAULT_PAGE = 1;
70
71
  const FLOW_SURFACE_TEMPLATE_DEFAULT_PAGE_SIZE = 50;
71
72
  function toTemplatePlainRow(row) {
@@ -206,82 +207,14 @@ function getFieldFilterable(field) {
206
207
  return (_a = field == null ? void 0 : field.options) == null ? void 0 : _a.filterable;
207
208
  }
208
209
  function inferAssociationLeafDisplayFieldUse(fieldInterface) {
209
- const normalized = String(fieldInterface || "").trim();
210
- const map = {
211
- richText: "DisplayHtmlFieldModel",
212
- number: "DisplayNumberFieldModel",
213
- integer: "DisplayNumberFieldModel",
214
- id: "DisplayNumberFieldModel",
215
- snowflakeId: "DisplayNumberFieldModel",
216
- json: "DisplayJSONFieldModel",
217
- select: "DisplayTextFieldModel",
218
- multipleSelect: "DisplayTextFieldModel",
219
- radioGroup: "DisplayTextFieldModel",
220
- checkboxGroup: "DisplayTextFieldModel",
221
- collection: "DisplayTextFieldModel",
222
- tableoid: "DisplayTextFieldModel",
223
- icon: "DisplayIconFieldModel",
224
- checkbox: "DisplayCheckboxFieldModel",
225
- password: "DisplayPasswordFieldModel",
226
- percent: "DisplayPercentFieldModel",
227
- date: "DisplayDateTimeFieldModel",
228
- datetimeNoTz: "DisplayDateTimeFieldModel",
229
- createdAt: "DisplayDateTimeFieldModel",
230
- datetime: "DisplayDateTimeFieldModel",
231
- updatedAt: "DisplayDateTimeFieldModel",
232
- unixTimestamp: "DisplayDateTimeFieldModel",
233
- formula: "DisplayDateTimeFieldModel",
234
- input: "DisplayTextFieldModel",
235
- email: "DisplayTextFieldModel",
236
- phone: "DisplayTextFieldModel",
237
- uuid: "DisplayTextFieldModel",
238
- textarea: "DisplayTextFieldModel",
239
- nanoid: "DisplayTextFieldModel",
240
- url: "DisplayURLFieldModel",
241
- color: "DisplayColorFieldModel",
242
- time: "DisplayTimeFieldModel"
243
- };
244
- return map[normalized];
210
+ return (0, import_core_field_default_bindings.getSharedFieldDefaultBindingUse)("display", fieldInterface);
245
211
  }
246
212
  function inferFieldMenuEditableFieldUse(fieldInterface) {
247
213
  const normalized = String(fieldInterface || "").trim();
248
214
  if (["m2m", "m2o", "o2o", "o2m", "oho", "obo", "updatedBy", "createdBy", "mbm"].includes(normalized)) {
249
215
  return "RecordSelectFieldModel";
250
216
  }
251
- const map = {
252
- json: "JsonFieldModel",
253
- textarea: "TextareaFieldModel",
254
- icon: "IconFieldModel",
255
- radioGroup: "SelectFieldModel",
256
- color: "ColorFieldModel",
257
- select: "SelectFieldModel",
258
- multipleSelect: "SelectFieldModel",
259
- checkboxGroup: "SelectFieldModel",
260
- checkbox: "CheckboxFieldModel",
261
- password: "PasswordFieldModel",
262
- number: "NumberFieldModel",
263
- integer: "NumberFieldModel",
264
- id: "NumberFieldModel",
265
- snowflakeId: "NumberFieldModel",
266
- percent: "PercentFieldModel",
267
- datetimeNoTz: "DateTimeNoTzFieldModel",
268
- date: "DateOnlyFieldModel",
269
- datetime: "DateTimeTzFieldModel",
270
- createdAt: "DateTimeTzFieldModel",
271
- updatedAt: "DateTimeTzFieldModel",
272
- unixTimestamp: "DateTimeTzFieldModel",
273
- time: "TimeFieldModel",
274
- collection: "CollectionSelectorFieldModel",
275
- tableoid: "CollectionSelectorFieldModel",
276
- richText: "RichTextFieldModel",
277
- input: "InputFieldModel",
278
- email: "InputFieldModel",
279
- phone: "InputFieldModel",
280
- uuid: "InputFieldModel",
281
- url: "InputFieldModel",
282
- nanoid: "InputFieldModel"
283
- };
284
- return map[normalized];
217
+ return (0, import_core_field_default_bindings.getSharedFieldDefaultBindingUse)("editable", normalized);
285
218
  }
286
219
  function isAssociationField(field) {
287
220
  if (typeof (field == null ? void 0 : field.isAssociationField) === "function") {
@@ -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<{
@@ -65,6 +66,14 @@ export type NormalizedComposeFieldSpec = {
65
66
  associationPathName?: string;
66
67
  renderer?: string;
67
68
  type?: string;
69
+ fieldType?: FlowSurfacePublicRelationFieldType;
70
+ fields?: string[];
71
+ selectorFields?: string[];
72
+ titleField?: string;
73
+ openMode?: string;
74
+ popupSize?: string;
75
+ pageSize?: number;
76
+ showIndex?: boolean;
68
77
  target?: string;
69
78
  settings: Record<string, any>;
70
79
  popup?: Record<string, any>;
@@ -72,6 +81,9 @@ export type NormalizedComposeFieldSpec = {
72
81
  [FLOW_SURFACE_APPLY_BLUEPRINT_POPUP_DEFAULTS_KEY]?: FlowSurfaceApplyBlueprintPopupDefaultsMetadata;
73
82
  };
74
83
  export declare function normalizeComposeFieldSpec(input: any, index: number): NormalizedComposeFieldSpec;
84
+ export declare function resolveRequestedFieldComponent(values: Record<string, any> | undefined): any;
85
+ export declare function resolveRequestedFieldUse(values: Record<string, any> | undefined): any;
86
+ export declare function resolveRequestedFieldUseAlias(values: Record<string, any> | undefined): string;
75
87
  export declare function normalizeComposeActionSpec(input: any, index: number): {
76
88
  popup?: any;
77
89
  key: string;
@@ -99,7 +111,7 @@ export declare function splitComposeFieldChanges(changes: Record<string, any>, w
99
111
  wrapperChanges: _.Dictionary<any>;
100
112
  fieldChanges: _.Dictionary<any>;
101
113
  };
102
- export declare function getCatalogRecordActionContainerUse(use?: string): "DetailsBlockModel" | "TableActionsColumnModel" | "ListItemModel" | "GridCardItemModel";
114
+ export declare function getCatalogRecordActionContainerUse(use?: string): "DetailsBlockModel" | "ListItemModel" | "GridCardItemModel" | "TableActionsColumnModel";
103
115
  export declare function normalizeRowSpans(spans?: Array<number | undefined>): number[];
104
116
  export declare function normalizePublicBlockHeightMode(input: any): string;
105
117
  export declare function normalizeStoredChartCardHeightMode(input: any): string;