@simpleapps-com/augur-hooks 2.0.10 → 2.0.12

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.
package/EXPORTS.md ADDED
@@ -0,0 +1,217 @@
1
+ # @simpleapps-com/augur-hooks exports
2
+
3
+ Version: 2.0.9
4
+
5
+ > Auto-generated from built type declarations. Do not edit manually.
6
+ > Regenerate with: `pnpm run generate-exports`
7
+
8
+ ## `@simpleapps-com/augur-hooks`
9
+
10
+ ### Values
11
+
12
+ | Export | Kind | Description |
13
+ |--------|------|-------------|
14
+ | `AugurApiClient` | value | |
15
+ | `AugurAuthContext` | value | |
16
+ | `AugurCallbacks` | value | |
17
+ | `AugurHooksProvider` | value | |
18
+ | `AugurSiteConfig` | value | |
19
+ | `AugurSiteDefaults` | value | |
20
+ | `AugurSiteFormatting` | value | |
21
+ | `BatchInvMastDocParam` | value | |
22
+ | `CacheConfig` | value | |
23
+ | `CacheProvider` | value | |
24
+ | `CacheTierConfig` | value | |
25
+ | `DeepQueryOptions` | value | |
26
+ | `DerivePriceInput` | value | |
27
+ | `DerivedPrice` | value | |
28
+ | `EdgeCacheValue` | value | |
29
+ | `GetItemCategoryApiOptions` | value | |
30
+ | `InfiniteScrollPage` | value | |
31
+ | `PageData` | value | |
32
+ | `PersistenceConfig` | value | |
33
+ | `ProxyMutationOptions` | value | |
34
+ | `ProxyQueryOptions` | value | |
35
+ | `ResolveStockInput` | value | |
36
+ | `ResolvedStock` | value | |
37
+ | `SearchSuggestion` | value | |
38
+ | `SearchSuggestionsResponse` | value | |
39
+ | `createSiteHooks` | function | Creates a pre-configured provider component and re-exports all hooks. |
40
+ | `executeBatchQuery` | function | |
41
+ | `getBatchInvMastDocKey` | function | |
42
+ | `getBatchInvMastDocOptions` | value | |
43
+ | `getCartPricingQueryOptions` | value | |
44
+ | `getCategoryItemsInfiniteKey` | value | |
45
+ | `getCategoryItemsInfiniteOptions` | value | |
46
+ | `getCustomerInvoiceDetailKey` | value | |
47
+ | `getCustomerInvoicesKey` | value | |
48
+ | `getCustomerOrderDetailKey` | value | |
49
+ | `getCustomerOrdersKey` | value | |
50
+ | `getCustomerQuoteDetailKey` | value | |
51
+ | `getCustomerQuotesKey` | value | |
52
+ | `getInvMastDocKey` | value | |
53
+ | `getInvMastDocOptions` | value | |
54
+ | `getInvMastKey` | value | |
55
+ | `getInvMastOptions` | value | |
56
+ | `getInvMastStockKey` | function | |
57
+ | `getInvMastStockOptions` | value | |
58
+ | `getItemAttributesKey` | value | |
59
+ | `getItemAttributesOptions` | value | |
60
+ | `getItemCategoryKey` | value | |
61
+ | `getItemCategoryOptions` | value | |
62
+ | `getItemDetailsKey` | value | |
63
+ | `getItemDetailsOptions` | value | |
64
+ | `getItemPriceKey` | value | |
65
+ | `getItemPriceOptions` | value | |
66
+ | `getItemSearchInfiniteKey` | value | |
67
+ | `getItemSearchInfiniteOptions` | value | |
68
+ | `getJoomlaContentKey` | value | |
69
+ | `getJoomlaContentListKey` | value | |
70
+ | `getJoomlaContentListOptions` | value | |
71
+ | `getJoomlaContentOptions` | value | |
72
+ | `getJoomlaMenuDocKey` | value | |
73
+ | `getJoomlaMenuDocOptions` | value | |
74
+ | `getJoomlaMenuKey` | value | |
75
+ | `getJoomlaMenuOptions` | value | |
76
+ | `getProductCategoryKey` | value | |
77
+ | `getProductCategoryOptions` | value | |
78
+ | `getProductSearchKey` | value | |
79
+ | `getProductSearchOptions` | value | |
80
+ | `getSearchSuggestionsKey` | value | |
81
+ | `getSearchSuggestionsOptions` | value | |
82
+ | `getStockKey` | value | |
83
+ | `getStockOptions` | value | |
84
+ | `useAugurApi` | value | |
85
+ | `useAugurAuth` | value | |
86
+ | `useAugurCache` | value | |
87
+ | `useAugurOptions` | value | |
88
+ | `useAugurPersistence` | function | Returns a fully configured `persistOptions` object for use with |
89
+ | `useAugurSite` | value | |
90
+ | `useBatchInvMastDoc` | function | Fetches and caches multiple inventory master documents in a single batch. |
91
+ | `useCartActions` | function | Optimistic cart actions hook with automatic rollback on failure. |
92
+ | `useCartHdrUid` | const | Select the current cart header UID. |
93
+ | `useCartInitialization` | function | Initialize cart state from session (authenticated) or cookie (guest). |
94
+ | `useCartLineCount` | const | Select the number of distinct line items in the cart. |
95
+ | `useCartLines` | const | Select the current cart line items array. |
96
+ | `useCartPricing` | function | Centralized hook for cart/checkout pricing. |
97
+ | `useCartQuantityTotal` | const | Select the total quantity summed across all cart lines. |
98
+ | `useCartStore` | const | Zustand store for cart state. Prefer the individual selector hooks below for optimal re-renders. |
99
+ | `useCategoryItemsInfinite` | function | Infinite scroll for category product listings. |
100
+ | `useClearCart` | const | Get the `clearCart` action (stable reference). |
101
+ | `useCustomerInvoices` | function | |
102
+ | `useCustomerOrders` | function | |
103
+ | `useCustomerQuotes` | function | |
104
+ | `useDebounce` | function | Debounces a rapidly-changing value. |
105
+ | `useFormatPrice` | function | Hook that returns a price formatter. |
106
+ | `useInvMast` | function | |
107
+ | `useInvMastDoc` | function | Fetches and caches an inventory master document via the augur-api SDK. |
108
+ | `useInvMastStock` | function | |
109
+ | `useInvoiceDetail` | function | |
110
+ | `useItemAttributes` | function | |
111
+ | `useItemCategory` | function | Fetches and caches item category data via the augur-api SDK. |
112
+ | `useItemDetails` | function | |
113
+ | `useItemFiltersStore` | const | Zustand store for item list filters, sorting, and pagination state. |
114
+ | `useItemPrice` | function | Fetches and caches item pricing via the augur-api SDK. |
115
+ | `useItemSearchInfinite` | function | Infinite scroll for search results. |
116
+ | `useJoomlaContent` | function | |
117
+ | `useJoomlaContentList` | function | |
118
+ | `useJoomlaMenu` | function | |
119
+ | `useJoomlaMenuDoc` | function | |
120
+ | `useOrderDetail` | function | |
121
+ | `usePaginationPrefetch` | const | Prefetch adjacent pages on hover for instant pagination. |
122
+ | `useProductCategory` | function | |
123
+ | `useProductSearch` | function | Searches products via the augur-api OpenSearch endpoint. |
124
+ | `useQuoteDetail` | function | |
125
+ | `useSearchSuggestions` | function | Fetches search suggestions via the augur-api OpenSearch endpoint. |
126
+ | `useSetCartHdrUid` | const | Get the `setCartHdrUid` action (stable reference). |
127
+ | `useSetCartLines` | const | Get the `setCartLines` action (stable reference). Also recomputes totals. |
128
+ | `useStock` | function | Fetches full TStock data and resolves it into a normalized stock object. |
129
+
130
+ ### Types
131
+
132
+ `BatchQueryConfig`, `CartActionCallbacks`, `CartInitCallbacks`, `CartPriceData`, `CartPricingResult`, `CartSessionInfo`, `CreateSiteHooksConfig`, `FormatPriceCallOptions`, `UseFormatPriceOptions`, `UseStockOptions`
133
+
134
+ ```ts
135
+ import { AugurApiClient, AugurAuthContext, AugurCallbacks } from "@simpleapps-com/augur-hooks";
136
+ ```
137
+
138
+ ## `@simpleapps-com/augur-hooks/server`
139
+
140
+ ### Values
141
+
142
+ | Export | Kind | Description |
143
+ |--------|------|-------------|
144
+ | `AugurAuthContext` | value | |
145
+ | `CacheConfig` | value | |
146
+ | `InfiniteScrollPage` | value | |
147
+ | `createAugurOptions` | function | Creates server-side query options proxy for prefetching. |
148
+ | `executeBatchQuery` | function | |
149
+ | `getBatchInvMastDocKey` | function | |
150
+ | `getBatchInvMastDocOptions` | value | |
151
+ | `getCartPricingQueryOptions` | value | |
152
+ | `getCategoryItemsInfiniteKey` | value | |
153
+ | `getCategoryItemsInfiniteOptions` | value | |
154
+ | `getCustomerInvoiceDetailKey` | value | |
155
+ | `getCustomerInvoicesKey` | value | |
156
+ | `getCustomerOrderDetailKey` | value | |
157
+ | `getCustomerOrdersKey` | value | |
158
+ | `getCustomerQuoteDetailKey` | value | |
159
+ | `getCustomerQuotesKey` | value | |
160
+ | `getInvMastDocKey` | value | |
161
+ | `getInvMastDocOptions` | value | |
162
+ | `getInvMastKey` | value | |
163
+ | `getInvMastOptions` | value | |
164
+ | `getInvMastStockKey` | function | |
165
+ | `getInvMastStockOptions` | value | |
166
+ | `getItemAttributesKey` | value | |
167
+ | `getItemAttributesOptions` | value | |
168
+ | `getItemCategoryKey` | value | |
169
+ | `getItemCategoryOptions` | value | |
170
+ | `getItemDetailsKey` | value | |
171
+ | `getItemDetailsOptions` | value | |
172
+ | `getItemPriceKey` | value | |
173
+ | `getItemPriceOptions` | value | |
174
+ | `getItemSearchInfiniteKey` | value | |
175
+ | `getItemSearchInfiniteOptions` | value | |
176
+ | `getJoomlaContentKey` | value | |
177
+ | `getJoomlaContentListKey` | value | |
178
+ | `getJoomlaContentListOptions` | value | |
179
+ | `getJoomlaContentOptions` | value | |
180
+ | `getJoomlaMenuDocKey` | value | |
181
+ | `getJoomlaMenuDocOptions` | value | |
182
+ | `getJoomlaMenuKey` | value | |
183
+ | `getJoomlaMenuOptions` | value | |
184
+ | `getProductCategoryKey` | value | |
185
+ | `getProductCategoryOptions` | value | |
186
+ | `getProductSearchKey` | value | |
187
+ | `getProductSearchOptions` | value | |
188
+ | `getQueryClient` | const | Returns a per-request singleton QueryClient for React Server Components. |
189
+ | `getSearchSuggestionsKey` | value | |
190
+ | `getSearchSuggestionsOptions` | value | |
191
+ | `getStockKey` | value | |
192
+ | `getStockOptions` | value | |
193
+ | `stableStringify` | value | |
194
+
195
+ ### Types
196
+
197
+ `AugurApiClient`, `AugurCallbacks`, `BatchInvMastDocParam`, `BatchQueryConfig`, `PageData`
198
+
199
+ ```ts
200
+ import { AugurAuthContext, CacheConfig, InfiniteScrollPage } from "@simpleapps-com/augur-hooks/server";
201
+ ```
202
+
203
+ ## `@simpleapps-com/augur-hooks/web`
204
+
205
+ ### Values
206
+
207
+ | Export | Kind | Description |
208
+ |--------|------|-------------|
209
+ | `MobileProvider` | function | Optional provider that tracks hydration state. |
210
+ | `useImageWithFallback` | function | |
211
+ | `useIsHydrated` | function | Returns true only after the client has hydrated. |
212
+ | `useIsMobile` | function | Returns whether the screen is mobile-sized. |
213
+ | `useMobileOptimizedIntersection` | const | IntersectionObserver hook with mobile-optimized root margins. |
214
+
215
+ ```ts
216
+ import { MobileProvider, useImageWithFallback, useIsHydrated } from "@simpleapps-com/augur-hooks/web";
217
+ ```
package/dist/index.cjs CHANGED
@@ -740,7 +740,13 @@ function useCartActions(callbacks) {
740
740
 
741
741
  var MAX_RETRY_ATTEMPTS = 7;
742
742
  var RETRY_DELAY_MS = 1e3;
743
+ var defaultGetCartToken = () => localStorage.getItem("cartToken");
744
+ var defaultSaveCartToken = (token) => localStorage.setItem("cartToken", token);
745
+ var defaultGenerateCartToken = () => crypto.randomUUID();
743
746
  function useCartInitialization(session, callbacks) {
747
+ const getCartToken = _nullishCoalesce(callbacks.getCartToken, () => ( defaultGetCartToken));
748
+ const saveCartToken = _nullishCoalesce(callbacks.saveCartToken, () => ( defaultSaveCartToken));
749
+ const generateCartToken = _nullishCoalesce(callbacks.generateCartToken, () => ( defaultGenerateCartToken));
744
750
  const auth = useAugurAuth();
745
751
  const cartHdrUid = useCartHdrUid();
746
752
  const setCartHdrUid = useSetCartHdrUid();
@@ -776,13 +782,13 @@ function useCartInitialization(session, callbacks) {
776
782
  isInitializingRef.current = true;
777
783
  retryCountRef.current = 0;
778
784
  const initializeGuestCart = async () => {
779
- const existingToken = callbacks.getCartToken();
780
- const cartToken = existingToken && typeof existingToken === "string" ? existingToken : callbacks.generateCartToken();
785
+ const existingToken = getCartToken();
786
+ const cartToken = existingToken && typeof existingToken === "string" ? existingToken : generateCartToken();
781
787
  while (retryCountRef.current < MAX_RETRY_ATTEMPTS) {
782
788
  try {
783
789
  const cartHdr = await callbacks.cartHdrLookup("0", cartToken);
784
790
  if (cartHdr && cartHdr.cartHdrUid !== 0) {
785
- callbacks.saveCartToken(cartToken);
791
+ saveCartToken(cartToken);
786
792
  setCartHdrUid(cartHdr.cartHdrUid);
787
793
  isInitializingRef.current = false;
788
794
  return;
@@ -809,7 +815,15 @@ function useCartInitialization(session, callbacks) {
809
815
  };
810
816
  void initializeGuestCart();
811
817
  }
812
- }, [effectiveSession, cartHdrUid, setCartHdrUid, callbacks]);
818
+ }, [
819
+ effectiveSession,
820
+ cartHdrUid,
821
+ setCartHdrUid,
822
+ callbacks,
823
+ getCartToken,
824
+ saveCartToken,
825
+ generateCartToken
826
+ ]);
813
827
  const { data: cartLinesData } = _reactquery.useQuery.call(void 0, {
814
828
  queryKey: ["cartLines", cartHdrUid],
815
829
  queryFn: async () => await _asyncNullishCoalesce(await callbacks.getCartLines(Number(cartHdrUid)), async () => ( [])),