@misiki/gocommerce-connector 0.3.1 → 0.4.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 +28 -0
- package/dist/{index-D8lNRhqJ.d.cts → index-iPG0fxzc.d.cts} +31 -1
- package/dist/{index-D8lNRhqJ.d.ts → index-iPG0fxzc.d.ts} +31 -1
- package/dist/index.cjs +38 -3
- 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 +37 -4
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +38 -3
- 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 +37 -4
- package/dist/services/index.js.map +1 -1
- package/package.json +2 -1
|
@@ -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 HomeService, V as InitService, W as Invitation, X as Lead, Z as MeilisearchService, _ as Member, a1 as MenuService, a4 as NewsletterService, a8 as OrderService, a9 as PageService, ab as PaymentMethodService, ad as PluginService, ad as PluginsService, ae as PopularSearchService, af as PopularityService, ai as ProductService, aj as ProfileService, ak as Quote, al as REDIRECT_GATEWAYS, am as ReelsService, an as RegionService, ao as RejectedLine, ar as ReviewService, au as SearchService, av as SettingService, av as SettingsService, ax as StateService, ay as StoreService, aA as StorefrontMenu, aD as UploadService, aE as UserService, aH as VariantService, aI as VarniCustomDesignService, aJ as VarniCustomProductService, aL as VendorService, aM as WarrantyService, aP as WishlistService, aQ as addressService, aR as authService, aS as autocompleteService, aT as b2bService, aU as bannerService, aV as blogService, aW as cartService, aX as categoryService, aY as chatService, aZ as checkoutService, a_ as collectionService, a$ as contactService, b0 as countryService, b1 as couponService, b3 as currencyService, b4 as dealService, b5 as demoRequestService, b7 as emptyPage, b8 as enquiryService, b9 as faqService, ba as feedbackService, be as galleryService, bf as homeService, bg as initService, bh as mediaUrl, bi as meilisearchService, bj as menuService, bl as newsletterService, bm as orderService, bn as pageService, bo as paymentMethodService, bp as pluginService, bq as pluginsService, br as popularSearchService, bs as popularityService, bv as productService, bw as profileService, bx as qs, by as reelsService, bz as regionService, bA as reviewService, bB as searchService, bC as
|
|
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 HomeService, V as InitService, W as Invitation, X as Lead, Z as MeilisearchService, _ as Member, a1 as MenuService, a4 as NewsletterService, a8 as OrderService, a9 as PageService, ab as PaymentMethodService, ad as PluginService, ad as PluginsService, ae as PopularSearchService, af as PopularityService, ai as ProductService, aj as ProfileService, ak as Quote, al as REDIRECT_GATEWAYS, am as ReelsService, an as RegionService, ao as RejectedLine, ar as ReviewService, au as SearchService, av as SettingService, av as SettingsService, ax as StateService, ay as StoreService, aA as StorefrontMenu, aD as UploadService, aE as UserService, aH as VariantService, aI as VarniCustomDesignService, aJ as VarniCustomProductService, aL as VendorService, aM as WarrantyService, aP as WishlistService, aQ as addressService, aR as authService, aS as autocompleteService, aT as b2bService, aU as bannerService, aV as blogService, aW as cartService, aX as categoryService, aY as chatService, aZ as checkoutService, a_ as collectionService, a$ as contactService, b0 as countryService, b1 as couponService, b3 as currencyService, b4 as dealService, b5 as demoRequestService, b7 as emptyPage, b8 as enquiryService, b9 as faqService, ba as feedbackService, be as galleryService, bf as homeService, bg as initService, bh as mediaUrl, bi as meilisearchService, bj as menuService, bl as newsletterService, bm as orderService, bn as pageService, bo as paymentMethodService, bp as pluginService, bq as pluginsService, br as popularSearchService, bs as popularityService, bv as productService, bw as profileService, bx as qs, by as reelsService, bz as regionService, bA as reviewService, bB as searchService, bC as setRequestHost, bD as settingService, bE as settingsService, bF as stateService, bG as staticStore, bH as storeForHost, bI as storeService, bT as toPage, bZ as uploadService, b_ as userService, b$ as variantService, c0 as varniCustomDesignService, c1 as varniCustomProductService, c2 as vendorService, c3 as warrantyService, c4 as wishlistService } from '../index-iPG0fxzc.cjs';
|
package/dist/services/index.d.ts
CHANGED
|
@@ -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 HomeService, V as InitService, W as Invitation, X as Lead, Z as MeilisearchService, _ as Member, a1 as MenuService, a4 as NewsletterService, a8 as OrderService, a9 as PageService, ab as PaymentMethodService, ad as PluginService, ad as PluginsService, ae as PopularSearchService, af as PopularityService, ai as ProductService, aj as ProfileService, ak as Quote, al as REDIRECT_GATEWAYS, am as ReelsService, an as RegionService, ao as RejectedLine, ar as ReviewService, au as SearchService, av as SettingService, av as SettingsService, ax as StateService, ay as StoreService, aA as StorefrontMenu, aD as UploadService, aE as UserService, aH as VariantService, aI as VarniCustomDesignService, aJ as VarniCustomProductService, aL as VendorService, aM as WarrantyService, aP as WishlistService, aQ as addressService, aR as authService, aS as autocompleteService, aT as b2bService, aU as bannerService, aV as blogService, aW as cartService, aX as categoryService, aY as chatService, aZ as checkoutService, a_ as collectionService, a$ as contactService, b0 as countryService, b1 as couponService, b3 as currencyService, b4 as dealService, b5 as demoRequestService, b7 as emptyPage, b8 as enquiryService, b9 as faqService, ba as feedbackService, be as galleryService, bf as homeService, bg as initService, bh as mediaUrl, bi as meilisearchService, bj as menuService, bl as newsletterService, bm as orderService, bn as pageService, bo as paymentMethodService, bp as pluginService, bq as pluginsService, br as popularSearchService, bs as popularityService, bv as productService, bw as profileService, bx as qs, by as reelsService, bz as regionService, bA as reviewService, bB as searchService, bC as
|
|
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 HomeService, V as InitService, W as Invitation, X as Lead, Z as MeilisearchService, _ as Member, a1 as MenuService, a4 as NewsletterService, a8 as OrderService, a9 as PageService, ab as PaymentMethodService, ad as PluginService, ad as PluginsService, ae as PopularSearchService, af as PopularityService, ai as ProductService, aj as ProfileService, ak as Quote, al as REDIRECT_GATEWAYS, am as ReelsService, an as RegionService, ao as RejectedLine, ar as ReviewService, au as SearchService, av as SettingService, av as SettingsService, ax as StateService, ay as StoreService, aA as StorefrontMenu, aD as UploadService, aE as UserService, aH as VariantService, aI as VarniCustomDesignService, aJ as VarniCustomProductService, aL as VendorService, aM as WarrantyService, aP as WishlistService, aQ as addressService, aR as authService, aS as autocompleteService, aT as b2bService, aU as bannerService, aV as blogService, aW as cartService, aX as categoryService, aY as chatService, aZ as checkoutService, a_ as collectionService, a$ as contactService, b0 as countryService, b1 as couponService, b3 as currencyService, b4 as dealService, b5 as demoRequestService, b7 as emptyPage, b8 as enquiryService, b9 as faqService, ba as feedbackService, be as galleryService, bf as homeService, bg as initService, bh as mediaUrl, bi as meilisearchService, bj as menuService, bl as newsletterService, bm as orderService, bn as pageService, bo as paymentMethodService, bp as pluginService, bq as pluginsService, br as popularSearchService, bs as popularityService, bv as productService, bw as profileService, bx as qs, by as reelsService, bz as regionService, bA as reviewService, bB as searchService, bC as setRequestHost, bD as settingService, bE as settingsService, bF as stateService, bG as staticStore, bH as storeForHost, bI as storeService, bT as toPage, bZ as uploadService, b_ as userService, b$ as variantService, c0 as varniCustomDesignService, c1 as varniCustomProductService, c2 as vendorService, c3 as warrantyService, c4 as wishlistService } from '../index-iPG0fxzc.js';
|
package/dist/services/index.js
CHANGED
|
@@ -210,6 +210,17 @@ var BaseService = class _BaseService {
|
|
|
210
210
|
get creds() {
|
|
211
211
|
return _BaseService._credentials;
|
|
212
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* The store this call is for: the request host's subdomain under
|
|
215
|
+
* `baseDomain`, else the static `store`. Read per call, never stored on the
|
|
216
|
+
* instance, because the server shares one process (and one credentials
|
|
217
|
+
* object) across every concurrent request and each may be for a different host.
|
|
218
|
+
*/
|
|
219
|
+
get store() {
|
|
220
|
+
const { baseDomain, store } = this.creds;
|
|
221
|
+
const host = typeof window !== "undefined" ? window.location?.hostname : requestHost?.();
|
|
222
|
+
return storeForHost(host, baseDomain) ?? store;
|
|
223
|
+
}
|
|
213
224
|
/**
|
|
214
225
|
* The engine's base URL from wherever this code runs. In the browser a
|
|
215
226
|
* configured proxy path wins, because the engine answers no CORS preflight.
|
|
@@ -243,7 +254,8 @@ var BaseService = class _BaseService {
|
|
|
243
254
|
const url = this.engineURL(path, lang ? { lang, ...req.query } : req.query);
|
|
244
255
|
const headers = { Accept: "application/json", ...req.headers };
|
|
245
256
|
if (req.body !== void 0) headers["Content-Type"] = "application/json";
|
|
246
|
-
|
|
257
|
+
const store = this.store;
|
|
258
|
+
if (store) headers["X-Store"] = store;
|
|
247
259
|
if (req.auth) {
|
|
248
260
|
const token = sessionToken();
|
|
249
261
|
if (!token) throw new GoCommerceError("Please sign in to continue.", 401, "unauthorized");
|
|
@@ -345,6 +357,18 @@ var BaseService = class _BaseService {
|
|
|
345
357
|
return body;
|
|
346
358
|
}
|
|
347
359
|
};
|
|
360
|
+
var requestHost;
|
|
361
|
+
function setRequestHost(fn) {
|
|
362
|
+
requestHost = fn;
|
|
363
|
+
}
|
|
364
|
+
function storeForHost(host, baseDomain) {
|
|
365
|
+
if (!host || !baseDomain) return void 0;
|
|
366
|
+
const h = host.toLowerCase().replace(/\.$/, "").replace(/:\d+$/, "");
|
|
367
|
+
const suffix = "." + baseDomain.toLowerCase().replace(/^\.+/, "").replace(/\.$/, "");
|
|
368
|
+
if (!h.endsWith(suffix)) return void 0;
|
|
369
|
+
const slug = h.slice(0, -suffix.length);
|
|
370
|
+
return slug && !slug.includes(".") ? slug : void 0;
|
|
371
|
+
}
|
|
348
372
|
var unreachable = (base, cause) => new GoCommerceError(`Could not reach the commerce engine at ${base}: ${cause?.message ?? cause}`, 0);
|
|
349
373
|
function qs(query) {
|
|
350
374
|
if (!query) return "";
|
|
@@ -946,7 +970,7 @@ function remember(key, load, ttl = TTL_MS) {
|
|
|
946
970
|
// src/services/facts.ts
|
|
947
971
|
var StoreFacts = class extends BaseService {
|
|
948
972
|
key(name) {
|
|
949
|
-
return `${this.engineBase()}|${this.
|
|
973
|
+
return `${this.engineBase()}|${this.store ?? ""}|${name}`;
|
|
950
974
|
}
|
|
951
975
|
/** Enabled plugins by key. A module that is not installed has no key here. */
|
|
952
976
|
plugins() {
|
|
@@ -2376,7 +2400,7 @@ var MenuService = class extends BaseService {
|
|
|
2376
2400
|
/** The header and footer menus, or `null` when the module is not there. Cached: a menu is store-level. */
|
|
2377
2401
|
async engineMenus() {
|
|
2378
2402
|
if (!await this.facts.pluginOn("navigation")) return null;
|
|
2379
|
-
return remember(`${this.engineBase()}|${this.
|
|
2403
|
+
return remember(`${this.engineBase()}|${this.store ?? ""}|menus`, async () => {
|
|
2380
2404
|
const out = [];
|
|
2381
2405
|
for (const handle of ["header", "footer"]) {
|
|
2382
2406
|
try {
|
|
@@ -2413,6 +2437,7 @@ var NewsletterService = class extends BaseService {
|
|
|
2413
2437
|
var newsletterService = new NewsletterService();
|
|
2414
2438
|
|
|
2415
2439
|
// src/services/store-service.ts
|
|
2440
|
+
var isStoreMissing = (err) => err instanceof GoCommerceError && err.status === 404 && (err.code === "store_not_found" || /store not found|no such store/i.test(err.message));
|
|
2416
2441
|
function symbolFor(code) {
|
|
2417
2442
|
try {
|
|
2418
2443
|
const part = new Intl.NumberFormat("en", { style: "currency", currency: code }).formatToParts(0).find((p) => p.type === "currency");
|
|
@@ -2425,6 +2450,14 @@ var StoreService = class extends BaseService {
|
|
|
2425
2450
|
facts = new StoreFacts(this._fetch);
|
|
2426
2451
|
async getStoreByIdOrDomain(_args = {}) {
|
|
2427
2452
|
const base = await readStaticStore();
|
|
2453
|
+
const store = this.store;
|
|
2454
|
+
if (store) {
|
|
2455
|
+
await this.facts.plugins().catch((err) => {
|
|
2456
|
+
if (isStoreMissing(err)) {
|
|
2457
|
+
throw new GoCommerceError(`store not found: no store "${store}" on this engine`, 404, "store_not_found");
|
|
2458
|
+
}
|
|
2459
|
+
});
|
|
2460
|
+
}
|
|
2428
2461
|
const live = await this.live().catch(() => ({}));
|
|
2429
2462
|
return { ...base, ...live, id: base.id || "gocommerce" };
|
|
2430
2463
|
}
|
|
@@ -3060,6 +3093,6 @@ function attemptKey(request) {
|
|
|
3060
3093
|
}
|
|
3061
3094
|
var b2bService = new B2bService();
|
|
3062
3095
|
|
|
3063
|
-
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, 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, mediaUrl, meilisearchService, menuService, newsletterService, orderService, pageService, paymentMethodService, pluginService, pluginsService, popularSearchService, popularityService, productService, profileService, qs, reelsService, regionService, reviewService, searchService, settingService, settingsService, stateService, staticStore, storeService, toPage, uploadService, userService, variantService, varniCustomDesignService, varniCustomProductService, vendorService, warrantyService, wishlistService };
|
|
3096
|
+
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, 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, mediaUrl, meilisearchService, menuService, newsletterService, orderService, 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 };
|
|
3064
3097
|
//# sourceMappingURL=index.js.map
|
|
3065
3098
|
//# sourceMappingURL=index.js.map
|