@misiki/gocommerce-connector 0.7.0 → 0.9.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 +19 -8
- package/dist/{index-D-hnd6-D.d.cts → index-72kQMxjZ.d.cts} +63 -2
- package/dist/{index-D-hnd6-D.d.ts → index-72kQMxjZ.d.ts} +63 -2
- package/dist/index.cjs +58 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +58 -6
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +58 -6
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.d.cts +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +58 -6
- package/dist/services/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -36,10 +36,11 @@ engine's routes start with `/api` too.
|
|
|
36
36
|
|
|
37
37
|
### The engine
|
|
38
38
|
|
|
39
|
-
Start it with the modules the storefront has screens for
|
|
39
|
+
Start it with the modules the storefront has screens for. The flags go before
|
|
40
|
+
`serve`; the engine ignores any that come after it.
|
|
40
41
|
|
|
41
42
|
```bash
|
|
42
|
-
gocommerce
|
|
43
|
+
gocommerce -identity -wishlist -reviews -cms -faq -menus serve
|
|
43
44
|
```
|
|
44
45
|
|
|
45
46
|
Each is optional. Without `-identity` there is no sign-in (guest checkout
|
|
@@ -50,11 +51,19 @@ business buyers (see "Beyond the storefront's screens").
|
|
|
50
51
|
|
|
51
52
|
### The browser and CORS
|
|
52
53
|
|
|
53
|
-
The engine sends
|
|
54
|
-
|
|
55
|
-
the
|
|
54
|
+
The engine sends CORS headers only to the origins listed in
|
|
55
|
+
`GOCOMMERCE_CORS_ORIGINS` (comma-separated, or `*` for any). Unset, a browser on
|
|
56
|
+
the storefront's origin cannot read a response from the engine's. Server-side
|
|
57
|
+
rendering is unaffected; it is the bag, sign-in and checkout — which run in the
|
|
58
|
+
browser — that need a route.
|
|
56
59
|
|
|
57
|
-
|
|
60
|
+
The simplest is to list the storefront's origin when starting the engine,
|
|
61
|
+
`GOCOMMERCE_CORS_ORIGINS=https://shop.example`, and leave
|
|
62
|
+
`PUBLIC_GOCOMMERCE_PROXY_PATH` unset. The browser then calls
|
|
63
|
+
`PUBLIC_GOCOMMERCE_API_URL` directly, so that has to be an address the
|
|
64
|
+
shopper's browser can reach.
|
|
65
|
+
|
|
66
|
+
Or proxy a path on the storefront's own origin to the engine and name it in
|
|
58
67
|
`PUBLIC_GOCOMMERCE_PROXY_PATH`. The browser then calls
|
|
59
68
|
`https://shop.example/gocommerce/api/carts`, and the server keeps calling
|
|
60
69
|
`PUBLIC_GOCOMMERCE_API_URL` directly. With Caddy:
|
|
@@ -129,7 +138,9 @@ down stays best-effort: the storefront renders from its static record.
|
|
|
129
138
|
| reviews | `/x/reviews` |
|
|
130
139
|
| content pages (`/p/…`, legal pages) | `/x/cms/pages` |
|
|
131
140
|
| FAQ | `/x/faq` |
|
|
132
|
-
| composed home page | `/x/layouts/home` (`?preview=` for a draft) — `layoutService.getHomeLayout()`, null when the store has none |
|
|
141
|
+
| composed home page | `/x/layouts/home` (`?preview=` for a draft) — `layoutService.getHomeLayout()`, null when the store has none; carries `themeSettings` and each collection list's `collections` |
|
|
142
|
+
| product and collection templates | `/x/layouts/product`, `/x/layouts/collection` (`?preview=` for a draft) — `layoutService.getProductLayout()` and `getCollectionLayout()`, the sections the shop arranged around the page's core (`main-product`, `main-collection`); null when none is published, and the page draws as before |
|
|
143
|
+
| theme settings | `/x/layouts/theme` (`?preview=` for a draft) — `layoutService.getThemeSettings()`, the store's colours, fonts and rounding for every page; null when there are none |
|
|
133
144
|
| menus | `/x/navigation/menus/{header,footer}`, laid over `store.menu`; any menu by handle |
|
|
134
145
|
| product specs table | the product's category attribute answers |
|
|
135
146
|
| attribute filters (`?attributes.color=Red`) | `/api/products?attr=color:Red` |
|
|
@@ -248,7 +259,7 @@ real one, seeding what they need through the admin API under names unique to
|
|
|
248
259
|
the run:
|
|
249
260
|
|
|
250
261
|
```bash
|
|
251
|
-
gocommerce
|
|
262
|
+
gocommerce -admin-token dev-token -identity -wishlist -reviews -cms -faq -menus -newsletter -contact -b2b serve
|
|
252
263
|
GOCOMMERCE_URL=http://127.0.0.1:8080 GOCOMMERCE_ADMIN_TOKEN=dev-token \
|
|
253
264
|
GOCOMMERCE_TEST_DB=postgres://…/the-stores-database npm test
|
|
254
265
|
```
|
|
@@ -5832,18 +5832,43 @@ declare class FaqService extends BaseService {
|
|
|
5832
5832
|
declare const pageService: PageService;
|
|
5833
5833
|
declare const faqService: FaqService;
|
|
5834
5834
|
|
|
5835
|
+
/**
|
|
5836
|
+
* The store's design tokens (ext/layouts, D127). Every key is optional and
|
|
5837
|
+
* an absent one means the storefront keeps its own look: colours are
|
|
5838
|
+
* `#rrggbb`, fonts are keys of the storefront's font list, `radius` is
|
|
5839
|
+
* none, small, medium or large.
|
|
5840
|
+
*/
|
|
5841
|
+
type ThemeSettings = Partial<Record<'background' | 'text' | 'accent' | 'accent_text' | 'muted' | 'heading_font' | 'body_font' | 'radius', string>>;
|
|
5842
|
+
/** A collection list's card: enough to draw a picture and a title and link to it. */
|
|
5843
|
+
type LayoutCollection = {
|
|
5844
|
+
id: string;
|
|
5845
|
+
title: string;
|
|
5846
|
+
slug: string;
|
|
5847
|
+
link: string;
|
|
5848
|
+
image: string | null;
|
|
5849
|
+
};
|
|
5835
5850
|
/**
|
|
5836
5851
|
* One section of a composed page. `settings` is the merchant's, as validated
|
|
5837
5852
|
* by the engine: plain text (never HTML) and links that are `/path` or
|
|
5838
5853
|
* `http(s)://`. A product grid also carries its products, resolved live and
|
|
5839
|
-
* mapped like any other product the storefront renders
|
|
5854
|
+
* mapped like any other product the storefront renders; a collection list
|
|
5855
|
+
* carries its collections.
|
|
5840
5856
|
*/
|
|
5841
5857
|
type HomeLayoutSection = {
|
|
5842
5858
|
id: string;
|
|
5843
5859
|
type: string;
|
|
5844
5860
|
settings: Record<string, unknown>;
|
|
5845
5861
|
products?: StorefrontProduct[];
|
|
5862
|
+
collections?: LayoutCollection[];
|
|
5846
5863
|
};
|
|
5864
|
+
/**
|
|
5865
|
+
* A page the shop arranges: the home page, or the template every product or
|
|
5866
|
+
* every collection is drawn in (ext/layouts, D128). A template holds its
|
|
5867
|
+
* core once — `main-product` (the catalogue's pictures, price and buy box)
|
|
5868
|
+
* or `main-collection` (the collection's grid) — at the place the shop put
|
|
5869
|
+
* it, and the storefront draws its own core there.
|
|
5870
|
+
*/
|
|
5871
|
+
type LayoutPage = 'home' | 'product' | 'collection';
|
|
5847
5872
|
type HomeLayout = {
|
|
5848
5873
|
page: string;
|
|
5849
5874
|
theme: string;
|
|
@@ -5851,8 +5876,18 @@ type HomeLayout = {
|
|
|
5851
5876
|
revision?: number;
|
|
5852
5877
|
/** True when this is the saved draft shown through a preview key. */
|
|
5853
5878
|
preview: boolean;
|
|
5879
|
+
/** The design tokens published with the page, or null for none. */
|
|
5880
|
+
themeSettings: ThemeSettings | null;
|
|
5854
5881
|
sections: HomeLayoutSection[];
|
|
5855
5882
|
};
|
|
5883
|
+
/** A composed page of any kind; a template's `themeSettings` is always null. */
|
|
5884
|
+
type PageLayout = HomeLayout;
|
|
5885
|
+
/** The design tokens alone, for every page the storefront draws. */
|
|
5886
|
+
type ThemeSettingsResult = {
|
|
5887
|
+
revision?: number;
|
|
5888
|
+
preview: boolean;
|
|
5889
|
+
settings: ThemeSettings;
|
|
5890
|
+
};
|
|
5856
5891
|
/**
|
|
5857
5892
|
* Composed pages from ext/layouts. A store without one — the plugin off,
|
|
5858
5893
|
* nothing published, an engine built without the module, or a preview key
|
|
@@ -5863,6 +5898,32 @@ declare class LayoutService extends BaseService {
|
|
|
5863
5898
|
getHomeLayout({ preview }?: {
|
|
5864
5899
|
preview?: string | null;
|
|
5865
5900
|
}): Promise<HomeLayout | null>;
|
|
5901
|
+
/**
|
|
5902
|
+
* The template every product page is drawn in: the sections around the
|
|
5903
|
+
* product's core (`main-product`). Null when none is published, so the
|
|
5904
|
+
* product page draws exactly as it did before templates existed.
|
|
5905
|
+
*/
|
|
5906
|
+
getProductLayout({ preview }?: {
|
|
5907
|
+
preview?: string | null;
|
|
5908
|
+
}): Promise<PageLayout | null>;
|
|
5909
|
+
/** The template every collection page is drawn in, around its grid (`main-collection`). */
|
|
5910
|
+
getCollectionLayout({ preview }?: {
|
|
5911
|
+
preview?: string | null;
|
|
5912
|
+
}): Promise<PageLayout | null>;
|
|
5913
|
+
/** Any arranged page by its key; null for none, as the three above. */
|
|
5914
|
+
getPageLayout(page: LayoutPage, { preview }?: {
|
|
5915
|
+
preview?: string | null;
|
|
5916
|
+
}): Promise<PageLayout | null>;
|
|
5917
|
+
/**
|
|
5918
|
+
* The store's design tokens, for a page other than the home page: the
|
|
5919
|
+
* published ones, or a preview key's draft. Null when there are none to
|
|
5920
|
+
* apply — nothing published, the editor off, an engine without the
|
|
5921
|
+
* module — and on any failure too: a missing look must never cost the
|
|
5922
|
+
* page.
|
|
5923
|
+
*/
|
|
5924
|
+
getThemeSettings({ preview }?: {
|
|
5925
|
+
preview?: string | null;
|
|
5926
|
+
}): Promise<ThemeSettingsResult | null>;
|
|
5866
5927
|
}
|
|
5867
5928
|
declare const layoutService: LayoutService;
|
|
5868
5929
|
|
|
@@ -7006,4 +7067,4 @@ declare class B2bService extends BaseService {
|
|
|
7006
7067
|
}
|
|
7007
7068
|
declare const b2bService: B2bService;
|
|
7008
7069
|
|
|
7009
|
-
export {
|
|
7070
|
+
export { LayoutService 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, type LayoutCollection as Z, type LayoutPage as _, AddressService as a, autocompleteService as a$, type Lead as a0, type ListMeta as a1, MeilisearchService as a2, type Member as a3, type Menu as a4, type MenuItem as a5, MenuService as a6, type MenuSummary as a7, type Money as a8, NewsletterService as a9, SearchService as aA, SettingService as aB, type ShippingRate as aC, StateService as aD, type StoreProfile as aE, StoreService as aF, type StorefrontCategory as aG, type StorefrontMenu as aH, type StorefrontOrder as aI, type StorefrontProduct as aJ, type ThemeSettings as aK, type ThemeSettingsResult as aL, UploadService as aM, UserService as aN, type Variant as aO, type VariantImage as aP, VariantService as aQ, VarniCustomDesignService as aR, VarniCustomProductService as aS, type Vendor as aT, VendorService as aU, WarrantyService as aV, type Wishlist as aW, type WishlistItem as aX, WishlistService as aY, addressService as aZ, authService as a_, type Offer as aa, type Order as ab, type OrderLine as ac, OrderService as ad, type PageLayout as ae, PageService as af, type PaymentIntent as ag, PaymentMethodService as ah, type Plugin as ai, PluginService as aj, PopularSearchService as ak, PopularityService as al, type Product as am, type ProductOption as an, ProductService as ao, ProfileService as ap, type Quote as aq, REDIRECT_GATEWAYS as ar, ReelsService as as, RegionService as at, type RejectedLine as au, type Review as av, type ReviewPage as aw, ReviewService as ax, type SearchDoc as ay, type SearchResult as az, type AppliedDiscount as b, toMajor as b$, b2bService as b0, bannerService as b1, blogService as b2, cartService as b3, categoryService as b4, chatService as b5, checkoutService as b6, collectionService as b7, contactService as b8, countryService as b9, pluginService as bA, pluginsService as bB, popularSearchService as bC, popularityService as bD, priceOf as bE, productImages as bF, productService as bG, profileService as bH, qs as bI, reelsService as bJ, regionService as bK, reviewService as bL, searchService as bM, setRequestHost as bN, settingService as bO, settingsService as bP, stateService as bQ, staticStore as bR, storeForHost as bS, storeService as bT, toCart as bU, toCartLine as bV, toCategory as bW, toCmsPage as bX, toCollection as bY, toEngineAddress as bZ, toIdentityAddress as b_, couponService as ba, currencyExponent as bb, currencyService as bc, dealService as bd, demoRequestService as be, emptyCart as bf, emptyPage as bg, enquiryService as bh, faqService as bi, feedbackService as bj, fromEngineAddress as bk, fromIdentityAddress as bl, fromSearchDoc as bm, galleryService as bn, homeService as bo, initService as bp, layoutService as bq, mediaUrl as br, meilisearchService as bs, menuService as bt, minorToMajor as bu, newsletterService as bv, orderService as bw, ownDomain as bx, pageService as by, paymentMethodService as bz, type Approval as c, toMinor as c0, toOrder as c1, toPage as c2, toProduct as c3, toRating as c4, toUser as c5, toVariant as c6, toVendor as c7, uploadService as c8, userService as c9, variantService as ca, varniCustomDesignService as cb, varniCustomProductService as cc, vendorService as cd, warrantyService as ce, wishlistService as cf, 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 };
|
|
@@ -5832,18 +5832,43 @@ declare class FaqService extends BaseService {
|
|
|
5832
5832
|
declare const pageService: PageService;
|
|
5833
5833
|
declare const faqService: FaqService;
|
|
5834
5834
|
|
|
5835
|
+
/**
|
|
5836
|
+
* The store's design tokens (ext/layouts, D127). Every key is optional and
|
|
5837
|
+
* an absent one means the storefront keeps its own look: colours are
|
|
5838
|
+
* `#rrggbb`, fonts are keys of the storefront's font list, `radius` is
|
|
5839
|
+
* none, small, medium or large.
|
|
5840
|
+
*/
|
|
5841
|
+
type ThemeSettings = Partial<Record<'background' | 'text' | 'accent' | 'accent_text' | 'muted' | 'heading_font' | 'body_font' | 'radius', string>>;
|
|
5842
|
+
/** A collection list's card: enough to draw a picture and a title and link to it. */
|
|
5843
|
+
type LayoutCollection = {
|
|
5844
|
+
id: string;
|
|
5845
|
+
title: string;
|
|
5846
|
+
slug: string;
|
|
5847
|
+
link: string;
|
|
5848
|
+
image: string | null;
|
|
5849
|
+
};
|
|
5835
5850
|
/**
|
|
5836
5851
|
* One section of a composed page. `settings` is the merchant's, as validated
|
|
5837
5852
|
* by the engine: plain text (never HTML) and links that are `/path` or
|
|
5838
5853
|
* `http(s)://`. A product grid also carries its products, resolved live and
|
|
5839
|
-
* mapped like any other product the storefront renders
|
|
5854
|
+
* mapped like any other product the storefront renders; a collection list
|
|
5855
|
+
* carries its collections.
|
|
5840
5856
|
*/
|
|
5841
5857
|
type HomeLayoutSection = {
|
|
5842
5858
|
id: string;
|
|
5843
5859
|
type: string;
|
|
5844
5860
|
settings: Record<string, unknown>;
|
|
5845
5861
|
products?: StorefrontProduct[];
|
|
5862
|
+
collections?: LayoutCollection[];
|
|
5846
5863
|
};
|
|
5864
|
+
/**
|
|
5865
|
+
* A page the shop arranges: the home page, or the template every product or
|
|
5866
|
+
* every collection is drawn in (ext/layouts, D128). A template holds its
|
|
5867
|
+
* core once — `main-product` (the catalogue's pictures, price and buy box)
|
|
5868
|
+
* or `main-collection` (the collection's grid) — at the place the shop put
|
|
5869
|
+
* it, and the storefront draws its own core there.
|
|
5870
|
+
*/
|
|
5871
|
+
type LayoutPage = 'home' | 'product' | 'collection';
|
|
5847
5872
|
type HomeLayout = {
|
|
5848
5873
|
page: string;
|
|
5849
5874
|
theme: string;
|
|
@@ -5851,8 +5876,18 @@ type HomeLayout = {
|
|
|
5851
5876
|
revision?: number;
|
|
5852
5877
|
/** True when this is the saved draft shown through a preview key. */
|
|
5853
5878
|
preview: boolean;
|
|
5879
|
+
/** The design tokens published with the page, or null for none. */
|
|
5880
|
+
themeSettings: ThemeSettings | null;
|
|
5854
5881
|
sections: HomeLayoutSection[];
|
|
5855
5882
|
};
|
|
5883
|
+
/** A composed page of any kind; a template's `themeSettings` is always null. */
|
|
5884
|
+
type PageLayout = HomeLayout;
|
|
5885
|
+
/** The design tokens alone, for every page the storefront draws. */
|
|
5886
|
+
type ThemeSettingsResult = {
|
|
5887
|
+
revision?: number;
|
|
5888
|
+
preview: boolean;
|
|
5889
|
+
settings: ThemeSettings;
|
|
5890
|
+
};
|
|
5856
5891
|
/**
|
|
5857
5892
|
* Composed pages from ext/layouts. A store without one — the plugin off,
|
|
5858
5893
|
* nothing published, an engine built without the module, or a preview key
|
|
@@ -5863,6 +5898,32 @@ declare class LayoutService extends BaseService {
|
|
|
5863
5898
|
getHomeLayout({ preview }?: {
|
|
5864
5899
|
preview?: string | null;
|
|
5865
5900
|
}): Promise<HomeLayout | null>;
|
|
5901
|
+
/**
|
|
5902
|
+
* The template every product page is drawn in: the sections around the
|
|
5903
|
+
* product's core (`main-product`). Null when none is published, so the
|
|
5904
|
+
* product page draws exactly as it did before templates existed.
|
|
5905
|
+
*/
|
|
5906
|
+
getProductLayout({ preview }?: {
|
|
5907
|
+
preview?: string | null;
|
|
5908
|
+
}): Promise<PageLayout | null>;
|
|
5909
|
+
/** The template every collection page is drawn in, around its grid (`main-collection`). */
|
|
5910
|
+
getCollectionLayout({ preview }?: {
|
|
5911
|
+
preview?: string | null;
|
|
5912
|
+
}): Promise<PageLayout | null>;
|
|
5913
|
+
/** Any arranged page by its key; null for none, as the three above. */
|
|
5914
|
+
getPageLayout(page: LayoutPage, { preview }?: {
|
|
5915
|
+
preview?: string | null;
|
|
5916
|
+
}): Promise<PageLayout | null>;
|
|
5917
|
+
/**
|
|
5918
|
+
* The store's design tokens, for a page other than the home page: the
|
|
5919
|
+
* published ones, or a preview key's draft. Null when there are none to
|
|
5920
|
+
* apply — nothing published, the editor off, an engine without the
|
|
5921
|
+
* module — and on any failure too: a missing look must never cost the
|
|
5922
|
+
* page.
|
|
5923
|
+
*/
|
|
5924
|
+
getThemeSettings({ preview }?: {
|
|
5925
|
+
preview?: string | null;
|
|
5926
|
+
}): Promise<ThemeSettingsResult | null>;
|
|
5866
5927
|
}
|
|
5867
5928
|
declare const layoutService: LayoutService;
|
|
5868
5929
|
|
|
@@ -7006,4 +7067,4 @@ declare class B2bService extends BaseService {
|
|
|
7006
7067
|
}
|
|
7007
7068
|
declare const b2bService: B2bService;
|
|
7008
7069
|
|
|
7009
|
-
export {
|
|
7070
|
+
export { LayoutService 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, type LayoutCollection as Z, type LayoutPage as _, AddressService as a, autocompleteService as a$, type Lead as a0, type ListMeta as a1, MeilisearchService as a2, type Member as a3, type Menu as a4, type MenuItem as a5, MenuService as a6, type MenuSummary as a7, type Money as a8, NewsletterService as a9, SearchService as aA, SettingService as aB, type ShippingRate as aC, StateService as aD, type StoreProfile as aE, StoreService as aF, type StorefrontCategory as aG, type StorefrontMenu as aH, type StorefrontOrder as aI, type StorefrontProduct as aJ, type ThemeSettings as aK, type ThemeSettingsResult as aL, UploadService as aM, UserService as aN, type Variant as aO, type VariantImage as aP, VariantService as aQ, VarniCustomDesignService as aR, VarniCustomProductService as aS, type Vendor as aT, VendorService as aU, WarrantyService as aV, type Wishlist as aW, type WishlistItem as aX, WishlistService as aY, addressService as aZ, authService as a_, type Offer as aa, type Order as ab, type OrderLine as ac, OrderService as ad, type PageLayout as ae, PageService as af, type PaymentIntent as ag, PaymentMethodService as ah, type Plugin as ai, PluginService as aj, PopularSearchService as ak, PopularityService as al, type Product as am, type ProductOption as an, ProductService as ao, ProfileService as ap, type Quote as aq, REDIRECT_GATEWAYS as ar, ReelsService as as, RegionService as at, type RejectedLine as au, type Review as av, type ReviewPage as aw, ReviewService as ax, type SearchDoc as ay, type SearchResult as az, type AppliedDiscount as b, toMajor as b$, b2bService as b0, bannerService as b1, blogService as b2, cartService as b3, categoryService as b4, chatService as b5, checkoutService as b6, collectionService as b7, contactService as b8, countryService as b9, pluginService as bA, pluginsService as bB, popularSearchService as bC, popularityService as bD, priceOf as bE, productImages as bF, productService as bG, profileService as bH, qs as bI, reelsService as bJ, regionService as bK, reviewService as bL, searchService as bM, setRequestHost as bN, settingService as bO, settingsService as bP, stateService as bQ, staticStore as bR, storeForHost as bS, storeService as bT, toCart as bU, toCartLine as bV, toCategory as bW, toCmsPage as bX, toCollection as bY, toEngineAddress as bZ, toIdentityAddress as b_, couponService as ba, currencyExponent as bb, currencyService as bc, dealService as bd, demoRequestService as be, emptyCart as bf, emptyPage as bg, enquiryService as bh, faqService as bi, feedbackService as bj, fromEngineAddress as bk, fromIdentityAddress as bl, fromSearchDoc as bm, galleryService as bn, homeService as bo, initService as bp, layoutService as bq, mediaUrl as br, meilisearchService as bs, menuService as bt, minorToMajor as bu, newsletterService as bv, orderService as bw, ownDomain as bx, pageService as by, paymentMethodService as bz, type Approval as c, toMinor as c0, toOrder as c1, toPage as c2, toProduct as c3, toRating as c4, toUser as c5, toVariant as c6, toVendor as c7, uploadService as c8, userService as c9, variantService as ca, varniCustomDesignService as cb, varniCustomProductService as cc, vendorService as cd, warrantyService as ce, wishlistService as cf, 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
|
@@ -2758,12 +2758,28 @@ var pageService = new PageService();
|
|
|
2758
2758
|
var faqService = new FaqService();
|
|
2759
2759
|
|
|
2760
2760
|
// src/services/layout-service.ts
|
|
2761
|
-
var
|
|
2761
|
+
var MEDIA_KEYS = /* @__PURE__ */ new Set(["image", "mobile_image", "poster", "video_file"]);
|
|
2762
2762
|
var LayoutService = class extends BaseService {
|
|
2763
2763
|
async getHomeLayout({ preview } = {}) {
|
|
2764
|
+
return this.getPageLayout("home", { preview });
|
|
2765
|
+
}
|
|
2766
|
+
/**
|
|
2767
|
+
* The template every product page is drawn in: the sections around the
|
|
2768
|
+
* product's core (`main-product`). Null when none is published, so the
|
|
2769
|
+
* product page draws exactly as it did before templates existed.
|
|
2770
|
+
*/
|
|
2771
|
+
async getProductLayout({ preview } = {}) {
|
|
2772
|
+
return this.getPageLayout("product", { preview });
|
|
2773
|
+
}
|
|
2774
|
+
/** The template every collection page is drawn in, around its grid (`main-collection`). */
|
|
2775
|
+
async getCollectionLayout({ preview } = {}) {
|
|
2776
|
+
return this.getPageLayout("collection", { preview });
|
|
2777
|
+
}
|
|
2778
|
+
/** Any arranged page by its key; null for none, as the three above. */
|
|
2779
|
+
async getPageLayout(page, { preview } = {}) {
|
|
2764
2780
|
let layout;
|
|
2765
2781
|
try {
|
|
2766
|
-
layout = await this.data(
|
|
2782
|
+
layout = await this.data(`/x/layouts/${encodeURIComponent(page)}`, {
|
|
2767
2783
|
query: { preview: preview?.trim() || void 0 }
|
|
2768
2784
|
});
|
|
2769
2785
|
} catch (err) {
|
|
@@ -2776,17 +2792,53 @@ var LayoutService = class extends BaseService {
|
|
|
2776
2792
|
theme: layout.theme,
|
|
2777
2793
|
revision: layout.revision,
|
|
2778
2794
|
preview: !!layout.preview,
|
|
2795
|
+
themeSettings: tokens(layout.theme_settings),
|
|
2779
2796
|
sections: (layout.sections ?? []).map(toSection)
|
|
2780
2797
|
};
|
|
2781
2798
|
}
|
|
2799
|
+
/**
|
|
2800
|
+
* The store's design tokens, for a page other than the home page: the
|
|
2801
|
+
* published ones, or a preview key's draft. Null when there are none to
|
|
2802
|
+
* apply — nothing published, the editor off, an engine without the
|
|
2803
|
+
* module — and on any failure too: a missing look must never cost the
|
|
2804
|
+
* page.
|
|
2805
|
+
*/
|
|
2806
|
+
async getThemeSettings({ preview } = {}) {
|
|
2807
|
+
try {
|
|
2808
|
+
const out = await this.data("/x/layouts/theme", {
|
|
2809
|
+
query: { preview: preview?.trim() || void 0 }
|
|
2810
|
+
});
|
|
2811
|
+
if (!out) return null;
|
|
2812
|
+
return { revision: out.revision, preview: !!out.preview, settings: tokens(out.settings) ?? {} };
|
|
2813
|
+
} catch {
|
|
2814
|
+
return null;
|
|
2815
|
+
}
|
|
2816
|
+
}
|
|
2782
2817
|
};
|
|
2783
|
-
function
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2818
|
+
function tokens(v) {
|
|
2819
|
+
return v && typeof v === "object" && !Array.isArray(v) && Object.keys(v).length ? { ...v } : null;
|
|
2820
|
+
}
|
|
2821
|
+
function withMedia(value, key) {
|
|
2822
|
+
if (Array.isArray(value)) return value.map((x) => withMedia(x, null));
|
|
2823
|
+
if (value && typeof value === "object") {
|
|
2824
|
+
return Object.fromEntries(Object.entries(value).map(([k, x]) => [k, withMedia(x, k)]));
|
|
2787
2825
|
}
|
|
2826
|
+
if (key && MEDIA_KEYS.has(key) && typeof value === "string") return mediaUrl(value);
|
|
2827
|
+
return value;
|
|
2828
|
+
}
|
|
2829
|
+
function toSection(s) {
|
|
2830
|
+
const settings = withMedia(s.settings ?? {}, null);
|
|
2788
2831
|
const out = { id: s.id, type: s.type, settings };
|
|
2789
2832
|
if (s.type === "product-grid") out.products = (s.products ?? []).map((p) => toProduct(p));
|
|
2833
|
+
if (s.type === "collection-list") {
|
|
2834
|
+
out.collections = (s.collections ?? []).map((c) => ({
|
|
2835
|
+
id: String(c.id),
|
|
2836
|
+
title: c.title,
|
|
2837
|
+
slug: c.slug,
|
|
2838
|
+
link: `/collections/${c.slug}`,
|
|
2839
|
+
image: mediaUrl(c.image) ?? null
|
|
2840
|
+
}));
|
|
2841
|
+
}
|
|
2790
2842
|
return out;
|
|
2791
2843
|
}
|
|
2792
2844
|
var layoutService = new LayoutService();
|