@scayle/storefront-nuxt 7.36.3
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 +598 -0
- package/LICENSE +21 -0
- package/README.md +67 -0
- package/dist/index.d.mts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.mjs +2 -0
- package/dist/module.cjs +5 -0
- package/dist/module.d.mts +8 -0
- package/dist/module.d.ts +8 -0
- package/dist/module.json +8 -0
- package/dist/module.mjs +173 -0
- package/dist/rpc.d.mts +12 -0
- package/dist/rpc.d.ts +12 -0
- package/dist/rpc.mjs +18 -0
- package/dist/runtime/api/cacheAuth.d.ts +12 -0
- package/dist/runtime/api/cacheAuth.mjs +40 -0
- package/dist/runtime/api/purgeAll.d.ts +2 -0
- package/dist/runtime/api/purgeAll.mjs +14 -0
- package/dist/runtime/api/purgeTags.d.ts +2 -0
- package/dist/runtime/api/purgeTags.mjs +19 -0
- package/dist/runtime/api/rpcHandler.d.ts +2 -0
- package/dist/runtime/api/rpcHandler.mjs +15 -0
- package/dist/runtime/api/up.d.ts +4 -0
- package/dist/runtime/api/up.mjs +4 -0
- package/dist/runtime/composables/core/useAvailableShops.d.ts +2 -0
- package/dist/runtime/composables/core/useAvailableShops.mjs +4 -0
- package/dist/runtime/composables/core/useCurrentShop.d.ts +3 -0
- package/dist/runtime/composables/core/useCurrentShop.mjs +8 -0
- package/dist/runtime/composables/core/useEventListener.d.ts +2 -0
- package/dist/runtime/composables/core/useEventListener.mjs +2 -0
- package/dist/runtime/composables/core/useLog.d.ts +1 -0
- package/dist/runtime/composables/core/useLog.mjs +8 -0
- package/dist/runtime/composables/core/useRpc.d.ts +17 -0
- package/dist/runtime/composables/core/useRpc.mjs +56 -0
- package/dist/runtime/composables/core/useSession.d.ts +21 -0
- package/dist/runtime/composables/core/useSession.mjs +21 -0
- package/dist/runtime/composables/core/useUser.d.ts +16 -0
- package/dist/runtime/composables/core/useUser.mjs +68 -0
- package/dist/runtime/composables/storefront/useBasket.d.ts +54 -0
- package/dist/runtime/composables/storefront/useBasket.mjs +165 -0
- package/dist/runtime/composables/storefront/useBrand.d.ts +16 -0
- package/dist/runtime/composables/storefront/useBrand.mjs +20 -0
- package/dist/runtime/composables/storefront/useBrands.d.ts +16 -0
- package/dist/runtime/composables/storefront/useBrands.mjs +20 -0
- package/dist/runtime/composables/storefront/useCategories.d.ts +20 -0
- package/dist/runtime/composables/storefront/useCategories.mjs +30 -0
- package/dist/runtime/composables/storefront/useCurrentPromotions.d.ts +16 -0
- package/dist/runtime/composables/storefront/useCurrentPromotions.mjs +20 -0
- package/dist/runtime/composables/storefront/useFacet.d.ts +48 -0
- package/dist/runtime/composables/storefront/useFacet.mjs +193 -0
- package/dist/runtime/composables/storefront/useFilters.d.ts +16 -0
- package/dist/runtime/composables/storefront/useFilters.mjs +20 -0
- package/dist/runtime/composables/storefront/useNavigationTree.d.ts +16 -0
- package/dist/runtime/composables/storefront/useNavigationTree.mjs +20 -0
- package/dist/runtime/composables/storefront/useNavigationTrees.d.ts +16 -0
- package/dist/runtime/composables/storefront/useNavigationTrees.mjs +20 -0
- package/dist/runtime/composables/storefront/useOrder.d.ts +89 -0
- package/dist/runtime/composables/storefront/useOrder.mjs +17 -0
- package/dist/runtime/composables/storefront/useOrderConfirmation.d.ts +89 -0
- package/dist/runtime/composables/storefront/useOrderConfirmation.mjs +17 -0
- package/dist/runtime/composables/storefront/useProduct.d.ts +16 -0
- package/dist/runtime/composables/storefront/useProduct.mjs +20 -0
- package/dist/runtime/composables/storefront/useProducts.d.ts +20 -0
- package/dist/runtime/composables/storefront/useProducts.mjs +20 -0
- package/dist/runtime/composables/storefront/useProductsByIds.d.ts +16 -0
- package/dist/runtime/composables/storefront/useProductsByIds.mjs +20 -0
- package/dist/runtime/composables/storefront/useProductsCount.d.ts +16 -0
- package/dist/runtime/composables/storefront/useProductsCount.mjs +20 -0
- package/dist/runtime/composables/storefront/usePromotions.d.ts +16 -0
- package/dist/runtime/composables/storefront/usePromotions.mjs +20 -0
- package/dist/runtime/composables/storefront/usePromotionsByIds.d.ts +16 -0
- package/dist/runtime/composables/storefront/usePromotionsByIds.mjs +20 -0
- package/dist/runtime/composables/storefront/useQueryFilterState.d.ts +12 -0
- package/dist/runtime/composables/storefront/useQueryFilterState.mjs +66 -0
- package/dist/runtime/composables/storefront/useSearch.d.ts +13 -0
- package/dist/runtime/composables/storefront/useSearch.mjs +49 -0
- package/dist/runtime/composables/storefront/useShopConfiguration.d.ts +13 -0
- package/dist/runtime/composables/storefront/useShopConfiguration.mjs +19 -0
- package/dist/runtime/composables/storefront/useUserAddresses.d.ts +13 -0
- package/dist/runtime/composables/storefront/useUserAddresses.mjs +19 -0
- package/dist/runtime/composables/storefront/useVariant.d.ts +16 -0
- package/dist/runtime/composables/storefront/useVariant.mjs +20 -0
- package/dist/runtime/composables/storefront/useWishlist.d.ts +48 -0
- package/dist/runtime/composables/storefront/useWishlist.mjs +119 -0
- package/dist/runtime/composables/useCoreLog.d.ts +1 -0
- package/dist/runtime/composables/useCoreLog.mjs +4 -0
- package/dist/runtime/context.d.ts +12 -0
- package/dist/runtime/context.mjs +98 -0
- package/dist/runtime/createLog.d.ts +3 -0
- package/dist/runtime/createLog.mjs +39 -0
- package/dist/runtime/error/handler.d.ts +14 -0
- package/dist/runtime/error/handler.mjs +53 -0
- package/dist/runtime/handler.d.ts +8 -0
- package/dist/runtime/handler.mjs +26 -0
- package/dist/runtime/log.d.ts +38 -0
- package/dist/runtime/log.mjs +68 -0
- package/dist/runtime/plugin/log.client.d.ts +8 -0
- package/dist/runtime/plugin/log.client.mjs +24 -0
- package/dist/runtime/plugin/log.server.d.ts +2 -0
- package/dist/runtime/plugin/log.server.mjs +11 -0
- package/dist/runtime/plugin/shop.d.ts +8 -0
- package/dist/runtime/plugin/shop.mjs +17 -0
- package/dist/runtime/rpc/rpcCall.d.ts +9 -0
- package/dist/runtime/rpc/rpcCall.mjs +16 -0
- package/dist/runtime/server/middleware/bootstrap.d.ts +12 -0
- package/dist/runtime/server/middleware/bootstrap.mjs +188 -0
- package/dist/runtime/server/middleware/bootstrap.test.d.ts +6 -0
- package/dist/runtime/server/middleware/bootstrap.test.mjs +277 -0
- package/dist/runtime/server/middleware/bootstrap.utils.d.ts +7 -0
- package/dist/runtime/server/middleware/bootstrap.utils.mjs +59 -0
- package/dist/runtime/server/middleware/cache.d.ts +12 -0
- package/dist/runtime/server/middleware/cache.mjs +44 -0
- package/dist/runtime/server/middleware/oauth.d.ts +3 -0
- package/dist/runtime/server/middleware/oauth.mjs +123 -0
- package/dist/runtime/server/middleware/redirects.d.ts +2 -0
- package/dist/runtime/server/middleware/redirects.mjs +86 -0
- package/dist/runtime/server/middleware/redirects.test.d.ts +1 -0
- package/dist/runtime/server/middleware/redirects.test.mjs +66 -0
- package/dist/runtime/server/middleware/redirects.utils.d.ts +18 -0
- package/dist/runtime/server/middleware/redirects.utils.mjs +28 -0
- package/dist/runtime/utils/error.d.ts +5 -0
- package/dist/runtime/utils/error.mjs +7 -0
- package/dist/runtime/utils/price.d.ts +11 -0
- package/dist/runtime/utils/price.mjs +32 -0
- package/dist/runtime/utils/price.test.d.ts +1 -0
- package/dist/runtime/utils/price.test.mjs +83 -0
- package/dist/runtime/utils/route.d.ts +2 -0
- package/dist/runtime/utils/route.mjs +3 -0
- package/dist/runtime/utils/route.test.d.ts +1 -0
- package/dist/runtime/utils/route.test.mjs +15 -0
- package/dist/shared/storefront-nuxt.9548700f.d.mts +161 -0
- package/dist/shared/storefront-nuxt.9548700f.d.ts +161 -0
- package/dist/types.d.mts +15 -0
- package/dist/types.d.ts +15 -0
- package/package.json +103 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AddOrUpdateItemType, ExistingItemHandling, RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
|
+
import { RpcOptions } from '../core/useRpc';
|
|
3
|
+
import { type MaybeRefOrGetter } from '#imports';
|
|
4
|
+
type UseBasketOptions = Partial<{
|
|
5
|
+
params: MaybeRefOrGetter<RpcMethodParameters<'getBasket'>>;
|
|
6
|
+
options: RpcOptions;
|
|
7
|
+
key: string;
|
|
8
|
+
}>;
|
|
9
|
+
export declare function useBasket({ params, options, key, }?: UseBasketOptions): Promise<{
|
|
10
|
+
data: import("vue").Ref<import("@scayle/storefront-core").BasketResponseData<import("@scayle/storefront-core").Product, import("@scayle/storefront-core").Variant>>;
|
|
11
|
+
items: import("vue").ComputedRef<import("@scayle/storefront-core").BasketItem<import("@scayle/storefront-core").Product, import("@scayle/storefront-core").Variant>[]>;
|
|
12
|
+
cost: import("vue").ComputedRef<import("@scayle/storefront-core").BasketTotalPrice>;
|
|
13
|
+
key: import("vue").ComputedRef<import("@aboutyou/backbone").BasketKey>;
|
|
14
|
+
packages: import("vue").ComputedRef<import("@aboutyou/backbone").BasketPackageInformation[]>;
|
|
15
|
+
shippingDates: import("vue").ComputedRef<(string | null)[] | undefined>;
|
|
16
|
+
isEmpty: import("vue").ComputedRef<boolean>;
|
|
17
|
+
fetching: import("vue").Ref<boolean>;
|
|
18
|
+
fetch: () => Promise<void>;
|
|
19
|
+
count: import("vue").ComputedRef<number>;
|
|
20
|
+
countWithoutSoldOutItems: import("vue").ComputedRef<number>;
|
|
21
|
+
addItem: ({ variantId, promotionId, quantity, existingItemHandling, displayData, customData, itemGroup, }: AddOrUpdateItemType & {
|
|
22
|
+
existingItemHandling?: 0 | 1 | 2 | 3 | undefined;
|
|
23
|
+
}) => Promise<void>;
|
|
24
|
+
addItems: (items: AddOrUpdateItemType[], existingItemHandling?: 1) => Promise<void>;
|
|
25
|
+
removeItem: (item: {
|
|
26
|
+
variantId: number;
|
|
27
|
+
}) => Promise<void>;
|
|
28
|
+
clear: () => Promise<void>;
|
|
29
|
+
contains: (item: {
|
|
30
|
+
variantId: number;
|
|
31
|
+
} | {
|
|
32
|
+
productId: number;
|
|
33
|
+
}) => boolean;
|
|
34
|
+
products: import("vue").ComputedRef<import("@scayle/storefront-core").Product[]>;
|
|
35
|
+
findItem: (item: {
|
|
36
|
+
variantId: number;
|
|
37
|
+
} | {
|
|
38
|
+
productId: number;
|
|
39
|
+
}) => import("@scayle/storefront-core").BasketItem<import("@scayle/storefront-core").Product, import("@scayle/storefront-core").Variant> | undefined;
|
|
40
|
+
generateBasketKey: ({ keyTemplate, hashAlgorithm, shopId, userId, log, }: {
|
|
41
|
+
keyTemplate: string;
|
|
42
|
+
hashAlgorithm: import("@scayle/storefront-core").HashAlgorithm;
|
|
43
|
+
shopId: string;
|
|
44
|
+
userId: string;
|
|
45
|
+
log?: import("@scayle/storefront-core").Log | undefined;
|
|
46
|
+
}) => Promise<any>;
|
|
47
|
+
mergeBaskets: (args: {
|
|
48
|
+
fromBasketKey: string;
|
|
49
|
+
toBasketKey: string;
|
|
50
|
+
}) => Promise<any>;
|
|
51
|
+
error: import("vue").Ref<import("nuxt/app").NuxtError | undefined>;
|
|
52
|
+
status: import("vue").Ref<import("../core/useRpc").Status>;
|
|
53
|
+
}>;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { generateBasketKey } from "@scayle/storefront-core/dist/utils/keys";
|
|
2
|
+
import {
|
|
3
|
+
BaseError,
|
|
4
|
+
ExistingItemHandling,
|
|
5
|
+
getShippingDates,
|
|
6
|
+
HttpStatusCode,
|
|
7
|
+
HttpStatusMessage
|
|
8
|
+
} from "@scayle/storefront-core";
|
|
9
|
+
import { useNuxtApp } from "nuxt/app";
|
|
10
|
+
import { computed } from "vue";
|
|
11
|
+
import { rpcCall } from "../../rpc/rpcCall.mjs";
|
|
12
|
+
import useEventListener from "../core/useEventListener.mjs";
|
|
13
|
+
import { useRpc } from "../core/useRpc.mjs";
|
|
14
|
+
import { useCurrentShop } from "../core/useCurrentShop.mjs";
|
|
15
|
+
import { toValue } from "#imports";
|
|
16
|
+
const onCheckoutUpdate = async (event, fetching, fetchCallback) => {
|
|
17
|
+
if (fetching) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (event?.data?.type === "tracking") {
|
|
21
|
+
const actionType = event.data.event?.event;
|
|
22
|
+
if (actionType === "add_to_cart" || actionType === "remove_from_cart") {
|
|
23
|
+
await fetchCallback();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
export async function useBasket({
|
|
28
|
+
params,
|
|
29
|
+
options,
|
|
30
|
+
key = "useBasket"
|
|
31
|
+
} = {}) {
|
|
32
|
+
const nuxtApp = useNuxtApp();
|
|
33
|
+
const shop = useCurrentShop();
|
|
34
|
+
const { data, fetch, fetching, error, status } = await useRpc(
|
|
35
|
+
"getBasket",
|
|
36
|
+
key,
|
|
37
|
+
params,
|
|
38
|
+
options
|
|
39
|
+
);
|
|
40
|
+
useEventListener(
|
|
41
|
+
"message",
|
|
42
|
+
(event) => onCheckoutUpdate(event, fetching.value, fetch)
|
|
43
|
+
);
|
|
44
|
+
const addItem = async ({
|
|
45
|
+
variantId,
|
|
46
|
+
promotionId,
|
|
47
|
+
quantity,
|
|
48
|
+
existingItemHandling,
|
|
49
|
+
displayData,
|
|
50
|
+
customData,
|
|
51
|
+
itemGroup
|
|
52
|
+
}) => {
|
|
53
|
+
data.value = await rpcCall(
|
|
54
|
+
nuxtApp,
|
|
55
|
+
"addItemToBasket",
|
|
56
|
+
toValue(shop)
|
|
57
|
+
)({
|
|
58
|
+
promotionId,
|
|
59
|
+
variantId,
|
|
60
|
+
quantity,
|
|
61
|
+
existingItemHandling,
|
|
62
|
+
displayData,
|
|
63
|
+
customData,
|
|
64
|
+
itemGroup,
|
|
65
|
+
with: toValue(params)
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
const addItems = async (items2, existingItemHandling = ExistingItemHandling.AddQuantityToExisting) => {
|
|
69
|
+
data.value = await rpcCall(
|
|
70
|
+
nuxtApp,
|
|
71
|
+
"addItemsToBasket",
|
|
72
|
+
toValue(shop)
|
|
73
|
+
)({
|
|
74
|
+
items: items2,
|
|
75
|
+
existingItemHandling,
|
|
76
|
+
with: toValue(params)
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
const mergeBaskets = async (args) => {
|
|
80
|
+
return await rpcCall(
|
|
81
|
+
nuxtApp,
|
|
82
|
+
"mergeBaskets",
|
|
83
|
+
toValue(shop)
|
|
84
|
+
)({
|
|
85
|
+
...args,
|
|
86
|
+
with: toValue(params)
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
const findItem = (item) => {
|
|
90
|
+
return data.value?.items?.find((entry) => {
|
|
91
|
+
if ("variantId" in item) {
|
|
92
|
+
return entry.variant.id === item.variantId;
|
|
93
|
+
}
|
|
94
|
+
return entry.product.id === item.productId;
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
const contains = (item) => {
|
|
98
|
+
return findItem(item) !== void 0;
|
|
99
|
+
};
|
|
100
|
+
const removeItem = async (item) => {
|
|
101
|
+
const element = findItem(item);
|
|
102
|
+
if (!element) {
|
|
103
|
+
throw new BaseError(
|
|
104
|
+
HttpStatusMessage.NOT_FOUND,
|
|
105
|
+
HttpStatusCode.NOT_FOUND,
|
|
106
|
+
`Could not find basket item by variant-id: ${item.variantId}`
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
data.value = await rpcCall(
|
|
110
|
+
nuxtApp,
|
|
111
|
+
"removeItemFromBasket",
|
|
112
|
+
toValue(shop)
|
|
113
|
+
)({
|
|
114
|
+
itemKey: element.key,
|
|
115
|
+
with: toValue(params)
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
const clear = async () => {
|
|
119
|
+
await rpcCall(nuxtApp, "clearBasket", toValue(shop))();
|
|
120
|
+
};
|
|
121
|
+
const products = computed(
|
|
122
|
+
() => data.value?.items.map((item) => item.product) || []
|
|
123
|
+
);
|
|
124
|
+
const count = computed(
|
|
125
|
+
() => data.value?.items?.reduce((prev, current) => prev + current.quantity, 0)
|
|
126
|
+
);
|
|
127
|
+
const countWithoutSoldOutItems = computed(
|
|
128
|
+
() => data.value?.items?.reduce(
|
|
129
|
+
(prev, current) => prev + (current.product.isSoldOut ? 0 : current.quantity),
|
|
130
|
+
0
|
|
131
|
+
)
|
|
132
|
+
);
|
|
133
|
+
const items = computed(() => data.value?.items);
|
|
134
|
+
const cost = computed(() => data.value?.cost);
|
|
135
|
+
const basketKey = computed(() => data.value?.key);
|
|
136
|
+
const isEmpty = computed(() => count.value === 0);
|
|
137
|
+
const packages = computed(() => data.value?.packages);
|
|
138
|
+
const shippingDates = computed(
|
|
139
|
+
() => packages.value ? getShippingDates(packages.value) : void 0
|
|
140
|
+
);
|
|
141
|
+
return {
|
|
142
|
+
data,
|
|
143
|
+
items,
|
|
144
|
+
cost,
|
|
145
|
+
key: basketKey,
|
|
146
|
+
packages,
|
|
147
|
+
shippingDates,
|
|
148
|
+
isEmpty,
|
|
149
|
+
fetching,
|
|
150
|
+
fetch,
|
|
151
|
+
count,
|
|
152
|
+
countWithoutSoldOutItems,
|
|
153
|
+
addItem,
|
|
154
|
+
addItems,
|
|
155
|
+
removeItem,
|
|
156
|
+
clear,
|
|
157
|
+
contains,
|
|
158
|
+
products,
|
|
159
|
+
findItem,
|
|
160
|
+
generateBasketKey,
|
|
161
|
+
mergeBaskets,
|
|
162
|
+
error,
|
|
163
|
+
status
|
|
164
|
+
};
|
|
165
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
|
+
import { RpcOptions } from '../core/useRpc';
|
|
3
|
+
import type { MaybeRefOrGetter } from '#imports';
|
|
4
|
+
type Options = Partial<{
|
|
5
|
+
params: MaybeRefOrGetter<RpcMethodParameters<'getBrandById'>>;
|
|
6
|
+
options: RpcOptions;
|
|
7
|
+
key: string;
|
|
8
|
+
}>;
|
|
9
|
+
export declare function useBrand({ params, options, key, }?: Options): Promise<{
|
|
10
|
+
data: import("vue").Ref<import("@scayle/storefront-core").Brand>;
|
|
11
|
+
fetching: import("vue").Ref<boolean>;
|
|
12
|
+
fetch: () => Promise<void>;
|
|
13
|
+
error: import("vue").Ref<import("nuxt/app").NuxtError | undefined>;
|
|
14
|
+
status: import("vue").Ref<import("../core/useRpc").Status>;
|
|
15
|
+
}>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useRpc } from "../core/useRpc.mjs";
|
|
2
|
+
export async function useBrand({
|
|
3
|
+
params,
|
|
4
|
+
options,
|
|
5
|
+
key = "useBrand"
|
|
6
|
+
} = {}) {
|
|
7
|
+
const { data, fetching, fetch, error, status } = await useRpc(
|
|
8
|
+
"getBrandById",
|
|
9
|
+
key,
|
|
10
|
+
params,
|
|
11
|
+
options
|
|
12
|
+
);
|
|
13
|
+
return {
|
|
14
|
+
data,
|
|
15
|
+
fetching,
|
|
16
|
+
fetch,
|
|
17
|
+
error,
|
|
18
|
+
status
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
|
+
import { RpcOptions } from '../core/useRpc';
|
|
3
|
+
import type { MaybeRefOrGetter } from '#imports';
|
|
4
|
+
type Options = Partial<{
|
|
5
|
+
params: MaybeRefOrGetter<RpcMethodParameters<'getBrands'>>;
|
|
6
|
+
options: RpcOptions;
|
|
7
|
+
key: string;
|
|
8
|
+
}>;
|
|
9
|
+
export declare function useBrands({ params, options, key, }?: Options): Promise<{
|
|
10
|
+
data: import("vue").Ref<import("@scayle/storefront-core").BrandsEndpointResponseData>;
|
|
11
|
+
fetching: import("vue").Ref<boolean>;
|
|
12
|
+
fetch: () => Promise<void>;
|
|
13
|
+
error: import("vue").Ref<import("nuxt/app").NuxtError | undefined>;
|
|
14
|
+
status: import("vue").Ref<import("../core/useRpc").Status>;
|
|
15
|
+
}>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useRpc } from "../core/useRpc.mjs";
|
|
2
|
+
export async function useBrands({
|
|
3
|
+
params,
|
|
4
|
+
options,
|
|
5
|
+
key = "useBrands"
|
|
6
|
+
} = {}) {
|
|
7
|
+
const { data, fetching, fetch, error, status } = await useRpc(
|
|
8
|
+
"getBrands",
|
|
9
|
+
key,
|
|
10
|
+
params,
|
|
11
|
+
options
|
|
12
|
+
);
|
|
13
|
+
return {
|
|
14
|
+
data,
|
|
15
|
+
fetching,
|
|
16
|
+
fetch,
|
|
17
|
+
error,
|
|
18
|
+
status
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
|
+
import { RpcOptions } from '../core/useRpc';
|
|
3
|
+
import type { MaybeRefOrGetter } from '#imports';
|
|
4
|
+
type Options = Partial<{
|
|
5
|
+
params: MaybeRefOrGetter<RpcMethodParameters<'getCategoriesByPath'>>;
|
|
6
|
+
options: RpcOptions;
|
|
7
|
+
key: string;
|
|
8
|
+
}>;
|
|
9
|
+
export declare function useCategories({ params, options, key, }?: Options): Promise<{
|
|
10
|
+
data: import("vue").Ref<{
|
|
11
|
+
categories: import("@scayle/storefront-core").Category | import("@scayle/storefront-core").Category[];
|
|
12
|
+
activeNode: import("@scayle/storefront-core").Category | undefined;
|
|
13
|
+
}>;
|
|
14
|
+
fetching: import("vue").Ref<boolean>;
|
|
15
|
+
fetch: () => Promise<void>;
|
|
16
|
+
error: import("vue").Ref<import("nuxt/app").NuxtError | undefined>;
|
|
17
|
+
status: import("vue").Ref<import("../core/useRpc").Status>;
|
|
18
|
+
getCategoryById: (id: number, includeHidden?: true) => Promise<import("@scayle/storefront-core").Category>;
|
|
19
|
+
}>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useNuxtApp } from "nuxt/app";
|
|
2
|
+
import { useRpc } from "../core/useRpc.mjs";
|
|
3
|
+
import { useCurrentShop } from "../core/useCurrentShop.mjs";
|
|
4
|
+
import { rpcCall } from "../../rpc/rpcCall.mjs";
|
|
5
|
+
export async function useCategories({
|
|
6
|
+
params,
|
|
7
|
+
options,
|
|
8
|
+
key = "useCategories"
|
|
9
|
+
} = {}) {
|
|
10
|
+
const currentShop = useCurrentShop();
|
|
11
|
+
const { data, fetching, fetch, error, status } = await useRpc(
|
|
12
|
+
"getCategoriesByPath",
|
|
13
|
+
key,
|
|
14
|
+
params,
|
|
15
|
+
options
|
|
16
|
+
);
|
|
17
|
+
const getCategoryById = rpcCall(
|
|
18
|
+
useNuxtApp(),
|
|
19
|
+
"getCategoryById",
|
|
20
|
+
currentShop.value ?? void 0
|
|
21
|
+
);
|
|
22
|
+
return {
|
|
23
|
+
data,
|
|
24
|
+
fetching,
|
|
25
|
+
fetch,
|
|
26
|
+
error,
|
|
27
|
+
status,
|
|
28
|
+
getCategoryById: (id, includeHidden) => getCategoryById({ id, includeHidden })
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
|
+
import { type RpcOptions } from '../core/useRpc';
|
|
3
|
+
import { type MaybeRefOrGetter } from '#imports';
|
|
4
|
+
type Options = Partial<{
|
|
5
|
+
params: MaybeRefOrGetter<RpcMethodParameters<'getCurrentPromotions'>>;
|
|
6
|
+
options: RpcOptions;
|
|
7
|
+
key: string;
|
|
8
|
+
}>;
|
|
9
|
+
export declare function useCurrentPromotions({ params, options, key, }?: Options): Promise<{
|
|
10
|
+
data: import("vue").Ref<import("@scayle/storefront-core").PromotionsResponseData>;
|
|
11
|
+
fetching: import("vue").Ref<boolean>;
|
|
12
|
+
fetch: () => Promise<void>;
|
|
13
|
+
error: import("vue").Ref<import("nuxt/app").NuxtError | undefined>;
|
|
14
|
+
status: import("vue").Ref<import("../core/useRpc").Status>;
|
|
15
|
+
}>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useRpc } from "../core/useRpc.mjs";
|
|
2
|
+
export async function useCurrentPromotions({
|
|
3
|
+
params,
|
|
4
|
+
options,
|
|
5
|
+
key = "useCurrentPromotions"
|
|
6
|
+
} = {}) {
|
|
7
|
+
const { data, fetching, fetch, error, status } = await useRpc(
|
|
8
|
+
"getCurrentPromotions",
|
|
9
|
+
key,
|
|
10
|
+
params,
|
|
11
|
+
options
|
|
12
|
+
);
|
|
13
|
+
return {
|
|
14
|
+
data,
|
|
15
|
+
fetching,
|
|
16
|
+
fetch,
|
|
17
|
+
error,
|
|
18
|
+
status
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { FilterParams, ProductWith } from '@scayle/storefront-core';
|
|
2
|
+
type FacetParams = Partial<{
|
|
3
|
+
with: {
|
|
4
|
+
product?: ProductWith;
|
|
5
|
+
};
|
|
6
|
+
includedFilters: string[];
|
|
7
|
+
includeSoldOut: boolean;
|
|
8
|
+
includeSellableForFree: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
type Options = Partial<{
|
|
11
|
+
params: FacetParams;
|
|
12
|
+
key: string;
|
|
13
|
+
}>;
|
|
14
|
+
export declare function useFacet({ key, params, }?: Options): Promise<{
|
|
15
|
+
filters: import("vue").ComputedRef<import("@aboutyou/backbone").FiltersEndpointResponseData>;
|
|
16
|
+
filtersFetching: import("vue").Ref<boolean>;
|
|
17
|
+
unfilteredCount: import("vue").ComputedRef<number>;
|
|
18
|
+
filterStatus: import("vue").Ref<import("../core/useRpc").Status>;
|
|
19
|
+
filterError: import("vue").Ref<import("nuxt/app").NuxtError | undefined>;
|
|
20
|
+
productCountData: import("vue").Ref<import("@scayle/storefront-core").FetchProductsCountResponse>;
|
|
21
|
+
refreshProductCount: ({ where, }?: FilterParams) => Promise<void>;
|
|
22
|
+
productCountFetching: import("vue").Ref<boolean>;
|
|
23
|
+
productCountError: import("vue").Ref<import("nuxt/app").NuxtError | undefined>;
|
|
24
|
+
productCountStatus: import("vue").Ref<import("../core/useRpc").Status>;
|
|
25
|
+
products: import("vue").ComputedRef<import("@scayle/storefront-core").Product[]>;
|
|
26
|
+
pagination: import("vue").ComputedRef<import("@scayle/storefront-core").Pagination>;
|
|
27
|
+
productsFetching: import("vue").Ref<boolean>;
|
|
28
|
+
filterProducts: ({ where, page, sort, orFiltersOperator, }: FilterParams) => Promise<void>;
|
|
29
|
+
productError: import("vue").Ref<import("nuxt/app").NuxtError | undefined>;
|
|
30
|
+
productStatus: import("vue").Ref<import("../core/useRpc").Status>;
|
|
31
|
+
categories: import("vue").ComputedRef<import("@scayle/storefront-core").Category | import("@scayle/storefront-core").Category[]>;
|
|
32
|
+
selectedCategory: import("vue").ComputedRef<import("@scayle/storefront-core").Category | undefined>;
|
|
33
|
+
categoriesFetching: import("vue").Ref<boolean>;
|
|
34
|
+
categoriesError: import("vue").Ref<import("nuxt/app").NuxtError | undefined>;
|
|
35
|
+
categoriesStatus: import("vue").Ref<import("../core/useRpc").Status>;
|
|
36
|
+
fetchProducts: ({ path, page, perPage, where, sort, pricePromotionKey, cache, orFiltersOperator, }: FilterParams & {
|
|
37
|
+
path: string;
|
|
38
|
+
pricePromotionKey?: string | undefined;
|
|
39
|
+
cache?: Partial<{
|
|
40
|
+
ttl: number;
|
|
41
|
+
cacheKey: string;
|
|
42
|
+
cacheKeyPrefix: string;
|
|
43
|
+
timeout: number;
|
|
44
|
+
}> | undefined;
|
|
45
|
+
}) => Promise<true | undefined>;
|
|
46
|
+
fetchPage: (pageToFetch: number) => Promise<void>;
|
|
47
|
+
}>;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { useState } from "nuxt/app";
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { useCategories } from "../storefront/useCategories.mjs";
|
|
4
|
+
import { useFilters } from "../storefront/useFilters.mjs";
|
|
5
|
+
import { useProducts } from "../storefront/useProducts.mjs";
|
|
6
|
+
import { useProductsCount } from "../storefront/useProductsCount.mjs";
|
|
7
|
+
export async function useFacet({
|
|
8
|
+
key = "useFacet",
|
|
9
|
+
params = {}
|
|
10
|
+
} = {}) {
|
|
11
|
+
const currentPath = useState(`${key}-path`, () => "");
|
|
12
|
+
const currentPage = useState(
|
|
13
|
+
`${key}-currentPage`,
|
|
14
|
+
() => 1
|
|
15
|
+
);
|
|
16
|
+
const currentPerPage = useState(`${key}-itemsPerPAge`, () => 20);
|
|
17
|
+
const currentWhereCondition = useState(
|
|
18
|
+
`${key}-whereCondition`
|
|
19
|
+
);
|
|
20
|
+
const currentSorting = useState(`${key}-sorting`);
|
|
21
|
+
const currentPricePromotionKey = useState(`${key}-pricePromotionKey`);
|
|
22
|
+
const currentCacheParams = useState(
|
|
23
|
+
`${key}-currentCacheParams`
|
|
24
|
+
);
|
|
25
|
+
const currentOrFiltersOperator = useState(
|
|
26
|
+
`${key}-orFilterOperator`
|
|
27
|
+
);
|
|
28
|
+
const productCountWhere = useState(
|
|
29
|
+
`${key}-productCountWhereCondition`
|
|
30
|
+
);
|
|
31
|
+
const {
|
|
32
|
+
data: categoryData,
|
|
33
|
+
fetch: refreshCategories,
|
|
34
|
+
fetching: categoriesFetching,
|
|
35
|
+
error: categoriesError,
|
|
36
|
+
status: categoriesStatus
|
|
37
|
+
} = await useCategories({
|
|
38
|
+
params: () => ({
|
|
39
|
+
path: currentPath.value,
|
|
40
|
+
includeHidden: params.with?.product?.categories?.includeHidden || void 0
|
|
41
|
+
}),
|
|
42
|
+
options: { autoFetch: false },
|
|
43
|
+
key: `${key}-categories`
|
|
44
|
+
});
|
|
45
|
+
const categories = computed(() => categoryData.value?.categories);
|
|
46
|
+
const selectedCategory = computed(() => categoryData.value?.activeNode);
|
|
47
|
+
const {
|
|
48
|
+
data: productData,
|
|
49
|
+
fetch: _refreshProducts,
|
|
50
|
+
fetching: productsFetching,
|
|
51
|
+
error: productError,
|
|
52
|
+
status: productStatus
|
|
53
|
+
} = await useProducts({
|
|
54
|
+
params: () => ({
|
|
55
|
+
page: currentPage.value,
|
|
56
|
+
perPage: currentPerPage.value,
|
|
57
|
+
with: params.with?.product,
|
|
58
|
+
category: currentPath.value,
|
|
59
|
+
includeSoldOut: params.includeSoldOut,
|
|
60
|
+
includeSellableForFree: params.includeSellableForFree,
|
|
61
|
+
where: currentWhereCondition.value,
|
|
62
|
+
sort: currentSorting.value,
|
|
63
|
+
pricePromotionKey: currentPricePromotionKey.value,
|
|
64
|
+
cache: currentCacheParams.value,
|
|
65
|
+
orFiltersOperator: currentOrFiltersOperator.value
|
|
66
|
+
}),
|
|
67
|
+
options: { autoFetch: false },
|
|
68
|
+
key: `${key}-products`
|
|
69
|
+
});
|
|
70
|
+
const {
|
|
71
|
+
data: productCountData,
|
|
72
|
+
fetch: _refreshProductCount,
|
|
73
|
+
fetching: productCountFetching,
|
|
74
|
+
error: productCountError,
|
|
75
|
+
status: productCountStatus
|
|
76
|
+
} = await useProductsCount({
|
|
77
|
+
params: () => ({
|
|
78
|
+
category: currentPath.value,
|
|
79
|
+
includedFilters: params.includedFilters,
|
|
80
|
+
includeSoldOut: params.includeSoldOut,
|
|
81
|
+
includeSellableForFree: params.includeSellableForFree,
|
|
82
|
+
where: productCountWhere.value,
|
|
83
|
+
orFiltersOperator: currentOrFiltersOperator.value
|
|
84
|
+
}),
|
|
85
|
+
options: { autoFetch: false },
|
|
86
|
+
key: `${key}-productCount`
|
|
87
|
+
});
|
|
88
|
+
const {
|
|
89
|
+
data: filterData,
|
|
90
|
+
fetch: refreshFilters,
|
|
91
|
+
fetching: filtersFetching,
|
|
92
|
+
error: filterError,
|
|
93
|
+
status: filterStatus
|
|
94
|
+
} = await useFilters({
|
|
95
|
+
params: () => ({
|
|
96
|
+
category: currentPath.value,
|
|
97
|
+
includedFilters: params.includedFilters,
|
|
98
|
+
includeSoldOut: params.includeSoldOut,
|
|
99
|
+
includeSellableForFree: params.includeSellableForFree,
|
|
100
|
+
where: currentWhereCondition.value,
|
|
101
|
+
orFiltersOperator: currentOrFiltersOperator.value
|
|
102
|
+
}),
|
|
103
|
+
options: { autoFetch: false },
|
|
104
|
+
key: `${key}-filters`
|
|
105
|
+
});
|
|
106
|
+
const pagination = computed(() => productData.value?.pagination);
|
|
107
|
+
const products = computed(() => productData.value?.products);
|
|
108
|
+
const filters = computed(() => filterData.value?.filters);
|
|
109
|
+
const unfilteredCount = computed(() => filterData.value?.unfilteredCount);
|
|
110
|
+
const refreshProductCount = async ({
|
|
111
|
+
where = void 0
|
|
112
|
+
} = {}) => {
|
|
113
|
+
productCountWhere.value = where;
|
|
114
|
+
if (productCountFetching.value) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
await _refreshProductCount();
|
|
118
|
+
};
|
|
119
|
+
const fetchProducts = async ({
|
|
120
|
+
path,
|
|
121
|
+
page = 1,
|
|
122
|
+
perPage = 20,
|
|
123
|
+
where = void 0,
|
|
124
|
+
sort = void 0,
|
|
125
|
+
pricePromotionKey = "",
|
|
126
|
+
cache,
|
|
127
|
+
orFiltersOperator = void 0
|
|
128
|
+
}) => {
|
|
129
|
+
currentPath.value = path;
|
|
130
|
+
currentPage.value = page;
|
|
131
|
+
currentPerPage.value = perPage;
|
|
132
|
+
currentWhereCondition.value = where;
|
|
133
|
+
currentSorting.value = sort;
|
|
134
|
+
currentPricePromotionKey.value = pricePromotionKey;
|
|
135
|
+
currentCacheParams.value = cache;
|
|
136
|
+
currentOrFiltersOperator.value = orFiltersOperator;
|
|
137
|
+
if (categoriesFetching.value || productsFetching.value || filtersFetching.value) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
await Promise.all([
|
|
141
|
+
refreshCategories(),
|
|
142
|
+
_refreshProducts(),
|
|
143
|
+
refreshFilters()
|
|
144
|
+
]);
|
|
145
|
+
return true;
|
|
146
|
+
};
|
|
147
|
+
const filterProducts = async ({
|
|
148
|
+
where = void 0,
|
|
149
|
+
page,
|
|
150
|
+
sort = void 0,
|
|
151
|
+
orFiltersOperator = void 0
|
|
152
|
+
}) => {
|
|
153
|
+
currentWhereCondition.value = where;
|
|
154
|
+
currentPage.value = page;
|
|
155
|
+
currentSorting.value = sort;
|
|
156
|
+
currentOrFiltersOperator.value = orFiltersOperator;
|
|
157
|
+
await _refreshProducts();
|
|
158
|
+
};
|
|
159
|
+
const fetchPage = async (pageToFetch) => {
|
|
160
|
+
currentPage.value = pageToFetch;
|
|
161
|
+
await _refreshProducts();
|
|
162
|
+
};
|
|
163
|
+
return {
|
|
164
|
+
// filter data
|
|
165
|
+
filters,
|
|
166
|
+
filtersFetching,
|
|
167
|
+
unfilteredCount,
|
|
168
|
+
filterStatus,
|
|
169
|
+
filterError,
|
|
170
|
+
// filter preview
|
|
171
|
+
productCountData,
|
|
172
|
+
refreshProductCount,
|
|
173
|
+
productCountFetching,
|
|
174
|
+
productCountError,
|
|
175
|
+
productCountStatus,
|
|
176
|
+
// product data
|
|
177
|
+
products,
|
|
178
|
+
pagination,
|
|
179
|
+
productsFetching,
|
|
180
|
+
filterProducts,
|
|
181
|
+
productError,
|
|
182
|
+
productStatus,
|
|
183
|
+
// category data
|
|
184
|
+
categories,
|
|
185
|
+
selectedCategory,
|
|
186
|
+
categoriesFetching,
|
|
187
|
+
categoriesError,
|
|
188
|
+
categoriesStatus,
|
|
189
|
+
// other
|
|
190
|
+
fetchProducts,
|
|
191
|
+
fetchPage
|
|
192
|
+
};
|
|
193
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
|
+
import { RpcOptions } from '../core/useRpc';
|
|
3
|
+
import type { MaybeRefOrGetter } from '#imports';
|
|
4
|
+
type Options = Partial<{
|
|
5
|
+
params: MaybeRefOrGetter<RpcMethodParameters<'getFilters'>>;
|
|
6
|
+
options: RpcOptions;
|
|
7
|
+
key: string;
|
|
8
|
+
}>;
|
|
9
|
+
export declare function useFilters({ params, options, key, }?: Options): Promise<{
|
|
10
|
+
data: import("vue").Ref<import("@scayle/storefront-core").FetchFiltersResponse>;
|
|
11
|
+
fetching: import("vue").Ref<boolean>;
|
|
12
|
+
fetch: () => Promise<void>;
|
|
13
|
+
error: import("vue").Ref<import("nuxt/app").NuxtError | undefined>;
|
|
14
|
+
status: import("vue").Ref<import("../core/useRpc").Status>;
|
|
15
|
+
}>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { useRpc } from "../core/useRpc.mjs";
|
|
2
|
+
export async function useFilters({
|
|
3
|
+
params,
|
|
4
|
+
options,
|
|
5
|
+
key = "useFilters"
|
|
6
|
+
} = {}) {
|
|
7
|
+
const { data, fetching, fetch, error, status } = await useRpc(
|
|
8
|
+
"getFilters",
|
|
9
|
+
key,
|
|
10
|
+
params,
|
|
11
|
+
options
|
|
12
|
+
);
|
|
13
|
+
return {
|
|
14
|
+
data,
|
|
15
|
+
fetching,
|
|
16
|
+
fetch,
|
|
17
|
+
error,
|
|
18
|
+
status
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RpcMethodParameters } from '@scayle/storefront-core';
|
|
2
|
+
import { RpcOptions } from '../core/useRpc';
|
|
3
|
+
import type { MaybeRefOrGetter } from '#imports';
|
|
4
|
+
type Options = Partial<{
|
|
5
|
+
params: MaybeRefOrGetter<RpcMethodParameters<'fetchNavigationTreeById'>>;
|
|
6
|
+
options: RpcOptions;
|
|
7
|
+
key: string;
|
|
8
|
+
}>;
|
|
9
|
+
export declare function useNavigationTree({ params, options, key, }?: Options): Promise<{
|
|
10
|
+
data: import("vue").Ref<import("@scayle/storefront-core").NavigationTree>;
|
|
11
|
+
fetching: import("vue").Ref<boolean>;
|
|
12
|
+
fetch: () => Promise<void>;
|
|
13
|
+
error: import("vue").Ref<import("nuxt/app").NuxtError | undefined>;
|
|
14
|
+
status: import("vue").Ref<import("../core/useRpc").Status>;
|
|
15
|
+
}>;
|
|
16
|
+
export {};
|