@simpleapps-com/augur-utils 2026.11.1 → 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.
- package/EXPORTS.md +5 -1
- package/dist/index.cjs +198 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +197 -22
- package/dist/index.js.map +1 -1
- package/dist/json-ld.d.ts +13 -0
- package/dist/json-ld.d.ts.map +1 -1
- package/llms.txt +5 -0
- package/package.json +1 -1
package/EXPORTS.md
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
| `BillingAddressInvoiceSchema` | const | Valibot schema for billing address with required PO number (invoice payments). |
|
|
13
13
|
| `BillingAddressSchema` | const | Valibot schema for billing address validation. Less strict than shipping: allows PO Box, no email/phone required. |
|
|
14
14
|
| `BLUR_DATA_URL` | const | 1x1 transparent PNG for Next.js `<Image blurDataURL={...}>` placeholders. |
|
|
15
|
+
| `breadcrumbLd` | const | A breadcrumb trail's BreadcrumbList as text. |
|
|
15
16
|
| `buildCheckoutPayload` | function | Builds the oe_hdr + oe_line payload required by the commerce checkout API from cart data. |
|
|
16
17
|
| `buildImageLoader` | function | Returns a loader function compatible with Next.js `<Image loader={...}>`. |
|
|
17
18
|
| `buildTrackingData` | function | Build a GA4 begin_checkout ecommerce payload from cart lines, item details, and prices. |
|
|
@@ -22,6 +23,7 @@
|
|
|
22
23
|
| `CONTIGUOUS_STATES` | const | Lower 48 contiguous states. |
|
|
23
24
|
| `createImageConfig` | function | Creates a frozen ImageConfig object. |
|
|
24
25
|
| `derivePrice` | function | Pure price derivation — usable in hooks AND server components. |
|
|
26
|
+
| `faqLd` | const | A FAQ page's FAQPage markup as text: one Question per entry. |
|
|
25
27
|
| `formatPrice` | function | Locale-aware currency formatting. Defaults to USD -- consumers can override locale and currency. |
|
|
26
28
|
| `generateBreadcrumbJsonLd` | function | Generates a Schema.org BreadcrumbList JSON-LD object from an array of breadcrumb items. |
|
|
27
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. |
|
|
@@ -33,7 +35,9 @@
|
|
|
33
35
|
| `getSchemaAvailability` | function | Maps resolved stock to a Schema.org availability URL. |
|
|
34
36
|
| `getShippingLeadDate` | function | Get shipping lead date estimate based on days string (the table is `shippingLeadOf`). |
|
|
35
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. |
|
|
36
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. |
|
|
37
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. |
|
|
38
42
|
| `paginateOffset` | function | Returns a copy of filters with offset adjusted for the given page. |
|
|
39
43
|
| `pushTrackingData` | function | Push ecommerce tracking data to window.dataLayer using the GA4 clear-then-push pattern. |
|
|
@@ -56,7 +60,7 @@
|
|
|
56
60
|
|
|
57
61
|
### Types
|
|
58
62
|
|
|
59
|
-
`AddToCartEventParams`, `BillingAddress`, `BreadcrumbJsonLdItem`, `BuildTrackingDataInput`, `CacheTier`, `CategoryFilterOptions`, `CheckoutInput`, `CheckoutPayment`, `CustomerDocument`, `DerivedPrice`, `DerivePriceInput`, `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
|
+
`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`
|
|
60
64
|
|
|
61
65
|
## `@simpleapps-com/augur-utils/web`
|
|
62
66
|
|
package/dist/index.cjs
CHANGED
|
@@ -310,6 +310,195 @@ var SCHEMA_URLS = {
|
|
|
310
310
|
BackOrder: "https://schema.org/BackOrder"
|
|
311
311
|
};
|
|
312
312
|
|
|
313
|
+
// ../utils/src/strings.ts
|
|
314
|
+
function codeAt(s, i) {
|
|
315
|
+
return i >= 0 && i < s.length ? s.charCodeAt(i) : -1;
|
|
316
|
+
}
|
|
317
|
+
function indexOfCode(s, code, from) {
|
|
318
|
+
const c = codeAt(s, from);
|
|
319
|
+
if (c === code) return from;
|
|
320
|
+
if (c === -1) return -1;
|
|
321
|
+
return indexOfCode(s, code, from + 1);
|
|
322
|
+
}
|
|
323
|
+
function startsWithAt(s, x, pos) {
|
|
324
|
+
const at = Math.min(pos, s.length);
|
|
325
|
+
return s.slice(at, Math.min(at + x.length, s.length)) === x;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// ../utils/src/lists.ts
|
|
329
|
+
function joinFrom(xs, sep, i) {
|
|
330
|
+
if (i >= xs.length) return "";
|
|
331
|
+
return joinRange(xs, sep, i, xs.length);
|
|
332
|
+
}
|
|
333
|
+
function joinRange(xs, sep, lo, hi) {
|
|
334
|
+
if (hi - lo === 1) return xs[lo];
|
|
335
|
+
const mid = lo + Math.floor((hi - lo) / 2);
|
|
336
|
+
return joinRange(xs, sep, lo, mid) + sep + joinRange(xs, sep, mid, hi);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// ../utils/src/replace.ts
|
|
340
|
+
function codeIndex(codes, c, i) {
|
|
341
|
+
if (i === codes.length) return -1;
|
|
342
|
+
return codes[i] === c ? i : codeIndex(codes, c, i + 1);
|
|
343
|
+
}
|
|
344
|
+
function substitute(s, codes, texts) {
|
|
345
|
+
let out = "";
|
|
346
|
+
for (let i = 0; i !== s.length; i++) {
|
|
347
|
+
const k = codeIndex(codes, s.charCodeAt(i), 0);
|
|
348
|
+
out = k >= 0 && k < texts.length ? out + texts[k] : out + s.slice(i, i + 1);
|
|
349
|
+
}
|
|
350
|
+
return out;
|
|
351
|
+
}
|
|
352
|
+
function jsonCodes() {
|
|
353
|
+
return [
|
|
354
|
+
34,
|
|
355
|
+
92,
|
|
356
|
+
8,
|
|
357
|
+
9,
|
|
358
|
+
10,
|
|
359
|
+
12,
|
|
360
|
+
13,
|
|
361
|
+
0,
|
|
362
|
+
1,
|
|
363
|
+
2,
|
|
364
|
+
3,
|
|
365
|
+
4,
|
|
366
|
+
5,
|
|
367
|
+
6,
|
|
368
|
+
7,
|
|
369
|
+
11,
|
|
370
|
+
14,
|
|
371
|
+
15,
|
|
372
|
+
16,
|
|
373
|
+
17,
|
|
374
|
+
18,
|
|
375
|
+
19,
|
|
376
|
+
20,
|
|
377
|
+
21,
|
|
378
|
+
22,
|
|
379
|
+
23,
|
|
380
|
+
24,
|
|
381
|
+
25,
|
|
382
|
+
26,
|
|
383
|
+
27,
|
|
384
|
+
28,
|
|
385
|
+
29,
|
|
386
|
+
30,
|
|
387
|
+
31
|
|
388
|
+
];
|
|
389
|
+
}
|
|
390
|
+
function jsonTexts() {
|
|
391
|
+
return [
|
|
392
|
+
'\\"',
|
|
393
|
+
"\\\\",
|
|
394
|
+
"\\b",
|
|
395
|
+
"\\t",
|
|
396
|
+
"\\n",
|
|
397
|
+
"\\f",
|
|
398
|
+
"\\r",
|
|
399
|
+
"\\u0000",
|
|
400
|
+
"\\u0001",
|
|
401
|
+
"\\u0002",
|
|
402
|
+
"\\u0003",
|
|
403
|
+
"\\u0004",
|
|
404
|
+
"\\u0005",
|
|
405
|
+
"\\u0006",
|
|
406
|
+
"\\u0007",
|
|
407
|
+
"\\u000b",
|
|
408
|
+
"\\u000e",
|
|
409
|
+
"\\u000f",
|
|
410
|
+
"\\u0010",
|
|
411
|
+
"\\u0011",
|
|
412
|
+
"\\u0012",
|
|
413
|
+
"\\u0013",
|
|
414
|
+
"\\u0014",
|
|
415
|
+
"\\u0015",
|
|
416
|
+
"\\u0016",
|
|
417
|
+
"\\u0017",
|
|
418
|
+
"\\u0018",
|
|
419
|
+
"\\u0019",
|
|
420
|
+
"\\u001a",
|
|
421
|
+
"\\u001b",
|
|
422
|
+
"\\u001c",
|
|
423
|
+
"\\u001d",
|
|
424
|
+
"\\u001e",
|
|
425
|
+
"\\u001f"
|
|
426
|
+
];
|
|
427
|
+
}
|
|
428
|
+
function jsonString(s) {
|
|
429
|
+
return '"' + substitute(s, jsonCodes(), jsonTexts()) + '"';
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// ../utils/src/json.ts
|
|
433
|
+
function jsonPair(key, value) {
|
|
434
|
+
return jsonString(key) + ":" + value;
|
|
435
|
+
}
|
|
436
|
+
function jsonTextPair(key, value) {
|
|
437
|
+
return jsonString(key) + ":" + jsonString(value);
|
|
438
|
+
}
|
|
439
|
+
function jsonObject(pairs) {
|
|
440
|
+
return "{" + joinFrom(pairs, ",", 0) + "}";
|
|
441
|
+
}
|
|
442
|
+
function jsonArray(items) {
|
|
443
|
+
return "[" + joinFrom(items, ",", 0) + "]";
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
// ../utils/src/decimal.ts
|
|
447
|
+
function decimal(n) {
|
|
448
|
+
const last = "0123456789".slice(n % 10, n % 10 + 1);
|
|
449
|
+
return n < 10 ? last : decimal(Math.floor(n / 10)) + last;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
// ../utils/src/json-ld-items.ts
|
|
453
|
+
function nodeHead(type) {
|
|
454
|
+
return [jsonTextPair("@context", "https://schema.org"), jsonTextPair("@type", type)];
|
|
455
|
+
}
|
|
456
|
+
function crumbItemsFrom(crumbs, i) {
|
|
457
|
+
if (i >= crumbs.length) return [];
|
|
458
|
+
const crumb = crumbs[i];
|
|
459
|
+
return [
|
|
460
|
+
jsonObject([
|
|
461
|
+
jsonTextPair("@type", "ListItem"),
|
|
462
|
+
jsonPair("position", decimal(i + 1)),
|
|
463
|
+
jsonTextPair("name", crumb.name),
|
|
464
|
+
jsonTextPair("item", crumb.url)
|
|
465
|
+
]),
|
|
466
|
+
...crumbItemsFrom(crumbs, i + 1)
|
|
467
|
+
];
|
|
468
|
+
}
|
|
469
|
+
function faqItemsFrom(faqs, i) {
|
|
470
|
+
if (i >= faqs.length) return [];
|
|
471
|
+
const faq = faqs[i];
|
|
472
|
+
return [
|
|
473
|
+
jsonObject([
|
|
474
|
+
jsonTextPair("@type", "Question"),
|
|
475
|
+
jsonTextPair("name", faq.question),
|
|
476
|
+
jsonPair(
|
|
477
|
+
"acceptedAnswer",
|
|
478
|
+
jsonObject([jsonTextPair("@type", "Answer"), jsonTextPair("text", faq.answer)])
|
|
479
|
+
)
|
|
480
|
+
]),
|
|
481
|
+
...faqItemsFrom(faqs, i + 1)
|
|
482
|
+
];
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// ../utils/src/json-ld.ts
|
|
486
|
+
function idRef(id) {
|
|
487
|
+
return jsonObject([jsonTextPair("@id", id)]);
|
|
488
|
+
}
|
|
489
|
+
function breadcrumbLd(crumbs) {
|
|
490
|
+
return jsonObject([
|
|
491
|
+
...nodeHead("BreadcrumbList"),
|
|
492
|
+
jsonPair("itemListElement", jsonArray(crumbItemsFrom(crumbs, 0)))
|
|
493
|
+
]);
|
|
494
|
+
}
|
|
495
|
+
function faqLd(faqs) {
|
|
496
|
+
return jsonObject([
|
|
497
|
+
...nodeHead("FAQPage"),
|
|
498
|
+
jsonPair("mainEntity", jsonArray(faqItemsFrom(faqs, 0)))
|
|
499
|
+
]);
|
|
500
|
+
}
|
|
501
|
+
|
|
313
502
|
// src/json-ld-rules.ts
|
|
314
503
|
function breadcrumbPosition(i) {
|
|
315
504
|
return i + 1;
|
|
@@ -360,6 +549,10 @@ function generateBreadcrumbJsonLd(items) {
|
|
|
360
549
|
}))
|
|
361
550
|
};
|
|
362
551
|
}
|
|
552
|
+
var breadcrumbLd2 = breadcrumbLd;
|
|
553
|
+
var faqLd2 = faqLd;
|
|
554
|
+
var nodeHead2 = nodeHead;
|
|
555
|
+
var idRef2 = idRef;
|
|
363
556
|
function getGtinField(upcOrEan) {
|
|
364
557
|
return gtinFieldOf(_nullishCoalesce(_optionalChain([upcOrEan, 'optionalAccess', _6 => _6.toUpperCase, 'call', _7 => _7()]), () => ( "")));
|
|
365
558
|
}
|
|
@@ -474,28 +667,6 @@ function unwrapOr(result) {
|
|
|
474
667
|
return result.ok ? _nullishCoalesce(result.data, () => ( null)) : null;
|
|
475
668
|
}
|
|
476
669
|
|
|
477
|
-
// ../utils/src/strings.ts
|
|
478
|
-
function codeAt(s, i) {
|
|
479
|
-
return i >= 0 && i < s.length ? s.charCodeAt(i) : -1;
|
|
480
|
-
}
|
|
481
|
-
function indexOfCode(s, code, from) {
|
|
482
|
-
const c = codeAt(s, from);
|
|
483
|
-
if (c === code) return from;
|
|
484
|
-
if (c === -1) return -1;
|
|
485
|
-
return indexOfCode(s, code, from + 1);
|
|
486
|
-
}
|
|
487
|
-
function startsWithAt(s, x, pos) {
|
|
488
|
-
const at = Math.min(pos, s.length);
|
|
489
|
-
return s.slice(at, Math.min(at + x.length, s.length)) === x;
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
// ../utils/src/lists.ts
|
|
493
|
-
function joinFrom(xs, sep, i) {
|
|
494
|
-
if (i >= xs.length) return "";
|
|
495
|
-
if (i === xs.length - 1) return xs[i];
|
|
496
|
-
return xs[i] + sep + joinFrom(xs, sep, i + 1);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
670
|
// src/image-rules.ts
|
|
500
671
|
function transformKeyOf(field) {
|
|
501
672
|
if (field === "width") return "w";
|
|
@@ -960,5 +1131,9 @@ function pushTrackingData(data) {
|
|
|
960
1131
|
|
|
961
1132
|
|
|
962
1133
|
|
|
963
|
-
|
|
1134
|
+
|
|
1135
|
+
|
|
1136
|
+
|
|
1137
|
+
|
|
1138
|
+
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.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.derivePrice = derivePrice; exports.faqLd = faqLd2; 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.idRef = idRef2; exports.isAddressDifferent = isAddressDifferent; exports.nodeHead = nodeHead2; exports.normalizePath = normalizePath; exports.paginateOffset = paginateOffset; exports.pushTrackingData = pushTrackingData; exports.resolveStock = resolveStock; exports.roundHalfAway = roundHalfAway; exports.sanitizeHtmlImages = sanitizeHtmlImages; exports.serializeCategoryFilters = serializeCategoryFilters; exports.serializeSearchParams = serializeSearchParams; exports.serializeTransforms = serializeTransforms; exports.trackAddToCart = trackAddToCart; exports.trackViewItem = trackViewItem; exports.transformShipToAddress = transformShipToAddress; exports.unwrap = unwrap; exports.unwrapOr = unwrapOr;
|
|
964
1139
|
//# sourceMappingURL=index.cjs.map
|