@faststore/core 3.1.3 → 3.2.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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +3 -3
- 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/371.js +1 -1
- package/.next/server/chunks/5430.js +1 -1
- package/.next/server/chunks/5754.js +1 -1
- package/.next/server/functions-config-manifest.json +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/[...slug].js +1 -1
- package/.next/server/pages/api/graphql.js +1 -1
- package/.next/server/pages/en-US/404.html +1 -1
- package/.next/server/pages/en-US/500.html +1 -1
- package/.next/server/pages/en-US/account.html +1 -1
- package/.next/server/pages/en-US/checkout.html +1 -1
- package/.next/server/pages/en-US/login.html +1 -1
- package/.next/server/pages/en-US/s.html +1 -1
- package/.next/server/pages/en-US.html +1 -1
- package/.next/server/pages-manifest.json +1 -1
- package/.next/static/chunks/pages/{_app-15d247b2153b1dc4.js → _app-7d970aad41a57338.js} +1 -1
- package/.next/trace +98 -97
- package/.turbo/turbo-build.log +2 -2
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +5 -5
- package/CHANGELOG.md +10 -0
- package/discovery.config.default.js +1 -0
- package/package.json +3 -3
- package/src/customizations/src/redirects/index.ts +12 -0
- package/src/pages/[...slug].tsx +11 -0
- package/src/sdk/redirects/index.ts +49 -0
- /package/.next/static/{_FAXrM-0l_1njeCBtxFGm → pAHxcj00oZn6QVPqQTt22}/_buildManifest.js +0 -0
- /package/.next/static/{_FAXrM-0l_1njeCBtxFGm → pAHxcj00oZn6QVPqQTt22}/_ssgManifest.js +0 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -67,7 +67,7 @@ Route (pages) Size First Load JS
|
|
|
67
67
|
+ First Load JS shared by all 94.7 kB
|
|
68
68
|
├ chunks/framework-12a146e94cfcf7c4.js 45.4 kB
|
|
69
69
|
├ chunks/main-209ac4974b020af1.js 33.1 kB
|
|
70
|
-
├ chunks/pages/_app-
|
|
70
|
+
├ chunks/pages/_app-7d970aad41a57338.js 9.84 kB
|
|
71
71
|
├ chunks/webpack-dbe55f259a50963c.js 3.39 kB
|
|
72
72
|
└ css/ee0556daedda6306.css 3.07 kB
|
|
73
73
|
|
|
@@ -75,4 +75,4 @@ Route (pages) Size First Load JS
|
|
|
75
75
|
○ (Static) automatically rendered as static HTML (uses no initial props)
|
|
76
76
|
● (SSG) automatically generated as static HTML + JSON (uses getStaticProps)
|
|
77
77
|
|
|
78
|
-
Done in
|
|
78
|
+
Done in 72.42s.
|
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/
|
|
4
|
-
PASS test/
|
|
5
|
-
PASS test/server/index.test.ts (39.
|
|
3
|
+
PASS test/utils/multipleTemplates.test.ts (35.969 s)
|
|
4
|
+
PASS test/server/cms/index.test.ts (36.256 s)
|
|
5
|
+
PASS test/server/index.test.ts (39.998 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:
|
|
10
|
+
Time: 41.213 s
|
|
11
11
|
Ran all test suites.
|
|
12
|
-
Done in 42.
|
|
12
|
+
Done in 42.94s.
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [3.2.0](https://github.com/vtex/faststore/compare/v3.1.4...v3.2.0) (2024-12-16)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- add new redirects feature ([#2583](https://github.com/vtex/faststore/issues/2583)) ([4624a5d](https://github.com/vtex/faststore/commit/4624a5d101fccc40788c362ab744f250386a8d4d))
|
|
11
|
+
|
|
12
|
+
## [3.1.4](https://github.com/vtex/faststore/compare/v3.1.3...v3.1.4) (2024-12-16)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @faststore/core
|
|
15
|
+
|
|
6
16
|
## 3.1.3 (2024-12-13)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @faststore/core
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "vtex/faststore",
|
|
6
6
|
"browserslist": "supports es6-module and not dead",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@faststore/graphql-utils": "^3.1.3",
|
|
49
49
|
"@faststore/lighthouse": "^3.1.3",
|
|
50
50
|
"@faststore/sdk": "^3.1.3",
|
|
51
|
-
"@faststore/ui": "^3.1.
|
|
51
|
+
"@faststore/ui": "^3.1.4",
|
|
52
52
|
"@graphql-codegen/cli": "5.0.2",
|
|
53
53
|
"@graphql-codegen/client-preset": "4.2.6",
|
|
54
54
|
"@graphql-codegen/typescript": "4.0.7",
|
|
@@ -128,5 +128,5 @@
|
|
|
128
128
|
"node": "18.19.0",
|
|
129
129
|
"yarn": "1.19.1"
|
|
130
130
|
},
|
|
131
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "435ed73e9db93c23324d1cbc070a3f6bec9cac14"
|
|
132
132
|
}
|
package/src/pages/[...slug].tsx
CHANGED
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
import ProductListingPage, {
|
|
23
23
|
ProductListingPageProps,
|
|
24
24
|
} from 'src/components/templates/ProductListingPage'
|
|
25
|
+
import { getRedirect } from 'src/sdk/redirects'
|
|
25
26
|
import { PageContentType } from 'src/server/cms'
|
|
26
27
|
import { getPLP, PLPContentType } from 'src/server/cms/plp'
|
|
27
28
|
import { getDynamicContent } from 'src/utils/dynamicContent'
|
|
@@ -140,6 +141,16 @@ export const getStaticProps: GetStaticProps<
|
|
|
140
141
|
const notFound = errors.find(isNotFoundError)
|
|
141
142
|
|
|
142
143
|
if (notFound) {
|
|
144
|
+
if (storeConfig.experimental.enableRedirects) {
|
|
145
|
+
const redirect = await getRedirect({ pathname: `/${slug}` })
|
|
146
|
+
if (redirect) {
|
|
147
|
+
return {
|
|
148
|
+
redirect,
|
|
149
|
+
revalidate: 60 * 5, // 5 minutes
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
143
154
|
return {
|
|
144
155
|
notFound: true,
|
|
145
156
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import storeConfig from 'discovery.config'
|
|
2
|
+
import { matcher } from 'src/customizations/src/redirects'
|
|
3
|
+
|
|
4
|
+
type GetRedirectArgs = {
|
|
5
|
+
pathname: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type GetRedirectReturn = {
|
|
9
|
+
destination: string
|
|
10
|
+
permanent: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type RewriterResponse = {
|
|
14
|
+
location: string
|
|
15
|
+
status: number
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const PERMANENT_STATUS = 308
|
|
19
|
+
|
|
20
|
+
export async function getRedirect({
|
|
21
|
+
pathname,
|
|
22
|
+
}: GetRedirectArgs): Promise<GetRedirectReturn> {
|
|
23
|
+
try {
|
|
24
|
+
const redirectMatch = matcher({ pathname })
|
|
25
|
+
if (redirectMatch) {
|
|
26
|
+
return {
|
|
27
|
+
destination: redirectMatch.destination,
|
|
28
|
+
permanent: redirectMatch.permanent ?? true,
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const response = await fetch(
|
|
33
|
+
`https://${storeConfig.api.storeId}.myvtex.com/_v/public/redirect-evaluate${pathname}`
|
|
34
|
+
)
|
|
35
|
+
const rewriterData = (await response.json()) as RewriterResponse
|
|
36
|
+
|
|
37
|
+
if (rewriterData.location) {
|
|
38
|
+
return {
|
|
39
|
+
destination: rewriterData.location,
|
|
40
|
+
permanent: rewriterData.status === PERMANENT_STATUS,
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return null
|
|
44
|
+
} catch (err) {
|
|
45
|
+
// TODO: handle error logs
|
|
46
|
+
console.error(err)
|
|
47
|
+
return null
|
|
48
|
+
}
|
|
49
|
+
}
|
|
File without changes
|
|
File without changes
|