@misiki/gocommerce-connector 0.21.0 → 0.23.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 -1
- package/dist/{index-BnLRuRag.d.cts → index-BM6hYdQs.d.cts} +43 -1
- package/dist/{index-BnLRuRag.d.ts → index-BM6hYdQs.d.ts} +43 -1
- package/dist/index.cjs +91 -2
- 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 +90 -3
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +91 -2
- 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 +90 -3
- package/dist/services/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,7 +47,8 @@ Each is optional. Without `-identity` there is no sign-in (guest checkout
|
|
|
47
47
|
always works); without `-reviews` products show no stars; and so on. Add
|
|
48
48
|
`-meilisearch` (with `MEILI_HOST` and keys) for typo-tolerant search once a store
|
|
49
49
|
switches the Meilisearch plugin on,
|
|
50
|
-
`-newsletter` and `-contact` for the signup box and contact form,
|
|
50
|
+
`-newsletter` and `-contact` for the signup box and contact form,
|
|
51
|
+
`-whatsapp` for WhatsApp order updates, and `-b2b` for
|
|
51
52
|
business buyers (see "Beyond the storefront's screens").
|
|
52
53
|
|
|
53
54
|
### The browser and CORS
|
|
@@ -153,6 +154,7 @@ down stays best-effort: the storefront renders from its static record.
|
|
|
153
154
|
| product specs table | the product's category attribute answers |
|
|
154
155
|
| attribute filters (`?attributes.color=Red`) | `/api/products?attr=color:Red` |
|
|
155
156
|
| newsletter box | `/x/newsletter/subscribe` |
|
|
157
|
+
| WhatsApp order updates at checkout | `/x/notify-whatsapp/consent` — `whatsappService.consentOffer()`: `{ enabled, marketing }`, whether to show the order-updates box and the offers-and-reminders box; both false when ext/notify-whatsapp is not in the engine or does not answer, so checkout never waits on it. `whatsappService.setConsent({ cartId, phone, orderUpdates, marketing })` (PUT) records both answers for the phone, an unticked box as `false`; with `marketing` the engine keeps the phone on the bag for basket reminders. It throws the engine's 400 (`validation_failed`) when the phone is not a WhatsApp number for the store's country |
|
|
156
158
|
| contact form, product enquiries | `/x/contact/messages`, with the form's hidden `website` honeypot passed on so the engine drops what a bot filled in |
|
|
157
159
|
| search words, type-ahead (plugin on) | `/x/meilisearch/search`, falling back to the engine's own search when it is off or down |
|
|
158
160
|
| store record | the storefront's own config, with the engine's currency, menus and module switches over it; the store's own logo, dark logo and icon (`logo_url`, `logo_dark_url`, `icon_url` from `/api/store`, D148) replace `logo`, `logoDark` and `favicon` when it has them; for the contact page (D156), the address once the store shows it (as `address: { street, city, state, pincode, country }`), `mapLocation` and `openingHours` when set, `businessCountry` (the store's ISO country, for the phone's country code), the `whatsapp-chat` plugin's number as `plugins.whatsappChatButton`, and Google Customer Reviews (ext/google-reviews) as `plugins.googleReviewsOptIn` (`active` while the survey is on) and `plugins.googleStoreWidget` (`{ active, position: 'RIGHT_BOTTOM' \| 'LEFT_BOTTOM' }`, off without the survey) |
|
|
@@ -723,6 +723,7 @@ type CartExtras = {
|
|
|
723
723
|
key: string;
|
|
724
724
|
body: string;
|
|
725
725
|
meta?: Record<string, string>;
|
|
726
|
+
attribution?: Record<string, unknown>;
|
|
726
727
|
} | null;
|
|
727
728
|
};
|
|
728
729
|
|
|
@@ -7150,6 +7151,47 @@ declare class NewsletterService extends BaseService {
|
|
|
7150
7151
|
}
|
|
7151
7152
|
declare const newsletterService: NewsletterService;
|
|
7152
7153
|
|
|
7154
|
+
/** Which WhatsApp boxes checkout shows. */
|
|
7155
|
+
type WhatsappConsentOffer = {
|
|
7156
|
+
/** The store sends order updates on WhatsApp: show the opt-in. */
|
|
7157
|
+
enabled: boolean;
|
|
7158
|
+
/** It sends basket reminders too: show the marketing box as well. */
|
|
7159
|
+
marketing: boolean;
|
|
7160
|
+
};
|
|
7161
|
+
/** What the engine kept for a phone: the number as it reads it, in E.164. */
|
|
7162
|
+
type WhatsappConsent = {
|
|
7163
|
+
phone: string;
|
|
7164
|
+
orderUpdates: boolean;
|
|
7165
|
+
marketing: boolean;
|
|
7166
|
+
};
|
|
7167
|
+
/**
|
|
7168
|
+
* The shopper's WhatsApp opt-in at checkout (ext/notify-whatsapp).
|
|
7169
|
+
*
|
|
7170
|
+
* The engine keeps the latest answer per phone, so an unticked box is sent as
|
|
7171
|
+
* `false` rather than left out: it is how a shopper who said yes last time
|
|
7172
|
+
* says no now.
|
|
7173
|
+
*/
|
|
7174
|
+
declare class WhatsappService extends BaseService {
|
|
7175
|
+
/**
|
|
7176
|
+
* Whether to show the boxes. Never throws: an engine without the module, or
|
|
7177
|
+
* one that fails, answers both off, because checkout must not depend on it.
|
|
7178
|
+
*/
|
|
7179
|
+
consentOffer(): Promise<WhatsappConsentOffer>;
|
|
7180
|
+
/**
|
|
7181
|
+
* Records both answers for the phone as typed, against the bag (with
|
|
7182
|
+
* `marketing`, the engine keeps the phone on it for basket reminders). Throws
|
|
7183
|
+
* the engine's 400 (`validation_failed`) when the phone is not a WhatsApp
|
|
7184
|
+
* number for the store's country.
|
|
7185
|
+
*/
|
|
7186
|
+
setConsent({ cartId, phone, orderUpdates, marketing, }: {
|
|
7187
|
+
cartId?: string | null;
|
|
7188
|
+
phone: string;
|
|
7189
|
+
orderUpdates: boolean;
|
|
7190
|
+
marketing: boolean;
|
|
7191
|
+
}): Promise<WhatsappConsent>;
|
|
7192
|
+
}
|
|
7193
|
+
declare const whatsappService: WhatsappService;
|
|
7194
|
+
|
|
7153
7195
|
type B2bRole = 'admin' | 'approver' | 'buyer';
|
|
7154
7196
|
type Company = {
|
|
7155
7197
|
id: number;
|
|
@@ -7697,4 +7739,4 @@ declare class B2bService extends BaseService {
|
|
|
7697
7739
|
}
|
|
7698
7740
|
declare const b2bService: B2bService;
|
|
7699
7741
|
|
|
7700
|
-
export { type GoogleReviews as $, type AddOn as A, type B2bPlaced as B, type Cart as C, type CompanyOrder as D, ContactService as E, CountryService as F, CouponService as G, type Credentials as H, type Credit as I, CurrencyService as J, type Customer as K, DealService as L, DemoRequestService as M, type EngineRequest as N, EnquiryService as O, type Envelope as P, type FacetValue as Q, type Faq as R, FaqService as S, FeedbackService as T, type FooterSettings as U, type FreeShipping as V, type Fulfillment as W, GalleryService as X, type GooglePlace as Y, type GoogleReview as Z, GoogleReviewService as _, type Address as a, type StorefrontProduct as a$, type GoogleSurvey as a0, type HeaderSettings as a1, type HomeLayout as a2, type HomeLayoutSection as a3, HomeService as a4, type IdentityAddress as a5, InitService as a6, type Invitation as a7, type LayoutCollection as a8, type LayoutPage as a9, type ProductFacets as aA, type ProductOption as aB, ProductService as aC, ProfileService as aD, type Quote as aE, REDIRECT_GATEWAYS as aF, ReelsService as aG, RegionService as aH, type RejectedLine as aI, type Review as aJ, type ReviewPage as aK, ReviewService as aL, type SearchDoc as aM, type SearchResult as aN, SearchService as aO, SettingService as aP, type ShippingRate as aQ, type SiteChrome as aR, type SiteFooter as aS, type SiteHeader as aT, type SocialLink as aU, StateService as aV, type StoreProfile as aW, StoreService as aX, type StorefrontCategory as aY, type StorefrontMenu as aZ, type StorefrontOrder as a_, LayoutService as aa, type Lead as ab, type ListMeta as ac, MeilisearchService as ad, type Member as ae, type Menu as af, type MenuItem as ag, MenuService as ah, type MenuSummary as ai, type Money as aj, NewsletterService as ak, type Offer as al, type OpeningHours as am, type Order as an, type OrderLine as ao, OrderService as ap, type PageLayout as aq, PageService as ar, type PaymentIntent as as, PaymentMethodService as at, type Plugin as au, PluginService as av, PopularSearchService as aw, PopularityService as ax, type Postcode as ay, type Product as az, AddressService as b,
|
|
7742
|
+
export { type GoogleReviews as $, type AddOn as A, type B2bPlaced as B, type Cart as C, type CompanyOrder as D, ContactService as E, CountryService as F, CouponService as G, type Credentials as H, type Credit as I, CurrencyService as J, type Customer as K, DealService as L, DemoRequestService as M, type EngineRequest as N, EnquiryService as O, type Envelope as P, type FacetValue as Q, type Faq as R, FaqService as S, FeedbackService as T, type FooterSettings as U, type FreeShipping as V, type Fulfillment as W, GalleryService as X, type GooglePlace as Y, type GoogleReview as Z, GoogleReviewService as _, type Address as a, type StorefrontProduct as a$, type GoogleSurvey as a0, type HeaderSettings as a1, type HomeLayout as a2, type HomeLayoutSection as a3, HomeService as a4, type IdentityAddress as a5, InitService as a6, type Invitation as a7, type LayoutCollection as a8, type LayoutPage as a9, type ProductFacets as aA, type ProductOption as aB, ProductService as aC, ProfileService as aD, type Quote as aE, REDIRECT_GATEWAYS as aF, ReelsService as aG, RegionService as aH, type RejectedLine as aI, type Review as aJ, type ReviewPage as aK, ReviewService as aL, type SearchDoc as aM, type SearchResult as aN, SearchService as aO, SettingService as aP, type ShippingRate as aQ, type SiteChrome as aR, type SiteFooter as aS, type SiteHeader as aT, type SocialLink as aU, StateService as aV, type StoreProfile as aW, StoreService as aX, type StorefrontCategory as aY, type StorefrontMenu as aZ, type StorefrontOrder as a_, LayoutService as aa, type Lead as ab, type ListMeta as ac, MeilisearchService as ad, type Member as ae, type Menu as af, type MenuItem as ag, MenuService as ah, type MenuSummary as ai, type Money as aj, NewsletterService as ak, type Offer as al, type OpeningHours as am, type Order as an, type OrderLine as ao, OrderService as ap, type PageLayout as aq, PageService as ar, type PaymentIntent as as, PaymentMethodService as at, type Plugin as au, PluginService as av, PopularSearchService as aw, PopularityService as ax, type Postcode as ay, type Product as az, AddressService as b, productImages as b$, type ThemeSettings as b0, type ThemeSettingsResult as b1, UploadService as b2, UserService as b3, type Variant as b4, type VariantImage as b5, VariantService as b6, VarniCustomDesignService as b7, VarniCustomProductService as b8, type Vendor as b9, emptyCart as bA, emptyPage as bB, enquiryService as bC, faqService as bD, feedbackService as bE, fromEngineAddress as bF, fromIdentityAddress as bG, fromSearchDoc as bH, galleryService as bI, googleReviewService as bJ, homeService as bK, initService as bL, layoutService as bM, mediaUrl as bN, meilisearchService as bO, menuService as bP, minorToMajor as bQ, newsletterService as bR, orderService as bS, ownDomain as bT, pageService as bU, paymentMethodService as bV, pluginService as bW, pluginsService as bX, popularSearchService as bY, popularityService as bZ, priceOf as b_, VendorService as ba, WarrantyService as bb, type WhatsappConsent as bc, type WhatsappConsentOffer as bd, WhatsappService as be, type Wishlist as bf, type WishlistItem as bg, WishlistService as bh, addressService as bi, authService as bj, autocompleteService as bk, b2bService as bl, bannerService as bm, blogService as bn, cartService as bo, categoryService as bp, chatService as bq, checkoutService as br, collectionService as bs, contactService as bt, countryService as bu, couponService as bv, currencyExponent as bw, currencyService as bx, dealService as by, demoRequestService as bz, type AppliedDiscount as c, productService as c0, productVideos as c1, profileService as c2, qs as c3, reelsService as c4, regionService as c5, reviewService as c6, searchService as c7, setRequestHost as c8, settingService as c9, userService as cA, variantService as cB, varniCustomDesignService as cC, varniCustomProductService as cD, vendorService as cE, warrantyService as cF, whatsappService as cG, wishlistService as cH, settingsService as ca, stateService as cb, staticStore as cc, storeForHost as cd, storeService as ce, toAddOn as cf, toCart as cg, toCartLine as ch, toCartOffer as ci, toCategory as cj, toCmsPage as ck, toCollection as cl, toEngineAddress as cm, toFreeShipping as cn, toIdentityAddress as co, toMajor as cp, toMinor as cq, toOrder as cr, toPage as cs, toProduct as ct, toRating as cu, toStorefrontFacets as cv, toUser as cw, toVariant as cx, toVendor as cy, uploadService as cz, type Approval as d, type AuthResponse as e, AuthService as f, AutocompleteService as g, type B2bRole as h, B2bService as i, BannerService as j, BaseService as k, BlogService as l, type CartLine as m, type CartOffer as n, CartService as o, CatalogService as p, type Category as q, CategoryService as r, ChatService as s, type CheckoutOptions as t, type CheckoutResult as u, CheckoutService as v, type CmsPage as w, type Collection as x, CollectionService as y, type Company as z };
|
|
@@ -723,6 +723,7 @@ type CartExtras = {
|
|
|
723
723
|
key: string;
|
|
724
724
|
body: string;
|
|
725
725
|
meta?: Record<string, string>;
|
|
726
|
+
attribution?: Record<string, unknown>;
|
|
726
727
|
} | null;
|
|
727
728
|
};
|
|
728
729
|
|
|
@@ -7150,6 +7151,47 @@ declare class NewsletterService extends BaseService {
|
|
|
7150
7151
|
}
|
|
7151
7152
|
declare const newsletterService: NewsletterService;
|
|
7152
7153
|
|
|
7154
|
+
/** Which WhatsApp boxes checkout shows. */
|
|
7155
|
+
type WhatsappConsentOffer = {
|
|
7156
|
+
/** The store sends order updates on WhatsApp: show the opt-in. */
|
|
7157
|
+
enabled: boolean;
|
|
7158
|
+
/** It sends basket reminders too: show the marketing box as well. */
|
|
7159
|
+
marketing: boolean;
|
|
7160
|
+
};
|
|
7161
|
+
/** What the engine kept for a phone: the number as it reads it, in E.164. */
|
|
7162
|
+
type WhatsappConsent = {
|
|
7163
|
+
phone: string;
|
|
7164
|
+
orderUpdates: boolean;
|
|
7165
|
+
marketing: boolean;
|
|
7166
|
+
};
|
|
7167
|
+
/**
|
|
7168
|
+
* The shopper's WhatsApp opt-in at checkout (ext/notify-whatsapp).
|
|
7169
|
+
*
|
|
7170
|
+
* The engine keeps the latest answer per phone, so an unticked box is sent as
|
|
7171
|
+
* `false` rather than left out: it is how a shopper who said yes last time
|
|
7172
|
+
* says no now.
|
|
7173
|
+
*/
|
|
7174
|
+
declare class WhatsappService extends BaseService {
|
|
7175
|
+
/**
|
|
7176
|
+
* Whether to show the boxes. Never throws: an engine without the module, or
|
|
7177
|
+
* one that fails, answers both off, because checkout must not depend on it.
|
|
7178
|
+
*/
|
|
7179
|
+
consentOffer(): Promise<WhatsappConsentOffer>;
|
|
7180
|
+
/**
|
|
7181
|
+
* Records both answers for the phone as typed, against the bag (with
|
|
7182
|
+
* `marketing`, the engine keeps the phone on it for basket reminders). Throws
|
|
7183
|
+
* the engine's 400 (`validation_failed`) when the phone is not a WhatsApp
|
|
7184
|
+
* number for the store's country.
|
|
7185
|
+
*/
|
|
7186
|
+
setConsent({ cartId, phone, orderUpdates, marketing, }: {
|
|
7187
|
+
cartId?: string | null;
|
|
7188
|
+
phone: string;
|
|
7189
|
+
orderUpdates: boolean;
|
|
7190
|
+
marketing: boolean;
|
|
7191
|
+
}): Promise<WhatsappConsent>;
|
|
7192
|
+
}
|
|
7193
|
+
declare const whatsappService: WhatsappService;
|
|
7194
|
+
|
|
7153
7195
|
type B2bRole = 'admin' | 'approver' | 'buyer';
|
|
7154
7196
|
type Company = {
|
|
7155
7197
|
id: number;
|
|
@@ -7697,4 +7739,4 @@ declare class B2bService extends BaseService {
|
|
|
7697
7739
|
}
|
|
7698
7740
|
declare const b2bService: B2bService;
|
|
7699
7741
|
|
|
7700
|
-
export { type GoogleReviews as $, type AddOn as A, type B2bPlaced as B, type Cart as C, type CompanyOrder as D, ContactService as E, CountryService as F, CouponService as G, type Credentials as H, type Credit as I, CurrencyService as J, type Customer as K, DealService as L, DemoRequestService as M, type EngineRequest as N, EnquiryService as O, type Envelope as P, type FacetValue as Q, type Faq as R, FaqService as S, FeedbackService as T, type FooterSettings as U, type FreeShipping as V, type Fulfillment as W, GalleryService as X, type GooglePlace as Y, type GoogleReview as Z, GoogleReviewService as _, type Address as a, type StorefrontProduct as a$, type GoogleSurvey as a0, type HeaderSettings as a1, type HomeLayout as a2, type HomeLayoutSection as a3, HomeService as a4, type IdentityAddress as a5, InitService as a6, type Invitation as a7, type LayoutCollection as a8, type LayoutPage as a9, type ProductFacets as aA, type ProductOption as aB, ProductService as aC, ProfileService as aD, type Quote as aE, REDIRECT_GATEWAYS as aF, ReelsService as aG, RegionService as aH, type RejectedLine as aI, type Review as aJ, type ReviewPage as aK, ReviewService as aL, type SearchDoc as aM, type SearchResult as aN, SearchService as aO, SettingService as aP, type ShippingRate as aQ, type SiteChrome as aR, type SiteFooter as aS, type SiteHeader as aT, type SocialLink as aU, StateService as aV, type StoreProfile as aW, StoreService as aX, type StorefrontCategory as aY, type StorefrontMenu as aZ, type StorefrontOrder as a_, LayoutService as aa, type Lead as ab, type ListMeta as ac, MeilisearchService as ad, type Member as ae, type Menu as af, type MenuItem as ag, MenuService as ah, type MenuSummary as ai, type Money as aj, NewsletterService as ak, type Offer as al, type OpeningHours as am, type Order as an, type OrderLine as ao, OrderService as ap, type PageLayout as aq, PageService as ar, type PaymentIntent as as, PaymentMethodService as at, type Plugin as au, PluginService as av, PopularSearchService as aw, PopularityService as ax, type Postcode as ay, type Product as az, AddressService as b,
|
|
7742
|
+
export { type GoogleReviews as $, type AddOn as A, type B2bPlaced as B, type Cart as C, type CompanyOrder as D, ContactService as E, CountryService as F, CouponService as G, type Credentials as H, type Credit as I, CurrencyService as J, type Customer as K, DealService as L, DemoRequestService as M, type EngineRequest as N, EnquiryService as O, type Envelope as P, type FacetValue as Q, type Faq as R, FaqService as S, FeedbackService as T, type FooterSettings as U, type FreeShipping as V, type Fulfillment as W, GalleryService as X, type GooglePlace as Y, type GoogleReview as Z, GoogleReviewService as _, type Address as a, type StorefrontProduct as a$, type GoogleSurvey as a0, type HeaderSettings as a1, type HomeLayout as a2, type HomeLayoutSection as a3, HomeService as a4, type IdentityAddress as a5, InitService as a6, type Invitation as a7, type LayoutCollection as a8, type LayoutPage as a9, type ProductFacets as aA, type ProductOption as aB, ProductService as aC, ProfileService as aD, type Quote as aE, REDIRECT_GATEWAYS as aF, ReelsService as aG, RegionService as aH, type RejectedLine as aI, type Review as aJ, type ReviewPage as aK, ReviewService as aL, type SearchDoc as aM, type SearchResult as aN, SearchService as aO, SettingService as aP, type ShippingRate as aQ, type SiteChrome as aR, type SiteFooter as aS, type SiteHeader as aT, type SocialLink as aU, StateService as aV, type StoreProfile as aW, StoreService as aX, type StorefrontCategory as aY, type StorefrontMenu as aZ, type StorefrontOrder as a_, LayoutService as aa, type Lead as ab, type ListMeta as ac, MeilisearchService as ad, type Member as ae, type Menu as af, type MenuItem as ag, MenuService as ah, type MenuSummary as ai, type Money as aj, NewsletterService as ak, type Offer as al, type OpeningHours as am, type Order as an, type OrderLine as ao, OrderService as ap, type PageLayout as aq, PageService as ar, type PaymentIntent as as, PaymentMethodService as at, type Plugin as au, PluginService as av, PopularSearchService as aw, PopularityService as ax, type Postcode as ay, type Product as az, AddressService as b, productImages as b$, type ThemeSettings as b0, type ThemeSettingsResult as b1, UploadService as b2, UserService as b3, type Variant as b4, type VariantImage as b5, VariantService as b6, VarniCustomDesignService as b7, VarniCustomProductService as b8, type Vendor as b9, emptyCart as bA, emptyPage as bB, enquiryService as bC, faqService as bD, feedbackService as bE, fromEngineAddress as bF, fromIdentityAddress as bG, fromSearchDoc as bH, galleryService as bI, googleReviewService as bJ, homeService as bK, initService as bL, layoutService as bM, mediaUrl as bN, meilisearchService as bO, menuService as bP, minorToMajor as bQ, newsletterService as bR, orderService as bS, ownDomain as bT, pageService as bU, paymentMethodService as bV, pluginService as bW, pluginsService as bX, popularSearchService as bY, popularityService as bZ, priceOf as b_, VendorService as ba, WarrantyService as bb, type WhatsappConsent as bc, type WhatsappConsentOffer as bd, WhatsappService as be, type Wishlist as bf, type WishlistItem as bg, WishlistService as bh, addressService as bi, authService as bj, autocompleteService as bk, b2bService as bl, bannerService as bm, blogService as bn, cartService as bo, categoryService as bp, chatService as bq, checkoutService as br, collectionService as bs, contactService as bt, countryService as bu, couponService as bv, currencyExponent as bw, currencyService as bx, dealService as by, demoRequestService as bz, type AppliedDiscount as c, productService as c0, productVideos as c1, profileService as c2, qs as c3, reelsService as c4, regionService as c5, reviewService as c6, searchService as c7, setRequestHost as c8, settingService as c9, userService as cA, variantService as cB, varniCustomDesignService as cC, varniCustomProductService as cD, vendorService as cE, warrantyService as cF, whatsappService as cG, wishlistService as cH, settingsService as ca, stateService as cb, staticStore as cc, storeForHost as cd, storeService as ce, toAddOn as cf, toCart as cg, toCartLine as ch, toCartOffer as ci, toCategory as cj, toCmsPage as ck, toCollection as cl, toEngineAddress as cm, toFreeShipping as cn, toIdentityAddress as co, toMajor as cp, toMinor as cq, toOrder as cr, toPage as cs, toProduct as ct, toRating as cu, toStorefrontFacets as cv, toUser as cw, toVariant as cx, toVendor as cy, uploadService as cz, type Approval as d, type AuthResponse as e, AuthService as f, AutocompleteService as g, type B2bRole as h, B2bService as i, BannerService as j, BaseService as k, BlogService as l, type CartLine as m, type CartOffer as n, CartService as o, CatalogService as p, type Category as q, CategoryService as r, ChatService as s, type CheckoutOptions as t, type CheckoutResult as u, CheckoutService as v, type CmsPage as w, type Collection as x, CollectionService as y, type Company as z };
|
package/dist/index.cjs
CHANGED
|
@@ -247,6 +247,41 @@ function metaBrowser() {
|
|
|
247
247
|
event_source_url: window.location.origin + window.location.pathname
|
|
248
248
|
};
|
|
249
249
|
}
|
|
250
|
+
var ATTRIBUTION_KEY = "gc_attribution";
|
|
251
|
+
var ATTRIBUTION_DAYS = 30;
|
|
252
|
+
var TOUCH_FIELDS = [
|
|
253
|
+
"utm_source",
|
|
254
|
+
"utm_medium",
|
|
255
|
+
"utm_campaign",
|
|
256
|
+
"utm_content",
|
|
257
|
+
"utm_term",
|
|
258
|
+
"gclid",
|
|
259
|
+
"gbraid",
|
|
260
|
+
"wbraid",
|
|
261
|
+
"fbclid",
|
|
262
|
+
"ttclid",
|
|
263
|
+
"msclkid",
|
|
264
|
+
"referrer",
|
|
265
|
+
"at"
|
|
266
|
+
];
|
|
267
|
+
function cleanTouch(raw, now) {
|
|
268
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
269
|
+
const at = Date.parse(String(raw.at ?? ""));
|
|
270
|
+
if (!Number.isFinite(at) || now - at > ATTRIBUTION_DAYS * 864e5 || at - now > 864e5) return void 0;
|
|
271
|
+
const out = {};
|
|
272
|
+
for (const k of TOUCH_FIELDS) {
|
|
273
|
+
const v = raw[k];
|
|
274
|
+
if (typeof v === "string" && v.trim()) out[k] = v.trim().slice(0, 200);
|
|
275
|
+
}
|
|
276
|
+
return Object.keys(out).length > 1 ? out : void 0;
|
|
277
|
+
}
|
|
278
|
+
function landingAttribution(now = Date.now()) {
|
|
279
|
+
const saved = readJSON(ATTRIBUTION_KEY);
|
|
280
|
+
const last = cleanTouch(saved?.last, now);
|
|
281
|
+
const first = cleanTouch(saved?.first, now) ?? last;
|
|
282
|
+
if (!first && !last) return void 0;
|
|
283
|
+
return { ...first ? { first } : {}, ...last ? { last } : {} };
|
|
284
|
+
}
|
|
250
285
|
function storedCartId() {
|
|
251
286
|
const v = readLocal("cart_id");
|
|
252
287
|
if (!v || v === "undefined" || v === "null") return null;
|
|
@@ -2221,10 +2256,18 @@ var CheckoutService = class extends BaseService {
|
|
|
2221
2256
|
const retry = extras.attempt?.body === `${code}:${serialised}`;
|
|
2222
2257
|
const key = retry ? extras.attempt.key : newKey();
|
|
2223
2258
|
const meta = retry ? extras.attempt?.meta : metaBrowser();
|
|
2224
|
-
|
|
2259
|
+
const attribution = retry ? extras.attempt?.attribution : landingAttribution();
|
|
2260
|
+
saveCartExtras(id2, {
|
|
2261
|
+
attempt: { key, body: `${code}:${serialised}`, ...meta ? { meta } : {}, ...attribution ? { attribution } : {} }
|
|
2262
|
+
});
|
|
2263
|
+
const metadata = {
|
|
2264
|
+
...extra.metadata,
|
|
2265
|
+
...meta ? { meta_capi: meta } : {},
|
|
2266
|
+
...attribution ? { attribution } : {}
|
|
2267
|
+
};
|
|
2225
2268
|
const result = await this.data(`/api/checkout/${encodeURIComponent(code)}`, {
|
|
2226
2269
|
method: "POST",
|
|
2227
|
-
body:
|
|
2270
|
+
body: Object.keys(metadata).length ? { ...body, metadata } : body,
|
|
2228
2271
|
headers: { "Idempotency-Key": key }
|
|
2229
2272
|
});
|
|
2230
2273
|
if (result.order.access_token) {
|
|
@@ -3673,6 +3716,50 @@ function withAmounts(v) {
|
|
|
3673
3716
|
}
|
|
3674
3717
|
var variantService = new VariantService();
|
|
3675
3718
|
|
|
3719
|
+
// src/services/whatsapp-service.ts
|
|
3720
|
+
var WhatsappService = class extends BaseService {
|
|
3721
|
+
/**
|
|
3722
|
+
* Whether to show the boxes. Never throws: an engine without the module, or
|
|
3723
|
+
* one that fails, answers both off, because checkout must not depend on it.
|
|
3724
|
+
*/
|
|
3725
|
+
async consentOffer() {
|
|
3726
|
+
try {
|
|
3727
|
+
const d = await this.data("/x/notify-whatsapp/consent");
|
|
3728
|
+
const enabled = d?.enabled === true;
|
|
3729
|
+
return { enabled, marketing: enabled && d?.marketing === true };
|
|
3730
|
+
} catch {
|
|
3731
|
+
return { enabled: false, marketing: false };
|
|
3732
|
+
}
|
|
3733
|
+
}
|
|
3734
|
+
/**
|
|
3735
|
+
* Records both answers for the phone as typed, against the bag (with
|
|
3736
|
+
* `marketing`, the engine keeps the phone on it for basket reminders). Throws
|
|
3737
|
+
* the engine's 400 (`validation_failed`) when the phone is not a WhatsApp
|
|
3738
|
+
* number for the store's country.
|
|
3739
|
+
*/
|
|
3740
|
+
async setConsent({
|
|
3741
|
+
cartId,
|
|
3742
|
+
phone,
|
|
3743
|
+
orderUpdates,
|
|
3744
|
+
marketing
|
|
3745
|
+
}) {
|
|
3746
|
+
const d = await this.data(
|
|
3747
|
+
"/x/notify-whatsapp/consent",
|
|
3748
|
+
{
|
|
3749
|
+
method: "PUT",
|
|
3750
|
+
body: {
|
|
3751
|
+
cart_id: cartId || storedCartId() || "",
|
|
3752
|
+
phone: String(phone ?? "").trim(),
|
|
3753
|
+
order_updates: orderUpdates === true,
|
|
3754
|
+
marketing: marketing === true
|
|
3755
|
+
}
|
|
3756
|
+
}
|
|
3757
|
+
);
|
|
3758
|
+
return { phone: d.phone, orderUpdates: d.order_updates, marketing: d.marketing };
|
|
3759
|
+
}
|
|
3760
|
+
};
|
|
3761
|
+
var whatsappService = new WhatsappService();
|
|
3762
|
+
|
|
3676
3763
|
// src/services/b2b-service.ts
|
|
3677
3764
|
var B2bService = class extends BaseService {
|
|
3678
3765
|
// ------------------------------------------------------------ company
|
|
@@ -3995,6 +4082,7 @@ exports.VarniCustomDesignService = VarniCustomDesignService;
|
|
|
3995
4082
|
exports.VarniCustomProductService = VarniCustomProductService;
|
|
3996
4083
|
exports.VendorService = VendorService;
|
|
3997
4084
|
exports.WarrantyService = WarrantyService;
|
|
4085
|
+
exports.WhatsappService = WhatsappService;
|
|
3998
4086
|
exports.WishlistService = WishlistService;
|
|
3999
4087
|
exports.addressService = addressService;
|
|
4000
4088
|
exports.authService = authService;
|
|
@@ -4090,6 +4178,7 @@ exports.varniCustomDesignService = varniCustomDesignService;
|
|
|
4090
4178
|
exports.varniCustomProductService = varniCustomProductService;
|
|
4091
4179
|
exports.vendorService = vendorService;
|
|
4092
4180
|
exports.warrantyService = warrantyService;
|
|
4181
|
+
exports.whatsappService = whatsappService;
|
|
4093
4182
|
exports.wishlistService = wishlistService;
|
|
4094
4183
|
//# sourceMappingURL=index.cjs.map
|
|
4095
4184
|
//# sourceMappingURL=index.cjs.map
|