@misiki/gocommerce-connector 0.22.0 → 0.24.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 +4 -1
- package/dist/{index-CIhSE2qR.d.cts → index-BWg1KptA.d.cts} +278 -3
- package/dist/{index-CIhSE2qR.d.ts → index-BWg1KptA.d.ts} +278 -3
- package/dist/index.cjs +113 -13
- 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 +110 -14
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +113 -13
- 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 +110 -14
- 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,
|
|
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, N as CustomizerEditor, O as CustomizerFile, Q as CustomizerSavedDesign, R as CustomizerService, U as DealService, V as DemoRequestService, W as EngineRequest, X as EnquiryService, $ as FaqService, a0 as FeedbackService, a1 as FooterSettings, a4 as GalleryService, a6 as GoogleReview, a7 as GoogleReviewService, a8 as GoogleReviews, aa as HeaderSettings, ab as HomeLayout, ac as HomeLayoutSection, ad as HomeService, af as InitService, ag as Invitation, ah as LayoutCollection, ai as LayoutPage, aj as LayoutService, ak as Lead, am as MeilisearchService, an as Member, aq as MenuService, at as NewsletterService, ay as OrderService, az as PageLayout, aA as PageService, aC as PaymentMethodService, aE as PluginService, aE as PluginsService, aF as PopularSearchService, aG as PopularityService, aL as ProductService, aM as ProfileService, aN as Quote, aO as REDIRECT_GATEWAYS, aP as ReelsService, aQ as RegionService, aR as RejectedLine, aU as ReviewService, aX as SearchService, aY as SettingService, aY as SettingsService, a_ as SiteChrome, a$ as SiteFooter, b0 as SiteHeader, b1 as SocialLink, b2 as StateService, b4 as StoreService, b6 as StorefrontMenu, b9 as ThemeSettings, ba as ThemeSettingsResult, bb as UploadService, bc as UserService, bf as VariantService, bg as VarniCustomDesignService, bh as VarniCustomProductService, bj as VendorService, bk as WarrantyService, bl as WhatsappConsent, bm as WhatsappConsentOffer, bn as WhatsappService, bq as WishlistService, br as addressService, bs as authService, bt as autocompleteService, bu as b2bService, bv as bannerService, bw as blogService, bx as cartService, by as categoryService, bz as chatService, bA as checkoutService, bB as collectionService, bC as contactService, bD as countryService, bE as couponService, bG as currencyService, bH as customizerService, bI as dealService, bJ as demoRequestService, bL as emptyPage, bM as enquiryService, bN as faqService, bO as feedbackService, bS as galleryService, bT as googleReviewService, bU as homeService, bV as initService, bW as layoutService, bX as mediaUrl, bY as meilisearchService, bZ as menuService, b$ as newsletterService, c0 as orderService, c1 as ownDomain, c2 as pageService, c3 as paymentMethodService, c4 as pluginService, c5 as pluginsService, c6 as popularSearchService, c7 as popularityService, ca as productService, cc as profileService, cd as qs, ce as reelsService, cf as regionService, cg as reviewService, ch as searchService, ci as setRequestHost, cj as settingService, ck as settingsService, cl as stateService, cm as staticStore, cn as storeForHost, co as storeService, cC as toPage, cF as toStorefrontFacets, cJ as uploadService, cK as userService, cL as variantService, cM as varniCustomDesignService, cN as varniCustomProductService, cO as vendorService, cP as warrantyService, cQ as whatsappService, cR as wishlistService } from '../index-BWg1KptA.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,
|
|
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, N as CustomizerEditor, O as CustomizerFile, Q as CustomizerSavedDesign, R as CustomizerService, U as DealService, V as DemoRequestService, W as EngineRequest, X as EnquiryService, $ as FaqService, a0 as FeedbackService, a1 as FooterSettings, a4 as GalleryService, a6 as GoogleReview, a7 as GoogleReviewService, a8 as GoogleReviews, aa as HeaderSettings, ab as HomeLayout, ac as HomeLayoutSection, ad as HomeService, af as InitService, ag as Invitation, ah as LayoutCollection, ai as LayoutPage, aj as LayoutService, ak as Lead, am as MeilisearchService, an as Member, aq as MenuService, at as NewsletterService, ay as OrderService, az as PageLayout, aA as PageService, aC as PaymentMethodService, aE as PluginService, aE as PluginsService, aF as PopularSearchService, aG as PopularityService, aL as ProductService, aM as ProfileService, aN as Quote, aO as REDIRECT_GATEWAYS, aP as ReelsService, aQ as RegionService, aR as RejectedLine, aU as ReviewService, aX as SearchService, aY as SettingService, aY as SettingsService, a_ as SiteChrome, a$ as SiteFooter, b0 as SiteHeader, b1 as SocialLink, b2 as StateService, b4 as StoreService, b6 as StorefrontMenu, b9 as ThemeSettings, ba as ThemeSettingsResult, bb as UploadService, bc as UserService, bf as VariantService, bg as VarniCustomDesignService, bh as VarniCustomProductService, bj as VendorService, bk as WarrantyService, bl as WhatsappConsent, bm as WhatsappConsentOffer, bn as WhatsappService, bq as WishlistService, br as addressService, bs as authService, bt as autocompleteService, bu as b2bService, bv as bannerService, bw as blogService, bx as cartService, by as categoryService, bz as chatService, bA as checkoutService, bB as collectionService, bC as contactService, bD as countryService, bE as couponService, bG as currencyService, bH as customizerService, bI as dealService, bJ as demoRequestService, bL as emptyPage, bM as enquiryService, bN as faqService, bO as feedbackService, bS as galleryService, bT as googleReviewService, bU as homeService, bV as initService, bW as layoutService, bX as mediaUrl, bY as meilisearchService, bZ as menuService, b$ as newsletterService, c0 as orderService, c1 as ownDomain, c2 as pageService, c3 as paymentMethodService, c4 as pluginService, c5 as pluginsService, c6 as popularSearchService, c7 as popularityService, ca as productService, cc as profileService, cd as qs, ce as reelsService, cf as regionService, cg as reviewService, ch as searchService, ci as setRequestHost, cj as settingService, ck as settingsService, cl as stateService, cm as staticStore, cn as storeForHost, co as storeService, cC as toPage, cF as toStorefrontFacets, cJ as uploadService, cK as userService, cL as variantService, cM as varniCustomDesignService, cN as varniCustomProductService, cO as vendorService, cP as warrantyService, cQ as whatsappService, cR as wishlistService } from '../index-BWg1KptA.js';
|
package/dist/services/index.js
CHANGED
|
@@ -302,7 +302,8 @@ var BaseService = class _BaseService {
|
|
|
302
302
|
const lang = (req.method ?? "GET") === "GET" ? this.creds.language : void 0;
|
|
303
303
|
const url = this.engineURL(path, lang ? { lang, ...req.query } : req.query);
|
|
304
304
|
const headers = { Accept: "application/json", ...req.headers };
|
|
305
|
-
|
|
305
|
+
const form = req.body instanceof FormData ? req.body : void 0;
|
|
306
|
+
if (req.body !== void 0 && !form) headers["Content-Type"] = "application/json";
|
|
306
307
|
const store = this.store;
|
|
307
308
|
if (store) headers["X-Store"] = store;
|
|
308
309
|
if (req.auth) {
|
|
@@ -313,7 +314,7 @@ var BaseService = class _BaseService {
|
|
|
313
314
|
const init = {
|
|
314
315
|
method: req.method ?? "GET",
|
|
315
316
|
headers,
|
|
316
|
-
body: req.body === void 0 ? void 0 : JSON.stringify(req.body)
|
|
317
|
+
body: form ?? (req.body === void 0 ? void 0 : JSON.stringify(req.body))
|
|
317
318
|
};
|
|
318
319
|
let res;
|
|
319
320
|
try {
|
|
@@ -810,6 +811,9 @@ function toCartLine(l, extra = {}) {
|
|
|
810
811
|
/** The add-on this line was bought as (D133), or null on an ordinary line. */
|
|
811
812
|
addOnId: l.add_on_id ? str(l.add_on_id) : null,
|
|
812
813
|
addOnFor: l.add_on_for ? str(l.add_on_for) : null,
|
|
814
|
+
/** The shopper's own design this line is made to (D162) and its picture, or null on a line sold as it is. */
|
|
815
|
+
designId: l.design_id ?? null,
|
|
816
|
+
designPreview: mediaUrl(l.design_preview_url),
|
|
813
817
|
subtotal: toMajor(l.total),
|
|
814
818
|
total: toMajor(l.total),
|
|
815
819
|
inStock: l.in_stock,
|
|
@@ -924,6 +928,8 @@ function toOrderLine(l, currency) {
|
|
|
924
928
|
total: toMajor(l.total),
|
|
925
929
|
currencyCode: currency,
|
|
926
930
|
status: l.shipped_quantity >= l.quantity ? "Shipped" : "Pending",
|
|
931
|
+
designId: l.metadata?.design?.id ?? null,
|
|
932
|
+
designPreview: mediaUrl(l.metadata?.design?.preview_url),
|
|
927
933
|
files: [],
|
|
928
934
|
usedOptions: []
|
|
929
935
|
};
|
|
@@ -1754,13 +1760,16 @@ var CartService = class extends BaseService {
|
|
|
1754
1760
|
}
|
|
1755
1761
|
/**
|
|
1756
1762
|
* `qty` is a change, not a total: +1 from a product page, −1 from a card's
|
|
1757
|
-
* minus button. With no cart yet, one is opened and remembered.
|
|
1763
|
+
* minus button. With no cart yet, one is opened and remembered. A
|
|
1764
|
+
* `designId` from `customizerService.saveDesign` makes the variant to the
|
|
1765
|
+
* shopper's design, on a line of its own.
|
|
1758
1766
|
*/
|
|
1759
1767
|
async addToCart({
|
|
1760
1768
|
cartId,
|
|
1761
1769
|
lineId,
|
|
1762
1770
|
qty = 1,
|
|
1763
|
-
variantId
|
|
1771
|
+
variantId,
|
|
1772
|
+
designId
|
|
1764
1773
|
}) {
|
|
1765
1774
|
let id2 = clean(cartId) ?? storedCartId();
|
|
1766
1775
|
if (lineId && id2) {
|
|
@@ -1774,21 +1783,16 @@ var CartService = class extends BaseService {
|
|
|
1774
1783
|
if (qty === REMOVE || Number(qty) <= 0) return this.getCartByCartId(id2);
|
|
1775
1784
|
if (!variantId) throw new GoCommerceError("Please choose an option before adding this to your bag.", 400);
|
|
1776
1785
|
if (!id2) id2 = await this.open();
|
|
1786
|
+
const body = { variant_id: Number(variantId), quantity: Number(qty), ...designId ? { design_id: designId } : {} };
|
|
1777
1787
|
try {
|
|
1778
1788
|
return await this.present(
|
|
1779
|
-
await this.data(`/api/carts/${encodeURIComponent(id2)}/line-items`, {
|
|
1780
|
-
method: "POST",
|
|
1781
|
-
body: { variant_id: Number(variantId), quantity: Number(qty) }
|
|
1782
|
-
})
|
|
1789
|
+
await this.data(`/api/carts/${encodeURIComponent(id2)}/line-items`, { method: "POST", body })
|
|
1783
1790
|
);
|
|
1784
1791
|
} catch (err) {
|
|
1785
|
-
if (err instanceof GoCommerceError &&
|
|
1792
|
+
if (err instanceof GoCommerceError && /cart not found|checked out/.test(err.message)) {
|
|
1786
1793
|
const fresh = await this.open();
|
|
1787
1794
|
return this.present(
|
|
1788
|
-
await this.data(`/api/carts/${encodeURIComponent(fresh)}/line-items`, {
|
|
1789
|
-
method: "POST",
|
|
1790
|
-
body: { variant_id: Number(variantId), quantity: Number(qty) }
|
|
1791
|
-
})
|
|
1795
|
+
await this.data(`/api/carts/${encodeURIComponent(fresh)}/line-items`, { method: "POST", body })
|
|
1792
1796
|
);
|
|
1793
1797
|
}
|
|
1794
1798
|
throw err;
|
|
@@ -2025,6 +2029,54 @@ var CartService = class extends BaseService {
|
|
|
2025
2029
|
var clean = (id2) => id2 && id2 !== "undefined" && id2 !== "null" ? id2 : null;
|
|
2026
2030
|
var cartService = new CartService();
|
|
2027
2031
|
|
|
2032
|
+
// src/services/customizer-service.ts
|
|
2033
|
+
var CustomizerService = class extends BaseService {
|
|
2034
|
+
facts = new StoreFacts(this._fetch);
|
|
2035
|
+
/** Null when the product cannot be designed, or on any failure: the page draws without the editor. */
|
|
2036
|
+
async setup(productId) {
|
|
2037
|
+
const plugins = await this.facts.plugins().catch(() => null);
|
|
2038
|
+
if (plugins && !plugins.has("customizer")) return null;
|
|
2039
|
+
const path = `/x/customizer/products/${encodeURIComponent(String(productId))}`;
|
|
2040
|
+
const s = await this.data(path).catch(() => null);
|
|
2041
|
+
if (!s) return null;
|
|
2042
|
+
return {
|
|
2043
|
+
productId: String(s.product_id),
|
|
2044
|
+
mockup: { ...s.mockup, url: media(s.mockup.url) },
|
|
2045
|
+
overlayUrl: mediaUrl(s.overlay_url),
|
|
2046
|
+
printArea: s.print_area,
|
|
2047
|
+
printSize: { widthMm: s.print_size.width_mm, heightMm: s.print_size.height_mm, dpi: s.print_size.dpi },
|
|
2048
|
+
tools: s.tools,
|
|
2049
|
+
fonts: s.fonts,
|
|
2050
|
+
stickers: s.stickers.map((k) => ({ ...k, url: media(k.url) })),
|
|
2051
|
+
minPhotoPx: s.min_photo_px,
|
|
2052
|
+
consent: s.consent
|
|
2053
|
+
};
|
|
2054
|
+
}
|
|
2055
|
+
/** A photo, or the finished preview or print file. The engine's refusal is thrown with its message. */
|
|
2056
|
+
async upload(file, filename) {
|
|
2057
|
+
const body = new FormData();
|
|
2058
|
+
body.append("file", file, filename);
|
|
2059
|
+
const u = await this.data("/x/customizer/uploads", { method: "POST", body });
|
|
2060
|
+
return { uploadId: u.upload_id, url: media(u.url), width: u.width, height: u.height };
|
|
2061
|
+
}
|
|
2062
|
+
/** The document goes as it is: the order keeps it, and whatever renders the print reads it there. */
|
|
2063
|
+
async saveDesign(design) {
|
|
2064
|
+
const d = await this.data("/x/customizer/designs", {
|
|
2065
|
+
method: "POST",
|
|
2066
|
+
body: {
|
|
2067
|
+
product_id: Number(design.productId),
|
|
2068
|
+
variant_id: Number(design.variantId),
|
|
2069
|
+
preview_upload_id: design.previewUploadId,
|
|
2070
|
+
print_upload_id: design.printUploadId,
|
|
2071
|
+
document: design.document
|
|
2072
|
+
}
|
|
2073
|
+
});
|
|
2074
|
+
return { designId: d.design_id, previewUrl: media(d.preview_url) };
|
|
2075
|
+
}
|
|
2076
|
+
};
|
|
2077
|
+
var media = (url) => mediaUrl(url) ?? url;
|
|
2078
|
+
var customizerService = new CustomizerService();
|
|
2079
|
+
|
|
2028
2080
|
// src/services/checkout-service.ts
|
|
2029
2081
|
var CheckoutService = class extends BaseService {
|
|
2030
2082
|
/** Delivery options for the address on the cart: `{ data: [{ id, name, base_rate }] }`. */
|
|
@@ -3698,6 +3750,50 @@ function withAmounts(v) {
|
|
|
3698
3750
|
}
|
|
3699
3751
|
var variantService = new VariantService();
|
|
3700
3752
|
|
|
3753
|
+
// src/services/whatsapp-service.ts
|
|
3754
|
+
var WhatsappService = class extends BaseService {
|
|
3755
|
+
/**
|
|
3756
|
+
* Whether to show the boxes. Never throws: an engine without the module, or
|
|
3757
|
+
* one that fails, answers both off, because checkout must not depend on it.
|
|
3758
|
+
*/
|
|
3759
|
+
async consentOffer() {
|
|
3760
|
+
try {
|
|
3761
|
+
const d = await this.data("/x/notify-whatsapp/consent");
|
|
3762
|
+
const enabled = d?.enabled === true;
|
|
3763
|
+
return { enabled, marketing: enabled && d?.marketing === true };
|
|
3764
|
+
} catch {
|
|
3765
|
+
return { enabled: false, marketing: false };
|
|
3766
|
+
}
|
|
3767
|
+
}
|
|
3768
|
+
/**
|
|
3769
|
+
* Records both answers for the phone as typed, against the bag (with
|
|
3770
|
+
* `marketing`, the engine keeps the phone on it for basket reminders). Throws
|
|
3771
|
+
* the engine's 400 (`validation_failed`) when the phone is not a WhatsApp
|
|
3772
|
+
* number for the store's country.
|
|
3773
|
+
*/
|
|
3774
|
+
async setConsent({
|
|
3775
|
+
cartId,
|
|
3776
|
+
phone,
|
|
3777
|
+
orderUpdates,
|
|
3778
|
+
marketing
|
|
3779
|
+
}) {
|
|
3780
|
+
const d = await this.data(
|
|
3781
|
+
"/x/notify-whatsapp/consent",
|
|
3782
|
+
{
|
|
3783
|
+
method: "PUT",
|
|
3784
|
+
body: {
|
|
3785
|
+
cart_id: cartId || storedCartId() || "",
|
|
3786
|
+
phone: String(phone ?? "").trim(),
|
|
3787
|
+
order_updates: orderUpdates === true,
|
|
3788
|
+
marketing: marketing === true
|
|
3789
|
+
}
|
|
3790
|
+
}
|
|
3791
|
+
);
|
|
3792
|
+
return { phone: d.phone, orderUpdates: d.order_updates, marketing: d.marketing };
|
|
3793
|
+
}
|
|
3794
|
+
};
|
|
3795
|
+
var whatsappService = new WhatsappService();
|
|
3796
|
+
|
|
3701
3797
|
// src/services/b2b-service.ts
|
|
3702
3798
|
var B2bService = class extends BaseService {
|
|
3703
3799
|
// ------------------------------------------------------------ company
|
|
@@ -3963,6 +4059,6 @@ function attemptKey(request) {
|
|
|
3963
4059
|
}
|
|
3964
4060
|
var b2bService = new B2bService();
|
|
3965
4061
|
|
|
3966
|
-
export { AddressService, AuthService, AutocompleteService, B2bService, BannerService, BaseService, BlogService, CartService, CatalogService, CategoryService, ChatService, CheckoutService, CollectionService, ContactService, CountryService, CouponService, CurrencyService, DealService, DemoRequestService, EnquiryService, FaqService, FeedbackService, GalleryService, GoogleReviewService, 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, googleReviewService, 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 };
|
|
4062
|
+
export { AddressService, AuthService, AutocompleteService, B2bService, BannerService, BaseService, BlogService, CartService, CatalogService, CategoryService, ChatService, CheckoutService, CollectionService, ContactService, CountryService, CouponService, CurrencyService, CustomizerService, DealService, DemoRequestService, EnquiryService, FaqService, FeedbackService, GalleryService, GoogleReviewService, 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, WhatsappService, WishlistService, addressService, authService, autocompleteService, b2bService, bannerService, blogService, cartService, categoryService, chatService, checkoutService, collectionService, contactService, countryService, couponService, currencyService, customizerService, dealService, demoRequestService, emptyPage, enquiryService, faqService, feedbackService, galleryService, googleReviewService, 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, whatsappService, wishlistService };
|
|
3967
4063
|
//# sourceMappingURL=index.js.map
|
|
3968
4064
|
//# sourceMappingURL=index.js.map
|