@nocobase/plugin-flow-engine 2.1.0-beta.14 → 2.1.0-beta.16

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 (229) hide show
  1. package/dist/ai/ai-employees/nathan/index.d.ts +10 -0
  2. package/dist/ai/ai-employees/nathan/index.js +41 -0
  3. package/dist/ai/ai-employees/nathan/prompt.md +132 -0
  4. package/dist/ai/ai-employees/nathan/skills/frontend-developer/SKILLS.md +69 -0
  5. package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextApis.js +2 -2
  6. package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextEnvs.js +2 -2
  7. package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextVars.js +2 -2
  8. package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/lintAndTestJS.js +2 -2
  9. package/dist/ai/docs/runjs/context/block-model.md +35 -35
  10. package/dist/ai/docs/runjs/context/collection-field.md +53 -51
  11. package/dist/ai/docs/runjs/context/collection.md +39 -39
  12. package/dist/ai/docs/runjs/context/data-source-manager.md +40 -30
  13. package/dist/ai/docs/runjs/context/data-source.md +52 -44
  14. package/dist/ai/docs/runjs/context/element.md +44 -38
  15. package/dist/ai/docs/runjs/context/exit-all.md +37 -35
  16. package/dist/ai/docs/runjs/context/exit.md +38 -35
  17. package/dist/ai/docs/runjs/context/filter-manager.md +36 -30
  18. package/dist/ai/docs/runjs/context/form.md +57 -57
  19. package/dist/ai/docs/runjs/context/get-model.md +22 -21
  20. package/dist/ai/docs/runjs/context/get-value.md +20 -19
  21. package/dist/ai/docs/runjs/context/get-var.md +61 -55
  22. package/dist/ai/docs/runjs/context/i18n.md +17 -14
  23. package/dist/ai/docs/runjs/context/import-async.md +333 -45
  24. package/dist/ai/docs/runjs/context/init-resource.md +20 -20
  25. package/dist/ai/docs/runjs/context/libs.md +31 -31
  26. package/dist/ai/docs/runjs/context/location.md +34 -31
  27. package/dist/ai/docs/runjs/context/logger.md +41 -40
  28. package/dist/ai/docs/runjs/context/make-resource.md +27 -26
  29. package/dist/ai/docs/runjs/context/message.md +42 -41
  30. package/dist/ai/docs/runjs/context/modal.md +44 -44
  31. package/dist/ai/docs/runjs/context/model.md +36 -33
  32. package/dist/ai/docs/runjs/context/notification.md +41 -40
  33. package/dist/ai/docs/runjs/context/off.md +14 -14
  34. package/dist/ai/docs/runjs/context/on.md +30 -29
  35. package/dist/ai/docs/runjs/context/open-view.md +40 -40
  36. package/dist/ai/docs/runjs/context/render.md +37 -32
  37. package/dist/ai/docs/runjs/context/request.md +46 -45
  38. package/dist/ai/docs/runjs/context/require-async.md +28 -25
  39. package/dist/ai/docs/runjs/context/resource.md +34 -34
  40. package/dist/ai/docs/runjs/context/route.md +36 -34
  41. package/dist/ai/docs/runjs/context/router.md +43 -31
  42. package/dist/ai/docs/runjs/context/set-value.md +18 -17
  43. package/dist/ai/docs/runjs/context/t.md +20 -17
  44. package/dist/ai/docs/runjs/context/view.md +49 -46
  45. package/dist/ai/docs/runjs/document.md +1 -0
  46. package/dist/ai/docs/runjs/import-modules.md +32 -32
  47. package/dist/ai/docs/runjs/index.md +13 -13
  48. package/dist/ai/docs/runjs/jsx.md +19 -19
  49. package/dist/ai/docs/runjs/model/form-block-model.md +1 -3
  50. package/dist/ai/docs/runjs/render.md +15 -15
  51. package/dist/ai/docs/runjs/resource/api-resource.md +53 -53
  52. package/dist/ai/docs/runjs/resource/multi-record-resource.md +64 -64
  53. package/dist/ai/docs/runjs/resource/single-record-resource.md +55 -55
  54. package/dist/ai/docs/runjs/resource/sql-resource.md +57 -57
  55. package/dist/ai/docs/runjs/window.md +5 -5
  56. package/dist/client/index.js +1 -1
  57. package/dist/externalVersion.js +11 -10
  58. package/dist/node_modules/ses/dist/ses.cjs +1 -1
  59. package/dist/node_modules/ses/package.json +1 -1
  60. package/dist/node_modules/zod/index.cjs +1 -1
  61. package/dist/node_modules/zod/package.json +1 -1
  62. package/dist/server/flow-surfaces/action-scope.d.ts +38 -0
  63. package/dist/server/flow-surfaces/action-scope.js +152 -0
  64. package/dist/server/flow-surfaces/apply/compiler.d.ts +13 -0
  65. package/dist/server/flow-surfaces/apply/compiler.js +969 -0
  66. package/dist/server/flow-surfaces/apply/layout.d.ts +34 -0
  67. package/dist/server/flow-surfaces/apply/layout.js +175 -0
  68. package/dist/server/flow-surfaces/apply/matching.d.ts +16 -0
  69. package/dist/server/flow-surfaces/apply/matching.js +181 -0
  70. package/dist/server/flow-surfaces/approval/blueprint-service.d.ts +84 -0
  71. package/dist/server/flow-surfaces/approval/blueprint-service.js +589 -0
  72. package/dist/server/flow-surfaces/approval/blueprint.d.ts +21 -0
  73. package/dist/server/flow-surfaces/approval/blueprint.js +187 -0
  74. package/dist/server/flow-surfaces/approval/builder.d.ts +225 -0
  75. package/dist/server/flow-surfaces/approval/builder.js +384 -0
  76. package/dist/server/flow-surfaces/approval/catalog-specs.d.ts +33 -0
  77. package/dist/server/flow-surfaces/approval/catalog-specs.js +156 -0
  78. package/dist/server/flow-surfaces/approval/index.d.ts +14 -0
  79. package/dist/server/flow-surfaces/approval/index.js +40 -0
  80. package/dist/server/flow-surfaces/approval/runtime-config.d.ts +44 -0
  81. package/dist/server/flow-surfaces/approval/runtime-config.js +299 -0
  82. package/dist/server/flow-surfaces/approval/semantic-use.d.ts +23 -0
  83. package/dist/server/flow-surfaces/approval/semantic-use.js +155 -0
  84. package/dist/server/flow-surfaces/association-title-field.d.ts +20 -0
  85. package/dist/server/flow-surfaces/association-title-field.js +158 -0
  86. package/dist/server/flow-surfaces/blueprint/compile-blocks.d.ts +14 -0
  87. package/dist/server/flow-surfaces/blueprint/compile-blocks.js +1007 -0
  88. package/dist/server/flow-surfaces/blueprint/compile-plan.d.ts +13 -0
  89. package/dist/server/flow-surfaces/blueprint/compile-plan.js +308 -0
  90. package/dist/server/flow-surfaces/blueprint/compile-reaction.d.ts +11 -0
  91. package/dist/server/flow-surfaces/blueprint/compile-reaction.js +72 -0
  92. package/dist/server/flow-surfaces/blueprint/defaults.d.ts +26 -0
  93. package/dist/server/flow-surfaces/blueprint/defaults.js +133 -0
  94. package/dist/server/flow-surfaces/blueprint/index.d.ts +12 -0
  95. package/dist/server/flow-surfaces/blueprint/index.js +44 -0
  96. package/dist/server/flow-surfaces/blueprint/normalize-document.d.ts +10 -0
  97. package/dist/server/flow-surfaces/blueprint/normalize-document.js +416 -0
  98. package/dist/server/flow-surfaces/blueprint/private-utils.d.ts +26 -0
  99. package/dist/server/flow-surfaces/blueprint/private-utils.js +182 -0
  100. package/dist/server/flow-surfaces/blueprint/public-types.d.ts +193 -0
  101. package/dist/server/flow-surfaces/blueprint/public-types.js +24 -0
  102. package/dist/server/flow-surfaces/builder.d.ts +211 -0
  103. package/dist/server/flow-surfaces/builder.js +1029 -0
  104. package/dist/server/flow-surfaces/catalog-smart.d.ts +18 -0
  105. package/dist/server/flow-surfaces/catalog-smart.js +239 -0
  106. package/dist/server/flow-surfaces/catalog-smart.projector.d.ts +15 -0
  107. package/dist/server/flow-surfaces/catalog-smart.projector.js +157 -0
  108. package/dist/server/flow-surfaces/catalog-smart.types.d.ts +99 -0
  109. package/dist/server/flow-surfaces/catalog-smart.types.js +24 -0
  110. package/dist/server/flow-surfaces/catalog.d.ts +78 -0
  111. package/dist/server/flow-surfaces/catalog.js +3496 -0
  112. package/dist/server/flow-surfaces/chart-config.d.ts +121 -0
  113. package/dist/server/flow-surfaces/chart-config.js +1394 -0
  114. package/dist/server/flow-surfaces/compose-compiler.d.ts +108 -0
  115. package/dist/server/flow-surfaces/compose-compiler.js +167 -0
  116. package/dist/server/flow-surfaces/compose-runtime.d.ts +93 -0
  117. package/dist/server/flow-surfaces/compose-runtime.js +375 -0
  118. package/dist/server/flow-surfaces/configure-options.d.ts +23 -0
  119. package/dist/server/flow-surfaces/configure-options.js +827 -0
  120. package/dist/server/flow-surfaces/constants.d.ts +351 -0
  121. package/dist/server/flow-surfaces/constants.js +104 -0
  122. package/dist/server/flow-surfaces/context.d.ts +72 -0
  123. package/dist/server/flow-surfaces/context.js +556 -0
  124. package/dist/server/flow-surfaces/contract-guard.d.ts +19 -0
  125. package/dist/server/flow-surfaces/contract-guard.js +402 -0
  126. package/dist/server/flow-surfaces/default-action-popup.d.ts +63 -0
  127. package/dist/server/flow-surfaces/default-action-popup.js +322 -0
  128. package/dist/server/flow-surfaces/default-block-actions.d.ts +32 -0
  129. package/dist/server/flow-surfaces/default-block-actions.js +185 -0
  130. package/dist/server/flow-surfaces/errors.d.ts +47 -0
  131. package/dist/server/flow-surfaces/errors.js +145 -0
  132. package/dist/server/flow-surfaces/executor.d.ts +23 -0
  133. package/dist/server/flow-surfaces/executor.js +132 -0
  134. package/dist/server/flow-surfaces/field-binding-registry.d.ts +23 -0
  135. package/dist/server/flow-surfaces/field-binding-registry.js +391 -0
  136. package/dist/server/flow-surfaces/field-semantics.d.ts +15 -0
  137. package/dist/server/flow-surfaces/field-semantics.js +81 -0
  138. package/dist/server/flow-surfaces/filter-group.d.ts +15 -0
  139. package/dist/server/flow-surfaces/filter-group.js +94 -0
  140. package/dist/server/flow-surfaces/index.d.ts +11 -0
  141. package/dist/server/flow-surfaces/index.js +243 -0
  142. package/dist/server/flow-surfaces/locator.d.ts +28 -0
  143. package/dist/server/flow-surfaces/locator.js +240 -0
  144. package/dist/server/flow-surfaces/node-use-sets.d.ts +15 -0
  145. package/dist/server/flow-surfaces/node-use-sets.js +131 -0
  146. package/dist/server/flow-surfaces/payload-shape.d.ts +9 -0
  147. package/dist/server/flow-surfaces/payload-shape.js +61 -0
  148. package/dist/server/flow-surfaces/placement.d.ts +33 -0
  149. package/dist/server/flow-surfaces/placement.js +195 -0
  150. package/dist/server/flow-surfaces/planning/action-specs.d.ts +179 -0
  151. package/dist/server/flow-surfaces/planning/action-specs.js +190 -0
  152. package/dist/server/flow-surfaces/planning/compiler.d.ts +37 -0
  153. package/dist/server/flow-surfaces/planning/compiler.js +376 -0
  154. package/dist/server/flow-surfaces/planning/context.d.ts +30 -0
  155. package/dist/server/flow-surfaces/planning/context.js +139 -0
  156. package/dist/server/flow-surfaces/planning/created-keys.d.ts +34 -0
  157. package/dist/server/flow-surfaces/planning/created-keys.js +375 -0
  158. package/dist/server/flow-surfaces/planning/key-kind.d.ts +11 -0
  159. package/dist/server/flow-surfaces/planning/key-kind.js +88 -0
  160. package/dist/server/flow-surfaces/planning/key-persistence.d.ts +34 -0
  161. package/dist/server/flow-surfaces/planning/key-persistence.js +148 -0
  162. package/dist/server/flow-surfaces/planning/key-registry.d.ts +40 -0
  163. package/dist/server/flow-surfaces/planning/key-registry.js +206 -0
  164. package/dist/server/flow-surfaces/planning/runtime.d.ts +37 -0
  165. package/dist/server/flow-surfaces/planning/runtime.js +259 -0
  166. package/dist/server/flow-surfaces/planning/step-link.d.ts +14 -0
  167. package/dist/server/flow-surfaces/planning/step-link.js +104 -0
  168. package/dist/server/flow-surfaces/planning/types.d.ts +55 -0
  169. package/dist/server/flow-surfaces/planning/types.js +24 -0
  170. package/dist/server/flow-surfaces/public-data-surface-default-filter.d.ts +20 -0
  171. package/dist/server/flow-surfaces/public-data-surface-default-filter.js +111 -0
  172. package/dist/server/flow-surfaces/reaction/errors.d.ts +20 -0
  173. package/dist/server/flow-surfaces/reaction/errors.js +69 -0
  174. package/dist/server/flow-surfaces/reaction/field-value.d.ts +34 -0
  175. package/dist/server/flow-surfaces/reaction/field-value.js +181 -0
  176. package/dist/server/flow-surfaces/reaction/fingerprint.d.ts +16 -0
  177. package/dist/server/flow-surfaces/reaction/fingerprint.js +71 -0
  178. package/dist/server/flow-surfaces/reaction/linkage.d.ts +136 -0
  179. package/dist/server/flow-surfaces/reaction/linkage.js +882 -0
  180. package/dist/server/flow-surfaces/reaction/meta.d.ts +11 -0
  181. package/dist/server/flow-surfaces/reaction/meta.js +451 -0
  182. package/dist/server/flow-surfaces/reaction/registry.d.ts +156 -0
  183. package/dist/server/flow-surfaces/reaction/registry.js +206 -0
  184. package/dist/server/flow-surfaces/reaction/resolver.d.ts +22 -0
  185. package/dist/server/flow-surfaces/reaction/resolver.js +202 -0
  186. package/dist/server/flow-surfaces/reaction/types.d.ts +241 -0
  187. package/dist/server/flow-surfaces/reaction/types.js +24 -0
  188. package/dist/server/flow-surfaces/reaction/utils.d.ts +17 -0
  189. package/dist/server/flow-surfaces/reaction/utils.js +67 -0
  190. package/dist/server/flow-surfaces/reaction/value-expr.d.ts +15 -0
  191. package/dist/server/flow-surfaces/reaction/value-expr.js +209 -0
  192. package/dist/server/flow-surfaces/reference-guards.d.ts +19 -0
  193. package/dist/server/flow-surfaces/reference-guards.js +103 -0
  194. package/dist/server/flow-surfaces/route-sync.d.ts +47 -0
  195. package/dist/server/flow-surfaces/route-sync.js +392 -0
  196. package/dist/server/flow-surfaces/service-helpers.d.ts +42 -0
  197. package/dist/server/flow-surfaces/service-helpers.js +377 -0
  198. package/dist/server/flow-surfaces/service-utils.d.ts +108 -0
  199. package/dist/server/flow-surfaces/service-utils.js +811 -0
  200. package/dist/server/flow-surfaces/service.d.ts +773 -0
  201. package/dist/server/flow-surfaces/service.js +13008 -0
  202. package/dist/server/flow-surfaces/support-matrix.d.ts +31 -0
  203. package/dist/server/flow-surfaces/support-matrix.js +259 -0
  204. package/dist/server/flow-surfaces/surface-context.d.ts +52 -0
  205. package/dist/server/flow-surfaces/surface-context.js +437 -0
  206. package/dist/server/flow-surfaces/template-compatibility.d.ts +42 -0
  207. package/dist/server/flow-surfaces/template-compatibility.js +189 -0
  208. package/dist/server/flow-surfaces/template-display.d.ts +20 -0
  209. package/dist/server/flow-surfaces/template-display.js +289 -0
  210. package/dist/server/flow-surfaces/template-service-utils.d.ts +62 -0
  211. package/dist/server/flow-surfaces/template-service-utils.js +281 -0
  212. package/dist/server/flow-surfaces/types.d.ts +288 -0
  213. package/dist/server/flow-surfaces/types.js +24 -0
  214. package/dist/server/plugin.js +2 -0
  215. package/dist/swagger/flow-surfaces.d.ts +5964 -0
  216. package/dist/swagger/flow-surfaces.examples.d.ts +1533 -0
  217. package/dist/swagger/flow-surfaces.examples.js +1758 -0
  218. package/dist/swagger/flow-surfaces.js +5315 -0
  219. package/dist/swagger/flow-surfaces.template-action-docs.d.ts +62 -0
  220. package/dist/swagger/flow-surfaces.template-action-docs.js +121 -0
  221. package/dist/swagger/flow-surfaces.template-schemas.d.ts +239 -0
  222. package/dist/swagger/flow-surfaces.template-schemas.js +255 -0
  223. package/dist/swagger/index.d.ts +5969 -0
  224. package/dist/swagger/index.js +50 -0
  225. package/package.json +2 -2
  226. /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextApis.d.ts +0 -0
  227. /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextEnvs.d.ts +0 -0
  228. /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextVars.d.ts +0 -0
  229. /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/lintAndTestJS.d.ts +0 -0
@@ -0,0 +1,375 @@
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 created_keys_exports = {};
38
+ __export(created_keys_exports, {
39
+ assertNoDuplicateFlowSurfaceCreatedKeys: () => assertNoDuplicateFlowSurfaceCreatedKeys,
40
+ collectFlowSurfaceCreatedKeys: () => collectFlowSurfaceCreatedKeys,
41
+ collectPersistableFlowSurfaceCreatedKeys: () => collectPersistableFlowSurfaceCreatedKeys,
42
+ isFlowSurfacePureKeyObject: () => isFlowSurfacePureKeyObject,
43
+ normalizeComposeInlineKeysForPlan: () => normalizeComposeInlineKeysForPlan,
44
+ normalizeFlowSurfaceCreatedKey: () => normalizeFlowSurfaceCreatedKey,
45
+ registerFlowSurfaceCreatedKeys: () => registerFlowSurfaceCreatedKeys
46
+ });
47
+ module.exports = __toCommonJS(created_keys_exports);
48
+ var import_lodash = __toESM(require("lodash"));
49
+ var import_errors = require("../errors");
50
+ var import_key_registry = require("./key-registry");
51
+ function normalizeFlowSurfaceCreatedKey(key, context) {
52
+ const normalized = typeof key === "string" ? key.trim() : String(key || "").trim();
53
+ if (!normalized) {
54
+ (0, import_errors.throwBadRequest)(`${context} key cannot be empty`);
55
+ }
56
+ if (import_key_registry.FLOW_SURFACE_RESERVED_KEYS.has(normalized)) {
57
+ (0, import_errors.throwBadRequest)(`${context} key '${normalized}' is reserved`);
58
+ }
59
+ return normalized;
60
+ }
61
+ function collectFlowSurfaceCreatedKeys(action, values, options = {}) {
62
+ if (!import_lodash.default.isPlainObject(values)) {
63
+ return [];
64
+ }
65
+ switch (action) {
66
+ case "createPage":
67
+ return collectBaseKey(values.key, `flowSurfaces ${action}`, [
68
+ ["", "pageUid"],
69
+ ["tab", "tabSchemaUid"],
70
+ ["grid", "gridUid"]
71
+ ]);
72
+ case "addTab":
73
+ return collectBaseKey(values.key, `flowSurfaces ${action}`, [
74
+ ["", "tabSchemaUid"],
75
+ ["grid", "gridUid"]
76
+ ]);
77
+ case "addPopupTab":
78
+ return collectBaseKey(values.key, `flowSurfaces ${action}`, [
79
+ ["", "popupTabUid"],
80
+ ["grid", "popupGridUid"]
81
+ ]);
82
+ case "addBlock":
83
+ return collectBaseKey(values.key, `flowSurfaces ${action}`, [
84
+ ["", "uid"],
85
+ ["grid", "blockGridUid"],
86
+ ["item", "itemUid"],
87
+ ["itemGrid", "itemGridUid"],
88
+ ["actionsColumn", "actionsColumnUid"]
89
+ ]);
90
+ case "addField":
91
+ return [
92
+ ...collectBaseKey(values.key, `flowSurfaces ${action}`, [
93
+ ["", "uid"],
94
+ ["field", "fieldUid"],
95
+ ["innerField", "innerFieldUid"]
96
+ ]),
97
+ ...shouldCollectAddFieldPopupKeys(values) ? collectDerivedKey(values.key, `flowSurfaces ${action}`, [
98
+ ["popupPage", "popupPageUid"],
99
+ ["popupTab", "popupTabUid"],
100
+ ["popupGrid", "popupGridUid"]
101
+ ]) : []
102
+ ];
103
+ case "addAction":
104
+ case "addRecordAction":
105
+ return collectBaseKey(values.key, `flowSurfaces ${action}`, [
106
+ ["", "uid"],
107
+ ["assignForm", "assignFormUid"],
108
+ ["assignFormGrid", "assignFormGridUid"],
109
+ ["popupPage", "popupPageUid"],
110
+ ["popupTab", "popupTabUid"],
111
+ ["popupGrid", "popupGridUid"]
112
+ ]);
113
+ case "configure":
114
+ return collectConfigureCreatedKeys(values, options);
115
+ case "compose":
116
+ return collectComposeCreatedKeys(values);
117
+ default:
118
+ return [];
119
+ }
120
+ }
121
+ function collectBaseKey(keyValue, context, defs) {
122
+ if (import_lodash.default.isUndefined(keyValue)) {
123
+ return [];
124
+ }
125
+ const baseKey = normalizeFlowSurfaceCreatedKey(keyValue, context);
126
+ return defs.map(([suffix, resultPath]) => ({
127
+ key: suffix ? `${baseKey}.${suffix}` : baseKey,
128
+ resultPath
129
+ }));
130
+ }
131
+ function collectDerivedKey(keyValue, context, defs) {
132
+ if (import_lodash.default.isUndefined(keyValue)) {
133
+ return [];
134
+ }
135
+ const baseKey = normalizeFlowSurfaceCreatedKey(keyValue, context);
136
+ return defs.map(([suffix, resultPath]) => ({
137
+ key: `${baseKey}.${suffix}`,
138
+ resultPath
139
+ }));
140
+ }
141
+ function shouldCollectAddFieldPopupKeys(values) {
142
+ return !import_lodash.default.isUndefined(values == null ? void 0 : values.popup);
143
+ }
144
+ function inferConfigureCreatedKeyBase(targetSelectorKey) {
145
+ if (import_lodash.default.isUndefined(targetSelectorKey)) {
146
+ return void 0;
147
+ }
148
+ const normalizedKey = normalizeFlowSurfaceCreatedKey(targetSelectorKey, "flowSurfaces configure target key");
149
+ if (normalizedKey.endsWith(".innerField")) {
150
+ return normalizedKey.slice(0, -".innerField".length);
151
+ }
152
+ if (normalizedKey.endsWith(".field")) {
153
+ return normalizedKey.slice(0, -".field".length);
154
+ }
155
+ return void 0;
156
+ }
157
+ function collectConfigureCreatedKeys(values, options = {}) {
158
+ var _a;
159
+ if (!import_lodash.default.isPlainObject((_a = values == null ? void 0 : values.changes) == null ? void 0 : _a.openView)) {
160
+ return [];
161
+ }
162
+ const keyBase = !import_lodash.default.isUndefined(values.key) ? values.key : inferConfigureCreatedKeyBase(options.targetSelectorKey);
163
+ if (import_lodash.default.isUndefined(keyBase)) {
164
+ return [];
165
+ }
166
+ return collectDerivedKey(keyBase, "flowSurfaces configure", [
167
+ ["popupPage", "popupPageUid"],
168
+ ["popupTab", "popupTabUid"],
169
+ ["popupGrid", "popupGridUid"]
170
+ ]);
171
+ }
172
+ function collectComposeCreatedKeys(values) {
173
+ const blocks = import_lodash.default.castArray((values == null ? void 0 : values.blocks) || []);
174
+ const specs = [];
175
+ blocks.forEach((block, blockIndex) => {
176
+ const blockContext = `flowSurfaces compose block #${blockIndex + 1}`;
177
+ if (import_lodash.default.isPlainObject(block) && !import_lodash.default.isUndefined(block.key)) {
178
+ specs.push(
179
+ ...collectBaseKey(block.key, blockContext, [
180
+ ["", `blocks.${blockIndex}.uid`],
181
+ ["grid", `blocks.${blockIndex}.gridUid`],
182
+ ["item", `blocks.${blockIndex}.itemUid`],
183
+ ["itemGrid", `blocks.${blockIndex}.itemGridUid`],
184
+ ["actionsColumn", `blocks.${blockIndex}.actionsColumnUid`]
185
+ ])
186
+ );
187
+ }
188
+ import_lodash.default.castArray((block == null ? void 0 : block.fields) || []).forEach((field, fieldIndex) => {
189
+ const fieldKey = resolveComposeFieldKey(field, `${blockContext} field #${fieldIndex + 1}`);
190
+ if (!fieldKey) {
191
+ return;
192
+ }
193
+ specs.push(
194
+ ...collectBaseKey(fieldKey, `${blockContext} field #${fieldIndex + 1}`, [
195
+ ["", `blocks.${blockIndex}.fields.${fieldIndex}.uid`],
196
+ ["field", `blocks.${blockIndex}.fields.${fieldIndex}.fieldUid`],
197
+ ["innerField", `blocks.${blockIndex}.fields.${fieldIndex}.innerFieldUid`],
198
+ ["popupPage", `blocks.${blockIndex}.fields.${fieldIndex}.popupPageUid`],
199
+ ["popupTab", `blocks.${blockIndex}.fields.${fieldIndex}.popupTabUid`],
200
+ ["popupGrid", `blocks.${blockIndex}.fields.${fieldIndex}.popupGridUid`]
201
+ ])
202
+ );
203
+ });
204
+ import_lodash.default.castArray((block == null ? void 0 : block.actions) || []).forEach((action, actionIndex) => {
205
+ const actionKey = resolveComposeActionKey(action, `${blockContext} action #${actionIndex + 1}`);
206
+ if (!actionKey) {
207
+ return;
208
+ }
209
+ specs.push(
210
+ ...collectBaseKey(actionKey, `${blockContext} action #${actionIndex + 1}`, [
211
+ ["", `blocks.${blockIndex}.actions.${actionIndex}.uid`],
212
+ ["assignForm", `blocks.${blockIndex}.actions.${actionIndex}.assignFormUid`],
213
+ ["assignFormGrid", `blocks.${blockIndex}.actions.${actionIndex}.assignFormGridUid`],
214
+ ["popupPage", `blocks.${blockIndex}.actions.${actionIndex}.popupPageUid`],
215
+ ["popupTab", `blocks.${blockIndex}.actions.${actionIndex}.popupTabUid`],
216
+ ["popupGrid", `blocks.${blockIndex}.actions.${actionIndex}.popupGridUid`]
217
+ ])
218
+ );
219
+ });
220
+ import_lodash.default.castArray((block == null ? void 0 : block.recordActions) || []).forEach((action, actionIndex) => {
221
+ const actionKey = resolveComposeActionKey(action, `${blockContext} recordAction #${actionIndex + 1}`);
222
+ if (!actionKey) {
223
+ return;
224
+ }
225
+ specs.push(
226
+ ...collectBaseKey(actionKey, `${blockContext} recordAction #${actionIndex + 1}`, [
227
+ ["", `blocks.${blockIndex}.recordActions.${actionIndex}.uid`],
228
+ ["assignForm", `blocks.${blockIndex}.recordActions.${actionIndex}.assignFormUid`],
229
+ ["assignFormGrid", `blocks.${blockIndex}.recordActions.${actionIndex}.assignFormGridUid`],
230
+ ["popupPage", `blocks.${blockIndex}.recordActions.${actionIndex}.popupPageUid`],
231
+ ["popupTab", `blocks.${blockIndex}.recordActions.${actionIndex}.popupTabUid`],
232
+ ["popupGrid", `blocks.${blockIndex}.recordActions.${actionIndex}.popupGridUid`]
233
+ ])
234
+ );
235
+ });
236
+ });
237
+ return specs;
238
+ }
239
+ function resolveComposeFieldKey(field, context) {
240
+ if (typeof field === "string") {
241
+ return normalizeFlowSurfaceCreatedKey(field, context);
242
+ }
243
+ if (!import_lodash.default.isPlainObject(field)) {
244
+ return void 0;
245
+ }
246
+ const semanticType = String(field.type || "").trim();
247
+ const fieldPath = String(field.fieldPath || "").trim();
248
+ const renderer = typeof field.renderer === "undefined" ? void 0 : String(field.renderer || "").trim();
249
+ const rawKey = String(field.key || semanticType || (renderer === "js" ? `js:${fieldPath}` : fieldPath)).trim();
250
+ return rawKey ? normalizeFlowSurfaceCreatedKey(rawKey, context) : void 0;
251
+ }
252
+ function resolveComposeActionKey(action, context) {
253
+ if (typeof action === "string") {
254
+ return normalizeFlowSurfaceCreatedKey(action, context);
255
+ }
256
+ if (!import_lodash.default.isPlainObject(action)) {
257
+ return void 0;
258
+ }
259
+ const rawKey = String(action.key || action.type || "").trim();
260
+ return rawKey ? normalizeFlowSurfaceCreatedKey(rawKey, context) : void 0;
261
+ }
262
+ function assertNoDuplicateFlowSurfaceCreatedKeys(specs, context, options = {}) {
263
+ const seen = /* @__PURE__ */ new Map();
264
+ const existing = new Set(options.existingKeys || []);
265
+ const reservedNames = new Set(options.reservedNames || []);
266
+ specs.forEach((spec, index) => {
267
+ if (reservedNames.has(spec.key)) {
268
+ (0, import_errors.throwBadRequest)(`${context} key '${spec.key}' conflicts with an existing step id`);
269
+ }
270
+ if (existing.has(spec.key)) {
271
+ (0, import_errors.throwBadRequest)(`${context} key '${spec.key}' is already defined`);
272
+ }
273
+ const previousIndex = seen.get(spec.key);
274
+ if (typeof previousIndex === "number") {
275
+ (0, import_errors.throwBadRequest)(`${context} key '${spec.key}' is duplicated at #${previousIndex + 1} and #${index + 1}`);
276
+ }
277
+ seen.set(spec.key, index);
278
+ });
279
+ }
280
+ function registerFlowSurfaceCreatedKeys(result, specs, keys) {
281
+ const registered = resolveFlowSurfaceCreatedKeyResults(result, specs);
282
+ registered.forEach((item) => keys.set(item.key, item.uid));
283
+ return registered;
284
+ }
285
+ function collectPersistableFlowSurfaceCreatedKeys(result, specs) {
286
+ const persistedUidSet = /* @__PURE__ */ new Set();
287
+ const persisted = [];
288
+ for (const item of resolveFlowSurfaceCreatedKeyResults(result, specs)) {
289
+ if (persistedUidSet.has(item.uid)) {
290
+ continue;
291
+ }
292
+ persistedUidSet.add(item.uid);
293
+ persisted.push(item);
294
+ }
295
+ return persisted;
296
+ }
297
+ function resolveFlowSurfaceCreatedKeyResults(result, specs) {
298
+ const registered = [];
299
+ for (const spec of specs) {
300
+ const value = import_lodash.default.get(result, spec.resultPath);
301
+ if (typeof value !== "string" || !value.trim()) {
302
+ continue;
303
+ }
304
+ registered.push({
305
+ key: spec.key,
306
+ uid: value.trim()
307
+ });
308
+ }
309
+ return registered;
310
+ }
311
+ function isFlowSurfacePureKeyObject(input) {
312
+ return import_lodash.default.isPlainObject(input) && Object.keys(input).length === 1 && typeof input.key === "string" && !!input.key.trim();
313
+ }
314
+ function normalizeComposeInlineKeysForPlan(values, contextPath) {
315
+ var _a;
316
+ if (!import_lodash.default.isPlainObject(values)) {
317
+ return values;
318
+ }
319
+ const cloned = import_lodash.default.cloneDeep(values);
320
+ const blockKeys = new Set(
321
+ import_lodash.default.castArray(cloned.blocks || []).map((block, index) => {
322
+ if (!import_lodash.default.isPlainObject(block) || import_lodash.default.isUndefined(block.key)) {
323
+ return "";
324
+ }
325
+ return normalizeFlowSurfaceCreatedKey(block.key, `${contextPath}.blocks[${index}]`);
326
+ }).filter(Boolean)
327
+ );
328
+ import_lodash.default.castArray(cloned.blocks || []).forEach((block, blockIndex) => {
329
+ import_lodash.default.castArray((block == null ? void 0 : block.fields) || []).forEach((field, fieldIndex) => {
330
+ if (typeof (field == null ? void 0 : field.target) !== "string" || !field.target.trim()) {
331
+ return;
332
+ }
333
+ const targetKey = normalizeFlowSurfaceCreatedKey(
334
+ field.target,
335
+ `${contextPath}.blocks[${blockIndex}].fields[${fieldIndex}].target`
336
+ );
337
+ if (!blockKeys.has(targetKey)) {
338
+ return;
339
+ }
340
+ field.target = targetKey;
341
+ });
342
+ });
343
+ import_lodash.default.castArray(((_a = cloned.layout) == null ? void 0 : _a.rows) || []).forEach((row, rowIndex) => {
344
+ if (!Array.isArray(row)) {
345
+ return;
346
+ }
347
+ row.forEach((cell, cellIndex) => {
348
+ if (typeof cell === "string") {
349
+ return;
350
+ }
351
+ if (!import_lodash.default.isPlainObject(cell) || typeof cell.key !== "string" || !cell.key.trim()) {
352
+ return;
353
+ }
354
+ const key = normalizeFlowSurfaceCreatedKey(cell.key, `${contextPath}.layout.rows[${rowIndex}][${cellIndex}]`);
355
+ if (!blockKeys.has(key)) {
356
+ (0, import_errors.throwBadRequest)(
357
+ `flowSurfaces compose local layout key '${key}' must match a block key in the same compose step`
358
+ );
359
+ }
360
+ delete cell.key;
361
+ cell.composeKey = key;
362
+ });
363
+ });
364
+ return cloned;
365
+ }
366
+ // Annotate the CommonJS export names for ESM import in node:
367
+ 0 && (module.exports = {
368
+ assertNoDuplicateFlowSurfaceCreatedKeys,
369
+ collectFlowSurfaceCreatedKeys,
370
+ collectPersistableFlowSurfaceCreatedKeys,
371
+ isFlowSurfacePureKeyObject,
372
+ normalizeComposeInlineKeysForPlan,
373
+ normalizeFlowSurfaceCreatedKey,
374
+ registerFlowSurfaceCreatedKeys
375
+ });
@@ -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 { FlowSurfaceBindKey } from '../types';
10
+ export declare function buildPlanKeyKind(node: any, resolvedKind?: string): string;
11
+ export declare function assertBindKeyKind(actionName: string, bindKey: FlowSurfaceBindKey, node: any, resolvedKind?: string): void;
@@ -0,0 +1,88 @@
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 __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var key_kind_exports = {};
28
+ __export(key_kind_exports, {
29
+ assertBindKeyKind: () => assertBindKeyKind,
30
+ buildPlanKeyKind: () => buildPlanKeyKind
31
+ });
32
+ module.exports = __toCommonJS(key_kind_exports);
33
+ var import_node_use_sets = require("../node-use-sets");
34
+ var import_approval = require("../approval");
35
+ var import_errors = require("../errors");
36
+ var import_placement = require("../placement");
37
+ var import_service_utils = require("../service-utils");
38
+ function buildPlanKeyKind(node, resolvedKind) {
39
+ const use = String((node == null ? void 0 : node.use) || "").trim();
40
+ const semanticUse = (0, import_approval.normalizeApprovalSemanticUse)(use);
41
+ if (semanticUse === "RootPageModel" || resolvedKind === "page") {
42
+ return "page";
43
+ }
44
+ if (semanticUse === "RootPageTabModel" || resolvedKind === "tab") {
45
+ return "tab";
46
+ }
47
+ if (semanticUse === "ChildPageModel") {
48
+ return "popupPage";
49
+ }
50
+ if (semanticUse === "ChildPageTabModel") {
51
+ return "popupTab";
52
+ }
53
+ if (semanticUse === "BlockGridModel" || resolvedKind === "grid") {
54
+ return "grid";
55
+ }
56
+ if ((0, import_placement.isPopupHostUse)(use)) {
57
+ return "popupHost";
58
+ }
59
+ if (import_node_use_sets.ACTION_BUTTON_USES.has(use)) {
60
+ return "action";
61
+ }
62
+ if (import_node_use_sets.FIELD_WRAPPER_USES.has(use) || import_node_use_sets.STANDALONE_FIELD_NODE_USES.has(use) || (0, import_service_utils.isFieldNodeUse)(use)) {
63
+ return "fieldHost";
64
+ }
65
+ if (import_node_use_sets.COLLECTION_BLOCK_USES.has(use) || import_node_use_sets.STATIC_CONTENT_BLOCK_USES.has(use) || import_node_use_sets.JS_BLOCK_USES.has(use) || use.endsWith("BlockModel")) {
66
+ return "block";
67
+ }
68
+ return resolvedKind || "node";
69
+ }
70
+ function assertBindKeyKind(actionName, bindKey, node, resolvedKind) {
71
+ if (!bindKey.expectedKind) {
72
+ return;
73
+ }
74
+ const actualKind = buildPlanKeyKind(node, resolvedKind);
75
+ const expectedKind = String(bindKey.expectedKind || "").trim();
76
+ const matched = expectedKind === "node" || expectedKind === actualKind || expectedKind === "block" && actualKind === "block" || expectedKind === "fieldHost" && actualKind === "fieldHost" || expectedKind === "popupHost" && actualKind === "popupHost" || expectedKind === "popupTab" && actualKind === "popupTab" || expectedKind === "action" && actualKind === "action";
77
+ if (matched) {
78
+ return;
79
+ }
80
+ (0, import_errors.throwBadRequest)(
81
+ `flowSurfaces ${actionName} bindKeys key '${bindKey.key}' expected kind '${expectedKind}', got '${actualKind}'`
82
+ );
83
+ }
84
+ // Annotate the CommonJS export names for ESM import in node:
85
+ 0 && (module.exports = {
86
+ assertBindKeyKind,
87
+ buildPlanKeyKind
88
+ });
@@ -0,0 +1,34 @@
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 { FlowSurfaceResolvedKey } from './types';
10
+ type FlowSurfaceDeclaredKeyPersistenceDeps = {
11
+ findModelById: (uid: string, options?: {
12
+ transaction?: any;
13
+ includeAsyncNode?: boolean;
14
+ }) => Promise<any>;
15
+ patchModel: (values: Record<string, any>, options?: {
16
+ transaction?: any;
17
+ }) => Promise<any>;
18
+ getDeclaredKeyFromNode: (node: any) => string | undefined;
19
+ };
20
+ export declare function assertKeyPersistable(actionName: string, keyInfo: FlowSurfaceResolvedKey, node: any): void;
21
+ export declare function assertRequestKeysPersistable(actionName: string, keys: Map<string, FlowSurfaceResolvedKey>, deps: FlowSurfaceDeclaredKeyPersistenceDeps, transaction?: any): Promise<void>;
22
+ export declare function clearDeclaredKeyForNode(uid: string, deps: FlowSurfaceDeclaredKeyPersistenceDeps, transaction?: any): Promise<void>;
23
+ export declare function persistDeclaredKeyForNode(keyInfo: FlowSurfaceResolvedKey, deps: FlowSurfaceDeclaredKeyPersistenceDeps, transaction?: any): Promise<{
24
+ key: string;
25
+ uid: string;
26
+ persisted: boolean;
27
+ skipped: string;
28
+ } | {
29
+ key: string;
30
+ uid: string;
31
+ persisted: boolean;
32
+ skipped?: undefined;
33
+ }>;
34
+ export {};
@@ -0,0 +1,148 @@
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 key_persistence_exports = {};
38
+ __export(key_persistence_exports, {
39
+ assertKeyPersistable: () => assertKeyPersistable,
40
+ assertRequestKeysPersistable: () => assertRequestKeysPersistable,
41
+ clearDeclaredKeyForNode: () => clearDeclaredKeyForNode,
42
+ persistDeclaredKeyForNode: () => persistDeclaredKeyForNode
43
+ });
44
+ module.exports = __toCommonJS(key_persistence_exports);
45
+ var import_lodash = __toESM(require("lodash"));
46
+ var import_errors = require("../errors");
47
+ var import_key_registry = require("./key-registry");
48
+ function getPersistableDeclaredKey(deps, node) {
49
+ const declaredKey = deps.getDeclaredKeyFromNode(node);
50
+ if (!declaredKey || import_key_registry.FLOW_SURFACE_RESERVED_KEYS.has(declaredKey)) {
51
+ return void 0;
52
+ }
53
+ return declaredKey;
54
+ }
55
+ function assertKeyPersistable(actionName, keyInfo, node) {
56
+ if (import_key_registry.FLOW_SURFACE_RESERVED_KEYS.has(keyInfo.key)) {
57
+ (0, import_errors.throwBadRequest)(
58
+ `flowSurfaces ${actionName} key '${keyInfo.key}' is reserved and cannot be persisted`,
59
+ import_key_registry.FLOW_SURFACE_KEY_NOT_PERSISTABLE_CODE
60
+ );
61
+ }
62
+ }
63
+ async function assertRequestKeysPersistable(actionName, keys, deps, transaction) {
64
+ for (const keyInfo of keys.values()) {
65
+ const node = await deps.findModelById(keyInfo.uid, {
66
+ transaction,
67
+ includeAsyncNode: true
68
+ });
69
+ if (!(node == null ? void 0 : node.uid)) {
70
+ continue;
71
+ }
72
+ assertKeyPersistable(actionName, keyInfo, node);
73
+ }
74
+ }
75
+ async function clearDeclaredKeyForNode(uid, deps, transaction) {
76
+ const node = await deps.findModelById(uid, {
77
+ transaction,
78
+ includeAsyncNode: true
79
+ });
80
+ if (!(node == null ? void 0 : node.uid) || !import_lodash.default.isPlainObject(node.stepParams)) {
81
+ return;
82
+ }
83
+ const nextStepParams = import_lodash.default.cloneDeep(node.stepParams || {});
84
+ import_lodash.default.unset(nextStepParams, [import_key_registry.FLOW_SURFACE_INTERNAL_META_KEY, import_key_registry.FLOW_SURFACE_DECLARED_KEY_KEY]);
85
+ if (import_lodash.default.isEmpty(import_lodash.default.get(nextStepParams, [import_key_registry.FLOW_SURFACE_INTERNAL_META_KEY]))) {
86
+ import_lodash.default.unset(nextStepParams, [import_key_registry.FLOW_SURFACE_INTERNAL_META_KEY]);
87
+ }
88
+ await deps.patchModel(
89
+ {
90
+ uid: node.uid,
91
+ ...Object.keys(nextStepParams).length ? { stepParams: nextStepParams } : { stepParams: {} }
92
+ },
93
+ { transaction }
94
+ );
95
+ }
96
+ async function persistDeclaredKeyForNode(keyInfo, deps, transaction) {
97
+ const node = await deps.findModelById(keyInfo.uid, {
98
+ transaction,
99
+ includeAsyncNode: true
100
+ });
101
+ if (!(node == null ? void 0 : node.uid)) {
102
+ return {
103
+ key: keyInfo.key,
104
+ uid: keyInfo.uid,
105
+ persisted: false,
106
+ skipped: "not_found"
107
+ };
108
+ }
109
+ assertKeyPersistable("key persistence", keyInfo, node);
110
+ if (keyInfo.reboundFromUid && keyInfo.reboundFromUid !== keyInfo.uid) {
111
+ await clearDeclaredKeyForNode(keyInfo.reboundFromUid, deps, transaction);
112
+ }
113
+ const currentDeclaredKey = getPersistableDeclaredKey(deps, node);
114
+ if (currentDeclaredKey && currentDeclaredKey !== keyInfo.key && !keyInfo.rebind) {
115
+ (0, import_errors.throwConflict)(
116
+ `flowSurfaces node '${node.uid}' already has declared key '${currentDeclaredKey}'`,
117
+ "FLOW_SURFACE_DECLARED_KEY_CONFLICT"
118
+ );
119
+ }
120
+ if (currentDeclaredKey === keyInfo.key) {
121
+ return {
122
+ key: keyInfo.key,
123
+ uid: keyInfo.uid,
124
+ persisted: true
125
+ };
126
+ }
127
+ const nextStepParams = import_lodash.default.cloneDeep(node.stepParams || {});
128
+ import_lodash.default.set(nextStepParams, [import_key_registry.FLOW_SURFACE_INTERNAL_META_KEY, import_key_registry.FLOW_SURFACE_DECLARED_KEY_KEY], keyInfo.key);
129
+ await deps.patchModel(
130
+ {
131
+ uid: node.uid,
132
+ stepParams: nextStepParams
133
+ },
134
+ { transaction }
135
+ );
136
+ return {
137
+ key: keyInfo.key,
138
+ uid: keyInfo.uid,
139
+ persisted: true
140
+ };
141
+ }
142
+ // Annotate the CommonJS export names for ESM import in node:
143
+ 0 && (module.exports = {
144
+ assertKeyPersistable,
145
+ assertRequestKeysPersistable,
146
+ clearDeclaredKeyForNode,
147
+ persistDeclaredKeyForNode
148
+ });