@asteby/storefront 0.2.0 → 0.3.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/mock.d.cts CHANGED
@@ -78,6 +78,7 @@ type MockState = {
78
78
  status: number;
79
79
  body: unknown;
80
80
  }>;
81
+ checkouts: Map<string, unknown>;
81
82
  seq: number;
82
83
  };
83
84
  declare function createMockStorefront(options?: MockStorefrontOptions): {
package/dist/mock.d.ts CHANGED
@@ -78,6 +78,7 @@ type MockState = {
78
78
  status: number;
79
79
  body: unknown;
80
80
  }>;
81
+ checkouts: Map<string, unknown>;
81
82
  seq: number;
82
83
  };
83
84
  declare function createMockStorefront(options?: MockStorefrontOptions): {
package/dist/mock.js CHANGED
@@ -360,6 +360,7 @@ function createMockStorefront(options = {}) {
360
360
  otps: /* @__PURE__ */ new Map(),
361
361
  sessions: /* @__PURE__ */ new Map(),
362
362
  idempotency: /* @__PURE__ */ new Map(),
363
+ checkouts: /* @__PURE__ */ new Map(),
363
364
  seq: 0
364
365
  };
365
366
  }
@@ -798,9 +799,15 @@ function createMockStorefront(options = {}) {
798
799
  stock_hold_expires_at: new Date(Date.now() + 30 * 6e4).toISOString()
799
800
  }
800
801
  };
802
+ state.checkouts.set(checkoutId, result);
801
803
  if (key) state.idempotency.set(`${params[0]}:${key}`, { status: 201, body: result });
802
804
  return { status: 201, body: result, cache: "private" };
803
805
  });
806
+ route("GET", "/checkouts/:id", "checkout:write", ({ params }) => {
807
+ const found = state.checkouts.get(params[0]);
808
+ if (!found) throw new HttpError(404, "not_found", "Checkout not found");
809
+ return { body: found, cache: "private" };
810
+ });
804
811
  route("POST", "/customer/otp", "customer:write", ({ body }) => {
805
812
  state.otps.set(identifierOf(body), otpCode);
806
813
  return { status: 204 };