@final-commerce/common 2.0.4 → 2.0.5-beta.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 +37 -2
- package/dist/index.d.ts +37 -2
- package/dist/index.js +29 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -10
- package/dist/index.mjs.map +1 -1
- package/dist/pos-types/index.d.mts +1 -0
- package/dist/pos-types/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -199,6 +199,7 @@ var Platform = /* @__PURE__ */ ((Platform2) => {
|
|
|
199
199
|
var OrderPlatform = /* @__PURE__ */ ((OrderPlatform2) => {
|
|
200
200
|
OrderPlatform2["POS"] = "in-store";
|
|
201
201
|
OrderPlatform2["WOO_COMMERCE"] = "woo-commerce";
|
|
202
|
+
OrderPlatform2["PUBLIC_API"] = "public-api";
|
|
202
203
|
return OrderPlatform2;
|
|
203
204
|
})(OrderPlatform || {});
|
|
204
205
|
var CustomerPlatform = /* @__PURE__ */ ((CustomerPlatform2) => {
|
|
@@ -996,10 +997,7 @@ function negateAtPaths(value, path, paths) {
|
|
|
996
997
|
function padHex(value, length) {
|
|
997
998
|
return value.toString(16).padStart(length, "0");
|
|
998
999
|
}
|
|
999
|
-
var PROCESS_RANDOM = Array.from(
|
|
1000
|
-
{ length: 5 },
|
|
1001
|
-
() => padHex(Math.floor(Math.random() * 256), 2)
|
|
1002
|
-
).join("");
|
|
1000
|
+
var PROCESS_RANDOM = Array.from({ length: 5 }, () => padHex(Math.floor(Math.random() * 256), 2)).join("");
|
|
1003
1001
|
var objectIdCounter = Math.floor(Math.random() * 16777215);
|
|
1004
1002
|
function generateMongoID() {
|
|
1005
1003
|
const timestamp = padHex(Math.floor(Date.now() / 1e3), 8);
|
|
@@ -1217,12 +1215,8 @@ var DEFAULT_CROSS_AXIS_RULES = [
|
|
|
1217
1215
|
|
|
1218
1216
|
// order-state-machine/default-config.ts
|
|
1219
1217
|
var DEFAULT_EPOCH = /* @__PURE__ */ new Date(0);
|
|
1220
|
-
var PAYMENT_LABELS = new Map(
|
|
1221
|
-
|
|
1222
|
-
);
|
|
1223
|
-
var FULFILLMENT_LABELS = new Map(
|
|
1224
|
-
baseFulfillmentDefinitions().map((d) => [d.id, d.label])
|
|
1225
|
-
);
|
|
1218
|
+
var PAYMENT_LABELS = new Map(basePaymentDefinitions().map((d) => [d.id, d.label]));
|
|
1219
|
+
var FULFILLMENT_LABELS = new Map(baseFulfillmentDefinitions().map((d) => [d.id, d.label]));
|
|
1226
1220
|
var TERMINAL_PAYMENT_STATES = new Set(
|
|
1227
1221
|
basePaymentDefinitions().filter((d) => d.isTerminal).map((d) => d.id)
|
|
1228
1222
|
);
|
|
@@ -2134,6 +2128,27 @@ function inferStatesFromLegacyStatus(order) {
|
|
|
2134
2128
|
return { payment: "unpaid", fulfillment: "pending" };
|
|
2135
2129
|
}
|
|
2136
2130
|
|
|
2131
|
+
// order-state-machine/write-strategy.ts
|
|
2132
|
+
var LegacyWriteStrategy = class {
|
|
2133
|
+
applyState(_order) {
|
|
2134
|
+
}
|
|
2135
|
+
};
|
|
2136
|
+
var DualWriteStrategy = class {
|
|
2137
|
+
constructor(config) {
|
|
2138
|
+
this.config = config;
|
|
2139
|
+
}
|
|
2140
|
+
applyState(order) {
|
|
2141
|
+
if (order.paymentState && order.fulfillmentState) {
|
|
2142
|
+
setOrderState(order, order.paymentState, order.fulfillmentState, this.config);
|
|
2143
|
+
return;
|
|
2144
|
+
}
|
|
2145
|
+
if (order.status) {
|
|
2146
|
+
const inferred = inferStatesFromLegacyStatus(order);
|
|
2147
|
+
setOrderState(order, inferred.payment, inferred.fulfillment, this.config);
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
};
|
|
2151
|
+
|
|
2137
2152
|
// order-state-machine/resolve-template.ts
|
|
2138
2153
|
function resolveTemplate(templateJson, params, values = {}) {
|
|
2139
2154
|
const resolvedValues = {};
|
|
@@ -2448,6 +2463,7 @@ export {
|
|
|
2448
2463
|
DEFAULT_CROSS_AXIS_RULES,
|
|
2449
2464
|
DEFAULT_DISPLAY_STATE_MAP,
|
|
2450
2465
|
DEFAULT_RESOLVED_CONFIG,
|
|
2466
|
+
DualWriteStrategy,
|
|
2451
2467
|
EUFixedRates,
|
|
2452
2468
|
EUROPE,
|
|
2453
2469
|
ExtensionCategory,
|
|
@@ -2457,6 +2473,7 @@ export {
|
|
|
2457
2473
|
InventoryBaseActionEnum,
|
|
2458
2474
|
InventorySpecificActionType,
|
|
2459
2475
|
InvoiceStatus,
|
|
2476
|
+
LegacyWriteStrategy,
|
|
2460
2477
|
LibraryItemType,
|
|
2461
2478
|
MenuProject,
|
|
2462
2479
|
NAFixedRates,
|