@simpleapps-com/augur-utils 2.0.4 → 2.0.7
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/dist/index.cjs +18 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -10
- package/dist/index.d.ts +46 -10
- package/dist/index.js +18 -18
- package/dist/index.js.map +1 -1
- package/package.json +4 -5
package/dist/index.cjs
CHANGED
|
@@ -59,7 +59,6 @@ function getPaymentStatus(invoice) {
|
|
|
59
59
|
|
|
60
60
|
// src/transform-ship-to-address.ts
|
|
61
61
|
function str(value) {
|
|
62
|
-
if (value == null) return "";
|
|
63
62
|
return String(value).trim();
|
|
64
63
|
}
|
|
65
64
|
function pick(raw, keys) {
|
|
@@ -85,11 +84,11 @@ var MAIL_FIELDS = {
|
|
|
85
84
|
country: ["mailCountry", "mail_country", "country"]
|
|
86
85
|
};
|
|
87
86
|
function transformShipToAddress(raw) {
|
|
88
|
-
const isPhys = raw
|
|
87
|
+
const isPhys = raw["physAddress1"] != null || raw["physCity"] != null || raw["physState"] != null;
|
|
89
88
|
const f = isPhys ? PHYS_FIELDS : MAIL_FIELDS;
|
|
90
89
|
const address = {
|
|
91
|
-
shipToId: _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(raw
|
|
92
|
-
name: str(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(raw
|
|
90
|
+
shipToId: _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(raw["shipToId"], () => ( raw["ship_to_id"])), () => ( raw["id"])), () => ( "")),
|
|
91
|
+
name: str(_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(raw["shipToName"], () => ( raw["ship_to_name"])), () => ( raw["name"])), () => ( ""))),
|
|
93
92
|
address1: pick(raw, [...f.address1]),
|
|
94
93
|
city: pick(raw, [...f.city]),
|
|
95
94
|
state: pick(raw, [...f.state]),
|
|
@@ -114,8 +113,7 @@ function buildCheckoutPayload(input) {
|
|
|
114
113
|
};
|
|
115
114
|
if (input.poNumber != null) oe_hdr.customer_po_no = input.poNumber;
|
|
116
115
|
if (input.shipToId != null) oe_hdr.ship_to_id = input.shipToId;
|
|
117
|
-
if (input.deliveryInstructions != null)
|
|
118
|
-
oe_hdr.delivery_instructions = input.deliveryInstructions;
|
|
116
|
+
if (input.deliveryInstructions != null) oe_hdr.delivery_instructions = input.deliveryInstructions;
|
|
119
117
|
const oe_line = input.cartLines.map((line) => {
|
|
120
118
|
const oeLine = {
|
|
121
119
|
item_id: line.itemId,
|
|
@@ -145,23 +143,14 @@ function derivePrice(input) {
|
|
|
145
143
|
|
|
146
144
|
// src/resolve-stock.ts
|
|
147
145
|
function resolveStock(input) {
|
|
148
|
-
const {
|
|
149
|
-
stock,
|
|
150
|
-
companyKey,
|
|
151
|
-
round = false,
|
|
152
|
-
lowStockThreshold = 0,
|
|
153
|
-
showQuantity = false
|
|
154
|
-
} = input;
|
|
146
|
+
const { stock, companyKey, round = false, lowStockThreshold = 0, showQuantity = false } = input;
|
|
155
147
|
if (!stock) return null;
|
|
156
148
|
const { companySummary } = stock;
|
|
157
149
|
let qty;
|
|
158
150
|
if (companyKey && companyKey in companySummary) {
|
|
159
151
|
qty = _nullishCoalesce(companySummary[companyKey], () => ( 0));
|
|
160
152
|
} else {
|
|
161
|
-
qty = Object.values(companySummary).reduce(
|
|
162
|
-
(sum, val) => sum + val,
|
|
163
|
-
0
|
|
164
|
-
);
|
|
153
|
+
qty = Object.values(companySummary).reduce((sum, val) => sum + val, 0);
|
|
165
154
|
}
|
|
166
155
|
if (round) {
|
|
167
156
|
qty = Math.round(qty);
|
|
@@ -201,6 +190,15 @@ function generateBreadcrumbJsonLd(items) {
|
|
|
201
190
|
};
|
|
202
191
|
}
|
|
203
192
|
|
|
193
|
+
// src/result.ts
|
|
194
|
+
function unwrap(result) {
|
|
195
|
+
if (!result.ok) throw new Error(result.error || "Action failed");
|
|
196
|
+
return result.data;
|
|
197
|
+
}
|
|
198
|
+
function unwrapOr(result) {
|
|
199
|
+
return result.ok ? _nullishCoalesce(result.data, () => ( null)) : null;
|
|
200
|
+
}
|
|
201
|
+
|
|
204
202
|
// src/image.ts
|
|
205
203
|
var BLUR_DATA_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mN88P/BfwYABQoBfqVKzQAAAABJRU5ErkJggg==";
|
|
206
204
|
var CDN_BASE = "https://agr.media";
|
|
@@ -316,5 +314,7 @@ function sanitizeHtmlImages(config, html, transforms) {
|
|
|
316
314
|
|
|
317
315
|
|
|
318
316
|
|
|
319
|
-
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
exports.BLUR_DATA_URL = BLUR_DATA_URL; exports.CACHE_CONFIG = CACHE_CONFIG; exports.buildCheckoutPayload = buildCheckoutPayload; exports.buildImageLoader = buildImageLoader; exports.cn = _chunk5UMFBGVAcjs.cn; exports.createImageConfig = createImageConfig; exports.derivePrice = derivePrice; exports.formatPrice = formatPrice; exports.generateBreadcrumbJsonLd = generateBreadcrumbJsonLd; exports.getDefaultImageUrl = getDefaultImageUrl; exports.getImageSrcSet = getImageSrcSet; exports.getImageUrl = getImageUrl; exports.getPaymentStatus = getPaymentStatus; exports.getSchemaAvailability = getSchemaAvailability; exports.isAddressDifferent = isAddressDifferent; exports.normalizePath = normalizePath; exports.resolveStock = resolveStock; exports.sanitizeHtmlImages = sanitizeHtmlImages; exports.serializeTransforms = serializeTransforms; exports.transformShipToAddress = transformShipToAddress; exports.unwrap = unwrap; exports.unwrapOr = unwrapOr;
|
|
320
320
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-utils/dist/index.cjs","../src/cache-config.ts","../src/format-price.ts","../src/address-comparison.ts","../src/get-payment-status.ts","../src/transform-ship-to-address.ts","../src/build-checkout-payload.ts","../src/derive-price.ts","../src/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AA,CAAQ,UAAU,CAAA,EAAG;AACrD,IAAA,GAAA,CAAI,MAAA,IAAU,KAAA,CAAA,EAAW,QAAA;AACzB,IAAA,MAAM,OAAA,EAAS,iBAAA,CAAkB,GAAG,CAAA;AACpC,IAAA,GAAA,CAAI,MAAA,EAAQ;AAEV,MAAA,MAAM,EAAA,EAAI,IAAA,IAAQ,SAAA,GAAY,MAAA,IAAU,MAAA,EAAQ,OAAA,EAAS,KAAA;AACzD,MAAA,KAAA,CAAM,IAAA,CAAK,CAAA,EAAA;AACb,IAAA;AACF,EAAA;AACa,EAAA;AACf;AASgB;AACN,EAAA;AAEM,EAAA;AACR,EAAA;AACK,EAAA;AACG,IAAA;AACA,MAAA;AACV,MAAA;AACF,IAAA;AACF,EAAA;AAGU,EAAA;AAGC,EAAA;AACI,IAAA;AACf,EAAA;AAEO,EAAA;AACT;AAUgB;AAMR,EAAA;AACD,EAAA;AACI,IAAA;AACT,EAAA;AAEM,EAAA;AAGS,EAAA;AAEiB,EAAA;AACpB,IAAA;AACP,IAAA;AACL,EAAA;AACM,EAAA;AACA,EAAA;AAEI,EAAA;AACZ;AAMgB;AAIR,EAAA;AACS,EAAA;AACT,EAAA;AACS,EAAA;AACL,EAAA;AACZ;AAKgB;AAOX,EAAA;AACa,IAAA;AACC,IAAA;AAEL,EAAA;AACd;AAKgB;AAIC,EAAA;AACP,IAAA;AACF,IAAA;AACK,MAAA;AACT,IAAA;AACO,IAAA;AACT,EAAA;AACF;AAMgB;AAKF,EAAA;AACV,IAAA;AACS,IAAA;AACD,MAAA;AACC,MAAA;AACT,IAAA;AACF,EAAA;AACF;AXoFkB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-utils/dist/index.cjs","sourcesContent":[null,"/**\n * Centralized cache configuration for React Query (TanStack Query)\n *\n * staleTime -- How long cached data is considered \"fresh\". While fresh,\n * React Query serves the cache instantly and does NOT refetch in the\n * background. After staleTime expires the data is \"stale\" and will be\n * refetched on the next access (mount, window focus, etc.).\n *\n * gcTime (garbage collection time) -- How long UNUSED cached data stays in\n * memory after all components using it unmount. Once gcTime expires the\n * cache entry is deleted entirely.\n *\n * STATIC (1h): categories, menus, item details\n * SEMI_STATIC (10m): pricing, stock, search results\n * DYNAMIC (5m): infinite scroll data\n * CART (2m): cart lines, cart header\n * REALTIME (0): active orders, checkout state\n */\nexport const CACHE_CONFIG = {\n STATIC: {\n staleTime: 1000 * 60 * 60, // 1 hour\n gcTime: 1000 * 60 * 60 * 24, // 24 hours\n },\n SEMI_STATIC: {\n staleTime: 1000 * 60 * 10, // 10 minutes\n gcTime: 1000 * 60 * 60 * 4, // 4 hours\n },\n DYNAMIC: {\n staleTime: 1000 * 60 * 5, // 5 minutes\n gcTime: 1000 * 60 * 30, // 30 minutes\n },\n CART: {\n staleTime: 1000 * 60 * 2, // 2 minutes\n gcTime: 1000 * 60 * 30, // 30 minutes\n },\n REALTIME: {\n staleTime: 0,\n gcTime: 1000 * 60 * 5, // 5 minutes\n },\n} as const;\n\nexport type CacheTier = keyof typeof CACHE_CONFIG;\n","/**\n * Locale-aware currency formatting.\n * Defaults to USD -- consumers can override locale and currency.\n */\nexport function formatPrice(\n price: number,\n locale: string = \"en-US\",\n currency: string = \"USD\",\n): string {\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency,\n minimumFractionDigits: 2,\n }).format(price);\n}\n","import type { TSmartyStreets } from \"./types/smarty-streets\";\n\n/** User-entered address fields for comparison. */\nexport interface UserAddress {\n address1: string;\n city: string;\n state: string;\n postalCode: string;\n}\n\n/**\n * Compares a user-entered address with a SmartyStreets-validated address.\n * Returns true if any field differs (case-insensitive for address/city,\n * exact match for state abbreviation and zip code).\n *\n * Used in checkout to prompt users when their input differs from the\n * USPS-validated address.\n */\nexport function isAddressDifferent(\n userAddress: UserAddress,\n smartyAddress: TSmartyStreets,\n): boolean {\n return (\n smartyAddress.deliveryLine1.toLowerCase() !== userAddress.address1.toLowerCase() ||\n smartyAddress.cityName.toLowerCase() !== userAddress.city.toLowerCase() ||\n smartyAddress.stateAbbreviation !== userAddress.state ||\n smartyAddress.zipCode !== userAddress.postalCode\n );\n}\n","export type PaymentStatusInvoice = {\n paidInFullFlag?: string | null;\n amountPaid?: number;\n totalAmount?: number;\n};\n\nexport type PaymentStatus = \"Paid\" | \"Partially Paid\" | \"Unpaid\";\n\nexport function getPaymentStatus(invoice: PaymentStatusInvoice): PaymentStatus {\n if (invoice.paidInFullFlag === \"Y\") return \"Paid\";\n if (\n invoice.amountPaid != null &&\n invoice.totalAmount != null &&\n invoice.amountPaid > 0\n )\n return \"Partially Paid\";\n return \"Unpaid\";\n}\n","export type ShipToAddress = {\n shipToId: string | number;\n name: string;\n address1: string;\n address2?: string;\n city: string;\n state: string;\n zip: string;\n country?: string;\n};\n\ntype RawShipTo = Record<string, unknown>;\n\nfunction str(value: unknown): string {\n if (value == null) return \"\";\n return String(value).trim();\n}\n\nfunction pick(raw: RawShipTo, keys: string[]): string {\n for (const k of keys) {\n if (raw[k] != null) return str(raw[k]);\n }\n return \"\";\n}\n\nconst PHYS_FIELDS = {\n address1: [\"physAddress1\", \"phys_address1\"],\n address2: [\"physAddress2\", \"phys_address2\"],\n city: [\"physCity\", \"phys_city\"],\n state: [\"physState\", \"phys_state\"],\n zip: [\"physPostalCode\", \"phys_postal_code\"],\n country: [\"physCountry\", \"phys_country\"],\n} as const;\n\nconst MAIL_FIELDS = {\n address1: [\"mailAddress1\", \"mail_address1\", \"address1\"],\n address2: [\"mailAddress2\", \"mail_address2\", \"address2\"],\n city: [\"mailCity\", \"mail_city\", \"city\"],\n state: [\"mailState\", \"mail_state\", \"state\"],\n zip: [\"mailPostalCode\", \"mail_postal_code\", \"postalCode\", \"zip\"],\n country: [\"mailCountry\", \"mail_country\", \"country\"],\n} as const;\n\nexport function transformShipToAddress(raw: RawShipTo): ShipToAddress {\n const isPhys =\n raw.physAddress1 != null ||\n raw.physCity != null ||\n raw.physState != null;\n\n const f = isPhys ? PHYS_FIELDS : MAIL_FIELDS;\n\n const address: ShipToAddress = {\n shipToId: (raw.shipToId ?? raw.ship_to_id ?? raw.id ?? \"\") as\n | string\n | number,\n name: str(raw.shipToName ?? raw.ship_to_name ?? raw.name ?? \"\"),\n address1: pick(raw, [...f.address1]),\n city: pick(raw, [...f.city]),\n state: pick(raw, [...f.state]),\n zip: pick(raw, [...f.zip]),\n };\n\n const address2 = pick(raw, [...f.address2]);\n if (address2) address.address2 = address2;\n\n const country = pick(raw, [...f.country]);\n if (country) address.country = country;\n\n return address;\n}\n","import type { TCartLine } from \"./types/cart\";\n\nexport type OeHdr = {\n customer_id: number;\n company_id: string;\n sales_location_id: number;\n user_id: number;\n user_email: string;\n taker: string;\n customer_po_no?: string;\n ship_to_id?: string | number;\n delivery_instructions?: string;\n};\n\nexport type OeLine = {\n item_id: string;\n unit_quantity: number;\n unit_of_measure: string;\n inv_mast_uid: number;\n unit_price?: number;\n};\n\nexport type CheckoutInput = {\n customerId: number;\n companyId: string;\n salesLocationId: number;\n userId: number;\n userEmail: string;\n taker?: string;\n cartLines: TCartLine[];\n poNumber?: string;\n shipToId?: string | number;\n deliveryInstructions?: string;\n};\n\nexport function buildCheckoutPayload(input: CheckoutInput): {\n oe_hdr: OeHdr;\n oe_line: OeLine[];\n} {\n const oe_hdr: OeHdr = {\n customer_id: input.customerId,\n company_id: input.companyId,\n sales_location_id: input.salesLocationId,\n user_id: input.userId,\n user_email: input.userEmail,\n taker: input.taker ?? \"ESTORE\",\n };\n\n if (input.poNumber != null) oe_hdr.customer_po_no = input.poNumber;\n if (input.shipToId != null) oe_hdr.ship_to_id = input.shipToId;\n if (input.deliveryInstructions != null)\n oe_hdr.delivery_instructions = input.deliveryInstructions;\n\n const oe_line: OeLine[] = input.cartLines.map((line) => {\n const oeLine: OeLine = {\n item_id: line.itemId,\n unit_quantity: line.quantity,\n unit_of_measure: line.unitOfMeasure,\n inv_mast_uid: line.invMastUid,\n };\n if (line.unitPrice != null) oeLine.unit_price = line.unitPrice;\n return oeLine;\n });\n\n return { oe_hdr, oe_line };\n}\n","import type { TPriceData } from \"./types/pricing\";\n\nexport interface DerivedPrice {\n unitPrice: number;\n unitOfMeasure: string;\n total: number;\n isCallForPrice: boolean;\n}\n\nexport interface DerivePriceInput {\n priceData: TPriceData | null | undefined;\n quantity?: number;\n}\n\n/**\n * Pure price derivation — usable in hooks AND server components.\n *\n * Returns `null` when `priceData` is missing (loading / error state).\n */\nexport function derivePrice(input: DerivePriceInput): DerivedPrice | null {\n const { priceData, quantity = 1 } = input;\n\n if (!priceData) return null;\n\n const unitPrice = priceData.unitPrice ?? 0;\n const unitOfMeasure =\n priceData.unitOfMeasure || priceData.item?.unitOfMeasure || \"\";\n\n return {\n unitPrice,\n unitOfMeasure,\n total: unitPrice * quantity,\n isCallForPrice: unitPrice === 0,\n };\n}\n","import type { TStock } from \"./types/inventory\";\n\nexport interface ResolveStockInput {\n stock: TStock | null | undefined;\n companyKey?: string;\n round?: boolean;\n lowStockThreshold?: number;\n showQuantity?: boolean;\n}\n\nexport interface ResolvedStock {\n quantity: number;\n isInStock: boolean;\n isLowStock: boolean;\n displayQuantity: number | null;\n}\n\n/**\n * Pure stock resolution -- usable in hooks AND server components.\n *\n * Returns `null` when `stock` is missing (loading / error state).\n */\nexport function resolveStock(input: ResolveStockInput): ResolvedStock | null {\n const {\n stock,\n companyKey,\n round = false,\n lowStockThreshold = 0,\n showQuantity = false,\n } = input;\n\n if (!stock) return null;\n\n const { companySummary } = stock;\n let qty: number;\n\n if (companyKey && companyKey in companySummary) {\n qty = companySummary[companyKey] ?? 0;\n } else {\n qty = Object.values(companySummary).reduce(\n (sum: number, val: number) => sum + val,\n 0,\n );\n }\n\n if (round) {\n qty = Math.round(qty);\n }\n\n const isInStock = qty > 0;\n const isLowStock = isInStock && lowStockThreshold > 0 && qty <= lowStockThreshold;\n\n return {\n quantity: qty,\n isInStock,\n isLowStock,\n displayQuantity: showQuantity ? qty : null,\n };\n}\n","import type { ResolvedStock } from \"./resolve-stock\";\n\nexport type SchemaAvailability =\n | \"https://schema.org/InStock\"\n | \"https://schema.org/OutOfStock\"\n | \"https://schema.org/LimitedAvailability\";\n\n/**\n * Maps resolved stock to a Schema.org availability URL.\n *\n * Returns `\"https://schema.org/OutOfStock\"` when `resolved` is null/undefined.\n */\nexport function getSchemaAvailability(\n resolved: ResolvedStock | null | undefined,\n): SchemaAvailability {\n if (!resolved || !resolved.isInStock) {\n return \"https://schema.org/OutOfStock\";\n }\n\n if (resolved.isLowStock) {\n return \"https://schema.org/LimitedAvailability\";\n }\n\n return \"https://schema.org/InStock\";\n}\n","export interface BreadcrumbJsonLdItem {\n name: string;\n url: string;\n}\n\nexport function generateBreadcrumbJsonLd(\n items: BreadcrumbJsonLdItem[],\n): Record<string, unknown> {\n return {\n \"@context\": \"https://schema.org\",\n \"@type\": \"BreadcrumbList\",\n itemListElement: items.map((item, index) => ({\n \"@type\": \"ListItem\",\n position: index + 1,\n name: item.name,\n item: item.url,\n })),\n };\n}\n","/**\n * Image CDN utilities for agr.media.\n * Pure functions -- no DOM or React dependencies. Safe for server, web, and mobile.\n */\n\n/** 1x1 transparent PNG for Next.js `<Image blurDataURL={...}>` placeholders. */\nexport const BLUR_DATA_URL =\n \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mN88P/BfwYABQoBfqVKzQAAAABJRU5ErkJggg==\";\n\nexport interface ImageTransforms {\n width?: number;\n height?: number;\n format?: \"auto\" | \"webp\" | \"avif\" | \"jpeg\" | \"jpg\" | \"png\";\n quality?: number;\n fit?: \"cover\" | \"contain\" | \"fill\" | \"inside\" | \"outside\";\n}\n\nexport interface ImageConfig {\n readonly clientDomain: string;\n readonly defaultImage?: string;\n readonly defaultTransforms?: ImageTransforms;\n readonly stripPrefixes?: string[];\n readonly defaultPath?: string;\n}\n\nexport interface ImageUrlOptions {\n defaultImage?: string;\n}\n\nconst CDN_BASE = \"https://agr.media\";\n\nconst TRANSFORM_KEY_MAP: Record<string, string> = {\n width: \"w\",\n height: \"h\",\n format: \"f\",\n quality: \"q\",\n fit: \"fit\",\n};\n\n/**\n * Creates a frozen ImageConfig object.\n */\nconst DEFAULT_STRIP_PREFIXES = [\"/images\", \"images\"];\n\n/**\n * Creates a frozen ImageConfig object.\n *\n * `stripPrefixes` defaults to `[\"/images\", \"images\"]` — set to `[]` to disable.\n */\nexport function createImageConfig(\n clientDomain: string,\n opts?: {\n defaultImage?: string;\n defaultTransforms?: ImageTransforms;\n stripPrefixes?: string[];\n defaultPath?: string;\n },\n): ImageConfig {\n return Object.freeze({\n clientDomain,\n defaultImage: opts?.defaultImage,\n defaultTransforms: opts?.defaultTransforms,\n stripPrefixes: opts?.stripPrefixes ?? DEFAULT_STRIP_PREFIXES,\n defaultPath: opts?.defaultPath,\n });\n}\n\n/**\n * Serializes transform options into the CDN path segment.\n * Example: `{ width: 400, format: \"webp\" }` → `\"w_400,f_webp\"`\n */\nexport function serializeTransforms(transforms: ImageTransforms): string {\n const parts: string[] = [];\n for (const [key, value] of Object.entries(transforms)) {\n if (value === undefined) continue;\n const prefix = TRANSFORM_KEY_MAP[key];\n if (prefix) {\n // Normalize \"jpg\" → \"jpeg\" for CDN compatibility\n const v = key === \"format\" && value === \"jpg\" ? \"jpeg\" : value;\n parts.push(`${prefix}_${v}`);\n }\n }\n return parts.join(\",\");\n}\n\n/**\n * Normalizes an image path by:\n * 1. Returning it as-is if it starts with `http` (external URL).\n * 2. Stripping configured prefixes (defaults: `/images`, `images`).\n * 3. Prepending `defaultPath` for bare filenames (no `/`).\n * 4. Stripping leading slashes.\n */\nexport function normalizePath(config: ImageConfig, raw: string): string {\n if (raw.startsWith(\"http\")) return raw;\n\n let cleaned = raw;\n const prefixes = config.stripPrefixes ?? DEFAULT_STRIP_PREFIXES;\n for (const prefix of prefixes) {\n if (cleaned.startsWith(prefix)) {\n cleaned = cleaned.slice(prefix.length);\n break;\n }\n }\n\n // Strip leading slashes\n cleaned = cleaned.replace(/^\\/+/, \"\");\n\n // Bare filename — prepend defaultPath\n if (config.defaultPath && !cleaned.includes(\"/\")) {\n cleaned = `${config.defaultPath}/${cleaned}`;\n }\n\n return cleaned;\n}\n\n/**\n * Builds a full agr.media URL for the given image path and transforms.\n *\n * - Empty/nullish paths return the default image URL.\n * - Paths starting with `http` are returned as-is (external CDN).\n * - Configured prefixes (default: `/images`) are stripped automatically.\n * - Bare filenames are prepended with `config.defaultPath` if set.\n */\nexport function getImageUrl(\n config: ImageConfig,\n imagePath: string | undefined | null,\n transforms?: ImageTransforms,\n options?: ImageUrlOptions,\n): string {\n const resolvedPath = imagePath?.trim();\n if (!resolvedPath) {\n return getDefaultImageUrl(config, options);\n }\n\n const normalized = normalizePath(config, resolvedPath);\n\n // External URL — pass through\n if (normalized.startsWith(\"http\")) return normalized;\n\n const merged: ImageTransforms = {\n ...config.defaultTransforms,\n ...transforms,\n };\n const serialized = serializeTransforms(merged);\n const transformSegment = serialized ? `/${serialized}` : \"\";\n\n return `${CDN_BASE}/${config.clientDomain}/images${transformSegment}/${normalized}`;\n}\n\n/**\n * Returns the default/placeholder image URL.\n * Per-call `options.defaultImage` overrides `config.defaultImage`.\n */\nexport function getDefaultImageUrl(\n config: ImageConfig,\n options?: ImageUrlOptions,\n): string {\n const fallback = options?.defaultImage ?? config.defaultImage;\n if (!fallback) return \"\";\n const normalized = normalizePath(config, fallback);\n if (normalized.startsWith(\"http\")) return normalized;\n return `${CDN_BASE}/${config.clientDomain}/images/${normalized}`;\n}\n\n/**\n * Generates a `srcset` string for responsive images.\n */\nexport function getImageSrcSet(\n config: ImageConfig,\n imagePath: string,\n widths: number[],\n transforms?: ImageTransforms,\n): string {\n return widths\n .map((w) => {\n const url = getImageUrl(config, imagePath, { ...transforms, width: w });\n return `${url} ${w}w`;\n })\n .join(\", \");\n}\n\n/**\n * Returns a loader function compatible with Next.js `<Image loader={...}>`.\n */\nexport function buildImageLoader(\n config: ImageConfig,\n transforms?: ImageTransforms,\n): (props: { src: string; width: number; quality?: number }) => string {\n return ({ src, width, quality }) => {\n const merged: ImageTransforms = { ...transforms, width };\n if (quality !== undefined) {\n merged.quality = quality;\n }\n return getImageUrl(config, src, merged);\n };\n}\n\n/**\n * Rewrites `<img src=\"...\">` attributes in an HTML string to use agr.media URLs.\n * Useful for CMS/Joomla content that contains raw image references.\n */\nexport function sanitizeHtmlImages(\n config: ImageConfig,\n html: string,\n transforms?: ImageTransforms,\n): string {\n return html.replace(\n /<img\\s([^>]*?)src=[\"']([^\"']+)[\"']/gi,\n (_match, before: string, src: string) => {\n const cdnUrl = getImageUrl(config, src, transforms);\n return `<img ${before}src=\"${cdnUrl}\"`;\n },\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-utils/dist/index.cjs","../src/cache-config.ts","../src/format-price.ts","../src/address-comparison.ts","../src/get-payment-status.ts","../src/transform-ship-to-address.ts","../src/build-checkout-payload.ts","../src/derive-price.ts","../src/resolve-stock.ts","../src/schema-availability.ts","../src/json-ld.ts","../src/result.ts","../src/image.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACcO,IAAM,aAAA,EAAe;AAAA,EAC1B,MAAA,EAAQ;AAAA,IACN,SAAA,EAAW,IAAA,EAAO,GAAA,EAAK,EAAA;AAAA;AAAA,IACvB,MAAA,EAAQ,IAAA,EAAO,GAAA,EAAK,GAAA,EAAK;AAAA;AAAA,EAC3B,CAAA;AAAA,EACA,WAAA,EAAa;AAAA,IACX,SAAA,EAAW,IAAA,EAAO,GAAA,EAAK,EAAA;AAAA;AAAA,IACvB,MAAA,EAAQ,IAAA,EAAO,GAAA,EAAK,GAAA,EAAK;AAAA;AAAA,EAC3B,CAAA;AAAA,EACA,OAAA,EAAS;AAAA,IACP,SAAA,EAAW,IAAA,EAAO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AY,MAAA,IAAU,MAAA,EAAQ,OAAA,EAAS,KAAA;AACzD,MAAA,KAAA,CAAM,IAAA,CAAK,CAAA,EAAA;AACb,IAAA;AACF,EAAA;AACa,EAAA;AACf;AASgB;AACN,EAAA;AAEM,EAAA;AACR,EAAA;AACK,EAAA;AACG,IAAA;AACA,MAAA;AACV,MAAA;AACF,IAAA;AACF,EAAA;AAGU,EAAA;AAGC,EAAA;AACI,IAAA;AACf,EAAA;AAEO,EAAA;AACT;AAUgB;AAMR,EAAA;AACD,EAAA;AACI,IAAA;AACT,EAAA;AAEM,EAAA;AAGS,EAAA;AAEiB,EAAA;AACpB,IAAA;AACP,IAAA;AACL,EAAA;AACM,EAAA;AACA,EAAA;AAEI,EAAA;AACZ;AAMgB;AACR,EAAA;AACS,EAAA;AACT,EAAA;AACS,EAAA;AACL,EAAA;AACZ;AAKgB;AAOX,EAAA;AACa,IAAA;AACC,IAAA;AAEL,EAAA;AACd;AAKgB;AAIC,EAAA;AACP,IAAA;AACF,IAAA;AACK,MAAA;AACT,IAAA;AACO,IAAA;AACT,EAAA;AACF;AAMgB;AAKF,EAAA;AACV,IAAA;AACS,IAAA;AACD,MAAA;AACC,MAAA;AACT,IAAA;AACF,EAAA;AACF;AZqFkB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-utils/dist/index.cjs","sourcesContent":[null,"/**\n * Centralized cache configuration for React Query (TanStack Query)\n *\n * staleTime -- How long cached data is considered \"fresh\". While fresh,\n * React Query serves the cache instantly and does NOT refetch in the\n * background. After staleTime expires the data is \"stale\" and will be\n * refetched on the next access (mount, window focus, etc.).\n *\n * gcTime (garbage collection time) -- How long UNUSED cached data stays in\n * memory after all components using it unmount. Once gcTime expires the\n * cache entry is deleted entirely.\n *\n * STATIC (1h): categories, menus, item details\n * SEMI_STATIC (10m): pricing, stock, search results\n * DYNAMIC (5m): infinite scroll data\n * CART (2m): cart lines, cart header\n * REALTIME (0): active orders, checkout state\n */\nexport const CACHE_CONFIG = {\n STATIC: {\n staleTime: 1000 * 60 * 60, // 1 hour\n gcTime: 1000 * 60 * 60 * 24, // 24 hours\n },\n SEMI_STATIC: {\n staleTime: 1000 * 60 * 10, // 10 minutes\n gcTime: 1000 * 60 * 60 * 4, // 4 hours\n },\n DYNAMIC: {\n staleTime: 1000 * 60 * 5, // 5 minutes\n gcTime: 1000 * 60 * 30, // 30 minutes\n },\n CART: {\n staleTime: 1000 * 60 * 2, // 2 minutes\n gcTime: 1000 * 60 * 30, // 30 minutes\n },\n REALTIME: {\n staleTime: 0,\n gcTime: 1000 * 60 * 5, // 5 minutes\n },\n} as const;\n\nexport type CacheTier = keyof typeof CACHE_CONFIG;\n","/**\n * Locale-aware currency formatting.\n * Defaults to USD -- consumers can override locale and currency.\n */\nexport function formatPrice(\n price: number,\n locale: string = \"en-US\",\n currency: string = \"USD\",\n): string {\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency,\n minimumFractionDigits: 2,\n }).format(price);\n}\n","import type { TSmartyStreets } from \"./types/smarty-streets\";\n\n/** User-entered address fields for comparison. */\nexport interface UserAddress {\n address1: string;\n city: string;\n state: string;\n postalCode: string;\n}\n\n/**\n * Compares a user-entered address with a SmartyStreets-validated address.\n * Returns true if any field differs (case-insensitive for address/city,\n * exact match for state abbreviation and zip code).\n *\n * Used in checkout to prompt users when their input differs from the\n * USPS-validated address.\n */\nexport function isAddressDifferent(\n userAddress: UserAddress,\n smartyAddress: TSmartyStreets,\n): boolean {\n return (\n smartyAddress.deliveryLine1.toLowerCase() !== userAddress.address1.toLowerCase() ||\n smartyAddress.cityName.toLowerCase() !== userAddress.city.toLowerCase() ||\n smartyAddress.stateAbbreviation !== userAddress.state ||\n smartyAddress.zipCode !== userAddress.postalCode\n );\n}\n","export type PaymentStatusInvoice = {\n paidInFullFlag?: string | null;\n amountPaid?: number;\n totalAmount?: number;\n};\n\nexport type PaymentStatus = \"Paid\" | \"Partially Paid\" | \"Unpaid\";\n\nexport function getPaymentStatus(invoice: PaymentStatusInvoice): PaymentStatus {\n if (invoice.paidInFullFlag === \"Y\") return \"Paid\";\n if (invoice.amountPaid != null && invoice.totalAmount != null && invoice.amountPaid > 0)\n return \"Partially Paid\";\n return \"Unpaid\";\n}\n","export type ShipToAddress = {\n shipToId: string | number;\n name: string;\n address1: string;\n address2?: string;\n city: string;\n state: string;\n zip: string;\n country?: string;\n};\n\ntype RawShipTo = Record<string, unknown>;\n\nfunction str(value: unknown): string {\n return String(value).trim();\n}\n\nfunction pick(raw: RawShipTo, keys: string[]): string {\n for (const k of keys) {\n if (raw[k] != null) return str(raw[k]);\n }\n return \"\";\n}\n\nconst PHYS_FIELDS = {\n address1: [\"physAddress1\", \"phys_address1\"],\n address2: [\"physAddress2\", \"phys_address2\"],\n city: [\"physCity\", \"phys_city\"],\n state: [\"physState\", \"phys_state\"],\n zip: [\"physPostalCode\", \"phys_postal_code\"],\n country: [\"physCountry\", \"phys_country\"],\n} as const;\n\nconst MAIL_FIELDS = {\n address1: [\"mailAddress1\", \"mail_address1\", \"address1\"],\n address2: [\"mailAddress2\", \"mail_address2\", \"address2\"],\n city: [\"mailCity\", \"mail_city\", \"city\"],\n state: [\"mailState\", \"mail_state\", \"state\"],\n zip: [\"mailPostalCode\", \"mail_postal_code\", \"postalCode\", \"zip\"],\n country: [\"mailCountry\", \"mail_country\", \"country\"],\n} as const;\n\nexport function transformShipToAddress(raw: RawShipTo): ShipToAddress {\n const isPhys = raw[\"physAddress1\"] != null || raw[\"physCity\"] != null || raw[\"physState\"] != null;\n\n const f = isPhys ? PHYS_FIELDS : MAIL_FIELDS;\n\n const address: ShipToAddress = {\n shipToId: (raw[\"shipToId\"] ?? raw[\"ship_to_id\"] ?? raw[\"id\"] ?? \"\") as string | number,\n name: str(raw[\"shipToName\"] ?? raw[\"ship_to_name\"] ?? raw[\"name\"] ?? \"\"),\n address1: pick(raw, [...f.address1]),\n city: pick(raw, [...f.city]),\n state: pick(raw, [...f.state]),\n zip: pick(raw, [...f.zip]),\n };\n\n const address2 = pick(raw, [...f.address2]);\n if (address2) address.address2 = address2;\n\n const country = pick(raw, [...f.country]);\n if (country) address.country = country;\n\n return address;\n}\n","import type { TCartLine } from \"./types/cart\";\n\nexport type OeHdr = {\n customer_id: number;\n company_id: string;\n sales_location_id: number;\n user_id: number;\n user_email: string;\n taker: string;\n customer_po_no?: string;\n ship_to_id?: string | number;\n delivery_instructions?: string;\n};\n\nexport type OeLine = {\n item_id: string;\n unit_quantity: number;\n unit_of_measure: string;\n inv_mast_uid: number;\n unit_price?: number;\n};\n\nexport type CheckoutInput = {\n customerId: number;\n companyId: string;\n salesLocationId: number;\n userId: number;\n userEmail: string;\n taker?: string;\n cartLines: TCartLine[];\n poNumber?: string;\n shipToId?: string | number;\n deliveryInstructions?: string;\n};\n\nexport function buildCheckoutPayload(input: CheckoutInput): {\n oe_hdr: OeHdr;\n oe_line: OeLine[];\n} {\n const oe_hdr: OeHdr = {\n customer_id: input.customerId,\n company_id: input.companyId,\n sales_location_id: input.salesLocationId,\n user_id: input.userId,\n user_email: input.userEmail,\n taker: input.taker ?? \"ESTORE\",\n };\n\n if (input.poNumber != null) oe_hdr.customer_po_no = input.poNumber;\n if (input.shipToId != null) oe_hdr.ship_to_id = input.shipToId;\n if (input.deliveryInstructions != null) oe_hdr.delivery_instructions = input.deliveryInstructions;\n\n const oe_line: OeLine[] = input.cartLines.map((line) => {\n const oeLine: OeLine = {\n item_id: line.itemId,\n unit_quantity: line.quantity,\n unit_of_measure: line.unitOfMeasure,\n inv_mast_uid: line.invMastUid,\n };\n if (line.unitPrice != null) oeLine.unit_price = line.unitPrice;\n return oeLine;\n });\n\n return { oe_hdr, oe_line };\n}\n","import type { TPriceData } from \"./types/pricing\";\n\nexport interface DerivedPrice {\n unitPrice: number;\n unitOfMeasure: string;\n total: number;\n isCallForPrice: boolean;\n}\n\nexport interface DerivePriceInput {\n priceData: TPriceData | null | undefined;\n quantity?: number;\n}\n\n/**\n * Pure price derivation — usable in hooks AND server components.\n *\n * Returns `null` when `priceData` is missing (loading / error state).\n */\nexport function derivePrice(input: DerivePriceInput): DerivedPrice | null {\n const { priceData, quantity = 1 } = input;\n\n if (!priceData) return null;\n\n const unitPrice = priceData.unitPrice ?? 0;\n const unitOfMeasure = priceData.unitOfMeasure || priceData.item?.unitOfMeasure || \"\";\n\n return {\n unitPrice,\n unitOfMeasure,\n total: unitPrice * quantity,\n isCallForPrice: unitPrice === 0,\n };\n}\n","import type { TStock } from \"./types/inventory\";\n\nexport interface ResolveStockInput {\n stock: TStock | null | undefined;\n companyKey?: string;\n round?: boolean;\n lowStockThreshold?: number;\n showQuantity?: boolean;\n}\n\nexport interface ResolvedStock {\n quantity: number;\n isInStock: boolean;\n isLowStock: boolean;\n displayQuantity: number | null;\n}\n\n/**\n * Pure stock resolution -- usable in hooks AND server components.\n *\n * Returns `null` when `stock` is missing (loading / error state).\n */\nexport function resolveStock(input: ResolveStockInput): ResolvedStock | null {\n const { stock, companyKey, round = false, lowStockThreshold = 0, showQuantity = false } = input;\n\n if (!stock) return null;\n\n const { companySummary } = stock;\n let qty: number;\n\n if (companyKey && companyKey in companySummary) {\n qty = companySummary[companyKey] ?? 0;\n } else {\n qty = Object.values(companySummary).reduce((sum: number, val: number) => sum + val, 0);\n }\n\n if (round) {\n qty = Math.round(qty);\n }\n\n const isInStock = qty > 0;\n const isLowStock = isInStock && lowStockThreshold > 0 && qty <= lowStockThreshold;\n\n return {\n quantity: qty,\n isInStock,\n isLowStock,\n displayQuantity: showQuantity ? qty : null,\n };\n}\n","import type { ResolvedStock } from \"./resolve-stock\";\n\nexport type SchemaAvailability =\n | \"https://schema.org/InStock\"\n | \"https://schema.org/OutOfStock\"\n | \"https://schema.org/LimitedAvailability\";\n\n/**\n * Maps resolved stock to a Schema.org availability URL.\n *\n * Returns `\"https://schema.org/OutOfStock\"` when `resolved` is null/undefined.\n */\nexport function getSchemaAvailability(\n resolved: ResolvedStock | null | undefined,\n): SchemaAvailability {\n if (!resolved || !resolved.isInStock) {\n return \"https://schema.org/OutOfStock\";\n }\n\n if (resolved.isLowStock) {\n return \"https://schema.org/LimitedAvailability\";\n }\n\n return \"https://schema.org/InStock\";\n}\n","export interface BreadcrumbJsonLdItem {\n name: string;\n url: string;\n}\n\nexport function generateBreadcrumbJsonLd(items: BreadcrumbJsonLdItem[]): Record<string, unknown> {\n return {\n \"@context\": \"https://schema.org\",\n \"@type\": \"BreadcrumbList\",\n itemListElement: items.map((item, index) => ({\n \"@type\": \"ListItem\",\n position: index + 1,\n name: item.name,\n item: item.url,\n })),\n };\n}\n","/** Result type for safe action wrappers. */\nexport type SafeActionResult<T> = { ok: true; data: T } | { ok: false; error: string };\n\n/**\n * Extracts the data from a `SafeActionResult`, throwing on error.\n *\n * Ideal for React Query `queryFn` where errors should propagate\n * to the error boundary.\n *\n * @example\n * ```ts\n * const cart = unwrap(await getCartLines(cartId));\n * ```\n */\nexport function unwrap<T>(result: SafeActionResult<T>): T {\n if (!result.ok) throw new Error(result.error || \"Action failed\");\n return result.data;\n}\n\n/**\n * Extracts the data from a `SafeActionResult`, returning `null` on error.\n *\n * For direct calls that prefer `null` over thrown errors.\n *\n * @example\n * ```ts\n * const cart = unwrapOr(await getCartLines(cartId));\n * if (!cart) { /* handle missing data *\\/ }\n * ```\n */\nexport function unwrapOr<T>(result: SafeActionResult<T>): T | null {\n return result.ok ? (result.data ?? null) : null;\n}\n","/**\n * Image CDN utilities for agr.media.\n * Pure functions -- no DOM or React dependencies. Safe for server, web, and mobile.\n */\n\n/** 1x1 transparent PNG for Next.js `<Image blurDataURL={...}>` placeholders. */\nexport const BLUR_DATA_URL =\n \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mN88P/BfwYABQoBfqVKzQAAAABJRU5ErkJggg==\";\n\nexport interface ImageTransforms {\n width?: number;\n height?: number;\n format?: \"auto\" | \"webp\" | \"avif\" | \"jpeg\" | \"jpg\" | \"png\";\n quality?: number;\n fit?: \"cover\" | \"contain\" | \"fill\" | \"inside\" | \"outside\";\n}\n\nexport interface ImageConfig {\n readonly clientDomain: string;\n readonly defaultImage?: string;\n readonly defaultTransforms?: ImageTransforms;\n readonly stripPrefixes?: string[];\n readonly defaultPath?: string;\n}\n\nexport interface ImageUrlOptions {\n defaultImage?: string;\n}\n\nconst CDN_BASE = \"https://agr.media\";\n\nconst TRANSFORM_KEY_MAP: Record<string, string> = {\n width: \"w\",\n height: \"h\",\n format: \"f\",\n quality: \"q\",\n fit: \"fit\",\n};\n\n/**\n * Creates a frozen ImageConfig object.\n */\nconst DEFAULT_STRIP_PREFIXES = [\"/images\", \"images\"];\n\n/**\n * Creates a frozen ImageConfig object.\n *\n * `stripPrefixes` defaults to `[\"/images\", \"images\"]` — set to `[]` to disable.\n */\nexport function createImageConfig(\n clientDomain: string,\n opts?: {\n defaultImage?: string;\n defaultTransforms?: ImageTransforms;\n stripPrefixes?: string[];\n defaultPath?: string;\n },\n): ImageConfig {\n return Object.freeze({\n clientDomain,\n defaultImage: opts?.defaultImage,\n defaultTransforms: opts?.defaultTransforms,\n stripPrefixes: opts?.stripPrefixes ?? DEFAULT_STRIP_PREFIXES,\n defaultPath: opts?.defaultPath,\n });\n}\n\n/**\n * Serializes transform options into the CDN path segment.\n * Example: `{ width: 400, format: \"webp\" }` → `\"w_400,f_webp\"`\n */\nexport function serializeTransforms(transforms: ImageTransforms): string {\n const parts: string[] = [];\n for (const [key, value] of Object.entries(transforms)) {\n if (value === undefined) continue;\n const prefix = TRANSFORM_KEY_MAP[key];\n if (prefix) {\n // Normalize \"jpg\" → \"jpeg\" for CDN compatibility\n const v = key === \"format\" && value === \"jpg\" ? \"jpeg\" : value;\n parts.push(`${prefix}_${v}`);\n }\n }\n return parts.join(\",\");\n}\n\n/**\n * Normalizes an image path by:\n * 1. Returning it as-is if it starts with `http` (external URL).\n * 2. Stripping configured prefixes (defaults: `/images`, `images`).\n * 3. Prepending `defaultPath` for bare filenames (no `/`).\n * 4. Stripping leading slashes.\n */\nexport function normalizePath(config: ImageConfig, raw: string): string {\n if (raw.startsWith(\"http\")) return raw;\n\n let cleaned = raw;\n const prefixes = config.stripPrefixes ?? DEFAULT_STRIP_PREFIXES;\n for (const prefix of prefixes) {\n if (cleaned.startsWith(prefix)) {\n cleaned = cleaned.slice(prefix.length);\n break;\n }\n }\n\n // Strip leading slashes\n cleaned = cleaned.replace(/^\\/+/, \"\");\n\n // Bare filename — prepend defaultPath\n if (config.defaultPath && !cleaned.includes(\"/\")) {\n cleaned = `${config.defaultPath}/${cleaned}`;\n }\n\n return cleaned;\n}\n\n/**\n * Builds a full agr.media URL for the given image path and transforms.\n *\n * - Empty/nullish paths return the default image URL.\n * - Paths starting with `http` are returned as-is (external CDN).\n * - Configured prefixes (default: `/images`) are stripped automatically.\n * - Bare filenames are prepended with `config.defaultPath` if set.\n */\nexport function getImageUrl(\n config: ImageConfig,\n imagePath: string | undefined | null,\n transforms?: ImageTransforms,\n options?: ImageUrlOptions,\n): string {\n const resolvedPath = imagePath?.trim();\n if (!resolvedPath) {\n return getDefaultImageUrl(config, options);\n }\n\n const normalized = normalizePath(config, resolvedPath);\n\n // External URL — pass through\n if (normalized.startsWith(\"http\")) return normalized;\n\n const merged: ImageTransforms = {\n ...config.defaultTransforms,\n ...transforms,\n };\n const serialized = serializeTransforms(merged);\n const transformSegment = serialized ? `/${serialized}` : \"\";\n\n return `${CDN_BASE}/${config.clientDomain}/images${transformSegment}/${normalized}`;\n}\n\n/**\n * Returns the default/placeholder image URL.\n * Per-call `options.defaultImage` overrides `config.defaultImage`.\n */\nexport function getDefaultImageUrl(config: ImageConfig, options?: ImageUrlOptions): string {\n const fallback = options?.defaultImage ?? config.defaultImage;\n if (!fallback) return \"\";\n const normalized = normalizePath(config, fallback);\n if (normalized.startsWith(\"http\")) return normalized;\n return `${CDN_BASE}/${config.clientDomain}/images/${normalized}`;\n}\n\n/**\n * Generates a `srcset` string for responsive images.\n */\nexport function getImageSrcSet(\n config: ImageConfig,\n imagePath: string,\n widths: number[],\n transforms?: ImageTransforms,\n): string {\n return widths\n .map((w) => {\n const url = getImageUrl(config, imagePath, { ...transforms, width: w });\n return `${url} ${w}w`;\n })\n .join(\", \");\n}\n\n/**\n * Returns a loader function compatible with Next.js `<Image loader={...}>`.\n */\nexport function buildImageLoader(\n config: ImageConfig,\n transforms?: ImageTransforms,\n): (props: { src: string; width: number; quality?: number }) => string {\n return ({ src, width, quality }) => {\n const merged: ImageTransforms = { ...transforms, width };\n if (quality !== undefined) {\n merged.quality = quality;\n }\n return getImageUrl(config, src, merged);\n };\n}\n\n/**\n * Rewrites `<img src=\"...\">` attributes in an HTML string to use agr.media URLs.\n * Useful for CMS/Joomla content that contains raw image references.\n */\nexport function sanitizeHtmlImages(\n config: ImageConfig,\n html: string,\n transforms?: ImageTransforms,\n): string {\n return html.replace(\n /<img\\s([^>]*?)src=[\"']([^\"']+)[\"']/gi,\n (_match, before: string, src: string) => {\n const cdnUrl = getImageUrl(config, src, transforms);\n return `<img ${before}src=\"${cdnUrl}\"`;\n },\n );\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -475,21 +475,24 @@ type MenuItem = {
|
|
|
475
475
|
children: MenuItem[];
|
|
476
476
|
};
|
|
477
477
|
type TMenu = {
|
|
478
|
-
id:
|
|
478
|
+
id: number;
|
|
479
479
|
title: string;
|
|
480
480
|
alias: string;
|
|
481
481
|
link: string;
|
|
482
|
-
level:
|
|
483
|
-
|
|
482
|
+
level: number;
|
|
483
|
+
parentId: number;
|
|
484
484
|
path: string;
|
|
485
|
-
published:
|
|
485
|
+
published: number;
|
|
486
486
|
type: string;
|
|
487
487
|
menutype: string;
|
|
488
|
-
lft:
|
|
489
|
-
rgt:
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
488
|
+
lft: number;
|
|
489
|
+
rgt: number;
|
|
490
|
+
checkedOut: number;
|
|
491
|
+
checkedOutTime: string;
|
|
492
|
+
componentId: number;
|
|
493
|
+
clientId: number;
|
|
494
|
+
browserNav: number;
|
|
495
|
+
templateStyleId: number;
|
|
493
496
|
note: string;
|
|
494
497
|
language: string;
|
|
495
498
|
params: string;
|
|
@@ -999,6 +1002,39 @@ interface BreadcrumbJsonLdItem {
|
|
|
999
1002
|
}
|
|
1000
1003
|
declare function generateBreadcrumbJsonLd(items: BreadcrumbJsonLdItem[]): Record<string, unknown>;
|
|
1001
1004
|
|
|
1005
|
+
/** Result type for safe action wrappers. */
|
|
1006
|
+
type SafeActionResult<T> = {
|
|
1007
|
+
ok: true;
|
|
1008
|
+
data: T;
|
|
1009
|
+
} | {
|
|
1010
|
+
ok: false;
|
|
1011
|
+
error: string;
|
|
1012
|
+
};
|
|
1013
|
+
/**
|
|
1014
|
+
* Extracts the data from a `SafeActionResult`, throwing on error.
|
|
1015
|
+
*
|
|
1016
|
+
* Ideal for React Query `queryFn` where errors should propagate
|
|
1017
|
+
* to the error boundary.
|
|
1018
|
+
*
|
|
1019
|
+
* @example
|
|
1020
|
+
* ```ts
|
|
1021
|
+
* const cart = unwrap(await getCartLines(cartId));
|
|
1022
|
+
* ```
|
|
1023
|
+
*/
|
|
1024
|
+
declare function unwrap<T>(result: SafeActionResult<T>): T;
|
|
1025
|
+
/**
|
|
1026
|
+
* Extracts the data from a `SafeActionResult`, returning `null` on error.
|
|
1027
|
+
*
|
|
1028
|
+
* For direct calls that prefer `null` over thrown errors.
|
|
1029
|
+
*
|
|
1030
|
+
* @example
|
|
1031
|
+
* ```ts
|
|
1032
|
+
* const cart = unwrapOr(await getCartLines(cartId));
|
|
1033
|
+
* if (!cart) { /* handle missing data *\/ }
|
|
1034
|
+
* ```
|
|
1035
|
+
*/
|
|
1036
|
+
declare function unwrapOr<T>(result: SafeActionResult<T>): T | null;
|
|
1037
|
+
|
|
1002
1038
|
/**
|
|
1003
1039
|
* Image CDN utilities for agr.media.
|
|
1004
1040
|
* Pure functions -- no DOM or React dependencies. Safe for server, web, and mobile.
|
|
@@ -1078,4 +1114,4 @@ declare function buildImageLoader(config: ImageConfig, transforms?: ImageTransfo
|
|
|
1078
1114
|
*/
|
|
1079
1115
|
declare function sanitizeHtmlImages(config: ImageConfig, html: string, transforms?: ImageTransforms): string;
|
|
1080
1116
|
|
|
1081
|
-
export { BLUR_DATA_URL, type BreadcrumbJsonLdItem, CACHE_CONFIG, type CacheTier, type CheckoutInput, type CustomerDocument, type DerivePriceInput, type DerivedPrice, type ImageConfig, type ImageTransforms, type ImageUrlOptions, type MenuItem, type OeHdr, type OeLine, type OrderHeader, type OrderLine, type OrderNote, type OrderPayment, type PaymentStatus, type PaymentStatusInvoice, type ResolveStockInput, type ResolvedStock, type SchemaAvailability, type ShipToAddress, type TAccountQuery, type TApiResponse, type TAttribute, type TAttributeValue, type TBillingUpdate, type TCardInfo, type TCartHdrUid, type TCartLine, type TCartLookUp, type TCategory, type TCategoryChild, type TCategoryItemsResult, type TCheckoutResult, type TInvMast, type TInvMastDoc, type TInventorySupplier, type TItemAccessory, type TItemAttribute, type TItemAttributes, type TItemCategory, type TItemDetails, type TItemRelatedProduct, type TItemUom, type TItemsFilters, type TJoomlaContent, type TJoomlaContentFilters, type TLibraryPriceBreak, type TLibraryPriceData, type TLtlRatesResponse, type TLtlShipmentData, type TMenu, type TMenuFilters, type TMetaTags, type TOrderCartLine, type TPasswordVerification, type TPaymentValidation, type TPriceData, type TProductCategory, type TProductItem, type TProductStockData, type TProfileValues, type TRelatedProduct, type TSearchSuggestion, type TSearchSuggestionsResponse, type TShippingMethod, type TSmartyStreets, type TStock, type TStockData, type TSurcharge, type TTax, type TTaxItem, type TTransactionSetup, type TUserProfile, type TWebDesc, type UserAddress, buildCheckoutPayload, buildImageLoader, createImageConfig, derivePrice, formatPrice, generateBreadcrumbJsonLd, getDefaultImageUrl, getImageSrcSet, getImageUrl, getPaymentStatus, getSchemaAvailability, isAddressDifferent, normalizePath, resolveStock, sanitizeHtmlImages, serializeTransforms, transformShipToAddress };
|
|
1117
|
+
export { BLUR_DATA_URL, type BreadcrumbJsonLdItem, CACHE_CONFIG, type CacheTier, type CheckoutInput, type CustomerDocument, type DerivePriceInput, type DerivedPrice, type ImageConfig, type ImageTransforms, type ImageUrlOptions, type MenuItem, type OeHdr, type OeLine, type OrderHeader, type OrderLine, type OrderNote, type OrderPayment, type PaymentStatus, type PaymentStatusInvoice, type ResolveStockInput, type ResolvedStock, type SafeActionResult, type SchemaAvailability, type ShipToAddress, type TAccountQuery, type TApiResponse, type TAttribute, type TAttributeValue, type TBillingUpdate, type TCardInfo, type TCartHdrUid, type TCartLine, type TCartLookUp, type TCategory, type TCategoryChild, type TCategoryItemsResult, type TCheckoutResult, type TInvMast, type TInvMastDoc, type TInventorySupplier, type TItemAccessory, type TItemAttribute, type TItemAttributes, type TItemCategory, type TItemDetails, type TItemRelatedProduct, type TItemUom, type TItemsFilters, type TJoomlaContent, type TJoomlaContentFilters, type TLibraryPriceBreak, type TLibraryPriceData, type TLtlRatesResponse, type TLtlShipmentData, type TMenu, type TMenuFilters, type TMetaTags, type TOrderCartLine, type TPasswordVerification, type TPaymentValidation, type TPriceData, type TProductCategory, type TProductItem, type TProductStockData, type TProfileValues, type TRelatedProduct, type TSearchSuggestion, type TSearchSuggestionsResponse, type TShippingMethod, type TSmartyStreets, type TStock, type TStockData, type TSurcharge, type TTax, type TTaxItem, type TTransactionSetup, type TUserProfile, type TWebDesc, type UserAddress, buildCheckoutPayload, buildImageLoader, createImageConfig, derivePrice, formatPrice, generateBreadcrumbJsonLd, getDefaultImageUrl, getImageSrcSet, getImageUrl, getPaymentStatus, getSchemaAvailability, isAddressDifferent, normalizePath, resolveStock, sanitizeHtmlImages, serializeTransforms, transformShipToAddress, unwrap, unwrapOr };
|
package/dist/index.d.ts
CHANGED
|
@@ -475,21 +475,24 @@ type MenuItem = {
|
|
|
475
475
|
children: MenuItem[];
|
|
476
476
|
};
|
|
477
477
|
type TMenu = {
|
|
478
|
-
id:
|
|
478
|
+
id: number;
|
|
479
479
|
title: string;
|
|
480
480
|
alias: string;
|
|
481
481
|
link: string;
|
|
482
|
-
level:
|
|
483
|
-
|
|
482
|
+
level: number;
|
|
483
|
+
parentId: number;
|
|
484
484
|
path: string;
|
|
485
|
-
published:
|
|
485
|
+
published: number;
|
|
486
486
|
type: string;
|
|
487
487
|
menutype: string;
|
|
488
|
-
lft:
|
|
489
|
-
rgt:
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
488
|
+
lft: number;
|
|
489
|
+
rgt: number;
|
|
490
|
+
checkedOut: number;
|
|
491
|
+
checkedOutTime: string;
|
|
492
|
+
componentId: number;
|
|
493
|
+
clientId: number;
|
|
494
|
+
browserNav: number;
|
|
495
|
+
templateStyleId: number;
|
|
493
496
|
note: string;
|
|
494
497
|
language: string;
|
|
495
498
|
params: string;
|
|
@@ -999,6 +1002,39 @@ interface BreadcrumbJsonLdItem {
|
|
|
999
1002
|
}
|
|
1000
1003
|
declare function generateBreadcrumbJsonLd(items: BreadcrumbJsonLdItem[]): Record<string, unknown>;
|
|
1001
1004
|
|
|
1005
|
+
/** Result type for safe action wrappers. */
|
|
1006
|
+
type SafeActionResult<T> = {
|
|
1007
|
+
ok: true;
|
|
1008
|
+
data: T;
|
|
1009
|
+
} | {
|
|
1010
|
+
ok: false;
|
|
1011
|
+
error: string;
|
|
1012
|
+
};
|
|
1013
|
+
/**
|
|
1014
|
+
* Extracts the data from a `SafeActionResult`, throwing on error.
|
|
1015
|
+
*
|
|
1016
|
+
* Ideal for React Query `queryFn` where errors should propagate
|
|
1017
|
+
* to the error boundary.
|
|
1018
|
+
*
|
|
1019
|
+
* @example
|
|
1020
|
+
* ```ts
|
|
1021
|
+
* const cart = unwrap(await getCartLines(cartId));
|
|
1022
|
+
* ```
|
|
1023
|
+
*/
|
|
1024
|
+
declare function unwrap<T>(result: SafeActionResult<T>): T;
|
|
1025
|
+
/**
|
|
1026
|
+
* Extracts the data from a `SafeActionResult`, returning `null` on error.
|
|
1027
|
+
*
|
|
1028
|
+
* For direct calls that prefer `null` over thrown errors.
|
|
1029
|
+
*
|
|
1030
|
+
* @example
|
|
1031
|
+
* ```ts
|
|
1032
|
+
* const cart = unwrapOr(await getCartLines(cartId));
|
|
1033
|
+
* if (!cart) { /* handle missing data *\/ }
|
|
1034
|
+
* ```
|
|
1035
|
+
*/
|
|
1036
|
+
declare function unwrapOr<T>(result: SafeActionResult<T>): T | null;
|
|
1037
|
+
|
|
1002
1038
|
/**
|
|
1003
1039
|
* Image CDN utilities for agr.media.
|
|
1004
1040
|
* Pure functions -- no DOM or React dependencies. Safe for server, web, and mobile.
|
|
@@ -1078,4 +1114,4 @@ declare function buildImageLoader(config: ImageConfig, transforms?: ImageTransfo
|
|
|
1078
1114
|
*/
|
|
1079
1115
|
declare function sanitizeHtmlImages(config: ImageConfig, html: string, transforms?: ImageTransforms): string;
|
|
1080
1116
|
|
|
1081
|
-
export { BLUR_DATA_URL, type BreadcrumbJsonLdItem, CACHE_CONFIG, type CacheTier, type CheckoutInput, type CustomerDocument, type DerivePriceInput, type DerivedPrice, type ImageConfig, type ImageTransforms, type ImageUrlOptions, type MenuItem, type OeHdr, type OeLine, type OrderHeader, type OrderLine, type OrderNote, type OrderPayment, type PaymentStatus, type PaymentStatusInvoice, type ResolveStockInput, type ResolvedStock, type SchemaAvailability, type ShipToAddress, type TAccountQuery, type TApiResponse, type TAttribute, type TAttributeValue, type TBillingUpdate, type TCardInfo, type TCartHdrUid, type TCartLine, type TCartLookUp, type TCategory, type TCategoryChild, type TCategoryItemsResult, type TCheckoutResult, type TInvMast, type TInvMastDoc, type TInventorySupplier, type TItemAccessory, type TItemAttribute, type TItemAttributes, type TItemCategory, type TItemDetails, type TItemRelatedProduct, type TItemUom, type TItemsFilters, type TJoomlaContent, type TJoomlaContentFilters, type TLibraryPriceBreak, type TLibraryPriceData, type TLtlRatesResponse, type TLtlShipmentData, type TMenu, type TMenuFilters, type TMetaTags, type TOrderCartLine, type TPasswordVerification, type TPaymentValidation, type TPriceData, type TProductCategory, type TProductItem, type TProductStockData, type TProfileValues, type TRelatedProduct, type TSearchSuggestion, type TSearchSuggestionsResponse, type TShippingMethod, type TSmartyStreets, type TStock, type TStockData, type TSurcharge, type TTax, type TTaxItem, type TTransactionSetup, type TUserProfile, type TWebDesc, type UserAddress, buildCheckoutPayload, buildImageLoader, createImageConfig, derivePrice, formatPrice, generateBreadcrumbJsonLd, getDefaultImageUrl, getImageSrcSet, getImageUrl, getPaymentStatus, getSchemaAvailability, isAddressDifferent, normalizePath, resolveStock, sanitizeHtmlImages, serializeTransforms, transformShipToAddress };
|
|
1117
|
+
export { BLUR_DATA_URL, type BreadcrumbJsonLdItem, CACHE_CONFIG, type CacheTier, type CheckoutInput, type CustomerDocument, type DerivePriceInput, type DerivedPrice, type ImageConfig, type ImageTransforms, type ImageUrlOptions, type MenuItem, type OeHdr, type OeLine, type OrderHeader, type OrderLine, type OrderNote, type OrderPayment, type PaymentStatus, type PaymentStatusInvoice, type ResolveStockInput, type ResolvedStock, type SafeActionResult, type SchemaAvailability, type ShipToAddress, type TAccountQuery, type TApiResponse, type TAttribute, type TAttributeValue, type TBillingUpdate, type TCardInfo, type TCartHdrUid, type TCartLine, type TCartLookUp, type TCategory, type TCategoryChild, type TCategoryItemsResult, type TCheckoutResult, type TInvMast, type TInvMastDoc, type TInventorySupplier, type TItemAccessory, type TItemAttribute, type TItemAttributes, type TItemCategory, type TItemDetails, type TItemRelatedProduct, type TItemUom, type TItemsFilters, type TJoomlaContent, type TJoomlaContentFilters, type TLibraryPriceBreak, type TLibraryPriceData, type TLtlRatesResponse, type TLtlShipmentData, type TMenu, type TMenuFilters, type TMetaTags, type TOrderCartLine, type TPasswordVerification, type TPaymentValidation, type TPriceData, type TProductCategory, type TProductItem, type TProductStockData, type TProfileValues, type TRelatedProduct, type TSearchSuggestion, type TSearchSuggestionsResponse, type TShippingMethod, type TSmartyStreets, type TStock, type TStockData, type TSurcharge, type TTax, type TTaxItem, type TTransactionSetup, type TUserProfile, type TWebDesc, type UserAddress, buildCheckoutPayload, buildImageLoader, createImageConfig, derivePrice, formatPrice, generateBreadcrumbJsonLd, getDefaultImageUrl, getImageSrcSet, getImageUrl, getPaymentStatus, getSchemaAvailability, isAddressDifferent, normalizePath, resolveStock, sanitizeHtmlImages, serializeTransforms, transformShipToAddress, unwrap, unwrapOr };
|
package/dist/index.js
CHANGED
|
@@ -59,7 +59,6 @@ function getPaymentStatus(invoice) {
|
|
|
59
59
|
|
|
60
60
|
// src/transform-ship-to-address.ts
|
|
61
61
|
function str(value) {
|
|
62
|
-
if (value == null) return "";
|
|
63
62
|
return String(value).trim();
|
|
64
63
|
}
|
|
65
64
|
function pick(raw, keys) {
|
|
@@ -85,11 +84,11 @@ var MAIL_FIELDS = {
|
|
|
85
84
|
country: ["mailCountry", "mail_country", "country"]
|
|
86
85
|
};
|
|
87
86
|
function transformShipToAddress(raw) {
|
|
88
|
-
const isPhys = raw
|
|
87
|
+
const isPhys = raw["physAddress1"] != null || raw["physCity"] != null || raw["physState"] != null;
|
|
89
88
|
const f = isPhys ? PHYS_FIELDS : MAIL_FIELDS;
|
|
90
89
|
const address = {
|
|
91
|
-
shipToId: raw
|
|
92
|
-
name: str(raw
|
|
90
|
+
shipToId: raw["shipToId"] ?? raw["ship_to_id"] ?? raw["id"] ?? "",
|
|
91
|
+
name: str(raw["shipToName"] ?? raw["ship_to_name"] ?? raw["name"] ?? ""),
|
|
93
92
|
address1: pick(raw, [...f.address1]),
|
|
94
93
|
city: pick(raw, [...f.city]),
|
|
95
94
|
state: pick(raw, [...f.state]),
|
|
@@ -114,8 +113,7 @@ function buildCheckoutPayload(input) {
|
|
|
114
113
|
};
|
|
115
114
|
if (input.poNumber != null) oe_hdr.customer_po_no = input.poNumber;
|
|
116
115
|
if (input.shipToId != null) oe_hdr.ship_to_id = input.shipToId;
|
|
117
|
-
if (input.deliveryInstructions != null)
|
|
118
|
-
oe_hdr.delivery_instructions = input.deliveryInstructions;
|
|
116
|
+
if (input.deliveryInstructions != null) oe_hdr.delivery_instructions = input.deliveryInstructions;
|
|
119
117
|
const oe_line = input.cartLines.map((line) => {
|
|
120
118
|
const oeLine = {
|
|
121
119
|
item_id: line.itemId,
|
|
@@ -145,23 +143,14 @@ function derivePrice(input) {
|
|
|
145
143
|
|
|
146
144
|
// src/resolve-stock.ts
|
|
147
145
|
function resolveStock(input) {
|
|
148
|
-
const {
|
|
149
|
-
stock,
|
|
150
|
-
companyKey,
|
|
151
|
-
round = false,
|
|
152
|
-
lowStockThreshold = 0,
|
|
153
|
-
showQuantity = false
|
|
154
|
-
} = input;
|
|
146
|
+
const { stock, companyKey, round = false, lowStockThreshold = 0, showQuantity = false } = input;
|
|
155
147
|
if (!stock) return null;
|
|
156
148
|
const { companySummary } = stock;
|
|
157
149
|
let qty;
|
|
158
150
|
if (companyKey && companyKey in companySummary) {
|
|
159
151
|
qty = companySummary[companyKey] ?? 0;
|
|
160
152
|
} else {
|
|
161
|
-
qty = Object.values(companySummary).reduce(
|
|
162
|
-
(sum, val) => sum + val,
|
|
163
|
-
0
|
|
164
|
-
);
|
|
153
|
+
qty = Object.values(companySummary).reduce((sum, val) => sum + val, 0);
|
|
165
154
|
}
|
|
166
155
|
if (round) {
|
|
167
156
|
qty = Math.round(qty);
|
|
@@ -201,6 +190,15 @@ function generateBreadcrumbJsonLd(items) {
|
|
|
201
190
|
};
|
|
202
191
|
}
|
|
203
192
|
|
|
193
|
+
// src/result.ts
|
|
194
|
+
function unwrap(result) {
|
|
195
|
+
if (!result.ok) throw new Error(result.error || "Action failed");
|
|
196
|
+
return result.data;
|
|
197
|
+
}
|
|
198
|
+
function unwrapOr(result) {
|
|
199
|
+
return result.ok ? result.data ?? null : null;
|
|
200
|
+
}
|
|
201
|
+
|
|
204
202
|
// src/image.ts
|
|
205
203
|
var BLUR_DATA_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mN88P/BfwYABQoBfqVKzQAAAABJRU5ErkJggg==";
|
|
206
204
|
var CDN_BASE = "https://agr.media";
|
|
@@ -315,6 +313,8 @@ export {
|
|
|
315
313
|
resolveStock,
|
|
316
314
|
sanitizeHtmlImages,
|
|
317
315
|
serializeTransforms,
|
|
318
|
-
transformShipToAddress
|
|
316
|
+
transformShipToAddress,
|
|
317
|
+
unwrap,
|
|
318
|
+
unwrapOr
|
|
319
319
|
};
|
|
320
320
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cache-config.ts","../src/format-price.ts","../src/address-comparison.ts","../src/get-payment-status.ts","../src/transform-ship-to-address.ts","../src/build-checkout-payload.ts","../src/derive-price.ts","../src/resolve-stock.ts","../src/schema-availability.ts","../src/json-ld.ts","../src/image.ts"],"sourcesContent":["/**\n * Centralized cache configuration for React Query (TanStack Query)\n *\n * staleTime -- How long cached data is considered \"fresh\". While fresh,\n * React Query serves the cache instantly and does NOT refetch in the\n * background. After staleTime expires the data is \"stale\" and will be\n * refetched on the next access (mount, window focus, etc.).\n *\n * gcTime (garbage collection time) -- How long UNUSED cached data stays in\n * memory after all components using it unmount. Once gcTime expires the\n * cache entry is deleted entirely.\n *\n * STATIC (1h): categories, menus, item details\n * SEMI_STATIC (10m): pricing, stock, search results\n * DYNAMIC (5m): infinite scroll data\n * CART (2m): cart lines, cart header\n * REALTIME (0): active orders, checkout state\n */\nexport const CACHE_CONFIG = {\n STATIC: {\n staleTime: 1000 * 60 * 60, // 1 hour\n gcTime: 1000 * 60 * 60 * 24, // 24 hours\n },\n SEMI_STATIC: {\n staleTime: 1000 * 60 * 10, // 10 minutes\n gcTime: 1000 * 60 * 60 * 4, // 4 hours\n },\n DYNAMIC: {\n staleTime: 1000 * 60 * 5, // 5 minutes\n gcTime: 1000 * 60 * 30, // 30 minutes\n },\n CART: {\n staleTime: 1000 * 60 * 2, // 2 minutes\n gcTime: 1000 * 60 * 30, // 30 minutes\n },\n REALTIME: {\n staleTime: 0,\n gcTime: 1000 * 60 * 5, // 5 minutes\n },\n} as const;\n\nexport type CacheTier = keyof typeof CACHE_CONFIG;\n","/**\n * Locale-aware currency formatting.\n * Defaults to USD -- consumers can override locale and currency.\n */\nexport function formatPrice(\n price: number,\n locale: string = \"en-US\",\n currency: string = \"USD\",\n): string {\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency,\n minimumFractionDigits: 2,\n }).format(price);\n}\n","import type { TSmartyStreets } from \"./types/smarty-streets\";\n\n/** User-entered address fields for comparison. */\nexport interface UserAddress {\n address1: string;\n city: string;\n state: string;\n postalCode: string;\n}\n\n/**\n * Compares a user-entered address with a SmartyStreets-validated address.\n * Returns true if any field differs (case-insensitive for address/city,\n * exact match for state abbreviation and zip code).\n *\n * Used in checkout to prompt users when their input differs from the\n * USPS-validated address.\n */\nexport function isAddressDifferent(\n userAddress: UserAddress,\n smartyAddress: TSmartyStreets,\n): boolean {\n return (\n smartyAddress.deliveryLine1.toLowerCase() !== userAddress.address1.toLowerCase() ||\n smartyAddress.cityName.toLowerCase() !== userAddress.city.toLowerCase() ||\n smartyAddress.stateAbbreviation !== userAddress.state ||\n smartyAddress.zipCode !== userAddress.postalCode\n );\n}\n","export type PaymentStatusInvoice = {\n paidInFullFlag?: string | null;\n amountPaid?: number;\n totalAmount?: number;\n};\n\nexport type PaymentStatus = \"Paid\" | \"Partially Paid\" | \"Unpaid\";\n\nexport function getPaymentStatus(invoice: PaymentStatusInvoice): PaymentStatus {\n if (invoice.paidInFullFlag === \"Y\") return \"Paid\";\n if (\n invoice.amountPaid != null &&\n invoice.totalAmount != null &&\n invoice.amountPaid > 0\n )\n return \"Partially Paid\";\n return \"Unpaid\";\n}\n","export type ShipToAddress = {\n shipToId: string | number;\n name: string;\n address1: string;\n address2?: string;\n city: string;\n state: string;\n zip: string;\n country?: string;\n};\n\ntype RawShipTo = Record<string, unknown>;\n\nfunction str(value: unknown): string {\n if (value == null) return \"\";\n return String(value).trim();\n}\n\nfunction pick(raw: RawShipTo, keys: string[]): string {\n for (const k of keys) {\n if (raw[k] != null) return str(raw[k]);\n }\n return \"\";\n}\n\nconst PHYS_FIELDS = {\n address1: [\"physAddress1\", \"phys_address1\"],\n address2: [\"physAddress2\", \"phys_address2\"],\n city: [\"physCity\", \"phys_city\"],\n state: [\"physState\", \"phys_state\"],\n zip: [\"physPostalCode\", \"phys_postal_code\"],\n country: [\"physCountry\", \"phys_country\"],\n} as const;\n\nconst MAIL_FIELDS = {\n address1: [\"mailAddress1\", \"mail_address1\", \"address1\"],\n address2: [\"mailAddress2\", \"mail_address2\", \"address2\"],\n city: [\"mailCity\", \"mail_city\", \"city\"],\n state: [\"mailState\", \"mail_state\", \"state\"],\n zip: [\"mailPostalCode\", \"mail_postal_code\", \"postalCode\", \"zip\"],\n country: [\"mailCountry\", \"mail_country\", \"country\"],\n} as const;\n\nexport function transformShipToAddress(raw: RawShipTo): ShipToAddress {\n const isPhys =\n raw.physAddress1 != null ||\n raw.physCity != null ||\n raw.physState != null;\n\n const f = isPhys ? PHYS_FIELDS : MAIL_FIELDS;\n\n const address: ShipToAddress = {\n shipToId: (raw.shipToId ?? raw.ship_to_id ?? raw.id ?? \"\") as\n | string\n | number,\n name: str(raw.shipToName ?? raw.ship_to_name ?? raw.name ?? \"\"),\n address1: pick(raw, [...f.address1]),\n city: pick(raw, [...f.city]),\n state: pick(raw, [...f.state]),\n zip: pick(raw, [...f.zip]),\n };\n\n const address2 = pick(raw, [...f.address2]);\n if (address2) address.address2 = address2;\n\n const country = pick(raw, [...f.country]);\n if (country) address.country = country;\n\n return address;\n}\n","import type { TCartLine } from \"./types/cart\";\n\nexport type OeHdr = {\n customer_id: number;\n company_id: string;\n sales_location_id: number;\n user_id: number;\n user_email: string;\n taker: string;\n customer_po_no?: string;\n ship_to_id?: string | number;\n delivery_instructions?: string;\n};\n\nexport type OeLine = {\n item_id: string;\n unit_quantity: number;\n unit_of_measure: string;\n inv_mast_uid: number;\n unit_price?: number;\n};\n\nexport type CheckoutInput = {\n customerId: number;\n companyId: string;\n salesLocationId: number;\n userId: number;\n userEmail: string;\n taker?: string;\n cartLines: TCartLine[];\n poNumber?: string;\n shipToId?: string | number;\n deliveryInstructions?: string;\n};\n\nexport function buildCheckoutPayload(input: CheckoutInput): {\n oe_hdr: OeHdr;\n oe_line: OeLine[];\n} {\n const oe_hdr: OeHdr = {\n customer_id: input.customerId,\n company_id: input.companyId,\n sales_location_id: input.salesLocationId,\n user_id: input.userId,\n user_email: input.userEmail,\n taker: input.taker ?? \"ESTORE\",\n };\n\n if (input.poNumber != null) oe_hdr.customer_po_no = input.poNumber;\n if (input.shipToId != null) oe_hdr.ship_to_id = input.shipToId;\n if (input.deliveryInstructions != null)\n oe_hdr.delivery_instructions = input.deliveryInstructions;\n\n const oe_line: OeLine[] = input.cartLines.map((line) => {\n const oeLine: OeLine = {\n item_id: line.itemId,\n unit_quantity: line.quantity,\n unit_of_measure: line.unitOfMeasure,\n inv_mast_uid: line.invMastUid,\n };\n if (line.unitPrice != null) oeLine.unit_price = line.unitPrice;\n return oeLine;\n });\n\n return { oe_hdr, oe_line };\n}\n","import type { TPriceData } from \"./types/pricing\";\n\nexport interface DerivedPrice {\n unitPrice: number;\n unitOfMeasure: string;\n total: number;\n isCallForPrice: boolean;\n}\n\nexport interface DerivePriceInput {\n priceData: TPriceData | null | undefined;\n quantity?: number;\n}\n\n/**\n * Pure price derivation — usable in hooks AND server components.\n *\n * Returns `null` when `priceData` is missing (loading / error state).\n */\nexport function derivePrice(input: DerivePriceInput): DerivedPrice | null {\n const { priceData, quantity = 1 } = input;\n\n if (!priceData) return null;\n\n const unitPrice = priceData.unitPrice ?? 0;\n const unitOfMeasure =\n priceData.unitOfMeasure || priceData.item?.unitOfMeasure || \"\";\n\n return {\n unitPrice,\n unitOfMeasure,\n total: unitPrice * quantity,\n isCallForPrice: unitPrice === 0,\n };\n}\n","import type { TStock } from \"./types/inventory\";\n\nexport interface ResolveStockInput {\n stock: TStock | null | undefined;\n companyKey?: string;\n round?: boolean;\n lowStockThreshold?: number;\n showQuantity?: boolean;\n}\n\nexport interface ResolvedStock {\n quantity: number;\n isInStock: boolean;\n isLowStock: boolean;\n displayQuantity: number | null;\n}\n\n/**\n * Pure stock resolution -- usable in hooks AND server components.\n *\n * Returns `null` when `stock` is missing (loading / error state).\n */\nexport function resolveStock(input: ResolveStockInput): ResolvedStock | null {\n const {\n stock,\n companyKey,\n round = false,\n lowStockThreshold = 0,\n showQuantity = false,\n } = input;\n\n if (!stock) return null;\n\n const { companySummary } = stock;\n let qty: number;\n\n if (companyKey && companyKey in companySummary) {\n qty = companySummary[companyKey] ?? 0;\n } else {\n qty = Object.values(companySummary).reduce(\n (sum: number, val: number) => sum + val,\n 0,\n );\n }\n\n if (round) {\n qty = Math.round(qty);\n }\n\n const isInStock = qty > 0;\n const isLowStock = isInStock && lowStockThreshold > 0 && qty <= lowStockThreshold;\n\n return {\n quantity: qty,\n isInStock,\n isLowStock,\n displayQuantity: showQuantity ? qty : null,\n };\n}\n","import type { ResolvedStock } from \"./resolve-stock\";\n\nexport type SchemaAvailability =\n | \"https://schema.org/InStock\"\n | \"https://schema.org/OutOfStock\"\n | \"https://schema.org/LimitedAvailability\";\n\n/**\n * Maps resolved stock to a Schema.org availability URL.\n *\n * Returns `\"https://schema.org/OutOfStock\"` when `resolved` is null/undefined.\n */\nexport function getSchemaAvailability(\n resolved: ResolvedStock | null | undefined,\n): SchemaAvailability {\n if (!resolved || !resolved.isInStock) {\n return \"https://schema.org/OutOfStock\";\n }\n\n if (resolved.isLowStock) {\n return \"https://schema.org/LimitedAvailability\";\n }\n\n return \"https://schema.org/InStock\";\n}\n","export interface BreadcrumbJsonLdItem {\n name: string;\n url: string;\n}\n\nexport function generateBreadcrumbJsonLd(\n items: BreadcrumbJsonLdItem[],\n): Record<string, unknown> {\n return {\n \"@context\": \"https://schema.org\",\n \"@type\": \"BreadcrumbList\",\n itemListElement: items.map((item, index) => ({\n \"@type\": \"ListItem\",\n position: index + 1,\n name: item.name,\n item: item.url,\n })),\n };\n}\n","/**\n * Image CDN utilities for agr.media.\n * Pure functions -- no DOM or React dependencies. Safe for server, web, and mobile.\n */\n\n/** 1x1 transparent PNG for Next.js `<Image blurDataURL={...}>` placeholders. */\nexport const BLUR_DATA_URL =\n \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mN88P/BfwYABQoBfqVKzQAAAABJRU5ErkJggg==\";\n\nexport interface ImageTransforms {\n width?: number;\n height?: number;\n format?: \"auto\" | \"webp\" | \"avif\" | \"jpeg\" | \"jpg\" | \"png\";\n quality?: number;\n fit?: \"cover\" | \"contain\" | \"fill\" | \"inside\" | \"outside\";\n}\n\nexport interface ImageConfig {\n readonly clientDomain: string;\n readonly defaultImage?: string;\n readonly defaultTransforms?: ImageTransforms;\n readonly stripPrefixes?: string[];\n readonly defaultPath?: string;\n}\n\nexport interface ImageUrlOptions {\n defaultImage?: string;\n}\n\nconst CDN_BASE = \"https://agr.media\";\n\nconst TRANSFORM_KEY_MAP: Record<string, string> = {\n width: \"w\",\n height: \"h\",\n format: \"f\",\n quality: \"q\",\n fit: \"fit\",\n};\n\n/**\n * Creates a frozen ImageConfig object.\n */\nconst DEFAULT_STRIP_PREFIXES = [\"/images\", \"images\"];\n\n/**\n * Creates a frozen ImageConfig object.\n *\n * `stripPrefixes` defaults to `[\"/images\", \"images\"]` — set to `[]` to disable.\n */\nexport function createImageConfig(\n clientDomain: string,\n opts?: {\n defaultImage?: string;\n defaultTransforms?: ImageTransforms;\n stripPrefixes?: string[];\n defaultPath?: string;\n },\n): ImageConfig {\n return Object.freeze({\n clientDomain,\n defaultImage: opts?.defaultImage,\n defaultTransforms: opts?.defaultTransforms,\n stripPrefixes: opts?.stripPrefixes ?? DEFAULT_STRIP_PREFIXES,\n defaultPath: opts?.defaultPath,\n });\n}\n\n/**\n * Serializes transform options into the CDN path segment.\n * Example: `{ width: 400, format: \"webp\" }` → `\"w_400,f_webp\"`\n */\nexport function serializeTransforms(transforms: ImageTransforms): string {\n const parts: string[] = [];\n for (const [key, value] of Object.entries(transforms)) {\n if (value === undefined) continue;\n const prefix = TRANSFORM_KEY_MAP[key];\n if (prefix) {\n // Normalize \"jpg\" → \"jpeg\" for CDN compatibility\n const v = key === \"format\" && value === \"jpg\" ? \"jpeg\" : value;\n parts.push(`${prefix}_${v}`);\n }\n }\n return parts.join(\",\");\n}\n\n/**\n * Normalizes an image path by:\n * 1. Returning it as-is if it starts with `http` (external URL).\n * 2. Stripping configured prefixes (defaults: `/images`, `images`).\n * 3. Prepending `defaultPath` for bare filenames (no `/`).\n * 4. Stripping leading slashes.\n */\nexport function normalizePath(config: ImageConfig, raw: string): string {\n if (raw.startsWith(\"http\")) return raw;\n\n let cleaned = raw;\n const prefixes = config.stripPrefixes ?? DEFAULT_STRIP_PREFIXES;\n for (const prefix of prefixes) {\n if (cleaned.startsWith(prefix)) {\n cleaned = cleaned.slice(prefix.length);\n break;\n }\n }\n\n // Strip leading slashes\n cleaned = cleaned.replace(/^\\/+/, \"\");\n\n // Bare filename — prepend defaultPath\n if (config.defaultPath && !cleaned.includes(\"/\")) {\n cleaned = `${config.defaultPath}/${cleaned}`;\n }\n\n return cleaned;\n}\n\n/**\n * Builds a full agr.media URL for the given image path and transforms.\n *\n * - Empty/nullish paths return the default image URL.\n * - Paths starting with `http` are returned as-is (external CDN).\n * - Configured prefixes (default: `/images`) are stripped automatically.\n * - Bare filenames are prepended with `config.defaultPath` if set.\n */\nexport function getImageUrl(\n config: ImageConfig,\n imagePath: string | undefined | null,\n transforms?: ImageTransforms,\n options?: ImageUrlOptions,\n): string {\n const resolvedPath = imagePath?.trim();\n if (!resolvedPath) {\n return getDefaultImageUrl(config, options);\n }\n\n const normalized = normalizePath(config, resolvedPath);\n\n // External URL — pass through\n if (normalized.startsWith(\"http\")) return normalized;\n\n const merged: ImageTransforms = {\n ...config.defaultTransforms,\n ...transforms,\n };\n const serialized = serializeTransforms(merged);\n const transformSegment = serialized ? `/${serialized}` : \"\";\n\n return `${CDN_BASE}/${config.clientDomain}/images${transformSegment}/${normalized}`;\n}\n\n/**\n * Returns the default/placeholder image URL.\n * Per-call `options.defaultImage` overrides `config.defaultImage`.\n */\nexport function getDefaultImageUrl(\n config: ImageConfig,\n options?: ImageUrlOptions,\n): string {\n const fallback = options?.defaultImage ?? config.defaultImage;\n if (!fallback) return \"\";\n const normalized = normalizePath(config, fallback);\n if (normalized.startsWith(\"http\")) return normalized;\n return `${CDN_BASE}/${config.clientDomain}/images/${normalized}`;\n}\n\n/**\n * Generates a `srcset` string for responsive images.\n */\nexport function getImageSrcSet(\n config: ImageConfig,\n imagePath: string,\n widths: number[],\n transforms?: ImageTransforms,\n): string {\n return widths\n .map((w) => {\n const url = getImageUrl(config, imagePath, { ...transforms, width: w });\n return `${url} ${w}w`;\n })\n .join(\", \");\n}\n\n/**\n * Returns a loader function compatible with Next.js `<Image loader={...}>`.\n */\nexport function buildImageLoader(\n config: ImageConfig,\n transforms?: ImageTransforms,\n): (props: { src: string; width: number; quality?: number }) => string {\n return ({ src, width, quality }) => {\n const merged: ImageTransforms = { ...transforms, width };\n if (quality !== undefined) {\n merged.quality = quality;\n }\n return getImageUrl(config, src, merged);\n };\n}\n\n/**\n * Rewrites `<img src=\"...\">` attributes in an HTML string to use agr.media URLs.\n * Useful for CMS/Joomla content that contains raw image references.\n */\nexport function sanitizeHtmlImages(\n config: ImageConfig,\n html: string,\n transforms?: ImageTransforms,\n): string {\n return html.replace(\n /<img\\s([^>]*?)src=[\"']([^\"']+)[\"']/gi,\n (_match, before: string, src: string) => {\n const cdnUrl = getImageUrl(config, src, transforms);\n return `<img ${before}src=\"${cdnUrl}\"`;\n },\n );\n}\n"],"mappings":";;;;;AAkBO,IAAM,eAAe;AAAA,EAC1B,QAAQ;AAAA,I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QACA,SACQ;AACR,QAAM,WAAW,SAAS,gBAAgB,OAAO;AACjD,MAAI,CAAC,SAAU,QAAO;AACtB,QAAM,aAAa,cAAc,QAAQ,QAAQ;AACjD,MAAI,WAAW,WAAW,MAAM,EAAG,QAAO;AAC1C,SAAO,GAAG,QAAQ,IAAI,OAAO,YAAY,WAAW,UAAU;AAChE;AAKO,SAAS,eACd,QACA,WACA,QACA,YACQ;AACR,SAAO,OACJ,IAAI,CAAC,MAAM;AACV,UAAM,MAAM,YAAY,QAAQ,WAAW,EAAE,GAAG,YAAY,OAAO,EAAE,CAAC;AACtE,WAAO,GAAG,GAAG,IAAI,CAAC;AAAA,EACpB,CAAC,EACA,KAAK,IAAI;AACd;AAKO,SAAS,iBACd,QACA,YACqE;AACrE,SAAO,CAAC,EAAE,KAAK,OAAO,QAAQ,MAAM;AAClC,UAAM,SAA0B,EAAE,GAAG,YAAY,MAAM;AACvD,QAAI,YAAY,QAAW;AACzB,aAAO,UAAU;AAAA,IACnB;AACA,WAAO,YAAY,QAAQ,KAAK,MAAM;AAAA,EACxC;AACF;AAMO,SAAS,mBACd,QACA,MACA,YACQ;AACR,SAAO,KAAK;AAAA,IACV;AAAA,IACA,CAAC,QAAQ,QAAgB,QAAgB;AACvC,YAAM,SAAS,YAAY,QAAQ,KAAK,UAAU;AAClD,aAAO,QAAQ,MAAM,QAAQ,MAAM;AAAA,IACrC;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/cache-config.ts","../src/format-price.ts","../src/address-comparison.ts","../src/get-payment-status.ts","../src/transform-ship-to-address.ts","../src/build-checkout-payload.ts","../src/derive-price.ts","../src/resolve-stock.ts","../src/schema-availability.ts","../src/json-ld.ts","../src/result.ts","../src/image.ts"],"sourcesContent":["/**\n * Centralized cache configuration for React Query (TanStack Query)\n *\n * staleTime -- How long cached data is considered \"fresh\". While fresh,\n * React Query serves the cache instantly and does NOT refetch in the\n * background. After staleTime expires the data is \"stale\" and will be\n * refetched on the next access (mount, window focus, etc.).\n *\n * gcTime (garbage collection time) -- How long UNUSED cached data stays in\n * memory after all components using it unmount. Once gcTime expires the\n * cache entry is deleted entirely.\n *\n * STATIC (1h): categories, menus, item details\n * SEMI_STATIC (10m): pricing, stock, search results\n * DYNAMIC (5m): infinite scroll data\n * CART (2m): cart lines, cart header\n * REALTIME (0): active orders, checkout state\n */\nexport const CACHE_CONFIG = {\n STATIC: {\n staleTime: 1000 * 60 * 60, // 1 hour\n gcTime: 1000 * 60 * 60 * 24, // 24 hours\n },\n SEMI_STATIC: {\n staleTime: 1000 * 60 * 10, // 10 minutes\n gcTime: 1000 * 60 * 60 * 4, // 4 hours\n },\n DYNAMIC: {\n staleTime: 1000 * 60 * 5, // 5 minutes\n gcTime: 1000 * 60 * 30, // 30 minutes\n },\n CART: {\n staleTime: 1000 * 60 * 2, // 2 minutes\n gcTime: 1000 * 60 * 30, // 30 minutes\n },\n REALTIME: {\n staleTime: 0,\n gcTime: 1000 * 60 * 5, // 5 minutes\n },\n} as const;\n\nexport type CacheTier = keyof typeof CACHE_CONFIG;\n","/**\n * Locale-aware currency formatting.\n * Defaults to USD -- consumers can override locale and currency.\n */\nexport function formatPrice(\n price: number,\n locale: string = \"en-US\",\n currency: string = \"USD\",\n): string {\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency,\n minimumFractionDigits: 2,\n }).format(price);\n}\n","import type { TSmartyStreets } from \"./types/smarty-streets\";\n\n/** User-entered address fields for comparison. */\nexport interface UserAddress {\n address1: string;\n city: string;\n state: string;\n postalCode: string;\n}\n\n/**\n * Compares a user-entered address with a SmartyStreets-validated address.\n * Returns true if any field differs (case-insensitive for address/city,\n * exact match for state abbreviation and zip code).\n *\n * Used in checkout to prompt users when their input differs from the\n * USPS-validated address.\n */\nexport function isAddressDifferent(\n userAddress: UserAddress,\n smartyAddress: TSmartyStreets,\n): boolean {\n return (\n smartyAddress.deliveryLine1.toLowerCase() !== userAddress.address1.toLowerCase() ||\n smartyAddress.cityName.toLowerCase() !== userAddress.city.toLowerCase() ||\n smartyAddress.stateAbbreviation !== userAddress.state ||\n smartyAddress.zipCode !== userAddress.postalCode\n );\n}\n","export type PaymentStatusInvoice = {\n paidInFullFlag?: string | null;\n amountPaid?: number;\n totalAmount?: number;\n};\n\nexport type PaymentStatus = \"Paid\" | \"Partially Paid\" | \"Unpaid\";\n\nexport function getPaymentStatus(invoice: PaymentStatusInvoice): PaymentStatus {\n if (invoice.paidInFullFlag === \"Y\") return \"Paid\";\n if (invoice.amountPaid != null && invoice.totalAmount != null && invoice.amountPaid > 0)\n return \"Partially Paid\";\n return \"Unpaid\";\n}\n","export type ShipToAddress = {\n shipToId: string | number;\n name: string;\n address1: string;\n address2?: string;\n city: string;\n state: string;\n zip: string;\n country?: string;\n};\n\ntype RawShipTo = Record<string, unknown>;\n\nfunction str(value: unknown): string {\n return String(value).trim();\n}\n\nfunction pick(raw: RawShipTo, keys: string[]): string {\n for (const k of keys) {\n if (raw[k] != null) return str(raw[k]);\n }\n return \"\";\n}\n\nconst PHYS_FIELDS = {\n address1: [\"physAddress1\", \"phys_address1\"],\n address2: [\"physAddress2\", \"phys_address2\"],\n city: [\"physCity\", \"phys_city\"],\n state: [\"physState\", \"phys_state\"],\n zip: [\"physPostalCode\", \"phys_postal_code\"],\n country: [\"physCountry\", \"phys_country\"],\n} as const;\n\nconst MAIL_FIELDS = {\n address1: [\"mailAddress1\", \"mail_address1\", \"address1\"],\n address2: [\"mailAddress2\", \"mail_address2\", \"address2\"],\n city: [\"mailCity\", \"mail_city\", \"city\"],\n state: [\"mailState\", \"mail_state\", \"state\"],\n zip: [\"mailPostalCode\", \"mail_postal_code\", \"postalCode\", \"zip\"],\n country: [\"mailCountry\", \"mail_country\", \"country\"],\n} as const;\n\nexport function transformShipToAddress(raw: RawShipTo): ShipToAddress {\n const isPhys = raw[\"physAddress1\"] != null || raw[\"physCity\"] != null || raw[\"physState\"] != null;\n\n const f = isPhys ? PHYS_FIELDS : MAIL_FIELDS;\n\n const address: ShipToAddress = {\n shipToId: (raw[\"shipToId\"] ?? raw[\"ship_to_id\"] ?? raw[\"id\"] ?? \"\") as string | number,\n name: str(raw[\"shipToName\"] ?? raw[\"ship_to_name\"] ?? raw[\"name\"] ?? \"\"),\n address1: pick(raw, [...f.address1]),\n city: pick(raw, [...f.city]),\n state: pick(raw, [...f.state]),\n zip: pick(raw, [...f.zip]),\n };\n\n const address2 = pick(raw, [...f.address2]);\n if (address2) address.address2 = address2;\n\n const country = pick(raw, [...f.country]);\n if (country) address.country = country;\n\n return address;\n}\n","import type { TCartLine } from \"./types/cart\";\n\nexport type OeHdr = {\n customer_id: number;\n company_id: string;\n sales_location_id: number;\n user_id: number;\n user_email: string;\n taker: string;\n customer_po_no?: string;\n ship_to_id?: string | number;\n delivery_instructions?: string;\n};\n\nexport type OeLine = {\n item_id: string;\n unit_quantity: number;\n unit_of_measure: string;\n inv_mast_uid: number;\n unit_price?: number;\n};\n\nexport type CheckoutInput = {\n customerId: number;\n companyId: string;\n salesLocationId: number;\n userId: number;\n userEmail: string;\n taker?: string;\n cartLines: TCartLine[];\n poNumber?: string;\n shipToId?: string | number;\n deliveryInstructions?: string;\n};\n\nexport function buildCheckoutPayload(input: CheckoutInput): {\n oe_hdr: OeHdr;\n oe_line: OeLine[];\n} {\n const oe_hdr: OeHdr = {\n customer_id: input.customerId,\n company_id: input.companyId,\n sales_location_id: input.salesLocationId,\n user_id: input.userId,\n user_email: input.userEmail,\n taker: input.taker ?? \"ESTORE\",\n };\n\n if (input.poNumber != null) oe_hdr.customer_po_no = input.poNumber;\n if (input.shipToId != null) oe_hdr.ship_to_id = input.shipToId;\n if (input.deliveryInstructions != null) oe_hdr.delivery_instructions = input.deliveryInstructions;\n\n const oe_line: OeLine[] = input.cartLines.map((line) => {\n const oeLine: OeLine = {\n item_id: line.itemId,\n unit_quantity: line.quantity,\n unit_of_measure: line.unitOfMeasure,\n inv_mast_uid: line.invMastUid,\n };\n if (line.unitPrice != null) oeLine.unit_price = line.unitPrice;\n return oeLine;\n });\n\n return { oe_hdr, oe_line };\n}\n","import type { TPriceData } from \"./types/pricing\";\n\nexport interface DerivedPrice {\n unitPrice: number;\n unitOfMeasure: string;\n total: number;\n isCallForPrice: boolean;\n}\n\nexport interface DerivePriceInput {\n priceData: TPriceData | null | undefined;\n quantity?: number;\n}\n\n/**\n * Pure price derivation — usable in hooks AND server components.\n *\n * Returns `null` when `priceData` is missing (loading / error state).\n */\nexport function derivePrice(input: DerivePriceInput): DerivedPrice | null {\n const { priceData, quantity = 1 } = input;\n\n if (!priceData) return null;\n\n const unitPrice = priceData.unitPrice ?? 0;\n const unitOfMeasure = priceData.unitOfMeasure || priceData.item?.unitOfMeasure || \"\";\n\n return {\n unitPrice,\n unitOfMeasure,\n total: unitPrice * quantity,\n isCallForPrice: unitPrice === 0,\n };\n}\n","import type { TStock } from \"./types/inventory\";\n\nexport interface ResolveStockInput {\n stock: TStock | null | undefined;\n companyKey?: string;\n round?: boolean;\n lowStockThreshold?: number;\n showQuantity?: boolean;\n}\n\nexport interface ResolvedStock {\n quantity: number;\n isInStock: boolean;\n isLowStock: boolean;\n displayQuantity: number | null;\n}\n\n/**\n * Pure stock resolution -- usable in hooks AND server components.\n *\n * Returns `null` when `stock` is missing (loading / error state).\n */\nexport function resolveStock(input: ResolveStockInput): ResolvedStock | null {\n const { stock, companyKey, round = false, lowStockThreshold = 0, showQuantity = false } = input;\n\n if (!stock) return null;\n\n const { companySummary } = stock;\n let qty: number;\n\n if (companyKey && companyKey in companySummary) {\n qty = companySummary[companyKey] ?? 0;\n } else {\n qty = Object.values(companySummary).reduce((sum: number, val: number) => sum + val, 0);\n }\n\n if (round) {\n qty = Math.round(qty);\n }\n\n const isInStock = qty > 0;\n const isLowStock = isInStock && lowStockThreshold > 0 && qty <= lowStockThreshold;\n\n return {\n quantity: qty,\n isInStock,\n isLowStock,\n displayQuantity: showQuantity ? qty : null,\n };\n}\n","import type { ResolvedStock } from \"./resolve-stock\";\n\nexport type SchemaAvailability =\n | \"https://schema.org/InStock\"\n | \"https://schema.org/OutOfStock\"\n | \"https://schema.org/LimitedAvailability\";\n\n/**\n * Maps resolved stock to a Schema.org availability URL.\n *\n * Returns `\"https://schema.org/OutOfStock\"` when `resolved` is null/undefined.\n */\nexport function getSchemaAvailability(\n resolved: ResolvedStock | null | undefined,\n): SchemaAvailability {\n if (!resolved || !resolved.isInStock) {\n return \"https://schema.org/OutOfStock\";\n }\n\n if (resolved.isLowStock) {\n return \"https://schema.org/LimitedAvailability\";\n }\n\n return \"https://schema.org/InStock\";\n}\n","export interface BreadcrumbJsonLdItem {\n name: string;\n url: string;\n}\n\nexport function generateBreadcrumbJsonLd(items: BreadcrumbJsonLdItem[]): Record<string, unknown> {\n return {\n \"@context\": \"https://schema.org\",\n \"@type\": \"BreadcrumbList\",\n itemListElement: items.map((item, index) => ({\n \"@type\": \"ListItem\",\n position: index + 1,\n name: item.name,\n item: item.url,\n })),\n };\n}\n","/** Result type for safe action wrappers. */\nexport type SafeActionResult<T> = { ok: true; data: T } | { ok: false; error: string };\n\n/**\n * Extracts the data from a `SafeActionResult`, throwing on error.\n *\n * Ideal for React Query `queryFn` where errors should propagate\n * to the error boundary.\n *\n * @example\n * ```ts\n * const cart = unwrap(await getCartLines(cartId));\n * ```\n */\nexport function unwrap<T>(result: SafeActionResult<T>): T {\n if (!result.ok) throw new Error(result.error || \"Action failed\");\n return result.data;\n}\n\n/**\n * Extracts the data from a `SafeActionResult`, returning `null` on error.\n *\n * For direct calls that prefer `null` over thrown errors.\n *\n * @example\n * ```ts\n * const cart = unwrapOr(await getCartLines(cartId));\n * if (!cart) { /* handle missing data *\\/ }\n * ```\n */\nexport function unwrapOr<T>(result: SafeActionResult<T>): T | null {\n return result.ok ? (result.data ?? null) : null;\n}\n","/**\n * Image CDN utilities for agr.media.\n * Pure functions -- no DOM or React dependencies. Safe for server, web, and mobile.\n */\n\n/** 1x1 transparent PNG for Next.js `<Image blurDataURL={...}>` placeholders. */\nexport const BLUR_DATA_URL =\n \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mN88P/BfwYABQoBfqVKzQAAAABJRU5ErkJggg==\";\n\nexport interface ImageTransforms {\n width?: number;\n height?: number;\n format?: \"auto\" | \"webp\" | \"avif\" | \"jpeg\" | \"jpg\" | \"png\";\n quality?: number;\n fit?: \"cover\" | \"contain\" | \"fill\" | \"inside\" | \"outside\";\n}\n\nexport interface ImageConfig {\n readonly clientDomain: string;\n readonly defaultImage?: string;\n readonly defaultTransforms?: ImageTransforms;\n readonly stripPrefixes?: string[];\n readonly defaultPath?: string;\n}\n\nexport interface ImageUrlOptions {\n defaultImage?: string;\n}\n\nconst CDN_BASE = \"https://agr.media\";\n\nconst TRANSFORM_KEY_MAP: Record<string, string> = {\n width: \"w\",\n height: \"h\",\n format: \"f\",\n quality: \"q\",\n fit: \"fit\",\n};\n\n/**\n * Creates a frozen ImageConfig object.\n */\nconst DEFAULT_STRIP_PREFIXES = [\"/images\", \"images\"];\n\n/**\n * Creates a frozen ImageConfig object.\n *\n * `stripPrefixes` defaults to `[\"/images\", \"images\"]` — set to `[]` to disable.\n */\nexport function createImageConfig(\n clientDomain: string,\n opts?: {\n defaultImage?: string;\n defaultTransforms?: ImageTransforms;\n stripPrefixes?: string[];\n defaultPath?: string;\n },\n): ImageConfig {\n return Object.freeze({\n clientDomain,\n defaultImage: opts?.defaultImage,\n defaultTransforms: opts?.defaultTransforms,\n stripPrefixes: opts?.stripPrefixes ?? DEFAULT_STRIP_PREFIXES,\n defaultPath: opts?.defaultPath,\n });\n}\n\n/**\n * Serializes transform options into the CDN path segment.\n * Example: `{ width: 400, format: \"webp\" }` → `\"w_400,f_webp\"`\n */\nexport function serializeTransforms(transforms: ImageTransforms): string {\n const parts: string[] = [];\n for (const [key, value] of Object.entries(transforms)) {\n if (value === undefined) continue;\n const prefix = TRANSFORM_KEY_MAP[key];\n if (prefix) {\n // Normalize \"jpg\" → \"jpeg\" for CDN compatibility\n const v = key === \"format\" && value === \"jpg\" ? \"jpeg\" : value;\n parts.push(`${prefix}_${v}`);\n }\n }\n return parts.join(\",\");\n}\n\n/**\n * Normalizes an image path by:\n * 1. Returning it as-is if it starts with `http` (external URL).\n * 2. Stripping configured prefixes (defaults: `/images`, `images`).\n * 3. Prepending `defaultPath` for bare filenames (no `/`).\n * 4. Stripping leading slashes.\n */\nexport function normalizePath(config: ImageConfig, raw: string): string {\n if (raw.startsWith(\"http\")) return raw;\n\n let cleaned = raw;\n const prefixes = config.stripPrefixes ?? DEFAULT_STRIP_PREFIXES;\n for (const prefix of prefixes) {\n if (cleaned.startsWith(prefix)) {\n cleaned = cleaned.slice(prefix.length);\n break;\n }\n }\n\n // Strip leading slashes\n cleaned = cleaned.replace(/^\\/+/, \"\");\n\n // Bare filename — prepend defaultPath\n if (config.defaultPath && !cleaned.includes(\"/\")) {\n cleaned = `${config.defaultPath}/${cleaned}`;\n }\n\n return cleaned;\n}\n\n/**\n * Builds a full agr.media URL for the given image path and transforms.\n *\n * - Empty/nullish paths return the default image URL.\n * - Paths starting with `http` are returned as-is (external CDN).\n * - Configured prefixes (default: `/images`) are stripped automatically.\n * - Bare filenames are prepended with `config.defaultPath` if set.\n */\nexport function getImageUrl(\n config: ImageConfig,\n imagePath: string | undefined | null,\n transforms?: ImageTransforms,\n options?: ImageUrlOptions,\n): string {\n const resolvedPath = imagePath?.trim();\n if (!resolvedPath) {\n return getDefaultImageUrl(config, options);\n }\n\n const normalized = normalizePath(config, resolvedPath);\n\n // External URL — pass through\n if (normalized.startsWith(\"http\")) return normalized;\n\n const merged: ImageTransforms = {\n ...config.defaultTransforms,\n ...transforms,\n };\n const serialized = serializeTransforms(merged);\n const transformSegment = serialized ? `/${serialized}` : \"\";\n\n return `${CDN_BASE}/${config.clientDomain}/images${transformSegment}/${normalized}`;\n}\n\n/**\n * Returns the default/placeholder image URL.\n * Per-call `options.defaultImage` overrides `config.defaultImage`.\n */\nexport function getDefaultImageUrl(config: ImageConfig, options?: ImageUrlOptions): string {\n const fallback = options?.defaultImage ?? config.defaultImage;\n if (!fallback) return \"\";\n const normalized = normalizePath(config, fallback);\n if (normalized.startsWith(\"http\")) return normalized;\n return `${CDN_BASE}/${config.clientDomain}/images/${normalized}`;\n}\n\n/**\n * Generates a `srcset` string for responsive images.\n */\nexport function getImageSrcSet(\n config: ImageConfig,\n imagePath: string,\n widths: number[],\n transforms?: ImageTransforms,\n): string {\n return widths\n .map((w) => {\n const url = getImageUrl(config, imagePath, { ...transforms, width: w });\n return `${url} ${w}w`;\n })\n .join(\", \");\n}\n\n/**\n * Returns a loader function compatible with Next.js `<Image loader={...}>`.\n */\nexport function buildImageLoader(\n config: ImageConfig,\n transforms?: ImageTransforms,\n): (props: { src: string; width: number; quality?: number }) => string {\n return ({ src, width, quality }) => {\n const merged: ImageTransforms = { ...transforms, width };\n if (quality !== undefined) {\n merged.quality = quality;\n }\n return getImageUrl(config, src, merged);\n };\n}\n\n/**\n * Rewrites `<img src=\"...\">` attributes in an HTML string to use agr.media URLs.\n * Useful for CMS/Joomla content that contains raw image references.\n */\nexport function sanitizeHtmlImages(\n config: ImageConfig,\n html: string,\n transforms?: ImageTransforms,\n): string {\n return html.replace(\n /<img\\s([^>]*?)src=[\"']([^\"']+)[\"']/gi,\n (_match, before: string, src: string) => {\n const cdnUrl = getImageUrl(config, src, transforms);\n return `<img ${before}src=\"${cdnUrl}\"`;\n },\n );\n}\n"],"mappings":";;;;;AAkBO,IAAM,eAAe;AAAA,EAC1B,QAAQ;AAAA,IACN,WAAW,MAAO,KAAK;AAAA;AAAA,IACvB,QAAQ,MAAO,KAAK,KAAK;AAAA;AAAA,EAC3B;AAAA,EACA,aAAa;AAAA,IACX,WAAW,MAAO,KAAK;AAAA;AAAA,IACvB,QAAQ,MAAO,KAAK,KAAK;AAAA;AAAA,EAC3B;AAAA,EACA,SAAS;AAAA,IACP,WAAW,MAAO,KAAK;AAAA;AAAA,IACvB,Q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AO;AACtB,QAAM,aAAa,cAAc,QAAQ,QAAQ;AACjD,MAAI,WAAW,WAAW,MAAM,EAAG,QAAO;AAC1C,SAAO,GAAG,QAAQ,IAAI,OAAO,YAAY,WAAW,UAAU;AAChE;AAKO,SAAS,eACd,QACA,WACA,QACA,YACQ;AACR,SAAO,OACJ,IAAI,CAAC,MAAM;AACV,UAAM,MAAM,YAAY,QAAQ,WAAW,EAAE,GAAG,YAAY,OAAO,EAAE,CAAC;AACtE,WAAO,GAAG,GAAG,IAAI,CAAC;AAAA,EACpB,CAAC,EACA,KAAK,IAAI;AACd;AAKO,SAAS,iBACd,QACA,YACqE;AACrE,SAAO,CAAC,EAAE,KAAK,OAAO,QAAQ,MAAM;AAClC,UAAM,SAA0B,EAAE,GAAG,YAAY,MAAM;AACvD,QAAI,YAAY,QAAW;AACzB,aAAO,UAAU;AAAA,IACnB;AACA,WAAO,YAAY,QAAQ,KAAK,MAAM;AAAA,EACxC;AACF;AAMO,SAAS,mBACd,QACA,MACA,YACQ;AACR,SAAO,KAAK;AAAA,IACV;AAAA,IACA,CAAC,QAAQ,QAAgB,QAAgB;AACvC,YAAM,SAAS,YAAY,QAAQ,KAAK,UAAU;AAClD,aAAO,QAAQ,MAAM,QAAQ,MAAM;AAAA,IACrC;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simpleapps-com/augur-utils",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
4
|
"description": "Shared types, cache configuration, and utility functions for Augur ecommerce sites",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,9 +25,7 @@
|
|
|
25
25
|
"files": [
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"valibot": "^1.0.0"
|
|
30
|
-
},
|
|
28
|
+
"dependencies": {},
|
|
31
29
|
"peerDependencies": {
|
|
32
30
|
"clsx": "^2.1.0",
|
|
33
31
|
"tailwind-merge": "^2.0.0 || ^3.0.0"
|
|
@@ -53,6 +51,7 @@
|
|
|
53
51
|
"dev": "tsup --watch",
|
|
54
52
|
"lint": "eslint src/",
|
|
55
53
|
"test": "vitest run --passWithNoTests --coverage",
|
|
56
|
-
"typecheck": "tsc --noEmit"
|
|
54
|
+
"typecheck": "tsc --noEmit",
|
|
55
|
+
"check-exports": "publint"
|
|
57
56
|
}
|
|
58
57
|
}
|