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

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 (51) hide show
  1. package/dist/ai/docs/runjs/context/block-model.md +35 -35
  2. package/dist/ai/docs/runjs/context/collection-field.md +51 -53
  3. package/dist/ai/docs/runjs/context/collection.md +39 -39
  4. package/dist/ai/docs/runjs/context/data-source-manager.md +30 -40
  5. package/dist/ai/docs/runjs/context/data-source.md +44 -52
  6. package/dist/ai/docs/runjs/context/element.md +38 -44
  7. package/dist/ai/docs/runjs/context/exit-all.md +35 -37
  8. package/dist/ai/docs/runjs/context/exit.md +35 -38
  9. package/dist/ai/docs/runjs/context/filter-manager.md +30 -36
  10. package/dist/ai/docs/runjs/context/form.md +57 -57
  11. package/dist/ai/docs/runjs/context/get-model.md +21 -22
  12. package/dist/ai/docs/runjs/context/get-value.md +19 -20
  13. package/dist/ai/docs/runjs/context/get-var.md +55 -61
  14. package/dist/ai/docs/runjs/context/i18n.md +14 -17
  15. package/dist/ai/docs/runjs/context/import-async.md +45 -333
  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 +31 -34
  19. package/dist/ai/docs/runjs/context/logger.md +40 -41
  20. package/dist/ai/docs/runjs/context/make-resource.md +26 -27
  21. package/dist/ai/docs/runjs/context/message.md +41 -42
  22. package/dist/ai/docs/runjs/context/modal.md +44 -44
  23. package/dist/ai/docs/runjs/context/model.md +33 -36
  24. package/dist/ai/docs/runjs/context/notification.md +40 -41
  25. package/dist/ai/docs/runjs/context/off.md +14 -14
  26. package/dist/ai/docs/runjs/context/on.md +29 -30
  27. package/dist/ai/docs/runjs/context/open-view.md +40 -40
  28. package/dist/ai/docs/runjs/context/render.md +32 -37
  29. package/dist/ai/docs/runjs/context/request.md +45 -46
  30. package/dist/ai/docs/runjs/context/require-async.md +25 -28
  31. package/dist/ai/docs/runjs/context/resource.md +34 -34
  32. package/dist/ai/docs/runjs/context/route.md +34 -36
  33. package/dist/ai/docs/runjs/context/router.md +31 -43
  34. package/dist/ai/docs/runjs/context/set-value.md +17 -18
  35. package/dist/ai/docs/runjs/context/t.md +17 -20
  36. package/dist/ai/docs/runjs/context/view.md +46 -49
  37. package/dist/ai/docs/runjs/document.md +0 -1
  38. package/dist/ai/docs/runjs/import-modules.md +32 -32
  39. package/dist/ai/docs/runjs/index.md +13 -13
  40. package/dist/ai/docs/runjs/jsx.md +19 -19
  41. package/dist/ai/docs/runjs/model/form-block-model.md +3 -1
  42. package/dist/ai/docs/runjs/render.md +15 -15
  43. package/dist/ai/docs/runjs/resource/api-resource.md +53 -53
  44. package/dist/ai/docs/runjs/resource/multi-record-resource.md +64 -64
  45. package/dist/ai/docs/runjs/resource/single-record-resource.md +55 -55
  46. package/dist/ai/docs/runjs/resource/sql-resource.md +57 -57
  47. package/dist/ai/docs/runjs/window.md +5 -5
  48. package/dist/externalVersion.js +10 -10
  49. package/dist/node_modules/ses/package.json +1 -1
  50. package/dist/node_modules/zod/package.json +1 -1
  51. package/package.json +2 -2
@@ -1,39 +1,39 @@
1
1
  # ctx.libs
2
2
 
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`.
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.
4
4
 
5
5
  ## Use Cases
6
6
 
7
7
  | Scenario | Description |
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. |
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 |
12
12
 
13
- ## Built-in Libraries Overview
13
+ ## Built-in libraries
14
14
 
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/) |
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/) |
25
25
 
26
- ## Top-level Aliases
26
+ ## Top-level aliases
27
27
 
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.
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.
29
29
 
30
- ## Lazy Loading
30
+ ## Lazy loading
31
31
 
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.
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.
33
33
 
34
34
  ## Examples
35
35
 
36
- ### Rendering with React and Ant Design
36
+ ### 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
- ### Using Hooks
48
+ ### 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
- ### Using Icons
62
+ ### 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
- ### Date Processing with dayjs
71
+ ### 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
- ### Utility Functions with lodash
79
+ ### 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 Calculations
86
+ ### formula
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
- ### Mathematical Expressions with math.js
94
+ ### math
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 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.
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.
105
105
 
106
106
  ## Related
107
107
 
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
108
+ - [ctx.importAsync()](./import-async.md): load external ESM (e.g. specific React, Vue)
109
+ - [ctx.render()](./render.md): render into container
@@ -1,88 +1,85 @@
1
1
  # ctx.location
2
2
 
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.
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.
4
4
 
5
5
  ## Use Cases
6
6
 
7
7
  | Scenario | Description |
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. |
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` |
12
12
 
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).
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.
14
14
 
15
- ## Type Definition
15
+ ## Type
16
16
 
17
17
  ```ts
18
18
  location: Location;
19
19
  ```
20
20
 
21
- `Location` comes from `react-router-dom`, consistent with the return value of React Router's `useLocation()`.
21
+ `Location` is from `react-router-dom`, same as `useLocation()`.
22
22
 
23
23
  ## Common Fields
24
24
 
25
25
  | Field | Type | Description |
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"`. |
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"` |
32
32
 
33
- ## Relationship with ctx.router and ctx.urlSearchParams
33
+ ## Relation to ctx.router, ctx.urlSearchParams
34
34
 
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. |
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` |
40
40
 
41
- `ctx.urlSearchParams` is parsed from `ctx.location.search`. If you only need query parameters, using `ctx.urlSearchParams` is more convenient.
41
+ `ctx.urlSearchParams` is derived from `ctx.location.search`; use it when you only need query params.
42
42
 
43
43
  ## Examples
44
44
 
45
- ### Branching Based on Path
45
+ ### Branch by path
46
46
 
47
47
  ```ts
48
48
  if (ctx.location.pathname.startsWith('/admin/users')) {
49
- ctx.message.info('Currently on the user management page');
49
+ ctx.message.info('On user management page');
50
50
  }
51
51
  ```
52
52
 
53
- ### Parsing Query Parameters
53
+ ### Parse query params
54
54
 
55
55
  ```ts
56
- // Method 1: Using ctx.urlSearchParams (Recommended)
57
56
  const page = ctx.urlSearchParams.page || 1;
58
57
  const status = ctx.urlSearchParams.status;
59
58
 
60
- // Method 2: Using URLSearchParams to parse search
61
59
  const params = new URLSearchParams(ctx.location.search);
62
60
  const page = params.get('page') || '1';
63
61
  const status = params.get('status');
64
62
  ```
65
63
 
66
- ### Receiving State Passed via Route Navigation
64
+ ### Read state from navigation
67
65
 
68
66
  ```ts
69
- // When navigating from the previous page: ctx.router.navigate('/users/123', { state: { from: 'dashboard' } })
70
67
  const prevState = ctx.location.state;
71
68
  if (prevState?.from === 'dashboard') {
72
- ctx.message.info('Navigated from the dashboard');
69
+ ctx.message.info('Navigated from dashboard');
73
70
  }
74
71
  ```
75
72
 
76
- ### Locating Anchors via Hash
73
+ ### Anchor by hash
77
74
 
78
75
  ```ts
79
- const hash = ctx.location.hash; // e.g., "#edit"
76
+ const hash = ctx.location.hash;
80
77
  if (hash === '#edit') {
81
- // Scroll to the edit area or execute corresponding logic
78
+ // Scroll to edit or run logic
82
79
  }
83
80
  ```
84
81
 
85
82
  ## Related
86
83
 
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`.
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`
@@ -1,85 +1,84 @@
1
1
  # ctx.logger
2
2
 
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.
3
+ Logging built on [pino](https://github.com/pinojs/pino); outputs structured JSON. Prefer `ctx.logger` over `console` for collection and analysis.
4
4
 
5
- ## Scenarios
5
+ ## Use Cases
6
6
 
7
- `ctx.logger` can be used in all RunJS scenarios for debugging, error tracking, performance analysis, etc.
7
+ Available in all RunJS contexts for debugging, error tracking, and performance.
8
8
 
9
- ## Type Definition
9
+ ## Type
10
10
 
11
11
  ```ts
12
12
  logger: pino.Logger;
13
13
  ```
14
14
 
15
- `ctx.logger` is an instance of `engine.logger.child({ module: 'flow-engine' })`, which is a pino child logger with a `module` context.
15
+ `ctx.logger` is `engine.logger.child({ module: 'flow-engine' })`, i.e. a pino child logger with a `module` context.
16
16
 
17
- ## Log Levels
17
+ ## Log levels
18
18
 
19
- pino supports the following levels (from highest to lowest):
19
+ From highest to lowest:
20
20
 
21
21
  | Level | Method | Description |
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 |
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 |
29
29
 
30
- ## Recommended Usage
30
+ ## Recommended usage
31
31
 
32
- The recommended format is `level(msg, meta)`: the message comes first, followed by an optional metadata object.
32
+ Use `level(msg, meta)`: message first, optional metadata object second.
33
33
 
34
34
  ```ts
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' });
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' });
39
39
  ctx.logger.error('Request failed', { err });
40
40
  ```
41
41
 
42
- pino also supports `level(meta, msg)` (object first) or `level({ msg, ...meta })` (single object), which can be used as needed.
42
+ pino also supports `level(meta, msg)` or `level({ msg, ...meta })` if needed.
43
43
 
44
44
  ## Examples
45
45
 
46
- ### Basic Usage
46
+ ### Basic
47
47
 
48
48
  ```ts
49
- ctx.logger.info('Block loading complete');
49
+ ctx.logger.info('Block loaded');
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
- ### Creating a Child Logger with child()
54
+ ### Child logger
55
55
 
56
56
  ```ts
57
- // Create a child logger with context for the current logic
58
57
  const log = ctx.logger.child({ scope: 'myBlock' });
59
- log.info('Executing step 1');
60
- log.debug('Executing step 2', { step: 2 });
58
+ log.info('Step 1');
59
+ log.debug('Step 2', { step: 2 });
61
60
  ```
62
61
 
63
- ### Relationship with console
62
+ ### vs console
64
63
 
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`.
64
+ Prefer `ctx.logger` for structured JSON. Rough mapping: `console.log` → `ctx.logger.info`, `console.error` → `ctx.logger.error`, `console.warn` → `ctx.logger.warn`.
66
65
 
67
- ## Log Format
66
+ ## Output format
68
67
 
69
- pino outputs structured JSON, where each log entry contains:
68
+ pino outputs JSON with:
70
69
 
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)
70
+ - `level`: numeric level
71
+ - `time`: timestamp (ms)
72
+ - `msg`: message
73
+ - `module`: `flow-engine`
74
+ - Any custom fields passed in the object
76
75
 
77
76
  ## Notes
78
77
 
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.
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
82
81
 
83
82
  ## Related
84
83
 
85
- - [pino](https://github.com/pinojs/pino) — The underlying logging library
84
+ - [pino](https://github.com/pinojs/pino)
@@ -1,18 +1,18 @@
1
1
  # ctx.makeResource()
2
2
 
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.
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.
4
4
 
5
5
  ## Use Cases
6
6
 
7
7
  | Scenario | Description |
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. |
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 |
12
12
 
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.
13
+ If you only need one resource and want it on `ctx.resource`, use [ctx.initResource()](./init-resource.md).
14
14
 
15
- ## Type Definition
15
+ ## Type
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` | Resource type: `'APIResource'`, `'SingleRecordResource'`, `'MultiRecordResource'`, `'SQLResource'` |
24
+ |-----------|------|-------------|
25
+ | `resourceType` | `string` | `'APIResource'`, `'SingleRecordResource'`, `'MultiRecordResource'`, `'SQLResource'` |
26
26
 
27
- **Returns**: The newly created resource instance.
27
+ **Returns**: The new resource instance.
28
28
 
29
- ## Difference from ctx.initResource()
29
+ ## Relation to ctx.initResource()
30
30
 
31
31
  | Method | Behavior |
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. |
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 |
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 remains its original value (if any)
45
+ // ctx.resource unchanged (if it existed)
46
46
  ```
47
47
 
48
48
  ### Multiple resources
@@ -58,16 +58,15 @@ await ordersRes.refresh();
58
58
 
59
59
  ctx.render(
60
60
  <div>
61
- <p>User count: {usersRes.getData().length}</p>
62
- <p>Order count: {ordersRes.getData().length}</p>
61
+ <p>Users: {usersRes.getData().length}</p>
62
+ <p>Orders: {ordersRes.getData().length}</p>
63
63
  </div>
64
64
  );
65
65
  ```
66
66
 
67
- ### Temporary query
67
+ ### One-off query
68
68
 
69
69
  ```ts
70
- // One-time query, does not pollute ctx.resource
71
70
  const tempRes = ctx.makeResource('SingleRecordResource');
72
71
  tempRes.setResourceName('users');
73
72
  tempRes.setFilterByTk(1);
@@ -77,14 +76,14 @@ const record = tempRes.getData();
77
76
 
78
77
  ## Notes
79
78
 
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.
79
+ - Call `setResourceName(name)` then `refresh()` to load data.
80
+ - Each instance is independent; good for loading several sources in parallel.
82
81
 
83
82
  ## Related
84
83
 
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
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)
@@ -1,63 +1,63 @@
1
1
  # ctx.message
2
2
 
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.
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.
4
4
 
5
5
  ## Use Cases
6
6
 
7
7
  | Scenario | Description |
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. |
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 |
12
12
 
13
- ## Type Definition
13
+ ## Type
14
14
 
15
15
  ```ts
16
16
  message: MessageInstance;
17
17
  ```
18
18
 
19
- `MessageInstance` is the Ant Design message interface, providing the following methods.
19
+ `MessageInstance` is the Ant Design message API.
20
20
 
21
21
  ## Common Methods
22
22
 
23
23
  | Method | Description |
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 |
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 |
32
32
 
33
33
  **Parameters:**
34
34
 
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
35
+ - `content`: `string` or `ConfigOptions`
36
+ - `duration`: optional seconds; default 3; 0 = no 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; // Message content
43
- duration?: number; // Auto-close delay (seconds)
44
- onClose?: () => void; // Callback when closed
45
- icon?: React.ReactNode; // Custom icon
42
+ content: React.ReactNode;
43
+ duration?: number;
44
+ onClose?: () => void;
45
+ icon?: React.ReactNode;
46
46
  }
47
47
  ```
48
48
 
49
49
  ## Examples
50
50
 
51
- ### Basic Usage
51
+ ### Basic
52
52
 
53
53
  ```ts
54
- ctx.message.success('Operation successful');
55
- ctx.message.error('Operation failed');
54
+ ctx.message.success('Done');
55
+ ctx.message.error('Failed');
56
56
  ctx.message.warning('Please select data first');
57
57
  ctx.message.info('Processing...');
58
58
  ```
59
59
 
60
- ### Internationalization with ctx.t
60
+ ### With ctx.t (i18n)
61
61
 
62
62
  ```ts
63
63
  ctx.message.success(ctx.t('Copied'));
@@ -65,43 +65,42 @@ 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
73
72
  await saveData();
74
- hide(); // Manually close loading
73
+ hide();
75
74
  ctx.message.success(ctx.t('Saved'));
76
75
  ```
77
76
 
78
- ### Custom Configuration with open
77
+ ### open with config
79
78
 
80
79
  ```ts
81
80
  ctx.message.open({
82
81
  type: 'success',
83
- content: 'Custom success prompt',
82
+ content: 'Custom success',
84
83
  duration: 5,
85
- onClose: () => console.log('message closed'),
84
+ onClose: () => console.log('closed'),
86
85
  });
87
86
  ```
88
87
 
89
- ### Close All Messages
88
+ ### Close all
90
89
 
91
90
  ```ts
92
91
  ctx.message.destroy();
93
92
  ```
94
93
 
95
- ## Difference Between ctx.message and ctx.notification
94
+ ## ctx.message vs ctx.notification
96
95
 
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 |
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 |
102
101
 
103
102
  ## Related
104
103
 
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
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