@misiki/gocommerce-connector 0.23.0 → 0.24.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 DealService, M as DemoRequestService, N as EngineRequest, O as EnquiryService, P as Envelope, Q as FacetValue, R as Faq, S as FaqService, T as FeedbackService, U as FooterSettings, V as FreeShipping, W as Fulfillment, X as GalleryService, Y as GooglePlace, Z as GoogleReview, _ as GoogleReviewService, $ as GoogleReviews, a0 as GoogleSurvey, a1 as HeaderSettings, a2 as HomeLayout, a3 as HomeLayoutSection, a4 as HomeService, a5 as IdentityAddress, a6 as InitService, a7 as Invitation, a8 as LayoutCollection, a9 as LayoutPage, aa as LayoutService, ab as Lead, ac as ListMeta, ad as MeilisearchService, ae as Member, af as Menu, ag as MenuItem, ah as MenuService, ai as MenuSummary, aj as Money, ak as NewsletterService, al as Offer, am as OpeningHours, an as Order, ao as OrderLine, ap as OrderService, aq as PageLayout, ar as PageService, as as PaymentIntent, at as PaymentMethodService, au as Plugin, av as PluginService, av as PluginsService, aw as PopularSearchService, ax as PopularityService, ay as Postcode, az as Product, aA as ProductFacets, aB as ProductOption, aC as ProductService, aD as ProfileService, aE as Quote, aF as REDIRECT_GATEWAYS, aG as ReelsService, aH as RegionService, aI as RejectedLine, aJ as Review, aK as ReviewPage, aL as ReviewService, aM as SearchDoc, aN as SearchResult, aO as SearchService, aP as SettingService, aP as SettingsService, aQ as ShippingRate, aR as SiteChrome, aS as SiteFooter, aT as SiteHeader, aU as SocialLink, aV as StateService, aW as StoreProfile, aX as StoreService, aY as StorefrontCategory, aZ as StorefrontMenu, a_ as StorefrontOrder, a$ as StorefrontProduct, b0 as ThemeSettings, b1 as ThemeSettingsResult, b2 as UploadService, b3 as UserService, b4 as Variant, b5 as VariantImage, b6 as VariantService, b7 as VarniCustomDesignService, b8 as VarniCustomProductService, b9 as Vendor, ba as VendorService, bb as WarrantyService, bc as WhatsappConsent, bd as WhatsappConsentOffer, be as WhatsappService, bf as Wishlist, bg as WishlistItem, bh as WishlistService, bi as addressService, bj as authService, bk as autocompleteService, bl as b2bService, bm as bannerService, bn as blogService, bo as cartService, bp as categoryService, bq as chatService, br as checkoutService, bs as collectionService, bt as contactService, bu as countryService, bv as couponService, bw as currencyExponent, bx as currencyService, by as dealService, bz as demoRequestService, bA as emptyCart, bB as emptyPage, bC as enquiryService, bD as faqService, bE as feedbackService, bF as fromEngineAddress, bG as fromIdentityAddress, bH as fromSearchDoc, bI as galleryService, bJ as googleReviewService, bK as homeService, bL as initService, bM as layoutService, bN as mediaUrl, bO as meilisearchService, bP as menuService, bQ as minorToMajor, bR as newsletterService, bS as orderService, bT as ownDomain, bU as pageService, bV as paymentMethodService, bW as pluginService, bX as pluginsService, bY as popularSearchService, bZ as popularityService, b_ as priceOf, b$ as productImages, c0 as productService, c1 as productVideos, c2 as profileService, c3 as qs, c4 as reelsService, c5 as regionService, c6 as reviewService, c7 as searchService, c8 as setRequestHost, c9 as settingService, ca as settingsService, cb as stateService, cc as staticStore, cd as storeForHost, ce as storeService, cf as toAddOn, cg as toCart, ch as toCartLine, ci as toCartOffer, cj as toCategory, ck as toCmsPage, cl as toCollection, cm as toEngineAddress, cn as toFreeShipping, co as toIdentityAddress, cp as toMajor, cq as toMinor, cr as toOrder, cs as toPage, ct as toProduct, cu as toRating, cv as toStorefrontFacets, cw as toUser, cx as toVariant, cy as toVendor, cz as uploadService, cA as userService, cB as variantService, cC as varniCustomDesignService, cD as varniCustomProductService, cE as vendorService, cF as warrantyService, cG as whatsappService, cH as wishlistService } from './index-BM6hYdQs.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 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-BWg1KptA.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 DealService, M as DemoRequestService, N as EngineRequest, O as EnquiryService, P as Envelope, Q as FacetValue, R as Faq, S as FaqService, T as FeedbackService, U as FooterSettings, V as FreeShipping, W as Fulfillment, X as GalleryService, Y as GooglePlace, Z as GoogleReview, _ as GoogleReviewService, $ as GoogleReviews, a0 as GoogleSurvey, a1 as HeaderSettings, a2 as HomeLayout, a3 as HomeLayoutSection, a4 as HomeService, a5 as IdentityAddress, a6 as InitService, a7 as Invitation, a8 as LayoutCollection, a9 as LayoutPage, aa as LayoutService, ab as Lead, ac as ListMeta, ad as MeilisearchService, ae as Member, af as Menu, ag as MenuItem, ah as MenuService, ai as MenuSummary, aj as Money, ak as NewsletterService, al as Offer, am as OpeningHours, an as Order, ao as OrderLine, ap as OrderService, aq as PageLayout, ar as PageService, as as PaymentIntent, at as PaymentMethodService, au as Plugin, av as PluginService, av as PluginsService, aw as PopularSearchService, ax as PopularityService, ay as Postcode, az as Product, aA as ProductFacets, aB as ProductOption, aC as ProductService, aD as ProfileService, aE as Quote, aF as REDIRECT_GATEWAYS, aG as ReelsService, aH as RegionService, aI as RejectedLine, aJ as Review, aK as ReviewPage, aL as ReviewService, aM as SearchDoc, aN as SearchResult, aO as SearchService, aP as SettingService, aP as SettingsService, aQ as ShippingRate, aR as SiteChrome, aS as SiteFooter, aT as SiteHeader, aU as SocialLink, aV as StateService, aW as StoreProfile, aX as StoreService, aY as StorefrontCategory, aZ as StorefrontMenu, a_ as StorefrontOrder, a$ as StorefrontProduct, b0 as ThemeSettings, b1 as ThemeSettingsResult, b2 as UploadService, b3 as UserService, b4 as Variant, b5 as VariantImage, b6 as VariantService, b7 as VarniCustomDesignService, b8 as VarniCustomProductService, b9 as Vendor, ba as VendorService, bb as WarrantyService, bc as WhatsappConsent, bd as WhatsappConsentOffer, be as WhatsappService, bf as Wishlist, bg as WishlistItem, bh as WishlistService, bi as addressService, bj as authService, bk as autocompleteService, bl as b2bService, bm as bannerService, bn as blogService, bo as cartService, bp as categoryService, bq as chatService, br as checkoutService, bs as collectionService, bt as contactService, bu as countryService, bv as couponService, bw as currencyExponent, bx as currencyService, by as dealService, bz as demoRequestService, bA as emptyCart, bB as emptyPage, bC as enquiryService, bD as faqService, bE as feedbackService, bF as fromEngineAddress, bG as fromIdentityAddress, bH as fromSearchDoc, bI as galleryService, bJ as googleReviewService, bK as homeService, bL as initService, bM as layoutService, bN as mediaUrl, bO as meilisearchService, bP as menuService, bQ as minorToMajor, bR as newsletterService, bS as orderService, bT as ownDomain, bU as pageService, bV as paymentMethodService, bW as pluginService, bX as pluginsService, bY as popularSearchService, bZ as popularityService, b_ as priceOf, b$ as productImages, c0 as productService, c1 as productVideos, c2 as profileService, c3 as qs, c4 as reelsService, c5 as regionService, c6 as reviewService, c7 as searchService, c8 as setRequestHost, c9 as settingService, ca as settingsService, cb as stateService, cc as staticStore, cd as storeForHost, ce as storeService, cf as toAddOn, cg as toCart, ch as toCartLine, ci as toCartOffer, cj as toCategory, ck as toCmsPage, cl as toCollection, cm as toEngineAddress, cn as toFreeShipping, co as toIdentityAddress, cp as toMajor, cq as toMinor, cr as toOrder, cs as toPage, ct as toProduct, cu as toRating, cv as toStorefrontFacets, cw as toUser, cx as toVariant, cy as toVendor, cz as uploadService, cA as userService, cB as variantService, cC as varniCustomDesignService, cD as varniCustomProductService, cE as vendorService, cF as warrantyService, cG as whatsappService, cH as wishlistService } from './index-BM6hYdQs.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 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-BWg1KptA.js';
2
2
 
3
3
  /**
4
4
  * The two ways a call through this connector fails.
package/dist/index.js CHANGED
@@ -375,7 +375,8 @@ var BaseService = class _BaseService {
375
375
  const lang = (req.method ?? "GET") === "GET" ? this.creds.language : void 0;
376
376
  const url = this.engineURL(path, lang ? { lang, ...req.query } : req.query);
377
377
  const headers = { Accept: "application/json", ...req.headers };
378
- if (req.body !== void 0) headers["Content-Type"] = "application/json";
378
+ const form = req.body instanceof FormData ? req.body : void 0;
379
+ if (req.body !== void 0 && !form) headers["Content-Type"] = "application/json";
379
380
  const store = this.store;
380
381
  if (store) headers["X-Store"] = store;
381
382
  if (req.auth) {
@@ -386,7 +387,7 @@ var BaseService = class _BaseService {
386
387
  const init = {
387
388
  method: req.method ?? "GET",
388
389
  headers,
389
- body: req.body === void 0 ? void 0 : JSON.stringify(req.body)
390
+ body: form ?? (req.body === void 0 ? void 0 : JSON.stringify(req.body))
390
391
  };
391
392
  let res;
392
393
  try {
@@ -842,6 +843,9 @@ function toCartLine(l, extra = {}) {
842
843
  /** The add-on this line was bought as (D133), or null on an ordinary line. */
843
844
  addOnId: l.add_on_id ? str(l.add_on_id) : null,
844
845
  addOnFor: l.add_on_for ? str(l.add_on_for) : null,
846
+ /** The shopper's own design this line is made to (D162) and its picture, or null on a line sold as it is. */
847
+ designId: l.design_id ?? null,
848
+ designPreview: mediaUrl(l.design_preview_url),
845
849
  subtotal: toMajor(l.total),
846
850
  total: toMajor(l.total),
847
851
  inStock: l.in_stock,
@@ -956,6 +960,8 @@ function toOrderLine(l, currency) {
956
960
  total: toMajor(l.total),
957
961
  currencyCode: currency,
958
962
  status: l.shipped_quantity >= l.quantity ? "Shipped" : "Pending",
963
+ designId: l.metadata?.design?.id ?? null,
964
+ designPreview: mediaUrl(l.metadata?.design?.preview_url),
959
965
  files: [],
960
966
  usedOptions: []
961
967
  };
@@ -1773,13 +1779,16 @@ var CartService = class extends BaseService {
1773
1779
  }
1774
1780
  /**
1775
1781
  * `qty` is a change, not a total: +1 from a product page, −1 from a card's
1776
- * minus button. With no cart yet, one is opened and remembered.
1782
+ * minus button. With no cart yet, one is opened and remembered. A
1783
+ * `designId` from `customizerService.saveDesign` makes the variant to the
1784
+ * shopper's design, on a line of its own.
1777
1785
  */
1778
1786
  async addToCart({
1779
1787
  cartId,
1780
1788
  lineId,
1781
1789
  qty = 1,
1782
- variantId
1790
+ variantId,
1791
+ designId
1783
1792
  }) {
1784
1793
  let id2 = clean(cartId) ?? storedCartId();
1785
1794
  if (lineId && id2) {
@@ -1793,21 +1802,16 @@ var CartService = class extends BaseService {
1793
1802
  if (qty === REMOVE || Number(qty) <= 0) return this.getCartByCartId(id2);
1794
1803
  if (!variantId) throw new GoCommerceError("Please choose an option before adding this to your bag.", 400);
1795
1804
  if (!id2) id2 = await this.open();
1805
+ const body = { variant_id: Number(variantId), quantity: Number(qty), ...designId ? { design_id: designId } : {} };
1796
1806
  try {
1797
1807
  return await this.present(
1798
- await this.data(`/api/carts/${encodeURIComponent(id2)}/line-items`, {
1799
- method: "POST",
1800
- body: { variant_id: Number(variantId), quantity: Number(qty) }
1801
- })
1808
+ await this.data(`/api/carts/${encodeURIComponent(id2)}/line-items`, { method: "POST", body })
1802
1809
  );
1803
1810
  } catch (err) {
1804
- if (err instanceof GoCommerceError && (err.status === 404 || /checked out/.test(err.message))) {
1811
+ if (err instanceof GoCommerceError && /cart not found|checked out/.test(err.message)) {
1805
1812
  const fresh = await this.open();
1806
1813
  return this.present(
1807
- await this.data(`/api/carts/${encodeURIComponent(fresh)}/line-items`, {
1808
- method: "POST",
1809
- body: { variant_id: Number(variantId), quantity: Number(qty) }
1810
- })
1814
+ await this.data(`/api/carts/${encodeURIComponent(fresh)}/line-items`, { method: "POST", body })
1811
1815
  );
1812
1816
  }
1813
1817
  throw err;
@@ -2044,6 +2048,54 @@ var CartService = class extends BaseService {
2044
2048
  var clean = (id2) => id2 && id2 !== "undefined" && id2 !== "null" ? id2 : null;
2045
2049
  var cartService = new CartService();
2046
2050
 
2051
+ // src/services/customizer-service.ts
2052
+ var CustomizerService = class extends BaseService {
2053
+ facts = new StoreFacts(this._fetch);
2054
+ /** Null when the product cannot be designed, or on any failure: the page draws without the editor. */
2055
+ async setup(productId) {
2056
+ const plugins = await this.facts.plugins().catch(() => null);
2057
+ if (plugins && !plugins.has("customizer")) return null;
2058
+ const path = `/x/customizer/products/${encodeURIComponent(String(productId))}`;
2059
+ const s = await this.data(path).catch(() => null);
2060
+ if (!s) return null;
2061
+ return {
2062
+ productId: String(s.product_id),
2063
+ mockup: { ...s.mockup, url: media(s.mockup.url) },
2064
+ overlayUrl: mediaUrl(s.overlay_url),
2065
+ printArea: s.print_area,
2066
+ printSize: { widthMm: s.print_size.width_mm, heightMm: s.print_size.height_mm, dpi: s.print_size.dpi },
2067
+ tools: s.tools,
2068
+ fonts: s.fonts,
2069
+ stickers: s.stickers.map((k) => ({ ...k, url: media(k.url) })),
2070
+ minPhotoPx: s.min_photo_px,
2071
+ consent: s.consent
2072
+ };
2073
+ }
2074
+ /** A photo, or the finished preview or print file. The engine's refusal is thrown with its message. */
2075
+ async upload(file, filename) {
2076
+ const body = new FormData();
2077
+ body.append("file", file, filename);
2078
+ const u = await this.data("/x/customizer/uploads", { method: "POST", body });
2079
+ return { uploadId: u.upload_id, url: media(u.url), width: u.width, height: u.height };
2080
+ }
2081
+ /** The document goes as it is: the order keeps it, and whatever renders the print reads it there. */
2082
+ async saveDesign(design) {
2083
+ const d = await this.data("/x/customizer/designs", {
2084
+ method: "POST",
2085
+ body: {
2086
+ product_id: Number(design.productId),
2087
+ variant_id: Number(design.variantId),
2088
+ preview_upload_id: design.previewUploadId,
2089
+ print_upload_id: design.printUploadId,
2090
+ document: design.document
2091
+ }
2092
+ });
2093
+ return { designId: d.design_id, previewUrl: media(d.preview_url) };
2094
+ }
2095
+ };
2096
+ var media = (url) => mediaUrl(url) ?? url;
2097
+ var customizerService = new CustomizerService();
2098
+
2047
2099
  // src/services/checkout-service.ts
2048
2100
  var CheckoutService = class extends BaseService {
2049
2101
  /** Delivery options for the address on the cart: `{ data: [{ id, name, base_rate }] }`. */
@@ -4023,6 +4075,6 @@ function attemptKey(request) {
4023
4075
  }
4024
4076
  var b2bService = new B2bService();
4025
4077
 
4026
- export { AddressService, AuthService, AutocompleteService, B2bService, BannerService, BaseService, BlogService, CartService, CatalogService, CategoryService, ChatService, CheckoutService, CollectionService, ContactService, CountryService, CouponService, CurrencyService, 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, 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 };
4078
+ 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 };
4027
4079
  //# sourceMappingURL=index.js.map
4028
4080
  //# sourceMappingURL=index.js.map