@moonbase.sh/vue 0.2.32 → 0.2.34
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 +33 -30
- package/dist/index.d.cts +20 -3
- package/dist/index.d.ts +20 -3
- package/dist/index.js +34 -31
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -250,6 +250,7 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
250
250
|
} finally {
|
|
251
251
|
this.loadedUser.value = true;
|
|
252
252
|
}
|
|
253
|
+
return this.currentUser.value;
|
|
253
254
|
}
|
|
254
255
|
async updateStorefront() {
|
|
255
256
|
const latestStorefront = await this.client.storefront.get(this.hasUtm.value ? this.utm.value : void 0);
|
|
@@ -262,6 +263,7 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
262
263
|
this.currentOrder.value.currency = latestStorefront.suggestedCurrency;
|
|
263
264
|
}
|
|
264
265
|
}
|
|
266
|
+
return latestStorefront;
|
|
265
267
|
}
|
|
266
268
|
async pushOrderContent() {
|
|
267
269
|
if (typeof window !== "undefined")
|
|
@@ -396,19 +398,18 @@ var import_storefront_api3 = require("@moonbase.sh/storefront-api");
|
|
|
396
398
|
var import_vue7 = require("vue");
|
|
397
399
|
function useActivationRequest(token, context) {
|
|
398
400
|
const storefront = context != null ? context : (0, import_vue7.inject)(storefrontKey);
|
|
399
|
-
const requestId = (0, import_vue7.toValue)(token);
|
|
400
|
-
if (!requestId)
|
|
401
|
-
throw new Error("No request ID was given when calling `useActivationRequest`");
|
|
402
401
|
if (!storefront)
|
|
403
402
|
throw new Error("No storefront configured");
|
|
404
|
-
const activationRequest = storefront.stateFactory(`activation-request-${
|
|
405
|
-
const error = storefront.stateFactory(`activation-request-${
|
|
406
|
-
const loading = storefront.stateFactory(`activation-request-${
|
|
407
|
-
const fulfilling = storefront.stateFactory(`activation-request-${
|
|
408
|
-
const completing = storefront.stateFactory(`activation-request-${
|
|
409
|
-
const completionTimeout = storefront.stateFactory(`activation-request-${
|
|
403
|
+
const activationRequest = storefront.stateFactory(`activation-request-${(0, import_vue7.toValue)(token)}`, null);
|
|
404
|
+
const error = storefront.stateFactory(`activation-request-${(0, import_vue7.toValue)(token)}-error`, null);
|
|
405
|
+
const loading = storefront.stateFactory(`activation-request-${(0, import_vue7.toValue)(token)}-loading`, true);
|
|
406
|
+
const fulfilling = storefront.stateFactory(`activation-request-${(0, import_vue7.toValue)(token)}-fulfilling`, false);
|
|
407
|
+
const completing = storefront.stateFactory(`activation-request-${(0, import_vue7.toValue)(token)}-completing`, false);
|
|
408
|
+
const completionTimeout = storefront.stateFactory(`activation-request-${(0, import_vue7.toValue)(token)}-completion-timeout`, null);
|
|
410
409
|
const checkCompletion = async () => {
|
|
411
|
-
|
|
410
|
+
if (!activationRequest.value)
|
|
411
|
+
return;
|
|
412
|
+
const completed = await storefront.client.activationRequests.isCompleted(activationRequest.value.id);
|
|
412
413
|
if (completed && activationRequest.value) {
|
|
413
414
|
activationRequest.value.status = import_storefront_api3.ActivationRequestStatus.Completed;
|
|
414
415
|
completing.value = false;
|
|
@@ -416,28 +417,31 @@ function useActivationRequest(token, context) {
|
|
|
416
417
|
completionTimeout.value = setTimeout(checkCompletion, 1500);
|
|
417
418
|
}
|
|
418
419
|
};
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
420
|
+
(0, import_vue7.watch)(() => (0, import_vue7.toValue)(token), async (newRequestId) => {
|
|
421
|
+
try {
|
|
422
|
+
if (newRequestId && newRequestId.length > 0) {
|
|
423
|
+
activationRequest.value = await storefront.client.activationRequests.get(newRequestId);
|
|
424
|
+
if (activationRequest.value.status === import_storefront_api3.ActivationRequestStatus.Fulfilled) {
|
|
425
|
+
completing.value = true;
|
|
426
|
+
checkCompletion();
|
|
427
|
+
}
|
|
428
|
+
loading.value = false;
|
|
429
|
+
} else {
|
|
430
|
+
error.value = new import_storefront_api3.MoonbaseError("Invalid input", "Missing request id", -1);
|
|
431
|
+
loading.value = false;
|
|
425
432
|
}
|
|
433
|
+
} catch (err) {
|
|
434
|
+
error.value = err;
|
|
426
435
|
loading.value = false;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
loading.value = false;
|
|
430
|
-
});
|
|
431
|
-
} else {
|
|
432
|
-
error.value = new Error("Missing request id");
|
|
433
|
-
loading.value = false;
|
|
434
|
-
}
|
|
436
|
+
}
|
|
437
|
+
}, { immediate: true });
|
|
435
438
|
(0, import_vue7.onBeforeUnmount)(() => {
|
|
436
439
|
if (completionTimeout.value)
|
|
437
440
|
clearTimeout(completionTimeout.value);
|
|
438
441
|
});
|
|
439
442
|
(0, import_vue7.watch)(storefront.currentUser, async () => {
|
|
440
443
|
var _a, _b;
|
|
444
|
+
const requestId = (0, import_vue7.toValue)(token);
|
|
441
445
|
if (!requestId || ((_b = (_a = activationRequest.value) == null ? void 0 : _a.licenseEligibility) == null ? void 0 : _b.eligible))
|
|
442
446
|
return;
|
|
443
447
|
loading.value = true;
|
|
@@ -464,23 +468,22 @@ function useActivationRequest(token, context) {
|
|
|
464
468
|
}),
|
|
465
469
|
fulfillLicense: async () => {
|
|
466
470
|
fulfilling.value = true;
|
|
467
|
-
activationRequest.value = await storefront.client.activationRequests.fulfillLicense(
|
|
471
|
+
activationRequest.value = await storefront.client.activationRequests.fulfillLicense(activationRequest.value.id);
|
|
468
472
|
fulfilling.value = false;
|
|
469
473
|
completing.value = true;
|
|
470
474
|
const _ = checkCompletion();
|
|
471
475
|
},
|
|
472
476
|
fulfillTrial: async () => {
|
|
473
477
|
fulfilling.value = true;
|
|
474
|
-
activationRequest.value = await storefront.client.activationRequests.fulfillTrial(
|
|
478
|
+
activationRequest.value = await storefront.client.activationRequests.fulfillTrial(activationRequest.value.id);
|
|
475
479
|
fulfilling.value = false;
|
|
476
480
|
completing.value = true;
|
|
477
481
|
const _ = checkCompletion();
|
|
478
482
|
},
|
|
479
483
|
cancel: async () => {
|
|
480
|
-
|
|
481
|
-
if (((_a = activationRequest.value) == null ? void 0 : _a.status) === import_storefront_api3.ActivationRequestStatus.Cancelled)
|
|
484
|
+
if (!activationRequest.value || activationRequest.value.status === import_storefront_api3.ActivationRequestStatus.Cancelled)
|
|
482
485
|
return;
|
|
483
|
-
activationRequest.value = await storefront.client.activationRequests.cancel(
|
|
486
|
+
activationRequest.value = await storefront.client.activationRequests.cancel(activationRequest.value.id);
|
|
484
487
|
}
|
|
485
488
|
};
|
|
486
489
|
}
|
|
@@ -708,7 +711,7 @@ function useAuth(context) {
|
|
|
708
711
|
},
|
|
709
712
|
confirmEmailChange: async (email, code) => {
|
|
710
713
|
await storefront.client.identity.confirmEmailChange(email, code);
|
|
711
|
-
|
|
714
|
+
return await storefront.updateUser();
|
|
712
715
|
}
|
|
713
716
|
};
|
|
714
717
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -16,8 +16,8 @@ interface StorefrontContext extends Pick<Plugin, keyof Plugin> {
|
|
|
16
16
|
loadedUser: Ref<boolean>;
|
|
17
17
|
loadedUserPromise: Promise<void>;
|
|
18
18
|
client: MoonbaseClient;
|
|
19
|
-
updateUser: () => Promise<
|
|
20
|
-
updateStorefront: () => Promise<
|
|
19
|
+
updateUser: () => Promise<User | null>;
|
|
20
|
+
updateStorefront: () => Promise<Storefront>;
|
|
21
21
|
pushOrderContent: () => Promise<void>;
|
|
22
22
|
resetOrder: () => void;
|
|
23
23
|
closeCheckout: () => void;
|
|
@@ -797,7 +797,24 @@ declare function useAuth(context?: StorefrontContext): {
|
|
|
797
797
|
resetPasswordToken: string | null;
|
|
798
798
|
}>;
|
|
799
799
|
confirmEmail: (email: string, code: string) => Promise<void>;
|
|
800
|
-
confirmEmailChange: (email: string, code: string) => Promise<
|
|
800
|
+
confirmEmailChange: (email: string, code: string) => Promise<{
|
|
801
|
+
id: string;
|
|
802
|
+
email: string;
|
|
803
|
+
name: string;
|
|
804
|
+
tenantId: string;
|
|
805
|
+
communicationPreferences: {
|
|
806
|
+
newsletterOptIn: boolean;
|
|
807
|
+
};
|
|
808
|
+
address?: {
|
|
809
|
+
countryCode: string;
|
|
810
|
+
streetAddress1: string;
|
|
811
|
+
streetAddress2: string | null;
|
|
812
|
+
locality: string | null;
|
|
813
|
+
region: string | null;
|
|
814
|
+
postCode: string;
|
|
815
|
+
} | undefined;
|
|
816
|
+
ownedProducts?: string[] | undefined;
|
|
817
|
+
} | null>;
|
|
801
818
|
};
|
|
802
819
|
|
|
803
820
|
declare const storefrontKey: InjectionKey<StorefrontContext>;
|
package/dist/index.d.ts
CHANGED
|
@@ -16,8 +16,8 @@ interface StorefrontContext extends Pick<Plugin, keyof Plugin> {
|
|
|
16
16
|
loadedUser: Ref<boolean>;
|
|
17
17
|
loadedUserPromise: Promise<void>;
|
|
18
18
|
client: MoonbaseClient;
|
|
19
|
-
updateUser: () => Promise<
|
|
20
|
-
updateStorefront: () => Promise<
|
|
19
|
+
updateUser: () => Promise<User | null>;
|
|
20
|
+
updateStorefront: () => Promise<Storefront>;
|
|
21
21
|
pushOrderContent: () => Promise<void>;
|
|
22
22
|
resetOrder: () => void;
|
|
23
23
|
closeCheckout: () => void;
|
|
@@ -797,7 +797,24 @@ declare function useAuth(context?: StorefrontContext): {
|
|
|
797
797
|
resetPasswordToken: string | null;
|
|
798
798
|
}>;
|
|
799
799
|
confirmEmail: (email: string, code: string) => Promise<void>;
|
|
800
|
-
confirmEmailChange: (email: string, code: string) => Promise<
|
|
800
|
+
confirmEmailChange: (email: string, code: string) => Promise<{
|
|
801
|
+
id: string;
|
|
802
|
+
email: string;
|
|
803
|
+
name: string;
|
|
804
|
+
tenantId: string;
|
|
805
|
+
communicationPreferences: {
|
|
806
|
+
newsletterOptIn: boolean;
|
|
807
|
+
};
|
|
808
|
+
address?: {
|
|
809
|
+
countryCode: string;
|
|
810
|
+
streetAddress1: string;
|
|
811
|
+
streetAddress2: string | null;
|
|
812
|
+
locality: string | null;
|
|
813
|
+
region: string | null;
|
|
814
|
+
postCode: string;
|
|
815
|
+
} | undefined;
|
|
816
|
+
ownedProducts?: string[] | undefined;
|
|
817
|
+
} | null>;
|
|
801
818
|
};
|
|
802
819
|
|
|
803
820
|
declare const storefrontKey: InjectionKey<StorefrontContext>;
|
package/dist/index.js
CHANGED
|
@@ -215,6 +215,7 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
215
215
|
} finally {
|
|
216
216
|
this.loadedUser.value = true;
|
|
217
217
|
}
|
|
218
|
+
return this.currentUser.value;
|
|
218
219
|
}
|
|
219
220
|
async updateStorefront() {
|
|
220
221
|
const latestStorefront = await this.client.storefront.get(this.hasUtm.value ? this.utm.value : void 0);
|
|
@@ -227,6 +228,7 @@ var _StorefrontContextImpl = class _StorefrontContextImpl {
|
|
|
227
228
|
this.currentOrder.value.currency = latestStorefront.suggestedCurrency;
|
|
228
229
|
}
|
|
229
230
|
}
|
|
231
|
+
return latestStorefront;
|
|
230
232
|
}
|
|
231
233
|
async pushOrderContent() {
|
|
232
234
|
if (typeof window !== "undefined")
|
|
@@ -357,23 +359,22 @@ function useInventory(context) {
|
|
|
357
359
|
}
|
|
358
360
|
|
|
359
361
|
// src/composables/useActivationRequest.ts
|
|
360
|
-
import { ActivationRequestStatus } from "@moonbase.sh/storefront-api";
|
|
362
|
+
import { ActivationRequestStatus, MoonbaseError } from "@moonbase.sh/storefront-api";
|
|
361
363
|
import { computed as computed6, inject as inject6, onBeforeUnmount, toValue, watch as watch2 } from "vue";
|
|
362
364
|
function useActivationRequest(token, context) {
|
|
363
365
|
const storefront = context != null ? context : inject6(storefrontKey);
|
|
364
|
-
const requestId = toValue(token);
|
|
365
|
-
if (!requestId)
|
|
366
|
-
throw new Error("No request ID was given when calling `useActivationRequest`");
|
|
367
366
|
if (!storefront)
|
|
368
367
|
throw new Error("No storefront configured");
|
|
369
|
-
const activationRequest = storefront.stateFactory(`activation-request-${
|
|
370
|
-
const error = storefront.stateFactory(`activation-request-${
|
|
371
|
-
const loading = storefront.stateFactory(`activation-request-${
|
|
372
|
-
const fulfilling = storefront.stateFactory(`activation-request-${
|
|
373
|
-
const completing = storefront.stateFactory(`activation-request-${
|
|
374
|
-
const completionTimeout = storefront.stateFactory(`activation-request-${
|
|
368
|
+
const activationRequest = storefront.stateFactory(`activation-request-${toValue(token)}`, null);
|
|
369
|
+
const error = storefront.stateFactory(`activation-request-${toValue(token)}-error`, null);
|
|
370
|
+
const loading = storefront.stateFactory(`activation-request-${toValue(token)}-loading`, true);
|
|
371
|
+
const fulfilling = storefront.stateFactory(`activation-request-${toValue(token)}-fulfilling`, false);
|
|
372
|
+
const completing = storefront.stateFactory(`activation-request-${toValue(token)}-completing`, false);
|
|
373
|
+
const completionTimeout = storefront.stateFactory(`activation-request-${toValue(token)}-completion-timeout`, null);
|
|
375
374
|
const checkCompletion = async () => {
|
|
376
|
-
|
|
375
|
+
if (!activationRequest.value)
|
|
376
|
+
return;
|
|
377
|
+
const completed = await storefront.client.activationRequests.isCompleted(activationRequest.value.id);
|
|
377
378
|
if (completed && activationRequest.value) {
|
|
378
379
|
activationRequest.value.status = ActivationRequestStatus.Completed;
|
|
379
380
|
completing.value = false;
|
|
@@ -381,28 +382,31 @@ function useActivationRequest(token, context) {
|
|
|
381
382
|
completionTimeout.value = setTimeout(checkCompletion, 1500);
|
|
382
383
|
}
|
|
383
384
|
};
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
385
|
+
watch2(() => toValue(token), async (newRequestId) => {
|
|
386
|
+
try {
|
|
387
|
+
if (newRequestId && newRequestId.length > 0) {
|
|
388
|
+
activationRequest.value = await storefront.client.activationRequests.get(newRequestId);
|
|
389
|
+
if (activationRequest.value.status === ActivationRequestStatus.Fulfilled) {
|
|
390
|
+
completing.value = true;
|
|
391
|
+
checkCompletion();
|
|
392
|
+
}
|
|
393
|
+
loading.value = false;
|
|
394
|
+
} else {
|
|
395
|
+
error.value = new MoonbaseError("Invalid input", "Missing request id", -1);
|
|
396
|
+
loading.value = false;
|
|
390
397
|
}
|
|
398
|
+
} catch (err) {
|
|
399
|
+
error.value = err;
|
|
391
400
|
loading.value = false;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
loading.value = false;
|
|
395
|
-
});
|
|
396
|
-
} else {
|
|
397
|
-
error.value = new Error("Missing request id");
|
|
398
|
-
loading.value = false;
|
|
399
|
-
}
|
|
401
|
+
}
|
|
402
|
+
}, { immediate: true });
|
|
400
403
|
onBeforeUnmount(() => {
|
|
401
404
|
if (completionTimeout.value)
|
|
402
405
|
clearTimeout(completionTimeout.value);
|
|
403
406
|
});
|
|
404
407
|
watch2(storefront.currentUser, async () => {
|
|
405
408
|
var _a, _b;
|
|
409
|
+
const requestId = toValue(token);
|
|
406
410
|
if (!requestId || ((_b = (_a = activationRequest.value) == null ? void 0 : _a.licenseEligibility) == null ? void 0 : _b.eligible))
|
|
407
411
|
return;
|
|
408
412
|
loading.value = true;
|
|
@@ -429,23 +433,22 @@ function useActivationRequest(token, context) {
|
|
|
429
433
|
}),
|
|
430
434
|
fulfillLicense: async () => {
|
|
431
435
|
fulfilling.value = true;
|
|
432
|
-
activationRequest.value = await storefront.client.activationRequests.fulfillLicense(
|
|
436
|
+
activationRequest.value = await storefront.client.activationRequests.fulfillLicense(activationRequest.value.id);
|
|
433
437
|
fulfilling.value = false;
|
|
434
438
|
completing.value = true;
|
|
435
439
|
const _ = checkCompletion();
|
|
436
440
|
},
|
|
437
441
|
fulfillTrial: async () => {
|
|
438
442
|
fulfilling.value = true;
|
|
439
|
-
activationRequest.value = await storefront.client.activationRequests.fulfillTrial(
|
|
443
|
+
activationRequest.value = await storefront.client.activationRequests.fulfillTrial(activationRequest.value.id);
|
|
440
444
|
fulfilling.value = false;
|
|
441
445
|
completing.value = true;
|
|
442
446
|
const _ = checkCompletion();
|
|
443
447
|
},
|
|
444
448
|
cancel: async () => {
|
|
445
|
-
|
|
446
|
-
if (((_a = activationRequest.value) == null ? void 0 : _a.status) === ActivationRequestStatus.Cancelled)
|
|
449
|
+
if (!activationRequest.value || activationRequest.value.status === ActivationRequestStatus.Cancelled)
|
|
447
450
|
return;
|
|
448
|
-
activationRequest.value = await storefront.client.activationRequests.cancel(
|
|
451
|
+
activationRequest.value = await storefront.client.activationRequests.cancel(activationRequest.value.id);
|
|
449
452
|
}
|
|
450
453
|
};
|
|
451
454
|
}
|
|
@@ -673,7 +676,7 @@ function useAuth(context) {
|
|
|
673
676
|
},
|
|
674
677
|
confirmEmailChange: async (email, code) => {
|
|
675
678
|
await storefront.client.identity.confirmEmailChange(email, code);
|
|
676
|
-
|
|
679
|
+
return await storefront.updateUser();
|
|
677
680
|
}
|
|
678
681
|
};
|
|
679
682
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbase.sh/vue",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.34",
|
|
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.
|
|
22
|
+
"@moonbase.sh/storefront-api": "0.2.34"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/uuid": "^9.0.8",
|