@zhin.js/adapter-wechat-mp 1.1.17 → 1.1.18

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/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @zhin.js/adapter-wechat-mp
2
2
 
3
+ ## 1.1.18
4
+
5
+ ### Patch Changes
6
+
7
+ - 6345a38: feat(adapters): add per-adapter Console pages
8
+
9
+ Every platform adapter now ships a `pages/index` Console page backed by a shared
10
+ `createAdapterConsolePage` component and `createAdapterConsoleRpc` server helper:
11
+
12
+ - See running endpoints, test connectivity, and manage
13
+ `plugins.<adapter>.endpoints` (add/remove writes `.env` references) from the
14
+ Console instead of chat commands.
15
+ - Surface LoginAssist pending tasks (QR / slider / SMS / device) so ICQQ login no
16
+ longer requires the terminal.
17
+ - QQ moves its QR binding flow (`qq endpoint add`) into Console actions with
18
+ public/private selection.
19
+ - Pages are permission-gated by `<adapter>:read`; writes need `<adapter>:write`.
20
+
21
+ - Updated dependencies [6345a38]
22
+ - Updated dependencies [ff3efe7]
23
+ - Updated dependencies [c58c589]
24
+ - @zhin.js/adapter@1.1.25
25
+ - @zhin.js/client@1.1.21
26
+ - @zhin.js/core@1.1.53
27
+ - @zhin.js/im-contract@1.1.9
28
+
3
29
  ## 1.1.17
4
30
 
5
31
  ### Patch Changes
package/README.md CHANGED
@@ -75,6 +75,16 @@ Runtime Host(`http`)须已 listen,Webhook 才可达。
75
75
  4. 设置 Token(与配置文件中的 `token` 一致)
76
76
  5. 如需消息加解密,设置 EncodingAESKey
77
77
 
78
+ ## Console 页面
79
+
80
+ 启动后打开 Console 的「微信公众号」页(地址 `/wechat-mp`),可以:
81
+
82
+ - 查看运行中的连接、点「测试连接」做连通性诊断;
83
+ - 增删 `plugins.wechat-mp.endpoints`(凭据写入 `.env`,配置里只保留 `${ENV}` 引用);
84
+ - 如果适配器要求登录,页面会显示 LoginAssist 的扫码 / 滑块 / 设备确认待办;
85
+
86
+ 读取需要 `wechat-mp:read`,写操作需要 `wechat-mp:write`;管理员 full token 不受限。页面里的「添加 endpoint」等价于原来的 `wechat-mp endpoint add`。
87
+
78
88
  ## 故障排查
79
89
 
80
90
  | 现象 | 排查 |
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 微信公众号 Console 页面元数据(浏览器与服务端共享;不要在这里 import 服务端代码)。
3
+ */
4
+ import type { AdapterConsoleField } from 'zhin.js/adapter';
5
+ export declare const wechatMpConsoleSpec: {
6
+ readonly adapterKey: "wechat-mp";
7
+ readonly adapterDisplayName: "微信公众号";
8
+ readonly fields: readonly AdapterConsoleField[];
9
+ readonly docsUrl: "https://zhin.js.org/adapters/wechat-mp";
10
+ readonly readPermission: "wechat-mp:read";
11
+ readonly writePermission: "wechat-mp:write";
12
+ };
@@ -0,0 +1,13 @@
1
+ export const wechatMpConsoleSpec = {
2
+ adapterKey: 'wechat-mp',
3
+ adapterDisplayName: '微信公众号',
4
+ fields: [
5
+ { key: 'appId', required: true, env: true, description: '公众号 AppID', descriptionI18n: { en: 'WeChat Official Account app ID' } },
6
+ { key: 'appSecret', required: true, env: true, description: '公众号 AppSecret', descriptionI18n: { en: 'WeChat Official Account app secret' } },
7
+ { key: 'token', required: true, env: true, description: '服务器配置 token', descriptionI18n: { en: 'Server configuration token' } },
8
+ { key: 'encodingAESKey', env: true, description: '消息加解密 key', descriptionI18n: { en: 'Message encryption key' } },
9
+ ],
10
+ docsUrl: 'https://zhin.js.org/adapters/wechat-mp',
11
+ readPermission: 'wechat-mp:read',
12
+ writePermission: 'wechat-mp:write',
13
+ };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 微信公众号 Console RPC:运行状态 + endpoint 增删(原 `wechat-mp endpoint` 聊天命令)。
3
+ *
4
+ * 页面绑定 `pages/index`,读取 / 写入分别要求 `<adapter>:read` / `<adapter>:write`。
5
+ */
6
+ import { type AdapterConsoleResources } from 'zhin.js/adapter';
7
+ import type { PluginConsoleRpc } from 'zhin.js';
8
+ export declare function createWechatMpConsoleRpc(resources: AdapterConsoleResources, getConfig: () => unknown): PluginConsoleRpc;
package/lib/console.js ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 微信公众号 Console RPC:运行状态 + endpoint 增删(原 `wechat-mp endpoint` 聊天命令)。
3
+ *
4
+ * 页面绑定 `pages/index`,读取 / 写入分别要求 `<adapter>:read` / `<adapter>:write`。
5
+ */
6
+ import { createAdapterConsoleRpc } from 'zhin.js/adapter';
7
+ import { wechatMpRuntimeStateToken } from './wechat-mp-runtime-state.js';
8
+ import { wechatMpConsoleSpec } from './console-spec.js';
9
+ export function createWechatMpConsoleRpc(resources, getConfig) {
10
+ const state = resources.use(wechatMpRuntimeStateToken);
11
+ return createAdapterConsoleRpc({
12
+ ...wechatMpConsoleSpec,
13
+ running: () => state.endpoints.values(),
14
+ getConfig,
15
+ }, resources);
16
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/adapter-wechat-mp",
3
- "version": "1.1.17",
3
+ "version": "1.1.18",
4
4
  "type": "module",
5
5
  "description": "Zhin.js WeChat Official Account adapter for Plugin Runtime (HTTP webhook)",
6
6
  "main": "./lib/index.js",
@@ -8,20 +8,23 @@
8
8
  "dependencies": {
9
9
  "axios": "^1.20.0",
10
10
  "xml2js": "^0.6.2",
11
- "@zhin.js/adapter": "1.1.24",
12
- "@zhin.js/core": "1.1.52",
11
+ "@zhin.js/adapter": "1.1.25",
12
+ "@zhin.js/client": "1.1.21",
13
+ "@zhin.js/console-contract": "1.1.3",
14
+ "@zhin.js/core": "1.1.53",
13
15
  "@zhin.js/feature-kit": "1.1.9",
14
16
  "@zhin.js/host-http": "1.1.11",
15
- "@zhin.js/im-contract": "1.1.8",
17
+ "@zhin.js/im-contract": "1.1.9",
16
18
  "@zhin.js/logger": "1.1.2",
19
+ "@zhin.js/page": "1.1.10",
17
20
  "@zhin.js/skill": "1.1.10"
18
21
  },
19
22
  "peerDependencies": {
20
- "@zhin.js/adapter": "^1.1.24",
23
+ "@zhin.js/adapter": "^1.1.25",
21
24
  "@zhin.js/command": "^1.1.11",
22
- "@zhin.js/core": "^1.1.52",
25
+ "@zhin.js/core": "^1.1.53",
23
26
  "@zhin.js/host-http": "^1.1.11",
24
- "zhin.js": "^1.1.17"
27
+ "zhin.js": "^1.1.18"
25
28
  },
26
29
  "peerDependenciesMeta": {
27
30
  "@zhin.js/command": {
@@ -36,7 +39,7 @@
36
39
  "@types/xml2js": "^0.4.14",
37
40
  "typescript": "^6.0.3",
38
41
  "vitest": "^4.1.10",
39
- "zhin.js": "1.1.17"
42
+ "zhin.js": "1.1.18"
40
43
  },
41
44
  "keywords": [
42
45
  "zhin",
@@ -64,6 +67,7 @@
64
67
  "files": [
65
68
  "adapters",
66
69
  "commands",
70
+ "pages",
67
71
  "plugin.js",
68
72
  "schema.json",
69
73
  "src",
@@ -103,6 +107,10 @@
103
107
  {
104
108
  "package": "@zhin.js/skill",
105
109
  "api": "^1.0.0"
110
+ },
111
+ {
112
+ "package": "@zhin.js/page",
113
+ "api": "^1.0.0"
106
114
  }
107
115
  ],
108
116
  "plugins": []
@@ -0,0 +1,15 @@
1
+ // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
+ import { definePage } from '@zhin.js/console-contract';
3
+ import { createAdapterConsolePage } from '@zhin.js/client';
4
+ export const meta = definePage({
5
+ title: '微信公众号',
6
+ titleI18n: { en: 'WeChat MP' },
7
+ icon: 'MessageSquare',
8
+ order: 75,
9
+ requiredPermissions: ['wechat-mp:read'],
10
+ });
11
+ /**
12
+ * Convention page: `pages/index/index.ts` → `/wechat-mp`(插件路径)。
13
+ * 连接状态、连接测试、endpoint 增删;登录待办来自 LoginAssist(ICQQ 等)。
14
+ */
15
+ export default createAdapterConsolePage('wechat-mp');
@@ -0,0 +1,16 @@
1
+ import { definePage } from '@zhin.js/console-contract';
2
+ import { createAdapterConsolePage } from '@zhin.js/client';
3
+
4
+ export const meta = definePage({
5
+ title: '微信公众号',
6
+ titleI18n: { en: 'WeChat MP' },
7
+ icon: 'MessageSquare',
8
+ order: 75,
9
+ requiredPermissions: ['wechat-mp:read'],
10
+ });
11
+
12
+ /**
13
+ * Convention page: `pages/index/index.ts` → `/wechat-mp`(插件路径)。
14
+ * 连接状态、连接测试、endpoint 增删;登录待办来自 LoginAssist(ICQQ 等)。
15
+ */
16
+ export default createAdapterConsolePage('wechat-mp');
package/plugin.js CHANGED
@@ -1,7 +1,8 @@
1
1
  // Generated by build-plugin-runtime-entries.mjs. Do not edit.
2
2
  import { createEndpointRuntimeState } from 'zhin.js/adapter';
3
- import { definePlugin } from 'zhin.js';
3
+ import { definePlugin, pluginConsoleRpcToken } from 'zhin.js';
4
4
  import { wechatMpRuntimeStateToken } from "./lib/wechat-mp-runtime-state.js";
5
+ import { createWechatMpConsoleRpc } from "./lib/console.js";
5
6
  export default definePlugin({
6
7
  name: 'wechat-mp',
7
8
  metadata: {
@@ -10,5 +11,6 @@ export default definePlugin({
10
11
  setup(context) {
11
12
  // 运行中 endpoint 注册表(wechat-mp endpoint list 的"运行中"数据源)
12
13
  context.resources.provide(wechatMpRuntimeStateToken, createEndpointRuntimeState());
14
+ context.resources.provide(pluginConsoleRpcToken, createWechatMpConsoleRpc(context.resources, () => context.config.get()));
13
15
  },
14
16
  });
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 微信公众号 Console 页面元数据(浏览器与服务端共享;不要在这里 import 服务端代码)。
3
+ */
4
+ import type { AdapterConsoleField } from 'zhin.js/adapter';
5
+
6
+ export const wechatMpConsoleSpec = {
7
+ adapterKey: 'wechat-mp',
8
+ adapterDisplayName: '微信公众号',
9
+ fields: [
10
+ { key: 'appId', required: true, env: true, description: '公众号 AppID', descriptionI18n: { en: 'WeChat Official Account app ID' } },
11
+ { key: 'appSecret', required: true, env: true, description: '公众号 AppSecret', descriptionI18n: { en: 'WeChat Official Account app secret' } },
12
+ { key: 'token', required: true, env: true, description: '服务器配置 token', descriptionI18n: { en: 'Server configuration token' } },
13
+ { key: 'encodingAESKey', env: true, description: '消息加解密 key', descriptionI18n: { en: 'Message encryption key' } },
14
+ ] as readonly AdapterConsoleField[],
15
+ docsUrl: 'https://zhin.js.org/adapters/wechat-mp',
16
+ readPermission: 'wechat-mp:read',
17
+ writePermission: 'wechat-mp:write',
18
+ } as const;
package/src/console.ts ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * 微信公众号 Console RPC:运行状态 + endpoint 增删(原 `wechat-mp endpoint` 聊天命令)。
3
+ *
4
+ * 页面绑定 `pages/index`,读取 / 写入分别要求 `<adapter>:read` / `<adapter>:write`。
5
+ */
6
+ import { createAdapterConsoleRpc, type AdapterConsoleResources } from 'zhin.js/adapter';
7
+ import type { PluginConsoleRpc } from 'zhin.js';
8
+ import { wechatMpRuntimeStateToken } from './wechat-mp-runtime-state.js';
9
+ import { wechatMpConsoleSpec } from './console-spec.js';
10
+
11
+ export function createWechatMpConsoleRpc(
12
+ resources: AdapterConsoleResources,
13
+ getConfig: () => unknown,
14
+ ): PluginConsoleRpc {
15
+ const state = resources.use(wechatMpRuntimeStateToken);
16
+ return createAdapterConsoleRpc({
17
+ ...wechatMpConsoleSpec,
18
+ running: () => state.endpoints.values(),
19
+ getConfig,
20
+ }, resources);
21
+ }