@final-commerce/common 2.2.0-beta.2 → 2.2.0-staging.1
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 +36 -35
- package/dist/index.d.ts +36 -35
- package/dist/index.js +23 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -189,7 +189,8 @@ declare enum Platform {
|
|
|
189
189
|
}
|
|
190
190
|
declare enum OrderPlatform {
|
|
191
191
|
POS = "in-store",
|
|
192
|
-
WOO_COMMERCE = "woo-commerce"
|
|
192
|
+
WOO_COMMERCE = "woo-commerce",
|
|
193
|
+
PUBLIC_API = "public-api"
|
|
193
194
|
}
|
|
194
195
|
declare enum CustomerPlatform {
|
|
195
196
|
POS = "in-store",
|
|
@@ -1030,6 +1031,40 @@ declare function setOrderState(order: OrderStateWritable, paymentState: PaymentS
|
|
|
1030
1031
|
|
|
1031
1032
|
declare function inferStatesFromLegacyStatus(order: OrderLikeForLegacyInference): StatePair;
|
|
1032
1033
|
|
|
1034
|
+
interface OrderMutationData extends OrderStateWritable {
|
|
1035
|
+
total?: number;
|
|
1036
|
+
balance?: number;
|
|
1037
|
+
paymentMethods?: {
|
|
1038
|
+
amount?: number;
|
|
1039
|
+
[key: string]: unknown;
|
|
1040
|
+
}[];
|
|
1041
|
+
refunds?: {
|
|
1042
|
+
quantity?: number;
|
|
1043
|
+
[key: string]: unknown;
|
|
1044
|
+
}[];
|
|
1045
|
+
refund?: {
|
|
1046
|
+
quantity?: number;
|
|
1047
|
+
[key: string]: unknown;
|
|
1048
|
+
}[];
|
|
1049
|
+
lineItems?: {
|
|
1050
|
+
quantity?: number;
|
|
1051
|
+
fulfilledQuantity?: number;
|
|
1052
|
+
returnedQuantity?: number;
|
|
1053
|
+
[key: string]: unknown;
|
|
1054
|
+
}[];
|
|
1055
|
+
}
|
|
1056
|
+
interface OrderWriteStrategy {
|
|
1057
|
+
applyState(order: OrderMutationData): void;
|
|
1058
|
+
}
|
|
1059
|
+
declare class LegacyWriteStrategy implements OrderWriteStrategy {
|
|
1060
|
+
applyState(_order: OrderMutationData): void;
|
|
1061
|
+
}
|
|
1062
|
+
declare class DualWriteStrategy implements OrderWriteStrategy {
|
|
1063
|
+
private readonly config;
|
|
1064
|
+
constructor(config: StoredStateConfig);
|
|
1065
|
+
applyState(order: OrderMutationData): void;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1033
1068
|
interface ResolveTemplateResult {
|
|
1034
1069
|
fragment: StateConfigFragment;
|
|
1035
1070
|
resolvedValues: Record<string, unknown>;
|
|
@@ -1145,40 +1180,6 @@ interface ConfigUpdatedPayload {
|
|
|
1145
1180
|
}
|
|
1146
1181
|
type OrderStateEventPayload = StateTransitionCompletedPayload | StateTransitionBlockedPayload | ConfigUpdatedPayload;
|
|
1147
1182
|
|
|
1148
|
-
interface OrderMutationData extends OrderStateWritable {
|
|
1149
|
-
total?: number;
|
|
1150
|
-
balance?: number;
|
|
1151
|
-
paymentMethods?: {
|
|
1152
|
-
amount?: number;
|
|
1153
|
-
[key: string]: unknown;
|
|
1154
|
-
}[];
|
|
1155
|
-
refunds?: {
|
|
1156
|
-
quantity?: number;
|
|
1157
|
-
[key: string]: unknown;
|
|
1158
|
-
}[];
|
|
1159
|
-
refund?: {
|
|
1160
|
-
quantity?: number;
|
|
1161
|
-
[key: string]: unknown;
|
|
1162
|
-
}[];
|
|
1163
|
-
lineItems?: {
|
|
1164
|
-
quantity?: number;
|
|
1165
|
-
fulfilledQuantity?: number;
|
|
1166
|
-
returnedQuantity?: number;
|
|
1167
|
-
[key: string]: unknown;
|
|
1168
|
-
}[];
|
|
1169
|
-
}
|
|
1170
|
-
interface OrderWriteStrategy {
|
|
1171
|
-
applyState(order: OrderMutationData): void;
|
|
1172
|
-
}
|
|
1173
|
-
declare class LegacyWriteStrategy implements OrderWriteStrategy {
|
|
1174
|
-
applyState(_order: OrderMutationData): void;
|
|
1175
|
-
}
|
|
1176
|
-
declare class DualWriteStrategy implements OrderWriteStrategy {
|
|
1177
|
-
private readonly config;
|
|
1178
|
-
constructor(config: StoredStateConfig);
|
|
1179
|
-
applyState(order: OrderMutationData): void;
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
1183
|
interface CurrencyRate {
|
|
1183
1184
|
rate: number;
|
|
1184
1185
|
country: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -189,7 +189,8 @@ declare enum Platform {
|
|
|
189
189
|
}
|
|
190
190
|
declare enum OrderPlatform {
|
|
191
191
|
POS = "in-store",
|
|
192
|
-
WOO_COMMERCE = "woo-commerce"
|
|
192
|
+
WOO_COMMERCE = "woo-commerce",
|
|
193
|
+
PUBLIC_API = "public-api"
|
|
193
194
|
}
|
|
194
195
|
declare enum CustomerPlatform {
|
|
195
196
|
POS = "in-store",
|
|
@@ -1030,6 +1031,40 @@ declare function setOrderState(order: OrderStateWritable, paymentState: PaymentS
|
|
|
1030
1031
|
|
|
1031
1032
|
declare function inferStatesFromLegacyStatus(order: OrderLikeForLegacyInference): StatePair;
|
|
1032
1033
|
|
|
1034
|
+
interface OrderMutationData extends OrderStateWritable {
|
|
1035
|
+
total?: number;
|
|
1036
|
+
balance?: number;
|
|
1037
|
+
paymentMethods?: {
|
|
1038
|
+
amount?: number;
|
|
1039
|
+
[key: string]: unknown;
|
|
1040
|
+
}[];
|
|
1041
|
+
refunds?: {
|
|
1042
|
+
quantity?: number;
|
|
1043
|
+
[key: string]: unknown;
|
|
1044
|
+
}[];
|
|
1045
|
+
refund?: {
|
|
1046
|
+
quantity?: number;
|
|
1047
|
+
[key: string]: unknown;
|
|
1048
|
+
}[];
|
|
1049
|
+
lineItems?: {
|
|
1050
|
+
quantity?: number;
|
|
1051
|
+
fulfilledQuantity?: number;
|
|
1052
|
+
returnedQuantity?: number;
|
|
1053
|
+
[key: string]: unknown;
|
|
1054
|
+
}[];
|
|
1055
|
+
}
|
|
1056
|
+
interface OrderWriteStrategy {
|
|
1057
|
+
applyState(order: OrderMutationData): void;
|
|
1058
|
+
}
|
|
1059
|
+
declare class LegacyWriteStrategy implements OrderWriteStrategy {
|
|
1060
|
+
applyState(_order: OrderMutationData): void;
|
|
1061
|
+
}
|
|
1062
|
+
declare class DualWriteStrategy implements OrderWriteStrategy {
|
|
1063
|
+
private readonly config;
|
|
1064
|
+
constructor(config: StoredStateConfig);
|
|
1065
|
+
applyState(order: OrderMutationData): void;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1033
1068
|
interface ResolveTemplateResult {
|
|
1034
1069
|
fragment: StateConfigFragment;
|
|
1035
1070
|
resolvedValues: Record<string, unknown>;
|
|
@@ -1145,40 +1180,6 @@ interface ConfigUpdatedPayload {
|
|
|
1145
1180
|
}
|
|
1146
1181
|
type OrderStateEventPayload = StateTransitionCompletedPayload | StateTransitionBlockedPayload | ConfigUpdatedPayload;
|
|
1147
1182
|
|
|
1148
|
-
interface OrderMutationData extends OrderStateWritable {
|
|
1149
|
-
total?: number;
|
|
1150
|
-
balance?: number;
|
|
1151
|
-
paymentMethods?: {
|
|
1152
|
-
amount?: number;
|
|
1153
|
-
[key: string]: unknown;
|
|
1154
|
-
}[];
|
|
1155
|
-
refunds?: {
|
|
1156
|
-
quantity?: number;
|
|
1157
|
-
[key: string]: unknown;
|
|
1158
|
-
}[];
|
|
1159
|
-
refund?: {
|
|
1160
|
-
quantity?: number;
|
|
1161
|
-
[key: string]: unknown;
|
|
1162
|
-
}[];
|
|
1163
|
-
lineItems?: {
|
|
1164
|
-
quantity?: number;
|
|
1165
|
-
fulfilledQuantity?: number;
|
|
1166
|
-
returnedQuantity?: number;
|
|
1167
|
-
[key: string]: unknown;
|
|
1168
|
-
}[];
|
|
1169
|
-
}
|
|
1170
|
-
interface OrderWriteStrategy {
|
|
1171
|
-
applyState(order: OrderMutationData): void;
|
|
1172
|
-
}
|
|
1173
|
-
declare class LegacyWriteStrategy implements OrderWriteStrategy {
|
|
1174
|
-
applyState(_order: OrderMutationData): void;
|
|
1175
|
-
}
|
|
1176
|
-
declare class DualWriteStrategy implements OrderWriteStrategy {
|
|
1177
|
-
private readonly config;
|
|
1178
|
-
constructor(config: StoredStateConfig);
|
|
1179
|
-
applyState(order: OrderMutationData): void;
|
|
1180
|
-
}
|
|
1181
|
-
|
|
1182
1183
|
interface CurrencyRate {
|
|
1183
1184
|
rate: number;
|
|
1184
1185
|
country: string;
|
package/dist/index.js
CHANGED
|
@@ -369,6 +369,7 @@ var Platform = /* @__PURE__ */ ((Platform2) => {
|
|
|
369
369
|
var OrderPlatform = /* @__PURE__ */ ((OrderPlatform2) => {
|
|
370
370
|
OrderPlatform2["POS"] = "in-store";
|
|
371
371
|
OrderPlatform2["WOO_COMMERCE"] = "woo-commerce";
|
|
372
|
+
OrderPlatform2["PUBLIC_API"] = "public-api";
|
|
372
373
|
return OrderPlatform2;
|
|
373
374
|
})(OrderPlatform || {});
|
|
374
375
|
var CustomerPlatform = /* @__PURE__ */ ((CustomerPlatform2) => {
|
|
@@ -1446,10 +1447,7 @@ function negateAtPaths(value, path, paths) {
|
|
|
1446
1447
|
function padHex(value, length) {
|
|
1447
1448
|
return value.toString(16).padStart(length, "0");
|
|
1448
1449
|
}
|
|
1449
|
-
var PROCESS_RANDOM = Array.from(
|
|
1450
|
-
{ length: 5 },
|
|
1451
|
-
() => padHex(Math.floor(Math.random() * 256), 2)
|
|
1452
|
-
).join("");
|
|
1450
|
+
var PROCESS_RANDOM = Array.from({ length: 5 }, () => padHex(Math.floor(Math.random() * 256), 2)).join("");
|
|
1453
1451
|
var objectIdCounter = Math.floor(Math.random() * 16777215);
|
|
1454
1452
|
function generateMongoID() {
|
|
1455
1453
|
const timestamp = padHex(Math.floor(Date.now() / 1e3), 8);
|
|
@@ -2594,6 +2592,27 @@ function inferStatesFromLegacyStatus(order) {
|
|
|
2594
2592
|
return { payment: "unpaid", fulfillment: "pending" };
|
|
2595
2593
|
}
|
|
2596
2594
|
|
|
2595
|
+
// order-state-machine/write-strategy.ts
|
|
2596
|
+
var LegacyWriteStrategy = class {
|
|
2597
|
+
applyState(_order) {
|
|
2598
|
+
}
|
|
2599
|
+
};
|
|
2600
|
+
var DualWriteStrategy = class {
|
|
2601
|
+
constructor(config) {
|
|
2602
|
+
this.config = config;
|
|
2603
|
+
}
|
|
2604
|
+
applyState(order) {
|
|
2605
|
+
if (order.paymentState && order.fulfillmentState) {
|
|
2606
|
+
setOrderState(order, order.paymentState, order.fulfillmentState, this.config);
|
|
2607
|
+
return;
|
|
2608
|
+
}
|
|
2609
|
+
if (order.status) {
|
|
2610
|
+
const inferred = inferStatesFromLegacyStatus(order);
|
|
2611
|
+
setOrderState(order, inferred.payment, inferred.fulfillment, this.config);
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
};
|
|
2615
|
+
|
|
2597
2616
|
// order-state-machine/resolve-template.ts
|
|
2598
2617
|
function resolveTemplate(templateJson, params, values = {}) {
|
|
2599
2618
|
const resolvedValues = {};
|
|
@@ -2895,27 +2914,6 @@ var ORDER_STATE_EVENTS = {
|
|
|
2895
2914
|
stateTransitionBlocked: "state-transition-blocked",
|
|
2896
2915
|
configUpdated: "config-updated"
|
|
2897
2916
|
};
|
|
2898
|
-
|
|
2899
|
-
// order-state-machine/write-strategy.ts
|
|
2900
|
-
var LegacyWriteStrategy = class {
|
|
2901
|
-
applyState(_order) {
|
|
2902
|
-
}
|
|
2903
|
-
};
|
|
2904
|
-
var DualWriteStrategy = class {
|
|
2905
|
-
constructor(config) {
|
|
2906
|
-
this.config = config;
|
|
2907
|
-
}
|
|
2908
|
-
applyState(order) {
|
|
2909
|
-
if (order.paymentState && order.fulfillmentState) {
|
|
2910
|
-
setOrderState(order, order.paymentState, order.fulfillmentState, this.config);
|
|
2911
|
-
return;
|
|
2912
|
-
}
|
|
2913
|
-
if (order.status) {
|
|
2914
|
-
const inferred = inferStatesFromLegacyStatus(order);
|
|
2915
|
-
setOrderState(order, inferred.payment, inferred.fulfillment, this.config);
|
|
2916
|
-
}
|
|
2917
|
-
}
|
|
2918
|
-
};
|
|
2919
2917
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2920
2918
|
0 && (module.exports = {
|
|
2921
2919
|
AttributeType,
|