@kotao/storefront 0.2.2 → 0.2.4

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 (48) hide show
  1. package/dist/chunk-4OQYNUGM.js +29 -0
  2. package/dist/chunk-4OQYNUGM.js.map +1 -0
  3. package/dist/{chunk-7XYWHWT4.js → chunk-4TEFGD42.js} +331 -38
  4. package/dist/chunk-4TEFGD42.js.map +1 -0
  5. package/dist/chunk-7MTCGXIG.js +144 -0
  6. package/dist/chunk-7MTCGXIG.js.map +1 -0
  7. package/dist/chunk-IIOHENCG.js +239 -0
  8. package/dist/chunk-IIOHENCG.js.map +1 -0
  9. package/dist/chunk-VV653S52.js +246 -0
  10. package/dist/chunk-VV653S52.js.map +1 -0
  11. package/dist/chunk-WG7HYVHJ.js +38 -0
  12. package/dist/chunk-WG7HYVHJ.js.map +1 -0
  13. package/dist/{client-DiPdlvPu.d.ts → client-D51WdvYR.d.ts} +55 -8
  14. package/dist/client-bsiNPHBi.d.ts +159 -0
  15. package/dist/createCartHandler-C4RrPwSG.d.ts +58 -0
  16. package/dist/editor.d.ts +1 -1
  17. package/dist/events-react.d.ts +68 -0
  18. package/dist/events-react.js +557 -0
  19. package/dist/events-react.js.map +1 -0
  20. package/dist/events.d.ts +18 -0
  21. package/dist/events.js +5 -0
  22. package/dist/events.js.map +1 -0
  23. package/dist/{fetch-B6TIc6lI.d.ts → fetch-M3Y-fQrW.d.ts} +1 -1
  24. package/dist/forms.d.ts +58 -0
  25. package/dist/forms.js +3 -0
  26. package/dist/forms.js.map +1 -0
  27. package/dist/http-types-CGh8WGHB.d.ts +11 -0
  28. package/dist/index.d.ts +74 -12
  29. package/dist/index.js +55 -9
  30. package/dist/index.js.map +1 -1
  31. package/dist/offer-token-C-nk_nj8.d.ts +16 -0
  32. package/dist/{pagination-CPgH3fAa.d.ts → pagination-DCrQk02Q.d.ts} +1 -1
  33. package/dist/product.d.ts +1 -1
  34. package/dist/react-router.d.ts +11 -7
  35. package/dist/react-router.js +4 -3
  36. package/dist/react-router.js.map +1 -1
  37. package/dist/react.d.ts +30 -7
  38. package/dist/react.js +4 -2
  39. package/dist/react.js.map +1 -1
  40. package/dist/{routing-BxRlep_-.d.ts → routing-sEonP93J.d.ts} +17 -60
  41. package/dist/seo.d.ts +2 -1
  42. package/dist/settings.d.ts +5 -4
  43. package/dist/{shop-DkQmro-Y.d.ts → shop-BJSvtmnV.d.ts} +2 -2
  44. package/dist/{store-DQK1nhob.d.ts → store-CtCWHI8H.d.ts} +1 -1
  45. package/dist/types-CSNXbGFW.d.ts +108 -0
  46. package/dist/{types-Df3bGbKU.d.ts → types-bcbQzx87.d.ts} +1 -1
  47. package/package.json +14 -2
  48. package/dist/chunk-7XYWHWT4.js.map +0 -1
@@ -0,0 +1,38 @@
1
+ // src/events/offer-token.ts
2
+ var CLAIM_TOKEN = /^[A-Za-z0-9_-]{43}$/u;
3
+ var consumedLocationMarkers = /* @__PURE__ */ new WeakMap();
4
+ function offerTokenHrefMarker(href) {
5
+ let left = 2166136261;
6
+ let right = 2246822507;
7
+ for (let index = 0; index < href.length; index += 1) {
8
+ const code = href.charCodeAt(index);
9
+ left = Math.imul(left ^ code, 16777619);
10
+ right = Math.imul(right ^ code, 3266489909);
11
+ }
12
+ return `${(left >>> 0).toString(16).padStart(8, "0")}${(right >>> 0).toString(16).padStart(8, "0")}`;
13
+ }
14
+ function consumeOfferTokenFragment(location, history) {
15
+ const marker = offerTokenHrefMarker(location.href);
16
+ const consumedMarkers = consumedLocationMarkers.get(location) ?? /* @__PURE__ */ new Set();
17
+ if (consumedMarkers.has(marker)) return null;
18
+ consumedMarkers.add(marker);
19
+ consumedLocationMarkers.set(location, consumedMarkers);
20
+ const url = new URL(location.href);
21
+ const queryHasToken = url.searchParams.has("token") || url.searchParams.has("claimToken");
22
+ const fragment = new URLSearchParams(url.hash.startsWith("#") ? url.hash.slice(1) : url.hash);
23
+ const fragmentToken = fragment.get("token");
24
+ const fragmentIsExact = fragment.size === 1 && fragment.has("token");
25
+ const shouldReplace = queryHasToken || url.hash !== "";
26
+ url.searchParams.delete("token");
27
+ url.searchParams.delete("claimToken");
28
+ url.hash = "";
29
+ if (shouldReplace) {
30
+ history.replaceState(history.state, "", `${url.pathname}${url.search}`);
31
+ }
32
+ if (queryHasToken || !fragmentIsExact || fragmentToken === null) return null;
33
+ return CLAIM_TOKEN.test(fragmentToken) ? fragmentToken : null;
34
+ }
35
+
36
+ export { consumeOfferTokenFragment, offerTokenHrefMarker };
37
+ //# sourceMappingURL=chunk-WG7HYVHJ.js.map
38
+ //# sourceMappingURL=chunk-WG7HYVHJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/events/offer-token.ts"],"names":[],"mappings":";AASA,IAAM,WAAA,GAAc,sBAAA;AACpB,IAAM,uBAAA,uBAA8B,OAAA,EAA6B;AAG1D,SAAS,qBAAqB,IAAA,EAAsB;AACzD,EAAA,IAAI,IAAA,GAAO,UAAA;AACX,EAAA,IAAI,KAAA,GAAQ,UAAA;AACZ,EAAA,KAAA,IAAS,QAAQ,CAAA,EAAG,KAAA,GAAQ,IAAA,CAAK,MAAA,EAAQ,SAAS,CAAA,EAAG;AACnD,IAAA,MAAM,IAAA,GAAO,IAAA,CAAK,UAAA,CAAW,KAAK,CAAA;AAClC,IAAA,IAAA,GAAO,IAAA,CAAK,IAAA,CAAK,IAAA,GAAO,IAAA,EAAM,QAAU,CAAA;AACxC,IAAA,KAAA,GAAQ,IAAA,CAAK,IAAA,CAAK,KAAA,GAAQ,IAAA,EAAM,UAAU,CAAA;AAAA,EAC5C;AACA,EAAA,OAAO,IAAI,IAAA,KAAS,CAAA,EAAG,SAAS,EAAE,CAAA,CAAE,SAAS,CAAA,EAAG,GAAG,CAAC,CAAA,EAAA,CAAI,KAAA,KAAU,GAC/D,QAAA,CAAS,EAAE,EACX,QAAA,CAAS,CAAA,EAAG,GAAG,CAAC,CAAA,CAAA;AACrB;AAMO,SAAS,yBAAA,CACd,UACA,OAAA,EACe;AACf,EAAA,MAAM,MAAA,GAAS,oBAAA,CAAqB,QAAA,CAAS,IAAI,CAAA;AACjD,EAAA,MAAM,kBAAkB,uBAAA,CAAwB,GAAA,CAAI,QAAQ,CAAA,wBAAS,GAAA,EAAY;AACjF,EAAA,IAAI,eAAA,CAAgB,GAAA,CAAI,MAAM,CAAA,EAAG,OAAO,IAAA;AACxC,EAAA,eAAA,CAAgB,IAAI,MAAM,CAAA;AAC1B,EAAA,uBAAA,CAAwB,GAAA,CAAI,UAAU,eAAe,CAAA;AAErD,EAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,QAAA,CAAS,IAAI,CAAA;AACjC,EAAA,MAAM,aAAA,GAAgB,IAAI,YAAA,CAAa,GAAA,CAAI,OAAO,CAAA,IAAK,GAAA,CAAI,YAAA,CAAa,GAAA,CAAI,YAAY,CAAA;AACxF,EAAA,MAAM,QAAA,GAAW,IAAI,eAAA,CAAgB,GAAA,CAAI,KAAK,UAAA,CAAW,GAAG,CAAA,GAAI,GAAA,CAAI,IAAA,CAAK,KAAA,CAAM,CAAC,CAAA,GAAI,IAAI,IAAI,CAAA;AAC5F,EAAA,MAAM,aAAA,GAAgB,QAAA,CAAS,GAAA,CAAI,OAAO,CAAA;AAC1C,EAAA,MAAM,kBAAkB,QAAA,CAAS,IAAA,KAAS,CAAA,IAAK,QAAA,CAAS,IAAI,OAAO,CAAA;AACnE,EAAA,MAAM,aAAA,GAAgB,aAAA,IAAiB,GAAA,CAAI,IAAA,KAAS,EAAA;AAEpD,EAAA,GAAA,CAAI,YAAA,CAAa,OAAO,OAAO,CAAA;AAC/B,EAAA,GAAA,CAAI,YAAA,CAAa,OAAO,YAAY,CAAA;AACpC,EAAA,GAAA,CAAI,IAAA,GAAO,EAAA;AACX,EAAA,IAAI,aAAA,EAAe;AACjB,IAAA,OAAA,CAAQ,YAAA,CAAa,OAAA,CAAQ,KAAA,EAAO,EAAA,EAAI,CAAA,EAAG,IAAI,QAAQ,CAAA,EAAG,GAAA,CAAI,MAAM,CAAA,CAAE,CAAA;AAAA,EACxE;AAEA,EAAA,IAAI,aAAA,IAAiB,CAAC,eAAA,IAAmB,aAAA,KAAkB,MAAM,OAAO,IAAA;AACxE,EAAA,OAAO,WAAA,CAAY,IAAA,CAAK,aAAa,CAAA,GAAI,aAAA,GAAgB,IAAA;AAC3D","file":"chunk-WG7HYVHJ.js","sourcesContent":["export interface OfferTokenLocation {\n readonly href: string\n}\n\nexport interface OfferTokenHistory {\n readonly state: unknown\n replaceState(data: unknown, unused: string, url?: string | URL | null): void\n}\n\nconst CLAIM_TOKEN = /^[A-Za-z0-9_-]{43}$/u\nconst consumedLocationMarkers = new WeakMap<object, Set<string>>()\n\n/** Lossy marker for replay detection. It never retains or reproduces the capability-bearing href. */\nexport function offerTokenHrefMarker(href: string): string {\n let left = 0x811c9dc5\n let right = 0x85ebca6b\n for (let index = 0; index < href.length; index += 1) {\n const code = href.charCodeAt(index)\n left = Math.imul(left ^ code, 0x01000193)\n right = Math.imul(right ^ code, 0xc2b2ae35)\n }\n return `${(left >>> 0).toString(16).padStart(8, '0')}${(right >>> 0)\n .toString(16)\n .padStart(8, '0')}`\n}\n\n/**\n * Consumes an offer capability from the fragment and removes capability-bearing URL state before\n * the caller can issue a request. Query-string capabilities are sanitized but never accepted.\n */\nexport function consumeOfferTokenFragment(\n location: OfferTokenLocation,\n history: OfferTokenHistory,\n): string | null {\n const marker = offerTokenHrefMarker(location.href)\n const consumedMarkers = consumedLocationMarkers.get(location) ?? new Set<string>()\n if (consumedMarkers.has(marker)) return null\n consumedMarkers.add(marker)\n consumedLocationMarkers.set(location, consumedMarkers)\n\n const url = new URL(location.href)\n const queryHasToken = url.searchParams.has('token') || url.searchParams.has('claimToken')\n const fragment = new URLSearchParams(url.hash.startsWith('#') ? url.hash.slice(1) : url.hash)\n const fragmentToken = fragment.get('token')\n const fragmentIsExact = fragment.size === 1 && fragment.has('token')\n const shouldReplace = queryHasToken || url.hash !== ''\n\n url.searchParams.delete('token')\n url.searchParams.delete('claimToken')\n url.hash = ''\n if (shouldReplace) {\n history.replaceState(history.state, '', `${url.pathname}${url.search}`)\n }\n\n if (queryHasToken || !fragmentIsExact || fragmentToken === null) return null\n return CLAIM_TOKEN.test(fragmentToken) ? fragmentToken : null\n}\n"]}
@@ -1,9 +1,13 @@
1
+ import { S as StorefrontHeadersInit } from './http-types-CGh8WGHB.js';
2
+
1
3
  interface CacheStrategy {
2
4
  readonly mode: 'none' | 'short' | 'long' | 'custom';
3
5
  /** seconds the value is considered fresh */
4
6
  readonly maxAge: number;
5
7
  /** extra seconds the stale value may be served while revalidating */
6
8
  readonly staleWhileRevalidate: number;
9
+ /** extra seconds the last value may be served only when revalidation fails */
10
+ readonly staleIfError?: number;
7
11
  }
8
12
  declare const CacheNone: () => CacheStrategy;
9
13
  declare const CacheShort: (o?: Partial<Omit<CacheStrategy, "mode">>) => CacheStrategy;
@@ -13,8 +17,32 @@ declare const CacheCustom: (s: Omit<CacheStrategy, "mode">) => CacheStrategy;
13
17
  declare const StorefrontDefaultCache: () => CacheStrategy;
14
18
  declare function generateCacheControlHeader(strategy: CacheStrategy): string;
15
19
  interface KotaoCache {
16
- run<T>(key: string, strategy: CacheStrategy, fn: () => Promise<T>): Promise<T>;
17
- readonly raw: Cache;
20
+ run<T>(key: string, strategy: CacheStrategy, fn: () => Promise<T>, onStaleIfError?: (fallback: StaleIfErrorFallback) => void): Promise<T>;
21
+ readonly raw: StorefrontCacheInput;
22
+ }
23
+ type StorefrontCacheRequest = Request | string | URL;
24
+ interface StorefrontCacheQueryOptions {
25
+ readonly cacheName?: string;
26
+ readonly ignoreMethod?: boolean;
27
+ readonly ignoreSearch?: boolean;
28
+ readonly ignoreVary?: boolean;
29
+ }
30
+ /** Worker-compatible Cache input required by the storefront cache implementation. */
31
+ interface StorefrontCacheInput {
32
+ delete(request: StorefrontCacheRequest, options?: StorefrontCacheQueryOptions): Promise<boolean>;
33
+ match(request: StorefrontCacheRequest, options?: StorefrontCacheQueryOptions): Promise<Response | undefined>;
34
+ put(request: StorefrontCacheRequest, response: Response): Promise<void>;
35
+ }
36
+ /** Full standard Cache surface retained by the public storefront client. */
37
+ interface StorefrontCache extends StorefrontCacheInput {
38
+ add(request: StorefrontCacheRequest): Promise<void>;
39
+ addAll(requests: StorefrontCacheRequest[]): Promise<void>;
40
+ keys(request?: StorefrontCacheRequest, options?: StorefrontCacheQueryOptions): Promise<readonly Request[]>;
41
+ matchAll(request?: StorefrontCacheRequest, options?: StorefrontCacheQueryOptions): Promise<readonly Response[]>;
42
+ }
43
+ interface StaleIfErrorFallback {
44
+ readonly ageSeconds: number;
45
+ readonly error: unknown;
18
46
  }
19
47
  /**
20
48
  * Stale-while-revalidate cache over an injected Cache (WFP untrusted mode disables
@@ -23,7 +51,7 @@ interface KotaoCache {
23
51
  * cross-request age is ever compared, which `Date.now()` reports correctly.
24
52
  */
25
53
  declare function createCache(opts: {
26
- cache: Cache;
54
+ cache: StorefrontCacheInput;
27
55
  waitUntil: (p: Promise<unknown>) => void;
28
56
  now?: () => number;
29
57
  }): KotaoCache;
@@ -32,6 +60,22 @@ interface StorefrontQueryOptions {
32
60
  variables?: Record<string, unknown>;
33
61
  cache?: CacheStrategy;
34
62
  storefrontApiVersion?: string;
63
+ /** Per-read upstream budget in milliseconds. Defaults to the client's 5,000 ms budget. */
64
+ timeoutMs?: number;
65
+ }
66
+ declare class StorefrontQueryTimeoutError extends Error {
67
+ readonly operationName: string;
68
+ readonly timeoutMs: number;
69
+ constructor(operationName: string, timeoutMs: number);
70
+ }
71
+ declare class StorefrontUpstreamError extends Error {
72
+ readonly operationName: string;
73
+ readonly status: number | undefined;
74
+ readonly cause: unknown;
75
+ constructor(operationName: string, message: string, options?: {
76
+ status?: number;
77
+ cause?: unknown;
78
+ });
35
79
  }
36
80
  interface StorefrontLooseConnection<T = any> {
37
81
  readonly nodes: T[];
@@ -87,7 +131,7 @@ interface StorefrontClient {
87
131
  CacheShort: typeof CacheShort;
88
132
  CacheLong: typeof CacheLong;
89
133
  CacheCustom: typeof CacheCustom;
90
- readonly cache: Cache;
134
+ readonly cache: StorefrontCache;
91
135
  readonly i18n: StorefrontI18n;
92
136
  }
93
137
  type Storefront<I18n = unknown> = StorefrontClient & {
@@ -111,6 +155,8 @@ interface StorefrontClientOptions {
111
155
  cache: KotaoCache;
112
156
  fetch?: typeof fetch | undefined;
113
157
  defaultStrategy?: CacheStrategy | undefined;
158
+ /** Default budget for each independent read query. Mutations are intentionally excluded. */
159
+ queryTimeoutMs?: number | undefined;
114
160
  /**
115
161
  * Pre-signed `x-kotao-shop` / `x-kotao-shop-signature` header pair, merged into every request.
116
162
  * In production the Gateway signs the shop-context; in local dev (no Gateway) the theme dev
@@ -121,7 +167,7 @@ interface StorefrontClientOptions {
121
167
  * Additional server request headers to forward to direct Storefront API calls. Used by
122
168
  * Hydrogen-compatible server adapters for `storefrontHeaders`.
123
169
  */
124
- extraHeaders?: HeadersInit | undefined;
170
+ extraHeaders?: StorefrontHeadersInit | undefined;
125
171
  /**
126
172
  * BCP 47 locale tag derived from the localization cookie (e.g. `'nl'`, `'es'`, `'de-de'`).
127
173
  * When set, `x-kotao-locale` is added to every request so storefront-api can overlay
@@ -136,17 +182,18 @@ interface StorefrontClientOptions {
136
182
  i18n?: Partial<StorefrontI18n> | undefined;
137
183
  }
138
184
  interface HydrogenStorefrontClientOptions<I18n extends object = StorefrontI18n> {
139
- cache: Cache;
185
+ cache: StorefrontCacheInput;
140
186
  waitUntil: (promise: Promise<unknown>) => void;
141
187
  i18n?: I18n | undefined;
142
188
  publicStorefrontToken: string;
143
189
  privateStorefrontToken?: string | undefined;
144
190
  storeDomain: string;
145
191
  storefrontId?: string | undefined;
146
- storefrontHeaders?: HeadersInit | undefined;
192
+ storefrontHeaders?: StorefrontHeadersInit | undefined;
147
193
  storefrontApiVersion?: string | undefined;
148
194
  fetch?: typeof fetch | undefined;
149
195
  defaultStrategy?: CacheStrategy | undefined;
196
+ queryTimeoutMs?: number | undefined;
150
197
  }
151
198
  /**
152
199
  * Typed GraphQL client mirroring Hydrogen's `createStorefrontClient`. Queries are SWR-cached
@@ -156,4 +203,4 @@ interface HydrogenStorefrontClientOptions<I18n extends object = StorefrontI18n>
156
203
  declare function createStorefrontClient(opts: StorefrontClientOptions): StorefrontClientResult;
157
204
  declare function createStorefrontClient<I18n extends object = StorefrontI18n>(opts: HydrogenStorefrontClientOptions<I18n>): StorefrontClientResult<StorefrontI18n & I18n>;
158
205
 
159
- export { type CacheStrategy as C, type HydrogenStorefrontClientOptions as H, type KotaoCache as K, type StorefrontAuthHeader as S, type StorefrontClient as a, CacheCustom as b, CacheLong as c, CacheNone as d, CacheShort as e, type Storefront as f, type StorefrontClientOptions as g, type StorefrontClientResult as h, StorefrontDefaultCache as i, type StorefrontQueryOptions as j, createCache as k, createStorefrontClient as l, generateCacheControlHeader as m };
206
+ export { type CacheStrategy as C, type HydrogenStorefrontClientOptions as H, type KotaoCache as K, type StorefrontClient as S, type StorefrontAuthHeader as a, type StorefrontCacheInput as b, CacheCustom as c, CacheLong as d, CacheNone as e, CacheShort as f, type StaleIfErrorFallback as g, type Storefront as h, type StorefrontCache as i, type StorefrontCacheQueryOptions as j, type StorefrontCacheRequest as k, type StorefrontClientOptions as l, type StorefrontClientResult as m, StorefrontDefaultCache as n, type StorefrontQueryOptions as o, StorefrontQueryTimeoutError as p, StorefrontUpstreamError as q, createCache as r, createStorefrontClient as s, generateCacheControlHeader as t };
@@ -0,0 +1,159 @@
1
+ import { F as FormVersionSchema } from './types-CSNXbGFW.js';
2
+ import { S as StorefrontHeadersInit } from './http-types-CGh8WGHB.js';
3
+
4
+ type EventRegistrationMode = 'instant' | 'approval_then_payment' | 'waitlist_only';
5
+ interface PublicEventVenue {
6
+ readonly name?: string | undefined;
7
+ readonly addressLine1?: string | undefined;
8
+ readonly addressLine2?: string | undefined;
9
+ readonly postalCode?: string | undefined;
10
+ readonly city?: string | undefined;
11
+ readonly countryCode?: string | undefined;
12
+ readonly notes?: string | undefined;
13
+ }
14
+ interface PublicEventForm {
15
+ readonly definitionId: string;
16
+ readonly versionId: string;
17
+ readonly title: string;
18
+ readonly schema: FormVersionSchema;
19
+ }
20
+ interface PublicEventTicketType {
21
+ readonly id: string;
22
+ readonly title: string;
23
+ readonly description: string | null;
24
+ readonly price: number;
25
+ readonly currency: string;
26
+ readonly availability: 'unlimited' | 'limited';
27
+ readonly available: number | null;
28
+ readonly minPerOrder: number;
29
+ readonly maxPerOrder: number;
30
+ readonly admissionMode: 'ticketed' | 'registration_only';
31
+ readonly salesState: 'upcoming' | 'on_sale' | 'paused' | 'sold_out' | 'ended';
32
+ readonly buyerForm: PublicEventForm | null;
33
+ readonly participantForm: PublicEventForm | null;
34
+ }
35
+ interface PublicEventOccurrence {
36
+ readonly id: string;
37
+ readonly startsAt: string;
38
+ readonly endsAt: string;
39
+ readonly timezone: string;
40
+ readonly venue: PublicEventVenue;
41
+ readonly ticketTypes: readonly PublicEventTicketType[];
42
+ }
43
+ interface PublicEvent {
44
+ readonly id: string;
45
+ readonly handle: string;
46
+ readonly title: string;
47
+ readonly description: string | null;
48
+ readonly registrationMode: EventRegistrationMode;
49
+ readonly venue: PublicEventVenue;
50
+ readonly occurrences: readonly PublicEventOccurrence[];
51
+ }
52
+ type EventFormAnswer = string | number | boolean | string[] | Record<string, string>;
53
+ interface EventFormSubmissionInput {
54
+ readonly versionId: string;
55
+ readonly answers: Readonly<Record<string, EventFormAnswer>>;
56
+ }
57
+ interface CreateEventCheckoutSession {
58
+ readonly ticketTypeId: string;
59
+ readonly quantity: number;
60
+ readonly cartToken: string;
61
+ readonly locale: string;
62
+ readonly buyer?: EventFormSubmissionInput;
63
+ readonly participants?: readonly EventFormSubmissionInput[];
64
+ readonly waitlistOffer?: {
65
+ readonly offerId: string;
66
+ readonly claimToken: string;
67
+ };
68
+ }
69
+ interface EventCheckoutSession {
70
+ readonly id: string;
71
+ readonly ticketTypeId: string;
72
+ readonly occurrenceId: string;
73
+ readonly quantity: number;
74
+ readonly state: 'draft' | 'ready' | 'cart_linked' | 'order_pending' | 'converted' | 'expired' | 'cancelled';
75
+ readonly expiresAt: string;
76
+ readonly createdAt: string;
77
+ readonly updatedAt: string;
78
+ }
79
+ interface CreateEventApprovalRequest {
80
+ readonly ticketTypeId: string;
81
+ readonly quantity: number;
82
+ readonly contactEmail: string;
83
+ readonly locale: string;
84
+ readonly buyer?: EventFormSubmissionInput;
85
+ readonly participants?: readonly EventFormSubmissionInput[];
86
+ }
87
+ interface EventApprovalRequestReceipt {
88
+ readonly id: string;
89
+ readonly state: 'awaiting_approval';
90
+ }
91
+ interface EventApprovalOfferResolution {
92
+ readonly offerId: string;
93
+ readonly state: 'active' | 'claimed';
94
+ readonly eventTitle: string;
95
+ readonly occurrenceStartsAt: string;
96
+ readonly ticketTypeTitle: string;
97
+ readonly quantity: number;
98
+ readonly expiresAt: string;
99
+ }
100
+ interface ClaimEventApprovalOffer {
101
+ readonly claimToken: string;
102
+ readonly cartToken: string;
103
+ readonly locale: string;
104
+ }
105
+ interface CreateEventWaitlistEntry {
106
+ readonly ticketTypeId: string;
107
+ readonly quantity: number;
108
+ readonly email: string;
109
+ }
110
+ interface EventWaitlistReceipt {
111
+ readonly id: string;
112
+ readonly state: 'waitlisted';
113
+ }
114
+ type EventRegistrationSubmission = {
115
+ readonly registrationMode: 'instant';
116
+ readonly handle: string;
117
+ readonly input: CreateEventCheckoutSession;
118
+ readonly idempotencyKey: string;
119
+ } | {
120
+ readonly registrationMode: 'approval_then_payment';
121
+ readonly handle: string;
122
+ readonly input: CreateEventApprovalRequest;
123
+ readonly idempotencyKey: string;
124
+ } | {
125
+ readonly registrationMode: 'waitlist_only';
126
+ readonly handle: string;
127
+ readonly input: CreateEventWaitlistEntry;
128
+ };
129
+ type EventRegistrationResult = {
130
+ readonly kind: 'checkout';
131
+ readonly checkoutSession: EventCheckoutSession;
132
+ } | {
133
+ readonly kind: 'approval';
134
+ readonly receipt: EventApprovalRequestReceipt;
135
+ } | {
136
+ readonly kind: 'waitlist';
137
+ readonly receipt: EventWaitlistReceipt;
138
+ };
139
+
140
+ interface EventsClient {
141
+ getEvent(handle: string): Promise<PublicEvent>;
142
+ createCheckoutSession(handle: string, input: CreateEventCheckoutSession, idempotencyKey: string): Promise<EventCheckoutSession>;
143
+ submitApplication(handle: string, input: CreateEventApprovalRequest, idempotencyKey: string): Promise<EventApprovalRequestReceipt>;
144
+ joinWaitlist(handle: string, input: CreateEventWaitlistEntry): Promise<EventWaitlistReceipt>;
145
+ submitRegistration(input: EventRegistrationSubmission): Promise<EventRegistrationResult>;
146
+ resolveOffer(offerId: string, claimToken: string, idempotencyKey?: string): Promise<EventApprovalOfferResolution>;
147
+ claimOffer(offerId: string, input: ClaimEventApprovalOffer, idempotencyKey: string): Promise<EventCheckoutSession>;
148
+ }
149
+ declare class StorefrontEventsRequestError extends Error {
150
+ readonly status: number;
151
+ constructor(status: number);
152
+ }
153
+ declare function createEventsClient(input: {
154
+ readonly baseUrl: string;
155
+ readonly fetch: typeof globalThis.fetch;
156
+ readonly defaultHeaders?: StorefrontHeadersInit;
157
+ }): EventsClient;
158
+
159
+ export { type ClaimEventApprovalOffer as C, type EventsClient as E, type PublicEvent as P, StorefrontEventsRequestError as S, type EventCheckoutSession as a, type EventApprovalOfferResolution as b, type EventRegistrationSubmission as c, type CreateEventApprovalRequest as d, type CreateEventCheckoutSession as e, type CreateEventWaitlistEntry as f, type EventApprovalRequestReceipt as g, type EventFormAnswer as h, type EventFormSubmissionInput as i, type EventRegistrationMode as j, type EventRegistrationResult as k, type EventWaitlistReceipt as l, type PublicEventForm as m, type PublicEventOccurrence as n, type PublicEventTicketType as o, type PublicEventVenue as p, createEventsClient as q };
@@ -0,0 +1,58 @@
1
+ import { S as StorefrontClient } from './client-D51WdvYR.js';
2
+ import { C as Cart, a as CartLineInput, b as CartAttribute, c as CartBuyerIdentityInput, d as CartMutationResult, e as CartLineUpdateInput, f as CartMetafield, g as CartMetafieldIdentifier, h as CartDeliveryAddress, i as CartSelectedDeliveryOption, j as CartFormAction } from './types-bcbQzx87.js';
3
+
4
+ interface CartCreateInput {
5
+ readonly lines?: readonly CartLineInput[];
6
+ readonly note?: string | null;
7
+ readonly attributes?: readonly CartAttribute[];
8
+ readonly buyerIdentity?: CartBuyerIdentityInput;
9
+ }
10
+ interface CartDispatchAction {
11
+ readonly action: CartFormAction;
12
+ readonly inputs: Record<string, unknown>;
13
+ }
14
+ interface CartHandler {
15
+ get(): Promise<Cart | null>;
16
+ getCart(): Promise<Cart | null>;
17
+ create(input?: CartCreateInput): Promise<CartMutationResult>;
18
+ addLines(lines: readonly CartLineInput[]): Promise<CartMutationResult>;
19
+ updateLines(lines: readonly CartLineUpdateInput[]): Promise<CartMutationResult>;
20
+ removeLines(lineIds: readonly string[]): Promise<CartMutationResult>;
21
+ updateBuyerIdentity(buyerIdentity: CartBuyerIdentityInput): Promise<CartMutationResult>;
22
+ updateDiscountCodes(discountCodes: readonly string[]): Promise<CartMutationResult>;
23
+ setCartId(cartId: string): Headers;
24
+ cartCreate(input?: CartCreateInput): Promise<CartMutationResult>;
25
+ linesAdd(lines: readonly CartLineInput[]): Promise<CartMutationResult>;
26
+ linesUpdate(lines: readonly CartLineUpdateInput[]): Promise<CartMutationResult>;
27
+ linesRemove(lineIds: readonly string[]): Promise<CartMutationResult>;
28
+ buyerIdentityUpdate(buyerIdentity: CartBuyerIdentityInput): Promise<CartMutationResult>;
29
+ discountCodesUpdate(discountCodes: readonly string[]): Promise<CartMutationResult>;
30
+ giftCardCodesAdd(giftCardCodes: readonly string[]): Promise<CartMutationResult>;
31
+ giftCardCodesRemove(giftCardCodes: readonly string[]): Promise<CartMutationResult>;
32
+ noteUpdate(note: string | null): Promise<CartMutationResult>;
33
+ attributesUpdate(attributes: readonly CartAttribute[]): Promise<CartMutationResult>;
34
+ metafieldsSet(metafields: readonly CartMetafield[]): Promise<CartMutationResult>;
35
+ metafieldsDelete(metafields: readonly CartMetafieldIdentifier[]): Promise<CartMutationResult>;
36
+ deliveryAddressesReplace(addresses: readonly CartDeliveryAddress[]): Promise<CartMutationResult>;
37
+ selectedDeliveryOptionsUpdate(selectedDeliveryOptions: readonly CartSelectedDeliveryOption[]): Promise<CartMutationResult>;
38
+ dispatch(action: CartDispatchAction): Promise<CartMutationResult>;
39
+ }
40
+ type MaybePromise<T> = T | Promise<T>;
41
+ type CartGetId = () => MaybePromise<string | null | undefined>;
42
+ type CartSetId = (cartId: string) => MaybePromise<string | Headers | null | undefined | void>;
43
+ interface RequestCartHandlerOptions {
44
+ request: Request;
45
+ storefront: StorefrontClient;
46
+ }
47
+ interface HydrogenCartHandlerOptions {
48
+ storefront: StorefrontClient;
49
+ customerAccount?: unknown;
50
+ getCartId: CartGetId;
51
+ setCartId: CartSetId;
52
+ }
53
+ type CreateCartHandlerOptions = RequestCartHandlerOptions | HydrogenCartHandlerOptions;
54
+ declare function cartGetIdDefault(headers: Headers): CartGetId;
55
+ declare function cartSetIdDefault(): CartSetId;
56
+ declare function createCartHandler(opts: CreateCartHandlerOptions): CartHandler;
57
+
58
+ export { type CartHandler as C, type HydrogenCartHandlerOptions as H, type RequestCartHandlerOptions as R, type CartDispatchAction as a, type CartGetId as b, type CartSetId as c, type CreateCartHandlerOptions as d, cartGetIdDefault as e, cartSetIdDefault as f, createCartHandler as g };
package/dist/editor.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { c as ThemeSettingsStore, b as ResolvedSettings, a as ResolvedSection, R as ResolvedBlock } from './store-DQK1nhob.js';
1
+ import { T as ThemeSettingsStore, R as ResolvedSettings, c as ResolvedSection, b as ResolvedBlock } from './store-CtCWHI8H.js';
2
2
 
3
3
  interface StorefrontEditorMessageTarget {
4
4
  postMessage(message: unknown, targetOrigin: string): void;
@@ -0,0 +1,68 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { O as OfferTokenLocation, a as OfferTokenHistory } from './offer-token-C-nk_nj8.js';
4
+ import { E as EventsClient, a as EventCheckoutSession, b as EventApprovalOfferResolution, P as PublicEvent, c as EventRegistrationSubmission } from './client-bsiNPHBi.js';
5
+ import './types-CSNXbGFW.js';
6
+ import './http-types-CGh8WGHB.js';
7
+
8
+ type EventRegistrationState = 'idle' | 'submitting' | 'awaiting_approval' | 'waitlisted' | 'checkout_ready' | 'request_error';
9
+ declare function useEventRegistration(input: {
10
+ readonly client: EventsClient;
11
+ readonly onCheckoutSession?: (session: EventCheckoutSession) => void;
12
+ }): {
13
+ readonly state: EventRegistrationState;
14
+ readonly submit: (submission: EventRegistrationSubmission) => Promise<void>;
15
+ readonly reset: () => void;
16
+ };
17
+ interface EventRegistrationLabels {
18
+ readonly submit: string;
19
+ readonly submitting: string;
20
+ readonly awaiting_approval: string;
21
+ readonly waitlisted: string;
22
+ readonly checkout_ready: string;
23
+ readonly request_error: string;
24
+ readonly email: string;
25
+ readonly quantity: string;
26
+ readonly ticket: string;
27
+ }
28
+ interface EventRegistrationFormProps {
29
+ readonly event: PublicEvent;
30
+ readonly locale: string;
31
+ readonly client: EventsClient;
32
+ readonly cartToken?: string;
33
+ readonly fallbackLocale?: string;
34
+ readonly onCheckoutSession?: (session: EventCheckoutSession) => void;
35
+ readonly labels?: Partial<EventRegistrationLabels>;
36
+ readonly className?: string;
37
+ }
38
+ declare function EventRegistrationForm({ event, locale, client, cartToken, fallbackLocale, onCheckoutSession, labels, className, }: EventRegistrationFormProps): react.JSX.Element;
39
+ type EventOfferState = 'resolving' | 'active' | 'claiming' | 'claimed' | 'expired' | 'unavailable' | 'request_error';
40
+ interface EventApprovalOfferLabels {
41
+ readonly resolving: ReactNode;
42
+ readonly claim: ReactNode;
43
+ readonly resume: ReactNode;
44
+ readonly claiming: ReactNode;
45
+ readonly claimed: ReactNode;
46
+ readonly expired: ReactNode;
47
+ readonly unavailable: ReactNode;
48
+ readonly requestError: ReactNode;
49
+ readonly retry?: ReactNode;
50
+ readonly expires: ReactNode;
51
+ }
52
+ interface EventApprovalOfferProps {
53
+ readonly client: EventsClient;
54
+ readonly offerId: string;
55
+ readonly cartToken: string;
56
+ readonly locale: string;
57
+ readonly idempotencyKey?: string;
58
+ readonly location?: OfferTokenLocation;
59
+ readonly history?: OfferTokenHistory;
60
+ readonly labels?: Partial<EventApprovalOfferLabels>;
61
+ readonly onCheckoutSession?: (session: EventCheckoutSession) => void;
62
+ readonly initialResolution?: EventApprovalOfferResolution;
63
+ readonly initialState?: Exclude<EventOfferState, 'resolving' | 'active' | 'claiming'>;
64
+ readonly className?: string;
65
+ }
66
+ declare function EventApprovalOffer({ client, offerId, cartToken, locale, idempotencyKey, location, history, labels, onCheckoutSession, initialResolution, initialState, className, }: EventApprovalOfferProps): react.JSX.Element;
67
+
68
+ export { EventApprovalOffer, type EventApprovalOfferLabels, type EventApprovalOfferProps, type EventOfferState, EventRegistrationForm, type EventRegistrationFormProps, type EventRegistrationLabels, type EventRegistrationState, useEventRegistration };