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

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