@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/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AddOn, a as Address, b as AddressService, c as AppliedDiscount, d as Approval, e as AuthResponse, f as AuthService, g as AutocompleteService, B as B2bPlaced, h as B2bRole, i as B2bService, j as BannerService, k as BaseService, l as BlogService, C as Cart, m as CartLine, n as CartOffer, o as CartService, p as CatalogService, q as Category, r as CategoryService, s as ChatService, t as CheckoutOptions, u as CheckoutResult, v as CheckoutService, w as CmsPage, x as Collection, y as CollectionService, z as Company, D as CompanyOrder, E as ContactService, F as CountryService, G as CouponService, H as Credentials, I as Credit, J as CurrencyService, K as Customer, L as CustomizerDesign, M as CustomizerDocument, N as CustomizerEditor, O as CustomizerFile, P as CustomizerLayer, Q as CustomizerSavedDesign, R as CustomizerService, S as CustomizerSetup, T as CustomizerUpload, U as DealService, V as DemoRequestService, W as EngineRequest, X as EnquiryService, Y as Envelope, Z as FacetValue, _ as Faq, $ as FaqService, a0 as FeedbackService, a1 as FooterSettings, a2 as FreeShipping, a3 as Fulfillment, a4 as GalleryService, a5 as GooglePlace, a6 as GoogleReview, a7 as GoogleReviewService, a8 as GoogleReviews, a9 as GoogleSurvey, aa as HeaderSettings, ab as HomeLayout, ac as HomeLayoutSection, ad as HomeService, ae as IdentityAddress, af as InitService, ag as Invitation, ah as LayoutCollection, ai as LayoutPage, aj as LayoutService, ak as Lead, al as ListMeta, am as MeilisearchService, an as Member, ao as Menu, ap as MenuItem, aq as MenuService, ar as MenuSummary, as as Money, at as NewsletterService, au as Offer, av as OpeningHours, aw as Order, ax as OrderLine, ay as OrderService, az as PageLayout, aA as PageService, aB as PaymentIntent, aC as PaymentMethodService, aD as Plugin, aE as PluginService, aE as PluginsService, aF as PopularSearchService, aG as PopularityService, aH as Postcode, aI as Product, aJ as ProductFacets, aK as ProductOption, aL as ProductService, aM as ProfileService, aN as Quote, aO as REDIRECT_GATEWAYS, aP as ReelsService, aQ as RegionService, aR as RejectedLine, aS as Review, aT as ReviewPage, aU as ReviewService, aV as SearchDoc, aW as SearchResult, aX as SearchService, aY as SettingService, aY as SettingsService, aZ as ShippingRate, a_ as SiteChrome, a$ as SiteFooter, b0 as SiteHeader, b1 as SocialLink, b2 as StateService, b3 as StoreProfile, b4 as StoreService, b5 as StorefrontCategory, b6 as StorefrontMenu, b7 as StorefrontOrder, b8 as StorefrontProduct, b9 as ThemeSettings, ba as ThemeSettingsResult, bb as UploadService, bc as UserService, bd as Variant, be as VariantImage, bf as VariantService, bg as VarniCustomDesignService, bh as VarniCustomProductService, bi as Vendor, bj as VendorService, bk as WarrantyService, bl as WhatsappConsent, bm as WhatsappConsentOffer, bn as WhatsappService, bo as Wishlist, bp as WishlistItem, bq as WishlistService, br as addressService, bs as authService, bt as autocompleteService, bu as b2bService, bv as bannerService, bw as blogService, bx as cartService, by as categoryService, bz as chatService, bA as checkoutService, bB as collectionService, bC as contactService, bD as countryService, bE as couponService, bF as currencyExponent, bG as currencyService, bH as customizerService, bI as dealService, bJ as demoRequestService, bK as emptyCart, bL as emptyPage, bM as enquiryService, bN as faqService, bO as feedbackService, bP as fromEngineAddress, bQ as fromIdentityAddress, bR as fromSearchDoc, bS as galleryService, bT as googleReviewService, bU as homeService, bV as initService, bW as layoutService, bX as mediaUrl, bY as meilisearchService, bZ as menuService, b_ as minorToMajor, b$ as newsletterService, c0 as orderService, c1 as ownDomain, c2 as pageService, c3 as paymentMethodService, c4 as pluginService, c5 as pluginsService, c6 as popularSearchService, c7 as popularityService, c8 as priceOf, c9 as productImages, ca as productService, cb as productVideos, cc as profileService, cd as qs, ce as reelsService, cf as regionService, cg as reviewService, ch as searchService, ci as setRequestHost, cj as settingService, ck as settingsService, cl as stateService, cm as staticStore, cn as storeForHost, co as storeService, cp as toAddOn, cq as toCart, cr as toCartLine, cs as toCartOffer, ct as toCategory, cu as toCmsPage, cv as toCollection, cw as toEngineAddress, cx as toFreeShipping, cy as toIdentityAddress, cz as toMajor, cA as toMinor, cB as toOrder, cC as toPage, cD as toProduct, cE as toRating, cF as toStorefrontFacets, cG as toUser, cH as toVariant, cI as toVendor, cJ as uploadService, cK as userService, cL as variantService, cM as varniCustomDesignService, cN as varniCustomProductService, cO as vendorService, cP as warrantyService, cQ as whatsappService, cR as wishlistService } from './index-DOlNI60Y.cjs';
1
+ export { A as AddOn, a as Address, b as AddressService, c as AppliedDiscount, d as Approval, e as AuthResponse, f as AuthService, g as AutocompleteService, B as B2bPlaced, h as B2bRole, i as B2bService, j as BannerService, k as BaseService, l as BlogService, C as Cart, m as CartLine, n as CartOffer, o as CartService, p as CatalogService, q as Category, r as CategoryService, s as ChatService, t as CheckoutOptions, u as CheckoutQuote, v as CheckoutResult, w as CheckoutService, x as CmsPage, y as Collection, z as CollectionService, D as Company, E as CompanyOrder, F as ContactService, G as CountryService, H as CouponService, I as Credentials, J as Credit, K as CurrencyService, L as Customer, M as CustomizerDesign, N as CustomizerDocument, O as CustomizerEditor, P as CustomizerFile, Q as CustomizerLayer, R as CustomizerSavedDesign, S as CustomizerService, T as CustomizerSetup, U as CustomizerUpload, V as DealService, W as DemoRequestService, X as EngineRequest, Y as EnquiryService, Z as Envelope, _ as FacetValue, $ as Faq, a0 as FaqService, a1 as FeedbackService, a2 as FooterSettings, a3 as FreeShipping, a4 as Fulfillment, a5 as GalleryService, a6 as GooglePlace, a7 as GoogleReview, a8 as GoogleReviewService, a9 as GoogleReviews, aa as GoogleSurvey, ab as HeaderSettings, ac as HomeLayout, ad as HomeLayoutSection, ae as HomeService, af as IdentityAddress, ag as InitService, ah as Invitation, ai as LayoutCollection, aj as LayoutPage, ak as LayoutService, al as Lead, am as ListMeta, an as MeilisearchService, ao as Member, ap as Menu, aq as MenuItem, ar as MenuService, as as MenuSummary, at as Money, au as NewsletterService, av as Offer, aw as OpeningHours, ax as Order, ay as OrderLine, az as OrderService, aA as PageLayout, aB as PageService, aC as PaymentIntent, aD as PaymentMethodService, aE as Plugin, aF as PluginService, aF as PluginsService, aG as PopularSearchService, aH as PopularityService, aI as Postcode, aJ as Product, aK as ProductFacets, aL as ProductOption, aM as ProductService, aN as ProfileService, aO as Quote, aP as REDIRECT_GATEWAYS, aQ as ReelsService, aR as RegionService, aS as RejectedLine, aT as Review, aU as ReviewPage, aV as ReviewService, aW as SearchDoc, aX as SearchResult, aY as SearchService, aZ as SettingService, aZ as SettingsService, a_ as ShippingRate, a$ as SiteChrome, b0 as SiteFooter, b1 as SiteHeader, b2 as SocialLink, b3 as StateService, b4 as StoreClosed, b5 as StorePass, b6 as StorePassAnswer, b7 as StoreProfile, b8 as StoreService, b9 as StoreUnlock, ba as StorefrontCategory, bb as StorefrontMenu, bc as StorefrontOrder, bd as StorefrontProduct, be as ThemeSettings, bf as ThemeSettingsResult, bg as UploadService, bh as UserService, bi as Variant, bj as VariantImage, bk as VariantService, bl as VarniCustomDesignService, bm as VarniCustomProductService, bn as Vendor, bo as VendorService, bp as WarrantyService, bq as WhatsappConsent, br as WhatsappConsentOffer, bs as WhatsappService, bt as Wishlist, bu as WishlistItem, bv as WishlistService, bw as addressService, bx as authService, by as autocompleteService, bz as b2bService, bA as bannerService, bB as blogService, bC as cartService, bD as categoryService, bE as chatService, bF as checkoutService, bG as collectionService, bH as contactService, bI as countryService, bJ as couponService, bK as currencyExponent, bL as currencyService, bM as customizerService, bN as dealService, bO as demoRequestService, bP as emptyCart, bQ as emptyPage, bR as enquiryService, bS as faqService, bT as feedbackService, bU as fromEngineAddress, bV as fromIdentityAddress, bW as fromSearchDoc, bX as galleryService, bY as googleReviewService, bZ as homeService, b_ as initService, b$ as layoutService, c0 as mediaUrl, c1 as meilisearchService, c2 as menuService, c3 as minorToMajor, c4 as newsletterService, c5 as orderService, c6 as ownDomain, c7 as pageService, c8 as paymentMethodService, c9 as pluginService, ca as pluginsService, cb as popularSearchService, cc as popularityService, cd as priceOf, ce as productImages, cf as productService, cg as productVideos, ch as profileService, ci as qs, cj as reelsService, ck as regionService, cl as reviewService, cm as searchService, cn as setRequestHost, co as settingService, cp as settingsService, cq as stateService, cr as staticStore, cs as storeForHost, ct as storeService, cu as toAddOn, cv as toCart, cw as toCartLine, cx as toCartOffer, cy as toCategory, cz as toCheckoutQuote, cA as toCmsPage, cB as toCollection, cC as toEngineAddress, cD as toFreeShipping, cE as toIdentityAddress, cF as toMajor, cG as toMinor, cH as toOrder, cI as toPage, cJ as toProduct, cK as toRating, cL as toStorefrontFacets, cM as toUser, cN as toVariant, cO as toVendor, cP as uploadService, cQ as userService, cR as variantService, cS as varniCustomDesignService, cT as varniCustomProductService, cU as vendorService, cV as warrantyService, cW as whatsappService, cX as wishlistService } from './index-CSqvRZQ4.cjs';
2
2
 
3
3
  /**
4
4
  * The two ways a call through this connector fails.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AddOn, a as Address, b as AddressService, c as AppliedDiscount, d as Approval, e as AuthResponse, f as AuthService, g as AutocompleteService, B as B2bPlaced, h as B2bRole, i as B2bService, j as BannerService, k as BaseService, l as BlogService, C as Cart, m as CartLine, n as CartOffer, o as CartService, p as CatalogService, q as Category, r as CategoryService, s as ChatService, t as CheckoutOptions, u as CheckoutResult, v as CheckoutService, w as CmsPage, x as Collection, y as CollectionService, z as Company, D as CompanyOrder, E as ContactService, F as CountryService, G as CouponService, H as Credentials, I as Credit, J as CurrencyService, K as Customer, L as CustomizerDesign, M as CustomizerDocument, N as CustomizerEditor, O as CustomizerFile, P as CustomizerLayer, Q as CustomizerSavedDesign, R as CustomizerService, S as CustomizerSetup, T as CustomizerUpload, U as DealService, V as DemoRequestService, W as EngineRequest, X as EnquiryService, Y as Envelope, Z as FacetValue, _ as Faq, $ as FaqService, a0 as FeedbackService, a1 as FooterSettings, a2 as FreeShipping, a3 as Fulfillment, a4 as GalleryService, a5 as GooglePlace, a6 as GoogleReview, a7 as GoogleReviewService, a8 as GoogleReviews, a9 as GoogleSurvey, aa as HeaderSettings, ab as HomeLayout, ac as HomeLayoutSection, ad as HomeService, ae as IdentityAddress, af as InitService, ag as Invitation, ah as LayoutCollection, ai as LayoutPage, aj as LayoutService, ak as Lead, al as ListMeta, am as MeilisearchService, an as Member, ao as Menu, ap as MenuItem, aq as MenuService, ar as MenuSummary, as as Money, at as NewsletterService, au as Offer, av as OpeningHours, aw as Order, ax as OrderLine, ay as OrderService, az as PageLayout, aA as PageService, aB as PaymentIntent, aC as PaymentMethodService, aD as Plugin, aE as PluginService, aE as PluginsService, aF as PopularSearchService, aG as PopularityService, aH as Postcode, aI as Product, aJ as ProductFacets, aK as ProductOption, aL as ProductService, aM as ProfileService, aN as Quote, aO as REDIRECT_GATEWAYS, aP as ReelsService, aQ as RegionService, aR as RejectedLine, aS as Review, aT as ReviewPage, aU as ReviewService, aV as SearchDoc, aW as SearchResult, aX as SearchService, aY as SettingService, aY as SettingsService, aZ as ShippingRate, a_ as SiteChrome, a$ as SiteFooter, b0 as SiteHeader, b1 as SocialLink, b2 as StateService, b3 as StoreProfile, b4 as StoreService, b5 as StorefrontCategory, b6 as StorefrontMenu, b7 as StorefrontOrder, b8 as StorefrontProduct, b9 as ThemeSettings, ba as ThemeSettingsResult, bb as UploadService, bc as UserService, bd as Variant, be as VariantImage, bf as VariantService, bg as VarniCustomDesignService, bh as VarniCustomProductService, bi as Vendor, bj as VendorService, bk as WarrantyService, bl as WhatsappConsent, bm as WhatsappConsentOffer, bn as WhatsappService, bo as Wishlist, bp as WishlistItem, bq as WishlistService, br as addressService, bs as authService, bt as autocompleteService, bu as b2bService, bv as bannerService, bw as blogService, bx as cartService, by as categoryService, bz as chatService, bA as checkoutService, bB as collectionService, bC as contactService, bD as countryService, bE as couponService, bF as currencyExponent, bG as currencyService, bH as customizerService, bI as dealService, bJ as demoRequestService, bK as emptyCart, bL as emptyPage, bM as enquiryService, bN as faqService, bO as feedbackService, bP as fromEngineAddress, bQ as fromIdentityAddress, bR as fromSearchDoc, bS as galleryService, bT as googleReviewService, bU as homeService, bV as initService, bW as layoutService, bX as mediaUrl, bY as meilisearchService, bZ as menuService, b_ as minorToMajor, b$ as newsletterService, c0 as orderService, c1 as ownDomain, c2 as pageService, c3 as paymentMethodService, c4 as pluginService, c5 as pluginsService, c6 as popularSearchService, c7 as popularityService, c8 as priceOf, c9 as productImages, ca as productService, cb as productVideos, cc as profileService, cd as qs, ce as reelsService, cf as regionService, cg as reviewService, ch as searchService, ci as setRequestHost, cj as settingService, ck as settingsService, cl as stateService, cm as staticStore, cn as storeForHost, co as storeService, cp as toAddOn, cq as toCart, cr as toCartLine, cs as toCartOffer, ct as toCategory, cu as toCmsPage, cv as toCollection, cw as toEngineAddress, cx as toFreeShipping, cy as toIdentityAddress, cz as toMajor, cA as toMinor, cB as toOrder, cC as toPage, cD as toProduct, cE as toRating, cF as toStorefrontFacets, cG as toUser, cH as toVariant, cI as toVendor, cJ as uploadService, cK as userService, cL as variantService, cM as varniCustomDesignService, cN as varniCustomProductService, cO as vendorService, cP as warrantyService, cQ as whatsappService, cR as wishlistService } from './index-DOlNI60Y.js';
1
+ export { A as AddOn, a as Address, b as AddressService, c as AppliedDiscount, d as Approval, e as AuthResponse, f as AuthService, g as AutocompleteService, B as B2bPlaced, h as B2bRole, i as B2bService, j as BannerService, k as BaseService, l as BlogService, C as Cart, m as CartLine, n as CartOffer, o as CartService, p as CatalogService, q as Category, r as CategoryService, s as ChatService, t as CheckoutOptions, u as CheckoutQuote, v as CheckoutResult, w as CheckoutService, x as CmsPage, y as Collection, z as CollectionService, D as Company, E as CompanyOrder, F as ContactService, G as CountryService, H as CouponService, I as Credentials, J as Credit, K as CurrencyService, L as Customer, M as CustomizerDesign, N as CustomizerDocument, O as CustomizerEditor, P as CustomizerFile, Q as CustomizerLayer, R as CustomizerSavedDesign, S as CustomizerService, T as CustomizerSetup, U as CustomizerUpload, V as DealService, W as DemoRequestService, X as EngineRequest, Y as EnquiryService, Z as Envelope, _ as FacetValue, $ as Faq, a0 as FaqService, a1 as FeedbackService, a2 as FooterSettings, a3 as FreeShipping, a4 as Fulfillment, a5 as GalleryService, a6 as GooglePlace, a7 as GoogleReview, a8 as GoogleReviewService, a9 as GoogleReviews, aa as GoogleSurvey, ab as HeaderSettings, ac as HomeLayout, ad as HomeLayoutSection, ae as HomeService, af as IdentityAddress, ag as InitService, ah as Invitation, ai as LayoutCollection, aj as LayoutPage, ak as LayoutService, al as Lead, am as ListMeta, an as MeilisearchService, ao as Member, ap as Menu, aq as MenuItem, ar as MenuService, as as MenuSummary, at as Money, au as NewsletterService, av as Offer, aw as OpeningHours, ax as Order, ay as OrderLine, az as OrderService, aA as PageLayout, aB as PageService, aC as PaymentIntent, aD as PaymentMethodService, aE as Plugin, aF as PluginService, aF as PluginsService, aG as PopularSearchService, aH as PopularityService, aI as Postcode, aJ as Product, aK as ProductFacets, aL as ProductOption, aM as ProductService, aN as ProfileService, aO as Quote, aP as REDIRECT_GATEWAYS, aQ as ReelsService, aR as RegionService, aS as RejectedLine, aT as Review, aU as ReviewPage, aV as ReviewService, aW as SearchDoc, aX as SearchResult, aY as SearchService, aZ as SettingService, aZ as SettingsService, a_ as ShippingRate, a$ as SiteChrome, b0 as SiteFooter, b1 as SiteHeader, b2 as SocialLink, b3 as StateService, b4 as StoreClosed, b5 as StorePass, b6 as StorePassAnswer, b7 as StoreProfile, b8 as StoreService, b9 as StoreUnlock, ba as StorefrontCategory, bb as StorefrontMenu, bc as StorefrontOrder, bd as StorefrontProduct, be as ThemeSettings, bf as ThemeSettingsResult, bg as UploadService, bh as UserService, bi as Variant, bj as VariantImage, bk as VariantService, bl as VarniCustomDesignService, bm as VarniCustomProductService, bn as Vendor, bo as VendorService, bp as WarrantyService, bq as WhatsappConsent, br as WhatsappConsentOffer, bs as WhatsappService, bt as Wishlist, bu as WishlistItem, bv as WishlistService, bw as addressService, bx as authService, by as autocompleteService, bz as b2bService, bA as bannerService, bB as blogService, bC as cartService, bD as categoryService, bE as chatService, bF as checkoutService, bG as collectionService, bH as contactService, bI as countryService, bJ as couponService, bK as currencyExponent, bL as currencyService, bM as customizerService, bN as dealService, bO as demoRequestService, bP as emptyCart, bQ as emptyPage, bR as enquiryService, bS as faqService, bT as feedbackService, bU as fromEngineAddress, bV as fromIdentityAddress, bW as fromSearchDoc, bX as galleryService, bY as googleReviewService, bZ as homeService, b_ as initService, b$ as layoutService, c0 as mediaUrl, c1 as meilisearchService, c2 as menuService, c3 as minorToMajor, c4 as newsletterService, c5 as orderService, c6 as ownDomain, c7 as pageService, c8 as paymentMethodService, c9 as pluginService, ca as pluginsService, cb as popularSearchService, cc as popularityService, cd as priceOf, ce as productImages, cf as productService, cg as productVideos, ch as profileService, ci as qs, cj as reelsService, ck as regionService, cl as reviewService, cm as searchService, cn as setRequestHost, co as settingService, cp as settingsService, cq as stateService, cr as staticStore, cs as storeForHost, ct as storeService, cu as toAddOn, cv as toCart, cw as toCartLine, cx as toCartOffer, cy as toCategory, cz as toCheckoutQuote, cA as toCmsPage, cB as toCollection, cC as toEngineAddress, cD as toFreeShipping, cE as toIdentityAddress, cF as toMajor, cG as toMinor, cH as toOrder, cI as toPage, cJ as toProduct, cK as toRating, cL as toStorefrontFacets, cM as toUser, cN as toVariant, cO as toVendor, cP as uploadService, cQ as userService, cR as variantService, cS as varniCustomDesignService, cT as varniCustomProductService, cU as vendorService, cV as warrantyService, cW as whatsappService, cX as wishlistService } from './index-CSqvRZQ4.js';
2
2
 
3
3
  /**
4
4
  * The two ways a call through this connector fails.
package/dist/index.js CHANGED
@@ -132,8 +132,17 @@ function remember(key, load, ttl = TTL_MS) {
132
132
  });
133
133
  return value;
134
134
  }
135
+ var known = /* @__PURE__ */ new Map();
136
+ function keep(key, value) {
137
+ known.set(key, value);
138
+ return value;
139
+ }
140
+ function recall(key) {
141
+ return known.get(key);
142
+ }
135
143
  function forgetAll() {
136
144
  entries.clear();
145
+ known.clear();
137
146
  }
138
147
 
139
148
  // src/browser.ts
@@ -550,6 +559,7 @@ function productImages(p) {
550
559
  if (url && !out.includes(url)) out.push(url);
551
560
  };
552
561
  push(mediaUrl(p.image_url));
562
+ push(mediaUrl(p.hover_image_url));
553
563
  for (const m of arr(p.media)) if (m.kind === "image") push(mediaUrl(m.url));
554
564
  for (const v of arr(p.variants)) for (const url of variantImages(v)) push(url);
555
565
  return out;
@@ -1118,7 +1128,22 @@ function toCartOffer(o, currency) {
1118
1128
  applies: o.applies,
1119
1129
  amount: o.amount ? toMajor(o.amount) : null,
1120
1130
  remaining: o.remaining ? toMajor(o.remaining) : null,
1121
- reason: o.reason ?? ""
1131
+ reason: o.reason ?? "",
1132
+ autoApply: !!o.auto_apply
1133
+ };
1134
+ }
1135
+ function toCheckoutQuote(q) {
1136
+ const d = q.discount;
1137
+ return {
1138
+ subtotal: toMajor(q.subtotal),
1139
+ shippingCharges: toMajor(q.shipping),
1140
+ shippingMethod: q.shipping_method ?? null,
1141
+ discount: toMajor(d?.amount),
1142
+ coupon: d ? { code: d.code, title: d.title, autoApplied: d.auto_applied, freeShipping: !!d.free_shipping } : null,
1143
+ tax: toMajor(q.tax),
1144
+ taxIncluded: q.tax_inclusive,
1145
+ codCharges: toMajor(q.payment_fee),
1146
+ total: toMajor(q.total)
1122
1147
  };
1123
1148
  }
1124
1149
  function toFreeShipping(f) {
@@ -2126,6 +2151,7 @@ var customizerService = new CustomizerService();
2126
2151
 
2127
2152
  // src/services/checkout-service.ts
2128
2153
  var CheckoutService = class extends BaseService {
2154
+ expected = /* @__PURE__ */ new Map();
2129
2155
  /** Delivery options for the address on the cart: `{ data: [{ id, name, base_rate }] }`. */
2130
2156
  async getShippingRates({ cartId } = {}) {
2131
2157
  const id2 = cartId || storedCartId();
@@ -2297,6 +2323,64 @@ var CheckoutService = class extends BaseService {
2297
2323
  );
2298
2324
  return { methods: options.methods ?? [], currency: options.currency };
2299
2325
  }
2326
+ /**
2327
+ * What checkout would charge for the cart now, by the storefront's method
2328
+ * code (`COD`, `RAZORPAY`, `PAYPAL`) or none yet (D185). Null until the
2329
+ * address step has stored an address, and null from an engine before D185.
2330
+ *
2331
+ * A refusal is checkout's own: the same GoCommerceError, with the same
2332
+ * message, that placing the order would raise now.
2333
+ */
2334
+ async getQuote({ cartId, method = "" } = {}) {
2335
+ const id2 = cartId || storedCartId();
2336
+ if (!id2 || !cartExtras(id2).shippingAddress) return null;
2337
+ const { extras, email, address } = await this.storedCheckout(id2);
2338
+ const code = method.toLowerCase() === "paypal" ? await this.redirectGateway() : method.toLowerCase();
2339
+ try {
2340
+ const quote2 = await this.data("/api/checkout/quote", {
2341
+ query: {
2342
+ cart: id2,
2343
+ country: address.country,
2344
+ state: address.state,
2345
+ shipping_rate_id: extras.shippingRateId || void 0,
2346
+ method: code || void 0,
2347
+ email: email || void 0
2348
+ }
2349
+ });
2350
+ return toCheckoutQuote(quote2);
2351
+ } catch (err) {
2352
+ if (err instanceof GoCommerceError && (err.status === 405 || err.status === 404 && err.message.startsWith("no route for "))) {
2353
+ return null;
2354
+ }
2355
+ throw err;
2356
+ }
2357
+ }
2358
+ /**
2359
+ * The total on screen as the shopper confirms, from getQuote, or null when nothing was quoted
2360
+ * (D185). Every order placed for the cart then carries it, and checkout refuses one whose own
2361
+ * total differs instead of charging it: `onChange` gets checkout's figures now and the sentence
2362
+ * the placing call fails with.
2363
+ */
2364
+ expectTotal({
2365
+ cartId,
2366
+ total,
2367
+ onChange
2368
+ }) {
2369
+ const id2 = cartId || storedCartId();
2370
+ if (!id2) return;
2371
+ if (typeof total === "number") this.expected.set(id2, { total, onChange });
2372
+ else this.expected.delete(id2);
2373
+ }
2374
+ async storedCheckout(cartId) {
2375
+ const id2 = cartId || storedCartId();
2376
+ if (!id2) throw new GoCommerceError("Your bag is empty.", 400);
2377
+ const extras = cartExtras(id2);
2378
+ const ship = extras.shippingAddress;
2379
+ if (!ship) throw new GoCommerceError("Add a delivery address first.", 400);
2380
+ const cart = await this.data(`/api/carts/${encodeURIComponent(id2)}`);
2381
+ const email = cart.email || (ship.email ? String(ship.email) : "");
2382
+ return { id: id2, extras, email, address: toEngineAddress(ship), currency: cart.currency };
2383
+ }
2300
2384
  async redirectGateway() {
2301
2385
  const { methods } = await this.listMethods();
2302
2386
  return methods.find((m) => REDIRECT_GATEWAYS.has(m.code))?.code;
@@ -2312,15 +2396,8 @@ var CheckoutService = class extends BaseService {
2312
2396
  * the engine refuses a key replayed with a different body.
2313
2397
  */
2314
2398
  async place(code, cartId, extra = {}) {
2315
- const id2 = cartId || storedCartId();
2316
- if (!id2) throw new GoCommerceError("Your bag is empty.", 400);
2317
- const extras = cartExtras(id2);
2318
- const ship = extras.shippingAddress;
2319
- if (!ship) throw new GoCommerceError("Add a delivery address first.", 400);
2320
- const cart = await this.data(`/api/carts/${encodeURIComponent(id2)}`);
2321
- const email = cart.email || (ship.email ? String(ship.email) : "");
2399
+ const { id: id2, extras, email, address, currency } = await this.storedCheckout(cartId);
2322
2400
  if (!email) throw new GoCommerceError("Add an email address so we can send your receipt.", 400);
2323
- const address = toEngineAddress(ship);
2324
2401
  const body = {
2325
2402
  cart_id: id2,
2326
2403
  email,
@@ -2343,10 +2420,23 @@ var CheckoutService = class extends BaseService {
2343
2420
  ...meta ? { meta_capi: meta } : {},
2344
2421
  ...attribution ? { attribution } : {}
2345
2422
  };
2423
+ const expected = this.expected.get(id2);
2346
2424
  const result = await this.data(`/api/checkout/${encodeURIComponent(code)}`, {
2347
2425
  method: "POST",
2348
- body: Object.keys(metadata).length ? { ...body, metadata } : body,
2426
+ body: {
2427
+ ...Object.keys(metadata).length ? { ...body, metadata } : body,
2428
+ ...expected ? { quoted_total_minor: toMinor(expected.total, currency) } : {}
2429
+ },
2349
2430
  headers: { "Idempotency-Key": key }
2431
+ }).catch((err) => {
2432
+ if (keyAlreadyUsed(err)) {
2433
+ throw new GoCommerceError("This order was already placed in another tab. Check that tab for its confirmation.", 400, err.code);
2434
+ }
2435
+ const now = movedTotal(err);
2436
+ if (!expected || !now) throw err;
2437
+ const message = `Your total changed to ${shopperAmount(now.total, currency)}. Check the new total and confirm again.`;
2438
+ expected.onChange?.(now, message);
2439
+ throw new GoCommerceError(message, 409, "total_changed", now);
2350
2440
  });
2351
2441
  if (result.order.access_token) {
2352
2442
  rememberOrder({
@@ -2369,6 +2459,21 @@ var CheckoutService = class extends BaseService {
2369
2459
  };
2370
2460
  var REDIRECT_GATEWAYS = /* @__PURE__ */ new Set(["adyen", "paddle", "lemonsqueezy", "creem", "hyperswitch", "revenuecat"]);
2371
2461
  var unsupported = (method, why) => new NotSupportedError("CheckoutService", method, why);
2462
+ function keyAlreadyUsed(err) {
2463
+ return err instanceof GoCommerceError && err.status === 400 && err.message.includes("Idempotency-Key was already used");
2464
+ }
2465
+ function movedTotal(err) {
2466
+ if (!(err instanceof GoCommerceError) || err.code !== "total_changed") return null;
2467
+ const now = err.details;
2468
+ return now?.total ? toCheckoutQuote(now) : null;
2469
+ }
2470
+ function shopperAmount(amount, currency) {
2471
+ return new Intl.NumberFormat(currency === "INR" ? "en-IN" : "en", {
2472
+ style: "currency",
2473
+ currency,
2474
+ ...Number.isInteger(amount) ? { minimumFractionDigits: 0 } : {}
2475
+ }).format(amount);
2476
+ }
2372
2477
  function newKey() {
2373
2478
  const c = globalThis.crypto;
2374
2479
  if (c?.randomUUID) return c.randomUUID();
@@ -2430,7 +2535,8 @@ var CouponService = class extends BaseService {
2430
2535
  minAmount: o.minAmount,
2431
2536
  description: o.applies ? o.title : o.remaining !== null ? `${o.title}. Add ${o.remaining} more to use this.` : o.reason || o.title,
2432
2537
  applies: o.applies,
2433
- remaining: o.remaining
2538
+ remaining: o.remaining,
2539
+ autoApply: o.autoApply
2434
2540
  }));
2435
2541
  return { data, count: data.length, pageSize: data.length, noOfPage: 1, page: 1 };
2436
2542
  }
@@ -3183,15 +3289,18 @@ var StoreService = class extends BaseService {
3183
3289
  async getStoreByIdOrDomain(_args = {}) {
3184
3290
  const base = await readStaticStore();
3185
3291
  const store = this.store;
3186
- if (store) {
3187
- await this.facts.plugins().catch((err) => {
3188
- if (isStoreMissing(err)) {
3292
+ const [plugins, live] = await Promise.all([
3293
+ this.facts.plugins().catch((err) => {
3294
+ if (store && isStoreMissing(err)) {
3189
3295
  throw new GoCommerceError(`store not found: no store "${store}" on this engine`, 404, "store_not_found");
3190
3296
  }
3191
- });
3192
- }
3193
- const live = await this.live().catch(() => ({}));
3194
- return { ...base, ...live, id: base.id || "gocommerce" };
3297
+ return void 0;
3298
+ }),
3299
+ this.live().catch(() => ({}))
3300
+ ]);
3301
+ const known2 = `${this.creds.apiUrl ?? ""}|${store ?? ""}|closed`;
3302
+ const closed = plugins ? keep(known2, closedOf(plugins)) : recall(known2);
3303
+ return { ...base, ...live, closed, id: base.id || "gocommerce" };
3195
3304
  }
3196
3305
  async getStore(storeId) {
3197
3306
  return this.getStoreByIdOrDomain({ storeId });
@@ -3226,6 +3335,46 @@ var StoreService = class extends BaseService {
3226
3335
  }
3227
3336
  return super.post(path, data);
3228
3337
  }
3338
+ /**
3339
+ * A closed store's password (D170), traded for a pass. Never throws. The
3340
+ * engine allows 20 tries an hour per client, and sees this server as the
3341
+ * client unless `clientAddress`, the shopper's, travels as `X-Forwarded-For`.
3342
+ */
3343
+ async unlockStore(password, { clientAddress } = {}) {
3344
+ const typed = password.trim();
3345
+ if (!typed) return { outcome: "wrong" };
3346
+ try {
3347
+ return { outcome: "unlocked", pass: await this.storePass({ password: typed }, clientAddress) };
3348
+ } catch (err) {
3349
+ return { outcome: err instanceof GoCommerceError && UNLOCK_REFUSED[err.status] || "unavailable" };
3350
+ }
3351
+ }
3352
+ /**
3353
+ * A pass checked without spending a try: the pass, or null when it is wrong,
3354
+ * expired, ended by a new password, or the store takes none now. Throws when
3355
+ * the engine cannot say.
3356
+ */
3357
+ async checkStorePass(token) {
3358
+ if (!token) return null;
3359
+ try {
3360
+ return await this.storePass({ token });
3361
+ } catch (err) {
3362
+ if (err instanceof GoCommerceError && (err.status === 422 || err.status === 404)) return null;
3363
+ throw err;
3364
+ }
3365
+ }
3366
+ async storePass(body, clientAddress) {
3367
+ const answer = await this.data("/api/store/password", {
3368
+ method: "POST",
3369
+ body,
3370
+ headers: clientAddress && ONE_IP_ADDRESS.test(clientAddress) ? { "X-Forwarded-For": clientAddress } : void 0
3371
+ });
3372
+ const expiresAt = new Date(answer?.expires_at ?? NaN);
3373
+ if (!answer?.token || Number.isNaN(expiresAt.getTime())) {
3374
+ throw new GoCommerceError("The commerce engine answered a store pass without its token or expiry.", 502);
3375
+ }
3376
+ return { token: answer.token, expiresAt };
3377
+ }
3229
3378
  async live() {
3230
3379
  const [ready, plugins, menus, base, profile, ships] = await Promise.all([
3231
3380
  this.facts.ready(),
@@ -3343,6 +3492,17 @@ var StoreService = class extends BaseService {
3343
3492
  }
3344
3493
  };
3345
3494
  var storeService = new StoreService();
3495
+ var ONE_IP_ADDRESS = /^[\da-f.:]{2,45}$/i;
3496
+ var UNLOCK_REFUSED = {
3497
+ 422: "wrong",
3498
+ 429: "throttled",
3499
+ 404: "open"
3500
+ };
3501
+ function closedOf(plugins) {
3502
+ const plugin = plugins?.get("store-close");
3503
+ if (!plugin) return void 0;
3504
+ return { message: String(plugin.settings?.message ?? ""), password: plugin.settings?.password === true };
3505
+ }
3346
3506
  var AD_TAGS = [
3347
3507
  ["meta-pixel", "pixel_id", "facebookPixel"],
3348
3508
  ["microsoft-clarity", "project_id", "microsoftClarity"],
@@ -3371,10 +3531,10 @@ function googleTags(plugins) {
3371
3531
  }
3372
3532
  function deliverable(base, ships) {
3373
3533
  if (ships.everywhere || !ships.countries.length) return {};
3374
- const known = new Map((base.countries ?? []).map((c) => [String(c.code).toUpperCase(), c]));
3375
- const countries = ships.countries.map((code) => known.get(code) ?? { code, name: regionName(code) });
3376
- const keep = base.country && ships.countries.includes(String(base.country.code).toUpperCase());
3377
- return { countries, ...keep ? {} : { country: countries[0] } };
3534
+ const known2 = new Map((base.countries ?? []).map((c) => [String(c.code).toUpperCase(), c]));
3535
+ const countries = ships.countries.map((code) => known2.get(code) ?? { code, name: regionName(code) });
3536
+ const keep2 = base.country && ships.countries.includes(String(base.country.code).toUpperCase());
3537
+ return { countries, ...keep2 ? {} : { country: countries[0] } };
3378
3538
  }
3379
3539
  function regionName(code) {
3380
3540
  try {
@@ -3529,7 +3689,8 @@ function toSection(s) {
3529
3689
  title: c.title,
3530
3690
  slug: c.slug,
3531
3691
  link: `/collections/${c.slug}`,
3532
- image: mediaUrl(c.image) ?? null
3692
+ image: mediaUrl(c.image) ?? null,
3693
+ description: c.description || null
3533
3694
  }));
3534
3695
  }
3535
3696
  return out;
@@ -4115,6 +4276,6 @@ function attemptKey(request) {
4115
4276
  }
4116
4277
  var b2bService = new B2bService();
4117
4278
 
4118
- export { AddressService, AuthService, AutocompleteService, B2bService, BannerService, BaseService, BlogService, CartService, CatalogService, CategoryService, ChatService, CheckoutService, CollectionService, ContactService, CountryService, CouponService, CurrencyService, CustomizerService, DealService, DemoRequestService, EnquiryService, FaqService, FeedbackService, GalleryService, GoCommerceError, GoogleReviewService, HomeService, InitService, LayoutService, MeilisearchService, MenuService, NewsletterService, NotSupportedError, OrderService, PageService, PaymentMethodService, PluginService, PluginService as PluginsService, PopularSearchService, PopularityService, ProductService, ProfileService, REDIRECT_GATEWAYS, ReelsService, RegionService, ReviewService, SearchService, SettingService, SettingService as SettingsService, StateService, StoreService, UploadService, UserService, VariantService, VarniCustomDesignService, VarniCustomProductService, VendorService, WarrantyService, WhatsappService, WishlistService, addressService, authService, autocompleteService, b2bService, bannerService, blogService, cartService, categoryService, chatService, checkoutService, forgetAll as clearStoreCache, collectionService, connectorName, contactService, countryService, couponService, currencyExponent, currencyService, customizerService, dealService, demoRequestService, emptyCart, emptyPage, enquiryService, faqService, feedbackService, fromEngineAddress, fromIdentityAddress, fromSearchDoc, galleryService, googleReviewService, hasStaticStore, homeService, initService, layoutService, mediaUrl, meilisearchService, menuService, minorToMajor, newsletterService, orderService, ownDomain, pageService, paymentMethodService, pluginService, pluginsService, popularSearchService, popularityService, priceOf, productImages, productService, productVideos, profileService, qs, readStaticStore, reelsService, regionService, reviewService, searchService, serveRestLocally, setRequestHost, setStaticStore, settingService, settingsService, stateService, staticStore, storeForHost, storeService, toAddOn, toCart, toCartLine, toCartOffer, toCategory, toCmsPage, toCollection, toEngineAddress, toFreeShipping, toIdentityAddress, toMajor, toMinor, toOrder, toPage, toProduct, toRating, toStorefrontFacets, toUser, toVariant, toVendor, uploadService, userService, variantService, varniCustomDesignService, varniCustomProductService, vendorService, warrantyService, whatsappService, wishlistService };
4279
+ export { AddressService, AuthService, AutocompleteService, B2bService, BannerService, BaseService, BlogService, CartService, CatalogService, CategoryService, ChatService, CheckoutService, CollectionService, ContactService, CountryService, CouponService, CurrencyService, CustomizerService, DealService, DemoRequestService, EnquiryService, FaqService, FeedbackService, GalleryService, GoCommerceError, GoogleReviewService, HomeService, InitService, LayoutService, MeilisearchService, MenuService, NewsletterService, NotSupportedError, OrderService, PageService, PaymentMethodService, PluginService, PluginService as PluginsService, PopularSearchService, PopularityService, ProductService, ProfileService, REDIRECT_GATEWAYS, ReelsService, RegionService, ReviewService, SearchService, SettingService, SettingService as SettingsService, StateService, StoreService, UploadService, UserService, VariantService, VarniCustomDesignService, VarniCustomProductService, VendorService, WarrantyService, WhatsappService, WishlistService, addressService, authService, autocompleteService, b2bService, bannerService, blogService, cartService, categoryService, chatService, checkoutService, forgetAll as clearStoreCache, collectionService, connectorName, contactService, countryService, couponService, currencyExponent, currencyService, customizerService, dealService, demoRequestService, emptyCart, emptyPage, enquiryService, faqService, feedbackService, fromEngineAddress, fromIdentityAddress, fromSearchDoc, galleryService, googleReviewService, hasStaticStore, homeService, initService, layoutService, mediaUrl, meilisearchService, menuService, minorToMajor, newsletterService, orderService, ownDomain, pageService, paymentMethodService, pluginService, pluginsService, popularSearchService, popularityService, priceOf, productImages, productService, productVideos, profileService, qs, readStaticStore, reelsService, regionService, reviewService, searchService, serveRestLocally, setRequestHost, setStaticStore, settingService, settingsService, stateService, staticStore, storeForHost, storeService, toAddOn, toCart, toCartLine, toCartOffer, toCategory, toCheckoutQuote, toCmsPage, toCollection, toEngineAddress, toFreeShipping, toIdentityAddress, toMajor, toMinor, toOrder, toPage, toProduct, toRating, toStorefrontFacets, toUser, toVariant, toVendor, uploadService, userService, variantService, varniCustomDesignService, varniCustomProductService, vendorService, warrantyService, whatsappService, wishlistService };
4119
4280
  //# sourceMappingURL=index.js.map
4120
4281
  //# sourceMappingURL=index.js.map