@zhin.js/adapter-satori 5.0.13 → 6.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/CHANGELOG.md +12 -0
- package/adapters/satori.js +1 -0
- package/adapters/satori.ts +1 -0
- package/lib/endpoint.d.ts +5 -3
- package/lib/endpoint.js +10 -4
- package/package.json +9 -9
- package/src/endpoint.ts +11 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @zhin.js/adapter-satori
|
|
2
2
|
|
|
3
|
+
## 6.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f2c532f: Expose exact per-Endpoint message operations through one validated Adapter capability model, route Core control calls through declared active capabilities, and connect existing recall, edit, reaction, and typing implementations across platform adapters.
|
|
8
|
+
- Updated dependencies [b10d058]
|
|
9
|
+
- Updated dependencies [f2c532f]
|
|
10
|
+
- @zhin.js/host-http@1.0.12
|
|
11
|
+
- @zhin.js/adapter@1.2.0
|
|
12
|
+
- @zhin.js/core@1.5.13
|
|
13
|
+
- zhin.js@6.0.13
|
|
14
|
+
|
|
3
15
|
## 5.0.13
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/adapters/satori.js
CHANGED
|
@@ -11,6 +11,7 @@ import { satoriRuntimeStateToken } from "../lib/satori-runtime-state.js";
|
|
|
11
11
|
export { SatoriWebhookEndpoint, SatoriWsEndpoint } from "../lib/endpoint.js";
|
|
12
12
|
export default defineAdapter({
|
|
13
13
|
capabilities: ['inbound', 'outbound'],
|
|
14
|
+
operations: ['recall'],
|
|
14
15
|
// Satori 协议 img/file 元素消费 url 与 base64 内联数据;无卡片交互面,交互段降级纯文本。
|
|
15
16
|
segments: {
|
|
16
17
|
outboundMedia: ['url', 'base64'],
|
package/adapters/satori.ts
CHANGED
package/lib/endpoint.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SatoriEndpoint — WebSocket and webhook lifecycle, outbound, admit.
|
|
3
3
|
*/
|
|
4
|
-
import { type EndpointInstance, type EndpointManagement, type EndpointSendRequest } from 'zhin.js/adapter';
|
|
4
|
+
import { type EndpointControl, type EndpointInstance, type EndpointManagement, type EndpointSendRequest } from 'zhin.js/adapter';
|
|
5
5
|
import type { MessageGateway, SideEventGateway } from '@zhin.js/core/runtime';
|
|
6
6
|
import type { HttpHost } from '@zhin.js/host-http';
|
|
7
7
|
import type { CapabilityId } from 'zhin.js';
|
|
@@ -19,6 +19,7 @@ export interface SatoriWsEndpointOptions {
|
|
|
19
19
|
export declare class SatoriWsEndpoint implements EndpointInstance {
|
|
20
20
|
#private;
|
|
21
21
|
readonly management: EndpointManagement;
|
|
22
|
+
readonly control: EndpointControl;
|
|
22
23
|
constructor(options: SatoriWsEndpointOptions);
|
|
23
24
|
start(): Promise<void>;
|
|
24
25
|
open(): void;
|
|
@@ -27,7 +28,7 @@ export declare class SatoriWsEndpoint implements EndpointInstance {
|
|
|
27
28
|
send({ conversation, payload }: EndpointSendRequest): Promise<string>;
|
|
28
29
|
/** Test / internal: admit a gateway event when the endpoint is open. */
|
|
29
30
|
admit(body: SatoriEventBody): void;
|
|
30
|
-
recall(id: string): Promise<void>;
|
|
31
|
+
recall(id: string, fallbackChannelId?: string): Promise<void>;
|
|
31
32
|
/** Test helper: inject a READY login without a live socket. */
|
|
32
33
|
setLogin(login: SatoriLogin): void;
|
|
33
34
|
}
|
|
@@ -42,6 +43,7 @@ export interface SatoriWebhookEndpointOptions {
|
|
|
42
43
|
export declare class SatoriWebhookEndpoint implements EndpointInstance {
|
|
43
44
|
#private;
|
|
44
45
|
readonly management: EndpointManagement;
|
|
46
|
+
readonly control: EndpointControl;
|
|
45
47
|
constructor(options: SatoriWebhookEndpointOptions);
|
|
46
48
|
/** Used by webhook handler. */
|
|
47
49
|
get isOpen(): boolean;
|
|
@@ -52,7 +54,7 @@ export declare class SatoriWebhookEndpoint implements EndpointInstance {
|
|
|
52
54
|
stop(): Promise<void>;
|
|
53
55
|
send({ conversation, payload }: EndpointSendRequest): Promise<string>;
|
|
54
56
|
admit(body: SatoriEventBody): void;
|
|
55
|
-
recall(id: string): Promise<void>;
|
|
57
|
+
recall(id: string, fallbackChannelId?: string): Promise<void>;
|
|
56
58
|
/** Test helper: inject login without a live webhook push. */
|
|
57
59
|
setLogin(login: SatoriLogin): void;
|
|
58
60
|
}
|
package/lib/endpoint.js
CHANGED
|
@@ -15,6 +15,9 @@ export class SatoriWsEndpoint {
|
|
|
15
15
|
#lastSn;
|
|
16
16
|
#open = false;
|
|
17
17
|
management = createSatoriEndpointManagement((resource, method, params) => this.#api(resource, method, params));
|
|
18
|
+
control = Object.freeze({
|
|
19
|
+
recall: (message) => this.recall(message.id, message.conversation.id),
|
|
20
|
+
});
|
|
18
21
|
constructor(options) {
|
|
19
22
|
this.#logger = getAdapterLogger('satori', options.config.id);
|
|
20
23
|
this.#options = options;
|
|
@@ -114,10 +117,10 @@ export class SatoriWsEndpoint {
|
|
|
114
117
|
}));
|
|
115
118
|
});
|
|
116
119
|
}
|
|
117
|
-
async recall(id) {
|
|
120
|
+
async recall(id, fallbackChannelId) {
|
|
118
121
|
const { channelId, messageId } = parseMessageRef(id);
|
|
119
122
|
await this.#api('message', 'delete', {
|
|
120
|
-
channel_id: channelId,
|
|
123
|
+
channel_id: channelId || fallbackChannelId || '',
|
|
121
124
|
message_id: messageId,
|
|
122
125
|
});
|
|
123
126
|
}
|
|
@@ -248,6 +251,9 @@ export class SatoriWebhookEndpoint {
|
|
|
248
251
|
#open = false;
|
|
249
252
|
#started = false;
|
|
250
253
|
management = createSatoriEndpointManagement((resource, method, params) => this.#api(resource, method, params));
|
|
254
|
+
control = Object.freeze({
|
|
255
|
+
recall: (message) => this.recall(message.id, message.conversation.id),
|
|
256
|
+
});
|
|
251
257
|
constructor(options) {
|
|
252
258
|
this.#logger = getAdapterLogger('satori', options.config.id);
|
|
253
259
|
this.#options = options;
|
|
@@ -343,10 +349,10 @@ export class SatoriWebhookEndpoint {
|
|
|
343
349
|
}));
|
|
344
350
|
});
|
|
345
351
|
}
|
|
346
|
-
async recall(id) {
|
|
352
|
+
async recall(id, fallbackChannelId) {
|
|
347
353
|
const { channelId, messageId } = parseMessageRef(id);
|
|
348
354
|
await this.#api('message', 'delete', {
|
|
349
|
-
channel_id: channelId,
|
|
355
|
+
channel_id: channelId || fallbackChannelId || '',
|
|
350
356
|
message_id: messageId,
|
|
351
357
|
});
|
|
352
358
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/adapter-satori",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0",
|
|
4
4
|
"description": "Zhin.js Satori adapter for Plugin Runtime (WebSocket client)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"ws": "^8.21.1",
|
|
42
|
-
"@zhin.js/adapter": "1.
|
|
43
|
-
"@zhin.js/core": "1.5.
|
|
44
|
-
"@zhin.js/host-http": "1.0.
|
|
42
|
+
"@zhin.js/adapter": "1.2.0",
|
|
43
|
+
"@zhin.js/core": "1.5.13",
|
|
44
|
+
"@zhin.js/host-http": "1.0.12",
|
|
45
45
|
"@zhin.js/im-contract": "1.0.4",
|
|
46
46
|
"@zhin.js/logger": "1.0.76"
|
|
47
47
|
},
|
|
@@ -50,14 +50,14 @@
|
|
|
50
50
|
"@types/ws": "^8.18.1",
|
|
51
51
|
"typescript": "^6.0.3",
|
|
52
52
|
"vitest": "^4.1.10",
|
|
53
|
-
"@zhin.js/host-http": "1.0.
|
|
54
|
-
"zhin.js": "6.0.
|
|
53
|
+
"@zhin.js/host-http": "1.0.12",
|
|
54
|
+
"zhin.js": "6.0.13"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@zhin.js/adapter": "1.
|
|
57
|
+
"@zhin.js/adapter": "1.2.0",
|
|
58
58
|
"@zhin.js/command": "1.0.15",
|
|
59
|
-
"@zhin.js/core": "1.5.
|
|
60
|
-
"zhin.js": "6.0.
|
|
59
|
+
"@zhin.js/core": "1.5.13",
|
|
60
|
+
"zhin.js": "6.0.13"
|
|
61
61
|
},
|
|
62
62
|
"peerDependenciesMeta": {
|
|
63
63
|
"@zhin.js/command": {
|
package/src/endpoint.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
createEndpointLifecycle,
|
|
6
6
|
type EndpointChannel,
|
|
7
7
|
type EndpointConnectHandle,
|
|
8
|
+
type EndpointControl,
|
|
8
9
|
type EndpointGroup,
|
|
9
10
|
type EndpointInstance,
|
|
10
11
|
type EndpointLifecycle,
|
|
@@ -66,6 +67,9 @@ export class SatoriWsEndpoint implements EndpointInstance {
|
|
|
66
67
|
readonly management: EndpointManagement = createSatoriEndpointManagement(
|
|
67
68
|
(resource, method, params) => this.#api(resource, method, params),
|
|
68
69
|
);
|
|
70
|
+
readonly control: EndpointControl = Object.freeze<EndpointControl>({
|
|
71
|
+
recall: (message) => this.recall(message.id, message.conversation.id),
|
|
72
|
+
});
|
|
69
73
|
|
|
70
74
|
constructor(options: SatoriWsEndpointOptions) {
|
|
71
75
|
this.#logger = getAdapterLogger('satori', options.config.id);
|
|
@@ -168,10 +172,10 @@ export class SatoriWsEndpoint implements EndpointInstance {
|
|
|
168
172
|
});
|
|
169
173
|
}
|
|
170
174
|
|
|
171
|
-
async recall(id: string): Promise<void> {
|
|
175
|
+
async recall(id: string, fallbackChannelId?: string): Promise<void> {
|
|
172
176
|
const { channelId, messageId } = parseMessageRef(id);
|
|
173
177
|
await this.#api('message', 'delete', {
|
|
174
|
-
channel_id: channelId,
|
|
178
|
+
channel_id: channelId || fallbackChannelId || '',
|
|
175
179
|
message_id: messageId,
|
|
176
180
|
});
|
|
177
181
|
}
|
|
@@ -325,6 +329,9 @@ export class SatoriWebhookEndpoint implements EndpointInstance {
|
|
|
325
329
|
readonly management: EndpointManagement = createSatoriEndpointManagement(
|
|
326
330
|
(resource, method, params) => this.#api(resource, method, params),
|
|
327
331
|
);
|
|
332
|
+
readonly control: EndpointControl = Object.freeze<EndpointControl>({
|
|
333
|
+
recall: (message) => this.recall(message.id, message.conversation.id),
|
|
334
|
+
});
|
|
328
335
|
|
|
329
336
|
constructor(options: SatoriWebhookEndpointOptions) {
|
|
330
337
|
this.#logger = getAdapterLogger('satori', options.config.id);
|
|
@@ -425,10 +432,10 @@ export class SatoriWebhookEndpoint implements EndpointInstance {
|
|
|
425
432
|
});
|
|
426
433
|
}
|
|
427
434
|
|
|
428
|
-
async recall(id: string): Promise<void> {
|
|
435
|
+
async recall(id: string, fallbackChannelId?: string): Promise<void> {
|
|
429
436
|
const { channelId, messageId } = parseMessageRef(id);
|
|
430
437
|
await this.#api('message', 'delete', {
|
|
431
|
-
channel_id: channelId,
|
|
438
|
+
channel_id: channelId || fallbackChannelId || '',
|
|
432
439
|
message_id: messageId,
|
|
433
440
|
});
|
|
434
441
|
}
|