@01.software/sdk 0.46.0 → 0.48.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 (57) hide show
  1. package/CHANGELOG.md +75 -1
  2. package/README.md +81 -7
  3. package/dist/client.cjs +304 -63
  4. package/dist/client.cjs.map +1 -1
  5. package/dist/client.d.cts +6 -6
  6. package/dist/client.d.ts +6 -6
  7. package/dist/client.js +304 -63
  8. package/dist/client.js.map +1 -1
  9. package/dist/{collection-client-DolMjCoC.d.cts → collection-client-CBup9yOx.d.cts} +4 -4
  10. package/dist/{collection-client-D6kKrYdq.d.ts → collection-client-D3ExJU-7.d.ts} +4 -4
  11. package/dist/{const-BAG0MH0u.d.cts → const-BXEi1Kix.d.cts} +4 -4
  12. package/dist/{const-CaPq2AE4.d.ts → const-k9gHylYa.d.ts} +4 -4
  13. package/dist/errors.cjs +49 -1
  14. package/dist/errors.cjs.map +1 -1
  15. package/dist/errors.d.cts +3 -3
  16. package/dist/errors.d.ts +3 -3
  17. package/dist/errors.js +49 -1
  18. package/dist/errors.js.map +1 -1
  19. package/dist/{index-YGrZrxNn.d.cts → index-BCM9CTL7.d.cts} +3 -3
  20. package/dist/{index-BNICJxBL.d.ts → index-CHGGkcLj.d.ts} +3 -3
  21. package/dist/index.cjs +308 -64
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +7 -7
  24. package/dist/index.d.ts +7 -7
  25. package/dist/index.js +308 -64
  26. package/dist/index.js.map +1 -1
  27. package/dist/{payload-types-CJZuXcgF.d.cts → payload-types-B6AZQcB7.d.cts} +182 -15
  28. package/dist/{payload-types-CJZuXcgF.d.ts → payload-types-B6AZQcB7.d.ts} +182 -15
  29. package/dist/query.cjs +144 -43
  30. package/dist/query.cjs.map +1 -1
  31. package/dist/query.d.cts +5 -5
  32. package/dist/query.d.ts +5 -5
  33. package/dist/query.js +144 -43
  34. package/dist/query.js.map +1 -1
  35. package/dist/realtime.d.cts +2 -2
  36. package/dist/realtime.d.ts +2 -2
  37. package/dist/server.cjs +385 -63
  38. package/dist/server.cjs.map +1 -1
  39. package/dist/server.d.cts +7 -7
  40. package/dist/server.d.ts +7 -7
  41. package/dist/server.js +385 -63
  42. package/dist/server.js.map +1 -1
  43. package/dist/storefront-cache.cjs +49 -1
  44. package/dist/storefront-cache.cjs.map +1 -1
  45. package/dist/storefront-cache.js +49 -1
  46. package/dist/storefront-cache.js.map +1 -1
  47. package/dist/{types-D5p7-m1l.d.cts → types-8us-_C-Q.d.cts} +2 -2
  48. package/dist/{types-BC6rVmJa.d.ts → types-ByD2zii1.d.ts} +2 -2
  49. package/dist/{types-xlqBeW2N.d.cts → types-CM2je9Kw.d.cts} +84 -7
  50. package/dist/{types-C60vHIkY.d.ts → types-DbA5V3mt.d.ts} +84 -7
  51. package/dist/ui/form.d.cts +1 -1
  52. package/dist/ui/form.d.ts +1 -1
  53. package/dist/ui/video.d.cts +1 -1
  54. package/dist/ui/video.d.ts +1 -1
  55. package/dist/webhook.d.cts +4 -4
  56. package/dist/webhook.d.ts +4 -4
  57. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/query.ts","../src/core/query/get-query-client.ts","../src/core/query/query-keys.ts","../src/core/query/collection-hooks.ts","../src/core/query/customer-hooks.ts","../src/core/errors.ts","../src/core/query/query-hooks.ts","../src/core/internal/utils/query-string.ts","../../../internal/http-contracts/src/index.ts","../src/core/api/endpoints.ts","../src/core/query/realtime.ts","../src/core/query/query-client.ts"],"sourcesContent":["export * from './core/query'\n","import {\n isServer,\n QueryClient,\n defaultShouldDehydrateQuery,\n} from '@tanstack/react-query'\n\nfunction makeQueryClient() {\n return new QueryClient({\n defaultOptions: {\n queries: {\n // Infinite staleTime: server-fetched data persists until explicitly invalidated.\n // For browser clients needing fresher data, override per-query:\n // useQuery({ ..., staleTime: 5 * 60 * 1000 })\n staleTime: Number.POSITIVE_INFINITY,\n refetchOnWindowFocus: false,\n },\n dehydrate: {\n shouldDehydrateQuery: (query) =>\n defaultShouldDehydrateQuery(query) ||\n query.state.status === 'pending',\n shouldRedactErrors: () => false,\n },\n },\n })\n}\n\nlet browserQueryClient: QueryClient | undefined\nlet browserStorefrontQueryClient: QueryClient | undefined\n\n/** Default React Query client (SSR hydration-friendly: infinite staleTime). */\nexport function getQueryClient() {\n if (isServer) {\n return makeQueryClient()\n }\n if (!browserQueryClient) {\n browserQueryClient = makeQueryClient()\n }\n return browserQueryClient\n}\n\nconst STOREFRONT_STALE_TIME_MS = 60_000\n\nfunction makeStorefrontQueryClient() {\n return new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: STOREFRONT_STALE_TIME_MS,\n refetchOnWindowFocus: false,\n },\n dehydrate: {\n shouldDehydrateQuery: (query) =>\n defaultShouldDehydrateQuery(query) ||\n query.state.status === 'pending',\n shouldRedactErrors: () => false,\n },\n },\n })\n}\n\n/**\n * Browser storefront client: refetches catalog data after ~1 minute instead of\n * keeping SSR data fresh forever. Use with `createQueryHooks(client, queryClient)`.\n */\nexport function getStorefrontQueryClient() {\n if (isServer) {\n return makeStorefrontQueryClient()\n }\n if (!browserStorefrontQueryClient) {\n browserStorefrontQueryClient = makeStorefrontQueryClient()\n }\n return browserStorefrontQueryClient\n}\n","import type { ServerCollection, ApiQueryOptions } from '../client/types'\nimport type { ProductDetailParams, ProductListingPageParams } from '../api'\nimport type { ProductListingGroupsQueryOptions } from './query-hooks'\n\ntype ProductListingPageKeyParams = {\n mode: 'catalog' | 'full'\n market?: string\n locale?: ProductListingPageParams['locale']\n fallbackLocale?: ProductListingPageParams['fallbackLocale']\n page?: number\n limit?: number\n search?: string\n sort?: ProductListingPageParams['sort']\n filters?: NonNullable<ProductListingPageParams['filters']>\n basePath?: string\n trailingSlash?: boolean\n emit?: ProductListingPageParams['emit']\n preferCompleteVariantFromHint?: ProductListingPageParams['preferCompleteVariantFromHint']\n}\n\nfunction nonEmpty(values: string[] | undefined): string[] | undefined {\n return values?.length ? values : undefined\n}\n\nfunction canonicalProductListingPageParams(\n params: ProductListingPageParams = {},\n limit?: number,\n): ProductListingPageKeyParams {\n const filters = params.filters\n const canonicalFilters: NonNullable<ProductListingPageParams['filters']> = {}\n const ids = nonEmpty(filters?.ids)\n if (ids) canonicalFilters.ids = ids\n const slugs = nonEmpty(filters?.slugs)\n if (slugs) canonicalFilters.slugs = slugs\n const handles = nonEmpty(filters?.handles)\n if (handles) canonicalFilters.handles = handles\n const categoryIds = nonEmpty(filters?.categoryIds)\n if (categoryIds) canonicalFilters.categoryIds = categoryIds\n const tagIds = nonEmpty(filters?.tagIds)\n if (tagIds) canonicalFilters.tagIds = tagIds\n if (filters?.price?.min != null || filters?.price?.max != null) {\n canonicalFilters.price = {\n ...(filters.price.min != null && { min: filters.price.min }),\n ...(filters.price.max != null && { max: filters.price.max }),\n }\n }\n if (filters?.availableForSale != null) {\n canonicalFilters.availableForSale = filters.availableForSale\n }\n\n const search = params.search?.trim()\n const market = params.market?.trim()\n return {\n mode: params.mode ?? 'catalog',\n ...(market && { market }),\n ...(params.locale != null && { locale: params.locale }),\n ...(params.fallbackLocale !== undefined && {\n fallbackLocale: params.fallbackLocale,\n }),\n ...(params.page != null && { page: params.page }),\n ...(limit != null\n ? { limit }\n : params.limit != null\n ? { limit: params.limit }\n : {}),\n ...(search && { search }),\n ...(params.sort != null && { sort: params.sort }),\n ...(Object.keys(canonicalFilters).length > 0 && {\n filters: canonicalFilters,\n }),\n ...(params.basePath != null && { basePath: params.basePath }),\n ...(params.trailingSlash != null && {\n trailingSlash: params.trailingSlash,\n }),\n ...(params.emit != null && { emit: params.emit }),\n ...(params.preferCompleteVariantFromHint != null && {\n preferCompleteVariantFromHint: params.preferCompleteVariantFromHint,\n }),\n }\n}\n\nfunction canonicalMarket(value: string | undefined): string | undefined {\n const market = value?.trim()\n return market || undefined\n}\n\nexport function canonicalProductListingGroupsQueryOptions(\n options?: ProductListingGroupsQueryOptions,\n limit?: number,\n): ProductListingGroupsQueryOptions | undefined {\n const { market: rawMarket, ...rest } = options ?? {}\n const market = canonicalMarket(rawMarket)\n const canonical: ProductListingGroupsQueryOptions = {\n ...rest,\n ...(limit !== undefined ? { limit } : {}),\n ...(market ? { market } : {}),\n }\n return Object.keys(canonical).length > 0 ? canonical : undefined\n}\n\nfunction canonicalProductDetailParams(\n params: ProductDetailParams,\n): ProductDetailParams {\n const market = params.market?.trim()\n const localeOptions = {\n ...(params.locale != null && { locale: params.locale }),\n ...(params.fallbackLocale !== undefined && {\n fallbackLocale: params.fallbackLocale,\n }),\n }\n if ('slug' in params) {\n return {\n slug: params.slug,\n ...(market ? { market } : {}),\n ...localeOptions,\n }\n }\n return {\n id: params.id,\n ...(market ? { market } : {}),\n ...localeOptions,\n }\n}\n\nexport function collectionKeys<T extends ServerCollection>(collection: T) {\n return {\n all: [collection] as const,\n lists: () => [collection, 'list'] as const,\n list: (options?: ApiQueryOptions) => [collection, 'list', options] as const,\n details: () => [collection, 'detail'] as const,\n detail: (id: string, options?: ApiQueryOptions) =>\n [collection, 'detail', id, options] as const,\n infinites: () => [collection, 'infinite'] as const,\n infinite: (options?: Omit<ApiQueryOptions, 'page'>, pageSize?: number) =>\n [\n collection,\n 'infinite',\n pageSize === undefined ? options : { ...options, limit: pageSize },\n ] as const,\n }\n}\n\nexport const customerKeys = {\n all: ['customer'] as const,\n me: () => ['customer', 'me'] as const,\n}\n\nexport const productKeys = {\n listingGroups: (options?: ProductListingGroupsQueryOptions) =>\n [\n 'products',\n 'listing-groups',\n 'list',\n canonicalProductListingGroupsQueryOptions(options),\n ] as const,\n listingGroupsCatalog: (options?: ProductListingGroupsQueryOptions) =>\n [\n 'products',\n 'listing-groups',\n 'catalog',\n canonicalProductListingGroupsQueryOptions(options),\n ] as const,\n listingGroupsInfinite: (\n options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>,\n pageSize?: number,\n ) =>\n [\n 'products',\n 'listing-groups',\n 'infinite',\n canonicalProductListingGroupsQueryOptions(options, pageSize),\n ] as const,\n listingGroupsCatalogInfinite: (\n options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>,\n pageSize?: number,\n ) =>\n [\n 'products',\n 'listing-groups',\n 'catalog',\n 'infinite',\n canonicalProductListingGroupsQueryOptions(options, pageSize),\n ] as const,\n listingPage: (params?: ProductListingPageParams) =>\n [\n 'products',\n 'listing-page',\n canonicalProductListingPageParams(params),\n ] as const,\n listingPageInfinite: (\n params?: Omit<ProductListingPageParams, 'page' | 'limit'>,\n pageSize?: number,\n ) =>\n [\n 'products',\n 'listing-page',\n 'infinite',\n canonicalProductListingPageParams(\n params as ProductListingPageParams | undefined,\n pageSize,\n ),\n ] as const,\n detail: (params: ProductDetailParams) =>\n ['products', 'detail', canonicalProductDetailParams(params)] as const,\n detailAll: () => ['products', 'detail'] as const,\n}\n","import {\n QueryClient,\n useQuery as useQueryOriginal,\n useSuspenseQuery as useSuspenseQueryOriginal,\n useInfiniteQuery as useInfiniteQueryOriginal,\n useSuspenseInfiniteQuery as useSuspenseInfiniteQueryOriginal,\n useMutation as useMutationOriginal,\n} from '@tanstack/react-query'\nimport type {\n InfiniteData,\n UseInfiniteQueryResult,\n UseQueryResult,\n UseSuspenseInfiniteQueryResult,\n UseSuspenseQueryResult,\n} from '@tanstack/react-query'\nimport type {\n PublicCollection,\n ServerCollection,\n ApiQueryOptions,\n PublicReadQueryOptions,\n PayloadFindResponse,\n PayloadMutationResponse,\n} from '../client/types'\nimport { type CollectionClient, type CollectionType } from '../collection'\nimport { SDKError } from '../internal/errors'\nimport { collectionKeys } from './query-keys'\n\n// ============================================================================\n// Query Params Types\n// ============================================================================\n\ntype CollectionReadOptions<TCollection extends ServerCollection> =\n [TCollection] extends [PublicCollection]\n ? PublicReadQueryOptions\n : ApiQueryOptions\n\nexport interface CollectionQueryParams<\n T extends ServerCollection,\n Options extends ApiQueryOptions = ApiQueryOptions,\n> {\n collection: T\n options?: Options\n}\n\nexport interface CollectionDetailQueryParams<\n T extends ServerCollection,\n Options extends ApiQueryOptions = ApiQueryOptions,\n> {\n collection: T\n id: string\n options?: Options\n}\n\nexport interface CollectionInfiniteQueryParams<\n T extends ServerCollection,\n Options extends ApiQueryOptions = ApiQueryOptions,\n> {\n collection: T\n options?: Omit<Options, 'page'>\n pageSize?: number\n}\n\n// ============================================================================\n// Shared option types\n// ============================================================================\n\nexport interface QueryOptions<TQueryFnData = unknown, TData = TQueryFnData> {\n enabled?: boolean\n staleTime?: number\n gcTime?: number\n refetchOnWindowFocus?: boolean\n refetchOnMount?: boolean | 'always'\n refetchInterval?: number | false\n retry?: boolean | number\n select?: (data: TQueryFnData) => TData\n placeholderData?:\n | TQueryFnData\n | ((previousData: TData | undefined) => TQueryFnData | undefined)\n initialData?: TQueryFnData | (() => TQueryFnData)\n initialDataUpdatedAt?: number | (() => number | undefined)\n}\n\nexport type SuspenseQueryOptions<\n TQueryFnData = unknown,\n TData = TQueryFnData,\n> = Omit<QueryOptions<TQueryFnData, TData>, 'enabled' | 'placeholderData'>\n\n// placeholderData/initialData omitted: InfiniteData<T> structure is complex to construct\nexport interface InfiniteQueryOptions<\n TQueryFnData = unknown,\n TData = InfiniteData<TQueryFnData>,\n> {\n enabled?: boolean\n staleTime?: number\n gcTime?: number\n refetchOnWindowFocus?: boolean\n refetchOnMount?: boolean | 'always'\n refetchInterval?: number | false\n retry?: boolean | number\n select?: (data: InfiniteData<TQueryFnData>) => TData\n}\n\nexport type SuspenseInfiniteQueryOptions<\n TQueryFnData = unknown,\n TData = InfiniteData<TQueryFnData>,\n> = Omit<InfiniteQueryOptions<TQueryFnData, TData>, 'enabled'>\n\ninterface MutationCallbacks<TData> {\n onSuccess?: (data: TData) => void\n onError?: (error: SDKError) => void\n onSettled?: () => void\n}\n\n// ============================================================================\n// Product detail invalidation\n// ============================================================================\n\nconst PRODUCT_DETAIL_INVALIDATING_COLLECTIONS = new Set([\n 'products',\n 'product-variants',\n 'product-options',\n 'product-option-values',\n 'product-categories',\n 'product-tags',\n 'product-collections',\n 'brands',\n 'brand-logos',\n 'images',\n])\n\n// ============================================================================\n// Collection Hooks Mixin\n// ============================================================================\n\nconst DEFAULT_PAGE_SIZE = 20\n\nexport class CollectionHooks<TCollection extends ServerCollection = PublicCollection> {\n protected queryClient: QueryClient\n protected collectionClient: CollectionClient<TCollection>\n\n constructor(\n queryClient: QueryClient,\n collectionClient: CollectionClient<TCollection>,\n ) {\n this.queryClient = queryClient\n this.collectionClient = collectionClient\n }\n\n // ===== useQuery =====\n useQuery<\n T extends TCollection,\n TData = PayloadFindResponse<CollectionType<T>>,\n >(\n params: CollectionQueryParams<T, CollectionReadOptions<TCollection>>,\n options?: QueryOptions<PayloadFindResponse<CollectionType<T>>, TData>,\n ): UseQueryResult<TData> {\n const { collection, options: queryOptions } = params\n const { placeholderData, ...restOptions } = (options ?? {}) as QueryOptions<\n PayloadFindResponse<CollectionType<T>>,\n TData\n >\n\n return useQueryOriginal({\n queryKey: collectionKeys(collection).list(queryOptions),\n queryFn: async () => {\n return await this.collectionClient\n .from(collection)\n .find(queryOptions)\n },\n ...restOptions,\n // NonFunctionGuard<T> incompatible with generic union types — safe cast\n ...(placeholderData !== undefined && {\n placeholderData: placeholderData as never,\n }),\n })\n }\n\n // ===== useSuspenseQuery =====\n useSuspenseQuery<\n T extends TCollection,\n TData = PayloadFindResponse<CollectionType<T>>,\n >(\n params: CollectionQueryParams<T, CollectionReadOptions<TCollection>>,\n options?: SuspenseQueryOptions<\n PayloadFindResponse<CollectionType<T>>,\n TData\n >,\n ): UseSuspenseQueryResult<TData> {\n const { collection, options: queryOptions } = params\n\n return useSuspenseQueryOriginal({\n queryKey: collectionKeys(collection).list(queryOptions),\n queryFn: async () => {\n return await this.collectionClient\n .from(collection)\n .find(queryOptions)\n },\n ...options,\n })\n }\n\n // ===== useQueryById =====\n useQueryById<T extends TCollection, TData = CollectionType<T>>(\n params: CollectionDetailQueryParams<T, CollectionReadOptions<TCollection>>,\n options?: QueryOptions<CollectionType<T>, TData>,\n ): UseQueryResult<TData> {\n const { collection, id, options: queryOptions } = params\n const { placeholderData, ...restOptions } = (options ?? {}) as QueryOptions<\n CollectionType<T>,\n TData\n >\n\n return useQueryOriginal({\n queryKey: collectionKeys(collection).detail(id, queryOptions),\n queryFn: async () => {\n return await this.collectionClient\n .from(collection)\n .findById(id, queryOptions)\n },\n ...restOptions,\n // NonFunctionGuard<T> incompatible with generic union types — safe cast\n ...(placeholderData !== undefined && {\n placeholderData: placeholderData as never,\n }),\n })\n }\n\n // ===== useSuspenseQueryById =====\n useSuspenseQueryById<T extends TCollection, TData = CollectionType<T>>(\n params: CollectionDetailQueryParams<T, CollectionReadOptions<TCollection>>,\n options?: SuspenseQueryOptions<CollectionType<T>, TData>,\n ): UseSuspenseQueryResult<TData> {\n const { collection, id, options: queryOptions } = params\n\n return useSuspenseQueryOriginal({\n queryKey: collectionKeys(collection).detail(id, queryOptions),\n queryFn: async () => {\n return await this.collectionClient\n .from(collection)\n .findById(id, queryOptions)\n },\n ...options,\n })\n }\n\n // ===== useInfiniteQuery =====\n useInfiniteQuery<\n T extends TCollection,\n TData = InfiniteData<PayloadFindResponse<CollectionType<T>>>,\n >(\n params: CollectionInfiniteQueryParams<\n T,\n CollectionReadOptions<TCollection>\n >,\n options?: InfiniteQueryOptions<\n PayloadFindResponse<CollectionType<T>>,\n TData\n >,\n ): UseInfiniteQueryResult<TData> {\n const { collection, options: queryOptions } = params\n const explicitPageSize = params.pageSize\n const pageSize = explicitPageSize ?? DEFAULT_PAGE_SIZE\n\n return useInfiniteQueryOriginal({\n queryKey: collectionKeys(collection).infinite(\n queryOptions,\n explicitPageSize,\n ),\n queryFn: async ({ pageParam }) => {\n const response = await this.collectionClient\n .from(collection)\n .find({ ...queryOptions, page: pageParam, limit: pageSize })\n return response\n },\n initialPageParam: 1,\n getNextPageParam: (lastPage: PayloadFindResponse<CollectionType<T>>) => {\n return lastPage.hasNextPage ? lastPage.nextPage : undefined\n },\n ...options,\n })\n }\n\n // ===== useSuspenseInfiniteQuery =====\n useSuspenseInfiniteQuery<\n T extends TCollection,\n TData = InfiniteData<PayloadFindResponse<CollectionType<T>>>,\n >(\n params: CollectionInfiniteQueryParams<\n T,\n CollectionReadOptions<TCollection>\n >,\n options?: SuspenseInfiniteQueryOptions<\n PayloadFindResponse<CollectionType<T>>,\n TData\n >,\n ): UseSuspenseInfiniteQueryResult<TData> {\n const { collection, options: queryOptions } = params\n const explicitPageSize = params.pageSize\n const pageSize = explicitPageSize ?? DEFAULT_PAGE_SIZE\n\n return useSuspenseInfiniteQueryOriginal({\n queryKey: collectionKeys(collection).infinite(\n queryOptions,\n explicitPageSize,\n ),\n queryFn: async ({ pageParam }) => {\n const response = await this.collectionClient\n .from(collection)\n .find({ ...queryOptions, page: pageParam, limit: pageSize })\n return response\n },\n initialPageParam: 1,\n getNextPageParam: (lastPage: PayloadFindResponse<CollectionType<T>>) => {\n return lastPage.hasNextPage ? lastPage.nextPage : undefined\n },\n ...options,\n })\n }\n\n // ===== prefetchQuery =====\n async prefetchQuery<T extends TCollection>(\n params: CollectionQueryParams<T, CollectionReadOptions<TCollection>>,\n options?: { staleTime?: number },\n ) {\n const { collection, options: queryOptions } = params\n\n return this.queryClient.prefetchQuery({\n queryKey: collectionKeys(collection).list(queryOptions),\n queryFn: async () => {\n return await this.collectionClient\n .from(collection)\n .find(queryOptions)\n },\n ...options,\n })\n }\n\n // ===== prefetchQueryById =====\n async prefetchQueryById<T extends TCollection>(\n params: CollectionDetailQueryParams<\n T,\n CollectionReadOptions<TCollection>\n >,\n options?: { staleTime?: number },\n ) {\n const { collection, id, options: queryOptions } = params\n\n return this.queryClient.prefetchQuery({\n queryKey: collectionKeys(collection).detail(id, queryOptions),\n queryFn: async () => {\n return await this.collectionClient\n .from(collection)\n .findById(id, queryOptions)\n },\n ...options,\n })\n }\n\n // ===== prefetchInfiniteQuery =====\n async prefetchInfiniteQuery<T extends TCollection>(\n params: CollectionInfiniteQueryParams<\n T,\n CollectionReadOptions<TCollection>\n >,\n options?: { pages?: number; staleTime?: number },\n ) {\n const { collection, options: queryOptions } = params\n const explicitPageSize = params.pageSize\n const pageSize = explicitPageSize ?? DEFAULT_PAGE_SIZE\n\n return this.queryClient.prefetchInfiniteQuery({\n queryKey: collectionKeys(collection).infinite(\n queryOptions,\n explicitPageSize,\n ),\n queryFn: async ({ pageParam }) => {\n const response = await this.collectionClient\n .from(collection)\n .find({ ...queryOptions, page: pageParam, limit: pageSize })\n return response\n },\n initialPageParam: 1,\n getNextPageParam: (lastPage: PayloadFindResponse<CollectionType<T>>) => {\n return lastPage.hasNextPage ? lastPage.nextPage : undefined\n },\n pages: options?.pages ?? 1,\n staleTime: options?.staleTime,\n })\n }\n\n // ===== Mutation Hooks =====\n\n useCreate<T extends TCollection>(\n params: { collection: T },\n options?: MutationCallbacks<PayloadMutationResponse<CollectionType<T>>>,\n ) {\n const { collection } = params\n\n return useMutationOriginal<\n PayloadMutationResponse<CollectionType<T>>,\n SDKError,\n {\n data: Partial<CollectionType<T>>\n file?: File | Blob\n filename?: string\n }\n >({\n mutationFn: async (variables) => {\n return await this.collectionClient\n .from(collection)\n .create(\n variables.data,\n variables.file\n ? { file: variables.file, filename: variables.filename }\n : undefined,\n )\n },\n onSuccess: (data) => {\n this.queryClient.invalidateQueries({\n queryKey: collectionKeys(collection).all,\n })\n if (PRODUCT_DETAIL_INVALIDATING_COLLECTIONS.has(collection)) {\n this.queryClient.invalidateQueries({ queryKey: ['products', 'detail'] })\n }\n options?.onSuccess?.(data)\n },\n onError: options?.onError,\n onSettled: options?.onSettled,\n })\n }\n\n useUpdate<T extends TCollection>(\n params: { collection: T },\n options?: MutationCallbacks<PayloadMutationResponse<CollectionType<T>>>,\n ) {\n const { collection } = params\n\n return useMutationOriginal<\n PayloadMutationResponse<CollectionType<T>>,\n SDKError,\n {\n id: string\n data: Partial<CollectionType<T>>\n file?: File | Blob\n filename?: string\n }\n >({\n mutationFn: async (variables) => {\n return await this.collectionClient\n .from(collection)\n .update(\n variables.id,\n variables.data,\n variables.file\n ? { file: variables.file, filename: variables.filename }\n : undefined,\n )\n },\n onSuccess: (data) => {\n this.queryClient.invalidateQueries({\n queryKey: collectionKeys(collection).all,\n })\n if (PRODUCT_DETAIL_INVALIDATING_COLLECTIONS.has(collection)) {\n this.queryClient.invalidateQueries({ queryKey: ['products', 'detail'] })\n }\n options?.onSuccess?.(data)\n },\n onError: options?.onError,\n onSettled: options?.onSettled,\n })\n }\n\n useRemove<T extends TCollection>(\n params: { collection: T },\n options?: MutationCallbacks<CollectionType<T>>,\n ) {\n const { collection } = params\n\n return useMutationOriginal<CollectionType<T>, SDKError, string>({\n mutationFn: async (id) => {\n return await this.collectionClient.from(collection).remove(id)\n },\n onSuccess: (data) => {\n this.queryClient.invalidateQueries({\n queryKey: collectionKeys(collection).all,\n })\n if (PRODUCT_DETAIL_INVALIDATING_COLLECTIONS.has(collection)) {\n this.queryClient.invalidateQueries({ queryKey: ['products', 'detail'] })\n }\n options?.onSuccess?.(data)\n },\n onError: options?.onError,\n onSettled: options?.onSettled,\n })\n }\n\n // ===== Cache Utilities =====\n\n invalidateQueries<T extends TCollection>(\n collection: T,\n type?: 'list' | 'detail' | 'infinite',\n ) {\n const queryKey = type ? [collection, type] : [collection]\n return this.queryClient.invalidateQueries({ queryKey })\n }\n\n getQueryData<T extends TCollection>(\n collection: T,\n type: 'list',\n options?: ApiQueryOptions,\n ): PayloadFindResponse<CollectionType<T>> | undefined\n getQueryData<T extends TCollection>(\n collection: T,\n type: 'detail',\n id: string,\n options?: ApiQueryOptions,\n ): CollectionType<T> | null | undefined\n getQueryData<T extends TCollection>(\n collection: T,\n type: 'list' | 'detail',\n idOrOptions?: string | ApiQueryOptions,\n options?: ApiQueryOptions,\n ) {\n if (type === 'list') {\n return this.queryClient.getQueryData(\n collectionKeys(collection).list(idOrOptions as ApiQueryOptions),\n )\n }\n return this.queryClient.getQueryData(\n collectionKeys(collection).detail(idOrOptions as string, options),\n )\n }\n\n setQueryData<T extends TCollection>(\n collection: T,\n type: 'list',\n data: PayloadFindResponse<CollectionType<T>>,\n options?: ApiQueryOptions,\n ): void\n setQueryData<T extends TCollection>(\n collection: T,\n type: 'detail',\n id: string,\n data: CollectionType<T> | null,\n options?: ApiQueryOptions,\n ): void\n setQueryData<T extends TCollection>(\n collection: T,\n type: 'list' | 'detail',\n dataOrId: PayloadFindResponse<CollectionType<T>> | string,\n dataOrOptions?: CollectionType<T> | null | ApiQueryOptions,\n options?: ApiQueryOptions,\n ) {\n if (type === 'list') {\n this.queryClient.setQueryData(\n collectionKeys(collection).list(dataOrOptions as ApiQueryOptions),\n dataOrId as PayloadFindResponse<CollectionType<T>>,\n )\n } else {\n this.queryClient.setQueryData(\n collectionKeys(collection).detail(dataOrId as string, options),\n dataOrOptions as CollectionType<T> | null,\n )\n }\n }\n}\n","import {\n QueryClient,\n useQuery as useQueryOriginal,\n useMutation as useMutationOriginal,\n} from '@tanstack/react-query'\nimport type { CustomerAuth } from '../customer/customer-auth'\nimport type {\n CustomerAuthResponse,\n CustomerRefreshResponse,\n CustomerProfile,\n CustomerRegisterData,\n CustomerLoginData,\n UpdateProfileData,\n} from '../customer/types'\nimport { createConfigError, SDKError } from '../internal/errors'\nimport { customerKeys } from './query-keys'\n\n// ============================================================================\n// Mutation helper\n// ============================================================================\n\ninterface MutationCallbacks<TData> {\n onSuccess?: (data: TData) => void\n onError?: (error: SDKError) => void\n onSettled?: () => void\n}\n\nfunction createMutation<TData, TVariables>(\n mutationFn: (variables: TVariables) => Promise<TData>,\n callbacks?: MutationCallbacks<TData>,\n onSuccessExtra?: (data: TData) => void,\n) {\n return useMutationOriginal({\n mutationFn,\n onSuccess: (data) => {\n onSuccessExtra?.(data)\n callbacks?.onSuccess?.(data)\n },\n onError: callbacks?.onError,\n onSettled: callbacks?.onSettled,\n })\n}\n\n// ============================================================================\n// Customer Hooks Mixin\n// ============================================================================\n\nexport class CustomerHooks {\n private queryClient: QueryClient\n private customerAuth?: CustomerAuth\n\n constructor(queryClient: QueryClient, customerAuth?: CustomerAuth) {\n this.queryClient = queryClient\n this.customerAuth = customerAuth\n }\n\n private ensureCustomerAuth(): CustomerAuth {\n if (!this.customerAuth) {\n throw createConfigError(\n 'Customer hooks require Client. Use createClient() instead of createServerClient().',\n )\n }\n return this.customerAuth\n }\n\n private invalidateMe = () => {\n this.queryClient.invalidateQueries({ queryKey: customerKeys.me() })\n }\n\n // ===== useCustomerMe =====\n useCustomerMe(options?: {\n enabled?: boolean\n staleTime?: number\n gcTime?: number\n refetchOnWindowFocus?: boolean\n refetchOnMount?: boolean | 'always'\n refetchInterval?: number | false\n retry?: boolean | number\n }) {\n return useQueryOriginal({\n queryKey: customerKeys.me(),\n queryFn: async () => {\n return await this.ensureCustomerAuth().me()\n },\n ...options,\n enabled:\n (options?.enabled ?? true) && !!this.customerAuth?.isAuthenticated(),\n })\n }\n\n // ===== Mutations =====\n\n useCustomerLogin(options?: MutationCallbacks<CustomerAuthResponse>) {\n return createMutation(\n (data: CustomerLoginData) => this.ensureCustomerAuth().login(data),\n options,\n this.invalidateMe,\n )\n }\n\n useCustomerRegister(\n options?: MutationCallbacks<{ customer: CustomerProfile }>,\n ) {\n return createMutation(\n (data: CustomerRegisterData) => this.ensureCustomerAuth().register(data),\n options,\n )\n }\n\n useCustomerLogout(options?: MutationCallbacks<void>) {\n return useMutationOriginal({\n mutationFn: async () => {\n this.ensureCustomerAuth().logout()\n },\n onSuccess: () => {\n this.queryClient.removeQueries({ queryKey: customerKeys.all })\n options?.onSuccess?.()\n },\n onError: options?.onError,\n onSettled: options?.onSettled,\n })\n }\n\n useCustomerForgotPassword(options?: MutationCallbacks<void>) {\n return createMutation(\n (email: string) =>\n this.ensureCustomerAuth()\n .forgotPassword(email)\n .then(() => {}),\n options,\n )\n }\n\n useCustomerResetPassword(options?: MutationCallbacks<void>) {\n return createMutation(\n (data: { token: string; password: string }) =>\n this.ensureCustomerAuth()\n .resetPassword(data.token, data.password)\n .then(() => {}),\n options,\n )\n }\n\n useCustomerRefreshToken(\n options?: MutationCallbacks<CustomerRefreshResponse>,\n ) {\n return createMutation(\n () => this.ensureCustomerAuth().refreshToken(),\n options,\n this.invalidateMe,\n )\n }\n\n useCustomerUpdateProfile(options?: MutationCallbacks<CustomerProfile>) {\n return createMutation(\n (data: UpdateProfileData) =>\n this.ensureCustomerAuth().updateProfile(data),\n options,\n this.invalidateMe,\n )\n }\n\n useCustomerChangePassword(options?: MutationCallbacks<void>) {\n return createMutation(\n (data: { currentPassword: string; newPassword: string }) =>\n this.ensureCustomerAuth()\n .changePassword(data.currentPassword, data.newPassword)\n .then(() => {}),\n options,\n )\n }\n\n // ===== Customer Cache Utilities =====\n\n invalidateCustomerQueries() {\n return this.queryClient.invalidateQueries({ queryKey: customerKeys.all })\n }\n\n getCustomerData(): CustomerProfile | null | undefined {\n return this.queryClient.getQueryData(customerKeys.me())\n }\n\n setCustomerData(data: CustomerProfile | null) {\n this.queryClient.setQueryData(customerKeys.me(), data)\n }\n}\n","export class SDKError extends Error {\n readonly code: string\n readonly status?: number\n readonly details?: unknown\n readonly userMessage?: string\n readonly suggestion?: string\n readonly requestId?: string\n readonly kind?: 'commerce'\n readonly reason?: CommerceErrorCode | 'unknown_commerce_error'\n readonly rawReason?: string\n readonly retryable?: boolean\n readonly retryAfter?: number\n\n constructor(\n code: string,\n message: string,\n status?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(message)\n this.name = 'SDKError'\n this.code = code\n this.status = status\n this.details = details\n this.userMessage = userMessage\n this.suggestion = suggestion\n this.requestId = requestId\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, new.target)\n }\n }\n\n getUserMessage(): string {\n return this.userMessage || this.message\n }\n\n toJSON() {\n return {\n name: this.name,\n code: this.code,\n message: this.message,\n status: this.status,\n details: this.details,\n userMessage: this.userMessage,\n suggestion: this.suggestion,\n ...(this.requestId !== undefined && { requestId: this.requestId }),\n ...(this.kind !== undefined && { kind: this.kind }),\n ...(this.reason !== undefined && { reason: this.reason }),\n ...(this.rawReason !== undefined && { rawReason: this.rawReason }),\n ...(this.retryable !== undefined && { retryable: this.retryable }),\n ...(this.retryAfter !== undefined && { retryAfter: this.retryAfter }),\n }\n }\n}\n\n/**\n * Canonical Cart/Checkout/PaymentSession error reasons. This public SDK mirror\n * intentionally does not import the private contracts package; parity is\n * enforced by a type test.\n */\nexport const COMMERCE_ERROR_CODES = [\n 'validation_failed',\n 'unauthorized',\n 'forbidden',\n 'token_expired',\n 'origin_not_allowed',\n 'server_credentials_required',\n 'not_found',\n 'conflict',\n 'cart_revision_conflict',\n 'rate_limit_exceeded',\n 'usage_limit_exceeded',\n 'service_unavailable',\n 'idempotency_conflict',\n 'idempotency_in_progress',\n 'cart_not_active',\n 'cart_locked',\n 'cart_empty',\n 'cart_market_unavailable',\n 'cart_market_mismatch',\n 'checkout_not_open',\n 'payment_slot_held',\n 'reservation_expired',\n 'payment_session_not_cancelable',\n 'provider_identity_mismatch',\n 'provider_unavailable',\n 'lock_timeout',\n 'price_changed',\n 'pricing_fact_in_use',\n 'insufficient_stock',\n 'market_not_found',\n 'market_shipping_currency_unsupported',\n 'missing_market_rate',\n 'missing_shipping_amount',\n 'no_enabled_payment_provider',\n 'product_market_unavailable',\n 'unsupported_currency',\n 'missing_price_row',\n 'payment_provider_currency_unsupported',\n 'discount_code_not_found',\n 'discount_not_started',\n 'discount_expired',\n 'discount_usage_limit',\n 'discount_per_customer_limit',\n 'discount_customer_required',\n 'discount_first_order_only',\n 'discount_customer_not_eligible',\n 'discount_customer_excluded',\n 'discount_items_required',\n 'discount_product_not_eligible',\n 'discount_product_excluded',\n 'discount_min_order_amount',\n 'discount_currency_scope_required',\n 'discount_allocation_method_unsupported',\n 'currency_mismatch',\n] as const\n\nexport type CommerceErrorCode = (typeof COMMERCE_ERROR_CODES)[number]\n\ntype CommerceSDKErrorBase = SDKError & {\n readonly kind: 'commerce'\n readonly requestId: string\n readonly retryable: boolean\n readonly retryAfter?: number\n readonly details?: Record<string, unknown>\n}\n\nexport type CommerceSDKError = CommerceSDKErrorBase &\n (\n | { readonly reason: CommerceErrorCode; readonly rawReason?: never }\n | {\n readonly reason: 'unknown_commerce_error'\n readonly rawReason: string\n }\n )\n\nconst COMMERCE_ERROR_CODE_SET: ReadonlySet<string> = new Set(\n COMMERCE_ERROR_CODES,\n)\nconst COMMERCE_ERROR_ENVELOPE_KEYS = new Set([\n 'error',\n 'reason',\n 'requestId',\n 'retryable',\n 'details',\n])\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nexport type CommerceErrorEnvelope = {\n error: string\n reason: string\n requestId: string\n retryable: boolean\n details?: Record<string, unknown>\n}\n\nfunction commerceProtocolError(\n issue: string,\n trustedRequestId?: string,\n): SDKError {\n return createApiError(\n 'Invalid canonical commerce error response.',\n 502,\n { protocol: 'commerce-error-envelope', issue },\n 'The server returned an incompatible commerce error response.',\n 'Verify that the Console commerce contract is deployed before using this SDK version.',\n trustedRequestId,\n )\n}\n\n/** @internal Strictly parse a canonical commerce error without retaining its raw body. */\nexport function parseCommerceErrorEnvelope(\n body: unknown,\n headerRequestId?: string,\n): CommerceErrorEnvelope {\n if (!isPlainRecord(body)) {\n throw commerceProtocolError('expected_object', headerRequestId)\n }\n if (Object.keys(body).some((key) => !COMMERCE_ERROR_ENVELOPE_KEYS.has(key))) {\n throw commerceProtocolError('unexpected_field', headerRequestId)\n }\n if (\n typeof body.error !== 'string' ||\n body.error.length === 0 ||\n typeof body.reason !== 'string' ||\n body.reason.length === 0 ||\n typeof body.requestId !== 'string' ||\n body.requestId.length === 0 ||\n (body.retryable !== undefined && typeof body.retryable !== 'boolean') ||\n (body.details !== undefined && !isPlainRecord(body.details))\n ) {\n throw commerceProtocolError('invalid_field', headerRequestId)\n }\n\n if (headerRequestId && headerRequestId !== body.requestId) {\n throw commerceProtocolError('request_id_mismatch', headerRequestId)\n }\n\n return {\n error: body.error,\n reason: body.reason,\n requestId: body.requestId,\n retryable: body.retryable === true,\n ...(body.details === undefined ? {} : { details: body.details }),\n }\n}\n\n/** @internal Validate and apply the canonical commerce error envelope. */\nexport function enhanceCommerceError(\n error: SDKError,\n body: unknown,\n headerRequestId?: string,\n): SDKError {\n const envelope = parseCommerceErrorEnvelope(body, headerRequestId)\n\n const known = COMMERCE_ERROR_CODE_SET.has(envelope.reason)\n Object.assign(error, {\n code: envelope.reason,\n kind: 'commerce' as const,\n reason: known\n ? (envelope.reason as CommerceErrorCode)\n : 'unknown_commerce_error',\n ...(known ? {} : { rawReason: envelope.reason }),\n requestId: envelope.requestId,\n retryable: envelope.retryable,\n details: envelope.details,\n })\n return error\n}\n\nexport function isCommerceSDKError(error: unknown): error is CommerceSDKError {\n if (!(error instanceof SDKError) || error.kind !== 'commerce') return false\n if (\n typeof error.requestId !== 'string' ||\n typeof error.retryable !== 'boolean' ||\n (error.retryAfter !== undefined &&\n (!Number.isSafeInteger(error.retryAfter) || error.retryAfter < 0)) ||\n typeof error.reason !== 'string'\n ) {\n return false\n }\n return error.reason === 'unknown_commerce_error'\n ? typeof error.rawReason === 'string'\n : COMMERCE_ERROR_CODE_SET.has(error.reason) && error.rawReason === undefined\n}\n\nexport class NetworkError extends SDKError {\n constructor(\n message: string,\n status?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('NETWORK_ERROR', message, status, details, userMessage, suggestion)\n this.name = 'NetworkError'\n }\n}\n\nexport class ValidationError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n status = 400,\n ) {\n super('VALIDATION_ERROR', message, status, details, userMessage, suggestion)\n this.name = 'ValidationError'\n }\n}\n\nexport class ApiError extends SDKError {\n constructor(\n message: string,\n status: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'API_ERROR',\n message,\n status,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'ApiError'\n }\n}\n\nexport class ConfigError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('CONFIG_ERROR', message, undefined, details, userMessage, suggestion)\n this.name = 'ConfigError'\n }\n}\n\nexport class TimeoutError extends SDKError {\n constructor(\n message = 'Request timed out.',\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('TIMEOUT_ERROR', message, 408, details, userMessage, suggestion)\n this.name = 'TimeoutError'\n }\n}\n\nexport class GoneError extends SDKError {\n constructor(\n message = 'The requested resource is no longer available.',\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('GONE_ERROR', message, 410, details, userMessage, suggestion)\n this.name = 'GoneError'\n }\n}\n\nexport class ServiceUnavailableError extends SDKError {\n readonly retryAfter?: number\n\n constructor(\n message = 'Service temporarily unavailable.',\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super(\n 'SERVICE_UNAVAILABLE_ERROR',\n message,\n 503,\n details,\n userMessage,\n suggestion,\n )\n this.name = 'ServiceUnavailableError'\n this.retryAfter = retryAfter\n }\n}\n\nexport class UsageLimitError extends SDKError {\n readonly usage: { limit: number; current: number; remaining: number }\n\n constructor(\n message: string,\n usage: { limit: number; current: number; remaining: number },\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('USAGE_LIMIT_ERROR', message, 429, details, userMessage, suggestion)\n this.name = 'UsageLimitError'\n this.usage = usage\n }\n\n toJSON() {\n return {\n ...super.toJSON(),\n usage: this.usage,\n }\n }\n}\n\nexport class AuthError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'auth_error',\n message,\n 401,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'AuthError'\n }\n}\n\nexport class PermissionError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'permission_error',\n message,\n 403,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'PermissionError'\n }\n}\n\nexport class NotFoundError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'not_found',\n message,\n 404,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'NotFoundError'\n }\n}\n\nexport class ConflictError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super('conflict', message, 409, details, userMessage, suggestion, requestId)\n this.name = 'ConflictError'\n }\n}\n\nexport class RateLimitError extends SDKError {\n readonly retryAfter?: number\n\n constructor(\n message: string,\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'rate_limit_exceeded',\n message,\n 429,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'RateLimitError'\n this.retryAfter = retryAfter\n }\n}\n\nexport function isSDKError(error: unknown): error is SDKError {\n return error instanceof SDKError\n}\n\nexport function isNetworkError(error: unknown): error is NetworkError {\n return error instanceof NetworkError\n}\n\nexport function isValidationError(error: unknown): error is ValidationError {\n if (error instanceof ValidationError) return true\n if (error == null || typeof error !== 'object') return false\n\n const candidate = error as {\n code?: unknown\n name?: unknown\n message?: unknown\n getUserMessage?: unknown\n toJSON?: unknown\n }\n return (\n candidate.name === 'ValidationError' &&\n candidate.code === 'VALIDATION_ERROR' &&\n typeof candidate.message === 'string' &&\n typeof candidate.getUserMessage === 'function' &&\n typeof candidate.toJSON === 'function'\n )\n}\n\nexport function isApiError(error: unknown): error is ApiError {\n return error instanceof ApiError\n}\n\nexport function isConfigError(error: unknown): error is ConfigError {\n return error instanceof ConfigError\n}\n\nexport function isTimeoutError(error: unknown): error is TimeoutError {\n return error instanceof TimeoutError\n}\n\nexport function isGoneError(error: unknown): error is GoneError {\n return error instanceof GoneError\n}\n\nexport function isServiceUnavailableError(\n error: unknown,\n): error is ServiceUnavailableError {\n return error instanceof ServiceUnavailableError\n}\n\nexport function isUsageLimitError(error: unknown): error is UsageLimitError {\n return error instanceof UsageLimitError\n}\n\nexport function isAuthError(error: unknown): error is AuthError {\n return error instanceof AuthError\n}\n\nexport function isPermissionError(error: unknown): error is PermissionError {\n return error instanceof PermissionError\n}\n\nexport function isNotFoundError(error: unknown): error is NotFoundError {\n return error instanceof NotFoundError\n}\n\nexport function isConflictError(error: unknown): error is ConflictError {\n return error instanceof ConflictError\n}\n\nexport function isRateLimitError(error: unknown): error is RateLimitError {\n return error instanceof RateLimitError\n}\n\nexport const createNetworkError = (\n message: string,\n status?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new NetworkError(message, status, details, userMessage, suggestion)\n\nexport const createValidationError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n status?: number,\n) => new ValidationError(message, details, userMessage, suggestion, status)\n\nexport const createApiError = (\n message: string,\n status: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new ApiError(message, status, details, userMessage, suggestion, requestId)\n\nexport const createConfigError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new ConfigError(message, details, userMessage, suggestion)\n\nexport const createTimeoutError = (\n message?: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new TimeoutError(message, details, userMessage, suggestion)\n\nexport const createGoneError = (\n message?: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new GoneError(message, details, userMessage, suggestion)\n\nexport const createServiceUnavailableError = (\n message?: string,\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) =>\n new ServiceUnavailableError(\n message,\n retryAfter,\n details,\n userMessage,\n suggestion,\n )\n\nexport const createUsageLimitError = (\n message: string,\n usage: { limit: number; current: number; remaining: number },\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new UsageLimitError(message, usage, details, userMessage, suggestion)\n\nexport const createAuthError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new AuthError(message, details, userMessage, suggestion, requestId)\n\nexport const createPermissionError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new PermissionError(message, details, userMessage, suggestion, requestId)\n\nexport const createNotFoundError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new NotFoundError(message, details, userMessage, suggestion, requestId)\n\nexport const createConflictError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new ConflictError(message, details, userMessage, suggestion, requestId)\n\nexport const createRateLimitError = (\n message: string,\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) =>\n new RateLimitError(\n message,\n retryAfter,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n","import {\n QueryClient,\n useInfiniteQuery as useInfiniteQueryOriginal,\n useQuery as useQueryOriginal,\n useSuspenseInfiniteQuery as useSuspenseInfiniteQueryOriginal,\n useSuspenseQuery as useSuspenseQueryOriginal,\n} from '@tanstack/react-query'\nimport type {\n InfiniteData,\n UseInfiniteQueryResult,\n UseQueryResult,\n UseSuspenseInfiniteQueryResult,\n UseSuspenseQueryResult,\n} from '@tanstack/react-query'\nimport type {\n ApiQueryOptions,\n PayloadFindResponse,\n PublicCollection,\n ServerCollection,\n} from '../client/types'\nimport type { CustomerAuth } from '../customer/customer-auth'\nimport type { CollectionClient } from '../collection'\nimport type {\n ProductDetailParams,\n ProductDetailCatalogResult,\n ProductListingGroupsCatalogItem,\n ProductListingGroupsItem,\n ProductListingPageBaseParams,\n ProductListingPageCatalogParams,\n ProductListingPageFullParams,\n ProductListingPageParams,\n ProductListingPageResult,\n} from '../api'\nimport {\n CollectionHooks,\n type InfiniteQueryOptions,\n type QueryOptions,\n type SuspenseInfiniteQueryOptions,\n type SuspenseQueryOptions,\n} from './collection-hooks'\nimport { CustomerHooks } from './customer-hooks'\nimport { createConfigError } from '../internal/errors'\nimport { listingPageSearchParams } from '../internal/utils/query-string'\nimport {\n COMMERCE_ENDPOINT_OPERATIONS,\n resolveOperationPath,\n} from '../api/endpoints'\nimport type { CommerceEndpointDescriptor } from '../api/endpoints'\nimport {\n canonicalProductListingGroupsQueryOptions,\n productKeys,\n} from './query-keys'\n\n// Re-export everything from sub-modules for barrel compatibility\nexport { collectionKeys, customerKeys } from './query-keys'\nexport { productKeys } from './query-keys'\nexport type {\n CollectionQueryParams,\n CollectionDetailQueryParams,\n CollectionInfiniteQueryParams,\n QueryOptions,\n SuspenseQueryOptions,\n InfiniteQueryOptions,\n SuspenseInfiniteQueryOptions,\n} from './collection-hooks'\n\nexport type ProductListingGroupsQueryOptions = Pick<\n ApiQueryOptions,\n 'page' | 'limit' | 'sort' | 'where'\n> & {\n market?: string\n locale?: ProductListingPageParams['locale']\n fallbackLocale?: ProductListingPageParams['fallbackLocale']\n}\n\ntype ProductDetailConvenienceOptions =\n QueryOptions<ProductDetailCatalogResult> & {\n market?: string\n locale?: ProductDetailParams['locale']\n fallbackLocale?: ProductDetailParams['fallbackLocale']\n }\n\nexport type ReadOnlyQueryHooks = Omit<\n QueryHooks<PublicCollection>,\n | 'useCreate'\n | 'useUpdate'\n | 'useRemove'\n | 'useProductListingGroupsQuery'\n | 'useSuspenseProductListingGroupsQuery'\n | 'useInfiniteProductListingGroupsQuery'\n | 'useSuspenseInfiniteProductListingGroupsQuery'\n | 'prefetchProductListingGroupsQuery'\n | 'prefetchInfiniteProductListingGroupsQuery'\n | 'useProductListingPage'\n | 'useSuspenseProductListingPage'\n | 'useInfiniteProductListingPage'\n | 'prefetchProductListingPage'\n | 'prefetchInfiniteProductListingPage'\n> & {\n useProductListingPage<\n TData = ProductListingPageResult<ProductListingGroupsCatalogItem>,\n >(\n params?: ProductListingPageCatalogParams,\n options?: QueryOptions<\n ProductListingPageResult<ProductListingGroupsCatalogItem>,\n TData\n >,\n ): UseQueryResult<TData>\n useSuspenseProductListingPage<\n TData = ProductListingPageResult<ProductListingGroupsCatalogItem>,\n >(\n params?: ProductListingPageCatalogParams,\n options?: SuspenseQueryOptions<\n ProductListingPageResult<ProductListingGroupsCatalogItem>,\n TData\n >,\n ): UseSuspenseQueryResult<TData>\n useInfiniteProductListingPage<\n TData = InfiniteData<\n ProductListingPageResult<ProductListingGroupsCatalogItem>\n >,\n >(\n params?: ProductListingPageCatalogInfiniteParams,\n options?: InfiniteQueryOptions<\n ProductListingPageResult<ProductListingGroupsCatalogItem>,\n TData\n >,\n ): UseInfiniteQueryResult<TData>\n prefetchProductListingPage(\n params?: ProductListingPageCatalogParams,\n options?: { staleTime?: number },\n ): Promise<void>\n prefetchInfiniteProductListingPage(\n params?: ProductListingPageCatalogInfiniteParams,\n options?: { pages?: number; staleTime?: number },\n ): Promise<void>\n}\n\n/**\n * Composes CollectionHooks + CustomerHooks into a single API surface.\n * All methods are delegated; no logic lives here.\n */\ninterface ProductDetailCallable {\n product: {\n detail: (params: ProductDetailParams) => Promise<ProductDetailCatalogResult>\n }\n}\n\ninterface ProductListingPageCatalogCallable {\n product: {\n listingPage: {\n (\n params?: ProductListingPageCatalogParams,\n ): Promise<ProductListingPageResult<ProductListingGroupsCatalogItem>>\n }\n }\n}\n\ninterface ProductListingPageCallable extends ProductListingPageCatalogCallable {\n product: ProductListingPageCatalogCallable['product'] & {\n listingPage: ProductListingPageCatalogCallable['product']['listingPage'] & {\n (\n params: ProductListingPageFullParams,\n ): Promise<ProductListingPageResult<ProductListingGroupsItem>>\n (\n params: ProductListingPageParams,\n ): Promise<\n | ProductListingPageResult<ProductListingGroupsCatalogItem>\n | ProductListingPageResult<ProductListingGroupsItem>\n >\n }\n }\n}\n\ntype ProductCommerceCallable = ProductDetailCallable &\n ProductListingPageCallable\n\ntype ProductListingPageCatalogResult =\n ProductListingPageResult<ProductListingGroupsCatalogItem>\ntype ProductListingPageFullResult =\n ProductListingPageResult<ProductListingGroupsItem>\ntype ProductListingPageUnionResult =\n | ProductListingPageCatalogResult\n | ProductListingPageFullResult\ntype ProductListingPageHookOptions<TData> =\n | QueryOptions<ProductListingPageCatalogResult, TData>\n | QueryOptions<ProductListingPageFullResult, TData>\n | QueryOptions<ProductListingPageUnionResult, TData>\ntype ProductListingPageSuspenseHookOptions<TData> =\n | SuspenseQueryOptions<ProductListingPageCatalogResult, TData>\n | SuspenseQueryOptions<ProductListingPageFullResult, TData>\n | SuspenseQueryOptions<ProductListingPageUnionResult, TData>\n\nexport type ProductListingPageInfiniteParams = Omit<\n ProductListingPageBaseParams,\n 'page' | 'limit'\n> & {\n mode?: ProductListingPageParams['mode']\n pageSize?: number\n}\n\nexport type ProductListingPageCatalogInfiniteParams = Omit<\n ProductListingPageInfiniteParams,\n 'mode'\n> & {\n mode?: 'catalog'\n}\n\ntype ProductMarketContext = {\n market?: string\n}\n\ntype ProductMarketAwareCommerce = {\n getDefaultMarket?: () => string | undefined\n}\n\nfunction normalizeMarket(market?: string): string | undefined {\n const normalized = market?.trim()\n return normalized || undefined\n}\n\nfunction requestCommerceFindEndpoint<T>(\n collectionClient: CollectionClient,\n endpoint: CommerceEndpointDescriptor,\n options?: { data?: unknown; query?: string | URLSearchParams },\n): Promise<PayloadFindResponse<T>> {\n const path = resolveOperationPath(endpoint, { query: options?.query })\n if (endpoint.method === 'get') {\n return collectionClient.requestFindEndpointGet<T>(path)\n }\n if (endpoint.method === 'post') {\n return collectionClient.requestFindEndpoint<T>(path, options?.data)\n }\n throw new TypeError(`Unsupported find endpoint method: ${endpoint.method}`)\n}\n\nfunction withDefaultMarket<T extends { market?: string }>(\n params: T | undefined,\n market?: string,\n): T | undefined {\n const defaultMarket = normalizeMarket(market)\n if (!defaultMarket || normalizeMarket(params?.market)) return params\n return { ...(params ?? ({} as T)), market: defaultMarket }\n}\n\nfunction resolveProductMarket(\n commerceClient: ProductMarketAwareCommerce,\n context?: ProductMarketContext,\n): string | undefined {\n return (\n normalizeMarket(context?.market) ??\n normalizeMarket(commerceClient.getDefaultMarket?.())\n )\n}\n\nfunction splitListingGroupsQueryOptions(\n queryOptions?: ProductListingGroupsQueryOptions,\n) {\n const normalized = canonicalProductListingGroupsQueryOptions(queryOptions)\n if (!normalized) return { market: undefined, options: undefined }\n const { market, ...options } = normalized\n return {\n market,\n options: Object.keys(options).length > 0 ? options : undefined,\n }\n}\n\nfunction fetchProductListingGroupsQuery(\n collectionClient: CollectionClient,\n queryOptions?: ProductListingGroupsQueryOptions,\n) {\n const { market, options } = splitListingGroupsQueryOptions(queryOptions)\n return requestCommerceFindEndpoint<ProductListingGroupsItem>(\n collectionClient,\n COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQuery,\n {\n data: {\n ...(market ? { market } : {}),\n ...(options ? { options } : {}),\n },\n },\n )\n}\n\nfunction fetchProductListingGroupsCatalogQuery(\n collectionClient: CollectionClient,\n queryOptions?: ProductListingGroupsQueryOptions,\n) {\n return requestCommerceFindEndpoint<ProductListingGroupsCatalogItem>(\n collectionClient,\n COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryCatalog,\n { query: listingPageSearchParams(queryOptions) },\n )\n}\n\nexport function productListingPageQueryOptions(\n commerceClient: ProductListingPageCatalogCallable,\n params?: ProductListingPageCatalogParams,\n context?: ProductMarketContext,\n): {\n queryKey: ReturnType<typeof productKeys.listingPage>\n queryFn: () => Promise<\n ProductListingPageResult<ProductListingGroupsCatalogItem>\n >\n}\nexport function productListingPageQueryOptions(\n commerceClient: ProductListingPageCallable,\n params: ProductListingPageFullParams,\n context?: ProductMarketContext,\n): {\n queryKey: ReturnType<typeof productKeys.listingPage>\n queryFn: () => Promise<ProductListingPageResult<ProductListingGroupsItem>>\n}\nexport function productListingPageQueryOptions(\n commerceClient: ProductListingPageCallable,\n params: ProductListingPageParams,\n context?: ProductMarketContext,\n): {\n queryKey: ReturnType<typeof productKeys.listingPage>\n queryFn: () => Promise<\n | ProductListingPageResult<ProductListingGroupsCatalogItem>\n | ProductListingPageResult<ProductListingGroupsItem>\n >\n}\nexport function productListingPageQueryOptions(\n commerceClient:\n | ProductListingPageCatalogCallable\n | ProductListingPageCallable,\n params: ProductListingPageParams = {},\n context?: ProductMarketContext,\n) {\n const effectiveParams =\n withDefaultMarket(\n params,\n resolveProductMarket(\n commerceClient as ProductMarketAwareCommerce,\n context,\n ),\n ) ?? params\n\n return {\n queryKey: productKeys.listingPage(effectiveParams),\n queryFn: () =>\n commerceClient.product.listingPage(\n effectiveParams as ProductListingPageCatalogParams,\n ),\n }\n}\n\nexport function productListingPageInfiniteQueryOptions(\n commerceClient: ProductListingPageCatalogCallable,\n params?: ProductListingPageCatalogInfiniteParams,\n context?: ProductMarketContext,\n): {\n queryKey: ReturnType<typeof productKeys.listingPageInfinite>\n queryFn: (args: {\n pageParam: number\n }) => Promise<ProductListingPageResult<ProductListingGroupsCatalogItem>>\n initialPageParam: number\n getNextPageParam: (\n lastPage: ProductListingPageResult<ProductListingGroupsCatalogItem>,\n ) => number | null | undefined\n}\nexport function productListingPageInfiniteQueryOptions(\n commerceClient: ProductListingPageCallable,\n params?: ProductListingPageInfiniteParams,\n context?: ProductMarketContext,\n): {\n queryKey: ReturnType<typeof productKeys.listingPageInfinite>\n queryFn: (args: {\n pageParam: number\n }) => Promise<\n | ProductListingPageResult<ProductListingGroupsCatalogItem>\n | ProductListingPageResult<ProductListingGroupsItem>\n >\n initialPageParam: number\n getNextPageParam: (\n lastPage: ProductListingPageResult<\n ProductListingGroupsCatalogItem | ProductListingGroupsItem\n >,\n ) => number | null | undefined\n}\nexport function productListingPageInfiniteQueryOptions(\n commerceClient:\n | ProductListingPageCatalogCallable\n | ProductListingPageCallable,\n params: ProductListingPageInfiniteParams = {},\n context?: ProductMarketContext,\n) {\n const {\n pageSize: explicitPageSize,\n page: _page,\n limit: _limit,\n ...pageParams\n } = params as ProductListingPageInfiniteParams & {\n page?: number\n limit?: number\n }\n const pageSize = explicitPageSize ?? 20\n const effectivePageParams =\n withDefaultMarket(\n pageParams,\n resolveProductMarket(\n commerceClient as ProductMarketAwareCommerce,\n context,\n ),\n ) ?? pageParams\n\n return {\n queryKey: productKeys.listingPageInfinite(\n effectivePageParams,\n explicitPageSize,\n ),\n queryFn: ({ pageParam }: { pageParam: number }) =>\n commerceClient.product.listingPage({\n ...effectivePageParams,\n page: pageParam,\n limit: pageSize,\n } as never),\n initialPageParam: 1,\n getNextPageParam: (\n lastPage: ProductListingPageResult<\n ProductListingGroupsCatalogItem | ProductListingGroupsItem\n >,\n ) => (lastPage.hasNextPage ? lastPage.nextPage : undefined),\n }\n}\n\nexport function prefetchProductListingPage(\n queryClient: QueryClient,\n commerceClient: ProductListingPageCatalogCallable,\n params?: ProductListingPageCatalogParams,\n options?: { staleTime?: number },\n context?: ProductMarketContext,\n): Promise<void>\nexport function prefetchProductListingPage(\n queryClient: QueryClient,\n commerceClient: ProductListingPageCallable,\n params: ProductListingPageFullParams,\n options?: { staleTime?: number },\n context?: ProductMarketContext,\n): Promise<void>\nexport function prefetchProductListingPage(\n queryClient: QueryClient,\n commerceClient: ProductListingPageCallable,\n params: ProductListingPageParams,\n options?: { staleTime?: number },\n context?: ProductMarketContext,\n): Promise<void>\nexport function prefetchProductListingPage(\n queryClient: QueryClient,\n commerceClient:\n | ProductListingPageCatalogCallable\n | ProductListingPageCallable,\n params: ProductListingPageParams = {},\n options?: { staleTime?: number },\n context?: ProductMarketContext,\n) {\n return queryClient.prefetchQuery({\n ...productListingPageQueryOptions(\n commerceClient as ProductListingPageCallable,\n params,\n context,\n ),\n ...options,\n })\n}\n\nexport function prefetchInfiniteProductListingPage(\n queryClient: QueryClient,\n commerceClient: ProductListingPageCatalogCallable,\n params?: ProductListingPageCatalogInfiniteParams,\n options?: { pages?: number; staleTime?: number },\n context?: ProductMarketContext,\n): Promise<void>\nexport function prefetchInfiniteProductListingPage(\n queryClient: QueryClient,\n commerceClient: ProductListingPageCallable,\n params?: ProductListingPageInfiniteParams,\n options?: { pages?: number; staleTime?: number },\n context?: ProductMarketContext,\n): Promise<void>\nexport function prefetchInfiniteProductListingPage(\n queryClient: QueryClient,\n commerceClient:\n | ProductListingPageCatalogCallable\n | ProductListingPageCallable,\n params: ProductListingPageInfiniteParams = {},\n options?: { pages?: number; staleTime?: number },\n context?: ProductMarketContext,\n) {\n return queryClient.prefetchInfiniteQuery({\n ...productListingPageInfiniteQueryOptions(\n commerceClient as ProductListingPageCallable,\n params,\n context,\n ),\n pages: options?.pages ?? 1,\n staleTime: options?.staleTime,\n })\n}\n\nexport class QueryHooks<\n TCollection extends ServerCollection = PublicCollection,\n> extends CollectionHooks<TCollection> {\n private _customer: CustomerHooks\n private _commerce?: ProductCommerceCallable\n private readonly market?: string\n\n constructor(\n queryClient: QueryClient,\n collectionClient: CollectionClient<TCollection>,\n customerAuth?: CustomerAuth,\n commerceClient?: ProductCommerceCallable,\n market?: string,\n ) {\n super(queryClient, collectionClient)\n this._customer = new CustomerHooks(queryClient, customerAuth)\n this._commerce = commerceClient\n this.market = normalizeMarket(market)\n }\n\n private ensureCommerce(): ProductCommerceCallable {\n if (!this._commerce) {\n throw createConfigError(\n 'Product listing page hooks require Client or ServerClient. Use createQueryHooks(client) or createServerQueryHooks(server) instead of constructing QueryHooks directly.',\n )\n }\n return this._commerce\n }\n\n private withProductMarket<T extends { market?: string }>(\n params: T | undefined,\n ): T | undefined {\n return withDefaultMarket(params, this.market)\n }\n\n // --- Customer hooks delegation ---\n useCustomerMe: CustomerHooks['useCustomerMe'] = (...args) =>\n this._customer.useCustomerMe(...args)\n useCustomerLogin: CustomerHooks['useCustomerLogin'] = (...args) =>\n this._customer.useCustomerLogin(...args)\n useCustomerRegister: CustomerHooks['useCustomerRegister'] = (...args) =>\n this._customer.useCustomerRegister(...args)\n useCustomerLogout: CustomerHooks['useCustomerLogout'] = (...args) =>\n this._customer.useCustomerLogout(...args)\n useCustomerForgotPassword: CustomerHooks['useCustomerForgotPassword'] = (\n ...args\n ) => this._customer.useCustomerForgotPassword(...args)\n useCustomerResetPassword: CustomerHooks['useCustomerResetPassword'] = (\n ...args\n ) => this._customer.useCustomerResetPassword(...args)\n useCustomerRefreshToken: CustomerHooks['useCustomerRefreshToken'] = (\n ...args\n ) => this._customer.useCustomerRefreshToken(...args)\n useCustomerUpdateProfile: CustomerHooks['useCustomerUpdateProfile'] = (\n ...args\n ) => this._customer.useCustomerUpdateProfile(...args)\n useCustomerChangePassword: CustomerHooks['useCustomerChangePassword'] = (\n ...args\n ) => this._customer.useCustomerChangePassword(...args)\n\n // --- Customer cache delegation ---\n invalidateCustomerQueries: CustomerHooks['invalidateCustomerQueries'] = () =>\n this._customer.invalidateCustomerQueries()\n getCustomerData: CustomerHooks['getCustomerData'] = () =>\n this._customer.getCustomerData()\n setCustomerData: CustomerHooks['setCustomerData'] = (data) =>\n this._customer.setCustomerData(data)\n\n useProductListingGroupsQuery<\n TData = PayloadFindResponse<ProductListingGroupsItem>,\n >(\n params: { options?: ProductListingGroupsQueryOptions },\n options?: QueryOptions<\n PayloadFindResponse<ProductListingGroupsItem>,\n TData\n >,\n ): UseQueryResult<TData> {\n const queryOptions = this.withProductMarket(params.options)\n const { placeholderData, ...restOptions } = (options ?? {}) as QueryOptions<\n PayloadFindResponse<ProductListingGroupsItem>,\n TData\n >\n\n return useQueryOriginal({\n queryKey: productKeys.listingGroups(queryOptions),\n queryFn: async () =>\n fetchProductListingGroupsQuery(this.collectionClient, queryOptions),\n ...restOptions,\n ...(placeholderData !== undefined && {\n placeholderData: placeholderData as never,\n }),\n })\n }\n\n useProductListingGroupsCatalogQuery<\n TData = PayloadFindResponse<ProductListingGroupsCatalogItem>,\n >(\n params: { options?: ProductListingGroupsQueryOptions },\n options?: QueryOptions<\n PayloadFindResponse<ProductListingGroupsCatalogItem>,\n TData\n >,\n ): UseQueryResult<TData> {\n const queryOptions = this.withProductMarket(params.options)\n const { placeholderData, ...restOptions } = (options ?? {}) as QueryOptions<\n PayloadFindResponse<ProductListingGroupsCatalogItem>,\n TData\n >\n\n return useQueryOriginal({\n queryKey: productKeys.listingGroupsCatalog(queryOptions),\n queryFn: async () =>\n fetchProductListingGroupsCatalogQuery(\n this.collectionClient,\n queryOptions,\n ),\n ...restOptions,\n ...(placeholderData !== undefined && {\n placeholderData: placeholderData as never,\n }),\n })\n }\n\n useSuspenseProductListingGroupsQuery<\n TData = PayloadFindResponse<ProductListingGroupsItem>,\n >(\n params: { options?: ProductListingGroupsQueryOptions },\n options?: SuspenseQueryOptions<\n PayloadFindResponse<ProductListingGroupsItem>,\n TData\n >,\n ): UseSuspenseQueryResult<TData> {\n const queryOptions = this.withProductMarket(params.options)\n\n return useSuspenseQueryOriginal({\n queryKey: productKeys.listingGroups(queryOptions),\n queryFn: async () =>\n fetchProductListingGroupsQuery(this.collectionClient, queryOptions),\n ...options,\n })\n }\n\n useSuspenseProductListingGroupsCatalogQuery<\n TData = PayloadFindResponse<ProductListingGroupsCatalogItem>,\n >(\n params: { options?: ProductListingGroupsQueryOptions },\n options?: SuspenseQueryOptions<\n PayloadFindResponse<ProductListingGroupsCatalogItem>,\n TData\n >,\n ): UseSuspenseQueryResult<TData> {\n const queryOptions = this.withProductMarket(params.options)\n\n return useSuspenseQueryOriginal({\n queryKey: productKeys.listingGroupsCatalog(queryOptions),\n queryFn: async () =>\n fetchProductListingGroupsCatalogQuery(\n this.collectionClient,\n queryOptions,\n ),\n ...options,\n })\n }\n\n useInfiniteProductListingGroupsQuery<\n TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>,\n >(\n params: {\n options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>\n pageSize?: number\n },\n options?: InfiniteQueryOptions<\n PayloadFindResponse<ProductListingGroupsItem>,\n TData\n >,\n ): UseInfiniteQueryResult<TData> {\n const queryOptions = this.withProductMarket(params.options)\n const explicitPageSize = params.pageSize\n const pageSize = explicitPageSize ?? 20\n\n return useInfiniteQueryOriginal({\n queryKey: productKeys.listingGroupsInfinite(\n queryOptions,\n explicitPageSize,\n ),\n queryFn: async ({ pageParam }) =>\n fetchProductListingGroupsQuery(this.collectionClient, {\n ...queryOptions,\n page: pageParam,\n limit: pageSize,\n }),\n initialPageParam: 1,\n getNextPageParam: (\n lastPage: PayloadFindResponse<ProductListingGroupsItem>,\n ) => (lastPage.hasNextPage ? lastPage.nextPage : undefined),\n ...options,\n })\n }\n\n useInfiniteProductListingGroupsCatalogQuery<\n TData = InfiniteData<PayloadFindResponse<ProductListingGroupsCatalogItem>>,\n >(\n params: {\n options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>\n pageSize?: number\n },\n options?: InfiniteQueryOptions<\n PayloadFindResponse<ProductListingGroupsCatalogItem>,\n TData\n >,\n ): UseInfiniteQueryResult<TData> {\n const queryOptions = this.withProductMarket(params.options)\n const explicitPageSize = params.pageSize\n const pageSize = explicitPageSize ?? 20\n\n return useInfiniteQueryOriginal({\n queryKey: productKeys.listingGroupsCatalogInfinite(\n queryOptions,\n explicitPageSize,\n ),\n queryFn: async ({ pageParam }) =>\n fetchProductListingGroupsCatalogQuery(this.collectionClient, {\n ...queryOptions,\n page: pageParam,\n limit: pageSize,\n }),\n initialPageParam: 1,\n getNextPageParam: (\n lastPage: PayloadFindResponse<ProductListingGroupsCatalogItem>,\n ) => (lastPage.hasNextPage ? lastPage.nextPage : undefined),\n ...options,\n })\n }\n\n useSuspenseInfiniteProductListingGroupsQuery<\n TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>,\n >(\n params: {\n options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>\n pageSize?: number\n },\n options?: SuspenseInfiniteQueryOptions<\n PayloadFindResponse<ProductListingGroupsItem>,\n TData\n >,\n ): UseSuspenseInfiniteQueryResult<TData> {\n const queryOptions = this.withProductMarket(params.options)\n const explicitPageSize = params.pageSize\n const pageSize = explicitPageSize ?? 20\n\n return useSuspenseInfiniteQueryOriginal({\n queryKey: productKeys.listingGroupsInfinite(\n queryOptions,\n explicitPageSize,\n ),\n queryFn: async ({ pageParam }) =>\n fetchProductListingGroupsQuery(this.collectionClient, {\n ...queryOptions,\n page: pageParam,\n limit: pageSize,\n }),\n initialPageParam: 1,\n getNextPageParam: (\n lastPage: PayloadFindResponse<ProductListingGroupsItem>,\n ) => (lastPage.hasNextPage ? lastPage.nextPage : undefined),\n ...options,\n })\n }\n\n useSuspenseInfiniteProductListingGroupsCatalogQuery<\n TData = InfiniteData<PayloadFindResponse<ProductListingGroupsCatalogItem>>,\n >(\n params: {\n options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>\n pageSize?: number\n },\n options?: SuspenseInfiniteQueryOptions<\n PayloadFindResponse<ProductListingGroupsCatalogItem>,\n TData\n >,\n ): UseSuspenseInfiniteQueryResult<TData> {\n const queryOptions = this.withProductMarket(params.options)\n const explicitPageSize = params.pageSize\n const pageSize = explicitPageSize ?? 20\n\n return useSuspenseInfiniteQueryOriginal({\n queryKey: productKeys.listingGroupsCatalogInfinite(\n queryOptions,\n explicitPageSize,\n ),\n queryFn: async ({ pageParam }) =>\n fetchProductListingGroupsCatalogQuery(this.collectionClient, {\n ...queryOptions,\n page: pageParam,\n limit: pageSize,\n }),\n initialPageParam: 1,\n getNextPageParam: (\n lastPage: PayloadFindResponse<ProductListingGroupsCatalogItem>,\n ) => (lastPage.hasNextPage ? lastPage.nextPage : undefined),\n ...options,\n })\n }\n\n async prefetchProductListingGroupsQuery(\n params: { options?: ProductListingGroupsQueryOptions },\n options?: { staleTime?: number },\n ) {\n const queryOptions = this.withProductMarket(params.options)\n\n return this.queryClient.prefetchQuery({\n queryKey: productKeys.listingGroups(queryOptions),\n queryFn: async () =>\n fetchProductListingGroupsQuery(this.collectionClient, queryOptions),\n ...options,\n })\n }\n\n async prefetchProductListingGroupsCatalogQuery(\n params: { options?: ProductListingGroupsQueryOptions },\n options?: { staleTime?: number },\n ) {\n const queryOptions = this.withProductMarket(params.options)\n\n return this.queryClient.prefetchQuery({\n queryKey: productKeys.listingGroupsCatalog(queryOptions),\n queryFn: async () =>\n fetchProductListingGroupsCatalogQuery(\n this.collectionClient,\n queryOptions,\n ),\n ...options,\n })\n }\n\n async prefetchInfiniteProductListingGroupsQuery(\n params: {\n options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>\n pageSize?: number\n },\n options?: { pages?: number; staleTime?: number },\n ) {\n const queryOptions = this.withProductMarket(params.options)\n const explicitPageSize = params.pageSize\n const pageSize = explicitPageSize ?? 20\n\n return this.queryClient.prefetchInfiniteQuery({\n queryKey: productKeys.listingGroupsInfinite(\n queryOptions,\n explicitPageSize,\n ),\n queryFn: async ({ pageParam }) =>\n fetchProductListingGroupsQuery(this.collectionClient, {\n ...queryOptions,\n page: pageParam,\n limit: pageSize,\n }),\n initialPageParam: 1,\n getNextPageParam: (\n lastPage: PayloadFindResponse<ProductListingGroupsItem>,\n ) => (lastPage.hasNextPage ? lastPage.nextPage : undefined),\n pages: options?.pages ?? 1,\n staleTime: options?.staleTime,\n })\n }\n\n async prefetchInfiniteProductListingGroupsCatalogQuery(\n params: {\n options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>\n pageSize?: number\n },\n options?: { pages?: number; staleTime?: number },\n ) {\n const queryOptions = this.withProductMarket(params.options)\n const explicitPageSize = params.pageSize\n const pageSize = explicitPageSize ?? 20\n\n return this.queryClient.prefetchInfiniteQuery({\n queryKey: productKeys.listingGroupsCatalogInfinite(\n queryOptions,\n explicitPageSize,\n ),\n queryFn: async ({ pageParam }) =>\n fetchProductListingGroupsCatalogQuery(this.collectionClient, {\n ...queryOptions,\n page: pageParam,\n limit: pageSize,\n }),\n initialPageParam: 1,\n getNextPageParam: (\n lastPage: PayloadFindResponse<ProductListingGroupsCatalogItem>,\n ) => (lastPage.hasNextPage ? lastPage.nextPage : undefined),\n pages: options?.pages ?? 1,\n staleTime: options?.staleTime,\n })\n }\n\n useProductListingPage<\n TData = ProductListingPageResult<ProductListingGroupsCatalogItem>,\n >(\n params?: ProductListingPageCatalogParams,\n options?: QueryOptions<\n ProductListingPageResult<ProductListingGroupsCatalogItem>,\n TData\n >,\n ): UseQueryResult<TData>\n useProductListingPage<\n TData = ProductListingPageResult<ProductListingGroupsItem>,\n >(\n params: ProductListingPageFullParams,\n options?: QueryOptions<\n ProductListingPageResult<ProductListingGroupsItem>,\n TData\n >,\n ): UseQueryResult<TData>\n useProductListingPage<\n TData =\n | ProductListingPageResult<ProductListingGroupsCatalogItem>\n | ProductListingPageResult<ProductListingGroupsItem>,\n >(\n params: ProductListingPageParams,\n options?: QueryOptions<\n | ProductListingPageResult<ProductListingGroupsCatalogItem>\n | ProductListingPageResult<ProductListingGroupsItem>,\n TData\n >,\n ): UseQueryResult<TData>\n useProductListingPage<TData = ProductListingPageUnionResult>(\n params: ProductListingPageParams = {},\n options?: ProductListingPageHookOptions<TData>,\n ): UseQueryResult<TData> {\n const { placeholderData, ...restOptions } = (options ?? {}) as QueryOptions<\n | ProductListingPageResult<ProductListingGroupsCatalogItem>\n | ProductListingPageResult<ProductListingGroupsItem>,\n unknown\n >\n\n return useQueryOriginal({\n ...productListingPageQueryOptions(this.ensureCommerce(), params, {\n market: this.market,\n }),\n ...restOptions,\n ...(placeholderData !== undefined && {\n placeholderData: placeholderData as never,\n }),\n }) as UseQueryResult<TData>\n }\n\n useSuspenseProductListingPage<\n TData = ProductListingPageResult<ProductListingGroupsCatalogItem>,\n >(\n params?: ProductListingPageCatalogParams,\n options?: SuspenseQueryOptions<\n ProductListingPageResult<ProductListingGroupsCatalogItem>,\n TData\n >,\n ): UseSuspenseQueryResult<TData>\n useSuspenseProductListingPage<\n TData = ProductListingPageResult<ProductListingGroupsItem>,\n >(\n params: ProductListingPageFullParams,\n options?: SuspenseQueryOptions<\n ProductListingPageResult<ProductListingGroupsItem>,\n TData\n >,\n ): UseSuspenseQueryResult<TData>\n useSuspenseProductListingPage<\n TData =\n | ProductListingPageResult<ProductListingGroupsCatalogItem>\n | ProductListingPageResult<ProductListingGroupsItem>,\n >(\n params: ProductListingPageParams,\n options?: SuspenseQueryOptions<\n | ProductListingPageResult<ProductListingGroupsCatalogItem>\n | ProductListingPageResult<ProductListingGroupsItem>,\n TData\n >,\n ): UseSuspenseQueryResult<TData>\n useSuspenseProductListingPage<TData = ProductListingPageUnionResult>(\n params: ProductListingPageParams = {},\n options?: ProductListingPageSuspenseHookOptions<TData>,\n ): UseSuspenseQueryResult<TData> {\n const suspenseOptions = options as\n | SuspenseQueryOptions<ProductListingPageUnionResult, TData>\n | undefined\n\n return useSuspenseQueryOriginal({\n ...productListingPageQueryOptions(this.ensureCommerce(), params, {\n market: this.market,\n }),\n ...suspenseOptions,\n }) as UseSuspenseQueryResult<TData>\n }\n\n useInfiniteProductListingPage<\n TData = InfiniteData<\n ProductListingPageResult<\n ProductListingGroupsCatalogItem | ProductListingGroupsItem\n >\n >,\n >(\n params: ProductListingPageInfiniteParams = {},\n options?: InfiniteQueryOptions<\n ProductListingPageResult<\n ProductListingGroupsCatalogItem | ProductListingGroupsItem\n >,\n TData\n >,\n ): UseInfiniteQueryResult<TData> {\n return useInfiniteQueryOriginal({\n ...productListingPageInfiniteQueryOptions(this.ensureCommerce(), params, {\n market: this.market,\n }),\n ...options,\n }) as UseInfiniteQueryResult<TData>\n }\n\n async prefetchProductListingPage(\n params?: ProductListingPageCatalogParams,\n options?: { staleTime?: number },\n ): Promise<void>\n async prefetchProductListingPage(\n params: ProductListingPageFullParams,\n options?: { staleTime?: number },\n ): Promise<void>\n async prefetchProductListingPage(\n params: ProductListingPageParams,\n options?: { staleTime?: number },\n ): Promise<void>\n async prefetchProductListingPage(\n params: ProductListingPageParams = {},\n options?: { staleTime?: number },\n ) {\n return prefetchProductListingPage(\n this.queryClient,\n this.ensureCommerce(),\n params,\n options,\n { market: this.market },\n )\n }\n\n async prefetchInfiniteProductListingPage(\n params: ProductListingPageInfiniteParams = {},\n options?: { pages?: number; staleTime?: number },\n ) {\n return prefetchInfiniteProductListingPage(\n this.queryClient,\n this.ensureCommerce(),\n params,\n options,\n { market: this.market },\n )\n }\n\n useProductDetail(\n params: ProductDetailParams,\n options?: QueryOptions<ProductDetailCatalogResult>,\n ): UseQueryResult<ProductDetailCatalogResult> {\n const discriminator = 'slug' in params ? params.slug : params.id\n const { enabled, ...restOptions } = options ?? {}\n const queryEnabled = enabled !== false && Boolean(discriminator)\n const effectiveParams = this.withProductMarket(params) ?? params\n\n return useQueryOriginal({\n queryKey: productKeys.detail(effectiveParams),\n queryFn: () => this._commerce!.product.detail(effectiveParams),\n enabled: queryEnabled,\n ...restOptions,\n }) as UseQueryResult<ProductDetailCatalogResult>\n }\n\n useProductDetailBySlug(\n slug: string,\n options?: ProductDetailConvenienceOptions,\n ): UseQueryResult<ProductDetailCatalogResult> {\n const { market, locale, fallbackLocale, ...queryOptions } = options ?? {}\n return this.useProductDetail(\n {\n slug,\n ...(market ? { market } : {}),\n ...(locale ? { locale } : {}),\n ...(fallbackLocale !== undefined ? { fallbackLocale } : {}),\n },\n queryOptions,\n )\n }\n\n useProductDetailById(\n id: string,\n options?: ProductDetailConvenienceOptions,\n ): UseQueryResult<ProductDetailCatalogResult> {\n const { market, locale, fallbackLocale, ...queryOptions } = options ?? {}\n return this.useProductDetail(\n {\n id,\n ...(market ? { market } : {}),\n ...(locale ? { locale } : {}),\n ...(fallbackLocale !== undefined ? { fallbackLocale } : {}),\n },\n queryOptions,\n )\n }\n}\n","import type {\n ProductFallbackLocaleOption,\n ProductLocaleOption,\n} from '../../api/product-api'\n\nfunction normalizedMarket(value: string | undefined): string | undefined {\n const market = value?.trim()\n return market || undefined\n}\n\ntype ProductLocaleQueryOptions = {\n locale?: ProductLocaleOption\n fallbackLocale?: ProductFallbackLocaleOption\n}\n\nfunction appendProductLocaleSearchParams(\n search: URLSearchParams,\n options?: ProductLocaleQueryOptions,\n): void {\n if (options?.locale) search.set('locale', options.locale)\n if (options?.fallbackLocale !== undefined) {\n search.set(\n 'fallbackLocale',\n options.fallbackLocale === false ? 'none' : options.fallbackLocale,\n )\n }\n}\n\nexport function productDetailSearchParams(\n params: ({ slug: string } | { id: string }) & {\n market?: string\n } & ProductLocaleQueryOptions,\n): string {\n const search = new URLSearchParams()\n if ('slug' in params) {\n search.set('slug', params.slug)\n } else {\n search.set('id', params.id)\n }\n const market = normalizedMarket(params.market)\n if (market) search.set('market', market)\n appendProductLocaleSearchParams(search, params)\n return search.toString()\n}\n\nexport function listingGroupsSearchParams(\n params: {\n productIds: string[]\n market?: string\n } & ProductLocaleQueryOptions,\n): string {\n const ids = params.productIds.map(encodeURIComponent).join(',')\n const search = new URLSearchParams()\n const market = normalizedMarket(params.market)\n if (market) search.set('market', market)\n appendProductLocaleSearchParams(search, params)\n const query = search.toString()\n return `ids=${ids}${query ? `&${query}` : ''}`\n}\n\ntype ListingGroupsQueryUrlOptions = {\n market?: string\n locale?: ProductLocaleOption\n fallbackLocale?: ProductFallbackLocaleOption\n page?: number\n limit?: number\n sort?: string | string[]\n where?: Record<string, unknown>\n}\n\nfunction appendListingGroupsQuerySearchParams(\n search: URLSearchParams,\n options?: ListingGroupsQueryUrlOptions,\n): void {\n const market = normalizedMarket(options?.market)\n if (market) search.set('market', market)\n appendProductLocaleSearchParams(search, options)\n if (options?.page != null) search.set('page', String(options.page))\n if (options?.limit != null) search.set('limit', String(options.limit))\n if (options?.sort != null) {\n const sort = options.sort\n search.set('sort', Array.isArray(sort) ? sort.join(',') : sort)\n }\n if (options?.where != null) {\n search.set('whereJson', JSON.stringify(options.where))\n }\n}\n\n/** Server-auth GET PLP listing-groups query (full variant stock fields). */\nexport function listingPageSearchParams(\n options?: ListingGroupsQueryUrlOptions,\n): string {\n const search = new URLSearchParams()\n appendListingGroupsQuerySearchParams(search, options)\n return search.toString()\n}\n\nexport function stockSnapshotSearchParams(params: {\n variantIds: string[]\n}): string {\n return `variantIds=${params.variantIds.map(encodeURIComponent).join(',')}`\n}\n","const operationBrand: unique symbol = Symbol('sdk-http-operation')\n\nexport type HttpOperation = {\n readonly [operationBrand]: true\n readonly collection: string | null\n readonly method: 'get' | 'post' | 'patch' | 'delete'\n readonly path: `/${string}`\n}\n\nconst operation = <\n TCollection extends string | null,\n TMethod extends HttpOperation['method'],\n TPath extends `/${string}`,\n>(\n collection: TCollection,\n method: TMethod,\n path: TPath,\n) =>\n Object.freeze({\n [operationBrand]: true,\n collection,\n method,\n path,\n } as const)\n\nexport const COMMERCE_ENDPOINT_OPERATIONS = {\n products: {\n detail: operation('products', 'get', '/detail'),\n detailCatalog: operation('products', 'get', '/detail/catalog'),\n listingGroups: operation('products', 'get', '/listing-groups'),\n listingGroupsCatalog: operation(\n 'products',\n 'get',\n '/listing-groups/catalog',\n ),\n listingGroupsQuery: operation('products', 'post', '/listing-groups/query'),\n listingGroupsQueryGet: operation(\n 'products',\n 'get',\n '/listing-groups/query',\n ),\n listingGroupsQueryCatalog: operation(\n 'products',\n 'get',\n '/listing-groups/query/catalog',\n ),\n stockCheck: operation('products', 'post', '/stock-check'),\n stockSnapshot: operation('products', 'get', '/stock'),\n upsert: operation('products', 'post', '/upsert'),\n },\n orders: {\n create: operation('orders', 'post', '/create'),\n update: operation('orders', 'post', '/update'),\n confirmPayment: operation('orders', 'post', '/confirm-payment'),\n byPayment: operation('orders', 'get', '/by-payment'),\n cancel: operation('orders', 'post', '/cancel'),\n resolveCancelRefund: operation('orders', 'post', '/resolve-cancel-refund'),\n checkout: operation('orders', 'post', '/checkout'),\n createFulfillment: operation('orders', 'post', '/create-fulfillment'),\n updateFulfillment: operation('orders', 'post', '/update-fulfillment'),\n },\n checkouts: {\n detail: operation('checkouts', 'post', '/detail'),\n query: operation('checkouts', 'post', '/query'),\n },\n transactions: {\n update: operation('transactions', 'post', '/update'),\n },\n returns: {\n create: operation('returns', 'post', '/create'),\n update: operation('returns', 'post', '/update'),\n returnRefund: operation('returns', 'post', '/return-refund'),\n },\n fulfillmentOrders: {\n prepare: operation(\n 'fulfillment-orders',\n 'post',\n '/prepare-fulfillment-order',\n ),\n },\n fulfillments: {\n bulkImport: operation('fulfillments', 'post', '/bulk-import'),\n },\n carts: {\n create: operation('carts', 'post', '/create'),\n retrieve: operation('carts', 'post', '/retrieve'),\n mine: operation('carts', 'post', '/mine'),\n merge: operation('carts', 'post', '/merge'),\n addItem: operation('carts', 'post', '/add-item'),\n updateItem: operation('carts', 'post', '/update-item'),\n removeItem: operation('carts', 'post', '/remove-item'),\n updateDiscountCodes: operation('carts', 'post', '/update-discount-codes'),\n updateAttributes: operation('carts', 'post', '/update-attributes'),\n clear: operation('carts', 'post', '/clear'),\n },\n paymentSessions: {\n create: operation('payment-sessions', 'post', '/create'),\n retrieve: operation('payment-sessions', 'post', '/retrieve'),\n cancel: operation('payment-sessions', 'post', '/cancel'),\n server: {\n create: operation('payment-sessions', 'post', '/server/create'),\n retrieve: operation('payment-sessions', 'post', '/server/retrieve'),\n cancel: operation('payment-sessions', 'post', '/server/cancel'),\n confirm: operation('payment-sessions', 'post', '/server/confirm'),\n },\n custom: {\n create: operation('orders', 'post', '/custom-payment-sessions'),\n confirm: operation('orders', 'post', '/custom-payment-sessions/confirm'),\n },\n },\n shippingPolicies: {\n calculate: operation('shipping-policies', 'post', '/calculate'),\n },\n discounts: {\n validate: operation('discounts', 'post', '/validate'),\n },\n} as const\n\nexport const MEMBERSHIP_ENDPOINT_OPERATIONS = {\n subscribe: operation(null, 'post', '/memberships/subscribe'),\n cancel: operation(null, 'post', '/memberships/:id/cancel'),\n me: operation(null, 'get', '/memberships/me'),\n} as const\n\n/** Public, shaped browser reads served by the event-occurrences collection. */\nexport const EVENTS_ENDPOINT_OPERATIONS = {\n occurrences: {\n range: operation('event-occurrences', 'get', '/range'),\n admissionAvailability: operation(\n 'event-occurrences',\n 'get',\n '/admission-availability',\n ),\n },\n} as const\n\nexport function resolveOperationTemplate(descriptor: HttpOperation): string {\n return descriptor.collection\n ? `/api/${descriptor.collection}${descriptor.path}`\n : `/api${descriptor.path}`\n}\n\nexport function resolveOperationPath(\n descriptor: HttpOperation,\n options?: {\n pathParams?: Readonly<Record<string, string>>\n query?: string | URLSearchParams\n },\n): string {\n const path = resolveOperationTemplate(descriptor).replace(\n /:([A-Za-z][A-Za-z0-9_]*)/g,\n (_, key) => {\n const value = options?.pathParams?.[key]\n if (value === undefined) {\n throw new TypeError(`Missing path parameter: ${key}`)\n }\n return encodeURIComponent(value)\n },\n )\n const unresolved = path.match(/:([A-Za-z][A-Za-z0-9_]*)/)\n if (unresolved) {\n throw new TypeError(`Missing path parameter: ${unresolved[1]}`)\n }\n\n const query = options?.query?.toString().replace(/^\\?/, '')\n return query ? `${path}?${query}` : path\n}\n\nexport function resolveOperationMethod(\n descriptor: HttpOperation,\n): Uppercase<HttpOperation['method']> {\n return descriptor.method.toUpperCase() as Uppercase<HttpOperation['method']>\n}\n","/**\n * Single source of truth for the commerce HTTP paths the SDK calls.\n *\n * Console exposes these as `slug + Endpoint.path` on collection configs; the SDK\n * has to hardcode the joined `/api/<slug>/<path>` because it cannot import the\n * Console at build time. To stop a Console path change from silently turning into\n * a runtime 404, non-quarantined values are cross-checked against live Console\n * endpoint registration by `apps/console/tests/unit/sdk/endpoint-parity.test.ts`.\n * That test also records canonical Phase 1 operations whose route is absent or\n * whose same-path legacy handler is not yet contract-compatible; registration\n * alone must never be interpreted as transport parity.\n *\n * Keep this internal — it is the transport contract, not public SDK surface.\n */\ntype CanonicalCommerceEndpointDescriptor = {\n readonly method: 'GET' | 'POST' | 'PATCH' | 'DELETE'\n readonly path: string\n}\n\nexport type CommerceEndpointDescriptor =\n | CanonicalCommerceEndpointDescriptor\n | HttpOperation\n\nconst endpoint = (\n method: CanonicalCommerceEndpointDescriptor['method'],\n path: string,\n): CanonicalCommerceEndpointDescriptor => ({ method, path })\n\nconst sharedEndpoint = (descriptor: HttpOperation): HttpOperation => descriptor\n\nexport function resolveOperationMethod(\n descriptor: CommerceEndpointDescriptor,\n): 'GET' | 'POST' | 'PATCH' | 'DELETE' {\n return 'collection' in descriptor\n ? resolveSharedOperationMethod(descriptor)\n : descriptor.method\n}\n\nexport function resolveOperationPath(\n descriptor: CommerceEndpointDescriptor,\n options?: {\n pathParams?: Readonly<Record<string, string>>\n query?: string | URLSearchParams\n },\n): string {\n if ('collection' in descriptor) {\n return resolveSharedOperationPath(descriptor, options)\n }\n const query = options?.query?.toString().replace(/^\\?/, '')\n return query ? `${descriptor.path}?${query}` : descriptor.path\n}\n\nexport const COMMERCE_ENDPOINTS = {\n products: {\n detail: endpoint('GET', '/api/products/detail'),\n detailCatalog: endpoint('GET', '/api/products/detail/catalog'),\n listingGroups: endpoint('GET', '/api/products/listing-groups'),\n listingGroupsCatalog: endpoint(\n 'GET',\n '/api/products/listing-groups/catalog',\n ),\n listingGroupsQuery: endpoint('GET', '/api/products/listing-groups/query'),\n listingGroupsQueryCatalog: endpoint(\n 'GET',\n '/api/products/listing-groups/query/catalog',\n ),\n stockCheck: endpoint('POST', '/api/products/stock-check'),\n stockSnapshot: endpoint('GET', '/api/products/stock'),\n upsert: endpoint('POST', '/api/products/upsert'),\n },\n orders: {\n update: endpoint('POST', '/api/orders/update'),\n byPayment: endpoint('GET', '/api/orders/by-payment'),\n cancel: endpoint('POST', '/api/orders/cancel'),\n resolveCancelRefund: endpoint('POST', '/api/orders/resolve-cancel-refund'),\n createFulfillment: endpoint('POST', '/api/orders/create-fulfillment'),\n updateFulfillment: endpoint('POST', '/api/orders/update-fulfillment'),\n },\n checkouts: {\n create: endpoint('POST', '/api/orders/checkout'),\n retrieve: endpoint('POST', '/api/checkouts/detail'),\n server: {\n create: endpoint('POST', '/api/orders/checkout'),\n retrieve: endpoint('POST', '/api/checkouts/detail'),\n query: endpoint('POST', '/api/checkouts/query'),\n },\n },\n returns: {\n create: endpoint('POST', '/api/returns/create'),\n update: endpoint('POST', '/api/returns/update'),\n returnRefund: endpoint('POST', '/api/returns/return-refund'),\n },\n fulfillmentOrders: {\n prepare: endpoint(\n 'POST',\n '/api/fulfillment-orders/prepare-fulfillment-order',\n ),\n },\n fulfillments: {\n bulkImport: endpoint('POST', '/api/fulfillments/bulk-import'),\n },\n carts: {\n create: endpoint('POST', '/api/carts/create'),\n retrieve: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.retrieve),\n mine: endpoint('POST', '/api/carts/mine'),\n merge: endpoint('POST', '/api/carts/merge'),\n server: {\n // Server credentials are an authorization lane, not a second Cart\n // transport. These must stay bound to the registered shared operations.\n create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.create),\n retrieve: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.retrieve),\n mine: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.mine),\n merge: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.merge),\n addItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.addItem),\n updateItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.updateItem),\n removeItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.removeItem),\n updateDiscountCodes: sharedEndpoint(\n COMMERCE_ENDPOINT_OPERATIONS.carts.updateDiscountCodes,\n ),\n updateAttributes: sharedEndpoint(\n COMMERCE_ENDPOINT_OPERATIONS.carts.updateAttributes,\n ),\n clear: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.clear),\n },\n addItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.addItem),\n updateItem: endpoint('POST', '/api/carts/update-item'),\n removeItem: endpoint('POST', '/api/carts/remove-item'),\n updateDiscountCodes: endpoint('POST', '/api/carts/update-discount-codes'),\n updateAttributes: endpoint('POST', '/api/carts/update-attributes'),\n clear: endpoint('POST', '/api/carts/clear'),\n },\n paymentSessions: {\n create: endpoint('POST', '/api/payment-sessions/create'),\n retrieve: endpoint('POST', '/api/payment-sessions/retrieve'),\n cancel: endpoint('POST', '/api/payment-sessions/cancel'),\n custom: {\n create: sharedEndpoint(\n COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.custom.create,\n ),\n confirm: sharedEndpoint(\n COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.custom.confirm,\n ),\n },\n server: {\n create: endpoint('POST', '/api/payment-sessions/server/create'),\n retrieve: endpoint('POST', '/api/payment-sessions/server/retrieve'),\n cancel: endpoint('POST', '/api/payment-sessions/server/cancel'),\n confirm: endpoint('POST', '/api/payment-sessions/server/confirm'),\n },\n },\n shippingPolicies: {\n calculate: endpoint('POST', '/api/shipping-policies/calculate'),\n },\n} as const\n\nfunction isCommerceEndpointDescriptor(\n value: unknown,\n): value is CommerceEndpointDescriptor {\n if (!value || typeof value !== 'object') return false\n const candidate = value as Record<string, unknown>\n return (\n typeof candidate.method === 'string' && typeof candidate.path === 'string'\n )\n}\n\nfunction flattenEndpointPaths(value: unknown): string[] {\n if (isCommerceEndpointDescriptor(value)) return [resolveOperationPath(value)]\n if (!value || typeof value !== 'object') return []\n return Object.values(value).flatMap((entry) => flattenEndpointPaths(entry))\n}\n\nfunction flattenEndpointDescriptors(\n value: unknown,\n): CommerceEndpointDescriptor[] {\n if (isCommerceEndpointDescriptor(value)) return [value]\n if (!value || typeof value !== 'object') return []\n return Object.values(value).flatMap((entry) =>\n flattenEndpointDescriptors(entry),\n )\n}\n\n/** Flat list of every commerce path the SDK declares — for the parity guard. */\nexport const COMMERCE_ENDPOINT_PATHS: readonly string[] =\n flattenEndpointPaths(COMMERCE_ENDPOINTS)\n\n/** Method-aware commerce descriptors covered by Console endpoint parity. */\nexport const COMMERCE_ENDPOINT_DESCRIPTORS: readonly CommerceEndpointDescriptor[] =\n flattenEndpointDescriptors(COMMERCE_ENDPOINTS)\n\n/**\n * Single source of truth for the membership HTTP paths the SDK calls.\n *\n * Mirrors `COMMERCE_ENDPOINTS` conventions. The `cancel` and webhook paths\n * are parameterised because they operate on a specific membership document.\n * Keep in sync with the Console collection endpoint registration.\n */\nexport const MEMBERSHIP_ENDPOINTS = {\n subscribe: '/api/memberships/subscribe',\n cancel: (id: string) => `/api/memberships/${id}/cancel` as const,\n me: '/api/memberships/me',\n} as const\n\n/** Flat list of every membership path the SDK declares — for the parity guard. */\nexport const MEMBERSHIP_ENDPOINT_PATHS: readonly string[] = [\n MEMBERSHIP_ENDPOINTS.subscribe,\n MEMBERSHIP_ENDPOINTS.cancel(':id'),\n MEMBERSHIP_ENDPOINTS.me,\n]\nimport {\n COMMERCE_ENDPOINT_OPERATIONS,\n MEMBERSHIP_ENDPOINT_OPERATIONS,\n resolveOperationMethod as resolveSharedOperationMethod,\n resolveOperationPath as resolveSharedOperationPath,\n type HttpOperation,\n} from '@01.software/http-contracts'\n\nexport { COMMERCE_ENDPOINT_OPERATIONS, MEMBERSHIP_ENDPOINT_OPERATIONS }\n","/**\n * Fetch-based SSE connection manager for real-time collection change events.\n * Uses fetch + ReadableStream to support custom auth headers (unlike native EventSource).\n */\n\nexport interface RealtimeEvent {\n collection: string\n operation: string\n id: string | null\n timestamp: string\n}\n\nexport type RealtimeListener = (event: RealtimeEvent) => void\n\nconst INITIAL_RECONNECT_DELAY = 1_000\nconst MAX_RECONNECT_DELAY = 30_000\nconst RECONNECT_BACKOFF_FACTOR = 2\nconst MAX_NO_TOKEN_RETRIES = 5\n\nexport class RealtimeConnection {\n private abortController: AbortController | null = null\n private reconnectAttempt = 0\n private noTokenAttempts = 0\n private reconnectTimer: ReturnType<typeof setTimeout> | null = null\n private listeners = new Set<RealtimeListener>()\n private _connected = false\n\n constructor(\n private baseUrl: string,\n private publishableKey: string,\n private getToken: () => string | null,\n private collections?: string[],\n ) {}\n\n get connected(): boolean {\n return this._connected\n }\n\n addListener(fn: RealtimeListener): () => void {\n this.listeners.add(fn)\n return () => this.listeners.delete(fn)\n }\n\n connect(): void {\n if (this.abortController) return // Already connecting/connected\n\n this.abortController = new AbortController()\n this.startStream(this.abortController.signal)\n }\n\n disconnect(): void {\n this._connected = false\n if (this.reconnectTimer) {\n clearTimeout(this.reconnectTimer)\n this.reconnectTimer = null\n }\n if (this.abortController) {\n this.abortController.abort()\n this.abortController = null\n }\n this.reconnectAttempt = 0\n this.noTokenAttempts = 0\n }\n\n private async startStream(signal: AbortSignal): Promise<void> {\n const token = this.getToken()\n if (!token) {\n this.noTokenAttempts++\n if (this.noTokenAttempts >= MAX_NO_TOKEN_RETRIES) {\n // Stop reconnecting — no token available after multiple attempts\n this._connected = false\n this.abortController = null\n return\n }\n this.scheduleReconnect()\n return\n }\n this.noTokenAttempts = 0\n\n const params = this.collections?.length\n ? `?collections=${this.collections.join(',')}`\n : ''\n const url = `${this.baseUrl}/api/events/stream${params}`\n\n try {\n const response = await fetch(url, {\n headers: {\n 'X-Publishable-Key': this.publishableKey,\n Authorization: `Bearer ${token}`,\n },\n signal,\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n // Token expired — try reconnecting (will get fresh token)\n this.scheduleReconnect()\n return\n }\n throw new Error(`SSE connection failed: ${response.status}`)\n }\n\n if (!response.body) {\n throw new Error('SSE response has no body')\n }\n\n this._connected = true\n this.reconnectAttempt = 0\n\n await this.readStream(response.body, signal)\n } catch {\n if (signal.aborted) return // Intentional disconnect\n this._connected = false\n this.scheduleReconnect()\n }\n }\n\n private async readStream(\n body: ReadableStream<Uint8Array>,\n signal: AbortSignal,\n ): Promise<void> {\n const reader = body.getReader()\n const decoder = new TextDecoder()\n let buffer = ''\n let currentEvent = ''\n let currentData = ''\n\n try {\n while (true) {\n const { done, value } = await reader.read()\n if (done || signal.aborted) break\n\n buffer += decoder.decode(value, { stream: true })\n const lines = buffer.split('\\n')\n buffer = lines.pop() ?? '' // Keep incomplete last line in buffer\n\n for (const line of lines) {\n if (line.startsWith('event: ')) {\n currentEvent = line.slice(7)\n } else if (line.startsWith('data: ')) {\n currentData += (currentData ? '\\n' : '') + line.slice(6)\n } else if (line === '') {\n // Empty line = end of event\n if (currentEvent === 'collection:change' && currentData) {\n try {\n const event: RealtimeEvent = JSON.parse(currentData)\n for (const listener of this.listeners) {\n try {\n listener(event)\n } catch {\n // Listener error — ignore\n }\n }\n } catch {\n // Malformed JSON — ignore\n }\n }\n currentEvent = ''\n currentData = ''\n }\n // Ignore comment lines (: heartbeat)\n }\n }\n } catch {\n // Stream read error\n } finally {\n reader.releaseLock()\n this._connected = false\n if (!signal.aborted) {\n this.scheduleReconnect()\n }\n }\n }\n\n private scheduleReconnect(): void {\n if (this.reconnectTimer) return\n\n const delay = Math.min(\n INITIAL_RECONNECT_DELAY *\n Math.pow(RECONNECT_BACKOFF_FACTOR, this.reconnectAttempt),\n MAX_RECONNECT_DELAY,\n )\n this.reconnectAttempt++\n\n this.reconnectTimer = setTimeout(() => {\n this.reconnectTimer = null\n this.abortController = new AbortController()\n this.startStream(this.abortController.signal)\n }, delay)\n }\n}\n","import type {\n PublicCollection,\n RootClient,\n RootServerClient,\n ServerCollection,\n} from '../client/types'\nimport type { CollectionClient, ServerCollectionClient } from '../collection'\nimport { QueryHooks, type ReadOnlyQueryHooks } from './query-hooks'\nimport { getQueryClient } from './get-query-client'\nimport type { QueryClient } from '@tanstack/react-query'\n\nfunction getClientMarket(client: {\n getConfig?: () => { market?: string | undefined }\n}): string | undefined {\n return client.getConfig?.().market\n}\n\nfunction createReadOnlyQueryHooksFacade(\n hooks: QueryHooks<PublicCollection>,\n): ReadOnlyQueryHooks {\n return {\n useQuery: hooks.useQuery.bind(hooks),\n useSuspenseQuery: hooks.useSuspenseQuery.bind(hooks),\n useQueryById: hooks.useQueryById.bind(hooks),\n useSuspenseQueryById: hooks.useSuspenseQueryById.bind(hooks),\n useInfiniteQuery: hooks.useInfiniteQuery.bind(hooks),\n useSuspenseInfiniteQuery: hooks.useSuspenseInfiniteQuery.bind(hooks),\n prefetchQuery: hooks.prefetchQuery.bind(hooks),\n prefetchQueryById: hooks.prefetchQueryById.bind(hooks),\n prefetchInfiniteQuery: hooks.prefetchInfiniteQuery.bind(hooks),\n invalidateQueries: hooks.invalidateQueries.bind(hooks),\n getQueryData: hooks.getQueryData.bind(hooks),\n setQueryData: hooks.setQueryData.bind(hooks),\n useCustomerMe: hooks.useCustomerMe.bind(hooks),\n useCustomerLogin: hooks.useCustomerLogin.bind(hooks),\n useCustomerRegister: hooks.useCustomerRegister.bind(hooks),\n useCustomerLogout: hooks.useCustomerLogout.bind(hooks),\n useCustomerForgotPassword: hooks.useCustomerForgotPassword.bind(hooks),\n useCustomerResetPassword: hooks.useCustomerResetPassword.bind(hooks),\n useCustomerRefreshToken: hooks.useCustomerRefreshToken.bind(hooks),\n useCustomerUpdateProfile: hooks.useCustomerUpdateProfile.bind(hooks),\n useCustomerChangePassword: hooks.useCustomerChangePassword.bind(hooks),\n invalidateCustomerQueries: hooks.invalidateCustomerQueries.bind(hooks),\n getCustomerData: hooks.getCustomerData.bind(hooks),\n setCustomerData: hooks.setCustomerData.bind(hooks),\n useProductListingGroupsCatalogQuery:\n hooks.useProductListingGroupsCatalogQuery.bind(hooks),\n useSuspenseProductListingGroupsCatalogQuery:\n hooks.useSuspenseProductListingGroupsCatalogQuery.bind(hooks),\n useInfiniteProductListingGroupsCatalogQuery:\n hooks.useInfiniteProductListingGroupsCatalogQuery.bind(hooks),\n useSuspenseInfiniteProductListingGroupsCatalogQuery:\n hooks.useSuspenseInfiniteProductListingGroupsCatalogQuery.bind(hooks),\n prefetchProductListingGroupsCatalogQuery:\n hooks.prefetchProductListingGroupsCatalogQuery.bind(hooks),\n prefetchInfiniteProductListingGroupsCatalogQuery:\n hooks.prefetchInfiniteProductListingGroupsCatalogQuery.bind(hooks),\n useProductListingPage: hooks.useProductListingPage.bind(hooks),\n useSuspenseProductListingPage:\n hooks.useSuspenseProductListingPage.bind(hooks),\n useInfiniteProductListingPage:\n hooks.useInfiniteProductListingPage.bind(hooks),\n prefetchProductListingPage: hooks.prefetchProductListingPage.bind(hooks),\n prefetchInfiniteProductListingPage:\n hooks.prefetchInfiniteProductListingPage.bind(hooks),\n useProductDetail: hooks.useProductDetail.bind(hooks),\n useProductDetailBySlug: hooks.useProductDetailBySlug.bind(hooks),\n useProductDetailById: hooks.useProductDetailById.bind(hooks),\n } as ReadOnlyQueryHooks\n}\n\nexport function createQueryHooks(\n client: RootClient,\n queryClient: QueryClient = getQueryClient(),\n): ReadOnlyQueryHooks {\n const hooks = new QueryHooks<PublicCollection>(\n queryClient,\n client.collections as unknown as CollectionClient<PublicCollection>,\n client.customer.auth,\n client.commerce as never,\n getClientMarket(client),\n )\n\n return createReadOnlyQueryHooksFacade(hooks)\n}\n\nexport function createServerQueryHooks(\n client: RootServerClient,\n queryClient: QueryClient = getQueryClient(),\n): QueryHooks<ServerCollection> {\n return new QueryHooks<ServerCollection>(\n queryClient,\n client.collections as ServerCollectionClient,\n undefined,\n client.commerce,\n getClientMarket(client),\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,yBAIO;AAEP,SAAS,kBAAkB;AACzB,SAAO,IAAI,+BAAY;AAAA,IACrB,gBAAgB;AAAA,MACd,SAAS;AAAA;AAAA;AAAA;AAAA,QAIP,WAAW,OAAO;AAAA,QAClB,sBAAsB;AAAA,MACxB;AAAA,MACA,WAAW;AAAA,QACT,sBAAsB,CAAC,cACrB,gDAA4B,KAAK,KACjC,MAAM,MAAM,WAAW;AAAA,QACzB,oBAAoB,MAAM;AAAA,MAC5B;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEA,IAAI;AACJ,IAAI;AAGG,SAAS,iBAAiB;AAC/B,MAAI,6BAAU;AACZ,WAAO,gBAAgB;AAAA,EACzB;AACA,MAAI,CAAC,oBAAoB;AACvB,yBAAqB,gBAAgB;AAAA,EACvC;AACA,SAAO;AACT;AAEA,IAAM,2BAA2B;AAEjC,SAAS,4BAA4B;AACnC,SAAO,IAAI,+BAAY;AAAA,IACrB,gBAAgB;AAAA,MACd,SAAS;AAAA,QACP,WAAW;AAAA,QACX,sBAAsB;AAAA,MACxB;AAAA,MACA,WAAW;AAAA,QACT,sBAAsB,CAAC,cACrB,gDAA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AAA,IAC7D,+BACE,MAAM,8BAA8B,KAAK,KAAK;AAAA,IAChD,+BACE,MAAM,8BAA8B,KAAK,KAAK;AAAA,IAChD,4BAA4B,MAAM,2BAA2B,KAAK,KAAK;AAAA,IACvE,oCACE,MAAM,mCAAmC,KAAK,KAAK;AAAA,IACrD,kBAAkB,MAAM,iBAAiB,KAAK,KAAK;AAAA,IACnD,wBAAwB,MAAM,uBAAuB,KAAK,KAAK;AAAA,IAC/D,sBAAsB,MAAM,qBAAqB,KAAK,KAAK;AAAA,EAC7D;AACF;AAEO,SAAS,iBACd,QACA,cAA2B,eAAe,GACtB;AACpB,QAAM,QAAQ,IAAI;AAAA,IAChB;AAAA,IACA,OAAO;AAAA,IACP,OAAO,SAAS;AAAA,IAChB,OAAO;AAAA,IACP,gBAAgB,MAAM;AAAA,EACxB;AAEA,SAAO,+BAA+B,KAAK;AAC7C;AAEO,SAAS,uBACd,QACA,cAA2B,eAAe,GACZ;AAC9B,SAAO,IAAI;AAAA,IACT;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA,OAAO;AAAA,IACP,gBAAgB,MAAM;AAAA,EACxB;AACF;","names":["import_react_query","useQueryOriginal","useSuspenseQueryOriginal","useInfiniteQueryOriginal","useSuspenseInfiniteQueryOriginal","useMutationOriginal","import_react_query","useMutationOriginal","useQueryOriginal","import_react_query","resolveOperationPath","endpoint","resolveOperationPath","useQueryOriginal","useSuspenseQueryOriginal","useInfiniteQueryOriginal","useSuspenseInfiniteQueryOriginal"]}
1
+ {"version":3,"sources":["../src/query.ts","../src/core/query/get-query-client.ts","../src/core/query/query-keys.ts","../src/core/query/collection-hooks.ts","../src/core/query/customer-hooks.ts","../src/core/errors.ts","../src/core/query/query-hooks.ts","../src/core/internal/utils/query-string.ts","../../../internal/http-contracts/src/index.ts","../src/core/api/endpoints.ts","../src/core/query/realtime.ts","../src/core/query/query-client.ts"],"sourcesContent":["export * from './core/query'\n","import {\n isServer,\n QueryClient,\n defaultShouldDehydrateQuery,\n} from '@tanstack/react-query'\n\nfunction makeQueryClient() {\n return new QueryClient({\n defaultOptions: {\n queries: {\n // Infinite staleTime: server-fetched data persists until explicitly invalidated.\n // For browser clients needing fresher data, override per-query:\n // useQuery({ ..., staleTime: 5 * 60 * 1000 })\n staleTime: Number.POSITIVE_INFINITY,\n refetchOnWindowFocus: false,\n },\n dehydrate: {\n shouldDehydrateQuery: (query) =>\n defaultShouldDehydrateQuery(query) ||\n query.state.status === 'pending',\n shouldRedactErrors: () => false,\n },\n },\n })\n}\n\nlet browserQueryClient: QueryClient | undefined\nlet browserStorefrontQueryClient: QueryClient | undefined\n\n/** Default React Query client (SSR hydration-friendly: infinite staleTime). */\nexport function getQueryClient() {\n if (isServer) {\n return makeQueryClient()\n }\n if (!browserQueryClient) {\n browserQueryClient = makeQueryClient()\n }\n return browserQueryClient\n}\n\nconst STOREFRONT_STALE_TIME_MS = 60_000\n\nfunction makeStorefrontQueryClient() {\n return new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: STOREFRONT_STALE_TIME_MS,\n refetchOnWindowFocus: false,\n },\n dehydrate: {\n shouldDehydrateQuery: (query) =>\n defaultShouldDehydrateQuery(query) ||\n query.state.status === 'pending',\n shouldRedactErrors: () => false,\n },\n },\n })\n}\n\n/**\n * Browser storefront client: refetches catalog data after ~1 minute instead of\n * keeping SSR data fresh forever. Use with `createQueryHooks(client, queryClient)`.\n */\nexport function getStorefrontQueryClient() {\n if (isServer) {\n return makeStorefrontQueryClient()\n }\n if (!browserStorefrontQueryClient) {\n browserStorefrontQueryClient = makeStorefrontQueryClient()\n }\n return browserStorefrontQueryClient\n}\n","import type { ServerCollection, ApiQueryOptions } from '../client/types'\nimport type { ProductDetailParams, ProductListingPageParams } from '../api'\nimport type { ProductListingGroupsQueryOptions } from './query-hooks'\n\ntype ProductListingPageKeyParams = {\n mode: 'catalog' | 'full'\n market?: string\n locale?: ProductListingPageParams['locale']\n fallbackLocale?: ProductListingPageParams['fallbackLocale']\n page?: number\n limit?: number\n search?: string\n sort?: ProductListingPageParams['sort']\n filters?: NonNullable<ProductListingPageParams['filters']>\n basePath?: string\n trailingSlash?: boolean\n emit?: ProductListingPageParams['emit']\n preferCompleteVariantFromHint?: ProductListingPageParams['preferCompleteVariantFromHint']\n}\n\nfunction nonEmpty(values: string[] | undefined): string[] | undefined {\n return values?.length ? values : undefined\n}\n\nfunction canonicalProductListingPageParams(\n params: ProductListingPageParams = {},\n limit?: number,\n): ProductListingPageKeyParams {\n const filters = params.filters\n const canonicalFilters: NonNullable<ProductListingPageParams['filters']> = {}\n const ids = nonEmpty(filters?.ids)\n if (ids) canonicalFilters.ids = ids\n const slugs = nonEmpty(filters?.slugs)\n if (slugs) canonicalFilters.slugs = slugs\n const handles = nonEmpty(filters?.handles)\n if (handles) canonicalFilters.handles = handles\n const categoryIds = nonEmpty(filters?.categoryIds)\n if (categoryIds) canonicalFilters.categoryIds = categoryIds\n const tagIds = nonEmpty(filters?.tagIds)\n if (tagIds) canonicalFilters.tagIds = tagIds\n if (filters?.price?.min != null || filters?.price?.max != null) {\n canonicalFilters.price = {\n ...(filters.price.min != null && { min: filters.price.min }),\n ...(filters.price.max != null && { max: filters.price.max }),\n }\n }\n if (filters?.availableForSale != null) {\n canonicalFilters.availableForSale = filters.availableForSale\n }\n\n const search = params.search?.trim()\n const market = params.market?.trim()\n return {\n mode: params.mode ?? 'catalog',\n ...(market && { market }),\n ...(params.locale != null && { locale: params.locale }),\n ...(params.fallbackLocale !== undefined && {\n fallbackLocale: params.fallbackLocale,\n }),\n ...(params.page != null && { page: params.page }),\n ...(limit != null\n ? { limit }\n : params.limit != null\n ? { limit: params.limit }\n : {}),\n ...(search && { search }),\n ...(params.sort != null && { sort: params.sort }),\n ...(Object.keys(canonicalFilters).length > 0 && {\n filters: canonicalFilters,\n }),\n ...(params.basePath != null && { basePath: params.basePath }),\n ...(params.trailingSlash != null && {\n trailingSlash: params.trailingSlash,\n }),\n ...(params.emit != null && { emit: params.emit }),\n ...(params.preferCompleteVariantFromHint != null && {\n preferCompleteVariantFromHint: params.preferCompleteVariantFromHint,\n }),\n }\n}\n\nfunction canonicalMarket(value: string | undefined): string | undefined {\n const market = value?.trim()\n return market || undefined\n}\n\nexport function canonicalProductListingGroupsQueryOptions(\n options?: ProductListingGroupsQueryOptions,\n limit?: number,\n): ProductListingGroupsQueryOptions | undefined {\n const { market: rawMarket, ...rest } = options ?? {}\n const market = canonicalMarket(rawMarket)\n const canonical: ProductListingGroupsQueryOptions = {\n ...rest,\n ...(limit !== undefined ? { limit } : {}),\n ...(market ? { market } : {}),\n }\n return Object.keys(canonical).length > 0 ? canonical : undefined\n}\n\nfunction canonicalProductDetailParams(\n params: ProductDetailParams,\n): ProductDetailParams {\n const market = params.market?.trim()\n const localeOptions = {\n ...(params.locale != null && { locale: params.locale }),\n ...(params.fallbackLocale !== undefined && {\n fallbackLocale: params.fallbackLocale,\n }),\n }\n if ('slug' in params) {\n return {\n slug: params.slug,\n ...(market ? { market } : {}),\n ...localeOptions,\n }\n }\n return {\n id: params.id,\n ...(market ? { market } : {}),\n ...localeOptions,\n }\n}\n\nexport function collectionKeys<T extends ServerCollection>(collection: T) {\n return {\n all: [collection] as const,\n lists: () => [collection, 'list'] as const,\n list: (options?: ApiQueryOptions) => [collection, 'list', options] as const,\n details: () => [collection, 'detail'] as const,\n detail: (id: string, options?: ApiQueryOptions) =>\n [collection, 'detail', id, options] as const,\n infinites: () => [collection, 'infinite'] as const,\n infinite: (options?: Omit<ApiQueryOptions, 'page'>, pageSize?: number) =>\n [\n collection,\n 'infinite',\n pageSize === undefined ? options : { ...options, limit: pageSize },\n ] as const,\n }\n}\n\nexport const customerKeys = {\n all: ['customer'] as const,\n me: () => ['customer', 'me'] as const,\n}\n\nexport const productKeys = {\n listingGroups: (options?: ProductListingGroupsQueryOptions) =>\n [\n 'products',\n 'listing-groups',\n 'list',\n canonicalProductListingGroupsQueryOptions(options),\n ] as const,\n listingGroupsCatalog: (options?: ProductListingGroupsQueryOptions) =>\n [\n 'products',\n 'listing-groups',\n 'catalog',\n canonicalProductListingGroupsQueryOptions(options),\n ] as const,\n listingGroupsInfinite: (\n options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>,\n pageSize?: number,\n ) =>\n [\n 'products',\n 'listing-groups',\n 'infinite',\n canonicalProductListingGroupsQueryOptions(options, pageSize),\n ] as const,\n listingGroupsCatalogInfinite: (\n options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>,\n pageSize?: number,\n ) =>\n [\n 'products',\n 'listing-groups',\n 'catalog',\n 'infinite',\n canonicalProductListingGroupsQueryOptions(options, pageSize),\n ] as const,\n listingPage: (params?: ProductListingPageParams) =>\n [\n 'products',\n 'listing-page',\n canonicalProductListingPageParams(params),\n ] as const,\n listingPageInfinite: (\n params?: Omit<ProductListingPageParams, 'page' | 'limit'>,\n pageSize?: number,\n ) =>\n [\n 'products',\n 'listing-page',\n 'infinite',\n canonicalProductListingPageParams(\n params as ProductListingPageParams | undefined,\n pageSize,\n ),\n ] as const,\n detail: (params: ProductDetailParams) =>\n ['products', 'detail', canonicalProductDetailParams(params)] as const,\n detailAll: () => ['products', 'detail'] as const,\n}\n","import {\n QueryClient,\n useQuery as useQueryOriginal,\n useSuspenseQuery as useSuspenseQueryOriginal,\n useInfiniteQuery as useInfiniteQueryOriginal,\n useSuspenseInfiniteQuery as useSuspenseInfiniteQueryOriginal,\n useMutation as useMutationOriginal,\n} from '@tanstack/react-query'\nimport type {\n InfiniteData,\n UseInfiniteQueryResult,\n UseQueryResult,\n UseSuspenseInfiniteQueryResult,\n UseSuspenseQueryResult,\n} from '@tanstack/react-query'\nimport type {\n PublicCollection,\n ServerCollection,\n ApiQueryOptions,\n PublicReadQueryOptions,\n PayloadFindResponse,\n PayloadMutationResponse,\n} from '../client/types'\nimport { type CollectionClient, type CollectionType } from '../collection'\nimport { SDKError } from '../internal/errors'\nimport { collectionKeys } from './query-keys'\n\n// ============================================================================\n// Query Params Types\n// ============================================================================\n\ntype CollectionReadOptions<TCollection extends ServerCollection> =\n [TCollection] extends [PublicCollection]\n ? PublicReadQueryOptions\n : ApiQueryOptions\n\nexport interface CollectionQueryParams<\n T extends ServerCollection,\n Options extends ApiQueryOptions = ApiQueryOptions,\n> {\n collection: T\n options?: Options\n}\n\nexport interface CollectionDetailQueryParams<\n T extends ServerCollection,\n Options extends ApiQueryOptions = ApiQueryOptions,\n> {\n collection: T\n id: string\n options?: Options\n}\n\nexport interface CollectionInfiniteQueryParams<\n T extends ServerCollection,\n Options extends ApiQueryOptions = ApiQueryOptions,\n> {\n collection: T\n options?: Omit<Options, 'page'>\n pageSize?: number\n}\n\n// ============================================================================\n// Shared option types\n// ============================================================================\n\nexport interface QueryOptions<TQueryFnData = unknown, TData = TQueryFnData> {\n enabled?: boolean\n staleTime?: number\n gcTime?: number\n refetchOnWindowFocus?: boolean\n refetchOnMount?: boolean | 'always'\n refetchInterval?: number | false\n retry?: boolean | number\n select?: (data: TQueryFnData) => TData\n placeholderData?:\n | TQueryFnData\n | ((previousData: TData | undefined) => TQueryFnData | undefined)\n initialData?: TQueryFnData | (() => TQueryFnData)\n initialDataUpdatedAt?: number | (() => number | undefined)\n}\n\nexport type SuspenseQueryOptions<\n TQueryFnData = unknown,\n TData = TQueryFnData,\n> = Omit<QueryOptions<TQueryFnData, TData>, 'enabled' | 'placeholderData'>\n\n// placeholderData/initialData omitted: InfiniteData<T> structure is complex to construct\nexport interface InfiniteQueryOptions<\n TQueryFnData = unknown,\n TData = InfiniteData<TQueryFnData>,\n> {\n enabled?: boolean\n staleTime?: number\n gcTime?: number\n refetchOnWindowFocus?: boolean\n refetchOnMount?: boolean | 'always'\n refetchInterval?: number | false\n retry?: boolean | number\n select?: (data: InfiniteData<TQueryFnData>) => TData\n}\n\nexport type SuspenseInfiniteQueryOptions<\n TQueryFnData = unknown,\n TData = InfiniteData<TQueryFnData>,\n> = Omit<InfiniteQueryOptions<TQueryFnData, TData>, 'enabled'>\n\ninterface MutationCallbacks<TData> {\n onSuccess?: (data: TData) => void\n onError?: (error: SDKError) => void\n onSettled?: () => void\n}\n\n// ============================================================================\n// Product detail invalidation\n// ============================================================================\n\nconst PRODUCT_DETAIL_INVALIDATING_COLLECTIONS = new Set([\n 'products',\n 'product-variants',\n 'product-options',\n 'product-option-values',\n 'product-categories',\n 'product-tags',\n 'product-collections',\n 'brands',\n 'brand-logos',\n 'images',\n])\n\n// ============================================================================\n// Collection Hooks Mixin\n// ============================================================================\n\nconst DEFAULT_PAGE_SIZE = 20\n\nexport class CollectionHooks<TCollection extends ServerCollection = PublicCollection> {\n protected queryClient: QueryClient\n protected collectionClient: CollectionClient<TCollection>\n\n constructor(\n queryClient: QueryClient,\n collectionClient: CollectionClient<TCollection>,\n ) {\n this.queryClient = queryClient\n this.collectionClient = collectionClient\n }\n\n // ===== useQuery =====\n useQuery<\n T extends TCollection,\n TData = PayloadFindResponse<CollectionType<T>>,\n >(\n params: CollectionQueryParams<T, CollectionReadOptions<TCollection>>,\n options?: QueryOptions<PayloadFindResponse<CollectionType<T>>, TData>,\n ): UseQueryResult<TData> {\n const { collection, options: queryOptions } = params\n const { placeholderData, ...restOptions } = (options ?? {}) as QueryOptions<\n PayloadFindResponse<CollectionType<T>>,\n TData\n >\n\n return useQueryOriginal({\n queryKey: collectionKeys(collection).list(queryOptions),\n queryFn: async () => {\n return await this.collectionClient\n .from(collection)\n .find(queryOptions)\n },\n ...restOptions,\n // NonFunctionGuard<T> incompatible with generic union types — safe cast\n ...(placeholderData !== undefined && {\n placeholderData: placeholderData as never,\n }),\n })\n }\n\n // ===== useSuspenseQuery =====\n useSuspenseQuery<\n T extends TCollection,\n TData = PayloadFindResponse<CollectionType<T>>,\n >(\n params: CollectionQueryParams<T, CollectionReadOptions<TCollection>>,\n options?: SuspenseQueryOptions<\n PayloadFindResponse<CollectionType<T>>,\n TData\n >,\n ): UseSuspenseQueryResult<TData> {\n const { collection, options: queryOptions } = params\n\n return useSuspenseQueryOriginal({\n queryKey: collectionKeys(collection).list(queryOptions),\n queryFn: async () => {\n return await this.collectionClient\n .from(collection)\n .find(queryOptions)\n },\n ...options,\n })\n }\n\n // ===== useQueryById =====\n useQueryById<T extends TCollection, TData = CollectionType<T>>(\n params: CollectionDetailQueryParams<T, CollectionReadOptions<TCollection>>,\n options?: QueryOptions<CollectionType<T>, TData>,\n ): UseQueryResult<TData> {\n const { collection, id, options: queryOptions } = params\n const { placeholderData, ...restOptions } = (options ?? {}) as QueryOptions<\n CollectionType<T>,\n TData\n >\n\n return useQueryOriginal({\n queryKey: collectionKeys(collection).detail(id, queryOptions),\n queryFn: async () => {\n return await this.collectionClient\n .from(collection)\n .findById(id, queryOptions)\n },\n ...restOptions,\n // NonFunctionGuard<T> incompatible with generic union types — safe cast\n ...(placeholderData !== undefined && {\n placeholderData: placeholderData as never,\n }),\n })\n }\n\n // ===== useSuspenseQueryById =====\n useSuspenseQueryById<T extends TCollection, TData = CollectionType<T>>(\n params: CollectionDetailQueryParams<T, CollectionReadOptions<TCollection>>,\n options?: SuspenseQueryOptions<CollectionType<T>, TData>,\n ): UseSuspenseQueryResult<TData> {\n const { collection, id, options: queryOptions } = params\n\n return useSuspenseQueryOriginal({\n queryKey: collectionKeys(collection).detail(id, queryOptions),\n queryFn: async () => {\n return await this.collectionClient\n .from(collection)\n .findById(id, queryOptions)\n },\n ...options,\n })\n }\n\n // ===== useInfiniteQuery =====\n useInfiniteQuery<\n T extends TCollection,\n TData = InfiniteData<PayloadFindResponse<CollectionType<T>>>,\n >(\n params: CollectionInfiniteQueryParams<\n T,\n CollectionReadOptions<TCollection>\n >,\n options?: InfiniteQueryOptions<\n PayloadFindResponse<CollectionType<T>>,\n TData\n >,\n ): UseInfiniteQueryResult<TData> {\n const { collection, options: queryOptions } = params\n const explicitPageSize = params.pageSize\n const pageSize = explicitPageSize ?? DEFAULT_PAGE_SIZE\n\n return useInfiniteQueryOriginal({\n queryKey: collectionKeys(collection).infinite(\n queryOptions,\n explicitPageSize,\n ),\n queryFn: async ({ pageParam }) => {\n const response = await this.collectionClient\n .from(collection)\n .find({ ...queryOptions, page: pageParam, limit: pageSize })\n return response\n },\n initialPageParam: 1,\n getNextPageParam: (lastPage: PayloadFindResponse<CollectionType<T>>) => {\n return lastPage.hasNextPage ? lastPage.nextPage : undefined\n },\n ...options,\n })\n }\n\n // ===== useSuspenseInfiniteQuery =====\n useSuspenseInfiniteQuery<\n T extends TCollection,\n TData = InfiniteData<PayloadFindResponse<CollectionType<T>>>,\n >(\n params: CollectionInfiniteQueryParams<\n T,\n CollectionReadOptions<TCollection>\n >,\n options?: SuspenseInfiniteQueryOptions<\n PayloadFindResponse<CollectionType<T>>,\n TData\n >,\n ): UseSuspenseInfiniteQueryResult<TData> {\n const { collection, options: queryOptions } = params\n const explicitPageSize = params.pageSize\n const pageSize = explicitPageSize ?? DEFAULT_PAGE_SIZE\n\n return useSuspenseInfiniteQueryOriginal({\n queryKey: collectionKeys(collection).infinite(\n queryOptions,\n explicitPageSize,\n ),\n queryFn: async ({ pageParam }) => {\n const response = await this.collectionClient\n .from(collection)\n .find({ ...queryOptions, page: pageParam, limit: pageSize })\n return response\n },\n initialPageParam: 1,\n getNextPageParam: (lastPage: PayloadFindResponse<CollectionType<T>>) => {\n return lastPage.hasNextPage ? lastPage.nextPage : undefined\n },\n ...options,\n })\n }\n\n // ===== prefetchQuery =====\n async prefetchQuery<T extends TCollection>(\n params: CollectionQueryParams<T, CollectionReadOptions<TCollection>>,\n options?: { staleTime?: number },\n ) {\n const { collection, options: queryOptions } = params\n\n return this.queryClient.prefetchQuery({\n queryKey: collectionKeys(collection).list(queryOptions),\n queryFn: async () => {\n return await this.collectionClient\n .from(collection)\n .find(queryOptions)\n },\n ...options,\n })\n }\n\n // ===== prefetchQueryById =====\n async prefetchQueryById<T extends TCollection>(\n params: CollectionDetailQueryParams<\n T,\n CollectionReadOptions<TCollection>\n >,\n options?: { staleTime?: number },\n ) {\n const { collection, id, options: queryOptions } = params\n\n return this.queryClient.prefetchQuery({\n queryKey: collectionKeys(collection).detail(id, queryOptions),\n queryFn: async () => {\n return await this.collectionClient\n .from(collection)\n .findById(id, queryOptions)\n },\n ...options,\n })\n }\n\n // ===== prefetchInfiniteQuery =====\n async prefetchInfiniteQuery<T extends TCollection>(\n params: CollectionInfiniteQueryParams<\n T,\n CollectionReadOptions<TCollection>\n >,\n options?: { pages?: number; staleTime?: number },\n ) {\n const { collection, options: queryOptions } = params\n const explicitPageSize = params.pageSize\n const pageSize = explicitPageSize ?? DEFAULT_PAGE_SIZE\n\n return this.queryClient.prefetchInfiniteQuery({\n queryKey: collectionKeys(collection).infinite(\n queryOptions,\n explicitPageSize,\n ),\n queryFn: async ({ pageParam }) => {\n const response = await this.collectionClient\n .from(collection)\n .find({ ...queryOptions, page: pageParam, limit: pageSize })\n return response\n },\n initialPageParam: 1,\n getNextPageParam: (lastPage: PayloadFindResponse<CollectionType<T>>) => {\n return lastPage.hasNextPage ? lastPage.nextPage : undefined\n },\n pages: options?.pages ?? 1,\n staleTime: options?.staleTime,\n })\n }\n\n // ===== Mutation Hooks =====\n\n useCreate<T extends TCollection>(\n params: { collection: T },\n options?: MutationCallbacks<PayloadMutationResponse<CollectionType<T>>>,\n ) {\n const { collection } = params\n\n return useMutationOriginal<\n PayloadMutationResponse<CollectionType<T>>,\n SDKError,\n {\n data: Partial<CollectionType<T>>\n file?: File | Blob\n filename?: string\n }\n >({\n mutationFn: async (variables) => {\n return await this.collectionClient\n .from(collection)\n .create(\n variables.data,\n variables.file\n ? { file: variables.file, filename: variables.filename }\n : undefined,\n )\n },\n onSuccess: (data) => {\n this.queryClient.invalidateQueries({\n queryKey: collectionKeys(collection).all,\n })\n if (PRODUCT_DETAIL_INVALIDATING_COLLECTIONS.has(collection)) {\n this.queryClient.invalidateQueries({ queryKey: ['products', 'detail'] })\n }\n options?.onSuccess?.(data)\n },\n onError: options?.onError,\n onSettled: options?.onSettled,\n })\n }\n\n useUpdate<T extends TCollection>(\n params: { collection: T },\n options?: MutationCallbacks<PayloadMutationResponse<CollectionType<T>>>,\n ) {\n const { collection } = params\n\n return useMutationOriginal<\n PayloadMutationResponse<CollectionType<T>>,\n SDKError,\n {\n id: string\n data: Partial<CollectionType<T>>\n file?: File | Blob\n filename?: string\n }\n >({\n mutationFn: async (variables) => {\n return await this.collectionClient\n .from(collection)\n .update(\n variables.id,\n variables.data,\n variables.file\n ? { file: variables.file, filename: variables.filename }\n : undefined,\n )\n },\n onSuccess: (data) => {\n this.queryClient.invalidateQueries({\n queryKey: collectionKeys(collection).all,\n })\n if (PRODUCT_DETAIL_INVALIDATING_COLLECTIONS.has(collection)) {\n this.queryClient.invalidateQueries({ queryKey: ['products', 'detail'] })\n }\n options?.onSuccess?.(data)\n },\n onError: options?.onError,\n onSettled: options?.onSettled,\n })\n }\n\n useRemove<T extends TCollection>(\n params: { collection: T },\n options?: MutationCallbacks<CollectionType<T>>,\n ) {\n const { collection } = params\n\n return useMutationOriginal<CollectionType<T>, SDKError, string>({\n mutationFn: async (id) => {\n return await this.collectionClient.from(collection).remove(id)\n },\n onSuccess: (data) => {\n this.queryClient.invalidateQueries({\n queryKey: collectionKeys(collection).all,\n })\n if (PRODUCT_DETAIL_INVALIDATING_COLLECTIONS.has(collection)) {\n this.queryClient.invalidateQueries({ queryKey: ['products', 'detail'] })\n }\n options?.onSuccess?.(data)\n },\n onError: options?.onError,\n onSettled: options?.onSettled,\n })\n }\n\n // ===== Cache Utilities =====\n\n invalidateQueries<T extends TCollection>(\n collection: T,\n type?: 'list' | 'detail' | 'infinite',\n ) {\n const queryKey = type ? [collection, type] : [collection]\n return this.queryClient.invalidateQueries({ queryKey })\n }\n\n getQueryData<T extends TCollection>(\n collection: T,\n type: 'list',\n options?: ApiQueryOptions,\n ): PayloadFindResponse<CollectionType<T>> | undefined\n getQueryData<T extends TCollection>(\n collection: T,\n type: 'detail',\n id: string,\n options?: ApiQueryOptions,\n ): CollectionType<T> | null | undefined\n getQueryData<T extends TCollection>(\n collection: T,\n type: 'list' | 'detail',\n idOrOptions?: string | ApiQueryOptions,\n options?: ApiQueryOptions,\n ) {\n if (type === 'list') {\n return this.queryClient.getQueryData(\n collectionKeys(collection).list(idOrOptions as ApiQueryOptions),\n )\n }\n return this.queryClient.getQueryData(\n collectionKeys(collection).detail(idOrOptions as string, options),\n )\n }\n\n setQueryData<T extends TCollection>(\n collection: T,\n type: 'list',\n data: PayloadFindResponse<CollectionType<T>>,\n options?: ApiQueryOptions,\n ): void\n setQueryData<T extends TCollection>(\n collection: T,\n type: 'detail',\n id: string,\n data: CollectionType<T> | null,\n options?: ApiQueryOptions,\n ): void\n setQueryData<T extends TCollection>(\n collection: T,\n type: 'list' | 'detail',\n dataOrId: PayloadFindResponse<CollectionType<T>> | string,\n dataOrOptions?: CollectionType<T> | null | ApiQueryOptions,\n options?: ApiQueryOptions,\n ) {\n if (type === 'list') {\n this.queryClient.setQueryData(\n collectionKeys(collection).list(dataOrOptions as ApiQueryOptions),\n dataOrId as PayloadFindResponse<CollectionType<T>>,\n )\n } else {\n this.queryClient.setQueryData(\n collectionKeys(collection).detail(dataOrId as string, options),\n dataOrOptions as CollectionType<T> | null,\n )\n }\n }\n}\n","import {\n QueryClient,\n useQuery as useQueryOriginal,\n useMutation as useMutationOriginal,\n} from '@tanstack/react-query'\nimport type { CustomerAuth } from '../customer/customer-auth'\nimport type {\n CustomerAuthResponse,\n CustomerRefreshResponse,\n CustomerProfile,\n CustomerRegisterData,\n CustomerLoginData,\n UpdateProfileData,\n} from '../customer/types'\nimport { createConfigError, SDKError } from '../internal/errors'\nimport { customerKeys } from './query-keys'\n\n// ============================================================================\n// Mutation helper\n// ============================================================================\n\ninterface MutationCallbacks<TData> {\n onSuccess?: (data: TData) => void\n onError?: (error: SDKError) => void\n onSettled?: () => void\n}\n\nfunction createMutation<TData, TVariables>(\n mutationFn: (variables: TVariables) => Promise<TData>,\n callbacks?: MutationCallbacks<TData>,\n onSuccessExtra?: (data: TData) => void,\n) {\n return useMutationOriginal({\n mutationFn,\n onSuccess: (data) => {\n onSuccessExtra?.(data)\n callbacks?.onSuccess?.(data)\n },\n onError: callbacks?.onError,\n onSettled: callbacks?.onSettled,\n })\n}\n\n// ============================================================================\n// Customer Hooks Mixin\n// ============================================================================\n\nexport class CustomerHooks {\n private queryClient: QueryClient\n private customerAuth?: CustomerAuth\n\n constructor(queryClient: QueryClient, customerAuth?: CustomerAuth) {\n this.queryClient = queryClient\n this.customerAuth = customerAuth\n }\n\n private ensureCustomerAuth(): CustomerAuth {\n if (!this.customerAuth) {\n throw createConfigError(\n 'Customer hooks require Client. Use createClient() instead of createServerClient().',\n )\n }\n return this.customerAuth\n }\n\n private invalidateMe = () => {\n this.queryClient.invalidateQueries({ queryKey: customerKeys.me() })\n }\n\n // ===== useCustomerMe =====\n useCustomerMe(options?: {\n enabled?: boolean\n staleTime?: number\n gcTime?: number\n refetchOnWindowFocus?: boolean\n refetchOnMount?: boolean | 'always'\n refetchInterval?: number | false\n retry?: boolean | number\n }) {\n return useQueryOriginal({\n queryKey: customerKeys.me(),\n queryFn: async () => {\n return await this.ensureCustomerAuth().me()\n },\n ...options,\n enabled:\n (options?.enabled ?? true) && !!this.customerAuth?.isAuthenticated(),\n })\n }\n\n // ===== Mutations =====\n\n useCustomerLogin(options?: MutationCallbacks<CustomerAuthResponse>) {\n return createMutation(\n (data: CustomerLoginData) => this.ensureCustomerAuth().login(data),\n options,\n this.invalidateMe,\n )\n }\n\n useCustomerRegister(\n options?: MutationCallbacks<{ customer: CustomerProfile }>,\n ) {\n return createMutation(\n (data: CustomerRegisterData) => this.ensureCustomerAuth().register(data),\n options,\n )\n }\n\n useCustomerLogout(options?: MutationCallbacks<void>) {\n return useMutationOriginal({\n mutationFn: async () => {\n this.ensureCustomerAuth().logout()\n },\n onSuccess: () => {\n this.queryClient.removeQueries({ queryKey: customerKeys.all })\n options?.onSuccess?.()\n },\n onError: options?.onError,\n onSettled: options?.onSettled,\n })\n }\n\n useCustomerForgotPassword(options?: MutationCallbacks<void>) {\n return createMutation(\n (email: string) =>\n this.ensureCustomerAuth()\n .forgotPassword(email)\n .then(() => {}),\n options,\n )\n }\n\n useCustomerResetPassword(options?: MutationCallbacks<void>) {\n return createMutation(\n (data: { token: string; password: string }) =>\n this.ensureCustomerAuth()\n .resetPassword(data.token, data.password)\n .then(() => {}),\n options,\n )\n }\n\n useCustomerRefreshToken(\n options?: MutationCallbacks<CustomerRefreshResponse>,\n ) {\n return createMutation(\n () => this.ensureCustomerAuth().refreshToken(),\n options,\n this.invalidateMe,\n )\n }\n\n useCustomerUpdateProfile(options?: MutationCallbacks<CustomerProfile>) {\n return createMutation(\n (data: UpdateProfileData) =>\n this.ensureCustomerAuth().updateProfile(data),\n options,\n this.invalidateMe,\n )\n }\n\n useCustomerChangePassword(options?: MutationCallbacks<void>) {\n return createMutation(\n (data: { currentPassword: string; newPassword: string }) =>\n this.ensureCustomerAuth()\n .changePassword(data.currentPassword, data.newPassword)\n .then(() => {}),\n options,\n )\n }\n\n // ===== Customer Cache Utilities =====\n\n invalidateCustomerQueries() {\n return this.queryClient.invalidateQueries({ queryKey: customerKeys.all })\n }\n\n getCustomerData(): CustomerProfile | null | undefined {\n return this.queryClient.getQueryData(customerKeys.me())\n }\n\n setCustomerData(data: CustomerProfile | null) {\n this.queryClient.setQueryData(customerKeys.me(), data)\n }\n}\n","export class SDKError extends Error {\n readonly code: string\n readonly status?: number\n readonly details?: unknown\n readonly userMessage?: string\n readonly suggestion?: string\n readonly requestId?: string\n readonly kind?: 'commerce'\n readonly reason?: CommerceErrorCode | 'unknown_commerce_error'\n readonly rawReason?: string\n readonly retryable?: boolean\n readonly retryAfter?: number\n\n constructor(\n code: string,\n message: string,\n status?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(message)\n this.name = 'SDKError'\n this.code = code\n this.status = status\n this.details = details\n this.userMessage = userMessage\n this.suggestion = suggestion\n this.requestId = requestId\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, new.target)\n }\n }\n\n getUserMessage(): string {\n return this.userMessage || this.message\n }\n\n toJSON() {\n return {\n name: this.name,\n code: this.code,\n message: this.message,\n status: this.status,\n details: this.details,\n userMessage: this.userMessage,\n suggestion: this.suggestion,\n ...(this.requestId !== undefined && { requestId: this.requestId }),\n ...(this.kind !== undefined && { kind: this.kind }),\n ...(this.reason !== undefined && { reason: this.reason }),\n ...(this.rawReason !== undefined && { rawReason: this.rawReason }),\n ...(this.retryable !== undefined && { retryable: this.retryable }),\n ...(this.retryAfter !== undefined && { retryAfter: this.retryAfter }),\n }\n }\n}\n\n/**\n * Canonical Cart/Checkout/PaymentSession error reasons. This public SDK mirror\n * intentionally does not import the private contracts package; parity is\n * enforced by a type test.\n */\nexport const COMMERCE_ERROR_CODES = [\n 'validation_failed',\n 'bad_request',\n 'unauthorized',\n 'forbidden',\n 'account_suspended',\n 'key_invalid',\n 'pat_tenant_header_forbidden',\n 'tenant_mismatch',\n 'test_tenant_expired',\n 'token_invalid',\n 'token_expired',\n 'origin_not_allowed',\n 'server_credentials_required',\n 'role_denied',\n 'scope_denied',\n 'feature_disabled',\n 'not_found',\n 'conflict',\n 'locked',\n 'cart_revision_conflict',\n 'rate_limit_exceeded',\n 'usage_limit_exceeded',\n 'service_unavailable',\n 'idempotency_conflict',\n 'idempotency_in_progress',\n 'idempotency_key_required',\n 'invalid_idempotency_key',\n 'cart_not_active',\n 'cart_locked',\n 'cart_empty',\n 'cart_market_unavailable',\n 'cart_market_mismatch',\n 'checkout_not_open',\n 'checkout_already_open',\n 'payment_slot_held',\n 'reservation_expired',\n 'payment_session_not_cancelable',\n 'payment_session_conflict',\n 'provider_identity_mismatch',\n 'payment_method_unavailable',\n 'provider_unavailable',\n 'lock_timeout',\n 'price_changed',\n 'pricing_fact_in_use',\n 'insufficient_stock',\n 'reservation_conflict',\n 'stock_lock_unavailable',\n 'variant_not_found',\n 'variant_stock_write_failed',\n 'stock_invariant_violation',\n 'payment_confirmation_in_flight',\n 'checkout_reservation_release_requires_transaction',\n 'admission_metadata_invalid',\n 'admission_metadata_required',\n 'capacity_exceeded',\n 'occurrence_lock_unavailable',\n 'occurrence_not_open',\n 'admission_type_capacity_exceeded',\n 'admission_type_occurrence_mismatch',\n 'admission_hold_expired',\n 'admission_hold_checkout_item_conflict',\n 'admission_hold_checkout_conflict',\n 'admission_hold_quantity_mismatch',\n 'admission_hold_unbound',\n 'admission_hold_missing',\n 'admission_hold_checkout_item_missing',\n 'admission_hold_expiry_failed',\n 'admission_hold_expiry_requires_transaction',\n 'admission_hold_line_item_mismatch',\n 'admission_materialization_failed',\n 'variant_inactive',\n 'variant_product_mismatch',\n 'product_not_public',\n 'market_not_found',\n 'market_shipping_currency_unsupported',\n 'missing_market_rate',\n 'missing_shipping_amount',\n 'no_enabled_payment_provider',\n 'product_market_unavailable',\n 'unsupported_currency',\n 'missing_price_row',\n 'payment_provider_currency_unsupported',\n 'discount_code_not_found',\n 'discount_not_started',\n 'discount_expired',\n 'discount_usage_limit',\n 'discount_per_customer_limit',\n 'discount_customer_required',\n 'discount_first_order_only',\n 'discount_customer_not_eligible',\n 'discount_customer_excluded',\n 'discount_items_required',\n 'discount_product_not_eligible',\n 'discount_product_excluded',\n 'discount_min_order_amount',\n 'discount_currency_scope_required',\n 'discount_allocation_method_unsupported',\n 'currency_mismatch',\n 'customer_token_required',\n 'market_required',\n 'server_derived',\n 'internal_error',\n] as const\n\nexport type CommerceErrorCode = (typeof COMMERCE_ERROR_CODES)[number]\n\ntype CommerceSDKErrorBase = SDKError & {\n readonly kind: 'commerce'\n readonly requestId: string\n readonly retryable: boolean\n readonly retryAfter?: number\n readonly details?: Record<string, unknown>\n}\n\nexport type CommerceSDKError = CommerceSDKErrorBase &\n (\n | { readonly reason: CommerceErrorCode; readonly rawReason?: never }\n | {\n readonly reason: 'unknown_commerce_error'\n readonly rawReason: string\n }\n )\n\nconst COMMERCE_ERROR_CODE_SET: ReadonlySet<string> = new Set(\n COMMERCE_ERROR_CODES,\n)\nconst COMMERCE_ERROR_ENVELOPE_KEYS = new Set([\n 'error',\n 'reason',\n 'requestId',\n 'retryable',\n 'details',\n])\n\nfunction isPlainRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nexport type CommerceErrorEnvelope = {\n error: string\n reason: string\n requestId: string\n retryable: boolean\n details?: Record<string, unknown>\n}\n\nfunction commerceProtocolError(\n issue: string,\n trustedRequestId?: string,\n): SDKError {\n return createApiError(\n 'Invalid canonical commerce error response.',\n 502,\n { protocol: 'commerce-error-envelope', issue },\n 'The server returned an incompatible commerce error response.',\n 'Verify that the Console commerce contract is deployed before using this SDK version.',\n trustedRequestId,\n )\n}\n\n/** @internal Strictly parse a canonical commerce error without retaining its raw body. */\nexport function parseCommerceErrorEnvelope(\n body: unknown,\n headerRequestId?: string,\n): CommerceErrorEnvelope {\n if (headerRequestId === undefined) {\n throw commerceProtocolError('missing_request_id_header')\n }\n if (headerRequestId.length === 0) {\n throw commerceProtocolError('empty_request_id_header')\n }\n if (!isPlainRecord(body)) {\n throw commerceProtocolError('expected_object', headerRequestId)\n }\n if (Object.keys(body).some((key) => !COMMERCE_ERROR_ENVELOPE_KEYS.has(key))) {\n throw commerceProtocolError('unexpected_field', headerRequestId)\n }\n if (\n typeof body.error !== 'string' ||\n body.error.length === 0 ||\n typeof body.reason !== 'string' ||\n body.reason.length === 0 ||\n typeof body.requestId !== 'string' ||\n body.requestId.length === 0 ||\n (body.retryable !== undefined && typeof body.retryable !== 'boolean') ||\n (body.details !== undefined && !isPlainRecord(body.details))\n ) {\n throw commerceProtocolError('invalid_field', headerRequestId)\n }\n\n if (headerRequestId !== undefined && headerRequestId !== body.requestId) {\n throw commerceProtocolError('request_id_mismatch', headerRequestId)\n }\n\n return {\n error: body.error,\n reason: body.reason,\n requestId: body.requestId,\n retryable: body.retryable === true,\n ...(body.details === undefined ? {} : { details: body.details }),\n }\n}\n\n/** @internal Validate and apply the canonical commerce error envelope. */\nexport function enhanceCommerceError(\n error: SDKError,\n body: unknown,\n headerRequestId?: string,\n): SDKError {\n const envelope = parseCommerceErrorEnvelope(body, headerRequestId)\n\n const known = COMMERCE_ERROR_CODE_SET.has(envelope.reason)\n Object.assign(error, {\n code: envelope.reason,\n kind: 'commerce' as const,\n reason: known\n ? (envelope.reason as CommerceErrorCode)\n : 'unknown_commerce_error',\n ...(known ? {} : { rawReason: envelope.reason }),\n requestId: envelope.requestId,\n retryable: envelope.retryable,\n details: envelope.details,\n })\n return error\n}\n\nexport function isCommerceSDKError(error: unknown): error is CommerceSDKError {\n if (!(error instanceof SDKError) || error.kind !== 'commerce') return false\n if (\n typeof error.requestId !== 'string' ||\n typeof error.retryable !== 'boolean' ||\n (error.retryAfter !== undefined &&\n (!Number.isSafeInteger(error.retryAfter) || error.retryAfter < 0)) ||\n typeof error.reason !== 'string'\n ) {\n return false\n }\n return error.reason === 'unknown_commerce_error'\n ? typeof error.rawReason === 'string'\n : COMMERCE_ERROR_CODE_SET.has(error.reason) && error.rawReason === undefined\n}\n\nexport class NetworkError extends SDKError {\n constructor(\n message: string,\n status?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('NETWORK_ERROR', message, status, details, userMessage, suggestion)\n this.name = 'NetworkError'\n }\n}\n\nexport class ValidationError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n status = 400,\n ) {\n super('VALIDATION_ERROR', message, status, details, userMessage, suggestion)\n this.name = 'ValidationError'\n }\n}\n\nexport class ApiError extends SDKError {\n constructor(\n message: string,\n status: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'API_ERROR',\n message,\n status,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'ApiError'\n }\n}\n\nexport class ConfigError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('CONFIG_ERROR', message, undefined, details, userMessage, suggestion)\n this.name = 'ConfigError'\n }\n}\n\nexport class TimeoutError extends SDKError {\n constructor(\n message = 'Request timed out.',\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('TIMEOUT_ERROR', message, 408, details, userMessage, suggestion)\n this.name = 'TimeoutError'\n }\n}\n\nexport class GoneError extends SDKError {\n constructor(\n message = 'The requested resource is no longer available.',\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('GONE_ERROR', message, 410, details, userMessage, suggestion)\n this.name = 'GoneError'\n }\n}\n\nexport class ServiceUnavailableError extends SDKError {\n readonly retryAfter?: number\n\n constructor(\n message = 'Service temporarily unavailable.',\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super(\n 'SERVICE_UNAVAILABLE_ERROR',\n message,\n 503,\n details,\n userMessage,\n suggestion,\n )\n this.name = 'ServiceUnavailableError'\n this.retryAfter = retryAfter\n }\n}\n\nexport class UsageLimitError extends SDKError {\n readonly usage: { limit: number; current: number; remaining: number }\n\n constructor(\n message: string,\n usage: { limit: number; current: number; remaining: number },\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n ) {\n super('USAGE_LIMIT_ERROR', message, 429, details, userMessage, suggestion)\n this.name = 'UsageLimitError'\n this.usage = usage\n }\n\n toJSON() {\n return {\n ...super.toJSON(),\n usage: this.usage,\n }\n }\n}\n\nexport class AuthError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'auth_error',\n message,\n 401,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'AuthError'\n }\n}\n\nexport class PermissionError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'permission_error',\n message,\n 403,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'PermissionError'\n }\n}\n\nexport class NotFoundError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'not_found',\n message,\n 404,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'NotFoundError'\n }\n}\n\nexport class ConflictError extends SDKError {\n constructor(\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super('conflict', message, 409, details, userMessage, suggestion, requestId)\n this.name = 'ConflictError'\n }\n}\n\nexport class RateLimitError extends SDKError {\n readonly retryAfter?: number\n\n constructor(\n message: string,\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n ) {\n super(\n 'rate_limit_exceeded',\n message,\n 429,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n this.name = 'RateLimitError'\n this.retryAfter = retryAfter\n }\n}\n\nexport function isSDKError(error: unknown): error is SDKError {\n return error instanceof SDKError\n}\n\nexport function isNetworkError(error: unknown): error is NetworkError {\n return error instanceof NetworkError\n}\n\nexport function isValidationError(error: unknown): error is ValidationError {\n if (error instanceof ValidationError) return true\n if (error == null || typeof error !== 'object') return false\n\n const candidate = error as {\n code?: unknown\n name?: unknown\n message?: unknown\n getUserMessage?: unknown\n toJSON?: unknown\n }\n return (\n candidate.name === 'ValidationError' &&\n candidate.code === 'VALIDATION_ERROR' &&\n typeof candidate.message === 'string' &&\n typeof candidate.getUserMessage === 'function' &&\n typeof candidate.toJSON === 'function'\n )\n}\n\nexport function isApiError(error: unknown): error is ApiError {\n return error instanceof ApiError\n}\n\nexport function isConfigError(error: unknown): error is ConfigError {\n return error instanceof ConfigError\n}\n\nexport function isTimeoutError(error: unknown): error is TimeoutError {\n return error instanceof TimeoutError\n}\n\nexport function isGoneError(error: unknown): error is GoneError {\n return error instanceof GoneError\n}\n\nexport function isServiceUnavailableError(\n error: unknown,\n): error is ServiceUnavailableError {\n return error instanceof ServiceUnavailableError\n}\n\nexport function isUsageLimitError(error: unknown): error is UsageLimitError {\n return error instanceof UsageLimitError\n}\n\nexport function isAuthError(error: unknown): error is AuthError {\n return error instanceof AuthError\n}\n\nexport function isPermissionError(error: unknown): error is PermissionError {\n return error instanceof PermissionError\n}\n\nexport function isNotFoundError(error: unknown): error is NotFoundError {\n return error instanceof NotFoundError\n}\n\nexport function isConflictError(error: unknown): error is ConflictError {\n return error instanceof ConflictError\n}\n\nexport function isRateLimitError(error: unknown): error is RateLimitError {\n return error instanceof RateLimitError\n}\n\nexport const createNetworkError = (\n message: string,\n status?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new NetworkError(message, status, details, userMessage, suggestion)\n\nexport const createValidationError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n status?: number,\n) => new ValidationError(message, details, userMessage, suggestion, status)\n\nexport const createApiError = (\n message: string,\n status: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new ApiError(message, status, details, userMessage, suggestion, requestId)\n\nexport const createConfigError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new ConfigError(message, details, userMessage, suggestion)\n\nexport const createTimeoutError = (\n message?: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new TimeoutError(message, details, userMessage, suggestion)\n\nexport const createGoneError = (\n message?: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new GoneError(message, details, userMessage, suggestion)\n\nexport const createServiceUnavailableError = (\n message?: string,\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) =>\n new ServiceUnavailableError(\n message,\n retryAfter,\n details,\n userMessage,\n suggestion,\n )\n\nexport const createUsageLimitError = (\n message: string,\n usage: { limit: number; current: number; remaining: number },\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n) => new UsageLimitError(message, usage, details, userMessage, suggestion)\n\nexport const createAuthError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new AuthError(message, details, userMessage, suggestion, requestId)\n\nexport const createPermissionError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new PermissionError(message, details, userMessage, suggestion, requestId)\n\nexport const createNotFoundError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new NotFoundError(message, details, userMessage, suggestion, requestId)\n\nexport const createConflictError = (\n message: string,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) => new ConflictError(message, details, userMessage, suggestion, requestId)\n\nexport const createRateLimitError = (\n message: string,\n retryAfter?: number,\n details?: unknown,\n userMessage?: string,\n suggestion?: string,\n requestId?: string,\n) =>\n new RateLimitError(\n message,\n retryAfter,\n details,\n userMessage,\n suggestion,\n requestId,\n )\n","import {\n QueryClient,\n useInfiniteQuery as useInfiniteQueryOriginal,\n useQuery as useQueryOriginal,\n useSuspenseInfiniteQuery as useSuspenseInfiniteQueryOriginal,\n useSuspenseQuery as useSuspenseQueryOriginal,\n} from '@tanstack/react-query'\nimport type {\n InfiniteData,\n UseInfiniteQueryResult,\n UseQueryResult,\n UseSuspenseInfiniteQueryResult,\n UseSuspenseQueryResult,\n} from '@tanstack/react-query'\nimport type {\n ApiQueryOptions,\n PayloadFindResponse,\n PublicCollection,\n ServerCollection,\n} from '../client/types'\nimport type { CustomerAuth } from '../customer/customer-auth'\nimport type { CollectionClient } from '../collection'\nimport type {\n ProductDetailParams,\n ProductDetailCatalogResult,\n ProductListingGroupsCatalogItem,\n ProductListingGroupsItem,\n ProductListingPageBaseParams,\n ProductListingPageCatalogParams,\n ProductListingPageFullParams,\n ProductListingPageParams,\n ProductListingPageResult,\n} from '../api'\nimport {\n CollectionHooks,\n type InfiniteQueryOptions,\n type QueryOptions,\n type SuspenseInfiniteQueryOptions,\n type SuspenseQueryOptions,\n} from './collection-hooks'\nimport { CustomerHooks } from './customer-hooks'\nimport { createConfigError } from '../internal/errors'\nimport { listingPageSearchParams } from '../internal/utils/query-string'\nimport {\n COMMERCE_ENDPOINT_OPERATIONS,\n resolveOperationPath,\n} from '../api/endpoints'\nimport type { CommerceEndpointDescriptor } from '../api/endpoints'\nimport {\n canonicalProductListingGroupsQueryOptions,\n productKeys,\n} from './query-keys'\n\n// Re-export everything from sub-modules for barrel compatibility\nexport { collectionKeys, customerKeys } from './query-keys'\nexport { productKeys } from './query-keys'\nexport type {\n CollectionQueryParams,\n CollectionDetailQueryParams,\n CollectionInfiniteQueryParams,\n QueryOptions,\n SuspenseQueryOptions,\n InfiniteQueryOptions,\n SuspenseInfiniteQueryOptions,\n} from './collection-hooks'\n\nexport type ProductListingGroupsQueryOptions = Pick<\n ApiQueryOptions,\n 'page' | 'limit' | 'sort' | 'where'\n> & {\n market?: string\n locale?: ProductListingPageParams['locale']\n fallbackLocale?: ProductListingPageParams['fallbackLocale']\n}\n\ntype ProductDetailConvenienceOptions =\n QueryOptions<ProductDetailCatalogResult> & {\n market?: string\n locale?: ProductDetailParams['locale']\n fallbackLocale?: ProductDetailParams['fallbackLocale']\n }\n\nexport type ReadOnlyQueryHooks = Omit<\n QueryHooks<PublicCollection>,\n | 'useCreate'\n | 'useUpdate'\n | 'useRemove'\n | 'useProductListingGroupsQuery'\n | 'useSuspenseProductListingGroupsQuery'\n | 'useInfiniteProductListingGroupsQuery'\n | 'useSuspenseInfiniteProductListingGroupsQuery'\n | 'prefetchProductListingGroupsQuery'\n | 'prefetchInfiniteProductListingGroupsQuery'\n | 'useProductListingPage'\n | 'useSuspenseProductListingPage'\n | 'useInfiniteProductListingPage'\n | 'prefetchProductListingPage'\n | 'prefetchInfiniteProductListingPage'\n> & {\n useProductListingPage<\n TData = ProductListingPageResult<ProductListingGroupsCatalogItem>,\n >(\n params?: ProductListingPageCatalogParams,\n options?: QueryOptions<\n ProductListingPageResult<ProductListingGroupsCatalogItem>,\n TData\n >,\n ): UseQueryResult<TData>\n useSuspenseProductListingPage<\n TData = ProductListingPageResult<ProductListingGroupsCatalogItem>,\n >(\n params?: ProductListingPageCatalogParams,\n options?: SuspenseQueryOptions<\n ProductListingPageResult<ProductListingGroupsCatalogItem>,\n TData\n >,\n ): UseSuspenseQueryResult<TData>\n useInfiniteProductListingPage<\n TData = InfiniteData<\n ProductListingPageResult<ProductListingGroupsCatalogItem>\n >,\n >(\n params?: ProductListingPageCatalogInfiniteParams,\n options?: InfiniteQueryOptions<\n ProductListingPageResult<ProductListingGroupsCatalogItem>,\n TData\n >,\n ): UseInfiniteQueryResult<TData>\n prefetchProductListingPage(\n params?: ProductListingPageCatalogParams,\n options?: { staleTime?: number },\n ): Promise<void>\n prefetchInfiniteProductListingPage(\n params?: ProductListingPageCatalogInfiniteParams,\n options?: { pages?: number; staleTime?: number },\n ): Promise<void>\n}\n\n/**\n * Composes CollectionHooks + CustomerHooks into a single API surface.\n * All methods are delegated; no logic lives here.\n */\ninterface ProductDetailCallable {\n product: {\n detail: (params: ProductDetailParams) => Promise<ProductDetailCatalogResult>\n }\n}\n\ninterface ProductListingPageCatalogCallable {\n product: {\n listingPage: {\n (\n params?: ProductListingPageCatalogParams,\n ): Promise<ProductListingPageResult<ProductListingGroupsCatalogItem>>\n }\n }\n}\n\ninterface ProductListingPageCallable extends ProductListingPageCatalogCallable {\n product: ProductListingPageCatalogCallable['product'] & {\n listingPage: ProductListingPageCatalogCallable['product']['listingPage'] & {\n (\n params: ProductListingPageFullParams,\n ): Promise<ProductListingPageResult<ProductListingGroupsItem>>\n (\n params: ProductListingPageParams,\n ): Promise<\n | ProductListingPageResult<ProductListingGroupsCatalogItem>\n | ProductListingPageResult<ProductListingGroupsItem>\n >\n }\n }\n}\n\ntype ProductCommerceCallable = ProductDetailCallable &\n ProductListingPageCallable\n\ntype ProductListingPageCatalogResult =\n ProductListingPageResult<ProductListingGroupsCatalogItem>\ntype ProductListingPageFullResult =\n ProductListingPageResult<ProductListingGroupsItem>\ntype ProductListingPageUnionResult =\n | ProductListingPageCatalogResult\n | ProductListingPageFullResult\ntype ProductListingPageHookOptions<TData> =\n | QueryOptions<ProductListingPageCatalogResult, TData>\n | QueryOptions<ProductListingPageFullResult, TData>\n | QueryOptions<ProductListingPageUnionResult, TData>\ntype ProductListingPageSuspenseHookOptions<TData> =\n | SuspenseQueryOptions<ProductListingPageCatalogResult, TData>\n | SuspenseQueryOptions<ProductListingPageFullResult, TData>\n | SuspenseQueryOptions<ProductListingPageUnionResult, TData>\n\nexport type ProductListingPageInfiniteParams = Omit<\n ProductListingPageBaseParams,\n 'page' | 'limit'\n> & {\n mode?: ProductListingPageParams['mode']\n pageSize?: number\n}\n\nexport type ProductListingPageCatalogInfiniteParams = Omit<\n ProductListingPageInfiniteParams,\n 'mode'\n> & {\n mode?: 'catalog'\n}\n\ntype ProductMarketContext = {\n market?: string\n}\n\ntype ProductMarketAwareCommerce = {\n getDefaultMarket?: () => string | undefined\n}\n\nfunction normalizeMarket(market?: string): string | undefined {\n const normalized = market?.trim()\n return normalized || undefined\n}\n\nfunction requestCommerceFindEndpoint<T>(\n collectionClient: CollectionClient,\n endpoint: CommerceEndpointDescriptor,\n options?: { data?: unknown; query?: string | URLSearchParams },\n): Promise<PayloadFindResponse<T>> {\n const path = resolveOperationPath(endpoint, { query: options?.query })\n if (endpoint.method === 'get') {\n return collectionClient.requestFindEndpointGet<T>(path)\n }\n if (endpoint.method === 'post') {\n return collectionClient.requestFindEndpoint<T>(path, options?.data)\n }\n throw new TypeError(`Unsupported find endpoint method: ${endpoint.method}`)\n}\n\nfunction withDefaultMarket<T extends { market?: string }>(\n params: T | undefined,\n market?: string,\n): T | undefined {\n const defaultMarket = normalizeMarket(market)\n if (!defaultMarket || normalizeMarket(params?.market)) return params\n return { ...(params ?? ({} as T)), market: defaultMarket }\n}\n\nfunction resolveProductMarket(\n commerceClient: ProductMarketAwareCommerce,\n context?: ProductMarketContext,\n): string | undefined {\n return (\n normalizeMarket(context?.market) ??\n normalizeMarket(commerceClient.getDefaultMarket?.())\n )\n}\n\nfunction splitListingGroupsQueryOptions(\n queryOptions?: ProductListingGroupsQueryOptions,\n) {\n const normalized = canonicalProductListingGroupsQueryOptions(queryOptions)\n if (!normalized) return { market: undefined, options: undefined }\n const { market, ...options } = normalized\n return {\n market,\n options: Object.keys(options).length > 0 ? options : undefined,\n }\n}\n\nfunction fetchProductListingGroupsQuery(\n collectionClient: CollectionClient,\n queryOptions?: ProductListingGroupsQueryOptions,\n) {\n const { market, options } = splitListingGroupsQueryOptions(queryOptions)\n return requestCommerceFindEndpoint<ProductListingGroupsItem>(\n collectionClient,\n COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQuery,\n {\n data: {\n ...(market ? { market } : {}),\n ...(options ? { options } : {}),\n },\n },\n )\n}\n\nfunction fetchProductListingGroupsCatalogQuery(\n collectionClient: CollectionClient,\n queryOptions?: ProductListingGroupsQueryOptions,\n) {\n return requestCommerceFindEndpoint<ProductListingGroupsCatalogItem>(\n collectionClient,\n COMMERCE_ENDPOINT_OPERATIONS.products.listingGroupsQueryCatalog,\n { query: listingPageSearchParams(queryOptions) },\n )\n}\n\nexport function productListingPageQueryOptions(\n commerceClient: ProductListingPageCatalogCallable,\n params?: ProductListingPageCatalogParams,\n context?: ProductMarketContext,\n): {\n queryKey: ReturnType<typeof productKeys.listingPage>\n queryFn: () => Promise<\n ProductListingPageResult<ProductListingGroupsCatalogItem>\n >\n}\nexport function productListingPageQueryOptions(\n commerceClient: ProductListingPageCallable,\n params: ProductListingPageFullParams,\n context?: ProductMarketContext,\n): {\n queryKey: ReturnType<typeof productKeys.listingPage>\n queryFn: () => Promise<ProductListingPageResult<ProductListingGroupsItem>>\n}\nexport function productListingPageQueryOptions(\n commerceClient: ProductListingPageCallable,\n params: ProductListingPageParams,\n context?: ProductMarketContext,\n): {\n queryKey: ReturnType<typeof productKeys.listingPage>\n queryFn: () => Promise<\n | ProductListingPageResult<ProductListingGroupsCatalogItem>\n | ProductListingPageResult<ProductListingGroupsItem>\n >\n}\nexport function productListingPageQueryOptions(\n commerceClient:\n | ProductListingPageCatalogCallable\n | ProductListingPageCallable,\n params: ProductListingPageParams = {},\n context?: ProductMarketContext,\n) {\n const effectiveParams =\n withDefaultMarket(\n params,\n resolveProductMarket(\n commerceClient as ProductMarketAwareCommerce,\n context,\n ),\n ) ?? params\n\n return {\n queryKey: productKeys.listingPage(effectiveParams),\n queryFn: () =>\n commerceClient.product.listingPage(\n effectiveParams as ProductListingPageCatalogParams,\n ),\n }\n}\n\nexport function productListingPageInfiniteQueryOptions(\n commerceClient: ProductListingPageCatalogCallable,\n params?: ProductListingPageCatalogInfiniteParams,\n context?: ProductMarketContext,\n): {\n queryKey: ReturnType<typeof productKeys.listingPageInfinite>\n queryFn: (args: {\n pageParam: number\n }) => Promise<ProductListingPageResult<ProductListingGroupsCatalogItem>>\n initialPageParam: number\n getNextPageParam: (\n lastPage: ProductListingPageResult<ProductListingGroupsCatalogItem>,\n ) => number | null | undefined\n}\nexport function productListingPageInfiniteQueryOptions(\n commerceClient: ProductListingPageCallable,\n params?: ProductListingPageInfiniteParams,\n context?: ProductMarketContext,\n): {\n queryKey: ReturnType<typeof productKeys.listingPageInfinite>\n queryFn: (args: {\n pageParam: number\n }) => Promise<\n | ProductListingPageResult<ProductListingGroupsCatalogItem>\n | ProductListingPageResult<ProductListingGroupsItem>\n >\n initialPageParam: number\n getNextPageParam: (\n lastPage: ProductListingPageResult<\n ProductListingGroupsCatalogItem | ProductListingGroupsItem\n >,\n ) => number | null | undefined\n}\nexport function productListingPageInfiniteQueryOptions(\n commerceClient:\n | ProductListingPageCatalogCallable\n | ProductListingPageCallable,\n params: ProductListingPageInfiniteParams = {},\n context?: ProductMarketContext,\n) {\n const {\n pageSize: explicitPageSize,\n page: _page,\n limit: _limit,\n ...pageParams\n } = params as ProductListingPageInfiniteParams & {\n page?: number\n limit?: number\n }\n const pageSize = explicitPageSize ?? 20\n const effectivePageParams =\n withDefaultMarket(\n pageParams,\n resolveProductMarket(\n commerceClient as ProductMarketAwareCommerce,\n context,\n ),\n ) ?? pageParams\n\n return {\n queryKey: productKeys.listingPageInfinite(\n effectivePageParams,\n explicitPageSize,\n ),\n queryFn: ({ pageParam }: { pageParam: number }) =>\n commerceClient.product.listingPage({\n ...effectivePageParams,\n page: pageParam,\n limit: pageSize,\n } as never),\n initialPageParam: 1,\n getNextPageParam: (\n lastPage: ProductListingPageResult<\n ProductListingGroupsCatalogItem | ProductListingGroupsItem\n >,\n ) => (lastPage.hasNextPage ? lastPage.nextPage : undefined),\n }\n}\n\nexport function prefetchProductListingPage(\n queryClient: QueryClient,\n commerceClient: ProductListingPageCatalogCallable,\n params?: ProductListingPageCatalogParams,\n options?: { staleTime?: number },\n context?: ProductMarketContext,\n): Promise<void>\nexport function prefetchProductListingPage(\n queryClient: QueryClient,\n commerceClient: ProductListingPageCallable,\n params: ProductListingPageFullParams,\n options?: { staleTime?: number },\n context?: ProductMarketContext,\n): Promise<void>\nexport function prefetchProductListingPage(\n queryClient: QueryClient,\n commerceClient: ProductListingPageCallable,\n params: ProductListingPageParams,\n options?: { staleTime?: number },\n context?: ProductMarketContext,\n): Promise<void>\nexport function prefetchProductListingPage(\n queryClient: QueryClient,\n commerceClient:\n | ProductListingPageCatalogCallable\n | ProductListingPageCallable,\n params: ProductListingPageParams = {},\n options?: { staleTime?: number },\n context?: ProductMarketContext,\n) {\n return queryClient.prefetchQuery({\n ...productListingPageQueryOptions(\n commerceClient as ProductListingPageCallable,\n params,\n context,\n ),\n ...options,\n })\n}\n\nexport function prefetchInfiniteProductListingPage(\n queryClient: QueryClient,\n commerceClient: ProductListingPageCatalogCallable,\n params?: ProductListingPageCatalogInfiniteParams,\n options?: { pages?: number; staleTime?: number },\n context?: ProductMarketContext,\n): Promise<void>\nexport function prefetchInfiniteProductListingPage(\n queryClient: QueryClient,\n commerceClient: ProductListingPageCallable,\n params?: ProductListingPageInfiniteParams,\n options?: { pages?: number; staleTime?: number },\n context?: ProductMarketContext,\n): Promise<void>\nexport function prefetchInfiniteProductListingPage(\n queryClient: QueryClient,\n commerceClient:\n | ProductListingPageCatalogCallable\n | ProductListingPageCallable,\n params: ProductListingPageInfiniteParams = {},\n options?: { pages?: number; staleTime?: number },\n context?: ProductMarketContext,\n) {\n return queryClient.prefetchInfiniteQuery({\n ...productListingPageInfiniteQueryOptions(\n commerceClient as ProductListingPageCallable,\n params,\n context,\n ),\n pages: options?.pages ?? 1,\n staleTime: options?.staleTime,\n })\n}\n\nexport class QueryHooks<\n TCollection extends ServerCollection = PublicCollection,\n> extends CollectionHooks<TCollection> {\n private _customer: CustomerHooks\n private _commerce?: ProductCommerceCallable\n private readonly market?: string\n\n constructor(\n queryClient: QueryClient,\n collectionClient: CollectionClient<TCollection>,\n customerAuth?: CustomerAuth,\n commerceClient?: ProductCommerceCallable,\n market?: string,\n ) {\n super(queryClient, collectionClient)\n this._customer = new CustomerHooks(queryClient, customerAuth)\n this._commerce = commerceClient\n this.market = normalizeMarket(market)\n }\n\n private ensureCommerce(): ProductCommerceCallable {\n if (!this._commerce) {\n throw createConfigError(\n 'Product listing page hooks require Client or ServerClient. Use createQueryHooks(client) or createServerQueryHooks(server) instead of constructing QueryHooks directly.',\n )\n }\n return this._commerce\n }\n\n private withProductMarket<T extends { market?: string }>(\n params: T | undefined,\n ): T | undefined {\n return withDefaultMarket(params, this.market)\n }\n\n // --- Customer hooks delegation ---\n useCustomerMe: CustomerHooks['useCustomerMe'] = (...args) =>\n this._customer.useCustomerMe(...args)\n useCustomerLogin: CustomerHooks['useCustomerLogin'] = (...args) =>\n this._customer.useCustomerLogin(...args)\n useCustomerRegister: CustomerHooks['useCustomerRegister'] = (...args) =>\n this._customer.useCustomerRegister(...args)\n useCustomerLogout: CustomerHooks['useCustomerLogout'] = (...args) =>\n this._customer.useCustomerLogout(...args)\n useCustomerForgotPassword: CustomerHooks['useCustomerForgotPassword'] = (\n ...args\n ) => this._customer.useCustomerForgotPassword(...args)\n useCustomerResetPassword: CustomerHooks['useCustomerResetPassword'] = (\n ...args\n ) => this._customer.useCustomerResetPassword(...args)\n useCustomerRefreshToken: CustomerHooks['useCustomerRefreshToken'] = (\n ...args\n ) => this._customer.useCustomerRefreshToken(...args)\n useCustomerUpdateProfile: CustomerHooks['useCustomerUpdateProfile'] = (\n ...args\n ) => this._customer.useCustomerUpdateProfile(...args)\n useCustomerChangePassword: CustomerHooks['useCustomerChangePassword'] = (\n ...args\n ) => this._customer.useCustomerChangePassword(...args)\n\n // --- Customer cache delegation ---\n invalidateCustomerQueries: CustomerHooks['invalidateCustomerQueries'] = () =>\n this._customer.invalidateCustomerQueries()\n getCustomerData: CustomerHooks['getCustomerData'] = () =>\n this._customer.getCustomerData()\n setCustomerData: CustomerHooks['setCustomerData'] = (data) =>\n this._customer.setCustomerData(data)\n\n useProductListingGroupsQuery<\n TData = PayloadFindResponse<ProductListingGroupsItem>,\n >(\n params: { options?: ProductListingGroupsQueryOptions },\n options?: QueryOptions<\n PayloadFindResponse<ProductListingGroupsItem>,\n TData\n >,\n ): UseQueryResult<TData> {\n const queryOptions = this.withProductMarket(params.options)\n const { placeholderData, ...restOptions } = (options ?? {}) as QueryOptions<\n PayloadFindResponse<ProductListingGroupsItem>,\n TData\n >\n\n return useQueryOriginal({\n queryKey: productKeys.listingGroups(queryOptions),\n queryFn: async () =>\n fetchProductListingGroupsQuery(this.collectionClient, queryOptions),\n ...restOptions,\n ...(placeholderData !== undefined && {\n placeholderData: placeholderData as never,\n }),\n })\n }\n\n useProductListingGroupsCatalogQuery<\n TData = PayloadFindResponse<ProductListingGroupsCatalogItem>,\n >(\n params: { options?: ProductListingGroupsQueryOptions },\n options?: QueryOptions<\n PayloadFindResponse<ProductListingGroupsCatalogItem>,\n TData\n >,\n ): UseQueryResult<TData> {\n const queryOptions = this.withProductMarket(params.options)\n const { placeholderData, ...restOptions } = (options ?? {}) as QueryOptions<\n PayloadFindResponse<ProductListingGroupsCatalogItem>,\n TData\n >\n\n return useQueryOriginal({\n queryKey: productKeys.listingGroupsCatalog(queryOptions),\n queryFn: async () =>\n fetchProductListingGroupsCatalogQuery(\n this.collectionClient,\n queryOptions,\n ),\n ...restOptions,\n ...(placeholderData !== undefined && {\n placeholderData: placeholderData as never,\n }),\n })\n }\n\n useSuspenseProductListingGroupsQuery<\n TData = PayloadFindResponse<ProductListingGroupsItem>,\n >(\n params: { options?: ProductListingGroupsQueryOptions },\n options?: SuspenseQueryOptions<\n PayloadFindResponse<ProductListingGroupsItem>,\n TData\n >,\n ): UseSuspenseQueryResult<TData> {\n const queryOptions = this.withProductMarket(params.options)\n\n return useSuspenseQueryOriginal({\n queryKey: productKeys.listingGroups(queryOptions),\n queryFn: async () =>\n fetchProductListingGroupsQuery(this.collectionClient, queryOptions),\n ...options,\n })\n }\n\n useSuspenseProductListingGroupsCatalogQuery<\n TData = PayloadFindResponse<ProductListingGroupsCatalogItem>,\n >(\n params: { options?: ProductListingGroupsQueryOptions },\n options?: SuspenseQueryOptions<\n PayloadFindResponse<ProductListingGroupsCatalogItem>,\n TData\n >,\n ): UseSuspenseQueryResult<TData> {\n const queryOptions = this.withProductMarket(params.options)\n\n return useSuspenseQueryOriginal({\n queryKey: productKeys.listingGroupsCatalog(queryOptions),\n queryFn: async () =>\n fetchProductListingGroupsCatalogQuery(\n this.collectionClient,\n queryOptions,\n ),\n ...options,\n })\n }\n\n useInfiniteProductListingGroupsQuery<\n TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>,\n >(\n params: {\n options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>\n pageSize?: number\n },\n options?: InfiniteQueryOptions<\n PayloadFindResponse<ProductListingGroupsItem>,\n TData\n >,\n ): UseInfiniteQueryResult<TData> {\n const queryOptions = this.withProductMarket(params.options)\n const explicitPageSize = params.pageSize\n const pageSize = explicitPageSize ?? 20\n\n return useInfiniteQueryOriginal({\n queryKey: productKeys.listingGroupsInfinite(\n queryOptions,\n explicitPageSize,\n ),\n queryFn: async ({ pageParam }) =>\n fetchProductListingGroupsQuery(this.collectionClient, {\n ...queryOptions,\n page: pageParam,\n limit: pageSize,\n }),\n initialPageParam: 1,\n getNextPageParam: (\n lastPage: PayloadFindResponse<ProductListingGroupsItem>,\n ) => (lastPage.hasNextPage ? lastPage.nextPage : undefined),\n ...options,\n })\n }\n\n useInfiniteProductListingGroupsCatalogQuery<\n TData = InfiniteData<PayloadFindResponse<ProductListingGroupsCatalogItem>>,\n >(\n params: {\n options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>\n pageSize?: number\n },\n options?: InfiniteQueryOptions<\n PayloadFindResponse<ProductListingGroupsCatalogItem>,\n TData\n >,\n ): UseInfiniteQueryResult<TData> {\n const queryOptions = this.withProductMarket(params.options)\n const explicitPageSize = params.pageSize\n const pageSize = explicitPageSize ?? 20\n\n return useInfiniteQueryOriginal({\n queryKey: productKeys.listingGroupsCatalogInfinite(\n queryOptions,\n explicitPageSize,\n ),\n queryFn: async ({ pageParam }) =>\n fetchProductListingGroupsCatalogQuery(this.collectionClient, {\n ...queryOptions,\n page: pageParam,\n limit: pageSize,\n }),\n initialPageParam: 1,\n getNextPageParam: (\n lastPage: PayloadFindResponse<ProductListingGroupsCatalogItem>,\n ) => (lastPage.hasNextPage ? lastPage.nextPage : undefined),\n ...options,\n })\n }\n\n useSuspenseInfiniteProductListingGroupsQuery<\n TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>,\n >(\n params: {\n options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>\n pageSize?: number\n },\n options?: SuspenseInfiniteQueryOptions<\n PayloadFindResponse<ProductListingGroupsItem>,\n TData\n >,\n ): UseSuspenseInfiniteQueryResult<TData> {\n const queryOptions = this.withProductMarket(params.options)\n const explicitPageSize = params.pageSize\n const pageSize = explicitPageSize ?? 20\n\n return useSuspenseInfiniteQueryOriginal({\n queryKey: productKeys.listingGroupsInfinite(\n queryOptions,\n explicitPageSize,\n ),\n queryFn: async ({ pageParam }) =>\n fetchProductListingGroupsQuery(this.collectionClient, {\n ...queryOptions,\n page: pageParam,\n limit: pageSize,\n }),\n initialPageParam: 1,\n getNextPageParam: (\n lastPage: PayloadFindResponse<ProductListingGroupsItem>,\n ) => (lastPage.hasNextPage ? lastPage.nextPage : undefined),\n ...options,\n })\n }\n\n useSuspenseInfiniteProductListingGroupsCatalogQuery<\n TData = InfiniteData<PayloadFindResponse<ProductListingGroupsCatalogItem>>,\n >(\n params: {\n options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>\n pageSize?: number\n },\n options?: SuspenseInfiniteQueryOptions<\n PayloadFindResponse<ProductListingGroupsCatalogItem>,\n TData\n >,\n ): UseSuspenseInfiniteQueryResult<TData> {\n const queryOptions = this.withProductMarket(params.options)\n const explicitPageSize = params.pageSize\n const pageSize = explicitPageSize ?? 20\n\n return useSuspenseInfiniteQueryOriginal({\n queryKey: productKeys.listingGroupsCatalogInfinite(\n queryOptions,\n explicitPageSize,\n ),\n queryFn: async ({ pageParam }) =>\n fetchProductListingGroupsCatalogQuery(this.collectionClient, {\n ...queryOptions,\n page: pageParam,\n limit: pageSize,\n }),\n initialPageParam: 1,\n getNextPageParam: (\n lastPage: PayloadFindResponse<ProductListingGroupsCatalogItem>,\n ) => (lastPage.hasNextPage ? lastPage.nextPage : undefined),\n ...options,\n })\n }\n\n async prefetchProductListingGroupsQuery(\n params: { options?: ProductListingGroupsQueryOptions },\n options?: { staleTime?: number },\n ) {\n const queryOptions = this.withProductMarket(params.options)\n\n return this.queryClient.prefetchQuery({\n queryKey: productKeys.listingGroups(queryOptions),\n queryFn: async () =>\n fetchProductListingGroupsQuery(this.collectionClient, queryOptions),\n ...options,\n })\n }\n\n async prefetchProductListingGroupsCatalogQuery(\n params: { options?: ProductListingGroupsQueryOptions },\n options?: { staleTime?: number },\n ) {\n const queryOptions = this.withProductMarket(params.options)\n\n return this.queryClient.prefetchQuery({\n queryKey: productKeys.listingGroupsCatalog(queryOptions),\n queryFn: async () =>\n fetchProductListingGroupsCatalogQuery(\n this.collectionClient,\n queryOptions,\n ),\n ...options,\n })\n }\n\n async prefetchInfiniteProductListingGroupsQuery(\n params: {\n options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>\n pageSize?: number\n },\n options?: { pages?: number; staleTime?: number },\n ) {\n const queryOptions = this.withProductMarket(params.options)\n const explicitPageSize = params.pageSize\n const pageSize = explicitPageSize ?? 20\n\n return this.queryClient.prefetchInfiniteQuery({\n queryKey: productKeys.listingGroupsInfinite(\n queryOptions,\n explicitPageSize,\n ),\n queryFn: async ({ pageParam }) =>\n fetchProductListingGroupsQuery(this.collectionClient, {\n ...queryOptions,\n page: pageParam,\n limit: pageSize,\n }),\n initialPageParam: 1,\n getNextPageParam: (\n lastPage: PayloadFindResponse<ProductListingGroupsItem>,\n ) => (lastPage.hasNextPage ? lastPage.nextPage : undefined),\n pages: options?.pages ?? 1,\n staleTime: options?.staleTime,\n })\n }\n\n async prefetchInfiniteProductListingGroupsCatalogQuery(\n params: {\n options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>\n pageSize?: number\n },\n options?: { pages?: number; staleTime?: number },\n ) {\n const queryOptions = this.withProductMarket(params.options)\n const explicitPageSize = params.pageSize\n const pageSize = explicitPageSize ?? 20\n\n return this.queryClient.prefetchInfiniteQuery({\n queryKey: productKeys.listingGroupsCatalogInfinite(\n queryOptions,\n explicitPageSize,\n ),\n queryFn: async ({ pageParam }) =>\n fetchProductListingGroupsCatalogQuery(this.collectionClient, {\n ...queryOptions,\n page: pageParam,\n limit: pageSize,\n }),\n initialPageParam: 1,\n getNextPageParam: (\n lastPage: PayloadFindResponse<ProductListingGroupsCatalogItem>,\n ) => (lastPage.hasNextPage ? lastPage.nextPage : undefined),\n pages: options?.pages ?? 1,\n staleTime: options?.staleTime,\n })\n }\n\n useProductListingPage<\n TData = ProductListingPageResult<ProductListingGroupsCatalogItem>,\n >(\n params?: ProductListingPageCatalogParams,\n options?: QueryOptions<\n ProductListingPageResult<ProductListingGroupsCatalogItem>,\n TData\n >,\n ): UseQueryResult<TData>\n useProductListingPage<\n TData = ProductListingPageResult<ProductListingGroupsItem>,\n >(\n params: ProductListingPageFullParams,\n options?: QueryOptions<\n ProductListingPageResult<ProductListingGroupsItem>,\n TData\n >,\n ): UseQueryResult<TData>\n useProductListingPage<\n TData =\n | ProductListingPageResult<ProductListingGroupsCatalogItem>\n | ProductListingPageResult<ProductListingGroupsItem>,\n >(\n params: ProductListingPageParams,\n options?: QueryOptions<\n | ProductListingPageResult<ProductListingGroupsCatalogItem>\n | ProductListingPageResult<ProductListingGroupsItem>,\n TData\n >,\n ): UseQueryResult<TData>\n useProductListingPage<TData = ProductListingPageUnionResult>(\n params: ProductListingPageParams = {},\n options?: ProductListingPageHookOptions<TData>,\n ): UseQueryResult<TData> {\n const { placeholderData, ...restOptions } = (options ?? {}) as QueryOptions<\n | ProductListingPageResult<ProductListingGroupsCatalogItem>\n | ProductListingPageResult<ProductListingGroupsItem>,\n unknown\n >\n\n return useQueryOriginal({\n ...productListingPageQueryOptions(this.ensureCommerce(), params, {\n market: this.market,\n }),\n ...restOptions,\n ...(placeholderData !== undefined && {\n placeholderData: placeholderData as never,\n }),\n }) as UseQueryResult<TData>\n }\n\n useSuspenseProductListingPage<\n TData = ProductListingPageResult<ProductListingGroupsCatalogItem>,\n >(\n params?: ProductListingPageCatalogParams,\n options?: SuspenseQueryOptions<\n ProductListingPageResult<ProductListingGroupsCatalogItem>,\n TData\n >,\n ): UseSuspenseQueryResult<TData>\n useSuspenseProductListingPage<\n TData = ProductListingPageResult<ProductListingGroupsItem>,\n >(\n params: ProductListingPageFullParams,\n options?: SuspenseQueryOptions<\n ProductListingPageResult<ProductListingGroupsItem>,\n TData\n >,\n ): UseSuspenseQueryResult<TData>\n useSuspenseProductListingPage<\n TData =\n | ProductListingPageResult<ProductListingGroupsCatalogItem>\n | ProductListingPageResult<ProductListingGroupsItem>,\n >(\n params: ProductListingPageParams,\n options?: SuspenseQueryOptions<\n | ProductListingPageResult<ProductListingGroupsCatalogItem>\n | ProductListingPageResult<ProductListingGroupsItem>,\n TData\n >,\n ): UseSuspenseQueryResult<TData>\n useSuspenseProductListingPage<TData = ProductListingPageUnionResult>(\n params: ProductListingPageParams = {},\n options?: ProductListingPageSuspenseHookOptions<TData>,\n ): UseSuspenseQueryResult<TData> {\n const suspenseOptions = options as\n | SuspenseQueryOptions<ProductListingPageUnionResult, TData>\n | undefined\n\n return useSuspenseQueryOriginal({\n ...productListingPageQueryOptions(this.ensureCommerce(), params, {\n market: this.market,\n }),\n ...suspenseOptions,\n }) as UseSuspenseQueryResult<TData>\n }\n\n useInfiniteProductListingPage<\n TData = InfiniteData<\n ProductListingPageResult<\n ProductListingGroupsCatalogItem | ProductListingGroupsItem\n >\n >,\n >(\n params: ProductListingPageInfiniteParams = {},\n options?: InfiniteQueryOptions<\n ProductListingPageResult<\n ProductListingGroupsCatalogItem | ProductListingGroupsItem\n >,\n TData\n >,\n ): UseInfiniteQueryResult<TData> {\n return useInfiniteQueryOriginal({\n ...productListingPageInfiniteQueryOptions(this.ensureCommerce(), params, {\n market: this.market,\n }),\n ...options,\n }) as UseInfiniteQueryResult<TData>\n }\n\n async prefetchProductListingPage(\n params?: ProductListingPageCatalogParams,\n options?: { staleTime?: number },\n ): Promise<void>\n async prefetchProductListingPage(\n params: ProductListingPageFullParams,\n options?: { staleTime?: number },\n ): Promise<void>\n async prefetchProductListingPage(\n params: ProductListingPageParams,\n options?: { staleTime?: number },\n ): Promise<void>\n async prefetchProductListingPage(\n params: ProductListingPageParams = {},\n options?: { staleTime?: number },\n ) {\n return prefetchProductListingPage(\n this.queryClient,\n this.ensureCommerce(),\n params,\n options,\n { market: this.market },\n )\n }\n\n async prefetchInfiniteProductListingPage(\n params: ProductListingPageInfiniteParams = {},\n options?: { pages?: number; staleTime?: number },\n ) {\n return prefetchInfiniteProductListingPage(\n this.queryClient,\n this.ensureCommerce(),\n params,\n options,\n { market: this.market },\n )\n }\n\n useProductDetail(\n params: ProductDetailParams,\n options?: QueryOptions<ProductDetailCatalogResult>,\n ): UseQueryResult<ProductDetailCatalogResult> {\n const discriminator = 'slug' in params ? params.slug : params.id\n const { enabled, ...restOptions } = options ?? {}\n const queryEnabled = enabled !== false && Boolean(discriminator)\n const effectiveParams = this.withProductMarket(params) ?? params\n\n return useQueryOriginal({\n queryKey: productKeys.detail(effectiveParams),\n queryFn: () => this._commerce!.product.detail(effectiveParams),\n enabled: queryEnabled,\n ...restOptions,\n }) as UseQueryResult<ProductDetailCatalogResult>\n }\n\n useProductDetailBySlug(\n slug: string,\n options?: ProductDetailConvenienceOptions,\n ): UseQueryResult<ProductDetailCatalogResult> {\n const { market, locale, fallbackLocale, ...queryOptions } = options ?? {}\n return this.useProductDetail(\n {\n slug,\n ...(market ? { market } : {}),\n ...(locale ? { locale } : {}),\n ...(fallbackLocale !== undefined ? { fallbackLocale } : {}),\n },\n queryOptions,\n )\n }\n\n useProductDetailById(\n id: string,\n options?: ProductDetailConvenienceOptions,\n ): UseQueryResult<ProductDetailCatalogResult> {\n const { market, locale, fallbackLocale, ...queryOptions } = options ?? {}\n return this.useProductDetail(\n {\n id,\n ...(market ? { market } : {}),\n ...(locale ? { locale } : {}),\n ...(fallbackLocale !== undefined ? { fallbackLocale } : {}),\n },\n queryOptions,\n )\n }\n}\n","import type {\n ProductFallbackLocaleOption,\n ProductLocaleOption,\n} from '../../api/product-api'\n\nfunction normalizedMarket(value: string | undefined): string | undefined {\n const market = value?.trim()\n return market || undefined\n}\n\ntype ProductLocaleQueryOptions = {\n locale?: ProductLocaleOption\n fallbackLocale?: ProductFallbackLocaleOption\n}\n\nfunction appendProductLocaleSearchParams(\n search: URLSearchParams,\n options?: ProductLocaleQueryOptions,\n): void {\n if (options?.locale) search.set('locale', options.locale)\n if (options?.fallbackLocale !== undefined) {\n search.set(\n 'fallbackLocale',\n options.fallbackLocale === false ? 'none' : options.fallbackLocale,\n )\n }\n}\n\nexport function productDetailSearchParams(\n params: ({ slug: string } | { id: string }) & {\n market?: string\n } & ProductLocaleQueryOptions,\n): string {\n const search = new URLSearchParams()\n if ('slug' in params) {\n search.set('slug', params.slug)\n } else {\n search.set('id', params.id)\n }\n const market = normalizedMarket(params.market)\n if (market) search.set('market', market)\n appendProductLocaleSearchParams(search, params)\n return search.toString()\n}\n\nexport function listingGroupsSearchParams(\n params: {\n productIds: string[]\n market?: string\n } & ProductLocaleQueryOptions,\n): string {\n const ids = params.productIds.map(encodeURIComponent).join(',')\n const search = new URLSearchParams()\n const market = normalizedMarket(params.market)\n if (market) search.set('market', market)\n appendProductLocaleSearchParams(search, params)\n const query = search.toString()\n return `ids=${ids}${query ? `&${query}` : ''}`\n}\n\ntype ListingGroupsQueryUrlOptions = {\n market?: string\n locale?: ProductLocaleOption\n fallbackLocale?: ProductFallbackLocaleOption\n page?: number\n limit?: number\n sort?: string | string[]\n where?: Record<string, unknown>\n}\n\nfunction appendListingGroupsQuerySearchParams(\n search: URLSearchParams,\n options?: ListingGroupsQueryUrlOptions,\n): void {\n const market = normalizedMarket(options?.market)\n if (market) search.set('market', market)\n appendProductLocaleSearchParams(search, options)\n if (options?.page != null) search.set('page', String(options.page))\n if (options?.limit != null) search.set('limit', String(options.limit))\n if (options?.sort != null) {\n const sort = options.sort\n search.set('sort', Array.isArray(sort) ? sort.join(',') : sort)\n }\n if (options?.where != null) {\n search.set('whereJson', JSON.stringify(options.where))\n }\n}\n\n/** Server-auth GET PLP listing-groups query (full variant stock fields). */\nexport function listingPageSearchParams(\n options?: ListingGroupsQueryUrlOptions,\n): string {\n const search = new URLSearchParams()\n appendListingGroupsQuerySearchParams(search, options)\n return search.toString()\n}\n\nexport function stockSnapshotSearchParams(params: {\n variantIds: string[]\n}): string {\n return `variantIds=${params.variantIds.map(encodeURIComponent).join(',')}`\n}\n","const operationBrand: unique symbol = Symbol('sdk-http-operation')\n\nexport type HttpOperation = {\n readonly [operationBrand]: true\n readonly collection: string | null\n readonly method: 'get' | 'post' | 'patch' | 'delete'\n readonly path: `/${string}`\n readonly errorFamily?: 'commerce'\n}\n\nconst operation = <\n TCollection extends string | null,\n TMethod extends HttpOperation['method'],\n TPath extends `/${string}`,\n>(\n collection: TCollection,\n method: TMethod,\n path: TPath,\n errorFamily?: HttpOperation['errorFamily'],\n) =>\n Object.freeze({\n [operationBrand]: true,\n collection,\n method,\n path,\n ...(errorFamily && { errorFamily }),\n } as const)\n\nconst strictCommerceOperation = <\n TCollection extends string | null,\n TMethod extends HttpOperation['method'],\n TPath extends `/${string}`,\n>(\n collection: TCollection,\n method: TMethod,\n path: TPath,\n) => operation(collection, method, path, 'commerce')\n\nexport const COMMERCE_ENDPOINT_OPERATIONS = {\n products: {\n detail: operation('products', 'get', '/detail'),\n detailCatalog: operation('products', 'get', '/detail/catalog'),\n listingGroups: operation('products', 'get', '/listing-groups'),\n listingGroupsCatalog: operation(\n 'products',\n 'get',\n '/listing-groups/catalog',\n ),\n listingGroupsQuery: operation('products', 'post', '/listing-groups/query'),\n listingGroupsQueryGet: operation(\n 'products',\n 'get',\n '/listing-groups/query',\n ),\n listingGroupsQueryCatalog: operation(\n 'products',\n 'get',\n '/listing-groups/query/catalog',\n ),\n stockCheck: operation('products', 'post', '/stock-check'),\n stockSnapshot: operation('products', 'get', '/stock'),\n upsert: operation('products', 'post', '/upsert'),\n },\n orders: {\n create: operation('orders', 'post', '/create'),\n update: operation('orders', 'post', '/update'),\n confirmPayment: operation('orders', 'post', '/confirm-payment'),\n byPayment: operation('orders', 'get', '/by-payment'),\n cancel: operation('orders', 'post', '/cancel'),\n resolveCancelRefund: operation('orders', 'post', '/resolve-cancel-refund'),\n checkout: strictCommerceOperation('orders', 'post', '/checkout'),\n createFulfillment: operation('orders', 'post', '/create-fulfillment'),\n updateFulfillment: operation('orders', 'post', '/update-fulfillment'),\n },\n checkouts: {\n detail: strictCommerceOperation('checkouts', 'post', '/detail'),\n query: strictCommerceOperation('checkouts', 'post', '/query'),\n },\n transactions: {\n update: operation('transactions', 'post', '/update'),\n },\n returns: {\n create: operation('returns', 'post', '/create'),\n update: operation('returns', 'post', '/update'),\n returnRefund: operation('returns', 'post', '/return-refund'),\n },\n fulfillmentOrders: {\n prepare: operation(\n 'fulfillment-orders',\n 'post',\n '/prepare-fulfillment-order',\n ),\n },\n fulfillments: {\n bulkImport: operation('fulfillments', 'post', '/bulk-import'),\n },\n carts: {\n create: strictCommerceOperation('carts', 'post', '/create'),\n retrieve: strictCommerceOperation('carts', 'post', '/retrieve'),\n mine: strictCommerceOperation('carts', 'post', '/mine'),\n merge: strictCommerceOperation('carts', 'post', '/merge'),\n addItem: strictCommerceOperation('carts', 'post', '/add-item'),\n updateItem: strictCommerceOperation('carts', 'post', '/update-item'),\n removeItem: strictCommerceOperation('carts', 'post', '/remove-item'),\n updateDiscountCodes: strictCommerceOperation(\n 'carts',\n 'post',\n '/update-discount-codes',\n ),\n updateAttributes: strictCommerceOperation(\n 'carts',\n 'post',\n '/update-attributes',\n ),\n clear: strictCommerceOperation('carts', 'post', '/clear'),\n },\n paymentSessions: {\n create: strictCommerceOperation('payment-sessions', 'post', '/create'),\n retrieve: strictCommerceOperation('payment-sessions', 'post', '/retrieve'),\n cancel: strictCommerceOperation('payment-sessions', 'post', '/cancel'),\n server: {\n create: strictCommerceOperation(\n 'payment-sessions',\n 'post',\n '/server/create',\n ),\n retrieve: strictCommerceOperation(\n 'payment-sessions',\n 'post',\n '/server/retrieve',\n ),\n cancel: strictCommerceOperation(\n 'payment-sessions',\n 'post',\n '/server/cancel',\n ),\n confirm: strictCommerceOperation(\n 'payment-sessions',\n 'post',\n '/server/confirm',\n ),\n },\n custom: {\n create: operation('orders', 'post', '/custom-payment-sessions'),\n retrieve: operation(\n 'orders',\n 'post',\n '/custom-payment-sessions/retrieve',\n ),\n confirm: operation('orders', 'post', '/custom-payment-sessions/confirm'),\n },\n },\n shippingPolicies: {\n calculate: operation('shipping-policies', 'post', '/calculate'),\n },\n discounts: {\n validate: operation('discounts', 'post', '/validate'),\n },\n} as const\n\nexport const MEMBERSHIP_ENDPOINT_OPERATIONS = {\n subscribe: operation(null, 'post', '/memberships/subscribe'),\n cancel: operation(null, 'post', '/memberships/:id/cancel'),\n me: operation(null, 'get', '/memberships/me'),\n} as const\n\n/** Public, shaped browser reads served by the event-occurrences collection. */\nexport const EVENTS_ENDPOINT_OPERATIONS = {\n occurrences: {\n range: operation('event-occurrences', 'get', '/range'),\n admissionAvailability: operation(\n 'event-occurrences',\n 'get',\n '/admission-availability',\n ),\n },\n} as const\n\n/** Public, shaped browser reads served by community collections. */\nexport const COMMUNITY_ENDPOINT_OPERATIONS = {\n posts: {\n detail: operation('posts', 'get', '/detail'),\n },\n} as const\n\nexport function resolveOperationTemplate(descriptor: HttpOperation): string {\n return descriptor.collection\n ? `/api/${descriptor.collection}${descriptor.path}`\n : `/api${descriptor.path}`\n}\n\nexport function resolveOperationPath(\n descriptor: HttpOperation,\n options?: {\n pathParams?: Readonly<Record<string, string>>\n query?: string | URLSearchParams\n },\n): string {\n const path = resolveOperationTemplate(descriptor).replace(\n /:([A-Za-z][A-Za-z0-9_]*)/g,\n (_, key) => {\n const value = options?.pathParams?.[key]\n if (value === undefined) {\n throw new TypeError(`Missing path parameter: ${key}`)\n }\n return encodeURIComponent(value)\n },\n )\n const unresolved = path.match(/:([A-Za-z][A-Za-z0-9_]*)/)\n if (unresolved) {\n throw new TypeError(`Missing path parameter: ${unresolved[1]}`)\n }\n\n const query = options?.query?.toString().replace(/^\\?/, '')\n return query ? `${path}?${query}` : path\n}\n\nexport function resolveOperationMethod(\n descriptor: HttpOperation,\n): Uppercase<HttpOperation['method']> {\n return descriptor.method.toUpperCase() as Uppercase<HttpOperation['method']>\n}\n","/**\n * Single source of truth for the commerce HTTP paths the SDK calls.\n *\n * Console exposes these as `slug + Endpoint.path` on collection configs; the SDK\n * has to hardcode the joined `/api/<slug>/<path>` because it cannot import the\n * Console at build time. To stop a Console path change from silently turning into\n * a runtime 404, non-quarantined values are cross-checked against live Console\n * endpoint registration by `apps/console/tests/unit/sdk/endpoint-parity.test.ts`.\n * That test also records canonical Phase 1 operations whose route is absent or\n * whose same-path legacy handler is not yet contract-compatible; registration\n * alone must never be interpreted as transport parity.\n *\n * Keep this internal — it is the transport contract, not public SDK surface.\n */\ntype CanonicalCommerceEndpointDescriptor = {\n readonly method: 'GET' | 'POST' | 'PATCH' | 'DELETE'\n readonly path: string\n}\n\nexport type CommerceEndpointDescriptor =\n | CanonicalCommerceEndpointDescriptor\n | HttpOperation\n\nconst endpoint = (\n method: CanonicalCommerceEndpointDescriptor['method'],\n path: string,\n): CanonicalCommerceEndpointDescriptor => ({ method, path })\n\nconst sharedEndpoint = (descriptor: HttpOperation): HttpOperation => descriptor\n\nexport function resolveOperationMethod(\n descriptor: CommerceEndpointDescriptor,\n): 'GET' | 'POST' | 'PATCH' | 'DELETE' {\n return 'collection' in descriptor\n ? resolveSharedOperationMethod(descriptor)\n : descriptor.method\n}\n\nexport function resolveOperationErrorFamily(\n descriptor: CommerceEndpointDescriptor,\n): 'commerce' | undefined {\n return 'collection' in descriptor ? descriptor.errorFamily : undefined\n}\n\nexport function resolveOperationPath(\n descriptor: CommerceEndpointDescriptor,\n options?: {\n pathParams?: Readonly<Record<string, string>>\n query?: string | URLSearchParams\n },\n): string {\n if ('collection' in descriptor) {\n return resolveSharedOperationPath(descriptor, options)\n }\n const query = options?.query?.toString().replace(/^\\?/, '')\n return query ? `${descriptor.path}?${query}` : descriptor.path\n}\n\nexport const COMMERCE_ENDPOINTS = {\n products: {\n detail: endpoint('GET', '/api/products/detail'),\n detailCatalog: endpoint('GET', '/api/products/detail/catalog'),\n listingGroups: endpoint('GET', '/api/products/listing-groups'),\n listingGroupsCatalog: endpoint(\n 'GET',\n '/api/products/listing-groups/catalog',\n ),\n listingGroupsQuery: endpoint('GET', '/api/products/listing-groups/query'),\n listingGroupsQueryCatalog: endpoint(\n 'GET',\n '/api/products/listing-groups/query/catalog',\n ),\n stockCheck: endpoint('POST', '/api/products/stock-check'),\n stockSnapshot: endpoint('GET', '/api/products/stock'),\n upsert: endpoint('POST', '/api/products/upsert'),\n },\n orders: {\n update: endpoint('POST', '/api/orders/update'),\n byPayment: endpoint('GET', '/api/orders/by-payment'),\n cancel: endpoint('POST', '/api/orders/cancel'),\n resolveCancelRefund: endpoint('POST', '/api/orders/resolve-cancel-refund'),\n createFulfillment: endpoint('POST', '/api/orders/create-fulfillment'),\n updateFulfillment: endpoint('POST', '/api/orders/update-fulfillment'),\n },\n checkouts: {\n create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.checkout),\n retrieve: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.checkouts.detail),\n server: {\n create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.orders.checkout),\n retrieve: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.checkouts.detail),\n query: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.checkouts.query),\n },\n },\n returns: {\n create: endpoint('POST', '/api/returns/create'),\n update: endpoint('POST', '/api/returns/update'),\n returnRefund: endpoint('POST', '/api/returns/return-refund'),\n },\n fulfillmentOrders: {\n prepare: endpoint(\n 'POST',\n '/api/fulfillment-orders/prepare-fulfillment-order',\n ),\n },\n fulfillments: {\n bulkImport: endpoint('POST', '/api/fulfillments/bulk-import'),\n },\n carts: {\n create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.create),\n retrieve: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.retrieve),\n mine: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.mine),\n merge: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.merge),\n server: {\n // Server credentials are an authorization lane, not a second Cart\n // transport. These must stay bound to the registered shared operations.\n create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.create),\n retrieve: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.retrieve),\n mine: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.mine),\n merge: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.merge),\n addItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.addItem),\n updateItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.updateItem),\n removeItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.removeItem),\n updateDiscountCodes: sharedEndpoint(\n COMMERCE_ENDPOINT_OPERATIONS.carts.updateDiscountCodes,\n ),\n updateAttributes: sharedEndpoint(\n COMMERCE_ENDPOINT_OPERATIONS.carts.updateAttributes,\n ),\n clear: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.clear),\n },\n addItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.addItem),\n updateItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.updateItem),\n removeItem: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.removeItem),\n updateDiscountCodes: sharedEndpoint(\n COMMERCE_ENDPOINT_OPERATIONS.carts.updateDiscountCodes,\n ),\n updateAttributes: sharedEndpoint(\n COMMERCE_ENDPOINT_OPERATIONS.carts.updateAttributes,\n ),\n clear: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.carts.clear),\n },\n paymentSessions: {\n create: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.create),\n retrieve: sharedEndpoint(\n COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.retrieve,\n ),\n cancel: sharedEndpoint(COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.cancel),\n custom: {\n create: sharedEndpoint(\n COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.custom.create,\n ),\n retrieve: sharedEndpoint(\n COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.custom.retrieve,\n ),\n confirm: sharedEndpoint(\n COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.custom.confirm,\n ),\n },\n server: {\n create: sharedEndpoint(\n COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.create,\n ),\n retrieve: sharedEndpoint(\n COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.retrieve,\n ),\n cancel: sharedEndpoint(\n COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.cancel,\n ),\n confirm: sharedEndpoint(\n COMMERCE_ENDPOINT_OPERATIONS.paymentSessions.server.confirm,\n ),\n },\n },\n shippingPolicies: {\n calculate: endpoint('POST', '/api/shipping-policies/calculate'),\n },\n} as const\n\nfunction isCommerceEndpointDescriptor(\n value: unknown,\n): value is CommerceEndpointDescriptor {\n if (!value || typeof value !== 'object') return false\n const candidate = value as Record<string, unknown>\n return (\n typeof candidate.method === 'string' && typeof candidate.path === 'string'\n )\n}\n\nfunction flattenEndpointPaths(value: unknown): string[] {\n if (isCommerceEndpointDescriptor(value)) return [resolveOperationPath(value)]\n if (!value || typeof value !== 'object') return []\n return Object.values(value).flatMap((entry) => flattenEndpointPaths(entry))\n}\n\nfunction flattenEndpointDescriptors(\n value: unknown,\n): CommerceEndpointDescriptor[] {\n if (isCommerceEndpointDescriptor(value)) return [value]\n if (!value || typeof value !== 'object') return []\n return Object.values(value).flatMap((entry) =>\n flattenEndpointDescriptors(entry),\n )\n}\n\n/** Flat list of every commerce path the SDK declares — for the parity guard. */\nexport const COMMERCE_ENDPOINT_PATHS: readonly string[] =\n flattenEndpointPaths(COMMERCE_ENDPOINTS)\n\n/** Method-aware commerce descriptors covered by Console endpoint parity. */\nexport const COMMERCE_ENDPOINT_DESCRIPTORS: readonly CommerceEndpointDescriptor[] =\n flattenEndpointDescriptors(COMMERCE_ENDPOINTS)\n\n/**\n * Single source of truth for the membership HTTP paths the SDK calls.\n *\n * Mirrors `COMMERCE_ENDPOINTS` conventions. The `cancel` and webhook paths\n * are parameterised because they operate on a specific membership document.\n * Keep in sync with the Console collection endpoint registration.\n */\nexport const MEMBERSHIP_ENDPOINTS = {\n subscribe: '/api/memberships/subscribe',\n cancel: (id: string) => `/api/memberships/${id}/cancel` as const,\n me: '/api/memberships/me',\n} as const\n\n/** Flat list of every membership path the SDK declares — for the parity guard. */\nexport const MEMBERSHIP_ENDPOINT_PATHS: readonly string[] = [\n MEMBERSHIP_ENDPOINTS.subscribe,\n MEMBERSHIP_ENDPOINTS.cancel(':id'),\n MEMBERSHIP_ENDPOINTS.me,\n]\nimport {\n COMMERCE_ENDPOINT_OPERATIONS,\n MEMBERSHIP_ENDPOINT_OPERATIONS,\n resolveOperationMethod as resolveSharedOperationMethod,\n resolveOperationPath as resolveSharedOperationPath,\n type HttpOperation,\n} from '@01.software/http-contracts'\n\nexport { COMMERCE_ENDPOINT_OPERATIONS, MEMBERSHIP_ENDPOINT_OPERATIONS }\n","/**\n * Fetch-based SSE connection manager for real-time collection change events.\n * Uses fetch + ReadableStream to support custom auth headers (unlike native EventSource).\n */\n\nexport interface RealtimeEvent {\n collection: string\n operation: string\n id: string | null\n timestamp: string\n}\n\nexport type RealtimeListener = (event: RealtimeEvent) => void\n\nconst INITIAL_RECONNECT_DELAY = 1_000\nconst MAX_RECONNECT_DELAY = 30_000\nconst RECONNECT_BACKOFF_FACTOR = 2\nconst MAX_NO_TOKEN_RETRIES = 5\n\nexport class RealtimeConnection {\n private abortController: AbortController | null = null\n private reconnectAttempt = 0\n private noTokenAttempts = 0\n private reconnectTimer: ReturnType<typeof setTimeout> | null = null\n private listeners = new Set<RealtimeListener>()\n private _connected = false\n\n constructor(\n private baseUrl: string,\n private publishableKey: string,\n private getToken: () => string | null,\n private collections?: string[],\n ) {}\n\n get connected(): boolean {\n return this._connected\n }\n\n addListener(fn: RealtimeListener): () => void {\n this.listeners.add(fn)\n return () => this.listeners.delete(fn)\n }\n\n connect(): void {\n if (this.abortController) return // Already connecting/connected\n\n this.abortController = new AbortController()\n this.startStream(this.abortController.signal)\n }\n\n disconnect(): void {\n this._connected = false\n if (this.reconnectTimer) {\n clearTimeout(this.reconnectTimer)\n this.reconnectTimer = null\n }\n if (this.abortController) {\n this.abortController.abort()\n this.abortController = null\n }\n this.reconnectAttempt = 0\n this.noTokenAttempts = 0\n }\n\n private async startStream(signal: AbortSignal): Promise<void> {\n const token = this.getToken()\n if (!token) {\n this.noTokenAttempts++\n if (this.noTokenAttempts >= MAX_NO_TOKEN_RETRIES) {\n // Stop reconnecting — no token available after multiple attempts\n this._connected = false\n this.abortController = null\n return\n }\n this.scheduleReconnect()\n return\n }\n this.noTokenAttempts = 0\n\n const params = this.collections?.length\n ? `?collections=${this.collections.join(',')}`\n : ''\n const url = `${this.baseUrl}/api/events/stream${params}`\n\n try {\n const response = await fetch(url, {\n headers: {\n 'X-Publishable-Key': this.publishableKey,\n Authorization: `Bearer ${token}`,\n },\n signal,\n })\n\n if (!response.ok) {\n if (response.status === 401) {\n // Token expired — try reconnecting (will get fresh token)\n this.scheduleReconnect()\n return\n }\n throw new Error(`SSE connection failed: ${response.status}`)\n }\n\n if (!response.body) {\n throw new Error('SSE response has no body')\n }\n\n this._connected = true\n this.reconnectAttempt = 0\n\n await this.readStream(response.body, signal)\n } catch {\n if (signal.aborted) return // Intentional disconnect\n this._connected = false\n this.scheduleReconnect()\n }\n }\n\n private async readStream(\n body: ReadableStream<Uint8Array>,\n signal: AbortSignal,\n ): Promise<void> {\n const reader = body.getReader()\n const decoder = new TextDecoder()\n let buffer = ''\n let currentEvent = ''\n let currentData = ''\n\n try {\n while (true) {\n const { done, value } = await reader.read()\n if (done || signal.aborted) break\n\n buffer += decoder.decode(value, { stream: true })\n const lines = buffer.split('\\n')\n buffer = lines.pop() ?? '' // Keep incomplete last line in buffer\n\n for (const line of lines) {\n if (line.startsWith('event: ')) {\n currentEvent = line.slice(7)\n } else if (line.startsWith('data: ')) {\n currentData += (currentData ? '\\n' : '') + line.slice(6)\n } else if (line === '') {\n // Empty line = end of event\n if (currentEvent === 'collection:change' && currentData) {\n try {\n const event: RealtimeEvent = JSON.parse(currentData)\n for (const listener of this.listeners) {\n try {\n listener(event)\n } catch {\n // Listener error — ignore\n }\n }\n } catch {\n // Malformed JSON — ignore\n }\n }\n currentEvent = ''\n currentData = ''\n }\n // Ignore comment lines (: heartbeat)\n }\n }\n } catch {\n // Stream read error\n } finally {\n reader.releaseLock()\n this._connected = false\n if (!signal.aborted) {\n this.scheduleReconnect()\n }\n }\n }\n\n private scheduleReconnect(): void {\n if (this.reconnectTimer) return\n\n const delay = Math.min(\n INITIAL_RECONNECT_DELAY *\n Math.pow(RECONNECT_BACKOFF_FACTOR, this.reconnectAttempt),\n MAX_RECONNECT_DELAY,\n )\n this.reconnectAttempt++\n\n this.reconnectTimer = setTimeout(() => {\n this.reconnectTimer = null\n this.abortController = new AbortController()\n this.startStream(this.abortController.signal)\n }, delay)\n }\n}\n","import type {\n PublicCollection,\n RootClient,\n RootServerClient,\n ServerCollection,\n} from '../client/types'\nimport type { CollectionClient, ServerCollectionClient } from '../collection'\nimport { QueryHooks, type ReadOnlyQueryHooks } from './query-hooks'\nimport { getQueryClient } from './get-query-client'\nimport type { QueryClient } from '@tanstack/react-query'\n\nfunction getClientMarket(client: {\n getConfig?: () => { market?: string | undefined }\n}): string | undefined {\n return client.getConfig?.().market\n}\n\nfunction createReadOnlyQueryHooksFacade(\n hooks: QueryHooks<PublicCollection>,\n): ReadOnlyQueryHooks {\n return {\n useQuery: hooks.useQuery.bind(hooks),\n useSuspenseQuery: hooks.useSuspenseQuery.bind(hooks),\n useQueryById: hooks.useQueryById.bind(hooks),\n useSuspenseQueryById: hooks.useSuspenseQueryById.bind(hooks),\n useInfiniteQuery: hooks.useInfiniteQuery.bind(hooks),\n useSuspenseInfiniteQuery: hooks.useSuspenseInfiniteQuery.bind(hooks),\n prefetchQuery: hooks.prefetchQuery.bind(hooks),\n prefetchQueryById: hooks.prefetchQueryById.bind(hooks),\n prefetchInfiniteQuery: hooks.prefetchInfiniteQuery.bind(hooks),\n invalidateQueries: hooks.invalidateQueries.bind(hooks),\n getQueryData: hooks.getQueryData.bind(hooks),\n setQueryData: hooks.setQueryData.bind(hooks),\n useCustomerMe: hooks.useCustomerMe.bind(hooks),\n useCustomerLogin: hooks.useCustomerLogin.bind(hooks),\n useCustomerRegister: hooks.useCustomerRegister.bind(hooks),\n useCustomerLogout: hooks.useCustomerLogout.bind(hooks),\n useCustomerForgotPassword: hooks.useCustomerForgotPassword.bind(hooks),\n useCustomerResetPassword: hooks.useCustomerResetPassword.bind(hooks),\n useCustomerRefreshToken: hooks.useCustomerRefreshToken.bind(hooks),\n useCustomerUpdateProfile: hooks.useCustomerUpdateProfile.bind(hooks),\n useCustomerChangePassword: hooks.useCustomerChangePassword.bind(hooks),\n invalidateCustomerQueries: hooks.invalidateCustomerQueries.bind(hooks),\n getCustomerData: hooks.getCustomerData.bind(hooks),\n setCustomerData: hooks.setCustomerData.bind(hooks),\n useProductListingGroupsCatalogQuery:\n hooks.useProductListingGroupsCatalogQuery.bind(hooks),\n useSuspenseProductListingGroupsCatalogQuery:\n hooks.useSuspenseProductListingGroupsCatalogQuery.bind(hooks),\n useInfiniteProductListingGroupsCatalogQuery:\n hooks.useInfiniteProductListingGroupsCatalogQuery.bind(hooks),\n useSuspenseInfiniteProductListingGroupsCatalogQuery:\n hooks.useSuspenseInfiniteProductListingGroupsCatalogQuery.bind(hooks),\n prefetchProductListingGroupsCatalogQuery:\n hooks.prefetchProductListingGroupsCatalogQuery.bind(hooks),\n prefetchInfiniteProductListingGroupsCatalogQuery:\n hooks.prefetchInfiniteProductListingGroupsCatalogQuery.bind(hooks),\n useProductListingPage: hooks.useProductListingPage.bind(hooks),\n useSuspenseProductListingPage:\n hooks.useSuspenseProductListingPage.bind(hooks),\n useInfiniteProductListingPage:\n hooks.useInfiniteProductListingPage.bind(hooks),\n prefetchProductListingPage: hooks.prefetchProductListingPage.bind(hooks),\n prefetchInfiniteProductListingPage:\n hooks.prefetchInfiniteProductListingPage.bind(hooks),\n useProductDetail: hooks.useProductDetail.bind(hooks),\n useProductDetailBySlug: hooks.useProductDetailBySlug.bind(hooks),\n useProductDetailById: hooks.useProductDetailById.bind(hooks),\n } as ReadOnlyQueryHooks\n}\n\nexport function createQueryHooks(\n client: RootClient,\n queryClient: QueryClient = getQueryClient(),\n): ReadOnlyQueryHooks {\n const hooks = new QueryHooks<PublicCollection>(\n queryClient,\n client.collections as unknown as CollectionClient<PublicCollection>,\n client.customer.auth,\n client.commerce as never,\n getClientMarket(client),\n )\n\n return createReadOnlyQueryHooksFacade(hooks)\n}\n\nexport function createServerQueryHooks(\n client: RootServerClient,\n queryClient: QueryClient = getQueryClient(),\n): QueryHooks<ServerCollection> {\n return new QueryHooks<ServerCollection>(\n queryClient,\n client.collections as ServerCollectionClient,\n undefined,\n client.commerce,\n getClientMarket(client),\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,yBAIO;AAEP,SAAS,kBAAkB;AACzB,SAAO,IAAI,+BAAY;AAAA,IACrB,gBAAgB;AAAA,MACd,SAAS;AAAA;AAAA;AAAA;AAAA,QAIP,WAAW,OAAO;AAAA,QAClB,sBAAsB;AAAA,MACxB;AAAA,MACA,WAAW;AAAA,QACT,sBAAsB,CAAC,cACrB,gDAA4B,KAAK,KACjC,MAAM,MAAM,WAAW;AAAA,QACzB,oBAAoB,MAAM;AAAA,MAC5B;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEA,IAAI;AACJ,IAAI;AAGG,SAAS,iBAAiB;AAC/B,MAAI,6BAAU;AACZ,WAAO,gBAAgB;AAAA,EACzB;AACA,MAAI,CAAC,oBAAoB;AACvB,yBAAqB,gBAAgB;AAAA,EACvC;AACA,SAAO;AACT;AAEA,IAAM,2BAA2B;AAEjC,SAAS,4BAA4B;AACnC,SAAO,IAAI,+BAAY;AAAA,IACrB,gBAAgB;AAAA,MACd,SAAS;AAAA,QACP,WAAW;AAAA,QACX,sBAAsB;AAAA,MACxB;AAAA,MACA,WAAW;AAAA,QACT,sBAAsB,CAAC,cACrB,gDAA4B,KAAK,KACjC,MAAM,MAAM,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AK,KAAK;AAAA,IAChD,4BAA4B,MAAM,2BAA2B,KAAK,KAAK;AAAA,IACvE,oCACE,MAAM,mCAAmC,KAAK,KAAK;AAAA,IACrD,kBAAkB,MAAM,iBAAiB,KAAK,KAAK;AAAA,IACnD,wBAAwB,MAAM,uBAAuB,KAAK,KAAK;AAAA,IAC/D,sBAAsB,MAAM,qBAAqB,KAAK,KAAK;AAAA,EAC7D;AACF;AAEO,SAAS,iBACd,QACA,cAA2B,eAAe,GACtB;AACpB,QAAM,QAAQ,IAAI;AAAA,IAChB;AAAA,IACA,OAAO;AAAA,IACP,OAAO,SAAS;AAAA,IAChB,OAAO;AAAA,IACP,gBAAgB,MAAM;AAAA,EACxB;AAEA,SAAO,+BAA+B,KAAK;AAC7C;AAEO,SAAS,uBACd,QACA,cAA2B,eAAe,GACZ;AAC9B,SAAO,IAAI;AAAA,IACT;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA,OAAO;AAAA,IACP,gBAAgB,MAAM;AAAA,EACxB;AACF;","names":["import_react_query","useQueryOriginal","useSuspenseQueryOriginal","useInfiniteQueryOriginal","useSuspenseInfiniteQueryOriginal","useMutationOriginal","import_react_query","useMutationOriginal","useQueryOriginal","import_react_query","resolveOperationPath","endpoint","resolveOperationPath","useQueryOriginal","useSuspenseQueryOriginal","useInfiniteQueryOriginal","useSuspenseInfiniteQueryOriginal"]}