@usethrottle/catalog 1.2.0 → 1.4.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +111 -15
  3. package/dist/admin.cjs +16 -16
  4. package/dist/admin.d.cts +15 -2
  5. package/dist/admin.d.ts +15 -2
  6. package/dist/admin.js +1 -1
  7. package/dist/{catalog-error-yTBMAdCv.d.cts → catalog-error-BKN5hNWP.d.cts} +11 -1
  8. package/dist/{catalog-error-7DCsTyB2.d.ts → catalog-error-BnabMMEy.d.ts} +11 -1
  9. package/dist/{chunk-JNBKKAMP.js → chunk-3FX2HISB.js} +97 -2
  10. package/dist/{chunk-B2DYAHNR.cjs → chunk-J2GHGQY6.cjs} +334 -43
  11. package/dist/{chunk-TDMDOHD3.cjs → chunk-OKWXS3FD.cjs} +110 -15
  12. package/dist/chunk-PZ3SFYH4.cjs +192 -0
  13. package/dist/chunk-SN6STYPW.js +192 -0
  14. package/dist/{chunk-55G4ZTD5.js → chunk-VJHA7J7B.js} +315 -24
  15. package/dist/{client-Dm6I4nAZ.d.ts → client-B6CsU_v9.d.ts} +1 -1
  16. package/dist/{client-BrHJCyBP.d.cts → client-terkEl6u.d.cts} +1 -1
  17. package/dist/{contract-types-BPSzY_Co.d.cts → contract-types-D2-SSPM9.d.cts} +241 -11
  18. package/dist/{contract-types-BPSzY_Co.d.ts → contract-types-D2-SSPM9.d.ts} +241 -11
  19. package/dist/index.cjs +34 -2
  20. package/dist/index.d.cts +56 -7
  21. package/dist/index.d.ts +56 -7
  22. package/dist/index.js +35 -3
  23. package/dist/next.cjs +180 -0
  24. package/dist/next.d.cts +60 -0
  25. package/dist/next.d.ts +60 -0
  26. package/dist/next.js +180 -0
  27. package/dist/react-extras.cjs +27 -9
  28. package/dist/react-extras.d.cts +7 -4
  29. package/dist/react-extras.d.ts +7 -4
  30. package/dist/react-extras.js +20 -2
  31. package/dist/react.cjs +130 -54
  32. package/dist/react.d.cts +52 -11
  33. package/dist/react.d.ts +52 -11
  34. package/dist/react.js +112 -36
  35. package/dist/server.cjs +58 -66
  36. package/dist/server.d.cts +58 -10
  37. package/dist/server.d.ts +58 -10
  38. package/dist/server.js +52 -60
  39. package/dist/{types-BlYCKzB8.d.ts → types-jNpOwEUw.d.cts} +81 -8
  40. package/dist/{types-BTrqSprj.d.cts → types-z57bkjjB.d.ts} +81 -8
  41. package/dist/url.d.cts +2 -1
  42. package/dist/url.d.ts +2 -1
  43. package/dist/{use-query-QOEBuYlp.d.ts → use-query-COqRZJnC.d.ts} +1 -1
  44. package/dist/{use-query-BZgjxGPO.d.cts → use-query-H1xgL3_e.d.cts} +1 -1
  45. package/package.json +17 -2
@@ -1,3 +1,5 @@
1
+ import { CurrencyCode } from '@usethrottle/money';
2
+
1
3
  type CartCheckAnswer = {
2
4
  priceContext?: 'anonymous' | 'customer' | 'email_unverified' | 'anonymous_fallback' | undefined;
3
5
  items: {
@@ -5,7 +7,7 @@ type CartCheckAnswer = {
5
7
  ok: boolean;
6
8
  code?: 'NOT_FOUND' | 'NOT_PURCHASABLE' | 'OUT_OF_STOCK' | 'QUANTITY_UNAVAILABLE' | 'BELOW_MIN' | 'ABOVE_MAX' | 'NO_PRICE_IN_CURRENCY' | 'PRICE_SOURCE_MISMATCH' | undefined;
7
9
  unitPriceMinor: number | null;
8
- currency: string | null;
10
+ currency: CurrencyCode | null;
9
11
  maxQuantity?: number | undefined;
10
12
  }[];
11
13
  };
@@ -29,7 +31,7 @@ type CartCreateAnswer = {
29
31
  unitPriceMinor: number;
30
32
  imageUrl: string | null;
31
33
  }[];
32
- currency: string;
34
+ currency: CurrencyCode;
33
35
  subtotalMinor: number;
34
36
  };
35
37
  returnUrlApplied?: boolean | undefined;
@@ -149,6 +151,15 @@ type StorefrontConfigAnswer = {
149
151
  extensionId: string;
150
152
  };
151
153
  generation: number;
154
+ settings: StorefrontSettings;
155
+ filters: StorefrontFilterDefinition[];
156
+ settingsVersion: number;
157
+ };
158
+ type StorefrontFilterDefinition = {
159
+ key: string;
160
+ label: string;
161
+ display: 'checkbox' | 'swatch' | 'range' | 'boolean' | 'dropdown';
162
+ source: string;
152
163
  };
153
164
  type StorefrontFilterValuesAnswer = {
154
165
  key: string;
@@ -218,7 +229,7 @@ type StorefrontListAnswer = {
218
229
  ignored?: string[] | undefined;
219
230
  };
220
231
  sort: 'relevance' | 'featured' | 'manual' | 'title_asc' | 'title_desc' | 'price_asc' | 'price_desc' | 'newest' | 'updated' | 'best_rated';
221
- currency: string | null;
232
+ currency: CurrencyCode | null;
222
233
  locale: string | null;
223
234
  priceContext?: 'anonymous' | 'customer' | 'email_unverified' | 'anonymous_fallback' | undefined;
224
235
  indexing?: true | undefined;
@@ -246,12 +257,12 @@ type StorefrontListProduct = {
246
257
  priceRange?: ({
247
258
  minMinor: number;
248
259
  maxMinor: number;
249
- currency: string;
260
+ currency: CurrencyCode;
250
261
  compareAtMinMinor: number | null;
251
262
  } | null) | ({
252
263
  minMinor: number;
253
264
  maxMinor: number;
254
- currency: string;
265
+ currency: CurrencyCode;
255
266
  } | null) | undefined;
256
267
  availability?: ('in_stock' | 'out_of_stock' | 'preorder' | 'backorder' | null) | ('in_stock' | 'out_of_stock' | 'preorder' | 'backorder' | null) | undefined;
257
268
  lowStock?: (boolean) | (boolean) | undefined;
@@ -296,7 +307,7 @@ type StorefrontListProduct = {
296
307
  options: Record<string, string> | null;
297
308
  priceMinor: number | null;
298
309
  salePriceMinor: number | null;
299
- currency: string | null;
310
+ currency: CurrencyCode | null;
300
311
  availability: 'in_stock' | 'out_of_stock' | 'preorder' | 'backorder' | null;
301
312
  gtin: string | null;
302
313
  mpn: string | null;
@@ -390,6 +401,32 @@ type StorefrontListProduct = {
390
401
  supersededBy?: string[] | undefined;
391
402
  supersedes?: string[] | undefined;
392
403
  };
404
+ type StorefrontMenuItem = {
405
+ label: string;
406
+ target: {
407
+ kind: 'category' | 'collection' | 'page' | 'product' | 'search' | 'url';
408
+ handle?: string | undefined;
409
+ q?: string | undefined;
410
+ href?: string | undefined;
411
+ };
412
+ children?: StorefrontMenuItem[] | undefined;
413
+ };
414
+ type StorefrontPageAnswer = {
415
+ handle: string;
416
+ title: string;
417
+ bodyHtml: string;
418
+ seo: {
419
+ title: string;
420
+ description: string;
421
+ };
422
+ };
423
+ type StorefrontPagesAnswer = {
424
+ pages: {
425
+ handle: string;
426
+ title: string;
427
+ position: number;
428
+ }[];
429
+ };
393
430
  type StorefrontProductAnswer = {
394
431
  product: {
395
432
  handle: string;
@@ -410,7 +447,7 @@ type StorefrontProductAnswer = {
410
447
  priceRange: {
411
448
  minMinor: number;
412
449
  maxMinor: number;
413
- currency: string;
450
+ currency: CurrencyCode;
414
451
  } | null;
415
452
  availability: 'in_stock' | 'out_of_stock' | 'preorder' | 'backorder' | null;
416
453
  variants: {
@@ -419,7 +456,7 @@ type StorefrontProductAnswer = {
419
456
  options: Record<string, string> | null;
420
457
  priceMinor: number | null;
421
458
  salePriceMinor: number | null;
422
- currency: string | null;
459
+ currency: CurrencyCode | null;
423
460
  availability: 'in_stock' | 'out_of_stock' | 'preorder' | 'backorder' | null;
424
461
  gtin: string | null;
425
462
  mpn: string | null;
@@ -547,6 +584,199 @@ type StorefrontReviewsAnswer = ({
547
584
  }) | ({
548
585
  redirectTo: string;
549
586
  });
587
+ type StorefrontSettings = {
588
+ storefrontId: 'default';
589
+ brand: {
590
+ storeName: string;
591
+ logo: {
592
+ light: {
593
+ id: string;
594
+ url: string;
595
+ } | null;
596
+ dark: {
597
+ id: string;
598
+ url: string;
599
+ } | null;
600
+ };
601
+ favicon: {
602
+ id: string;
603
+ url: string;
604
+ } | null;
605
+ };
606
+ theme: {
607
+ light: {
608
+ colorPrimary: string;
609
+ colorPrimaryForeground: string;
610
+ colorBackground: string;
611
+ colorSurface: string;
612
+ colorForeground: string;
613
+ colorMuted: string;
614
+ colorMutedForeground: string;
615
+ colorBorder: string;
616
+ colorBorderControl: string;
617
+ colorAccent: string;
618
+ colorSale: string;
619
+ colorSuccess: string;
620
+ colorWarning: string;
621
+ colorDanger: string;
622
+ };
623
+ dark: {
624
+ colorPrimary: string;
625
+ colorPrimaryForeground: string;
626
+ colorBackground: string;
627
+ colorSurface: string;
628
+ colorForeground: string;
629
+ colorMuted: string;
630
+ colorMutedForeground: string;
631
+ colorBorder: string;
632
+ colorBorderControl: string;
633
+ colorAccent: string;
634
+ colorSale: string;
635
+ colorSuccess: string;
636
+ colorWarning: string;
637
+ colorDanger: string;
638
+ };
639
+ fonts: {
640
+ heading: 'Instrument Serif' | 'Playfair Display' | 'Lora' | 'Merriweather' | 'Cormorant Garamond' | 'EB Garamond' | 'Libre Baskerville' | 'Source Serif 4' | 'Fraunces' | 'DM Serif Display' | 'Inter' | 'Schibsted Grotesk' | 'DM Sans' | 'Manrope' | 'Poppins' | 'Montserrat' | 'Work Sans' | 'Rubik' | 'Nunito Sans' | 'Open Sans' | 'Lato' | 'Raleway' | 'Outfit' | 'Plus Jakarta Sans' | 'Figtree' | 'Karla' | 'DM Mono' | 'JetBrains Mono' | 'IBM Plex Mono' | 'Space Mono' | 'Bebas Neue' | 'Oswald' | 'Archivo Black' | 'Space Grotesk' | 'Syne' | 'system-sans' | 'system-serif' | 'system-mono';
641
+ body: 'Instrument Serif' | 'Playfair Display' | 'Lora' | 'Merriweather' | 'Cormorant Garamond' | 'EB Garamond' | 'Libre Baskerville' | 'Source Serif 4' | 'Fraunces' | 'DM Serif Display' | 'Inter' | 'Schibsted Grotesk' | 'DM Sans' | 'Manrope' | 'Poppins' | 'Montserrat' | 'Work Sans' | 'Rubik' | 'Nunito Sans' | 'Open Sans' | 'Lato' | 'Raleway' | 'Outfit' | 'Plus Jakarta Sans' | 'Figtree' | 'Karla' | 'DM Mono' | 'JetBrains Mono' | 'IBM Plex Mono' | 'Space Mono' | 'Bebas Neue' | 'Oswald' | 'Archivo Black' | 'Space Grotesk' | 'Syne' | 'system-sans' | 'system-serif' | 'system-mono';
642
+ mono: 'Instrument Serif' | 'Playfair Display' | 'Lora' | 'Merriweather' | 'Cormorant Garamond' | 'EB Garamond' | 'Libre Baskerville' | 'Source Serif 4' | 'Fraunces' | 'DM Serif Display' | 'Inter' | 'Schibsted Grotesk' | 'DM Sans' | 'Manrope' | 'Poppins' | 'Montserrat' | 'Work Sans' | 'Rubik' | 'Nunito Sans' | 'Open Sans' | 'Lato' | 'Raleway' | 'Outfit' | 'Plus Jakarta Sans' | 'Figtree' | 'Karla' | 'DM Mono' | 'JetBrains Mono' | 'IBM Plex Mono' | 'Space Mono' | 'Bebas Neue' | 'Oswald' | 'Archivo Black' | 'Space Grotesk' | 'Syne' | 'system-sans' | 'system-serif' | 'system-mono';
643
+ };
644
+ radius: number;
645
+ spacingScale: 'compact' | 'comfortable' | 'roomy';
646
+ colorScheme: 'light' | 'dark' | 'auto';
647
+ };
648
+ navigation: {
649
+ header: StorefrontMenuItem[];
650
+ footer: StorefrontMenuItem[];
651
+ };
652
+ home: {
653
+ hero: {
654
+ image: {
655
+ id: string;
656
+ url: string;
657
+ } | null;
658
+ heading: string;
659
+ subheading: string;
660
+ ctaLabel: string;
661
+ ctaTarget: {
662
+ kind: 'category' | 'collection' | 'page' | 'product' | 'search' | 'url';
663
+ handle?: string | undefined;
664
+ q?: string | undefined;
665
+ href?: string | undefined;
666
+ } | null;
667
+ };
668
+ shelves: {
669
+ kind: 'collection' | 'featured' | 'newest' | 'best_rated' | 'categories';
670
+ handle?: string | undefined;
671
+ title?: string | undefined;
672
+ limit: number;
673
+ }[];
674
+ };
675
+ announcement: {
676
+ enabled: boolean;
677
+ message: string;
678
+ target: {
679
+ kind: 'category' | 'collection' | 'page' | 'product' | 'search' | 'url';
680
+ handle?: string | undefined;
681
+ q?: string | undefined;
682
+ href?: string | undefined;
683
+ } | null;
684
+ startsAt: string | null;
685
+ endsAt: string | null;
686
+ };
687
+ listing: {
688
+ pageSize: number;
689
+ pagination: 'numbered' | 'load_more' | 'infinite';
690
+ columns: {
691
+ desktop: number;
692
+ mobile: number;
693
+ };
694
+ defaultSort: 'relevance' | 'featured' | 'manual' | 'title_asc' | 'title_desc' | 'price_asc' | 'price_desc' | 'newest' | 'updated' | 'best_rated';
695
+ filterLayout: 'sidebar' | 'topbar' | 'drawer';
696
+ sorts: {
697
+ key: 'relevance' | 'featured' | 'manual' | 'title_asc' | 'title_desc' | 'price_asc' | 'price_desc' | 'newest' | 'updated' | 'best_rated';
698
+ enabled: boolean;
699
+ label: string;
700
+ }[];
701
+ };
702
+ card: {
703
+ style: 'standard' | 'minimal' | 'overlay' | 'row';
704
+ showRating: boolean;
705
+ showSwatches: boolean;
706
+ showBrand: boolean;
707
+ showCompareAt: boolean;
708
+ showBadges: boolean;
709
+ secondImageOnHover: boolean;
710
+ quickAdd: boolean;
711
+ };
712
+ badges: {
713
+ sale: {
714
+ enabled: boolean;
715
+ label: string;
716
+ colour: string;
717
+ };
718
+ new: {
719
+ enabled: boolean;
720
+ label: string;
721
+ colour: string;
722
+ days: number;
723
+ };
724
+ lowStock: {
725
+ enabled: boolean;
726
+ label: string;
727
+ };
728
+ custom: {
729
+ tag: string;
730
+ label: string;
731
+ colour: string;
732
+ }[];
733
+ };
734
+ stock: {
735
+ hideOutOfStock: boolean;
736
+ showExactCount: boolean;
737
+ words: {
738
+ inStock: string;
739
+ lowStock: string;
740
+ outOfStock: string;
741
+ backorder: string;
742
+ preorder: string;
743
+ };
744
+ lowStockThreshold: number | null;
745
+ };
746
+ product: {
747
+ layout: 'classic' | 'stacked' | 'editorial';
748
+ sectionsStyle: 'auto' | 'tabs' | 'accordion' | 'stacked';
749
+ sections: {
750
+ key: 'description' | 'specs' | 'shipping' | 'tags' | 'categories' | 'related' | 'reviews';
751
+ enabled: boolean;
752
+ title: string;
753
+ pageHandle: string | null;
754
+ }[];
755
+ relatedLimit: number;
756
+ relatedTitle: string;
757
+ };
758
+ seo: {
759
+ titleTemplate: string;
760
+ defaultDescription: string;
761
+ shareImage: {
762
+ id: string;
763
+ url: string;
764
+ } | null;
765
+ };
766
+ strings: Record<'shop.title' | 'shop.description' | 'search.title' | 'search.placeholder' | 'search.results' | 'empty.search' | 'empty.listing' | 'empty.category' | 'empty.collection' | 'empty.cart' | 'cart.title' | 'cart.checkout' | 'cart.continueShopping' | 'filters.title' | 'filters.clearAll' | 'filters.apply' | 'filters.showMore' | 'filters.showLess' | 'filters.priceMin' | 'filters.priceMax' | 'boolean.yes' | 'boolean.no' | 'sort.label' | 'listing.count' | 'listing.loadMore' | 'listing.loading' | 'listing.previous' | 'listing.next' | 'product.addToCart' | 'product.quantity' | 'product.selectOption' | 'product.sku' | 'product.description' | 'product.specs' | 'product.shipping' | 'product.tags' | 'product.categories' | 'product.related' | 'product.reviews' | 'product.noReviews' | 'product.writeReview' | 'home.shopAll' | 'home.featured' | 'home.newest' | 'home.bestRated' | 'home.categories' | 'footer.copyright' | 'nav.menu' | 'nav.account' | 'nav.cart' | 'error.notFound' | 'error.generic', string>;
767
+ routes: {
768
+ product: string;
769
+ category: string;
770
+ collection: string;
771
+ tag: string;
772
+ page: string;
773
+ search: string;
774
+ shop: string;
775
+ };
776
+ preview: {
777
+ storeUrl: string | null;
778
+ };
779
+ };
550
780
  type StorefrontSuggestAnswer = {
551
781
  products: {
552
782
  handle: string;
@@ -562,7 +792,7 @@ type StorefrontSuggestAnswer = {
562
792
  priceRange: {
563
793
  minMinor: number;
564
794
  maxMinor: number;
565
- currency: string;
795
+ currency: CurrencyCode;
566
796
  compareAtMinMinor: number | null;
567
797
  } | null;
568
798
  availability: 'in_stock' | 'out_of_stock' | 'preorder' | 'backorder' | null;
@@ -594,6 +824,6 @@ type StorefrontTagsAnswer = {
594
824
  productCount: number;
595
825
  }[];
596
826
  };
597
- type CatalogContractErrorCode = 'INVALID_REQUEST' | 'AUTHENTICATION_FAILED' | 'INFRASTRUCTURE_UNAVAILABLE' | 'PROVIDER_UNAVAILABLE' | 'INTERNAL_ERROR' | 'CUSTOMER_TOKEN_INVALID' | 'ORIGIN_NOT_ALLOWED' | 'SERVER_KEY_IN_BROWSER' | 'KEY_NOT_ALLOWED_IN_URL' | 'NOT_FOUND' | 'RATE_LIMITED' | 'STOREFRONT_UNAVAILABLE' | 'REQUEST_BODY_TOO_LARGE' | 'CART_CURRENCY_REQUIRED' | 'CART_CURRENCY_NOT_ENABLED' | 'CHECKOUT_NOT_CONFIGURED' | 'EXTENSION_UPGRADE_REQUIRED' | 'CART_ITEMS_INVALID' | 'CART_REJECTED' | 'CART_UNAVAILABLE' | 'CHECKOUT_UNAVAILABLE' | 'RETURN_URL_NOT_ALLOWED' | 'CHECKOUT_TOTAL_TOO_LARGE' | 'CHECKOUT_CART_MISMATCH' | 'CHECKOUT_ITEMS_INVALID' | 'CHECKOUT_REJECTED' | 'CURRENCY_NOT_ENABLED' | 'STOREFRONT_INDEXING' | 'EMAIL_NOT_VERIFIED' | 'NOT_VERIFIED_BUYER' | 'PURCHASE_REFUNDED' | 'ALREADY_REVIEWED' | 'REVIEW_QUEUE_FULL' | 'REVIEW_VERIFICATION_UNAVAILABLE';
827
+ type CatalogContractErrorCode = 'INVALID_REQUEST' | 'AUTHENTICATION_FAILED' | 'INFRASTRUCTURE_UNAVAILABLE' | 'PROVIDER_UNAVAILABLE' | 'INTERNAL_ERROR' | 'CUSTOMER_TOKEN_INVALID' | 'ORIGIN_NOT_ALLOWED' | 'SERVER_KEY_IN_BROWSER' | 'KEY_NOT_ALLOWED_IN_URL' | 'NOT_FOUND' | 'RATE_LIMITED' | 'STOREFRONT_UNAVAILABLE' | 'REQUEST_BODY_TOO_LARGE' | 'CART_CURRENCY_REQUIRED' | 'CART_CURRENCY_NOT_ENABLED' | 'CHECKOUT_NOT_CONFIGURED' | 'EXTENSION_UPGRADE_REQUIRED' | 'CART_ITEMS_INVALID' | 'CART_REJECTED' | 'CART_UNAVAILABLE' | 'CHECKOUT_UNAVAILABLE' | 'RETURN_URL_NOT_ALLOWED' | 'CHECKOUT_TOTAL_TOO_LARGE' | 'CHECKOUT_CART_MISMATCH' | 'CHECKOUT_ITEMS_INVALID' | 'CHECKOUT_REJECTED' | 'CURRENCY_NOT_ENABLED' | 'STOREFRONT_INDEXING' | 'EMAIL_NOT_VERIFIED' | 'NOT_VERIFIED_BUYER' | 'PURCHASE_REFUNDED' | 'ALREADY_REVIEWED' | 'REVIEW_QUEUE_FULL' | 'REVIEW_VERIFICATION_UNAVAILABLE' | 'PAGE_NOT_FOUND' | 'PREVIEW_EXPIRED';
598
828
 
599
- export type { CartCheckAnswer as C, ReviewSubmitAnswer as R, StorefrontCategoryNode as S, ReviewSubmitInput as a, StorefrontListAnswer as b, StorefrontListProduct as c, ReviewEligibilityAnswer as d, StorefrontProductAnswer as e, CartCheckRequest as f, CartCreateAnswer as g, CartCreateRequest as h, CatalogContractErrorCode as i, StorefrontCategoriesAnswer as j, StorefrontCategoryAnswer as k, StorefrontCollectionAnswer as l, StorefrontCollectionsAnswer as m, StorefrontConfigAnswer as n, StorefrontFilterValuesAnswer as o, StorefrontRelatedAnswer as p, StorefrontReviewsAnswer as q, StorefrontSuggestAnswer as r, StorefrontTagsAnswer as s };
829
+ export type { CartCheckAnswer as C, ReviewSubmitAnswer as R, StorefrontSettings as S, ReviewSubmitInput as a, StorefrontMenuItem as b, StorefrontCategoryNode as c, StorefrontListAnswer as d, StorefrontListProduct as e, ReviewEligibilityAnswer as f, StorefrontProductAnswer as g, CartCheckRequest as h, CartCreateAnswer as i, CartCreateRequest as j, CatalogContractErrorCode as k, StorefrontCategoriesAnswer as l, StorefrontCategoryAnswer as m, StorefrontCollectionAnswer as n, StorefrontCollectionsAnswer as o, StorefrontConfigAnswer as p, StorefrontFilterDefinition as q, StorefrontFilterValuesAnswer as r, StorefrontPageAnswer as s, StorefrontPagesAnswer as t, StorefrontRelatedAnswer as u, StorefrontReviewsAnswer as v, StorefrontSuggestAnswer as w, StorefrontTagsAnswer as x };