@nocobase/plugin-flow-engine 2.1.0-alpha.7 → 2.1.0-alpha.9

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,39 +1,39 @@
1
1
  # ctx.libs
2
2
 
3
- `ctx.libs` is the unified namespace for RunJS built-in libraries (React, Ant Design, dayjs, lodash, etc.). **No `import` or async loading**; use `ctx.libs.xxx` directly.
3
+ `ctx.libs` is the unified namespace for built-in libraries in RunJS, containing commonly used libraries such as React, Ant Design, dayjs, and lodash. **No `import` or asynchronous loading is required**; they can be used directly via `ctx.libs.xxx`.
4
4
 
5
5
  ## Use Cases
6
6
 
7
7
  | Scenario | Description |
8
- |----------|-------------|
9
- | **JSBlock / JSField / JSItem / JSColumn** | React + Ant Design for UI, dayjs for dates, lodash for data |
10
- | **Formulas / calculations** | formula or math for Excel-like formulas and math expressions |
11
- | **Event flow / linkage** | lodash, dayjs, formula, etc. in logic-only code |
8
+ |------|------|
9
+ | **JSBlock / JSField / JSItem / JSColumn** | Use React + Ant Design to render UI, dayjs for date handling, and lodash for data processing. |
10
+ | **Formula / Calculation** | Use formula or math for Excel-like formulas and mathematical expression operations. |
11
+ | **Workflow / Linkage Rules** | Call utility libraries like lodash, dayjs, and formula in pure logic scenarios. |
12
12
 
13
- ## Built-in libraries
13
+ ## Built-in Libraries Overview
14
14
 
15
- | Property | Description | Docs |
16
- |----------|-------------|------|
17
- | `ctx.libs.React` | React core for JSX and Hooks | [React](https://react.dev/) |
18
- | `ctx.libs.ReactDOM` | ReactDOM (e.g. `createRoot`) | [React DOM](https://react.dev/reference/react-dom) |
19
- | `ctx.libs.antd` | Ant Design (Button, Card, Table, Form, Input, Modal, etc.) | [Ant Design](https://ant.design/components/overview/) |
20
- | `ctx.libs.antdIcons` | Ant Design icons (PlusOutlined, UserOutlined, etc.) | [@ant-design/icons](https://ant.design/components/icon/) |
21
- | `ctx.libs.dayjs` | Date/time utilities | [dayjs](https://day.js.org/) |
22
- | `ctx.libs.lodash` | Utilities (get, set, debounce, etc.) | [Lodash](https://lodash.com/docs/) |
23
- | `ctx.libs.formula` | Excel-like formulas (SUM, AVERAGE, IF, etc.) | [Formula.js](https://formulajs.info/functions/) |
24
- | `ctx.libs.math` | Math expressions and evaluation | [Math.js](https://mathjs.org/docs/) |
15
+ | Property | Description | Documentation |
16
+ |------|------|------|
17
+ | `ctx.libs.React` | React core, used for JSX and Hooks | [React](https://react.dev/) |
18
+ | `ctx.libs.ReactDOM` | ReactDOM client API (including `createRoot`), used with React for rendering | [React DOM](https://react.dev/reference/react-dom) |
19
+ | `ctx.libs.antd` | Ant Design component library (Button, Card, Table, Form, Input, Modal, etc.) | [Ant Design](https://ant.design/components/overview/) |
20
+ | `ctx.libs.antdIcons` | Ant Design icon library (e.g., PlusOutlined, UserOutlined) | [@ant-design/icons](https://ant.design/components/icon/) |
21
+ | `ctx.libs.dayjs` | Date and time utility library | [dayjs](https://day.js.org/) |
22
+ | `ctx.libs.lodash` | Utility library (get, set, debounce, etc.) | [Lodash](https://lodash.com/docs/) |
23
+ | `ctx.libs.formula` | Excel-like formula function library (SUM, AVERAGE, IF, etc.) | [Formula.js](https://formulajs.info/functions/) |
24
+ | `ctx.libs.math` | Mathematical expression and calculation library | [Math.js](https://mathjs.org/docs/) |
25
25
 
26
- ## Top-level aliases
26
+ ## Top-level Aliases
27
27
 
28
- For backward compatibility, some libs are also on `ctx`: `ctx.React`, `ctx.ReactDOM`, `ctx.antd`, `ctx.dayjs`. **Prefer `ctx.libs.xxx`** for consistency and docs.
28
+ For compatibility with legacy code, some libraries are also exposed at the top level: `ctx.React`, `ctx.ReactDOM`, `ctx.antd`, and `ctx.dayjs`. **It is recommended to consistently use `ctx.libs.xxx`** for easier maintenance and documentation searching.
29
29
 
30
- ## Lazy loading
30
+ ## Lazy Loading
31
31
 
32
- `lodash`, `formula`, `math` are **lazy-loaded**: the first access to `ctx.libs.lodash` triggers a dynamic import, then the result is cached. `React`, `antd`, `dayjs`, `antdIcons` are preloaded in context.
32
+ `lodash`, `formula`, and `math` use **lazy loading**: a dynamic import is triggered only when `ctx.libs.lodash` is accessed for the first time, and the cache is reused thereafter. `React`, `antd`, `dayjs`, and `antdIcons` are pre-configured by the context and are available immediately.
33
33
 
34
34
  ## Examples
35
35
 
36
- ### React and Ant Design
36
+ ### Rendering with React and Ant Design
37
37
 
38
38
  ```tsx
39
39
  const { Button, Card } = ctx.libs.antd;
@@ -45,7 +45,7 @@ ctx.render(
45
45
  );
46
46
  ```
47
47
 
48
- ### Hooks
48
+ ### Using Hooks
49
49
 
50
50
  ```tsx
51
51
  const { React } = ctx.libs;
@@ -59,7 +59,7 @@ const App = () => {
59
59
  ctx.render(<App />);
60
60
  ```
61
61
 
62
- ### Icons
62
+ ### Using Icons
63
63
 
64
64
  ```tsx
65
65
  const { Button } = ctx.libs.antd;
@@ -68,7 +68,7 @@ const { UserOutlined, HeartOutlined } = ctx.libs.antdIcons;
68
68
  ctx.render(<Button icon={<UserOutlined />}>User</Button>);
69
69
  ```
70
70
 
71
- ### dayjs
71
+ ### Date Processing with dayjs
72
72
 
73
73
  ```ts
74
74
  const now = ctx.libs.dayjs();
@@ -76,14 +76,14 @@ const formatted = now.format('YYYY-MM-DD HH:mm:ss');
76
76
  ctx.message.info(formatted);
77
77
  ```
78
78
 
79
- ### lodash
79
+ ### Utility Functions with lodash
80
80
 
81
81
  ```ts
82
82
  const user = { profile: { name: 'Alice' } };
83
83
  const name = ctx.libs.lodash.get(user, 'profile.name', 'Unknown');
84
84
  ```
85
85
 
86
- ### formula
86
+ ### Formula Calculations
87
87
 
88
88
  ```ts
89
89
  const values = [1, 2, 3, 4];
@@ -91,7 +91,7 @@ const sum = ctx.libs.formula.SUM(values);
91
91
  const avg = ctx.libs.formula.AVERAGE(values);
92
92
  ```
93
93
 
94
- ### math
94
+ ### Mathematical Expressions with math.js
95
95
 
96
96
  ```ts
97
97
  const result = ctx.libs.math.evaluate('2 + 3 * 4');
@@ -100,10 +100,10 @@ const result = ctx.libs.math.evaluate('2 + 3 * 4');
100
100
 
101
101
  ## Notes
102
102
 
103
- - **Mixing with ctx.importAsync**: If you load external React via `ctx.importAsync('react@19')`, JSX uses that instance; **do not** mix with `ctx.libs.antd`. Load antd for that React version (e.g. `ctx.importAsync('antd@5.x')`, `ctx.importAsync('@ant-design/icons@5.x')`).
104
- - **Multiple React instances**: "Invalid hook call" or null hook dispatcher usually means multiple React instances. Before using `ctx.libs.React` or Hooks, run `await ctx.importAsync('react@version')` so the same React as the page is used.
103
+ - **Mixing with ctx.importAsync**: If an external React is loaded via `ctx.importAsync('react@19')`, JSX will use that instance. In this case, **do not** mix it with `ctx.libs.antd`. Ant Design must be loaded to match that React version (e.g., `ctx.importAsync('antd@5.x')`, `ctx.importAsync('@ant-design/icons@5.x')`).
104
+ - **Multiple React Instances**: If "Invalid hook call" occurs or the hook dispatcher is null, it is usually caused by multiple React instances. Before reading `ctx.libs.React` or calling Hooks, execute `await ctx.importAsync('react@version')` first to ensure the same React instance is shared with the page.
105
105
 
106
106
  ## Related
107
107
 
108
- - [ctx.importAsync()](./import-async.md): load external ESM (e.g. specific React, Vue)
109
- - [ctx.render()](./render.md): render into container
108
+ - [ctx.importAsync()](./import-async.md) - Load external ESM modules on demand (e.g., specific versions of React, Vue)
109
+ - [ctx.render()](./render.md) - Render content to a container
@@ -1,85 +1,88 @@
1
1
  # ctx.location
2
2
 
3
- Current route location, equivalent to React Router’s `location`. Use with `ctx.router` and `ctx.route` to read pathname, search, hash, and state passed via navigation.
3
+ Current route location information, equivalent to the React Router `location` object. It is typically used in conjunction with `ctx.router` and `ctx.route` to read the current path, query string, hash, and state passed through the route.
4
4
 
5
5
  ## Use Cases
6
6
 
7
7
  | Scenario | Description |
8
- |----------|-------------|
9
- | **JSBlock / JSField** | Conditional render or logic based on path, query, or hash |
10
- | **Linkage / event flow** | Read URL params for filtering or use `location.state` for source |
11
- | **After navigation** | On target page, read `ctx.location.state` from `ctx.router.navigate` |
8
+ |------|------|
9
+ | **JSBlock / JSField** | Perform conditional rendering or logic branching based on the current path, query parameters, or hash. |
10
+ | **Linkage Rules / FlowEngine** | Read URL query parameters for linkage filtering, or determine the source based on `location.state`. |
11
+ | **Post-navigation processing** | Receive data passed from the previous page via `ctx.router.navigate` using `ctx.location.state` on the target page. |
12
12
 
13
- > Note: `ctx.location` is only available in RunJS when a router context exists (e.g. JSBlock on a page, event flow); in pure backend or non-routed contexts (e.g. workflow) it may be empty.
13
+ > Note: `ctx.location` is only available in RunJS environments with a routing context (e.g., JSBlock within a page, FlowEngine, etc.); it may be null in pure backend or non-routing contexts (e.g., Workflows).
14
14
 
15
- ## Type
15
+ ## Type Definition
16
16
 
17
17
  ```ts
18
18
  location: Location;
19
19
  ```
20
20
 
21
- `Location` is from `react-router-dom`, same as `useLocation()`.
21
+ `Location` comes from `react-router-dom`, consistent with the return value of React Router's `useLocation()`.
22
22
 
23
23
  ## Common Fields
24
24
 
25
25
  | Field | Type | Description |
26
- |-------|------|-------------|
27
- | `pathname` | `string` | Current path, leading `/` (e.g. `/admin/users`) |
28
- | `search` | `string` | Query string, leading `?` (e.g. `?page=1&status=active`) |
29
- | `hash` | `string` | Hash fragment, leading `#` (e.g. `#section-1`) |
30
- | `state` | `any` | Data passed via `ctx.router.navigate(path, { state })`; not in URL |
31
- | `key` | `string` | Unique key for this location; initial page is `"default"` |
26
+ |------|------|------|
27
+ | `pathname` | `string` | The current path, starting with `/` (e.g., `/admin/users`). |
28
+ | `search` | `string` | The query string, starting with `?` (e.g., `?page=1&status=active`). |
29
+ | `hash` | `string` | The hash fragment, starting with `#` (e.g., `#section-1`). |
30
+ | `state` | `any` | Arbitrary data passed via `ctx.router.navigate(path, { state })`, not reflected in the URL. |
31
+ | `key` | `string` | A unique identifier for this location; the initial page is `"default"`. |
32
32
 
33
- ## Relation to ctx.router, ctx.urlSearchParams
33
+ ## Relationship with ctx.router and ctx.urlSearchParams
34
34
 
35
- | Use | Recommended |
36
- |-----|-------------|
37
- | **Path, hash, state** | `ctx.location.pathname` / `ctx.location.hash` / `ctx.location.state` |
38
- | **Query params as object** | `ctx.urlSearchParams` |
39
- | **Parse search** | `new URLSearchParams(ctx.location.search)` or `ctx.urlSearchParams` |
35
+ | Purpose | Recommended Usage |
36
+ |------|----------|
37
+ | **Read path, hash, state** | `ctx.location.pathname` / `ctx.location.hash` / `ctx.location.state` |
38
+ | **Read query parameters (as object)** | `ctx.urlSearchParams`, which provides the parsed object directly. |
39
+ | **Parse search string** | `new URLSearchParams(ctx.location.search)` or use `ctx.urlSearchParams` directly. |
40
40
 
41
- `ctx.urlSearchParams` is derived from `ctx.location.search`; use it when you only need query params.
41
+ `ctx.urlSearchParams` is parsed from `ctx.location.search`. If you only need query parameters, using `ctx.urlSearchParams` is more convenient.
42
42
 
43
43
  ## Examples
44
44
 
45
- ### Branch by path
45
+ ### Branching Based on Path
46
46
 
47
47
  ```ts
48
48
  if (ctx.location.pathname.startsWith('/admin/users')) {
49
- ctx.message.info('On user management page');
49
+ ctx.message.info('Currently on the user management page');
50
50
  }
51
51
  ```
52
52
 
53
- ### Parse query params
53
+ ### Parsing Query Parameters
54
54
 
55
55
  ```ts
56
+ // Method 1: Using ctx.urlSearchParams (Recommended)
56
57
  const page = ctx.urlSearchParams.page || 1;
57
58
  const status = ctx.urlSearchParams.status;
58
59
 
60
+ // Method 2: Using URLSearchParams to parse search
59
61
  const params = new URLSearchParams(ctx.location.search);
60
62
  const page = params.get('page') || '1';
61
63
  const status = params.get('status');
62
64
  ```
63
65
 
64
- ### Read state from navigation
66
+ ### Receiving State Passed via Route Navigation
65
67
 
66
68
  ```ts
69
+ // When navigating from the previous page: ctx.router.navigate('/users/123', { state: { from: 'dashboard' } })
67
70
  const prevState = ctx.location.state;
68
71
  if (prevState?.from === 'dashboard') {
69
- ctx.message.info('Navigated from dashboard');
72
+ ctx.message.info('Navigated from the dashboard');
70
73
  }
71
74
  ```
72
75
 
73
- ### Anchor by hash
76
+ ### Locating Anchors via Hash
74
77
 
75
78
  ```ts
76
- const hash = ctx.location.hash;
79
+ const hash = ctx.location.hash; // e.g., "#edit"
77
80
  if (hash === '#edit') {
78
- // Scroll to edit or run logic
81
+ // Scroll to the edit area or execute corresponding logic
79
82
  }
80
83
  ```
81
84
 
82
85
  ## Related
83
86
 
84
- - [ctx.router](./router.md): navigation; `state` from `ctx.router.navigate` is available as `ctx.location.state`
85
- - [ctx.route](./route.md): current route match (params, config); use with `ctx.location`
87
+ - [ctx.router](./router.md): Route navigation; the `state` from `ctx.router.navigate` can be retrieved via `ctx.location.state` on the target page.
88
+ - [ctx.route](./route.md): Current route match information (parameters, configuration, etc.), often used in conjunction with `ctx.location`.
@@ -1,84 +1,85 @@
1
1
  # ctx.logger
2
2
 
3
- Logging built on [pino](https://github.com/pinojs/pino); outputs structured JSON. Prefer `ctx.logger` over `console` for collection and analysis.
3
+ A logging wrapper based on [pino](https://github.com/pinojs/pino), providing high-performance structured JSON logs. It is recommended to use `ctx.logger` instead of `console` for easier log collection and analysis.
4
4
 
5
- ## Use Cases
5
+ ## Scenarios
6
6
 
7
- Available in all RunJS contexts for debugging, error tracking, and performance.
7
+ `ctx.logger` can be used in all RunJS scenarios for debugging, error tracking, performance analysis, etc.
8
8
 
9
- ## Type
9
+ ## Type Definition
10
10
 
11
11
  ```ts
12
12
  logger: pino.Logger;
13
13
  ```
14
14
 
15
- `ctx.logger` is `engine.logger.child({ module: 'flow-engine' })`, i.e. a pino child logger with a `module` context.
15
+ `ctx.logger` is an instance of `engine.logger.child({ module: 'flow-engine' })`, which is a pino child logger with a `module` context.
16
16
 
17
- ## Log levels
17
+ ## Log Levels
18
18
 
19
- From highest to lowest:
19
+ pino supports the following levels (from highest to lowest):
20
20
 
21
21
  | Level | Method | Description |
22
- |-------|--------|-------------|
23
- | `fatal` | `ctx.logger.fatal()` | Fatal; usually process exit |
24
- | `error` | `ctx.logger.error()` | Error; request or operation failed |
25
- | `warn` | `ctx.logger.warn()` | Warning; potential issue |
26
- | `info` | `ctx.logger.info()` | General runtime info |
27
- | `debug` | `ctx.logger.debug()` | Debug; development |
28
- | `trace` | `ctx.logger.trace()` | Verbose; deep diagnosis |
22
+ |------|------|------|
23
+ | `fatal` | `ctx.logger.fatal()` | Fatal error, usually leading to process exit |
24
+ | `error` | `ctx.logger.error()` | Error, indicating a failed request or operation |
25
+ | `warn` | `ctx.logger.warn()` | Warning, indicating potential risks or abnormal situations |
26
+ | `info` | `ctx.logger.info()` | General runtime information |
27
+ | `debug` | `ctx.logger.debug()` | Debugging information, used during development |
28
+ | `trace` | `ctx.logger.trace()` | Detailed trace, used for deep diagnostics |
29
29
 
30
- ## Recommended usage
30
+ ## Recommended Usage
31
31
 
32
- Use `level(msg, meta)`: message first, optional metadata object second.
32
+ The recommended format is `level(msg, meta)`: the message comes first, followed by an optional metadata object.
33
33
 
34
34
  ```ts
35
- ctx.logger.info('Block loaded');
36
- ctx.logger.info('Success', { recordId: 456 });
37
- ctx.logger.warn('Slow', { duration: 5000 });
38
- ctx.logger.error('Failed', { userId: 123, action: 'create' });
35
+ ctx.logger.info('Block loading complete');
36
+ ctx.logger.info('Operation successful', { recordId: 456 });
37
+ ctx.logger.warn('Performance warning', { duration: 5000 });
38
+ ctx.logger.error('Operation failed', { userId: 123, action: 'create' });
39
39
  ctx.logger.error('Request failed', { err });
40
40
  ```
41
41
 
42
- pino also supports `level(meta, msg)` or `level({ msg, ...meta })` if needed.
42
+ pino also supports `level(meta, msg)` (object first) or `level({ msg, ...meta })` (single object), which can be used as needed.
43
43
 
44
44
  ## Examples
45
45
 
46
- ### Basic
46
+ ### Basic Usage
47
47
 
48
48
  ```ts
49
- ctx.logger.info('Block loaded');
49
+ ctx.logger.info('Block loading complete');
50
50
  ctx.logger.warn('Request failed, using cache', { err });
51
- ctx.logger.debug('Saving', { recordId: ctx.record?.id });
51
+ ctx.logger.debug('Saving...', { recordId: ctx.record?.id });
52
52
  ```
53
53
 
54
- ### Child logger
54
+ ### Creating a Child Logger with child()
55
55
 
56
56
  ```ts
57
+ // Create a child logger with context for the current logic
57
58
  const log = ctx.logger.child({ scope: 'myBlock' });
58
- log.info('Step 1');
59
- log.debug('Step 2', { step: 2 });
59
+ log.info('Executing step 1');
60
+ log.debug('Executing step 2', { step: 2 });
60
61
  ```
61
62
 
62
- ### vs console
63
+ ### Relationship with console
63
64
 
64
- Prefer `ctx.logger` for structured JSON. Rough mapping: `console.log` → `ctx.logger.info`, `console.error` → `ctx.logger.error`, `console.warn` → `ctx.logger.warn`.
65
+ It is recommended to use `ctx.logger` directly to obtain structured JSON logs. If you are accustomed to using `console`, the mappings are: `console.log` → `ctx.logger.info`, `console.error` → `ctx.logger.error`, `console.warn` → `ctx.logger.warn`.
65
66
 
66
- ## Output format
67
+ ## Log Format
67
68
 
68
- pino outputs JSON with:
69
+ pino outputs structured JSON, where each log entry contains:
69
70
 
70
- - `level`: numeric level
71
- - `time`: timestamp (ms)
72
- - `msg`: message
73
- - `module`: `flow-engine`
74
- - Any custom fields passed in the object
71
+ - `level`: Log level (numeric)
72
+ - `time`: Timestamp (milliseconds)
73
+ - `msg`: Log message
74
+ - `module`: Fixed as `flow-engine`
75
+ - Other custom fields (passed via objects)
75
76
 
76
77
  ## Notes
77
78
 
78
- - Logs are JSON for easy collection and querying
79
- - Child loggers from `child()` also work well with `level(msg, meta)`
80
- - Some environments (e.g. workflow) may use different log handling
79
+ - Logs are structured JSON, making them easy to collect, search, and analyze.
80
+ - Child loggers created via `child()` also follow the `level(msg, meta)` recommendation.
81
+ - Some runtime environments (such as Workflows) may use different log output methods.
81
82
 
82
83
  ## Related
83
84
 
84
- - [pino](https://github.com/pinojs/pino)
85
+ - [pino](https://github.com/pinojs/pino) — The underlying logging library
@@ -1,18 +1,18 @@
1
1
  # ctx.makeResource()
2
2
 
3
- **Creates** a new resource instance and returns it; **does not** set or change `ctx.resource`. Use when you need multiple resources or a temporary one.
3
+ **Creates** and returns a new resource instance **without** writing to or modifying `ctx.resource`. It is suitable for scenarios requiring multiple independent resources or temporary usage.
4
4
 
5
5
  ## Use Cases
6
6
 
7
7
  | Scenario | Description |
8
- |----------|-------------|
9
- | **Multiple resources** | Load several data sources (e.g. users + orders), each with its own resource |
10
- | **One-off query** | Single query, no need to bind to `ctx.resource` |
11
- | **Auxiliary data** | Main data in `ctx.resource`, extra data from a `makeResource` instance |
8
+ |------|------|
9
+ | **Multiple resources** | Load multiple data sources simultaneously (e.g., user list + order list), each using an independent resource. |
10
+ | **Temporary queries** | One-time queries that are discarded after use, without needing to bind to `ctx.resource`. |
11
+ | **Auxiliary data** | Use `ctx.resource` for primary data and `makeResource` to create instances for additional data. |
12
12
 
13
- If you only need one resource and want it on `ctx.resource`, use [ctx.initResource()](./init-resource.md).
13
+ If you only need a single resource and want to bind it to `ctx.resource`, using [ctx.initResource()](./init-resource.md) is more appropriate.
14
14
 
15
- ## Type
15
+ ## Type Definition
16
16
 
17
17
  ```ts
18
18
  makeResource<T = FlowResource>(
@@ -21,17 +21,17 @@ makeResource<T = FlowResource>(
21
21
  ```
22
22
 
23
23
  | Parameter | Type | Description |
24
- |-----------|------|-------------|
25
- | `resourceType` | `string` | `'APIResource'`, `'SingleRecordResource'`, `'MultiRecordResource'`, `'SQLResource'` |
24
+ |------|------|------|
25
+ | `resourceType` | `string` | Resource type: `'APIResource'`, `'SingleRecordResource'`, `'MultiRecordResource'`, `'SQLResource'` |
26
26
 
27
- **Returns**: The new resource instance.
27
+ **Returns**: The newly created resource instance.
28
28
 
29
- ## Relation to ctx.initResource()
29
+ ## Difference from ctx.initResource()
30
30
 
31
31
  | Method | Behavior |
32
- |--------|----------|
33
- | `ctx.makeResource(type)` | Creates and returns; **does not** set `ctx.resource`; can call multiple times for multiple resources |
34
- | `ctx.initResource(type)` | Creates and binds if missing; otherwise returns existing. Ensures `ctx.resource` is set |
32
+ |------|------|
33
+ | `ctx.makeResource(type)` | Only creates and returns a new instance, **not** writing to `ctx.resource`. Can be called multiple times to obtain multiple independent resources. |
34
+ | `ctx.initResource(type)` | Creates and binds if `ctx.resource` does not exist; returns it directly if it already exists. Ensures `ctx.resource` is available. |
35
35
 
36
36
  ## Examples
37
37
 
@@ -42,7 +42,7 @@ const listRes = ctx.makeResource('MultiRecordResource');
42
42
  listRes.setResourceName('users');
43
43
  await listRes.refresh();
44
44
  const users = listRes.getData();
45
- // ctx.resource unchanged (if it existed)
45
+ // ctx.resource remains its original value (if any)
46
46
  ```
47
47
 
48
48
  ### Multiple resources
@@ -58,15 +58,16 @@ await ordersRes.refresh();
58
58
 
59
59
  ctx.render(
60
60
  <div>
61
- <p>Users: {usersRes.getData().length}</p>
62
- <p>Orders: {ordersRes.getData().length}</p>
61
+ <p>User count: {usersRes.getData().length}</p>
62
+ <p>Order count: {ordersRes.getData().length}</p>
63
63
  </div>
64
64
  );
65
65
  ```
66
66
 
67
- ### One-off query
67
+ ### Temporary query
68
68
 
69
69
  ```ts
70
+ // One-time query, does not pollute ctx.resource
70
71
  const tempRes = ctx.makeResource('SingleRecordResource');
71
72
  tempRes.setResourceName('users');
72
73
  tempRes.setFilterByTk(1);
@@ -76,14 +77,14 @@ const record = tempRes.getData();
76
77
 
77
78
  ## Notes
78
79
 
79
- - Call `setResourceName(name)` then `refresh()` to load data.
80
- - Each instance is independent; good for loading several sources in parallel.
80
+ - The newly created resource needs to call `setResourceName(name)` to specify the collection, and then load data via `refresh()`.
81
+ - Each resource instance is independent and does not affect others; suitable for loading multiple data sources in parallel.
81
82
 
82
83
  ## Related
83
84
 
84
- - [ctx.initResource()](./init-resource.md): init and bind to `ctx.resource`
85
- - [ctx.resource](./resource.md): current context resource
86
- - [MultiRecordResource](../resource/multi-record-resource.md)
87
- - [SingleRecordResource](../resource/single-record-resource.md)
88
- - [APIResource](../resource/api-resource.md)
89
- - [SQLResource](../resource/sql-resource.md)
85
+ - [ctx.initResource()](./init-resource.md): Initialize and bind to `ctx.resource`
86
+ - [ctx.resource](./resource.md): The resource instance in the current context
87
+ - [MultiRecordResource](../resource/multi-record-resource) — Multiple records/List
88
+ - [SingleRecordResource](../resource/single-record-resource) — Single record
89
+ - [APIResource](../resource/api-resource) — General API resource
90
+ - [SQLResource](../resource/sql-resource) — SQL query resource
@@ -1,63 +1,63 @@
1
1
  # ctx.message
2
2
 
3
- Ant Design global message API; shows short messages at the top center. Messages auto-close after a while or can be closed by the user.
3
+ Ant Design global message API, used to display temporary light prompts at the top center of the page. Messages close automatically after a certain period or can be closed manually by the user.
4
4
 
5
5
  ## Use Cases
6
6
 
7
7
  | Scenario | Description |
8
- |----------|-------------|
9
- | **JSBlock / JSField / JSItem / JSColumn** | Quick feedback: validation, copy success, etc. |
10
- | **Form actions / event flow** | Submit success, save failed, validation failed |
11
- | **JSAction** | Click or batch action feedback |
8
+ |------|------|
9
+ | **JSBlock / JSField / JSItem / JSColumn** | Operation feedback, validation prompts, copy success, and other light prompts |
10
+ | **Form Operations / Workflow** | Feedback for submission success, save failure, validation failure, etc. |
11
+ | **Action Events (JSAction)** | Immediate feedback for clicks, batch operation completion, etc. |
12
12
 
13
- ## Type
13
+ ## Type Definition
14
14
 
15
15
  ```ts
16
16
  message: MessageInstance;
17
17
  ```
18
18
 
19
- `MessageInstance` is the Ant Design message API.
19
+ `MessageInstance` is the Ant Design message interface, providing the following methods.
20
20
 
21
21
  ## Common Methods
22
22
 
23
23
  | Method | Description |
24
- |--------|-------------|
25
- | `success(content, duration?)` | Success message |
26
- | `error(content, duration?)` | Error message |
27
- | `warning(content, duration?)` | Warning message |
28
- | `info(content, duration?)` | Info message |
29
- | `loading(content, duration?)` | Loading (usually closed manually) |
30
- | `open(config)` | Open with custom config |
31
- | `destroy()` | Close all messages |
24
+ |------|------|
25
+ | `success(content, duration?)` | Display a success prompt |
26
+ | `error(content, duration?)` | Display an error prompt |
27
+ | `warning(content, duration?)` | Display a warning prompt |
28
+ | `info(content, duration?)` | Display an information prompt |
29
+ | `loading(content, duration?)` | Display a loading prompt (must be closed manually) |
30
+ | `open(config)` | Open a message using custom configuration |
31
+ | `destroy()` | Close all currently displayed messages |
32
32
 
33
33
  **Parameters:**
34
34
 
35
- - `content`: `string` or `ConfigOptions`
36
- - `duration`: optional seconds; default 3; 0 = no auto-close
35
+ - `content` (`string` | `ConfigOptions`): Message content or configuration object
36
+ - `duration` (`number`, optional): Auto-close delay (seconds), default is 3 seconds; set to 0 to disable auto-close
37
37
 
38
- **ConfigOptions** (when content is an object):
38
+ **ConfigOptions** (when `content` is an object):
39
39
 
40
40
  ```ts
41
41
  interface ConfigOptions {
42
- content: React.ReactNode;
43
- duration?: number;
44
- onClose?: () => void;
45
- icon?: React.ReactNode;
42
+ content: React.ReactNode; // Message content
43
+ duration?: number; // Auto-close delay (seconds)
44
+ onClose?: () => void; // Callback when closed
45
+ icon?: React.ReactNode; // Custom icon
46
46
  }
47
47
  ```
48
48
 
49
49
  ## Examples
50
50
 
51
- ### Basic
51
+ ### Basic Usage
52
52
 
53
53
  ```ts
54
- ctx.message.success('Done');
55
- ctx.message.error('Failed');
54
+ ctx.message.success('Operation successful');
55
+ ctx.message.error('Operation failed');
56
56
  ctx.message.warning('Please select data first');
57
57
  ctx.message.info('Processing...');
58
58
  ```
59
59
 
60
- ### With ctx.t (i18n)
60
+ ### Internationalization with ctx.t
61
61
 
62
62
  ```ts
63
63
  ctx.message.success(ctx.t('Copied'));
@@ -65,42 +65,43 @@ ctx.message.warning(ctx.t('Please select at least one row'));
65
65
  ctx.message.success(ctx.t('Exported {{count}} records', { count: rows.length }));
66
66
  ```
67
67
 
68
- ### Loading and manual close
68
+ ### Loading and Manual Close
69
69
 
70
70
  ```ts
71
71
  const hide = ctx.message.loading(ctx.t('Saving...'));
72
+ // Execute asynchronous operation
72
73
  await saveData();
73
- hide();
74
+ hide(); // Manually close loading
74
75
  ctx.message.success(ctx.t('Saved'));
75
76
  ```
76
77
 
77
- ### open with config
78
+ ### Custom Configuration with open
78
79
 
79
80
  ```ts
80
81
  ctx.message.open({
81
82
  type: 'success',
82
- content: 'Custom success',
83
+ content: 'Custom success prompt',
83
84
  duration: 5,
84
- onClose: () => console.log('closed'),
85
+ onClose: () => console.log('message closed'),
85
86
  });
86
87
  ```
87
88
 
88
- ### Close all
89
+ ### Close All Messages
89
90
 
90
91
  ```ts
91
92
  ctx.message.destroy();
92
93
  ```
93
94
 
94
- ## ctx.message vs ctx.notification
95
+ ## Difference Between ctx.message and ctx.notification
95
96
 
96
- | | ctx.message | ctx.notification |
97
- |---|-------------|-------------------|
98
- | **Position** | Top center | Top right |
99
- | **Use** | Short, auto-dismiss | Panel with title/description; can stay longer |
100
- | **Typical** | Action feedback, validation, copy | Task done, system notice, longer content |
97
+ | Feature | ctx.message | ctx.notification |
98
+ |------|--------------|------------------|
99
+ | **Position** | Top center of the page | Top right corner |
100
+ | **Purpose** | Temporary light prompt, disappears automatically | Notification panel, can include title and description, suitable for longer display |
101
+ | **Typical Scenarios** | Operation feedback, validation prompts, copy success | Task completion notifications, system messages, longer content requiring user attention |
101
102
 
102
103
  ## Related
103
104
 
104
- - [ctx.notification](./notification.md): top-right notifications
105
- - [ctx.modal](./modal.md): modal confirm
106
- - [ctx.t()](./t.md): i18n; often used with message
105
+ - [ctx.notification](./notification.md) - Top-right notifications, suitable for longer display durations
106
+ - [ctx.modal](./modal.md) - Modal confirmation, blocking interaction
107
+ - [ctx.t()](./t.md) - Internationalization, commonly used with message