@scayle/storefront-product-detail 1.8.0 → 1.9.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
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @scayle/storefront-product-detail
|
|
2
2
|
|
|
3
|
+
## 1.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- **[RPC]** Updated built-in RPC methods to use `GET` for safe, cacheable reads and `PUT`/`POST`/`DELETE` for mutations, enabling CDN and browser caching for public data fetches.
|
|
8
|
+
|
|
3
9
|
## 1.8.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -13,19 +19,19 @@
|
|
|
13
19
|
params: {
|
|
14
20
|
productId: 123,
|
|
15
21
|
limit: 10,
|
|
16
|
-
with: { attributes:
|
|
22
|
+
with: { attributes: "all", images: { attributes: "all" } },
|
|
17
23
|
where: {
|
|
18
24
|
attributes: [
|
|
19
25
|
{
|
|
20
|
-
type:
|
|
21
|
-
key:
|
|
26
|
+
type: "attributes",
|
|
27
|
+
key: "brand",
|
|
22
28
|
values: [456],
|
|
23
29
|
},
|
|
24
30
|
],
|
|
25
31
|
},
|
|
26
32
|
ignoreSameMasterKey: true,
|
|
27
33
|
},
|
|
28
|
-
})
|
|
34
|
+
});
|
|
29
35
|
```
|
|
30
36
|
|
|
31
37
|
## 1.7.0
|
|
@@ -72,64 +78,64 @@
|
|
|
72
78
|
**`sellableTimeframeStartsInFuture`:**
|
|
73
79
|
|
|
74
80
|
```ts
|
|
75
|
-
import { sellableTimeframeStartsInFuture } from
|
|
81
|
+
import { sellableTimeframeStartsInFuture } from "@scayle/storefront-product-detail";
|
|
76
82
|
|
|
77
83
|
// Example timeframe
|
|
78
84
|
const timeframe = {
|
|
79
|
-
sellableFrom:
|
|
80
|
-
sellableTo:
|
|
81
|
-
}
|
|
85
|
+
sellableFrom: "2099-01-01T00:00:00Z",
|
|
86
|
+
sellableTo: "2100-01-01T00:00:00Z",
|
|
87
|
+
};
|
|
82
88
|
|
|
83
|
-
const inFuture = sellableTimeframeStartsInFuture(timeframe)
|
|
84
|
-
console.log(inFuture) // true if current date is before 2099-01-01
|
|
89
|
+
const inFuture = sellableTimeframeStartsInFuture(timeframe);
|
|
90
|
+
console.log(inFuture); // true if current date is before 2099-01-01
|
|
85
91
|
```
|
|
86
92
|
|
|
87
93
|
**`sellableTimeframeEndsInPast`:**
|
|
88
94
|
|
|
89
95
|
```ts
|
|
90
|
-
import { sellableTimeframeEndsInPast } from
|
|
96
|
+
import { sellableTimeframeEndsInPast } from "@scayle/storefront-product-detail";
|
|
91
97
|
|
|
92
98
|
const timeframe = {
|
|
93
|
-
sellableFrom:
|
|
94
|
-
sellableTo:
|
|
95
|
-
}
|
|
99
|
+
sellableFrom: "2018-01-01T00:00:00Z",
|
|
100
|
+
sellableTo: "2020-01-01T00:00:00Z",
|
|
101
|
+
};
|
|
96
102
|
|
|
97
|
-
const ended = sellableTimeframeEndsInPast(timeframe)
|
|
98
|
-
console.log(ended) // true if current date is after 2020-01-01
|
|
103
|
+
const ended = sellableTimeframeEndsInPast(timeframe);
|
|
104
|
+
console.log(ended); // true if current date is after 2020-01-01
|
|
99
105
|
```
|
|
100
106
|
|
|
101
107
|
**`isInSellableTimeframe`:**
|
|
102
108
|
|
|
103
109
|
```ts
|
|
104
|
-
import { isInSellableTimeframe } from
|
|
110
|
+
import { isInSellableTimeframe } from "@scayle/storefront-product-detail";
|
|
105
111
|
|
|
106
112
|
const timeframe = {
|
|
107
|
-
sellableFrom:
|
|
108
|
-
sellableTo:
|
|
109
|
-
}
|
|
113
|
+
sellableFrom: "2023-01-01T00:00:00Z",
|
|
114
|
+
sellableTo: "2025-01-01T00:00:00Z",
|
|
115
|
+
};
|
|
110
116
|
|
|
111
|
-
const active = isInSellableTimeframe(timeframe)
|
|
112
|
-
console.log(active) // true if current date is between 2023-01-01 and 2025-01-01
|
|
117
|
+
const active = isInSellableTimeframe(timeframe);
|
|
118
|
+
console.log(active); // true if current date is between 2023-01-01 and 2025-01-01
|
|
113
119
|
```
|
|
114
120
|
|
|
115
121
|
**`useSellableTimeFrame`:**
|
|
116
122
|
|
|
117
123
|
```ts
|
|
118
|
-
import { useSellableTimeFrame } from
|
|
124
|
+
import { useSellableTimeFrame } from "@scayle/storefront-product-detail";
|
|
119
125
|
|
|
120
126
|
const timeframe = {
|
|
121
|
-
sellableFrom:
|
|
122
|
-
sellableTo:
|
|
123
|
-
}
|
|
127
|
+
sellableFrom: "2023-01-01T00:00:00Z",
|
|
128
|
+
sellableTo: "2025-01-01T00:00:00Z",
|
|
129
|
+
};
|
|
124
130
|
const {
|
|
125
131
|
isInSellableTimeframe,
|
|
126
132
|
sellableTimeframeStartsInFuture,
|
|
127
133
|
sellableTimeframeEndsInPast,
|
|
128
|
-
} = useSellableTimeFrame(timeframe)
|
|
134
|
+
} = useSellableTimeFrame(timeframe);
|
|
129
135
|
|
|
130
|
-
console.log(isInSellableTimeframe) // true if the timeframe is active
|
|
131
|
-
console.log(sellableTimeframeStartsInFuture) // true if the time frame starts in the future
|
|
132
|
-
console.log(sellableTimeframeEndsInPast) // true if the timeframe ended in the past
|
|
136
|
+
console.log(isInSellableTimeframe); // true if the timeframe is active
|
|
137
|
+
console.log(sellableTimeframeStartsInFuture); // true if the time frame starts in the future
|
|
138
|
+
console.log(sellableTimeframeEndsInPast); // true if the timeframe ended in the past
|
|
133
139
|
```
|
|
134
140
|
|
|
135
141
|
## 1.5.6
|
|
@@ -145,20 +151,20 @@
|
|
|
145
151
|
|
|
146
152
|
```ts
|
|
147
153
|
// Before
|
|
148
|
-
const { data } = await useRpc(
|
|
154
|
+
const { data } = await useRpc("getProduct", "my-static-product-key", {
|
|
149
155
|
productId: 123,
|
|
150
|
-
})
|
|
156
|
+
});
|
|
151
157
|
|
|
152
158
|
// After
|
|
153
|
-
const productId = ref(123)
|
|
159
|
+
const productId = ref(123);
|
|
154
160
|
|
|
155
161
|
// The key is now reactive. If `productId` changes, the key updates
|
|
156
162
|
// to 'product-456' (for example) and triggers a new fetch.
|
|
157
163
|
const { data } = await useRpc(
|
|
158
|
-
|
|
164
|
+
"getProduct",
|
|
159
165
|
() => `product-${productId.value}`,
|
|
160
|
-
{ productId }
|
|
161
|
-
)
|
|
166
|
+
{ productId }
|
|
167
|
+
);
|
|
162
168
|
```
|
|
163
169
|
|
|
164
170
|
## 1.5.5
|
|
@@ -195,15 +201,15 @@
|
|
|
195
201
|
|
|
196
202
|
```ts
|
|
197
203
|
export default defineNuxtConfig({
|
|
198
|
-
modules: [
|
|
204
|
+
modules: ["@scayle/storefront-product-detail"],
|
|
199
205
|
runtimeConfig: {
|
|
200
206
|
public: {
|
|
201
|
-
|
|
207
|
+
"product-detail": {
|
|
202
208
|
maxRecentlyViewedProducts: 15,
|
|
203
209
|
},
|
|
204
210
|
},
|
|
205
211
|
},
|
|
206
|
-
})
|
|
212
|
+
});
|
|
207
213
|
```
|
|
208
214
|
|
|
209
215
|
## 1.5.0
|
|
@@ -215,15 +221,15 @@
|
|
|
215
221
|
Example usage:
|
|
216
222
|
|
|
217
223
|
```ts
|
|
218
|
-
import { useRecentlyViewedProducts } from
|
|
224
|
+
import { useRecentlyViewedProducts } from "#storefront-product-detail/composables";
|
|
219
225
|
|
|
220
226
|
const { products, addProduct, loadMissingProducts } =
|
|
221
|
-
useRecentlyViewedProducts()
|
|
227
|
+
useRecentlyViewedProducts();
|
|
222
228
|
|
|
223
229
|
onBeforeMount(async () => {
|
|
224
|
-
addProductId(1234)
|
|
225
|
-
await loadMissingProducts()
|
|
226
|
-
})
|
|
230
|
+
addProductId(1234);
|
|
231
|
+
await loadMissingProducts();
|
|
232
|
+
});
|
|
227
233
|
```
|
|
228
234
|
|
|
229
235
|
## 1.4.2
|
|
@@ -255,46 +261,44 @@
|
|
|
255
261
|
|
|
256
262
|
```ts
|
|
257
263
|
useProductSeoData({
|
|
258
|
-
name:
|
|
259
|
-
brand:
|
|
260
|
-
productDescription:
|
|
264
|
+
name: "Name",
|
|
265
|
+
brand: "Brand",
|
|
266
|
+
productDescription: "Description",
|
|
261
267
|
variants: variants.value.map((variant) => {
|
|
262
268
|
return generateProductSchema({
|
|
263
|
-
productName:
|
|
269
|
+
productName: "Name",
|
|
264
270
|
variant,
|
|
265
271
|
url: `${$config.public.baseUrl}${route.fullPath}`,
|
|
266
272
|
size,
|
|
267
|
-
})
|
|
273
|
+
});
|
|
268
274
|
}),
|
|
269
275
|
images: images.value,
|
|
270
276
|
productId: product.value?.id || 0,
|
|
271
277
|
color: formatColors(colors.value),
|
|
272
|
-
variesBy:
|
|
273
|
-
? [
|
|
274
|
-
|
|
275
|
-
})
|
|
278
|
+
variesBy:
|
|
279
|
+
variants.value.length > 1 ? ["https://schema.org/size"] : undefined,
|
|
280
|
+
});
|
|
276
281
|
|
|
277
282
|
// Will become
|
|
278
283
|
|
|
279
284
|
useProductSeoData({
|
|
280
|
-
name:
|
|
281
|
-
brand:
|
|
282
|
-
productDescription:
|
|
285
|
+
name: "Name",
|
|
286
|
+
brand: "Brand",
|
|
287
|
+
productDescription: "Description",
|
|
283
288
|
variants: variants.value.map((variant) => {
|
|
284
289
|
return generateProductSchema({
|
|
285
|
-
productName:
|
|
290
|
+
productName: "Name",
|
|
286
291
|
variant,
|
|
287
292
|
url: `${$config.public.baseUrl}${route.fullPath}`,
|
|
288
293
|
size,
|
|
289
294
|
images: images.value[0],
|
|
290
|
-
})
|
|
295
|
+
});
|
|
291
296
|
}),
|
|
292
297
|
productId: product.value?.id || 0,
|
|
293
298
|
color: formatColors(colors.value),
|
|
294
|
-
variesBy:
|
|
295
|
-
? [
|
|
296
|
-
|
|
297
|
-
})
|
|
299
|
+
variesBy:
|
|
300
|
+
variants.value.length > 1 ? ["https://schema.org/size"] : undefined,
|
|
301
|
+
});
|
|
298
302
|
```
|
|
299
303
|
|
|
300
304
|
## 1.2.0
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineNuxtModule, createResolver, addImportsDir } from '@nuxt/kit';
|
|
2
2
|
|
|
3
3
|
const PACKAGE_NAME = "@scayle/storefront-product-detail";
|
|
4
|
-
const PACKAGE_VERSION = "1.
|
|
4
|
+
const PACKAGE_VERSION = "1.9.0";
|
|
5
5
|
const module$1 = defineNuxtModule({
|
|
6
6
|
meta: {
|
|
7
7
|
name: PACKAGE_NAME,
|
|
@@ -2,9 +2,10 @@ import {
|
|
|
2
2
|
ErrorResponse,
|
|
3
3
|
FetchError,
|
|
4
4
|
MINUTE,
|
|
5
|
-
MIN_WITH_PARAMS_PRODUCT
|
|
5
|
+
MIN_WITH_PARAMS_PRODUCT,
|
|
6
|
+
defineRpcHandler
|
|
6
7
|
} from "@scayle/storefront-nuxt";
|
|
7
|
-
export const getSimilarProducts = async
|
|
8
|
+
export const getSimilarProducts = defineRpcHandler(async (options, context) => {
|
|
8
9
|
const { sapiClient, cached, withParams } = context;
|
|
9
10
|
const campaignKey = await context.callRpc?.("getCampaignKey");
|
|
10
11
|
const { productId, with: withParameter, ...rest } = options;
|
|
@@ -34,4 +35,4 @@ export const getSimilarProducts = async function getProductsByReferenceKeys(opti
|
|
|
34
35
|
campaignKey,
|
|
35
36
|
...rest
|
|
36
37
|
});
|
|
37
|
-
};
|
|
38
|
+
}, { method: "GET" });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-product-detail",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Collection of essential composables and utilities to work with product detail",
|
|
5
5
|
"author": "SCAYLE Commerce Engine",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
"CHANGELOG.md",
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">= 22.0.0"
|
|
29
|
+
},
|
|
27
30
|
"imports": {
|
|
28
31
|
"#storefront-product-detail": "./dist/runtime/index.js"
|
|
29
32
|
},
|
|
@@ -37,29 +40,28 @@
|
|
|
37
40
|
},
|
|
38
41
|
"devDependencies": {
|
|
39
42
|
"@arethetypeswrong/cli": "0.18.2",
|
|
40
|
-
"@nuxt/kit": "3.20.
|
|
43
|
+
"@nuxt/kit": "^3.20.2",
|
|
41
44
|
"@nuxt/module-builder": "1.0.2",
|
|
42
|
-
"@nuxt/schema": "3.20.
|
|
43
|
-
"@nuxt/test-utils": "
|
|
44
|
-
"@
|
|
45
|
-
"@
|
|
46
|
-
"@
|
|
47
|
-
"
|
|
48
|
-
"eslint-formatter-gitlab": "7.0
|
|
49
|
-
"eslint": "
|
|
50
|
-
"happy-dom": "20.
|
|
51
|
-
"nuxt": "3.20.
|
|
52
|
-
"publint": "0.3.
|
|
45
|
+
"@nuxt/schema": "^3.20.2",
|
|
46
|
+
"@nuxt/test-utils": "4.0.0",
|
|
47
|
+
"@scayle/eslint-config-storefront": "^4.8.0",
|
|
48
|
+
"@types/node": "22.19.17",
|
|
49
|
+
"@vitest/coverage-v8": "4.1.5",
|
|
50
|
+
"@vueuse/core": "14.2.1",
|
|
51
|
+
"eslint-formatter-gitlab": "7.1.0",
|
|
52
|
+
"eslint": "10.2.1",
|
|
53
|
+
"happy-dom": "20.9.0",
|
|
54
|
+
"nuxt": "^3.20.2",
|
|
55
|
+
"publint": "0.3.18",
|
|
53
56
|
"schema-dts": "1.1.5",
|
|
54
57
|
"typescript": "5.9.3",
|
|
55
58
|
"unbuild": "3.6.1",
|
|
56
|
-
"vitest": "4.
|
|
59
|
+
"vitest": "4.1.5",
|
|
57
60
|
"vue-router": "4.6.4",
|
|
58
|
-
"vue-tsc": "3.2.
|
|
59
|
-
"vue": "3.5.
|
|
60
|
-
"@scayle/
|
|
61
|
-
"@scayle/
|
|
62
|
-
"@scayle/storefront-nuxt": "8.59.0"
|
|
61
|
+
"vue-tsc": "3.2.6",
|
|
62
|
+
"vue": "3.5.32",
|
|
63
|
+
"@scayle/storefront-nuxt": "8.61.0",
|
|
64
|
+
"@scayle/vitest-config-storefront": "1.0.0"
|
|
63
65
|
},
|
|
64
66
|
"scripts": {
|
|
65
67
|
"build": "nuxt-module-build build",
|
|
@@ -69,11 +71,6 @@
|
|
|
69
71
|
"lint": "eslint .",
|
|
70
72
|
"lint:ci": "eslint . --format gitlab",
|
|
71
73
|
"lint:fix": "eslint . --fix",
|
|
72
|
-
"format": "dprint check",
|
|
73
|
-
"format:fix": "dprint fmt",
|
|
74
|
-
"test": "vitest --run",
|
|
75
|
-
"test:watch": "vitest",
|
|
76
|
-
"test:ci": "vitest --run --coverage --reporter=default --reporter=junit --outputFile=./coverage/junit.xml",
|
|
77
74
|
"typecheck": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
78
75
|
"package:lint": "publint",
|
|
79
76
|
"verify-packaging": "attw --pack . --profile esm-only"
|