@usethrottle/catalog 1.0.0 → 1.1.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,4 +1,4 @@
1
- import { p as CatalogContractErrorCode } from './types-DYfIvIaI.cjs';
1
+ import { g as CatalogContractErrorCode } from './contract-types-DhiThMEr.cjs';
2
2
 
3
3
  /**
4
4
  * Shared error type for every Throttle SDK.
@@ -239,5 +239,5 @@ declare class FeatureUnavailableError extends CatalogError {
239
239
  /** True for a `CatalogError` from this or any other copy of the SDK. */
240
240
  declare function isCatalogError(value: unknown): value is CatalogError;
241
241
 
242
- export { CartLineError as C, FeatureUnavailableError as F, NetworkError as N, OriginNotAllowedError as O, RateLimitedError as R, CatalogError as b, CustomerTokenInvalidError as h, TimeoutError as i, isCatalogError as j };
243
- export type { ThrottleCartCode as T, CartLineProblem as a, CatalogErrorCode as c, CatalogErrorInit as d, CatalogErrorIssue as e, CatalogErrorSource as f, ClientErrorCode as g };
242
+ export { CartLineError as C, FeatureUnavailableError as F, NetworkError as N, OriginNotAllowedError as O, RateLimitedError as R, TimeoutError as T, CatalogError as b, CustomerTokenInvalidError as h, isCatalogError as i };
243
+ export type { CartLineProblem as a, CatalogErrorCode as c, CatalogErrorInit as d, CatalogErrorIssue as e, CatalogErrorSource as f, ClientErrorCode as g, ThrottleCartCode as j };
@@ -3,7 +3,7 @@
3
3
  var _chunkETV4XYOVcjs = require('./chunk-ETV4XYOV.cjs');
4
4
 
5
5
  // src/version.ts
6
- var SDK_VERSION = true ? "1.0.0" : "0.0.0-dev";
6
+ var SDK_VERSION = true ? "1.1.0" : "0.0.0-dev";
7
7
 
8
8
  // src/errors/catalog-error.ts
9
9
  var _errors = require('@usethrottle/errors');
@@ -128,6 +128,7 @@ var TAG_MAX_CHARS = 256;
128
128
  var DEFAULT_REVALIDATE_S = 60;
129
129
  var LIST_PAGE_SIZE = 100;
130
130
  var LIST_MAX_HANDLES = 5e4;
131
+ var CATEGORY_TREE_MAX_DEPTH = 10;
131
132
 
132
133
  // src/errors/map.ts
133
134
  var ERROR_KINDS = Object.freeze({
@@ -1176,4 +1177,5 @@ function createCatalogClient(options) {
1176
1177
 
1177
1178
 
1178
1179
 
1179
- exports.SDK_VERSION = SDK_VERSION; exports.CatalogError = CatalogError; exports.RateLimitedError = RateLimitedError; exports.OriginNotAllowedError = OriginNotAllowedError; exports.CustomerTokenInvalidError = CustomerTokenInvalidError; exports.CartLineError = CartLineError; exports.TimeoutError = TimeoutError; exports.NetworkError = NetworkError; exports.FeatureUnavailableError = FeatureUnavailableError; exports.isCatalogError = isCatalogError; exports.DEFAULT_BASE_URL = DEFAULT_BASE_URL; exports.THROTTLE_CHECKOUT_URL = THROTTLE_CHECKOUT_URL; exports.RATE_LIMIT_DEFAULT_RETRY_S = RATE_LIMIT_DEFAULT_RETRY_S; exports.STALE_MS = STALE_MS; exports.CACHE_MAX_ENTRIES = CACHE_MAX_ENTRIES; exports.SUGGEST_DEBOUNCE_MS = SUGGEST_DEBOUNCE_MS; exports.SUGGEST_MIN_CHARS = SUGGEST_MIN_CHARS; exports.INDEXING_REVALIDATE_MS = INDEXING_REVALIDATE_MS; exports.CACHE_TAG = CACHE_TAG; exports.TAG_MAX_CHARS = TAG_MAX_CHARS; exports.DEFAULT_REVALIDATE_S = DEFAULT_REVALIDATE_S; exports.LIST_PAGE_SIZE = LIST_PAGE_SIZE; exports.LIST_MAX_HANDLES = LIST_MAX_HANDLES; exports.createCatalogClient = createCatalogClient;
1180
+
1181
+ exports.SDK_VERSION = SDK_VERSION; exports.CatalogError = CatalogError; exports.RateLimitedError = RateLimitedError; exports.OriginNotAllowedError = OriginNotAllowedError; exports.CustomerTokenInvalidError = CustomerTokenInvalidError; exports.CartLineError = CartLineError; exports.TimeoutError = TimeoutError; exports.NetworkError = NetworkError; exports.FeatureUnavailableError = FeatureUnavailableError; exports.isCatalogError = isCatalogError; exports.DEFAULT_BASE_URL = DEFAULT_BASE_URL; exports.THROTTLE_CHECKOUT_URL = THROTTLE_CHECKOUT_URL; exports.RATE_LIMIT_DEFAULT_RETRY_S = RATE_LIMIT_DEFAULT_RETRY_S; exports.STALE_MS = STALE_MS; exports.CACHE_MAX_ENTRIES = CACHE_MAX_ENTRIES; exports.SUGGEST_DEBOUNCE_MS = SUGGEST_DEBOUNCE_MS; exports.SUGGEST_MIN_CHARS = SUGGEST_MIN_CHARS; exports.INDEXING_REVALIDATE_MS = INDEXING_REVALIDATE_MS; exports.CACHE_TAG = CACHE_TAG; exports.TAG_MAX_CHARS = TAG_MAX_CHARS; exports.DEFAULT_REVALIDATE_S = DEFAULT_REVALIDATE_S; exports.LIST_PAGE_SIZE = LIST_PAGE_SIZE; exports.LIST_MAX_HANDLES = LIST_MAX_HANDLES; exports.CATEGORY_TREE_MAX_DEPTH = CATEGORY_TREE_MAX_DEPTH; exports.createCatalogClient = createCatalogClient;
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-PKBMQBKP.js";
4
4
 
5
5
  // src/version.ts
6
- var SDK_VERSION = true ? "1.0.0" : "0.0.0-dev";
6
+ var SDK_VERSION = true ? "1.1.0" : "0.0.0-dev";
7
7
 
8
8
  // src/errors/catalog-error.ts
9
9
  import { ThrottleError } from "@usethrottle/errors";
@@ -128,6 +128,7 @@ var TAG_MAX_CHARS = 256;
128
128
  var DEFAULT_REVALIDATE_S = 60;
129
129
  var LIST_PAGE_SIZE = 100;
130
130
  var LIST_MAX_HANDLES = 5e4;
131
+ var CATEGORY_TREE_MAX_DEPTH = 10;
131
132
 
132
133
  // src/errors/map.ts
133
134
  var ERROR_KINDS = Object.freeze({
@@ -1175,5 +1176,6 @@ export {
1175
1176
  DEFAULT_REVALIDATE_S,
1176
1177
  LIST_PAGE_SIZE,
1177
1178
  LIST_MAX_HANDLES,
1179
+ CATEGORY_TREE_MAX_DEPTH,
1178
1180
  createCatalogClient
1179
1181
  };
@@ -1,4 +1,4 @@
1
- import { X as RequestSpec, C as CallOptions, s as CatalogNamespaces, o as CatalogClientOptions } from './types-DYfIvIaI.cjs';
1
+ import { v as RequestSpec, C as CallOptions, k as CatalogNamespaces, h as CatalogClientOptions } from './types-DsjoG8ce.cjs';
2
2
 
3
3
  /**
4
4
  * The package version, baked in at build time (tsup `define`). Under the
@@ -1,4 +1,4 @@
1
- import { X as RequestSpec, C as CallOptions, s as CatalogNamespaces, o as CatalogClientOptions } from './types-DYfIvIaI.js';
1
+ import { v as RequestSpec, C as CallOptions, k as CatalogNamespaces, h as CatalogClientOptions } from './types-xQLID-4j.js';
2
2
 
3
3
  /**
4
4
  * The package version, baked in at build time (tsup `define`). Under the
@@ -596,275 +596,4 @@ type StorefrontTagsAnswer = {
596
596
  };
597
597
  type CatalogContractErrorCode = 'INVALID_REQUEST' | 'AUTHENTICATION_FAILED' | 'INFRASTRUCTURE_UNAVAILABLE' | 'PROVIDER_UNAVAILABLE' | 'INTERNAL_ERROR' | 'CUSTOMER_TOKEN_INVALID' | 'ORIGIN_NOT_ALLOWED' | 'SERVER_KEY_IN_BROWSER' | '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';
598
598
 
599
- type QueryPairs = [string, string][];
600
-
601
- /** One stored answer for ETag reuse (P6-R13). */
602
- type CatalogHttpCacheEntry = {
603
- etag: string;
604
- body: unknown;
605
- };
606
- /** Caller-provided store for ETag reuse; without one nothing is sent (P6-R13). */
607
- type CatalogHttpCache = {
608
- get(key: string): CatalogHttpCacheEntry | undefined;
609
- set(key: string, entry: CatalogHttpCacheEntry): void;
610
- };
611
- type CustomerTokenSource = () => string | null | undefined | Promise<string | null | undefined>;
612
- type CatalogClientOptions = {
613
- publishableKey: string;
614
- baseUrl?: string;
615
- fetch?: typeof fetch;
616
- timeoutMs?: number;
617
- currency?: string;
618
- locale?: string;
619
- customerToken?: CustomerTokenSource;
620
- cache?: CatalogHttpCache;
621
- /** The customer partition of the cache key (P6-R13). */
622
- cacheScope?: () => string;
623
- indexingRetry?: false | {
624
- maxWaitSeconds: number;
625
- };
626
- headers?: Record<string, string>;
627
- };
628
- /** Next.js's `fetch` cache options; the SDK never imports Next. */
629
- type NextFetchOptions = {
630
- revalidate?: number | false;
631
- tags?: string[];
632
- };
633
- type CallOptions = {
634
- signal?: AbortSignal;
635
- timeoutMs?: number;
636
- currency?: string;
637
- locale?: string;
638
- /** Extra `fetch` init keys (for example Next's `next`); never overrides the request. */
639
- fetchInit?: Record<string, unknown>;
640
- /**
641
- * Sent as the `fetch` init's `next` (over `fetchInit.next`). The server
642
- * client adds one to every cacheable GET (P6-R17); a plain client passes it
643
- * through. A request that carries a customer token drops it and is sent
644
- * `cache: 'no-store'`.
645
- */
646
- next?: NextFetchOptions;
647
- };
648
- type RequestSpec = {
649
- method: 'GET' | 'POST';
650
- /** Already encoded, starting with `/`. */
651
- path: string;
652
- query?: QueryPairs;
653
- body?: unknown;
654
- /** `'optional'` and `'required'` both send a token when there is one; `tokenFallback` decides a `401`. */
655
- customerToken: 'none' | 'optional' | 'required';
656
- tokenFallback: 'anonymous' | 'throw';
657
- /** The endpoint never answers a resource `404` (P6-R8 (b)). */
658
- featureRoute: boolean;
659
- idempotencyKey?: string;
660
- /** `false` turns off the one indexing retry for this request (P6-R10). */
661
- indexingRetry?: boolean;
662
- ifNoneMatch?: string;
663
- /**
664
- * Query context the transport appends to a GET: `'priced'` adds `currency`
665
- * and `locale`, `'locale'` adds `locale` only (call options over client
666
- * options). A POST takes them in its body, from `context()`.
667
- */
668
- context?: 'priced' | 'locale';
669
- };
670
-
671
- /** A list sort the catalog knows. */
672
- type StorefrontSort = StorefrontListAnswer['sort'];
673
- /** An old handle's answer: where the resource lives now. */
674
- type Redirect = {
675
- redirectTo: string;
676
- };
677
- /** `fields`: `lite` (the list default), `full`, or top-level product keys. */
678
- type FieldsOption = 'lite' | 'full' | readonly string[];
679
- /** The `/products` (and `/filters/:key/values`) selection. */
680
- type ProductsQuery = {
681
- q?: string;
682
- category?: string;
683
- collection?: string;
684
- /** Sent as repeated `tag`. */
685
- tags?: string[];
686
- featured?: boolean;
687
- /** `filter.<key>`, one parameter per value; a range is one `min..max` value. */
688
- filters?: Record<string, string | readonly string[]>;
689
- handles?: string[];
690
- skus?: string[];
691
- vehicle?: {
692
- year?: number;
693
- make: string;
694
- model: string;
695
- submodel?: string;
696
- engine?: string;
697
- };
698
- sort?: StorefrontSort | (string & {});
699
- limit?: number;
700
- page?: number;
701
- cursor?: string;
702
- /** `true` for every filter, or filter keys (repeated). */
703
- facets?: boolean | readonly string[];
704
- /** Comma-joined on the wire. */
705
- fields?: FieldsOption;
706
- /** Comma-joined on the wire. */
707
- include?: readonly string[];
708
- };
709
- /** A line of a Throttle cart. */
710
- type ThrottleLine = {
711
- id: string;
712
- referenceId: string | null;
713
- name: string;
714
- quantity: number;
715
- unitPrice: number;
716
- imageUrl: string | null;
717
- resolution?: {
718
- status: 'resolved' | 'refused' | 'stale';
719
- code: string | null;
720
- maxQuantity: number | null;
721
- } | null;
722
- };
723
- /** Throttle's cart as a cart session answers it; other keys pass through. */
724
- type ThrottleCart = {
725
- cartId: string;
726
- currency: string;
727
- subtotal: number;
728
- total: number;
729
- unitCount: number;
730
- lineItems?: ThrottleLine[];
731
- lineResolver?: {
732
- extensionId: string | null;
733
- };
734
- } & {
735
- [key: string]: unknown;
736
- };
737
- /**
738
- * A cart session answer, `data` unwrapped. Throttle sends `status` and
739
- * `expiresAt` on `get()` only; the mutations answer `{ cartSessionId, cart }`
740
- * and `refresh()` adds `changed`.
741
- */
742
- type CartSessionSnapshot = {
743
- cartSessionId: string;
744
- status?: string;
745
- expiresAt?: string;
746
- cart: ThrottleCart;
747
- changed?: boolean;
748
- };
749
- /** The store's look, as Throttle answers it on a cart-session read. */
750
- type CartSessionBranding = {
751
- logoUrl: string | null;
752
- primaryColor: string | null;
753
- merchantName: string | null;
754
- };
755
- /**
756
- * What `CartSession.get()` answers: the snapshot plus the fields only the
757
- * read carries. `metadata` is the session's own write-once metadata (the
758
- * buyer's return, cancel and storefront URLs among it), so its keys are the
759
- * caller's.
760
- */
761
- type CartSessionDetail = CartSessionSnapshot & {
762
- status: string;
763
- expiresAt: string;
764
- /** Throttle sends both today; an older deployment may omit them. */
765
- branding?: CartSessionBranding;
766
- metadata?: Record<string, unknown>;
767
- };
768
- type CartCheckoutInput = {
769
- /** Absolute `http:` or `https:` URL; anything else is refused before a request. */
770
- returnUrl: string;
771
- /** Absolute `http:` or `https:` URL; anything else is refused before a request. */
772
- cancelUrl: string;
773
- customerEmail?: string;
774
- keepOpen?: boolean;
775
- };
776
- type CartCheckout = {
777
- checkoutUrl: string;
778
- checkoutSessionId: string;
779
- expiresAt: string;
780
- };
781
- /** Per-call options of a cart-session call. */
782
- type SessionCallOptions = Pick<CallOptions, 'signal' | 'timeoutMs'>;
783
- /** One Throttle cart session, addressed by its opaque id. */
784
- type CartSession = {
785
- readonly id: string;
786
- get(call?: SessionCallOptions): Promise<CartSessionDetail>;
787
- add(input: {
788
- sku: string;
789
- quantity?: number;
790
- metadata?: Record<string, unknown>;
791
- }, call?: SessionCallOptions): Promise<CartSessionSnapshot>;
792
- update(lineId: string, quantity: number, call?: SessionCallOptions): Promise<CartSessionSnapshot>;
793
- remove(lineId: string, call?: SessionCallOptions): Promise<CartSessionSnapshot>;
794
- refresh(call?: SessionCallOptions): Promise<CartSessionSnapshot>;
795
- /** Refuses non-http(s) URLs before a request, and never returns a non-http(s) `checkoutUrl`. */
796
- checkout(input: CartCheckoutInput, call?: SessionCallOptions): Promise<CartCheckout>;
797
- };
798
- type ProductsNamespace = {
799
- list(query?: ProductsQuery, call?: CallOptions): Promise<StorefrontListAnswer>;
800
- /** Always the full product (`fields=full`, P6-R18), or a redirect. */
801
- get(handle: string, opts?: {
802
- include?: readonly string[];
803
- } & CallOptions): Promise<StorefrontProductAnswer | Redirect>;
804
- related(handle: string, opts?: {
805
- limit?: number;
806
- fields?: FieldsOption;
807
- } & CallOptions): Promise<StorefrontRelatedAnswer>;
808
- };
809
- type FiltersNamespace = {
810
- values(key: string, query?: ProductsQuery, call?: CallOptions): Promise<StorefrontFilterValuesAnswer>;
811
- };
812
- type CategoriesNamespace = {
813
- tree(opts?: {
814
- depth?: 1 | 2 | 3;
815
- } & CallOptions): Promise<StorefrontCategoriesAnswer>;
816
- get(handle: string, call?: CallOptions): Promise<StorefrontCategoryAnswer>;
817
- };
818
- type TagsNamespace = {
819
- list(opts?: {
820
- q?: string;
821
- limit?: number;
822
- } & CallOptions): Promise<StorefrontTagsAnswer>;
823
- };
824
- type CollectionsNamespace = {
825
- list(opts?: {
826
- limit?: number;
827
- cursor?: string;
828
- } & CallOptions): Promise<StorefrontCollectionsAnswer>;
829
- get(handle: string, call?: CallOptions): Promise<StorefrontCollectionAnswer>;
830
- };
831
- type ReviewsNamespace = {
832
- list(handle: string, opts?: {
833
- sort?: 'newest' | 'highest' | 'lowest';
834
- rating?: 1 | 2 | 3 | 4 | 5;
835
- limit?: number;
836
- cursor?: string;
837
- } & CallOptions): Promise<StorefrontReviewsAnswer>;
838
- eligibility(handle: string, call?: CallOptions): Promise<ReviewEligibilityAnswer>;
839
- submit(handle: string, input: ReviewSubmitInput, opts?: {
840
- idempotencyKey?: string;
841
- } & CallOptions): Promise<ReviewSubmitAnswer>;
842
- };
843
- type CartsNamespace = {
844
- check(items: {
845
- sku: string;
846
- quantity: number;
847
- }[], opts?: CallOptions): Promise<CartCheckAnswer>;
848
- create(input: CartCreateRequest, opts?: {
849
- idempotencyKey?: string;
850
- } & CallOptions): Promise<CartCreateAnswer>;
851
- /** Throttle's cart-session routes; no catalog key and no customer token are sent. */
852
- session(sessionId: string, opts?: {
853
- throttleBaseUrl?: string;
854
- }): CartSession;
855
- };
856
- type CatalogNamespaces = {
857
- readonly products: ProductsNamespace;
858
- readonly filters: FiltersNamespace;
859
- readonly categories: CategoriesNamespace;
860
- readonly tags: TagsNamespace;
861
- readonly collections: CollectionsNamespace;
862
- readonly suggest: (q: string, opts?: {
863
- limit?: number;
864
- } & CallOptions) => Promise<StorefrontSuggestAnswer>;
865
- readonly config: (call?: CallOptions) => Promise<StorefrontConfigAnswer>;
866
- readonly reviews: ReviewsNamespace;
867
- readonly carts: CartsNamespace;
868
- };
869
-
870
- export type { ReviewSubmitInput as A, ReviewsNamespace as B, CallOptions as C, SessionCallOptions as D, StorefrontCategoriesAnswer as E, FieldsOption as F, StorefrontCategoryAnswer as G, StorefrontCollectionAnswer as H, StorefrontCollectionsAnswer as I, StorefrontConfigAnswer as J, StorefrontFilterValuesAnswer as K, StorefrontRelatedAnswer as L, StorefrontReviewsAnswer as M, NextFetchOptions as N, StorefrontSort as O, ProductsNamespace as P, StorefrontSuggestAnswer as Q, Redirect as R, StorefrontCategoryNode as S, StorefrontTagsAnswer as T, TagsNamespace as U, ThrottleCart as V, ThrottleLine as W, RequestSpec as X, StorefrontListAnswer as a, StorefrontListProduct as b, StorefrontProductAnswer as c, CartCheckAnswer as d, CartCheckRequest as e, CartCheckout as f, CartCheckoutInput as g, CartCreateAnswer as h, CartCreateRequest as i, CartSession as j, CartSessionBranding as k, CartSessionDetail as l, CartSessionSnapshot as m, CartsNamespace as n, CatalogClientOptions as o, CatalogContractErrorCode as p, CatalogHttpCache as q, CatalogHttpCacheEntry as r, CatalogNamespaces as s, CategoriesNamespace as t, CollectionsNamespace as u, CustomerTokenSource as v, FiltersNamespace as w, ProductsQuery as x, ReviewEligibilityAnswer as y, ReviewSubmitAnswer as z };
599
+ export type { CartCheckAnswer as C, ReviewEligibilityAnswer as R, StorefrontCategoryNode as S, StorefrontListAnswer as a, StorefrontListProduct as b, StorefrontProductAnswer as c, CartCheckRequest as d, CartCreateAnswer as e, CartCreateRequest as f, CatalogContractErrorCode as g, ReviewSubmitAnswer as h, ReviewSubmitInput 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 };
@@ -596,275 +596,4 @@ type StorefrontTagsAnswer = {
596
596
  };
597
597
  type CatalogContractErrorCode = 'INVALID_REQUEST' | 'AUTHENTICATION_FAILED' | 'INFRASTRUCTURE_UNAVAILABLE' | 'PROVIDER_UNAVAILABLE' | 'INTERNAL_ERROR' | 'CUSTOMER_TOKEN_INVALID' | 'ORIGIN_NOT_ALLOWED' | 'SERVER_KEY_IN_BROWSER' | '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';
598
598
 
599
- type QueryPairs = [string, string][];
600
-
601
- /** One stored answer for ETag reuse (P6-R13). */
602
- type CatalogHttpCacheEntry = {
603
- etag: string;
604
- body: unknown;
605
- };
606
- /** Caller-provided store for ETag reuse; without one nothing is sent (P6-R13). */
607
- type CatalogHttpCache = {
608
- get(key: string): CatalogHttpCacheEntry | undefined;
609
- set(key: string, entry: CatalogHttpCacheEntry): void;
610
- };
611
- type CustomerTokenSource = () => string | null | undefined | Promise<string | null | undefined>;
612
- type CatalogClientOptions = {
613
- publishableKey: string;
614
- baseUrl?: string;
615
- fetch?: typeof fetch;
616
- timeoutMs?: number;
617
- currency?: string;
618
- locale?: string;
619
- customerToken?: CustomerTokenSource;
620
- cache?: CatalogHttpCache;
621
- /** The customer partition of the cache key (P6-R13). */
622
- cacheScope?: () => string;
623
- indexingRetry?: false | {
624
- maxWaitSeconds: number;
625
- };
626
- headers?: Record<string, string>;
627
- };
628
- /** Next.js's `fetch` cache options; the SDK never imports Next. */
629
- type NextFetchOptions = {
630
- revalidate?: number | false;
631
- tags?: string[];
632
- };
633
- type CallOptions = {
634
- signal?: AbortSignal;
635
- timeoutMs?: number;
636
- currency?: string;
637
- locale?: string;
638
- /** Extra `fetch` init keys (for example Next's `next`); never overrides the request. */
639
- fetchInit?: Record<string, unknown>;
640
- /**
641
- * Sent as the `fetch` init's `next` (over `fetchInit.next`). The server
642
- * client adds one to every cacheable GET (P6-R17); a plain client passes it
643
- * through. A request that carries a customer token drops it and is sent
644
- * `cache: 'no-store'`.
645
- */
646
- next?: NextFetchOptions;
647
- };
648
- type RequestSpec = {
649
- method: 'GET' | 'POST';
650
- /** Already encoded, starting with `/`. */
651
- path: string;
652
- query?: QueryPairs;
653
- body?: unknown;
654
- /** `'optional'` and `'required'` both send a token when there is one; `tokenFallback` decides a `401`. */
655
- customerToken: 'none' | 'optional' | 'required';
656
- tokenFallback: 'anonymous' | 'throw';
657
- /** The endpoint never answers a resource `404` (P6-R8 (b)). */
658
- featureRoute: boolean;
659
- idempotencyKey?: string;
660
- /** `false` turns off the one indexing retry for this request (P6-R10). */
661
- indexingRetry?: boolean;
662
- ifNoneMatch?: string;
663
- /**
664
- * Query context the transport appends to a GET: `'priced'` adds `currency`
665
- * and `locale`, `'locale'` adds `locale` only (call options over client
666
- * options). A POST takes them in its body, from `context()`.
667
- */
668
- context?: 'priced' | 'locale';
669
- };
670
-
671
- /** A list sort the catalog knows. */
672
- type StorefrontSort = StorefrontListAnswer['sort'];
673
- /** An old handle's answer: where the resource lives now. */
674
- type Redirect = {
675
- redirectTo: string;
676
- };
677
- /** `fields`: `lite` (the list default), `full`, or top-level product keys. */
678
- type FieldsOption = 'lite' | 'full' | readonly string[];
679
- /** The `/products` (and `/filters/:key/values`) selection. */
680
- type ProductsQuery = {
681
- q?: string;
682
- category?: string;
683
- collection?: string;
684
- /** Sent as repeated `tag`. */
685
- tags?: string[];
686
- featured?: boolean;
687
- /** `filter.<key>`, one parameter per value; a range is one `min..max` value. */
688
- filters?: Record<string, string | readonly string[]>;
689
- handles?: string[];
690
- skus?: string[];
691
- vehicle?: {
692
- year?: number;
693
- make: string;
694
- model: string;
695
- submodel?: string;
696
- engine?: string;
697
- };
698
- sort?: StorefrontSort | (string & {});
699
- limit?: number;
700
- page?: number;
701
- cursor?: string;
702
- /** `true` for every filter, or filter keys (repeated). */
703
- facets?: boolean | readonly string[];
704
- /** Comma-joined on the wire. */
705
- fields?: FieldsOption;
706
- /** Comma-joined on the wire. */
707
- include?: readonly string[];
708
- };
709
- /** A line of a Throttle cart. */
710
- type ThrottleLine = {
711
- id: string;
712
- referenceId: string | null;
713
- name: string;
714
- quantity: number;
715
- unitPrice: number;
716
- imageUrl: string | null;
717
- resolution?: {
718
- status: 'resolved' | 'refused' | 'stale';
719
- code: string | null;
720
- maxQuantity: number | null;
721
- } | null;
722
- };
723
- /** Throttle's cart as a cart session answers it; other keys pass through. */
724
- type ThrottleCart = {
725
- cartId: string;
726
- currency: string;
727
- subtotal: number;
728
- total: number;
729
- unitCount: number;
730
- lineItems?: ThrottleLine[];
731
- lineResolver?: {
732
- extensionId: string | null;
733
- };
734
- } & {
735
- [key: string]: unknown;
736
- };
737
- /**
738
- * A cart session answer, `data` unwrapped. Throttle sends `status` and
739
- * `expiresAt` on `get()` only; the mutations answer `{ cartSessionId, cart }`
740
- * and `refresh()` adds `changed`.
741
- */
742
- type CartSessionSnapshot = {
743
- cartSessionId: string;
744
- status?: string;
745
- expiresAt?: string;
746
- cart: ThrottleCart;
747
- changed?: boolean;
748
- };
749
- /** The store's look, as Throttle answers it on a cart-session read. */
750
- type CartSessionBranding = {
751
- logoUrl: string | null;
752
- primaryColor: string | null;
753
- merchantName: string | null;
754
- };
755
- /**
756
- * What `CartSession.get()` answers: the snapshot plus the fields only the
757
- * read carries. `metadata` is the session's own write-once metadata (the
758
- * buyer's return, cancel and storefront URLs among it), so its keys are the
759
- * caller's.
760
- */
761
- type CartSessionDetail = CartSessionSnapshot & {
762
- status: string;
763
- expiresAt: string;
764
- /** Throttle sends both today; an older deployment may omit them. */
765
- branding?: CartSessionBranding;
766
- metadata?: Record<string, unknown>;
767
- };
768
- type CartCheckoutInput = {
769
- /** Absolute `http:` or `https:` URL; anything else is refused before a request. */
770
- returnUrl: string;
771
- /** Absolute `http:` or `https:` URL; anything else is refused before a request. */
772
- cancelUrl: string;
773
- customerEmail?: string;
774
- keepOpen?: boolean;
775
- };
776
- type CartCheckout = {
777
- checkoutUrl: string;
778
- checkoutSessionId: string;
779
- expiresAt: string;
780
- };
781
- /** Per-call options of a cart-session call. */
782
- type SessionCallOptions = Pick<CallOptions, 'signal' | 'timeoutMs'>;
783
- /** One Throttle cart session, addressed by its opaque id. */
784
- type CartSession = {
785
- readonly id: string;
786
- get(call?: SessionCallOptions): Promise<CartSessionDetail>;
787
- add(input: {
788
- sku: string;
789
- quantity?: number;
790
- metadata?: Record<string, unknown>;
791
- }, call?: SessionCallOptions): Promise<CartSessionSnapshot>;
792
- update(lineId: string, quantity: number, call?: SessionCallOptions): Promise<CartSessionSnapshot>;
793
- remove(lineId: string, call?: SessionCallOptions): Promise<CartSessionSnapshot>;
794
- refresh(call?: SessionCallOptions): Promise<CartSessionSnapshot>;
795
- /** Refuses non-http(s) URLs before a request, and never returns a non-http(s) `checkoutUrl`. */
796
- checkout(input: CartCheckoutInput, call?: SessionCallOptions): Promise<CartCheckout>;
797
- };
798
- type ProductsNamespace = {
799
- list(query?: ProductsQuery, call?: CallOptions): Promise<StorefrontListAnswer>;
800
- /** Always the full product (`fields=full`, P6-R18), or a redirect. */
801
- get(handle: string, opts?: {
802
- include?: readonly string[];
803
- } & CallOptions): Promise<StorefrontProductAnswer | Redirect>;
804
- related(handle: string, opts?: {
805
- limit?: number;
806
- fields?: FieldsOption;
807
- } & CallOptions): Promise<StorefrontRelatedAnswer>;
808
- };
809
- type FiltersNamespace = {
810
- values(key: string, query?: ProductsQuery, call?: CallOptions): Promise<StorefrontFilterValuesAnswer>;
811
- };
812
- type CategoriesNamespace = {
813
- tree(opts?: {
814
- depth?: 1 | 2 | 3;
815
- } & CallOptions): Promise<StorefrontCategoriesAnswer>;
816
- get(handle: string, call?: CallOptions): Promise<StorefrontCategoryAnswer>;
817
- };
818
- type TagsNamespace = {
819
- list(opts?: {
820
- q?: string;
821
- limit?: number;
822
- } & CallOptions): Promise<StorefrontTagsAnswer>;
823
- };
824
- type CollectionsNamespace = {
825
- list(opts?: {
826
- limit?: number;
827
- cursor?: string;
828
- } & CallOptions): Promise<StorefrontCollectionsAnswer>;
829
- get(handle: string, call?: CallOptions): Promise<StorefrontCollectionAnswer>;
830
- };
831
- type ReviewsNamespace = {
832
- list(handle: string, opts?: {
833
- sort?: 'newest' | 'highest' | 'lowest';
834
- rating?: 1 | 2 | 3 | 4 | 5;
835
- limit?: number;
836
- cursor?: string;
837
- } & CallOptions): Promise<StorefrontReviewsAnswer>;
838
- eligibility(handle: string, call?: CallOptions): Promise<ReviewEligibilityAnswer>;
839
- submit(handle: string, input: ReviewSubmitInput, opts?: {
840
- idempotencyKey?: string;
841
- } & CallOptions): Promise<ReviewSubmitAnswer>;
842
- };
843
- type CartsNamespace = {
844
- check(items: {
845
- sku: string;
846
- quantity: number;
847
- }[], opts?: CallOptions): Promise<CartCheckAnswer>;
848
- create(input: CartCreateRequest, opts?: {
849
- idempotencyKey?: string;
850
- } & CallOptions): Promise<CartCreateAnswer>;
851
- /** Throttle's cart-session routes; no catalog key and no customer token are sent. */
852
- session(sessionId: string, opts?: {
853
- throttleBaseUrl?: string;
854
- }): CartSession;
855
- };
856
- type CatalogNamespaces = {
857
- readonly products: ProductsNamespace;
858
- readonly filters: FiltersNamespace;
859
- readonly categories: CategoriesNamespace;
860
- readonly tags: TagsNamespace;
861
- readonly collections: CollectionsNamespace;
862
- readonly suggest: (q: string, opts?: {
863
- limit?: number;
864
- } & CallOptions) => Promise<StorefrontSuggestAnswer>;
865
- readonly config: (call?: CallOptions) => Promise<StorefrontConfigAnswer>;
866
- readonly reviews: ReviewsNamespace;
867
- readonly carts: CartsNamespace;
868
- };
869
-
870
- export type { ReviewSubmitInput as A, ReviewsNamespace as B, CallOptions as C, SessionCallOptions as D, StorefrontCategoriesAnswer as E, FieldsOption as F, StorefrontCategoryAnswer as G, StorefrontCollectionAnswer as H, StorefrontCollectionsAnswer as I, StorefrontConfigAnswer as J, StorefrontFilterValuesAnswer as K, StorefrontRelatedAnswer as L, StorefrontReviewsAnswer as M, NextFetchOptions as N, StorefrontSort as O, ProductsNamespace as P, StorefrontSuggestAnswer as Q, Redirect as R, StorefrontCategoryNode as S, StorefrontTagsAnswer as T, TagsNamespace as U, ThrottleCart as V, ThrottleLine as W, RequestSpec as X, StorefrontListAnswer as a, StorefrontListProduct as b, StorefrontProductAnswer as c, CartCheckAnswer as d, CartCheckRequest as e, CartCheckout as f, CartCheckoutInput as g, CartCreateAnswer as h, CartCreateRequest as i, CartSession as j, CartSessionBranding as k, CartSessionDetail as l, CartSessionSnapshot as m, CartsNamespace as n, CatalogClientOptions as o, CatalogContractErrorCode as p, CatalogHttpCache as q, CatalogHttpCacheEntry as r, CatalogNamespaces as s, CategoriesNamespace as t, CollectionsNamespace as u, CustomerTokenSource as v, FiltersNamespace as w, ProductsQuery as x, ReviewEligibilityAnswer as y, ReviewSubmitAnswer as z };
599
+ export type { CartCheckAnswer as C, ReviewEligibilityAnswer as R, StorefrontCategoryNode as S, StorefrontListAnswer as a, StorefrontListProduct as b, StorefrontProductAnswer as c, CartCheckRequest as d, CartCreateAnswer as e, CartCreateRequest as f, CatalogContractErrorCode as g, ReviewSubmitAnswer as h, ReviewSubmitInput 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 };
package/dist/index.cjs CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
 
12
12
 
13
- var _chunkZFUELHUUcjs = require('./chunk-ZFUELHUU.cjs');
13
+ var _chunk4ORXUW2Ucjs = require('./chunk-4ORXUW2U.cjs');
14
14
  require('./chunk-ETV4XYOV.cjs');
15
15
 
16
16
 
@@ -24,4 +24,4 @@ require('./chunk-ETV4XYOV.cjs');
24
24
 
25
25
 
26
26
 
27
- exports.CartLineError = _chunkZFUELHUUcjs.CartLineError; exports.CatalogError = _chunkZFUELHUUcjs.CatalogError; exports.CustomerTokenInvalidError = _chunkZFUELHUUcjs.CustomerTokenInvalidError; exports.FeatureUnavailableError = _chunkZFUELHUUcjs.FeatureUnavailableError; exports.NetworkError = _chunkZFUELHUUcjs.NetworkError; exports.OriginNotAllowedError = _chunkZFUELHUUcjs.OriginNotAllowedError; exports.RateLimitedError = _chunkZFUELHUUcjs.RateLimitedError; exports.SDK_VERSION = _chunkZFUELHUUcjs.SDK_VERSION; exports.TimeoutError = _chunkZFUELHUUcjs.TimeoutError; exports.createCatalogClient = _chunkZFUELHUUcjs.createCatalogClient; exports.isCatalogError = _chunkZFUELHUUcjs.isCatalogError;
27
+ exports.CartLineError = _chunk4ORXUW2Ucjs.CartLineError; exports.CatalogError = _chunk4ORXUW2Ucjs.CatalogError; exports.CustomerTokenInvalidError = _chunk4ORXUW2Ucjs.CustomerTokenInvalidError; exports.FeatureUnavailableError = _chunk4ORXUW2Ucjs.FeatureUnavailableError; exports.NetworkError = _chunk4ORXUW2Ucjs.NetworkError; exports.OriginNotAllowedError = _chunk4ORXUW2Ucjs.OriginNotAllowedError; exports.RateLimitedError = _chunk4ORXUW2Ucjs.RateLimitedError; exports.SDK_VERSION = _chunk4ORXUW2Ucjs.SDK_VERSION; exports.TimeoutError = _chunk4ORXUW2Ucjs.TimeoutError; exports.createCatalogClient = _chunk4ORXUW2Ucjs.createCatalogClient; exports.isCatalogError = _chunk4ORXUW2Ucjs.isCatalogError;