stream-chat 5.6.0 → 6.0.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 (40) hide show
  1. package/README.md +21 -13
  2. package/dist/browser.es.js +120 -123
  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 +120 -123
  7. package/dist/browser.js.map +1 -1
  8. package/dist/index.es.js +120 -123
  9. package/dist/index.es.js.map +1 -1
  10. package/dist/index.js +120 -123
  11. package/dist/index.js.map +1 -1
  12. package/dist/types/channel.d.ts +123 -123
  13. package/dist/types/channel.d.ts.map +1 -1
  14. package/dist/types/channel_state.d.ts +41 -41
  15. package/dist/types/channel_state.d.ts.map +1 -1
  16. package/dist/types/client.d.ts +161 -161
  17. package/dist/types/client.d.ts.map +1 -1
  18. package/dist/types/client_state.d.ts +6 -6
  19. package/dist/types/client_state.d.ts.map +1 -1
  20. package/dist/types/connection.d.ts +10 -10
  21. package/dist/types/connection.d.ts.map +1 -1
  22. package/dist/types/connection_fallback.d.ts +7 -7
  23. package/dist/types/connection_fallback.d.ts.map +1 -1
  24. package/dist/types/insights.d.ts +2 -2
  25. package/dist/types/token_manager.d.ts +6 -6
  26. package/dist/types/token_manager.d.ts.map +1 -1
  27. package/dist/types/types.d.ts +330 -232
  28. package/dist/types/types.d.ts.map +1 -1
  29. package/dist/types/utils.d.ts +2 -2
  30. package/dist/types/utils.d.ts.map +1 -1
  31. package/package.json +2 -2
  32. package/src/channel.ts +191 -289
  33. package/src/channel_state.ts +54 -219
  34. package/src/client.ts +246 -521
  35. package/src/client_state.ts +6 -6
  36. package/src/connection.ts +7 -22
  37. package/src/connection_fallback.ts +7 -21
  38. package/src/token_manager.ts +6 -6
  39. package/src/types.ts +432 -483
  40. package/src/utils.ts +7 -11
package/README.md CHANGED
@@ -35,7 +35,15 @@ Documentation for this JavaScript client are available at the [Stream Website](h
35
35
  The StreamChat client is setup to allow extension of the base types through use of generics when instantiated. The default instantiation has all generics set to `Record<string, unknown>`.
36
36
 
37
37
  ```typescript
38
- StreamChat<AttachmentType, ChannelType, CommandType, EventType, MessageType, ReactionType, UserType>
38
+ StreamChat<{
39
+ attachmentType: AttachmentType;
40
+ channelType: ChannelType;
41
+ commandType: CommandType;
42
+ eventType: EventType;
43
+ messageType: MessageType;
44
+ reactionType: ReactionType;
45
+ userType: UserType;
46
+ }>
39
47
  ```
40
48
 
41
49
  Custom types provided when initializing the client will carry through to all client returns and provide intellisense to queries.
@@ -57,26 +65,26 @@ type CustomReaction = { size?: number };
57
65
  type ChatEvent = { quitChannel?: boolean };
58
66
  type CustomCommands = 'giphy';
59
67
 
68
+ type StreamType = {
69
+ attachmentType: ChatAttachment;
70
+ channelType: ChatChannel;
71
+ commandType: CustomCommands;
72
+ eventType: ChatEvent;
73
+ messageType: UserMessage | AdminMessage;
74
+ reactionType: CustomReaction;
75
+ userType: ChatUser1 | ChatUser2;
76
+ };
77
+
60
78
  // Instantiate a new client (server side)
61
79
  // you can also use `new StreamChat<T,T,...>()`
62
- const client = StreamChat.getInstance<
63
- ChatAttachment,
64
- ChatChannel,
65
- CustomCommands,
66
- ChatEvent,
67
- UserMessage | AdminMessage,
68
- CustomReaction,
69
- ChatUser1 | ChatUser2
70
- >('YOUR_API_KEY', 'API_KEY_SECRET');
80
+ const client = StreamChat.getInstance<StreamType>('YOUR_API_KEY', 'API_KEY_SECRET');
71
81
 
72
82
  /**
73
83
  * Instantiate a new client (client side)
74
84
  * Unused generics default to Record<string, unknown>
75
85
  * with the exception of Command which defaults to string & {}
76
86
  */
77
- const client = StreamChat.getInstance<{}, ChatChannel, {}, {}, UserMessage | AdminMessage, {}, ChatUser1 | ChatUser2>(
78
- 'YOUR_API_KEY',
79
- );
87
+ const client = StreamChat.getInstance<StreamType>('YOUR_API_KEY');
80
88
  ```
81
89
 
82
90
  Query operations will return results that utilize the custom types added via generics. In addition the query filters are type checked and provide intellisense using both the key and type of the parameter to ensure accurate use.