@simpleapps-com/augur-hooks 2.4.0 → 2026.11.2

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 (103) hide show
  1. package/EXPORTS.md +25 -65
  2. package/README.md +21 -246
  3. package/dist/checkout/create-checkout-provider.d.ts +25 -0
  4. package/dist/checkout/create-checkout-provider.d.ts.map +1 -0
  5. package/dist/checkout/index.cjs +123 -106
  6. package/dist/checkout/index.cjs.map +1 -1
  7. package/dist/checkout/index.d.ts +5 -293
  8. package/dist/checkout/index.d.ts.map +1 -0
  9. package/dist/checkout/index.js +99 -82
  10. package/dist/checkout/index.js.map +1 -1
  11. package/dist/checkout/{index.d.cts → types.d.ts} +18 -40
  12. package/dist/checkout/types.d.ts.map +1 -0
  13. package/dist/chunk-6Z6JGK2C.cjs.map +1 -1
  14. package/dist/chunk-JJX23M5N.js +532 -0
  15. package/dist/chunk-JJX23M5N.js.map +1 -0
  16. package/dist/chunk-UZAFXUAO.cjs +532 -0
  17. package/dist/chunk-UZAFXUAO.cjs.map +1 -0
  18. package/dist/duration.d.ts +16 -0
  19. package/dist/duration.d.ts.map +1 -0
  20. package/dist/hooks/use-cart-actions.d.ts +68 -0
  21. package/dist/hooks/use-cart-actions.d.ts.map +1 -0
  22. package/dist/hooks/use-cart-initialization.d.ts +60 -0
  23. package/dist/hooks/use-cart-initialization.d.ts.map +1 -0
  24. package/dist/hooks/use-cart-pricing.d.ts +41 -0
  25. package/dist/hooks/use-cart-pricing.d.ts.map +1 -0
  26. package/dist/hooks/use-checkout-persistence.d.ts +41 -0
  27. package/dist/hooks/use-checkout-persistence.d.ts.map +1 -0
  28. package/dist/hooks/use-debounce.d.ts +6 -0
  29. package/dist/hooks/use-debounce.d.ts.map +1 -0
  30. package/dist/hooks/use-format-price.d.ts +29 -0
  31. package/dist/hooks/use-format-price.d.ts.map +1 -0
  32. package/dist/hooks/use-latest.d.ts +8 -0
  33. package/dist/hooks/use-latest.d.ts.map +1 -0
  34. package/dist/hooks/use-modal-lifecycle.d.ts +11 -0
  35. package/dist/hooks/use-modal-lifecycle.d.ts.map +1 -0
  36. package/dist/hooks/use-order-readiness.d.ts +47 -0
  37. package/dist/hooks/use-order-readiness.d.ts.map +1 -0
  38. package/dist/hooks/use-pagination-prefetch.d.ts +27 -0
  39. package/dist/hooks/use-pagination-prefetch.d.ts.map +1 -0
  40. package/dist/{use-order-readiness-DZTIfRzw.d.ts → hooks/use-payment-flow.d.ts} +23 -67
  41. package/dist/hooks/use-payment-flow.d.ts.map +1 -0
  42. package/dist/hooks/use-stock.d.ts +32 -0
  43. package/dist/hooks/use-stock.d.ts.map +1 -0
  44. package/dist/index.cjs +227 -184
  45. package/dist/index.cjs.map +1 -1
  46. package/dist/index.d.ts +32 -456
  47. package/dist/index.d.ts.map +1 -0
  48. package/dist/index.js +205 -162
  49. package/dist/index.js.map +1 -1
  50. package/dist/persistence/apply-limits.d.ts +8 -0
  51. package/dist/persistence/apply-limits.d.ts.map +1 -0
  52. package/dist/persistence/create-persister.d.ts +10 -0
  53. package/dist/persistence/create-persister.d.ts.map +1 -0
  54. package/dist/persistence/serializer.d.ts +11 -0
  55. package/dist/persistence/serializer.d.ts.map +1 -0
  56. package/dist/persistence/use-persistence.d.ts +59 -0
  57. package/dist/persistence/use-persistence.d.ts.map +1 -0
  58. package/dist/persistence/use-storage-monitor.d.ts +11 -0
  59. package/dist/persistence/use-storage-monitor.d.ts.map +1 -0
  60. package/dist/provider.d.ts +89 -0
  61. package/dist/provider.d.ts.map +1 -0
  62. package/dist/queries/batch-query.d.ts +23 -0
  63. package/dist/queries/batch-query.d.ts.map +1 -0
  64. package/dist/queries/index.d.ts +3 -0
  65. package/dist/queries/index.d.ts.map +1 -0
  66. package/dist/query-action-registry.d.ts +19 -0
  67. package/dist/query-action-registry.d.ts.map +1 -0
  68. package/dist/rules.d.ts +133 -0
  69. package/dist/rules.d.ts.map +1 -0
  70. package/dist/server.cjs +2 -1
  71. package/dist/server.cjs.map +1 -1
  72. package/dist/server.d.ts +10 -12
  73. package/dist/server.d.ts.map +1 -0
  74. package/dist/server.js +2 -1
  75. package/dist/server.js.map +1 -1
  76. package/dist/stores/cart-store.d.ts +51 -0
  77. package/dist/stores/cart-store.d.ts.map +1 -0
  78. package/dist/stores/items-filters-store.d.ts +30 -0
  79. package/dist/stores/items-filters-store.d.ts.map +1 -0
  80. package/dist/types.d.ts +48 -0
  81. package/dist/types.d.ts.map +1 -0
  82. package/dist/web/use-image-with-fallback.d.ts +16 -0
  83. package/dist/web/use-image-with-fallback.d.ts.map +1 -0
  84. package/dist/web/use-mobile-detection.d.ts +28 -0
  85. package/dist/web/use-mobile-detection.d.ts.map +1 -0
  86. package/dist/web/use-mobile-optimized-intersection.d.ts +17 -0
  87. package/dist/web/use-mobile-optimized-intersection.d.ts.map +1 -0
  88. package/dist/web.cjs.map +1 -1
  89. package/dist/web.d.ts +4 -60
  90. package/dist/web.d.ts.map +1 -0
  91. package/dist/web.js.map +1 -1
  92. package/llms.txt +76 -54
  93. package/package.json +26 -14
  94. package/dist/batch-query-CTlvxSmL.d.cts +0 -165
  95. package/dist/batch-query-CTlvxSmL.d.ts +0 -165
  96. package/dist/chunk-F5DUFW57.cjs +0 -383
  97. package/dist/chunk-F5DUFW57.cjs.map +0 -1
  98. package/dist/chunk-JNOHB4OP.js +0 -383
  99. package/dist/chunk-JNOHB4OP.js.map +0 -1
  100. package/dist/index.d.cts +0 -456
  101. package/dist/server.d.cts +0 -44
  102. package/dist/use-order-readiness-DZTIfRzw.d.cts +0 -137
  103. package/dist/web.d.cts +0 -60
package/dist/index.d.ts CHANGED
@@ -1,456 +1,32 @@
1
- import { P as PersistenceConfig } from './batch-query-CTlvxSmL.js';
2
- export { A as AugurApiClient, a as AugurHooksProvider, B as BatchQueryConfig, G as GetItemCategoryApiOptions, b as PageData, e as executeBatchQuery, u as useAugurApi, c as useAugurApiOptional, d as useAugurAuth, f as useAugurCache, g as useAugurOptions, h as useAugurSite } from './batch-query-CTlvxSmL.js';
3
- export { AugurAuthContext, AugurSiteConfig, AugurSiteDefaults, AugurSiteFormatting, CacheConfig, CacheProvider, CacheTierConfig, DeepQueryOptions, EdgeCacheValue, InfiniteScrollPage, ProxyMutationOptions, ProxyQueryOptions } from '@simpleapps-com/augur-core';
4
- import * as zustand from 'zustand';
5
- import * as _simpleapps_com_augur_utils from '@simpleapps-com/augur-utils';
6
- import { TCartLine, TItemsFilters, TStock, TPriceData } from '@simpleapps-com/augur-utils';
7
- export { DerivePriceInput, DerivedPrice, ResolveStockInput, ResolvedStock, TSearchSuggestion as SearchSuggestion, TSearchSuggestionsResponse as SearchSuggestionsResponse } from '@simpleapps-com/augur-utils';
8
- export { O as OrderReadinessParams, P as PaymentBillingAddress, a as PaymentFlowCallbacks, d as determineOrderReadiness, u as useOrderReadiness, b as usePaymentFlow } from './use-order-readiness-DZTIfRzw.js';
9
- import { QueryKey } from '@tanstack/react-query';
10
- import * as _tanstack_react_query_persist_client from '@tanstack/react-query-persist-client';
11
- import 'react/jsx-runtime';
12
- import 'react';
13
- import '@simpleapps-com/augur-api';
14
-
15
- /** Internal state shape for the cart Zustand store. */
16
- interface CartState {
17
- /** P21 cart header UID; `undefined` when no cart exists. */
18
- cartHdrUid: number | string | undefined;
19
- /** Current line items in the cart. */
20
- cartLines: TCartLine[];
21
- /** Sum of `quantity` across all cart lines (auto-computed by `setCartLines`). */
22
- cartQuantityTotal: number;
23
- /** Number of distinct line items (auto-computed by `setCartLines`). */
24
- cartLineCount: number;
25
- setCartHdrUid: (cartHdrUid: number | string | undefined) => void;
26
- /** Replace all cart lines. Auto-recomputes `cartQuantityTotal` and `cartLineCount`. */
27
- setCartLines: (cartLines: TCartLine[]) => void;
28
- /** Reset the cart to its empty initial state. */
29
- clearCart: () => void;
30
- }
31
- /** Zustand store for cart state. Prefer the individual selector hooks below for optimal re-renders. */
32
- declare const useCartStore: zustand.UseBoundStore<Omit<zustand.StoreApi<CartState>, "setState" | "devtools"> & {
33
- setState(partial: CartState | Partial<CartState> | ((state: CartState) => CartState | Partial<CartState>), replace?: false | undefined, action?: (string | {
34
- [x: string]: unknown;
35
- [x: number]: unknown;
36
- [x: symbol]: unknown;
37
- type: string;
38
- }) | undefined): void;
39
- setState(state: CartState | ((state: CartState) => CartState), replace: true, action?: (string | {
40
- [x: string]: unknown;
41
- [x: number]: unknown;
42
- [x: symbol]: unknown;
43
- type: string;
44
- }) | undefined): void;
45
- devtools: {
46
- cleanup: () => void;
47
- };
48
- }>;
49
- /** Select the current cart header UID. */
50
- declare const useCartHdrUid: () => string | number | undefined;
51
- /** Select the current cart line items array. */
52
- declare const useCartLines: () => TCartLine[];
53
- /** Select the total quantity summed across all cart lines. */
54
- declare const useCartQuantityTotal: () => number;
55
- /** Select the number of distinct line items in the cart. */
56
- declare const useCartLineCount: () => number;
57
- /** Get the `setCartHdrUid` action (stable reference). */
58
- declare const useSetCartHdrUid: () => (cartHdrUid: number | string | undefined) => void;
59
- /** Get the `setCartLines` action (stable reference). Also recomputes totals. */
60
- declare const useSetCartLines: () => (cartLines: TCartLine[]) => void;
61
- /** Get the `clearCart` action (stable reference). */
62
- declare const useClearCart: () => () => void;
63
-
64
- /** Zustand state shape for item list filtering, sorting, and pagination. */
65
- interface ItemsFiltersState {
66
- /** Snapshot of the initial defaults; useful for "reset filters" UIs. */
67
- initialFiltersState: TItemsFilters;
68
- /** Current active filter/sort/pagination state. */
69
- itemsFilters: TItemsFilters;
70
- /** Replace the entire filter state. */
71
- setItemsFilters: (itemFilters: TItemsFilters) => void;
72
- }
73
- /** Zustand store for item list filters, sorting, and pagination state. */
74
- declare const useItemFiltersStore: zustand.UseBoundStore<Omit<zustand.StoreApi<ItemsFiltersState>, "setState" | "devtools"> & {
75
- setState(partial: ItemsFiltersState | Partial<ItemsFiltersState> | ((state: ItemsFiltersState) => ItemsFiltersState | Partial<ItemsFiltersState>), replace?: false | undefined, action?: (string | {
76
- [x: string]: unknown;
77
- [x: number]: unknown;
78
- [x: symbol]: unknown;
79
- type: string;
80
- }) | undefined): void;
81
- setState(state: ItemsFiltersState | ((state: ItemsFiltersState) => ItemsFiltersState), replace: true, action?: (string | {
82
- [x: string]: unknown;
83
- [x: number]: unknown;
84
- [x: symbol]: unknown;
85
- type: string;
86
- }) | undefined): void;
87
- devtools: {
88
- cleanup: () => void;
89
- };
90
- }>;
91
-
92
- /**
93
- * Debounces a rapidly-changing value.
94
- * Returns the latest value only after `delay` ms of inactivity.
95
- */
96
- declare function useDebounce<T>(value: T, delay?: number): T;
97
-
98
- /** Options for configuring the useFormatPrice hook. */
99
- interface UseFormatPriceOptions {
100
- /** BCP 47 locale tag. Overrides site.formatting.locale. */
101
- locale?: string;
102
- /** ISO 4217 currency code. Overrides site.formatting.currency. */
103
- currency?: string;
104
- /** Decimal digits. Overrides site.formatting.precision. */
105
- precision?: number;
106
- /** Label returned when the effective value is 0 (e.g. "Call for Price"). */
107
- zeroLabel?: string;
108
- }
109
- /** Per-call options passed to the returned formatPrice function. */
110
- interface FormatPriceCallOptions {
111
- /** Override decimal digits for this call only. */
112
- precision?: number;
113
- /** Multiply the value by this quantity before formatting. */
114
- quantity?: number;
115
- }
116
- /**
117
- * Hook that returns a price formatter.
118
- * Reads defaults from site config when params are omitted.
119
- *
120
- * Supports both the new options-object signature and the legacy positional
121
- * `(locale?, currency?)` signature for backwards compatibility.
122
- */
123
- declare function useFormatPrice(optionsOrLocale?: UseFormatPriceOptions | string, legacyCurrency?: string): {
124
- formatPrice: (price: number, callOptions?: FormatPriceCallOptions) => string;
125
- };
126
-
127
- interface UseStockOptions {
128
- enabled?: boolean;
129
- /** Override the default queryFn (e.g. with a custom server action). */
130
- queryFn?: () => Promise<TStock>;
131
- /** Company key to extract stock for a specific company. */
132
- companyKey?: string;
133
- /** Whether to round the quantity. */
134
- round?: boolean;
135
- /** Threshold below which stock is considered "low". */
136
- lowStockThreshold?: number;
137
- /** Whether to include the quantity in the resolved output. */
138
- showQuantity?: boolean;
139
- }
140
- /**
141
- * Fetches full TStock data and resolves it into a normalized stock object.
142
- *
143
- * Uses the proxy from AugurHooksProvider context. Works with:
144
- * - Direct SDK (api prop on provider)
145
- * - Server actions (auto-detected via queryAction registration)
146
- * - Custom queryFn override
147
- */
148
- declare function useStock(invMastUid: number | string, options?: UseStockOptions): {
149
- stock: TStock | null;
150
- resolved: _simpleapps_com_augur_utils.ResolvedStock | null;
151
- loading: false;
152
- error: Error | null;
153
- };
154
-
155
- type CartLineInput = Pick<TCartLine, "invMastUid" | "quantity" | "unitOfMeasure"> & {
156
- cartHdrUid?: number | string | undefined;
157
- };
158
- /** Site-specific callbacks injected into useCartActions. */
159
- interface CartActionCallbacks {
160
- /** Add items to cart via API. Truthy = success, falsy = failure. */
161
- addToCart: (cartHdrUid: number, items: Array<{
162
- cartHdrUid: number;
163
- invMastUid: number;
164
- quantity: number;
165
- unitOfMeasure: string;
166
- }>) => Promise<boolean | undefined | void>;
167
- /** Update cart lines via API. Truthy = success, falsy = failure. */
168
- updateCartLines: (cartHdrUid: number, lines: TCartLine[]) => Promise<boolean | undefined | void>;
169
- /** Delete all items from cart via API. Truthy = success, falsy = failure. */
170
- deleteItemsFromCart: (cartHdrUid: number) => Promise<boolean | undefined | void>;
171
- /** Optional toast notification callback. */
172
- toast?: {
173
- info?: (message: string) => void;
174
- error?: (message: string) => void;
175
- success?: (message: string) => void;
176
- };
177
- }
178
- interface CartActionOptions {
179
- showToast?: boolean;
180
- itemId?: string;
181
- onSuccess?: () => void;
182
- onError?: (error: Error) => void;
183
- }
184
- /**
185
- * Optimistic cart actions hook with automatic rollback on failure.
186
- *
187
- * Accepts site-specific server action callbacks so the hook itself
188
- * has no dependency on any particular server action implementation.
189
- *
190
- * @example
191
- * ```tsx
192
- * import { useCartActions } from "@simpleapps-com/augur-hooks";
193
- * import { addToCart, updateCartLines, deleteItemsFromCart } from "@/lib/actions/commerce";
194
- * import { toast } from "react-toastify";
195
- *
196
- * const cart = useCartActions({
197
- * addToCart, updateCartLines, deleteItemsFromCart,
198
- * toast: { info: toast.info, error: toast.error },
199
- * });
200
- *
201
- * await cart.addToCart({ invMastUid: 123, quantity: 1, unitOfMeasure: "EA" });
202
- * ```
203
- */
204
- declare function useCartActions(callbacks: CartActionCallbacks): {
205
- addToCart: (item: CartLineInput, options?: CartActionOptions) => Promise<boolean>;
206
- updateQuantity: (invMastUid: number, newQuantity: number, options?: CartActionOptions) => Promise<boolean>;
207
- removeFromCart: (invMastUid: number, options?: CartActionOptions) => Promise<boolean>;
208
- clearCart: (options?: Omit<CartActionOptions, "itemId">) => Promise<boolean>;
209
- isInCart: (invMastUid: number) => boolean;
210
- getItemQuantity: (invMastUid: number) => number;
211
- cartHdrUid: string | number | undefined;
212
- cartLines: TCartLine[];
213
- invalidateCartCache: () => void;
214
- };
215
-
216
- /**
217
- * Shared modal lifecycle hook -- scroll lock, Escape key, client-side hydration gate.
218
- *
219
- * Locks body scroll when the modal is open and restores it on close.
220
- * Listens for Escape key to trigger onClose. Returns isClient for
221
- * hydration-safe conditional rendering.
222
- */
223
- declare function useModalLifecycle(isOpen: boolean, onClose: () => void): {
224
- isClient: boolean;
225
- };
226
-
227
- /** A single persisted field with its storage key and optional TTL. */
228
- interface CheckoutPersistField<T> {
229
- key: string;
230
- value: T;
231
- set: (value: T) => void;
232
- /** Valibot or custom validator. Return the parsed value or throw to reject. */
233
- validate?: (raw: unknown) => T;
234
- /** TTL in milliseconds. Default: 30 minutes. */
235
- ttl?: number;
236
- }
237
- /**
238
- * Saves a value to sessionStorage with a timestamp for TTL expiration.
239
- *
240
- * Fails silently on storage errors (private browsing, quota exceeded).
241
- */
242
- declare function saveToSession(key: string, value: unknown): void;
243
- /**
244
- * Loads a value from sessionStorage, checking TTL and optionally validating.
245
- *
246
- * Returns null if missing, expired, invalid, or storage is unavailable.
247
- * Cleans up expired entries automatically.
248
- */
249
- declare function loadFromSession<T>(key: string, ttl?: number, validate?: (raw: unknown) => T): T | null;
250
- /** Removes a checkout persistence key from sessionStorage. */
251
- declare function clearFromSession(key: string): void;
252
- /**
253
- * Hook that persists checkout state fields to sessionStorage and restores on mount.
254
- *
255
- * Each field is saved when its value changes and restored once on initial mount.
256
- * Validates restored values against an optional schema to guard against
257
- * corrupted or stale storage. Expired entries (past TTL) are discarded.
258
- */
259
- declare function useCheckoutPersistence(fields: CheckoutPersistField<unknown>[]): void;
260
- /**
261
- * Clears all checkout persistence keys from sessionStorage.
262
- *
263
- * Call after successful order submission to prevent stale data on next checkout.
264
- */
265
- declare function clearCheckoutPersistence(keys: string[]): void;
266
-
267
- /** Session info passed from the consumer's auth system. */
268
- interface CartSessionInfo {
269
- /** Auth status: "loading" | "authenticated" | "unauthenticated" */
270
- status: "loading" | "authenticated" | "unauthenticated";
271
- /** User's ID (e.g., Joomla user ID). Undefined if not authenticated. */
272
- userId?: string | number;
273
- /** Cart header UID from the auth session, if available. */
274
- cartHdrUid?: number | string;
275
- }
276
- /** Site-specific callbacks injected into useCartInitialization. */
277
- interface CartInitCallbacks {
278
- /** Look up or create a cart header. Returns { cartHdrUid, cartToken? }. */
279
- cartHdrLookup: (userId: string | number, cartToken: string) => Promise<{
280
- cartHdrUid: number;
281
- cartToken?: string | null;
282
- } | null | undefined>;
283
- /** Fetch cart line items for a given cart header UID. */
284
- getCartLines: (cartHdrUid: number) => Promise<TCartLine[] | undefined>;
285
- /** Get the current cart token. Defaults to localStorage.getItem("cartToken"). */
286
- getCartToken?: () => string | null;
287
- /** Save cart token. Defaults to localStorage.setItem("cartToken", token). */
288
- saveCartToken?: (token: string) => void;
289
- /** Generate a new unique cart token. Defaults to crypto.randomUUID(). */
290
- generateCartToken?: () => string;
291
- }
292
- /**
293
- * Initialize cart state from session (authenticated) or cookie (guest).
294
- * Call once in the root layout.
295
- *
296
- * @example
297
- * ```tsx
298
- * import { useCartInitialization } from "@simpleapps-com/augur-hooks";
299
- * import { useSession } from "next-auth/react";
300
- * import { cartHdrLookup, getCartLines } from "@/lib/actions/commerce";
301
- *
302
- * function CartInitializer() {
303
- * const { data: session, status } = useSession();
304
- *
305
- * // Minimal setup — token storage defaults to localStorage,
306
- * // token generation defaults to crypto.randomUUID().
307
- * useCartInitialization(
308
- * {
309
- * status,
310
- * userId: session?.user?.id,
311
- * cartHdrUid: session?.user?.cartHdrUid,
312
- * },
313
- * { cartHdrLookup, getCartLines },
314
- * );
315
- *
316
- * return null;
317
- * }
318
- * ```
319
- */
320
- declare function useCartInitialization(session: CartSessionInfo, callbacks: CartInitCallbacks): {
321
- cartHdrUid: string | number | undefined;
322
- isInitializing: boolean;
323
- retryCount: number;
324
- };
325
-
326
- interface CartPriceData {
327
- unitPrice: number;
328
- priceData: Record<string, unknown> | null;
329
- }
330
- interface CartPricingResult {
331
- /** Map of itemId -> price data (with quantity-specific pricing) */
332
- prices: Record<string, CartPriceData>;
333
- /** Get unit price for an item (returns 0 if not found) */
334
- getUnitPrice: (itemId: string) => number;
335
- /** Get total price for an item (unitPrice * quantity) */
336
- getItemTotal: (itemId: string, quantity: number) => number;
337
- /** Cart subtotal (sum of all item totals) */
338
- subtotal: number;
339
- /** True if any price is still loading */
340
- isLoading: boolean;
341
- /** True if all prices loaded successfully */
342
- isSuccess: boolean;
343
- /** True if any price failed to load */
344
- isError: boolean;
345
- }
346
- interface UseCartPricingOptions {
347
- customerId?: string | number;
348
- /** Override per-item price fetching (e.g. with a custom server action). */
349
- queryFn?: (itemId: string, customerId: string | number, quantity: number) => Promise<TPriceData>;
350
- }
351
- /**
352
- * Centralized hook for cart/checkout pricing.
353
- *
354
- * Fetches prices for ALL cart items with their actual quantities
355
- * to support quantity-based price breaks. React Query dedupes
356
- * identical calls across components.
357
- *
358
- * Uses the proxy from AugurHooksProvider context. Works with:
359
- * - Direct SDK (api prop on provider)
360
- * - Server actions (auto-detected via queryAction registration)
361
- * - Custom queryFn override
362
- */
363
- declare function useCartPricing(options?: UseCartPricingOptions): CartPricingResult;
364
-
365
- interface UsePaginationPrefetchOptions {
366
- /** Query key for the paginated data */
367
- queryKey: QueryKey;
368
- /** Function to fetch a page of data */
369
- queryFn: (offset: number) => Promise<unknown>;
370
- /** Number of items per page */
371
- pageSize: number;
372
- /** Custom query key builder. Receives the base key and offset, returns the full key. Default: [...queryKey, offset]. */
373
- queryKeyFn?: (baseKey: QueryKey, offset: number) => QueryKey;
374
- /** Stale time in ms (defaults to 10 minutes) */
375
- staleTime?: number;
376
- /** GC time in ms (defaults to 30 minutes) */
377
- gcTime?: number;
378
- enabled?: boolean;
379
- }
380
- /**
381
- * Prefetch adjacent pages on hover for instant pagination.
382
- * Accepts a generic queryFn so it works with any paginated resource.
383
- */
384
- declare const usePaginationPrefetch: ({ queryKey, queryFn, pageSize, queryKeyFn, staleTime, gcTime, enabled, }: UsePaginationPrefetchOptions) => {
385
- prefetchPage: (page: number) => Promise<void>;
386
- handlePaginationHover: (page: number) => () => void;
387
- };
388
-
389
- /**
390
- * Returns a fully configured `persistOptions` object for use with
391
- * `PersistQueryClientProvider` from `@tanstack/react-query-persist-client`.
392
- *
393
- * Handles:
394
- * - SSR-safe persister creation (no-op on server)
395
- * - Map → Record serialization for localStorage compatibility
396
- * - Selective persistence (only successful queries matching persistableKeys)
397
- * - Per-key-prefix LRU eviction (via `limits`)
398
- * - Throttled writes to localStorage
399
- * - Hydration safety (maxAge: 0 until client mount)
400
- * - Storage monitoring with automatic eviction when over threshold
401
- * - Dev mode auto-buster (invalidates cache on each restart)
402
- *
403
- * @example
404
- * ```tsx
405
- * import { useAugurPersistence } from "@simpleapps-com/augur-hooks";
406
- *
407
- * function Providers({ children }) {
408
- * const [queryClient] = useState(() => new QueryClient({ ... }));
409
- * const persistOptions = useAugurPersistence({
410
- * key: "my-site-cache",
411
- * buster: "1.0.0",
412
- * persistableKeys: ["price", "categories", "invMast"],
413
- * limits: { invMast: 100 },
414
- * });
415
- *
416
- * return (
417
- * <PersistQueryClientProvider client={queryClient} persistOptions={persistOptions}>
418
- * <augur.Provider api={api} auth={auth}>
419
- * {children}
420
- * </augur.Provider>
421
- * </PersistQueryClientProvider>
422
- * );
423
- * }
424
- * ```
425
- */
426
- declare function useAugurPersistence(config: PersistenceConfig): {
427
- persister: _tanstack_react_query_persist_client.Persister;
428
- maxAge: number;
429
- buster: string;
430
- dehydrateOptions: {
431
- shouldDehydrateQuery: (query: {
432
- queryKey: readonly unknown[];
433
- state: {
434
- status: string;
435
- };
436
- }) => boolean;
437
- };
438
- };
439
-
440
- /**
441
- * Lightweight registry for a query action function.
442
- *
443
- * augur-server/hooks.ts registers its queryAction as a side effect when
444
- * imported. augur-hooks consumers (useCartPricing, useStock, the provider)
445
- * read from this registry to route data through server actions automatically.
446
- *
447
- * No circular dependency: augur-server depends on augur-hooks and writes here.
448
- * augur-hooks reads from its own module.
449
- */
450
- type QueryActionFn = (methodPath: string, ...args: unknown[]) => Promise<unknown>;
451
- /** Register a query action function (called by augur-server/hooks.ts on import). */
452
- declare function registerQueryAction(fn: QueryActionFn): void;
453
- /** Returns the registered query action, or null if none registered. */
454
- declare function getRegisteredQueryAction(): QueryActionFn | null;
455
-
456
- export { type CartActionCallbacks, type CartInitCallbacks, type CartPriceData, type CartPricingResult, type CartSessionInfo, type CheckoutPersistField, type FormatPriceCallOptions, PersistenceConfig, type UseFormatPriceOptions, type UseStockOptions, clearCheckoutPersistence, clearFromSession, getRegisteredQueryAction, loadFromSession, registerQueryAction, saveToSession, useAugurPersistence, useCartActions, useCartHdrUid, useCartInitialization, useCartLineCount, useCartLines, useCartPricing, useCartQuantityTotal, useCartStore, useCheckoutPersistence, useClearCart, useDebounce, useFormatPrice, useItemFiltersStore, useModalLifecycle, usePaginationPrefetch, useSetCartHdrUid, useSetCartLines, useStock };
1
+ export { AugurHooksProvider, useAugurOptions, useAugurApi, useAugurApiOptional, useAugurAuth, useAugurCache, useAugurSite, } from "./provider";
2
+ export type { AugurApiClient } from "./provider";
3
+ export type { AugurAuthContext, InfiniteScrollPage, CacheProvider, CacheTierConfig, CacheConfig, EdgeCacheValue, DeepQueryOptions, ProxyQueryOptions, ProxyMutationOptions, AugurSiteConfig, AugurSiteDefaults, AugurSiteFormatting, } from "@simpleapps-com/augur-core";
4
+ export type { PageData, SearchSuggestion, SearchSuggestionsResponse, GetItemCategoryApiOptions, PersistenceConfig, } from "./types";
5
+ export { useCartStore, useCartHdrUid, useCartLines, useCartQuantityTotal, useCartLineCount, useSetCartHdrUid, useSetCartLines, useClearCart, } from "./stores/cart-store";
6
+ export { useItemFiltersStore } from "./stores/items-filters-store";
7
+ export { useDebounce } from "./hooks/use-debounce";
8
+ export { useFormatPrice } from "./hooks/use-format-price";
9
+ export type { UseFormatPriceOptions, FormatPriceCallOptions } from "./hooks/use-format-price";
10
+ export type { DerivedPrice, DerivePriceInput } from "@simpleapps-com/augur-utils";
11
+ export { useStock } from "./hooks/use-stock";
12
+ export type { UseStockOptions } from "./hooks/use-stock";
13
+ export type { ResolvedStock, ResolveStockInput } from "@simpleapps-com/augur-utils";
14
+ export { executeBatchQuery } from "./queries/batch-query";
15
+ export type { BatchQueryConfig } from "./queries/batch-query";
16
+ export { useCartActions } from "./hooks/use-cart-actions";
17
+ export type { CartActionCallbacks } from "./hooks/use-cart-actions";
18
+ export { usePaymentFlow } from "./hooks/use-payment-flow";
19
+ export type { PaymentFlowCallbacks, PaymentBillingAddress } from "./hooks/use-payment-flow";
20
+ export { useModalLifecycle } from "./hooks/use-modal-lifecycle";
21
+ export { useOrderReadiness, determineOrderReadiness } from "./hooks/use-order-readiness";
22
+ export type { OrderReadinessParams } from "./hooks/use-order-readiness";
23
+ export { useCheckoutPersistence, saveToSession, loadFromSession, clearFromSession, clearCheckoutPersistence, } from "./hooks/use-checkout-persistence";
24
+ export type { CheckoutPersistField } from "./hooks/use-checkout-persistence";
25
+ export { useCartInitialization } from "./hooks/use-cart-initialization";
26
+ export type { CartSessionInfo, CartInitCallbacks } from "./hooks/use-cart-initialization";
27
+ export { useCartPricing } from "./hooks/use-cart-pricing";
28
+ export type { CartPriceData, CartPricingResult } from "./hooks/use-cart-pricing";
29
+ export { usePaginationPrefetch } from "./hooks/use-pagination-prefetch";
30
+ export { useAugurPersistence } from "./persistence/use-persistence";
31
+ export { registerQueryAction, getRegisteredQueryAction } from "./query-action-registry";
32
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,mBAAmB,EACnB,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AAGpC,YAAY,EACV,QAAQ,EACR,gBAAgB,EAChB,yBAAyB,EACzB,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,YAAY,GACb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,YAAY,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAG9F,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAGlF,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAG9D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,YAAY,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAGpE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,YAAY,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAG5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACzF,YAAY,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAE7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,YAAY,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAE1F,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAGjF,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAGxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGpE,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC"}