@misiki/gocommerce-connector 0.15.0 → 0.19.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, aj as OrderService, ak as PageLayout, al as PageService, an as PaymentMethodService, ap as PluginService, ap as PluginsService, aq as PopularSearchService, ar as PopularityService, aw as ProductService, ax as ProfileService, ay as Quote, az as REDIRECT_GATEWAYS, aA as ReelsService, aB as RegionService, aC as RejectedLine, aF as ReviewService, aI as SearchService, aJ as SettingService, aJ as SettingsService, aL as SiteChrome, aM as SiteFooter, aN as SiteHeader, aO as SocialLink, aP as StateService, aR as StoreService, aT as StorefrontMenu, aW as ThemeSettings, aX as ThemeSettingsResult, aY as UploadService, aZ as UserService, b0 as VariantService, b1 as VarniCustomDesignService, b2 as VarniCustomProductService, b4 as VendorService, b5 as WarrantyService, b8 as WishlistService, b9 as addressService, ba as authService, bb as autocompleteService, bc as b2bService, bd as bannerService, be as blogService, bf as cartService, bg as categoryService, bh as chatService, bi as checkoutService, bj as collectionService, bk as contactService, bl as countryService, bm as couponService, bo as currencyService, bp as dealService, bq as demoRequestService, bs as emptyPage, bt as enquiryService, bu as faqService, bv as feedbackService, bz as galleryService, bA as homeService, bB as initService, bC as layoutService, bD as mediaUrl, bE as meilisearchService, bF as menuService, bH as newsletterService, bI as orderService, bJ as ownDomain, bK as pageService, bL as paymentMethodService, bM as pluginService, bN as pluginsService, bO as popularSearchService, bP as popularityService, bS as productService, bU as profileService, bV as qs, bW as reelsService, bX as regionService, bY as reviewService, bZ as searchService, b_ as setRequestHost, b$ as settingService, c0 as settingsService, c1 as stateService, c2 as staticStore, c3 as storeForHost, c4 as storeService, ci as toPage, cl as toStorefrontFacets, cp as uploadService, cq as userService, cr as variantService, cs as varniCustomDesignService, ct as varniCustomProductService, cu as vendorService, cv as warrantyService, cw as wishlistService } from '../index-GdjWgh5b.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-BsvUnF4H.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, aj as OrderService, ak as PageLayout, al as PageService, an as PaymentMethodService, ap as PluginService, ap as PluginsService, aq as PopularSearchService, ar as PopularityService, aw as ProductService, ax as ProfileService, ay as Quote, az as REDIRECT_GATEWAYS, aA as ReelsService, aB as RegionService, aC as RejectedLine, aF as ReviewService, aI as SearchService, aJ as SettingService, aJ as SettingsService, aL as SiteChrome, aM as SiteFooter, aN as SiteHeader, aO as SocialLink, aP as StateService, aR as StoreService, aT as StorefrontMenu, aW as ThemeSettings, aX as ThemeSettingsResult, aY as UploadService, aZ as UserService, b0 as VariantService, b1 as VarniCustomDesignService, b2 as VarniCustomProductService, b4 as VendorService, b5 as WarrantyService, b8 as WishlistService, b9 as addressService, ba as authService, bb as autocompleteService, bc as b2bService, bd as bannerService, be as blogService, bf as cartService, bg as categoryService, bh as chatService, bi as checkoutService, bj as collectionService, bk as contactService, bl as countryService, bm as couponService, bo as currencyService, bp as dealService, bq as demoRequestService, bs as emptyPage, bt as enquiryService, bu as faqService, bv as feedbackService, bz as galleryService, bA as homeService, bB as initService, bC as layoutService, bD as mediaUrl, bE as meilisearchService, bF as menuService, bH as newsletterService, bI as orderService, bJ as ownDomain, bK as pageService, bL as paymentMethodService, bM as pluginService, bN as pluginsService, bO as popularSearchService, bP as popularityService, bS as productService, bU as profileService, bV as qs, bW as reelsService, bX as regionService, bY as reviewService, bZ as searchService, b_ as setRequestHost, b$ as settingService, c0 as settingsService, c1 as stateService, c2 as staticStore, c3 as storeForHost, c4 as storeService, ci as toPage, cl as toStorefrontFacets, cp as uploadService, cq as userService, cr as variantService, cs as varniCustomDesignService, ct as varniCustomProductService, cu as vendorService, cv as warrantyService, cw as wishlistService } from '../index-GdjWgh5b.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-BsvUnF4H.js';
@@ -2852,6 +2852,71 @@ var ReviewService = class extends BaseService {
2852
2852
  };
2853
2853
  var reviewService = new ReviewService();
2854
2854
 
2855
+ // src/services/google-review-service.ts
2856
+ var PLUGIN = "google-reviews";
2857
+ var GoogleReviewService = class extends BaseService {
2858
+ facts = new StoreFacts(this._fetch);
2859
+ /**
2860
+ * Google's rating and its most relevant reviews, read live. Google's terms
2861
+ * forbid keeping them, so nothing here caches them either, and every call
2862
+ * is one the store pays Google for: call it when the section is in view.
2863
+ */
2864
+ async place() {
2865
+ if (!await this.switchOn("show_place")) return null;
2866
+ const p = await this.orNull(() => this.data("/x/google-reviews/place"));
2867
+ if (!p?.user_rating_count) return null;
2868
+ return {
2869
+ rating: p.rating,
2870
+ count: p.user_rating_count,
2871
+ mapsUrl: p.google_maps_uri ?? "",
2872
+ reviews: (p.reviews ?? []).map((r) => ({
2873
+ author: r.author?.name ?? "",
2874
+ authorUrl: r.author?.uri ?? "",
2875
+ authorPhoto: r.author?.photo_uri ?? "",
2876
+ rating: r.rating,
2877
+ text: r.text ?? "",
2878
+ language: r.language ?? "",
2879
+ when: r.relative_time ?? "",
2880
+ visited: r.visit_date ?? "",
2881
+ url: r.google_maps_uri ?? "",
2882
+ reportUrl: r.flag_uri ?? ""
2883
+ }))
2884
+ };
2885
+ }
2886
+ /**
2887
+ * What Google Customer Reviews' opt-in is rendered with, for an order placed
2888
+ * in this browser: its access token is kept here, and nowhere else can ask.
2889
+ * Every field is the order's own; the keys are Google's, to pass unchanged
2890
+ * to `gapi.surveyoptin.render`.
2891
+ */
2892
+ async survey(orderNumber) {
2893
+ const kept = orderNumber ? placedOrder(orderNumber) : void 0;
2894
+ if (!kept || !await this.switchOn("customer_reviews")) return null;
2895
+ return this.orNull(
2896
+ () => this.data(`/x/google-reviews/survey/${encodeURIComponent(orderNumber)}`, {
2897
+ query: { token: kept.token }
2898
+ })
2899
+ );
2900
+ }
2901
+ async switchOn(setting) {
2902
+ try {
2903
+ return (await this.facts.plugins()).get(PLUGIN)?.settings?.[setting] === true;
2904
+ } catch {
2905
+ return false;
2906
+ }
2907
+ }
2908
+ /** Off, used up for the day, or refused by Google: nothing to show. Anything else still throws. */
2909
+ async orNull(call) {
2910
+ try {
2911
+ return await call();
2912
+ } catch (err) {
2913
+ if (err instanceof GoCommerceError && [404, 429, 502].includes(err.status)) return null;
2914
+ throw err;
2915
+ }
2916
+ }
2917
+ };
2918
+ var googleReviewService = new GoogleReviewService();
2919
+
2855
2920
  // src/services/menu-service.ts
2856
2921
  function linkFor(item) {
2857
2922
  const t = item.target ?? "";
@@ -3031,6 +3096,21 @@ var StoreService = class extends BaseService {
3031
3096
  ...profile?.logo_url ? { logo: mediaUrl(profile.logo_url), logoDark: void 0 } : {},
3032
3097
  ...profile?.logo_dark_url ? { logoDark: mediaUrl(profile.logo_dark_url) } : {},
3033
3098
  ...profile?.icon_url ? { favicon: mediaUrl(profile.icon_url) } : {},
3099
+ // What the contact page shows (D156), only what the store published. The address
3100
+ // in the shape the storefront's contact page and home-page JSON-LD already read. The
3101
+ // country beside it, not over `country`: that is the address form's default country.
3102
+ ...profile?.country ? { businessCountry: profile.country } : {},
3103
+ ...profile?.address ? {
3104
+ address: {
3105
+ street: [profile.address.line1, profile.address.line2].filter(Boolean).join(", "),
3106
+ city: profile.address.city,
3107
+ state: profile.address.state,
3108
+ pincode: profile.address.postal_code,
3109
+ country: profile.address.country
3110
+ }
3111
+ } : {},
3112
+ ...profile?.map_location ? { mapLocation: profile.map_location } : {},
3113
+ ...profile?.opening_hours?.length ? { openingHours: profile.opening_hours } : {},
3034
3114
  currencyCode: code,
3035
3115
  currencySymbol: sameCurrency ? base.currencySymbol ?? symbolFor(code) : symbolFor(code),
3036
3116
  currency: {
@@ -3044,10 +3124,28 @@ var StoreService = class extends BaseService {
3044
3124
  // Features this connector serves from a module: on exactly when the
3045
3125
  // module is installed and switched on, whatever the static record says.
3046
3126
  isWishlist: { ...basePlugins.isWishlist, ...flag(plugins.has("wishlist")) },
3127
+ // The corner button and the contact page's WhatsApp card read the number from
3128
+ // here; the engine's plugin holds it, in international digits.
3129
+ whatsappChatButton: {
3130
+ ...basePlugins.whatsappChatButton,
3131
+ ...flag(plugins.has("whatsapp-chat")),
3132
+ ...plugins.has("whatsapp-chat") ? {
3133
+ phone: String(plugins.get("whatsapp-chat")?.settings?.phone ?? ""),
3134
+ message: String(plugins.get("whatsapp-chat")?.settings?.message ?? "")
3135
+ } : {}
3136
+ },
3047
3137
  isProductReviewsAndRatings: {
3048
3138
  ...basePlugins.isProductReviewsAndRatings,
3049
3139
  ...flag(plugins.has("product-reviews"))
3050
3140
  },
3141
+ // Google Customer Reviews (ext/google-reviews): the confirmation page's survey offer,
3142
+ // whose fields the engine builds from the order, and Google's store widget, which
3143
+ // belongs to the same programme and so needs the survey on.
3144
+ googleReviewsOptIn: {
3145
+ ...basePlugins.googleReviewsOptIn,
3146
+ ...flag(googleSetting(plugins, "customer_reviews") === true)
3147
+ },
3148
+ googleStoreWidget: storeWidget(plugins),
3051
3149
  // The footer's sign-up box posts to ext/newsletter, and the theme editor's footer
3052
3150
  // switch (D131) can only show it while that is on.
3053
3151
  newsletter: { ...basePlugins.newsletter, ...flag(plugins.has("newsletter")) },
@@ -3090,6 +3188,12 @@ function regionName(code) {
3090
3188
  return code;
3091
3189
  }
3092
3190
  }
3191
+ var googleSetting = (plugins, key) => plugins.get("google-reviews")?.settings?.[key];
3192
+ function storeWidget(plugins) {
3193
+ const where = googleSetting(plugins, "store_widget");
3194
+ if (googleSetting(plugins, "customer_reviews") !== true || !where) return { active: false };
3195
+ return { active: true, position: where === "Bottom left" ? "LEFT_BOTTOM" : "RIGHT_BOTTOM" };
3196
+ }
3093
3197
  var LOGIN_TYPES = { phone_otp: "PHONE", email_or_phone: "BOTH", email_password: "EMAIL" };
3094
3198
 
3095
3199
  // src/services/page-service.ts
@@ -3270,7 +3374,8 @@ var ContactService = class extends BaseService {
3270
3374
  email,
3271
3375
  phone,
3272
3376
  message,
3273
- subject
3377
+ subject,
3378
+ website
3274
3379
  }) {
3275
3380
  return this.data("/x/contact/messages", {
3276
3381
  method: "POST",
@@ -3279,7 +3384,8 @@ var ContactService = class extends BaseService {
3279
3384
  email: String(email ?? ""),
3280
3385
  ...phone ? { phone: String(phone) } : {},
3281
3386
  ...subject ? { subject: String(subject) } : {},
3282
- body: String(message ?? "")
3387
+ body: String(message ?? ""),
3388
+ ...website ? { website: String(website) } : {}
3283
3389
  }
3284
3390
  });
3285
3391
  }
@@ -3770,6 +3876,6 @@ function attemptKey(request) {
3770
3876
  }
3771
3877
  var b2bService = new B2bService();
3772
3878
 
3773
- 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 };
3879
+ 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 };
3774
3880
  //# sourceMappingURL=index.js.map
3775
3881
  //# sourceMappingURL=index.js.map