@misiki/gocommerce-connector 0.4.8 → 0.6.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.
@@ -2247,11 +2247,16 @@ var AuthService = class extends UserService {
2247
2247
  return { errorCode: err.code ?? "invalid_token", message: err.message };
2248
2248
  }
2249
2249
  }
2250
- /** Texts a 4-digit sign-in code to `phone`, which needs its country code. */
2251
- async getOtp({ phone }) {
2250
+ /**
2251
+ * Texts a 4-digit sign-in code to `phone`, which needs its country code. `domain`, the page's
2252
+ * host and in the browser read from it, lets the engine end the text "@domain #code" when the
2253
+ * host is the store's own, which Chrome on Android reads to fill the code in (D124).
2254
+ */
2255
+ async getOtp({ phone, domain }) {
2256
+ const site = domain ?? (typeof window !== "undefined" ? window.location?.hostname : void 0);
2252
2257
  const res = await this.account("/x/identity/otp", {
2253
2258
  method: "POST",
2254
- body: { phone: String(phone ?? "").trim() }
2259
+ body: { phone: String(phone ?? "").trim(), ...site ? { domain: site } : {} }
2255
2260
  });
2256
2261
  return { expiresInMinutes: res?.expires_in_minutes ?? 10 };
2257
2262
  }
@@ -2711,6 +2716,40 @@ var FaqService = class extends BaseService {
2711
2716
  var pageService = new PageService();
2712
2717
  var faqService = new FaqService();
2713
2718
 
2719
+ // src/services/layout-service.ts
2720
+ var IMAGE_KEYS = ["image", "mobile_image"];
2721
+ var LayoutService = class extends BaseService {
2722
+ async getHomeLayout({ preview } = {}) {
2723
+ let layout;
2724
+ try {
2725
+ layout = await this.data("/x/layouts/home", {
2726
+ query: { preview: preview?.trim() || void 0 }
2727
+ });
2728
+ } catch (err) {
2729
+ if (err instanceof GoCommerceError && err.status === 404) return null;
2730
+ throw err;
2731
+ }
2732
+ if (!layout) return null;
2733
+ return {
2734
+ page: layout.page,
2735
+ theme: layout.theme,
2736
+ revision: layout.revision,
2737
+ preview: !!layout.preview,
2738
+ sections: (layout.sections ?? []).map(toSection)
2739
+ };
2740
+ }
2741
+ };
2742
+ function toSection(s) {
2743
+ const settings = { ...s.settings ?? {} };
2744
+ for (const key of IMAGE_KEYS) {
2745
+ if (typeof settings[key] === "string") settings[key] = mediaUrl(settings[key]);
2746
+ }
2747
+ const out = { id: s.id, type: s.type, settings };
2748
+ if (s.type === "product-grid") out.products = (s.products ?? []).map((p) => toProduct(p));
2749
+ return out;
2750
+ }
2751
+ var layoutService = new LayoutService();
2752
+
2714
2753
  // src/services/vendor-service.ts
2715
2754
  var VendorService = class extends BaseService {
2716
2755
  async list({
@@ -3269,6 +3308,7 @@ exports.FeedbackService = FeedbackService;
3269
3308
  exports.GalleryService = GalleryService;
3270
3309
  exports.HomeService = HomeService;
3271
3310
  exports.InitService = InitService;
3311
+ exports.LayoutService = LayoutService;
3272
3312
  exports.MeilisearchService = MeilisearchService;
3273
3313
  exports.MenuService = MenuService;
3274
3314
  exports.NewsletterService = NewsletterService;
@@ -3322,6 +3362,7 @@ exports.feedbackService = feedbackService;
3322
3362
  exports.galleryService = galleryService;
3323
3363
  exports.homeService = homeService;
3324
3364
  exports.initService = initService;
3365
+ exports.layoutService = layoutService;
3325
3366
  exports.mediaUrl = mediaUrl;
3326
3367
  exports.meilisearchService = meilisearchService;
3327
3368
  exports.menuService = menuService;