@final-commerce/common 2.5.1-preprod.5 → 2.5.1-staging2.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/dist/index.mjs CHANGED
@@ -2492,51 +2492,6 @@ function inferStatesFromLegacyStatus(order) {
2492
2492
  return { payment: "unpaid", fulfillment: "pending" };
2493
2493
  }
2494
2494
 
2495
- // order-state-machine/in-cart.ts
2496
- function hasInCartFlag(order) {
2497
- return order.inCart != null;
2498
- }
2499
- function isInCart(order) {
2500
- if (order.inCart != null) return order.inCart.active === true;
2501
- if (order.fulfillmentState) return order.fulfillmentState === "draft";
2502
- return (order.status ?? "").trim().toLowerCase() === "in-cart";
2503
- }
2504
-
2505
- // order-state-machine/order-status.ts
2506
- function validateOrderStatuses(statuses) {
2507
- if (!Array.isArray(statuses)) {
2508
- return [{ index: -1, field: "orderStatuses", message: "must be an array" }];
2509
- }
2510
- const errors = [];
2511
- const seen = /* @__PURE__ */ new Set();
2512
- statuses.forEach((raw, index) => {
2513
- const s = raw ?? {};
2514
- const add = (field, message) => errors.push({ index, field, message });
2515
- if (typeof s.id !== "string" || !s.id.trim()) add("id", "must be a non-empty string");
2516
- else if (seen.has(s.id)) add("id", `duplicate id "${s.id}"`);
2517
- else seen.add(s.id);
2518
- if (typeof s.label !== "string" || !s.label.trim()) add("label", "must be a non-empty string");
2519
- for (const field of ["color", "icon"]) {
2520
- if (s[field] !== void 0 && typeof s[field] !== "string") add(field, "must be a string");
2521
- }
2522
- if (s.fulfillmentState !== void 0 && !(typeof s.fulfillmentState === "string" && isFulfillmentState(s.fulfillmentState))) {
2523
- add("fulfillmentState", `"${String(s.fulfillmentState)}" is not a fulfillment state`);
2524
- }
2525
- if (s.requiresPaymentState !== void 0) {
2526
- if (!Array.isArray(s.requiresPaymentState) || s.requiresPaymentState.length === 0) {
2527
- add("requiresPaymentState", "must be a non-empty array of payment states");
2528
- } else {
2529
- for (const p of s.requiresPaymentState) {
2530
- if (!(typeof p === "string" && isPaymentState(p))) {
2531
- add("requiresPaymentState", `"${String(p)}" is not a payment state`);
2532
- }
2533
- }
2534
- }
2535
- }
2536
- });
2537
- return errors;
2538
- }
2539
-
2540
2495
  // order-state-machine/write-strategy.ts
2541
2496
  var LegacyWriteStrategy = class {
2542
2497
  applyState(_order) {
@@ -3048,7 +3003,9 @@ function buildGrid(rule, timeZone, from, to, now, busy = []) {
3048
3003
  const start = startAt.getTime();
3049
3004
  if (start < askedFrom || start >= askedTo) return false;
3050
3005
  if (start < notBefore || start > notAfter) return false;
3051
- return !blocked.some(({ from: blockFrom, to: blockTo }) => start < blockTo && bufferEndAt.getTime() > blockFrom);
3006
+ return !blocked.some(
3007
+ ({ from: blockFrom, to: blockTo }) => start < blockTo && bufferEndAt.getTime() > blockFrom
3008
+ );
3052
3009
  }).sort((first, second) => +first.startAt - +second.startAt);
3053
3010
  }
3054
3011
  function slotsForWindow(grid, startAt, endAt) {
@@ -3167,7 +3124,14 @@ function buildAvailability({
3167
3124
  for (const slot of slots2) {
3168
3125
  const { taken, foreignProductId } = occupancyIn(mine, productId, slot.startAt, slot.bufferEndAt, shared);
3169
3126
  const free = foreignProductId ? 0 : Math.max(capacity - taken, 0);
3170
- const entry = byInstant.get(+slot.startAt) ?? { ...slot, capacity: 0, booked: 0, free: 0, resources: [], dayKey: shopDayKey(slot.startAt, resource.timeZone) };
3127
+ const entry = byInstant.get(+slot.startAt) ?? {
3128
+ ...slot,
3129
+ capacity: 0,
3130
+ booked: 0,
3131
+ free: 0,
3132
+ resources: [],
3133
+ dayKey: shopDayKey(slot.startAt, resource.timeZone)
3134
+ };
3171
3135
  entry.capacity += capacity;
3172
3136
  entry.booked += foreignProductId ? capacity : taken;
3173
3137
  entry.free += free;
@@ -3245,33 +3209,38 @@ var ADYEN_ROLLOUT_COUNTRY_CODES = /* @__PURE__ */ new Set(["CA"]);
3245
3209
  function isAdyenRolloutCountry(alpha2) {
3246
3210
  return ADYEN_ROLLOUT_COUNTRY_CODES.has(alpha2);
3247
3211
  }
3248
- var AFFIRM_PRICE_PLANS = ["core", "standard", "signature"];
3249
- function isAffirmPricePlan(value) {
3250
- return typeof value === "string" && AFFIRM_PRICE_PLANS.includes(value);
3212
+ var ADYEN_STORE_STATE_PROVINCE_COUNTRIES = /* @__PURE__ */ new Set(["AU", "BR", "CA", "IN", "MX", "NZ", "US"]);
3213
+ function adyenStoreRequiresStateOrProvince(alpha2) {
3214
+ return !!alpha2 && ADYEN_STORE_STATE_PROVINCE_COUNTRIES.has(alpha2);
3251
3215
  }
3252
- var AFFIRM_COUNTRY_CODES = /* @__PURE__ */ new Set(["CA"]);
3253
- function isAffirmCountry(alpha2) {
3254
- return !!alpha2 && AFFIRM_COUNTRY_CODES.has(alpha2.toUpperCase());
3216
+ var ADYEN_LEGAL_ENTITY_STATE_PROVINCE_COUNTRIES = /* @__PURE__ */ new Set(["AU", "BR", "CA", "IN", "MX", "NZ", "US"]);
3217
+ function adyenLegalEntityRequiresStateOrProvince(alpha2) {
3218
+ return !!alpha2 && ADYEN_LEGAL_ENTITY_STATE_PROVINCE_COUNTRIES.has(alpha2);
3255
3219
  }
3256
- var BNPL_METHOD_STATUS = {
3257
- ACTIVE: "active",
3258
- PENDING: "pending",
3259
- UNAVAILABLE: "unavailable",
3260
- UNKNOWN: "unknown"
3261
- };
3262
- var BNPL_SKIP_REASON = {
3263
- PENDING: "pending",
3264
- NO_SUPPORT_EMAIL: "no_support_email",
3265
- NO_CURRENCY: "no_currency",
3266
- NO_BUSINESS_LINE: "no_business_line"
3220
+ var ADYEN_NO_TAX_NUMBER_ABSENT_COUNTRIES = /* @__PURE__ */ new Set(["CA"]);
3221
+ function adyenSupportsTaxNumberAbsent(alpha2) {
3222
+ return !!alpha2 && !ADYEN_NO_TAX_NUMBER_ABSENT_COUNTRIES.has(alpha2);
3223
+ }
3224
+ var ADYEN_TAX_NUMBER_FORMATS = {
3225
+ CA: { pattern: /^\d{9}$/, length: 9 }
3267
3226
  };
3227
+ function adyenTaxNumberFormat(alpha2) {
3228
+ return alpha2 ? ADYEN_TAX_NUMBER_FORMATS[alpha2] : void 0;
3229
+ }
3230
+ var ADYEN_TAX_NUMBER_MIN_LENGTH = 5;
3231
+ var ADYEN_JOB_TITLE_ASSOCIATION_TYPES = ["signatory", "uboThroughControl"];
3232
+ function adyenRequiresJobTitle(associationType) {
3233
+ return ADYEN_JOB_TITLE_ASSOCIATION_TYPES.includes(associationType);
3234
+ }
3268
3235
  export {
3236
+ ADYEN_JOB_TITLE_ASSOCIATION_TYPES,
3237
+ ADYEN_LEGAL_ENTITY_STATE_PROVINCE_COUNTRIES,
3238
+ ADYEN_NO_TAX_NUMBER_ABSENT_COUNTRIES,
3269
3239
  ADYEN_ROLLOUT_COUNTRY_CODES,
3270
- AFFIRM_COUNTRY_CODES,
3271
- AFFIRM_PRICE_PLANS,
3240
+ ADYEN_STORE_STATE_PROVINCE_COUNTRIES,
3241
+ ADYEN_TAX_NUMBER_FORMATS,
3242
+ ADYEN_TAX_NUMBER_MIN_LENGTH,
3272
3243
  AttributeType,
3273
- BNPL_METHOD_STATUS,
3274
- BNPL_SKIP_REASON,
3275
3244
  BookingRatePeriod,
3276
3245
  BookingResourceKind,
3277
3246
  BookingResourceStatus,
@@ -3348,6 +3317,11 @@ export {
3348
3317
  TopMetericsSort,
3349
3318
  UserTypes,
3350
3319
  addAmounts,
3320
+ adyenLegalEntityRequiresStateOrProvince,
3321
+ adyenRequiresJobTitle,
3322
+ adyenStoreRequiresStateOrProvince,
3323
+ adyenSupportsTaxNumberAbsent,
3324
+ adyenTaxNumberFormat,
3351
3325
  amountToString,
3352
3326
  assertUnitSane,
3353
3327
  availableIn,
@@ -3396,15 +3370,11 @@ export {
3396
3370
  getPricingRegionFromCountry,
3397
3371
  getSettlementTotal,
3398
3372
  getTotalCollected,
3399
- hasInCartFlag,
3400
3373
  holdExpiresAt,
3401
3374
  inferStatesFromLegacyStatus,
3402
3375
  isAdyenRolloutCountry,
3403
- isAffirmCountry,
3404
- isAffirmPricePlan,
3405
3376
  isConditionOperator,
3406
3377
  isFulfillmentState,
3407
- isInCart,
3408
3378
  isPaymentState,
3409
3379
  isSupportedCurrency,
3410
3380
  isSystemFamilyCode,
@@ -3438,7 +3408,6 @@ export {
3438
3408
  toMinorUnits,
3439
3409
  validateConfig,
3440
3410
  validateFragmentCompatibility,
3441
- validateOrderStatuses,
3442
3411
  violatesFinancialInvariant,
3443
3412
  windowEndsAt,
3444
3413
  withinPresence