@faststore/core 3.42.0 → 3.43.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.
Files changed (89) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +16 -16
  3. package/.next/cache/.tsbuildinfo +1 -1
  4. package/.next/cache/config.json +3 -3
  5. package/.next/cache/webpack/client-production/0.pack +0 -0
  6. package/.next/cache/webpack/client-production/index.pack +0 -0
  7. package/.next/cache/webpack/server-production/0.pack +0 -0
  8. package/.next/cache/webpack/server-production/index.pack +0 -0
  9. package/.next/prerender-manifest.js +1 -1
  10. package/.next/prerender-manifest.json +1 -1
  11. package/.next/react-loadable-manifest.json +4 -4
  12. package/.next/routes-manifest.json +1 -1
  13. package/.next/server/chunks/1506.js +1 -1
  14. package/.next/server/chunks/4289.js +4 -4
  15. package/.next/server/chunks/6968.js +9 -0
  16. package/.next/server/chunks/8646.js +1 -1
  17. package/.next/server/middleware-build-manifest.js +1 -1
  18. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  19. package/.next/server/pages/404.js +1 -1
  20. package/.next/server/pages/404.js.nft.json +1 -1
  21. package/.next/server/pages/500.js +1 -1
  22. package/.next/server/pages/500.js.nft.json +1 -1
  23. package/.next/server/pages/[...slug].js +1 -1
  24. package/.next/server/pages/[...slug].js.nft.json +1 -1
  25. package/.next/server/pages/[slug]/p.js +1 -1
  26. package/.next/server/pages/[slug]/p.js.nft.json +1 -1
  27. package/.next/server/pages/_app.js.nft.json +1 -1
  28. package/.next/server/pages/_document.js.nft.json +1 -1
  29. package/.next/server/pages/_error.js.nft.json +1 -1
  30. package/.next/server/pages/account/profile.js +1 -1
  31. package/.next/server/pages/account/profile.js.nft.json +1 -1
  32. package/.next/server/pages/account.js.nft.json +1 -1
  33. package/.next/server/pages/api/graphql.js.nft.json +1 -1
  34. package/.next/server/pages/api/health/live.js.nft.json +1 -1
  35. package/.next/server/pages/api/health/ready.js.nft.json +1 -1
  36. package/.next/server/pages/api/preview.js +1 -1
  37. package/.next/server/pages/api/preview.js.nft.json +1 -1
  38. package/.next/server/pages/checkout.js +1 -1
  39. package/.next/server/pages/checkout.js.nft.json +1 -1
  40. package/.next/server/pages/en-US/404.html +2 -2
  41. package/.next/server/pages/en-US/500.html +2 -2
  42. package/.next/server/pages/en-US/checkout.html +2 -2
  43. package/.next/server/pages/en-US/login.html +2 -2
  44. package/.next/server/pages/en-US/s.html +2 -2
  45. package/.next/server/pages/en-US.html +2 -2
  46. package/.next/server/pages/index.js +1 -1
  47. package/.next/server/pages/index.js.nft.json +1 -1
  48. package/.next/server/pages/login.js +1 -1
  49. package/.next/server/pages/login.js.nft.json +1 -1
  50. package/.next/server/pages/s.js +1 -1
  51. package/.next/server/pages/s.js.nft.json +1 -1
  52. package/.next/server/pages-manifest.json +1 -1
  53. package/.next/static/chunks/{1552.e7cece605fc2e1cd.js → 1552.b5a073e7ac834965.js} +1 -1
  54. package/.next/static/chunks/630.13d3dd939b789798.js +6 -0
  55. package/.next/static/chunks/8827.179b49f8ab3afe48.js +1 -0
  56. package/.next/static/chunks/pages/[...slug]-2cfb2b1b8ee3b7a9.js +1 -0
  57. package/.next/static/chunks/pages/{_app-0f16b6b5d7dfab2a.js → _app-f02182ccd58f2781.js} +1 -1
  58. package/.next/static/chunks/webpack-0dd5a14ceff64065.js +1 -0
  59. package/.next/static/{Ra_8xXVEVCNHcT2KePSUO → f5jWOXDXh3GdBy9EK8IDc}/_buildManifest.js +1 -1
  60. package/.next/trace +111 -109
  61. package/.turbo/turbo-build.log +17 -17
  62. package/.turbo/turbo-test.log +5 -5
  63. package/CHANGELOG.md +6 -0
  64. package/discovery.config.default.js +6 -0
  65. package/package.json +3 -2
  66. package/src/components/cms/GlobalSections.tsx +13 -9
  67. package/src/components/templates/LandingPage/LandingPage.tsx +22 -18
  68. package/src/components/templates/ProductListingPage/ProductListing.tsx +6 -1
  69. package/src/experimental/searchServerSideFunctions/getServerSideProps.ts +8 -5
  70. package/src/experimental/searchServerSideFunctions/getStaticProps.ts +9 -7
  71. package/src/pages/404.tsx +6 -5
  72. package/src/pages/500.tsx +6 -5
  73. package/src/pages/[...slug].tsx +11 -4
  74. package/src/pages/[slug]/p.tsx +14 -5
  75. package/src/pages/api/preview.ts +43 -18
  76. package/src/pages/index.tsx +9 -7
  77. package/src/pages/login.tsx +6 -5
  78. package/src/sdk/error/MissingContentError/MissingContentError.ts +6 -4
  79. package/src/sdk/error/MultipleContentError/MultipleContentError.ts +6 -4
  80. package/src/server/cms/index.ts +1 -2
  81. package/src/server/content/service.ts +227 -0
  82. package/src/server/content/types.ts +26 -0
  83. package/src/server/content/utils.ts +8 -0
  84. package/.next/server/chunks/6026.js +0 -9
  85. package/.next/static/chunks/1036.27f5244aaf7d0915.js +0 -1
  86. package/.next/static/chunks/485.a35fab0c7c75a11b.js +0 -1
  87. package/.next/static/chunks/pages/[...slug]-f4fd6c8d7dc53f8f.js +0 -1
  88. package/.next/static/chunks/webpack-d72e5eb27bf80195.js +0 -1
  89. /package/.next/static/{Ra_8xXVEVCNHcT2KePSUO → f5jWOXDXh3GdBy9EK8IDc}/_ssgManifest.js +0 -0
@@ -1,23 +1,23 @@
1
1
 
2
- > @faststore/core@3.41.9 prebuild /home/runner/work/faststore/faststore/packages/core
2
+ > @faststore/core@3.42.0 prebuild /home/runner/work/faststore/faststore/packages/core
3
3
  > na run partytown && na run generate
4
4
 
5
5
 
6
- > @faststore/core@3.41.9 partytown /home/runner/work/faststore/faststore/packages/core
6
+ > @faststore/core@3.42.0 partytown /home/runner/work/faststore/faststore/packages/core
7
7
  > partytown copylib ./public/~partytown
8
8
 
9
9
  Partytown lib copied to: /home/runner/work/faststore/faststore/packages/core/public/~partytown
10
10
 
11
- > @faststore/core@3.41.9 generate /home/runner/work/faststore/faststore/packages/core
11
+ > @faststore/core@3.42.0 generate /home/runner/work/faststore/faststore/packages/core
12
12
  > na run generate:schema && na run generate:codegen && na run format:generated
13
13
 
14
14
 
15
- > @faststore/core@3.41.9 generate:schema /home/runner/work/faststore/faststore/packages/core
15
+ > @faststore/core@3.42.0 generate:schema /home/runner/work/faststore/faststore/packages/core
16
16
  > tsx src/server/generator/generateGraphQLSchemaFile.ts
17
17
 
18
18
  Schema GraphQL file generated successfully
19
19
 
20
- > @faststore/core@3.41.9 generate:codegen /home/runner/work/faststore/faststore/packages/core
20
+ > @faststore/core@3.42.0 generate:codegen /home/runner/work/faststore/faststore/packages/core
21
21
  > graphql-codegen
22
22
 
23
23
  [STARTED] Parse Configuration
@@ -37,11 +37,11 @@ Running lifecycle hook "afterStart" scripts...
37
37
  [CLI] Loading Documents
38
38
  [CLI] Generating output
39
39
 
40
- > @faststore/core@3.41.9 format:generated /home/runner/work/faststore/faststore/packages/core
40
+ > @faststore/core@3.42.0 format:generated /home/runner/work/faststore/faststore/packages/core
41
41
  > prettier --write "@generated/**/*.{ts,js,tsx,jsx,json}" --loglevel error
42
42
 
43
43
 
44
- > @faststore/core@3.41.9 build /home/runner/work/faststore/faststore/packages/core
44
+ > @faststore/core@3.42.0 build /home/runner/work/faststore/faststore/packages/core
45
45
  > next build
46
46
 
47
47
  ⚠ No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
@@ -69,29 +69,29 @@ Warning: Dynamic Content not found for the page: home. Refer to the Dynamic Cont
69
69
  Route (pages) Size First Load JS
70
70
  ┌ ● / 3.86 kB 124 kB
71
71
  ├ └ css/b1806cbafd0c1f81.css 3.06 kB
72
- ├ /_app 0 B 92.4 kB
73
- ├ ● /[...slug] 2.34 kB 133 kB
72
+ ├ /_app 0 B 92.5 kB
73
+ ├ ● /[...slug] 2.44 kB 133 kB
74
74
  ├ ● /[slug]/p 35.7 kB 156 kB
75
75
  ├ ├ css/a3ca6a9b63f657be.css 5.75 kB
76
76
  ├ ├ css/62a5153ac7061286.css 6.11 kB
77
77
  ├ └ css/b5bf49598c8f8b66.css 16.1 kB
78
78
  ├ ○ /404 1.48 kB 122 kB
79
79
  ├ ● /500 1.48 kB 122 kB
80
- ├ λ /account 240 B 92.7 kB
80
+ ├ λ /account 240 B 92.8 kB
81
81
  ├ λ /account/profile 1.34 kB 122 kB
82
82
  ├ └ css/249b9deaabc0d32d.css 2.51 kB
83
- ├ λ /api/graphql 0 B 92.4 kB
84
- ├ λ /api/health/live 0 B 92.4 kB
85
- ├ λ /api/health/ready 0 B 92.4 kB
86
- ├ λ /api/preview 0 B 92.4 kB
83
+ ├ λ /api/graphql 0 B 92.5 kB
84
+ ├ λ /api/health/live 0 B 92.5 kB
85
+ ├ λ /api/health/ready 0 B 92.5 kB
86
+ ├ λ /api/preview 0 B 92.5 kB
87
87
  ├ ● /checkout 694 B 121 kB
88
88
  ├ ● /login 1.59 kB 122 kB
89
89
  └ ● /s 3.17 kB 134 kB
90
- + First Load JS shared by all 95.9 kB
90
+ + First Load JS shared by all 96 kB
91
91
  ├ chunks/framework-807b0f81cbc129f0.js 45.4 kB
92
92
  ├ chunks/main-5569625b3fdd6741.js 33.1 kB
93
- ├ chunks/pages/_app-0f16b6b5d7dfab2a.js 10.4 kB
94
- ├ chunks/webpack-d72e5eb27bf80195.js 3.62 kB
93
+ ├ chunks/pages/_app-f02182ccd58f2781.js 10.4 kB
94
+ ├ chunks/webpack-0dd5a14ceff64065.js 3.68 kB
95
95
  └ css/0a57ee6c7a57788c.css 3.49 kB
96
96
 
97
97
  λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
@@ -1,14 +1,14 @@
1
1
 
2
- > @faststore/core@3.41.9 test /home/runner/work/faststore/faststore/packages/core
2
+ > @faststore/core@3.42.0 test /home/runner/work/faststore/faststore/packages/core
3
3
  > jest
4
4
 
5
- PASS test/utils/multipleTemplates.test.ts (23.58 s)
6
- PASS test/server/cms/global.test.ts (24.55 s)
5
+ PASS test/server/cms/global.test.ts (24.058 s)
6
+ PASS test/utils/multipleTemplates.test.ts (24.28 s)
7
7
  PASS test/server/cms/index.test.ts
8
- PASS test/server/index.test.ts (29.038 s)
8
+ PASS test/server/index.test.ts (29.435 s)
9
9
 
10
10
  Test Suites: 4 passed, 4 total
11
11
  Tests: 22 passed, 22 total
12
12
  Snapshots: 0 total
13
- Time: 30.255 s
13
+ Time: 30.555 s
14
14
  Ran all test suites.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
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.43.0](https://github.com/vtex/faststore/compare/v3.42.0...v3.43.0) (2025-05-12)
7
+
8
+ ### Features
9
+
10
+ - [CP-432] [CP-433] Adding CP integration as a data source alternative to hCMS ([#2807](https://github.com/vtex/faststore/issues/2807)) ([122e2d9](https://github.com/vtex/faststore/commit/122e2d94cb94a6edc9726a3be8d83e62fa44a51e)), closes [/github.com/vtex/faststore/pull/2807/files#diff-63a7f8cba93bce2eb5ed6be3a1bcf1fbde76d643b165ae2a1a44cc8765dfb73fR141](https://github.com//github.com/vtex/faststore/pull/2807/files/issues/diff-63a7f8cba93bce2eb5ed6be3a1bcf1fbde76d643b165ae2a1a44cc8765dfb73fR141) [/github.com/vtex/faststore/pull/2807/files#diff-8dd0ec358e808043c69af593825ff65e9afe1dd776dad04f15480a45b57a2608R91](https://github.com//github.com/vtex/faststore/pull/2807/files/issues/diff-8dd0ec358e808043c69af593825ff65e9afe1dd776dad04f15480a45b57a2608R91) [/github.com/vtex/faststore/pull/2807/files#diff-63a7f8cba93bce2eb5ed6be3a1bcf1fbde76d643b165ae2a1a44cc8765dfb73fR24](https://github.com//github.com/vtex/faststore/pull/2807/files/issues/diff-63a7f8cba93bce2eb5ed6be3a1bcf1fbde76d643b165ae2a1a44cc8765dfb73fR24)
11
+
6
12
  # [3.42.0](https://github.com/vtex/faststore/compare/v3.41.9...v3.42.0) (2025-05-08)
7
13
 
8
14
  ### Features
@@ -88,6 +88,8 @@ module.exports = {
88
88
  plp: '/office',
89
89
  search: '/s?q=headphone',
90
90
  pdp: '/apple-magic-mouse/p',
91
+ 500: '/500',
92
+ 404: '/404',
91
93
  },
92
94
 
93
95
  // Lighthouse CI
@@ -122,6 +124,10 @@ module.exports = {
122
124
  data: process.env.CMS_DATA,
123
125
  },
124
126
 
127
+ contentSource: {
128
+ type: 'CMS',
129
+ },
130
+
125
131
  experimental: {
126
132
  cypressVersion: 12,
127
133
  enableCypressExtension: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/core",
3
- "version": "3.42.0",
3
+ "version": "3.43.0",
4
4
  "license": "MIT",
5
5
  "repository": "vtex/faststore",
6
6
  "browserslist": "supports es6-module and not dead",
@@ -62,6 +62,7 @@
62
62
  "@parcel/watcher": "^2.4.0",
63
63
  "@types/react": "^18.2.42",
64
64
  "@vtex/client-cms": "^0.2.12",
65
+ "@vtex/client-cp": "0.2.2",
65
66
  "@vtex/prettier-config": "1.0.0",
66
67
  "autoprefixer": "^10.4.0",
67
68
  "css-loader": "^6.7.1",
@@ -105,5 +106,5 @@
105
106
  "ts-jest": "29.1.1",
106
107
  "typescript": "5.3.2"
107
108
  },
108
- "gitHead": "d8814aed0849211cb76d06b880c6d556bf1ac898"
109
+ "gitHead": "201303ea329a26779a521232b5f866dea4aa278c"
109
110
  }
@@ -1,6 +1,8 @@
1
- import type { Locator, Section } from '@vtex/client-cms'
1
+ import type { Section } from '@vtex/client-cms'
2
2
  import storeConfig from 'discovery.config'
3
- import { type PageContentType, getPage } from 'src/server/cms'
3
+ import type { PageContentType } from 'src/server/cms'
4
+ import { contentService } from 'src/server/content/service'
5
+ import type { PreviewData } from 'src/server/content/types'
4
6
 
5
7
  export const GLOBAL_SECTIONS_CONTENT_TYPE = 'globalSections'
6
8
  export const GLOBAL_SECTIONS_HEADER_CONTENT_TYPE = 'globalHeaderSections'
@@ -11,7 +13,7 @@ export type GlobalSectionsData = {
11
13
  }
12
14
 
13
15
  export const getGlobalSectionsByType = async (
14
- previewData: Locator,
16
+ previewData: PreviewData,
15
17
  contentType: string
16
18
  ): Promise<GlobalSectionsData> => {
17
19
  if (storeConfig.cms.data) {
@@ -19,26 +21,28 @@ export const getGlobalSectionsByType = async (
19
21
  const page = cmsData[contentType][0]
20
22
 
21
23
  if (page) {
22
- const pageData = getPage<PageContentType>({
23
- contentType: contentType,
24
+ const pageData = contentService.getSingleContent<PageContentType>({
25
+ contentType,
26
+ previewData,
24
27
  documentId: page.documentId,
25
28
  versionId: page.versionId,
29
+ releaseId: page.releaseId,
26
30
  })
27
31
 
28
32
  return pageData
29
33
  }
30
34
  }
31
35
 
32
- const pageData = getPage<PageContentType>({
33
- ...(previewData?.contentType === contentType && previewData),
34
- contentType: contentType,
36
+ const pageData = contentService.getSingleContent<PageContentType>({
37
+ contentType,
38
+ previewData,
35
39
  })
36
40
 
37
41
  return pageData
38
42
  }
39
43
 
40
44
  export const getGlobalSectionsData = (
41
- previewData: Locator
45
+ previewData: PreviewData
42
46
  ): Promise<GlobalSectionsData>[] => {
43
47
  const globalSections = getGlobalSectionsByType(
44
48
  previewData,
@@ -1,4 +1,3 @@
1
- import type { Locator } from '@vtex/client-cms'
2
1
  import { NextSeo, SiteLinksSearchBoxJsonLd } from 'next-seo'
3
2
  import type { ComponentType } from 'react'
4
3
 
@@ -17,9 +16,10 @@ import { default as GLOBAL_COMPONENTS } from 'src/components/cms/global/Componen
17
16
  import MissingContentError from 'src/sdk/error/MissingContentError/MissingContentError'
18
17
  import PageProvider from 'src/sdk/overrides/PageProvider'
19
18
  import type { PageContentType } from 'src/server/cms'
20
- import { getPage } from 'src/server/cms'
21
19
 
22
20
  import storeConfig from 'discovery.config'
21
+ import type { PreviewData } from 'src/server/content/types'
22
+ import { contentService } from 'src/server/content/service'
23
23
 
24
24
  /* A list of components that can be used in the CMS. */
25
25
  const COMPONENTS: Record<string, ComponentType<any>> = {
@@ -105,7 +105,7 @@ export default function LandingPage({
105
105
 
106
106
  export const getLandingPageBySlug = async (
107
107
  slug: string,
108
- previewData: Locator
108
+ previewData: PreviewData
109
109
  ) => {
110
110
  try {
111
111
  if (storeConfig.cms.data) {
@@ -115,26 +115,30 @@ export const getLandingPageBySlug = async (
115
115
  })
116
116
 
117
117
  if (pageBySlug) {
118
- const landingPageData = await getPage<PageContentType>({
119
- contentType: 'landingPage',
120
- documentId: pageBySlug.documentId,
121
- versionId: pageBySlug.versionId,
122
- })
118
+ const landingPageData =
119
+ await contentService.getSingleContent<PageContentType>({
120
+ contentType: 'landingPage',
121
+ previewData,
122
+ documentId: pageBySlug.documentId,
123
+ versionId: pageBySlug.versionId,
124
+ releaseId: pageBySlug.releaseId,
125
+ slug: pageBySlug.settings?.seo?.slug,
126
+ })
123
127
 
124
128
  return landingPageData
125
129
  }
126
130
  }
127
131
 
128
- const landingPageData = await getPage<PageContentType>({
129
- ...(previewData?.contentType === 'landingPage'
130
- ? previewData
131
- : {
132
- filters: {
133
- filters: { 'settings.seo.slug': `/${slug}` },
134
- },
135
- }),
136
- contentType: 'landingPage',
137
- })
132
+ const landingPageData =
133
+ await contentService.getSingleContent<PageContentType>({
134
+ contentType: 'landingPage',
135
+ previewData,
136
+ slug,
137
+ filters:
138
+ previewData?.contentType !== 'landingPage'
139
+ ? { filters: { 'settings.seo.slug': `/${slug}` } }
140
+ : undefined,
141
+ })
138
142
  return landingPageData
139
143
  } catch (error) {
140
144
  if (error instanceof MissingContentError) {
@@ -23,6 +23,8 @@ import {
23
23
  } from 'src/sdk/product/usePageProductsQuery'
24
24
  import { useProductGalleryQuery } from 'src/sdk/product/useProductGalleryQuery'
25
25
  import { useApplySearchState } from 'src/sdk/search/state'
26
+ import { useRouter } from 'next/router'
27
+ import { isContentPlatformSource } from 'src/server/content/utils'
26
28
 
27
29
  const ScrollToTopButton = dynamic(
28
30
  () =>
@@ -49,6 +51,7 @@ export default function ProductListing({
49
51
  serverManyProductsVariables,
50
52
  globalSections,
51
53
  }: ProductListingPageProps) {
54
+ const router = useRouter()
52
55
  const { state } = useSearch()
53
56
  const { sort, term, selectedFacets } = state
54
57
 
@@ -56,7 +59,9 @@ export default function ProductListing({
56
59
 
57
60
  const applySearchState = useApplySearchState()
58
61
  useEffect(() => {
59
- applySearchState(formatSearchState(state))
62
+ if (!isContentPlatformSource() || !router.isPreview) {
63
+ applySearchState(formatSearchState(state))
64
+ }
60
65
  }, [])
61
66
 
62
67
  const { data: pageProductGalleryData } = useProductGalleryQuery({
@@ -1,16 +1,17 @@
1
1
  import type { GetServerSideProps } from 'next'
2
2
  import type { SearchPageProps } from './getStaticProps'
3
3
 
4
- import type { Locator } from '@vtex/client-cms'
5
4
  import storeConfig from 'discovery.config'
6
5
  import { getGlobalSectionsData } from 'src/components/cms/GlobalSections'
7
6
  import { type SearchContentType, getPage } from 'src/server/cms'
8
7
  import { injectGlobalSections } from 'src/server/cms/global'
8
+ import type { PreviewData } from 'src/server/content/types'
9
+ import { contentService } from 'src/server/content/service'
9
10
 
10
11
  export const getServerSideProps: GetServerSideProps<
11
12
  SearchPageProps,
12
13
  Record<string, string>,
13
- Locator
14
+ PreviewData
14
15
  > = async (context) => {
15
16
  const { previewData, query, res } = context
16
17
  const searchTerm = (query.q as string)?.split('+').join(' ')
@@ -31,10 +32,12 @@ export const getServerSideProps: GetServerSideProps<
31
32
  globalSectionsHeader,
32
33
  globalSectionsFooter,
33
34
  ] = await Promise.all([
34
- getPage<SearchContentType>({
35
+ contentService.getSingleContent<SearchContentType>({
35
36
  contentType: 'search',
37
+ previewData,
36
38
  documentId: page.documentId,
37
39
  versionId: page.versionId,
40
+ releaseId: page.releaseId,
38
41
  }),
39
42
  globalSectionsPromise,
40
43
  globalSectionsHeaderPromise,
@@ -58,9 +61,9 @@ export const getServerSideProps: GetServerSideProps<
58
61
 
59
62
  const [page, globalSections, globalSectionsHeader, globalSectionsFooter] =
60
63
  await Promise.all([
61
- getPage<SearchContentType>({
62
- ...(previewData?.contentType === 'search' ? previewData : null),
64
+ contentService.getSingleContent<SearchContentType>({
63
65
  contentType: 'search',
66
+ previewData,
64
67
  }),
65
68
  globalSectionsPromise,
66
69
  globalSectionsHeaderPromise,
@@ -1,12 +1,13 @@
1
- import type { Locator } from '@vtex/client-cms'
2
1
  import storeConfig from 'discovery.config'
3
2
  import type { GetStaticProps } from 'next'
4
3
  import {
5
4
  getGlobalSectionsData,
6
5
  type GlobalSectionsData,
7
6
  } from 'src/components/cms/GlobalSections'
8
- import { getPage, type SearchContentType } from 'src/server/cms'
7
+ import type { SearchContentType } from 'src/server/cms'
9
8
  import { injectGlobalSections } from 'src/server/cms/global'
9
+ import { contentService } from 'src/server/content/service'
10
+ import type { PreviewData } from 'src/server/content/types'
10
11
 
11
12
  export type SearchPageProps = {
12
13
  page: SearchContentType
@@ -21,10 +22,9 @@ export type SearchPageProps = {
21
22
  export const getStaticProps: GetStaticProps<
22
23
  SearchPageProps,
23
24
  Record<string, string>,
24
- Locator
25
+ PreviewData
25
26
  > = async (context) => {
26
27
  const { previewData } = context
27
-
28
28
  const [
29
29
  globalSectionsPromise,
30
30
  globalSectionsHeaderPromise,
@@ -42,10 +42,12 @@ export const getStaticProps: GetStaticProps<
42
42
  globalSectionsHeader,
43
43
  globalSectionsFooter,
44
44
  ] = await Promise.all([
45
- getPage<SearchContentType>({
45
+ contentService.getSingleContent<SearchContentType>({
46
46
  contentType: 'search',
47
+ previewData,
47
48
  documentId: page.documentId,
48
49
  versionId: page.versionId,
50
+ releaseId: page.releaseId,
49
51
  }),
50
52
  globalSectionsPromise,
51
53
  globalSectionsHeaderPromise,
@@ -66,9 +68,9 @@ export const getStaticProps: GetStaticProps<
66
68
 
67
69
  const [page, globalSections, globalSectionsHeader, globalSectionsFooter] =
68
70
  await Promise.all([
69
- getPage<SearchContentType>({
70
- ...(previewData?.contentType === 'search' ? previewData : null),
71
+ contentService.getSingleContent<SearchContentType>({
71
72
  contentType: 'search',
73
+ previewData,
72
74
  }),
73
75
  globalSectionsPromise,
74
76
  globalSectionsHeaderPromise,
package/src/pages/404.tsx CHANGED
@@ -1,4 +1,3 @@
1
- import type { Locator } from '@vtex/client-cms'
2
1
  import type { GetStaticProps } from 'next'
3
2
  import { NextSeo } from 'next-seo'
4
3
  import type { ComponentType } from 'react'
@@ -12,8 +11,10 @@ import RenderSections from 'src/components/cms/RenderSections'
12
11
  import { OverriddenDefaultEmptyState as EmptyState } from 'src/components/sections/EmptyState/OverriddenDefaultEmptyState'
13
12
  import CUSTOM_COMPONENTS from 'src/customizations/src/components'
14
13
  import PLUGINS_COMPONENTS from 'src/plugins'
15
- import { type PageContentType, getPage } from 'src/server/cms'
14
+ import type { PageContentType } from 'src/server/cms'
16
15
  import { injectGlobalSections } from 'src/server/cms/global'
16
+ import { contentService } from 'src/server/content/service'
17
+ import type { PreviewData } from 'src/server/content/types'
17
18
 
18
19
  /* A list of components that can be used in the CMS. */
19
20
  const COMPONENTS: Record<string, ComponentType<any>> = {
@@ -55,7 +56,7 @@ function Page({ page: { sections }, globalSections }: Props) {
55
56
  export const getStaticProps: GetStaticProps<
56
57
  Props,
57
58
  Record<string, string>,
58
- Locator
59
+ PreviewData
59
60
  > = async ({ previewData }) => {
60
61
  const [
61
62
  globalSectionsPromise,
@@ -65,9 +66,9 @@ export const getStaticProps: GetStaticProps<
65
66
 
66
67
  const [page, globalSections, globalSectionsHeader, globalSectionsFooter] =
67
68
  await Promise.all([
68
- getPage<PageContentType>({
69
- ...(previewData?.contentType === '404' && previewData),
69
+ contentService.getSingleContent<PageContentType>({
70
70
  contentType: '404',
71
+ previewData,
71
72
  }),
72
73
  globalSectionsPromise,
73
74
  globalSectionsHeaderPromise,
package/src/pages/500.tsx CHANGED
@@ -1,4 +1,3 @@
1
- import type { Locator } from '@vtex/client-cms'
2
1
  import type { GetStaticProps } from 'next'
3
2
  import { NextSeo } from 'next-seo'
4
3
  import type { ComponentType } from 'react'
@@ -12,8 +11,10 @@ import RenderSections from 'src/components/cms/RenderSections'
12
11
  import { OverriddenDefaultEmptyState as EmptyState } from 'src/components/sections/EmptyState/OverriddenDefaultEmptyState'
13
12
  import CUSTOM_COMPONENTS from 'src/customizations/src/components'
14
13
  import PLUGINS_COMPONENTS from 'src/plugins'
15
- import { type PageContentType, getPage } from 'src/server/cms'
14
+ import type { PageContentType } from 'src/server/cms'
16
15
  import { injectGlobalSections } from 'src/server/cms/global'
16
+ import { contentService } from 'src/server/content/service'
17
+ import type { PreviewData } from 'src/server/content/types'
17
18
 
18
19
  /* A list of components that can be used in the CMS. */
19
20
  const COMPONENTS: Record<string, ComponentType<any>> = {
@@ -56,7 +57,7 @@ function Page({ page: { sections }, globalSections }: Props) {
56
57
  export const getStaticProps: GetStaticProps<
57
58
  Props,
58
59
  Record<string, string>,
59
- Locator
60
+ PreviewData
60
61
  > = async ({ previewData }) => {
61
62
  const [
62
63
  globalSectionsPromise,
@@ -66,9 +67,9 @@ export const getStaticProps: GetStaticProps<
66
67
 
67
68
  const [page, globalSections, globalSectionsHeader, globalSectionsFooter] =
68
69
  await Promise.all([
69
- getPage<PageContentType>({
70
- ...(previewData?.contentType === '500' && previewData),
70
+ contentService.getSingleContent<PageContentType>({
71
71
  contentType: '500',
72
+ previewData,
72
73
  }),
73
74
  globalSectionsPromise,
74
75
  globalSectionsHeaderPromise,
@@ -12,7 +12,6 @@ import type {
12
12
  import { execute } from 'src/server'
13
13
 
14
14
  import type { SearchState } from '@faststore/sdk'
15
- import type { Locator } from '@vtex/client-cms'
16
15
  import dynamic from 'next/dynamic'
17
16
  import {
18
17
  getGlobalSectionsData,
@@ -28,9 +27,11 @@ import ProductListingPage, {
28
27
  import { getRedirect } from 'src/sdk/redirects'
29
28
  import type { PageContentType } from 'src/server/cms'
30
29
  import { injectGlobalSections } from 'src/server/cms/global'
31
- import { getPLP, type PLPContentType } from 'src/server/cms/plp'
30
+ import type { PLPContentType } from 'src/server/cms/plp'
32
31
  import { getDynamicContent } from 'src/utils/dynamicContent'
33
32
  import { fetchServerManyProducts } from 'src/utils/fetchProductGallerySSR'
33
+ import { contentService } from 'src/server/content/service'
34
+ import type { PreviewData } from 'src/server/content/types'
34
35
 
35
36
  const LandingPage = dynamic(
36
37
  () => import('src/components/templates/LandingPage')
@@ -103,7 +104,7 @@ const query = gql(`
103
104
  export const getStaticProps: GetStaticProps<
104
105
  Props,
105
106
  { slug: string[] },
106
- Locator
107
+ PreviewData
107
108
  > = async ({ params, previewData }) => {
108
109
  const slug = params?.slug.join('/') ?? ''
109
110
  const rewrites = (await storeConfig.rewrites?.()) ?? []
@@ -162,7 +163,13 @@ export const getStaticProps: GetStaticProps<
162
163
  variables: { slug },
163
164
  operation: query,
164
165
  }),
165
- getPLP(slug, previewData, rewrites),
166
+ contentService.getPlpContent(
167
+ {
168
+ previewData,
169
+ slug,
170
+ },
171
+ rewrites
172
+ ),
166
173
  globalSectionsPromise,
167
174
  globalSectionsHeaderPromise,
168
175
  globalSectionsFooterPromise,
@@ -1,5 +1,4 @@
1
1
  import { isNotFoundError } from '@faststore/api'
2
- import type { Locator } from '@vtex/client-cms'
3
2
  import deepmerge from 'deepmerge'
4
3
  import type { GetStaticPaths, GetStaticProps } from 'next'
5
4
  import { BreadcrumbJsonLd, NextSeo, ProductJsonLd } from 'next-seo'
@@ -37,7 +36,9 @@ import { getOfferUrl, useOffer } from 'src/sdk/offer'
37
36
  import PageProvider, { type PDPContext } from 'src/sdk/overrides/PageProvider'
38
37
  import { useProductQuery } from 'src/sdk/product/useProductQuery'
39
38
  import { injectGlobalSections } from 'src/server/cms/global'
40
- import { getPDP, type PDPContentType } from 'src/server/cms/pdp'
39
+ import type { PDPContentType } from 'src/server/cms/pdp'
40
+ import { contentService } from 'src/server/content/service'
41
+ import type { PreviewData } from 'src/server/content/types'
41
42
 
42
43
  type StoreConfig = typeof storeConfig & {
43
44
  experimental: {
@@ -183,7 +184,9 @@ function Page({
183
184
  <BreadcrumbJsonLd itemListElements={itemListElements} />
184
185
  <ProductJsonLd
185
186
  id={`${meta.canonical}${settings?.seo?.id ?? ''}`}
186
- mainEntityOfPage={`${meta.canonical}${settings?.seo?.mainEntityOfPage ?? ''}`}
187
+ mainEntityOfPage={`${meta.canonical}${
188
+ settings?.seo?.mainEntityOfPage ?? ''
189
+ }`}
187
190
  productName={product.name}
188
191
  description={product.description}
189
192
  brand={product.brand.name}
@@ -283,7 +286,7 @@ const query = gql(`
283
286
  export const getStaticProps: GetStaticProps<
284
287
  Props,
285
288
  { slug: string },
286
- Locator
289
+ PreviewData
287
290
  > = async ({ params, previewData }) => {
288
291
  const slug = params?.slug ?? ''
289
292
 
@@ -333,7 +336,13 @@ export const getStaticProps: GetStaticProps<
333
336
  throw errors[0]
334
337
  }
335
338
 
336
- const cmsPage: PDPContentType = await getPDP(data.product, previewData)
339
+ const cmsPage: PDPContentType = await contentService.getPdpContent(
340
+ data.product,
341
+ {
342
+ previewData,
343
+ slug,
344
+ }
345
+ )
337
346
 
338
347
  const { seo } = data.product
339
348
  const title = seo.title