@simpleapps-com/augur-hooks 2.0.4 → 2.0.7

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,5 +1,5 @@
1
- import { G as GetItemCategoryApiOptions, B as BatchInvMastDocParam, P as PageData, A as AugurCallbacks, a as AugurApiClient, b as PersistenceConfig } from './customer-quotes-iSzQcffc.cjs';
2
- export { c as AugurHooksProvider, d as BatchQueryConfig, e as executeBatchQuery, g as getBatchInvMastDocKey, f as getBatchInvMastDocOptions, h as getCartPricingQueryOptions, i as getCategoryItemsInfiniteKey, j as getCategoryItemsInfiniteOptions, k as getCustomerInvoiceDetailKey, l as getCustomerInvoicesKey, m as getCustomerOrderDetailKey, n as getCustomerOrdersKey, o as getCustomerQuoteDetailKey, p as getCustomerQuotesKey, q as getInvMastDocKey, r as getInvMastDocOptions, s as getInvMastKey, t as getInvMastOptions, u as getInvMastStockKey, v as getInvMastStockOptions, w as getItemAttributesKey, x as getItemAttributesOptions, y as getItemCategoryKey, z as getItemCategoryOptions, C as getItemDetailsKey, D as getItemDetailsOptions, E as getItemPriceKey, F as getItemPriceOptions, H as getItemSearchInfiniteKey, I as getItemSearchInfiniteOptions, J as getJoomlaContentKey, K as getJoomlaContentListKey, L as getJoomlaContentListOptions, M as getJoomlaContentOptions, N as getJoomlaMenuDocKey, O as getJoomlaMenuDocOptions, Q as getJoomlaMenuKey, R as getJoomlaMenuOptions, S as getProductCategoryKey, T as getProductCategoryOptions, U as getProductSearchKey, V as getProductSearchOptions, W as getSearchSuggestionsKey, X as getSearchSuggestionsOptions, Y as getStockKey, Z as getStockOptions, _ as useAugurApi, $ as useAugurApiOptional, a0 as useAugurAuth, a1 as useAugurCache, a2 as useAugurOptions, a3 as useAugurSite } from './customer-quotes-iSzQcffc.cjs';
1
+ import { G as GetItemCategoryApiOptions, B as BatchInvMastDocParam, P as PageData, A as AugurCallbacks, a as AugurApiClient, b as PersistenceConfig } from './customer-quotes-BQYqzomR.cjs';
2
+ export { c as AugurHooksProvider, d as BatchQueryConfig, e as executeBatchQuery, g as getBatchInvMastDocKey, f as getBatchInvMastDocOptions, h as getCartPricingQueryOptions, i as getCategoryItemsInfiniteKey, j as getCategoryItemsInfiniteOptions, k as getCustomerInvoiceDetailKey, l as getCustomerInvoicesKey, m as getCustomerOrderDetailKey, n as getCustomerOrdersKey, o as getCustomerQuoteDetailKey, p as getCustomerQuotesKey, q as getInvMastDocKey, r as getInvMastDocOptions, s as getInvMastKey, t as getInvMastOptions, u as getInvMastStockKey, v as getInvMastStockOptions, w as getItemAttributesKey, x as getItemAttributesOptions, y as getItemCategoryKey, z as getItemCategoryOptions, C as getItemDetailsKey, D as getItemDetailsOptions, E as getItemPriceKey, F as getItemPriceOptions, H as getItemSearchInfiniteKey, I as getItemSearchInfiniteOptions, J as getJoomlaContentKey, K as getJoomlaContentListKey, L as getJoomlaContentListOptions, M as getJoomlaContentOptions, N as getJoomlaMenuDocKey, O as getJoomlaMenuDocOptions, Q as getJoomlaMenuKey, R as getJoomlaMenuOptions, S as getProductCategoryKey, T as getProductCategoryOptions, U as getProductSearchKey, V as getProductSearchOptions, W as getSearchSuggestionsKey, X as getSearchSuggestionsOptions, Y as getStockKey, Z as getStockOptions, _ as useAugurApi, $ as useAugurApiOptional, a0 as useAugurAuth, a1 as useAugurCache, a2 as useAugurOptions, a3 as useAugurSite } from './customer-quotes-BQYqzomR.cjs';
3
3
  import { InfiniteScrollPage, ListResult, CacheConfig, AugurAuthContext } from '@simpleapps-com/augur-core';
4
4
  export { AugurAuthContext, AugurSiteConfig, AugurSiteDefaults, AugurSiteFormatting, CacheConfig, CacheProvider, CacheTierConfig, DeepQueryOptions, EdgeCacheValue, InfiniteScrollPage, ProxyMutationOptions, ProxyQueryOptions } from '@simpleapps-com/augur-core';
5
5
  import * as zustand from 'zustand';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { G as GetItemCategoryApiOptions, B as BatchInvMastDocParam, P as PageData, A as AugurCallbacks, a as AugurApiClient, b as PersistenceConfig } from './customer-quotes-iSzQcffc.js';
2
- export { c as AugurHooksProvider, d as BatchQueryConfig, e as executeBatchQuery, g as getBatchInvMastDocKey, f as getBatchInvMastDocOptions, h as getCartPricingQueryOptions, i as getCategoryItemsInfiniteKey, j as getCategoryItemsInfiniteOptions, k as getCustomerInvoiceDetailKey, l as getCustomerInvoicesKey, m as getCustomerOrderDetailKey, n as getCustomerOrdersKey, o as getCustomerQuoteDetailKey, p as getCustomerQuotesKey, q as getInvMastDocKey, r as getInvMastDocOptions, s as getInvMastKey, t as getInvMastOptions, u as getInvMastStockKey, v as getInvMastStockOptions, w as getItemAttributesKey, x as getItemAttributesOptions, y as getItemCategoryKey, z as getItemCategoryOptions, C as getItemDetailsKey, D as getItemDetailsOptions, E as getItemPriceKey, F as getItemPriceOptions, H as getItemSearchInfiniteKey, I as getItemSearchInfiniteOptions, J as getJoomlaContentKey, K as getJoomlaContentListKey, L as getJoomlaContentListOptions, M as getJoomlaContentOptions, N as getJoomlaMenuDocKey, O as getJoomlaMenuDocOptions, Q as getJoomlaMenuKey, R as getJoomlaMenuOptions, S as getProductCategoryKey, T as getProductCategoryOptions, U as getProductSearchKey, V as getProductSearchOptions, W as getSearchSuggestionsKey, X as getSearchSuggestionsOptions, Y as getStockKey, Z as getStockOptions, _ as useAugurApi, $ as useAugurApiOptional, a0 as useAugurAuth, a1 as useAugurCache, a2 as useAugurOptions, a3 as useAugurSite } from './customer-quotes-iSzQcffc.js';
1
+ import { G as GetItemCategoryApiOptions, B as BatchInvMastDocParam, P as PageData, A as AugurCallbacks, a as AugurApiClient, b as PersistenceConfig } from './customer-quotes-BQYqzomR.js';
2
+ export { c as AugurHooksProvider, d as BatchQueryConfig, e as executeBatchQuery, g as getBatchInvMastDocKey, f as getBatchInvMastDocOptions, h as getCartPricingQueryOptions, i as getCategoryItemsInfiniteKey, j as getCategoryItemsInfiniteOptions, k as getCustomerInvoiceDetailKey, l as getCustomerInvoicesKey, m as getCustomerOrderDetailKey, n as getCustomerOrdersKey, o as getCustomerQuoteDetailKey, p as getCustomerQuotesKey, q as getInvMastDocKey, r as getInvMastDocOptions, s as getInvMastKey, t as getInvMastOptions, u as getInvMastStockKey, v as getInvMastStockOptions, w as getItemAttributesKey, x as getItemAttributesOptions, y as getItemCategoryKey, z as getItemCategoryOptions, C as getItemDetailsKey, D as getItemDetailsOptions, E as getItemPriceKey, F as getItemPriceOptions, H as getItemSearchInfiniteKey, I as getItemSearchInfiniteOptions, J as getJoomlaContentKey, K as getJoomlaContentListKey, L as getJoomlaContentListOptions, M as getJoomlaContentOptions, N as getJoomlaMenuDocKey, O as getJoomlaMenuDocOptions, Q as getJoomlaMenuKey, R as getJoomlaMenuOptions, S as getProductCategoryKey, T as getProductCategoryOptions, U as getProductSearchKey, V as getProductSearchOptions, W as getSearchSuggestionsKey, X as getSearchSuggestionsOptions, Y as getStockKey, Z as getStockOptions, _ as useAugurApi, $ as useAugurApiOptional, a0 as useAugurAuth, a1 as useAugurCache, a2 as useAugurOptions, a3 as useAugurSite } from './customer-quotes-BQYqzomR.js';
3
3
  import { InfiniteScrollPage, ListResult, CacheConfig, AugurAuthContext } from '@simpleapps-com/augur-core';
4
4
  export { AugurAuthContext, AugurSiteConfig, AugurSiteDefaults, AugurSiteFormatting, CacheConfig, CacheProvider, CacheTierConfig, DeepQueryOptions, EdgeCacheValue, InfiniteScrollPage, ProxyMutationOptions, ProxyQueryOptions } from '@simpleapps-com/augur-core';
5
5
  import * as zustand from 'zustand';
package/dist/index.js CHANGED
@@ -43,7 +43,7 @@ import {
43
43
  getSearchSuggestionsOptions,
44
44
  getStockKey,
45
45
  getStockOptions
46
- } from "./chunk-PP74YBNR.js";
46
+ } from "./chunk-QFZHOGID.js";
47
47
  import {
48
48
  useImageWithFallback
49
49
  } from "./chunk-LTBEP4MC.js";
@@ -53,12 +53,8 @@ import { createContext, useContext, useMemo } from "react";
53
53
  import { createOptionsProxy } from "@simpleapps-com/augur-core";
54
54
  import { jsx } from "react/jsx-runtime";
55
55
  var AugurApiContext = createContext(null);
56
- var AugurCallbacksContext = createContext(
57
- void 0
58
- );
59
- var AugurAuthReactContext = createContext(
60
- void 0
61
- );
56
+ var AugurCallbacksContext = createContext(void 0);
57
+ var AugurAuthReactContext = createContext(void 0);
62
58
  var AugurCacheContext = createContext(void 0);
63
59
  var AugurOptionsContext = createContext(null);
64
60
  var AugurSiteContext = createContext(void 0);
@@ -70,7 +66,7 @@ function AugurHooksProvider({
70
66
  site,
71
67
  children
72
68
  }) {
73
- if (process.env.NODE_ENV === "development" && !api && !callbacks) {
69
+ if (process.env["NODE_ENV"] === "development" && !api && !callbacks) {
74
70
  console.warn(
75
71
  "AugurHooksProvider: neither `api` nor `callbacks` provided. Hooks will fail at runtime unless every hook receives a queryFn override."
76
72
  );
@@ -129,10 +125,7 @@ var useCartStore = create()(
129
125
  cartLineCount: 0,
130
126
  setCartHdrUid: (cartHdrUid) => set({ cartHdrUid }, false, "setCartHdrUid"),
131
127
  setCartLines: (cartLines) => {
132
- const cartQuantityTotal = cartLines.reduce(
133
- (sum, line) => sum + (line.quantity || 0),
134
- 0
135
- );
128
+ const cartQuantityTotal = cartLines.reduce((sum, line) => sum + (line.quantity || 0), 0);
136
129
  const cartLineCount = cartLines.length;
137
130
  set({ cartLines, cartQuantityTotal, cartLineCount }, false, "setCartLines");
138
131
  },
@@ -142,7 +135,7 @@ var useCartStore = create()(
142
135
  "clearCart"
143
136
  )
144
137
  }),
145
- { name: "CartStore", enabled: process.env.NODE_ENV === "development" }
138
+ { name: "CartStore", enabled: process.env["NODE_ENV"] === "development" }
146
139
  )
147
140
  );
148
141
  var useCartHdrUid = () => useCartStore((s) => s.cartHdrUid);
@@ -173,7 +166,7 @@ var useItemFiltersStore = create2()(
173
166
  }),
174
167
  {
175
168
  name: "ItemsFiltersStore",
176
- enabled: process.env.NODE_ENV === "development"
169
+ enabled: process.env["NODE_ENV"] === "development"
177
170
  }
178
171
  )
179
172
  );
@@ -211,7 +204,12 @@ function resolveFormatting(opts, siteFormatting) {
211
204
  function useFormatPrice(optionsOrLocale, legacyCurrency) {
212
205
  const site = useAugurSite();
213
206
  const opts = normaliseOptions(optionsOrLocale, legacyCurrency);
214
- const { locale, currency, precision: basePrecision, zeroLabel } = resolveFormatting(opts, site?.formatting);
207
+ const {
208
+ locale,
209
+ currency,
210
+ precision: basePrecision,
211
+ zeroLabel
212
+ } = resolveFormatting(opts, site?.formatting);
215
213
  const formatPrice = (price, callOptions) => {
216
214
  const effectiveValue = price * (callOptions?.quantity ?? 1);
217
215
  if (effectiveValue === 0 && zeroLabel !== void 0) {
@@ -269,7 +267,9 @@ function useInvMastDoc(invMastUid, itemId, options = {}) {
269
267
  );
270
268
  const { data, isLoading, error } = useQuery2({
271
269
  ...queryOpts,
272
- ...options.queryFn ?? callbacks?.getInvMastDoc ? { queryFn: options.queryFn ?? (() => callbacks.getInvMastDoc(invMastUid, itemId, options.includePricing ?? "N")) } : {},
270
+ ...options.queryFn ?? callbacks?.getInvMastDoc ? {
271
+ queryFn: options.queryFn ?? (() => callbacks.getInvMastDoc(invMastUid, itemId, options.includePricing ?? "N"))
272
+ } : {},
273
273
  enabled: options.enabled ?? true,
274
274
  initialData: options.initialData
275
275
  });
@@ -282,15 +282,12 @@ function useItemCategory(itemCategoryUid, options = {}) {
282
282
  const api = useAugurApiOptional();
283
283
  const callbacks = useAugurCallbacks();
284
284
  const cache = useAugurCache();
285
- const queryOpts = getItemCategoryOptions(
286
- api,
287
- itemCategoryUid,
288
- options.apiOptions,
289
- cache
290
- );
285
+ const queryOpts = getItemCategoryOptions(api, itemCategoryUid, options.apiOptions, cache);
291
286
  const { data, isLoading, error } = useQuery3({
292
287
  ...queryOpts,
293
- ...options.queryFn ?? callbacks?.getItemCategory ? { queryFn: options.queryFn ?? (() => callbacks.getItemCategory(itemCategoryUid, options.apiOptions)) } : {},
288
+ ...options.queryFn ?? callbacks?.getItemCategory ? {
289
+ queryFn: options.queryFn ?? (() => callbacks.getItemCategory(itemCategoryUid, options.apiOptions))
290
+ } : {},
294
291
  enabled: options.enabled ?? true
295
292
  });
296
293
  return { category: data, isLoading, error };
@@ -361,7 +358,13 @@ function useStock(invMastUid, options = {}) {
361
358
  lowStockThreshold: options.lowStockThreshold,
362
359
  showQuantity: options.showQuantity
363
360
  }),
364
- [query.data, options.companyKey, options.round, options.lowStockThreshold, options.showQuantity]
361
+ [
362
+ query.data,
363
+ options.companyKey,
364
+ options.round,
365
+ options.lowStockThreshold,
366
+ options.showQuantity
367
+ ]
365
368
  );
366
369
  return {
367
370
  stock: query.data ?? null,
@@ -533,7 +536,9 @@ function useSearchSuggestions(query, options = {}) {
533
536
  const defaultOptions = getSearchSuggestionsOptions(api, query, limit, offset, cache);
534
537
  const { data, isLoading, error } = useQuery12({
535
538
  ...defaultOptions,
536
- ...options.queryFn ?? callbacks?.getSearchSuggestions ? { queryFn: options.queryFn ?? (() => callbacks.getSearchSuggestions(query, limit, offset)) } : {},
539
+ ...options.queryFn ?? callbacks?.getSearchSuggestions ? {
540
+ queryFn: options.queryFn ?? (() => callbacks.getSearchSuggestions(query, limit, offset))
541
+ } : {},
537
542
  enabled
538
543
  });
539
544
  return {
@@ -558,9 +563,7 @@ function requireCartUid(cartHdrUid) {
558
563
  return num;
559
564
  }
560
565
  function buildOptimisticAdd(cartLines, item, cartHdrUid, itemId) {
561
- const existingIndex = cartLines.findIndex(
562
- (line) => line.invMastUid === item.invMastUid
563
- );
566
+ const existingIndex = cartLines.findIndex((line) => line.invMastUid === item.invMastUid);
564
567
  if (existingIndex >= 0) {
565
568
  return cartLines.map(
566
569
  (line, index) => index === existingIndex ? { ...line, quantity: line.quantity + item.quantity } : line
@@ -588,8 +591,8 @@ function useCartActions(callbacks) {
588
591
  const setCartLines = useSetCartLines();
589
592
  const notify = callbacks.toast;
590
593
  const invalidateCartCache = useCallback(() => {
591
- queryClient.invalidateQueries({ queryKey: ["cartLines", cartHdrUid] });
592
- queryClient.invalidateQueries({
594
+ void queryClient.invalidateQueries({ queryKey: ["cartLines", cartHdrUid] });
595
+ void queryClient.invalidateQueries({
593
596
  queryKey: ["cart-also-bought", cartHdrUid]
594
597
  });
595
598
  }, [queryClient, cartHdrUid]);
@@ -786,10 +789,7 @@ function useCartInitialization(session, callbacks) {
786
789
  }
787
790
  retryCountRef.current++;
788
791
  if (retryCountRef.current < MAX_RETRY_ATTEMPTS) {
789
- const delay = Math.min(
790
- RETRY_DELAY_MS * Math.pow(1.5, retryCountRef.current),
791
- 1e4
792
- );
792
+ const delay = Math.min(RETRY_DELAY_MS * Math.pow(1.5, retryCountRef.current), 1e4);
793
793
  await new Promise((resolve) => setTimeout(resolve, delay));
794
794
  }
795
795
  } catch (error) {
@@ -799,20 +799,15 @@ function useCartInitialization(session, callbacks) {
799
799
  );
800
800
  retryCountRef.current++;
801
801
  if (retryCountRef.current < MAX_RETRY_ATTEMPTS) {
802
- const delay = Math.min(
803
- RETRY_DELAY_MS * Math.pow(1.5, retryCountRef.current),
804
- 1e4
805
- );
802
+ const delay = Math.min(RETRY_DELAY_MS * Math.pow(1.5, retryCountRef.current), 1e4);
806
803
  await new Promise((resolve) => setTimeout(resolve, delay));
807
804
  }
808
805
  }
809
806
  }
810
- console.error(
811
- `Cart initialization failed after ${MAX_RETRY_ATTEMPTS} attempts`
812
- );
807
+ console.error(`Cart initialization failed after ${MAX_RETRY_ATTEMPTS} attempts`);
813
808
  isInitializingRef.current = false;
814
809
  };
815
- initializeGuestCart();
810
+ void initializeGuestCart();
816
811
  }
817
812
  }, [effectiveSession, cartHdrUid, setCartHdrUid, callbacks]);
818
813
  const { data: cartLinesData } = useQuery13({
@@ -954,12 +949,7 @@ function useCategoryItemsInfinite(itemCategoryUid, itemsFilters, options = {}) {
954
949
  const callbacks = useAugurCallbacks();
955
950
  const cache = useAugurCache();
956
951
  const { enabled = true } = options;
957
- const defaultOptions = getCategoryItemsInfiniteOptions(
958
- api,
959
- itemCategoryUid,
960
- itemsFilters,
961
- cache
962
- );
952
+ const defaultOptions = getCategoryItemsInfiniteOptions(api, itemCategoryUid, itemsFilters, cache);
963
953
  const cb = callbacks?.getCategoryItemsInfinite;
964
954
  const resolvedQueryFn = options.queryFn ?? (cb ? ({ pageParam }) => cb({
965
955
  itemCategoryUid,
@@ -981,12 +971,7 @@ function useItemSearchInfinite(itemsFilters, itemCategoryUid, options = {}) {
981
971
  const callbacks = useAugurCallbacks();
982
972
  const cache = useAugurCache();
983
973
  const { enabled = true } = options;
984
- const defaultOptions = getItemSearchInfiniteOptions(
985
- api,
986
- itemsFilters,
987
- itemCategoryUid,
988
- cache
989
- );
974
+ const defaultOptions = getItemSearchInfiniteOptions(api, itemsFilters, itemCategoryUid, cache);
990
975
  const cb = callbacks?.getItemSearchInfinite;
991
976
  const resolvedQueryFn = options.queryFn ?? (cb ? ({ pageParam }) => cb({
992
977
  itemsFilters,
@@ -1312,9 +1297,7 @@ function createSiteHooks(config = {}) {
1312
1297
  // Hooks -- images
1313
1298
  useImageWithFallback: (imagePath, options) => {
1314
1299
  if (!imageConfig) {
1315
- throw new Error(
1316
- "useImageWithFallback requires imageConfig in createSiteHooks config"
1317
- );
1300
+ throw new Error("useImageWithFallback requires imageConfig in createSiteHooks config");
1318
1301
  }
1319
1302
  return useImageWithFallback(imageConfig, imagePath, options);
1320
1303
  }
@@ -1465,16 +1448,19 @@ function useAugurPersistence(config) {
1465
1448
  setIsMounted(true);
1466
1449
  }, []);
1467
1450
  useStorageMonitor(config);
1468
- const isDev = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
1451
+ const isDev = typeof process !== "undefined" && process.env?.["NODE_ENV"] === "development";
1469
1452
  const { persistableKeys } = config;
1470
- const dehydrateOptions = useMemo6(() => ({
1471
- shouldDehydrateQuery: (query) => {
1472
- const key = query.queryKey;
1473
- if (!Array.isArray(key) || key.length === 0) return false;
1474
- if (query.state.status !== "success") return false;
1475
- return persistableKeys.includes(key[0]);
1476
- }
1477
- }), [persistableKeys]);
1453
+ const dehydrateOptions = useMemo6(
1454
+ () => ({
1455
+ shouldDehydrateQuery: (query) => {
1456
+ const key = query.queryKey;
1457
+ if (!Array.isArray(key) || key.length === 0) return false;
1458
+ if (query.state.status !== "success") return false;
1459
+ return persistableKeys.includes(key[0]);
1460
+ }
1461
+ }),
1462
+ [persistableKeys]
1463
+ );
1478
1464
  return {
1479
1465
  persister,
1480
1466
  maxAge: isMounted ? config.maxAge ?? 24 * 60 * 60 * 1e3 : 0,