@misiki/gocommerce-connector 0.12.0 → 0.13.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 CHANGED
@@ -127,16 +127,18 @@ down stays best-effort: the storefront renders from its static record.
127
127
  | category pages and tree | `/api/categories`, `/api/categories/{slug}` — a category sells its descendants |
128
128
  | collections | `/api/collections`, `/api/collections/{slug}` |
129
129
  | featured / trending shelves | the collection with slug `featured` / `trending`; newest products when there is none |
130
+ | product page extras | on the product from `/api/products/slug/{slug}` (D134): `highlights` and `freeGift` from the product's own metadata, `soldAtLeast` when the shop shows sold counts (null otherwise, never zero), and the product's videos after its pictures in `images` (and alone in `videos`), so the gallery plays them |
130
131
  | bag | `/api/carts…`, `/api/carts/{token}/discount` |
131
132
  | Complete the set (add-ons) | `/api/add-ons?product_id=` — `productService.listAddOns({ product })`, each at the price ticking it adds (`price`) beside its own (`regularPrice`); `cartService.addAddOn({ addOnId })` after the product is in the bag. The engine keeps the offer price only while the product is in the bag, one for each |
132
- | You may also like | `/api/cross-sells?product_id=` — `productService.listCrossSells({ product })`, curated only; the bag's `/api/carts/{token}/cross-sells` — `cartService.listCrossSells()`, falling back to the first item's related products |
133
+ | You may also like | `/api/cross-sells?product_id=` — `productService.listCrossSells({ product })`, curated only; the bag's `/api/carts/{token}/cross-sells` — `cartService.listCrossSells()`, which includes the collection the shop chose for every basket (D134), falling back to the first item's related products |
133
134
  | the bag's offers and free delivery | `/api/carts/{token}/offers` — `cartService.getOffers()` and the coupon drawer's `couponService.listCoupons()`: only the codes the shop chose to show; `/api/carts/{token}/free-shipping` — `cartService.getFreeShipping()`, from the store's own rates, null when it cannot say |
134
135
  | delivery options | `/api/checkout/rates` |
135
136
  | payment methods | `/api/checkout` — cash on delivery, Razorpay, and the first hosted-page gateway (see below) |
136
137
  | place order | `POST /api/checkout/{code}` with an `Idempotency-Key` |
137
138
  | order lookup | `/api/orders/{number}?token=` (guest), `/x/identity/me/orders` (account) |
138
139
  | sign-in, sign-up, profile, password reset | `/x/identity/*` |
139
- | address book | `/x/identity/me/addresses` |
140
+ | address book | `/x/identity/me/addresses`, with its `label` (Home, Work, Other) |
141
+ | 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) |
140
142
  | wishlist | `/x/wishlist` |
141
143
  | reviews | `/x/reviews` |
142
144
  | content pages (`/p/…`, legal pages) | `/x/cms/pages` |
@@ -201,6 +201,10 @@ type Product = {
201
201
  seo_description: string;
202
202
  image_url?: string;
203
203
  media_count?: number;
204
+ /** The gallery, pictures and videos in order: on the public product only (D134). */
205
+ media?: VariantImage[];
206
+ /** The sold count rounded down; absent unless the shop shows counts and it passed the threshold (D134). */
207
+ sold_at_least?: number;
204
208
  options: ProductOption[] | null;
205
209
  variants: Variant[] | null;
206
210
  collections: {
@@ -589,6 +593,14 @@ type MenuSummary = {
589
593
  handle: string;
590
594
  title: string;
591
595
  };
596
+ /** GET /api/postcodes/{country}/{code} (D134). */
597
+ type Postcode = {
598
+ country: string;
599
+ postcode: string;
600
+ city: string;
601
+ state: string;
602
+ state_code: string;
603
+ };
592
604
 
593
605
  /**
594
606
  * The state this connector keeps in the shopper's browser, and only there.
@@ -650,11 +662,16 @@ type CartExtras = {
650
662
  };
651
663
 
652
664
  /**
653
- * Every picture the public API offers for a product: the lead image, then each
654
- * variant's. The engine keeps the full gallery on admin routes only, so this
655
- * is the honest union rather than the whole media library.
665
+ * Every picture the public API offers for a product: the lead image, the
666
+ * product's gallery (on the single product, D134), then each variant's.
656
667
  */
657
668
  declare function productImages(p: Product): string[];
669
+ /**
670
+ * The product's videos, an upload or a YouTube link, in the gallery's order
671
+ * (D134). They follow the pictures in `images`, where the storefront's gallery
672
+ * plays them; a card's thumbnail is never one.
673
+ */
674
+ declare function productVideos(p: Product): string[];
658
675
  declare function toVariant(v: Variant, p: Product, optionless: boolean): {
659
676
  id: string;
660
677
  productId: string;
@@ -711,6 +728,10 @@ declare function toProduct(p: Product, extra?: {
711
728
  image_url: string;
712
729
  images: string;
713
730
  imageList: string[];
731
+ videos: string[];
732
+ highlights: string[];
733
+ freeGift: string | null;
734
+ soldAtLeast: number | null;
714
735
  manageInventory: boolean;
715
736
  allowBackorder: boolean;
716
737
  stock: number;
@@ -1511,6 +1532,10 @@ declare class ProductService extends CatalogService {
1511
1532
  image_url: string;
1512
1533
  images: string;
1513
1534
  imageList: string[];
1535
+ videos: string[];
1536
+ highlights: string[];
1537
+ freeGift: string | null;
1538
+ soldAtLeast: number | null;
1514
1539
  manageInventory: boolean;
1515
1540
  allowBackorder: boolean;
1516
1541
  stock: number;
@@ -1624,6 +1649,10 @@ declare class ProductService extends CatalogService {
1624
1649
  image_url: string;
1625
1650
  images: string;
1626
1651
  imageList: string[];
1652
+ videos: string[];
1653
+ highlights: string[];
1654
+ freeGift: string | null;
1655
+ soldAtLeast: number | null;
1627
1656
  manageInventory: boolean;
1628
1657
  allowBackorder: boolean;
1629
1658
  stock: number;
@@ -1772,6 +1801,10 @@ declare class ProductService extends CatalogService {
1772
1801
  image_url: string;
1773
1802
  images: string;
1774
1803
  imageList: string[];
1804
+ videos: string[];
1805
+ highlights: string[];
1806
+ freeGift: string | null;
1807
+ soldAtLeast: number | null;
1775
1808
  manageInventory: boolean;
1776
1809
  allowBackorder: boolean;
1777
1810
  stock: number;
@@ -1919,6 +1952,10 @@ declare class ProductService extends CatalogService {
1919
1952
  image_url: string;
1920
1953
  images: string;
1921
1954
  imageList: string[];
1955
+ videos: string[];
1956
+ highlights: string[];
1957
+ freeGift: string | null;
1958
+ soldAtLeast: number | null;
1922
1959
  manageInventory: boolean;
1923
1960
  allowBackorder: boolean;
1924
1961
  stock: number;
@@ -2113,6 +2150,10 @@ declare class ProductService extends CatalogService {
2113
2150
  image_url: string;
2114
2151
  images: string;
2115
2152
  imageList: string[];
2153
+ videos: string[];
2154
+ highlights: string[];
2155
+ freeGift: string | null;
2156
+ soldAtLeast: number | null;
2116
2157
  manageInventory: boolean;
2117
2158
  allowBackorder: boolean;
2118
2159
  stock: number;
@@ -2333,6 +2374,10 @@ declare class SearchService extends CatalogService {
2333
2374
  image_url: string;
2334
2375
  images: string;
2335
2376
  imageList: string[];
2377
+ videos: string[];
2378
+ highlights: string[];
2379
+ freeGift: string | null;
2380
+ soldAtLeast: number | null;
2336
2381
  manageInventory: boolean;
2337
2382
  allowBackorder: boolean;
2338
2383
  stock: number;
@@ -2518,6 +2563,10 @@ declare class MeilisearchService extends CatalogService {
2518
2563
  image_url: string;
2519
2564
  images: string;
2520
2565
  imageList: string[];
2566
+ videos: string[];
2567
+ highlights: string[];
2568
+ freeGift: string | null;
2569
+ soldAtLeast: number | null;
2521
2570
  manageInventory: boolean;
2522
2571
  allowBackorder: boolean;
2523
2572
  stock: number;
@@ -2705,6 +2754,10 @@ declare class MeilisearchService extends CatalogService {
2705
2754
  image_url: string;
2706
2755
  images: string;
2707
2756
  imageList: string[];
2757
+ videos: string[];
2758
+ highlights: string[];
2759
+ freeGift: string | null;
2760
+ soldAtLeast: number | null;
2708
2761
  manageInventory: boolean;
2709
2762
  allowBackorder: boolean;
2710
2763
  stock: number;
@@ -2894,6 +2947,10 @@ declare class CollectionService extends BaseService {
2894
2947
  image_url: string;
2895
2948
  images: string;
2896
2949
  imageList: string[];
2950
+ videos: string[];
2951
+ highlights: string[];
2952
+ freeGift: string | null;
2953
+ soldAtLeast: number | null;
2897
2954
  manageInventory: boolean;
2898
2955
  allowBackorder: boolean;
2899
2956
  stock: number;
@@ -3002,6 +3059,10 @@ declare class CollectionService extends BaseService {
3002
3059
  image_url: string;
3003
3060
  images: string;
3004
3061
  imageList: string[];
3062
+ videos: string[];
3063
+ highlights: string[];
3064
+ freeGift: string | null;
3065
+ soldAtLeast: number | null;
3005
3066
  manageInventory: boolean;
3006
3067
  allowBackorder: boolean;
3007
3068
  stock: number;
@@ -5779,6 +5840,22 @@ declare class AddressService extends BaseService {
5779
5840
  createdAt: string;
5780
5841
  updatedAt: string;
5781
5842
  }>;
5843
+ /**
5844
+ * The city and state for a postcode (D134), for the address form to fill
5845
+ * in. India's six-digit PIN codes only, from the directory the engine was
5846
+ * given; null for anything it cannot answer, so the form simply leaves the
5847
+ * fields to the shopper.
5848
+ */
5849
+ lookupPostcode({ country, postcode }: {
5850
+ country?: string;
5851
+ postcode: string;
5852
+ }): Promise<{
5853
+ country: string;
5854
+ postcode: string;
5855
+ city: string;
5856
+ state: string;
5857
+ stateCode: string;
5858
+ } | null>;
5782
5859
  deleteAddress(id: string): Promise<{
5783
5860
  id: string;
5784
5861
  deleted: boolean;
@@ -5824,6 +5901,10 @@ declare class WishlistService extends BaseService {
5824
5901
  image_url: string;
5825
5902
  images: string;
5826
5903
  imageList: string[];
5904
+ videos: string[];
5905
+ highlights: string[];
5906
+ freeGift: string | null;
5907
+ soldAtLeast: number | null;
5827
5908
  manageInventory: boolean;
5828
5909
  allowBackorder: boolean;
5829
5910
  stock: number;
@@ -6582,6 +6663,10 @@ declare class AutocompleteService extends MeilisearchService {
6582
6663
  image_url: string;
6583
6664
  images: string;
6584
6665
  imageList: string[];
6666
+ videos: string[];
6667
+ highlights: string[];
6668
+ freeGift: string | null;
6669
+ soldAtLeast: number | null;
6585
6670
  manageInventory: boolean;
6586
6671
  allowBackorder: boolean;
6587
6672
  stock: number;
@@ -7482,4 +7567,4 @@ declare class B2bService extends BaseService {
7482
7567
  }
7483
7568
  declare const b2bService: B2bService;
7484
7569
 
7485
- export { HomeService 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 HeaderSettings as Y, type HomeLayout as Z, type HomeLayoutSection as _, type Address as a, VariantService as a$, type IdentityAddress as a0, InitService as a1, type Invitation as a2, type LayoutCollection as a3, type LayoutPage as a4, LayoutService as a5, type Lead as a6, type ListMeta as a7, MeilisearchService as a8, type Member as a9, RegionService as aA, type RejectedLine as aB, type Review as aC, type ReviewPage as aD, ReviewService as aE, type SearchDoc as aF, type SearchResult as aG, SearchService as aH, SettingService as aI, type ShippingRate as aJ, type SiteChrome as aK, type SiteFooter as aL, type SiteHeader as aM, type SocialLink as aN, StateService as aO, type StoreProfile as aP, StoreService as aQ, type StorefrontCategory as aR, type StorefrontMenu as aS, type StorefrontOrder as aT, type StorefrontProduct as aU, type ThemeSettings as aV, type ThemeSettingsResult as aW, UploadService as aX, UserService as aY, type Variant as aZ, type VariantImage as a_, type Menu as aa, type MenuItem as ab, MenuService as ac, type MenuSummary as ad, type Money as ae, NewsletterService as af, type Offer as ag, type Order as ah, type OrderLine as ai, OrderService as aj, type PageLayout as ak, PageService as al, type PaymentIntent as am, PaymentMethodService as an, type Plugin as ao, PluginService as ap, PopularSearchService as aq, PopularityService as ar, type Product as as, type ProductFacets as at, type ProductOption as au, ProductService as av, ProfileService as aw, type Quote as ax, REDIRECT_GATEWAYS as ay, ReelsService as az, AddressService as b, stateService as b$, VarniCustomDesignService as b0, VarniCustomProductService as b1, type Vendor as b2, VendorService as b3, WarrantyService as b4, type Wishlist as b5, type WishlistItem as b6, WishlistService as b7, addressService as b8, authService as b9, initService as bA, layoutService as bB, mediaUrl as bC, meilisearchService as bD, menuService as bE, minorToMajor as bF, newsletterService as bG, orderService as bH, ownDomain as bI, pageService as bJ, paymentMethodService as bK, pluginService as bL, pluginsService as bM, popularSearchService as bN, popularityService as bO, priceOf as bP, productImages as bQ, productService as bR, profileService as bS, qs as bT, reelsService as bU, regionService as bV, reviewService as bW, searchService as bX, setRequestHost as bY, settingService as bZ, settingsService as b_, autocompleteService as ba, b2bService as bb, bannerService as bc, blogService as bd, cartService as be, categoryService as bf, chatService as bg, checkoutService as bh, collectionService as bi, contactService as bj, countryService as bk, couponService as bl, currencyExponent as bm, currencyService as bn, dealService as bo, demoRequestService as bp, emptyCart as bq, emptyPage as br, enquiryService as bs, faqService as bt, feedbackService as bu, fromEngineAddress as bv, fromIdentityAddress as bw, fromSearchDoc as bx, galleryService as by, homeService as bz, type AppliedDiscount as c, staticStore as c0, storeForHost as c1, storeService as c2, toAddOn as c3, toCart as c4, toCartLine as c5, toCartOffer as c6, toCategory as c7, toCmsPage as c8, toCollection as c9, toEngineAddress as ca, toFreeShipping as cb, toIdentityAddress as cc, toMajor as cd, toMinor as ce, toOrder as cf, toPage as cg, toProduct as ch, toRating as ci, toStorefrontFacets as cj, toUser as ck, toVariant as cl, toVendor as cm, uploadService as cn, userService as co, variantService as cp, varniCustomDesignService as cq, varniCustomProductService as cr, vendorService as cs, warrantyService as ct, wishlistService as cu, 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 };
7570
+ export { HomeService 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 HeaderSettings as Y, type HomeLayout as Z, type HomeLayoutSection as _, type Address as a, type VariantImage as a$, type IdentityAddress as a0, InitService as a1, type Invitation as a2, type LayoutCollection as a3, type LayoutPage as a4, LayoutService as a5, type Lead as a6, type ListMeta as a7, MeilisearchService as a8, type Member as a9, ReelsService as aA, RegionService as aB, type RejectedLine as aC, type Review as aD, type ReviewPage as aE, ReviewService as aF, type SearchDoc as aG, type SearchResult as aH, SearchService as aI, SettingService as aJ, type ShippingRate as aK, type SiteChrome as aL, type SiteFooter as aM, type SiteHeader as aN, type SocialLink as aO, StateService as aP, type StoreProfile as aQ, StoreService as aR, type StorefrontCategory as aS, type StorefrontMenu as aT, type StorefrontOrder as aU, type StorefrontProduct as aV, type ThemeSettings as aW, type ThemeSettingsResult as aX, UploadService as aY, UserService as aZ, type Variant as a_, type Menu as aa, type MenuItem as ab, MenuService as ac, type MenuSummary as ad, type Money as ae, NewsletterService as af, type Offer as ag, type Order as ah, type OrderLine as ai, OrderService as aj, type PageLayout as ak, PageService as al, type PaymentIntent as am, PaymentMethodService as an, type Plugin as ao, PluginService as ap, PopularSearchService as aq, PopularityService as ar, type Postcode as as, type Product as at, type ProductFacets as au, type ProductOption as av, ProductService as aw, ProfileService as ax, type Quote as ay, REDIRECT_GATEWAYS as az, AddressService as b, settingService as b$, VariantService as b0, VarniCustomDesignService as b1, VarniCustomProductService as b2, type Vendor as b3, VendorService as b4, WarrantyService as b5, type Wishlist as b6, type WishlistItem as b7, WishlistService as b8, addressService as b9, homeService as bA, initService as bB, layoutService as bC, mediaUrl as bD, meilisearchService as bE, menuService as bF, minorToMajor as bG, newsletterService as bH, orderService as bI, ownDomain as bJ, pageService as bK, paymentMethodService as bL, pluginService as bM, pluginsService as bN, popularSearchService as bO, popularityService as bP, priceOf as bQ, productImages as bR, productService as bS, productVideos as bT, profileService as bU, qs as bV, reelsService as bW, regionService as bX, reviewService as bY, searchService as bZ, setRequestHost as b_, authService as ba, autocompleteService as bb, b2bService as bc, bannerService as bd, blogService as be, cartService as bf, categoryService as bg, chatService as bh, checkoutService as bi, collectionService as bj, contactService as bk, countryService as bl, couponService as bm, currencyExponent as bn, currencyService as bo, dealService as bp, demoRequestService as bq, emptyCart as br, emptyPage as bs, enquiryService as bt, faqService as bu, feedbackService as bv, fromEngineAddress as bw, fromIdentityAddress as bx, fromSearchDoc as by, galleryService as bz, type AppliedDiscount as c, settingsService as c0, stateService as c1, staticStore as c2, storeForHost as c3, storeService as c4, toAddOn as c5, toCart as c6, toCartLine as c7, toCartOffer as c8, toCategory as c9, toCmsPage as ca, toCollection as cb, toEngineAddress as cc, toFreeShipping as cd, toIdentityAddress as ce, toMajor as cf, toMinor as cg, toOrder as ch, toPage as ci, toProduct as cj, toRating as ck, toStorefrontFacets as cl, toUser as cm, toVariant as cn, toVendor as co, uploadService as cp, userService as cq, variantService as cr, varniCustomDesignService as cs, varniCustomProductService as ct, vendorService as cu, warrantyService as cv, wishlistService as cw, 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 };
@@ -201,6 +201,10 @@ type Product = {
201
201
  seo_description: string;
202
202
  image_url?: string;
203
203
  media_count?: number;
204
+ /** The gallery, pictures and videos in order: on the public product only (D134). */
205
+ media?: VariantImage[];
206
+ /** The sold count rounded down; absent unless the shop shows counts and it passed the threshold (D134). */
207
+ sold_at_least?: number;
204
208
  options: ProductOption[] | null;
205
209
  variants: Variant[] | null;
206
210
  collections: {
@@ -589,6 +593,14 @@ type MenuSummary = {
589
593
  handle: string;
590
594
  title: string;
591
595
  };
596
+ /** GET /api/postcodes/{country}/{code} (D134). */
597
+ type Postcode = {
598
+ country: string;
599
+ postcode: string;
600
+ city: string;
601
+ state: string;
602
+ state_code: string;
603
+ };
592
604
 
593
605
  /**
594
606
  * The state this connector keeps in the shopper's browser, and only there.
@@ -650,11 +662,16 @@ type CartExtras = {
650
662
  };
651
663
 
652
664
  /**
653
- * Every picture the public API offers for a product: the lead image, then each
654
- * variant's. The engine keeps the full gallery on admin routes only, so this
655
- * is the honest union rather than the whole media library.
665
+ * Every picture the public API offers for a product: the lead image, the
666
+ * product's gallery (on the single product, D134), then each variant's.
656
667
  */
657
668
  declare function productImages(p: Product): string[];
669
+ /**
670
+ * The product's videos, an upload or a YouTube link, in the gallery's order
671
+ * (D134). They follow the pictures in `images`, where the storefront's gallery
672
+ * plays them; a card's thumbnail is never one.
673
+ */
674
+ declare function productVideos(p: Product): string[];
658
675
  declare function toVariant(v: Variant, p: Product, optionless: boolean): {
659
676
  id: string;
660
677
  productId: string;
@@ -711,6 +728,10 @@ declare function toProduct(p: Product, extra?: {
711
728
  image_url: string;
712
729
  images: string;
713
730
  imageList: string[];
731
+ videos: string[];
732
+ highlights: string[];
733
+ freeGift: string | null;
734
+ soldAtLeast: number | null;
714
735
  manageInventory: boolean;
715
736
  allowBackorder: boolean;
716
737
  stock: number;
@@ -1511,6 +1532,10 @@ declare class ProductService extends CatalogService {
1511
1532
  image_url: string;
1512
1533
  images: string;
1513
1534
  imageList: string[];
1535
+ videos: string[];
1536
+ highlights: string[];
1537
+ freeGift: string | null;
1538
+ soldAtLeast: number | null;
1514
1539
  manageInventory: boolean;
1515
1540
  allowBackorder: boolean;
1516
1541
  stock: number;
@@ -1624,6 +1649,10 @@ declare class ProductService extends CatalogService {
1624
1649
  image_url: string;
1625
1650
  images: string;
1626
1651
  imageList: string[];
1652
+ videos: string[];
1653
+ highlights: string[];
1654
+ freeGift: string | null;
1655
+ soldAtLeast: number | null;
1627
1656
  manageInventory: boolean;
1628
1657
  allowBackorder: boolean;
1629
1658
  stock: number;
@@ -1772,6 +1801,10 @@ declare class ProductService extends CatalogService {
1772
1801
  image_url: string;
1773
1802
  images: string;
1774
1803
  imageList: string[];
1804
+ videos: string[];
1805
+ highlights: string[];
1806
+ freeGift: string | null;
1807
+ soldAtLeast: number | null;
1775
1808
  manageInventory: boolean;
1776
1809
  allowBackorder: boolean;
1777
1810
  stock: number;
@@ -1919,6 +1952,10 @@ declare class ProductService extends CatalogService {
1919
1952
  image_url: string;
1920
1953
  images: string;
1921
1954
  imageList: string[];
1955
+ videos: string[];
1956
+ highlights: string[];
1957
+ freeGift: string | null;
1958
+ soldAtLeast: number | null;
1922
1959
  manageInventory: boolean;
1923
1960
  allowBackorder: boolean;
1924
1961
  stock: number;
@@ -2113,6 +2150,10 @@ declare class ProductService extends CatalogService {
2113
2150
  image_url: string;
2114
2151
  images: string;
2115
2152
  imageList: string[];
2153
+ videos: string[];
2154
+ highlights: string[];
2155
+ freeGift: string | null;
2156
+ soldAtLeast: number | null;
2116
2157
  manageInventory: boolean;
2117
2158
  allowBackorder: boolean;
2118
2159
  stock: number;
@@ -2333,6 +2374,10 @@ declare class SearchService extends CatalogService {
2333
2374
  image_url: string;
2334
2375
  images: string;
2335
2376
  imageList: string[];
2377
+ videos: string[];
2378
+ highlights: string[];
2379
+ freeGift: string | null;
2380
+ soldAtLeast: number | null;
2336
2381
  manageInventory: boolean;
2337
2382
  allowBackorder: boolean;
2338
2383
  stock: number;
@@ -2518,6 +2563,10 @@ declare class MeilisearchService extends CatalogService {
2518
2563
  image_url: string;
2519
2564
  images: string;
2520
2565
  imageList: string[];
2566
+ videos: string[];
2567
+ highlights: string[];
2568
+ freeGift: string | null;
2569
+ soldAtLeast: number | null;
2521
2570
  manageInventory: boolean;
2522
2571
  allowBackorder: boolean;
2523
2572
  stock: number;
@@ -2705,6 +2754,10 @@ declare class MeilisearchService extends CatalogService {
2705
2754
  image_url: string;
2706
2755
  images: string;
2707
2756
  imageList: string[];
2757
+ videos: string[];
2758
+ highlights: string[];
2759
+ freeGift: string | null;
2760
+ soldAtLeast: number | null;
2708
2761
  manageInventory: boolean;
2709
2762
  allowBackorder: boolean;
2710
2763
  stock: number;
@@ -2894,6 +2947,10 @@ declare class CollectionService extends BaseService {
2894
2947
  image_url: string;
2895
2948
  images: string;
2896
2949
  imageList: string[];
2950
+ videos: string[];
2951
+ highlights: string[];
2952
+ freeGift: string | null;
2953
+ soldAtLeast: number | null;
2897
2954
  manageInventory: boolean;
2898
2955
  allowBackorder: boolean;
2899
2956
  stock: number;
@@ -3002,6 +3059,10 @@ declare class CollectionService extends BaseService {
3002
3059
  image_url: string;
3003
3060
  images: string;
3004
3061
  imageList: string[];
3062
+ videos: string[];
3063
+ highlights: string[];
3064
+ freeGift: string | null;
3065
+ soldAtLeast: number | null;
3005
3066
  manageInventory: boolean;
3006
3067
  allowBackorder: boolean;
3007
3068
  stock: number;
@@ -5779,6 +5840,22 @@ declare class AddressService extends BaseService {
5779
5840
  createdAt: string;
5780
5841
  updatedAt: string;
5781
5842
  }>;
5843
+ /**
5844
+ * The city and state for a postcode (D134), for the address form to fill
5845
+ * in. India's six-digit PIN codes only, from the directory the engine was
5846
+ * given; null for anything it cannot answer, so the form simply leaves the
5847
+ * fields to the shopper.
5848
+ */
5849
+ lookupPostcode({ country, postcode }: {
5850
+ country?: string;
5851
+ postcode: string;
5852
+ }): Promise<{
5853
+ country: string;
5854
+ postcode: string;
5855
+ city: string;
5856
+ state: string;
5857
+ stateCode: string;
5858
+ } | null>;
5782
5859
  deleteAddress(id: string): Promise<{
5783
5860
  id: string;
5784
5861
  deleted: boolean;
@@ -5824,6 +5901,10 @@ declare class WishlistService extends BaseService {
5824
5901
  image_url: string;
5825
5902
  images: string;
5826
5903
  imageList: string[];
5904
+ videos: string[];
5905
+ highlights: string[];
5906
+ freeGift: string | null;
5907
+ soldAtLeast: number | null;
5827
5908
  manageInventory: boolean;
5828
5909
  allowBackorder: boolean;
5829
5910
  stock: number;
@@ -6582,6 +6663,10 @@ declare class AutocompleteService extends MeilisearchService {
6582
6663
  image_url: string;
6583
6664
  images: string;
6584
6665
  imageList: string[];
6666
+ videos: string[];
6667
+ highlights: string[];
6668
+ freeGift: string | null;
6669
+ soldAtLeast: number | null;
6585
6670
  manageInventory: boolean;
6586
6671
  allowBackorder: boolean;
6587
6672
  stock: number;
@@ -7482,4 +7567,4 @@ declare class B2bService extends BaseService {
7482
7567
  }
7483
7568
  declare const b2bService: B2bService;
7484
7569
 
7485
- export { HomeService 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 HeaderSettings as Y, type HomeLayout as Z, type HomeLayoutSection as _, type Address as a, VariantService as a$, type IdentityAddress as a0, InitService as a1, type Invitation as a2, type LayoutCollection as a3, type LayoutPage as a4, LayoutService as a5, type Lead as a6, type ListMeta as a7, MeilisearchService as a8, type Member as a9, RegionService as aA, type RejectedLine as aB, type Review as aC, type ReviewPage as aD, ReviewService as aE, type SearchDoc as aF, type SearchResult as aG, SearchService as aH, SettingService as aI, type ShippingRate as aJ, type SiteChrome as aK, type SiteFooter as aL, type SiteHeader as aM, type SocialLink as aN, StateService as aO, type StoreProfile as aP, StoreService as aQ, type StorefrontCategory as aR, type StorefrontMenu as aS, type StorefrontOrder as aT, type StorefrontProduct as aU, type ThemeSettings as aV, type ThemeSettingsResult as aW, UploadService as aX, UserService as aY, type Variant as aZ, type VariantImage as a_, type Menu as aa, type MenuItem as ab, MenuService as ac, type MenuSummary as ad, type Money as ae, NewsletterService as af, type Offer as ag, type Order as ah, type OrderLine as ai, OrderService as aj, type PageLayout as ak, PageService as al, type PaymentIntent as am, PaymentMethodService as an, type Plugin as ao, PluginService as ap, PopularSearchService as aq, PopularityService as ar, type Product as as, type ProductFacets as at, type ProductOption as au, ProductService as av, ProfileService as aw, type Quote as ax, REDIRECT_GATEWAYS as ay, ReelsService as az, AddressService as b, stateService as b$, VarniCustomDesignService as b0, VarniCustomProductService as b1, type Vendor as b2, VendorService as b3, WarrantyService as b4, type Wishlist as b5, type WishlistItem as b6, WishlistService as b7, addressService as b8, authService as b9, initService as bA, layoutService as bB, mediaUrl as bC, meilisearchService as bD, menuService as bE, minorToMajor as bF, newsletterService as bG, orderService as bH, ownDomain as bI, pageService as bJ, paymentMethodService as bK, pluginService as bL, pluginsService as bM, popularSearchService as bN, popularityService as bO, priceOf as bP, productImages as bQ, productService as bR, profileService as bS, qs as bT, reelsService as bU, regionService as bV, reviewService as bW, searchService as bX, setRequestHost as bY, settingService as bZ, settingsService as b_, autocompleteService as ba, b2bService as bb, bannerService as bc, blogService as bd, cartService as be, categoryService as bf, chatService as bg, checkoutService as bh, collectionService as bi, contactService as bj, countryService as bk, couponService as bl, currencyExponent as bm, currencyService as bn, dealService as bo, demoRequestService as bp, emptyCart as bq, emptyPage as br, enquiryService as bs, faqService as bt, feedbackService as bu, fromEngineAddress as bv, fromIdentityAddress as bw, fromSearchDoc as bx, galleryService as by, homeService as bz, type AppliedDiscount as c, staticStore as c0, storeForHost as c1, storeService as c2, toAddOn as c3, toCart as c4, toCartLine as c5, toCartOffer as c6, toCategory as c7, toCmsPage as c8, toCollection as c9, toEngineAddress as ca, toFreeShipping as cb, toIdentityAddress as cc, toMajor as cd, toMinor as ce, toOrder as cf, toPage as cg, toProduct as ch, toRating as ci, toStorefrontFacets as cj, toUser as ck, toVariant as cl, toVendor as cm, uploadService as cn, userService as co, variantService as cp, varniCustomDesignService as cq, varniCustomProductService as cr, vendorService as cs, warrantyService as ct, wishlistService as cu, 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 };
7570
+ export { HomeService 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 HeaderSettings as Y, type HomeLayout as Z, type HomeLayoutSection as _, type Address as a, type VariantImage as a$, type IdentityAddress as a0, InitService as a1, type Invitation as a2, type LayoutCollection as a3, type LayoutPage as a4, LayoutService as a5, type Lead as a6, type ListMeta as a7, MeilisearchService as a8, type Member as a9, ReelsService as aA, RegionService as aB, type RejectedLine as aC, type Review as aD, type ReviewPage as aE, ReviewService as aF, type SearchDoc as aG, type SearchResult as aH, SearchService as aI, SettingService as aJ, type ShippingRate as aK, type SiteChrome as aL, type SiteFooter as aM, type SiteHeader as aN, type SocialLink as aO, StateService as aP, type StoreProfile as aQ, StoreService as aR, type StorefrontCategory as aS, type StorefrontMenu as aT, type StorefrontOrder as aU, type StorefrontProduct as aV, type ThemeSettings as aW, type ThemeSettingsResult as aX, UploadService as aY, UserService as aZ, type Variant as a_, type Menu as aa, type MenuItem as ab, MenuService as ac, type MenuSummary as ad, type Money as ae, NewsletterService as af, type Offer as ag, type Order as ah, type OrderLine as ai, OrderService as aj, type PageLayout as ak, PageService as al, type PaymentIntent as am, PaymentMethodService as an, type Plugin as ao, PluginService as ap, PopularSearchService as aq, PopularityService as ar, type Postcode as as, type Product as at, type ProductFacets as au, type ProductOption as av, ProductService as aw, ProfileService as ax, type Quote as ay, REDIRECT_GATEWAYS as az, AddressService as b, settingService as b$, VariantService as b0, VarniCustomDesignService as b1, VarniCustomProductService as b2, type Vendor as b3, VendorService as b4, WarrantyService as b5, type Wishlist as b6, type WishlistItem as b7, WishlistService as b8, addressService as b9, homeService as bA, initService as bB, layoutService as bC, mediaUrl as bD, meilisearchService as bE, menuService as bF, minorToMajor as bG, newsletterService as bH, orderService as bI, ownDomain as bJ, pageService as bK, paymentMethodService as bL, pluginService as bM, pluginsService as bN, popularSearchService as bO, popularityService as bP, priceOf as bQ, productImages as bR, productService as bS, productVideos as bT, profileService as bU, qs as bV, reelsService as bW, regionService as bX, reviewService as bY, searchService as bZ, setRequestHost as b_, authService as ba, autocompleteService as bb, b2bService as bc, bannerService as bd, blogService as be, cartService as bf, categoryService as bg, chatService as bh, checkoutService as bi, collectionService as bj, contactService as bk, countryService as bl, couponService as bm, currencyExponent as bn, currencyService as bo, dealService as bp, demoRequestService as bq, emptyCart as br, emptyPage as bs, enquiryService as bt, faqService as bu, feedbackService as bv, fromEngineAddress as bw, fromIdentityAddress as bx, fromSearchDoc as by, galleryService as bz, type AppliedDiscount as c, settingsService as c0, stateService as c1, staticStore as c2, storeForHost as c3, storeService as c4, toAddOn as c5, toCart as c6, toCartLine as c7, toCartOffer as c8, toCategory as c9, toCmsPage as ca, toCollection as cb, toEngineAddress as cc, toFreeShipping as cd, toIdentityAddress as ce, toMajor as cf, toMinor as cg, toOrder as ch, toPage as ci, toProduct as cj, toRating as ck, toStorefrontFacets as cl, toUser as cm, toVariant as cn, toVendor as co, uploadService as cp, userService as cq, variantService as cr, varniCustomDesignService as cs, varniCustomProductService as ct, vendorService as cu, warrantyService as cv, wishlistService as cw, 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
@@ -498,9 +498,27 @@ function productImages(p) {
498
498
  if (url && !out.includes(url)) out.push(url);
499
499
  };
500
500
  push(mediaUrl(p.image_url));
501
+ for (const m of arr(p.media)) if (m.kind === "image") push(mediaUrl(m.url));
501
502
  for (const v of arr(p.variants)) for (const url of variantImages(v)) push(url);
502
503
  return out;
503
504
  }
505
+ function productVideos(p) {
506
+ const out = [];
507
+ for (const m of arr(p.media)) {
508
+ const url = m.kind === "video" ? mediaUrl(m.url) : null;
509
+ if (url && !out.includes(url)) out.push(url);
510
+ }
511
+ return out;
512
+ }
513
+ function highlightsOf(p) {
514
+ const raw = p.metadata?.highlights;
515
+ if (!Array.isArray(raw)) return [];
516
+ return raw.filter((s) => typeof s === "string").map((s) => s.trim()).filter(Boolean);
517
+ }
518
+ function freeGiftOf(p) {
519
+ const raw = p.metadata?.free_gift;
520
+ return typeof raw === "string" && raw.trim() ? raw.trim() : null;
521
+ }
504
522
  function toVariant(v, p, optionless) {
505
523
  const images = variantImages(v);
506
524
  const options = arr(p.options);
@@ -548,6 +566,7 @@ function toProduct(p, extra = {}) {
548
566
  const lead = live[0] ?? arr(p.variants)[0];
549
567
  const optionless = arr(p.options).length === 0;
550
568
  const images = productImages(p);
569
+ const videos = productVideos(p);
551
570
  const prices = live.map((v) => toMajor(v.price));
552
571
  const tracked = live.filter((v) => v.track_inventory);
553
572
  const category = p.category;
@@ -574,8 +593,14 @@ function toProduct(p, extra = {}) {
574
593
  originCountry: lead?.origin_country ?? null,
575
594
  thumbnail: images[0] ?? null,
576
595
  image_url: images[0] ?? null,
577
- images: images.join(","),
596
+ images: [...images, ...videos].join(","),
578
597
  imageList: images,
598
+ videos,
599
+ // What the buy box says beside the price (D134): plain text, drawn as text.
600
+ highlights: highlightsOf(p),
601
+ freeGift: freeGiftOf(p),
602
+ // Counted by the engine, rounded down, and absent rather than zero.
603
+ soldAtLeast: typeof p.sold_at_least === "number" && p.sold_at_least > 0 ? p.sold_at_least : null,
579
604
  // Product-level stock is what a card shows before a variant is picked:
580
605
  // buyable when any live variant is, counted only where counting means
581
606
  // something.
@@ -748,7 +773,9 @@ function toIdentityAddress(a) {
748
773
  state: e.state ?? "",
749
774
  postal_code: e.postal_code,
750
775
  country: e.country,
751
- ...a.label ? { label: String(a.label) } : {},
776
+ // Sent whenever the form has it, empty included: the engine keeps a label it is not sent, so
777
+ // leaving out an emptied one would keep the old Home or Work (D134).
778
+ ...typeof a.label === "string" ? { label: a.label } : {},
752
779
  ...a.isPrimary ? { is_default: true } : {}
753
780
  };
754
781
  }
@@ -2688,6 +2715,24 @@ var AddressService = class extends BaseService {
2688
2715
  });
2689
2716
  return fromIdentityAddress(a, currentMe()?.email);
2690
2717
  }
2718
+ /**
2719
+ * The city and state for a postcode (D134), for the address form to fill
2720
+ * in. India's six-digit PIN codes only, from the directory the engine was
2721
+ * given; null for anything it cannot answer, so the form simply leaves the
2722
+ * fields to the shopper.
2723
+ */
2724
+ async lookupPostcode({ country = "IN", postcode }) {
2725
+ const code = String(postcode ?? "").trim();
2726
+ const cc = String(country ?? "").trim().toUpperCase();
2727
+ if (cc !== "IN" || !/^[1-9][0-9]{5}$/.test(code)) return null;
2728
+ try {
2729
+ const p = await this.data(`/api/postcodes/${cc}/${code}`);
2730
+ return { country: p.country, postcode: p.postcode, city: p.city, state: p.state, stateCode: p.state_code };
2731
+ } catch (err) {
2732
+ if (err instanceof GoCommerceError && (err.status === 404 || err.status === 400)) return null;
2733
+ throw err;
2734
+ }
2735
+ }
2691
2736
  async deleteAddress(id2) {
2692
2737
  await this.engine(`/x/identity/me/addresses/${enc(id2)}`, { method: "DELETE", auth: true });
2693
2738
  return { id: String(id2), deleted: true };
@@ -3812,6 +3857,7 @@ exports.popularityService = popularityService;
3812
3857
  exports.priceOf = priceOf;
3813
3858
  exports.productImages = productImages;
3814
3859
  exports.productService = productService;
3860
+ exports.productVideos = productVideos;
3815
3861
  exports.profileService = profileService;
3816
3862
  exports.qs = qs;
3817
3863
  exports.readStaticStore = readStaticStore;