@misiki/gocommerce-connector 0.4.9 → 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.
package/README.md CHANGED
@@ -129,6 +129,7 @@ down stays best-effort: the storefront renders from its static record.
129
129
  | reviews | `/x/reviews` |
130
130
  | content pages (`/p/…`, legal pages) | `/x/cms/pages` |
131
131
  | FAQ | `/x/faq` |
132
+ | composed home page | `/x/layouts/home` (`?preview=` for a draft) — `layoutService.getHomeLayout()`, null when the store has none |
132
133
  | menus | `/x/navigation/menus/{header,footer}`, laid over `store.menu`; any menu by handle |
133
134
  | product specs table | the product's category attribute answers |
134
135
  | attribute filters (`?attributes.color=Red`) | `/api/products?attr=color:Red` |
@@ -5619,6 +5619,40 @@ declare class FaqService extends BaseService {
5619
5619
  declare const pageService: PageService;
5620
5620
  declare const faqService: FaqService;
5621
5621
 
5622
+ /**
5623
+ * One section of a composed page. `settings` is the merchant's, as validated
5624
+ * by the engine: plain text (never HTML) and links that are `/path` or
5625
+ * `http(s)://`. A product grid also carries its products, resolved live and
5626
+ * mapped like any other product the storefront renders.
5627
+ */
5628
+ type HomeLayoutSection = {
5629
+ id: string;
5630
+ type: string;
5631
+ settings: Record<string, unknown>;
5632
+ products?: StorefrontProduct[];
5633
+ };
5634
+ type HomeLayout = {
5635
+ page: string;
5636
+ theme: string;
5637
+ /** The published revision this is; absent on a preview. */
5638
+ revision?: number;
5639
+ /** True when this is the saved draft shown through a preview key. */
5640
+ preview: boolean;
5641
+ sections: HomeLayoutSection[];
5642
+ };
5643
+ /**
5644
+ * Composed pages from ext/layouts. A store without one — the plugin off,
5645
+ * nothing published, an engine built without the module, or a preview key
5646
+ * that is wrong or expired — answers null, and the storefront renders its
5647
+ * built-in page.
5648
+ */
5649
+ declare class LayoutService extends BaseService {
5650
+ getHomeLayout({ preview }?: {
5651
+ preview?: string | null;
5652
+ }): Promise<HomeLayout | null>;
5653
+ }
5654
+ declare const layoutService: LayoutService;
5655
+
5622
5656
  /** The marketplace's sellers: approved vendors only. */
5623
5657
  declare class VendorService extends BaseService {
5624
5658
  list({ page, limit, q, search, }?: {
@@ -6759,4 +6793,4 @@ declare class B2bService extends BaseService {
6759
6793
  }
6760
6794
  declare const b2bService: B2bService;
6761
6795
 
6762
- export { type Menu as $, type Address as A, type B2bPlaced as B, type Cart as C, CountryService as D, CouponService as E, type Credentials as F, type Credit as G, CurrencyService as H, type Customer as I, DealService as J, DemoRequestService as K, type EngineRequest as L, EnquiryService as M, type Envelope as N, type Faq as O, FaqService as P, FeedbackService as Q, type Fulfillment as R, GalleryService as S, HomeService as T, type IdentityAddress as U, InitService as V, type Invitation as W, type Lead as X, type ListMeta as Y, MeilisearchService as Z, type Member as _, AddressService as a, collectionService as a$, type MenuItem as a0, MenuService as a1, type MenuSummary as a2, type Money as a3, NewsletterService as a4, type Offer as a5, type Order as a6, type OrderLine as a7, OrderService as a8, PageService as a9, type StorefrontCategory as aA, type StorefrontMenu as aB, type StorefrontOrder as aC, type StorefrontProduct as aD, UploadService as aE, UserService as aF, type Variant as aG, type VariantImage as aH, VariantService as aI, VarniCustomDesignService as aJ, VarniCustomProductService as aK, type Vendor as aL, VendorService as aM, WarrantyService as aN, type Wishlist as aO, type WishlistItem as aP, WishlistService as aQ, addressService as aR, authService as aS, autocompleteService as aT, b2bService as aU, bannerService as aV, blogService as aW, cartService as aX, categoryService as aY, chatService as aZ, checkoutService as a_, type PaymentIntent as aa, PaymentMethodService as ab, type Plugin as ac, PluginService as ad, PopularSearchService as ae, PopularityService as af, type Product as ag, type ProductOption as ah, ProductService as ai, ProfileService as aj, type Quote as ak, REDIRECT_GATEWAYS as al, ReelsService as am, RegionService as an, type RejectedLine as ao, type Review as ap, type ReviewPage as aq, ReviewService as ar, type SearchDoc as as, type SearchResult as at, SearchService as au, SettingService as av, type ShippingRate as aw, StateService as ax, type StoreProfile as ay, StoreService as az, type AppliedDiscount as b, uploadService as b$, contactService as b0, countryService as b1, couponService as b2, currencyExponent as b3, currencyService as b4, dealService as b5, demoRequestService as b6, emptyCart as b7, emptyPage as b8, enquiryService as b9, reelsService as bA, regionService as bB, reviewService as bC, searchService as bD, setRequestHost as bE, settingService as bF, settingsService as bG, stateService as bH, staticStore as bI, storeForHost as bJ, storeService as bK, toCart as bL, toCartLine as bM, toCategory as bN, toCmsPage as bO, toCollection as bP, toEngineAddress as bQ, toIdentityAddress as bR, toMajor as bS, toMinor as bT, toOrder as bU, toPage as bV, toProduct as bW, toRating as bX, toUser as bY, toVariant as bZ, toVendor as b_, faqService as ba, feedbackService as bb, fromEngineAddress as bc, fromIdentityAddress as bd, fromSearchDoc as be, galleryService as bf, homeService as bg, initService as bh, mediaUrl as bi, meilisearchService as bj, menuService as bk, minorToMajor as bl, newsletterService as bm, orderService as bn, ownDomain as bo, pageService as bp, paymentMethodService as bq, pluginService as br, pluginsService as bs, popularSearchService as bt, popularityService as bu, priceOf as bv, productImages as bw, productService as bx, profileService as by, qs as bz, type Approval as c, userService as c0, variantService as c1, varniCustomDesignService as c2, varniCustomProductService as c3, vendorService as c4, warrantyService as c5, wishlistService as c6, type AuthResponse as d, AuthService as e, AutocompleteService as f, type B2bRole as g, B2bService as h, BannerService as i, BaseService as j, BlogService as k, type CartLine as l, CartService as m, CatalogService as n, type Category as o, CategoryService as p, ChatService as q, type CheckoutOptions as r, type CheckoutResult as s, CheckoutService as t, type CmsPage as u, type Collection as v, CollectionService as w, type Company as x, type CompanyOrder as y, ContactService as z };
6796
+ export { type ListMeta as $, type Address as A, type B2bPlaced as B, type Cart as C, CountryService as D, CouponService as E, type Credentials as F, type Credit as G, CurrencyService as H, type Customer as I, DealService as J, DemoRequestService as K, type EngineRequest as L, EnquiryService as M, type Envelope as N, type Faq as O, FaqService as P, FeedbackService as Q, type Fulfillment as R, GalleryService as S, type HomeLayout as T, type HomeLayoutSection as U, HomeService as V, type IdentityAddress as W, InitService as X, type Invitation as Y, LayoutService as Z, type Lead as _, AddressService as a, categoryService as a$, MeilisearchService as a0, type Member as a1, type Menu as a2, type MenuItem as a3, MenuService as a4, type MenuSummary as a5, type Money as a6, NewsletterService as a7, type Offer as a8, type Order as a9, StateService as aA, type StoreProfile as aB, StoreService as aC, type StorefrontCategory as aD, type StorefrontMenu as aE, type StorefrontOrder as aF, type StorefrontProduct as aG, UploadService as aH, UserService as aI, type Variant as aJ, type VariantImage as aK, VariantService as aL, VarniCustomDesignService as aM, VarniCustomProductService as aN, type Vendor as aO, VendorService as aP, WarrantyService as aQ, type Wishlist as aR, type WishlistItem as aS, WishlistService as aT, addressService as aU, authService as aV, autocompleteService as aW, b2bService as aX, bannerService as aY, blogService as aZ, cartService as a_, type OrderLine as aa, OrderService as ab, PageService as ac, type PaymentIntent as ad, PaymentMethodService as ae, type Plugin as af, PluginService as ag, PopularSearchService as ah, PopularityService as ai, type Product as aj, type ProductOption as ak, ProductService as al, ProfileService as am, type Quote as an, REDIRECT_GATEWAYS as ao, ReelsService as ap, RegionService as aq, type RejectedLine as ar, type Review as as, type ReviewPage as at, ReviewService as au, type SearchDoc as av, type SearchResult as aw, SearchService as ax, SettingService as ay, type ShippingRate as az, type AppliedDiscount as b, toRating as b$, chatService as b0, checkoutService as b1, collectionService as b2, contactService as b3, countryService as b4, couponService as b5, currencyExponent as b6, currencyService as b7, dealService as b8, demoRequestService as b9, productImages as bA, productService as bB, profileService as bC, qs as bD, reelsService as bE, regionService as bF, reviewService as bG, searchService as bH, setRequestHost as bI, settingService as bJ, settingsService as bK, stateService as bL, staticStore as bM, storeForHost as bN, storeService as bO, toCart as bP, toCartLine as bQ, toCategory as bR, toCmsPage as bS, toCollection as bT, toEngineAddress as bU, toIdentityAddress as bV, toMajor as bW, toMinor as bX, toOrder as bY, toPage as bZ, toProduct as b_, emptyCart as ba, emptyPage as bb, enquiryService as bc, faqService as bd, feedbackService as be, fromEngineAddress as bf, fromIdentityAddress as bg, fromSearchDoc as bh, galleryService as bi, homeService as bj, initService as bk, layoutService as bl, mediaUrl as bm, meilisearchService as bn, menuService as bo, minorToMajor as bp, newsletterService as bq, orderService as br, ownDomain as bs, pageService as bt, paymentMethodService as bu, pluginService as bv, pluginsService as bw, popularSearchService as bx, popularityService as by, priceOf as bz, type Approval as c, toUser as c0, toVariant as c1, toVendor as c2, uploadService as c3, userService as c4, variantService as c5, varniCustomDesignService as c6, varniCustomProductService as c7, vendorService as c8, warrantyService as c9, wishlistService as ca, type AuthResponse as d, AuthService as e, AutocompleteService as f, type B2bRole as g, B2bService as h, BannerService as i, BaseService as j, BlogService as k, type CartLine as l, CartService as m, CatalogService as n, type Category as o, CategoryService as p, ChatService as q, type CheckoutOptions as r, type CheckoutResult as s, CheckoutService as t, type CmsPage as u, type Collection as v, CollectionService as w, type Company as x, type CompanyOrder as y, ContactService as z };
@@ -5619,6 +5619,40 @@ declare class FaqService extends BaseService {
5619
5619
  declare const pageService: PageService;
5620
5620
  declare const faqService: FaqService;
5621
5621
 
5622
+ /**
5623
+ * One section of a composed page. `settings` is the merchant's, as validated
5624
+ * by the engine: plain text (never HTML) and links that are `/path` or
5625
+ * `http(s)://`. A product grid also carries its products, resolved live and
5626
+ * mapped like any other product the storefront renders.
5627
+ */
5628
+ type HomeLayoutSection = {
5629
+ id: string;
5630
+ type: string;
5631
+ settings: Record<string, unknown>;
5632
+ products?: StorefrontProduct[];
5633
+ };
5634
+ type HomeLayout = {
5635
+ page: string;
5636
+ theme: string;
5637
+ /** The published revision this is; absent on a preview. */
5638
+ revision?: number;
5639
+ /** True when this is the saved draft shown through a preview key. */
5640
+ preview: boolean;
5641
+ sections: HomeLayoutSection[];
5642
+ };
5643
+ /**
5644
+ * Composed pages from ext/layouts. A store without one — the plugin off,
5645
+ * nothing published, an engine built without the module, or a preview key
5646
+ * that is wrong or expired — answers null, and the storefront renders its
5647
+ * built-in page.
5648
+ */
5649
+ declare class LayoutService extends BaseService {
5650
+ getHomeLayout({ preview }?: {
5651
+ preview?: string | null;
5652
+ }): Promise<HomeLayout | null>;
5653
+ }
5654
+ declare const layoutService: LayoutService;
5655
+
5622
5656
  /** The marketplace's sellers: approved vendors only. */
5623
5657
  declare class VendorService extends BaseService {
5624
5658
  list({ page, limit, q, search, }?: {
@@ -6759,4 +6793,4 @@ declare class B2bService extends BaseService {
6759
6793
  }
6760
6794
  declare const b2bService: B2bService;
6761
6795
 
6762
- export { type Menu as $, type Address as A, type B2bPlaced as B, type Cart as C, CountryService as D, CouponService as E, type Credentials as F, type Credit as G, CurrencyService as H, type Customer as I, DealService as J, DemoRequestService as K, type EngineRequest as L, EnquiryService as M, type Envelope as N, type Faq as O, FaqService as P, FeedbackService as Q, type Fulfillment as R, GalleryService as S, HomeService as T, type IdentityAddress as U, InitService as V, type Invitation as W, type Lead as X, type ListMeta as Y, MeilisearchService as Z, type Member as _, AddressService as a, collectionService as a$, type MenuItem as a0, MenuService as a1, type MenuSummary as a2, type Money as a3, NewsletterService as a4, type Offer as a5, type Order as a6, type OrderLine as a7, OrderService as a8, PageService as a9, type StorefrontCategory as aA, type StorefrontMenu as aB, type StorefrontOrder as aC, type StorefrontProduct as aD, UploadService as aE, UserService as aF, type Variant as aG, type VariantImage as aH, VariantService as aI, VarniCustomDesignService as aJ, VarniCustomProductService as aK, type Vendor as aL, VendorService as aM, WarrantyService as aN, type Wishlist as aO, type WishlistItem as aP, WishlistService as aQ, addressService as aR, authService as aS, autocompleteService as aT, b2bService as aU, bannerService as aV, blogService as aW, cartService as aX, categoryService as aY, chatService as aZ, checkoutService as a_, type PaymentIntent as aa, PaymentMethodService as ab, type Plugin as ac, PluginService as ad, PopularSearchService as ae, PopularityService as af, type Product as ag, type ProductOption as ah, ProductService as ai, ProfileService as aj, type Quote as ak, REDIRECT_GATEWAYS as al, ReelsService as am, RegionService as an, type RejectedLine as ao, type Review as ap, type ReviewPage as aq, ReviewService as ar, type SearchDoc as as, type SearchResult as at, SearchService as au, SettingService as av, type ShippingRate as aw, StateService as ax, type StoreProfile as ay, StoreService as az, type AppliedDiscount as b, uploadService as b$, contactService as b0, countryService as b1, couponService as b2, currencyExponent as b3, currencyService as b4, dealService as b5, demoRequestService as b6, emptyCart as b7, emptyPage as b8, enquiryService as b9, reelsService as bA, regionService as bB, reviewService as bC, searchService as bD, setRequestHost as bE, settingService as bF, settingsService as bG, stateService as bH, staticStore as bI, storeForHost as bJ, storeService as bK, toCart as bL, toCartLine as bM, toCategory as bN, toCmsPage as bO, toCollection as bP, toEngineAddress as bQ, toIdentityAddress as bR, toMajor as bS, toMinor as bT, toOrder as bU, toPage as bV, toProduct as bW, toRating as bX, toUser as bY, toVariant as bZ, toVendor as b_, faqService as ba, feedbackService as bb, fromEngineAddress as bc, fromIdentityAddress as bd, fromSearchDoc as be, galleryService as bf, homeService as bg, initService as bh, mediaUrl as bi, meilisearchService as bj, menuService as bk, minorToMajor as bl, newsletterService as bm, orderService as bn, ownDomain as bo, pageService as bp, paymentMethodService as bq, pluginService as br, pluginsService as bs, popularSearchService as bt, popularityService as bu, priceOf as bv, productImages as bw, productService as bx, profileService as by, qs as bz, type Approval as c, userService as c0, variantService as c1, varniCustomDesignService as c2, varniCustomProductService as c3, vendorService as c4, warrantyService as c5, wishlistService as c6, type AuthResponse as d, AuthService as e, AutocompleteService as f, type B2bRole as g, B2bService as h, BannerService as i, BaseService as j, BlogService as k, type CartLine as l, CartService as m, CatalogService as n, type Category as o, CategoryService as p, ChatService as q, type CheckoutOptions as r, type CheckoutResult as s, CheckoutService as t, type CmsPage as u, type Collection as v, CollectionService as w, type Company as x, type CompanyOrder as y, ContactService as z };
6796
+ export { type ListMeta as $, type Address as A, type B2bPlaced as B, type Cart as C, CountryService as D, CouponService as E, type Credentials as F, type Credit as G, CurrencyService as H, type Customer as I, DealService as J, DemoRequestService as K, type EngineRequest as L, EnquiryService as M, type Envelope as N, type Faq as O, FaqService as P, FeedbackService as Q, type Fulfillment as R, GalleryService as S, type HomeLayout as T, type HomeLayoutSection as U, HomeService as V, type IdentityAddress as W, InitService as X, type Invitation as Y, LayoutService as Z, type Lead as _, AddressService as a, categoryService as a$, MeilisearchService as a0, type Member as a1, type Menu as a2, type MenuItem as a3, MenuService as a4, type MenuSummary as a5, type Money as a6, NewsletterService as a7, type Offer as a8, type Order as a9, StateService as aA, type StoreProfile as aB, StoreService as aC, type StorefrontCategory as aD, type StorefrontMenu as aE, type StorefrontOrder as aF, type StorefrontProduct as aG, UploadService as aH, UserService as aI, type Variant as aJ, type VariantImage as aK, VariantService as aL, VarniCustomDesignService as aM, VarniCustomProductService as aN, type Vendor as aO, VendorService as aP, WarrantyService as aQ, type Wishlist as aR, type WishlistItem as aS, WishlistService as aT, addressService as aU, authService as aV, autocompleteService as aW, b2bService as aX, bannerService as aY, blogService as aZ, cartService as a_, type OrderLine as aa, OrderService as ab, PageService as ac, type PaymentIntent as ad, PaymentMethodService as ae, type Plugin as af, PluginService as ag, PopularSearchService as ah, PopularityService as ai, type Product as aj, type ProductOption as ak, ProductService as al, ProfileService as am, type Quote as an, REDIRECT_GATEWAYS as ao, ReelsService as ap, RegionService as aq, type RejectedLine as ar, type Review as as, type ReviewPage as at, ReviewService as au, type SearchDoc as av, type SearchResult as aw, SearchService as ax, SettingService as ay, type ShippingRate as az, type AppliedDiscount as b, toRating as b$, chatService as b0, checkoutService as b1, collectionService as b2, contactService as b3, countryService as b4, couponService as b5, currencyExponent as b6, currencyService as b7, dealService as b8, demoRequestService as b9, productImages as bA, productService as bB, profileService as bC, qs as bD, reelsService as bE, regionService as bF, reviewService as bG, searchService as bH, setRequestHost as bI, settingService as bJ, settingsService as bK, stateService as bL, staticStore as bM, storeForHost as bN, storeService as bO, toCart as bP, toCartLine as bQ, toCategory as bR, toCmsPage as bS, toCollection as bT, toEngineAddress as bU, toIdentityAddress as bV, toMajor as bW, toMinor as bX, toOrder as bY, toPage as bZ, toProduct as b_, emptyCart as ba, emptyPage as bb, enquiryService as bc, faqService as bd, feedbackService as be, fromEngineAddress as bf, fromIdentityAddress as bg, fromSearchDoc as bh, galleryService as bi, homeService as bj, initService as bk, layoutService as bl, mediaUrl as bm, meilisearchService as bn, menuService as bo, minorToMajor as bp, newsletterService as bq, orderService as br, ownDomain as bs, pageService as bt, paymentMethodService as bu, pluginService as bv, pluginsService as bw, popularSearchService as bx, popularityService as by, priceOf as bz, type Approval as c, toUser as c0, toVariant as c1, toVendor as c2, uploadService as c3, userService as c4, variantService as c5, varniCustomDesignService as c6, varniCustomProductService as c7, vendorService as c8, warrantyService as c9, wishlistService as ca, type AuthResponse as d, AuthService as e, AutocompleteService as f, type B2bRole as g, B2bService as h, BannerService as i, BaseService as j, BlogService as k, type CartLine as l, CartService as m, CatalogService as n, type Category as o, CategoryService as p, ChatService as q, type CheckoutOptions as r, type CheckoutResult as s, CheckoutService as t, type CmsPage as u, type Collection as v, CollectionService as w, type Company as x, type CompanyOrder as y, ContactService as z };
package/dist/index.cjs CHANGED
@@ -2732,6 +2732,40 @@ var FaqService = class extends BaseService {
2732
2732
  var pageService = new PageService();
2733
2733
  var faqService = new FaqService();
2734
2734
 
2735
+ // src/services/layout-service.ts
2736
+ var IMAGE_KEYS = ["image", "mobile_image"];
2737
+ var LayoutService = class extends BaseService {
2738
+ async getHomeLayout({ preview } = {}) {
2739
+ let layout;
2740
+ try {
2741
+ layout = await this.data("/x/layouts/home", {
2742
+ query: { preview: preview?.trim() || void 0 }
2743
+ });
2744
+ } catch (err) {
2745
+ if (err instanceof GoCommerceError && err.status === 404) return null;
2746
+ throw err;
2747
+ }
2748
+ if (!layout) return null;
2749
+ return {
2750
+ page: layout.page,
2751
+ theme: layout.theme,
2752
+ revision: layout.revision,
2753
+ preview: !!layout.preview,
2754
+ sections: (layout.sections ?? []).map(toSection)
2755
+ };
2756
+ }
2757
+ };
2758
+ function toSection(s) {
2759
+ const settings = { ...s.settings ?? {} };
2760
+ for (const key of IMAGE_KEYS) {
2761
+ if (typeof settings[key] === "string") settings[key] = mediaUrl(settings[key]);
2762
+ }
2763
+ const out = { id: s.id, type: s.type, settings };
2764
+ if (s.type === "product-grid") out.products = (s.products ?? []).map((p) => toProduct(p));
2765
+ return out;
2766
+ }
2767
+ var layoutService = new LayoutService();
2768
+
2735
2769
  // src/services/vendor-service.ts
2736
2770
  var VendorService = class extends BaseService {
2737
2771
  async list({
@@ -3291,6 +3325,7 @@ exports.GalleryService = GalleryService;
3291
3325
  exports.GoCommerceError = GoCommerceError;
3292
3326
  exports.HomeService = HomeService;
3293
3327
  exports.InitService = InitService;
3328
+ exports.LayoutService = LayoutService;
3294
3329
  exports.MeilisearchService = MeilisearchService;
3295
3330
  exports.MenuService = MenuService;
3296
3331
  exports.NewsletterService = NewsletterService;
@@ -3353,6 +3388,7 @@ exports.galleryService = galleryService;
3353
3388
  exports.hasStaticStore = hasStaticStore;
3354
3389
  exports.homeService = homeService;
3355
3390
  exports.initService = initService;
3391
+ exports.layoutService = layoutService;
3356
3392
  exports.mediaUrl = mediaUrl;
3357
3393
  exports.meilisearchService = meilisearchService;
3358
3394
  exports.menuService = menuService;