@unboundcx/sdk 4.9.0 → 4.9.3
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/package.json +1 -1
- package/schemas/layouts/SCHEMA.md +316 -36
- package/schemas/layouts/section.js +17 -0
- package/services/chat.js +776 -231
- package/services/messaging/CampaignsService.js +27 -0
- package/services/objects.js +21 -2
- package/services/phoneNumbers.js +28 -0
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,37 +768,88 @@ 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
|
/**
|
|
719
|
-
* Report a message.
|
|
791
|
+
* Report a message. Refused (403) if reporting is disabled for the
|
|
792
|
+
* account, the message is the caller's own, a system message, or
|
|
793
|
+
* already deleted.
|
|
720
794
|
* @param {string} id
|
|
721
795
|
* @param {Object} params
|
|
722
|
-
* @param {string} params.reason
|
|
796
|
+
* @param {string} [params.reason] - One of the account's reportReasons
|
|
797
|
+
* @param {string} [params.note] - Optional free-text detail (max 500 chars)
|
|
723
798
|
* @returns {Promise<Object>}
|
|
724
799
|
*/
|
|
725
|
-
async reportMessage(id, { reason } = {}) {
|
|
800
|
+
async reportMessage(id, { reason, note } = {}) {
|
|
726
801
|
this.sdk.validateParams(
|
|
727
|
-
{ id, reason },
|
|
802
|
+
{ id, reason, note },
|
|
803
|
+
{
|
|
804
|
+
id: { type: "string", required: true },
|
|
805
|
+
reason: { type: "string", required: false },
|
|
806
|
+
note: { type: "string", required: false },
|
|
807
|
+
},
|
|
808
|
+
);
|
|
809
|
+
const body = {};
|
|
810
|
+
if (reason !== undefined) body.reason = reason;
|
|
811
|
+
if (note !== undefined) body.note = note;
|
|
812
|
+
return internalRequest(this.sdk, `/chat/messages/${id}/report`, "POST", {
|
|
813
|
+
body,
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* Get chat settings relevant to the caller (e.g. whether message
|
|
819
|
+
* reporting is enabled for the account).
|
|
820
|
+
* @returns {Promise<Object>} `{allowReports, reportReasons}`
|
|
821
|
+
*/
|
|
822
|
+
async getSettings() {
|
|
823
|
+
return internalRequest(this.sdk, "/chat/settings", "GET");
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
/**
|
|
827
|
+
* Admin: get account-level chat settings.
|
|
828
|
+
* @returns {Promise<Object>} `{allowReports, reportReasons}`
|
|
829
|
+
*/
|
|
830
|
+
async adminGetSettings() {
|
|
831
|
+
return internalRequest(this.sdk, "/chat/admin/settings", "GET");
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* Admin: update account-level chat settings.
|
|
836
|
+
* @param {Object} params
|
|
837
|
+
* @param {boolean} params.allowReports
|
|
838
|
+
* @param {string[]} [params.reportReasons]
|
|
839
|
+
* @returns {Promise<Object>} `{allowReports, reportReasons}`
|
|
840
|
+
*/
|
|
841
|
+
async adminPutSettings({ allowReports, reportReasons } = {}) {
|
|
842
|
+
this.sdk.validateParams(
|
|
843
|
+
{ allowReports, reportReasons },
|
|
728
844
|
{
|
|
729
|
-
|
|
730
|
-
|
|
845
|
+
allowReports: { type: "boolean", required: true },
|
|
846
|
+
reportReasons: { type: "array", required: false },
|
|
731
847
|
},
|
|
732
848
|
);
|
|
733
|
-
|
|
734
|
-
|
|
849
|
+
const body = { allowReports };
|
|
850
|
+
if (reportReasons !== undefined) body.reportReasons = reportReasons;
|
|
851
|
+
return internalRequest(this.sdk, "/chat/admin/settings", "PUT", {
|
|
852
|
+
body,
|
|
735
853
|
});
|
|
736
854
|
}
|
|
737
855
|
|
|
@@ -746,8 +864,8 @@ export class ChatService {
|
|
|
746
864
|
this.sdk.validateParams(
|
|
747
865
|
{ q, kind },
|
|
748
866
|
{
|
|
749
|
-
q: { type:
|
|
750
|
-
kind: { type:
|
|
867
|
+
q: { type: "string", required: false },
|
|
868
|
+
kind: { type: "string", required: false },
|
|
751
869
|
},
|
|
752
870
|
);
|
|
753
871
|
|
|
@@ -755,7 +873,7 @@ export class ChatService {
|
|
|
755
873
|
if (q !== undefined) query.q = q;
|
|
756
874
|
if (kind !== undefined) query.kind = kind;
|
|
757
875
|
|
|
758
|
-
return internalRequest(this.sdk,
|
|
876
|
+
return internalRequest(this.sdk, "/chat/admin/channels", "GET", { query });
|
|
759
877
|
}
|
|
760
878
|
|
|
761
879
|
/**
|
|
@@ -764,8 +882,8 @@ export class ChatService {
|
|
|
764
882
|
* @returns {Promise<Object>}
|
|
765
883
|
*/
|
|
766
884
|
async adminGetChannel(id) {
|
|
767
|
-
this.sdk.validateParams({ id }, { id: { type:
|
|
768
|
-
return internalRequest(this.sdk, `/chat/admin/channels/${id}`,
|
|
885
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
886
|
+
return internalRequest(this.sdk, `/chat/admin/channels/${id}`, "GET");
|
|
769
887
|
}
|
|
770
888
|
|
|
771
889
|
/**
|
|
@@ -774,8 +892,12 @@ export class ChatService {
|
|
|
774
892
|
* @returns {Promise<Object>}
|
|
775
893
|
*/
|
|
776
894
|
async adminExportChannel(id) {
|
|
777
|
-
this.sdk.validateParams({ id }, { id: { type:
|
|
778
|
-
return internalRequest(
|
|
895
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
896
|
+
return internalRequest(
|
|
897
|
+
this.sdk,
|
|
898
|
+
`/chat/admin/channels/${id}/export`,
|
|
899
|
+
"GET",
|
|
900
|
+
);
|
|
779
901
|
}
|
|
780
902
|
|
|
781
903
|
/**
|
|
@@ -787,13 +909,13 @@ export class ChatService {
|
|
|
787
909
|
async adminListReports({ status } = {}) {
|
|
788
910
|
this.sdk.validateParams(
|
|
789
911
|
{ status },
|
|
790
|
-
{ status: { type:
|
|
912
|
+
{ status: { type: "string", required: false } },
|
|
791
913
|
);
|
|
792
914
|
|
|
793
915
|
const query = {};
|
|
794
916
|
if (status !== undefined) query.status = status;
|
|
795
917
|
|
|
796
|
-
return internalRequest(this.sdk,
|
|
918
|
+
return internalRequest(this.sdk, "/chat/admin/reports", "GET", { query });
|
|
797
919
|
}
|
|
798
920
|
|
|
799
921
|
/**
|
|
@@ -807,11 +929,11 @@ export class ChatService {
|
|
|
807
929
|
this.sdk.validateParams(
|
|
808
930
|
{ id, status },
|
|
809
931
|
{
|
|
810
|
-
id: { type:
|
|
811
|
-
status: { type:
|
|
932
|
+
id: { type: "string", required: true },
|
|
933
|
+
status: { type: "string", required: true },
|
|
812
934
|
},
|
|
813
935
|
);
|
|
814
|
-
return internalRequest(this.sdk, `/chat/admin/reports/${id}`,
|
|
936
|
+
return internalRequest(this.sdk, `/chat/admin/reports/${id}`, "POST", {
|
|
815
937
|
body: { status },
|
|
816
938
|
});
|
|
817
939
|
}
|
|
@@ -819,11 +941,23 @@ export class ChatService {
|
|
|
819
941
|
/**
|
|
820
942
|
* Admin: delete a message (moderation).
|
|
821
943
|
* @param {string} id
|
|
944
|
+
* @param {Object} [params]
|
|
945
|
+
* @param {string} [params.reason]
|
|
822
946
|
* @returns {Promise<Object>}
|
|
823
947
|
*/
|
|
824
|
-
async adminDeleteMessage(id) {
|
|
825
|
-
this.sdk.validateParams(
|
|
826
|
-
|
|
948
|
+
async adminDeleteMessage(id, { reason } = {}) {
|
|
949
|
+
this.sdk.validateParams(
|
|
950
|
+
{ id, reason },
|
|
951
|
+
{
|
|
952
|
+
id: { type: "string", required: true },
|
|
953
|
+
reason: { type: "string", required: false },
|
|
954
|
+
},
|
|
955
|
+
);
|
|
956
|
+
const query = {};
|
|
957
|
+
if (reason !== undefined) query.reason = reason;
|
|
958
|
+
return internalRequest(this.sdk, `/chat/admin/messages/${id}`, "DELETE", {
|
|
959
|
+
query,
|
|
960
|
+
});
|
|
827
961
|
}
|
|
828
962
|
|
|
829
963
|
/**
|
|
@@ -831,7 +965,325 @@ export class ChatService {
|
|
|
831
965
|
* @returns {Promise<Object>}
|
|
832
966
|
*/
|
|
833
967
|
async adminAudit() {
|
|
834
|
-
return internalRequest(this.sdk,
|
|
968
|
+
return internalRequest(this.sdk, "/chat/admin/audit", "GET");
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
/**
|
|
972
|
+
* Admin: full-account message search (no membership ACL).
|
|
973
|
+
* @param {Object} [params]
|
|
974
|
+
* @param {string} [params.q] Boolean-mode fulltext; quoted phrases pass through
|
|
975
|
+
* @param {string[]} [params.userIds]
|
|
976
|
+
* @param {string[]} [params.channelIds] Empty/omitted = all channels
|
|
977
|
+
* @param {string[]} [params.kinds]
|
|
978
|
+
* @param {string} [params.from] ISO date/datetime
|
|
979
|
+
* @param {string} [params.to] ISO date/datetime
|
|
980
|
+
* @param {boolean} [params.includeDeleted] Default true server-side
|
|
981
|
+
* @param {string} [params.nextId] Pagination cursor (message id)
|
|
982
|
+
* @param {number} [params.limit]
|
|
983
|
+
* @returns {Promise<Object>} `{results: [{message, channel}], nextId}`
|
|
984
|
+
*/
|
|
985
|
+
async adminSearch({
|
|
986
|
+
q,
|
|
987
|
+
userIds,
|
|
988
|
+
channelIds,
|
|
989
|
+
kinds,
|
|
990
|
+
from,
|
|
991
|
+
to,
|
|
992
|
+
includeDeleted,
|
|
993
|
+
nextId,
|
|
994
|
+
limit,
|
|
995
|
+
} = {}) {
|
|
996
|
+
this.sdk.validateParams(
|
|
997
|
+
{
|
|
998
|
+
q,
|
|
999
|
+
userIds,
|
|
1000
|
+
channelIds,
|
|
1001
|
+
kinds,
|
|
1002
|
+
from,
|
|
1003
|
+
to,
|
|
1004
|
+
includeDeleted,
|
|
1005
|
+
nextId,
|
|
1006
|
+
limit,
|
|
1007
|
+
},
|
|
1008
|
+
{
|
|
1009
|
+
q: { type: "string", required: false },
|
|
1010
|
+
userIds: { type: "array", required: false },
|
|
1011
|
+
channelIds: { type: "array", required: false },
|
|
1012
|
+
kinds: { type: "array", required: false },
|
|
1013
|
+
from: { type: "string", required: false },
|
|
1014
|
+
to: { type: "string", required: false },
|
|
1015
|
+
includeDeleted: { type: "boolean", required: false },
|
|
1016
|
+
nextId: { type: "string", required: false },
|
|
1017
|
+
limit: { type: "number", required: false },
|
|
1018
|
+
},
|
|
1019
|
+
);
|
|
1020
|
+
|
|
1021
|
+
// Array params use bracket notation (`userIds[]=a&userIds[]=b`) so the
|
|
1022
|
+
// API's qs parser always yields an array, even for a single value.
|
|
1023
|
+
const query = [];
|
|
1024
|
+
if (q !== undefined) query.push(["q", q]);
|
|
1025
|
+
for (const v of userIds || []) query.push(["userIds[]", v]);
|
|
1026
|
+
for (const v of channelIds || []) query.push(["channelIds[]", v]);
|
|
1027
|
+
for (const v of kinds || []) query.push(["kinds[]", v]);
|
|
1028
|
+
if (from !== undefined) query.push(["from", from]);
|
|
1029
|
+
if (to !== undefined) query.push(["to", to]);
|
|
1030
|
+
if (includeDeleted !== undefined) {
|
|
1031
|
+
query.push(["includeDeleted", includeDeleted ? "1" : "0"]);
|
|
1032
|
+
}
|
|
1033
|
+
if (nextId !== undefined) query.push(["nextId", nextId]);
|
|
1034
|
+
if (limit !== undefined) query.push(["limit", String(limit)]);
|
|
1035
|
+
|
|
1036
|
+
return internalRequest(this.sdk, "/chat/admin/search", "GET", { query });
|
|
1037
|
+
}
|
|
1038
|
+
|
|
1039
|
+
/**
|
|
1040
|
+
* Admin: get a message (any channel) with its channel and pre-edit original.
|
|
1041
|
+
* @param {string} id
|
|
1042
|
+
* @returns {Promise<Object>} `{message, channel, original}`
|
|
1043
|
+
*/
|
|
1044
|
+
async adminGetMessage(id) {
|
|
1045
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
1046
|
+
return internalRequest(this.sdk, `/chat/admin/messages/${id}`, "GET");
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* Admin: free-form edit of a message; reason required, no edit window.
|
|
1051
|
+
* @param {string} id
|
|
1052
|
+
* @param {Object} params
|
|
1053
|
+
* @param {Object} params.message Message doc
|
|
1054
|
+
* @param {string} params.reason
|
|
1055
|
+
* @returns {Promise<Object>} Updated message
|
|
1056
|
+
*/
|
|
1057
|
+
async adminEditMessage(id, { message, reason } = {}) {
|
|
1058
|
+
this.sdk.validateParams(
|
|
1059
|
+
{ id, message, reason },
|
|
1060
|
+
{
|
|
1061
|
+
id: { type: "string", required: true },
|
|
1062
|
+
message: { type: "object", required: true },
|
|
1063
|
+
reason: { type: "string", required: true },
|
|
1064
|
+
},
|
|
1065
|
+
);
|
|
1066
|
+
return internalRequest(this.sdk, `/chat/admin/messages/${id}`, "PATCH", {
|
|
1067
|
+
body: { message, reason },
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
/**
|
|
1072
|
+
* Admin: get a message report with its message and channel.
|
|
1073
|
+
* @param {string} id
|
|
1074
|
+
* @returns {Promise<Object>}
|
|
1075
|
+
*/
|
|
1076
|
+
async adminGetReport(id) {
|
|
1077
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
1078
|
+
return internalRequest(this.sdk, `/chat/admin/reports/${id}`, "GET");
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
/**
|
|
1082
|
+
* Admin: list audit events.
|
|
1083
|
+
* @param {Object} [params]
|
|
1084
|
+
* @param {string} [params.type]
|
|
1085
|
+
* @param {string} [params.actorId]
|
|
1086
|
+
* @param {string} [params.channelId]
|
|
1087
|
+
* @param {string} [params.from]
|
|
1088
|
+
* @param {string} [params.to]
|
|
1089
|
+
* @param {string} [params.nextId]
|
|
1090
|
+
* @param {number} [params.limit]
|
|
1091
|
+
* @returns {Promise<Object>} `{results, nextId}`
|
|
1092
|
+
*/
|
|
1093
|
+
async adminListAudit({
|
|
1094
|
+
type,
|
|
1095
|
+
actorId,
|
|
1096
|
+
channelId,
|
|
1097
|
+
from,
|
|
1098
|
+
to,
|
|
1099
|
+
nextId,
|
|
1100
|
+
limit,
|
|
1101
|
+
} = {}) {
|
|
1102
|
+
this.sdk.validateParams(
|
|
1103
|
+
{ type, actorId, channelId, from, to, nextId, limit },
|
|
1104
|
+
{
|
|
1105
|
+
type: { type: "string", required: false },
|
|
1106
|
+
actorId: { type: "string", required: false },
|
|
1107
|
+
channelId: { type: "string", required: false },
|
|
1108
|
+
from: { type: "string", required: false },
|
|
1109
|
+
to: { type: "string", required: false },
|
|
1110
|
+
nextId: { type: "string", required: false },
|
|
1111
|
+
limit: { type: "number", required: false },
|
|
1112
|
+
},
|
|
1113
|
+
);
|
|
1114
|
+
|
|
1115
|
+
const query = {};
|
|
1116
|
+
if (type !== undefined) query.type = type;
|
|
1117
|
+
if (actorId !== undefined) query.actorId = actorId;
|
|
1118
|
+
if (channelId !== undefined) query.channelId = channelId;
|
|
1119
|
+
if (from !== undefined) query.from = from;
|
|
1120
|
+
if (to !== undefined) query.to = to;
|
|
1121
|
+
if (nextId !== undefined) query.nextId = nextId;
|
|
1122
|
+
if (limit !== undefined) query.limit = limit;
|
|
1123
|
+
|
|
1124
|
+
return internalRequest(this.sdk, "/chat/admin/audit", "GET", { query });
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
/**
|
|
1128
|
+
* Admin: list per-group default channels.
|
|
1129
|
+
* @returns {Promise<Object>} `{results: [{group, channels}]}`
|
|
1130
|
+
*/
|
|
1131
|
+
async adminListDefaults() {
|
|
1132
|
+
return internalRequest(this.sdk, "/chat/admin/defaults", "GET");
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
/**
|
|
1136
|
+
* Admin: list all webhooks across channels.
|
|
1137
|
+
* @returns {Promise<Object>} `{results}`
|
|
1138
|
+
*/
|
|
1139
|
+
async adminListWebhooks() {
|
|
1140
|
+
return internalRequest(this.sdk, "/chat/admin/webhooks", "GET");
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
/**
|
|
1144
|
+
* Admin: list retention policies (account default + per-kind overrides).
|
|
1145
|
+
* @returns {Promise<Object>} `{results}`
|
|
1146
|
+
*/
|
|
1147
|
+
async adminGetRetention() {
|
|
1148
|
+
return internalRequest(this.sdk, "/chat/admin/retention", "GET");
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
/**
|
|
1152
|
+
* Admin: upsert retention policies.
|
|
1153
|
+
* @param {Object[]} policies
|
|
1154
|
+
* @param {'account'|'kind'} policies[].scope
|
|
1155
|
+
* @param {string} [policies[].kind]
|
|
1156
|
+
* @param {number|null} [policies[].purgeDeletedAfterDays]
|
|
1157
|
+
* @param {boolean} [policies[].enabled]
|
|
1158
|
+
* @returns {Promise<Object>} `{results}`
|
|
1159
|
+
*/
|
|
1160
|
+
async adminPutRetention(policies) {
|
|
1161
|
+
this.sdk.validateParams(
|
|
1162
|
+
{ policies },
|
|
1163
|
+
{ policies: { type: "array", required: true } },
|
|
1164
|
+
);
|
|
1165
|
+
return internalRequest(this.sdk, "/chat/admin/retention", "PUT", {
|
|
1166
|
+
body: { policies },
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
/**
|
|
1171
|
+
* Admin: preview counts that would purge now, per retention policy.
|
|
1172
|
+
* @returns {Promise<Object>} `{results, heldSearchCount, heldMessageCount}`
|
|
1173
|
+
* `heldSearchCount` is the number of saved searches currently on legal
|
|
1174
|
+
* hold; `heldMessageCount` is how many otherwise-purgeable messages are
|
|
1175
|
+
* protected by those holds (across all policies).
|
|
1176
|
+
*/
|
|
1177
|
+
async adminRetentionPreview() {
|
|
1178
|
+
return internalRequest(this.sdk, "/chat/admin/retention/preview", "GET");
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
/**
|
|
1182
|
+
* Admin: set or release legal hold on a channel.
|
|
1183
|
+
* @param {string} id
|
|
1184
|
+
* @param {Object} params
|
|
1185
|
+
* @param {boolean} params.hold
|
|
1186
|
+
* @returns {Promise<Object>} Updated channel
|
|
1187
|
+
*/
|
|
1188
|
+
async adminSetLegalHold(id, { hold } = {}) {
|
|
1189
|
+
this.sdk.validateParams(
|
|
1190
|
+
{ id, hold },
|
|
1191
|
+
{
|
|
1192
|
+
id: { type: "string", required: true },
|
|
1193
|
+
hold: { type: "boolean", required: true },
|
|
1194
|
+
},
|
|
1195
|
+
);
|
|
1196
|
+
return internalRequest(
|
|
1197
|
+
this.sdk,
|
|
1198
|
+
`/chat/admin/channels/${id}/legal-hold`,
|
|
1199
|
+
"POST",
|
|
1200
|
+
{ body: { hold } },
|
|
1201
|
+
);
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
/**
|
|
1205
|
+
* Admin: list saved searches (own + shared with chat:admin:review).
|
|
1206
|
+
* @returns {Promise<Object>} `{results}`
|
|
1207
|
+
*/
|
|
1208
|
+
async adminListSavedSearches() {
|
|
1209
|
+
return internalRequest(this.sdk, "/chat/admin/saved-searches", "GET");
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
/**
|
|
1213
|
+
* Admin: create a saved search.
|
|
1214
|
+
* @param {Object} params
|
|
1215
|
+
* @param {string} params.name
|
|
1216
|
+
* @param {Object} params.criteria Search criteria (same shape as adminSearch params)
|
|
1217
|
+
* @param {boolean} [params.shared] Shared with everyone holding chat:admin:review
|
|
1218
|
+
* @param {Object} [params.hold] Legal hold — `{enabled, reason}`. `reason` is
|
|
1219
|
+
* required (max 500 chars) when `enabled` is true. Freezes every message
|
|
1220
|
+
* matching `criteria` against retention purge until released.
|
|
1221
|
+
* @returns {Promise<Object>} `{id}`
|
|
1222
|
+
*/
|
|
1223
|
+
async adminCreateSavedSearch({ name, criteria, shared, hold } = {}) {
|
|
1224
|
+
this.sdk.validateParams(
|
|
1225
|
+
{ name, criteria, shared, hold },
|
|
1226
|
+
{
|
|
1227
|
+
name: { type: "string", required: true },
|
|
1228
|
+
criteria: { type: "object", required: true },
|
|
1229
|
+
shared: { type: "boolean", required: false },
|
|
1230
|
+
hold: { type: "object", required: false },
|
|
1231
|
+
},
|
|
1232
|
+
);
|
|
1233
|
+
const body = { name, criteria };
|
|
1234
|
+
if (shared !== undefined) body.shared = shared;
|
|
1235
|
+
if (hold !== undefined) body.hold = hold;
|
|
1236
|
+
return internalRequest(this.sdk, "/chat/admin/saved-searches", "POST", {
|
|
1237
|
+
body,
|
|
1238
|
+
});
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
/**
|
|
1242
|
+
* Admin: update a saved search (owner only).
|
|
1243
|
+
* @param {string} id
|
|
1244
|
+
* @param {Object} [patch]
|
|
1245
|
+
* @param {string} [patch.name]
|
|
1246
|
+
* @param {Object} [patch.criteria]
|
|
1247
|
+
* @param {boolean} [patch.shared]
|
|
1248
|
+
* @param {Object} [patch.hold] `{enabled, reason}` — set `enabled: false`
|
|
1249
|
+
* to release an active hold; `reason` required when enabling.
|
|
1250
|
+
* @returns {Promise<Object>} Updated saved search — includes
|
|
1251
|
+
* `hold: {enabled, reason, by, at} | null`
|
|
1252
|
+
*/
|
|
1253
|
+
async adminUpdateSavedSearch(id, { name, criteria, shared, hold } = {}) {
|
|
1254
|
+
this.sdk.validateParams(
|
|
1255
|
+
{ id, hold },
|
|
1256
|
+
{
|
|
1257
|
+
id: { type: "string", required: true },
|
|
1258
|
+
hold: { type: "object", required: false },
|
|
1259
|
+
},
|
|
1260
|
+
);
|
|
1261
|
+
const body = {};
|
|
1262
|
+
if (name !== undefined) body.name = name;
|
|
1263
|
+
if (criteria !== undefined) body.criteria = criteria;
|
|
1264
|
+
if (shared !== undefined) body.shared = shared;
|
|
1265
|
+
if (hold !== undefined) body.hold = hold;
|
|
1266
|
+
return internalRequest(
|
|
1267
|
+
this.sdk,
|
|
1268
|
+
`/chat/admin/saved-searches/${id}`,
|
|
1269
|
+
"PATCH",
|
|
1270
|
+
{ body },
|
|
1271
|
+
);
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
/**
|
|
1275
|
+
* Admin: delete a saved search (owner only). Refused (400) while the
|
|
1276
|
+
* saved search has an active legal hold — release it first.
|
|
1277
|
+
* @param {string} id
|
|
1278
|
+
* @returns {Promise<Object>} `{id}`
|
|
1279
|
+
*/
|
|
1280
|
+
async adminDeleteSavedSearch(id) {
|
|
1281
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
1282
|
+
return internalRequest(
|
|
1283
|
+
this.sdk,
|
|
1284
|
+
`/chat/admin/saved-searches/${id}`,
|
|
1285
|
+
"DELETE",
|
|
1286
|
+
);
|
|
835
1287
|
}
|
|
836
1288
|
|
|
837
1289
|
/**
|
|
@@ -845,11 +1297,11 @@ export class ChatService {
|
|
|
845
1297
|
this.sdk.validateParams(
|
|
846
1298
|
{ relatedId, recordTypeId },
|
|
847
1299
|
{
|
|
848
|
-
relatedId: { type:
|
|
849
|
-
recordTypeId: { type:
|
|
1300
|
+
relatedId: { type: "string", required: true },
|
|
1301
|
+
recordTypeId: { type: "string", required: true },
|
|
850
1302
|
},
|
|
851
1303
|
);
|
|
852
|
-
return internalRequest(this.sdk, `/chat/records/${relatedId}`,
|
|
1304
|
+
return internalRequest(this.sdk, `/chat/records/${relatedId}`, "GET", {
|
|
853
1305
|
query: { recordTypeId },
|
|
854
1306
|
});
|
|
855
1307
|
}
|
|
@@ -866,14 +1318,19 @@ export class ChatService {
|
|
|
866
1318
|
this.sdk.validateParams(
|
|
867
1319
|
{ relatedId, message, recordTypeId },
|
|
868
1320
|
{
|
|
869
|
-
relatedId: { type:
|
|
870
|
-
message: { type:
|
|
871
|
-
recordTypeId: { type:
|
|
1321
|
+
relatedId: { type: "string", required: true },
|
|
1322
|
+
message: { type: "object", required: true },
|
|
1323
|
+
recordTypeId: { type: "string", required: true },
|
|
1324
|
+
},
|
|
1325
|
+
);
|
|
1326
|
+
return internalRequest(
|
|
1327
|
+
this.sdk,
|
|
1328
|
+
`/chat/records/${relatedId}/messages`,
|
|
1329
|
+
"POST",
|
|
1330
|
+
{
|
|
1331
|
+
body: { message, recordTypeId },
|
|
872
1332
|
},
|
|
873
1333
|
);
|
|
874
|
-
return internalRequest(this.sdk, `/chat/records/${relatedId}/messages`, 'POST', {
|
|
875
|
-
body: { message, recordTypeId },
|
|
876
|
-
});
|
|
877
1334
|
}
|
|
878
1335
|
|
|
879
1336
|
/**
|
|
@@ -884,9 +1341,9 @@ export class ChatService {
|
|
|
884
1341
|
async getChannelMeet(channelId) {
|
|
885
1342
|
this.sdk.validateParams(
|
|
886
1343
|
{ channelId },
|
|
887
|
-
{ channelId: { type:
|
|
1344
|
+
{ channelId: { type: "string", required: true } },
|
|
888
1345
|
);
|
|
889
|
-
return internalRequest(this.sdk, `/chat/channels/${channelId}/meet`,
|
|
1346
|
+
return internalRequest(this.sdk, `/chat/channels/${channelId}/meet`, "GET");
|
|
890
1347
|
}
|
|
891
1348
|
|
|
892
1349
|
/**
|
|
@@ -894,7 +1351,7 @@ export class ChatService {
|
|
|
894
1351
|
* @returns {Promise<Object>}
|
|
895
1352
|
*/
|
|
896
1353
|
async getVapidPublicKey() {
|
|
897
|
-
return internalRequest(this.sdk,
|
|
1354
|
+
return internalRequest(this.sdk, "/chat/push/vapidPublicKey", "GET");
|
|
898
1355
|
}
|
|
899
1356
|
|
|
900
1357
|
/**
|
|
@@ -908,11 +1365,11 @@ export class ChatService {
|
|
|
908
1365
|
this.sdk.validateParams(
|
|
909
1366
|
{ kind, subscription },
|
|
910
1367
|
{
|
|
911
|
-
kind: { type:
|
|
912
|
-
subscription: { type:
|
|
1368
|
+
kind: { type: "string", required: true },
|
|
1369
|
+
subscription: { type: "object", required: true },
|
|
913
1370
|
},
|
|
914
1371
|
);
|
|
915
|
-
return internalRequest(this.sdk,
|
|
1372
|
+
return internalRequest(this.sdk, "/chat/push/devices", "POST", {
|
|
916
1373
|
body: { kind, subscription },
|
|
917
1374
|
});
|
|
918
1375
|
}
|
|
@@ -923,8 +1380,8 @@ export class ChatService {
|
|
|
923
1380
|
* @returns {Promise<Object>}
|
|
924
1381
|
*/
|
|
925
1382
|
async unregisterPushDevice(id) {
|
|
926
|
-
this.sdk.validateParams({ id }, { id: { type:
|
|
927
|
-
return internalRequest(this.sdk, `/chat/push/devices/${id}`,
|
|
1383
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
1384
|
+
return internalRequest(this.sdk, `/chat/push/devices/${id}`, "DELETE");
|
|
928
1385
|
}
|
|
929
1386
|
|
|
930
1387
|
/**
|
|
@@ -938,13 +1395,18 @@ export class ChatService {
|
|
|
938
1395
|
this.sdk.validateParams(
|
|
939
1396
|
{ channelId, notifyLevel },
|
|
940
1397
|
{
|
|
941
|
-
channelId: { type:
|
|
942
|
-
notifyLevel: { type:
|
|
1398
|
+
channelId: { type: "string", required: true },
|
|
1399
|
+
notifyLevel: { type: "string", required: true },
|
|
1400
|
+
},
|
|
1401
|
+
);
|
|
1402
|
+
return internalRequest(
|
|
1403
|
+
this.sdk,
|
|
1404
|
+
`/chat/channels/${channelId}/notify`,
|
|
1405
|
+
"PATCH",
|
|
1406
|
+
{
|
|
1407
|
+
body: { notifyLevel },
|
|
943
1408
|
},
|
|
944
1409
|
);
|
|
945
|
-
return internalRequest(this.sdk, `/chat/channels/${channelId}/notify`, 'PATCH', {
|
|
946
|
-
body: { notifyLevel },
|
|
947
|
-
});
|
|
948
1410
|
}
|
|
949
1411
|
|
|
950
1412
|
/**
|
|
@@ -952,7 +1414,7 @@ export class ChatService {
|
|
|
952
1414
|
* @returns {Promise<Object>}
|
|
953
1415
|
*/
|
|
954
1416
|
async listPins() {
|
|
955
|
-
return internalRequest(this.sdk,
|
|
1417
|
+
return internalRequest(this.sdk, "/chat/pins", "GET");
|
|
956
1418
|
}
|
|
957
1419
|
|
|
958
1420
|
/**
|
|
@@ -968,18 +1430,18 @@ export class ChatService {
|
|
|
968
1430
|
this.sdk.validateParams(
|
|
969
1431
|
{ kind, channelId, relatedId, relatedRecordTypeId },
|
|
970
1432
|
{
|
|
971
|
-
kind: { type:
|
|
972
|
-
channelId: { type:
|
|
973
|
-
relatedId: { type:
|
|
974
|
-
relatedRecordTypeId: { type:
|
|
1433
|
+
kind: { type: "string", required: true },
|
|
1434
|
+
channelId: { type: "string", required: false },
|
|
1435
|
+
relatedId: { type: "string", required: false },
|
|
1436
|
+
relatedRecordTypeId: { type: "string", required: false },
|
|
975
1437
|
},
|
|
976
1438
|
);
|
|
977
1439
|
const body = { kind };
|
|
978
1440
|
if (channelId !== undefined) body.channelId = channelId;
|
|
979
1441
|
if (relatedId !== undefined) body.relatedId = relatedId;
|
|
980
|
-
if (relatedRecordTypeId !== undefined)
|
|
981
|
-
relatedRecordTypeId;
|
|
982
|
-
return internalRequest(this.sdk,
|
|
1442
|
+
if (relatedRecordTypeId !== undefined)
|
|
1443
|
+
body.relatedRecordTypeId = relatedRecordTypeId;
|
|
1444
|
+
return internalRequest(this.sdk, "/chat/pins", "POST", { body });
|
|
983
1445
|
}
|
|
984
1446
|
|
|
985
1447
|
/**
|
|
@@ -988,8 +1450,8 @@ export class ChatService {
|
|
|
988
1450
|
* @returns {Promise<Object>}
|
|
989
1451
|
*/
|
|
990
1452
|
async unpinItem(id) {
|
|
991
|
-
this.sdk.validateParams({ id }, { id: { type:
|
|
992
|
-
return internalRequest(this.sdk, `/chat/pins/${id}`,
|
|
1453
|
+
this.sdk.validateParams({ id }, { id: { type: "string", required: true } });
|
|
1454
|
+
return internalRequest(this.sdk, `/chat/pins/${id}`, "DELETE");
|
|
993
1455
|
}
|
|
994
1456
|
|
|
995
1457
|
/**
|
|
@@ -1003,14 +1465,14 @@ export class ChatService {
|
|
|
1003
1465
|
this.sdk.validateParams(
|
|
1004
1466
|
{ channelId, messageId },
|
|
1005
1467
|
{
|
|
1006
|
-
channelId: { type:
|
|
1007
|
-
messageId: { type:
|
|
1468
|
+
channelId: { type: "string", required: true },
|
|
1469
|
+
messageId: { type: "string", required: true },
|
|
1008
1470
|
},
|
|
1009
1471
|
);
|
|
1010
1472
|
return internalRequest(
|
|
1011
1473
|
this.sdk,
|
|
1012
1474
|
`/chat/channels/${channelId}/pinned-message`,
|
|
1013
|
-
|
|
1475
|
+
"PUT",
|
|
1014
1476
|
{ body: { messageId } },
|
|
1015
1477
|
);
|
|
1016
1478
|
}
|
|
@@ -1023,12 +1485,12 @@ export class ChatService {
|
|
|
1023
1485
|
async unpinMessage(channelId) {
|
|
1024
1486
|
this.sdk.validateParams(
|
|
1025
1487
|
{ channelId },
|
|
1026
|
-
{ channelId: { type:
|
|
1488
|
+
{ channelId: { type: "string", required: true } },
|
|
1027
1489
|
);
|
|
1028
1490
|
return internalRequest(
|
|
1029
1491
|
this.sdk,
|
|
1030
1492
|
`/chat/channels/${channelId}/pinned-message`,
|
|
1031
|
-
|
|
1493
|
+
"DELETE",
|
|
1032
1494
|
);
|
|
1033
1495
|
}
|
|
1034
1496
|
|
|
@@ -1043,7 +1505,7 @@ export class ChatService {
|
|
|
1043
1505
|
const query = {};
|
|
1044
1506
|
if (kind) query.kind = kind;
|
|
1045
1507
|
if (limit != null) query.limit = limit;
|
|
1046
|
-
return internalRequest(this.sdk,
|
|
1508
|
+
return internalRequest(this.sdk, "/chat/mentions", "GET", { query });
|
|
1047
1509
|
}
|
|
1048
1510
|
|
|
1049
1511
|
/**
|
|
@@ -1057,7 +1519,7 @@ export class ChatService {
|
|
|
1057
1519
|
const query = {};
|
|
1058
1520
|
if (kind) query.kind = kind;
|
|
1059
1521
|
if (limit != null) query.limit = limit;
|
|
1060
|
-
return internalRequest(this.sdk,
|
|
1522
|
+
return internalRequest(this.sdk, "/chat/threads", "GET", { query });
|
|
1061
1523
|
}
|
|
1062
1524
|
|
|
1063
1525
|
/**
|
|
@@ -1068,12 +1530,12 @@ export class ChatService {
|
|
|
1068
1530
|
async getGroupDefaultChannels(groupId) {
|
|
1069
1531
|
this.sdk.validateParams(
|
|
1070
1532
|
{ groupId },
|
|
1071
|
-
{ groupId: { type:
|
|
1533
|
+
{ groupId: { type: "string", required: true } },
|
|
1072
1534
|
);
|
|
1073
1535
|
return internalRequest(
|
|
1074
1536
|
this.sdk,
|
|
1075
1537
|
`/chat/groups/${groupId}/default-channels`,
|
|
1076
|
-
|
|
1538
|
+
"GET",
|
|
1077
1539
|
);
|
|
1078
1540
|
}
|
|
1079
1541
|
|
|
@@ -1088,14 +1550,14 @@ export class ChatService {
|
|
|
1088
1550
|
this.sdk.validateParams(
|
|
1089
1551
|
{ groupId, channelIds },
|
|
1090
1552
|
{
|
|
1091
|
-
groupId: { type:
|
|
1092
|
-
channelIds: { type:
|
|
1553
|
+
groupId: { type: "string", required: true },
|
|
1554
|
+
channelIds: { type: "array", required: false },
|
|
1093
1555
|
},
|
|
1094
1556
|
);
|
|
1095
1557
|
return internalRequest(
|
|
1096
1558
|
this.sdk,
|
|
1097
1559
|
`/chat/groups/${groupId}/default-channels`,
|
|
1098
|
-
|
|
1560
|
+
"PUT",
|
|
1099
1561
|
{ body: { channelIds } },
|
|
1100
1562
|
);
|
|
1101
1563
|
}
|
|
@@ -1108,12 +1570,12 @@ export class ChatService {
|
|
|
1108
1570
|
async createChannelMeet(channelId) {
|
|
1109
1571
|
this.sdk.validateParams(
|
|
1110
1572
|
{ channelId },
|
|
1111
|
-
{ channelId: { type:
|
|
1573
|
+
{ channelId: { type: "string", required: true } },
|
|
1112
1574
|
);
|
|
1113
1575
|
return internalRequest(
|
|
1114
1576
|
this.sdk,
|
|
1115
1577
|
`/chat/channels/${channelId}/meet`,
|
|
1116
|
-
|
|
1578
|
+
"POST",
|
|
1117
1579
|
{ body: {} },
|
|
1118
1580
|
);
|
|
1119
1581
|
}
|
|
@@ -1133,23 +1595,23 @@ export class ChatService {
|
|
|
1133
1595
|
async updateChannelMeet(channelId, patch = {}) {
|
|
1134
1596
|
this.sdk.validateParams(
|
|
1135
1597
|
{ channelId },
|
|
1136
|
-
{ channelId: { type:
|
|
1598
|
+
{ channelId: { type: "string", required: true } },
|
|
1137
1599
|
);
|
|
1138
1600
|
const body = {};
|
|
1139
1601
|
for (const key of [
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1602
|
+
"slug",
|
|
1603
|
+
"password",
|
|
1604
|
+
"guestsCanStart",
|
|
1605
|
+
"startRecordingOn",
|
|
1606
|
+
"startTranscribingOn",
|
|
1607
|
+
"endMeetingWithoutHostTimeLimit",
|
|
1146
1608
|
]) {
|
|
1147
1609
|
if (patch[key] !== undefined) body[key] = patch[key];
|
|
1148
1610
|
}
|
|
1149
1611
|
return internalRequest(
|
|
1150
1612
|
this.sdk,
|
|
1151
1613
|
`/chat/channels/${channelId}/meet`,
|
|
1152
|
-
|
|
1614
|
+
"PATCH",
|
|
1153
1615
|
{ body },
|
|
1154
1616
|
);
|
|
1155
1617
|
}
|
|
@@ -1164,14 +1626,14 @@ export class ChatService {
|
|
|
1164
1626
|
this.sdk.validateParams(
|
|
1165
1627
|
{ channelId, slug },
|
|
1166
1628
|
{
|
|
1167
|
-
channelId: { type:
|
|
1168
|
-
slug: { type:
|
|
1629
|
+
channelId: { type: "string", required: true },
|
|
1630
|
+
slug: { type: "string", required: true },
|
|
1169
1631
|
},
|
|
1170
1632
|
);
|
|
1171
1633
|
return internalRequest(
|
|
1172
1634
|
this.sdk,
|
|
1173
1635
|
`/chat/channels/${channelId}/meet/slug-available`,
|
|
1174
|
-
|
|
1636
|
+
"GET",
|
|
1175
1637
|
{ query: { slug } },
|
|
1176
1638
|
);
|
|
1177
1639
|
}
|
|
@@ -1184,12 +1646,12 @@ export class ChatService {
|
|
|
1184
1646
|
async regenerateChannelMeetPassword(channelId) {
|
|
1185
1647
|
this.sdk.validateParams(
|
|
1186
1648
|
{ channelId },
|
|
1187
|
-
{ channelId: { type:
|
|
1649
|
+
{ channelId: { type: "string", required: true } },
|
|
1188
1650
|
);
|
|
1189
1651
|
return internalRequest(
|
|
1190
1652
|
this.sdk,
|
|
1191
1653
|
`/chat/channels/${channelId}/meet/regenerate-password`,
|
|
1192
|
-
|
|
1654
|
+
"POST",
|
|
1193
1655
|
{ body: {} },
|
|
1194
1656
|
);
|
|
1195
1657
|
}
|
|
@@ -1199,7 +1661,7 @@ export class ChatService {
|
|
|
1199
1661
|
* @returns {Promise<Object>}
|
|
1200
1662
|
*/
|
|
1201
1663
|
async listBots() {
|
|
1202
|
-
return internalRequest(this.sdk,
|
|
1664
|
+
return internalRequest(this.sdk, "/chat/bots", "GET");
|
|
1203
1665
|
}
|
|
1204
1666
|
|
|
1205
1667
|
/**
|
|
@@ -1213,11 +1675,11 @@ export class ChatService {
|
|
|
1213
1675
|
this.sdk.validateParams(
|
|
1214
1676
|
{ id, name },
|
|
1215
1677
|
{
|
|
1216
|
-
id: { type:
|
|
1217
|
-
name: { type:
|
|
1678
|
+
id: { type: "string", required: true },
|
|
1679
|
+
name: { type: "string", required: false },
|
|
1218
1680
|
},
|
|
1219
1681
|
);
|
|
1220
|
-
return internalRequest(this.sdk, `/chat/bots/${id}`,
|
|
1682
|
+
return internalRequest(this.sdk, `/chat/bots/${id}`, "PATCH", {
|
|
1221
1683
|
body: { name },
|
|
1222
1684
|
});
|
|
1223
1685
|
}
|
|
@@ -1230,12 +1692,12 @@ export class ChatService {
|
|
|
1230
1692
|
async getBotMemory(channelId) {
|
|
1231
1693
|
this.sdk.validateParams(
|
|
1232
1694
|
{ channelId },
|
|
1233
|
-
{ channelId: { type:
|
|
1695
|
+
{ channelId: { type: "string", required: true } },
|
|
1234
1696
|
);
|
|
1235
1697
|
return internalRequest(
|
|
1236
1698
|
this.sdk,
|
|
1237
1699
|
`/chat/channels/${channelId}/bot-memory`,
|
|
1238
|
-
|
|
1700
|
+
"GET",
|
|
1239
1701
|
);
|
|
1240
1702
|
}
|
|
1241
1703
|
|
|
@@ -1247,12 +1709,12 @@ export class ChatService {
|
|
|
1247
1709
|
async resetBotMemory(channelId) {
|
|
1248
1710
|
this.sdk.validateParams(
|
|
1249
1711
|
{ channelId },
|
|
1250
|
-
{ channelId: { type:
|
|
1712
|
+
{ channelId: { type: "string", required: true } },
|
|
1251
1713
|
);
|
|
1252
1714
|
return internalRequest(
|
|
1253
1715
|
this.sdk,
|
|
1254
1716
|
`/chat/channels/${channelId}/bot-memory/reset`,
|
|
1255
|
-
|
|
1717
|
+
"POST",
|
|
1256
1718
|
{ body: {} },
|
|
1257
1719
|
);
|
|
1258
1720
|
}
|
|
@@ -1265,12 +1727,12 @@ export class ChatService {
|
|
|
1265
1727
|
async compactBotMemory(channelId) {
|
|
1266
1728
|
this.sdk.validateParams(
|
|
1267
1729
|
{ channelId },
|
|
1268
|
-
{ channelId: { type:
|
|
1730
|
+
{ channelId: { type: "string", required: true } },
|
|
1269
1731
|
);
|
|
1270
1732
|
return internalRequest(
|
|
1271
1733
|
this.sdk,
|
|
1272
1734
|
`/chat/channels/${channelId}/bot-memory/compact`,
|
|
1273
|
-
|
|
1735
|
+
"POST",
|
|
1274
1736
|
{ body: {} },
|
|
1275
1737
|
);
|
|
1276
1738
|
}
|
|
@@ -1287,8 +1749,11 @@ export class ChatService {
|
|
|
1287
1749
|
return this.adminListReports(query);
|
|
1288
1750
|
}
|
|
1289
1751
|
|
|
1290
|
-
async listAdminAudit() {
|
|
1291
|
-
|
|
1752
|
+
async listAdminAudit(query) {
|
|
1753
|
+
// legacy callers passed a bare channelId string
|
|
1754
|
+
return this.adminListAudit(
|
|
1755
|
+
typeof query === "string" ? { channelId: query } : query,
|
|
1756
|
+
);
|
|
1292
1757
|
}
|
|
1293
1758
|
|
|
1294
1759
|
async listAdminMessages(channelId, query) {
|
|
@@ -1296,12 +1761,92 @@ export class ChatService {
|
|
|
1296
1761
|
}
|
|
1297
1762
|
|
|
1298
1763
|
async dismissAdminReport(id) {
|
|
1299
|
-
return this.adminReviewReport(id, { status:
|
|
1764
|
+
return this.adminReviewReport(id, { status: "dismissed" });
|
|
1300
1765
|
}
|
|
1301
1766
|
|
|
1302
1767
|
async actionAdminReport(id, body = {}) {
|
|
1303
1768
|
return this.adminReviewReport(id, {
|
|
1304
|
-
status: body.status ||
|
|
1769
|
+
status: body.status || "actioned",
|
|
1770
|
+
});
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
async getAdminReport(id) {
|
|
1774
|
+
return this.adminGetReport(id);
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
async getOriginalMessage(id) {
|
|
1778
|
+
return this.adminGetMessage(id);
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
async listAdminDefaults() {
|
|
1782
|
+
return this.adminListDefaults();
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
async listAdminWebhooks() {
|
|
1786
|
+
return this.adminListWebhooks();
|
|
1787
|
+
}
|
|
1788
|
+
|
|
1789
|
+
/**
|
|
1790
|
+
* Get the chat channel that receives status updates for a source
|
|
1791
|
+
* (campaign, port, etc.). Returns `{ subscription: null }` if none.
|
|
1792
|
+
* @param {Object} params
|
|
1793
|
+
* @param {string} params.sourceType
|
|
1794
|
+
* @param {string} params.sourceId
|
|
1795
|
+
* @returns {Promise<{ subscription: Object|null }>}
|
|
1796
|
+
*/
|
|
1797
|
+
async getAlertSubscription({ sourceType, sourceId }) {
|
|
1798
|
+
this.sdk.validateParams(
|
|
1799
|
+
{ sourceType, sourceId },
|
|
1800
|
+
{
|
|
1801
|
+
sourceType: { type: "string", required: true },
|
|
1802
|
+
sourceId: { type: "string", required: true },
|
|
1803
|
+
},
|
|
1804
|
+
);
|
|
1805
|
+
return internalRequest(this.sdk, "/chat/alert-subscriptions", "GET", {
|
|
1806
|
+
query: { sourceType, sourceId },
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
/**
|
|
1811
|
+
* Post status updates for a source to a chat channel.
|
|
1812
|
+
* Pass the caller's You channel (`openDm({ userIds: [] })`) as the default.
|
|
1813
|
+
* @param {Object} params
|
|
1814
|
+
* @param {string} params.sourceType
|
|
1815
|
+
* @param {string} params.sourceId
|
|
1816
|
+
* @param {string} params.channelId
|
|
1817
|
+
* @returns {Promise<{ subscription: Object }>}
|
|
1818
|
+
*/
|
|
1819
|
+
async setAlertSubscription({ sourceType, sourceId, channelId }) {
|
|
1820
|
+
this.sdk.validateParams(
|
|
1821
|
+
{ sourceType, sourceId, channelId },
|
|
1822
|
+
{
|
|
1823
|
+
sourceType: { type: "string", required: true },
|
|
1824
|
+
sourceId: { type: "string", required: true },
|
|
1825
|
+
channelId: { type: "string", required: true },
|
|
1826
|
+
},
|
|
1827
|
+
);
|
|
1828
|
+
return internalRequest(this.sdk, "/chat/alert-subscriptions", "PUT", {
|
|
1829
|
+
body: { sourceType, sourceId, channelId },
|
|
1830
|
+
});
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
/**
|
|
1834
|
+
* Stop posting status updates for a source.
|
|
1835
|
+
* @param {Object} params
|
|
1836
|
+
* @param {string} params.sourceType
|
|
1837
|
+
* @param {string} params.sourceId
|
|
1838
|
+
* @returns {Promise<Object>}
|
|
1839
|
+
*/
|
|
1840
|
+
async deleteAlertSubscription({ sourceType, sourceId }) {
|
|
1841
|
+
this.sdk.validateParams(
|
|
1842
|
+
{ sourceType, sourceId },
|
|
1843
|
+
{
|
|
1844
|
+
sourceType: { type: "string", required: true },
|
|
1845
|
+
sourceId: { type: "string", required: true },
|
|
1846
|
+
},
|
|
1847
|
+
);
|
|
1848
|
+
return internalRequest(this.sdk, "/chat/alert-subscriptions", "DELETE", {
|
|
1849
|
+
query: { sourceType, sourceId },
|
|
1305
1850
|
});
|
|
1306
1851
|
}
|
|
1307
1852
|
}
|