@stream-io/node-sdk 0.2.5 → 0.3.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 (66) hide show
  1. package/dist/index.cjs.js +2550 -2124
  2. package/dist/index.cjs.js.map +1 -1
  3. package/dist/index.es.js +2535 -2109
  4. package/dist/index.es.js.map +1 -1
  5. package/dist/src/StreamCall.d.ts +5 -3
  6. package/dist/src/StreamChannel.d.ts +7 -9
  7. package/dist/src/StreamChatClient.d.ts +2 -5
  8. package/dist/src/StreamClient.d.ts +15 -26
  9. package/dist/src/gen/chat/apis/ProductchatApi.d.ts +1750 -0
  10. package/dist/src/gen/chat/apis/index.d.ts +1 -27
  11. package/dist/src/gen/chat/models/index.d.ts +5101 -5891
  12. package/dist/src/gen/chat/runtime.d.ts +2 -2
  13. package/dist/src/gen/video/apis/ProductvideoApi.d.ts +17 -2
  14. package/dist/src/gen/video/models/index.d.ts +323 -39
  15. package/dist/src/gen/video/runtime.d.ts +1 -1
  16. package/package.json +1 -1
  17. package/src/StreamCall.ts +14 -2
  18. package/src/StreamChannel.ts +44 -49
  19. package/src/StreamChatClient.ts +23 -35
  20. package/src/StreamClient.ts +71 -232
  21. package/src/gen/chat/.openapi-generator/FILES +1 -19
  22. package/src/gen/chat/apis/ProductchatApi.ts +7007 -0
  23. package/src/gen/chat/apis/index.ts +1 -27
  24. package/src/gen/chat/models/index.ts +5758 -6564
  25. package/src/gen/chat/runtime.ts +3 -3
  26. package/src/gen/video/apis/ProductvideoApi.ts +64 -1
  27. package/src/gen/video/models/index.ts +328 -40
  28. package/src/gen/video/runtime.ts +1 -1
  29. package/dist/src/gen/chat/apis/ChannelTypesApi.d.ts +0 -81
  30. package/dist/src/gen/chat/apis/ChannelsApi.d.ts +0 -280
  31. package/dist/src/gen/chat/apis/CustomCommandsApi.d.ts +0 -81
  32. package/dist/src/gen/chat/apis/DefaultApi.d.ts +0 -60
  33. package/dist/src/gen/chat/apis/DevicesApi.d.ts +0 -58
  34. package/dist/src/gen/chat/apis/EventsApi.d.ts +0 -47
  35. package/dist/src/gen/chat/apis/FilesApi.d.ts +0 -85
  36. package/dist/src/gen/chat/apis/GDPRApi.d.ts +0 -114
  37. package/dist/src/gen/chat/apis/ImportsApi.d.ts +0 -67
  38. package/dist/src/gen/chat/apis/MessagesApi.d.ts +0 -374
  39. package/dist/src/gen/chat/apis/ModerationApi.d.ts +0 -271
  40. package/dist/src/gen/chat/apis/PermissionsV2Api.d.ts +0 -77
  41. package/dist/src/gen/chat/apis/PushApi.d.ts +0 -65
  42. package/dist/src/gen/chat/apis/ReactionsApi.d.ts +0 -62
  43. package/dist/src/gen/chat/apis/ServerSideApi.d.ts +0 -31
  44. package/dist/src/gen/chat/apis/SettingsApi.d.ts +0 -257
  45. package/dist/src/gen/chat/apis/TasksApi.d.ts +0 -31
  46. package/dist/src/gen/chat/apis/TestingApi.d.ts +0 -57
  47. package/dist/src/gen/chat/apis/UsersApi.d.ts +0 -313
  48. package/src/gen/chat/apis/ChannelTypesApi.ts +0 -275
  49. package/src/gen/chat/apis/ChannelsApi.ts +0 -1096
  50. package/src/gen/chat/apis/CustomCommandsApi.ts +0 -276
  51. package/src/gen/chat/apis/DefaultApi.ts +0 -196
  52. package/src/gen/chat/apis/DevicesApi.ts +0 -180
  53. package/src/gen/chat/apis/EventsApi.ts +0 -147
  54. package/src/gen/chat/apis/FilesApi.ts +0 -312
  55. package/src/gen/chat/apis/GDPRApi.ts +0 -418
  56. package/src/gen/chat/apis/ImportsApi.ts +0 -222
  57. package/src/gen/chat/apis/MessagesApi.ts +0 -1475
  58. package/src/gen/chat/apis/ModerationApi.ts +0 -1038
  59. package/src/gen/chat/apis/PermissionsV2Api.ts +0 -259
  60. package/src/gen/chat/apis/PushApi.ts +0 -183
  61. package/src/gen/chat/apis/ReactionsApi.ts +0 -202
  62. package/src/gen/chat/apis/ServerSideApi.ts +0 -79
  63. package/src/gen/chat/apis/SettingsApi.ts +0 -948
  64. package/src/gen/chat/apis/TasksApi.ts +0 -75
  65. package/src/gen/chat/apis/TestingApi.ts +0 -185
  66. package/src/gen/chat/apis/UsersApi.ts +0 -1203
@@ -1,12 +1,10 @@
1
1
  import { StreamClient } from './StreamClient';
2
2
  import {
3
3
  ChannelGetOrCreateRequest,
4
- ChannelsApi,
5
4
  DeleteChannelRequest,
6
5
  DeleteMessageRequest,
7
6
  DeleteReactionRequest,
8
7
  EventRequest,
9
- EventsApi,
10
8
  GetManyMessagesRequest,
11
9
  GetMessageRequest,
12
10
  GetOGRequest,
@@ -15,8 +13,8 @@ import {
15
13
  HideChannelRequest,
16
14
  MarkReadRequest,
17
15
  MarkUnreadRequest,
18
- MessagesApi,
19
16
  MuteChannelRequest,
17
+ ProductchatApi,
20
18
  QueryMembersRequest,
21
19
  SendMessageRequest,
22
20
  SendReactionRequest,
@@ -32,9 +30,7 @@ import {
32
30
  import { OmitTypeId } from './types';
33
31
 
34
32
  export class StreamChannel {
35
- private readonly channelsApi: ChannelsApi;
36
- private readonly messagesApi: MessagesApi;
37
- private readonly eventsApi: EventsApi;
33
+ private readonly chatApi: ProductchatApi;
38
34
 
39
35
  constructor(
40
36
  private readonly streamClient: StreamClient,
@@ -43,11 +39,7 @@ export class StreamChannel {
43
39
  ) {
44
40
  const configuration = this.streamClient.getConfiguration();
45
41
  /** @ts-expect-error */
46
- this.channelsApi = new ChannelsApi(configuration);
47
- /** @ts-expect-error */
48
- this.messagesApi = new MessagesApi(configuration);
49
- /** @ts-expect-error */
50
- this.eventsApi = new EventsApi(configuration);
42
+ this.chatApi = new ProductchatApi(configuration);
51
43
  }
52
44
 
53
45
  get cid() {
@@ -55,14 +47,14 @@ export class StreamChannel {
55
47
  }
56
48
 
57
49
  delete = (request?: OmitTypeId<DeleteChannelRequest>) => {
58
- return this.channelsApi.deleteChannel({
50
+ return this.chatApi.deleteChannel({
59
51
  ...this.baseRequest,
60
52
  ...(request ?? {}),
61
53
  });
62
54
  };
63
55
 
64
56
  update = (updateChannelRequest: OmitTypeId<UpdateChannelRequest>) => {
65
- return this.channelsApi.updateChannel({
57
+ return this.chatApi.updateChannel({
66
58
  ...this.baseRequest,
67
59
  updateChannelRequest,
68
60
  });
@@ -71,7 +63,7 @@ export class StreamChannel {
71
63
  updatePartial = (
72
64
  updateChannelPartialRequest: OmitTypeId<UpdateChannelPartialRequest>,
73
65
  ) => {
74
- return this.channelsApi.updateChannelPartial({
66
+ return this.chatApi.updateChannelPartial({
75
67
  ...this.baseRequest,
76
68
  updateChannelPartialRequest,
77
69
  });
@@ -81,61 +73,65 @@ export class StreamChannel {
81
73
  channelGetOrCreateRequest?: ChannelGetOrCreateRequest,
82
74
  ) => {
83
75
  if (this.id) {
84
- return await this.channelsApi.getOrCreateChannel({
76
+ return await this.chatApi.getOrCreateChannel({
85
77
  ...this.baseRequest,
86
78
  channelGetOrCreateRequest: channelGetOrCreateRequest ?? {},
87
79
  });
88
80
  } else {
89
- throw new Error(`This operation isn't yet implemented`);
90
- // if (!channelGetOrCreateRequest?.data?.members) {
91
- // throw new Error('You need to provide members to create a channel without ID');
92
- // }
93
- // const response = await this.channelsApi.getOrCreateChannelType1({type: this.type, channelGetOrCreateRequest});
94
- // this.id = response.channel?.id;
95
- // return response;
81
+ if (!channelGetOrCreateRequest?.data?.members) {
82
+ throw new Error(
83
+ 'You need to provide members to create a channel without ID',
84
+ );
85
+ }
86
+ const response = await this.chatApi.getOrCreateDistinctChannel({
87
+ type: this.type,
88
+ channelGetOrCreateRequest,
89
+ });
90
+ this.id = response.channel?.id;
91
+ return response;
96
92
  }
97
93
  };
98
94
 
99
95
  markRead = (markReadRequest: MarkReadRequest) => {
100
- return this.channelsApi.markRead({ ...this.baseRequest, markReadRequest });
96
+ return this.chatApi.markRead({ ...this.baseRequest, markReadRequest });
101
97
  };
102
98
 
103
99
  markUnread = (markUnreadRequest: MarkUnreadRequest) => {
104
- return this.channelsApi.markUnread({
100
+ return this.chatApi.markUnread({
105
101
  ...this.baseRequest,
106
102
  markUnreadRequest,
107
103
  });
108
104
  };
109
105
 
110
106
  show = (showChannelRequest: ShowChannelRequest) => {
111
- return this.channelsApi.showChannel({
107
+ return this.chatApi.showChannel({
112
108
  ...this.baseRequest,
113
109
  showChannelRequest,
114
110
  });
115
111
  };
116
112
 
117
113
  hide = (hideChannelRequest: HideChannelRequest) => {
118
- return this.channelsApi.hideChannel({
114
+ return this.chatApi.hideChannel({
119
115
  ...this.baseRequest,
120
116
  hideChannelRequest,
121
117
  });
122
118
  };
123
119
 
124
120
  truncate = (truncateChannelRequest: TruncateChannelRequest) => {
125
- return this.channelsApi.truncateChannel({
121
+ return this.chatApi.truncateChannel({
126
122
  ...this.baseRequest,
127
123
  truncateChannelRequest,
128
124
  });
129
125
  };
130
126
 
131
127
  queryMembers = (request: OmitTypeId<QueryMembersRequest>) => {
132
- return this.channelsApi.queryMembers({
128
+ return this.chatApi.queryMembers({
133
129
  payload: { ...this.baseRequest, ...request },
134
130
  });
135
131
  };
136
132
 
137
133
  mute = (muteChannelRequest: Omit<MuteChannelRequest, 'channel_cids'>) => {
138
- return this.channelsApi.muteChannel({
134
+ return this.chatApi.muteChannel({
139
135
  muteChannelRequest: { ...muteChannelRequest, channel_cids: [this.cid] },
140
136
  });
141
137
  };
@@ -146,63 +142,62 @@ export class StreamChannel {
146
142
  'channel_cids' | 'channel_cid'
147
143
  >,
148
144
  ) => {
149
- return this.channelsApi.unmuteChannel({
145
+ return this.chatApi.unmuteChannel({
150
146
  unmuteChannelRequest: {
151
147
  ...unmuteChannelRequest,
152
- channel_cid: this.cid,
153
- channel_cids: [],
148
+ channel_cids: [this.cid],
154
149
  },
155
150
  });
156
151
  };
157
152
 
158
153
  // TODO: there is probably an issue with the generated code here
159
154
  // uploadFile = (options: Omit<OmitTypeId<UploadFileRequest>, 'file'>, file: Buffer) => {
160
- // return this.messagesApi.uploadFile({...options, ...this.baseRequest, file: file as any as string});
155
+ // return this.chatApi.uploadFile({...options, ...this.baseRequest, file: file as any as string});
161
156
  // }
162
157
 
163
158
  // deleteFile = (request: OmitTypeId<DeleteFileRequest>) => {
164
- // return this.messagesApi.deleteFile({...request, ...this.baseRequest});
159
+ // return this.chatApi.deleteFile({...request, ...this.baseRequest});
165
160
  // }
166
161
 
167
162
  // uploadImage = (request: OmitTypeId<UploadImageRequest>) => {
168
- // return this.messagesApi.uploadImage({...request, ...this.baseRequest});
163
+ // return this.chatApi.uploadImage({...request, ...this.baseRequest});
169
164
  // }
170
165
 
171
166
  // deleteImage = (request: OmitTypeId<DeleteImageRequest>) => {
172
- // return this.messagesApi.deleteImage({...request, ...this.baseRequest});
167
+ // return this.chatApi.deleteImage({...request, ...this.baseRequest});
173
168
  // }
174
169
 
175
170
  sendMessage = (sendMessageRequest: SendMessageRequest) => {
176
- return this.messagesApi.sendMessage({
171
+ return this.chatApi.sendMessage({
177
172
  ...this.baseRequest,
178
173
  sendMessageRequest,
179
174
  });
180
175
  };
181
176
 
182
177
  deleteMessage = (request: DeleteMessageRequest) => {
183
- return this.messagesApi.deleteMessage(request);
178
+ return this.chatApi.deleteMessage(request);
184
179
  };
185
180
 
186
181
  updateMessage = (id: string, updateMessageRequest: UpdateMessageRequest) => {
187
- return this.messagesApi.updateMessage({ id, updateMessageRequest });
182
+ return this.chatApi.updateMessage({ id, updateMessageRequest });
188
183
  };
189
184
 
190
185
  updateMessagePartial = (
191
186
  id: string,
192
187
  updateMessagePartialRequest: UpdateMessagePartialRequest,
193
188
  ) => {
194
- return this.messagesApi.updateMessagePartial({
189
+ return this.chatApi.updateMessagePartial({
195
190
  id,
196
191
  updateMessagePartialRequest,
197
192
  });
198
193
  };
199
194
 
200
195
  getMessage = (request: GetMessageRequest) => {
201
- return this.messagesApi.getMessage(request);
196
+ return this.chatApi.getMessage(request);
202
197
  };
203
198
 
204
199
  getManyMessages = (request: OmitTypeId<GetManyMessagesRequest>) => {
205
- return this.messagesApi.getManyMessages({
200
+ return this.chatApi.getManyMessages({
206
201
  ...request,
207
202
  ...this.baseRequest,
208
203
  });
@@ -212,22 +207,22 @@ export class StreamChannel {
212
207
  id: string,
213
208
  translateMessageRequest: TranslateMessageRequest,
214
209
  ) => {
215
- return this.messagesApi.translateMessage({ id, translateMessageRequest });
210
+ return this.chatApi.translateMessage({ id, translateMessageRequest });
216
211
  };
217
212
 
218
213
  getMessagesAround = (request: GetRepliesRequest) => {
219
- return this.messagesApi.getReplies(request);
214
+ return this.chatApi.getReplies(request);
220
215
  };
221
216
 
222
217
  getOpenGraphData = (request: GetOGRequest) => {
223
- return this.messagesApi.getOG(request);
218
+ return this.chatApi.getOG(request);
224
219
  };
225
220
 
226
221
  sendMessageReaction = (
227
222
  messageId: string,
228
223
  sendReactionRequest: SendReactionRequest,
229
224
  ) => {
230
- return this.messagesApi.sendReaction({
225
+ return this.chatApi.sendReaction({
231
226
  id: messageId,
232
227
  sendReactionRequest,
233
228
  });
@@ -237,18 +232,18 @@ export class StreamChannel {
237
232
  messageId: string,
238
233
  request: Omit<DeleteReactionRequest, 'id'>,
239
234
  ) => {
240
- return this.messagesApi.deleteReaction({ ...request, id: messageId });
235
+ return this.chatApi.deleteReaction({ ...request, id: messageId });
241
236
  };
242
237
 
243
238
  getMessageReactions = (
244
239
  messageId: string,
245
240
  request?: Omit<GetReactionsRequest, 'id'>,
246
241
  ) => {
247
- return this.messagesApi.getReactions({ ...(request ?? {}), id: messageId });
242
+ return this.chatApi.getReactions({ ...(request ?? {}), id: messageId });
248
243
  };
249
244
 
250
245
  sendCustomEvent = (event: EventRequest) => {
251
- return this.eventsApi.sendEvent({
246
+ return this.chatApi.sendEvent({
252
247
  ...this.baseRequest,
253
248
  sendEventRequest: { event },
254
249
  });
@@ -1,12 +1,9 @@
1
1
  import { StreamChannel } from './StreamChannel';
2
2
  import { StreamClient } from './StreamClient';
3
3
  import {
4
- ChannelTypesApi,
5
- ChannelsApi,
6
4
  CreateBlockListRequest,
7
5
  CreateChannelTypeRequest,
8
6
  CreateCommandRequest,
9
- CustomCommandsApi,
10
7
  DeleteBlockListRequest,
11
8
  DeleteChannelTypeRequest,
12
9
  DeleteCommandRequest,
@@ -15,30 +12,21 @@ import {
15
12
  GetChannelTypeRequest,
16
13
  GetCommandRequest,
17
14
  GetExportChannelsStatusRequest,
15
+ ProductchatApi,
18
16
  QueryChannelsRequest,
19
17
  SearchRequest,
20
- SettingsApi,
21
18
  UpdateBlockListRequest,
22
19
  UpdateChannelTypeRequest,
23
20
  UpdateCommandRequest,
24
21
  } from './gen/chat';
25
22
 
26
23
  export class StreamChatClient {
27
- private readonly settingsApi: SettingsApi;
28
- private readonly channelTypesApi: ChannelTypesApi;
29
- private readonly channelsApi: ChannelsApi;
30
- private readonly commandsApi: CustomCommandsApi;
24
+ private readonly chatApi: ProductchatApi;
31
25
 
32
26
  constructor(private readonly streamClient: StreamClient) {
33
27
  const configuration = this.streamClient.getConfiguration();
34
28
  /** @ts-expect-error */
35
- this.settingsApi = new SettingsApi(configuration);
36
- /** @ts-expect-error */
37
- this.channelTypesApi = new ChannelTypesApi(configuration);
38
- /** @ts-expect-error */
39
- this.channelsApi = new ChannelsApi(configuration);
40
- /** @ts-expect-error */
41
- this.commandsApi = new CustomCommandsApi(configuration);
29
+ this.chatApi = new ProductchatApi(configuration);
42
30
  }
43
31
 
44
32
  channel = (type: string, id?: string) => {
@@ -46,94 +34,94 @@ export class StreamChatClient {
46
34
  };
47
35
 
48
36
  createBlockList = (createBlockListRequest: CreateBlockListRequest) => {
49
- return this.settingsApi.createBlockList({ createBlockListRequest });
37
+ return this.chatApi.createBlockList({ createBlockListRequest });
50
38
  };
51
39
 
52
40
  listBlockLists = () => {
53
- return this.settingsApi.listBlockLists();
41
+ return this.chatApi.listBlockLists();
54
42
  };
55
43
 
56
44
  getBlockList = (request: GetBlockListRequest) => {
57
- return this.settingsApi.getBlockList(request);
45
+ return this.chatApi.getBlockList(request);
58
46
  };
59
47
 
60
48
  updateBlockList = (
61
49
  name: string,
62
50
  updateBlockListRequest: UpdateBlockListRequest,
63
51
  ) => {
64
- return this.settingsApi.updateBlockList({ name, updateBlockListRequest });
52
+ return this.chatApi.updateBlockList({ name, updateBlockListRequest });
65
53
  };
66
54
 
67
55
  deleteBlockList = (request: DeleteBlockListRequest) => {
68
- return this.settingsApi.deleteBlockList(request);
56
+ return this.chatApi.deleteBlockList(request);
69
57
  };
70
58
 
71
59
  createChannelType = (createChannelTypeRequest: CreateChannelTypeRequest) => {
72
- return this.channelTypesApi.createChannelType({ createChannelTypeRequest });
60
+ return this.chatApi.createChannelType({ createChannelTypeRequest });
73
61
  };
74
62
 
75
63
  deleteChannelType = (request: DeleteChannelTypeRequest) => {
76
- return this.channelTypesApi.deleteChannelType(request);
64
+ return this.chatApi.deleteChannelType(request);
77
65
  };
78
66
 
79
67
  getChannelType = (request: GetChannelTypeRequest) => {
80
- return this.channelTypesApi.getChannelType(request);
68
+ return this.chatApi.getChannelType(request);
81
69
  };
82
70
 
83
71
  listChannelTypes = () => {
84
- return this.channelTypesApi.listChannelTypes();
72
+ return this.chatApi.listChannelTypes();
85
73
  };
86
74
 
87
75
  updateChannelType = (
88
76
  name: string,
89
77
  updateChannelTypeRequest: UpdateChannelTypeRequest,
90
78
  ) => {
91
- return this.channelTypesApi.updateChannelType({
79
+ return this.chatApi.updateChannelType({
92
80
  name,
93
81
  updateChannelTypeRequest,
94
82
  });
95
83
  };
96
84
 
97
85
  queryChannels = (queryChannelsRequest?: QueryChannelsRequest) => {
98
- return this.channelsApi.queryChannels({
99
- queryChannelsRequest: queryChannelsRequest ?? null,
86
+ return this.chatApi.queryChannels({
87
+ queryChannelsRequest: queryChannelsRequest ?? {},
100
88
  });
101
89
  };
102
90
 
103
91
  searchMessages = (payload?: SearchRequest) => {
104
- return this.channelsApi.search({ payload });
92
+ return this.chatApi.search({ payload });
105
93
  };
106
94
 
107
95
  exportChannels = (exportChannelsRequest?: ExportChannelsRequest) => {
108
- return this.channelsApi.exportChannels({
96
+ return this.chatApi.exportChannels({
109
97
  exportChannelsRequest: exportChannelsRequest ?? null,
110
98
  });
111
99
  };
112
100
 
113
101
  getExportStatus = (request: GetExportChannelsStatusRequest) => {
114
- return this.channelsApi.getExportChannelsStatus(request);
102
+ return this.chatApi.getExportChannelsStatus(request);
115
103
  };
116
104
 
117
105
  listCommands = () => {
118
- return this.commandsApi.listCommands();
106
+ return this.chatApi.listCommands();
119
107
  };
120
108
 
121
109
  createCommand = (createCommandRequest: CreateCommandRequest) => {
122
- return this.commandsApi.createCommand({ createCommandRequest });
110
+ return this.chatApi.createCommand({ createCommandRequest });
123
111
  };
124
112
 
125
113
  getCommand = (getCommandRequest: GetCommandRequest) => {
126
- return this.commandsApi.getCommand(getCommandRequest);
114
+ return this.chatApi.getCommand(getCommandRequest);
127
115
  };
128
116
 
129
117
  updateCommand = (
130
118
  name: string,
131
119
  updateCommandRequest: UpdateCommandRequest,
132
120
  ) => {
133
- return this.commandsApi.updateCommand({ name, updateCommandRequest });
121
+ return this.chatApi.updateCommand({ name, updateCommandRequest });
134
122
  };
135
123
 
136
124
  deleteCommand = (request: DeleteCommandRequest) => {
137
- return this.commandsApi.deleteCommand(request);
125
+ return this.chatApi.deleteCommand(request);
138
126
  };
139
127
  }