@simpleapps-com/augur-utils 2.3.1 → 2026.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/EXPORTS.md +24 -31
- package/README.md +19 -180
- package/dist/address-comparison.d.ts +18 -0
- package/dist/address-comparison.d.ts.map +1 -0
- package/dist/address-schemas.d.ts +45 -0
- package/dist/address-schemas.d.ts.map +1 -0
- package/dist/analytics.d.ts +66 -0
- package/dist/analytics.d.ts.map +1 -0
- package/dist/build-checkout-payload.d.ts +37 -0
- package/dist/build-checkout-payload.d.ts.map +1 -0
- package/dist/cache-config.d.ts +42 -0
- package/dist/cache-config.d.ts.map +1 -0
- package/dist/chunk-5UMFBGVA.cjs.map +1 -1
- package/dist/date-helpers.d.ts +16 -0
- package/dist/date-helpers.d.ts.map +1 -0
- package/dist/derive-price.d.ts +49 -0
- package/dist/derive-price.d.ts.map +1 -0
- package/dist/format-price.d.ts +6 -0
- package/dist/format-price.d.ts.map +1 -0
- package/dist/get-payment-status.d.ts +10 -0
- package/dist/get-payment-status.d.ts.map +1 -0
- package/dist/image-rules.d.ts +70 -0
- package/dist/image-rules.d.ts.map +1 -0
- package/dist/image.d.ts +80 -0
- package/dist/image.d.ts.map +1 -0
- package/dist/index.cjs +385 -171
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +63 -1409
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +374 -160
- package/dist/index.js.map +1 -1
- package/dist/json-ld-rules.d.ts +50 -0
- package/dist/json-ld-rules.d.ts.map +1 -0
- package/dist/json-ld.d.ts +34 -0
- package/dist/json-ld.d.ts.map +1 -0
- package/dist/money.d.ts +37 -0
- package/dist/money.d.ts.map +1 -0
- package/dist/price-breaks.d.ts +16 -0
- package/dist/price-breaks.d.ts.map +1 -0
- package/dist/price-outcome.d.ts +19 -0
- package/dist/price-outcome.d.ts.map +1 -0
- package/dist/resolve-stock.d.ts +22 -0
- package/dist/resolve-stock.d.ts.map +1 -0
- package/dist/result.d.ts +33 -0
- package/dist/result.d.ts.map +1 -0
- package/dist/rules.d.ts +45 -0
- package/dist/rules.d.ts.map +1 -0
- package/dist/schema-availability.d.ts +11 -0
- package/dist/schema-availability.d.ts.map +1 -0
- package/dist/transform-ship-to-address.d.ts +15 -0
- package/dist/transform-ship-to-address.d.ts.map +1 -0
- package/dist/transforms.d.ts +70 -0
- package/dist/transforms.d.ts.map +1 -0
- package/dist/types/api.d.ts +8 -0
- package/dist/types/api.d.ts.map +1 -0
- package/dist/types/attribute.d.ts +12 -0
- package/dist/types/attribute.d.ts.map +1 -0
- package/dist/types/cart.d.ts +25 -0
- package/dist/types/cart.d.ts.map +1 -0
- package/dist/types/category-items.d.ts +4 -0
- package/dist/types/category-items.d.ts.map +1 -0
- package/dist/types/category.d.ts +19 -0
- package/dist/types/category.d.ts.map +1 -0
- package/dist/types/checkout.d.ts +4 -0
- package/dist/types/checkout.d.ts.map +1 -0
- package/dist/types/customer.d.ts +4 -0
- package/dist/types/customer.d.ts.map +1 -0
- package/dist/types/filter.d.ts +9 -0
- package/dist/types/filter.d.ts.map +1 -0
- package/dist/types/inventory.d.ts +10 -0
- package/dist/types/inventory.d.ts.map +1 -0
- package/dist/types/joomla.d.ts +11 -0
- package/dist/types/joomla.d.ts.map +1 -0
- package/dist/types/ltl-shipping.d.ts +45 -0
- package/dist/types/ltl-shipping.d.ts.map +1 -0
- package/dist/types/menu.d.ts +14 -0
- package/dist/types/menu.d.ts.map +1 -0
- package/dist/types/meta.d.ts +11 -0
- package/dist/types/meta.d.ts.map +1 -0
- package/dist/types/order.d.ts +72 -0
- package/dist/types/order.d.ts.map +1 -0
- package/dist/types/password.d.ts +7 -0
- package/dist/types/password.d.ts.map +1 -0
- package/dist/types/payment.d.ts +69 -0
- package/dist/types/payment.d.ts.map +1 -0
- package/dist/types/pricing.d.ts +25 -0
- package/dist/types/pricing.d.ts.map +1 -0
- package/dist/types/product.d.ts +58 -0
- package/dist/types/product.d.ts.map +1 -0
- package/dist/types/search.d.ts +16 -0
- package/dist/types/search.d.ts.map +1 -0
- package/dist/types/shipping.d.ts +4 -0
- package/dist/types/shipping.d.ts.map +1 -0
- package/dist/types/smarty-streets.d.ts +4 -0
- package/dist/types/smarty-streets.d.ts.map +1 -0
- package/dist/types/supplier.d.ts +4 -0
- package/dist/types/supplier.d.ts.map +1 -0
- package/dist/types/tax.d.ts +6 -0
- package/dist/types/tax.d.ts.map +1 -0
- package/dist/types/uom.d.ts +4 -0
- package/dist/types/uom.d.ts.map +1 -0
- package/dist/types/user-profile.d.ts +5 -0
- package/dist/types/user-profile.d.ts.map +1 -0
- package/dist/us-states.d.ts +15 -0
- package/dist/us-states.d.ts.map +1 -0
- package/dist/validation-patterns.d.ts +22 -0
- package/dist/validation-patterns.d.ts.map +1 -0
- package/dist/web.cjs.map +1 -1
- package/dist/web.d.ts +3 -5
- package/dist/web.d.ts.map +1 -0
- package/llms.txt +44 -38
- package/package.json +25 -13
- package/dist/index.d.cts +0 -1409
- package/dist/web.d.cts +0 -6
package/dist/index.cjs
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var _chunk5UMFBGVAcjs = require('./chunk-5UMFBGVA.cjs');
|
|
4
4
|
|
|
5
|
+
// src/price-breaks.ts
|
|
6
|
+
function hasPriceBreaks(libraryPriceData) {
|
|
7
|
+
return libraryPriceData !== null && Array.isArray(libraryPriceData.breaks);
|
|
8
|
+
}
|
|
9
|
+
|
|
5
10
|
// src/cache-config.ts
|
|
6
11
|
var CACHE_CONFIG = {
|
|
7
12
|
STATIC: {
|
|
@@ -44,29 +49,99 @@ function formatPrice(price, locale = "en-US", currency = "USD") {
|
|
|
44
49
|
}).format(price);
|
|
45
50
|
}
|
|
46
51
|
|
|
52
|
+
// src/rules.ts
|
|
53
|
+
function paymentStatusOf(paidInFull, hasAmounts, amountPaid) {
|
|
54
|
+
if (paidInFull) return "Paid";
|
|
55
|
+
if (hasAmounts && amountPaid > 0) return "Partially Paid";
|
|
56
|
+
return "Unpaid";
|
|
57
|
+
}
|
|
58
|
+
function isLowStockOf(quantity, threshold) {
|
|
59
|
+
return quantity > 0 && threshold > 0 && quantity <= threshold;
|
|
60
|
+
}
|
|
61
|
+
function allYesFrom(flags, i) {
|
|
62
|
+
if (i >= flags.length) return true;
|
|
63
|
+
return flags[i] === "Y" && allYesFrom(flags, i + 1);
|
|
64
|
+
}
|
|
65
|
+
function isDiscontinuedOf(flags) {
|
|
66
|
+
return flags.length > 0 && allYesFrom(flags, 0);
|
|
67
|
+
}
|
|
68
|
+
function categorySortBy(prefix, sortBy) {
|
|
69
|
+
return prefix !== "" && sortBy !== "" ? prefix + sortBy : sortBy;
|
|
70
|
+
}
|
|
71
|
+
function searchSortBy(sortBy) {
|
|
72
|
+
return sortBy !== "" ? sortBy : void 0;
|
|
73
|
+
}
|
|
74
|
+
function pageOffset(page, limit) {
|
|
75
|
+
return page * limit;
|
|
76
|
+
}
|
|
77
|
+
function unwrapMessage(error) {
|
|
78
|
+
return error !== "" ? error : "Action failed";
|
|
79
|
+
}
|
|
80
|
+
function shippingLeadOf(days) {
|
|
81
|
+
if (days === "1-2") return { from: 1, to: 4 };
|
|
82
|
+
if (days === "2") return { from: 4, to: 0 };
|
|
83
|
+
if (days === "2-3") return { from: 2, to: 5 };
|
|
84
|
+
if (days === "3") return { from: 5, to: 0 };
|
|
85
|
+
if (days === "3-4") return { from: 3, to: 6 };
|
|
86
|
+
if (days === "4") return { from: 6, to: 0 };
|
|
87
|
+
if (days === "5") return { from: 7, to: 0 };
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
function isBusinessDayName(dayName) {
|
|
91
|
+
return dayName !== "Sunday" && dayName !== "Saturday";
|
|
92
|
+
}
|
|
93
|
+
function availabilityOf(isInStock, isDiscontinued) {
|
|
94
|
+
if (isInStock) return "InStock";
|
|
95
|
+
if (isDiscontinued) return "OutOfStock";
|
|
96
|
+
return "BackOrder";
|
|
97
|
+
}
|
|
98
|
+
function takerOf(taker) {
|
|
99
|
+
return _nullishCoalesce(taker, () => ( "ESTORE"));
|
|
100
|
+
}
|
|
101
|
+
function addressDifferentOf(line1Same, citySame, stateSame, zipSame) {
|
|
102
|
+
return !line1Same || !citySame || !stateSame || !zipSame;
|
|
103
|
+
}
|
|
104
|
+
|
|
47
105
|
// src/address-comparison.ts
|
|
48
106
|
function isAddressDifferent(userAddress, smartyAddress) {
|
|
49
|
-
return
|
|
107
|
+
return addressDifferentOf(
|
|
108
|
+
(_nullishCoalesce(smartyAddress.deliveryLine1, () => ( ""))).toLowerCase() === userAddress.address1.toLowerCase(),
|
|
109
|
+
(_nullishCoalesce(smartyAddress.cityName, () => ( ""))).toLowerCase() === userAddress.city.toLowerCase(),
|
|
110
|
+
smartyAddress.stateAbbreviation === userAddress.state,
|
|
111
|
+
smartyAddress.zipCode === userAddress.postalCode
|
|
112
|
+
);
|
|
50
113
|
}
|
|
51
114
|
|
|
52
115
|
// src/get-payment-status.ts
|
|
53
116
|
function getPaymentStatus(invoice) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
117
|
+
return paymentStatusOf(
|
|
118
|
+
invoice.paidInFullFlag === "Y",
|
|
119
|
+
invoice.amountPaid != null && invoice.totalAmount != null,
|
|
120
|
+
_nullishCoalesce(invoice.amountPaid, () => ( 0))
|
|
121
|
+
);
|
|
58
122
|
}
|
|
59
123
|
|
|
60
124
|
// src/transform-ship-to-address.ts
|
|
61
125
|
function str(value) {
|
|
62
126
|
return String(value).trim();
|
|
63
127
|
}
|
|
64
|
-
function
|
|
128
|
+
function firstPresent(raw, keys) {
|
|
65
129
|
for (const k of keys) {
|
|
66
|
-
if (raw[k] != null) return
|
|
130
|
+
if (raw[k] != null) return raw[k];
|
|
67
131
|
}
|
|
68
132
|
return "";
|
|
69
133
|
}
|
|
134
|
+
function pick(raw, keys) {
|
|
135
|
+
return str(firstPresent(raw, keys));
|
|
136
|
+
}
|
|
137
|
+
var PHYS_MARKERS = [
|
|
138
|
+
"physAddress1",
|
|
139
|
+
"phys_address1",
|
|
140
|
+
"physCity",
|
|
141
|
+
"phys_city",
|
|
142
|
+
"physState",
|
|
143
|
+
"phys_state"
|
|
144
|
+
];
|
|
70
145
|
var PHYS_FIELDS = {
|
|
71
146
|
address1: ["physAddress1", "phys_address1"],
|
|
72
147
|
address2: ["physAddress2", "phys_address2"],
|
|
@@ -84,19 +159,19 @@ var MAIL_FIELDS = {
|
|
|
84
159
|
country: ["mailCountry", "mail_country", "country"]
|
|
85
160
|
};
|
|
86
161
|
function transformShipToAddress(raw) {
|
|
87
|
-
const isPhys =
|
|
162
|
+
const isPhys = PHYS_MARKERS.some((k) => raw[k] != null);
|
|
88
163
|
const f = isPhys ? PHYS_FIELDS : MAIL_FIELDS;
|
|
89
164
|
const address = {
|
|
90
|
-
shipToId:
|
|
91
|
-
name:
|
|
92
|
-
address1: pick(raw,
|
|
93
|
-
city: pick(raw,
|
|
94
|
-
state: pick(raw,
|
|
95
|
-
zip: pick(raw,
|
|
165
|
+
shipToId: firstPresent(raw, ["shipToId", "ship_to_id", "id"]),
|
|
166
|
+
name: pick(raw, ["shipToName", "ship_to_name", "name"]),
|
|
167
|
+
address1: pick(raw, f.address1),
|
|
168
|
+
city: pick(raw, f.city),
|
|
169
|
+
state: pick(raw, f.state),
|
|
170
|
+
zip: pick(raw, f.zip)
|
|
96
171
|
};
|
|
97
|
-
const address2 = pick(raw,
|
|
172
|
+
const address2 = pick(raw, f.address2);
|
|
98
173
|
if (address2) address.address2 = address2;
|
|
99
|
-
const country = pick(raw,
|
|
174
|
+
const country = pick(raw, f.country);
|
|
100
175
|
if (country) address.country = country;
|
|
101
176
|
return address;
|
|
102
177
|
}
|
|
@@ -109,7 +184,7 @@ function buildCheckoutPayload(input) {
|
|
|
109
184
|
sales_location_id: input.salesLocationId,
|
|
110
185
|
user_id: input.userId,
|
|
111
186
|
user_email: input.userEmail,
|
|
112
|
-
taker:
|
|
187
|
+
taker: takerOf(input.taker)
|
|
113
188
|
};
|
|
114
189
|
if (input.poNumber != null) oe_hdr.customer_po_no = input.poNumber;
|
|
115
190
|
if (input.shipToId != null) oe_hdr.ship_to_id = input.shipToId;
|
|
@@ -127,37 +202,95 @@ function buildCheckoutPayload(input) {
|
|
|
127
202
|
return { oe_hdr, oe_line };
|
|
128
203
|
}
|
|
129
204
|
|
|
205
|
+
// src/money.ts
|
|
206
|
+
var MONEY_DECIMALS = 8;
|
|
207
|
+
var MAX_SHIFTED = 2 ** 51;
|
|
208
|
+
function shiftDecimal(value, places) {
|
|
209
|
+
const [mantissa, exponent = "0"] = String(value).split("e");
|
|
210
|
+
return Number(`${mantissa}e${Number(exponent) + places}`);
|
|
211
|
+
}
|
|
212
|
+
function roundHalfAway(value, decimals) {
|
|
213
|
+
if (!Number.isInteger(decimals) || decimals < 0) {
|
|
214
|
+
throw new RangeError(
|
|
215
|
+
`roundHalfAway: decimals must be a non-negative integer, got ${String(decimals)}`
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
if (!Number.isFinite(value)) return value;
|
|
219
|
+
const shifted = shiftDecimal(Math.abs(value), decimals);
|
|
220
|
+
if (!(shifted < MAX_SHIFTED)) return value;
|
|
221
|
+
const rounded = Math.round(shifted);
|
|
222
|
+
if (rounded === 0) return 0;
|
|
223
|
+
return Math.sign(value) * shiftDecimal(rounded, -decimals);
|
|
224
|
+
}
|
|
225
|
+
function cleanMoney(value) {
|
|
226
|
+
return roundHalfAway(value, MONEY_DECIMALS);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// src/price-outcome.ts
|
|
230
|
+
function priceOutcome(quantityOk, hasPrice, priceFinite, unitPrice) {
|
|
231
|
+
if (!quantityOk) return "badQuantity";
|
|
232
|
+
if (!hasPrice) return "loading";
|
|
233
|
+
if (!priceFinite || unitPrice < 0) return "badPrice";
|
|
234
|
+
if (unitPrice === 0) return "callForPrice";
|
|
235
|
+
return "priced";
|
|
236
|
+
}
|
|
237
|
+
|
|
130
238
|
// src/derive-price.ts
|
|
239
|
+
function outcomeError(outcome, quantity, unitPrice) {
|
|
240
|
+
if (outcome === "badQuantity") {
|
|
241
|
+
return new RangeError(
|
|
242
|
+
`derivePrice: quantity must be a non-negative finite number, got ${String(quantity)}`
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
if (outcome === "badPrice") {
|
|
246
|
+
return new RangeError(
|
|
247
|
+
`derivePrice: unitPrice must be a non-negative finite number, got ${String(unitPrice)}`
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
function outcomeFor(priceData, unitPrice, quantity) {
|
|
253
|
+
const hasPrice = priceData != null && unitPrice != null;
|
|
254
|
+
return priceOutcome(
|
|
255
|
+
Number.isFinite(quantity) && quantity >= 0,
|
|
256
|
+
hasPrice,
|
|
257
|
+
Number.isFinite(unitPrice),
|
|
258
|
+
// Read only when hasPrice is true; the 0 is never compared then.
|
|
259
|
+
_nullishCoalesce(unitPrice, () => ( 0))
|
|
260
|
+
);
|
|
261
|
+
}
|
|
131
262
|
function derivePrice(input) {
|
|
132
263
|
const { priceData, quantity = 1 } = input;
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
};
|
|
264
|
+
const unitPrice = _optionalChain([priceData, 'optionalAccess', _ => _.unitPrice]);
|
|
265
|
+
const outcome = outcomeFor(priceData, unitPrice, quantity);
|
|
266
|
+
const error = outcomeError(outcome, quantity, unitPrice);
|
|
267
|
+
if (error) throw error;
|
|
268
|
+
if (outcome === "loading") return { state: "loading" };
|
|
269
|
+
const record = priceData;
|
|
270
|
+
const price = unitPrice;
|
|
271
|
+
const unitOfMeasure = _nullishCoalesce(_optionalChain([record, 'access', _2 => _2.item, 'optionalAccess', _3 => _3.unitOfMeasure]), () => ( ""));
|
|
272
|
+
if (outcome === "callForPrice") return { state: "callForPrice", unitOfMeasure };
|
|
273
|
+
return { state: "priced", unitPrice: price, total: cleanMoney(price * quantity), unitOfMeasure };
|
|
142
274
|
}
|
|
143
275
|
|
|
144
276
|
// src/resolve-stock.ts
|
|
277
|
+
function summaryQuantity(companySummary, companyKey) {
|
|
278
|
+
if (companyKey && companyKey in companySummary) {
|
|
279
|
+
return _nullishCoalesce(companySummary[companyKey], () => ( 0));
|
|
280
|
+
}
|
|
281
|
+
return Object.values(companySummary).reduce((sum, val) => sum + val, 0);
|
|
282
|
+
}
|
|
283
|
+
function allDiscontinued(stockData) {
|
|
284
|
+
return isDiscontinuedOf(stockData.map((d) => d.discontinued));
|
|
285
|
+
}
|
|
145
286
|
function resolveStock(input) {
|
|
146
287
|
const { stock, companyKey, round = false, lowStockThreshold = 0, showQuantity = false } = input;
|
|
147
288
|
if (!stock) return null;
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
if (companyKey && companyKey in companySummary) {
|
|
151
|
-
qty = _nullishCoalesce(companySummary[companyKey], () => ( 0));
|
|
152
|
-
} else {
|
|
153
|
-
qty = Object.values(companySummary).reduce((sum, val) => sum + val, 0);
|
|
154
|
-
}
|
|
155
|
-
if (round) {
|
|
156
|
-
qty = Math.round(qty);
|
|
157
|
-
}
|
|
289
|
+
const summed = summaryQuantity(stock.companySummary, companyKey);
|
|
290
|
+
const qty = round ? Math.round(summed) : summed;
|
|
158
291
|
const isInStock = qty > 0;
|
|
159
|
-
const isLowStock =
|
|
160
|
-
const isDiscontinued = stock.stockData
|
|
292
|
+
const isLowStock = isLowStockOf(qty, lowStockThreshold);
|
|
293
|
+
const isDiscontinued = allDiscontinued(stock.stockData);
|
|
161
294
|
return {
|
|
162
295
|
quantity: qty,
|
|
163
296
|
isInStock,
|
|
@@ -169,13 +302,49 @@ function resolveStock(input) {
|
|
|
169
302
|
|
|
170
303
|
// src/schema-availability.ts
|
|
171
304
|
function getSchemaAvailability(resolved) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
305
|
+
return SCHEMA_URLS[availabilityOf(!!_optionalChain([resolved, 'optionalAccess', _4 => _4.isInStock]), !!_optionalChain([resolved, 'optionalAccess', _5 => _5.isDiscontinued]))];
|
|
306
|
+
}
|
|
307
|
+
var SCHEMA_URLS = {
|
|
308
|
+
InStock: "https://schema.org/InStock",
|
|
309
|
+
OutOfStock: "https://schema.org/OutOfStock",
|
|
310
|
+
BackOrder: "https://schema.org/BackOrder"
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
// src/json-ld-rules.ts
|
|
314
|
+
function breadcrumbPosition(i) {
|
|
315
|
+
return i + 1;
|
|
316
|
+
}
|
|
317
|
+
function gtinFieldOf(upper) {
|
|
318
|
+
if (upper === "UPC") return "gtin12";
|
|
319
|
+
if (upper === "EAN") return "gtin13";
|
|
320
|
+
return "gtin";
|
|
321
|
+
}
|
|
322
|
+
function isSuppressedOf(deleteFlag, onlineCd, statusCd) {
|
|
323
|
+
return deleteFlag === "Y" || onlineCd === 0 || statusCd === 0;
|
|
324
|
+
}
|
|
325
|
+
function productNameOf(suppressed, name, unitPrice) {
|
|
326
|
+
if (suppressed) return null;
|
|
327
|
+
if (name === "" || unitPrice <= 0) return null;
|
|
328
|
+
return name;
|
|
329
|
+
}
|
|
330
|
+
function firstNonBlankOf(a, b) {
|
|
331
|
+
if (a !== "") return a;
|
|
332
|
+
if (b !== "") return b;
|
|
333
|
+
return void 0;
|
|
334
|
+
}
|
|
335
|
+
function primarySupplierFrom(flags, i) {
|
|
336
|
+
if (i >= flags.length) return -1;
|
|
337
|
+
if (flags[i] === "Y") return i;
|
|
338
|
+
return primarySupplierFrom(flags, i + 1);
|
|
339
|
+
}
|
|
340
|
+
function supplierIndexOf(flags) {
|
|
341
|
+
const primary = primarySupplierFrom(flags, 0);
|
|
342
|
+
if (primary >= 0) return primary;
|
|
343
|
+
return flags.length > 0 ? 0 : -1;
|
|
344
|
+
}
|
|
345
|
+
function offerUrlOf(siteUrl, itemPath, itemId) {
|
|
346
|
+
if (siteUrl === "") return void 0;
|
|
347
|
+
return siteUrl + itemPath + "/" + itemId;
|
|
179
348
|
}
|
|
180
349
|
|
|
181
350
|
// src/json-ld.ts
|
|
@@ -185,22 +354,18 @@ function generateBreadcrumbJsonLd(items) {
|
|
|
185
354
|
"@type": "BreadcrumbList",
|
|
186
355
|
itemListElement: items.map((item, index) => ({
|
|
187
356
|
"@type": "ListItem",
|
|
188
|
-
position: index
|
|
357
|
+
position: breadcrumbPosition(index),
|
|
189
358
|
name: item.name,
|
|
190
359
|
item: item.url
|
|
191
360
|
}))
|
|
192
361
|
};
|
|
193
362
|
}
|
|
194
363
|
function getGtinField(upcOrEan) {
|
|
195
|
-
|
|
196
|
-
if (val === "UPC") return "gtin12";
|
|
197
|
-
if (val === "EAN") return "gtin13";
|
|
198
|
-
return "gtin";
|
|
364
|
+
return gtinFieldOf(_nullishCoalesce(_optionalChain([upcOrEan, 'optionalAccess', _6 => _6.toUpperCase, 'call', _7 => _7()]), () => ( "")));
|
|
199
365
|
}
|
|
200
366
|
function getPrimarySupplierPartNo(suppliers) {
|
|
201
|
-
const
|
|
202
|
-
const
|
|
203
|
-
const partNo = _optionalChain([supplier, 'optionalAccess', _7 => _7.supplierPartNo, 'optionalAccess', _8 => _8.trim, 'call', _9 => _9()]);
|
|
367
|
+
const supplier = suppliers[supplierIndexOf(suppliers.map((s) => _nullishCoalesce(s.primarySupplierFlag, () => ( ""))))];
|
|
368
|
+
const partNo = _optionalChain([supplier, 'optionalAccess', _8 => _8.supplierPartNo, 'optionalAccess', _9 => _9.trim, 'call', _10 => _10()]);
|
|
204
369
|
return partNo || void 0;
|
|
205
370
|
}
|
|
206
371
|
function buildQuantitativeValue(value, unitCode) {
|
|
@@ -224,14 +389,12 @@ function omitEmpty(obj) {
|
|
|
224
389
|
return result;
|
|
225
390
|
}
|
|
226
391
|
function resolveBrand(doc) {
|
|
227
|
-
const name = _optionalChain([doc, 'access',
|
|
228
|
-
if (
|
|
392
|
+
const name = firstNonBlankOf(_nullishCoalesce(_optionalChain([doc, 'access', _11 => _11.brandName, 'optionalAccess', _12 => _12.trim, 'call', _13 => _13()]), () => ( "")), _nullishCoalesce(_optionalChain([doc, 'access', _14 => _14.parkerProductCd, 'optionalAccess', _15 => _15.trim, 'call', _16 => _16()]), () => ( "")));
|
|
393
|
+
if (name === void 0) return void 0;
|
|
229
394
|
return { "@type": "Brand", name };
|
|
230
395
|
}
|
|
231
396
|
function resolveDescription(doc) {
|
|
232
|
-
|
|
233
|
-
if (_optionalChain([doc, 'access', _19 => _19.extendedDesc, 'optionalAccess', _20 => _20.trim, 'call', _21 => _21()])) return doc.extendedDesc.trim();
|
|
234
|
-
return void 0;
|
|
397
|
+
return firstNonBlankOf(_nullishCoalesce(_optionalChain([doc, 'access', _17 => _17.displayDesc, 'optionalAccess', _18 => _18.trim, 'call', _19 => _19()]), () => ( "")), _nullishCoalesce(_optionalChain([doc, 'access', _20 => _20.extendedDesc, 'optionalAccess', _21 => _21.trim, 'call', _22 => _22()]), () => ( "")));
|
|
235
398
|
}
|
|
236
399
|
function resolveImages(doc, transform2) {
|
|
237
400
|
if (doc.images.length === 0) return void 0;
|
|
@@ -245,8 +408,8 @@ function buildOffers(doc, options) {
|
|
|
245
408
|
const availability = getSchemaAvailability(resolved);
|
|
246
409
|
const validUntil = /* @__PURE__ */ new Date();
|
|
247
410
|
validUntil.setDate(validUntil.getDate() + priceValidDays);
|
|
248
|
-
const url = options.siteUrl
|
|
249
|
-
const eligibleQuantity = _optionalChain([doc, 'access',
|
|
411
|
+
const url = offerUrlOf(_nullishCoalesce(options.siteUrl, () => ( "")), itemPath, doc.itemId);
|
|
412
|
+
const eligibleQuantity = _optionalChain([doc, 'access', _23 => _23.defaultSellingUnit, 'optionalAccess', _24 => _24.trim, 'call', _25 => _25()]) ? { "@type": "QuantitativeValue", unitCode: doc.defaultSellingUnit.trim() } : void 0;
|
|
250
413
|
const seller = options.seller ? { "@type": "Organization", name: options.seller.name, url: options.seller.url } : void 0;
|
|
251
414
|
return {
|
|
252
415
|
"@type": "Offer",
|
|
@@ -262,22 +425,25 @@ function buildOffers(doc, options) {
|
|
|
262
425
|
shippingDetails: options.shippingDetails
|
|
263
426
|
};
|
|
264
427
|
}
|
|
265
|
-
function
|
|
266
|
-
|
|
428
|
+
function productName(doc, unitPrice) {
|
|
429
|
+
const suppressed = isSuppressedOf(doc.deleteFlag, doc.onlineCd, doc.statusCd);
|
|
430
|
+
return productNameOf(suppressed, (doc.itemDesc || "").trim(), unitPrice);
|
|
431
|
+
}
|
|
432
|
+
function buildAggregateRating(rating) {
|
|
433
|
+
if (!rating) return void 0;
|
|
434
|
+
return {
|
|
435
|
+
"@type": "AggregateRating",
|
|
436
|
+
ratingValue: rating.ratingValue,
|
|
437
|
+
reviewCount: rating.reviewCount
|
|
438
|
+
};
|
|
267
439
|
}
|
|
268
440
|
function generateProductJsonLd(doc, options) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
if (!name) return null;
|
|
272
|
-
if (options.unitPrice <= 0) return null;
|
|
441
|
+
const name = productName(doc, options.unitPrice);
|
|
442
|
+
if (name === null) return null;
|
|
273
443
|
const weightUnit = _nullishCoalesce(options.weightUnit, () => ( "LBR"));
|
|
274
444
|
const dimensionUnit = _nullishCoalesce(options.dimensionUnit, () => ( "INH"));
|
|
275
|
-
const gtinId = _optionalChain([doc, 'access',
|
|
276
|
-
const aggregateRating = options.aggregateRating
|
|
277
|
-
"@type": "AggregateRating",
|
|
278
|
-
ratingValue: options.aggregateRating.ratingValue,
|
|
279
|
-
reviewCount: options.aggregateRating.reviewCount
|
|
280
|
-
} : void 0;
|
|
445
|
+
const gtinId = _optionalChain([doc, 'access', _26 => _26.upcOrEanId, 'optionalAccess', _27 => _27.trim, 'call', _28 => _28()]) || void 0;
|
|
446
|
+
const aggregateRating = buildAggregateRating(options.aggregateRating);
|
|
281
447
|
const product = {
|
|
282
448
|
"@context": "https://schema.org",
|
|
283
449
|
"@type": "Product",
|
|
@@ -301,82 +467,147 @@ function generateProductJsonLd(doc, options) {
|
|
|
301
467
|
|
|
302
468
|
// src/result.ts
|
|
303
469
|
function unwrap(result) {
|
|
304
|
-
if (!result.ok) throw new Error(result.error
|
|
470
|
+
if (!result.ok) throw new Error(unwrapMessage(result.error));
|
|
305
471
|
return result.data;
|
|
306
472
|
}
|
|
307
473
|
function unwrapOr(result) {
|
|
308
474
|
return result.ok ? _nullishCoalesce(result.data, () => ( null)) : null;
|
|
309
475
|
}
|
|
310
476
|
|
|
477
|
+
// ../utils/src/strings.ts
|
|
478
|
+
function codeAt(s, i) {
|
|
479
|
+
return i >= 0 && i < s.length ? s.charCodeAt(i) : -1;
|
|
480
|
+
}
|
|
481
|
+
function indexOfCode(s, code, from) {
|
|
482
|
+
const c = codeAt(s, from);
|
|
483
|
+
if (c === code) return from;
|
|
484
|
+
if (c === -1) return -1;
|
|
485
|
+
return indexOfCode(s, code, from + 1);
|
|
486
|
+
}
|
|
487
|
+
function startsWithAt(s, x, pos) {
|
|
488
|
+
const at = Math.min(pos, s.length);
|
|
489
|
+
return s.slice(at, Math.min(at + x.length, s.length)) === x;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// ../utils/src/lists.ts
|
|
493
|
+
function joinFrom(xs, sep, i) {
|
|
494
|
+
if (i >= xs.length) return "";
|
|
495
|
+
if (i === xs.length - 1) return xs[i];
|
|
496
|
+
return xs[i] + sep + joinFrom(xs, sep, i + 1);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// src/image-rules.ts
|
|
500
|
+
function transformKeyOf(field) {
|
|
501
|
+
if (field === "width") return "w";
|
|
502
|
+
if (field === "height") return "h";
|
|
503
|
+
if (field === "format") return "f";
|
|
504
|
+
if (field === "quality") return "q";
|
|
505
|
+
if (field === "fit") return "fit";
|
|
506
|
+
return "";
|
|
507
|
+
}
|
|
508
|
+
function transformValueOf(field, value) {
|
|
509
|
+
if (field === "format" && value === "jpg") return "jpeg";
|
|
510
|
+
return value;
|
|
511
|
+
}
|
|
512
|
+
function transformPartsFrom(fields, present, texts, i) {
|
|
513
|
+
if (i >= fields.length) return [];
|
|
514
|
+
const field = fields[i];
|
|
515
|
+
const key = transformKeyOf(field);
|
|
516
|
+
const rest = transformPartsFrom(fields, present, texts, i + 1);
|
|
517
|
+
if (present[i] && key !== "") {
|
|
518
|
+
return [key + "_" + transformValueOf(field, texts[i]), ...rest];
|
|
519
|
+
}
|
|
520
|
+
return rest;
|
|
521
|
+
}
|
|
522
|
+
function serializedTransforms(fields, present, texts) {
|
|
523
|
+
return joinFrom(transformPartsFrom(fields, present, texts, 0), ",", 0);
|
|
524
|
+
}
|
|
525
|
+
function isExternal(path) {
|
|
526
|
+
return startsWithAt(path, "http", 0);
|
|
527
|
+
}
|
|
528
|
+
function stripFirstPrefixFrom(path, prefixes, i) {
|
|
529
|
+
if (i >= prefixes.length) return path;
|
|
530
|
+
const prefix = prefixes[i];
|
|
531
|
+
if (startsWithAt(path, prefix, 0)) return path.slice(prefix.length);
|
|
532
|
+
return stripFirstPrefixFrom(path, prefixes, i + 1);
|
|
533
|
+
}
|
|
534
|
+
function stripLeadingSlashes(s) {
|
|
535
|
+
if (codeAt(s, 0) !== 47) return s;
|
|
536
|
+
return stripLeadingSlashes(s.slice(1));
|
|
537
|
+
}
|
|
538
|
+
function normalizedPath(raw, prefixes, defaultPath) {
|
|
539
|
+
if (isExternal(raw)) return raw;
|
|
540
|
+
const cleaned = stripLeadingSlashes(stripFirstPrefixFrom(raw, prefixes, 0));
|
|
541
|
+
if (defaultPath !== "" && indexOfCode(cleaned, 47, 0) < 0) return defaultPath + "/" + cleaned;
|
|
542
|
+
return cleaned;
|
|
543
|
+
}
|
|
544
|
+
function cdnUrlOf(clientDomain, serialized, normalized) {
|
|
545
|
+
const segment = serialized !== "" ? "/" + serialized : "";
|
|
546
|
+
return "https://agr.media/" + clientDomain + "/images" + segment + "/" + normalized;
|
|
547
|
+
}
|
|
548
|
+
function defaultImageUrlOf(clientDomain, fallback, prefixes, defaultPath) {
|
|
549
|
+
if (fallback === "") return "";
|
|
550
|
+
const normalized = normalizedPath(fallback, prefixes, defaultPath);
|
|
551
|
+
if (isExternal(normalized)) return normalized;
|
|
552
|
+
return "https://agr.media/" + clientDomain + "/images/" + normalized;
|
|
553
|
+
}
|
|
554
|
+
function imageUrlOf(clientDomain, path, serialized, fallback, prefixes, defaultPath) {
|
|
555
|
+
if (path === "") return defaultImageUrlOf(clientDomain, fallback, prefixes, defaultPath);
|
|
556
|
+
const normalized = normalizedPath(path, prefixes, defaultPath);
|
|
557
|
+
if (isExternal(normalized)) return normalized;
|
|
558
|
+
return cdnUrlOf(clientDomain, serialized, normalized);
|
|
559
|
+
}
|
|
560
|
+
|
|
311
561
|
// src/image.ts
|
|
312
562
|
var BLUR_DATA_URL = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mN88P/BfwYABQoBfqVKzQAAAABJRU5ErkJggg==";
|
|
313
|
-
var CDN_BASE = "https://agr.media";
|
|
314
|
-
var TRANSFORM_KEY_MAP = {
|
|
315
|
-
width: "w",
|
|
316
|
-
height: "h",
|
|
317
|
-
format: "f",
|
|
318
|
-
quality: "q",
|
|
319
|
-
fit: "fit"
|
|
320
|
-
};
|
|
321
563
|
var DEFAULT_STRIP_PREFIXES = ["/images", "images"];
|
|
322
564
|
function createImageConfig(clientDomain, opts) {
|
|
323
565
|
return Object.freeze({
|
|
324
566
|
clientDomain,
|
|
325
|
-
defaultImage: _optionalChain([opts, 'optionalAccess',
|
|
326
|
-
defaultTransforms: _optionalChain([opts, 'optionalAccess',
|
|
327
|
-
stripPrefixes: _nullishCoalesce(_optionalChain([opts, 'optionalAccess',
|
|
328
|
-
defaultPath: _optionalChain([opts, 'optionalAccess',
|
|
567
|
+
defaultImage: _optionalChain([opts, 'optionalAccess', _29 => _29.defaultImage]),
|
|
568
|
+
defaultTransforms: _optionalChain([opts, 'optionalAccess', _30 => _30.defaultTransforms]),
|
|
569
|
+
stripPrefixes: _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _31 => _31.stripPrefixes]), () => ( DEFAULT_STRIP_PREFIXES)),
|
|
570
|
+
defaultPath: _optionalChain([opts, 'optionalAccess', _32 => _32.defaultPath])
|
|
329
571
|
});
|
|
330
572
|
}
|
|
331
573
|
function serializeTransforms(transforms) {
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
parts.push(`${prefix}_${v2}`);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
return parts.join(",");
|
|
574
|
+
const entries = Object.entries(transforms);
|
|
575
|
+
return serializedTransforms(
|
|
576
|
+
entries.map(([key]) => key),
|
|
577
|
+
entries.map(([, value]) => value !== void 0),
|
|
578
|
+
entries.map(([, value]) => String(value))
|
|
579
|
+
);
|
|
342
580
|
}
|
|
343
581
|
function normalizePath(config, raw) {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
if (cleaned.startsWith(prefix)) {
|
|
349
|
-
cleaned = cleaned.slice(prefix.length);
|
|
350
|
-
break;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
cleaned = cleaned.replace(/^\/+/, "");
|
|
354
|
-
if (config.defaultPath && !cleaned.includes("/")) {
|
|
355
|
-
cleaned = `${config.defaultPath}/${cleaned}`;
|
|
356
|
-
}
|
|
357
|
-
return cleaned;
|
|
582
|
+
return normalizedPath(raw, prefixesOf(config), _nullishCoalesce(config.defaultPath, () => ( "")));
|
|
583
|
+
}
|
|
584
|
+
function prefixesOf(config) {
|
|
585
|
+
return _nullishCoalesce(config.stripPrefixes, () => ( DEFAULT_STRIP_PREFIXES));
|
|
358
586
|
}
|
|
359
587
|
function getImageUrl(config, imagePath, transforms, options) {
|
|
360
|
-
const resolvedPath = _optionalChain([imagePath, 'optionalAccess', _32 => _32.trim, 'call', _33 => _33()]);
|
|
361
|
-
if (!resolvedPath) {
|
|
362
|
-
return getDefaultImageUrl(config, options);
|
|
363
|
-
}
|
|
364
|
-
const normalized = normalizePath(config, resolvedPath);
|
|
365
|
-
if (normalized.startsWith("http")) return normalized;
|
|
366
588
|
const merged = {
|
|
367
589
|
...config.defaultTransforms,
|
|
368
590
|
...transforms
|
|
369
591
|
};
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
592
|
+
return imageUrlOf(
|
|
593
|
+
config.clientDomain,
|
|
594
|
+
_nullishCoalesce(_optionalChain([imagePath, 'optionalAccess', _33 => _33.trim, 'call', _34 => _34()]), () => ( "")),
|
|
595
|
+
serializeTransforms(merged),
|
|
596
|
+
fallbackOf(config, options),
|
|
597
|
+
prefixesOf(config),
|
|
598
|
+
_nullishCoalesce(config.defaultPath, () => ( ""))
|
|
599
|
+
);
|
|
373
600
|
}
|
|
374
601
|
function getDefaultImageUrl(config, options) {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
602
|
+
return defaultImageUrlOf(
|
|
603
|
+
config.clientDomain,
|
|
604
|
+
fallbackOf(config, options),
|
|
605
|
+
prefixesOf(config),
|
|
606
|
+
_nullishCoalesce(config.defaultPath, () => ( ""))
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
function fallbackOf(config, options) {
|
|
610
|
+
return _nullishCoalesce(_nullishCoalesce(_optionalChain([options, 'optionalAccess', _35 => _35.defaultImage]), () => ( config.defaultImage)), () => ( ""));
|
|
380
611
|
}
|
|
381
612
|
function getImageSrcSet(config, imagePath, widths, transforms) {
|
|
382
613
|
return widths.map((w) => {
|
|
@@ -438,20 +669,20 @@ var US_TERRITORIES = _statesus.states.filter((s) => s.territory);
|
|
|
438
669
|
|
|
439
670
|
// src/address-schemas.ts
|
|
440
671
|
var validStateCodes = US_STATES.map((state) => state.code);
|
|
672
|
+
function personName(requiredMessage, invalidMessage) {
|
|
673
|
+
return v.pipe(
|
|
674
|
+
v.string(),
|
|
675
|
+
v.minLength(1, requiredMessage),
|
|
676
|
+
v.regex(VALIDATION_PATTERNS.nameFormat, invalidMessage),
|
|
677
|
+
v.regex(VALIDATION_PATTERNS.nameNoNumbers, invalidMessage)
|
|
678
|
+
);
|
|
679
|
+
}
|
|
680
|
+
var firstName = personName("First name is required", "Invalid first name");
|
|
681
|
+
var lastName = personName("Last name is required", "Invalid last name");
|
|
441
682
|
var ShippingAddressSchema = v.object({
|
|
442
683
|
companyName: v.optional(v.string()),
|
|
443
|
-
firstName
|
|
444
|
-
|
|
445
|
-
v.minLength(1, "First name is required"),
|
|
446
|
-
v.regex(VALIDATION_PATTERNS.nameFormat, "Invalid first name"),
|
|
447
|
-
v.regex(VALIDATION_PATTERNS.nameNoNumbers, "Invalid first name")
|
|
448
|
-
),
|
|
449
|
-
lastName: v.pipe(
|
|
450
|
-
v.string(),
|
|
451
|
-
v.minLength(1, "Last name is required"),
|
|
452
|
-
v.regex(VALIDATION_PATTERNS.nameFormat, "Invalid last name"),
|
|
453
|
-
v.regex(VALIDATION_PATTERNS.nameNoNumbers, "Invalid last name")
|
|
454
|
-
),
|
|
684
|
+
firstName,
|
|
685
|
+
lastName,
|
|
455
686
|
address1: v.pipe(
|
|
456
687
|
v.string(),
|
|
457
688
|
v.minLength(1, "Address 1 is required"),
|
|
@@ -506,18 +737,8 @@ var ShippingAddressSchema = v.object({
|
|
|
506
737
|
});
|
|
507
738
|
var BillingAddressSchema = v.object({
|
|
508
739
|
poNumber: v.optional(v.string()),
|
|
509
|
-
firstName
|
|
510
|
-
|
|
511
|
-
v.minLength(1, "First name is required"),
|
|
512
|
-
v.regex(VALIDATION_PATTERNS.nameFormat, "Invalid first name"),
|
|
513
|
-
v.regex(VALIDATION_PATTERNS.nameNoNumbers, "Invalid first name")
|
|
514
|
-
),
|
|
515
|
-
lastName: v.pipe(
|
|
516
|
-
v.string(),
|
|
517
|
-
v.minLength(1, "Last name is required"),
|
|
518
|
-
v.regex(VALIDATION_PATTERNS.nameFormat, "Invalid last name"),
|
|
519
|
-
v.regex(VALIDATION_PATTERNS.nameNoNumbers, "Invalid last name")
|
|
520
|
-
),
|
|
740
|
+
firstName,
|
|
741
|
+
lastName,
|
|
521
742
|
address1: v.pipe(
|
|
522
743
|
v.string(),
|
|
523
744
|
v.minLength(1, "Address 1 is required"),
|
|
@@ -547,24 +768,15 @@ function getBusinessDay(businessDaysFromNow) {
|
|
|
547
768
|
const date = /* @__PURE__ */ new Date();
|
|
548
769
|
date.setDate(date.getDate() + i);
|
|
549
770
|
const dayName = date.toLocaleDateString("en-US", { weekday: "long" });
|
|
550
|
-
if (dayName
|
|
771
|
+
if (isBusinessDayName(dayName)) {
|
|
551
772
|
businessDays.push(date.toLocaleDateString("en-US", DATE_FORMAT_OPTIONS));
|
|
552
773
|
}
|
|
553
774
|
i++;
|
|
554
775
|
}
|
|
555
776
|
return businessDays[businessDays.length - 1] || "";
|
|
556
777
|
}
|
|
557
|
-
var SHIPPING_LEAD_CONFIG = {
|
|
558
|
-
"1-2": { from: 1, to: 4 },
|
|
559
|
-
"2": { from: 4 },
|
|
560
|
-
"2-3": { from: 2, to: 5 },
|
|
561
|
-
"3": { from: 5 },
|
|
562
|
-
"3-4": { from: 3, to: 6 },
|
|
563
|
-
"4": { from: 6 },
|
|
564
|
-
"5": { from: 7 }
|
|
565
|
-
};
|
|
566
778
|
function getShippingLeadDate(days) {
|
|
567
|
-
const config =
|
|
779
|
+
const config = shippingLeadOf(days);
|
|
568
780
|
if (!config) return "";
|
|
569
781
|
const fromDate = getBusinessDay(config.from);
|
|
570
782
|
if (config.to) {
|
|
@@ -577,10 +789,7 @@ function getShippingLeadDate(days) {
|
|
|
577
789
|
// src/transforms.ts
|
|
578
790
|
function serializeCategoryFilters(filters, options) {
|
|
579
791
|
const { sortByPrefix, includeStock = true } = _nullishCoalesce(options, () => ( {}));
|
|
580
|
-
|
|
581
|
-
if (sortByPrefix && sortBy) {
|
|
582
|
-
sortBy = `${sortByPrefix}${sortBy}`;
|
|
583
|
-
}
|
|
792
|
+
const sortBy = filters.sortBy ? categorySortBy(_nullishCoalesce(sortByPrefix, () => ( "")), filters.sortBy) : filters.sortBy;
|
|
584
793
|
const params = {
|
|
585
794
|
filters: JSON.stringify(filters.filters),
|
|
586
795
|
limit: filters.limit,
|
|
@@ -600,16 +809,16 @@ function serializeSearchParams(filters, options) {
|
|
|
600
809
|
searchType: "query",
|
|
601
810
|
size: filters.limit,
|
|
602
811
|
from: filters.offset,
|
|
603
|
-
sortBy: filters.sortBy
|
|
812
|
+
sortBy: searchSortBy(filters.sortBy),
|
|
604
813
|
classId5List: categoryUid ? String(categoryUid) : void 0,
|
|
605
|
-
filters: _optionalChain([filters, 'access',
|
|
814
|
+
filters: _optionalChain([filters, 'access', _36 => _36.filters, 'optionalAccess', _37 => _37.length]) ? JSON.stringify(filters.filters) : void 0,
|
|
606
815
|
sourceFieldsList: sourceFields
|
|
607
816
|
};
|
|
608
817
|
}
|
|
609
818
|
function paginateOffset(filters, pageParam) {
|
|
610
819
|
return {
|
|
611
820
|
...filters,
|
|
612
|
-
offset: pageParam
|
|
821
|
+
offset: pageOffset(pageParam, filters.limit)
|
|
613
822
|
};
|
|
614
823
|
}
|
|
615
824
|
|
|
@@ -627,7 +836,7 @@ function trackAddToCart({
|
|
|
627
836
|
event: "add_to_cart",
|
|
628
837
|
ecommerce: {
|
|
629
838
|
currency: "USD",
|
|
630
|
-
value:
|
|
839
|
+
value: roundHalfAway(estimatedCost, 2),
|
|
631
840
|
items: [
|
|
632
841
|
{
|
|
633
842
|
item_id: itemId,
|
|
@@ -675,13 +884,13 @@ function buildTrackingData({
|
|
|
675
884
|
const items = cartLines.map((line, index) => {
|
|
676
885
|
const details = itemDetails[line.itemId];
|
|
677
886
|
const price = getUnitPrice(line.itemId);
|
|
678
|
-
total
|
|
887
|
+
total = cleanMoney(total + cleanMoney(price * line.quantity));
|
|
679
888
|
return {
|
|
680
889
|
item_id: line.itemId,
|
|
681
|
-
item_name: _nullishCoalesce(_optionalChain([details, 'optionalAccess',
|
|
890
|
+
item_name: _nullishCoalesce(_optionalChain([details, 'optionalAccess', _38 => _38.itemDesc]), () => ( "")),
|
|
682
891
|
currency,
|
|
683
892
|
index,
|
|
684
|
-
item_category: _nullishCoalesce(_optionalChain([details, 'optionalAccess',
|
|
893
|
+
item_category: _nullishCoalesce(_optionalChain([details, 'optionalAccess', _39 => _39.classId5]), () => ( "")),
|
|
685
894
|
price,
|
|
686
895
|
quantity: line.quantity
|
|
687
896
|
};
|
|
@@ -689,7 +898,8 @@ function buildTrackingData({
|
|
|
689
898
|
return {
|
|
690
899
|
event: "begin_checkout",
|
|
691
900
|
currency,
|
|
692
|
-
|
|
901
|
+
// toFixed(2) rounds ties wrong (1.005 → "1.00"); roundHalfAway gives 1.01.
|
|
902
|
+
value: roundHalfAway(total, 2),
|
|
693
903
|
items
|
|
694
904
|
};
|
|
695
905
|
}
|
|
@@ -746,5 +956,9 @@ function pushTrackingData(data) {
|
|
|
746
956
|
|
|
747
957
|
|
|
748
958
|
|
|
749
|
-
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
|
|
963
|
+
exports.BLUR_DATA_URL = BLUR_DATA_URL; exports.BillingAddressInvoiceSchema = BillingAddressInvoiceSchema; exports.BillingAddressSchema = BillingAddressSchema; exports.CACHE_CONFIG = CACHE_CONFIG; exports.CONTIGUOUS_STATES = CONTIGUOUS_STATES; exports.ShippingAddressSchema = ShippingAddressSchema; exports.US_STATES = US_STATES; exports.US_STATES_FULL = US_STATES_FULL; exports.US_TERRITORIES = US_TERRITORIES; exports.VALIDATION_PATTERNS = VALIDATION_PATTERNS; exports.buildCheckoutPayload = buildCheckoutPayload; exports.buildImageLoader = buildImageLoader; exports.buildTrackingData = buildTrackingData; exports.categorySortBy = categorySortBy; exports.cleanMoney = cleanMoney; exports.cn = _chunk5UMFBGVAcjs.cn; exports.createImageConfig = createImageConfig; exports.derivePrice = derivePrice; exports.formatPrice = formatPrice; exports.generateBreadcrumbJsonLd = generateBreadcrumbJsonLd; exports.generateProductJsonLd = generateProductJsonLd; exports.getBusinessDay = getBusinessDay; exports.getDefaultImageUrl = getDefaultImageUrl; exports.getImageSrcSet = getImageSrcSet; exports.getImageUrl = getImageUrl; exports.getPaymentStatus = getPaymentStatus; exports.getSchemaAvailability = getSchemaAvailability; exports.getShippingLeadDate = getShippingLeadDate; exports.hasPriceBreaks = hasPriceBreaks; exports.isAddressDifferent = isAddressDifferent; exports.normalizePath = normalizePath; exports.paginateOffset = paginateOffset; exports.pushTrackingData = pushTrackingData; exports.resolveStock = resolveStock; exports.roundHalfAway = roundHalfAway; exports.sanitizeHtmlImages = sanitizeHtmlImages; exports.serializeCategoryFilters = serializeCategoryFilters; exports.serializeSearchParams = serializeSearchParams; exports.serializeTransforms = serializeTransforms; exports.trackAddToCart = trackAddToCart; exports.trackViewItem = trackViewItem; exports.transformShipToAddress = transformShipToAddress; exports.unwrap = unwrap; exports.unwrapOr = unwrapOr;
|
|
750
964
|
//# sourceMappingURL=index.cjs.map
|