@simpleapps-com/augur-hooks 0.1.4 → 0.1.5

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/index.d.cts CHANGED
@@ -1,93 +1,11 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ReactNode } from 'react';
1
+ import { G as GetItemCategoryApiOptions, P as PageData, S as SearchSuggestionsResponse, a as SearchSuggestion } from './server-ZsiDw2HO.cjs';
2
+ export { A as AugurApiClient, b as AugurHooksProvider, C as CATEGORY_CACHE_OPTIONS, I as INV_MAST_CACHE_OPTIONS, c as INV_MAST_DOC_CACHE_OPTIONS, d as PRICE_CACHE_OPTIONS, e as SEARCH_SUGGESTIONS_CACHE_OPTIONS, g as getCartPricingQueryOptions, f as getCategoryItemsInfiniteKey, h as getInvMastDocKey, i as getInvMastDocOptions, j as getInvMastKey, k as getInvMastOptions, l as getInvMastStockKey, m as getInvMastStockOptions, n as getItemAttributesKey, o as getItemAttributesOptions, p as getItemCategoryKey, q as getItemCategoryOptions, r as getItemDetailsKey, s as getItemDetailsOptions, t as getItemPriceKey, u as getItemPriceOptions, v as getItemSearchInfiniteKey, w as getProductCategoryKey, x as getProductCategoryOptions, y as getProductSearchKey, z as getProductSearchOptions, B as getSearchSuggestionsKey, D as getSearchSuggestionsOptions, E as useAugurApi } from './server-ZsiDw2HO.cjs';
3
3
  import * as zustand from 'zustand';
4
- import * as _simpleapps_com_augur_utils from '@simpleapps-com/augur-utils';
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, TProductItem } 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,24 +148,17 @@ declare function useInvMastStock(invMastUid: number | string, options?: UseInvMa
320
148
  type ProductCategoryResponse = {
321
149
  itemCategoryDesc: string;
322
150
  childrenTotal: number;
323
- children: TProductCategory[];
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): {
338
159
  childrenTotal: number;
339
160
  itemCategoryDesc: string;
340
- productCategories: TProductCategory[] | null;
161
+ productCategories: unknown[] | null;
341
162
  productCategoryImage: string | null;
342
163
  loading: boolean;
343
164
  error: Error | null;
@@ -347,13 +168,6 @@ 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: TProductItem[];
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: TProductItem[] | null;
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.
@@ -602,24 +381,6 @@ interface UseCartPricingOptions {
602
381
  * identical calls across components.
603
382
  */
604
383
  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
384
 
624
385
  interface UsePaginationPrefetchOptions {
625
386
  /** Query key for the paginated data */
@@ -651,7 +412,6 @@ interface CategoryItemsInfiniteResponse {
651
412
  interface UseCategoryItemsInfiniteOptions {
652
413
  enabled?: boolean;
653
414
  }
654
- declare const getCategoryItemsInfiniteKey: (itemCategoryUid: number, itemsFilters: TItemsFilters) => readonly ["categoryItemsInfinite", number, string];
655
415
  /**
656
416
  * Infinite scroll for category product listings.
657
417
  * Fetches pages of products via the augur-api SDK.
@@ -666,11 +426,10 @@ interface ItemSearchInfiniteResponse {
666
426
  interface UseItemSearchInfiniteOptions {
667
427
  enabled?: boolean;
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
433
  declare function useItemSearchInfinite(itemsFilters: TItemsFilters, itemCategoryUid?: number | string, options?: UseItemSearchInfiniteOptions): _tanstack_react_query.UseInfiniteQueryResult<_tanstack_react_query.InfiniteData<ItemSearchInfiniteResponse, unknown>, Error>;
675
434
 
676
- export { type AugurApiClient, AugurHooksProvider, CATEGORY_CACHE_OPTIONS, type CartActionCallbacks, type CartInitCallbacks, type CartPriceData, type CartPricingResult, type CartSessionInfo, type GetItemCategoryApiOptions, INV_MAST_CACHE_OPTIONS, INV_MAST_DOC_CACHE_OPTIONS, PRICE_CACHE_OPTIONS, type PageData, type SearchSuggestion, type SearchSuggestionsResponse, getCartPricingQueryOptions, getCategoryItemsInfiniteKey, getInvMastDocKey, getInvMastDocOptions, getInvMastKey, getInvMastOptions, getInvMastStockKey, getInvMastStockOptions, getItemAttributesKey, getItemAttributesOptions, getItemCategoryKey, getItemCategoryOptions, getItemDetailsKey, getItemDetailsOptions, getItemPriceKey, getItemPriceOptions, getItemSearchInfiniteKey, getProductCategoryKey, getProductCategoryOptions, getProductSearchKey, getProductSearchOptions, getSearchSuggestionsKey, getSearchSuggestionsOptions, useAugurApi, 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 };
435
+ export { type CartActionCallbacks, type CartInitCallbacks, type CartPriceData, type CartPricingResult, type CartSessionInfo, GetItemCategoryApiOptions, 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 };