@stream-io/node-sdk 0.3.1 → 0.4.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.
- package/dist/index.cjs.js +4136 -9282
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -3
- package/dist/index.es.js +4136 -9206
- package/dist/index.es.js.map +1 -1
- package/dist/src/BaseApi.d.ts +10 -0
- package/dist/src/StreamCall.d.ts +5 -37
- package/dist/src/StreamChannel.d.ts +7 -34
- package/dist/src/StreamChatClient.d.ts +2 -25
- package/dist/src/StreamClient.d.ts +51 -59
- package/dist/src/StreamModerationClient.d.ts +3 -0
- package/dist/src/StreamVideoClient.d.ts +2 -18
- package/dist/src/gen/chat/ChannelApi.d.ts +33 -0
- package/dist/src/gen/chat/ChatApi.d.ts +241 -0
- package/dist/src/gen/common/CommonApi.d.ts +99 -0
- package/dist/src/gen/model-decoders/index.d.ts +3 -0
- package/dist/src/gen/models/index.d.ts +3881 -0
- package/dist/src/gen/moderation/ModerationApi.d.ts +38 -0
- package/dist/src/gen/video/CallApi.d.ts +56 -0
- package/dist/src/gen/video/VideoApi.d.ts +151 -0
- package/dist/src/types.d.ts +25 -0
- package/dist/src/utils/create-token.d.ts +2 -0
- package/dist/src/utils/rate-limit.d.ts +2 -0
- package/index.ts +2 -3
- package/package.json +5 -4
- package/src/BaseApi.ts +115 -0
- package/src/StreamCall.ts +9 -199
- package/src/StreamChannel.ts +23 -246
- package/src/StreamChatClient.ts +3 -122
- package/src/StreamClient.ts +101 -345
- package/src/StreamModerationClient.ts +3 -0
- package/src/StreamVideoClient.ts +3 -95
- package/src/gen/chat/ChannelApi.ts +270 -0
- package/src/gen/chat/ChatApi.ts +1857 -0
- package/src/gen/common/CommonApi.ts +1004 -0
- package/src/gen/model-decoders/index.ts +1897 -0
- package/src/gen/models/index.ts +6794 -0
- package/src/gen/moderation/ModerationApi.ts +476 -0
- package/src/gen/video/CallApi.ts +309 -0
- package/src/gen/video/VideoApi.ts +1007 -0
- package/src/types.ts +35 -0
- package/src/utils/create-token.ts +6 -1
- package/src/utils/rate-limit.ts +21 -0
- package/dist/src/gen/chat/apis/ProductchatApi.d.ts +0 -1750
- package/dist/src/gen/chat/apis/index.d.ts +0 -1
- package/dist/src/gen/chat/index.d.ts +0 -3
- package/dist/src/gen/chat/models/index.d.ts +0 -14865
- package/dist/src/gen/chat/runtime.d.ts +0 -180
- package/dist/src/gen/video/apis/ProductvideoApi.d.ts +0 -648
- package/dist/src/gen/video/apis/index.d.ts +0 -1
- package/dist/src/gen/video/index.d.ts +0 -3
- package/dist/src/gen/video/models/index.d.ts +0 -5011
- package/dist/src/gen/video/runtime.d.ts +0 -180
- package/src/gen/chat/.openapi-generator/FILES +0 -6
- package/src/gen/chat/.openapi-generator/VERSION +0 -1
- package/src/gen/chat/.openapi-generator-ignore +0 -23
- package/src/gen/chat/apis/ProductchatApi.ts +0 -7007
- package/src/gen/chat/apis/index.ts +0 -3
- package/src/gen/chat/index.ts +0 -5
- package/src/gen/chat/models/index.ts +0 -14766
- package/src/gen/chat/runtime.ts +0 -415
- package/src/gen/video/.openapi-generator/FILES +0 -6
- package/src/gen/video/.openapi-generator/VERSION +0 -1
- package/src/gen/video/.openapi-generator-ignore +0 -23
- package/src/gen/video/apis/ProductvideoApi.ts +0 -2575
- package/src/gen/video/apis/index.ts +0 -3
- package/src/gen/video/index.ts +0 -5
- package/src/gen/video/models/index.ts +0 -5000
- 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
|
+
}
|