@misiki/gocommerce-connector 0.4.3 → 0.4.5

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.
@@ -1 +1 @@
1
- export { a as AddressService, c as Approval, e as AuthService, f as AutocompleteService, B as B2bPlaced, g as B2bRole, h as B2bService, i as BannerService, j as BaseService, k as BlogService, m as CartService, n as CatalogService, p as CategoryService, q as ChatService, t as CheckoutService, w as CollectionService, x as Company, y as CompanyOrder, z as ContactService, D as CountryService, E as CouponService, G as Credit, H as CurrencyService, J as DealService, K as DemoRequestService, L as EngineRequest, M as EnquiryService, P as FaqService, Q as FeedbackService, S as GalleryService, T as HomeService, V as InitService, W as Invitation, X as Lead, Z as MeilisearchService, _ as Member, a1 as MenuService, a4 as NewsletterService, a8 as OrderService, a9 as PageService, ab as PaymentMethodService, ad as PluginService, ad as PluginsService, ae as PopularSearchService, af as PopularityService, ai as ProductService, aj as ProfileService, ak as Quote, al as REDIRECT_GATEWAYS, am as ReelsService, an as RegionService, ao as RejectedLine, ar as ReviewService, au as SearchService, av as SettingService, av as SettingsService, ax as StateService, az as StoreService, aB as StorefrontMenu, aE as UploadService, aF as UserService, aI as VariantService, aJ as VarniCustomDesignService, aK as VarniCustomProductService, aM as VendorService, aN as WarrantyService, 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, b4 as currencyService, b5 as dealService, b6 as demoRequestService, b8 as emptyPage, b9 as enquiryService, ba as faqService, bb as feedbackService, bf as galleryService, bg as homeService, bh as initService, bi as mediaUrl, bj as meilisearchService, bk as menuService, 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, 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, bV as toPage, 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-wGZwLTCe.cjs';
1
+ export { a as AddressService, c as Approval, e as AuthService, f as AutocompleteService, B as B2bPlaced, g as B2bRole, h as B2bService, i as BannerService, j as BaseService, k as BlogService, m as CartService, n as CatalogService, p as CategoryService, q as ChatService, t as CheckoutService, w as CollectionService, x as Company, y as CompanyOrder, z as ContactService, D as CountryService, E as CouponService, G as Credit, H as CurrencyService, J as DealService, K as DemoRequestService, L as EngineRequest, M as EnquiryService, P as FaqService, Q as FeedbackService, S as GalleryService, T as HomeService, V as InitService, W as Invitation, X as Lead, Z as MeilisearchService, _ as Member, a1 as MenuService, a4 as NewsletterService, a8 as OrderService, a9 as PageService, ab as PaymentMethodService, ad as PluginService, ad as PluginsService, ae as PopularSearchService, af as PopularityService, ai as ProductService, aj as ProfileService, ak as Quote, al as REDIRECT_GATEWAYS, am as ReelsService, an as RegionService, ao as RejectedLine, ar as ReviewService, au as SearchService, av as SettingService, av as SettingsService, ax as StateService, az as StoreService, aB as StorefrontMenu, aE as UploadService, aF as UserService, aI as VariantService, aJ as VarniCustomDesignService, aK as VarniCustomProductService, aM as VendorService, aN as WarrantyService, 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, b4 as currencyService, b5 as dealService, b6 as demoRequestService, b8 as emptyPage, b9 as enquiryService, ba as faqService, bb as feedbackService, bf as galleryService, bg as homeService, bh as initService, bi as mediaUrl, bj as meilisearchService, bk as menuService, 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, 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, bV as toPage, 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-CmPI-hcH.cjs';
@@ -1 +1 @@
1
- export { a as AddressService, c as Approval, e as AuthService, f as AutocompleteService, B as B2bPlaced, g as B2bRole, h as B2bService, i as BannerService, j as BaseService, k as BlogService, m as CartService, n as CatalogService, p as CategoryService, q as ChatService, t as CheckoutService, w as CollectionService, x as Company, y as CompanyOrder, z as ContactService, D as CountryService, E as CouponService, G as Credit, H as CurrencyService, J as DealService, K as DemoRequestService, L as EngineRequest, M as EnquiryService, P as FaqService, Q as FeedbackService, S as GalleryService, T as HomeService, V as InitService, W as Invitation, X as Lead, Z as MeilisearchService, _ as Member, a1 as MenuService, a4 as NewsletterService, a8 as OrderService, a9 as PageService, ab as PaymentMethodService, ad as PluginService, ad as PluginsService, ae as PopularSearchService, af as PopularityService, ai as ProductService, aj as ProfileService, ak as Quote, al as REDIRECT_GATEWAYS, am as ReelsService, an as RegionService, ao as RejectedLine, ar as ReviewService, au as SearchService, av as SettingService, av as SettingsService, ax as StateService, az as StoreService, aB as StorefrontMenu, aE as UploadService, aF as UserService, aI as VariantService, aJ as VarniCustomDesignService, aK as VarniCustomProductService, aM as VendorService, aN as WarrantyService, 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, b4 as currencyService, b5 as dealService, b6 as demoRequestService, b8 as emptyPage, b9 as enquiryService, ba as faqService, bb as feedbackService, bf as galleryService, bg as homeService, bh as initService, bi as mediaUrl, bj as meilisearchService, bk as menuService, 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, 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, bV as toPage, 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-wGZwLTCe.js';
1
+ export { a as AddressService, c as Approval, e as AuthService, f as AutocompleteService, B as B2bPlaced, g as B2bRole, h as B2bService, i as BannerService, j as BaseService, k as BlogService, m as CartService, n as CatalogService, p as CategoryService, q as ChatService, t as CheckoutService, w as CollectionService, x as Company, y as CompanyOrder, z as ContactService, D as CountryService, E as CouponService, G as Credit, H as CurrencyService, J as DealService, K as DemoRequestService, L as EngineRequest, M as EnquiryService, P as FaqService, Q as FeedbackService, S as GalleryService, T as HomeService, V as InitService, W as Invitation, X as Lead, Z as MeilisearchService, _ as Member, a1 as MenuService, a4 as NewsletterService, a8 as OrderService, a9 as PageService, ab as PaymentMethodService, ad as PluginService, ad as PluginsService, ae as PopularSearchService, af as PopularityService, ai as ProductService, aj as ProfileService, ak as Quote, al as REDIRECT_GATEWAYS, am as ReelsService, an as RegionService, ao as RejectedLine, ar as ReviewService, au as SearchService, av as SettingService, av as SettingsService, ax as StateService, az as StoreService, aB as StorefrontMenu, aE as UploadService, aF as UserService, aI as VariantService, aJ as VarniCustomDesignService, aK as VarniCustomProductService, aM as VendorService, aN as WarrantyService, 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, b4 as currencyService, b5 as dealService, b6 as demoRequestService, b8 as emptyPage, b9 as enquiryService, ba as faqService, bb as feedbackService, bf as galleryService, bg as homeService, bh as initService, bi as mediaUrl, bj as meilisearchService, bk as menuService, 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, 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, bV as toPage, 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-CmPI-hcH.js';
@@ -2023,12 +2023,31 @@ var OrderService = class extends BaseService {
2023
2023
  async listPublic(_args = {}) {
2024
2024
  return emptyPage();
2025
2025
  }
2026
- async getOrderByEmailAndOTP() {
2027
- throw new NotSupportedError(
2028
- "OrderService",
2029
- "getOrderByEmailAndOTP",
2030
- "the engine sends no one-time codes; a guest reads an order with its access token"
2026
+ /**
2027
+ * Sends a 4-digit code to the email or phone on the order, when `contact`
2028
+ * is that email or phone. The engine answers the same either way, so this
2029
+ * resolves whether or not anything was sent.
2030
+ */
2031
+ async requestOrderCode({ orderNo, contact }) {
2032
+ const res = await this.data(
2033
+ `/api/orders/${encodeURIComponent(orderNo.trim())}/code`,
2034
+ { method: "POST", body: { contact: contact.trim() } }
2035
+ );
2036
+ return { expiresInMinutes: res?.expires_in_minutes ?? 10 };
2037
+ }
2038
+ /**
2039
+ * Opens an order with the code `requestOrderCode` sent. The token it answers
2040
+ * is kept like an order placed in this browser, so the order page and
2041
+ * `getOrder` read it again without another code.
2042
+ */
2043
+ async getOrderByEmailAndOTP({ orderNo, otp }) {
2044
+ const number = orderNo.trim();
2045
+ const res = await this.data(
2046
+ `/api/orders/${encodeURIComponent(number)}/code/verify`,
2047
+ { method: "POST", body: { code: String(otp).trim() } }
2031
2048
  );
2049
+ rememberOrder({ number: res.order.number, token: res.access_token, cartId: "" });
2050
+ return { data: [toOrder(res.order)] };
2032
2051
  }
2033
2052
  };
2034
2053
  var clean2 = (v) => v && v !== "undefined" && v !== "null" ? v : void 0;
@@ -2165,6 +2184,19 @@ var UserService = class extends BaseService {
2165
2184
  }
2166
2185
  };
2167
2186
  var AuthService = class extends UserService {
2187
+ facts = new StoreFacts(this._fetch);
2188
+ /**
2189
+ * How this store signs customers in: `email_password` or `phone_otp`.
2190
+ * A store whose accounts module says nothing signs in by email.
2191
+ */
2192
+ async loginMethod() {
2193
+ try {
2194
+ const method = (await this.facts.plugins()).get("identity")?.settings?.login_method;
2195
+ return method === "phone_otp" ? "phone_otp" : "email_password";
2196
+ } catch {
2197
+ return "email_password";
2198
+ }
2199
+ }
2168
2200
  async forgotPassword({ email }) {
2169
2201
  return this.account("/x/identity/password-reset", {
2170
2202
  method: "POST",
@@ -2191,11 +2223,21 @@ var AuthService = class extends UserService {
2191
2223
  return { errorCode: err.code ?? "invalid_token", message: err.message };
2192
2224
  }
2193
2225
  }
2194
- async getOtp() {
2195
- throw new NotSupportedError("AuthService", "getOtp", "sign in with an email and password");
2226
+ /** Texts a 4-digit sign-in code to `phone`, which needs its country code. */
2227
+ async getOtp({ phone }) {
2228
+ const res = await this.account("/x/identity/otp", {
2229
+ method: "POST",
2230
+ body: { phone: String(phone ?? "").trim() }
2231
+ });
2232
+ return { expiresInMinutes: res?.expires_in_minutes ?? 10 };
2196
2233
  }
2197
- async verifyOtp() {
2198
- throw new NotSupportedError("AuthService", "verifyOtp", "sign in with an email and password");
2234
+ /** Signs in the account on `phone` with the code it was sent, opening one the first time. */
2235
+ async verifyOtp({ phone, otp }) {
2236
+ const auth = await this.account("/x/identity/otp/verify", {
2237
+ method: "POST",
2238
+ body: { phone: String(phone ?? "").trim(), code: String(otp ?? "").trim() }
2239
+ });
2240
+ return this.signedIn(auth);
2199
2241
  }
2200
2242
  async joinAsAdmin() {
2201
2243
  throw new NotSupportedError("AuthService", "joinAsAdmin", "operators are invited from the admin panel");
@@ -2550,7 +2592,11 @@ var StoreService = class extends BaseService {
2550
2592
  ...flag(plugins.has("product-reviews"))
2551
2593
  }
2552
2594
  },
2553
- ...menus?.length ? { menu: menus } : {}
2595
+ ...menus?.length ? { menu: menus } : {},
2596
+ // The one way this store signs customers in (D116), which the sign-in
2597
+ // form reads as PHONE or EMAIL. Without the accounts module the static
2598
+ // record says.
2599
+ ...plugins.has("identity") ? { loginType: plugins.get("identity")?.settings?.login_method === "phone_otp" ? "PHONE" : "EMAIL" } : {}
2554
2600
  };
2555
2601
  }
2556
2602
  };