@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.d.mts
CHANGED
|
@@ -1038,21 +1038,6 @@ declare function isConditionOperator(value: string): value is ConditionOperator;
|
|
|
1038
1038
|
type PathMode = 'strict' | 'permissive';
|
|
1039
1039
|
declare const PATH_MODES: readonly PathMode[];
|
|
1040
1040
|
|
|
1041
|
-
interface OrderStatusDefinition {
|
|
1042
|
-
id: string;
|
|
1043
|
-
label: string;
|
|
1044
|
-
color?: string;
|
|
1045
|
-
icon?: string;
|
|
1046
|
-
fulfillmentState?: FulfillmentState;
|
|
1047
|
-
requiresPaymentState?: PaymentState[];
|
|
1048
|
-
}
|
|
1049
|
-
interface OrderStatusValidationError {
|
|
1050
|
-
index: number;
|
|
1051
|
-
field: string;
|
|
1052
|
-
message: string;
|
|
1053
|
-
}
|
|
1054
|
-
declare function validateOrderStatuses(statuses: unknown): OrderStatusValidationError[];
|
|
1055
|
-
|
|
1056
1041
|
interface OrderPaymentMethod {
|
|
1057
1042
|
id?: string;
|
|
1058
1043
|
amount?: number;
|
|
@@ -1226,7 +1211,6 @@ interface StoredStateConfig {
|
|
|
1226
1211
|
validInitialStates: StatePair[];
|
|
1227
1212
|
enforceValidInitialStates?: boolean;
|
|
1228
1213
|
displayStateMap: DisplayStateRule[];
|
|
1229
|
-
orderStatuses?: OrderStatusDefinition[];
|
|
1230
1214
|
createdAt: Date;
|
|
1231
1215
|
updatedAt: Date;
|
|
1232
1216
|
}
|
|
@@ -1358,6 +1342,22 @@ interface OrderLikeForInCart {
|
|
|
1358
1342
|
declare function hasInCartFlag(order: OrderLikeForInCart): boolean;
|
|
1359
1343
|
declare function isInCart(order: OrderLikeForInCart): boolean;
|
|
1360
1344
|
|
|
1345
|
+
interface OrderStatusDefinition {
|
|
1346
|
+
id: string;
|
|
1347
|
+
key: string;
|
|
1348
|
+
defaultLabel: string;
|
|
1349
|
+
color?: string;
|
|
1350
|
+
icon?: string;
|
|
1351
|
+
fulfillmentState?: FulfillmentState;
|
|
1352
|
+
requiresPaymentState?: PaymentState[];
|
|
1353
|
+
}
|
|
1354
|
+
interface OrderStatusValidationError {
|
|
1355
|
+
index: number;
|
|
1356
|
+
field: string;
|
|
1357
|
+
message: string;
|
|
1358
|
+
}
|
|
1359
|
+
declare function validateOrderStatuses(statuses: unknown): OrderStatusValidationError[];
|
|
1360
|
+
|
|
1361
1361
|
interface OrderMutationData extends OrderStateWritable {
|
|
1362
1362
|
total?: number;
|
|
1363
1363
|
balance?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -1038,21 +1038,6 @@ declare function isConditionOperator(value: string): value is ConditionOperator;
|
|
|
1038
1038
|
type PathMode = 'strict' | 'permissive';
|
|
1039
1039
|
declare const PATH_MODES: readonly PathMode[];
|
|
1040
1040
|
|
|
1041
|
-
interface OrderStatusDefinition {
|
|
1042
|
-
id: string;
|
|
1043
|
-
label: string;
|
|
1044
|
-
color?: string;
|
|
1045
|
-
icon?: string;
|
|
1046
|
-
fulfillmentState?: FulfillmentState;
|
|
1047
|
-
requiresPaymentState?: PaymentState[];
|
|
1048
|
-
}
|
|
1049
|
-
interface OrderStatusValidationError {
|
|
1050
|
-
index: number;
|
|
1051
|
-
field: string;
|
|
1052
|
-
message: string;
|
|
1053
|
-
}
|
|
1054
|
-
declare function validateOrderStatuses(statuses: unknown): OrderStatusValidationError[];
|
|
1055
|
-
|
|
1056
1041
|
interface OrderPaymentMethod {
|
|
1057
1042
|
id?: string;
|
|
1058
1043
|
amount?: number;
|
|
@@ -1226,7 +1211,6 @@ interface StoredStateConfig {
|
|
|
1226
1211
|
validInitialStates: StatePair[];
|
|
1227
1212
|
enforceValidInitialStates?: boolean;
|
|
1228
1213
|
displayStateMap: DisplayStateRule[];
|
|
1229
|
-
orderStatuses?: OrderStatusDefinition[];
|
|
1230
1214
|
createdAt: Date;
|
|
1231
1215
|
updatedAt: Date;
|
|
1232
1216
|
}
|
|
@@ -1358,6 +1342,22 @@ interface OrderLikeForInCart {
|
|
|
1358
1342
|
declare function hasInCartFlag(order: OrderLikeForInCart): boolean;
|
|
1359
1343
|
declare function isInCart(order: OrderLikeForInCart): boolean;
|
|
1360
1344
|
|
|
1345
|
+
interface OrderStatusDefinition {
|
|
1346
|
+
id: string;
|
|
1347
|
+
key: string;
|
|
1348
|
+
defaultLabel: string;
|
|
1349
|
+
color?: string;
|
|
1350
|
+
icon?: string;
|
|
1351
|
+
fulfillmentState?: FulfillmentState;
|
|
1352
|
+
requiresPaymentState?: PaymentState[];
|
|
1353
|
+
}
|
|
1354
|
+
interface OrderStatusValidationError {
|
|
1355
|
+
index: number;
|
|
1356
|
+
field: string;
|
|
1357
|
+
message: string;
|
|
1358
|
+
}
|
|
1359
|
+
declare function validateOrderStatuses(statuses: unknown): OrderStatusValidationError[];
|
|
1360
|
+
|
|
1361
1361
|
interface OrderMutationData extends OrderStateWritable {
|
|
1362
1362
|
total?: number;
|
|
1363
1363
|
balance?: number;
|
package/dist/index.js
CHANGED
|
@@ -3038,19 +3038,27 @@ function isInCart(order) {
|
|
|
3038
3038
|
}
|
|
3039
3039
|
|
|
3040
3040
|
// order-state-machine/order-status.ts
|
|
3041
|
+
var STATUS_KEY = /^[a-z0-9][a-z0-9_-]*$/;
|
|
3041
3042
|
function validateOrderStatuses(statuses) {
|
|
3042
3043
|
if (!Array.isArray(statuses)) {
|
|
3043
3044
|
return [{ index: -1, field: "orderStatuses", message: "must be an array" }];
|
|
3044
3045
|
}
|
|
3045
3046
|
const errors = [];
|
|
3046
|
-
const
|
|
3047
|
+
const seenIds = /* @__PURE__ */ new Set();
|
|
3048
|
+
const seenKeys = /* @__PURE__ */ new Set();
|
|
3047
3049
|
statuses.forEach((raw, index) => {
|
|
3048
3050
|
const s = raw ?? {};
|
|
3049
3051
|
const add = (field, message) => errors.push({ index, field, message });
|
|
3050
3052
|
if (typeof s.id !== "string" || !s.id.trim()) add("id", "must be a non-empty string");
|
|
3051
|
-
else if (
|
|
3052
|
-
else
|
|
3053
|
-
if (typeof s.
|
|
3053
|
+
else if (seenIds.has(s.id)) add("id", `duplicate id "${s.id}"`);
|
|
3054
|
+
else seenIds.add(s.id);
|
|
3055
|
+
if (typeof s.key !== "string" || !STATUS_KEY.test(s.key)) {
|
|
3056
|
+
add("key", 'must be lowercase letters, digits, "-" or "_"');
|
|
3057
|
+
} else if (seenKeys.has(s.key)) add("key", `duplicate key "${s.key}"`);
|
|
3058
|
+
else seenKeys.add(s.key);
|
|
3059
|
+
if (typeof s.defaultLabel !== "string" || !s.defaultLabel.trim()) {
|
|
3060
|
+
add("defaultLabel", "must be a non-empty string");
|
|
3061
|
+
}
|
|
3054
3062
|
for (const field of ["color", "icon"]) {
|
|
3055
3063
|
if (s[field] !== void 0 && typeof s[field] !== "string") add(field, "must be a string");
|
|
3056
3064
|
}
|