stream-chat 4.4.3 → 4.5.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/README.md +4 -13
  2. package/dist/browser.es.js +1571 -1071
  3. package/dist/browser.es.js.map +1 -1
  4. package/dist/browser.full-bundle.min.js +1 -1
  5. package/dist/browser.full-bundle.min.js.map +1 -1
  6. package/dist/browser.js +1571 -1071
  7. package/dist/browser.js.map +1 -1
  8. package/dist/index.es.js +1571 -1071
  9. package/dist/index.es.js.map +1 -1
  10. package/dist/index.js +1571 -1071
  11. package/dist/index.js.map +1 -1
  12. package/dist/types/base64.d.ts.map +1 -1
  13. package/dist/types/channel.d.ts +19 -15
  14. package/dist/types/channel.d.ts.map +1 -1
  15. package/dist/types/channel_state.d.ts +2 -2
  16. package/dist/types/channel_state.d.ts.map +1 -1
  17. package/dist/types/client.d.ts +18 -39
  18. package/dist/types/client.d.ts.map +1 -1
  19. package/dist/types/client_state.d.ts +2 -2
  20. package/dist/types/client_state.d.ts.map +1 -1
  21. package/dist/types/connection.d.ts +14 -49
  22. package/dist/types/connection.d.ts.map +1 -1
  23. package/dist/types/connection_fallback.d.ts +42 -0
  24. package/dist/types/connection_fallback.d.ts.map +1 -0
  25. package/dist/types/errors.d.ts +14 -0
  26. package/dist/types/errors.d.ts.map +1 -0
  27. package/dist/types/insights.d.ts +6 -6
  28. package/dist/types/insights.d.ts.map +1 -1
  29. package/dist/types/permissions.d.ts.map +1 -1
  30. package/dist/types/signing.d.ts +3 -3
  31. package/dist/types/signing.d.ts.map +1 -1
  32. package/dist/types/token_manager.d.ts +2 -2
  33. package/dist/types/token_manager.d.ts.map +1 -1
  34. package/dist/types/types.d.ts +94 -80
  35. package/dist/types/types.d.ts.map +1 -1
  36. package/dist/types/utils.d.ts +12 -2
  37. package/dist/types/utils.d.ts.map +1 -1
  38. package/package.json +3 -3
  39. package/src/base64.ts +1 -4
  40. package/src/channel.ts +133 -461
  41. package/src/channel_state.ts +31 -158
  42. package/src/client.ts +277 -674
  43. package/src/client_state.ts +2 -2
  44. package/src/connection.ts +143 -394
  45. package/src/connection_fallback.ts +205 -0
  46. package/src/errors.ts +58 -0
  47. package/src/insights.ts +15 -23
  48. package/src/permissions.ts +3 -24
  49. package/src/signing.ts +6 -17
  50. package/src/token_manager.ts +6 -18
  51. package/src/types.ts +268 -504
  52. package/src/utils.ts +39 -19
  53. package/CHANGELOG.md +0 -844
package/src/types.ts CHANGED
@@ -24,15 +24,14 @@ export type RequireAtLeastOne<T> = {
24
24
  [K in keyof T]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<keyof T, K>>>;
25
25
  }[keyof T];
26
26
 
27
- export type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<
28
- T,
29
- Exclude<keyof T, Keys>
30
- > &
27
+ export type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> &
31
28
  {
32
29
  [K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>;
33
30
  }[Keys];
34
31
 
35
- export type UnknownType = Record<string, unknown>;
32
+ /* Unknown Record */
33
+ export type UR = Record<string, unknown>;
34
+ export type UnknownType = UR; //alias to avoid breaking change
36
35
 
37
36
  export type Unpacked<T> = T extends (infer U)[]
38
37
  ? U // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -50,9 +49,7 @@ export type APIResponse = {
50
49
  duration: string;
51
50
  };
52
51
 
53
- export type AppSettingsAPIResponse<
54
- CommandType extends string = LiteralStringForUnion
55
- > = APIResponse & {
52
+ export type AppSettingsAPIResponse<CommandType extends string = LiteralStringForUnion> = APIResponse & {
56
53
  app?: {
57
54
  channel_configs: Record<
58
55
  string,
@@ -129,22 +126,15 @@ export type ModerationResult = {
129
126
  };
130
127
 
131
128
  export type MessageFlagsResponse<
132
- ChannelType extends UnknownType = UnknownType,
129
+ ChannelType extends UR = UR,
133
130
  CommandType extends string = LiteralStringForUnion,
134
- UserType extends UnknownType = UnknownType,
135
- AttachmentType = UnknownType,
136
- MessageType = UnknownType,
137
- ReactionType = UnknownType
131
+ UserType extends UR = UR,
132
+ AttachmentType = UR,
133
+ MessageType = UR,
134
+ ReactionType = UR
138
135
  > = APIResponse & {
139
136
  flags?: Array<{
140
- message: MessageResponse<
141
- AttachmentType,
142
- ChannelType,
143
- CommandType,
144
- MessageType,
145
- ReactionType,
146
- UserType
147
- >;
137
+ message: MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>;
148
138
  user: UserResponse<UserType>;
149
139
  approved_at?: string;
150
140
  created_at?: string;
@@ -158,9 +148,9 @@ export type MessageFlagsResponse<
158
148
  };
159
149
 
160
150
  export type BannedUsersResponse<
161
- ChannelType extends UnknownType = UnknownType,
151
+ ChannelType extends UR = UR,
162
152
  CommandType extends string = LiteralStringForUnion,
163
- UserType extends UnknownType = UnknownType
153
+ UserType extends UR = UR
164
154
  > = APIResponse & {
165
155
  bans?: Array<{
166
156
  user: UserResponse<UserType>;
@@ -179,9 +169,9 @@ export type BlockListResponse = BlockList & {
179
169
  };
180
170
 
181
171
  export type ChannelResponse<
182
- ChannelType = UnknownType,
172
+ ChannelType = UR,
183
173
  CommandType extends string = LiteralStringForUnion,
184
- UserType = UnknownType
174
+ UserType = UR
185
175
  > = ChannelType & {
186
176
  cid: string;
187
177
  disabled: boolean;
@@ -205,35 +195,22 @@ export type ChannelResponse<
205
195
  name?: string;
206
196
  own_capabilities?: string[];
207
197
  team?: string;
198
+ truncated_at?: string;
208
199
  updated_at?: string;
209
200
  };
210
201
 
211
202
  export type ChannelAPIResponse<
212
- AttachmentType = UnknownType,
213
- ChannelType = UnknownType,
203
+ AttachmentType = UR,
204
+ ChannelType = UR,
214
205
  CommandType extends string = LiteralStringForUnion,
215
- MessageType = UnknownType,
216
- ReactionType = UnknownType,
217
- UserType = UnknownType
206
+ MessageType = UR,
207
+ ReactionType = UR,
208
+ UserType = UR
218
209
  > = APIResponse & {
219
210
  channel: ChannelResponse<ChannelType, CommandType, UserType>;
220
211
  members: ChannelMemberResponse<UserType>[];
221
- messages: MessageResponse<
222
- AttachmentType,
223
- ChannelType,
224
- CommandType,
225
- MessageType,
226
- ReactionType,
227
- UserType
228
- >[];
229
- pinned_messages: MessageResponse<
230
- AttachmentType,
231
- ChannelType,
232
- CommandType,
233
- MessageType,
234
- ReactionType,
235
- UserType
236
- >[];
212
+ messages: MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>[];
213
+ pinned_messages: MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>[];
237
214
  hidden?: boolean;
238
215
  membership?: ChannelMembership<UserType> | null;
239
216
  read?: ReadResponse<UserType>[];
@@ -241,11 +218,16 @@ export type ChannelAPIResponse<
241
218
  watchers?: UserResponse<UserType>[];
242
219
  };
243
220
 
244
- export type ChannelMemberAPIResponse<UserType = UnknownType> = APIResponse & {
221
+ export type ChannelUpdateOptions = {
222
+ hide_history?: boolean;
223
+ skip_push?: boolean;
224
+ };
225
+
226
+ export type ChannelMemberAPIResponse<UserType = UR> = APIResponse & {
245
227
  members: ChannelMemberResponse<UserType>[];
246
228
  };
247
229
 
248
- export type ChannelMemberResponse<UserType = UnknownType> = {
230
+ export type ChannelMemberResponse<UserType = UR> = {
249
231
  banned?: boolean;
250
232
  channel_role?: Role;
251
233
  created_at?: string;
@@ -277,9 +259,7 @@ export type CheckSQSResponse = APIResponse & {
277
259
  error?: string;
278
260
  };
279
261
 
280
- export type CommandResponse<
281
- CommandType extends string = LiteralStringForUnion
282
- > = Partial<CreatedAtUpdatedAt> & {
262
+ export type CommandResponse<CommandType extends string = LiteralStringForUnion> = Partial<CreatedAtUpdatedAt> & {
283
263
  args?: string;
284
264
  description?: string;
285
265
  name?: CommandVariants<CommandType>;
@@ -287,56 +267,44 @@ export type CommandResponse<
287
267
  };
288
268
 
289
269
  export type ConnectAPIResponse<
290
- ChannelType extends UnknownType = UnknownType,
270
+ ChannelType extends UR = UR,
291
271
  CommandType extends string = LiteralStringForUnion,
292
- UserType extends UnknownType = UnknownType
272
+ UserType extends UR = UR
293
273
  > = Promise<void | ConnectionOpen<ChannelType, CommandType, UserType>>;
294
274
 
295
- export type CreateChannelResponse<
296
- CommandType extends string = LiteralStringForUnion
297
- > = APIResponse &
275
+ export type CreateChannelResponse<CommandType extends string = LiteralStringForUnion> = APIResponse &
298
276
  Omit<CreateChannelOptions<CommandType>, 'client_id' | 'connection_id'> & {
299
277
  created_at: string;
300
278
  updated_at: string;
301
279
  grants?: Record<string, string[]>;
302
280
  };
303
281
 
304
- export type CreateCommandResponse<
305
- CommandType extends string = LiteralStringForUnion
306
- > = APIResponse & { command: CreateCommandOptions<CommandType> & CreatedAtUpdatedAt };
282
+ export type CreateCommandResponse<CommandType extends string = LiteralStringForUnion> = APIResponse & {
283
+ command: CreateCommandOptions<CommandType> & CreatedAtUpdatedAt;
284
+ };
307
285
 
308
286
  export type DeleteChannelAPIResponse<
309
- ChannelType = UnknownType,
287
+ ChannelType = UR,
310
288
  CommandType extends string = LiteralStringForUnion,
311
- UserType = UnknownType
289
+ UserType = UR
312
290
  > = APIResponse & {
313
291
  channel: ChannelResponse<ChannelType, CommandType, UserType>;
314
292
  };
315
293
 
316
- export type DeleteCommandResponse<
317
- CommandType extends string = LiteralStringForUnion
318
- > = APIResponse & {
294
+ export type DeleteCommandResponse<CommandType extends string = LiteralStringForUnion> = APIResponse & {
319
295
  name?: CommandVariants<CommandType>;
320
296
  };
321
297
 
322
298
  export type EventAPIResponse<
323
- AttachmentType extends UnknownType = UnknownType,
324
- ChannelType extends UnknownType = UnknownType,
299
+ AttachmentType extends UR = UR,
300
+ ChannelType extends UR = UR,
325
301
  CommandType extends string = LiteralStringForUnion,
326
- EventType extends UnknownType = UnknownType,
327
- MessageType extends UnknownType = UnknownType,
328
- ReactionType extends UnknownType = UnknownType,
329
- UserType extends UnknownType = UnknownType
302
+ EventType extends UR = UR,
303
+ MessageType extends UR = UR,
304
+ ReactionType extends UR = UR,
305
+ UserType extends UR = UR
330
306
  > = APIResponse & {
331
- event: Event<
332
- AttachmentType,
333
- ChannelType,
334
- CommandType,
335
- EventType,
336
- MessageType,
337
- ReactionType,
338
- UserType
339
- >;
307
+ event: Event<AttachmentType, ChannelType, CommandType, EventType, MessageType, ReactionType, UserType>;
340
308
  };
341
309
 
342
310
  export type ExportChannelResponse = {
@@ -350,7 +318,7 @@ export type ExportChannelStatusResponse = {
350
318
  updated_at?: string;
351
319
  };
352
320
 
353
- export type FlagMessageResponse<UserType = UnknownType> = APIResponse & {
321
+ export type FlagMessageResponse<UserType = UR> = APIResponse & {
354
322
  flag: {
355
323
  created_at: string;
356
324
  created_by_automod: boolean;
@@ -364,7 +332,7 @@ export type FlagMessageResponse<UserType = UnknownType> = APIResponse & {
364
332
  };
365
333
  };
366
334
 
367
- export type FlagUserResponse<UserType = UnknownType> = APIResponse & {
335
+ export type FlagUserResponse<UserType = UR> = APIResponse & {
368
336
  flag: {
369
337
  created_at: string;
370
338
  created_by_automod: boolean;
@@ -379,12 +347,12 @@ export type FlagUserResponse<UserType = UnknownType> = APIResponse & {
379
347
  };
380
348
 
381
349
  export type FormatMessageResponse<
382
- AttachmentType = UnknownType,
383
- ChannelType = UnknownType,
350
+ AttachmentType = UR,
351
+ ChannelType = UR,
384
352
  CommandType extends string = LiteralStringForUnion,
385
- MessageType = UnknownType,
386
- ReactionType = UnknownType,
387
- UserType = UnknownType
353
+ MessageType = UR,
354
+ ReactionType = UR,
355
+ UserType = UR
388
356
  > = Omit<
389
357
  MessageResponse<AttachmentType, ChannelType, CommandType, {}, ReactionType, UserType>,
390
358
  'created_at' | 'pinned_at' | 'updated_at' | 'status'
@@ -396,9 +364,7 @@ export type FormatMessageResponse<
396
364
  updated_at: Date;
397
365
  };
398
366
 
399
- export type GetChannelTypeResponse<
400
- CommandType extends string = LiteralStringForUnion
401
- > = APIResponse &
367
+ export type GetChannelTypeResponse<CommandType extends string = LiteralStringForUnion> = APIResponse &
402
368
  Omit<CreateChannelOptions<CommandType>, 'client_id' | 'connection_id' | 'commands'> & {
403
369
  created_at: string;
404
370
  updated_at: string;
@@ -406,26 +372,19 @@ export type GetChannelTypeResponse<
406
372
  grants?: Record<string, string[]>;
407
373
  };
408
374
 
409
- export type GetCommandResponse<
410
- CommandType extends string = LiteralStringForUnion
411
- > = APIResponse & CreateCommandOptions<CommandType> & CreatedAtUpdatedAt;
375
+ export type GetCommandResponse<CommandType extends string = LiteralStringForUnion> = APIResponse &
376
+ CreateCommandOptions<CommandType> &
377
+ CreatedAtUpdatedAt;
412
378
 
413
379
  export type GetMultipleMessagesAPIResponse<
414
- AttachmentType = UnknownType,
415
- ChannelType = UnknownType,
380
+ AttachmentType = UR,
381
+ ChannelType = UR,
416
382
  CommandType extends string = LiteralStringForUnion,
417
- MessageType = UnknownType,
418
- ReactionType = UnknownType,
419
- UserType = UnknownType
383
+ MessageType = UR,
384
+ ReactionType = UR,
385
+ UserType = UR
420
386
  > = APIResponse & {
421
- messages: MessageResponse<
422
- AttachmentType,
423
- ChannelType,
424
- CommandType,
425
- MessageType,
426
- ReactionType,
427
- UserType
428
- >[];
387
+ messages: MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>[];
429
388
  };
430
389
 
431
390
  export type GetRateLimitsResponse = APIResponse & {
@@ -435,40 +394,25 @@ export type GetRateLimitsResponse = APIResponse & {
435
394
  web?: RateLimitsMap;
436
395
  };
437
396
 
438
- export type GetReactionsAPIResponse<
439
- ReactionType = UnknownType,
440
- UserType = UnknownType
441
- > = APIResponse & {
397
+ export type GetReactionsAPIResponse<ReactionType = UR, UserType = UR> = APIResponse & {
442
398
  reactions: ReactionResponse<ReactionType, UserType>[];
443
399
  };
444
400
 
445
401
  export type GetRepliesAPIResponse<
446
- AttachmentType = UnknownType,
447
- ChannelType = UnknownType,
402
+ AttachmentType = UR,
403
+ ChannelType = UR,
448
404
  CommandType extends string = LiteralStringForUnion,
449
- MessageType = UnknownType,
450
- ReactionType = UnknownType,
451
- UserType = UnknownType
405
+ MessageType = UR,
406
+ ReactionType = UR,
407
+ UserType = UR
452
408
  > = APIResponse & {
453
- messages: MessageResponse<
454
- AttachmentType,
455
- ChannelType,
456
- CommandType,
457
- MessageType,
458
- ReactionType,
459
- UserType
460
- >[];
409
+ messages: MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>[];
461
410
  };
462
411
 
463
- export type ListChannelResponse<
464
- CommandType extends string = LiteralStringForUnion
465
- > = APIResponse & {
412
+ export type ListChannelResponse<CommandType extends string = LiteralStringForUnion> = APIResponse & {
466
413
  channel_types: Record<
467
414
  string,
468
- Omit<
469
- CreateChannelOptions<CommandType>,
470
- 'client_id' | 'connection_id' | 'commands'
471
- > & {
415
+ Omit<CreateChannelOptions<CommandType>, 'client_id' | 'connection_id' | 'commands'> & {
472
416
  commands: CommandResponse<CommandType>[];
473
417
  created_at: string;
474
418
  updated_at: string;
@@ -481,16 +425,14 @@ export type ListChannelTypesAPIResponse<
481
425
  CommandType extends string = LiteralStringForUnion
482
426
  > = ListChannelResponse<CommandType>;
483
427
 
484
- export type ListCommandsResponse<
485
- CommandType extends string = LiteralStringForUnion
486
- > = APIResponse & {
428
+ export type ListCommandsResponse<CommandType extends string = LiteralStringForUnion> = APIResponse & {
487
429
  commands: Array<CreateCommandOptions<CommandType> & CreatedAtUpdatedAt>;
488
430
  };
489
431
 
490
432
  export type MuteChannelAPIResponse<
491
- ChannelType extends UnknownType = UnknownType,
433
+ ChannelType extends UR = UR,
492
434
  CommandType extends string = LiteralStringForUnion,
493
- UserType extends UnknownType = UnknownType
435
+ UserType extends UR = UR
494
436
  > = APIResponse & {
495
437
  channel_mute: ChannelMute<ChannelType, CommandType, UserType>;
496
438
  own_user: OwnUserResponse<ChannelType, CommandType, UserType>;
@@ -499,37 +441,23 @@ export type MuteChannelAPIResponse<
499
441
  };
500
442
 
501
443
  export type MessageResponse<
502
- AttachmentType = UnknownType,
503
- ChannelType = UnknownType,
444
+ AttachmentType = UR,
445
+ ChannelType = UR,
504
446
  CommandType extends string = LiteralStringForUnion,
505
- MessageType = UnknownType,
506
- ReactionType = UnknownType,
507
- UserType = UnknownType
508
- > = MessageResponseBase<
509
- AttachmentType,
510
- ChannelType,
511
- CommandType,
512
- MessageType,
513
- ReactionType,
514
- UserType
515
- > & {
516
- quoted_message?: MessageResponseBase<
517
- AttachmentType,
518
- ChannelType,
519
- CommandType,
520
- MessageType,
521
- ReactionType,
522
- UserType
523
- >;
447
+ MessageType = UR,
448
+ ReactionType = UR,
449
+ UserType = UR
450
+ > = MessageResponseBase<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType> & {
451
+ quoted_message?: MessageResponseBase<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>;
524
452
  };
525
453
 
526
454
  export type MessageResponseBase<
527
- AttachmentType = UnknownType,
528
- ChannelType = UnknownType,
455
+ AttachmentType = UR,
456
+ ChannelType = UR,
529
457
  CommandType extends string = LiteralStringForUnion,
530
- MessageType = UnknownType,
531
- ReactionType = UnknownType,
532
- UserType = UnknownType
458
+ MessageType = UR,
459
+ ReactionType = UR,
460
+ UserType = UR
533
461
  > = MessageBase<AttachmentType, MessageType, UserType> & {
534
462
  args?: string;
535
463
  channel?: ChannelResponse<ChannelType, CommandType, UserType>;
@@ -558,7 +486,7 @@ export type MessageResponseBase<
558
486
  updated_at?: string;
559
487
  };
560
488
 
561
- export type MuteResponse<UserType = UnknownType> = {
489
+ export type MuteResponse<UserType = UR> = {
562
490
  user: UserResponse<UserType>;
563
491
  created_at?: string;
564
492
  expires?: string;
@@ -567,9 +495,9 @@ export type MuteResponse<UserType = UnknownType> = {
567
495
  };
568
496
 
569
497
  export type MuteUserResponse<
570
- ChannelType extends UnknownType = UnknownType,
498
+ ChannelType extends UR = UR,
571
499
  CommandType extends string = LiteralStringForUnion,
572
- UserType extends UnknownType = UnknownType
500
+ UserType extends UR = UR
573
501
  > = APIResponse & {
574
502
  mute?: MuteResponse<UserType>;
575
503
  mutes?: Array<Mute<UserType>>;
@@ -577,9 +505,9 @@ export type MuteUserResponse<
577
505
  };
578
506
 
579
507
  export type OwnUserBase<
580
- ChannelType extends UnknownType = UnknownType,
508
+ ChannelType extends UR = UR,
581
509
  CommandType extends string = LiteralStringForUnion,
582
- UserType extends UnknownType = UnknownType
510
+ UserType extends UR = UR
583
511
  > = {
584
512
  channel_mutes: ChannelMute<ChannelType, CommandType, UserType>[];
585
513
  devices: Device<UserType>[];
@@ -592,15 +520,15 @@ export type OwnUserBase<
592
520
  };
593
521
 
594
522
  export type OwnUserResponse<
595
- ChannelType extends UnknownType = UnknownType,
523
+ ChannelType extends UR = UR,
596
524
  CommandType extends string = LiteralStringForUnion,
597
- UserType extends UnknownType = UnknownType
525
+ UserType extends UR = UR
598
526
  > = UserResponse<UserType> & OwnUserBase<ChannelType, CommandType, UserType>;
599
527
 
600
528
  export type PartialUpdateChannelAPIResponse<
601
- ChannelType = UnknownType,
529
+ ChannelType = UR,
602
530
  CommandType extends string = LiteralStringForUnion,
603
- UserType = UnknownType
531
+ UserType = UR
604
532
  > = APIResponse & {
605
533
  channel: ChannelResponse<ChannelType, CommandType, UserType>;
606
534
  members: ChannelMemberResponse<UserType>[];
@@ -615,55 +543,38 @@ export type PermissionsAPIResponse = APIResponse & {
615
543
  };
616
544
 
617
545
  export type ReactionAPIResponse<
618
- AttachmentType = UnknownType,
619
- ChannelType = UnknownType,
546
+ AttachmentType = UR,
547
+ ChannelType = UR,
620
548
  CommandType extends string = LiteralStringForUnion,
621
- MessageType = UnknownType,
622
- ReactionType = UnknownType,
623
- UserType = UnknownType
549
+ MessageType = UR,
550
+ ReactionType = UR,
551
+ UserType = UR
624
552
  > = APIResponse & {
625
- message: MessageResponse<
626
- AttachmentType,
627
- ChannelType,
628
- CommandType,
629
- MessageType,
630
- ReactionType,
631
- UserType
632
- >;
553
+ message: MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>;
633
554
  reaction: ReactionResponse<ReactionType, UserType>;
634
555
  };
635
556
 
636
- export type ReactionResponse<
637
- ReactionType = UnknownType,
638
- UserType = UnknownType
639
- > = Reaction<ReactionType, UserType> & {
557
+ export type ReactionResponse<ReactionType = UR, UserType = UR> = Reaction<ReactionType, UserType> & {
640
558
  created_at: string;
641
559
  updated_at: string;
642
560
  };
643
561
 
644
- export type ReadResponse<UserType = UnknownType> = {
562
+ export type ReadResponse<UserType = UR> = {
645
563
  last_read: string;
646
564
  user: UserResponse<UserType>;
647
565
  unread_messages?: number;
648
566
  };
649
567
 
650
568
  export type SearchAPIResponse<
651
- AttachmentType = UnknownType,
652
- ChannelType = UnknownType,
569
+ AttachmentType = UR,
570
+ ChannelType = UR,
653
571
  CommandType extends string = LiteralStringForUnion,
654
- MessageType = UnknownType,
655
- ReactionType = UnknownType,
656
- UserType = UnknownType
572
+ MessageType = UR,
573
+ ReactionType = UR,
574
+ UserType = UR
657
575
  > = APIResponse & {
658
576
  results: {
659
- message: MessageResponse<
660
- AttachmentType,
661
- ChannelType,
662
- CommandType,
663
- MessageType,
664
- ReactionType,
665
- UserType
666
- >;
577
+ message: MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>;
667
578
  }[];
668
579
  next?: string;
669
580
  previous?: string;
@@ -679,62 +590,48 @@ export type SearchWarning = {
679
590
  export type SendFileAPIResponse = APIResponse & { file: string };
680
591
 
681
592
  export type SendMessageAPIResponse<
682
- AttachmentType = UnknownType,
683
- ChannelType = UnknownType,
593
+ AttachmentType = UR,
594
+ ChannelType = UR,
684
595
  CommandType extends string = LiteralStringForUnion,
685
- MessageType = UnknownType,
686
- ReactionType = UnknownType,
687
- UserType = UnknownType
596
+ MessageType = UR,
597
+ ReactionType = UR,
598
+ UserType = UR
688
599
  > = APIResponse & {
689
- message: MessageResponse<
690
- AttachmentType,
691
- ChannelType,
692
- CommandType,
693
- MessageType,
694
- ReactionType,
695
- UserType
696
- >;
600
+ message: MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>;
697
601
  };
698
602
 
699
603
  export type TruncateChannelAPIResponse<
700
- ChannelType = UnknownType,
604
+ ChannelType = UR,
701
605
  CommandType extends string = LiteralStringForUnion,
702
- UserType = UnknownType
606
+ UserType = UR,
607
+ AttachmentType = UR,
608
+ MessageType = UR,
609
+ ReactionType = UR
703
610
  > = APIResponse & {
704
611
  channel: ChannelResponse<ChannelType, CommandType, UserType>;
612
+ message?: MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>;
705
613
  };
706
614
 
707
615
  export type UpdateChannelAPIResponse<
708
- AttachmentType = UnknownType,
709
- ChannelType = UnknownType,
616
+ AttachmentType = UR,
617
+ ChannelType = UR,
710
618
  CommandType extends string = LiteralStringForUnion,
711
- MessageType = UnknownType,
712
- ReactionType = UnknownType,
713
- UserType = UnknownType
619
+ MessageType = UR,
620
+ ReactionType = UR,
621
+ UserType = UR
714
622
  > = APIResponse & {
715
623
  channel: ChannelResponse<ChannelType, CommandType, UserType>;
716
624
  members: ChannelMemberResponse<UserType>[];
717
- message?: MessageResponse<
718
- AttachmentType,
719
- ChannelType,
720
- CommandType,
721
- MessageType,
722
- ReactionType,
723
- UserType
724
- >;
625
+ message?: MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>;
725
626
  };
726
627
 
727
- export type UpdateChannelResponse<
728
- CommandType extends string = LiteralStringForUnion
729
- > = APIResponse &
628
+ export type UpdateChannelResponse<CommandType extends string = LiteralStringForUnion> = APIResponse &
730
629
  Omit<CreateChannelOptions<CommandType>, 'client_id' | 'connection_id'> & {
731
630
  created_at: string;
732
631
  updated_at: string;
733
632
  };
734
633
 
735
- export type UpdateCommandResponse<
736
- CommandType extends string = LiteralStringForUnion
737
- > = APIResponse & {
634
+ export type UpdateCommandResponse<CommandType extends string = LiteralStringForUnion> = APIResponse & {
738
635
  command: UpdateCommandOptions<CommandType> &
739
636
  CreatedAtUpdatedAt & {
740
637
  name: CommandVariants<CommandType>;
@@ -742,32 +639,25 @@ export type UpdateCommandResponse<
742
639
  };
743
640
 
744
641
  export type UpdateMessageAPIResponse<
745
- AttachmentType = UnknownType,
746
- ChannelType = UnknownType,
642
+ AttachmentType = UR,
643
+ ChannelType = UR,
747
644
  CommandType extends string = LiteralStringForUnion,
748
- MessageType = UnknownType,
749
- ReactionType = UnknownType,
750
- UserType = UnknownType
645
+ MessageType = UR,
646
+ ReactionType = UR,
647
+ UserType = UR
751
648
  > = APIResponse & {
752
- message: MessageResponse<
753
- AttachmentType,
754
- ChannelType,
755
- CommandType,
756
- MessageType,
757
- ReactionType,
758
- UserType
759
- >;
649
+ message: MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>;
760
650
  };
761
651
 
762
- export type UsersAPIResponse<UserType = UnknownType> = APIResponse & {
652
+ export type UsersAPIResponse<UserType = UR> = APIResponse & {
763
653
  users: Array<UserResponse<UserType>>;
764
654
  };
765
655
 
766
- export type UpdateUsersAPIResponse<UserType = UnknownType> = APIResponse & {
656
+ export type UpdateUsersAPIResponse<UserType = UR> = APIResponse & {
767
657
  users: { [key: string]: UserResponse<UserType> };
768
658
  };
769
659
 
770
- export type UserResponse<UserType = UnknownType> = User<UserType> & {
660
+ export type UserResponse<UserType = UR> = User<UserType> & {
771
661
  banned?: boolean;
772
662
  created_at?: string;
773
663
  deactivated_at?: string;
@@ -789,12 +679,9 @@ export type MessageFlagsPaginationOptions = {
789
679
  offset?: number;
790
680
  };
791
681
 
792
- export type BannedUsersPaginationOptions = Omit<
793
- PaginationOptions,
794
- 'id_gt' | 'id_gte' | 'id_lt' | 'id_lte'
795
- >;
682
+ export type BannedUsersPaginationOptions = Omit<PaginationOptions, 'id_gt' | 'id_gte' | 'id_lt' | 'id_lte'>;
796
683
 
797
- export type BanUserOptions<UserType = UnknownType> = UnBanUserOptions & {
684
+ export type BanUserOptions<UserType = UR> = UnBanUserOptions & {
798
685
  banned_by?: UserResponse<UserType>;
799
686
  banned_by_id?: string;
800
687
  ip_ban?: boolean;
@@ -811,22 +698,17 @@ export type BanUserOptions<UserType = UnknownType> = UnBanUserOptions & {
811
698
  };
812
699
 
813
700
  export type ChannelOptions = {
814
- last_message_ids?: { [key: string]: string };
815
701
  limit?: number;
702
+ member_limit?: number;
816
703
  message_limit?: number;
817
704
  offset?: number;
818
705
  presence?: boolean;
819
- recovery?: boolean;
820
706
  state?: boolean;
821
707
  user_id?: string;
822
708
  watch?: boolean;
823
709
  };
824
710
 
825
- export type ChannelQueryOptions<
826
- ChannelType = UnknownType,
827
- CommandType extends string = LiteralStringForUnion,
828
- UserType = UnknownType
829
- > = {
711
+ export type ChannelQueryOptions<ChannelType = UR, CommandType extends string = LiteralStringForUnion, UserType = UR> = {
830
712
  client_id?: string;
831
713
  connection_id?: string;
832
714
  data?: ChannelResponse<ChannelType, CommandType, UserType>;
@@ -889,12 +771,12 @@ export type CustomPermissionOptions = {
889
771
 
890
772
  // TODO: rename to UpdateChannelOptions in the next major update and use it in channel._update and/or channel.update
891
773
  export type InviteOptions<
892
- AttachmentType = UnknownType,
893
- ChannelType = UnknownType,
774
+ AttachmentType = UR,
775
+ ChannelType = UR,
894
776
  CommandType extends string = LiteralStringForUnion,
895
- MessageType = UnknownType,
896
- ReactionType = UnknownType,
897
- UserType = UnknownType
777
+ MessageType = UR,
778
+ ReactionType = UR,
779
+ UserType = UR
898
780
  > = {
899
781
  accept_invite?: boolean;
900
782
  add_members?: string[];
@@ -904,14 +786,7 @@ export type InviteOptions<
904
786
  data?: Omit<ChannelResponse<ChannelType, CommandType, UserType>, 'id' | 'cid'>;
905
787
  demote_moderators?: string[];
906
788
  invites?: string[];
907
- message?: MessageResponse<
908
- AttachmentType,
909
- ChannelType,
910
- CommandType,
911
- MessageType,
912
- ReactionType,
913
- UserType
914
- >;
789
+ message?: MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>;
915
790
  reject_invite?: boolean;
916
791
  remove_members?: string[];
917
792
  user?: UserResponse<UserType>;
@@ -919,11 +794,9 @@ export type InviteOptions<
919
794
  };
920
795
 
921
796
  /** @deprecated use MarkChannelsReadOptions instead */
922
- export type MarkAllReadOptions<
923
- UserType = UnknownType
924
- > = MarkChannelsReadOptions<UserType>;
797
+ export type MarkAllReadOptions<UserType = UR> = MarkChannelsReadOptions<UserType>;
925
798
 
926
- export type MarkChannelsReadOptions<UserType = UnknownType> = {
799
+ export type MarkChannelsReadOptions<UserType = UR> = {
927
800
  client_id?: string;
928
801
  connection_id?: string;
929
802
  read_by_channel?: Record<string, string>;
@@ -931,7 +804,7 @@ export type MarkChannelsReadOptions<UserType = UnknownType> = {
931
804
  user_id?: string;
932
805
  };
933
806
 
934
- export type MarkReadOptions<UserType = UnknownType> = {
807
+ export type MarkReadOptions<UserType = UR> = {
935
808
  client_id?: string;
936
809
  connection_id?: string;
937
810
  message_id?: string;
@@ -939,7 +812,7 @@ export type MarkReadOptions<UserType = UnknownType> = {
939
812
  user_id?: string;
940
813
  };
941
814
 
942
- export type MuteUserOptions<UserType = UnknownType> = {
815
+ export type MuteUserOptions<UserType = UR> = {
943
816
  client_id?: string;
944
817
  connection_id?: string;
945
818
  id?: string;
@@ -978,7 +851,7 @@ export type QueryMembersOptions = {
978
851
  user_id_lte?: string;
979
852
  };
980
853
 
981
- export type SearchOptions<MessageType = UnknownType> = {
854
+ export type SearchOptions<MessageType = UR> = {
982
855
  limit?: number;
983
856
  next?: string;
984
857
  offset?: number;
@@ -998,6 +871,8 @@ export type StreamChatOptions = AxiosRequestConfig & {
998
871
  browser?: boolean;
999
872
  device?: BaseDeviceFields;
1000
873
  enableInsights?: boolean;
874
+ /** experimental feature, please contact support if you want this feature enabled for you */
875
+ enableWSFallback?: boolean;
1001
876
  logger?: Logger;
1002
877
  /**
1003
878
  * When network is recovered, we re-query the active channels on client. But in single query, you can recover
@@ -1022,9 +897,10 @@ export type UnBanUserOptions = {
1022
897
  };
1023
898
 
1024
899
  // TODO: rename to UpdateChannelTypeOptions in the next major update
1025
- export type UpdateChannelOptions<
1026
- CommandType extends string = LiteralStringForUnion
1027
- > = Omit<CreateChannelOptions<CommandType>, 'name'> & {
900
+ export type UpdateChannelOptions<CommandType extends string = LiteralStringForUnion> = Omit<
901
+ CreateChannelOptions<CommandType>,
902
+ 'name'
903
+ > & {
1028
904
  created_at?: string;
1029
905
  updated_at?: string;
1030
906
  };
@@ -1051,13 +927,13 @@ export type ConnectionChangeEvent = {
1051
927
  };
1052
928
 
1053
929
  export type Event<
1054
- AttachmentType extends UnknownType = UnknownType,
1055
- ChannelType extends UnknownType = UnknownType,
930
+ AttachmentType extends UR = UR,
931
+ ChannelType extends UR = UR,
1056
932
  CommandType extends string = LiteralStringForUnion,
1057
- EventType extends UnknownType = UnknownType,
1058
- MessageType extends UnknownType = UnknownType,
1059
- ReactionType extends UnknownType = UnknownType,
1060
- UserType extends UnknownType = UnknownType
933
+ EventType extends UR = UR,
934
+ MessageType extends UR = UR,
935
+ ReactionType extends UR = UR,
936
+ UserType extends UR = UR
1061
937
  > = EventType & {
1062
938
  type: EventTypes;
1063
939
  channel?: ChannelResponse<ChannelType, CommandType, UserType>;
@@ -1071,14 +947,7 @@ export type Event<
1071
947
  mark_messages_deleted?: boolean;
1072
948
  me?: OwnUserResponse<ChannelType, CommandType, UserType>;
1073
949
  member?: ChannelMemberResponse<UserType>;
1074
- message?: MessageResponse<
1075
- AttachmentType,
1076
- ChannelType,
1077
- CommandType,
1078
- MessageType,
1079
- ReactionType,
1080
- UserType
1081
- >;
950
+ message?: MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>;
1082
951
  online?: boolean;
1083
952
  parent_id?: string;
1084
953
  reaction?: ReactionResponse<ReactionType, UserType>;
@@ -1092,29 +961,19 @@ export type Event<
1092
961
  watcher_count?: number;
1093
962
  };
1094
963
 
1095
- export type UserCustomEvent<EventType extends UnknownType = UnknownType> = EventType & {
964
+ export type UserCustomEvent<EventType extends UR = UR> = EventType & {
1096
965
  type: string;
1097
966
  };
1098
967
 
1099
968
  export type EventHandler<
1100
- AttachmentType extends UnknownType = UnknownType,
1101
- ChannelType extends UnknownType = UnknownType,
969
+ AttachmentType extends UR = UR,
970
+ ChannelType extends UR = UR,
1102
971
  CommandType extends string = LiteralStringForUnion,
1103
- EventType extends UnknownType = UnknownType,
1104
- MessageType extends UnknownType = UnknownType,
1105
- ReactionType extends UnknownType = UnknownType,
1106
- UserType extends UnknownType = UnknownType
1107
- > = (
1108
- event: Event<
1109
- AttachmentType,
1110
- ChannelType,
1111
- CommandType,
1112
- EventType,
1113
- MessageType,
1114
- ReactionType,
1115
- UserType
1116
- >,
1117
- ) => void;
972
+ EventType extends UR = UR,
973
+ MessageType extends UR = UR,
974
+ ReactionType extends UR = UR,
975
+ UserType extends UR = UR
976
+ > = (event: Event<AttachmentType, ChannelType, CommandType, EventType, MessageType, ReactionType, UserType>) => void;
1118
977
 
1119
978
  export type EventTypes =
1120
979
  | 'all'
@@ -1176,27 +1035,18 @@ export type MessageFlagsFiltersOptions = {
1176
1035
  export type MessageFlagsFilters = QueryFilters<
1177
1036
  {
1178
1037
  channel_cid?:
1179
- | RequireOnlyOne<
1180
- Pick<QueryFilter<MessageFlagsFiltersOptions['channel_cid']>, '$eq' | '$in'>
1181
- >
1038
+ | RequireOnlyOne<Pick<QueryFilter<MessageFlagsFiltersOptions['channel_cid']>, '$eq' | '$in'>>
1182
1039
  | PrimitiveFilter<MessageFlagsFiltersOptions['channel_cid']>;
1183
1040
  } & {
1184
1041
  team?:
1185
- | RequireOnlyOne<
1186
- Pick<QueryFilter<MessageFlagsFiltersOptions['team']>, '$eq' | '$in'>
1187
- >
1042
+ | RequireOnlyOne<Pick<QueryFilter<MessageFlagsFiltersOptions['team']>, '$eq' | '$in'>>
1188
1043
  | PrimitiveFilter<MessageFlagsFiltersOptions['team']>;
1189
1044
  } & {
1190
1045
  user_id?:
1191
- | RequireOnlyOne<
1192
- Pick<QueryFilter<MessageFlagsFiltersOptions['user_id']>, '$eq' | '$in'>
1193
- >
1046
+ | RequireOnlyOne<Pick<QueryFilter<MessageFlagsFiltersOptions['user_id']>, '$eq' | '$in'>>
1194
1047
  | PrimitiveFilter<MessageFlagsFiltersOptions['user_id']>;
1195
1048
  } & {
1196
- [Key in keyof Omit<
1197
- MessageFlagsFiltersOptions,
1198
- 'channel_cid' | 'user_id' | 'is_reviewed'
1199
- >]:
1049
+ [Key in keyof Omit<MessageFlagsFiltersOptions, 'channel_cid' | 'user_id' | 'is_reviewed'>]:
1200
1050
  | RequireOnlyOne<QueryFilter<MessageFlagsFiltersOptions[Key]>>
1201
1051
  | PrimitiveFilter<MessageFlagsFiltersOptions[Key]>;
1202
1052
  }
@@ -1213,9 +1063,7 @@ export type BannedUsersFilterOptions = {
1213
1063
  export type BannedUsersFilters = QueryFilters<
1214
1064
  {
1215
1065
  channel_cid?:
1216
- | RequireOnlyOne<
1217
- Pick<QueryFilter<BannedUsersFilterOptions['channel_cid']>, '$eq' | '$in'>
1218
- >
1066
+ | RequireOnlyOne<Pick<QueryFilter<BannedUsersFilterOptions['channel_cid']>, '$eq' | '$in'>>
1219
1067
  | PrimitiveFilter<BannedUsersFilterOptions['channel_cid']>;
1220
1068
  } & {
1221
1069
  reason?:
@@ -1233,9 +1081,9 @@ export type BannedUsersFilters = QueryFilters<
1233
1081
  >;
1234
1082
 
1235
1083
  export type ChannelFilters<
1236
- ChannelType = UnknownType,
1084
+ ChannelType = UR,
1237
1085
  CommandType extends string = LiteralStringForUnion,
1238
- UserType = UnknownType
1086
+ UserType = UR
1239
1087
  > = QueryFilters<
1240
1088
  ContainsOperator<ChannelType> & {
1241
1089
  members?:
@@ -1251,10 +1099,7 @@ export type ChannelFilters<
1251
1099
  >
1252
1100
  | PrimitiveFilter<ChannelResponse<ChannelType, CommandType, UserType>['name']>;
1253
1101
  } & {
1254
- [Key in keyof Omit<
1255
- ChannelResponse<{}, CommandType, UserType>,
1256
- 'name' | 'members'
1257
- >]:
1102
+ [Key in keyof Omit<ChannelResponse<{}, CommandType, UserType>, 'name' | 'members'>]:
1258
1103
  | RequireOnlyOne<QueryFilter<ChannelResponse<{}, CommandType, UserType>[Key]>>
1259
1104
  | PrimitiveFilter<ChannelResponse<{}, CommandType, UserType>[Key]>;
1260
1105
  }
@@ -1275,12 +1120,12 @@ export type ContainsOperator<CustomType = {}> = {
1275
1120
  };
1276
1121
 
1277
1122
  export type MessageFilters<
1278
- AttachmentType = UnknownType,
1279
- ChannelType = UnknownType,
1123
+ AttachmentType = UR,
1124
+ ChannelType = UR,
1280
1125
  CommandType extends string = LiteralStringForUnion,
1281
- MessageType = UnknownType,
1282
- ReactionType = UnknownType,
1283
- UserType = UnknownType
1126
+ MessageType = UR,
1127
+ ReactionType = UR,
1128
+ UserType = UR
1284
1129
  > = QueryFilters<
1285
1130
  ContainsOperator<MessageType> & {
1286
1131
  text?:
@@ -1294,78 +1139,29 @@ export type MessageFilters<
1294
1139
  ReactionType,
1295
1140
  UserType
1296
1141
  >['text'];
1297
- $q?: MessageResponse<
1298
- AttachmentType,
1299
- ChannelType,
1300
- CommandType,
1301
- MessageType,
1302
- ReactionType,
1303
- UserType
1304
- >['text'];
1142
+ $q?: MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>['text'];
1305
1143
  } & QueryFilter<
1306
- MessageResponse<
1307
- AttachmentType,
1308
- ChannelType,
1309
- CommandType,
1310
- MessageType,
1311
- ReactionType,
1312
- UserType
1313
- >['text']
1144
+ MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>['text']
1314
1145
  >
1315
1146
  >
1316
1147
  | PrimitiveFilter<
1317
- MessageResponse<
1318
- AttachmentType,
1319
- ChannelType,
1320
- CommandType,
1321
- MessageType,
1322
- ReactionType,
1323
- UserType
1324
- >['text']
1148
+ MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>['text']
1325
1149
  >;
1326
1150
  } & {
1327
1151
  [Key in keyof Omit<
1328
- MessageResponse<
1329
- AttachmentType,
1330
- ChannelType,
1331
- CommandType,
1332
- {},
1333
- ReactionType,
1334
- UserType
1335
- >,
1152
+ MessageResponse<AttachmentType, ChannelType, CommandType, {}, ReactionType, UserType>,
1336
1153
  'text'
1337
1154
  >]?:
1338
1155
  | RequireOnlyOne<
1339
- QueryFilter<
1340
- MessageResponse<
1341
- AttachmentType,
1342
- ChannelType,
1343
- CommandType,
1344
- {},
1345
- ReactionType,
1346
- UserType
1347
- >[Key]
1348
- >
1156
+ QueryFilter<MessageResponse<AttachmentType, ChannelType, CommandType, {}, ReactionType, UserType>[Key]>
1349
1157
  >
1350
- | PrimitiveFilter<
1351
- MessageResponse<
1352
- AttachmentType,
1353
- ChannelType,
1354
- CommandType,
1355
- {},
1356
- ReactionType,
1357
- UserType
1358
- >[Key]
1359
- >;
1158
+ | PrimitiveFilter<MessageResponse<AttachmentType, ChannelType, CommandType, {}, ReactionType, UserType>[Key]>;
1360
1159
  }
1361
1160
  >;
1362
1161
 
1363
1162
  export type PrimitiveFilter<ObjectType> = ObjectType | null;
1364
1163
 
1365
- export type QueryFilter<ObjectType = string> = NonNullable<ObjectType> extends
1366
- | string
1367
- | number
1368
- | boolean
1164
+ export type QueryFilter<ObjectType = string> = NonNullable<ObjectType> extends string | number | boolean
1369
1165
  ? {
1370
1166
  $eq?: PrimitiveFilter<ObjectType>;
1371
1167
  $exists?: boolean;
@@ -1396,21 +1192,13 @@ export type QueryLogicalOperators<Operators> = {
1396
1192
  $or?: ArrayTwoOrMore<QueryFilters<Operators>>;
1397
1193
  };
1398
1194
 
1399
- export type UserFilters<UserType = UnknownType> = QueryFilters<
1195
+ export type UserFilters<UserType = UR> = QueryFilters<
1400
1196
  ContainsOperator<UserType> & {
1401
1197
  id?:
1402
- | RequireOnlyOne<
1403
- { $autocomplete?: UserResponse<UserType>['id'] } & QueryFilter<
1404
- UserResponse<UserType>['id']
1405
- >
1406
- >
1198
+ | RequireOnlyOne<{ $autocomplete?: UserResponse<UserType>['id'] } & QueryFilter<UserResponse<UserType>['id']>>
1407
1199
  | PrimitiveFilter<UserResponse<UserType>['id']>;
1408
1200
  name?:
1409
- | RequireOnlyOne<
1410
- { $autocomplete?: UserResponse<UserType>['name'] } & QueryFilter<
1411
- UserResponse<UserType>['name']
1412
- >
1413
- >
1201
+ | RequireOnlyOne<{ $autocomplete?: UserResponse<UserType>['name'] } & QueryFilter<UserResponse<UserType>['name']>>
1414
1202
  | PrimitiveFilter<UserResponse<UserType>['name']>;
1415
1203
  teams?:
1416
1204
  | RequireOnlyOne<{
@@ -1420,9 +1208,7 @@ export type UserFilters<UserType = UnknownType> = QueryFilters<
1420
1208
  | PrimitiveFilter<UserResponse<UserType>['teams']>;
1421
1209
  username?:
1422
1210
  | RequireOnlyOne<
1423
- { $autocomplete?: UserResponse<UserType>['username'] } & QueryFilter<
1424
- UserResponse<UserType>['username']
1425
- >
1211
+ { $autocomplete?: UserResponse<UserType>['username'] } & QueryFilter<UserResponse<UserType>['username']>
1426
1212
  >
1427
1213
  | PrimitiveFilter<UserResponse<UserType>['username']>;
1428
1214
  } & {
@@ -1440,11 +1226,9 @@ export type BannedUsersSort = BannedUsersSortBase | Array<BannedUsersSortBase>;
1440
1226
 
1441
1227
  export type BannedUsersSortBase = { created_at?: AscDesc };
1442
1228
 
1443
- export type ChannelSort<ChannelType = UnknownType> =
1444
- | ChannelSortBase<ChannelType>
1445
- | Array<ChannelSortBase<ChannelType>>;
1229
+ export type ChannelSort<ChannelType = UR> = ChannelSortBase<ChannelType> | Array<ChannelSortBase<ChannelType>>;
1446
1230
 
1447
- export type ChannelSortBase<ChannelType = UnknownType> = Sort<ChannelType> & {
1231
+ export type ChannelSortBase<ChannelType = UR> = Sort<ChannelType> & {
1448
1232
  created_at?: AscDesc;
1449
1233
  has_unread?: AscDesc;
1450
1234
  last_message_at?: AscDesc;
@@ -1458,15 +1242,13 @@ export type Sort<T> = {
1458
1242
  [P in keyof T]?: AscDesc;
1459
1243
  };
1460
1244
 
1461
- export type UserSort<UserType = UnknownType> =
1462
- | Sort<UserResponse<UserType>>
1463
- | Array<Sort<UserResponse<UserType>>>;
1245
+ export type UserSort<UserType = UR> = Sort<UserResponse<UserType>> | Array<Sort<UserResponse<UserType>>>;
1464
1246
 
1465
- export type MemberSort<UserType = UnknownType> =
1247
+ export type MemberSort<UserType = UR> =
1466
1248
  | Sort<Pick<UserResponse<UserType>, 'id' | 'created_at' | 'name'>>
1467
1249
  | Array<Sort<Pick<UserResponse<UserType>, 'id' | 'created_at' | 'name'>>>;
1468
1250
 
1469
- export type SearchMessageSortBase<MessageType = UnknownType> = Sort<MessageType> & {
1251
+ export type SearchMessageSortBase<MessageType = UR> = Sort<MessageType> & {
1470
1252
  attachments?: AscDesc;
1471
1253
  'attachments.type'?: AscDesc;
1472
1254
  created_at?: AscDesc;
@@ -1482,15 +1264,11 @@ export type SearchMessageSortBase<MessageType = UnknownType> = Sort<MessageType>
1482
1264
  'user.id'?: AscDesc;
1483
1265
  };
1484
1266
 
1485
- export type SearchMessageSort<MessageType = UnknownType> =
1267
+ export type SearchMessageSort<MessageType = UR> =
1486
1268
  | SearchMessageSortBase<MessageType>
1487
1269
  | Array<SearchMessageSortBase<MessageType>>;
1488
1270
 
1489
- export type QuerySort<
1490
- ChannelType = UnknownType,
1491
- UserType = UnknownType,
1492
- MessageType = UnknownType
1493
- > =
1271
+ export type QuerySort<ChannelType = UR, UserType = UR, MessageType = UR> =
1494
1272
  | BannedUsersSort
1495
1273
  | ChannelSort<ChannelType>
1496
1274
  | SearchMessageSort<MessageType>
@@ -1567,7 +1345,7 @@ export type AppSettings = {
1567
1345
  webhook_url?: string;
1568
1346
  };
1569
1347
 
1570
- export type Attachment<T = UnknownType> = T & {
1348
+ export type Attachment<T = UR> = T & {
1571
1349
  actions?: Action[];
1572
1350
  asset_url?: string;
1573
1351
  author_icon?: string;
@@ -1606,9 +1384,7 @@ export type BlockList = {
1606
1384
  words: string[];
1607
1385
  };
1608
1386
 
1609
- export type ChannelConfig<
1610
- CommandType extends string = LiteralStringForUnion
1611
- > = ChannelConfigFields &
1387
+ export type ChannelConfig<CommandType extends string = LiteralStringForUnion> = ChannelConfigFields &
1612
1388
  CreatedAtUpdatedAt & {
1613
1389
  commands?: CommandVariants<CommandType>[];
1614
1390
  };
@@ -1644,19 +1420,17 @@ export type ChannelConfigFields = {
1644
1420
  url_enrichment?: boolean;
1645
1421
  };
1646
1422
 
1647
- export type ChannelConfigWithInfo<
1648
- CommandType extends string = LiteralStringForUnion
1649
- > = ChannelConfigFields &
1423
+ export type ChannelConfigWithInfo<CommandType extends string = LiteralStringForUnion> = ChannelConfigFields &
1650
1424
  CreatedAtUpdatedAt & {
1651
1425
  commands?: CommandResponse<CommandType>[];
1652
1426
  };
1653
1427
 
1654
- export type ChannelData<ChannelType = UnknownType> = ChannelType & {
1428
+ export type ChannelData<ChannelType = UR> = ChannelType & {
1655
1429
  members?: string[];
1656
1430
  name?: string;
1657
1431
  };
1658
1432
 
1659
- export type ChannelMembership<UserType = UnknownType> = {
1433
+ export type ChannelMembership<UserType = UR> = {
1660
1434
  banned?: boolean;
1661
1435
  channel_role?: Role;
1662
1436
  created_at?: string;
@@ -1668,9 +1442,9 @@ export type ChannelMembership<UserType = UnknownType> = {
1668
1442
  };
1669
1443
 
1670
1444
  export type ChannelMute<
1671
- ChannelType extends UnknownType = UnknownType,
1445
+ ChannelType extends UR = UR,
1672
1446
  CommandType extends string = LiteralStringForUnion,
1673
- UserType extends UnknownType = UnknownType
1447
+ UserType extends UR = UR
1674
1448
  > = {
1675
1449
  user: UserResponse<UserType>;
1676
1450
  channel?: ChannelResponse<ChannelType, CommandType, UserType>;
@@ -1687,7 +1461,7 @@ export type ChannelRole = {
1687
1461
  same_team?: boolean;
1688
1462
  };
1689
1463
 
1690
- export type CheckPushInput<UserType = UnknownType> = {
1464
+ export type CheckPushInput<UserType = UR> = {
1691
1465
  apn_template?: string;
1692
1466
  client_id?: string;
1693
1467
  connection_id?: string;
@@ -1717,9 +1491,9 @@ export type Configs<CommandType extends string = LiteralStringForUnion> = {
1717
1491
  };
1718
1492
 
1719
1493
  export type ConnectionOpen<
1720
- ChannelType extends UnknownType = UnknownType,
1494
+ ChannelType extends UR = UR,
1721
1495
  CommandType extends string = LiteralStringForUnion,
1722
- UserType extends UnknownType = UnknownType
1496
+ UserType extends UR = UR
1723
1497
  > = {
1724
1498
  connection_id: string;
1725
1499
  cid?: string;
@@ -1733,7 +1507,7 @@ export type CreatedAtUpdatedAt = {
1733
1507
  updated_at: string;
1734
1508
  };
1735
1509
 
1736
- export type Device<UserType = UnknownType> = DeviceFields & {
1510
+ export type Device<UserType = UR> = DeviceFields & {
1737
1511
  provider?: string;
1738
1512
  user?: UserResponse<UserType>;
1739
1513
  user_id?: string;
@@ -1875,25 +1649,17 @@ export type HuaweiConfig = {
1875
1649
 
1876
1650
  export type LiteralStringForUnion = string & {};
1877
1651
 
1878
- export type Logger = (
1879
- logLevel: 'info' | 'error' | 'warn',
1880
- message: string,
1881
- extraData?: Record<string, unknown>,
1882
- ) => void;
1883
-
1884
- export type Message<
1885
- AttachmentType = UnknownType,
1886
- MessageType = UnknownType,
1887
- UserType = UnknownType
1888
- > = Partial<MessageBase<AttachmentType, MessageType, UserType>> & {
1652
+ export type LogLevel = 'info' | 'error' | 'warn';
1653
+
1654
+ export type Logger = (logLevel: LogLevel, message: string, extraData?: Record<string, unknown>) => void;
1655
+
1656
+ export type Message<AttachmentType = UR, MessageType = UR, UserType = UR> = Partial<
1657
+ MessageBase<AttachmentType, MessageType, UserType>
1658
+ > & {
1889
1659
  mentioned_users?: string[];
1890
1660
  };
1891
1661
 
1892
- export type MessageBase<
1893
- AttachmentType = UnknownType,
1894
- MessageType = UnknownType,
1895
- UserType = UnknownType
1896
- > = MessageType & {
1662
+ export type MessageBase<AttachmentType = UR, MessageType = UR, UserType = UR> = MessageType & {
1897
1663
  id: string;
1898
1664
  attachments?: Attachment<AttachmentType>[];
1899
1665
  html?: string;
@@ -1907,38 +1673,32 @@ export type MessageBase<
1907
1673
  user_id?: string;
1908
1674
  };
1909
1675
 
1910
- export type MessageLabel =
1911
- | 'deleted'
1912
- | 'ephemeral'
1913
- | 'error'
1914
- | 'regular'
1915
- | 'reply'
1916
- | 'system';
1676
+ export type MessageLabel = 'deleted' | 'ephemeral' | 'error' | 'regular' | 'reply' | 'system';
1917
1677
 
1918
- export type Mute<UserType = UnknownType> = {
1678
+ export type Mute<UserType = UR> = {
1919
1679
  created_at: string;
1920
1680
  target: UserResponse<UserType>;
1921
1681
  updated_at: string;
1922
1682
  user: UserResponse<UserType>;
1923
1683
  };
1924
1684
 
1925
- export type PartialUpdateChannel<ChannelType = UnknownType> = {
1685
+ export type PartialUpdateChannel<ChannelType = UR> = {
1926
1686
  set?: Partial<ChannelResponse<ChannelType>>;
1927
1687
  unset?: Array<keyof ChannelResponse<ChannelType>>;
1928
1688
  };
1929
1689
 
1930
- export type PartialUserUpdate<UserType = UnknownType> = {
1690
+ export type PartialUserUpdate<UserType = UR> = {
1931
1691
  id: string;
1932
1692
  set?: Partial<UserResponse<UserType>>;
1933
1693
  unset?: Array<keyof UserResponse<UserType>>;
1934
1694
  };
1935
1695
 
1936
- export type MessageUpdatableFields<MessageType = UnknownType> = Omit<
1696
+ export type MessageUpdatableFields<MessageType = UR> = Omit<
1937
1697
  MessageResponse<MessageType>,
1938
1698
  'cid' | 'created_at' | 'updated_at' | 'deleted_at' | 'user' | 'user_id'
1939
1699
  >;
1940
1700
 
1941
- export type PartialMessageUpdate<MessageType = UnknownType> = {
1701
+ export type PartialMessageUpdate<MessageType = UR> = {
1942
1702
  set?: Partial<MessageUpdatableFields<MessageType>>;
1943
1703
  unset?: Array<keyof MessageUpdatableFields<MessageType>>;
1944
1704
  };
@@ -1982,10 +1742,7 @@ export type RateLimitsInfo = {
1982
1742
 
1983
1743
  export type RateLimitsMap = Record<EndpointName, RateLimitsInfo>;
1984
1744
 
1985
- export type Reaction<
1986
- ReactionType = UnknownType,
1987
- UserType = UnknownType
1988
- > = ReactionType & {
1745
+ export type Reaction<ReactionType = UR, UserType = UR> = ReactionType & {
1989
1746
  type: string;
1990
1747
  message_id?: string;
1991
1748
  score?: number;
@@ -2014,12 +1771,12 @@ export type Resource =
2014
1771
  | 'UploadAttachment';
2015
1772
 
2016
1773
  export type SearchPayload<
2017
- AttachmentType = UnknownType,
2018
- ChannelType = UnknownType,
1774
+ AttachmentType = UR,
1775
+ ChannelType = UR,
2019
1776
  CommandType extends string = LiteralStringForUnion,
2020
- MessageType = UnknownType,
2021
- ReactionType = UnknownType,
2022
- UserType = UnknownType
1777
+ MessageType = UR,
1778
+ ReactionType = UR,
1779
+ UserType = UR
2023
1780
  > = Omit<SearchOptions<MessageType>, 'sort'> & {
2024
1781
  client_id?: string;
2025
1782
  connection_id?: string;
@@ -2118,26 +1875,33 @@ export type TranslationLanguages =
2118
1875
 
2119
1876
  export type TypingStartEvent = Event;
2120
1877
 
1878
+ export type ReservedMessageFields =
1879
+ | 'command'
1880
+ | 'created_at'
1881
+ | 'html'
1882
+ | 'latest_reactions'
1883
+ | 'own_reactions'
1884
+ | 'quoted_message'
1885
+ | 'reaction_counts'
1886
+ | 'reply_count'
1887
+ | 'type'
1888
+ | 'updated_at'
1889
+ | 'user'
1890
+ | '__html';
1891
+
2121
1892
  export type UpdatedMessage<
2122
- AttachmentType = UnknownType,
2123
- ChannelType = UnknownType,
1893
+ AttachmentType = UR,
1894
+ ChannelType = UR,
2124
1895
  CommandType extends string = LiteralStringForUnion,
2125
- MessageType = UnknownType,
2126
- ReactionType = UnknownType,
2127
- UserType = UnknownType
1896
+ MessageType = UR,
1897
+ ReactionType = UR,
1898
+ UserType = UR
2128
1899
  > = Omit<
2129
- MessageResponse<
2130
- AttachmentType,
2131
- ChannelType,
2132
- CommandType,
2133
- MessageType,
2134
- ReactionType,
2135
- UserType
2136
- >,
1900
+ MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>,
2137
1901
  'mentioned_users'
2138
1902
  > & { mentioned_users?: string[] };
2139
1903
 
2140
- export type User<UserType = UnknownType> = UserType & {
1904
+ export type User<UserType = UR> = UserType & {
2141
1905
  id: string;
2142
1906
  anon?: boolean;
2143
1907
  name?: string;
@@ -2203,14 +1967,7 @@ export type CampaignData = {
2203
1967
 
2204
1968
  export type CampaignStatus = {
2205
1969
  errors: string[];
2206
- status:
2207
- | 'draft'
2208
- | 'stopped'
2209
- | 'scheduled'
2210
- | 'completed'
2211
- | 'failed'
2212
- | 'canceled'
2213
- | 'in_progress';
1970
+ status: 'draft' | 'stopped' | 'scheduled' | 'completed' | 'failed' | 'canceled' | 'in_progress';
2214
1971
  completed_at?: string;
2215
1972
  failed_at?: string;
2216
1973
  progress?: number;
@@ -2236,5 +1993,12 @@ export type TaskStatus = {
2236
1993
  description: string;
2237
1994
  type: string;
2238
1995
  };
2239
- result?: UnknownType;
1996
+ result?: UR;
1997
+ };
1998
+
1999
+ export type TruncateOptions<AttachmentType, MessageType, UserType> = {
2000
+ hard_delete?: boolean;
2001
+ message?: Message<AttachmentType, MessageType, UserType>;
2002
+ skip_push?: boolean;
2003
+ truncated_at?: Date;
2240
2004
  };