@final-commerce/common 2.5.1-preprod.7 → 2.5.1-preprod.8
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 +16 -16
- package/dist/index.d.ts +16 -16
- package/dist/index.js +12 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -4
- package/dist/index.mjs.map +1 -1
- package/dist/pos-types/index.d.mts +81 -68
- package/dist/pos-types/index.d.ts +81 -68
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2503,19 +2503,27 @@ function isInCart(order) {
|
|
|
2503
2503
|
}
|
|
2504
2504
|
|
|
2505
2505
|
// order-state-machine/order-status.ts
|
|
2506
|
+
var STATUS_KEY = /^[a-z0-9][a-z0-9_-]*$/;
|
|
2506
2507
|
function validateOrderStatuses(statuses) {
|
|
2507
2508
|
if (!Array.isArray(statuses)) {
|
|
2508
2509
|
return [{ index: -1, field: "orderStatuses", message: "must be an array" }];
|
|
2509
2510
|
}
|
|
2510
2511
|
const errors = [];
|
|
2511
|
-
const
|
|
2512
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
2513
|
+
const seenKeys = /* @__PURE__ */ new Set();
|
|
2512
2514
|
statuses.forEach((raw, index) => {
|
|
2513
2515
|
const s = raw ?? {};
|
|
2514
2516
|
const add = (field, message) => errors.push({ index, field, message });
|
|
2515
2517
|
if (typeof s.id !== "string" || !s.id.trim()) add("id", "must be a non-empty string");
|
|
2516
|
-
else if (
|
|
2517
|
-
else
|
|
2518
|
-
if (typeof s.
|
|
2518
|
+
else if (seenIds.has(s.id)) add("id", `duplicate id "${s.id}"`);
|
|
2519
|
+
else seenIds.add(s.id);
|
|
2520
|
+
if (typeof s.key !== "string" || !STATUS_KEY.test(s.key)) {
|
|
2521
|
+
add("key", 'must be lowercase letters, digits, "-" or "_"');
|
|
2522
|
+
} else if (seenKeys.has(s.key)) add("key", `duplicate key "${s.key}"`);
|
|
2523
|
+
else seenKeys.add(s.key);
|
|
2524
|
+
if (typeof s.defaultLabel !== "string" || !s.defaultLabel.trim()) {
|
|
2525
|
+
add("defaultLabel", "must be a non-empty string");
|
|
2526
|
+
}
|
|
2519
2527
|
for (const field of ["color", "icon"]) {
|
|
2520
2528
|
if (s[field] !== void 0 && typeof s[field] !== "string") add(field, "must be a string");
|
|
2521
2529
|
}
|