@getmicdrop/venue-calendar 3.3.1 → 3.3.3

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.
Files changed (50) hide show
  1. package/dist/{VenueCalendar-Xppig0q_.js → VenueCalendar-qwLPhCFH.js} +2698 -2693
  2. package/dist/VenueCalendar-qwLPhCFH.js.map +1 -0
  3. package/dist/api/api.cjs +2 -0
  4. package/dist/api/api.cjs.map +1 -0
  5. package/dist/api/api.mjs +787 -0
  6. package/dist/api/api.mjs.map +1 -0
  7. package/dist/api/client.d.ts +46 -0
  8. package/dist/api/events.d.ts +102 -0
  9. package/dist/api/index.d.ts +38 -0
  10. package/dist/api/orders.d.ts +104 -0
  11. package/dist/api/promo.d.ts +45 -0
  12. package/dist/api/transformers/event.d.ts +86 -0
  13. package/dist/api/transformers/index.d.ts +9 -0
  14. package/dist/api/transformers/order.d.ts +105 -0
  15. package/dist/api/transformers/venue.d.ts +48 -0
  16. package/dist/api/venues.d.ts +33 -0
  17. package/dist/{index-BjErG0CG.js → index-TUrDiCfO.js} +2 -2
  18. package/dist/{index-BjErG0CG.js.map → index-TUrDiCfO.js.map} +1 -1
  19. package/dist/venue-calendar.css +1 -1
  20. package/dist/venue-calendar.es.js +1 -1
  21. package/dist/venue-calendar.iife.js +14 -14
  22. package/dist/venue-calendar.iife.js.map +1 -1
  23. package/dist/venue-calendar.umd.js +14 -14
  24. package/dist/venue-calendar.umd.js.map +1 -1
  25. package/package.json +96 -94
  26. package/dist/VenueCalendar-Xppig0q_.js.map +0 -1
  27. package/src/lib/api/client.ts +0 -210
  28. package/src/lib/api/events.ts +0 -358
  29. package/src/lib/api/index.ts +0 -182
  30. package/src/lib/api/orders.ts +0 -390
  31. package/src/lib/api/promo.ts +0 -164
  32. package/src/lib/api/transformers/event.ts +0 -248
  33. package/src/lib/api/transformers/index.ts +0 -29
  34. package/src/lib/api/transformers/order.ts +0 -207
  35. package/src/lib/api/transformers/venue.ts +0 -118
  36. package/src/lib/api/venues.ts +0 -100
  37. package/src/lib/utils/api.js +0 -790
  38. package/src/lib/utils/api.test.js +0 -1284
  39. package/src/lib/utils/constants.js +0 -8
  40. package/src/lib/utils/constants.test.js +0 -39
  41. package/src/lib/utils/datetime.js +0 -266
  42. package/src/lib/utils/datetime.test.js +0 -340
  43. package/src/lib/utils/event-transform.js +0 -464
  44. package/src/lib/utils/event-transform.test.js +0 -413
  45. package/src/lib/utils/logger.js +0 -105
  46. package/src/lib/utils/timezone.js +0 -109
  47. package/src/lib/utils/timezone.test.js +0 -222
  48. package/src/lib/utils/utils.js +0 -806
  49. package/src/lib/utils/utils.test.js +0 -959
  50. /package/{src/lib/api/types.ts → dist/api/types.d.ts} +0 -0
@@ -1,182 +0,0 @@
1
- /**
2
- * MicDrop Public Checkout API
3
- *
4
- * This module provides a complete API layer for the public checkout flow:
5
- * - Order creation and management
6
- * - Payment processing with Stripe
7
- * - Promo code validation
8
- * - Event and venue data fetching
9
- * - Session management
10
- *
11
- * All endpoints are public (no authentication required) and use
12
- * the /api/v2/public base path.
13
- *
14
- * @example
15
- * ```typescript
16
- * import {
17
- * createPaymentIntent,
18
- * validatePromoCode,
19
- * transformOrder,
20
- * } from '@getmicdrop/venue-calendar/api';
21
- *
22
- * // Create payment intent
23
- * const intent = await createPaymentIntent(cartId, { 123: 2 });
24
- *
25
- * // Validate promo code
26
- * const promo = await validatePromoCode(eventId, 'DISCOUNT10');
27
- *
28
- * // Transform order for display
29
- * const order = transformOrder(apiResponse);
30
- * ```
31
- */
32
-
33
- // ============================================================================
34
- // Client Configuration
35
- // ============================================================================
36
-
37
- export {
38
- configureApi,
39
- getApiConfig,
40
- getPublicBaseUrl,
41
- getLegacyPublicUrl,
42
- getOrdersPublicUrl,
43
- getClientIP,
44
- apiGet,
45
- apiPost,
46
- apiPut,
47
- apiDelete,
48
- } from './client.js';
49
-
50
- // ============================================================================
51
- // Orders API
52
- // ============================================================================
53
-
54
- export {
55
- // Payment
56
- createPaymentIntent,
57
- validatePaymentIntent,
58
-
59
- // Order lifecycle
60
- createOrder,
61
- getOrder,
62
- completeReservation,
63
- cancelReservation,
64
-
65
- // Session management
66
- extendCheckoutSession,
67
- getSessionStatus,
68
-
69
- // Legacy aliases (for micdrop-frontend compatibility)
70
- initiateOrder,
71
- trackUTMSource,
72
- } from './orders.js';
73
-
74
- // ============================================================================
75
- // Promo Codes API
76
- // ============================================================================
77
-
78
- export {
79
- validatePromoCode,
80
- hasPromoCodes,
81
- applyPromoCode,
82
- removePromoCode,
83
- } from './promo.js';
84
-
85
- // ============================================================================
86
- // Events API
87
- // ============================================================================
88
-
89
- export {
90
- fetchEventDetails,
91
- fetchEventTickets,
92
- fetchEventPerformers,
93
- fetchAllVenues,
94
- fetchVenueEvents,
95
- getMonthEvents,
96
- getOrgMonthEvents,
97
- getSeriesOccurrences,
98
- fetchSeriesOccurrences,
99
- checkEventPassword,
100
- testNetworkConnection,
101
- } from './events.js';
102
-
103
- // ============================================================================
104
- // Venues API
105
- // ============================================================================
106
-
107
- export {
108
- getVenue,
109
- getVenueFees,
110
- getVenueBySlug,
111
- } from './venues.js';
112
-
113
- // ============================================================================
114
- // Transformers
115
- // ============================================================================
116
-
117
- export {
118
- // Order
119
- transformOrder,
120
- transformTicket,
121
- transformOrderForDisplay,
122
-
123
- // Event
124
- transformEvent,
125
- transformEventData,
126
- transformAvailableTicket,
127
- getCDNImageUrl,
128
- getEventImageUrl,
129
- calculateCtaState,
130
-
131
- // Venue
132
- transformVenue,
133
- extractVenueFees,
134
- formatVenueAddress,
135
- } from './transformers/index.js';
136
-
137
- // ============================================================================
138
- // Types
139
- // ============================================================================
140
-
141
- export type {
142
- // API Configuration
143
- ApiConfig,
144
- ApiResponse,
145
-
146
- // Orders & Payment
147
- PaymentIntentRequest,
148
- PaymentIntentResponse,
149
- CompleteReservationResponse,
150
- CancelReservationResponse,
151
- CreateOrderRequest,
152
- CreateOrderResponse,
153
- ValidatePaymentRequest,
154
- ValidatePaymentResponse,
155
- AttendeeInfo,
156
-
157
- // Session
158
- ExtendSessionRequest,
159
- ExtendSessionResponse,
160
- SessionStatus,
161
-
162
- // Promo
163
- PromoValidationResponse,
164
- HasPromoCodesResponse,
165
-
166
- // Orders
167
- Order,
168
- PurchasedTicket,
169
-
170
- // Events
171
- Event,
172
- AvailableTicket,
173
- EventPerformersResponse,
174
- Performer,
175
-
176
- // Venues
177
- Venue,
178
-
179
- // Series
180
- SeriesOccurrence,
181
- SeriesOccurrencesResponse,
182
- } from './types.js';
@@ -1,390 +0,0 @@
1
- /**
2
- * Orders API
3
- *
4
- * Functions for managing orders, payments, and reservations
5
- * in the public checkout flow.
6
- */
7
-
8
- import { logger } from '../utils/logger.js';
9
- import {
10
- getPublicBaseUrl,
11
- getLegacyPublicUrl,
12
- getOrdersPublicUrl,
13
- getClientIP,
14
- simpleFetch,
15
- } from './client.js';
16
- import type {
17
- PaymentIntentResponse,
18
- CompleteReservationResponse,
19
- CancelReservationResponse,
20
- CreateOrderResponse,
21
- ValidatePaymentRequest,
22
- ValidatePaymentResponse,
23
- ExtendSessionResponse,
24
- SessionStatus,
25
- Order,
26
- } from './types.js';
27
-
28
- /**
29
- * Create a payment intent for the cart
30
- *
31
- * This initiates the Stripe payment flow by creating a PaymentIntent
32
- * on the backend. The response includes the client_secret needed
33
- * for Stripe Elements.
34
- *
35
- * @param cartId - The cart/order UUID
36
- * @param quantities - Map of ticketId -> quantity
37
- * @returns Payment intent data including client_secret, or null on error
38
- */
39
- export async function createPaymentIntent(
40
- cartId: string,
41
- quantities: Record<string | number, number>
42
- ): Promise<PaymentIntentResponse | null> {
43
- try {
44
- // Uses /api/orders/public/cart/:uuid/payment-intent (same as micdrop-frontend)
45
- const response = await fetch(
46
- `${getOrdersPublicUrl()}/cart/${cartId}/payment-intent`,
47
- {
48
- method: 'POST',
49
- headers: {
50
- 'Content-Type': 'application/json',
51
- },
52
- credentials: 'include',
53
- body: JSON.stringify({
54
- productQuantities: quantities,
55
- }),
56
- }
57
- );
58
-
59
- if (!response.ok) {
60
- const errorData = await response.json().catch(() => ({}));
61
- logger.error('Payment intent creation failed:', errorData);
62
- throw new Error(errorData.error || 'Failed to create payment intent');
63
- }
64
-
65
- const data = await response.json();
66
- logger.debug('Payment intent created:', data);
67
- return data;
68
- } catch (error) {
69
- logger.error('createPaymentIntent error:', error);
70
- return null;
71
- }
72
- }
73
-
74
- /**
75
- * Complete reservation after successful payment
76
- *
77
- * Called after Stripe confirms the payment to finalize the order
78
- * and generate tickets.
79
- *
80
- * @param orderUuid - The order UUID
81
- * @returns Success status and message
82
- */
83
- export async function completeReservation(
84
- orderUuid: string
85
- ): Promise<CompleteReservationResponse> {
86
- try {
87
- const response = await fetch(
88
- `${getPublicBaseUrl()}/orders/complete/${orderUuid}`,
89
- {
90
- method: 'POST',
91
- headers: {
92
- 'Content-Type': 'application/json',
93
- },
94
- }
95
- );
96
-
97
- if (!response.ok) {
98
- const errorData = await response.json().catch(() => ({}));
99
- return {
100
- success: false,
101
- error: errorData.error || 'Failed to complete reservation',
102
- };
103
- }
104
-
105
- const result = await response.json();
106
- return {
107
- success: true,
108
- message: result.message,
109
- };
110
- } catch (error) {
111
- logger.error('Error completing reservation:', error);
112
- return { success: false, error: 'Network error completing reservation' };
113
- }
114
- }
115
-
116
- /**
117
- * Cancel reservation and release tickets back to inventory
118
- *
119
- * Called when user abandons checkout or session expires.
120
- *
121
- * @param orderUuid - The order UUID
122
- * @returns Success status and message
123
- */
124
- export async function cancelReservation(
125
- orderUuid: string
126
- ): Promise<CancelReservationResponse> {
127
- try {
128
- const response = await fetch(
129
- `${getPublicBaseUrl()}/orders/cancel/${orderUuid}`,
130
- {
131
- method: 'POST',
132
- headers: {
133
- 'Content-Type': 'application/json',
134
- },
135
- }
136
- );
137
-
138
- if (!response.ok) {
139
- const errorData = await response.json().catch(() => ({}));
140
- return {
141
- success: false,
142
- error: errorData.error || 'Failed to cancel reservation',
143
- };
144
- }
145
-
146
- const result = await response.json();
147
- return {
148
- success: true,
149
- message: result.message,
150
- };
151
- } catch (error) {
152
- logger.error('Error cancelling reservation:', error);
153
- return { success: false, error: 'Network error cancelling reservation' };
154
- }
155
- }
156
-
157
- /**
158
- * Create a new order/cart
159
- *
160
- * This creates an empty order that can be used for checkout.
161
- * The order UUID is used for all subsequent operations.
162
- *
163
- * @param eventId - The event ID
164
- * @param promoCode - Optional promo code to apply
165
- * @returns The order UUID, or null on error
166
- */
167
- export async function createOrder(
168
- eventId: string | number,
169
- promoCode?: string
170
- ): Promise<CreateOrderResponse | null> {
171
- try {
172
- // Uses /api/public/createOrder (same as micdrop-frontend)
173
- const response = await fetch(`${getLegacyPublicUrl()}/createOrder`, {
174
- method: 'POST',
175
- headers: {
176
- 'Content-Type': 'application/json',
177
- },
178
- body: JSON.stringify({
179
- eventID: eventId,
180
- promoCode,
181
- }),
182
- });
183
-
184
- if (!response.ok) {
185
- const errorData = await response.json().catch(() => ({}));
186
- logger.error('Create order failed:', errorData);
187
- return null;
188
- }
189
-
190
- return response.json();
191
- } catch (error) {
192
- logger.error('createOrder error:', error);
193
- return null;
194
- }
195
- }
196
-
197
- /**
198
- * Get order details (public, no auth required)
199
- *
200
- * Fetches the order details for displaying on the success page.
201
- *
202
- * @param orderId - The order UUID or ID
203
- * @returns The order details, or null on error
204
- */
205
- export async function getOrder(orderId: string): Promise<Order | null> {
206
- // Uses /api/public/getOrder/:id (same as micdrop-frontend)
207
- return simpleFetch<Order>(`${getLegacyPublicUrl()}/getOrder/${orderId}`);
208
- }
209
-
210
- /**
211
- * Validate payment intent and complete the order
212
- *
213
- * This is an alternative to completeReservation that accepts
214
- * additional payment details. Used by micdrop-frontend.
215
- *
216
- * @param cartId - The cart/order UUID
217
- * @param payload - Payment validation payload
218
- * @returns Validation result
219
- */
220
- export async function validatePaymentIntent(
221
- cartId: string,
222
- payload: ValidatePaymentRequest
223
- ): Promise<ValidatePaymentResponse | null> {
224
- try {
225
- // Uses /api/public/validatePaymentIntent/:id (same as micdrop-frontend)
226
- const response = await fetch(
227
- `${getLegacyPublicUrl()}/validatePaymentIntent/${cartId}`,
228
- {
229
- method: 'POST',
230
- headers: {
231
- 'Content-Type': 'application/json',
232
- },
233
- body: JSON.stringify(payload),
234
- }
235
- );
236
-
237
- if (!response.ok) {
238
- const errorData = await response.json().catch(() => ({}));
239
- logger.error('Payment validation failed:', errorData);
240
- return {
241
- success: false,
242
- status: 'failed',
243
- error: errorData.error || 'Payment validation failed',
244
- };
245
- }
246
-
247
- const result = await response.json();
248
- return {
249
- success: true,
250
- status: result.status || 'Payment succeeded',
251
- orderUUID: result.orderUUID || result.uuid,
252
- };
253
- } catch (error) {
254
- logger.error('validatePaymentIntent error:', error);
255
- return null;
256
- }
257
- }
258
-
259
- /**
260
- * Extend the checkout session by 15 minutes
261
- *
262
- * Users get a limited number of extensions (typically 2-3).
263
- *
264
- * @param orderUuid - The order UUID
265
- * @returns Extension result with new expiry time
266
- */
267
- export async function extendCheckoutSession(
268
- orderUuid: string
269
- ): Promise<ExtendSessionResponse> {
270
- try {
271
- const response = await fetch(`${getPublicBaseUrl()}/orders/extend-session`, {
272
- method: 'POST',
273
- headers: {
274
- 'Content-Type': 'application/json',
275
- },
276
- body: JSON.stringify({ orderUuid }),
277
- });
278
-
279
- if (!response.ok) {
280
- const errorData = await response.json().catch(() => ({}));
281
- return {
282
- success: false,
283
- error: errorData.error || 'Failed to extend session',
284
- };
285
- }
286
-
287
- const result = await response.json();
288
- return {
289
- success: true,
290
- newExpiryTime: result.newExpiryTime,
291
- remainingExtensions: result.remainingExtensions,
292
- };
293
- } catch (error) {
294
- logger.error('Error extending checkout session:', error);
295
- return { success: false, error: 'Network error extending session' };
296
- }
297
- }
298
-
299
- /**
300
- * Get current session status including expiry time
301
- *
302
- * Used to display countdown timer and check if extensions are available.
303
- *
304
- * @param orderUuid - The order UUID
305
- * @returns Session status including expiry time
306
- */
307
- export async function getSessionStatus(orderUuid: string): Promise<SessionStatus> {
308
- try {
309
- const response = await fetch(
310
- `${getPublicBaseUrl()}/orders/session/${orderUuid}`
311
- );
312
-
313
- if (!response.ok) {
314
- const errorData = await response.json().catch(() => ({}));
315
- return { error: errorData.error || 'No active session found' };
316
- }
317
-
318
- const result = await response.json();
319
- return {
320
- expiresAt: result.expiresAt,
321
- extensionCount: result.extensionCount,
322
- remainingExtensions: result.remainingExtensions,
323
- canExtend: result.canExtend,
324
- reservationCount: result.reservationCount,
325
- };
326
- } catch (error) {
327
- logger.error('Error getting session status:', error);
328
- return { error: 'Network error getting session status' };
329
- }
330
- }
331
-
332
- /**
333
- * Initiate a new order (alias for createOrder)
334
- *
335
- * This function provides backwards compatibility with micdrop-frontend.
336
- * It accepts the same parameters as the legacy initiateOrder function.
337
- *
338
- * @param cartData - Object containing eventID and optional quantities/promoCode
339
- * @returns The order UUID, or null on error
340
- */
341
- export async function initiateOrder(
342
- cartData: { eventID: string | number; promoCode?: string; quantities?: Record<string | number, number> } = {} as any
343
- ): Promise<string | null> {
344
- try {
345
- // Uses /api/public/createOrder (same as micdrop-frontend)
346
- const response = await fetch(`${getLegacyPublicUrl()}/createOrder`, {
347
- method: 'POST',
348
- headers: {
349
- 'Content-Type': 'application/json',
350
- },
351
- body: JSON.stringify(cartData),
352
- });
353
-
354
- if (!response.ok) {
355
- const errorData = await response.json().catch(() => ({}));
356
- logger.error('Order initiation failed:', errorData);
357
- return null;
358
- }
359
-
360
- const data = await response.json();
361
- return data.uuid;
362
- } catch (error) {
363
- logger.error('initiateOrder error:', error);
364
- return null;
365
- }
366
- }
367
-
368
- /**
369
- * Track UTM source for analytics
370
- *
371
- * Records the traffic source (utm_source parameter) for marketing analytics.
372
- *
373
- * @param venueId - The venue ID
374
- * @returns Promise that resolves when tracking is complete
375
- */
376
- export async function trackUTMSource(venueId: string | number): Promise<void> {
377
- if (typeof window === 'undefined') return;
378
-
379
- const urlParams = new URLSearchParams(window.location.search);
380
- const utmSource = urlParams.get('utm_source') || 'Direct';
381
-
382
- try {
383
- // Uses /api/public/increment/:venueId/:source (same as micdrop-frontend)
384
- await fetch(
385
- `${getLegacyPublicUrl()}/increment/${venueId}/${encodeURIComponent(utmSource)}`
386
- );
387
- } catch (error) {
388
- logger.error('UTM tracking failed:', error);
389
- }
390
- }