@misiki/gocommerce-connector 0.9.1 → 0.11.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/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 HomeLayout, U as HomeLayoutSection, V as HomeService, W as IdentityAddress, X as InitService, Y as Invitation, Z as LayoutCollection, _ as LayoutPage, $ as LayoutService, a0 as Lead, a1 as ListMeta, a2 as MeilisearchService, a3 as Member, a4 as Menu, a5 as MenuItem, a6 as MenuService, a7 as MenuSummary, a8 as Money, a9 as NewsletterService, aa as Offer, ab as Order, ac as OrderLine, ad as OrderService, ae as PageLayout, af as PageService, ag as PaymentIntent, ah as PaymentMethodService, ai as Plugin, aj as PluginService, aj as PluginsService, ak as PopularSearchService, al as PopularityService, am as Product, an as ProductOption, ao as ProductService, ap as ProfileService, aq as Quote, ar as REDIRECT_GATEWAYS, as as ReelsService, at as RegionService, au as RejectedLine, av as Review, aw as ReviewPage, ax as ReviewService, ay as SearchDoc, az as SearchResult, aA as SearchService, aB as SettingService, aB as SettingsService, aC as ShippingRate, aD as StateService, aE as StoreProfile, aF as StoreService, aG as StorefrontCategory, aH as StorefrontMenu, aI as StorefrontOrder, aJ as StorefrontProduct, aK as ThemeSettings, aL as ThemeSettingsResult, aM as UploadService, aN as UserService, aO as Variant, aP as VariantImage, aQ as VariantService, aR as VarniCustomDesignService, aS as VarniCustomProductService, aT as Vendor, aU as VendorService, aV as WarrantyService, aW as Wishlist, aX as WishlistItem, aY as WishlistService, aZ as addressService, a_ as authService, a$ as autocompleteService, b0 as b2bService, b1 as bannerService, b2 as blogService, b3 as cartService, b4 as categoryService, b5 as chatService, b6 as checkoutService, b7 as collectionService, b8 as contactService, b9 as countryService, ba as couponService, bb as currencyExponent, bc as currencyService, bd as dealService, be as demoRequestService, bf as emptyCart, bg as emptyPage, bh as enquiryService, bi as faqService, bj as feedbackService, bk as fromEngineAddress, bl as fromIdentityAddress, bm as fromSearchDoc, bn as galleryService, bo as homeService, bp as initService, bq as layoutService, br as mediaUrl, bs as meilisearchService, bt as menuService, bu as minorToMajor, bv as newsletterService, bw as orderService, bx as ownDomain, by as pageService, bz as paymentMethodService, bA as pluginService, bB as pluginsService, bC as popularSearchService, bD as popularityService, bE as priceOf, bF as productImages, bG as productService, bH as profileService, bI as qs, bJ as reelsService, bK as regionService, bL as reviewService, bM as searchService, bN as setRequestHost, bO as settingService, bP as settingsService, bQ as stateService, bR as staticStore, bS as storeForHost, bT as storeService, bU as toCart, bV as toCartLine, bW as toCategory, bX as toCmsPage, bY as toCollection, bZ as toEngineAddress, b_ as toIdentityAddress, b$ as toMajor, c0 as toMinor, c1 as toOrder, c2 as toPage, c3 as toProduct, c4 as toRating, c5 as toUser, c6 as toVariant, c7 as toVendor, c8 as uploadService, c9 as userService, ca as variantService, cb as varniCustomDesignService, cc as varniCustomProductService, cd as vendorService, ce as warrantyService, cf as wishlistService } from './index-DSvV8FbK.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 FacetValue, P as Faq, Q as FaqService, R as FeedbackService, S as FooterSettings, T as Fulfillment, U as GalleryService, V as HeaderSettings, W as HomeLayout, X as HomeLayoutSection, Y as HomeService, Z as IdentityAddress, _ as InitService, $ as Invitation, a0 as LayoutCollection, a1 as LayoutPage, a2 as LayoutService, a3 as Lead, a4 as ListMeta, a5 as MeilisearchService, a6 as Member, a7 as Menu, a8 as MenuItem, a9 as MenuService, aa as MenuSummary, ab as Money, ac as NewsletterService, ad as Offer, ae as Order, af as OrderLine, ag as OrderService, ah as PageLayout, ai as PageService, aj as PaymentIntent, ak as PaymentMethodService, al as Plugin, am as PluginService, am as PluginsService, an as PopularSearchService, ao as PopularityService, ap as Product, aq as ProductFacets, ar as ProductOption, as as ProductService, at as ProfileService, au as Quote, av as REDIRECT_GATEWAYS, aw as ReelsService, ax as RegionService, ay as RejectedLine, az as Review, aA as ReviewPage, aB as ReviewService, aC as SearchDoc, aD as SearchResult, aE as SearchService, aF as SettingService, aF as SettingsService, aG as ShippingRate, aH as SiteChrome, aI as SiteFooter, aJ as SiteHeader, aK as SocialLink, aL as StateService, aM as StoreProfile, aN as StoreService, aO as StorefrontCategory, aP as StorefrontMenu, aQ as StorefrontOrder, aR as StorefrontProduct, aS as ThemeSettings, aT as ThemeSettingsResult, aU as UploadService, aV as UserService, aW as Variant, aX as VariantImage, aY as VariantService, aZ as VarniCustomDesignService, a_ as VarniCustomProductService, a$ as Vendor, b0 as VendorService, b1 as WarrantyService, b2 as Wishlist, b3 as WishlistItem, b4 as WishlistService, b5 as addressService, b6 as authService, b7 as autocompleteService, b8 as b2bService, b9 as bannerService, ba as blogService, bb as cartService, bc as categoryService, bd as chatService, be as checkoutService, bf as collectionService, bg as contactService, bh as countryService, bi as couponService, bj as currencyExponent, bk as currencyService, bl as dealService, bm as demoRequestService, bn as emptyCart, bo as emptyPage, bp as enquiryService, bq as faqService, br as feedbackService, bs as fromEngineAddress, bt as fromIdentityAddress, bu as fromSearchDoc, bv as galleryService, bw as homeService, bx as initService, by as layoutService, bz as mediaUrl, bA as meilisearchService, bB as menuService, bC as minorToMajor, bD as newsletterService, bE as orderService, bF as ownDomain, bG as pageService, bH as paymentMethodService, bI as pluginService, bJ as pluginsService, bK as popularSearchService, bL as popularityService, bM as priceOf, bN as productImages, bO as productService, bP as profileService, bQ as qs, bR as reelsService, bS as regionService, bT as reviewService, bU as searchService, bV as setRequestHost, bW as settingService, bX as settingsService, bY as stateService, bZ as staticStore, b_ as storeForHost, b$ as storeService, c0 as toCart, c1 as toCartLine, c2 as toCategory, c3 as toCmsPage, c4 as toCollection, c5 as toEngineAddress, c6 as toIdentityAddress, c7 as toMajor, c8 as toMinor, c9 as toOrder, ca as toPage, cb as toProduct, cc as toRating, cd as toStorefrontFacets, ce as toUser, cf as toVariant, cg as toVendor, ch as uploadService, ci as userService, cj as variantService, ck as varniCustomDesignService, cl as varniCustomProductService, cm as vendorService, cn as warrantyService, co as wishlistService } from './index-90wdO5MM.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 HomeLayout, U as HomeLayoutSection, V as HomeService, W as IdentityAddress, X as InitService, Y as Invitation, Z as LayoutCollection, _ as LayoutPage, $ as LayoutService, a0 as Lead, a1 as ListMeta, a2 as MeilisearchService, a3 as Member, a4 as Menu, a5 as MenuItem, a6 as MenuService, a7 as MenuSummary, a8 as Money, a9 as NewsletterService, aa as Offer, ab as Order, ac as OrderLine, ad as OrderService, ae as PageLayout, af as PageService, ag as PaymentIntent, ah as PaymentMethodService, ai as Plugin, aj as PluginService, aj as PluginsService, ak as PopularSearchService, al as PopularityService, am as Product, an as ProductOption, ao as ProductService, ap as ProfileService, aq as Quote, ar as REDIRECT_GATEWAYS, as as ReelsService, at as RegionService, au as RejectedLine, av as Review, aw as ReviewPage, ax as ReviewService, ay as SearchDoc, az as SearchResult, aA as SearchService, aB as SettingService, aB as SettingsService, aC as ShippingRate, aD as StateService, aE as StoreProfile, aF as StoreService, aG as StorefrontCategory, aH as StorefrontMenu, aI as StorefrontOrder, aJ as StorefrontProduct, aK as ThemeSettings, aL as ThemeSettingsResult, aM as UploadService, aN as UserService, aO as Variant, aP as VariantImage, aQ as VariantService, aR as VarniCustomDesignService, aS as VarniCustomProductService, aT as Vendor, aU as VendorService, aV as WarrantyService, aW as Wishlist, aX as WishlistItem, aY as WishlistService, aZ as addressService, a_ as authService, a$ as autocompleteService, b0 as b2bService, b1 as bannerService, b2 as blogService, b3 as cartService, b4 as categoryService, b5 as chatService, b6 as checkoutService, b7 as collectionService, b8 as contactService, b9 as countryService, ba as couponService, bb as currencyExponent, bc as currencyService, bd as dealService, be as demoRequestService, bf as emptyCart, bg as emptyPage, bh as enquiryService, bi as faqService, bj as feedbackService, bk as fromEngineAddress, bl as fromIdentityAddress, bm as fromSearchDoc, bn as galleryService, bo as homeService, bp as initService, bq as layoutService, br as mediaUrl, bs as meilisearchService, bt as menuService, bu as minorToMajor, bv as newsletterService, bw as orderService, bx as ownDomain, by as pageService, bz as paymentMethodService, bA as pluginService, bB as pluginsService, bC as popularSearchService, bD as popularityService, bE as priceOf, bF as productImages, bG as productService, bH as profileService, bI as qs, bJ as reelsService, bK as regionService, bL as reviewService, bM as searchService, bN as setRequestHost, bO as settingService, bP as settingsService, bQ as stateService, bR as staticStore, bS as storeForHost, bT as storeService, bU as toCart, bV as toCartLine, bW as toCategory, bX as toCmsPage, bY as toCollection, bZ as toEngineAddress, b_ as toIdentityAddress, b$ as toMajor, c0 as toMinor, c1 as toOrder, c2 as toPage, c3 as toProduct, c4 as toRating, c5 as toUser, c6 as toVariant, c7 as toVendor, c8 as uploadService, c9 as userService, ca as variantService, cb as varniCustomDesignService, cc as varniCustomProductService, cd as vendorService, ce as warrantyService, cf as wishlistService } from './index-DSvV8FbK.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 FacetValue, P as Faq, Q as FaqService, R as FeedbackService, S as FooterSettings, T as Fulfillment, U as GalleryService, V as HeaderSettings, W as HomeLayout, X as HomeLayoutSection, Y as HomeService, Z as IdentityAddress, _ as InitService, $ as Invitation, a0 as LayoutCollection, a1 as LayoutPage, a2 as LayoutService, a3 as Lead, a4 as ListMeta, a5 as MeilisearchService, a6 as Member, a7 as Menu, a8 as MenuItem, a9 as MenuService, aa as MenuSummary, ab as Money, ac as NewsletterService, ad as Offer, ae as Order, af as OrderLine, ag as OrderService, ah as PageLayout, ai as PageService, aj as PaymentIntent, ak as PaymentMethodService, al as Plugin, am as PluginService, am as PluginsService, an as PopularSearchService, ao as PopularityService, ap as Product, aq as ProductFacets, ar as ProductOption, as as ProductService, at as ProfileService, au as Quote, av as REDIRECT_GATEWAYS, aw as ReelsService, ax as RegionService, ay as RejectedLine, az as Review, aA as ReviewPage, aB as ReviewService, aC as SearchDoc, aD as SearchResult, aE as SearchService, aF as SettingService, aF as SettingsService, aG as ShippingRate, aH as SiteChrome, aI as SiteFooter, aJ as SiteHeader, aK as SocialLink, aL as StateService, aM as StoreProfile, aN as StoreService, aO as StorefrontCategory, aP as StorefrontMenu, aQ as StorefrontOrder, aR as StorefrontProduct, aS as ThemeSettings, aT as ThemeSettingsResult, aU as UploadService, aV as UserService, aW as Variant, aX as VariantImage, aY as VariantService, aZ as VarniCustomDesignService, a_ as VarniCustomProductService, a$ as Vendor, b0 as VendorService, b1 as WarrantyService, b2 as Wishlist, b3 as WishlistItem, b4 as WishlistService, b5 as addressService, b6 as authService, b7 as autocompleteService, b8 as b2bService, b9 as bannerService, ba as blogService, bb as cartService, bc as categoryService, bd as chatService, be as checkoutService, bf as collectionService, bg as contactService, bh as countryService, bi as couponService, bj as currencyExponent, bk as currencyService, bl as dealService, bm as demoRequestService, bn as emptyCart, bo as emptyPage, bp as enquiryService, bq as faqService, br as feedbackService, bs as fromEngineAddress, bt as fromIdentityAddress, bu as fromSearchDoc, bv as galleryService, bw as homeService, bx as initService, by as layoutService, bz as mediaUrl, bA as meilisearchService, bB as menuService, bC as minorToMajor, bD as newsletterService, bE as orderService, bF as ownDomain, bG as pageService, bH as paymentMethodService, bI as pluginService, bJ as pluginsService, bK as popularSearchService, bL as popularityService, bM as priceOf, bN as productImages, bO as productService, bP as profileService, bQ as qs, bR as reelsService, bS as regionService, bT as reviewService, bU as searchService, bV as setRequestHost, bW as settingService, bX as settingsService, bY as stateService, bZ as staticStore, b_ as storeForHost, b$ as storeService, c0 as toCart, c1 as toCartLine, c2 as toCategory, c3 as toCmsPage, c4 as toCollection, c5 as toEngineAddress, c6 as toIdentityAddress, c7 as toMajor, c8 as toMinor, c9 as toOrder, ca as toPage, cb as toProduct, cc as toRating, cd as toStorefrontFacets, ce as toUser, cf as toVariant, cg as toVendor, ch as uploadService, ci as userService, cj as variantService, ck as varniCustomDesignService, cl as varniCustomProductService, cm as vendorService, cn as warrantyService, co as wishlistService } from './index-90wdO5MM.js';
2
2
 
3
3
  /**
4
4
  * The two ways a call through this connector fails.
package/dist/index.js CHANGED
@@ -1084,11 +1084,14 @@ var StoreFacts = class extends BaseService {
1084
1084
 
1085
1085
  // src/services/catalog.ts
1086
1086
  var PAGE_SIZE = 24;
1087
- function indexSort(sort) {
1088
- if (!sort) return void 0;
1087
+ function sortParts(sort) {
1089
1088
  const s = sort.trim();
1090
1089
  const [field, dir] = s.startsWith("-") ? [s.slice(1), "desc"] : s.includes(":") ? s.split(":") : [s, "asc"];
1091
- const d = dir === "desc" ? "desc" : "asc";
1090
+ return [field, dir === "desc" ? "desc" : "asc"];
1091
+ }
1092
+ function indexSort(sort) {
1093
+ if (!sort) return void 0;
1094
+ const [field, d] = sortParts(sort);
1092
1095
  switch (field) {
1093
1096
  case "price":
1094
1097
  return `price_minor:${d}`;
@@ -1104,6 +1107,20 @@ function indexSort(sort) {
1104
1107
  return void 0;
1105
1108
  }
1106
1109
  }
1110
+ function engineSort(sort) {
1111
+ if (!sort || NATURAL.has(sort)) return {};
1112
+ const [field, order] = sortParts(sort);
1113
+ const key = {
1114
+ price: "price",
1115
+ createdAt: "created_at",
1116
+ created_at: "created_at",
1117
+ updatedAt: "updated_at",
1118
+ updated_at: "updated_at",
1119
+ title: "title",
1120
+ name: "title"
1121
+ }[field];
1122
+ return key ? { sort: key, order } : {};
1123
+ }
1107
1124
  var NATURAL = /* @__PURE__ */ new Set([
1108
1125
  "-createdAt",
1109
1126
  "createdAt:desc",
@@ -1113,6 +1130,7 @@ var NATURAL = /* @__PURE__ */ new Set([
1113
1130
  "popularity:desc"
1114
1131
  ]);
1115
1132
  var quote = (s) => `"${s.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
1133
+ var legacyListing = /* @__PURE__ */ new Set();
1116
1134
  var CatalogService = class extends BaseService {
1117
1135
  facts = new StoreFacts(this._fetch);
1118
1136
  async queryCatalog(q) {
@@ -1122,6 +1140,39 @@ var CatalogService = class extends BaseService {
1122
1140
  const wantsRange = Number.isFinite(q.priceFrom) || Number.isFinite(q.priceTo);
1123
1141
  const sortKey = q.sort && !NATURAL.has(q.sort) ? indexSort(q.sort) : void 0;
1124
1142
  const hierarchy = q.category ? await this.facts.hierarchy(q.category) : [];
1143
+ const attr = Object.entries(q.attributes ?? {}).flatMap(
1144
+ ([handle, values]) => values.filter(Boolean).map((v) => `${handle}:${v}`)
1145
+ );
1146
+ if (q.facets && !legacyListing.has(this.engineBase())) {
1147
+ const { currency } = await this.facts.ready();
1148
+ const minor = (n) => Number.isFinite(n) ? Math.max(0, toMinor(n, currency)) : void 0;
1149
+ const env2 = await this.engine("/api/products", {
1150
+ query: {
1151
+ q: search,
1152
+ page,
1153
+ limit,
1154
+ channel: this.creds.channel,
1155
+ category: q.category,
1156
+ tag: q.tags,
1157
+ vendor: q.vendors,
1158
+ product_type: q.productTypes,
1159
+ attr,
1160
+ price_min: minor(q.priceFrom),
1161
+ price_max: minor(q.priceTo),
1162
+ ...engineSort(q.sort),
1163
+ facets: 1
1164
+ }
1165
+ });
1166
+ if (env2.meta?.facets) {
1167
+ return {
1168
+ ...toPage(env2, (p) => toProduct(p)),
1169
+ categoryHierarchy: hierarchy,
1170
+ sorted: true,
1171
+ facets: env2.meta.facets
1172
+ };
1173
+ }
1174
+ legacyListing.add(this.engineBase());
1175
+ }
1125
1176
  if ((sortKey || wantsRange) && await this.facts.pluginOn("meilisearch")) {
1126
1177
  const filters = [];
1127
1178
  if (q.category) {
@@ -1169,9 +1220,6 @@ var CatalogService = class extends BaseService {
1169
1220
  sorted
1170
1221
  };
1171
1222
  }
1172
- const attr = Object.entries(q.attributes ?? {}).flatMap(
1173
- ([handle, values]) => values.filter(Boolean).map((v) => `${handle}:${v}`)
1174
- );
1175
1223
  const env = await this.engine("/api/products", {
1176
1224
  query: { q: search, page, limit, channel: this.creds.channel, attr }
1177
1225
  });
@@ -1337,16 +1385,44 @@ var num = (v) => {
1337
1385
  const n = Number(v);
1338
1386
  return Number.isFinite(n) ? n : void 0;
1339
1387
  };
1388
+ function decodeOnce(v) {
1389
+ try {
1390
+ return decodeURIComponent(v);
1391
+ } catch {
1392
+ return v;
1393
+ }
1394
+ }
1395
+ function listParam(p, key) {
1396
+ const out = p.getAll(key).flatMap((v) => decodeOnce(v).split(",")).map((v) => v.trim()).filter(Boolean);
1397
+ return out.length ? out : void 0;
1398
+ }
1340
1399
  function attributesFrom(p) {
1341
1400
  const out = {};
1342
- for (const [key, value] of p) {
1401
+ for (const key of new Set(p.keys())) {
1343
1402
  if (!key.startsWith("attributes.")) continue;
1344
1403
  const handle = key.slice("attributes.".length);
1345
- const values = value.split(",").map((v) => decodeURIComponent(v).trim()).filter(Boolean);
1346
- if (handle && values.length) out[handle] = [...out[handle] ?? [], ...values];
1404
+ const values = listParam(p, key);
1405
+ if (handle && values) out[handle] = values;
1347
1406
  }
1348
1407
  return Object.keys(out).length ? out : void 0;
1349
1408
  }
1409
+ var counts = (values) => Object.fromEntries((values ?? []).map((v) => [v.value, v.count]));
1410
+ function toStorefrontFacets(f) {
1411
+ if (!f) return { priceStat: {}, categories: [], tags: [], allFilters: {} };
1412
+ const allFilters = {};
1413
+ const group = (key, values) => {
1414
+ if (values?.length) allFilters[key] = counts(values);
1415
+ };
1416
+ group("vendor", f.vendors);
1417
+ group("product_type", f.product_types);
1418
+ for (const [handle, values] of Object.entries(f.attributes ?? {})) group(`attributes.${handle}`, values);
1419
+ return {
1420
+ priceStat: f.price ? { min: toMajor(f.price.min), max: toMajor(f.price.max) } : {},
1421
+ categories: (f.categories ?? []).map((c) => ({ name: c.title, slug: c.slug, count: c.count })),
1422
+ tags: (f.tags ?? []).map((t) => ({ name: t.value, count: t.count })),
1423
+ allFilters
1424
+ };
1425
+ }
1350
1426
  var SearchService = class extends CatalogService {
1351
1427
  emptyResult() {
1352
1428
  return {
@@ -1354,7 +1430,7 @@ var SearchService = class extends CatalogService {
1354
1430
  count: 0,
1355
1431
  totalPages: 0,
1356
1432
  categoryHierarchy: [],
1357
- facets: { priceStat: {}, categories: [], tags: [], allFilters: {} }
1433
+ facets: toStorefrontFacets()
1358
1434
  };
1359
1435
  }
1360
1436
  async searchWithUrl(url, slug) {
@@ -1369,7 +1445,11 @@ var SearchService = class extends CatalogService {
1369
1445
  category: slug || p.get("categories")?.split(",")[0] || void 0,
1370
1446
  priceFrom: num(p.get("priceFrom")) ?? num(from ?? null),
1371
1447
  priceTo: num(p.get("priceTo")) ?? num(to ?? null),
1372
- attributes: attributesFrom(p)
1448
+ attributes: attributesFrom(p),
1449
+ tags: listParam(p, "tags"),
1450
+ vendors: listParam(p, "vendor"),
1451
+ productTypes: listParam(p, "product_type"),
1452
+ facets: true
1373
1453
  });
1374
1454
  return {
1375
1455
  data: res.data,
@@ -1377,7 +1457,7 @@ var SearchService = class extends CatalogService {
1377
1457
  totalPages: res.noOfPage,
1378
1458
  page: res.page,
1379
1459
  categoryHierarchy: res.categoryHierarchy,
1380
- facets: { priceStat: {}, categories: [], tags: [], allFilters: {} }
1460
+ facets: toStorefrontFacets(res.facets)
1381
1461
  };
1382
1462
  } catch (err) {
1383
1463
  if (err?.status === 404) return this.emptyResult();
@@ -2597,21 +2677,38 @@ var MenuService = class extends BaseService {
2597
2677
  const m = await this.data(`/x/navigation/menus/${encodeURIComponent(handle)}`);
2598
2678
  return { menuId: m.handle, name: m.title, items: (m.items ?? []).map(toItem) };
2599
2679
  }
2600
- /** The header and footer menus, or `null` when the module is not there. Cached: a menu is store-level. */
2680
+ /**
2681
+ * The header and footer menus, or `null` when the module is not there. Cached: a menu is
2682
+ * store-level. Each is the menu the shop chose for it in the theme editor's header or footer
2683
+ * (GoCommerce D131), still under the `header` / `footer` id every storefront looks for, so the
2684
+ * choice reaches every place that draws one; the menus named so are the default.
2685
+ */
2601
2686
  async engineMenus() {
2602
2687
  if (!await this.facts.pluginOn("navigation")) return null;
2603
2688
  return remember(`${this.engineBase()}|${this.store ?? ""}|menus`, async () => {
2604
2689
  const out = [];
2605
- for (const handle of ["header", "footer"]) {
2690
+ for (const part of ["header", "footer"]) {
2606
2691
  try {
2607
- const m = await this.data(`/x/navigation/menus/${handle}`);
2608
- out.push({ menuId: handle, name: m.title, items: (m.items ?? []).map(toItem) });
2692
+ const handle = await this.chosenMenu(part);
2693
+ const m = await this.data(`/x/navigation/menus/${encodeURIComponent(handle)}`);
2694
+ out.push({ menuId: part, name: m.title, items: (m.items ?? []).map(toItem) });
2609
2695
  } catch {
2610
2696
  }
2611
2697
  }
2612
2698
  return out;
2613
2699
  }).catch(() => null);
2614
2700
  }
2701
+ /** The handle of the menu the published header or footer names, else the part's own name. */
2702
+ async chosenMenu(part) {
2703
+ if (!await this.facts.pluginOn("layouts")) return part;
2704
+ try {
2705
+ const layout = await this.data(`/x/layouts/${part}`);
2706
+ const menu = layout?.sections?.find((s) => s.type === part)?.settings?.menu;
2707
+ return typeof menu === "string" && menu ? menu : part;
2708
+ } catch {
2709
+ return part;
2710
+ }
2711
+ }
2615
2712
  };
2616
2713
  var menuService = new MenuService();
2617
2714
 
@@ -2726,7 +2823,10 @@ var StoreService = class extends BaseService {
2726
2823
  isProductReviewsAndRatings: {
2727
2824
  ...basePlugins.isProductReviewsAndRatings,
2728
2825
  ...flag(plugins.has("product-reviews"))
2729
- }
2826
+ },
2827
+ // The footer's sign-up box posts to ext/newsletter, and the theme editor's footer
2828
+ // switch (D131) can only show it while that is on.
2829
+ newsletter: { ...basePlugins.newsletter, ...flag(plugins.has("newsletter")) }
2730
2830
  },
2731
2831
  ...menus?.length ? { menu: menus } : {},
2732
2832
  ...deliverable(base, ships),
@@ -2841,6 +2941,35 @@ var LayoutService = class extends BaseService {
2841
2941
  return null;
2842
2942
  }
2843
2943
  }
2944
+ /**
2945
+ * The header the shop set in the theme editor (D131), drawn on every
2946
+ * page: the published one, or a preview key's draft. Null — the
2947
+ * storefront's own header — when none is published, the editor is off, the
2948
+ * engine is older, or anything fails: a header is never worth an error page.
2949
+ */
2950
+ async getHeader({ preview } = {}) {
2951
+ return this.chrome("header", preview);
2952
+ }
2953
+ /** The footer the shop set in the theme editor (D131); null for the storefront's own, as getHeader. */
2954
+ async getFooter({ preview } = {}) {
2955
+ return this.chrome("footer", preview);
2956
+ }
2957
+ async chrome(page, preview) {
2958
+ let layout;
2959
+ try {
2960
+ layout = await this.getPageLayout(page, { preview });
2961
+ } catch {
2962
+ return null;
2963
+ }
2964
+ const section = layout?.sections.find((s) => s.type === page);
2965
+ if (!layout || !section) return null;
2966
+ const settings = { ...section.settings };
2967
+ let menu = null;
2968
+ if (typeof settings.menu === "string" && settings.menu) {
2969
+ menu = await new MenuService(this._fetch).getMenu(settings.menu).catch(() => null);
2970
+ }
2971
+ return { revision: layout.revision, preview: layout.preview, settings, menu };
2972
+ }
2844
2973
  };
2845
2974
  function tokens(v) {
2846
2975
  return v && typeof v === "object" && !Array.isArray(v) && Object.keys(v).length ? { ...v } : null;
@@ -3403,6 +3532,6 @@ function attemptKey(request) {
3403
3532
  }
3404
3533
  var b2bService = new B2bService();
3405
3534
 
3406
- 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, LayoutService, 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, layoutService, 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 };
3535
+ 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, LayoutService, 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, layoutService, 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, toStorefrontFacets, toUser, toVariant, toVendor, uploadService, userService, variantService, varniCustomDesignService, varniCustomProductService, vendorService, warrantyService, wishlistService };
3407
3536
  //# sourceMappingURL=index.js.map
3408
3537
  //# sourceMappingURL=index.js.map