@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.
- package/CHANGELOG.md +484 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/module.d.mts +2 -2
- package/dist/module.d.ts +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +6 -6
- package/dist/runtime/api/rpcHandler.d.ts +4 -6
- package/dist/runtime/campaignKey.d.ts +1 -2
- package/dist/runtime/campaignKey.js +3 -9
- package/dist/runtime/composables/core/useIDP.d.ts +2 -4
- package/dist/runtime/composables/core/useIDP.js +1 -8
- package/dist/runtime/composables/core/useRpc.d.ts +4 -17
- package/dist/runtime/composables/core/useRpc.js +11 -20
- package/dist/runtime/composables/core/useSession.d.ts +1 -1
- package/dist/runtime/composables/core/useUser.d.ts +2 -4
- package/dist/runtime/composables/core/useUser.js +3 -12
- package/dist/runtime/composables/index.d.ts +0 -3
- package/dist/runtime/composables/index.js +0 -3
- package/dist/runtime/composables/storefront/useBasket.d.ts +6 -4
- package/dist/runtime/composables/storefront/useBasket.js +68 -38
- package/dist/runtime/composables/storefront/useBrand.d.ts +2 -4
- package/dist/runtime/composables/storefront/useBrand.js +3 -4
- package/dist/runtime/composables/storefront/useBrands.d.ts +2 -4
- package/dist/runtime/composables/storefront/useBrands.js +3 -4
- package/dist/runtime/composables/storefront/useCategories.d.ts +3 -5
- package/dist/runtime/composables/storefront/useCategories.js +3 -8
- package/dist/runtime/composables/storefront/useCategoryById.d.ts +2 -4
- package/dist/runtime/composables/storefront/useCategoryById.js +3 -4
- package/dist/runtime/composables/storefront/useCategoryByPath.d.ts +2 -4
- package/dist/runtime/composables/storefront/useCategoryByPath.js +3 -4
- package/dist/runtime/composables/storefront/useCurrentPromotions.d.ts +2 -4
- package/dist/runtime/composables/storefront/useCurrentPromotions.js +3 -4
- package/dist/runtime/composables/storefront/useFilters.d.ts +2 -4
- package/dist/runtime/composables/storefront/useFilters.js +3 -4
- package/dist/runtime/composables/storefront/useNavigationTree.d.ts +3 -11
- package/dist/runtime/composables/storefront/useNavigationTree.js +6 -9
- package/dist/runtime/composables/storefront/useNavigationTrees.d.ts +2 -4
- package/dist/runtime/composables/storefront/useNavigationTrees.js +3 -4
- package/dist/runtime/composables/storefront/useOrder.d.ts +3 -5
- package/dist/runtime/composables/storefront/useOrder.js +3 -5
- package/dist/runtime/composables/storefront/useOrderConfirmation.d.ts +3 -5
- package/dist/runtime/composables/storefront/useOrderConfirmation.js +2 -2
- package/dist/runtime/composables/storefront/useProduct.d.ts +2 -4
- package/dist/runtime/composables/storefront/useProduct.js +3 -4
- package/dist/runtime/composables/storefront/useProducts.d.ts +2 -4
- package/dist/runtime/composables/storefront/useProducts.js +3 -4
- package/dist/runtime/composables/storefront/useProductsByIds.d.ts +2 -4
- package/dist/runtime/composables/storefront/useProductsByIds.js +3 -4
- package/dist/runtime/composables/storefront/useProductsByReferenceKeys.d.ts +2 -4
- package/dist/runtime/composables/storefront/useProductsByReferenceKeys.js +3 -4
- package/dist/runtime/composables/storefront/useProductsCount.d.ts +2 -4
- package/dist/runtime/composables/storefront/useProductsCount.js +3 -4
- package/dist/runtime/composables/storefront/usePromotions.d.ts +2 -4
- package/dist/runtime/composables/storefront/usePromotions.js +3 -4
- package/dist/runtime/composables/storefront/usePromotionsByIds.d.ts +2 -4
- package/dist/runtime/composables/storefront/usePromotionsByIds.js +3 -4
- package/dist/runtime/composables/storefront/useShopConfiguration.d.ts +1 -3
- package/dist/runtime/composables/storefront/useShopConfiguration.js +3 -4
- package/dist/runtime/composables/storefront/useStorefrontSearch.d.ts +5 -3
- package/dist/runtime/composables/storefront/useStorefrontSearch.js +3 -5
- package/dist/runtime/composables/storefront/useUserAddresses.d.ts +1 -3
- package/dist/runtime/composables/storefront/useUserAddresses.js +3 -4
- package/dist/runtime/composables/storefront/useVariant.d.ts +2 -4
- package/dist/runtime/composables/storefront/useVariant.js +3 -4
- package/dist/runtime/composables/storefront/useWishlist.d.ts +2 -3
- package/dist/runtime/composables/storefront/useWishlist.js +12 -21
- package/dist/runtime/context.js +1 -5
- package/dist/runtime/createLog.d.ts +1 -1
- package/dist/runtime/error/handler.d.ts +1 -1
- package/dist/runtime/error/handler.js +1 -28
- package/dist/runtime/nitro/plugins/nitroRuntimeStorageConfig.js +5 -93
- package/dist/runtime/plugin/shop.d.ts +4 -4
- package/dist/runtime/rpc/rpcCall.d.ts +1 -1
- package/dist/runtime/server/middleware/bootstrap-utils.d.ts +1 -5
- package/dist/runtime/server/middleware/bootstrap-utils.js +2 -4
- package/dist/runtime/server/middleware/bootstrap.js +3 -5
- package/dist/runtime/server/utils/cacheStorage.d.ts +1 -1
- package/dist/runtime/server/utils/cacheStorage.js +2 -2
- package/dist/runtime/utils/zodSchema.d.ts +467 -1840
- package/dist/runtime/utils/zodSchema.js +34 -83
- package/dist/shared/{storefront-nuxt.80aa5060.d.ts → storefront-nuxt.a816664e.d.mts} +4 -25
- package/dist/shared/{storefront-nuxt.80aa5060.d.mts → storefront-nuxt.a816664e.d.ts} +4 -25
- package/dist/test/factories.d.mts +1 -1
- package/dist/test/factories.d.ts +1 -1
- package/dist/test/factories.mjs +0 -2
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +9 -9
- package/dist/runtime/composables/storefront/useFacet.d.ts +0 -100
- package/dist/runtime/composables/storefront/useFacet.js +0 -210
- package/dist/runtime/composables/storefront/useQueryFilterState.d.ts +0 -13
- package/dist/runtime/composables/storefront/useQueryFilterState.js +0 -78
- package/dist/runtime/composables/storefront/useSearch.d.ts +0 -14
- package/dist/runtime/composables/storefront/useSearch.js +0 -44
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,489 @@
|
|
|
1
1
|
# @scayle/storefront-nuxt
|
|
2
2
|
|
|
3
|
+
## 8.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- **\[💥 BREAKING\]** Removed deprecated `transformLegacyConfig` function in favor of the new unified `storefront.storage` configuration system.
|
|
8
|
+
Legacy configuration options `provider` and `redis` configuration are no longer supported and have been deprecated since Storefront Boilerplate v1.0.0-rc.05.
|
|
9
|
+
|
|
10
|
+
You'll need to migrate your existing storage settings to the new `storefront.storage` format.
|
|
11
|
+
Check the [SCAYLE Resource Center](https://scayle.dev/en/storefront-guide/developer-guide/basic-setup/introduction#storage) for more details.
|
|
12
|
+
|
|
13
|
+
- _No Longer Supported: Legacy Storage Setup in (`nuxt.config.ts`):_
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
export default defineNuxtConfig({
|
|
17
|
+
// ...
|
|
18
|
+
runtimeConfig: {
|
|
19
|
+
// ...
|
|
20
|
+
storefront: {
|
|
21
|
+
// ...
|
|
22
|
+
redis: {
|
|
23
|
+
host: 'localhost',
|
|
24
|
+
port: 6379,
|
|
25
|
+
prefix: '',
|
|
26
|
+
user: '',
|
|
27
|
+
password: '',
|
|
28
|
+
sslTransit: false,
|
|
29
|
+
},
|
|
30
|
+
// ...
|
|
31
|
+
session: {
|
|
32
|
+
// ...
|
|
33
|
+
provider: 'redis',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
// ...
|
|
37
|
+
},
|
|
38
|
+
// ...
|
|
39
|
+
})
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
- _Current Unified Storage Approach (`nuxt.config.ts`):_
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
export default defineNuxtConfig({
|
|
46
|
+
// ...
|
|
47
|
+
runtimeConfig: {
|
|
48
|
+
// ...
|
|
49
|
+
storefront: {
|
|
50
|
+
// ...
|
|
51
|
+
storage: {
|
|
52
|
+
cache: {
|
|
53
|
+
driver: 'redis',
|
|
54
|
+
host: 'localhost',
|
|
55
|
+
port: 6379,
|
|
56
|
+
},
|
|
57
|
+
session: {
|
|
58
|
+
driver: 'redis',
|
|
59
|
+
host: 'localhost',
|
|
60
|
+
port: 6379,
|
|
61
|
+
},
|
|
62
|
+
// ...
|
|
63
|
+
},
|
|
64
|
+
// ...
|
|
65
|
+
},
|
|
66
|
+
// ...
|
|
67
|
+
},
|
|
68
|
+
// ...
|
|
69
|
+
})
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
- **\[💥 BREAKING\]** The composable `useSearch` has been replaced by `useStorefrontSearch`, consolidating and transitioning to SCAYLE Search v2.
|
|
73
|
+
|
|
74
|
+
- _Previous Usage of `useSearch`:_
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
const { search, data } = useSearch({ params: { with: ...}, key: 'search' })
|
|
78
|
+
|
|
79
|
+
search({term: 'searchTerm', slug: 'slug', productLimit: 10})
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
- _Current Usage of `useStorefrontSearch`:_
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
const searchTerm = ref()
|
|
86
|
+
|
|
87
|
+
const { data, resolveSearch } = useStorefrontSearch(searchTerm, { categoryId: ..., with: { ... } }, 'search')
|
|
88
|
+
//data contains search suggestions
|
|
89
|
+
|
|
90
|
+
resolveSearch()
|
|
91
|
+
//data contains search results
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
- **\[💥 BREAKING\]** The previous use of the `useFacet` composable for category-related product listings was overly complex and difficult to customize. To simplify things, dedicated composables are being introduced:
|
|
95
|
+
|
|
96
|
+
- `useProductsByCategory`: Replaces `useFacet` for fetching products within a specific category.
|
|
97
|
+
- `useFilters` or `useProductListFilters`: Provide focused filter management capabilities.
|
|
98
|
+
|
|
99
|
+
- _Previous Usage of `useFacet`:_
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
const {products, category, filters, ...} = useFacet()
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
- _Current Usage of dedicated Category-Specific Composables:_
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
const { data: category } = useCategoryById({
|
|
109
|
+
params: {
|
|
110
|
+
id,
|
|
111
|
+
children: 0,
|
|
112
|
+
properties: { withName: ['sale'] },
|
|
113
|
+
},
|
|
114
|
+
}, 'current-category-id')
|
|
115
|
+
|
|
116
|
+
const {
|
|
117
|
+
products,
|
|
118
|
+
pagination,
|
|
119
|
+
fetching,
|
|
120
|
+
totalProductsCount,
|
|
121
|
+
paginationOffset,
|
|
122
|
+
} = useProductsByCategory(currentCategoryId, route)
|
|
123
|
+
|
|
124
|
+
const { availableFilters } = useFilters({
|
|
125
|
+
...
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
- **\[💥 BREAKING\]** We've renamed the `useNavigationTree` composable to `useNavigationTreeById` for better clarity. Its functionality, parameters and return values stay identical.
|
|
130
|
+
- **\[💥 BREAKING\]** The composable `useQueryFilterState` has been superseded by the `useFilter` and `useAppliedFilters` (part of `@scayle/storefront-product-listing`) composables.
|
|
131
|
+
|
|
132
|
+
- _Previous Usage of `useQueryFilterState`:_
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
const { activeFilters, applyFilters, resetFilterUrl, productConditions } =
|
|
136
|
+
useQueryFilterState()
|
|
137
|
+
|
|
138
|
+
applyFilters({ brand: 23, sale: true, maxPrice: 100, minPrice: 0 })
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
- _Current Usage of `useFilter` and `useAppliedFilters`:_
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
const {
|
|
145
|
+
applyPriceFilter,
|
|
146
|
+
applyBooleanFilter,
|
|
147
|
+
applyAttributeFilter,
|
|
148
|
+
resetFilters,
|
|
149
|
+
resetPriceFilter,
|
|
150
|
+
resetFilter,
|
|
151
|
+
} = useFilter()
|
|
152
|
+
|
|
153
|
+
applyPriceFilter([0, 100])
|
|
154
|
+
applyBooleanFilter('sale', true)
|
|
155
|
+
applyAttributeFilter('brand', 23)
|
|
156
|
+
|
|
157
|
+
const route = useRoute()
|
|
158
|
+
const {
|
|
159
|
+
appliedFilter,
|
|
160
|
+
appliedFiltersCount,
|
|
161
|
+
appliedAttributeValues,
|
|
162
|
+
appliedBooleanValues,
|
|
163
|
+
areFiltersApplied,
|
|
164
|
+
} = useAppliedFilters(route)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
- **\[💥 BREAKING\]** The `getBadgeLabel` helper function has been removed, giving you more control over badge label display.
|
|
168
|
+
|
|
169
|
+
- **Note:** This change doesn't affect projects using SCAYLE Storefront Boilerplate v1.0 or later.
|
|
170
|
+
- For applications based on older versions or using `getBadgeLabel`, you can refer to the previous implementation below:
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
const BadgeLabel = {
|
|
174
|
+
NEW: 'new',
|
|
175
|
+
SOLD_OUT: 'sold_out',
|
|
176
|
+
ONLINE_EXCLUSIVE: 'online_exclusive',
|
|
177
|
+
SUSTAINABLE: 'sustainable',
|
|
178
|
+
PREMIUM: 'premium',
|
|
179
|
+
DEFAULT: '',
|
|
180
|
+
} as const
|
|
181
|
+
|
|
182
|
+
type BadgeLabelParamsKeys =
|
|
183
|
+
| 'isNew'
|
|
184
|
+
| 'isSoldOut'
|
|
185
|
+
| 'isOnlineOnly'
|
|
186
|
+
| 'isSustainable'
|
|
187
|
+
| 'isPremium'
|
|
188
|
+
type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean>>
|
|
189
|
+
|
|
190
|
+
const getBadgeLabel = (params: BadgeLabelParams = {}): string => {
|
|
191
|
+
if (!params) {
|
|
192
|
+
return BadgeLabel.DEFAULT
|
|
193
|
+
}
|
|
194
|
+
const { isNew, isSoldOut, isOnlineOnly, isSustainable, isPremium } =
|
|
195
|
+
params
|
|
196
|
+
|
|
197
|
+
if (isNew) {
|
|
198
|
+
return BadgeLabel.NEW
|
|
199
|
+
} else if (isSoldOut) {
|
|
200
|
+
return BadgeLabel.SOLD_OUT
|
|
201
|
+
} else if (isOnlineOnly) {
|
|
202
|
+
return BadgeLabel.ONLINE_EXCLUSIVE
|
|
203
|
+
} else if (isSustainable) {
|
|
204
|
+
return BadgeLabel.SUSTAINABLE
|
|
205
|
+
} else if (isPremium) {
|
|
206
|
+
return BadgeLabel.PREMIUM
|
|
207
|
+
} else {
|
|
208
|
+
return BadgeLabel.DEFAULT
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
- **\[💥 BREAKING\]** The `store` option in the module configuration has been removed. `œscayle/storefront-nuxt@7.84.0` introduced the `shops` option as a replacement, but maintained backward compatibility with the `store` option. Going forward, configuring shops must be done using the `shops` keyword.
|
|
214
|
+
|
|
215
|
+
- For more information, please refer to the [documentation](https://scayle.dev/en/storefront-guide/developer-guide/basic-setup/introduction#shops).
|
|
216
|
+
- **NOTE:** These changes might impact your environment variables used for deployments. Please check your infrastructure and deployment setup and adapt accordingly!
|
|
217
|
+
- _Previous Store Configuration in `nuxt.config.ts`:_
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
export default defineNuxtConfig({
|
|
221
|
+
// ...
|
|
222
|
+
runtimeConfig: {
|
|
223
|
+
// ...
|
|
224
|
+
storefront: {
|
|
225
|
+
// ...
|
|
226
|
+
store: {
|
|
227
|
+
// ...
|
|
228
|
+
},
|
|
229
|
+
// ...
|
|
230
|
+
},
|
|
231
|
+
// ...
|
|
232
|
+
},
|
|
233
|
+
// ...
|
|
234
|
+
})
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
- _Previous Environment Variables for Store Configuration:_
|
|
238
|
+
|
|
239
|
+
```env
|
|
240
|
+
NUXT_STOREFRONT_STORE_{UNIQUE_IDENTIFIER}_CHECKOUT_USER=''
|
|
241
|
+
NUXT_STOREFRONT_STORE_{UNIQUE_IDENTIFIER}_CHECKOUT_TOKEN=''
|
|
242
|
+
NUXT_STOREFRONT_STORE_{UNIQUE_IDENTIFIER}_CHECKOUT_SECRET=''
|
|
243
|
+
NUXT_STOREFRONT_STORE_{UNIQUE_IDENTIFIER}_CHECKOUT_HOST=''
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
- _Current Shops Configuration in `nuxt.config.ts`:_
|
|
247
|
+
|
|
248
|
+
```ts
|
|
249
|
+
export default defineNuxtConfig({
|
|
250
|
+
// ...
|
|
251
|
+
runtimeConfig: {
|
|
252
|
+
// ...
|
|
253
|
+
storefront: {
|
|
254
|
+
// ...
|
|
255
|
+
shops: {
|
|
256
|
+
// ...
|
|
257
|
+
},
|
|
258
|
+
// ...
|
|
259
|
+
},
|
|
260
|
+
// ...
|
|
261
|
+
},
|
|
262
|
+
// ...
|
|
263
|
+
})
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
- _Current Environment Variables for Shops Configuration:_
|
|
267
|
+
|
|
268
|
+
```env
|
|
269
|
+
NUXT_STOREFRONT_SHOPS_{UNIQUE_IDENTIFIER}_CHECKOUT_USER=''
|
|
270
|
+
NUXT_STOREFRONT_SHOPS_{UNIQUE_IDENTIFIER}_CHECKOUT_TOKEN=''
|
|
271
|
+
NUXT_STOREFRONT_SHOPS_{UNIQUE_IDENTIFIER}_CHECKOUT_SECRET=''
|
|
272
|
+
NUXT_STOREFRONT_SHOPS_{UNIQUE_IDENTIFIER}_CHECKOUT_HOST=''
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
- **\[💥 BREAKING\]** To better align with the current Nuxt 3 architecture make key handling more explicit, we've simplified how you interact with the key parameter in RPC composables from version 8 onwards.
|
|
276
|
+
Instead of placing the key within the composable's options object, you'll now provide it as the second argument when calling the composable.
|
|
277
|
+
|
|
278
|
+
- _Previous `key` as options parameter:_
|
|
279
|
+
|
|
280
|
+
```ts
|
|
281
|
+
useProduct({
|
|
282
|
+
// ...
|
|
283
|
+
key: 'productKey',
|
|
284
|
+
})
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
- _Current `key` as dedicated composables argument:_
|
|
288
|
+
|
|
289
|
+
```ts
|
|
290
|
+
useProduct(
|
|
291
|
+
{
|
|
292
|
+
// ...
|
|
293
|
+
},
|
|
294
|
+
'productKey',
|
|
295
|
+
)
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
- **\[💥 BREAKING\]** Introducing a new feature flag `storefront.legacy.enableSessionMigration` to control the automatic migration of legacy session data, set to `false` by default. Starting with `@scayle/storefront-nuxt@7.68.0` Storefront uses unique session cookie names for each shop, simplifying implementation and enhancing stability.
|
|
299
|
+
Instead of relying on the Path attribute, each shop receives a distinct cookie name. This change is internal and should not require code modifications.
|
|
300
|
+
|
|
301
|
+
- _Cookie format before `@scayle/storefront-nuxt@7.68.0`:_
|
|
302
|
+
- `Set-Cookie: $session=s:fa3746f9-88c8-4065-a6c9-0c7bee473dd8.pSoaN6Q7iFHHyWKE7s9gQAqdDzGb9fS8a478P7PHLxw; Path=/de`
|
|
303
|
+
- _Cookie format after `@scayle/storefront-nuxt@7.68.0`:_
|
|
304
|
+
- `Set-Cookie: $session-1001=s:fa3746f9-88c8-4065-a6c9-0c7bee473dd8.pSoaN6Q7iFHHyWKE7s9gQAqdDzGb9fS8a478P7PHLxw; Path=/`
|
|
305
|
+
- **NOTE:** Upgrading directly to this version from a version prior to `@scayle/storefront-nuxt@7.68.0` without enabling the `storefront.legacy.enableSessionMigration` feature flag will lead to loss of user sessions. Ensure version `@scayle/storefront-nuxt@7.68.0` or higher has been deployed in production for a period exceeding the configured session TTL before upgrading to this version. This ensures all legacy sessions have been migrated. Consult the updated documentation for details on the cookie format changes and migration procedures.
|
|
306
|
+
|
|
307
|
+
- **\[💥 BREAKING\]** We've optimized the way Identity Provider (IDP) logins are handled. Instead of using the `handleIDPLoginCallback` RPC method, which has been removed, from the `useIDP` composable, you'll now use the `loginIDP` function, which has been moved to the `useAuthentication` composable. This change consolidates IDP login functionality within `useAuthentication` for a more unified approach.
|
|
308
|
+
|
|
309
|
+
- _Previous Usage of `handleIDPLoginCallback`:_
|
|
310
|
+
|
|
311
|
+
```ts
|
|
312
|
+
const { handleIDPLoginCallback } = await useIDP()
|
|
313
|
+
|
|
314
|
+
watch(
|
|
315
|
+
() => route.query,
|
|
316
|
+
async (query) => {
|
|
317
|
+
if (query.code && isString(query.code)) {
|
|
318
|
+
await handleIDPLoginCallback(query.code)
|
|
319
|
+
}
|
|
320
|
+
},
|
|
321
|
+
{ immediate: true },
|
|
322
|
+
)
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
- _Current Usage of `loginIDP`:_
|
|
326
|
+
|
|
327
|
+
```ts
|
|
328
|
+
const { loginIDP } = useAuthentication('login')
|
|
329
|
+
|
|
330
|
+
onMounted(async () => {
|
|
331
|
+
await loginIDP(props.code)
|
|
332
|
+
})
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
- **\[🧹 NON-BREAKING\]** Addressed various type resolution errors that were present when using the `@scayle/storefront-nuxt` package with different Node.js versions and module systems. These errors manifested as internal resolution errors or ESM dynamic import only warnings. With this fix, the package now more consistently resolves types correctly across Node.js 16 (CJS and ESM), and bundlers, ensuring a smoother developer experience.
|
|
336
|
+
- **\[💥 BREAKING\]** The `useBasket` composable now gracefully handles cases where adding items to the basket results in a smaller quantity being added than originally requested by checking against `AddToBasketFailureKind`.
|
|
337
|
+
- **\[💥 BREAKING\]** The deprecated `autoFetch` option of `useRpc` has been removed in favor of the `immediate` option. This also applies to all data fetching composables provided by `@scayle/storefront-nuxt`.
|
|
338
|
+
|
|
339
|
+
- _Previous `useRpc` with `autoFetch`:_
|
|
340
|
+
|
|
341
|
+
```ts
|
|
342
|
+
useRpc('rpcMethod', key, params, { autoFetch: true })
|
|
343
|
+
|
|
344
|
+
useUser({ autoFetch: true })
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
- _Current `useRpc` with `immediate`:_
|
|
348
|
+
|
|
349
|
+
```ts
|
|
350
|
+
useRpc('rpcMethod', key, params, { immediate: true })
|
|
351
|
+
|
|
352
|
+
useUser({ immediate: true })
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
- **\[💥 BREAKING\]** The attribute `isCmsPreview` has been removed from `RpcContext`.
|
|
356
|
+
- **\[💥 BREAKING\]** The attribute `storeCampaignKeyword` has been removed from `RpcContext`.
|
|
357
|
+
|
|
358
|
+
- The `campaignKey` is now automatically determined by fetching campaign data through the Storefront API client by retrieving a list of all campaigns from the API. It then narrows down the list by filtering for campaigns that are still active, ensuring any returned campaign is currently running. These active campaigns are then sorted by their start date, ensuring chronological order. Finally, it iterates through the sorted campaigns to find the first one that is currently active, returning its key as an identifier. If no active campaign is found or an error occurs, it returns nothing.
|
|
359
|
+
- The `storeCampaignKeyword` is also no longer used to determine the active campaign key. The functionality to run only certain campaigns for specific countries is now supported through the SCAYLE Panel out of the box.
|
|
360
|
+
|
|
361
|
+
- **\[💥 BREAKING\]** The composable `useStorefrontSearch` is now consistent with `useRpc` return values. The `fetching` boolean is replaced by `status` with states `idle`, `pending`, `error` or `success`.
|
|
362
|
+
|
|
363
|
+
- _Previous `useStorefrontSearch` returning `fetching`:_
|
|
364
|
+
|
|
365
|
+
```ts
|
|
366
|
+
const {
|
|
367
|
+
data,
|
|
368
|
+
resolveSearch,
|
|
369
|
+
getSearchSuggestions,
|
|
370
|
+
fetching,
|
|
371
|
+
...searchData
|
|
372
|
+
} = useStorefrontSearch(searchQuery, { key })
|
|
373
|
+
|
|
374
|
+
fetching.value // true or false
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
- _Current `useStorefrontSearch` returning `status`:_
|
|
378
|
+
|
|
379
|
+
```ts
|
|
380
|
+
const { data, resolveSearch, getSearchSuggestions, status, ...searchData } =
|
|
381
|
+
useStorefrontSearch(searchQuery, {}, key)
|
|
382
|
+
|
|
383
|
+
status.value // 'idle', 'pending', 'error' or 'success'
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
- **\[💥 BREAKING\]** We've simplified composable caching and clarified the control you have over shared state behavior. The configuration option `disableDefaultGetCachedDataOverride` has been replaced with `legacy.enableDefaultGetCachedDataOverride`, and its logic has been reversed. Now, when `legacy.enableDefaultGetCachedDataOverride` is not set or set to `false`, the default behavior maintains the shared state functionality of `useRpc`, where multiple calls with the same key use the same cached data. Setting the option to `true` bypasses this shared caching, providing data isolation between calls. To maintain your existing caching behavior, simply change the value of `disableDefaultGetCachedDataOverride` to its opposite in your `nuxt.config.ts` file.
|
|
387
|
+
|
|
388
|
+
Old config
|
|
389
|
+
|
|
390
|
+
- _Previous `disableDefaultGetCachedDataOverride` in `nuxt.config.ts`:_
|
|
391
|
+
|
|
392
|
+
```ts
|
|
393
|
+
export default defineNuxtConfig({
|
|
394
|
+
// ...
|
|
395
|
+
runtimeConfig: {
|
|
396
|
+
// ...
|
|
397
|
+
public: {
|
|
398
|
+
// ...
|
|
399
|
+
storefront: {
|
|
400
|
+
// ...
|
|
401
|
+
disableDefaultGetCachedDataOverride: false,
|
|
402
|
+
},
|
|
403
|
+
// ...
|
|
404
|
+
},
|
|
405
|
+
// ...
|
|
406
|
+
},
|
|
407
|
+
// ...
|
|
408
|
+
})
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
- _Current `enableDefaultGetCachedDataOverride`in `nuxt.config.ts`:_
|
|
412
|
+
|
|
413
|
+
```ts
|
|
414
|
+
export default defineNuxtConfig({
|
|
415
|
+
// ...
|
|
416
|
+
runtimeConfig: {
|
|
417
|
+
// ...
|
|
418
|
+
public: {
|
|
419
|
+
// ...
|
|
420
|
+
storefront: {
|
|
421
|
+
// ...
|
|
422
|
+
legacy: {
|
|
423
|
+
// ...
|
|
424
|
+
enableDefaultGetCachedDataOverride: true,
|
|
425
|
+
},
|
|
426
|
+
// ...
|
|
427
|
+
},
|
|
428
|
+
// ...
|
|
429
|
+
},
|
|
430
|
+
// ...
|
|
431
|
+
},
|
|
432
|
+
// ...
|
|
433
|
+
})
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
- **\[💥 BREAKING\]** The `useRpc` composable has been updated to provide a more modern and robust data fetching experience, aligning its interface with the current and underlying [Nuxt 3 `useAsyncData`.](https://nuxt.com/docs/api/composables/use-async-data#return-values).
|
|
437
|
+
The separate `fetch` function has been replaced with a single, intuitive `refresh` function that can be used to refresh the data returned by the `handler` function.
|
|
438
|
+
Additionally, the boolean `pending` flag has been superseded by a more informative `status` return value, offering greater insight into the fetching lifecycle with possible states: `idle`, `pending`, `success`, and `error`.
|
|
439
|
+
These changes enhance the developer experience and provide greater clarity and control over data fetching operations within components.
|
|
440
|
+
|
|
441
|
+
- **NOTE:** This update not only impacts the `useRpc` composable directly, but also extends to other RPC composables relying on it, such as `useProducts` and `useCategories`!
|
|
442
|
+
|
|
443
|
+
- **\[💥 BREAKING\]** Removed special handling for `BAPIError` and `BaseError` thrown in RPC methods. These custom `Error` classes were previously used in RPC methods to allow customizing the status code and message of errors.
|
|
444
|
+
However, they have been deprecated since January 2024 when the preferred approach was changed to return the native `Response` object. This provides performance benefits by limiting the transformations necessary in the response pipeline, and aligns `@scayle/storefront-nuxt` with web standards. It also simplifies the implementation and means `@scayle/storefront-nuxt` no longer needs to be aware of third-party libraries used and their possible errors.
|
|
445
|
+
In this release, the legacy special handling for `BAPIError` and `BaseError` has been removed. Now they will be treated like any other `Error`. If they are thrown uncaught during the execution of an RPC method, a 500 status code will be used in the response. They have also been removed from `@scayle/storefront-nuxt`.
|
|
446
|
+
For most users, this change will have no impact as the core RPC methods have been updated for some time. However, if you have custom RPC methods you should review their implementation.
|
|
447
|
+
In order to have an RPC method use a specific status code, it should return a `Response` object.
|
|
448
|
+
|
|
449
|
+
- _Previous Usage with `BaseError`:_
|
|
450
|
+
|
|
451
|
+
```ts
|
|
452
|
+
function myCustomRpc() {
|
|
453
|
+
// ...
|
|
454
|
+
|
|
455
|
+
throw new BaseError(404)
|
|
456
|
+
}
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
- _Current Usage with `Response` object and `status` code:_
|
|
460
|
+
|
|
461
|
+
```ts
|
|
462
|
+
function myCustomRpc() {
|
|
463
|
+
// ...
|
|
464
|
+
|
|
465
|
+
return new Response(null, { status: 404 })
|
|
466
|
+
}
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
- **\[💥 BREAKING\]** We've updated how API routes are structured in multi-shop environments using path-based selection (`path` or `path_except_default`). Instead of being nested under each shop's specific path, all API routes will now be mounted globally under a single path, which defaults to `/api`. This means the option to customize the `apiBasePath` on a per-shop basis has been removed. This change promotes consistency and makes API route management more straightforward.
|
|
470
|
+
- **\[💥 BREAKING\]** The methods `getBasket`, `removeItemFromBasket`, `addItemsToBasket`, and `addItemToBasket` have been updated. Instead of returning the basket object directly, the basket will now be accessible as a property within the response body. Furthermore, errors occurring during`addItemToBasket` and `addItemsToBasket` will from now on return HTTP 400. The error kind can be identified by checking the `error` property of the response.
|
|
471
|
+
|
|
472
|
+
### Patch Changes
|
|
473
|
+
|
|
474
|
+
- Updated dependency `@vueuse/core@11.3.0` to `@vueuse/core@12.0.0`
|
|
475
|
+
**Dependencies**
|
|
476
|
+
|
|
477
|
+
- Updated dependency to @scayle/storefront-core@8.0.0
|
|
478
|
+
|
|
479
|
+
## 7.95.4
|
|
480
|
+
|
|
481
|
+
### Patch Changes
|
|
482
|
+
|
|
483
|
+
**Dependencies**
|
|
484
|
+
|
|
485
|
+
- Updated dependency to @scayle/storefront-core@7.69.3
|
|
486
|
+
|
|
3
487
|
## 7.95.3
|
|
4
488
|
|
|
5
489
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { d as AdditionalShopConfig, A as AppKeys, h as CheckoutEvent, C as CheckoutShopConfig, M as ModuleBaseOptions, i as ModulePublicRuntimeConfig, P as PublicShopConfig, c as SapiConfig, S as SessionConfig, e as ShopConfig, f as ShopConfigIndexed, b as StorageConfig, a as StorageEntity, g as StorefrontConfig } from './shared/storefront-nuxt.a816664e.mjs';
|
|
2
2
|
export { rpcCall } from '../dist/runtime/rpc/rpcCall.js';
|
|
3
3
|
export { extendPromise } from '../dist/runtime/utils/promise.js';
|
|
4
4
|
export * from '../dist/runtime/utils/seo.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { d as AdditionalShopConfig, A as AppKeys, h as CheckoutEvent, C as CheckoutShopConfig, M as ModuleBaseOptions, i as ModulePublicRuntimeConfig, P as PublicShopConfig, c as SapiConfig, S as SessionConfig, e as ShopConfig, f as ShopConfigIndexed, b as StorageConfig, a as StorageEntity, g as StorefrontConfig } from './shared/storefront-nuxt.a816664e.js';
|
|
2
2
|
export { rpcCall } from '../dist/runtime/rpc/rpcCall.js';
|
|
3
3
|
export { extendPromise } from '../dist/runtime/utils/promise.js';
|
|
4
4
|
export * from '../dist/runtime/utils/seo.js';
|
package/dist/module.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { M as ModuleBaseOptions } from './shared/storefront-nuxt.
|
|
3
|
-
export {
|
|
2
|
+
import { M as ModuleBaseOptions } from './shared/storefront-nuxt.a816664e.mjs';
|
|
3
|
+
export { d as AdditionalShopConfig, A as AppKeys, h as CheckoutEvent, C as CheckoutShopConfig, i as ModulePublicRuntimeConfig, P as PublicShopConfig, c as SapiConfig, S as SessionConfig, e as ShopConfig, f as ShopConfigIndexed, b as StorageConfig, a as StorageEntity, g as StorefrontConfig } from './shared/storefront-nuxt.a816664e.mjs';
|
|
4
4
|
export { LogLevel } from '@scayle/storefront-core';
|
|
5
5
|
import '@scayle/unstorage-compression-driver';
|
|
6
6
|
import 'unstorage';
|
package/dist/module.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { M as ModuleBaseOptions } from './shared/storefront-nuxt.
|
|
3
|
-
export {
|
|
2
|
+
import { M as ModuleBaseOptions } from './shared/storefront-nuxt.a816664e.js';
|
|
3
|
+
export { d as AdditionalShopConfig, A as AppKeys, h as CheckoutEvent, C as CheckoutShopConfig, i as ModulePublicRuntimeConfig, P as PublicShopConfig, c as SapiConfig, S as SessionConfig, e as ShopConfig, f as ShopConfigIndexed, b as StorageConfig, a as StorageEntity, g as StorefrontConfig } from './shared/storefront-nuxt.a816664e.js';
|
|
4
4
|
export { LogLevel } from '@scayle/storefront-core';
|
|
5
5
|
import '@scayle/unstorage-compression-driver';
|
|
6
6
|
import 'unstorage';
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -12,10 +12,7 @@ function stringToBoolean(value, defaultValue = false) {
|
|
|
12
12
|
function getUsedDrivers(options) {
|
|
13
13
|
const drivers = /* @__PURE__ */ new Set();
|
|
14
14
|
drivers.add("memory");
|
|
15
|
-
const shops =
|
|
16
|
-
if (options.redis || Object.values(shops).some((shop) => shop.redis)) {
|
|
17
|
-
drivers.add("redis");
|
|
18
|
-
}
|
|
15
|
+
const shops = options.shops ?? {};
|
|
19
16
|
const addDriver = (config) => {
|
|
20
17
|
if (config?.cache?.driver) {
|
|
21
18
|
drivers.add(config.cache.driver);
|
|
@@ -48,7 +45,7 @@ export default {
|
|
|
48
45
|
}`;
|
|
49
46
|
}
|
|
50
47
|
const PACKAGE_NAME = "@scayle/storefront-nuxt";
|
|
51
|
-
const PACKAGE_VERSION = "
|
|
48
|
+
const PACKAGE_VERSION = "8.0.0";
|
|
52
49
|
const logger = createConsola({
|
|
53
50
|
fancy: true,
|
|
54
51
|
formatOptions: {
|
|
@@ -100,6 +97,9 @@ const module = defineNuxtModule({
|
|
|
100
97
|
basketKey: "basket_{shopId}_{userId}",
|
|
101
98
|
hashAlgorithm: "sha256"
|
|
102
99
|
},
|
|
100
|
+
legacy: {
|
|
101
|
+
enableSessionMigration: false
|
|
102
|
+
},
|
|
103
103
|
internalAccessHeader: ""
|
|
104
104
|
},
|
|
105
105
|
setup(options, nuxt) {
|
|
@@ -176,7 +176,7 @@ Missing RPC Overrides: ${Array.from(overridenRPCMethodNames).map((name) => `'${n
|
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
178
|
const shops = convertShopsToList(
|
|
179
|
-
|
|
179
|
+
nuxt.options.runtimeConfig.storefront.shops ?? {}
|
|
180
180
|
);
|
|
181
181
|
const shopSelector = nuxt.options.runtimeConfig.storefront.shopSelector;
|
|
182
182
|
if (shopSelector === "path" || shopSelector === "path_or_default") {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<string | true | import("@scayle/storefront-core").ShopUser | string[] | import("@scayle/storefront-api").Product | import("@scayle/storefront-api").Product[] | {
|
|
1
|
+
declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<string | true | import("@scayle/storefront-core").ShopUser | string[] | Response | import("@scayle/storefront-api").Product | import("@scayle/storefront-api").Product[] | {
|
|
2
2
|
count: number;
|
|
3
3
|
} | {
|
|
4
4
|
filters: import("@scayle/storefront-api").FiltersEndpointResponseData;
|
|
@@ -15,9 +15,7 @@ declare const _default: import("h3").EventHandler<import("h3").EventHandlerReque
|
|
|
15
15
|
next: number;
|
|
16
16
|
last: number;
|
|
17
17
|
};
|
|
18
|
-
} |
|
|
19
|
-
type: "failure";
|
|
20
|
-
statusCode: number;
|
|
18
|
+
} | {
|
|
21
19
|
basket: import("@scayle/storefront-api").BasketResponseData<import("@scayle/storefront-api").Product, import("@scayle/storefront-api").Variant>;
|
|
22
20
|
} | {
|
|
23
21
|
readonly type: "success";
|
|
@@ -32,9 +30,9 @@ declare const _default: import("h3").EventHandler<import("h3").EventHandlerReque
|
|
|
32
30
|
} | import("@scayle/storefront-api").Category | {
|
|
33
31
|
categories: import("@scayle/storefront-api").Category;
|
|
34
32
|
activeNode: import("@scayle/storefront-api").Category;
|
|
35
|
-
} | import("@scayle/storefront-core").Order | import("@scayle/storefront-api").
|
|
33
|
+
} | import("@scayle/storefront-core").Order | import("@scayle/storefront-api").SearchV2SuggestionsEndpointResponseData | import("@scayle/storefront-api").SearchEntity | import("@scayle/storefront-api").ShopConfiguration | {
|
|
36
34
|
user: import("@scayle/storefront-core").ShopUser | undefined;
|
|
37
|
-
} | import("@scayle/storefront-api").Wishlist |
|
|
35
|
+
} | import("@scayle/storefront-api").Wishlist | import("@scayle/storefront-core").ShopUserAddress[] | {
|
|
38
36
|
accessToken: string;
|
|
39
37
|
checkoutJwt: string;
|
|
40
38
|
} | import("@scayle/storefront-api").VariantDetail[] | import("@scayle/storefront-api").NavigationAllEndpointResponseData | import("@scayle/storefront-api").NavigationTree | {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { StorefrontAPIClient, CachedType, Campaign, Log } from '@scayle/storefront-core';
|
|
2
2
|
export declare const isCampaignActive: (campaign?: Campaign) => boolean;
|
|
3
3
|
export declare const campaignHasNotEnded: (campaign: Campaign) => boolean;
|
|
4
|
-
export declare const campaignKeyMatchesKeyword: (campaign: Campaign, keyword?: string) => boolean;
|
|
5
4
|
export declare const sortCampaignsByDateAscending: (a: Campaign, b: Campaign) => number;
|
|
6
|
-
export declare const fetchCampaignKey: (sapiClient: StorefrontAPIClient, cached: CachedType,
|
|
5
|
+
export declare const fetchCampaignKey: (sapiClient: StorefrontAPIClient, cached: CachedType, log: Log) => Promise<string | undefined>;
|
|
@@ -12,26 +12,20 @@ export const isCampaignActive = (campaign) => {
|
|
|
12
12
|
export const campaignHasNotEnded = (campaign) => {
|
|
13
13
|
return new Date(campaign.end_at).getTime() > Date.now();
|
|
14
14
|
};
|
|
15
|
-
export const campaignKeyMatchesKeyword = (campaign, keyword) => {
|
|
16
|
-
if (!keyword) {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
return campaign.key.toLowerCase().startsWith(keyword.toLowerCase());
|
|
20
|
-
};
|
|
21
15
|
export const sortCampaignsByDateAscending = (a, b) => {
|
|
22
16
|
return new Date(a.start_at).getTime() - new Date(b.start_at).getTime();
|
|
23
17
|
};
|
|
24
|
-
export const fetchCampaignKey = async (sapiClient, cached,
|
|
18
|
+
export const fetchCampaignKey = async (sapiClient, cached, log) => {
|
|
25
19
|
try {
|
|
26
20
|
const { campaigns } = await cached(async () => {
|
|
27
21
|
const { entities } = await sapiClient.campaigns.get();
|
|
28
22
|
return {
|
|
29
23
|
campaigns: entities.filter((campaign) => {
|
|
30
|
-
return campaignHasNotEnded(campaign)
|
|
24
|
+
return campaignHasNotEnded(campaign);
|
|
31
25
|
}).sort(sortCampaignsByDateAscending)
|
|
32
26
|
};
|
|
33
27
|
}, {
|
|
34
|
-
cacheKeyPrefix:
|
|
28
|
+
cacheKeyPrefix: "fetch-campaignKey",
|
|
35
29
|
ttl: 5 * 60
|
|
36
30
|
})();
|
|
37
31
|
return campaigns.find(isCampaignActive)?.key;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { MaybeRefOrGetter } from 'vue';
|
|
2
|
-
import type { RpcMethodParameters
|
|
2
|
+
import type { RpcMethodParameters } from '@scayle/storefront-core';
|
|
3
3
|
import { type UseRpcReturn } from '../core/useRpc.js';
|
|
4
|
-
type UseIDPBaseReturn = Pick<Awaited<UseRpcReturn<'getExternalIdpRedirect'>>, 'data' | 'error' | 'status' | '
|
|
5
|
-
handleIDPLoginCallback: (params: RpcMethodParameters<'handleIDPLoginCallback'>) => RpcMethodReturnType<'handleIDPLoginCallback'>;
|
|
6
|
-
};
|
|
4
|
+
type UseIDPBaseReturn = Pick<Awaited<UseRpcReturn<'getExternalIdpRedirect'>>, 'data' | 'error' | 'status' | 'refresh'>;
|
|
7
5
|
export declare function useIDP(params?: MaybeRefOrGetter<RpcMethodParameters<'getExternalIdpRedirect'>>, key?: string): UseIDPBaseReturn & Promise<UseIDPBaseReturn>;
|
|
8
6
|
export {};
|