@im-more/dsh-slack 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/cordis.patch.yml +13 -0
- package/lib/index.js +2659 -0
- package/lib/index.js.map +1 -0
- package/lib/types/bot.d.ts +66 -0
- package/lib/types/bot.d.ts.map +1 -0
- package/lib/types/bot.js +165 -0
- package/lib/types/bot.js.map +1 -0
- package/lib/types/config.d.ts +49 -0
- package/lib/types/config.d.ts.map +1 -0
- package/lib/types/config.js +54 -0
- package/lib/types/config.js.map +1 -0
- package/lib/types/decode.d.ts +126 -0
- package/lib/types/decode.d.ts.map +1 -0
- package/lib/types/decode.js +396 -0
- package/lib/types/decode.js.map +1 -0
- package/lib/types/errors.d.ts +61 -0
- package/lib/types/errors.d.ts.map +1 -0
- package/lib/types/errors.js +196 -0
- package/lib/types/errors.js.map +1 -0
- package/lib/types/identity.d.ts +27 -0
- package/lib/types/identity.d.ts.map +1 -0
- package/lib/types/identity.js +35 -0
- package/lib/types/identity.js.map +1 -0
- package/lib/types/index.d.ts +14 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +14 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/modes/mrkdwn.d.ts +17 -0
- package/lib/types/modes/mrkdwn.d.ts.map +1 -0
- package/lib/types/modes/mrkdwn.js +123 -0
- package/lib/types/modes/mrkdwn.js.map +1 -0
- package/lib/types/modes/shared.d.ts +164 -0
- package/lib/types/modes/shared.d.ts.map +1 -0
- package/lib/types/modes/shared.js +411 -0
- package/lib/types/modes/shared.js.map +1 -0
- package/lib/types/mrkdwn.d.ts +41 -0
- package/lib/types/mrkdwn.d.ts.map +1 -0
- package/lib/types/mrkdwn.js +137 -0
- package/lib/types/mrkdwn.js.map +1 -0
- package/lib/types/request.d.ts +225 -0
- package/lib/types/request.d.ts.map +1 -0
- package/lib/types/request.js +330 -0
- package/lib/types/request.js.map +1 -0
- package/lib/types/send.d.ts +74 -0
- package/lib/types/send.d.ts.map +1 -0
- package/lib/types/send.js +200 -0
- package/lib/types/send.js.map +1 -0
- package/lib/types/transport/socket.d.ts +58 -0
- package/lib/types/transport/socket.d.ts.map +1 -0
- package/lib/types/transport/socket.js +297 -0
- package/lib/types/transport/socket.js.map +1 -0
- package/lib/types/transport/webhook.d.ts +48 -0
- package/lib/types/transport/webhook.d.ts.map +1 -0
- package/lib/types/transport/webhook.js +210 -0
- package/lib/types/transport/webhook.js.map +1 -0
- package/lib/types/types/admin.d.ts +682 -0
- package/lib/types/types/admin.d.ts.map +1 -0
- package/lib/types/types/admin.js +172 -0
- package/lib/types/types/admin.js.map +1 -0
- package/lib/types/types/api.d.ts +20 -0
- package/lib/types/types/api.d.ts.map +1 -0
- package/lib/types/types/api.js +7 -0
- package/lib/types/types/api.js.map +1 -0
- package/lib/types/types/apps.d.ts +138 -0
- package/lib/types/types/apps.d.ts.map +1 -0
- package/lib/types/types/apps.js +28 -0
- package/lib/types/types/apps.js.map +1 -0
- package/lib/types/types/auth.d.ts +36 -0
- package/lib/types/types/auth.d.ts.map +1 -0
- package/lib/types/types/auth.js +10 -0
- package/lib/types/types/auth.js.map +1 -0
- package/lib/types/types/bots.d.ts +32 -0
- package/lib/types/types/bots.d.ts.map +1 -0
- package/lib/types/types/bots.js +7 -0
- package/lib/types/types/bots.js.map +1 -0
- package/lib/types/types/calls.d.ts +82 -0
- package/lib/types/types/calls.d.ts.map +1 -0
- package/lib/types/types/calls.js +22 -0
- package/lib/types/types/calls.js.map +1 -0
- package/lib/types/types/chat.d.ts +208 -0
- package/lib/types/types/chat.d.ts.map +1 -0
- package/lib/types/types/chat.js +34 -0
- package/lib/types/types/chat.js.map +1 -0
- package/lib/types/types/conversations.d.ts +266 -0
- package/lib/types/types/conversations.d.ts.map +1 -0
- package/lib/types/types/conversations.js +58 -0
- package/lib/types/types/conversations.js.map +1 -0
- package/lib/types/types/definition.d.ts +505 -0
- package/lib/types/types/definition.d.ts.map +1 -0
- package/lib/types/types/definition.js +2 -0
- package/lib/types/types/definition.js.map +1 -0
- package/lib/types/types/dialog.d.ts +20 -0
- package/lib/types/types/dialog.d.ts.map +1 -0
- package/lib/types/types/dialog.js +7 -0
- package/lib/types/types/dialog.js.map +1 -0
- package/lib/types/types/dnd.d.ts +70 -0
- package/lib/types/types/dnd.d.ts.map +1 -0
- package/lib/types/types/dnd.js +19 -0
- package/lib/types/types/dnd.js.map +1 -0
- package/lib/types/types/emoji.d.ts +18 -0
- package/lib/types/types/emoji.d.ts.map +1 -0
- package/lib/types/types/emoji.js +7 -0
- package/lib/types/types/emoji.js.map +1 -0
- package/lib/types/types/events/base-events.d.ts +235 -0
- package/lib/types/types/events/base-events.d.ts.map +1 -0
- package/lib/types/types/events/base-events.js +3 -0
- package/lib/types/types/events/base-events.js.map +1 -0
- package/lib/types/types/events/index.d.ts +97 -0
- package/lib/types/types/events/index.d.ts.map +1 -0
- package/lib/types/types/events/index.js +3 -0
- package/lib/types/types/events/index.js.map +1 -0
- package/lib/types/types/events/message-events.d.ts +215 -0
- package/lib/types/types/events/message-events.d.ts.map +1 -0
- package/lib/types/types/events/message-events.js +3 -0
- package/lib/types/types/events/message-events.js.map +1 -0
- package/lib/types/types/files.d.ts +189 -0
- package/lib/types/types/files.d.ts.map +1 -0
- package/lib/types/types/files.js +43 -0
- package/lib/types/types/files.js.map +1 -0
- package/lib/types/types/index.d.ts +82 -0
- package/lib/types/types/index.d.ts.map +1 -0
- package/lib/types/types/index.js +29 -0
- package/lib/types/types/index.js.map +1 -0
- package/lib/types/types/internal.d.ts +17 -0
- package/lib/types/types/internal.d.ts.map +1 -0
- package/lib/types/types/internal.js +60 -0
- package/lib/types/types/internal.js.map +1 -0
- package/lib/types/types/migration.d.ts +25 -0
- package/lib/types/types/migration.d.ts.map +1 -0
- package/lib/types/types/migration.js +7 -0
- package/lib/types/types/migration.js.map +1 -0
- package/lib/types/types/oauth.d.ts +50 -0
- package/lib/types/types/oauth.d.ts.map +1 -0
- package/lib/types/types/oauth.js +13 -0
- package/lib/types/types/oauth.js.map +1 -0
- package/lib/types/types/pins.d.ts +39 -0
- package/lib/types/types/pins.d.ts.map +1 -0
- package/lib/types/types/pins.js +13 -0
- package/lib/types/types/pins.js.map +1 -0
- package/lib/types/types/reactions.d.ts +75 -0
- package/lib/types/types/reactions.d.ts.map +1 -0
- package/lib/types/types/reactions.js +16 -0
- package/lib/types/types/reactions.js.map +1 -0
- package/lib/types/types/reminders.d.ts +64 -0
- package/lib/types/types/reminders.d.ts.map +1 -0
- package/lib/types/types/reminders.js +19 -0
- package/lib/types/types/reminders.js.map +1 -0
- package/lib/types/types/rtm.d.ts +30 -0
- package/lib/types/types/rtm.d.ts.map +1 -0
- package/lib/types/types/rtm.js +7 -0
- package/lib/types/types/rtm.js.map +1 -0
- package/lib/types/types/search.d.ts +24 -0
- package/lib/types/types/search.d.ts.map +1 -0
- package/lib/types/types/search.js +7 -0
- package/lib/types/types/search.js.map +1 -0
- package/lib/types/types/stars.d.ts +56 -0
- package/lib/types/types/stars.d.ts.map +1 -0
- package/lib/types/types/stars.js +13 -0
- package/lib/types/types/stars.js.map +1 -0
- package/lib/types/types/team.d.ts +98 -0
- package/lib/types/types/team.d.ts.map +1 -0
- package/lib/types/types/team.js +19 -0
- package/lib/types/types/team.js.map +1 -0
- package/lib/types/types/usergroups.d.ts +103 -0
- package/lib/types/types/usergroups.d.ts.map +1 -0
- package/lib/types/types/usergroups.js +25 -0
- package/lib/types/types/usergroups.js.map +1 -0
- package/lib/types/types/users.d.ts +169 -0
- package/lib/types/types/users.d.ts.map +1 -0
- package/lib/types/types/users.js +40 -0
- package/lib/types/types/users.js.map +1 -0
- package/lib/types/types/views.d.ts +56 -0
- package/lib/types/types/views.d.ts.map +1 -0
- package/lib/types/types/views.js +16 -0
- package/lib/types/types/views.js.map +1 -0
- package/lib/types/types/workflows.d.ts +45 -0
- package/lib/types/types/workflows.d.ts.map +1 -0
- package/lib/types/types/workflows.js +13 -0
- package/lib/types/types/workflows.js.map +1 -0
- package/package.json +65 -3
- package/src/bot.ts +273 -0
- package/src/config.ts +92 -0
- package/src/decode.ts +489 -0
- package/src/errors.ts +230 -0
- package/src/identity.ts +59 -0
- package/src/index.ts +64 -0
- package/src/modes/mrkdwn.ts +159 -0
- package/src/modes/shared.ts +515 -0
- package/src/mrkdwn.ts +146 -0
- package/src/request.ts +449 -0
- package/src/send.ts +300 -0
- package/src/transport/socket.ts +393 -0
- package/src/transport/webhook.ts +269 -0
- package/src/types/admin.ts +910 -0
- package/src/types/api.ts +28 -0
- package/src/types/apps.ts +175 -0
- package/src/types/auth.ts +49 -0
- package/src/types/bots.ts +40 -0
- package/src/types/calls.ts +110 -0
- package/src/types/chat.ts +255 -0
- package/src/types/conversations.ts +342 -0
- package/src/types/definition.ts +530 -0
- package/src/types/dialog.ts +28 -0
- package/src/types/dnd.ts +94 -0
- package/src/types/emoji.ts +26 -0
- package/src/types/events/base-events.ts +281 -0
- package/src/types/events/index.ts +125 -0
- package/src/types/events/message-events.ts +253 -0
- package/src/types/files.ts +245 -0
- package/src/types/index.ts +84 -0
- package/src/types/internal.ts +60 -0
- package/src/types/migration.ts +34 -0
- package/src/types/oauth.ts +66 -0
- package/src/types/pins.ts +55 -0
- package/src/types/reactions.ts +95 -0
- package/src/types/reminders.ts +88 -0
- package/src/types/rtm.ts +38 -0
- package/src/types/search.ts +32 -0
- package/src/types/stars.ts +72 -0
- package/src/types/team.ts +122 -0
- package/src/types/usergroups.ts +135 -0
- package/src/types/users.ts +221 -0
- package/src/types/views.ts +76 -0
- package/src/types/workflows.ts +61 -0
- package/README.md +0 -3
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slack Web API transport: one request path for every method the adapter calls, the `ok` envelope, `Retry-After`,
|
|
3
|
+
* credential-scoped file downloads and the two-step file upload.
|
|
4
|
+
*
|
|
5
|
+
* The migrated `Internal` class in `types/internal.ts` keeps the complete documented method surface for
|
|
6
|
+
* `bot.internal`; the adapter's own calls go through this module because `Internal` hands back the parsed envelope
|
|
7
|
+
* only, while classification needs the one thing the envelope does not carry: the HTTP status and `Retry-After` of a
|
|
8
|
+
* 429 answer.
|
|
9
|
+
*/
|
|
10
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
11
|
+
/** Everything one bot needs to make Slack Web API requests. */
|
|
12
|
+
export interface SlackApi {
|
|
13
|
+
readonly ctx: Context;
|
|
14
|
+
/** Web API root, without a trailing slash (`https://slack.com/api`). */
|
|
15
|
+
readonly base: string;
|
|
16
|
+
/** `xoxb-…`: every method except `apps.connections.open`. */
|
|
17
|
+
readonly botToken: string;
|
|
18
|
+
/** `xapp-…`: only `apps.connections.open`. */
|
|
19
|
+
readonly appToken: string;
|
|
20
|
+
}
|
|
21
|
+
/** One request body: flat values, with arrays sent as their JSON text in a form field. */
|
|
22
|
+
export type SlackParams = Record<string, unknown>;
|
|
23
|
+
/**
|
|
24
|
+
* The endpoints the adapter calls, keyed by method name.
|
|
25
|
+
*
|
|
26
|
+
* The method → path/method/body mapping is the one `Internal.define` installs for the migrated declarations; the two
|
|
27
|
+
* `files.*` upload methods are absent from those 2023 declarations, so their entries are the current API's.
|
|
28
|
+
*/
|
|
29
|
+
export declare const ROUTES: {
|
|
30
|
+
readonly authTest: {
|
|
31
|
+
readonly path: "/auth.test";
|
|
32
|
+
readonly method: "GET";
|
|
33
|
+
readonly json: false;
|
|
34
|
+
};
|
|
35
|
+
readonly appsConnectionsOpen: {
|
|
36
|
+
readonly path: "/apps.connections.open";
|
|
37
|
+
readonly method: "POST";
|
|
38
|
+
readonly json: false;
|
|
39
|
+
};
|
|
40
|
+
readonly chatDelete: {
|
|
41
|
+
readonly path: "/chat.delete";
|
|
42
|
+
readonly method: "POST";
|
|
43
|
+
readonly json: true;
|
|
44
|
+
};
|
|
45
|
+
readonly chatPostMessage: {
|
|
46
|
+
readonly path: "/chat.postMessage";
|
|
47
|
+
readonly method: "POST";
|
|
48
|
+
readonly json: true;
|
|
49
|
+
};
|
|
50
|
+
readonly conversationsHistory: {
|
|
51
|
+
readonly path: "/conversations.history";
|
|
52
|
+
readonly method: "GET";
|
|
53
|
+
readonly json: false;
|
|
54
|
+
};
|
|
55
|
+
readonly filesInfo: {
|
|
56
|
+
readonly path: "/files.info";
|
|
57
|
+
readonly method: "GET";
|
|
58
|
+
readonly json: false;
|
|
59
|
+
};
|
|
60
|
+
readonly reactionsAdd: {
|
|
61
|
+
readonly path: "/reactions.add";
|
|
62
|
+
readonly method: "POST";
|
|
63
|
+
readonly json: true;
|
|
64
|
+
};
|
|
65
|
+
readonly reactionsRemove: {
|
|
66
|
+
readonly path: "/reactions.remove";
|
|
67
|
+
readonly method: "POST";
|
|
68
|
+
readonly json: true;
|
|
69
|
+
};
|
|
70
|
+
readonly usersList: {
|
|
71
|
+
readonly path: "/users.list";
|
|
72
|
+
readonly method: "GET";
|
|
73
|
+
readonly json: false;
|
|
74
|
+
};
|
|
75
|
+
readonly getUploadUrlExternal: {
|
|
76
|
+
readonly path: "/files.getUploadURLExternal";
|
|
77
|
+
readonly method: "POST";
|
|
78
|
+
readonly json: false;
|
|
79
|
+
};
|
|
80
|
+
readonly completeUploadExternal: {
|
|
81
|
+
readonly path: "/files.completeUploadExternal";
|
|
82
|
+
readonly method: "POST";
|
|
83
|
+
readonly json: false;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
/** One Web API method this adapter calls. */
|
|
87
|
+
export type SlackMethod = keyof typeof ROUTES;
|
|
88
|
+
/** The fields every Slack answer carries, plus the two warning carriers. */
|
|
89
|
+
export interface SlackEnvelope {
|
|
90
|
+
ok?: boolean;
|
|
91
|
+
error?: string;
|
|
92
|
+
/** `chat.*` reports a single warning here (`message_truncated`). */
|
|
93
|
+
warning?: string;
|
|
94
|
+
/** Other methods report warnings here. */
|
|
95
|
+
response_metadata?: {
|
|
96
|
+
next_cursor?: string;
|
|
97
|
+
warnings?: string[];
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export interface CallOptions {
|
|
101
|
+
/** Use the app-level token (`apps.connections.open`) instead of the bot token. */
|
|
102
|
+
app?: boolean;
|
|
103
|
+
signal?: AbortSignal;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Build the request endpoints of one bot.
|
|
107
|
+
* @param ctx - the context whose `http` service performs the requests.
|
|
108
|
+
* @param config - `apiBaseUrl` of the profile row.
|
|
109
|
+
* @param botToken - the bot token.
|
|
110
|
+
* @param appToken - the app-level token.
|
|
111
|
+
* @returns the request dependencies, shared by every call of the bot.
|
|
112
|
+
*/
|
|
113
|
+
export declare function createSlackApi(ctx: Context, config: {
|
|
114
|
+
apiBaseUrl: string;
|
|
115
|
+
botToken: string;
|
|
116
|
+
token: string;
|
|
117
|
+
}): SlackApi;
|
|
118
|
+
/**
|
|
119
|
+
* A request body encoded as form fields; an array becomes its JSON text, as Slack's file methods expect.
|
|
120
|
+
* @param params - the request body.
|
|
121
|
+
* @returns the body to send with `application/x-www-form-urlencoded`.
|
|
122
|
+
*/
|
|
123
|
+
export declare function encodeForm(params: SlackParams): URLSearchParams;
|
|
124
|
+
/**
|
|
125
|
+
* `Retry-After` of a 429 answer, in milliseconds.
|
|
126
|
+
* @param response - the answer.
|
|
127
|
+
* @returns the delay in milliseconds, or undefined when the header is absent or unreadable.
|
|
128
|
+
*/
|
|
129
|
+
export declare function retryAfterOf(response: Response): number | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* Refuse an answer that does not say `ok: true`.
|
|
132
|
+
*
|
|
133
|
+
* `Internal` hands the raw envelope back, so every call site used to have to remember this check. A successful answer
|
|
134
|
+
* may still carry a warning (`message_truncated`), which is logged: the text was accepted but shortened, so it is not
|
|
135
|
+
* an error and must not fail the send.
|
|
136
|
+
*
|
|
137
|
+
* @param api - the request dependencies, for the logger.
|
|
138
|
+
* @param method - Slack method name, for the message.
|
|
139
|
+
* @param body - the parsed envelope.
|
|
140
|
+
* @param status - HTTP status of the answer.
|
|
141
|
+
* @returns the same envelope, for the caller to read its payload.
|
|
142
|
+
* @throws SlackApiError when the platform refused the call.
|
|
143
|
+
*/
|
|
144
|
+
export declare function ensureOk<V extends SlackEnvelope>(api: SlackApi, method: SlackMethod, body: V, status?: number): V;
|
|
145
|
+
/**
|
|
146
|
+
* Call one Web API method and return its `ok: true` answer.
|
|
147
|
+
*
|
|
148
|
+
* @param api - the request dependencies.
|
|
149
|
+
* @param method - Slack method name.
|
|
150
|
+
* @param params - query parameters of a GET, or the request body.
|
|
151
|
+
* @param options - app-token selection and cancellation.
|
|
152
|
+
* @returns the parsed answer.
|
|
153
|
+
* @throws SlackApiError for a status, a refusal or an unreadable answer.
|
|
154
|
+
*/
|
|
155
|
+
export declare function callApi<V extends SlackEnvelope>(api: SlackApi, method: SlackMethod, params?: SlackParams, options?: CallOptions): Promise<V>;
|
|
156
|
+
/**
|
|
157
|
+
* Whether a URL names a host the bot token may be sent to.
|
|
158
|
+
*
|
|
159
|
+
* Slack's guidance is to never send the credentials to a host outside Slack, and a `url_private` of a remote file
|
|
160
|
+
* names an external host. The comparison is exact on the parsed hostname: `files.slack.com.evil.example` and
|
|
161
|
+
* `evil-slack.com` are both refused, and plain HTTP is refused because the token would travel unencrypted.
|
|
162
|
+
*
|
|
163
|
+
* @param url - the file URL.
|
|
164
|
+
* @returns whether the bot token may be presented to it.
|
|
165
|
+
*/
|
|
166
|
+
export declare function isSlackFileUrl(url: URL): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Download one Slack-hosted file with the bot token.
|
|
169
|
+
*
|
|
170
|
+
* @param api - the request dependencies.
|
|
171
|
+
* @param src - `url_private` of a `files.info` answer.
|
|
172
|
+
* @param signal - cancellation.
|
|
173
|
+
* @returns the response whose body is the file.
|
|
174
|
+
* @throws SlackApiError when the host is not a Slack file host.
|
|
175
|
+
*/
|
|
176
|
+
export declare function downloadFile(api: SlackApi, src: string, signal?: AbortSignal): Promise<Response>;
|
|
177
|
+
/** A ticket of the two-step upload. */
|
|
178
|
+
export interface SlackUploadTicket {
|
|
179
|
+
/** Pre-signed URL of the byte upload; it is not on `slack.com/api` and carries no credentials. */
|
|
180
|
+
uploadUrl: string;
|
|
181
|
+
fileId: string;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Ask for the upload URL and the file id (`files.getUploadURLExternal`).
|
|
185
|
+
* @param api - the request dependencies.
|
|
186
|
+
* @param file - name and byte length the platform records.
|
|
187
|
+
* @param signal - cancellation.
|
|
188
|
+
* @returns the ticket of the byte upload.
|
|
189
|
+
*/
|
|
190
|
+
export declare function startUpload(api: SlackApi, file: {
|
|
191
|
+
name: string;
|
|
192
|
+
length: number;
|
|
193
|
+
}, signal?: AbortSignal): Promise<SlackUploadTicket>;
|
|
194
|
+
/**
|
|
195
|
+
* Upload the bytes to the ticket's URL.
|
|
196
|
+
*
|
|
197
|
+
* The URL is pre-signed, so no credential travels with it; the answer is plain text (`OK - <size>`), so a 2xx is the
|
|
198
|
+
* whole success signal.
|
|
199
|
+
*
|
|
200
|
+
* @param api - the request dependencies.
|
|
201
|
+
* @param ticket - what {@link startUpload} returned.
|
|
202
|
+
* @param data - the file bytes.
|
|
203
|
+
* @param signal - cancellation.
|
|
204
|
+
*/
|
|
205
|
+
export declare function putUploadBytes(api: SlackApi, ticket: SlackUploadTicket, data: Uint8Array, signal?: AbortSignal): Promise<void>;
|
|
206
|
+
/** One file of the `files.completeUploadExternal` answer. */
|
|
207
|
+
export interface SlackUploadedFile {
|
|
208
|
+
id?: string;
|
|
209
|
+
created?: number;
|
|
210
|
+
shares?: unknown;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Share an uploaded file into a channel (`files.completeUploadExternal`).
|
|
214
|
+
* @param api - the request dependencies.
|
|
215
|
+
* @param files - ids and titles to share.
|
|
216
|
+
* @param channel - channel the file message appears in.
|
|
217
|
+
* @param threadTs - thread to post the file into, when the message answers a thread.
|
|
218
|
+
* @param signal - cancellation.
|
|
219
|
+
* @returns the shared files, from which the message timestamp is read.
|
|
220
|
+
*/
|
|
221
|
+
export declare function finishUpload(api: SlackApi, files: readonly {
|
|
222
|
+
id: string;
|
|
223
|
+
title: string;
|
|
224
|
+
}[], channel: string, threadTs: string | undefined, signal?: AbortSignal): Promise<SlackUploadedFile[]>;
|
|
225
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/request.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAIlD,+DAA+D;AAC/D,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;IACrB,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,6DAA6D;IAC7D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,8CAA8C;IAC9C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B;AAED,0FAA0F;AAC1F,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAUjD;;;;;GAKG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4B4B,CAAA;AAE/C,6CAA6C;AAC7C,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,MAAM,CAAA;AAE7C,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC5B,EAAE,CAAC,EAAE,OAAO,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,0CAA0C;IAC1C,iBAAiB,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE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;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EACtC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,iBAAiB,CAAC,CAgB5B;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,QAAQ,EACb,MAAM,EAAE,iBAAiB,EACzB,IAAI,EAAE,UAAU,EAChB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC,CAuBf;AAED,6DAA6D;AAC7D,MAAM,WAAW,iBAAiB;IAChC,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,SAAS;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,EAC/C,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAY9B"}
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slack Web API transport: one request path for every method the adapter calls, the `ok` envelope, `Retry-After`,
|
|
3
|
+
* credential-scoped file downloads and the two-step file upload.
|
|
4
|
+
*
|
|
5
|
+
* The migrated `Internal` class in `types/internal.ts` keeps the complete documented method surface for
|
|
6
|
+
* `bot.internal`; the adapter's own calls go through this module because `Internal` hands back the parsed envelope
|
|
7
|
+
* only, while classification needs the one thing the envelope does not carry: the HTTP status and `Retry-After` of a
|
|
8
|
+
* 429 answer.
|
|
9
|
+
*/
|
|
10
|
+
import { SlackApiError } from "./errors.js";
|
|
11
|
+
/**
|
|
12
|
+
* The endpoints the adapter calls, keyed by method name.
|
|
13
|
+
*
|
|
14
|
+
* The method → path/method/body mapping is the one `Internal.define` installs for the migrated declarations; the two
|
|
15
|
+
* `files.*` upload methods are absent from those 2023 declarations, so their entries are the current API's.
|
|
16
|
+
*/
|
|
17
|
+
export const ROUTES = {
|
|
18
|
+
authTest: { path: '/auth.test', method: 'GET', json: false },
|
|
19
|
+
appsConnectionsOpen: {
|
|
20
|
+
path: '/apps.connections.open',
|
|
21
|
+
method: 'POST',
|
|
22
|
+
json: false,
|
|
23
|
+
},
|
|
24
|
+
chatDelete: { path: '/chat.delete', method: 'POST', json: true },
|
|
25
|
+
chatPostMessage: { path: '/chat.postMessage', method: 'POST', json: true },
|
|
26
|
+
conversationsHistory: {
|
|
27
|
+
path: '/conversations.history',
|
|
28
|
+
method: 'GET',
|
|
29
|
+
json: false,
|
|
30
|
+
},
|
|
31
|
+
filesInfo: { path: '/files.info', method: 'GET', json: false },
|
|
32
|
+
reactionsAdd: { path: '/reactions.add', method: 'POST', json: true },
|
|
33
|
+
reactionsRemove: { path: '/reactions.remove', method: 'POST', json: true },
|
|
34
|
+
usersList: { path: '/users.list', method: 'GET', json: false },
|
|
35
|
+
getUploadUrlExternal: {
|
|
36
|
+
path: '/files.getUploadURLExternal',
|
|
37
|
+
method: 'POST',
|
|
38
|
+
json: false,
|
|
39
|
+
},
|
|
40
|
+
completeUploadExternal: {
|
|
41
|
+
path: '/files.completeUploadExternal',
|
|
42
|
+
method: 'POST',
|
|
43
|
+
json: false,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Build the request endpoints of one bot.
|
|
48
|
+
* @param ctx - the context whose `http` service performs the requests.
|
|
49
|
+
* @param config - `apiBaseUrl` of the profile row.
|
|
50
|
+
* @param botToken - the bot token.
|
|
51
|
+
* @param appToken - the app-level token.
|
|
52
|
+
* @returns the request dependencies, shared by every call of the bot.
|
|
53
|
+
*/
|
|
54
|
+
export function createSlackApi(ctx, config) {
|
|
55
|
+
return {
|
|
56
|
+
ctx,
|
|
57
|
+
base: config.apiBaseUrl.replace(/\/+$/, ''),
|
|
58
|
+
botToken: config.botToken,
|
|
59
|
+
appToken: config.token,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A request body encoded as form fields; an array becomes its JSON text, as Slack's file methods expect.
|
|
64
|
+
* @param params - the request body.
|
|
65
|
+
* @returns the body to send with `application/x-www-form-urlencoded`.
|
|
66
|
+
*/
|
|
67
|
+
export function encodeForm(params) {
|
|
68
|
+
const form = new URLSearchParams();
|
|
69
|
+
for (const [key, value] of Object.entries(params)) {
|
|
70
|
+
if (value === undefined || value === null)
|
|
71
|
+
continue;
|
|
72
|
+
form.append(key, typeof value === 'object' ? JSON.stringify(value) : String(value));
|
|
73
|
+
}
|
|
74
|
+
return form;
|
|
75
|
+
}
|
|
76
|
+
/** Whether a caught value is the abort error of a cancelled request. */
|
|
77
|
+
function isAbortError(error) {
|
|
78
|
+
return ((error instanceof Error || error instanceof DOMException) &&
|
|
79
|
+
error.name === 'AbortError');
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* `Retry-After` of a 429 answer, in milliseconds.
|
|
83
|
+
* @param response - the answer.
|
|
84
|
+
* @returns the delay in milliseconds, or undefined when the header is absent or unreadable.
|
|
85
|
+
*/
|
|
86
|
+
export function retryAfterOf(response) {
|
|
87
|
+
const header = response.headers.get('retry-after');
|
|
88
|
+
if (header === null)
|
|
89
|
+
return undefined;
|
|
90
|
+
const seconds = Number(header);
|
|
91
|
+
if (!Number.isFinite(seconds) || seconds < 0)
|
|
92
|
+
return undefined;
|
|
93
|
+
return seconds * 1000;
|
|
94
|
+
}
|
|
95
|
+
/** Read a JSON answer; an unreadable body is reported as absence rather than a parse error. */
|
|
96
|
+
async function jsonOf(response) {
|
|
97
|
+
let body;
|
|
98
|
+
try {
|
|
99
|
+
body = await response.json();
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
// The answer carried no JSON (a proxy error page, an empty body): the caller reports the status instead.
|
|
103
|
+
void error;
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
if (typeof body !== 'object' || body === null)
|
|
107
|
+
return undefined;
|
|
108
|
+
return body;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Refuse an answer that does not say `ok: true`.
|
|
112
|
+
*
|
|
113
|
+
* `Internal` hands the raw envelope back, so every call site used to have to remember this check. A successful answer
|
|
114
|
+
* may still carry a warning (`message_truncated`), which is logged: the text was accepted but shortened, so it is not
|
|
115
|
+
* an error and must not fail the send.
|
|
116
|
+
*
|
|
117
|
+
* @param api - the request dependencies, for the logger.
|
|
118
|
+
* @param method - Slack method name, for the message.
|
|
119
|
+
* @param body - the parsed envelope.
|
|
120
|
+
* @param status - HTTP status of the answer.
|
|
121
|
+
* @returns the same envelope, for the caller to read its payload.
|
|
122
|
+
* @throws SlackApiError when the platform refused the call.
|
|
123
|
+
*/
|
|
124
|
+
export function ensureOk(api, method, body, status = 200) {
|
|
125
|
+
const name = ROUTES[method].path.slice(1);
|
|
126
|
+
if (body.ok !== true) {
|
|
127
|
+
throw new SlackApiError(`slack ${name} failed: ${body.error ?? 'the answer does not say ok'}`, {
|
|
128
|
+
method: name,
|
|
129
|
+
status,
|
|
130
|
+
...(body.error === undefined ? {} : { code: body.error }),
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
const warnings = [
|
|
134
|
+
...(body.warning === undefined ? [] : [body.warning]),
|
|
135
|
+
...(body.response_metadata?.warnings ?? []),
|
|
136
|
+
];
|
|
137
|
+
if (warnings.length > 0) {
|
|
138
|
+
api.ctx.logger.warn('slack %s answered warnings: %s', name, warnings.join(', '));
|
|
139
|
+
}
|
|
140
|
+
return body;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Call one Web API method and return its `ok: true` answer.
|
|
144
|
+
*
|
|
145
|
+
* @param api - the request dependencies.
|
|
146
|
+
* @param method - Slack method name.
|
|
147
|
+
* @param params - query parameters of a GET, or the request body.
|
|
148
|
+
* @param options - app-token selection and cancellation.
|
|
149
|
+
* @returns the parsed answer.
|
|
150
|
+
* @throws SlackApiError for a status, a refusal or an unreadable answer.
|
|
151
|
+
*/
|
|
152
|
+
export async function callApi(api, method, params = {}, options = {}) {
|
|
153
|
+
const route = ROUTES[method];
|
|
154
|
+
const token = options.app === true ? api.appToken : api.botToken;
|
|
155
|
+
const config = {
|
|
156
|
+
method: route.method,
|
|
157
|
+
headers: { authorization: `Bearer ${token}` },
|
|
158
|
+
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
159
|
+
};
|
|
160
|
+
if (route.method === 'GET')
|
|
161
|
+
config.params = params;
|
|
162
|
+
else if (route.json)
|
|
163
|
+
config.data = params;
|
|
164
|
+
else {
|
|
165
|
+
config.data = encodeForm(params);
|
|
166
|
+
config.headers = {
|
|
167
|
+
...config.headers,
|
|
168
|
+
'content-type': 'application/x-www-form-urlencoded',
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
let response;
|
|
172
|
+
try {
|
|
173
|
+
response = await api.ctx.http(`${api.base}${route.path}`, config);
|
|
174
|
+
}
|
|
175
|
+
catch (cause) {
|
|
176
|
+
if (options.signal?.aborted === true)
|
|
177
|
+
throw options.signal.reason;
|
|
178
|
+
if (isAbortError(cause))
|
|
179
|
+
throw cause;
|
|
180
|
+
throw new SlackApiError(`slack ${route.path.slice(1)} request failed`, {
|
|
181
|
+
method: route.path.slice(1),
|
|
182
|
+
cause,
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
const status = response.status;
|
|
186
|
+
const retryAfterMs = retryAfterOf(response);
|
|
187
|
+
const body = await jsonOf(response);
|
|
188
|
+
if (body === undefined) {
|
|
189
|
+
throw new SlackApiError(`slack ${route.path.slice(1)} answered ${status} without a JSON envelope`, {
|
|
190
|
+
method: route.path.slice(1),
|
|
191
|
+
status,
|
|
192
|
+
...(retryAfterMs === undefined ? {} : { retryAfterMs }),
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
if (status === 429) {
|
|
196
|
+
throw new SlackApiError(`slack ${route.path.slice(1)} was rate limited`, {
|
|
197
|
+
method: route.path.slice(1),
|
|
198
|
+
status,
|
|
199
|
+
...(body.error === undefined ? {} : { code: body.error }),
|
|
200
|
+
...(retryAfterMs === undefined ? {} : { retryAfterMs }),
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
return ensureOk(api, method, { ...body }, status);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Whether a URL names a host the bot token may be sent to.
|
|
207
|
+
*
|
|
208
|
+
* Slack's guidance is to never send the credentials to a host outside Slack, and a `url_private` of a remote file
|
|
209
|
+
* names an external host. The comparison is exact on the parsed hostname: `files.slack.com.evil.example` and
|
|
210
|
+
* `evil-slack.com` are both refused, and plain HTTP is refused because the token would travel unencrypted.
|
|
211
|
+
*
|
|
212
|
+
* @param url - the file URL.
|
|
213
|
+
* @returns whether the bot token may be presented to it.
|
|
214
|
+
*/
|
|
215
|
+
export function isSlackFileUrl(url) {
|
|
216
|
+
if (url.protocol !== 'https:')
|
|
217
|
+
return false;
|
|
218
|
+
const host = url.hostname.toLowerCase();
|
|
219
|
+
return host === 'slack.com' || host.endsWith('.slack.com');
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Download one Slack-hosted file with the bot token.
|
|
223
|
+
*
|
|
224
|
+
* @param api - the request dependencies.
|
|
225
|
+
* @param src - `url_private` of a `files.info` answer.
|
|
226
|
+
* @param signal - cancellation.
|
|
227
|
+
* @returns the response whose body is the file.
|
|
228
|
+
* @throws SlackApiError when the host is not a Slack file host.
|
|
229
|
+
*/
|
|
230
|
+
export async function downloadFile(api, src, signal) {
|
|
231
|
+
let url;
|
|
232
|
+
try {
|
|
233
|
+
url = new URL(src);
|
|
234
|
+
}
|
|
235
|
+
catch (cause) {
|
|
236
|
+
throw new SlackApiError(`slack: "${src}" is not a URL`, {
|
|
237
|
+
method: 'files.info',
|
|
238
|
+
cause,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
if (!isSlackFileUrl(url)) {
|
|
242
|
+
throw new SlackApiError(`slack: refusing to send the bot token to ${url.hostname}`, { method: 'files.info' });
|
|
243
|
+
}
|
|
244
|
+
try {
|
|
245
|
+
return await api.ctx.http(url, {
|
|
246
|
+
headers: { authorization: `Bearer ${api.botToken}` },
|
|
247
|
+
...(signal === undefined ? {} : { signal }),
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
catch (cause) {
|
|
251
|
+
if (signal?.aborted === true)
|
|
252
|
+
throw signal.reason;
|
|
253
|
+
if (isAbortError(cause))
|
|
254
|
+
throw cause;
|
|
255
|
+
throw new SlackApiError('slack file download failed', {
|
|
256
|
+
method: 'files.info',
|
|
257
|
+
cause,
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Ask for the upload URL and the file id (`files.getUploadURLExternal`).
|
|
263
|
+
* @param api - the request dependencies.
|
|
264
|
+
* @param file - name and byte length the platform records.
|
|
265
|
+
* @param signal - cancellation.
|
|
266
|
+
* @returns the ticket of the byte upload.
|
|
267
|
+
*/
|
|
268
|
+
export async function startUpload(api, file, signal) {
|
|
269
|
+
const answer = await callApi(api, 'getUploadUrlExternal', { filename: file.name, length: file.length }, signal === undefined ? {} : { signal });
|
|
270
|
+
if (answer.upload_url === undefined || answer.file_id === undefined) {
|
|
271
|
+
throw new SlackApiError('slack files.getUploadURLExternal answered without upload_url/file_id', { method: 'getUploadUrlExternal' });
|
|
272
|
+
}
|
|
273
|
+
return { uploadUrl: answer.upload_url, fileId: answer.file_id };
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Upload the bytes to the ticket's URL.
|
|
277
|
+
*
|
|
278
|
+
* The URL is pre-signed, so no credential travels with it; the answer is plain text (`OK - <size>`), so a 2xx is the
|
|
279
|
+
* whole success signal.
|
|
280
|
+
*
|
|
281
|
+
* @param api - the request dependencies.
|
|
282
|
+
* @param ticket - what {@link startUpload} returned.
|
|
283
|
+
* @param data - the file bytes.
|
|
284
|
+
* @param signal - cancellation.
|
|
285
|
+
*/
|
|
286
|
+
export async function putUploadBytes(api, ticket, data, signal) {
|
|
287
|
+
let response;
|
|
288
|
+
try {
|
|
289
|
+
response = await api.ctx.http(ticket.uploadUrl, {
|
|
290
|
+
method: 'POST',
|
|
291
|
+
headers: { 'content-type': 'application/octet-stream' },
|
|
292
|
+
data,
|
|
293
|
+
...(signal === undefined ? {} : { signal }),
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
catch (cause) {
|
|
297
|
+
if (signal?.aborted === true)
|
|
298
|
+
throw signal.reason;
|
|
299
|
+
if (isAbortError(cause))
|
|
300
|
+
throw cause;
|
|
301
|
+
throw new SlackApiError('slack file upload failed', {
|
|
302
|
+
method: 'getUploadUrlExternal',
|
|
303
|
+
cause,
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
if (!response.ok) {
|
|
307
|
+
throw new SlackApiError(`slack file upload answered ${response.status}`, {
|
|
308
|
+
method: 'getUploadUrlExternal',
|
|
309
|
+
status: response.status,
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Share an uploaded file into a channel (`files.completeUploadExternal`).
|
|
315
|
+
* @param api - the request dependencies.
|
|
316
|
+
* @param files - ids and titles to share.
|
|
317
|
+
* @param channel - channel the file message appears in.
|
|
318
|
+
* @param threadTs - thread to post the file into, when the message answers a thread.
|
|
319
|
+
* @param signal - cancellation.
|
|
320
|
+
* @returns the shared files, from which the message timestamp is read.
|
|
321
|
+
*/
|
|
322
|
+
export async function finishUpload(api, files, channel, threadTs, signal) {
|
|
323
|
+
const answer = await callApi(api, 'completeUploadExternal', {
|
|
324
|
+
files: [...files],
|
|
325
|
+
channel_id: channel,
|
|
326
|
+
...(threadTs === undefined ? {} : { thread_ts: threadTs }),
|
|
327
|
+
}, signal === undefined ? {} : { signal });
|
|
328
|
+
return answer.files ?? [];
|
|
329
|
+
}
|
|
330
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/request.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAwB3C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,QAAQ,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;IAC5D,mBAAmB,EAAE;QACnB,IAAI,EAAE,wBAAwB;QAC9B,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,KAAK;KACZ;IACD,UAAU,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;IAChE,eAAe,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;IAC1E,oBAAoB,EAAE;QACpB,IAAI,EAAE,wBAAwB;QAC9B,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,KAAK;KACZ;IACD,SAAS,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE;IAC9D,YAAY,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;IACpE,eAAe,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE;IAC1E,SAAS,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAA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U,YAAY,CAChC,GAAa,EACb,KAA+C,EAC/C,OAAe,EACf,QAA4B,EAC5B,MAAoB;IAEpB,MAAM,MAAM,GAAG,MAAM,OAAO,CAC1B,GAAG,EACH,wBAAwB,EACxB;QACE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC;QACjB,UAAU,EAAE,OAAO;QACnB,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC;KAC3D,EACD,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CACvC,CAAA;IACD,OAAO,MAAM,CAAC,KAAK,IAAI,EAAE,CAAA;AAC3B,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Outbound hooks: the send pipeline's payload, deletion, member reads, message reads and reactions.
|
|
3
|
+
*
|
|
4
|
+
* Slack publishes a text part with `chat.postMessage` and an attachment with `files.completeUploadExternal`; there is
|
|
5
|
+
* no edit (the adapter does not implement `editPayload`), so the core's `edit` degrades to recall-and-resend.
|
|
6
|
+
*/
|
|
7
|
+
import type { ChatRef, InboundMessage, MembersPage, MessageHandle, MessageRef, SendContext, SentPart, Target } from '@deepseek-ai/cordis-plugin-im-core';
|
|
8
|
+
import type { SlackBot } from './bot.ts';
|
|
9
|
+
import type { SlackApi } from './request.ts';
|
|
10
|
+
import type { SlackPayload } from './modes/shared.ts';
|
|
11
|
+
/** Everything the send hooks need from the adapter. */
|
|
12
|
+
export interface SlackSendDeps {
|
|
13
|
+
readonly api: SlackApi;
|
|
14
|
+
/** `team_id` of the installation, recorded in `SentPart.referrer`. */
|
|
15
|
+
readonly teamId: string | undefined;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Send one serialized payload.
|
|
19
|
+
* @param deps - the request dependencies.
|
|
20
|
+
* @param payload - the mode's request data.
|
|
21
|
+
* @param _target - the target chat, already carried by the payload.
|
|
22
|
+
* @param _ctx - part index and quote, already resolved by `serialize`.
|
|
23
|
+
* @returns the published part.
|
|
24
|
+
*/
|
|
25
|
+
export declare function sendPayload(deps: SlackSendDeps, payload: SlackPayload, _target: Target, _ctx: SendContext): Promise<SentPart>;
|
|
26
|
+
/**
|
|
27
|
+
* Recall one published part.
|
|
28
|
+
* @param deps - the request dependencies.
|
|
29
|
+
* @param part - the part to recall.
|
|
30
|
+
* @param handle - the message the part belongs to, which names the channel.
|
|
31
|
+
*/
|
|
32
|
+
export declare function deletePart(deps: SlackSendDeps, part: SentPart, handle: MessageHandle): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* List the members of the workspace.
|
|
35
|
+
*
|
|
36
|
+
* `users.list` is workspace-level: Slack has no paged channel-member read that this adapter could page, so the list is
|
|
37
|
+
* every human and bot of the installation, not the people of one conversation.
|
|
38
|
+
*
|
|
39
|
+
* @param deps - the request dependencies.
|
|
40
|
+
* @param _chat - the chat the caller asked about; unused, because the platform's list is not per chat.
|
|
41
|
+
* @param cursor - `next_cursor` of the previous page.
|
|
42
|
+
* @param limit - page size the platform should use.
|
|
43
|
+
* @returns one page of members.
|
|
44
|
+
*/
|
|
45
|
+
export declare function members(deps: SlackSendDeps, _chat: ChatRef, cursor?: string, limit?: number): Promise<MembersPage>;
|
|
46
|
+
/**
|
|
47
|
+
* Read one message by its timestamp.
|
|
48
|
+
*
|
|
49
|
+
* `conversations.history` answers newest first, so the call bounds both ends of the range: `oldest` alone (the
|
|
50
|
+
* upstream form) would return the newest message of the range instead of the one asked for.
|
|
51
|
+
*
|
|
52
|
+
* @param deps - the request dependencies.
|
|
53
|
+
* @param bot - the adapter, needed to decode the answer.
|
|
54
|
+
* @param chat - the chat the caller asked about; the answer carries no chat type, so it is reused verbatim.
|
|
55
|
+
* @param id - platform message timestamp.
|
|
56
|
+
* @returns the decoded message, with the same `chat` the caller passed.
|
|
57
|
+
* @throws PlatformError `not-found` when the timestamp names no message of that chat.
|
|
58
|
+
*/
|
|
59
|
+
export declare function getMessage(deps: SlackSendDeps, bot: SlackBot, chat: ChatRef, id: string): Promise<InboundMessage>;
|
|
60
|
+
/**
|
|
61
|
+
* Add one reaction to a published message.
|
|
62
|
+
* @param deps - the request dependencies.
|
|
63
|
+
* @param message - the message to react to.
|
|
64
|
+
* @param emoji - the emoji (`:tada:` or `tada`).
|
|
65
|
+
*/
|
|
66
|
+
export declare function createReaction(deps: SlackSendDeps, message: MessageRef, emoji: string): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Remove one reaction from a published message.
|
|
69
|
+
* @param deps - the request dependencies.
|
|
70
|
+
* @param message - the message to react to.
|
|
71
|
+
* @param emoji - the emoji (`:tada:` or `tada`).
|
|
72
|
+
*/
|
|
73
|
+
export declare function deleteReaction(deps: SlackSendDeps, message: MessageRef, emoji: string): Promise<void>;
|
|
74
|
+
//# sourceMappingURL=send.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/send.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,OAAO,EACP,cAAc,EACd,WAAW,EACX,aAAa,EACb,UAAU,EACV,WAAW,EACX,QAAQ,EACR,MAAM,EAEP,MAAM,oCAAoC,CAAA;AAC3C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAIxC,OAAO,KAAK,EAAE,QAAQ,EAAe,MAAM,cAAc,CAAA;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAErD,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAA;IACtB,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;CACpC;AAsCD;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,aAAa,EACn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