@01.software/sdk 0.33.0 → 0.34.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 (70) hide show
  1. package/README.md +214 -22
  2. package/dist/analytics/react.cjs.map +1 -1
  3. package/dist/analytics/react.js.map +1 -1
  4. package/dist/analytics.cjs.map +1 -1
  5. package/dist/analytics.js.map +1 -1
  6. package/dist/client.cjs +341 -26
  7. package/dist/client.cjs.map +1 -1
  8. package/dist/client.d.cts +7 -6
  9. package/dist/client.d.ts +7 -6
  10. package/dist/client.js +341 -26
  11. package/dist/client.js.map +1 -1
  12. package/dist/{collection-client-De6eKW1J.d.cts → collection-client-CR2B8c1v.d.cts} +7 -3
  13. package/dist/{collection-client-B6SlhzIP.d.ts → collection-client-DkREjhQ9.d.ts} +7 -3
  14. package/dist/{const-sPR2IkCe.d.cts → const-BTvdrXtY.d.cts} +4 -4
  15. package/dist/{const-DwmSDeWq.d.ts → const-CdqCauHQ.d.ts} +4 -4
  16. package/dist/index-CjA3U6X3.d.cts +186 -0
  17. package/dist/index-DK8_NXkh.d.ts +186 -0
  18. package/dist/index.cjs +1401 -176
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +74 -9
  21. package/dist/index.d.ts +74 -9
  22. package/dist/index.js +1401 -176
  23. package/dist/index.js.map +1 -1
  24. package/dist/{payload-types-dkeQyrDC.d.cts → payload-types-C7tb7Xbs.d.cts} +208 -52
  25. package/dist/{payload-types-dkeQyrDC.d.ts → payload-types-C7tb7Xbs.d.ts} +208 -52
  26. package/dist/query.cjs +194 -35
  27. package/dist/query.cjs.map +1 -1
  28. package/dist/query.d.cts +44 -17
  29. package/dist/query.d.ts +44 -17
  30. package/dist/query.js +194 -35
  31. package/dist/query.js.map +1 -1
  32. package/dist/realtime.cjs.map +1 -1
  33. package/dist/realtime.d.cts +2 -2
  34. package/dist/realtime.d.ts +2 -2
  35. package/dist/realtime.js.map +1 -1
  36. package/dist/{server-CrsPyqEc.d.cts → server-nXOezi4b.d.cts} +22 -6
  37. package/dist/{server-CrsPyqEc.d.ts → server-nXOezi4b.d.ts} +22 -6
  38. package/dist/server.cjs +439 -32
  39. package/dist/server.cjs.map +1 -1
  40. package/dist/server.d.cts +11 -179
  41. package/dist/server.d.ts +11 -179
  42. package/dist/server.js +439 -32
  43. package/dist/server.js.map +1 -1
  44. package/dist/{types-Cel_4L9t.d.ts → types-1ylMrCuW.d.ts} +1 -1
  45. package/dist/{types-B3YT092I.d.cts → types-Bx558PU6.d.cts} +1 -1
  46. package/dist/{types-BHh0YLmq.d.ts → types-Byo_Rty4.d.ts} +705 -69
  47. package/dist/{types-BZKxss8Y.d.cts → types-DDhtZI6E.d.cts} +705 -69
  48. package/dist/ui/canvas/server.cjs +231 -38
  49. package/dist/ui/canvas/server.cjs.map +1 -1
  50. package/dist/ui/canvas/server.d.cts +1 -1
  51. package/dist/ui/canvas/server.d.ts +1 -1
  52. package/dist/ui/canvas/server.js +221 -38
  53. package/dist/ui/canvas/server.js.map +1 -1
  54. package/dist/ui/canvas.cjs +320 -257
  55. package/dist/ui/canvas.cjs.map +1 -1
  56. package/dist/ui/canvas.d.cts +5 -19
  57. package/dist/ui/canvas.d.ts +5 -19
  58. package/dist/ui/canvas.js +323 -260
  59. package/dist/ui/canvas.js.map +1 -1
  60. package/dist/ui/form.d.cts +1 -1
  61. package/dist/ui/form.d.ts +1 -1
  62. package/dist/ui/video.d.cts +1 -1
  63. package/dist/ui/video.d.ts +1 -1
  64. package/dist/webhook.cjs +2 -1
  65. package/dist/webhook.cjs.map +1 -1
  66. package/dist/webhook.d.cts +20 -179
  67. package/dist/webhook.d.ts +20 -179
  68. package/dist/webhook.js +2 -1
  69. package/dist/webhook.js.map +1 -1
  70. package/package.json +4 -5
package/dist/query.d.cts CHANGED
@@ -1,16 +1,21 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { QueryClient, UseQueryResult, UseSuspenseQueryResult, InfiniteData, UseInfiniteQueryResult, UseSuspenseInfiniteQueryResult } from '@tanstack/react-query';
3
- import { A as ApiQueryOptions, P as PayloadFindResponse, g as PayloadMutationResponse, J as CustomerAuth, N as CustomerProfile, L as CustomerAuthResponse, M as CustomerLoginData, T as CustomerRegisterResponse, Q as CustomerRegisterData, O as CustomerRefreshResponse, b1 as UpdateProfileData, ad as ProductDetailParams, ae as ProductDetailResult, at as ProductListingGroupsItem, h as RootClient } from './types-BZKxss8Y.cjs';
4
- import './payload-types-dkeQyrDC.cjs';
5
- import { C as CollectionClient } from './collection-client-De6eKW1J.cjs';
6
- import { c as ServerCollection, P as PublicCollection } from './const-sPR2IkCe.cjs';
7
- import { C as CollectionType } from './types-B3YT092I.cjs';
3
+ import { A as ApiQueryOptions, P as PayloadFindResponse, h as PayloadMutationResponse, a8 as CustomerAuth, a9 as CustomerProfile, aa as CustomerAuthResponse, ab as CustomerLoginData, ac as CustomerRegisterResponse, ad as CustomerRegisterData, ae as CustomerRefreshResponse, af as UpdateProfileData, ag as ProductDetailParams, ah as ProductDetailResult, ai as ProductListingGroupsItem, i as RootClient, Y as RootServerClient } from './types-DDhtZI6E.cjs';
4
+ import './payload-types-C7tb7Xbs.cjs';
5
+ import { C as CollectionClient } from './collection-client-CR2B8c1v.cjs';
6
+ import { S as ServerCollection, P as PublicCollection } from './const-BTvdrXtY.cjs';
7
+ import { C as CollectionType } from './types-Bx558PU6.cjs';
8
8
  import { S as SDKError } from './index-BGEhoDUs.cjs';
9
9
  export { a as RealtimeConnection, R as RealtimeEvent, b as RealtimeListener } from './realtime-D7HtUpqt.cjs';
10
- import { ServerClient } from './server.cjs';
11
10
  import './metadata.cjs';
12
11
 
12
+ /** Default React Query client (SSR hydration-friendly: infinite staleTime). */
13
13
  declare function getQueryClient(): QueryClient;
14
+ /**
15
+ * Browser storefront client: refetches catalog data after ~1 minute instead of
16
+ * keeping SSR data fresh forever. Use with `createQueryHooks(client, queryClient)`.
17
+ */
18
+ declare function getStorefrontQueryClient(): QueryClient;
14
19
 
15
20
  interface CollectionQueryParams<T extends ServerCollection> {
16
21
  collection: T;
@@ -172,22 +177,41 @@ declare class QueryHooks<TCollection extends ServerCollection = PublicCollection
172
177
  useProductListingGroupsQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
173
178
  options?: ProductListingGroupsQueryOptions;
174
179
  }, options?: QueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): UseQueryResult<TData>;
180
+ useProductListingGroupsCatalogQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
181
+ options?: ProductListingGroupsQueryOptions;
182
+ }, options?: QueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): UseQueryResult<TData>;
175
183
  useSuspenseProductListingGroupsQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
176
184
  options?: ProductListingGroupsQueryOptions;
177
185
  }, options?: SuspenseQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): UseSuspenseQueryResult<TData>;
186
+ useSuspenseProductListingGroupsCatalogQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
187
+ options?: ProductListingGroupsQueryOptions;
188
+ }, options?: SuspenseQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): UseSuspenseQueryResult<TData>;
178
189
  useInfiniteProductListingGroupsQuery<TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>>(params: {
179
190
  options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
180
191
  pageSize?: number;
181
192
  }, options?: InfiniteQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): UseInfiniteQueryResult<TData>;
193
+ useInfiniteProductListingGroupsCatalogQuery<TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>>(params: {
194
+ options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
195
+ pageSize?: number;
196
+ }, options?: InfiniteQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): UseInfiniteQueryResult<TData>;
182
197
  useSuspenseInfiniteProductListingGroupsQuery<TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>>(params: {
183
198
  options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
184
199
  pageSize?: number;
185
200
  }, options?: SuspenseInfiniteQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): UseSuspenseInfiniteQueryResult<TData>;
201
+ useSuspenseInfiniteProductListingGroupsCatalogQuery<TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>>(params: {
202
+ options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
203
+ pageSize?: number;
204
+ }, options?: SuspenseInfiniteQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): UseSuspenseInfiniteQueryResult<TData>;
186
205
  prefetchProductListingGroupsQuery(params: {
187
206
  options?: ProductListingGroupsQueryOptions;
188
207
  }, options?: {
189
208
  staleTime?: number;
190
209
  }): Promise<void>;
210
+ prefetchProductListingGroupsCatalogQuery(params: {
211
+ options?: ProductListingGroupsQueryOptions;
212
+ }, options?: {
213
+ staleTime?: number;
214
+ }): Promise<void>;
191
215
  prefetchInfiniteProductListingGroupsQuery(params: {
192
216
  options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
193
217
  pageSize?: number;
@@ -195,19 +219,20 @@ declare class QueryHooks<TCollection extends ServerCollection = PublicCollection
195
219
  pages?: number;
196
220
  staleTime?: number;
197
221
  }): Promise<void>;
222
+ prefetchInfiniteProductListingGroupsCatalogQuery(params: {
223
+ options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
224
+ pageSize?: number;
225
+ }, options?: {
226
+ pages?: number;
227
+ staleTime?: number;
228
+ }): Promise<void>;
198
229
  useProductDetail(params: {
199
230
  slug: string;
200
231
  } | {
201
232
  id: string;
202
- }, options?: {
203
- enabled?: boolean;
204
- }): UseQueryResult<ProductDetailResult>;
205
- useProductDetailBySlug(slug: string, options?: {
206
- enabled?: boolean;
207
- }): UseQueryResult<ProductDetailResult>;
208
- useProductDetailById(id: string, options?: {
209
- enabled?: boolean;
210
- }): UseQueryResult<ProductDetailResult>;
233
+ }, options?: QueryOptions<ProductDetailResult>): UseQueryResult<ProductDetailResult>;
234
+ useProductDetailBySlug(slug: string, options?: QueryOptions<ProductDetailResult>): UseQueryResult<ProductDetailResult>;
235
+ useProductDetailById(id: string, options?: QueryOptions<ProductDetailResult>): UseQueryResult<ProductDetailResult>;
211
236
  }
212
237
 
213
238
  declare function collectionKeys<T extends ServerCollection>(collection: T): {
@@ -225,7 +250,9 @@ declare const customerKeys: {
225
250
  };
226
251
  declare const productKeys: {
227
252
  listingGroups: (options?: ProductListingGroupsQueryOptions) => readonly ["products", "listing-groups", "list", ProductListingGroupsQueryOptions | undefined];
253
+ listingGroupsCatalog: (options?: ProductListingGroupsQueryOptions) => readonly ["products", "listing-groups", "catalog", ProductListingGroupsQueryOptions | undefined];
228
254
  listingGroupsInfinite: (options?: Omit<ProductListingGroupsQueryOptions, "page" | "limit">) => readonly ["products", "listing-groups", "infinite", Omit<ProductListingGroupsQueryOptions, "page" | "limit"> | undefined];
255
+ listingGroupsCatalogInfinite: (options?: Omit<ProductListingGroupsQueryOptions, "page" | "limit">) => readonly ["products", "listing-groups", "catalog", "infinite", Omit<ProductListingGroupsQueryOptions, "page" | "limit"> | undefined];
229
256
  detail: (params: {
230
257
  slug: string;
231
258
  } | {
@@ -239,6 +266,6 @@ declare const productKeys: {
239
266
  };
240
267
 
241
268
  declare function createQueryHooks(client: RootClient, queryClient?: QueryClient): ReadOnlyQueryHooks;
242
- declare function createServerQueryHooks(client: ServerClient, queryClient?: QueryClient): QueryHooks<ServerCollection>;
269
+ declare function createServerQueryHooks(client: RootServerClient, queryClient?: QueryClient): QueryHooks<ServerCollection>;
243
270
 
244
- export { type CollectionDetailQueryParams, CollectionHooks, type CollectionInfiniteQueryParams, type CollectionQueryParams, CustomerHooks, type InfiniteQueryOptions, type ProductListingGroupsQueryOptions, QueryHooks, type QueryOptions, type ReadOnlyQueryHooks, type SuspenseInfiniteQueryOptions, type SuspenseQueryOptions, collectionKeys, createQueryHooks, createServerQueryHooks, customerKeys, getQueryClient, productKeys };
271
+ export { type CollectionDetailQueryParams, CollectionHooks, type CollectionInfiniteQueryParams, type CollectionQueryParams, CustomerHooks, type InfiniteQueryOptions, type ProductListingGroupsQueryOptions, QueryHooks, type QueryOptions, type ReadOnlyQueryHooks, type SuspenseInfiniteQueryOptions, type SuspenseQueryOptions, collectionKeys, createQueryHooks, createServerQueryHooks, customerKeys, getQueryClient, getStorefrontQueryClient, productKeys };
package/dist/query.d.ts CHANGED
@@ -1,16 +1,21 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
2
  import { QueryClient, UseQueryResult, UseSuspenseQueryResult, InfiniteData, UseInfiniteQueryResult, UseSuspenseInfiniteQueryResult } from '@tanstack/react-query';
3
- import { A as ApiQueryOptions, P as PayloadFindResponse, g as PayloadMutationResponse, J as CustomerAuth, N as CustomerProfile, L as CustomerAuthResponse, M as CustomerLoginData, T as CustomerRegisterResponse, Q as CustomerRegisterData, O as CustomerRefreshResponse, b1 as UpdateProfileData, ad as ProductDetailParams, ae as ProductDetailResult, at as ProductListingGroupsItem, h as RootClient } from './types-BHh0YLmq.js';
4
- import './payload-types-dkeQyrDC.js';
5
- import { C as CollectionClient } from './collection-client-B6SlhzIP.js';
6
- import { c as ServerCollection, P as PublicCollection } from './const-DwmSDeWq.js';
7
- import { C as CollectionType } from './types-Cel_4L9t.js';
3
+ import { A as ApiQueryOptions, P as PayloadFindResponse, h as PayloadMutationResponse, a8 as CustomerAuth, a9 as CustomerProfile, aa as CustomerAuthResponse, ab as CustomerLoginData, ac as CustomerRegisterResponse, ad as CustomerRegisterData, ae as CustomerRefreshResponse, af as UpdateProfileData, ag as ProductDetailParams, ah as ProductDetailResult, ai as ProductListingGroupsItem, i as RootClient, Y as RootServerClient } from './types-Byo_Rty4.js';
4
+ import './payload-types-C7tb7Xbs.js';
5
+ import { C as CollectionClient } from './collection-client-DkREjhQ9.js';
6
+ import { S as ServerCollection, P as PublicCollection } from './const-CdqCauHQ.js';
7
+ import { C as CollectionType } from './types-1ylMrCuW.js';
8
8
  import { S as SDKError } from './index-BGEhoDUs.js';
9
9
  export { a as RealtimeConnection, R as RealtimeEvent, b as RealtimeListener } from './realtime-D7HtUpqt.js';
10
- import { ServerClient } from './server.js';
11
10
  import './metadata.js';
12
11
 
12
+ /** Default React Query client (SSR hydration-friendly: infinite staleTime). */
13
13
  declare function getQueryClient(): QueryClient;
14
+ /**
15
+ * Browser storefront client: refetches catalog data after ~1 minute instead of
16
+ * keeping SSR data fresh forever. Use with `createQueryHooks(client, queryClient)`.
17
+ */
18
+ declare function getStorefrontQueryClient(): QueryClient;
14
19
 
15
20
  interface CollectionQueryParams<T extends ServerCollection> {
16
21
  collection: T;
@@ -172,22 +177,41 @@ declare class QueryHooks<TCollection extends ServerCollection = PublicCollection
172
177
  useProductListingGroupsQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
173
178
  options?: ProductListingGroupsQueryOptions;
174
179
  }, options?: QueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): UseQueryResult<TData>;
180
+ useProductListingGroupsCatalogQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
181
+ options?: ProductListingGroupsQueryOptions;
182
+ }, options?: QueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): UseQueryResult<TData>;
175
183
  useSuspenseProductListingGroupsQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
176
184
  options?: ProductListingGroupsQueryOptions;
177
185
  }, options?: SuspenseQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): UseSuspenseQueryResult<TData>;
186
+ useSuspenseProductListingGroupsCatalogQuery<TData = PayloadFindResponse<ProductListingGroupsItem>>(params: {
187
+ options?: ProductListingGroupsQueryOptions;
188
+ }, options?: SuspenseQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): UseSuspenseQueryResult<TData>;
178
189
  useInfiniteProductListingGroupsQuery<TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>>(params: {
179
190
  options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
180
191
  pageSize?: number;
181
192
  }, options?: InfiniteQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): UseInfiniteQueryResult<TData>;
193
+ useInfiniteProductListingGroupsCatalogQuery<TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>>(params: {
194
+ options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
195
+ pageSize?: number;
196
+ }, options?: InfiniteQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): UseInfiniteQueryResult<TData>;
182
197
  useSuspenseInfiniteProductListingGroupsQuery<TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>>(params: {
183
198
  options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
184
199
  pageSize?: number;
185
200
  }, options?: SuspenseInfiniteQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): UseSuspenseInfiniteQueryResult<TData>;
201
+ useSuspenseInfiniteProductListingGroupsCatalogQuery<TData = InfiniteData<PayloadFindResponse<ProductListingGroupsItem>>>(params: {
202
+ options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
203
+ pageSize?: number;
204
+ }, options?: SuspenseInfiniteQueryOptions<PayloadFindResponse<ProductListingGroupsItem>, TData>): UseSuspenseInfiniteQueryResult<TData>;
186
205
  prefetchProductListingGroupsQuery(params: {
187
206
  options?: ProductListingGroupsQueryOptions;
188
207
  }, options?: {
189
208
  staleTime?: number;
190
209
  }): Promise<void>;
210
+ prefetchProductListingGroupsCatalogQuery(params: {
211
+ options?: ProductListingGroupsQueryOptions;
212
+ }, options?: {
213
+ staleTime?: number;
214
+ }): Promise<void>;
191
215
  prefetchInfiniteProductListingGroupsQuery(params: {
192
216
  options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
193
217
  pageSize?: number;
@@ -195,19 +219,20 @@ declare class QueryHooks<TCollection extends ServerCollection = PublicCollection
195
219
  pages?: number;
196
220
  staleTime?: number;
197
221
  }): Promise<void>;
222
+ prefetchInfiniteProductListingGroupsCatalogQuery(params: {
223
+ options?: Omit<ProductListingGroupsQueryOptions, 'page' | 'limit'>;
224
+ pageSize?: number;
225
+ }, options?: {
226
+ pages?: number;
227
+ staleTime?: number;
228
+ }): Promise<void>;
198
229
  useProductDetail(params: {
199
230
  slug: string;
200
231
  } | {
201
232
  id: string;
202
- }, options?: {
203
- enabled?: boolean;
204
- }): UseQueryResult<ProductDetailResult>;
205
- useProductDetailBySlug(slug: string, options?: {
206
- enabled?: boolean;
207
- }): UseQueryResult<ProductDetailResult>;
208
- useProductDetailById(id: string, options?: {
209
- enabled?: boolean;
210
- }): UseQueryResult<ProductDetailResult>;
233
+ }, options?: QueryOptions<ProductDetailResult>): UseQueryResult<ProductDetailResult>;
234
+ useProductDetailBySlug(slug: string, options?: QueryOptions<ProductDetailResult>): UseQueryResult<ProductDetailResult>;
235
+ useProductDetailById(id: string, options?: QueryOptions<ProductDetailResult>): UseQueryResult<ProductDetailResult>;
211
236
  }
212
237
 
213
238
  declare function collectionKeys<T extends ServerCollection>(collection: T): {
@@ -225,7 +250,9 @@ declare const customerKeys: {
225
250
  };
226
251
  declare const productKeys: {
227
252
  listingGroups: (options?: ProductListingGroupsQueryOptions) => readonly ["products", "listing-groups", "list", ProductListingGroupsQueryOptions | undefined];
253
+ listingGroupsCatalog: (options?: ProductListingGroupsQueryOptions) => readonly ["products", "listing-groups", "catalog", ProductListingGroupsQueryOptions | undefined];
228
254
  listingGroupsInfinite: (options?: Omit<ProductListingGroupsQueryOptions, "page" | "limit">) => readonly ["products", "listing-groups", "infinite", Omit<ProductListingGroupsQueryOptions, "page" | "limit"> | undefined];
255
+ listingGroupsCatalogInfinite: (options?: Omit<ProductListingGroupsQueryOptions, "page" | "limit">) => readonly ["products", "listing-groups", "catalog", "infinite", Omit<ProductListingGroupsQueryOptions, "page" | "limit"> | undefined];
229
256
  detail: (params: {
230
257
  slug: string;
231
258
  } | {
@@ -239,6 +266,6 @@ declare const productKeys: {
239
266
  };
240
267
 
241
268
  declare function createQueryHooks(client: RootClient, queryClient?: QueryClient): ReadOnlyQueryHooks;
242
- declare function createServerQueryHooks(client: ServerClient, queryClient?: QueryClient): QueryHooks<ServerCollection>;
269
+ declare function createServerQueryHooks(client: RootServerClient, queryClient?: QueryClient): QueryHooks<ServerCollection>;
243
270
 
244
- export { type CollectionDetailQueryParams, CollectionHooks, type CollectionInfiniteQueryParams, type CollectionQueryParams, CustomerHooks, type InfiniteQueryOptions, type ProductListingGroupsQueryOptions, QueryHooks, type QueryOptions, type ReadOnlyQueryHooks, type SuspenseInfiniteQueryOptions, type SuspenseQueryOptions, collectionKeys, createQueryHooks, createServerQueryHooks, customerKeys, getQueryClient, productKeys };
271
+ export { type CollectionDetailQueryParams, CollectionHooks, type CollectionInfiniteQueryParams, type CollectionQueryParams, CustomerHooks, type InfiniteQueryOptions, type ProductListingGroupsQueryOptions, QueryHooks, type QueryOptions, type ReadOnlyQueryHooks, type SuspenseInfiniteQueryOptions, type SuspenseQueryOptions, collectionKeys, createQueryHooks, createServerQueryHooks, customerKeys, getQueryClient, getStorefrontQueryClient, productKeys };
package/dist/query.js CHANGED
@@ -22,6 +22,7 @@ function makeQueryClient() {
22
22
  });
23
23
  }
24
24
  var browserQueryClient;
25
+ var browserStorefrontQueryClient;
25
26
  function getQueryClient() {
26
27
  if (isServer) {
27
28
  return makeQueryClient();
@@ -31,6 +32,30 @@ function getQueryClient() {
31
32
  }
32
33
  return browserQueryClient;
33
34
  }
35
+ var STOREFRONT_STALE_TIME_MS = 6e4;
36
+ function makeStorefrontQueryClient() {
37
+ return new QueryClient({
38
+ defaultOptions: {
39
+ queries: {
40
+ staleTime: STOREFRONT_STALE_TIME_MS,
41
+ refetchOnWindowFocus: false
42
+ },
43
+ dehydrate: {
44
+ shouldDehydrateQuery: (query) => defaultShouldDehydrateQuery(query) || query.state.status === "pending",
45
+ shouldRedactErrors: () => false
46
+ }
47
+ }
48
+ });
49
+ }
50
+ function getStorefrontQueryClient() {
51
+ if (isServer) {
52
+ return makeStorefrontQueryClient();
53
+ }
54
+ if (!browserStorefrontQueryClient) {
55
+ browserStorefrontQueryClient = makeStorefrontQueryClient();
56
+ }
57
+ return browserStorefrontQueryClient;
58
+ }
34
59
 
35
60
  // src/core/query/query-keys.ts
36
61
  function collectionKeys(collection) {
@@ -50,7 +75,9 @@ var customerKeys = {
50
75
  };
51
76
  var productKeys = {
52
77
  listingGroups: (options) => ["products", "listing-groups", "list", options],
78
+ listingGroupsCatalog: (options) => ["products", "listing-groups", "catalog", options],
53
79
  listingGroupsInfinite: (options) => ["products", "listing-groups", "infinite", options],
80
+ listingGroupsCatalogInfinite: (options) => ["products", "listing-groups", "catalog", "infinite", options],
54
81
  detail: (params) => ["products", "detail", params],
55
82
  detailAll: () => ["products", "detail"]
56
83
  };
@@ -580,6 +607,42 @@ import {
580
607
  useSuspenseInfiniteQuery as useSuspenseInfiniteQueryOriginal2,
581
608
  useSuspenseQuery as useSuspenseQueryOriginal2
582
609
  } from "@tanstack/react-query";
610
+
611
+ // src/core/internal/utils/query-string.ts
612
+ function appendListingGroupsQuerySearchParams(search, options) {
613
+ if (options?.page != null) search.set("page", String(options.page));
614
+ if (options?.limit != null) search.set("limit", String(options.limit));
615
+ if (options?.sort != null) {
616
+ const sort = options.sort;
617
+ search.set(
618
+ "sort",
619
+ Array.isArray(sort) ? sort.join(",") : sort
620
+ );
621
+ }
622
+ if (options?.where != null) {
623
+ search.set("whereJson", JSON.stringify(options.where));
624
+ }
625
+ }
626
+ function listingGroupsQueryCatalogUrl(options) {
627
+ const search = new URLSearchParams();
628
+ appendListingGroupsQuerySearchParams(search, options);
629
+ const query = search.toString();
630
+ return `/api/products/listing-groups/query/catalog${query ? `?${query}` : ""}`;
631
+ }
632
+
633
+ // src/core/query/query-hooks.ts
634
+ var LISTING_GROUPS_QUERY_PATH = "/api/products/listing-groups/query";
635
+ function fetchProductListingGroupsQuery(collectionClient, queryOptions) {
636
+ return collectionClient.requestFindEndpoint(
637
+ LISTING_GROUPS_QUERY_PATH,
638
+ { options: queryOptions }
639
+ );
640
+ }
641
+ function fetchProductListingGroupsCatalogQuery(collectionClient, queryOptions) {
642
+ return collectionClient.requestFindEndpointGet(
643
+ listingGroupsQueryCatalogUrl(queryOptions)
644
+ );
645
+ }
583
646
  var QueryHooks = class extends CollectionHooks {
584
647
  constructor(queryClient, collectionClient, customerAuth, commerceClient) {
585
648
  super(queryClient, collectionClient);
@@ -605,9 +668,21 @@ var QueryHooks = class extends CollectionHooks {
605
668
  const { placeholderData, ...restOptions } = options ?? {};
606
669
  return useQueryOriginal3({
607
670
  queryKey: productKeys.listingGroups(queryOptions),
608
- queryFn: async () => this.collectionClient.requestFindEndpoint(
609
- "/api/products/listing-groups/query",
610
- { options: queryOptions }
671
+ queryFn: async () => fetchProductListingGroupsQuery(this.collectionClient, queryOptions),
672
+ ...restOptions,
673
+ ...placeholderData !== void 0 && {
674
+ placeholderData
675
+ }
676
+ });
677
+ }
678
+ useProductListingGroupsCatalogQuery(params, options) {
679
+ const queryOptions = params.options;
680
+ const { placeholderData, ...restOptions } = options ?? {};
681
+ return useQueryOriginal3({
682
+ queryKey: productKeys.listingGroupsCatalog(queryOptions),
683
+ queryFn: async () => fetchProductListingGroupsCatalogQuery(
684
+ this.collectionClient,
685
+ queryOptions
611
686
  ),
612
687
  ...restOptions,
613
688
  ...placeholderData !== void 0 && {
@@ -619,9 +694,17 @@ var QueryHooks = class extends CollectionHooks {
619
694
  const queryOptions = params.options;
620
695
  return useSuspenseQueryOriginal2({
621
696
  queryKey: productKeys.listingGroups(queryOptions),
622
- queryFn: async () => this.collectionClient.requestFindEndpoint(
623
- "/api/products/listing-groups/query",
624
- { options: queryOptions }
697
+ queryFn: async () => fetchProductListingGroupsQuery(this.collectionClient, queryOptions),
698
+ ...options
699
+ });
700
+ }
701
+ useSuspenseProductListingGroupsCatalogQuery(params, options) {
702
+ const queryOptions = params.options;
703
+ return useSuspenseQueryOriginal2({
704
+ queryKey: productKeys.listingGroupsCatalog(queryOptions),
705
+ queryFn: async () => fetchProductListingGroupsCatalogQuery(
706
+ this.collectionClient,
707
+ queryOptions
625
708
  ),
626
709
  ...options
627
710
  });
@@ -633,12 +716,28 @@ var QueryHooks = class extends CollectionHooks {
633
716
  } = params;
634
717
  return useInfiniteQueryOriginal2({
635
718
  queryKey: productKeys.listingGroupsInfinite(queryOptions),
636
- queryFn: async ({ pageParam }) => this.collectionClient.requestFindEndpoint(
637
- "/api/products/listing-groups/query",
638
- {
639
- options: { ...queryOptions, page: pageParam, limit: pageSize }
640
- }
641
- ),
719
+ queryFn: async ({ pageParam }) => fetchProductListingGroupsQuery(this.collectionClient, {
720
+ ...queryOptions,
721
+ page: pageParam,
722
+ limit: pageSize
723
+ }),
724
+ initialPageParam: 1,
725
+ getNextPageParam: (lastPage) => lastPage.hasNextPage ? lastPage.nextPage : void 0,
726
+ ...options
727
+ });
728
+ }
729
+ useInfiniteProductListingGroupsCatalogQuery(params, options) {
730
+ const {
731
+ options: queryOptions,
732
+ pageSize = 20
733
+ } = params;
734
+ return useInfiniteQueryOriginal2({
735
+ queryKey: productKeys.listingGroupsCatalogInfinite(queryOptions),
736
+ queryFn: async ({ pageParam }) => fetchProductListingGroupsCatalogQuery(this.collectionClient, {
737
+ ...queryOptions,
738
+ page: pageParam,
739
+ limit: pageSize
740
+ }),
642
741
  initialPageParam: 1,
643
742
  getNextPageParam: (lastPage) => lastPage.hasNextPage ? lastPage.nextPage : void 0,
644
743
  ...options
@@ -651,12 +750,28 @@ var QueryHooks = class extends CollectionHooks {
651
750
  } = params;
652
751
  return useSuspenseInfiniteQueryOriginal2({
653
752
  queryKey: productKeys.listingGroupsInfinite(queryOptions),
654
- queryFn: async ({ pageParam }) => this.collectionClient.requestFindEndpoint(
655
- "/api/products/listing-groups/query",
656
- {
657
- options: { ...queryOptions, page: pageParam, limit: pageSize }
658
- }
659
- ),
753
+ queryFn: async ({ pageParam }) => fetchProductListingGroupsQuery(this.collectionClient, {
754
+ ...queryOptions,
755
+ page: pageParam,
756
+ limit: pageSize
757
+ }),
758
+ initialPageParam: 1,
759
+ getNextPageParam: (lastPage) => lastPage.hasNextPage ? lastPage.nextPage : void 0,
760
+ ...options
761
+ });
762
+ }
763
+ useSuspenseInfiniteProductListingGroupsCatalogQuery(params, options) {
764
+ const {
765
+ options: queryOptions,
766
+ pageSize = 20
767
+ } = params;
768
+ return useSuspenseInfiniteQueryOriginal2({
769
+ queryKey: productKeys.listingGroupsCatalogInfinite(queryOptions),
770
+ queryFn: async ({ pageParam }) => fetchProductListingGroupsCatalogQuery(this.collectionClient, {
771
+ ...queryOptions,
772
+ page: pageParam,
773
+ limit: pageSize
774
+ }),
660
775
  initialPageParam: 1,
661
776
  getNextPageParam: (lastPage) => lastPage.hasNextPage ? lastPage.nextPage : void 0,
662
777
  ...options
@@ -666,9 +781,17 @@ var QueryHooks = class extends CollectionHooks {
666
781
  const queryOptions = params.options;
667
782
  return this.queryClient.prefetchQuery({
668
783
  queryKey: productKeys.listingGroups(queryOptions),
669
- queryFn: async () => this.collectionClient.requestFindEndpoint(
670
- "/api/products/listing-groups/query",
671
- { options: queryOptions }
784
+ queryFn: async () => fetchProductListingGroupsQuery(this.collectionClient, queryOptions),
785
+ ...options
786
+ });
787
+ }
788
+ async prefetchProductListingGroupsCatalogQuery(params, options) {
789
+ const queryOptions = params.options;
790
+ return this.queryClient.prefetchQuery({
791
+ queryKey: productKeys.listingGroupsCatalog(queryOptions),
792
+ queryFn: async () => fetchProductListingGroupsCatalogQuery(
793
+ this.collectionClient,
794
+ queryOptions
672
795
  ),
673
796
  ...options
674
797
  });
@@ -680,12 +803,29 @@ var QueryHooks = class extends CollectionHooks {
680
803
  } = params;
681
804
  return this.queryClient.prefetchInfiniteQuery({
682
805
  queryKey: productKeys.listingGroupsInfinite(queryOptions),
683
- queryFn: async ({ pageParam }) => this.collectionClient.requestFindEndpoint(
684
- "/api/products/listing-groups/query",
685
- {
686
- options: { ...queryOptions, page: pageParam, limit: pageSize }
687
- }
688
- ),
806
+ queryFn: async ({ pageParam }) => fetchProductListingGroupsQuery(this.collectionClient, {
807
+ ...queryOptions,
808
+ page: pageParam,
809
+ limit: pageSize
810
+ }),
811
+ initialPageParam: 1,
812
+ getNextPageParam: (lastPage) => lastPage.hasNextPage ? lastPage.nextPage : void 0,
813
+ pages: options?.pages ?? 1,
814
+ staleTime: options?.staleTime
815
+ });
816
+ }
817
+ async prefetchInfiniteProductListingGroupsCatalogQuery(params, options) {
818
+ const {
819
+ options: queryOptions,
820
+ pageSize = 20
821
+ } = params;
822
+ return this.queryClient.prefetchInfiniteQuery({
823
+ queryKey: productKeys.listingGroupsCatalogInfinite(queryOptions),
824
+ queryFn: async ({ pageParam }) => fetchProductListingGroupsCatalogQuery(this.collectionClient, {
825
+ ...queryOptions,
826
+ page: pageParam,
827
+ limit: pageSize
828
+ }),
689
829
  initialPageParam: 1,
690
830
  getNextPageParam: (lastPage) => lastPage.hasNextPage ? lastPage.nextPage : void 0,
691
831
  pages: options?.pages ?? 1,
@@ -694,11 +834,13 @@ var QueryHooks = class extends CollectionHooks {
694
834
  }
695
835
  useProductDetail(params, options) {
696
836
  const discriminator = "slug" in params ? params.slug : params.id;
697
- const enabled = options?.enabled !== false && Boolean(discriminator);
837
+ const { enabled, ...restOptions } = options ?? {};
838
+ const queryEnabled = enabled !== false && Boolean(discriminator);
698
839
  return useQueryOriginal3({
699
840
  queryKey: productKeys.detail(params),
700
841
  queryFn: () => this._commerce.product.detail(params),
701
- enabled
842
+ enabled: queryEnabled,
843
+ ...restOptions
702
844
  });
703
845
  }
704
846
  useProductDetailBySlug(slug, options) {
@@ -1080,9 +1222,12 @@ function resolveApiUrl(apiUrl) {
1080
1222
 
1081
1223
  // src/core/internal/utils/http.ts
1082
1224
  var DEFAULT_TIMEOUT = 3e4;
1225
+ var STOREFRONT_BROWSER_TIMEOUT = 15e3;
1083
1226
  var DEFAULT_RETRYABLE_STATUSES = [408, 429, 500, 502, 503, 504];
1084
1227
  var NON_RETRYABLE_STATUSES = [400, 401, 403, 404, 409, 422];
1085
1228
  var SAFE_METHODS = ["GET", "HEAD", "OPTIONS"];
1229
+ var DEFAULT_MAX_RETRIES = 3;
1230
+ var STOREFRONT_BROWSER_MAX_RETRIES = 1;
1086
1231
  function debugLog(debug, type, message, data) {
1087
1232
  if (!debug) return;
1088
1233
  const shouldLog = debug === true || type === "request" && debug.logRequests || type === "response" && debug.logResponses || type === "error" && debug.logErrors;
@@ -1275,15 +1420,18 @@ async function httpFetch(url, options) {
1275
1420
  publishableKey,
1276
1421
  secretKey,
1277
1422
  customerToken,
1278
- timeout = DEFAULT_TIMEOUT,
1423
+ timeout: timeoutOption = DEFAULT_TIMEOUT,
1279
1424
  debug,
1280
1425
  retry,
1281
1426
  onUnauthorized,
1282
1427
  ...requestInit
1283
1428
  } = options || {};
1284
1429
  const baseUrl = resolveApiUrl(apiUrl);
1430
+ const method = (requestInit.method || "GET").toUpperCase();
1431
+ const isPublishableKeyBrowserGet = typeof window !== "undefined" && !secretKey && !customerToken && Boolean(publishableKey) && SAFE_METHODS.includes(method);
1432
+ const timeout = timeoutOption === DEFAULT_TIMEOUT && isPublishableKeyBrowserGet ? STOREFRONT_BROWSER_TIMEOUT : timeoutOption;
1285
1433
  const retryConfig = {
1286
- maxRetries: retry?.maxRetries ?? 3,
1434
+ maxRetries: retry?.maxRetries ?? (isPublishableKeyBrowserGet ? STOREFRONT_BROWSER_MAX_RETRIES : DEFAULT_MAX_RETRIES),
1287
1435
  retryableStatuses: retry?.retryableStatuses ?? DEFAULT_RETRYABLE_STATUSES,
1288
1436
  retryDelay: retry?.retryDelay ?? ((attempt) => Math.min(1e3 * 2 ** attempt, 1e4))
1289
1437
  };
@@ -1391,8 +1539,8 @@ async function httpFetch(url, options) {
1391
1539
  ),
1392
1540
  requestId
1393
1541
  );
1394
- const method = (requestInit.method || "GET").toUpperCase();
1395
- if (attempt < retryConfig.maxRetries && SAFE_METHODS.includes(method) && retryConfig.retryableStatuses.includes(response.status)) {
1542
+ const method2 = (requestInit.method || "GET").toUpperCase();
1543
+ if (attempt < retryConfig.maxRetries && SAFE_METHODS.includes(method2) && retryConfig.retryableStatuses.includes(response.status)) {
1396
1544
  lastError = error;
1397
1545
  const retryDelay = retryConfig.retryDelay(attempt);
1398
1546
  debugLog(debug, "error", `Retrying in ${retryDelay}ms...`, error);
@@ -1404,8 +1552,8 @@ async function httpFetch(url, options) {
1404
1552
  return response;
1405
1553
  } catch (error) {
1406
1554
  debugLog(debug, "error", url, error);
1407
- const method = (requestInit.method || "GET").toUpperCase();
1408
- const isSafe = SAFE_METHODS.includes(method);
1555
+ const method2 = (requestInit.method || "GET").toUpperCase();
1556
+ const isSafe = SAFE_METHODS.includes(method2);
1409
1557
  if (error instanceof Error && error.name === "AbortError") {
1410
1558
  const timeoutError = createTimeoutError(
1411
1559
  `Request timed out after ${timeout}ms.`,
@@ -1638,6 +1786,16 @@ var CollectionClient = class extends HttpClient {
1638
1786
  });
1639
1787
  return this.parseFindResponse(response);
1640
1788
  }
1789
+ /**
1790
+ * Find-like response from a cacheable GET custom endpoint.
1791
+ */
1792
+ async requestFindEndpointGet(endpoint) {
1793
+ const response = await this.fetchWithTracking(endpoint, {
1794
+ ...this.defaultOptions,
1795
+ method: "GET"
1796
+ });
1797
+ return this.parseFindResponse(response);
1798
+ }
1641
1799
  /**
1642
1800
  * Find document by ID
1643
1801
  * GET /api/{collection}/{id}
@@ -1831,6 +1989,7 @@ export {
1831
1989
  createServerQueryHooks,
1832
1990
  customerKeys,
1833
1991
  getQueryClient,
1992
+ getStorefrontQueryClient,
1834
1993
  productKeys
1835
1994
  };
1836
1995
  //# sourceMappingURL=query.js.map