@scayle/storefront-core 7.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. package/CHANGELOG.md +480 -0
  2. package/LICENSE +21 -0
  3. package/README.md +29 -0
  4. package/dist/bapi/init.cjs +30 -0
  5. package/dist/bapi/init.d.ts +14 -0
  6. package/dist/bapi/init.mjs +23 -0
  7. package/dist/cache/cache.cjs +1 -0
  8. package/dist/cache/cache.d.ts +8 -0
  9. package/dist/cache/cache.mjs +0 -0
  10. package/dist/cache/cached.cjs +89 -0
  11. package/dist/cache/cached.d.ts +24 -0
  12. package/dist/cache/cached.mjs +92 -0
  13. package/dist/cache/index.cjs +38 -0
  14. package/dist/cache/index.d.ts +3 -0
  15. package/dist/cache/index.mjs +3 -0
  16. package/dist/cache/providers/redis.cjs +94 -0
  17. package/dist/cache/providers/redis.d.ts +28 -0
  18. package/dist/cache/providers/redis.mjs +86 -0
  19. package/dist/cache/providers/unstorage.cjs +54 -0
  20. package/dist/cache/providers/unstorage.d.ts +16 -0
  21. package/dist/cache/providers/unstorage.mjs +49 -0
  22. package/dist/cache/types.cjs +11 -0
  23. package/dist/cache/types.d.ts +6 -0
  24. package/dist/cache/types.mjs +4 -0
  25. package/dist/constants/basket.cjs +13 -0
  26. package/dist/constants/basket.d.ts +8 -0
  27. package/dist/constants/basket.mjs +6 -0
  28. package/dist/constants/cache.cjs +8 -0
  29. package/dist/constants/cache.d.ts +1 -0
  30. package/dist/constants/cache.mjs +1 -0
  31. package/dist/constants/hash.cjs +11 -0
  32. package/dist/constants/hash.d.ts +6 -0
  33. package/dist/constants/hash.mjs +4 -0
  34. package/dist/constants/httpStatus.cjs +636 -0
  35. package/dist/constants/httpStatus.d.ts +632 -0
  36. package/dist/constants/httpStatus.mjs +629 -0
  37. package/dist/constants/index.cjs +93 -0
  38. package/dist/constants/index.d.ts +8 -0
  39. package/dist/constants/index.mjs +8 -0
  40. package/dist/constants/product.cjs +11 -0
  41. package/dist/constants/product.d.ts +6 -0
  42. package/dist/constants/product.mjs +4 -0
  43. package/dist/constants/promotion.cjs +10 -0
  44. package/dist/constants/promotion.d.ts +2 -0
  45. package/dist/constants/promotion.mjs +2 -0
  46. package/dist/constants/sorting.cjs +24 -0
  47. package/dist/constants/sorting.d.ts +20 -0
  48. package/dist/constants/sorting.mjs +17 -0
  49. package/dist/constants/withParameters.cjs +138 -0
  50. package/dist/constants/withParameters.d.ts +30 -0
  51. package/dist/constants/withParameters.mjs +132 -0
  52. package/dist/errors/BAPIError.cjs +16 -0
  53. package/dist/errors/BAPIError.d.ts +6 -0
  54. package/dist/errors/BAPIError.mjs +9 -0
  55. package/dist/errors/baseError.cjs +17 -0
  56. package/dist/errors/baseError.d.ts +5 -0
  57. package/dist/errors/baseError.mjs +10 -0
  58. package/dist/errors/index.cjs +27 -0
  59. package/dist/errors/index.d.ts +2 -0
  60. package/dist/errors/index.mjs +2 -0
  61. package/dist/helpers/advancedAttributeHelpers.cjs +26 -0
  62. package/dist/helpers/advancedAttributeHelpers.d.ts +12 -0
  63. package/dist/helpers/advancedAttributeHelpers.mjs +21 -0
  64. package/dist/helpers/arrayHelpers.cjs +10 -0
  65. package/dist/helpers/arrayHelpers.d.ts +1 -0
  66. package/dist/helpers/arrayHelpers.mjs +3 -0
  67. package/dist/helpers/attributeHelpers.cjs +24 -0
  68. package/dist/helpers/attributeHelpers.d.ts +5 -0
  69. package/dist/helpers/attributeHelpers.mjs +17 -0
  70. package/dist/helpers/autobind.cjs +44 -0
  71. package/dist/helpers/autobind.d.ts +39 -0
  72. package/dist/helpers/autobind.mjs +35 -0
  73. package/dist/helpers/basketHelpers.cjs +12 -0
  74. package/dist/helpers/basketHelpers.d.ts +2 -0
  75. package/dist/helpers/basketHelpers.mjs +5 -0
  76. package/dist/helpers/categoryHelper.cjs +61 -0
  77. package/dist/helpers/categoryHelper.d.ts +7 -0
  78. package/dist/helpers/categoryHelper.mjs +44 -0
  79. package/dist/helpers/filterHelper.cjs +156 -0
  80. package/dist/helpers/filterHelper.d.ts +82 -0
  81. package/dist/helpers/filterHelper.mjs +147 -0
  82. package/dist/helpers/formHelpers.cjs +114 -0
  83. package/dist/helpers/formHelpers.d.ts +48 -0
  84. package/dist/helpers/formHelpers.mjs +106 -0
  85. package/dist/helpers/imageHelpers.cjs +20 -0
  86. package/dist/helpers/imageHelpers.d.ts +4 -0
  87. package/dist/helpers/imageHelpers.mjs +14 -0
  88. package/dist/helpers/index.cjs +192 -0
  89. package/dist/helpers/index.d.ts +17 -0
  90. package/dist/helpers/index.mjs +17 -0
  91. package/dist/helpers/localization.cjs +13 -0
  92. package/dist/helpers/localization.d.ts +7 -0
  93. package/dist/helpers/localization.mjs +6 -0
  94. package/dist/helpers/objectHelpers.cjs +19 -0
  95. package/dist/helpers/objectHelpers.d.ts +1 -0
  96. package/dist/helpers/objectHelpers.mjs +6 -0
  97. package/dist/helpers/orderHelpers.cjs +10 -0
  98. package/dist/helpers/orderHelpers.d.ts +67 -0
  99. package/dist/helpers/orderHelpers.mjs +4 -0
  100. package/dist/helpers/product.fixture.cjs +770 -0
  101. package/dist/helpers/product.fixture.d.ts +415 -0
  102. package/dist/helpers/product.fixture.mjs +838 -0
  103. package/dist/helpers/productDisruptorHelper.cjs +37 -0
  104. package/dist/helpers/productDisruptorHelper.d.ts +10 -0
  105. package/dist/helpers/productDisruptorHelper.mjs +23 -0
  106. package/dist/helpers/productHelpers.cjs +188 -0
  107. package/dist/helpers/productHelpers.d.ts +41 -0
  108. package/dist/helpers/productHelpers.mjs +170 -0
  109. package/dist/helpers/sanitizationHelpers.cjs +15 -0
  110. package/dist/helpers/sanitizationHelpers.d.ts +2 -0
  111. package/dist/helpers/sanitizationHelpers.mjs +6 -0
  112. package/dist/helpers/sortingHelper.cjs +67 -0
  113. package/dist/helpers/sortingHelper.d.ts +69 -0
  114. package/dist/helpers/sortingHelper.mjs +66 -0
  115. package/dist/helpers/stringHelpers.cjs +8 -0
  116. package/dist/helpers/stringHelpers.d.ts +2 -0
  117. package/dist/helpers/stringHelpers.mjs +2 -0
  118. package/dist/index.cjs +85 -0
  119. package/dist/index.d.ts +19 -0
  120. package/dist/index.mjs +8 -0
  121. package/dist/rpc/methods/basket/basket.cjs +183 -0
  122. package/dist/rpc/methods/basket/basket.d.ts +23 -0
  123. package/dist/rpc/methods/basket/basket.mjs +181 -0
  124. package/dist/rpc/methods/brands.cjs +34 -0
  125. package/dist/rpc/methods/brands.d.ts +5 -0
  126. package/dist/rpc/methods/brands.mjs +16 -0
  127. package/dist/rpc/methods/categories.cjs +102 -0
  128. package/dist/rpc/methods/categories.d.ts +21 -0
  129. package/dist/rpc/methods/categories.mjs +64 -0
  130. package/dist/rpc/methods/cbd.cjs +45 -0
  131. package/dist/rpc/methods/cbd.d.ts +4 -0
  132. package/dist/rpc/methods/cbd.mjs +36 -0
  133. package/dist/rpc/methods/checkout/index.cjs +38 -0
  134. package/dist/rpc/methods/checkout/index.d.ts +3 -0
  135. package/dist/rpc/methods/checkout/index.mjs +3 -0
  136. package/dist/rpc/methods/checkout/order.cjs +55 -0
  137. package/dist/rpc/methods/checkout/order.d.ts +4 -0
  138. package/dist/rpc/methods/checkout/order.mjs +43 -0
  139. package/dist/rpc/methods/checkout/shopUser.cjs +126 -0
  140. package/dist/rpc/methods/checkout/shopUser.d.ts +7 -0
  141. package/dist/rpc/methods/checkout/shopUser.mjs +109 -0
  142. package/dist/rpc/methods/checkout/shopUserAddresses.cjs +25 -0
  143. package/dist/rpc/methods/checkout/shopUserAddresses.d.ts +3 -0
  144. package/dist/rpc/methods/checkout/shopUserAddresses.mjs +19 -0
  145. package/dist/rpc/methods/index.cjs +159 -0
  146. package/dist/rpc/methods/index.d.ts +14 -0
  147. package/dist/rpc/methods/index.mjs +14 -0
  148. package/dist/rpc/methods/navigationTrees.cjs +33 -0
  149. package/dist/rpc/methods/navigationTrees.d.ts +5 -0
  150. package/dist/rpc/methods/navigationTrees.mjs +10 -0
  151. package/dist/rpc/methods/products.cjs +261 -0
  152. package/dist/rpc/methods/products.d.ts +13 -0
  153. package/dist/rpc/methods/products.mjs +217 -0
  154. package/dist/rpc/methods/promotion.cjs +53 -0
  155. package/dist/rpc/methods/promotion.d.ts +4 -0
  156. package/dist/rpc/methods/promotion.mjs +38 -0
  157. package/dist/rpc/methods/search.cjs +38 -0
  158. package/dist/rpc/methods/search.d.ts +10 -0
  159. package/dist/rpc/methods/search.mjs +22 -0
  160. package/dist/rpc/methods/session.cjs +274 -0
  161. package/dist/rpc/methods/session.d.ts +20 -0
  162. package/dist/rpc/methods/session.mjs +309 -0
  163. package/dist/rpc/methods/shopConfiguration.cjs +15 -0
  164. package/dist/rpc/methods/shopConfiguration.d.ts +4 -0
  165. package/dist/rpc/methods/shopConfiguration.mjs +6 -0
  166. package/dist/rpc/methods/user.cjs +89 -0
  167. package/dist/rpc/methods/user.d.ts +20 -0
  168. package/dist/rpc/methods/user.mjs +56 -0
  169. package/dist/rpc/methods/variants.cjs +29 -0
  170. package/dist/rpc/methods/variants.d.ts +8 -0
  171. package/dist/rpc/methods/variants.mjs +12 -0
  172. package/dist/rpc/methods/wishlist.cjs +85 -0
  173. package/dist/rpc/methods/wishlist.d.ts +13 -0
  174. package/dist/rpc/methods/wishlist.mjs +61 -0
  175. package/dist/server.cjs +39 -0
  176. package/dist/server.d.ts +5 -0
  177. package/dist/server.mjs +4 -0
  178. package/dist/types/api/auth.cjs +1 -0
  179. package/dist/types/api/auth.d.ts +63 -0
  180. package/dist/types/api/auth.mjs +0 -0
  181. package/dist/types/api/context.cjs +1 -0
  182. package/dist/types/api/context.d.ts +61 -0
  183. package/dist/types/api/context.mjs +0 -0
  184. package/dist/types/api/rpc.cjs +1 -0
  185. package/dist/types/api/rpc.d.ts +4 -0
  186. package/dist/types/api/rpc.mjs +0 -0
  187. package/dist/types/bapi/basket.cjs +1 -0
  188. package/dist/types/bapi/basket.d.ts +25 -0
  189. package/dist/types/bapi/basket.mjs +0 -0
  190. package/dist/types/bapi/brand.cjs +1 -0
  191. package/dist/types/bapi/brand.d.ts +2 -0
  192. package/dist/types/bapi/brand.mjs +0 -0
  193. package/dist/types/bapi/category.cjs +1 -0
  194. package/dist/types/bapi/category.d.ts +6 -0
  195. package/dist/types/bapi/category.mjs +0 -0
  196. package/dist/types/bapi/filter.cjs +1 -0
  197. package/dist/types/bapi/filter.d.ts +49 -0
  198. package/dist/types/bapi/filter.mjs +0 -0
  199. package/dist/types/bapi/navigation.cjs +1 -0
  200. package/dist/types/bapi/navigation.d.ts +10 -0
  201. package/dist/types/bapi/navigation.mjs +0 -0
  202. package/dist/types/bapi/order.cjs +1 -0
  203. package/dist/types/bapi/order.d.ts +554 -0
  204. package/dist/types/bapi/order.mjs +0 -0
  205. package/dist/types/bapi/pagination.cjs +1 -0
  206. package/dist/types/bapi/pagination.d.ts +13 -0
  207. package/dist/types/bapi/pagination.mjs +0 -0
  208. package/dist/types/bapi/product.cjs +1 -0
  209. package/dist/types/bapi/product.d.ts +84 -0
  210. package/dist/types/bapi/product.mjs +0 -0
  211. package/dist/types/bapi/productFilter.cjs +1 -0
  212. package/dist/types/bapi/productFilter.d.ts +7 -0
  213. package/dist/types/bapi/productFilter.mjs +0 -0
  214. package/dist/types/bapi/promotion.cjs +1 -0
  215. package/dist/types/bapi/promotion.d.ts +2 -0
  216. package/dist/types/bapi/promotion.mjs +0 -0
  217. package/dist/types/bapi/redirects.cjs +1 -0
  218. package/dist/types/bapi/redirects.d.ts +1 -0
  219. package/dist/types/bapi/redirects.mjs +0 -0
  220. package/dist/types/bapi/router.cjs +1 -0
  221. package/dist/types/bapi/router.d.ts +1 -0
  222. package/dist/types/bapi/router.mjs +0 -0
  223. package/dist/types/bapi/search.cjs +1 -0
  224. package/dist/types/bapi/search.d.ts +21 -0
  225. package/dist/types/bapi/search.mjs +0 -0
  226. package/dist/types/bapi/sorting.cjs +5 -0
  227. package/dist/types/bapi/sorting.d.ts +10 -0
  228. package/dist/types/bapi/sorting.mjs +1 -0
  229. package/dist/types/bapi/wishlist.cjs +1 -0
  230. package/dist/types/bapi/wishlist.d.ts +9 -0
  231. package/dist/types/bapi/wishlist.mjs +0 -0
  232. package/dist/types/breadcrumb.cjs +1 -0
  233. package/dist/types/breadcrumb.d.ts +4 -0
  234. package/dist/types/breadcrumb.mjs +0 -0
  235. package/dist/types/index.cjs +236 -0
  236. package/dist/types/index.d.ts +22 -0
  237. package/dist/types/index.mjs +21 -0
  238. package/dist/types/promises.cjs +1 -0
  239. package/dist/types/promises.d.ts +2 -0
  240. package/dist/types/promises.mjs +0 -0
  241. package/dist/types/user.cjs +1 -0
  242. package/dist/types/user.d.ts +100 -0
  243. package/dist/types/user.mjs +0 -0
  244. package/dist/utils/compression.cjs +24 -0
  245. package/dist/utils/compression.d.ts +2 -0
  246. package/dist/utils/compression.mjs +16 -0
  247. package/dist/utils/hash.cjs +68 -0
  248. package/dist/utils/hash.d.ts +8 -0
  249. package/dist/utils/hash.mjs +61 -0
  250. package/dist/utils/index.cjs +27 -0
  251. package/dist/utils/index.d.ts +2 -0
  252. package/dist/utils/index.mjs +2 -0
  253. package/dist/utils/keys.cjs +67 -0
  254. package/dist/utils/keys.d.ts +24 -0
  255. package/dist/utils/keys.mjs +56 -0
  256. package/dist/utils/log.cjs +93 -0
  257. package/dist/utils/log.d.ts +43 -0
  258. package/dist/utils/log.mjs +75 -0
  259. package/dist/utils/rpc.cjs +41 -0
  260. package/dist/utils/rpc.d.ts +6 -0
  261. package/dist/utils/rpc.mjs +35 -0
  262. package/dist/utils/timeout.cjs +17 -0
  263. package/dist/utils/timeout.d.ts +2 -0
  264. package/dist/utils/timeout.mjs +9 -0
  265. package/dist/utils/user.cjs +75 -0
  266. package/dist/utils/user.d.ts +14 -0
  267. package/dist/utils/user.mjs +65 -0
  268. package/package.json +97 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,480 @@
1
+ # @scayle/storefront-core
2
+
3
+ ## 7.22.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Add license file
8
+
9
+ ## 7.22.0
10
+
11
+ ### Minor Changes
12
+
13
+ - Upgrade package `@aboutyou/backbone`to `v15.14.1`
14
+
15
+ ## 7.21.0
16
+
17
+ ### Minor Changes
18
+
19
+ - - Add `promotion` RPC methods and types
20
+ - - Add promotion data within the basket payloads
21
+
22
+ ### Patch Changes
23
+
24
+ - Fix product URL generation, remove additional special characters that can break routing
25
+
26
+ ## 7.20.0
27
+
28
+ ### Minor Changes
29
+
30
+ - Upgrade backbone to the `v15.12.1`
31
+
32
+ ## 7.19.1
33
+
34
+ ### Patch Changes
35
+
36
+ - The `auth` config is optional
37
+
38
+ ## 7.19.0
39
+
40
+ ### Minor Changes
41
+
42
+ - Support setting default `with` params in the module options
43
+
44
+ ## 7.18.0
45
+
46
+ ### Minor Changes
47
+
48
+ - Expose error codes from BAPI for the basket rpc methods
49
+
50
+ ## 7.17.0
51
+
52
+ ### Minor Changes
53
+
54
+ - Limit perPage for getBrands and getProductsByCategory to 100
55
+
56
+ ## 7.16.0
57
+
58
+ ### Minor Changes
59
+
60
+ - Support expiring CBD tokens
61
+
62
+ ## 7.15.1
63
+
64
+ ### Patch Changes
65
+
66
+ - Remove unnecessary dependencies
67
+
68
+ ## 7.15.0
69
+
70
+ ### Minor Changes
71
+
72
+ - Support importing all dist/ files directly
73
+
74
+ ## 7.14.3
75
+
76
+ ### Patch Changes
77
+
78
+ - Import fix
79
+
80
+ ## 7.14.2
81
+
82
+ ### Patch Changes
83
+
84
+ - Make redis an optional dependency
85
+
86
+ ## 7.14.1
87
+
88
+ ### Patch Changes
89
+
90
+ - Remove unused body-parser dependency
91
+
92
+ ## 7.14.0
93
+
94
+ ### Minor Changes
95
+
96
+ - Read OAuth settings from the RpcContext
97
+
98
+ ## 7.13.0
99
+
100
+ ### Minor Changes
101
+
102
+ - Save user to session during login/register process. This will fix wrong wishlist/basket keys, in the RpcContext, after the login/registering.
103
+ - Safe user to session during login process. This will fix wrong wishlist/basket keys , in the RpcContext, after the login.
104
+
105
+ ## 7.12.2
106
+
107
+ ### Patch Changes
108
+
109
+ - Replace crypto with uncrypto
110
+
111
+ ## 7.12.1
112
+
113
+ ### Patch Changes
114
+
115
+ - Export BapiClient and Redirect from BAPI
116
+
117
+ ## 7.12.0
118
+
119
+ ### Minor Changes
120
+
121
+ - `to` prop of `BreadcrumbItem` returned from `getBreadcrumbsFromPath` now start with `/`
122
+
123
+ ## 7.11.0
124
+
125
+ ### Minor Changes
126
+
127
+ - Move `deserializeFilters` and `serializeFilters` to `@scayle/storefront-core`
128
+
129
+ ## 7.10.2
130
+
131
+ ### Patch Changes
132
+
133
+ - encodeBase64 and decodeBase64 should be able to be run in browser environments
134
+
135
+ ## 7.10.1
136
+
137
+ ### Patch Changes
138
+
139
+ - Get accessToken from getUserRequest on client side.
140
+ Merge basket and wishlist after login/register to logged in user.
141
+
142
+ ## 7.10.0
143
+
144
+ ### Minor Changes
145
+
146
+ - Add the possibility to use Token based authentication.
147
+
148
+ ## 7.9.0
149
+
150
+ ### Minor Changes
151
+
152
+ - Add unstorage cache provider
153
+
154
+ ### Patch Changes
155
+
156
+ - Fix crypto-js imports needed for basked/wishlist key generation.
157
+
158
+ ## 7.8.0
159
+
160
+ ### Minor Changes
161
+
162
+ - provide exports of package as ESM and CJS format
163
+ - Migrate helpers to core package
164
+
165
+ ### Patch Changes
166
+
167
+ - Add `initBapi` function to initialize a BapiClient
168
+
169
+ ## 7.7.1
170
+
171
+ ### Patch Changes
172
+
173
+ - orFiltersOperator should be optional in FetchProductsByCategoryParams and FetchProductsCountParams
174
+
175
+ ## 7.7.0
176
+
177
+ ### Minor Changes
178
+
179
+ - Update @aboutyou/backbone package and add support for `onFiltersOperator` BAPI parameter
180
+
181
+ ## 7.6.1
182
+
183
+ ### Patch Changes
184
+
185
+ - Move keys utils to core package
186
+
187
+ ## 7.6.0
188
+
189
+ ### Minor Changes
190
+
191
+ - Set the domain property in the rpc context
192
+
193
+ ## 7.5.0
194
+
195
+ ### Minor Changes
196
+
197
+ - `refresh()` of `useUser()` and `useUserFacet()` will now clear the session and user state if the checkout returns `HTTP 403 Forbidden`.
198
+ - **Breaking** `destroySession` is now async.
199
+
200
+ ## 7.4.0
201
+
202
+ ### Minor Changes
203
+
204
+ - Add option `includeSellableForFree` to `useFacet` and `useProducts` to include free products.
205
+
206
+ ## 7.3.1
207
+
208
+ ### Patch Changes
209
+
210
+ - Move RpcMethodsStorefront type to the nuxt2 package so it's accessible to shops
211
+
212
+ ## 7.3.0
213
+
214
+ ### Minor Changes
215
+
216
+ - Add rpcMethods `getBrand` and `getBrands` & corresponding composables, to make bapi-sdk brand endpoints available.
217
+
218
+ ## 7.2.1
219
+
220
+ ### Patch Changes
221
+
222
+ - Added ability to add basket groups by accepting `itemGroup` in the payload for the rpc method `addItemsToBasket`
223
+
224
+ ## 7.2.0
225
+
226
+ ### Minor Changes
227
+
228
+ - - Replaced `enums` with the companion object pattern approach.
229
+ - - Replaced `HttpStatusMessage` number values with the actual message
230
+ - - Exposed `HashAlgorithm` constant with its type and move it to the core
231
+ - **Breaking:** If you are importing `HashAlgorithm` from `@scayle/storefront-nuxt2` change to importing it from `@scayle/storefront-core`
232
+
233
+ ## 7.1.0
234
+
235
+ ### Minor Changes
236
+
237
+ - Fix `fetchAllFiltersForCategory` caching issue by returning the cached value.
238
+ - Fix `fetchAllFiltersForCategory` caching issue by returning the cached value.
239
+
240
+ ## 7.0.0
241
+
242
+ ### Major Changes
243
+
244
+ - **Changes to basket and wishlist functions**
245
+ - Going forward, the only way to specify `with` and `pricePromotionKey` for the basket is by passing them to `useBasketWithParams()`.
246
+ They can no longer be overridden when calling `basket.addItem()`, `basket.removeItem()` or `basket.fetch()`.
247
+ - The only way to specify `pricePromotionKey` for the wishlist is by to passing them to `useWishlistWithParams()`.
248
+ They can no longer be overridden when calling `wishlist.addItem()`, `wishlist.removeItem()`, `wishlist.toggleItem()` or `wishlist.fetch()`.
249
+ - **Removed deprecated functions and values**
250
+ - **Removal**: `user.fetch()`
251
+ - user is fetched automatically. If you want to refresh the user, use `user.refresh()`
252
+ - **Removal**: `user.forceRefreshUser()`
253
+ - instead use `user.refresh()`
254
+ - **Removal**: `useUser()`
255
+ - instead use `useUserWithParams()`
256
+ - **Removal**: `useBasket()`
257
+ - instead use `useBasketWithParams()`
258
+ - **Removal**: `useWishlist()`
259
+ - instead use `useWishlistWithParams()`
260
+ - **Removal**: `ShopUser.emailHash`
261
+ - instead hash the email address on shop side
262
+ - **Removal**: `wishlist.contains()`
263
+ - instead use `wishlist.findItem()`
264
+ - **Removal**: `applyFilter()`
265
+ - instead use `applyFilters()`
266
+ - **Removal**: `Log.attachToNuxtContext()`
267
+ - instead use `inject('log', log)` in your plugin
268
+ - **Removal**: `Log.attachToWindow()`
269
+ - instead use `Log.default = log`
270
+ - **Removal**: `sortingValues`
271
+ - instead use `getSortingValues()`
272
+ - **Changed NPM package names**
273
+
274
+ - **Breaking**: Change package scope and name of `@aboutyou/scayle-sfc-nuxt` to `@scayle/storefront-nuxt2`
275
+ - **Breaking**: Change package scope and name of `@aboutyou/sfc-nuxt3` to `@scayle/storefront-nuxt`
276
+ - **Breaking**: Change package scope and name of `@aboutyou/scayle-sfc-lib` to `@scayle/storefront-core`
277
+ - **Breaking**: Change package scope and name of `@aboutyou/eslint-config-sfc` to `@scayle/eslint-config-storefront`
278
+ - **Breaking**: Change package scope and name of `@aboutyou/prettier-config-sfc` to `@scayle/prettier-config-storefront`
279
+
280
+ _NOTE: Due to the changes of the NPM package scope from `@aboutyou` to `@scayle`,
281
+ it is required to change the consuming projects local `.npmrc` file as follows:_
282
+
283
+ - Before:
284
+
285
+ ```
286
+ @aboutyou:registry=https://gitlab.com/api/v4/packages/npm/
287
+ ```
288
+
289
+ - After:
290
+
291
+ ```
292
+ @aboutyou:registry=https://gitlab.com/api/v4/projects/29746107/packages/npm/
293
+ @scayle:registry=https://gitlab.com/api/v4/projects/29746107/packages/npm/
294
+ ```
295
+
296
+ - **Removal**: `isEmpty`, `isEqual`, `pluck` and `copyTo` object helpers are removed.
297
+ _NOTE: We recommend to use native utilities or `radash` within your project!_
298
+ - **Removal**: Remove the deprecated pino-based logger.
299
+ _NOTE: For more information, please check out the "Logging"-section in `README.md`._
300
+ - Changes to hash utils:
301
+ - `hmac`, `verifyToken`, `buildSignature` functions are now async
302
+ - hash functions are no longer exported from `utils/index`. They must be imported from `utils/hash`
303
+ - `sha256` function added
304
+ - **Breaking**: Minimum `node` version raised to `18.15.0`
305
+ - `sha256` is used for default cache keys instead of `md5`
306
+ - **Breaking**: Remove the BasicAuth module
307
+ - Support sha256 for basket and wishlist keys
308
+
309
+ The `appKeys.isHashed` config option has been renamed to `appKeys.hashAlgorithm`. Instead of a boolean, there are now three options.
310
+
311
+ - `'sha256'` Use the `sha256` function for hashing basket and wishlist keys
312
+ - `'md5'` Use the `md5` function for hashing basket and wishlist keys (Equivalent to `isHashed: true` in v6)
313
+ - `null` Do not hash basket and wishlist keys (Equivalent to `isHashed: false` in v6)
314
+
315
+ - **Redis optimizations**
316
+ Reduce memory usage by replacing `with parameters` from fetching all attributes and fetching minimum attributes required to run the demo shop.
317
+ _NOTE: As this is a **breaking change**, in order to upgrade you will need to pass the `with parameters` required by the shop to function correctly!_
318
+
319
+ ### Minor Changes
320
+
321
+ - Support optionally dropping MD5 and the crypto-js dependency
322
+ When `process.env.SFC_OMIT_MD5` is `true`, the md5 function will be replaced with an empty stub. If you do not use the MD5 hash at all this can be used to reduce bundle sizes.
323
+
324
+ In `nuxt.config.js` add
325
+
326
+ ```js
327
+ env: {
328
+ SFC_OMIT_MD5: true
329
+ }
330
+ ```
331
+
332
+ or if you want to control it from a `.env`
333
+
334
+ ```js
335
+ env: {
336
+ SFC_OMIT_MD5: process.env.SFC_OMIT_MD5
337
+ }
338
+ ```
339
+
340
+ - **Improvement**: Overall code enhancement within `storefront-core` package in favor of reducing the cognitive complexity and increasing maintainability
341
+ - Introduce `autobind` helper
342
+ - Refactor `cached` file
343
+
344
+ ### Patch Changes
345
+
346
+ - **Bugfix**: Resolve incompatibility with Webpack 4-based build processes
347
+
348
+ ## 7.0.0-alpha.3
349
+
350
+ ### Major Changes
351
+
352
+ - Changes to hash utils:
353
+ - `hmac`, `verifyToken`, `buildSignature` functions are now async
354
+ - hash functions are no longer exported from `utils/index`. They must be imported from `utils/hash`
355
+ - `sha256` function added
356
+ - `sha256` is used for default cache keys instead of `md5`
357
+ - Support sha256 for basket and wishlist keys
358
+
359
+ The `appKeys.isHashed` config option has been renamed to `appKeys.hashAlgorithm`. Instead of a boolean, there are now three options.
360
+
361
+ - `'sha256'` Use the `sha256` function for hashing basket and wishlist keys
362
+ - `'md5'` Use the `md5` function for hashing basket and wishlist keys (Equivalent to `isHashed: true` in v6)
363
+ - `null` Do not hash basket and wishlist keys (Equivalent to `isHashed: false` in v6)
364
+
365
+ ### Minor Changes
366
+
367
+ - Support optionally dropping MD5 and the crypto-js dependency
368
+ When `process.env.SFC_OMIT_MD5` is `true`, the md5 function will be replaced with an empty stub. If you do not use the MD5 hash at all this can be used to reduce bundle sizes.
369
+
370
+ In `nuxt.config.js` add
371
+
372
+ ```js
373
+ env: {
374
+ SFC_OMIT_MD5: true
375
+ }
376
+ ```
377
+
378
+ or if you want to control it from a `.env`
379
+
380
+ ```js
381
+ env: {
382
+ SFC_OMIT_MD5: process.env.SFC_OMIT_MD5
383
+ }
384
+ ```
385
+
386
+ ## 7.0.0-alpha.2
387
+
388
+ ### Patch Changes
389
+
390
+ - **Bugfix**: Resolve incompatibility with Webpack 4-based build processes
391
+
392
+ ## 7.0.0-alpha.1
393
+
394
+ ### Major Changes
395
+
396
+ - **Redis optimizations**
397
+ Reduce memory usage by replacing `with parameters` from fetching all attributes and fetching minimum attributes required to run the demo shop.
398
+ _NOTE: As this is a **breaking change**, in order to upgrade you will need to pass the `with parameters` required by the shop to function correctly!_
399
+
400
+ ### Minor Changes
401
+
402
+ - **Improvement**: Overall code enhancement within `storefront-core` package in favor of reducing the cognitive complexity and increasing maintainability
403
+ - Introduce `autobind` helper
404
+ - Refactor `cached` file
405
+
406
+ ## 7.0.0-alpha.0
407
+
408
+ ### Major Changes
409
+
410
+ - **Changes to basket and wishlist functions**
411
+
412
+ Going forward, the only way to specify `with` and `pricePromotionKey` for the basket is pass them to `useBasketWithParams()`.
413
+ They can no longer be overridden when calling `basket.addItem()`, `basket.removeItem()` and `basket.fetch()`.
414
+
415
+ The only way to specify `pricePromotionKey` for the wishlist is to pass them to `useWishlistWithParams()`.
416
+ They can no longer be overridden when calling `wishlist.addItem()`, `wishlist.removeItem()`, `wishlist.toggleItem()` and `wishlist.fetch()`.
417
+
418
+ - **Removed deprecated functions and values**
419
+
420
+ - `user.fetch()` User is fetched automatically. If you want to refresh the user, use `user.refresh()`
421
+ - `user.forceRefreshUser()` Use `user.refresh()` instead.
422
+ - `useUser()` Use `useUserWithParams()` instead.
423
+ - `useBasket()` Use `useBasketWithParams()` instead.
424
+ - `useWishlist()` Use `useWishlistWithParams()` instead.
425
+ - `ShopUser.emailHash` Hash the email on shop side instead.
426
+ - `wishlist.contains()` Use `wishlist.findItem()` instead.
427
+ - `applyFilter()` Use `applyFilters()` instead.
428
+ - `Log.attachToNuxtContext()` Use `inject('log', log)` in your plugin instead.
429
+ - `Log.attachToWindow()` Use `Log.default = log` instead.
430
+ - `sortingValues` Use `getSortingValues()` instead.
431
+
432
+ - **Changed NPM package names**
433
+
434
+ - **Breaking**: Change package scope and name of `@aboutyou/scayle-sfc-nuxt` to `@scayle/storefront-nuxt2`
435
+ - **Breaking**: Change package scope and name of `@aboutyou/sfc-nuxt3` to `@scayle/storefront-nuxt`
436
+ - **Breaking**: Change package scope and name of `@aboutyou/scayle-sfc-lib` to `@scayle/storefront-core``
437
+ - **Breaking**: Change package scope and name of `@aboutyou/eslint-config-sfc` to `@scayle/eslint-config-storefront`
438
+ - **Breaking**: Change package scope and name of `@aboutyou/prettier-config-sfc` to `@scayle/prettier-config-storefront`
439
+
440
+ Due to the changes of the NPM package scope from `@aboutyou` to `@scayle`,
441
+ it is required to change the consuming projects local `.npmrc` file as follows:
442
+
443
+ - Before: `@aboutyou:registry=https://gitlab.com/api/v4/packages/npm/`
444
+ - After: `@scayle:registry=https://gitlab.com/api/v4/packages/npm/`
445
+
446
+ - `isEmpty`, `isEqual`, `pluck` and `copyTo` object helpers are removed. (Recommendation: It would be good to use native utils or `radash` within the project locally)
447
+ - Remove the deprecated pino-based logger. For more information, please check out the "Logging"-section in README.md.
448
+ - Minimum node version is 18.15.0
449
+ - Remove the basic auth module
450
+
451
+ ## 6.8.0
452
+
453
+ ### Minor Changes
454
+
455
+ - Adds ability to ignore shop locale if passed to the breadcrumb helper. The shop needs to provide its locale using `$currentShop.locale`
456
+
457
+ ## 6.7.1
458
+
459
+ ### Patch Changes
460
+
461
+ - **Bugfix**: move `CACHE_TIMEOUT` to dedicated file for reexport, instead of `cache/providers/redis.ts`, to avoid buildtime errors in nuxt2 package.
462
+
463
+ ## 6.7.0
464
+
465
+ ### Minor Changes
466
+
467
+ - **Deps**: updated `@aboutyou/backbone` to `v15.3.0`
468
+
469
+ ## 6.6.16
470
+
471
+ ### Patch Changes
472
+
473
+ - _Cache_: reduce redis cache timeout from 5000ms to 500ms
474
+
475
+ ## 6.6.15
476
+
477
+ ### Patch Changes
478
+
479
+ - _Cache_: introduce shared redis `CACHE_TIMEOUT` constant across shared packages
480
+ - _Cache_: Increase redis `get` timeout from `300ms` to `5000ms` to account for longer taking redis responses
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 SCAYLE GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Storefront Core
2
+
3
+ [![npm version][npm-version-src]][npm-version-href]
4
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
5
+ [![License][license-src]][license-href]
6
+
7
+ This is a shared package for framework-independent components of the Storefront Core.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ # Using pnpm
13
+ pnpm add @scayle/storefront-core
14
+
15
+ # Using yarn
16
+ yarn add @scayle/storefront-core
17
+
18
+ # Using npm
19
+ npm install @scayle/storefront-core
20
+ ```
21
+
22
+ <!-- Badges -->
23
+
24
+ [npm-version-src]: https://img.shields.io/npm/v/@scayle/storefront-core/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
25
+ [npm-version-href]: https://npmjs.com/package/@scayle/storefront-core
26
+ [npm-downloads-src]: https://img.shields.io/npm/dm/@scayle/storefront-core.svg?style=flat&colorA=18181B&colorB=28CF8D
27
+ [npm-downloads-href]: https://npmjs.com/package/@scayle/storefront-core
28
+ [license-src]: https://img.shields.io/npm/l/@scayle/storefront-core.svg?style=flat&colorA=18181B&colorB=28CF8D
29
+ [license-href]: https://npmjs.com/package/@scayle/storefront-core
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.init = void 0;
7
+ var _backbone = require("@aboutyou/backbone");
8
+ const init = config => {
9
+ let auth;
10
+ if (config.authentication === "basic") {
11
+ auth = {
12
+ type: config.authentication,
13
+ username: config.username,
14
+ password: config.password
15
+ };
16
+ } else if (config.authentication === "token") {
17
+ auth = {
18
+ type: config.authentication,
19
+ token: config.token
20
+ };
21
+ } else {
22
+ throw new Error("Invalid BAPI authentication type");
23
+ }
24
+ return new _backbone.BapiClient({
25
+ host: config.host,
26
+ shopId: config.shopId,
27
+ auth
28
+ });
29
+ };
30
+ exports.init = init;
@@ -0,0 +1,14 @@
1
+ import { BapiClient } from '@aboutyou/backbone';
2
+ type BapiConfig = {
3
+ host: string;
4
+ shopId: number;
5
+ } & ({
6
+ authentication: 'basic';
7
+ username: string;
8
+ password: string;
9
+ } | {
10
+ authentication: 'token';
11
+ token: string;
12
+ });
13
+ export declare const init: (config: BapiConfig) => BapiClient;
14
+ export {};
@@ -0,0 +1,23 @@
1
+ import { BapiClient } from "@aboutyou/backbone";
2
+ export const init = (config) => {
3
+ let auth;
4
+ if (config.authentication === "basic") {
5
+ auth = {
6
+ type: config.authentication,
7
+ username: config.username,
8
+ password: config.password
9
+ };
10
+ } else if (config.authentication === "token") {
11
+ auth = {
12
+ type: config.authentication,
13
+ token: config.token
14
+ };
15
+ } else {
16
+ throw new Error("Invalid BAPI authentication type");
17
+ }
18
+ return new BapiClient({
19
+ host: config.host,
20
+ shopId: config.shopId,
21
+ auth
22
+ });
23
+ };
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,8 @@
1
+ export interface Cache {
2
+ set: (key: string, value: any, ttl: number, tags?: string[]) => Promise<void>;
3
+ get(key: string): Promise<any>;
4
+ has(key: string): Promise<boolean>;
5
+ purgeTags: (tags: string[]) => Promise<void>;
6
+ purgeKeys: (keys: string[]) => Promise<void>;
7
+ purgeAll: () => Promise<void>;
8
+ }
File without changes
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Cached = void 0;
7
+ var _radash = require("radash");
8
+ var _autobind = require("../helpers/autobind.cjs");
9
+ var _utils = require("../utils/index.cjs");
10
+ var _hash = require("../utils/hash.cjs");
11
+ var _constants = require("../constants/index.cjs");
12
+ const CACHE_NOT_INITIALIZED_MSG = "Cache is not initialized";
13
+ class Cached {
14
+ cache;
15
+ log;
16
+ prefix;
17
+ enabled;
18
+ constructor(cache, log, prefix = "", enabled = process.env.AY_CACHE_DISABLED !== "true") {
19
+ if (!cache) {
20
+ log.error(CACHE_NOT_INITIALIZED_MSG);
21
+ throw new Error(CACHE_NOT_INITIALIZED_MSG);
22
+ }
23
+ this.cache = cache;
24
+ this.log = log.space("cached.init");
25
+ this.prefix = prefix;
26
+ this.enabled = enabled;
27
+ (0, _autobind.autobind)(this);
28
+ }
29
+ get isCacheEnabled() {
30
+ return this.enabled;
31
+ }
32
+ execute(fn, options) {
33
+ return async (...args) => {
34
+ const prefix = options?.cacheKeyPrefix ?? fn.name;
35
+ const params = [...args, this?.prefix];
36
+ const cacheKey = options?.cacheKey ?? (await this.createCacheKey(params, prefix));
37
+ const [cacheGetError, cachedResponse] = await (0, _radash.tryit)(this.getCacheValue)(cacheKey, options);
38
+ if (cachedResponse) {
39
+ return cachedResponse;
40
+ }
41
+ if (cacheGetError) {
42
+ this.handleError(cacheGetError, false);
43
+ }
44
+ const [error, response] = await (0, _radash.tryit)(fn)(...args);
45
+ if (error) {
46
+ this.handleError(error);
47
+ }
48
+ if (cacheGetError) {
49
+ return response;
50
+ }
51
+ const [cacheSetError] = await (0, _radash.tryit)(this.setCacheValue)(cacheKey, response, options);
52
+ if (cacheSetError) {
53
+ this.handleError(cacheSetError);
54
+ }
55
+ return response;
56
+ };
57
+ }
58
+ async getCacheValue(cacheKey, options) {
59
+ if (!this.isCacheEnabled) {
60
+ return;
61
+ }
62
+ const data = await (0, _utils.timeout)(options?.timeout ?? _constants.CACHE_TIMEOUT, this.cache.get(cacheKey));
63
+ if (data !== null) {
64
+ return data;
65
+ }
66
+ }
67
+ async setCacheValue(cacheKey, value, options) {
68
+ if (!this.isCacheEnabled) {
69
+ return;
70
+ }
71
+ const ttl = options?.ttl || 60 * 60;
72
+ if (ttl) {
73
+ await (0, _utils.timeout)(_constants.CACHE_TIMEOUT, this.cache.set(cacheKey, value, ttl));
74
+ }
75
+ }
76
+ async createCacheKey(params, prefix = "") {
77
+ return [prefix, await (0, _hash.sha256)(JSON.stringify(params))].join(":");
78
+ }
79
+ handleError(error, shouldThrow = true) {
80
+ if (error.message === "timeout") {
81
+ return this.log.error("Cache timeout");
82
+ }
83
+ this.log.error(error);
84
+ if (shouldThrow) {
85
+ throw error;
86
+ }
87
+ }
88
+ }
89
+ exports.Cached = Cached;