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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/LICENSE +201 -661
  2. package/README.md +79 -9
  3. package/dist/ai/ai-employees/nathan/index.d.ts +10 -0
  4. package/dist/ai/ai-employees/nathan/index.js +42 -0
  5. package/dist/ai/ai-employees/nathan/prompt.md +168 -0
  6. package/dist/ai/ai-employees/nathan/skills/frontend-developer/SKILLS.md +86 -0
  7. package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextApis.js +2 -2
  8. package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextEnvs.js +2 -2
  9. package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextVars.js +2 -2
  10. package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/lintAndTestJS.js +6 -4
  11. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/patchJSCode.d.ts +10 -0
  12. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/patchJSCode.js +65 -0
  13. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/readJSCode.d.ts +10 -0
  14. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/readJSCode.js +61 -0
  15. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/writeJSCode.d.ts +10 -0
  16. package/dist/ai/ai-employees/nathan/skills/frontend-developer/tools/writeJSCode.js +65 -0
  17. package/dist/ai/docs/runjs/context/block-model.md +35 -35
  18. package/dist/ai/docs/runjs/context/collection-field.md +53 -51
  19. package/dist/ai/docs/runjs/context/collection.md +39 -39
  20. package/dist/ai/docs/runjs/context/data-source-manager.md +40 -30
  21. package/dist/ai/docs/runjs/context/data-source.md +52 -44
  22. package/dist/ai/docs/runjs/context/element.md +44 -38
  23. package/dist/ai/docs/runjs/context/exit-all.md +37 -35
  24. package/dist/ai/docs/runjs/context/exit.md +38 -35
  25. package/dist/ai/docs/runjs/context/filter-manager.md +36 -30
  26. package/dist/ai/docs/runjs/context/form.md +57 -57
  27. package/dist/ai/docs/runjs/context/get-model.md +22 -21
  28. package/dist/ai/docs/runjs/context/get-value.md +20 -19
  29. package/dist/ai/docs/runjs/context/get-var.md +61 -55
  30. package/dist/ai/docs/runjs/context/i18n.md +17 -14
  31. package/dist/ai/docs/runjs/context/import-async.md +333 -45
  32. package/dist/ai/docs/runjs/context/init-resource.md +20 -20
  33. package/dist/ai/docs/runjs/context/libs.md +31 -31
  34. package/dist/ai/docs/runjs/context/location.md +34 -31
  35. package/dist/ai/docs/runjs/context/logger.md +41 -40
  36. package/dist/ai/docs/runjs/context/make-resource.md +27 -26
  37. package/dist/ai/docs/runjs/context/message.md +42 -41
  38. package/dist/ai/docs/runjs/context/modal.md +44 -44
  39. package/dist/ai/docs/runjs/context/model.md +36 -33
  40. package/dist/ai/docs/runjs/context/notification.md +41 -40
  41. package/dist/ai/docs/runjs/context/off.md +14 -14
  42. package/dist/ai/docs/runjs/context/on.md +30 -29
  43. package/dist/ai/docs/runjs/context/open-view.md +40 -40
  44. package/dist/ai/docs/runjs/context/render.md +37 -32
  45. package/dist/ai/docs/runjs/context/request.md +46 -45
  46. package/dist/ai/docs/runjs/context/require-async.md +28 -25
  47. package/dist/ai/docs/runjs/context/resource.md +34 -34
  48. package/dist/ai/docs/runjs/context/route.md +36 -34
  49. package/dist/ai/docs/runjs/context/router.md +43 -31
  50. package/dist/ai/docs/runjs/context/set-value.md +18 -17
  51. package/dist/ai/docs/runjs/context/sql.md +7 -15
  52. package/dist/ai/docs/runjs/context/t.md +20 -17
  53. package/dist/ai/docs/runjs/context/view.md +49 -46
  54. package/dist/ai/docs/runjs/document.md +1 -0
  55. package/dist/ai/docs/runjs/import-modules.md +32 -32
  56. package/dist/ai/docs/runjs/index.md +13 -13
  57. package/dist/ai/docs/runjs/jsx.md +19 -19
  58. package/dist/ai/docs/runjs/model/form-block-model.md +1 -3
  59. package/dist/ai/docs/runjs/render.md +15 -15
  60. package/dist/ai/docs/runjs/resource/api-resource.md +53 -53
  61. package/dist/ai/docs/runjs/resource/multi-record-resource.md +64 -64
  62. package/dist/ai/docs/runjs/resource/single-record-resource.md +55 -55
  63. package/dist/ai/docs/runjs/resource/sql-resource.md +57 -57
  64. package/dist/ai/docs/runjs/window.md +5 -5
  65. package/dist/client/index.js +1 -1
  66. package/dist/externalVersion.js +12 -11
  67. package/dist/locale/en-US.json +1 -0
  68. package/dist/locale/index.d.ts +2 -0
  69. package/dist/locale/zh-CN.json +1 -0
  70. package/dist/node_modules/ses/dist/ses.cjs +1 -1
  71. package/dist/node_modules/ses/package.json +1 -1
  72. package/dist/node_modules/zod/index.cjs +1 -1
  73. package/dist/node_modules/zod/package.json +1 -1
  74. package/dist/server/collections/flowsql.js +1 -0
  75. package/dist/server/flow-surfaces/action-scope.d.ts +39 -0
  76. package/dist/server/flow-surfaces/action-scope.js +156 -0
  77. package/dist/server/flow-surfaces/apply/compiler.d.ts +13 -0
  78. package/dist/server/flow-surfaces/apply/compiler.js +971 -0
  79. package/dist/server/flow-surfaces/apply/layout.d.ts +34 -0
  80. package/dist/server/flow-surfaces/apply/layout.js +175 -0
  81. package/dist/server/flow-surfaces/apply/matching.d.ts +16 -0
  82. package/dist/server/flow-surfaces/apply/matching.js +181 -0
  83. package/dist/server/flow-surfaces/approval/blueprint-service.d.ts +84 -0
  84. package/dist/server/flow-surfaces/approval/blueprint-service.js +589 -0
  85. package/dist/server/flow-surfaces/approval/blueprint.d.ts +21 -0
  86. package/dist/server/flow-surfaces/approval/blueprint.js +187 -0
  87. package/dist/server/flow-surfaces/approval/builder.d.ts +225 -0
  88. package/dist/server/flow-surfaces/approval/builder.js +384 -0
  89. package/dist/server/flow-surfaces/approval/catalog-specs.d.ts +33 -0
  90. package/dist/server/flow-surfaces/approval/catalog-specs.js +156 -0
  91. package/dist/server/flow-surfaces/approval/index.d.ts +14 -0
  92. package/dist/server/flow-surfaces/approval/index.js +40 -0
  93. package/dist/server/flow-surfaces/approval/runtime-config.d.ts +44 -0
  94. package/dist/server/flow-surfaces/approval/runtime-config.js +299 -0
  95. package/dist/server/flow-surfaces/approval/semantic-use.d.ts +23 -0
  96. package/dist/server/flow-surfaces/approval/semantic-use.js +155 -0
  97. package/dist/server/flow-surfaces/association-interfaces.d.ts +10 -0
  98. package/dist/server/flow-surfaces/association-interfaces.js +39 -0
  99. package/dist/server/flow-surfaces/association-title-field.d.ts +20 -0
  100. package/dist/server/flow-surfaces/association-title-field.js +192 -0
  101. package/dist/server/flow-surfaces/blueprint/compile-blocks.d.ts +15 -0
  102. package/dist/server/flow-surfaces/blueprint/compile-blocks.js +1251 -0
  103. package/dist/server/flow-surfaces/blueprint/compile-plan.d.ts +14 -0
  104. package/dist/server/flow-surfaces/blueprint/compile-plan.js +308 -0
  105. package/dist/server/flow-surfaces/blueprint/compile-reaction.d.ts +11 -0
  106. package/dist/server/flow-surfaces/blueprint/compile-reaction.js +72 -0
  107. package/dist/server/flow-surfaces/blueprint/defaults.d.ts +26 -0
  108. package/dist/server/flow-surfaces/blueprint/defaults.js +133 -0
  109. package/dist/server/flow-surfaces/blueprint/index.d.ts +12 -0
  110. package/dist/server/flow-surfaces/blueprint/index.js +44 -0
  111. package/dist/server/flow-surfaces/blueprint/normalize-document.d.ts +10 -0
  112. package/dist/server/flow-surfaces/blueprint/normalize-document.js +407 -0
  113. package/dist/server/flow-surfaces/blueprint/private-utils.d.ts +25 -0
  114. package/dist/server/flow-surfaces/blueprint/private-utils.js +179 -0
  115. package/dist/server/flow-surfaces/blueprint/public-types.d.ts +201 -0
  116. package/dist/server/flow-surfaces/blueprint/public-types.js +24 -0
  117. package/dist/server/flow-surfaces/builder.d.ts +238 -0
  118. package/dist/server/flow-surfaces/builder.js +1261 -0
  119. package/dist/server/flow-surfaces/catalog-smart.d.ts +18 -0
  120. package/dist/server/flow-surfaces/catalog-smart.js +239 -0
  121. package/dist/server/flow-surfaces/catalog-smart.projector.d.ts +15 -0
  122. package/dist/server/flow-surfaces/catalog-smart.projector.js +157 -0
  123. package/dist/server/flow-surfaces/catalog-smart.types.d.ts +99 -0
  124. package/dist/server/flow-surfaces/catalog-smart.types.js +24 -0
  125. package/dist/server/flow-surfaces/catalog.d.ts +79 -0
  126. package/dist/server/flow-surfaces/catalog.js +3743 -0
  127. package/dist/server/flow-surfaces/chart-config.d.ts +121 -0
  128. package/dist/server/flow-surfaces/chart-config.js +1394 -0
  129. package/dist/server/flow-surfaces/compose-compiler.d.ts +115 -0
  130. package/dist/server/flow-surfaces/compose-compiler.js +174 -0
  131. package/dist/server/flow-surfaces/compose-runtime.d.ts +94 -0
  132. package/dist/server/flow-surfaces/compose-runtime.js +376 -0
  133. package/dist/server/flow-surfaces/configure-options.d.ts +23 -0
  134. package/dist/server/flow-surfaces/configure-options.js +904 -0
  135. package/dist/server/flow-surfaces/constants.d.ts +351 -0
  136. package/dist/server/flow-surfaces/constants.js +104 -0
  137. package/dist/server/flow-surfaces/context.d.ts +72 -0
  138. package/dist/server/flow-surfaces/context.js +556 -0
  139. package/dist/server/flow-surfaces/contract-guard.d.ts +19 -0
  140. package/dist/server/flow-surfaces/contract-guard.js +410 -0
  141. package/dist/server/flow-surfaces/core-field-default-bindings.d.ts +12 -0
  142. package/dist/server/flow-surfaces/core-field-default-bindings.js +157 -0
  143. package/dist/server/flow-surfaces/default-action-popup.d.ts +63 -0
  144. package/dist/server/flow-surfaces/default-action-popup.js +322 -0
  145. package/dist/server/flow-surfaces/default-block-actions.d.ts +32 -0
  146. package/dist/server/flow-surfaces/default-block-actions.js +210 -0
  147. package/dist/server/flow-surfaces/errors.d.ts +47 -0
  148. package/dist/server/flow-surfaces/errors.js +145 -0
  149. package/dist/server/flow-surfaces/executor.d.ts +23 -0
  150. package/dist/server/flow-surfaces/executor.js +132 -0
  151. package/dist/server/flow-surfaces/field-binding-registry.d.ts +24 -0
  152. package/dist/server/flow-surfaces/field-binding-registry.js +396 -0
  153. package/dist/server/flow-surfaces/field-semantics.d.ts +15 -0
  154. package/dist/server/flow-surfaces/field-semantics.js +84 -0
  155. package/dist/server/flow-surfaces/field-type-resolver.d.ts +45 -0
  156. package/dist/server/flow-surfaces/field-type-resolver.js +312 -0
  157. package/dist/server/flow-surfaces/filter-group.d.ts +15 -0
  158. package/dist/server/flow-surfaces/filter-group.js +94 -0
  159. package/dist/server/flow-surfaces/hidden-popup-calendar.d.ts +86 -0
  160. package/dist/server/flow-surfaces/hidden-popup-calendar.js +554 -0
  161. package/dist/server/flow-surfaces/hidden-popup-contract.d.ts +116 -0
  162. package/dist/server/flow-surfaces/hidden-popup-contract.js +611 -0
  163. package/dist/server/flow-surfaces/hidden-popup-kanban.d.ts +62 -0
  164. package/dist/server/flow-surfaces/hidden-popup-kanban.js +651 -0
  165. package/dist/server/flow-surfaces/index.d.ts +11 -0
  166. package/dist/server/flow-surfaces/index.js +302 -0
  167. package/dist/server/flow-surfaces/locator.d.ts +28 -0
  168. package/dist/server/flow-surfaces/locator.js +240 -0
  169. package/dist/server/flow-surfaces/node-use-sets.d.ts +15 -0
  170. package/dist/server/flow-surfaces/node-use-sets.js +135 -0
  171. package/dist/server/flow-surfaces/payload-shape.d.ts +9 -0
  172. package/dist/server/flow-surfaces/payload-shape.js +61 -0
  173. package/dist/server/flow-surfaces/placement.d.ts +33 -0
  174. package/dist/server/flow-surfaces/placement.js +199 -0
  175. package/dist/server/flow-surfaces/planning/action-specs.d.ts +179 -0
  176. package/dist/server/flow-surfaces/planning/action-specs.js +190 -0
  177. package/dist/server/flow-surfaces/planning/compiler.d.ts +37 -0
  178. package/dist/server/flow-surfaces/planning/compiler.js +376 -0
  179. package/dist/server/flow-surfaces/planning/context.d.ts +30 -0
  180. package/dist/server/flow-surfaces/planning/context.js +139 -0
  181. package/dist/server/flow-surfaces/planning/created-keys.d.ts +34 -0
  182. package/dist/server/flow-surfaces/planning/created-keys.js +375 -0
  183. package/dist/server/flow-surfaces/planning/key-kind.d.ts +11 -0
  184. package/dist/server/flow-surfaces/planning/key-kind.js +88 -0
  185. package/dist/server/flow-surfaces/planning/key-persistence.d.ts +34 -0
  186. package/dist/server/flow-surfaces/planning/key-persistence.js +148 -0
  187. package/dist/server/flow-surfaces/planning/key-registry.d.ts +40 -0
  188. package/dist/server/flow-surfaces/planning/key-registry.js +206 -0
  189. package/dist/server/flow-surfaces/planning/runtime.d.ts +37 -0
  190. package/dist/server/flow-surfaces/planning/runtime.js +259 -0
  191. package/dist/server/flow-surfaces/planning/step-link.d.ts +14 -0
  192. package/dist/server/flow-surfaces/planning/step-link.js +104 -0
  193. package/dist/server/flow-surfaces/planning/types.d.ts +55 -0
  194. package/dist/server/flow-surfaces/planning/types.js +24 -0
  195. package/dist/server/flow-surfaces/public-compatibility.d.ts +28 -0
  196. package/dist/server/flow-surfaces/public-compatibility.js +161 -0
  197. package/dist/server/flow-surfaces/public-data-surface-default-filter.d.ts +24 -0
  198. package/dist/server/flow-surfaces/public-data-surface-default-filter.js +152 -0
  199. package/dist/server/flow-surfaces/reaction/errors.d.ts +20 -0
  200. package/dist/server/flow-surfaces/reaction/errors.js +69 -0
  201. package/dist/server/flow-surfaces/reaction/field-value.d.ts +34 -0
  202. package/dist/server/flow-surfaces/reaction/field-value.js +181 -0
  203. package/dist/server/flow-surfaces/reaction/fingerprint.d.ts +16 -0
  204. package/dist/server/flow-surfaces/reaction/fingerprint.js +71 -0
  205. package/dist/server/flow-surfaces/reaction/linkage.d.ts +136 -0
  206. package/dist/server/flow-surfaces/reaction/linkage.js +882 -0
  207. package/dist/server/flow-surfaces/reaction/meta.d.ts +11 -0
  208. package/dist/server/flow-surfaces/reaction/meta.js +451 -0
  209. package/dist/server/flow-surfaces/reaction/registry.d.ts +156 -0
  210. package/dist/server/flow-surfaces/reaction/registry.js +206 -0
  211. package/dist/server/flow-surfaces/reaction/resolver.d.ts +22 -0
  212. package/dist/server/flow-surfaces/reaction/resolver.js +202 -0
  213. package/dist/server/flow-surfaces/reaction/types.d.ts +241 -0
  214. package/dist/server/flow-surfaces/reaction/types.js +24 -0
  215. package/dist/server/flow-surfaces/reaction/utils.d.ts +17 -0
  216. package/dist/server/flow-surfaces/reaction/utils.js +67 -0
  217. package/dist/server/flow-surfaces/reaction/value-expr.d.ts +15 -0
  218. package/dist/server/flow-surfaces/reaction/value-expr.js +209 -0
  219. package/dist/server/flow-surfaces/reference-guards.d.ts +19 -0
  220. package/dist/server/flow-surfaces/reference-guards.js +103 -0
  221. package/dist/server/flow-surfaces/route-sync.d.ts +50 -0
  222. package/dist/server/flow-surfaces/route-sync.js +393 -0
  223. package/dist/server/flow-surfaces/service-helpers.d.ts +42 -0
  224. package/dist/server/flow-surfaces/service-helpers.js +310 -0
  225. package/dist/server/flow-surfaces/service-utils.d.ts +120 -0
  226. package/dist/server/flow-surfaces/service-utils.js +878 -0
  227. package/dist/server/flow-surfaces/service.d.ts +896 -0
  228. package/dist/server/flow-surfaces/service.js +16248 -0
  229. package/dist/server/flow-surfaces/support-matrix.d.ts +31 -0
  230. package/dist/server/flow-surfaces/support-matrix.js +282 -0
  231. package/dist/server/flow-surfaces/surface-context.d.ts +52 -0
  232. package/dist/server/flow-surfaces/surface-context.js +440 -0
  233. package/dist/server/flow-surfaces/template-compatibility.d.ts +42 -0
  234. package/dist/server/flow-surfaces/template-compatibility.js +189 -0
  235. package/dist/server/flow-surfaces/template-display.d.ts +20 -0
  236. package/dist/server/flow-surfaces/template-display.js +289 -0
  237. package/dist/server/flow-surfaces/template-service-utils.d.ts +62 -0
  238. package/dist/server/flow-surfaces/template-service-utils.js +281 -0
  239. package/dist/server/flow-surfaces/types.d.ts +288 -0
  240. package/dist/server/flow-surfaces/types.js +24 -0
  241. package/dist/server/index.d.ts +1 -0
  242. package/dist/server/index.js +7 -2
  243. package/dist/server/migrations/20260508000000-remove-flow-model-options-runtime-uid.d.ts +13 -0
  244. package/dist/server/migrations/20260508000000-remove-flow-model-options-runtime-uid.js +67 -0
  245. package/dist/server/plugin.d.ts +0 -1
  246. package/dist/server/plugin.js +9 -34
  247. package/dist/server/repository.js +0 -5
  248. package/dist/server/variables/resolve.d.ts +21 -0
  249. package/dist/server/variables/resolve.js +79 -0
  250. package/dist/swagger/flow-surfaces.d.ts +6106 -0
  251. package/dist/swagger/flow-surfaces.examples.d.ts +1577 -0
  252. package/dist/swagger/flow-surfaces.examples.js +1816 -0
  253. package/dist/swagger/flow-surfaces.js +5375 -0
  254. package/dist/swagger/flow-surfaces.template-action-docs.d.ts +62 -0
  255. package/dist/swagger/flow-surfaces.template-action-docs.js +121 -0
  256. package/dist/swagger/flow-surfaces.template-schemas.d.ts +239 -0
  257. package/dist/swagger/flow-surfaces.template-schemas.js +255 -0
  258. package/dist/swagger/index.d.ts +6111 -0
  259. package/dist/swagger/index.js +50 -0
  260. package/package.json +3 -3
  261. /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextApis.d.ts +0 -0
  262. /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextEnvs.d.ts +0 -0
  263. /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/getContextVars.d.ts +0 -0
  264. /package/dist/ai/{tools → ai-employees/nathan/skills/frontend-developer/tools}/lintAndTestJS.d.ts +0 -0
@@ -0,0 +1,65 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var writeJSCode_exports = {};
28
+ __export(writeJSCode_exports, {
29
+ default: () => writeJSCode_default
30
+ });
31
+ module.exports = __toCommonJS(writeJSCode_exports);
32
+ var import_ai = require("@nocobase/ai");
33
+ var import_zod = require("zod");
34
+ var writeJSCode_default = (0, import_ai.defineTools)({
35
+ scope: "SPECIFIED",
36
+ execution: "frontend",
37
+ defaultPermission: "ALLOW",
38
+ introduction: {
39
+ title: `{{t("ai.tools.writeJSCode.title")}}`,
40
+ about: `{{t("ai.tools.writeJSCode.about")}}`
41
+ },
42
+ definition: {
43
+ name: "writeJSCode",
44
+ description: "Write complete JavaScript/JSX code into the current code editor. Use only when the editor is empty, the user asks for a complete replacement, or the change is a deliberate broad rewrite. For adding, modifying, fixing, or extending existing code, use patchJSCode instead.",
45
+ schema: import_zod.z.object({
46
+ code: import_zod.z.string().describe(
47
+ "The complete JavaScript/JSX code to write into the current editor. Do not use for small incremental changes to existing code."
48
+ )
49
+ })
50
+ },
51
+ invoke: async (ctx, _args, runtime) => {
52
+ const { toolCallResults } = ctx.action.params.values || {};
53
+ const { result } = (toolCallResults == null ? void 0 : toolCallResults.find((item) => item.id === runtime.toolCallId)) ?? {};
54
+ if (toolCallResults && result) {
55
+ return {
56
+ status: result.status ?? "error",
57
+ content: JSON.stringify(result.content ?? {})
58
+ };
59
+ }
60
+ return {
61
+ status: "error",
62
+ content: JSON.stringify({ success: false, message: "Write code failed: no result returned" })
63
+ };
64
+ }
65
+ });
@@ -1,49 +1,49 @@
1
1
  # ctx.blockModel
2
2
 
3
- The parent block model (BlockModel instance) that hosts the current JS field / JS block. In JSField, JSItem, JSColumn, etc., `ctx.blockModel` refers to the form block or table block that hosts the current JS logic; in a standalone JSBlock it may be `null` or the same as `ctx.model`.
3
+ The parent block model (BlockModel instance) where the current JS Field / JS Block is located. In scenarios such as JSField, JSItem, and JSColumn, `ctx.blockModel` points to the form block or table block carrying the current JS logic. In a standalone JSBlock, it may be `null` or the same as `ctx.model`.
4
4
 
5
- ## Use Cases
5
+ ## Scenarios
6
6
 
7
7
  | Scenario | Description |
8
- |----------|-------------|
9
- | **JSField** | Access parent form block's `form`, `collection`, `resource` for linkage or validation |
10
- | **JSItem** | Access parent table/form block's resource and collection in sub-table items |
11
- | **JSColumn** | Access parent table block's `resource` (e.g. `getSelectedRows`), `collection` |
12
- | **Form actions / event flow** | Use `form` for pre-submit validation, `resource` for refresh, etc. |
8
+ |------|------|
9
+ | **JSField** | Access the `form`, `collection`, and `resource` of the parent form block within a form field to implement linkage or validation. |
10
+ | **JSItem** | Access the resource and collection information of the parent table/form block within a sub-table item. |
11
+ | **JSColumn** | Access the `resource` (e.g., `getSelectedRows`) and `collection` of the parent table block within a table column. |
12
+ | **Form Actions / FlowEngine** | Access `form` for pre-submission validation, `resource` for refreshing, etc. |
13
13
 
14
- > Note: `ctx.blockModel` is only available in RunJS contexts that have a parent block; in a standalone JSBlock (no parent form/table) it may be `null`—check before use.
14
+ > Note: `ctx.blockModel` is only available in RunJS contexts where a parent block exists. In standalone JSBlocks (without a parent form/table), it may be `null`. It is recommended to perform a null check before use.
15
15
 
16
- ## Type
16
+ ## Type Definition
17
17
 
18
18
  ```ts
19
19
  blockModel: BlockModel | FormBlockModel | TableBlockModel | CollectionBlockModel | DataBlockModel | null;
20
20
  ```
21
21
 
22
- The exact type depends on the parent block: form blocks are usually `FormBlockModel` / `EditFormModel`, table blocks are usually `TableBlockModel`.
22
+ The specific type depends on the parent block type: form blocks are mostly `FormBlockModel` or `EditFormModel`, while table blocks are mostly `TableBlockModel`.
23
23
 
24
24
  ## Common Properties
25
25
 
26
26
  | Property | Type | Description |
27
- |----------|------|-------------|
28
- | `uid` | `string` | Block model unique id |
29
- | `collection` | `Collection` | Collection bound to the block |
30
- | `resource` | `Resource` | Resource instance (`SingleRecordResource` / `MultiRecordResource`, etc.) |
31
- | `form` | `FormInstance` | Form block: Ant Design Form instance (`getFieldsValue`, `validateFields`, `setFieldsValue`, etc.) |
32
- | `emitter` | `EventEmitter` | Event emitter; can listen to `formValuesChange`, `onFieldReset`, etc. |
27
+ |------|------|------|
28
+ | `uid` | `string` | Unique identifier of the block model. |
29
+ | `collection` | `Collection` | The collection bound to the current block. |
30
+ | `resource` | `Resource` | The resource instance used by the block (`SingleRecordResource` / `MultiRecordResource`, etc.). |
31
+ | `form` | `FormInstance` | Form Block: Ant Design Form instance, supporting `getFieldsValue`, `validateFields`, `setFieldsValue`, etc. |
32
+ | `emitter` | `EventEmitter` | Event emitter, used to listen for `formValuesChange`, `onFieldReset`, etc. |
33
33
 
34
- ## Relation to ctx.model, ctx.form
34
+ ## Relationship with ctx.model and ctx.form
35
35
 
36
- | Need | Recommended |
37
- |------|-------------|
38
- | **Parent block of current JS** | `ctx.blockModel` |
39
- | **Read/write form fields** | `ctx.form` (same as `ctx.blockModel?.form`; more convenient in form blocks) |
40
- | **Model for current execution context** | `ctx.model` (field model in JSField, block model in JSBlock) |
36
+ | Requirement | Recommended Usage |
37
+ |------|----------|
38
+ | **Parent block of the current JS** | `ctx.blockModel` |
39
+ | **Read/Write form fields** | `ctx.form` (equivalent to `ctx.blockModel?.form`, more convenient in form blocks) |
40
+ | **Model of the current execution context** | `ctx.model` (Field model in JSField, Block model in JSBlock) |
41
41
 
42
- In JSField, `ctx.model` is the field model and `ctx.blockModel` is the form/table block that hosts it; `ctx.form` is usually `ctx.blockModel.form`.
42
+ In a JSField, `ctx.model` is the field model, and `ctx.blockModel` is the form or table block carrying that field; `ctx.form` is typically `ctx.blockModel.form`.
43
43
 
44
44
  ## Examples
45
45
 
46
- ### Table: get selected rows and process
46
+ ### Table: Get selected rows and process
47
47
 
48
48
  ```ts
49
49
  const rows = ctx.blockModel?.resource?.getSelectedRows?.() || [];
@@ -53,7 +53,7 @@ if (rows.length === 0) {
53
53
  }
54
54
  ```
55
55
 
56
- ### Form: validate and refresh
56
+ ### Form Scenario: Validate and Refresh
57
57
 
58
58
  ```ts
59
59
  if (ctx.blockModel?.form) {
@@ -62,15 +62,15 @@ if (ctx.blockModel?.form) {
62
62
  }
63
63
  ```
64
64
 
65
- ### Listen to form changes
65
+ ### Listen for Form Changes
66
66
 
67
67
  ```ts
68
68
  ctx.blockModel?.emitter?.on?.('formValuesChange', (payload) => {
69
- // React to latest form values or re-render
69
+ // Implement linkage or re-rendering based on the latest form values
70
70
  });
71
71
  ```
72
72
 
73
- ### Trigger block re-render
73
+ ### Trigger Block Re-render
74
74
 
75
75
  ```ts
76
76
  ctx.blockModel?.rerender?.();
@@ -78,13 +78,13 @@ ctx.blockModel?.rerender?.();
78
78
 
79
79
  ## Notes
80
80
 
81
- - In a **standalone JSBlock** (no parent form/table), `ctx.blockModel` may be `null`; use optional chaining: `ctx.blockModel?.resource?.refresh?.()`.
82
- - In **JSField / JSItem / JSColumn**, `ctx.blockModel` is the form or table block that hosts the field; in **JSBlock**, it may be the block itself or an ancestor, depending on hierarchy.
83
- - `resource` exists only on data blocks; `form` exists only on form blocks; table blocks usually have no `form`.
81
+ - In a **standalone JSBlock** (without a parent form or table block), `ctx.blockModel` may be `null`. It is recommended to use optional chaining when accessing its properties: `ctx.blockModel?.resource?.refresh?.()`.
82
+ - In **JSField / JSItem / JSColumn**, `ctx.blockModel` refers to the form or table block carrying the current field. In a **JSBlock**, it may be itself or an upper-level block, depending on the actual hierarchy.
83
+ - `resource` only exists in data blocks; `form` only exists in form blocks. Table blocks typically do not have a `form`.
84
84
 
85
85
  ## Related
86
86
 
87
- - [ctx.model](./model.md): model for current execution context
88
- - [ctx.form](./form.md): form instance, common in form blocks
89
- - [ctx.resource](./resource.md): resource instance (same as `ctx.blockModel?.resource` when present)
90
- - [ctx.getModel()](./get-model.md): get another block model by uid
87
+ - [ctx.model](./model.md): The model of the current execution context.
88
+ - [ctx.form](./form.md): Form instance, commonly used in form blocks.
89
+ - [ctx.resource](./resource.md): Resource instance (equivalent to `ctx.blockModel?.resource`, use directly if available).
90
+ - [ctx.getModel()](./get-model.md): Get other block models by UID.
@@ -1,18 +1,18 @@
1
1
  # ctx.collectionField
2
2
 
3
- The collection field (CollectionField) instance for the current RunJS context; used to access field metadata, type, validation rules, and association info. Only present when the field is bound to a collection definition; custom/virtual fields may have `null`.
3
+ The `CollectionField` instance associated with the current RunJS execution context, used to access field metadata, types, validation rules, and association information. It only exists when the field is bound to a collection definition; custom/virtual fields may be `null`.
4
4
 
5
5
  ## Use Cases
6
6
 
7
7
  | Scenario | Description |
8
- |----------|-------------|
9
- | **JSField** | Use `interface`, `enum`, `targetCollection`, etc. for linkage or validation |
10
- | **JSItem** | Access metadata of the column’s field in sub-table items |
11
- | **JSColumn** | Choose render by `collectionField.interface`, or use `targetCollection` |
8
+ |------|------|
9
+ | **JSField** | Perform linkage or validation in form fields based on `interface`, `enum`, `targetCollection`, etc. |
10
+ | **JSItem** | Access metadata of the field corresponding to the current column in sub-table items. |
11
+ | **JSColumn** | Select rendering methods based on `collectionField.interface` or access `targetCollection` in table columns. |
12
12
 
13
- > Note: `ctx.collectionField` is only available when the field is bound to a collection; in standalone JSBlock or actions with no field binding it is usually `undefined`—check before use.
13
+ > Note: `ctx.collectionField` is only available when the field is bound to a Collection definition; it is usually `undefined` in scenarios like JSBlock independent blocks or action events without field binding. It is recommended to check for null values before use.
14
14
 
15
- ## Type
15
+ ## Type Definition
16
16
 
17
17
  ```ts
18
18
  collectionField: CollectionField | null | undefined;
@@ -21,46 +21,47 @@ collectionField: CollectionField | null | undefined;
21
21
  ## Common Properties
22
22
 
23
23
  | Property | Type | Description |
24
- |----------|------|-------------|
25
- | `name` | `string` | Field name (e.g. `status`, `userId`) |
26
- | `title` | `string` | Field title (i18n) |
27
- | `type` | `string` | Data type (`string`, `integer`, `belongsTo`, etc.) |
28
- | `interface` | `string` | UI type (`input`, `select`, `m2o`, `o2m`, `m2m`, etc.) |
29
- | `collection` | `Collection` | Field’s collection |
30
- | `targetCollection` | `Collection` | Target collection for association fields only |
31
- | `target` | `string` | Target collection name (association) |
32
- | `enum` | `array` | Enum options (select, radio, etc.) |
24
+ |------|------|------|
25
+ | `name` | `string` | Field name (e.g., `status`, `userId`) |
26
+ | `title` | `string` | Field title (including internationalization) |
27
+ | `type` | `string` | Field data type (`string`, `integer`, `belongsTo`, etc.) |
28
+ | `interface` | `string` | Field interface type (`input`, `select`, `m2o`, `o2m`, `m2m`, etc.) |
29
+ | `collection` | `Collection` | The collection the field belongs to |
30
+ | `targetCollection` | `Collection` | The target collection of the association field (only for association types) |
31
+ | `target` | `string` | Target collection name (for association fields) |
32
+ | `enum` | `array` | Enumeration options (select, radio, etc.) |
33
33
  | `defaultValue` | `any` | Default value |
34
- | `collectionName` | `string` | Collection name |
35
- | `foreignKey` | `string` | Foreign key (e.g. belongsTo) |
36
- | `sourceKey` | `string` | Source key (e.g. hasMany) |
37
- | `targetKey` | `string` | Target key |
38
- | `fullpath` | `string` | Full path (e.g. `main.users.status`) for API/variables |
39
- | `resourceName` | `string` | Resource name (e.g. `users.status`) |
40
- | `readonly` | `boolean` | Read-only |
41
- | `titleable` | `boolean` | Can be used as title |
42
- | `validation` | `object` | Validation config |
43
- | `uiSchema` | `object` | UI config |
44
- | `targetCollectionTitleField` | `CollectionField` | Title field of target collection (association) |
34
+ | `collectionName` | `string` | Name of the collection it belongs to |
35
+ | `foreignKey` | `string` | Foreign key field name (belongsTo, etc.) |
36
+ | `sourceKey` | `string` | Association source key (hasMany, etc.) |
37
+ | `targetKey` | `string` | Association target key |
38
+ | `fullpath` | `string` | Full path (e.g., `main.users.status`), used for API or variable references |
39
+ | `resourceName` | `string` | Resource name (e.g., `users.status`) |
40
+ | `readonly` | `boolean` | Whether it is read-only |
41
+ | `titleable` | `boolean` | Whether it can be displayed as a title |
42
+ | `validation` | `object` | Validation rule configuration |
43
+ | `uiSchema` | `object` | UI configuration |
44
+ | `targetCollectionTitleField` | `CollectionField` | The title field of the target collection (for association fields) |
45
45
 
46
46
  ## Common Methods
47
47
 
48
48
  | Method | Description |
49
- |--------|-------------|
50
- | `isAssociationField(): boolean` | Whether it is an association (belongsTo, hasMany, hasOne, belongsToMany, etc.) |
51
- | `isRelationshipField(): boolean` | Whether it is a relationship (o2o, m2o, o2m, m2m, etc.) |
52
- | `getComponentProps(): object` | Default props for the field component |
53
- | `getFields(): CollectionField[]` | Fields of target collection (association only) |
54
- | `getFilterOperators(): object[]` | Filter operators (e.g. `$eq`, `$ne`) |
49
+ |------|------|
50
+ | `isAssociationField(): boolean` | Whether it is an association field (belongsTo, hasMany, hasOne, belongsToMany, etc.) |
51
+ | `isRelationshipField(): boolean` | Whether it is a relationship field (including o2o, m2o, o2m, m2m, etc.) |
52
+ | `getComponentProps(): object` | Get the default props of the field component |
53
+ | `getFields(): CollectionField[]` | Get the field list of the target collection (association fields only) |
54
+ | `getFilterOperators(): object[]` | Get the filter operators supported by this field (e.g., `$eq`, `$ne`, etc.) |
55
55
 
56
56
  ## Examples
57
57
 
58
- ### Branch by field type
58
+ ### Branch rendering based on field type
59
59
 
60
60
  ```ts
61
61
  if (!ctx.collectionField) return null;
62
62
  const { interface: iface } = ctx.collectionField;
63
63
  if (['m2o', 'o2m', 'm2m'].includes(iface)) {
64
+ // Association field: display associated records
64
65
  const target = ctx.collectionField.targetCollection;
65
66
  // ...
66
67
  } else if (iface === 'select' || iface === 'radioGroup') {
@@ -69,24 +70,24 @@ if (['m2o', 'o2m', 'm2m'].includes(iface)) {
69
70
  }
70
71
  ```
71
72
 
72
- ### Check association and use target collection
73
+ ### Determine if it is an association field and access the target collection
73
74
 
74
75
  ```ts
75
76
  if (ctx.collectionField?.isAssociationField()) {
76
77
  const targetCol = ctx.collectionField.targetCollection;
77
78
  const titleField = targetCol?.titleCollectionField?.name;
78
- // ...
79
+ // Process according to the target collection structure
79
80
  }
80
81
  ```
81
82
 
82
- ### Get enum options
83
+ ### Get enumeration options
83
84
 
84
85
  ```ts
85
86
  const options = ctx.collectionField?.enum ?? [];
86
87
  const labels = options.map((o) => (typeof o === 'object' ? o.label : o));
87
88
  ```
88
89
 
89
- ### Conditional render by readonly
90
+ ### Conditional rendering based on read-only/view mode
90
91
 
91
92
  ```ts
92
93
  const { Input } = ctx.libs.antd;
@@ -97,34 +98,35 @@ if (ctx.collectionField?.readonly) {
97
98
  }
98
99
  ```
99
100
 
100
- ### Title field of target collection
101
+ ### Get the title field of the target collection
101
102
 
102
103
  ```ts
104
+ // When displaying an association field, use targetCollectionTitleField to get the title field name
103
105
  const titleField = ctx.collectionField?.targetCollectionTitleField;
104
106
  const titleKey = titleField?.name ?? 'title';
105
107
  const assocValue = ctx.getValue?.() ?? ctx.record?.[ctx.collectionField?.name];
106
108
  const label = assocValue?.[titleKey];
107
109
  ```
108
110
 
109
- ## Relation to ctx.collection
111
+ ## Relationship with ctx.collection
110
112
 
111
- | Need | Recommended |
112
- |------|-------------|
113
- | **Collection of current field** | `ctx.collectionField?.collection` or `ctx.collection` |
113
+ | Requirement | Recommended Usage |
114
+ |------|----------|
115
+ | **Current field's collection** | `ctx.collectionField?.collection` or `ctx.collection` |
114
116
  | **Field metadata (name, type, interface, enum, etc.)** | `ctx.collectionField` |
115
117
  | **Target collection** | `ctx.collectionField?.targetCollection` |
116
118
 
117
- `ctx.collection` is usually the block’s collection; `ctx.collectionField` is the field definition; they can differ in sub-tables and associations.
119
+ `ctx.collection` usually represents the collection bound to the current block; `ctx.collectionField` represents the definition of the current field in the collection. In scenarios like sub-tables or association fields, the two may differ.
118
120
 
119
121
  ## Notes
120
122
 
121
- - In **JSBlock**, **JSAction (no field binding)**, `ctx.collectionField` is usually `undefined`; use optional chaining.
122
- - Custom JS fields not bound to a collection field may have `ctx.collectionField` as `null`.
123
- - `targetCollection` exists only for association fields (m2o, o2m, m2m); `enum` only for select, radioGroup, etc.
123
+ - In scenarios such as **JSBlock** or **JSAction (without field binding)**, `ctx.collectionField` is usually `undefined`. It is recommended to use optional chaining before access.
124
+ - If a custom JS field is not bound to a collection field, `ctx.collectionField` may be `null`.
125
+ - `targetCollection` only exists for association type fields (e.g., m2o, o2m, m2m); `enum` only exists for fields with options like select or radioGroup.
124
126
 
125
127
  ## Related
126
128
 
127
- - [ctx.collection](./collection.md): collection for current context
128
- - [ctx.model](./model.md): model for current execution context
129
- - [ctx.blockModel](./block-model.md): parent block
130
- - [ctx.getValue()](./get-value.md), [ctx.setValue()](./set-value.md): read/write current field value
129
+ - [ctx.collection](./collection.md): Collection associated with the current context
130
+ - [ctx.model](./model.md): Model where the current execution context is located
131
+ - [ctx.blockModel](./block-model.md): Parent block carrying the current JS
132
+ - [ctx.getValue()](./get-value.md), [ctx.setValue()](./set-value.md): Read and write the current field value
@@ -1,18 +1,18 @@
1
1
  # ctx.collection
2
2
 
3
- The collection (data table) instance associated with the current RunJS execution context; used to access collection metadata, field definitions, primary key, etc. Usually from `ctx.blockModel.collection` or `ctx.collectionField?.collection`.
3
+ The Collection instance associated with the current RunJS execution context, used to access collection metadata, field definitions, primary keys, and other configurations. It usually originates from `ctx.blockModel.collection` or `ctx.collectionField?.collection`.
4
4
 
5
5
  ## Use Cases
6
6
 
7
7
  | Scenario | Description |
8
- |----------|-------------|
9
- | **JSBlock** | Block-bound collection; access `name`, `getFields`, `filterTargetKey`, etc. |
10
- | **JSField / JSItem / JSColumn** | Collection of current field or parent block; get field list, primary key, etc. |
11
- | **Table column / detail block** | Render by collection structure, pass `filterByTk` when opening popup, etc. |
8
+ |------|------|
9
+ | **JSBlock** | The collection bound to the block; can access `name`, `getFields`, `filterTargetKey`, etc. |
10
+ | **JSField / JSItem / JSColumn** | The collection the current field belongs to (or the parent block's collection), used to retrieve field lists, primary keys, etc. |
11
+ | **Table Column / Detail Block** | Used for rendering based on collection structure or passing `filterByTk` when opening popups. |
12
12
 
13
- > Note: `ctx.collection` is available when the context is bound to a data block, form block, or table block; a standalone JSBlock with no bound collection may have `null`—check before use.
13
+ > Note: `ctx.collection` is available in scenarios where a data block, form block, or table block is bound to a collection. In an independent JSBlock that is not bound to a collection, it may be `null`. It is recommended to perform a null check before use.
14
14
 
15
- ## Type
15
+ ## Type Definition
16
16
 
17
17
  ```ts
18
18
  collection: Collection | null | undefined;
@@ -21,39 +21,39 @@ collection: Collection | null | undefined;
21
21
  ## Common Properties
22
22
 
23
23
  | Property | Type | Description |
24
- |----------|------|-------------|
25
- | `name` | `string` | Collection name (e.g. `users`, `orders`) |
26
- | `title` | `string` | Collection title (i18n) |
27
- | `filterTargetKey` | `string \| string[]` | Primary key field name(s); used for `filterByTk`, `getFilterByTK` |
28
- | `dataSourceKey` | `string` | Data source key (e.g. `main`) |
29
- | `dataSource` | `DataSource` | Data source instance |
30
- | `template` | `string` | Collection template (e.g. `general`, `file`, `tree`) |
31
- | `titleableFields` | `CollectionField[]` | Fields that can be used as title |
32
- | `titleCollectionField` | `CollectionField` | Title field instance |
24
+ |------|------|------|
25
+ | `name` | `string` | Collection name (e.g., `users`, `orders`) |
26
+ | `title` | `string` | Collection title (includes internationalization) |
27
+ | `filterTargetKey` | `string \| string[]` | Primary key field name, used for `filterByTk` and `getFilterByTK` |
28
+ | `dataSourceKey` | `string` | Data source key (e.g., `main`) |
29
+ | `dataSource` | `DataSource` | The data source instance it belongs to |
30
+ | `template` | `string` | Collection template (e.g., `general`, `file`, `tree`) |
31
+ | `titleableFields` | `CollectionField[]` | List of fields that can be displayed as titles |
32
+ | `titleCollectionField` | `CollectionField` | The title field instance |
33
33
 
34
34
  ## Common Methods
35
35
 
36
36
  | Method | Description |
37
- |--------|-------------|
38
- | `getFields(): CollectionField[]` | All fields (including inherited) |
39
- | `getField(name: string): CollectionField \| undefined` | Single field by name |
40
- | `getFieldByPath(path: string): CollectionField \| undefined` | Field by path (supports association, e.g. `user.name`) |
41
- | `getAssociationFields(types?): CollectionField[]` | Association fields; `types` e.g. `['one']`, `['many']` |
42
- | `getFilterByTK(record): any` | Primary key value from record for API `filterByTk` |
37
+ |------|------|
38
+ | `getFields(): CollectionField[]` | Get all fields (including inherited ones) |
39
+ | `getField(name: string): CollectionField \| undefined` | Get a single field by field name |
40
+ | `getFieldByPath(path: string): CollectionField \| undefined` | Get a field by path (supports associations, e.g., `user.name`) |
41
+ | `getAssociationFields(types?): CollectionField[]` | Get association fields; `types` can be `['one']`, `['many']`, etc. |
42
+ | `getFilterByTK(record): any` | Extract the primary key value from a record, used for the API's `filterByTk` |
43
43
 
44
- ## Relation to ctx.collectionField, ctx.blockModel
44
+ ## Relationship with ctx.collectionField and ctx.blockModel
45
45
 
46
- | Need | Recommended |
47
- |------|-------------|
48
- | **Collection for current context** | `ctx.collection` (same as `ctx.blockModel?.collection` or `ctx.collectionField?.collection`) |
49
- | **Collection of current field** | `ctx.collectionField?.collection` |
50
- | **Target collection of association** | `ctx.collectionField?.targetCollection` |
46
+ | Requirement | Recommended Usage |
47
+ |------|----------|
48
+ | **Collection associated with current context** | `ctx.collection` (equivalent to `ctx.blockModel?.collection` or `ctx.collectionField?.collection`) |
49
+ | **Collection definition of the current field** | `ctx.collectionField?.collection` (the collection the field belongs to) |
50
+ | **Association target collection** | `ctx.collectionField?.targetCollection` (the target collection of an association field) |
51
51
 
52
- In sub-tables etc., `ctx.collection` may be the association target; in normal form/table it is usually the block’s collection.
52
+ In scenarios like sub-tables, `ctx.collection` might be the association target collection; in standard forms/tables, it is usually the collection bound to the block.
53
53
 
54
54
  ## Examples
55
55
 
56
- ### Get primary key and open popup
56
+ ### Get Primary Key and Open Popup
57
57
 
58
58
  ```ts
59
59
  const primaryKey = ctx.collection?.filterTargetKey ?? 'id';
@@ -66,7 +66,7 @@ await ctx.openView(popupUid, {
66
66
  });
67
67
  ```
68
68
 
69
- ### Iterate fields for validation or linkage
69
+ ### Iterate Through Fields for Validation or Linkage
70
70
 
71
71
  ```ts
72
72
  const fields = ctx.collection?.getFields() ?? [];
@@ -80,21 +80,21 @@ for (const f of requiredFields) {
80
80
  }
81
81
  ```
82
82
 
83
- ### Get association fields
83
+ ### Get Association Fields
84
84
 
85
85
  ```ts
86
86
  const oneToMany = ctx.collection?.getAssociationFields(['many']) ?? [];
87
- // For sub-tables, association resources, etc.
87
+ // Used for building sub-tables, associated resources, etc.
88
88
  ```
89
89
 
90
90
  ## Notes
91
91
 
92
- - `filterTargetKey` is the collection’s primary key field name; some collections use `string[]` composite keys; fallback is often `'id'`.
93
- - In **sub-tables, association fields**, `ctx.collection` may point to the association target, different from `ctx.blockModel.collection`.
94
- - `getFields()` merges inherited collection fields; local fields override inherited ones with the same name.
92
+ - `filterTargetKey` is the primary key field name of the collection. Some collections may use a `string[]` for composite primary keys. If not configured, `'id'` is commonly used as a fallback.
93
+ - In scenarios like **sub-tables or association fields**, `ctx.collection` may point to the association target collection, which differs from `ctx.blockModel.collection`.
94
+ - `getFields()` merges fields from inherited collections; local fields override inherited fields with the same name.
95
95
 
96
96
  ## Related
97
97
 
98
- - [ctx.collectionField](./collection-field.md): current field’s collection field definition
99
- - [ctx.blockModel](./block-model.md): parent block that hosts current JS; has `collection`
100
- - [ctx.model](./model.md): current model; may have `collection`
98
+ - [ctx.collectionField](./collection-field.md): The collection field definition of the current field
99
+ - [ctx.blockModel](./block-model.md): The parent block hosting the current JS, containing `collection`
100
+ - [ctx.model](./model.md): The current model, which may contain `collection`