@moonbase.sh/vue 0.1.96 → 0.1.97

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
@@ -34,7 +34,7 @@ __export(src_exports, {
34
34
  useVoucher: () => useVoucher
35
35
  });
36
36
  module.exports = __toCommonJS(src_exports);
37
- var import_storefront_api3 = require("@moonbase.sh/storefront-api");
37
+ var import_storefront_api4 = require("@moonbase.sh/storefront-api");
38
38
  var import_vue11 = require("vue");
39
39
 
40
40
  // src/context.ts
@@ -248,25 +248,30 @@ function useInventory() {
248
248
  throw new Error("No storefront configured");
249
249
  return {
250
250
  getLicenses: async (nextUrl) => {
251
- return storefront.client.licenses.get(nextUrl);
251
+ return storefront.client.inventory.licenses.get(nextUrl);
252
252
  },
253
253
  getLicenseActivations: async (licenseId, nextUrl) => {
254
- return storefront.client.licenses.getActivations(licenseId, nextUrl);
254
+ return storefront.client.inventory.licenses.getActivations(licenseId, nextUrl);
255
255
  },
256
256
  getProducts: async (nextUrl) => {
257
- return storefront.client.products.getOwned(nextUrl);
257
+ return storefront.client.inventory.products.getOwned(nextUrl);
258
258
  },
259
259
  getProductLicenses: async (productId, nextUrl) => {
260
- return storefront.client.products.getLicenses(productId, nextUrl);
260
+ return storefront.client.inventory.products.getLicenses(productId, nextUrl);
261
261
  },
262
262
  getProductActivations: async (productId, nextUrl) => {
263
- return storefront.client.products.getActivations(productId, nextUrl);
263
+ return storefront.client.inventory.products.getActivations(productId, nextUrl);
264
264
  },
265
265
  revokeActivation: async (activation) => {
266
- return storefront.client.licenses.revokeActivation(activation.licenseId, activation.id);
266
+ return storefront.client.inventory.licenses.revokeActivation(activation.licenseId, activation.id);
267
267
  },
268
268
  activateProduct: async (deviceToken, activationMethod) => {
269
- return storefront.client.products.activate(deviceToken, activationMethod);
269
+ return storefront.client.inventory.activation.activate(deviceToken, activationMethod);
270
+ },
271
+ downloadProduct: async (download) => {
272
+ if (!download.path)
273
+ throw new Error("Product is not downloadable");
274
+ window.location.href = await storefront.client.inventory.products.getDownloadUrl(download.path);
270
275
  }
271
276
  };
272
277
  }
@@ -329,6 +334,7 @@ function useActivationRequest(requestId) {
329
334
  }
330
335
 
331
336
  // src/composables/useVoucher.ts
337
+ var import_storefront_api3 = require("@moonbase.sh/storefront-api");
332
338
  var import_vue8 = require("vue");
333
339
  function useVoucher() {
334
340
  const storefront = (0, import_vue8.inject)(storefrontKey);
@@ -336,10 +342,22 @@ function useVoucher() {
336
342
  throw new Error("No storefront configured");
337
343
  return {
338
344
  peek: async (code) => {
339
- return storefront.client.vouchers.peek(code);
345
+ try {
346
+ return await storefront.client.vouchers.peek(code);
347
+ } catch (e) {
348
+ if (e instanceof import_storefront_api3.NotFoundError)
349
+ throw new Error("Voucher code invalid");
350
+ throw e;
351
+ }
340
352
  },
341
353
  redeem: async (code) => {
342
- return storefront.client.vouchers.redeem(code);
354
+ try {
355
+ return await storefront.client.vouchers.redeem(code);
356
+ } catch (e) {
357
+ if (e instanceof import_storefront_api3.NotFoundError)
358
+ throw new Error("Voucher code invalid");
359
+ throw e;
360
+ }
343
361
  }
344
362
  };
345
363
  }
@@ -491,15 +509,18 @@ function useAuth() {
491
509
  const _ = storefront.updateStorefront();
492
510
  return user;
493
511
  },
494
- signOut: () => {
512
+ signOut: async () => {
495
513
  storefront.client.tokenStore.setUser(null);
514
+ await storefront.updateStorefront();
496
515
  storefront.currentUser.value = null;
497
- const _ = storefront.updateStorefront();
498
516
  },
499
- update: async (name, email, emailConfirmationToken) => {
500
- const result = await storefront.client.identity.update(name, email, emailConfirmationToken);
501
- if (storefront.currentUser.value)
517
+ update: async (name, email, emailConfirmationToken, communicationPreferences) => {
518
+ const result = await storefront.client.identity.update(name, email, emailConfirmationToken, communicationPreferences);
519
+ if (storefront.currentUser.value) {
502
520
  storefront.currentUser.value.name = name;
521
+ if (communicationPreferences)
522
+ storefront.currentUser.value.communicationPreferences = communicationPreferences;
523
+ }
503
524
  return result;
504
525
  },
505
526
  setPassword: async (currentPassword, newPassword) => {
@@ -523,7 +544,7 @@ function createStorefront(endpoint, stateFactory) {
523
544
  };
524
545
  return new StorefrontContextImpl(
525
546
  configuration,
526
- new import_storefront_api3.MoonbaseClient(configuration),
547
+ new import_storefront_api4.MoonbaseClient(configuration),
527
548
  // Default to vue refs but allow stuff like Nuxt useState wrappers
528
549
  stateFactory || ((_, state) => (0, import_vue11.ref)(state))
529
550
  );
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _moonbase_sh_storefront_api from '@moonbase.sh/storefront-api';
2
- import { MoonbaseConfiguration, Storefront, Order, User, MoonbaseClient, StorefrontBundle, StorefrontProduct, ActivationMethod, Activation, PricingVariation, LineItem } from '@moonbase.sh/storefront-api';
2
+ import { MoonbaseConfiguration, Storefront, Order, User, MoonbaseClient, StorefrontBundle, StorefrontProduct, ActivationMethod, Activation, Download, PricingVariation, CommunicationPreferences, LineItem } from '@moonbase.sh/storefront-api';
3
3
  export * from '@moonbase.sh/storefront-api';
4
4
  import * as vue from 'vue';
5
5
  import { Plugin, Ref, App, UnwrapRef, InjectionKey } from 'vue';
@@ -40,10 +40,7 @@ declare function useInventory(): {
40
40
  getLicenses: (nextUrl?: string) => Promise<_moonbase_sh_storefront_api.Page<{
41
41
  status: _moonbase_sh_storefront_api.LicenseStatus;
42
42
  id: string;
43
- activeNumberOfActivations: number;
44
- maxNumberOfActivations: number;
45
- createdAt: Date;
46
- product?: {
43
+ product: {
47
44
  id: string;
48
45
  name: string;
49
46
  tagline: string;
@@ -63,7 +60,10 @@ declare function useInventory(): {
63
60
  platform: _moonbase_sh_storefront_api.Platform;
64
61
  size: number;
65
62
  }[] | undefined;
66
- } | undefined;
63
+ };
64
+ activeNumberOfActivations: number;
65
+ maxNumberOfActivations: number;
66
+ createdAt: Date;
67
67
  }>>;
68
68
  getLicenseActivations: (licenseId: string, nextUrl?: string) => Promise<_moonbase_sh_storefront_api.Page<{
69
69
  status: _moonbase_sh_storefront_api.ActivationStatus;
@@ -97,10 +97,7 @@ declare function useInventory(): {
97
97
  getProductLicenses: (productId: string, nextUrl?: string) => Promise<_moonbase_sh_storefront_api.Page<{
98
98
  status: _moonbase_sh_storefront_api.LicenseStatus;
99
99
  id: string;
100
- activeNumberOfActivations: number;
101
- maxNumberOfActivations: number;
102
- createdAt: Date;
103
- product?: {
100
+ product: {
104
101
  id: string;
105
102
  name: string;
106
103
  tagline: string;
@@ -120,7 +117,10 @@ declare function useInventory(): {
120
117
  platform: _moonbase_sh_storefront_api.Platform;
121
118
  size: number;
122
119
  }[] | undefined;
123
- } | undefined;
120
+ };
121
+ activeNumberOfActivations: number;
122
+ maxNumberOfActivations: number;
123
+ createdAt: Date;
124
124
  }>>;
125
125
  getProductActivations: (productId: string, nextUrl?: string) => Promise<_moonbase_sh_storefront_api.Page<{
126
126
  status: _moonbase_sh_storefront_api.ActivationStatus;
@@ -135,10 +135,7 @@ declare function useInventory(): {
135
135
  license: {
136
136
  status: _moonbase_sh_storefront_api.LicenseStatus;
137
137
  id: string;
138
- activeNumberOfActivations: number;
139
- maxNumberOfActivations: number;
140
- createdAt: Date;
141
- product?: {
138
+ product: {
142
139
  id: string;
143
140
  name: string;
144
141
  tagline: string;
@@ -158,10 +155,14 @@ declare function useInventory(): {
158
155
  platform: _moonbase_sh_storefront_api.Platform;
159
156
  size: number;
160
157
  }[] | undefined;
161
- } | undefined;
158
+ };
159
+ activeNumberOfActivations: number;
160
+ maxNumberOfActivations: number;
161
+ createdAt: Date;
162
162
  };
163
163
  url: string;
164
164
  }>;
165
+ downloadProduct: (download: Download) => Promise<void>;
165
166
  };
166
167
 
167
168
  declare function useActivationRequest(requestId: string): {
@@ -439,7 +440,7 @@ declare function useVoucher(): {
439
440
  } | undefined;
440
441
  }[] | undefined;
441
442
  } & {
442
- included: boolean;
443
+ included?: boolean | undefined;
443
444
  })[];
444
445
  defaultVariation?: {
445
446
  id: string;
@@ -609,7 +610,7 @@ declare function useVoucher(): {
609
610
  } | undefined;
610
611
  }[] | undefined;
611
612
  } & {
612
- included: boolean;
613
+ included?: boolean | undefined;
613
614
  })[];
614
615
  defaultVariation?: {
615
616
  id: string;
@@ -838,7 +839,7 @@ declare function useCart(): {
838
839
  } | undefined;
839
840
  }[] | undefined;
840
841
  } & {
841
- included: boolean;
842
+ included?: boolean | undefined;
842
843
  })[];
843
844
  defaultVariation?: {
844
845
  id: string;
@@ -958,8 +959,8 @@ declare function useAuth(): {
958
959
  postCode: string;
959
960
  } | undefined;
960
961
  }>;
961
- signOut: () => void;
962
- update: (name: string, email: string, emailConfirmationToken?: string) => Promise<{
962
+ signOut: () => Promise<void>;
963
+ update: (name: string, email: string, emailConfirmationToken?: string, communicationPreferences?: CommunicationPreferences) => Promise<{
963
964
  needsEmailConfirmationToken: boolean;
964
965
  }>;
965
966
  setPassword: (currentPassword: string, newPassword: string) => Promise<void>;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _moonbase_sh_storefront_api from '@moonbase.sh/storefront-api';
2
- import { MoonbaseConfiguration, Storefront, Order, User, MoonbaseClient, StorefrontBundle, StorefrontProduct, ActivationMethod, Activation, PricingVariation, LineItem } from '@moonbase.sh/storefront-api';
2
+ import { MoonbaseConfiguration, Storefront, Order, User, MoonbaseClient, StorefrontBundle, StorefrontProduct, ActivationMethod, Activation, Download, PricingVariation, CommunicationPreferences, LineItem } from '@moonbase.sh/storefront-api';
3
3
  export * from '@moonbase.sh/storefront-api';
4
4
  import * as vue from 'vue';
5
5
  import { Plugin, Ref, App, UnwrapRef, InjectionKey } from 'vue';
@@ -40,10 +40,7 @@ declare function useInventory(): {
40
40
  getLicenses: (nextUrl?: string) => Promise<_moonbase_sh_storefront_api.Page<{
41
41
  status: _moonbase_sh_storefront_api.LicenseStatus;
42
42
  id: string;
43
- activeNumberOfActivations: number;
44
- maxNumberOfActivations: number;
45
- createdAt: Date;
46
- product?: {
43
+ product: {
47
44
  id: string;
48
45
  name: string;
49
46
  tagline: string;
@@ -63,7 +60,10 @@ declare function useInventory(): {
63
60
  platform: _moonbase_sh_storefront_api.Platform;
64
61
  size: number;
65
62
  }[] | undefined;
66
- } | undefined;
63
+ };
64
+ activeNumberOfActivations: number;
65
+ maxNumberOfActivations: number;
66
+ createdAt: Date;
67
67
  }>>;
68
68
  getLicenseActivations: (licenseId: string, nextUrl?: string) => Promise<_moonbase_sh_storefront_api.Page<{
69
69
  status: _moonbase_sh_storefront_api.ActivationStatus;
@@ -97,10 +97,7 @@ declare function useInventory(): {
97
97
  getProductLicenses: (productId: string, nextUrl?: string) => Promise<_moonbase_sh_storefront_api.Page<{
98
98
  status: _moonbase_sh_storefront_api.LicenseStatus;
99
99
  id: string;
100
- activeNumberOfActivations: number;
101
- maxNumberOfActivations: number;
102
- createdAt: Date;
103
- product?: {
100
+ product: {
104
101
  id: string;
105
102
  name: string;
106
103
  tagline: string;
@@ -120,7 +117,10 @@ declare function useInventory(): {
120
117
  platform: _moonbase_sh_storefront_api.Platform;
121
118
  size: number;
122
119
  }[] | undefined;
123
- } | undefined;
120
+ };
121
+ activeNumberOfActivations: number;
122
+ maxNumberOfActivations: number;
123
+ createdAt: Date;
124
124
  }>>;
125
125
  getProductActivations: (productId: string, nextUrl?: string) => Promise<_moonbase_sh_storefront_api.Page<{
126
126
  status: _moonbase_sh_storefront_api.ActivationStatus;
@@ -135,10 +135,7 @@ declare function useInventory(): {
135
135
  license: {
136
136
  status: _moonbase_sh_storefront_api.LicenseStatus;
137
137
  id: string;
138
- activeNumberOfActivations: number;
139
- maxNumberOfActivations: number;
140
- createdAt: Date;
141
- product?: {
138
+ product: {
142
139
  id: string;
143
140
  name: string;
144
141
  tagline: string;
@@ -158,10 +155,14 @@ declare function useInventory(): {
158
155
  platform: _moonbase_sh_storefront_api.Platform;
159
156
  size: number;
160
157
  }[] | undefined;
161
- } | undefined;
158
+ };
159
+ activeNumberOfActivations: number;
160
+ maxNumberOfActivations: number;
161
+ createdAt: Date;
162
162
  };
163
163
  url: string;
164
164
  }>;
165
+ downloadProduct: (download: Download) => Promise<void>;
165
166
  };
166
167
 
167
168
  declare function useActivationRequest(requestId: string): {
@@ -439,7 +440,7 @@ declare function useVoucher(): {
439
440
  } | undefined;
440
441
  }[] | undefined;
441
442
  } & {
442
- included: boolean;
443
+ included?: boolean | undefined;
443
444
  })[];
444
445
  defaultVariation?: {
445
446
  id: string;
@@ -609,7 +610,7 @@ declare function useVoucher(): {
609
610
  } | undefined;
610
611
  }[] | undefined;
611
612
  } & {
612
- included: boolean;
613
+ included?: boolean | undefined;
613
614
  })[];
614
615
  defaultVariation?: {
615
616
  id: string;
@@ -838,7 +839,7 @@ declare function useCart(): {
838
839
  } | undefined;
839
840
  }[] | undefined;
840
841
  } & {
841
- included: boolean;
842
+ included?: boolean | undefined;
842
843
  })[];
843
844
  defaultVariation?: {
844
845
  id: string;
@@ -958,8 +959,8 @@ declare function useAuth(): {
958
959
  postCode: string;
959
960
  } | undefined;
960
961
  }>;
961
- signOut: () => void;
962
- update: (name: string, email: string, emailConfirmationToken?: string) => Promise<{
962
+ signOut: () => Promise<void>;
963
+ update: (name: string, email: string, emailConfirmationToken?: string, communicationPreferences?: CommunicationPreferences) => Promise<{
963
964
  needsEmailConfirmationToken: boolean;
964
965
  }>;
965
966
  setPassword: (currentPassword: string, newPassword: string) => Promise<void>;
package/dist/index.js CHANGED
@@ -213,25 +213,30 @@ function useInventory() {
213
213
  throw new Error("No storefront configured");
214
214
  return {
215
215
  getLicenses: async (nextUrl) => {
216
- return storefront.client.licenses.get(nextUrl);
216
+ return storefront.client.inventory.licenses.get(nextUrl);
217
217
  },
218
218
  getLicenseActivations: async (licenseId, nextUrl) => {
219
- return storefront.client.licenses.getActivations(licenseId, nextUrl);
219
+ return storefront.client.inventory.licenses.getActivations(licenseId, nextUrl);
220
220
  },
221
221
  getProducts: async (nextUrl) => {
222
- return storefront.client.products.getOwned(nextUrl);
222
+ return storefront.client.inventory.products.getOwned(nextUrl);
223
223
  },
224
224
  getProductLicenses: async (productId, nextUrl) => {
225
- return storefront.client.products.getLicenses(productId, nextUrl);
225
+ return storefront.client.inventory.products.getLicenses(productId, nextUrl);
226
226
  },
227
227
  getProductActivations: async (productId, nextUrl) => {
228
- return storefront.client.products.getActivations(productId, nextUrl);
228
+ return storefront.client.inventory.products.getActivations(productId, nextUrl);
229
229
  },
230
230
  revokeActivation: async (activation) => {
231
- return storefront.client.licenses.revokeActivation(activation.licenseId, activation.id);
231
+ return storefront.client.inventory.licenses.revokeActivation(activation.licenseId, activation.id);
232
232
  },
233
233
  activateProduct: async (deviceToken, activationMethod) => {
234
- return storefront.client.products.activate(deviceToken, activationMethod);
234
+ return storefront.client.inventory.activation.activate(deviceToken, activationMethod);
235
+ },
236
+ downloadProduct: async (download) => {
237
+ if (!download.path)
238
+ throw new Error("Product is not downloadable");
239
+ window.location.href = await storefront.client.inventory.products.getDownloadUrl(download.path);
235
240
  }
236
241
  };
237
242
  }
@@ -294,6 +299,7 @@ function useActivationRequest(requestId) {
294
299
  }
295
300
 
296
301
  // src/composables/useVoucher.ts
302
+ import { NotFoundError } from "@moonbase.sh/storefront-api";
297
303
  import { inject as inject7 } from "vue";
298
304
  function useVoucher() {
299
305
  const storefront = inject7(storefrontKey);
@@ -301,10 +307,22 @@ function useVoucher() {
301
307
  throw new Error("No storefront configured");
302
308
  return {
303
309
  peek: async (code) => {
304
- return storefront.client.vouchers.peek(code);
310
+ try {
311
+ return await storefront.client.vouchers.peek(code);
312
+ } catch (e) {
313
+ if (e instanceof NotFoundError)
314
+ throw new Error("Voucher code invalid");
315
+ throw e;
316
+ }
305
317
  },
306
318
  redeem: async (code) => {
307
- return storefront.client.vouchers.redeem(code);
319
+ try {
320
+ return await storefront.client.vouchers.redeem(code);
321
+ } catch (e) {
322
+ if (e instanceof NotFoundError)
323
+ throw new Error("Voucher code invalid");
324
+ throw e;
325
+ }
308
326
  }
309
327
  };
310
328
  }
@@ -456,15 +474,18 @@ function useAuth() {
456
474
  const _ = storefront.updateStorefront();
457
475
  return user;
458
476
  },
459
- signOut: () => {
477
+ signOut: async () => {
460
478
  storefront.client.tokenStore.setUser(null);
479
+ await storefront.updateStorefront();
461
480
  storefront.currentUser.value = null;
462
- const _ = storefront.updateStorefront();
463
481
  },
464
- update: async (name, email, emailConfirmationToken) => {
465
- const result = await storefront.client.identity.update(name, email, emailConfirmationToken);
466
- if (storefront.currentUser.value)
482
+ update: async (name, email, emailConfirmationToken, communicationPreferences) => {
483
+ const result = await storefront.client.identity.update(name, email, emailConfirmationToken, communicationPreferences);
484
+ if (storefront.currentUser.value) {
467
485
  storefront.currentUser.value.name = name;
486
+ if (communicationPreferences)
487
+ storefront.currentUser.value.communicationPreferences = communicationPreferences;
488
+ }
468
489
  return result;
469
490
  },
470
491
  setPassword: async (currentPassword, newPassword) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moonbase.sh/vue",
3
3
  "type": "module",
4
- "version": "0.1.96",
4
+ "version": "0.1.97",
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",
@@ -18,7 +18,7 @@
18
18
  "dependencies": {
19
19
  "@vue/devtools-api": "^6.5.1",
20
20
  "uuid": "^9.0.1",
21
- "@moonbase.sh/storefront-api": "0.1.96"
21
+ "@moonbase.sh/storefront-api": "0.1.97"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/uuid": "^9.0.7",