@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.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) => {
@@ -1276,10 +1277,7 @@ function negateAtPaths(value, path, paths) {
1276
1277
  function padHex(value, length) {
1277
1278
  return value.toString(16).padStart(length, "0");
1278
1279
  }
1279
- var PROCESS_RANDOM = Array.from(
1280
- { length: 5 },
1281
- () => padHex(Math.floor(Math.random() * 256), 2)
1282
- ).join("");
1280
+ var PROCESS_RANDOM = Array.from({ length: 5 }, () => padHex(Math.floor(Math.random() * 256), 2)).join("");
1283
1281
  var objectIdCounter = Math.floor(Math.random() * 16777215);
1284
1282
  function generateMongoID() {
1285
1283
  const timestamp = padHex(Math.floor(Date.now() / 1e3), 8);
@@ -2424,6 +2422,27 @@ function inferStatesFromLegacyStatus(order) {
2424
2422
  return { payment: "unpaid", fulfillment: "pending" };
2425
2423
  }
2426
2424
 
2425
+ // order-state-machine/write-strategy.ts
2426
+ var LegacyWriteStrategy = class {
2427
+ applyState(_order) {
2428
+ }
2429
+ };
2430
+ var DualWriteStrategy = class {
2431
+ constructor(config) {
2432
+ this.config = config;
2433
+ }
2434
+ applyState(order) {
2435
+ if (order.paymentState && order.fulfillmentState) {
2436
+ setOrderState(order, order.paymentState, order.fulfillmentState, this.config);
2437
+ return;
2438
+ }
2439
+ if (order.status) {
2440
+ const inferred = inferStatesFromLegacyStatus(order);
2441
+ setOrderState(order, inferred.payment, inferred.fulfillment, this.config);
2442
+ }
2443
+ }
2444
+ };
2445
+
2427
2446
  // order-state-machine/resolve-template.ts
2428
2447
  function resolveTemplate(templateJson, params, values = {}) {
2429
2448
  const resolvedValues = {};
@@ -2725,27 +2744,6 @@ var ORDER_STATE_EVENTS = {
2725
2744
  stateTransitionBlocked: "state-transition-blocked",
2726
2745
  configUpdated: "config-updated"
2727
2746
  };
2728
-
2729
- // order-state-machine/write-strategy.ts
2730
- var LegacyWriteStrategy = class {
2731
- applyState(_order) {
2732
- }
2733
- };
2734
- var DualWriteStrategy = class {
2735
- constructor(config) {
2736
- this.config = config;
2737
- }
2738
- applyState(order) {
2739
- if (order.paymentState && order.fulfillmentState) {
2740
- setOrderState(order, order.paymentState, order.fulfillmentState, this.config);
2741
- return;
2742
- }
2743
- if (order.status) {
2744
- const inferred = inferStatesFromLegacyStatus(order);
2745
- setOrderState(order, inferred.payment, inferred.fulfillment, this.config);
2746
- }
2747
- }
2748
- };
2749
2747
  export {
2750
2748
  AttributeType,
2751
2749
  CONDITION_OPERATORS,