@stream-io/node-sdk 0.4.19 → 0.4.21

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.es.mjs CHANGED
@@ -138,7 +138,7 @@ class BaseApi {
138
138
  Authorization: this.apiConfig.token,
139
139
  'stream-auth-type': 'jwt',
140
140
  'Content-Type': 'application/json',
141
- 'X-Stream-Client': 'stream-node-' + "0.4.19",
141
+ 'X-Stream-Client': 'stream-node-' + "0.4.21",
142
142
  'Accept-Encoding': 'gzip',
143
143
  'x-client-request-id': clientRequestId,
144
144
  };
@@ -149,6 +149,7 @@ class BaseApi {
149
149
  method,
150
150
  body: JSON.stringify(body),
151
151
  headers,
152
+ dispatcher: this.dispatcher,
152
153
  });
153
154
  const responseHeaders = response.headers;
154
155
  const metadata = {
@@ -209,6 +210,7 @@ class BaseApi {
209
210
  }
210
211
  return newParams.join('&');
211
212
  };
213
+ this.dispatcher = this.apiConfig.agent;
212
214
  }
213
215
  }
214
216
 
@@ -512,6 +514,7 @@ decoders.ChannelStateResponse = (input) => {
512
514
  read: { type: 'ReadStateResponse', isSingle: false },
513
515
  watchers: { type: 'UserResponse', isSingle: false },
514
516
  channel: { type: 'ChannelResponse', isSingle: true },
517
+ draft: { type: 'DraftResponse', isSingle: true },
515
518
  membership: { type: 'ChannelMember', isSingle: true },
516
519
  push_preferences: { type: 'ChannelPushPreferences', isSingle: true },
517
520
  };
@@ -528,6 +531,7 @@ decoders.ChannelStateResponseFields = (input) => {
528
531
  read: { type: 'ReadStateResponse', isSingle: false },
529
532
  watchers: { type: 'UserResponse', isSingle: false },
530
533
  channel: { type: 'ChannelResponse', isSingle: true },
534
+ draft: { type: 'DraftResponse', isSingle: true },
531
535
  membership: { type: 'ChannelMember', isSingle: true },
532
536
  push_preferences: { type: 'ChannelPushPreferences', isSingle: true },
533
537
  };
@@ -654,6 +658,22 @@ decoders.DeviceResponse = (input) => {
654
658
  };
655
659
  return decode(typeMappings, input);
656
660
  };
661
+ decoders.DraftPayloadResponse = (input) => {
662
+ const typeMappings = {
663
+ mentioned_users: { type: 'UserResponse', isSingle: false },
664
+ };
665
+ return decode(typeMappings, input);
666
+ };
667
+ decoders.DraftResponse = (input) => {
668
+ const typeMappings = {
669
+ created_at: { type: 'DatetimeType', isSingle: true },
670
+ message: { type: 'DraftPayloadResponse', isSingle: true },
671
+ channel: { type: 'ChannelResponse', isSingle: true },
672
+ parent_message: { type: 'MessageResponse', isSingle: true },
673
+ quoted_message: { type: 'MessageResponse', isSingle: true },
674
+ };
675
+ return decode(typeMappings, input);
676
+ };
657
677
  decoders.EgressRTMPResponse = (input) => {
658
678
  const typeMappings = {
659
679
  started_at: { type: 'DatetimeType', isSingle: true },
@@ -704,7 +724,7 @@ decoders.ExportUserResponse = (input) => {
704
724
  };
705
725
  return decode(typeMappings, input);
706
726
  };
707
- decoders.Flag2 = (input) => {
727
+ decoders.Flag = (input) => {
708
728
  const typeMappings = {
709
729
  created_at: { type: 'DatetimeType', isSingle: true },
710
730
  updated_at: { type: 'DatetimeType', isSingle: true },
@@ -712,14 +732,6 @@ decoders.Flag2 = (input) => {
712
732
  };
713
733
  return decode(typeMappings, input);
714
734
  };
715
- decoders.Flag2Response = (input) => {
716
- const typeMappings = {
717
- created_at: { type: 'DatetimeType', isSingle: true },
718
- updated_at: { type: 'DatetimeType', isSingle: true },
719
- user: { type: 'UserResponse', isSingle: true },
720
- };
721
- return decode(typeMappings, input);
722
- };
723
735
  decoders.FlagDetails = (input) => {
724
736
  const typeMappings = {
725
737
  automod: { type: 'AutomodDetails', isSingle: true },
@@ -779,12 +791,6 @@ decoders.GetCallTypeResponse = (input) => {
779
791
  };
780
792
  return decode(typeMappings, input);
781
793
  };
782
- decoders.GetCampaignResponse = (input) => {
783
- const typeMappings = {
784
- campaign: { type: 'CampaignResponse', isSingle: true },
785
- };
786
- return decode(typeMappings, input);
787
- };
788
794
  decoders.GetChannelTypeResponse = (input) => {
789
795
  const typeMappings = {
790
796
  created_at: { type: 'DatetimeType', isSingle: true },
@@ -806,6 +812,12 @@ decoders.GetConfigResponse = (input) => {
806
812
  };
807
813
  return decode(typeMappings, input);
808
814
  };
815
+ decoders.GetDraftResponse = (input) => {
816
+ const typeMappings = {
817
+ draft: { type: 'DraftResponse', isSingle: true },
818
+ };
819
+ return decode(typeMappings, input);
820
+ };
809
821
  decoders.GetImportResponse = (input) => {
810
822
  const typeMappings = {
811
823
  import_task: { type: 'ImportTask', isSingle: true },
@@ -869,14 +881,6 @@ decoders.GetThreadResponse = (input) => {
869
881
  };
870
882
  return decode(typeMappings, input);
871
883
  };
872
- decoders.GetUserModerationReportResponse = (input) => {
873
- const typeMappings = {
874
- user_blocks: { type: 'UserBlock', isSingle: false },
875
- user_mutes: { type: 'UserMute', isSingle: false },
876
- user: { type: 'UserResponse', isSingle: true },
877
- };
878
- return decode(typeMappings, input);
879
- };
880
884
  decoders.GoLiveResponse = (input) => {
881
885
  const typeMappings = {
882
886
  call: { type: 'CallResponse', isSingle: true },
@@ -1049,6 +1053,7 @@ decoders.MessageResponse = (input) => {
1049
1053
  pin_expires: { type: 'DatetimeType', isSingle: true },
1050
1054
  pinned_at: { type: 'DatetimeType', isSingle: true },
1051
1055
  thread_participants: { type: 'UserResponse', isSingle: false },
1056
+ draft: { type: 'DraftResponse', isSingle: true },
1052
1057
  pinned_by: { type: 'UserResponse', isSingle: true },
1053
1058
  poll: { type: 'PollResponseData', isSingle: true },
1054
1059
  quoted_message: { type: 'MessageResponse', isSingle: true },
@@ -1070,6 +1075,7 @@ decoders.MessageWithChannelResponse = (input) => {
1070
1075
  pin_expires: { type: 'DatetimeType', isSingle: true },
1071
1076
  pinned_at: { type: 'DatetimeType', isSingle: true },
1072
1077
  thread_participants: { type: 'UserResponse', isSingle: false },
1078
+ draft: { type: 'DraftResponse', isSingle: true },
1073
1079
  pinned_by: { type: 'UserResponse', isSingle: true },
1074
1080
  poll: { type: 'PollResponseData', isSingle: true },
1075
1081
  quoted_message: { type: 'MessageResponse', isSingle: true },
@@ -1077,13 +1083,6 @@ decoders.MessageWithChannelResponse = (input) => {
1077
1083
  };
1078
1084
  return decode(typeMappings, input);
1079
1085
  };
1080
- decoders.ModerationUsageStats = (input) => {
1081
- const typeMappings = {
1082
- reference_date: { type: 'DatetimeType', isSingle: true },
1083
- updated_at: { type: 'DatetimeType', isSingle: true },
1084
- };
1085
- return decode(typeMappings, input);
1086
- };
1087
1086
  decoders.MuteChannelResponse = (input) => {
1088
1087
  const typeMappings = {
1089
1088
  channel_mutes: { type: 'ChannelMute', isSingle: false },
@@ -1261,6 +1260,12 @@ decoders.QueryChannelsResponse = (input) => {
1261
1260
  };
1262
1261
  return decode(typeMappings, input);
1263
1262
  };
1263
+ decoders.QueryDraftsResponse = (input) => {
1264
+ const typeMappings = {
1265
+ drafts: { type: 'DraftResponse', isSingle: false },
1266
+ };
1267
+ return decode(typeMappings, input);
1268
+ };
1264
1269
  decoders.QueryFeedModerationTemplate = (input) => {
1265
1270
  const typeMappings = {
1266
1271
  created_at: { type: 'DatetimeType', isSingle: true },
@@ -1334,12 +1339,6 @@ decoders.QueryThreadsResponse = (input) => {
1334
1339
  };
1335
1340
  return decode(typeMappings, input);
1336
1341
  };
1337
- decoders.QueryUsageStatsResponse = (input) => {
1338
- const typeMappings = {
1339
- items: { type: 'ModerationUsageStats', isSingle: false },
1340
- };
1341
- return decode(typeMappings, input);
1342
- };
1343
1342
  decoders.QueryUsersResponse = (input) => {
1344
1343
  const typeMappings = {
1345
1344
  users: { type: 'FullUserResponse', isSingle: false },
@@ -1388,7 +1387,7 @@ decoders.ReviewQueueItem = (input) => {
1388
1387
  updated_at: { type: 'DatetimeType', isSingle: true },
1389
1388
  actions: { type: 'ActionLog', isSingle: false },
1390
1389
  bans: { type: 'Ban', isSingle: false },
1391
- flags: { type: 'Flag2', isSingle: false },
1390
+ flags: { type: 'Flag', isSingle: false },
1392
1391
  assigned_to: { type: 'User', isSingle: true },
1393
1392
  entity_creator: { type: 'EntityCreator', isSingle: true },
1394
1393
  feeds_v2_reaction: { type: 'Reaction', isSingle: true },
@@ -1403,7 +1402,6 @@ decoders.ReviewQueueItemResponse = (input) => {
1403
1402
  updated_at: { type: 'DatetimeType', isSingle: true },
1404
1403
  actions: { type: 'ActionLogResponse', isSingle: false },
1405
1404
  bans: { type: 'Ban', isSingle: false },
1406
- flags: { type: 'Flag2Response', isSingle: false },
1407
1405
  completed_at: { type: 'DatetimeType', isSingle: true },
1408
1406
  reviewed_at: { type: 'DatetimeType', isSingle: true },
1409
1407
  assigned_to: { type: 'UserResponse', isSingle: true },
@@ -1441,6 +1439,7 @@ decoders.SearchResultMessage = (input) => {
1441
1439
  pinned_at: { type: 'DatetimeType', isSingle: true },
1442
1440
  thread_participants: { type: 'UserResponse', isSingle: false },
1443
1441
  channel: { type: 'ChannelResponse', isSingle: true },
1442
+ draft: { type: 'DraftResponse', isSingle: true },
1444
1443
  pinned_by: { type: 'UserResponse', isSingle: true },
1445
1444
  poll: { type: 'PollResponseData', isSingle: true },
1446
1445
  quoted_message: { type: 'MessageResponse', isSingle: true },
@@ -1483,12 +1482,6 @@ decoders.SendReactionResponse = (input) => {
1483
1482
  };
1484
1483
  return decode(typeMappings, input);
1485
1484
  };
1486
- decoders.StartCampaignResponse = (input) => {
1487
- const typeMappings = {
1488
- campaign: { type: 'CampaignResponse', isSingle: true },
1489
- };
1490
- return decode(typeMappings, input);
1491
- };
1492
1485
  decoders.StopLiveResponse = (input) => {
1493
1486
  const typeMappings = {
1494
1487
  call: { type: 'CallResponse', isSingle: true },
@@ -1535,6 +1528,7 @@ decoders.ThreadStateResponse = (input) => {
1535
1528
  thread_participants: { type: 'ThreadParticipant', isSingle: false },
1536
1529
  channel: { type: 'ChannelResponse', isSingle: true },
1537
1530
  created_by: { type: 'UserResponse', isSingle: true },
1531
+ draft: { type: 'DraftResponse', isSingle: true },
1538
1532
  parent_message: { type: 'MessageResponse', isSingle: true },
1539
1533
  };
1540
1534
  return decode(typeMappings, input);
@@ -1693,12 +1687,6 @@ decoders.User = (input) => {
1693
1687
  };
1694
1688
  return decode(typeMappings, input);
1695
1689
  };
1696
- decoders.UserBlock = (input) => {
1697
- const typeMappings = {
1698
- created_at: { type: 'DatetimeType', isSingle: true },
1699
- };
1700
- return decode(typeMappings, input);
1701
- };
1702
1690
  decoders.UserMute = (input) => {
1703
1691
  const typeMappings = {
1704
1692
  created_at: { type: 'DatetimeType', isSingle: true },
@@ -3086,6 +3074,7 @@ class ChatApi extends BaseApi {
3086
3074
  limit: request?.limit,
3087
3075
  next: request?.next,
3088
3076
  prev: request?.prev,
3077
+ user_limit: request?.user_limit,
3089
3078
  sort: request?.sort,
3090
3079
  filter: request?.filter,
3091
3080
  };
@@ -3094,10 +3083,15 @@ class ChatApi extends BaseApi {
3094
3083
  return { ...response.body, metadata: response.metadata };
3095
3084
  };
3096
3085
  this.getCampaign = async (request) => {
3086
+ const queryParams = {
3087
+ prev: request?.prev,
3088
+ next: request?.next,
3089
+ limit: request?.limit,
3090
+ };
3097
3091
  const pathParams = {
3098
3092
  id: request?.id,
3099
3093
  };
3100
- const response = await this.sendRequest('GET', '/api/v2/chat/campaigns/{id}', pathParams, undefined);
3094
+ const response = await this.sendRequest('GET', '/api/v2/chat/campaigns/{id}', pathParams, queryParams);
3101
3095
  decoders.GetCampaignResponse?.(response.body);
3102
3096
  return { ...response.body, metadata: response.metadata };
3103
3097
  };
@@ -3227,6 +3221,32 @@ class ChatApi extends BaseApi {
3227
3221
  decoders.UpdateChannelResponse?.(response.body);
3228
3222
  return { ...response.body, metadata: response.metadata };
3229
3223
  };
3224
+ this.deleteDraft = async (request) => {
3225
+ const queryParams = {
3226
+ parent_id: request?.parent_id,
3227
+ user_id: request?.user_id,
3228
+ };
3229
+ const pathParams = {
3230
+ type: request?.type,
3231
+ id: request?.id,
3232
+ };
3233
+ const response = await this.sendRequest('DELETE', '/api/v2/chat/channels/{type}/{id}/draft', pathParams, queryParams);
3234
+ decoders.Response?.(response.body);
3235
+ return { ...response.body, metadata: response.metadata };
3236
+ };
3237
+ this.getDraft = async (request) => {
3238
+ const queryParams = {
3239
+ parent_id: request?.parent_id,
3240
+ user_id: request?.user_id,
3241
+ };
3242
+ const pathParams = {
3243
+ type: request?.type,
3244
+ id: request?.id,
3245
+ };
3246
+ const response = await this.sendRequest('GET', '/api/v2/chat/channels/{type}/{id}/draft', pathParams, queryParams);
3247
+ decoders.GetDraftResponse?.(response.body);
3248
+ return { ...response.body, metadata: response.metadata };
3249
+ };
3230
3250
  this.sendEvent = async (request) => {
3231
3251
  const pathParams = {
3232
3252
  type: request?.type,
@@ -3565,6 +3585,20 @@ class ChatApi extends BaseApi {
3565
3585
  decoders.UpdateCommandResponse?.(response.body);
3566
3586
  return { ...response.body, metadata: response.metadata };
3567
3587
  };
3588
+ this.queryDrafts = async (request) => {
3589
+ const body = {
3590
+ limit: request?.limit,
3591
+ next: request?.next,
3592
+ prev: request?.prev,
3593
+ user_id: request?.user_id,
3594
+ sort: request?.sort,
3595
+ filter: request?.filter,
3596
+ user: request?.user,
3597
+ };
3598
+ const response = await this.sendRequest('POST', '/api/v2/chat/drafts/query', undefined, undefined, body);
3599
+ decoders.QueryDraftsResponse?.(response.body);
3600
+ return { ...response.body, metadata: response.metadata };
3601
+ };
3568
3602
  this.exportChannels = async (request) => {
3569
3603
  const body = {
3570
3604
  channels: request?.channels,
@@ -4181,6 +4215,22 @@ class ChannelApi {
4181
4215
  ...request,
4182
4216
  });
4183
4217
  };
4218
+ this.deleteDraft = (request) => {
4219
+ if (!this.id) {
4220
+ throw new Error(`Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`);
4221
+ }
4222
+ return this.chatApi.deleteDraft({
4223
+ id: this.id,
4224
+ type: this.type,
4225
+ ...request,
4226
+ });
4227
+ };
4228
+ this.getDraft = (request) => {
4229
+ if (!this.id) {
4230
+ throw new Error(`Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`);
4231
+ }
4232
+ return this.chatApi.getDraft({ id: this.id, type: this.type, ...request });
4233
+ };
4184
4234
  this.sendEvent = (request) => {
4185
4235
  if (!this.id) {
4186
4236
  throw new Error(`Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`);
@@ -4366,15 +4416,6 @@ class StreamChatClient extends ChatApi {
4366
4416
  class ModerationApi extends BaseApi {
4367
4417
  constructor() {
4368
4418
  super(...arguments);
4369
- this.getModerationAnalytics = async (request) => {
4370
- const body = {
4371
- end_date: request?.end_date,
4372
- start_date: request?.start_date,
4373
- };
4374
- const response = await this.sendRequest('POST', '/api/v2/moderation/analytics', undefined, undefined, body);
4375
- decoders.GetModerationAnalyticsResponse?.(response.body);
4376
- return { ...response.body, metadata: response.metadata };
4377
- };
4378
4419
  this.ban = async (request) => {
4379
4420
  const body = {
4380
4421
  target_user_id: request?.target_user_id,
@@ -4414,7 +4455,6 @@ class ModerationApi extends BaseApi {
4414
4455
  team: request?.team,
4415
4456
  user_id: request?.user_id,
4416
4457
  ai_image_config: request?.ai_image_config,
4417
- ai_image_lite_config: request?.ai_image_lite_config,
4418
4458
  ai_text_config: request?.ai_text_config,
4419
4459
  ai_video_config: request?.ai_video_config,
4420
4460
  automod_platform_circumvention_config: request?.automod_platform_circumvention_config,
@@ -4529,11 +4569,6 @@ class ModerationApi extends BaseApi {
4529
4569
  decoders.QueryModerationLogsResponse?.(response.body);
4530
4570
  return { ...response.body, metadata: response.metadata };
4531
4571
  };
4532
- this.getModeratorStats = async () => {
4533
- const response = await this.sendRequest('GET', '/api/v2/moderation/moderator_stats', undefined, undefined);
4534
- decoders.ModeratorStatsResponse?.(response.body);
4535
- return { ...response.body, metadata: response.metadata };
4536
- };
4537
4572
  this.mute = async (request) => {
4538
4573
  const body = {
4539
4574
  target_ids: request?.target_ids,
@@ -4545,11 +4580,6 @@ class ModerationApi extends BaseApi {
4545
4580
  decoders.MuteResponse?.(response.body);
4546
4581
  return { ...response.body, metadata: response.metadata };
4547
4582
  };
4548
- this.getQueueStats = async () => {
4549
- const response = await this.sendRequest('GET', '/api/v2/moderation/queue_stats', undefined, undefined);
4550
- decoders.QueueStatsResponse?.(response.body);
4551
- return { ...response.body, metadata: response.metadata };
4552
- };
4553
4583
  this.queryReviewQueue = async (request) => {
4554
4584
  const body = {
4555
4585
  limit: request?.limit,
@@ -4619,31 +4649,6 @@ class ModerationApi extends BaseApi {
4619
4649
  decoders.UnmuteResponse?.(response.body);
4620
4650
  return { ...response.body, metadata: response.metadata };
4621
4651
  };
4622
- this.queryUsageStats = async (request) => {
4623
- const body = {
4624
- limit: request?.limit,
4625
- next: request?.next,
4626
- prev: request?.prev,
4627
- user_id: request?.user_id,
4628
- sort: request?.sort,
4629
- filter: request?.filter,
4630
- user: request?.user,
4631
- };
4632
- const response = await this.sendRequest('POST', '/api/v2/moderation/usage_stats', undefined, undefined, body);
4633
- decoders.QueryUsageStatsResponse?.(response.body);
4634
- return { ...response.body, metadata: response.metadata };
4635
- };
4636
- this.getUserReport = async (request) => {
4637
- const queryParams = {
4638
- user_id: request?.user_id,
4639
- create_user_if_not_exists: request?.create_user_if_not_exists,
4640
- include_user_mutes: request?.include_user_mutes,
4641
- include_user_blocks: request?.include_user_blocks,
4642
- };
4643
- const response = await this.sendRequest('GET', '/api/v2/moderation/user_report', undefined, queryParams);
4644
- decoders.GetUserModerationReportResponse?.(response.body);
4645
- return { ...response.body, metadata: response.metadata };
4646
- };
4647
4652
  }
4648
4653
  }
4649
4654
 
@@ -4662,7 +4667,13 @@ class StreamClient extends CommonApi {
4662
4667
  const timeout = config?.timeout ?? StreamClient.DEFAULT_TIMEOUT;
4663
4668
  const chatBaseUrl = config?.basePath ?? 'https://chat.stream-io-api.com';
4664
4669
  const videoBaseUrl = config?.basePath ?? 'https://video.stream-io-api.com';
4665
- super({ apiKey, token, timeout, baseUrl: chatBaseUrl });
4670
+ super({
4671
+ apiKey,
4672
+ token,
4673
+ timeout,
4674
+ baseUrl: chatBaseUrl,
4675
+ agent: config?.agent,
4676
+ });
4666
4677
  this.apiKey = apiKey;
4667
4678
  this.secret = secret;
4668
4679
  this.config = config;
@@ -4763,18 +4774,21 @@ class StreamClient extends CommonApi {
4763
4774
  token,
4764
4775
  timeout,
4765
4776
  baseUrl: videoBaseUrl,
4777
+ agent: config?.agent,
4766
4778
  });
4767
4779
  this.chat = new StreamChatClient({
4768
4780
  apiKey,
4769
4781
  token,
4770
4782
  timeout,
4771
4783
  baseUrl: chatBaseUrl,
4784
+ agent: config?.agent,
4772
4785
  });
4773
4786
  this.moderation = new StreamModerationClient({
4774
4787
  apiKey,
4775
4788
  token,
4776
4789
  timeout,
4777
4790
  baseUrl: chatBaseUrl,
4791
+ agent: config?.agent,
4778
4792
  });
4779
4793
  }
4780
4794
  }