@simpleapps-com/augur-hooks 2.3.1 → 2026.11.1

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 (99) 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-QB7VB5FZ.cjs +523 -0
  15. package/dist/chunk-QB7VB5FZ.cjs.map +1 -0
  16. package/dist/{chunk-NRWH2BMN.js → chunk-UTDAFIQP.js} +237 -91
  17. package/dist/chunk-UTDAFIQP.js.map +1 -0
  18. package/dist/hooks/use-cart-actions.d.ts +68 -0
  19. package/dist/hooks/use-cart-actions.d.ts.map +1 -0
  20. package/dist/hooks/use-cart-initialization.d.ts +60 -0
  21. package/dist/hooks/use-cart-initialization.d.ts.map +1 -0
  22. package/dist/hooks/use-cart-pricing.d.ts +41 -0
  23. package/dist/hooks/use-cart-pricing.d.ts.map +1 -0
  24. package/dist/hooks/use-checkout-persistence.d.ts +40 -0
  25. package/dist/hooks/use-checkout-persistence.d.ts.map +1 -0
  26. package/dist/hooks/use-debounce.d.ts +6 -0
  27. package/dist/hooks/use-debounce.d.ts.map +1 -0
  28. package/dist/hooks/use-format-price.d.ts +29 -0
  29. package/dist/hooks/use-format-price.d.ts.map +1 -0
  30. package/dist/hooks/use-latest.d.ts +8 -0
  31. package/dist/hooks/use-latest.d.ts.map +1 -0
  32. package/dist/hooks/use-modal-lifecycle.d.ts +11 -0
  33. package/dist/hooks/use-modal-lifecycle.d.ts.map +1 -0
  34. package/dist/hooks/use-order-readiness.d.ts +47 -0
  35. package/dist/hooks/use-order-readiness.d.ts.map +1 -0
  36. package/dist/hooks/use-pagination-prefetch.d.ts +26 -0
  37. package/dist/hooks/use-pagination-prefetch.d.ts.map +1 -0
  38. package/dist/{use-order-readiness-DZTIfRzw.d.ts → hooks/use-payment-flow.d.ts} +23 -67
  39. package/dist/hooks/use-payment-flow.d.ts.map +1 -0
  40. package/dist/hooks/use-stock.d.ts +32 -0
  41. package/dist/hooks/use-stock.d.ts.map +1 -0
  42. package/dist/index.cjs +251 -192
  43. package/dist/index.cjs.map +1 -1
  44. package/dist/index.d.ts +32 -456
  45. package/dist/index.d.ts.map +1 -0
  46. package/dist/index.js +230 -171
  47. package/dist/index.js.map +1 -1
  48. package/dist/persistence/apply-limits.d.ts +8 -0
  49. package/dist/persistence/apply-limits.d.ts.map +1 -0
  50. package/dist/persistence/create-persister.d.ts +10 -0
  51. package/dist/persistence/create-persister.d.ts.map +1 -0
  52. package/dist/persistence/serializer.d.ts +11 -0
  53. package/dist/persistence/serializer.d.ts.map +1 -0
  54. package/dist/persistence/use-persistence.d.ts +59 -0
  55. package/dist/persistence/use-persistence.d.ts.map +1 -0
  56. package/dist/persistence/use-storage-monitor.d.ts +11 -0
  57. package/dist/persistence/use-storage-monitor.d.ts.map +1 -0
  58. package/dist/provider.d.ts +89 -0
  59. package/dist/provider.d.ts.map +1 -0
  60. package/dist/queries/batch-query.d.ts +23 -0
  61. package/dist/queries/batch-query.d.ts.map +1 -0
  62. package/dist/queries/cache-helper.d.ts +16 -0
  63. package/dist/queries/cache-helper.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 +130 -0
  69. package/dist/rules.d.ts.map +1 -0
  70. package/dist/server.cjs.map +1 -1
  71. package/dist/server.d.ts +10 -12
  72. package/dist/server.d.ts.map +1 -0
  73. package/dist/stores/cart-store.d.ts +51 -0
  74. package/dist/stores/cart-store.d.ts.map +1 -0
  75. package/dist/stores/items-filters-store.d.ts +30 -0
  76. package/dist/stores/items-filters-store.d.ts.map +1 -0
  77. package/dist/types.d.ts +48 -0
  78. package/dist/types.d.ts.map +1 -0
  79. package/dist/web/use-image-with-fallback.d.ts +16 -0
  80. package/dist/web/use-image-with-fallback.d.ts.map +1 -0
  81. package/dist/web/use-mobile-detection.d.ts +28 -0
  82. package/dist/web/use-mobile-detection.d.ts.map +1 -0
  83. package/dist/web/use-mobile-optimized-intersection.d.ts +17 -0
  84. package/dist/web/use-mobile-optimized-intersection.d.ts.map +1 -0
  85. package/dist/web.cjs.map +1 -1
  86. package/dist/web.d.ts +4 -60
  87. package/dist/web.d.ts.map +1 -0
  88. package/dist/web.js.map +1 -1
  89. package/llms.txt +76 -54
  90. package/package.json +25 -14
  91. package/dist/batch-query-CTlvxSmL.d.cts +0 -165
  92. package/dist/batch-query-CTlvxSmL.d.ts +0 -165
  93. package/dist/chunk-I4A5L2I6.cjs +0 -377
  94. package/dist/chunk-I4A5L2I6.cjs.map +0 -1
  95. package/dist/chunk-NRWH2BMN.js.map +0 -1
  96. package/dist/index.d.cts +0 -456
  97. package/dist/server.d.cts +0 -44
  98. package/dist/use-order-readiness-DZTIfRzw.d.cts +0 -137
  99. package/dist/web.d.cts +0 -60
@@ -1,8 +1,7 @@
1
- import * as react from 'react';
2
- import { TTransactionSetup, TCardInfo, TPaymentValidation, TAccountQuery, TBillingUpdate } from '@simpleapps-com/augur-utils';
3
-
1
+ import type { Dispatch, SetStateAction } from "react";
2
+ import type { TTransactionSetup, TCardInfo, TPaymentValidation, TAccountQuery, TBillingUpdate } from "@simpleapps-com/augur-utils";
4
3
  /** Site-specific payment action callbacks injected into usePaymentFlow. */
5
- interface PaymentFlowCallbacks {
4
+ export interface PaymentFlowCallbacks {
6
5
  /** Initialize a payment session. Returns transaction setup or undefined on failure. */
7
6
  transactionSetup: (params: {
8
7
  customerId: string;
@@ -36,7 +35,7 @@ interface PaymentFlowCallbacks {
36
35
  };
37
36
  }
38
37
  /** Billing address shape accepted by the payment flow. */
39
- interface PaymentBillingAddress {
38
+ export interface PaymentBillingAddress {
40
39
  address1: string;
41
40
  address2?: string;
42
41
  city: string;
@@ -52,6 +51,22 @@ interface UsePaymentFlowParams {
52
51
  /** Persist payment tokens to sessionStorage for cross-navigation recovery. */
53
52
  persistPayment?: boolean;
54
53
  }
54
+ /** sessionStorage key for persisted payment tokens. */
55
+ export declare const PAYMENT_STORAGE_KEY = "checkout:payment";
56
+ /** State and setters returned by usePaymentFlow. */
57
+ interface PaymentFlow {
58
+ isOpen: boolean;
59
+ setIsOpen: Dispatch<SetStateAction<boolean>>;
60
+ editCc: boolean;
61
+ setEditCc: Dispatch<SetStateAction<boolean>>;
62
+ unified: TTransactionSetup | null;
63
+ unifiedCc: TCardInfo | null;
64
+ unifiedResponse: boolean;
65
+ unifiedBilling: boolean;
66
+ unifiedPayment: TAccountQuery | null;
67
+ capturedBin: string | null;
68
+ handleBinCapture: (bin: string) => void;
69
+ }
55
70
  /**
56
71
  * Manages the full Element/Unified payment lifecycle:
57
72
  * transactionSetup -> cardInfo -> validatePayment -> accountQuery -> billingUpdate
@@ -73,65 +88,6 @@ interface UsePaymentFlowParams {
73
88
  * });
74
89
  * ```
75
90
  */
76
- declare function usePaymentFlow({ callbacks, customerId, billingAddress, paymentMethod, shippingAccepted, persistPayment, }: UsePaymentFlowParams): {
77
- isOpen: boolean;
78
- setIsOpen: react.Dispatch<react.SetStateAction<boolean>>;
79
- editCc: boolean;
80
- setEditCc: react.Dispatch<react.SetStateAction<boolean>>;
81
- unified: TTransactionSetup | null;
82
- unifiedCc: TCardInfo | null;
83
- unifiedResponse: boolean;
84
- unifiedBilling: boolean;
85
- unifiedPayment: TAccountQuery | null;
86
- capturedBin: string | null;
87
- handleBinCapture: (bin: string) => void;
88
- };
89
-
90
- /** Parameters for order readiness validation. */
91
- interface OrderReadinessParams {
92
- cartHdrUid: string | number | undefined;
93
- shippingAddress: unknown;
94
- billingAddress: unknown;
95
- shippingMethodSaved: boolean;
96
- showBillingInfoSummary: boolean;
97
- processingOrder: boolean;
98
- paymentMethod: string;
99
- unifiedPaymentAccountId: string | undefined;
100
- unifiedBilling: boolean;
101
- isFreeShipping: boolean;
102
- carrierId: string;
103
- shippingFee: number | undefined;
104
- isEditShippingInfo: boolean;
105
- isEditShippingMethods: boolean;
106
- isEditBillingInfo: boolean;
107
- editCc: boolean;
108
- /**
109
- * Site-provided function to check if the order is ready.
110
- *
111
- * Return `true` or `false` to override the default gates. Return
112
- * `undefined` to defer to the default logic (useful when the override
113
- * only applies to specific order flows — e.g. sample-only or pickup).
114
- */
115
- customReadinessCheck?: (params: OrderReadinessParams) => boolean | undefined;
116
- }
117
- /**
118
- * Pure function that determines if an order is ready to submit.
119
- *
120
- * Checks all gates: cart exists, addresses present, shipping method saved,
121
- * billing shown, payment complete (for credit card), shipping fee present
122
- * (for non-free, non-pickup orders), and no sections being edited.
123
- */
124
- declare function determineOrderReadiness(params: OrderReadinessParams): boolean;
125
- /**
126
- * Debounced order readiness hook.
127
- *
128
- * Recomputes readiness 300ms after any dependency changes to avoid
129
- * excessive re-renders during rapid state transitions (e.g., typing
130
- * in address fields).
131
- */
132
- declare function useOrderReadiness(params: OrderReadinessParams): {
133
- enableProcessOrderBtn: boolean;
134
- processingValidation: boolean;
135
- };
136
-
137
- export { type OrderReadinessParams as O, type PaymentBillingAddress as P, type PaymentFlowCallbacks as a, usePaymentFlow as b, determineOrderReadiness as d, useOrderReadiness as u };
91
+ export declare function usePaymentFlow({ callbacks, customerId, billingAddress, paymentMethod, shippingAccepted, persistPayment, }: UsePaymentFlowParams): PaymentFlow;
92
+ export {};
93
+ //# sourceMappingURL=use-payment-flow.d.ts.map
@@ -0,0 +1 @@
1
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C7B,SAAS,EACT,UAAU,EACV,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,cAAc,GACf,EAAE,oBAAoB,GAAG,WAAW,CAkQpC"}
@@ -0,0 +1,32 @@
1
+ import type { ResolvedStock, TStock } from "@simpleapps-com/augur-utils";
2
+ export interface UseStockOptions {
3
+ enabled?: boolean;
4
+ /** Override the default queryFn (e.g. with a custom server action). */
5
+ queryFn?: () => Promise<TStock>;
6
+ /** Company key to extract stock for a specific company. */
7
+ companyKey?: string;
8
+ /** Whether to round the quantity. */
9
+ round?: boolean;
10
+ /** Threshold below which stock is considered "low". */
11
+ lowStockThreshold?: number;
12
+ /** Whether to include the quantity in the resolved output. */
13
+ showQuantity?: boolean;
14
+ }
15
+ /** Raw stock, its resolved form, and query state returned by useStock. */
16
+ interface StockResult {
17
+ stock: TStock | null;
18
+ resolved: ResolvedStock | null;
19
+ loading: boolean;
20
+ error: Error | null;
21
+ }
22
+ /**
23
+ * Fetches full TStock data and resolves it into a normalized stock object.
24
+ *
25
+ * Uses the proxy from AugurHooksProvider context. Works with:
26
+ * - Direct SDK (api prop on provider)
27
+ * - Server actions (auto-detected via queryAction registration)
28
+ * - Custom queryFn override
29
+ */
30
+ export declare function useStock(invMastUid: number | string, options?: UseStockOptions): StockResult;
31
+ export {};
32
+ //# sourceMappingURL=use-stock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-stock.d.ts","sourceRoot":"","sources":["../../src/hooks/use-stock.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAKzE,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAChC,2DAA2D;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,uDAAuD;IACvD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,8DAA8D;IAC9D,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,0EAA0E;AAC1E,UAAU,WAAW;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,WAAW,CAqChG"}