@final-commerce/common 2.8.1-online.5 → 2.8.1-online.6
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.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +21 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3758,6 +3758,16 @@ function listCountries(locale = "en") {
|
|
|
3758
3758
|
const names = regionNames(locale) ?? regionNames("en");
|
|
3759
3759
|
return countryCodes().map((code) => ({ code, name: names?.of(code) ?? code })).sort((a, b) => a.name.localeCompare(b.name, locale));
|
|
3760
3760
|
}
|
|
3761
|
+
var SHIPPING_COUNTRIES = ["CA"];
|
|
3762
|
+
function shipsToCountry(code) {
|
|
3763
|
+
return !!code && SHIPPING_COUNTRIES.includes(code);
|
|
3764
|
+
}
|
|
3765
|
+
function listShippingCountries(locale = "en") {
|
|
3766
|
+
const names = regionNames(locale) ?? regionNames("en");
|
|
3767
|
+
return SHIPPING_COUNTRIES.map((code) => ({ code, name: names?.of(code) ?? code })).sort(
|
|
3768
|
+
(a, b) => a.name.localeCompare(b.name, locale)
|
|
3769
|
+
);
|
|
3770
|
+
}
|
|
3761
3771
|
|
|
3762
3772
|
// shipping/provinces.ts
|
|
3763
3773
|
var CANADA_PROVINCES = [
|
|
@@ -3871,6 +3881,7 @@ function resolveShipping({ zones, address, itemsTotal, channel }) {
|
|
|
3871
3881
|
});
|
|
3872
3882
|
const normalized = normalizeAddress(address);
|
|
3873
3883
|
if (!normalized.country) return none("INCOMPLETE" /* INCOMPLETE */);
|
|
3884
|
+
if (!shipsToCountry(normalized.country)) return none("NO_COVERAGE" /* NO_COVERAGE */);
|
|
3874
3885
|
if (!postCodeMatchesProvince(normalized)) return none("ADDRESS_MISMATCH" /* ADDRESS_MISMATCH */);
|
|
3875
3886
|
const zone = findZone(zones, addressPlaceKeys(normalized));
|
|
3876
3887
|
if (!zone) return none("NO_COVERAGE" /* NO_COVERAGE */);
|
|
@@ -3935,7 +3946,9 @@ function countriesShippedTo(zones) {
|
|
|
3935
3946
|
const countries = /* @__PURE__ */ new Set();
|
|
3936
3947
|
for (const zone of zones) {
|
|
3937
3948
|
if (!zone.ships) continue;
|
|
3938
|
-
for (const key of zoneKeys(zone))
|
|
3949
|
+
for (const key of zoneKeys(zone)) {
|
|
3950
|
+
if (key !== EVERYWHERE_KEY && shipsToCountry(key.slice(0, 2))) countries.add(key.slice(0, 2));
|
|
3951
|
+
}
|
|
3939
3952
|
}
|
|
3940
3953
|
return [...countries].sort();
|
|
3941
3954
|
}
|
|
@@ -3955,7 +3968,7 @@ function placeProblems(zone) {
|
|
|
3955
3968
|
if (zone.places.length === 0) return [{ code: "NO_PLACES" /* NO_PLACES */ }];
|
|
3956
3969
|
if (!zone.places.every((place) => fitsKind(place, zone.kind))) return [{ code: "INVALID_PLACE" /* INVALID_PLACE */ }];
|
|
3957
3970
|
const keys = zone.places.map(placeKey);
|
|
3958
|
-
if (keys.some((key) => !key)) return [{ code: "INVALID_PLACE" /* INVALID_PLACE */ }];
|
|
3971
|
+
if (keys.some((key) => !key || !shipsToCountry(key.slice(0, 2)))) return [{ code: "INVALID_PLACE" /* INVALID_PLACE */ }];
|
|
3959
3972
|
if (new Set(keys).size !== keys.length) return [{ code: "DUPLICATE_PLACE" /* DUPLICATE_PLACE */ }];
|
|
3960
3973
|
return [];
|
|
3961
3974
|
}
|
|
@@ -4308,6 +4321,7 @@ export {
|
|
|
4308
4321
|
ResidualPaymentMethod,
|
|
4309
4322
|
ResidualStatus,
|
|
4310
4323
|
ResourceAvailabilityState,
|
|
4324
|
+
SHIPPING_COUNTRIES,
|
|
4311
4325
|
STANDARD_TAX_TYPE,
|
|
4312
4326
|
STATE_SCHEMA,
|
|
4313
4327
|
STRIPE_SUPPORTED_COUNTRIES,
|
|
@@ -4415,6 +4429,7 @@ export {
|
|
|
4415
4429
|
lineStockMoves,
|
|
4416
4430
|
listCountries,
|
|
4417
4431
|
listProvinces,
|
|
4432
|
+
listShippingCountries,
|
|
4418
4433
|
mapToLegacyStatus,
|
|
4419
4434
|
maxPrecisionFor,
|
|
4420
4435
|
mergeFragment,
|
|
@@ -4451,6 +4466,7 @@ export {
|
|
|
4451
4466
|
sameFamily,
|
|
4452
4467
|
setOrderState,
|
|
4453
4468
|
sha1Hex,
|
|
4469
|
+
shipsToCountry,
|
|
4454
4470
|
shopDayKey,
|
|
4455
4471
|
shopDayRange,
|
|
4456
4472
|
signReportForDisplay,
|