@moonbase.sh/vue 0.2.44 → 0.2.46

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.cjs CHANGED
@@ -309,6 +309,16 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
309
309
  if (typeof window !== "undefined")
310
310
  localStorage.removeItem(_StorefrontContextImpl.sessionKey);
311
311
  }
312
+ async surrenderOrder() {
313
+ try {
314
+ await this.client.orders.removeBillingDetails(this.currentOrder.value.id);
315
+ } catch (err) {
316
+ if (err instanceof import_storefront_api2.NotFoundError) {
317
+ return;
318
+ }
319
+ console.warn("Could not surrender order:", err);
320
+ }
321
+ }
312
322
  };
313
323
  _StorefrontContextImpl.userKey = "moonbase_user";
314
324
  _StorefrontContextImpl.sessionKey = "moonbase_session";
@@ -686,7 +696,7 @@ function useAuth(context) {
686
696
  },
687
697
  signOut: async () => {
688
698
  storefront.client.tokenStore.setUser(null);
689
- await storefront.updateStorefront();
699
+ await Promise.all([storefront.updateStorefront(), storefront.surrenderOrder()]);
690
700
  storefront.currentUser.value = null;
691
701
  },
692
702
  update: async (name, email, emailConfirmationToken, communicationPreferences) => {
package/dist/index.d.cts CHANGED
@@ -20,6 +20,7 @@ interface StorefrontContext extends Pick<Plugin, keyof Plugin> {
20
20
  updateStorefront: () => Promise<Storefront>;
21
21
  pushOrderContent: () => Promise<void>;
22
22
  resetOrder: () => void;
23
+ surrenderOrder: () => Promise<void>;
23
24
  closeCheckout: () => void;
24
25
  onCheckoutCompleted: (callback: (order: CompletedOrder) => void) => void;
25
26
  onCheckoutClosed: (callback: (intent: string | undefined) => void) => void;
package/dist/index.d.ts CHANGED
@@ -20,6 +20,7 @@ interface StorefrontContext extends Pick<Plugin, keyof Plugin> {
20
20
  updateStorefront: () => Promise<Storefront>;
21
21
  pushOrderContent: () => Promise<void>;
22
22
  resetOrder: () => void;
23
+ surrenderOrder: () => Promise<void>;
23
24
  closeCheckout: () => void;
24
25
  onCheckoutCompleted: (callback: (order: CompletedOrder) => void) => void;
25
26
  onCheckoutClosed: (callback: (intent: string | undefined) => void) => void;
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import { ref as ref2 } from "vue";
5
5
  // src/context.ts
6
6
  import { v4 as uuidv4 } from "uuid";
7
7
  import { computed, ref, watch } from "vue";
8
- import { NotAuthenticatedError, OrderStatus } from "@moonbase.sh/storefront-api";
8
+ import { NotAuthenticatedError, NotFoundError, OrderStatus } from "@moonbase.sh/storefront-api";
9
9
 
10
10
  // src/symbols.ts
11
11
  var storefrontKey = Symbol("storefront");
@@ -274,6 +274,16 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
274
274
  if (typeof window !== "undefined")
275
275
  localStorage.removeItem(_StorefrontContextImpl.sessionKey);
276
276
  }
277
+ async surrenderOrder() {
278
+ try {
279
+ await this.client.orders.removeBillingDetails(this.currentOrder.value.id);
280
+ } catch (err) {
281
+ if (err instanceof NotFoundError) {
282
+ return;
283
+ }
284
+ console.warn("Could not surrender order:", err);
285
+ }
286
+ }
277
287
  };
278
288
  _StorefrontContextImpl.userKey = "moonbase_user";
279
289
  _StorefrontContextImpl.sessionKey = "moonbase_session";
@@ -453,7 +463,7 @@ function useActivationRequest(token, context) {
453
463
  }
454
464
 
455
465
  // src/composables/useVoucher.ts
456
- import { NotFoundError } from "@moonbase.sh/storefront-api";
466
+ import { NotFoundError as NotFoundError2 } from "@moonbase.sh/storefront-api";
457
467
  import { inject as inject7 } from "vue";
458
468
  function useVoucher(context) {
459
469
  const storefront = context != null ? context : inject7(storefrontKey);
@@ -464,7 +474,7 @@ function useVoucher(context) {
464
474
  try {
465
475
  return await storefront.client.vouchers.peek(code);
466
476
  } catch (e) {
467
- if (e instanceof NotFoundError)
477
+ if (e instanceof NotFoundError2)
468
478
  throw new Error("Voucher code invalid");
469
479
  throw e;
470
480
  }
@@ -473,7 +483,7 @@ function useVoucher(context) {
473
483
  try {
474
484
  return await storefront.client.vouchers.redeem(code);
475
485
  } catch (e) {
476
- if (e instanceof NotFoundError)
486
+ if (e instanceof NotFoundError2)
477
487
  throw new Error("Voucher code invalid");
478
488
  throw e;
479
489
  }
@@ -651,7 +661,7 @@ function useAuth(context) {
651
661
  },
652
662
  signOut: async () => {
653
663
  storefront.client.tokenStore.setUser(null);
654
- await storefront.updateStorefront();
664
+ await Promise.all([storefront.updateStorefront(), storefront.surrenderOrder()]);
655
665
  storefront.currentUser.value = null;
656
666
  },
657
667
  update: async (name, email, emailConfirmationToken, communicationPreferences) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moonbase.sh/vue",
3
3
  "type": "module",
4
- "version": "0.2.44",
4
+ "version": "0.2.46",
5
5
  "description": "Package to let you build vue.js storefronts with Moonbase.sh as payment and delivery provider",
6
6
  "author": "Tobias Lønnerød Madsen <m@dsen.tv>",
7
7
  "license": "MIT",
@@ -19,7 +19,7 @@
19
19
  "@vue/devtools-api": "^6.6.3",
20
20
  "uuid": "^9.0.1",
21
21
  "zod": "^3.23.8",
22
- "@moonbase.sh/storefront-api": "0.2.44"
22
+ "@moonbase.sh/storefront-api": "0.2.46"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/uuid": "^9.0.8",