@kimposoft/plugin-sdk 0.0.0-stage → 1.1.0-tp.20
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.
- package/LICENSE +202 -0
- package/NOTICE +9 -0
- package/README.md +48 -2
- package/package.json +141 -4
- package/src/action-designer.ts +250 -0
- package/src/attachment-url.ts +195 -0
- package/src/auth/index.ts +6 -0
- package/src/auth/qrcode.ts +519 -0
- package/src/auth/types.ts +261 -0
- package/src/display-style.ts +250 -0
- package/src/editor-frame.ts +623 -0
- package/src/editor-session.ts +1214 -0
- package/src/editor-testing.ts +838 -0
- package/src/editor.ts +1641 -0
- package/src/frame-transport.ts +491 -0
- package/src/frontend-routes.ts +99 -0
- package/src/hooks.ts +48 -0
- package/src/host-caps.ts +93 -0
- package/src/i18n.ts +238 -0
- package/src/im-panel.ts +132 -0
- package/src/image-tools.ts +91 -0
- package/src/index.ts +118 -0
- package/src/interactive-session.ts +94 -0
- package/src/nahida-im.ts +391 -0
- package/src/nahida-ws.ts +23 -0
- package/src/org-directory.ts +78 -0
- package/src/oz-realtime.ts +144 -0
- package/src/page.ts +404 -0
- package/src/print.ts +393 -0
- package/src/surface.ts +281 -0
- package/src/theme-mocks.ts +140 -0
- package/src/theme.ts +125 -0
- package/src/ui-fixtures/confirm.ts +16 -0
- package/src/ui-fixtures/entity-picker.ts +24 -0
- package/src/ui-fixtures/expression-editor.ts +52 -0
- package/src/ui-fixtures/image-cropper.ts +23 -0
- package/src/ui-fixtures/index.ts +16 -0
- package/src/ui-fixtures/org-tri-picker.ts +19 -0
- package/src/ui-fixtures/prompt.ts +19 -0
- package/src/ui-fixtures/record-picker.ts +17 -0
- package/src/ui-fixtures/template-picker.ts +13 -0
- package/src/ui-mocks.ts +250 -0
- package/src/ui.ts +479 -0
- package/src/workflow-designer.ts +475 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Kimpo Plugin SDK
|
|
2
|
+
Copyright 2026 金宝量行(无锡)软件有限公司
|
|
3
|
+
|
|
4
|
+
This product is licensed under the Apache License, Version 2.0
|
|
5
|
+
(see the LICENSE file in this repository).
|
|
6
|
+
|
|
7
|
+
This repository includes code generated by protoc-gen-go and
|
|
8
|
+
protoc-gen-go-grpc from the .proto files under proto/. The generated
|
|
9
|
+
code is distributed under the same license as this repository.
|
package/README.md
CHANGED
|
@@ -1,3 +1,49 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @kimposoft/plugin-sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Kimpo 插件的前端契约包:surface 挂载、宿主桥(hostBridge)能力面、宿主 UI 服务、主题、多语言、登录页与历史记录页等类型定义,以及少量零依赖的运行时辅助函数(`definePluginSurface`、`createPluginI18n`、`formatDisplayStyleValue` 等)。
|
|
4
|
+
|
|
5
|
+
- **不是纯类型包**:`definePluginSurface`、`definePluginLoginSurface`、`defineImPanelSurface`、`definePrintModeBuildSpec`(含打印方案运行时)、沙箱框架传输(`./frame`)、`createPluginI18n` 等是真运行时代码,用到时会打进你的 bundle。
|
|
6
|
+
- **以 TypeScript 源码发布**(`exports` 指向 `src/*.ts`,包里没有编译好的 `.js` / `.d.ts`):构建工具必须能编译依赖里的 TS——vite、esbuild、`tsc` 都可以;纯 JS + webpack 的工程要给 `node_modules/@kimposoft/plugin-sdk` 配 `ts-loader` / `babel-loader`(`@babel/preset-typescript`),否则会报语法错误。
|
|
7
|
+
- 没有第三方运行时依赖;版本与 Go SDK 模块 tag 对齐(`1.1.0-tp.20` ↔ `v1.1.0-tp.20`)。
|
|
8
|
+
- 许可证:Apache-2.0(见 `LICENSE` 与 `NOTICE`)。
|
|
9
|
+
|
|
10
|
+
## 安装
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
# npm 公共源(预览版在 dist-tag next)
|
|
14
|
+
npm install @kimposoft/plugin-sdk@next # 或锁定版本:@1.1.0-tp.20
|
|
15
|
+
|
|
16
|
+
# 离线:用离线开发包(或 SDK 仓库 frontend/ 目录 npm pack)产出的 tarball
|
|
17
|
+
npm install ./kimposoft-plugin-sdk-1.1.0-tp.20.tgz
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**不要外部化**本包:它的运行时辅助函数会被打进插件 bundle。只有 `vue` 需要外部化(宿主框架提供 `window.Vue`);`naive-ui` 等其他依赖用到就打进 bundle。
|
|
21
|
+
|
|
22
|
+
## 入口
|
|
23
|
+
|
|
24
|
+
根入口 `@kimposoft/plugin-sdk` 重导出绝大多数契约;也可以按子路径导入:
|
|
25
|
+
|
|
26
|
+
| 子路径 | 内容 |
|
|
27
|
+
|---|---|
|
|
28
|
+
| `.` | 根入口(surface、editor、hooks、ui、theme、i18n、page、auth、附件与展示样式工具等) |
|
|
29
|
+
| `./surface` | 通用 surface 挂载契约(`definePluginSurface`) |
|
|
30
|
+
| `./editor` | 编辑器插件契约与宿主桥 |
|
|
31
|
+
| `./hooks` | 宿主扩展槽注册契约 |
|
|
32
|
+
| `./ui` / `./ui-mocks` / `./ui-fixtures` | 宿主 UI 服务(表达式编辑器、选人、确认框等)及测试用 mock 与夹具 |
|
|
33
|
+
| `./theme` / `./theme-mocks` | 宿主设计数值(theme 能力)及测试用 mock |
|
|
34
|
+
| `./host-caps` | hostCaps 白名单裁剪 |
|
|
35
|
+
| `./i18n` | 多语言契约与两级查找 helper |
|
|
36
|
+
| `./page` | 历史记录页(page-slot)契约 |
|
|
37
|
+
| `./auth` | 登录页插件契约 |
|
|
38
|
+
| `./action-designer` | 动作设计器插件契约(只走子路径) |
|
|
39
|
+
| `./workflow-designer` | 流程设计器插件契约 |
|
|
40
|
+
| `./nahida-im` / `./nahida-ws` / `./org-directory` | 消息引擎前端契约、WS 长连接、组织架构取人 |
|
|
41
|
+
| `./oz-realtime` | 宿主实时订阅通道 |
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { definePluginSurface, createPluginI18n, type SurfaceCreateInput } from '@kimposoft/plugin-sdk';
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## 文档
|
|
48
|
+
|
|
49
|
+
SDK 仓库 <https://github.com/kimposoft/kimpo-plugin-sdk> 的 `docs/third-party/`:从开发实例、manifest、前端构建约定(`frontend-build.md`)到各类插件的接入说明与已知限制。
|
package/package.json
CHANGED
|
@@ -1,6 +1,143 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kimposoft/plugin-sdk",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.1.0-tp.20",
|
|
4
|
+
"description": "Kimpo 插件前端 SDK:契约类型 + 少量运行时代码(挂载点 / 登录页 / 打印方案登记、沙箱框架桥、多语言等,会打进插件 bundle),无第三方运行时依赖;以 TypeScript 源码发布(exports 指向 src/*.ts),需用能编译 TS 的构建工具(vite、esbuild、tsc 等)",
|
|
5
|
+
"homepage": "https://github.com/kimposoft/kimpo-plugin-sdk#readme",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/kimposoft/kimpo-plugin-sdk.git",
|
|
9
|
+
"directory": "frontend"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/kimposoft/kimpo-plugin-sdk/issues"
|
|
13
|
+
},
|
|
14
|
+
"typesVersions": {
|
|
15
|
+
"*": {
|
|
16
|
+
"surface": [
|
|
17
|
+
"./src/surface.ts"
|
|
18
|
+
],
|
|
19
|
+
"frame": [
|
|
20
|
+
"./src/frame-transport.ts"
|
|
21
|
+
],
|
|
22
|
+
"print": [
|
|
23
|
+
"./src/print.ts"
|
|
24
|
+
],
|
|
25
|
+
"host-caps": [
|
|
26
|
+
"./src/host-caps.ts"
|
|
27
|
+
],
|
|
28
|
+
"ui": [
|
|
29
|
+
"./src/ui.ts"
|
|
30
|
+
],
|
|
31
|
+
"ui-mocks": [
|
|
32
|
+
"./src/ui-mocks.ts"
|
|
33
|
+
],
|
|
34
|
+
"theme": [
|
|
35
|
+
"./src/theme.ts"
|
|
36
|
+
],
|
|
37
|
+
"theme-mocks": [
|
|
38
|
+
"./src/theme-mocks.ts"
|
|
39
|
+
],
|
|
40
|
+
"ui-fixtures": [
|
|
41
|
+
"./src/ui-fixtures/index.ts"
|
|
42
|
+
],
|
|
43
|
+
"editor": [
|
|
44
|
+
"./src/editor.ts"
|
|
45
|
+
],
|
|
46
|
+
"editor-frame": [
|
|
47
|
+
"./src/editor-frame.ts"
|
|
48
|
+
],
|
|
49
|
+
"editor-session": [
|
|
50
|
+
"./src/editor-session.ts"
|
|
51
|
+
],
|
|
52
|
+
"editor-testing": [
|
|
53
|
+
"./src/editor-testing.ts"
|
|
54
|
+
],
|
|
55
|
+
"hooks": [
|
|
56
|
+
"./src/hooks.ts"
|
|
57
|
+
],
|
|
58
|
+
"nahida-im": [
|
|
59
|
+
"./src/nahida-im.ts"
|
|
60
|
+
],
|
|
61
|
+
"org-directory": [
|
|
62
|
+
"./src/org-directory.ts"
|
|
63
|
+
],
|
|
64
|
+
"nahida-ws": [
|
|
65
|
+
"./src/nahida-ws.ts"
|
|
66
|
+
],
|
|
67
|
+
"oz-realtime": [
|
|
68
|
+
"./src/oz-realtime.ts"
|
|
69
|
+
],
|
|
70
|
+
"action-designer": [
|
|
71
|
+
"./src/action-designer.ts"
|
|
72
|
+
],
|
|
73
|
+
"im-panel": [
|
|
74
|
+
"./src/im-panel.ts"
|
|
75
|
+
],
|
|
76
|
+
"workflow-designer": [
|
|
77
|
+
"./src/workflow-designer.ts"
|
|
78
|
+
],
|
|
79
|
+
"i18n": [
|
|
80
|
+
"./src/i18n.ts"
|
|
81
|
+
],
|
|
82
|
+
"page": [
|
|
83
|
+
"./src/page.ts"
|
|
84
|
+
],
|
|
85
|
+
"auth": [
|
|
86
|
+
"./src/auth/index.ts"
|
|
87
|
+
],
|
|
88
|
+
"*": [
|
|
89
|
+
"./src/*"
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"exports": {
|
|
94
|
+
".": "./src/index.ts",
|
|
95
|
+
"./surface": "./src/surface.ts",
|
|
96
|
+
"./frame": "./src/frame-transport.ts",
|
|
97
|
+
"./print": "./src/print.ts",
|
|
98
|
+
"./host-caps": "./src/host-caps.ts",
|
|
99
|
+
"./ui": "./src/ui.ts",
|
|
100
|
+
"./ui-mocks": "./src/ui-mocks.ts",
|
|
101
|
+
"./theme": "./src/theme.ts",
|
|
102
|
+
"./theme-mocks": "./src/theme-mocks.ts",
|
|
103
|
+
"./ui-fixtures": "./src/ui-fixtures/index.ts",
|
|
104
|
+
"./editor": "./src/editor.ts",
|
|
105
|
+
"./editor-frame": "./src/editor-frame.ts",
|
|
106
|
+
"./editor-session": "./src/editor-session.ts",
|
|
107
|
+
"./editor-testing": "./src/editor-testing.ts",
|
|
108
|
+
"./hooks": "./src/hooks.ts",
|
|
109
|
+
"./nahida-im": "./src/nahida-im.ts",
|
|
110
|
+
"./org-directory": "./src/org-directory.ts",
|
|
111
|
+
"./nahida-ws": "./src/nahida-ws.ts",
|
|
112
|
+
"./oz-realtime": "./src/oz-realtime.ts",
|
|
113
|
+
"./action-designer": "./src/action-designer.ts",
|
|
114
|
+
"./im-panel": "./src/im-panel.ts",
|
|
115
|
+
"./workflow-designer": "./src/workflow-designer.ts",
|
|
116
|
+
"./i18n": "./src/i18n.ts",
|
|
117
|
+
"./page": "./src/page.ts",
|
|
118
|
+
"./auth": "./src/auth/index.ts"
|
|
119
|
+
},
|
|
120
|
+
"scripts": {
|
|
121
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
122
|
+
"test": "vitest run"
|
|
123
|
+
},
|
|
124
|
+
"devDependencies": {
|
|
125
|
+
"@types/node": "22.15.30",
|
|
126
|
+
"typescript": "5.8.3",
|
|
127
|
+
"vitest": "3.2.4"
|
|
128
|
+
},
|
|
129
|
+
"files": [
|
|
130
|
+
"src",
|
|
131
|
+
"!src/**/*.test.ts",
|
|
132
|
+
"!src/**/*.spec.ts",
|
|
133
|
+
"!src/**/*.selftest.ts",
|
|
134
|
+
"!src/**/__tests__",
|
|
135
|
+
"README.md",
|
|
136
|
+
"NOTICE"
|
|
137
|
+
],
|
|
138
|
+
"license": "Apache-2.0",
|
|
139
|
+
"publishConfig": {
|
|
140
|
+
"access": "public",
|
|
141
|
+
"tag": "next"
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* action-designer.ts —— 动作设计器插件(surfaceType='action-designer')的公开契约。
|
|
3
|
+
*
|
|
4
|
+
* 宿主在模板设计器工具栏「动作」(或定时任务设计)里挂载 action-designer surface,并向插件提供:
|
|
5
|
+
* - hostBridge['domain:action-designer']:ActionDesignerHostApi(宿主实现以类型断言绑定本接口);
|
|
6
|
+
* - 组件 prop `input`:ActionDesignerSurfaceInput(模板模式 / 定时任务模式)。
|
|
7
|
+
* 动作行为文档 BehaviorDocument 是插件保存给宿主、宿主动作管线执行的结构。
|
|
8
|
+
*
|
|
9
|
+
* 本文件只承诺列出的方法与字段;宿主实现可能有更多方法,不在公开契约内的不要依赖。
|
|
10
|
+
*
|
|
11
|
+
* 挂载档(1.1.0-tp.5 起第三方可用沙箱档):
|
|
12
|
+
* - 第三方一律在宿主沙箱框架(iframe)里运行。宿主把框架放在一个只在 input.visible 时显示的透明全屏层里,
|
|
13
|
+
* 插件照常自己画遮罩与对话框(position: fixed 相对框架视口,恰好铺满页面);
|
|
14
|
+
* - hostBridge 上的方法全部是远程调用(返回 Promise);`interactiveSession.snapshot` 是挂载时快照,后续变化
|
|
15
|
+
* 经 `onChange` 回调推送,`onChange` 的返回值在沙箱档是 `Promise<() => void>`,用 `disposerOf()` 统一成同步退订;
|
|
16
|
+
* - 沙箱档 `domain:action-designer` 只开放 {@link ACTION_DESIGNER_FRAME_HOST_API_METHODS} 列出的方法,返回值收敛为
|
|
17
|
+
* `{ data, error }` 纯数据;宿主组件类能力(嵌套动作配置面板、表达式宿主、缩略图渲染器)与窗口尺寸记忆不开放。
|
|
18
|
+
*/
|
|
19
|
+
import { definePluginSurface, type SurfaceCreateInput, type SurfaceMountResult } from './surface';
|
|
20
|
+
import type { InteractiveSessionHandle } from './interactive-session';
|
|
21
|
+
|
|
22
|
+
/** 宿主 request() 的扁平信封:成功 { data, error:null },失败 { data?, error }。 */
|
|
23
|
+
export interface HostResult<T> {
|
|
24
|
+
data?: T | null;
|
|
25
|
+
error?: { code?: string; message?: string; response?: { data?: unknown } } | null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** 模板模式作用域(宿主经 input.scope 传入,原样回传给宿主方法)。 */
|
|
29
|
+
export interface ActionDesignerScope {
|
|
30
|
+
appId: string;
|
|
31
|
+
templateId: string;
|
|
32
|
+
templateVersionNo: string;
|
|
33
|
+
designerType?: string;
|
|
34
|
+
pluginId?: string;
|
|
35
|
+
pluginInstanceId?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** 多语言文本:字符串或按 locale 的对象。 */
|
|
39
|
+
export type LocalizedText = string | Record<string, string>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 数据动作的标准操作种类(闭集):取数到表单 / 新增 / 修改 / 删除记录。
|
|
43
|
+
* 与 manifest `capabilities.data_actions[].operation_kind`、Go SDK `biz.DataActionKind` 取值一致。
|
|
44
|
+
*/
|
|
45
|
+
export type DataActionKind = 'fetch' | 'create' | 'update' | 'delete';
|
|
46
|
+
|
|
47
|
+
/** 数据动作种类闭集(固定顺序)。 */
|
|
48
|
+
export const DATA_ACTION_KINDS: readonly DataActionKind[] = ['fetch', 'create', 'update', 'delete'];
|
|
49
|
+
|
|
50
|
+
/** 判断字符串是否为数据动作种类(大小写敏感)。 */
|
|
51
|
+
export function isDataActionKind(value: unknown): value is DataActionKind {
|
|
52
|
+
return typeof value === 'string' && (DATA_ACTION_KINDS as readonly string[]).includes(value);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** 动作注册中心条目(GET /api/v1/action-registry/actions 的 data.actions[])。 */
|
|
56
|
+
export interface ActionDefinition {
|
|
57
|
+
name: string;
|
|
58
|
+
title: LocalizedText;
|
|
59
|
+
description?: LocalizedText;
|
|
60
|
+
source: string;
|
|
61
|
+
plugin_id?: string;
|
|
62
|
+
capabilities?: { asyncable?: boolean; side_effecting?: boolean; scheduled_context?: boolean };
|
|
63
|
+
params_schema?: JsonSchema;
|
|
64
|
+
category?: string;
|
|
65
|
+
sort_weight?: number;
|
|
66
|
+
/**
|
|
67
|
+
* 数据动作的操作种类:动作由插件在 manifest `capabilities.data_actions` 声明、且声明插件就是登记插件时,
|
|
68
|
+
* 宿主随动作目录下发;普通动作不带。老宿主不下发本字段。替代设计器可据此识别写节点(create / update / delete)
|
|
69
|
+
* 与取数节点,配置面板仍按 `params_schema['x-editor']`(`extract-v4` / `write-v4`)判定。
|
|
70
|
+
*/
|
|
71
|
+
operation_kind?: DataActionKind;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** 参数 schema(动作参数 schema 受限方言,见 Go SDK plugin/paramschema_strict.go)。 */
|
|
75
|
+
export interface JsonSchema {
|
|
76
|
+
type?: string;
|
|
77
|
+
enum?: unknown[];
|
|
78
|
+
default?: unknown;
|
|
79
|
+
description?: string;
|
|
80
|
+
minimum?: number;
|
|
81
|
+
maximum?: number;
|
|
82
|
+
properties?: Record<string, JsonSchema>;
|
|
83
|
+
required?: string[];
|
|
84
|
+
[k: string]: unknown;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 动作行为文档(与官方设计器保存的结构一致)。
|
|
89
|
+
* 约束:trigger_bindings[].scopes 取 'form' 或 'field:<字段ID>';seq 与 disabled 为零值时不写;
|
|
90
|
+
* 事件键见宿主 getSupportedTriggers(before-save / after-save 已退役)。
|
|
91
|
+
*/
|
|
92
|
+
export interface BehaviorDocument {
|
|
93
|
+
trigger_bindings: TriggerBinding[];
|
|
94
|
+
action_groups: { group_id: string; group_guard_id?: string; ordered_node_ids: string[] }[];
|
|
95
|
+
action_nodes: ActionNode[];
|
|
96
|
+
guards: unknown[];
|
|
97
|
+
conditions?: unknown[];
|
|
98
|
+
[k: string]: unknown;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface TriggerBinding {
|
|
102
|
+
binding_id: string;
|
|
103
|
+
name?: string;
|
|
104
|
+
trigger_event_key?: string;
|
|
105
|
+
trigger_event_keys?: string[];
|
|
106
|
+
scope?: string;
|
|
107
|
+
scopes?: string[];
|
|
108
|
+
ordered_group_ids: string[];
|
|
109
|
+
disabled?: boolean;
|
|
110
|
+
seq?: number;
|
|
111
|
+
[k: string]: unknown;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface ActionNode {
|
|
115
|
+
node_id: string;
|
|
116
|
+
action_name: string;
|
|
117
|
+
source?: string;
|
|
118
|
+
name?: string;
|
|
119
|
+
disabled?: boolean;
|
|
120
|
+
params?: Record<string, unknown>;
|
|
121
|
+
children_node_ids?: string[];
|
|
122
|
+
[k: string]: unknown;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** 动作文档信封(GET/PUT .../action-document 的 data)。 */
|
|
126
|
+
export interface ActionDocumentEnvelope {
|
|
127
|
+
template_id: string;
|
|
128
|
+
template_version_no: string;
|
|
129
|
+
/** 动作文档原文:宿主透传不做类型保证,插件按 BehaviorDocument 结构解析(可能为 null)。 */
|
|
130
|
+
actions: unknown;
|
|
131
|
+
checksum?: string;
|
|
132
|
+
content_revision: number;
|
|
133
|
+
version_no: number;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface TemplateTable {
|
|
137
|
+
data_table_id: string;
|
|
138
|
+
table_name: string;
|
|
139
|
+
table_role?: string;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface TemplateField {
|
|
143
|
+
field_id: string;
|
|
144
|
+
field_name: string;
|
|
145
|
+
data_type: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** domain:action-designer 公开方法。 */
|
|
149
|
+
export interface ActionDesignerHostApi {
|
|
150
|
+
openActionDocument(scope: ActionDesignerScope): Promise<HostResult<ActionDocumentEnvelope>>;
|
|
151
|
+
saveActionDocument(
|
|
152
|
+
scope: ActionDesignerScope,
|
|
153
|
+
body: { actions: unknown; expectedVersionNo: number }
|
|
154
|
+
): Promise<HostResult<ActionDocumentEnvelope>>;
|
|
155
|
+
listActionRegistry(): Promise<HostResult<{ actions: ActionDefinition[] }>>;
|
|
156
|
+
getSupportedTriggers(pluginId: string): Promise<string[] | null>;
|
|
157
|
+
listTemplateTables(appId: string, templateId: string, versionNo?: string): Promise<HostResult<{ items: TemplateTable[] }>>;
|
|
158
|
+
listTemplateFields(
|
|
159
|
+
appId: string,
|
|
160
|
+
templateId: string,
|
|
161
|
+
versionNo: string | undefined,
|
|
162
|
+
dataTableId: string
|
|
163
|
+
): Promise<HostResult<{ items: TemplateField[] }>>;
|
|
164
|
+
/** 定时任务模式(input.kind='job')读取任务持有的动作文档(tp.5 起列入公开契约)。 */
|
|
165
|
+
openJobActionDocument?(appId: string, jobId: string): Promise<HostResult<ActionDocumentEnvelope>>;
|
|
166
|
+
/** 定时任务模式保存(CAS:expectedVersionNo 为打开时的 version_no)。 */
|
|
167
|
+
saveJobActionDocument?(
|
|
168
|
+
appId: string,
|
|
169
|
+
jobId: string,
|
|
170
|
+
body: { actions: unknown; expectedVersionNo: number }
|
|
171
|
+
): Promise<HostResult<ActionDocumentEnvelope>>;
|
|
172
|
+
/** 列出本应用的模板(可按关键字过滤),供「跨模板」类动作选目标模板。 */
|
|
173
|
+
listAppTemplates?(appId: string, keyword?: string): Promise<HostResult<unknown>>;
|
|
174
|
+
/** 列出模板绑定的流程(流程类动作选流程)。 */
|
|
175
|
+
listTemplateWorkflows?(appId: string, templateId: string): Promise<HostResult<unknown>>;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** 沙箱档宿主为 domain:action-designer 开放的方法白名单(与宿主沙箱档实现同口径)。 */
|
|
179
|
+
export const ACTION_DESIGNER_FRAME_HOST_API_METHODS = [
|
|
180
|
+
'openActionDocument',
|
|
181
|
+
'saveActionDocument',
|
|
182
|
+
'openJobActionDocument',
|
|
183
|
+
'saveJobActionDocument',
|
|
184
|
+
'listActionRegistry',
|
|
185
|
+
'getSupportedTriggers',
|
|
186
|
+
'listTemplateTables',
|
|
187
|
+
'listTemplateFields',
|
|
188
|
+
'listAppTemplates',
|
|
189
|
+
'listTemplateWorkflows'
|
|
190
|
+
] as const;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* 宿主经组件 prop `input` 传入的业务形状。设计器需自己绘制弹窗(宿主不提供外壳),用 visible 控制显隐,
|
|
194
|
+
* 关闭前调用 requestClose()(宿主负责未保存确认,确认框 z-index 2001,插件遮罩须低于该值)。
|
|
195
|
+
*/
|
|
196
|
+
export type ActionDesignerSurfaceInput =
|
|
197
|
+
| {
|
|
198
|
+
kind: 'template';
|
|
199
|
+
scope: ActionDesignerScope;
|
|
200
|
+
visible: boolean;
|
|
201
|
+
title?: string;
|
|
202
|
+
requestClose: () => Promise<boolean>;
|
|
203
|
+
interactiveSessionOwnership: 'inherited' | 'owned';
|
|
204
|
+
}
|
|
205
|
+
| {
|
|
206
|
+
kind: 'job';
|
|
207
|
+
appId: string;
|
|
208
|
+
jobId: string;
|
|
209
|
+
jobName?: string;
|
|
210
|
+
visible: boolean;
|
|
211
|
+
title?: string;
|
|
212
|
+
requestClose: () => Promise<boolean>;
|
|
213
|
+
interactiveSessionOwnership: 'inherited' | 'owned';
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* defineActionDesignerSurface —— 动作设计器专用的 definePluginSurface(tp.5 起):两种挂载档写法一致,
|
|
218
|
+
* 沙箱档自动启动框架运行时并做前端域自检(action-designer 需 frontend.surface + frontend.interactive-session)。
|
|
219
|
+
* 工厂拿到宿主 input(组件 prop `input` 的值)、`domain:action-designer` 与交互会话;缺任一能力即抛错(快速失败)。
|
|
220
|
+
*/
|
|
221
|
+
export function defineActionDesignerSurface(
|
|
222
|
+
factory: (ctx: {
|
|
223
|
+
input: SurfaceCreateInput;
|
|
224
|
+
surfaceInput: ActionDesignerSurfaceInput | undefined;
|
|
225
|
+
hostApi: ActionDesignerHostApi;
|
|
226
|
+
interactiveSession: InteractiveSessionHandle;
|
|
227
|
+
}) => SurfaceMountResult
|
|
228
|
+
): (input: SurfaceCreateInput) => SurfaceMountResult {
|
|
229
|
+
return definePluginSurface((input: SurfaceCreateInput) => {
|
|
230
|
+
if ((input.surfaceType as string) !== 'action-designer') {
|
|
231
|
+
throw new Error(`defineActionDesignerSurface: unsupported surface ${String(input.surfaceType)}`);
|
|
232
|
+
}
|
|
233
|
+
const bridge = (input.hostBridge ?? {}) as Record<string, unknown>;
|
|
234
|
+
const read = (key: string): unknown => {
|
|
235
|
+
try {
|
|
236
|
+
return bridge[key];
|
|
237
|
+
} catch {
|
|
238
|
+
// 宿主按 host_caps 裁剪的 Proxy 读未声明键会抛错:视为缺失。
|
|
239
|
+
return undefined;
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
const hostApi = read('domain:action-designer') as ActionDesignerHostApi | undefined;
|
|
243
|
+
const interactiveSession = read('interactiveSession') as InteractiveSessionHandle | undefined;
|
|
244
|
+
if (!hostApi || !interactiveSession) {
|
|
245
|
+
throw new Error('defineActionDesignerSurface: host_caps must include domain:action-designer and platform.interactiveSession');
|
|
246
|
+
}
|
|
247
|
+
const props = (input.props ?? {}) as Record<string, unknown>;
|
|
248
|
+
return factory({ input, surfaceInput: props.input as ActionDesignerSurfaceInput | undefined, hostApi, interactiveSession });
|
|
249
|
+
});
|
|
250
|
+
}
|