@scryme/chat 2.13.3 → 2.15.1
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/dist/sdk.d.ts +925 -33
- package/dist/sdk.js +685 -8
- package/package.json +1 -1
- package/src/__tests__/sdk.test.ts +224 -2
- package/src/sdk.ts +1261 -69
package/src/sdk.ts
CHANGED
|
@@ -16,6 +16,13 @@ import type {
|
|
|
16
16
|
MarkAsReadDto,
|
|
17
17
|
UsersControllerSearchUsersParams,
|
|
18
18
|
DmsControllerGetMessagesParams,
|
|
19
|
+
CreateMessageDto,
|
|
20
|
+
V3CreateWebhookDto,
|
|
21
|
+
V3UpdateWebhookDto,
|
|
22
|
+
CreateChannelIncomingWebhookDto,
|
|
23
|
+
UpdateChannelIncomingWebhookDto,
|
|
24
|
+
ExecuteChannelIncomingWebhookDto,
|
|
25
|
+
V3ChannelIncomingWebhooksControllerExecuteWebhookByChannelIdParams,
|
|
19
26
|
V3WorkspacesControllerGetWorkspacesResult,
|
|
20
27
|
V3WorkspacesControllerGetWorkspaceBySlugResult,
|
|
21
28
|
V3WorkspacesControllerProvisionWorkspaceResult,
|
|
@@ -46,22 +53,428 @@ import type {
|
|
|
46
53
|
UsersControllerGetMeResult,
|
|
47
54
|
UsersControllerGetUserResult,
|
|
48
55
|
UsersControllerSearchUsersResult,
|
|
56
|
+
DmsControllerAddReactionBody,
|
|
57
|
+
DmsControllerAddReactionResult,
|
|
58
|
+
DmsControllerRemoveReactionResult,
|
|
59
|
+
V3WebhooksControllerGetWebhooksResult,
|
|
60
|
+
V3WebhooksControllerCreateWebhookResult,
|
|
61
|
+
V3WebhooksControllerGetWebhookResult,
|
|
62
|
+
V3WebhooksControllerUpdateWebhookResult,
|
|
63
|
+
V3WebhooksControllerDeleteWebhookResult,
|
|
64
|
+
V3ChannelIncomingWebhooksControllerGetChannelWebhooksResult,
|
|
65
|
+
V3ChannelIncomingWebhooksControllerCreateChannelWebhookResult,
|
|
66
|
+
V3ChannelIncomingWebhooksControllerGetChannelWebhookResult,
|
|
67
|
+
V3ChannelIncomingWebhooksControllerUpdateChannelWebhookResult,
|
|
68
|
+
V3ChannelIncomingWebhooksControllerDeleteChannelWebhookResult,
|
|
69
|
+
V3ChannelIncomingWebhooksControllerExecuteWebhookByUrlTokenResult,
|
|
70
|
+
V3ChannelIncomingWebhooksControllerExecuteWebhookByChannelIdResult,
|
|
71
|
+
V3OAuthControllerGetTokenResult,
|
|
49
72
|
} from './generated/v3-server';
|
|
50
73
|
|
|
74
|
+
// --- High-fidelity Response and Entity Interfaces for Excellent DX ---
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Represents a message attachment.
|
|
78
|
+
*/
|
|
79
|
+
export interface MessageAttachment {
|
|
80
|
+
id: string;
|
|
81
|
+
messageId?: string | null;
|
|
82
|
+
name: string;
|
|
83
|
+
type: string;
|
|
84
|
+
url: string;
|
|
85
|
+
size?: string | null;
|
|
86
|
+
createdAt: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Represents a user reaction to a message.
|
|
91
|
+
*/
|
|
92
|
+
export interface MessageReaction {
|
|
93
|
+
id: string;
|
|
94
|
+
messageId: string;
|
|
95
|
+
userId: string;
|
|
96
|
+
emoji: string;
|
|
97
|
+
customEmojiId?: string | null;
|
|
98
|
+
createdAt: string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Represents a workspace in the Scryme platform (Enterprise M2M API V3).
|
|
103
|
+
*/
|
|
104
|
+
export interface V3Workspace {
|
|
105
|
+
/** Unique workspace identifier. */
|
|
106
|
+
id: string;
|
|
107
|
+
/** Display name of the workspace. */
|
|
108
|
+
name: string;
|
|
109
|
+
/** Unique URL-friendly slug representing the workspace. */
|
|
110
|
+
slug: string;
|
|
111
|
+
/** Description of the workspace. */
|
|
112
|
+
description?: string | null;
|
|
113
|
+
/** Icon identifier or URL. */
|
|
114
|
+
icon?: string | null;
|
|
115
|
+
/** Industry categorization of the workspace. */
|
|
116
|
+
industry?: string | null;
|
|
117
|
+
/** Custom branding configuration object. */
|
|
118
|
+
brandingConfig?: Record<string, unknown> | null;
|
|
119
|
+
/** ISO timestamp when the workspace was created. */
|
|
120
|
+
createdAt: string;
|
|
121
|
+
/** ISO timestamp when the workspace was last updated. */
|
|
122
|
+
updatedAt?: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Envelope response containing a list of workspaces.
|
|
127
|
+
*/
|
|
128
|
+
export interface V3WorkspacesResponse {
|
|
129
|
+
/** Indicates whether the API call was successful. */
|
|
130
|
+
success: boolean;
|
|
131
|
+
/** The payload of the response containing the workspaces. */
|
|
132
|
+
data: {
|
|
133
|
+
/** List of workspaces returned by the API. */
|
|
134
|
+
workspaces: V3Workspace[];
|
|
135
|
+
};
|
|
136
|
+
/** ISO timestamp of when the response was generated. */
|
|
137
|
+
timestamp: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Envelope response containing a single workspace.
|
|
142
|
+
*/
|
|
143
|
+
export interface V3WorkspaceResponse {
|
|
144
|
+
/** Indicates whether the API call was successful. */
|
|
145
|
+
success: boolean;
|
|
146
|
+
/** The payload of the response containing the workspace. */
|
|
147
|
+
data: {
|
|
148
|
+
/** The retrieved workspace details. */
|
|
149
|
+
workspace: V3Workspace;
|
|
150
|
+
};
|
|
151
|
+
/** ISO timestamp of when the response was generated. */
|
|
152
|
+
timestamp: string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Envelope response containing provisioned workspace details and its default system bot.
|
|
157
|
+
*/
|
|
158
|
+
export interface V3ProvisionWorkspaceResponse {
|
|
159
|
+
/** Indicates whether the API call was successful. */
|
|
160
|
+
success: boolean;
|
|
161
|
+
/** The payload containing details of the newly provisioned workspace and bot. */
|
|
162
|
+
data: {
|
|
163
|
+
/** Basic details of the provisioned workspace. */
|
|
164
|
+
workspace: {
|
|
165
|
+
/** Unique workspace identifier. */
|
|
166
|
+
id: string;
|
|
167
|
+
/** Display name of the workspace. */
|
|
168
|
+
name: string;
|
|
169
|
+
/** Unique slug for the workspace. */
|
|
170
|
+
slug: string;
|
|
171
|
+
};
|
|
172
|
+
/** Details of the automatically generated system bot for the workspace. */
|
|
173
|
+
bot: {
|
|
174
|
+
/** Unique identifier of the bot. */
|
|
175
|
+
id: string;
|
|
176
|
+
/** Client ID used for bot authentication. */
|
|
177
|
+
clientId: string;
|
|
178
|
+
/** Client Secret used for bot authentication. */
|
|
179
|
+
clientSecret: string;
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
/** ISO timestamp of when the response was generated. */
|
|
183
|
+
timestamp: string;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Envelope response containing workspace deletion confirmation.
|
|
188
|
+
*/
|
|
189
|
+
export interface V3DeleteWorkspaceResponse {
|
|
190
|
+
/** Indicates whether the API call was successful. */
|
|
191
|
+
success: boolean;
|
|
192
|
+
/** The payload indicating deletion status. */
|
|
193
|
+
data: {
|
|
194
|
+
/** True if the workspace was deleted successfully. */
|
|
195
|
+
success: boolean;
|
|
196
|
+
};
|
|
197
|
+
/** ISO timestamp of when the response was generated. */
|
|
198
|
+
timestamp: string;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Details of a member belonging to a workspace.
|
|
203
|
+
*/
|
|
204
|
+
export interface V3WorkspaceMember {
|
|
205
|
+
/** Unique membership identifier. */
|
|
206
|
+
id: string;
|
|
207
|
+
/** Unique workspace identifier. */
|
|
208
|
+
workspaceId: string;
|
|
209
|
+
/** Unique user identifier. */
|
|
210
|
+
userId: string;
|
|
211
|
+
/** Associated department identifier if the member is assigned to one. */
|
|
212
|
+
departmentId?: string | null;
|
|
213
|
+
/** The member's role (e.g., owner, admin, moderator, member, guest). */
|
|
214
|
+
role: string;
|
|
215
|
+
/** Type of member (e.g., regular user, bot, guest). */
|
|
216
|
+
memberType: string;
|
|
217
|
+
/** ISO timestamp of when the member joined the workspace. */
|
|
218
|
+
joinedAt: string;
|
|
219
|
+
/** Member's notification preferences. */
|
|
220
|
+
notificationPreference: string;
|
|
221
|
+
/** Nested basic details of the member's user profile. */
|
|
222
|
+
user: {
|
|
223
|
+
/** Unique user identifier. */
|
|
224
|
+
id: string;
|
|
225
|
+
/** Full name of the user. */
|
|
226
|
+
name: string;
|
|
227
|
+
/** Email address of the user. */
|
|
228
|
+
email: string;
|
|
229
|
+
/** URL to the user's avatar image. */
|
|
230
|
+
avatar?: string | null;
|
|
231
|
+
/** Current status message or indicator of the user. */
|
|
232
|
+
status?: string | null;
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Envelope response containing a list of workspace members.
|
|
238
|
+
*/
|
|
239
|
+
export interface V3WorkspaceMembersResponse {
|
|
240
|
+
/** Indicates whether the API call was successful. */
|
|
241
|
+
success: boolean;
|
|
242
|
+
/** The payload containing workspace members. */
|
|
243
|
+
data: {
|
|
244
|
+
/** List of members belonging to the workspace. */
|
|
245
|
+
members: V3WorkspaceMember[];
|
|
246
|
+
};
|
|
247
|
+
/** ISO timestamp of when the response was generated. */
|
|
248
|
+
timestamp: string;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Envelope response containing a newly added workspace member.
|
|
253
|
+
*/
|
|
254
|
+
export interface V3AddWorkspaceMemberResponse {
|
|
255
|
+
/** Indicates whether the API call was successful. */
|
|
256
|
+
success: boolean;
|
|
257
|
+
/** The payload containing the added workspace member. */
|
|
258
|
+
data: {
|
|
259
|
+
/** Details of the added member. */
|
|
260
|
+
member: V3WorkspaceMember;
|
|
261
|
+
};
|
|
262
|
+
/** ISO timestamp of when the response was generated. */
|
|
263
|
+
timestamp: string;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Envelope response containing details of a specific workspace member.
|
|
268
|
+
*/
|
|
269
|
+
export interface V3GetWorkspaceMemberResponse {
|
|
270
|
+
/** Indicates whether the API call was successful. */
|
|
271
|
+
success: boolean;
|
|
272
|
+
/** The payload containing the workspace member details. */
|
|
273
|
+
data: {
|
|
274
|
+
/** Details of the workspace member. */
|
|
275
|
+
member: V3WorkspaceMember;
|
|
276
|
+
};
|
|
277
|
+
/** ISO timestamp of when the response was generated. */
|
|
278
|
+
timestamp: string;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Envelope response containing the updated workspace member details.
|
|
283
|
+
*/
|
|
284
|
+
export interface V3UpdateWorkspaceMemberResponse {
|
|
285
|
+
/** Indicates whether the API call was successful. */
|
|
286
|
+
success: boolean;
|
|
287
|
+
/** The payload containing the updated workspace member. */
|
|
288
|
+
data: {
|
|
289
|
+
/** Details of the updated member. */
|
|
290
|
+
member: V3WorkspaceMember;
|
|
291
|
+
};
|
|
292
|
+
/** ISO timestamp of when the response was generated. */
|
|
293
|
+
timestamp: string;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Envelope response containing workspace member removal confirmation.
|
|
298
|
+
*/
|
|
299
|
+
export interface V3DeleteWorkspaceMemberResponse {
|
|
300
|
+
/** Indicates whether the API call was successful. */
|
|
301
|
+
success: boolean;
|
|
302
|
+
/** The payload indicating deletion status. */
|
|
303
|
+
data: {
|
|
304
|
+
/** True if the workspace member was removed successfully. */
|
|
305
|
+
success: boolean;
|
|
306
|
+
};
|
|
307
|
+
/** ISO timestamp of when the response was generated. */
|
|
308
|
+
timestamp: string;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Represents a channel in a workspace.
|
|
313
|
+
*/
|
|
314
|
+
export interface WorkspaceChannel {
|
|
315
|
+
/** Unique channel identifier. */
|
|
316
|
+
id: string;
|
|
317
|
+
/** Display name of the channel. */
|
|
318
|
+
name: string;
|
|
319
|
+
/** Unique URL-friendly slug representing the channel. */
|
|
320
|
+
slug: string;
|
|
321
|
+
/** Optional icon name or identifier for the channel. */
|
|
322
|
+
icon?: string;
|
|
323
|
+
/** Type of the channel. */
|
|
324
|
+
type: 'public' | 'private';
|
|
325
|
+
/** Optional descriptive text about the channel. */
|
|
326
|
+
description?: string | null;
|
|
327
|
+
/** True if the channel is private and restricted. */
|
|
328
|
+
isPrivate: boolean;
|
|
329
|
+
/** Unique workspace identifier. */
|
|
330
|
+
workspaceId: string;
|
|
331
|
+
/** Optional parent channel or category identifier. */
|
|
332
|
+
parentId?: string | null;
|
|
333
|
+
/** ISO timestamp when the channel was created. */
|
|
334
|
+
createdAt: string;
|
|
335
|
+
/** ISO timestamp when the channel was last updated. */
|
|
336
|
+
updatedAt: string;
|
|
337
|
+
/** Unread message count in this channel for the active user. */
|
|
338
|
+
unreadCount?: number;
|
|
339
|
+
/** Mentions count in this channel for the active user. */
|
|
340
|
+
mentionCount?: number;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Represents a message sent to a workspace channel or direct message conversation.
|
|
345
|
+
*/
|
|
346
|
+
export interface ChannelMessage {
|
|
347
|
+
/** Unique message identifier. */
|
|
348
|
+
id: string;
|
|
349
|
+
/** The text content of the message. */
|
|
350
|
+
content: string;
|
|
351
|
+
/** ISO timestamp when the message was sent. */
|
|
352
|
+
createdAt: string;
|
|
353
|
+
/** ISO timestamp when the message was last updated. */
|
|
354
|
+
updatedAt: string;
|
|
355
|
+
/** The unique channel identifier if sent within a channel. */
|
|
356
|
+
channelId: string;
|
|
357
|
+
/** Unique identifier of the user who sent the message. */
|
|
358
|
+
userId: string;
|
|
359
|
+
/** Basic profile details of the user who sent the message. */
|
|
360
|
+
user: {
|
|
361
|
+
/** Unique user identifier. */
|
|
362
|
+
id: string;
|
|
363
|
+
/** Display name of the user. */
|
|
364
|
+
name: string;
|
|
365
|
+
/** Username of the user. */
|
|
366
|
+
username?: string;
|
|
367
|
+
/** URL to the user's avatar image. */
|
|
368
|
+
avatar?: string | null;
|
|
369
|
+
};
|
|
370
|
+
/** Optional identifier of the message this message is replying to. */
|
|
371
|
+
replyToId?: string | null;
|
|
372
|
+
/** Optional identifier of the root thread message. */
|
|
373
|
+
threadId?: string | null;
|
|
374
|
+
/** Optional attachments uploaded with the message. */
|
|
375
|
+
attachments?: MessageAttachment[];
|
|
376
|
+
/** Reactions associated with this message. */
|
|
377
|
+
reactions?: MessageReaction[];
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Represents a direct message conversation between users.
|
|
382
|
+
*/
|
|
383
|
+
export interface DmConversation {
|
|
384
|
+
/** Unique conversation identifier. */
|
|
385
|
+
id: string;
|
|
386
|
+
/** ISO timestamp when the DM conversation was created. */
|
|
387
|
+
createdAt: string;
|
|
388
|
+
/** ISO timestamp when the DM conversation was last updated. */
|
|
389
|
+
updatedAt: string;
|
|
390
|
+
/** List of participant profiles in this conversation. */
|
|
391
|
+
participants: {
|
|
392
|
+
/** Participant record ID. */
|
|
393
|
+
id: string;
|
|
394
|
+
/** Unique user ID of the participant. */
|
|
395
|
+
userId: string;
|
|
396
|
+
/** Associated conversation ID. */
|
|
397
|
+
conversationId: string;
|
|
398
|
+
/** Profile details of the participant user. */
|
|
399
|
+
user: {
|
|
400
|
+
/** Unique user identifier. */
|
|
401
|
+
id: string;
|
|
402
|
+
/** Display name of the user. */
|
|
403
|
+
name: string;
|
|
404
|
+
/** Username of the user. */
|
|
405
|
+
username?: string;
|
|
406
|
+
/** URL to the user's avatar image. */
|
|
407
|
+
avatar?: string | null;
|
|
408
|
+
};
|
|
409
|
+
}[];
|
|
410
|
+
/** Messages belonging to this DM conversation. */
|
|
411
|
+
messages?: ChannelMessage[];
|
|
412
|
+
/** Metadata count summaries for the conversation. */
|
|
413
|
+
_count?: {
|
|
414
|
+
/** Total number of messages in the conversation. */
|
|
415
|
+
messages: number;
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Public or private profile information of a user.
|
|
421
|
+
*/
|
|
422
|
+
export interface UserProfile {
|
|
423
|
+
/** Unique user identifier. */
|
|
424
|
+
id: string;
|
|
425
|
+
/** Display name of the user. */
|
|
426
|
+
name: string;
|
|
427
|
+
/** Unique username of the user. */
|
|
428
|
+
username: string;
|
|
429
|
+
/** Email address of the user (available only on self profile or with appropriate access). */
|
|
430
|
+
email?: string;
|
|
431
|
+
/** URL to the user's avatar image. */
|
|
432
|
+
avatar?: string | null;
|
|
433
|
+
/** Current status message or custom presence text. */
|
|
434
|
+
status?: string | null;
|
|
435
|
+
/** Global application role of the user (e.g., admin, member). */
|
|
436
|
+
role?: string;
|
|
437
|
+
/** ISO timestamp when the user account was created. */
|
|
438
|
+
createdAt?: string;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Configuration options for initializing the Scryme SDK.
|
|
443
|
+
*/
|
|
51
444
|
export interface ScrymeSDKOptions {
|
|
445
|
+
/**
|
|
446
|
+
* The base URL of the Scryme API server.
|
|
447
|
+
* If not provided, the SDK will automatically resolve it from localStorage or environment variables.
|
|
448
|
+
*/
|
|
52
449
|
baseURL?: string;
|
|
450
|
+
/** OAuth2 Client ID for Machine-to-Machine (M2M) authentication. */
|
|
53
451
|
clientId?: string;
|
|
452
|
+
/** OAuth2 Client Secret for Machine-to-Machine (M2M) authentication. */
|
|
54
453
|
clientSecret?: string;
|
|
454
|
+
/** Static Bearer token or pre-fetched session token. */
|
|
55
455
|
token?: string;
|
|
56
456
|
}
|
|
57
457
|
|
|
458
|
+
/**
|
|
459
|
+
* The primary client SDK class for accessing the Scryme Chat platform APIs.
|
|
460
|
+
* Supports automated OAuth2 Token management and provides clean, type-safe namespaces.
|
|
461
|
+
*/
|
|
58
462
|
export class ScrymeSDK {
|
|
463
|
+
/** The currently cached access token. */
|
|
59
464
|
private token: string | null = null;
|
|
465
|
+
/** Timestamp in milliseconds indicating when the cached token will expire. */
|
|
60
466
|
private tokenExpiresAt: number | null = null;
|
|
467
|
+
/** Normalized base URL of the target API server. */
|
|
61
468
|
public baseURL: string;
|
|
469
|
+
/** OAuth2 Client ID used for client credentials flow. */
|
|
62
470
|
private clientId?: string;
|
|
471
|
+
/** OAuth2 Client Secret used for client credentials flow. */
|
|
63
472
|
private clientSecret?: string;
|
|
64
473
|
|
|
474
|
+
/**
|
|
475
|
+
* Synchronizes the authentication token to local storage and the global configuration.
|
|
476
|
+
* @param token The token to synchronize.
|
|
477
|
+
*/
|
|
65
478
|
private syncToken(token: string | null) {
|
|
66
479
|
if (!token) return;
|
|
67
480
|
setGlobalToken(token);
|
|
@@ -72,6 +485,10 @@ export class ScrymeSDK {
|
|
|
72
485
|
}
|
|
73
486
|
}
|
|
74
487
|
|
|
488
|
+
/**
|
|
489
|
+
* Constructs a new ScrymeSDK instance.
|
|
490
|
+
* @param options Configuration options for baseURL, tokens, and credentials.
|
|
491
|
+
*/
|
|
75
492
|
constructor(options: ScrymeSDKOptions = {}) {
|
|
76
493
|
this.clientId = options.clientId;
|
|
77
494
|
this.clientSecret = options.clientSecret;
|
|
@@ -93,7 +510,9 @@ export class ScrymeSDK {
|
|
|
93
510
|
const env = g.process?.env || g.__env__ || {};
|
|
94
511
|
const isProd =
|
|
95
512
|
env.NODE_ENV === 'production' ||
|
|
96
|
-
(typeof window !== 'undefined' &&
|
|
513
|
+
(typeof window !== 'undefined' &&
|
|
514
|
+
window.location.hostname !== 'localhost' &&
|
|
515
|
+
window.location.hostname !== '127.0.0.1');
|
|
97
516
|
|
|
98
517
|
url =
|
|
99
518
|
env.API_URL ||
|
|
@@ -105,7 +524,9 @@ export class ScrymeSDK {
|
|
|
105
524
|
}
|
|
106
525
|
|
|
107
526
|
/**
|
|
108
|
-
* Automatically retrieves or
|
|
527
|
+
* Automatically retrieves a cached token, or fetches a new one via M2M OAuth2 Client Credentials
|
|
528
|
+
* if a clientId and clientSecret are configured.
|
|
529
|
+
* @returns A promise resolving to the token string, or null if unauthenticated.
|
|
109
530
|
*/
|
|
110
531
|
public async getOrFetchToken(): Promise<string | null> {
|
|
111
532
|
// If we already have a token and it is not expired, return it
|
|
@@ -158,9 +579,10 @@ export class ScrymeSDK {
|
|
|
158
579
|
}
|
|
159
580
|
|
|
160
581
|
/**
|
|
161
|
-
*
|
|
582
|
+
* Generates the default request configuration containing the authorization headers and baseURL.
|
|
583
|
+
* @returns Request configuration object.
|
|
162
584
|
*/
|
|
163
|
-
private async getRequestConfig(): Promise<
|
|
585
|
+
private async getRequestConfig(): Promise<AxiosRequestConfig> {
|
|
164
586
|
const token = await this.getOrFetchToken();
|
|
165
587
|
return {
|
|
166
588
|
baseURL: `${this.baseURL}/api`,
|
|
@@ -180,7 +602,7 @@ export class ScrymeSDK {
|
|
|
180
602
|
get: (target, prop) => {
|
|
181
603
|
const originalMethod = Reflect.get(target, prop);
|
|
182
604
|
if (typeof originalMethod === 'function') {
|
|
183
|
-
return async (...args:
|
|
605
|
+
return async (...args: unknown[]) => {
|
|
184
606
|
const config = await this.getRequestConfig();
|
|
185
607
|
const arity = originalMethod.length;
|
|
186
608
|
const newArgs = [...args];
|
|
@@ -188,13 +610,13 @@ export class ScrymeSDK {
|
|
|
188
610
|
// Orval generated functions accept `options` as their last parameter.
|
|
189
611
|
// If the user provided options, we merge them with our default request config.
|
|
190
612
|
if (args.length >= arity && typeof args[args.length - 1] === 'object') {
|
|
191
|
-
const userOptions = args[args.length - 1];
|
|
613
|
+
const userOptions = args[args.length - 1] as AxiosRequestConfig;
|
|
192
614
|
newArgs[args.length - 1] = {
|
|
193
615
|
...userOptions,
|
|
194
616
|
baseURL: config.baseURL,
|
|
195
617
|
headers: {
|
|
196
618
|
...config.headers,
|
|
197
|
-
...userOptions
|
|
619
|
+
...userOptions?.headers,
|
|
198
620
|
},
|
|
199
621
|
};
|
|
200
622
|
} else {
|
|
@@ -205,135 +627,905 @@ export class ScrymeSDK {
|
|
|
205
627
|
newArgs.push(config);
|
|
206
628
|
}
|
|
207
629
|
|
|
208
|
-
return originalMethod(...newArgs);
|
|
630
|
+
return (originalMethod as (...a: unknown[]) => unknown)(...newArgs);
|
|
209
631
|
};
|
|
210
632
|
}
|
|
211
633
|
return originalMethod;
|
|
212
634
|
},
|
|
213
|
-
}) as
|
|
635
|
+
}) as unknown as ReturnType<typeof getSkyrmeChatAPI>;
|
|
214
636
|
}
|
|
215
637
|
|
|
216
638
|
// --- High-level nested namespace chains for excellent DX ---
|
|
217
639
|
|
|
640
|
+
/**
|
|
641
|
+
* Operations for managing workspaces, including creation, updating, retrieval,
|
|
642
|
+
* members, and channels.
|
|
643
|
+
*/
|
|
218
644
|
public get workspace() {
|
|
219
645
|
return {
|
|
220
|
-
|
|
221
|
-
|
|
646
|
+
/**
|
|
647
|
+
* Lists all workspaces in the authenticated organization context.
|
|
648
|
+
* @param options Optional request config override.
|
|
649
|
+
* @returns List of workspaces returned exactly from the endpoint.
|
|
650
|
+
*/
|
|
651
|
+
list: async (options?: AxiosRequestConfig): Promise<V3WorkspacesResponse> => {
|
|
652
|
+
return this.raw.v3WorkspacesControllerGetWorkspaces(options) as unknown as V3WorkspacesResponse;
|
|
222
653
|
},
|
|
223
|
-
|
|
224
|
-
|
|
654
|
+
/**
|
|
655
|
+
* Retrieves detailed information of a specific workspace by its slug.
|
|
656
|
+
* @param slug The unique workspace slug identifier.
|
|
657
|
+
* @param options Optional request config override.
|
|
658
|
+
* @returns Workspace details returned exactly from the endpoint.
|
|
659
|
+
*/
|
|
660
|
+
get: async (slug: string, options?: AxiosRequestConfig): Promise<V3WorkspaceResponse> => {
|
|
661
|
+
return this.raw.v3WorkspacesControllerGetWorkspaceBySlug(slug, options) as unknown as V3WorkspaceResponse;
|
|
225
662
|
},
|
|
226
|
-
|
|
227
|
-
|
|
663
|
+
/**
|
|
664
|
+
* Provisions a new workspace inside the organization.
|
|
665
|
+
* @param data Workspace creation and configuration data.
|
|
666
|
+
* @param options Optional request config override.
|
|
667
|
+
* @returns Provisioned workspace and bot configuration exactly from the endpoint.
|
|
668
|
+
*/
|
|
669
|
+
create: async (
|
|
670
|
+
data: V3ProvisionWorkspaceDto,
|
|
671
|
+
options?: AxiosRequestConfig
|
|
672
|
+
): Promise<V3ProvisionWorkspaceResponse> => {
|
|
673
|
+
return this.raw.v3WorkspacesControllerProvisionWorkspace(data, options) as unknown as V3ProvisionWorkspaceResponse;
|
|
228
674
|
},
|
|
229
|
-
|
|
230
|
-
|
|
675
|
+
/**
|
|
676
|
+
* Updates the configurations and metadata of an existing workspace.
|
|
677
|
+
* @param slug The unique workspace slug identifier.
|
|
678
|
+
* @param data Fields to update.
|
|
679
|
+
* @param options Optional request config override.
|
|
680
|
+
* @returns The updated workspace details exactly from the endpoint.
|
|
681
|
+
*/
|
|
682
|
+
update: async (
|
|
683
|
+
slug: string,
|
|
684
|
+
data: V3UpdateWorkspaceDto,
|
|
685
|
+
options?: AxiosRequestConfig
|
|
686
|
+
): Promise<V3WorkspaceResponse> => {
|
|
687
|
+
return this.raw.v3WorkspacesControllerUpdateWorkspace(slug, data, options) as unknown as V3WorkspaceResponse;
|
|
231
688
|
},
|
|
232
|
-
|
|
233
|
-
|
|
689
|
+
/**
|
|
690
|
+
* Permanently deletes a specific workspace by its slug.
|
|
691
|
+
* @param slug The unique workspace slug identifier.
|
|
692
|
+
* @param options Optional request config override.
|
|
693
|
+
* @returns Deletion status response exactly from the endpoint.
|
|
694
|
+
*/
|
|
695
|
+
delete: async (slug: string, options?: AxiosRequestConfig): Promise<V3DeleteWorkspaceResponse> => {
|
|
696
|
+
return this.raw.v3WorkspacesControllerDeleteWorkspace(slug, options) as unknown as V3DeleteWorkspaceResponse;
|
|
234
697
|
},
|
|
698
|
+
/**
|
|
699
|
+
* Operations for managing workspace members, including listing, adding, role updates, and removal.
|
|
700
|
+
*/
|
|
235
701
|
members: {
|
|
236
|
-
|
|
237
|
-
|
|
702
|
+
/**
|
|
703
|
+
* Lists all members currently in a workspace.
|
|
704
|
+
* @param slug The unique workspace slug identifier.
|
|
705
|
+
* @param options Optional request config override.
|
|
706
|
+
* @returns List of workspace members exactly from the endpoint.
|
|
707
|
+
*/
|
|
708
|
+
list: async (slug: string, options?: AxiosRequestConfig): Promise<V3WorkspaceMembersResponse> => {
|
|
709
|
+
return this.raw.v3WorkspacesControllerGetWorkspaceMembers(slug, options) as unknown as V3WorkspaceMembersResponse;
|
|
238
710
|
},
|
|
239
|
-
|
|
240
|
-
|
|
711
|
+
/**
|
|
712
|
+
* Adds a new member to the workspace.
|
|
713
|
+
* @param slug The unique workspace slug identifier.
|
|
714
|
+
* @param data Input DTO containing the user's email and role.
|
|
715
|
+
* @param options Optional request config override.
|
|
716
|
+
* @returns Newly added member details exactly from the endpoint.
|
|
717
|
+
*/
|
|
718
|
+
add: async (
|
|
719
|
+
slug: string,
|
|
720
|
+
data: V3AddMemberDto,
|
|
721
|
+
options?: AxiosRequestConfig
|
|
722
|
+
): Promise<V3AddWorkspaceMemberResponse> => {
|
|
723
|
+
return this.raw.v3WorkspacesControllerAddWorkspaceMember(slug, data, options) as unknown as V3AddWorkspaceMemberResponse;
|
|
241
724
|
},
|
|
242
|
-
|
|
243
|
-
|
|
725
|
+
/**
|
|
726
|
+
* Retrieves membership details of a specific member in a workspace.
|
|
727
|
+
* @param slug The unique workspace slug identifier.
|
|
728
|
+
* @param memberId Unique ID of the workspace member (user ID).
|
|
729
|
+
* @param options Optional request config override.
|
|
730
|
+
* @returns Workspace member details exactly from the endpoint.
|
|
731
|
+
*/
|
|
732
|
+
get: async (
|
|
733
|
+
slug: string,
|
|
734
|
+
memberId: string,
|
|
735
|
+
options?: AxiosRequestConfig
|
|
736
|
+
): Promise<V3GetWorkspaceMemberResponse> => {
|
|
737
|
+
return this.raw.v3WorkspacesControllerGetWorkspaceMember(slug, memberId, options) as unknown as V3GetWorkspaceMemberResponse;
|
|
244
738
|
},
|
|
245
|
-
|
|
246
|
-
|
|
739
|
+
/**
|
|
740
|
+
* Updates the role or configuration of a workspace member.
|
|
741
|
+
* @param slug The unique workspace slug identifier.
|
|
742
|
+
* @param memberId Unique ID of the workspace member (user ID).
|
|
743
|
+
* @param data Update details containing the target role.
|
|
744
|
+
* @param options Optional request config override.
|
|
745
|
+
* @returns The updated workspace member details exactly from the endpoint.
|
|
746
|
+
*/
|
|
747
|
+
update: async (
|
|
748
|
+
slug: string,
|
|
749
|
+
memberId: string,
|
|
750
|
+
data: V3UpdateMemberRoleDto,
|
|
751
|
+
options?: AxiosRequestConfig
|
|
752
|
+
): Promise<V3UpdateWorkspaceMemberResponse> => {
|
|
753
|
+
return this.raw.v3WorkspacesControllerUpdateWorkspaceMember(slug, memberId, data, options) as unknown as V3UpdateWorkspaceMemberResponse;
|
|
247
754
|
},
|
|
248
|
-
|
|
249
|
-
|
|
755
|
+
/**
|
|
756
|
+
* Removes a member from the workspace.
|
|
757
|
+
* @param slug The unique workspace slug identifier.
|
|
758
|
+
* @param memberId Unique ID of the workspace member (user ID).
|
|
759
|
+
* @param options Optional request config override.
|
|
760
|
+
* @returns Workspace member deletion confirmation exactly from the endpoint.
|
|
761
|
+
*/
|
|
762
|
+
delete: async (
|
|
763
|
+
slug: string,
|
|
764
|
+
memberId: string,
|
|
765
|
+
options?: AxiosRequestConfig
|
|
766
|
+
): Promise<V3DeleteWorkspaceMemberResponse> => {
|
|
767
|
+
return this.raw.v3WorkspacesControllerDeleteWorkspaceMember(slug, memberId, options) as unknown as V3DeleteWorkspaceMemberResponse;
|
|
250
768
|
},
|
|
251
769
|
},
|
|
770
|
+
/**
|
|
771
|
+
* Operations for listing and creating channels inside a workspace.
|
|
772
|
+
*/
|
|
252
773
|
channels: {
|
|
253
|
-
|
|
254
|
-
|
|
774
|
+
/**
|
|
775
|
+
* Lists all public channels (and private channels the user has access to) in a workspace.
|
|
776
|
+
* @param slug The unique workspace slug identifier.
|
|
777
|
+
* @param options Optional request config override.
|
|
778
|
+
* @returns List of channels returned exactly from the endpoint.
|
|
779
|
+
*/
|
|
780
|
+
list: async (slug: string, options?: AxiosRequestConfig): Promise<WorkspaceChannel[]> => {
|
|
781
|
+
return this.raw.channelsControllerGetWorkspaceChannels(slug, options) as unknown as WorkspaceChannel[];
|
|
255
782
|
},
|
|
256
|
-
|
|
257
|
-
|
|
783
|
+
/**
|
|
784
|
+
* Creates a new channel within a workspace.
|
|
785
|
+
* @param slug The unique workspace slug identifier.
|
|
786
|
+
* @param data Configuration DTO for the new channel.
|
|
787
|
+
* @param options Optional request config override.
|
|
788
|
+
* @returns Details of the created channel exactly from the endpoint.
|
|
789
|
+
*/
|
|
790
|
+
create: async (
|
|
791
|
+
slug: string,
|
|
792
|
+
data: CreateWorkspaceChannelDto,
|
|
793
|
+
options?: AxiosRequestConfig
|
|
794
|
+
): Promise<WorkspaceChannel> => {
|
|
795
|
+
return this.raw.channelsControllerCreateChannel(slug, data, options) as unknown as WorkspaceChannel;
|
|
258
796
|
},
|
|
259
797
|
},
|
|
260
798
|
};
|
|
261
799
|
}
|
|
262
800
|
|
|
801
|
+
/**
|
|
802
|
+
* Operations for managing specific channels and channel message actions.
|
|
803
|
+
*/
|
|
263
804
|
public get channel() {
|
|
264
805
|
return {
|
|
265
|
-
|
|
266
|
-
|
|
806
|
+
/**
|
|
807
|
+
* Retrieves detailed information of a specific channel.
|
|
808
|
+
* @param slug The unique workspace slug identifier.
|
|
809
|
+
* @param channelId Unique identifier of the channel.
|
|
810
|
+
* @param options Optional request config override.
|
|
811
|
+
* @returns Channel details returned exactly from the endpoint.
|
|
812
|
+
*/
|
|
813
|
+
get: async (slug: string, channelId: string, options?: AxiosRequestConfig): Promise<WorkspaceChannel> => {
|
|
814
|
+
return this.raw.channelsControllerGetChannel(slug, channelId, options) as unknown as WorkspaceChannel;
|
|
267
815
|
},
|
|
268
|
-
|
|
269
|
-
|
|
816
|
+
/**
|
|
817
|
+
* Updates configuration, description, icon or status of an existing channel.
|
|
818
|
+
* @param slug The unique workspace slug identifier.
|
|
819
|
+
* @param channelId Unique identifier of the channel.
|
|
820
|
+
* @param data Configuration options to update.
|
|
821
|
+
* @param options Optional request config override.
|
|
822
|
+
* @returns The updated channel details exactly from the endpoint.
|
|
823
|
+
*/
|
|
824
|
+
update: async (
|
|
825
|
+
slug: string,
|
|
826
|
+
channelId: string,
|
|
827
|
+
data: UpdateWorkspaceChannelDto,
|
|
828
|
+
options?: AxiosRequestConfig
|
|
829
|
+
): Promise<WorkspaceChannel> => {
|
|
830
|
+
return this.raw.channelsControllerUpdateChannel(slug, channelId, data, options) as unknown as WorkspaceChannel;
|
|
270
831
|
},
|
|
271
|
-
|
|
272
|
-
|
|
832
|
+
/**
|
|
833
|
+
* Permanently deletes a channel from a workspace.
|
|
834
|
+
* @param slug The unique workspace slug identifier.
|
|
835
|
+
* @param channelId Unique identifier of the channel to delete.
|
|
836
|
+
* @param options Optional request config override.
|
|
837
|
+
* @returns Success status indicating that the channel was deleted exactly from the endpoint.
|
|
838
|
+
*/
|
|
839
|
+
delete: async (slug: string, channelId: string, options?: AxiosRequestConfig): Promise<{ success: boolean }> => {
|
|
840
|
+
return this.raw.channelsControllerDeleteChannel(slug, channelId, options) as unknown as { success: boolean };
|
|
273
841
|
},
|
|
842
|
+
/**
|
|
843
|
+
* Sub-namespace for managing messages inside a channel.
|
|
844
|
+
*/
|
|
274
845
|
message: {
|
|
275
|
-
|
|
276
|
-
|
|
846
|
+
/**
|
|
847
|
+
* Lists messages in a channel with cursor pagination support.
|
|
848
|
+
* @param channelId Unique identifier of the channel.
|
|
849
|
+
* @param params Query parameters for limiting, sorting, or pagination cursors.
|
|
850
|
+
* @param options Optional request config override.
|
|
851
|
+
* @returns Object containing the messages array and next pagination cursor exactly from the endpoint.
|
|
852
|
+
*/
|
|
853
|
+
list: async (
|
|
854
|
+
channelId: string,
|
|
855
|
+
params?: ChannelsControllerGetMessagesParams,
|
|
856
|
+
options?: AxiosRequestConfig
|
|
857
|
+
): Promise<{ messages: ChannelMessage[]; nextCursor?: string }> => {
|
|
858
|
+
return this.raw.channelsControllerGetMessages(channelId, params, options) as unknown as { messages: ChannelMessage[]; nextCursor?: string };
|
|
859
|
+
},
|
|
860
|
+
/**
|
|
861
|
+
* Sends a new message to a channel.
|
|
862
|
+
* @param channelId Unique identifier of the target channel.
|
|
863
|
+
* @param data The message content string or structured CreateMessageDto object.
|
|
864
|
+
* @param options Optional request config override.
|
|
865
|
+
* @returns The created message exactly from the endpoint.
|
|
866
|
+
*/
|
|
867
|
+
create: async (
|
|
868
|
+
channelId: string,
|
|
869
|
+
data: CreateMessageDto | string,
|
|
870
|
+
options?: AxiosRequestConfig
|
|
871
|
+
): Promise<ChannelMessage> => {
|
|
872
|
+
const payload = typeof data === 'string' ? { content: data } : data;
|
|
873
|
+
return this.raw.channelsControllerCreateMessage(channelId, {
|
|
874
|
+
...options,
|
|
875
|
+
data: payload,
|
|
876
|
+
}) as unknown as ChannelMessage;
|
|
277
877
|
},
|
|
278
|
-
|
|
279
|
-
|
|
878
|
+
/**
|
|
879
|
+
* Updates the content of a previously sent message in a channel.
|
|
880
|
+
* @param channelId Unique identifier of the channel containing the message.
|
|
881
|
+
* @param messageId Unique identifier of the message to update.
|
|
882
|
+
* @param data The new content payload.
|
|
883
|
+
* @param options Optional request config override.
|
|
884
|
+
* @returns The updated message details exactly from the endpoint.
|
|
885
|
+
*/
|
|
886
|
+
update: async (
|
|
887
|
+
channelId: string,
|
|
888
|
+
messageId: string,
|
|
889
|
+
data: ChannelsControllerUpdateMessageBody,
|
|
890
|
+
options?: AxiosRequestConfig
|
|
891
|
+
): Promise<ChannelMessage> => {
|
|
892
|
+
return this.raw.channelsControllerUpdateMessage(channelId, messageId, data, options) as unknown as ChannelMessage;
|
|
893
|
+
},
|
|
894
|
+
/**
|
|
895
|
+
* Permanently deletes a message in a channel.
|
|
896
|
+
* @param channelId Unique identifier of the channel containing the message.
|
|
897
|
+
* @param messageId Unique identifier of the message to delete.
|
|
898
|
+
* @param options Optional request config override.
|
|
899
|
+
* @returns Success status indicating that the message was deleted exactly from the endpoint.
|
|
900
|
+
*/
|
|
901
|
+
delete: async (
|
|
902
|
+
channelId: string,
|
|
903
|
+
messageId: string,
|
|
904
|
+
options?: AxiosRequestConfig
|
|
905
|
+
): Promise<{ success: boolean }> => {
|
|
906
|
+
return this.raw.channelsControllerDeleteMessage(channelId, messageId, options) as unknown as { success: boolean };
|
|
907
|
+
},
|
|
908
|
+
/**
|
|
909
|
+
* Adds a reaction (emoji) to a message in a channel.
|
|
910
|
+
* @param channelId Unique identifier of the channel containing the message.
|
|
911
|
+
* @param messageId Unique identifier of the message.
|
|
912
|
+
* @param data Object containing the target emoji character.
|
|
913
|
+
* @param options Optional request config override.
|
|
914
|
+
* @returns The reaction response returned exactly from the endpoint.
|
|
915
|
+
*/
|
|
916
|
+
addReaction: async (
|
|
917
|
+
channelId: string,
|
|
918
|
+
messageId: string,
|
|
919
|
+
data: ChannelsControllerAddReactionBody,
|
|
920
|
+
options?: AxiosRequestConfig
|
|
921
|
+
): Promise<ChannelsControllerAddReactionResult> => {
|
|
922
|
+
return this.raw.channelsControllerAddReaction(channelId, messageId, data, options) as unknown as ChannelsControllerAddReactionResult;
|
|
923
|
+
},
|
|
924
|
+
/**
|
|
925
|
+
* Removes a reaction (emoji) from a message in a channel.
|
|
926
|
+
* @param channelId Unique identifier of the channel containing the message.
|
|
927
|
+
* @param messageId Unique identifier of the message.
|
|
928
|
+
* @param emoji The emoji character to remove.
|
|
929
|
+
* @param options Optional request config override.
|
|
930
|
+
* @returns The reaction removal response returned exactly from the endpoint.
|
|
931
|
+
*/
|
|
932
|
+
removeReaction: async (
|
|
933
|
+
channelId: string,
|
|
934
|
+
messageId: string,
|
|
935
|
+
emoji: string,
|
|
936
|
+
options?: AxiosRequestConfig
|
|
937
|
+
): Promise<ChannelsControllerRemoveReactionResult> => {
|
|
938
|
+
return this.raw.channelsControllerRemoveReaction(channelId, messageId, emoji, options) as unknown as ChannelsControllerRemoveReactionResult;
|
|
280
939
|
},
|
|
281
940
|
},
|
|
282
941
|
};
|
|
283
942
|
}
|
|
284
943
|
|
|
944
|
+
/**
|
|
945
|
+
* Operations for modifying, reacting to, or deleting existing messages (both channel & direct messages).
|
|
946
|
+
* Automatically intercepts direct messages starting with 'dm-' and routes them correctly.
|
|
947
|
+
*/
|
|
285
948
|
public get message() {
|
|
286
949
|
return {
|
|
287
|
-
|
|
288
|
-
|
|
950
|
+
/**
|
|
951
|
+
* Updates the content of a previously sent message.
|
|
952
|
+
* @param channelId Unique identifier of the channel or DM conversation containing the message.
|
|
953
|
+
* @param messageId Unique identifier of the message to update.
|
|
954
|
+
* @param data The new content payload.
|
|
955
|
+
* @param options Optional request config override.
|
|
956
|
+
* @returns The updated message details exactly from the endpoint.
|
|
957
|
+
*/
|
|
958
|
+
update: async (
|
|
959
|
+
channelId: string,
|
|
960
|
+
messageId: string,
|
|
961
|
+
data: ChannelsControllerUpdateMessageBody | UpdateDmMessageDto,
|
|
962
|
+
options?: AxiosRequestConfig
|
|
963
|
+
): Promise<ChannelMessage> => {
|
|
964
|
+
if (channelId.startsWith('dm-')) {
|
|
965
|
+
return this.raw.dmsControllerUpdateMessage(channelId, messageId, data as UpdateDmMessageDto, options) as unknown as ChannelMessage;
|
|
966
|
+
}
|
|
967
|
+
return this.raw.channelsControllerUpdateMessage(channelId, messageId, data as ChannelsControllerUpdateMessageBody, options) as unknown as ChannelMessage;
|
|
289
968
|
},
|
|
290
|
-
|
|
291
|
-
|
|
969
|
+
/**
|
|
970
|
+
* Permanently deletes a message.
|
|
971
|
+
* @param channelId Unique identifier of the channel or DM conversation containing the message.
|
|
972
|
+
* @param messageId Unique identifier of the message to delete.
|
|
973
|
+
* @param options Optional request config override.
|
|
974
|
+
* @returns Success status indicating that the message was deleted exactly from the endpoint.
|
|
975
|
+
*/
|
|
976
|
+
delete: async (
|
|
977
|
+
channelId: string,
|
|
978
|
+
messageId: string,
|
|
979
|
+
options?: AxiosRequestConfig
|
|
980
|
+
): Promise<{ success: boolean }> => {
|
|
981
|
+
if (channelId.startsWith('dm-')) {
|
|
982
|
+
return this.raw.dmsControllerDeleteMessage(channelId, messageId, options) as unknown as { success: boolean };
|
|
983
|
+
}
|
|
984
|
+
return this.raw.channelsControllerDeleteMessage(channelId, messageId, options) as unknown as { success: boolean };
|
|
292
985
|
},
|
|
293
|
-
|
|
294
|
-
|
|
986
|
+
/**
|
|
987
|
+
* Adds a reaction (emoji) to a message.
|
|
988
|
+
* @param channelId Unique identifier of the channel or DM conversation containing the message.
|
|
989
|
+
* @param messageId Unique identifier of the message.
|
|
990
|
+
* @param data Object containing the target emoji character.
|
|
991
|
+
* @param options Optional request config override.
|
|
992
|
+
* @returns The reaction response returned exactly from the endpoint.
|
|
993
|
+
*/
|
|
994
|
+
addReaction: async (
|
|
995
|
+
channelId: string,
|
|
996
|
+
messageId: string,
|
|
997
|
+
data: ChannelsControllerAddReactionBody | DmsControllerAddReactionBody,
|
|
998
|
+
options?: AxiosRequestConfig
|
|
999
|
+
): Promise<ChannelsControllerAddReactionResult | DmsControllerAddReactionResult> => {
|
|
1000
|
+
if (channelId.startsWith('dm-')) {
|
|
1001
|
+
return this.raw.dmsControllerAddReaction(channelId, messageId, data as DmsControllerAddReactionBody, options) as unknown as DmsControllerAddReactionResult;
|
|
1002
|
+
}
|
|
1003
|
+
return this.raw.channelsControllerAddReaction(channelId, messageId, data as ChannelsControllerAddReactionBody, options) as unknown as ChannelsControllerAddReactionResult;
|
|
295
1004
|
},
|
|
296
|
-
|
|
297
|
-
|
|
1005
|
+
/**
|
|
1006
|
+
* Removes a reaction (emoji) from a message.
|
|
1007
|
+
* @param channelId Unique identifier of the channel or DM conversation containing the message.
|
|
1008
|
+
* @param messageId Unique identifier of the message.
|
|
1009
|
+
* @param emoji The emoji character to remove.
|
|
1010
|
+
* @param options Optional request config override.
|
|
1011
|
+
* @returns The reaction removal response returned exactly from the endpoint.
|
|
1012
|
+
*/
|
|
1013
|
+
removeReaction: async (
|
|
1014
|
+
channelId: string,
|
|
1015
|
+
messageId: string,
|
|
1016
|
+
emoji: string,
|
|
1017
|
+
options?: AxiosRequestConfig
|
|
1018
|
+
): Promise<ChannelsControllerRemoveReactionResult | DmsControllerRemoveReactionResult> => {
|
|
1019
|
+
if (channelId.startsWith('dm-')) {
|
|
1020
|
+
return this.raw.dmsControllerRemoveReaction(channelId, messageId, emoji, options) as unknown as DmsControllerRemoveReactionResult;
|
|
1021
|
+
}
|
|
1022
|
+
return this.raw.channelsControllerRemoveReaction(channelId, messageId, emoji, options) as unknown as ChannelsControllerRemoveReactionResult;
|
|
298
1023
|
},
|
|
299
1024
|
};
|
|
300
1025
|
}
|
|
301
1026
|
|
|
1027
|
+
/**
|
|
1028
|
+
* Operations for managing direct messages (DMs) and direct message conversations.
|
|
1029
|
+
*/
|
|
302
1030
|
public get dm() {
|
|
303
1031
|
return {
|
|
304
|
-
|
|
305
|
-
|
|
1032
|
+
/**
|
|
1033
|
+
* Lists all active direct message conversations for the authenticated user.
|
|
1034
|
+
* @param options Optional request config override.
|
|
1035
|
+
* @returns List of active DM conversations returned exactly from the endpoint.
|
|
1036
|
+
*/
|
|
1037
|
+
list: async (options?: AxiosRequestConfig): Promise<DmConversation[]> => {
|
|
1038
|
+
return this.raw.dmsControllerGetDms(options) as unknown as DmConversation[];
|
|
306
1039
|
},
|
|
307
|
-
|
|
308
|
-
|
|
1040
|
+
/**
|
|
1041
|
+
* Creates/initiates a direct message conversation with specified users.
|
|
1042
|
+
* @param data Create direct message details containing target participant IDs.
|
|
1043
|
+
* @param options Optional request config override.
|
|
1044
|
+
* @returns Details of the created DM conversation exactly from the endpoint.
|
|
1045
|
+
*/
|
|
1046
|
+
create: async (data: CreateDmDto, options?: AxiosRequestConfig): Promise<DmConversation> => {
|
|
1047
|
+
return this.raw.dmsControllerCreateDm(data, options) as unknown as DmConversation;
|
|
309
1048
|
},
|
|
310
|
-
|
|
311
|
-
|
|
1049
|
+
/**
|
|
1050
|
+
* Retrieves details of a specific direct message conversation.
|
|
1051
|
+
* @param dmId Unique identifier of the direct message conversation.
|
|
1052
|
+
* @param options Optional request config override.
|
|
1053
|
+
* @returns Detailed direct message conversation object exactly from the endpoint.
|
|
1054
|
+
*/
|
|
1055
|
+
get: async (dmId: string, options?: AxiosRequestConfig): Promise<DmConversation> => {
|
|
1056
|
+
return this.raw.dmsControllerGetDm(dmId, options) as unknown as DmConversation;
|
|
312
1057
|
},
|
|
313
|
-
|
|
314
|
-
|
|
1058
|
+
/**
|
|
1059
|
+
* Deletes/closes an active direct message conversation.
|
|
1060
|
+
* @param dmId Unique identifier of the direct message conversation to close.
|
|
1061
|
+
* @param options Optional request config override.
|
|
1062
|
+
* @returns Success status indicating that the DM conversation was deleted exactly from the endpoint.
|
|
1063
|
+
*/
|
|
1064
|
+
delete: async (dmId: string, options?: AxiosRequestConfig): Promise<{ success: boolean }> => {
|
|
1065
|
+
return this.raw.dmsControllerDeleteDm(dmId, options) as unknown as { success: boolean };
|
|
315
1066
|
},
|
|
1067
|
+
/**
|
|
1068
|
+
* Sub-namespace for managing direct messages in a specific DM conversation.
|
|
1069
|
+
*/
|
|
316
1070
|
message: {
|
|
317
|
-
|
|
318
|
-
|
|
1071
|
+
/**
|
|
1072
|
+
* Lists messages in a direct message conversation with cursor pagination.
|
|
1073
|
+
* @param dmId Unique identifier of the direct message conversation.
|
|
1074
|
+
* @param params Query parameters for pagination limits, cursors or search filters.
|
|
1075
|
+
* @param options Optional request config override.
|
|
1076
|
+
* @returns List of direct messages and next pagination cursor exactly from the endpoint.
|
|
1077
|
+
*/
|
|
1078
|
+
list: async (
|
|
1079
|
+
dmId: string,
|
|
1080
|
+
params?: DmsControllerGetMessagesParams,
|
|
1081
|
+
options?: AxiosRequestConfig
|
|
1082
|
+
): Promise<{ messages: ChannelMessage[]; nextCursor?: string }> => {
|
|
1083
|
+
return this.raw.dmsControllerGetMessages(dmId, params, options) as unknown as { messages: ChannelMessage[]; nextCursor?: string };
|
|
1084
|
+
},
|
|
1085
|
+
/**
|
|
1086
|
+
* Sends a new message in a direct message conversation.
|
|
1087
|
+
* @param dmId Unique identifier of the direct message conversation.
|
|
1088
|
+
* @param data The message content string or structured CreateMessageDto object.
|
|
1089
|
+
* @param options Optional request config override.
|
|
1090
|
+
* @returns The sent message exactly from the endpoint.
|
|
1091
|
+
*/
|
|
1092
|
+
create: async (
|
|
1093
|
+
dmId: string,
|
|
1094
|
+
data: CreateMessageDto | { content: string } | string,
|
|
1095
|
+
options?: AxiosRequestConfig
|
|
1096
|
+
): Promise<ChannelMessage> => {
|
|
1097
|
+
const payload = typeof data === 'string' ? { content: data } : data;
|
|
1098
|
+
return this.raw.dmsControllerCreateMessage(dmId, {
|
|
1099
|
+
...options,
|
|
1100
|
+
data: payload,
|
|
1101
|
+
}) as unknown as ChannelMessage;
|
|
1102
|
+
},
|
|
1103
|
+
/**
|
|
1104
|
+
* Updates the content of a previously sent direct message.
|
|
1105
|
+
* @param dmId Unique identifier of the direct message conversation.
|
|
1106
|
+
* @param messageId Unique identifier of the message to update.
|
|
1107
|
+
* @param data The new content payload.
|
|
1108
|
+
* @param options Optional request config override.
|
|
1109
|
+
* @returns The updated message details exactly from the endpoint.
|
|
1110
|
+
*/
|
|
1111
|
+
update: async (
|
|
1112
|
+
dmId: string,
|
|
1113
|
+
messageId: string,
|
|
1114
|
+
data: UpdateDmMessageDto,
|
|
1115
|
+
options?: AxiosRequestConfig
|
|
1116
|
+
): Promise<ChannelMessage> => {
|
|
1117
|
+
return this.raw.dmsControllerUpdateMessage(dmId, messageId, data, options) as unknown as ChannelMessage;
|
|
319
1118
|
},
|
|
320
|
-
|
|
321
|
-
|
|
1119
|
+
/**
|
|
1120
|
+
* Permanently deletes a direct message.
|
|
1121
|
+
* @param dmId Unique identifier of the direct message conversation.
|
|
1122
|
+
* @param messageId Unique identifier of the message to delete.
|
|
1123
|
+
* @param options Optional request config override.
|
|
1124
|
+
* @returns Success status indicating that the message was deleted exactly from the endpoint.
|
|
1125
|
+
*/
|
|
1126
|
+
delete: async (
|
|
1127
|
+
dmId: string,
|
|
1128
|
+
messageId: string,
|
|
1129
|
+
options?: AxiosRequestConfig
|
|
1130
|
+
): Promise<{ success: boolean }> => {
|
|
1131
|
+
return this.raw.dmsControllerDeleteMessage(dmId, messageId, options) as unknown as { success: boolean };
|
|
1132
|
+
},
|
|
1133
|
+
/**
|
|
1134
|
+
* Adds a reaction (emoji) to a direct message.
|
|
1135
|
+
* @param dmId Unique identifier of the direct message conversation.
|
|
1136
|
+
* @param messageId Unique identifier of the message.
|
|
1137
|
+
* @param data Object containing the target emoji character.
|
|
1138
|
+
* @param options Optional request config override.
|
|
1139
|
+
* @returns The reaction response returned exactly from the endpoint.
|
|
1140
|
+
*/
|
|
1141
|
+
addReaction: async (
|
|
1142
|
+
dmId: string,
|
|
1143
|
+
messageId: string,
|
|
1144
|
+
data: DmsControllerAddReactionBody,
|
|
1145
|
+
options?: AxiosRequestConfig
|
|
1146
|
+
): Promise<DmsControllerAddReactionResult> => {
|
|
1147
|
+
return this.raw.dmsControllerAddReaction(dmId, messageId, data, options) as unknown as DmsControllerAddReactionResult;
|
|
1148
|
+
},
|
|
1149
|
+
/**
|
|
1150
|
+
* Removes a reaction (emoji) from a direct message.
|
|
1151
|
+
* @param dmId Unique identifier of the direct message conversation.
|
|
1152
|
+
* @param messageId Unique identifier of the message.
|
|
1153
|
+
* @param emoji The emoji character to remove.
|
|
1154
|
+
* @param options Optional request config override.
|
|
1155
|
+
* @returns The reaction removal response returned exactly from the endpoint.
|
|
1156
|
+
*/
|
|
1157
|
+
removeReaction: async (
|
|
1158
|
+
dmId: string,
|
|
1159
|
+
messageId: string,
|
|
1160
|
+
emoji: string,
|
|
1161
|
+
options?: AxiosRequestConfig
|
|
1162
|
+
): Promise<DmsControllerRemoveReactionResult> => {
|
|
1163
|
+
return this.raw.dmsControllerRemoveReaction(dmId, messageId, emoji, options) as unknown as DmsControllerRemoveReactionResult;
|
|
322
1164
|
},
|
|
323
1165
|
},
|
|
324
1166
|
};
|
|
325
1167
|
}
|
|
326
1168
|
|
|
1169
|
+
/**
|
|
1170
|
+
* Operations for retrieving information about the current user or other user profiles,
|
|
1171
|
+
* as well as performing user searches.
|
|
1172
|
+
*/
|
|
327
1173
|
public get user() {
|
|
328
1174
|
return {
|
|
329
|
-
|
|
330
|
-
|
|
1175
|
+
/**
|
|
1176
|
+
* Retrieves the profile details of the currently authenticated user.
|
|
1177
|
+
* @param options Optional request config override.
|
|
1178
|
+
* @returns The active user's profile returned exactly from the endpoint.
|
|
1179
|
+
*/
|
|
1180
|
+
me: async (options?: AxiosRequestConfig): Promise<UserProfile> => {
|
|
1181
|
+
return this.raw.usersControllerGetMe(options) as unknown as UserProfile;
|
|
1182
|
+
},
|
|
1183
|
+
/**
|
|
1184
|
+
* Retrieves the public profile of a user by their user ID.
|
|
1185
|
+
* @param userId Unique identifier of the target user.
|
|
1186
|
+
* @param options Optional request config override.
|
|
1187
|
+
* @returns Public user profile returned exactly from the endpoint.
|
|
1188
|
+
*/
|
|
1189
|
+
get: async (userId: string, options?: AxiosRequestConfig): Promise<UserProfile> => {
|
|
1190
|
+
return this.raw.usersControllerGetUser(userId, options) as unknown as UserProfile;
|
|
1191
|
+
},
|
|
1192
|
+
/**
|
|
1193
|
+
* Searches the organization or workspace directory for user profiles matching specific queries.
|
|
1194
|
+
* @param params Object containing search filters and query string parameters.
|
|
1195
|
+
* @param options Optional request config override.
|
|
1196
|
+
* @returns List of matching user profiles returned exactly from the endpoint.
|
|
1197
|
+
*/
|
|
1198
|
+
search: async (
|
|
1199
|
+
params: UsersControllerSearchUsersParams,
|
|
1200
|
+
options?: AxiosRequestConfig
|
|
1201
|
+
): Promise<UserProfile[]> => {
|
|
1202
|
+
return this.raw.usersControllerSearchUsers(params, options) as unknown as UserProfile[];
|
|
1203
|
+
},
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
/**
|
|
1208
|
+
* Operations for managing webhooks (both standard workspace webhooks and channel incoming webhooks).
|
|
1209
|
+
*/
|
|
1210
|
+
public get webhooks() {
|
|
1211
|
+
return {
|
|
1212
|
+
/**
|
|
1213
|
+
* Lists all configured webhooks for a workspace. Requires webhooks:read scope.
|
|
1214
|
+
* @param slug The unique workspace slug.
|
|
1215
|
+
* @param options Optional request config override.
|
|
1216
|
+
*/
|
|
1217
|
+
list: async (slug: string, options?: AxiosRequestConfig): Promise<V3WebhooksControllerGetWebhooksResult> => {
|
|
1218
|
+
return this.raw.v3WebhooksControllerGetWebhooks(slug, options) as unknown as V3WebhooksControllerGetWebhooksResult;
|
|
1219
|
+
},
|
|
1220
|
+
/**
|
|
1221
|
+
* Creates a new standard webhook for a workspace. Requires webhooks:write scope.
|
|
1222
|
+
* @param slug The unique workspace slug.
|
|
1223
|
+
* @param data Configuration options for the standard webhook.
|
|
1224
|
+
* @param options Optional request config override.
|
|
1225
|
+
*/
|
|
1226
|
+
create: async (slug: string, data: V3CreateWebhookDto, options?: AxiosRequestConfig): Promise<V3WebhooksControllerCreateWebhookResult> => {
|
|
1227
|
+
return this.raw.v3WebhooksControllerCreateWebhook(slug, data, options) as unknown as V3WebhooksControllerCreateWebhookResult;
|
|
1228
|
+
},
|
|
1229
|
+
/**
|
|
1230
|
+
* Retrieves details of a specific webhook. Requires webhooks:read scope.
|
|
1231
|
+
* @param slug The unique workspace slug.
|
|
1232
|
+
* @param webhookId The unique webhook identifier.
|
|
1233
|
+
* @param options Optional request config override.
|
|
1234
|
+
*/
|
|
1235
|
+
get: async (slug: string, webhookId: string, options?: AxiosRequestConfig): Promise<V3WebhooksControllerGetWebhookResult> => {
|
|
1236
|
+
return this.raw.v3WebhooksControllerGetWebhook(slug, webhookId, options) as unknown as V3WebhooksControllerGetWebhookResult;
|
|
1237
|
+
},
|
|
1238
|
+
/**
|
|
1239
|
+
* Updates a standard webhook for a workspace. Requires webhooks:write scope.
|
|
1240
|
+
* @param slug The unique workspace slug.
|
|
1241
|
+
* @param webhookId The unique webhook identifier.
|
|
1242
|
+
* @param data Fields to update on the webhook.
|
|
1243
|
+
* @param options Optional request config override.
|
|
1244
|
+
*/
|
|
1245
|
+
update: async (
|
|
1246
|
+
slug: string,
|
|
1247
|
+
webhookId: string,
|
|
1248
|
+
data: V3UpdateWebhookDto,
|
|
1249
|
+
options?: AxiosRequestConfig
|
|
1250
|
+
): Promise<V3WebhooksControllerUpdateWebhookResult> => {
|
|
1251
|
+
return this.raw.v3WebhooksControllerUpdateWebhook(slug, webhookId, data, options) as unknown as V3WebhooksControllerUpdateWebhookResult;
|
|
1252
|
+
},
|
|
1253
|
+
/**
|
|
1254
|
+
* Permanently deletes a standard webhook. Requires webhooks:write scope.
|
|
1255
|
+
* @param slug The unique workspace slug.
|
|
1256
|
+
* @param webhookId The unique webhook identifier.
|
|
1257
|
+
* @param options Optional request config override.
|
|
1258
|
+
*/
|
|
1259
|
+
delete: async (slug: string, webhookId: string, options?: AxiosRequestConfig): Promise<V3WebhooksControllerDeleteWebhookResult> => {
|
|
1260
|
+
return this.raw.v3WebhooksControllerDeleteWebhook(slug, webhookId, options) as unknown as V3WebhooksControllerDeleteWebhookResult;
|
|
1261
|
+
},
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* Sub-namespace for managing channel incoming webhooks.
|
|
1265
|
+
*/
|
|
1266
|
+
incoming: {
|
|
1267
|
+
/**
|
|
1268
|
+
* Lists incoming webhooks configured for a specific channel. Requires webhooks:read scope.
|
|
1269
|
+
* @param slug The unique workspace slug.
|
|
1270
|
+
* @param channelId The unique channel identifier.
|
|
1271
|
+
* @param options Optional request config override.
|
|
1272
|
+
*/
|
|
1273
|
+
list: async (slug: string, channelId: string, options?: AxiosRequestConfig): Promise<V3ChannelIncomingWebhooksControllerGetChannelWebhooksResult> => {
|
|
1274
|
+
return this.raw.v3ChannelIncomingWebhooksControllerGetChannelWebhooks(slug, channelId, options) as unknown as V3ChannelIncomingWebhooksControllerGetChannelWebhooksResult;
|
|
1275
|
+
},
|
|
1276
|
+
/**
|
|
1277
|
+
* Creates an incoming webhook for a specific channel. Requires webhooks:write scope.
|
|
1278
|
+
* @param slug The unique workspace slug.
|
|
1279
|
+
* @param channelId The unique channel identifier.
|
|
1280
|
+
* @param data Configuration options for the incoming webhook.
|
|
1281
|
+
* @param options Optional request config override.
|
|
1282
|
+
*/
|
|
1283
|
+
create: async (
|
|
1284
|
+
slug: string,
|
|
1285
|
+
channelId: string,
|
|
1286
|
+
data: CreateChannelIncomingWebhookDto,
|
|
1287
|
+
options?: AxiosRequestConfig
|
|
1288
|
+
): Promise<V3ChannelIncomingWebhooksControllerCreateChannelWebhookResult> => {
|
|
1289
|
+
return this.raw.v3ChannelIncomingWebhooksControllerCreateChannelWebhook(slug, channelId, data, options) as unknown as V3ChannelIncomingWebhooksControllerCreateChannelWebhookResult;
|
|
1290
|
+
},
|
|
1291
|
+
/**
|
|
1292
|
+
* Retrieves details of a specific channel incoming webhook. Requires webhooks:read scope.
|
|
1293
|
+
* @param slug The unique workspace slug.
|
|
1294
|
+
* @param channelId The unique channel identifier.
|
|
1295
|
+
* @param webhookId The unique webhook identifier.
|
|
1296
|
+
* @param options Optional request config override.
|
|
1297
|
+
*/
|
|
1298
|
+
get: async (slug: string, channelId: string, webhookId: string, options?: AxiosRequestConfig): Promise<V3ChannelIncomingWebhooksControllerGetChannelWebhookResult> => {
|
|
1299
|
+
return this.raw.v3ChannelIncomingWebhooksControllerGetChannelWebhook(slug, channelId, webhookId, options) as unknown as V3ChannelIncomingWebhooksControllerGetChannelWebhookResult;
|
|
1300
|
+
},
|
|
1301
|
+
/**
|
|
1302
|
+
* Updates a channel incoming webhook. Requires webhooks:write scope.
|
|
1303
|
+
* @param slug The unique workspace slug.
|
|
1304
|
+
* @param channelId The unique channel identifier.
|
|
1305
|
+
* @param webhookId The unique webhook identifier.
|
|
1306
|
+
* @param data Fields to update on the incoming webhook.
|
|
1307
|
+
* @param options Optional request config override.
|
|
1308
|
+
*/
|
|
1309
|
+
update: async (
|
|
1310
|
+
slug: string,
|
|
1311
|
+
channelId: string,
|
|
1312
|
+
webhookId: string,
|
|
1313
|
+
data: UpdateChannelIncomingWebhookDto,
|
|
1314
|
+
options?: AxiosRequestConfig
|
|
1315
|
+
): Promise<V3ChannelIncomingWebhooksControllerUpdateChannelWebhookResult> => {
|
|
1316
|
+
return this.raw.v3ChannelIncomingWebhooksControllerUpdateChannelWebhook(
|
|
1317
|
+
slug,
|
|
1318
|
+
channelId,
|
|
1319
|
+
webhookId,
|
|
1320
|
+
data,
|
|
1321
|
+
options
|
|
1322
|
+
) as unknown as V3ChannelIncomingWebhooksControllerUpdateChannelWebhookResult;
|
|
1323
|
+
},
|
|
1324
|
+
/**
|
|
1325
|
+
* Deletes a channel incoming webhook. Requires webhooks:write scope.
|
|
1326
|
+
* @param slug The unique workspace slug.
|
|
1327
|
+
* @param channelId The unique channel identifier.
|
|
1328
|
+
* @param webhookId The unique webhook identifier.
|
|
1329
|
+
* @param options Optional request config override.
|
|
1330
|
+
*/
|
|
1331
|
+
delete: async (
|
|
1332
|
+
slug: string,
|
|
1333
|
+
channelId: string,
|
|
1334
|
+
webhookId: string,
|
|
1335
|
+
options?: AxiosRequestConfig
|
|
1336
|
+
): Promise<V3ChannelIncomingWebhooksControllerDeleteChannelWebhookResult> => {
|
|
1337
|
+
return this.raw.v3ChannelIncomingWebhooksControllerDeleteChannelWebhook(slug, channelId, webhookId, options) as unknown as V3ChannelIncomingWebhooksControllerDeleteChannelWebhookResult;
|
|
1338
|
+
},
|
|
1339
|
+
/**
|
|
1340
|
+
* Executes an incoming webhook using its unique url token directly. No auth headers required.
|
|
1341
|
+
* @param token The unique webhook token from the webhook URL.
|
|
1342
|
+
* @param data The payload payload consisting of content/attachments/metadata.
|
|
1343
|
+
* @param options Optional request config override.
|
|
1344
|
+
*/
|
|
1345
|
+
executeByUrlToken: async (
|
|
1346
|
+
token: string,
|
|
1347
|
+
data: ExecuteChannelIncomingWebhookDto,
|
|
1348
|
+
options?: AxiosRequestConfig
|
|
1349
|
+
): Promise<V3ChannelIncomingWebhooksControllerExecuteWebhookByUrlTokenResult> => {
|
|
1350
|
+
return this.raw.v3ChannelIncomingWebhooksControllerExecuteWebhookByUrlToken(token, data, options) as unknown as V3ChannelIncomingWebhooksControllerExecuteWebhookByUrlTokenResult;
|
|
1351
|
+
},
|
|
1352
|
+
/**
|
|
1353
|
+
* Executes an incoming webhook by channel ID.
|
|
1354
|
+
* @param channelId The target channel identifier.
|
|
1355
|
+
* @param data The payload payload consisting of content/attachments/metadata.
|
|
1356
|
+
* @param params Optional query parameters like token or signature.
|
|
1357
|
+
* @param options Optional request config override.
|
|
1358
|
+
*/
|
|
1359
|
+
executeByChannelId: async (
|
|
1360
|
+
channelId: string,
|
|
1361
|
+
data: ExecuteChannelIncomingWebhookDto,
|
|
1362
|
+
params?: V3ChannelIncomingWebhooksControllerExecuteWebhookByChannelIdParams,
|
|
1363
|
+
options?: AxiosRequestConfig
|
|
1364
|
+
): Promise<V3ChannelIncomingWebhooksControllerExecuteWebhookByChannelIdResult> => {
|
|
1365
|
+
return this.raw.v3ChannelIncomingWebhooksControllerExecuteWebhookByChannelId(
|
|
1366
|
+
channelId,
|
|
1367
|
+
data,
|
|
1368
|
+
params,
|
|
1369
|
+
options
|
|
1370
|
+
) as unknown as V3ChannelIncomingWebhooksControllerExecuteWebhookByChannelIdResult;
|
|
1371
|
+
},
|
|
1372
|
+
},
|
|
1373
|
+
};
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
/**
|
|
1377
|
+
* First-class namespace for Machine-to-Machine (M2M) operations,
|
|
1378
|
+
* grouping V3 Enterprise M2M APIs into logical, highly cohesive spaces.
|
|
1379
|
+
*/
|
|
1380
|
+
public get m2m() {
|
|
1381
|
+
return {
|
|
1382
|
+
/**
|
|
1383
|
+
* M2M Workspace Operations (Provisioning, Retrieval, and Lifecycle management).
|
|
1384
|
+
*/
|
|
1385
|
+
workspace: {
|
|
1386
|
+
/**
|
|
1387
|
+
* Provisions a brand new tenant workspace in the organization.
|
|
1388
|
+
* @param data Configuration payload for workspace name, slug, owner, and initial setups.
|
|
1389
|
+
* @param options Optional request config override.
|
|
1390
|
+
*/
|
|
1391
|
+
provision: async (
|
|
1392
|
+
data: V3ProvisionWorkspaceDto,
|
|
1393
|
+
options?: AxiosRequestConfig
|
|
1394
|
+
): Promise<V3ProvisionWorkspaceResponse> => {
|
|
1395
|
+
return this.raw.v3WorkspacesControllerProvisionWorkspace(data, options) as unknown as V3ProvisionWorkspaceResponse;
|
|
1396
|
+
},
|
|
1397
|
+
/**
|
|
1398
|
+
* Retrieves detailed information of a specific workspace by its slug.
|
|
1399
|
+
* @param slug The unique workspace slug.
|
|
1400
|
+
* @param options Optional request config override.
|
|
1401
|
+
*/
|
|
1402
|
+
get: async (slug: string, options?: AxiosRequestConfig): Promise<V3WorkspaceResponse> => {
|
|
1403
|
+
return this.raw.v3WorkspacesControllerGetWorkspaceBySlug(slug, options) as unknown as V3WorkspaceResponse;
|
|
1404
|
+
},
|
|
1405
|
+
/**
|
|
1406
|
+
* Lists all workspaces under the organization context.
|
|
1407
|
+
* @param options Optional request config override.
|
|
1408
|
+
*/
|
|
1409
|
+
list: async (options?: AxiosRequestConfig): Promise<V3WorkspacesResponse> => {
|
|
1410
|
+
return this.raw.v3WorkspacesControllerGetWorkspaces(options) as unknown as V3WorkspacesResponse;
|
|
1411
|
+
},
|
|
1412
|
+
/**
|
|
1413
|
+
* Updates configuration and branding metadata of a specific workspace.
|
|
1414
|
+
* @param slug The unique workspace slug.
|
|
1415
|
+
* @param data Workspace update DTO.
|
|
1416
|
+
* @param options Optional request config override.
|
|
1417
|
+
*/
|
|
1418
|
+
update: async (
|
|
1419
|
+
slug: string,
|
|
1420
|
+
data: V3UpdateWorkspaceDto,
|
|
1421
|
+
options?: AxiosRequestConfig
|
|
1422
|
+
): Promise<V3WorkspaceResponse> => {
|
|
1423
|
+
return this.raw.v3WorkspacesControllerUpdateWorkspace(slug, data, options) as unknown as V3WorkspaceResponse;
|
|
1424
|
+
},
|
|
1425
|
+
/**
|
|
1426
|
+
* Permanently deletes a specific workspace by its slug.
|
|
1427
|
+
* @param slug The unique workspace slug.
|
|
1428
|
+
* @param options Optional request config override.
|
|
1429
|
+
*/
|
|
1430
|
+
delete: async (slug: string, options?: AxiosRequestConfig): Promise<V3DeleteWorkspaceResponse> => {
|
|
1431
|
+
return this.raw.v3WorkspacesControllerDeleteWorkspace(slug, options) as unknown as V3DeleteWorkspaceResponse;
|
|
1432
|
+
},
|
|
331
1433
|
},
|
|
332
|
-
|
|
333
|
-
|
|
1434
|
+
|
|
1435
|
+
/**
|
|
1436
|
+
* M2M Workspace Membership Operations (Adding, modifying roles, and removing workspace members).
|
|
1437
|
+
*/
|
|
1438
|
+
member: {
|
|
1439
|
+
/**
|
|
1440
|
+
* Lists all members currently in a workspace.
|
|
1441
|
+
* @param slug The unique workspace slug.
|
|
1442
|
+
* @param options Optional request config override.
|
|
1443
|
+
*/
|
|
1444
|
+
list: async (slug: string, options?: AxiosRequestConfig): Promise<V3WorkspaceMembersResponse> => {
|
|
1445
|
+
return this.raw.v3WorkspacesControllerGetWorkspaceMembers(slug, options) as unknown as V3WorkspaceMembersResponse;
|
|
1446
|
+
},
|
|
1447
|
+
/**
|
|
1448
|
+
* Adds a new member to a workspace.
|
|
1449
|
+
* @param slug The unique workspace slug.
|
|
1450
|
+
* @param data Configuration containing user email and target role.
|
|
1451
|
+
* @param options Optional request config override.
|
|
1452
|
+
*/
|
|
1453
|
+
add: async (
|
|
1454
|
+
slug: string,
|
|
1455
|
+
data: V3AddMemberDto,
|
|
1456
|
+
options?: AxiosRequestConfig
|
|
1457
|
+
): Promise<V3AddWorkspaceMemberResponse> => {
|
|
1458
|
+
return this.raw.v3WorkspacesControllerAddWorkspaceMember(slug, data, options) as unknown as V3AddWorkspaceMemberResponse;
|
|
1459
|
+
},
|
|
1460
|
+
/**
|
|
1461
|
+
* Retrieves membership details of a specific workspace member.
|
|
1462
|
+
* @param slug The unique workspace slug.
|
|
1463
|
+
* @param memberId Unique ID of the workspace member (user ID).
|
|
1464
|
+
* @param options Optional request config override.
|
|
1465
|
+
*/
|
|
1466
|
+
get: async (
|
|
1467
|
+
slug: string,
|
|
1468
|
+
memberId: string,
|
|
1469
|
+
options?: AxiosRequestConfig
|
|
1470
|
+
): Promise<V3GetWorkspaceMemberResponse> => {
|
|
1471
|
+
return this.raw.v3WorkspacesControllerGetWorkspaceMember(slug, memberId, options) as unknown as V3GetWorkspaceMemberResponse;
|
|
1472
|
+
},
|
|
1473
|
+
/**
|
|
1474
|
+
* Updates the role or settings of an existing member in a workspace.
|
|
1475
|
+
* @param slug The unique workspace slug.
|
|
1476
|
+
* @param memberId Unique ID of the workspace member (user ID).
|
|
1477
|
+
* @param data Updated role.
|
|
1478
|
+
* @param options Optional request config override.
|
|
1479
|
+
*/
|
|
1480
|
+
update: async (
|
|
1481
|
+
slug: string,
|
|
1482
|
+
memberId: string,
|
|
1483
|
+
data: V3UpdateMemberRoleDto,
|
|
1484
|
+
options?: AxiosRequestConfig
|
|
1485
|
+
): Promise<V3UpdateWorkspaceMemberResponse> => {
|
|
1486
|
+
return this.raw.v3WorkspacesControllerUpdateWorkspaceMember(slug, memberId, data, options) as unknown as V3UpdateWorkspaceMemberResponse;
|
|
1487
|
+
},
|
|
1488
|
+
/**
|
|
1489
|
+
* Removes a member from a workspace.
|
|
1490
|
+
* @param slug The unique workspace slug.
|
|
1491
|
+
* @param memberId Unique ID of the workspace member (user ID).
|
|
1492
|
+
* @param options Optional request config override.
|
|
1493
|
+
*/
|
|
1494
|
+
delete: async (
|
|
1495
|
+
slug: string,
|
|
1496
|
+
memberId: string,
|
|
1497
|
+
options?: AxiosRequestConfig
|
|
1498
|
+
): Promise<V3DeleteWorkspaceMemberResponse> => {
|
|
1499
|
+
return this.raw.v3WorkspacesControllerDeleteWorkspaceMember(slug, memberId, options) as unknown as V3DeleteWorkspaceMemberResponse;
|
|
1500
|
+
},
|
|
334
1501
|
},
|
|
335
|
-
|
|
336
|
-
|
|
1502
|
+
|
|
1503
|
+
/**
|
|
1504
|
+
* M2M Authentication and Token Management Utilities.
|
|
1505
|
+
*/
|
|
1506
|
+
auth: {
|
|
1507
|
+
/**
|
|
1508
|
+
* Explicitly exchanges Client Credentials for a V3 access token.
|
|
1509
|
+
* @param clientId The unique M2M Client ID.
|
|
1510
|
+
* @param clientSecret The secure M2M Client Secret.
|
|
1511
|
+
* @param options Optional request config override.
|
|
1512
|
+
*/
|
|
1513
|
+
token: async (clientId: string, clientSecret: string, options?: AxiosRequestConfig): Promise<V3OAuthControllerGetTokenResult> => {
|
|
1514
|
+
return this.raw.v3OAuthControllerGetToken(
|
|
1515
|
+
{
|
|
1516
|
+
client_id: clientId,
|
|
1517
|
+
client_secret: clientSecret,
|
|
1518
|
+
grant_type: 'client_credentials',
|
|
1519
|
+
},
|
|
1520
|
+
options
|
|
1521
|
+
) as unknown as V3OAuthControllerGetTokenResult;
|
|
1522
|
+
},
|
|
1523
|
+
/**
|
|
1524
|
+
* Dynamically retrieves the current cached M2M token, or proactively fetches a new one.
|
|
1525
|
+
*/
|
|
1526
|
+
getOrFetchToken: async (): Promise<string | null> => {
|
|
1527
|
+
return this.getOrFetchToken();
|
|
1528
|
+
},
|
|
337
1529
|
},
|
|
338
1530
|
};
|
|
339
1531
|
}
|