@zhin.js/adapter-lark 1.1.18 → 1.1.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/lib/endpoint.d.ts CHANGED
@@ -1,105 +1,14 @@
1
- import type { LarkCardAction } from './cards.js';
2
- import { Endpoint, type EndpointTransportState, type EndpointControl, type EndpointManagement, type EndpointSendRequest } from 'zhin.js/adapter';
3
- import type { HttpHost } from '@zhin.js/host-http';
4
- import type { CapabilityId } from 'zhin.js';
5
- import { resolveMediaBinary } from './media-upload.js';
6
- import { type LarkMessage, type ResolvedLarkConfig } from './protocol.js';
7
- import { type LarkLongConnectionFactory } from './long-connection.js';
8
- export type LarkFetch = (url: string, init?: {
9
- readonly method?: string;
10
- readonly headers?: Record<string, string>;
11
- readonly body?: string | FormData;
12
- readonly signal?: AbortSignal;
13
- }) => Promise<{
14
- readonly ok: boolean;
15
- readonly status: number;
16
- text(): Promise<string>;
17
- json(): Promise<unknown>;
18
- }>;
19
- export interface LarkEndpointOptions {
20
- readonly id: CapabilityId;
21
- readonly http?: HttpHost;
22
- readonly longConnectionFactory?: LarkLongConnectionFactory;
23
- readonly config: ResolvedLarkConfig;
24
- readonly fetch?: LarkFetch;
25
- }
26
- export interface LarkClientApi {
27
- getUserInfo(userId: string, userIdType?: 'open_id' | 'user_id' | 'union_id'): Promise<unknown>;
28
- getChatInfo(chatId: string): Promise<unknown>;
29
- uploadFile(filePath: string, fileType?: 'image' | 'file' | 'video' | 'audio'): Promise<string | null>;
30
- createChat(name: string, userIds: string[], ownerId?: string): Promise<string | null>;
31
- updateChatInfo(chatId: string, options: {
32
- name?: string;
33
- description?: string;
34
- }): Promise<boolean>;
35
- addChatMembers(chatId: string, userIds: string[]): Promise<boolean>;
36
- removeChatMembers(chatId: string, userIds: string[]): Promise<boolean>;
37
- getChatMembers(chatId: string): Promise<unknown[]>;
38
- dissolveChat(chatId: string): Promise<boolean>;
39
- setChatManagers(chatId: string, userIds: string[]): Promise<boolean>;
40
- removeChatManagers(chatId: string, userIds: string[]): Promise<boolean>;
41
- }
42
- /** Feishu/Lark OpenAPI client surface carried by every Endpoint event. */
43
- export declare class LarkClient implements LarkClientApi {
44
- readonly api: LarkClientApi;
45
- constructor(api: LarkClientApi);
46
- getUserInfo: (id: string, type?: "open_id" | "user_id" | "union_id") => Promise<unknown>;
47
- getChatInfo: (id: string) => Promise<unknown>;
48
- uploadFile: (path: string, type?: "image" | "file" | "video" | "audio") => Promise<string | null>;
49
- createChat: (name: string, users: string[], owner?: string) => Promise<string | null>;
50
- updateChatInfo: (id: string, options: {
51
- name?: string;
52
- description?: string;
53
- }) => Promise<boolean>;
54
- addChatMembers: (id: string, users: string[]) => Promise<boolean>;
55
- removeChatMembers: (id: string, users: string[]) => Promise<boolean>;
56
- getChatMembers: (id: string) => Promise<unknown[]>;
57
- dissolveChat: (id: string) => Promise<boolean>;
58
- setChatManagers: (id: string, users: string[]) => Promise<boolean>;
59
- removeChatManagers: (id: string, users: string[]) => Promise<boolean>;
60
- }
61
- export declare class LarkEndpoint extends Endpoint<LarkClient> {
1
+ import { endpointSpec, type Endpoint } from 'zhin.js/adapter';
2
+ import { LarkClient, type LarkEndpointOptions } from './client.js';
3
+ export type { LarkEndpointOptions } from './client.js';
4
+ export type { LarkFetch } from './client.js';
5
+ /** Actual protocol Client; framework lifecycle and admission stay in their symbol namespace. */
6
+ export declare class LarkEndpoint extends LarkClient implements Endpoint {
62
7
  #private;
63
- readonly client: LarkClient;
64
- /**
65
- * Console 社交面语义端口。Lark OpenAPI 仅接读取类列表能力:
66
- * - listGroups:GET /im/v1/chats(bot 所在群列表,分页归一为 {group_id: chat_id, name})
67
- * - listGroupMembers:GET /im/v1/chats/:chat_id/members(open_id 分页,返回平台原生成员形状)
68
- * 不接的项:listFriends(Lark 无好友概念,contact API 为组织通讯录而非社交关系)、
69
- * listChannels(无频道/guild 概念)、写操作(审批/踢人/禁言等本轮不在范围内)。
70
- */
71
- readonly management: EndpointManagement;
72
- readonly control: EndpointControl;
8
+ readonly [endpointSpec]: import("@zhin.js/adapter").EndpointSpecification;
73
9
  constructor(options: LarkEndpointOptions);
74
- /** Used by webhook handler. */
75
- get isOpen(): boolean;
76
- get config(): ResolvedLarkConfig;
77
- get transportState(): EndpointTransportState | undefined;
78
- start(): Promise<void>;
79
- open(): void;
80
- close(): void;
81
- stop(): Promise<void>;
82
- send({ conversation, payload, locale }: EndpointSendRequest): Promise<string>;
83
- recallMessage(messageId: string): Promise<void>;
84
- /** Upload must succeed before issuing a message; dropped media is never confirmed. */
85
- uploadImage(media: Parameters<typeof resolveMediaBinary>[0]): Promise<string>;
86
- /** Test / internal: admit a parsed message when open (non-webhook path). */
87
- admit(msg: LarkMessage): void;
88
- /** Only correlate callbacks to a card actually sent by this endpoint. */
89
- admitCardAction(event: LarkCardAction): void;
90
- admitPlatform(name: string, event: unknown): void;
91
- getUserInfo(userId: string, userIdType?: 'open_id' | 'user_id' | 'union_id'): Promise<unknown>;
92
- getChatInfo(chatId: string): Promise<unknown>;
93
- uploadFile(filePath: string, fileType?: 'image' | 'file' | 'video' | 'audio'): Promise<string | null>;
94
- createChat(name: string, userIds: string[], ownerId?: string): Promise<string | null>;
95
- updateChatInfo(chatId: string, options: {
96
- name?: string;
97
- description?: string;
98
- }): Promise<boolean>;
99
- addChatMembers(chatId: string, userIds: string[]): Promise<boolean>;
100
- removeChatMembers(chatId: string, userIds: string[]): Promise<boolean>;
101
- getChatMembers(chatId: string): Promise<unknown[]>;
102
- dissolveChat(chatId: string): Promise<boolean>;
103
- setChatManagers(chatId: string, userIds: string[]): Promise<boolean>;
104
- removeChatManagers(chatId: string, userIds: string[]): Promise<boolean>;
10
+ protected receiveInboundCallback<T>(receive: () => T | Promise<T>): Promise<T>;
11
+ protected publishEvent(name: string, payload: unknown): Promise<unknown>;
12
+ protected publishAccepted(name: string, payload: unknown): Promise<void>;
13
+ protected publishPlatform(name: string, event: unknown): Promise<unknown>;
105
14
  }