@misiki/gocommerce-connector 0.29.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -160,6 +160,7 @@ down stays best-effort: the storefront renders from its static record.
160
160
  | contact form, product enquiries | `/x/contact/messages`, with the form's hidden `website` honeypot passed on so the engine drops what a bot filled in |
161
161
  | search words, type-ahead (plugin on) | `/x/meilisearch/search`, falling back to the engine's own search when it is off or down |
162
162
  | store record | the storefront's own config, with the engine's currency, menus and module switches over it; the store's own logo, dark logo and icon (`logo_url`, `logo_dark_url`, `icon_url` from `/api/store`, D148) replace `logo`, `logoDark` and `favicon` when it has them; for the contact page (D156), the address once the store shows it (as `address: { street, city, state, pincode, country }`), `mapLocation` and `openingHours` when set, `businessCountry` (the store's ISO country, for the phone's country code), the `whatsapp-chat` plugin's number as `plugins.whatsappChatButton`, and Google Customer Reviews (ext/google-reviews) as `plugins.googleReviewsOptIn` (`active` while the survey is on), `plugins.googleStoreWidget` (`{ active, position: 'RIGHT_BOTTOM' \| 'LEFT_BOTTOM' }`, off without the survey), and the `criteo` plugin's account as `plugins.criteo: { active, accountId }` (the engine decides, never the static record) |
163
+ | store closed, or behind a password (D170) | `store-close` in `/api/plugins`: the store record's `closed` is `{ message, password }` while it is on, `password` saying whether the store has one (never what it is), and absent while the store is open, whatever the static record says and even when the rest of the record fails. When the plugin list itself cannot be read, the last answer stands; with none yet, the store reads as open. Through `POST /api/store/password`, `storeService.unlockStore(password, { clientAddress })` trims what was typed and answers `{ outcome: 'unlocked', pass: { token, expiresAt } }`, or an `outcome` of `wrong`, `throttled` (the engine allows 20 tries an hour), `open` (the store takes no password now) or `unavailable`, and never throws. It sends `clientAddress`, the shopper's, as `X-Forwarded-For` when it is one IP address, so shoppers behind one storefront do not share those tries; the engine believes it only from a server in its `GOCOMMERCE_TRUSTED_PROXIES`. `storeService.checkStorePass(token)` checks a pass without spending a try: the pass, or null when it is wrong, expired or ended by a new password, and it throws the `GoCommerceError` when the engine cannot answer |
163
164
  | resized product pictures | `/images/{store}/cdn-cgi/image/width=…/…` — the store record's `plugins.imageCdn` is turned on with provider `cloudflare` and the engine's `images_path` (from `/api/store`, D139) after `PUBLIC_GOCOMMERCE_API_URL`, so the storefront's srcset asks the engine for each width; an engine without it leaves the static record's setting |
164
165
 
165
166
  Blogs, banners, reels, chat, warranties, deals and uploads have no engine
@@ -201,6 +201,8 @@ type Product = {
201
201
  seo_description: string;
202
202
  image_url?: string;
203
203
  media_count?: number;
204
+ /** The picture after the lead, which a listing card shows on hover. */
205
+ hover_image_url?: string;
204
206
  /** The gallery, pictures and videos in order: on the public product only (D134). */
205
207
  media?: VariantImage[];
206
208
  /** The sold count rounded down; absent unless the shop shows counts and it passed the threshold (D134). */
@@ -297,6 +299,8 @@ type CartOffer = {
297
299
  free_shipping?: boolean;
298
300
  remaining?: Money;
299
301
  reason?: string;
302
+ /** Checkout applies it by itself when no code is typed (D179); absent on an engine before it. */
303
+ auto_apply?: boolean;
300
304
  };
301
305
  /** How far a basket is from free delivery (D133). */
302
306
  type FreeShipping = {
@@ -423,6 +427,24 @@ type CheckoutOptions = {
423
427
  }[];
424
428
  currency: string;
425
429
  };
430
+ /** What checkout would charge for a cart now, placing nothing (D185). */
431
+ type CheckoutQuote = {
432
+ subtotal: Money;
433
+ shipping: Money;
434
+ shipping_method?: string;
435
+ /** The code checkout took off; `auto_applied` when the shopper typed none and checkout chose it (D179). */
436
+ discount: {
437
+ code: string;
438
+ title: string;
439
+ auto_applied: boolean;
440
+ amount: Money;
441
+ free_shipping?: boolean;
442
+ } | null;
443
+ tax: Money;
444
+ tax_inclusive: boolean;
445
+ payment_fee: Money;
446
+ total: Money;
447
+ };
426
448
  type ShippingRate = {
427
449
  rate_id: number;
428
450
  name: string;
@@ -594,6 +616,11 @@ type OpeningHours = {
594
616
  opens: string;
595
617
  closes: string;
596
618
  };
619
+ /** `POST /api/store/password` (D170): a closed store's pass, from its password or a pass still good. */
620
+ type StorePassAnswer = {
621
+ token: string;
622
+ expires_at: string;
623
+ };
597
624
  type Vendor = {
598
625
  id: number;
599
626
  slug: string;
@@ -1453,6 +1480,27 @@ declare function toCartOffer(o: CartOffer, currency: string): {
1453
1480
  amount: number | null;
1454
1481
  remaining: number | null;
1455
1482
  reason: string;
1483
+ autoApply: boolean;
1484
+ };
1485
+ /**
1486
+ * A checkout quote under the names `toOrder` gives the order it becomes, so a
1487
+ * page shows the two the same way.
1488
+ */
1489
+ declare function toCheckoutQuote(q: CheckoutQuote): {
1490
+ subtotal: number;
1491
+ shippingCharges: number;
1492
+ shippingMethod: string | null;
1493
+ discount: number;
1494
+ coupon: {
1495
+ code: string;
1496
+ title: string;
1497
+ autoApplied: boolean;
1498
+ freeShipping: boolean;
1499
+ } | null;
1500
+ tax: number;
1501
+ taxIncluded: boolean;
1502
+ codCharges: number;
1503
+ total: number;
1456
1504
  };
1457
1505
  declare function toFreeShipping(f: FreeShipping): {
1458
1506
  qualifies: boolean;
@@ -3856,6 +3904,7 @@ declare class CartService extends BaseService {
3856
3904
  amount: number | null;
3857
3905
  remaining: number | null;
3858
3906
  reason: string;
3907
+ autoApply: boolean;
3859
3908
  }[]>;
3860
3909
  /**
3861
3910
  * How far the bag is from free delivery (D133), read from the store's own
@@ -4618,6 +4667,7 @@ declare const customizerService: CustomizerService;
4618
4667
  * the order page shows `payment_status` once the webhook has landed.
4619
4668
  */
4620
4669
  declare class CheckoutService extends BaseService {
4670
+ private expected;
4621
4671
  /** Delivery options for the address on the cart: `{ data: [{ id, name, base_rate }] }`. */
4622
4672
  getShippingRates({ cartId }?: {
4623
4673
  cartId?: string;
@@ -4844,6 +4894,45 @@ declare class CheckoutService extends BaseService {
4844
4894
  }[];
4845
4895
  currency: string;
4846
4896
  }>;
4897
+ /**
4898
+ * What checkout would charge for the cart now, by the storefront's method
4899
+ * code (`COD`, `RAZORPAY`, `PAYPAL`) or none yet (D185). Null until the
4900
+ * address step has stored an address, and null from an engine before D185.
4901
+ *
4902
+ * A refusal is checkout's own: the same GoCommerceError, with the same
4903
+ * message, that placing the order would raise now.
4904
+ */
4905
+ getQuote({ cartId, method }?: {
4906
+ cartId?: string;
4907
+ method?: string;
4908
+ }): Promise<{
4909
+ subtotal: number;
4910
+ shippingCharges: number;
4911
+ shippingMethod: string | null;
4912
+ discount: number;
4913
+ coupon: {
4914
+ code: string;
4915
+ title: string;
4916
+ autoApplied: boolean;
4917
+ freeShipping: boolean;
4918
+ } | null;
4919
+ tax: number;
4920
+ taxIncluded: boolean;
4921
+ codCharges: number;
4922
+ total: number;
4923
+ } | null>;
4924
+ /**
4925
+ * The total on screen as the shopper confirms, from getQuote, or null when nothing was quoted
4926
+ * (D185). Every order placed for the cart then carries it, and checkout refuses one whose own
4927
+ * total differs instead of charging it: `onChange` gets checkout's figures now and the sentence
4928
+ * the placing call fails with.
4929
+ */
4930
+ expectTotal({ cartId, total, onChange, }: {
4931
+ cartId?: string;
4932
+ total?: number | null;
4933
+ onChange?: Expected['onChange'];
4934
+ }): void;
4935
+ private storedCheckout;
4847
4936
  private redirectGateway;
4848
4937
  /**
4849
4938
  * One checkout attempt.
@@ -4859,6 +4948,10 @@ declare class CheckoutService extends BaseService {
4859
4948
  }
4860
4949
  /** The engine's gateways that take payment on their own hosted page. */
4861
4950
  declare const REDIRECT_GATEWAYS: Set<string>;
4951
+ type Expected = {
4952
+ total: number;
4953
+ onChange?: (quote: ReturnType<typeof toCheckoutQuote>, message: string) => void;
4954
+ };
4862
4955
  declare const checkoutService: CheckoutService;
4863
4956
 
4864
4957
  declare class PaymentMethodService extends BaseService {
@@ -4893,8 +4986,9 @@ declare const paymentMethodService: PaymentMethodService;
4893
4986
  * `cartService.applyCoupon`.
4894
4987
  *
4895
4988
  * The drawer's shape: `amount` is the percentage or the amount,
4896
- * `minAmount` the bag it needs, and `description` says what is
4897
- * still missing.
4989
+ * `minAmount` the bag it needs, `description` says what is
4990
+ * still missing, and `autoApply` marks a code checkout applies by
4991
+ * itself (D179).
4898
4992
  */
4899
4993
  declare class CouponService extends BaseService {
4900
4994
  listCoupons(_args?: Record<string, unknown>): Promise<{
@@ -4908,6 +5002,7 @@ declare class CouponService extends BaseService {
4908
5002
  description: string;
4909
5003
  applies: boolean;
4910
5004
  remaining: number | null;
5005
+ autoApply: boolean;
4911
5006
  }[];
4912
5007
  count: number;
4913
5008
  pageSize: number;
@@ -6549,9 +6644,11 @@ declare class StoreService extends BaseService {
6549
6644
  storeId?: string;
6550
6645
  domain?: string;
6551
6646
  }): Promise<{
6647
+ closed: StoreClosed | undefined;
6552
6648
  id: any;
6553
6649
  }>;
6554
6650
  getStore(storeId?: string): Promise<{
6651
+ closed: StoreClosed | undefined;
6555
6652
  id: any;
6556
6653
  }>;
6557
6654
  /**
@@ -6568,9 +6665,39 @@ declare class StoreService extends BaseService {
6568
6665
  * that list lives here.
6569
6666
  */
6570
6667
  post<T = any>(path: string, data?: unknown): Promise<T>;
6668
+ /**
6669
+ * A closed store's password (D170), traded for a pass. Never throws. The
6670
+ * engine allows 20 tries an hour per client, and sees this server as the
6671
+ * client unless `clientAddress`, the shopper's, travels as `X-Forwarded-For`.
6672
+ */
6673
+ unlockStore(password: string, { clientAddress }?: {
6674
+ clientAddress?: string;
6675
+ }): Promise<StoreUnlock>;
6676
+ /**
6677
+ * A pass checked without spending a try: the pass, or null when it is wrong,
6678
+ * expired, ended by a new password, or the store takes none now. Throws when
6679
+ * the engine cannot say.
6680
+ */
6681
+ checkStorePass(token: string): Promise<StorePass | null>;
6682
+ private storePass;
6571
6683
  private live;
6572
6684
  }
6573
6685
  declare const storeService: StoreService;
6686
+ /** A store its owner closed (D170): the message to show, and whether a password lets a visitor in. */
6687
+ type StoreClosed = {
6688
+ message: string;
6689
+ password: boolean;
6690
+ };
6691
+ type StorePass = {
6692
+ token: string;
6693
+ expiresAt: Date;
6694
+ };
6695
+ type StoreUnlock = {
6696
+ outcome: 'unlocked';
6697
+ pass: StorePass;
6698
+ } | {
6699
+ outcome: 'wrong' | 'throttled' | 'open' | 'unavailable';
6700
+ };
6574
6701
 
6575
6702
  /**
6576
6703
  * Content pages from ext/cms, in the shopper's language with the store's
@@ -6663,6 +6790,7 @@ type LayoutCollection = {
6663
6790
  slug: string;
6664
6791
  link: string;
6665
6792
  image: string | null;
6793
+ description: string | null;
6666
6794
  };
6667
6795
  /**
6668
6796
  * One section of a composed page. `settings` is the merchant's, as validated
@@ -6908,21 +7036,26 @@ declare class PluginService extends BaseService {
6908
7036
  /** The store record again, for the callers that ask for it as "settings" or "init". */
6909
7037
  declare class SettingService extends BaseService {
6910
7038
  fetchSettings(_args?: Record<string, unknown>): Promise<{
7039
+ closed: StoreClosed | undefined;
6911
7040
  id: any;
6912
7041
  }>;
6913
7042
  list(args?: Record<string, unknown>): Promise<{
7043
+ closed: StoreClosed | undefined;
6914
7044
  id: any;
6915
7045
  }>;
6916
7046
  }
6917
7047
  declare class InitService extends SettingService {
6918
7048
  fetchInit(_args?: Record<string, unknown>): Promise<{
6919
7049
  storeOne: {
7050
+ closed: StoreClosed | undefined;
6920
7051
  id: any;
6921
7052
  };
6922
7053
  store: {
7054
+ closed: StoreClosed | undefined;
6923
7055
  id: any;
6924
7056
  };
6925
7057
  settings: {
7058
+ closed: StoreClosed | undefined;
6926
7059
  id: any;
6927
7060
  };
6928
7061
  }>;
@@ -7999,4 +8132,4 @@ declare class B2bService extends BaseService {
7999
8132
  }
8000
8133
  declare const b2bService: B2bService;
8001
8134
 
8002
- export { FaqService as $, type AddOn as A, type B2bPlaced as B, type Cart as C, type CompanyOrder as D, ContactService as E, CountryService as F, CouponService as G, type Credentials as H, type Credit as I, CurrencyService as J, type Customer as K, type CustomizerDesign as L, type CustomizerDocument as M, type CustomizerEditor as N, type CustomizerFile as O, type CustomizerLayer as P, type CustomizerSavedDesign as Q, CustomizerService as R, type CustomizerSetup as S, type CustomizerUpload as T, DealService as U, DemoRequestService as V, type EngineRequest as W, EnquiryService as X, type Envelope as Y, type FacetValue as Z, type Faq as _, type Address as a, type SiteFooter as a$, FeedbackService as a0, type FooterSettings as a1, type FreeShipping as a2, type Fulfillment as a3, GalleryService as a4, type GooglePlace as a5, type GoogleReview as a6, GoogleReviewService as a7, type GoogleReviews as a8, type GoogleSurvey as a9, PageService as aA, type PaymentIntent as aB, PaymentMethodService as aC, type Plugin as aD, PluginService as aE, PopularSearchService as aF, PopularityService as aG, type Postcode as aH, type Product as aI, type ProductFacets as aJ, type ProductOption as aK, ProductService as aL, ProfileService as aM, type Quote as aN, REDIRECT_GATEWAYS as aO, ReelsService as aP, RegionService as aQ, type RejectedLine as aR, type Review as aS, type ReviewPage as aT, ReviewService as aU, type SearchDoc as aV, type SearchResult as aW, SearchService as aX, SettingService as aY, type ShippingRate as aZ, type SiteChrome as a_, type HeaderSettings as aa, type HomeLayout as ab, type HomeLayoutSection as ac, HomeService as ad, type IdentityAddress as ae, InitService as af, type Invitation as ag, type LayoutCollection as ah, type LayoutPage as ai, LayoutService as aj, type Lead as ak, type ListMeta as al, MeilisearchService as am, type Member as an, type Menu as ao, type MenuItem as ap, MenuService as aq, type MenuSummary as ar, type Money as as, NewsletterService as at, type Offer as au, type OpeningHours as av, type Order as aw, type OrderLine as ax, OrderService as ay, type PageLayout as az, AddressService as b, newsletterService as b$, type SiteHeader as b0, type SocialLink as b1, StateService as b2, type StoreProfile as b3, StoreService as b4, type StorefrontCategory as b5, type StorefrontMenu as b6, type StorefrontOrder as b7, type StorefrontProduct as b8, type ThemeSettings as b9, checkoutService as bA, collectionService as bB, contactService as bC, countryService as bD, couponService as bE, currencyExponent as bF, currencyService as bG, customizerService as bH, dealService as bI, demoRequestService as bJ, emptyCart as bK, emptyPage as bL, enquiryService as bM, faqService as bN, feedbackService as bO, fromEngineAddress as bP, fromIdentityAddress as bQ, fromSearchDoc as bR, galleryService as bS, googleReviewService as bT, homeService as bU, initService as bV, layoutService as bW, mediaUrl as bX, meilisearchService as bY, menuService as bZ, minorToMajor as b_, type ThemeSettingsResult as ba, UploadService as bb, UserService as bc, type Variant as bd, type VariantImage as be, VariantService as bf, VarniCustomDesignService as bg, VarniCustomProductService as bh, type Vendor as bi, VendorService as bj, WarrantyService as bk, type WhatsappConsent as bl, type WhatsappConsentOffer as bm, WhatsappService as bn, type Wishlist as bo, type WishlistItem as bp, WishlistService as bq, addressService as br, authService as bs, autocompleteService as bt, b2bService as bu, bannerService as bv, blogService as bw, cartService as bx, categoryService as by, chatService as bz, type AppliedDiscount as c, orderService as c0, ownDomain as c1, pageService as c2, paymentMethodService as c3, pluginService as c4, pluginsService as c5, popularSearchService as c6, popularityService as c7, priceOf as c8, productImages as c9, toMinor as cA, toOrder as cB, toPage as cC, toProduct as cD, toRating as cE, toStorefrontFacets as cF, toUser as cG, toVariant as cH, toVendor as cI, uploadService as cJ, userService as cK, variantService as cL, varniCustomDesignService as cM, varniCustomProductService as cN, vendorService as cO, warrantyService as cP, whatsappService as cQ, wishlistService as cR, productService as ca, productVideos as cb, profileService as cc, qs as cd, reelsService as ce, regionService as cf, reviewService as cg, searchService as ch, setRequestHost as ci, settingService as cj, settingsService as ck, stateService as cl, staticStore as cm, storeForHost as cn, storeService as co, toAddOn as cp, toCart as cq, toCartLine as cr, toCartOffer as cs, toCategory as ct, toCmsPage as cu, toCollection as cv, toEngineAddress as cw, toFreeShipping as cx, toIdentityAddress as cy, toMajor as cz, type Approval as d, type AuthResponse as e, AuthService as f, AutocompleteService as g, type B2bRole as h, B2bService as i, BannerService as j, BaseService as k, BlogService as l, type CartLine as m, type CartOffer as n, CartService as o, CatalogService as p, type Category as q, CategoryService as r, ChatService as s, type CheckoutOptions as t, type CheckoutResult as u, CheckoutService as v, type CmsPage as w, type Collection as x, CollectionService as y, type Company as z };
8135
+ export { type Faq as $, type AddOn as A, type B2bPlaced as B, type Cart as C, type Company as D, type CompanyOrder as E, ContactService as F, CountryService as G, CouponService as H, type Credentials as I, type Credit as J, CurrencyService as K, type Customer as L, type CustomizerDesign as M, type CustomizerDocument as N, type CustomizerEditor as O, type CustomizerFile as P, type CustomizerLayer as Q, type CustomizerSavedDesign as R, CustomizerService as S, type CustomizerSetup as T, type CustomizerUpload as U, DealService as V, DemoRequestService as W, type EngineRequest as X, EnquiryService as Y, type Envelope as Z, type FacetValue as _, type Address as a, type SiteChrome as a$, FaqService as a0, FeedbackService as a1, type FooterSettings as a2, type FreeShipping as a3, type Fulfillment as a4, GalleryService as a5, type GooglePlace as a6, type GoogleReview as a7, GoogleReviewService as a8, type GoogleReviews as a9, type PageLayout as aA, PageService as aB, type PaymentIntent as aC, PaymentMethodService as aD, type Plugin as aE, PluginService as aF, PopularSearchService as aG, PopularityService as aH, type Postcode as aI, type Product as aJ, type ProductFacets as aK, type ProductOption as aL, ProductService as aM, ProfileService as aN, type Quote as aO, REDIRECT_GATEWAYS as aP, ReelsService as aQ, RegionService as aR, type RejectedLine as aS, type Review as aT, type ReviewPage as aU, ReviewService as aV, type SearchDoc as aW, type SearchResult as aX, SearchService as aY, SettingService as aZ, type ShippingRate as a_, type GoogleSurvey as aa, type HeaderSettings as ab, type HomeLayout as ac, type HomeLayoutSection as ad, HomeService as ae, type IdentityAddress as af, InitService as ag, type Invitation as ah, type LayoutCollection as ai, type LayoutPage as aj, LayoutService as ak, type Lead as al, type ListMeta as am, MeilisearchService as an, type Member as ao, type Menu as ap, type MenuItem as aq, MenuService as ar, type MenuSummary as as, type Money as at, NewsletterService as au, type Offer as av, type OpeningHours as aw, type Order as ax, type OrderLine as ay, OrderService as az, AddressService as b, layoutService as b$, type SiteFooter as b0, type SiteHeader as b1, type SocialLink as b2, StateService as b3, type StoreClosed as b4, type StorePass as b5, type StorePassAnswer as b6, type StoreProfile as b7, StoreService as b8, type StoreUnlock as b9, bannerService as bA, blogService as bB, cartService as bC, categoryService as bD, chatService as bE, checkoutService as bF, collectionService as bG, contactService as bH, countryService as bI, couponService as bJ, currencyExponent as bK, currencyService as bL, customizerService as bM, dealService as bN, demoRequestService as bO, emptyCart as bP, emptyPage as bQ, enquiryService as bR, faqService as bS, feedbackService as bT, fromEngineAddress as bU, fromIdentityAddress as bV, fromSearchDoc as bW, galleryService as bX, googleReviewService as bY, homeService as bZ, initService as b_, type StorefrontCategory as ba, type StorefrontMenu as bb, type StorefrontOrder as bc, type StorefrontProduct as bd, type ThemeSettings as be, type ThemeSettingsResult as bf, UploadService as bg, UserService as bh, type Variant as bi, type VariantImage as bj, VariantService as bk, VarniCustomDesignService as bl, VarniCustomProductService as bm, type Vendor as bn, VendorService as bo, WarrantyService as bp, type WhatsappConsent as bq, type WhatsappConsentOffer as br, WhatsappService as bs, type Wishlist as bt, type WishlistItem as bu, WishlistService as bv, addressService as bw, authService as bx, autocompleteService as by, b2bService as bz, type AppliedDiscount as c, mediaUrl as c0, meilisearchService as c1, menuService as c2, minorToMajor as c3, newsletterService as c4, orderService as c5, ownDomain as c6, pageService as c7, paymentMethodService as c8, pluginService as c9, toCmsPage as cA, toCollection as cB, toEngineAddress as cC, toFreeShipping as cD, toIdentityAddress as cE, toMajor as cF, toMinor as cG, toOrder as cH, toPage as cI, toProduct as cJ, toRating as cK, toStorefrontFacets as cL, toUser as cM, toVariant as cN, toVendor as cO, uploadService as cP, userService as cQ, variantService as cR, varniCustomDesignService as cS, varniCustomProductService as cT, vendorService as cU, warrantyService as cV, whatsappService as cW, wishlistService as cX, pluginsService as ca, popularSearchService as cb, popularityService as cc, priceOf as cd, productImages as ce, productService as cf, productVideos as cg, profileService as ch, qs as ci, reelsService as cj, regionService as ck, reviewService as cl, searchService as cm, setRequestHost as cn, settingService as co, settingsService as cp, stateService as cq, staticStore as cr, storeForHost as cs, storeService as ct, toAddOn as cu, toCart as cv, toCartLine as cw, toCartOffer as cx, toCategory as cy, toCheckoutQuote as cz, type Approval as d, type AuthResponse as e, AuthService as f, AutocompleteService as g, type B2bRole as h, B2bService as i, BannerService as j, BaseService as k, BlogService as l, type CartLine as m, type CartOffer as n, CartService as o, CatalogService as p, type Category as q, CategoryService as r, ChatService as s, type CheckoutOptions as t, type CheckoutQuote as u, type CheckoutResult as v, CheckoutService as w, type CmsPage as x, type Collection as y, CollectionService as z };
@@ -201,6 +201,8 @@ type Product = {
201
201
  seo_description: string;
202
202
  image_url?: string;
203
203
  media_count?: number;
204
+ /** The picture after the lead, which a listing card shows on hover. */
205
+ hover_image_url?: string;
204
206
  /** The gallery, pictures and videos in order: on the public product only (D134). */
205
207
  media?: VariantImage[];
206
208
  /** The sold count rounded down; absent unless the shop shows counts and it passed the threshold (D134). */
@@ -297,6 +299,8 @@ type CartOffer = {
297
299
  free_shipping?: boolean;
298
300
  remaining?: Money;
299
301
  reason?: string;
302
+ /** Checkout applies it by itself when no code is typed (D179); absent on an engine before it. */
303
+ auto_apply?: boolean;
300
304
  };
301
305
  /** How far a basket is from free delivery (D133). */
302
306
  type FreeShipping = {
@@ -423,6 +427,24 @@ type CheckoutOptions = {
423
427
  }[];
424
428
  currency: string;
425
429
  };
430
+ /** What checkout would charge for a cart now, placing nothing (D185). */
431
+ type CheckoutQuote = {
432
+ subtotal: Money;
433
+ shipping: Money;
434
+ shipping_method?: string;
435
+ /** The code checkout took off; `auto_applied` when the shopper typed none and checkout chose it (D179). */
436
+ discount: {
437
+ code: string;
438
+ title: string;
439
+ auto_applied: boolean;
440
+ amount: Money;
441
+ free_shipping?: boolean;
442
+ } | null;
443
+ tax: Money;
444
+ tax_inclusive: boolean;
445
+ payment_fee: Money;
446
+ total: Money;
447
+ };
426
448
  type ShippingRate = {
427
449
  rate_id: number;
428
450
  name: string;
@@ -594,6 +616,11 @@ type OpeningHours = {
594
616
  opens: string;
595
617
  closes: string;
596
618
  };
619
+ /** `POST /api/store/password` (D170): a closed store's pass, from its password or a pass still good. */
620
+ type StorePassAnswer = {
621
+ token: string;
622
+ expires_at: string;
623
+ };
597
624
  type Vendor = {
598
625
  id: number;
599
626
  slug: string;
@@ -1453,6 +1480,27 @@ declare function toCartOffer(o: CartOffer, currency: string): {
1453
1480
  amount: number | null;
1454
1481
  remaining: number | null;
1455
1482
  reason: string;
1483
+ autoApply: boolean;
1484
+ };
1485
+ /**
1486
+ * A checkout quote under the names `toOrder` gives the order it becomes, so a
1487
+ * page shows the two the same way.
1488
+ */
1489
+ declare function toCheckoutQuote(q: CheckoutQuote): {
1490
+ subtotal: number;
1491
+ shippingCharges: number;
1492
+ shippingMethod: string | null;
1493
+ discount: number;
1494
+ coupon: {
1495
+ code: string;
1496
+ title: string;
1497
+ autoApplied: boolean;
1498
+ freeShipping: boolean;
1499
+ } | null;
1500
+ tax: number;
1501
+ taxIncluded: boolean;
1502
+ codCharges: number;
1503
+ total: number;
1456
1504
  };
1457
1505
  declare function toFreeShipping(f: FreeShipping): {
1458
1506
  qualifies: boolean;
@@ -3856,6 +3904,7 @@ declare class CartService extends BaseService {
3856
3904
  amount: number | null;
3857
3905
  remaining: number | null;
3858
3906
  reason: string;
3907
+ autoApply: boolean;
3859
3908
  }[]>;
3860
3909
  /**
3861
3910
  * How far the bag is from free delivery (D133), read from the store's own
@@ -4618,6 +4667,7 @@ declare const customizerService: CustomizerService;
4618
4667
  * the order page shows `payment_status` once the webhook has landed.
4619
4668
  */
4620
4669
  declare class CheckoutService extends BaseService {
4670
+ private expected;
4621
4671
  /** Delivery options for the address on the cart: `{ data: [{ id, name, base_rate }] }`. */
4622
4672
  getShippingRates({ cartId }?: {
4623
4673
  cartId?: string;
@@ -4844,6 +4894,45 @@ declare class CheckoutService extends BaseService {
4844
4894
  }[];
4845
4895
  currency: string;
4846
4896
  }>;
4897
+ /**
4898
+ * What checkout would charge for the cart now, by the storefront's method
4899
+ * code (`COD`, `RAZORPAY`, `PAYPAL`) or none yet (D185). Null until the
4900
+ * address step has stored an address, and null from an engine before D185.
4901
+ *
4902
+ * A refusal is checkout's own: the same GoCommerceError, with the same
4903
+ * message, that placing the order would raise now.
4904
+ */
4905
+ getQuote({ cartId, method }?: {
4906
+ cartId?: string;
4907
+ method?: string;
4908
+ }): Promise<{
4909
+ subtotal: number;
4910
+ shippingCharges: number;
4911
+ shippingMethod: string | null;
4912
+ discount: number;
4913
+ coupon: {
4914
+ code: string;
4915
+ title: string;
4916
+ autoApplied: boolean;
4917
+ freeShipping: boolean;
4918
+ } | null;
4919
+ tax: number;
4920
+ taxIncluded: boolean;
4921
+ codCharges: number;
4922
+ total: number;
4923
+ } | null>;
4924
+ /**
4925
+ * The total on screen as the shopper confirms, from getQuote, or null when nothing was quoted
4926
+ * (D185). Every order placed for the cart then carries it, and checkout refuses one whose own
4927
+ * total differs instead of charging it: `onChange` gets checkout's figures now and the sentence
4928
+ * the placing call fails with.
4929
+ */
4930
+ expectTotal({ cartId, total, onChange, }: {
4931
+ cartId?: string;
4932
+ total?: number | null;
4933
+ onChange?: Expected['onChange'];
4934
+ }): void;
4935
+ private storedCheckout;
4847
4936
  private redirectGateway;
4848
4937
  /**
4849
4938
  * One checkout attempt.
@@ -4859,6 +4948,10 @@ declare class CheckoutService extends BaseService {
4859
4948
  }
4860
4949
  /** The engine's gateways that take payment on their own hosted page. */
4861
4950
  declare const REDIRECT_GATEWAYS: Set<string>;
4951
+ type Expected = {
4952
+ total: number;
4953
+ onChange?: (quote: ReturnType<typeof toCheckoutQuote>, message: string) => void;
4954
+ };
4862
4955
  declare const checkoutService: CheckoutService;
4863
4956
 
4864
4957
  declare class PaymentMethodService extends BaseService {
@@ -4893,8 +4986,9 @@ declare const paymentMethodService: PaymentMethodService;
4893
4986
  * `cartService.applyCoupon`.
4894
4987
  *
4895
4988
  * The drawer's shape: `amount` is the percentage or the amount,
4896
- * `minAmount` the bag it needs, and `description` says what is
4897
- * still missing.
4989
+ * `minAmount` the bag it needs, `description` says what is
4990
+ * still missing, and `autoApply` marks a code checkout applies by
4991
+ * itself (D179).
4898
4992
  */
4899
4993
  declare class CouponService extends BaseService {
4900
4994
  listCoupons(_args?: Record<string, unknown>): Promise<{
@@ -4908,6 +5002,7 @@ declare class CouponService extends BaseService {
4908
5002
  description: string;
4909
5003
  applies: boolean;
4910
5004
  remaining: number | null;
5005
+ autoApply: boolean;
4911
5006
  }[];
4912
5007
  count: number;
4913
5008
  pageSize: number;
@@ -6549,9 +6644,11 @@ declare class StoreService extends BaseService {
6549
6644
  storeId?: string;
6550
6645
  domain?: string;
6551
6646
  }): Promise<{
6647
+ closed: StoreClosed | undefined;
6552
6648
  id: any;
6553
6649
  }>;
6554
6650
  getStore(storeId?: string): Promise<{
6651
+ closed: StoreClosed | undefined;
6555
6652
  id: any;
6556
6653
  }>;
6557
6654
  /**
@@ -6568,9 +6665,39 @@ declare class StoreService extends BaseService {
6568
6665
  * that list lives here.
6569
6666
  */
6570
6667
  post<T = any>(path: string, data?: unknown): Promise<T>;
6668
+ /**
6669
+ * A closed store's password (D170), traded for a pass. Never throws. The
6670
+ * engine allows 20 tries an hour per client, and sees this server as the
6671
+ * client unless `clientAddress`, the shopper's, travels as `X-Forwarded-For`.
6672
+ */
6673
+ unlockStore(password: string, { clientAddress }?: {
6674
+ clientAddress?: string;
6675
+ }): Promise<StoreUnlock>;
6676
+ /**
6677
+ * A pass checked without spending a try: the pass, or null when it is wrong,
6678
+ * expired, ended by a new password, or the store takes none now. Throws when
6679
+ * the engine cannot say.
6680
+ */
6681
+ checkStorePass(token: string): Promise<StorePass | null>;
6682
+ private storePass;
6571
6683
  private live;
6572
6684
  }
6573
6685
  declare const storeService: StoreService;
6686
+ /** A store its owner closed (D170): the message to show, and whether a password lets a visitor in. */
6687
+ type StoreClosed = {
6688
+ message: string;
6689
+ password: boolean;
6690
+ };
6691
+ type StorePass = {
6692
+ token: string;
6693
+ expiresAt: Date;
6694
+ };
6695
+ type StoreUnlock = {
6696
+ outcome: 'unlocked';
6697
+ pass: StorePass;
6698
+ } | {
6699
+ outcome: 'wrong' | 'throttled' | 'open' | 'unavailable';
6700
+ };
6574
6701
 
6575
6702
  /**
6576
6703
  * Content pages from ext/cms, in the shopper's language with the store's
@@ -6663,6 +6790,7 @@ type LayoutCollection = {
6663
6790
  slug: string;
6664
6791
  link: string;
6665
6792
  image: string | null;
6793
+ description: string | null;
6666
6794
  };
6667
6795
  /**
6668
6796
  * One section of a composed page. `settings` is the merchant's, as validated
@@ -6908,21 +7036,26 @@ declare class PluginService extends BaseService {
6908
7036
  /** The store record again, for the callers that ask for it as "settings" or "init". */
6909
7037
  declare class SettingService extends BaseService {
6910
7038
  fetchSettings(_args?: Record<string, unknown>): Promise<{
7039
+ closed: StoreClosed | undefined;
6911
7040
  id: any;
6912
7041
  }>;
6913
7042
  list(args?: Record<string, unknown>): Promise<{
7043
+ closed: StoreClosed | undefined;
6914
7044
  id: any;
6915
7045
  }>;
6916
7046
  }
6917
7047
  declare class InitService extends SettingService {
6918
7048
  fetchInit(_args?: Record<string, unknown>): Promise<{
6919
7049
  storeOne: {
7050
+ closed: StoreClosed | undefined;
6920
7051
  id: any;
6921
7052
  };
6922
7053
  store: {
7054
+ closed: StoreClosed | undefined;
6923
7055
  id: any;
6924
7056
  };
6925
7057
  settings: {
7058
+ closed: StoreClosed | undefined;
6926
7059
  id: any;
6927
7060
  };
6928
7061
  }>;
@@ -7999,4 +8132,4 @@ declare class B2bService extends BaseService {
7999
8132
  }
8000
8133
  declare const b2bService: B2bService;
8001
8134
 
8002
- export { FaqService as $, type AddOn as A, type B2bPlaced as B, type Cart as C, type CompanyOrder as D, ContactService as E, CountryService as F, CouponService as G, type Credentials as H, type Credit as I, CurrencyService as J, type Customer as K, type CustomizerDesign as L, type CustomizerDocument as M, type CustomizerEditor as N, type CustomizerFile as O, type CustomizerLayer as P, type CustomizerSavedDesign as Q, CustomizerService as R, type CustomizerSetup as S, type CustomizerUpload as T, DealService as U, DemoRequestService as V, type EngineRequest as W, EnquiryService as X, type Envelope as Y, type FacetValue as Z, type Faq as _, type Address as a, type SiteFooter as a$, FeedbackService as a0, type FooterSettings as a1, type FreeShipping as a2, type Fulfillment as a3, GalleryService as a4, type GooglePlace as a5, type GoogleReview as a6, GoogleReviewService as a7, type GoogleReviews as a8, type GoogleSurvey as a9, PageService as aA, type PaymentIntent as aB, PaymentMethodService as aC, type Plugin as aD, PluginService as aE, PopularSearchService as aF, PopularityService as aG, type Postcode as aH, type Product as aI, type ProductFacets as aJ, type ProductOption as aK, ProductService as aL, ProfileService as aM, type Quote as aN, REDIRECT_GATEWAYS as aO, ReelsService as aP, RegionService as aQ, type RejectedLine as aR, type Review as aS, type ReviewPage as aT, ReviewService as aU, type SearchDoc as aV, type SearchResult as aW, SearchService as aX, SettingService as aY, type ShippingRate as aZ, type SiteChrome as a_, type HeaderSettings as aa, type HomeLayout as ab, type HomeLayoutSection as ac, HomeService as ad, type IdentityAddress as ae, InitService as af, type Invitation as ag, type LayoutCollection as ah, type LayoutPage as ai, LayoutService as aj, type Lead as ak, type ListMeta as al, MeilisearchService as am, type Member as an, type Menu as ao, type MenuItem as ap, MenuService as aq, type MenuSummary as ar, type Money as as, NewsletterService as at, type Offer as au, type OpeningHours as av, type Order as aw, type OrderLine as ax, OrderService as ay, type PageLayout as az, AddressService as b, newsletterService as b$, type SiteHeader as b0, type SocialLink as b1, StateService as b2, type StoreProfile as b3, StoreService as b4, type StorefrontCategory as b5, type StorefrontMenu as b6, type StorefrontOrder as b7, type StorefrontProduct as b8, type ThemeSettings as b9, checkoutService as bA, collectionService as bB, contactService as bC, countryService as bD, couponService as bE, currencyExponent as bF, currencyService as bG, customizerService as bH, dealService as bI, demoRequestService as bJ, emptyCart as bK, emptyPage as bL, enquiryService as bM, faqService as bN, feedbackService as bO, fromEngineAddress as bP, fromIdentityAddress as bQ, fromSearchDoc as bR, galleryService as bS, googleReviewService as bT, homeService as bU, initService as bV, layoutService as bW, mediaUrl as bX, meilisearchService as bY, menuService as bZ, minorToMajor as b_, type ThemeSettingsResult as ba, UploadService as bb, UserService as bc, type Variant as bd, type VariantImage as be, VariantService as bf, VarniCustomDesignService as bg, VarniCustomProductService as bh, type Vendor as bi, VendorService as bj, WarrantyService as bk, type WhatsappConsent as bl, type WhatsappConsentOffer as bm, WhatsappService as bn, type Wishlist as bo, type WishlistItem as bp, WishlistService as bq, addressService as br, authService as bs, autocompleteService as bt, b2bService as bu, bannerService as bv, blogService as bw, cartService as bx, categoryService as by, chatService as bz, type AppliedDiscount as c, orderService as c0, ownDomain as c1, pageService as c2, paymentMethodService as c3, pluginService as c4, pluginsService as c5, popularSearchService as c6, popularityService as c7, priceOf as c8, productImages as c9, toMinor as cA, toOrder as cB, toPage as cC, toProduct as cD, toRating as cE, toStorefrontFacets as cF, toUser as cG, toVariant as cH, toVendor as cI, uploadService as cJ, userService as cK, variantService as cL, varniCustomDesignService as cM, varniCustomProductService as cN, vendorService as cO, warrantyService as cP, whatsappService as cQ, wishlistService as cR, productService as ca, productVideos as cb, profileService as cc, qs as cd, reelsService as ce, regionService as cf, reviewService as cg, searchService as ch, setRequestHost as ci, settingService as cj, settingsService as ck, stateService as cl, staticStore as cm, storeForHost as cn, storeService as co, toAddOn as cp, toCart as cq, toCartLine as cr, toCartOffer as cs, toCategory as ct, toCmsPage as cu, toCollection as cv, toEngineAddress as cw, toFreeShipping as cx, toIdentityAddress as cy, toMajor as cz, type Approval as d, type AuthResponse as e, AuthService as f, AutocompleteService as g, type B2bRole as h, B2bService as i, BannerService as j, BaseService as k, BlogService as l, type CartLine as m, type CartOffer as n, CartService as o, CatalogService as p, type Category as q, CategoryService as r, ChatService as s, type CheckoutOptions as t, type CheckoutResult as u, CheckoutService as v, type CmsPage as w, type Collection as x, CollectionService as y, type Company as z };
8135
+ export { type Faq as $, type AddOn as A, type B2bPlaced as B, type Cart as C, type Company as D, type CompanyOrder as E, ContactService as F, CountryService as G, CouponService as H, type Credentials as I, type Credit as J, CurrencyService as K, type Customer as L, type CustomizerDesign as M, type CustomizerDocument as N, type CustomizerEditor as O, type CustomizerFile as P, type CustomizerLayer as Q, type CustomizerSavedDesign as R, CustomizerService as S, type CustomizerSetup as T, type CustomizerUpload as U, DealService as V, DemoRequestService as W, type EngineRequest as X, EnquiryService as Y, type Envelope as Z, type FacetValue as _, type Address as a, type SiteChrome as a$, FaqService as a0, FeedbackService as a1, type FooterSettings as a2, type FreeShipping as a3, type Fulfillment as a4, GalleryService as a5, type GooglePlace as a6, type GoogleReview as a7, GoogleReviewService as a8, type GoogleReviews as a9, type PageLayout as aA, PageService as aB, type PaymentIntent as aC, PaymentMethodService as aD, type Plugin as aE, PluginService as aF, PopularSearchService as aG, PopularityService as aH, type Postcode as aI, type Product as aJ, type ProductFacets as aK, type ProductOption as aL, ProductService as aM, ProfileService as aN, type Quote as aO, REDIRECT_GATEWAYS as aP, ReelsService as aQ, RegionService as aR, type RejectedLine as aS, type Review as aT, type ReviewPage as aU, ReviewService as aV, type SearchDoc as aW, type SearchResult as aX, SearchService as aY, SettingService as aZ, type ShippingRate as a_, type GoogleSurvey as aa, type HeaderSettings as ab, type HomeLayout as ac, type HomeLayoutSection as ad, HomeService as ae, type IdentityAddress as af, InitService as ag, type Invitation as ah, type LayoutCollection as ai, type LayoutPage as aj, LayoutService as ak, type Lead as al, type ListMeta as am, MeilisearchService as an, type Member as ao, type Menu as ap, type MenuItem as aq, MenuService as ar, type MenuSummary as as, type Money as at, NewsletterService as au, type Offer as av, type OpeningHours as aw, type Order as ax, type OrderLine as ay, OrderService as az, AddressService as b, layoutService as b$, type SiteFooter as b0, type SiteHeader as b1, type SocialLink as b2, StateService as b3, type StoreClosed as b4, type StorePass as b5, type StorePassAnswer as b6, type StoreProfile as b7, StoreService as b8, type StoreUnlock as b9, bannerService as bA, blogService as bB, cartService as bC, categoryService as bD, chatService as bE, checkoutService as bF, collectionService as bG, contactService as bH, countryService as bI, couponService as bJ, currencyExponent as bK, currencyService as bL, customizerService as bM, dealService as bN, demoRequestService as bO, emptyCart as bP, emptyPage as bQ, enquiryService as bR, faqService as bS, feedbackService as bT, fromEngineAddress as bU, fromIdentityAddress as bV, fromSearchDoc as bW, galleryService as bX, googleReviewService as bY, homeService as bZ, initService as b_, type StorefrontCategory as ba, type StorefrontMenu as bb, type StorefrontOrder as bc, type StorefrontProduct as bd, type ThemeSettings as be, type ThemeSettingsResult as bf, UploadService as bg, UserService as bh, type Variant as bi, type VariantImage as bj, VariantService as bk, VarniCustomDesignService as bl, VarniCustomProductService as bm, type Vendor as bn, VendorService as bo, WarrantyService as bp, type WhatsappConsent as bq, type WhatsappConsentOffer as br, WhatsappService as bs, type Wishlist as bt, type WishlistItem as bu, WishlistService as bv, addressService as bw, authService as bx, autocompleteService as by, b2bService as bz, type AppliedDiscount as c, mediaUrl as c0, meilisearchService as c1, menuService as c2, minorToMajor as c3, newsletterService as c4, orderService as c5, ownDomain as c6, pageService as c7, paymentMethodService as c8, pluginService as c9, toCmsPage as cA, toCollection as cB, toEngineAddress as cC, toFreeShipping as cD, toIdentityAddress as cE, toMajor as cF, toMinor as cG, toOrder as cH, toPage as cI, toProduct as cJ, toRating as cK, toStorefrontFacets as cL, toUser as cM, toVariant as cN, toVendor as cO, uploadService as cP, userService as cQ, variantService as cR, varniCustomDesignService as cS, varniCustomProductService as cT, vendorService as cU, warrantyService as cV, whatsappService as cW, wishlistService as cX, pluginsService as ca, popularSearchService as cb, popularityService as cc, priceOf as cd, productImages as ce, productService as cf, productVideos as cg, profileService as ch, qs as ci, reelsService as cj, regionService as ck, reviewService as cl, searchService as cm, setRequestHost as cn, settingService as co, settingsService as cp, stateService as cq, staticStore as cr, storeForHost as cs, storeService as ct, toAddOn as cu, toCart as cv, toCartLine as cw, toCartOffer as cx, toCategory as cy, toCheckoutQuote as cz, type Approval as d, type AuthResponse as e, AuthService as f, AutocompleteService as g, type B2bRole as h, B2bService as i, BannerService as j, BaseService as k, BlogService as l, type CartLine as m, type CartOffer as n, CartService as o, CatalogService as p, type Category as q, CategoryService as r, ChatService as s, type CheckoutOptions as t, type CheckoutQuote as u, type CheckoutResult as v, CheckoutService as w, type CmsPage as x, type Collection as y, CollectionService as z };