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

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 (244) 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 +969 -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-title-field.d.ts +20 -0
  92. package/dist/server/flow-surfaces/association-title-field.js +192 -0
  93. package/dist/server/flow-surfaces/blueprint/compile-blocks.d.ts +14 -0
  94. package/dist/server/flow-surfaces/blueprint/compile-blocks.js +1029 -0
  95. package/dist/server/flow-surfaces/blueprint/compile-plan.d.ts +13 -0
  96. package/dist/server/flow-surfaces/blueprint/compile-plan.js +308 -0
  97. package/dist/server/flow-surfaces/blueprint/compile-reaction.d.ts +11 -0
  98. package/dist/server/flow-surfaces/blueprint/compile-reaction.js +72 -0
  99. package/dist/server/flow-surfaces/blueprint/defaults.d.ts +26 -0
  100. package/dist/server/flow-surfaces/blueprint/defaults.js +133 -0
  101. package/dist/server/flow-surfaces/blueprint/index.d.ts +12 -0
  102. package/dist/server/flow-surfaces/blueprint/index.js +44 -0
  103. package/dist/server/flow-surfaces/blueprint/normalize-document.d.ts +10 -0
  104. package/dist/server/flow-surfaces/blueprint/normalize-document.js +416 -0
  105. package/dist/server/flow-surfaces/blueprint/private-utils.d.ts +26 -0
  106. package/dist/server/flow-surfaces/blueprint/private-utils.js +182 -0
  107. package/dist/server/flow-surfaces/blueprint/public-types.d.ts +193 -0
  108. package/dist/server/flow-surfaces/blueprint/public-types.js +24 -0
  109. package/dist/server/flow-surfaces/builder.d.ts +211 -0
  110. package/dist/server/flow-surfaces/builder.js +1097 -0
  111. package/dist/server/flow-surfaces/catalog-smart.d.ts +18 -0
  112. package/dist/server/flow-surfaces/catalog-smart.js +239 -0
  113. package/dist/server/flow-surfaces/catalog-smart.projector.d.ts +15 -0
  114. package/dist/server/flow-surfaces/catalog-smart.projector.js +157 -0
  115. package/dist/server/flow-surfaces/catalog-smart.types.d.ts +99 -0
  116. package/dist/server/flow-surfaces/catalog-smart.types.js +24 -0
  117. package/dist/server/flow-surfaces/catalog.d.ts +78 -0
  118. package/dist/server/flow-surfaces/catalog.js +3577 -0
  119. package/dist/server/flow-surfaces/chart-config.d.ts +121 -0
  120. package/dist/server/flow-surfaces/chart-config.js +1394 -0
  121. package/dist/server/flow-surfaces/compose-compiler.d.ts +108 -0
  122. package/dist/server/flow-surfaces/compose-compiler.js +167 -0
  123. package/dist/server/flow-surfaces/compose-runtime.d.ts +93 -0
  124. package/dist/server/flow-surfaces/compose-runtime.js +375 -0
  125. package/dist/server/flow-surfaces/configure-options.d.ts +23 -0
  126. package/dist/server/flow-surfaces/configure-options.js +860 -0
  127. package/dist/server/flow-surfaces/constants.d.ts +351 -0
  128. package/dist/server/flow-surfaces/constants.js +104 -0
  129. package/dist/server/flow-surfaces/context.d.ts +72 -0
  130. package/dist/server/flow-surfaces/context.js +556 -0
  131. package/dist/server/flow-surfaces/contract-guard.d.ts +19 -0
  132. package/dist/server/flow-surfaces/contract-guard.js +402 -0
  133. package/dist/server/flow-surfaces/core-field-default-bindings.d.ts +12 -0
  134. package/dist/server/flow-surfaces/core-field-default-bindings.js +157 -0
  135. package/dist/server/flow-surfaces/default-action-popup.d.ts +63 -0
  136. package/dist/server/flow-surfaces/default-action-popup.js +322 -0
  137. package/dist/server/flow-surfaces/default-block-actions.d.ts +32 -0
  138. package/dist/server/flow-surfaces/default-block-actions.js +209 -0
  139. package/dist/server/flow-surfaces/errors.d.ts +47 -0
  140. package/dist/server/flow-surfaces/errors.js +145 -0
  141. package/dist/server/flow-surfaces/executor.d.ts +23 -0
  142. package/dist/server/flow-surfaces/executor.js +132 -0
  143. package/dist/server/flow-surfaces/field-binding-registry.d.ts +23 -0
  144. package/dist/server/flow-surfaces/field-binding-registry.js +391 -0
  145. package/dist/server/flow-surfaces/field-semantics.d.ts +15 -0
  146. package/dist/server/flow-surfaces/field-semantics.js +83 -0
  147. package/dist/server/flow-surfaces/filter-group.d.ts +15 -0
  148. package/dist/server/flow-surfaces/filter-group.js +94 -0
  149. package/dist/server/flow-surfaces/index.d.ts +11 -0
  150. package/dist/server/flow-surfaces/index.js +302 -0
  151. package/dist/server/flow-surfaces/locator.d.ts +28 -0
  152. package/dist/server/flow-surfaces/locator.js +240 -0
  153. package/dist/server/flow-surfaces/node-use-sets.d.ts +15 -0
  154. package/dist/server/flow-surfaces/node-use-sets.js +134 -0
  155. package/dist/server/flow-surfaces/payload-shape.d.ts +9 -0
  156. package/dist/server/flow-surfaces/payload-shape.js +61 -0
  157. package/dist/server/flow-surfaces/placement.d.ts +33 -0
  158. package/dist/server/flow-surfaces/placement.js +198 -0
  159. package/dist/server/flow-surfaces/planning/action-specs.d.ts +179 -0
  160. package/dist/server/flow-surfaces/planning/action-specs.js +190 -0
  161. package/dist/server/flow-surfaces/planning/compiler.d.ts +37 -0
  162. package/dist/server/flow-surfaces/planning/compiler.js +376 -0
  163. package/dist/server/flow-surfaces/planning/context.d.ts +30 -0
  164. package/dist/server/flow-surfaces/planning/context.js +139 -0
  165. package/dist/server/flow-surfaces/planning/created-keys.d.ts +34 -0
  166. package/dist/server/flow-surfaces/planning/created-keys.js +375 -0
  167. package/dist/server/flow-surfaces/planning/key-kind.d.ts +11 -0
  168. package/dist/server/flow-surfaces/planning/key-kind.js +88 -0
  169. package/dist/server/flow-surfaces/planning/key-persistence.d.ts +34 -0
  170. package/dist/server/flow-surfaces/planning/key-persistence.js +148 -0
  171. package/dist/server/flow-surfaces/planning/key-registry.d.ts +40 -0
  172. package/dist/server/flow-surfaces/planning/key-registry.js +206 -0
  173. package/dist/server/flow-surfaces/planning/runtime.d.ts +37 -0
  174. package/dist/server/flow-surfaces/planning/runtime.js +259 -0
  175. package/dist/server/flow-surfaces/planning/step-link.d.ts +14 -0
  176. package/dist/server/flow-surfaces/planning/step-link.js +104 -0
  177. package/dist/server/flow-surfaces/planning/types.d.ts +55 -0
  178. package/dist/server/flow-surfaces/planning/types.js +24 -0
  179. package/dist/server/flow-surfaces/public-data-surface-default-filter.d.ts +24 -0
  180. package/dist/server/flow-surfaces/public-data-surface-default-filter.js +152 -0
  181. package/dist/server/flow-surfaces/reaction/errors.d.ts +20 -0
  182. package/dist/server/flow-surfaces/reaction/errors.js +69 -0
  183. package/dist/server/flow-surfaces/reaction/field-value.d.ts +34 -0
  184. package/dist/server/flow-surfaces/reaction/field-value.js +181 -0
  185. package/dist/server/flow-surfaces/reaction/fingerprint.d.ts +16 -0
  186. package/dist/server/flow-surfaces/reaction/fingerprint.js +71 -0
  187. package/dist/server/flow-surfaces/reaction/linkage.d.ts +136 -0
  188. package/dist/server/flow-surfaces/reaction/linkage.js +882 -0
  189. package/dist/server/flow-surfaces/reaction/meta.d.ts +11 -0
  190. package/dist/server/flow-surfaces/reaction/meta.js +451 -0
  191. package/dist/server/flow-surfaces/reaction/registry.d.ts +156 -0
  192. package/dist/server/flow-surfaces/reaction/registry.js +206 -0
  193. package/dist/server/flow-surfaces/reaction/resolver.d.ts +22 -0
  194. package/dist/server/flow-surfaces/reaction/resolver.js +202 -0
  195. package/dist/server/flow-surfaces/reaction/types.d.ts +241 -0
  196. package/dist/server/flow-surfaces/reaction/types.js +24 -0
  197. package/dist/server/flow-surfaces/reaction/utils.d.ts +17 -0
  198. package/dist/server/flow-surfaces/reaction/utils.js +67 -0
  199. package/dist/server/flow-surfaces/reaction/value-expr.d.ts +15 -0
  200. package/dist/server/flow-surfaces/reaction/value-expr.js +209 -0
  201. package/dist/server/flow-surfaces/reference-guards.d.ts +19 -0
  202. package/dist/server/flow-surfaces/reference-guards.js +103 -0
  203. package/dist/server/flow-surfaces/route-sync.d.ts +47 -0
  204. package/dist/server/flow-surfaces/route-sync.js +392 -0
  205. package/dist/server/flow-surfaces/service-helpers.d.ts +42 -0
  206. package/dist/server/flow-surfaces/service-helpers.js +310 -0
  207. package/dist/server/flow-surfaces/service-utils.d.ts +108 -0
  208. package/dist/server/flow-surfaces/service-utils.js +811 -0
  209. package/dist/server/flow-surfaces/service.d.ts +814 -0
  210. package/dist/server/flow-surfaces/service.js +14276 -0
  211. package/dist/server/flow-surfaces/support-matrix.d.ts +31 -0
  212. package/dist/server/flow-surfaces/support-matrix.js +271 -0
  213. package/dist/server/flow-surfaces/surface-context.d.ts +52 -0
  214. package/dist/server/flow-surfaces/surface-context.js +440 -0
  215. package/dist/server/flow-surfaces/template-compatibility.d.ts +42 -0
  216. package/dist/server/flow-surfaces/template-compatibility.js +189 -0
  217. package/dist/server/flow-surfaces/template-display.d.ts +20 -0
  218. package/dist/server/flow-surfaces/template-display.js +289 -0
  219. package/dist/server/flow-surfaces/template-service-utils.d.ts +62 -0
  220. package/dist/server/flow-surfaces/template-service-utils.js +281 -0
  221. package/dist/server/flow-surfaces/types.d.ts +288 -0
  222. package/dist/server/flow-surfaces/types.js +24 -0
  223. package/dist/server/index.d.ts +1 -0
  224. package/dist/server/index.js +7 -2
  225. package/dist/server/plugin.d.ts +0 -1
  226. package/dist/server/plugin.js +9 -34
  227. package/dist/server/repository.js +0 -5
  228. package/dist/server/variables/resolve.d.ts +21 -0
  229. package/dist/server/variables/resolve.js +79 -0
  230. package/dist/swagger/flow-surfaces.d.ts +5964 -0
  231. package/dist/swagger/flow-surfaces.examples.d.ts +1572 -0
  232. package/dist/swagger/flow-surfaces.examples.js +1805 -0
  233. package/dist/swagger/flow-surfaces.js +5322 -0
  234. package/dist/swagger/flow-surfaces.template-action-docs.d.ts +62 -0
  235. package/dist/swagger/flow-surfaces.template-action-docs.js +121 -0
  236. package/dist/swagger/flow-surfaces.template-schemas.d.ts +239 -0
  237. package/dist/swagger/flow-surfaces.template-schemas.js +255 -0
  238. package/dist/swagger/index.d.ts +5969 -0
  239. package/dist/swagger/index.js +50 -0
  240. package/package.json +3 -3
  241. /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextApis.d.ts +0 -0
  242. /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextEnvs.d.ts +0 -0
  243. /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextVars.d.ts +0 -0
  244. /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/lintAndTestJS.d.ts +0 -0
@@ -0,0 +1,1097 @@
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 builder_exports = {};
38
+ __export(builder_exports, {
39
+ assignClientKeysToUids: () => assignClientKeysToUids,
40
+ buildActionTree: () => buildActionTree,
41
+ buildBlockTree: () => buildBlockTree,
42
+ buildCanonicalTableActionsColumnNode: () => buildCanonicalTableActionsColumnNode,
43
+ buildFieldTree: () => buildFieldTree,
44
+ buildPersistedRootPageModel: () => buildPersistedRootPageModel,
45
+ buildPopupPageTree: () => buildPopupPageTree,
46
+ buildStandaloneFieldNode: () => buildStandaloneFieldNode,
47
+ buildSyntheticRootPageTabModel: () => buildSyntheticRootPageTabModel
48
+ });
49
+ module.exports = __toCommonJS(builder_exports);
50
+ var import_utils = require("@nocobase/utils");
51
+ var import_lodash = __toESM(require("lodash"));
52
+ var import_catalog = require("./catalog");
53
+ var import_chart_config = require("./chart-config");
54
+ var import_approval = require("./approval");
55
+ var import_service_utils = require("./service-utils");
56
+ const JS_BLOCK_DEFAULT_CODE = [
57
+ "// Welcome to the JS block",
58
+ "ctx.render(`",
59
+ ` <div style="padding: 24px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; line-height: 1.6;">`,
60
+ ' <h2 style="color: #1890ff; margin: 0 0 12px 0; font-size: 24px; font-weight: 600;">JS Block</h2>',
61
+ ' <p style="color: #666; margin: 0;">Replace this code with your custom JavaScript to build an interactive block.</p>',
62
+ " </div>",
63
+ "`);"
64
+ ].join("\n");
65
+ const JS_FIELD_DEFAULT_CODE = [
66
+ "function JsReadonlyField() {",
67
+ " const React = ctx.React;",
68
+ " const { prefix, suffix, overflowMode } = ctx.model?.props || {};",
69
+ " const text = String(ctx.value ?? '');",
70
+ " const whiteSpace = overflowMode === 'wrap' ? 'pre-line' : 'nowrap';",
71
+ "",
72
+ " return (",
73
+ " <span style={{ whiteSpace }}>",
74
+ " {prefix}",
75
+ " {text}",
76
+ " {suffix}",
77
+ " </span>",
78
+ " );",
79
+ "}",
80
+ "",
81
+ "ctx.render(<JsReadonlyField />);"
82
+ ].join("\n");
83
+ const JS_EDITABLE_FIELD_DEFAULT_CODE = [
84
+ "// Render an editable antd Input via JSX and keep it in sync with form value.",
85
+ "function JsEditableField() {",
86
+ " const React = ctx.React;",
87
+ " const { Input } = ctx.antd;",
88
+ " const [value, setValue] = React.useState(ctx.getValue?.() ?? '');",
89
+ "",
90
+ " React.useEffect(() => {",
91
+ " const handler = (ev) => setValue(ev?.detail ?? '');",
92
+ " ctx.element?.addEventListener('js-field:value-change', handler);",
93
+ " return () => ctx.element?.removeEventListener('js-field:value-change', handler);",
94
+ " }, []);",
95
+ "",
96
+ " const onChange = (e) => {",
97
+ " const v = e?.target?.value ?? '';",
98
+ " setValue(v);",
99
+ " ctx.setValue?.(v);",
100
+ " };",
101
+ "",
102
+ " return <Input {...ctx.model.props} value={value} onChange={onChange} />;",
103
+ "}",
104
+ "",
105
+ "ctx.render(<JsEditableField />);"
106
+ ].join("\n");
107
+ const JS_ITEM_DEFAULT_CODE = [
108
+ "function JsItem() {",
109
+ " return (",
110
+ ` <div style={{ fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif", lineHeight: 1.6 }}>`,
111
+ " <h3 style={{ color: '#1890ff', margin: '0 0 12px 0', fontSize: 18, fontWeight: 600 }}>JS Item</h3>",
112
+ " <div style={{ color: '#555' }}>This area is rendered by your JavaScript code.</div>",
113
+ " </div>",
114
+ " );",
115
+ "}",
116
+ "",
117
+ "ctx.render(<JsItem />);"
118
+ ].join("\n");
119
+ const JS_COLUMN_DEFAULT_CODE = `ctx.render('<span class="nb-js-column">JS column</span>');`;
120
+ const CALENDAR_QUICK_CREATE_ACTION_KEY = "quickCreateAction";
121
+ const CALENDAR_EVENT_VIEW_ACTION_KEY = "eventViewAction";
122
+ const KANBAN_QUICK_CREATE_ACTION_KEY = "quickCreateAction";
123
+ const KANBAN_CARD_VIEW_ACTION_KEY = "cardViewAction";
124
+ const CALENDAR_READONLY_ACTION_MODEL_USES = /* @__PURE__ */ new Set([
125
+ "CalendarNavActionModel",
126
+ "CalendarTitleActionModel",
127
+ "CalendarViewSelectActionModel"
128
+ ]);
129
+ const JS_ACTION_DEFAULT_CODE_BY_USE = {
130
+ JSCollectionActionModel: [
131
+ "const rows = ctx.resource?.getSelectedRows?.() || [];",
132
+ "if (!rows.length) {",
133
+ " ctx.message.warning('Please select data first.');",
134
+ "} else {",
135
+ " ctx.message.success('Selected ' + rows.length + ' row(s).');",
136
+ "}"
137
+ ].join("\n"),
138
+ JSRecordActionModel: [
139
+ "if (!ctx.record) {",
140
+ " ctx.message.error('No record');",
141
+ "} else {",
142
+ " ctx.message.success('Record ID: ' + (ctx.filterByTk ?? ctx.record?.id));",
143
+ "}"
144
+ ].join("\n"),
145
+ JSFormActionModel: [
146
+ "const values = ctx.form?.getFieldsValue?.() || {};",
147
+ "ctx.message.success('Current form values: ' + JSON.stringify(values));"
148
+ ].join("\n"),
149
+ JSItemActionModel: [
150
+ "const values = ctx.form?.getFieldsValue?.() || ctx.formValues || {};",
151
+ "ctx.message.success('Current form values: ' + JSON.stringify(values));"
152
+ ].join("\n"),
153
+ FilterFormJSActionModel: "",
154
+ JSActionModel: "ctx.message.info('Hello JS action.');"
155
+ };
156
+ function buildRunJsStepParams(code) {
157
+ return {
158
+ runJs: {
159
+ version: "v2",
160
+ code
161
+ }
162
+ };
163
+ }
164
+ function buildPersistedRootPageModel(options) {
165
+ const pageUid = options.pageUid || (0, import_utils.uid)();
166
+ const enableTabs = !!options.enableTabs;
167
+ const displayTitle = options.displayTitle !== false;
168
+ return {
169
+ uid: pageUid,
170
+ use: "RootPageModel",
171
+ props: {
172
+ routeId: options.routeId,
173
+ title: options.pageTitle,
174
+ enableTabs,
175
+ displayTitle
176
+ },
177
+ stepParams: {
178
+ pageSettings: {
179
+ general: {
180
+ title: options.pageTitle,
181
+ displayTitle,
182
+ enableTabs,
183
+ documentTitle: options.pageDocumentTitle
184
+ }
185
+ }
186
+ }
187
+ };
188
+ }
189
+ function buildSyntheticRootPageTabModel(options) {
190
+ var _a;
191
+ const stepParams = import_lodash.default.cloneDeep(options.stepParams || {});
192
+ return {
193
+ uid: options.uid,
194
+ use: options.use || "RootPageTabModel",
195
+ props: {
196
+ ...options.props || {},
197
+ route: import_lodash.default.cloneDeep(options.route),
198
+ title: options.title,
199
+ icon: options.icon
200
+ },
201
+ decoratorProps: import_lodash.default.cloneDeep(options.decoratorProps || {}),
202
+ flowRegistry: import_lodash.default.cloneDeep(options.flowRegistry || {}),
203
+ stepParams: {
204
+ ...stepParams,
205
+ pageTabSettings: {
206
+ ...stepParams.pageTabSettings || {},
207
+ tab: {
208
+ ...((_a = stepParams.pageTabSettings) == null ? void 0 : _a.tab) || {},
209
+ title: options.title,
210
+ icon: options.icon,
211
+ documentTitle: options.documentTitle
212
+ }
213
+ }
214
+ },
215
+ ...options.grid ? { subModels: { grid: options.grid } } : {}
216
+ };
217
+ }
218
+ function buildBlockTree(options) {
219
+ var _a, _b;
220
+ const use = (0, import_catalog.resolveSupportedBlockCatalogItem)(
221
+ {
222
+ type: options.type,
223
+ use: options.use,
224
+ containerUse: options.containerUse
225
+ },
226
+ {
227
+ requireCreateSupported: true
228
+ }
229
+ ).use;
230
+ const defaults = buildBlockDefaults(use);
231
+ const approvalBlockDefaults = (0, import_approval.buildApprovalBlockDefaults)(use);
232
+ const baseStepParams = import_lodash.default.merge(
233
+ {},
234
+ import_lodash.default.cloneDeep(defaults.stepParams || {}),
235
+ import_lodash.default.cloneDeep((approvalBlockDefaults == null ? void 0 : approvalBlockDefaults.stepParams) || {}),
236
+ import_lodash.default.cloneDeep(options.stepParams || {})
237
+ );
238
+ const normalizedResourceInit = import_lodash.default.pickBy(import_lodash.default.cloneDeep(options.resourceInit || {}), (value) => !import_lodash.default.isUndefined(value));
239
+ if (use === "ChartBlockModel") {
240
+ import_lodash.default.unset(baseStepParams, "resourceSettings");
241
+ const currentConfigure = import_lodash.default.get(baseStepParams, ["chartSettings", "configure"]) || {};
242
+ const nextConfigure = import_lodash.default.merge(
243
+ {
244
+ query: {
245
+ mode: "builder"
246
+ },
247
+ chart: {
248
+ option: {
249
+ mode: "basic"
250
+ }
251
+ }
252
+ },
253
+ import_lodash.default.cloneDeep(currentConfigure)
254
+ );
255
+ if (Object.keys(normalizedResourceInit).length) {
256
+ import_lodash.default.set(nextConfigure, ["query", "mode"], "builder");
257
+ import_lodash.default.set(
258
+ nextConfigure,
259
+ ["query", "collectionPath"],
260
+ [normalizedResourceInit.dataSourceKey || import_chart_config.CHART_DEFAULT_DATA_SOURCE_KEY, normalizedResourceInit.collectionName]
261
+ );
262
+ import_lodash.default.unset(nextConfigure, ["query", "resource"]);
263
+ }
264
+ import_lodash.default.set(baseStepParams, ["chartSettings", "configure"], nextConfigure);
265
+ } else if (Object.keys(normalizedResourceInit).length) {
266
+ import_lodash.default.set(baseStepParams, ["resourceSettings", "init"], normalizedResourceInit);
267
+ }
268
+ const model = {
269
+ ...use === "CalendarBlockModel" || use === "KanbanBlockModel" ? { uid: (0, import_utils.uid)() } : {},
270
+ use,
271
+ ...typeof (approvalBlockDefaults == null ? void 0 : approvalBlockDefaults.async) === "boolean" ? { async: approvalBlockDefaults.async } : {},
272
+ props: import_lodash.default.merge(
273
+ {},
274
+ import_lodash.default.cloneDeep(defaults.props || {}),
275
+ import_lodash.default.cloneDeep((approvalBlockDefaults == null ? void 0 : approvalBlockDefaults.props) || {}),
276
+ import_lodash.default.cloneDeep(options.props || {})
277
+ ),
278
+ decoratorProps: import_lodash.default.merge(
279
+ {},
280
+ import_lodash.default.cloneDeep(defaults.decoratorProps || {}),
281
+ import_lodash.default.cloneDeep((approvalBlockDefaults == null ? void 0 : approvalBlockDefaults.decoratorProps) || {}),
282
+ import_lodash.default.cloneDeep(options.decoratorProps || {})
283
+ ),
284
+ stepParams: baseStepParams
285
+ };
286
+ const flowRegistry = import_lodash.default.merge(
287
+ {},
288
+ import_lodash.default.cloneDeep(defaults.flowRegistry || {}),
289
+ import_lodash.default.cloneDeep((approvalBlockDefaults == null ? void 0 : approvalBlockDefaults.flowRegistry) || {}),
290
+ import_lodash.default.cloneDeep(options.flowRegistry || {})
291
+ );
292
+ if (Object.keys(flowRegistry).length) {
293
+ model.flowRegistry = flowRegistry;
294
+ }
295
+ if (approvalBlockDefaults == null ? void 0 : approvalBlockDefaults.subModels) {
296
+ model.subModels = {};
297
+ const gridDefaults = (0, import_service_utils.getSingleNodeSubModel)(approvalBlockDefaults.subModels.grid);
298
+ if (gridDefaults == null ? void 0 : gridDefaults.use) {
299
+ model.subModels.grid = {
300
+ uid: (0, import_utils.uid)(),
301
+ use: gridDefaults.use
302
+ };
303
+ }
304
+ if (Array.isArray(approvalBlockDefaults.subModels.actions) && approvalBlockDefaults.subModels.actions.length) {
305
+ model.subModels.actions = approvalBlockDefaults.subModels.actions.map((action) => ({
306
+ uid: (0, import_utils.uid)(),
307
+ ...buildActionTree({
308
+ use: action.use,
309
+ containerUse: use
310
+ })
311
+ }));
312
+ }
313
+ } else if (use === "TableBlockModel") {
314
+ model.subModels = {
315
+ columns: [buildCanonicalTableActionsColumnNode()]
316
+ };
317
+ } else if (["FormBlockModel", "CreateFormModel", "EditFormModel", "AssignFormModel"].includes(use)) {
318
+ model.subModels = {
319
+ grid: {
320
+ uid: (0, import_utils.uid)(),
321
+ use: use === "AssignFormModel" ? "AssignFormGridModel" : "FormGridModel"
322
+ }
323
+ };
324
+ } else if (use === "DetailsBlockModel") {
325
+ model.subModels = {
326
+ grid: {
327
+ uid: (0, import_utils.uid)(),
328
+ use: "DetailsGridModel"
329
+ }
330
+ };
331
+ } else if (use === "FilterFormBlockModel") {
332
+ model.subModels = {
333
+ grid: {
334
+ uid: (0, import_utils.uid)(),
335
+ use: "FilterFormGridModel"
336
+ }
337
+ };
338
+ } else if (use === "ListBlockModel") {
339
+ model.subModels = {
340
+ item: {
341
+ uid: (0, import_utils.uid)(),
342
+ use: "ListItemModel",
343
+ subModels: {
344
+ grid: {
345
+ uid: (0, import_utils.uid)(),
346
+ use: "DetailsGridModel"
347
+ }
348
+ }
349
+ }
350
+ };
351
+ } else if (use === "GridCardBlockModel") {
352
+ model.subModels = {
353
+ item: {
354
+ uid: (0, import_utils.uid)(),
355
+ use: "GridCardItemModel",
356
+ subModels: {
357
+ grid: {
358
+ uid: (0, import_utils.uid)(),
359
+ use: "DetailsGridModel"
360
+ }
361
+ }
362
+ }
363
+ };
364
+ } else if (use === "KanbanBlockModel") {
365
+ const blockUid = model.uid || (0, import_utils.uid)();
366
+ model.uid = blockUid;
367
+ model.subModels = {
368
+ item: {
369
+ uid: (0, import_utils.uid)(),
370
+ use: "KanbanCardItemModel",
371
+ subModels: {
372
+ grid: {
373
+ uid: (0, import_utils.uid)(),
374
+ use: "DetailsGridModel"
375
+ }
376
+ }
377
+ },
378
+ [KANBAN_QUICK_CREATE_ACTION_KEY]: buildKanbanPopupActionNode({
379
+ actionKey: KANBAN_QUICK_CREATE_ACTION_KEY,
380
+ blockUid,
381
+ resourceInit: normalizedResourceInit
382
+ }),
383
+ [KANBAN_CARD_VIEW_ACTION_KEY]: buildKanbanPopupActionNode({
384
+ actionKey: KANBAN_CARD_VIEW_ACTION_KEY,
385
+ blockUid,
386
+ resourceInit: normalizedResourceInit
387
+ })
388
+ };
389
+ } else if (use === "CalendarBlockModel") {
390
+ const blockUid = model.uid || (0, import_utils.uid)();
391
+ model.uid = blockUid;
392
+ model.subModels = {
393
+ [CALENDAR_QUICK_CREATE_ACTION_KEY]: buildCalendarPopupActionNode({
394
+ actionKey: CALENDAR_QUICK_CREATE_ACTION_KEY,
395
+ blockUid,
396
+ resourceInit: normalizedResourceInit,
397
+ popupSettings: (_a = model.props) == null ? void 0 : _a.quickCreatePopupSettings
398
+ }),
399
+ [CALENDAR_EVENT_VIEW_ACTION_KEY]: buildCalendarPopupActionNode({
400
+ actionKey: CALENDAR_EVENT_VIEW_ACTION_KEY,
401
+ blockUid,
402
+ resourceInit: normalizedResourceInit,
403
+ popupSettings: (_b = model.props) == null ? void 0 : _b.eventPopupSettings
404
+ })
405
+ };
406
+ }
407
+ return assignClientKeysToUids(model, {});
408
+ }
409
+ function buildKanbanPopupActionNode(options) {
410
+ const actionUid = options.actionKey === KANBAN_QUICK_CREATE_ACTION_KEY ? `${options.blockUid}-quick-create-action` : `${options.blockUid}-card-view-action`;
411
+ return {
412
+ uid: actionUid,
413
+ use: options.actionKey === KANBAN_QUICK_CREATE_ACTION_KEY ? "KanbanQuickCreateActionModel" : "KanbanCardViewActionModel",
414
+ stepParams: {
415
+ popupSettings: {
416
+ openView: buildKanbanPopupOpenView({
417
+ actionUid,
418
+ resourceInit: options.resourceInit,
419
+ popupSettings: options.popupSettings
420
+ })
421
+ }
422
+ }
423
+ };
424
+ }
425
+ function buildKanbanPopupOpenView(options) {
426
+ var _a, _b, _c;
427
+ const defaults = import_lodash.default.pickBy(
428
+ {
429
+ mode: "drawer",
430
+ size: "medium",
431
+ pageModelClass: "ChildPageModel",
432
+ uid: options.actionUid,
433
+ collectionName: (_a = options.resourceInit) == null ? void 0 : _a.collectionName,
434
+ dataSourceKey: ((_b = options.resourceInit) == null ? void 0 : _b.dataSourceKey) || (((_c = options.resourceInit) == null ? void 0 : _c.collectionName) ? "main" : void 0)
435
+ },
436
+ (value) => !import_lodash.default.isUndefined(value)
437
+ );
438
+ const current = import_lodash.default.cloneDeep(options.popupSettings || {});
439
+ return import_lodash.default.pickBy(
440
+ {
441
+ ...defaults,
442
+ ...current,
443
+ uid: current.uid || defaults.uid,
444
+ collectionName: current.collectionName || defaults.collectionName,
445
+ dataSourceKey: current.dataSourceKey || defaults.dataSourceKey
446
+ },
447
+ (value) => !import_lodash.default.isUndefined(value)
448
+ );
449
+ }
450
+ function buildCalendarPopupActionNode(options) {
451
+ const actionUid = `${options.blockUid}-${options.actionKey}`;
452
+ return {
453
+ uid: actionUid,
454
+ use: options.actionKey === CALENDAR_QUICK_CREATE_ACTION_KEY ? "CalendarQuickCreateActionModel" : "CalendarEventViewActionModel",
455
+ stepParams: {
456
+ popupSettings: {
457
+ openView: buildCalendarPopupOpenView({
458
+ actionUid,
459
+ resourceInit: options.resourceInit,
460
+ popupSettings: options.popupSettings
461
+ })
462
+ }
463
+ }
464
+ };
465
+ }
466
+ function buildCalendarPopupOpenView(options) {
467
+ var _a, _b, _c;
468
+ const defaults = import_lodash.default.pickBy(
469
+ {
470
+ mode: "drawer",
471
+ size: "medium",
472
+ pageModelClass: "ChildPageModel",
473
+ uid: options.actionUid,
474
+ collectionName: (_a = options.resourceInit) == null ? void 0 : _a.collectionName,
475
+ dataSourceKey: ((_b = options.resourceInit) == null ? void 0 : _b.dataSourceKey) || (((_c = options.resourceInit) == null ? void 0 : _c.collectionName) ? "main" : void 0)
476
+ },
477
+ (value) => !import_lodash.default.isUndefined(value)
478
+ );
479
+ const current = import_lodash.default.cloneDeep(options.popupSettings || {});
480
+ return import_lodash.default.pickBy(
481
+ {
482
+ ...defaults,
483
+ ...current,
484
+ uid: current.uid || defaults.uid,
485
+ collectionName: current.collectionName || defaults.collectionName,
486
+ dataSourceKey: current.dataSourceKey || defaults.dataSourceKey
487
+ },
488
+ (value) => !import_lodash.default.isUndefined(value)
489
+ );
490
+ }
491
+ function buildPopupPageTree(options) {
492
+ const pageUid = options.pageUid || (0, import_utils.uid)();
493
+ const tabUid = options.tabUid || (0, import_utils.uid)();
494
+ const gridUid = options.gridUid || (0, import_utils.uid)();
495
+ const displayTitle = options.displayTitle === true;
496
+ const enableTabs = options.enableTabs !== false;
497
+ const tabTitle = options.tabTitle || '{{t("Details")}}';
498
+ return {
499
+ uid: pageUid,
500
+ use: "ChildPageModel",
501
+ props: {
502
+ ...options.pageTitle ? { title: options.pageTitle } : {},
503
+ displayTitle,
504
+ enableTabs
505
+ },
506
+ stepParams: {
507
+ pageSettings: {
508
+ general: {
509
+ ...options.pageTitle ? { title: options.pageTitle } : {},
510
+ displayTitle,
511
+ enableTabs
512
+ }
513
+ }
514
+ },
515
+ subModels: {
516
+ tabs: [
517
+ {
518
+ uid: tabUid,
519
+ use: "ChildPageTabModel",
520
+ props: {
521
+ title: tabTitle
522
+ },
523
+ stepParams: {
524
+ pageTabSettings: {
525
+ tab: {
526
+ title: tabTitle
527
+ }
528
+ }
529
+ },
530
+ subModels: {
531
+ grid: {
532
+ uid: gridUid,
533
+ use: "BlockGridModel"
534
+ }
535
+ }
536
+ }
537
+ ]
538
+ }
539
+ };
540
+ }
541
+ function buildFieldTree(params) {
542
+ const wrapperUid = params.uid || (0, import_utils.uid)();
543
+ const innerUid = params.innerUid || (0, import_utils.uid)();
544
+ const fieldDefaults = getStandaloneFieldDefaults(params.fieldUse);
545
+ const approvalTree = (0, import_approval.buildApprovalFieldTree)({
546
+ ...params,
547
+ uid: wrapperUid,
548
+ innerUid,
549
+ fieldDefaults
550
+ });
551
+ if (approvalTree) {
552
+ return {
553
+ wrapperUid: approvalTree.wrapperUid,
554
+ innerUid: approvalTree.innerUid,
555
+ model: approvalTree.model
556
+ };
557
+ }
558
+ const initPayload = import_lodash.default.pickBy(
559
+ {
560
+ dataSourceKey: params.dataSourceKey,
561
+ collectionName: params.collectionName,
562
+ fieldPath: params.fieldPath,
563
+ ...params.associationPathName ? { associationPathName: params.associationPathName } : {}
564
+ },
565
+ (value) => !import_lodash.default.isUndefined(value)
566
+ );
567
+ const stepParams = {
568
+ fieldSettings: {
569
+ init: initPayload
570
+ }
571
+ };
572
+ if (params.filterFormInit) {
573
+ stepParams.filterFormItemSettings = {
574
+ init: params.filterFormInit
575
+ };
576
+ }
577
+ return {
578
+ wrapperUid,
579
+ innerUid,
580
+ model: {
581
+ uid: wrapperUid,
582
+ use: params.wrapperUse,
583
+ props: import_lodash.default.cloneDeep(params.wrapperProps || {}),
584
+ stepParams,
585
+ subModels: {
586
+ field: {
587
+ uid: innerUid,
588
+ use: params.fieldUse,
589
+ props: import_lodash.default.cloneDeep(params.fieldProps || {}),
590
+ stepParams: import_lodash.default.merge(
591
+ {},
592
+ fieldDefaults.stepParams || {},
593
+ import_lodash.default.cloneDeep({
594
+ fieldSettings: {
595
+ init: initPayload
596
+ }
597
+ })
598
+ )
599
+ }
600
+ }
601
+ }
602
+ };
603
+ }
604
+ function buildStandaloneFieldNode(options) {
605
+ const defaults = getStandaloneFieldDefaults(options.use);
606
+ return {
607
+ uid: options.uid || (0, import_utils.uid)(),
608
+ use: options.use,
609
+ props: import_lodash.default.merge({}, import_lodash.default.cloneDeep(defaults.props || {}), import_lodash.default.cloneDeep(options.props || {})),
610
+ decoratorProps: import_lodash.default.merge({}, import_lodash.default.cloneDeep(defaults.decoratorProps || {}), import_lodash.default.cloneDeep(options.decoratorProps || {})),
611
+ stepParams: import_lodash.default.merge({}, import_lodash.default.cloneDeep(defaults.stepParams || {}), import_lodash.default.cloneDeep(options.stepParams || {}))
612
+ };
613
+ }
614
+ function buildActionTree(options) {
615
+ var _a;
616
+ const catalogItem = (0, import_catalog.resolveSupportedActionCatalogItem)(
617
+ {
618
+ type: options.type,
619
+ use: options.use,
620
+ containerUse: options.containerUse
621
+ },
622
+ {
623
+ requireCreateSupported: true
624
+ }
625
+ );
626
+ const use = catalogItem.use;
627
+ const defaults = buildActionDefaults({
628
+ use,
629
+ catalogItem,
630
+ containerUse: options.containerUse,
631
+ resourceInit: options.resourceInit
632
+ });
633
+ const props = import_lodash.default.merge({}, import_lodash.default.cloneDeep(defaults.props || {}), import_lodash.default.cloneDeep(options.props || {}));
634
+ const stepParams = import_lodash.default.merge({}, import_lodash.default.cloneDeep(defaults.stepParams || {}), import_lodash.default.cloneDeep(options.stepParams || {}));
635
+ if (import_lodash.default.isPlainObject((_a = stepParams == null ? void 0 : stepParams.buttonSettings) == null ? void 0 : _a.general)) {
636
+ stepParams.buttonSettings.general = import_lodash.default.merge({}, stepParams.buttonSettings.general, pickButtonGeneralProps(props));
637
+ }
638
+ return {
639
+ use,
640
+ props,
641
+ decoratorProps: import_lodash.default.merge({}, import_lodash.default.cloneDeep(defaults.decoratorProps || {}), import_lodash.default.cloneDeep(options.decoratorProps || {})),
642
+ stepParams,
643
+ flowRegistry: import_lodash.default.merge({}, import_lodash.default.cloneDeep(defaults.flowRegistry || {}), import_lodash.default.cloneDeep(options.flowRegistry || {})),
644
+ ...defaults.subModels ? { subModels: import_lodash.default.cloneDeep(defaults.subModels) } : {}
645
+ };
646
+ }
647
+ function buildCanonicalTableActionsColumnNode(options = {}) {
648
+ return {
649
+ uid: options.uid || (0, import_utils.uid)(),
650
+ use: "TableActionsColumnModel",
651
+ props: import_lodash.default.cloneDeep(options.props || {}),
652
+ decoratorProps: import_lodash.default.cloneDeep(options.decoratorProps || {}),
653
+ stepParams: import_lodash.default.merge(
654
+ {},
655
+ {
656
+ tableColumnSettings: {
657
+ title: {
658
+ title: '{{t("Actions")}}'
659
+ }
660
+ }
661
+ },
662
+ import_lodash.default.cloneDeep(options.stepParams || {})
663
+ ),
664
+ flowRegistry: import_lodash.default.cloneDeep(options.flowRegistry || {})
665
+ };
666
+ }
667
+ function pickButtonGeneralProps(props) {
668
+ return import_lodash.default.pickBy(
669
+ import_lodash.default.pick(props || {}, ["title", "tooltip", "icon", "type", "danger", "color"]),
670
+ (value) => !import_lodash.default.isUndefined(value)
671
+ );
672
+ }
673
+ function assignClientKeysToUids(spec, clientKeyToUid) {
674
+ const next = import_lodash.default.cloneDeep(spec);
675
+ const walk = (node) => {
676
+ if (!node.uid) {
677
+ node.uid = (0, import_utils.uid)();
678
+ }
679
+ if (node.clientKey) {
680
+ clientKeyToUid[node.clientKey] = node.uid;
681
+ }
682
+ Object.values(node.subModels || {}).forEach((value) => {
683
+ import_lodash.default.castArray(value).forEach((child) => walk(child));
684
+ });
685
+ };
686
+ walk(next);
687
+ return next;
688
+ }
689
+ function buildActionDefaults(options) {
690
+ var _a, _b, _c;
691
+ const approvalDefaults = (0, import_approval.buildApprovalActionDefaults)(options.use);
692
+ const readonlyCalendarAction = CALENDAR_READONLY_ACTION_MODEL_USES.has(options.use);
693
+ const props = import_lodash.default.merge(
694
+ {},
695
+ inferActionDefaultProps(options.use, options.catalogItem.scope),
696
+ (approvalDefaults == null ? void 0 : approvalDefaults.props) || {}
697
+ );
698
+ const normalizedProps = applyContainerActionStyle(props, options.containerUse);
699
+ const stepParams = import_lodash.default.merge(
700
+ {},
701
+ import_lodash.default.cloneDeep((approvalDefaults == null ? void 0 : approvalDefaults.stepParams) || {}),
702
+ readonlyCalendarAction ? {} : {
703
+ buttonSettings: {
704
+ general: pickButtonGeneralProps(normalizedProps)
705
+ }
706
+ }
707
+ );
708
+ const subModels = import_lodash.default.cloneDeep((approvalDefaults == null ? void 0 : approvalDefaults.subModels) || {});
709
+ if (approvalDefaults) {
710
+ return {
711
+ props: normalizedProps,
712
+ stepParams,
713
+ ...Object.keys(subModels).length ? { subModels } : {}
714
+ };
715
+ }
716
+ if ([
717
+ "AddNewActionModel",
718
+ "ViewActionModel",
719
+ "EditActionModel",
720
+ "PopupCollectionActionModel",
721
+ "DuplicateActionModel",
722
+ "AddChildActionModel",
723
+ "MailSendActionModel"
724
+ ].includes(options.use)) {
725
+ const popupSourceId = inferPopupActionSourceId(options.resourceInit);
726
+ stepParams.popupSettings = {
727
+ openView: {
728
+ mode: "drawer",
729
+ size: "medium",
730
+ pageModelClass: "ChildPageModel",
731
+ ...((_a = options.resourceInit) == null ? void 0 : _a.dataSourceKey) ? { dataSourceKey: options.resourceInit.dataSourceKey } : {},
732
+ ...((_b = options.resourceInit) == null ? void 0 : _b.collectionName) ? { collectionName: options.resourceInit.collectionName } : {},
733
+ ...((_c = options.resourceInit) == null ? void 0 : _c.associationName) ? { associationName: options.resourceInit.associationName } : {},
734
+ ...popupSourceId ? { sourceId: popupSourceId } : {}
735
+ }
736
+ };
737
+ }
738
+ if (options.use === "DeleteActionModel" || options.use === "BulkDeleteActionModel") {
739
+ stepParams.deleteSettings = {
740
+ confirm: {
741
+ enable: true,
742
+ title: '{{t("Delete record")}}',
743
+ content: '{{t("Are you sure you want to delete it?")}}'
744
+ }
745
+ };
746
+ }
747
+ if (options.use === "FormSubmitActionModel") {
748
+ stepParams.submitSettings = {
749
+ confirm: {
750
+ enable: false,
751
+ title: '{{t("Submit record")}}',
752
+ content: '{{t("Are you sure you want to save it?")}}'
753
+ }
754
+ };
755
+ }
756
+ if (["UpdateRecordActionModel", "BulkUpdateActionModel"].includes(options.use)) {
757
+ stepParams.assignSettings = {
758
+ confirm: {
759
+ enable: false,
760
+ title: options.use === "BulkUpdateActionModel" ? '{{t("Bulk update")}}' : '{{t("Perform the Update record")}}',
761
+ content: '{{t("Are you sure you want to perform the Update record action?")}}'
762
+ },
763
+ assignFieldValues: {
764
+ assignedValues: {}
765
+ }
766
+ };
767
+ stepParams.apply = {
768
+ apply: {
769
+ assignedValues: {}
770
+ }
771
+ };
772
+ subModels.assignForm = {
773
+ uid: (0, import_utils.uid)(),
774
+ use: "AssignFormModel",
775
+ stepParams: {
776
+ resourceSettings: {
777
+ init: import_lodash.default.cloneDeep(options.resourceInit || {})
778
+ }
779
+ },
780
+ subModels: {
781
+ grid: {
782
+ uid: (0, import_utils.uid)(),
783
+ use: "AssignFormGridModel"
784
+ }
785
+ }
786
+ };
787
+ }
788
+ if (JS_ACTION_DEFAULT_CODE_BY_USE[options.use] !== void 0) {
789
+ stepParams.clickSettings = buildRunJsStepParams(JS_ACTION_DEFAULT_CODE_BY_USE[options.use]);
790
+ }
791
+ return {
792
+ props: normalizedProps,
793
+ stepParams,
794
+ ...Object.keys(subModels).length ? { subModels } : {}
795
+ };
796
+ }
797
+ function inferPopupActionSourceId(resourceInit) {
798
+ if (!(resourceInit == null ? void 0 : resourceInit.associationName)) {
799
+ return void 0;
800
+ }
801
+ const sourceId = typeof (resourceInit == null ? void 0 : resourceInit.sourceId) === "string" ? resourceInit.sourceId.trim() : resourceInit == null ? void 0 : resourceInit.sourceId;
802
+ if (!sourceId) {
803
+ return void 0;
804
+ }
805
+ if (sourceId === "{{ctx.view.inputArgs.filterByTk}}") {
806
+ return "{{ctx.view.inputArgs.sourceId}}";
807
+ }
808
+ return sourceId;
809
+ }
810
+ function inferActionDefaultProps(use, scope) {
811
+ const map = {
812
+ AddNewActionModel: {
813
+ type: "primary",
814
+ title: '{{t("Add new")}}',
815
+ icon: "PlusOutlined"
816
+ },
817
+ ViewActionModel: {
818
+ type: "link",
819
+ title: '{{t("View")}}',
820
+ icon: "EyeOutlined"
821
+ },
822
+ EditActionModel: {
823
+ title: '{{t("Edit")}}',
824
+ icon: "EditOutlined"
825
+ },
826
+ PopupCollectionActionModel: {
827
+ title: '{{t("Popup")}}',
828
+ icon: "ExportOutlined"
829
+ },
830
+ DeleteActionModel: {
831
+ type: "link",
832
+ title: '{{t("Delete")}}',
833
+ icon: "DeleteOutlined"
834
+ },
835
+ UpdateRecordActionModel: {
836
+ type: "link",
837
+ title: '{{t("Update record")}}',
838
+ icon: "EditOutlined"
839
+ },
840
+ BulkUpdateActionModel: {
841
+ title: '{{t("Bulk update")}}',
842
+ icon: "EditOutlined"
843
+ },
844
+ FilterActionModel: {
845
+ title: '{{t("Filter")}}',
846
+ icon: "FilterOutlined"
847
+ },
848
+ RefreshActionModel: {
849
+ title: '{{t("Refresh")}}',
850
+ icon: "ReloadOutlined"
851
+ },
852
+ ExpandCollapseActionModel: {
853
+ icon: "DownOutlined"
854
+ },
855
+ BulkDeleteActionModel: {
856
+ title: '{{t("Delete")}}',
857
+ icon: "DeleteOutlined"
858
+ },
859
+ BulkEditActionModel: {
860
+ title: '{{t("Bulk edit")}}',
861
+ icon: "EditOutlined"
862
+ },
863
+ ExportActionModel: {
864
+ title: '{{t("Export")}}',
865
+ icon: "DownloadOutlined"
866
+ },
867
+ ExportAttachmentActionModel: {
868
+ title: '{{t("Export attachments")}}',
869
+ icon: "DownloadOutlined"
870
+ },
871
+ ImportActionModel: {
872
+ title: '{{t("Import")}}',
873
+ icon: "UploadOutlined"
874
+ },
875
+ LinkActionModel: {
876
+ type: "link",
877
+ title: '{{t("Link")}}'
878
+ },
879
+ UploadActionModel: {
880
+ title: '{{t("Upload")}}',
881
+ icon: "UploadOutlined"
882
+ },
883
+ DuplicateActionModel: {
884
+ type: "link",
885
+ title: '{{t("Duplicate")}}',
886
+ icon: "CopyOutlined"
887
+ },
888
+ AddChildActionModel: {
889
+ type: "link",
890
+ title: '{{t("Add child")}}',
891
+ icon: "PlusOutlined"
892
+ },
893
+ TemplatePrintCollectionActionModel: {
894
+ title: '{{t("Template print", { ns: "@nocobase/plugin-action-template-print" })}}',
895
+ icon: "PrinterOutlined"
896
+ },
897
+ TemplatePrintRecordActionModel: {
898
+ type: "link",
899
+ title: '{{t("Template print", { ns: "@nocobase/plugin-action-template-print" })}}',
900
+ icon: "PrinterOutlined"
901
+ },
902
+ CollectionTriggerWorkflowActionModel: {
903
+ title: '{{t("Trigger workflow", { ns: "@nocobase/plugin-workflow-custom-action-trigger" })}}',
904
+ icon: "PlayCircleOutlined"
905
+ },
906
+ RecordTriggerWorkflowActionModel: {
907
+ type: "link",
908
+ title: '{{t("Trigger workflow", { ns: "@nocobase/plugin-workflow-custom-action-trigger" })}}',
909
+ icon: "PlayCircleOutlined"
910
+ },
911
+ FormTriggerWorkflowActionModel: {
912
+ title: '{{t("Trigger workflow", { ns: "@nocobase/plugin-workflow-custom-action-trigger" })}}',
913
+ icon: "PlayCircleOutlined"
914
+ },
915
+ WorkbenchTriggerWorkflowActionModel: {
916
+ title: '{{t("Trigger global workflow", { ns: "@nocobase/plugin-workflow-custom-action-trigger" })}}',
917
+ icon: "PlayCircleOutlined"
918
+ },
919
+ MailSendActionModel: {
920
+ title: '{{t("Compose email", { ns: ["@nocobase/plugin-email-manager", "client"] })}}',
921
+ icon: "MailOutlined"
922
+ },
923
+ FormSubmitActionModel: {
924
+ title: '{{t("Submit")}}',
925
+ type: "primary",
926
+ htmlType: "submit"
927
+ },
928
+ FilterFormSubmitActionModel: {
929
+ title: '{{t("Filter")}}',
930
+ type: "primary"
931
+ },
932
+ FilterFormResetActionModel: {
933
+ title: '{{t("Reset")}}'
934
+ },
935
+ FilterFormCollapseActionModel: {
936
+ type: "link",
937
+ title: '{{t("Collapse button")}}'
938
+ },
939
+ CalendarTodayActionModel: {
940
+ type: "default",
941
+ title: '{{t("Today", { ns: "calendar" })}}'
942
+ },
943
+ CalendarNavActionModel: {},
944
+ CalendarTitleActionModel: {},
945
+ CalendarViewSelectActionModel: {},
946
+ JSCollectionActionModel: {
947
+ title: '{{t("JS action")}}',
948
+ icon: "JavaScriptOutlined"
949
+ },
950
+ JSRecordActionModel: {
951
+ type: "link",
952
+ title: '{{t("JS action")}}',
953
+ icon: "JavaScriptOutlined"
954
+ },
955
+ JSFormActionModel: {
956
+ title: '{{t("JS action")}}',
957
+ icon: "JavaScriptOutlined"
958
+ },
959
+ JSItemActionModel: {
960
+ title: '{{t("JS item")}}',
961
+ icon: "JavaScriptOutlined"
962
+ },
963
+ FilterFormJSActionModel: {
964
+ title: '{{t("JS action")}}',
965
+ icon: "JavaScriptOutlined"
966
+ },
967
+ JSActionModel: {
968
+ type: "default",
969
+ title: '{{t("JS action")}}',
970
+ icon: "JavaScriptOutlined"
971
+ }
972
+ };
973
+ return import_lodash.default.cloneDeep(
974
+ map[use] || {
975
+ title: humanizeActionTitle(use),
976
+ ...scope === "record" ? { type: "link" } : { type: "default" }
977
+ }
978
+ );
979
+ }
980
+ function applyContainerActionStyle(props, containerUse) {
981
+ if (containerUse === "TableActionsColumnModel") {
982
+ return {
983
+ ...props,
984
+ type: "link",
985
+ icon: null
986
+ };
987
+ }
988
+ if (containerUse === "DetailsBlockModel") {
989
+ return {
990
+ ...props,
991
+ type: "default"
992
+ };
993
+ }
994
+ return props;
995
+ }
996
+ function buildBlockDefaults(use) {
997
+ if (use === "JSBlockModel") {
998
+ return {
999
+ stepParams: {
1000
+ jsSettings: buildRunJsStepParams(JS_BLOCK_DEFAULT_CODE)
1001
+ }
1002
+ };
1003
+ }
1004
+ if (use === "ChartBlockModel") {
1005
+ return {
1006
+ stepParams: {
1007
+ chartSettings: {
1008
+ configure: {
1009
+ query: {
1010
+ mode: "builder"
1011
+ },
1012
+ chart: {
1013
+ option: {
1014
+ mode: "basic"
1015
+ }
1016
+ }
1017
+ }
1018
+ }
1019
+ }
1020
+ };
1021
+ }
1022
+ if (use === "CalendarBlockModel") {
1023
+ return {
1024
+ props: {
1025
+ fieldNames: {
1026
+ id: "id"
1027
+ },
1028
+ defaultView: "month",
1029
+ enableQuickCreateEvent: true,
1030
+ weekStart: 1
1031
+ }
1032
+ };
1033
+ }
1034
+ return {};
1035
+ }
1036
+ function getStandaloneFieldDefaults(use) {
1037
+ switch (use) {
1038
+ case "JSFieldModel":
1039
+ return {
1040
+ stepParams: {
1041
+ jsSettings: buildRunJsStepParams(JS_FIELD_DEFAULT_CODE)
1042
+ }
1043
+ };
1044
+ case "JSEditableFieldModel":
1045
+ return {
1046
+ stepParams: {
1047
+ jsSettings: buildRunJsStepParams(JS_EDITABLE_FIELD_DEFAULT_CODE)
1048
+ }
1049
+ };
1050
+ case "JSColumnModel":
1051
+ return {
1052
+ props: {
1053
+ title: '{{t("JS column")}}'
1054
+ },
1055
+ stepParams: {
1056
+ tableColumnSettings: {
1057
+ title: {
1058
+ title: '{{t("JS column")}}'
1059
+ }
1060
+ },
1061
+ jsSettings: buildRunJsStepParams(JS_COLUMN_DEFAULT_CODE)
1062
+ }
1063
+ };
1064
+ case "JSItemModel":
1065
+ return {
1066
+ stepParams: {
1067
+ jsSettings: buildRunJsStepParams(JS_ITEM_DEFAULT_CODE)
1068
+ }
1069
+ };
1070
+ case "DividerItemModel":
1071
+ return {
1072
+ props: {
1073
+ label: '{{t("Divider")}}',
1074
+ orientation: "left"
1075
+ }
1076
+ };
1077
+ default:
1078
+ return {};
1079
+ }
1080
+ }
1081
+ function humanizeActionTitle(use) {
1082
+ const normalized = String(use || "").replace(/ActionModel$/, "").replace(/(Collection|Record|Form|Workbench)$/, "");
1083
+ const title = import_lodash.default.startCase(normalized).replace(/\bJs\b/g, "JS").trim() || "Action";
1084
+ return `{{t(${JSON.stringify(title)})}}`;
1085
+ }
1086
+ // Annotate the CommonJS export names for ESM import in node:
1087
+ 0 && (module.exports = {
1088
+ assignClientKeysToUids,
1089
+ buildActionTree,
1090
+ buildBlockTree,
1091
+ buildCanonicalTableActionsColumnNode,
1092
+ buildFieldTree,
1093
+ buildPersistedRootPageModel,
1094
+ buildPopupPageTree,
1095
+ buildStandaloneFieldNode,
1096
+ buildSyntheticRootPageTabModel
1097
+ });