@connectedxm/client 0.0.3 → 0.0.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @connectedxm/client-sdk
2
2
 
3
+ ## 0.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - 8ec09a2: fix utilities export
8
+
9
+ ## 0.0.4
10
+
11
+ ### Patch Changes
12
+
13
+ - d8c1212: add additional utilities
14
+
3
15
  ## 0.0.3
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,3 +1,4 @@
1
+ import { QueryClient, InfiniteData } from '@tanstack/react-query';
1
2
  import React from 'react';
2
3
 
3
4
  interface ConnectedXMResponse<TData> {
@@ -1060,6 +1061,22 @@ interface BaseSeries {
1060
1061
  interface Series extends BaseSeries {
1061
1062
  }
1062
1063
 
1064
+ declare const AppendInfiniteQuery: (queryClient: QueryClient, key: Array<string>, newData: any) => void;
1065
+
1066
+ declare const GetErrorMessage: (error: any, fallback?: string) => string;
1067
+
1068
+ declare function MergeInfinitePages<TData>(data: InfiniteData<ConnectedXMResponse<TData[]>>): TData[];
1069
+
1070
+ interface ItemWithId {
1071
+ id: string;
1072
+ alternateId?: number;
1073
+ slug?: string;
1074
+ username?: string;
1075
+ name?: string | null;
1076
+ code?: string;
1077
+ }
1078
+ declare const CacheIndividualQueries: <TData extends ItemWithId>(response: InfiniteData<ConnectedXMResponse<TData[]>>, queryClient: QueryClient, queryKeyFn: (id: string) => any, SET_FUNCTION: (client: QueryClient, keyParams: any, response: ConnectedXMResponse<TData>) => void, itemMap?: ((item: TData) => TData) | undefined) => void;
1079
+
1063
1080
  declare const useSetAuthToken: () => (token?: string | undefined) => void;
1064
1081
 
1065
1082
  interface ConnectedXMProps {
@@ -1072,4 +1089,4 @@ interface ConnectedXMProps {
1072
1089
  }
1073
1090
  declare const ConnectedXM: ({ organizationId, apiUrl, token, executeAs, locale, children, }: ConnectedXMProps) => React.JSX.Element;
1074
1091
 
1075
- export { type Account, type AccountShare, type AccountTier, AccountType, type Activity, type Advertisement, type AdvertisementClick, AdvertisementType, type AdvertisementView, type Announcement, type BaseAccount, type BaseAccountTier, type BaseActivity, type BaseAdvertisement, type BaseAnnouncement, type BaseBenefit, type BaseChatChannel, type BaseChatChannelMember, type BaseChatChannelMessage, type BaseCommunity, type BaseCommunityMembership, type BaseComplimentaryTicket, type BaseContent, type BaseContentType, type BaseCoupon, type BaseEvent, type BaseEventActivation, type BaseEventActivationCompletion, type BaseEventPage, type BaseFaq, type BaseFaqSection, type BaseImage, type BaseInstance, type BaseIntegrations, type BaseInterest, type BaseLead, type BaseLike, type BaseNotification, type BaseOrganization, type BasePage, type BasePurchase, type BaseRegistrationGuest, type BaseRegistrationPayment, type BaseRegistrationQuestion, type BaseRegistrationQuestionChoice, type BaseRegistrationQuestionResponse, type BaseRegistrationQuestionSearchValue, type BaseRegistrationSection, type BaseScan, type BaseSeries, type BaseSession, type BaseSpeaker, type BaseSponsorshipLevel, type BaseSupportTicket, type BaseSupportTicketNote, type BaseTeamMember, type BaseTicket, type BaseTrack, type BaseTransfer, type Benefit, type ChatChannel, type ChatChannelMember, type ChatChannelMessage, type Community, CommunityAccess, type CommunityMembership, CommunityMembershipRole, type ComplimentaryTicket, ConnectedXM, type ConnectedXMResponse, type Content, type ContentType, ContentTypeFormat, type Coupon, CouponType, Currency, type Event, type EventActivation, type EventActivationCompletion, type EventAllowlistMember, type EventListing, type EventPage, EventSource, EventType, type Faq, type FaqSection, type Image, ImageType, type Instance, type Integrations, type Interest, type Lead, type Like, type LinkPreview, type ManagedCoupon, type ManagedCouponOrder, type Notification, type NotificationPreferences, NotificationType, type Order, type OrgMembership, type Organization, type Page, type Purchase, type PushDevice, PushDeviceAppType, PushService, type Registration, type RegistrationEventDetails, type RegistrationGuest, type RegistrationPayment, type RegistrationQuestion, type RegistrationQuestionChoice, type RegistrationQuestionResponse, type RegistrationQuestionSearchValue, RegistrationQuestionType, type RegistrationSection, type RegistrationSectionQuestion, RegistrationStatus, type Scan, type Self, type Series, type Session, type Speaker, type SponsorshipLevel, type StreamInput, type SupportTicket, type SupportTicketNote, SupportTicketType, type TeamMember, type Ticket, type TicketAllowlistMember, TicketEventAccessLevel, TicketVisibility, type Track, type Transfer, type User, isListing, isManagedCoupon, isSelf, isTypeAccount, isTypeAccountTier, isTypeActivity, isTypeAdvertisement, isTypeAnnouncement, isTypeBenefit, isTypeCommunity, isTypeCommunityMembership, isTypeContent, isTypeContentType, isTypeCoupon, isTypeEvent, isTypeEventActivation, isTypeEventActivationCompletion, isTypeEventPage, isTypeFaq, isTypeFaqSection, isTypeImage, isTypeInstance, isTypeIntegrations, isTypeLead, isTypeNotification, isTypeOrganization, isTypePurchase, isTypeScan, isTypeSession, isTypeSpeaker, isTypeSponsorshipLevel, isTypeSupportTicket, isTypeSupportTicketNote, isTypeTeamMember, isTypeTicket, isTypeTrack, isTypeTransfer, useSetAuthToken };
1092
+ export { type Account, type AccountShare, type AccountTier, AccountType, type Activity, type Advertisement, type AdvertisementClick, AdvertisementType, type AdvertisementView, type Announcement, AppendInfiniteQuery, type BaseAccount, type BaseAccountTier, type BaseActivity, type BaseAdvertisement, type BaseAnnouncement, type BaseBenefit, type BaseChatChannel, type BaseChatChannelMember, type BaseChatChannelMessage, type BaseCommunity, type BaseCommunityMembership, type BaseComplimentaryTicket, type BaseContent, type BaseContentType, type BaseCoupon, type BaseEvent, type BaseEventActivation, type BaseEventActivationCompletion, type BaseEventPage, type BaseFaq, type BaseFaqSection, type BaseImage, type BaseInstance, type BaseIntegrations, type BaseInterest, type BaseLead, type BaseLike, type BaseNotification, type BaseOrganization, type BasePage, type BasePurchase, type BaseRegistrationGuest, type BaseRegistrationPayment, type BaseRegistrationQuestion, type BaseRegistrationQuestionChoice, type BaseRegistrationQuestionResponse, type BaseRegistrationQuestionSearchValue, type BaseRegistrationSection, type BaseScan, type BaseSeries, type BaseSession, type BaseSpeaker, type BaseSponsorshipLevel, type BaseSupportTicket, type BaseSupportTicketNote, type BaseTeamMember, type BaseTicket, type BaseTrack, type BaseTransfer, type Benefit, CacheIndividualQueries, type ChatChannel, type ChatChannelMember, type ChatChannelMessage, type Community, CommunityAccess, type CommunityMembership, CommunityMembershipRole, type ComplimentaryTicket, ConnectedXM, type ConnectedXMResponse, type Content, type ContentType, ContentTypeFormat, type Coupon, CouponType, Currency, type Event, type EventActivation, type EventActivationCompletion, type EventAllowlistMember, type EventListing, type EventPage, EventSource, EventType, type Faq, type FaqSection, GetErrorMessage, type Image, ImageType, type Instance, type Integrations, type Interest, type Lead, type Like, type LinkPreview, type ManagedCoupon, type ManagedCouponOrder, MergeInfinitePages, type Notification, type NotificationPreferences, NotificationType, type Order, type OrgMembership, type Organization, type Page, type Purchase, type PushDevice, PushDeviceAppType, PushService, type Registration, type RegistrationEventDetails, type RegistrationGuest, type RegistrationPayment, type RegistrationQuestion, type RegistrationQuestionChoice, type RegistrationQuestionResponse, type RegistrationQuestionSearchValue, RegistrationQuestionType, type RegistrationSection, type RegistrationSectionQuestion, RegistrationStatus, type Scan, type Self, type Series, type Session, type Speaker, type SponsorshipLevel, type StreamInput, type SupportTicket, type SupportTicketNote, SupportTicketType, type TeamMember, type Ticket, type TicketAllowlistMember, TicketEventAccessLevel, TicketVisibility, type Track, type Transfer, type User, isListing, isManagedCoupon, isSelf, isTypeAccount, isTypeAccountTier, isTypeActivity, isTypeAdvertisement, isTypeAnnouncement, isTypeBenefit, isTypeCommunity, isTypeCommunityMembership, isTypeContent, isTypeContentType, isTypeCoupon, isTypeEvent, isTypeEventActivation, isTypeEventActivationCompletion, isTypeEventPage, isTypeFaq, isTypeFaqSection, isTypeImage, isTypeInstance, isTypeIntegrations, isTypeLead, isTypeNotification, isTypeOrganization, isTypePurchase, isTypeScan, isTypeSession, isTypeSpeaker, isTypeSponsorshipLevel, isTypeSupportTicket, isTypeSupportTicketNote, isTypeTeamMember, isTypeTicket, isTypeTrack, isTypeTransfer, useSetAuthToken };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { QueryClient, InfiniteData } from '@tanstack/react-query';
1
2
  import React from 'react';
2
3
 
3
4
  interface ConnectedXMResponse<TData> {
@@ -1060,6 +1061,22 @@ interface BaseSeries {
1060
1061
  interface Series extends BaseSeries {
1061
1062
  }
1062
1063
 
1064
+ declare const AppendInfiniteQuery: (queryClient: QueryClient, key: Array<string>, newData: any) => void;
1065
+
1066
+ declare const GetErrorMessage: (error: any, fallback?: string) => string;
1067
+
1068
+ declare function MergeInfinitePages<TData>(data: InfiniteData<ConnectedXMResponse<TData[]>>): TData[];
1069
+
1070
+ interface ItemWithId {
1071
+ id: string;
1072
+ alternateId?: number;
1073
+ slug?: string;
1074
+ username?: string;
1075
+ name?: string | null;
1076
+ code?: string;
1077
+ }
1078
+ declare const CacheIndividualQueries: <TData extends ItemWithId>(response: InfiniteData<ConnectedXMResponse<TData[]>>, queryClient: QueryClient, queryKeyFn: (id: string) => any, SET_FUNCTION: (client: QueryClient, keyParams: any, response: ConnectedXMResponse<TData>) => void, itemMap?: ((item: TData) => TData) | undefined) => void;
1079
+
1063
1080
  declare const useSetAuthToken: () => (token?: string | undefined) => void;
1064
1081
 
1065
1082
  interface ConnectedXMProps {
@@ -1072,4 +1089,4 @@ interface ConnectedXMProps {
1072
1089
  }
1073
1090
  declare const ConnectedXM: ({ organizationId, apiUrl, token, executeAs, locale, children, }: ConnectedXMProps) => React.JSX.Element;
1074
1091
 
1075
- export { type Account, type AccountShare, type AccountTier, AccountType, type Activity, type Advertisement, type AdvertisementClick, AdvertisementType, type AdvertisementView, type Announcement, type BaseAccount, type BaseAccountTier, type BaseActivity, type BaseAdvertisement, type BaseAnnouncement, type BaseBenefit, type BaseChatChannel, type BaseChatChannelMember, type BaseChatChannelMessage, type BaseCommunity, type BaseCommunityMembership, type BaseComplimentaryTicket, type BaseContent, type BaseContentType, type BaseCoupon, type BaseEvent, type BaseEventActivation, type BaseEventActivationCompletion, type BaseEventPage, type BaseFaq, type BaseFaqSection, type BaseImage, type BaseInstance, type BaseIntegrations, type BaseInterest, type BaseLead, type BaseLike, type BaseNotification, type BaseOrganization, type BasePage, type BasePurchase, type BaseRegistrationGuest, type BaseRegistrationPayment, type BaseRegistrationQuestion, type BaseRegistrationQuestionChoice, type BaseRegistrationQuestionResponse, type BaseRegistrationQuestionSearchValue, type BaseRegistrationSection, type BaseScan, type BaseSeries, type BaseSession, type BaseSpeaker, type BaseSponsorshipLevel, type BaseSupportTicket, type BaseSupportTicketNote, type BaseTeamMember, type BaseTicket, type BaseTrack, type BaseTransfer, type Benefit, type ChatChannel, type ChatChannelMember, type ChatChannelMessage, type Community, CommunityAccess, type CommunityMembership, CommunityMembershipRole, type ComplimentaryTicket, ConnectedXM, type ConnectedXMResponse, type Content, type ContentType, ContentTypeFormat, type Coupon, CouponType, Currency, type Event, type EventActivation, type EventActivationCompletion, type EventAllowlistMember, type EventListing, type EventPage, EventSource, EventType, type Faq, type FaqSection, type Image, ImageType, type Instance, type Integrations, type Interest, type Lead, type Like, type LinkPreview, type ManagedCoupon, type ManagedCouponOrder, type Notification, type NotificationPreferences, NotificationType, type Order, type OrgMembership, type Organization, type Page, type Purchase, type PushDevice, PushDeviceAppType, PushService, type Registration, type RegistrationEventDetails, type RegistrationGuest, type RegistrationPayment, type RegistrationQuestion, type RegistrationQuestionChoice, type RegistrationQuestionResponse, type RegistrationQuestionSearchValue, RegistrationQuestionType, type RegistrationSection, type RegistrationSectionQuestion, RegistrationStatus, type Scan, type Self, type Series, type Session, type Speaker, type SponsorshipLevel, type StreamInput, type SupportTicket, type SupportTicketNote, SupportTicketType, type TeamMember, type Ticket, type TicketAllowlistMember, TicketEventAccessLevel, TicketVisibility, type Track, type Transfer, type User, isListing, isManagedCoupon, isSelf, isTypeAccount, isTypeAccountTier, isTypeActivity, isTypeAdvertisement, isTypeAnnouncement, isTypeBenefit, isTypeCommunity, isTypeCommunityMembership, isTypeContent, isTypeContentType, isTypeCoupon, isTypeEvent, isTypeEventActivation, isTypeEventActivationCompletion, isTypeEventPage, isTypeFaq, isTypeFaqSection, isTypeImage, isTypeInstance, isTypeIntegrations, isTypeLead, isTypeNotification, isTypeOrganization, isTypePurchase, isTypeScan, isTypeSession, isTypeSpeaker, isTypeSponsorshipLevel, isTypeSupportTicket, isTypeSupportTicketNote, isTypeTeamMember, isTypeTicket, isTypeTrack, isTypeTransfer, useSetAuthToken };
1092
+ export { type Account, type AccountShare, type AccountTier, AccountType, type Activity, type Advertisement, type AdvertisementClick, AdvertisementType, type AdvertisementView, type Announcement, AppendInfiniteQuery, type BaseAccount, type BaseAccountTier, type BaseActivity, type BaseAdvertisement, type BaseAnnouncement, type BaseBenefit, type BaseChatChannel, type BaseChatChannelMember, type BaseChatChannelMessage, type BaseCommunity, type BaseCommunityMembership, type BaseComplimentaryTicket, type BaseContent, type BaseContentType, type BaseCoupon, type BaseEvent, type BaseEventActivation, type BaseEventActivationCompletion, type BaseEventPage, type BaseFaq, type BaseFaqSection, type BaseImage, type BaseInstance, type BaseIntegrations, type BaseInterest, type BaseLead, type BaseLike, type BaseNotification, type BaseOrganization, type BasePage, type BasePurchase, type BaseRegistrationGuest, type BaseRegistrationPayment, type BaseRegistrationQuestion, type BaseRegistrationQuestionChoice, type BaseRegistrationQuestionResponse, type BaseRegistrationQuestionSearchValue, type BaseRegistrationSection, type BaseScan, type BaseSeries, type BaseSession, type BaseSpeaker, type BaseSponsorshipLevel, type BaseSupportTicket, type BaseSupportTicketNote, type BaseTeamMember, type BaseTicket, type BaseTrack, type BaseTransfer, type Benefit, CacheIndividualQueries, type ChatChannel, type ChatChannelMember, type ChatChannelMessage, type Community, CommunityAccess, type CommunityMembership, CommunityMembershipRole, type ComplimentaryTicket, ConnectedXM, type ConnectedXMResponse, type Content, type ContentType, ContentTypeFormat, type Coupon, CouponType, Currency, type Event, type EventActivation, type EventActivationCompletion, type EventAllowlistMember, type EventListing, type EventPage, EventSource, EventType, type Faq, type FaqSection, GetErrorMessage, type Image, ImageType, type Instance, type Integrations, type Interest, type Lead, type Like, type LinkPreview, type ManagedCoupon, type ManagedCouponOrder, MergeInfinitePages, type Notification, type NotificationPreferences, NotificationType, type Order, type OrgMembership, type Organization, type Page, type Purchase, type PushDevice, PushDeviceAppType, PushService, type Registration, type RegistrationEventDetails, type RegistrationGuest, type RegistrationPayment, type RegistrationQuestion, type RegistrationQuestionChoice, type RegistrationQuestionResponse, type RegistrationQuestionSearchValue, RegistrationQuestionType, type RegistrationSection, type RegistrationSectionQuestion, RegistrationStatus, type Scan, type Self, type Series, type Session, type Speaker, type SponsorshipLevel, type StreamInput, type SupportTicket, type SupportTicketNote, SupportTicketType, type TeamMember, type Ticket, type TicketAllowlistMember, TicketEventAccessLevel, TicketVisibility, type Track, type Transfer, type User, isListing, isManagedCoupon, isSelf, isTypeAccount, isTypeAccountTier, isTypeActivity, isTypeAdvertisement, isTypeAnnouncement, isTypeBenefit, isTypeCommunity, isTypeCommunityMembership, isTypeContent, isTypeContentType, isTypeCoupon, isTypeEvent, isTypeEventActivation, isTypeEventActivationCompletion, isTypeEventPage, isTypeFaq, isTypeFaqSection, isTypeImage, isTypeInstance, isTypeIntegrations, isTypeLead, isTypeNotification, isTypeOrganization, isTypePurchase, isTypeScan, isTypeSession, isTypeSpeaker, isTypeSponsorshipLevel, isTypeSupportTicket, isTypeSupportTicketNote, isTypeTeamMember, isTypeTicket, isTypeTrack, isTypeTransfer, useSetAuthToken };
package/dist/index.js CHANGED
@@ -7,6 +7,12 @@ function _array_like_to_array(arr, len) {
7
7
  function _array_with_holes(arr) {
8
8
  if (Array.isArray(arr)) return arr;
9
9
  }
10
+ function _array_without_holes(arr) {
11
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
12
+ }
13
+ function _iterable_to_array(iter) {
14
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
15
+ }
10
16
  function _iterable_to_array_limit(arr, i) {
11
17
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
12
18
  if (_i == null) return;
@@ -34,9 +40,15 @@ function _iterable_to_array_limit(arr, i) {
34
40
  function _non_iterable_rest() {
35
41
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
36
42
  }
43
+ function _non_iterable_spread() {
44
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
45
+ }
37
46
  function _sliced_to_array(arr, i) {
38
47
  return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
39
48
  }
49
+ function _to_consumable_array(arr) {
50
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
51
+ }
40
52
  function _unsupported_iterable_to_array(o, minLen) {
41
53
  if (!o) return;
42
54
  if (typeof o === "string") return _array_like_to_array(o, minLen);
@@ -112,6 +124,12 @@ __export(src_exports, {
112
124
  AdvertisementType: function() {
113
125
  return AdvertisementType;
114
126
  },
127
+ AppendInfiniteQuery: function() {
128
+ return AppendInfiniteQuery;
129
+ },
130
+ CacheIndividualQueries: function() {
131
+ return CacheIndividualQueries;
132
+ },
115
133
  CommunityAccess: function() {
116
134
  return CommunityAccess;
117
135
  },
@@ -136,9 +154,15 @@ __export(src_exports, {
136
154
  EventType: function() {
137
155
  return EventType;
138
156
  },
157
+ GetErrorMessage: function() {
158
+ return GetErrorMessage;
159
+ },
139
160
  ImageType: function() {
140
161
  return ImageType;
141
162
  },
163
+ MergeInfinitePages: function() {
164
+ return MergeInfinitePages;
165
+ },
142
166
  NotificationType: function() {
143
167
  return NotificationType;
144
168
  },
@@ -510,6 +534,74 @@ var isTypeEventActivation = function(eventActivation) {
510
534
  var isTypeEventActivationCompletion = function(eventActivationCompletion) {
511
535
  return eventActivationCompletion.updatedAt !== void 0;
512
536
  };
537
+ // src/utilities/AppendInfiniteQuery.ts
538
+ var AppendInfiniteQuery = function(queryClient, key, newData) {
539
+ queryClient.setQueriesData(key, function(data) {
540
+ var _data_pages_, _data_pages;
541
+ if (data === null || data === void 0 ? void 0 : (_data_pages = data.pages) === null || _data_pages === void 0 ? void 0 : (_data_pages_ = _data_pages[0]) === null || _data_pages_ === void 0 ? void 0 : _data_pages_.data) {
542
+ var _data_pages_1, _data_pages1, _data_pages__data, _data_pages_2, _data_pages2;
543
+ if ((data === null || data === void 0 ? void 0 : (_data_pages1 = data.pages) === null || _data_pages1 === void 0 ? void 0 : (_data_pages_1 = _data_pages1[0]) === null || _data_pages_1 === void 0 ? void 0 : _data_pages_1.data) && (data === null || data === void 0 ? void 0 : (_data_pages2 = data.pages) === null || _data_pages2 === void 0 ? void 0 : (_data_pages_2 = _data_pages2[0]) === null || _data_pages_2 === void 0 ? void 0 : (_data_pages__data = _data_pages_2.data) === null || _data_pages__data === void 0 ? void 0 : _data_pages__data.length) > 0 && newData) {
544
+ var _data_pages__data1, _data_pages_3, _data_pages3;
545
+ data === null || data === void 0 ? void 0 : (_data_pages3 = data.pages) === null || _data_pages3 === void 0 ? void 0 : (_data_pages_3 = _data_pages3[0]) === null || _data_pages_3 === void 0 ? void 0 : (_data_pages__data1 = _data_pages_3.data) === null || _data_pages__data1 === void 0 ? void 0 : _data_pages__data1.unshift(newData);
546
+ } else {
547
+ data.pages[0].data = [
548
+ newData
549
+ ];
550
+ }
551
+ }
552
+ return data;
553
+ });
554
+ };
555
+ // src/utilities/GetErrorMessage.ts
556
+ var import_axios = __toESM(require("axios"));
557
+ var GetErrorMessage = function(error) {
558
+ var fallback = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "Something went wrong";
559
+ var message = fallback;
560
+ if (import_axios.default.isAxiosError(error)) {
561
+ var _error_response_data, _error_response;
562
+ message = ((_error_response = error.response) === null || _error_response === void 0 ? void 0 : (_error_response_data = _error_response.data) === null || _error_response_data === void 0 ? void 0 : _error_response_data.message) || message;
563
+ } else {
564
+ message = error.message;
565
+ }
566
+ return message;
567
+ };
568
+ // src/utilities/MergeInfinitePages.ts
569
+ function MergeInfinitePages(data) {
570
+ return data.pages.reduce(function(sessions, page) {
571
+ return _to_consumable_array(sessions).concat(_to_consumable_array(page.data));
572
+ }, []);
573
+ }
574
+ // src/utilities/CacheIndividualQueries.ts
575
+ var CacheIndividualQueries = function(response, queryClient, queryKeyFn, SET_FUNCTION, itemMap) {
576
+ response.pages.forEach(function(page) {
577
+ page.data.forEach(function(item) {
578
+ item = itemMap ? itemMap(item) : item;
579
+ if (item.id) {
580
+ var SudoResponse = {
581
+ status: page.status,
582
+ message: "Cached From: ".concat(page.message),
583
+ data: item
584
+ };
585
+ SET_FUNCTION(queryClient, queryKeyFn(item.id), SudoResponse);
586
+ if (item.slug) {
587
+ SET_FUNCTION(queryClient, queryKeyFn(item.slug), SudoResponse);
588
+ }
589
+ if (item.username) {
590
+ SET_FUNCTION(queryClient, queryKeyFn(item.username), SudoResponse);
591
+ }
592
+ if (item.code) {
593
+ SET_FUNCTION(queryClient, queryKeyFn(item.code), SudoResponse);
594
+ }
595
+ if (item.name) {
596
+ SET_FUNCTION(queryClient, queryKeyFn(item.name), SudoResponse);
597
+ }
598
+ if (item.alternateId) {
599
+ SET_FUNCTION(queryClient, queryKeyFn(item.alternateId.toString()), SudoResponse);
600
+ }
601
+ }
602
+ });
603
+ });
604
+ };
513
605
  // src/hooks/useConnectedXM.ts
514
606
  var import_react2 = __toESM(require("react"));
515
607
  // src/Context.ts
@@ -549,6 +641,8 @@ var ConnectedXM = function(param) {
549
641
  0 && (module.exports = {
550
642
  AccountType: AccountType,
551
643
  AdvertisementType: AdvertisementType,
644
+ AppendInfiniteQuery: AppendInfiniteQuery,
645
+ CacheIndividualQueries: CacheIndividualQueries,
552
646
  CommunityAccess: CommunityAccess,
553
647
  CommunityMembershipRole: CommunityMembershipRole,
554
648
  ConnectedXM: ConnectedXM,
@@ -557,7 +651,9 @@ var ConnectedXM = function(param) {
557
651
  Currency: Currency,
558
652
  EventSource: EventSource,
559
653
  EventType: EventType,
654
+ GetErrorMessage: GetErrorMessage,
560
655
  ImageType: ImageType,
656
+ MergeInfinitePages: MergeInfinitePages,
561
657
  NotificationType: NotificationType,
562
658
  PushDeviceAppType: PushDeviceAppType,
563
659
  PushService: PushService,
package/dist/index.mjs CHANGED
@@ -230,6 +230,78 @@ var isTypeEventActivationCompletion = (eventActivationCompletion) => {
230
230
  return eventActivationCompletion.updatedAt !== void 0;
231
231
  };
232
232
 
233
+ // src/utilities/AppendInfiniteQuery.ts
234
+ var AppendInfiniteQuery = (queryClient, key, newData) => {
235
+ queryClient.setQueriesData(key, (data) => {
236
+ if (data?.pages?.[0]?.data) {
237
+ if (data?.pages?.[0]?.data && data?.pages?.[0]?.data?.length > 0 && newData) {
238
+ data?.pages?.[0]?.data?.unshift(newData);
239
+ } else {
240
+ data.pages[0].data = [newData];
241
+ }
242
+ }
243
+ return data;
244
+ });
245
+ };
246
+
247
+ // src/utilities/GetErrorMessage.ts
248
+ import axios from "axios";
249
+ var GetErrorMessage = (error, fallback = "Something went wrong") => {
250
+ let message = fallback;
251
+ if (axios.isAxiosError(error)) {
252
+ message = error.response?.data?.message || message;
253
+ } else {
254
+ message = error.message;
255
+ }
256
+ return message;
257
+ };
258
+
259
+ // src/utilities/MergeInfinitePages.ts
260
+ function MergeInfinitePages(data) {
261
+ return data.pages.reduce(
262
+ (sessions, page) => {
263
+ return [...sessions, ...page.data];
264
+ },
265
+ []
266
+ );
267
+ }
268
+
269
+ // src/utilities/CacheIndividualQueries.ts
270
+ var CacheIndividualQueries = (response, queryClient, queryKeyFn, SET_FUNCTION, itemMap) => {
271
+ response.pages.forEach((page) => {
272
+ page.data.forEach((item) => {
273
+ item = itemMap ? itemMap(item) : item;
274
+ if (item.id) {
275
+ const SudoResponse = {
276
+ status: page.status,
277
+ message: `Cached From: ${page.message}`,
278
+ data: item
279
+ };
280
+ SET_FUNCTION(queryClient, queryKeyFn(item.id), SudoResponse);
281
+ if (item.slug) {
282
+ SET_FUNCTION(queryClient, queryKeyFn(item.slug), SudoResponse);
283
+ }
284
+ if (item.username) {
285
+ SET_FUNCTION(queryClient, queryKeyFn(item.username), SudoResponse);
286
+ }
287
+ if (item.code) {
288
+ SET_FUNCTION(queryClient, queryKeyFn(item.code), SudoResponse);
289
+ }
290
+ if (item.name) {
291
+ SET_FUNCTION(queryClient, queryKeyFn(item.name), SudoResponse);
292
+ }
293
+ if (item.alternateId) {
294
+ SET_FUNCTION(
295
+ queryClient,
296
+ queryKeyFn(item.alternateId.toString()),
297
+ SudoResponse
298
+ );
299
+ }
300
+ }
301
+ });
302
+ });
303
+ };
304
+
233
305
  // src/hooks/useConnectedXM.ts
234
306
  import React2 from "react";
235
307
 
@@ -282,6 +354,8 @@ var ConnectedXM = ({
282
354
  export {
283
355
  AccountType,
284
356
  AdvertisementType,
357
+ AppendInfiniteQuery,
358
+ CacheIndividualQueries,
285
359
  CommunityAccess,
286
360
  CommunityMembershipRole,
287
361
  ConnectedXM,
@@ -290,7 +364,9 @@ export {
290
364
  Currency,
291
365
  EventSource,
292
366
  EventType,
367
+ GetErrorMessage,
293
368
  ImageType,
369
+ MergeInfinitePages,
294
370
  NotificationType,
295
371
  PushDeviceAppType,
296
372
  PushService,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connectedxm/client",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Client API javascript SDK",
5
5
  "author": "ConnectedXM Inc.",
6
6
  "license": "MIT",