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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/LICENSE +201 -661
  2. package/README.md +79 -9
  3. package/dist/ai/ai-employees/nathan/index.d.ts +10 -0
  4. package/dist/ai/ai-employees/nathan/index.js +41 -0
  5. package/dist/ai/ai-employees/nathan/prompt.md +132 -0
  6. package/dist/ai/ai-employees/nathan/skills/frontend-developer/SKILLS.md +69 -0
  7. package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextApis.js +2 -2
  8. package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextEnvs.js +2 -2
  9. package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextVars.js +2 -2
  10. package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/lintAndTestJS.js +2 -2
  11. package/dist/ai/docs/runjs/context/block-model.md +35 -35
  12. package/dist/ai/docs/runjs/context/collection-field.md +53 -51
  13. package/dist/ai/docs/runjs/context/collection.md +39 -39
  14. package/dist/ai/docs/runjs/context/data-source-manager.md +40 -30
  15. package/dist/ai/docs/runjs/context/data-source.md +52 -44
  16. package/dist/ai/docs/runjs/context/element.md +44 -38
  17. package/dist/ai/docs/runjs/context/exit-all.md +37 -35
  18. package/dist/ai/docs/runjs/context/exit.md +38 -35
  19. package/dist/ai/docs/runjs/context/filter-manager.md +36 -30
  20. package/dist/ai/docs/runjs/context/form.md +57 -57
  21. package/dist/ai/docs/runjs/context/get-model.md +22 -21
  22. package/dist/ai/docs/runjs/context/get-value.md +20 -19
  23. package/dist/ai/docs/runjs/context/get-var.md +61 -55
  24. package/dist/ai/docs/runjs/context/i18n.md +17 -14
  25. package/dist/ai/docs/runjs/context/import-async.md +333 -45
  26. package/dist/ai/docs/runjs/context/init-resource.md +20 -20
  27. package/dist/ai/docs/runjs/context/libs.md +31 -31
  28. package/dist/ai/docs/runjs/context/location.md +34 -31
  29. package/dist/ai/docs/runjs/context/logger.md +41 -40
  30. package/dist/ai/docs/runjs/context/make-resource.md +27 -26
  31. package/dist/ai/docs/runjs/context/message.md +42 -41
  32. package/dist/ai/docs/runjs/context/modal.md +44 -44
  33. package/dist/ai/docs/runjs/context/model.md +36 -33
  34. package/dist/ai/docs/runjs/context/notification.md +41 -40
  35. package/dist/ai/docs/runjs/context/off.md +14 -14
  36. package/dist/ai/docs/runjs/context/on.md +30 -29
  37. package/dist/ai/docs/runjs/context/open-view.md +40 -40
  38. package/dist/ai/docs/runjs/context/render.md +37 -32
  39. package/dist/ai/docs/runjs/context/request.md +46 -45
  40. package/dist/ai/docs/runjs/context/require-async.md +28 -25
  41. package/dist/ai/docs/runjs/context/resource.md +34 -34
  42. package/dist/ai/docs/runjs/context/route.md +36 -34
  43. package/dist/ai/docs/runjs/context/router.md +43 -31
  44. package/dist/ai/docs/runjs/context/set-value.md +18 -17
  45. package/dist/ai/docs/runjs/context/sql.md +7 -15
  46. package/dist/ai/docs/runjs/context/t.md +20 -17
  47. package/dist/ai/docs/runjs/context/view.md +49 -46
  48. package/dist/ai/docs/runjs/document.md +1 -0
  49. package/dist/ai/docs/runjs/import-modules.md +32 -32
  50. package/dist/ai/docs/runjs/index.md +13 -13
  51. package/dist/ai/docs/runjs/jsx.md +19 -19
  52. package/dist/ai/docs/runjs/model/form-block-model.md +1 -3
  53. package/dist/ai/docs/runjs/render.md +15 -15
  54. package/dist/ai/docs/runjs/resource/api-resource.md +53 -53
  55. package/dist/ai/docs/runjs/resource/multi-record-resource.md +64 -64
  56. package/dist/ai/docs/runjs/resource/single-record-resource.md +55 -55
  57. package/dist/ai/docs/runjs/resource/sql-resource.md +57 -57
  58. package/dist/ai/docs/runjs/window.md +5 -5
  59. package/dist/client/index.js +1 -1
  60. package/dist/externalVersion.js +12 -11
  61. package/dist/locale/en-US.json +1 -0
  62. package/dist/locale/index.d.ts +2 -0
  63. package/dist/locale/zh-CN.json +1 -0
  64. package/dist/node_modules/ses/dist/ses.cjs +1 -1
  65. package/dist/node_modules/ses/package.json +1 -1
  66. package/dist/node_modules/zod/index.cjs +1 -1
  67. package/dist/node_modules/zod/package.json +1 -1
  68. package/dist/server/collections/flowsql.js +1 -0
  69. package/dist/server/flow-surfaces/action-scope.d.ts +39 -0
  70. package/dist/server/flow-surfaces/action-scope.js +156 -0
  71. package/dist/server/flow-surfaces/apply/compiler.d.ts +13 -0
  72. package/dist/server/flow-surfaces/apply/compiler.js +971 -0
  73. package/dist/server/flow-surfaces/apply/layout.d.ts +34 -0
  74. package/dist/server/flow-surfaces/apply/layout.js +175 -0
  75. package/dist/server/flow-surfaces/apply/matching.d.ts +16 -0
  76. package/dist/server/flow-surfaces/apply/matching.js +181 -0
  77. package/dist/server/flow-surfaces/approval/blueprint-service.d.ts +84 -0
  78. package/dist/server/flow-surfaces/approval/blueprint-service.js +589 -0
  79. package/dist/server/flow-surfaces/approval/blueprint.d.ts +21 -0
  80. package/dist/server/flow-surfaces/approval/blueprint.js +187 -0
  81. package/dist/server/flow-surfaces/approval/builder.d.ts +225 -0
  82. package/dist/server/flow-surfaces/approval/builder.js +384 -0
  83. package/dist/server/flow-surfaces/approval/catalog-specs.d.ts +33 -0
  84. package/dist/server/flow-surfaces/approval/catalog-specs.js +156 -0
  85. package/dist/server/flow-surfaces/approval/index.d.ts +14 -0
  86. package/dist/server/flow-surfaces/approval/index.js +40 -0
  87. package/dist/server/flow-surfaces/approval/runtime-config.d.ts +44 -0
  88. package/dist/server/flow-surfaces/approval/runtime-config.js +299 -0
  89. package/dist/server/flow-surfaces/approval/semantic-use.d.ts +23 -0
  90. package/dist/server/flow-surfaces/approval/semantic-use.js +155 -0
  91. package/dist/server/flow-surfaces/association-interfaces.d.ts +10 -0
  92. package/dist/server/flow-surfaces/association-interfaces.js +39 -0
  93. package/dist/server/flow-surfaces/association-title-field.d.ts +20 -0
  94. package/dist/server/flow-surfaces/association-title-field.js +192 -0
  95. package/dist/server/flow-surfaces/blueprint/compile-blocks.d.ts +14 -0
  96. package/dist/server/flow-surfaces/blueprint/compile-blocks.js +1074 -0
  97. package/dist/server/flow-surfaces/blueprint/compile-plan.d.ts +13 -0
  98. package/dist/server/flow-surfaces/blueprint/compile-plan.js +308 -0
  99. package/dist/server/flow-surfaces/blueprint/compile-reaction.d.ts +11 -0
  100. package/dist/server/flow-surfaces/blueprint/compile-reaction.js +72 -0
  101. package/dist/server/flow-surfaces/blueprint/defaults.d.ts +26 -0
  102. package/dist/server/flow-surfaces/blueprint/defaults.js +133 -0
  103. package/dist/server/flow-surfaces/blueprint/index.d.ts +12 -0
  104. package/dist/server/flow-surfaces/blueprint/index.js +44 -0
  105. package/dist/server/flow-surfaces/blueprint/normalize-document.d.ts +10 -0
  106. package/dist/server/flow-surfaces/blueprint/normalize-document.js +416 -0
  107. package/dist/server/flow-surfaces/blueprint/private-utils.d.ts +26 -0
  108. package/dist/server/flow-surfaces/blueprint/private-utils.js +182 -0
  109. package/dist/server/flow-surfaces/blueprint/public-types.d.ts +201 -0
  110. package/dist/server/flow-surfaces/blueprint/public-types.js +24 -0
  111. package/dist/server/flow-surfaces/builder.d.ts +237 -0
  112. package/dist/server/flow-surfaces/builder.js +1129 -0
  113. package/dist/server/flow-surfaces/catalog-smart.d.ts +18 -0
  114. package/dist/server/flow-surfaces/catalog-smart.js +239 -0
  115. package/dist/server/flow-surfaces/catalog-smart.projector.d.ts +15 -0
  116. package/dist/server/flow-surfaces/catalog-smart.projector.js +157 -0
  117. package/dist/server/flow-surfaces/catalog-smart.types.d.ts +99 -0
  118. package/dist/server/flow-surfaces/catalog-smart.types.js +24 -0
  119. package/dist/server/flow-surfaces/catalog.d.ts +79 -0
  120. package/dist/server/flow-surfaces/catalog.js +3693 -0
  121. package/dist/server/flow-surfaces/chart-config.d.ts +121 -0
  122. package/dist/server/flow-surfaces/chart-config.js +1394 -0
  123. package/dist/server/flow-surfaces/compose-compiler.d.ts +116 -0
  124. package/dist/server/flow-surfaces/compose-compiler.js +175 -0
  125. package/dist/server/flow-surfaces/compose-runtime.d.ts +93 -0
  126. package/dist/server/flow-surfaces/compose-runtime.js +375 -0
  127. package/dist/server/flow-surfaces/configure-options.d.ts +23 -0
  128. package/dist/server/flow-surfaces/configure-options.js +893 -0
  129. package/dist/server/flow-surfaces/constants.d.ts +351 -0
  130. package/dist/server/flow-surfaces/constants.js +104 -0
  131. package/dist/server/flow-surfaces/context.d.ts +72 -0
  132. package/dist/server/flow-surfaces/context.js +556 -0
  133. package/dist/server/flow-surfaces/contract-guard.d.ts +19 -0
  134. package/dist/server/flow-surfaces/contract-guard.js +402 -0
  135. package/dist/server/flow-surfaces/core-field-default-bindings.d.ts +12 -0
  136. package/dist/server/flow-surfaces/core-field-default-bindings.js +157 -0
  137. package/dist/server/flow-surfaces/default-action-popup.d.ts +63 -0
  138. package/dist/server/flow-surfaces/default-action-popup.js +322 -0
  139. package/dist/server/flow-surfaces/default-block-actions.d.ts +32 -0
  140. package/dist/server/flow-surfaces/default-block-actions.js +209 -0
  141. package/dist/server/flow-surfaces/errors.d.ts +47 -0
  142. package/dist/server/flow-surfaces/errors.js +145 -0
  143. package/dist/server/flow-surfaces/executor.d.ts +23 -0
  144. package/dist/server/flow-surfaces/executor.js +132 -0
  145. package/dist/server/flow-surfaces/field-binding-registry.d.ts +24 -0
  146. package/dist/server/flow-surfaces/field-binding-registry.js +396 -0
  147. package/dist/server/flow-surfaces/field-semantics.d.ts +15 -0
  148. package/dist/server/flow-surfaces/field-semantics.js +84 -0
  149. package/dist/server/flow-surfaces/field-type-resolver.d.ts +46 -0
  150. package/dist/server/flow-surfaces/field-type-resolver.js +322 -0
  151. package/dist/server/flow-surfaces/filter-group.d.ts +15 -0
  152. package/dist/server/flow-surfaces/filter-group.js +94 -0
  153. package/dist/server/flow-surfaces/index.d.ts +11 -0
  154. package/dist/server/flow-surfaces/index.js +302 -0
  155. package/dist/server/flow-surfaces/locator.d.ts +28 -0
  156. package/dist/server/flow-surfaces/locator.js +240 -0
  157. package/dist/server/flow-surfaces/node-use-sets.d.ts +15 -0
  158. package/dist/server/flow-surfaces/node-use-sets.js +135 -0
  159. package/dist/server/flow-surfaces/payload-shape.d.ts +9 -0
  160. package/dist/server/flow-surfaces/payload-shape.js +61 -0
  161. package/dist/server/flow-surfaces/placement.d.ts +33 -0
  162. package/dist/server/flow-surfaces/placement.js +198 -0
  163. package/dist/server/flow-surfaces/planning/action-specs.d.ts +179 -0
  164. package/dist/server/flow-surfaces/planning/action-specs.js +190 -0
  165. package/dist/server/flow-surfaces/planning/compiler.d.ts +37 -0
  166. package/dist/server/flow-surfaces/planning/compiler.js +376 -0
  167. package/dist/server/flow-surfaces/planning/context.d.ts +30 -0
  168. package/dist/server/flow-surfaces/planning/context.js +139 -0
  169. package/dist/server/flow-surfaces/planning/created-keys.d.ts +34 -0
  170. package/dist/server/flow-surfaces/planning/created-keys.js +375 -0
  171. package/dist/server/flow-surfaces/planning/key-kind.d.ts +11 -0
  172. package/dist/server/flow-surfaces/planning/key-kind.js +88 -0
  173. package/dist/server/flow-surfaces/planning/key-persistence.d.ts +34 -0
  174. package/dist/server/flow-surfaces/planning/key-persistence.js +148 -0
  175. package/dist/server/flow-surfaces/planning/key-registry.d.ts +40 -0
  176. package/dist/server/flow-surfaces/planning/key-registry.js +206 -0
  177. package/dist/server/flow-surfaces/planning/runtime.d.ts +37 -0
  178. package/dist/server/flow-surfaces/planning/runtime.js +259 -0
  179. package/dist/server/flow-surfaces/planning/step-link.d.ts +14 -0
  180. package/dist/server/flow-surfaces/planning/step-link.js +104 -0
  181. package/dist/server/flow-surfaces/planning/types.d.ts +55 -0
  182. package/dist/server/flow-surfaces/planning/types.js +24 -0
  183. package/dist/server/flow-surfaces/public-data-surface-default-filter.d.ts +24 -0
  184. package/dist/server/flow-surfaces/public-data-surface-default-filter.js +152 -0
  185. package/dist/server/flow-surfaces/reaction/errors.d.ts +20 -0
  186. package/dist/server/flow-surfaces/reaction/errors.js +69 -0
  187. package/dist/server/flow-surfaces/reaction/field-value.d.ts +34 -0
  188. package/dist/server/flow-surfaces/reaction/field-value.js +181 -0
  189. package/dist/server/flow-surfaces/reaction/fingerprint.d.ts +16 -0
  190. package/dist/server/flow-surfaces/reaction/fingerprint.js +71 -0
  191. package/dist/server/flow-surfaces/reaction/linkage.d.ts +136 -0
  192. package/dist/server/flow-surfaces/reaction/linkage.js +882 -0
  193. package/dist/server/flow-surfaces/reaction/meta.d.ts +11 -0
  194. package/dist/server/flow-surfaces/reaction/meta.js +451 -0
  195. package/dist/server/flow-surfaces/reaction/registry.d.ts +156 -0
  196. package/dist/server/flow-surfaces/reaction/registry.js +206 -0
  197. package/dist/server/flow-surfaces/reaction/resolver.d.ts +22 -0
  198. package/dist/server/flow-surfaces/reaction/resolver.js +202 -0
  199. package/dist/server/flow-surfaces/reaction/types.d.ts +241 -0
  200. package/dist/server/flow-surfaces/reaction/types.js +24 -0
  201. package/dist/server/flow-surfaces/reaction/utils.d.ts +17 -0
  202. package/dist/server/flow-surfaces/reaction/utils.js +67 -0
  203. package/dist/server/flow-surfaces/reaction/value-expr.d.ts +15 -0
  204. package/dist/server/flow-surfaces/reaction/value-expr.js +209 -0
  205. package/dist/server/flow-surfaces/reference-guards.d.ts +19 -0
  206. package/dist/server/flow-surfaces/reference-guards.js +103 -0
  207. package/dist/server/flow-surfaces/route-sync.d.ts +47 -0
  208. package/dist/server/flow-surfaces/route-sync.js +392 -0
  209. package/dist/server/flow-surfaces/service-helpers.d.ts +42 -0
  210. package/dist/server/flow-surfaces/service-helpers.js +310 -0
  211. package/dist/server/flow-surfaces/service-utils.d.ts +120 -0
  212. package/dist/server/flow-surfaces/service-utils.js +863 -0
  213. package/dist/server/flow-surfaces/service.d.ts +830 -0
  214. package/dist/server/flow-surfaces/service.js +15043 -0
  215. package/dist/server/flow-surfaces/support-matrix.d.ts +31 -0
  216. package/dist/server/flow-surfaces/support-matrix.js +282 -0
  217. package/dist/server/flow-surfaces/surface-context.d.ts +52 -0
  218. package/dist/server/flow-surfaces/surface-context.js +440 -0
  219. package/dist/server/flow-surfaces/template-compatibility.d.ts +42 -0
  220. package/dist/server/flow-surfaces/template-compatibility.js +189 -0
  221. package/dist/server/flow-surfaces/template-display.d.ts +20 -0
  222. package/dist/server/flow-surfaces/template-display.js +289 -0
  223. package/dist/server/flow-surfaces/template-service-utils.d.ts +62 -0
  224. package/dist/server/flow-surfaces/template-service-utils.js +281 -0
  225. package/dist/server/flow-surfaces/types.d.ts +288 -0
  226. package/dist/server/flow-surfaces/types.js +24 -0
  227. package/dist/server/index.d.ts +1 -0
  228. package/dist/server/index.js +7 -2
  229. package/dist/server/plugin.d.ts +0 -1
  230. package/dist/server/plugin.js +9 -34
  231. package/dist/server/repository.js +0 -5
  232. package/dist/server/variables/resolve.d.ts +21 -0
  233. package/dist/server/variables/resolve.js +79 -0
  234. package/dist/swagger/flow-surfaces.d.ts +6135 -0
  235. package/dist/swagger/flow-surfaces.examples.d.ts +1577 -0
  236. package/dist/swagger/flow-surfaces.examples.js +1816 -0
  237. package/dist/swagger/flow-surfaces.js +5384 -0
  238. package/dist/swagger/flow-surfaces.template-action-docs.d.ts +62 -0
  239. package/dist/swagger/flow-surfaces.template-action-docs.js +121 -0
  240. package/dist/swagger/flow-surfaces.template-schemas.d.ts +239 -0
  241. package/dist/swagger/flow-surfaces.template-schemas.js +255 -0
  242. package/dist/swagger/index.d.ts +6140 -0
  243. package/dist/swagger/index.js +50 -0
  244. package/package.json +3 -3
  245. /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextApis.d.ts +0 -0
  246. /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextEnvs.d.ts +0 -0
  247. /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextVars.d.ts +0 -0
  248. /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/lintAndTestJS.d.ts +0 -0
@@ -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
+ });
@@ -0,0 +1,15 @@
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_EMPTY_FILTER_GROUP: {
10
+ logic: string;
11
+ items: any[];
12
+ };
13
+ export declare const FLOW_SURFACE_FILTER_GROUP_EXAMPLE: string;
14
+ export declare function normalizeFlowSurfaceFilterGroupValue(value: any, errorPrefix: string): any;
15
+ export declare function assertFlowSurfaceFilterGroupShape(filter: any): void;
@@ -0,0 +1,94 @@
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 filter_group_exports = {};
38
+ __export(filter_group_exports, {
39
+ FLOW_SURFACE_EMPTY_FILTER_GROUP: () => FLOW_SURFACE_EMPTY_FILTER_GROUP,
40
+ FLOW_SURFACE_FILTER_GROUP_EXAMPLE: () => FLOW_SURFACE_FILTER_GROUP_EXAMPLE,
41
+ assertFlowSurfaceFilterGroupShape: () => assertFlowSurfaceFilterGroupShape,
42
+ normalizeFlowSurfaceFilterGroupValue: () => normalizeFlowSurfaceFilterGroupValue
43
+ });
44
+ module.exports = __toCommonJS(filter_group_exports);
45
+ var import_utils = require("@nocobase/utils");
46
+ var import_lodash = __toESM(require("lodash"));
47
+ var import_errors = require("./errors");
48
+ const FLOW_SURFACE_EMPTY_FILTER_GROUP = {
49
+ logic: "$and",
50
+ items: []
51
+ };
52
+ const FLOW_SURFACE_FILTER_GROUP_EXAMPLE = JSON.stringify(FLOW_SURFACE_EMPTY_FILTER_GROUP);
53
+ function normalizeFlowSurfaceFilterGroupValue(value, errorPrefix) {
54
+ const normalized = value === null || import_lodash.default.isPlainObject(value) && !Object.keys(value).length ? import_lodash.default.cloneDeep(FLOW_SURFACE_EMPTY_FILTER_GROUP) : import_lodash.default.cloneDeep(value);
55
+ try {
56
+ assertFlowSurfaceFilterGroupShape(normalized);
57
+ (0, import_utils.transformFilter)(normalized);
58
+ return normalized;
59
+ } catch (error) {
60
+ const reason = error instanceof Error ? error.message : String(error);
61
+ (0, import_errors.throwBadRequest)(`${errorPrefix}: ${reason}`);
62
+ }
63
+ }
64
+ function assertFlowSurfaceFilterGroupShape(filter) {
65
+ if (!import_lodash.default.isPlainObject(filter)) {
66
+ throw new Error("Invalid filter: filter must be an object");
67
+ }
68
+ if (!("logic" in filter) || !("items" in filter)) {
69
+ throw new Error("Invalid filter: filter must have logic and items properties");
70
+ }
71
+ if (filter.logic !== "$and" && filter.logic !== "$or") {
72
+ throw new Error("Invalid filter: logic must be '$and' or '$or'");
73
+ }
74
+ if (!Array.isArray(filter.items)) {
75
+ throw new Error("Invalid filter: items must be an array");
76
+ }
77
+ filter.items.forEach((item) => {
78
+ if (import_lodash.default.isPlainObject(item) && "logic" in item && "items" in item) {
79
+ assertFlowSurfaceFilterGroupShape(item);
80
+ return;
81
+ }
82
+ if (import_lodash.default.isPlainObject(item) && typeof item.path === "string" && typeof item.operator === "string") {
83
+ return;
84
+ }
85
+ throw new Error("Invalid filter item type");
86
+ });
87
+ }
88
+ // Annotate the CommonJS export names for ESM import in node:
89
+ 0 && (module.exports = {
90
+ FLOW_SURFACE_EMPTY_FILTER_GROUP,
91
+ FLOW_SURFACE_FILTER_GROUP_EXAMPLE,
92
+ assertFlowSurfaceFilterGroupShape,
93
+ normalizeFlowSurfaceFilterGroupValue
94
+ });
@@ -0,0 +1,11 @@
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
+ import type { Plugin } from '@nocobase/server';
10
+ import { FlowSurfacesService } from './service';
11
+ export declare function registerFlowSurfacesResource(plugin: Plugin): FlowSurfacesService;