@faststore/core 3.0.11 → 3.0.12
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/498.js +1 -1
- package/.next/server/chunks/640.js +1 -1
- package/.next/server/chunks/646.js +3 -3
- package/.next/server/chunks/997.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.js +1 -1
- package/.next/server/pages/500.js +1 -1
- package/.next/server/pages/[...slug].js +1 -1
- package/.next/server/pages/[slug]/p.js +1 -1
- package/.next/server/pages/en-US/404.html +2 -2
- package/.next/server/pages/en-US/500.html +2 -2
- package/.next/server/pages/en-US/account.html +2 -2
- package/.next/server/pages/en-US/checkout.html +2 -2
- package/.next/server/pages/en-US/login.html +2 -2
- package/.next/server/pages/en-US/s.html +2 -2
- package/.next/server/pages/en-US.html +2 -2
- package/.next/server/pages/index.js +1 -1
- package/.next/server/pages/login.js +1 -1
- package/.next/server/pages/s.js +1 -1
- package/.next/server/pages-manifest.json +1 -1
- package/.next/static/{4vX-pcZ2UBYJ2at7PjGjO → YyyfSkn4MlzCeIY09phdk}/_buildManifest.js +1 -1
- package/.next/static/chunks/pages/{_app-6516d0c2c7e0e686.js → _app-ad8623e78bc5b766.js} +1 -1
- package/.next/trace +91 -91
- package/.turbo/turbo-build.log +2 -2
- package/.turbo/turbo-test.log +10 -10
- package/faststore.config.default.js +4 -0
- package/package.json +2 -2
- package/src/components/cms/GlobalSections.tsx +17 -1
- package/src/components/templates/LandingPage/LandingPage.tsx +19 -2
- package/src/pages/[...slug].tsx +28 -6
- package/src/pages/[slug]/p.tsx +23 -7
- package/src/pages/index.tsx +24 -8
- package/src/pages/s.tsx +25 -9
- package/src/server/cms.ts +26 -0
- /package/.next/static/{4vX-pcZ2UBYJ2at7PjGjO → YyyfSkn4MlzCeIY09phdk}/_ssgManifest.js +0 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
$ yarn partytown & yarn generate && next build
|
|
2
|
-
$ faststore generate-graphql -c
|
|
3
2
|
$ partytown copylib ./public/~partytown
|
|
4
3
|
Partytown lib copied to: /home/runner/work/faststore/faststore/packages/core/public/~partytown
|
|
4
|
+
$ faststore generate-graphql -c
|
|
5
5
|
success - GraphQL schema, types, and optimizations successfully generated 🎉
|
|
6
6
|
⚠ No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
|
|
7
7
|
Attention: Next.js now collects completely anonymous telemetry regarding usage.
|
|
@@ -53,7 +53,7 @@ Route (pages) Size First Load JS
|
|
|
53
53
|
+ First Load JS shared by all 96.5 kB
|
|
54
54
|
├ chunks/framework-8e279965036b6169.js 45.4 kB
|
|
55
55
|
├ chunks/main-6f63f6746cc029db.js 33.1 kB
|
|
56
|
-
├ chunks/pages/_app-
|
|
56
|
+
├ chunks/pages/_app-ad8623e78bc5b766.js 12.5 kB
|
|
57
57
|
├ chunks/webpack-b4a2fdf4ef127bb7.js 2.45 kB
|
|
58
58
|
└ css/5d1f64b61ea581f4.css 3.05 kB
|
|
59
59
|
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
$ jest
|
|
2
|
-
PASS test/server/index.test.ts (21.
|
|
2
|
+
PASS test/server/index.test.ts (21.304 s)
|
|
3
3
|
FastStore GraphQL Layer
|
|
4
4
|
@faststore/api
|
|
5
|
-
✓ should return a valid GraphQL schema (
|
|
6
|
-
✓ should return a valid GraphQL schema contain all expected types (
|
|
7
|
-
✓ should return a valid GraphQL schema contain all expected queries (
|
|
5
|
+
✓ should return a valid GraphQL schema (6 ms)
|
|
6
|
+
✓ should return a valid GraphQL schema contain all expected types (5 ms)
|
|
7
|
+
✓ should return a valid GraphQL schema contain all expected queries (1 ms)
|
|
8
8
|
✓ should return a valid GraphQL schema contain all expected mutations (1 ms)
|
|
9
9
|
VTEX API Extension
|
|
10
|
-
✓ getTypeDefsFromFolder function should return an Array (
|
|
10
|
+
✓ getTypeDefsFromFolder function should return an Array (5 ms)
|
|
11
11
|
Third Party API Extension
|
|
12
|
-
✓ getTypeDefsFromFolder function should return an Array (
|
|
12
|
+
✓ getTypeDefsFromFolder function should return an Array (4 ms)
|
|
13
13
|
Final Schema after merging
|
|
14
|
-
✓ should return a valid merged GraphQL schema (
|
|
14
|
+
✓ should return a valid merged GraphQL schema (29 ms)
|
|
15
15
|
Envelop
|
|
16
|
-
✓ should exist with its plugins (
|
|
17
|
-
✓ should handle options and execute (
|
|
16
|
+
✓ should exist with its plugins (32 ms)
|
|
17
|
+
✓ should handle options and execute (125 ms)
|
|
18
18
|
|
|
19
19
|
Test Suites: 1 passed, 1 total
|
|
20
20
|
Tests: 9 passed, 9 total
|
|
21
21
|
Snapshots: 0 total
|
|
22
|
-
Time: 21.
|
|
22
|
+
Time: 21.349 s
|
|
23
23
|
Ran all test suites.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.12",
|
|
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": "110cdfee8c6b8149f44606b7de82d5488ce90420"
|
|
132
132
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Locator, Section } from '@vtex/client-cms'
|
|
2
2
|
import type { ComponentType } from 'react'
|
|
3
3
|
import { PropsWithChildren, lazy } from 'react'
|
|
4
|
+
import storeConfig from 'faststore.config'
|
|
4
5
|
import CUSTOM_COMPONENTS from 'src/customizations/src/components'
|
|
5
|
-
import { PageContentType, getPage } from 'src/server/cms'
|
|
6
|
+
import { PageContentType, getPage, getPageByVersionId } from 'src/server/cms'
|
|
6
7
|
|
|
7
8
|
import Toast from 'src/components/common/Toast'
|
|
8
9
|
import RenderSections from './RenderSections'
|
|
@@ -50,6 +51,21 @@ export default GlobalSections
|
|
|
50
51
|
export const getGlobalSectionsData = async (
|
|
51
52
|
previewData: Locator
|
|
52
53
|
): Promise<GlobalSectionsData> => {
|
|
54
|
+
if (storeConfig.cms.data) {
|
|
55
|
+
const cmsData = JSON.parse(storeConfig.cms.data)
|
|
56
|
+
const page = cmsData[GLOBAL_SECTIONS_CONTENT_TYPE][0]
|
|
57
|
+
|
|
58
|
+
if (page) {
|
|
59
|
+
const pageData = await getPageByVersionId<PageContentType>({
|
|
60
|
+
contentType: GLOBAL_SECTIONS_CONTENT_TYPE,
|
|
61
|
+
documentId: page.documentId,
|
|
62
|
+
versionId: page.versionId,
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
return pageData
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
53
69
|
const { sections } = await getPage<PageContentType>({
|
|
54
70
|
...(previewData?.contentType === GLOBAL_SECTIONS_CONTENT_TYPE &&
|
|
55
71
|
previewData),
|
|
@@ -10,11 +10,11 @@ import { OverriddenDefaultNewsletter as Newsletter } from 'src/components/sectio
|
|
|
10
10
|
import { OverriddenDefaultProductShelf as ProductShelf } from 'src/components/sections/ProductShelf/OverriddenDefaultProductShelf'
|
|
11
11
|
import Incentives from 'src/components/sections/Incentives'
|
|
12
12
|
import ProductTiles from 'src/components/sections/ProductTiles'
|
|
13
|
-
import { getPage } from 'src/server/cms'
|
|
13
|
+
import { getPage, getPageByVersionId } from 'src/server/cms'
|
|
14
14
|
import type { PageContentType } from 'src/server/cms'
|
|
15
15
|
import CUSTOM_COMPONENTS from 'src/customizations/src/components'
|
|
16
16
|
|
|
17
|
-
import storeConfig from '
|
|
17
|
+
import storeConfig from 'faststore.config'
|
|
18
18
|
|
|
19
19
|
/* A list of components that can be used in the CMS. */
|
|
20
20
|
const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
@@ -85,6 +85,23 @@ export const getLandingPageBySlug = async (
|
|
|
85
85
|
previewData: Locator
|
|
86
86
|
) => {
|
|
87
87
|
try {
|
|
88
|
+
if (storeConfig.cms.data) {
|
|
89
|
+
const cmsData = JSON.parse(storeConfig.cms.data)
|
|
90
|
+
const pageBySlug = cmsData['landingPage'].find((page) => {
|
|
91
|
+
slug === page.settings?.seo?.slug
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
if (pageBySlug) {
|
|
95
|
+
const landingPageData = await getPageByVersionId<PageContentType>({
|
|
96
|
+
contentType: 'landingPage',
|
|
97
|
+
documentId: pageBySlug.documentId,
|
|
98
|
+
versionId: pageBySlug.versionId,
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
return landingPageData
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
88
105
|
const landingPageData = await getPage<PageContentType>({
|
|
89
106
|
...(previewData?.contentType === 'landingPage'
|
|
90
107
|
? previewData
|
package/src/pages/[...slug].tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isNotFoundError } from '@faststore/api'
|
|
2
2
|
import type { GetStaticPaths, GetStaticProps } from 'next'
|
|
3
|
+
import storeConfig from 'faststore.config'
|
|
3
4
|
|
|
4
5
|
import { gql } from '@generated'
|
|
5
6
|
import type {
|
|
@@ -14,7 +15,12 @@ import GlobalSections, {
|
|
|
14
15
|
getGlobalSectionsData,
|
|
15
16
|
GlobalSectionsData,
|
|
16
17
|
} from 'src/components/cms/GlobalSections'
|
|
17
|
-
import {
|
|
18
|
+
import {
|
|
19
|
+
getPage,
|
|
20
|
+
getPageByVersionId,
|
|
21
|
+
PageContentType,
|
|
22
|
+
PLPContentType,
|
|
23
|
+
} from 'src/server/cms'
|
|
18
24
|
import ProductListingPage, {
|
|
19
25
|
ProductListingPageProps,
|
|
20
26
|
} from 'src/components/templates/ProductListingPage'
|
|
@@ -100,7 +106,7 @@ export const getStaticProps: GetStaticProps<
|
|
|
100
106
|
}
|
|
101
107
|
}
|
|
102
108
|
|
|
103
|
-
const [{ data, errors = [] }
|
|
109
|
+
const [{ data, errors = [] }] = await Promise.all([
|
|
104
110
|
execute<
|
|
105
111
|
ServerCollectionPageQueryQueryVariables,
|
|
106
112
|
ServerCollectionPageQueryQuery
|
|
@@ -108,11 +114,27 @@ export const getStaticProps: GetStaticProps<
|
|
|
108
114
|
variables: { slug },
|
|
109
115
|
operation: query,
|
|
110
116
|
}),
|
|
111
|
-
|
|
117
|
+
])
|
|
118
|
+
|
|
119
|
+
let pageData
|
|
120
|
+
|
|
121
|
+
if (storeConfig.cms.data) {
|
|
122
|
+
const cmsData = JSON.parse(storeConfig.cms.data)
|
|
123
|
+
const page = cmsData['plp'][0]
|
|
124
|
+
|
|
125
|
+
if (page) {
|
|
126
|
+
pageData = await getPageByVersionId<PLPContentType>({
|
|
127
|
+
contentType: 'plp',
|
|
128
|
+
documentId: page.documentId,
|
|
129
|
+
versionId: page.versionId,
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
} else {
|
|
133
|
+
pageData = await getPage<PLPContentType>({
|
|
112
134
|
...(previewData?.contentType === 'plp' ? previewData : null),
|
|
113
135
|
contentType: 'plp',
|
|
114
|
-
})
|
|
115
|
-
|
|
136
|
+
})
|
|
137
|
+
}
|
|
116
138
|
|
|
117
139
|
const notFound = errors.find(isNotFoundError)
|
|
118
140
|
|
|
@@ -130,7 +152,7 @@ export const getStaticProps: GetStaticProps<
|
|
|
130
152
|
return {
|
|
131
153
|
props: {
|
|
132
154
|
data,
|
|
133
|
-
page,
|
|
155
|
+
page: pageData,
|
|
134
156
|
globalSections: await globalSectionsPromise,
|
|
135
157
|
type: 'plp',
|
|
136
158
|
key: slug,
|
package/src/pages/[slug]/p.tsx
CHANGED
|
@@ -21,13 +21,13 @@ import { useSession } from 'src/sdk/session'
|
|
|
21
21
|
import { mark } from 'src/sdk/tests/mark'
|
|
22
22
|
import { execute } from 'src/server'
|
|
23
23
|
import type { PDPContentType } from 'src/server/cms'
|
|
24
|
-
import { getPage } from 'src/server/cms'
|
|
24
|
+
import { getPage, getPageByVersionId } from 'src/server/cms'
|
|
25
25
|
|
|
26
26
|
import GlobalSections, {
|
|
27
27
|
GlobalSectionsData,
|
|
28
28
|
getGlobalSectionsData,
|
|
29
29
|
} from 'src/components/cms/GlobalSections'
|
|
30
|
-
import storeConfig from '
|
|
30
|
+
import storeConfig from 'faststore.config'
|
|
31
31
|
import { useProductQuery } from 'src/sdk/product/useProductQuery'
|
|
32
32
|
import PageProvider, { PDPContext } from 'src/sdk/overrides/PageProvider'
|
|
33
33
|
|
|
@@ -200,18 +200,34 @@ export const getStaticProps: GetStaticProps<
|
|
|
200
200
|
Locator
|
|
201
201
|
> = async ({ params, previewData }) => {
|
|
202
202
|
const slug = params?.slug ?? ''
|
|
203
|
-
const [searchResult,
|
|
203
|
+
const [searchResult, globalSections] = await Promise.all([
|
|
204
204
|
execute<ServerProductQueryQueryVariables, ServerProductQueryQuery>({
|
|
205
205
|
variables: { locator: [{ key: 'slug', value: slug }] },
|
|
206
206
|
operation: query,
|
|
207
207
|
}),
|
|
208
|
-
getPage<PDPContentType>({
|
|
209
|
-
...(previewData?.contentType === 'pdp' ? previewData : null),
|
|
210
|
-
contentType: 'pdp',
|
|
211
|
-
}),
|
|
212
208
|
getGlobalSectionsData(previewData),
|
|
213
209
|
])
|
|
214
210
|
|
|
211
|
+
let cmsPage
|
|
212
|
+
|
|
213
|
+
if (storeConfig.cms.data) {
|
|
214
|
+
const cmsData = JSON.parse(storeConfig.cms.data)
|
|
215
|
+
const page = cmsData['pdp'][0]
|
|
216
|
+
|
|
217
|
+
if (page) {
|
|
218
|
+
cmsPage = getPageByVersionId<PDPContentType>({
|
|
219
|
+
contentType: 'pdp',
|
|
220
|
+
documentId: page.documentId,
|
|
221
|
+
versionId: page.versionId,
|
|
222
|
+
})
|
|
223
|
+
}
|
|
224
|
+
} else {
|
|
225
|
+
cmsPage = getPage<PDPContentType>({
|
|
226
|
+
...(previewData?.contentType === 'pdp' ? previewData : null),
|
|
227
|
+
contentType: 'pdp',
|
|
228
|
+
})
|
|
229
|
+
}
|
|
230
|
+
|
|
215
231
|
const { data, errors = [] } = searchResult
|
|
216
232
|
|
|
217
233
|
const notFound = errors.find(isNotFoundError)
|
package/src/pages/index.tsx
CHANGED
|
@@ -13,7 +13,7 @@ import ProductTiles from 'src/components/sections/ProductTiles'
|
|
|
13
13
|
import CUSTOM_COMPONENTS from 'src/customizations/src/components'
|
|
14
14
|
import { mark } from 'src/sdk/tests/mark'
|
|
15
15
|
import type { PageContentType } from 'src/server/cms'
|
|
16
|
-
import { getPage } from 'src/server/cms'
|
|
16
|
+
import { getPage, getPageByVersionId } from 'src/server/cms'
|
|
17
17
|
|
|
18
18
|
import GlobalSections, {
|
|
19
19
|
GlobalSectionsData,
|
|
@@ -85,13 +85,29 @@ export const getStaticProps: GetStaticProps<
|
|
|
85
85
|
Record<string, string>,
|
|
86
86
|
Locator
|
|
87
87
|
> = async ({ previewData }) => {
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
88
|
+
const globalSections = await getGlobalSectionsData(previewData)
|
|
89
|
+
|
|
90
|
+
if (storeConfig.cms.data) {
|
|
91
|
+
const cmsData = JSON.parse(storeConfig.cms.data)
|
|
92
|
+
const page = cmsData['home'][0]
|
|
93
|
+
|
|
94
|
+
if (page) {
|
|
95
|
+
const pageData = await getPageByVersionId<PageContentType>({
|
|
96
|
+
contentType: 'home',
|
|
97
|
+
documentId: page.documentId,
|
|
98
|
+
versionId: page.versionId,
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
props: { page: pageData, globalSections },
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const page = await getPage<PageContentType>({
|
|
108
|
+
...(previewData?.contentType === 'home' && previewData),
|
|
109
|
+
contentType: 'home',
|
|
110
|
+
})
|
|
95
111
|
|
|
96
112
|
return {
|
|
97
113
|
props: { page, globalSections },
|
package/src/pages/s.tsx
CHANGED
|
@@ -19,8 +19,8 @@ import GlobalSections, {
|
|
|
19
19
|
getGlobalSectionsData,
|
|
20
20
|
GlobalSectionsData,
|
|
21
21
|
} from 'src/components/cms/GlobalSections'
|
|
22
|
-
import { getPage, SearchContentType } from 'src/server/cms'
|
|
23
|
-
import storeConfig from '
|
|
22
|
+
import { getPage, getPageByVersionId, SearchContentType } from 'src/server/cms'
|
|
23
|
+
import storeConfig from 'faststore.config'
|
|
24
24
|
import SearchPage from 'src/components/templates/SearchPage/SearchPage'
|
|
25
25
|
|
|
26
26
|
type Props = {
|
|
@@ -118,13 +118,29 @@ export const getStaticProps: GetStaticProps<
|
|
|
118
118
|
Record<string, string>,
|
|
119
119
|
Locator
|
|
120
120
|
> = async ({ previewData }) => {
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
const globalSections = await getGlobalSectionsData(previewData)
|
|
122
|
+
|
|
123
|
+
if (storeConfig.cms.data) {
|
|
124
|
+
const cmsData = JSON.parse(storeConfig.cms.data)
|
|
125
|
+
const page = cmsData['search'][0]
|
|
126
|
+
|
|
127
|
+
if (page) {
|
|
128
|
+
const pageData = await getPageByVersionId<SearchContentType>({
|
|
129
|
+
contentType: 'search',
|
|
130
|
+
documentId: page.documentId,
|
|
131
|
+
versionId: page.versionId,
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
props: { page: pageData, globalSections },
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const page = await getPage<SearchContentType>({
|
|
141
|
+
...(previewData?.contentType === 'search' ? previewData : null),
|
|
142
|
+
contentType: 'search',
|
|
143
|
+
})
|
|
128
144
|
|
|
129
145
|
return {
|
|
130
146
|
props: {
|
package/src/server/cms.ts
CHANGED
|
@@ -39,6 +39,32 @@ export const getPage = async <T extends ContentData>(options: Options) => {
|
|
|
39
39
|
return pages[0] as T
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
export type VersionOptions = {
|
|
43
|
+
contentType: string
|
|
44
|
+
documentId: string
|
|
45
|
+
versionId: string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const getPageByVersionId = async <T extends ContentData>(
|
|
49
|
+
options: VersionOptions
|
|
50
|
+
) => {
|
|
51
|
+
const result = await clientCMS
|
|
52
|
+
.getCMSPage(options)
|
|
53
|
+
.then((page) => ({ data: [page] }))
|
|
54
|
+
|
|
55
|
+
const pages = result.data
|
|
56
|
+
|
|
57
|
+
if (!pages[0]) {
|
|
58
|
+
throw new MissingContentError(options)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (pages.length !== 1) {
|
|
62
|
+
throw new MultipleContentError(options)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return pages[0] as T
|
|
66
|
+
}
|
|
67
|
+
|
|
42
68
|
type ProductGallerySettings = {
|
|
43
69
|
settings: {
|
|
44
70
|
productGallery: {
|
|
File without changes
|