@getmicdrop/venue-calendar 4.0.112 → 4.0.114

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 (99) hide show
  1. package/README.md +2 -0
  2. package/dist/CartView-DP-zSPnp.js +2466 -0
  3. package/dist/CartView-DP-zSPnp.js.map +1 -0
  4. package/dist/{Checkout-nyPWpzmE.js → Checkout-4OBtw96f.js} +5 -5
  5. package/dist/{Checkout-nyPWpzmE.js.map → Checkout-4OBtw96f.js.map} +1 -1
  6. package/dist/{Checkout-ns94gCrx.js → Checkout-Bn3zFEcH.js} +54 -54
  7. package/dist/{Checkout-ns94gCrx.js.map → Checkout-Bn3zFEcH.js.map} +1 -1
  8. package/dist/{CheckoutTimer-Bv4qR0Mn.js → CheckoutTimer-7n0Rg2J4.js} +5 -5
  9. package/dist/{CheckoutTimer-Bv4qR0Mn.js.map → CheckoutTimer-7n0Rg2J4.js.map} +1 -1
  10. package/dist/{ClockIcon-D2ib_bzt.js → ClockIcon-B5QsNamV.js} +2 -2
  11. package/dist/{ClockIcon-D2ib_bzt.js.map → ClockIcon-B5QsNamV.js.map} +1 -1
  12. package/dist/{CollectionView-G3OmVuiX.js → CollectionView-D__MAuqN.js} +44 -45
  13. package/dist/CollectionView-D__MAuqN.js.map +1 -0
  14. package/dist/{Event-B1syGqOf.js → Event-B0q-bk_t.js} +585 -581
  15. package/dist/Event-B0q-bk_t.js.map +1 -0
  16. package/dist/{EventPage-CqryTYfg.js → EventPage-DcgdVEO1.js} +10 -10
  17. package/dist/EventPage-DcgdVEO1.js.map +1 -0
  18. package/dist/{Heading-BM6t9w6d.js → Heading-CPS9G7Qy.js} +5 -5
  19. package/dist/Heading-CPS9G7Qy.js.map +1 -0
  20. package/dist/{ScarcityBadge-B7KnIEoD.js → ScarcityBadge-2WQu1zu5.js} +28 -28
  21. package/dist/{ScarcityBadge-B7KnIEoD.js.map → ScarcityBadge-2WQu1zu5.js.map} +1 -1
  22. package/dist/{SeriesPage-DYbBhYHy.js → SeriesPage-dj131X05.js} +5 -5
  23. package/dist/{SeriesPage-DYbBhYHy.js.map → SeriesPage-dj131X05.js.map} +1 -1
  24. package/dist/{Spinner-D2Ff-2jf.js → Spinner-nG3bt_QB.js} +2 -2
  25. package/dist/{Spinner-D2Ff-2jf.js.map → Spinner-nG3bt_QB.js.map} +1 -1
  26. package/dist/{Success-CPQuVaaV.js → Success-C9GZXfob.js} +8 -8
  27. package/dist/Success-C9GZXfob.js.map +1 -0
  28. package/dist/{Text-C-9C-Rav.js → Text-DDafFquO.js} +4 -4
  29. package/dist/{Text-C-9C-Rav.js.map → Text-DDafFquO.js.map} +1 -1
  30. package/dist/{VenueCalendar-Dkr4qm4p.js → VenueCalendar-DLn8bG9x.js} +4143 -4091
  31. package/dist/VenueCalendar-DLn8bG9x.js.map +1 -0
  32. package/dist/{ViewTicketsEmbed-B581Bukn.js → ViewTicketsEmbed-CdG_Pmhe.js} +388 -381
  33. package/dist/{ViewTicketsEmbed-B581Bukn.js.map → ViewTicketsEmbed-CdG_Pmhe.js.map} +1 -1
  34. package/dist/api/api/client.d.ts +17 -0
  35. package/dist/api/api/cta.d.ts +34 -0
  36. package/dist/api/api/events.d.ts +183 -0
  37. package/dist/api/api/gift-cards.d.ts +108 -0
  38. package/dist/api/api/index.d.ts +46 -0
  39. package/dist/api/api/orders.d.ts +149 -0
  40. package/dist/api/api/promo.d.ts +45 -0
  41. package/dist/api/api/result.d.ts +78 -0
  42. package/dist/api/api/route-manifest.d.ts +179 -0
  43. package/dist/api/api/transformers/address.d.ts +18 -0
  44. package/dist/api/api/transformers/cart.d.ts +19 -0
  45. package/dist/api/api/transformers/collection.d.ts +12 -0
  46. package/dist/api/api/transformers/event.d.ts +173 -0
  47. package/dist/api/api/transformers/giftCard.d.ts +11 -0
  48. package/dist/api/api/transformers/index.d.ts +27 -0
  49. package/dist/api/api/transformers/order.d.ts +44 -0
  50. package/dist/api/api/transformers/performer.d.ts +8 -0
  51. package/dist/api/api/transformers/series.d.ts +12 -0
  52. package/dist/api/api/transformers/venue.d.ts +39 -0
  53. package/dist/api/api/venues.d.ts +33 -0
  54. package/dist/api/api/waitlist.d.ts +49 -0
  55. package/dist/api/api.cjs +2 -0
  56. package/dist/api/api.cjs.map +1 -0
  57. package/dist/api/api.mjs +1302 -0
  58. package/dist/api/api.mjs.map +1 -0
  59. package/dist/api/types.d.ts +483 -0
  60. package/dist/{labels-DAFwZdnA.js → labels-CgmLAnGa.js} +3 -3
  61. package/dist/{labels-DAFwZdnA.js.map → labels-CgmLAnGa.js.map} +1 -1
  62. package/dist/{modalManager.svelte-BbA2uxS7.js → modalManager.svelte-Bb8AqZzB.js} +2 -2
  63. package/dist/{modalManager.svelte-BbA2uxS7.js.map → modalManager.svelte-Bb8AqZzB.js.map} +1 -1
  64. package/dist/navigation--gZASiSa.js.map +1 -1
  65. package/dist/{promo-BGoSmBd_.js → promo-DJRCG611.js} +9 -9
  66. package/dist/{promo-BGoSmBd_.js.map → promo-DJRCG611.js.map} +1 -1
  67. package/dist/seo/HostSeoController.d.ts +68 -0
  68. package/dist/seo/buildCollectionJsonLd.d.ts +8 -0
  69. package/dist/seo/buildEventJsonLd.d.ts +9 -0
  70. package/dist/seo/buildSeriesJsonLd.d.ts +6 -0
  71. package/dist/seo/helpers.d.ts +88 -0
  72. package/dist/seo/index.d.ts +10 -0
  73. package/dist/seo/seo.cjs +2 -0
  74. package/dist/seo/seo.cjs.map +1 -0
  75. package/dist/seo/seo.mjs +688 -0
  76. package/dist/seo/seo.mjs.map +1 -0
  77. package/dist/seo/types.d.ts +149 -0
  78. package/dist/{showcase-state-options-BWzGMPZ-.js → showcase-state-options-BcHrrA3V.js} +2 -2
  79. package/dist/showcase-state-options-BcHrrA3V.js.map +1 -0
  80. package/dist/{transform-CpjZiH34.js → transform-BdZxoZmv.js} +10 -10
  81. package/dist/{transform-CpjZiH34.js.map → transform-BdZxoZmv.js.map} +1 -1
  82. package/dist/{utm-D1uGUvk2.js → utm-BAxeAo8P.js} +2 -2
  83. package/dist/{utm-D1uGUvk2.js.map → utm-BAxeAo8P.js.map} +1 -1
  84. package/dist/venue-calendar.css +1 -1
  85. package/dist/venue-calendar.es.js +4 -4
  86. package/dist/venue-calendar.iife.js +37 -37
  87. package/dist/venue-calendar.iife.js.map +1 -1
  88. package/dist/venue-calendar.umd.js +32 -32
  89. package/dist/venue-calendar.umd.js.map +1 -1
  90. package/package.json +7 -3
  91. package/dist/CartView-H6PXIc8m.js +0 -2475
  92. package/dist/CartView-H6PXIc8m.js.map +0 -1
  93. package/dist/CollectionView-G3OmVuiX.js.map +0 -1
  94. package/dist/Event-B1syGqOf.js.map +0 -1
  95. package/dist/EventPage-CqryTYfg.js.map +0 -1
  96. package/dist/Heading-BM6t9w6d.js.map +0 -1
  97. package/dist/Success-CPQuVaaV.js.map +0 -1
  98. package/dist/VenueCalendar-Dkr4qm4p.js.map +0 -1
  99. package/dist/showcase-state-options-BWzGMPZ-.js.map +0 -1
@@ -0,0 +1,17 @@
1
+ import { ApiConfig, ApiResponse } from './types.js';
2
+ export declare function configureApi(config: Partial<ApiConfig>): void;
3
+ export declare function getApiConfig(): Required<ApiConfig>;
4
+ export declare function getPublicBaseUrl(): string;
5
+ export declare function getLegacyPublicUrl(): string;
6
+ export declare function getOrdersV2Url(): string;
7
+ /** @deprecated IP is now resolved server-side via request headers. */
8
+ export declare function getClientIP(): Promise<string>;
9
+ export declare function apiGet<T>(endpoint: string, options?: RequestInit): Promise<ApiResponse<T>>;
10
+ export declare function apiPost<T>(endpoint: string, body?: unknown, options?: RequestInit): Promise<ApiResponse<T>>;
11
+ export declare function apiPut<T>(endpoint: string, body?: unknown, options?: RequestInit): Promise<ApiResponse<T>>;
12
+ export declare function apiDelete<T>(endpoint: string, options?: RequestInit): Promise<ApiResponse<T>>;
13
+ /**
14
+ * Simple fetch wrapper that returns parsed JSON or null on error.
15
+ * Inherits the global timeout + retry policy for GETs.
16
+ */
17
+ export declare function simpleFetch<T>(url: string, options?: RequestInit): Promise<T | null>;
@@ -0,0 +1,34 @@
1
+ import { isHiddenTicketPurchasable } from '@getmicdrop/svelte-components/transforms';
2
+ export interface CtaStateOptions {
3
+ cancelled?: boolean;
4
+ isRegistration?: boolean;
5
+ waitlistEnabled?: boolean;
6
+ }
7
+ export interface CtaState {
8
+ text: string;
9
+ disabled: boolean;
10
+ reason: 'cancelled' | 'event_past' | 'no_tickets' | 'available' | 'coming_soon' | 'sold_out_waitlist' | 'sold_out' | 'sales_ended' | 'hidden_only';
11
+ }
12
+ interface CtaEvent {
13
+ startDateTime?: string | null;
14
+ endDateTime?: string | null;
15
+ hasPurchasableHiddenTickets?: boolean;
16
+ }
17
+ interface CtaTicket {
18
+ salesChannel?: number;
19
+ salesBegin?: string | null;
20
+ salesStart?: string | null;
21
+ saleBegin?: string | null;
22
+ onSaleStart?: string | null;
23
+ salesEnd?: string | null;
24
+ saleEnd?: string | null;
25
+ onSaleEnd?: string | null;
26
+ remainingCapacity?: number | null;
27
+ quantityRemaining?: number | null;
28
+ quantity?: number | null;
29
+ soldOut?: boolean;
30
+ isHidden?: boolean;
31
+ visibility?: number;
32
+ }
33
+ export { isHiddenTicketPurchasable };
34
+ export declare function computeCtaState(event: CtaEvent, tickets: CtaTicket[] | undefined, options?: CtaStateOptions): CtaState;
@@ -0,0 +1,183 @@
1
+ import { Result } from './result.js';
2
+ import { Event, AvailableTicket, EventPerformersResponse, SeriesOccurrencesResponse, PublicCollectionData, ResolvedEntity } from './types.js';
3
+ /**
4
+ * Fetch event details, discriminating a real 404 from a transient failure.
5
+ *
6
+ * The SSR loader (`[id]/[slug]/+page.js`) gates its HTTP status on this: only an
7
+ * upstream 404 (`errNotFound`) becomes a page 404. A 5xx, a network error, or a
8
+ * timeout is `err(...)` (transient) so the loader can answer 503/retry instead
9
+ * of rendering a permanent-looking 404 to a buyer or crawler on a backend blip.
10
+ *
11
+ * @param eventId - The event ID
12
+ * @param customFetch - Optional custom fetch function (for SSR)
13
+ * @param password - Optional password for gated events
14
+ * @returns `ok(event)`, `errNotFound(...)` for a real 404, or `err(...)` transient
15
+ */
16
+ export declare function fetchEventDetailsResult(eventId: string | number, customFetch?: typeof fetch, password?: string): Promise<Result<Event>>;
17
+ /**
18
+ * Fetch event details
19
+ *
20
+ * Gets full event information including venue and ticket data.
21
+ *
22
+ * Fail-open adapter over {@link fetchEventDetailsResult}: existing in-widget
23
+ * callers (Checkout, CartView, EventPage) keep degrading to `null` on any
24
+ * failure. SSR loaders that need to answer 404-vs-503 use the Result variant.
25
+ *
26
+ * @param eventId - The event ID
27
+ * @param customFetch - Optional custom fetch function (for SSR)
28
+ * @returns Event details or null on error
29
+ */
30
+ export declare function fetchEventDetails(eventId: string | number, customFetch?: typeof fetch, password?: string): Promise<Event | null>;
31
+ /**
32
+ * Fetch available tickets for an event
33
+ *
34
+ * Returns all ticket types that are currently available for sale.
35
+ *
36
+ * @param eventId - The event ID
37
+ * @returns Array of available tickets
38
+ */
39
+ export declare function fetchEventTicketsResult(eventId: string | number): Promise<Result<AvailableTicket[]>>;
40
+ export declare function fetchEventTickets(eventId: string | number): Promise<AvailableTicket[]>;
41
+ /**
42
+ * Fetch performers for an event
43
+ *
44
+ * Returns the lineup with pre-resolved avatar URLs.
45
+ *
46
+ * @param eventId - The event ID
47
+ * @returns Performers list and visibility flag
48
+ */
49
+ export declare function fetchEventPerformersResult(eventId: string | number): Promise<Result<EventPerformersResponse>>;
50
+ export declare function fetchEventPerformers(eventId: string | number): Promise<EventPerformersResponse>;
51
+ /**
52
+ * Fetch all venues for an organization
53
+ *
54
+ * @param orgId - The organization ID
55
+ * @returns Array of venues
56
+ */
57
+ export declare function fetchAllVenuesResult(orgId: string | number): Promise<Result<any[]>>;
58
+ export declare function fetchAllVenues(orgId: string | number): Promise<any[]>;
59
+ /**
60
+ * Fetch events for a venue
61
+ *
62
+ * @param venueId - The venue ID
63
+ * @returns Array of events
64
+ */
65
+ export declare function fetchVenueEventsResult(venueId: string | number): Promise<Result<Event[]>>;
66
+ export declare function fetchVenueEvents(venueId: string | number): Promise<Event[]>;
67
+ export declare function getMonthEventsResult(venueId: string | number, year: number, month: number): Promise<Result<Event[]>>;
68
+ export declare function getMonthEvents(venueId: string | number, year: number, month: number): Promise<Event[]>;
69
+ /**
70
+ * Get events for an organization for a specific month
71
+ *
72
+ * @param orgId - The organization ID
73
+ * @param year - The year (e.g., 2024)
74
+ * @param month - The month (1-12)
75
+ * @returns Array of events for the month
76
+ */
77
+ export declare function getOrgMonthEventsResult(orgId: string | number, year: number, month: number): Promise<Result<Event[]>>;
78
+ export declare function getOrgMonthEvents(orgId: string | number, year: number, month: number): Promise<Event[]>;
79
+ /**
80
+ * Get series occurrences for date selector
81
+ *
82
+ * Returns all instances of a recurring event series.
83
+ *
84
+ * @param eventSeriesId - The series ID
85
+ * @returns Series occurrences
86
+ */
87
+ export declare function getSeriesOccurrencesResult(eventSeriesId: number): Promise<Result<SeriesOccurrencesResponse>>;
88
+ export declare function getSeriesOccurrences(eventSeriesId: number): Promise<SeriesOccurrencesResponse | null>;
89
+ /**
90
+ * Fetch series occurrences with CTA state
91
+ *
92
+ * Returns full series data including availability status.
93
+ *
94
+ * @param eventSeriesId - The series ID
95
+ * @param venueId - The venue ID
96
+ * @returns Series occurrences with CTA state
97
+ */
98
+ export declare function fetchSeriesOccurrencesResult(eventSeriesId: number, venueId: string | number): Promise<Result<SeriesOccurrencesResponse>>;
99
+ export declare function fetchSeriesOccurrences(eventSeriesId: number, venueId: string | number): Promise<SeriesOccurrencesResponse | null>;
100
+ /**
101
+ * Resolve an entity-agnostic public id to its concrete type + data.
102
+ *
103
+ * The embed deep-link (`#{id}-{slug}`) carries no type prefix, so a cold
104
+ * deep link (the show isn't in the loaded calendar month) needs the backend
105
+ * to say whether the id is an event, series, or collection before the widget
106
+ * can render the right view. This is the same `/api/v2/public/resolve/{id}`
107
+ * endpoint get-micdrop.com's `/e/{slugId}` page resolves server-side; here we
108
+ * call it cross-origin from the venue's page (the public API already serves
109
+ * the calendar cross-origin, so CORS is in place).
110
+ *
111
+ * @param id - The entity id (numeric, type-agnostic)
112
+ * @param slug - Optional slug hint (lets the backend canonicalize)
113
+ * @returns `{ type, id, title, data }` or null on failure
114
+ */
115
+ export declare function resolvePublicEntity(id: string | number, slug?: string): Promise<ResolvedEntity | null>;
116
+ /**
117
+ * Fetch public collection data
118
+ *
119
+ * Returns collection info including events list.
120
+ * For password-protected collections, pass the password to authenticate.
121
+ *
122
+ * @param collectionId - The collection ID
123
+ * @param password - Optional password for protected collections
124
+ * @returns Collection data or null on error
125
+ */
126
+ export declare function fetchPublicCollection(collectionId: string | number, password?: string): Promise<PublicCollectionData | null>;
127
+ /**
128
+ * Check collection password
129
+ *
130
+ * Validates password for password-protected collections.
131
+ *
132
+ * @param collectionId - The collection ID
133
+ * @param password - The password to check
134
+ * @returns Whether the password is valid
135
+ */
136
+ export declare function checkCollectionPassword(collectionId: string | number, password: string): Promise<boolean>;
137
+ /**
138
+ * Check event password
139
+ *
140
+ * Validates password for password-protected events.
141
+ *
142
+ * @param eventId - The event ID
143
+ * @param password - The password to check
144
+ * @returns Whether the password is valid
145
+ */
146
+ export declare function checkEventPassword(eventId: string | number, password: string): Promise<{
147
+ valid: boolean;
148
+ }>;
149
+ /**
150
+ * Test network connection
151
+ *
152
+ * Asks whether the public API is reachable.
153
+ *
154
+ * THE QUESTION IS "DID THE ROUTER ANSWER", NOT "DID THE RESOURCE EXIST" — the
155
+ * same distinction route-manifest.ts is built on. Under the old `response.ok`
156
+ * rule this probe reported the API DOWN on a healthy backend on EVERY branch,
157
+ * for EVERY input, always. Measured against production: HEAD answers 405 on
158
+ * every route the backend serves — including `HEAD /events/venue/42` for a venue
159
+ * that EXISTS — and the old `HEAD /health` branch answered 404, because the
160
+ * router does not serve /health at all. None of those are `ok`. A liveness check
161
+ * that always fails is worse than none.
162
+ *
163
+ * Two changes fix two different things, and they are separable:
164
+ *
165
+ * 1. THE STATUS RULE is what fixes liveness. Reachable means ANSWERED, not
166
+ * `response.ok`. A 400, a 404 or a 405 is the backend talking: it is up.
167
+ * Only a transport failure (DNS, TLS, CORS, offline) or a 5xx means it is
168
+ * not serving. This rule alone would have made liveness report up, even on
169
+ * the old /health probe (404 < 500).
170
+ * 2. THE REPOINT is what stops this naming a route the router does not serve —
171
+ * the name-resolution gate, and #444. Every branch now names a route the
172
+ * backend actually SERVES. There is no id-free public route, so the no-ids
173
+ * branch asks a served route about an id that cannot exist: we do not care
174
+ * what it says about the venue, only that it said anything at all. This is
175
+ * not what fixes liveness.
176
+ *
177
+ * Do not "simplify" `status < 500` back to `response.ok`. That is the bug.
178
+ *
179
+ * @param orgId - Optional org ID
180
+ * @param venueId - Optional venue ID
181
+ * @returns Whether the API answered
182
+ */
183
+ export declare function testNetworkConnection(orgId?: string | number, venueId?: string | number): Promise<boolean>;
@@ -0,0 +1,108 @@
1
+ import { VenueId } from '@getmicdrop/svelte-components';
2
+ import { Result } from './result.js';
3
+ /**
4
+ * Request payload for creating a gift card purchase
5
+ */
6
+ export interface GiftCardPurchaseRequest {
7
+ venueId: number | VenueId;
8
+ amount: number;
9
+ recipientEmail: string;
10
+ recipientName: string;
11
+ personalMessage?: string;
12
+ purchaserEmail: string;
13
+ purchaserName: string;
14
+ scheduledDeliveryAt?: string | null;
15
+ }
16
+ /**
17
+ * Response from gift card purchase creation
18
+ */
19
+ export interface GiftCardPurchaseResponse {
20
+ giftCardUUID: string;
21
+ clientSecret: string;
22
+ amount: number;
23
+ stripePublishableKey: string;
24
+ }
25
+ /**
26
+ * Venue information needed for gift card purchase
27
+ */
28
+ export interface VenueInfo {
29
+ id: VenueId;
30
+ name: string;
31
+ slug: string;
32
+ stripePublishableKey?: string;
33
+ }
34
+ /**
35
+ * Create a gift card purchase and get Stripe client secret
36
+ * @param req - Gift card purchase request details
37
+ * @returns Gift card UUID and Stripe client secret, or null on failure
38
+ */
39
+ export declare function createGiftCardPurchase(req: GiftCardPurchaseRequest): Promise<GiftCardPurchaseResponse | null>;
40
+ /**
41
+ * Result shape consumed by the Checkout component / GiftCardInput.
42
+ * Monetary fields here are in DOLLARS (formatCurrency-ready).
43
+ */
44
+ export interface ApplyGiftCardResult {
45
+ valid: boolean;
46
+ giftCardCode?: string;
47
+ giftCardAmount?: number;
48
+ giftCardBalance?: number;
49
+ paymentType?: string;
50
+ stripeAmount?: number;
51
+ orderTotal?: number;
52
+ requiresStripe?: boolean;
53
+ error?: string;
54
+ }
55
+ /**
56
+ * Apply a gift card to a cart.
57
+ */
58
+ export declare function applyGiftCard(cartId: string, code: string): Promise<ApplyGiftCardResult>;
59
+ export interface RemoveGiftCardResult {
60
+ success: boolean;
61
+ error?: string;
62
+ }
63
+ /**
64
+ * Remove a gift card from a cart. Pass a `code` to remove a single stacked card;
65
+ * omit it to remove all applied gift cards.
66
+ */
67
+ export declare function removeGiftCard(cartId: string, code?: string): Promise<RemoveGiftCardResult>;
68
+ export interface CompleteGiftCardPaymentInput {
69
+ firstName: string;
70
+ lastName: string;
71
+ email: string;
72
+ phoneNumber?: string | null;
73
+ mailingList?: boolean;
74
+ }
75
+ export interface CompleteGiftCardPaymentResult {
76
+ success: boolean;
77
+ orderId?: string;
78
+ confirmationNumber?: string;
79
+ error?: string;
80
+ }
81
+ /**
82
+ * Complete a gift-card-only payment (no Stripe required when balance >= total).
83
+ */
84
+ export declare function completeGiftCardPayment(cartId: string, customerDetails: CompleteGiftCardPaymentInput): Promise<CompleteGiftCardPaymentResult>;
85
+ /**
86
+ * Fetch venue information by slug, discriminating a real 404 from a transient
87
+ * failure.
88
+ *
89
+ * The gift-card SSR loader (`v/[venueSlug]/gift-cards/purchase/+page.ts`) gates
90
+ * its HTTP status on this: only an upstream 404 (`errNotFound`) becomes a page
91
+ * 404. A 5xx, network error, or timeout is `err(...)` (transient) so the loader
92
+ * answers 503/retry rather than a permanent-looking 404 on a backend blip.
93
+ *
94
+ * @param slug - Venue slug
95
+ * @param customFetch - Optional custom fetch function (for SSR)
96
+ * @returns `ok(venue)`, `errNotFound(...)` for a real 404, or `err(...)` transient
97
+ */
98
+ export declare function getVenueBySlugResult(slug: string, customFetch?: typeof fetch): Promise<Result<VenueInfo>>;
99
+ /**
100
+ * Fetch venue information by slug
101
+ *
102
+ * Fail-open adapter over {@link getVenueBySlugResult}: returns `null` on any
103
+ * failure. SSR loaders that need 404-vs-503 use the Result variant.
104
+ *
105
+ * @param slug - Venue slug
106
+ * @returns Venue info or null on failure
107
+ */
108
+ export declare function getVenueBySlug(slug: string, customFetch?: typeof fetch): Promise<VenueInfo | null>;
@@ -0,0 +1,46 @@
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
+ export { configureApi, getApiConfig, getPublicBaseUrl, getLegacyPublicUrl, getOrdersV2Url, getClientIP, apiGet, apiPost, apiPut, apiDelete, } from './client.js';
33
+ export { createPaymentIntent, validatePaymentIntent, updateCartQuantities, getCartByUUID, createOrder, getOrder, completeReservation, cancelReservation, extendCheckoutSession, getSessionStatus, initiateOrder, trackUTMSource, } from './orders.js';
34
+ export type { CartReservationView, CartView } from './orders.js';
35
+ export { validatePromoCode, hasPromoCodes, applyPromoCode, removePromoCode, } from './promo.js';
36
+ export { fetchEventDetails, fetchEventTickets, fetchEventPerformers, fetchAllVenues, fetchVenueEvents, getMonthEvents, getOrgMonthEvents, getSeriesOccurrences, fetchSeriesOccurrences, fetchPublicCollection, resolvePublicEntity, checkEventPassword, checkCollectionPassword, testNetworkConnection, fetchEventDetailsResult, fetchEventTicketsResult, fetchEventPerformersResult, fetchAllVenuesResult, fetchVenueEventsResult, getMonthEventsResult, getOrgMonthEventsResult, getSeriesOccurrencesResult, fetchSeriesOccurrencesResult, } from './events.js';
37
+ export { ok, err, errNotFound, isOk, isErr, unwrapOr, type Result, } from './result.js';
38
+ export { getVenue, getVenueFees, getVenueBySlug } from './venues.js';
39
+ export { createGiftCardPurchase, applyGiftCard, removeGiftCard, completeGiftCardPayment, } from './gift-cards.js';
40
+ export type { GiftCardPurchaseRequest, GiftCardPurchaseResponse, ApplyGiftCardResult, RemoveGiftCardResult, CompleteGiftCardPaymentInput, CompleteGiftCardPaymentResult, } from './gift-cards.js';
41
+ export { joinWaitlist, getWaitlistStatus, validateWaitlistToken, } from './waitlist.js';
42
+ export type { JoinWaitlistResult, WaitlistStatusResult, ValidateWaitlistTokenResult, } from './waitlist.js';
43
+ export { computeCtaState } from './cta.js';
44
+ export type { CtaState, CtaStateOptions } from './cta.js';
45
+ export { transformOrder, transformTicket, transformOrderForDisplay, transformEvent, transformEventData, transformAvailableTicket, getCDNImageUrl, getEventImageUrl, calculateCtaState, transformVenue, extractVenueFees, formatVenueAddress, } from './transformers/index.js';
46
+ export type { ApiConfig, ApiResponse, PaymentIntentRequest, PaymentIntentResponse, CompleteReservationResponse, CancelReservationResponse, CreateOrderRequest, CreateOrderResponse, ValidatePaymentRequest, ValidatePaymentResponse, AttendeeInfo, ExtendSessionRequest, ExtendSessionResponse, SessionStatus, PromoValidationResponse, HasPromoCodesResponse, Order, PurchasedTicket, Event, AvailableTicket, EventPerformersResponse, Performer, Venue, SeriesOccurrence, SeriesOccurrencesResponse, SeriesPageData, PublicCollectionData, } from './types.js';
@@ -0,0 +1,149 @@
1
+ import { PaymentIntentResponse, CompleteReservationResponse, CancelReservationResponse, CreateOrderResponse, ValidatePaymentRequest, ValidatePaymentResponse, ExtendSessionResponse, SessionStatus, Order } from './types.js';
2
+ /**
3
+ * Create a payment intent for the cart
4
+ *
5
+ * This initiates the Stripe payment flow by creating a PaymentIntent
6
+ * on the backend. The response includes the client_secret needed
7
+ * for Stripe Elements.
8
+ *
9
+ * @param cartId - The cart/order UUID
10
+ * @param quantities - Map of ticketId -> quantity
11
+ * @param donationAmounts - Map of ticketId -> donation amount in dollars (for type=2 tickets)
12
+ * @returns Payment intent data including client_secret, or null on error
13
+ */
14
+ export declare function createPaymentIntent(cartId: string, quantities: Record<string | number, number>, donationAmounts?: Record<string | number, number>): Promise<PaymentIntentResponse | null>;
15
+ /**
16
+ * Fetch an existing cart by UUID (cross-device pre-fill — §1.3).
17
+ *
18
+ * Returns the server's authoritative view of a cart so a second device
19
+ * visiting the tickets page can see the in-progress reservation it created
20
+ * on another device. Returns `null` if:
21
+ * - the cart no longer exists (404)
22
+ * - the cart belongs to a different event than `expectedEventID` (when
23
+ * supplied) — we don't want to mix carts across events
24
+ * - the cart status is no longer `reserved` / `active` (e.g. expired,
25
+ * completed, abandoned) — caller should treat the local cookie as stale
26
+ * - any network/decode failure (caller falls back to localStorage only)
27
+ *
28
+ * Returned shape matches the orders-service `GET /v2Public/cart/{uuid}`
29
+ * response: a Cart model with embedded Reservations.
30
+ */
31
+ export interface CartReservationView {
32
+ ticketID: number;
33
+ quantity: number;
34
+ priceAtReservation: number;
35
+ status: string;
36
+ }
37
+ export interface CartView {
38
+ uuid: string;
39
+ eventID: number;
40
+ status: string;
41
+ expiresAt: string;
42
+ reservations: CartReservationView[];
43
+ }
44
+ export declare function getCartByUUID(cartUUID: string, expectedEventID?: string | number): Promise<CartView | null>;
45
+ /**
46
+ * Update cart quantities after the cart already exists.
47
+ *
48
+ * Replaces all reservations on the cart with the new quantities.
49
+ * The orders-service handler releases old reservations (returning
50
+ * inventory) and creates new ones (decrementing inventory) atomically.
51
+ *
52
+ * Use this when the user changes ticket counts AFTER the initial
53
+ * cart was created via initiateOrder. The cart UUID is preserved,
54
+ * so the timer and extension state stay intact.
55
+ *
56
+ * @returns true on success, false on failure
57
+ */
58
+ export declare function updateCartQuantities(cartId: string, quantities: Record<string | number, number>, donationAmounts?: Record<string | number, number>): Promise<boolean>;
59
+ /**
60
+ * Complete reservation after successful payment
61
+ *
62
+ * Called after Stripe confirms the payment to finalize the order
63
+ * and generate tickets.
64
+ *
65
+ * @param orderUuid - The order UUID
66
+ * @returns Success status and message
67
+ */
68
+ export declare function completeReservation(orderUuid: string): Promise<CompleteReservationResponse>;
69
+ /**
70
+ * Cancel reservation and release tickets back to inventory
71
+ *
72
+ * Called when user abandons checkout or session expires.
73
+ *
74
+ * @param orderUuid - The order UUID
75
+ * @returns Success status and message
76
+ */
77
+ export declare function cancelReservation(orderUuid: string): Promise<CancelReservationResponse>;
78
+ /**
79
+ * Create a new order/cart
80
+ *
81
+ * This creates an empty order that can be used for checkout.
82
+ * The order UUID is used for all subsequent operations.
83
+ *
84
+ * @param eventId - The event ID
85
+ * @param promoCode - Optional promo code to apply
86
+ * @returns The order UUID, or null on error
87
+ */
88
+ export declare function createOrder(eventId: string | number, promoCode?: string): Promise<CreateOrderResponse | null>;
89
+ /**
90
+ * Get order details (public, no auth required)
91
+ *
92
+ * Fetches the order details for displaying on the success page.
93
+ *
94
+ * @param orderId - The order UUID or ID
95
+ * @returns The order details, or null on error
96
+ */
97
+ export declare function getOrder(orderId: string): Promise<Order | null>;
98
+ /**
99
+ * Validate payment intent and complete the order
100
+ *
101
+ * This is an alternative to completeReservation that accepts
102
+ * additional payment details. Used by micdrop-frontend.
103
+ *
104
+ * @param cartId - The cart/order UUID
105
+ * @param payload - Payment validation payload
106
+ * @returns Validation result
107
+ */
108
+ export declare function validatePaymentIntent(cartId: string, payload: ValidatePaymentRequest): Promise<ValidatePaymentResponse | null>;
109
+ /**
110
+ * Extend the checkout session by 15 minutes
111
+ *
112
+ * Users get a limited number of extensions (typically 2-3).
113
+ *
114
+ * @param orderUuid - The order UUID
115
+ * @returns Extension result with new expiry time
116
+ */
117
+ export declare function extendCheckoutSession(orderUuid: string): Promise<ExtendSessionResponse>;
118
+ /**
119
+ * Get current session status including expiry time
120
+ *
121
+ * Used to display countdown timer and check if extensions are available.
122
+ *
123
+ * @param orderUuid - The order UUID
124
+ * @returns Session status including expiry time
125
+ */
126
+ export declare function getSessionStatus(orderUuid: string): Promise<SessionStatus>;
127
+ /**
128
+ * Initiate a new order (alias for createOrder)
129
+ *
130
+ * This function provides backwards compatibility with micdrop-frontend.
131
+ * It accepts the same parameters as the legacy initiateOrder function.
132
+ *
133
+ * @param cartData - Object containing eventID and optional quantities/promoCode
134
+ * @returns The order UUID, or null on error
135
+ */
136
+ export declare function initiateOrder(cartData?: {
137
+ eventID: string | number;
138
+ promoCode?: string;
139
+ quantities?: Record<string | number, number>;
140
+ }): Promise<string | null>;
141
+ /**
142
+ * Track UTM source for analytics
143
+ *
144
+ * Records the traffic source (utm_source parameter) for marketing analytics.
145
+ *
146
+ * @param venueId - The venue ID
147
+ * @returns Promise that resolves when tracking is complete
148
+ */
149
+ export declare function trackUTMSource(venueId: string | number): Promise<void>;
@@ -0,0 +1,45 @@
1
+ import { PromoValidationResponse } from './types.js';
2
+ /**
3
+ * Validate a promo code for an event
4
+ *
5
+ * Checks if a promo code is valid and returns its effects:
6
+ * - Discount amount and type
7
+ * - Hidden ticket reveal
8
+ *
9
+ * @param eventId - The event ID
10
+ * @param code - The promo code to validate
11
+ * @returns Validation result with discount info
12
+ */
13
+ export declare function validatePromoCode(eventId: string | number, code: string): Promise<PromoValidationResponse>;
14
+ /**
15
+ * Check if promo codes are available for an event
16
+ *
17
+ * Used to conditionally show/hide the promo code input field.
18
+ *
19
+ * @param eventId - The event ID
20
+ * @returns Whether promo codes exist for this event
21
+ */
22
+ export declare function hasPromoCodes(eventId: string | number): Promise<boolean>;
23
+ /**
24
+ * Apply a promo code to a cart
25
+ *
26
+ * This updates the cart with the promo code discount.
27
+ *
28
+ * @param cartId - The cart UUID
29
+ * @param code - The promo code to apply
30
+ * @returns Success status
31
+ */
32
+ export declare function applyPromoCode(cartId: string, code: string): Promise<{
33
+ success: boolean;
34
+ error?: string;
35
+ }>;
36
+ /**
37
+ * Remove a promo code from a cart
38
+ *
39
+ * @param cartId - The cart UUID
40
+ * @returns Success status
41
+ */
42
+ export declare function removePromoCode(cartId: string): Promise<{
43
+ success: boolean;
44
+ error?: string;
45
+ }>;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Result — the canonical error channel for API loaders.
3
+ *
4
+ * The public loaders in this package historically collapsed a failed fetch
5
+ * to an empty value (`[]`, `{ performers: [], showPerformers: false }`, or
6
+ * `null`), which is indistinguishable from a genuinely empty result. A buyer
7
+ * hitting a live event during a transient endpoint blip then sees a dead
8
+ * "No tickets available" button with no retry; a failed calendar month
9
+ * renders dark, so the venue looks like it has nothing on.
10
+ *
11
+ * `Result<T>` gives loaders a typed error channel so callers can tell
12
+ * "the request failed" apart from "there is genuinely nothing here", and
13
+ * offer a retry instead of silently degrading. Loaders expose a `*Result`
14
+ * variant returning this; the array/object-returning public functions stay
15
+ * as thin fail-open adapters over that variant (single source of truth for
16
+ * the fetch + validation logic).
17
+ *
18
+ * Not to be confused with `ApiResponse<T>` (types.ts) — that is the write-path
19
+ * HTTP envelope returned by `apiPost`/`apiGet`/etc. (`{ success, data?, error?,
20
+ * statusCode? }`, discriminated on `.success`). `Result<T>` is the read-path
21
+ * loader channel, discriminated on `.ok`. They are deliberately separate:
22
+ * `ApiResponse` carries transport metadata, `Result` carries only "loaded vs
23
+ * failed". Check `.ok` on a Result, `.success` on an ApiResponse — never mix.
24
+ */
25
+ export type Result<T> = {
26
+ ok: true;
27
+ data: T;
28
+ } | {
29
+ ok: false;
30
+ error: string;
31
+ notFound?: boolean;
32
+ };
33
+ /** Wrap a successful value. */
34
+ export declare function ok<T>(data: T): Result<T>;
35
+ /**
36
+ * Wrap a failure with a short, stable error code (used for i18n/render).
37
+ *
38
+ * This is a TRANSIENT failure by default (`notFound` is unset) — the request
39
+ * couldn't complete (network, timeout, 5xx). Loaders that gate an SSR 404 on a
40
+ * Result must treat a plain `err(...)` as retryable (503), not "gone" (404), so
41
+ * a backend blip never renders a permanent-looking 404 to a buyer or crawler.
42
+ */
43
+ export declare function err(error: string): Result<never>;
44
+ /**
45
+ * Wrap a genuine "this resource does not exist" failure (upstream 404).
46
+ *
47
+ * Distinct from `err(...)`: only this warrants an SSR 404. A transient upstream
48
+ * failure must NOT collapse to `errNotFound` — that is exactly the bug this
49
+ * channel exists to prevent (a fetch blip becoming a permanent 404).
50
+ */
51
+ export declare function errNotFound(error: string): Result<never>;
52
+ /** Narrowing guard — true when the result carries data. */
53
+ export declare function isOk<T>(result: Result<T>): result is {
54
+ ok: true;
55
+ data: T;
56
+ };
57
+ /**
58
+ * Narrowing guard — true when the result is a failure (transient OR not-found).
59
+ *
60
+ * This package typechecks with `strictNullChecks` off, where the ELSE flow of a
61
+ * discriminated union does NOT narrow (`if (r.ok) {…}` narrows the positive
62
+ * branch, but the fall-through keeps the full union). Consumers that need the
63
+ * failure branch's `error`/`notFound` must narrow POSITIVELY through this guard
64
+ * rather than relying on `!r.ok` control flow.
65
+ */
66
+ export declare function isErr<T>(result: Result<T>): result is {
67
+ ok: false;
68
+ error: string;
69
+ notFound?: boolean;
70
+ };
71
+ /**
72
+ * Collapse a Result to its data, substituting `fallback` on failure.
73
+ *
74
+ * This is the fail-open bridge the legacy array/object-returning loaders use
75
+ * so existing callers keep their current "degrade to empty" behaviour until
76
+ * they adopt the Result variant and render an error/retry state.
77
+ */
78
+ export declare function unwrapOr<T>(result: Result<T>, fallback: T): T;