@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.d.mts
CHANGED
|
@@ -859,21 +859,6 @@ declare function isConditionOperator(value: string): value is ConditionOperator;
|
|
|
859
859
|
type PathMode = 'strict' | 'permissive';
|
|
860
860
|
declare const PATH_MODES: readonly PathMode[];
|
|
861
861
|
|
|
862
|
-
interface OrderStatusDefinition {
|
|
863
|
-
id: string;
|
|
864
|
-
label: string;
|
|
865
|
-
color?: string;
|
|
866
|
-
icon?: string;
|
|
867
|
-
fulfillmentState?: FulfillmentState;
|
|
868
|
-
requiresPaymentState?: PaymentState[];
|
|
869
|
-
}
|
|
870
|
-
interface OrderStatusValidationError {
|
|
871
|
-
index: number;
|
|
872
|
-
field: string;
|
|
873
|
-
message: string;
|
|
874
|
-
}
|
|
875
|
-
declare function validateOrderStatuses(statuses: unknown): OrderStatusValidationError[];
|
|
876
|
-
|
|
877
862
|
interface OrderPaymentMethod {
|
|
878
863
|
id?: string;
|
|
879
864
|
amount?: number;
|
|
@@ -1047,7 +1032,6 @@ interface StoredStateConfig {
|
|
|
1047
1032
|
validInitialStates: StatePair[];
|
|
1048
1033
|
enforceValidInitialStates?: boolean;
|
|
1049
1034
|
displayStateMap: DisplayStateRule[];
|
|
1050
|
-
orderStatuses?: OrderStatusDefinition[];
|
|
1051
1035
|
createdAt: Date;
|
|
1052
1036
|
updatedAt: Date;
|
|
1053
1037
|
}
|
|
@@ -1179,6 +1163,22 @@ interface OrderLikeForInCart {
|
|
|
1179
1163
|
declare function hasInCartFlag(order: OrderLikeForInCart): boolean;
|
|
1180
1164
|
declare function isInCart(order: OrderLikeForInCart): boolean;
|
|
1181
1165
|
|
|
1166
|
+
interface OrderStatusDefinition {
|
|
1167
|
+
id: string;
|
|
1168
|
+
key: string;
|
|
1169
|
+
defaultLabel: string;
|
|
1170
|
+
color?: string;
|
|
1171
|
+
icon?: string;
|
|
1172
|
+
fulfillmentState?: FulfillmentState;
|
|
1173
|
+
requiresPaymentState?: PaymentState[];
|
|
1174
|
+
}
|
|
1175
|
+
interface OrderStatusValidationError {
|
|
1176
|
+
index: number;
|
|
1177
|
+
field: string;
|
|
1178
|
+
message: string;
|
|
1179
|
+
}
|
|
1180
|
+
declare function validateOrderStatuses(statuses: unknown): OrderStatusValidationError[];
|
|
1181
|
+
|
|
1182
1182
|
interface OrderMutationData extends OrderStateWritable {
|
|
1183
1183
|
total?: number;
|
|
1184
1184
|
balance?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -859,21 +859,6 @@ declare function isConditionOperator(value: string): value is ConditionOperator;
|
|
|
859
859
|
type PathMode = 'strict' | 'permissive';
|
|
860
860
|
declare const PATH_MODES: readonly PathMode[];
|
|
861
861
|
|
|
862
|
-
interface OrderStatusDefinition {
|
|
863
|
-
id: string;
|
|
864
|
-
label: string;
|
|
865
|
-
color?: string;
|
|
866
|
-
icon?: string;
|
|
867
|
-
fulfillmentState?: FulfillmentState;
|
|
868
|
-
requiresPaymentState?: PaymentState[];
|
|
869
|
-
}
|
|
870
|
-
interface OrderStatusValidationError {
|
|
871
|
-
index: number;
|
|
872
|
-
field: string;
|
|
873
|
-
message: string;
|
|
874
|
-
}
|
|
875
|
-
declare function validateOrderStatuses(statuses: unknown): OrderStatusValidationError[];
|
|
876
|
-
|
|
877
862
|
interface OrderPaymentMethod {
|
|
878
863
|
id?: string;
|
|
879
864
|
amount?: number;
|
|
@@ -1047,7 +1032,6 @@ interface StoredStateConfig {
|
|
|
1047
1032
|
validInitialStates: StatePair[];
|
|
1048
1033
|
enforceValidInitialStates?: boolean;
|
|
1049
1034
|
displayStateMap: DisplayStateRule[];
|
|
1050
|
-
orderStatuses?: OrderStatusDefinition[];
|
|
1051
1035
|
createdAt: Date;
|
|
1052
1036
|
updatedAt: Date;
|
|
1053
1037
|
}
|
|
@@ -1179,6 +1163,22 @@ interface OrderLikeForInCart {
|
|
|
1179
1163
|
declare function hasInCartFlag(order: OrderLikeForInCart): boolean;
|
|
1180
1164
|
declare function isInCart(order: OrderLikeForInCart): boolean;
|
|
1181
1165
|
|
|
1166
|
+
interface OrderStatusDefinition {
|
|
1167
|
+
id: string;
|
|
1168
|
+
key: string;
|
|
1169
|
+
defaultLabel: string;
|
|
1170
|
+
color?: string;
|
|
1171
|
+
icon?: string;
|
|
1172
|
+
fulfillmentState?: FulfillmentState;
|
|
1173
|
+
requiresPaymentState?: PaymentState[];
|
|
1174
|
+
}
|
|
1175
|
+
interface OrderStatusValidationError {
|
|
1176
|
+
index: number;
|
|
1177
|
+
field: string;
|
|
1178
|
+
message: string;
|
|
1179
|
+
}
|
|
1180
|
+
declare function validateOrderStatuses(statuses: unknown): OrderStatusValidationError[];
|
|
1181
|
+
|
|
1182
1182
|
interface OrderMutationData extends OrderStateWritable {
|
|
1183
1183
|
total?: number;
|
|
1184
1184
|
balance?: number;
|
package/dist/index.js
CHANGED
|
@@ -2714,19 +2714,27 @@ function isInCart(order) {
|
|
|
2714
2714
|
}
|
|
2715
2715
|
|
|
2716
2716
|
// order-state-machine/order-status.ts
|
|
2717
|
+
var STATUS_KEY = /^[a-z0-9][a-z0-9_-]*$/;
|
|
2717
2718
|
function validateOrderStatuses(statuses) {
|
|
2718
2719
|
if (!Array.isArray(statuses)) {
|
|
2719
2720
|
return [{ index: -1, field: "orderStatuses", message: "must be an array" }];
|
|
2720
2721
|
}
|
|
2721
2722
|
const errors = [];
|
|
2722
|
-
const
|
|
2723
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
2724
|
+
const seenKeys = /* @__PURE__ */ new Set();
|
|
2723
2725
|
statuses.forEach((raw, index) => {
|
|
2724
2726
|
const s = raw ?? {};
|
|
2725
2727
|
const add = (field, message) => errors.push({ index, field, message });
|
|
2726
2728
|
if (typeof s.id !== "string" || !s.id.trim()) add("id", "must be a non-empty string");
|
|
2727
|
-
else if (
|
|
2728
|
-
else
|
|
2729
|
-
if (typeof s.
|
|
2729
|
+
else if (seenIds.has(s.id)) add("id", `duplicate id "${s.id}"`);
|
|
2730
|
+
else seenIds.add(s.id);
|
|
2731
|
+
if (typeof s.key !== "string" || !STATUS_KEY.test(s.key)) {
|
|
2732
|
+
add("key", 'must be lowercase letters, digits, "-" or "_"');
|
|
2733
|
+
} else if (seenKeys.has(s.key)) add("key", `duplicate key "${s.key}"`);
|
|
2734
|
+
else seenKeys.add(s.key);
|
|
2735
|
+
if (typeof s.defaultLabel !== "string" || !s.defaultLabel.trim()) {
|
|
2736
|
+
add("defaultLabel", "must be a non-empty string");
|
|
2737
|
+
}
|
|
2730
2738
|
for (const field of ["color", "icon"]) {
|
|
2731
2739
|
if (s[field] !== void 0 && typeof s[field] !== "string") add(field, "must be a string");
|
|
2732
2740
|
}
|