stream-chat 8.57.1 → 9.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -65
- package/dist/cjs/index.browser.cjs +11043 -0
- package/dist/cjs/index.browser.cjs.map +7 -0
- package/dist/cjs/index.node.cjs +22452 -0
- package/dist/cjs/index.node.cjs.map +7 -0
- package/dist/esm/index.js +11039 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/types/base64.d.ts +0 -1
- package/dist/types/campaign.d.ts +12 -13
- package/dist/types/channel.d.ts +143 -145
- package/dist/types/channel_manager.d.ts +23 -27
- package/dist/types/channel_state.d.ts +51 -52
- package/dist/types/client.d.ts +293 -347
- package/dist/types/client_state.d.ts +7 -8
- package/dist/types/connection.d.ts +13 -16
- package/dist/types/connection_fallback.d.ts +5 -6
- package/dist/types/constants.d.ts +0 -1
- package/dist/types/custom_types.d.ts +22 -0
- package/dist/types/errors.d.ts +2 -3
- package/dist/types/events.d.ts +0 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/insights.d.ts +5 -7
- package/dist/types/moderation.d.ts +8 -9
- package/dist/types/permissions.d.ts +2 -3
- package/dist/types/poll.d.ts +34 -35
- package/dist/types/poll_manager.d.ts +9 -10
- package/dist/types/search_controller.d.ts +42 -47
- package/dist/types/segment.d.ts +7 -8
- package/dist/types/signing.d.ts +3 -5
- package/dist/types/store.d.ts +5 -6
- package/dist/types/thread.d.ts +31 -31
- package/dist/types/thread_manager.d.ts +10 -11
- package/dist/types/token_manager.d.ts +9 -10
- package/dist/types/types.d.ts +820 -822
- package/dist/types/utils.d.ts +34 -36
- package/package.json +55 -59
- package/src/campaign.ts +4 -4
- package/src/channel.ts +195 -226
- package/src/channel_manager.ts +37 -51
- package/src/channel_state.ts +59 -82
- package/src/client.ts +287 -345
- package/src/client_state.ts +8 -8
- package/src/connection.ts +31 -21
- package/src/connection_fallback.ts +15 -13
- package/src/custom_types.ts +13 -0
- package/src/errors.ts +1 -1
- package/src/index.ts +1 -0
- package/src/moderation.ts +8 -13
- package/src/permissions.ts +1 -1
- package/src/poll.ts +51 -68
- package/src/poll_manager.ts +10 -15
- package/src/search_controller.ts +37 -49
- package/src/segment.ts +4 -11
- package/src/signing.ts +10 -5
- package/src/thread.ts +31 -39
- package/src/thread_manager.ts +14 -14
- package/src/token_manager.ts +10 -9
- package/src/types.ts +641 -766
- package/src/utils.ts +31 -66
- package/dist/browser.es.js +0 -19235
- package/dist/browser.es.js.map +0 -1
- package/dist/browser.full-bundle.min.js +0 -2
- package/dist/browser.full-bundle.min.js.map +0 -1
- package/dist/browser.js +0 -19316
- package/dist/browser.js.map +0 -1
- package/dist/index.es.js +0 -19238
- package/dist/index.es.js.map +0 -1
- package/dist/index.js +0 -19322
- package/dist/index.js.map +0 -1
- package/dist/types/base64.d.ts.map +0 -1
- package/dist/types/campaign.d.ts.map +0 -1
- package/dist/types/channel.d.ts.map +0 -1
- package/dist/types/channel_manager.d.ts.map +0 -1
- package/dist/types/channel_state.d.ts.map +0 -1
- package/dist/types/client.d.ts.map +0 -1
- package/dist/types/client_state.d.ts.map +0 -1
- package/dist/types/connection.d.ts.map +0 -1
- package/dist/types/connection_fallback.d.ts.map +0 -1
- package/dist/types/constants.d.ts.map +0 -1
- package/dist/types/errors.d.ts.map +0 -1
- package/dist/types/events.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/insights.d.ts.map +0 -1
- package/dist/types/moderation.d.ts.map +0 -1
- package/dist/types/permissions.d.ts.map +0 -1
- package/dist/types/poll.d.ts.map +0 -1
- package/dist/types/poll_manager.d.ts.map +0 -1
- package/dist/types/search_controller.d.ts.map +0 -1
- package/dist/types/segment.d.ts.map +0 -1
- package/dist/types/signing.d.ts.map +0 -1
- package/dist/types/store.d.ts.map +0 -1
- package/dist/types/thread.d.ts.map +0 -1
- package/dist/types/thread_manager.d.ts.map +0 -1
- package/dist/types/token_manager.d.ts.map +0 -1
- package/dist/types/types.d.ts.map +0 -1
- package/dist/types/utils.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
You can sign up for a Stream account at our [Get Started](https://getstream.io/chat/get_started/) page.
|
|
22
22
|
|
|
23
|
-
This library can be used by both frontend and backend applications. For frontend, we have frameworks that are based on this library such as the [Flutter](https://github.com/GetStream/stream-chat-flutter), [React](https://github.com/GetStream/stream-chat-react) and [Angular](https://github.com/GetStream/stream-chat-angular) SDKs. For more information, check out our [
|
|
23
|
+
This library can be used by both frontend and backend applications. For frontend, we have frameworks that are based on this library such as the [Flutter](https://github.com/GetStream/stream-chat-flutter), [React](https://github.com/GetStream/stream-chat-react) and [Angular](https://github.com/GetStream/stream-chat-angular) SDKs. For more information, check out our [documentation](https://getstream.io/chat/docs/).
|
|
24
24
|
|
|
25
25
|
## ⚙️ Installation
|
|
26
26
|
|
|
@@ -36,95 +36,89 @@ npm install stream-chat
|
|
|
36
36
|
yarn add stream-chat
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
## ✨ Getting Started
|
|
40
40
|
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
```ts
|
|
42
|
+
import { StreamChat } from 'stream-chat';
|
|
43
|
+
// or if you are using CommonJS
|
|
44
|
+
const { StreamChat } = require('stream-chat');
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
const client = new StreamChat('API_KEY', 'API_SECRET', {
|
|
47
|
+
disableCache: true, // recommended option for server-side use
|
|
48
|
+
// ...other options like `baseURL`...
|
|
49
|
+
});
|
|
46
50
|
|
|
47
|
-
|
|
51
|
+
// create a user
|
|
52
|
+
await client.upsertUser({
|
|
53
|
+
id: 'vishal-1',
|
|
54
|
+
name: 'Vishal',
|
|
55
|
+
});
|
|
48
56
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const StreamChat = require('stream-chat').StreamChat;
|
|
57
|
+
// create a channel
|
|
58
|
+
const channel = client.channel('messaging', 'test-channel', { created_by_id: 'vishal-1' });
|
|
59
|
+
await channel.create();
|
|
53
60
|
|
|
54
|
-
|
|
61
|
+
// send message
|
|
62
|
+
const { message } = await channel.sendMessage({ text: 'This is a test message' });
|
|
55
63
|
|
|
56
|
-
|
|
57
|
-
await channel.
|
|
64
|
+
// send reaction
|
|
65
|
+
await channel.sendReaction(message.id, { type: 'love', user: { id: 'vishal-1' } });
|
|
58
66
|
```
|
|
59
67
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
```typescript
|
|
63
|
-
type ChatChannel = { image: string; category?: string };
|
|
64
|
-
type ChatUser1 = { nickname: string; age: number; admin?: boolean };
|
|
65
|
-
type ChatUser2 = { nickname: string; avatar?: string };
|
|
66
|
-
type UserMessage = { country?: string };
|
|
67
|
-
type AdminMessage = { priorityLevel: number };
|
|
68
|
-
type ChatAttachment = { originalURL?: string };
|
|
69
|
-
type CustomReaction = { size?: number };
|
|
70
|
-
type ChatEvent = { quitChannel?: boolean };
|
|
71
|
-
type CustomCommands = 'giphy';
|
|
72
|
-
|
|
73
|
-
type StreamType = {
|
|
74
|
-
attachmentType: ChatAttachment;
|
|
75
|
-
channelType: ChatChannel;
|
|
76
|
-
commandType: CustomCommands;
|
|
77
|
-
eventType: ChatEvent;
|
|
78
|
-
messageType: UserMessage | AdminMessage;
|
|
79
|
-
reactionType: CustomReaction;
|
|
80
|
-
userType: ChatUser1 | ChatUser2;
|
|
81
|
-
};
|
|
68
|
+
The `StreamChat` client is set up to allow extension of the base types through use of module augmentation, custom types will carry through to all client returns and provide code-completion to queries (if supported). To extend Stream's entities with custom data you'll have to create a declaration file and make sure it's loaded by TypeScript, [see the list of extendable interfaces](https://github.com/GetStream/stream-chat-js/blob/master/src/custom_types.ts) and the example bellow using two of the most common ones:
|
|
82
69
|
|
|
83
|
-
|
|
70
|
+
```ts
|
|
71
|
+
// stream-custom-data.d.ts
|
|
84
72
|
|
|
85
|
-
|
|
86
|
-
const channel = client.channel('messaging', 'TestChannel');
|
|
87
|
-
await channel.create();
|
|
73
|
+
import 'stream-chat';
|
|
88
74
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
75
|
+
declare module 'stream-chat' {
|
|
76
|
+
interface CustomMessageData {
|
|
77
|
+
custom_property?: number;
|
|
78
|
+
}
|
|
79
|
+
interface CustomUserData {
|
|
80
|
+
profile_picture?: string;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
94
83
|
|
|
95
|
-
//
|
|
96
|
-
const { message } = await channel.sendMessage({ text: `Test message` });
|
|
84
|
+
// index.ts
|
|
97
85
|
|
|
98
|
-
//
|
|
99
|
-
await
|
|
86
|
+
// property `profile_picture` is code-completed and expects type `string | undefined`
|
|
87
|
+
await client.partialUpdateUser({ id: 'vishal-1', set: { profile_picture: 'https://random.picture/1.jpg' } });
|
|
88
|
+
|
|
89
|
+
// property `custom_property` is code-completed and expects type `number | undefined`
|
|
90
|
+
const { message } = await channel.sendMessage({ text: 'This is another test message', custom_property: 255 });
|
|
91
|
+
|
|
92
|
+
message.custom_property; // in the response object as well
|
|
100
93
|
```
|
|
101
94
|
|
|
102
|
-
|
|
95
|
+
> [!WARNING]
|
|
96
|
+
> Generics mechanism has been removed in version `9.0.0` in favour of the module augmentation, please see [the release guide](https://getstream.io/chat/docs/node/upgrade-stream-chat-to-v9) on how to migrate.
|
|
103
97
|
|
|
104
|
-
## 🔗 (Optional) Development Setup in Combination
|
|
98
|
+
## 🔗 (Optional) Development Setup in Combination With Our SDKs
|
|
105
99
|
|
|
106
100
|
### Connect to [Stream Chat React Native SDK](https://github.com/GetStream/stream-chat-react-native)
|
|
107
101
|
|
|
108
|
-
Run in the root of this
|
|
102
|
+
Run in the root of this repository:
|
|
109
103
|
|
|
110
|
-
```
|
|
104
|
+
```sh
|
|
111
105
|
yarn link
|
|
112
106
|
```
|
|
113
107
|
|
|
114
|
-
Run in the root of one of the example
|
|
108
|
+
Run in the root of one of the example applications (SampleApp/TypeScriptMessaging) in the `stream-chat-react-native` repository:
|
|
115
109
|
|
|
116
|
-
```
|
|
110
|
+
```sh
|
|
117
111
|
yarn link stream-chat
|
|
118
112
|
yarn start
|
|
119
113
|
```
|
|
120
114
|
|
|
121
|
-
Open `metro.config.js` file and set value for watchFolders as
|
|
115
|
+
Open `metro.config.js` file and set value for `watchFolders` as:
|
|
122
116
|
|
|
123
|
-
```
|
|
124
|
-
const streamChatRoot = '
|
|
117
|
+
```js
|
|
118
|
+
const streamChatRoot = '<PATH TO YOUR PROJECT>/stream-chat-js'
|
|
125
119
|
|
|
126
120
|
module.exports = {
|
|
127
|
-
// the rest of the metro
|
|
121
|
+
// the rest of the metro configuration goes here
|
|
128
122
|
...
|
|
129
123
|
watchFolders: [projectRoot].concat(alternateRoots).concat([streamChatRoot]),
|
|
130
124
|
resolver: {
|
|
@@ -139,17 +133,17 @@ module.exports = {
|
|
|
139
133
|
};
|
|
140
134
|
```
|
|
141
135
|
|
|
142
|
-
Make sure to replace
|
|
136
|
+
Make sure to replace `<PATH TO YOUR PROJECT>` with the correct path for the `stream-chat-js` folder as per your directory structure.
|
|
143
137
|
|
|
144
|
-
Run in the root of this
|
|
138
|
+
Run in the root of this repository:
|
|
145
139
|
|
|
146
|
-
```
|
|
140
|
+
```sh
|
|
147
141
|
yarn start
|
|
148
142
|
```
|
|
149
143
|
|
|
150
|
-
## 📚 More
|
|
144
|
+
## 📚 More Code Examples
|
|
151
145
|
|
|
152
|
-
|
|
146
|
+
Read up more on [Logging](./docs/logging.md) and [User Token](./docs/userToken.md) or visit our [documentation](https://getstream.io/chat/docs/) for more examples.
|
|
153
147
|
|
|
154
148
|
## ✍️ Contributing
|
|
155
149
|
|
|
@@ -157,7 +151,7 @@ We welcome code changes that improve this library or fix a problem, please make
|
|
|
157
151
|
|
|
158
152
|
Head over to [CONTRIBUTING.md](./CONTRIBUTING.md) for some development tips.
|
|
159
153
|
|
|
160
|
-
## 🧑💻 We
|
|
154
|
+
## 🧑💻 We Are Hiring!
|
|
161
155
|
|
|
162
156
|
We've recently closed a [$38 million Series B funding round](https://techcrunch.com/2021/03/04/stream-raises-38m-as-its-chat-and-activity-feed-apis-power-communications-for-1b-users/) and we keep actively growing.
|
|
163
157
|
Our APIs are used by more than a billion end-users, and you'll have a chance to make a huge impact on the product within a team of the strongest engineers all over the world.
|