@misiki/gocommerce-connector 0.13.0 → 0.14.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 AddOn, a as Address, b as AddressService, c as AppliedDiscount, d as Approval, e as AuthResponse, f as AuthService, g as AutocompleteService, B as B2bPlaced, h as B2bRole, i as B2bService, j as BannerService, k as BaseService, l as BlogService, C as Cart, m as CartLine, n as CartOffer, o as CartService, p as CatalogService, q as Category, r as CategoryService, s as ChatService, t as CheckoutOptions, u as CheckoutResult, v as CheckoutService, w as CmsPage, x as Collection, y as CollectionService, z as Company, D as CompanyOrder, E as ContactService, F as CountryService, G as CouponService, H as Credentials, I as Credit, J as CurrencyService, K as Customer, L as DealService, M as DemoRequestService, N as EngineRequest, O as EnquiryService, P as Envelope, Q as FacetValue, R as Faq, S as FaqService, T as FeedbackService, U as FooterSettings, V as FreeShipping, W as Fulfillment, X as GalleryService, Y as HeaderSettings, Z as HomeLayout, _ as HomeLayoutSection, $ as HomeService, a0 as IdentityAddress, a1 as InitService, a2 as Invitation, a3 as LayoutCollection, a4 as LayoutPage, a5 as LayoutService, a6 as Lead, a7 as ListMeta, a8 as MeilisearchService, a9 as Member, aa as Menu, ab as MenuItem, ac as MenuService, ad as MenuSummary, ae as Money, af as NewsletterService, ag as Offer, ah as Order, ai as OrderLine, aj as OrderService, ak as PageLayout, al as PageService, am as PaymentIntent, an as PaymentMethodService, ao as Plugin, ap as PluginService, ap as PluginsService, aq as PopularSearchService, ar as PopularityService, as as Postcode, at as Product, au as ProductFacets, av as ProductOption, aw as ProductService, ax as ProfileService, ay as Quote, az as REDIRECT_GATEWAYS, aA as ReelsService, aB as RegionService, aC as RejectedLine, aD as Review, aE as ReviewPage, aF as ReviewService, aG as SearchDoc, aH as SearchResult, aI as SearchService, aJ as SettingService, aJ as SettingsService, aK as ShippingRate, aL as SiteChrome, aM as SiteFooter, aN as SiteHeader, aO as SocialLink, aP as StateService, aQ as StoreProfile, aR as StoreService, aS as StorefrontCategory, aT as StorefrontMenu, aU as StorefrontOrder, aV as StorefrontProduct, aW as ThemeSettings, aX as ThemeSettingsResult, aY as UploadService, aZ as UserService, a_ as Variant, a$ as VariantImage, b0 as VariantService, b1 as VarniCustomDesignService, b2 as VarniCustomProductService, b3 as Vendor, b4 as VendorService, b5 as WarrantyService, b6 as Wishlist, b7 as WishlistItem, b8 as WishlistService, b9 as addressService, ba as authService, bb as autocompleteService, bc as b2bService, bd as bannerService, be as blogService, bf as cartService, bg as categoryService, bh as chatService, bi as checkoutService, bj as collectionService, bk as contactService, bl as countryService, bm as couponService, bn as currencyExponent, bo as currencyService, bp as dealService, bq as demoRequestService, br as emptyCart, bs as emptyPage, bt as enquiryService, bu as faqService, bv as feedbackService, bw as fromEngineAddress, bx as fromIdentityAddress, by as fromSearchDoc, bz as galleryService, bA as homeService, bB as initService, bC as layoutService, bD as mediaUrl, bE as meilisearchService, bF as menuService, bG as minorToMajor, bH as newsletterService, bI as orderService, bJ as ownDomain, bK as pageService, bL as paymentMethodService, bM as pluginService, bN as pluginsService, bO as popularSearchService, bP as popularityService, bQ as priceOf, bR as productImages, bS as productService, bT as productVideos, bU as profileService, bV as qs, bW as reelsService, bX as regionService, bY as reviewService, bZ as searchService, b_ as setRequestHost, b$ as settingService, c0 as settingsService, c1 as stateService, c2 as staticStore, c3 as storeForHost, c4 as storeService, c5 as toAddOn, c6 as toCart, c7 as toCartLine, c8 as toCartOffer, c9 as toCategory, ca as toCmsPage, cb as toCollection, cc as toEngineAddress, cd as toFreeShipping, ce as toIdentityAddress, cf as toMajor, cg as toMinor, ch as toOrder, ci as toPage, cj as toProduct, ck as toRating, cl as toStorefrontFacets, cm as toUser, cn as toVariant, co as toVendor, cp as uploadService, cq as userService, cr as variantService, cs as varniCustomDesignService, ct as varniCustomProductService, cu as vendorService, cv as warrantyService, cw as wishlistService } from './index-DHKyh3CU.cjs';
1
+ export { A as AddOn, a as Address, b as AddressService, c as AppliedDiscount, d as Approval, e as AuthResponse, f as AuthService, g as AutocompleteService, B as B2bPlaced, h as B2bRole, i as B2bService, j as BannerService, k as BaseService, l as BlogService, C as Cart, m as CartLine, n as CartOffer, o as CartService, p as CatalogService, q as Category, r as CategoryService, s as ChatService, t as CheckoutOptions, u as CheckoutResult, v as CheckoutService, w as CmsPage, x as Collection, y as CollectionService, z as Company, D as CompanyOrder, E as ContactService, F as CountryService, G as CouponService, H as Credentials, I as Credit, J as CurrencyService, K as Customer, L as DealService, M as DemoRequestService, N as EngineRequest, O as EnquiryService, P as Envelope, Q as FacetValue, R as Faq, S as FaqService, T as FeedbackService, U as FooterSettings, V as FreeShipping, W as Fulfillment, X as GalleryService, Y as HeaderSettings, Z as HomeLayout, _ as HomeLayoutSection, $ as HomeService, a0 as IdentityAddress, a1 as InitService, a2 as Invitation, a3 as LayoutCollection, a4 as LayoutPage, a5 as LayoutService, a6 as Lead, a7 as ListMeta, a8 as MeilisearchService, a9 as Member, aa as Menu, ab as MenuItem, ac as MenuService, ad as MenuSummary, ae as Money, af as NewsletterService, ag as Offer, ah as Order, ai as OrderLine, aj as OrderService, ak as PageLayout, al as PageService, am as PaymentIntent, an as PaymentMethodService, ao as Plugin, ap as PluginService, ap as PluginsService, aq as PopularSearchService, ar as PopularityService, as as Postcode, at as Product, au as ProductFacets, av as ProductOption, aw as ProductService, ax as ProfileService, ay as Quote, az as REDIRECT_GATEWAYS, aA as ReelsService, aB as RegionService, aC as RejectedLine, aD as Review, aE as ReviewPage, aF as ReviewService, aG as SearchDoc, aH as SearchResult, aI as SearchService, aJ as SettingService, aJ as SettingsService, aK as ShippingRate, aL as SiteChrome, aM as SiteFooter, aN as SiteHeader, aO as SocialLink, aP as StateService, aQ as StoreProfile, aR as StoreService, aS as StorefrontCategory, aT as StorefrontMenu, aU as StorefrontOrder, aV as StorefrontProduct, aW as ThemeSettings, aX as ThemeSettingsResult, aY as UploadService, aZ as UserService, a_ as Variant, a$ as VariantImage, b0 as VariantService, b1 as VarniCustomDesignService, b2 as VarniCustomProductService, b3 as Vendor, b4 as VendorService, b5 as WarrantyService, b6 as Wishlist, b7 as WishlistItem, b8 as WishlistService, b9 as addressService, ba as authService, bb as autocompleteService, bc as b2bService, bd as bannerService, be as blogService, bf as cartService, bg as categoryService, bh as chatService, bi as checkoutService, bj as collectionService, bk as contactService, bl as countryService, bm as couponService, bn as currencyExponent, bo as currencyService, bp as dealService, bq as demoRequestService, br as emptyCart, bs as emptyPage, bt as enquiryService, bu as faqService, bv as feedbackService, bw as fromEngineAddress, bx as fromIdentityAddress, by as fromSearchDoc, bz as galleryService, bA as homeService, bB as initService, bC as layoutService, bD as mediaUrl, bE as meilisearchService, bF as menuService, bG as minorToMajor, bH as newsletterService, bI as orderService, bJ as ownDomain, bK as pageService, bL as paymentMethodService, bM as pluginService, bN as pluginsService, bO as popularSearchService, bP as popularityService, bQ as priceOf, bR as productImages, bS as productService, bT as productVideos, bU as profileService, bV as qs, bW as reelsService, bX as regionService, bY as reviewService, bZ as searchService, b_ as setRequestHost, b$ as settingService, c0 as settingsService, c1 as stateService, c2 as staticStore, c3 as storeForHost, c4 as storeService, c5 as toAddOn, c6 as toCart, c7 as toCartLine, c8 as toCartOffer, c9 as toCategory, ca as toCmsPage, cb as toCollection, cc as toEngineAddress, cd as toFreeShipping, ce as toIdentityAddress, cf as toMajor, cg as toMinor, ch as toOrder, ci as toPage, cj as toProduct, ck as toRating, cl as toStorefrontFacets, cm as toUser, cn as toVariant, co as toVendor, cp as uploadService, cq as userService, cr as variantService, cs as varniCustomDesignService, ct as varniCustomProductService, cu as vendorService, cv as warrantyService, cw as wishlistService } from './index-C0CR05Q4.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 AddOn, a as Address, b as AddressService, c as AppliedDiscount, d as Approval, e as AuthResponse, f as AuthService, g as AutocompleteService, B as B2bPlaced, h as B2bRole, i as B2bService, j as BannerService, k as BaseService, l as BlogService, C as Cart, m as CartLine, n as CartOffer, o as CartService, p as CatalogService, q as Category, r as CategoryService, s as ChatService, t as CheckoutOptions, u as CheckoutResult, v as CheckoutService, w as CmsPage, x as Collection, y as CollectionService, z as Company, D as CompanyOrder, E as ContactService, F as CountryService, G as CouponService, H as Credentials, I as Credit, J as CurrencyService, K as Customer, L as DealService, M as DemoRequestService, N as EngineRequest, O as EnquiryService, P as Envelope, Q as FacetValue, R as Faq, S as FaqService, T as FeedbackService, U as FooterSettings, V as FreeShipping, W as Fulfillment, X as GalleryService, Y as HeaderSettings, Z as HomeLayout, _ as HomeLayoutSection, $ as HomeService, a0 as IdentityAddress, a1 as InitService, a2 as Invitation, a3 as LayoutCollection, a4 as LayoutPage, a5 as LayoutService, a6 as Lead, a7 as ListMeta, a8 as MeilisearchService, a9 as Member, aa as Menu, ab as MenuItem, ac as MenuService, ad as MenuSummary, ae as Money, af as NewsletterService, ag as Offer, ah as Order, ai as OrderLine, aj as OrderService, ak as PageLayout, al as PageService, am as PaymentIntent, an as PaymentMethodService, ao as Plugin, ap as PluginService, ap as PluginsService, aq as PopularSearchService, ar as PopularityService, as as Postcode, at as Product, au as ProductFacets, av as ProductOption, aw as ProductService, ax as ProfileService, ay as Quote, az as REDIRECT_GATEWAYS, aA as ReelsService, aB as RegionService, aC as RejectedLine, aD as Review, aE as ReviewPage, aF as ReviewService, aG as SearchDoc, aH as SearchResult, aI as SearchService, aJ as SettingService, aJ as SettingsService, aK as ShippingRate, aL as SiteChrome, aM as SiteFooter, aN as SiteHeader, aO as SocialLink, aP as StateService, aQ as StoreProfile, aR as StoreService, aS as StorefrontCategory, aT as StorefrontMenu, aU as StorefrontOrder, aV as StorefrontProduct, aW as ThemeSettings, aX as ThemeSettingsResult, aY as UploadService, aZ as UserService, a_ as Variant, a$ as VariantImage, b0 as VariantService, b1 as VarniCustomDesignService, b2 as VarniCustomProductService, b3 as Vendor, b4 as VendorService, b5 as WarrantyService, b6 as Wishlist, b7 as WishlistItem, b8 as WishlistService, b9 as addressService, ba as authService, bb as autocompleteService, bc as b2bService, bd as bannerService, be as blogService, bf as cartService, bg as categoryService, bh as chatService, bi as checkoutService, bj as collectionService, bk as contactService, bl as countryService, bm as couponService, bn as currencyExponent, bo as currencyService, bp as dealService, bq as demoRequestService, br as emptyCart, bs as emptyPage, bt as enquiryService, bu as faqService, bv as feedbackService, bw as fromEngineAddress, bx as fromIdentityAddress, by as fromSearchDoc, bz as galleryService, bA as homeService, bB as initService, bC as layoutService, bD as mediaUrl, bE as meilisearchService, bF as menuService, bG as minorToMajor, bH as newsletterService, bI as orderService, bJ as ownDomain, bK as pageService, bL as paymentMethodService, bM as pluginService, bN as pluginsService, bO as popularSearchService, bP as popularityService, bQ as priceOf, bR as productImages, bS as productService, bT as productVideos, bU as profileService, bV as qs, bW as reelsService, bX as regionService, bY as reviewService, bZ as searchService, b_ as setRequestHost, b$ as settingService, c0 as settingsService, c1 as stateService, c2 as staticStore, c3 as storeForHost, c4 as storeService, c5 as toAddOn, c6 as toCart, c7 as toCartLine, c8 as toCartOffer, c9 as toCategory, ca as toCmsPage, cb as toCollection, cc as toEngineAddress, cd as toFreeShipping, ce as toIdentityAddress, cf as toMajor, cg as toMinor, ch as toOrder, ci as toPage, cj as toProduct, ck as toRating, cl as toStorefrontFacets, cm as toUser, cn as toVariant, co as toVendor, cp as uploadService, cq as userService, cr as variantService, cs as varniCustomDesignService, ct as varniCustomProductService, cu as vendorService, cv as warrantyService, cw as wishlistService } from './index-DHKyh3CU.js';
1
+ export { A as AddOn, a as Address, b as AddressService, c as AppliedDiscount, d as Approval, e as AuthResponse, f as AuthService, g as AutocompleteService, B as B2bPlaced, h as B2bRole, i as B2bService, j as BannerService, k as BaseService, l as BlogService, C as Cart, m as CartLine, n as CartOffer, o as CartService, p as CatalogService, q as Category, r as CategoryService, s as ChatService, t as CheckoutOptions, u as CheckoutResult, v as CheckoutService, w as CmsPage, x as Collection, y as CollectionService, z as Company, D as CompanyOrder, E as ContactService, F as CountryService, G as CouponService, H as Credentials, I as Credit, J as CurrencyService, K as Customer, L as DealService, M as DemoRequestService, N as EngineRequest, O as EnquiryService, P as Envelope, Q as FacetValue, R as Faq, S as FaqService, T as FeedbackService, U as FooterSettings, V as FreeShipping, W as Fulfillment, X as GalleryService, Y as HeaderSettings, Z as HomeLayout, _ as HomeLayoutSection, $ as HomeService, a0 as IdentityAddress, a1 as InitService, a2 as Invitation, a3 as LayoutCollection, a4 as LayoutPage, a5 as LayoutService, a6 as Lead, a7 as ListMeta, a8 as MeilisearchService, a9 as Member, aa as Menu, ab as MenuItem, ac as MenuService, ad as MenuSummary, ae as Money, af as NewsletterService, ag as Offer, ah as Order, ai as OrderLine, aj as OrderService, ak as PageLayout, al as PageService, am as PaymentIntent, an as PaymentMethodService, ao as Plugin, ap as PluginService, ap as PluginsService, aq as PopularSearchService, ar as PopularityService, as as Postcode, at as Product, au as ProductFacets, av as ProductOption, aw as ProductService, ax as ProfileService, ay as Quote, az as REDIRECT_GATEWAYS, aA as ReelsService, aB as RegionService, aC as RejectedLine, aD as Review, aE as ReviewPage, aF as ReviewService, aG as SearchDoc, aH as SearchResult, aI as SearchService, aJ as SettingService, aJ as SettingsService, aK as ShippingRate, aL as SiteChrome, aM as SiteFooter, aN as SiteHeader, aO as SocialLink, aP as StateService, aQ as StoreProfile, aR as StoreService, aS as StorefrontCategory, aT as StorefrontMenu, aU as StorefrontOrder, aV as StorefrontProduct, aW as ThemeSettings, aX as ThemeSettingsResult, aY as UploadService, aZ as UserService, a_ as Variant, a$ as VariantImage, b0 as VariantService, b1 as VarniCustomDesignService, b2 as VarniCustomProductService, b3 as Vendor, b4 as VendorService, b5 as WarrantyService, b6 as Wishlist, b7 as WishlistItem, b8 as WishlistService, b9 as addressService, ba as authService, bb as autocompleteService, bc as b2bService, bd as bannerService, be as blogService, bf as cartService, bg as categoryService, bh as chatService, bi as checkoutService, bj as collectionService, bk as contactService, bl as countryService, bm as couponService, bn as currencyExponent, bo as currencyService, bp as dealService, bq as demoRequestService, br as emptyCart, bs as emptyPage, bt as enquiryService, bu as faqService, bv as feedbackService, bw as fromEngineAddress, bx as fromIdentityAddress, by as fromSearchDoc, bz as galleryService, bA as homeService, bB as initService, bC as layoutService, bD as mediaUrl, bE as meilisearchService, bF as menuService, bG as minorToMajor, bH as newsletterService, bI as orderService, bJ as ownDomain, bK as pageService, bL as paymentMethodService, bM as pluginService, bN as pluginsService, bO as popularSearchService, bP as popularityService, bQ as priceOf, bR as productImages, bS as productService, bT as productVideos, bU as profileService, bV as qs, bW as reelsService, bX as regionService, bY as reviewService, bZ as searchService, b_ as setRequestHost, b$ as settingService, c0 as settingsService, c1 as stateService, c2 as staticStore, c3 as storeForHost, c4 as storeService, c5 as toAddOn, c6 as toCart, c7 as toCartLine, c8 as toCartOffer, c9 as toCategory, ca as toCmsPage, cb as toCollection, cc as toEngineAddress, cd as toFreeShipping, ce as toIdentityAddress, cf as toMajor, cg as toMinor, ch as toOrder, ci as toPage, cj as toProduct, ck as toRating, cl as toStorefrontFacets, cm as toUser, cn as toVariant, co as toVendor, cp as uploadService, cq as userService, cr as variantService, cs as varniCustomDesignService, ct as varniCustomProductService, cu as vendorService, cv as warrantyService, cw as wishlistService } from './index-C0CR05Q4.js';
2
2
 
3
3
  /**
4
4
  * The two ways a call through this connector fails.
package/dist/index.js CHANGED
@@ -1214,14 +1214,17 @@ var CatalogService = class extends BaseService {
1214
1214
  const attr = Object.entries(q.attributes ?? {}).flatMap(
1215
1215
  ([handle, values]) => values.filter(Boolean).map((v) => `${handle}:${v}`)
1216
1216
  );
1217
- if (q.facets && !legacyListing.has(this.engineBase())) {
1217
+ const refined = attr.length > 0 || !!(q.tags?.length || q.vendors?.length || q.productTypes?.length);
1218
+ const triedIndex = !!search && !refined;
1219
+ const counted = q.facets && !legacyListing.has(this.engineBase());
1220
+ const facetListing = async (page2, limit2) => {
1218
1221
  const { currency } = await this.facts.ready();
1219
1222
  const minor = (n) => Number.isFinite(n) ? Math.max(0, toMinor(n, currency)) : void 0;
1220
- const env2 = await this.engine("/api/products", {
1223
+ return this.engine("/api/products", {
1221
1224
  query: {
1222
1225
  q: search,
1223
- page,
1224
- limit,
1226
+ page: page2,
1227
+ limit: limit2,
1225
1228
  channel: this.creds.channel,
1226
1229
  category: q.category,
1227
1230
  tag: q.tags,
@@ -1234,6 +1237,16 @@ var CatalogService = class extends BaseService {
1234
1237
  facets: 1
1235
1238
  }
1236
1239
  });
1240
+ };
1241
+ if (triedIndex && await this.facts.pluginOn("meilisearch")) {
1242
+ const [found, rail] = await Promise.all([
1243
+ this.fromIndex(q, { page, limit, search, sortKey, wantsRange, hierarchy }),
1244
+ counted ? facetListing(1, 1).catch(() => null) : null
1245
+ ]);
1246
+ if (found) return rail?.meta?.facets ? { ...found, facets: rail.meta.facets } : found;
1247
+ }
1248
+ if (counted) {
1249
+ const env2 = await facetListing(page, limit);
1237
1250
  if (env2.meta?.facets) {
1238
1251
  return {
1239
1252
  ...toPage(env2, (p) => toProduct(p)),
@@ -1244,39 +1257,9 @@ var CatalogService = class extends BaseService {
1244
1257
  }
1245
1258
  legacyListing.add(this.engineBase());
1246
1259
  }
1247
- if ((sortKey || wantsRange) && await this.facts.pluginOn("meilisearch")) {
1248
- const filters = [];
1249
- if (q.category) {
1250
- const names = (await this.facts.subtree(q.category).catch(() => [])).map(
1251
- (c) => quote(c.full_name)
1252
- );
1253
- if (!names.length) return { ...emptyCatalog(limit), categoryHierarchy: hierarchy, sorted: true };
1254
- filters.push(`category IN [${names.join(", ")}]`);
1255
- }
1256
- if (wantsRange) {
1257
- const { currency } = await this.facts.ready();
1258
- if (Number.isFinite(q.priceFrom)) filters.push(`price_minor >= ${toMinor(q.priceFrom, currency)}`);
1259
- if (Number.isFinite(q.priceTo)) filters.push(`price_minor <= ${toMinor(q.priceTo, currency)}`);
1260
- }
1261
- const res = await this.data("/x/meilisearch/search", {
1262
- query: {
1263
- q: search ?? "",
1264
- limit,
1265
- offset: (page - 1) * limit,
1266
- filter: filters.join(" AND ") || void 0,
1267
- sort: sortKey
1268
- }
1269
- });
1270
- const total = res.total ?? 0;
1271
- return {
1272
- data: (res.hits ?? []).map(fromSearchDoc),
1273
- count: total,
1274
- pageSize: limit,
1275
- noOfPage: Math.max(1, Math.ceil(total / limit)),
1276
- page,
1277
- categoryHierarchy: hierarchy,
1278
- sorted: true
1279
- };
1260
+ if (!triedIndex && (sortKey || wantsRange)) {
1261
+ const found = await this.fromIndex(q, { page, limit, search, sortKey, wantsRange, hierarchy });
1262
+ if (found) return found;
1280
1263
  }
1281
1264
  const sorted = !sortKey && !wantsRange;
1282
1265
  if (q.category && !search) {
@@ -1296,6 +1279,45 @@ var CatalogService = class extends BaseService {
1296
1279
  });
1297
1280
  return { ...toPage(env, (p) => toProduct(p)), categoryHierarchy: hierarchy, sorted };
1298
1281
  }
1282
+ /**
1283
+ * The shelf from the Meilisearch module, or null when the store has it off,
1284
+ * sells through a channel, finds nothing for the words, or it cannot answer (Meilisearch down: the engine says `unavailable`), so
1285
+ * the caller asks the database instead of showing the shopper an error.
1286
+ */
1287
+ async fromIndex(q, o) {
1288
+ if (this.creds.channel || !await this.facts.pluginOn("meilisearch")) return null;
1289
+ const filters = [];
1290
+ if (q.category) {
1291
+ const names = (await this.facts.subtree(q.category).catch(() => [])).map((c) => quote(c.full_name));
1292
+ if (!names.length) return { ...emptyCatalog(o.limit), categoryHierarchy: o.hierarchy, sorted: true };
1293
+ filters.push(`category IN [${names.join(", ")}]`);
1294
+ }
1295
+ if (o.wantsRange) {
1296
+ const { currency } = await this.facts.ready();
1297
+ if (Number.isFinite(q.priceFrom)) filters.push(`price_minor >= ${toMinor(q.priceFrom, currency)}`);
1298
+ if (Number.isFinite(q.priceTo)) filters.push(`price_minor <= ${toMinor(q.priceTo, currency)}`);
1299
+ }
1300
+ const res = await this.data("/x/meilisearch/search", {
1301
+ query: {
1302
+ q: o.search ?? "",
1303
+ limit: o.limit,
1304
+ offset: (o.page - 1) * o.limit,
1305
+ filter: filters.join(" AND ") || void 0,
1306
+ sort: o.sortKey
1307
+ }
1308
+ }).catch(() => null);
1309
+ if (!res || res.unavailable || o.search && !res.hits?.length) return null;
1310
+ const total = res.total ?? 0;
1311
+ return {
1312
+ data: (res.hits ?? []).map(fromSearchDoc),
1313
+ count: total,
1314
+ pageSize: o.limit,
1315
+ noOfPage: Math.max(1, Math.ceil(total / o.limit)),
1316
+ page: o.page,
1317
+ categoryHierarchy: o.hierarchy,
1318
+ sorted: true
1319
+ };
1320
+ }
1299
1321
  };
1300
1322
  function emptyCatalog(limit = PAGE_SIZE) {
1301
1323
  return { data: [], count: 0, pageSize: limit, noOfPage: 0, page: 1 };
@@ -1593,10 +1615,8 @@ var MeilisearchService = class extends CatalogService {
1593
1615
  async searchAutoComplete({ query, search, limit = 8 } = {}) {
1594
1616
  const q = (query ?? search ?? "").trim();
1595
1617
  if (!q) return { data: [] };
1596
- if (await this.facts.pluginOn("meilisearch")) {
1597
- const res = await this.data("/x/meilisearch/search", { query: { q, limit } });
1598
- return { data: (res.hits ?? []).map(fromSearchDoc) };
1599
- }
1618
+ const found = await this.fromIndex({}, { page: 1, limit, search: q, wantsRange: false, hierarchy: [] });
1619
+ if (found) return { data: found.data };
1600
1620
  const rows = await this.data("/api/products", { query: { q, limit, channel: this.creds.channel } }) ?? [];
1601
1621
  return { data: rows.map((p) => toProduct(p)) };
1602
1622
  }