@getmicdrop/venue-calendar 2.0.0 → 3.2.0
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/README.md +119 -6
- package/dist/VenueCalendar-Xppig0q_.js +22015 -0
- package/dist/VenueCalendar-Xppig0q_.js.map +1 -0
- package/dist/index-BjErG0CG.js +486 -0
- package/dist/index-BjErG0CG.js.map +1 -0
- package/dist/types/index.d.ts +395 -0
- package/dist/venue-calendar.css +1 -1
- package/dist/venue-calendar.es.js +22 -8283
- package/dist/venue-calendar.es.js.map +1 -1
- package/dist/venue-calendar.iife.js +51 -40
- package/dist/venue-calendar.iife.js.map +1 -1
- package/dist/venue-calendar.umd.js +51 -40
- package/dist/venue-calendar.umd.js.map +1 -1
- package/package.json +93 -68
- package/src/lib/api/client.ts +210 -0
- package/src/lib/api/events.ts +358 -0
- package/src/lib/api/index.ts +182 -0
- package/src/lib/api/orders.ts +390 -0
- package/src/lib/api/promo.ts +164 -0
- package/src/lib/api/transformers/event.ts +248 -0
- package/src/lib/api/transformers/index.ts +29 -0
- package/src/lib/api/transformers/order.ts +207 -0
- package/src/lib/api/transformers/venue.ts +118 -0
- package/src/lib/api/types.ts +289 -0
- package/src/lib/api/venues.ts +100 -0
- package/src/lib/theme.js +209 -0
package/package.json
CHANGED
|
@@ -1,68 +1,93 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@getmicdrop/venue-calendar",
|
|
3
|
+
"version": "3.2.0",
|
|
4
|
+
"description": "A customizable Svelte calendar component for displaying comedy events",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"types": "./dist/types/index.d.ts",
|
|
7
|
+
"main": "./dist/venue-calendar.umd.js",
|
|
8
|
+
"module": "./dist/venue-calendar.es.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
12
|
+
"import": "./dist/venue-calendar.es.js",
|
|
13
|
+
"require": "./dist/venue-calendar.umd.js",
|
|
14
|
+
"default": "./dist/venue-calendar.es.js"
|
|
15
|
+
},
|
|
16
|
+
"./api": {
|
|
17
|
+
"types": "./src/lib/api/index.ts",
|
|
18
|
+
"import": "./src/lib/api/index.ts",
|
|
19
|
+
"default": "./src/lib/api/index.ts"
|
|
20
|
+
},
|
|
21
|
+
"./theme": {
|
|
22
|
+
"import": "./src/lib/theme.js",
|
|
23
|
+
"default": "./src/lib/theme.js"
|
|
24
|
+
},
|
|
25
|
+
"./dist/venue-calendar.css": "./dist/venue-calendar.css"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"src/lib/api",
|
|
30
|
+
"src/lib/theme.js",
|
|
31
|
+
"README.md"
|
|
32
|
+
],
|
|
33
|
+
"scripts": {
|
|
34
|
+
"dev": "vite dev",
|
|
35
|
+
"build": "vite build",
|
|
36
|
+
"build:lib": "vite build --config vite.config.lib.js",
|
|
37
|
+
"preview": "vite preview",
|
|
38
|
+
"prepare": "svelte-kit sync || echo ''",
|
|
39
|
+
"prepublishOnly": "npm run build:lib",
|
|
40
|
+
"check": "svelte-check --diagnostic-sources \"js,svelte\"",
|
|
41
|
+
"check:all": "svelte-check",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"test:watch": "vitest",
|
|
44
|
+
"test:ui": "vitest --ui"
|
|
45
|
+
},
|
|
46
|
+
"keywords": [
|
|
47
|
+
"svelte",
|
|
48
|
+
"calendar",
|
|
49
|
+
"events",
|
|
50
|
+
"comedy",
|
|
51
|
+
"venue",
|
|
52
|
+
"component",
|
|
53
|
+
"micdrop"
|
|
54
|
+
],
|
|
55
|
+
"author": "MicDrop",
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"repository": {
|
|
58
|
+
"type": "git",
|
|
59
|
+
"url": "git+https://github.com/get-micdrop/venue-calendar.git"
|
|
60
|
+
},
|
|
61
|
+
"bugs": {
|
|
62
|
+
"url": "https://github.com/get-micdrop/venue-calendar/issues"
|
|
63
|
+
},
|
|
64
|
+
"homepage": "https://github.com/get-micdrop/venue-calendar#readme",
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"svelte": "^5.0.0"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@sveltejs/adapter-auto": "^6.1.0",
|
|
70
|
+
"@sveltejs/kit": "^2.49.4",
|
|
71
|
+
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
|
72
|
+
"@tailwindcss/vite": "^4.0.0",
|
|
73
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
74
|
+
"@testing-library/svelte": "^5.3.1",
|
|
75
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
76
|
+
"baseline-browser-mapping": "^2.9.11",
|
|
77
|
+
"jsdom": "^27.4.0",
|
|
78
|
+
"svelte": "^5.46.1",
|
|
79
|
+
"svelte-check": "^4.3.5",
|
|
80
|
+
"tailwindcss": "^4.0.0",
|
|
81
|
+
"typescript": "^5.9.3",
|
|
82
|
+
"vite": "^7.0.0",
|
|
83
|
+
"vitest": "^4.0.16"
|
|
84
|
+
},
|
|
85
|
+
"dependencies": {
|
|
86
|
+
"@getmicdrop/svelte-components": "^5.8.3",
|
|
87
|
+
"@stripe/stripe-js": "^4.0.0",
|
|
88
|
+
"carbon-icons-svelte": "^13.7.0",
|
|
89
|
+
"esbuild": "^0.27.2",
|
|
90
|
+
"js-cookie": "^3.0.5",
|
|
91
|
+
"svelte-stripe": "^1.4.0"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
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
|
+
}
|