@connectedxm/admin 2.8.19 → 2.8.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.js CHANGED
@@ -17840,6 +17840,73 @@ var useGetThreadMembers = (threadId = "", params = {}, options = {}) => {
17840
17840
  );
17841
17841
  };
17842
17842
 
17843
+ // src/queries/useConnectedCursorQuery.ts
17844
+ import {
17845
+ useInfiniteQuery as useInfiniteQuery2
17846
+ } from "@tanstack/react-query";
17847
+ var useConnectedCursorQuery = (queryKeys, queryFn, params = {}, options = {
17848
+ shouldRedirect: false
17849
+ }, domain) => {
17850
+ if (typeof params.pageSize === "undefined") params.pageSize = 25;
17851
+ const {
17852
+ onModuleForbidden,
17853
+ onNotAuthorized,
17854
+ onNotFound,
17855
+ apiUrl,
17856
+ getToken,
17857
+ organizationId,
17858
+ getExecuteAs,
17859
+ queryClient
17860
+ } = useConnectedXM();
17861
+ const { allowed } = usePermission_default(domain, domain ? "read" : void 0);
17862
+ const getNextPageParam = (lastPage) => {
17863
+ if (lastPage.cursor) {
17864
+ return lastPage.cursor;
17865
+ }
17866
+ return null;
17867
+ };
17868
+ return useInfiniteQuery2({
17869
+ staleTime: 60 * 1e3,
17870
+ // 60 Seconds
17871
+ retry: (failureCount, error) => {
17872
+ if (error.response?.status === 404) {
17873
+ if (onNotFound) onNotFound(error, queryKeys, options.shouldRedirect || false);
17874
+ return false;
17875
+ }
17876
+ if (error.response?.status === 403 || error.response?.status === 460 || error.response?.status === 461) {
17877
+ if (onModuleForbidden) onModuleForbidden(error, queryKeys, options.shouldRedirect || false);
17878
+ return false;
17879
+ }
17880
+ if (error.response?.status === 401) {
17881
+ if (onNotAuthorized) onNotAuthorized(error, queryKeys, options.shouldRedirect || false);
17882
+ return false;
17883
+ }
17884
+ if (failureCount < 3) return true;
17885
+ return false;
17886
+ },
17887
+ ...options,
17888
+ queryKey: [
17889
+ ...queryKeys,
17890
+ ...GetBaseInfiniteQueryKeys(params?.search)
17891
+ ],
17892
+ queryFn: ({ pageParam }) => queryFn({
17893
+ ...params,
17894
+ pageSize: params.pageSize || 25,
17895
+ cursor: pageParam,
17896
+ queryClient,
17897
+ adminApiParams: {
17898
+ apiUrl,
17899
+ getToken,
17900
+ organizationId,
17901
+ getExecuteAs
17902
+ }
17903
+ }),
17904
+ initialPageParam: null,
17905
+ getNextPageParam,
17906
+ enabled: (!domain || allowed) && options.enabled
17907
+ });
17908
+ };
17909
+
17843
17910
  // src/utilities/AppendInfiniteQuery.ts
17844
17911
  import { produce } from "immer";
17845
17912
  var AppendInfiniteQuery = (queryClient, key, newData) => {
@@ -17963,7 +18030,7 @@ var THREAD_MESSAGES_QUERY_KEY = (threadId) => [
17963
18030
  ...THREAD_QUERY_KEY(threadId),
17964
18031
  "MESSAGES"
17965
18032
  ];
17966
- var SET_THREAD_MESSAGES_QUERY_DATA = (client, keyParams, response, baseKeys = ["en"]) => {
18033
+ var SET_THREAD_MESSAGES_QUERY_DATA = (client, keyParams, response, baseKeys = [""]) => {
17967
18034
  client.setQueryData(
17968
18035
  [
17969
18036
  ...THREAD_MESSAGES_QUERY_KEY(...keyParams),
@@ -17974,7 +18041,7 @@ var SET_THREAD_MESSAGES_QUERY_DATA = (client, keyParams, response, baseKeys = ["
17974
18041
  };
17975
18042
  var GetThreadMessages = async ({
17976
18043
  threadId,
17977
- pageParam,
18044
+ cursor,
17978
18045
  pageSize,
17979
18046
  orderBy,
17980
18047
  search,
@@ -17984,7 +18051,7 @@ var GetThreadMessages = async ({
17984
18051
  const adminApi = await GetAdminAPI(adminApiParams);
17985
18052
  const { data } = await adminApi.get(`/threads/${threadId}/messages`, {
17986
18053
  params: {
17987
- page: pageParam || void 0,
18054
+ cursor: cursor || void 0,
17988
18055
  pageSize: pageSize || void 0,
17989
18056
  orderBy: orderBy || void 0,
17990
18057
  search: search || void 0
@@ -18001,7 +18068,7 @@ var GetThreadMessages = async ({
18001
18068
  };
18002
18069
  var useGetThreadMessages = (threadId = "", params = {}, options = {}) => {
18003
18070
  const { authenticated } = useConnectedXM();
18004
- return useConnectedInfiniteQuery(
18071
+ return useConnectedCursorQuery(
18005
18072
  THREAD_MESSAGES_QUERY_KEY(threadId),
18006
18073
  (params2) => GetThreadMessages({ ...params2, threadId }),
18007
18074
  params,
@@ -18232,6 +18299,46 @@ var useGetThreadMessageVideos = (threadId, messageId, params = {}, options = {})
18232
18299
  );
18233
18300
  };
18234
18301
 
18302
+ // src/queries/threads/useGetThreadMessagesPoll.ts
18303
+ var THREAD_MESSAGES_POLL_QUERY_KEY = (threadId, lastMessageId) => [
18304
+ ...THREAD_QUERY_KEY(threadId),
18305
+ "MESSAGES",
18306
+ lastMessageId,
18307
+ "POLL"
18308
+ ];
18309
+ var SET_THREAD_MESSAGES_POLL_QUERY_DATA = (client, keyParams, response) => {
18310
+ client.setQueryData(THREAD_MESSAGES_POLL_QUERY_KEY(...keyParams), response);
18311
+ };
18312
+ var GetThreadMessagesPoll = async ({
18313
+ threadId,
18314
+ lastMessageId,
18315
+ adminApiParams
18316
+ }) => {
18317
+ const adminApi = await GetAdminAPI(adminApiParams);
18318
+ const { data } = await adminApi.get(`/threads/${threadId}/messages/poll`, {
18319
+ params: {
18320
+ lastMessageId: lastMessageId || void 0
18321
+ }
18322
+ });
18323
+ return data;
18324
+ };
18325
+ var useGetThreadMessagesPoll = (threadId = "", lastMessageId = "", options = {}) => {
18326
+ const { authenticated } = useConnectedXM();
18327
+ return useConnectedSingleQuery(
18328
+ THREAD_MESSAGES_POLL_QUERY_KEY(threadId, lastMessageId),
18329
+ (params) => GetThreadMessagesPoll({ ...params, threadId, lastMessageId }),
18330
+ {
18331
+ ...options,
18332
+ enabled: !!authenticated && !!threadId && !!lastMessageId && (options?.enabled ?? true),
18333
+ // Polling configuration - you can adjust these as needed
18334
+ refetchInterval: options.refetchInterval ?? 5e3,
18335
+ // Poll every 5 seconds
18336
+ refetchIntervalInBackground: options.refetchIntervalInBackground ?? false
18337
+ },
18338
+ "threads"
18339
+ );
18340
+ };
18341
+
18235
18342
  // src/queries/tiers/useGetTiers.ts
18236
18343
  var TIERS_QUERY_KEY = (type) => {
18237
18344
  const keys = ["TIERS"];
@@ -18592,6 +18699,35 @@ var useGetVideoCaptions = (videoId = "", params = {}, options = {}) => {
18592
18699
  );
18593
18700
  };
18594
18701
 
18702
+ // src/queries/videos/useGetVideoDownloadStatus.ts
18703
+ var VIDEO_DOWNLOAD_STATUS_QUERY_KEY = (videoId) => [
18704
+ ...VIDEOS_QUERY_KEY(""),
18705
+ videoId,
18706
+ "download-status"
18707
+ ];
18708
+ var SET_VIDEO_DOWNLOAD_STATUS_QUERY_DATA = (client, keyParams, response) => {
18709
+ client.setQueryData(VIDEO_DOWNLOAD_STATUS_QUERY_KEY(...keyParams), response);
18710
+ };
18711
+ var GetVideoDownloadStatus = async ({
18712
+ videoId,
18713
+ adminApiParams
18714
+ }) => {
18715
+ const adminApi = await GetAdminAPI(adminApiParams);
18716
+ const { data } = await adminApi.get(`/videos/${videoId}/downloads`);
18717
+ return data;
18718
+ };
18719
+ var useGetVideoDownloadStatus = (videoId = "", options = {}) => {
18720
+ return useConnectedSingleQuery(
18721
+ VIDEO_DOWNLOAD_STATUS_QUERY_KEY(videoId),
18722
+ (params) => GetVideoDownloadStatus({ videoId, ...params }),
18723
+ {
18724
+ ...options,
18725
+ enabled: !!videoId && (options?.enabled ?? true)
18726
+ },
18727
+ "storage"
18728
+ );
18729
+ };
18730
+
18595
18731
  // src/PermissionsWrapper.tsx
18596
18732
  var PermissionsWrapper = ({
18597
18733
  children,
@@ -35861,6 +35997,29 @@ var useGenerateVideoCaptions = (options = {}) => {
35861
35997
  });
35862
35998
  };
35863
35999
 
36000
+ // src/mutations/videos/useInitiateVideoDownload.ts
36001
+ var InitiateVideoDownload = async ({
36002
+ videoId,
36003
+ adminApiParams,
36004
+ queryClient
36005
+ }) => {
36006
+ const connectedXM = await GetAdminAPI(adminApiParams);
36007
+ const { data } = await connectedXM.post(`/videos/${videoId}/downloads`);
36008
+ if (queryClient && data.status === "ok") {
36009
+ queryClient.invalidateQueries({ queryKey: VIDEOS_QUERY_KEY() });
36010
+ if (data.data?.default?.url) {
36011
+ queryClient.invalidateQueries({ queryKey: VIDEOS_QUERY_KEY(videoId) });
36012
+ }
36013
+ }
36014
+ return data;
36015
+ };
36016
+ var useInitiateVideoDownload = (options = {}) => {
36017
+ return useConnectedMutation(InitiateVideoDownload, options, {
36018
+ domain: "storage",
36019
+ type: "update"
36020
+ });
36021
+ };
36022
+
35864
36023
  // src/mutations/videos/useUpdateVideo.ts
35865
36024
  var UpdateVideo = async ({
35866
36025
  videoId,
@@ -37026,6 +37185,7 @@ export {
37026
37185
  GetThreadMessageReactions,
37027
37186
  GetThreadMessageVideos,
37028
37187
  GetThreadMessages,
37188
+ GetThreadMessagesPoll,
37029
37189
  GetThreads,
37030
37190
  GetTier,
37031
37191
  GetTierAccounts,
@@ -37036,6 +37196,7 @@ export {
37036
37196
  GetTiers,
37037
37197
  GetVideo,
37038
37198
  GetVideoCaptions,
37199
+ GetVideoDownloadStatus,
37039
37200
  GetVideos,
37040
37201
  GroupAccess,
37041
37202
  GroupInvitationStatus,
@@ -37067,6 +37228,7 @@ export {
37067
37228
  ImpersonateAccount,
37068
37229
  ImportItemStatus,
37069
37230
  ImportType,
37231
+ InitiateVideoDownload,
37070
37232
  IntegrationType,
37071
37233
  InvoiceStatus,
37072
37234
  LEVELS_QUERY_KEY,
@@ -37620,6 +37782,7 @@ export {
37620
37782
  SET_THREAD_CIRCLE_ACCOUNT_QUERY_DATA,
37621
37783
  SET_THREAD_CIRCLE_QUERY_DATA,
37622
37784
  SET_THREAD_CIRCLE_THREADS_QUERY_DATA,
37785
+ SET_THREAD_MESSAGES_POLL_QUERY_DATA,
37623
37786
  SET_THREAD_MESSAGES_QUERY_DATA,
37624
37787
  SET_THREAD_MESSAGE_FILES_QUERY_DATA,
37625
37788
  SET_THREAD_MESSAGE_IMAGES_QUERY_DATA,
@@ -37634,6 +37797,7 @@ export {
37634
37797
  SET_TIER_SUBSCRIBERS_QUERY_DATA,
37635
37798
  SET_VIDEOS_QUERY_DATA,
37636
37799
  SET_VIDEO_CAPTIONS_QUERY_DATA,
37800
+ SET_VIDEO_DOWNLOAD_STATUS_QUERY_DATA,
37637
37801
  SET_VIDEO_QUERY_DATA,
37638
37802
  STREAM_INPUTS_QUERY_KEY,
37639
37803
  STREAM_INPUT_OUTPUTS_QUERY_KEY,
@@ -37695,6 +37859,7 @@ export {
37695
37859
  THREAD_CIRCLE_QUERY_KEY,
37696
37860
  THREAD_CIRCLE_THREADS_QUERY_KEY,
37697
37861
  THREAD_MEMBERS_QUERY_KEY,
37862
+ THREAD_MESSAGES_POLL_QUERY_KEY,
37698
37863
  THREAD_MESSAGES_QUERY_KEY,
37699
37864
  THREAD_MESSAGE_FILES_QUERY_KEY,
37700
37865
  THREAD_MESSAGE_IMAGES_QUERY_KEY,
@@ -37882,6 +38047,7 @@ export {
37882
38047
  UserRole,
37883
38048
  VIDEOS_QUERY_KEY,
37884
38049
  VIDEO_CAPTIONS_QUERY_KEY,
38050
+ VIDEO_DOWNLOAD_STATUS_QUERY_KEY,
37885
38051
  VIDEO_QUERY_KEY,
37886
38052
  VerifyOrganizationWebhook,
37887
38053
  VideoSource,
@@ -37951,6 +38117,7 @@ export {
37951
38117
  useCancelSubscription,
37952
38118
  useCloneEvent,
37953
38119
  useConfirmAccountLogin,
38120
+ useConnectedCursorQuery,
37954
38121
  useConnectedInfiniteQuery,
37955
38122
  useConnectedMutation,
37956
38123
  useConnectedSingleQuery,
@@ -38664,6 +38831,7 @@ export {
38664
38831
  useGetThreadMessageReactions,
38665
38832
  useGetThreadMessageVideos,
38666
38833
  useGetThreadMessages,
38834
+ useGetThreadMessagesPoll,
38667
38835
  useGetThreads,
38668
38836
  useGetTier,
38669
38837
  useGetTierAccounts,
@@ -38674,8 +38842,10 @@ export {
38674
38842
  useGetTiers,
38675
38843
  useGetVideo,
38676
38844
  useGetVideoCaptions,
38845
+ useGetVideoDownloadStatus,
38677
38846
  useGetVideos,
38678
38847
  useImpersonateAccount,
38848
+ useInitiateVideoDownload,
38679
38849
  useRefundOrganizationPayment,
38680
38850
  useReinviteGroupInvitation,
38681
38851
  useRejectGroupRequest,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connectedxm/admin",
3
- "version": "2.8.19",
3
+ "version": "2.8.21",
4
4
  "description": "Admin API javascript SDK",
5
5
  "author": "ConnectedXM Inc.",
6
6
  "type": "module",