@asteby/storefront 0.8.0 → 0.9.0
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 +30 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -3
- package/dist/index.d.ts +34 -3
- package/dist/index.js +27 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1110,8 +1110,35 @@ function hreflangLinks(markets, path, defaultMarket, protocol = "https") {
|
|
|
1110
1110
|
return links;
|
|
1111
1111
|
}
|
|
1112
1112
|
|
|
1113
|
+
// src/delivery.ts
|
|
1114
|
+
function parseDelivery(value) {
|
|
1115
|
+
const raw = (value ?? "").trim();
|
|
1116
|
+
const i = raw.indexOf(":");
|
|
1117
|
+
const head = i === -1 ? raw : raw.slice(0, i);
|
|
1118
|
+
const id = i === -1 ? "" : raw.slice(i + 1);
|
|
1119
|
+
const kind = head === "pickup" ? "pickup" : head === "ship" ? "ship" : "rate";
|
|
1120
|
+
return { kind, id, method: kind === "pickup" ? "pickup" : "shipping", addressOnly: kind === "ship" };
|
|
1121
|
+
}
|
|
1122
|
+
function deliveryInput(choice) {
|
|
1123
|
+
if (choice.addressOnly) return null;
|
|
1124
|
+
if (choice.kind === "pickup") return { method: "pickup", branch_id: choice.id };
|
|
1125
|
+
return { method: "shipping", rate_id: choice.id || void 0 };
|
|
1126
|
+
}
|
|
1127
|
+
var MISSING_WEIGHT = "missing_weight";
|
|
1128
|
+
function deliveryNotices(delivery) {
|
|
1129
|
+
const all = delivery?.unavailable ?? [];
|
|
1130
|
+
const missingWeight = all.filter((u) => u.code === MISSING_WEIGHT);
|
|
1131
|
+
const unavailable = all.filter((u) => u.code !== MISSING_WEIGHT);
|
|
1132
|
+
return {
|
|
1133
|
+
missingWeight,
|
|
1134
|
+
unavailable,
|
|
1135
|
+
hasNotices: missingWeight.length > 0 || unavailable.length > 0 || delivery?.partial === true
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1113
1139
|
exports.CLIENT_IP_HEADER = CLIENT_IP_HEADER;
|
|
1114
1140
|
exports.COUNTRY_HEADERS = COUNTRY_HEADERS;
|
|
1141
|
+
exports.MISSING_WEIGHT = MISSING_WEIGHT;
|
|
1115
1142
|
exports.NOTE_MAX_LENGTH = NOTE_MAX_LENGTH;
|
|
1116
1143
|
exports.StorefrontError = StorefrontError;
|
|
1117
1144
|
exports.appendParams = appendParams;
|
|
@@ -1123,6 +1150,8 @@ exports.clampPercent = clampPercent;
|
|
|
1123
1150
|
exports.createStorefrontClient = createStorefrontClient;
|
|
1124
1151
|
exports.declineMessage = declineMessage;
|
|
1125
1152
|
exports.declineMessageKey = declineMessageKey;
|
|
1153
|
+
exports.deliveryInput = deliveryInput;
|
|
1154
|
+
exports.deliveryNotices = deliveryNotices;
|
|
1126
1155
|
exports.formatAvailabilityMessage = formatAvailabilityMessage;
|
|
1127
1156
|
exports.formatMoney = formatMoney;
|
|
1128
1157
|
exports.formatVoucherExpiry = formatVoucherExpiry;
|
|
@@ -1133,6 +1162,7 @@ exports.isTokenPublishable = isTokenPublishable;
|
|
|
1133
1162
|
exports.negotiateLocale = negotiateLocale;
|
|
1134
1163
|
exports.normalizeClientIp = normalizeClientIp;
|
|
1135
1164
|
exports.normalizeNote = normalizeNote;
|
|
1165
|
+
exports.parseDelivery = parseDelivery;
|
|
1136
1166
|
exports.parseMoney = parseMoney;
|
|
1137
1167
|
exports.parseProductFilters = parseProductFilters;
|
|
1138
1168
|
exports.paymentErrorView = paymentErrorView;
|