@zhin.js/adapter-wechat-mp 3.0.2 → 4.0.0

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/package.json CHANGED
@@ -1,26 +1,36 @@
1
1
  {
2
2
  "name": "@zhin.js/adapter-wechat-mp",
3
- "version": "3.0.2",
3
+ "version": "4.0.0",
4
4
  "type": "module",
5
- "description": "Zhin.js adapter for WeChat Official Account (微信公众号)",
5
+ "description": "Zhin.js WeChat Official Account adapter for Plugin Runtime (HTTP webhook)",
6
6
  "main": "./lib/index.js",
7
7
  "types": "./lib/index.d.ts",
8
8
  "dependencies": {
9
- "xml2js": "^0.6.2",
10
9
  "axios": "^1.18.0",
11
- "form-data": "^4.0.6"
10
+ "xml2js": "^0.6.2",
11
+ "@zhin.js/adapter": "1.1.0",
12
+ "@zhin.js/core": "1.4.0",
13
+ "@zhin.js/host-http": "1.0.2",
14
+ "@zhin.js/logger": "1.0.75",
15
+ "@zhin.js/plugin-runtime": "1.1.0"
12
16
  },
13
17
  "peerDependencies": {
14
- "@zhin.js/host-router": "2.0.3",
15
- "zhin.js": "4.1.2"
18
+ "@zhin.js/adapter": "1.1.0",
19
+ "@zhin.js/core": "1.4.0",
20
+ "@zhin.js/host-http": "1.0.2",
21
+ "@zhin.js/plugin-runtime": "1.1.0",
22
+ "zhin.js": "5.0.0"
23
+ },
24
+ "peerDependenciesMeta": {
25
+ "zhin.js": {
26
+ "optional": true
27
+ }
16
28
  },
17
29
  "devDependencies": {
18
- "@types/koa": "^3.0.3",
19
30
  "@types/node": "^26.1.0",
20
31
  "@types/xml2js": "^0.4.14",
21
32
  "typescript": "^6.0.3",
22
- "@zhin.js/host-router": "2.0.3",
23
- "zhin.js": "4.1.2"
33
+ "vitest": "^4.1.10"
24
34
  },
25
35
  "keywords": [
26
36
  "zhin",
@@ -46,6 +56,9 @@
46
56
  "directory": "plugins/adapters/wechat-mp"
47
57
  },
48
58
  "files": [
59
+ "adapters",
60
+ "plugin.ts",
61
+ "schema.json",
49
62
  "src",
50
63
  "lib",
51
64
  "agent",
@@ -66,9 +79,23 @@
66
79
  "engines": {
67
80
  "node": "^20.19.0 || >=22.12.0"
68
81
  },
82
+ "zhin": {
83
+ "protocol": 1,
84
+ "type": "plugin",
85
+ "entry": "./plugin.ts",
86
+ "engine": "^1.0.0",
87
+ "runtime": "trusted",
88
+ "features": [
89
+ {
90
+ "package": "@zhin.js/adapter",
91
+ "api": "^1.0.0"
92
+ }
93
+ ],
94
+ "plugins": []
95
+ },
69
96
  "scripts": {
70
- "build": "pnpm build:node",
97
+ "build": "tsc",
71
98
  "clean": "rimraf lib",
72
- "build:node": "tsc"
99
+ "test": "NODE_OPTIONS=--experimental-strip-types vitest run --root ../../.. plugins/adapters/wechat-mp/tests"
73
100
  }
74
101
  }
package/plugin.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { definePlugin } from '@zhin.js/plugin-runtime';
2
+
3
+ export default definePlugin({
4
+ name: 'wechat-mp',
5
+ metadata: {
6
+ displayName: 'WeChat Official Account Adapter',
7
+ },
8
+ });
package/schema.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "additionalProperties": false,
5
+ "properties": {
6
+ "path": {
7
+ "type": "string",
8
+ "default": "/wechat/webhook"
9
+ },
10
+ "encrypt": {
11
+ "type": "boolean",
12
+ "default": false
13
+ },
14
+ "encryptMode": {
15
+ "type": "string",
16
+ "enum": [
17
+ "plain",
18
+ "compatible",
19
+ "secure"
20
+ ],
21
+ "description": "Default follows encrypt: 'plain' when encrypt=false, 'compatible' when encrypt=true"
22
+ },
23
+ "replyMode": {
24
+ "type": "string",
25
+ "enum": [
26
+ "passive",
27
+ "customer_service"
28
+ ],
29
+ "default": "passive"
30
+ },
31
+ "passiveReplyTimeoutMs": {
32
+ "type": "number",
33
+ "default": 4500
34
+ },
35
+ "endpoints": {
36
+ "type": "array",
37
+ "description": "多账号:一个插件实例挂多个 endpoint。每项与顶层字段同构(name 必填,其余覆盖顶层)",
38
+ "items": {
39
+ "type": "object",
40
+ "additionalProperties": true,
41
+ "properties": {
42
+ "name": {
43
+ "type": "string",
44
+ "description": "WeChat MP bot name"
45
+ },
46
+ "appId": {
47
+ "type": "string",
48
+ "description": "WeChat MP app ID"
49
+ },
50
+ "appSecret": {
51
+ "type": "string",
52
+ "description": "WeChat MP app secret"
53
+ },
54
+ "token": {
55
+ "type": "string",
56
+ "description": "WeChat MP callback token"
57
+ },
58
+ "encodingAESKey": {
59
+ "type": "string",
60
+ "description": "WeChat MP encoding AES key"
61
+ }
62
+ },
63
+ "required": [
64
+ "name",
65
+ "appId",
66
+ "appSecret",
67
+ "token"
68
+ ]
69
+ }
70
+ },
71
+ "commandPrefix": {
72
+ "type": "string",
73
+ "default": "",
74
+ "description": "命令前缀(默认 '' 无前缀,任意文本按命令匹配;如 '/' 要求 / 开头)。endpoints[i] 可逐项覆盖"
75
+ }
76
+ },
77
+ "required": [
78
+ "endpoints"
79
+ ]
80
+ }