@moonbase.sh/vue 0.1.59 → 0.1.62
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 +25 -11
- package/dist/index.d.cts +306 -1
- package/dist/index.d.ts +306 -1
- package/dist/index.js +18 -5
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -29,11 +29,12 @@ __export(src_exports, {
|
|
|
29
29
|
useCart: () => useCart,
|
|
30
30
|
useInventory: () => useInventory,
|
|
31
31
|
useProduct: () => useProduct,
|
|
32
|
-
useProducts: () => useProducts
|
|
32
|
+
useProducts: () => useProducts,
|
|
33
|
+
useVoucher: () => useVoucher
|
|
33
34
|
});
|
|
34
35
|
module.exports = __toCommonJS(src_exports);
|
|
35
36
|
var import_api_client2 = require("@moonbase.sh/api-client");
|
|
36
|
-
var
|
|
37
|
+
var import_vue10 = require("vue");
|
|
37
38
|
|
|
38
39
|
// src/context.ts
|
|
39
40
|
var import_api_client = require("@moonbase.sh/api-client");
|
|
@@ -248,16 +249,28 @@ function useInventory() {
|
|
|
248
249
|
};
|
|
249
250
|
}
|
|
250
251
|
|
|
251
|
-
// src/composables/
|
|
252
|
+
// src/composables/useVoucher.ts
|
|
252
253
|
var import_vue7 = require("vue");
|
|
253
|
-
function
|
|
254
|
+
function useVoucher() {
|
|
254
255
|
const storefront = (0, import_vue7.inject)(storefrontKey);
|
|
255
256
|
if (!storefront)
|
|
256
257
|
throw new Error("No storefront configured");
|
|
257
258
|
return {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
peek: storefront.client.vouchers.peek,
|
|
260
|
+
redeem: storefront.client.vouchers.redeem
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// src/composables/useCart.ts
|
|
265
|
+
var import_vue8 = require("vue");
|
|
266
|
+
function useCart() {
|
|
267
|
+
const storefront = (0, import_vue8.inject)(storefrontKey);
|
|
268
|
+
if (!storefront)
|
|
269
|
+
throw new Error("No storefront configured");
|
|
270
|
+
return {
|
|
271
|
+
items: (0, import_vue8.computed)(() => storefront.currentOrder.value.items),
|
|
272
|
+
currency: (0, import_vue8.computed)(() => storefront.currentOrder.value.currency || storefront.storefront.value.suggestedCurrency),
|
|
273
|
+
total: (0, import_vue8.computed)(() => {
|
|
261
274
|
const currency = storefront.currentOrder.value.currency || storefront.storefront.value.suggestedCurrency;
|
|
262
275
|
const total = storefront.currentOrder.value.items.reduce((agg, item) => {
|
|
263
276
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
@@ -278,7 +291,7 @@ function useCart() {
|
|
|
278
291
|
return { amount: total, currency };
|
|
279
292
|
}),
|
|
280
293
|
addToCart: (item, variation) => {
|
|
281
|
-
item = (0,
|
|
294
|
+
item = (0, import_vue8.unref)(item);
|
|
282
295
|
variation != null ? variation : variation = item.defaultVariation;
|
|
283
296
|
if (!variation)
|
|
284
297
|
throw new Error("Added item does not have a default variation, and none have been specified");
|
|
@@ -339,9 +352,9 @@ function useCart() {
|
|
|
339
352
|
}
|
|
340
353
|
|
|
341
354
|
// src/composables/useAuth.ts
|
|
342
|
-
var
|
|
355
|
+
var import_vue9 = require("vue");
|
|
343
356
|
function useAuth() {
|
|
344
|
-
const storefront = (0,
|
|
357
|
+
const storefront = (0, import_vue9.inject)(storefrontKey);
|
|
345
358
|
if (!storefront)
|
|
346
359
|
throw new Error("No storefront configured");
|
|
347
360
|
return {
|
|
@@ -399,7 +412,7 @@ function createStorefront(endpoint, stateFactory) {
|
|
|
399
412
|
configuration,
|
|
400
413
|
new import_api_client2.MoonbaseClient(configuration),
|
|
401
414
|
// Default to vue refs but allow stuff like Nuxt useState wrappers
|
|
402
|
-
stateFactory || ((_, state) => (0,
|
|
415
|
+
stateFactory || ((_, state) => (0, import_vue10.ref)(state))
|
|
403
416
|
);
|
|
404
417
|
}
|
|
405
418
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -413,5 +426,6 @@ function createStorefront(endpoint, stateFactory) {
|
|
|
413
426
|
useInventory,
|
|
414
427
|
useProduct,
|
|
415
428
|
useProducts,
|
|
429
|
+
useVoucher,
|
|
416
430
|
...require("@moonbase.sh/api-client")
|
|
417
431
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -90,6 +90,309 @@ declare function useInventory(): {
|
|
|
90
90
|
}>>;
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
+
declare function useVoucher(): {
|
|
94
|
+
peek: (code: string) => Promise<{
|
|
95
|
+
code: string;
|
|
96
|
+
id: string;
|
|
97
|
+
name: string;
|
|
98
|
+
description: string;
|
|
99
|
+
redeemed: boolean;
|
|
100
|
+
redeemsProducts: {
|
|
101
|
+
value: {
|
|
102
|
+
type: "product";
|
|
103
|
+
id: string;
|
|
104
|
+
name: string;
|
|
105
|
+
iconUrl: string;
|
|
106
|
+
tagline: string;
|
|
107
|
+
owned: boolean;
|
|
108
|
+
defaultVariation?: {
|
|
109
|
+
id: string;
|
|
110
|
+
name: string;
|
|
111
|
+
originalPrice: Record<string, number>;
|
|
112
|
+
price: Record<string, number>;
|
|
113
|
+
hasDiscount: boolean;
|
|
114
|
+
discount?: {
|
|
115
|
+
type: "PercentageOffDiscount";
|
|
116
|
+
name: string;
|
|
117
|
+
percentage: number;
|
|
118
|
+
total: Record<string, number>;
|
|
119
|
+
description?: string | undefined;
|
|
120
|
+
} | {
|
|
121
|
+
type: "FlatAmountOffDiscount";
|
|
122
|
+
name: string;
|
|
123
|
+
total: Record<string, number>;
|
|
124
|
+
description?: string | undefined;
|
|
125
|
+
} | undefined;
|
|
126
|
+
} | undefined;
|
|
127
|
+
variations?: {
|
|
128
|
+
id: string;
|
|
129
|
+
name: string;
|
|
130
|
+
originalPrice: Record<string, number>;
|
|
131
|
+
price: Record<string, number>;
|
|
132
|
+
hasDiscount: boolean;
|
|
133
|
+
discount?: {
|
|
134
|
+
type: "PercentageOffDiscount";
|
|
135
|
+
name: string;
|
|
136
|
+
percentage: number;
|
|
137
|
+
total: Record<string, number>;
|
|
138
|
+
description?: string | undefined;
|
|
139
|
+
} | {
|
|
140
|
+
type: "FlatAmountOffDiscount";
|
|
141
|
+
name: string;
|
|
142
|
+
total: Record<string, number>;
|
|
143
|
+
description?: string | undefined;
|
|
144
|
+
} | undefined;
|
|
145
|
+
}[] | undefined;
|
|
146
|
+
};
|
|
147
|
+
quantity: number;
|
|
148
|
+
}[];
|
|
149
|
+
redeemsBundles: {
|
|
150
|
+
value: {
|
|
151
|
+
type: "bundle";
|
|
152
|
+
id: string;
|
|
153
|
+
name: string;
|
|
154
|
+
iconUrl: string;
|
|
155
|
+
tagline: string;
|
|
156
|
+
products: {
|
|
157
|
+
type: "product";
|
|
158
|
+
id: string;
|
|
159
|
+
name: string;
|
|
160
|
+
iconUrl: string;
|
|
161
|
+
tagline: string;
|
|
162
|
+
owned: boolean;
|
|
163
|
+
defaultVariation?: {
|
|
164
|
+
id: string;
|
|
165
|
+
name: string;
|
|
166
|
+
originalPrice: Record<string, number>;
|
|
167
|
+
price: Record<string, number>;
|
|
168
|
+
hasDiscount: boolean;
|
|
169
|
+
discount?: {
|
|
170
|
+
type: "PercentageOffDiscount";
|
|
171
|
+
name: string;
|
|
172
|
+
percentage: number;
|
|
173
|
+
total: Record<string, number>;
|
|
174
|
+
description?: string | undefined;
|
|
175
|
+
} | {
|
|
176
|
+
type: "FlatAmountOffDiscount";
|
|
177
|
+
name: string;
|
|
178
|
+
total: Record<string, number>;
|
|
179
|
+
description?: string | undefined;
|
|
180
|
+
} | undefined;
|
|
181
|
+
} | undefined;
|
|
182
|
+
variations?: {
|
|
183
|
+
id: string;
|
|
184
|
+
name: string;
|
|
185
|
+
originalPrice: Record<string, number>;
|
|
186
|
+
price: Record<string, number>;
|
|
187
|
+
hasDiscount: boolean;
|
|
188
|
+
discount?: {
|
|
189
|
+
type: "PercentageOffDiscount";
|
|
190
|
+
name: string;
|
|
191
|
+
percentage: number;
|
|
192
|
+
total: Record<string, number>;
|
|
193
|
+
description?: string | undefined;
|
|
194
|
+
} | {
|
|
195
|
+
type: "FlatAmountOffDiscount";
|
|
196
|
+
name: string;
|
|
197
|
+
total: Record<string, number>;
|
|
198
|
+
description?: string | undefined;
|
|
199
|
+
} | undefined;
|
|
200
|
+
}[] | undefined;
|
|
201
|
+
}[];
|
|
202
|
+
defaultVariation?: {
|
|
203
|
+
id: string;
|
|
204
|
+
name: string;
|
|
205
|
+
originalPrice: Record<string, number>;
|
|
206
|
+
price: Record<string, number>;
|
|
207
|
+
hasDiscount: boolean;
|
|
208
|
+
discount?: {
|
|
209
|
+
type: "PercentageOffDiscount";
|
|
210
|
+
name: string;
|
|
211
|
+
percentage: number;
|
|
212
|
+
total: Record<string, number>;
|
|
213
|
+
description?: string | undefined;
|
|
214
|
+
} | {
|
|
215
|
+
type: "FlatAmountOffDiscount";
|
|
216
|
+
name: string;
|
|
217
|
+
total: Record<string, number>;
|
|
218
|
+
description?: string | undefined;
|
|
219
|
+
} | undefined;
|
|
220
|
+
} | undefined;
|
|
221
|
+
variations?: {
|
|
222
|
+
id: string;
|
|
223
|
+
name: string;
|
|
224
|
+
originalPrice: Record<string, number>;
|
|
225
|
+
price: Record<string, number>;
|
|
226
|
+
hasDiscount: boolean;
|
|
227
|
+
discount?: {
|
|
228
|
+
type: "PercentageOffDiscount";
|
|
229
|
+
name: string;
|
|
230
|
+
percentage: number;
|
|
231
|
+
total: Record<string, number>;
|
|
232
|
+
description?: string | undefined;
|
|
233
|
+
} | {
|
|
234
|
+
type: "FlatAmountOffDiscount";
|
|
235
|
+
name: string;
|
|
236
|
+
total: Record<string, number>;
|
|
237
|
+
description?: string | undefined;
|
|
238
|
+
} | undefined;
|
|
239
|
+
}[] | undefined;
|
|
240
|
+
};
|
|
241
|
+
quantity: number;
|
|
242
|
+
}[];
|
|
243
|
+
}>;
|
|
244
|
+
redeem: (code: string) => Promise<{
|
|
245
|
+
code: string;
|
|
246
|
+
id: string;
|
|
247
|
+
name: string;
|
|
248
|
+
description: string;
|
|
249
|
+
redeemed: boolean;
|
|
250
|
+
redeemsProducts: {
|
|
251
|
+
value: {
|
|
252
|
+
type: "product";
|
|
253
|
+
id: string;
|
|
254
|
+
name: string;
|
|
255
|
+
iconUrl: string;
|
|
256
|
+
tagline: string;
|
|
257
|
+
owned: boolean;
|
|
258
|
+
defaultVariation?: {
|
|
259
|
+
id: string;
|
|
260
|
+
name: string;
|
|
261
|
+
originalPrice: Record<string, number>;
|
|
262
|
+
price: Record<string, number>;
|
|
263
|
+
hasDiscount: boolean;
|
|
264
|
+
discount?: {
|
|
265
|
+
type: "PercentageOffDiscount";
|
|
266
|
+
name: string;
|
|
267
|
+
percentage: number;
|
|
268
|
+
total: Record<string, number>;
|
|
269
|
+
description?: string | undefined;
|
|
270
|
+
} | {
|
|
271
|
+
type: "FlatAmountOffDiscount";
|
|
272
|
+
name: string;
|
|
273
|
+
total: Record<string, number>;
|
|
274
|
+
description?: string | undefined;
|
|
275
|
+
} | undefined;
|
|
276
|
+
} | undefined;
|
|
277
|
+
variations?: {
|
|
278
|
+
id: string;
|
|
279
|
+
name: string;
|
|
280
|
+
originalPrice: Record<string, number>;
|
|
281
|
+
price: Record<string, number>;
|
|
282
|
+
hasDiscount: boolean;
|
|
283
|
+
discount?: {
|
|
284
|
+
type: "PercentageOffDiscount";
|
|
285
|
+
name: string;
|
|
286
|
+
percentage: number;
|
|
287
|
+
total: Record<string, number>;
|
|
288
|
+
description?: string | undefined;
|
|
289
|
+
} | {
|
|
290
|
+
type: "FlatAmountOffDiscount";
|
|
291
|
+
name: string;
|
|
292
|
+
total: Record<string, number>;
|
|
293
|
+
description?: string | undefined;
|
|
294
|
+
} | undefined;
|
|
295
|
+
}[] | undefined;
|
|
296
|
+
};
|
|
297
|
+
quantity: number;
|
|
298
|
+
}[];
|
|
299
|
+
redeemsBundles: {
|
|
300
|
+
value: {
|
|
301
|
+
type: "bundle";
|
|
302
|
+
id: string;
|
|
303
|
+
name: string;
|
|
304
|
+
iconUrl: string;
|
|
305
|
+
tagline: string;
|
|
306
|
+
products: {
|
|
307
|
+
type: "product";
|
|
308
|
+
id: string;
|
|
309
|
+
name: string;
|
|
310
|
+
iconUrl: string;
|
|
311
|
+
tagline: string;
|
|
312
|
+
owned: boolean;
|
|
313
|
+
defaultVariation?: {
|
|
314
|
+
id: string;
|
|
315
|
+
name: string;
|
|
316
|
+
originalPrice: Record<string, number>;
|
|
317
|
+
price: Record<string, number>;
|
|
318
|
+
hasDiscount: boolean;
|
|
319
|
+
discount?: {
|
|
320
|
+
type: "PercentageOffDiscount";
|
|
321
|
+
name: string;
|
|
322
|
+
percentage: number;
|
|
323
|
+
total: Record<string, number>;
|
|
324
|
+
description?: string | undefined;
|
|
325
|
+
} | {
|
|
326
|
+
type: "FlatAmountOffDiscount";
|
|
327
|
+
name: string;
|
|
328
|
+
total: Record<string, number>;
|
|
329
|
+
description?: string | undefined;
|
|
330
|
+
} | undefined;
|
|
331
|
+
} | undefined;
|
|
332
|
+
variations?: {
|
|
333
|
+
id: string;
|
|
334
|
+
name: string;
|
|
335
|
+
originalPrice: Record<string, number>;
|
|
336
|
+
price: Record<string, number>;
|
|
337
|
+
hasDiscount: boolean;
|
|
338
|
+
discount?: {
|
|
339
|
+
type: "PercentageOffDiscount";
|
|
340
|
+
name: string;
|
|
341
|
+
percentage: number;
|
|
342
|
+
total: Record<string, number>;
|
|
343
|
+
description?: string | undefined;
|
|
344
|
+
} | {
|
|
345
|
+
type: "FlatAmountOffDiscount";
|
|
346
|
+
name: string;
|
|
347
|
+
total: Record<string, number>;
|
|
348
|
+
description?: string | undefined;
|
|
349
|
+
} | undefined;
|
|
350
|
+
}[] | undefined;
|
|
351
|
+
}[];
|
|
352
|
+
defaultVariation?: {
|
|
353
|
+
id: string;
|
|
354
|
+
name: string;
|
|
355
|
+
originalPrice: Record<string, number>;
|
|
356
|
+
price: Record<string, number>;
|
|
357
|
+
hasDiscount: boolean;
|
|
358
|
+
discount?: {
|
|
359
|
+
type: "PercentageOffDiscount";
|
|
360
|
+
name: string;
|
|
361
|
+
percentage: number;
|
|
362
|
+
total: Record<string, number>;
|
|
363
|
+
description?: string | undefined;
|
|
364
|
+
} | {
|
|
365
|
+
type: "FlatAmountOffDiscount";
|
|
366
|
+
name: string;
|
|
367
|
+
total: Record<string, number>;
|
|
368
|
+
description?: string | undefined;
|
|
369
|
+
} | undefined;
|
|
370
|
+
} | undefined;
|
|
371
|
+
variations?: {
|
|
372
|
+
id: string;
|
|
373
|
+
name: string;
|
|
374
|
+
originalPrice: Record<string, number>;
|
|
375
|
+
price: Record<string, number>;
|
|
376
|
+
hasDiscount: boolean;
|
|
377
|
+
discount?: {
|
|
378
|
+
type: "PercentageOffDiscount";
|
|
379
|
+
name: string;
|
|
380
|
+
percentage: number;
|
|
381
|
+
total: Record<string, number>;
|
|
382
|
+
description?: string | undefined;
|
|
383
|
+
} | {
|
|
384
|
+
type: "FlatAmountOffDiscount";
|
|
385
|
+
name: string;
|
|
386
|
+
total: Record<string, number>;
|
|
387
|
+
description?: string | undefined;
|
|
388
|
+
} | undefined;
|
|
389
|
+
}[] | undefined;
|
|
390
|
+
};
|
|
391
|
+
quantity: number;
|
|
392
|
+
}[];
|
|
393
|
+
}>;
|
|
394
|
+
};
|
|
395
|
+
|
|
93
396
|
declare function useCart(): {
|
|
94
397
|
items: vue.ComputedRef<({
|
|
95
398
|
type: "Product";
|
|
@@ -123,6 +426,7 @@ declare function useCart(): {
|
|
|
123
426
|
name: string;
|
|
124
427
|
tagline: string;
|
|
125
428
|
iconUrl: string;
|
|
429
|
+
owned: boolean;
|
|
126
430
|
defaultVariation?: {
|
|
127
431
|
id: string;
|
|
128
432
|
price: Record<string, number>;
|
|
@@ -200,6 +504,7 @@ declare function useCart(): {
|
|
|
200
504
|
name: string;
|
|
201
505
|
tagline: string;
|
|
202
506
|
iconUrl: string;
|
|
507
|
+
owned: boolean;
|
|
203
508
|
defaultVariation?: {
|
|
204
509
|
id: string;
|
|
205
510
|
price: Record<string, number>;
|
|
@@ -351,4 +656,4 @@ interface Cart {
|
|
|
351
656
|
type CartItem = LineItem;
|
|
352
657
|
declare function createStorefront(endpoint: string, stateFactory?: StateFactory): StorefrontContext;
|
|
353
658
|
|
|
354
|
-
export { type Cart, type CartItem, createStorefront, storefrontKey, useAuth, useBundle, useBundles, useCart, useInventory, useProduct, useProducts };
|
|
659
|
+
export { type Cart, type CartItem, createStorefront, storefrontKey, useAuth, useBundle, useBundles, useCart, useInventory, useProduct, useProducts, useVoucher };
|
package/dist/index.d.ts
CHANGED
|
@@ -90,6 +90,309 @@ declare function useInventory(): {
|
|
|
90
90
|
}>>;
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
+
declare function useVoucher(): {
|
|
94
|
+
peek: (code: string) => Promise<{
|
|
95
|
+
code: string;
|
|
96
|
+
id: string;
|
|
97
|
+
name: string;
|
|
98
|
+
description: string;
|
|
99
|
+
redeemed: boolean;
|
|
100
|
+
redeemsProducts: {
|
|
101
|
+
value: {
|
|
102
|
+
type: "product";
|
|
103
|
+
id: string;
|
|
104
|
+
name: string;
|
|
105
|
+
iconUrl: string;
|
|
106
|
+
tagline: string;
|
|
107
|
+
owned: boolean;
|
|
108
|
+
defaultVariation?: {
|
|
109
|
+
id: string;
|
|
110
|
+
name: string;
|
|
111
|
+
originalPrice: Record<string, number>;
|
|
112
|
+
price: Record<string, number>;
|
|
113
|
+
hasDiscount: boolean;
|
|
114
|
+
discount?: {
|
|
115
|
+
type: "PercentageOffDiscount";
|
|
116
|
+
name: string;
|
|
117
|
+
percentage: number;
|
|
118
|
+
total: Record<string, number>;
|
|
119
|
+
description?: string | undefined;
|
|
120
|
+
} | {
|
|
121
|
+
type: "FlatAmountOffDiscount";
|
|
122
|
+
name: string;
|
|
123
|
+
total: Record<string, number>;
|
|
124
|
+
description?: string | undefined;
|
|
125
|
+
} | undefined;
|
|
126
|
+
} | undefined;
|
|
127
|
+
variations?: {
|
|
128
|
+
id: string;
|
|
129
|
+
name: string;
|
|
130
|
+
originalPrice: Record<string, number>;
|
|
131
|
+
price: Record<string, number>;
|
|
132
|
+
hasDiscount: boolean;
|
|
133
|
+
discount?: {
|
|
134
|
+
type: "PercentageOffDiscount";
|
|
135
|
+
name: string;
|
|
136
|
+
percentage: number;
|
|
137
|
+
total: Record<string, number>;
|
|
138
|
+
description?: string | undefined;
|
|
139
|
+
} | {
|
|
140
|
+
type: "FlatAmountOffDiscount";
|
|
141
|
+
name: string;
|
|
142
|
+
total: Record<string, number>;
|
|
143
|
+
description?: string | undefined;
|
|
144
|
+
} | undefined;
|
|
145
|
+
}[] | undefined;
|
|
146
|
+
};
|
|
147
|
+
quantity: number;
|
|
148
|
+
}[];
|
|
149
|
+
redeemsBundles: {
|
|
150
|
+
value: {
|
|
151
|
+
type: "bundle";
|
|
152
|
+
id: string;
|
|
153
|
+
name: string;
|
|
154
|
+
iconUrl: string;
|
|
155
|
+
tagline: string;
|
|
156
|
+
products: {
|
|
157
|
+
type: "product";
|
|
158
|
+
id: string;
|
|
159
|
+
name: string;
|
|
160
|
+
iconUrl: string;
|
|
161
|
+
tagline: string;
|
|
162
|
+
owned: boolean;
|
|
163
|
+
defaultVariation?: {
|
|
164
|
+
id: string;
|
|
165
|
+
name: string;
|
|
166
|
+
originalPrice: Record<string, number>;
|
|
167
|
+
price: Record<string, number>;
|
|
168
|
+
hasDiscount: boolean;
|
|
169
|
+
discount?: {
|
|
170
|
+
type: "PercentageOffDiscount";
|
|
171
|
+
name: string;
|
|
172
|
+
percentage: number;
|
|
173
|
+
total: Record<string, number>;
|
|
174
|
+
description?: string | undefined;
|
|
175
|
+
} | {
|
|
176
|
+
type: "FlatAmountOffDiscount";
|
|
177
|
+
name: string;
|
|
178
|
+
total: Record<string, number>;
|
|
179
|
+
description?: string | undefined;
|
|
180
|
+
} | undefined;
|
|
181
|
+
} | undefined;
|
|
182
|
+
variations?: {
|
|
183
|
+
id: string;
|
|
184
|
+
name: string;
|
|
185
|
+
originalPrice: Record<string, number>;
|
|
186
|
+
price: Record<string, number>;
|
|
187
|
+
hasDiscount: boolean;
|
|
188
|
+
discount?: {
|
|
189
|
+
type: "PercentageOffDiscount";
|
|
190
|
+
name: string;
|
|
191
|
+
percentage: number;
|
|
192
|
+
total: Record<string, number>;
|
|
193
|
+
description?: string | undefined;
|
|
194
|
+
} | {
|
|
195
|
+
type: "FlatAmountOffDiscount";
|
|
196
|
+
name: string;
|
|
197
|
+
total: Record<string, number>;
|
|
198
|
+
description?: string | undefined;
|
|
199
|
+
} | undefined;
|
|
200
|
+
}[] | undefined;
|
|
201
|
+
}[];
|
|
202
|
+
defaultVariation?: {
|
|
203
|
+
id: string;
|
|
204
|
+
name: string;
|
|
205
|
+
originalPrice: Record<string, number>;
|
|
206
|
+
price: Record<string, number>;
|
|
207
|
+
hasDiscount: boolean;
|
|
208
|
+
discount?: {
|
|
209
|
+
type: "PercentageOffDiscount";
|
|
210
|
+
name: string;
|
|
211
|
+
percentage: number;
|
|
212
|
+
total: Record<string, number>;
|
|
213
|
+
description?: string | undefined;
|
|
214
|
+
} | {
|
|
215
|
+
type: "FlatAmountOffDiscount";
|
|
216
|
+
name: string;
|
|
217
|
+
total: Record<string, number>;
|
|
218
|
+
description?: string | undefined;
|
|
219
|
+
} | undefined;
|
|
220
|
+
} | undefined;
|
|
221
|
+
variations?: {
|
|
222
|
+
id: string;
|
|
223
|
+
name: string;
|
|
224
|
+
originalPrice: Record<string, number>;
|
|
225
|
+
price: Record<string, number>;
|
|
226
|
+
hasDiscount: boolean;
|
|
227
|
+
discount?: {
|
|
228
|
+
type: "PercentageOffDiscount";
|
|
229
|
+
name: string;
|
|
230
|
+
percentage: number;
|
|
231
|
+
total: Record<string, number>;
|
|
232
|
+
description?: string | undefined;
|
|
233
|
+
} | {
|
|
234
|
+
type: "FlatAmountOffDiscount";
|
|
235
|
+
name: string;
|
|
236
|
+
total: Record<string, number>;
|
|
237
|
+
description?: string | undefined;
|
|
238
|
+
} | undefined;
|
|
239
|
+
}[] | undefined;
|
|
240
|
+
};
|
|
241
|
+
quantity: number;
|
|
242
|
+
}[];
|
|
243
|
+
}>;
|
|
244
|
+
redeem: (code: string) => Promise<{
|
|
245
|
+
code: string;
|
|
246
|
+
id: string;
|
|
247
|
+
name: string;
|
|
248
|
+
description: string;
|
|
249
|
+
redeemed: boolean;
|
|
250
|
+
redeemsProducts: {
|
|
251
|
+
value: {
|
|
252
|
+
type: "product";
|
|
253
|
+
id: string;
|
|
254
|
+
name: string;
|
|
255
|
+
iconUrl: string;
|
|
256
|
+
tagline: string;
|
|
257
|
+
owned: boolean;
|
|
258
|
+
defaultVariation?: {
|
|
259
|
+
id: string;
|
|
260
|
+
name: string;
|
|
261
|
+
originalPrice: Record<string, number>;
|
|
262
|
+
price: Record<string, number>;
|
|
263
|
+
hasDiscount: boolean;
|
|
264
|
+
discount?: {
|
|
265
|
+
type: "PercentageOffDiscount";
|
|
266
|
+
name: string;
|
|
267
|
+
percentage: number;
|
|
268
|
+
total: Record<string, number>;
|
|
269
|
+
description?: string | undefined;
|
|
270
|
+
} | {
|
|
271
|
+
type: "FlatAmountOffDiscount";
|
|
272
|
+
name: string;
|
|
273
|
+
total: Record<string, number>;
|
|
274
|
+
description?: string | undefined;
|
|
275
|
+
} | undefined;
|
|
276
|
+
} | undefined;
|
|
277
|
+
variations?: {
|
|
278
|
+
id: string;
|
|
279
|
+
name: string;
|
|
280
|
+
originalPrice: Record<string, number>;
|
|
281
|
+
price: Record<string, number>;
|
|
282
|
+
hasDiscount: boolean;
|
|
283
|
+
discount?: {
|
|
284
|
+
type: "PercentageOffDiscount";
|
|
285
|
+
name: string;
|
|
286
|
+
percentage: number;
|
|
287
|
+
total: Record<string, number>;
|
|
288
|
+
description?: string | undefined;
|
|
289
|
+
} | {
|
|
290
|
+
type: "FlatAmountOffDiscount";
|
|
291
|
+
name: string;
|
|
292
|
+
total: Record<string, number>;
|
|
293
|
+
description?: string | undefined;
|
|
294
|
+
} | undefined;
|
|
295
|
+
}[] | undefined;
|
|
296
|
+
};
|
|
297
|
+
quantity: number;
|
|
298
|
+
}[];
|
|
299
|
+
redeemsBundles: {
|
|
300
|
+
value: {
|
|
301
|
+
type: "bundle";
|
|
302
|
+
id: string;
|
|
303
|
+
name: string;
|
|
304
|
+
iconUrl: string;
|
|
305
|
+
tagline: string;
|
|
306
|
+
products: {
|
|
307
|
+
type: "product";
|
|
308
|
+
id: string;
|
|
309
|
+
name: string;
|
|
310
|
+
iconUrl: string;
|
|
311
|
+
tagline: string;
|
|
312
|
+
owned: boolean;
|
|
313
|
+
defaultVariation?: {
|
|
314
|
+
id: string;
|
|
315
|
+
name: string;
|
|
316
|
+
originalPrice: Record<string, number>;
|
|
317
|
+
price: Record<string, number>;
|
|
318
|
+
hasDiscount: boolean;
|
|
319
|
+
discount?: {
|
|
320
|
+
type: "PercentageOffDiscount";
|
|
321
|
+
name: string;
|
|
322
|
+
percentage: number;
|
|
323
|
+
total: Record<string, number>;
|
|
324
|
+
description?: string | undefined;
|
|
325
|
+
} | {
|
|
326
|
+
type: "FlatAmountOffDiscount";
|
|
327
|
+
name: string;
|
|
328
|
+
total: Record<string, number>;
|
|
329
|
+
description?: string | undefined;
|
|
330
|
+
} | undefined;
|
|
331
|
+
} | undefined;
|
|
332
|
+
variations?: {
|
|
333
|
+
id: string;
|
|
334
|
+
name: string;
|
|
335
|
+
originalPrice: Record<string, number>;
|
|
336
|
+
price: Record<string, number>;
|
|
337
|
+
hasDiscount: boolean;
|
|
338
|
+
discount?: {
|
|
339
|
+
type: "PercentageOffDiscount";
|
|
340
|
+
name: string;
|
|
341
|
+
percentage: number;
|
|
342
|
+
total: Record<string, number>;
|
|
343
|
+
description?: string | undefined;
|
|
344
|
+
} | {
|
|
345
|
+
type: "FlatAmountOffDiscount";
|
|
346
|
+
name: string;
|
|
347
|
+
total: Record<string, number>;
|
|
348
|
+
description?: string | undefined;
|
|
349
|
+
} | undefined;
|
|
350
|
+
}[] | undefined;
|
|
351
|
+
}[];
|
|
352
|
+
defaultVariation?: {
|
|
353
|
+
id: string;
|
|
354
|
+
name: string;
|
|
355
|
+
originalPrice: Record<string, number>;
|
|
356
|
+
price: Record<string, number>;
|
|
357
|
+
hasDiscount: boolean;
|
|
358
|
+
discount?: {
|
|
359
|
+
type: "PercentageOffDiscount";
|
|
360
|
+
name: string;
|
|
361
|
+
percentage: number;
|
|
362
|
+
total: Record<string, number>;
|
|
363
|
+
description?: string | undefined;
|
|
364
|
+
} | {
|
|
365
|
+
type: "FlatAmountOffDiscount";
|
|
366
|
+
name: string;
|
|
367
|
+
total: Record<string, number>;
|
|
368
|
+
description?: string | undefined;
|
|
369
|
+
} | undefined;
|
|
370
|
+
} | undefined;
|
|
371
|
+
variations?: {
|
|
372
|
+
id: string;
|
|
373
|
+
name: string;
|
|
374
|
+
originalPrice: Record<string, number>;
|
|
375
|
+
price: Record<string, number>;
|
|
376
|
+
hasDiscount: boolean;
|
|
377
|
+
discount?: {
|
|
378
|
+
type: "PercentageOffDiscount";
|
|
379
|
+
name: string;
|
|
380
|
+
percentage: number;
|
|
381
|
+
total: Record<string, number>;
|
|
382
|
+
description?: string | undefined;
|
|
383
|
+
} | {
|
|
384
|
+
type: "FlatAmountOffDiscount";
|
|
385
|
+
name: string;
|
|
386
|
+
total: Record<string, number>;
|
|
387
|
+
description?: string | undefined;
|
|
388
|
+
} | undefined;
|
|
389
|
+
}[] | undefined;
|
|
390
|
+
};
|
|
391
|
+
quantity: number;
|
|
392
|
+
}[];
|
|
393
|
+
}>;
|
|
394
|
+
};
|
|
395
|
+
|
|
93
396
|
declare function useCart(): {
|
|
94
397
|
items: vue.ComputedRef<({
|
|
95
398
|
type: "Product";
|
|
@@ -123,6 +426,7 @@ declare function useCart(): {
|
|
|
123
426
|
name: string;
|
|
124
427
|
tagline: string;
|
|
125
428
|
iconUrl: string;
|
|
429
|
+
owned: boolean;
|
|
126
430
|
defaultVariation?: {
|
|
127
431
|
id: string;
|
|
128
432
|
price: Record<string, number>;
|
|
@@ -200,6 +504,7 @@ declare function useCart(): {
|
|
|
200
504
|
name: string;
|
|
201
505
|
tagline: string;
|
|
202
506
|
iconUrl: string;
|
|
507
|
+
owned: boolean;
|
|
203
508
|
defaultVariation?: {
|
|
204
509
|
id: string;
|
|
205
510
|
price: Record<string, number>;
|
|
@@ -351,4 +656,4 @@ interface Cart {
|
|
|
351
656
|
type CartItem = LineItem;
|
|
352
657
|
declare function createStorefront(endpoint: string, stateFactory?: StateFactory): StorefrontContext;
|
|
353
658
|
|
|
354
|
-
export { type Cart, type CartItem, createStorefront, storefrontKey, useAuth, useBundle, useBundles, useCart, useInventory, useProduct, useProducts };
|
|
659
|
+
export { type Cart, type CartItem, createStorefront, storefrontKey, useAuth, useBundle, useBundles, useCart, useInventory, useProduct, useProducts, useVoucher };
|
package/dist/index.js
CHANGED
|
@@ -215,10 +215,22 @@ function useInventory() {
|
|
|
215
215
|
};
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
+
// src/composables/useVoucher.ts
|
|
219
|
+
import { inject as inject6 } from "vue";
|
|
220
|
+
function useVoucher() {
|
|
221
|
+
const storefront = inject6(storefrontKey);
|
|
222
|
+
if (!storefront)
|
|
223
|
+
throw new Error("No storefront configured");
|
|
224
|
+
return {
|
|
225
|
+
peek: storefront.client.vouchers.peek,
|
|
226
|
+
redeem: storefront.client.vouchers.redeem
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
218
230
|
// src/composables/useCart.ts
|
|
219
|
-
import { computed as computed5, inject as
|
|
231
|
+
import { computed as computed5, inject as inject7, unref } from "vue";
|
|
220
232
|
function useCart() {
|
|
221
|
-
const storefront =
|
|
233
|
+
const storefront = inject7(storefrontKey);
|
|
222
234
|
if (!storefront)
|
|
223
235
|
throw new Error("No storefront configured");
|
|
224
236
|
return {
|
|
@@ -306,9 +318,9 @@ function useCart() {
|
|
|
306
318
|
}
|
|
307
319
|
|
|
308
320
|
// src/composables/useAuth.ts
|
|
309
|
-
import { inject as
|
|
321
|
+
import { inject as inject8 } from "vue";
|
|
310
322
|
function useAuth() {
|
|
311
|
-
const storefront =
|
|
323
|
+
const storefront = inject8(storefrontKey);
|
|
312
324
|
if (!storefront)
|
|
313
325
|
throw new Error("No storefront configured");
|
|
314
326
|
return {
|
|
@@ -378,5 +390,6 @@ export {
|
|
|
378
390
|
useCart,
|
|
379
391
|
useInventory,
|
|
380
392
|
useProduct,
|
|
381
|
-
useProducts
|
|
393
|
+
useProducts,
|
|
394
|
+
useVoucher
|
|
382
395
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbase.sh/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.62",
|
|
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.
|
|
21
|
+
"@moonbase.sh/api-client": "0.1.62"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/uuid": "^9.0.7",
|