@misiki/gocommerce-connector 0.16.0 → 0.20.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 { 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, ak as OrderService, al as PageLayout, am as PageService, ao as PaymentMethodService, aq as PluginService, aq as PluginsService, ar as PopularSearchService, as as PopularityService, ax as ProductService, ay as ProfileService, az as Quote, aA as REDIRECT_GATEWAYS, aB as ReelsService, aC as RegionService, aD as RejectedLine, aG as ReviewService, aJ as SearchService, aK as SettingService, aK as SettingsService, aM as SiteChrome, aN as SiteFooter, aO as SiteHeader, aP as SocialLink, aQ as StateService, aS as StoreService, aU as StorefrontMenu, aX as ThemeSettings, aY as ThemeSettingsResult, aZ as UploadService, a_ as UserService, b1 as VariantService, b2 as VarniCustomDesignService, b3 as VarniCustomProductService, b5 as VendorService, b6 as WarrantyService, b9 as WishlistService, ba as addressService, bb as authService, bc as autocompleteService, bd as b2bService, be as bannerService, bf as blogService, bg as cartService, bh as categoryService, bi as chatService, bj as checkoutService, bk as collectionService, bl as contactService, bm as countryService, bn as couponService, bp as currencyService, bq as dealService, br as demoRequestService, bt as emptyPage, bu as enquiryService, bv as faqService, bw as feedbackService, bA as galleryService, bB as homeService, bC as initService, bD as layoutService, bE as mediaUrl, bF as meilisearchService, bG as menuService, bI as newsletterService, bJ as orderService, bK as ownDomain, bL as pageService, bM as paymentMethodService, bN as pluginService, bO as pluginsService, bP as popularSearchService, bQ as popularityService, bT as productService, bV as profileService, bW as qs, bX as reelsService, bY as regionService, bZ as reviewService, b_ as searchService, b$ as setRequestHost, c0 as settingService, c1 as settingsService, c2 as stateService, c3 as staticStore, c4 as storeForHost, c5 as storeService, cj as toPage, cm as toStorefrontFacets, cq as uploadService, cr as userService, cs as variantService, ct as varniCustomDesignService, cu as varniCustomProductService, cv as vendorService, cw as warrantyService, cx as wishlistService } from '../index-Dm_1E1ai.cjs';
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, Z as GoogleReview, _ as GoogleReviewService, $ as GoogleReviews, a1 as HeaderSettings, a2 as HomeLayout, a3 as HomeLayoutSection, a4 as HomeService, a6 as InitService, a7 as Invitation, a8 as LayoutCollection, a9 as LayoutPage, aa as LayoutService, ab as Lead, ad as MeilisearchService, ae as Member, ah as MenuService, ak as NewsletterService, ap as OrderService, aq as PageLayout, ar as PageService, at as PaymentMethodService, av as PluginService, av as PluginsService, aw as PopularSearchService, ax as PopularityService, aC as ProductService, aD as ProfileService, aE as Quote, aF as REDIRECT_GATEWAYS, aG as ReelsService, aH as RegionService, aI as RejectedLine, aL as ReviewService, aO as SearchService, aP as SettingService, aP as SettingsService, aR as SiteChrome, aS as SiteFooter, aT as SiteHeader, aU as SocialLink, aV as StateService, aX as StoreService, aZ as StorefrontMenu, b0 as ThemeSettings, b1 as ThemeSettingsResult, b2 as UploadService, b3 as UserService, b6 as VariantService, b7 as VarniCustomDesignService, b8 as VarniCustomProductService, ba as VendorService, bb as WarrantyService, be as WishlistService, bf as addressService, bg as authService, bh as autocompleteService, bi as b2bService, bj as bannerService, bk as blogService, bl as cartService, bm as categoryService, bn as chatService, bo as checkoutService, bp as collectionService, bq as contactService, br as countryService, bs as couponService, bu as currencyService, bv as dealService, bw as demoRequestService, by as emptyPage, bz as enquiryService, bA as faqService, bB as feedbackService, bF as galleryService, bG as googleReviewService, bH as homeService, bI as initService, bJ as layoutService, bK as mediaUrl, bL as meilisearchService, bM as menuService, bO as newsletterService, bP as orderService, bQ as ownDomain, bR as pageService, bS as paymentMethodService, bT as pluginService, bU as pluginsService, bV as popularSearchService, bW as popularityService, bZ as productService, b$ as profileService, c0 as qs, c1 as reelsService, c2 as regionService, c3 as reviewService, c4 as searchService, c5 as setRequestHost, c6 as settingService, c7 as settingsService, c8 as stateService, c9 as staticStore, ca as storeForHost, cb as storeService, cp as toPage, cs as toStorefrontFacets, cw as uploadService, cx as userService, cy as variantService, cz as varniCustomDesignService, cA as varniCustomProductService, cB as vendorService, cC as warrantyService, cD as wishlistService } from '../index-BnLRuRag.cjs';
@@ -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, ak as OrderService, al as PageLayout, am as PageService, ao as PaymentMethodService, aq as PluginService, aq as PluginsService, ar as PopularSearchService, as as PopularityService, ax as ProductService, ay as ProfileService, az as Quote, aA as REDIRECT_GATEWAYS, aB as ReelsService, aC as RegionService, aD as RejectedLine, aG as ReviewService, aJ as SearchService, aK as SettingService, aK as SettingsService, aM as SiteChrome, aN as SiteFooter, aO as SiteHeader, aP as SocialLink, aQ as StateService, aS as StoreService, aU as StorefrontMenu, aX as ThemeSettings, aY as ThemeSettingsResult, aZ as UploadService, a_ as UserService, b1 as VariantService, b2 as VarniCustomDesignService, b3 as VarniCustomProductService, b5 as VendorService, b6 as WarrantyService, b9 as WishlistService, ba as addressService, bb as authService, bc as autocompleteService, bd as b2bService, be as bannerService, bf as blogService, bg as cartService, bh as categoryService, bi as chatService, bj as checkoutService, bk as collectionService, bl as contactService, bm as countryService, bn as couponService, bp as currencyService, bq as dealService, br as demoRequestService, bt as emptyPage, bu as enquiryService, bv as faqService, bw as feedbackService, bA as galleryService, bB as homeService, bC as initService, bD as layoutService, bE as mediaUrl, bF as meilisearchService, bG as menuService, bI as newsletterService, bJ as orderService, bK as ownDomain, bL as pageService, bM as paymentMethodService, bN as pluginService, bO as pluginsService, bP as popularSearchService, bQ as popularityService, bT as productService, bV as profileService, bW as qs, bX as reelsService, bY as regionService, bZ as reviewService, b_ as searchService, b$ as setRequestHost, c0 as settingService, c1 as settingsService, c2 as stateService, c3 as staticStore, c4 as storeForHost, c5 as storeService, cj as toPage, cm as toStorefrontFacets, cq as uploadService, cr as userService, cs as variantService, ct as varniCustomDesignService, cu as varniCustomProductService, cv as vendorService, cw as warrantyService, cx as wishlistService } from '../index-Dm_1E1ai.js';
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, Z as GoogleReview, _ as GoogleReviewService, $ as GoogleReviews, a1 as HeaderSettings, a2 as HomeLayout, a3 as HomeLayoutSection, a4 as HomeService, a6 as InitService, a7 as Invitation, a8 as LayoutCollection, a9 as LayoutPage, aa as LayoutService, ab as Lead, ad as MeilisearchService, ae as Member, ah as MenuService, ak as NewsletterService, ap as OrderService, aq as PageLayout, ar as PageService, at as PaymentMethodService, av as PluginService, av as PluginsService, aw as PopularSearchService, ax as PopularityService, aC as ProductService, aD as ProfileService, aE as Quote, aF as REDIRECT_GATEWAYS, aG as ReelsService, aH as RegionService, aI as RejectedLine, aL as ReviewService, aO as SearchService, aP as SettingService, aP as SettingsService, aR as SiteChrome, aS as SiteFooter, aT as SiteHeader, aU as SocialLink, aV as StateService, aX as StoreService, aZ as StorefrontMenu, b0 as ThemeSettings, b1 as ThemeSettingsResult, b2 as UploadService, b3 as UserService, b6 as VariantService, b7 as VarniCustomDesignService, b8 as VarniCustomProductService, ba as VendorService, bb as WarrantyService, be as WishlistService, bf as addressService, bg as authService, bh as autocompleteService, bi as b2bService, bj as bannerService, bk as blogService, bl as cartService, bm as categoryService, bn as chatService, bo as checkoutService, bp as collectionService, bq as contactService, br as countryService, bs as couponService, bu as currencyService, bv as dealService, bw as demoRequestService, by as emptyPage, bz as enquiryService, bA as faqService, bB as feedbackService, bF as galleryService, bG as googleReviewService, bH as homeService, bI as initService, bJ as layoutService, bK as mediaUrl, bL as meilisearchService, bM as menuService, bO as newsletterService, bP as orderService, bQ as ownDomain, bR as pageService, bS as paymentMethodService, bT as pluginService, bU as pluginsService, bV as popularSearchService, bW as popularityService, bZ as productService, b$ as profileService, c0 as qs, c1 as reelsService, c2 as regionService, c3 as reviewService, c4 as searchService, c5 as setRequestHost, c6 as settingService, c7 as settingsService, c8 as stateService, c9 as staticStore, ca as storeForHost, cb as storeService, cp as toPage, cs as toStorefrontFacets, cw as uploadService, cx as userService, cy as variantService, cz as varniCustomDesignService, cA as varniCustomProductService, cB as vendorService, cC as warrantyService, cD as wishlistService } from '../index-BnLRuRag.js';
@@ -161,6 +161,17 @@ function currentMe() {
161
161
  return null;
162
162
  }
163
163
  }
164
+ function metaBrowser() {
165
+ const fbp = readCookie("_fbp");
166
+ if (!fbp || typeof window.fbq !== "function") return void 0;
167
+ const fbc = readCookie("_fbc");
168
+ return {
169
+ fbp,
170
+ ...fbc ? { fbc } : {},
171
+ client_user_agent: window.navigator.userAgent,
172
+ event_source_url: window.location.origin + window.location.pathname
173
+ };
174
+ }
164
175
  function storedCartId() {
165
176
  const v = readLocal("cart_id");
166
177
  if (!v || v === "undefined" || v === "null") return null;
@@ -2186,11 +2197,13 @@ var CheckoutService = class extends BaseService {
2186
2197
  ...extra
2187
2198
  };
2188
2199
  const serialised = JSON.stringify(body);
2189
- const key = extras.attempt?.body === `${code}:${serialised}` ? extras.attempt.key : newKey();
2190
- saveCartExtras(id2, { attempt: { key, body: `${code}:${serialised}` } });
2200
+ const retry = extras.attempt?.body === `${code}:${serialised}`;
2201
+ const key = retry ? extras.attempt.key : newKey();
2202
+ const meta = retry ? extras.attempt?.meta : metaBrowser();
2203
+ saveCartExtras(id2, { attempt: { key, body: `${code}:${serialised}`, ...meta ? { meta } : {} } });
2191
2204
  const result = await this.data(`/api/checkout/${encodeURIComponent(code)}`, {
2192
2205
  method: "POST",
2193
- body,
2206
+ body: meta ? { ...body, metadata: { ...extra.metadata, meta_capi: meta } } : body,
2194
2207
  headers: { "Idempotency-Key": key }
2195
2208
  });
2196
2209
  if (result.order.access_token) {
@@ -2852,6 +2865,71 @@ var ReviewService = class extends BaseService {
2852
2865
  };
2853
2866
  var reviewService = new ReviewService();
2854
2867
 
2868
+ // src/services/google-review-service.ts
2869
+ var PLUGIN = "google-reviews";
2870
+ var GoogleReviewService = class extends BaseService {
2871
+ facts = new StoreFacts(this._fetch);
2872
+ /**
2873
+ * Google's rating and its most relevant reviews, read live. Google's terms
2874
+ * forbid keeping them, so nothing here caches them either, and every call
2875
+ * is one the store pays Google for: call it when the section is in view.
2876
+ */
2877
+ async place() {
2878
+ if (!await this.switchOn("show_place")) return null;
2879
+ const p = await this.orNull(() => this.data("/x/google-reviews/place"));
2880
+ if (!p?.user_rating_count) return null;
2881
+ return {
2882
+ rating: p.rating,
2883
+ count: p.user_rating_count,
2884
+ mapsUrl: p.google_maps_uri ?? "",
2885
+ reviews: (p.reviews ?? []).map((r) => ({
2886
+ author: r.author?.name ?? "",
2887
+ authorUrl: r.author?.uri ?? "",
2888
+ authorPhoto: r.author?.photo_uri ?? "",
2889
+ rating: r.rating,
2890
+ text: r.text ?? "",
2891
+ language: r.language ?? "",
2892
+ when: r.relative_time ?? "",
2893
+ visited: r.visit_date ?? "",
2894
+ url: r.google_maps_uri ?? "",
2895
+ reportUrl: r.flag_uri ?? ""
2896
+ }))
2897
+ };
2898
+ }
2899
+ /**
2900
+ * What Google Customer Reviews' opt-in is rendered with, for an order placed
2901
+ * in this browser: its access token is kept here, and nowhere else can ask.
2902
+ * Every field is the order's own; the keys are Google's, to pass unchanged
2903
+ * to `gapi.surveyoptin.render`.
2904
+ */
2905
+ async survey(orderNumber) {
2906
+ const kept = orderNumber ? placedOrder(orderNumber) : void 0;
2907
+ if (!kept || !await this.switchOn("customer_reviews")) return null;
2908
+ return this.orNull(
2909
+ () => this.data(`/x/google-reviews/survey/${encodeURIComponent(orderNumber)}`, {
2910
+ query: { token: kept.token }
2911
+ })
2912
+ );
2913
+ }
2914
+ async switchOn(setting) {
2915
+ try {
2916
+ return (await this.facts.plugins()).get(PLUGIN)?.settings?.[setting] === true;
2917
+ } catch {
2918
+ return false;
2919
+ }
2920
+ }
2921
+ /** Off, used up for the day, or refused by Google: nothing to show. Anything else still throws. */
2922
+ async orNull(call) {
2923
+ try {
2924
+ return await call();
2925
+ } catch (err) {
2926
+ if (err instanceof GoCommerceError && [404, 429, 502].includes(err.status)) return null;
2927
+ throw err;
2928
+ }
2929
+ }
2930
+ };
2931
+ var googleReviewService = new GoogleReviewService();
2932
+
2855
2933
  // src/services/menu-service.ts
2856
2934
  function linkFor(item) {
2857
2935
  const t = item.target ?? "";
@@ -3073,9 +3151,21 @@ var StoreService = class extends BaseService {
3073
3151
  ...basePlugins.isProductReviewsAndRatings,
3074
3152
  ...flag(plugins.has("product-reviews"))
3075
3153
  },
3154
+ // Google Customer Reviews (ext/google-reviews): the confirmation page's survey offer,
3155
+ // whose fields the engine builds from the order, and Google's store widget, which
3156
+ // belongs to the same programme and so needs the survey on.
3157
+ googleReviewsOptIn: {
3158
+ ...basePlugins.googleReviewsOptIn,
3159
+ ...flag(googleSetting(plugins, "customer_reviews") === true)
3160
+ },
3161
+ googleStoreWidget: storeWidget(plugins),
3076
3162
  // The footer's sign-up box posts to ext/newsletter, and the theme editor's footer
3077
3163
  // switch (D131) can only show it while that is on.
3078
3164
  newsletter: { ...basePlugins.newsletter, ...flag(plugins.has("newsletter")) },
3165
+ // The ad and analytics tags (D160). The engine decides, not the static record:
3166
+ // one storefront serves every store, and one store's pixel must never
3167
+ // load on another's pages.
3168
+ ...adTags(plugins),
3079
3169
  // Discount codes are core: every GoCommerce store takes them, so
3080
3170
  // the code box is shown whatever the static record says.
3081
3171
  isDiscountCoupons: { ...basePlugins.isDiscountCoupons, active: true },
@@ -3101,6 +3191,22 @@ var StoreService = class extends BaseService {
3101
3191
  }
3102
3192
  };
3103
3193
  var storeService = new StoreService();
3194
+ var AD_TAGS = [
3195
+ ["meta-pixel", "pixel_id", "facebookPixel"],
3196
+ ["microsoft-clarity", "project_id", "microsoftClarity"],
3197
+ ["hotjar", "site_id", "hotjar"],
3198
+ ["tiktok-pixel", "pixel_id", "tiktokPixel"],
3199
+ ["pinterest-tag", "tag_id", "pinterestTag"],
3200
+ ["snapchat-pixel", "pixel_id", "snapchatPixel"]
3201
+ ];
3202
+ function adTags(plugins) {
3203
+ return Object.fromEntries(
3204
+ AD_TAGS.map(([key, field, name]) => {
3205
+ const id2 = String(plugins.get(key)?.settings?.[field] ?? "").trim();
3206
+ return [name, id2 ? { active: true, id: id2 } : { active: false }];
3207
+ })
3208
+ );
3209
+ }
3104
3210
  function deliverable(base, ships) {
3105
3211
  if (ships.everywhere || !ships.countries.length) return {};
3106
3212
  const known = new Map((base.countries ?? []).map((c) => [String(c.code).toUpperCase(), c]));
@@ -3115,6 +3221,12 @@ function regionName(code) {
3115
3221
  return code;
3116
3222
  }
3117
3223
  }
3224
+ var googleSetting = (plugins, key) => plugins.get("google-reviews")?.settings?.[key];
3225
+ function storeWidget(plugins) {
3226
+ const where = googleSetting(plugins, "store_widget");
3227
+ if (googleSetting(plugins, "customer_reviews") !== true || !where) return { active: false };
3228
+ return { active: true, position: where === "Bottom left" ? "LEFT_BOTTOM" : "RIGHT_BOTTOM" };
3229
+ }
3118
3230
  var LOGIN_TYPES = { phone_otp: "PHONE", email_or_phone: "BOTH", email_password: "EMAIL" };
3119
3231
 
3120
3232
  // src/services/page-service.ts
@@ -3797,6 +3909,6 @@ function attemptKey(request) {
3797
3909
  }
3798
3910
  var b2bService = new B2bService();
3799
3911
 
3800
- 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 };
3912
+ 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 };
3801
3913
  //# sourceMappingURL=index.js.map
3802
3914
  //# sourceMappingURL=index.js.map