@unboundcx/sdk 4.8.18 → 4.9.2
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/index.js +3 -0
- package/package.json +1 -1
- package/schemas/layouts/SCHEMA.md +316 -36
- package/schemas/layouts/section.js +17 -0
- package/services/branding.js +352 -0
- package/services/chat.js +725 -226
- package/services/layouts.js +25 -1
- package/services/messaging/CampaignsService.js +27 -0
- package/services/objects.js +21 -2
package/services/chat.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { internalRequest } from
|
|
1
|
+
import { internalRequest } from "../base.js";
|
|
2
2
|
/**
|
|
3
3
|
* ChatService — channels, DMs, membership, unreads, DND, messages, search,
|
|
4
4
|
* webhooks, card actions, reports, admin review, admin export, record feeds,
|
|
@@ -26,11 +26,11 @@ export class ChatService {
|
|
|
26
26
|
this.sdk.validateParams(
|
|
27
27
|
{ name, topic, kind, settings, groupIds },
|
|
28
28
|
{
|
|
29
|
-
name: { type:
|
|
30
|
-
topic: { type:
|
|
31
|
-
kind: { type:
|
|
32
|
-
settings: { type:
|
|
33
|
-
groupIds: { type:
|
|
29
|
+
name: { type: "string", required: true },
|
|
30
|
+
topic: { type: "string", required: false },
|
|
31
|
+
kind: { type: "string", required: false },
|
|
32
|
+
settings: { type: "object", required: false },
|
|
33
|
+
groupIds: { type: "array", required: false },
|
|
34
34
|
},
|
|
35
35
|
);
|
|
36
36
|
|
|
@@ -40,7 +40,7 @@ export class ChatService {
|
|
|
40
40
|
if (settings !== undefined) body.settings = settings;
|
|
41
41
|
if (groupIds !== undefined) body.groupIds = groupIds;
|
|
42
42
|
|
|
43
|
-
return internalRequest(this.sdk,
|
|
43
|
+
return internalRequest(this.sdk, "/chat/channels", "POST", { body });
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
@@ -48,7 +48,7 @@ export class ChatService {
|
|
|
48
48
|
* @returns {Promise<Object>}
|
|
49
49
|
*/
|
|
50
50
|
async listChannels() {
|
|
51
|
-
return internalRequest(this.sdk,
|
|
51
|
+
return internalRequest(this.sdk, "/chat/channels", "GET");
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
@@ -56,7 +56,7 @@ export class ChatService {
|
|
|
56
56
|
* @returns {Promise<Object>}
|
|
57
57
|
*/
|
|
58
58
|
async browseChannels() {
|
|
59
|
-
return internalRequest(this.sdk,
|
|
59
|
+
return internalRequest(this.sdk, "/chat/channels/browse", "GET");
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/**
|
|
@@ -65,8 +65,8 @@ export class ChatService {
|
|
|
65
65
|
* @returns {Promise<Object>}
|
|
66
66
|
*/
|
|
67
67
|
async getChannel(id) {
|
|
68
|
-
this.sdk.validateParams({ id }, { id: { type:
|
|
69
|
-
return internalRequest(this.sdk, `/chat/channels/${id}`,
|
|
68
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
69
|
+
return internalRequest(this.sdk, `/chat/channels/${id}`, "GET");
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
@@ -82,11 +82,11 @@ export class ChatService {
|
|
|
82
82
|
this.sdk.validateParams(
|
|
83
83
|
{ id, name, topic, settings, kind },
|
|
84
84
|
{
|
|
85
|
-
id: { type:
|
|
86
|
-
name: { type:
|
|
87
|
-
topic: { type:
|
|
88
|
-
settings: { type:
|
|
89
|
-
kind: { type:
|
|
85
|
+
id: { type: "string", required: true },
|
|
86
|
+
name: { type: "string", required: false },
|
|
87
|
+
topic: { type: "string", required: false },
|
|
88
|
+
settings: { type: "object", required: false },
|
|
89
|
+
kind: { type: "string", required: false },
|
|
90
90
|
},
|
|
91
91
|
);
|
|
92
92
|
|
|
@@ -96,7 +96,7 @@ export class ChatService {
|
|
|
96
96
|
if (settings !== undefined) body.settings = settings;
|
|
97
97
|
if (kind !== undefined) body.kind = kind;
|
|
98
98
|
|
|
99
|
-
return internalRequest(this.sdk, `/chat/channels/${id}`,
|
|
99
|
+
return internalRequest(this.sdk, `/chat/channels/${id}`, "PATCH", { body });
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
/**
|
|
@@ -105,8 +105,8 @@ export class ChatService {
|
|
|
105
105
|
* @returns {Promise<Object>}
|
|
106
106
|
*/
|
|
107
107
|
async archiveChannel(id) {
|
|
108
|
-
this.sdk.validateParams({ id }, { id: { type:
|
|
109
|
-
return internalRequest(this.sdk, `/chat/channels/${id}/archive`,
|
|
108
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
109
|
+
return internalRequest(this.sdk, `/chat/channels/${id}/archive`, "POST", {
|
|
110
110
|
body: {},
|
|
111
111
|
});
|
|
112
112
|
}
|
|
@@ -117,8 +117,8 @@ export class ChatService {
|
|
|
117
117
|
* @returns {Promise<Object>}
|
|
118
118
|
*/
|
|
119
119
|
async unarchiveChannel(id) {
|
|
120
|
-
this.sdk.validateParams({ id }, { id: { type:
|
|
121
|
-
return internalRequest(this.sdk, `/chat/channels/${id}/unarchive`,
|
|
120
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
121
|
+
return internalRequest(this.sdk, `/chat/channels/${id}/unarchive`, "POST", {
|
|
122
122
|
body: {},
|
|
123
123
|
});
|
|
124
124
|
}
|
|
@@ -129,8 +129,10 @@ export class ChatService {
|
|
|
129
129
|
* @returns {Promise<Object>}
|
|
130
130
|
*/
|
|
131
131
|
async joinChannel(id) {
|
|
132
|
-
this.sdk.validateParams({ id }, { id: { type:
|
|
133
|
-
return internalRequest(this.sdk, `/chat/channels/${id}/join`,
|
|
132
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
133
|
+
return internalRequest(this.sdk, `/chat/channels/${id}/join`, "POST", {
|
|
134
|
+
body: {},
|
|
135
|
+
});
|
|
134
136
|
}
|
|
135
137
|
|
|
136
138
|
/**
|
|
@@ -139,8 +141,10 @@ export class ChatService {
|
|
|
139
141
|
* @returns {Promise<Object>}
|
|
140
142
|
*/
|
|
141
143
|
async leaveChannel(id) {
|
|
142
|
-
this.sdk.validateParams({ id }, { id: { type:
|
|
143
|
-
return internalRequest(this.sdk, `/chat/channels/${id}/leave`,
|
|
144
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
145
|
+
return internalRequest(this.sdk, `/chat/channels/${id}/leave`, "POST", {
|
|
146
|
+
body: {},
|
|
147
|
+
});
|
|
144
148
|
}
|
|
145
149
|
|
|
146
150
|
/**
|
|
@@ -149,8 +153,8 @@ export class ChatService {
|
|
|
149
153
|
* @returns {Promise<Object>}
|
|
150
154
|
*/
|
|
151
155
|
async listMembers(id) {
|
|
152
|
-
this.sdk.validateParams({ id }, { id: { type:
|
|
153
|
-
return internalRequest(this.sdk, `/chat/channels/${id}/members`,
|
|
156
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
157
|
+
return internalRequest(this.sdk, `/chat/channels/${id}/members`, "GET");
|
|
154
158
|
}
|
|
155
159
|
|
|
156
160
|
/**
|
|
@@ -165,16 +169,18 @@ export class ChatService {
|
|
|
165
169
|
this.sdk.validateParams(
|
|
166
170
|
{ id, userId, role },
|
|
167
171
|
{
|
|
168
|
-
id: { type:
|
|
169
|
-
userId: { type:
|
|
170
|
-
role: { type:
|
|
172
|
+
id: { type: "string", required: true },
|
|
173
|
+
userId: { type: "string", required: true },
|
|
174
|
+
role: { type: "string", required: false },
|
|
171
175
|
},
|
|
172
176
|
);
|
|
173
177
|
|
|
174
178
|
const body = { userId };
|
|
175
179
|
if (role !== undefined) body.role = role;
|
|
176
180
|
|
|
177
|
-
return internalRequest(this.sdk, `/chat/channels/${id}/members`,
|
|
181
|
+
return internalRequest(this.sdk, `/chat/channels/${id}/members`, "POST", {
|
|
182
|
+
body,
|
|
183
|
+
});
|
|
178
184
|
}
|
|
179
185
|
|
|
180
186
|
/**
|
|
@@ -187,11 +193,15 @@ export class ChatService {
|
|
|
187
193
|
this.sdk.validateParams(
|
|
188
194
|
{ id, userId },
|
|
189
195
|
{
|
|
190
|
-
id: { type:
|
|
191
|
-
userId: { type:
|
|
196
|
+
id: { type: "string", required: true },
|
|
197
|
+
userId: { type: "string", required: true },
|
|
192
198
|
},
|
|
193
199
|
);
|
|
194
|
-
return internalRequest(
|
|
200
|
+
return internalRequest(
|
|
201
|
+
this.sdk,
|
|
202
|
+
`/chat/channels/${id}/members/${userId}`,
|
|
203
|
+
"DELETE",
|
|
204
|
+
);
|
|
195
205
|
}
|
|
196
206
|
|
|
197
207
|
/**
|
|
@@ -200,8 +210,12 @@ export class ChatService {
|
|
|
200
210
|
* @returns {Promise<Object>}
|
|
201
211
|
*/
|
|
202
212
|
async getGroupDefaults(id) {
|
|
203
|
-
this.sdk.validateParams({ id }, { id: { type:
|
|
204
|
-
return internalRequest(
|
|
213
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
214
|
+
return internalRequest(
|
|
215
|
+
this.sdk,
|
|
216
|
+
`/chat/channels/${id}/group-defaults`,
|
|
217
|
+
"GET",
|
|
218
|
+
);
|
|
205
219
|
}
|
|
206
220
|
|
|
207
221
|
/**
|
|
@@ -215,13 +229,18 @@ export class ChatService {
|
|
|
215
229
|
this.sdk.validateParams(
|
|
216
230
|
{ id, groupIds },
|
|
217
231
|
{
|
|
218
|
-
id: { type:
|
|
219
|
-
groupIds: { type:
|
|
232
|
+
id: { type: "string", required: true },
|
|
233
|
+
groupIds: { type: "array", required: true },
|
|
234
|
+
},
|
|
235
|
+
);
|
|
236
|
+
return internalRequest(
|
|
237
|
+
this.sdk,
|
|
238
|
+
`/chat/channels/${id}/group-defaults`,
|
|
239
|
+
"PUT",
|
|
240
|
+
{
|
|
241
|
+
body: { groupIds },
|
|
220
242
|
},
|
|
221
243
|
);
|
|
222
|
-
return internalRequest(this.sdk, `/chat/channels/${id}/group-defaults`, 'PUT', {
|
|
223
|
-
body: { groupIds },
|
|
224
|
-
});
|
|
225
244
|
}
|
|
226
245
|
|
|
227
246
|
/**
|
|
@@ -234,9 +253,11 @@ export class ChatService {
|
|
|
234
253
|
async openDm({ userIds }) {
|
|
235
254
|
this.sdk.validateParams(
|
|
236
255
|
{ userIds },
|
|
237
|
-
{ userIds: { type:
|
|
256
|
+
{ userIds: { type: "array", required: true } },
|
|
238
257
|
);
|
|
239
|
-
return internalRequest(this.sdk,
|
|
258
|
+
return internalRequest(this.sdk, "/chat/dms", "POST", {
|
|
259
|
+
body: { userIds },
|
|
260
|
+
});
|
|
240
261
|
}
|
|
241
262
|
|
|
242
263
|
/**
|
|
@@ -244,7 +265,7 @@ export class ChatService {
|
|
|
244
265
|
* @returns {Promise<Object>}
|
|
245
266
|
*/
|
|
246
267
|
async getUnreads() {
|
|
247
|
-
return internalRequest(this.sdk,
|
|
268
|
+
return internalRequest(this.sdk, "/chat/unreads", "GET");
|
|
248
269
|
}
|
|
249
270
|
|
|
250
271
|
/**
|
|
@@ -252,7 +273,7 @@ export class ChatService {
|
|
|
252
273
|
* @returns {Promise<Object>}
|
|
253
274
|
*/
|
|
254
275
|
async getDnd() {
|
|
255
|
-
return internalRequest(this.sdk,
|
|
276
|
+
return internalRequest(this.sdk, "/chat/dnd", "GET");
|
|
256
277
|
}
|
|
257
278
|
|
|
258
279
|
/**
|
|
@@ -264,9 +285,11 @@ export class ChatService {
|
|
|
264
285
|
async setDnd({ enabled } = {}) {
|
|
265
286
|
this.sdk.validateParams(
|
|
266
287
|
{ enabled },
|
|
267
|
-
{ enabled: { type:
|
|
288
|
+
{ enabled: { type: "boolean", required: true } },
|
|
268
289
|
);
|
|
269
|
-
return internalRequest(this.sdk,
|
|
290
|
+
return internalRequest(this.sdk, "/chat/dnd", "PATCH", {
|
|
291
|
+
body: { enabled },
|
|
292
|
+
});
|
|
270
293
|
}
|
|
271
294
|
|
|
272
295
|
/**
|
|
@@ -274,7 +297,7 @@ export class ChatService {
|
|
|
274
297
|
* @returns {Promise<Object>}
|
|
275
298
|
*/
|
|
276
299
|
async getEmojiFavorites() {
|
|
277
|
-
return internalRequest(this.sdk,
|
|
300
|
+
return internalRequest(this.sdk, "/chat/emoji-favorites", "GET");
|
|
278
301
|
}
|
|
279
302
|
|
|
280
303
|
/**
|
|
@@ -286,9 +309,9 @@ export class ChatService {
|
|
|
286
309
|
async setEmojiFavorites({ emojis } = {}) {
|
|
287
310
|
this.sdk.validateParams(
|
|
288
311
|
{ emojis },
|
|
289
|
-
{ emojis: { type:
|
|
312
|
+
{ emojis: { type: "array", required: true } },
|
|
290
313
|
);
|
|
291
|
-
return internalRequest(this.sdk,
|
|
314
|
+
return internalRequest(this.sdk, "/chat/emoji-favorites", "PATCH", {
|
|
292
315
|
body: { emojis },
|
|
293
316
|
});
|
|
294
317
|
}
|
|
@@ -303,13 +326,18 @@ export class ChatService {
|
|
|
303
326
|
this.sdk.validateParams(
|
|
304
327
|
{ channelId, messageId },
|
|
305
328
|
{
|
|
306
|
-
channelId: { type:
|
|
307
|
-
messageId: { type:
|
|
329
|
+
channelId: { type: "string", required: true },
|
|
330
|
+
messageId: { type: "string", required: true },
|
|
331
|
+
},
|
|
332
|
+
);
|
|
333
|
+
return internalRequest(
|
|
334
|
+
this.sdk,
|
|
335
|
+
`/chat/channels/${channelId}/read`,
|
|
336
|
+
"POST",
|
|
337
|
+
{
|
|
338
|
+
body: { messageId },
|
|
308
339
|
},
|
|
309
340
|
);
|
|
310
|
-
return internalRequest(this.sdk, `/chat/channels/${channelId}/read`, 'POST', {
|
|
311
|
-
body: { messageId },
|
|
312
|
-
});
|
|
313
341
|
}
|
|
314
342
|
|
|
315
343
|
/**
|
|
@@ -322,13 +350,18 @@ export class ChatService {
|
|
|
322
350
|
this.sdk.validateParams(
|
|
323
351
|
{ channelId, messageId },
|
|
324
352
|
{
|
|
325
|
-
channelId: { type:
|
|
326
|
-
messageId: { type:
|
|
353
|
+
channelId: { type: "string", required: true },
|
|
354
|
+
messageId: { type: "string", required: true },
|
|
355
|
+
},
|
|
356
|
+
);
|
|
357
|
+
return internalRequest(
|
|
358
|
+
this.sdk,
|
|
359
|
+
`/chat/channels/${channelId}/unread`,
|
|
360
|
+
"POST",
|
|
361
|
+
{
|
|
362
|
+
body: { messageId },
|
|
327
363
|
},
|
|
328
364
|
);
|
|
329
|
-
return internalRequest(this.sdk, `/chat/channels/${channelId}/unread`, 'POST', {
|
|
330
|
-
body: { messageId },
|
|
331
|
-
});
|
|
332
365
|
}
|
|
333
366
|
|
|
334
367
|
/**
|
|
@@ -342,13 +375,18 @@ export class ChatService {
|
|
|
342
375
|
this.sdk.validateParams(
|
|
343
376
|
{ groupId, userId },
|
|
344
377
|
{
|
|
345
|
-
groupId: { type:
|
|
346
|
-
userId: { type:
|
|
378
|
+
groupId: { type: "string", required: true },
|
|
379
|
+
userId: { type: "string", required: true },
|
|
380
|
+
},
|
|
381
|
+
);
|
|
382
|
+
return internalRequest(
|
|
383
|
+
this.sdk,
|
|
384
|
+
`/chat/groups/${groupId}/linked-channels`,
|
|
385
|
+
"GET",
|
|
386
|
+
{
|
|
387
|
+
query: { userId },
|
|
347
388
|
},
|
|
348
389
|
);
|
|
349
|
-
return internalRequest(this.sdk, `/chat/groups/${groupId}/linked-channels`, 'GET', {
|
|
350
|
-
query: { userId },
|
|
351
|
-
});
|
|
352
390
|
}
|
|
353
391
|
|
|
354
392
|
/**
|
|
@@ -364,10 +402,10 @@ export class ChatService {
|
|
|
364
402
|
this.sdk.validateParams(
|
|
365
403
|
{ channelId, before, after, limit },
|
|
366
404
|
{
|
|
367
|
-
channelId: { type:
|
|
368
|
-
before: { type:
|
|
369
|
-
after: { type:
|
|
370
|
-
limit: { type:
|
|
405
|
+
channelId: { type: "string", required: true },
|
|
406
|
+
before: { type: "string", required: false },
|
|
407
|
+
after: { type: "string", required: false },
|
|
408
|
+
limit: { type: "number", required: false },
|
|
371
409
|
},
|
|
372
410
|
);
|
|
373
411
|
|
|
@@ -376,9 +414,14 @@ export class ChatService {
|
|
|
376
414
|
if (after !== undefined) query.after = after;
|
|
377
415
|
if (limit !== undefined) query.limit = limit;
|
|
378
416
|
|
|
379
|
-
return internalRequest(
|
|
380
|
-
|
|
381
|
-
|
|
417
|
+
return internalRequest(
|
|
418
|
+
this.sdk,
|
|
419
|
+
`/chat/channels/${channelId}/messages`,
|
|
420
|
+
"GET",
|
|
421
|
+
{
|
|
422
|
+
query,
|
|
423
|
+
},
|
|
424
|
+
);
|
|
382
425
|
}
|
|
383
426
|
|
|
384
427
|
/**
|
|
@@ -419,15 +462,15 @@ export class ChatService {
|
|
|
419
462
|
toolConfig,
|
|
420
463
|
},
|
|
421
464
|
{
|
|
422
|
-
channelId: { type:
|
|
423
|
-
message: { type:
|
|
424
|
-
threadRootId: { type:
|
|
425
|
-
alsoSendToChannel: { type:
|
|
426
|
-
storageIds: { type:
|
|
427
|
-
suppressUnfurlUrls: { type:
|
|
428
|
-
unfurls: { type:
|
|
429
|
-
tools: { type:
|
|
430
|
-
toolConfig: { type:
|
|
465
|
+
channelId: { type: "string", required: true },
|
|
466
|
+
message: { type: "object", required: true },
|
|
467
|
+
threadRootId: { type: "string", required: false },
|
|
468
|
+
alsoSendToChannel: { type: "boolean", required: false },
|
|
469
|
+
storageIds: { type: "array", required: false },
|
|
470
|
+
suppressUnfurlUrls: { type: "array", required: false },
|
|
471
|
+
unfurls: { type: "array", required: false },
|
|
472
|
+
tools: { type: "array", required: false },
|
|
473
|
+
toolConfig: { type: "object", required: false },
|
|
431
474
|
},
|
|
432
475
|
);
|
|
433
476
|
|
|
@@ -444,9 +487,14 @@ export class ChatService {
|
|
|
444
487
|
if (tools !== undefined) body.tools = tools;
|
|
445
488
|
if (toolConfig !== undefined) body.toolConfig = toolConfig;
|
|
446
489
|
|
|
447
|
-
return internalRequest(
|
|
448
|
-
|
|
449
|
-
|
|
490
|
+
return internalRequest(
|
|
491
|
+
this.sdk,
|
|
492
|
+
`/chat/channels/${channelId}/messages`,
|
|
493
|
+
"POST",
|
|
494
|
+
{
|
|
495
|
+
body,
|
|
496
|
+
},
|
|
497
|
+
);
|
|
450
498
|
}
|
|
451
499
|
|
|
452
500
|
/**
|
|
@@ -460,11 +508,11 @@ export class ChatService {
|
|
|
460
508
|
this.sdk.validateParams(
|
|
461
509
|
{ id, message },
|
|
462
510
|
{
|
|
463
|
-
id: { type:
|
|
464
|
-
message: { type:
|
|
511
|
+
id: { type: "string", required: true },
|
|
512
|
+
message: { type: "object", required: true },
|
|
465
513
|
},
|
|
466
514
|
);
|
|
467
|
-
return internalRequest(this.sdk, `/chat/messages/${id}`,
|
|
515
|
+
return internalRequest(this.sdk, `/chat/messages/${id}`, "PATCH", {
|
|
468
516
|
body: { message },
|
|
469
517
|
});
|
|
470
518
|
}
|
|
@@ -476,11 +524,14 @@ export class ChatService {
|
|
|
476
524
|
* @returns {Promise<Object>}
|
|
477
525
|
*/
|
|
478
526
|
async previewLink({ url } = {}) {
|
|
479
|
-
this.sdk.validateParams(
|
|
527
|
+
this.sdk.validateParams(
|
|
528
|
+
{ url },
|
|
529
|
+
{ url: { type: "string", required: true } },
|
|
530
|
+
);
|
|
480
531
|
return internalRequest(
|
|
481
532
|
this.sdk,
|
|
482
533
|
`/chat/link-preview?url=${encodeURIComponent(url)}`,
|
|
483
|
-
|
|
534
|
+
"GET",
|
|
484
535
|
);
|
|
485
536
|
}
|
|
486
537
|
|
|
@@ -495,14 +546,14 @@ export class ChatService {
|
|
|
495
546
|
this.sdk.validateParams(
|
|
496
547
|
{ id, url },
|
|
497
548
|
{
|
|
498
|
-
id: { type:
|
|
499
|
-
url: { type:
|
|
549
|
+
id: { type: "string", required: true },
|
|
550
|
+
url: { type: "string", required: true },
|
|
500
551
|
},
|
|
501
552
|
);
|
|
502
553
|
return internalRequest(
|
|
503
554
|
this.sdk,
|
|
504
555
|
`/chat/messages/${id}/unfurls/hide`,
|
|
505
|
-
|
|
556
|
+
"POST",
|
|
506
557
|
{ body: { url } },
|
|
507
558
|
);
|
|
508
559
|
}
|
|
@@ -513,8 +564,8 @@ export class ChatService {
|
|
|
513
564
|
* @returns {Promise<Object>}
|
|
514
565
|
*/
|
|
515
566
|
async deleteMessage(id) {
|
|
516
|
-
this.sdk.validateParams({ id }, { id: { type:
|
|
517
|
-
return internalRequest(this.sdk, `/chat/messages/${id}`,
|
|
567
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
568
|
+
return internalRequest(this.sdk, `/chat/messages/${id}`, "DELETE");
|
|
518
569
|
}
|
|
519
570
|
|
|
520
571
|
/**
|
|
@@ -528,11 +579,11 @@ export class ChatService {
|
|
|
528
579
|
this.sdk.validateParams(
|
|
529
580
|
{ id, emoji },
|
|
530
581
|
{
|
|
531
|
-
id: { type:
|
|
532
|
-
emoji: { type:
|
|
582
|
+
id: { type: "string", required: true },
|
|
583
|
+
emoji: { type: "string", required: true },
|
|
533
584
|
},
|
|
534
585
|
);
|
|
535
|
-
return internalRequest(this.sdk, `/chat/messages/${id}/reactions`,
|
|
586
|
+
return internalRequest(this.sdk, `/chat/messages/${id}/reactions`, "POST", {
|
|
536
587
|
body: { emoji },
|
|
537
588
|
});
|
|
538
589
|
}
|
|
@@ -548,13 +599,18 @@ export class ChatService {
|
|
|
548
599
|
this.sdk.validateParams(
|
|
549
600
|
{ id, emoji },
|
|
550
601
|
{
|
|
551
|
-
id: { type:
|
|
552
|
-
emoji: { type:
|
|
602
|
+
id: { type: "string", required: true },
|
|
603
|
+
emoji: { type: "string", required: true },
|
|
604
|
+
},
|
|
605
|
+
);
|
|
606
|
+
return internalRequest(
|
|
607
|
+
this.sdk,
|
|
608
|
+
`/chat/messages/${id}/reactions`,
|
|
609
|
+
"DELETE",
|
|
610
|
+
{
|
|
611
|
+
body: { emoji },
|
|
553
612
|
},
|
|
554
613
|
);
|
|
555
|
-
return internalRequest(this.sdk, `/chat/messages/${id}/reactions`, 'DELETE', {
|
|
556
|
-
body: { emoji },
|
|
557
|
-
});
|
|
558
614
|
}
|
|
559
615
|
|
|
560
616
|
/**
|
|
@@ -567,13 +623,14 @@ export class ChatService {
|
|
|
567
623
|
this.sdk.validateParams(
|
|
568
624
|
{ channelId, rootId },
|
|
569
625
|
{
|
|
570
|
-
channelId: { type:
|
|
571
|
-
rootId: { type:
|
|
626
|
+
channelId: { type: "string", required: true },
|
|
627
|
+
rootId: { type: "string", required: true },
|
|
572
628
|
},
|
|
573
629
|
);
|
|
574
|
-
return internalRequest(
|
|
630
|
+
return internalRequest(
|
|
631
|
+
this.sdk,
|
|
575
632
|
`/chat/channels/${channelId}/messages/${rootId}/thread`,
|
|
576
|
-
|
|
633
|
+
"GET",
|
|
577
634
|
);
|
|
578
635
|
}
|
|
579
636
|
|
|
@@ -603,14 +660,14 @@ export class ChatService {
|
|
|
603
660
|
this.sdk.validateParams(
|
|
604
661
|
{ q, channelId, fromUserId, before, after, kind, nextId, limit },
|
|
605
662
|
{
|
|
606
|
-
q: { type:
|
|
607
|
-
channelId: { type:
|
|
608
|
-
fromUserId: { type:
|
|
609
|
-
before: { type:
|
|
610
|
-
after: { type:
|
|
611
|
-
kind: { type:
|
|
612
|
-
nextId: { type:
|
|
613
|
-
limit: { type:
|
|
663
|
+
q: { type: "string", required: true },
|
|
664
|
+
channelId: { type: "string", required: false },
|
|
665
|
+
fromUserId: { type: "string", required: false },
|
|
666
|
+
before: { type: "string", required: false },
|
|
667
|
+
after: { type: "string", required: false },
|
|
668
|
+
kind: { type: "string", required: false },
|
|
669
|
+
nextId: { type: "string", required: false },
|
|
670
|
+
limit: { type: "number", required: false },
|
|
614
671
|
},
|
|
615
672
|
);
|
|
616
673
|
|
|
@@ -623,7 +680,7 @@ export class ChatService {
|
|
|
623
680
|
if (nextId !== undefined) query.nextId = nextId;
|
|
624
681
|
if (limit !== undefined) query.limit = limit;
|
|
625
682
|
|
|
626
|
-
return internalRequest(this.sdk,
|
|
683
|
+
return internalRequest(this.sdk, "/chat/search", "GET", { query });
|
|
627
684
|
}
|
|
628
685
|
|
|
629
686
|
/**
|
|
@@ -640,10 +697,10 @@ export class ChatService {
|
|
|
640
697
|
this.sdk.validateParams(
|
|
641
698
|
{ channelId, name, avatar, callbackUrl },
|
|
642
699
|
{
|
|
643
|
-
channelId: { type:
|
|
644
|
-
name: { type:
|
|
645
|
-
avatar: { type:
|
|
646
|
-
callbackUrl: { type:
|
|
700
|
+
channelId: { type: "string", required: true },
|
|
701
|
+
name: { type: "string", required: true },
|
|
702
|
+
avatar: { type: "string", required: false },
|
|
703
|
+
callbackUrl: { type: "string", required: false },
|
|
647
704
|
},
|
|
648
705
|
);
|
|
649
706
|
|
|
@@ -651,9 +708,14 @@ export class ChatService {
|
|
|
651
708
|
if (avatar !== undefined) body.avatar = avatar;
|
|
652
709
|
if (callbackUrl !== undefined) body.callbackUrl = callbackUrl;
|
|
653
710
|
|
|
654
|
-
return internalRequest(
|
|
655
|
-
|
|
656
|
-
|
|
711
|
+
return internalRequest(
|
|
712
|
+
this.sdk,
|
|
713
|
+
`/chat/channels/${channelId}/webhooks`,
|
|
714
|
+
"POST",
|
|
715
|
+
{
|
|
716
|
+
body,
|
|
717
|
+
},
|
|
718
|
+
);
|
|
657
719
|
}
|
|
658
720
|
|
|
659
721
|
/**
|
|
@@ -664,9 +726,13 @@ export class ChatService {
|
|
|
664
726
|
async listWebhooks(channelId) {
|
|
665
727
|
this.sdk.validateParams(
|
|
666
728
|
{ channelId },
|
|
667
|
-
{ channelId: { type:
|
|
729
|
+
{ channelId: { type: "string", required: true } },
|
|
730
|
+
);
|
|
731
|
+
return internalRequest(
|
|
732
|
+
this.sdk,
|
|
733
|
+
`/chat/channels/${channelId}/webhooks`,
|
|
734
|
+
"GET",
|
|
668
735
|
);
|
|
669
|
-
return internalRequest(this.sdk, `/chat/channels/${channelId}/webhooks`, 'GET');
|
|
670
736
|
}
|
|
671
737
|
|
|
672
738
|
/**
|
|
@@ -679,13 +745,14 @@ export class ChatService {
|
|
|
679
745
|
this.sdk.validateParams(
|
|
680
746
|
{ channelId, webhookId },
|
|
681
747
|
{
|
|
682
|
-
channelId: { type:
|
|
683
|
-
webhookId: { type:
|
|
748
|
+
channelId: { type: "string", required: true },
|
|
749
|
+
webhookId: { type: "string", required: true },
|
|
684
750
|
},
|
|
685
751
|
);
|
|
686
|
-
return internalRequest(
|
|
752
|
+
return internalRequest(
|
|
753
|
+
this.sdk,
|
|
687
754
|
`/chat/channels/${channelId}/webhooks/${webhookId}`,
|
|
688
|
-
|
|
755
|
+
"DELETE",
|
|
689
756
|
);
|
|
690
757
|
}
|
|
691
758
|
|
|
@@ -701,18 +768,23 @@ export class ChatService {
|
|
|
701
768
|
this.sdk.validateParams(
|
|
702
769
|
{ messageId, actionId, value },
|
|
703
770
|
{
|
|
704
|
-
messageId: { type:
|
|
705
|
-
actionId: { type:
|
|
706
|
-
value: { type:
|
|
771
|
+
messageId: { type: "string", required: true },
|
|
772
|
+
actionId: { type: "string", required: true },
|
|
773
|
+
value: { type: "string", required: false },
|
|
707
774
|
},
|
|
708
775
|
);
|
|
709
776
|
|
|
710
777
|
const body = { actionId };
|
|
711
778
|
if (value !== undefined) body.value = value;
|
|
712
779
|
|
|
713
|
-
return internalRequest(
|
|
714
|
-
|
|
715
|
-
|
|
780
|
+
return internalRequest(
|
|
781
|
+
this.sdk,
|
|
782
|
+
`/chat/messages/${messageId}/actions`,
|
|
783
|
+
"POST",
|
|
784
|
+
{
|
|
785
|
+
body,
|
|
786
|
+
},
|
|
787
|
+
);
|
|
716
788
|
}
|
|
717
789
|
|
|
718
790
|
/**
|
|
@@ -726,11 +798,11 @@ export class ChatService {
|
|
|
726
798
|
this.sdk.validateParams(
|
|
727
799
|
{ id, reason },
|
|
728
800
|
{
|
|
729
|
-
id: { type:
|
|
730
|
-
reason: { type:
|
|
801
|
+
id: { type: "string", required: true },
|
|
802
|
+
reason: { type: "string", required: true },
|
|
731
803
|
},
|
|
732
804
|
);
|
|
733
|
-
return internalRequest(this.sdk, `/chat/messages/${id}/report`,
|
|
805
|
+
return internalRequest(this.sdk, `/chat/messages/${id}/report`, "POST", {
|
|
734
806
|
body: { reason },
|
|
735
807
|
});
|
|
736
808
|
}
|
|
@@ -746,8 +818,8 @@ export class ChatService {
|
|
|
746
818
|
this.sdk.validateParams(
|
|
747
819
|
{ q, kind },
|
|
748
820
|
{
|
|
749
|
-
q: { type:
|
|
750
|
-
kind: { type:
|
|
821
|
+
q: { type: "string", required: false },
|
|
822
|
+
kind: { type: "string", required: false },
|
|
751
823
|
},
|
|
752
824
|
);
|
|
753
825
|
|
|
@@ -755,7 +827,7 @@ export class ChatService {
|
|
|
755
827
|
if (q !== undefined) query.q = q;
|
|
756
828
|
if (kind !== undefined) query.kind = kind;
|
|
757
829
|
|
|
758
|
-
return internalRequest(this.sdk,
|
|
830
|
+
return internalRequest(this.sdk, "/chat/admin/channels", "GET", { query });
|
|
759
831
|
}
|
|
760
832
|
|
|
761
833
|
/**
|
|
@@ -764,8 +836,8 @@ export class ChatService {
|
|
|
764
836
|
* @returns {Promise<Object>}
|
|
765
837
|
*/
|
|
766
838
|
async adminGetChannel(id) {
|
|
767
|
-
this.sdk.validateParams({ id }, { id: { type:
|
|
768
|
-
return internalRequest(this.sdk, `/chat/admin/channels/${id}`,
|
|
839
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
840
|
+
return internalRequest(this.sdk, `/chat/admin/channels/${id}`, "GET");
|
|
769
841
|
}
|
|
770
842
|
|
|
771
843
|
/**
|
|
@@ -774,8 +846,12 @@ export class ChatService {
|
|
|
774
846
|
* @returns {Promise<Object>}
|
|
775
847
|
*/
|
|
776
848
|
async adminExportChannel(id) {
|
|
777
|
-
this.sdk.validateParams({ id }, { id: { type:
|
|
778
|
-
return internalRequest(
|
|
849
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
850
|
+
return internalRequest(
|
|
851
|
+
this.sdk,
|
|
852
|
+
`/chat/admin/channels/${id}/export`,
|
|
853
|
+
"GET",
|
|
854
|
+
);
|
|
779
855
|
}
|
|
780
856
|
|
|
781
857
|
/**
|
|
@@ -787,13 +863,13 @@ export class ChatService {
|
|
|
787
863
|
async adminListReports({ status } = {}) {
|
|
788
864
|
this.sdk.validateParams(
|
|
789
865
|
{ status },
|
|
790
|
-
{ status: { type:
|
|
866
|
+
{ status: { type: "string", required: false } },
|
|
791
867
|
);
|
|
792
868
|
|
|
793
869
|
const query = {};
|
|
794
870
|
if (status !== undefined) query.status = status;
|
|
795
871
|
|
|
796
|
-
return internalRequest(this.sdk,
|
|
872
|
+
return internalRequest(this.sdk, "/chat/admin/reports", "GET", { query });
|
|
797
873
|
}
|
|
798
874
|
|
|
799
875
|
/**
|
|
@@ -807,11 +883,11 @@ export class ChatService {
|
|
|
807
883
|
this.sdk.validateParams(
|
|
808
884
|
{ id, status },
|
|
809
885
|
{
|
|
810
|
-
id: { type:
|
|
811
|
-
status: { type:
|
|
886
|
+
id: { type: "string", required: true },
|
|
887
|
+
status: { type: "string", required: true },
|
|
812
888
|
},
|
|
813
889
|
);
|
|
814
|
-
return internalRequest(this.sdk, `/chat/admin/reports/${id}`,
|
|
890
|
+
return internalRequest(this.sdk, `/chat/admin/reports/${id}`, "POST", {
|
|
815
891
|
body: { status },
|
|
816
892
|
});
|
|
817
893
|
}
|
|
@@ -819,11 +895,23 @@ export class ChatService {
|
|
|
819
895
|
/**
|
|
820
896
|
* Admin: delete a message (moderation).
|
|
821
897
|
* @param {string} id
|
|
898
|
+
* @param {Object} [params]
|
|
899
|
+
* @param {string} [params.reason]
|
|
822
900
|
* @returns {Promise<Object>}
|
|
823
901
|
*/
|
|
824
|
-
async adminDeleteMessage(id) {
|
|
825
|
-
this.sdk.validateParams(
|
|
826
|
-
|
|
902
|
+
async adminDeleteMessage(id, { reason } = {}) {
|
|
903
|
+
this.sdk.validateParams(
|
|
904
|
+
{ id, reason },
|
|
905
|
+
{
|
|
906
|
+
id: { type: "string", required: true },
|
|
907
|
+
reason: { type: "string", required: false },
|
|
908
|
+
},
|
|
909
|
+
);
|
|
910
|
+
const query = {};
|
|
911
|
+
if (reason !== undefined) query.reason = reason;
|
|
912
|
+
return internalRequest(this.sdk, `/chat/admin/messages/${id}`, "DELETE", {
|
|
913
|
+
query,
|
|
914
|
+
});
|
|
827
915
|
}
|
|
828
916
|
|
|
829
917
|
/**
|
|
@@ -831,7 +919,325 @@ export class ChatService {
|
|
|
831
919
|
* @returns {Promise<Object>}
|
|
832
920
|
*/
|
|
833
921
|
async adminAudit() {
|
|
834
|
-
return internalRequest(this.sdk,
|
|
922
|
+
return internalRequest(this.sdk, "/chat/admin/audit", "GET");
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* Admin: full-account message search (no membership ACL).
|
|
927
|
+
* @param {Object} [params]
|
|
928
|
+
* @param {string} [params.q] Boolean-mode fulltext; quoted phrases pass through
|
|
929
|
+
* @param {string[]} [params.userIds]
|
|
930
|
+
* @param {string[]} [params.channelIds] Empty/omitted = all channels
|
|
931
|
+
* @param {string[]} [params.kinds]
|
|
932
|
+
* @param {string} [params.from] ISO date/datetime
|
|
933
|
+
* @param {string} [params.to] ISO date/datetime
|
|
934
|
+
* @param {boolean} [params.includeDeleted] Default true server-side
|
|
935
|
+
* @param {string} [params.nextId] Pagination cursor (message id)
|
|
936
|
+
* @param {number} [params.limit]
|
|
937
|
+
* @returns {Promise<Object>} `{results: [{message, channel}], nextId}`
|
|
938
|
+
*/
|
|
939
|
+
async adminSearch({
|
|
940
|
+
q,
|
|
941
|
+
userIds,
|
|
942
|
+
channelIds,
|
|
943
|
+
kinds,
|
|
944
|
+
from,
|
|
945
|
+
to,
|
|
946
|
+
includeDeleted,
|
|
947
|
+
nextId,
|
|
948
|
+
limit,
|
|
949
|
+
} = {}) {
|
|
950
|
+
this.sdk.validateParams(
|
|
951
|
+
{
|
|
952
|
+
q,
|
|
953
|
+
userIds,
|
|
954
|
+
channelIds,
|
|
955
|
+
kinds,
|
|
956
|
+
from,
|
|
957
|
+
to,
|
|
958
|
+
includeDeleted,
|
|
959
|
+
nextId,
|
|
960
|
+
limit,
|
|
961
|
+
},
|
|
962
|
+
{
|
|
963
|
+
q: { type: "string", required: false },
|
|
964
|
+
userIds: { type: "array", required: false },
|
|
965
|
+
channelIds: { type: "array", required: false },
|
|
966
|
+
kinds: { type: "array", required: false },
|
|
967
|
+
from: { type: "string", required: false },
|
|
968
|
+
to: { type: "string", required: false },
|
|
969
|
+
includeDeleted: { type: "boolean", required: false },
|
|
970
|
+
nextId: { type: "string", required: false },
|
|
971
|
+
limit: { type: "number", required: false },
|
|
972
|
+
},
|
|
973
|
+
);
|
|
974
|
+
|
|
975
|
+
// Array params use bracket notation (`userIds[]=a&userIds[]=b`) so the
|
|
976
|
+
// API's qs parser always yields an array, even for a single value.
|
|
977
|
+
const query = [];
|
|
978
|
+
if (q !== undefined) query.push(["q", q]);
|
|
979
|
+
for (const v of userIds || []) query.push(["userIds[]", v]);
|
|
980
|
+
for (const v of channelIds || []) query.push(["channelIds[]", v]);
|
|
981
|
+
for (const v of kinds || []) query.push(["kinds[]", v]);
|
|
982
|
+
if (from !== undefined) query.push(["from", from]);
|
|
983
|
+
if (to !== undefined) query.push(["to", to]);
|
|
984
|
+
if (includeDeleted !== undefined) {
|
|
985
|
+
query.push(["includeDeleted", includeDeleted ? "1" : "0"]);
|
|
986
|
+
}
|
|
987
|
+
if (nextId !== undefined) query.push(["nextId", nextId]);
|
|
988
|
+
if (limit !== undefined) query.push(["limit", String(limit)]);
|
|
989
|
+
|
|
990
|
+
return internalRequest(this.sdk, "/chat/admin/search", "GET", { query });
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
/**
|
|
994
|
+
* Admin: get a message (any channel) with its channel and pre-edit original.
|
|
995
|
+
* @param {string} id
|
|
996
|
+
* @returns {Promise<Object>} `{message, channel, original}`
|
|
997
|
+
*/
|
|
998
|
+
async adminGetMessage(id) {
|
|
999
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
1000
|
+
return internalRequest(this.sdk, `/chat/admin/messages/${id}`, "GET");
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
/**
|
|
1004
|
+
* Admin: free-form edit of a message; reason required, no edit window.
|
|
1005
|
+
* @param {string} id
|
|
1006
|
+
* @param {Object} params
|
|
1007
|
+
* @param {Object} params.message Message doc
|
|
1008
|
+
* @param {string} params.reason
|
|
1009
|
+
* @returns {Promise<Object>} Updated message
|
|
1010
|
+
*/
|
|
1011
|
+
async adminEditMessage(id, { message, reason } = {}) {
|
|
1012
|
+
this.sdk.validateParams(
|
|
1013
|
+
{ id, message, reason },
|
|
1014
|
+
{
|
|
1015
|
+
id: { type: "string", required: true },
|
|
1016
|
+
message: { type: "object", required: true },
|
|
1017
|
+
reason: { type: "string", required: true },
|
|
1018
|
+
},
|
|
1019
|
+
);
|
|
1020
|
+
return internalRequest(this.sdk, `/chat/admin/messages/${id}`, "PATCH", {
|
|
1021
|
+
body: { message, reason },
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
/**
|
|
1026
|
+
* Admin: get a message report with its message and channel.
|
|
1027
|
+
* @param {string} id
|
|
1028
|
+
* @returns {Promise<Object>}
|
|
1029
|
+
*/
|
|
1030
|
+
async adminGetReport(id) {
|
|
1031
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
1032
|
+
return internalRequest(this.sdk, `/chat/admin/reports/${id}`, "GET");
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* Admin: list audit events.
|
|
1037
|
+
* @param {Object} [params]
|
|
1038
|
+
* @param {string} [params.type]
|
|
1039
|
+
* @param {string} [params.actorId]
|
|
1040
|
+
* @param {string} [params.channelId]
|
|
1041
|
+
* @param {string} [params.from]
|
|
1042
|
+
* @param {string} [params.to]
|
|
1043
|
+
* @param {string} [params.nextId]
|
|
1044
|
+
* @param {number} [params.limit]
|
|
1045
|
+
* @returns {Promise<Object>} `{results, nextId}`
|
|
1046
|
+
*/
|
|
1047
|
+
async adminListAudit({
|
|
1048
|
+
type,
|
|
1049
|
+
actorId,
|
|
1050
|
+
channelId,
|
|
1051
|
+
from,
|
|
1052
|
+
to,
|
|
1053
|
+
nextId,
|
|
1054
|
+
limit,
|
|
1055
|
+
} = {}) {
|
|
1056
|
+
this.sdk.validateParams(
|
|
1057
|
+
{ type, actorId, channelId, from, to, nextId, limit },
|
|
1058
|
+
{
|
|
1059
|
+
type: { type: "string", required: false },
|
|
1060
|
+
actorId: { type: "string", required: false },
|
|
1061
|
+
channelId: { type: "string", required: false },
|
|
1062
|
+
from: { type: "string", required: false },
|
|
1063
|
+
to: { type: "string", required: false },
|
|
1064
|
+
nextId: { type: "string", required: false },
|
|
1065
|
+
limit: { type: "number", required: false },
|
|
1066
|
+
},
|
|
1067
|
+
);
|
|
1068
|
+
|
|
1069
|
+
const query = {};
|
|
1070
|
+
if (type !== undefined) query.type = type;
|
|
1071
|
+
if (actorId !== undefined) query.actorId = actorId;
|
|
1072
|
+
if (channelId !== undefined) query.channelId = channelId;
|
|
1073
|
+
if (from !== undefined) query.from = from;
|
|
1074
|
+
if (to !== undefined) query.to = to;
|
|
1075
|
+
if (nextId !== undefined) query.nextId = nextId;
|
|
1076
|
+
if (limit !== undefined) query.limit = limit;
|
|
1077
|
+
|
|
1078
|
+
return internalRequest(this.sdk, "/chat/admin/audit", "GET", { query });
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
/**
|
|
1082
|
+
* Admin: list per-group default channels.
|
|
1083
|
+
* @returns {Promise<Object>} `{results: [{group, channels}]}`
|
|
1084
|
+
*/
|
|
1085
|
+
async adminListDefaults() {
|
|
1086
|
+
return internalRequest(this.sdk, "/chat/admin/defaults", "GET");
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
/**
|
|
1090
|
+
* Admin: list all webhooks across channels.
|
|
1091
|
+
* @returns {Promise<Object>} `{results}`
|
|
1092
|
+
*/
|
|
1093
|
+
async adminListWebhooks() {
|
|
1094
|
+
return internalRequest(this.sdk, "/chat/admin/webhooks", "GET");
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* Admin: list retention policies (account default + per-kind overrides).
|
|
1099
|
+
* @returns {Promise<Object>} `{results}`
|
|
1100
|
+
*/
|
|
1101
|
+
async adminGetRetention() {
|
|
1102
|
+
return internalRequest(this.sdk, "/chat/admin/retention", "GET");
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
/**
|
|
1106
|
+
* Admin: upsert retention policies.
|
|
1107
|
+
* @param {Object[]} policies
|
|
1108
|
+
* @param {'account'|'kind'} policies[].scope
|
|
1109
|
+
* @param {string} [policies[].kind]
|
|
1110
|
+
* @param {number|null} [policies[].purgeDeletedAfterDays]
|
|
1111
|
+
* @param {boolean} [policies[].enabled]
|
|
1112
|
+
* @returns {Promise<Object>} `{results}`
|
|
1113
|
+
*/
|
|
1114
|
+
async adminPutRetention(policies) {
|
|
1115
|
+
this.sdk.validateParams(
|
|
1116
|
+
{ policies },
|
|
1117
|
+
{ policies: { type: "array", required: true } },
|
|
1118
|
+
);
|
|
1119
|
+
return internalRequest(this.sdk, "/chat/admin/retention", "PUT", {
|
|
1120
|
+
body: { policies },
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
/**
|
|
1125
|
+
* Admin: preview counts that would purge now, per retention policy.
|
|
1126
|
+
* @returns {Promise<Object>} `{results, heldSearchCount, heldMessageCount}`
|
|
1127
|
+
* `heldSearchCount` is the number of saved searches currently on legal
|
|
1128
|
+
* hold; `heldMessageCount` is how many otherwise-purgeable messages are
|
|
1129
|
+
* protected by those holds (across all policies).
|
|
1130
|
+
*/
|
|
1131
|
+
async adminRetentionPreview() {
|
|
1132
|
+
return internalRequest(this.sdk, "/chat/admin/retention/preview", "GET");
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
/**
|
|
1136
|
+
* Admin: set or release legal hold on a channel.
|
|
1137
|
+
* @param {string} id
|
|
1138
|
+
* @param {Object} params
|
|
1139
|
+
* @param {boolean} params.hold
|
|
1140
|
+
* @returns {Promise<Object>} Updated channel
|
|
1141
|
+
*/
|
|
1142
|
+
async adminSetLegalHold(id, { hold } = {}) {
|
|
1143
|
+
this.sdk.validateParams(
|
|
1144
|
+
{ id, hold },
|
|
1145
|
+
{
|
|
1146
|
+
id: { type: "string", required: true },
|
|
1147
|
+
hold: { type: "boolean", required: true },
|
|
1148
|
+
},
|
|
1149
|
+
);
|
|
1150
|
+
return internalRequest(
|
|
1151
|
+
this.sdk,
|
|
1152
|
+
`/chat/admin/channels/${id}/legal-hold`,
|
|
1153
|
+
"POST",
|
|
1154
|
+
{ body: { hold } },
|
|
1155
|
+
);
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
/**
|
|
1159
|
+
* Admin: list saved searches (own + shared with chat:admin:review).
|
|
1160
|
+
* @returns {Promise<Object>} `{results}`
|
|
1161
|
+
*/
|
|
1162
|
+
async adminListSavedSearches() {
|
|
1163
|
+
return internalRequest(this.sdk, "/chat/admin/saved-searches", "GET");
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
/**
|
|
1167
|
+
* Admin: create a saved search.
|
|
1168
|
+
* @param {Object} params
|
|
1169
|
+
* @param {string} params.name
|
|
1170
|
+
* @param {Object} params.criteria Search criteria (same shape as adminSearch params)
|
|
1171
|
+
* @param {boolean} [params.shared] Shared with everyone holding chat:admin:review
|
|
1172
|
+
* @param {Object} [params.hold] Legal hold — `{enabled, reason}`. `reason` is
|
|
1173
|
+
* required (max 500 chars) when `enabled` is true. Freezes every message
|
|
1174
|
+
* matching `criteria` against retention purge until released.
|
|
1175
|
+
* @returns {Promise<Object>} `{id}`
|
|
1176
|
+
*/
|
|
1177
|
+
async adminCreateSavedSearch({ name, criteria, shared, hold } = {}) {
|
|
1178
|
+
this.sdk.validateParams(
|
|
1179
|
+
{ name, criteria, shared, hold },
|
|
1180
|
+
{
|
|
1181
|
+
name: { type: "string", required: true },
|
|
1182
|
+
criteria: { type: "object", required: true },
|
|
1183
|
+
shared: { type: "boolean", required: false },
|
|
1184
|
+
hold: { type: "object", required: false },
|
|
1185
|
+
},
|
|
1186
|
+
);
|
|
1187
|
+
const body = { name, criteria };
|
|
1188
|
+
if (shared !== undefined) body.shared = shared;
|
|
1189
|
+
if (hold !== undefined) body.hold = hold;
|
|
1190
|
+
return internalRequest(this.sdk, "/chat/admin/saved-searches", "POST", {
|
|
1191
|
+
body,
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
/**
|
|
1196
|
+
* Admin: update a saved search (owner only).
|
|
1197
|
+
* @param {string} id
|
|
1198
|
+
* @param {Object} [patch]
|
|
1199
|
+
* @param {string} [patch.name]
|
|
1200
|
+
* @param {Object} [patch.criteria]
|
|
1201
|
+
* @param {boolean} [patch.shared]
|
|
1202
|
+
* @param {Object} [patch.hold] `{enabled, reason}` — set `enabled: false`
|
|
1203
|
+
* to release an active hold; `reason` required when enabling.
|
|
1204
|
+
* @returns {Promise<Object>} Updated saved search — includes
|
|
1205
|
+
* `hold: {enabled, reason, by, at} | null`
|
|
1206
|
+
*/
|
|
1207
|
+
async adminUpdateSavedSearch(id, { name, criteria, shared, hold } = {}) {
|
|
1208
|
+
this.sdk.validateParams(
|
|
1209
|
+
{ id, hold },
|
|
1210
|
+
{
|
|
1211
|
+
id: { type: "string", required: true },
|
|
1212
|
+
hold: { type: "object", required: false },
|
|
1213
|
+
},
|
|
1214
|
+
);
|
|
1215
|
+
const body = {};
|
|
1216
|
+
if (name !== undefined) body.name = name;
|
|
1217
|
+
if (criteria !== undefined) body.criteria = criteria;
|
|
1218
|
+
if (shared !== undefined) body.shared = shared;
|
|
1219
|
+
if (hold !== undefined) body.hold = hold;
|
|
1220
|
+
return internalRequest(
|
|
1221
|
+
this.sdk,
|
|
1222
|
+
`/chat/admin/saved-searches/${id}`,
|
|
1223
|
+
"PATCH",
|
|
1224
|
+
{ body },
|
|
1225
|
+
);
|
|
1226
|
+
}
|
|
1227
|
+
|
|
1228
|
+
/**
|
|
1229
|
+
* Admin: delete a saved search (owner only). Refused (400) while the
|
|
1230
|
+
* saved search has an active legal hold — release it first.
|
|
1231
|
+
* @param {string} id
|
|
1232
|
+
* @returns {Promise<Object>} `{id}`
|
|
1233
|
+
*/
|
|
1234
|
+
async adminDeleteSavedSearch(id) {
|
|
1235
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
1236
|
+
return internalRequest(
|
|
1237
|
+
this.sdk,
|
|
1238
|
+
`/chat/admin/saved-searches/${id}`,
|
|
1239
|
+
"DELETE",
|
|
1240
|
+
);
|
|
835
1241
|
}
|
|
836
1242
|
|
|
837
1243
|
/**
|
|
@@ -845,11 +1251,11 @@ export class ChatService {
|
|
|
845
1251
|
this.sdk.validateParams(
|
|
846
1252
|
{ relatedId, recordTypeId },
|
|
847
1253
|
{
|
|
848
|
-
relatedId: { type:
|
|
849
|
-
recordTypeId: { type:
|
|
1254
|
+
relatedId: { type: "string", required: true },
|
|
1255
|
+
recordTypeId: { type: "string", required: true },
|
|
850
1256
|
},
|
|
851
1257
|
);
|
|
852
|
-
return internalRequest(this.sdk, `/chat/records/${relatedId}`,
|
|
1258
|
+
return internalRequest(this.sdk, `/chat/records/${relatedId}`, "GET", {
|
|
853
1259
|
query: { recordTypeId },
|
|
854
1260
|
});
|
|
855
1261
|
}
|
|
@@ -866,14 +1272,19 @@ export class ChatService {
|
|
|
866
1272
|
this.sdk.validateParams(
|
|
867
1273
|
{ relatedId, message, recordTypeId },
|
|
868
1274
|
{
|
|
869
|
-
relatedId: { type:
|
|
870
|
-
message: { type:
|
|
871
|
-
recordTypeId: { type:
|
|
1275
|
+
relatedId: { type: "string", required: true },
|
|
1276
|
+
message: { type: "object", required: true },
|
|
1277
|
+
recordTypeId: { type: "string", required: true },
|
|
1278
|
+
},
|
|
1279
|
+
);
|
|
1280
|
+
return internalRequest(
|
|
1281
|
+
this.sdk,
|
|
1282
|
+
`/chat/records/${relatedId}/messages`,
|
|
1283
|
+
"POST",
|
|
1284
|
+
{
|
|
1285
|
+
body: { message, recordTypeId },
|
|
872
1286
|
},
|
|
873
1287
|
);
|
|
874
|
-
return internalRequest(this.sdk, `/chat/records/${relatedId}/messages`, 'POST', {
|
|
875
|
-
body: { message, recordTypeId },
|
|
876
|
-
});
|
|
877
1288
|
}
|
|
878
1289
|
|
|
879
1290
|
/**
|
|
@@ -884,9 +1295,9 @@ export class ChatService {
|
|
|
884
1295
|
async getChannelMeet(channelId) {
|
|
885
1296
|
this.sdk.validateParams(
|
|
886
1297
|
{ channelId },
|
|
887
|
-
{ channelId: { type:
|
|
1298
|
+
{ channelId: { type: "string", required: true } },
|
|
888
1299
|
);
|
|
889
|
-
return internalRequest(this.sdk, `/chat/channels/${channelId}/meet`,
|
|
1300
|
+
return internalRequest(this.sdk, `/chat/channels/${channelId}/meet`, "GET");
|
|
890
1301
|
}
|
|
891
1302
|
|
|
892
1303
|
/**
|
|
@@ -894,7 +1305,7 @@ export class ChatService {
|
|
|
894
1305
|
* @returns {Promise<Object>}
|
|
895
1306
|
*/
|
|
896
1307
|
async getVapidPublicKey() {
|
|
897
|
-
return internalRequest(this.sdk,
|
|
1308
|
+
return internalRequest(this.sdk, "/chat/push/vapidPublicKey", "GET");
|
|
898
1309
|
}
|
|
899
1310
|
|
|
900
1311
|
/**
|
|
@@ -908,11 +1319,11 @@ export class ChatService {
|
|
|
908
1319
|
this.sdk.validateParams(
|
|
909
1320
|
{ kind, subscription },
|
|
910
1321
|
{
|
|
911
|
-
kind: { type:
|
|
912
|
-
subscription: { type:
|
|
1322
|
+
kind: { type: "string", required: true },
|
|
1323
|
+
subscription: { type: "object", required: true },
|
|
913
1324
|
},
|
|
914
1325
|
);
|
|
915
|
-
return internalRequest(this.sdk,
|
|
1326
|
+
return internalRequest(this.sdk, "/chat/push/devices", "POST", {
|
|
916
1327
|
body: { kind, subscription },
|
|
917
1328
|
});
|
|
918
1329
|
}
|
|
@@ -923,8 +1334,8 @@ export class ChatService {
|
|
|
923
1334
|
* @returns {Promise<Object>}
|
|
924
1335
|
*/
|
|
925
1336
|
async unregisterPushDevice(id) {
|
|
926
|
-
this.sdk.validateParams({ id }, { id: { type:
|
|
927
|
-
return internalRequest(this.sdk, `/chat/push/devices/${id}`,
|
|
1337
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
1338
|
+
return internalRequest(this.sdk, `/chat/push/devices/${id}`, "DELETE");
|
|
928
1339
|
}
|
|
929
1340
|
|
|
930
1341
|
/**
|
|
@@ -938,13 +1349,18 @@ export class ChatService {
|
|
|
938
1349
|
this.sdk.validateParams(
|
|
939
1350
|
{ channelId, notifyLevel },
|
|
940
1351
|
{
|
|
941
|
-
channelId: { type:
|
|
942
|
-
notifyLevel: { type:
|
|
1352
|
+
channelId: { type: "string", required: true },
|
|
1353
|
+
notifyLevel: { type: "string", required: true },
|
|
1354
|
+
},
|
|
1355
|
+
);
|
|
1356
|
+
return internalRequest(
|
|
1357
|
+
this.sdk,
|
|
1358
|
+
`/chat/channels/${channelId}/notify`,
|
|
1359
|
+
"PATCH",
|
|
1360
|
+
{
|
|
1361
|
+
body: { notifyLevel },
|
|
943
1362
|
},
|
|
944
1363
|
);
|
|
945
|
-
return internalRequest(this.sdk, `/chat/channels/${channelId}/notify`, 'PATCH', {
|
|
946
|
-
body: { notifyLevel },
|
|
947
|
-
});
|
|
948
1364
|
}
|
|
949
1365
|
|
|
950
1366
|
/**
|
|
@@ -952,7 +1368,7 @@ export class ChatService {
|
|
|
952
1368
|
* @returns {Promise<Object>}
|
|
953
1369
|
*/
|
|
954
1370
|
async listPins() {
|
|
955
|
-
return internalRequest(this.sdk,
|
|
1371
|
+
return internalRequest(this.sdk, "/chat/pins", "GET");
|
|
956
1372
|
}
|
|
957
1373
|
|
|
958
1374
|
/**
|
|
@@ -968,18 +1384,18 @@ export class ChatService {
|
|
|
968
1384
|
this.sdk.validateParams(
|
|
969
1385
|
{ kind, channelId, relatedId, relatedRecordTypeId },
|
|
970
1386
|
{
|
|
971
|
-
kind: { type:
|
|
972
|
-
channelId: { type:
|
|
973
|
-
relatedId: { type:
|
|
974
|
-
relatedRecordTypeId: { type:
|
|
1387
|
+
kind: { type: "string", required: true },
|
|
1388
|
+
channelId: { type: "string", required: false },
|
|
1389
|
+
relatedId: { type: "string", required: false },
|
|
1390
|
+
relatedRecordTypeId: { type: "string", required: false },
|
|
975
1391
|
},
|
|
976
1392
|
);
|
|
977
1393
|
const body = { kind };
|
|
978
1394
|
if (channelId !== undefined) body.channelId = channelId;
|
|
979
1395
|
if (relatedId !== undefined) body.relatedId = relatedId;
|
|
980
|
-
if (relatedRecordTypeId !== undefined)
|
|
981
|
-
relatedRecordTypeId;
|
|
982
|
-
return internalRequest(this.sdk,
|
|
1396
|
+
if (relatedRecordTypeId !== undefined)
|
|
1397
|
+
body.relatedRecordTypeId = relatedRecordTypeId;
|
|
1398
|
+
return internalRequest(this.sdk, "/chat/pins", "POST", { body });
|
|
983
1399
|
}
|
|
984
1400
|
|
|
985
1401
|
/**
|
|
@@ -988,8 +1404,8 @@ export class ChatService {
|
|
|
988
1404
|
* @returns {Promise<Object>}
|
|
989
1405
|
*/
|
|
990
1406
|
async unpinItem(id) {
|
|
991
|
-
this.sdk.validateParams({ id }, { id: { type:
|
|
992
|
-
return internalRequest(this.sdk, `/chat/pins/${id}`,
|
|
1407
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
1408
|
+
return internalRequest(this.sdk, `/chat/pins/${id}`, "DELETE");
|
|
993
1409
|
}
|
|
994
1410
|
|
|
995
1411
|
/**
|
|
@@ -1003,14 +1419,14 @@ export class ChatService {
|
|
|
1003
1419
|
this.sdk.validateParams(
|
|
1004
1420
|
{ channelId, messageId },
|
|
1005
1421
|
{
|
|
1006
|
-
channelId: { type:
|
|
1007
|
-
messageId: { type:
|
|
1422
|
+
channelId: { type: "string", required: true },
|
|
1423
|
+
messageId: { type: "string", required: true },
|
|
1008
1424
|
},
|
|
1009
1425
|
);
|
|
1010
1426
|
return internalRequest(
|
|
1011
1427
|
this.sdk,
|
|
1012
1428
|
`/chat/channels/${channelId}/pinned-message`,
|
|
1013
|
-
|
|
1429
|
+
"PUT",
|
|
1014
1430
|
{ body: { messageId } },
|
|
1015
1431
|
);
|
|
1016
1432
|
}
|
|
@@ -1023,12 +1439,12 @@ export class ChatService {
|
|
|
1023
1439
|
async unpinMessage(channelId) {
|
|
1024
1440
|
this.sdk.validateParams(
|
|
1025
1441
|
{ channelId },
|
|
1026
|
-
{ channelId: { type:
|
|
1442
|
+
{ channelId: { type: "string", required: true } },
|
|
1027
1443
|
);
|
|
1028
1444
|
return internalRequest(
|
|
1029
1445
|
this.sdk,
|
|
1030
1446
|
`/chat/channels/${channelId}/pinned-message`,
|
|
1031
|
-
|
|
1447
|
+
"DELETE",
|
|
1032
1448
|
);
|
|
1033
1449
|
}
|
|
1034
1450
|
|
|
@@ -1043,7 +1459,7 @@ export class ChatService {
|
|
|
1043
1459
|
const query = {};
|
|
1044
1460
|
if (kind) query.kind = kind;
|
|
1045
1461
|
if (limit != null) query.limit = limit;
|
|
1046
|
-
return internalRequest(this.sdk,
|
|
1462
|
+
return internalRequest(this.sdk, "/chat/mentions", "GET", { query });
|
|
1047
1463
|
}
|
|
1048
1464
|
|
|
1049
1465
|
/**
|
|
@@ -1057,7 +1473,7 @@ export class ChatService {
|
|
|
1057
1473
|
const query = {};
|
|
1058
1474
|
if (kind) query.kind = kind;
|
|
1059
1475
|
if (limit != null) query.limit = limit;
|
|
1060
|
-
return internalRequest(this.sdk,
|
|
1476
|
+
return internalRequest(this.sdk, "/chat/threads", "GET", { query });
|
|
1061
1477
|
}
|
|
1062
1478
|
|
|
1063
1479
|
/**
|
|
@@ -1068,12 +1484,12 @@ export class ChatService {
|
|
|
1068
1484
|
async getGroupDefaultChannels(groupId) {
|
|
1069
1485
|
this.sdk.validateParams(
|
|
1070
1486
|
{ groupId },
|
|
1071
|
-
{ groupId: { type:
|
|
1487
|
+
{ groupId: { type: "string", required: true } },
|
|
1072
1488
|
);
|
|
1073
1489
|
return internalRequest(
|
|
1074
1490
|
this.sdk,
|
|
1075
1491
|
`/chat/groups/${groupId}/default-channels`,
|
|
1076
|
-
|
|
1492
|
+
"GET",
|
|
1077
1493
|
);
|
|
1078
1494
|
}
|
|
1079
1495
|
|
|
@@ -1088,14 +1504,14 @@ export class ChatService {
|
|
|
1088
1504
|
this.sdk.validateParams(
|
|
1089
1505
|
{ groupId, channelIds },
|
|
1090
1506
|
{
|
|
1091
|
-
groupId: { type:
|
|
1092
|
-
channelIds: { type:
|
|
1507
|
+
groupId: { type: "string", required: true },
|
|
1508
|
+
channelIds: { type: "array", required: false },
|
|
1093
1509
|
},
|
|
1094
1510
|
);
|
|
1095
1511
|
return internalRequest(
|
|
1096
1512
|
this.sdk,
|
|
1097
1513
|
`/chat/groups/${groupId}/default-channels`,
|
|
1098
|
-
|
|
1514
|
+
"PUT",
|
|
1099
1515
|
{ body: { channelIds } },
|
|
1100
1516
|
);
|
|
1101
1517
|
}
|
|
@@ -1108,12 +1524,12 @@ export class ChatService {
|
|
|
1108
1524
|
async createChannelMeet(channelId) {
|
|
1109
1525
|
this.sdk.validateParams(
|
|
1110
1526
|
{ channelId },
|
|
1111
|
-
{ channelId: { type:
|
|
1527
|
+
{ channelId: { type: "string", required: true } },
|
|
1112
1528
|
);
|
|
1113
1529
|
return internalRequest(
|
|
1114
1530
|
this.sdk,
|
|
1115
1531
|
`/chat/channels/${channelId}/meet`,
|
|
1116
|
-
|
|
1532
|
+
"POST",
|
|
1117
1533
|
{ body: {} },
|
|
1118
1534
|
);
|
|
1119
1535
|
}
|
|
@@ -1133,23 +1549,23 @@ export class ChatService {
|
|
|
1133
1549
|
async updateChannelMeet(channelId, patch = {}) {
|
|
1134
1550
|
this.sdk.validateParams(
|
|
1135
1551
|
{ channelId },
|
|
1136
|
-
{ channelId: { type:
|
|
1552
|
+
{ channelId: { type: "string", required: true } },
|
|
1137
1553
|
);
|
|
1138
1554
|
const body = {};
|
|
1139
1555
|
for (const key of [
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1556
|
+
"slug",
|
|
1557
|
+
"password",
|
|
1558
|
+
"guestsCanStart",
|
|
1559
|
+
"startRecordingOn",
|
|
1560
|
+
"startTranscribingOn",
|
|
1561
|
+
"endMeetingWithoutHostTimeLimit",
|
|
1146
1562
|
]) {
|
|
1147
1563
|
if (patch[key] !== undefined) body[key] = patch[key];
|
|
1148
1564
|
}
|
|
1149
1565
|
return internalRequest(
|
|
1150
1566
|
this.sdk,
|
|
1151
1567
|
`/chat/channels/${channelId}/meet`,
|
|
1152
|
-
|
|
1568
|
+
"PATCH",
|
|
1153
1569
|
{ body },
|
|
1154
1570
|
);
|
|
1155
1571
|
}
|
|
@@ -1164,14 +1580,14 @@ export class ChatService {
|
|
|
1164
1580
|
this.sdk.validateParams(
|
|
1165
1581
|
{ channelId, slug },
|
|
1166
1582
|
{
|
|
1167
|
-
channelId: { type:
|
|
1168
|
-
slug: { type:
|
|
1583
|
+
channelId: { type: "string", required: true },
|
|
1584
|
+
slug: { type: "string", required: true },
|
|
1169
1585
|
},
|
|
1170
1586
|
);
|
|
1171
1587
|
return internalRequest(
|
|
1172
1588
|
this.sdk,
|
|
1173
1589
|
`/chat/channels/${channelId}/meet/slug-available`,
|
|
1174
|
-
|
|
1590
|
+
"GET",
|
|
1175
1591
|
{ query: { slug } },
|
|
1176
1592
|
);
|
|
1177
1593
|
}
|
|
@@ -1184,12 +1600,12 @@ export class ChatService {
|
|
|
1184
1600
|
async regenerateChannelMeetPassword(channelId) {
|
|
1185
1601
|
this.sdk.validateParams(
|
|
1186
1602
|
{ channelId },
|
|
1187
|
-
{ channelId: { type:
|
|
1603
|
+
{ channelId: { type: "string", required: true } },
|
|
1188
1604
|
);
|
|
1189
1605
|
return internalRequest(
|
|
1190
1606
|
this.sdk,
|
|
1191
1607
|
`/chat/channels/${channelId}/meet/regenerate-password`,
|
|
1192
|
-
|
|
1608
|
+
"POST",
|
|
1193
1609
|
{ body: {} },
|
|
1194
1610
|
);
|
|
1195
1611
|
}
|
|
@@ -1199,7 +1615,7 @@ export class ChatService {
|
|
|
1199
1615
|
* @returns {Promise<Object>}
|
|
1200
1616
|
*/
|
|
1201
1617
|
async listBots() {
|
|
1202
|
-
return internalRequest(this.sdk,
|
|
1618
|
+
return internalRequest(this.sdk, "/chat/bots", "GET");
|
|
1203
1619
|
}
|
|
1204
1620
|
|
|
1205
1621
|
/**
|
|
@@ -1213,11 +1629,11 @@ export class ChatService {
|
|
|
1213
1629
|
this.sdk.validateParams(
|
|
1214
1630
|
{ id, name },
|
|
1215
1631
|
{
|
|
1216
|
-
id: { type:
|
|
1217
|
-
name: { type:
|
|
1632
|
+
id: { type: "string", required: true },
|
|
1633
|
+
name: { type: "string", required: false },
|
|
1218
1634
|
},
|
|
1219
1635
|
);
|
|
1220
|
-
return internalRequest(this.sdk, `/chat/bots/${id}`,
|
|
1636
|
+
return internalRequest(this.sdk, `/chat/bots/${id}`, "PATCH", {
|
|
1221
1637
|
body: { name },
|
|
1222
1638
|
});
|
|
1223
1639
|
}
|
|
@@ -1230,12 +1646,12 @@ export class ChatService {
|
|
|
1230
1646
|
async getBotMemory(channelId) {
|
|
1231
1647
|
this.sdk.validateParams(
|
|
1232
1648
|
{ channelId },
|
|
1233
|
-
{ channelId: { type:
|
|
1649
|
+
{ channelId: { type: "string", required: true } },
|
|
1234
1650
|
);
|
|
1235
1651
|
return internalRequest(
|
|
1236
1652
|
this.sdk,
|
|
1237
1653
|
`/chat/channels/${channelId}/bot-memory`,
|
|
1238
|
-
|
|
1654
|
+
"GET",
|
|
1239
1655
|
);
|
|
1240
1656
|
}
|
|
1241
1657
|
|
|
@@ -1247,12 +1663,12 @@ export class ChatService {
|
|
|
1247
1663
|
async resetBotMemory(channelId) {
|
|
1248
1664
|
this.sdk.validateParams(
|
|
1249
1665
|
{ channelId },
|
|
1250
|
-
{ channelId: { type:
|
|
1666
|
+
{ channelId: { type: "string", required: true } },
|
|
1251
1667
|
);
|
|
1252
1668
|
return internalRequest(
|
|
1253
1669
|
this.sdk,
|
|
1254
1670
|
`/chat/channels/${channelId}/bot-memory/reset`,
|
|
1255
|
-
|
|
1671
|
+
"POST",
|
|
1256
1672
|
{ body: {} },
|
|
1257
1673
|
);
|
|
1258
1674
|
}
|
|
@@ -1265,12 +1681,12 @@ export class ChatService {
|
|
|
1265
1681
|
async compactBotMemory(channelId) {
|
|
1266
1682
|
this.sdk.validateParams(
|
|
1267
1683
|
{ channelId },
|
|
1268
|
-
{ channelId: { type:
|
|
1684
|
+
{ channelId: { type: "string", required: true } },
|
|
1269
1685
|
);
|
|
1270
1686
|
return internalRequest(
|
|
1271
1687
|
this.sdk,
|
|
1272
1688
|
`/chat/channels/${channelId}/bot-memory/compact`,
|
|
1273
|
-
|
|
1689
|
+
"POST",
|
|
1274
1690
|
{ body: {} },
|
|
1275
1691
|
);
|
|
1276
1692
|
}
|
|
@@ -1287,8 +1703,11 @@ export class ChatService {
|
|
|
1287
1703
|
return this.adminListReports(query);
|
|
1288
1704
|
}
|
|
1289
1705
|
|
|
1290
|
-
async listAdminAudit() {
|
|
1291
|
-
|
|
1706
|
+
async listAdminAudit(query) {
|
|
1707
|
+
// legacy callers passed a bare channelId string
|
|
1708
|
+
return this.adminListAudit(
|
|
1709
|
+
typeof query === "string" ? { channelId: query } : query,
|
|
1710
|
+
);
|
|
1292
1711
|
}
|
|
1293
1712
|
|
|
1294
1713
|
async listAdminMessages(channelId, query) {
|
|
@@ -1296,12 +1715,92 @@ export class ChatService {
|
|
|
1296
1715
|
}
|
|
1297
1716
|
|
|
1298
1717
|
async dismissAdminReport(id) {
|
|
1299
|
-
return this.adminReviewReport(id, { status:
|
|
1718
|
+
return this.adminReviewReport(id, { status: "dismissed" });
|
|
1300
1719
|
}
|
|
1301
1720
|
|
|
1302
1721
|
async actionAdminReport(id, body = {}) {
|
|
1303
1722
|
return this.adminReviewReport(id, {
|
|
1304
|
-
status: body.status ||
|
|
1723
|
+
status: body.status || "actioned",
|
|
1724
|
+
});
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
async getAdminReport(id) {
|
|
1728
|
+
return this.adminGetReport(id);
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
async getOriginalMessage(id) {
|
|
1732
|
+
return this.adminGetMessage(id);
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
async listAdminDefaults() {
|
|
1736
|
+
return this.adminListDefaults();
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
async listAdminWebhooks() {
|
|
1740
|
+
return this.adminListWebhooks();
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
/**
|
|
1744
|
+
* Get the chat channel that receives status updates for a source
|
|
1745
|
+
* (campaign, port, etc.). Returns `{ subscription: null }` if none.
|
|
1746
|
+
* @param {Object} params
|
|
1747
|
+
* @param {string} params.sourceType
|
|
1748
|
+
* @param {string} params.sourceId
|
|
1749
|
+
* @returns {Promise<{ subscription: Object|null }>}
|
|
1750
|
+
*/
|
|
1751
|
+
async getAlertSubscription({ sourceType, sourceId }) {
|
|
1752
|
+
this.sdk.validateParams(
|
|
1753
|
+
{ sourceType, sourceId },
|
|
1754
|
+
{
|
|
1755
|
+
sourceType: { type: "string", required: true },
|
|
1756
|
+
sourceId: { type: "string", required: true },
|
|
1757
|
+
},
|
|
1758
|
+
);
|
|
1759
|
+
return internalRequest(this.sdk, "/chat/alert-subscriptions", "GET", {
|
|
1760
|
+
query: { sourceType, sourceId },
|
|
1761
|
+
});
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
/**
|
|
1765
|
+
* Post status updates for a source to a chat channel.
|
|
1766
|
+
* Pass the caller's You channel (`openDm({ userIds: [] })`) as the default.
|
|
1767
|
+
* @param {Object} params
|
|
1768
|
+
* @param {string} params.sourceType
|
|
1769
|
+
* @param {string} params.sourceId
|
|
1770
|
+
* @param {string} params.channelId
|
|
1771
|
+
* @returns {Promise<{ subscription: Object }>}
|
|
1772
|
+
*/
|
|
1773
|
+
async setAlertSubscription({ sourceType, sourceId, channelId }) {
|
|
1774
|
+
this.sdk.validateParams(
|
|
1775
|
+
{ sourceType, sourceId, channelId },
|
|
1776
|
+
{
|
|
1777
|
+
sourceType: { type: "string", required: true },
|
|
1778
|
+
sourceId: { type: "string", required: true },
|
|
1779
|
+
channelId: { type: "string", required: true },
|
|
1780
|
+
},
|
|
1781
|
+
);
|
|
1782
|
+
return internalRequest(this.sdk, "/chat/alert-subscriptions", "PUT", {
|
|
1783
|
+
body: { sourceType, sourceId, channelId },
|
|
1784
|
+
});
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
/**
|
|
1788
|
+
* Stop posting status updates for a source.
|
|
1789
|
+
* @param {Object} params
|
|
1790
|
+
* @param {string} params.sourceType
|
|
1791
|
+
* @param {string} params.sourceId
|
|
1792
|
+
* @returns {Promise<Object>}
|
|
1793
|
+
*/
|
|
1794
|
+
async deleteAlertSubscription({ sourceType, sourceId }) {
|
|
1795
|
+
this.sdk.validateParams(
|
|
1796
|
+
{ sourceType, sourceId },
|
|
1797
|
+
{
|
|
1798
|
+
sourceType: { type: "string", required: true },
|
|
1799
|
+
sourceId: { type: "string", required: true },
|
|
1800
|
+
},
|
|
1801
|
+
);
|
|
1802
|
+
return internalRequest(this.sdk, "/chat/alert-subscriptions", "DELETE", {
|
|
1803
|
+
query: { sourceType, sourceId },
|
|
1305
1804
|
});
|
|
1306
1805
|
}
|
|
1307
1806
|
}
|