Skip to content

Commit

Permalink
refactor: workflow links (nocobase#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
mytharcher authored Aug 17, 2024
1 parent b40d958 commit e428ead
Show file tree
Hide file tree
Showing 153 changed files with 1,243 additions and 670 deletions.
2 changes: 1 addition & 1 deletion .dumi/theme/builtins/PluginInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const PluginInfo = (props) => {
{zhCN ? (
<p>该功能由{commercial ? '商业' : ''}插件 <Link to={link ?? `/handbook/${name}`}>plugin-{name}</Link> 提供{commercial && <>,请查看 <a target="_blank" href="https://www.nocobase.com/cn/plugins">商业授权</a> 了解详情</>}</p>
) : (
<p>This feature is provided by the {commercial ? 'commercial ' : ''}plugin <Link to={`/handbook/${name}`}>plugin-{name}</Link>. {commercial && <><br/> Please refer to the <a target="_blank" href="https://www.nocobase.com/en/plugins">commercial license</a> for details.</>}</p>
<p>This feature is provided by the {commercial ? 'commercial ' : ''}plugin <Link to={link ?? `/handbook/${name}`}>plugin-{name}</Link>. {commercial && <><br/> Please refer to the <a target="_blank" href="https://www.nocobase.com/en/plugins">commercial license</a> for details.</>}</p>
)}
</section>
</div>
Expand Down
93 changes: 51 additions & 42 deletions docs/config/handbook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export default [
{
title: 'Expression collection',
'title.zh-CN': '表达式表',
link: '/handbook/workflow/plugins/dynamic-calculation/collection',
link: '/handbook/workflow-dynamic-calculation/collection',
},
{
title: 'SQL collection',
Expand Down Expand Up @@ -1358,7 +1358,16 @@ export default [
children: [
'/handbook/workflow',
'/handbook/workflow/quick-start',
'/handbook/workflow/advanced',
{
title: 'Advanced',
'title.zh-CN': '进阶理解',
children: [
'/handbook/workflow/advanced/variables',
'/handbook/workflow/advanced/executions',
'/handbook/workflow/advanced/revisions',
'/handbook/workflow/advanced/options',
],
},
{
title: 'Triggers',
'title.zh-CN': '触发器',
Expand Down Expand Up @@ -1446,127 +1455,127 @@ export default [
'title.zh-CN': '操作后事件',
subTitle: '@nocobase/plugin-workflow-action-trigger',
children: [
'/handbook/workflow/plugins/action-trigger',
'/handbook/workflow/plugins/action-trigger/trigger',
'/handbook/workflow/plugins/action-trigger/action',
'/handbook/workflow/plugins/action-trigger/example',
'/handbook/workflow/plugins/action-trigger/http-api',
'/handbook/workflow-action-trigger',
'/handbook/workflow-action-trigger/trigger',
'/handbook/workflow-action-trigger/action',
'/handbook/workflow-action-trigger/example',
'/handbook/workflow-action-trigger/http-api',
],
},
{
title: 'Aggregate',
'title.zh-CN': '聚合查询',
subTitle: '@nocobase/plugin-workflow-aggregate',
link: '/handbook/workflow/plugins/aggregate',
link: '/handbook/workflow-aggregate',
},
{
title: 'Approval',
'title.zh-CN': '审批',
subTitle: '@nocobase/plugin-workflow-approval',
children: [
'/handbook/workflow/plugins/approval',
'/handbook/workflow/plugins/approval/trigger',
'/handbook/workflow/plugins/approval/node',
'/handbook/workflow/plugins/approval/action',
'/handbook/workflow/plugins/approval/block',
'/handbook/workflow/plugins/approval/advanced',
'/handbook/workflow/plugins/approval/http-api',
'/handbook/workflow-approval',
'/handbook/workflow-approval/trigger',
'/handbook/workflow-approval/node',
'/handbook/workflow-approval/action',
'/handbook/workflow-approval/block',
'/handbook/workflow-approval/advanced',
'/handbook/workflow-approval/http-api',
],
},
{
title: 'Custom action trigger',
'title.zh-CN': '自定义操作事件',
subTitle: '@nocobase/plugin-workflow-custom-action-trigger',
children: [
'/handbook/workflow/plugins/custom-action-trigger',
'/handbook/workflow/plugins/custom-action-trigger/trigger',
'/handbook/workflow/plugins/custom-action-trigger/action',
'/handbook/workflow/plugins/custom-action-trigger/example',
'/handbook/workflow/plugins/custom-action-trigger/http-api',
'/handbook/workflow-custom-action-trigger',
'/handbook/workflow-custom-action-trigger/trigger',
'/handbook/workflow-custom-action-trigger/action',
'/handbook/workflow-custom-action-trigger/example',
'/handbook/workflow-custom-action-trigger/http-api',
],
},
{
title: 'Delay',
'title.zh-CN': '延时',
subTitle: '@nocobase/plugin-workflow-delay',
link: '/handbook/workflow/plugins/delay',
link: '/handbook/workflow-delay',
},
{
title: 'Dynamic calculation',
'title.zh-CN': '动态表达式',
subTitle: '@nocobase/plugin-workflow-dynamic-calculation',
children: [
'/handbook/workflow/plugins/dynamic-calculation',
'/handbook/workflow/plugins/dynamic-calculation/collection',
'/handbook/workflow/plugins/dynamic-calculation/node',
'/handbook/workflow-dynamic-calculation',
'/handbook/workflow-dynamic-calculation/collection',
'/handbook/workflow-dynamic-calculation/node',
],
},
{
title: 'JSON query',
'title.zh-CN': 'JSON 解析',
subTitle: '@nocobase/plugin-workflow-json-query',
link: '/handbook/workflow/plugins/json-query',
link: '/handbook/workflow-json-query',
},
{
title: 'Loop',
'title.zh-CN': '循环',
subTitle: '@nocobase/plugin-workflow-loop',
link: '/handbook/workflow/plugins/loop',
link: '/handbook/workflow-loop',
},
{
title: 'Manual process',
'title.zh-CN': '人工处理',
subTitle: '@nocobase/plugin-workflow-manual',
children: [
'/handbook/workflow/plugins/manual',
'/handbook/workflow/plugins/manual/node',
'/handbook/workflow/plugins/manual/block',
'/handbook/workflow/plugins/manual/example',
'/handbook/workflow-manual',
'/handbook/workflow-manual/node',
'/handbook/workflow-manual/block',
'/handbook/workflow-manual/example',
],
},
{
title: 'Parallel',
'title.zh-CN': '并行分支',
subTitle: '@nocobase/plugin-workflow-parallel',
link: '/handbook/workflow/plugins/parallel',
link: '/handbook/workflow-parallel',
},
{
title: 'HTTP Request',
'title.zh-CN': 'HTTP 请求',
subTitle: '@nocobase/plugin-workflow-request',
link: '/handbook/workflow/plugins/request',
link: '/handbook/workflow-request',
},
{
title: 'Pre-action trigger',
'title.zh-CN': '操作前事件',
subTitle: '@nocobase/plugin-workflow-request-interceptor',
link: '/handbook/workflow/plugins/request-interceptor',
link: '/handbook/workflow-request-interceptor',
children: [
'/handbook/workflow/plugins/request-interceptor',
'/handbook/workflow/plugins/request-interceptor/trigger',
'/handbook/workflow/plugins/request-interceptor/action',
'/handbook/workflow/plugins/request-interceptor/advanced',
'/handbook/workflow/plugins/request-interceptor/example',
'/handbook/workflow/plugins/request-interceptor/http-api',
'/handbook/workflow-request-interceptor',
'/handbook/workflow-request-interceptor/trigger',
'/handbook/workflow-request-interceptor/action',
'/handbook/workflow-request-interceptor/advanced',
'/handbook/workflow-request-interceptor/example',
'/handbook/workflow-request-interceptor/http-api',
],
},
{
title: 'Response message',
'title.zh-CN': '响应消息',
subTitle: '@nocobase/plugin-workflow-response-message',
link: '/handbook/workflow/plugins/response-message',
link: '/handbook/workflow-response-message',
},
{
title: 'SQL action',
'title.zh-CN': 'SQL 操作',
subTitle: '@nocobase/plugin-workflow-sql',
link: '/handbook/workflow/plugins/sql',
link: '/handbook/workflow-sql',
},
{
title: 'Custom variable',
'title.zh-CN': '自定义变量',
subTitle: '@nocobase/plugin-workflow-variable',
link: '/handbook/workflow/plugins/variable',
link: '/handbook/workflow-variable',
},
],
},
Expand Down
53 changes: 27 additions & 26 deletions docs/en-US/api/server/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,28 +90,6 @@ Executed before the plugin is removed.

Executed after the plugin is removed.

### `onSync()`

In a distributed environment, handle synchronization events published by the current plugin from other nodes. When the plugin uses memory state, it is necessary to override the event handling logic to ensure synchronization with the state of other nodes.

#### Signature

```
onSync(message: SyncMessage): void | Promise<void>
```

#### Arguments

- `message`: Sync message data from other nodes.

#### Example

```ts
onSync(message: SyncMessage) {
console.log('onSync', message);
// this.reloadData();
}
```

## Other Methods

Expand All @@ -127,24 +105,47 @@ Creates a logger. Refer to [Logger](../logger.md).

A method for internal use. Outputs plugin-related configuration information.

### `sync()`
### `sendSyncMessage()`

Publish synchronization messages. The synchronization messages sent by this method will only be received by the same plugin on other nodes, and will not be related to other plugins.

#### Signature

```ts
sync(data: SyncMessageData = {}): void | Promise<void>
sendSyncMessage(message: any): void | Promise<void>
```

#### Arguments

- `data`: Sync message data, in key-value pair format. The keys and values must be strings.
- `message`: Sync message data.

#### Example

```ts
this.sync({
this.sendSyncMessage({
key: 'value'
});
```

### `handleSyncMessage()`

In a distributed environment, handle synchronization events published by the current plugin from other nodes. When the plugin uses memory state, it is necessary to override the event handling logic to ensure synchronization with the state of other nodes.

#### Signature

```
handleSyncMessage(message: any): void | Promise<void>
```

#### Arguments

- `message`: Sync message data from other nodes.

#### Example

```ts
handleSyncMessage(message: SyncMessage) {
console.log('handleSyncMessage', message);
// this.reloadData();
}
```
74 changes: 0 additions & 74 deletions docs/en-US/api/server/sync-manager.md

This file was deleted.

37 changes: 37 additions & 0 deletions docs/en-US/api/server/sync-message-manager.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SyncMessageManager

Used to manage synchronization signals between multiple application nodes. In a distributed deployment, when the memory state changes, it is necessary to notify other nodes for synchronization. `SyncMessageManager` provides a common interface to be invoked, allowing it to be used in same way across different modules.

The SyncMessageManager itself does not implement specific synchronization functionality, but provides a unified interface, and it will invoke the underlying `pubSubManager` to send and receive messages.

## `SyncMessageManager`

### Members

#### `constructor()`

Constructor, creates an instance of the SyncMessageManager. An instance is automatically created during application initialization and is accessible globally within the application (`app.syncMessageManager`), so there is no need to call it.

#### `subscribe(channel: string, callback: SyncEventCallback)`

Subscribes to sync events.

- `channel`: Channel name to differentiate between different sync events.
- `callback`: Event callback function, called when a sync event occurs.

#### `unsubscribe(channel: string, callback: SyncEventCallback)`

Unsubscribes from sync events.

#### `publish(channel: string, message: any)`

Publishes a sync message.

- `channel`: Channel name to differentiate between different sync events.
- `message`: Sync message data.

### Related Types

```ts
export type PubSubCallback = (message: any) => Promise<void>;
```
Loading

0 comments on commit e428ead

Please sign in to comment.