@zhin.js/adapter-wechat-mp 5.0.9 → 5.0.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.
- package/CHANGELOG.md +10 -0
- package/README.md +1 -1
- package/adapters/wechat-mp.js +1 -1
- package/adapters/wechat-mp.ts +1 -1
- package/lib/endpoint.d.ts +2 -2
- package/lib/webhook.d.ts +1 -1
- package/lib/wechat-mp-endpoint-commands.js +2 -2
- package/lib/wechat-mp-runtime-state.d.ts +1 -1
- package/lib/wechat-mp-runtime-state.js +1 -1
- package/package.json +9 -11
- package/plugin.js +2 -2
- package/src/endpoint.ts +2 -2
- package/src/webhook.ts +1 -1
- package/src/wechat-mp-endpoint-commands.ts +2 -2
- package/src/wechat-mp-runtime-state.ts +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ pnpm add @zhin.js/adapter-wechat-mp
|
|
|
21
21
|
- `@zhin.js/adapter` — 约定式 `adapters/wechat-mp.ts`(`defineAdapter`)
|
|
22
22
|
- `@zhin.js/core` — `messageGatewayToken` 入站/出站
|
|
23
23
|
- `@zhin.js/host-http` — `httpHostToken` 注册 Webhook 路由(**非** legacy host-router/Koa)
|
|
24
|
-
-
|
|
24
|
+
- `zhin.js` — `plugin.ts`(`definePlugin`)
|
|
25
25
|
- 配置经插件 `schema.json` 落到 `plugins.<instanceKey>`
|
|
26
26
|
|
|
27
27
|
入站:`gateway.receive({ conversation: { endpoint, kind: 'private', id: openid }, message: { conversation, id }, content: text, sender, metadata })`
|
package/adapters/wechat-mp.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Convention entry: discover `adapters/wechat-mp.ts` → defineAdapter.
|
|
4
4
|
*/
|
|
5
|
-
import { defineAdapter } from '
|
|
5
|
+
import { defineAdapter } from 'zhin.js/adapter';
|
|
6
6
|
import { messageGatewayToken } from '@zhin.js/core/runtime';
|
|
7
7
|
import { httpHostToken } from '@zhin.js/host-http';
|
|
8
8
|
import { WeChatMpEndpoint } from "../lib/endpoint.js";
|
package/adapters/wechat-mp.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Convention entry: discover `adapters/wechat-mp.ts` → defineAdapter.
|
|
3
3
|
*/
|
|
4
|
-
import { defineAdapter } from '
|
|
4
|
+
import { defineAdapter } from 'zhin.js/adapter';
|
|
5
5
|
import { messageGatewayToken } from '@zhin.js/core/runtime';
|
|
6
6
|
import { httpHostToken } from '@zhin.js/host-http';
|
|
7
7
|
import { WeChatMpEndpoint } from '../src/endpoint.js';
|
package/lib/endpoint.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { EndpointFriend, EndpointInstance, EndpointManagement, EndpointSendRequest } from '
|
|
1
|
+
import type { EndpointFriend, EndpointInstance, EndpointManagement, EndpointSendRequest } from 'zhin.js/adapter';
|
|
2
2
|
import type { MessageGateway } from '@zhin.js/core/runtime';
|
|
3
3
|
import type { HttpHost } from '@zhin.js/host-http';
|
|
4
|
-
import type { CapabilityId } from '
|
|
4
|
+
import type { CapabilityId } from 'zhin.js';
|
|
5
5
|
import { type ResolvedWeChatMpConfig, type WeChatMessage } from './protocol.js';
|
|
6
6
|
export type WeChatMpFetch = (url: string, init?: {
|
|
7
7
|
readonly method?: string;
|
package/lib/webhook.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
5
5
|
import type { MessageGateway } from '@zhin.js/core/runtime';
|
|
6
6
|
import type { HttpHost, HttpRouteRegistration } from '@zhin.js/host-http';
|
|
7
|
-
import type { CapabilityId } from '
|
|
7
|
+
import type { CapabilityId } from 'zhin.js';
|
|
8
8
|
import { type ResolvedWeChatMpConfig, type WeChatMessage } from './protocol.js';
|
|
9
9
|
export interface WeChatMpWebhookHandler {
|
|
10
10
|
readonly config: ResolvedWeChatMpConfig;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* `wechat-mp.endpoint` 命令族:由 @zhin.js/adapter 的 createEndpointCommands 套件生成。
|
|
3
3
|
* commands/endpoint/ 下的 list / add / remove 直接默认导出这三项。
|
|
4
4
|
*/
|
|
5
|
-
import { createEndpointCommands } from '
|
|
6
|
-
import { defineCommand } from '
|
|
5
|
+
import { createEndpointCommands } from 'zhin.js/adapter';
|
|
6
|
+
import { defineCommand } from 'zhin.js/command';
|
|
7
7
|
import { wechatMpRuntimeStateToken } from './wechat-mp-runtime-state.js';
|
|
8
8
|
export const wechatMpEndpointCommands = createEndpointCommands({
|
|
9
9
|
adapterKey: 'wechat-mp',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const wechatMpRuntimeStateToken: import("
|
|
1
|
+
export declare const wechatMpRuntimeStateToken: import("zhin.js").Token<import("@zhin.js/adapter").EndpointRuntimeState>;
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* WeChat MP 插件实例的运行时状态:adapter create() 注册的 endpoint 列表。
|
|
3
3
|
* 由 plugin.ts setup() provide,adapter create 与 `wechat-mp.endpoint` 命令共享(同一 owner generation)。
|
|
4
4
|
*/
|
|
5
|
-
import { defineEndpointRuntimeStateToken } from '
|
|
5
|
+
import { defineEndpointRuntimeStateToken } from 'zhin.js/adapter';
|
|
6
6
|
export const wechatMpRuntimeStateToken = defineEndpointRuntimeStateToken('wechat-mp');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/adapter-wechat-mp",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.10",
|
|
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,17 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"axios": "^1.19.0",
|
|
10
10
|
"xml2js": "^0.6.2",
|
|
11
|
-
"@zhin.js/adapter": "1.1.
|
|
12
|
-
"@zhin.js/
|
|
13
|
-
"@zhin.js/core": "1.5.9",
|
|
11
|
+
"@zhin.js/adapter": "1.1.10",
|
|
12
|
+
"@zhin.js/core": "1.5.10",
|
|
14
13
|
"@zhin.js/host-http": "1.0.10",
|
|
15
14
|
"@zhin.js/im-contract": "1.0.3",
|
|
16
|
-
"@zhin.js/logger": "1.0.76"
|
|
17
|
-
"@zhin.js/plugin-runtime": "1.1.6"
|
|
15
|
+
"@zhin.js/logger": "1.0.76"
|
|
18
16
|
},
|
|
19
17
|
"peerDependencies": {
|
|
20
|
-
"@zhin.js/adapter": "1.1.
|
|
21
|
-
"@zhin.js/core": "1.5.
|
|
18
|
+
"@zhin.js/adapter": "1.1.10",
|
|
19
|
+
"@zhin.js/core": "1.5.10",
|
|
22
20
|
"@zhin.js/host-http": "1.0.10",
|
|
23
|
-
"
|
|
24
|
-
"zhin.js": "6.0.9"
|
|
21
|
+
"zhin.js": "6.0.10"
|
|
25
22
|
},
|
|
26
23
|
"peerDependenciesMeta": {
|
|
27
24
|
"zhin.js": {
|
|
@@ -32,7 +29,8 @@
|
|
|
32
29
|
"@types/node": "^26.1.2",
|
|
33
30
|
"@types/xml2js": "^0.4.14",
|
|
34
31
|
"typescript": "^6.0.3",
|
|
35
|
-
"vitest": "^4.1.10"
|
|
32
|
+
"vitest": "^4.1.10",
|
|
33
|
+
"zhin.js": "6.0.10"
|
|
36
34
|
},
|
|
37
35
|
"keywords": [
|
|
38
36
|
"zhin",
|
package/plugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Generated by build-plugin-runtime-entries.mjs. Do not edit.
|
|
2
|
-
import { createEndpointRuntimeState } from '
|
|
3
|
-
import { definePlugin } from '
|
|
2
|
+
import { createEndpointRuntimeState } from 'zhin.js/adapter';
|
|
3
|
+
import { definePlugin } from 'zhin.js';
|
|
4
4
|
import { wechatMpRuntimeStateToken } from "./lib/wechat-mp-runtime-state.js";
|
|
5
5
|
export default definePlugin({
|
|
6
6
|
name: 'wechat-mp',
|
package/src/endpoint.ts
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* WeChatMpEndpoint — lifecycle, outbound, admit, access token refresh.
|
|
3
3
|
*/
|
|
4
4
|
import axios from 'axios';
|
|
5
|
-
import type { EndpointFriend, EndpointInstance, EndpointManagement, EndpointSendRequest } from '
|
|
5
|
+
import type { EndpointFriend, EndpointInstance, EndpointManagement, EndpointSendRequest } from 'zhin.js/adapter';
|
|
6
6
|
import type { MessageGateway } from '@zhin.js/core/runtime';
|
|
7
7
|
import type { HttpHost, HttpRouteRegistration } from '@zhin.js/host-http';
|
|
8
8
|
import { formatCompact, getAdapterLogger } from '@zhin.js/logger';
|
|
9
|
-
import type { CapabilityId } from '
|
|
9
|
+
import type { CapabilityId } from 'zhin.js';
|
|
10
10
|
import {
|
|
11
11
|
extractOutboundText,
|
|
12
12
|
formatCustomerServiceBody,
|
package/src/webhook.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
|
5
5
|
import type { MessageGateway } from '@zhin.js/core/runtime';
|
|
6
6
|
import type { HttpHost, HttpRouteRegistration } from '@zhin.js/host-http';
|
|
7
7
|
import { formatCompact, getLogger } from '@zhin.js/logger';
|
|
8
|
-
import type { CapabilityId } from '
|
|
8
|
+
import type { CapabilityId } from 'zhin.js';
|
|
9
9
|
import {
|
|
10
10
|
getPassiveReplyCapture,
|
|
11
11
|
runWithPassiveReplyCapture,
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* `wechat-mp.endpoint` 命令族:由 @zhin.js/adapter 的 createEndpointCommands 套件生成。
|
|
3
3
|
* commands/endpoint/ 下的 list / add / remove 直接默认导出这三项。
|
|
4
4
|
*/
|
|
5
|
-
import { createEndpointCommands } from '
|
|
6
|
-
import { defineCommand } from '
|
|
5
|
+
import { createEndpointCommands } from 'zhin.js/adapter';
|
|
6
|
+
import { defineCommand } from 'zhin.js/command';
|
|
7
7
|
import { wechatMpRuntimeStateToken } from './wechat-mp-runtime-state.js';
|
|
8
8
|
|
|
9
9
|
export const wechatMpEndpointCommands = createEndpointCommands({
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* WeChat MP 插件实例的运行时状态:adapter create() 注册的 endpoint 列表。
|
|
3
3
|
* 由 plugin.ts setup() provide,adapter create 与 `wechat-mp.endpoint` 命令共享(同一 owner generation)。
|
|
4
4
|
*/
|
|
5
|
-
import { defineEndpointRuntimeStateToken } from '
|
|
5
|
+
import { defineEndpointRuntimeStateToken } from 'zhin.js/adapter';
|
|
6
6
|
|
|
7
7
|
export const wechatMpRuntimeStateToken = defineEndpointRuntimeStateToken('wechat-mp');
|