@simpleapps-com/augur-hooks 0.1.4 → 0.1.6
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/dist/chunk-DS2ECDHJ.js +312 -0
- package/dist/chunk-DS2ECDHJ.js.map +1 -0
- package/dist/chunk-YSRBE3YI.cjs +312 -0
- package/dist/chunk-YSRBE3YI.cjs.map +1 -0
- package/dist/index.cjs +199 -322
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -275
- package/dist/index.d.ts +34 -275
- package/dist/index.js +169 -292
- package/dist/index.js.map +1 -1
- package/dist/server-CF43MUMf.d.cts +432 -0
- package/dist/server-CF43MUMf.d.ts +432 -0
- package/dist/server.cjs +65 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +4 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.js +65 -0
- package/dist/server.js.map +1 -0
- package/package.json +7 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,93 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { G as GetItemCategoryApiOptions, P as PageData, S as SearchSuggestionsResponse, a as SearchSuggestion, I as InfiniteScrollPage } from './server-CF43MUMf.cjs';
|
|
2
|
+
export { A as AugurApiClient, b as AugurAuthContext, c as AugurCallbacks, d as AugurHooksProvider, C as CATEGORY_CACHE_OPTIONS, e as INV_MAST_CACHE_OPTIONS, f as INV_MAST_DOC_CACHE_OPTIONS, g as PRICE_CACHE_OPTIONS, h as SEARCH_SUGGESTIONS_CACHE_OPTIONS, i as getCartPricingQueryOptions, j as getCategoryItemsInfiniteKey, k as getCategoryItemsInfiniteOptions, l as getInvMastDocKey, m as getInvMastDocOptions, n as getInvMastKey, o as getInvMastOptions, p as getInvMastStockKey, q as getInvMastStockOptions, r as getItemAttributesKey, s as getItemAttributesOptions, t as getItemCategoryKey, u as getItemCategoryOptions, v as getItemDetailsKey, w as getItemDetailsOptions, x as getItemPriceKey, y as getItemPriceOptions, z as getItemSearchInfiniteKey, B as getItemSearchInfiniteOptions, D as getProductCategoryKey, E as getProductCategoryOptions, F as getProductSearchKey, H as getProductSearchOptions, J as getSearchSuggestionsKey, K as getSearchSuggestionsOptions, L as useAugurApi, M as useAugurAuth } from './server-CF43MUMf.cjs';
|
|
3
3
|
import * as zustand from 'zustand';
|
|
4
|
-
import
|
|
5
|
-
import { TCartLine, TItemsFilters, TPriceData, TInvMastDoc, TCategory, TItemDetails, TProductCategory, TAttribute, TProductItem } from '@simpleapps-com/augur-utils';
|
|
4
|
+
import { TCartLine, TItemsFilters, TPriceData, TInvMastDoc, TCategory, TItemDetails, TAttribute } from '@simpleapps-com/augur-utils';
|
|
6
5
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
7
6
|
import { QueryKey } from '@tanstack/react-query';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* Minimal type for the augur-api SDK instance.
|
|
11
|
-
* Consumers provide their concrete AugurAPI instance; we keep the type
|
|
12
|
-
* loose so augur-hooks doesn't need to depend directly on the SDK package.
|
|
13
|
-
*/
|
|
14
|
-
type AugurApiClient = any;
|
|
15
|
-
interface AugurHooksProviderProps {
|
|
16
|
-
api: AugurApiClient;
|
|
17
|
-
children: ReactNode;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Provides the augur-api SDK instance to all hooks in the tree.
|
|
21
|
-
*
|
|
22
|
-
* ```tsx
|
|
23
|
-
* import { AugurAPI } from "@simpleapps-com/augur-api";
|
|
24
|
-
* const api = new AugurAPI({ baseUrl: "...", token: "..." });
|
|
25
|
-
*
|
|
26
|
-
* <AugurHooksProvider api={api}>
|
|
27
|
-
* <App />
|
|
28
|
-
* </AugurHooksProvider>
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
declare function AugurHooksProvider({ api, children }: AugurHooksProviderProps): react_jsx_runtime.JSX.Element;
|
|
32
|
-
/**
|
|
33
|
-
* Returns the augur-api SDK instance from context.
|
|
34
|
-
* Throws if called outside of `<AugurHooksProvider>`.
|
|
35
|
-
*/
|
|
36
|
-
declare function useAugurApi(): AugurApiClient;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Hook-specific types that don't belong in augur-utils.
|
|
40
|
-
* These describe hook parameters and API response shapes.
|
|
41
|
-
*/
|
|
42
|
-
/** Parameters for product search queries. */
|
|
43
|
-
type PageData = {
|
|
44
|
-
categoryIdList?: string;
|
|
45
|
-
filters?: [string, string][];
|
|
46
|
-
limit: number;
|
|
47
|
-
page: number;
|
|
48
|
-
offset: number;
|
|
49
|
-
q: string;
|
|
50
|
-
sortBy: string;
|
|
51
|
-
tagslist?: string;
|
|
52
|
-
itemCategoryUid?: number;
|
|
53
|
-
};
|
|
54
|
-
/** A single search suggestion from OpenSearch. */
|
|
55
|
-
type SearchSuggestion = {
|
|
56
|
-
suggestionsUid: number;
|
|
57
|
-
queryStringUid: number;
|
|
58
|
-
suggestionsString: string;
|
|
59
|
-
suggestionsMetaphone: string | null;
|
|
60
|
-
avgTotalResults: number;
|
|
61
|
-
dateCreated: string;
|
|
62
|
-
dateLastModified: string;
|
|
63
|
-
updateCd: number;
|
|
64
|
-
statusCd: number;
|
|
65
|
-
processCd: number;
|
|
66
|
-
score: number;
|
|
67
|
-
};
|
|
68
|
-
/** Response shape from the search suggestions endpoint. */
|
|
69
|
-
type SearchSuggestionsResponse = {
|
|
70
|
-
count: number;
|
|
71
|
-
data: SearchSuggestion[];
|
|
72
|
-
message: string;
|
|
73
|
-
options: unknown[];
|
|
74
|
-
params: unknown[];
|
|
75
|
-
status: number;
|
|
76
|
-
total: number;
|
|
77
|
-
totalResults: number;
|
|
78
|
-
};
|
|
79
|
-
/** API options for item category queries. */
|
|
80
|
-
interface GetItemCategoryApiOptions {
|
|
81
|
-
childrenFilter?: string;
|
|
82
|
-
childrenLimit?: number;
|
|
83
|
-
childrenOffset?: number;
|
|
84
|
-
classId5List?: string;
|
|
85
|
-
filters?: Record<string, string>;
|
|
86
|
-
orderBy?: string;
|
|
87
|
-
path?: string;
|
|
88
|
-
productCollection?: string;
|
|
89
|
-
rootItemCategoryId?: string;
|
|
90
|
-
}
|
|
7
|
+
import 'react/jsx-runtime';
|
|
8
|
+
import 'react';
|
|
91
9
|
|
|
92
10
|
interface CartState {
|
|
93
11
|
cartHdrUid: number | string | undefined;
|
|
@@ -163,35 +81,6 @@ interface UseItemPriceOptions {
|
|
|
163
81
|
/** Override the default queryFn (e.g. with a cached server action). */
|
|
164
82
|
queryFn?: () => Promise<TPriceData>;
|
|
165
83
|
}
|
|
166
|
-
declare const PRICE_CACHE_OPTIONS: {
|
|
167
|
-
readonly refetchOnReconnect: true;
|
|
168
|
-
readonly refetchOnWindowFocus: false;
|
|
169
|
-
readonly meta: {
|
|
170
|
-
readonly persist: true;
|
|
171
|
-
};
|
|
172
|
-
readonly staleTime: number;
|
|
173
|
-
readonly gcTime: number;
|
|
174
|
-
};
|
|
175
|
-
/**
|
|
176
|
-
* Generates a consistent query key for item price queries.
|
|
177
|
-
* Usable in both client hooks and server-side prefetch.
|
|
178
|
-
*/
|
|
179
|
-
declare const getItemPriceKey: (itemId: string | undefined, customerId: string | number | undefined, quantity?: number) => readonly ["price", string, string | number | undefined, number];
|
|
180
|
-
/**
|
|
181
|
-
* Query options for item price. Accepts the SDK instance so it works
|
|
182
|
-
* in both client (via provider) and server (via direct construction).
|
|
183
|
-
*/
|
|
184
|
-
declare const getItemPriceOptions: (api: AugurApiClient, itemId: string | undefined, customerId: string | number | undefined, quantity?: number) => {
|
|
185
|
-
refetchOnReconnect: true;
|
|
186
|
-
refetchOnWindowFocus: false;
|
|
187
|
-
meta: {
|
|
188
|
-
readonly persist: true;
|
|
189
|
-
};
|
|
190
|
-
staleTime: number;
|
|
191
|
-
gcTime: number;
|
|
192
|
-
queryKey: readonly ["price", string, string | number | undefined, number];
|
|
193
|
-
queryFn: () => Promise<TPriceData>;
|
|
194
|
-
};
|
|
195
84
|
/**
|
|
196
85
|
* Fetches and caches item pricing via the augur-api SDK.
|
|
197
86
|
*
|
|
@@ -212,25 +101,6 @@ interface UseInvMastDocOptions {
|
|
|
212
101
|
/** Override the default queryFn (e.g. with a cached server action). */
|
|
213
102
|
queryFn?: () => Promise<TInvMastDoc>;
|
|
214
103
|
}
|
|
215
|
-
declare const INV_MAST_DOC_CACHE_OPTIONS: {
|
|
216
|
-
readonly staleTime: number;
|
|
217
|
-
readonly gcTime: number;
|
|
218
|
-
};
|
|
219
|
-
/**
|
|
220
|
-
* Generates a consistent query key for inv mast doc queries.
|
|
221
|
-
* Usable in both client hooks and server-side prefetch.
|
|
222
|
-
*/
|
|
223
|
-
declare const getInvMastDocKey: (invMastUid: number, itemId: string, includePricing: "Y" | "N") => readonly ["invMastDoc", number, string, "Y" | "N"];
|
|
224
|
-
/**
|
|
225
|
-
* Query options for inv mast doc. Accepts the SDK instance so it works
|
|
226
|
-
* in both client (via provider) and server (via direct construction).
|
|
227
|
-
*/
|
|
228
|
-
declare const getInvMastDocOptions: (api: AugurApiClient, invMastUid: number, itemId: string, includePricing: "Y" | "N") => {
|
|
229
|
-
staleTime: number;
|
|
230
|
-
gcTime: number;
|
|
231
|
-
queryKey: readonly ["invMastDoc", number, string, "Y" | "N"];
|
|
232
|
-
queryFn: () => Promise<TInvMastDoc>;
|
|
233
|
-
};
|
|
234
104
|
/**
|
|
235
105
|
* Fetches and caches an inventory master document via the augur-api SDK.
|
|
236
106
|
*/
|
|
@@ -246,30 +116,6 @@ interface UseItemCategoryOptions {
|
|
|
246
116
|
/** Override the default queryFn (e.g. with a cached server action). */
|
|
247
117
|
queryFn?: () => Promise<TCategory>;
|
|
248
118
|
}
|
|
249
|
-
declare const CATEGORY_CACHE_OPTIONS: {
|
|
250
|
-
readonly staleTime: number;
|
|
251
|
-
readonly gcTime: number;
|
|
252
|
-
};
|
|
253
|
-
type ItemCategoryQueryKey = readonly [
|
|
254
|
-
"itemCategory",
|
|
255
|
-
number,
|
|
256
|
-
GetItemCategoryApiOptions | undefined
|
|
257
|
-
];
|
|
258
|
-
/**
|
|
259
|
-
* Generates a consistent query key for item category queries.
|
|
260
|
-
* Usable in both client hooks and server-side prefetch.
|
|
261
|
-
*/
|
|
262
|
-
declare const getItemCategoryKey: (itemCategoryUid: number, apiOptions?: GetItemCategoryApiOptions) => ItemCategoryQueryKey;
|
|
263
|
-
/**
|
|
264
|
-
* Query options for item category. Accepts the SDK instance so it works
|
|
265
|
-
* in both client (via provider) and server (via direct construction).
|
|
266
|
-
*/
|
|
267
|
-
declare const getItemCategoryOptions: (api: AugurApiClient, itemCategoryUid: number, apiOptions?: GetItemCategoryApiOptions) => {
|
|
268
|
-
staleTime: number;
|
|
269
|
-
gcTime: number;
|
|
270
|
-
queryKey: ItemCategoryQueryKey;
|
|
271
|
-
queryFn: () => Promise<TCategory>;
|
|
272
|
-
};
|
|
273
119
|
/**
|
|
274
120
|
* Fetches and caches item category data via the augur-api SDK.
|
|
275
121
|
*/
|
|
@@ -283,17 +129,6 @@ interface UseInvMastOptions {
|
|
|
283
129
|
enabled?: boolean;
|
|
284
130
|
queryFn?: () => Promise<TItemDetails>;
|
|
285
131
|
}
|
|
286
|
-
declare const INV_MAST_CACHE_OPTIONS: {
|
|
287
|
-
readonly staleTime: number;
|
|
288
|
-
readonly gcTime: number;
|
|
289
|
-
};
|
|
290
|
-
declare const getInvMastKey: (invMastUid: number, itemId: string) => readonly ["invMast", number, string];
|
|
291
|
-
declare const getInvMastOptions: (api: AugurApiClient, invMastUid: number, itemId: string) => {
|
|
292
|
-
staleTime: number;
|
|
293
|
-
gcTime: number;
|
|
294
|
-
queryKey: readonly ["invMast", number, string];
|
|
295
|
-
queryFn: () => Promise<TItemDetails>;
|
|
296
|
-
};
|
|
297
132
|
declare function useInvMast(invMastUid: number, itemId: string, options?: UseInvMastOptions): {
|
|
298
133
|
item: TItemDetails | undefined;
|
|
299
134
|
isLoading: boolean;
|
|
@@ -304,13 +139,6 @@ interface UseInvMastStockOptions {
|
|
|
304
139
|
enabled?: boolean;
|
|
305
140
|
queryFn?: () => Promise<number>;
|
|
306
141
|
}
|
|
307
|
-
declare const getInvMastStockKey: (invMastUid: number | string) => readonly ["invMastStock", string | number];
|
|
308
|
-
declare const getInvMastStockOptions: (api: AugurApiClient, invMastUid: number | string) => {
|
|
309
|
-
staleTime: number;
|
|
310
|
-
gcTime: number;
|
|
311
|
-
queryKey: readonly ["invMastStock", string | number];
|
|
312
|
-
queryFn: () => Promise<number>;
|
|
313
|
-
};
|
|
314
142
|
declare function useInvMastStock(invMastUid: number | string, options?: UseInvMastStockOptions): {
|
|
315
143
|
qtyOnHand: number | null;
|
|
316
144
|
loading: boolean;
|
|
@@ -320,40 +148,26 @@ declare function useInvMastStock(invMastUid: number | string, options?: UseInvMa
|
|
|
320
148
|
type ProductCategoryResponse = {
|
|
321
149
|
itemCategoryDesc: string;
|
|
322
150
|
childrenTotal: number;
|
|
323
|
-
children:
|
|
151
|
+
children: unknown[];
|
|
324
152
|
categoryImage: string | null;
|
|
325
153
|
};
|
|
326
154
|
interface UseProductCategoryOptions {
|
|
327
155
|
enabled?: boolean;
|
|
328
156
|
queryFn?: () => Promise<ProductCategoryResponse>;
|
|
329
157
|
}
|
|
330
|
-
declare const getProductCategoryKey: (itemCategoryUid: number | string | null) => readonly ["productCategory", string | number | null];
|
|
331
|
-
declare const getProductCategoryOptions: (api: AugurApiClient, itemCategoryUid: number | string) => {
|
|
332
|
-
staleTime: number;
|
|
333
|
-
gcTime: number;
|
|
334
|
-
queryKey: readonly ["productCategory", string | number | null];
|
|
335
|
-
queryFn: () => Promise<ProductCategoryResponse>;
|
|
336
|
-
};
|
|
337
158
|
declare function useProductCategory(itemCategoryUid: number | string | null, options?: UseProductCategoryOptions): {
|
|
159
|
+
loading: boolean;
|
|
160
|
+
error: Error | null;
|
|
338
161
|
childrenTotal: number;
|
|
339
162
|
itemCategoryDesc: string;
|
|
340
|
-
productCategories:
|
|
163
|
+
productCategories: unknown[] | null;
|
|
341
164
|
productCategoryImage: string | null;
|
|
342
|
-
loading: boolean;
|
|
343
|
-
error: Error | null;
|
|
344
165
|
};
|
|
345
166
|
|
|
346
167
|
interface UseItemDetailsOptions {
|
|
347
168
|
enabled?: boolean;
|
|
348
169
|
queryFn?: () => Promise<TItemDetails>;
|
|
349
170
|
}
|
|
350
|
-
declare const getItemDetailsKey: (itemId: number | string) => readonly ["itemDetails", string | number];
|
|
351
|
-
declare const getItemDetailsOptions: (api: AugurApiClient, itemId: number | string) => {
|
|
352
|
-
staleTime: number;
|
|
353
|
-
gcTime: number;
|
|
354
|
-
queryKey: readonly ["itemDetails", string | number];
|
|
355
|
-
queryFn: () => Promise<TItemDetails>;
|
|
356
|
-
};
|
|
357
171
|
declare function useItemDetails(itemId: number | string | undefined, options?: UseItemDetailsOptions): {
|
|
358
172
|
itemCategoryUid: number | null | undefined;
|
|
359
173
|
itemDetails: TItemDetails | null;
|
|
@@ -367,13 +181,6 @@ interface UseItemAttributesOptions {
|
|
|
367
181
|
attributes: TAttribute[];
|
|
368
182
|
}>;
|
|
369
183
|
}
|
|
370
|
-
declare const getItemAttributesKey: (itemCategoryUid: number | string | null) => readonly ["itemAttributes", string | number | null];
|
|
371
|
-
declare const getItemAttributesOptions: (api: AugurApiClient, itemCategoryUid: number | string) => {
|
|
372
|
-
staleTime: number;
|
|
373
|
-
gcTime: number;
|
|
374
|
-
queryKey: readonly ["itemAttributes", string | number | null];
|
|
375
|
-
queryFn: () => Promise<any>;
|
|
376
|
-
};
|
|
377
184
|
declare function useItemAttributes(itemCategoryUid: number | string | null, options?: UseItemAttributesOptions): {
|
|
378
185
|
attributes: any;
|
|
379
186
|
loading: boolean;
|
|
@@ -381,33 +188,19 @@ declare function useItemAttributes(itemCategoryUid: number | string | null, opti
|
|
|
381
188
|
};
|
|
382
189
|
|
|
383
190
|
type ProductSearchResponse = {
|
|
384
|
-
items:
|
|
191
|
+
items: unknown[];
|
|
385
192
|
totalResults: number;
|
|
386
193
|
};
|
|
387
194
|
interface UseProductSearchOptions {
|
|
388
195
|
/** Override the default queryFn (e.g. with a cached server action). */
|
|
389
196
|
queryFn?: () => Promise<ProductSearchResponse>;
|
|
390
197
|
}
|
|
391
|
-
/**
|
|
392
|
-
* Generates a consistent query key for product search queries.
|
|
393
|
-
*/
|
|
394
|
-
declare const getProductSearchKey: (pageData: PageData) => readonly ["productSearch", string, number, number, string, number | undefined];
|
|
395
|
-
/**
|
|
396
|
-
* Query options for product search. Accepts the SDK instance so it works
|
|
397
|
-
* in both client (via provider) and server (via direct construction).
|
|
398
|
-
*/
|
|
399
|
-
declare const getProductSearchOptions: (api: AugurApiClient, pageData: PageData) => {
|
|
400
|
-
staleTime: number;
|
|
401
|
-
gcTime: number;
|
|
402
|
-
queryKey: readonly ["productSearch", string, number, number, string, number | undefined];
|
|
403
|
-
queryFn: () => Promise<ProductSearchResponse>;
|
|
404
|
-
};
|
|
405
198
|
/**
|
|
406
199
|
* Searches products via the augur-api OpenSearch endpoint.
|
|
407
200
|
* Replaces the ampro-online pattern of fetching from a Next.js API route.
|
|
408
201
|
*/
|
|
409
202
|
declare function useProductSearch(pageData: PageData, options?: UseProductSearchOptions): {
|
|
410
|
-
productItems:
|
|
203
|
+
productItems: unknown[] | null;
|
|
411
204
|
total: number;
|
|
412
205
|
loading: boolean;
|
|
413
206
|
error: Error | null;
|
|
@@ -420,20 +213,6 @@ interface UseSearchSuggestionsOptions {
|
|
|
420
213
|
/** Override the default queryFn (e.g. with a cached server action). */
|
|
421
214
|
queryFn?: () => Promise<SearchSuggestionsResponse>;
|
|
422
215
|
}
|
|
423
|
-
/**
|
|
424
|
-
* Generates a consistent query key for search suggestion queries.
|
|
425
|
-
*/
|
|
426
|
-
declare const getSearchSuggestionsKey: (query: string, limit: number, offset: number) => readonly ["searchSuggestions", string, number, number];
|
|
427
|
-
/**
|
|
428
|
-
* Query options for search suggestions. Accepts the SDK instance so it works
|
|
429
|
-
* in both client (via provider) and server (via direct construction).
|
|
430
|
-
*/
|
|
431
|
-
declare const getSearchSuggestionsOptions: (api: AugurApiClient, query: string, limit?: number, offset?: number) => {
|
|
432
|
-
staleTime: number;
|
|
433
|
-
gcTime: number;
|
|
434
|
-
queryKey: readonly ["searchSuggestions", string, number, number];
|
|
435
|
-
queryFn: () => Promise<SearchSuggestionsResponse>;
|
|
436
|
-
};
|
|
437
216
|
/**
|
|
438
217
|
* Fetches search suggestions via the augur-api OpenSearch endpoint.
|
|
439
218
|
* Replaces the ampro-online pattern of fetching from a Next.js API route.
|
|
@@ -450,17 +229,17 @@ type CartLineInput = Pick<TCartLine, "invMastUid" | "quantity" | "unitOfMeasure"
|
|
|
450
229
|
};
|
|
451
230
|
/** Site-specific callbacks injected into useCartActions. */
|
|
452
231
|
interface CartActionCallbacks {
|
|
453
|
-
/** Add items to cart via API.
|
|
232
|
+
/** Add items to cart via API. Truthy = success, falsy = failure. */
|
|
454
233
|
addToCart: (cartHdrUid: number, items: Array<{
|
|
455
234
|
cartHdrUid: number;
|
|
456
235
|
invMastUid: number;
|
|
457
236
|
quantity: number;
|
|
458
237
|
unitOfMeasure: string;
|
|
459
|
-
}>) => Promise<boolean>;
|
|
460
|
-
/** Update cart lines via API.
|
|
461
|
-
updateCartLines: (cartHdrUid: number, lines: TCartLine[]) => Promise<boolean>;
|
|
462
|
-
/** Delete all items from cart via API.
|
|
463
|
-
deleteItemsFromCart: (cartHdrUid: number) => Promise<boolean>;
|
|
238
|
+
}>) => Promise<boolean | undefined | void>;
|
|
239
|
+
/** Update cart lines via API. Truthy = success, falsy = failure. */
|
|
240
|
+
updateCartLines: (cartHdrUid: number, lines: TCartLine[]) => Promise<boolean | undefined | void>;
|
|
241
|
+
/** Delete all items from cart via API. Truthy = success, falsy = failure. */
|
|
242
|
+
deleteItemsFromCart: (cartHdrUid: number) => Promise<boolean | undefined | void>;
|
|
464
243
|
/** Optional toast notification callback. */
|
|
465
244
|
toast?: {
|
|
466
245
|
info?: (message: string) => void;
|
|
@@ -513,17 +292,17 @@ interface CartSessionInfo {
|
|
|
513
292
|
/** User's ID (e.g., Joomla user ID). Undefined if not authenticated. */
|
|
514
293
|
userId?: string | number;
|
|
515
294
|
/** Cart header UID from the auth session, if available. */
|
|
516
|
-
cartHdrUid?: number;
|
|
295
|
+
cartHdrUid?: number | string;
|
|
517
296
|
}
|
|
518
297
|
/** Site-specific callbacks injected into useCartInitialization. */
|
|
519
298
|
interface CartInitCallbacks {
|
|
520
299
|
/** Look up or create a cart header. Returns { cartHdrUid, cartToken? }. */
|
|
521
300
|
cartHdrLookup: (userId: string | number, cartToken: string) => Promise<{
|
|
522
301
|
cartHdrUid: number;
|
|
523
|
-
cartToken?: string;
|
|
524
|
-
} | null>;
|
|
302
|
+
cartToken?: string | null;
|
|
303
|
+
} | null | undefined>;
|
|
525
304
|
/** Fetch cart line items for a given cart header UID. */
|
|
526
|
-
getCartLines: (cartHdrUid: number) => Promise<TCartLine[]>;
|
|
305
|
+
getCartLines: (cartHdrUid: number) => Promise<TCartLine[] | undefined>;
|
|
527
306
|
/** Get the current cart token from cookies. */
|
|
528
307
|
getCartToken: () => string | null;
|
|
529
308
|
/** Save cart token to cookies. */
|
|
@@ -593,6 +372,8 @@ interface CartPricingResult {
|
|
|
593
372
|
}
|
|
594
373
|
interface UseCartPricingOptions {
|
|
595
374
|
customerId?: string | number;
|
|
375
|
+
/** Override per-item price fetching (e.g. with a server action). */
|
|
376
|
+
queryFn?: (itemId: string, customerId: string | number, quantity: number) => Promise<TPriceData>;
|
|
596
377
|
}
|
|
597
378
|
/**
|
|
598
379
|
* Centralized hook for cart/checkout pricing.
|
|
@@ -602,24 +383,6 @@ interface UseCartPricingOptions {
|
|
|
602
383
|
* identical calls across components.
|
|
603
384
|
*/
|
|
604
385
|
declare function useCartPricing(options?: UseCartPricingOptions): CartPricingResult;
|
|
605
|
-
/**
|
|
606
|
-
* Get cart pricing query options for prefetching or parent components.
|
|
607
|
-
*/
|
|
608
|
-
declare function getCartPricingQueryOptions(api: ReturnType<typeof useAugurApi>, cartLines: Array<{
|
|
609
|
-
itemId: string;
|
|
610
|
-
quantity: number;
|
|
611
|
-
}>, customerId: string | number | undefined): {
|
|
612
|
-
enabled: boolean;
|
|
613
|
-
refetchOnReconnect: true;
|
|
614
|
-
refetchOnWindowFocus: false;
|
|
615
|
-
meta: {
|
|
616
|
-
readonly persist: true;
|
|
617
|
-
};
|
|
618
|
-
staleTime: number;
|
|
619
|
-
gcTime: number;
|
|
620
|
-
queryKey: readonly ["price", string, string | number | undefined, number];
|
|
621
|
-
queryFn: () => Promise<_simpleapps_com_augur_utils.TPriceData>;
|
|
622
|
-
}[];
|
|
623
386
|
|
|
624
387
|
interface UsePaginationPrefetchOptions {
|
|
625
388
|
/** Query key for the paginated data */
|
|
@@ -643,34 +406,30 @@ declare const usePaginationPrefetch: ({ queryKey, queryFn, pageSize, staleTime,
|
|
|
643
406
|
handlePaginationHover: (page: number) => () => void;
|
|
644
407
|
};
|
|
645
408
|
|
|
646
|
-
interface CategoryItemsInfiniteResponse {
|
|
647
|
-
data: TProductItem[];
|
|
648
|
-
total: number;
|
|
649
|
-
nextCursor?: number;
|
|
650
|
-
}
|
|
651
409
|
interface UseCategoryItemsInfiniteOptions {
|
|
652
410
|
enabled?: boolean;
|
|
411
|
+
/** Override the default queryFn (e.g. with a server action). */
|
|
412
|
+
queryFn?: (context: {
|
|
413
|
+
pageParam: unknown;
|
|
414
|
+
}) => Promise<InfiniteScrollPage>;
|
|
653
415
|
}
|
|
654
|
-
declare const getCategoryItemsInfiniteKey: (itemCategoryUid: number, itemsFilters: TItemsFilters) => readonly ["categoryItemsInfinite", number, string];
|
|
655
416
|
/**
|
|
656
417
|
* Infinite scroll for category product listings.
|
|
657
418
|
* Fetches pages of products via the augur-api SDK.
|
|
658
419
|
*/
|
|
659
|
-
declare function useCategoryItemsInfinite(itemCategoryUid: number, itemsFilters: TItemsFilters, options?: UseCategoryItemsInfiniteOptions): _tanstack_react_query.UseInfiniteQueryResult<_tanstack_react_query.InfiniteData<
|
|
420
|
+
declare function useCategoryItemsInfinite(itemCategoryUid: number, itemsFilters: TItemsFilters, options?: UseCategoryItemsInfiniteOptions): _tanstack_react_query.UseInfiniteQueryResult<_tanstack_react_query.InfiniteData<InfiniteScrollPage, unknown>, Error>;
|
|
660
421
|
|
|
661
|
-
interface ItemSearchInfiniteResponse {
|
|
662
|
-
data: TProductItem[];
|
|
663
|
-
total: number;
|
|
664
|
-
nextCursor?: number;
|
|
665
|
-
}
|
|
666
422
|
interface UseItemSearchInfiniteOptions {
|
|
667
423
|
enabled?: boolean;
|
|
424
|
+
/** Override the default queryFn (e.g. with a server action). */
|
|
425
|
+
queryFn?: (context: {
|
|
426
|
+
pageParam: unknown;
|
|
427
|
+
}) => Promise<InfiniteScrollPage>;
|
|
668
428
|
}
|
|
669
|
-
declare const getItemSearchInfiniteKey: (itemsFilters: TItemsFilters, itemCategoryUid?: number | string) => readonly ["itemSearchInfinite", string, string | number | undefined];
|
|
670
429
|
/**
|
|
671
430
|
* Infinite scroll for search results.
|
|
672
431
|
* Fetches pages of products via the augur-api SDK OpenSearch endpoint.
|
|
673
432
|
*/
|
|
674
|
-
declare function useItemSearchInfinite(itemsFilters: TItemsFilters, itemCategoryUid?: number | string, options?: UseItemSearchInfiniteOptions): _tanstack_react_query.UseInfiniteQueryResult<_tanstack_react_query.InfiniteData<
|
|
433
|
+
declare function useItemSearchInfinite(itemsFilters: TItemsFilters, itemCategoryUid?: number | string, options?: UseItemSearchInfiniteOptions): _tanstack_react_query.UseInfiniteQueryResult<_tanstack_react_query.InfiniteData<InfiniteScrollPage, unknown>, Error>;
|
|
675
434
|
|
|
676
|
-
export { type
|
|
435
|
+
export { type CartActionCallbacks, type CartInitCallbacks, type CartPriceData, type CartPricingResult, type CartSessionInfo, GetItemCategoryApiOptions, InfiniteScrollPage, PageData, SearchSuggestion, SearchSuggestionsResponse, useCartActions, useCartHdrUid, useCartInitialization, useCartItemCount, useCartLines, useCartPricing, useCartStore, useCategoryItemsInfinite, useClearCart, useDebounce, useFormatPrice, useInvMast, useInvMastDoc, useInvMastStock, useItemAttributes, useItemCategory, useItemDetails, useItemFiltersStore, useItemPrice, useItemSearchInfinite, usePaginationPrefetch, useProductCategory, useProductSearch, useSearchSuggestions, useSetCartHdrUid, useSetCartLines };
|