@suiteop/storefront 0.4.0 → 0.6.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/CHANGELOG.md +56 -0
- package/README.md +9 -2
- package/dist/astro-content-model.cjs +5 -5
- package/dist/astro-content-model.js +4 -4
- package/dist/astro.cjs +1 -1
- package/dist/astro.d.cts +66 -1
- package/dist/astro.d.ts +66 -1
- package/dist/astro.js +1 -1
- package/dist/availability.d-Cla9GuGc.d.cts +84 -0
- package/dist/availability.d-Cla9GuGc.d.ts +84 -0
- package/dist/checkout.cjs +4 -4
- package/dist/checkout.d.cts +11 -0
- package/dist/checkout.d.ts +11 -0
- package/dist/checkout.js +3 -3
- package/dist/{chunk-TLTL7M3O.js → chunk-3B6ZYRYF.js} +2 -2
- package/dist/chunk-3NE27PHL.cjs +19 -0
- package/dist/{chunk-HMLBMNGA.js → chunk-7ZAI36LH.js} +1 -1
- package/dist/{chunk-LVFRVNT3.cjs → chunk-EHQFWSP6.cjs} +2 -1
- package/dist/{chunk-6NFURJXI.js → chunk-IBCBDAGY.js} +2 -2
- package/dist/{chunk-USOISC2R.cjs → chunk-J5FZ4WDQ.cjs} +2 -2
- package/dist/chunk-JF245QUY.cjs +9 -0
- package/dist/{chunk-IUJTHNB3.cjs → chunk-OXCLLFCY.cjs} +3 -3
- package/dist/chunk-QBHOJGZI.cjs +21 -0
- package/dist/{chunk-VV2UNVQ2.cjs → chunk-UMCI4YBN.cjs} +2 -2
- package/dist/chunk-UQWQPTHO.js +3 -0
- package/dist/{chunk-ZI2PG7LS.js → chunk-W5K7IDYN.js} +1 -1
- package/dist/chunk-XOCFEVP4.js +6 -0
- package/dist/chunk-YIYGBTAM.js +9 -0
- package/dist/{client-oyYRhUv0.d.ts → client-CX8K7JNt.d.cts} +108 -20
- package/dist/{client-CZWN4im4.d.cts → client-s-lEwqzc.d.ts} +108 -20
- package/dist/components.cjs +2 -2
- package/dist/components.d.cts +43 -1
- package/dist/components.d.ts +43 -1
- package/dist/components.js +1 -1
- package/dist/config.cjs +10 -3
- package/dist/config.d.cts +240 -79
- package/dist/config.d.ts +240 -79
- package/dist/config.js +4 -4
- package/dist/content.cjs +11 -11
- package/dist/content.d.cts +53 -9
- package/dist/content.d.ts +53 -9
- package/dist/content.js +4 -4
- package/dist/{errors-CAW7nLHr.d.cts → errors-Oax7djdp.d.ts} +54 -13
- package/dist/{errors-DoXdi1vS.d.ts → errors-welPvrD6.d.cts} +54 -13
- package/dist/index.cjs +22 -22
- package/dist/index.d.cts +27 -8
- package/dist/index.d.ts +27 -8
- package/dist/index.js +5 -5
- package/dist/react.cjs +7 -7
- package/dist/react.d.cts +24 -3
- package/dist/react.d.ts +24 -3
- package/dist/react.js +6 -6
- package/package.json +1 -1
- package/dist/availability-CnzmxuV3.d.cts +0 -60
- package/dist/availability-CnzmxuV3.d.ts +0 -60
- package/dist/chunk-CTHHMNLE.cjs +0 -19
- package/dist/chunk-E5CGGMCO.cjs +0 -19
- package/dist/chunk-PYVUDQSQ.js +0 -3
- package/dist/chunk-TRXDDUEL.js +0 -5
- package/dist/chunk-UWUKERLK.js +0 -9
- package/dist/chunk-ZLAOY6IF.cjs +0 -9
|
@@ -1,100 +1,131 @@
|
|
|
1
|
-
import { B as BookingResult,
|
|
1
|
+
import { B as BookingResult, z as StorefrontQuote } from './client-CX8K7JNt.cjs';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
|
|
4
4
|
declare const storefrontClientEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
5
|
-
name: z.ZodLiteral<"page_view">;
|
|
6
5
|
eventId: z.ZodUUID;
|
|
7
6
|
ts: z.ZodNumber;
|
|
8
7
|
path: z.ZodString;
|
|
9
8
|
referrerHost: z.ZodNullable<z.ZodString>;
|
|
9
|
+
name: z.ZodLiteral<"page_view">;
|
|
10
10
|
}, z.core.$strip>, z.ZodObject<{
|
|
11
|
+
eventId: z.ZodUUID;
|
|
12
|
+
ts: z.ZodNumber;
|
|
13
|
+
path: z.ZodString;
|
|
14
|
+
referrerHost: z.ZodNullable<z.ZodString>;
|
|
11
15
|
name: z.ZodLiteral<"view_search_results">;
|
|
12
16
|
checkIn: z.ZodOptional<z.ZodISODate>;
|
|
13
17
|
checkOut: z.ZodOptional<z.ZodISODate>;
|
|
14
18
|
guests: z.ZodOptional<z.ZodNumber>;
|
|
15
19
|
locationId: z.ZodOptional<z.ZodUUID>;
|
|
20
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
16
21
|
eventId: z.ZodUUID;
|
|
17
22
|
ts: z.ZodNumber;
|
|
18
23
|
path: z.ZodString;
|
|
19
24
|
referrerHost: z.ZodNullable<z.ZodString>;
|
|
20
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
21
25
|
name: z.ZodLiteral<"view_item_list">;
|
|
22
26
|
listName: z.ZodString;
|
|
23
27
|
itemCount: z.ZodNumber;
|
|
28
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
24
29
|
eventId: z.ZodUUID;
|
|
25
30
|
ts: z.ZodNumber;
|
|
26
31
|
path: z.ZodString;
|
|
27
32
|
referrerHost: z.ZodNullable<z.ZodString>;
|
|
28
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
29
33
|
name: z.ZodLiteral<"view_item">;
|
|
30
34
|
listingId: z.ZodUUID;
|
|
35
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
31
36
|
eventId: z.ZodUUID;
|
|
32
37
|
ts: z.ZodNumber;
|
|
33
38
|
path: z.ZodString;
|
|
34
39
|
referrerHost: z.ZodNullable<z.ZodString>;
|
|
35
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
36
40
|
name: z.ZodLiteral<"view_quote">;
|
|
37
41
|
listingId: z.ZodUUID;
|
|
38
42
|
valueMinor: z.ZodNumber;
|
|
39
43
|
currency: z.ZodString;
|
|
40
44
|
nights: z.ZodNumber;
|
|
45
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
41
46
|
eventId: z.ZodUUID;
|
|
42
47
|
ts: z.ZodNumber;
|
|
43
48
|
path: z.ZodString;
|
|
44
49
|
referrerHost: z.ZodNullable<z.ZodString>;
|
|
45
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
46
50
|
name: z.ZodLiteral<"begin_checkout">;
|
|
47
51
|
checkoutSessionId: z.ZodUUID;
|
|
52
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
48
53
|
eventId: z.ZodUUID;
|
|
49
54
|
ts: z.ZodNumber;
|
|
50
55
|
path: z.ZodString;
|
|
51
56
|
referrerHost: z.ZodNullable<z.ZodString>;
|
|
52
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
53
57
|
name: z.ZodLiteral<"add_payment_info">;
|
|
54
58
|
checkoutSessionId: z.ZodUUID;
|
|
59
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
55
60
|
eventId: z.ZodUUID;
|
|
56
61
|
ts: z.ZodNumber;
|
|
57
62
|
path: z.ZodString;
|
|
58
63
|
referrerHost: z.ZodNullable<z.ZodString>;
|
|
59
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
60
64
|
name: z.ZodLiteral<"generate_lead">;
|
|
61
65
|
formId: z.ZodOptional<z.ZodString>;
|
|
66
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
62
67
|
eventId: z.ZodUUID;
|
|
63
68
|
ts: z.ZodNumber;
|
|
64
69
|
path: z.ZodString;
|
|
65
70
|
referrerHost: z.ZodNullable<z.ZodString>;
|
|
66
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
67
71
|
name: z.ZodLiteral<"sign_up">;
|
|
68
72
|
method: z.ZodLiteral<"newsletter">;
|
|
69
|
-
eventId: z.ZodUUID;
|
|
70
|
-
ts: z.ZodNumber;
|
|
71
|
-
path: z.ZodString;
|
|
72
|
-
referrerHost: z.ZodNullable<z.ZodString>;
|
|
73
73
|
}, z.core.$strip>], "name">;
|
|
74
74
|
type StorefrontClientEvent = z.infer<typeof storefrontClientEventSchema>;
|
|
75
75
|
|
|
76
76
|
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
77
|
+
/**
|
|
78
|
+
* An event as a page tracks it: the SDK fills `eventId`, `ts`, `path` and `referrerHost`.
|
|
79
|
+
* `purchase` is not among them — revenue is written by the server when a booking confirms.
|
|
80
|
+
*/
|
|
77
81
|
type TrackEvent = DistributiveOmit<StorefrontClientEvent, 'eventId' | 'ts' | 'path' | 'referrerHost'>;
|
|
82
|
+
/** Called once per analytics instance, on the first failed send. */
|
|
78
83
|
type AnalyticsReporter = (err: unknown) => void;
|
|
79
84
|
interface AnalyticsOptions {
|
|
85
|
+
/** The site's publishable key — sent as `?key=` (`navigator.sendBeacon` cannot set headers). */
|
|
80
86
|
publishableKey: string;
|
|
81
87
|
report?: AnalyticsReporter;
|
|
82
88
|
}
|
|
83
89
|
interface StorefrontAnalytics {
|
|
84
90
|
track(event: TrackEvent): void;
|
|
91
|
+
/** A `page_view` of the current location. */
|
|
85
92
|
pageView(): void;
|
|
93
|
+
/** Send what is queued now; `beacon` for a page that is going away. */
|
|
86
94
|
flush(opts?: {
|
|
87
95
|
beacon?: boolean;
|
|
88
96
|
}): void;
|
|
89
97
|
dispose(): void;
|
|
90
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* The Meta Pixel `Purchase` for a confirmed booking, under ads consent only, with the booking
|
|
101
|
+
* request id as `eventID` — the same `event_id` the server's Conversions API purchase carries, so
|
|
102
|
+
* Meta keeps one. `value` / `currency` are sent when the caller has the amount (minor units,
|
|
103
|
+
* ×100). Never sent to gtag: GA4 and Google Ads get purchase from the server only.
|
|
104
|
+
*/
|
|
91
105
|
declare function trackPurchasePixel(booking: Pick<BookingResult, 'bookingRequestId'> & {
|
|
92
106
|
totalMinor?: number | null;
|
|
93
107
|
currency?: string | null;
|
|
94
108
|
}): void;
|
|
109
|
+
/**
|
|
110
|
+
* Storefront analytics: batches GA4-aligned events in memory and posts them to the
|
|
111
|
+
* storefront edge every 2 s, at 10 events, and on `pagehide` (`navigator.sendBeacon`, else
|
|
112
|
+
* `fetch` with `keepalive`). Sent regardless of consent: the edge stores labels only — no IP, no
|
|
113
|
+
* user agent, no identifier — and nothing here reads or writes a cookie or web storage. Each
|
|
114
|
+
* event is also mirrored to the site's client tags (`gtag` / `fbq`) when the consent allows.
|
|
115
|
+
* A 404 means the site is not behind the SuiteOp edge: the instance goes quiet.
|
|
116
|
+
*/
|
|
95
117
|
declare function createAnalytics(opts: AnalyticsOptions): StorefrontAnalytics;
|
|
118
|
+
/**
|
|
119
|
+
* The document's one analytics instance for a publishable key. It outlives any component — an
|
|
120
|
+
* Astro island unmounted by a view transition keeps its queue — and flushes on `pagehide`.
|
|
121
|
+
*/
|
|
96
122
|
declare function analyticsFor(publishableKey: string): StorefrontAnalytics;
|
|
97
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Every `error.code` the Storefront API answers, the codes the SuiteOp storefront edge answers,
|
|
126
|
+
* and the SDK's own.
|
|
127
|
+
* `StorefrontError.code` stays `string`, so a code a newer API adds degrades, never throws.
|
|
128
|
+
*/
|
|
98
129
|
declare const STOREFRONT_ERROR_CODES: readonly ["wrong_region", "origin_not_allowed", "origin_required", "site_archived", "not_bookable", "quote_invalid", "quote_expired", "price_changed", "currency_unsupported", "payment_declined", "session_expired", "rate_limited", "contact_not_configured", "payment_account_unavailable", "idempotency_key_required", "idempotency_key_reused", "payment_mode_unsupported", "payment_not_authorized", "payment_method_required", "site_not_published", "preview_read_only", "bookings_closed", "extras_invalid", "UNAUTHORIZED", "VALIDATION_ERROR", "NOT_FOUND", "site_not_found", "upstream_timeout", "timeout", "network", "invalid_response", "internal_error", "checkout_unavailable"];
|
|
99
130
|
type StorefrontErrorCode = (typeof STOREFRONT_ERROR_CODES)[number];
|
|
100
131
|
type StorefrontRegion = 'us' | 'eu' | 'apac';
|
|
@@ -107,27 +138,36 @@ interface StorefrontErrorInit {
|
|
|
107
138
|
details?: Record<string, unknown>;
|
|
108
139
|
cause?: unknown;
|
|
109
140
|
}
|
|
141
|
+
/** Any failure the client reports: an API refusal, a malformed answer, a timeout, the network. */
|
|
110
142
|
declare class StorefrontError extends Error {
|
|
111
143
|
name: string;
|
|
144
|
+
/** HTTP status; 0 when no response arrived (timeout, network). */
|
|
112
145
|
readonly status: number;
|
|
113
146
|
readonly type: string;
|
|
147
|
+
/** `StorefrontErrorCode` for every code this version knows; any string for newer ones. */
|
|
114
148
|
readonly code: StorefrontErrorCode | (string & {});
|
|
115
149
|
readonly requestId: string | null;
|
|
116
150
|
readonly details: Record<string, unknown>;
|
|
117
151
|
constructor(init: StorefrontErrorInit);
|
|
118
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* `price_changed` (409). At checkout-session creation `quote` is the fresh quote to show the
|
|
155
|
+
* guest; at confirm it is null and `requiresNewSession` is true — start a new checkout.
|
|
156
|
+
*/
|
|
119
157
|
declare class PriceChangedError extends StorefrontError {
|
|
120
158
|
name: string;
|
|
121
159
|
readonly quote: StorefrontQuote | null;
|
|
122
160
|
readonly requiresNewSession: boolean;
|
|
123
161
|
constructor(init: StorefrontErrorInit);
|
|
124
162
|
}
|
|
163
|
+
/** `wrong_region` (421): the key belongs to another region. `baseUrl` is null when the API could not name it. */
|
|
125
164
|
declare class WrongRegionError extends StorefrontError {
|
|
126
165
|
name: string;
|
|
127
166
|
readonly region: StorefrontRegion | null;
|
|
128
167
|
readonly baseUrl: string | null;
|
|
129
168
|
constructor(init: StorefrontErrorInit);
|
|
130
169
|
}
|
|
170
|
+
/** `rate_limited` (429). `scope` names the budget: this key, this visitor's IP, or the PMS account. */
|
|
131
171
|
declare class RateLimitedError extends StorefrontError {
|
|
132
172
|
name: string;
|
|
133
173
|
readonly retryAfterSec: number | null;
|
|
@@ -144,6 +184,7 @@ declare class StorefrontNetworkError extends StorefrontError {
|
|
|
144
184
|
name: string;
|
|
145
185
|
constructor(cause: unknown);
|
|
146
186
|
}
|
|
187
|
+
/** A mistake in how the SDK is set up (bad key, bad base URL, hook outside its provider). */
|
|
147
188
|
declare class StorefrontConfigError extends Error {
|
|
148
189
|
name: string;
|
|
149
190
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk3NE27PHL_cjs = require('./chunk-3NE27PHL.cjs');
|
|
4
4
|
var chunkEVSAMV5K_cjs = require('./chunk-EVSAMV5K.cjs');
|
|
5
|
-
require('./chunk-
|
|
6
|
-
require('./chunk-
|
|
7
|
-
var
|
|
8
|
-
require('./chunk-
|
|
5
|
+
require('./chunk-JF245QUY.cjs');
|
|
6
|
+
require('./chunk-QBHOJGZI.cjs');
|
|
7
|
+
var chunkJ5FZ4WDQ_cjs = require('./chunk-J5FZ4WDQ.cjs');
|
|
8
|
+
require('./chunk-EHQFWSP6.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
Object.defineProperty(exports, "SDK_VERSION", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunk3NE27PHL_cjs.SDK_VERSION; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "STOREFRONT_API_PATH", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunk3NE27PHL_cjs.STOREFRONT_API_PATH; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "STOREFRONT_API_VERSION", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunk3NE27PHL_cjs.STOREFRONT_API_VERSION; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "analyticsFor", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunk3NE27PHL_cjs.analyticsFor; }
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports, "createAnalytics", {
|
|
29
29
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunk3NE27PHL_cjs.createAnalytics; }
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "createStorefrontClient", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunk3NE27PHL_cjs.createStorefrontClient; }
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "getAttribution", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunk3NE27PHL_cjs.getAttribution; }
|
|
39
39
|
});
|
|
40
40
|
Object.defineProperty(exports, "parsePublishableKey", {
|
|
41
41
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
42
|
+
get: function () { return chunk3NE27PHL_cjs.parsePublishableKey; }
|
|
43
43
|
});
|
|
44
44
|
Object.defineProperty(exports, "trackPurchasePixel", {
|
|
45
45
|
enumerable: true,
|
|
46
|
-
get: function () { return
|
|
46
|
+
get: function () { return chunk3NE27PHL_cjs.trackPurchasePixel; }
|
|
47
47
|
});
|
|
48
48
|
Object.defineProperty(exports, "IMAGE_WIDTHS", {
|
|
49
49
|
enumerable: true,
|
|
@@ -63,33 +63,33 @@ Object.defineProperty(exports, "imageUrl", {
|
|
|
63
63
|
});
|
|
64
64
|
Object.defineProperty(exports, "PriceChangedError", {
|
|
65
65
|
enumerable: true,
|
|
66
|
-
get: function () { return
|
|
66
|
+
get: function () { return chunkJ5FZ4WDQ_cjs.PriceChangedError; }
|
|
67
67
|
});
|
|
68
68
|
Object.defineProperty(exports, "RateLimitedError", {
|
|
69
69
|
enumerable: true,
|
|
70
|
-
get: function () { return
|
|
70
|
+
get: function () { return chunkJ5FZ4WDQ_cjs.RateLimitedError; }
|
|
71
71
|
});
|
|
72
72
|
Object.defineProperty(exports, "STOREFRONT_ERROR_CODES", {
|
|
73
73
|
enumerable: true,
|
|
74
|
-
get: function () { return
|
|
74
|
+
get: function () { return chunkJ5FZ4WDQ_cjs.STOREFRONT_ERROR_CODES; }
|
|
75
75
|
});
|
|
76
76
|
Object.defineProperty(exports, "StorefrontConfigError", {
|
|
77
77
|
enumerable: true,
|
|
78
|
-
get: function () { return
|
|
78
|
+
get: function () { return chunkJ5FZ4WDQ_cjs.StorefrontConfigError; }
|
|
79
79
|
});
|
|
80
80
|
Object.defineProperty(exports, "StorefrontError", {
|
|
81
81
|
enumerable: true,
|
|
82
|
-
get: function () { return
|
|
82
|
+
get: function () { return chunkJ5FZ4WDQ_cjs.StorefrontError; }
|
|
83
83
|
});
|
|
84
84
|
Object.defineProperty(exports, "StorefrontNetworkError", {
|
|
85
85
|
enumerable: true,
|
|
86
|
-
get: function () { return
|
|
86
|
+
get: function () { return chunkJ5FZ4WDQ_cjs.StorefrontNetworkError; }
|
|
87
87
|
});
|
|
88
88
|
Object.defineProperty(exports, "StorefrontTimeoutError", {
|
|
89
89
|
enumerable: true,
|
|
90
|
-
get: function () { return
|
|
90
|
+
get: function () { return chunkJ5FZ4WDQ_cjs.StorefrontTimeoutError; }
|
|
91
91
|
});
|
|
92
92
|
Object.defineProperty(exports, "WrongRegionError", {
|
|
93
93
|
enumerable: true,
|
|
94
|
-
get: function () { return
|
|
94
|
+
get: function () { return chunkJ5FZ4WDQ_cjs.WrongRegionError; }
|
|
95
95
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { S as StorefrontRegion } from './errors-
|
|
2
|
-
export { A as AnalyticsOptions, a as AnalyticsReporter, P as PriceChangedError, R as RateLimitedError, b as STOREFRONT_ERROR_CODES, c as StorefrontAnalytics, d as StorefrontConfigError, e as StorefrontError, f as StorefrontErrorCode, g as StorefrontErrorInit, h as StorefrontNetworkError, i as StorefrontTimeoutError, T as TrackEvent, W as WrongRegionError, j as analyticsFor, k as createAnalytics, t as trackPurchasePixel } from './errors-
|
|
1
|
+
import { S as StorefrontRegion } from './errors-welPvrD6.cjs';
|
|
2
|
+
export { A as AnalyticsOptions, a as AnalyticsReporter, P as PriceChangedError, R as RateLimitedError, b as STOREFRONT_ERROR_CODES, c as StorefrontAnalytics, d as StorefrontConfigError, e as StorefrontError, f as StorefrontErrorCode, g as StorefrontErrorInit, h as StorefrontNetworkError, i as StorefrontTimeoutError, T as TrackEvent, W as WrongRegionError, j as analyticsFor, k as createAnalytics, t as trackPurchasePixel } from './errors-welPvrD6.cjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
export { B as BookingResult, C as CheckoutMountDescriptor, a as CheckoutSession, b as ConfirmCheckoutSessionInput, c as ConfirmCheckoutSessionRequest, d as ContentListQuery, e as CreateCheckoutSessionInput, f as CreateCheckoutSessionOptions, g as CreatedCheckoutSession, P as Page, R as RequestOptions, S as STOREFRONT_API_PATH, h as StorefrontBooking, i as StorefrontBuilding, j as StorefrontClient, k as StorefrontClientOptions, l as StorefrontContactInput, m as StorefrontContentItem, n as StorefrontContentModel, o as StorefrontContentRef, p as StorefrontGuestInput, q as StorefrontGuide, r as StorefrontGuideItem, s as StorefrontImage, t as StorefrontListing, u as
|
|
5
|
-
export { S as StorefrontAvailability, a as
|
|
4
|
+
export { B as BookingResult, C as CheckoutMountDescriptor, a as CheckoutSession, b as ConfirmCheckoutSessionInput, c as ConfirmCheckoutSessionRequest, d as ContentListQuery, e as CreateCheckoutSessionInput, f as CreateCheckoutSessionOptions, g as CreatedCheckoutSession, P as Page, R as RequestOptions, S as STOREFRONT_API_PATH, h as StorefrontBooking, i as StorefrontBuilding, j as StorefrontClient, k as StorefrontClientOptions, l as StorefrontContactInput, m as StorefrontContentItem, n as StorefrontContentModel, o as StorefrontContentRef, p as StorefrontGuestInput, q as StorefrontGuide, r as StorefrontGuideItem, s as StorefrontImage, t as StorefrontListing, u as StorefrontListingFacets, v as StorefrontListingSort, w as StorefrontListingSummary, x as StorefrontListingsQuery, y as StorefrontLocation, z as StorefrontQuote, A as StorefrontQuoteInput, D as StorefrontRatePlanQuote, E as StorefrontReview, F as StorefrontReviewsQuery, G as StorefrontSite, H as createStorefrontClient } from './client-CX8K7JNt.cjs';
|
|
5
|
+
export { S as StorefrontAvailability, a as StorefrontBuildingAvailabilityQuery, b as StorefrontCalendar, c as StorefrontCalendarDay, d as StorefrontCalendarQuery, e as StorefrontStay, f as StorefrontUnavailableReason, g as StorefrontUnitAvailability, h as StorefrontUnitUnavailableReason } from './availability.d-Cla9GuGc.cjs';
|
|
6
6
|
|
|
7
7
|
declare const attributionTouchSchema: z.ZodObject<{
|
|
8
8
|
ts: z.ZodISODateTime;
|
|
@@ -20,8 +20,8 @@ declare const attributionTouchSchema: z.ZodObject<{
|
|
|
20
20
|
msclkid: z.ZodNullable<z.ZodString>;
|
|
21
21
|
paidClick: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
22
22
|
google: "google";
|
|
23
|
-
microsoft: "microsoft";
|
|
24
23
|
meta: "meta";
|
|
24
|
+
microsoft: "microsoft";
|
|
25
25
|
}>>>;
|
|
26
26
|
}, z.core.$strip>;
|
|
27
27
|
type AttributionTouch = z.infer<typeof attributionTouchSchema>;
|
|
@@ -49,8 +49,8 @@ declare const storefrontAttributionInputSchema: z.ZodObject<{
|
|
|
49
49
|
msclkid: z.ZodNullable<z.ZodString>;
|
|
50
50
|
paidClick: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
51
51
|
google: "google";
|
|
52
|
-
microsoft: "microsoft";
|
|
53
52
|
meta: "meta";
|
|
53
|
+
microsoft: "microsoft";
|
|
54
54
|
}>>>;
|
|
55
55
|
}, z.core.$strip>>;
|
|
56
56
|
last: z.ZodNullable<z.ZodObject<{
|
|
@@ -69,8 +69,8 @@ declare const storefrontAttributionInputSchema: z.ZodObject<{
|
|
|
69
69
|
msclkid: z.ZodNullable<z.ZodString>;
|
|
70
70
|
paidClick: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
71
71
|
google: "google";
|
|
72
|
-
microsoft: "microsoft";
|
|
73
72
|
meta: "meta";
|
|
73
|
+
microsoft: "microsoft";
|
|
74
74
|
}>>>;
|
|
75
75
|
}, z.core.$strip>>;
|
|
76
76
|
ids: z.ZodObject<{
|
|
@@ -87,8 +87,8 @@ declare const storefrontAttributionInputSchema: z.ZodObject<{
|
|
|
87
87
|
user: "user";
|
|
88
88
|
}>;
|
|
89
89
|
region: z.ZodEnum<{
|
|
90
|
-
restricted: "restricted";
|
|
91
90
|
other: "other";
|
|
91
|
+
restricted: "restricted";
|
|
92
92
|
}>;
|
|
93
93
|
decidedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
94
94
|
}, z.core.$strip>;
|
|
@@ -102,10 +102,19 @@ declare const storefrontAttributionInputSchema: z.ZodObject<{
|
|
|
102
102
|
}, z.core.$strip>;
|
|
103
103
|
type StorefrontAttributionInput = z.infer<typeof storefrontAttributionInputSchema>;
|
|
104
104
|
|
|
105
|
+
/** Called once per malformed input `getAttribution` skipped; `where` names the cookie or element. */
|
|
105
106
|
type AttributionReporter = (err: unknown, where: string) => void;
|
|
106
107
|
interface AttributionOptions {
|
|
108
|
+
/** Default: `console.warn`. Malformed input never throws — it is reported and read as null. */
|
|
107
109
|
report?: AttributionReporter;
|
|
108
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* What the checkout session carries: the `so_attr` first/last touch (read only under
|
|
113
|
+
* analytics consent), with this page's own touch from the edge as `last` when it is not direct, the
|
|
114
|
+
* GA / Meta browser ids, the visitor's A/B variant when the site runs a split, and the page's
|
|
115
|
+
* consent. The API validates every field again, recomputes
|
|
116
|
+
* the channels and keeps each id only under the consent that covers it. Null outside a browser.
|
|
117
|
+
*/
|
|
109
118
|
declare function getAttribution(opts?: AttributionOptions): StorefrontAttributionInput | null;
|
|
110
119
|
|
|
111
120
|
declare const CDN_IMAGE_WIDTHS: readonly [320, 640, 1080, 1600];
|
|
@@ -122,9 +131,19 @@ interface ParsedPublishableKey {
|
|
|
122
131
|
environment: 'live' | 'test';
|
|
123
132
|
region: StorefrontRegion;
|
|
124
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Reads the environment and region a publishable key encodes
|
|
136
|
+
* (`pk_{live|test}_{us|eu|apac}_<24 base62>`). Throws `StorefrontConfigError`, whose message
|
|
137
|
+
* never repeats the key, for anything else — loudest for a secret key.
|
|
138
|
+
*/
|
|
125
139
|
declare function parsePublishableKey(key: string): ParsedPublishableKey;
|
|
126
140
|
|
|
141
|
+
/** This package's version, stamped from package.json at build time. */
|
|
127
142
|
declare const SDK_VERSION: string;
|
|
143
|
+
/**
|
|
144
|
+
* The Storefront API version this SDK speaks, sent as `X-SuiteOp-Api-Version`. Pinned per SDK
|
|
145
|
+
* release so an API evolution never changes an installed SDK's behaviour (README §Versioning).
|
|
146
|
+
*/
|
|
128
147
|
declare const STOREFRONT_API_VERSION = "2026-09-27";
|
|
129
148
|
|
|
130
149
|
export { type AttributionIds, type AttributionOptions, type AttributionReporter, type AttributionTouch, CDN_IMAGE_WIDTHS as IMAGE_WIDTHS, type CdnImageWidth as ImageWidth, type ParsedPublishableKey, SDK_VERSION, STOREFRONT_API_VERSION, type StorefrontAttributionInput, StorefrontRegion, getAttribution, cdnImageProps as imageProps, cdnImageSrcSet as imageSrcSet, cdnImageUrl as imageUrl, parsePublishableKey };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { S as StorefrontRegion } from './errors-
|
|
2
|
-
export { A as AnalyticsOptions, a as AnalyticsReporter, P as PriceChangedError, R as RateLimitedError, b as STOREFRONT_ERROR_CODES, c as StorefrontAnalytics, d as StorefrontConfigError, e as StorefrontError, f as StorefrontErrorCode, g as StorefrontErrorInit, h as StorefrontNetworkError, i as StorefrontTimeoutError, T as TrackEvent, W as WrongRegionError, j as analyticsFor, k as createAnalytics, t as trackPurchasePixel } from './errors-
|
|
1
|
+
import { S as StorefrontRegion } from './errors-Oax7djdp.js';
|
|
2
|
+
export { A as AnalyticsOptions, a as AnalyticsReporter, P as PriceChangedError, R as RateLimitedError, b as STOREFRONT_ERROR_CODES, c as StorefrontAnalytics, d as StorefrontConfigError, e as StorefrontError, f as StorefrontErrorCode, g as StorefrontErrorInit, h as StorefrontNetworkError, i as StorefrontTimeoutError, T as TrackEvent, W as WrongRegionError, j as analyticsFor, k as createAnalytics, t as trackPurchasePixel } from './errors-Oax7djdp.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
export { B as BookingResult, C as CheckoutMountDescriptor, a as CheckoutSession, b as ConfirmCheckoutSessionInput, c as ConfirmCheckoutSessionRequest, d as ContentListQuery, e as CreateCheckoutSessionInput, f as CreateCheckoutSessionOptions, g as CreatedCheckoutSession, P as Page, R as RequestOptions, S as STOREFRONT_API_PATH, h as StorefrontBooking, i as StorefrontBuilding, j as StorefrontClient, k as StorefrontClientOptions, l as StorefrontContactInput, m as StorefrontContentItem, n as StorefrontContentModel, o as StorefrontContentRef, p as StorefrontGuestInput, q as StorefrontGuide, r as StorefrontGuideItem, s as StorefrontImage, t as StorefrontListing, u as
|
|
5
|
-
export { S as StorefrontAvailability, a as
|
|
4
|
+
export { B as BookingResult, C as CheckoutMountDescriptor, a as CheckoutSession, b as ConfirmCheckoutSessionInput, c as ConfirmCheckoutSessionRequest, d as ContentListQuery, e as CreateCheckoutSessionInput, f as CreateCheckoutSessionOptions, g as CreatedCheckoutSession, P as Page, R as RequestOptions, S as STOREFRONT_API_PATH, h as StorefrontBooking, i as StorefrontBuilding, j as StorefrontClient, k as StorefrontClientOptions, l as StorefrontContactInput, m as StorefrontContentItem, n as StorefrontContentModel, o as StorefrontContentRef, p as StorefrontGuestInput, q as StorefrontGuide, r as StorefrontGuideItem, s as StorefrontImage, t as StorefrontListing, u as StorefrontListingFacets, v as StorefrontListingSort, w as StorefrontListingSummary, x as StorefrontListingsQuery, y as StorefrontLocation, z as StorefrontQuote, A as StorefrontQuoteInput, D as StorefrontRatePlanQuote, E as StorefrontReview, F as StorefrontReviewsQuery, G as StorefrontSite, H as createStorefrontClient } from './client-s-lEwqzc.js';
|
|
5
|
+
export { S as StorefrontAvailability, a as StorefrontBuildingAvailabilityQuery, b as StorefrontCalendar, c as StorefrontCalendarDay, d as StorefrontCalendarQuery, e as StorefrontStay, f as StorefrontUnavailableReason, g as StorefrontUnitAvailability, h as StorefrontUnitUnavailableReason } from './availability.d-Cla9GuGc.js';
|
|
6
6
|
|
|
7
7
|
declare const attributionTouchSchema: z.ZodObject<{
|
|
8
8
|
ts: z.ZodISODateTime;
|
|
@@ -20,8 +20,8 @@ declare const attributionTouchSchema: z.ZodObject<{
|
|
|
20
20
|
msclkid: z.ZodNullable<z.ZodString>;
|
|
21
21
|
paidClick: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
22
22
|
google: "google";
|
|
23
|
-
microsoft: "microsoft";
|
|
24
23
|
meta: "meta";
|
|
24
|
+
microsoft: "microsoft";
|
|
25
25
|
}>>>;
|
|
26
26
|
}, z.core.$strip>;
|
|
27
27
|
type AttributionTouch = z.infer<typeof attributionTouchSchema>;
|
|
@@ -49,8 +49,8 @@ declare const storefrontAttributionInputSchema: z.ZodObject<{
|
|
|
49
49
|
msclkid: z.ZodNullable<z.ZodString>;
|
|
50
50
|
paidClick: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
51
51
|
google: "google";
|
|
52
|
-
microsoft: "microsoft";
|
|
53
52
|
meta: "meta";
|
|
53
|
+
microsoft: "microsoft";
|
|
54
54
|
}>>>;
|
|
55
55
|
}, z.core.$strip>>;
|
|
56
56
|
last: z.ZodNullable<z.ZodObject<{
|
|
@@ -69,8 +69,8 @@ declare const storefrontAttributionInputSchema: z.ZodObject<{
|
|
|
69
69
|
msclkid: z.ZodNullable<z.ZodString>;
|
|
70
70
|
paidClick: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
71
71
|
google: "google";
|
|
72
|
-
microsoft: "microsoft";
|
|
73
72
|
meta: "meta";
|
|
73
|
+
microsoft: "microsoft";
|
|
74
74
|
}>>>;
|
|
75
75
|
}, z.core.$strip>>;
|
|
76
76
|
ids: z.ZodObject<{
|
|
@@ -87,8 +87,8 @@ declare const storefrontAttributionInputSchema: z.ZodObject<{
|
|
|
87
87
|
user: "user";
|
|
88
88
|
}>;
|
|
89
89
|
region: z.ZodEnum<{
|
|
90
|
-
restricted: "restricted";
|
|
91
90
|
other: "other";
|
|
91
|
+
restricted: "restricted";
|
|
92
92
|
}>;
|
|
93
93
|
decidedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
94
94
|
}, z.core.$strip>;
|
|
@@ -102,10 +102,19 @@ declare const storefrontAttributionInputSchema: z.ZodObject<{
|
|
|
102
102
|
}, z.core.$strip>;
|
|
103
103
|
type StorefrontAttributionInput = z.infer<typeof storefrontAttributionInputSchema>;
|
|
104
104
|
|
|
105
|
+
/** Called once per malformed input `getAttribution` skipped; `where` names the cookie or element. */
|
|
105
106
|
type AttributionReporter = (err: unknown, where: string) => void;
|
|
106
107
|
interface AttributionOptions {
|
|
108
|
+
/** Default: `console.warn`. Malformed input never throws — it is reported and read as null. */
|
|
107
109
|
report?: AttributionReporter;
|
|
108
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* What the checkout session carries: the `so_attr` first/last touch (read only under
|
|
113
|
+
* analytics consent), with this page's own touch from the edge as `last` when it is not direct, the
|
|
114
|
+
* GA / Meta browser ids, the visitor's A/B variant when the site runs a split, and the page's
|
|
115
|
+
* consent. The API validates every field again, recomputes
|
|
116
|
+
* the channels and keeps each id only under the consent that covers it. Null outside a browser.
|
|
117
|
+
*/
|
|
109
118
|
declare function getAttribution(opts?: AttributionOptions): StorefrontAttributionInput | null;
|
|
110
119
|
|
|
111
120
|
declare const CDN_IMAGE_WIDTHS: readonly [320, 640, 1080, 1600];
|
|
@@ -122,9 +131,19 @@ interface ParsedPublishableKey {
|
|
|
122
131
|
environment: 'live' | 'test';
|
|
123
132
|
region: StorefrontRegion;
|
|
124
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Reads the environment and region a publishable key encodes
|
|
136
|
+
* (`pk_{live|test}_{us|eu|apac}_<24 base62>`). Throws `StorefrontConfigError`, whose message
|
|
137
|
+
* never repeats the key, for anything else — loudest for a secret key.
|
|
138
|
+
*/
|
|
125
139
|
declare function parsePublishableKey(key: string): ParsedPublishableKey;
|
|
126
140
|
|
|
141
|
+
/** This package's version, stamped from package.json at build time. */
|
|
127
142
|
declare const SDK_VERSION: string;
|
|
143
|
+
/**
|
|
144
|
+
* The Storefront API version this SDK speaks, sent as `X-SuiteOp-Api-Version`. Pinned per SDK
|
|
145
|
+
* release so an API evolution never changes an installed SDK's behaviour (README §Versioning).
|
|
146
|
+
*/
|
|
128
147
|
declare const STOREFRONT_API_VERSION = "2026-09-27";
|
|
129
148
|
|
|
130
149
|
export { type AttributionIds, type AttributionOptions, type AttributionReporter, type AttributionTouch, CDN_IMAGE_WIDTHS as IMAGE_WIDTHS, type CdnImageWidth as ImageWidth, type ParsedPublishableKey, SDK_VERSION, STOREFRONT_API_VERSION, type StorefrontAttributionInput, StorefrontRegion, getAttribution, cdnImageProps as imageProps, cdnImageSrcSet as imageSrcSet, cdnImageUrl as imageUrl, parsePublishableKey };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { SDK_VERSION, STOREFRONT_API_PATH, STOREFRONT_API_VERSION, analyticsFor, createAnalytics, createStorefrontClient, getAttribution, parsePublishableKey, trackPurchasePixel } from './chunk-
|
|
1
|
+
export { SDK_VERSION, STOREFRONT_API_PATH, STOREFRONT_API_VERSION, analyticsFor, createAnalytics, createStorefrontClient, getAttribution, parsePublishableKey, trackPurchasePixel } from './chunk-YIYGBTAM.js';
|
|
2
2
|
export { CDN_IMAGE_WIDTHS as IMAGE_WIDTHS, cdnImageProps as imageProps, cdnImageSrcSet as imageSrcSet, cdnImageUrl as imageUrl } from './chunk-A43EXKPY.js';
|
|
3
|
-
import './chunk-
|
|
4
|
-
import './chunk-
|
|
5
|
-
export { PriceChangedError, RateLimitedError, STOREFRONT_ERROR_CODES, StorefrontConfigError, StorefrontError, StorefrontNetworkError, StorefrontTimeoutError, WrongRegionError } from './chunk-
|
|
6
|
-
import './chunk-
|
|
3
|
+
import './chunk-UQWQPTHO.js';
|
|
4
|
+
import './chunk-XOCFEVP4.js';
|
|
5
|
+
export { PriceChangedError, RateLimitedError, STOREFRONT_ERROR_CODES, StorefrontConfigError, StorefrontError, StorefrontNetworkError, StorefrontTimeoutError, WrongRegionError } from './chunk-W5K7IDYN.js';
|
|
6
|
+
import './chunk-IBCBDAGY.js';
|
package/dist/react.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
require('./chunk-
|
|
6
|
-
require('./chunk-
|
|
7
|
-
var
|
|
8
|
-
require('./chunk-
|
|
3
|
+
var chunk3NE27PHL_cjs = require('./chunk-3NE27PHL.cjs');
|
|
4
|
+
var chunkUMCI4YBN_cjs = require('./chunk-UMCI4YBN.cjs');
|
|
5
|
+
require('./chunk-JF245QUY.cjs');
|
|
6
|
+
require('./chunk-QBHOJGZI.cjs');
|
|
7
|
+
var chunkJ5FZ4WDQ_cjs = require('./chunk-J5FZ4WDQ.cjs');
|
|
8
|
+
require('./chunk-EHQFWSP6.cjs');
|
|
9
9
|
var react = require('react');
|
|
10
10
|
var jsxRuntime = require('react/jsx-runtime');
|
|
11
11
|
|
|
12
|
-
var SuiteOpContext=react.createContext(null);var ASTRO_PAGE_LOAD="astro:page-load";function SuiteOpProvider({client,children}){const value=react.useMemo(()=>({client,requests:new Map,analytics:
|
|
12
|
+
var SuiteOpContext=react.createContext(null);var ASTRO_PAGE_LOAD="astro:page-load";function SuiteOpProvider({client,children}){const value=react.useMemo(()=>({client,requests:new Map,analytics:chunk3NE27PHL_cjs.analyticsFor(client.publishableKey)}),[client]);const{analytics}=value;react.useEffect(()=>{const onPageLoad=()=>analytics.pageView();onPageLoad();document.addEventListener(ASTRO_PAGE_LOAD,onPageLoad);return ()=>document.removeEventListener(ASTRO_PAGE_LOAD,onPageLoad)},[analytics]);return jsxRuntime.jsx(SuiteOpContext.Provider,{value,children})}function useTrack(){const{analytics}=useSuiteOpContext("useTrack");return analytics.track}function useSuiteOpContext(hookName){const value=react.useContext(SuiteOpContext);if(!value)throw new chunkJ5FZ4WDQ_cjs.StorefrontConfigError(`${hookName} must be used inside <SuiteOpProvider>`);return value}function useStorefrontClient(){return useSuiteOpContext("useStorefrontClient").client}var SHARED_TTL_MS=3e4;function toStorefrontError(err){if(err instanceof chunkJ5FZ4WDQ_cjs.StorefrontError)return err;return new chunkJ5FZ4WDQ_cjs.StorefrontError({status:0,code:"internal_error",message:err instanceof Error?err.message:"Unexpected error",cause:err})}function acquire(requests,key,run){const now=Date.now();for(const[k,entry2]of requests){if(entry2.refs===0&&entry2.settledAt!==null&&now-entry2.settledAt>=SHARED_TTL_MS){requests.delete(k);}}const cached=requests.get(key);if(cached&&(cached.settledAt===null||now-cached.settledAt<SHARED_TTL_MS)){cached.refs+=1;return cached}const controller=new AbortController;const entry={promise:Promise.resolve(),controller,refs:1,settledAt:null};entry.promise=run({signal:controller.signal}).then(data=>{entry.settledAt=Date.now();return data},err=>{if(requests.get(key)===entry)requests.delete(key);throw err});requests.set(key,entry);return entry}function release(requests,key,entry){entry.refs-=1;queueMicrotask(()=>{if(entry.refs>0||entry.settledAt!==null)return;entry.controller.abort();if(requests.get(key)===entry)requests.delete(key);});}function useSharedRead(hookName,key,run){const{requests}=useSuiteOpContext(hookName);const[current,setCurrent]=react.useState(null);const runRef=react.useRef(run);runRef.current=run;react.useEffect(()=>{if(key===null)return;let active=true;const entry=acquire(requests,key,opts=>runRef.current(opts));entry.promise.then(data=>{if(active)setCurrent({key,state:{status:"success",data}});},err=>{if(active&&!entry.controller.signal.aborted){setCurrent({key,state:{status:"error",error:toStorefrontError(err)}});}});return ()=>{active=false;release(requests,key,entry);}},[requests,key]);if(key===null)return {status:"idle"};return current?.key===key?current.state:{status:"loading"}}function useListing(id){const{client}=useSuiteOpContext("useListing");return useSharedRead("useListing",id===null?null:`listing:${id}`,opts=>client.listings.get(id,opts))}function useAvailability(listingId,stay){const{client}=useSuiteOpContext("useAvailability");const key=listingId===null||stay===null?null:`availability:${JSON.stringify([listingId,stay.checkIn,stay.checkOut,stay.guests])}`;return useSharedRead("useAvailability",key,opts=>client.availability.get(listingId,stay,opts))}function useMutationState(){const[state,setState]=react.useState({status:"idle"});const seq=react.useRef(0);const track=react.useCallback(async(work,onError)=>{const mine=++seq.current;setState({status:"loading"});try{const data=await work();if(mine===seq.current)setState({status:"success",data});return data}catch(err){if(mine===seq.current){onError?.(err);setState({status:"error",error:toStorefrontError(err)});}throw err}},[]);return {state,track}}function useQuote(){const{client}=useSuiteOpContext("useQuote");const{state,track}=useMutationState();const quote=react.useCallback(input=>track(()=>client.quotes.create(input)),[client,track]);return {quote,state}}function useCheckoutSession(){const{client}=useSuiteOpContext("useCheckoutSession");const{state,track}=useMutationState();const[priceChanged,setPriceChanged]=react.useState(null);const create=react.useCallback((input,opts)=>{setPriceChanged(null);return track(()=>client.checkoutSessions.create(input,opts),err=>{if(err instanceof chunkJ5FZ4WDQ_cjs.PriceChangedError)setPriceChanged(err.quote);})},[client,track]);return {create,session:state,priceChanged}}var EVENTS={"suiteop-checkout:ready":h=>h.onReady?.(),"suiteop-checkout:confirmed":(h,detail)=>h.onComplete(detail),"suiteop-checkout:pending":(h,detail)=>h.onPending?.(detail),"suiteop-checkout:error":(h,detail)=>{const error=detail;if(error.code==="price_changed"&&h.onPriceChanged)h.onPriceChanged();else h.onError?.(error);}};function SuiteOpCheckout(props){const client=useStorefrontClient();const ref=react.useRef(null);const handlers=react.useRef(props);handlers.current=props;react.useEffect(()=>{let active=true;chunkUMCI4YBN_cjs.loadCheckout({origin:props.checkoutOrigin}).catch(err=>{if(!active)return;const code=err instanceof chunkJ5FZ4WDQ_cjs.StorefrontError?err.code:"checkout_unavailable";handlers.current.onError?.({code,requiresNewSession:false});});return ()=>{active=false;}},[props.checkoutOrigin]);react.useEffect(()=>{const element=ref.current;if(!element)return;const listeners=Object.entries(EVENTS).map(([type,handle])=>{const listener=event=>handle(handlers.current,event.detail);element.addEventListener(type,listener);return [type,listener]});return ()=>{for(const[type,listener]of listeners)element.removeEventListener(type,listener);}},[]);const apiBase=client.baseUrl.endsWith(chunk3NE27PHL_cjs.STOREFRONT_API_PATH)?client.baseUrl.slice(0,-chunk3NE27PHL_cjs.STOREFRONT_API_PATH.length):client.baseUrl;return react.createElement("suiteop-checkout",{ref,class:props.className,"session-id":props.checkoutSessionId,"quote-ref":props.quoteRef,"idempotency-key":props.idempotencyKey,"api-base":apiBase,"publishable-key":client.publishableKey,locale:props.locale})}
|
|
13
13
|
|
|
14
14
|
exports.SuiteOpCheckout = SuiteOpCheckout;
|
|
15
15
|
exports.SuiteOpProvider = SuiteOpProvider;
|
package/dist/react.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { e as CreateCheckoutSessionInput, f as CreateCheckoutSessionOptions, g as CreatedCheckoutSession,
|
|
3
|
-
import { e as StorefrontError, T as TrackEvent } from './errors-
|
|
1
|
+
import { e as StorefrontStay, S as StorefrontAvailability } from './availability.d-Cla9GuGc.cjs';
|
|
2
|
+
import { e as CreateCheckoutSessionInput, f as CreateCheckoutSessionOptions, g as CreatedCheckoutSession, z as StorefrontQuote, t as StorefrontListing, A as StorefrontQuoteInput, j as StorefrontClient, B as BookingResult } from './client-CX8K7JNt.cjs';
|
|
3
|
+
import { e as StorefrontError, T as TrackEvent } from './errors-welPvrD6.cjs';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { ReactNode, JSX } from 'react';
|
|
6
6
|
import 'zod';
|
|
@@ -23,8 +23,10 @@ declare function useQuote(): {
|
|
|
23
23
|
state: AsyncState<StorefrontQuote>;
|
|
24
24
|
};
|
|
25
25
|
declare function useCheckoutSession(): {
|
|
26
|
+
/** The client reuses one Idempotency-Key per quoteRef + rate plan, so a double click opens one session. */
|
|
26
27
|
create(input: CreateCheckoutSessionInput, opts?: CreateCheckoutSessionOptions): Promise<CreatedCheckoutSession>;
|
|
27
28
|
session: AsyncState<CreatedCheckoutSession>;
|
|
29
|
+
/** The fresh quote when the last create was refused with `price_changed`; show it, then re-create. */
|
|
28
30
|
priceChanged: StorefrontQuote | null;
|
|
29
31
|
};
|
|
30
32
|
|
|
@@ -32,7 +34,16 @@ interface SuiteOpProviderProps {
|
|
|
32
34
|
client: StorefrontClient;
|
|
33
35
|
children: ReactNode;
|
|
34
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Provides the Storefront client to the hooks below it, and storefront analytics: a
|
|
39
|
+
* `page_view` on mount and on every Astro view-transition navigation to a new URL. JSON-LD
|
|
40
|
+
* arrives in a later minor.
|
|
41
|
+
*/
|
|
35
42
|
declare function SuiteOpProvider({ client, children }: SuiteOpProviderProps): react.JSX.Element;
|
|
43
|
+
/**
|
|
44
|
+
* Track a storefront event (`view_item`, `begin_checkout`, `generate_lead` …); the SDK fills the
|
|
45
|
+
* event id, time, path and referrer. `purchase` does not type-check: the server records it.
|
|
46
|
+
*/
|
|
36
47
|
declare function useTrack(): (event: TrackEvent) => void;
|
|
37
48
|
declare function useStorefrontClient(): StorefrontClient;
|
|
38
49
|
|
|
@@ -41,18 +52,28 @@ interface SuiteOpCheckoutError {
|
|
|
41
52
|
requiresNewSession: boolean;
|
|
42
53
|
}
|
|
43
54
|
interface SuiteOpCheckoutProps {
|
|
55
|
+
/** The three values the session was created with — the element replays the create to recover the mount. */
|
|
44
56
|
checkoutSessionId: string;
|
|
45
57
|
quoteRef: string;
|
|
46
58
|
idempotencyKey: string;
|
|
47
59
|
locale?: string;
|
|
60
|
+
/** The storefront host serving the checkout bundle. Default: the page's own origin. */
|
|
48
61
|
checkoutOrigin?: string;
|
|
49
62
|
onReady?(): void;
|
|
50
63
|
onComplete(result: BookingResult): void;
|
|
51
64
|
onPending?(result: BookingResult): void;
|
|
65
|
+
/**
|
|
66
|
+
* `price_changed`: re-quote and create a new session. Without this handler it reaches `onError`.
|
|
67
|
+
*/
|
|
52
68
|
onPriceChanged?(): void;
|
|
53
69
|
onError?(error: SuiteOpCheckoutError): void;
|
|
54
70
|
className?: string;
|
|
55
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* The SuiteOp checkout (card entry + confirmation) for one checkout session. Loads the bundle on
|
|
74
|
+
* mount and renders `<suiteop-checkout>` with the `<SuiteOpProvider>` client's key and API origin.
|
|
75
|
+
* Card data only ever touches the bundle's provider elements.
|
|
76
|
+
*/
|
|
56
77
|
declare function SuiteOpCheckout(props: SuiteOpCheckoutProps): JSX.Element;
|
|
57
78
|
|
|
58
79
|
export { type AsyncState, SuiteOpCheckout, type SuiteOpCheckoutError, type SuiteOpCheckoutProps, SuiteOpProvider, type SuiteOpProviderProps, useAvailability, useCheckoutSession, useListing, useQuote, useStorefrontClient, useTrack };
|