@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,210 +0,0 @@
1
- /**
2
- * API Client for MicDrop Public Checkout API
3
- *
4
- * Provides a centralized HTTP client with:
5
- * - Configurable base URL
6
- * - Error handling and logging
7
- * - Request/response typing
8
- * - IP address capture for payment intents
9
- */
10
-
11
- import { logger } from '../utils/logger.js';
12
- import type { ApiConfig, ApiResponse } from './types.js';
13
-
14
- // Default API configuration
15
- const DEFAULT_CONFIG: Required<ApiConfig> = {
16
- baseUrl: 'https://get-micdrop.com',
17
- timeout: 30000,
18
- onError: (error: Error) => logger.error('API Error:', error),
19
- };
20
-
21
- // Global configuration (can be overridden)
22
- let globalConfig: Required<ApiConfig> = { ...DEFAULT_CONFIG };
23
-
24
- /**
25
- * Configure the API client
26
- */
27
- export function configureApi(config: Partial<ApiConfig>): void {
28
- globalConfig = { ...globalConfig, ...config };
29
- }
30
-
31
- /**
32
- * Get the current API configuration
33
- */
34
- export function getApiConfig(): Required<ApiConfig> {
35
- return { ...globalConfig };
36
- }
37
-
38
- /**
39
- * Get the public API base URL for v2 endpoints
40
- */
41
- export function getPublicBaseUrl(): string {
42
- return `${globalConfig.baseUrl}/api/v2/public`;
43
- }
44
-
45
- /**
46
- * Get the legacy public API base URL
47
- */
48
- export function getLegacyPublicUrl(): string {
49
- return `${globalConfig.baseUrl}/api/public`;
50
- }
51
-
52
- /**
53
- * Get the orders API base URL
54
- */
55
- export function getOrdersPublicUrl(): string {
56
- return `${globalConfig.baseUrl}/api/orders/public`;
57
- }
58
-
59
- /**
60
- * Get the user's IP address for payment intents
61
- */
62
- export async function getClientIP(): Promise<string> {
63
- try {
64
- const response = await fetch('https://api.ipify.org?format=json');
65
- const data = await response.json();
66
- return data.ip || '';
67
- } catch (error) {
68
- logger.warn('Could not fetch client IP:', error);
69
- return '';
70
- }
71
- }
72
-
73
- /**
74
- * Make a GET request to the API
75
- */
76
- export async function apiGet<T>(
77
- endpoint: string,
78
- options?: RequestInit
79
- ): Promise<ApiResponse<T>> {
80
- return apiRequest<T>('GET', endpoint, undefined, options);
81
- }
82
-
83
- /**
84
- * Make a POST request to the API
85
- */
86
- export async function apiPost<T>(
87
- endpoint: string,
88
- body?: unknown,
89
- options?: RequestInit
90
- ): Promise<ApiResponse<T>> {
91
- return apiRequest<T>('POST', endpoint, body, options);
92
- }
93
-
94
- /**
95
- * Make a PUT request to the API
96
- */
97
- export async function apiPut<T>(
98
- endpoint: string,
99
- body?: unknown,
100
- options?: RequestInit
101
- ): Promise<ApiResponse<T>> {
102
- return apiRequest<T>('PUT', endpoint, body, options);
103
- }
104
-
105
- /**
106
- * Make a DELETE request to the API
107
- */
108
- export async function apiDelete<T>(
109
- endpoint: string,
110
- options?: RequestInit
111
- ): Promise<ApiResponse<T>> {
112
- return apiRequest<T>('DELETE', endpoint, undefined, options);
113
- }
114
-
115
- /**
116
- * Core API request function
117
- */
118
- async function apiRequest<T>(
119
- method: string,
120
- endpoint: string,
121
- body?: unknown,
122
- options?: RequestInit
123
- ): Promise<ApiResponse<T>> {
124
- const url = endpoint.startsWith('http')
125
- ? endpoint
126
- : `${getPublicBaseUrl()}${endpoint}`;
127
-
128
- const controller = new AbortController();
129
- const timeoutId = setTimeout(() => controller.abort(), globalConfig.timeout);
130
-
131
- try {
132
- const response = await fetch(url, {
133
- method,
134
- headers: {
135
- 'Content-Type': 'application/json',
136
- ...options?.headers,
137
- },
138
- body: body ? JSON.stringify(body) : undefined,
139
- credentials: 'include',
140
- signal: controller.signal,
141
- ...options,
142
- });
143
-
144
- clearTimeout(timeoutId);
145
-
146
- if (!response.ok) {
147
- const errorData = await response.json().catch(() => ({}));
148
- const error = new Error(
149
- errorData.error || errorData.message || `HTTP ${response.status}`
150
- );
151
- globalConfig.onError(error);
152
-
153
- return {
154
- success: false,
155
- error: errorData.error || errorData.message || `HTTP ${response.status}`,
156
- statusCode: response.status,
157
- };
158
- }
159
-
160
- const data = await response.json();
161
- return {
162
- success: true,
163
- data: data as T,
164
- statusCode: response.status,
165
- };
166
- } catch (error) {
167
- clearTimeout(timeoutId);
168
-
169
- const errorMessage =
170
- error instanceof Error
171
- ? error.name === 'AbortError'
172
- ? 'Request timed out'
173
- : error.message
174
- : 'Unknown error';
175
-
176
- globalConfig.onError(error instanceof Error ? error : new Error(errorMessage));
177
-
178
- return {
179
- success: false,
180
- error: errorMessage,
181
- };
182
- }
183
- }
184
-
185
- /**
186
- * Simple fetch wrapper for backwards compatibility
187
- * Returns data directly or null on error
188
- */
189
- export async function simpleFetch<T>(
190
- url: string,
191
- options?: RequestInit
192
- ): Promise<T | null> {
193
- try {
194
- const response = await fetch(url, {
195
- credentials: 'include',
196
- ...options,
197
- });
198
-
199
- if (!response.ok) {
200
- const errorData = await response.json().catch(() => ({}));
201
- logger.error(`API request failed: ${response.status}`, errorData);
202
- return null;
203
- }
204
-
205
- return response.json();
206
- } catch (error) {
207
- logger.error('API request error:', error);
208
- return null;
209
- }
210
- }
@@ -1,358 +0,0 @@
1
- /**
2
- * Events API
3
- *
4
- * Functions for fetching event data, tickets, and performers
5
- * in the public checkout flow.
6
- */
7
-
8
- import { logger } from '../utils/logger.js';
9
- import { getPublicBaseUrl, simpleFetch } from './client.js';
10
- import type {
11
- Event,
12
- AvailableTicket,
13
- EventPerformersResponse,
14
- SeriesOccurrencesResponse,
15
- } from './types.js';
16
-
17
- /**
18
- * Fetch event details
19
- *
20
- * Gets full event information including venue and ticket data.
21
- *
22
- * @param eventId - The event ID
23
- * @param customFetch - Optional custom fetch function (for SSR)
24
- * @returns Event details or null on error
25
- */
26
- export async function fetchEventDetails(
27
- eventId: string | number,
28
- customFetch: typeof fetch = fetch
29
- ): Promise<Event | null> {
30
- try {
31
- const response = await customFetch(`${getPublicBaseUrl()}/events/${eventId}`);
32
-
33
- if (!response.ok) {
34
- throw new Error(`Failed to fetch event details: ${response.status}`);
35
- }
36
-
37
- return response.json();
38
- } catch (error) {
39
- logger.error('Error fetching event details:', error);
40
- return null;
41
- }
42
- }
43
-
44
- /**
45
- * Fetch available tickets for an event
46
- *
47
- * Returns all ticket types that are currently available for sale.
48
- *
49
- * @param eventId - The event ID
50
- * @returns Array of available tickets
51
- */
52
- export async function fetchEventTickets(
53
- eventId: string | number
54
- ): Promise<AvailableTicket[]> {
55
- try {
56
- const response = await fetch(
57
- `${getPublicBaseUrl()}/tickets/event/${eventId}`
58
- );
59
-
60
- if (!response.ok) {
61
- throw new Error(`Failed to fetch tickets: ${response.status}`);
62
- }
63
-
64
- const tickets = await response.json();
65
- return Array.isArray(tickets) ? tickets : [];
66
- } catch (error) {
67
- logger.error('Error fetching tickets:', error);
68
- return [];
69
- }
70
- }
71
-
72
- /**
73
- * Fetch performers for an event
74
- *
75
- * Returns the lineup with pre-resolved avatar URLs.
76
- *
77
- * @param eventId - The event ID
78
- * @returns Performers list and visibility flag
79
- */
80
- export async function fetchEventPerformers(
81
- eventId: string | number
82
- ): Promise<EventPerformersResponse> {
83
- try {
84
- if (!eventId) {
85
- logger.warn('fetchEventPerformers called without eventId');
86
- return { performers: [], showPerformers: false };
87
- }
88
-
89
- const response = await fetch(
90
- `${getPublicBaseUrl()}/events/${eventId}/performers`
91
- );
92
-
93
- if (!response.ok) {
94
- logger.error(
95
- `Failed to fetch performers: ${response.status} ${response.statusText}`
96
- );
97
- return { performers: [], showPerformers: false };
98
- }
99
-
100
- const data = await response.json();
101
- return {
102
- performers: Array.isArray(data.performers) ? data.performers : [],
103
- showPerformers: data.showPerformers === true,
104
- };
105
- } catch (error) {
106
- logger.error('Error fetching event performers:', error);
107
- return { performers: [], showPerformers: false };
108
- }
109
- }
110
-
111
- /**
112
- * Fetch all venues for an organization
113
- *
114
- * @param orgId - The organization ID
115
- * @returns Array of venues
116
- */
117
- export async function fetchAllVenues(orgId: string | number): Promise<any[]> {
118
- try {
119
- if (!orgId) {
120
- logger.warn('fetchAllVenues called without orgId');
121
- return [];
122
- }
123
-
124
- const response = await fetch(
125
- `${getPublicBaseUrl()}/venues/organization/${orgId}`
126
- );
127
-
128
- if (!response.ok) {
129
- logger.error(
130
- `Failed to fetch venues: ${response.status} ${response.statusText}`
131
- );
132
- return [];
133
- }
134
-
135
- const venues = await response.json();
136
- return Array.isArray(venues) ? venues : [];
137
- } catch (error) {
138
- logger.error('Error fetching venues:', error);
139
- return [];
140
- }
141
- }
142
-
143
- /**
144
- * Fetch events for a venue
145
- *
146
- * @param venueId - The venue ID
147
- * @returns Array of events
148
- */
149
- export async function fetchVenueEvents(venueId: string | number): Promise<Event[]> {
150
- try {
151
- if (!venueId) {
152
- logger.warn('fetchVenueEvents called without venueId');
153
- return [];
154
- }
155
-
156
- const response = await fetch(
157
- `${getPublicBaseUrl()}/events/venue/${venueId}`
158
- );
159
-
160
- if (!response.ok) {
161
- logger.error(
162
- `Failed to fetch venue events: ${response.status} ${response.statusText}`
163
- );
164
- return [];
165
- }
166
-
167
- const events = await response.json();
168
- return Array.isArray(events) ? events : [];
169
- } catch (error) {
170
- logger.error('Error fetching venue events:', error);
171
- return [];
172
- }
173
- }
174
-
175
- /**
176
- * Get events for a specific month
177
- *
178
- * Used for calendar views to efficiently load events.
179
- *
180
- * @param venueId - The venue ID
181
- * @param year - The year (e.g., 2024)
182
- * @param month - The month (1-12)
183
- * @returns Array of events for the month
184
- */
185
- export async function getMonthEvents(
186
- venueId: string | number,
187
- year: number,
188
- month: number
189
- ): Promise<Event[]> {
190
- try {
191
- const response = await fetch(
192
- `${getPublicBaseUrl()}/events/venue/${venueId}/month/${year}/${month}`
193
- );
194
-
195
- if (!response.ok) {
196
- logger.error(`Failed to fetch month events: ${response.status}`);
197
- return [];
198
- }
199
-
200
- const data = await response.json();
201
- return Array.isArray(data.events) ? data.events : Array.isArray(data) ? data : [];
202
- } catch (error) {
203
- logger.error('Error fetching month events:', error);
204
- return [];
205
- }
206
- }
207
-
208
- /**
209
- * Get events for an organization for a specific month
210
- *
211
- * @param orgId - The organization ID
212
- * @param year - The year (e.g., 2024)
213
- * @param month - The month (1-12)
214
- * @returns Array of events for the month
215
- */
216
- export async function getOrgMonthEvents(
217
- orgId: string | number,
218
- year: number,
219
- month: number
220
- ): Promise<Event[]> {
221
- try {
222
- const response = await fetch(
223
- `${getPublicBaseUrl()}/events/organization/${orgId}/month/${year}/${month}`
224
- );
225
-
226
- if (!response.ok) {
227
- logger.error(`Failed to fetch org month events: ${response.status}`);
228
- return [];
229
- }
230
-
231
- const data = await response.json();
232
- return Array.isArray(data.events) ? data.events : Array.isArray(data) ? data : [];
233
- } catch (error) {
234
- logger.error('Error fetching org month events:', error);
235
- return [];
236
- }
237
- }
238
-
239
- /**
240
- * Get series occurrences for date selector
241
- *
242
- * Returns all instances of a recurring event series.
243
- *
244
- * @param eventSeriesId - The series ID
245
- * @returns Series occurrences
246
- */
247
- export async function getSeriesOccurrences(
248
- eventSeriesId: number
249
- ): Promise<SeriesOccurrencesResponse | null> {
250
- try {
251
- const response = await fetch(
252
- `${getPublicBaseUrl()}/series/${eventSeriesId}/occurrences`
253
- );
254
-
255
- if (!response.ok) {
256
- logger.error(`Failed to fetch series occurrences: ${response.status}`);
257
- return null;
258
- }
259
-
260
- return response.json();
261
- } catch (error) {
262
- logger.error('Error fetching series occurrences:', error);
263
- return null;
264
- }
265
- }
266
-
267
- /**
268
- * Fetch series occurrences with CTA state
269
- *
270
- * Returns full series data including availability status.
271
- *
272
- * @param eventSeriesId - The series ID
273
- * @param venueId - The venue ID
274
- * @returns Series occurrences with CTA state
275
- */
276
- export async function fetchSeriesOccurrences(
277
- eventSeriesId: number,
278
- venueId: string | number
279
- ): Promise<SeriesOccurrencesResponse | null> {
280
- try {
281
- const response = await fetch(
282
- `${getPublicBaseUrl()}/series/${eventSeriesId}/occurrences?venueId=${venueId}`
283
- );
284
-
285
- if (!response.ok) {
286
- logger.error(`Failed to fetch series with CTA: ${response.status}`);
287
- return null;
288
- }
289
-
290
- return response.json();
291
- } catch (error) {
292
- logger.error('Error fetching series occurrences:', error);
293
- return null;
294
- }
295
- }
296
-
297
- /**
298
- * Check event password
299
- *
300
- * Validates password for password-protected events.
301
- *
302
- * @param eventId - The event ID
303
- * @param password - The password to check
304
- * @returns Whether the password is valid
305
- */
306
- export async function checkEventPassword(
307
- eventId: string | number,
308
- password: string
309
- ): Promise<boolean> {
310
- try {
311
- const encodedPassword = encodeURIComponent(password);
312
- const response = await fetch(
313
- `${getPublicBaseUrl()}/events/${eventId}/check-password/${encodedPassword}`
314
- );
315
-
316
- if (!response.ok) {
317
- return false;
318
- }
319
-
320
- const result = await response.json();
321
- return result.valid === true;
322
- } catch (error) {
323
- logger.error('Error checking event password:', error);
324
- return false;
325
- }
326
- }
327
-
328
- /**
329
- * Test network connection
330
- *
331
- * Health check endpoint for connectivity testing.
332
- *
333
- * @param orgId - Optional org ID
334
- * @param venueId - Optional venue ID
335
- * @returns Whether the connection is working
336
- */
337
- export async function testNetworkConnection(
338
- orgId?: string | number,
339
- venueId?: string | number
340
- ): Promise<boolean> {
341
- try {
342
- // Use a simple endpoint to test connectivity
343
- const url = venueId
344
- ? `${getPublicBaseUrl()}/events/venue/${venueId}`
345
- : orgId
346
- ? `${getPublicBaseUrl()}/venues/organization/${orgId}`
347
- : `${getPublicBaseUrl()}/health`;
348
-
349
- const response = await fetch(url, {
350
- method: 'HEAD',
351
- });
352
-
353
- return response.ok;
354
- } catch (error) {
355
- logger.error('Network connection test failed:', error);
356
- return false;
357
- }
358
- }