@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/README.md +3 -2
- package/dist/{index-DHKyh3CU.d.cts → index-C0CR05Q4.d.cts} +77 -66
- package/dist/{index-DHKyh3CU.d.ts → index-C0CR05Q4.d.ts} +77 -66
- package/dist/index.cjs +61 -41
- 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 +61 -41
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +61 -41
- 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 +61 -41
- package/dist/services/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export { b as AddressService, d as Approval, f as AuthService, g as AutocompleteService, B as B2bPlaced, h as B2bRole, i as B2bService, j as BannerService, k as BaseService, l as BlogService, o as CartService, p as CatalogService, r as CategoryService, s as ChatService, v as CheckoutService, y as CollectionService, z as Company, D as CompanyOrder, E as ContactService, F as CountryService, G as CouponService, I as Credit, J as CurrencyService, L as DealService, M as DemoRequestService, N as EngineRequest, O as EnquiryService, S as FaqService, T as FeedbackService, U as FooterSettings, X as GalleryService, Y as HeaderSettings, Z as HomeLayout, _ as HomeLayoutSection, $ as HomeService, a1 as InitService, a2 as Invitation, a3 as LayoutCollection, a4 as LayoutPage, a5 as LayoutService, a6 as Lead, a8 as MeilisearchService, a9 as Member, ac as MenuService, af as NewsletterService, aj as OrderService, ak as PageLayout, al as PageService, an as PaymentMethodService, ap as PluginService, ap as PluginsService, aq as PopularSearchService, ar as PopularityService, aw as ProductService, ax as ProfileService, ay as Quote, az as REDIRECT_GATEWAYS, aA as ReelsService, aB as RegionService, aC as RejectedLine, aF as ReviewService, aI as SearchService, aJ as SettingService, aJ as SettingsService, aL as SiteChrome, aM as SiteFooter, aN as SiteHeader, aO as SocialLink, aP as StateService, aR as StoreService, aT as StorefrontMenu, aW as ThemeSettings, aX as ThemeSettingsResult, aY as UploadService, aZ as UserService, b0 as VariantService, b1 as VarniCustomDesignService, b2 as VarniCustomProductService, b4 as VendorService, b5 as WarrantyService, 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, bo as currencyService, bp as dealService, bq as demoRequestService, bs as emptyPage, bt as enquiryService, bu as faqService, bv as feedbackService, bz as galleryService, bA as homeService, bB as initService, bC as layoutService, bD as mediaUrl, bE as meilisearchService, bF as menuService, 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, bS as productService, 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, ci as toPage, cl as toStorefrontFacets, 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-
|
|
1
|
+
export { b as AddressService, d as Approval, f as AuthService, g as AutocompleteService, B as B2bPlaced, h as B2bRole, i as B2bService, j as BannerService, k as BaseService, l as BlogService, o as CartService, p as CatalogService, r as CategoryService, s as ChatService, v as CheckoutService, y as CollectionService, z as Company, D as CompanyOrder, E as ContactService, F as CountryService, G as CouponService, I as Credit, J as CurrencyService, L as DealService, M as DemoRequestService, N as EngineRequest, O as EnquiryService, S as FaqService, T as FeedbackService, U as FooterSettings, X as GalleryService, Y as HeaderSettings, Z as HomeLayout, _ as HomeLayoutSection, $ as HomeService, a1 as InitService, a2 as Invitation, a3 as LayoutCollection, a4 as LayoutPage, a5 as LayoutService, a6 as Lead, a8 as MeilisearchService, a9 as Member, ac as MenuService, af as NewsletterService, aj as OrderService, ak as PageLayout, al as PageService, an as PaymentMethodService, ap as PluginService, ap as PluginsService, aq as PopularSearchService, ar as PopularityService, aw as ProductService, ax as ProfileService, ay as Quote, az as REDIRECT_GATEWAYS, aA as ReelsService, aB as RegionService, aC as RejectedLine, aF as ReviewService, aI as SearchService, aJ as SettingService, aJ as SettingsService, aL as SiteChrome, aM as SiteFooter, aN as SiteHeader, aO as SocialLink, aP as StateService, aR as StoreService, aT as StorefrontMenu, aW as ThemeSettings, aX as ThemeSettingsResult, aY as UploadService, aZ as UserService, b0 as VariantService, b1 as VarniCustomDesignService, b2 as VarniCustomProductService, b4 as VendorService, b5 as WarrantyService, 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, bo as currencyService, bp as dealService, bq as demoRequestService, bs as emptyPage, bt as enquiryService, bu as faqService, bv as feedbackService, bz as galleryService, bA as homeService, bB as initService, bC as layoutService, bD as mediaUrl, bE as meilisearchService, bF as menuService, 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, bS as productService, 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, ci as toPage, cl as toStorefrontFacets, 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';
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { b as AddressService, d as Approval, f as AuthService, g as AutocompleteService, B as B2bPlaced, h as B2bRole, i as B2bService, j as BannerService, k as BaseService, l as BlogService, o as CartService, p as CatalogService, r as CategoryService, s as ChatService, v as CheckoutService, y as CollectionService, z as Company, D as CompanyOrder, E as ContactService, F as CountryService, G as CouponService, I as Credit, J as CurrencyService, L as DealService, M as DemoRequestService, N as EngineRequest, O as EnquiryService, S as FaqService, T as FeedbackService, U as FooterSettings, X as GalleryService, Y as HeaderSettings, Z as HomeLayout, _ as HomeLayoutSection, $ as HomeService, a1 as InitService, a2 as Invitation, a3 as LayoutCollection, a4 as LayoutPage, a5 as LayoutService, a6 as Lead, a8 as MeilisearchService, a9 as Member, ac as MenuService, af as NewsletterService, aj as OrderService, ak as PageLayout, al as PageService, an as PaymentMethodService, ap as PluginService, ap as PluginsService, aq as PopularSearchService, ar as PopularityService, aw as ProductService, ax as ProfileService, ay as Quote, az as REDIRECT_GATEWAYS, aA as ReelsService, aB as RegionService, aC as RejectedLine, aF as ReviewService, aI as SearchService, aJ as SettingService, aJ as SettingsService, aL as SiteChrome, aM as SiteFooter, aN as SiteHeader, aO as SocialLink, aP as StateService, aR as StoreService, aT as StorefrontMenu, aW as ThemeSettings, aX as ThemeSettingsResult, aY as UploadService, aZ as UserService, b0 as VariantService, b1 as VarniCustomDesignService, b2 as VarniCustomProductService, b4 as VendorService, b5 as WarrantyService, 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, bo as currencyService, bp as dealService, bq as demoRequestService, bs as emptyPage, bt as enquiryService, bu as faqService, bv as feedbackService, bz as galleryService, bA as homeService, bB as initService, bC as layoutService, bD as mediaUrl, bE as meilisearchService, bF as menuService, 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, bS as productService, 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, ci as toPage, cl as toStorefrontFacets, 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-
|
|
1
|
+
export { b as AddressService, d as Approval, f as AuthService, g as AutocompleteService, B as B2bPlaced, h as B2bRole, i as B2bService, j as BannerService, k as BaseService, l as BlogService, o as CartService, p as CatalogService, r as CategoryService, s as ChatService, v as CheckoutService, y as CollectionService, z as Company, D as CompanyOrder, E as ContactService, F as CountryService, G as CouponService, I as Credit, J as CurrencyService, L as DealService, M as DemoRequestService, N as EngineRequest, O as EnquiryService, S as FaqService, T as FeedbackService, U as FooterSettings, X as GalleryService, Y as HeaderSettings, Z as HomeLayout, _ as HomeLayoutSection, $ as HomeService, a1 as InitService, a2 as Invitation, a3 as LayoutCollection, a4 as LayoutPage, a5 as LayoutService, a6 as Lead, a8 as MeilisearchService, a9 as Member, ac as MenuService, af as NewsletterService, aj as OrderService, ak as PageLayout, al as PageService, an as PaymentMethodService, ap as PluginService, ap as PluginsService, aq as PopularSearchService, ar as PopularityService, aw as ProductService, ax as ProfileService, ay as Quote, az as REDIRECT_GATEWAYS, aA as ReelsService, aB as RegionService, aC as RejectedLine, aF as ReviewService, aI as SearchService, aJ as SettingService, aJ as SettingsService, aL as SiteChrome, aM as SiteFooter, aN as SiteHeader, aO as SocialLink, aP as StateService, aR as StoreService, aT as StorefrontMenu, aW as ThemeSettings, aX as ThemeSettingsResult, aY as UploadService, aZ as UserService, b0 as VariantService, b1 as VarniCustomDesignService, b2 as VarniCustomProductService, b4 as VendorService, b5 as WarrantyService, 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, bo as currencyService, bp as dealService, bq as demoRequestService, bs as emptyPage, bt as enquiryService, bu as faqService, bv as feedbackService, bz as galleryService, bA as homeService, bB as initService, bC as layoutService, bD as mediaUrl, bE as meilisearchService, bF as menuService, 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, bS as productService, 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, ci as toPage, cl as toStorefrontFacets, 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';
|
package/dist/services/index.js
CHANGED
|
@@ -1195,14 +1195,17 @@ var CatalogService = class extends BaseService {
|
|
|
1195
1195
|
const attr = Object.entries(q.attributes ?? {}).flatMap(
|
|
1196
1196
|
([handle, values]) => values.filter(Boolean).map((v) => `${handle}:${v}`)
|
|
1197
1197
|
);
|
|
1198
|
-
|
|
1198
|
+
const refined = attr.length > 0 || !!(q.tags?.length || q.vendors?.length || q.productTypes?.length);
|
|
1199
|
+
const triedIndex = !!search && !refined;
|
|
1200
|
+
const counted = q.facets && !legacyListing.has(this.engineBase());
|
|
1201
|
+
const facetListing = async (page2, limit2) => {
|
|
1199
1202
|
const { currency } = await this.facts.ready();
|
|
1200
1203
|
const minor = (n) => Number.isFinite(n) ? Math.max(0, toMinor(n, currency)) : void 0;
|
|
1201
|
-
|
|
1204
|
+
return this.engine("/api/products", {
|
|
1202
1205
|
query: {
|
|
1203
1206
|
q: search,
|
|
1204
|
-
page,
|
|
1205
|
-
limit,
|
|
1207
|
+
page: page2,
|
|
1208
|
+
limit: limit2,
|
|
1206
1209
|
channel: this.creds.channel,
|
|
1207
1210
|
category: q.category,
|
|
1208
1211
|
tag: q.tags,
|
|
@@ -1215,6 +1218,16 @@ var CatalogService = class extends BaseService {
|
|
|
1215
1218
|
facets: 1
|
|
1216
1219
|
}
|
|
1217
1220
|
});
|
|
1221
|
+
};
|
|
1222
|
+
if (triedIndex && await this.facts.pluginOn("meilisearch")) {
|
|
1223
|
+
const [found, rail] = await Promise.all([
|
|
1224
|
+
this.fromIndex(q, { page, limit, search, sortKey, wantsRange, hierarchy }),
|
|
1225
|
+
counted ? facetListing(1, 1).catch(() => null) : null
|
|
1226
|
+
]);
|
|
1227
|
+
if (found) return rail?.meta?.facets ? { ...found, facets: rail.meta.facets } : found;
|
|
1228
|
+
}
|
|
1229
|
+
if (counted) {
|
|
1230
|
+
const env2 = await facetListing(page, limit);
|
|
1218
1231
|
if (env2.meta?.facets) {
|
|
1219
1232
|
return {
|
|
1220
1233
|
...toPage(env2, (p) => toProduct(p)),
|
|
@@ -1225,39 +1238,9 @@ var CatalogService = class extends BaseService {
|
|
|
1225
1238
|
}
|
|
1226
1239
|
legacyListing.add(this.engineBase());
|
|
1227
1240
|
}
|
|
1228
|
-
if ((sortKey || wantsRange)
|
|
1229
|
-
const
|
|
1230
|
-
if (
|
|
1231
|
-
const names = (await this.facts.subtree(q.category).catch(() => [])).map(
|
|
1232
|
-
(c) => quote(c.full_name)
|
|
1233
|
-
);
|
|
1234
|
-
if (!names.length) return { ...emptyCatalog(limit), categoryHierarchy: hierarchy, sorted: true };
|
|
1235
|
-
filters.push(`category IN [${names.join(", ")}]`);
|
|
1236
|
-
}
|
|
1237
|
-
if (wantsRange) {
|
|
1238
|
-
const { currency } = await this.facts.ready();
|
|
1239
|
-
if (Number.isFinite(q.priceFrom)) filters.push(`price_minor >= ${toMinor(q.priceFrom, currency)}`);
|
|
1240
|
-
if (Number.isFinite(q.priceTo)) filters.push(`price_minor <= ${toMinor(q.priceTo, currency)}`);
|
|
1241
|
-
}
|
|
1242
|
-
const res = await this.data("/x/meilisearch/search", {
|
|
1243
|
-
query: {
|
|
1244
|
-
q: search ?? "",
|
|
1245
|
-
limit,
|
|
1246
|
-
offset: (page - 1) * limit,
|
|
1247
|
-
filter: filters.join(" AND ") || void 0,
|
|
1248
|
-
sort: sortKey
|
|
1249
|
-
}
|
|
1250
|
-
});
|
|
1251
|
-
const total = res.total ?? 0;
|
|
1252
|
-
return {
|
|
1253
|
-
data: (res.hits ?? []).map(fromSearchDoc),
|
|
1254
|
-
count: total,
|
|
1255
|
-
pageSize: limit,
|
|
1256
|
-
noOfPage: Math.max(1, Math.ceil(total / limit)),
|
|
1257
|
-
page,
|
|
1258
|
-
categoryHierarchy: hierarchy,
|
|
1259
|
-
sorted: true
|
|
1260
|
-
};
|
|
1241
|
+
if (!triedIndex && (sortKey || wantsRange)) {
|
|
1242
|
+
const found = await this.fromIndex(q, { page, limit, search, sortKey, wantsRange, hierarchy });
|
|
1243
|
+
if (found) return found;
|
|
1261
1244
|
}
|
|
1262
1245
|
const sorted = !sortKey && !wantsRange;
|
|
1263
1246
|
if (q.category && !search) {
|
|
@@ -1277,6 +1260,45 @@ var CatalogService = class extends BaseService {
|
|
|
1277
1260
|
});
|
|
1278
1261
|
return { ...toPage(env, (p) => toProduct(p)), categoryHierarchy: hierarchy, sorted };
|
|
1279
1262
|
}
|
|
1263
|
+
/**
|
|
1264
|
+
* The shelf from the Meilisearch module, or null when the store has it off,
|
|
1265
|
+
* sells through a channel, finds nothing for the words, or it cannot answer (Meilisearch down: the engine says `unavailable`), so
|
|
1266
|
+
* the caller asks the database instead of showing the shopper an error.
|
|
1267
|
+
*/
|
|
1268
|
+
async fromIndex(q, o) {
|
|
1269
|
+
if (this.creds.channel || !await this.facts.pluginOn("meilisearch")) return null;
|
|
1270
|
+
const filters = [];
|
|
1271
|
+
if (q.category) {
|
|
1272
|
+
const names = (await this.facts.subtree(q.category).catch(() => [])).map((c) => quote(c.full_name));
|
|
1273
|
+
if (!names.length) return { ...emptyCatalog(o.limit), categoryHierarchy: o.hierarchy, sorted: true };
|
|
1274
|
+
filters.push(`category IN [${names.join(", ")}]`);
|
|
1275
|
+
}
|
|
1276
|
+
if (o.wantsRange) {
|
|
1277
|
+
const { currency } = await this.facts.ready();
|
|
1278
|
+
if (Number.isFinite(q.priceFrom)) filters.push(`price_minor >= ${toMinor(q.priceFrom, currency)}`);
|
|
1279
|
+
if (Number.isFinite(q.priceTo)) filters.push(`price_minor <= ${toMinor(q.priceTo, currency)}`);
|
|
1280
|
+
}
|
|
1281
|
+
const res = await this.data("/x/meilisearch/search", {
|
|
1282
|
+
query: {
|
|
1283
|
+
q: o.search ?? "",
|
|
1284
|
+
limit: o.limit,
|
|
1285
|
+
offset: (o.page - 1) * o.limit,
|
|
1286
|
+
filter: filters.join(" AND ") || void 0,
|
|
1287
|
+
sort: o.sortKey
|
|
1288
|
+
}
|
|
1289
|
+
}).catch(() => null);
|
|
1290
|
+
if (!res || res.unavailable || o.search && !res.hits?.length) return null;
|
|
1291
|
+
const total = res.total ?? 0;
|
|
1292
|
+
return {
|
|
1293
|
+
data: (res.hits ?? []).map(fromSearchDoc),
|
|
1294
|
+
count: total,
|
|
1295
|
+
pageSize: o.limit,
|
|
1296
|
+
noOfPage: Math.max(1, Math.ceil(total / o.limit)),
|
|
1297
|
+
page: o.page,
|
|
1298
|
+
categoryHierarchy: o.hierarchy,
|
|
1299
|
+
sorted: true
|
|
1300
|
+
};
|
|
1301
|
+
}
|
|
1280
1302
|
};
|
|
1281
1303
|
function emptyCatalog(limit = PAGE_SIZE) {
|
|
1282
1304
|
return { data: [], count: 0, pageSize: limit, noOfPage: 0, page: 1 };
|
|
@@ -1574,10 +1596,8 @@ var MeilisearchService = class extends CatalogService {
|
|
|
1574
1596
|
async searchAutoComplete({ query, search, limit = 8 } = {}) {
|
|
1575
1597
|
const q = (query ?? search ?? "").trim();
|
|
1576
1598
|
if (!q) return { data: [] };
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
return { data: (res.hits ?? []).map(fromSearchDoc) };
|
|
1580
|
-
}
|
|
1599
|
+
const found = await this.fromIndex({}, { page: 1, limit, search: q, wantsRange: false, hierarchy: [] });
|
|
1600
|
+
if (found) return { data: found.data };
|
|
1581
1601
|
const rows = await this.data("/api/products", { query: { q, limit, channel: this.creds.channel } }) ?? [];
|
|
1582
1602
|
return { data: rows.map((p) => toProduct(p)) };
|
|
1583
1603
|
}
|