@nocobase/plugin-flow-engine 2.1.0-alpha.6 → 2.1.0-alpha.8

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 (53) hide show
  1. package/dist/ai/docs/runjs/context/block-model.md +35 -35
  2. package/dist/ai/docs/runjs/context/collection-field.md +53 -51
  3. package/dist/ai/docs/runjs/context/collection.md +39 -39
  4. package/dist/ai/docs/runjs/context/data-source-manager.md +40 -30
  5. package/dist/ai/docs/runjs/context/data-source.md +52 -44
  6. package/dist/ai/docs/runjs/context/element.md +44 -38
  7. package/dist/ai/docs/runjs/context/exit-all.md +37 -35
  8. package/dist/ai/docs/runjs/context/exit.md +38 -35
  9. package/dist/ai/docs/runjs/context/filter-manager.md +36 -30
  10. package/dist/ai/docs/runjs/context/form.md +57 -57
  11. package/dist/ai/docs/runjs/context/get-model.md +22 -21
  12. package/dist/ai/docs/runjs/context/get-value.md +20 -19
  13. package/dist/ai/docs/runjs/context/get-var.md +61 -55
  14. package/dist/ai/docs/runjs/context/i18n.md +17 -14
  15. package/dist/ai/docs/runjs/context/import-async.md +333 -45
  16. package/dist/ai/docs/runjs/context/init-resource.md +20 -20
  17. package/dist/ai/docs/runjs/context/libs.md +31 -31
  18. package/dist/ai/docs/runjs/context/location.md +34 -31
  19. package/dist/ai/docs/runjs/context/logger.md +41 -40
  20. package/dist/ai/docs/runjs/context/make-resource.md +27 -26
  21. package/dist/ai/docs/runjs/context/message.md +42 -41
  22. package/dist/ai/docs/runjs/context/modal.md +44 -44
  23. package/dist/ai/docs/runjs/context/model.md +36 -33
  24. package/dist/ai/docs/runjs/context/notification.md +41 -40
  25. package/dist/ai/docs/runjs/context/off.md +14 -14
  26. package/dist/ai/docs/runjs/context/on.md +30 -29
  27. package/dist/ai/docs/runjs/context/open-view.md +40 -40
  28. package/dist/ai/docs/runjs/context/render.md +37 -32
  29. package/dist/ai/docs/runjs/context/request.md +46 -45
  30. package/dist/ai/docs/runjs/context/require-async.md +28 -25
  31. package/dist/ai/docs/runjs/context/resource.md +34 -34
  32. package/dist/ai/docs/runjs/context/route.md +36 -34
  33. package/dist/ai/docs/runjs/context/router.md +43 -31
  34. package/dist/ai/docs/runjs/context/set-value.md +18 -17
  35. package/dist/ai/docs/runjs/context/sql.md +7 -15
  36. package/dist/ai/docs/runjs/context/t.md +20 -17
  37. package/dist/ai/docs/runjs/context/view.md +49 -46
  38. package/dist/ai/docs/runjs/document.md +1 -0
  39. package/dist/ai/docs/runjs/import-modules.md +32 -32
  40. package/dist/ai/docs/runjs/index.md +13 -13
  41. package/dist/ai/docs/runjs/jsx.md +19 -19
  42. package/dist/ai/docs/runjs/model/form-block-model.md +1 -3
  43. package/dist/ai/docs/runjs/render.md +15 -15
  44. package/dist/ai/docs/runjs/resource/api-resource.md +53 -53
  45. package/dist/ai/docs/runjs/resource/multi-record-resource.md +64 -64
  46. package/dist/ai/docs/runjs/resource/single-record-resource.md +55 -55
  47. package/dist/ai/docs/runjs/resource/sql-resource.md +57 -57
  48. package/dist/ai/docs/runjs/window.md +5 -5
  49. package/dist/externalVersion.js +10 -10
  50. package/dist/node_modules/ses/package.json +1 -1
  51. package/dist/node_modules/zod/package.json +1 -1
  52. package/dist/server/collections/flowsql.js +1 -0
  53. package/package.json +2 -2
@@ -1,73 +1,73 @@
1
1
  # APIResource
2
2
 
3
- Generic **API resource** that sends requests by URL; use for any HTTP endpoint. Extends FlowResource with request config and `refresh()`. Unlike [MultiRecordResource](./multi-record-resource.md) and [SingleRecordResource](./single-record-resource.md), APIResource does not depend on resource name and requests directly by URL; suitable for custom endpoints, third-party APIs, etc.
3
+ A **generic API resource** for making requests based on URLs, suitable for any HTTP interface. It inherits from the `FlowResource` base class and extends it with request configuration and `refresh()`. Unlike [MultiRecordResource](./multi-record-resource.md) and [SingleRecordResource](./single-record-resource.md), `APIResource` does not depend on a resource name; it requests directly by URL, making it suitable for custom interfaces, third-party APIs, and other scenarios.
4
4
 
5
- **Create with**: `ctx.makeResource('APIResource')` or `ctx.initResource('APIResource')`. Before use call `setURL()`; RunJS context auto-injects `ctx.api` (APIClient), no need to call `setAPIClient` manually.
5
+ **Creation method**: `ctx.makeResource('APIResource')` or `ctx.initResource('APIResource')`. You must call `setURL()` before use. In the RunJS context, `ctx.api` (APIClient) is automatically injected, so there is no need to call `setAPIClient` manually.
6
6
 
7
7
  ---
8
8
 
9
- ## Use cases
9
+ ## Use Cases
10
10
 
11
11
  | Scenario | Description |
12
- |----------|-------------|
13
- | **Custom endpoints** | Call non-standard resource APIs (e.g. `/api/custom/stats`, `/api/reports/summary`) |
14
- | **Third-party APIs** | Request external services via full URL (target must support CORS) |
15
- | **One-off queries** | Fetch data temporarily, no need to bind to `ctx.resource` |
16
- | **vs ctx.request** | Use APIResource when you need reactive data, events, or error state; use `ctx.request()` for simple one-off requests |
12
+ |------|------|
13
+ | **Custom Interface** | Call non-standard resource APIs (e.g., `/api/custom/stats`, `/api/reports/summary`). |
14
+ | **Third-party API** | Request external services via full URL (requires CORS support from the target). |
15
+ | **One-time Query** | Temporary data fetching that is disposable and does not need to be bound to `ctx.resource`. |
16
+ | **Choosing between APIResource and ctx.request** | Use `APIResource` when reactive data, events, or error states are needed; use `ctx.request()` for simple one-time requests. |
17
17
 
18
18
  ---
19
19
 
20
- ## Base (FlowResource)
20
+ ## Base Class Capabilities (FlowResource)
21
21
 
22
- All resources support:
22
+ All Resources possess the following:
23
23
 
24
24
  | Method | Description |
25
- |--------|-------------|
26
- | `getData()` | Current data |
27
- | `setData(value)` | Set data (local only) |
28
- | `hasData()` | Whether data exists |
29
- | `getMeta(key?)` / `setMeta(meta)` | Read/write metadata |
30
- | `getError()` / `setError(err)` / `clearError()` | Error state |
31
- | `on(event, callback)` / `once` / `off` / `emit` | Subscribe and emit events |
25
+ |------|------|
26
+ | `getData()` | Get current data. |
27
+ | `setData(value)` | Set data (local only). |
28
+ | `hasData()` | Whether data exists. |
29
+ | `getMeta(key?)` / `setMeta(meta)` | Read/write metadata. |
30
+ | `getError()` / `setError(err)` / `clearError()` | Error state management. |
31
+ | `on(event, callback)` / `once` / `off` / `emit` | Event subscription and triggering. |
32
32
 
33
33
  ---
34
34
 
35
- ## Request config
35
+ ## Request Configuration
36
36
 
37
37
  | Method | Description |
38
- |--------|-------------|
39
- | `setAPIClient(api)` | Set APIClient instance (RunJS usually injects via context) |
40
- | `getURL()` / `setURL(url)` | Request URL |
41
- | `loading` | Load state (get/set) |
42
- | `clearRequestParameters()` | Clear request params |
43
- | `setRequestParameters(params)` | Merge request params |
44
- | `setRequestMethod(method)` | Method (e.g. `'get'`, `'post'`, default `'get'`) |
45
- | `addRequestHeader(key, value)` / `removeRequestHeader(key)` | Headers |
46
- | `addRequestParameter(key, value)` / `getRequestParameter(key)` / `removeRequestParameter(key)` | Single param add/get/remove |
47
- | `setRequestBody(data)` | Request body (for POST/PUT/PATCH) |
48
- | `setRequestOptions(key, value)` / `getRequestOptions()` | General request options |
38
+ |------|------|
39
+ | `setAPIClient(api)` | Set the APIClient instance (usually automatically injected in RunJS). |
40
+ | `getURL()` / `setURL(url)` | Request URL. |
41
+ | `loading` | Read/write loading state (get/set). |
42
+ | `clearRequestParameters()` | Clear request parameters. |
43
+ | `setRequestParameters(params)` | Merge and set request parameters. |
44
+ | `setRequestMethod(method)` | Set request method (e.g., `'get'`, `'post'`, default is `'get'`). |
45
+ | `addRequestHeader(key, value)` / `removeRequestHeader(key)` | Request headers. |
46
+ | `addRequestParameter(key, value)` / `getRequestParameter(key)` / `removeRequestParameter(key)` | Add, delete, or query a single parameter. |
47
+ | `setRequestBody(data)` | Request body (used for POST/PUT/PATCH). |
48
+ | `setRequestOptions(key, value)` / `getRequestOptions()` | General request options. |
49
49
 
50
50
  ---
51
51
 
52
- ## URL format
52
+ ## URL Format
53
53
 
54
- - **Resource style**: NocoBase shorthand supported, e.g. `users:list`, `posts:get`, concatenated with baseURL
55
- - **Relative path**: e.g. `/api/custom/endpoint`, concatenated with app baseURL
56
- - **Full URL**: Use full address for cross-origin; target must configure CORS
54
+ - **Resource Style**: Supports NocoBase resource shorthand, such as `users:list` or `posts:get`, which will be concatenated with the `baseURL`.
55
+ - **Relative Path**: e.g., `/api/custom/endpoint`, concatenated with the application's `baseURL`.
56
+ - **Full URL**: Use full addresses for cross-origin requests; the target must have CORS configured.
57
57
 
58
58
  ---
59
59
 
60
- ## Data fetch
60
+ ## Data Fetching
61
61
 
62
62
  | Method | Description |
63
- |--------|-------------|
64
- | `refresh()` | Send request with current URL, method, params, headers, data; write response `data` to `setData(data)` and emit `'refresh'`. On failure sets `setError(err)` and throws `ResourceError`, does not emit `refresh`. Requires `api` and URL. |
63
+ |------|------|
64
+ | `refresh()` | Initiates a request based on the current URL, method, params, headers, and data. It writes the response `data` into `setData(data)` and triggers the `'refresh'` event. On failure, it sets `setError(err)` and throws a `ResourceError`, without triggering the `refresh` event. Requires `api` and URL to be set. |
65
65
 
66
66
  ---
67
67
 
68
68
  ## Examples
69
69
 
70
- ### Basic GET request
70
+ ### Basic GET Request
71
71
 
72
72
  ```js
73
73
  const res = ctx.makeResource('APIResource');
@@ -77,7 +77,7 @@ await res.refresh();
77
77
  const data = res.getData();
78
78
  ```
79
79
 
80
- ### Resource-style URL
80
+ ### Resource Style URL
81
81
 
82
82
  ```js
83
83
  const res = ctx.makeResource('APIResource');
@@ -87,18 +87,18 @@ await res.refresh();
87
87
  const rows = res.getData()?.data ?? [];
88
88
  ```
89
89
 
90
- ### POST request (with body)
90
+ ### POST Request (with Request Body)
91
91
 
92
92
  ```js
93
93
  const res = ctx.makeResource('APIResource');
94
94
  res.setURL('/api/custom/submit');
95
95
  res.setRequestMethod('post');
96
- res.setRequestBody({ name: 'Test', type: 'report' });
96
+ res.setRequestBody({ name: 'test', type: 'report' });
97
97
  await res.refresh();
98
98
  const result = res.getData();
99
99
  ```
100
100
 
101
- ### Listen to refresh event
101
+ ### Listening to the refresh Event
102
102
 
103
103
  ```js
104
104
  const res = ctx.makeResource('APIResource');
@@ -110,7 +110,7 @@ res.on('refresh', () => {
110
110
  await res.refresh();
111
111
  ```
112
112
 
113
- ### Error handling
113
+ ### Error Handling
114
114
 
115
115
  ```js
116
116
  const res = ctx.makeResource('APIResource');
@@ -124,7 +124,7 @@ try {
124
124
  }
125
125
  ```
126
126
 
127
- ### Custom headers
127
+ ### Custom Request Headers
128
128
 
129
129
  ```js
130
130
  const res = ctx.makeResource('APIResource');
@@ -138,18 +138,18 @@ await res.refresh();
138
138
 
139
139
  ## Notes
140
140
 
141
- - **ctx.api dependency**: RunJS injects `ctx.api`; usually no need to call `setAPIClient`. Set it manually when used without context.
142
- - **refresh = request**: `refresh()` sends one request with current config; method, params, data, etc. must be set before calling.
143
- - **Error does not update data**: On failure `getData()` keeps previous value; use `getError()` for error info.
144
- - **vs ctx.request**: Use `ctx.request()` for simple one-off requests; use APIResource when you need reactive data, events, or error state management.
141
+ - **ctx.api Dependency**: In RunJS, `ctx.api` is injected by the environment; manual `setAPIClient` is usually unnecessary. If used in a context-less scenario, you must set it yourself.
142
+ - **Refresh Means Request**: `refresh()` initiates a request based on the current configuration; method, params, data, etc., must be configured before calling.
143
+ - **Errors Do Not Update Data**: On failure, `getData()` keeps its previous value; error information can be retrieved via `getError()`.
144
+ - **Vs ctx.request**: Use `ctx.request()` for simple one-time requests; use `APIResource` when reactive data, events, and error state management are required.
145
145
 
146
146
  ---
147
147
 
148
148
  ## Related
149
149
 
150
- - [ctx.resource](../context/resource.md) - Resource instance in current context
151
- - [ctx.initResource()](../context/init-resource.md) - Initialize and bind to ctx.resource
152
- - [ctx.makeResource()](../context/make-resource.md) - Create resource instance without binding
153
- - [ctx.request()](../context/request.md) - Generic HTTP request, for simple one-off calls
154
- - [MultiRecordResource](./multi-record-resource.md) - For data tables/lists, CRUD, pagination
155
- - [SingleRecordResource](./single-record-resource.md) - For single records
150
+ - [ctx.resource](../context/resource.md) - The resource instance in the current context
151
+ - [ctx.initResource()](../context/init-resource.md) - Initialize and bind to `ctx.resource`
152
+ - [ctx.makeResource()](../context/make-resource.md) - Create a new resource instance without binding
153
+ - [ctx.request()](../context/request.md) - General HTTP request, suitable for simple one-time calls
154
+ - [MultiRecordResource](./multi-record-resource.md) - For Collections/lists, supports CRUD and pagination
155
+ - [SingleRecordResource](./single-record-resource.md) - For single records
@@ -1,102 +1,102 @@
1
1
  # MultiRecordResource
2
2
 
3
- Resource for **data tables/lists**: request returns an array; supports pagination, filter, sort, and CRUD. Use for tables, lists, and other "multiple records" scenarios. Unlike [APIResource](./api-resource.md), MultiRecordResource uses `setResourceName()` to specify resource name and auto-builds URLs like `users:list`, `users:create`, with built-in pagination, filter, and selected rows.
3
+ A collection-oriented Resource: requests return an array and support pagination, filtering, sorting, and CRUD operations. It is suitable for "multiple records" scenarios such as tables and lists. Unlike [APIResource](./api-resource.md), MultiRecordResource specifies the resource name via `setResourceName()`, automatically constructs URLs like `users:list` and `users:create`, and includes built-in capabilities for pagination, filtering, and row selection.
4
4
 
5
5
  **Inheritance**: FlowResource → APIResource → BaseRecordResource → MultiRecordResource.
6
6
 
7
- **Create with**: `ctx.makeResource('MultiRecordResource')` or `ctx.initResource('MultiRecordResource')`. Before use call `setResourceName('collectionName')` (e.g. `'users'`); RunJS injects `ctx.api`.
7
+ **Creation**: `ctx.makeResource('MultiRecordResource')` or `ctx.initResource('MultiRecordResource')`. Before use, you must call `setResourceName('collectionName')` (e.g., `'users'`). In RunJS, `ctx.api` is injected by the runtime environment.
8
8
 
9
9
  ---
10
10
 
11
- ## Use cases
11
+ ## Use Cases
12
12
 
13
13
  | Scenario | Description |
14
- |----------|-------------|
15
- | **Table block** | Table and list blocks use MultiRecordResource by default; pagination, filter, sort |
16
- | **JSBlock list** | Load users, orders, etc. in JSBlock and render custom UI |
17
- | **Batch operations** | Use `getSelectedRows()` for selected rows, `destroySelectedRows()` for batch delete |
18
- | **Association resources** | Load associated data with `users.tags`; requires `setSourceId(parentRecordId)` |
14
+ |------|------|
15
+ | **Table Blocks** | Table and list blocks use MultiRecordResource by default, supporting pagination, filtering, and sorting. |
16
+ | **JSBlock Lists** | Load data from collections like users or orders in a JSBlock and perform custom rendering. |
17
+ | **Bulk Operations** | Use `getSelectedRows()` to get selected rows and `destroySelectedRows()` for bulk deletion. |
18
+ | **Association Resources** | Load associated collections using formats like `users.tags`, which requires `setSourceId(parentRecordId)`. |
19
19
 
20
20
  ---
21
21
 
22
- ## Data format
22
+ ## Data Format
23
23
 
24
- - `getData()` returns a **record array**, i.e. the list API `data` field
25
- - `getMeta()` returns pagination meta: `page`, `pageSize`, `count`, `totalPage`, etc.
24
+ - `getData()` returns an **array of records**, which is the `data` field from the list API response.
25
+ - `getMeta()` returns pagination and other metadata: `page`, `pageSize`, `count`, `totalPage`, etc.
26
26
 
27
27
  ---
28
28
 
29
- ## Resource name and data source
29
+ ## Resource Name and Data Source
30
30
 
31
31
  | Method | Description |
32
- |--------|-------------|
33
- | `setResourceName(name)` / `getResourceName()` | Resource name, e.g. `'users'`, `'users.tags'` (association) |
34
- | `setSourceId(id)` / `getSourceId()` | Parent record id for association resources (e.g. `users.tags` needs users primary key) |
35
- | `setDataSourceKey(key)` / `getDataSourceKey()` | Data source key (for multiple data sources) |
32
+ |------|------|
33
+ | `setResourceName(name)` / `getResourceName()` | The resource name, e.g., `'users'`, `'users.tags'` (association resource). |
34
+ | `setSourceId(id)` / `getSourceId()` | The parent record ID for association resources (e.g., for `users.tags`, pass the primary key of the user). |
35
+ | `setDataSourceKey(key)` / `getDataSourceKey()` | Data source identifier (used in multi-data source scenarios). |
36
36
 
37
37
  ---
38
38
 
39
- ## Request params (filter / fields / sort)
39
+ ## Request Parameters (Filter / Fields / Sort)
40
40
 
41
41
  | Method | Description |
42
- |--------|-------------|
43
- | `setFilterByTk(tk)` / `getFilterByTk()` | Primary key filter (single get, etc.) |
44
- | `setFilter(filter)` / `getFilter()` / `resetFilter()` | Filter; supports `$eq`, `$ne`, `$in`, etc. |
45
- | `addFilterGroup(key, filter)` / `removeFilterGroup(key)` | Filter groups (combine conditions) |
46
- | `setFields(fields)` / `getFields()` | Requested fields (whitelist) |
47
- | `setSort(sort)` / `getSort()` | Sort, e.g. `['-createdAt']` for created-at desc |
48
- | `setAppends(appends)` / `getAppends()` / `addAppends` / `removeAppends` | Association expansion (e.g. `['user', 'tags']`) |
42
+ |------|------|
43
+ | `setFilterByTk(tk)` / `getFilterByTk()` | Filter by primary key (for single record `get`, etc.). |
44
+ | `setFilter(filter)` / `getFilter()` / `resetFilter()` | Filter conditions, supporting operators like `$eq`, `$ne`, `$in`, etc. |
45
+ | `addFilterGroup(key, filter)` / `removeFilterGroup(key)` | Filter groups (for combining multiple conditions). |
46
+ | `setFields(fields)` / `getFields()` | Requested fields (whitelist). |
47
+ | `setSort(sort)` / `getSort()` | Sorting, e.g., `['-createdAt']` for descending order by creation time. |
48
+ | `setAppends(appends)` / `getAppends()` / `addAppends` / `removeAppends` | Association loading (e.g., `['user', 'tags']`). |
49
49
 
50
50
  ---
51
51
 
52
52
  ## Pagination
53
53
 
54
54
  | Method | Description |
55
- |--------|-------------|
56
- | `setPage(page)` / `getPage()` | Current page (1-based) |
57
- | `setPageSize(size)` / `getPageSize()` | Page size, default 20 |
58
- | `getTotalPage()` | Total pages |
59
- | `getCount()` | Total count (from server meta) |
60
- | `next()` / `previous()` / `goto(page)` | Change page and trigger refresh |
55
+ |------|------|
56
+ | `setPage(page)` / `getPage()` | Current page (starting from 1). |
57
+ | `setPageSize(size)` / `getPageSize()` | Number of items per page, default is 20. |
58
+ | `getTotalPage()` | Total number of pages. |
59
+ | `getCount()` | Total number of records (from server-side meta). |
60
+ | `next()` / `previous()` / `goto(page)` | Change page and trigger `refresh`. |
61
61
 
62
62
  ---
63
63
 
64
- ## Selected rows (table)
64
+ ## Selected Rows (Table Scenarios)
65
65
 
66
66
  | Method | Description |
67
- |--------|-------------|
68
- | `setSelectedRows(rows)` / `getSelectedRows()` | Currently selected row data for batch delete, etc. |
67
+ |------|------|
68
+ | `setSelectedRows(rows)` / `getSelectedRows()` | Currently selected row data, used for bulk deletion and other operations. |
69
69
 
70
70
  ---
71
71
 
72
- ## CRUD and list operations
72
+ ## CRUD and List Operations
73
73
 
74
74
  | Method | Description |
75
- |--------|-------------|
76
- | `refresh()` | Request list with current params; update `getData()` and pagination meta; emit `'refresh'` |
77
- | `get(filterByTk)` | Request single record; returns that record (does not write to getData) |
78
- | `create(data, options?)` | Create; optional `{ refresh: false }` to skip auto refresh; emit `'saved'` |
79
- | `update(filterByTk, data, options?)` | Update by primary key |
80
- | `destroy(target)` | Delete; target can be primary key, row object, or array (batch delete) |
81
- | `destroySelectedRows()` | Delete selected rows (throws if none selected) |
82
- | `setItem(index, item)` | Replace one row locally (no request) |
83
- | `runAction(actionName, options)` | Call any resource action (e.g. custom action) |
75
+ |------|------|
76
+ | `refresh()` | Requests the list with current parameters, updates `getData()` and pagination meta, and triggers the `'refresh'` event. |
77
+ | `get(filterByTk)` | Requests a single record and returns it (does not write to `getData`). |
78
+ | `create(data, options?)` | Creates a record. Optional `{ refresh: false }` prevents automatic refresh. Triggers `'saved'`. |
79
+ | `update(filterByTk, data, options?)` | Updates a record by its primary key. |
80
+ | `destroy(target)` | Deletes records. `target` can be a primary key, a row object, or an array of primary keys/row objects (bulk delete). |
81
+ | `destroySelectedRows()` | Deletes currently selected rows (throws an error if none are selected). |
82
+ | `setItem(index, item)` | Replaces a specific row of data locally (does not initiate a request). |
83
+ | `runAction(actionName, options)` | Calls any resource action (e.g., custom actions). |
84
84
 
85
85
  ---
86
86
 
87
- ## Config and events
87
+ ## Configuration and Events
88
88
 
89
89
  | Method | Description |
90
- |--------|-------------|
91
- | `setRefreshAction(name)` | Action used for refresh; default `'list'` |
92
- | `setCreateActionOptions(options)` / `setUpdateActionOptions(options)` | Request config for create/update |
93
- | `on('refresh', fn)` / `on('saved', fn)` | Fired when refresh completes or after save |
90
+ |------|------|
91
+ | `setRefreshAction(name)` | The action called during refresh, default is `'list'`. |
92
+ | `setCreateActionOptions(options)` / `setUpdateActionOptions(options)` | Request configuration for create/update. |
93
+ | `on('refresh', fn)` / `on('saved', fn)` | Triggered after refresh completion or after saving. |
94
94
 
95
95
  ---
96
96
 
97
97
  ## Examples
98
98
 
99
- ### Basic list
99
+ ### Basic List
100
100
 
101
101
  ```js
102
102
  ctx.initResource('MultiRecordResource');
@@ -107,7 +107,7 @@ const rows = ctx.resource.getData();
107
107
  const total = ctx.resource.getCount();
108
108
  ```
109
109
 
110
- ### Filter and sort
110
+ ### Filtering and Sorting
111
111
 
112
112
  ```js
113
113
  ctx.resource.setResourceName('users');
@@ -117,7 +117,7 @@ ctx.resource.setFields(['id', 'nickname', 'email']);
117
117
  await ctx.resource.refresh();
118
118
  ```
119
119
 
120
- ### Association expansion
120
+ ### Association Loading
121
121
 
122
122
  ```js
123
123
  ctx.resource.setResourceName('orders');
@@ -126,17 +126,17 @@ await ctx.resource.refresh();
126
126
  const orders = ctx.resource.getData();
127
127
  ```
128
128
 
129
- ### Create and pagination
129
+ ### Create and Pagination
130
130
 
131
131
  ```js
132
- await ctx.resource.create({ name: 'John', email: 'john@example.com' });
132
+ await ctx.resource.create({ name: 'John Doe', email: 'john.doe@example.com' });
133
133
 
134
134
  await ctx.resource.next();
135
135
  await ctx.resource.previous();
136
136
  await ctx.resource.goto(3);
137
137
  ```
138
138
 
139
- ### Batch delete selected rows
139
+ ### Bulk Delete Selected Rows
140
140
 
141
141
  ```js
142
142
  const rows = ctx.resource?.getSelectedRows?.() || [];
@@ -148,7 +148,7 @@ await ctx.resource.destroySelectedRows();
148
148
  ctx.message.success(ctx.t('Deleted'));
149
149
  ```
150
150
 
151
- ### Listen to refresh event
151
+ ### Listening to the refresh Event
152
152
 
153
153
  ```js
154
154
  ctx.resource?.on?.('refresh', () => {
@@ -158,7 +158,7 @@ ctx.resource?.on?.('refresh', () => {
158
158
  await ctx.resource?.refresh?.();
159
159
  ```
160
160
 
161
- ### Association resource (child table)
161
+ ### Association Resource (Sub-table)
162
162
 
163
163
  ```js
164
164
  const res = ctx.makeResource('MultiRecordResource');
@@ -172,17 +172,17 @@ const roles = res.getData();
172
172
 
173
173
  ## Notes
174
174
 
175
- - **setResourceName required**: Must call `setResourceName('collectionName')` before use; otherwise request URL cannot be built.
176
- - **Association resources**: When resource name is `parent.child` (e.g. `users.tags`), call `setSourceId(parentPrimaryKey)` first.
177
- - **refresh debounce**: Multiple `refresh()` calls in the same event loop only run the last one to avoid duplicate requests.
178
- - **getData is array**: List API returns `data` as record array; `getData()` returns that array directly.
175
+ - **setResourceName is Required**: You must call `setResourceName('collectionName')` before use, otherwise the request URL cannot be constructed.
176
+ - **Association Resources**: When the resource name is in the format `parent.child` (e.g., `users.tags`), you must call `setSourceId(parentPrimaryKey)` first.
177
+ - **Refresh Debouncing**: Multiple calls to `refresh()` within the same event loop will only execute the last one to avoid redundant requests.
178
+ - **getData returns an Array**: The `data` returned by the list API is an array of records, and `getData()` returns this array directly.
179
179
 
180
180
  ---
181
181
 
182
182
  ## Related
183
183
 
184
- - [ctx.resource](../context/resource.md) - Resource instance in current context
184
+ - [ctx.resource](../context/resource.md) - The resource instance in the current context
185
185
  - [ctx.initResource()](../context/init-resource.md) - Initialize and bind to ctx.resource
186
- - [ctx.makeResource()](../context/make-resource.md) - Create resource instance without binding
187
- - [APIResource](./api-resource.md) - Generic API resource, request by URL
188
- - [SingleRecordResource](./single-record-resource.md) - For single records
186
+ - [ctx.makeResource()](../context/make-resource.md) - Create a new resource instance without binding
187
+ - [APIResource](./api-resource.md) - General API resource requested by URL
188
+ - [SingleRecordResource](./single-record-resource.md) - Oriented towards a single record