@stream-io/node-sdk 0.4.19 → 0.4.20
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 +115 -98
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.mjs +115 -98
- package/dist/index.es.mjs.map +1 -1
- package/dist/src/BaseApi.d.ts +1 -0
- package/dist/src/StreamClient.d.ts +7 -0
- package/dist/src/gen/chat/ChannelApi.d.ts +9 -1
- package/dist/src/gen/chat/ChatApi.d.ts +17 -1
- package/dist/src/gen/models/index.d.ts +119 -119
- package/dist/src/gen/moderation/ModerationApi.d.ts +1 -11
- package/dist/src/types.d.ts +3 -0
- package/package.json +2 -1
- package/src/BaseApi.ts +9 -1
- package/src/StreamClient.ts +18 -1
- package/src/gen/chat/ChannelApi.ts +29 -0
- package/src/gen/chat/ChatApi.ts +89 -1
- package/src/gen/model-decoders/index.ts +50 -63
- package/src/gen/models/index.ts +214 -206
- package/src/gen/moderation/ModerationApi.ts +0 -94
- package/src/types.ts +4 -0
package/dist/index.cjs.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var jwt = require('jsonwebtoken');
|
|
4
4
|
var uuid = require('uuid');
|
|
5
5
|
var crypto = require('crypto');
|
|
6
|
+
var undici = require('undici');
|
|
6
7
|
|
|
7
8
|
function _interopNamespaceDefault(e) {
|
|
8
9
|
var n = Object.create(null);
|
|
@@ -157,7 +158,7 @@ class BaseApi {
|
|
|
157
158
|
Authorization: this.apiConfig.token,
|
|
158
159
|
'stream-auth-type': 'jwt',
|
|
159
160
|
'Content-Type': 'application/json',
|
|
160
|
-
'X-Stream-Client': 'stream-node-' + "0.4.
|
|
161
|
+
'X-Stream-Client': 'stream-node-' + "0.4.20",
|
|
161
162
|
'Accept-Encoding': 'gzip',
|
|
162
163
|
'x-client-request-id': clientRequestId,
|
|
163
164
|
};
|
|
@@ -168,6 +169,8 @@ class BaseApi {
|
|
|
168
169
|
method,
|
|
169
170
|
body: JSON.stringify(body),
|
|
170
171
|
headers,
|
|
172
|
+
/** @ts-expect-error we get types from DOM here, but we should use node types */
|
|
173
|
+
dispatcher: this.dispatcher,
|
|
171
174
|
});
|
|
172
175
|
const responseHeaders = response.headers;
|
|
173
176
|
const metadata = {
|
|
@@ -228,6 +231,7 @@ class BaseApi {
|
|
|
228
231
|
}
|
|
229
232
|
return newParams.join('&');
|
|
230
233
|
};
|
|
234
|
+
this.dispatcher = this.apiConfig.agent;
|
|
231
235
|
}
|
|
232
236
|
}
|
|
233
237
|
|
|
@@ -531,6 +535,7 @@ decoders.ChannelStateResponse = (input) => {
|
|
|
531
535
|
read: { type: 'ReadStateResponse', isSingle: false },
|
|
532
536
|
watchers: { type: 'UserResponse', isSingle: false },
|
|
533
537
|
channel: { type: 'ChannelResponse', isSingle: true },
|
|
538
|
+
draft: { type: 'DraftResponse', isSingle: true },
|
|
534
539
|
membership: { type: 'ChannelMember', isSingle: true },
|
|
535
540
|
push_preferences: { type: 'ChannelPushPreferences', isSingle: true },
|
|
536
541
|
};
|
|
@@ -547,6 +552,7 @@ decoders.ChannelStateResponseFields = (input) => {
|
|
|
547
552
|
read: { type: 'ReadStateResponse', isSingle: false },
|
|
548
553
|
watchers: { type: 'UserResponse', isSingle: false },
|
|
549
554
|
channel: { type: 'ChannelResponse', isSingle: true },
|
|
555
|
+
draft: { type: 'DraftResponse', isSingle: true },
|
|
550
556
|
membership: { type: 'ChannelMember', isSingle: true },
|
|
551
557
|
push_preferences: { type: 'ChannelPushPreferences', isSingle: true },
|
|
552
558
|
};
|
|
@@ -673,6 +679,22 @@ decoders.DeviceResponse = (input) => {
|
|
|
673
679
|
};
|
|
674
680
|
return decode(typeMappings, input);
|
|
675
681
|
};
|
|
682
|
+
decoders.DraftPayloadResponse = (input) => {
|
|
683
|
+
const typeMappings = {
|
|
684
|
+
mentioned_users: { type: 'UserResponse', isSingle: false },
|
|
685
|
+
};
|
|
686
|
+
return decode(typeMappings, input);
|
|
687
|
+
};
|
|
688
|
+
decoders.DraftResponse = (input) => {
|
|
689
|
+
const typeMappings = {
|
|
690
|
+
created_at: { type: 'DatetimeType', isSingle: true },
|
|
691
|
+
message: { type: 'DraftPayloadResponse', isSingle: true },
|
|
692
|
+
channel: { type: 'ChannelResponse', isSingle: true },
|
|
693
|
+
parent_message: { type: 'MessageResponse', isSingle: true },
|
|
694
|
+
quoted_message: { type: 'MessageResponse', isSingle: true },
|
|
695
|
+
};
|
|
696
|
+
return decode(typeMappings, input);
|
|
697
|
+
};
|
|
676
698
|
decoders.EgressRTMPResponse = (input) => {
|
|
677
699
|
const typeMappings = {
|
|
678
700
|
started_at: { type: 'DatetimeType', isSingle: true },
|
|
@@ -723,7 +745,7 @@ decoders.ExportUserResponse = (input) => {
|
|
|
723
745
|
};
|
|
724
746
|
return decode(typeMappings, input);
|
|
725
747
|
};
|
|
726
|
-
decoders.
|
|
748
|
+
decoders.Flag = (input) => {
|
|
727
749
|
const typeMappings = {
|
|
728
750
|
created_at: { type: 'DatetimeType', isSingle: true },
|
|
729
751
|
updated_at: { type: 'DatetimeType', isSingle: true },
|
|
@@ -731,14 +753,6 @@ decoders.Flag2 = (input) => {
|
|
|
731
753
|
};
|
|
732
754
|
return decode(typeMappings, input);
|
|
733
755
|
};
|
|
734
|
-
decoders.Flag2Response = (input) => {
|
|
735
|
-
const typeMappings = {
|
|
736
|
-
created_at: { type: 'DatetimeType', isSingle: true },
|
|
737
|
-
updated_at: { type: 'DatetimeType', isSingle: true },
|
|
738
|
-
user: { type: 'UserResponse', isSingle: true },
|
|
739
|
-
};
|
|
740
|
-
return decode(typeMappings, input);
|
|
741
|
-
};
|
|
742
756
|
decoders.FlagDetails = (input) => {
|
|
743
757
|
const typeMappings = {
|
|
744
758
|
automod: { type: 'AutomodDetails', isSingle: true },
|
|
@@ -798,12 +812,6 @@ decoders.GetCallTypeResponse = (input) => {
|
|
|
798
812
|
};
|
|
799
813
|
return decode(typeMappings, input);
|
|
800
814
|
};
|
|
801
|
-
decoders.GetCampaignResponse = (input) => {
|
|
802
|
-
const typeMappings = {
|
|
803
|
-
campaign: { type: 'CampaignResponse', isSingle: true },
|
|
804
|
-
};
|
|
805
|
-
return decode(typeMappings, input);
|
|
806
|
-
};
|
|
807
815
|
decoders.GetChannelTypeResponse = (input) => {
|
|
808
816
|
const typeMappings = {
|
|
809
817
|
created_at: { type: 'DatetimeType', isSingle: true },
|
|
@@ -825,6 +833,12 @@ decoders.GetConfigResponse = (input) => {
|
|
|
825
833
|
};
|
|
826
834
|
return decode(typeMappings, input);
|
|
827
835
|
};
|
|
836
|
+
decoders.GetDraftResponse = (input) => {
|
|
837
|
+
const typeMappings = {
|
|
838
|
+
draft: { type: 'DraftResponse', isSingle: true },
|
|
839
|
+
};
|
|
840
|
+
return decode(typeMappings, input);
|
|
841
|
+
};
|
|
828
842
|
decoders.GetImportResponse = (input) => {
|
|
829
843
|
const typeMappings = {
|
|
830
844
|
import_task: { type: 'ImportTask', isSingle: true },
|
|
@@ -888,14 +902,6 @@ decoders.GetThreadResponse = (input) => {
|
|
|
888
902
|
};
|
|
889
903
|
return decode(typeMappings, input);
|
|
890
904
|
};
|
|
891
|
-
decoders.GetUserModerationReportResponse = (input) => {
|
|
892
|
-
const typeMappings = {
|
|
893
|
-
user_blocks: { type: 'UserBlock', isSingle: false },
|
|
894
|
-
user_mutes: { type: 'UserMute', isSingle: false },
|
|
895
|
-
user: { type: 'UserResponse', isSingle: true },
|
|
896
|
-
};
|
|
897
|
-
return decode(typeMappings, input);
|
|
898
|
-
};
|
|
899
905
|
decoders.GoLiveResponse = (input) => {
|
|
900
906
|
const typeMappings = {
|
|
901
907
|
call: { type: 'CallResponse', isSingle: true },
|
|
@@ -1068,6 +1074,7 @@ decoders.MessageResponse = (input) => {
|
|
|
1068
1074
|
pin_expires: { type: 'DatetimeType', isSingle: true },
|
|
1069
1075
|
pinned_at: { type: 'DatetimeType', isSingle: true },
|
|
1070
1076
|
thread_participants: { type: 'UserResponse', isSingle: false },
|
|
1077
|
+
draft: { type: 'DraftResponse', isSingle: true },
|
|
1071
1078
|
pinned_by: { type: 'UserResponse', isSingle: true },
|
|
1072
1079
|
poll: { type: 'PollResponseData', isSingle: true },
|
|
1073
1080
|
quoted_message: { type: 'MessageResponse', isSingle: true },
|
|
@@ -1089,6 +1096,7 @@ decoders.MessageWithChannelResponse = (input) => {
|
|
|
1089
1096
|
pin_expires: { type: 'DatetimeType', isSingle: true },
|
|
1090
1097
|
pinned_at: { type: 'DatetimeType', isSingle: true },
|
|
1091
1098
|
thread_participants: { type: 'UserResponse', isSingle: false },
|
|
1099
|
+
draft: { type: 'DraftResponse', isSingle: true },
|
|
1092
1100
|
pinned_by: { type: 'UserResponse', isSingle: true },
|
|
1093
1101
|
poll: { type: 'PollResponseData', isSingle: true },
|
|
1094
1102
|
quoted_message: { type: 'MessageResponse', isSingle: true },
|
|
@@ -1096,13 +1104,6 @@ decoders.MessageWithChannelResponse = (input) => {
|
|
|
1096
1104
|
};
|
|
1097
1105
|
return decode(typeMappings, input);
|
|
1098
1106
|
};
|
|
1099
|
-
decoders.ModerationUsageStats = (input) => {
|
|
1100
|
-
const typeMappings = {
|
|
1101
|
-
reference_date: { type: 'DatetimeType', isSingle: true },
|
|
1102
|
-
updated_at: { type: 'DatetimeType', isSingle: true },
|
|
1103
|
-
};
|
|
1104
|
-
return decode(typeMappings, input);
|
|
1105
|
-
};
|
|
1106
1107
|
decoders.MuteChannelResponse = (input) => {
|
|
1107
1108
|
const typeMappings = {
|
|
1108
1109
|
channel_mutes: { type: 'ChannelMute', isSingle: false },
|
|
@@ -1280,6 +1281,12 @@ decoders.QueryChannelsResponse = (input) => {
|
|
|
1280
1281
|
};
|
|
1281
1282
|
return decode(typeMappings, input);
|
|
1282
1283
|
};
|
|
1284
|
+
decoders.QueryDraftsResponse = (input) => {
|
|
1285
|
+
const typeMappings = {
|
|
1286
|
+
drafts: { type: 'DraftResponse', isSingle: false },
|
|
1287
|
+
};
|
|
1288
|
+
return decode(typeMappings, input);
|
|
1289
|
+
};
|
|
1283
1290
|
decoders.QueryFeedModerationTemplate = (input) => {
|
|
1284
1291
|
const typeMappings = {
|
|
1285
1292
|
created_at: { type: 'DatetimeType', isSingle: true },
|
|
@@ -1353,12 +1360,6 @@ decoders.QueryThreadsResponse = (input) => {
|
|
|
1353
1360
|
};
|
|
1354
1361
|
return decode(typeMappings, input);
|
|
1355
1362
|
};
|
|
1356
|
-
decoders.QueryUsageStatsResponse = (input) => {
|
|
1357
|
-
const typeMappings = {
|
|
1358
|
-
items: { type: 'ModerationUsageStats', isSingle: false },
|
|
1359
|
-
};
|
|
1360
|
-
return decode(typeMappings, input);
|
|
1361
|
-
};
|
|
1362
1363
|
decoders.QueryUsersResponse = (input) => {
|
|
1363
1364
|
const typeMappings = {
|
|
1364
1365
|
users: { type: 'FullUserResponse', isSingle: false },
|
|
@@ -1407,7 +1408,7 @@ decoders.ReviewQueueItem = (input) => {
|
|
|
1407
1408
|
updated_at: { type: 'DatetimeType', isSingle: true },
|
|
1408
1409
|
actions: { type: 'ActionLog', isSingle: false },
|
|
1409
1410
|
bans: { type: 'Ban', isSingle: false },
|
|
1410
|
-
flags: { type: '
|
|
1411
|
+
flags: { type: 'Flag', isSingle: false },
|
|
1411
1412
|
assigned_to: { type: 'User', isSingle: true },
|
|
1412
1413
|
entity_creator: { type: 'EntityCreator', isSingle: true },
|
|
1413
1414
|
feeds_v2_reaction: { type: 'Reaction', isSingle: true },
|
|
@@ -1422,7 +1423,6 @@ decoders.ReviewQueueItemResponse = (input) => {
|
|
|
1422
1423
|
updated_at: { type: 'DatetimeType', isSingle: true },
|
|
1423
1424
|
actions: { type: 'ActionLogResponse', isSingle: false },
|
|
1424
1425
|
bans: { type: 'Ban', isSingle: false },
|
|
1425
|
-
flags: { type: 'Flag2Response', isSingle: false },
|
|
1426
1426
|
completed_at: { type: 'DatetimeType', isSingle: true },
|
|
1427
1427
|
reviewed_at: { type: 'DatetimeType', isSingle: true },
|
|
1428
1428
|
assigned_to: { type: 'UserResponse', isSingle: true },
|
|
@@ -1460,6 +1460,7 @@ decoders.SearchResultMessage = (input) => {
|
|
|
1460
1460
|
pinned_at: { type: 'DatetimeType', isSingle: true },
|
|
1461
1461
|
thread_participants: { type: 'UserResponse', isSingle: false },
|
|
1462
1462
|
channel: { type: 'ChannelResponse', isSingle: true },
|
|
1463
|
+
draft: { type: 'DraftResponse', isSingle: true },
|
|
1463
1464
|
pinned_by: { type: 'UserResponse', isSingle: true },
|
|
1464
1465
|
poll: { type: 'PollResponseData', isSingle: true },
|
|
1465
1466
|
quoted_message: { type: 'MessageResponse', isSingle: true },
|
|
@@ -1502,12 +1503,6 @@ decoders.SendReactionResponse = (input) => {
|
|
|
1502
1503
|
};
|
|
1503
1504
|
return decode(typeMappings, input);
|
|
1504
1505
|
};
|
|
1505
|
-
decoders.StartCampaignResponse = (input) => {
|
|
1506
|
-
const typeMappings = {
|
|
1507
|
-
campaign: { type: 'CampaignResponse', isSingle: true },
|
|
1508
|
-
};
|
|
1509
|
-
return decode(typeMappings, input);
|
|
1510
|
-
};
|
|
1511
1506
|
decoders.StopLiveResponse = (input) => {
|
|
1512
1507
|
const typeMappings = {
|
|
1513
1508
|
call: { type: 'CallResponse', isSingle: true },
|
|
@@ -1554,6 +1549,7 @@ decoders.ThreadStateResponse = (input) => {
|
|
|
1554
1549
|
thread_participants: { type: 'ThreadParticipant', isSingle: false },
|
|
1555
1550
|
channel: { type: 'ChannelResponse', isSingle: true },
|
|
1556
1551
|
created_by: { type: 'UserResponse', isSingle: true },
|
|
1552
|
+
draft: { type: 'DraftResponse', isSingle: true },
|
|
1557
1553
|
parent_message: { type: 'MessageResponse', isSingle: true },
|
|
1558
1554
|
};
|
|
1559
1555
|
return decode(typeMappings, input);
|
|
@@ -1712,12 +1708,6 @@ decoders.User = (input) => {
|
|
|
1712
1708
|
};
|
|
1713
1709
|
return decode(typeMappings, input);
|
|
1714
1710
|
};
|
|
1715
|
-
decoders.UserBlock = (input) => {
|
|
1716
|
-
const typeMappings = {
|
|
1717
|
-
created_at: { type: 'DatetimeType', isSingle: true },
|
|
1718
|
-
};
|
|
1719
|
-
return decode(typeMappings, input);
|
|
1720
|
-
};
|
|
1721
1711
|
decoders.UserMute = (input) => {
|
|
1722
1712
|
const typeMappings = {
|
|
1723
1713
|
created_at: { type: 'DatetimeType', isSingle: true },
|
|
@@ -3105,6 +3095,7 @@ class ChatApi extends BaseApi {
|
|
|
3105
3095
|
limit: request?.limit,
|
|
3106
3096
|
next: request?.next,
|
|
3107
3097
|
prev: request?.prev,
|
|
3098
|
+
user_limit: request?.user_limit,
|
|
3108
3099
|
sort: request?.sort,
|
|
3109
3100
|
filter: request?.filter,
|
|
3110
3101
|
};
|
|
@@ -3113,10 +3104,15 @@ class ChatApi extends BaseApi {
|
|
|
3113
3104
|
return { ...response.body, metadata: response.metadata };
|
|
3114
3105
|
};
|
|
3115
3106
|
this.getCampaign = async (request) => {
|
|
3107
|
+
const queryParams = {
|
|
3108
|
+
prev: request?.prev,
|
|
3109
|
+
next: request?.next,
|
|
3110
|
+
limit: request?.limit,
|
|
3111
|
+
};
|
|
3116
3112
|
const pathParams = {
|
|
3117
3113
|
id: request?.id,
|
|
3118
3114
|
};
|
|
3119
|
-
const response = await this.sendRequest('GET', '/api/v2/chat/campaigns/{id}', pathParams,
|
|
3115
|
+
const response = await this.sendRequest('GET', '/api/v2/chat/campaigns/{id}', pathParams, queryParams);
|
|
3120
3116
|
decoders.GetCampaignResponse?.(response.body);
|
|
3121
3117
|
return { ...response.body, metadata: response.metadata };
|
|
3122
3118
|
};
|
|
@@ -3246,6 +3242,32 @@ class ChatApi extends BaseApi {
|
|
|
3246
3242
|
decoders.UpdateChannelResponse?.(response.body);
|
|
3247
3243
|
return { ...response.body, metadata: response.metadata };
|
|
3248
3244
|
};
|
|
3245
|
+
this.deleteDraft = async (request) => {
|
|
3246
|
+
const queryParams = {
|
|
3247
|
+
parent_id: request?.parent_id,
|
|
3248
|
+
user_id: request?.user_id,
|
|
3249
|
+
};
|
|
3250
|
+
const pathParams = {
|
|
3251
|
+
type: request?.type,
|
|
3252
|
+
id: request?.id,
|
|
3253
|
+
};
|
|
3254
|
+
const response = await this.sendRequest('DELETE', '/api/v2/chat/channels/{type}/{id}/draft', pathParams, queryParams);
|
|
3255
|
+
decoders.Response?.(response.body);
|
|
3256
|
+
return { ...response.body, metadata: response.metadata };
|
|
3257
|
+
};
|
|
3258
|
+
this.getDraft = async (request) => {
|
|
3259
|
+
const queryParams = {
|
|
3260
|
+
parent_id: request?.parent_id,
|
|
3261
|
+
user_id: request?.user_id,
|
|
3262
|
+
};
|
|
3263
|
+
const pathParams = {
|
|
3264
|
+
type: request?.type,
|
|
3265
|
+
id: request?.id,
|
|
3266
|
+
};
|
|
3267
|
+
const response = await this.sendRequest('GET', '/api/v2/chat/channels/{type}/{id}/draft', pathParams, queryParams);
|
|
3268
|
+
decoders.GetDraftResponse?.(response.body);
|
|
3269
|
+
return { ...response.body, metadata: response.metadata };
|
|
3270
|
+
};
|
|
3249
3271
|
this.sendEvent = async (request) => {
|
|
3250
3272
|
const pathParams = {
|
|
3251
3273
|
type: request?.type,
|
|
@@ -3584,6 +3606,20 @@ class ChatApi extends BaseApi {
|
|
|
3584
3606
|
decoders.UpdateCommandResponse?.(response.body);
|
|
3585
3607
|
return { ...response.body, metadata: response.metadata };
|
|
3586
3608
|
};
|
|
3609
|
+
this.queryDrafts = async (request) => {
|
|
3610
|
+
const body = {
|
|
3611
|
+
limit: request?.limit,
|
|
3612
|
+
next: request?.next,
|
|
3613
|
+
prev: request?.prev,
|
|
3614
|
+
user_id: request?.user_id,
|
|
3615
|
+
sort: request?.sort,
|
|
3616
|
+
filter: request?.filter,
|
|
3617
|
+
user: request?.user,
|
|
3618
|
+
};
|
|
3619
|
+
const response = await this.sendRequest('POST', '/api/v2/chat/drafts/query', undefined, undefined, body);
|
|
3620
|
+
decoders.QueryDraftsResponse?.(response.body);
|
|
3621
|
+
return { ...response.body, metadata: response.metadata };
|
|
3622
|
+
};
|
|
3587
3623
|
this.exportChannels = async (request) => {
|
|
3588
3624
|
const body = {
|
|
3589
3625
|
channels: request?.channels,
|
|
@@ -4200,6 +4236,22 @@ class ChannelApi {
|
|
|
4200
4236
|
...request,
|
|
4201
4237
|
});
|
|
4202
4238
|
};
|
|
4239
|
+
this.deleteDraft = (request) => {
|
|
4240
|
+
if (!this.id) {
|
|
4241
|
+
throw new Error(`Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`);
|
|
4242
|
+
}
|
|
4243
|
+
return this.chatApi.deleteDraft({
|
|
4244
|
+
id: this.id,
|
|
4245
|
+
type: this.type,
|
|
4246
|
+
...request,
|
|
4247
|
+
});
|
|
4248
|
+
};
|
|
4249
|
+
this.getDraft = (request) => {
|
|
4250
|
+
if (!this.id) {
|
|
4251
|
+
throw new Error(`Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`);
|
|
4252
|
+
}
|
|
4253
|
+
return this.chatApi.getDraft({ id: this.id, type: this.type, ...request });
|
|
4254
|
+
};
|
|
4203
4255
|
this.sendEvent = (request) => {
|
|
4204
4256
|
if (!this.id) {
|
|
4205
4257
|
throw new Error(`Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`);
|
|
@@ -4385,15 +4437,6 @@ class StreamChatClient extends ChatApi {
|
|
|
4385
4437
|
class ModerationApi extends BaseApi {
|
|
4386
4438
|
constructor() {
|
|
4387
4439
|
super(...arguments);
|
|
4388
|
-
this.getModerationAnalytics = async (request) => {
|
|
4389
|
-
const body = {
|
|
4390
|
-
end_date: request?.end_date,
|
|
4391
|
-
start_date: request?.start_date,
|
|
4392
|
-
};
|
|
4393
|
-
const response = await this.sendRequest('POST', '/api/v2/moderation/analytics', undefined, undefined, body);
|
|
4394
|
-
decoders.GetModerationAnalyticsResponse?.(response.body);
|
|
4395
|
-
return { ...response.body, metadata: response.metadata };
|
|
4396
|
-
};
|
|
4397
4440
|
this.ban = async (request) => {
|
|
4398
4441
|
const body = {
|
|
4399
4442
|
target_user_id: request?.target_user_id,
|
|
@@ -4433,7 +4476,6 @@ class ModerationApi extends BaseApi {
|
|
|
4433
4476
|
team: request?.team,
|
|
4434
4477
|
user_id: request?.user_id,
|
|
4435
4478
|
ai_image_config: request?.ai_image_config,
|
|
4436
|
-
ai_image_lite_config: request?.ai_image_lite_config,
|
|
4437
4479
|
ai_text_config: request?.ai_text_config,
|
|
4438
4480
|
ai_video_config: request?.ai_video_config,
|
|
4439
4481
|
automod_platform_circumvention_config: request?.automod_platform_circumvention_config,
|
|
@@ -4548,11 +4590,6 @@ class ModerationApi extends BaseApi {
|
|
|
4548
4590
|
decoders.QueryModerationLogsResponse?.(response.body);
|
|
4549
4591
|
return { ...response.body, metadata: response.metadata };
|
|
4550
4592
|
};
|
|
4551
|
-
this.getModeratorStats = async () => {
|
|
4552
|
-
const response = await this.sendRequest('GET', '/api/v2/moderation/moderator_stats', undefined, undefined);
|
|
4553
|
-
decoders.ModeratorStatsResponse?.(response.body);
|
|
4554
|
-
return { ...response.body, metadata: response.metadata };
|
|
4555
|
-
};
|
|
4556
4593
|
this.mute = async (request) => {
|
|
4557
4594
|
const body = {
|
|
4558
4595
|
target_ids: request?.target_ids,
|
|
@@ -4564,11 +4601,6 @@ class ModerationApi extends BaseApi {
|
|
|
4564
4601
|
decoders.MuteResponse?.(response.body);
|
|
4565
4602
|
return { ...response.body, metadata: response.metadata };
|
|
4566
4603
|
};
|
|
4567
|
-
this.getQueueStats = async () => {
|
|
4568
|
-
const response = await this.sendRequest('GET', '/api/v2/moderation/queue_stats', undefined, undefined);
|
|
4569
|
-
decoders.QueueStatsResponse?.(response.body);
|
|
4570
|
-
return { ...response.body, metadata: response.metadata };
|
|
4571
|
-
};
|
|
4572
4604
|
this.queryReviewQueue = async (request) => {
|
|
4573
4605
|
const body = {
|
|
4574
4606
|
limit: request?.limit,
|
|
@@ -4638,31 +4670,6 @@ class ModerationApi extends BaseApi {
|
|
|
4638
4670
|
decoders.UnmuteResponse?.(response.body);
|
|
4639
4671
|
return { ...response.body, metadata: response.metadata };
|
|
4640
4672
|
};
|
|
4641
|
-
this.queryUsageStats = async (request) => {
|
|
4642
|
-
const body = {
|
|
4643
|
-
limit: request?.limit,
|
|
4644
|
-
next: request?.next,
|
|
4645
|
-
prev: request?.prev,
|
|
4646
|
-
user_id: request?.user_id,
|
|
4647
|
-
sort: request?.sort,
|
|
4648
|
-
filter: request?.filter,
|
|
4649
|
-
user: request?.user,
|
|
4650
|
-
};
|
|
4651
|
-
const response = await this.sendRequest('POST', '/api/v2/moderation/usage_stats', undefined, undefined, body);
|
|
4652
|
-
decoders.QueryUsageStatsResponse?.(response.body);
|
|
4653
|
-
return { ...response.body, metadata: response.metadata };
|
|
4654
|
-
};
|
|
4655
|
-
this.getUserReport = async (request) => {
|
|
4656
|
-
const queryParams = {
|
|
4657
|
-
user_id: request?.user_id,
|
|
4658
|
-
create_user_if_not_exists: request?.create_user_if_not_exists,
|
|
4659
|
-
include_user_mutes: request?.include_user_mutes,
|
|
4660
|
-
include_user_blocks: request?.include_user_blocks,
|
|
4661
|
-
};
|
|
4662
|
-
const response = await this.sendRequest('GET', '/api/v2/moderation/user_report', undefined, queryParams);
|
|
4663
|
-
decoders.GetUserModerationReportResponse?.(response.body);
|
|
4664
|
-
return { ...response.body, metadata: response.metadata };
|
|
4665
|
-
};
|
|
4666
4673
|
}
|
|
4667
4674
|
}
|
|
4668
4675
|
|
|
@@ -4679,9 +4686,15 @@ class StreamClient extends CommonApi {
|
|
|
4679
4686
|
constructor(apiKey, secret, config) {
|
|
4680
4687
|
const token = JWTServerToken(secret);
|
|
4681
4688
|
const timeout = config?.timeout ?? StreamClient.DEFAULT_TIMEOUT;
|
|
4689
|
+
const agent = config?.agent ??
|
|
4690
|
+
new undici.Agent({
|
|
4691
|
+
connections: config?.maxConnections === undefined
|
|
4692
|
+
? StreamClient.MAX_CONNECTIONS
|
|
4693
|
+
: config.maxConnections,
|
|
4694
|
+
});
|
|
4682
4695
|
const chatBaseUrl = config?.basePath ?? 'https://chat.stream-io-api.com';
|
|
4683
4696
|
const videoBaseUrl = config?.basePath ?? 'https://video.stream-io-api.com';
|
|
4684
|
-
super({ apiKey, token, timeout, baseUrl: chatBaseUrl });
|
|
4697
|
+
super({ apiKey, token, timeout, baseUrl: chatBaseUrl, agent });
|
|
4685
4698
|
this.apiKey = apiKey;
|
|
4686
4699
|
this.secret = secret;
|
|
4687
4700
|
this.config = config;
|
|
@@ -4782,22 +4795,26 @@ class StreamClient extends CommonApi {
|
|
|
4782
4795
|
token,
|
|
4783
4796
|
timeout,
|
|
4784
4797
|
baseUrl: videoBaseUrl,
|
|
4798
|
+
agent,
|
|
4785
4799
|
});
|
|
4786
4800
|
this.chat = new StreamChatClient({
|
|
4787
4801
|
apiKey,
|
|
4788
4802
|
token,
|
|
4789
4803
|
timeout,
|
|
4790
4804
|
baseUrl: chatBaseUrl,
|
|
4805
|
+
agent,
|
|
4791
4806
|
});
|
|
4792
4807
|
this.moderation = new StreamModerationClient({
|
|
4793
4808
|
apiKey,
|
|
4794
4809
|
token,
|
|
4795
4810
|
timeout,
|
|
4796
4811
|
baseUrl: chatBaseUrl,
|
|
4812
|
+
agent,
|
|
4797
4813
|
});
|
|
4798
4814
|
}
|
|
4799
4815
|
}
|
|
4800
4816
|
StreamClient.DEFAULT_TIMEOUT = 3000;
|
|
4817
|
+
StreamClient.MAX_CONNECTIONS = 100;
|
|
4801
4818
|
|
|
4802
4819
|
exports.ChannelOwnCapability = ChannelOwnCapability;
|
|
4803
4820
|
exports.OwnCapability = OwnCapability;
|