@misiki/gocommerce-connector 0.9.1 → 0.10.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.
@@ -1 +1 @@
1
- export { a as AddressService, c as Approval, e as AuthService, f as AutocompleteService, B as B2bPlaced, g as B2bRole, h as B2bService, i as BannerService, j as BaseService, k as BlogService, m as CartService, n as CatalogService, p as CategoryService, q as ChatService, t as CheckoutService, w as CollectionService, x as Company, y as CompanyOrder, z as ContactService, D as CountryService, E as CouponService, G as Credit, H as CurrencyService, J as DealService, K as DemoRequestService, L as EngineRequest, M as EnquiryService, P as FaqService, Q as FeedbackService, S as GalleryService, T as HomeLayout, U as HomeLayoutSection, V as HomeService, X as InitService, Y as Invitation, Z as LayoutCollection, _ as LayoutPage, $ as LayoutService, a0 as Lead, a2 as MeilisearchService, a3 as Member, a6 as MenuService, a9 as NewsletterService, ad as OrderService, ae as PageLayout, af as PageService, ah as PaymentMethodService, aj as PluginService, aj as PluginsService, ak as PopularSearchService, al as PopularityService, ao as ProductService, ap as ProfileService, aq as Quote, ar as REDIRECT_GATEWAYS, as as ReelsService, at as RegionService, au as RejectedLine, ax as ReviewService, aA as SearchService, aB as SettingService, aB as SettingsService, aD as StateService, aF as StoreService, aH as StorefrontMenu, aK as ThemeSettings, aL as ThemeSettingsResult, aM as UploadService, aN as UserService, aQ as VariantService, aR as VarniCustomDesignService, aS as VarniCustomProductService, aU as VendorService, aV as WarrantyService, 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, bc as currencyService, bd as dealService, be as demoRequestService, bg as emptyPage, bh as enquiryService, bi as faqService, bj as feedbackService, bn as galleryService, bo as homeService, bp as initService, bq as layoutService, br as mediaUrl, bs as meilisearchService, bt as menuService, 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, 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, c2 as toPage, 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 AddressService, c as Approval, e as AuthService, f as AutocompleteService, B as B2bPlaced, g as B2bRole, h as B2bService, i as BannerService, j as BaseService, k as BlogService, m as CartService, n as CatalogService, p as CategoryService, q as ChatService, t as CheckoutService, w as CollectionService, x as Company, y as CompanyOrder, z as ContactService, D as CountryService, E as CouponService, G as Credit, H as CurrencyService, J as DealService, K as DemoRequestService, L as EngineRequest, M as EnquiryService, Q as FaqService, R as FeedbackService, T as GalleryService, U as HomeLayout, V as HomeLayoutSection, W as HomeService, Y as InitService, Z as Invitation, _ as LayoutCollection, $ as LayoutPage, a0 as LayoutService, a1 as Lead, a3 as MeilisearchService, a4 as Member, a7 as MenuService, aa as NewsletterService, ae as OrderService, af as PageLayout, ag as PageService, ai as PaymentMethodService, ak as PluginService, ak as PluginsService, al as PopularSearchService, am as PopularityService, aq as ProductService, ar as ProfileService, as as Quote, at as REDIRECT_GATEWAYS, au as ReelsService, av as RegionService, aw as RejectedLine, az as ReviewService, aC as SearchService, aD as SettingService, aD as SettingsService, aF as StateService, aH as StoreService, aJ as StorefrontMenu, aM as ThemeSettings, aN as ThemeSettingsResult, aO as UploadService, aP as UserService, aS as VariantService, aT as VarniCustomDesignService, aU as VarniCustomProductService, aW as VendorService, aX as WarrantyService, a_ as WishlistService, a$ as addressService, b0 as authService, b1 as autocompleteService, b2 as b2bService, b3 as bannerService, b4 as blogService, b5 as cartService, b6 as categoryService, b7 as chatService, b8 as checkoutService, b9 as collectionService, ba as contactService, bb as countryService, bc as couponService, be as currencyService, bf as dealService, bg as demoRequestService, bi as emptyPage, bj as enquiryService, bk as faqService, bl as feedbackService, bp as galleryService, bq as homeService, br as initService, bs as layoutService, bt as mediaUrl, bu as meilisearchService, bv as menuService, bx as newsletterService, by as orderService, bz as ownDomain, bA as pageService, bB as paymentMethodService, bC as pluginService, bD as pluginsService, bE as popularSearchService, bF as popularityService, bI as productService, bJ as profileService, bK as qs, bL as reelsService, bM as regionService, bN as reviewService, bO as searchService, bP as setRequestHost, bQ as settingService, bR as settingsService, bS as stateService, bT as staticStore, bU as storeForHost, bV as storeService, c4 as toPage, c7 as toStorefrontFacets, cb as uploadService, cc as userService, cd as variantService, ce as varniCustomDesignService, cf as varniCustomProductService, cg as vendorService, ch as warrantyService, ci as wishlistService } from '../index-mqcHZ96i.cjs';
@@ -1 +1 @@
1
- export { a as AddressService, c as Approval, e as AuthService, f as AutocompleteService, B as B2bPlaced, g as B2bRole, h as B2bService, i as BannerService, j as BaseService, k as BlogService, m as CartService, n as CatalogService, p as CategoryService, q as ChatService, t as CheckoutService, w as CollectionService, x as Company, y as CompanyOrder, z as ContactService, D as CountryService, E as CouponService, G as Credit, H as CurrencyService, J as DealService, K as DemoRequestService, L as EngineRequest, M as EnquiryService, P as FaqService, Q as FeedbackService, S as GalleryService, T as HomeLayout, U as HomeLayoutSection, V as HomeService, X as InitService, Y as Invitation, Z as LayoutCollection, _ as LayoutPage, $ as LayoutService, a0 as Lead, a2 as MeilisearchService, a3 as Member, a6 as MenuService, a9 as NewsletterService, ad as OrderService, ae as PageLayout, af as PageService, ah as PaymentMethodService, aj as PluginService, aj as PluginsService, ak as PopularSearchService, al as PopularityService, ao as ProductService, ap as ProfileService, aq as Quote, ar as REDIRECT_GATEWAYS, as as ReelsService, at as RegionService, au as RejectedLine, ax as ReviewService, aA as SearchService, aB as SettingService, aB as SettingsService, aD as StateService, aF as StoreService, aH as StorefrontMenu, aK as ThemeSettings, aL as ThemeSettingsResult, aM as UploadService, aN as UserService, aQ as VariantService, aR as VarniCustomDesignService, aS as VarniCustomProductService, aU as VendorService, aV as WarrantyService, 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, bc as currencyService, bd as dealService, be as demoRequestService, bg as emptyPage, bh as enquiryService, bi as faqService, bj as feedbackService, bn as galleryService, bo as homeService, bp as initService, bq as layoutService, br as mediaUrl, bs as meilisearchService, bt as menuService, 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, 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, c2 as toPage, 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 AddressService, c as Approval, e as AuthService, f as AutocompleteService, B as B2bPlaced, g as B2bRole, h as B2bService, i as BannerService, j as BaseService, k as BlogService, m as CartService, n as CatalogService, p as CategoryService, q as ChatService, t as CheckoutService, w as CollectionService, x as Company, y as CompanyOrder, z as ContactService, D as CountryService, E as CouponService, G as Credit, H as CurrencyService, J as DealService, K as DemoRequestService, L as EngineRequest, M as EnquiryService, Q as FaqService, R as FeedbackService, T as GalleryService, U as HomeLayout, V as HomeLayoutSection, W as HomeService, Y as InitService, Z as Invitation, _ as LayoutCollection, $ as LayoutPage, a0 as LayoutService, a1 as Lead, a3 as MeilisearchService, a4 as Member, a7 as MenuService, aa as NewsletterService, ae as OrderService, af as PageLayout, ag as PageService, ai as PaymentMethodService, ak as PluginService, ak as PluginsService, al as PopularSearchService, am as PopularityService, aq as ProductService, ar as ProfileService, as as Quote, at as REDIRECT_GATEWAYS, au as ReelsService, av as RegionService, aw as RejectedLine, az as ReviewService, aC as SearchService, aD as SettingService, aD as SettingsService, aF as StateService, aH as StoreService, aJ as StorefrontMenu, aM as ThemeSettings, aN as ThemeSettingsResult, aO as UploadService, aP as UserService, aS as VariantService, aT as VarniCustomDesignService, aU as VarniCustomProductService, aW as VendorService, aX as WarrantyService, a_ as WishlistService, a$ as addressService, b0 as authService, b1 as autocompleteService, b2 as b2bService, b3 as bannerService, b4 as blogService, b5 as cartService, b6 as categoryService, b7 as chatService, b8 as checkoutService, b9 as collectionService, ba as contactService, bb as countryService, bc as couponService, be as currencyService, bf as dealService, bg as demoRequestService, bi as emptyPage, bj as enquiryService, bk as faqService, bl as feedbackService, bp as galleryService, bq as homeService, br as initService, bs as layoutService, bt as mediaUrl, bu as meilisearchService, bv as menuService, bx as newsletterService, by as orderService, bz as ownDomain, bA as pageService, bB as paymentMethodService, bC as pluginService, bD as pluginsService, bE as popularSearchService, bF as popularityService, bI as productService, bJ as profileService, bK as qs, bL as reelsService, bM as regionService, bN as reviewService, bO as searchService, bP as setRequestHost, bQ as settingService, bR as settingsService, bS as stateService, bT as staticStore, bU as storeForHost, bV as storeService, c4 as toPage, c7 as toStorefrontFacets, cb as uploadService, cc as userService, cd as variantService, ce as varniCustomDesignService, cf as varniCustomProductService, cg as vendorService, ch as warrantyService, ci as wishlistService } from '../index-mqcHZ96i.js';
@@ -1065,11 +1065,14 @@ var StoreFacts = class extends BaseService {
1065
1065
 
1066
1066
  // src/services/catalog.ts
1067
1067
  var PAGE_SIZE = 24;
1068
- function indexSort(sort) {
1069
- if (!sort) return void 0;
1068
+ function sortParts(sort) {
1070
1069
  const s = sort.trim();
1071
1070
  const [field, dir] = s.startsWith("-") ? [s.slice(1), "desc"] : s.includes(":") ? s.split(":") : [s, "asc"];
1072
- const d = dir === "desc" ? "desc" : "asc";
1071
+ return [field, dir === "desc" ? "desc" : "asc"];
1072
+ }
1073
+ function indexSort(sort) {
1074
+ if (!sort) return void 0;
1075
+ const [field, d] = sortParts(sort);
1073
1076
  switch (field) {
1074
1077
  case "price":
1075
1078
  return `price_minor:${d}`;
@@ -1085,6 +1088,20 @@ function indexSort(sort) {
1085
1088
  return void 0;
1086
1089
  }
1087
1090
  }
1091
+ function engineSort(sort) {
1092
+ if (!sort || NATURAL.has(sort)) return {};
1093
+ const [field, order] = sortParts(sort);
1094
+ const key = {
1095
+ price: "price",
1096
+ createdAt: "created_at",
1097
+ created_at: "created_at",
1098
+ updatedAt: "updated_at",
1099
+ updated_at: "updated_at",
1100
+ title: "title",
1101
+ name: "title"
1102
+ }[field];
1103
+ return key ? { sort: key, order } : {};
1104
+ }
1088
1105
  var NATURAL = /* @__PURE__ */ new Set([
1089
1106
  "-createdAt",
1090
1107
  "createdAt:desc",
@@ -1094,6 +1111,7 @@ var NATURAL = /* @__PURE__ */ new Set([
1094
1111
  "popularity:desc"
1095
1112
  ]);
1096
1113
  var quote = (s) => `"${s.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
1114
+ var legacyListing = /* @__PURE__ */ new Set();
1097
1115
  var CatalogService = class extends BaseService {
1098
1116
  facts = new StoreFacts(this._fetch);
1099
1117
  async queryCatalog(q) {
@@ -1103,6 +1121,39 @@ var CatalogService = class extends BaseService {
1103
1121
  const wantsRange = Number.isFinite(q.priceFrom) || Number.isFinite(q.priceTo);
1104
1122
  const sortKey = q.sort && !NATURAL.has(q.sort) ? indexSort(q.sort) : void 0;
1105
1123
  const hierarchy = q.category ? await this.facts.hierarchy(q.category) : [];
1124
+ const attr = Object.entries(q.attributes ?? {}).flatMap(
1125
+ ([handle, values]) => values.filter(Boolean).map((v) => `${handle}:${v}`)
1126
+ );
1127
+ if (q.facets && !legacyListing.has(this.engineBase())) {
1128
+ const { currency } = await this.facts.ready();
1129
+ const minor = (n) => Number.isFinite(n) ? Math.max(0, toMinor(n, currency)) : void 0;
1130
+ const env2 = await this.engine("/api/products", {
1131
+ query: {
1132
+ q: search,
1133
+ page,
1134
+ limit,
1135
+ channel: this.creds.channel,
1136
+ category: q.category,
1137
+ tag: q.tags,
1138
+ vendor: q.vendors,
1139
+ product_type: q.productTypes,
1140
+ attr,
1141
+ price_min: minor(q.priceFrom),
1142
+ price_max: minor(q.priceTo),
1143
+ ...engineSort(q.sort),
1144
+ facets: 1
1145
+ }
1146
+ });
1147
+ if (env2.meta?.facets) {
1148
+ return {
1149
+ ...toPage(env2, (p) => toProduct(p)),
1150
+ categoryHierarchy: hierarchy,
1151
+ sorted: true,
1152
+ facets: env2.meta.facets
1153
+ };
1154
+ }
1155
+ legacyListing.add(this.engineBase());
1156
+ }
1106
1157
  if ((sortKey || wantsRange) && await this.facts.pluginOn("meilisearch")) {
1107
1158
  const filters = [];
1108
1159
  if (q.category) {
@@ -1150,9 +1201,6 @@ var CatalogService = class extends BaseService {
1150
1201
  sorted
1151
1202
  };
1152
1203
  }
1153
- const attr = Object.entries(q.attributes ?? {}).flatMap(
1154
- ([handle, values]) => values.filter(Boolean).map((v) => `${handle}:${v}`)
1155
- );
1156
1204
  const env = await this.engine("/api/products", {
1157
1205
  query: { q: search, page, limit, channel: this.creds.channel, attr }
1158
1206
  });
@@ -1318,16 +1366,44 @@ var num = (v) => {
1318
1366
  const n = Number(v);
1319
1367
  return Number.isFinite(n) ? n : void 0;
1320
1368
  };
1369
+ function decodeOnce(v) {
1370
+ try {
1371
+ return decodeURIComponent(v);
1372
+ } catch {
1373
+ return v;
1374
+ }
1375
+ }
1376
+ function listParam(p, key) {
1377
+ const out = p.getAll(key).flatMap((v) => decodeOnce(v).split(",")).map((v) => v.trim()).filter(Boolean);
1378
+ return out.length ? out : void 0;
1379
+ }
1321
1380
  function attributesFrom(p) {
1322
1381
  const out = {};
1323
- for (const [key, value] of p) {
1382
+ for (const key of new Set(p.keys())) {
1324
1383
  if (!key.startsWith("attributes.")) continue;
1325
1384
  const handle = key.slice("attributes.".length);
1326
- const values = value.split(",").map((v) => decodeURIComponent(v).trim()).filter(Boolean);
1327
- if (handle && values.length) out[handle] = [...out[handle] ?? [], ...values];
1385
+ const values = listParam(p, key);
1386
+ if (handle && values) out[handle] = values;
1328
1387
  }
1329
1388
  return Object.keys(out).length ? out : void 0;
1330
1389
  }
1390
+ var counts = (values) => Object.fromEntries((values ?? []).map((v) => [v.value, v.count]));
1391
+ function toStorefrontFacets(f) {
1392
+ if (!f) return { priceStat: {}, categories: [], tags: [], allFilters: {} };
1393
+ const allFilters = {};
1394
+ const group = (key, values) => {
1395
+ if (values?.length) allFilters[key] = counts(values);
1396
+ };
1397
+ group("vendor", f.vendors);
1398
+ group("product_type", f.product_types);
1399
+ for (const [handle, values] of Object.entries(f.attributes ?? {})) group(`attributes.${handle}`, values);
1400
+ return {
1401
+ priceStat: f.price ? { min: toMajor(f.price.min), max: toMajor(f.price.max) } : {},
1402
+ categories: (f.categories ?? []).map((c) => ({ name: c.title, slug: c.slug, count: c.count })),
1403
+ tags: (f.tags ?? []).map((t) => ({ name: t.value, count: t.count })),
1404
+ allFilters
1405
+ };
1406
+ }
1331
1407
  var SearchService = class extends CatalogService {
1332
1408
  emptyResult() {
1333
1409
  return {
@@ -1335,7 +1411,7 @@ var SearchService = class extends CatalogService {
1335
1411
  count: 0,
1336
1412
  totalPages: 0,
1337
1413
  categoryHierarchy: [],
1338
- facets: { priceStat: {}, categories: [], tags: [], allFilters: {} }
1414
+ facets: toStorefrontFacets()
1339
1415
  };
1340
1416
  }
1341
1417
  async searchWithUrl(url, slug) {
@@ -1350,7 +1426,11 @@ var SearchService = class extends CatalogService {
1350
1426
  category: slug || p.get("categories")?.split(",")[0] || void 0,
1351
1427
  priceFrom: num(p.get("priceFrom")) ?? num(from ?? null),
1352
1428
  priceTo: num(p.get("priceTo")) ?? num(to ?? null),
1353
- attributes: attributesFrom(p)
1429
+ attributes: attributesFrom(p),
1430
+ tags: listParam(p, "tags"),
1431
+ vendors: listParam(p, "vendor"),
1432
+ productTypes: listParam(p, "product_type"),
1433
+ facets: true
1354
1434
  });
1355
1435
  return {
1356
1436
  data: res.data,
@@ -1358,7 +1438,7 @@ var SearchService = class extends CatalogService {
1358
1438
  totalPages: res.noOfPage,
1359
1439
  page: res.page,
1360
1440
  categoryHierarchy: res.categoryHierarchy,
1361
- facets: { priceStat: {}, categories: [], tags: [], allFilters: {} }
1441
+ facets: toStorefrontFacets(res.facets)
1362
1442
  };
1363
1443
  } catch (err) {
1364
1444
  if (err?.status === 404) return this.emptyResult();
@@ -3387,6 +3467,6 @@ function attemptKey(request) {
3387
3467
  }
3388
3468
  var b2bService = new B2bService();
3389
3469
 
3390
- export { AddressService, AuthService, AutocompleteService, B2bService, BannerService, BaseService, BlogService, CartService, CatalogService, CategoryService, ChatService, CheckoutService, CollectionService, ContactService, CountryService, CouponService, CurrencyService, DealService, DemoRequestService, EnquiryService, FaqService, FeedbackService, GalleryService, HomeService, InitService, LayoutService, MeilisearchService, MenuService, NewsletterService, 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, collectionService, contactService, countryService, couponService, currencyService, dealService, demoRequestService, emptyPage, enquiryService, faqService, feedbackService, galleryService, homeService, initService, layoutService, mediaUrl, meilisearchService, menuService, newsletterService, orderService, ownDomain, pageService, paymentMethodService, pluginService, pluginsService, popularSearchService, popularityService, productService, profileService, qs, reelsService, regionService, reviewService, searchService, setRequestHost, settingService, settingsService, stateService, staticStore, storeForHost, storeService, toPage, uploadService, userService, variantService, varniCustomDesignService, varniCustomProductService, vendorService, warrantyService, wishlistService };
3470
+ export { AddressService, AuthService, AutocompleteService, B2bService, BannerService, BaseService, BlogService, CartService, CatalogService, CategoryService, ChatService, CheckoutService, CollectionService, ContactService, CountryService, CouponService, CurrencyService, DealService, DemoRequestService, EnquiryService, FaqService, FeedbackService, GalleryService, HomeService, InitService, LayoutService, MeilisearchService, MenuService, NewsletterService, 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, collectionService, contactService, countryService, couponService, currencyService, dealService, demoRequestService, emptyPage, enquiryService, faqService, feedbackService, galleryService, homeService, initService, layoutService, mediaUrl, meilisearchService, menuService, newsletterService, orderService, ownDomain, pageService, paymentMethodService, pluginService, pluginsService, popularSearchService, popularityService, productService, profileService, qs, reelsService, regionService, reviewService, searchService, setRequestHost, settingService, settingsService, stateService, staticStore, storeForHost, storeService, toPage, toStorefrontFacets, uploadService, userService, variantService, varniCustomDesignService, varniCustomProductService, vendorService, warrantyService, wishlistService };
3391
3471
  //# sourceMappingURL=index.js.map
3392
3472
  //# sourceMappingURL=index.js.map