@final-commerce/common 2.5.1-preprod.2 → 2.5.1-preprod.4

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,6 +2492,51 @@ 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
+
2495
2540
  // order-state-machine/write-strategy.ts
2496
2541
  var LegacyWriteStrategy = class {
2497
2542
  applyState(_order) {
@@ -3204,10 +3249,29 @@ var AFFIRM_PRICE_PLANS = ["core", "standard", "signature"];
3204
3249
  function isAffirmPricePlan(value) {
3205
3250
  return typeof value === "string" && AFFIRM_PRICE_PLANS.includes(value);
3206
3251
  }
3252
+ var AFFIRM_COUNTRY_CODES = /* @__PURE__ */ new Set(["CA"]);
3253
+ function isAffirmCountry(alpha2) {
3254
+ return !!alpha2 && AFFIRM_COUNTRY_CODES.has(alpha2.toUpperCase());
3255
+ }
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"
3267
+ };
3207
3268
  export {
3208
3269
  ADYEN_ROLLOUT_COUNTRY_CODES,
3270
+ AFFIRM_COUNTRY_CODES,
3209
3271
  AFFIRM_PRICE_PLANS,
3210
3272
  AttributeType,
3273
+ BNPL_METHOD_STATUS,
3274
+ BNPL_SKIP_REASON,
3211
3275
  BookingRatePeriod,
3212
3276
  BookingResourceKind,
3213
3277
  BookingResourceStatus,
@@ -3332,12 +3396,15 @@ export {
3332
3396
  getPricingRegionFromCountry,
3333
3397
  getSettlementTotal,
3334
3398
  getTotalCollected,
3399
+ hasInCartFlag,
3335
3400
  holdExpiresAt,
3336
3401
  inferStatesFromLegacyStatus,
3337
3402
  isAdyenRolloutCountry,
3403
+ isAffirmCountry,
3338
3404
  isAffirmPricePlan,
3339
3405
  isConditionOperator,
3340
3406
  isFulfillmentState,
3407
+ isInCart,
3341
3408
  isPaymentState,
3342
3409
  isSupportedCurrency,
3343
3410
  isSystemFamilyCode,
@@ -3371,6 +3438,7 @@ export {
3371
3438
  toMinorUnits,
3372
3439
  validateConfig,
3373
3440
  validateFragmentCompatibility,
3441
+ validateOrderStatuses,
3374
3442
  violatesFinancialInvariant,
3375
3443
  windowEndsAt,
3376
3444
  withinPresence