stream-chat 4.4.3-dev.3 → 5.0.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 (53) hide show
  1. package/README.md +4 -13
  2. package/dist/browser.es.js +1258 -722
  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 +1258 -721
  7. package/dist/browser.js.map +1 -1
  8. package/dist/index.es.js +1258 -722
  9. package/dist/index.es.js.map +1 -1
  10. package/dist/index.js +1258 -721
  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 +25 -42
  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 +41 -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 +16 -9
  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 +95 -89
  35. package/dist/types/types.d.ts.map +1 -1
  36. package/dist/types/utils.d.ts +13 -3
  37. package/dist/types/utils.d.ts.map +1 -1
  38. package/package.json +4 -4
  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 +298 -712
  43. package/src/client_state.ts +2 -2
  44. package/src/connection.ts +146 -395
  45. package/src/connection_fallback.ts +209 -0
  46. package/src/errors.ts +58 -0
  47. package/src/insights.ts +37 -31
  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 +269 -512
  52. package/src/utils.ts +58 -24
  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,44 +679,28 @@ 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;
801
688
  reason?: string;
802
689
  timeout?: number;
803
- /**
804
- * @deprecated please use banned_by
805
- */
806
- user?: UserResponse<UserType>;
807
- /**
808
- * @deprecated please use banned_by_id
809
- */
810
- user_id?: string;
811
690
  };
812
691
 
813
692
  export type ChannelOptions = {
814
- last_message_ids?: { [key: string]: string };
815
693
  limit?: number;
694
+ member_limit?: number;
816
695
  message_limit?: number;
817
696
  offset?: number;
818
697
  presence?: boolean;
819
- recovery?: boolean;
820
698
  state?: boolean;
821
699
  user_id?: string;
822
700
  watch?: boolean;
823
701
  };
824
702
 
825
- export type ChannelQueryOptions<
826
- ChannelType = UnknownType,
827
- CommandType extends string = LiteralStringForUnion,
828
- UserType = UnknownType
829
- > = {
703
+ export type ChannelQueryOptions<ChannelType = UR, CommandType extends string = LiteralStringForUnion, UserType = UR> = {
830
704
  client_id?: string;
831
705
  connection_id?: string;
832
706
  data?: ChannelResponse<ChannelType, CommandType, UserType>;
@@ -889,12 +763,12 @@ export type CustomPermissionOptions = {
889
763
 
890
764
  // TODO: rename to UpdateChannelOptions in the next major update and use it in channel._update and/or channel.update
891
765
  export type InviteOptions<
892
- AttachmentType = UnknownType,
893
- ChannelType = UnknownType,
766
+ AttachmentType = UR,
767
+ ChannelType = UR,
894
768
  CommandType extends string = LiteralStringForUnion,
895
- MessageType = UnknownType,
896
- ReactionType = UnknownType,
897
- UserType = UnknownType
769
+ MessageType = UR,
770
+ ReactionType = UR,
771
+ UserType = UR
898
772
  > = {
899
773
  accept_invite?: boolean;
900
774
  add_members?: string[];
@@ -904,14 +778,7 @@ export type InviteOptions<
904
778
  data?: Omit<ChannelResponse<ChannelType, CommandType, UserType>, 'id' | 'cid'>;
905
779
  demote_moderators?: string[];
906
780
  invites?: string[];
907
- message?: MessageResponse<
908
- AttachmentType,
909
- ChannelType,
910
- CommandType,
911
- MessageType,
912
- ReactionType,
913
- UserType
914
- >;
781
+ message?: MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>;
915
782
  reject_invite?: boolean;
916
783
  remove_members?: string[];
917
784
  user?: UserResponse<UserType>;
@@ -919,11 +786,9 @@ export type InviteOptions<
919
786
  };
920
787
 
921
788
  /** @deprecated use MarkChannelsReadOptions instead */
922
- export type MarkAllReadOptions<
923
- UserType = UnknownType
924
- > = MarkChannelsReadOptions<UserType>;
789
+ export type MarkAllReadOptions<UserType = UR> = MarkChannelsReadOptions<UserType>;
925
790
 
926
- export type MarkChannelsReadOptions<UserType = UnknownType> = {
791
+ export type MarkChannelsReadOptions<UserType = UR> = {
927
792
  client_id?: string;
928
793
  connection_id?: string;
929
794
  read_by_channel?: Record<string, string>;
@@ -931,7 +796,7 @@ export type MarkChannelsReadOptions<UserType = UnknownType> = {
931
796
  user_id?: string;
932
797
  };
933
798
 
934
- export type MarkReadOptions<UserType = UnknownType> = {
799
+ export type MarkReadOptions<UserType = UR> = {
935
800
  client_id?: string;
936
801
  connection_id?: string;
937
802
  message_id?: string;
@@ -939,7 +804,7 @@ export type MarkReadOptions<UserType = UnknownType> = {
939
804
  user_id?: string;
940
805
  };
941
806
 
942
- export type MuteUserOptions<UserType = UnknownType> = {
807
+ export type MuteUserOptions<UserType = UR> = {
943
808
  client_id?: string;
944
809
  connection_id?: string;
945
810
  id?: string;
@@ -978,7 +843,7 @@ export type QueryMembersOptions = {
978
843
  user_id_lte?: string;
979
844
  };
980
845
 
981
- export type SearchOptions<MessageType = UnknownType> = {
846
+ export type SearchOptions<MessageType = UR> = {
982
847
  limit?: number;
983
848
  next?: string;
984
849
  offset?: number;
@@ -998,6 +863,8 @@ export type StreamChatOptions = AxiosRequestConfig & {
998
863
  browser?: boolean;
999
864
  device?: BaseDeviceFields;
1000
865
  enableInsights?: boolean;
866
+ /** experimental feature, please contact support if you want this feature enabled for you */
867
+ enableWSFallback?: boolean;
1001
868
  logger?: Logger;
1002
869
  /**
1003
870
  * When network is recovered, we re-query the active channels on client. But in single query, you can recover
@@ -1022,9 +889,10 @@ export type UnBanUserOptions = {
1022
889
  };
1023
890
 
1024
891
  // TODO: rename to UpdateChannelTypeOptions in the next major update
1025
- export type UpdateChannelOptions<
1026
- CommandType extends string = LiteralStringForUnion
1027
- > = Omit<CreateChannelOptions<CommandType>, 'name'> & {
892
+ export type UpdateChannelOptions<CommandType extends string = LiteralStringForUnion> = Omit<
893
+ CreateChannelOptions<CommandType>,
894
+ 'name'
895
+ > & {
1028
896
  created_at?: string;
1029
897
  updated_at?: string;
1030
898
  };
@@ -1051,13 +919,13 @@ export type ConnectionChangeEvent = {
1051
919
  };
1052
920
 
1053
921
  export type Event<
1054
- AttachmentType extends UnknownType = UnknownType,
1055
- ChannelType extends UnknownType = UnknownType,
922
+ AttachmentType extends UR = UR,
923
+ ChannelType extends UR = UR,
1056
924
  CommandType extends string = LiteralStringForUnion,
1057
- EventType extends UnknownType = UnknownType,
1058
- MessageType extends UnknownType = UnknownType,
1059
- ReactionType extends UnknownType = UnknownType,
1060
- UserType extends UnknownType = UnknownType
925
+ EventType extends UR = UR,
926
+ MessageType extends UR = UR,
927
+ ReactionType extends UR = UR,
928
+ UserType extends UR = UR
1061
929
  > = EventType & {
1062
930
  type: EventTypes;
1063
931
  channel?: ChannelResponse<ChannelType, CommandType, UserType>;
@@ -1071,14 +939,7 @@ export type Event<
1071
939
  mark_messages_deleted?: boolean;
1072
940
  me?: OwnUserResponse<ChannelType, CommandType, UserType>;
1073
941
  member?: ChannelMemberResponse<UserType>;
1074
- message?: MessageResponse<
1075
- AttachmentType,
1076
- ChannelType,
1077
- CommandType,
1078
- MessageType,
1079
- ReactionType,
1080
- UserType
1081
- >;
942
+ message?: MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>;
1082
943
  online?: boolean;
1083
944
  parent_id?: string;
1084
945
  reaction?: ReactionResponse<ReactionType, UserType>;
@@ -1092,29 +953,19 @@ export type Event<
1092
953
  watcher_count?: number;
1093
954
  };
1094
955
 
1095
- export type UserCustomEvent<EventType extends UnknownType = UnknownType> = EventType & {
956
+ export type UserCustomEvent<EventType extends UR = UR> = EventType & {
1096
957
  type: string;
1097
958
  };
1098
959
 
1099
960
  export type EventHandler<
1100
- AttachmentType extends UnknownType = UnknownType,
1101
- ChannelType extends UnknownType = UnknownType,
961
+ AttachmentType extends UR = UR,
962
+ ChannelType extends UR = UR,
1102
963
  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;
964
+ EventType extends UR = UR,
965
+ MessageType extends UR = UR,
966
+ ReactionType extends UR = UR,
967
+ UserType extends UR = UR
968
+ > = (event: Event<AttachmentType, ChannelType, CommandType, EventType, MessageType, ReactionType, UserType>) => void;
1118
969
 
1119
970
  export type EventTypes =
1120
971
  | 'all'
@@ -1126,6 +977,7 @@ export type EventTypes =
1126
977
  | 'channel.unmuted'
1127
978
  | 'channel.updated'
1128
979
  | 'channel.visible'
980
+ | 'transport.changed' // ws vs longpoll
1129
981
  | 'connection.changed'
1130
982
  | 'connection.recovered'
1131
983
  | 'health.check'
@@ -1176,27 +1028,18 @@ export type MessageFlagsFiltersOptions = {
1176
1028
  export type MessageFlagsFilters = QueryFilters<
1177
1029
  {
1178
1030
  channel_cid?:
1179
- | RequireOnlyOne<
1180
- Pick<QueryFilter<MessageFlagsFiltersOptions['channel_cid']>, '$eq' | '$in'>
1181
- >
1031
+ | RequireOnlyOne<Pick<QueryFilter<MessageFlagsFiltersOptions['channel_cid']>, '$eq' | '$in'>>
1182
1032
  | PrimitiveFilter<MessageFlagsFiltersOptions['channel_cid']>;
1183
1033
  } & {
1184
1034
  team?:
1185
- | RequireOnlyOne<
1186
- Pick<QueryFilter<MessageFlagsFiltersOptions['team']>, '$eq' | '$in'>
1187
- >
1035
+ | RequireOnlyOne<Pick<QueryFilter<MessageFlagsFiltersOptions['team']>, '$eq' | '$in'>>
1188
1036
  | PrimitiveFilter<MessageFlagsFiltersOptions['team']>;
1189
1037
  } & {
1190
1038
  user_id?:
1191
- | RequireOnlyOne<
1192
- Pick<QueryFilter<MessageFlagsFiltersOptions['user_id']>, '$eq' | '$in'>
1193
- >
1039
+ | RequireOnlyOne<Pick<QueryFilter<MessageFlagsFiltersOptions['user_id']>, '$eq' | '$in'>>
1194
1040
  | PrimitiveFilter<MessageFlagsFiltersOptions['user_id']>;
1195
1041
  } & {
1196
- [Key in keyof Omit<
1197
- MessageFlagsFiltersOptions,
1198
- 'channel_cid' | 'user_id' | 'is_reviewed'
1199
- >]:
1042
+ [Key in keyof Omit<MessageFlagsFiltersOptions, 'channel_cid' | 'user_id' | 'is_reviewed'>]:
1200
1043
  | RequireOnlyOne<QueryFilter<MessageFlagsFiltersOptions[Key]>>
1201
1044
  | PrimitiveFilter<MessageFlagsFiltersOptions[Key]>;
1202
1045
  }
@@ -1213,9 +1056,7 @@ export type BannedUsersFilterOptions = {
1213
1056
  export type BannedUsersFilters = QueryFilters<
1214
1057
  {
1215
1058
  channel_cid?:
1216
- | RequireOnlyOne<
1217
- Pick<QueryFilter<BannedUsersFilterOptions['channel_cid']>, '$eq' | '$in'>
1218
- >
1059
+ | RequireOnlyOne<Pick<QueryFilter<BannedUsersFilterOptions['channel_cid']>, '$eq' | '$in'>>
1219
1060
  | PrimitiveFilter<BannedUsersFilterOptions['channel_cid']>;
1220
1061
  } & {
1221
1062
  reason?:
@@ -1233,9 +1074,9 @@ export type BannedUsersFilters = QueryFilters<
1233
1074
  >;
1234
1075
 
1235
1076
  export type ChannelFilters<
1236
- ChannelType = UnknownType,
1077
+ ChannelType = UR,
1237
1078
  CommandType extends string = LiteralStringForUnion,
1238
- UserType = UnknownType
1079
+ UserType = UR
1239
1080
  > = QueryFilters<
1240
1081
  ContainsOperator<ChannelType> & {
1241
1082
  members?:
@@ -1251,10 +1092,7 @@ export type ChannelFilters<
1251
1092
  >
1252
1093
  | PrimitiveFilter<ChannelResponse<ChannelType, CommandType, UserType>['name']>;
1253
1094
  } & {
1254
- [Key in keyof Omit<
1255
- ChannelResponse<{}, CommandType, UserType>,
1256
- 'name' | 'members'
1257
- >]:
1095
+ [Key in keyof Omit<ChannelResponse<{}, CommandType, UserType>, 'name' | 'members'>]:
1258
1096
  | RequireOnlyOne<QueryFilter<ChannelResponse<{}, CommandType, UserType>[Key]>>
1259
1097
  | PrimitiveFilter<ChannelResponse<{}, CommandType, UserType>[Key]>;
1260
1098
  }
@@ -1275,12 +1113,12 @@ export type ContainsOperator<CustomType = {}> = {
1275
1113
  };
1276
1114
 
1277
1115
  export type MessageFilters<
1278
- AttachmentType = UnknownType,
1279
- ChannelType = UnknownType,
1116
+ AttachmentType = UR,
1117
+ ChannelType = UR,
1280
1118
  CommandType extends string = LiteralStringForUnion,
1281
- MessageType = UnknownType,
1282
- ReactionType = UnknownType,
1283
- UserType = UnknownType
1119
+ MessageType = UR,
1120
+ ReactionType = UR,
1121
+ UserType = UR
1284
1122
  > = QueryFilters<
1285
1123
  ContainsOperator<MessageType> & {
1286
1124
  text?:
@@ -1294,78 +1132,29 @@ export type MessageFilters<
1294
1132
  ReactionType,
1295
1133
  UserType
1296
1134
  >['text'];
1297
- $q?: MessageResponse<
1298
- AttachmentType,
1299
- ChannelType,
1300
- CommandType,
1301
- MessageType,
1302
- ReactionType,
1303
- UserType
1304
- >['text'];
1135
+ $q?: MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>['text'];
1305
1136
  } & QueryFilter<
1306
- MessageResponse<
1307
- AttachmentType,
1308
- ChannelType,
1309
- CommandType,
1310
- MessageType,
1311
- ReactionType,
1312
- UserType
1313
- >['text']
1137
+ MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>['text']
1314
1138
  >
1315
1139
  >
1316
1140
  | PrimitiveFilter<
1317
- MessageResponse<
1318
- AttachmentType,
1319
- ChannelType,
1320
- CommandType,
1321
- MessageType,
1322
- ReactionType,
1323
- UserType
1324
- >['text']
1141
+ MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>['text']
1325
1142
  >;
1326
1143
  } & {
1327
1144
  [Key in keyof Omit<
1328
- MessageResponse<
1329
- AttachmentType,
1330
- ChannelType,
1331
- CommandType,
1332
- {},
1333
- ReactionType,
1334
- UserType
1335
- >,
1145
+ MessageResponse<AttachmentType, ChannelType, CommandType, {}, ReactionType, UserType>,
1336
1146
  'text'
1337
1147
  >]?:
1338
1148
  | RequireOnlyOne<
1339
- QueryFilter<
1340
- MessageResponse<
1341
- AttachmentType,
1342
- ChannelType,
1343
- CommandType,
1344
- {},
1345
- ReactionType,
1346
- UserType
1347
- >[Key]
1348
- >
1149
+ QueryFilter<MessageResponse<AttachmentType, ChannelType, CommandType, {}, ReactionType, UserType>[Key]>
1349
1150
  >
1350
- | PrimitiveFilter<
1351
- MessageResponse<
1352
- AttachmentType,
1353
- ChannelType,
1354
- CommandType,
1355
- {},
1356
- ReactionType,
1357
- UserType
1358
- >[Key]
1359
- >;
1151
+ | PrimitiveFilter<MessageResponse<AttachmentType, ChannelType, CommandType, {}, ReactionType, UserType>[Key]>;
1360
1152
  }
1361
1153
  >;
1362
1154
 
1363
1155
  export type PrimitiveFilter<ObjectType> = ObjectType | null;
1364
1156
 
1365
- export type QueryFilter<ObjectType = string> = NonNullable<ObjectType> extends
1366
- | string
1367
- | number
1368
- | boolean
1157
+ export type QueryFilter<ObjectType = string> = NonNullable<ObjectType> extends string | number | boolean
1369
1158
  ? {
1370
1159
  $eq?: PrimitiveFilter<ObjectType>;
1371
1160
  $exists?: boolean;
@@ -1396,21 +1185,13 @@ export type QueryLogicalOperators<Operators> = {
1396
1185
  $or?: ArrayTwoOrMore<QueryFilters<Operators>>;
1397
1186
  };
1398
1187
 
1399
- export type UserFilters<UserType = UnknownType> = QueryFilters<
1188
+ export type UserFilters<UserType = UR> = QueryFilters<
1400
1189
  ContainsOperator<UserType> & {
1401
1190
  id?:
1402
- | RequireOnlyOne<
1403
- { $autocomplete?: UserResponse<UserType>['id'] } & QueryFilter<
1404
- UserResponse<UserType>['id']
1405
- >
1406
- >
1191
+ | RequireOnlyOne<{ $autocomplete?: UserResponse<UserType>['id'] } & QueryFilter<UserResponse<UserType>['id']>>
1407
1192
  | PrimitiveFilter<UserResponse<UserType>['id']>;
1408
1193
  name?:
1409
- | RequireOnlyOne<
1410
- { $autocomplete?: UserResponse<UserType>['name'] } & QueryFilter<
1411
- UserResponse<UserType>['name']
1412
- >
1413
- >
1194
+ | RequireOnlyOne<{ $autocomplete?: UserResponse<UserType>['name'] } & QueryFilter<UserResponse<UserType>['name']>>
1414
1195
  | PrimitiveFilter<UserResponse<UserType>['name']>;
1415
1196
  teams?:
1416
1197
  | RequireOnlyOne<{
@@ -1420,9 +1201,7 @@ export type UserFilters<UserType = UnknownType> = QueryFilters<
1420
1201
  | PrimitiveFilter<UserResponse<UserType>['teams']>;
1421
1202
  username?:
1422
1203
  | RequireOnlyOne<
1423
- { $autocomplete?: UserResponse<UserType>['username'] } & QueryFilter<
1424
- UserResponse<UserType>['username']
1425
- >
1204
+ { $autocomplete?: UserResponse<UserType>['username'] } & QueryFilter<UserResponse<UserType>['username']>
1426
1205
  >
1427
1206
  | PrimitiveFilter<UserResponse<UserType>['username']>;
1428
1207
  } & {
@@ -1440,11 +1219,9 @@ export type BannedUsersSort = BannedUsersSortBase | Array<BannedUsersSortBase>;
1440
1219
 
1441
1220
  export type BannedUsersSortBase = { created_at?: AscDesc };
1442
1221
 
1443
- export type ChannelSort<ChannelType = UnknownType> =
1444
- | ChannelSortBase<ChannelType>
1445
- | Array<ChannelSortBase<ChannelType>>;
1222
+ export type ChannelSort<ChannelType = UR> = ChannelSortBase<ChannelType> | Array<ChannelSortBase<ChannelType>>;
1446
1223
 
1447
- export type ChannelSortBase<ChannelType = UnknownType> = Sort<ChannelType> & {
1224
+ export type ChannelSortBase<ChannelType = UR> = Sort<ChannelType> & {
1448
1225
  created_at?: AscDesc;
1449
1226
  has_unread?: AscDesc;
1450
1227
  last_message_at?: AscDesc;
@@ -1458,15 +1235,13 @@ export type Sort<T> = {
1458
1235
  [P in keyof T]?: AscDesc;
1459
1236
  };
1460
1237
 
1461
- export type UserSort<UserType = UnknownType> =
1462
- | Sort<UserResponse<UserType>>
1463
- | Array<Sort<UserResponse<UserType>>>;
1238
+ export type UserSort<UserType = UR> = Sort<UserResponse<UserType>> | Array<Sort<UserResponse<UserType>>>;
1464
1239
 
1465
- export type MemberSort<UserType = UnknownType> =
1240
+ export type MemberSort<UserType = UR> =
1466
1241
  | Sort<Pick<UserResponse<UserType>, 'id' | 'created_at' | 'name'>>
1467
1242
  | Array<Sort<Pick<UserResponse<UserType>, 'id' | 'created_at' | 'name'>>>;
1468
1243
 
1469
- export type SearchMessageSortBase<MessageType = UnknownType> = Sort<MessageType> & {
1244
+ export type SearchMessageSortBase<MessageType = UR> = Sort<MessageType> & {
1470
1245
  attachments?: AscDesc;
1471
1246
  'attachments.type'?: AscDesc;
1472
1247
  created_at?: AscDesc;
@@ -1482,15 +1257,11 @@ export type SearchMessageSortBase<MessageType = UnknownType> = Sort<MessageType>
1482
1257
  'user.id'?: AscDesc;
1483
1258
  };
1484
1259
 
1485
- export type SearchMessageSort<MessageType = UnknownType> =
1260
+ export type SearchMessageSort<MessageType = UR> =
1486
1261
  | SearchMessageSortBase<MessageType>
1487
1262
  | Array<SearchMessageSortBase<MessageType>>;
1488
1263
 
1489
- export type QuerySort<
1490
- ChannelType = UnknownType,
1491
- UserType = UnknownType,
1492
- MessageType = UnknownType
1493
- > =
1264
+ export type QuerySort<ChannelType = UR, UserType = UR, MessageType = UR> =
1494
1265
  | BannedUsersSort
1495
1266
  | ChannelSort<ChannelType>
1496
1267
  | SearchMessageSort<MessageType>
@@ -1567,7 +1338,7 @@ export type AppSettings = {
1567
1338
  webhook_url?: string;
1568
1339
  };
1569
1340
 
1570
- export type Attachment<T = UnknownType> = T & {
1341
+ export type Attachment<T = UR> = T & {
1571
1342
  actions?: Action[];
1572
1343
  asset_url?: string;
1573
1344
  author_icon?: string;
@@ -1606,9 +1377,7 @@ export type BlockList = {
1606
1377
  words: string[];
1607
1378
  };
1608
1379
 
1609
- export type ChannelConfig<
1610
- CommandType extends string = LiteralStringForUnion
1611
- > = ChannelConfigFields &
1380
+ export type ChannelConfig<CommandType extends string = LiteralStringForUnion> = ChannelConfigFields &
1612
1381
  CreatedAtUpdatedAt & {
1613
1382
  commands?: CommandVariants<CommandType>[];
1614
1383
  };
@@ -1644,19 +1413,17 @@ export type ChannelConfigFields = {
1644
1413
  url_enrichment?: boolean;
1645
1414
  };
1646
1415
 
1647
- export type ChannelConfigWithInfo<
1648
- CommandType extends string = LiteralStringForUnion
1649
- > = ChannelConfigFields &
1416
+ export type ChannelConfigWithInfo<CommandType extends string = LiteralStringForUnion> = ChannelConfigFields &
1650
1417
  CreatedAtUpdatedAt & {
1651
1418
  commands?: CommandResponse<CommandType>[];
1652
1419
  };
1653
1420
 
1654
- export type ChannelData<ChannelType = UnknownType> = ChannelType & {
1421
+ export type ChannelData<ChannelType = UR> = ChannelType & {
1655
1422
  members?: string[];
1656
1423
  name?: string;
1657
1424
  };
1658
1425
 
1659
- export type ChannelMembership<UserType = UnknownType> = {
1426
+ export type ChannelMembership<UserType = UR> = {
1660
1427
  banned?: boolean;
1661
1428
  channel_role?: Role;
1662
1429
  created_at?: string;
@@ -1668,9 +1435,9 @@ export type ChannelMembership<UserType = UnknownType> = {
1668
1435
  };
1669
1436
 
1670
1437
  export type ChannelMute<
1671
- ChannelType extends UnknownType = UnknownType,
1438
+ ChannelType extends UR = UR,
1672
1439
  CommandType extends string = LiteralStringForUnion,
1673
- UserType extends UnknownType = UnknownType
1440
+ UserType extends UR = UR
1674
1441
  > = {
1675
1442
  user: UserResponse<UserType>;
1676
1443
  channel?: ChannelResponse<ChannelType, CommandType, UserType>;
@@ -1687,7 +1454,7 @@ export type ChannelRole = {
1687
1454
  same_team?: boolean;
1688
1455
  };
1689
1456
 
1690
- export type CheckPushInput<UserType = UnknownType> = {
1457
+ export type CheckPushInput<UserType = UR> = {
1691
1458
  apn_template?: string;
1692
1459
  client_id?: string;
1693
1460
  connection_id?: string;
@@ -1717,9 +1484,9 @@ export type Configs<CommandType extends string = LiteralStringForUnion> = {
1717
1484
  };
1718
1485
 
1719
1486
  export type ConnectionOpen<
1720
- ChannelType extends UnknownType = UnknownType,
1487
+ ChannelType extends UR = UR,
1721
1488
  CommandType extends string = LiteralStringForUnion,
1722
- UserType extends UnknownType = UnknownType
1489
+ UserType extends UR = UR
1723
1490
  > = {
1724
1491
  connection_id: string;
1725
1492
  cid?: string;
@@ -1733,7 +1500,7 @@ export type CreatedAtUpdatedAt = {
1733
1500
  updated_at: string;
1734
1501
  };
1735
1502
 
1736
- export type Device<UserType = UnknownType> = DeviceFields & {
1503
+ export type Device<UserType = UR> = DeviceFields & {
1737
1504
  provider?: string;
1738
1505
  user?: UserResponse<UserType>;
1739
1506
  user_id?: string;
@@ -1875,25 +1642,17 @@ export type HuaweiConfig = {
1875
1642
 
1876
1643
  export type LiteralStringForUnion = string & {};
1877
1644
 
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>> & {
1645
+ export type LogLevel = 'info' | 'error' | 'warn';
1646
+
1647
+ export type Logger = (logLevel: LogLevel, message: string, extraData?: Record<string, unknown>) => void;
1648
+
1649
+ export type Message<AttachmentType = UR, MessageType = UR, UserType = UR> = Partial<
1650
+ MessageBase<AttachmentType, MessageType, UserType>
1651
+ > & {
1889
1652
  mentioned_users?: string[];
1890
1653
  };
1891
1654
 
1892
- export type MessageBase<
1893
- AttachmentType = UnknownType,
1894
- MessageType = UnknownType,
1895
- UserType = UnknownType
1896
- > = MessageType & {
1655
+ export type MessageBase<AttachmentType = UR, MessageType = UR, UserType = UR> = MessageType & {
1897
1656
  id: string;
1898
1657
  attachments?: Attachment<AttachmentType>[];
1899
1658
  html?: string;
@@ -1907,38 +1666,32 @@ export type MessageBase<
1907
1666
  user_id?: string;
1908
1667
  };
1909
1668
 
1910
- export type MessageLabel =
1911
- | 'deleted'
1912
- | 'ephemeral'
1913
- | 'error'
1914
- | 'regular'
1915
- | 'reply'
1916
- | 'system';
1669
+ export type MessageLabel = 'deleted' | 'ephemeral' | 'error' | 'regular' | 'reply' | 'system';
1917
1670
 
1918
- export type Mute<UserType = UnknownType> = {
1671
+ export type Mute<UserType = UR> = {
1919
1672
  created_at: string;
1920
1673
  target: UserResponse<UserType>;
1921
1674
  updated_at: string;
1922
1675
  user: UserResponse<UserType>;
1923
1676
  };
1924
1677
 
1925
- export type PartialUpdateChannel<ChannelType = UnknownType> = {
1678
+ export type PartialUpdateChannel<ChannelType = UR> = {
1926
1679
  set?: Partial<ChannelResponse<ChannelType>>;
1927
1680
  unset?: Array<keyof ChannelResponse<ChannelType>>;
1928
1681
  };
1929
1682
 
1930
- export type PartialUserUpdate<UserType = UnknownType> = {
1683
+ export type PartialUserUpdate<UserType = UR> = {
1931
1684
  id: string;
1932
1685
  set?: Partial<UserResponse<UserType>>;
1933
1686
  unset?: Array<keyof UserResponse<UserType>>;
1934
1687
  };
1935
1688
 
1936
- export type MessageUpdatableFields<MessageType = UnknownType> = Omit<
1689
+ export type MessageUpdatableFields<MessageType = UR> = Omit<
1937
1690
  MessageResponse<MessageType>,
1938
1691
  'cid' | 'created_at' | 'updated_at' | 'deleted_at' | 'user' | 'user_id'
1939
1692
  >;
1940
1693
 
1941
- export type PartialMessageUpdate<MessageType = UnknownType> = {
1694
+ export type PartialMessageUpdate<MessageType = UR> = {
1942
1695
  set?: Partial<MessageUpdatableFields<MessageType>>;
1943
1696
  unset?: Array<keyof MessageUpdatableFields<MessageType>>;
1944
1697
  };
@@ -1982,10 +1735,7 @@ export type RateLimitsInfo = {
1982
1735
 
1983
1736
  export type RateLimitsMap = Record<EndpointName, RateLimitsInfo>;
1984
1737
 
1985
- export type Reaction<
1986
- ReactionType = UnknownType,
1987
- UserType = UnknownType
1988
- > = ReactionType & {
1738
+ export type Reaction<ReactionType = UR, UserType = UR> = ReactionType & {
1989
1739
  type: string;
1990
1740
  message_id?: string;
1991
1741
  score?: number;
@@ -2014,12 +1764,12 @@ export type Resource =
2014
1764
  | 'UploadAttachment';
2015
1765
 
2016
1766
  export type SearchPayload<
2017
- AttachmentType = UnknownType,
2018
- ChannelType = UnknownType,
1767
+ AttachmentType = UR,
1768
+ ChannelType = UR,
2019
1769
  CommandType extends string = LiteralStringForUnion,
2020
- MessageType = UnknownType,
2021
- ReactionType = UnknownType,
2022
- UserType = UnknownType
1770
+ MessageType = UR,
1771
+ ReactionType = UR,
1772
+ UserType = UR
2023
1773
  > = Omit<SearchOptions<MessageType>, 'sort'> & {
2024
1774
  client_id?: string;
2025
1775
  connection_id?: string;
@@ -2118,26 +1868,33 @@ export type TranslationLanguages =
2118
1868
 
2119
1869
  export type TypingStartEvent = Event;
2120
1870
 
1871
+ export type ReservedMessageFields =
1872
+ | 'command'
1873
+ | 'created_at'
1874
+ | 'html'
1875
+ | 'latest_reactions'
1876
+ | 'own_reactions'
1877
+ | 'quoted_message'
1878
+ | 'reaction_counts'
1879
+ | 'reply_count'
1880
+ | 'type'
1881
+ | 'updated_at'
1882
+ | 'user'
1883
+ | '__html';
1884
+
2121
1885
  export type UpdatedMessage<
2122
- AttachmentType = UnknownType,
2123
- ChannelType = UnknownType,
1886
+ AttachmentType = UR,
1887
+ ChannelType = UR,
2124
1888
  CommandType extends string = LiteralStringForUnion,
2125
- MessageType = UnknownType,
2126
- ReactionType = UnknownType,
2127
- UserType = UnknownType
1889
+ MessageType = UR,
1890
+ ReactionType = UR,
1891
+ UserType = UR
2128
1892
  > = Omit<
2129
- MessageResponse<
2130
- AttachmentType,
2131
- ChannelType,
2132
- CommandType,
2133
- MessageType,
2134
- ReactionType,
2135
- UserType
2136
- >,
1893
+ MessageResponse<AttachmentType, ChannelType, CommandType, MessageType, ReactionType, UserType>,
2137
1894
  'mentioned_users'
2138
1895
  > & { mentioned_users?: string[] };
2139
1896
 
2140
- export type User<UserType = UnknownType> = UserType & {
1897
+ export type User<UserType = UR> = UserType & {
2141
1898
  id: string;
2142
1899
  anon?: boolean;
2143
1900
  name?: string;
@@ -2203,14 +1960,7 @@ export type CampaignData = {
2203
1960
 
2204
1961
  export type CampaignStatus = {
2205
1962
  errors: string[];
2206
- status:
2207
- | 'draft'
2208
- | 'stopped'
2209
- | 'scheduled'
2210
- | 'completed'
2211
- | 'failed'
2212
- | 'canceled'
2213
- | 'in_progress';
1963
+ status: 'draft' | 'stopped' | 'scheduled' | 'completed' | 'failed' | 'canceled' | 'in_progress';
2214
1964
  completed_at?: string;
2215
1965
  failed_at?: string;
2216
1966
  progress?: number;
@@ -2236,5 +1986,12 @@ export type TaskStatus = {
2236
1986
  description: string;
2237
1987
  type: string;
2238
1988
  };
2239
- result?: UnknownType;
1989
+ result?: UR;
1990
+ };
1991
+
1992
+ export type TruncateOptions<AttachmentType, MessageType, UserType> = {
1993
+ hard_delete?: boolean;
1994
+ message?: Message<AttachmentType, MessageType, UserType>;
1995
+ skip_push?: boolean;
1996
+ truncated_at?: Date;
2240
1997
  };