@scayle/storefront-nuxt 7.95.3 → 8.0.0

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.
Files changed (95) hide show
  1. package/CHANGELOG.md +484 -0
  2. package/dist/index.d.mts +1 -1
  3. package/dist/index.d.ts +1 -1
  4. package/dist/module.d.mts +2 -2
  5. package/dist/module.d.ts +2 -2
  6. package/dist/module.json +1 -1
  7. package/dist/module.mjs +6 -6
  8. package/dist/runtime/api/rpcHandler.d.ts +4 -6
  9. package/dist/runtime/campaignKey.d.ts +1 -2
  10. package/dist/runtime/campaignKey.js +3 -9
  11. package/dist/runtime/composables/core/useIDP.d.ts +2 -4
  12. package/dist/runtime/composables/core/useIDP.js +1 -8
  13. package/dist/runtime/composables/core/useRpc.d.ts +4 -17
  14. package/dist/runtime/composables/core/useRpc.js +11 -20
  15. package/dist/runtime/composables/core/useSession.d.ts +1 -1
  16. package/dist/runtime/composables/core/useUser.d.ts +2 -4
  17. package/dist/runtime/composables/core/useUser.js +3 -12
  18. package/dist/runtime/composables/index.d.ts +0 -3
  19. package/dist/runtime/composables/index.js +0 -3
  20. package/dist/runtime/composables/storefront/useBasket.d.ts +6 -4
  21. package/dist/runtime/composables/storefront/useBasket.js +68 -38
  22. package/dist/runtime/composables/storefront/useBrand.d.ts +2 -4
  23. package/dist/runtime/composables/storefront/useBrand.js +3 -4
  24. package/dist/runtime/composables/storefront/useBrands.d.ts +2 -4
  25. package/dist/runtime/composables/storefront/useBrands.js +3 -4
  26. package/dist/runtime/composables/storefront/useCategories.d.ts +3 -5
  27. package/dist/runtime/composables/storefront/useCategories.js +3 -8
  28. package/dist/runtime/composables/storefront/useCategoryById.d.ts +2 -4
  29. package/dist/runtime/composables/storefront/useCategoryById.js +3 -4
  30. package/dist/runtime/composables/storefront/useCategoryByPath.d.ts +2 -4
  31. package/dist/runtime/composables/storefront/useCategoryByPath.js +3 -4
  32. package/dist/runtime/composables/storefront/useCurrentPromotions.d.ts +2 -4
  33. package/dist/runtime/composables/storefront/useCurrentPromotions.js +3 -4
  34. package/dist/runtime/composables/storefront/useFilters.d.ts +2 -4
  35. package/dist/runtime/composables/storefront/useFilters.js +3 -4
  36. package/dist/runtime/composables/storefront/useNavigationTree.d.ts +3 -11
  37. package/dist/runtime/composables/storefront/useNavigationTree.js +6 -9
  38. package/dist/runtime/composables/storefront/useNavigationTrees.d.ts +2 -4
  39. package/dist/runtime/composables/storefront/useNavigationTrees.js +3 -4
  40. package/dist/runtime/composables/storefront/useOrder.d.ts +3 -5
  41. package/dist/runtime/composables/storefront/useOrder.js +3 -5
  42. package/dist/runtime/composables/storefront/useOrderConfirmation.d.ts +3 -5
  43. package/dist/runtime/composables/storefront/useOrderConfirmation.js +2 -2
  44. package/dist/runtime/composables/storefront/useProduct.d.ts +2 -4
  45. package/dist/runtime/composables/storefront/useProduct.js +3 -4
  46. package/dist/runtime/composables/storefront/useProducts.d.ts +2 -4
  47. package/dist/runtime/composables/storefront/useProducts.js +3 -4
  48. package/dist/runtime/composables/storefront/useProductsByIds.d.ts +2 -4
  49. package/dist/runtime/composables/storefront/useProductsByIds.js +3 -4
  50. package/dist/runtime/composables/storefront/useProductsByReferenceKeys.d.ts +2 -4
  51. package/dist/runtime/composables/storefront/useProductsByReferenceKeys.js +3 -4
  52. package/dist/runtime/composables/storefront/useProductsCount.d.ts +2 -4
  53. package/dist/runtime/composables/storefront/useProductsCount.js +3 -4
  54. package/dist/runtime/composables/storefront/usePromotions.d.ts +2 -4
  55. package/dist/runtime/composables/storefront/usePromotions.js +3 -4
  56. package/dist/runtime/composables/storefront/usePromotionsByIds.d.ts +2 -4
  57. package/dist/runtime/composables/storefront/usePromotionsByIds.js +3 -4
  58. package/dist/runtime/composables/storefront/useShopConfiguration.d.ts +1 -3
  59. package/dist/runtime/composables/storefront/useShopConfiguration.js +3 -4
  60. package/dist/runtime/composables/storefront/useStorefrontSearch.d.ts +5 -3
  61. package/dist/runtime/composables/storefront/useStorefrontSearch.js +3 -5
  62. package/dist/runtime/composables/storefront/useUserAddresses.d.ts +1 -3
  63. package/dist/runtime/composables/storefront/useUserAddresses.js +3 -4
  64. package/dist/runtime/composables/storefront/useVariant.d.ts +2 -4
  65. package/dist/runtime/composables/storefront/useVariant.js +3 -4
  66. package/dist/runtime/composables/storefront/useWishlist.d.ts +2 -3
  67. package/dist/runtime/composables/storefront/useWishlist.js +12 -21
  68. package/dist/runtime/context.js +1 -5
  69. package/dist/runtime/createLog.d.ts +1 -1
  70. package/dist/runtime/error/handler.d.ts +1 -1
  71. package/dist/runtime/error/handler.js +1 -28
  72. package/dist/runtime/nitro/plugins/nitroRuntimeStorageConfig.js +5 -93
  73. package/dist/runtime/plugin/shop.d.ts +4 -4
  74. package/dist/runtime/rpc/rpcCall.d.ts +1 -1
  75. package/dist/runtime/server/middleware/bootstrap-utils.d.ts +1 -5
  76. package/dist/runtime/server/middleware/bootstrap-utils.js +2 -4
  77. package/dist/runtime/server/middleware/bootstrap.js +3 -5
  78. package/dist/runtime/server/utils/cacheStorage.d.ts +1 -1
  79. package/dist/runtime/server/utils/cacheStorage.js +2 -2
  80. package/dist/runtime/utils/zodSchema.d.ts +467 -1840
  81. package/dist/runtime/utils/zodSchema.js +34 -83
  82. package/dist/shared/{storefront-nuxt.80aa5060.d.ts → storefront-nuxt.a816664e.d.mts} +4 -25
  83. package/dist/shared/{storefront-nuxt.80aa5060.d.mts → storefront-nuxt.a816664e.d.ts} +4 -25
  84. package/dist/test/factories.d.mts +1 -1
  85. package/dist/test/factories.d.ts +1 -1
  86. package/dist/test/factories.mjs +0 -2
  87. package/dist/types.d.mts +1 -1
  88. package/dist/types.d.ts +1 -1
  89. package/package.json +9 -9
  90. package/dist/runtime/composables/storefront/useFacet.d.ts +0 -100
  91. package/dist/runtime/composables/storefront/useFacet.js +0 -210
  92. package/dist/runtime/composables/storefront/useQueryFilterState.d.ts +0 -13
  93. package/dist/runtime/composables/storefront/useQueryFilterState.js +0 -78
  94. package/dist/runtime/composables/storefront/useSearch.d.ts +0 -14
  95. package/dist/runtime/composables/storefront/useSearch.js +0 -44
@@ -1,210 +0,0 @@
1
- import { useState } from "nuxt/app";
2
- import { computed } from "vue";
3
- import { useCategories } from "../storefront/useCategories.js";
4
- import { useFilters } from "../storefront/useFilters.js";
5
- import { useProducts } from "../storefront/useProducts.js";
6
- import { useProductsCount } from "../storefront/useProductsCount.js";
7
- import { extendPromise } from "../../utils/promise.js";
8
- export function useFacet({
9
- key: optionsKey,
10
- params = { initialPath: "/" }
11
- } = {}, _key) {
12
- const key = optionsKey ?? _key ?? "useFacet";
13
- const currentPath = useState(
14
- `${key}-path`,
15
- () => params.initialPath ?? "/"
16
- );
17
- const currentPage = useState(
18
- `${key}-currentPage`,
19
- () => 1
20
- );
21
- const currentPerPage = useState(`${key}-itemsPerPage`, () => 20);
22
- const currentWhereCondition = useState(
23
- `${key}-whereCondition`
24
- );
25
- const currentSorting = useState(`${key}-sorting`);
26
- const currentPricePromotionKey = useState(`${key}-pricePromotionKey`);
27
- const currentCacheParams = useState(
28
- `${key}-currentCacheParams`
29
- );
30
- const currentOrFiltersOperator = useState(
31
- `${key}-orFilterOperator`
32
- );
33
- const productCountWhere = useState(
34
- `${key}-productCountWhereCondition`
35
- );
36
- const categoriesPromise = useCategories({
37
- params: () => ({
38
- path: currentPath.value,
39
- includeHidden: params.with?.product?.categories?.includeHidden || void 0
40
- }),
41
- options: { immediate: false },
42
- key: `${key}-categories`
43
- });
44
- const productsPromise = useProducts({
45
- params: () => ({
46
- page: currentPage.value,
47
- perPage: currentPerPage.value,
48
- with: params.with?.product,
49
- category: currentPath.value,
50
- includeSoldOut: params.includeSoldOut,
51
- includeSellableForFree: params.includeSellableForFree,
52
- where: currentWhereCondition.value,
53
- sort: currentSorting.value,
54
- pricePromotionKey: currentPricePromotionKey.value,
55
- cache: currentCacheParams.value,
56
- orFiltersOperator: currentOrFiltersOperator.value
57
- }),
58
- options: { immediate: false },
59
- key: `${key}-products`
60
- });
61
- const productsCountPromise = useProductsCount({
62
- params: () => ({
63
- category: currentPath.value,
64
- includedFilters: params.includedFilters,
65
- includeSoldOut: params.includeSoldOut,
66
- includeSellableForFree: params.includeSellableForFree,
67
- where: productCountWhere.value,
68
- orFiltersOperator: currentOrFiltersOperator.value
69
- }),
70
- options: { immediate: false },
71
- key: `${key}-productCount`
72
- });
73
- const filtersPromise = useFilters({
74
- params: () => ({
75
- category: currentPath.value,
76
- includedFilters: params.includedFilters,
77
- includeSoldOut: params.includeSoldOut,
78
- includeSellableForFree: params.includeSellableForFree,
79
- where: currentWhereCondition.value,
80
- orFiltersOperator: currentOrFiltersOperator.value
81
- }),
82
- options: { immediate: false },
83
- key: `${key}-filters`
84
- });
85
- const {
86
- data: categoryData,
87
- fetch: refreshCategories,
88
- fetching: categoriesFetching,
89
- error: categoriesError,
90
- status: categoriesStatus
91
- } = categoriesPromise;
92
- const {
93
- data: productData,
94
- fetch: _refreshProducts,
95
- fetching: productsFetching,
96
- error: productError,
97
- status: productStatus
98
- } = productsPromise;
99
- const {
100
- data: productCountData,
101
- fetch: _refreshProductCount,
102
- fetching: productCountFetching,
103
- error: productCountError,
104
- status: productCountStatus
105
- } = productsCountPromise;
106
- const {
107
- data: filterData,
108
- fetch: refreshFilters,
109
- fetching: filtersFetching,
110
- error: filterError,
111
- status: filterStatus
112
- } = filtersPromise;
113
- const categories = computed(() => categoryData.value?.categories);
114
- const selectedCategory = computed(() => categoryData.value?.activeNode);
115
- const pagination = computed(() => productData.value?.pagination);
116
- const products = computed(() => productData.value?.products);
117
- const filters = computed(() => filterData.value?.filters);
118
- const unfilteredCount = computed(() => filterData.value?.unfilteredCount);
119
- const refreshProductCount = async ({
120
- where = void 0
121
- } = {}) => {
122
- productCountWhere.value = where;
123
- if (productCountFetching.value) {
124
- return;
125
- }
126
- await _refreshProductCount();
127
- };
128
- const fetchProducts = async ({
129
- path,
130
- page = 1,
131
- perPage = 20,
132
- where = void 0,
133
- sort = void 0,
134
- pricePromotionKey = "",
135
- cache,
136
- orFiltersOperator = void 0
137
- }) => {
138
- currentPath.value = path;
139
- currentPage.value = page;
140
- currentPerPage.value = perPage;
141
- currentWhereCondition.value = where;
142
- currentSorting.value = sort;
143
- currentPricePromotionKey.value = pricePromotionKey;
144
- currentCacheParams.value = cache;
145
- currentOrFiltersOperator.value = orFiltersOperator;
146
- if (categoriesFetching.value || productsFetching.value || filtersFetching.value) {
147
- return;
148
- }
149
- await Promise.all([
150
- refreshCategories(),
151
- _refreshProducts(),
152
- refreshFilters()
153
- ]);
154
- return true;
155
- };
156
- const filterProducts = async ({
157
- where = void 0,
158
- page,
159
- sort = void 0,
160
- orFiltersOperator = void 0
161
- }) => {
162
- currentWhereCondition.value = where;
163
- currentPage.value = page;
164
- currentSorting.value = sort;
165
- currentOrFiltersOperator.value = orFiltersOperator;
166
- await _refreshProducts();
167
- };
168
- const fetchPage = async (pageToFetch) => {
169
- currentPage.value = pageToFetch;
170
- await _refreshProducts();
171
- };
172
- return extendPromise(
173
- Promise.all([
174
- categoriesPromise,
175
- productsPromise,
176
- productsCountPromise,
177
- filtersPromise
178
- ]).then(() => ({})),
179
- {
180
- // filter data
181
- filters,
182
- filtersFetching,
183
- unfilteredCount,
184
- filterStatus,
185
- filterError,
186
- // filter preview
187
- productCountData,
188
- refreshProductCount,
189
- productCountFetching,
190
- productCountError,
191
- productCountStatus,
192
- // product data
193
- products,
194
- pagination,
195
- productsFetching,
196
- filterProducts,
197
- productError,
198
- productStatus,
199
- // category data
200
- categories,
201
- selectedCategory,
202
- categoriesFetching,
203
- categoriesError,
204
- categoriesStatus,
205
- // other
206
- fetchProducts,
207
- fetchPage
208
- }
209
- );
210
- }
@@ -1,13 +0,0 @@
1
- import { type FilterParams, type TransformedFilter, type Filter, type SortingValueKey } from '@scayle/storefront-core';
2
- type Options = {
3
- defaultSort?: SortingValueKey;
4
- };
5
- /** @deprecated The Storefront Boilerplate contains a `useQueryFilterState` composable you can use instead. **/
6
- export declare function useQueryFilterState(options?: Options): {
7
- activeFilters: import("vue").ComputedRef<Filter>;
8
- applyFilters: (filter?: Filter, scrollToTop?: boolean) => Promise<void>;
9
- isActiveFilter: (filter?: TransformedFilter) => any;
10
- resetFilterUrl: () => Promise<void>;
11
- productConditions: import("vue").ComputedRef<FilterParams>;
12
- };
13
- export {};
@@ -1,78 +0,0 @@
1
- import {
2
- isFilterActive,
3
- transformToWhereCondition,
4
- serializeFilters,
5
- deserializeFilters,
6
- getSortByValue
7
- } from "@scayle/storefront-core";
8
- import { computed } from "vue";
9
- import { getCurrentPage } from "../../utils/route.js";
10
- import { useRoute, useRouter } from "#imports";
11
- const DEFAULT_QUERY_KEYS = ["page", "sort", "term"];
12
- function queryValueToString(value) {
13
- return Array.isArray(value) ? value.map((v) => v?.toString()).filter(Boolean).join(",") : value?.toString();
14
- }
15
- const isEqual = (x, y) => {
16
- if (Object.is(x, y)) {
17
- return true;
18
- }
19
- if (typeof x !== "object" || x === null || typeof y !== "object" || y === null) {
20
- return x === y;
21
- }
22
- const keys = Object.keys(x);
23
- return keys.length === Object.keys(y).length && keys.every((key) => Reflect.has(y, key) && isEqual(x[key], y[key]));
24
- };
25
- export function useQueryFilterState(options = {}) {
26
- const router = useRouter();
27
- const route = useRoute();
28
- const activeFilters = computed(() => {
29
- const allowedFilters = Object.fromEntries(
30
- Object.entries(route.query).filter(
31
- ([key]) => !DEFAULT_QUERY_KEYS.includes(key)
32
- ).map(([key, value]) => [key, queryValueToString(value)]).filter(([_key, value]) => !!value)
33
- );
34
- return deserializeFilters(allowedFilters);
35
- });
36
- const isActiveFilter = (filter) => {
37
- if (!filter) {
38
- return Object.values(activeFilters.value).length === 0;
39
- }
40
- return isFilterActive(activeFilters.value, filter);
41
- };
42
- const applyFilters = async (filter, scrollToTop = true) => {
43
- const newQuery = {
44
- sort: route.query.sort,
45
- term: route.query.term,
46
- ...filter ? serializeFilters(filter) : {}
47
- };
48
- if (isEqual(route.query, newQuery)) {
49
- return;
50
- }
51
- await router.push({
52
- query: { ...newQuery }
53
- });
54
- if (scrollToTop) {
55
- window.scroll({
56
- behavior: "smooth",
57
- top: 0
58
- });
59
- }
60
- };
61
- const resetFilterUrl = async () => {
62
- await router.replace({ query: { term: route.query.term } });
63
- };
64
- const generateFilterParams = () => {
65
- return {
66
- where: { ...transformToWhereCondition(activeFilters.value) },
67
- page: getCurrentPage(route.query),
68
- sort: getSortByValue(route.query?.sort || "", options?.defaultSort)
69
- };
70
- };
71
- return {
72
- activeFilters,
73
- applyFilters,
74
- isActiveFilter,
75
- resetFilterUrl,
76
- productConditions: computed(() => generateFilterParams())
77
- };
78
- }
@@ -1,14 +0,0 @@
1
- import type { SearchInput, SearchOptions, TypeaheadSuggestionsEndpointResponseData } from '@scayle/storefront-core';
2
- type Options = Partial<{
3
- params: SearchOptions;
4
- key: string;
5
- }>;
6
- /** @deprecated `useSearch` is deprecated. Please, use `useSearchSuggestions` or `useSearchResolve` */
7
- export declare function useSearch({ params, key }?: Options): {
8
- data: import("vue").Ref<TypeaheadSuggestionsEndpointResponseData | undefined, TypeaheadSuggestionsEndpointResponseData | undefined>;
9
- pending: import("vue").Ref<boolean, boolean>;
10
- searchQuery: import("vue").Ref<string, string>;
11
- resetSearch: () => void;
12
- search: ({ term, slug, productLimit }: SearchInput) => Promise<void>;
13
- };
14
- export {};
@@ -1,44 +0,0 @@
1
- import { useState } from "nuxt/app";
2
- import { useRpcCall } from "../core/useRpcCall.js";
3
- export function useSearch({ params, key = "search" } = {}) {
4
- const data = useState(
5
- `${key}-data`,
6
- () => void 0
7
- );
8
- const searchQuery = useState(`${key}-searchQuery`, () => "");
9
- const pending = useState(`${key}-pending`, () => false);
10
- const error = useState(`${key}-error`, () => void 0);
11
- const status = useState(`${key}-error`, () => "idle");
12
- const searchProductsRpc = useRpcCall("searchProducts");
13
- const search = async ({ term, slug, productLimit }) => {
14
- pending.value = true;
15
- status.value = "pending";
16
- if (!term) {
17
- return;
18
- }
19
- try {
20
- data.value = await searchProductsRpc({
21
- term: String(term),
22
- slug,
23
- with: params?.with,
24
- productLimit
25
- });
26
- } catch (e) {
27
- error.value = e;
28
- } finally {
29
- pending.value = false;
30
- status.value = error.value ? "error" : "success";
31
- }
32
- };
33
- const resetSearch = () => {
34
- searchQuery.value = "";
35
- data.value = { suggestions: [] };
36
- };
37
- return {
38
- data,
39
- pending,
40
- searchQuery,
41
- resetSearch,
42
- search
43
- };
44
- }