@stream-io/node-sdk 0.3.0 → 0.4.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 (70) hide show
  1. package/README.md +1 -1
  2. package/dist/index.cjs.js +4140 -9282
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.d.ts +2 -3
  5. package/dist/index.es.js +4140 -9206
  6. package/dist/index.es.js.map +1 -1
  7. package/dist/src/BaseApi.d.ts +10 -0
  8. package/dist/src/StreamCall.d.ts +5 -37
  9. package/dist/src/StreamChannel.d.ts +7 -34
  10. package/dist/src/StreamChatClient.d.ts +2 -25
  11. package/dist/src/StreamClient.d.ts +51 -59
  12. package/dist/src/StreamModerationClient.d.ts +3 -0
  13. package/dist/src/StreamVideoClient.d.ts +2 -18
  14. package/dist/src/gen/chat/ChannelApi.d.ts +33 -0
  15. package/dist/src/gen/chat/ChatApi.d.ts +241 -0
  16. package/dist/src/gen/common/CommonApi.d.ts +99 -0
  17. package/dist/src/gen/model-decoders/index.d.ts +3 -0
  18. package/dist/src/gen/models/index.d.ts +3878 -0
  19. package/dist/src/gen/moderation/ModerationApi.d.ts +38 -0
  20. package/dist/src/gen/video/CallApi.d.ts +56 -0
  21. package/dist/src/gen/video/VideoApi.d.ts +151 -0
  22. package/dist/src/types.d.ts +25 -0
  23. package/dist/src/utils/create-token.d.ts +2 -0
  24. package/dist/src/utils/rate-limit.d.ts +2 -0
  25. package/index.ts +2 -3
  26. package/package.json +12 -4
  27. package/src/BaseApi.ts +115 -0
  28. package/src/StreamCall.ts +9 -199
  29. package/src/StreamChannel.ts +23 -246
  30. package/src/StreamChatClient.ts +3 -122
  31. package/src/StreamClient.ts +101 -345
  32. package/src/StreamModerationClient.ts +3 -0
  33. package/src/StreamVideoClient.ts +3 -95
  34. package/src/gen/chat/ChannelApi.ts +270 -0
  35. package/src/gen/chat/ChatApi.ts +1857 -0
  36. package/src/gen/common/CommonApi.ts +1004 -0
  37. package/src/gen/model-decoders/index.ts +1897 -0
  38. package/src/gen/models/index.ts +6790 -0
  39. package/src/gen/moderation/ModerationApi.ts +476 -0
  40. package/src/gen/video/CallApi.ts +309 -0
  41. package/src/gen/video/VideoApi.ts +1011 -0
  42. package/src/types.ts +35 -0
  43. package/src/utils/create-token.ts +6 -1
  44. package/src/utils/rate-limit.ts +21 -0
  45. package/dist/src/gen/chat/apis/ProductchatApi.d.ts +0 -1750
  46. package/dist/src/gen/chat/apis/index.d.ts +0 -1
  47. package/dist/src/gen/chat/index.d.ts +0 -3
  48. package/dist/src/gen/chat/models/index.d.ts +0 -14865
  49. package/dist/src/gen/chat/runtime.d.ts +0 -180
  50. package/dist/src/gen/video/apis/ProductvideoApi.d.ts +0 -648
  51. package/dist/src/gen/video/apis/index.d.ts +0 -1
  52. package/dist/src/gen/video/index.d.ts +0 -3
  53. package/dist/src/gen/video/models/index.d.ts +0 -5011
  54. package/dist/src/gen/video/runtime.d.ts +0 -180
  55. package/src/gen/chat/.openapi-generator/FILES +0 -6
  56. package/src/gen/chat/.openapi-generator/VERSION +0 -1
  57. package/src/gen/chat/.openapi-generator-ignore +0 -23
  58. package/src/gen/chat/apis/ProductchatApi.ts +0 -7007
  59. package/src/gen/chat/apis/index.ts +0 -3
  60. package/src/gen/chat/index.ts +0 -5
  61. package/src/gen/chat/models/index.ts +0 -14766
  62. package/src/gen/chat/runtime.ts +0 -415
  63. package/src/gen/video/.openapi-generator/FILES +0 -6
  64. package/src/gen/video/.openapi-generator/VERSION +0 -1
  65. package/src/gen/video/.openapi-generator-ignore +0 -23
  66. package/src/gen/video/apis/ProductvideoApi.ts +0 -2575
  67. package/src/gen/video/apis/index.ts +0 -3
  68. package/src/gen/video/index.ts +0 -5
  69. package/src/gen/video/models/index.ts +0 -5000
  70. package/src/gen/video/runtime.ts +0 -415
@@ -0,0 +1,270 @@
1
+ import { ChatApi } from './ChatApi';
2
+ import { StreamResponse } from '../../types';
3
+ import {
4
+ ChannelGetOrCreateRequest,
5
+ ChannelStateResponse,
6
+ DeleteChannelResponse,
7
+ EventResponse,
8
+ FileUploadRequest,
9
+ FileUploadResponse,
10
+ GetManyMessagesResponse,
11
+ HideChannelRequest,
12
+ HideChannelResponse,
13
+ ImageUploadRequest,
14
+ ImageUploadResponse,
15
+ MarkReadRequest,
16
+ MarkReadResponse,
17
+ MarkUnreadRequest,
18
+ Response,
19
+ SendEventRequest,
20
+ SendMessageRequest,
21
+ SendMessageResponse,
22
+ ShowChannelRequest,
23
+ ShowChannelResponse,
24
+ TruncateChannelRequest,
25
+ TruncateChannelResponse,
26
+ UpdateChannelPartialRequest,
27
+ UpdateChannelPartialResponse,
28
+ UpdateChannelRequest,
29
+ UpdateChannelResponse,
30
+ } from '../models';
31
+
32
+ export class ChannelApi {
33
+ constructor(
34
+ protected chatApi: ChatApi,
35
+ public readonly type: string,
36
+ public id?: string,
37
+ ) {}
38
+
39
+ delete = (request?: {
40
+ hard_delete?: boolean;
41
+ }): Promise<StreamResponse<DeleteChannelResponse>> => {
42
+ if (!this.id) {
43
+ throw new Error(
44
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
45
+ );
46
+ }
47
+ return this.chatApi.deleteChannel({
48
+ id: this.id,
49
+ type: this.type,
50
+ ...request,
51
+ });
52
+ };
53
+
54
+ updateChannelPartial = (
55
+ request?: UpdateChannelPartialRequest,
56
+ ): Promise<StreamResponse<UpdateChannelPartialResponse>> => {
57
+ if (!this.id) {
58
+ throw new Error(
59
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
60
+ );
61
+ }
62
+ return this.chatApi.updateChannelPartial({
63
+ id: this.id,
64
+ type: this.type,
65
+ ...request,
66
+ });
67
+ };
68
+
69
+ update = (
70
+ request?: UpdateChannelRequest,
71
+ ): Promise<StreamResponse<UpdateChannelResponse>> => {
72
+ if (!this.id) {
73
+ throw new Error(
74
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
75
+ );
76
+ }
77
+ return this.chatApi.updateChannel({
78
+ id: this.id,
79
+ type: this.type,
80
+ ...request,
81
+ });
82
+ };
83
+
84
+ sendEvent = (
85
+ request: SendEventRequest,
86
+ ): Promise<StreamResponse<EventResponse>> => {
87
+ if (!this.id) {
88
+ throw new Error(
89
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
90
+ );
91
+ }
92
+ return this.chatApi.sendEvent({ id: this.id, type: this.type, ...request });
93
+ };
94
+
95
+ deleteFile = (request?: {
96
+ url?: string;
97
+ }): Promise<StreamResponse<Response>> => {
98
+ if (!this.id) {
99
+ throw new Error(
100
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
101
+ );
102
+ }
103
+ return this.chatApi.deleteFile({
104
+ id: this.id,
105
+ type: this.type,
106
+ ...request,
107
+ });
108
+ };
109
+
110
+ uploadFile = (
111
+ request?: FileUploadRequest,
112
+ ): Promise<StreamResponse<FileUploadResponse>> => {
113
+ if (!this.id) {
114
+ throw new Error(
115
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
116
+ );
117
+ }
118
+ return this.chatApi.uploadFile({
119
+ id: this.id,
120
+ type: this.type,
121
+ ...request,
122
+ });
123
+ };
124
+
125
+ hide = (
126
+ request?: HideChannelRequest,
127
+ ): Promise<StreamResponse<HideChannelResponse>> => {
128
+ if (!this.id) {
129
+ throw new Error(
130
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
131
+ );
132
+ }
133
+ return this.chatApi.hideChannel({
134
+ id: this.id,
135
+ type: this.type,
136
+ ...request,
137
+ });
138
+ };
139
+
140
+ deleteImage = (request?: {
141
+ url?: string;
142
+ }): Promise<StreamResponse<Response>> => {
143
+ if (!this.id) {
144
+ throw new Error(
145
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
146
+ );
147
+ }
148
+ return this.chatApi.deleteImage({
149
+ id: this.id,
150
+ type: this.type,
151
+ ...request,
152
+ });
153
+ };
154
+
155
+ uploadImage = (
156
+ request?: ImageUploadRequest,
157
+ ): Promise<StreamResponse<ImageUploadResponse>> => {
158
+ if (!this.id) {
159
+ throw new Error(
160
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
161
+ );
162
+ }
163
+ return this.chatApi.uploadImage({
164
+ id: this.id,
165
+ type: this.type,
166
+ ...request,
167
+ });
168
+ };
169
+
170
+ sendMessage = (
171
+ request: SendMessageRequest,
172
+ ): Promise<StreamResponse<SendMessageResponse>> => {
173
+ if (!this.id) {
174
+ throw new Error(
175
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
176
+ );
177
+ }
178
+ return this.chatApi.sendMessage({
179
+ id: this.id,
180
+ type: this.type,
181
+ ...request,
182
+ });
183
+ };
184
+
185
+ getManyMessages = (request: {
186
+ ids: string[];
187
+ }): Promise<StreamResponse<GetManyMessagesResponse>> => {
188
+ if (!this.id) {
189
+ throw new Error(
190
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
191
+ );
192
+ }
193
+ return this.chatApi.getManyMessages({
194
+ id: this.id,
195
+ type: this.type,
196
+ ...request,
197
+ });
198
+ };
199
+
200
+ getOrCreate = (
201
+ request?: ChannelGetOrCreateRequest,
202
+ ): Promise<StreamResponse<ChannelStateResponse>> => {
203
+ if (!this.id) {
204
+ throw new Error(
205
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
206
+ );
207
+ }
208
+ return this.chatApi.getOrCreateChannel({
209
+ id: this.id,
210
+ type: this.type,
211
+ ...request,
212
+ });
213
+ };
214
+
215
+ markRead = (
216
+ request?: MarkReadRequest,
217
+ ): Promise<StreamResponse<MarkReadResponse>> => {
218
+ if (!this.id) {
219
+ throw new Error(
220
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
221
+ );
222
+ }
223
+ return this.chatApi.markRead({ id: this.id, type: this.type, ...request });
224
+ };
225
+
226
+ show = (
227
+ request?: ShowChannelRequest,
228
+ ): Promise<StreamResponse<ShowChannelResponse>> => {
229
+ if (!this.id) {
230
+ throw new Error(
231
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
232
+ );
233
+ }
234
+ return this.chatApi.showChannel({
235
+ id: this.id,
236
+ type: this.type,
237
+ ...request,
238
+ });
239
+ };
240
+
241
+ truncate = (
242
+ request?: TruncateChannelRequest,
243
+ ): Promise<StreamResponse<TruncateChannelResponse>> => {
244
+ if (!this.id) {
245
+ throw new Error(
246
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
247
+ );
248
+ }
249
+ return this.chatApi.truncateChannel({
250
+ id: this.id,
251
+ type: this.type,
252
+ ...request,
253
+ });
254
+ };
255
+
256
+ markUnread = (
257
+ request?: MarkUnreadRequest,
258
+ ): Promise<StreamResponse<Response>> => {
259
+ if (!this.id) {
260
+ throw new Error(
261
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
262
+ );
263
+ }
264
+ return this.chatApi.markUnread({
265
+ id: this.id,
266
+ type: this.type,
267
+ ...request,
268
+ });
269
+ };
270
+ }