@stream-io/node-sdk 0.3.1 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/dist/index.cjs.js +4136 -9282
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.d.ts +2 -3
  4. package/dist/index.es.js +4136 -9206
  5. package/dist/index.es.js.map +1 -1
  6. package/dist/src/BaseApi.d.ts +10 -0
  7. package/dist/src/StreamCall.d.ts +5 -37
  8. package/dist/src/StreamChannel.d.ts +7 -34
  9. package/dist/src/StreamChatClient.d.ts +2 -25
  10. package/dist/src/StreamClient.d.ts +51 -59
  11. package/dist/src/StreamModerationClient.d.ts +3 -0
  12. package/dist/src/StreamVideoClient.d.ts +2 -18
  13. package/dist/src/gen/chat/ChannelApi.d.ts +33 -0
  14. package/dist/src/gen/chat/ChatApi.d.ts +241 -0
  15. package/dist/src/gen/common/CommonApi.d.ts +99 -0
  16. package/dist/src/gen/model-decoders/index.d.ts +3 -0
  17. package/dist/src/gen/models/index.d.ts +3881 -0
  18. package/dist/src/gen/moderation/ModerationApi.d.ts +38 -0
  19. package/dist/src/gen/video/CallApi.d.ts +56 -0
  20. package/dist/src/gen/video/VideoApi.d.ts +151 -0
  21. package/dist/src/types.d.ts +25 -0
  22. package/dist/src/utils/create-token.d.ts +2 -0
  23. package/dist/src/utils/rate-limit.d.ts +2 -0
  24. package/index.ts +2 -3
  25. package/package.json +5 -4
  26. package/src/BaseApi.ts +115 -0
  27. package/src/StreamCall.ts +9 -199
  28. package/src/StreamChannel.ts +23 -246
  29. package/src/StreamChatClient.ts +3 -122
  30. package/src/StreamClient.ts +101 -345
  31. package/src/StreamModerationClient.ts +3 -0
  32. package/src/StreamVideoClient.ts +3 -95
  33. package/src/gen/chat/ChannelApi.ts +270 -0
  34. package/src/gen/chat/ChatApi.ts +1857 -0
  35. package/src/gen/common/CommonApi.ts +1004 -0
  36. package/src/gen/model-decoders/index.ts +1897 -0
  37. package/src/gen/models/index.ts +6794 -0
  38. package/src/gen/moderation/ModerationApi.ts +476 -0
  39. package/src/gen/video/CallApi.ts +309 -0
  40. package/src/gen/video/VideoApi.ts +1007 -0
  41. package/src/types.ts +35 -0
  42. package/src/utils/create-token.ts +6 -1
  43. package/src/utils/rate-limit.ts +21 -0
  44. package/dist/src/gen/chat/apis/ProductchatApi.d.ts +0 -1750
  45. package/dist/src/gen/chat/apis/index.d.ts +0 -1
  46. package/dist/src/gen/chat/index.d.ts +0 -3
  47. package/dist/src/gen/chat/models/index.d.ts +0 -14865
  48. package/dist/src/gen/chat/runtime.d.ts +0 -180
  49. package/dist/src/gen/video/apis/ProductvideoApi.d.ts +0 -648
  50. package/dist/src/gen/video/apis/index.d.ts +0 -1
  51. package/dist/src/gen/video/index.d.ts +0 -3
  52. package/dist/src/gen/video/models/index.d.ts +0 -5011
  53. package/dist/src/gen/video/runtime.d.ts +0 -180
  54. package/src/gen/chat/.openapi-generator/FILES +0 -6
  55. package/src/gen/chat/.openapi-generator/VERSION +0 -1
  56. package/src/gen/chat/.openapi-generator-ignore +0 -23
  57. package/src/gen/chat/apis/ProductchatApi.ts +0 -7007
  58. package/src/gen/chat/apis/index.ts +0 -3
  59. package/src/gen/chat/index.ts +0 -5
  60. package/src/gen/chat/models/index.ts +0 -14766
  61. package/src/gen/chat/runtime.ts +0 -415
  62. package/src/gen/video/.openapi-generator/FILES +0 -6
  63. package/src/gen/video/.openapi-generator/VERSION +0 -1
  64. package/src/gen/video/.openapi-generator-ignore +0 -23
  65. package/src/gen/video/apis/ProductvideoApi.ts +0 -2575
  66. package/src/gen/video/apis/index.ts +0 -3
  67. package/src/gen/video/index.ts +0 -5
  68. package/src/gen/video/models/index.ts +0 -5000
  69. package/src/gen/video/runtime.ts +0 -415
@@ -0,0 +1,1857 @@
1
+ import { BaseApi } from '../../BaseApi';
2
+ import { StreamResponse } from '../../types';
3
+ import {
4
+ CastPollVoteRequest,
5
+ ChannelGetOrCreateRequest,
6
+ ChannelStateResponse,
7
+ CommitMessageRequest,
8
+ CreateChannelTypeRequest,
9
+ CreateChannelTypeResponse,
10
+ CreateCommandRequest,
11
+ CreateCommandResponse,
12
+ CreatePollOptionRequest,
13
+ CreatePollRequest,
14
+ DeleteChannelResponse,
15
+ DeleteChannelsRequest,
16
+ DeleteChannelsResponse,
17
+ DeleteCommandResponse,
18
+ DeleteMessageResponse,
19
+ EventResponse,
20
+ ExportChannelsRequest,
21
+ ExportChannelsResponse,
22
+ FileUploadRequest,
23
+ FileUploadResponse,
24
+ GetChannelTypeResponse,
25
+ GetCommandResponse,
26
+ GetExportChannelsStatusResponse,
27
+ GetManyMessagesResponse,
28
+ GetMessageResponse,
29
+ GetReactionsResponse,
30
+ GetRepliesResponse,
31
+ GetThreadResponse,
32
+ HideChannelRequest,
33
+ HideChannelResponse,
34
+ ImageUploadRequest,
35
+ ImageUploadResponse,
36
+ ListChannelTypesResponse,
37
+ ListCommandsResponse,
38
+ MarkChannelsReadRequest,
39
+ MarkReadRequest,
40
+ MarkReadResponse,
41
+ MarkUnreadRequest,
42
+ MembersResponse,
43
+ MessageActionRequest,
44
+ MessageResponse,
45
+ MuteChannelRequest,
46
+ MuteChannelResponse,
47
+ PollOptionResponse,
48
+ PollResponse,
49
+ PollVoteResponse,
50
+ PollVotesResponse,
51
+ QueryBannedUsersRequest,
52
+ QueryBannedUsersResponse,
53
+ QueryChannelsRequest,
54
+ QueryChannelsResponse,
55
+ QueryMembersRequest,
56
+ QueryMessageFlagsRequest,
57
+ QueryMessageFlagsResponse,
58
+ QueryMessageHistoryRequest,
59
+ QueryMessageHistoryResponse,
60
+ QueryPollVotesRequest,
61
+ QueryPollsRequest,
62
+ QueryPollsResponse,
63
+ QueryReactionsRequest,
64
+ QueryReactionsResponse,
65
+ QueryThreadsRequest,
66
+ QueryThreadsResponse,
67
+ ReactionRemovalResponse,
68
+ Response,
69
+ SearchRequest,
70
+ SearchResponse,
71
+ SendEventRequest,
72
+ SendMessageRequest,
73
+ SendMessageResponse,
74
+ SendReactionRequest,
75
+ SendReactionResponse,
76
+ SendUserCustomEventRequest,
77
+ ShowChannelRequest,
78
+ ShowChannelResponse,
79
+ SortParamRequest,
80
+ TranslateMessageRequest,
81
+ TruncateChannelRequest,
82
+ TruncateChannelResponse,
83
+ UnmuteChannelRequest,
84
+ UnmuteResponse,
85
+ UnreadCountsBatchRequest,
86
+ UnreadCountsBatchResponse,
87
+ UpdateChannelPartialRequest,
88
+ UpdateChannelPartialResponse,
89
+ UpdateChannelRequest,
90
+ UpdateChannelResponse,
91
+ UpdateChannelTypeRequest,
92
+ UpdateChannelTypeResponse,
93
+ UpdateCommandRequest,
94
+ UpdateCommandResponse,
95
+ UpdateMessagePartialRequest,
96
+ UpdateMessagePartialResponse,
97
+ UpdateMessageRequest,
98
+ UpdateMessageResponse,
99
+ UpdatePollOptionRequest,
100
+ UpdatePollPartialRequest,
101
+ UpdatePollRequest,
102
+ UpdateThreadPartialRequest,
103
+ UpdateThreadPartialResponse,
104
+ WrappedUnreadCountsResponse,
105
+ } from '../models';
106
+ import { decoders } from '../model-decoders';
107
+
108
+ export class ChatApi extends BaseApi {
109
+ queryChannels = async (
110
+ request?: QueryChannelsRequest,
111
+ ): Promise<StreamResponse<QueryChannelsResponse>> => {
112
+ const body = {
113
+ limit: request?.limit,
114
+ member_limit: request?.member_limit,
115
+ message_limit: request?.message_limit,
116
+ offset: request?.offset,
117
+ state: request?.state,
118
+ user_id: request?.user_id,
119
+ sort: request?.sort,
120
+ filter_conditions: request?.filter_conditions,
121
+ user: request?.user,
122
+ };
123
+
124
+ const response = await this.sendRequest<
125
+ StreamResponse<QueryChannelsResponse>
126
+ >('POST', '/api/v2/chat/channels', undefined, undefined, body);
127
+
128
+ decoders.QueryChannelsResponse?.(response.body);
129
+
130
+ return { ...response.body, metadata: response.metadata };
131
+ };
132
+
133
+ deleteChannels = async (
134
+ request: DeleteChannelsRequest,
135
+ ): Promise<StreamResponse<DeleteChannelsResponse>> => {
136
+ const body = {
137
+ cids: request?.cids,
138
+ hard_delete: request?.hard_delete,
139
+ };
140
+
141
+ const response = await this.sendRequest<
142
+ StreamResponse<DeleteChannelsResponse>
143
+ >('POST', '/api/v2/chat/channels/delete', undefined, undefined, body);
144
+
145
+ decoders.DeleteChannelsResponse?.(response.body);
146
+
147
+ return { ...response.body, metadata: response.metadata };
148
+ };
149
+
150
+ markChannelsRead = async (
151
+ request?: MarkChannelsReadRequest,
152
+ ): Promise<StreamResponse<MarkReadResponse>> => {
153
+ const body = {
154
+ user_id: request?.user_id,
155
+ read_by_channel: request?.read_by_channel,
156
+ user: request?.user,
157
+ };
158
+
159
+ const response = await this.sendRequest<StreamResponse<MarkReadResponse>>(
160
+ 'POST',
161
+ '/api/v2/chat/channels/read',
162
+ undefined,
163
+ undefined,
164
+ body,
165
+ );
166
+
167
+ decoders.MarkReadResponse?.(response.body);
168
+
169
+ return { ...response.body, metadata: response.metadata };
170
+ };
171
+
172
+ getOrCreateDistinctChannel = async (
173
+ request: ChannelGetOrCreateRequest & { type: string },
174
+ ): Promise<StreamResponse<ChannelStateResponse>> => {
175
+ const pathParams = {
176
+ type: request?.type,
177
+ };
178
+ const body = {
179
+ hide_for_creator: request?.hide_for_creator,
180
+ state: request?.state,
181
+ thread_unread_counts: request?.thread_unread_counts,
182
+ data: request?.data,
183
+ members: request?.members,
184
+ messages: request?.messages,
185
+ watchers: request?.watchers,
186
+ };
187
+
188
+ const response = await this.sendRequest<
189
+ StreamResponse<ChannelStateResponse>
190
+ >(
191
+ 'POST',
192
+ '/api/v2/chat/channels/{type}/query',
193
+ pathParams,
194
+ undefined,
195
+ body,
196
+ );
197
+
198
+ decoders.ChannelStateResponse?.(response.body);
199
+
200
+ return { ...response.body, metadata: response.metadata };
201
+ };
202
+
203
+ deleteChannel = async (request: {
204
+ type: string;
205
+ id: string;
206
+ hard_delete?: boolean;
207
+ }): Promise<StreamResponse<DeleteChannelResponse>> => {
208
+ const queryParams = {
209
+ hard_delete: request?.hard_delete,
210
+ };
211
+ const pathParams = {
212
+ type: request?.type,
213
+ id: request?.id,
214
+ };
215
+
216
+ const response = await this.sendRequest<
217
+ StreamResponse<DeleteChannelResponse>
218
+ >('DELETE', '/api/v2/chat/channels/{type}/{id}', pathParams, queryParams);
219
+
220
+ decoders.DeleteChannelResponse?.(response.body);
221
+
222
+ return { ...response.body, metadata: response.metadata };
223
+ };
224
+
225
+ updateChannelPartial = async (
226
+ request: UpdateChannelPartialRequest & { type: string; id: string },
227
+ ): Promise<StreamResponse<UpdateChannelPartialResponse>> => {
228
+ const pathParams = {
229
+ type: request?.type,
230
+ id: request?.id,
231
+ };
232
+ const body = {
233
+ user_id: request?.user_id,
234
+ unset: request?.unset,
235
+ set: request?.set,
236
+ user: request?.user,
237
+ };
238
+
239
+ const response = await this.sendRequest<
240
+ StreamResponse<UpdateChannelPartialResponse>
241
+ >(
242
+ 'PATCH',
243
+ '/api/v2/chat/channels/{type}/{id}',
244
+ pathParams,
245
+ undefined,
246
+ body,
247
+ );
248
+
249
+ decoders.UpdateChannelPartialResponse?.(response.body);
250
+
251
+ return { ...response.body, metadata: response.metadata };
252
+ };
253
+
254
+ updateChannel = async (
255
+ request: UpdateChannelRequest & { type: string; id: string },
256
+ ): Promise<StreamResponse<UpdateChannelResponse>> => {
257
+ const pathParams = {
258
+ type: request?.type,
259
+ id: request?.id,
260
+ };
261
+ const body = {
262
+ accept_invite: request?.accept_invite,
263
+ cooldown: request?.cooldown,
264
+ hide_history: request?.hide_history,
265
+ reject_invite: request?.reject_invite,
266
+ skip_push: request?.skip_push,
267
+ user_id: request?.user_id,
268
+ add_members: request?.add_members,
269
+ add_moderators: request?.add_moderators,
270
+ assign_roles: request?.assign_roles,
271
+ demote_moderators: request?.demote_moderators,
272
+ invites: request?.invites,
273
+ remove_members: request?.remove_members,
274
+ data: request?.data,
275
+ message: request?.message,
276
+ user: request?.user,
277
+ };
278
+
279
+ const response = await this.sendRequest<
280
+ StreamResponse<UpdateChannelResponse>
281
+ >('POST', '/api/v2/chat/channels/{type}/{id}', pathParams, undefined, body);
282
+
283
+ decoders.UpdateChannelResponse?.(response.body);
284
+
285
+ return { ...response.body, metadata: response.metadata };
286
+ };
287
+
288
+ sendEvent = async (
289
+ request: SendEventRequest & { type: string; id: string },
290
+ ): Promise<StreamResponse<EventResponse>> => {
291
+ const pathParams = {
292
+ type: request?.type,
293
+ id: request?.id,
294
+ };
295
+ const body = {
296
+ event: request?.event,
297
+ };
298
+
299
+ const response = await this.sendRequest<StreamResponse<EventResponse>>(
300
+ 'POST',
301
+ '/api/v2/chat/channels/{type}/{id}/event',
302
+ pathParams,
303
+ undefined,
304
+ body,
305
+ );
306
+
307
+ decoders.EventResponse?.(response.body);
308
+
309
+ return { ...response.body, metadata: response.metadata };
310
+ };
311
+
312
+ deleteFile = async (request: {
313
+ type: string;
314
+ id: string;
315
+ url?: string;
316
+ }): Promise<StreamResponse<Response>> => {
317
+ const queryParams = {
318
+ url: request?.url,
319
+ };
320
+ const pathParams = {
321
+ type: request?.type,
322
+ id: request?.id,
323
+ };
324
+
325
+ const response = await this.sendRequest<StreamResponse<Response>>(
326
+ 'DELETE',
327
+ '/api/v2/chat/channels/{type}/{id}/file',
328
+ pathParams,
329
+ queryParams,
330
+ );
331
+
332
+ decoders.Response?.(response.body);
333
+
334
+ return { ...response.body, metadata: response.metadata };
335
+ };
336
+
337
+ uploadFile = async (
338
+ request: FileUploadRequest & { type: string; id: string },
339
+ ): Promise<StreamResponse<FileUploadResponse>> => {
340
+ const pathParams = {
341
+ type: request?.type,
342
+ id: request?.id,
343
+ };
344
+ const body = {
345
+ file: request?.file,
346
+ user: request?.user,
347
+ };
348
+
349
+ const response = await this.sendRequest<StreamResponse<FileUploadResponse>>(
350
+ 'POST',
351
+ '/api/v2/chat/channels/{type}/{id}/file',
352
+ pathParams,
353
+ undefined,
354
+ body,
355
+ );
356
+
357
+ decoders.FileUploadResponse?.(response.body);
358
+
359
+ return { ...response.body, metadata: response.metadata };
360
+ };
361
+
362
+ hideChannel = async (
363
+ request: HideChannelRequest & { type: string; id: string },
364
+ ): Promise<StreamResponse<HideChannelResponse>> => {
365
+ const pathParams = {
366
+ type: request?.type,
367
+ id: request?.id,
368
+ };
369
+ const body = {
370
+ clear_history: request?.clear_history,
371
+ user_id: request?.user_id,
372
+ user: request?.user,
373
+ };
374
+
375
+ const response = await this.sendRequest<
376
+ StreamResponse<HideChannelResponse>
377
+ >(
378
+ 'POST',
379
+ '/api/v2/chat/channels/{type}/{id}/hide',
380
+ pathParams,
381
+ undefined,
382
+ body,
383
+ );
384
+
385
+ decoders.HideChannelResponse?.(response.body);
386
+
387
+ return { ...response.body, metadata: response.metadata };
388
+ };
389
+
390
+ deleteImage = async (request: {
391
+ type: string;
392
+ id: string;
393
+ url?: string;
394
+ }): Promise<StreamResponse<Response>> => {
395
+ const queryParams = {
396
+ url: request?.url,
397
+ };
398
+ const pathParams = {
399
+ type: request?.type,
400
+ id: request?.id,
401
+ };
402
+
403
+ const response = await this.sendRequest<StreamResponse<Response>>(
404
+ 'DELETE',
405
+ '/api/v2/chat/channels/{type}/{id}/image',
406
+ pathParams,
407
+ queryParams,
408
+ );
409
+
410
+ decoders.Response?.(response.body);
411
+
412
+ return { ...response.body, metadata: response.metadata };
413
+ };
414
+
415
+ uploadImage = async (
416
+ request: ImageUploadRequest & { type: string; id: string },
417
+ ): Promise<StreamResponse<ImageUploadResponse>> => {
418
+ const pathParams = {
419
+ type: request?.type,
420
+ id: request?.id,
421
+ };
422
+ const body = {
423
+ file: request?.file,
424
+ upload_sizes: request?.upload_sizes,
425
+ user: request?.user,
426
+ };
427
+
428
+ const response = await this.sendRequest<
429
+ StreamResponse<ImageUploadResponse>
430
+ >(
431
+ 'POST',
432
+ '/api/v2/chat/channels/{type}/{id}/image',
433
+ pathParams,
434
+ undefined,
435
+ body,
436
+ );
437
+
438
+ decoders.ImageUploadResponse?.(response.body);
439
+
440
+ return { ...response.body, metadata: response.metadata };
441
+ };
442
+
443
+ sendMessage = async (
444
+ request: SendMessageRequest & { type: string; id: string },
445
+ ): Promise<StreamResponse<SendMessageResponse>> => {
446
+ const pathParams = {
447
+ type: request?.type,
448
+ id: request?.id,
449
+ };
450
+ const body = {
451
+ message: request?.message,
452
+ force_moderation: request?.force_moderation,
453
+ keep_channel_hidden: request?.keep_channel_hidden,
454
+ pending: request?.pending,
455
+ skip_enrich_url: request?.skip_enrich_url,
456
+ skip_push: request?.skip_push,
457
+ pending_message_metadata: request?.pending_message_metadata,
458
+ };
459
+
460
+ const response = await this.sendRequest<
461
+ StreamResponse<SendMessageResponse>
462
+ >(
463
+ 'POST',
464
+ '/api/v2/chat/channels/{type}/{id}/message',
465
+ pathParams,
466
+ undefined,
467
+ body,
468
+ );
469
+
470
+ decoders.SendMessageResponse?.(response.body);
471
+
472
+ return { ...response.body, metadata: response.metadata };
473
+ };
474
+
475
+ getManyMessages = async (request: {
476
+ type: string;
477
+ id: string;
478
+ ids: string[];
479
+ }): Promise<StreamResponse<GetManyMessagesResponse>> => {
480
+ const queryParams = {
481
+ ids: request?.ids,
482
+ };
483
+ const pathParams = {
484
+ type: request?.type,
485
+ id: request?.id,
486
+ };
487
+
488
+ const response = await this.sendRequest<
489
+ StreamResponse<GetManyMessagesResponse>
490
+ >(
491
+ 'GET',
492
+ '/api/v2/chat/channels/{type}/{id}/messages',
493
+ pathParams,
494
+ queryParams,
495
+ );
496
+
497
+ decoders.GetManyMessagesResponse?.(response.body);
498
+
499
+ return { ...response.body, metadata: response.metadata };
500
+ };
501
+
502
+ getOrCreateChannel = async (
503
+ request: ChannelGetOrCreateRequest & { type: string; id: string },
504
+ ): Promise<StreamResponse<ChannelStateResponse>> => {
505
+ const pathParams = {
506
+ type: request?.type,
507
+ id: request?.id,
508
+ };
509
+ const body = {
510
+ hide_for_creator: request?.hide_for_creator,
511
+ state: request?.state,
512
+ thread_unread_counts: request?.thread_unread_counts,
513
+ data: request?.data,
514
+ members: request?.members,
515
+ messages: request?.messages,
516
+ watchers: request?.watchers,
517
+ };
518
+
519
+ const response = await this.sendRequest<
520
+ StreamResponse<ChannelStateResponse>
521
+ >(
522
+ 'POST',
523
+ '/api/v2/chat/channels/{type}/{id}/query',
524
+ pathParams,
525
+ undefined,
526
+ body,
527
+ );
528
+
529
+ decoders.ChannelStateResponse?.(response.body);
530
+
531
+ return { ...response.body, metadata: response.metadata };
532
+ };
533
+
534
+ markRead = async (
535
+ request: MarkReadRequest & { type: string; id: string },
536
+ ): Promise<StreamResponse<MarkReadResponse>> => {
537
+ const pathParams = {
538
+ type: request?.type,
539
+ id: request?.id,
540
+ };
541
+ const body = {
542
+ message_id: request?.message_id,
543
+ thread_id: request?.thread_id,
544
+ user_id: request?.user_id,
545
+ user: request?.user,
546
+ };
547
+
548
+ const response = await this.sendRequest<StreamResponse<MarkReadResponse>>(
549
+ 'POST',
550
+ '/api/v2/chat/channels/{type}/{id}/read',
551
+ pathParams,
552
+ undefined,
553
+ body,
554
+ );
555
+
556
+ decoders.MarkReadResponse?.(response.body);
557
+
558
+ return { ...response.body, metadata: response.metadata };
559
+ };
560
+
561
+ showChannel = async (
562
+ request: ShowChannelRequest & { type: string; id: string },
563
+ ): Promise<StreamResponse<ShowChannelResponse>> => {
564
+ const pathParams = {
565
+ type: request?.type,
566
+ id: request?.id,
567
+ };
568
+ const body = {
569
+ user_id: request?.user_id,
570
+ user: request?.user,
571
+ };
572
+
573
+ const response = await this.sendRequest<
574
+ StreamResponse<ShowChannelResponse>
575
+ >(
576
+ 'POST',
577
+ '/api/v2/chat/channels/{type}/{id}/show',
578
+ pathParams,
579
+ undefined,
580
+ body,
581
+ );
582
+
583
+ decoders.ShowChannelResponse?.(response.body);
584
+
585
+ return { ...response.body, metadata: response.metadata };
586
+ };
587
+
588
+ truncateChannel = async (
589
+ request: TruncateChannelRequest & { type: string; id: string },
590
+ ): Promise<StreamResponse<TruncateChannelResponse>> => {
591
+ const pathParams = {
592
+ type: request?.type,
593
+ id: request?.id,
594
+ };
595
+ const body = {
596
+ hard_delete: request?.hard_delete,
597
+ skip_push: request?.skip_push,
598
+ truncated_at: request?.truncated_at,
599
+ user_id: request?.user_id,
600
+ message: request?.message,
601
+ user: request?.user,
602
+ };
603
+
604
+ const response = await this.sendRequest<
605
+ StreamResponse<TruncateChannelResponse>
606
+ >(
607
+ 'POST',
608
+ '/api/v2/chat/channels/{type}/{id}/truncate',
609
+ pathParams,
610
+ undefined,
611
+ body,
612
+ );
613
+
614
+ decoders.TruncateChannelResponse?.(response.body);
615
+
616
+ return { ...response.body, metadata: response.metadata };
617
+ };
618
+
619
+ markUnread = async (
620
+ request: MarkUnreadRequest & { type: string; id: string },
621
+ ): Promise<StreamResponse<Response>> => {
622
+ const pathParams = {
623
+ type: request?.type,
624
+ id: request?.id,
625
+ };
626
+ const body = {
627
+ message_id: request?.message_id,
628
+ thread_id: request?.thread_id,
629
+ user_id: request?.user_id,
630
+ user: request?.user,
631
+ };
632
+
633
+ const response = await this.sendRequest<StreamResponse<Response>>(
634
+ 'POST',
635
+ '/api/v2/chat/channels/{type}/{id}/unread',
636
+ pathParams,
637
+ undefined,
638
+ body,
639
+ );
640
+
641
+ decoders.Response?.(response.body);
642
+
643
+ return { ...response.body, metadata: response.metadata };
644
+ };
645
+
646
+ listChannelTypes = async (): Promise<
647
+ StreamResponse<ListChannelTypesResponse>
648
+ > => {
649
+ const response = await this.sendRequest<
650
+ StreamResponse<ListChannelTypesResponse>
651
+ >('GET', '/api/v2/chat/channeltypes', undefined, undefined);
652
+
653
+ decoders.ListChannelTypesResponse?.(response.body);
654
+
655
+ return { ...response.body, metadata: response.metadata };
656
+ };
657
+
658
+ createChannelType = async (
659
+ request: CreateChannelTypeRequest,
660
+ ): Promise<StreamResponse<CreateChannelTypeResponse>> => {
661
+ const body = {
662
+ automod: request?.automod,
663
+ automod_behavior: request?.automod_behavior,
664
+ max_message_length: request?.max_message_length,
665
+ name: request?.name,
666
+ blocklist: request?.blocklist,
667
+ blocklist_behavior: request?.blocklist_behavior,
668
+ connect_events: request?.connect_events,
669
+ custom_events: request?.custom_events,
670
+ mark_messages_pending: request?.mark_messages_pending,
671
+ message_retention: request?.message_retention,
672
+ mutes: request?.mutes,
673
+ partition_size: request?.partition_size,
674
+ partition_ttl: request?.partition_ttl,
675
+ polls: request?.polls,
676
+ push_notifications: request?.push_notifications,
677
+ reactions: request?.reactions,
678
+ read_events: request?.read_events,
679
+ replies: request?.replies,
680
+ search: request?.search,
681
+ typing_events: request?.typing_events,
682
+ uploads: request?.uploads,
683
+ url_enrichment: request?.url_enrichment,
684
+ blocklists: request?.blocklists,
685
+ commands: request?.commands,
686
+ permissions: request?.permissions,
687
+ grants: request?.grants,
688
+ };
689
+
690
+ const response = await this.sendRequest<
691
+ StreamResponse<CreateChannelTypeResponse>
692
+ >('POST', '/api/v2/chat/channeltypes', undefined, undefined, body);
693
+
694
+ decoders.CreateChannelTypeResponse?.(response.body);
695
+
696
+ return { ...response.body, metadata: response.metadata };
697
+ };
698
+
699
+ deleteChannelType = async (request: {
700
+ name: string;
701
+ }): Promise<StreamResponse<Response>> => {
702
+ const pathParams = {
703
+ name: request?.name,
704
+ };
705
+
706
+ const response = await this.sendRequest<StreamResponse<Response>>(
707
+ 'DELETE',
708
+ '/api/v2/chat/channeltypes/{name}',
709
+ pathParams,
710
+ undefined,
711
+ );
712
+
713
+ decoders.Response?.(response.body);
714
+
715
+ return { ...response.body, metadata: response.metadata };
716
+ };
717
+
718
+ getChannelType = async (request: {
719
+ name: string;
720
+ }): Promise<StreamResponse<GetChannelTypeResponse>> => {
721
+ const pathParams = {
722
+ name: request?.name,
723
+ };
724
+
725
+ const response = await this.sendRequest<
726
+ StreamResponse<GetChannelTypeResponse>
727
+ >('GET', '/api/v2/chat/channeltypes/{name}', pathParams, undefined);
728
+
729
+ decoders.GetChannelTypeResponse?.(response.body);
730
+
731
+ return { ...response.body, metadata: response.metadata };
732
+ };
733
+
734
+ updateChannelType = async (
735
+ request: UpdateChannelTypeRequest & { name: string },
736
+ ): Promise<StreamResponse<UpdateChannelTypeResponse>> => {
737
+ const pathParams = {
738
+ name: request?.name,
739
+ };
740
+ const body = {
741
+ automod: request?.automod,
742
+ automod_behavior: request?.automod_behavior,
743
+ max_message_length: request?.max_message_length,
744
+ blocklist: request?.blocklist,
745
+ blocklist_behavior: request?.blocklist_behavior,
746
+ connect_events: request?.connect_events,
747
+ custom_events: request?.custom_events,
748
+ mark_messages_pending: request?.mark_messages_pending,
749
+ mutes: request?.mutes,
750
+ partition_size: request?.partition_size,
751
+ partition_ttl: request?.partition_ttl,
752
+ polls: request?.polls,
753
+ push_notifications: request?.push_notifications,
754
+ quotes: request?.quotes,
755
+ reactions: request?.reactions,
756
+ read_events: request?.read_events,
757
+ reminders: request?.reminders,
758
+ replies: request?.replies,
759
+ search: request?.search,
760
+ typing_events: request?.typing_events,
761
+ uploads: request?.uploads,
762
+ url_enrichment: request?.url_enrichment,
763
+ allowed_flag_reasons: request?.allowed_flag_reasons,
764
+ blocklists: request?.blocklists,
765
+ commands: request?.commands,
766
+ permissions: request?.permissions,
767
+ automod_thresholds: request?.automod_thresholds,
768
+ grants: request?.grants,
769
+ };
770
+
771
+ const response = await this.sendRequest<
772
+ StreamResponse<UpdateChannelTypeResponse>
773
+ >('PUT', '/api/v2/chat/channeltypes/{name}', pathParams, undefined, body);
774
+
775
+ decoders.UpdateChannelTypeResponse?.(response.body);
776
+
777
+ return { ...response.body, metadata: response.metadata };
778
+ };
779
+
780
+ listCommands = async (): Promise<StreamResponse<ListCommandsResponse>> => {
781
+ const response = await this.sendRequest<
782
+ StreamResponse<ListCommandsResponse>
783
+ >('GET', '/api/v2/chat/commands', undefined, undefined);
784
+
785
+ decoders.ListCommandsResponse?.(response.body);
786
+
787
+ return { ...response.body, metadata: response.metadata };
788
+ };
789
+
790
+ createCommand = async (
791
+ request: CreateCommandRequest,
792
+ ): Promise<StreamResponse<CreateCommandResponse>> => {
793
+ const body = {
794
+ description: request?.description,
795
+ name: request?.name,
796
+ args: request?.args,
797
+ set: request?.set,
798
+ };
799
+
800
+ const response = await this.sendRequest<
801
+ StreamResponse<CreateCommandResponse>
802
+ >('POST', '/api/v2/chat/commands', undefined, undefined, body);
803
+
804
+ decoders.CreateCommandResponse?.(response.body);
805
+
806
+ return { ...response.body, metadata: response.metadata };
807
+ };
808
+
809
+ deleteCommand = async (request: {
810
+ name: string;
811
+ }): Promise<StreamResponse<DeleteCommandResponse>> => {
812
+ const pathParams = {
813
+ name: request?.name,
814
+ };
815
+
816
+ const response = await this.sendRequest<
817
+ StreamResponse<DeleteCommandResponse>
818
+ >('DELETE', '/api/v2/chat/commands/{name}', pathParams, undefined);
819
+
820
+ decoders.DeleteCommandResponse?.(response.body);
821
+
822
+ return { ...response.body, metadata: response.metadata };
823
+ };
824
+
825
+ getCommand = async (request: {
826
+ name: string;
827
+ }): Promise<StreamResponse<GetCommandResponse>> => {
828
+ const pathParams = {
829
+ name: request?.name,
830
+ };
831
+
832
+ const response = await this.sendRequest<StreamResponse<GetCommandResponse>>(
833
+ 'GET',
834
+ '/api/v2/chat/commands/{name}',
835
+ pathParams,
836
+ undefined,
837
+ );
838
+
839
+ decoders.GetCommandResponse?.(response.body);
840
+
841
+ return { ...response.body, metadata: response.metadata };
842
+ };
843
+
844
+ updateCommand = async (
845
+ request: UpdateCommandRequest & { name: string },
846
+ ): Promise<StreamResponse<UpdateCommandResponse>> => {
847
+ const pathParams = {
848
+ name: request?.name,
849
+ };
850
+ const body = {
851
+ description: request?.description,
852
+ args: request?.args,
853
+ set: request?.set,
854
+ };
855
+
856
+ const response = await this.sendRequest<
857
+ StreamResponse<UpdateCommandResponse>
858
+ >('PUT', '/api/v2/chat/commands/{name}', pathParams, undefined, body);
859
+
860
+ decoders.UpdateCommandResponse?.(response.body);
861
+
862
+ return { ...response.body, metadata: response.metadata };
863
+ };
864
+
865
+ exportChannels = async (
866
+ request: ExportChannelsRequest,
867
+ ): Promise<StreamResponse<ExportChannelsResponse>> => {
868
+ const body = {
869
+ channels: request?.channels,
870
+ clear_deleted_message_text: request?.clear_deleted_message_text,
871
+ export_users: request?.export_users,
872
+ include_soft_deleted_channels: request?.include_soft_deleted_channels,
873
+ include_truncated_messages: request?.include_truncated_messages,
874
+ version: request?.version,
875
+ };
876
+
877
+ const response = await this.sendRequest<
878
+ StreamResponse<ExportChannelsResponse>
879
+ >('POST', '/api/v2/chat/export_channels', undefined, undefined, body);
880
+
881
+ decoders.ExportChannelsResponse?.(response.body);
882
+
883
+ return { ...response.body, metadata: response.metadata };
884
+ };
885
+
886
+ getExportChannelsStatus = async (request: {
887
+ id: string;
888
+ }): Promise<StreamResponse<GetExportChannelsStatusResponse>> => {
889
+ const pathParams = {
890
+ id: request?.id,
891
+ };
892
+
893
+ const response = await this.sendRequest<
894
+ StreamResponse<GetExportChannelsStatusResponse>
895
+ >('GET', '/api/v2/chat/export_channels/{id}', pathParams, undefined);
896
+
897
+ decoders.GetExportChannelsStatusResponse?.(response.body);
898
+
899
+ return { ...response.body, metadata: response.metadata };
900
+ };
901
+
902
+ queryMembers = async (request?: {
903
+ payload?: QueryMembersRequest;
904
+ }): Promise<StreamResponse<MembersResponse>> => {
905
+ const queryParams = {
906
+ payload: request?.payload,
907
+ };
908
+
909
+ const response = await this.sendRequest<StreamResponse<MembersResponse>>(
910
+ 'GET',
911
+ '/api/v2/chat/members',
912
+ undefined,
913
+ queryParams,
914
+ );
915
+
916
+ decoders.MembersResponse?.(response.body);
917
+
918
+ return { ...response.body, metadata: response.metadata };
919
+ };
920
+
921
+ queryMessageHistory = async (
922
+ request: QueryMessageHistoryRequest,
923
+ ): Promise<StreamResponse<QueryMessageHistoryResponse>> => {
924
+ const body = {
925
+ filter: request?.filter,
926
+ limit: request?.limit,
927
+ next: request?.next,
928
+ prev: request?.prev,
929
+ sort: request?.sort,
930
+ };
931
+
932
+ const response = await this.sendRequest<
933
+ StreamResponse<QueryMessageHistoryResponse>
934
+ >('POST', '/api/v2/chat/messages/history', undefined, undefined, body);
935
+
936
+ decoders.QueryMessageHistoryResponse?.(response.body);
937
+
938
+ return { ...response.body, metadata: response.metadata };
939
+ };
940
+
941
+ deleteMessage = async (request: {
942
+ id: string;
943
+ hard?: boolean;
944
+ deleted_by?: string;
945
+ }): Promise<StreamResponse<DeleteMessageResponse>> => {
946
+ const queryParams = {
947
+ hard: request?.hard,
948
+ deleted_by: request?.deleted_by,
949
+ };
950
+ const pathParams = {
951
+ id: request?.id,
952
+ };
953
+
954
+ const response = await this.sendRequest<
955
+ StreamResponse<DeleteMessageResponse>
956
+ >('DELETE', '/api/v2/chat/messages/{id}', pathParams, queryParams);
957
+
958
+ decoders.DeleteMessageResponse?.(response.body);
959
+
960
+ return { ...response.body, metadata: response.metadata };
961
+ };
962
+
963
+ getMessage = async (request: {
964
+ id: string;
965
+ show_deleted_message?: boolean;
966
+ }): Promise<StreamResponse<GetMessageResponse>> => {
967
+ const queryParams = {
968
+ show_deleted_message: request?.show_deleted_message,
969
+ };
970
+ const pathParams = {
971
+ id: request?.id,
972
+ };
973
+
974
+ const response = await this.sendRequest<StreamResponse<GetMessageResponse>>(
975
+ 'GET',
976
+ '/api/v2/chat/messages/{id}',
977
+ pathParams,
978
+ queryParams,
979
+ );
980
+
981
+ decoders.GetMessageResponse?.(response.body);
982
+
983
+ return { ...response.body, metadata: response.metadata };
984
+ };
985
+
986
+ updateMessage = async (
987
+ request: UpdateMessageRequest & { id: string },
988
+ ): Promise<StreamResponse<UpdateMessageResponse>> => {
989
+ const pathParams = {
990
+ id: request?.id,
991
+ };
992
+ const body = {
993
+ message: request?.message,
994
+ skip_enrich_url: request?.skip_enrich_url,
995
+ };
996
+
997
+ const response = await this.sendRequest<
998
+ StreamResponse<UpdateMessageResponse>
999
+ >('POST', '/api/v2/chat/messages/{id}', pathParams, undefined, body);
1000
+
1001
+ decoders.UpdateMessageResponse?.(response.body);
1002
+
1003
+ return { ...response.body, metadata: response.metadata };
1004
+ };
1005
+
1006
+ updateMessagePartial = async (
1007
+ request: UpdateMessagePartialRequest & { id: string },
1008
+ ): Promise<StreamResponse<UpdateMessagePartialResponse>> => {
1009
+ const pathParams = {
1010
+ id: request?.id,
1011
+ };
1012
+ const body = {
1013
+ skip_enrich_url: request?.skip_enrich_url,
1014
+ user_id: request?.user_id,
1015
+ unset: request?.unset,
1016
+ set: request?.set,
1017
+ user: request?.user,
1018
+ };
1019
+
1020
+ const response = await this.sendRequest<
1021
+ StreamResponse<UpdateMessagePartialResponse>
1022
+ >('PUT', '/api/v2/chat/messages/{id}', pathParams, undefined, body);
1023
+
1024
+ decoders.UpdateMessagePartialResponse?.(response.body);
1025
+
1026
+ return { ...response.body, metadata: response.metadata };
1027
+ };
1028
+
1029
+ runMessageAction = async (
1030
+ request: MessageActionRequest & { id: string },
1031
+ ): Promise<StreamResponse<MessageResponse>> => {
1032
+ const pathParams = {
1033
+ id: request?.id,
1034
+ };
1035
+ const body = {
1036
+ form_data: request?.form_data,
1037
+ user_id: request?.user_id,
1038
+ user: request?.user,
1039
+ };
1040
+
1041
+ const response = await this.sendRequest<StreamResponse<MessageResponse>>(
1042
+ 'POST',
1043
+ '/api/v2/chat/messages/{id}/action',
1044
+ pathParams,
1045
+ undefined,
1046
+ body,
1047
+ );
1048
+
1049
+ decoders.MessageResponse?.(response.body);
1050
+
1051
+ return { ...response.body, metadata: response.metadata };
1052
+ };
1053
+
1054
+ commitMessage = async (
1055
+ request: CommitMessageRequest & { id: string },
1056
+ ): Promise<StreamResponse<MessageResponse>> => {
1057
+ const pathParams = {
1058
+ id: request?.id,
1059
+ };
1060
+ const body = {};
1061
+
1062
+ const response = await this.sendRequest<StreamResponse<MessageResponse>>(
1063
+ 'POST',
1064
+ '/api/v2/chat/messages/{id}/commit',
1065
+ pathParams,
1066
+ undefined,
1067
+ body,
1068
+ );
1069
+
1070
+ decoders.MessageResponse?.(response.body);
1071
+
1072
+ return { ...response.body, metadata: response.metadata };
1073
+ };
1074
+
1075
+ sendReaction = async (
1076
+ request: SendReactionRequest & { id: string },
1077
+ ): Promise<StreamResponse<SendReactionResponse>> => {
1078
+ const pathParams = {
1079
+ id: request?.id,
1080
+ };
1081
+ const body = {
1082
+ reaction: request?.reaction,
1083
+ enforce_unique: request?.enforce_unique,
1084
+ skip_push: request?.skip_push,
1085
+ };
1086
+
1087
+ const response = await this.sendRequest<
1088
+ StreamResponse<SendReactionResponse>
1089
+ >(
1090
+ 'POST',
1091
+ '/api/v2/chat/messages/{id}/reaction',
1092
+ pathParams,
1093
+ undefined,
1094
+ body,
1095
+ );
1096
+
1097
+ decoders.SendReactionResponse?.(response.body);
1098
+
1099
+ return { ...response.body, metadata: response.metadata };
1100
+ };
1101
+
1102
+ deleteReaction = async (request: {
1103
+ id: string;
1104
+ type: string;
1105
+ user_id?: string;
1106
+ }): Promise<StreamResponse<ReactionRemovalResponse>> => {
1107
+ const queryParams = {
1108
+ user_id: request?.user_id,
1109
+ };
1110
+ const pathParams = {
1111
+ id: request?.id,
1112
+ type: request?.type,
1113
+ };
1114
+
1115
+ const response = await this.sendRequest<
1116
+ StreamResponse<ReactionRemovalResponse>
1117
+ >(
1118
+ 'DELETE',
1119
+ '/api/v2/chat/messages/{id}/reaction/{type}',
1120
+ pathParams,
1121
+ queryParams,
1122
+ );
1123
+
1124
+ decoders.ReactionRemovalResponse?.(response.body);
1125
+
1126
+ return { ...response.body, metadata: response.metadata };
1127
+ };
1128
+
1129
+ getReactions = async (request: {
1130
+ id: string;
1131
+ limit?: number;
1132
+ offset?: number;
1133
+ }): Promise<StreamResponse<GetReactionsResponse>> => {
1134
+ const queryParams = {
1135
+ limit: request?.limit,
1136
+ offset: request?.offset,
1137
+ };
1138
+ const pathParams = {
1139
+ id: request?.id,
1140
+ };
1141
+
1142
+ const response = await this.sendRequest<
1143
+ StreamResponse<GetReactionsResponse>
1144
+ >('GET', '/api/v2/chat/messages/{id}/reactions', pathParams, queryParams);
1145
+
1146
+ decoders.GetReactionsResponse?.(response.body);
1147
+
1148
+ return { ...response.body, metadata: response.metadata };
1149
+ };
1150
+
1151
+ queryReactions = async (
1152
+ request: QueryReactionsRequest & { id: string },
1153
+ ): Promise<StreamResponse<QueryReactionsResponse>> => {
1154
+ const pathParams = {
1155
+ id: request?.id,
1156
+ };
1157
+ const body = {
1158
+ limit: request?.limit,
1159
+ next: request?.next,
1160
+ prev: request?.prev,
1161
+ user_id: request?.user_id,
1162
+ sort: request?.sort,
1163
+ filter: request?.filter,
1164
+ user: request?.user,
1165
+ };
1166
+
1167
+ const response = await this.sendRequest<
1168
+ StreamResponse<QueryReactionsResponse>
1169
+ >(
1170
+ 'POST',
1171
+ '/api/v2/chat/messages/{id}/reactions',
1172
+ pathParams,
1173
+ undefined,
1174
+ body,
1175
+ );
1176
+
1177
+ decoders.QueryReactionsResponse?.(response.body);
1178
+
1179
+ return { ...response.body, metadata: response.metadata };
1180
+ };
1181
+
1182
+ translateMessage = async (
1183
+ request: TranslateMessageRequest & { id: string },
1184
+ ): Promise<StreamResponse<MessageResponse>> => {
1185
+ const pathParams = {
1186
+ id: request?.id,
1187
+ };
1188
+ const body = {
1189
+ language: request?.language,
1190
+ };
1191
+
1192
+ const response = await this.sendRequest<StreamResponse<MessageResponse>>(
1193
+ 'POST',
1194
+ '/api/v2/chat/messages/{id}/translate',
1195
+ pathParams,
1196
+ undefined,
1197
+ body,
1198
+ );
1199
+
1200
+ decoders.MessageResponse?.(response.body);
1201
+
1202
+ return { ...response.body, metadata: response.metadata };
1203
+ };
1204
+
1205
+ undeleteMessage = async (
1206
+ request: UpdateMessageRequest & { id: string },
1207
+ ): Promise<StreamResponse<UpdateMessageResponse>> => {
1208
+ const pathParams = {
1209
+ id: request?.id,
1210
+ };
1211
+ const body = {
1212
+ message: request?.message,
1213
+ skip_enrich_url: request?.skip_enrich_url,
1214
+ };
1215
+
1216
+ const response = await this.sendRequest<
1217
+ StreamResponse<UpdateMessageResponse>
1218
+ >(
1219
+ 'POST',
1220
+ '/api/v2/chat/messages/{id}/undelete',
1221
+ pathParams,
1222
+ undefined,
1223
+ body,
1224
+ );
1225
+
1226
+ decoders.UpdateMessageResponse?.(response.body);
1227
+
1228
+ return { ...response.body, metadata: response.metadata };
1229
+ };
1230
+
1231
+ castPollVote = async (
1232
+ request: CastPollVoteRequest & { message_id: string; poll_id: string },
1233
+ ): Promise<StreamResponse<PollVoteResponse>> => {
1234
+ const pathParams = {
1235
+ message_id: request?.message_id,
1236
+ poll_id: request?.poll_id,
1237
+ };
1238
+ const body = {
1239
+ user_id: request?.user_id,
1240
+ user: request?.user,
1241
+ vote: request?.vote,
1242
+ };
1243
+
1244
+ const response = await this.sendRequest<StreamResponse<PollVoteResponse>>(
1245
+ 'POST',
1246
+ '/api/v2/chat/messages/{message_id}/polls/{poll_id}/vote',
1247
+ pathParams,
1248
+ undefined,
1249
+ body,
1250
+ );
1251
+
1252
+ decoders.PollVoteResponse?.(response.body);
1253
+
1254
+ return { ...response.body, metadata: response.metadata };
1255
+ };
1256
+
1257
+ removePollVote = async (request: {
1258
+ message_id: string;
1259
+ poll_id: string;
1260
+ vote_id: string;
1261
+ user_id?: string;
1262
+ }): Promise<StreamResponse<PollVoteResponse>> => {
1263
+ const queryParams = {
1264
+ user_id: request?.user_id,
1265
+ };
1266
+ const pathParams = {
1267
+ message_id: request?.message_id,
1268
+ poll_id: request?.poll_id,
1269
+ vote_id: request?.vote_id,
1270
+ };
1271
+
1272
+ const response = await this.sendRequest<StreamResponse<PollVoteResponse>>(
1273
+ 'DELETE',
1274
+ '/api/v2/chat/messages/{message_id}/polls/{poll_id}/vote/{vote_id}',
1275
+ pathParams,
1276
+ queryParams,
1277
+ );
1278
+
1279
+ decoders.PollVoteResponse?.(response.body);
1280
+
1281
+ return { ...response.body, metadata: response.metadata };
1282
+ };
1283
+
1284
+ getReplies = async (request: {
1285
+ parent_id: string;
1286
+ limit?: number;
1287
+ offset?: number;
1288
+ id_gte?: string;
1289
+ id_gt?: string;
1290
+ id_lte?: string;
1291
+ id_lt?: string;
1292
+ created_at_after_or_equal?: Date;
1293
+ created_at_after?: Date;
1294
+ created_at_before_or_equal?: Date;
1295
+ created_at_before?: Date;
1296
+ id_around?: string;
1297
+ created_at_around?: Date;
1298
+ sort?: SortParamRequest[];
1299
+ }): Promise<StreamResponse<GetRepliesResponse>> => {
1300
+ const queryParams = {
1301
+ limit: request?.limit,
1302
+ offset: request?.offset,
1303
+ id_gte: request?.id_gte,
1304
+ id_gt: request?.id_gt,
1305
+ id_lte: request?.id_lte,
1306
+ id_lt: request?.id_lt,
1307
+ created_at_after_or_equal: request?.created_at_after_or_equal,
1308
+ created_at_after: request?.created_at_after,
1309
+ created_at_before_or_equal: request?.created_at_before_or_equal,
1310
+ created_at_before: request?.created_at_before,
1311
+ id_around: request?.id_around,
1312
+ created_at_around: request?.created_at_around,
1313
+ sort: request?.sort,
1314
+ };
1315
+ const pathParams = {
1316
+ parent_id: request?.parent_id,
1317
+ };
1318
+
1319
+ const response = await this.sendRequest<StreamResponse<GetRepliesResponse>>(
1320
+ 'GET',
1321
+ '/api/v2/chat/messages/{parent_id}/replies',
1322
+ pathParams,
1323
+ queryParams,
1324
+ );
1325
+
1326
+ decoders.GetRepliesResponse?.(response.body);
1327
+
1328
+ return { ...response.body, metadata: response.metadata };
1329
+ };
1330
+
1331
+ queryMessageFlags = async (request?: {
1332
+ payload?: QueryMessageFlagsRequest;
1333
+ }): Promise<StreamResponse<QueryMessageFlagsResponse>> => {
1334
+ const queryParams = {
1335
+ payload: request?.payload,
1336
+ };
1337
+
1338
+ const response = await this.sendRequest<
1339
+ StreamResponse<QueryMessageFlagsResponse>
1340
+ >('GET', '/api/v2/chat/moderation/flags/message', undefined, queryParams);
1341
+
1342
+ decoders.QueryMessageFlagsResponse?.(response.body);
1343
+
1344
+ return { ...response.body, metadata: response.metadata };
1345
+ };
1346
+
1347
+ muteChannel = async (
1348
+ request?: MuteChannelRequest,
1349
+ ): Promise<StreamResponse<MuteChannelResponse>> => {
1350
+ const body = {
1351
+ expiration: request?.expiration,
1352
+ user_id: request?.user_id,
1353
+ channel_cids: request?.channel_cids,
1354
+ user: request?.user,
1355
+ };
1356
+
1357
+ const response = await this.sendRequest<
1358
+ StreamResponse<MuteChannelResponse>
1359
+ >(
1360
+ 'POST',
1361
+ '/api/v2/chat/moderation/mute/channel',
1362
+ undefined,
1363
+ undefined,
1364
+ body,
1365
+ );
1366
+
1367
+ decoders.MuteChannelResponse?.(response.body);
1368
+
1369
+ return { ...response.body, metadata: response.metadata };
1370
+ };
1371
+
1372
+ unmuteChannel = async (
1373
+ request?: UnmuteChannelRequest,
1374
+ ): Promise<StreamResponse<UnmuteResponse>> => {
1375
+ const body = {
1376
+ expiration: request?.expiration,
1377
+ user_id: request?.user_id,
1378
+ channel_cids: request?.channel_cids,
1379
+ user: request?.user,
1380
+ };
1381
+
1382
+ const response = await this.sendRequest<StreamResponse<UnmuteResponse>>(
1383
+ 'POST',
1384
+ '/api/v2/chat/moderation/unmute/channel',
1385
+ undefined,
1386
+ undefined,
1387
+ body,
1388
+ );
1389
+
1390
+ decoders.UnmuteResponse?.(response.body);
1391
+
1392
+ return { ...response.body, metadata: response.metadata };
1393
+ };
1394
+
1395
+ createPoll = async (
1396
+ request: CreatePollRequest,
1397
+ ): Promise<StreamResponse<PollResponse>> => {
1398
+ const body = {
1399
+ name: request?.name,
1400
+ allow_answers: request?.allow_answers,
1401
+ allow_user_suggested_options: request?.allow_user_suggested_options,
1402
+ description: request?.description,
1403
+ enforce_unique_vote: request?.enforce_unique_vote,
1404
+ id: request?.id,
1405
+ is_closed: request?.is_closed,
1406
+ max_votes_allowed: request?.max_votes_allowed,
1407
+ user_id: request?.user_id,
1408
+ voting_visibility: request?.voting_visibility,
1409
+ options: request?.options,
1410
+ custom: request?.custom,
1411
+ user: request?.user,
1412
+ };
1413
+
1414
+ const response = await this.sendRequest<StreamResponse<PollResponse>>(
1415
+ 'POST',
1416
+ '/api/v2/chat/polls',
1417
+ undefined,
1418
+ undefined,
1419
+ body,
1420
+ );
1421
+
1422
+ decoders.PollResponse?.(response.body);
1423
+
1424
+ return { ...response.body, metadata: response.metadata };
1425
+ };
1426
+
1427
+ updatePoll = async (
1428
+ request: UpdatePollRequest,
1429
+ ): Promise<StreamResponse<PollResponse>> => {
1430
+ const body = {
1431
+ id: request?.id,
1432
+ name: request?.name,
1433
+ allow_answers: request?.allow_answers,
1434
+ allow_user_suggested_options: request?.allow_user_suggested_options,
1435
+ description: request?.description,
1436
+ enforce_unique_vote: request?.enforce_unique_vote,
1437
+ is_closed: request?.is_closed,
1438
+ max_votes_allowed: request?.max_votes_allowed,
1439
+ user_id: request?.user_id,
1440
+ voting_visibility: request?.voting_visibility,
1441
+ options: request?.options,
1442
+ custom: request?.custom,
1443
+ user: request?.user,
1444
+ };
1445
+
1446
+ const response = await this.sendRequest<StreamResponse<PollResponse>>(
1447
+ 'PUT',
1448
+ '/api/v2/chat/polls',
1449
+ undefined,
1450
+ undefined,
1451
+ body,
1452
+ );
1453
+
1454
+ decoders.PollResponse?.(response.body);
1455
+
1456
+ return { ...response.body, metadata: response.metadata };
1457
+ };
1458
+
1459
+ queryPolls = async (
1460
+ request?: QueryPollsRequest & { user_id?: string },
1461
+ ): Promise<StreamResponse<QueryPollsResponse>> => {
1462
+ const queryParams = {
1463
+ user_id: request?.user_id,
1464
+ };
1465
+ const body = {
1466
+ limit: request?.limit,
1467
+ next: request?.next,
1468
+ prev: request?.prev,
1469
+ sort: request?.sort,
1470
+ filter: request?.filter,
1471
+ };
1472
+
1473
+ const response = await this.sendRequest<StreamResponse<QueryPollsResponse>>(
1474
+ 'POST',
1475
+ '/api/v2/chat/polls/query',
1476
+ undefined,
1477
+ queryParams,
1478
+ body,
1479
+ );
1480
+
1481
+ decoders.QueryPollsResponse?.(response.body);
1482
+
1483
+ return { ...response.body, metadata: response.metadata };
1484
+ };
1485
+
1486
+ deletePoll = async (request: {
1487
+ poll_id: string;
1488
+ user_id?: string;
1489
+ }): Promise<StreamResponse<Response>> => {
1490
+ const queryParams = {
1491
+ user_id: request?.user_id,
1492
+ };
1493
+ const pathParams = {
1494
+ poll_id: request?.poll_id,
1495
+ };
1496
+
1497
+ const response = await this.sendRequest<StreamResponse<Response>>(
1498
+ 'DELETE',
1499
+ '/api/v2/chat/polls/{poll_id}',
1500
+ pathParams,
1501
+ queryParams,
1502
+ );
1503
+
1504
+ decoders.Response?.(response.body);
1505
+
1506
+ return { ...response.body, metadata: response.metadata };
1507
+ };
1508
+
1509
+ getPoll = async (request: {
1510
+ poll_id: string;
1511
+ user_id?: string;
1512
+ }): Promise<StreamResponse<PollResponse>> => {
1513
+ const queryParams = {
1514
+ user_id: request?.user_id,
1515
+ };
1516
+ const pathParams = {
1517
+ poll_id: request?.poll_id,
1518
+ };
1519
+
1520
+ const response = await this.sendRequest<StreamResponse<PollResponse>>(
1521
+ 'GET',
1522
+ '/api/v2/chat/polls/{poll_id}',
1523
+ pathParams,
1524
+ queryParams,
1525
+ );
1526
+
1527
+ decoders.PollResponse?.(response.body);
1528
+
1529
+ return { ...response.body, metadata: response.metadata };
1530
+ };
1531
+
1532
+ updatePollPartial = async (
1533
+ request: UpdatePollPartialRequest & { poll_id: string },
1534
+ ): Promise<StreamResponse<PollResponse>> => {
1535
+ const pathParams = {
1536
+ poll_id: request?.poll_id,
1537
+ };
1538
+ const body = {
1539
+ user_id: request?.user_id,
1540
+ unset: request?.unset,
1541
+ set: request?.set,
1542
+ user: request?.user,
1543
+ };
1544
+
1545
+ const response = await this.sendRequest<StreamResponse<PollResponse>>(
1546
+ 'PATCH',
1547
+ '/api/v2/chat/polls/{poll_id}',
1548
+ pathParams,
1549
+ undefined,
1550
+ body,
1551
+ );
1552
+
1553
+ decoders.PollResponse?.(response.body);
1554
+
1555
+ return { ...response.body, metadata: response.metadata };
1556
+ };
1557
+
1558
+ createPollOption = async (
1559
+ request: CreatePollOptionRequest & { poll_id: string },
1560
+ ): Promise<StreamResponse<PollOptionResponse>> => {
1561
+ const pathParams = {
1562
+ poll_id: request?.poll_id,
1563
+ };
1564
+ const body = {
1565
+ text: request?.text,
1566
+ position: request?.position,
1567
+ user_id: request?.user_id,
1568
+ custom: request?.custom,
1569
+ user: request?.user,
1570
+ };
1571
+
1572
+ const response = await this.sendRequest<StreamResponse<PollOptionResponse>>(
1573
+ 'POST',
1574
+ '/api/v2/chat/polls/{poll_id}/options',
1575
+ pathParams,
1576
+ undefined,
1577
+ body,
1578
+ );
1579
+
1580
+ decoders.PollOptionResponse?.(response.body);
1581
+
1582
+ return { ...response.body, metadata: response.metadata };
1583
+ };
1584
+
1585
+ updatePollOption = async (
1586
+ request: UpdatePollOptionRequest & { poll_id: string },
1587
+ ): Promise<StreamResponse<PollOptionResponse>> => {
1588
+ const pathParams = {
1589
+ poll_id: request?.poll_id,
1590
+ };
1591
+ const body = {
1592
+ id: request?.id,
1593
+ text: request?.text,
1594
+ user_id: request?.user_id,
1595
+ custom: request?.custom,
1596
+ user: request?.user,
1597
+ };
1598
+
1599
+ const response = await this.sendRequest<StreamResponse<PollOptionResponse>>(
1600
+ 'PUT',
1601
+ '/api/v2/chat/polls/{poll_id}/options',
1602
+ pathParams,
1603
+ undefined,
1604
+ body,
1605
+ );
1606
+
1607
+ decoders.PollOptionResponse?.(response.body);
1608
+
1609
+ return { ...response.body, metadata: response.metadata };
1610
+ };
1611
+
1612
+ deletePollOption = async (request: {
1613
+ poll_id: string;
1614
+ option_id: string;
1615
+ user_id?: string;
1616
+ }): Promise<StreamResponse<Response>> => {
1617
+ const queryParams = {
1618
+ user_id: request?.user_id,
1619
+ };
1620
+ const pathParams = {
1621
+ poll_id: request?.poll_id,
1622
+ option_id: request?.option_id,
1623
+ };
1624
+
1625
+ const response = await this.sendRequest<StreamResponse<Response>>(
1626
+ 'DELETE',
1627
+ '/api/v2/chat/polls/{poll_id}/options/{option_id}',
1628
+ pathParams,
1629
+ queryParams,
1630
+ );
1631
+
1632
+ decoders.Response?.(response.body);
1633
+
1634
+ return { ...response.body, metadata: response.metadata };
1635
+ };
1636
+
1637
+ getPollOption = async (request: {
1638
+ poll_id: string;
1639
+ option_id: string;
1640
+ user_id?: string;
1641
+ }): Promise<StreamResponse<PollOptionResponse>> => {
1642
+ const queryParams = {
1643
+ user_id: request?.user_id,
1644
+ };
1645
+ const pathParams = {
1646
+ poll_id: request?.poll_id,
1647
+ option_id: request?.option_id,
1648
+ };
1649
+
1650
+ const response = await this.sendRequest<StreamResponse<PollOptionResponse>>(
1651
+ 'GET',
1652
+ '/api/v2/chat/polls/{poll_id}/options/{option_id}',
1653
+ pathParams,
1654
+ queryParams,
1655
+ );
1656
+
1657
+ decoders.PollOptionResponse?.(response.body);
1658
+
1659
+ return { ...response.body, metadata: response.metadata };
1660
+ };
1661
+
1662
+ queryPollVotes = async (
1663
+ request: QueryPollVotesRequest & { poll_id: string; user_id?: string },
1664
+ ): Promise<StreamResponse<PollVotesResponse>> => {
1665
+ const queryParams = {
1666
+ user_id: request?.user_id,
1667
+ };
1668
+ const pathParams = {
1669
+ poll_id: request?.poll_id,
1670
+ };
1671
+ const body = {
1672
+ limit: request?.limit,
1673
+ next: request?.next,
1674
+ prev: request?.prev,
1675
+ sort: request?.sort,
1676
+ filter: request?.filter,
1677
+ };
1678
+
1679
+ const response = await this.sendRequest<StreamResponse<PollVotesResponse>>(
1680
+ 'POST',
1681
+ '/api/v2/chat/polls/{poll_id}/votes',
1682
+ pathParams,
1683
+ queryParams,
1684
+ body,
1685
+ );
1686
+
1687
+ decoders.PollVotesResponse?.(response.body);
1688
+
1689
+ return { ...response.body, metadata: response.metadata };
1690
+ };
1691
+
1692
+ queryBannedUsers = async (request?: {
1693
+ payload?: QueryBannedUsersRequest;
1694
+ }): Promise<StreamResponse<QueryBannedUsersResponse>> => {
1695
+ const queryParams = {
1696
+ payload: request?.payload,
1697
+ };
1698
+
1699
+ const response = await this.sendRequest<
1700
+ StreamResponse<QueryBannedUsersResponse>
1701
+ >('GET', '/api/v2/chat/query_banned_users', undefined, queryParams);
1702
+
1703
+ decoders.QueryBannedUsersResponse?.(response.body);
1704
+
1705
+ return { ...response.body, metadata: response.metadata };
1706
+ };
1707
+
1708
+ search = async (request?: {
1709
+ payload?: SearchRequest;
1710
+ }): Promise<StreamResponse<SearchResponse>> => {
1711
+ const queryParams = {
1712
+ payload: request?.payload,
1713
+ };
1714
+
1715
+ const response = await this.sendRequest<StreamResponse<SearchResponse>>(
1716
+ 'GET',
1717
+ '/api/v2/chat/search',
1718
+ undefined,
1719
+ queryParams,
1720
+ );
1721
+
1722
+ decoders.SearchResponse?.(response.body);
1723
+
1724
+ return { ...response.body, metadata: response.metadata };
1725
+ };
1726
+
1727
+ queryThreads = async (
1728
+ request?: QueryThreadsRequest,
1729
+ ): Promise<StreamResponse<QueryThreadsResponse>> => {
1730
+ const body = {
1731
+ limit: request?.limit,
1732
+ member_limit: request?.member_limit,
1733
+ next: request?.next,
1734
+ participant_limit: request?.participant_limit,
1735
+ prev: request?.prev,
1736
+ reply_limit: request?.reply_limit,
1737
+ user_id: request?.user_id,
1738
+ user: request?.user,
1739
+ };
1740
+
1741
+ const response = await this.sendRequest<
1742
+ StreamResponse<QueryThreadsResponse>
1743
+ >('POST', '/api/v2/chat/threads', undefined, undefined, body);
1744
+
1745
+ decoders.QueryThreadsResponse?.(response.body);
1746
+
1747
+ return { ...response.body, metadata: response.metadata };
1748
+ };
1749
+
1750
+ getThread = async (request: {
1751
+ message_id: string;
1752
+ connection_id?: string;
1753
+ reply_limit?: number;
1754
+ participant_limit?: number;
1755
+ member_limit?: number;
1756
+ }): Promise<StreamResponse<GetThreadResponse>> => {
1757
+ const queryParams = {
1758
+ connection_id: request?.connection_id,
1759
+ reply_limit: request?.reply_limit,
1760
+ participant_limit: request?.participant_limit,
1761
+ member_limit: request?.member_limit,
1762
+ };
1763
+ const pathParams = {
1764
+ message_id: request?.message_id,
1765
+ };
1766
+
1767
+ const response = await this.sendRequest<StreamResponse<GetThreadResponse>>(
1768
+ 'GET',
1769
+ '/api/v2/chat/threads/{message_id}',
1770
+ pathParams,
1771
+ queryParams,
1772
+ );
1773
+
1774
+ decoders.GetThreadResponse?.(response.body);
1775
+
1776
+ return { ...response.body, metadata: response.metadata };
1777
+ };
1778
+
1779
+ updateThreadPartial = async (
1780
+ request: UpdateThreadPartialRequest & { message_id: string },
1781
+ ): Promise<StreamResponse<UpdateThreadPartialResponse>> => {
1782
+ const pathParams = {
1783
+ message_id: request?.message_id,
1784
+ };
1785
+ const body = {
1786
+ user_id: request?.user_id,
1787
+ unset: request?.unset,
1788
+ set: request?.set,
1789
+ user: request?.user,
1790
+ };
1791
+
1792
+ const response = await this.sendRequest<
1793
+ StreamResponse<UpdateThreadPartialResponse>
1794
+ >(
1795
+ 'PATCH',
1796
+ '/api/v2/chat/threads/{message_id}',
1797
+ pathParams,
1798
+ undefined,
1799
+ body,
1800
+ );
1801
+
1802
+ decoders.UpdateThreadPartialResponse?.(response.body);
1803
+
1804
+ return { ...response.body, metadata: response.metadata };
1805
+ };
1806
+
1807
+ unreadCounts = async (): Promise<
1808
+ StreamResponse<WrappedUnreadCountsResponse>
1809
+ > => {
1810
+ const response = await this.sendRequest<
1811
+ StreamResponse<WrappedUnreadCountsResponse>
1812
+ >('GET', '/api/v2/chat/unread', undefined, undefined);
1813
+
1814
+ decoders.WrappedUnreadCountsResponse?.(response.body);
1815
+
1816
+ return { ...response.body, metadata: response.metadata };
1817
+ };
1818
+
1819
+ unreadCountsBatch = async (
1820
+ request: UnreadCountsBatchRequest,
1821
+ ): Promise<StreamResponse<UnreadCountsBatchResponse>> => {
1822
+ const body = {
1823
+ user_ids: request?.user_ids,
1824
+ };
1825
+
1826
+ const response = await this.sendRequest<
1827
+ StreamResponse<UnreadCountsBatchResponse>
1828
+ >('POST', '/api/v2/chat/unread_batch', undefined, undefined, body);
1829
+
1830
+ decoders.UnreadCountsBatchResponse?.(response.body);
1831
+
1832
+ return { ...response.body, metadata: response.metadata };
1833
+ };
1834
+
1835
+ sendUserCustomEvent = async (
1836
+ request: SendUserCustomEventRequest & { user_id: string },
1837
+ ): Promise<StreamResponse<Response>> => {
1838
+ const pathParams = {
1839
+ user_id: request?.user_id,
1840
+ };
1841
+ const body = {
1842
+ event: request?.event,
1843
+ };
1844
+
1845
+ const response = await this.sendRequest<StreamResponse<Response>>(
1846
+ 'POST',
1847
+ '/api/v2/chat/users/{user_id}/event',
1848
+ pathParams,
1849
+ undefined,
1850
+ body,
1851
+ );
1852
+
1853
+ decoders.Response?.(response.body);
1854
+
1855
+ return { ...response.body, metadata: response.metadata };
1856
+ };
1857
+ }