@simpleapps-com/augur-utils 2026.11.2 → 2026.11.4
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/EXPORTS.md +24 -2
- package/README.md +15 -2
- package/dist/analytics.d.ts +8 -3
- package/dist/analytics.d.ts.map +1 -1
- package/dist/cache-config.d.ts +17 -11
- package/dist/cache-config.d.ts.map +1 -1
- package/dist/cart-line-rules.d.ts +43 -0
- package/dist/cart-line-rules.d.ts.map +1 -0
- package/dist/date-helpers.d.ts.map +1 -1
- package/dist/duration.d.ts +43 -0
- package/dist/duration.d.ts.map +1 -0
- package/dist/index.cjs +200 -80
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +200 -80
- package/dist/index.js.map +1 -1
- package/dist/rules.d.ts +46 -0
- package/dist/rules.d.ts.map +1 -1
- package/dist/runtime.d.ts +24 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/transform-ship-to-address.d.ts.map +1 -1
- package/llms.txt +26 -1
- package/package.json +4 -3
package/EXPORTS.md
CHANGED
|
@@ -9,21 +9,24 @@
|
|
|
9
9
|
|
|
10
10
|
| Export | Kind | Description |
|
|
11
11
|
|--------|------|-------------|
|
|
12
|
+
| `addMillis` | const | A clock reading plus a duration, both milliseconds: when something expires. |
|
|
12
13
|
| `BillingAddressInvoiceSchema` | const | Valibot schema for billing address with required PO number (invoice payments). |
|
|
13
14
|
| `BillingAddressSchema` | const | Valibot schema for billing address validation. Less strict than shipping: allows PO Box, no email/phone required. |
|
|
14
15
|
| `BLUR_DATA_URL` | const | 1x1 transparent PNG for Next.js `<Image blurDataURL={...}>` placeholders. |
|
|
15
16
|
| `breadcrumbLd` | const | A breadcrumb trail's BreadcrumbList as text. |
|
|
16
17
|
| `buildCheckoutPayload` | function | Builds the oe_hdr + oe_line payload required by the commerce checkout API from cart data. |
|
|
17
18
|
| `buildImageLoader` | function | Returns a loader function compatible with Next.js `<Image loader={...}>`. |
|
|
18
|
-
| `buildTrackingData` | function | Build a GA4 begin_checkout ecommerce payload from cart lines, item details, and
|
|
19
|
+
| `buildTrackingData` | function | Build a GA4 begin_checkout ecommerce payload from cart lines, item details, and each line's own price. |
|
|
19
20
|
| `CACHE_CONFIG` | const | Centralized cache configuration for React Query (TanStack Query) |
|
|
20
21
|
| `categorySortBy` | function | serializeCategoryFilters' sortBy: the prefix applied only when both are non-empty. |
|
|
21
22
|
| `cleanMoney` | function | Remove JS float noise from a money product or sum. |
|
|
22
23
|
| `cn` | function | Merge Tailwind classes without conflicts. Web only (tailwind-merge is meaningless in RN). |
|
|
23
24
|
| `CONTIGUOUS_STATES` | const | Lower 48 contiguous states. |
|
|
24
25
|
| `createImageConfig` | function | Creates a frozen ImageConfig object. |
|
|
26
|
+
| `days` | const | `n` days, in seconds. |
|
|
25
27
|
| `derivePrice` | function | Pure price derivation — usable in hooks AND server components. |
|
|
26
28
|
| `faqLd` | const | A FAQ page's FAQPage markup as text: one Question per entry. |
|
|
29
|
+
| `floorSeconds` | const | Milliseconds as whole seconds, rounded down. |
|
|
27
30
|
| `formatPrice` | function | Locale-aware currency formatting. Defaults to USD -- consumers can override locale and currency. |
|
|
28
31
|
| `generateBreadcrumbJsonLd` | function | Generates a Schema.org BreadcrumbList JSON-LD object from an array of breadcrumb items. |
|
|
29
32
|
| `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. |
|
|
@@ -35,19 +38,37 @@
|
|
|
35
38
|
| `getSchemaAvailability` | function | Maps resolved stock to a Schema.org availability URL. |
|
|
36
39
|
| `getShippingLeadDate` | function | Get shipping lead date estimate based on days string (the table is `shippingLeadOf`). |
|
|
37
40
|
| `hasPriceBreaks` | function | Type guard: true when `libraryPriceData` is the price-page shape with quantity `breaks`. |
|
|
41
|
+
| `hours` | const | `n` hours, in seconds. |
|
|
38
42
|
| `idRef` | const | A reference to another node by its @id, as JSON text. |
|
|
39
43
|
| `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). |
|
|
44
|
+
| `isServerRuntime` | function | Returns true when running outside a browser (Node SSR, edge, Deno). Mirrors `isServer` in `@tanstack/query-core` (`build/modern/utils.js`). Evaluated per call, not at module scope, so `"use client"` modules that also run during SSR resolve correctly on each pass. |
|
|
45
|
+
| `lineHasQuantity` | function | Whether a cart line has a quantity (augur always stores one; the type allows null). |
|
|
46
|
+
| `linePriceAt` | function | Line `i`'s unit price from the per-line list (cart order): its own, fetched at its own quantity, so one item on two lines (two units of measure) keeps two prices; 0 past the end. |
|
|
47
|
+
| `millis` | const | `n` milliseconds, for a duration under a second. |
|
|
48
|
+
| `millisOf` | const | `n` as `Millis`, or null unless it is a safe integer at least 0. |
|
|
49
|
+
| `minusMillis` | const | A reading less a duration, never below 0. |
|
|
50
|
+
| `minutes` | const | `n` minutes, in seconds. |
|
|
40
51
|
| `nodeHead` | const | The schema.org context and a node's type: its first two members, as JSON text. |
|
|
41
52
|
| `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. |
|
|
42
53
|
| `paginateOffset` | function | Returns a copy of filters with offset adjusted for the given page. |
|
|
54
|
+
| `priceQueryRuns` | function | Whether a line's price query runs: a customer, an itemId, and a quantity (the price engine is never asked for a quantity nobody entered). |
|
|
55
|
+
| `priceQueryUnit` | function | The unit of measure a line's price query asks for: the line's own, so a CASE/6 line is priced per case, not as one EACH (the price engine prices a query without a unit in the item's default selling unit); null for a missing or blank unit (a line saved before the client required one). |
|
|
56
|
+
| `pricingLoadingFrom` | function | Cart pricing is loading when any query that runs is loading. |
|
|
57
|
+
| `pricingSettledFrom` | function | Cart pricing is settled when every query that runs has succeeded: a line whose query never runs (no quantity, no itemId, no customer) can't hold it back (its query stays pending and idle). |
|
|
43
58
|
| `pushTrackingData` | function | Push ecommerce tracking data to window.dataLayer using the GA4 clear-then-push pattern. |
|
|
59
|
+
| `resolveGcTime` | function | Returns the React Query `gcTime` to use for a query built in this runtime. On the server returns `Infinity`, which query-core treats as "schedule no GC timer", so a per-request QueryClient is freed when the request ends. A finite value would start a timer that pins the whole request cache. In the browser returns `clientGcTime` unchanged. The result is a `number`, not `Millis`: `Infinity` is no whole number of milliseconds. |
|
|
44
60
|
| `resolveStock` | function | Pure stock resolution -- usable in hooks AND server components. |
|
|
45
61
|
| `roundHalfAway` | function | Round half away from zero to `decimals` places. |
|
|
46
62
|
| `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. |
|
|
63
|
+
| `seconds` | const | `n` seconds. |
|
|
64
|
+
| `secondsOf` | const | `n` as `Seconds`, or null unless it is a safe integer at least 0. |
|
|
47
65
|
| `serializeCategoryFilters` | function | Converts TItemsFilters to the SDK params shape for category item endpoints. |
|
|
48
66
|
| `serializeSearchParams` | function | Converts TItemsFilters to the SDK params shape for search endpoints. |
|
|
49
67
|
| `serializeTransforms` | function | Serializes transform options into the CDN path segment. Example: `{ width: 400, format: "webp" }` → `"w_400,f_webp"` |
|
|
50
68
|
| `ShippingAddressSchema` | const | Valibot schema for shipping address validation. Enforces no PO Box, requires street number, formats phone number. |
|
|
69
|
+
| `tierBrowserGcTime` | function | A tier's gcTime in the browser: STATIC 24 h, SEMI_STATIC 4 h, DYNAMIC and CART 30 min, REALTIME 5 min; never shorter than its staleTime. On the server the tier's gcTime is `gcTimeFor(true, …)`: none. |
|
|
70
|
+
| `tierStaleTime` | function | A tier's staleTime: STATIC 1 h, SEMI_STATIC 10 min, DYNAMIC 5 min, CART 2 min, REALTIME 0. |
|
|
71
|
+
| `toMillis` | const | Seconds as milliseconds, exactly. |
|
|
51
72
|
| `trackAddToCart` | function | Track add_to_cart event to Google Analytics dataLayer. |
|
|
52
73
|
| `trackViewItem` | function | Track view_item event to Google Analytics dataLayer. |
|
|
53
74
|
| `transformShipToAddress` | function | Normalizes a raw ship-to address object (camelCase or snake_case, physical or mailing) into a consistent ShipToAddress shape. |
|
|
@@ -57,10 +78,11 @@
|
|
|
57
78
|
| `US_STATES_FULL` | const | All US states and territories — full data from states-us. |
|
|
58
79
|
| `US_TERRITORIES` | const | US territories (PR, GU, VI, AS, MP). |
|
|
59
80
|
| `VALIDATION_PATTERNS` | const | Common regex patterns used for form validation across augur-hosted sites. |
|
|
81
|
+
| `wholeSeconds` | const | An outside count of seconds, rounded down; 0 when it is then no safe integer at least 0. |
|
|
60
82
|
|
|
61
83
|
### Types
|
|
62
84
|
|
|
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`
|
|
85
|
+
`AddToCartEventParams`, `BillingAddress`, `BreadcrumbJsonLdItem`, `BuildTrackingDataInput`, `CacheTier`, `CategoryFilterOptions`, `CheckoutInput`, `CheckoutPayment`, `CustomerDocument`, `DerivedPrice`, `DerivePriceInput`, `Faq`, `ImageConfig`, `ImageTransforms`, `ImageUrlOptions`, `MenuItem`, `Millis`, `OeHdr`, `OeLine`, `OrderHeader`, `OrderLine`, `OrderNote`, `OrderPayment`, `PaymentStatus`, `PaymentStatusInvoice`, `ProductJsonLdAggregateRating`, `ProductJsonLdOptions`, `ProductJsonLdSeller`, `ResolvedStock`, `ResolveStockInput`, `SafeActionResult`, `SchemaAvailability`, `SearchParamOptions`, `Seconds`, `ShippingAddress`, `ShipToAddress`, `TAccountQuery`, `TApiResponse`, `TAttribute`, `TAttributeValue`, `TBillingUpdate`, `TCardInfo`, `TCartHdrUid`, `TCartLine`, `TCartLookUp`, `TCategory`, `TCategoryChild`, `TCategoryItemsResult`, `TCheckoutResult`, `TierName`, `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`
|
|
64
86
|
|
|
65
87
|
## `@simpleapps-com/augur-utils/web`
|
|
66
88
|
|
package/README.md
CHANGED
|
@@ -23,8 +23,21 @@ pnpm add @simpleapps-com/augur-utils
|
|
|
23
23
|
## Development
|
|
24
24
|
|
|
25
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
|
|
27
|
-
`models/AugurUtils.dfy`, links `models/links/augur-utils-*.dfy`);
|
|
26
|
+
(`src/rules.ts`, `src/price-outcome.ts`, `src/image-rules.ts`, `src/json-ld-rules.ts`,
|
|
27
|
+
`src/cart-line-rules.ts`; model `models/AugurUtils.dfy`, links `models/links/augur-utils-*.dfy`);
|
|
28
|
+
the rest is tested at 100%.
|
|
29
|
+
|
|
30
|
+
Cart-line pricing (#93) lives in `src/cart-line-rules.ts`: `lineHasQuantity`, `priceQueryRuns`
|
|
31
|
+
(augur never stores a null quantity, `models/AugurCommerceCartLine.dfy`; the type allows one, and
|
|
32
|
+
such a line is not priced), `pricingSettledFrom` / `pricingLoadingFrom` (over the prices that are
|
|
33
|
+
fetched) and `linePriceAt` (each line's own price, so one item on two lines keeps two).
|
|
34
|
+
`buildTrackingData` takes `getLineUnitPrice(index)`, a price per line.
|
|
35
|
+
|
|
36
|
+
`CACHE_CONFIG`'s tiers are server-safe (#94): each `gcTime` is a getter through
|
|
37
|
+
`resolveGcTime` (`src/runtime.ts`, the proved `gcTimeFor` in `src/rules.ts`), so it is
|
|
38
|
+
`Infinity` on the server and the tier's value in the browser, decided each time a tier is read.
|
|
39
|
+
`isServerRuntime` and `resolveGcTime` live here, the lowest package that needs them; augur-core
|
|
40
|
+
re-exports `resolveGcTime`.
|
|
28
41
|
|
|
29
42
|
```bash
|
|
30
43
|
pnpm -C repo/packages/augur-utils test
|
package/dist/analytics.d.ts
CHANGED
|
@@ -52,13 +52,18 @@ export interface BuildTrackingDataInput {
|
|
|
52
52
|
itemDesc?: string;
|
|
53
53
|
classId5?: string;
|
|
54
54
|
}>;
|
|
55
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Unit price of the line at `index` in `cartLines` (useCartPricing's `getLineUnitPrice`). Per
|
|
57
|
+
* line, not per item: one item on two lines (two units of measure) has two prices.
|
|
58
|
+
*/
|
|
59
|
+
getLineUnitPrice: (index: number) => number;
|
|
56
60
|
currency?: string;
|
|
57
61
|
}
|
|
58
62
|
/**
|
|
59
|
-
* Build a GA4 begin_checkout ecommerce payload from cart lines, item details, and
|
|
63
|
+
* Build a GA4 begin_checkout ecommerce payload from cart lines, item details, and each line's own
|
|
64
|
+
* price.
|
|
60
65
|
*/
|
|
61
|
-
export declare function buildTrackingData({ cartLines, itemDetails,
|
|
66
|
+
export declare function buildTrackingData({ cartLines, itemDetails, getLineUnitPrice, currency, }: BuildTrackingDataInput): TrackingData;
|
|
62
67
|
/**
|
|
63
68
|
* Push ecommerce tracking data to window.dataLayer using the GA4 clear-then-push pattern.
|
|
64
69
|
*/
|
package/dist/analytics.d.ts.map
CHANGED
|
@@ -1 +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,EAA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E,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;;;OAGG;IACH,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC5C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,QAAgB,GACjB,EAAE,sBAAsB,GAAG,YAAY,CAwBvC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAYzD"}
|
package/dist/cache-config.d.ts
CHANGED
|
@@ -8,33 +8,39 @@
|
|
|
8
8
|
*
|
|
9
9
|
* gcTime (garbage collection time) -- How long UNUSED cached data stays in
|
|
10
10
|
* memory after all components using it unmount. Once gcTime expires the
|
|
11
|
-
* cache entry is deleted entirely.
|
|
11
|
+
* cache entry is deleted entirely. Server-safe (#94): each tier's gcTime is
|
|
12
|
+
* read through `resolveGcTime`, so on the server it is `Infinity` (no GC
|
|
13
|
+
* timer, the per-request cache is freed with the request) and in the browser
|
|
14
|
+
* the value below, never shorter than the tier's staleTime (proved). It is
|
|
15
|
+
* decided each time the tier is read, so spreading a tier after the proxy's
|
|
16
|
+
* options (`{ ...q.items.get(id), ...CACHE_CONFIG.STATIC }`) is safe in a
|
|
17
|
+
* `"use client"` module rendered on the server too.
|
|
12
18
|
*
|
|
13
|
-
* STATIC (1h):
|
|
14
|
-
* SEMI_STATIC (10m):
|
|
15
|
-
* DYNAMIC (5m):
|
|
16
|
-
* CART (2m):
|
|
17
|
-
* REALTIME (0):
|
|
19
|
+
* STATIC (1h, gc 24h): categories, menus, item details
|
|
20
|
+
* SEMI_STATIC (10m, gc 4h): pricing, stock, search results
|
|
21
|
+
* DYNAMIC (5m, gc 30m): infinite scroll data
|
|
22
|
+
* CART (2m, gc 30m): cart lines, cart header
|
|
23
|
+
* REALTIME (0, gc 5m): active orders, checkout state
|
|
18
24
|
*/
|
|
19
25
|
export declare const CACHE_CONFIG: {
|
|
20
26
|
readonly STATIC: {
|
|
21
|
-
readonly staleTime:
|
|
27
|
+
readonly staleTime: import("./duration").Millis;
|
|
22
28
|
readonly gcTime: number;
|
|
23
29
|
};
|
|
24
30
|
readonly SEMI_STATIC: {
|
|
25
|
-
readonly staleTime:
|
|
31
|
+
readonly staleTime: import("./duration").Millis;
|
|
26
32
|
readonly gcTime: number;
|
|
27
33
|
};
|
|
28
34
|
readonly DYNAMIC: {
|
|
29
|
-
readonly staleTime:
|
|
35
|
+
readonly staleTime: import("./duration").Millis;
|
|
30
36
|
readonly gcTime: number;
|
|
31
37
|
};
|
|
32
38
|
readonly CART: {
|
|
33
|
-
readonly staleTime:
|
|
39
|
+
readonly staleTime: import("./duration").Millis;
|
|
34
40
|
readonly gcTime: number;
|
|
35
41
|
};
|
|
36
42
|
readonly REALTIME: {
|
|
37
|
-
readonly staleTime:
|
|
43
|
+
readonly staleTime: import("./duration").Millis;
|
|
38
44
|
readonly gcTime: number;
|
|
39
45
|
};
|
|
40
46
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache-config.d.ts","sourceRoot":"","sources":["../src/cache-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cache-config.d.ts","sourceRoot":"","sources":["../src/cache-config.ts"],"names":[],"mappings":"AAiBA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,YAAY;;;yBA9BP,MAAM;;;;yBAAN,MAAM;;;;yBAAN,MAAM;;;;yBAAN,MAAM;;;;yBAAN,MAAM;;CAoCd,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,MAAM,OAAO,YAAY,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a cart line has a quantity (augur always stores one; the type allows null).
|
|
3
|
+
*
|
|
4
|
+
* @ensures result ⟺ quantity ≠ null, the model's LineHasQuantity
|
|
5
|
+
*/
|
|
6
|
+
export declare function lineHasQuantity(quantity: number | null): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Whether a line's price query runs: a customer, an itemId, and a quantity (the price engine is
|
|
9
|
+
* never asked for a quantity nobody entered).
|
|
10
|
+
*
|
|
11
|
+
* @ensures result ⟺ hasCustomer ∧ hasItemId ∧ quantity ≠ null, the model's PriceQueryRuns over
|
|
12
|
+
* LineHasQuantity
|
|
13
|
+
*/
|
|
14
|
+
export declare function priceQueryRuns(hasCustomer: boolean, hasItemId: boolean, quantity: number | null): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* The unit of measure a line's price query asks for: the line's own, so a CASE/6 line is priced per
|
|
17
|
+
* case, not as one EACH (the price engine prices a query without a unit in the item's default
|
|
18
|
+
* selling unit); null for a missing or blank unit (a line saved before the client required one).
|
|
19
|
+
*
|
|
20
|
+
* @ensures result = unitOfMeasure when it is set and not blank, else null: the model's QueryUnit
|
|
21
|
+
*/
|
|
22
|
+
export declare function priceQueryUnit(unitOfMeasure: string | null): string | null;
|
|
23
|
+
/**
|
|
24
|
+
* Cart pricing is settled when every query that runs has succeeded: a line whose query never runs
|
|
25
|
+
* (no quantity, no itemId, no customer) can't hold it back (its query stays pending and idle).
|
|
26
|
+
*
|
|
27
|
+
* @ensures exactly the model's PricingSettledFrom
|
|
28
|
+
*/
|
|
29
|
+
export declare function pricingSettledFrom(succeeded: boolean[], runs: boolean[], i: number): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Cart pricing is loading when any query that runs is loading.
|
|
32
|
+
*
|
|
33
|
+
* @ensures exactly the model's PricingLoadingFrom
|
|
34
|
+
*/
|
|
35
|
+
export declare function pricingLoadingFrom(loading: boolean[], runs: boolean[], i: number): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Line `i`'s unit price from the per-line list (cart order): its own, fetched at its own quantity,
|
|
38
|
+
* so one item on two lines (two units of measure) keeps two prices; 0 past the end.
|
|
39
|
+
*
|
|
40
|
+
* @ensures result = unitPrices[i] when i < |unitPrices|, else 0, the model's LinePriceAt
|
|
41
|
+
*/
|
|
42
|
+
export declare function linePriceAt(unitPrices: number[], i: number): number;
|
|
43
|
+
//# sourceMappingURL=cart-line-rules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cart-line-rules.d.ts","sourceRoot":"","sources":["../src/cart-line-rules.ts"],"names":[],"mappings":"AAWA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAIhE;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,OAAO,EACpB,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,MAAM,GAAG,IAAI,GACtB,OAAO,CAIT;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAI1E;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAW5F;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAW1F;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAMnE"}
|
|
@@ -1 +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,
|
|
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,CAMxD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seconds and milliseconds for the published augur-* packages (2026-11-08): the same two types
|
|
3
|
+
* as `@atlas/utils/duration`, which is private (its code is bundled in, its types can't be
|
|
4
|
+
* named in a published `.d.ts`). The brands are the same, so a `Seconds` from either package is
|
|
5
|
+
* the other's (as the SDK's `SiteId` is auth-core's); the builders are the proved ones, passed
|
|
6
|
+
* through (model `Utils` "durations", link `models/links/utils-duration.dfy`).
|
|
7
|
+
*
|
|
8
|
+
* A TTL in seconds can't go where milliseconds are meant: React Query's `staleTime` / `gcTime`
|
|
9
|
+
* are `Millis`, a Redis TTL is `Seconds`. Write `toMillis(minutes(5))`, not `300000`.
|
|
10
|
+
*/
|
|
11
|
+
/** A whole number of seconds (a Redis TTL, a JWT `exp`). */
|
|
12
|
+
export type Seconds = number & {
|
|
13
|
+
readonly __seconds: true;
|
|
14
|
+
};
|
|
15
|
+
/** A whole number of milliseconds (React Query's `staleTime` / `gcTime`, `Date.now()`). */
|
|
16
|
+
export type Millis = number & {
|
|
17
|
+
readonly __millis: true;
|
|
18
|
+
};
|
|
19
|
+
/** `n` seconds. */
|
|
20
|
+
export declare const seconds: (n: number) => Seconds;
|
|
21
|
+
/** `n` minutes, in seconds. */
|
|
22
|
+
export declare const minutes: (n: number) => Seconds;
|
|
23
|
+
/** `n` hours, in seconds. */
|
|
24
|
+
export declare const hours: (n: number) => Seconds;
|
|
25
|
+
/** `n` days, in seconds. */
|
|
26
|
+
export declare const days: (n: number) => Seconds;
|
|
27
|
+
/** `n` milliseconds, for a duration under a second. */
|
|
28
|
+
export declare const millis: (n: number) => Millis;
|
|
29
|
+
/** Seconds as milliseconds, exactly. */
|
|
30
|
+
export declare const toMillis: (d: Seconds) => Millis;
|
|
31
|
+
/** A clock reading plus a duration, both milliseconds: when something expires. */
|
|
32
|
+
export declare const addMillis: (a: Millis, b: Millis) => Millis;
|
|
33
|
+
/** A reading less a duration, never below 0. */
|
|
34
|
+
export declare const minusMillis: (a: Millis, b: Millis) => Millis;
|
|
35
|
+
/** Milliseconds as whole seconds, rounded down. */
|
|
36
|
+
export declare const floorSeconds: (m: Millis) => Seconds;
|
|
37
|
+
/** `n` as `Seconds`, or null unless it is a safe integer at least 0. */
|
|
38
|
+
export declare const secondsOf: (n: number) => Seconds | null;
|
|
39
|
+
/** An outside count of seconds, rounded down; 0 when it is then no safe integer at least 0. */
|
|
40
|
+
export declare const wholeSeconds: (n: number) => Seconds;
|
|
41
|
+
/** `n` as `Millis`, or null unless it is a safe integer at least 0. */
|
|
42
|
+
export declare const millisOf: (n: number) => Millis | null;
|
|
43
|
+
//# sourceMappingURL=duration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../src/duration.ts"],"names":[],"mappings":"AAEA;;;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