@faststore/core 3.0.152 → 3.0.153
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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +2 -2
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/config.json +3 -3
- package/.next/cache/eslint/.cache_1gneedd +1 -1
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/next-minimal-server.js.nft.json +1 -1
- package/.next/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.js +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/routes-manifest.json +1 -1
- package/.next/server/chunks/350.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/api/graphql.js +1 -1
- package/.next/server/pages/api/preview.js +1 -1
- package/.next/server/pages/en-US/404.html +1 -1
- package/.next/server/pages/en-US/404.json +1 -1
- package/.next/server/pages/en-US/500.html +1 -1
- package/.next/server/pages/en-US/500.json +1 -1
- package/.next/server/pages/en-US/account.html +1 -1
- package/.next/server/pages/en-US/account.json +1 -1
- package/.next/server/pages/en-US/checkout.html +1 -1
- package/.next/server/pages/en-US/checkout.json +1 -1
- package/.next/server/pages/en-US/login.html +1 -1
- package/.next/server/pages/en-US/login.json +1 -1
- package/.next/server/pages/en-US/s.html +1 -1
- package/.next/server/pages/en-US/s.json +1 -1
- package/.next/server/pages/en-US.html +2 -2
- package/.next/server/pages/en-US.json +1 -1
- package/.next/server/pages-manifest.json +1 -1
- package/.next/trace +98 -98
- package/.turbo/turbo-build.log +2 -2
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +5 -5
- package/package.json +2 -2
- package/src/pages/api/preview.ts +33 -11
- /package/.next/static/{03UTa7YuWpYhZyEUa_cAu → FXMFCIKLN-fFiSeONDqs3}/_buildManifest.js +0 -0
- /package/.next/static/{03UTa7YuWpYhZyEUa_cAu → FXMFCIKLN-fFiSeONDqs3}/_ssgManifest.js +0 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -38,8 +38,8 @@ https://nextjs.org/telemetry
|
|
|
38
38
|
Collecting page data ...
|
|
39
39
|
Generating static pages (0/7) ...
|
|
40
40
|
|
|
41
41
|
Generating static pages (1/7)
|
|
42
|
-
|
|
43
42
|
Generating static pages (3/7)
|
|
44
43
|
Warning: Dynamic Content not found for the page: home. Refer to the Dynamic Content documentation at https://developers.vtex.com/docs/guides/faststore/dynamic-content-overview for mapping the page and the corresponding data-fetching function.
|
|
44
|
+
|
|
45
45
|
Generating static pages (3/7)
|
|
46
46
|
|
|
47
47
|
Generating static pages (5/7)
|
|
48
48
|
|
|
49
49
|
✓ Generating static pages (7/7)
|
|
50
50
|
Finalizing page optimization ...
|
|
@@ -74,4 +74,4 @@ Route (pages) Size First Load JS
|
|
|
74
74
|
○ (Static) automatically rendered as static HTML (uses no initial props)
|
|
75
75
|
● (SSG) automatically generated as static HTML + JSON (uses getStaticProps)
|
|
76
76
|
|
|
77
|
-
Done in
|
|
77
|
+
Done in 70.84s.
|
package/.turbo/turbo-lint.log
CHANGED
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
yarn run v1.22.22
|
|
2
2
|
$ jest
|
|
3
|
-
PASS test/utils/multipleTemplates.test.ts (
|
|
4
|
-
PASS test/server/cms/index.test.ts (34.
|
|
5
|
-
PASS test/server/index.test.ts (38.
|
|
3
|
+
PASS test/utils/multipleTemplates.test.ts (33.959 s)
|
|
4
|
+
PASS test/server/cms/index.test.ts (34.228 s)
|
|
5
|
+
PASS test/server/index.test.ts (38.562 s)
|
|
6
6
|
|
|
7
7
|
Test Suites: 3 passed, 3 total
|
|
8
8
|
Tests: 19 passed, 19 total
|
|
9
9
|
Snapshots: 0 total
|
|
10
|
-
Time: 39.
|
|
10
|
+
Time: 39.653 s
|
|
11
11
|
Ran all test suites.
|
|
12
|
-
Done in
|
|
12
|
+
Done in 41.17s.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.153",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "vtex/faststore",
|
|
6
6
|
"browserslist": "supports es6-module and not dead",
|
|
@@ -128,5 +128,5 @@
|
|
|
128
128
|
"node": "18.19.0",
|
|
129
129
|
"yarn": "1.19.1"
|
|
130
130
|
},
|
|
131
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "6f2e5b5970de162e5c425f70ce20552fe195a3de"
|
|
132
132
|
}
|
package/src/pages/api/preview.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { NextApiHandler, NextApiRequest } from 'next'
|
|
2
|
+
import type { Locator } from '@vtex/client-cms'
|
|
2
3
|
|
|
3
4
|
import { clientCMS } from 'src/server/cms'
|
|
4
5
|
import { previewRedirects } from '../../../discovery.config'
|
|
@@ -20,10 +21,7 @@ const pickParam = (req: NextApiRequest, parameter: string) => {
|
|
|
20
21
|
const maybeParam = req.query[parameter]
|
|
21
22
|
|
|
22
23
|
if (typeof maybeParam !== 'string') {
|
|
23
|
-
|
|
24
|
-
`Parameter ${parameter} missing from querystring`,
|
|
25
|
-
400
|
|
26
|
-
)
|
|
24
|
+
return undefined
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
return maybeParam
|
|
@@ -32,14 +30,37 @@ const pickParam = (req: NextApiRequest, parameter: string) => {
|
|
|
32
30
|
// TODO: Improve security by disabling CMS preview in production
|
|
33
31
|
const handler: NextApiHandler = async (req, res) => {
|
|
34
32
|
try {
|
|
35
|
-
const locator =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
const locator = [
|
|
34
|
+
'contentType',
|
|
35
|
+
'documentId',
|
|
36
|
+
'versionId',
|
|
37
|
+
'releaseId',
|
|
38
|
+
].reduce((acc, param) => {
|
|
39
|
+
const value = pickParam(req, param)
|
|
40
|
+
|
|
41
|
+
if (value !== undefined) acc[param] = value
|
|
42
|
+
|
|
43
|
+
return acc
|
|
44
|
+
}, {} as Record<string, string>)
|
|
45
|
+
|
|
46
|
+
// Check if required path params are present
|
|
47
|
+
if (!locator.contentType || !locator.documentId) {
|
|
48
|
+
throw new StatusError(
|
|
49
|
+
`The following path params are required: contentType, documentId`,
|
|
50
|
+
400
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Check if at least one of the querystring params are present
|
|
55
|
+
if (!locator.versionId && !locator.releaseId) {
|
|
56
|
+
throw new StatusError(
|
|
57
|
+
`One of the following querystring params are required: versionId, releaseId`,
|
|
58
|
+
400
|
|
59
|
+
)
|
|
39
60
|
}
|
|
40
61
|
|
|
41
62
|
// Fetch CMS to check if the provided `locator` exists
|
|
42
|
-
const page = await clientCMS.getCMSPage(locator)
|
|
63
|
+
const page = await clientCMS.getCMSPage(locator as Locator)
|
|
43
64
|
|
|
44
65
|
// If the content doesn't exist prevent preview mode from being enabled
|
|
45
66
|
if (!page) {
|
|
@@ -56,8 +77,9 @@ const handler: NextApiHandler = async (req, res) => {
|
|
|
56
77
|
})
|
|
57
78
|
|
|
58
79
|
// Redirect to the path from the fetched locator
|
|
59
|
-
|
|
60
|
-
|
|
80
|
+
const redirects = previewRedirects as Record<string, string>
|
|
81
|
+
if (redirects[locator.contentType]) {
|
|
82
|
+
res.redirect(redirects[locator.contentType])
|
|
61
83
|
return
|
|
62
84
|
}
|
|
63
85
|
|
|
File without changes
|
|
File without changes
|