@scayle/storefront-nuxt 7.60.1 → 7.61.1
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/CHANGELOG.md +18 -0
- package/dist/module.json +1 -1
- package/dist/runtime/api/rpcHandler.mjs +2 -2
- package/dist/runtime/composables/core/useIDP.d.ts +3 -1
- package/dist/runtime/composables/core/useIDP.mjs +1 -0
- package/dist/runtime/composables/core/useSession.d.ts +5 -0
- package/dist/runtime/composables/core/useSession.mjs +2 -1
- package/dist/runtime/composables/storefront/useBasket.d.ts +14 -16
- package/dist/runtime/composables/storefront/useBasket.mjs +18 -7
- package/dist/runtime/composables/storefront/useWishlist.d.ts +11 -13
- package/dist/runtime/composables/storefront/useWishlist.mjs +18 -7
- package/dist/runtime/error/handler.d.ts +1 -1
- package/dist/runtime/handler.mjs +5 -15
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @scayle/storefront-nuxt
|
|
2
2
|
|
|
3
|
+
## 7.61.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- `useBasket` and `useWishlist` should no longer trigger duplicate requests when used in multiple components
|
|
8
|
+
|
|
9
|
+
## 7.61.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- Expose the `loginWithIDP` function from the `useSession` composable.
|
|
14
|
+
- Add error logging to RPC handler
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @scayle/storefront-core@7.44.0
|
|
20
|
+
|
|
3
21
|
## 7.60.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/module.json
CHANGED
|
@@ -11,7 +11,7 @@ export default defineEventHandler(async (event) => {
|
|
|
11
11
|
try {
|
|
12
12
|
return await handler(method, body?.payload, event.context.$rpcContext);
|
|
13
13
|
} catch (e) {
|
|
14
|
-
|
|
15
|
-
return createError(
|
|
14
|
+
event.context.$rpcContext.log.space("sfc").error(`RPC Handler failed: ${method}`, e);
|
|
15
|
+
return createError(resolveError(e));
|
|
16
16
|
}
|
|
17
17
|
});
|
|
@@ -6,7 +6,9 @@ export declare const useIDP: () => Promise<{
|
|
|
6
6
|
fetch: () => Promise<void>;
|
|
7
7
|
error: import("vue").Ref<import("nuxt/app").NuxtError<unknown> | undefined>;
|
|
8
8
|
status: import("vue").Ref<import("../core/useRpc").Status>;
|
|
9
|
-
handleIDPLoginCallback: (params:
|
|
9
|
+
handleIDPLoginCallback: (params: {
|
|
10
|
+
code: string;
|
|
11
|
+
}) => Promise<{
|
|
10
12
|
message: string;
|
|
11
13
|
}>;
|
|
12
14
|
}>;
|
|
@@ -14,4 +14,9 @@ export declare function useSession(): {
|
|
|
14
14
|
success: boolean;
|
|
15
15
|
}>;
|
|
16
16
|
resetPasswordByHash: (params: import("utility-types").Optional<import("@scayle/storefront-core").UpdatePasswordByHashRequest, "shop_id">) => Promise<void | undefined>;
|
|
17
|
+
loginWithIDP: (params: {
|
|
18
|
+
code: string;
|
|
19
|
+
}) => Promise<{
|
|
20
|
+
message: string;
|
|
21
|
+
}>;
|
|
17
22
|
};
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import type { AddOrUpdateItemType, RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
2
|
import { ExistingItemHandling } from '@scayle/storefront-core';
|
|
3
|
-
import type { RpcOptions } from '../core/useRpc';
|
|
4
3
|
import { type MaybeRefOrGetter } from '#imports';
|
|
5
4
|
type UseBasketOptions = Partial<{
|
|
6
5
|
params: MaybeRefOrGetter<RpcMethodParameters<'getBasket'>>;
|
|
7
|
-
options: RpcOptions;
|
|
8
6
|
key: string;
|
|
9
7
|
}>;
|
|
10
|
-
export declare function useBasket({ params,
|
|
11
|
-
data:
|
|
12
|
-
items: import("vue").ComputedRef<
|
|
13
|
-
cost: import("vue").ComputedRef<
|
|
14
|
-
key: import("vue").ComputedRef<
|
|
15
|
-
packages: import("vue").ComputedRef<
|
|
8
|
+
export declare function useBasket({ params, key, }?: UseBasketOptions): Promise<{
|
|
9
|
+
data: any;
|
|
10
|
+
items: import("vue").ComputedRef<any>;
|
|
11
|
+
cost: import("vue").ComputedRef<any>;
|
|
12
|
+
key: import("vue").ComputedRef<any>;
|
|
13
|
+
packages: import("vue").ComputedRef<any>;
|
|
16
14
|
shippingDates: import("vue").ComputedRef<(string | null)[] | undefined>;
|
|
17
15
|
isEmpty: import("vue").ComputedRef<boolean>;
|
|
18
|
-
fetching:
|
|
19
|
-
fetch:
|
|
20
|
-
count: import("vue").ComputedRef<
|
|
21
|
-
countWithoutSoldOutItems: import("vue").ComputedRef<
|
|
16
|
+
fetching: any;
|
|
17
|
+
fetch: any;
|
|
18
|
+
count: import("vue").ComputedRef<any>;
|
|
19
|
+
countWithoutSoldOutItems: import("vue").ComputedRef<any>;
|
|
22
20
|
addItem: ({ variantId, promotionId, quantity, existingItemHandling, displayData, customData, itemGroup, }: AddOrUpdateItemType & {
|
|
23
21
|
existingItemHandling?: 0 | 1 | 2 | 3 | undefined;
|
|
24
22
|
}) => Promise<void>;
|
|
@@ -32,12 +30,12 @@ export declare function useBasket({ params, options, key, }?: UseBasketOptions):
|
|
|
32
30
|
} | {
|
|
33
31
|
productId: number;
|
|
34
32
|
}) => boolean;
|
|
35
|
-
products: import("vue").ComputedRef<
|
|
33
|
+
products: import("vue").ComputedRef<any>;
|
|
36
34
|
findItem: (item: {
|
|
37
35
|
variantId: number;
|
|
38
36
|
} | {
|
|
39
37
|
productId: number;
|
|
40
|
-
}) =>
|
|
38
|
+
}) => any;
|
|
41
39
|
generateBasketKey: ({ keyTemplate, hashAlgorithm, shopId, userId, log, }: {
|
|
42
40
|
keyTemplate: string;
|
|
43
41
|
hashAlgorithm: import("@scayle/storefront-core").HashAlgorithm;
|
|
@@ -49,7 +47,7 @@ export declare function useBasket({ params, options, key, }?: UseBasketOptions):
|
|
|
49
47
|
fromBasketKey: string;
|
|
50
48
|
toBasketKey: string;
|
|
51
49
|
}) => Promise<any>;
|
|
52
|
-
error:
|
|
53
|
-
status:
|
|
50
|
+
error: any;
|
|
51
|
+
status: any;
|
|
54
52
|
}>;
|
|
55
53
|
export {};
|
|
@@ -10,9 +10,8 @@ import { useNuxtApp } from "nuxt/app";
|
|
|
10
10
|
import { computed } from "vue";
|
|
11
11
|
import { useEventListener } from "@vueuse/core";
|
|
12
12
|
import { rpcCall } from "../../rpc/rpcCall.mjs";
|
|
13
|
-
import { useRpc } from "../core/useRpc.mjs";
|
|
14
13
|
import { useCurrentShop } from "../core/useCurrentShop.mjs";
|
|
15
|
-
import { toValue } from "#imports";
|
|
14
|
+
import { toValue, toRef, useAsyncData } from "#imports";
|
|
16
15
|
const onCheckoutUpdate = async (event, fetching, fetchCallback) => {
|
|
17
16
|
if (fetching) {
|
|
18
17
|
return;
|
|
@@ -26,16 +25,28 @@ const onCheckoutUpdate = async (event, fetching, fetchCallback) => {
|
|
|
26
25
|
};
|
|
27
26
|
export async function useBasket({
|
|
28
27
|
params,
|
|
29
|
-
options,
|
|
30
28
|
key = "useBasket"
|
|
31
29
|
} = {}) {
|
|
32
30
|
const nuxtApp = useNuxtApp();
|
|
33
31
|
const shop = useCurrentShop();
|
|
34
|
-
const {
|
|
35
|
-
|
|
32
|
+
const {
|
|
33
|
+
data,
|
|
34
|
+
pending: fetching,
|
|
35
|
+
error,
|
|
36
|
+
refresh: fetch,
|
|
37
|
+
status
|
|
38
|
+
} = await useAsyncData(
|
|
36
39
|
key,
|
|
37
|
-
params,
|
|
38
|
-
|
|
40
|
+
() => rpcCall(nuxtApp, "getBasket", toValue(shop))(toValue(params)),
|
|
41
|
+
{
|
|
42
|
+
server: false,
|
|
43
|
+
// TODO: In some cases it might be ok to fetch on server
|
|
44
|
+
watch: [toRef(params)],
|
|
45
|
+
dedupe: "defer",
|
|
46
|
+
getCachedData: (key2) => {
|
|
47
|
+
return toValue(nuxtApp._asyncData[key2]?.data);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
39
50
|
);
|
|
40
51
|
useEventListener(
|
|
41
52
|
"message",
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { RpcOptions } from '../core/useRpc';
|
|
1
|
+
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
3
2
|
import type { MaybeRefOrGetter } from '#imports';
|
|
4
3
|
type Options = Partial<{
|
|
5
4
|
params: MaybeRefOrGetter<RpcMethodParameters<'getWishlist'>>;
|
|
6
|
-
options: RpcOptions;
|
|
7
5
|
key: string;
|
|
8
6
|
}>;
|
|
9
|
-
export declare function useWishlist({ params,
|
|
10
|
-
data:
|
|
11
|
-
count: import("vue").ComputedRef<
|
|
12
|
-
items: import("vue").ComputedRef<
|
|
13
|
-
products: import("vue").ComputedRef<
|
|
7
|
+
export declare function useWishlist({ params, key, }?: Options): Promise<{
|
|
8
|
+
data: any;
|
|
9
|
+
count: import("vue").ComputedRef<any>;
|
|
10
|
+
items: import("vue").ComputedRef<any>;
|
|
11
|
+
products: import("vue").ComputedRef<any>;
|
|
14
12
|
addItem: (item: {
|
|
15
13
|
variantId?: number;
|
|
16
14
|
productId?: number;
|
|
@@ -27,8 +25,8 @@ export declare function useWishlist({ params, options, key, }?: Options): Promis
|
|
|
27
25
|
productId?: number;
|
|
28
26
|
}) => Promise<void>;
|
|
29
27
|
clear: () => Promise<void>;
|
|
30
|
-
fetching:
|
|
31
|
-
fetch:
|
|
28
|
+
fetching: any;
|
|
29
|
+
fetch: any;
|
|
32
30
|
toggleItem: (item: {
|
|
33
31
|
variantId?: number;
|
|
34
32
|
productId?: number;
|
|
@@ -36,13 +34,13 @@ export declare function useWishlist({ params, options, key, }?: Options): Promis
|
|
|
36
34
|
findItem: (item: {
|
|
37
35
|
variantId?: number;
|
|
38
36
|
productId?: number;
|
|
39
|
-
}) =>
|
|
37
|
+
}) => any;
|
|
40
38
|
contains: (item: {
|
|
41
39
|
variantId: number;
|
|
42
40
|
} | {
|
|
43
41
|
productId: number;
|
|
44
42
|
}) => boolean;
|
|
45
|
-
error:
|
|
46
|
-
status:
|
|
43
|
+
error: any;
|
|
44
|
+
status: any;
|
|
47
45
|
}>;
|
|
48
46
|
export {};
|
|
@@ -7,20 +7,31 @@ import { useNuxtApp } from "nuxt/app";
|
|
|
7
7
|
import { computed } from "vue";
|
|
8
8
|
import { rpcCall } from "../../rpc/rpcCall.mjs";
|
|
9
9
|
import { useCurrentShop } from "../core/useCurrentShop.mjs";
|
|
10
|
-
import {
|
|
11
|
-
import { toValue } from "#imports";
|
|
10
|
+
import { toValue, toRef, useAsyncData } from "#imports";
|
|
12
11
|
export async function useWishlist({
|
|
13
12
|
params,
|
|
14
|
-
options,
|
|
15
13
|
key = "useWishlist"
|
|
16
14
|
} = {}) {
|
|
17
15
|
const nuxtApp = useNuxtApp();
|
|
18
16
|
const shop = useCurrentShop();
|
|
19
|
-
const {
|
|
20
|
-
|
|
17
|
+
const {
|
|
18
|
+
data,
|
|
19
|
+
pending: fetching,
|
|
20
|
+
error,
|
|
21
|
+
refresh: fetch,
|
|
22
|
+
status
|
|
23
|
+
} = await useAsyncData(
|
|
21
24
|
key,
|
|
22
|
-
params,
|
|
23
|
-
|
|
25
|
+
() => rpcCall(nuxtApp, "getWishlist", toValue(shop))(toValue(params)),
|
|
26
|
+
{
|
|
27
|
+
server: false,
|
|
28
|
+
// TODO: In some cases it might be ok to fetch on server
|
|
29
|
+
watch: [toRef(params)],
|
|
30
|
+
dedupe: "defer",
|
|
31
|
+
getCachedData: (key2) => {
|
|
32
|
+
return toValue(nuxtApp._asyncData[key2]?.data);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
24
35
|
);
|
|
25
36
|
const addItem = async (item) => {
|
|
26
37
|
data.value = await rpcCall(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare const resolveError: (error: Error | unknown) => {
|
|
2
|
-
statusCode:
|
|
2
|
+
statusCode: 401 | 500 | 400 | 100 | 101 | 102 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 426 | 428 | 429 | 431 | 451 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
|
|
3
3
|
statusMessage: string;
|
|
4
4
|
name: string;
|
|
5
5
|
};
|
package/dist/runtime/handler.mjs
CHANGED
|
@@ -11,24 +11,14 @@ export const handler = async (method, payload, rpcContext) => {
|
|
|
11
11
|
const log = rpcContext.log.space("sfc").space("rpc");
|
|
12
12
|
return await log.time(`Calling RPC method: ${method}`, async () => {
|
|
13
13
|
const fun = rpcMethods[method];
|
|
14
|
-
|
|
15
|
-
if (fun.length === 1) {
|
|
16
|
-
return await fun(
|
|
17
|
-
rpcContext
|
|
18
|
-
);
|
|
19
|
-
}
|
|
14
|
+
if (fun.length === 1) {
|
|
20
15
|
return await fun(
|
|
21
|
-
payload,
|
|
22
16
|
rpcContext
|
|
23
17
|
);
|
|
24
|
-
} catch (e) {
|
|
25
|
-
if (e instanceof Error) {
|
|
26
|
-
return new Response(JSON.stringify({ message: e.message }), {
|
|
27
|
-
status: 500
|
|
28
|
-
});
|
|
29
|
-
} else {
|
|
30
|
-
return new Response(null, { status: 500 });
|
|
31
|
-
}
|
|
32
18
|
}
|
|
19
|
+
return await fun(
|
|
20
|
+
payload,
|
|
21
|
+
rpcContext
|
|
22
|
+
);
|
|
33
23
|
});
|
|
34
24
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.61.1",
|
|
5
5
|
"description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
|
|
6
6
|
"author": "SCAYLE Commerce Engine",
|
|
7
7
|
"license": "MIT",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@nuxt/kit": "3.10.2",
|
|
64
64
|
"@scayle/h3-session": "0.3.5",
|
|
65
|
-
"@scayle/storefront-core": "7.
|
|
65
|
+
"@scayle/storefront-core": "7.44.0",
|
|
66
66
|
"@scayle/unstorage-compression-driver": "0.1.2",
|
|
67
67
|
"@vueuse/core": "10.9.0",
|
|
68
68
|
"consola": "3.2.3",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"@nuxt/test-utils": "3.11.0",
|
|
85
85
|
"@scayle/eslint-config-storefront": "3.2.6",
|
|
86
86
|
"@scayle/prettier-config-storefront": "2.0.2",
|
|
87
|
-
"@types/node": "20.11.
|
|
87
|
+
"@types/node": "20.11.25",
|
|
88
88
|
"eslint": "8.57.0",
|
|
89
89
|
"eslint-formatter-gitlab": "5.1.0",
|
|
90
90
|
"h3": "1.11.1",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"prettier": "3.0.0",
|
|
94
94
|
"publint": "0.2.7",
|
|
95
95
|
"vitest": "1.3.1",
|
|
96
|
-
"vue-tsc": "
|
|
96
|
+
"vue-tsc": "2.0.6"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
99
|
"h3": "^1.10.0",
|