@connectedxm/client 0.0.4 → 0.0.55

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.mjs DELETED
@@ -1,442 +0,0 @@
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
-
7
- // src/interfaces.ts
8
- var RegistrationStatus = /* @__PURE__ */ ((RegistrationStatus2) => {
9
- RegistrationStatus2["registered"] = "registered";
10
- RegistrationStatus2["checkedIn"] = "checkedIn";
11
- RegistrationStatus2["checkedOut"] = "checkedOut";
12
- RegistrationStatus2["waitlisted"] = "waitlisted";
13
- RegistrationStatus2["cancelled"] = "cancelled";
14
- RegistrationStatus2["transferred"] = "transferred";
15
- RegistrationStatus2["invited"] = "invited";
16
- RegistrationStatus2["rejected"] = "rejected";
17
- RegistrationStatus2["draft"] = "draft";
18
- return RegistrationStatus2;
19
- })(RegistrationStatus || {});
20
- var ImageType = /* @__PURE__ */ ((ImageType2) => {
21
- ImageType2["admin"] = "admin";
22
- ImageType2["people"] = "people";
23
- ImageType2["activity"] = "activity";
24
- ImageType2["banner"] = "banner";
25
- return ImageType2;
26
- })(ImageType || {});
27
- var isTypeImage = (image) => {
28
- return image.name !== void 0;
29
- };
30
- var isTypeIntegrations = (integrations) => {
31
- return integrations.ghost !== void 0;
32
- };
33
- var Currency = /* @__PURE__ */ ((Currency2) => {
34
- Currency2["USD"] = "USD";
35
- return Currency2;
36
- })(Currency || {});
37
- var isTypeOrganization = (organization) => {
38
- return organization.email !== void 0;
39
- };
40
- var isTypeAccountTier = (accountTier) => {
41
- return accountTier.description !== void 0;
42
- };
43
- var AccountType = /* @__PURE__ */ ((AccountType2) => {
44
- AccountType2["account"] = "account";
45
- AccountType2["team"] = "team";
46
- return AccountType2;
47
- })(AccountType || {});
48
- var isTypeAccount = (account) => {
49
- return account._count !== void 0;
50
- };
51
- var isSelf = (account) => {
52
- return account.email !== void 0;
53
- };
54
- var isTypeActivity = (activity) => {
55
- return activity._count !== void 0;
56
- };
57
- var CommunityAccess = /* @__PURE__ */ ((CommunityAccess2) => {
58
- CommunityAccess2["public"] = "public";
59
- CommunityAccess2["private"] = "private";
60
- return CommunityAccess2;
61
- })(CommunityAccess || {});
62
- var isTypeCommunity = (community) => {
63
- return community._count !== void 0;
64
- };
65
- var EventSource = /* @__PURE__ */ ((EventSource2) => {
66
- EventSource2["admin"] = "admin";
67
- EventSource2["moderator"] = "moderator";
68
- EventSource2["account"] = "account";
69
- return EventSource2;
70
- })(EventSource || {});
71
- var EventType = /* @__PURE__ */ ((EventType2) => {
72
- EventType2["physical"] = "physical";
73
- EventType2["virtual"] = "virtual";
74
- EventType2["hybrid"] = "hybrid";
75
- return EventType2;
76
- })(EventType || {});
77
- var isTypeEvent = (event) => {
78
- return event._count !== void 0;
79
- };
80
- var RegistrationQuestionType = /* @__PURE__ */ ((RegistrationQuestionType2) => {
81
- RegistrationQuestionType2["text"] = "text";
82
- RegistrationQuestionType2["textarea"] = "textarea";
83
- RegistrationQuestionType2["number"] = "number";
84
- RegistrationQuestionType2["time"] = "time";
85
- RegistrationQuestionType2["date"] = "date";
86
- RegistrationQuestionType2["toggle"] = "toggle";
87
- RegistrationQuestionType2["select"] = "select";
88
- RegistrationQuestionType2["radio"] = "radio";
89
- RegistrationQuestionType2["checkbox"] = "checkbox";
90
- RegistrationQuestionType2["search"] = "search";
91
- return RegistrationQuestionType2;
92
- })(RegistrationQuestionType || {});
93
- var isListing = (event) => {
94
- return event.newActivityCreatorEmailNotification !== void 0;
95
- };
96
- var TicketVisibility = /* @__PURE__ */ ((TicketVisibility2) => {
97
- TicketVisibility2["public"] = "public";
98
- TicketVisibility2["private"] = "private";
99
- return TicketVisibility2;
100
- })(TicketVisibility || {});
101
- var TicketEventAccessLevel = /* @__PURE__ */ ((TicketEventAccessLevel2) => {
102
- TicketEventAccessLevel2["regular"] = "regular";
103
- TicketEventAccessLevel2["virtual"] = "virtual";
104
- TicketEventAccessLevel2["vip"] = "vip";
105
- return TicketEventAccessLevel2;
106
- })(TicketEventAccessLevel || {});
107
- var isTypeTicket = (ticket) => {
108
- return ticket.visibility !== void 0;
109
- };
110
- var isTypePurchase = (purchase) => {
111
- return purchase.createdAt !== void 0;
112
- };
113
- var isTypeTransfer = (transfer) => {
114
- return transfer.createdAt !== void 0;
115
- };
116
- var NotificationType = /* @__PURE__ */ ((NotificationType2) => {
117
- NotificationType2["ANNOUNCEMENT"] = "ANNOUNCEMENT";
118
- NotificationType2["FOLLOW"] = "FOLLOW";
119
- NotificationType2["INVITATION"] = "INVITATION";
120
- NotificationType2["TRANSFER"] = "TRANSFER";
121
- NotificationType2["LIKE"] = "LIKE";
122
- NotificationType2["COMMENT"] = "COMMENT";
123
- NotificationType2["RESHARE"] = "RESHARE";
124
- NotificationType2["EVENT"] = "EVENT";
125
- NotificationType2["ACTIVITY"] = "ACTIVITY";
126
- return NotificationType2;
127
- })(NotificationType || {});
128
- var isTypeNotification = (notification) => {
129
- return notification.createdAt !== void 0;
130
- };
131
- var CouponType = /* @__PURE__ */ ((CouponType2) => {
132
- CouponType2["order"] = "order";
133
- CouponType2["ticket"] = "ticket";
134
- return CouponType2;
135
- })(CouponType || {});
136
- var isTypeCoupon = (coupon) => {
137
- return coupon.description !== void 0;
138
- };
139
- var isManagedCoupon = (coupon) => {
140
- return coupon.active !== void 0;
141
- };
142
- var isTypeInstance = (instance) => {
143
- return instance.coupon !== void 0;
144
- };
145
- var isTypeTrack = (track) => {
146
- return track.description !== void 0;
147
- };
148
- var isTypeSpeaker = (speaker) => {
149
- return speaker.website !== void 0;
150
- };
151
- var isTypeSession = (session) => {
152
- return session.longDescription !== void 0;
153
- };
154
- var isTypeEventPage = (page) => {
155
- return page.html !== void 0;
156
- };
157
- var isTypeScan = (scan) => {
158
- return scan.createdAt !== void 0;
159
- };
160
- var isTypeSponsorshipLevel = (sponsorshipLevel) => {
161
- return sponsorshipLevel.description !== void 0;
162
- };
163
- var isTypeFaq = (faq) => {
164
- return faq.section !== void 0;
165
- };
166
- var isTypeFaqSection = (faqSection) => {
167
- return faqSection.faqs !== void 0;
168
- };
169
- var SupportTicketType = /* @__PURE__ */ ((SupportTicketType2) => {
170
- SupportTicketType2["support"] = "support";
171
- SupportTicketType2["inquiry"] = "inquiry";
172
- return SupportTicketType2;
173
- })(SupportTicketType || {});
174
- var isTypeSupportTicket = (supportTicket) => {
175
- return supportTicket.email !== void 0;
176
- };
177
- var isTypeSupportTicketNote = (supportTicketNote) => {
178
- return supportTicketNote.createdAt !== void 0;
179
- };
180
- var AdvertisementType = /* @__PURE__ */ ((AdvertisementType2) => {
181
- AdvertisementType2["square"] = "square";
182
- AdvertisementType2["rectangle"] = "rectangle";
183
- return AdvertisementType2;
184
- })(AdvertisementType || {});
185
- var isTypeAdvertisement = (advertisement) => {
186
- return advertisement.title !== void 0;
187
- };
188
- var isTypeTeamMember = (teamMember) => {
189
- return teamMember.email !== void 0;
190
- };
191
- var CommunityMembershipRole = /* @__PURE__ */ ((CommunityMembershipRole2) => {
192
- CommunityMembershipRole2["member"] = "member";
193
- CommunityMembershipRole2["moderator"] = "moderator";
194
- return CommunityMembershipRole2;
195
- })(CommunityMembershipRole || {});
196
- var isTypeCommunityMembership = (communityMembership) => {
197
- return communityMembership.createdAt !== void 0;
198
- };
199
- var ContentTypeFormat = /* @__PURE__ */ ((ContentTypeFormat2) => {
200
- ContentTypeFormat2["article"] = "article";
201
- ContentTypeFormat2["podcast"] = "podcast";
202
- ContentTypeFormat2["video"] = "video";
203
- return ContentTypeFormat2;
204
- })(ContentTypeFormat || {});
205
- var isTypeContentType = (contentType) => {
206
- return contentType.priority !== void 0;
207
- };
208
- var isTypeContent = (content) => {
209
- return content.body !== void 0;
210
- };
211
- var isTypeLead = (lead) => {
212
- return lead.email !== void 0;
213
- };
214
- var PushDeviceAppType = /* @__PURE__ */ ((PushDeviceAppType2) => {
215
- PushDeviceAppType2["EVENTXM"] = "EVENTXM";
216
- PushDeviceAppType2["COMMUNITYXM"] = "COMMUNITYXM";
217
- return PushDeviceAppType2;
218
- })(PushDeviceAppType || {});
219
- var PushService = /* @__PURE__ */ ((PushService2) => {
220
- PushService2["apn"] = "apn";
221
- PushService2["firebase"] = "firebase";
222
- PushService2["huawei"] = "huawei";
223
- PushService2["xiaomi"] = "xiaomi";
224
- return PushService2;
225
- })(PushService || {});
226
- var isTypeAnnouncement = (announcement) => {
227
- return announcement.updatedAt !== void 0;
228
- };
229
- var isTypeBenefit = (benefit) => {
230
- return benefit.createdAt !== void 0;
231
- };
232
- var isTypeEventActivation = (eventActivation) => {
233
- return eventActivation.createdAt !== void 0;
234
- };
235
- var isTypeEventActivationCompletion = (eventActivationCompletion) => {
236
- return eventActivationCompletion.updatedAt !== void 0;
237
- };
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
-
331
- // src/hooks/useConnectedXM.ts
332
- import React2 from "react";
333
-
334
- // src/Context.ts
335
- import React from "react";
336
- var Context = React.createContext({});
337
- var Context_default = Context;
338
-
339
- // src/hooks/useConnectedXM.ts
340
- var useConnectedXM = () => {
341
- const context = React2.useContext(Context_default);
342
- if (!context) {
343
- throw new Error("useConnectedXM must be used within a ConnectedXMProvider");
344
- }
345
- return context;
346
- };
347
-
348
- // src/hooks/useSetAuthToken.ts
349
- var useSetAuthToken = () => {
350
- const { setAuthToken } = useConnectedXM();
351
- return setAuthToken;
352
- };
353
-
354
- // src/ConnectedXM.tsx
355
- import React3 from "react";
356
- var ConnectedXM = ({
357
- organizationId,
358
- apiUrl = "https://api.connectedxm.app",
359
- token,
360
- executeAs,
361
- locale = "en",
362
- children
363
- }) => {
364
- const [authToken, setAuthToken] = React3.useState(token);
365
- return /* @__PURE__ */ React3.createElement(
366
- Context_default.Provider,
367
- {
368
- value: {
369
- organizationId,
370
- apiUrl,
371
- token: authToken,
372
- setAuthToken,
373
- executeAs,
374
- locale
375
- }
376
- },
377
- children
378
- );
379
- };
380
- export {
381
- AccountType,
382
- AdvertisementType,
383
- AppendInfiniteQuery_exports as AppendInfiniteQuery,
384
- CacheIndividualQueries_exports as CacheIndividualQueries,
385
- CommunityAccess,
386
- CommunityMembershipRole,
387
- ConnectedXM,
388
- ContentTypeFormat,
389
- CouponType,
390
- Currency,
391
- EventSource,
392
- EventType,
393
- GetErrorMessage_exports as GetErrorMessage,
394
- ImageType,
395
- MergeInfinitePages_exports as MergeInfinitePages,
396
- NotificationType,
397
- PushDeviceAppType,
398
- PushService,
399
- RegistrationQuestionType,
400
- RegistrationStatus,
401
- SupportTicketType,
402
- TicketEventAccessLevel,
403
- TicketVisibility,
404
- isListing,
405
- isManagedCoupon,
406
- isSelf,
407
- isTypeAccount,
408
- isTypeAccountTier,
409
- isTypeActivity,
410
- isTypeAdvertisement,
411
- isTypeAnnouncement,
412
- isTypeBenefit,
413
- isTypeCommunity,
414
- isTypeCommunityMembership,
415
- isTypeContent,
416
- isTypeContentType,
417
- isTypeCoupon,
418
- isTypeEvent,
419
- isTypeEventActivation,
420
- isTypeEventActivationCompletion,
421
- isTypeEventPage,
422
- isTypeFaq,
423
- isTypeFaqSection,
424
- isTypeImage,
425
- isTypeInstance,
426
- isTypeIntegrations,
427
- isTypeLead,
428
- isTypeNotification,
429
- isTypeOrganization,
430
- isTypePurchase,
431
- isTypeScan,
432
- isTypeSession,
433
- isTypeSpeaker,
434
- isTypeSponsorshipLevel,
435
- isTypeSupportTicket,
436
- isTypeSupportTicketNote,
437
- isTypeTeamMember,
438
- isTypeTicket,
439
- isTypeTrack,
440
- isTypeTransfer,
441
- useSetAuthToken
442
- };