@misiki/gocommerce-connector 0.16.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.
- package/README.md +2 -1
- package/dist/{index-Dm_1E1ai.d.cts → index-BsvUnF4H.d.cts} +85 -1
- package/dist/{index-Dm_1E1ai.d.ts → index-BsvUnF4H.d.ts} +85 -1
- package/dist/index.cjs +81 -0
- 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 +80 -1
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +81 -0
- 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 +80 -1
- package/dist/services/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -142,6 +142,7 @@ down stays best-effort: the storefront renders from its static record.
|
|
|
142
142
|
| PIN code autofill | `/api/postcodes/IN/{pin}` — `addressService.lookupPostcode({ country, postcode })`: city and state, or null when the engine has no directory or the PIN is unknown (D134) |
|
|
143
143
|
| wishlist | `/x/wishlist` |
|
|
144
144
|
| reviews | `/x/reviews` |
|
|
145
|
+
| Google reviews | `/x/google-reviews/place` — `googleReviewService.place()`: the store's Google rating, rating count and up to five Google reviews with their authors' names, photos and profile links, read live on every call because Google's terms forbid keeping them (call it when the section is in view; each call is billed to the store's Google key). Null while ext/google-reviews or its `show_place` switch is off, when the place has no ratings, when the day's lookups are spent (429) or Google refuses (502). `/x/google-reviews/survey/{number}` — `googleReviewService.survey(number)`: Google Customer Reviews' opt-in fields, built by the engine from an order placed in this browser, read with its access token; null for any other order or while `customer_reviews` is off |
|
|
145
146
|
| content pages (`/p/…`, legal pages) | `/x/cms/pages` |
|
|
146
147
|
| FAQ | `/x/faq` |
|
|
147
148
|
| composed home page | `/x/layouts/home` (`?preview=` for a draft) — `layoutService.getHomeLayout()`, null when the store has none; carries `themeSettings` and each collection list's `collections` |
|
|
@@ -154,7 +155,7 @@ down stays best-effort: the storefront renders from its static record.
|
|
|
154
155
|
| newsletter box | `/x/newsletter/subscribe` |
|
|
155
156
|
| 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 |
|
|
156
157
|
| search words, type-ahead (plugin on) | `/x/meilisearch/search`, falling back to the engine's own search when it is off or down |
|
|
157
|
-
| 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),
|
|
158
|
+
| 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) |
|
|
158
159
|
| resized product pictures | `/images/{store}/cdn-cgi/image/width=…/…` — the store record's `plugins.imageCdn` is turned on with provider `cloudflare` and the engine's `images_path` (from `/api/store`, D139) after `PUBLIC_GOCOMMERCE_API_URL`, so the storefront's srcset asks the engine for each width; an engine without it leaves the static record's setting |
|
|
159
160
|
|
|
160
161
|
Blogs, banners, reels, chat, warranties, deals and uploads have no engine
|
|
@@ -418,6 +418,36 @@ type Plugin = {
|
|
|
418
418
|
title: string;
|
|
419
419
|
settings: Record<string, unknown>;
|
|
420
420
|
};
|
|
421
|
+
/** `GET /x/google-reviews/place` (ext/google-reviews): Google's answer just now, never stored. */
|
|
422
|
+
type GooglePlace = {
|
|
423
|
+
rating: number;
|
|
424
|
+
user_rating_count: number;
|
|
425
|
+
google_maps_uri: string;
|
|
426
|
+
reviews: {
|
|
427
|
+
author: {
|
|
428
|
+
name: string;
|
|
429
|
+
uri?: string;
|
|
430
|
+
photo_uri?: string;
|
|
431
|
+
};
|
|
432
|
+
rating: number;
|
|
433
|
+
text?: string;
|
|
434
|
+
language?: string;
|
|
435
|
+
relative_time?: string;
|
|
436
|
+
publish_time?: string;
|
|
437
|
+
visit_date?: string;
|
|
438
|
+
google_maps_uri?: string;
|
|
439
|
+
flag_uri?: string;
|
|
440
|
+
}[];
|
|
441
|
+
};
|
|
442
|
+
/** `GET /x/google-reviews/survey/{number}`: Google Customer Reviews' opt-in fields, from the order. */
|
|
443
|
+
type GoogleSurvey = {
|
|
444
|
+
merchant_id: number;
|
|
445
|
+
order_id: string;
|
|
446
|
+
email: string;
|
|
447
|
+
delivery_country: string;
|
|
448
|
+
estimated_delivery_date: string;
|
|
449
|
+
opt_in_style?: string;
|
|
450
|
+
};
|
|
421
451
|
/** `GET /api/store`: what anyone may read about the shop. */
|
|
422
452
|
type StoreProfile = {
|
|
423
453
|
name: string;
|
|
@@ -6150,6 +6180,60 @@ declare class ReviewService extends BaseService {
|
|
|
6150
6180
|
}
|
|
6151
6181
|
declare const reviewService: ReviewService;
|
|
6152
6182
|
|
|
6183
|
+
/** A Google review with what Google's attribution policy asks a storefront to show. */
|
|
6184
|
+
type GoogleReview = {
|
|
6185
|
+
author: string;
|
|
6186
|
+
/** The author's Google profile and photo; https or empty. */
|
|
6187
|
+
authorUrl: string;
|
|
6188
|
+
authorPhoto: string;
|
|
6189
|
+
rating: number;
|
|
6190
|
+
/** The reviewer's own words, in their language. Empty for a rating with no words. */
|
|
6191
|
+
text: string;
|
|
6192
|
+
language: string;
|
|
6193
|
+
/** Google's own words for when, such as "a month ago". */
|
|
6194
|
+
when: string;
|
|
6195
|
+
/** YYYY-MM, when Google has one. */
|
|
6196
|
+
visited: string;
|
|
6197
|
+
/** The review on Google Maps, and where to report it to Google. */
|
|
6198
|
+
url: string;
|
|
6199
|
+
reportUrl: string;
|
|
6200
|
+
};
|
|
6201
|
+
type GoogleReviews = {
|
|
6202
|
+
/** Google's own rating and count, never worked out from `reviews`. */
|
|
6203
|
+
rating: number;
|
|
6204
|
+
count: number;
|
|
6205
|
+
/** Every review, on Google Maps: `reviews` are at most five of them. */
|
|
6206
|
+
mapsUrl: string;
|
|
6207
|
+
reviews: GoogleReview[];
|
|
6208
|
+
};
|
|
6209
|
+
/**
|
|
6210
|
+
* The store's Google reviews and Google Customer Reviews (ext/google-reviews).
|
|
6211
|
+
*
|
|
6212
|
+
* Both calls answer null when there is nothing to show — the plugin or its
|
|
6213
|
+
* switch off, Google refusing, the day's lookups spent — because each is an
|
|
6214
|
+
* extra on a page that must render without it.
|
|
6215
|
+
*/
|
|
6216
|
+
declare class GoogleReviewService extends BaseService {
|
|
6217
|
+
private readonly facts;
|
|
6218
|
+
/**
|
|
6219
|
+
* Google's rating and its most relevant reviews, read live. Google's terms
|
|
6220
|
+
* forbid keeping them, so nothing here caches them either, and every call
|
|
6221
|
+
* is one the store pays Google for: call it when the section is in view.
|
|
6222
|
+
*/
|
|
6223
|
+
place(): Promise<GoogleReviews | null>;
|
|
6224
|
+
/**
|
|
6225
|
+
* What Google Customer Reviews' opt-in is rendered with, for an order placed
|
|
6226
|
+
* in this browser: its access token is kept here, and nowhere else can ask.
|
|
6227
|
+
* Every field is the order's own; the keys are Google's, to pass unchanged
|
|
6228
|
+
* to `gapi.surveyoptin.render`.
|
|
6229
|
+
*/
|
|
6230
|
+
survey(orderNumber: string): Promise<GoogleSurvey | null>;
|
|
6231
|
+
private switchOn;
|
|
6232
|
+
/** Off, used up for the day, or refused by Google: nothing to show. Anything else still throws. */
|
|
6233
|
+
private orNull;
|
|
6234
|
+
}
|
|
6235
|
+
declare const googleReviewService: GoogleReviewService;
|
|
6236
|
+
|
|
6153
6237
|
type StorefrontMenu = {
|
|
6154
6238
|
menuId: string;
|
|
6155
6239
|
name: string;
|
|
@@ -7609,4 +7693,4 @@ declare class B2bService extends BaseService {
|
|
|
7609
7693
|
}
|
|
7610
7694
|
declare const b2bService: B2bService;
|
|
7611
7695
|
|
|
7612
|
-
export {
|
|
7696
|
+
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, profileService 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, faqService as bA, feedbackService as bB, fromEngineAddress as bC, fromIdentityAddress as bD, fromSearchDoc as bE, galleryService as bF, googleReviewService as bG, homeService as bH, initService as bI, layoutService as bJ, mediaUrl as bK, meilisearchService as bL, menuService as bM, minorToMajor as bN, newsletterService as bO, orderService as bP, ownDomain as bQ, pageService as bR, paymentMethodService as bS, pluginService as bT, pluginsService as bU, popularSearchService as bV, popularityService as bW, priceOf as bX, productImages as bY, productService as bZ, productVideos as b_, VendorService as ba, WarrantyService as bb, type Wishlist as bc, type WishlistItem as bd, WishlistService as be, addressService as bf, authService as bg, autocompleteService as bh, b2bService as bi, bannerService as bj, blogService as bk, cartService as bl, categoryService as bm, chatService as bn, checkoutService as bo, collectionService as bp, contactService as bq, countryService as br, couponService as bs, currencyExponent as bt, currencyService as bu, dealService as bv, demoRequestService as bw, emptyCart as bx, emptyPage as by, enquiryService as bz, type AppliedDiscount as c, qs as c0, reelsService as c1, regionService as c2, reviewService as c3, searchService as c4, setRequestHost as c5, settingService as c6, settingsService as c7, stateService as c8, staticStore as c9, varniCustomProductService as cA, vendorService as cB, warrantyService as cC, wishlistService as cD, storeForHost as ca, storeService as cb, toAddOn as cc, toCart as cd, toCartLine as ce, toCartOffer as cf, toCategory as cg, toCmsPage as ch, toCollection as ci, toEngineAddress as cj, toFreeShipping as ck, toIdentityAddress as cl, toMajor as cm, toMinor as cn, toOrder as co, toPage as cp, toProduct as cq, toRating as cr, toStorefrontFacets as cs, toUser as ct, toVariant as cu, toVendor as cv, uploadService as cw, userService as cx, variantService as cy, varniCustomDesignService 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 };
|
|
@@ -418,6 +418,36 @@ type Plugin = {
|
|
|
418
418
|
title: string;
|
|
419
419
|
settings: Record<string, unknown>;
|
|
420
420
|
};
|
|
421
|
+
/** `GET /x/google-reviews/place` (ext/google-reviews): Google's answer just now, never stored. */
|
|
422
|
+
type GooglePlace = {
|
|
423
|
+
rating: number;
|
|
424
|
+
user_rating_count: number;
|
|
425
|
+
google_maps_uri: string;
|
|
426
|
+
reviews: {
|
|
427
|
+
author: {
|
|
428
|
+
name: string;
|
|
429
|
+
uri?: string;
|
|
430
|
+
photo_uri?: string;
|
|
431
|
+
};
|
|
432
|
+
rating: number;
|
|
433
|
+
text?: string;
|
|
434
|
+
language?: string;
|
|
435
|
+
relative_time?: string;
|
|
436
|
+
publish_time?: string;
|
|
437
|
+
visit_date?: string;
|
|
438
|
+
google_maps_uri?: string;
|
|
439
|
+
flag_uri?: string;
|
|
440
|
+
}[];
|
|
441
|
+
};
|
|
442
|
+
/** `GET /x/google-reviews/survey/{number}`: Google Customer Reviews' opt-in fields, from the order. */
|
|
443
|
+
type GoogleSurvey = {
|
|
444
|
+
merchant_id: number;
|
|
445
|
+
order_id: string;
|
|
446
|
+
email: string;
|
|
447
|
+
delivery_country: string;
|
|
448
|
+
estimated_delivery_date: string;
|
|
449
|
+
opt_in_style?: string;
|
|
450
|
+
};
|
|
421
451
|
/** `GET /api/store`: what anyone may read about the shop. */
|
|
422
452
|
type StoreProfile = {
|
|
423
453
|
name: string;
|
|
@@ -6150,6 +6180,60 @@ declare class ReviewService extends BaseService {
|
|
|
6150
6180
|
}
|
|
6151
6181
|
declare const reviewService: ReviewService;
|
|
6152
6182
|
|
|
6183
|
+
/** A Google review with what Google's attribution policy asks a storefront to show. */
|
|
6184
|
+
type GoogleReview = {
|
|
6185
|
+
author: string;
|
|
6186
|
+
/** The author's Google profile and photo; https or empty. */
|
|
6187
|
+
authorUrl: string;
|
|
6188
|
+
authorPhoto: string;
|
|
6189
|
+
rating: number;
|
|
6190
|
+
/** The reviewer's own words, in their language. Empty for a rating with no words. */
|
|
6191
|
+
text: string;
|
|
6192
|
+
language: string;
|
|
6193
|
+
/** Google's own words for when, such as "a month ago". */
|
|
6194
|
+
when: string;
|
|
6195
|
+
/** YYYY-MM, when Google has one. */
|
|
6196
|
+
visited: string;
|
|
6197
|
+
/** The review on Google Maps, and where to report it to Google. */
|
|
6198
|
+
url: string;
|
|
6199
|
+
reportUrl: string;
|
|
6200
|
+
};
|
|
6201
|
+
type GoogleReviews = {
|
|
6202
|
+
/** Google's own rating and count, never worked out from `reviews`. */
|
|
6203
|
+
rating: number;
|
|
6204
|
+
count: number;
|
|
6205
|
+
/** Every review, on Google Maps: `reviews` are at most five of them. */
|
|
6206
|
+
mapsUrl: string;
|
|
6207
|
+
reviews: GoogleReview[];
|
|
6208
|
+
};
|
|
6209
|
+
/**
|
|
6210
|
+
* The store's Google reviews and Google Customer Reviews (ext/google-reviews).
|
|
6211
|
+
*
|
|
6212
|
+
* Both calls answer null when there is nothing to show — the plugin or its
|
|
6213
|
+
* switch off, Google refusing, the day's lookups spent — because each is an
|
|
6214
|
+
* extra on a page that must render without it.
|
|
6215
|
+
*/
|
|
6216
|
+
declare class GoogleReviewService extends BaseService {
|
|
6217
|
+
private readonly facts;
|
|
6218
|
+
/**
|
|
6219
|
+
* Google's rating and its most relevant reviews, read live. Google's terms
|
|
6220
|
+
* forbid keeping them, so nothing here caches them either, and every call
|
|
6221
|
+
* is one the store pays Google for: call it when the section is in view.
|
|
6222
|
+
*/
|
|
6223
|
+
place(): Promise<GoogleReviews | null>;
|
|
6224
|
+
/**
|
|
6225
|
+
* What Google Customer Reviews' opt-in is rendered with, for an order placed
|
|
6226
|
+
* in this browser: its access token is kept here, and nowhere else can ask.
|
|
6227
|
+
* Every field is the order's own; the keys are Google's, to pass unchanged
|
|
6228
|
+
* to `gapi.surveyoptin.render`.
|
|
6229
|
+
*/
|
|
6230
|
+
survey(orderNumber: string): Promise<GoogleSurvey | null>;
|
|
6231
|
+
private switchOn;
|
|
6232
|
+
/** Off, used up for the day, or refused by Google: nothing to show. Anything else still throws. */
|
|
6233
|
+
private orNull;
|
|
6234
|
+
}
|
|
6235
|
+
declare const googleReviewService: GoogleReviewService;
|
|
6236
|
+
|
|
6153
6237
|
type StorefrontMenu = {
|
|
6154
6238
|
menuId: string;
|
|
6155
6239
|
name: string;
|
|
@@ -7609,4 +7693,4 @@ declare class B2bService extends BaseService {
|
|
|
7609
7693
|
}
|
|
7610
7694
|
declare const b2bService: B2bService;
|
|
7611
7695
|
|
|
7612
|
-
export {
|
|
7696
|
+
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, profileService 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, faqService as bA, feedbackService as bB, fromEngineAddress as bC, fromIdentityAddress as bD, fromSearchDoc as bE, galleryService as bF, googleReviewService as bG, homeService as bH, initService as bI, layoutService as bJ, mediaUrl as bK, meilisearchService as bL, menuService as bM, minorToMajor as bN, newsletterService as bO, orderService as bP, ownDomain as bQ, pageService as bR, paymentMethodService as bS, pluginService as bT, pluginsService as bU, popularSearchService as bV, popularityService as bW, priceOf as bX, productImages as bY, productService as bZ, productVideos as b_, VendorService as ba, WarrantyService as bb, type Wishlist as bc, type WishlistItem as bd, WishlistService as be, addressService as bf, authService as bg, autocompleteService as bh, b2bService as bi, bannerService as bj, blogService as bk, cartService as bl, categoryService as bm, chatService as bn, checkoutService as bo, collectionService as bp, contactService as bq, countryService as br, couponService as bs, currencyExponent as bt, currencyService as bu, dealService as bv, demoRequestService as bw, emptyCart as bx, emptyPage as by, enquiryService as bz, type AppliedDiscount as c, qs as c0, reelsService as c1, regionService as c2, reviewService as c3, searchService as c4, setRequestHost as c5, settingService as c6, settingsService as c7, stateService as c8, staticStore as c9, varniCustomProductService as cA, vendorService as cB, warrantyService as cC, wishlistService as cD, storeForHost as ca, storeService as cb, toAddOn as cc, toCart as cd, toCartLine as ce, toCartOffer as cf, toCategory as cg, toCmsPage as ch, toCollection as ci, toEngineAddress as cj, toFreeShipping as ck, toIdentityAddress as cl, toMajor as cm, toMinor as cn, toOrder as co, toPage as cp, toProduct as cq, toRating as cr, toStorefrontFacets as cs, toUser as ct, toVariant as cu, toVendor as cv, uploadService as cw, userService as cx, variantService as cy, varniCustomDesignService 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
|
@@ -2873,6 +2873,71 @@ var ReviewService = class extends BaseService {
|
|
|
2873
2873
|
};
|
|
2874
2874
|
var reviewService = new ReviewService();
|
|
2875
2875
|
|
|
2876
|
+
// src/services/google-review-service.ts
|
|
2877
|
+
var PLUGIN = "google-reviews";
|
|
2878
|
+
var GoogleReviewService = class extends BaseService {
|
|
2879
|
+
facts = new StoreFacts(this._fetch);
|
|
2880
|
+
/**
|
|
2881
|
+
* Google's rating and its most relevant reviews, read live. Google's terms
|
|
2882
|
+
* forbid keeping them, so nothing here caches them either, and every call
|
|
2883
|
+
* is one the store pays Google for: call it when the section is in view.
|
|
2884
|
+
*/
|
|
2885
|
+
async place() {
|
|
2886
|
+
if (!await this.switchOn("show_place")) return null;
|
|
2887
|
+
const p = await this.orNull(() => this.data("/x/google-reviews/place"));
|
|
2888
|
+
if (!p?.user_rating_count) return null;
|
|
2889
|
+
return {
|
|
2890
|
+
rating: p.rating,
|
|
2891
|
+
count: p.user_rating_count,
|
|
2892
|
+
mapsUrl: p.google_maps_uri ?? "",
|
|
2893
|
+
reviews: (p.reviews ?? []).map((r) => ({
|
|
2894
|
+
author: r.author?.name ?? "",
|
|
2895
|
+
authorUrl: r.author?.uri ?? "",
|
|
2896
|
+
authorPhoto: r.author?.photo_uri ?? "",
|
|
2897
|
+
rating: r.rating,
|
|
2898
|
+
text: r.text ?? "",
|
|
2899
|
+
language: r.language ?? "",
|
|
2900
|
+
when: r.relative_time ?? "",
|
|
2901
|
+
visited: r.visit_date ?? "",
|
|
2902
|
+
url: r.google_maps_uri ?? "",
|
|
2903
|
+
reportUrl: r.flag_uri ?? ""
|
|
2904
|
+
}))
|
|
2905
|
+
};
|
|
2906
|
+
}
|
|
2907
|
+
/**
|
|
2908
|
+
* What Google Customer Reviews' opt-in is rendered with, for an order placed
|
|
2909
|
+
* in this browser: its access token is kept here, and nowhere else can ask.
|
|
2910
|
+
* Every field is the order's own; the keys are Google's, to pass unchanged
|
|
2911
|
+
* to `gapi.surveyoptin.render`.
|
|
2912
|
+
*/
|
|
2913
|
+
async survey(orderNumber) {
|
|
2914
|
+
const kept = orderNumber ? placedOrder(orderNumber) : void 0;
|
|
2915
|
+
if (!kept || !await this.switchOn("customer_reviews")) return null;
|
|
2916
|
+
return this.orNull(
|
|
2917
|
+
() => this.data(`/x/google-reviews/survey/${encodeURIComponent(orderNumber)}`, {
|
|
2918
|
+
query: { token: kept.token }
|
|
2919
|
+
})
|
|
2920
|
+
);
|
|
2921
|
+
}
|
|
2922
|
+
async switchOn(setting) {
|
|
2923
|
+
try {
|
|
2924
|
+
return (await this.facts.plugins()).get(PLUGIN)?.settings?.[setting] === true;
|
|
2925
|
+
} catch {
|
|
2926
|
+
return false;
|
|
2927
|
+
}
|
|
2928
|
+
}
|
|
2929
|
+
/** Off, used up for the day, or refused by Google: nothing to show. Anything else still throws. */
|
|
2930
|
+
async orNull(call) {
|
|
2931
|
+
try {
|
|
2932
|
+
return await call();
|
|
2933
|
+
} catch (err) {
|
|
2934
|
+
if (err instanceof GoCommerceError && [404, 429, 502].includes(err.status)) return null;
|
|
2935
|
+
throw err;
|
|
2936
|
+
}
|
|
2937
|
+
}
|
|
2938
|
+
};
|
|
2939
|
+
var googleReviewService = new GoogleReviewService();
|
|
2940
|
+
|
|
2876
2941
|
// src/services/menu-service.ts
|
|
2877
2942
|
function linkFor(item) {
|
|
2878
2943
|
const t = item.target ?? "";
|
|
@@ -3091,6 +3156,14 @@ var StoreService = class extends BaseService {
|
|
|
3091
3156
|
...basePlugins.isProductReviewsAndRatings,
|
|
3092
3157
|
...flag(plugins.has("product-reviews"))
|
|
3093
3158
|
},
|
|
3159
|
+
// Google Customer Reviews (ext/google-reviews): the confirmation page's survey offer,
|
|
3160
|
+
// whose fields the engine builds from the order, and Google's store widget, which
|
|
3161
|
+
// belongs to the same programme and so needs the survey on.
|
|
3162
|
+
googleReviewsOptIn: {
|
|
3163
|
+
...basePlugins.googleReviewsOptIn,
|
|
3164
|
+
...flag(googleSetting(plugins, "customer_reviews") === true)
|
|
3165
|
+
},
|
|
3166
|
+
googleStoreWidget: storeWidget(plugins),
|
|
3094
3167
|
// The footer's sign-up box posts to ext/newsletter, and the theme editor's footer
|
|
3095
3168
|
// switch (D131) can only show it while that is on.
|
|
3096
3169
|
newsletter: { ...basePlugins.newsletter, ...flag(plugins.has("newsletter")) },
|
|
@@ -3133,6 +3206,12 @@ function regionName(code) {
|
|
|
3133
3206
|
return code;
|
|
3134
3207
|
}
|
|
3135
3208
|
}
|
|
3209
|
+
var googleSetting = (plugins, key) => plugins.get("google-reviews")?.settings?.[key];
|
|
3210
|
+
function storeWidget(plugins) {
|
|
3211
|
+
const where = googleSetting(plugins, "store_widget");
|
|
3212
|
+
if (googleSetting(plugins, "customer_reviews") !== true || !where) return { active: false };
|
|
3213
|
+
return { active: true, position: where === "Bottom left" ? "LEFT_BOTTOM" : "RIGHT_BOTTOM" };
|
|
3214
|
+
}
|
|
3136
3215
|
var LOGIN_TYPES = { phone_otp: "PHONE", email_or_phone: "BOTH", email_password: "EMAIL" };
|
|
3137
3216
|
|
|
3138
3217
|
// src/services/page-service.ts
|
|
@@ -3839,6 +3918,7 @@ exports.FaqService = FaqService;
|
|
|
3839
3918
|
exports.FeedbackService = FeedbackService;
|
|
3840
3919
|
exports.GalleryService = GalleryService;
|
|
3841
3920
|
exports.GoCommerceError = GoCommerceError;
|
|
3921
|
+
exports.GoogleReviewService = GoogleReviewService;
|
|
3842
3922
|
exports.HomeService = HomeService;
|
|
3843
3923
|
exports.InitService = InitService;
|
|
3844
3924
|
exports.LayoutService = LayoutService;
|
|
@@ -3901,6 +3981,7 @@ exports.fromEngineAddress = fromEngineAddress;
|
|
|
3901
3981
|
exports.fromIdentityAddress = fromIdentityAddress;
|
|
3902
3982
|
exports.fromSearchDoc = fromSearchDoc;
|
|
3903
3983
|
exports.galleryService = galleryService;
|
|
3984
|
+
exports.googleReviewService = googleReviewService;
|
|
3904
3985
|
exports.hasStaticStore = hasStaticStore;
|
|
3905
3986
|
exports.homeService = homeService;
|
|
3906
3987
|
exports.initService = initService;
|