@scayle/storefront-nuxt 7.61.0 → 7.61.2
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 +15 -0
- package/dist/module.json +1 -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 +10 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @scayle/storefront-nuxt
|
|
2
2
|
|
|
3
|
+
## 7.61.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated to `vue@3.4.21` (For more details check the [Vue 3.4.21 Changelog](https://github.com/vuejs/core/blob/main/CHANGELOG.md#3421-2024-02-28)
|
|
8
|
+
- Updated to `nuxt@3.10.3` (For more details check the [Nuxt 3.10.3 Release Notes](https://github.com/nuxt/nuxt/releases/tag/v3.10.3))
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
- @scayle/storefront-core@7.44.1
|
|
11
|
+
|
|
12
|
+
## 7.61.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- `useBasket` and `useWishlist` should no longer trigger duplicate requests when used in multiple components
|
|
17
|
+
|
|
3
18
|
## 7.61.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
package/dist/module.json
CHANGED
|
@@ -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.61.
|
|
4
|
+
"version": "7.61.2",
|
|
5
5
|
"description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
|
|
6
6
|
"author": "SCAYLE Commerce Engine",
|
|
7
7
|
"license": "MIT",
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"test:watch": "vitest watch"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@nuxt/kit": "3.10.
|
|
63
|
+
"@nuxt/kit": "3.10.3",
|
|
64
64
|
"@scayle/h3-session": "0.3.5",
|
|
65
|
-
"@scayle/storefront-core": "7.44.
|
|
65
|
+
"@scayle/storefront-core": "7.44.1",
|
|
66
66
|
"@scayle/unstorage-compression-driver": "0.1.2",
|
|
67
67
|
"@vueuse/core": "10.9.0",
|
|
68
68
|
"consola": "3.2.3",
|
|
@@ -80,20 +80,20 @@
|
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
82
|
"@nuxt/module-builder": "0.5.5",
|
|
83
|
-
"@nuxt/schema": "3.10.
|
|
83
|
+
"@nuxt/schema": "3.10.3",
|
|
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",
|
|
91
91
|
"node-mocks-http": "1.14.1",
|
|
92
|
-
"nuxt": "3.10.
|
|
92
|
+
"nuxt": "3.10.3",
|
|
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",
|
|
@@ -103,17 +103,9 @@
|
|
|
103
103
|
},
|
|
104
104
|
"resolutions": {
|
|
105
105
|
"h3": "1.11.1",
|
|
106
|
-
"
|
|
107
|
-
"@
|
|
108
|
-
"@
|
|
109
|
-
"@vue/compiler-sfc": "3.4.19",
|
|
110
|
-
"@vue/compiler-ssr": "3.4.19",
|
|
111
|
-
"@vue/reactivity": "3.4.19",
|
|
112
|
-
"@vue/runtime-core": "3.4.19",
|
|
113
|
-
"@vue/runtime-dom": "3.4.19",
|
|
114
|
-
"@vue/server-renderer": "3.4.19",
|
|
115
|
-
"@nuxt/kit": "3.10.2",
|
|
116
|
-
"@nuxt/schema": "3.10.2"
|
|
106
|
+
"vue": "3.4.21",
|
|
107
|
+
"@nuxt/kit": "3.10.3",
|
|
108
|
+
"@nuxt/schema": "3.10.3"
|
|
117
109
|
},
|
|
118
110
|
"volta": {
|
|
119
111
|
"node": "20.11.1"
|