@final-commerce/common 2.6.1-staging2.1 → 2.7.0
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 +87 -69
- package/dist/pos-types/index.d.ts +87 -69
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2810,19 +2810,27 @@ function isInCart(order) {
|
|
|
2810
2810
|
}
|
|
2811
2811
|
|
|
2812
2812
|
// order-state-machine/order-status.ts
|
|
2813
|
+
var STATUS_KEY = /^[a-z0-9][a-z0-9_-]*$/;
|
|
2813
2814
|
function validateOrderStatuses(statuses) {
|
|
2814
2815
|
if (!Array.isArray(statuses)) {
|
|
2815
2816
|
return [{ index: -1, field: "orderStatuses", message: "must be an array" }];
|
|
2816
2817
|
}
|
|
2817
2818
|
const errors = [];
|
|
2818
|
-
const
|
|
2819
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
2820
|
+
const seenKeys = /* @__PURE__ */ new Set();
|
|
2819
2821
|
statuses.forEach((raw, index) => {
|
|
2820
2822
|
const s = raw ?? {};
|
|
2821
2823
|
const add = (field, message) => errors.push({ index, field, message });
|
|
2822
2824
|
if (typeof s.id !== "string" || !s.id.trim()) add("id", "must be a non-empty string");
|
|
2823
|
-
else if (
|
|
2824
|
-
else
|
|
2825
|
-
if (typeof s.
|
|
2825
|
+
else if (seenIds.has(s.id)) add("id", `duplicate id "${s.id}"`);
|
|
2826
|
+
else seenIds.add(s.id);
|
|
2827
|
+
if (typeof s.key !== "string" || !STATUS_KEY.test(s.key)) {
|
|
2828
|
+
add("key", 'must be lowercase letters, digits, "-" or "_"');
|
|
2829
|
+
} else if (seenKeys.has(s.key)) add("key", `duplicate key "${s.key}"`);
|
|
2830
|
+
else seenKeys.add(s.key);
|
|
2831
|
+
if (typeof s.defaultLabel !== "string" || !s.defaultLabel.trim()) {
|
|
2832
|
+
add("defaultLabel", "must be a non-empty string");
|
|
2833
|
+
}
|
|
2826
2834
|
for (const field of ["color", "icon"]) {
|
|
2827
2835
|
if (s[field] !== void 0 && typeof s[field] !== "string") add(field, "must be a string");
|
|
2828
2836
|
}
|