@final-commerce/common 2.5.1-preprod.2 → 2.5.1-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.d.mts +27 -1
- package/dist/index.d.ts +27 -1
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +48 -0
- package/dist/index.mjs.map +1 -1
- package/dist/pos-types/index.d.mts +25 -2
- package/dist/pos-types/index.d.ts +25 -2
- package/dist/pos-types/index.js +1 -0
- package/dist/pos-types/index.js.map +1 -1
- package/dist/pos-types/index.mjs +1 -0
- package/dist/pos-types/index.mjs.map +1 -1
- package/package.json +1 -1
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) {
|
|
@@ -3332,12 +3377,14 @@ export {
|
|
|
3332
3377
|
getPricingRegionFromCountry,
|
|
3333
3378
|
getSettlementTotal,
|
|
3334
3379
|
getTotalCollected,
|
|
3380
|
+
hasInCartFlag,
|
|
3335
3381
|
holdExpiresAt,
|
|
3336
3382
|
inferStatesFromLegacyStatus,
|
|
3337
3383
|
isAdyenRolloutCountry,
|
|
3338
3384
|
isAffirmPricePlan,
|
|
3339
3385
|
isConditionOperator,
|
|
3340
3386
|
isFulfillmentState,
|
|
3387
|
+
isInCart,
|
|
3341
3388
|
isPaymentState,
|
|
3342
3389
|
isSupportedCurrency,
|
|
3343
3390
|
isSystemFamilyCode,
|
|
@@ -3371,6 +3418,7 @@ export {
|
|
|
3371
3418
|
toMinorUnits,
|
|
3372
3419
|
validateConfig,
|
|
3373
3420
|
validateFragmentCompatibility,
|
|
3421
|
+
validateOrderStatuses,
|
|
3374
3422
|
violatesFinancialInvariant,
|
|
3375
3423
|
windowEndsAt,
|
|
3376
3424
|
withinPresence
|