@moonbase.sh/vue 0.1.52 → 0.1.58

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
@@ -27,12 +27,13 @@ __export(src_exports, {
27
27
  useBundle: () => useBundle,
28
28
  useBundles: () => useBundles,
29
29
  useCart: () => useCart,
30
+ useInventory: () => useInventory,
30
31
  useProduct: () => useProduct,
31
32
  useProducts: () => useProducts
32
33
  });
33
34
  module.exports = __toCommonJS(src_exports);
34
35
  var import_api_client2 = require("@moonbase.sh/api-client");
35
- var import_vue8 = require("vue");
36
+ var import_vue9 = require("vue");
36
37
 
37
38
  // src/context.ts
38
39
  var import_api_client = require("@moonbase.sh/api-client");
@@ -225,16 +226,38 @@ function useProducts() {
225
226
  return (0, import_vue5.computed)(() => storefront.storefront.value.products);
226
227
  }
227
228
 
228
- // src/composables/useCart.ts
229
+ // src/composables/useInventory.ts
229
230
  var import_vue6 = require("vue");
230
- function useCart() {
231
+ function useInventory() {
231
232
  const storefront = (0, import_vue6.inject)(storefrontKey);
232
233
  if (!storefront)
233
234
  throw new Error("No storefront configured");
234
235
  return {
235
- items: (0, import_vue6.computed)(() => storefront.currentOrder.value.items),
236
- currency: (0, import_vue6.computed)(() => storefront.currentOrder.value.currency || storefront.storefront.value.suggestedCurrency),
237
- total: (0, import_vue6.computed)(() => {
236
+ getLicenses: async (nextUrl) => {
237
+ return storefront.client.licenses.get(nextUrl);
238
+ },
239
+ getLicenseActivations: async (licenseId, nextUrl) => {
240
+ return storefront.client.licenses.getActivations(licenseId, nextUrl);
241
+ },
242
+ getProducts: async (nextUrl) => {
243
+ return storefront.client.products.getOwned(nextUrl);
244
+ },
245
+ getProductLicenses: async (productId, nextUrl) => {
246
+ return storefront.client.products.getLicenses(productId, nextUrl);
247
+ }
248
+ };
249
+ }
250
+
251
+ // src/composables/useCart.ts
252
+ var import_vue7 = require("vue");
253
+ function useCart() {
254
+ const storefront = (0, import_vue7.inject)(storefrontKey);
255
+ if (!storefront)
256
+ throw new Error("No storefront configured");
257
+ return {
258
+ items: (0, import_vue7.computed)(() => storefront.currentOrder.value.items),
259
+ currency: (0, import_vue7.computed)(() => storefront.currentOrder.value.currency || storefront.storefront.value.suggestedCurrency),
260
+ total: (0, import_vue7.computed)(() => {
238
261
  const currency = storefront.currentOrder.value.currency || storefront.storefront.value.suggestedCurrency;
239
262
  const total = storefront.currentOrder.value.items.reduce((agg, item) => {
240
263
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
@@ -255,7 +278,7 @@ function useCart() {
255
278
  return { amount: total, currency };
256
279
  }),
257
280
  addToCart: (item, variation) => {
258
- item = (0, import_vue6.unref)(item);
281
+ item = (0, import_vue7.unref)(item);
259
282
  variation != null ? variation : variation = item.defaultVariation;
260
283
  if (!variation)
261
284
  throw new Error("Added item does not have a default variation, and none have been specified");
@@ -316,9 +339,9 @@ function useCart() {
316
339
  }
317
340
 
318
341
  // src/composables/useAuth.ts
319
- var import_vue7 = require("vue");
342
+ var import_vue8 = require("vue");
320
343
  function useAuth() {
321
- const storefront = (0, import_vue7.inject)(storefrontKey);
344
+ const storefront = (0, import_vue8.inject)(storefrontKey);
322
345
  if (!storefront)
323
346
  throw new Error("No storefront configured");
324
347
  return {
@@ -376,7 +399,7 @@ function createStorefront(endpoint, stateFactory) {
376
399
  configuration,
377
400
  new import_api_client2.MoonbaseClient(configuration),
378
401
  // Default to vue refs but allow stuff like Nuxt useState wrappers
379
- stateFactory || ((_, state) => (0, import_vue8.ref)(state))
402
+ stateFactory || ((_, state) => (0, import_vue9.ref)(state))
380
403
  );
381
404
  }
382
405
  // Annotate the CommonJS export names for ESM import in node:
@@ -387,6 +410,7 @@ function createStorefront(endpoint, stateFactory) {
387
410
  useBundle,
388
411
  useBundles,
389
412
  useCart,
413
+ useInventory,
390
414
  useProduct,
391
415
  useProducts,
392
416
  ...require("@moonbase.sh/api-client")
package/dist/index.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Address, LineItem } from '@moonbase.sh/api-client/src';
2
+ import * as _moonbase_sh_api_client from '@moonbase.sh/api-client';
2
3
  import { Storefront, Order, User, MoonbaseClient, StorefrontBundle, StorefrontProduct, PricingVariation } from '@moonbase.sh/api-client';
3
4
  export * from '@moonbase.sh/api-client';
4
5
  import * as vue from 'vue';
@@ -32,8 +33,140 @@ declare function useProduct(productId: string): Ref<StorefrontProduct | null>;
32
33
 
33
34
  declare function useProducts(): Ref<StorefrontProduct[]>;
34
35
 
36
+ declare function useInventory(): {
37
+ getLicenses: (nextUrl?: string) => Promise<_moonbase_sh_api_client.Page<{
38
+ status: _moonbase_sh_api_client.LicenseStatus;
39
+ id: string;
40
+ activeNumberOfActivations: number;
41
+ maxNumberOfActivations: number;
42
+ createdAt: Date;
43
+ product?: {
44
+ id: string;
45
+ name: string;
46
+ iconUrl: string | null;
47
+ currentVersion: string | null;
48
+ downloads: {
49
+ name: string;
50
+ key: string;
51
+ platform: _moonbase_sh_api_client.Platform;
52
+ }[] | null;
53
+ } | undefined;
54
+ }>>;
55
+ getLicenseActivations: (licenseId: string, nextUrl?: string) => Promise<_moonbase_sh_api_client.Page<{
56
+ status: _moonbase_sh_api_client.ActivationStatus;
57
+ id: string;
58
+ name: string;
59
+ activationMethod: _moonbase_sh_api_client.ActivationMethod;
60
+ lastValidatedAt: Date;
61
+ }>>;
62
+ getProducts: (nextUrl?: string) => Promise<_moonbase_sh_api_client.Page<{
63
+ id: string;
64
+ name: string;
65
+ iconUrl: string | null;
66
+ currentVersion: string | null;
67
+ downloads: {
68
+ name: string;
69
+ key: string;
70
+ platform: _moonbase_sh_api_client.Platform;
71
+ }[] | null;
72
+ }>>;
73
+ getProductLicenses: (productId: string, nextUrl?: string) => Promise<_moonbase_sh_api_client.Page<{
74
+ status: _moonbase_sh_api_client.LicenseStatus;
75
+ id: string;
76
+ activeNumberOfActivations: number;
77
+ maxNumberOfActivations: number;
78
+ createdAt: Date;
79
+ product?: {
80
+ id: string;
81
+ name: string;
82
+ iconUrl: string | null;
83
+ currentVersion: string | null;
84
+ downloads: {
85
+ name: string;
86
+ key: string;
87
+ platform: _moonbase_sh_api_client.Platform;
88
+ }[] | null;
89
+ } | undefined;
90
+ }>>;
91
+ };
92
+
35
93
  declare function useCart(): {
36
- items: vue.ComputedRef<CartItem[]>;
94
+ items: vue.ComputedRef<({
95
+ type: "Product";
96
+ id: string;
97
+ productId: string;
98
+ quantity: number;
99
+ variationId: string;
100
+ price?: Record<string, number> | undefined;
101
+ variation?: {
102
+ id: string;
103
+ price: Record<string, number>;
104
+ name: string;
105
+ } | undefined;
106
+ product?: {
107
+ type: "product";
108
+ id: string;
109
+ name: string;
110
+ tagline: string;
111
+ iconUrl: string;
112
+ defaultVariation?: {
113
+ id: string;
114
+ price: Record<string, number>;
115
+ name: string;
116
+ } | undefined;
117
+ variations?: {
118
+ id: string;
119
+ price: Record<string, number>;
120
+ name: string;
121
+ }[] | undefined;
122
+ } | undefined;
123
+ } | {
124
+ type: "Bundle";
125
+ id: string;
126
+ quantity: number;
127
+ variationId: string;
128
+ bundleId: string;
129
+ price?: Record<string, number> | undefined;
130
+ variation?: {
131
+ id: string;
132
+ price: Record<string, number>;
133
+ name: string;
134
+ } | undefined;
135
+ bundle?: {
136
+ type: "bundle";
137
+ id: string;
138
+ name: string;
139
+ tagline: string;
140
+ iconUrl: string;
141
+ products: {
142
+ type: "product";
143
+ id: string;
144
+ name: string;
145
+ tagline: string;
146
+ iconUrl: string;
147
+ defaultVariation?: {
148
+ id: string;
149
+ price: Record<string, number>;
150
+ name: string;
151
+ } | undefined;
152
+ variations?: {
153
+ id: string;
154
+ price: Record<string, number>;
155
+ name: string;
156
+ }[] | undefined;
157
+ }[];
158
+ defaultVariation?: {
159
+ id: string;
160
+ price: Record<string, number>;
161
+ name: string;
162
+ } | undefined;
163
+ variations?: {
164
+ id: string;
165
+ price: Record<string, number>;
166
+ name: string;
167
+ }[] | undefined;
168
+ } | undefined;
169
+ })[]>;
37
170
  currency: vue.ComputedRef<string>;
38
171
  total: vue.ComputedRef<{
39
172
  amount: number;
@@ -103,7 +236,7 @@ declare const storefrontKey: InjectionKey<StorefrontContext>;
103
236
  interface Cart {
104
237
  items: CartItem[];
105
238
  }
106
- type CartItem = LineItem & {};
239
+ type CartItem = LineItem;
107
240
  declare function createStorefront(endpoint: string, stateFactory?: StateFactory): StorefrontContext;
108
241
 
109
- export { type Cart, type CartItem, createStorefront, storefrontKey, useAuth, useBundle, useBundles, useCart, useProduct, useProducts };
242
+ export { type Cart, type CartItem, createStorefront, storefrontKey, useAuth, useBundle, useBundles, useCart, useInventory, useProduct, useProducts };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { Address, LineItem } from '@moonbase.sh/api-client/src';
2
+ import * as _moonbase_sh_api_client from '@moonbase.sh/api-client';
2
3
  import { Storefront, Order, User, MoonbaseClient, StorefrontBundle, StorefrontProduct, PricingVariation } from '@moonbase.sh/api-client';
3
4
  export * from '@moonbase.sh/api-client';
4
5
  import * as vue from 'vue';
@@ -32,8 +33,140 @@ declare function useProduct(productId: string): Ref<StorefrontProduct | null>;
32
33
 
33
34
  declare function useProducts(): Ref<StorefrontProduct[]>;
34
35
 
36
+ declare function useInventory(): {
37
+ getLicenses: (nextUrl?: string) => Promise<_moonbase_sh_api_client.Page<{
38
+ status: _moonbase_sh_api_client.LicenseStatus;
39
+ id: string;
40
+ activeNumberOfActivations: number;
41
+ maxNumberOfActivations: number;
42
+ createdAt: Date;
43
+ product?: {
44
+ id: string;
45
+ name: string;
46
+ iconUrl: string | null;
47
+ currentVersion: string | null;
48
+ downloads: {
49
+ name: string;
50
+ key: string;
51
+ platform: _moonbase_sh_api_client.Platform;
52
+ }[] | null;
53
+ } | undefined;
54
+ }>>;
55
+ getLicenseActivations: (licenseId: string, nextUrl?: string) => Promise<_moonbase_sh_api_client.Page<{
56
+ status: _moonbase_sh_api_client.ActivationStatus;
57
+ id: string;
58
+ name: string;
59
+ activationMethod: _moonbase_sh_api_client.ActivationMethod;
60
+ lastValidatedAt: Date;
61
+ }>>;
62
+ getProducts: (nextUrl?: string) => Promise<_moonbase_sh_api_client.Page<{
63
+ id: string;
64
+ name: string;
65
+ iconUrl: string | null;
66
+ currentVersion: string | null;
67
+ downloads: {
68
+ name: string;
69
+ key: string;
70
+ platform: _moonbase_sh_api_client.Platform;
71
+ }[] | null;
72
+ }>>;
73
+ getProductLicenses: (productId: string, nextUrl?: string) => Promise<_moonbase_sh_api_client.Page<{
74
+ status: _moonbase_sh_api_client.LicenseStatus;
75
+ id: string;
76
+ activeNumberOfActivations: number;
77
+ maxNumberOfActivations: number;
78
+ createdAt: Date;
79
+ product?: {
80
+ id: string;
81
+ name: string;
82
+ iconUrl: string | null;
83
+ currentVersion: string | null;
84
+ downloads: {
85
+ name: string;
86
+ key: string;
87
+ platform: _moonbase_sh_api_client.Platform;
88
+ }[] | null;
89
+ } | undefined;
90
+ }>>;
91
+ };
92
+
35
93
  declare function useCart(): {
36
- items: vue.ComputedRef<CartItem[]>;
94
+ items: vue.ComputedRef<({
95
+ type: "Product";
96
+ id: string;
97
+ productId: string;
98
+ quantity: number;
99
+ variationId: string;
100
+ price?: Record<string, number> | undefined;
101
+ variation?: {
102
+ id: string;
103
+ price: Record<string, number>;
104
+ name: string;
105
+ } | undefined;
106
+ product?: {
107
+ type: "product";
108
+ id: string;
109
+ name: string;
110
+ tagline: string;
111
+ iconUrl: string;
112
+ defaultVariation?: {
113
+ id: string;
114
+ price: Record<string, number>;
115
+ name: string;
116
+ } | undefined;
117
+ variations?: {
118
+ id: string;
119
+ price: Record<string, number>;
120
+ name: string;
121
+ }[] | undefined;
122
+ } | undefined;
123
+ } | {
124
+ type: "Bundle";
125
+ id: string;
126
+ quantity: number;
127
+ variationId: string;
128
+ bundleId: string;
129
+ price?: Record<string, number> | undefined;
130
+ variation?: {
131
+ id: string;
132
+ price: Record<string, number>;
133
+ name: string;
134
+ } | undefined;
135
+ bundle?: {
136
+ type: "bundle";
137
+ id: string;
138
+ name: string;
139
+ tagline: string;
140
+ iconUrl: string;
141
+ products: {
142
+ type: "product";
143
+ id: string;
144
+ name: string;
145
+ tagline: string;
146
+ iconUrl: string;
147
+ defaultVariation?: {
148
+ id: string;
149
+ price: Record<string, number>;
150
+ name: string;
151
+ } | undefined;
152
+ variations?: {
153
+ id: string;
154
+ price: Record<string, number>;
155
+ name: string;
156
+ }[] | undefined;
157
+ }[];
158
+ defaultVariation?: {
159
+ id: string;
160
+ price: Record<string, number>;
161
+ name: string;
162
+ } | undefined;
163
+ variations?: {
164
+ id: string;
165
+ price: Record<string, number>;
166
+ name: string;
167
+ }[] | undefined;
168
+ } | undefined;
169
+ })[]>;
37
170
  currency: vue.ComputedRef<string>;
38
171
  total: vue.ComputedRef<{
39
172
  amount: number;
@@ -103,7 +236,7 @@ declare const storefrontKey: InjectionKey<StorefrontContext>;
103
236
  interface Cart {
104
237
  items: CartItem[];
105
238
  }
106
- type CartItem = LineItem & {};
239
+ type CartItem = LineItem;
107
240
  declare function createStorefront(endpoint: string, stateFactory?: StateFactory): StorefrontContext;
108
241
 
109
- export { type Cart, type CartItem, createStorefront, storefrontKey, useAuth, useBundle, useBundles, useCart, useProduct, useProducts };
242
+ export { type Cart, type CartItem, createStorefront, storefrontKey, useAuth, useBundle, useBundles, useCart, useInventory, useProduct, useProducts };
package/dist/index.js CHANGED
@@ -193,10 +193,32 @@ function useProducts() {
193
193
  return computed4(() => storefront.storefront.value.products);
194
194
  }
195
195
 
196
+ // src/composables/useInventory.ts
197
+ import { inject as inject5 } from "vue";
198
+ function useInventory() {
199
+ const storefront = inject5(storefrontKey);
200
+ if (!storefront)
201
+ throw new Error("No storefront configured");
202
+ return {
203
+ getLicenses: async (nextUrl) => {
204
+ return storefront.client.licenses.get(nextUrl);
205
+ },
206
+ getLicenseActivations: async (licenseId, nextUrl) => {
207
+ return storefront.client.licenses.getActivations(licenseId, nextUrl);
208
+ },
209
+ getProducts: async (nextUrl) => {
210
+ return storefront.client.products.getOwned(nextUrl);
211
+ },
212
+ getProductLicenses: async (productId, nextUrl) => {
213
+ return storefront.client.products.getLicenses(productId, nextUrl);
214
+ }
215
+ };
216
+ }
217
+
196
218
  // src/composables/useCart.ts
197
- import { computed as computed5, inject as inject5, unref } from "vue";
219
+ import { computed as computed5, inject as inject6, unref } from "vue";
198
220
  function useCart() {
199
- const storefront = inject5(storefrontKey);
221
+ const storefront = inject6(storefrontKey);
200
222
  if (!storefront)
201
223
  throw new Error("No storefront configured");
202
224
  return {
@@ -284,9 +306,9 @@ function useCart() {
284
306
  }
285
307
 
286
308
  // src/composables/useAuth.ts
287
- import { inject as inject6 } from "vue";
309
+ import { inject as inject7 } from "vue";
288
310
  function useAuth() {
289
- const storefront = inject6(storefrontKey);
311
+ const storefront = inject7(storefrontKey);
290
312
  if (!storefront)
291
313
  throw new Error("No storefront configured");
292
314
  return {
@@ -354,6 +376,7 @@ export {
354
376
  useBundle,
355
377
  useBundles,
356
378
  useCart,
379
+ useInventory,
357
380
  useProduct,
358
381
  useProducts
359
382
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@moonbase.sh/vue",
3
3
  "type": "module",
4
- "version": "0.1.52",
4
+ "version": "0.1.58",
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/api-client": "0.1.52"
21
+ "@moonbase.sh/api-client": "0.1.58"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/uuid": "^9.0.7",