@bestcheckout/dynamic-component-cli 0.0.0-stage → 0.1.1

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.
@@ -0,0 +1,1230 @@
1
+ import { ComponentType, ReactNode } from 'react';
2
+
3
+ export type DynamicPageType = "checkout" | "upsell" | "downsell" | "thankYou";
4
+ export type DynamicComponentContext = {
5
+ shopId?: string;
6
+ themeId: string;
7
+ pageType: DynamicPageType;
8
+ handle?: string;
9
+ sectionId: string;
10
+ mode: "editor" | "preview" | "live" | "storefront";
11
+ device: "desktop" | "mobile";
12
+ };
13
+ export type DynamicComponentManifest = {
14
+ componentId: string;
15
+ name: string;
16
+ supportedPageTypes?: readonly DynamicPageType[];
17
+ capabilities?: {
18
+ offerRecommendation?: boolean;
19
+ };
20
+ };
21
+ type DynamicComponentRuntime = Record<string, unknown>;
22
+ type DynamicComponentProps = {
23
+ settings: Record<string, unknown>;
24
+ runtime: DynamicComponentRuntime;
25
+ context: DynamicComponentContext;
26
+ };
27
+ type DynamicComponentModule = {
28
+ manifest: DynamicComponentManifest;
29
+ schema: unknown;
30
+ defaultSettings: Record<string, unknown>;
31
+ Component: ComponentType<DynamicComponentProps>;
32
+ styles?: string;
33
+ };
34
+ type DynamicComponentDefinition = DynamicComponentModule;
35
+ type CheckoutTemplateKey = "checkout" | "thankYou" | "upsell" | "downsell";
36
+ type OfferTemplateKey = Extract<CheckoutTemplateKey, "upsell" | "downsell">;
37
+ declare const checkoutFixedComponentTypes: readonly [
38
+ "header",
39
+ "mobileOrderSummary",
40
+ "expressCheckout",
41
+ "contact",
42
+ "delivery",
43
+ "shippingMethod",
44
+ "payment",
45
+ "cta",
46
+ "orderSummary",
47
+ "policyLinks"
48
+ ];
49
+ type CheckoutFixedComponentType = (typeof checkoutFixedComponentTypes)[number];
50
+ declare const thankYouFixedComponentTypes: readonly [
51
+ "header",
52
+ "orderStatus",
53
+ "orderDetails",
54
+ "continueShopping",
55
+ "contactUs",
56
+ "thankYouOrderSummary",
57
+ "policyLinks"
58
+ ];
59
+ type ThankYouFixedComponentType = (typeof thankYouFixedComponentTypes)[number];
60
+ declare const offerFixedComponentTypes: readonly [
61
+ "orderConfirmation",
62
+ "progress",
63
+ "offer"
64
+ ];
65
+ type OfferFixedComponentType = (typeof offerFixedComponentTypes)[number];
66
+ type CheckoutCoreComponentType = CheckoutFixedComponentType | ThankYouFixedComponentType | OfferFixedComponentType;
67
+ type CheckoutAddableComponentType = "dynamic" | "announcementBar" | "countdown" | "paymentIcons" | "trustBadges" | "trustpilotReview" | "reviewCard" | "testimonials" | "facebookComments" | "staticContent" | "footer" | "productUpsell" | "shippingInsurance" | "vipClub";
68
+ type CheckoutComponentType = CheckoutCoreComponentType | CheckoutAddableComponentType;
69
+ type CheckoutSlotKey = "headerAbove" | "headerBelow" | "beforeExpressCheckout" | "afterContact" | "afterShippingMethod" | "afterPayment" | "afterCta" | "afterOrderSummary" | "afterPolicyLinks" | "footer";
70
+ type ThankYouSlotKey = "thankYouHeaderAbove" | "thankYouBeforeOrderStatus" | "thankYouAfterOrderStatus" | "thankYouAfterOrderDetails" | "thankYouAfterContactUs" | "thankYouAfterOrderSummary" | "thankYouAfterPolicyLinks" | "thankYouFooter";
71
+ type OfferSlotKey = "offerHeaderAbove" | "afterOrderConfirmation" | "afterProgress" | "afterOffer" | "afterOfferPolicyLinks";
72
+ type CheckoutAnySlotKey = CheckoutSlotKey | ThankYouSlotKey | OfferSlotKey;
73
+ type CheckoutSectionInstance = {
74
+ id: string;
75
+ type: CheckoutComponentType;
76
+ enabled: boolean;
77
+ settings: Record<string, unknown>;
78
+ /** Platform-owned placement metadata. Component authors never see this field. */
79
+ slot?: CheckoutAnySlotKey;
80
+ blocks?: CheckoutBlockInstance[];
81
+ };
82
+ type CheckoutBlockInstance = {
83
+ id: string;
84
+ type: string;
85
+ enabled: boolean;
86
+ settings: Record<string, unknown>;
87
+ };
88
+ type CheckoutFieldError = {
89
+ field: "contact" | "delivery" | "billing" | "shipping" | "payment" | "coupon";
90
+ path: string;
91
+ message: string;
92
+ };
93
+ type CheckoutActionCode = "unavailable" | "invalid_input" | "not_found" | "not_removable" | "blocked" | "stale" | "failed" | "refresh_failed" | "validation_failed" | "form_not_ready" | "unsupported_method" | "payment_failed" | "cancelled";
94
+ type CheckoutActionResult = {
95
+ ok: true;
96
+ outcome?: "applied" | "replaced_better" | "kept_better" | "removed";
97
+ message?: string;
98
+ } | {
99
+ ok: false;
100
+ code: CheckoutActionCode;
101
+ message?: string;
102
+ errors?: readonly CheckoutFieldError[];
103
+ };
104
+ type CheckoutValidationResult = {
105
+ valid: boolean;
106
+ errors: readonly CheckoutFieldError[];
107
+ };
108
+ type CheckoutSubmitResult = {
109
+ ok: true;
110
+ orderId?: string;
111
+ confirmationNumber?: string;
112
+ redirectUrl?: string;
113
+ } | {
114
+ ok: false;
115
+ code: CheckoutActionCode;
116
+ message?: string;
117
+ errors: readonly CheckoutFieldError[];
118
+ blockedReasons?: readonly CheckoutSubmitBlock[];
119
+ };
120
+ type CheckoutSubmitBlock = "order_loading" | "order_unknown" | "order_refresh_failed" | "inventory_unavailable" | "transaction_pending" | "selection_initializing" | "coupon_pending" | "shipping_pending" | "shipping_unavailable" | "submitting" | "unsupported_method" | "form_not_ready" | "host_blocked";
121
+ type CheckoutDynamicStatus = {
122
+ dataStatus: "loading" | "ready" | "error" | "unknown";
123
+ canSubmit: boolean;
124
+ isSubmitting: boolean;
125
+ blockedReasons: readonly CheckoutSubmitBlock[];
126
+ error?: string;
127
+ };
128
+ type CheckoutInstanceIdentity = {
129
+ themeId: string;
130
+ pageType: "checkout";
131
+ handle: string;
132
+ sectionId: string;
133
+ };
134
+ type CheckoutUpsellInput = {
135
+ productId: string;
136
+ variantId?: string;
137
+ quantity: number;
138
+ };
139
+ type CheckoutProductResult = {
140
+ ok: true;
141
+ product: CheckoutPreviewProduct;
142
+ } | Extract<CheckoutActionResult, {
143
+ ok: false;
144
+ }>;
145
+ type CheckoutAddressSuggestion = {
146
+ id: string;
147
+ text: string;
148
+ };
149
+ type CheckoutAddressSuggestionsResult = {
150
+ ok: true;
151
+ suggestions: readonly CheckoutAddressSuggestion[];
152
+ } | Extract<CheckoutActionResult, {
153
+ ok: false;
154
+ }>;
155
+ type CheckoutAddressAutocomplete = {
156
+ search(query: string): Promise<CheckoutAddressSuggestionsResult>;
157
+ apply(suggestionId: string): Promise<CheckoutActionResult>;
158
+ /** Invalidate pending searches/details when the input or address mode changes. */
159
+ cancel(): void;
160
+ };
161
+ type CheckoutDynamicHost = {
162
+ getStatus(): CheckoutDynamicStatus;
163
+ validateContact(): CheckoutValidationResult;
164
+ validateAll(): Promise<CheckoutValidationResult>;
165
+ submit(): Promise<CheckoutSubmitResult>;
166
+ upsell?: {
167
+ getProduct(productId: string): Promise<CheckoutProductResult>;
168
+ getSelections(identity: CheckoutInstanceIdentity): readonly CheckoutUpsellSelection[];
169
+ setSelection(identity: CheckoutInstanceIdentity, input: CheckoutUpsellInput): Promise<CheckoutActionResult>;
170
+ };
171
+ deliveryAutocomplete?: CheckoutAddressAutocomplete;
172
+ billingAutocomplete?: CheckoutAddressAutocomplete;
173
+ getDeliveryAddresses?(): NonNullable<CheckoutDeliveryState["savedAddresses"]>;
174
+ getBillingState?(): CheckoutBillingState;
175
+ useNewAddress?(): void;
176
+ /** Open the Host-owned saved-address creation UI; success means opened, not saved. */
177
+ openNewAddress?(): CheckoutActionResult;
178
+ selectSavedAddress?(id: string): Promise<CheckoutActionResult>;
179
+ editSavedAddress?(id: string): CheckoutActionResult;
180
+ deleteSavedAddress?(id: string): Promise<CheckoutActionResult>;
181
+ selectShippingRate?(id: string): Promise<CheckoutActionResult>;
182
+ getShippingStatus?(): "waiting_address" | "loading" | "available" | "empty" | "error";
183
+ applyCoupon?(code: string): Promise<CheckoutActionResult>;
184
+ removeCoupon?(code: string): Promise<CheckoutActionResult>;
185
+ validatePayment?(method: string): Promise<CheckoutValidationResult>;
186
+ /** Change the selected secure/payment method through the Host guard. */
187
+ selectPaymentMethod?(method: string): CheckoutActionResult;
188
+ /** Reserve a secure form before React/SDK creation. The adapter owns release. */
189
+ acquirePaymentMount?(identity: CheckoutInstanceIdentity, method: string): {
190
+ render(): ReactNode;
191
+ validate(): Promise<CheckoutValidationResult>;
192
+ release(): void;
193
+ };
194
+ /** Return null for a configured method that does not support this mount path. */
195
+ renderPayment?(kind: "secure" | "action" | "express", method?: string): ReactNode;
196
+ };
197
+ type DynamicActionResult = {
198
+ ok: true;
199
+ } | {
200
+ ok: false;
201
+ code: "unavailable" | "invalid_destination" | "blocked" | "failed";
202
+ message?: string;
203
+ };
204
+ type DynamicBrandRuntime = Readonly<{
205
+ name?: string;
206
+ logoUrl?: string;
207
+ logoAlt?: string;
208
+ }>;
209
+ type DynamicNavigationRuntime = {
210
+ navigate(input: {
211
+ url: string;
212
+ target?: "_self" | "_blank";
213
+ }): Promise<DynamicActionResult>;
214
+ };
215
+ type DynamicCartSnapshot = Readonly<{
216
+ /** Unknown until the store cart has been read; never inferred from an order. */
217
+ itemCount?: number;
218
+ subtotal?: number;
219
+ total?: number;
220
+ currency?: string;
221
+ isLoading: boolean;
222
+ error?: string;
223
+ }>;
224
+ type DynamicAccountSnapshot = Readonly<{
225
+ status: "loading";
226
+ }> | Readonly<{
227
+ status: "signed_out";
228
+ }> | Readonly<{
229
+ status: "signed_in";
230
+ customerName?: string;
231
+ email?: string;
232
+ }> | Readonly<{
233
+ status: "error";
234
+ message?: string;
235
+ }>;
236
+ type DynamicCartActions = {
237
+ addItem?(input: {
238
+ productId: string;
239
+ variantId?: string;
240
+ quantity: number;
241
+ }): Promise<DynamicActionResult>;
242
+ open?(): Promise<DynamicActionResult>;
243
+ };
244
+ type DynamicAccountActions = {
245
+ open?(): Promise<DynamicActionResult>;
246
+ login?(): Promise<DynamicActionResult>;
247
+ logout?(): Promise<DynamicActionResult>;
248
+ };
249
+ type DynamicOrderActions = {
250
+ refresh?(input?: {
251
+ target?: "main" | "addOn" | "all";
252
+ }): Promise<DynamicActionResult>;
253
+ continueShopping?(): Promise<DynamicActionResult>;
254
+ viewOrder?(): Promise<DynamicActionResult>;
255
+ };
256
+ type DynamicCartRuntime = DynamicCartActions & {
257
+ getSnapshot(): DynamicCartSnapshot;
258
+ subscribe(listener: (snapshot: DynamicCartSnapshot) => void): () => void;
259
+ };
260
+ type DynamicAccountRuntime = DynamicAccountActions & {
261
+ getSnapshot(): DynamicAccountSnapshot;
262
+ subscribe(listener: (snapshot: DynamicAccountSnapshot) => void): () => void;
263
+ };
264
+ type CheckoutLineItemKind = "product" | "service" | "membership";
265
+ type CheckoutLinePromotion = {
266
+ label: string;
267
+ };
268
+ type CheckoutLineItem = {
269
+ id: string;
270
+ kind: CheckoutLineItemKind;
271
+ title: string;
272
+ variant?: string;
273
+ image?: unknown;
274
+ quantity: number;
275
+ unitPrice: number;
276
+ compareAtPrice?: number;
277
+ /** Display-level values supplied by the checkout calculation service. */
278
+ displayPrice?: number;
279
+ displayCompareAtPrice?: number;
280
+ promotions?: CheckoutLinePromotion[];
281
+ sourceSectionId?: string;
282
+ sourceProductId?: string;
283
+ sourceProductAttrUnique?: string;
284
+ isDefaultSelection?: boolean;
285
+ offerType?: "shippingInsurance" | "vipClub";
286
+ canEditQuantity?: boolean;
287
+ hidePrice?: boolean;
288
+ isBundleItem?: boolean;
289
+ isBundleHeader?: boolean;
290
+ /** Bundle 子项里的赠品。摘要用 Free 标签,其余子项用 Included。 */
291
+ isBundleGift?: boolean;
292
+ isSpecialOffer?: boolean;
293
+ availability?: "available" | "unavailable" | "lowStock";
294
+ availabilityMessage?: string;
295
+ };
296
+ type CheckoutUpsellSelection = {
297
+ productId: string;
298
+ productAttrUnique: string;
299
+ quantity: number;
300
+ };
301
+ type CheckoutAppliedCoupon = {
302
+ code: string;
303
+ label?: string;
304
+ removable?: boolean;
305
+ };
306
+ type CheckoutCouponFeedback = {
307
+ status: "success" | "info" | "error";
308
+ message: string;
309
+ /** Clear the entered code after a completed API response, including rejected codes. */
310
+ clearInput?: boolean;
311
+ };
312
+ type CheckoutSummaryDiscount = {
313
+ id: string;
314
+ label: string;
315
+ amount: number;
316
+ };
317
+ type CheckoutSummaryDiscounts = {
318
+ order: CheckoutSummaryDiscount[];
319
+ shipping: CheckoutSummaryDiscount[];
320
+ };
321
+ type CheckoutShippingRate = {
322
+ id: string;
323
+ title: string;
324
+ description?: string;
325
+ price: number;
326
+ };
327
+ type CheckoutExpressPaymentMethod = {
328
+ id: string;
329
+ label: string;
330
+ appearance?: "shop-pay" | "paypal" | "google-pay" | "apple-pay";
331
+ };
332
+ type CheckoutPaymentMethod = {
333
+ id: string;
334
+ title: string;
335
+ description?: string;
336
+ /** Whether the fixed Payment card header should render supported-card logos. */
337
+ showCardBrandIcons?: boolean;
338
+ };
339
+ type CheckoutExpressCheckoutRenderProps = {
340
+ methods: CheckoutExpressPaymentMethod[];
341
+ selectedMethod?: string;
342
+ isSubmitting: boolean;
343
+ onSelect: (method: string) => void;
344
+ };
345
+ type CheckoutPaymentDetailsRenderProps = {
346
+ method: CheckoutPaymentMethod;
347
+ isSubmitting: boolean;
348
+ /** Opaque Host reservation; never provided by dynamic component code. */
349
+ mountToken?: object;
350
+ };
351
+ type CheckoutPaymentActionRenderProps = {
352
+ /** Dynamic Host supplies its guarded submission path; fixed Sections retain their own path. */
353
+ onSubmit?: () => void;
354
+ method: CheckoutPaymentMethod;
355
+ isSubmitting: boolean;
356
+ };
357
+ type CheckoutDeliveryField = "firstName" | "lastName" | "address" | "apartment" | "state" | "stateInput" | "city" | "cityInput" | "zip" | "phone";
358
+ type CheckoutDeliveryValues = Record<CheckoutDeliveryField, string> & {
359
+ country: string;
360
+ };
361
+ type CheckoutDeliveryOption = {
362
+ /** Optional presentational icon supplied by the Checkout Host, e.g. a country flag. */
363
+ imageUrl?: string;
364
+ value: string;
365
+ label: string;
366
+ };
367
+ type CheckoutSavedAddress = {
368
+ email?: string;
369
+ id: string;
370
+ name: string;
371
+ summary: string;
372
+ canEdit?: boolean;
373
+ canDelete?: boolean;
374
+ };
375
+ type CheckoutGoogleAddress = {
376
+ line1: string;
377
+ postalCode: string;
378
+ countryCode: string;
379
+ countryName: string;
380
+ adminArea1: string;
381
+ adminAreaLong: string;
382
+ adminAreaShort: string;
383
+ locality: string;
384
+ localityLong: string;
385
+ localityShort: string;
386
+ formattedAddress?: string;
387
+ };
388
+ type CheckoutAddressInputRenderProps = {
389
+ error?: boolean;
390
+ id: string;
391
+ onBlur?: () => void;
392
+ onChange: (value: string) => void;
393
+ placeholder: string;
394
+ value: string;
395
+ };
396
+ type CheckoutAccount = {
397
+ email: string;
398
+ avatar?: string;
399
+ };
400
+ type CheckoutDeliveryState = {
401
+ values: CheckoutDeliveryValues;
402
+ countryOptions: CheckoutDeliveryOption[];
403
+ stateOptions: CheckoutDeliveryOption[];
404
+ cityOptions: CheckoutDeliveryOption[];
405
+ useStateSelect: boolean;
406
+ useCitySelect: boolean;
407
+ phoneCode?: string;
408
+ errors?: Partial<Record<keyof CheckoutDeliveryValues, string>>;
409
+ savedAddresses?: CheckoutSavedAddress[];
410
+ /** Saved addresses rendered in the current collapsed or expanded state. */
411
+ savedAddressCount?: number;
412
+ selectedSavedAddressId?: string;
413
+ isSavedAddressListExpanded?: boolean;
414
+ isUsingNewAddress?: boolean;
415
+ googlePlacesApiKey?: string;
416
+ };
417
+ type CheckoutBillingState = {
418
+ values: CheckoutDeliveryValues;
419
+ countryOptions: CheckoutDeliveryOption[];
420
+ stateOptions: CheckoutDeliveryOption[];
421
+ cityOptions: CheckoutDeliveryOption[];
422
+ useStateSelect: boolean;
423
+ useCitySelect: boolean;
424
+ phoneCode?: string;
425
+ errors?: Partial<Record<keyof CheckoutDeliveryValues, string>>;
426
+ googlePlacesApiKey?: string;
427
+ sameAsShipping: boolean;
428
+ hasShippingAddress: boolean;
429
+ };
430
+ type CheckoutPreviewState = {
431
+ currencyCode?: string;
432
+ currencySymbol: string;
433
+ currencyPrecision?: number;
434
+ isLoggedIn?: boolean;
435
+ contactEmail?: string;
436
+ /** Host-owned validation feedback shown after the primary CTA is pressed. */
437
+ contactEmailError?: string;
438
+ lines: CheckoutLineItem[];
439
+ /** Product Upsell selections confirmed by the order replacement response. */
440
+ upsellSelections?: CheckoutUpsellSelection[];
441
+ /** A complete server-calculated order snapshot for live storefront rendering. */
442
+ summary?: CheckoutSummary;
443
+ /** Editor-only sample discounts. They are never part of a saved Checkout draft. */
444
+ previewSummaryDiscounts?: CheckoutSummaryDiscounts;
445
+ shippingRates: CheckoutShippingRate[];
446
+ shippingErrorMessage?: string;
447
+ selectedShippingRateId: string;
448
+ isShippingLoading?: boolean;
449
+ appliedCouponCode?: string;
450
+ appliedCoupons?: CheckoutAppliedCoupon[];
451
+ couponError?: string;
452
+ couponFeedback?: CheckoutCouponFeedback;
453
+ isCouponApplying?: boolean;
454
+ isOrderLoading?: boolean;
455
+ orderRefreshError?: string;
456
+ canSubmit?: boolean;
457
+ selectedPaymentMethod: string;
458
+ paymentMethods?: CheckoutPaymentMethod[];
459
+ expressPaymentMethods?: CheckoutExpressPaymentMethod[];
460
+ selectedExpressPaymentMethod?: string;
461
+ isSubmitting?: boolean;
462
+ mobileSummaryExpanded?: boolean;
463
+ mobileBottomSummaryExpanded?: boolean;
464
+ /** 完成页摘要独立展开,避免沿用 Checkout 顶部摘要的临时状态。 */
465
+ thankYouSummaryExpanded?: boolean;
466
+ selectedOfferSectionIds?: string[];
467
+ transactionPendingKeys?: string[];
468
+ transactionErrors?: Record<string, string>;
469
+ /** Live Checkout host restores persisted add-on choices before enabling controls. */
470
+ isCheckoutSelectionInitializing?: boolean;
471
+ };
472
+ type CheckoutRuntime = {
473
+ state: CheckoutPreviewState;
474
+ /** Final dynamic Checkout business boundary; fixed Sections keep their existing callbacks. */
475
+ dynamicCheckout?: CheckoutDynamicHost;
476
+ /** 订单完成页使用服务端确认的快照,禁止由主题层重新计算或修改。 */
477
+ thankYou?: CheckoutThankYouSnapshot;
478
+ brand?: CheckoutBrand;
479
+ cartUrl?: string;
480
+ account?: CheckoutAccount;
481
+ setLineQuantity?: (lineId: string, quantity: number) => void;
482
+ setUpsellProductQuantity?: (product: CheckoutPreviewProduct, options: {
483
+ sectionId?: string;
484
+ variant?: CheckoutPreviewProductVariant;
485
+ }, quantity: number) => void | Promise<void>;
486
+ addProduct?: (product: CheckoutPreviewProduct, options?: {
487
+ sectionId?: string;
488
+ variant?: CheckoutPreviewProductVariant;
489
+ }) => void | Promise<void>;
490
+ setProductVariant?: (product: CheckoutPreviewProduct, options: {
491
+ sectionId?: string;
492
+ variant?: CheckoutPreviewProductVariant;
493
+ }) => void | Promise<void>;
494
+ toggleConfiguredOffer?: (section: CheckoutSectionInstance, selected: boolean) => void | Promise<void>;
495
+ applyCoupon?: (code: string) => void | Promise<void>;
496
+ removeCoupon?: (code: string) => void | Promise<void>;
497
+ setShippingRate?: (rateId: string) => void;
498
+ setPaymentMethod?: (method: string) => void;
499
+ startExpressCheckout?: (method: string) => void;
500
+ renderExpressCheckout?: (props: CheckoutExpressCheckoutRenderProps) => ReactNode;
501
+ renderPaymentDetails?: (props: CheckoutPaymentDetailsRenderProps) => ReactNode;
502
+ renderPaymentAction?: (props: CheckoutPaymentActionRenderProps) => ReactNode;
503
+ setContactEmail?: (email: string) => void;
504
+ openSignIn?: () => void;
505
+ delivery?: CheckoutDeliveryState;
506
+ setDeliveryField?: (field: CheckoutDeliveryField, value: string) => void;
507
+ /** Validate a field after it has been touched; initial form state stays quiet. */
508
+ validateDeliveryField?: (field: keyof CheckoutDeliveryValues) => void;
509
+ setDeliveryCountry?: (countryId: string) => void;
510
+ setDeliveryState?: (stateId: string) => void;
511
+ setDeliveryCity?: (cityId: string) => void;
512
+ selectSavedAddress?: (addressId: string) => void;
513
+ setSavedAddressListExpanded?: (expanded: boolean) => void;
514
+ useNewDeliveryAddress?: () => void;
515
+ editSavedAddress?: (addressId: string) => void;
516
+ deleteSavedAddress?: (addressId: string) => void;
517
+ applyGoogleDeliveryAddress?: (address: CheckoutGoogleAddress) => void;
518
+ renderDeliveryAddressInput?: (props: CheckoutAddressInputRenderProps) => ReactNode;
519
+ billing?: CheckoutBillingState;
520
+ setBillingSameAsShipping?: (sameAsShipping: boolean) => void;
521
+ setBillingField?: (field: CheckoutDeliveryField, value: string) => void;
522
+ /** Validate a field after it has been touched; initial form state stays quiet. */
523
+ validateBillingField?: (field: keyof CheckoutDeliveryValues) => void;
524
+ setBillingCountry?: (countryId: string) => void;
525
+ setBillingState?: (stateId: string) => void;
526
+ setBillingCity?: (cityId: string) => void;
527
+ applyGoogleBillingAddress?: (address: CheckoutGoogleAddress) => void;
528
+ renderBillingAddressInput?: (props: CheckoutAddressInputRenderProps) => ReactNode;
529
+ signOut?: () => void;
530
+ setMobileSummaryExpanded?: (expanded: boolean) => void;
531
+ setMobileBottomSummaryExpanded?: (expanded: boolean) => void;
532
+ refreshThankYouOrder?: (input?: {
533
+ target?: "main" | "addOn" | "all";
534
+ }) => Promise<DynamicActionResult>;
535
+ setThankYouSummaryExpanded?: (expanded: boolean) => void;
536
+ submitOrder?: () => void | Promise<void | boolean>;
537
+ };
538
+ type CheckoutBrand = {
539
+ logo?: string;
540
+ name?: string;
541
+ homeUrl?: string;
542
+ };
543
+ type CheckoutPreviewProduct = {
544
+ id: string;
545
+ productId?: string;
546
+ productAttrUnique?: string;
547
+ /** True only when the source product is configured as an SPU (`spec_type: 1`). */
548
+ hasVariants?: boolean;
549
+ title: string;
550
+ variant?: string;
551
+ image?: string;
552
+ price: number;
553
+ compareAtPrice?: number;
554
+ available?: boolean;
555
+ variants?: CheckoutPreviewProductVariant[];
556
+ };
557
+ type CheckoutPreviewProductVariant = {
558
+ id: string;
559
+ productAttrUnique?: string;
560
+ title: string;
561
+ price: number;
562
+ compareAtPrice?: number;
563
+ image?: string;
564
+ available?: boolean;
565
+ isDefault?: boolean;
566
+ };
567
+ type CheckoutSummary = {
568
+ subtotal: number;
569
+ shipping: number;
570
+ total: number;
571
+ savings: number;
572
+ discounts: CheckoutSummaryDiscounts;
573
+ /** Only present when the Host has an authoritative tax amount; absence is unknown. */
574
+ tax?: number;
575
+ shippingOriginalPrice?: number;
576
+ chargedInUsd?: number;
577
+ };
578
+ type CheckoutAddress = {
579
+ name?: string;
580
+ line1?: string;
581
+ line2?: string;
582
+ city?: string;
583
+ state?: string;
584
+ zip?: string;
585
+ country?: string;
586
+ phone?: string;
587
+ };
588
+ type CheckoutThankYouSnapshot = {
589
+ confirmationNumber?: string;
590
+ orderNumber?: string;
591
+ orderStatus: "confirmed" | "processing" | "failed" | "unknown";
592
+ businessState?: {
593
+ paid?: boolean;
594
+ status?: string | number;
595
+ deleted?: boolean;
596
+ };
597
+ customer: {
598
+ name?: string;
599
+ fullName?: string;
600
+ email?: string;
601
+ phone?: string;
602
+ };
603
+ shippingAddress?: CheckoutAddress;
604
+ billingAddress?: CheckoutAddress;
605
+ billingSameAsShipping?: boolean;
606
+ shippingMethod?: string;
607
+ payment?: {
608
+ brand?: string;
609
+ last4?: string;
610
+ label?: string;
611
+ };
612
+ lines?: CheckoutLineItem[];
613
+ summary?: CheckoutSummary;
614
+ /** B6: no currency or amount is fabricated when the service omits it. */
615
+ currency?: {
616
+ code?: string;
617
+ symbol?: string;
618
+ precision?: number;
619
+ };
620
+ amounts?: {
621
+ subtotal?: number;
622
+ shipping?: number;
623
+ total?: number;
624
+ tax?: number;
625
+ };
626
+ reads?: {
627
+ main: CheckoutThankYouOrderRead;
628
+ addOn: CheckoutThankYouOrderRead;
629
+ };
630
+ /** Live-only child order snapshots for a Post-purchase group order. */
631
+ orderSummaries?: CheckoutThankYouOrderSummary[];
632
+ /** Live-only group total supplied by post_purchase.total_paid. */
633
+ mergedOrderTotal?: number;
634
+ /** Optional host-provided fulfillment progress; never inferred from totals. */
635
+ shippingProgress?: {
636
+ /** Zero-based index into steps, or the default Preparing/Shipped/Delivered steps. */
637
+ currentStep?: number;
638
+ /** Display-ready relative time, such as "just now". */
639
+ updatedAt?: string;
640
+ /** Host-formatted date or delivery window. */
641
+ estimatedDelivery?: string;
642
+ steps?: readonly string[];
643
+ };
644
+ };
645
+ type CheckoutThankYouOrderRead = {
646
+ orderId?: string;
647
+ status: "unknown" | "loading" | "success" | "empty" | "error";
648
+ refreshing: boolean;
649
+ stale: boolean;
650
+ error?: string;
651
+ /** Last successful, safe order data. Retained during refresh and failure. */
652
+ data?: CheckoutThankYouSnapshot;
653
+ };
654
+ type CheckoutThankYouOrderSummary = {
655
+ orderStatus?: CheckoutThankYouSnapshot["orderStatus"];
656
+ currency?: {
657
+ code?: string;
658
+ symbol?: string;
659
+ precision?: number;
660
+ };
661
+ orderNumber: string;
662
+ lines: CheckoutLineItem[];
663
+ summary: CheckoutSummary;
664
+ };
665
+ type OfferPurchaseOptionChoice = {
666
+ id: string;
667
+ label: string;
668
+ /** Supporting copy shown while this choice is selected. */
669
+ detail?: string;
670
+ };
671
+ type OfferPurchaseOptions = {
672
+ /** Visible heading. Defaults to "Purchase option". */
673
+ label?: string;
674
+ choices: OfferPurchaseOptionChoice[];
675
+ /** Choice selected on first render. */
676
+ selectedId?: string;
677
+ /** Supporting copy used when the selected choice has none of its own. */
678
+ detail?: string;
679
+ };
680
+ type PostPurchaseOfferRuntime = {
681
+ identity: {
682
+ sessionId: number;
683
+ sessionPageId: number;
684
+ pageType: OfferTemplateKey;
685
+ themeId: number;
686
+ handle: string;
687
+ };
688
+ /** Original Checkout order number supplied by the Storefront SSR Snapshot Base Order. */
689
+ orderConfirmation: {
690
+ orderSn: string;
691
+ /** Only set when the host has a real, safe destination. */
692
+ viewOrderUrl?: string;
693
+ };
694
+ /** Currency for fallback display when a recommendation variant omits it. */
695
+ currency: {
696
+ code: string;
697
+ symbol?: string;
698
+ precision?: number;
699
+ };
700
+ recommendations: readonly PostPurchaseOfferRecommendation[];
701
+ /** Host-owned transaction results shared by fixed and dynamic consumers. */
702
+ transactions?: Readonly<Record<number, {
703
+ status: PostPurchaseOfferPaymentStatus | "unknown" | "submitting";
704
+ attempt?: PostPurchaseOfferPaymentAttempt;
705
+ failureMessage?: string;
706
+ }>>;
707
+ continuation?: {
708
+ pending: boolean;
709
+ completed: boolean;
710
+ started?: boolean;
711
+ error?: string;
712
+ };
713
+ };
714
+ type PostPurchaseOfferRecommendation = {
715
+ recommendationId: number;
716
+ productId: number;
717
+ sort: number;
718
+ accepted: boolean;
719
+ selectedVariantId: number;
720
+ product: PostPurchaseOfferProduct;
721
+ /** Only PP-returned variants belong here, already matched to display data. */
722
+ variants: readonly PostPurchaseOfferVariant[];
723
+ /** Host-supplied purchase choices for this recommendation. */
724
+ purchaseOptions?: OfferPurchaseOptions;
725
+ };
726
+ type PostPurchaseOfferProduct = {
727
+ title: string;
728
+ image?: string;
729
+ description?: string;
730
+ rating?: number;
731
+ ratingCount?: number;
732
+ /** Display-only catalog metadata; it never supersedes a PP locked price. */
733
+ compareAtPrice?: string;
734
+ /** CSS color values keyed by normalized option label. */
735
+ colorSwatches: Record<string, string>;
736
+ /** Catalog-provided image swatches keyed by normalized option label. */
737
+ colorSwatchImages?: Record<string, string>;
738
+ purchaseOptions?: OfferPurchaseOptions;
739
+ };
740
+ type PostPurchaseOfferVariant = {
741
+ variantId: number;
742
+ sort: number;
743
+ /** Decimal string locked by the Post-purchase service. */
744
+ price: string;
745
+ /** PP-calculated unit saving for this exact variant. */
746
+ discountAmount?: string;
747
+ currency: string;
748
+ /** Post-purchase availability is authoritative over catalog stock. */
749
+ available: boolean;
750
+ title: string;
751
+ options: Record<string, string>;
752
+ image?: string;
753
+ /** Display-only catalog metadata; it never supersedes `price`. */
754
+ compareAtPrice?: string;
755
+ /** Variant-specific purchase choices. They override the product and recommendation. */
756
+ purchaseOptions?: OfferPurchaseOptions;
757
+ };
758
+ type PostPurchaseOfferRepriceInput = {
759
+ recommendationId: number;
760
+ variantId: number;
761
+ quantity: number;
762
+ /** Optional subscription/one-time choice selected by the Offer component. */
763
+ purchaseOptionId?: string;
764
+ };
765
+ type PostPurchaseOfferRepriceResult = {
766
+ recommendationId: number;
767
+ variantId: number;
768
+ quantity: number;
769
+ purchaseOptionId?: string;
770
+ /** Decimal string; never calculate money in the renderer. */
771
+ unitPrice: string;
772
+ /** Decimal string total for `quantity`; never calculate money in the renderer. */
773
+ amount: string;
774
+ currency: string;
775
+ };
776
+ type PostPurchaseOfferPaymentStatus = "not_started" | "processing" | "requires_action" | "succeeded" | "succeeded_pending_order" | "failed";
777
+ type PostPurchaseOfferAcceptResult = {
778
+ /** Payment/application outcome returned as `data.status` by the service. */
779
+ status: PostPurchaseOfferPaymentStatus;
780
+ /** Display-only message for an explicit payment failure. */
781
+ failureMessage?: string;
782
+ };
783
+ type PostPurchaseOfferPaymentStatusResult = {
784
+ /** Payment/application outcome returned as `data.status` by the service. */
785
+ status: PostPurchaseOfferPaymentStatus;
786
+ /** Display-only message for an explicit payment failure. */
787
+ failureMessage?: string;
788
+ };
789
+ type PostPurchaseOfferPaymentAttempt = PostPurchaseOfferRepriceInput;
790
+ type PostPurchaseOfferActions = {
791
+ getSnapshot?: () => PostPurchaseOfferRuntime;
792
+ subscribe?: (listener: () => void) => () => void;
793
+ reprice: (input: PostPurchaseOfferRepriceInput) => Promise<PostPurchaseOfferRepriceResult>;
794
+ accept: (input: PostPurchaseOfferRepriceInput) => Promise<PostPurchaseOfferAcceptResult>;
795
+ /** Reads one card's existing payment attempt without creating a new charge. */
796
+ getPaymentStatus?: (recommendationId: number) => Promise<PostPurchaseOfferPaymentStatusResult>;
797
+ /** Leaves the entered page, then opens Downsell or completes to Thank You. */
798
+ leaveAndContinue: () => Promise<void>;
799
+ /**
800
+ * Reads a same-tab retry tuple saved by the Storefront host after a previous
801
+ * Accept attempt. It is optional so a host without recovery storage remains
802
+ * safely usable, just without cross-refresh payment recovery.
803
+ */
804
+ getPaymentAttempt?: (recommendationId: number) => PostPurchaseOfferPaymentAttempt | undefined;
805
+ };
806
+ type MountRefresh = ((host: CheckoutRuntime) => void) & {
807
+ element: HTMLElement;
808
+ unmount(): void;
809
+ };
810
+ type Channel = {
811
+ host?: CheckoutRuntime;
812
+ snapshot?: DynamicCheckoutSnapshot;
813
+ preview?: boolean;
814
+ disposed?: boolean;
815
+ listeners: Set<(snapshot: DynamicCheckoutSnapshot) => void>;
816
+ paymentMounts: Set<MountRefresh>;
817
+ };
818
+ declare function toCheckoutSnapshot(host: CheckoutRuntime, preview?: boolean): {
819
+ contact: {
820
+ email: string | undefined;
821
+ error: string | undefined;
822
+ };
823
+ lines: CheckoutLineItem[];
824
+ summary: CheckoutSummary | undefined;
825
+ currency: Pick<{
826
+ code?: string;
827
+ symbol?: string;
828
+ precision?: number;
829
+ }, "symbol" | "code" | "precision">;
830
+ delivery: {
831
+ savedAddresses: Pick<CheckoutSavedAddress, "email" | "name" | "id" | "summary" | "canEdit" | "canDelete">[] | undefined;
832
+ useStateSelect: boolean;
833
+ useCitySelect: boolean;
834
+ phoneCode?: string;
835
+ savedAddressCount?: number | undefined;
836
+ selectedSavedAddressId?: string | undefined;
837
+ isSavedAddressListExpanded?: boolean | undefined;
838
+ isUsingNewAddress?: boolean | undefined;
839
+ googlePlacesApiKey?: string | undefined;
840
+ values: CheckoutDeliveryValues;
841
+ errors: Partial<CheckoutDeliveryValues> | undefined;
842
+ countryOptions: CheckoutDeliveryOption[];
843
+ stateOptions: CheckoutDeliveryOption[];
844
+ cityOptions: CheckoutDeliveryOption[];
845
+ };
846
+ billing: {
847
+ useStateSelect: boolean;
848
+ useCitySelect: boolean;
849
+ phoneCode?: string;
850
+ googlePlacesApiKey?: string | undefined;
851
+ sameAsShipping: boolean;
852
+ hasShippingAddress: boolean;
853
+ values: CheckoutDeliveryValues;
854
+ errors: Partial<CheckoutDeliveryValues> | undefined;
855
+ countryOptions: CheckoutDeliveryOption[];
856
+ stateOptions: CheckoutDeliveryOption[];
857
+ cityOptions: CheckoutDeliveryOption[];
858
+ };
859
+ shipping: {
860
+ rates: Pick<CheckoutShippingRate, "description" | "title" | "id" | "price">[];
861
+ selectedRateId: string;
862
+ isLoading: boolean | undefined;
863
+ error: string | undefined;
864
+ status: "available" | "error" | "loading" | "waiting_address" | "empty";
865
+ };
866
+ coupon: {
867
+ appliedCodes: string[];
868
+ applied: Pick<CheckoutAppliedCoupon, "code" | "label" | "removable">[];
869
+ error: string | undefined;
870
+ feedback: Pick<CheckoutCouponFeedback, "status" | "message" | "clearInput"> | undefined;
871
+ isApplying: boolean | undefined;
872
+ };
873
+ payment: {
874
+ methods: Pick<CheckoutPaymentMethod, "description" | "title" | "id" | "showCardBrandIcons">[];
875
+ selectedMethod: string;
876
+ isSubmitting: boolean | undefined;
877
+ expressMethods: Pick<CheckoutExpressPaymentMethod, "label" | "id" | "appearance">[];
878
+ };
879
+ status: CheckoutDynamicStatus;
880
+ };
881
+ export type DynamicCheckoutSnapshot = ReturnType<typeof toCheckoutSnapshot>;
882
+ declare function createDynamicCheckoutAdapter(context: DynamicComponentContext, channel: Channel, initial: CheckoutRuntime): {
883
+ getSnapshot: () => {
884
+ contact: {
885
+ email: string | undefined;
886
+ error: string | undefined;
887
+ };
888
+ lines: CheckoutLineItem[];
889
+ summary: CheckoutSummary | undefined;
890
+ currency: Pick<{
891
+ code?: string;
892
+ symbol?: string;
893
+ precision?: number;
894
+ }, "symbol" | "code" | "precision">;
895
+ delivery: {
896
+ savedAddresses: Pick<CheckoutSavedAddress, "email" | "name" | "id" | "summary" | "canEdit" | "canDelete">[] | undefined;
897
+ useStateSelect: boolean;
898
+ useCitySelect: boolean;
899
+ phoneCode?: string;
900
+ savedAddressCount?: number | undefined;
901
+ selectedSavedAddressId?: string | undefined;
902
+ isSavedAddressListExpanded?: boolean | undefined;
903
+ isUsingNewAddress?: boolean | undefined;
904
+ googlePlacesApiKey?: string | undefined;
905
+ values: CheckoutDeliveryValues;
906
+ errors: Partial<CheckoutDeliveryValues> | undefined;
907
+ countryOptions: CheckoutDeliveryOption[];
908
+ stateOptions: CheckoutDeliveryOption[];
909
+ cityOptions: CheckoutDeliveryOption[];
910
+ };
911
+ billing: {
912
+ useStateSelect: boolean;
913
+ useCitySelect: boolean;
914
+ phoneCode?: string;
915
+ googlePlacesApiKey?: string | undefined;
916
+ sameAsShipping: boolean;
917
+ hasShippingAddress: boolean;
918
+ values: CheckoutDeliveryValues;
919
+ errors: Partial<CheckoutDeliveryValues> | undefined;
920
+ countryOptions: CheckoutDeliveryOption[];
921
+ stateOptions: CheckoutDeliveryOption[];
922
+ cityOptions: CheckoutDeliveryOption[];
923
+ };
924
+ shipping: {
925
+ rates: Pick<CheckoutShippingRate, "description" | "title" | "id" | "price">[];
926
+ selectedRateId: string;
927
+ isLoading: boolean | undefined;
928
+ error: string | undefined;
929
+ status: "available" | "error" | "loading" | "waiting_address" | "empty";
930
+ };
931
+ coupon: {
932
+ appliedCodes: string[];
933
+ applied: Pick<CheckoutAppliedCoupon, "code" | "label" | "removable">[];
934
+ error: string | undefined;
935
+ feedback: Pick<CheckoutCouponFeedback, "status" | "message" | "clearInput"> | undefined;
936
+ isApplying: boolean | undefined;
937
+ };
938
+ payment: {
939
+ methods: Pick<CheckoutPaymentMethod, "description" | "title" | "id" | "showCardBrandIcons">[];
940
+ selectedMethod: string;
941
+ isSubmitting: boolean | undefined;
942
+ expressMethods: Pick<CheckoutExpressPaymentMethod, "label" | "id" | "appearance">[];
943
+ };
944
+ status: CheckoutDynamicStatus;
945
+ };
946
+ subscribe(listener: (snapshot: DynamicCheckoutSnapshot) => void): () => void;
947
+ contact: {
948
+ getState: () => {
949
+ email: string | undefined;
950
+ error: string | undefined;
951
+ };
952
+ setEmail: (email: string) => void;
953
+ validate: () => CheckoutValidationResult;
954
+ };
955
+ upsell: {
956
+ getProduct: (productId: string) => Promise<CheckoutProductResult>;
957
+ getSelections: () => readonly CheckoutUpsellSelection[];
958
+ setSelection: ({ productId, variantId, quantity }: {
959
+ productId: string;
960
+ variantId?: string;
961
+ quantity: number;
962
+ }) => Promise<{
963
+ ok: true;
964
+ outcome?: "applied" | "replaced_better" | "kept_better" | "removed";
965
+ message?: string;
966
+ } | {
967
+ ok: false;
968
+ code: CheckoutActionCode;
969
+ message?: string;
970
+ errors?: readonly CheckoutFieldError[];
971
+ }>;
972
+ remove: (productId: string) => Promise<{
973
+ ok: true;
974
+ outcome?: "applied" | "replaced_better" | "kept_better" | "removed";
975
+ message?: string;
976
+ } | {
977
+ ok: false;
978
+ code: CheckoutActionCode;
979
+ message?: string;
980
+ errors?: readonly CheckoutFieldError[];
981
+ }>;
982
+ };
983
+ delivery: {
984
+ getState: () => {
985
+ savedAddresses: Pick<CheckoutSavedAddress, "email" | "name" | "id" | "summary" | "canEdit" | "canDelete">[] | undefined;
986
+ useStateSelect: boolean;
987
+ useCitySelect: boolean;
988
+ phoneCode?: string;
989
+ savedAddressCount?: number | undefined;
990
+ selectedSavedAddressId?: string | undefined;
991
+ isSavedAddressListExpanded?: boolean | undefined;
992
+ isUsingNewAddress?: boolean | undefined;
993
+ googlePlacesApiKey?: string | undefined;
994
+ values: CheckoutDeliveryValues;
995
+ errors: Partial<CheckoutDeliveryValues> | undefined;
996
+ countryOptions: CheckoutDeliveryOption[];
997
+ stateOptions: CheckoutDeliveryOption[];
998
+ cityOptions: CheckoutDeliveryOption[];
999
+ };
1000
+ setField: ({ field, value }: {
1001
+ field: keyof CheckoutDeliveryState["values"];
1002
+ value: string;
1003
+ }) => void;
1004
+ validateField: (field: keyof CheckoutDeliveryState["values"]) => void;
1005
+ setCountry: (id: string) => void;
1006
+ setState: (id: string) => void;
1007
+ setCity: (id: string) => void;
1008
+ selectSavedAddress: (id: string) => Promise<{
1009
+ ok: true;
1010
+ outcome?: "applied" | "replaced_better" | "kept_better" | "removed";
1011
+ message?: string;
1012
+ } | {
1013
+ ok: false;
1014
+ code: CheckoutActionCode;
1015
+ message?: string;
1016
+ errors?: readonly CheckoutFieldError[];
1017
+ }>;
1018
+ useNewAddress: () => void;
1019
+ readonly openNewAddress: (() => Promise<{
1020
+ ok: true;
1021
+ outcome?: "applied" | "replaced_better" | "kept_better" | "removed";
1022
+ message?: string;
1023
+ } | {
1024
+ ok: false;
1025
+ code: CheckoutActionCode;
1026
+ message?: string;
1027
+ errors?: readonly CheckoutFieldError[];
1028
+ }>) | undefined;
1029
+ editSavedAddress: (id: string) => Promise<{
1030
+ ok: true;
1031
+ outcome?: "applied" | "replaced_better" | "kept_better" | "removed";
1032
+ message?: string;
1033
+ } | {
1034
+ ok: false;
1035
+ code: CheckoutActionCode;
1036
+ message?: string;
1037
+ errors?: readonly CheckoutFieldError[];
1038
+ }>;
1039
+ deleteSavedAddress: (id: string) => Promise<{
1040
+ ok: true;
1041
+ outcome?: "applied" | "replaced_better" | "kept_better" | "removed";
1042
+ message?: string;
1043
+ } | {
1044
+ ok: false;
1045
+ code: CheckoutActionCode;
1046
+ message?: string;
1047
+ errors?: readonly CheckoutFieldError[];
1048
+ }>;
1049
+ autocomplete: CheckoutAddressAutocomplete | undefined;
1050
+ };
1051
+ billing: {
1052
+ getState: () => {
1053
+ useStateSelect: boolean;
1054
+ useCitySelect: boolean;
1055
+ phoneCode?: string;
1056
+ googlePlacesApiKey?: string | undefined;
1057
+ sameAsShipping: boolean;
1058
+ hasShippingAddress: boolean;
1059
+ values: CheckoutDeliveryValues;
1060
+ errors: Partial<CheckoutDeliveryValues> | undefined;
1061
+ countryOptions: CheckoutDeliveryOption[];
1062
+ stateOptions: CheckoutDeliveryOption[];
1063
+ cityOptions: CheckoutDeliveryOption[];
1064
+ };
1065
+ setSameAsShipping: (value: boolean) => void;
1066
+ setField: ({ field, value }: {
1067
+ field: keyof CheckoutBillingState["values"];
1068
+ value: string;
1069
+ }) => void;
1070
+ validateField: (field: keyof CheckoutBillingState["values"]) => void;
1071
+ setCountry: (id: string) => void;
1072
+ setState: (id: string) => void;
1073
+ setCity: (id: string) => void;
1074
+ autocomplete: CheckoutAddressAutocomplete | undefined;
1075
+ };
1076
+ shipping: {
1077
+ getState: () => {
1078
+ rates: Pick<CheckoutShippingRate, "description" | "title" | "id" | "price">[];
1079
+ selectedRateId: string;
1080
+ isLoading: boolean | undefined;
1081
+ error: string | undefined;
1082
+ status: "available" | "error" | "loading" | "waiting_address" | "empty";
1083
+ };
1084
+ selectRate: (id: string) => Promise<{
1085
+ ok: true;
1086
+ outcome?: "applied" | "replaced_better" | "kept_better" | "removed";
1087
+ message?: string;
1088
+ } | {
1089
+ ok: false;
1090
+ code: CheckoutActionCode;
1091
+ message?: string;
1092
+ errors?: readonly CheckoutFieldError[];
1093
+ }>;
1094
+ };
1095
+ coupon: {
1096
+ getState: () => {
1097
+ appliedCodes: string[];
1098
+ applied: Pick<CheckoutAppliedCoupon, "code" | "label" | "removable">[];
1099
+ error: string | undefined;
1100
+ feedback: Pick<CheckoutCouponFeedback, "status" | "message" | "clearInput"> | undefined;
1101
+ isApplying: boolean | undefined;
1102
+ };
1103
+ apply: (code: string) => Promise<{
1104
+ ok: true;
1105
+ outcome?: "applied" | "replaced_better" | "kept_better" | "removed";
1106
+ message?: string;
1107
+ } | {
1108
+ ok: false;
1109
+ code: CheckoutActionCode;
1110
+ message?: string;
1111
+ errors?: readonly CheckoutFieldError[];
1112
+ }>;
1113
+ remove: (code: string) => Promise<{
1114
+ ok: true;
1115
+ outcome?: "applied" | "replaced_better" | "kept_better" | "removed";
1116
+ message?: string;
1117
+ } | {
1118
+ ok: false;
1119
+ code: CheckoutActionCode;
1120
+ message?: string;
1121
+ errors?: readonly CheckoutFieldError[];
1122
+ }>;
1123
+ };
1124
+ payment: {
1125
+ getState: () => {
1126
+ methods: Pick<CheckoutPaymentMethod, "description" | "title" | "id" | "showCardBrandIcons">[];
1127
+ selectedMethod: string;
1128
+ isSubmitting: boolean | undefined;
1129
+ expressMethods: Pick<CheckoutExpressPaymentMethod, "label" | "id" | "appearance">[];
1130
+ };
1131
+ selectMethod: (method: string) => Promise<{
1132
+ ok: true;
1133
+ outcome?: "applied" | "replaced_better" | "kept_better" | "removed";
1134
+ message?: string;
1135
+ } | {
1136
+ ok: false;
1137
+ code: CheckoutActionCode;
1138
+ message?: string;
1139
+ errors?: readonly CheckoutFieldError[];
1140
+ }>;
1141
+ mountSecureElement: ({ element, method }: {
1142
+ element: HTMLElement;
1143
+ method: string;
1144
+ }) => Promise<{
1145
+ unmount: () => void;
1146
+ validate(): Promise<{
1147
+ valid: boolean;
1148
+ message: string;
1149
+ }>;
1150
+ }>;
1151
+ mountAction: ({ element, method }: {
1152
+ element: HTMLElement;
1153
+ method: string;
1154
+ }) => Promise<{
1155
+ unmount: () => void;
1156
+ validate(): Promise<{
1157
+ valid: boolean;
1158
+ message: string;
1159
+ }>;
1160
+ }>;
1161
+ };
1162
+ express: {
1163
+ mount: ({ element }: {
1164
+ element: HTMLElement;
1165
+ }) => Promise<{
1166
+ unmount: () => void;
1167
+ validate(): Promise<{
1168
+ valid: boolean;
1169
+ message: string;
1170
+ }>;
1171
+ }>;
1172
+ };
1173
+ validation: {
1174
+ validateAll: () => Promise<CheckoutValidationResult>;
1175
+ };
1176
+ submit: () => Promise<{
1177
+ ok: true;
1178
+ orderId?: string;
1179
+ confirmationNumber?: string;
1180
+ redirectUrl?: string;
1181
+ } | {
1182
+ errors: readonly CheckoutFieldError[];
1183
+ ok: false;
1184
+ code: CheckoutActionCode;
1185
+ message?: string;
1186
+ blockedReasons?: readonly CheckoutSubmitBlock[];
1187
+ }>;
1188
+ };
1189
+ export type DynamicCheckoutRuntime = ReturnType<typeof createDynamicCheckoutAdapter>;
1190
+ type DynamicOfferRuntime = {
1191
+ getSnapshot(): PostPurchaseOfferRuntime;
1192
+ subscribe(listener: (snapshot: PostPurchaseOfferRuntime) => void): () => void;
1193
+ reprice?: PostPurchaseOfferActions["reprice"];
1194
+ accept?: PostPurchaseOfferActions["accept"];
1195
+ getPaymentStatus?: PostPurchaseOfferActions["getPaymentStatus"];
1196
+ getPaymentAttempt?: PostPurchaseOfferActions["getPaymentAttempt"];
1197
+ leaveAndContinue?: PostPurchaseOfferActions["leaveAndContinue"];
1198
+ };
1199
+ type DynamicOrderRuntime = DynamicOrderActions & {
1200
+ subscribe(listener: (snapshot: ReturnType<DynamicOrderRuntime["getSnapshot"]>) => void): () => void;
1201
+ getSnapshot(): (Readonly<CheckoutThankYouSnapshot> & {
1202
+ currency?: CheckoutThankYouSnapshot["currency"];
1203
+ }) | undefined;
1204
+ };
1205
+ export type DynamicRuntime = DynamicComponentRuntime & {
1206
+ page: DynamicComponentContext;
1207
+ brand?: DynamicBrandRuntime;
1208
+ navigation?: DynamicNavigationRuntime;
1209
+ cart?: DynamicCartRuntime;
1210
+ account?: DynamicAccountRuntime;
1211
+ checkout?: DynamicCheckoutRuntime;
1212
+ offer?: DynamicOfferRuntime;
1213
+ order?: DynamicOrderRuntime;
1214
+ };
1215
+ type DynamicComponentProps$1 = {
1216
+ settings: Record<string, unknown>;
1217
+ runtime: DynamicRuntime;
1218
+ context: DynamicComponentContext;
1219
+ };
1220
+ type DynamicComponentDefinition$1 = Omit<DynamicComponentDefinition, "Component"> & {
1221
+ Component: ComponentType<DynamicComponentProps$1>;
1222
+ };
1223
+
1224
+ export {
1225
+ DynamicComponentDefinition$1 as DynamicComponentDefinition,
1226
+ DynamicComponentProps$1 as DynamicComponentProps,
1227
+ };
1228
+
1229
+ export {};
1230
+