@connectedxm/admin 2.8.20 → 2.8.22

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
@@ -12721,6 +12721,8 @@ var BadgeFieldType = /* @__PURE__ */ ((BadgeFieldType2) => {
12721
12721
  BadgeFieldType2["tier"] = "tier";
12722
12722
  BadgeFieldType2["ticket"] = "ticket";
12723
12723
  BadgeFieldType2["pass"] = "pass";
12724
+ BadgeFieldType2["session"] = "session";
12725
+ BadgeFieldType2["session_question"] = "session_question";
12724
12726
  return BadgeFieldType2;
12725
12727
  })(BadgeFieldType || {});
12726
12728
  var BadgeFieldTransformation = /* @__PURE__ */ ((BadgeFieldTransformation2) => {
@@ -17840,6 +17842,73 @@ var useGetThreadMembers = (threadId = "", params = {}, options = {}) => {
17840
17842
  );
17841
17843
  };
17842
17844
 
17845
+ // src/queries/useConnectedCursorQuery.ts
17846
+ import {
17847
+ useInfiniteQuery as useInfiniteQuery2
17848
+ } from "@tanstack/react-query";
17849
+ var useConnectedCursorQuery = (queryKeys, queryFn, params = {}, options = {
17850
+ shouldRedirect: false
17851
+ }, domain) => {
17852
+ if (typeof params.pageSize === "undefined") params.pageSize = 25;
17853
+ const {
17854
+ onModuleForbidden,
17855
+ onNotAuthorized,
17856
+ onNotFound,
17857
+ apiUrl,
17858
+ getToken,
17859
+ organizationId,
17860
+ getExecuteAs,
17861
+ queryClient
17862
+ } = useConnectedXM();
17863
+ const { allowed } = usePermission_default(domain, domain ? "read" : void 0);
17864
+ const getNextPageParam = (lastPage) => {
17865
+ if (lastPage.cursor) {
17866
+ return lastPage.cursor;
17867
+ }
17868
+ return null;
17869
+ };
17870
+ return useInfiniteQuery2({
17871
+ staleTime: 60 * 1e3,
17872
+ // 60 Seconds
17873
+ retry: (failureCount, error) => {
17874
+ if (error.response?.status === 404) {
17875
+ if (onNotFound) onNotFound(error, queryKeys, options.shouldRedirect || false);
17876
+ return false;
17877
+ }
17878
+ if (error.response?.status === 403 || error.response?.status === 460 || error.response?.status === 461) {
17879
+ if (onModuleForbidden) onModuleForbidden(error, queryKeys, options.shouldRedirect || false);
17880
+ return false;
17881
+ }
17882
+ if (error.response?.status === 401) {
17883
+ if (onNotAuthorized) onNotAuthorized(error, queryKeys, options.shouldRedirect || false);
17884
+ return false;
17885
+ }
17886
+ if (failureCount < 3) return true;
17887
+ return false;
17888
+ },
17889
+ ...options,
17890
+ queryKey: [
17891
+ ...queryKeys,
17892
+ ...GetBaseInfiniteQueryKeys(params?.search)
17893
+ ],
17894
+ queryFn: ({ pageParam }) => queryFn({
17895
+ ...params,
17896
+ pageSize: params.pageSize || 25,
17897
+ cursor: pageParam,
17898
+ queryClient,
17899
+ adminApiParams: {
17900
+ apiUrl,
17901
+ getToken,
17902
+ organizationId,
17903
+ getExecuteAs
17904
+ }
17905
+ }),
17906
+ initialPageParam: null,
17907
+ getNextPageParam,
17908
+ enabled: (!domain || allowed) && options.enabled
17909
+ });
17910
+ };
17911
+
17843
17912
  // src/utilities/AppendInfiniteQuery.ts
17844
17913
  import { produce } from "immer";
17845
17914
  var AppendInfiniteQuery = (queryClient, key, newData) => {
@@ -17963,7 +18032,7 @@ var THREAD_MESSAGES_QUERY_KEY = (threadId) => [
17963
18032
  ...THREAD_QUERY_KEY(threadId),
17964
18033
  "MESSAGES"
17965
18034
  ];
17966
- var SET_THREAD_MESSAGES_QUERY_DATA = (client, keyParams, response, baseKeys = ["en"]) => {
18035
+ var SET_THREAD_MESSAGES_QUERY_DATA = (client, keyParams, response, baseKeys = [""]) => {
17967
18036
  client.setQueryData(
17968
18037
  [
17969
18038
  ...THREAD_MESSAGES_QUERY_KEY(...keyParams),
@@ -17974,7 +18043,7 @@ var SET_THREAD_MESSAGES_QUERY_DATA = (client, keyParams, response, baseKeys = ["
17974
18043
  };
17975
18044
  var GetThreadMessages = async ({
17976
18045
  threadId,
17977
- pageParam,
18046
+ cursor,
17978
18047
  pageSize,
17979
18048
  orderBy,
17980
18049
  search,
@@ -17984,7 +18053,7 @@ var GetThreadMessages = async ({
17984
18053
  const adminApi = await GetAdminAPI(adminApiParams);
17985
18054
  const { data } = await adminApi.get(`/threads/${threadId}/messages`, {
17986
18055
  params: {
17987
- page: pageParam || void 0,
18056
+ cursor: cursor || void 0,
17988
18057
  pageSize: pageSize || void 0,
17989
18058
  orderBy: orderBy || void 0,
17990
18059
  search: search || void 0
@@ -18001,7 +18070,7 @@ var GetThreadMessages = async ({
18001
18070
  };
18002
18071
  var useGetThreadMessages = (threadId = "", params = {}, options = {}) => {
18003
18072
  const { authenticated } = useConnectedXM();
18004
- return useConnectedInfiniteQuery(
18073
+ return useConnectedCursorQuery(
18005
18074
  THREAD_MESSAGES_QUERY_KEY(threadId),
18006
18075
  (params2) => GetThreadMessages({ ...params2, threadId }),
18007
18076
  params,
@@ -18232,6 +18301,46 @@ var useGetThreadMessageVideos = (threadId, messageId, params = {}, options = {})
18232
18301
  );
18233
18302
  };
18234
18303
 
18304
+ // src/queries/threads/useGetThreadMessagesPoll.ts
18305
+ var THREAD_MESSAGES_POLL_QUERY_KEY = (threadId, lastMessageId) => [
18306
+ ...THREAD_QUERY_KEY(threadId),
18307
+ "MESSAGES",
18308
+ lastMessageId,
18309
+ "POLL"
18310
+ ];
18311
+ var SET_THREAD_MESSAGES_POLL_QUERY_DATA = (client, keyParams, response) => {
18312
+ client.setQueryData(THREAD_MESSAGES_POLL_QUERY_KEY(...keyParams), response);
18313
+ };
18314
+ var GetThreadMessagesPoll = async ({
18315
+ threadId,
18316
+ lastMessageId,
18317
+ adminApiParams
18318
+ }) => {
18319
+ const adminApi = await GetAdminAPI(adminApiParams);
18320
+ const { data } = await adminApi.get(`/threads/${threadId}/messages/poll`, {
18321
+ params: {
18322
+ lastMessageId: lastMessageId || void 0
18323
+ }
18324
+ });
18325
+ return data;
18326
+ };
18327
+ var useGetThreadMessagesPoll = (threadId = "", lastMessageId = "", options = {}) => {
18328
+ const { authenticated } = useConnectedXM();
18329
+ return useConnectedSingleQuery(
18330
+ THREAD_MESSAGES_POLL_QUERY_KEY(threadId, lastMessageId),
18331
+ (params) => GetThreadMessagesPoll({ ...params, threadId, lastMessageId }),
18332
+ {
18333
+ ...options,
18334
+ enabled: !!authenticated && !!threadId && !!lastMessageId && (options?.enabled ?? true),
18335
+ // Polling configuration - you can adjust these as needed
18336
+ refetchInterval: options.refetchInterval ?? 5e3,
18337
+ // Poll every 5 seconds
18338
+ refetchIntervalInBackground: options.refetchIntervalInBackground ?? false
18339
+ },
18340
+ "threads"
18341
+ );
18342
+ };
18343
+
18235
18344
  // src/queries/tiers/useGetTiers.ts
18236
18345
  var TIERS_QUERY_KEY = (type) => {
18237
18346
  const keys = ["TIERS"];
@@ -37078,6 +37187,7 @@ export {
37078
37187
  GetThreadMessageReactions,
37079
37188
  GetThreadMessageVideos,
37080
37189
  GetThreadMessages,
37190
+ GetThreadMessagesPoll,
37081
37191
  GetThreads,
37082
37192
  GetTier,
37083
37193
  GetTierAccounts,
@@ -37674,6 +37784,7 @@ export {
37674
37784
  SET_THREAD_CIRCLE_ACCOUNT_QUERY_DATA,
37675
37785
  SET_THREAD_CIRCLE_QUERY_DATA,
37676
37786
  SET_THREAD_CIRCLE_THREADS_QUERY_DATA,
37787
+ SET_THREAD_MESSAGES_POLL_QUERY_DATA,
37677
37788
  SET_THREAD_MESSAGES_QUERY_DATA,
37678
37789
  SET_THREAD_MESSAGE_FILES_QUERY_DATA,
37679
37790
  SET_THREAD_MESSAGE_IMAGES_QUERY_DATA,
@@ -37750,6 +37861,7 @@ export {
37750
37861
  THREAD_CIRCLE_QUERY_KEY,
37751
37862
  THREAD_CIRCLE_THREADS_QUERY_KEY,
37752
37863
  THREAD_MEMBERS_QUERY_KEY,
37864
+ THREAD_MESSAGES_POLL_QUERY_KEY,
37753
37865
  THREAD_MESSAGES_QUERY_KEY,
37754
37866
  THREAD_MESSAGE_FILES_QUERY_KEY,
37755
37867
  THREAD_MESSAGE_IMAGES_QUERY_KEY,
@@ -38007,6 +38119,7 @@ export {
38007
38119
  useCancelSubscription,
38008
38120
  useCloneEvent,
38009
38121
  useConfirmAccountLogin,
38122
+ useConnectedCursorQuery,
38010
38123
  useConnectedInfiniteQuery,
38011
38124
  useConnectedMutation,
38012
38125
  useConnectedSingleQuery,
@@ -38720,6 +38833,7 @@ export {
38720
38833
  useGetThreadMessageReactions,
38721
38834
  useGetThreadMessageVideos,
38722
38835
  useGetThreadMessages,
38836
+ useGetThreadMessagesPoll,
38723
38837
  useGetThreads,
38724
38838
  useGetTier,
38725
38839
  useGetTierAccounts,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connectedxm/admin",
3
- "version": "2.8.20",
3
+ "version": "2.8.22",
4
4
  "description": "Admin API javascript SDK",
5
5
  "author": "ConnectedXM Inc.",
6
6
  "type": "module",