@misiki/gocommerce-connector 0.4.2 → 0.4.4

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 Address, a as AddressService, b as AppliedDiscount, c as Approval, d as AuthResponse, e as AuthService, f as AutocompleteService, B as B2bPlaced, g as B2bRole, h as B2bService, i as BannerService, j as BaseService, k as BlogService, C as Cart, l as CartLine, m as CartService, n as CatalogService, o as Category, p as CategoryService, q as ChatService, r as CheckoutOptions, s as CheckoutResult, t as CheckoutService, u as CmsPage, v as Collection, w as CollectionService, x as Company, y as CompanyOrder, z as ContactService, D as CountryService, E as CouponService, F as Credentials, G as Credit, H as CurrencyService, I as Customer, J as DealService, K as DemoRequestService, L as EngineRequest, M as EnquiryService, N as Envelope, O as Faq, P as FaqService, Q as FeedbackService, R as Fulfillment, S as GalleryService, T as HomeService, U as IdentityAddress, V as InitService, W as Invitation, X as Lead, Y as ListMeta, Z as MeilisearchService, _ as Member, $ as Menu, a0 as MenuItem, a1 as MenuService, a2 as MenuSummary, a3 as Money, a4 as NewsletterService, a5 as Offer, a6 as Order, a7 as OrderLine, a8 as OrderService, a9 as PageService, aa as PaymentIntent, ab as PaymentMethodService, ac as Plugin, ad as PluginService, ad as PluginsService, ae as PopularSearchService, af as PopularityService, ag as Product, ah as ProductOption, ai as ProductService, aj as ProfileService, ak as Quote, al as REDIRECT_GATEWAYS, am as ReelsService, an as RegionService, ao as RejectedLine, ap as Review, aq as ReviewPage, ar as ReviewService, as as SearchDoc, at as SearchResult, au as SearchService, av as SettingService, av as SettingsService, aw as ShippingRate, ax as StateService, ay as StoreProfile, az as StoreService, aA as StorefrontCategory, aB as StorefrontMenu, aC as StorefrontOrder, aD as StorefrontProduct, aE as UploadService, aF as UserService, aG as Variant, aH as VariantImage, aI as VariantService, aJ as VarniCustomDesignService, aK as VarniCustomProductService, aL as Vendor, aM as VendorService, aN as WarrantyService, aO as Wishlist, aP as WishlistItem, aQ as WishlistService, aR as addressService, aS as authService, aT as autocompleteService, aU as b2bService, aV as bannerService, aW as blogService, aX as cartService, aY as categoryService, aZ as chatService, a_ as checkoutService, a$ as collectionService, b0 as contactService, b1 as countryService, b2 as couponService, b3 as currencyExponent, b4 as currencyService, b5 as dealService, b6 as demoRequestService, b7 as emptyCart, b8 as emptyPage, b9 as enquiryService, ba as faqService, bb as feedbackService, bc as fromEngineAddress, bd as fromIdentityAddress, be as fromSearchDoc, bf as galleryService, bg as homeService, bh as initService, bi as mediaUrl, bj as meilisearchService, bk as menuService, bl as minorToMajor, bm as newsletterService, bn as orderService, bo as pageService, bp as paymentMethodService, bq as pluginService, br as pluginsService, bs as popularSearchService, bt as popularityService, bu as priceOf, bv as productImages, bw as productService, bx as profileService, by as qs, bz as reelsService, bA as regionService, bB as reviewService, bC as searchService, bD as setRequestHost, bE as settingService, bF as settingsService, bG as stateService, bH as staticStore, bI as storeForHost, bJ as storeService, bK as toCart, bL as toCartLine, bM as toCategory, bN as toCmsPage, bO as toCollection, bP as toEngineAddress, bQ as toIdentityAddress, bR as toMajor, bS as toMinor, bT as toOrder, bU as toPage, bV as toProduct, bW as toRating, bX as toUser, bY as toVariant, bZ as toVendor, b_ as uploadService, b$ as userService, c0 as variantService, c1 as varniCustomDesignService, c2 as varniCustomProductService, c3 as vendorService, c4 as warrantyService, c5 as wishlistService } from './index-CIjHKuHK.cjs';
1
+ export { A as Address, a as AddressService, b as AppliedDiscount, c as Approval, d as AuthResponse, e as AuthService, f as AutocompleteService, B as B2bPlaced, g as B2bRole, h as B2bService, i as BannerService, j as BaseService, k as BlogService, C as Cart, l as CartLine, m as CartService, n as CatalogService, o as Category, p as CategoryService, q as ChatService, r as CheckoutOptions, s as CheckoutResult, t as CheckoutService, u as CmsPage, v as Collection, w as CollectionService, x as Company, y as CompanyOrder, z as ContactService, D as CountryService, E as CouponService, F as Credentials, G as Credit, H as CurrencyService, I as Customer, J as DealService, K as DemoRequestService, L as EngineRequest, M as EnquiryService, N as Envelope, O as Faq, P as FaqService, Q as FeedbackService, R as Fulfillment, S as GalleryService, T as HomeService, U as IdentityAddress, V as InitService, W as Invitation, X as Lead, Y as ListMeta, Z as MeilisearchService, _ as Member, $ as Menu, a0 as MenuItem, a1 as MenuService, a2 as MenuSummary, a3 as Money, a4 as NewsletterService, a5 as Offer, a6 as Order, a7 as OrderLine, a8 as OrderService, a9 as PageService, aa as PaymentIntent, ab as PaymentMethodService, ac as Plugin, ad as PluginService, ad as PluginsService, ae as PopularSearchService, af as PopularityService, ag as Product, ah as ProductOption, ai as ProductService, aj as ProfileService, ak as Quote, al as REDIRECT_GATEWAYS, am as ReelsService, an as RegionService, ao as RejectedLine, ap as Review, aq as ReviewPage, ar as ReviewService, as as SearchDoc, at as SearchResult, au as SearchService, av as SettingService, av as SettingsService, aw as ShippingRate, ax as StateService, ay as StoreProfile, az as StoreService, aA as StorefrontCategory, aB as StorefrontMenu, aC as StorefrontOrder, aD as StorefrontProduct, aE as UploadService, aF as UserService, aG as Variant, aH as VariantImage, aI as VariantService, aJ as VarniCustomDesignService, aK as VarniCustomProductService, aL as Vendor, aM as VendorService, aN as WarrantyService, aO as Wishlist, aP as WishlistItem, aQ as WishlistService, aR as addressService, aS as authService, aT as autocompleteService, aU as b2bService, aV as bannerService, aW as blogService, aX as cartService, aY as categoryService, aZ as chatService, a_ as checkoutService, a$ as collectionService, b0 as contactService, b1 as countryService, b2 as couponService, b3 as currencyExponent, b4 as currencyService, b5 as dealService, b6 as demoRequestService, b7 as emptyCart, b8 as emptyPage, b9 as enquiryService, ba as faqService, bb as feedbackService, bc as fromEngineAddress, bd as fromIdentityAddress, be as fromSearchDoc, bf as galleryService, bg as homeService, bh as initService, bi as mediaUrl, bj as meilisearchService, bk as menuService, bl as minorToMajor, bm as newsletterService, bn as orderService, bo as ownDomain, bp as pageService, bq as paymentMethodService, br as pluginService, bs as pluginsService, bt as popularSearchService, bu as popularityService, bv as priceOf, bw as productImages, bx as productService, by as profileService, bz as qs, bA as reelsService, bB as regionService, bC as reviewService, bD as searchService, bE as setRequestHost, bF as settingService, bG as settingsService, bH as stateService, bI as staticStore, bJ as storeForHost, bK as storeService, bL as toCart, bM as toCartLine, bN as toCategory, bO as toCmsPage, bP as toCollection, bQ as toEngineAddress, bR as toIdentityAddress, bS as toMajor, bT as toMinor, bU as toOrder, bV as toPage, bW as toProduct, bX as toRating, bY as toUser, bZ as toVariant, b_ as toVendor, b$ as uploadService, c0 as userService, c1 as variantService, c2 as varniCustomDesignService, c3 as varniCustomProductService, c4 as vendorService, c5 as warrantyService, c6 as wishlistService } from './index-BNYk4TS2.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 Address, a as AddressService, b as AppliedDiscount, c as Approval, d as AuthResponse, e as AuthService, f as AutocompleteService, B as B2bPlaced, g as B2bRole, h as B2bService, i as BannerService, j as BaseService, k as BlogService, C as Cart, l as CartLine, m as CartService, n as CatalogService, o as Category, p as CategoryService, q as ChatService, r as CheckoutOptions, s as CheckoutResult, t as CheckoutService, u as CmsPage, v as Collection, w as CollectionService, x as Company, y as CompanyOrder, z as ContactService, D as CountryService, E as CouponService, F as Credentials, G as Credit, H as CurrencyService, I as Customer, J as DealService, K as DemoRequestService, L as EngineRequest, M as EnquiryService, N as Envelope, O as Faq, P as FaqService, Q as FeedbackService, R as Fulfillment, S as GalleryService, T as HomeService, U as IdentityAddress, V as InitService, W as Invitation, X as Lead, Y as ListMeta, Z as MeilisearchService, _ as Member, $ as Menu, a0 as MenuItem, a1 as MenuService, a2 as MenuSummary, a3 as Money, a4 as NewsletterService, a5 as Offer, a6 as Order, a7 as OrderLine, a8 as OrderService, a9 as PageService, aa as PaymentIntent, ab as PaymentMethodService, ac as Plugin, ad as PluginService, ad as PluginsService, ae as PopularSearchService, af as PopularityService, ag as Product, ah as ProductOption, ai as ProductService, aj as ProfileService, ak as Quote, al as REDIRECT_GATEWAYS, am as ReelsService, an as RegionService, ao as RejectedLine, ap as Review, aq as ReviewPage, ar as ReviewService, as as SearchDoc, at as SearchResult, au as SearchService, av as SettingService, av as SettingsService, aw as ShippingRate, ax as StateService, ay as StoreProfile, az as StoreService, aA as StorefrontCategory, aB as StorefrontMenu, aC as StorefrontOrder, aD as StorefrontProduct, aE as UploadService, aF as UserService, aG as Variant, aH as VariantImage, aI as VariantService, aJ as VarniCustomDesignService, aK as VarniCustomProductService, aL as Vendor, aM as VendorService, aN as WarrantyService, aO as Wishlist, aP as WishlistItem, aQ as WishlistService, aR as addressService, aS as authService, aT as autocompleteService, aU as b2bService, aV as bannerService, aW as blogService, aX as cartService, aY as categoryService, aZ as chatService, a_ as checkoutService, a$ as collectionService, b0 as contactService, b1 as countryService, b2 as couponService, b3 as currencyExponent, b4 as currencyService, b5 as dealService, b6 as demoRequestService, b7 as emptyCart, b8 as emptyPage, b9 as enquiryService, ba as faqService, bb as feedbackService, bc as fromEngineAddress, bd as fromIdentityAddress, be as fromSearchDoc, bf as galleryService, bg as homeService, bh as initService, bi as mediaUrl, bj as meilisearchService, bk as menuService, bl as minorToMajor, bm as newsletterService, bn as orderService, bo as pageService, bp as paymentMethodService, bq as pluginService, br as pluginsService, bs as popularSearchService, bt as popularityService, bu as priceOf, bv as productImages, bw as productService, bx as profileService, by as qs, bz as reelsService, bA as regionService, bB as reviewService, bC as searchService, bD as setRequestHost, bE as settingService, bF as settingsService, bG as stateService, bH as staticStore, bI as storeForHost, bJ as storeService, bK as toCart, bL as toCartLine, bM as toCategory, bN as toCmsPage, bO as toCollection, bP as toEngineAddress, bQ as toIdentityAddress, bR as toMajor, bS as toMinor, bT as toOrder, bU as toPage, bV as toProduct, bW as toRating, bX as toUser, bY as toVariant, bZ as toVendor, b_ as uploadService, b$ as userService, c0 as variantService, c1 as varniCustomDesignService, c2 as varniCustomProductService, c3 as vendorService, c4 as warrantyService, c5 as wishlistService } from './index-CIjHKuHK.js';
1
+ export { A as Address, a as AddressService, b as AppliedDiscount, c as Approval, d as AuthResponse, e as AuthService, f as AutocompleteService, B as B2bPlaced, g as B2bRole, h as B2bService, i as BannerService, j as BaseService, k as BlogService, C as Cart, l as CartLine, m as CartService, n as CatalogService, o as Category, p as CategoryService, q as ChatService, r as CheckoutOptions, s as CheckoutResult, t as CheckoutService, u as CmsPage, v as Collection, w as CollectionService, x as Company, y as CompanyOrder, z as ContactService, D as CountryService, E as CouponService, F as Credentials, G as Credit, H as CurrencyService, I as Customer, J as DealService, K as DemoRequestService, L as EngineRequest, M as EnquiryService, N as Envelope, O as Faq, P as FaqService, Q as FeedbackService, R as Fulfillment, S as GalleryService, T as HomeService, U as IdentityAddress, V as InitService, W as Invitation, X as Lead, Y as ListMeta, Z as MeilisearchService, _ as Member, $ as Menu, a0 as MenuItem, a1 as MenuService, a2 as MenuSummary, a3 as Money, a4 as NewsletterService, a5 as Offer, a6 as Order, a7 as OrderLine, a8 as OrderService, a9 as PageService, aa as PaymentIntent, ab as PaymentMethodService, ac as Plugin, ad as PluginService, ad as PluginsService, ae as PopularSearchService, af as PopularityService, ag as Product, ah as ProductOption, ai as ProductService, aj as ProfileService, ak as Quote, al as REDIRECT_GATEWAYS, am as ReelsService, an as RegionService, ao as RejectedLine, ap as Review, aq as ReviewPage, ar as ReviewService, as as SearchDoc, at as SearchResult, au as SearchService, av as SettingService, av as SettingsService, aw as ShippingRate, ax as StateService, ay as StoreProfile, az as StoreService, aA as StorefrontCategory, aB as StorefrontMenu, aC as StorefrontOrder, aD as StorefrontProduct, aE as UploadService, aF as UserService, aG as Variant, aH as VariantImage, aI as VariantService, aJ as VarniCustomDesignService, aK as VarniCustomProductService, aL as Vendor, aM as VendorService, aN as WarrantyService, aO as Wishlist, aP as WishlistItem, aQ as WishlistService, aR as addressService, aS as authService, aT as autocompleteService, aU as b2bService, aV as bannerService, aW as blogService, aX as cartService, aY as categoryService, aZ as chatService, a_ as checkoutService, a$ as collectionService, b0 as contactService, b1 as countryService, b2 as couponService, b3 as currencyExponent, b4 as currencyService, b5 as dealService, b6 as demoRequestService, b7 as emptyCart, b8 as emptyPage, b9 as enquiryService, ba as faqService, bb as feedbackService, bc as fromEngineAddress, bd as fromIdentityAddress, be as fromSearchDoc, bf as galleryService, bg as homeService, bh as initService, bi as mediaUrl, bj as meilisearchService, bk as menuService, bl as minorToMajor, bm as newsletterService, bn as orderService, bo as ownDomain, bp as pageService, bq as paymentMethodService, br as pluginService, bs as pluginsService, bt as popularSearchService, bu as popularityService, bv as priceOf, bw as productImages, bx as productService, by as profileService, bz as qs, bA as reelsService, bB as regionService, bC as reviewService, bD as searchService, bE as setRequestHost, bF as settingService, bG as settingsService, bH as stateService, bI as staticStore, bJ as storeForHost, bK as storeService, bL as toCart, bM as toCartLine, bN as toCategory, bO as toCmsPage, bP as toCollection, bQ as toEngineAddress, bR as toIdentityAddress, bS as toMajor, bT as toMinor, bU as toOrder, bV as toPage, bW as toProduct, bX as toRating, bY as toUser, bZ as toVariant, b_ as toVendor, b$ as uploadService, c0 as userService, c1 as variantService, c2 as varniCustomDesignService, c3 as varniCustomProductService, c4 as vendorService, c5 as warrantyService, c6 as wishlistService } from './index-BNYk4TS2.js';
2
2
 
3
3
  /**
4
4
  * The two ways a call through this connector fails.
package/dist/index.js CHANGED
@@ -285,14 +285,16 @@ var BaseService = class _BaseService {
285
285
  }
286
286
  /**
287
287
  * The store this call is for: the request host's subdomain under
288
- * `baseDomain`, else the static `store`. Read per call, never stored on the
289
- * instance, because the server shares one process (and one credentials
290
- * object) across every concurrent request and each may be for a different host.
288
+ * `baseDomain`, else the static `store`, else the host itself when it is a
289
+ * store's own domain (the engine answers only a verified one). Read per call,
290
+ * never stored on the instance, because the server shares one process (and
291
+ * one credentials object) across every concurrent request and each may be
292
+ * for a different host.
291
293
  */
292
294
  get store() {
293
295
  const { baseDomain, store } = this.creds;
294
296
  const host = typeof window !== "undefined" ? window.location?.hostname : requestHost?.();
295
- return storeForHost(host, baseDomain) ?? store;
297
+ return storeForHost(host, baseDomain) ?? store ?? ownDomain(host, baseDomain);
296
298
  }
297
299
  /**
298
300
  * The engine's base URL from wherever this code runs. In the browser a
@@ -442,6 +444,14 @@ function storeForHost(host, baseDomain) {
442
444
  const slug = h.slice(0, -suffix.length);
443
445
  return slug && !slug.includes(".") ? slug : void 0;
444
446
  }
447
+ function ownDomain(host, baseDomain) {
448
+ if (!host || !baseDomain) return void 0;
449
+ const h = host.toLowerCase().replace(/:\d+$/, "").replace(/\.$/, "");
450
+ const base = baseDomain.toLowerCase().replace(/^\.+/, "").replace(/\.$/, "");
451
+ if (!h.includes(".") || h === base || h.endsWith("." + base) || h.endsWith(".localhost")) return void 0;
452
+ if (/^[\d.]+$/.test(h) || h.includes(":") || h.startsWith("[")) return void 0;
453
+ return h;
454
+ }
445
455
  var unreachable = (base, cause) => new GoCommerceError(`Could not reach the commerce engine at ${base}: ${cause?.message ?? cause}`, 0);
446
456
  function qs(query) {
447
457
  if (!query) return "";
@@ -2032,12 +2042,31 @@ var OrderService = class extends BaseService {
2032
2042
  async listPublic(_args = {}) {
2033
2043
  return emptyPage();
2034
2044
  }
2035
- async getOrderByEmailAndOTP() {
2036
- throw new NotSupportedError(
2037
- "OrderService",
2038
- "getOrderByEmailAndOTP",
2039
- "the engine sends no one-time codes; a guest reads an order with its access token"
2045
+ /**
2046
+ * Sends a 4-digit code to the email or phone on the order, when `contact`
2047
+ * is that email or phone. The engine answers the same either way, so this
2048
+ * resolves whether or not anything was sent.
2049
+ */
2050
+ async requestOrderCode({ orderNo, contact }) {
2051
+ const res = await this.data(
2052
+ `/api/orders/${encodeURIComponent(orderNo.trim())}/code`,
2053
+ { method: "POST", body: { contact: contact.trim() } }
2054
+ );
2055
+ return { expiresInMinutes: res?.expires_in_minutes ?? 10 };
2056
+ }
2057
+ /**
2058
+ * Opens an order with the code `requestOrderCode` sent. The token it answers
2059
+ * is kept like an order placed in this browser, so the order page and
2060
+ * `getOrder` read it again without another code.
2061
+ */
2062
+ async getOrderByEmailAndOTP({ orderNo, otp }) {
2063
+ const number = orderNo.trim();
2064
+ const res = await this.data(
2065
+ `/api/orders/${encodeURIComponent(number)}/code/verify`,
2066
+ { method: "POST", body: { code: String(otp).trim() } }
2040
2067
  );
2068
+ rememberOrder({ number: res.order.number, token: res.access_token, cartId: "" });
2069
+ return { data: [toOrder(res.order)] };
2041
2070
  }
2042
2071
  };
2043
2072
  var clean2 = (v) => v && v !== "undefined" && v !== "null" ? v : void 0;
@@ -3125,6 +3154,6 @@ function attemptKey(request) {
3125
3154
  }
3126
3155
  var b2bService = new B2bService();
3127
3156
 
3128
- 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, HomeService, InitService, 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, 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, hasStaticStore, homeService, initService, mediaUrl, meilisearchService, menuService, minorToMajor, newsletterService, orderService, pageService, paymentMethodService, pluginService, pluginsService, popularSearchService, popularityService, priceOf, productImages, productService, profileService, qs, readStaticStore, reelsService, regionService, reviewService, searchService, serveRestLocally, setRequestHost, setStaticStore, settingService, settingsService, stateService, staticStore, storeForHost, storeService, toCart, toCartLine, toCategory, toCmsPage, toCollection, toEngineAddress, toIdentityAddress, toMajor, toMinor, toOrder, toPage, toProduct, toRating, toUser, toVariant, toVendor, uploadService, userService, variantService, varniCustomDesignService, varniCustomProductService, vendorService, warrantyService, wishlistService };
3157
+ 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, HomeService, InitService, 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, 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, hasStaticStore, homeService, initService, mediaUrl, meilisearchService, menuService, minorToMajor, newsletterService, orderService, ownDomain, pageService, paymentMethodService, pluginService, pluginsService, popularSearchService, popularityService, priceOf, productImages, productService, profileService, qs, readStaticStore, reelsService, regionService, reviewService, searchService, serveRestLocally, setRequestHost, setStaticStore, settingService, settingsService, stateService, staticStore, storeForHost, storeService, toCart, toCartLine, toCategory, toCmsPage, toCollection, toEngineAddress, toIdentityAddress, toMajor, toMinor, toOrder, toPage, toProduct, toRating, toUser, toVariant, toVendor, uploadService, userService, variantService, varniCustomDesignService, varniCustomProductService, vendorService, warrantyService, wishlistService };
3129
3158
  //# sourceMappingURL=index.js.map
3130
3159
  //# sourceMappingURL=index.js.map