@simpleapps-com/augur-utils 2.4.0 → 2026.11.2

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 (114) hide show
  1. package/EXPORTS.md +28 -31
  2. package/README.md +19 -180
  3. package/dist/address-comparison.d.ts +18 -0
  4. package/dist/address-comparison.d.ts.map +1 -0
  5. package/dist/address-schemas.d.ts +45 -0
  6. package/dist/address-schemas.d.ts.map +1 -0
  7. package/dist/analytics.d.ts +66 -0
  8. package/dist/analytics.d.ts.map +1 -0
  9. package/dist/build-checkout-payload.d.ts +37 -0
  10. package/dist/build-checkout-payload.d.ts.map +1 -0
  11. package/dist/cache-config.d.ts +42 -0
  12. package/dist/cache-config.d.ts.map +1 -0
  13. package/dist/chunk-5UMFBGVA.cjs.map +1 -1
  14. package/dist/date-helpers.d.ts +16 -0
  15. package/dist/date-helpers.d.ts.map +1 -0
  16. package/dist/derive-price.d.ts +49 -0
  17. package/dist/derive-price.d.ts.map +1 -0
  18. package/dist/format-price.d.ts +6 -0
  19. package/dist/format-price.d.ts.map +1 -0
  20. package/dist/get-payment-status.d.ts +10 -0
  21. package/dist/get-payment-status.d.ts.map +1 -0
  22. package/dist/image-rules.d.ts +70 -0
  23. package/dist/image-rules.d.ts.map +1 -0
  24. package/dist/image.d.ts +80 -0
  25. package/dist/image.d.ts.map +1 -0
  26. package/dist/index.cjs +545 -166
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.ts +63 -1448
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +544 -165
  31. package/dist/index.js.map +1 -1
  32. package/dist/json-ld-rules.d.ts +50 -0
  33. package/dist/json-ld-rules.d.ts.map +1 -0
  34. package/dist/json-ld.d.ts +47 -0
  35. package/dist/json-ld.d.ts.map +1 -0
  36. package/dist/money.d.ts +37 -0
  37. package/dist/money.d.ts.map +1 -0
  38. package/dist/price-breaks.d.ts +16 -0
  39. package/dist/price-breaks.d.ts.map +1 -0
  40. package/dist/price-outcome.d.ts +19 -0
  41. package/dist/price-outcome.d.ts.map +1 -0
  42. package/dist/resolve-stock.d.ts +22 -0
  43. package/dist/resolve-stock.d.ts.map +1 -0
  44. package/dist/result.d.ts +33 -0
  45. package/dist/result.d.ts.map +1 -0
  46. package/dist/rules.d.ts +45 -0
  47. package/dist/rules.d.ts.map +1 -0
  48. package/dist/schema-availability.d.ts +11 -0
  49. package/dist/schema-availability.d.ts.map +1 -0
  50. package/dist/transform-ship-to-address.d.ts +15 -0
  51. package/dist/transform-ship-to-address.d.ts.map +1 -0
  52. package/dist/transforms.d.ts +70 -0
  53. package/dist/transforms.d.ts.map +1 -0
  54. package/dist/types/api.d.ts +8 -0
  55. package/dist/types/api.d.ts.map +1 -0
  56. package/dist/types/attribute.d.ts +12 -0
  57. package/dist/types/attribute.d.ts.map +1 -0
  58. package/dist/types/cart.d.ts +25 -0
  59. package/dist/types/cart.d.ts.map +1 -0
  60. package/dist/types/category-items.d.ts +4 -0
  61. package/dist/types/category-items.d.ts.map +1 -0
  62. package/dist/types/category.d.ts +19 -0
  63. package/dist/types/category.d.ts.map +1 -0
  64. package/dist/types/checkout.d.ts +4 -0
  65. package/dist/types/checkout.d.ts.map +1 -0
  66. package/dist/types/customer.d.ts +4 -0
  67. package/dist/types/customer.d.ts.map +1 -0
  68. package/dist/types/filter.d.ts +9 -0
  69. package/dist/types/filter.d.ts.map +1 -0
  70. package/dist/types/inventory.d.ts +10 -0
  71. package/dist/types/inventory.d.ts.map +1 -0
  72. package/dist/types/joomla.d.ts +11 -0
  73. package/dist/types/joomla.d.ts.map +1 -0
  74. package/dist/types/ltl-shipping.d.ts +45 -0
  75. package/dist/types/ltl-shipping.d.ts.map +1 -0
  76. package/dist/types/menu.d.ts +14 -0
  77. package/dist/types/menu.d.ts.map +1 -0
  78. package/dist/types/meta.d.ts +11 -0
  79. package/dist/types/meta.d.ts.map +1 -0
  80. package/dist/types/order.d.ts +72 -0
  81. package/dist/types/order.d.ts.map +1 -0
  82. package/dist/types/password.d.ts +7 -0
  83. package/dist/types/password.d.ts.map +1 -0
  84. package/dist/types/payment.d.ts +69 -0
  85. package/dist/types/payment.d.ts.map +1 -0
  86. package/dist/types/pricing.d.ts +25 -0
  87. package/dist/types/pricing.d.ts.map +1 -0
  88. package/dist/types/product.d.ts +58 -0
  89. package/dist/types/product.d.ts.map +1 -0
  90. package/dist/types/search.d.ts +16 -0
  91. package/dist/types/search.d.ts.map +1 -0
  92. package/dist/types/shipping.d.ts +4 -0
  93. package/dist/types/shipping.d.ts.map +1 -0
  94. package/dist/types/smarty-streets.d.ts +4 -0
  95. package/dist/types/smarty-streets.d.ts.map +1 -0
  96. package/dist/types/supplier.d.ts +4 -0
  97. package/dist/types/supplier.d.ts.map +1 -0
  98. package/dist/types/tax.d.ts +6 -0
  99. package/dist/types/tax.d.ts.map +1 -0
  100. package/dist/types/uom.d.ts +4 -0
  101. package/dist/types/uom.d.ts.map +1 -0
  102. package/dist/types/user-profile.d.ts +5 -0
  103. package/dist/types/user-profile.d.ts.map +1 -0
  104. package/dist/us-states.d.ts +15 -0
  105. package/dist/us-states.d.ts.map +1 -0
  106. package/dist/validation-patterns.d.ts +22 -0
  107. package/dist/validation-patterns.d.ts.map +1 -0
  108. package/dist/web.cjs.map +1 -1
  109. package/dist/web.d.ts +3 -5
  110. package/dist/web.d.ts.map +1 -0
  111. package/llms.txt +49 -38
  112. package/package.json +25 -13
  113. package/dist/index.d.cts +0 -1448
  114. package/dist/web.d.cts +0 -6
package/EXPORTS.md CHANGED
@@ -1,9 +1,7 @@
1
1
  # @simpleapps-com/augur-utils exports
2
2
 
3
- Version: 2.2.29
4
-
5
- > Auto-generated from built type declarations. Do not edit manually.
6
- > Regenerate with: `pnpm run generate-exports`
3
+ > Generated from the package's build by `pnpm -C repo/sites/augur-build generate`. Do not edit by hand.
4
+ > Guide: https://augur.build/docs/packages/augur-utils
7
5
 
8
6
  ## `@simpleapps-com/augur-utils`
9
7
 
@@ -11,55 +9,58 @@ Version: 2.2.29
11
9
 
12
10
  | Export | Kind | Description |
13
11
  |--------|------|-------------|
14
- | `BLUR_DATA_URL` | const | 1x1 transparent PNG for Next.js `<Image blurDataURL={...}>` placeholders. |
15
12
  | `BillingAddressInvoiceSchema` | const | Valibot schema for billing address with required PO number (invoice payments). |
16
- | `BillingAddressSchema` | const | Valibot schema for billing address validation. |
17
- | `CACHE_CONFIG` | const | Centralized cache configuration for React Query (TanStack Query) |
18
- | `CONTIGUOUS_STATES` | const | Lower 48 contiguous states. |
19
- | `ShippingAddressSchema` | const | Valibot schema for shipping address validation. |
20
- | `USState` | value | |
21
- | `US_STATES` | const | All US states and territories — backward-compatible {code, name} shape. |
22
- | `US_STATES_FULL` | const | All US states and territories — full data from states-us. |
23
- | `US_TERRITORIES` | const | US territories (PR, GU, VI, AS, MP). |
24
- | `VALIDATION_PATTERNS` | const | Common regex patterns used for form validation across augur-hosted sites. |
13
+ | `BillingAddressSchema` | const | Valibot schema for billing address validation. Less strict than shipping: allows PO Box, no email/phone required. |
14
+ | `BLUR_DATA_URL` | const | 1x1 transparent PNG for Next.js `<Image blurDataURL={...}>` placeholders. |
15
+ | `breadcrumbLd` | const | A breadcrumb trail's BreadcrumbList as text. |
25
16
  | `buildCheckoutPayload` | function | Builds the oe_hdr + oe_line payload required by the commerce checkout API from cart data. |
26
17
  | `buildImageLoader` | function | Returns a loader function compatible with Next.js `<Image loader={...}>`. |
27
18
  | `buildTrackingData` | function | Build a GA4 begin_checkout ecommerce payload from cart lines, item details, and prices. |
28
- | `cn` | value | |
19
+ | `CACHE_CONFIG` | const | Centralized cache configuration for React Query (TanStack Query) |
20
+ | `categorySortBy` | function | serializeCategoryFilters' sortBy: the prefix applied only when both are non-empty. |
21
+ | `cleanMoney` | function | Remove JS float noise from a money product or sum. |
22
+ | `cn` | function | Merge Tailwind classes without conflicts. Web only (tailwind-merge is meaningless in RN). |
23
+ | `CONTIGUOUS_STATES` | const | Lower 48 contiguous states. |
29
24
  | `createImageConfig` | function | Creates a frozen ImageConfig object. |
30
25
  | `derivePrice` | function | Pure price derivation — usable in hooks AND server components. |
31
- | `formatPrice` | function | Locale-aware currency formatting. |
26
+ | `faqLd` | const | A FAQ page's FAQPage markup as text: one Question per entry. |
27
+ | `formatPrice` | function | Locale-aware currency formatting. Defaults to USD -- consumers can override locale and currency. |
32
28
  | `generateBreadcrumbJsonLd` | function | Generates a Schema.org BreadcrumbList JSON-LD object from an array of breadcrumb items. |
33
29
  | `generateProductJsonLd` | function | Generates a Schema.org Product JSON-LD string from an inventory document. Returns null if the item is suppressed, unnamed, or has no price. |
34
30
  | `getBusinessDay` | function | Get the Nth business day from today (skipping weekends). |
35
- | `getDefaultImageUrl` | function | Returns the default/placeholder image URL. |
31
+ | `getDefaultImageUrl` | function | Returns the default/placeholder image URL. Per-call `options.defaultImage` overrides `config.defaultImage`. |
36
32
  | `getImageSrcSet` | function | Generates a `srcset` string for responsive images. |
37
33
  | `getImageUrl` | function | Builds a full agr.media URL for the given image path and transforms. |
38
34
  | `getPaymentStatus` | function | Returns "Paid", "Partially Paid", or "Unpaid" based on invoice payment flags and amounts. |
39
35
  | `getSchemaAvailability` | function | Maps resolved stock to a Schema.org availability URL. |
40
- | `getShippingLeadDate` | function | Get shipping lead date estimate based on days string. |
41
- | `isAddressDifferent` | function | Compares a user-entered address with a SmartyStreets-validated address. |
42
- | `normalizePath` | function | Normalizes an image path by: |
36
+ | `getShippingLeadDate` | function | Get shipping lead date estimate based on days string (the table is `shippingLeadOf`). |
37
+ | `hasPriceBreaks` | function | Type guard: true when `libraryPriceData` is the price-page shape with quantity `breaks`. |
38
+ | `idRef` | const | A reference to another node by its @id, as JSON text. |
39
+ | `isAddressDifferent` | function | Compares a user-entered address with a SmartyStreets-validated address. Returns true if any field differs (case-insensitive for address/city, exact match for state abbreviation and zip code). |
40
+ | `nodeHead` | const | The schema.org context and a node's type: its first two members, as JSON text. |
41
+ | `normalizePath` | function | Normalizes an image path by: 1. Returning it as-is if it starts with `http` (external URL). 2. Stripping configured prefixes (defaults: `/images`, `images`). 3. Prepending `defaultPath` for bare filenames (no `/`). 4. Stripping leading slashes. |
43
42
  | `paginateOffset` | function | Returns a copy of filters with offset adjusted for the given page. |
44
43
  | `pushTrackingData` | function | Push ecommerce tracking data to window.dataLayer using the GA4 clear-then-push pattern. |
45
44
  | `resolveStock` | function | Pure stock resolution -- usable in hooks AND server components. |
46
- | `sanitizeHtmlImages` | function | Rewrites `<img src="...">` attributes in an HTML string to use agr.media URLs. |
45
+ | `roundHalfAway` | function | Round half away from zero to `decimals` places. |
46
+ | `sanitizeHtmlImages` | function | Rewrites `<img src="...">` attributes in an HTML string to use agr.media URLs. Useful for CMS/Joomla content that contains raw image references. |
47
47
  | `serializeCategoryFilters` | function | Converts TItemsFilters to the SDK params shape for category item endpoints. |
48
48
  | `serializeSearchParams` | function | Converts TItemsFilters to the SDK params shape for search endpoints. |
49
- | `serializeTransforms` | function | Serializes transform options into the CDN path segment. |
49
+ | `serializeTransforms` | function | Serializes transform options into the CDN path segment. Example: `{ width: 400, format: "webp" }` → `"w_400,f_webp"` |
50
+ | `ShippingAddressSchema` | const | Valibot schema for shipping address validation. Enforces no PO Box, requires street number, formats phone number. |
50
51
  | `trackAddToCart` | function | Track add_to_cart event to Google Analytics dataLayer. |
51
52
  | `trackViewItem` | function | Track view_item event to Google Analytics dataLayer. |
52
53
  | `transformShipToAddress` | function | Normalizes a raw ship-to address object (camelCase or snake_case, physical or mailing) into a consistent ShipToAddress shape. |
53
54
  | `unwrap` | function | Extracts the data from a `SafeActionResult`, throwing on error. |
54
55
  | `unwrapOr` | function | Extracts the data from a `SafeActionResult`, returning `null` on error. |
56
+ | `US_STATES` | const | All US states and territories — backward-compatible {code, name} shape. |
57
+ | `US_STATES_FULL` | const | All US states and territories — full data from states-us. |
58
+ | `US_TERRITORIES` | const | US territories (PR, GU, VI, AS, MP). |
59
+ | `VALIDATION_PATTERNS` | const | Common regex patterns used for form validation across augur-hosted sites. |
55
60
 
56
61
  ### Types
57
62
 
58
- `AddToCartEventParams`, `BillingAddress`, `BreadcrumbJsonLdItem`, `BuildTrackingDataInput`, `CacheTier`, `CategoryFilterOptions`, `CheckoutInput`, `CheckoutPayment`, `CustomerDocument`, `DerivePriceInput`, `DerivedPrice`, `ImageConfig`, `ImageTransforms`, `ImageUrlOptions`, `MenuItem`, `OeHdr`, `OeLine`, `OrderHeader`, `OrderLine`, `OrderNote`, `OrderPayment`, `PaymentStatus`, `PaymentStatusInvoice`, `ProductJsonLdAggregateRating`, `ProductJsonLdOptions`, `ProductJsonLdSeller`, `ResolveStockInput`, `ResolvedStock`, `SafeActionResult`, `SchemaAvailability`, `SearchParamOptions`, `ShipToAddress`, `ShippingAddress`, `TAccountQuery`, `TApiResponse`, `TAttribute`, `TAttributeValue`, `TBillingUpdate`, `TCardInfo`, `TCartHdrUid`, `TCartLine`, `TCartLookUp`, `TCategory`, `TCategoryChild`, `TCategoryItemsResult`, `TCheckoutResult`, `TInvMast`, `TInvMastDoc`, `TInventorySupplier`, `TItemAccessory`, `TItemAttribute`, `TItemAttributes`, `TItemCategory`, `TItemDetails`, `TItemRelatedProduct`, `TItemUom`, `TItemsFilters`, `TJoomlaContent`, `TJoomlaContentFilters`, `TLibraryPriceBreak`, `TLibraryPriceData`, `TLtlRatesResponse`, `TLtlShipmentData`, `TMenu`, `TMenuFilters`, `TMetaTags`, `TOrderCartLine`, `TPasswordVerification`, `TPaymentValidation`, `TPriceData`, `TProductCategory`, `TProductItem`, `TProductStockData`, `TProfileValues`, `TRelatedProduct`, `TSearchSuggestion`, `TSearchSuggestionsResponse`, `TShippingMethod`, `TSmartyStreets`, `TStock`, `TStockData`, `TSurcharge`, `TTax`, `TTaxItem`, `TTransactionSetup`, `TUserProfile`, `TWebDesc`, `TrackingData`, `TrackingItem`, `USStateCode`, `UserAddress`, `ViewItemEventParams`
59
-
60
- ```ts
61
- import { BLUR_DATA_URL, BillingAddressInvoiceSchema, BillingAddressSchema } from "@simpleapps-com/augur-utils";
62
- ```
63
+ `AddToCartEventParams`, `BillingAddress`, `BreadcrumbJsonLdItem`, `BuildTrackingDataInput`, `CacheTier`, `CategoryFilterOptions`, `CheckoutInput`, `CheckoutPayment`, `CustomerDocument`, `DerivedPrice`, `DerivePriceInput`, `Faq`, `ImageConfig`, `ImageTransforms`, `ImageUrlOptions`, `MenuItem`, `OeHdr`, `OeLine`, `OrderHeader`, `OrderLine`, `OrderNote`, `OrderPayment`, `PaymentStatus`, `PaymentStatusInvoice`, `ProductJsonLdAggregateRating`, `ProductJsonLdOptions`, `ProductJsonLdSeller`, `ResolvedStock`, `ResolveStockInput`, `SafeActionResult`, `SchemaAvailability`, `SearchParamOptions`, `ShippingAddress`, `ShipToAddress`, `TAccountQuery`, `TApiResponse`, `TAttribute`, `TAttributeValue`, `TBillingUpdate`, `TCardInfo`, `TCartHdrUid`, `TCartLine`, `TCartLookUp`, `TCategory`, `TCategoryChild`, `TCategoryItemsResult`, `TCheckoutResult`, `TInventorySupplier`, `TInvMast`, `TInvMastDoc`, `TItemAccessory`, `TItemAttribute`, `TItemAttributes`, `TItemCategory`, `TItemDetails`, `TItemRelatedProduct`, `TItemsFilters`, `TItemUom`, `TJoomlaContent`, `TJoomlaContentFilters`, `TLibraryMultiplierData`, `TLibraryPriceBreak`, `TLibraryPriceData`, `TLtlRatesResponse`, `TLtlShipmentData`, `TMenu`, `TMenuFilters`, `TMetaTags`, `TOrderCartLine`, `TPasswordVerification`, `TPaymentValidation`, `TPriceData`, `TProductCategory`, `TProductItem`, `TProductStockData`, `TProfileValues`, `TrackingData`, `TrackingItem`, `TRelatedProduct`, `TSearchSuggestion`, `TSearchSuggestionsResponse`, `TShippingMethod`, `TSmartyStreets`, `TStock`, `TStockData`, `TSurcharge`, `TTax`, `TTaxItem`, `TTransactionSetup`, `TUserProfile`, `TWebDesc`, `UserAddress`, `USState`, `USStateCode`, `ViewItemEventParams`
63
64
 
64
65
  ## `@simpleapps-com/augur-utils/web`
65
66
 
@@ -68,7 +69,3 @@ import { BLUR_DATA_URL, BillingAddressInvoiceSchema, BillingAddressSchema } from
68
69
  | Export | Kind | Description |
69
70
  |--------|------|-------------|
70
71
  | `cn` | function | Merge Tailwind classes without conflicts. Web only (tailwind-merge is meaningless in RN). |
71
-
72
- ```ts
73
- import { cn } from "@simpleapps-com/augur-utils/web";
74
- ```
package/README.md CHANGED
@@ -1,10 +1,13 @@
1
1
  # @simpleapps-com/augur-utils
2
2
 
3
- > Shared types, cache configuration, and utility functions for Augur ecommerce sites
3
+ > Shared types, money math, pricing and stock derivation, formatters, image URLs, analytics and address schemas for Augur sites
4
4
 
5
- > Auto-generated. Do not edit manually. Regenerate with: `pnpm run generate-exports`
5
+ Part of the **@simpleapps-com/augur-\*** platform. Each package releases on its own CalVer
6
+ version; nothing requires them to share one.
6
7
 
7
- Part of the **@simpleapps-com/augur-\*** platform. All packages use fixed versioning (same version number).
8
+ - Guide: https://augur.build/docs/packages/augur-utils
9
+ - Every export: [`EXPORTS.md`](EXPORTS.md) (generated from the build)
10
+ - Releases: https://augur.build/docs/packages/changelog
8
11
 
9
12
  ## Install
10
13
 
@@ -12,185 +15,21 @@ Part of the **@simpleapps-com/augur-\*** platform. All packages use fixed versio
12
15
  pnpm add @simpleapps-com/augur-utils
13
16
  ```
14
17
 
15
- ### Peer Dependencies
18
+ | Import | Purpose |
19
+ | --------------------------------- | -------------------------------------- |
20
+ | `@simpleapps-com/augur-utils` | Types and helpers; no framework or DOM |
21
+ | `@simpleapps-com/augur-utils/web` | `cn` only |
16
22
 
17
- `clsx`, `tailwind-merge`, `valibot`
23
+ ## Development
18
24
 
19
- ## Entry Points
25
+ TypeScript in `src/`, built to `dist/` (ESM and CJS) by tsup. The decisions are proved
26
+ (`src/rules.ts`, `src/price-outcome.ts`, `src/image-rules.ts`, `src/json-ld-rules.ts`; model
27
+ `models/AugurUtils.dfy`, links `models/links/augur-utils-*.dfy`); the rest is tested at 100%.
20
28
 
21
- | Import | Description |
22
- |--------|-------------|
23
- | `@simpleapps-com/augur-utils` | 41 exports, 92 types |
24
- | `@simpleapps-com/augur-utils/web` | 1 exports, 0 types |
25
-
26
- ## Exports
27
-
28
- ### Analytics
29
-
30
- | Export | Kind | Description |
31
- |--------|------|-------------|
32
- | `buildTrackingData` | function | Build a GA4 begin_checkout ecommerce payload from cart lines, item details, and prices. |
33
- | `pushTrackingData` | function | Push ecommerce tracking data to window.dataLayer using the GA4 clear-then-push pattern. |
34
-
35
- ### Cart
36
-
37
- | Export | Kind | Description |
38
- |--------|------|-------------|
39
- | `trackAddToCart` | function | Track add_to_cart event to Google Analytics dataLayer. |
40
-
41
- ### Configuration
42
-
43
- | Export | Kind | Description |
44
- |--------|------|-------------|
45
- | `CACHE_CONFIG` | const | Centralized cache configuration for React Query (TanStack Query) |
46
-
47
- ### Formatting & Dates
48
-
49
- | Export | Kind | Description |
50
- |--------|------|-------------|
51
- | `getBusinessDay` | function | Get the Nth business day from today (skipping weekends). |
52
-
53
- ### Image & CDN
54
-
55
- | Export | Kind | Description |
56
- |--------|------|-------------|
57
- | `BLUR_DATA_URL` | const | 1x1 transparent PNG for Next.js `<Image blurDataURL={...}>` placeholders. |
58
- | `buildImageLoader` | function | Returns a loader function compatible with Next.js `<Image loader={...}>`. |
59
- | `createImageConfig` | function | Creates a frozen ImageConfig object. |
60
- | `getDefaultImageUrl` | function | Returns the default/placeholder image URL. |
61
- | `getImageSrcSet` | function | Generates a `srcset` string for responsive images. |
62
- | `getImageUrl` | function | Builds a full agr.media URL for the given image path and transforms. |
63
- | `sanitizeHtmlImages` | function | Rewrites `<img src="...">` attributes in an HTML string to use agr.media URLs. |
64
-
65
- ### Items & Categories
66
-
67
- | Export | Kind | Description |
68
- |--------|------|-------------|
69
- | `generateProductJsonLd` | function | Generates a Schema.org Product JSON-LD string from an inventory document. Returns null if the item is suppressed, unnamed, or has no price. |
70
- | `serializeCategoryFilters` | function | Converts TItemsFilters to the SDK params shape for category item endpoints. |
71
- | `trackViewItem` | function | Track view_item event to Google Analytics dataLayer. |
72
-
73
- ### Payment & Checkout
74
-
75
- | Export | Kind | Description |
76
- |--------|------|-------------|
77
- | `BillingAddressInvoiceSchema` | const | Valibot schema for billing address with required PO number (invoice payments). |
78
- | `BillingAddressSchema` | const | Valibot schema for billing address validation. |
79
- | `buildCheckoutPayload` | function | Builds the oe_hdr + oe_line payload required by the commerce checkout API from cart data. |
80
- | `getPaymentStatus` | function | Returns "Paid", "Partially Paid", or "Unpaid" based on invoice payment flags and amounts. |
81
-
82
- ### Pricing
83
-
84
- | Export | Kind | Description |
85
- |--------|------|-------------|
86
- | `derivePrice` | function | Pure price derivation — usable in hooks AND server components. |
87
- | `formatPrice` | function | Locale-aware currency formatting. |
88
-
89
- ### Search
90
-
91
- | Export | Kind | Description |
92
- |--------|------|-------------|
93
- | `serializeSearchParams` | function | Converts TItemsFilters to the SDK params shape for search endpoints. |
94
-
95
- ### SEO & Structured Data
96
-
97
- | Export | Kind | Description |
98
- |--------|------|-------------|
99
- | `generateBreadcrumbJsonLd` | function | Generates a Schema.org BreadcrumbList JSON-LD object from an array of breadcrumb items. |
100
-
101
- ### Shipping & Address
102
-
103
- | Export | Kind | Description |
104
- |--------|------|-------------|
105
- | `ShippingAddressSchema` | const | Valibot schema for shipping address validation. |
106
- | `getShippingLeadDate` | function | Get shipping lead date estimate based on days string. |
107
- | `isAddressDifferent` | function | Compares a user-entered address with a SmartyStreets-validated address. |
108
- | `transformShipToAddress` | function | Normalizes a raw ship-to address object (camelCase or snake_case, physical or mailing) into a consistent ShipToAddress shape. |
109
-
110
- ### Stock
111
-
112
- | Export | Kind | Description |
113
- |--------|------|-------------|
114
- | `resolveStock` | function | Pure stock resolution -- usable in hooks AND server components. |
115
-
116
- ### Transforms
117
-
118
- | Export | Kind | Description |
119
- |--------|------|-------------|
120
- | `paginateOffset` | function | Returns a copy of filters with offset adjusted for the given page. |
121
- | `serializeTransforms` | function | Serializes transform options into the CDN path segment. |
122
-
123
- ### Validation
124
-
125
- | Export | Kind | Description |
126
- |--------|------|-------------|
127
- | `VALIDATION_PATTERNS` | const | Common regex patterns used for form validation across augur-hosted sites. |
128
- | `getSchemaAvailability` | function | Maps resolved stock to a Schema.org availability URL. |
129
-
130
- ### Utilities
131
-
132
- | Export | Kind | Description |
133
- |--------|------|-------------|
134
- | `cn` | value | |
135
- | `unwrap` | function | Extracts the data from a `SafeActionResult`, throwing on error. |
136
- | `unwrapOr` | function | Extracts the data from a `SafeActionResult`, returning `null` on error. |
137
- | `cn` | function | Merge Tailwind classes without conflicts. Web only (tailwind-merge is meaningless in RN). |
138
-
139
- ### Other
140
-
141
- | Export | Kind | Description |
142
- |--------|------|-------------|
143
- | `CONTIGUOUS_STATES` | const | Lower 48 contiguous states. |
144
- | `USState` | value | |
145
- | `US_STATES` | const | All US states and territories — backward-compatible {code, name} shape. |
146
- | `US_STATES_FULL` | const | All US states and territories — full data from states-us. |
147
- | `US_TERRITORIES` | const | US territories (PR, GU, VI, AS, MP). |
148
- | `normalizePath` | function | Normalizes an image path by: |
149
-
150
- ## Examples
151
-
152
- ### paginateOffset
153
-
154
- ```tsx
155
- useInfiniteQuery({
156
- ...q.items.itemCategory.categoryItems.list(
157
- uid,
158
- serializeCategoryFilters(paginateOffset(filters, pageParam), site)
159
- ),
160
- initialPageParam: 0,
161
- getNextPageParam: (last, _all, lastPage) =>
162
- (lastPage + 1) * filters.limit < last.total ? lastPage + 1 : undefined,
163
- });
164
- ```
165
-
166
- ### unwrap
167
-
168
- ```ts
169
- const cart = unwrap(await getCartLines(cartId));
170
- ```
171
-
172
- ### unwrapOr
173
-
174
- ```ts
175
- const cart = unwrapOr(await getCartLines(cartId));
176
- if (!cart) { /* handle missing data *\/ }
29
+ ```bash
30
+ pnpm -C repo/packages/augur-utils test
31
+ pnpm -C repo/packages/augur-utils proofs
177
32
  ```
178
33
 
179
- ## Types
180
-
181
- `AddToCartEventParams`, `BillingAddress`, `BreadcrumbJsonLdItem`, `BuildTrackingDataInput`, `CacheTier`, `CategoryFilterOptions`, `CheckoutInput`, `CheckoutPayment`, `CustomerDocument`, `DerivePriceInput`, `DerivedPrice`, `ImageConfig`, `ImageTransforms`, `ImageUrlOptions`, `MenuItem`, `OeHdr`, `OeLine`, `OrderHeader`, `OrderLine`, `OrderNote`, `OrderPayment`, `PaymentStatus`, `PaymentStatusInvoice`, `ProductJsonLdAggregateRating`, `ProductJsonLdOptions`, `ProductJsonLdSeller`, `ResolveStockInput`, `ResolvedStock`, `SafeActionResult`, `SchemaAvailability`, `SearchParamOptions`, `ShipToAddress`, `ShippingAddress`, `TAccountQuery`, `TApiResponse`, `TAttribute`, `TAttributeValue`, `TBillingUpdate`, `TCardInfo`, `TCartHdrUid`, `TCartLine`, `TCartLookUp`, `TCategory`, `TCategoryChild`, `TCategoryItemsResult`, `TCheckoutResult`, `TInvMast`, `TInvMastDoc`, `TInventorySupplier`, `TItemAccessory`, `TItemAttribute`, `TItemAttributes`, `TItemCategory`, `TItemDetails`, `TItemRelatedProduct`, `TItemUom`, `TItemsFilters`, `TJoomlaContent`, `TJoomlaContentFilters`, `TLibraryPriceBreak`, `TLibraryPriceData`, `TLtlRatesResponse`, `TLtlShipmentData`, `TMenu`, `TMenuFilters`, `TMetaTags`, `TOrderCartLine`, `TPasswordVerification`, `TPaymentValidation`, `TPriceData`, `TProductCategory`, `TProductItem`, `TProductStockData`, `TProfileValues`, `TRelatedProduct`, `TSearchSuggestion`, `TSearchSuggestionsResponse`, `TShippingMethod`, `TSmartyStreets`, `TStock`, `TStockData`, `TSurcharge`, `TTax`, `TTaxItem`, `TTransactionSetup`, `TUserProfile`, `TWebDesc`, `TrackingData`, `TrackingItem`, `USStateCode`, `UserAddress`, `ViewItemEventParams`
182
-
183
-
184
- ## Related Packages
185
-
186
- All packages use fixed versioning -- same version number across the platform.
187
-
188
- | Package | Description |
189
- |---------|-------------|
190
- | `@simpleapps-com/augur-config` | Shared tooling configuration presets for Augur ecommerce sites |
191
- | `@simpleapps-com/augur-core` | Universal foundation for Augur packages — proxy infrastructure, cache keys, method classification, shared types |
192
- | `@simpleapps-com/augur-hooks` | Cross-platform React Query hooks and Zustand stores for Augur ecommerce sites |
193
- | `@simpleapps-com/augur-mobile` | React Native/Expo adapters for Augur ecommerce apps (offline sync, biometrics, push) |
194
- | `@simpleapps-com/augur-server` | Server-side utilities for Augur ecommerce sites (Redis caching, SDK helpers, auth) |
195
- | `@simpleapps-com/augur-tailwind` | Shared Tailwind CSS v4 theme with HSL variables for Augur ecommerce sites |
196
- | `@simpleapps-com/augur-web` | Shared React UI components for Augur ecommerce sites (Radix + Tailwind) |
34
+ A change to its exports MUST come with `pnpm -C repo/sites/augur-build generate` (the drift
35
+ test fails otherwise), and the guide changes in the same PR.
@@ -0,0 +1,18 @@
1
+ import type { TSmartyStreets } from "./types/smarty-streets";
2
+ /** User-entered address fields for comparison. */
3
+ export interface UserAddress {
4
+ address1: string;
5
+ city: string;
6
+ state: string;
7
+ postalCode: string;
8
+ }
9
+ /**
10
+ * Compares a user-entered address with a SmartyStreets-validated address.
11
+ * Returns true if any field differs (case-insensitive for address/city,
12
+ * exact match for state abbreviation and zip code).
13
+ *
14
+ * Used in checkout to prompt users when their input differs from the
15
+ * USPS-validated address.
16
+ */
17
+ export declare function isAddressDifferent(userAddress: UserAddress, smartyAddress: TSmartyStreets): boolean;
18
+ //# sourceMappingURL=address-comparison.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-comparison.d.ts","sourceRoot":"","sources":["../src/address-comparison.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,cAAc,GAC5B,OAAO,CAOT"}
@@ -0,0 +1,45 @@
1
+ import * as v from "valibot";
2
+ /**
3
+ * Valibot schema for shipping address validation.
4
+ * Enforces no PO Box, requires street number, formats phone number.
5
+ */
6
+ export declare const ShippingAddressSchema: v.ObjectSchema<{
7
+ readonly companyName: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
8
+ readonly firstName: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, string>, v.RegexAction<string, string>, v.RegexAction<string, string>]>;
9
+ readonly lastName: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, string>, v.RegexAction<string, string>, v.RegexAction<string, string>]>;
10
+ readonly address1: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "Address 1 is required">, v.RegexAction<string, "Invalid address">, v.RegexAction<string, "PO Box addresses are not allowed for shipping">, v.RegexAction<string, "Address must contain at least one number">]>;
11
+ readonly address2: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid address format">, v.CheckAction<string, "PO Box addresses are not allowed for shipping">]>, undefined>;
12
+ readonly postalCode: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "Zip code is required">, v.RegexAction<string, "Zip code must be exactly 5 digits">]>;
13
+ readonly city: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 2, "City is required">, v.RegexAction<string, "City must contain only letters, spaces, periods, hyphens, or apostrophes">]>;
14
+ readonly state: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "State is required">, v.PicklistSchema<[string, ...string[]], "Please select a valid US state">]>;
15
+ readonly country: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "Country is required">]>;
16
+ readonly email: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "Email is required">, v.EmailAction<string, "Invalid email">]>;
17
+ readonly phoneNumber: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "Phone number is required">, v.RegexAction<string, "Invalid phone number">, v.TransformAction<string, string>]>;
18
+ readonly notes: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
19
+ readonly plus4Code: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
20
+ }, undefined>;
21
+ /**
22
+ * Valibot schema for billing address validation.
23
+ * Less strict than shipping: allows PO Box, no email/phone required.
24
+ */
25
+ export declare const BillingAddressSchema: v.ObjectSchema<{
26
+ readonly poNumber: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
27
+ readonly firstName: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, string>, v.RegexAction<string, string>, v.RegexAction<string, string>]>;
28
+ readonly lastName: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, string>, v.RegexAction<string, string>, v.RegexAction<string, string>]>;
29
+ readonly address1: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "Address 1 is required">, v.RegexAction<string, "Invalid address">]>;
30
+ readonly address2: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
31
+ readonly postalCode: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "Zip code is required">]>;
32
+ readonly city: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "City is required">]>;
33
+ readonly state: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "State is required">]>;
34
+ readonly country: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, "Country is required">]>;
35
+ readonly plus4Code: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
36
+ }, undefined>;
37
+ /**
38
+ * Valibot schema for billing address with required PO number (invoice payments).
39
+ */
40
+ export declare const BillingAddressInvoiceSchema: v.ObjectSchema<{
41
+ readonly poNumber: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 2, "PO number is required">]>;
42
+ }, undefined>;
43
+ export type ShippingAddress = v.InferOutput<typeof ShippingAddressSchema>;
44
+ export type BillingAddress = v.InferOutput<typeof BillingAddressSchema>;
45
+ //# sourceMappingURL=address-schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"address-schemas.d.ts","sourceRoot":"","sources":["../src/address-schemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAmB7B;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;aAuDhC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;aAe/B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,2BAA2B;;aAEtC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAC1E,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Analytics utility functions for tracking ecommerce events via Google Analytics.
3
+ */
4
+ declare global {
5
+ interface Window {
6
+ dataLayer?: Record<string, unknown>[];
7
+ gtag?: (...args: unknown[]) => void;
8
+ }
9
+ }
10
+ export interface AddToCartEventParams {
11
+ itemId: string;
12
+ itemName: string;
13
+ price: number;
14
+ quantity: number;
15
+ estimatedCost: number;
16
+ }
17
+ /**
18
+ * Track add_to_cart event to Google Analytics dataLayer.
19
+ */
20
+ export declare function trackAddToCart({ itemId, itemName, price, quantity, estimatedCost, }: AddToCartEventParams): void;
21
+ export interface ViewItemEventParams {
22
+ itemId: string;
23
+ itemName: string;
24
+ price: number;
25
+ category?: string;
26
+ }
27
+ /**
28
+ * Track view_item event to Google Analytics dataLayer.
29
+ */
30
+ export declare function trackViewItem({ itemId, itemName, price, category, }: ViewItemEventParams): void;
31
+ export interface TrackingItem {
32
+ item_id: string;
33
+ item_name: string;
34
+ currency: string;
35
+ index: number;
36
+ item_category: string;
37
+ price: number;
38
+ quantity: number;
39
+ }
40
+ export interface TrackingData {
41
+ event: string;
42
+ currency: string;
43
+ value: number;
44
+ items: TrackingItem[];
45
+ }
46
+ export interface BuildTrackingDataInput {
47
+ cartLines: {
48
+ itemId: string;
49
+ quantity: number;
50
+ }[];
51
+ itemDetails: Record<string, {
52
+ itemDesc?: string;
53
+ classId5?: string;
54
+ }>;
55
+ getUnitPrice: (itemId: string) => number;
56
+ currency?: string;
57
+ }
58
+ /**
59
+ * Build a GA4 begin_checkout ecommerce payload from cart lines, item details, and prices.
60
+ */
61
+ export declare function buildTrackingData({ cartLines, itemDetails, getUnitPrice, currency, }: BuildTrackingDataInput): TrackingData;
62
+ /**
63
+ * Push ecommerce tracking data to window.dataLayer using the GA4 clear-then-push pattern.
64
+ */
65
+ export declare function pushTrackingData(data: TrackingData): void;
66
+ //# sourceMappingURL=analytics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../src/analytics.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;QACtC,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;KACrC;CACF;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAC7B,MAAM,EACN,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,aAAa,GACd,EAAE,oBAAoB,GAAG,IAAI,CAwB7B;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,QAAQ,EACR,KAAK,EACL,QAAa,GACd,EAAE,mBAAmB,GAAG,IAAI,CAkB5B;AAMD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,YAAY,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAClD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtE,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,WAAW,EACX,YAAY,EACZ,QAAgB,GACjB,EAAE,sBAAsB,GAAG,YAAY,CAwBvC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAYzD"}
@@ -0,0 +1,37 @@
1
+ import type { TCartLine } from "./types/cart";
2
+ export type OeHdr = {
3
+ customer_id: number;
4
+ company_id: string;
5
+ sales_location_id: number;
6
+ user_id: number;
7
+ user_email: string;
8
+ taker: string;
9
+ customer_po_no?: string;
10
+ ship_to_id?: string | number;
11
+ delivery_instructions?: string;
12
+ };
13
+ export type OeLine = {
14
+ item_id: string;
15
+ unit_quantity: number | null;
16
+ unit_of_measure: string | null;
17
+ inv_mast_uid: number;
18
+ unit_price?: number;
19
+ };
20
+ export type CheckoutInput = {
21
+ customerId: number;
22
+ companyId: string;
23
+ salesLocationId: number;
24
+ userId: number;
25
+ userEmail: string;
26
+ taker?: string;
27
+ cartLines: TCartLine[];
28
+ poNumber?: string;
29
+ shipToId?: string | number;
30
+ deliveryInstructions?: string;
31
+ };
32
+ /** Builds the oe_hdr + oe_line payload required by the commerce checkout API from cart data. */
33
+ export declare function buildCheckoutPayload(input: CheckoutInput): {
34
+ oe_hdr: OeHdr;
35
+ oe_line: OeLine[];
36
+ };
37
+ //# sourceMappingURL=build-checkout-payload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-checkout-payload.d.ts","sourceRoot":"","sources":["../src/build-checkout-payload.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,MAAM,KAAK,GAAG;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AAEF,gGAAgG;AAChG,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,aAAa,GAAG;IAC1D,MAAM,EAAE,KAAK,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CA0BA"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Centralized cache configuration for React Query (TanStack Query)
3
+ *
4
+ * staleTime -- How long cached data is considered "fresh". While fresh,
5
+ * React Query serves the cache instantly and does NOT refetch in the
6
+ * background. After staleTime expires the data is "stale" and will be
7
+ * refetched on the next access (mount, window focus, etc.).
8
+ *
9
+ * gcTime (garbage collection time) -- How long UNUSED cached data stays in
10
+ * memory after all components using it unmount. Once gcTime expires the
11
+ * cache entry is deleted entirely.
12
+ *
13
+ * STATIC (1h): categories, menus, item details
14
+ * SEMI_STATIC (10m): pricing, stock, search results
15
+ * DYNAMIC (5m): infinite scroll data
16
+ * CART (2m): cart lines, cart header
17
+ * REALTIME (0): active orders, checkout state
18
+ */
19
+ export declare const CACHE_CONFIG: {
20
+ readonly STATIC: {
21
+ readonly staleTime: number;
22
+ readonly gcTime: number;
23
+ };
24
+ readonly SEMI_STATIC: {
25
+ readonly staleTime: number;
26
+ readonly gcTime: number;
27
+ };
28
+ readonly DYNAMIC: {
29
+ readonly staleTime: number;
30
+ readonly gcTime: number;
31
+ };
32
+ readonly CART: {
33
+ readonly staleTime: number;
34
+ readonly gcTime: number;
35
+ };
36
+ readonly REALTIME: {
37
+ readonly staleTime: 0;
38
+ readonly gcTime: number;
39
+ };
40
+ };
41
+ export type CacheTier = keyof typeof CACHE_CONFIG;
42
+ //# sourceMappingURL=cache-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache-config.d.ts","sourceRoot":"","sources":["../src/cache-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;CAqBf,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,MAAM,OAAO,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-utils/dist/chunk-5UMFBGVA.cjs","../src/web.ts"],"names":[],"mappings":"AAAA;ACAA,4BAAsC;AACtC,+CAAwB;AAGjB,SAAS,EAAA,CAAA,GAAM,MAAA,EAAsB;AAC1C,EAAA,OAAO,oCAAA,wBAAQ,MAAW,CAAC,CAAA;AAC7B;ADAA;AACA;AACE;AACF,gBAAC","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-utils/dist/chunk-5UMFBGVA.cjs","sourcesContent":[null,"import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/** Merge Tailwind classes without conflicts. Web only (tailwind-merge is meaningless in RN). */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n"]}
1
+ {"version":3,"sources":["/Users/stuartjackson/Projects/simpleapps/atlas/repo/packages/augur-utils/dist/chunk-5UMFBGVA.cjs","../src/web.ts"],"names":[],"mappings":"AAAA;ACAA,4BAAsC;AACtC,+CAAwB;AAGjB,SAAS,EAAA,CAAA,GAAM,MAAA,EAAsB;AAC1C,EAAA,OAAO,oCAAA,wBAAQ,MAAW,CAAC,CAAA;AAC7B;ADAA;AACA;AACE;AACF,gBAAC","file":"/Users/stuartjackson/Projects/simpleapps/atlas/repo/packages/augur-utils/dist/chunk-5UMFBGVA.cjs","sourcesContent":[null,"import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/** Merge Tailwind classes without conflicts. Web only (tailwind-merge is meaningless in RN). */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n"]}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Date utility functions for shipping calculations.
3
+ */
4
+ /**
5
+ * Get the Nth business day from today (skipping weekends).
6
+ * @param businessDaysFromNow - Number of business days to add
7
+ * @returns Formatted date string
8
+ */
9
+ export declare function getBusinessDay(businessDaysFromNow: number): string;
10
+ /**
11
+ * Get shipping lead date estimate based on days string (the table is `shippingLeadOf`).
12
+ * @param days - Shipping days string (e.g., "1-2", "2-3", "3")
13
+ * @returns Formatted date range or single date
14
+ */
15
+ export declare function getShippingLeadDate(days: string): string;
16
+ //# sourceMappingURL=date-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-helpers.d.ts","sourceRoot":"","sources":["../src/date-helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAUH;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,mBAAmB,EAAE,MAAM,GAAG,MAAM,CAgBlE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAYxD"}
@@ -0,0 +1,49 @@
1
+ import type { TPriceData } from "./types/pricing";
2
+ /**
3
+ * Result of price derivation as a discriminated union over the three real
4
+ * domain states. The `state` tag lifts the previously-overloaded `0` sentinel
5
+ * into the type system: "loading" (no price record yet) is now distinct from
6
+ * "callForPrice" (a genuine zero price). See GH #454.
7
+ */
8
+ export type DerivedPrice = {
9
+ state: "loading";
10
+ } | {
11
+ state: "priced";
12
+ unitPrice: number;
13
+ total: number;
14
+ unitOfMeasure: string;
15
+ } | {
16
+ state: "callForPrice";
17
+ unitOfMeasure: string;
18
+ };
19
+ export interface DerivePriceInput {
20
+ priceData: TPriceData | null | undefined;
21
+ /**
22
+ * Quantity in the priced unit. Fractional values come from UOM conversion (ft, sqft, lb).
23
+ * Omit it to price one unit. Null is not accepted: an unknown quantity cannot be priced,
24
+ * so the caller decides how to handle it.
25
+ */
26
+ quantity?: number;
27
+ }
28
+ /**
29
+ * Pure price derivation — usable in hooks AND server components.
30
+ *
31
+ * @requires quantity = undefined ∨ (quantity ∈ ℝ ∧ quantity ≥ 0 ∧ Number.isFinite(quantity))
32
+ * // omitted → 1 (a one-unit price); fractional quantities (UOM conversion, e.g. 2023.5 ft) are valid;
33
+ * // negative, NaN, ±Infinity, or a null passed at runtime → RangeError. -0 passes (-0 ≥ 0).
34
+ * @requires unitPrice ≥ 0 ∧ Number.isFinite(unitPrice) (when a price record is present)
35
+ * // violated → RangeError
36
+ * @ensures result.state = "loading" ⟺ priceData == null ∨ priceData.unitPrice == null (given the quantity @requires; a bad quantity throws even while loading)
37
+ * // a missing price record (undefined/null) is loading, NOT a zero price — the distinction GH #454 restores
38
+ * @ensures result.state = "callForPrice" ⟺ priceData.unitPrice = 0
39
+ * // a genuine zero price is call-for-price, distinct from loading
40
+ * @ensures result.state = "priced" ⟺ priceData.unitPrice > 0
41
+ * // total = cleanMoney(unitPrice · quantity): the product rounded half away from zero to
42
+ * // 8 decimals, which removes float noise (38.0714 · 3 → 114.2142, not 114.21419999999999)
43
+ *
44
+ * The state decision (which branch, including the two RangeErrors) is `priceOutcome`, proved
45
+ * with LemmaScript (`price-outcome.ts`, linked to `models/AugurUtils.dfy`). This function computes
46
+ * its three flags and does the money math; both are tested, not proved.
47
+ */
48
+ export declare function derivePrice(input: DerivePriceInput): DerivedPrice;
49
+ //# sourceMappingURL=derive-price.d.ts.map