@final-commerce/common 2.9.2-preprod.1 → 2.9.2-preprod.3

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.mjs CHANGED
@@ -3800,6 +3800,16 @@ function listCountries(locale = "en") {
3800
3800
  const names = regionNames(locale) ?? regionNames("en");
3801
3801
  return countryCodes().map((code) => ({ code, name: names?.of(code) ?? code })).sort((a, b) => a.name.localeCompare(b.name, locale));
3802
3802
  }
3803
+ var SHIPPING_COUNTRIES = ["CA"];
3804
+ function shipsToCountry(code) {
3805
+ return !!code && SHIPPING_COUNTRIES.includes(code);
3806
+ }
3807
+ function listShippingCountries(locale = "en") {
3808
+ const names = regionNames(locale) ?? regionNames("en");
3809
+ return SHIPPING_COUNTRIES.map((code) => ({ code, name: names?.of(code) ?? code })).sort(
3810
+ (a, b) => a.name.localeCompare(b.name, locale)
3811
+ );
3812
+ }
3803
3813
 
3804
3814
  // shipping/provinces.ts
3805
3815
  var CANADA_PROVINCES = [
@@ -3913,6 +3923,7 @@ function resolveShipping({ zones, address, itemsTotal, channel }) {
3913
3923
  });
3914
3924
  const normalized = normalizeAddress(address);
3915
3925
  if (!normalized.country) return none("INCOMPLETE" /* INCOMPLETE */);
3926
+ if (!shipsToCountry(normalized.country)) return none("NO_COVERAGE" /* NO_COVERAGE */);
3916
3927
  if (!postCodeMatchesProvince(normalized)) return none("ADDRESS_MISMATCH" /* ADDRESS_MISMATCH */);
3917
3928
  const zone = findZone(zones, addressPlaceKeys(normalized));
3918
3929
  if (!zone) return none("NO_COVERAGE" /* NO_COVERAGE */);
@@ -3977,7 +3988,9 @@ function countriesShippedTo(zones) {
3977
3988
  const countries = /* @__PURE__ */ new Set();
3978
3989
  for (const zone of zones) {
3979
3990
  if (!zone.ships) continue;
3980
- for (const key of zoneKeys(zone)) if (key !== EVERYWHERE_KEY) countries.add(key.slice(0, 2));
3991
+ for (const key of zoneKeys(zone)) {
3992
+ if (key !== EVERYWHERE_KEY && shipsToCountry(key.slice(0, 2))) countries.add(key.slice(0, 2));
3993
+ }
3981
3994
  }
3982
3995
  return [...countries].sort();
3983
3996
  }
@@ -3997,7 +4010,7 @@ function placeProblems(zone) {
3997
4010
  if (zone.places.length === 0) return [{ code: "NO_PLACES" /* NO_PLACES */ }];
3998
4011
  if (!zone.places.every((place) => fitsKind(place, zone.kind))) return [{ code: "INVALID_PLACE" /* INVALID_PLACE */ }];
3999
4012
  const keys = zone.places.map(placeKey);
4000
- if (keys.some((key) => !key)) return [{ code: "INVALID_PLACE" /* INVALID_PLACE */ }];
4013
+ if (keys.some((key) => !key || !shipsToCountry(key.slice(0, 2)))) return [{ code: "INVALID_PLACE" /* INVALID_PLACE */ }];
4001
4014
  if (new Set(keys).size !== keys.length) return [{ code: "DUPLICATE_PLACE" /* DUPLICATE_PLACE */ }];
4002
4015
  return [];
4003
4016
  }
@@ -4211,6 +4224,7 @@ export {
4211
4224
  ResidualPaymentMethod,
4212
4225
  ResidualStatus,
4213
4226
  ResourceAvailabilityState,
4227
+ SHIPPING_COUNTRIES,
4214
4228
  STATE_SCHEMA,
4215
4229
  STRIPE_SUPPORTED_COUNTRIES,
4216
4230
  SYSTEM_FAMILIES,
@@ -4316,6 +4330,7 @@ export {
4316
4330
  lineStockMoves,
4317
4331
  listCountries,
4318
4332
  listProvinces,
4333
+ listShippingCountries,
4319
4334
  mapToLegacyStatus,
4320
4335
  maxPrecisionFor,
4321
4336
  mergeFragment,
@@ -4351,6 +4366,7 @@ export {
4351
4366
  roundToPrecision,
4352
4367
  sameFamily,
4353
4368
  setOrderState,
4369
+ shipsToCountry,
4354
4370
  shopDayKey,
4355
4371
  shopDayRange,
4356
4372
  signReportForDisplay,