@simpleapps-com/augur-utils 2026.11.2 → 2026.11.3
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 +17 -1
- package/README.md +6 -0
- package/dist/cache-config.d.ts +17 -11
- package/dist/cache-config.d.ts.map +1 -1
- package/dist/duration.d.ts +43 -0
- package/dist/duration.d.ts.map +1 -0
- package/dist/index.cjs +134 -52
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +134 -52
- package/dist/index.js.map +1 -1
- package/dist/rules.d.ts +32 -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/llms.txt +19 -0
- package/package.json +4 -3
package/EXPORTS.md
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
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. |
|
|
@@ -22,8 +23,10 @@
|
|
|
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,31 @@
|
|
|
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
|
+
| `millis` | const | `n` milliseconds, for a duration under a second. |
|
|
46
|
+
| `millisOf` | const | `n` as `Millis`, or null unless it is a safe integer at least 0. |
|
|
47
|
+
| `minusMillis` | const | A reading less a duration, never below 0. |
|
|
48
|
+
| `minutes` | const | `n` minutes, in seconds. |
|
|
40
49
|
| `nodeHead` | const | The schema.org context and a node's type: its first two members, as JSON text. |
|
|
41
50
|
| `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
51
|
| `paginateOffset` | function | Returns a copy of filters with offset adjusted for the given page. |
|
|
43
52
|
| `pushTrackingData` | function | Push ecommerce tracking data to window.dataLayer using the GA4 clear-then-push pattern. |
|
|
53
|
+
| `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
54
|
| `resolveStock` | function | Pure stock resolution -- usable in hooks AND server components. |
|
|
45
55
|
| `roundHalfAway` | function | Round half away from zero to `decimals` places. |
|
|
46
56
|
| `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. |
|
|
57
|
+
| `seconds` | const | `n` seconds. |
|
|
58
|
+
| `secondsOf` | const | `n` as `Seconds`, or null unless it is a safe integer at least 0. |
|
|
47
59
|
| `serializeCategoryFilters` | function | Converts TItemsFilters to the SDK params shape for category item endpoints. |
|
|
48
60
|
| `serializeSearchParams` | function | Converts TItemsFilters to the SDK params shape for search endpoints. |
|
|
49
61
|
| `serializeTransforms` | function | Serializes transform options into the CDN path segment. Example: `{ width: 400, format: "webp" }` → `"w_400,f_webp"` |
|
|
50
62
|
| `ShippingAddressSchema` | const | Valibot schema for shipping address validation. Enforces no PO Box, requires street number, formats phone number. |
|
|
63
|
+
| `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. |
|
|
64
|
+
| `tierStaleTime` | function | A tier's staleTime: STATIC 1 h, SEMI_STATIC 10 min, DYNAMIC 5 min, CART 2 min, REALTIME 0. |
|
|
65
|
+
| `toMillis` | const | Seconds as milliseconds, exactly. |
|
|
51
66
|
| `trackAddToCart` | function | Track add_to_cart event to Google Analytics dataLayer. |
|
|
52
67
|
| `trackViewItem` | function | Track view_item event to Google Analytics dataLayer. |
|
|
53
68
|
| `transformShipToAddress` | function | Normalizes a raw ship-to address object (camelCase or snake_case, physical or mailing) into a consistent ShipToAddress shape. |
|
|
@@ -57,10 +72,11 @@
|
|
|
57
72
|
| `US_STATES_FULL` | const | All US states and territories — full data from states-us. |
|
|
58
73
|
| `US_TERRITORIES` | const | US territories (PR, GU, VI, AS, MP). |
|
|
59
74
|
| `VALIDATION_PATTERNS` | const | Common regex patterns used for form validation across augur-hosted sites. |
|
|
75
|
+
| `wholeSeconds` | const | An outside count of seconds, rounded down; 0 when it is then no safe integer at least 0. |
|
|
60
76
|
|
|
61
77
|
### Types
|
|
62
78
|
|
|
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`
|
|
79
|
+
`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
80
|
|
|
65
81
|
## `@simpleapps-com/augur-utils/web`
|
|
66
82
|
|
package/README.md
CHANGED
|
@@ -26,6 +26,12 @@ TypeScript in `src/`, built to `dist/` (ESM and CJS) by tsup. The decisions are
|
|
|
26
26
|
(`src/rules.ts`, `src/price-outcome.ts`, `src/image-rules.ts`, `src/json-ld-rules.ts`; model
|
|
27
27
|
`models/AugurUtils.dfy`, links `models/links/augur-utils-*.dfy`); the rest is tested at 100%.
|
|
28
28
|
|
|
29
|
+
`CACHE_CONFIG`'s tiers are server-safe (#94): each `gcTime` is a getter through
|
|
30
|
+
`resolveGcTime` (`src/runtime.ts`, the proved `gcTimeFor` in `src/rules.ts`), so it is
|
|
31
|
+
`Infinity` on the server and the tier's value in the browser, decided each time a tier is read.
|
|
32
|
+
`isServerRuntime` and `resolveGcTime` live here, the lowest package that needs them; augur-core
|
|
33
|
+
re-exports `resolveGcTime`.
|
|
34
|
+
|
|
29
35
|
```bash
|
|
30
36
|
pnpm -C repo/packages/augur-utils test
|
|
31
37
|
pnpm -C repo/packages/augur-utils proofs
|
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
|
+
* 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;;;;;;;;;GASG;AAEH,4DAA4D;AAE5D,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAA;CAAE,CAAC;AAE5D,2FAA2F;AAE3F,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAA;CAAE,CAAC;AAE1D,mBAAmB;AACnB,eAAO,MAAM,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAA0B,CAAC;AAChE,+BAA+B;AAC/B,eAAO,MAAM,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAA0B,CAAC;AAChE,6BAA6B;AAC7B,eAAO,MAAM,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAwB,CAAC;AAC5D,4BAA4B;AAC5B,eAAO,MAAM,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAuB,CAAC;AAC1D,uDAAuD;AACvD,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAwB,CAAC;AAC7D,wCAAwC;AACxC,eAAO,MAAM,QAAQ,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,MAA0B,CAAC;AAClE,kFAAkF;AAClF,eAAO,MAAM,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAA2B,CAAC;AAC9E,gDAAgD;AAChD,eAAO,MAAM,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,MAA6B,CAAC;AAClF,mDAAmD;AACnD,eAAO,MAAM,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAA+B,CAAC;AAC1E,wEAAwE;AACxE,eAAO,MAAM,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAAO,GAAG,IAAyB,CAAC;AAC3E,+FAA+F;AAC/F,eAAO,MAAM,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,OAA+B,CAAC;AAC1E,uEAAuE;AACvE,eAAO,MAAM,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,GAAG,IAAwB,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -7,46 +7,43 @@ function hasPriceBreaks(libraryPriceData) {
|
|
|
7
7
|
return libraryPriceData !== null && Array.isArray(libraryPriceData.breaks);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
// src/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
currency,
|
|
48
|
-
minimumFractionDigits: 2
|
|
49
|
-
}).format(price);
|
|
10
|
+
// ../foundation/src/duration.ts
|
|
11
|
+
function seconds(n) {
|
|
12
|
+
return n;
|
|
13
|
+
}
|
|
14
|
+
function minutes(n) {
|
|
15
|
+
return n * 60;
|
|
16
|
+
}
|
|
17
|
+
function hours(n) {
|
|
18
|
+
return n * 3600;
|
|
19
|
+
}
|
|
20
|
+
function days(n) {
|
|
21
|
+
return n * 86400;
|
|
22
|
+
}
|
|
23
|
+
function millis(n) {
|
|
24
|
+
return n;
|
|
25
|
+
}
|
|
26
|
+
function toMillis(d) {
|
|
27
|
+
return d * 1e3;
|
|
28
|
+
}
|
|
29
|
+
function floorSeconds(m) {
|
|
30
|
+
return Math.floor(m / 1e3);
|
|
31
|
+
}
|
|
32
|
+
function addMillis(a, b) {
|
|
33
|
+
return a + b;
|
|
34
|
+
}
|
|
35
|
+
function minusMillis(a, b) {
|
|
36
|
+
return a >= b ? a - b : millis(0);
|
|
37
|
+
}
|
|
38
|
+
function secondsOf(n) {
|
|
39
|
+
return Math.floor(n) === n && n >= 0 && n <= 9007199254740991 ? n : null;
|
|
40
|
+
}
|
|
41
|
+
function wholeSeconds(n) {
|
|
42
|
+
const whole = secondsOf(Math.floor(n));
|
|
43
|
+
return whole === null ? seconds(0) : whole;
|
|
44
|
+
}
|
|
45
|
+
function millisOf(n) {
|
|
46
|
+
return Math.floor(n) === n && n >= 0 && n <= 9007199254740991 ? n : null;
|
|
50
47
|
}
|
|
51
48
|
|
|
52
49
|
// src/rules.ts
|
|
@@ -77,14 +74,14 @@ function pageOffset(page, limit) {
|
|
|
77
74
|
function unwrapMessage(error) {
|
|
78
75
|
return error !== "" ? error : "Action failed";
|
|
79
76
|
}
|
|
80
|
-
function shippingLeadOf(
|
|
81
|
-
if (
|
|
82
|
-
if (
|
|
83
|
-
if (
|
|
84
|
-
if (
|
|
85
|
-
if (
|
|
86
|
-
if (
|
|
87
|
-
if (
|
|
77
|
+
function shippingLeadOf(days3) {
|
|
78
|
+
if (days3 === "1-2") return { from: 1, to: 4 };
|
|
79
|
+
if (days3 === "2") return { from: 4, to: 0 };
|
|
80
|
+
if (days3 === "2-3") return { from: 2, to: 5 };
|
|
81
|
+
if (days3 === "3") return { from: 5, to: 0 };
|
|
82
|
+
if (days3 === "3-4") return { from: 3, to: 6 };
|
|
83
|
+
if (days3 === "4") return { from: 6, to: 0 };
|
|
84
|
+
if (days3 === "5") return { from: 7, to: 0 };
|
|
88
85
|
return null;
|
|
89
86
|
}
|
|
90
87
|
function isBusinessDayName(dayName) {
|
|
@@ -101,6 +98,75 @@ function takerOf(taker) {
|
|
|
101
98
|
function addressDifferentOf(line1Same, citySame, stateSame, zipSame) {
|
|
102
99
|
return !line1Same || !citySame || !stateSame || !zipSame;
|
|
103
100
|
}
|
|
101
|
+
function gcTimeFor(isServer, clientGcTime) {
|
|
102
|
+
return isServer ? null : clientGcTime;
|
|
103
|
+
}
|
|
104
|
+
function tierStaleTime(t) {
|
|
105
|
+
if (t === "STATIC") return toMillis(hours(1));
|
|
106
|
+
if (t === "SEMI_STATIC") return toMillis(minutes(10));
|
|
107
|
+
if (t === "DYNAMIC") return toMillis(minutes(5));
|
|
108
|
+
if (t === "CART") return toMillis(minutes(2));
|
|
109
|
+
return millis(0);
|
|
110
|
+
}
|
|
111
|
+
function tierBrowserGcTime(t) {
|
|
112
|
+
if (t === "STATIC") return toMillis(hours(24));
|
|
113
|
+
if (t === "SEMI_STATIC") return toMillis(hours(4));
|
|
114
|
+
if (t === "DYNAMIC") return toMillis(minutes(30));
|
|
115
|
+
if (t === "CART") return toMillis(minutes(30));
|
|
116
|
+
return toMillis(minutes(5));
|
|
117
|
+
}
|
|
118
|
+
function serverRuntimeOf(hasWindow, hasDeno) {
|
|
119
|
+
return !hasWindow || hasDeno;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/runtime.ts
|
|
123
|
+
function isServerRuntime() {
|
|
124
|
+
const hasWindow = typeof globalThis.window !== "undefined";
|
|
125
|
+
return serverRuntimeOf(hasWindow, "Deno" in globalThis);
|
|
126
|
+
}
|
|
127
|
+
function resolveGcTime(clientGcTime) {
|
|
128
|
+
return _nullishCoalesce(gcTimeFor(isServerRuntime(), clientGcTime), () => ( Infinity));
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// src/cache-config.ts
|
|
132
|
+
function tier(name) {
|
|
133
|
+
return {
|
|
134
|
+
staleTime: tierStaleTime(name),
|
|
135
|
+
get gcTime() {
|
|
136
|
+
return resolveGcTime(tierBrowserGcTime(name));
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
var CACHE_CONFIG = {
|
|
141
|
+
STATIC: tier("STATIC"),
|
|
142
|
+
SEMI_STATIC: tier("SEMI_STATIC"),
|
|
143
|
+
DYNAMIC: tier("DYNAMIC"),
|
|
144
|
+
CART: tier("CART"),
|
|
145
|
+
REALTIME: tier("REALTIME")
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// src/duration.ts
|
|
149
|
+
var seconds2 = seconds;
|
|
150
|
+
var minutes2 = minutes;
|
|
151
|
+
var hours2 = hours;
|
|
152
|
+
var days2 = days;
|
|
153
|
+
var millis2 = millis;
|
|
154
|
+
var toMillis2 = toMillis;
|
|
155
|
+
var addMillis2 = addMillis;
|
|
156
|
+
var minusMillis2 = minusMillis;
|
|
157
|
+
var floorSeconds2 = floorSeconds;
|
|
158
|
+
var secondsOf2 = secondsOf;
|
|
159
|
+
var wholeSeconds2 = wholeSeconds;
|
|
160
|
+
var millisOf2 = millisOf;
|
|
161
|
+
|
|
162
|
+
// src/format-price.ts
|
|
163
|
+
function formatPrice(price, locale = "en-US", currency = "USD") {
|
|
164
|
+
return new Intl.NumberFormat(locale, {
|
|
165
|
+
style: "currency",
|
|
166
|
+
currency,
|
|
167
|
+
minimumFractionDigits: 2
|
|
168
|
+
}).format(price);
|
|
169
|
+
}
|
|
104
170
|
|
|
105
171
|
// src/address-comparison.ts
|
|
106
172
|
function isAddressDifferent(userAddress, smartyAddress) {
|
|
@@ -443,7 +509,7 @@ function jsonArray(items) {
|
|
|
443
509
|
return "[" + joinFrom(items, ",", 0) + "]";
|
|
444
510
|
}
|
|
445
511
|
|
|
446
|
-
// ../
|
|
512
|
+
// ../foundation/src/decimal.ts
|
|
447
513
|
function decimal(n) {
|
|
448
514
|
const last = "0123456789".slice(n % 10, n % 10 + 1);
|
|
449
515
|
return n < 10 ? last : decimal(Math.floor(n / 10)) + last;
|
|
@@ -946,8 +1012,8 @@ function getBusinessDay(businessDaysFromNow) {
|
|
|
946
1012
|
}
|
|
947
1013
|
return businessDays[businessDays.length - 1] || "";
|
|
948
1014
|
}
|
|
949
|
-
function getShippingLeadDate(
|
|
950
|
-
const config = shippingLeadOf(
|
|
1015
|
+
function getShippingLeadDate(days3) {
|
|
1016
|
+
const config = shippingLeadOf(days3);
|
|
951
1017
|
if (!config) return "";
|
|
952
1018
|
const fromDate = getBusinessDay(config.from);
|
|
953
1019
|
if (config.to) {
|
|
@@ -1135,5 +1201,21 @@ function pushTrackingData(data) {
|
|
|
1135
1201
|
|
|
1136
1202
|
|
|
1137
1203
|
|
|
1138
|
-
|
|
1204
|
+
|
|
1205
|
+
|
|
1206
|
+
|
|
1207
|
+
|
|
1208
|
+
|
|
1209
|
+
|
|
1210
|
+
|
|
1211
|
+
|
|
1212
|
+
|
|
1213
|
+
|
|
1214
|
+
|
|
1215
|
+
|
|
1216
|
+
|
|
1217
|
+
|
|
1218
|
+
|
|
1219
|
+
|
|
1220
|
+
exports.BLUR_DATA_URL = BLUR_DATA_URL; exports.BillingAddressInvoiceSchema = BillingAddressInvoiceSchema; exports.BillingAddressSchema = BillingAddressSchema; exports.CACHE_CONFIG = CACHE_CONFIG; exports.CONTIGUOUS_STATES = CONTIGUOUS_STATES; exports.ShippingAddressSchema = ShippingAddressSchema; exports.US_STATES = US_STATES; exports.US_STATES_FULL = US_STATES_FULL; exports.US_TERRITORIES = US_TERRITORIES; exports.VALIDATION_PATTERNS = VALIDATION_PATTERNS; exports.addMillis = addMillis2; exports.breadcrumbLd = breadcrumbLd2; exports.buildCheckoutPayload = buildCheckoutPayload; exports.buildImageLoader = buildImageLoader; exports.buildTrackingData = buildTrackingData; exports.categorySortBy = categorySortBy; exports.cleanMoney = cleanMoney; exports.cn = _chunk5UMFBGVAcjs.cn; exports.createImageConfig = createImageConfig; exports.days = days2; exports.derivePrice = derivePrice; exports.faqLd = faqLd2; exports.floorSeconds = floorSeconds2; exports.formatPrice = formatPrice; exports.generateBreadcrumbJsonLd = generateBreadcrumbJsonLd; exports.generateProductJsonLd = generateProductJsonLd; exports.getBusinessDay = getBusinessDay; exports.getDefaultImageUrl = getDefaultImageUrl; exports.getImageSrcSet = getImageSrcSet; exports.getImageUrl = getImageUrl; exports.getPaymentStatus = getPaymentStatus; exports.getSchemaAvailability = getSchemaAvailability; exports.getShippingLeadDate = getShippingLeadDate; exports.hasPriceBreaks = hasPriceBreaks; exports.hours = hours2; exports.idRef = idRef2; exports.isAddressDifferent = isAddressDifferent; exports.isServerRuntime = isServerRuntime; exports.millis = millis2; exports.millisOf = millisOf2; exports.minusMillis = minusMillis2; exports.minutes = minutes2; exports.nodeHead = nodeHead2; exports.normalizePath = normalizePath; exports.paginateOffset = paginateOffset; exports.pushTrackingData = pushTrackingData; exports.resolveGcTime = resolveGcTime; exports.resolveStock = resolveStock; exports.roundHalfAway = roundHalfAway; exports.sanitizeHtmlImages = sanitizeHtmlImages; exports.seconds = seconds2; exports.secondsOf = secondsOf2; exports.serializeCategoryFilters = serializeCategoryFilters; exports.serializeSearchParams = serializeSearchParams; exports.serializeTransforms = serializeTransforms; exports.tierBrowserGcTime = tierBrowserGcTime; exports.tierStaleTime = tierStaleTime; exports.toMillis = toMillis2; exports.trackAddToCart = trackAddToCart; exports.trackViewItem = trackViewItem; exports.transformShipToAddress = transformShipToAddress; exports.unwrap = unwrap; exports.unwrapOr = unwrapOr; exports.wholeSeconds = wholeSeconds2;
|
|
1139
1221
|
//# sourceMappingURL=index.cjs.map
|