@nocobase/plugin-flow-engine 2.1.0-alpha.3 → 2.1.0-alpha.31

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 (264) 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 +42 -0
  5. package/dist/ai/ai-employees/nathan/prompt.md +168 -0
  6. package/dist/ai/ai-employees/nathan/skills/frontend-developer/SKILLS.md +86 -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 +6 -4
  11. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/patchJSCode.d.ts +10 -0
  12. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/patchJSCode.js +65 -0
  13. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/readJSCode.d.ts +10 -0
  14. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/readJSCode.js +61 -0
  15. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/writeJSCode.d.ts +10 -0
  16. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/writeJSCode.js +65 -0
  17. package/dist/ai/docs/runjs/context/block-model.md +35 -35
  18. package/dist/ai/docs/runjs/context/collection-field.md +53 -51
  19. package/dist/ai/docs/runjs/context/collection.md +39 -39
  20. package/dist/ai/docs/runjs/context/data-source-manager.md +40 -30
  21. package/dist/ai/docs/runjs/context/data-source.md +52 -44
  22. package/dist/ai/docs/runjs/context/element.md +44 -38
  23. package/dist/ai/docs/runjs/context/exit-all.md +37 -35
  24. package/dist/ai/docs/runjs/context/exit.md +38 -35
  25. package/dist/ai/docs/runjs/context/filter-manager.md +36 -30
  26. package/dist/ai/docs/runjs/context/form.md +57 -57
  27. package/dist/ai/docs/runjs/context/get-model.md +22 -21
  28. package/dist/ai/docs/runjs/context/get-value.md +20 -19
  29. package/dist/ai/docs/runjs/context/get-var.md +61 -55
  30. package/dist/ai/docs/runjs/context/i18n.md +17 -14
  31. package/dist/ai/docs/runjs/context/import-async.md +333 -45
  32. package/dist/ai/docs/runjs/context/init-resource.md +20 -20
  33. package/dist/ai/docs/runjs/context/libs.md +31 -31
  34. package/dist/ai/docs/runjs/context/location.md +34 -31
  35. package/dist/ai/docs/runjs/context/logger.md +41 -40
  36. package/dist/ai/docs/runjs/context/make-resource.md +27 -26
  37. package/dist/ai/docs/runjs/context/message.md +42 -41
  38. package/dist/ai/docs/runjs/context/modal.md +44 -44
  39. package/dist/ai/docs/runjs/context/model.md +36 -33
  40. package/dist/ai/docs/runjs/context/notification.md +41 -40
  41. package/dist/ai/docs/runjs/context/off.md +14 -14
  42. package/dist/ai/docs/runjs/context/on.md +30 -29
  43. package/dist/ai/docs/runjs/context/open-view.md +40 -40
  44. package/dist/ai/docs/runjs/context/render.md +37 -32
  45. package/dist/ai/docs/runjs/context/request.md +46 -45
  46. package/dist/ai/docs/runjs/context/require-async.md +28 -25
  47. package/dist/ai/docs/runjs/context/resource.md +34 -34
  48. package/dist/ai/docs/runjs/context/route.md +36 -34
  49. package/dist/ai/docs/runjs/context/router.md +43 -31
  50. package/dist/ai/docs/runjs/context/set-value.md +18 -17
  51. package/dist/ai/docs/runjs/context/sql.md +7 -15
  52. package/dist/ai/docs/runjs/context/t.md +20 -17
  53. package/dist/ai/docs/runjs/context/view.md +49 -46
  54. package/dist/ai/docs/runjs/document.md +1 -0
  55. package/dist/ai/docs/runjs/import-modules.md +32 -32
  56. package/dist/ai/docs/runjs/index.md +13 -13
  57. package/dist/ai/docs/runjs/jsx.md +19 -19
  58. package/dist/ai/docs/runjs/model/form-block-model.md +1 -3
  59. package/dist/ai/docs/runjs/render.md +15 -15
  60. package/dist/ai/docs/runjs/resource/api-resource.md +53 -53
  61. package/dist/ai/docs/runjs/resource/multi-record-resource.md +64 -64
  62. package/dist/ai/docs/runjs/resource/single-record-resource.md +55 -55
  63. package/dist/ai/docs/runjs/resource/sql-resource.md +57 -57
  64. package/dist/ai/docs/runjs/window.md +5 -5
  65. package/dist/client/index.js +1 -1
  66. package/dist/externalVersion.js +12 -11
  67. package/dist/locale/en-US.json +1 -0
  68. package/dist/locale/index.d.ts +2 -0
  69. package/dist/locale/zh-CN.json +1 -0
  70. package/dist/node_modules/ses/dist/ses.cjs +1 -1
  71. package/dist/node_modules/ses/package.json +1 -1
  72. package/dist/node_modules/zod/index.cjs +1 -1
  73. package/dist/node_modules/zod/package.json +1 -1
  74. package/dist/server/collections/flowsql.js +1 -0
  75. package/dist/server/flow-surfaces/action-scope.d.ts +39 -0
  76. package/dist/server/flow-surfaces/action-scope.js +156 -0
  77. package/dist/server/flow-surfaces/apply/compiler.d.ts +13 -0
  78. package/dist/server/flow-surfaces/apply/compiler.js +971 -0
  79. package/dist/server/flow-surfaces/apply/layout.d.ts +34 -0
  80. package/dist/server/flow-surfaces/apply/layout.js +175 -0
  81. package/dist/server/flow-surfaces/apply/matching.d.ts +16 -0
  82. package/dist/server/flow-surfaces/apply/matching.js +181 -0
  83. package/dist/server/flow-surfaces/approval/blueprint-service.d.ts +84 -0
  84. package/dist/server/flow-surfaces/approval/blueprint-service.js +589 -0
  85. package/dist/server/flow-surfaces/approval/blueprint.d.ts +21 -0
  86. package/dist/server/flow-surfaces/approval/blueprint.js +187 -0
  87. package/dist/server/flow-surfaces/approval/builder.d.ts +225 -0
  88. package/dist/server/flow-surfaces/approval/builder.js +384 -0
  89. package/dist/server/flow-surfaces/approval/catalog-specs.d.ts +33 -0
  90. package/dist/server/flow-surfaces/approval/catalog-specs.js +156 -0
  91. package/dist/server/flow-surfaces/approval/index.d.ts +14 -0
  92. package/dist/server/flow-surfaces/approval/index.js +40 -0
  93. package/dist/server/flow-surfaces/approval/runtime-config.d.ts +44 -0
  94. package/dist/server/flow-surfaces/approval/runtime-config.js +299 -0
  95. package/dist/server/flow-surfaces/approval/semantic-use.d.ts +23 -0
  96. package/dist/server/flow-surfaces/approval/semantic-use.js +155 -0
  97. package/dist/server/flow-surfaces/association-interfaces.d.ts +10 -0
  98. package/dist/server/flow-surfaces/association-interfaces.js +39 -0
  99. package/dist/server/flow-surfaces/association-title-field.d.ts +20 -0
  100. package/dist/server/flow-surfaces/association-title-field.js +192 -0
  101. package/dist/server/flow-surfaces/blueprint/compile-blocks.d.ts +15 -0
  102. package/dist/server/flow-surfaces/blueprint/compile-blocks.js +1251 -0
  103. package/dist/server/flow-surfaces/blueprint/compile-plan.d.ts +14 -0
  104. package/dist/server/flow-surfaces/blueprint/compile-plan.js +308 -0
  105. package/dist/server/flow-surfaces/blueprint/compile-reaction.d.ts +11 -0
  106. package/dist/server/flow-surfaces/blueprint/compile-reaction.js +72 -0
  107. package/dist/server/flow-surfaces/blueprint/defaults.d.ts +26 -0
  108. package/dist/server/flow-surfaces/blueprint/defaults.js +133 -0
  109. package/dist/server/flow-surfaces/blueprint/index.d.ts +12 -0
  110. package/dist/server/flow-surfaces/blueprint/index.js +44 -0
  111. package/dist/server/flow-surfaces/blueprint/normalize-document.d.ts +10 -0
  112. package/dist/server/flow-surfaces/blueprint/normalize-document.js +407 -0
  113. package/dist/server/flow-surfaces/blueprint/private-utils.d.ts +25 -0
  114. package/dist/server/flow-surfaces/blueprint/private-utils.js +179 -0
  115. package/dist/server/flow-surfaces/blueprint/public-types.d.ts +201 -0
  116. package/dist/server/flow-surfaces/blueprint/public-types.js +24 -0
  117. package/dist/server/flow-surfaces/builder.d.ts +238 -0
  118. package/dist/server/flow-surfaces/builder.js +1261 -0
  119. package/dist/server/flow-surfaces/catalog-smart.d.ts +18 -0
  120. package/dist/server/flow-surfaces/catalog-smart.js +239 -0
  121. package/dist/server/flow-surfaces/catalog-smart.projector.d.ts +15 -0
  122. package/dist/server/flow-surfaces/catalog-smart.projector.js +157 -0
  123. package/dist/server/flow-surfaces/catalog-smart.types.d.ts +99 -0
  124. package/dist/server/flow-surfaces/catalog-smart.types.js +24 -0
  125. package/dist/server/flow-surfaces/catalog.d.ts +79 -0
  126. package/dist/server/flow-surfaces/catalog.js +3743 -0
  127. package/dist/server/flow-surfaces/chart-config.d.ts +121 -0
  128. package/dist/server/flow-surfaces/chart-config.js +1394 -0
  129. package/dist/server/flow-surfaces/compose-compiler.d.ts +115 -0
  130. package/dist/server/flow-surfaces/compose-compiler.js +174 -0
  131. package/dist/server/flow-surfaces/compose-runtime.d.ts +94 -0
  132. package/dist/server/flow-surfaces/compose-runtime.js +376 -0
  133. package/dist/server/flow-surfaces/configure-options.d.ts +23 -0
  134. package/dist/server/flow-surfaces/configure-options.js +904 -0
  135. package/dist/server/flow-surfaces/constants.d.ts +351 -0
  136. package/dist/server/flow-surfaces/constants.js +104 -0
  137. package/dist/server/flow-surfaces/context.d.ts +72 -0
  138. package/dist/server/flow-surfaces/context.js +556 -0
  139. package/dist/server/flow-surfaces/contract-guard.d.ts +19 -0
  140. package/dist/server/flow-surfaces/contract-guard.js +410 -0
  141. package/dist/server/flow-surfaces/core-field-default-bindings.d.ts +12 -0
  142. package/dist/server/flow-surfaces/core-field-default-bindings.js +157 -0
  143. package/dist/server/flow-surfaces/default-action-popup.d.ts +63 -0
  144. package/dist/server/flow-surfaces/default-action-popup.js +322 -0
  145. package/dist/server/flow-surfaces/default-block-actions.d.ts +32 -0
  146. package/dist/server/flow-surfaces/default-block-actions.js +210 -0
  147. package/dist/server/flow-surfaces/errors.d.ts +47 -0
  148. package/dist/server/flow-surfaces/errors.js +145 -0
  149. package/dist/server/flow-surfaces/executor.d.ts +23 -0
  150. package/dist/server/flow-surfaces/executor.js +132 -0
  151. package/dist/server/flow-surfaces/field-binding-registry.d.ts +24 -0
  152. package/dist/server/flow-surfaces/field-binding-registry.js +396 -0
  153. package/dist/server/flow-surfaces/field-semantics.d.ts +15 -0
  154. package/dist/server/flow-surfaces/field-semantics.js +84 -0
  155. package/dist/server/flow-surfaces/field-type-resolver.d.ts +45 -0
  156. package/dist/server/flow-surfaces/field-type-resolver.js +312 -0
  157. package/dist/server/flow-surfaces/filter-group.d.ts +15 -0
  158. package/dist/server/flow-surfaces/filter-group.js +94 -0
  159. package/dist/server/flow-surfaces/hidden-popup-calendar.d.ts +86 -0
  160. package/dist/server/flow-surfaces/hidden-popup-calendar.js +554 -0
  161. package/dist/server/flow-surfaces/hidden-popup-contract.d.ts +116 -0
  162. package/dist/server/flow-surfaces/hidden-popup-contract.js +611 -0
  163. package/dist/server/flow-surfaces/hidden-popup-kanban.d.ts +62 -0
  164. package/dist/server/flow-surfaces/hidden-popup-kanban.js +651 -0
  165. package/dist/server/flow-surfaces/index.d.ts +11 -0
  166. package/dist/server/flow-surfaces/index.js +302 -0
  167. package/dist/server/flow-surfaces/locator.d.ts +28 -0
  168. package/dist/server/flow-surfaces/locator.js +240 -0
  169. package/dist/server/flow-surfaces/node-use-sets.d.ts +15 -0
  170. package/dist/server/flow-surfaces/node-use-sets.js +135 -0
  171. package/dist/server/flow-surfaces/payload-shape.d.ts +9 -0
  172. package/dist/server/flow-surfaces/payload-shape.js +61 -0
  173. package/dist/server/flow-surfaces/placement.d.ts +33 -0
  174. package/dist/server/flow-surfaces/placement.js +199 -0
  175. package/dist/server/flow-surfaces/planning/action-specs.d.ts +179 -0
  176. package/dist/server/flow-surfaces/planning/action-specs.js +190 -0
  177. package/dist/server/flow-surfaces/planning/compiler.d.ts +37 -0
  178. package/dist/server/flow-surfaces/planning/compiler.js +376 -0
  179. package/dist/server/flow-surfaces/planning/context.d.ts +30 -0
  180. package/dist/server/flow-surfaces/planning/context.js +139 -0
  181. package/dist/server/flow-surfaces/planning/created-keys.d.ts +34 -0
  182. package/dist/server/flow-surfaces/planning/created-keys.js +375 -0
  183. package/dist/server/flow-surfaces/planning/key-kind.d.ts +11 -0
  184. package/dist/server/flow-surfaces/planning/key-kind.js +88 -0
  185. package/dist/server/flow-surfaces/planning/key-persistence.d.ts +34 -0
  186. package/dist/server/flow-surfaces/planning/key-persistence.js +148 -0
  187. package/dist/server/flow-surfaces/planning/key-registry.d.ts +40 -0
  188. package/dist/server/flow-surfaces/planning/key-registry.js +206 -0
  189. package/dist/server/flow-surfaces/planning/runtime.d.ts +37 -0
  190. package/dist/server/flow-surfaces/planning/runtime.js +259 -0
  191. package/dist/server/flow-surfaces/planning/step-link.d.ts +14 -0
  192. package/dist/server/flow-surfaces/planning/step-link.js +104 -0
  193. package/dist/server/flow-surfaces/planning/types.d.ts +55 -0
  194. package/dist/server/flow-surfaces/planning/types.js +24 -0
  195. package/dist/server/flow-surfaces/public-compatibility.d.ts +28 -0
  196. package/dist/server/flow-surfaces/public-compatibility.js +161 -0
  197. package/dist/server/flow-surfaces/public-data-surface-default-filter.d.ts +24 -0
  198. package/dist/server/flow-surfaces/public-data-surface-default-filter.js +152 -0
  199. package/dist/server/flow-surfaces/reaction/errors.d.ts +20 -0
  200. package/dist/server/flow-surfaces/reaction/errors.js +69 -0
  201. package/dist/server/flow-surfaces/reaction/field-value.d.ts +34 -0
  202. package/dist/server/flow-surfaces/reaction/field-value.js +181 -0
  203. package/dist/server/flow-surfaces/reaction/fingerprint.d.ts +16 -0
  204. package/dist/server/flow-surfaces/reaction/fingerprint.js +71 -0
  205. package/dist/server/flow-surfaces/reaction/linkage.d.ts +136 -0
  206. package/dist/server/flow-surfaces/reaction/linkage.js +882 -0
  207. package/dist/server/flow-surfaces/reaction/meta.d.ts +11 -0
  208. package/dist/server/flow-surfaces/reaction/meta.js +451 -0
  209. package/dist/server/flow-surfaces/reaction/registry.d.ts +156 -0
  210. package/dist/server/flow-surfaces/reaction/registry.js +206 -0
  211. package/dist/server/flow-surfaces/reaction/resolver.d.ts +22 -0
  212. package/dist/server/flow-surfaces/reaction/resolver.js +202 -0
  213. package/dist/server/flow-surfaces/reaction/types.d.ts +241 -0
  214. package/dist/server/flow-surfaces/reaction/types.js +24 -0
  215. package/dist/server/flow-surfaces/reaction/utils.d.ts +17 -0
  216. package/dist/server/flow-surfaces/reaction/utils.js +67 -0
  217. package/dist/server/flow-surfaces/reaction/value-expr.d.ts +15 -0
  218. package/dist/server/flow-surfaces/reaction/value-expr.js +209 -0
  219. package/dist/server/flow-surfaces/reference-guards.d.ts +19 -0
  220. package/dist/server/flow-surfaces/reference-guards.js +103 -0
  221. package/dist/server/flow-surfaces/route-sync.d.ts +50 -0
  222. package/dist/server/flow-surfaces/route-sync.js +393 -0
  223. package/dist/server/flow-surfaces/service-helpers.d.ts +42 -0
  224. package/dist/server/flow-surfaces/service-helpers.js +310 -0
  225. package/dist/server/flow-surfaces/service-utils.d.ts +120 -0
  226. package/dist/server/flow-surfaces/service-utils.js +878 -0
  227. package/dist/server/flow-surfaces/service.d.ts +896 -0
  228. package/dist/server/flow-surfaces/service.js +16248 -0
  229. package/dist/server/flow-surfaces/support-matrix.d.ts +31 -0
  230. package/dist/server/flow-surfaces/support-matrix.js +282 -0
  231. package/dist/server/flow-surfaces/surface-context.d.ts +52 -0
  232. package/dist/server/flow-surfaces/surface-context.js +440 -0
  233. package/dist/server/flow-surfaces/template-compatibility.d.ts +42 -0
  234. package/dist/server/flow-surfaces/template-compatibility.js +189 -0
  235. package/dist/server/flow-surfaces/template-display.d.ts +20 -0
  236. package/dist/server/flow-surfaces/template-display.js +289 -0
  237. package/dist/server/flow-surfaces/template-service-utils.d.ts +62 -0
  238. package/dist/server/flow-surfaces/template-service-utils.js +281 -0
  239. package/dist/server/flow-surfaces/types.d.ts +288 -0
  240. package/dist/server/flow-surfaces/types.js +24 -0
  241. package/dist/server/index.d.ts +1 -0
  242. package/dist/server/index.js +7 -2
  243. package/dist/server/migrations/20260508000000-remove-flow-model-options-runtime-uid.d.ts +13 -0
  244. package/dist/server/migrations/20260508000000-remove-flow-model-options-runtime-uid.js +67 -0
  245. package/dist/server/plugin.d.ts +0 -1
  246. package/dist/server/plugin.js +9 -34
  247. package/dist/server/repository.js +0 -5
  248. package/dist/server/variables/resolve.d.ts +21 -0
  249. package/dist/server/variables/resolve.js +79 -0
  250. package/dist/swagger/flow-surfaces.d.ts +6106 -0
  251. package/dist/swagger/flow-surfaces.examples.d.ts +1577 -0
  252. package/dist/swagger/flow-surfaces.examples.js +1816 -0
  253. package/dist/swagger/flow-surfaces.js +5375 -0
  254. package/dist/swagger/flow-surfaces.template-action-docs.d.ts +62 -0
  255. package/dist/swagger/flow-surfaces.template-action-docs.js +121 -0
  256. package/dist/swagger/flow-surfaces.template-schemas.d.ts +239 -0
  257. package/dist/swagger/flow-surfaces.template-schemas.js +255 -0
  258. package/dist/swagger/index.d.ts +6111 -0
  259. package/dist/swagger/index.js +50 -0
  260. package/package.json +3 -3
  261. /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextApis.d.ts +0 -0
  262. /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextEnvs.d.ts +0 -0
  263. /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextVars.d.ts +0 -0
  264. /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/lintAndTestJS.d.ts +0 -0
@@ -0,0 +1,393 @@
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 route_sync_exports = {};
38
+ __export(route_sync_exports, {
39
+ FlowSurfaceRouteSync: () => FlowSurfaceRouteSync
40
+ });
41
+ module.exports = __toCommonJS(route_sync_exports);
42
+ var import_lodash = __toESM(require("lodash"));
43
+ var import_builder = require("./builder");
44
+ class FlowSurfaceRouteSync {
45
+ constructor(db, repository, patchModel = (values, options) => repository.patch(values, options)) {
46
+ this.db = db;
47
+ this.repository = repository;
48
+ this.patchModel = patchModel;
49
+ }
50
+ async buildPageTree(pageRouteLike, transaction) {
51
+ var _a, _b, _c, _d, _e, _f, _g;
52
+ const pageRoute = await this.hydrateRoute(pageRouteLike, transaction);
53
+ const pageSchemaUid = ((_a = pageRoute == null ? void 0 : pageRoute.get) == null ? void 0 : _a.call(pageRoute, "schemaUid")) || (pageRoute == null ? void 0 : pageRoute.schemaUid);
54
+ const pageModel = await this.repository.findModelByParentId(pageSchemaUid, {
55
+ transaction,
56
+ subKey: "page",
57
+ includeAsyncNode: true
58
+ });
59
+ const tabs = await Promise.all(
60
+ import_lodash.default.sortBy(
61
+ import_lodash.default.castArray(((_b = pageRoute == null ? void 0 : pageRoute.get) == null ? void 0 : _b.call(pageRoute, "children")) || (pageRoute == null ? void 0 : pageRoute.children) || []),
62
+ (item) => {
63
+ var _a2;
64
+ return ((_a2 = item == null ? void 0 : item.get) == null ? void 0 : _a2.call(item, "sort")) ?? (item == null ? void 0 : item.sort);
65
+ }
66
+ ).map((route) => this.buildTabAnchor(route, transaction))
67
+ );
68
+ const routeBacked = this.readPageRouteBackedState(pageRoute, pageModel);
69
+ if (pageModel == null ? void 0 : pageModel.uid) {
70
+ return {
71
+ ...pageModel,
72
+ props: {
73
+ ...pageModel.props || {},
74
+ routeId: ((_c = pageRoute == null ? void 0 : pageRoute.get) == null ? void 0 : _c.call(pageRoute, "id")) || (pageRoute == null ? void 0 : pageRoute.id),
75
+ ...routeBacked
76
+ },
77
+ stepParams: {
78
+ ...pageModel.stepParams || {},
79
+ pageSettings: {
80
+ ...((_d = pageModel.stepParams) == null ? void 0 : _d.pageSettings) || {},
81
+ general: {
82
+ ...((_f = (_e = pageModel.stepParams) == null ? void 0 : _e.pageSettings) == null ? void 0 : _f.general) || {},
83
+ ...routeBacked
84
+ }
85
+ }
86
+ },
87
+ subModels: {
88
+ ...pageModel.subModels || {},
89
+ tabs
90
+ }
91
+ };
92
+ }
93
+ return {
94
+ uid: pageSchemaUid,
95
+ use: "RootPageModel",
96
+ props: {
97
+ routeId: ((_g = pageRoute == null ? void 0 : pageRoute.get) == null ? void 0 : _g.call(pageRoute, "id")) || (pageRoute == null ? void 0 : pageRoute.id),
98
+ ...routeBacked
99
+ },
100
+ stepParams: {
101
+ pageSettings: {
102
+ general: {
103
+ ...routeBacked
104
+ }
105
+ }
106
+ },
107
+ subModels: {
108
+ tabs
109
+ }
110
+ };
111
+ }
112
+ async buildTabAnchor(tabRouteLike, transaction) {
113
+ var _a, _b, _c;
114
+ const tabRoute = await this.hydrateRoute(tabRouteLike, transaction);
115
+ const schemaUid = ((_a = tabRoute == null ? void 0 : tabRoute.get) == null ? void 0 : _a.call(tabRoute, "schemaUid")) || (tabRoute == null ? void 0 : tabRoute.schemaUid);
116
+ const routeNode = await this.repository.findModelById(schemaUid, {
117
+ transaction,
118
+ includeAsyncNode: true
119
+ });
120
+ const grid = ((_b = routeNode == null ? void 0 : routeNode.subModels) == null ? void 0 : _b.grid) || await this.repository.findModelByParentId(schemaUid, {
121
+ transaction,
122
+ subKey: "grid",
123
+ includeAsyncNode: true
124
+ });
125
+ return (0, import_builder.buildSyntheticRootPageTabModel)({
126
+ uid: schemaUid,
127
+ use: (routeNode == null ? void 0 : routeNode.use) || "RootPageTabModel",
128
+ props: (routeNode == null ? void 0 : routeNode.props) || {},
129
+ decoratorProps: (routeNode == null ? void 0 : routeNode.decoratorProps) || {},
130
+ flowRegistry: readRouteOptions(tabRoute).flowRegistry || (routeNode == null ? void 0 : routeNode.flowRegistry) || {},
131
+ stepParams: (routeNode == null ? void 0 : routeNode.stepParams) || {},
132
+ route: ((_c = tabRoute == null ? void 0 : tabRoute.toJSON) == null ? void 0 : _c.call(tabRoute)) || tabRoute,
133
+ title: readRouteProp(tabRoute, "title"),
134
+ icon: readRouteProp(tabRoute, "icon"),
135
+ documentTitle: readRouteOptions(tabRoute).documentTitle,
136
+ grid
137
+ });
138
+ }
139
+ async removeRouteAnchorChildren(schemaUid, transaction) {
140
+ if (!schemaUid) {
141
+ return;
142
+ }
143
+ const node = await this.repository.findModelById(schemaUid, {
144
+ transaction,
145
+ includeAsyncNode: true
146
+ });
147
+ const children = Object.values((node == null ? void 0 : node.subModels) || {}).flatMap((value) => import_lodash.default.castArray(value));
148
+ for (const child of children) {
149
+ await this.repository.remove(child.uid, { transaction });
150
+ }
151
+ const asyncGridChild = await this.repository.findModelByParentId(schemaUid, {
152
+ transaction,
153
+ subKey: "grid",
154
+ includeAsyncNode: true
155
+ });
156
+ if (asyncGridChild == null ? void 0 : asyncGridChild.uid) {
157
+ await this.repository.remove(asyncGridChild.uid, { transaction });
158
+ }
159
+ }
160
+ async removeTabAnchorTree(schemaUid, transaction) {
161
+ const tabAnchor = await this.findPersistedTabAnchor(schemaUid, transaction);
162
+ if (tabAnchor == null ? void 0 : tabAnchor.uid) {
163
+ await this.repository.remove(tabAnchor.uid, { transaction });
164
+ return;
165
+ }
166
+ await this.removeRouteAnchorChildren(schemaUid, transaction);
167
+ }
168
+ async persistPageSettings(target, current, nextPayload, transaction) {
169
+ var _a;
170
+ const route = await this.hydrateRoute(target.pageRoute, transaction);
171
+ const routeValues = this.buildPageRoutePatch(current, nextPayload, route);
172
+ if (Object.keys(routeValues).length) {
173
+ await this.db.getRepository("desktopRoutes").update({
174
+ filterByTk: String(route.get("id")),
175
+ values: routeValues,
176
+ transaction
177
+ });
178
+ }
179
+ const pageSchemaUid = ((_a = route == null ? void 0 : route.get) == null ? void 0 : _a.call(route, "schemaUid")) || (route == null ? void 0 : route.schemaUid);
180
+ const pageModel = target.pageModel || (pageSchemaUid ? await this.repository.findModelByParentId(pageSchemaUid, {
181
+ transaction,
182
+ subKey: "page",
183
+ includeAsyncNode: true
184
+ }) : null);
185
+ if (pageModel == null ? void 0 : pageModel.uid) {
186
+ await this.patchModel(
187
+ {
188
+ ...this.normalizePagePayload(current, nextPayload, routeValues),
189
+ uid: pageModel.uid
190
+ },
191
+ { transaction }
192
+ );
193
+ }
194
+ }
195
+ async persistTabSettings(target, current, nextPayload, transaction) {
196
+ const route = await this.hydrateRoute(target.tabRoute, transaction);
197
+ const routeValues = this.buildTabRoutePatch(current, nextPayload, route);
198
+ if (Object.keys(routeValues).length) {
199
+ await this.db.getRepository("desktopRoutes").update({
200
+ filterByTk: String(route.get("id")),
201
+ values: routeValues,
202
+ transaction
203
+ });
204
+ }
205
+ const tabAnchor = await this.findPersistedTabAnchor(target.uid || (current == null ? void 0 : current.uid), transaction);
206
+ if (!(tabAnchor == null ? void 0 : tabAnchor.uid)) {
207
+ return;
208
+ }
209
+ const latestRoute = await this.hydrateRoute(target.tabRoute, transaction);
210
+ await this.patchModel(
211
+ this.normalizeTabPayload(await this.buildTabAnchor(latestRoute, transaction), nextPayload, routeValues),
212
+ { transaction }
213
+ );
214
+ }
215
+ async findPersistedTabAnchor(schemaUid, transaction) {
216
+ const node = await this.repository.findModelById(schemaUid, {
217
+ transaction,
218
+ includeAsyncNode: true
219
+ });
220
+ if ((node == null ? void 0 : node.use) === "RootPageTabModel" || (node == null ? void 0 : node.use) === "ChildPageTabModel") {
221
+ return node;
222
+ }
223
+ return null;
224
+ }
225
+ async hydrateRoute(routeLike, transaction) {
226
+ var _a;
227
+ if (!((_a = routeLike == null ? void 0 : routeLike.get) == null ? void 0 : _a.call(routeLike, "id"))) {
228
+ return routeLike;
229
+ }
230
+ return this.db.getRepository("desktopRoutes").findOne({
231
+ filterByTk: String(routeLike.get("id")),
232
+ appends: ["children"],
233
+ transaction
234
+ });
235
+ }
236
+ readPageRouteBackedState(route, pageModel) {
237
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
238
+ return {
239
+ title: readRouteProp(route, "title") ?? ((_a = pageModel == null ? void 0 : pageModel.props) == null ? void 0 : _a.title) ?? ((_d = (_c = (_b = pageModel == null ? void 0 : pageModel.stepParams) == null ? void 0 : _b.pageSettings) == null ? void 0 : _c.general) == null ? void 0 : _d.title),
240
+ icon: readRouteProp(route, "icon") ?? ((_e = pageModel == null ? void 0 : pageModel.props) == null ? void 0 : _e.icon) ?? ((_h = (_g = (_f = pageModel == null ? void 0 : pageModel.stepParams) == null ? void 0 : _f.pageSettings) == null ? void 0 : _g.general) == null ? void 0 : _h.icon),
241
+ enableTabs: !!(readRouteProp(route, "enableTabs") ?? ((_i = pageModel == null ? void 0 : pageModel.props) == null ? void 0 : _i.enableTabs) ?? ((_l = (_k = (_j = pageModel == null ? void 0 : pageModel.stepParams) == null ? void 0 : _j.pageSettings) == null ? void 0 : _k.general) == null ? void 0 : _l.enableTabs)),
242
+ enableHeader: firstDefined(
243
+ readRouteProp(route, "enableHeader"),
244
+ (_m = pageModel == null ? void 0 : pageModel.props) == null ? void 0 : _m.enableHeader,
245
+ (_p = (_o = (_n = pageModel == null ? void 0 : pageModel.stepParams) == null ? void 0 : _n.pageSettings) == null ? void 0 : _o.general) == null ? void 0 : _p.enableHeader
246
+ ),
247
+ displayTitle: !!(readRouteProp(route, "displayTitle") ?? ((_q = pageModel == null ? void 0 : pageModel.props) == null ? void 0 : _q.displayTitle) ?? ((_t = (_s = (_r = pageModel == null ? void 0 : pageModel.stepParams) == null ? void 0 : _r.pageSettings) == null ? void 0 : _s.general) == null ? void 0 : _t.displayTitle) ?? true)
248
+ };
249
+ }
250
+ buildPageRoutePatch(current, nextPayload, route) {
251
+ var _a, _b, _c, _d, _e, _f, _g, _h;
252
+ const nextProps = nextPayload.props || {};
253
+ const nextGeneral = ((_b = (_a = nextPayload.stepParams) == null ? void 0 : _a.pageSettings) == null ? void 0 : _b.general) || {};
254
+ const routePatch = {};
255
+ const nextTitle = firstDefined(nextGeneral.title, nextProps.title);
256
+ const nextIcon = firstDefined(nextGeneral.icon, nextProps.icon);
257
+ const nextEnableTabs = firstDefined(nextGeneral.enableTabs, nextProps.enableTabs);
258
+ const nextEnableHeader = firstDefined(nextGeneral.enableHeader, nextProps.enableHeader);
259
+ const nextDisplayTitle = firstDefined(nextGeneral.displayTitle, nextProps.displayTitle);
260
+ if (!import_lodash.default.isUndefined(nextTitle)) {
261
+ routePatch.title = nextTitle;
262
+ }
263
+ if (!import_lodash.default.isUndefined(nextIcon)) {
264
+ routePatch.icon = nextIcon;
265
+ }
266
+ if (!import_lodash.default.isUndefined(nextEnableTabs)) {
267
+ routePatch.enableTabs = !!nextEnableTabs;
268
+ }
269
+ if (!import_lodash.default.isUndefined(nextEnableHeader)) {
270
+ routePatch.enableHeader = !!nextEnableHeader;
271
+ }
272
+ if (!import_lodash.default.isUndefined(nextDisplayTitle)) {
273
+ routePatch.displayTitle = !!nextDisplayTitle;
274
+ }
275
+ if (!Object.keys(routePatch).length) {
276
+ return {};
277
+ }
278
+ return {
279
+ title: routePatch.title ?? readRouteProp(route, "title") ?? ((_c = current == null ? void 0 : current.props) == null ? void 0 : _c.title),
280
+ ...!import_lodash.default.isUndefined(routePatch.icon) ? { icon: routePatch.icon } : {},
281
+ enableTabs: routePatch.enableTabs ?? !!(readRouteProp(route, "enableTabs") ?? ((_d = current == null ? void 0 : current.props) == null ? void 0 : _d.enableTabs)),
282
+ ...!import_lodash.default.isUndefined(routePatch.enableHeader) ? { enableHeader: routePatch.enableHeader } : !import_lodash.default.isUndefined(readRouteProp(route, "enableHeader")) ? { enableHeader: !!readRouteProp(route, "enableHeader") } : {},
283
+ displayTitle: routePatch.displayTitle ?? !!(readRouteProp(route, "displayTitle") ?? ((_e = current == null ? void 0 : current.props) == null ? void 0 : _e.displayTitle) ?? ((_h = (_g = (_f = current == null ? void 0 : current.stepParams) == null ? void 0 : _f.pageSettings) == null ? void 0 : _g.general) == null ? void 0 : _h.displayTitle) ?? true)
284
+ };
285
+ }
286
+ normalizePagePayload(current, nextPayload, routePatch) {
287
+ var _a, _b;
288
+ if (!Object.keys(routePatch).length) {
289
+ return nextPayload;
290
+ }
291
+ const pageSettings = ((_a = current == null ? void 0 : current.stepParams) == null ? void 0 : _a.pageSettings) || {};
292
+ const nextPageSettings = ((_b = nextPayload.stepParams) == null ? void 0 : _b.pageSettings) || {};
293
+ return {
294
+ ...nextPayload,
295
+ props: {
296
+ ...(current == null ? void 0 : current.props) || {},
297
+ ...nextPayload.props || {},
298
+ ...routePatch
299
+ },
300
+ stepParams: {
301
+ ...(current == null ? void 0 : current.stepParams) || {},
302
+ ...nextPayload.stepParams || {},
303
+ pageSettings: {
304
+ ...pageSettings,
305
+ ...nextPageSettings,
306
+ general: {
307
+ ...pageSettings.general || {},
308
+ ...nextPageSettings.general || {},
309
+ ...routePatch
310
+ }
311
+ }
312
+ }
313
+ };
314
+ }
315
+ buildTabRoutePatch(_current, nextPayload, route) {
316
+ var _a, _b;
317
+ const nextProps = nextPayload.props || {};
318
+ const nextTab = ((_b = (_a = nextPayload.stepParams) == null ? void 0 : _a.pageTabSettings) == null ? void 0 : _b.tab) || {};
319
+ const routeOptions = readRouteOptions(route);
320
+ const patch = {};
321
+ const nextTitle = firstDefined(nextTab.title, nextProps.title);
322
+ const nextIcon = firstDefined(nextTab.icon, nextProps.icon);
323
+ if (!import_lodash.default.isUndefined(nextTitle)) {
324
+ patch.title = nextTitle;
325
+ }
326
+ if (!import_lodash.default.isUndefined(nextIcon)) {
327
+ patch.icon = nextIcon;
328
+ }
329
+ const nextOptions = {
330
+ ...routeOptions || {},
331
+ ...!import_lodash.default.isUndefined(nextTab.documentTitle) ? { documentTitle: nextTab.documentTitle } : {},
332
+ ...!import_lodash.default.isUndefined(nextPayload.flowRegistry) ? { flowRegistry: nextPayload.flowRegistry } : {}
333
+ };
334
+ if (!import_lodash.default.isEqual(nextOptions, routeOptions || {})) {
335
+ patch.options = nextOptions;
336
+ }
337
+ if (!Object.keys(patch).length) {
338
+ return {};
339
+ }
340
+ return {
341
+ ...!import_lodash.default.isUndefined(patch.title) ? { title: patch.title } : {},
342
+ ...!import_lodash.default.isUndefined(patch.icon) ? { icon: patch.icon } : {},
343
+ ...patch.options ? { options: patch.options } : {}
344
+ };
345
+ }
346
+ normalizeTabPayload(current, nextPayload, routePatch) {
347
+ var _a, _b, _c, _d, _e, _f, _g, _h;
348
+ const currentTab = ((_b = (_a = current == null ? void 0 : current.stepParams) == null ? void 0 : _a.pageTabSettings) == null ? void 0 : _b.tab) || {};
349
+ const nextTab = ((_d = (_c = nextPayload.stepParams) == null ? void 0 : _c.pageTabSettings) == null ? void 0 : _d.tab) || {};
350
+ const routeBackedTab = {
351
+ ...!import_lodash.default.isUndefined(routePatch.title) ? { title: routePatch.title } : {},
352
+ ...!import_lodash.default.isUndefined(routePatch.icon) ? { icon: routePatch.icon } : {},
353
+ ...!import_lodash.default.isUndefined((_e = routePatch.options) == null ? void 0 : _e.documentTitle) ? { documentTitle: routePatch.options.documentTitle } : {}
354
+ };
355
+ return {
356
+ ...nextPayload,
357
+ props: {
358
+ ...(current == null ? void 0 : current.props) || {},
359
+ ...nextPayload.props || {},
360
+ ...import_lodash.default.pick(routeBackedTab, ["title", "icon"])
361
+ },
362
+ stepParams: {
363
+ ...(current == null ? void 0 : current.stepParams) || {},
364
+ ...nextPayload.stepParams || {},
365
+ pageTabSettings: {
366
+ ...((_f = current == null ? void 0 : current.stepParams) == null ? void 0 : _f.pageTabSettings) || {},
367
+ ...((_g = nextPayload.stepParams) == null ? void 0 : _g.pageTabSettings) || {},
368
+ tab: {
369
+ ...currentTab,
370
+ ...nextTab,
371
+ ...routeBackedTab
372
+ }
373
+ }
374
+ },
375
+ flowRegistry: !import_lodash.default.isUndefined((_h = routePatch.options) == null ? void 0 : _h.flowRegistry) ? routePatch.options.flowRegistry : !import_lodash.default.isUndefined(nextPayload.flowRegistry) ? nextPayload.flowRegistry : current == null ? void 0 : current.flowRegistry
376
+ };
377
+ }
378
+ }
379
+ function readRouteProp(route, key) {
380
+ var _a;
381
+ return ((_a = route == null ? void 0 : route.get) == null ? void 0 : _a.call(route, key)) ?? (route == null ? void 0 : route[key]);
382
+ }
383
+ function readRouteOptions(route) {
384
+ var _a;
385
+ return ((_a = route == null ? void 0 : route.get) == null ? void 0 : _a.call(route, "options")) || (route == null ? void 0 : route.options) || {};
386
+ }
387
+ function firstDefined(...values) {
388
+ return values.find((value) => !import_lodash.default.isUndefined(value));
389
+ }
390
+ // Annotate the CommonJS export names for ESM import in node:
391
+ 0 && (module.exports = {
392
+ FlowSurfaceRouteSync
393
+ });
@@ -0,0 +1,42 @@
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 _ from 'lodash';
10
+ export type FlowSurfaceFieldMenuCandidateDedupeShape = {
11
+ fieldPath: string;
12
+ associationPathName?: string;
13
+ explicitWrapperUse?: string;
14
+ explicitFieldUse?: string;
15
+ };
16
+ export declare function toTemplatePlainRow(row: any): any;
17
+ export declare function buildFlowTemplateSearchFilter(existing: any, search?: string): any;
18
+ export declare function normalizeTemplatePage(value: any): number;
19
+ export declare function normalizeTemplatePageSize(value: any): number;
20
+ export declare function normalizeFieldPath(fieldPath: string, associationPathName?: string): string;
21
+ export declare function hasConfiguredFlowContextValue(value: any): boolean;
22
+ export declare function buildFilterFieldMeta(field: any): _.Dictionary<any>;
23
+ export declare function getCollectionFields(collection: any): any[];
24
+ export declare function getCollectionTitle(collection: any): any;
25
+ export declare function getCollectionName(collection: any): any;
26
+ export declare function getCollectionTitleFieldName(collection: any): any;
27
+ export declare function getFieldName(field: any): any;
28
+ export declare function getFieldTitle(field: any): any;
29
+ export declare function resolveAssociationNameFromField(field: any, fallbackCollection?: any): any;
30
+ export declare function getFieldInterface(field: any): any;
31
+ export declare function getFieldType(field: any): any;
32
+ export declare function inferFlowContextTypeFromField(field: any): "string" | "number" | "boolean" | "object" | "array";
33
+ export declare function getFieldTarget(field: any): any;
34
+ export declare function getFieldFilterable(field: any): any;
35
+ export declare function inferAssociationLeafDisplayFieldUse(fieldInterface?: string): string;
36
+ export declare function inferFieldMenuEditableFieldUse(fieldInterface?: string): string;
37
+ export declare function isAssociationField(field: any): any;
38
+ export declare function resolveFieldFromCollection(collection: any, fieldPath: string): any;
39
+ export declare function resolveFieldTargetCollection(field: any, dataSourceKey: string, getCollection: (dataSourceKey: string, collectionName: string) => any): any;
40
+ export declare function buildCatalogCollectionCycleKey(collection: any, dataSourceKey?: string): string;
41
+ export declare function dedupeVisibleFieldCandidates<T extends FlowSurfaceFieldMenuCandidateDedupeShape>(candidates: T[]): T[];
42
+ export declare function getAssociationFilterTargetKey(field: any, targetCollection?: any): any;