@connectedxm/client 0.0.2 → 0.0.4

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.4
4
+
5
+ ### Patch Changes
6
+
7
+ - d8c1212: add additional utilities
8
+
9
+ ## 0.0.3
10
+
11
+ ### Patch Changes
12
+
13
+ - 3b7f67d: add getErrorMessage utility
14
+
3
15
  ## 0.0.2
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,38 @@ 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 namespace AppendInfiniteQuery$1 {
1067
+ export { AppendInfiniteQuery as default };
1068
+ }
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
+
1080
+ declare namespace CacheIndividualQueries$1 {
1081
+ export { CacheIndividualQueries as default };
1082
+ }
1083
+
1084
+ declare const GetErrorMessage: (error: any, fallback?: string) => string;
1085
+
1086
+ declare namespace GetErrorMessage$1 {
1087
+ export { GetErrorMessage as default };
1088
+ }
1089
+
1090
+ declare function MergeInfinitePages<TData>(data: InfiniteData<ConnectedXMResponse<TData[]>>): TData[];
1091
+
1092
+ declare namespace MergeInfinitePages$1 {
1093
+ export { MergeInfinitePages as default };
1094
+ }
1095
+
1063
1096
  declare const useSetAuthToken: () => (token?: string | undefined) => void;
1064
1097
 
1065
1098
  interface ConnectedXMProps {
@@ -1072,4 +1105,4 @@ interface ConnectedXMProps {
1072
1105
  }
1073
1106
  declare const ConnectedXM: ({ organizationId, apiUrl, token, executeAs, locale, children, }: ConnectedXMProps) => React.JSX.Element;
1074
1107
 
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 };
1108
+ export { type Account, type AccountShare, type AccountTier, AccountType, type Activity, type Advertisement, type AdvertisementClick, AdvertisementType, type AdvertisementView, type Announcement, AppendInfiniteQuery$1 as 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$1 as 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$1 as GetErrorMessage, type Image, ImageType, type Instance, type Integrations, type Interest, type Lead, type Like, type LinkPreview, type ManagedCoupon, type ManagedCouponOrder, MergeInfinitePages$1 as 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,38 @@ 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 namespace AppendInfiniteQuery$1 {
1067
+ export { AppendInfiniteQuery as default };
1068
+ }
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
+
1080
+ declare namespace CacheIndividualQueries$1 {
1081
+ export { CacheIndividualQueries as default };
1082
+ }
1083
+
1084
+ declare const GetErrorMessage: (error: any, fallback?: string) => string;
1085
+
1086
+ declare namespace GetErrorMessage$1 {
1087
+ export { GetErrorMessage as default };
1088
+ }
1089
+
1090
+ declare function MergeInfinitePages<TData>(data: InfiniteData<ConnectedXMResponse<TData[]>>): TData[];
1091
+
1092
+ declare namespace MergeInfinitePages$1 {
1093
+ export { MergeInfinitePages as default };
1094
+ }
1095
+
1063
1096
  declare const useSetAuthToken: () => (token?: string | undefined) => void;
1064
1097
 
1065
1098
  interface ConnectedXMProps {
@@ -1072,4 +1105,4 @@ interface ConnectedXMProps {
1072
1105
  }
1073
1106
  declare const ConnectedXM: ({ organizationId, apiUrl, token, executeAs, locale, children, }: ConnectedXMProps) => React.JSX.Element;
1074
1107
 
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 };
1108
+ export { type Account, type AccountShare, type AccountTier, AccountType, type Activity, type Advertisement, type AdvertisementClick, AdvertisementType, type AdvertisementView, type Announcement, AppendInfiniteQuery$1 as 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$1 as 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$1 as GetErrorMessage, type Image, ImageType, type Instance, type Integrations, type Interest, type Lead, type Like, type LinkPreview, type ManagedCoupon, type ManagedCouponOrder, MergeInfinitePages$1 as 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_exports;
129
+ },
130
+ CacheIndividualQueries: function() {
131
+ return CacheIndividualQueries_exports;
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_exports;
159
+ },
139
160
  ImageType: function() {
140
161
  return ImageType;
141
162
  },
163
+ MergeInfinitePages: function() {
164
+ return MergeInfinitePages_exports;
165
+ },
142
166
  NotificationType: function() {
143
167
  return NotificationType;
144
168
  },
@@ -510,6 +534,102 @@ 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_exports = {};
539
+ __export(AppendInfiniteQuery_exports, {
540
+ default: function() {
541
+ return AppendInfiniteQuery_default;
542
+ }
543
+ });
544
+ var AppendInfiniteQuery = function(queryClient, key, newData) {
545
+ queryClient.setQueriesData(key, function(data) {
546
+ var _data_pages_, _data_pages;
547
+ 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) {
548
+ var _data_pages_1, _data_pages1, _data_pages__data, _data_pages_2, _data_pages2;
549
+ 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) {
550
+ var _data_pages__data1, _data_pages_3, _data_pages3;
551
+ 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);
552
+ } else {
553
+ data.pages[0].data = [
554
+ newData
555
+ ];
556
+ }
557
+ }
558
+ return data;
559
+ });
560
+ };
561
+ var AppendInfiniteQuery_default = AppendInfiniteQuery;
562
+ // src/utilities/CacheIndividualQueries.ts
563
+ var CacheIndividualQueries_exports = {};
564
+ __export(CacheIndividualQueries_exports, {
565
+ default: function() {
566
+ return CacheIndividualQueries_default;
567
+ }
568
+ });
569
+ var CacheIndividualQueries = function(response, queryClient, queryKeyFn, SET_FUNCTION, itemMap) {
570
+ response.pages.forEach(function(page) {
571
+ page.data.forEach(function(item) {
572
+ item = itemMap ? itemMap(item) : item;
573
+ if (item.id) {
574
+ var SudoResponse = {
575
+ status: page.status,
576
+ message: "Cached From: ".concat(page.message),
577
+ data: item
578
+ };
579
+ SET_FUNCTION(queryClient, queryKeyFn(item.id), SudoResponse);
580
+ if (item.slug) {
581
+ SET_FUNCTION(queryClient, queryKeyFn(item.slug), SudoResponse);
582
+ }
583
+ if (item.username) {
584
+ SET_FUNCTION(queryClient, queryKeyFn(item.username), SudoResponse);
585
+ }
586
+ if (item.code) {
587
+ SET_FUNCTION(queryClient, queryKeyFn(item.code), SudoResponse);
588
+ }
589
+ if (item.name) {
590
+ SET_FUNCTION(queryClient, queryKeyFn(item.name), SudoResponse);
591
+ }
592
+ if (item.alternateId) {
593
+ SET_FUNCTION(queryClient, queryKeyFn(item.alternateId.toString()), SudoResponse);
594
+ }
595
+ }
596
+ });
597
+ });
598
+ };
599
+ var CacheIndividualQueries_default = CacheIndividualQueries;
600
+ // src/utilities/GetErrorMessage.ts
601
+ var GetErrorMessage_exports = {};
602
+ __export(GetErrorMessage_exports, {
603
+ default: function() {
604
+ return GetErrorMessage_default;
605
+ }
606
+ });
607
+ var import_axios = __toESM(require("axios"));
608
+ var GetErrorMessage = function(error) {
609
+ var fallback = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "Something went wrong";
610
+ var message = fallback;
611
+ if (import_axios.default.isAxiosError(error)) {
612
+ var _error_response_data, _error_response;
613
+ 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;
614
+ } else {
615
+ message = error.message;
616
+ }
617
+ return message;
618
+ };
619
+ var GetErrorMessage_default = GetErrorMessage;
620
+ // src/utilities/MergeInfinitePages.ts
621
+ var MergeInfinitePages_exports = {};
622
+ __export(MergeInfinitePages_exports, {
623
+ default: function() {
624
+ return MergeInfinitePages_default;
625
+ }
626
+ });
627
+ function MergeInfinitePages(data) {
628
+ return data.pages.reduce(function(sessions, page) {
629
+ return _to_consumable_array(sessions).concat(_to_consumable_array(page.data));
630
+ }, []);
631
+ }
632
+ var MergeInfinitePages_default = MergeInfinitePages;
513
633
  // src/hooks/useConnectedXM.ts
514
634
  var import_react2 = __toESM(require("react"));
515
635
  // src/Context.ts
@@ -549,6 +669,8 @@ var ConnectedXM = function(param) {
549
669
  0 && (module.exports = {
550
670
  AccountType: AccountType,
551
671
  AdvertisementType: AdvertisementType,
672
+ AppendInfiniteQuery: AppendInfiniteQuery,
673
+ CacheIndividualQueries: CacheIndividualQueries,
552
674
  CommunityAccess: CommunityAccess,
553
675
  CommunityMembershipRole: CommunityMembershipRole,
554
676
  ConnectedXM: ConnectedXM,
@@ -557,7 +679,9 @@ var ConnectedXM = function(param) {
557
679
  Currency: Currency,
558
680
  EventSource: EventSource,
559
681
  EventType: EventType,
682
+ GetErrorMessage: GetErrorMessage,
560
683
  ImageType: ImageType,
684
+ MergeInfinitePages: MergeInfinitePages,
561
685
  NotificationType: NotificationType,
562
686
  PushDeviceAppType: PushDeviceAppType,
563
687
  PushService: PushService,
package/dist/index.mjs CHANGED
@@ -1,3 +1,9 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
1
7
  // src/interfaces.ts
2
8
  var RegistrationStatus = /* @__PURE__ */ ((RegistrationStatus2) => {
3
9
  RegistrationStatus2["registered"] = "registered";
@@ -230,6 +236,98 @@ var isTypeEventActivationCompletion = (eventActivationCompletion) => {
230
236
  return eventActivationCompletion.updatedAt !== void 0;
231
237
  };
232
238
 
239
+ // src/utilities/AppendInfiniteQuery.ts
240
+ var AppendInfiniteQuery_exports = {};
241
+ __export(AppendInfiniteQuery_exports, {
242
+ default: () => AppendInfiniteQuery_default
243
+ });
244
+ var AppendInfiniteQuery = (queryClient, key, newData) => {
245
+ queryClient.setQueriesData(key, (data) => {
246
+ if (data?.pages?.[0]?.data) {
247
+ if (data?.pages?.[0]?.data && data?.pages?.[0]?.data?.length > 0 && newData) {
248
+ data?.pages?.[0]?.data?.unshift(newData);
249
+ } else {
250
+ data.pages[0].data = [newData];
251
+ }
252
+ }
253
+ return data;
254
+ });
255
+ };
256
+ var AppendInfiniteQuery_default = AppendInfiniteQuery;
257
+
258
+ // src/utilities/CacheIndividualQueries.ts
259
+ var CacheIndividualQueries_exports = {};
260
+ __export(CacheIndividualQueries_exports, {
261
+ default: () => CacheIndividualQueries_default
262
+ });
263
+ var CacheIndividualQueries = (response, queryClient, queryKeyFn, SET_FUNCTION, itemMap) => {
264
+ response.pages.forEach((page) => {
265
+ page.data.forEach((item) => {
266
+ item = itemMap ? itemMap(item) : item;
267
+ if (item.id) {
268
+ const SudoResponse = {
269
+ status: page.status,
270
+ message: `Cached From: ${page.message}`,
271
+ data: item
272
+ };
273
+ SET_FUNCTION(queryClient, queryKeyFn(item.id), SudoResponse);
274
+ if (item.slug) {
275
+ SET_FUNCTION(queryClient, queryKeyFn(item.slug), SudoResponse);
276
+ }
277
+ if (item.username) {
278
+ SET_FUNCTION(queryClient, queryKeyFn(item.username), SudoResponse);
279
+ }
280
+ if (item.code) {
281
+ SET_FUNCTION(queryClient, queryKeyFn(item.code), SudoResponse);
282
+ }
283
+ if (item.name) {
284
+ SET_FUNCTION(queryClient, queryKeyFn(item.name), SudoResponse);
285
+ }
286
+ if (item.alternateId) {
287
+ SET_FUNCTION(
288
+ queryClient,
289
+ queryKeyFn(item.alternateId.toString()),
290
+ SudoResponse
291
+ );
292
+ }
293
+ }
294
+ });
295
+ });
296
+ };
297
+ var CacheIndividualQueries_default = CacheIndividualQueries;
298
+
299
+ // src/utilities/GetErrorMessage.ts
300
+ var GetErrorMessage_exports = {};
301
+ __export(GetErrorMessage_exports, {
302
+ default: () => GetErrorMessage_default
303
+ });
304
+ import axios from "axios";
305
+ var GetErrorMessage = (error, fallback = "Something went wrong") => {
306
+ let message = fallback;
307
+ if (axios.isAxiosError(error)) {
308
+ message = error.response?.data?.message || message;
309
+ } else {
310
+ message = error.message;
311
+ }
312
+ return message;
313
+ };
314
+ var GetErrorMessage_default = GetErrorMessage;
315
+
316
+ // src/utilities/MergeInfinitePages.ts
317
+ var MergeInfinitePages_exports = {};
318
+ __export(MergeInfinitePages_exports, {
319
+ default: () => MergeInfinitePages_default
320
+ });
321
+ function MergeInfinitePages(data) {
322
+ return data.pages.reduce(
323
+ (sessions, page) => {
324
+ return [...sessions, ...page.data];
325
+ },
326
+ []
327
+ );
328
+ }
329
+ var MergeInfinitePages_default = MergeInfinitePages;
330
+
233
331
  // src/hooks/useConnectedXM.ts
234
332
  import React2 from "react";
235
333
 
@@ -282,6 +380,8 @@ var ConnectedXM = ({
282
380
  export {
283
381
  AccountType,
284
382
  AdvertisementType,
383
+ AppendInfiniteQuery_exports as AppendInfiniteQuery,
384
+ CacheIndividualQueries_exports as CacheIndividualQueries,
285
385
  CommunityAccess,
286
386
  CommunityMembershipRole,
287
387
  ConnectedXM,
@@ -290,7 +390,9 @@ export {
290
390
  Currency,
291
391
  EventSource,
292
392
  EventType,
393
+ GetErrorMessage_exports as GetErrorMessage,
293
394
  ImageType,
395
+ MergeInfinitePages_exports as MergeInfinitePages,
294
396
  NotificationType,
295
397
  PushDeviceAppType,
296
398
  PushService,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connectedxm/client",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Client API javascript SDK",
5
5
  "author": "ConnectedXM Inc.",
6
6
  "license": "MIT",