@scayle/storefront-nuxt 7.74.0 → 7.75.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 +50 -1
- package/dist/index.d.mts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.mjs +15 -0
- package/dist/module.d.mts +2 -2
- package/dist/module.d.ts +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +32 -1
- package/dist/rpc.d.mts +1 -1
- package/dist/rpc.d.ts +1 -1
- package/dist/runtime/composables/core/useIDP.d.ts +5 -5
- package/dist/runtime/composables/core/useIDP.mjs +2 -2
- package/dist/runtime/composables/core/useRpc.d.ts +38 -9
- package/dist/runtime/composables/core/useRpc.mjs +29 -49
- package/dist/runtime/composables/core/useUser.d.ts +21 -6
- package/dist/runtime/composables/core/useUser.mjs +26 -10
- package/dist/runtime/composables/storefront/useBasket.d.ts +69 -8
- package/dist/runtime/composables/storefront/useBasket.mjs +16 -18
- package/dist/runtime/composables/storefront/useBrand.d.ts +4 -9
- package/dist/runtime/composables/storefront/useBrand.mjs +5 -12
- package/dist/runtime/composables/storefront/useBrands.d.ts +4 -9
- package/dist/runtime/composables/storefront/useBrands.mjs +5 -12
- package/dist/runtime/composables/storefront/useCategories.d.ts +23 -13
- package/dist/runtime/composables/storefront/useCategories.mjs +8 -12
- package/dist/runtime/composables/storefront/useCategoryById.d.ts +4 -9
- package/dist/runtime/composables/storefront/useCategoryById.mjs +5 -12
- package/dist/runtime/composables/storefront/useCategoryByPath.d.ts +4 -9
- package/dist/runtime/composables/storefront/useCategoryByPath.mjs +5 -12
- package/dist/runtime/composables/storefront/useCurrentPromotions.d.ts +4 -9
- package/dist/runtime/composables/storefront/useCurrentPromotions.mjs +5 -12
- package/dist/runtime/composables/storefront/useFacet.d.ts +60 -15
- package/dist/runtime/composables/storefront/useFacet.mjs +117 -110
- package/dist/runtime/composables/storefront/useFilters.d.ts +4 -12
- package/dist/runtime/composables/storefront/useFilters.mjs +5 -12
- package/dist/runtime/composables/storefront/useNavigationTree.d.ts +4 -9
- package/dist/runtime/composables/storefront/useNavigationTree.mjs +5 -12
- package/dist/runtime/composables/storefront/useNavigationTrees.d.ts +4 -9
- package/dist/runtime/composables/storefront/useNavigationTrees.mjs +5 -12
- package/dist/runtime/composables/storefront/useOrder.d.ts +6 -5
- package/dist/runtime/composables/storefront/useOrder.mjs +2 -2
- package/dist/runtime/composables/storefront/useOrderConfirmation.d.ts +6 -5
- package/dist/runtime/composables/storefront/useOrderConfirmation.mjs +2 -2
- package/dist/runtime/composables/storefront/useProduct.d.ts +4 -9
- package/dist/runtime/composables/storefront/useProduct.mjs +5 -12
- package/dist/runtime/composables/storefront/useProducts.d.ts +4 -21
- package/dist/runtime/composables/storefront/useProducts.mjs +5 -12
- package/dist/runtime/composables/storefront/useProductsByIds.d.ts +4 -9
- package/dist/runtime/composables/storefront/useProductsByIds.mjs +5 -12
- package/dist/runtime/composables/storefront/useProductsByReferenceKeys.d.ts +4 -9
- package/dist/runtime/composables/storefront/useProductsByReferenceKeys.mjs +5 -12
- package/dist/runtime/composables/storefront/useProductsCount.d.ts +4 -11
- package/dist/runtime/composables/storefront/useProductsCount.mjs +5 -12
- package/dist/runtime/composables/storefront/usePromotions.d.ts +4 -9
- package/dist/runtime/composables/storefront/usePromotions.mjs +5 -12
- package/dist/runtime/composables/storefront/usePromotionsByIds.d.ts +4 -9
- package/dist/runtime/composables/storefront/usePromotionsByIds.mjs +5 -12
- package/dist/runtime/composables/storefront/useShopConfiguration.d.ts +4 -9
- package/dist/runtime/composables/storefront/useShopConfiguration.mjs +5 -12
- package/dist/runtime/composables/storefront/useUserAddresses.d.ts +4 -9
- package/dist/runtime/composables/storefront/useUserAddresses.mjs +5 -12
- package/dist/runtime/composables/storefront/useVariant.d.ts +4 -9
- package/dist/runtime/composables/storefront/useVariant.mjs +5 -12
- package/dist/runtime/composables/storefront/useWishlist.d.ts +42 -4
- package/dist/runtime/composables/storefront/useWishlist.mjs +17 -14
- package/dist/runtime/log.mjs +1 -1
- package/dist/runtime/utils/promise.d.ts +9 -0
- package/dist/runtime/utils/promise.mjs +12 -0
- package/dist/runtime/utils/zodSchema.d.ts +22 -22
- package/dist/runtime/utils/zodSchema.mjs +4 -4
- package/dist/shared/{storefront-nuxt.db7a2f93.d.mts → storefront-nuxt.257df9a6.d.mts} +8 -8
- package/dist/shared/{storefront-nuxt.db7a2f93.d.ts → storefront-nuxt.257df9a6.d.ts} +8 -8
- package/package.json +2 -2
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { type RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
|
-
import { type
|
|
2
|
+
import { type UseRpcOptions, type UseRpcReturn } from '../core/useRpc';
|
|
3
3
|
import { type MaybeRefOrGetter } from '#imports';
|
|
4
4
|
type Options = Partial<{
|
|
5
5
|
params: MaybeRefOrGetter<RpcMethodParameters<'getProductsByReferenceKeys'>>;
|
|
6
|
-
options:
|
|
6
|
+
options: UseRpcOptions<'getProductsByReferenceKeys'>;
|
|
7
|
+
/** @deprecated use the second argument of the composable to define the key */
|
|
7
8
|
key: string;
|
|
8
9
|
}>;
|
|
9
|
-
export declare function useProductsByReferenceKeys({ params, options, key, }?: Options):
|
|
10
|
-
data: import("vue").Ref<import("@scayle/storefront-api").Product[] | undefined>;
|
|
11
|
-
fetching: import("vue").Ref<boolean>;
|
|
12
|
-
fetch: () => Promise<void>;
|
|
13
|
-
error: import("vue").Ref<import("nuxt/app").NuxtError<unknown> | undefined>;
|
|
14
|
-
status: import("vue").Ref<import("../core/useRpc").Status>;
|
|
15
|
-
}>;
|
|
10
|
+
export declare function useProductsByReferenceKeys({ params, options, key: _key, }?: Options, key?: string): UseRpcReturn<'getProductsByReferenceKeys'>;
|
|
16
11
|
export {};
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
import { useRpc } from "../core/useRpc.mjs";
|
|
2
|
-
export
|
|
2
|
+
export function useProductsByReferenceKeys({
|
|
3
3
|
params,
|
|
4
4
|
options,
|
|
5
|
-
key
|
|
6
|
-
} = {}) {
|
|
7
|
-
|
|
5
|
+
key: _key
|
|
6
|
+
} = {}, key) {
|
|
7
|
+
return useRpc(
|
|
8
8
|
"getProductsByReferenceKeys",
|
|
9
|
-
key,
|
|
9
|
+
_key ?? key ?? "useProductsByReferenceKeys",
|
|
10
10
|
params,
|
|
11
11
|
options
|
|
12
12
|
);
|
|
13
|
-
return {
|
|
14
|
-
data,
|
|
15
|
-
fetching,
|
|
16
|
-
fetch,
|
|
17
|
-
error,
|
|
18
|
-
status
|
|
19
|
-
};
|
|
20
13
|
}
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
|
-
import type {
|
|
2
|
+
import type { UseRpcOptions, UseRpcReturn } from '../core/useRpc';
|
|
3
3
|
import type { MaybeRefOrGetter } from '#imports';
|
|
4
4
|
type Options = Partial<{
|
|
5
5
|
params: MaybeRefOrGetter<RpcMethodParameters<'getProductsCount'>>;
|
|
6
|
-
options:
|
|
6
|
+
options: UseRpcOptions<'getProductsCount'>;
|
|
7
|
+
/** @deprecated use the second argument of the composable to define the key */
|
|
7
8
|
key: string;
|
|
8
9
|
}>;
|
|
9
|
-
export declare function useProductsCount({ params, options, key, }?: Options):
|
|
10
|
-
data: import("vue").Ref<{
|
|
11
|
-
count: number;
|
|
12
|
-
} | undefined>;
|
|
13
|
-
fetching: import("vue").Ref<boolean>;
|
|
14
|
-
fetch: () => Promise<void>;
|
|
15
|
-
error: import("vue").Ref<import("nuxt/app").NuxtError<unknown> | undefined>;
|
|
16
|
-
status: import("vue").Ref<import("../core/useRpc").Status>;
|
|
17
|
-
}>;
|
|
10
|
+
export declare function useProductsCount({ params, options, key: _key, }?: Options, key?: string): UseRpcReturn<'getProductsCount'>;
|
|
18
11
|
export {};
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
import { useRpc } from "../core/useRpc.mjs";
|
|
2
|
-
export
|
|
2
|
+
export function useProductsCount({
|
|
3
3
|
params,
|
|
4
4
|
options,
|
|
5
|
-
key
|
|
6
|
-
} = {}) {
|
|
7
|
-
|
|
5
|
+
key: _key
|
|
6
|
+
} = {}, key) {
|
|
7
|
+
return useRpc(
|
|
8
8
|
"getProductsCount",
|
|
9
|
-
key,
|
|
9
|
+
_key ?? key ?? "useProductsCount",
|
|
10
10
|
params,
|
|
11
11
|
options
|
|
12
12
|
);
|
|
13
|
-
return {
|
|
14
|
-
data,
|
|
15
|
-
fetching,
|
|
16
|
-
fetch,
|
|
17
|
-
error,
|
|
18
|
-
status
|
|
19
|
-
};
|
|
20
13
|
}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { type RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
|
-
import { type
|
|
2
|
+
import { type UseRpcOptions, type UseRpcReturn } from '../core/useRpc';
|
|
3
3
|
import { type MaybeRefOrGetter } from '#imports';
|
|
4
4
|
type Options = Partial<{
|
|
5
5
|
params: MaybeRefOrGetter<RpcMethodParameters<'getPromotions'>>;
|
|
6
|
-
options:
|
|
6
|
+
options: UseRpcOptions<'getPromotions'>;
|
|
7
|
+
/** @deprecated use the second argument of the composable to define the key */
|
|
7
8
|
key: string;
|
|
8
9
|
}>;
|
|
9
|
-
export declare function usePromotions({ params, options, key, }?: Options):
|
|
10
|
-
data: import("vue").Ref<import("@scayle/storefront-api").PromotionsEndpointResponseData | undefined>;
|
|
11
|
-
fetching: import("vue").Ref<boolean>;
|
|
12
|
-
fetch: () => Promise<void>;
|
|
13
|
-
error: import("vue").Ref<import("nuxt/app").NuxtError<unknown> | undefined>;
|
|
14
|
-
status: import("vue").Ref<import("../core/useRpc").Status>;
|
|
15
|
-
}>;
|
|
10
|
+
export declare function usePromotions({ params, options, key: _key, }?: Options, key?: string): UseRpcReturn<'getPromotions'>;
|
|
16
11
|
export {};
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
import { useRpc } from "../core/useRpc.mjs";
|
|
2
|
-
export
|
|
2
|
+
export function usePromotions({
|
|
3
3
|
params,
|
|
4
4
|
options,
|
|
5
|
-
key
|
|
6
|
-
} = {}) {
|
|
7
|
-
|
|
5
|
+
key: _key
|
|
6
|
+
} = {}, key) {
|
|
7
|
+
return useRpc(
|
|
8
8
|
"getPromotions",
|
|
9
|
-
key,
|
|
9
|
+
_key ?? key ?? "usePromotions",
|
|
10
10
|
params,
|
|
11
11
|
options
|
|
12
12
|
);
|
|
13
|
-
return {
|
|
14
|
-
data,
|
|
15
|
-
fetching,
|
|
16
|
-
fetch,
|
|
17
|
-
error,
|
|
18
|
-
status
|
|
19
|
-
};
|
|
20
13
|
}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { type RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
|
-
import { type
|
|
2
|
+
import { type UseRpcOptions, type UseRpcReturn } from '../core/useRpc';
|
|
3
3
|
import { type MaybeRefOrGetter } from '#imports';
|
|
4
4
|
type Options = Partial<{
|
|
5
5
|
params: MaybeRefOrGetter<RpcMethodParameters<'getPromotionsByIds'>>;
|
|
6
|
-
options:
|
|
6
|
+
options: UseRpcOptions<'getPromotionsByIds'>;
|
|
7
|
+
/** @deprecated use the second argument of the composable to define the key */
|
|
7
8
|
key: string;
|
|
8
9
|
}>;
|
|
9
|
-
export declare function usePromotionsByIds({ params, options, key, }?: Options):
|
|
10
|
-
data: import("vue").Ref<import("@scayle/storefront-api").PromotionsEndpointResponseData | undefined>;
|
|
11
|
-
fetching: import("vue").Ref<boolean>;
|
|
12
|
-
fetch: () => Promise<void>;
|
|
13
|
-
error: import("vue").Ref<import("nuxt/app").NuxtError<unknown> | undefined>;
|
|
14
|
-
status: import("vue").Ref<import("../core/useRpc").Status>;
|
|
15
|
-
}>;
|
|
10
|
+
export declare function usePromotionsByIds({ params, options, key: _key, }?: Options, key?: string): UseRpcReturn<'getPromotionsByIds'>;
|
|
16
11
|
export {};
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
import { useRpc } from "../core/useRpc.mjs";
|
|
2
|
-
export
|
|
2
|
+
export function usePromotionsByIds({
|
|
3
3
|
params,
|
|
4
4
|
options,
|
|
5
|
-
key
|
|
6
|
-
} = {}) {
|
|
7
|
-
|
|
5
|
+
key: _key
|
|
6
|
+
} = {}, key) {
|
|
7
|
+
return useRpc(
|
|
8
8
|
"getPromotionsByIds",
|
|
9
|
-
key,
|
|
9
|
+
_key ?? key ?? "usePromotionsByIds",
|
|
10
10
|
params,
|
|
11
11
|
options
|
|
12
12
|
);
|
|
13
|
-
return {
|
|
14
|
-
data,
|
|
15
|
-
fetching,
|
|
16
|
-
fetch,
|
|
17
|
-
error,
|
|
18
|
-
status
|
|
19
|
-
};
|
|
20
13
|
}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { UseRpcOptions, UseRpcReturn } from '../core/useRpc';
|
|
2
2
|
type Options = Partial<{
|
|
3
|
-
options:
|
|
3
|
+
options: UseRpcOptions<'getShopConfiguration'>;
|
|
4
|
+
/** @deprecated use the second argument of the composable to define the key */
|
|
4
5
|
key: string;
|
|
5
6
|
}>;
|
|
6
|
-
export declare function useShopConfiguration({ options, key, }?: Options):
|
|
7
|
-
data: import("vue").Ref<import("@scayle/storefront-api").ShopConfiguration | undefined>;
|
|
8
|
-
fetching: import("vue").Ref<boolean>;
|
|
9
|
-
fetch: () => Promise<void>;
|
|
10
|
-
error: import("vue").Ref<import("nuxt/app").NuxtError<unknown> | undefined>;
|
|
11
|
-
status: import("vue").Ref<import("../core/useRpc").Status>;
|
|
12
|
-
}>;
|
|
7
|
+
export declare function useShopConfiguration({ options, key: _key, }?: Options, key?: string): UseRpcReturn<'getShopConfiguration'>;
|
|
13
8
|
export {};
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import { useRpc } from "../core/useRpc.mjs";
|
|
2
|
-
export
|
|
2
|
+
export function useShopConfiguration({
|
|
3
3
|
options,
|
|
4
|
-
key
|
|
5
|
-
} = {}) {
|
|
6
|
-
|
|
4
|
+
key: _key
|
|
5
|
+
} = {}, key) {
|
|
6
|
+
return useRpc(
|
|
7
7
|
"getShopConfiguration",
|
|
8
|
-
key,
|
|
8
|
+
_key ?? key ?? "useShopConfiguration",
|
|
9
9
|
void 0,
|
|
10
10
|
options
|
|
11
11
|
);
|
|
12
|
-
return {
|
|
13
|
-
data,
|
|
14
|
-
fetching,
|
|
15
|
-
fetch,
|
|
16
|
-
error,
|
|
17
|
-
status
|
|
18
|
-
};
|
|
19
12
|
}
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { UseRpcOptions, UseRpcReturn } from '../core/useRpc';
|
|
2
2
|
type Options = Partial<{
|
|
3
|
-
options:
|
|
3
|
+
options: UseRpcOptions<'getShopUserAddresses'>;
|
|
4
|
+
/** @deprecated use the second argument of the composable to define the key */
|
|
4
5
|
key: string;
|
|
5
6
|
}>;
|
|
6
|
-
export declare function useUserAddresses({ options, key, }?: Options):
|
|
7
|
-
data: import("vue").Ref<import("@scayle/storefront-core").ShopUserAddress[] | undefined>;
|
|
8
|
-
fetching: import("vue").Ref<boolean>;
|
|
9
|
-
fetch: () => Promise<void>;
|
|
10
|
-
error: import("vue").Ref<import("nuxt/app").NuxtError<unknown> | undefined>;
|
|
11
|
-
status: import("vue").Ref<import("../core/useRpc").Status>;
|
|
12
|
-
}>;
|
|
7
|
+
export declare function useUserAddresses({ options, key: _key, }?: Options, key?: string): UseRpcReturn<'getShopUserAddresses'>;
|
|
13
8
|
export {};
|
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import { useRpc } from "../core/useRpc.mjs";
|
|
2
|
-
export
|
|
2
|
+
export function useUserAddresses({
|
|
3
3
|
options,
|
|
4
|
-
key
|
|
5
|
-
} = {}) {
|
|
6
|
-
|
|
4
|
+
key: _key
|
|
5
|
+
} = {}, key) {
|
|
6
|
+
return useRpc(
|
|
7
7
|
"getShopUserAddresses",
|
|
8
|
-
key,
|
|
8
|
+
_key ?? key ?? "useUserAddresses",
|
|
9
9
|
void 0,
|
|
10
10
|
options
|
|
11
11
|
);
|
|
12
|
-
return {
|
|
13
|
-
data,
|
|
14
|
-
fetching,
|
|
15
|
-
fetch,
|
|
16
|
-
error,
|
|
17
|
-
status
|
|
18
|
-
};
|
|
19
12
|
}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { type RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
|
-
import { type
|
|
2
|
+
import { type UseRpcOptions, type UseRpcReturn } from '../core/useRpc';
|
|
3
3
|
import { type MaybeRefOrGetter } from '#imports';
|
|
4
4
|
type Options = Partial<{
|
|
5
5
|
params: MaybeRefOrGetter<RpcMethodParameters<'getVariantById'>>;
|
|
6
|
-
options:
|
|
6
|
+
options: UseRpcOptions<'getVariantById'>;
|
|
7
|
+
/** @deprecated use the second argument of the composable to define the key */
|
|
7
8
|
key: string;
|
|
8
9
|
}>;
|
|
9
|
-
export declare function useVariant({ params, options, key, }?: Options):
|
|
10
|
-
data: import("vue").Ref<import("@scayle/storefront-api").VariantDetail[] | undefined>;
|
|
11
|
-
fetching: import("vue").Ref<boolean>;
|
|
12
|
-
fetch: () => Promise<void>;
|
|
13
|
-
error: import("vue").Ref<import("nuxt/app").NuxtError<unknown> | undefined>;
|
|
14
|
-
status: import("vue").Ref<import("../core/useRpc").Status>;
|
|
15
|
-
}>;
|
|
10
|
+
export declare function useVariant({ params, options, key: _key, }?: Options, key?: string): UseRpcReturn<'getVariantById'>;
|
|
16
11
|
export {};
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
import { useRpc } from "../core/useRpc.mjs";
|
|
2
|
-
export
|
|
2
|
+
export function useVariant({
|
|
3
3
|
params,
|
|
4
4
|
options,
|
|
5
|
-
key
|
|
6
|
-
} = {}) {
|
|
7
|
-
|
|
5
|
+
key: _key
|
|
6
|
+
} = {}, key) {
|
|
7
|
+
return useRpc(
|
|
8
8
|
"getVariantById",
|
|
9
|
-
key,
|
|
9
|
+
_key ?? key ?? "useVariant",
|
|
10
10
|
params,
|
|
11
11
|
options
|
|
12
12
|
);
|
|
13
|
-
return {
|
|
14
|
-
data,
|
|
15
|
-
fetching,
|
|
16
|
-
fetch,
|
|
17
|
-
error,
|
|
18
|
-
status
|
|
19
|
-
};
|
|
20
13
|
}
|
|
@@ -4,10 +4,48 @@ type Options = Partial<{
|
|
|
4
4
|
params: MaybeRefOrGetter<RpcMethodParameters<'getWishlist'>>;
|
|
5
5
|
key: string;
|
|
6
6
|
}>;
|
|
7
|
-
export declare function useWishlist({ params, key, }?: Options):
|
|
8
|
-
data: import("vue").Ref<WishlistResponseData
|
|
9
|
-
count: import("vue").ComputedRef<number
|
|
10
|
-
items: import("vue").ComputedRef<WishlistItem[]
|
|
7
|
+
export declare function useWishlist({ params, key, }?: Options): {
|
|
8
|
+
data: import("vue").Ref<WishlistResponseData>;
|
|
9
|
+
count: import("vue").ComputedRef<number>;
|
|
10
|
+
items: import("vue").ComputedRef<WishlistItem[]>;
|
|
11
|
+
products: import("vue").ComputedRef<Product[]>;
|
|
12
|
+
addItem: (item: {
|
|
13
|
+
variantId?: number;
|
|
14
|
+
productId?: number;
|
|
15
|
+
}) => Promise<void>;
|
|
16
|
+
removeItem: (item: {
|
|
17
|
+
variantId?: number;
|
|
18
|
+
productId?: number;
|
|
19
|
+
}) => Promise<void>;
|
|
20
|
+
replaceItem: (item: {
|
|
21
|
+
variantId?: number;
|
|
22
|
+
productId?: number;
|
|
23
|
+
}, newItem: {
|
|
24
|
+
variantId?: number;
|
|
25
|
+
productId?: number;
|
|
26
|
+
}) => Promise<void>;
|
|
27
|
+
clear: () => Promise<void>;
|
|
28
|
+
fetching: import("vue").Ref<boolean>;
|
|
29
|
+
fetch: (opts?: import("nuxt/dist/app/composables/asyncData").AsyncDataExecuteOptions | undefined) => Promise<void>;
|
|
30
|
+
toggleItem: (item: {
|
|
31
|
+
variantId?: number;
|
|
32
|
+
productId?: number;
|
|
33
|
+
}) => Promise<void>;
|
|
34
|
+
findItem: (item: {
|
|
35
|
+
variantId?: number;
|
|
36
|
+
productId?: number;
|
|
37
|
+
}) => WishlistItem | undefined;
|
|
38
|
+
contains: (item: {
|
|
39
|
+
variantId: number;
|
|
40
|
+
} | {
|
|
41
|
+
productId: number;
|
|
42
|
+
}) => boolean;
|
|
43
|
+
error: import("vue").Ref<import("nuxt/app").NuxtError<unknown> | null>;
|
|
44
|
+
status: import("vue").Ref<import("nuxt/app").AsyncDataRequestStatus>;
|
|
45
|
+
} & Promise<{
|
|
46
|
+
data: import("vue").Ref<WishlistResponseData>;
|
|
47
|
+
count: import("vue").ComputedRef<number>;
|
|
48
|
+
items: import("vue").ComputedRef<WishlistItem[]>;
|
|
11
49
|
products: import("vue").ComputedRef<Product[]>;
|
|
12
50
|
addItem: (item: {
|
|
13
51
|
variantId?: number;
|
|
@@ -3,26 +3,23 @@ import {
|
|
|
3
3
|
HttpStatusMessage,
|
|
4
4
|
HttpStatusCode
|
|
5
5
|
} from "@scayle/storefront-core";
|
|
6
|
-
import { useNuxtApp
|
|
6
|
+
import { useNuxtApp } from "nuxt/app";
|
|
7
7
|
import { computed } from "vue";
|
|
8
8
|
import { rpcCall } from "../../rpc/rpcCall.mjs";
|
|
9
|
+
import { useRpc } from "../core/useRpc.mjs";
|
|
10
|
+
import { extendPromise } from "../../utils/promise.mjs";
|
|
9
11
|
import { useCurrentShop } from "../core/useCurrentShop.mjs";
|
|
10
12
|
import { toValue, toRef } from "#imports";
|
|
11
|
-
export
|
|
13
|
+
export function useWishlist({
|
|
12
14
|
params,
|
|
13
15
|
key = "useWishlist"
|
|
14
16
|
} = {}) {
|
|
15
17
|
const nuxtApp = useNuxtApp();
|
|
16
18
|
const shop = useCurrentShop();
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
pending: fetching,
|
|
20
|
-
error,
|
|
21
|
-
refresh: fetch,
|
|
22
|
-
status
|
|
23
|
-
} = await useAsyncData(
|
|
19
|
+
const asyncData = useRpc(
|
|
20
|
+
"getWishlist",
|
|
24
21
|
key,
|
|
25
|
-
|
|
22
|
+
params,
|
|
26
23
|
{
|
|
27
24
|
server: false,
|
|
28
25
|
// TODO: In some cases it might be ok to fetch on server
|
|
@@ -30,10 +27,16 @@ export async function useWishlist({
|
|
|
30
27
|
dedupe: "defer",
|
|
31
28
|
getCachedData: (key2) => {
|
|
32
29
|
return toValue(nuxtApp._asyncData[key2]?.data) ?? void 0;
|
|
33
|
-
}
|
|
34
|
-
default: () => void 0
|
|
30
|
+
}
|
|
35
31
|
}
|
|
36
32
|
);
|
|
33
|
+
const {
|
|
34
|
+
data,
|
|
35
|
+
pending: fetching,
|
|
36
|
+
error,
|
|
37
|
+
refresh: fetch,
|
|
38
|
+
status
|
|
39
|
+
} = asyncData;
|
|
37
40
|
const addItem = async (item) => {
|
|
38
41
|
data.value = await rpcCall(
|
|
39
42
|
nuxtApp,
|
|
@@ -111,7 +114,7 @@ export async function useWishlist({
|
|
|
111
114
|
const products = computed(() => {
|
|
112
115
|
return items.value?.map((item) => item.product) || [];
|
|
113
116
|
});
|
|
114
|
-
return {
|
|
117
|
+
return extendPromise(asyncData.then(() => ({})), {
|
|
115
118
|
data,
|
|
116
119
|
count,
|
|
117
120
|
items,
|
|
@@ -127,5 +130,5 @@ export async function useWishlist({
|
|
|
127
130
|
contains,
|
|
128
131
|
error,
|
|
129
132
|
status
|
|
130
|
-
};
|
|
133
|
+
});
|
|
131
134
|
}
|
package/dist/runtime/log.mjs
CHANGED
|
@@ -37,7 +37,7 @@ export class Log {
|
|
|
37
37
|
try {
|
|
38
38
|
this._handler({ level, message, data, space: this._space });
|
|
39
39
|
} catch (e) {
|
|
40
|
-
console.error(`Error writing log message: ${e}`);
|
|
40
|
+
console.error(`Error writing log message: "${message}" -- ${e}`);
|
|
41
41
|
}
|
|
42
42
|
} else {
|
|
43
43
|
const logFunc = console[level] || console.log;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This function accepts a Promise which has the same interface as its resolved value.
|
|
3
|
+
* It returns a new Promise which extends the original Promise and the original Promise's resolve value
|
|
4
|
+
* with all the properties in source.
|
|
5
|
+
* @param promise
|
|
6
|
+
* @param source
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function extendPromise<T extends object, U>(promise: T & Promise<T>, source: U): T & U & Promise<T & U>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function extendPromise(promise, source) {
|
|
2
|
+
const newPromise = promise.then(
|
|
3
|
+
(result) => Object.assign(result, source)
|
|
4
|
+
);
|
|
5
|
+
const withoutPromise = Object.assign({}, promise);
|
|
6
|
+
for (const key of Object.getOwnPropertyNames(
|
|
7
|
+
Promise.prototype
|
|
8
|
+
)) {
|
|
9
|
+
delete withoutPromise[key];
|
|
10
|
+
}
|
|
11
|
+
return Object.assign(newPromise, Object.assign(withoutPromise, source));
|
|
12
|
+
}
|