@faststore/core 2.1.84 → 2.2.0-alpha.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 (211) hide show
  1. package/.turbo/turbo-build.log +9 -7
  2. package/.turbo/turbo-test.log +25 -0
  3. package/@generated/graphql/index.ts +183 -79
  4. package/@generated/graphql/persisted.json +5 -5
  5. package/@generated/graphql/schema.graphql +1053 -0
  6. package/api/index.ts +15 -0
  7. package/cms/faststore/sections.json +2 -32
  8. package/codegen.yml +2 -1
  9. package/generate.sh +71 -0
  10. package/index.ts +15 -0
  11. package/jest.config.js +6 -0
  12. package/package.json +33 -18
  13. package/src/components/ThirdPartyScripts/ThirdPartyScripts.tsx +1 -2
  14. package/src/components/cms/RenderSections.tsx +4 -5
  15. package/src/components/navigation/Navbar/Navbar.tsx +4 -3
  16. package/src/components/navigation/NavbarSlider/NavbarSlider.tsx +5 -4
  17. package/src/components/product/ProductGrid/ProductGrid.tsx +4 -3
  18. package/src/components/sections/Breadcrumb/Breadcrumb.tsx +17 -22
  19. package/src/components/sections/CrossSellingShelf/CrossSellingShelf.tsx +8 -6
  20. package/src/components/sections/Footer/Footer.tsx +2 -14
  21. package/src/components/sections/Navbar/Navbar.tsx +0 -4
  22. package/src/components/sections/ProductDetails/ProductDetails.tsx +23 -33
  23. package/src/components/sections/ProductGallery/ProductGallery.tsx +15 -26
  24. package/src/components/sections/ProductShelf/ProductShelf.tsx +1 -1
  25. package/src/components/sections/ProductTiles/ProductTiles.tsx +4 -3
  26. package/src/components/templates/ProductListingPage/ProductListing.tsx +95 -0
  27. package/src/components/templates/ProductListingPage/ProductListingPage.tsx +34 -68
  28. package/src/components/templates/SearchPage/SearchPage.tsx +81 -0
  29. package/src/components/templates/SearchPage/index.ts +2 -0
  30. package/src/components/ui/ProductGallery/ProductGallery.tsx +24 -16
  31. package/src/components/ui/ProductGallery/ProductGalleryPage.tsx +8 -7
  32. package/src/components/ui/ProductGallery/useDelayedFacets.ts +3 -3
  33. package/src/components/ui/ProductShelf/ProductShelf.tsx +3 -2
  34. package/src/customizations/GlobalOverrides.tsx +0 -2
  35. package/src/customizations/fragments/ClientProduct.ts +9 -0
  36. package/src/customizations/fragments/ClientProductGallery.ts +19 -0
  37. package/src/customizations/fragments/ClientProducts.ts +19 -0
  38. package/src/customizations/fragments/ServerCollectionPage.ts +9 -0
  39. package/src/customizations/fragments/ServerProductPage.ts +9 -0
  40. package/src/customizations/graphql/thirdParty/resolvers/index.ts +3 -0
  41. package/src/customizations/graphql/vtex/resolvers/index.ts +3 -0
  42. package/src/pages/[...slug].tsx +5 -3
  43. package/src/pages/[slug]/p.tsx +38 -18
  44. package/src/pages/s.tsx +22 -34
  45. package/src/sdk/graphql/useQuery.ts +17 -13
  46. package/src/sdk/overrides/PageProvider.tsx +78 -0
  47. package/src/sdk/product/useLocalizedVariables.ts +33 -0
  48. package/src/sdk/product/usePageProductsQuery.ts +139 -0
  49. package/src/{components/sections/ProductGallery/useGalleryQuery.ts → sdk/product/useProductGalleryQuery.ts} +12 -13
  50. package/src/sdk/product/{useProduct.ts → useProductQuery.ts} +10 -7
  51. package/src/sdk/product/useProductsPrefetch.ts +72 -0
  52. package/src/sdk/product/useProductsQuery.ts +17 -63
  53. package/src/server/generator/generateGraphQLSchemaFile.ts +3 -0
  54. package/src/server/generator/schema.ts +82 -0
  55. package/src/server/index.ts +34 -21
  56. package/src/server/options.ts +16 -0
  57. package/test/server/index.test.ts +146 -0
  58. package/.next/BUILD_ID +0 -1
  59. package/.next/build-manifest.json +0 -129
  60. package/.next/cache/.tsbuildinfo +0 -1
  61. package/.next/cache/config.json +0 -7
  62. package/.next/cache/eslint/.cache_1gneedd +0 -1
  63. package/.next/cache/next-server.js.nft.json +0 -1
  64. package/.next/cache/webpack/client-production/0.pack +0 -0
  65. package/.next/cache/webpack/client-production/index.pack +0 -0
  66. package/.next/cache/webpack/server-production/0.pack +0 -0
  67. package/.next/cache/webpack/server-production/index.pack +0 -0
  68. package/.next/export-marker.json +0 -1
  69. package/.next/images-manifest.json +0 -1
  70. package/.next/next-server.js.nft.json +0 -1
  71. package/.next/package.json +0 -1
  72. package/.next/prerender-manifest.json +0 -1
  73. package/.next/react-loadable-manifest.json +0 -44
  74. package/.next/required-server-files.json +0 -1
  75. package/.next/routes-manifest.json +0 -1
  76. package/.next/server/chunks/143.js +0 -106
  77. package/.next/server/chunks/177.js +0 -120
  78. package/.next/server/chunks/183.js +0 -94
  79. package/.next/server/chunks/184.js +0 -61
  80. package/.next/server/chunks/186.js +0 -113
  81. package/.next/server/chunks/289.js +0 -239
  82. package/.next/server/chunks/312.js +0 -697
  83. package/.next/server/chunks/350.js +0 -143
  84. package/.next/server/chunks/483.js +0 -650
  85. package/.next/server/chunks/487.js +0 -9142
  86. package/.next/server/chunks/53.js +0 -61
  87. package/.next/server/chunks/530.js +0 -626
  88. package/.next/server/chunks/576.js +0 -94
  89. package/.next/server/chunks/650.js +0 -9142
  90. package/.next/server/chunks/676.js +0 -32
  91. package/.next/server/chunks/693.js +0 -58
  92. package/.next/server/chunks/71.js +0 -1254
  93. package/.next/server/chunks/74.js +0 -4065
  94. package/.next/server/chunks/753.js +0 -509
  95. package/.next/server/chunks/779.js +0 -58
  96. package/.next/server/chunks/825.js +0 -4039
  97. package/.next/server/chunks/854.js +0 -72
  98. package/.next/server/chunks/859.js +0 -959
  99. package/.next/server/chunks/907.js +0 -1911
  100. package/.next/server/chunks/933.js +0 -517
  101. package/.next/server/chunks/98.js +0 -124
  102. package/.next/server/chunks/988.js +0 -211
  103. package/.next/server/chunks/font-manifest.json +0 -1
  104. package/.next/server/font-manifest.json +0 -1
  105. package/.next/server/middleware-build-manifest.js +0 -1
  106. package/.next/server/middleware-manifest.json +0 -6
  107. package/.next/server/middleware-react-loadable-manifest.js +0 -1
  108. package/.next/server/pages/404.js +0 -386
  109. package/.next/server/pages/404.js.nft.json +0 -1
  110. package/.next/server/pages/500.js +0 -388
  111. package/.next/server/pages/500.js.nft.json +0 -1
  112. package/.next/server/pages/[...slug].js +0 -1005
  113. package/.next/server/pages/[...slug].js.nft.json +0 -1
  114. package/.next/server/pages/[slug]/p.js +0 -2269
  115. package/.next/server/pages/[slug]/p.js.nft.json +0 -1
  116. package/.next/server/pages/_app.js +0 -280
  117. package/.next/server/pages/_app.js.nft.json +0 -1
  118. package/.next/server/pages/_document.js +0 -374
  119. package/.next/server/pages/_document.js.nft.json +0 -1
  120. package/.next/server/pages/_error.js +0 -164
  121. package/.next/server/pages/_error.js.nft.json +0 -1
  122. package/.next/server/pages/account.js +0 -363
  123. package/.next/server/pages/account.js.nft.json +0 -1
  124. package/.next/server/pages/api/graphql.js +0 -365
  125. package/.next/server/pages/api/graphql.js.nft.json +0 -1
  126. package/.next/server/pages/api/health/live.js +0 -31
  127. package/.next/server/pages/api/health/live.js.nft.json +0 -1
  128. package/.next/server/pages/api/health/ready.js +0 -31
  129. package/.next/server/pages/api/health/ready.js.nft.json +0 -1
  130. package/.next/server/pages/api/preview.js +0 -148
  131. package/.next/server/pages/api/preview.js.nft.json +0 -1
  132. package/.next/server/pages/checkout.js +0 -363
  133. package/.next/server/pages/checkout.js.nft.json +0 -1
  134. package/.next/server/pages/en-US/404.html +0 -81
  135. package/.next/server/pages/en-US/404.json +0 -1
  136. package/.next/server/pages/en-US/500.html +0 -81
  137. package/.next/server/pages/en-US/500.json +0 -1
  138. package/.next/server/pages/en-US/account.html +0 -81
  139. package/.next/server/pages/en-US/account.json +0 -1
  140. package/.next/server/pages/en-US/checkout.html +0 -81
  141. package/.next/server/pages/en-US/checkout.json +0 -1
  142. package/.next/server/pages/en-US/login.html +0 -81
  143. package/.next/server/pages/en-US/login.json +0 -1
  144. package/.next/server/pages/en-US/s.html +0 -81
  145. package/.next/server/pages/en-US/s.json +0 -1
  146. package/.next/server/pages/en-US.html +0 -81
  147. package/.next/server/pages/en-US.json +0 -1
  148. package/.next/server/pages/index.js +0 -439
  149. package/.next/server/pages/index.js.nft.json +0 -1
  150. package/.next/server/pages/login.js +0 -368
  151. package/.next/server/pages/login.js.nft.json +0 -1
  152. package/.next/server/pages/s.js +0 -466
  153. package/.next/server/pages/s.js.nft.json +0 -1
  154. package/.next/server/pages-manifest.json +0 -18
  155. package/.next/server/webpack-api-runtime.js +0 -229
  156. package/.next/server/webpack-runtime.js +0 -229
  157. package/.next/static/UFCNzAvjHLcTNmP8sQK5l/_buildManifest.js +0 -1
  158. package/.next/static/UFCNzAvjHLcTNmP8sQK5l/_ssgManifest.js +0 -1
  159. package/.next/static/chunks/143.dd8a556e6957baa1.js +0 -1
  160. package/.next/static/chunks/148.582eaa81293ee470.js +0 -1
  161. package/.next/static/chunks/238-39630714f5d70169.js +0 -1
  162. package/.next/static/chunks/243-b4f8e506d156ee41.js +0 -1
  163. package/.next/static/chunks/530.ec68de379130c11e.js +0 -1
  164. package/.next/static/chunks/548-4ee971bf7bdb3e81.js +0 -1
  165. package/.next/static/chunks/603-072c8fb73ac35775.js +0 -1
  166. package/.next/static/chunks/651.7142f31ce1e052b3.js +0 -1
  167. package/.next/static/chunks/709.7bc5a25ce30abda6.js +0 -1
  168. package/.next/static/chunks/738-a5ff304828f20cbf.js +0 -1
  169. package/.next/static/chunks/741.52f7fb873418346f.js +0 -1
  170. package/.next/static/chunks/98.97381d2021f86cd9.js +0 -1
  171. package/.next/static/chunks/988.afda042dd9ba11d1.js +0 -1
  172. package/.next/static/chunks/framework-dfd14d7ce6600b03.js +0 -1
  173. package/.next/static/chunks/main-fd466221927468fd.js +0 -1
  174. package/.next/static/chunks/pages/404-af78f7cd1d3c1f60.js +0 -1
  175. package/.next/static/chunks/pages/500-f6346ca5f9dc4fef.js +0 -1
  176. package/.next/static/chunks/pages/[...slug]-3f4e5f74ff9436ec.js +0 -1
  177. package/.next/static/chunks/pages/[slug]/p-8e20c206fb84d184.js +0 -1
  178. package/.next/static/chunks/pages/_app-895781b1c7b5bf56.js +0 -1
  179. package/.next/static/chunks/pages/_error-a7a0c1d9bfbb4f38.js +0 -1
  180. package/.next/static/chunks/pages/account-05bd79fb78365e88.js +0 -1
  181. package/.next/static/chunks/pages/checkout-c973786e68f25a39.js +0 -1
  182. package/.next/static/chunks/pages/index-73110361a184aa10.js +0 -1
  183. package/.next/static/chunks/pages/login-8deb9243376b6aa1.js +0 -1
  184. package/.next/static/chunks/pages/s-94691e1fdc9521a4.js +0 -1
  185. package/.next/static/chunks/polyfills-c67a75d1b6f99dc8.js +0 -1
  186. package/.next/static/chunks/webpack-504557a0a7373460.js +0 -1
  187. package/.next/static/css/20e4a3a45cdd65f4.css +0 -1
  188. package/.next/static/css/4b7138899cd07c63.css +0 -1
  189. package/.next/static/css/527e334fa69cf40a.css +0 -1
  190. package/.next/static/css/6e1a7434f061d0ef.css +0 -1
  191. package/.next/static/css/9e76fef1c9ca89af.css +0 -1
  192. package/.next/static/css/a2eefb25a4608343.css +0 -1
  193. package/.next/static/css/cb7d1fcea42fab9c.css +0 -1
  194. package/.next/static/css/df588bb98c0b0ca6.css +0 -1
  195. package/.next/static/css/e3b039e8f5daf95f.css +0 -1
  196. package/.next/static/css/f0e2d1b8832e935d.css +0 -1
  197. package/.next/trace +0 -80
  198. package/public/~partytown/debug/partytown-atomics.js +0 -556
  199. package/public/~partytown/debug/partytown-media.js +0 -374
  200. package/public/~partytown/debug/partytown-sandbox-sw.js +0 -543
  201. package/public/~partytown/debug/partytown-sw.js +0 -59
  202. package/public/~partytown/debug/partytown-ww-atomics.js +0 -1789
  203. package/public/~partytown/debug/partytown-ww-sw.js +0 -1781
  204. package/public/~partytown/debug/partytown.js +0 -72
  205. package/public/~partytown/partytown-atomics.js +0 -2
  206. package/public/~partytown/partytown-media.js +0 -2
  207. package/public/~partytown/partytown-sw.js +0 -2
  208. package/public/~partytown/partytown.js +0 -2
  209. package/src/components/ui/ProductGallery/usePageProducts.ts +0 -48
  210. package/src/customizations/components/overrides/ThirdPartyScripts.tsx +0 -9
  211. package/src/customizations/scripts/ThirdPartyScripts.tsx +0 -8
package/api/index.ts ADDED
@@ -0,0 +1,15 @@
1
+ export { gql } from '@faststore/graphql-utils'
2
+ export type {
3
+ StoreAggregateOfferRoot,
4
+ StorePropertyValueRoot,
5
+ StoreCollectionRoot,
6
+ StoreFacetRoot,
7
+ StoreSearchResultRoot,
8
+ StoreSeoRoot,
9
+ StoreShippingSLARoot,
10
+ StoreOfferRoot,
11
+ StoreSkuVariationsRoot,
12
+ StoreProductGroupRoot,
13
+ StoreProductRoot,
14
+ StoreOrganizationRoot,
15
+ } from '@faststore/api'
@@ -166,21 +166,6 @@
166
166
  "alt": {
167
167
  "title": "Alternative Label",
168
168
  "type": "string"
169
- },
170
- "link": {
171
- "title": "Logo Link",
172
- "type": "object",
173
- "required": ["url", "title"],
174
- "properties": {
175
- "url": {
176
- "title": "Link URL",
177
- "type": "string"
178
- },
179
- "title": {
180
- "title": "Link Title",
181
- "type": "string"
182
- }
183
- }
184
169
  }
185
170
  }
186
171
  },
@@ -571,23 +556,8 @@
571
556
  }
572
557
  },
573
558
  "alt": {
574
- "title": "Alternative Label",
575
- "type": "string"
576
- },
577
- "link": {
578
- "title": "Logo Link",
579
- "type": "object",
580
- "required": ["url", "title"],
581
- "properties": {
582
- "url": {
583
- "title": "Link URL",
584
- "type": "string"
585
- },
586
- "title": {
587
- "title": "Link Title",
588
- "type": "string"
589
- }
590
- }
559
+ "type": "string",
560
+ "title": "Alternative Label"
591
561
  }
592
562
  }
593
563
  },
package/codegen.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  overwrite: true
2
- schema: http://localhost:3000/api/graphql
2
+ errorsOnly: true
3
+ schema: ./@generated/graphql/schema.graphql
3
4
  documents:
4
5
  - ./src/**/*.{ts,tsx}
5
6
  config:
package/generate.sh ADDED
@@ -0,0 +1,71 @@
1
+ #!/bin/sh
2
+
3
+ # ANSI color codes
4
+ RED='\033[0;31m'
5
+ YELLOW='\033[1;33m'
6
+ PURPLE='\033[0;35m'
7
+ GREEN='\033[0;32m'
8
+ NC='\033[0m' # No Color
9
+
10
+ # Initialize debug flag to false
11
+ DEBUG_FLAG=false
12
+
13
+ # Check for --debug flag
14
+ if [ "$1" = "--debug" ]; then
15
+ DEBUG_FLAG=true
16
+ fi
17
+
18
+ # Function to display errors with readable messages
19
+ show_error() {
20
+ local cmd="$3"
21
+
22
+ echo "${RED}error${NC} $1"
23
+ if [ "$DEBUG_FLAG" = "true" ]; then
24
+ echo "${PURPLE}DEBUG - \$ $cmd ${RED}error root ↓${NC}\n$2"
25
+ fi
26
+ exit 1
27
+ }
28
+
29
+ # Function to display warnings
30
+ show_warning() {
31
+ local cmd="$3"
32
+
33
+ echo "${YELLOW}warn${NC} $1"
34
+ if [ "$DEBUG_FLAG" = "true" ]; then
35
+ echo "${PURPLE}DEBUG - \$ $cmd ${YELLOW}warn root ↓${NC}\n$2"
36
+ fi
37
+ }
38
+
39
+ # Function to run a command and handle errors and warnings
40
+ run_command() {
41
+ local cmd="$1"
42
+ local error_message="$2"
43
+ local warn="$3"
44
+ local output
45
+
46
+ if [ "$DEBUG_FLAG" = "true" ]; then
47
+ output="$($cmd --debug --verbose 2>&1)"
48
+ else
49
+ output="$($cmd 2>&1)"
50
+ fi
51
+
52
+ local exit_code="$?"
53
+ if [ "$warn" = "true" ]; then
54
+ if [ "$exit_code" -ne 0 ]; then
55
+ show_warning "$error_message" "$output" "$cmd"
56
+ fi
57
+ elif [ "$exit_code" -ne 0 ]; then
58
+ show_error "$error_message" "$output" "$cmd"
59
+ fi
60
+ }
61
+
62
+ # Run "yarn generate:schema" without outputting logs and errors
63
+ run_command "yarn generate:schema" "Failed to run 'yarn generate:schema'. Please check your setup." "false"
64
+
65
+ # Run graphql-codegen and capture the output
66
+ run_command "graphql-codegen" "GraphQL was not optimized and TS files were not updated. Changes in the GraphQL layer did not take effect" "false"
67
+
68
+ # Run "yarn format:generated" and display a warning if it produces output
69
+ run_command "yarn format:generated" "Failed to format generated files. 'yarn format:generated' thrown errors" "true"
70
+
71
+ echo "${GREEN}GraphQL schema, types, and optimizations successfully generated 🎉${NC}"
package/index.ts ADDED
@@ -0,0 +1,15 @@
1
+ export {
2
+ usePage,
3
+ usePDP,
4
+ usePLP,
5
+ useSearchPage,
6
+ isPDP,
7
+ isPLP,
8
+ isSearchPage,
9
+ } from './src/sdk/overrides/PageProvider'
10
+
11
+ export type {
12
+ PDPContext,
13
+ PLPContext,
14
+ SearchPageContext,
15
+ } from './src/sdk/overrides/PageProvider'
package/jest.config.js ADDED
@@ -0,0 +1,6 @@
1
+ /** @type {import('ts-jest').JestConfigWithTsJest} */
2
+ module.exports = {
3
+ preset: 'ts-jest',
4
+ testPathIgnorePatterns: ['/node_modules/', 'cypress/'],
5
+ modulePaths: ['<rootDir>/test'],
6
+ }
package/package.json CHANGED
@@ -1,17 +1,23 @@
1
1
  {
2
2
  "name": "@faststore/core",
3
- "version": "2.1.84",
3
+ "version": "2.2.0-alpha.0",
4
4
  "license": "MIT",
5
5
  "browserslist": "supports es6-module and not dead",
6
+ "exports": {
7
+ ".": "./index.ts"
8
+ },
6
9
  "scripts": {
7
- "generate": "graphql-codegen",
8
- "build": "yarn partytown && next build",
9
- "dev": "yarn partytown && next dev",
10
+ "generate:schema": "tsx src/server/generator/generateGraphQLSchemaFile.ts",
11
+ "generate": "./generate.sh",
12
+ "build": "yarn partytown & yarn generate && next build",
13
+ "dev": "yarn partytown & yarn generate && next dev",
10
14
  "clean": "rm -r .next",
11
15
  "serve": "next start",
12
- "test": "cypress open",
16
+ "test:e2e": "cypress open",
17
+ "test": "tsdx test",
13
18
  "lhci": "lhci autorun",
14
19
  "format": "prettier --write \"**/*.{ts,js,tsx,jsx,json}\"",
20
+ "format:generated": "prettier --write \"@generated/**/*.{ts,js,tsx,jsx,json}\" --loglevel error",
15
21
  "lint": "next lint",
16
22
  "stylelint": "stylelint \"**/*.scss\"",
17
23
  "stylelint:fix": "stylelint \"**/*.scss\" --fix",
@@ -29,16 +35,24 @@
29
35
  "@envelop/graphql-jit": "^1.1.1",
30
36
  "@envelop/parser-cache": "^2.2.0",
31
37
  "@envelop/validation-cache": "^2.2.0",
32
- "@faststore/api": "^2.1.83",
33
- "@faststore/components": "^2.1.82",
34
- "@faststore/graphql-utils": "^2.1.82",
35
- "@faststore/sdk": "^2.1.82",
36
- "@faststore/ui": "^2.1.82",
38
+ "@faststore/api": "^2.2.0-alpha.0",
39
+ "@faststore/components": "^2.2.0-alpha.0",
40
+ "@faststore/graphql-utils": "^2.2.0-alpha.0",
41
+ "@faststore/sdk": "^2.2.0-alpha.0",
42
+ "@faststore/ui": "^2.2.0-alpha.0",
43
+ "@graphql-codegen/cli": "^3.3.1",
44
+ "@graphql-codegen/typescript": "^3.0.4",
45
+ "@graphql-codegen/typescript-operations": "^3.0.4",
46
+ "@graphql-tools/load-files": "^7.0.0",
47
+ "@graphql-tools/merge": "^9.0.0",
48
+ "@graphql-tools/utils": "^9.2.1",
37
49
  "@types/react": "^18.0.14",
38
50
  "@vtex/client-cms": "^0.2.12",
51
+ "@vtex/prettier-config": "1.0.0",
39
52
  "autoprefixer": "^10.4.0",
40
53
  "chalk": "^5.2.0",
41
54
  "css-loader": "^6.7.1",
55
+ "deepmerge": "^4.3.1",
42
56
  "draft-js": "^0.11.7",
43
57
  "draft-js-export-html": "^1.4.1",
44
58
  "graphql": "^15.0.0",
@@ -48,6 +62,7 @@
48
62
  "next-seo": "^5.4.0",
49
63
  "nextjs-progressbar": "^0.0.14",
50
64
  "postcss": "^8.4.4",
65
+ "prettier": "^2.2.0",
51
66
  "react": "^18.2.0",
52
67
  "react-dom": "^18.2.0",
53
68
  "react-intersection-observer": "^8.32.5",
@@ -57,15 +72,14 @@
57
72
  "style-loader": "^3.3.1",
58
73
  "swr": "^1.3.0",
59
74
  "tsconfig-paths-webpack-plugin": "^3.5.2",
75
+ "tsx": "^3.12.7",
60
76
  "typescript": "4.7.3"
61
77
  },
62
78
  "devDependencies": {
63
79
  "@cypress/code-coverage": "^3.9.10",
64
- "@faststore/eslint-config": "^2.1.82",
80
+ "@envelop/testing": "^6.0.0",
81
+ "@faststore/eslint-config": "^2.2.0-alpha.0",
65
82
  "@faststore/lighthouse": "^1.12.32",
66
- "@graphql-codegen/cli": "^2.6.2",
67
- "@graphql-codegen/typescript": "^2.5.1",
68
- "@graphql-codegen/typescript-operations": "^2.4.2",
69
83
  "@lhci/cli": "^0.9.0",
70
84
  "@storybook/addon-a11y": "^6.5.9",
71
85
  "@storybook/addon-actions": "^6.5.9",
@@ -76,7 +90,7 @@
76
90
  "@storybook/react": "^6.5.9",
77
91
  "@testing-library/cypress": "^8.0.0",
78
92
  "@types/cypress": "^1.1.3",
79
- "@vtex/prettier-config": "1.0.0",
93
+ "@types/jest": "29.1.0",
80
94
  "axe-core": "^4.3.3",
81
95
  "cypress": "9.6.0",
82
96
  "cypress-axe": "^0.13.0",
@@ -85,15 +99,16 @@
85
99
  "eslint": "^7.32.0",
86
100
  "husky": "^5.2.0",
87
101
  "is-ci": "^3.0.0",
102
+ "jest": "29.1.0",
88
103
  "lint-staged": "^10.5.4",
89
104
  "msw-storybook-addon": "^1.6.3",
90
- "prettier": "^2.2.0",
91
105
  "stylelint": "^14.6.0",
92
106
  "stylelint-config-recess-order": "^3.0.0",
93
107
  "stylelint-config-standard": "^24.0.0",
94
108
  "stylelint-config-standard-scss": "^3.0.0",
95
109
  "stylelint-order": "^5.0.0",
96
- "stylelint-scss": "^4.0.1"
110
+ "stylelint-scss": "^4.0.1",
111
+ "ts-jest": "29.1.0"
97
112
  },
98
113
  "lint-staged": {
99
114
  "*.{ts,js,tsx,jsx}": [
@@ -110,5 +125,5 @@
110
125
  "msw": {
111
126
  "workerDirectory": "public"
112
127
  },
113
- "gitHead": "bcb306faa77c468a32e69677b657aaa80b18058d"
128
+ "gitHead": "356e52b6eae13cc4000c6915985009d45e7ae0c6"
114
129
  }
@@ -1,5 +1,5 @@
1
1
  import { Partytown } from '@builder.io/partytown/react'
2
- import OverrideComponents from 'src/customizations/GlobalOverrides'
2
+
3
3
  import storeConfig from '../../../faststore.config'
4
4
  import GoogleTagManager from './GoogleTagManager'
5
5
  import VTEX from './vtex'
@@ -26,7 +26,6 @@ function ThirdPartyScripts() {
26
26
  <>
27
27
  {includeGTM && <GoogleTagManager containerId={gtmContainerId} />}
28
28
  {includeVTEX && <VTEX />}
29
- <OverrideComponents.ThirdPartyScripts />
30
29
  <Partytown
31
30
  key="partytown"
32
31
  // Variables to forward to from main to worker
@@ -1,5 +1,5 @@
1
1
  import chalk from 'chalk'
2
- import { ComponentType, PropsWithChildren, useMemo } from 'react'
2
+ import { ComponentType, PropsWithChildren, memo, useMemo } from 'react'
3
3
 
4
4
  import SectionBoundary from './SectionBoundary'
5
5
  import { Section } from '@vtex/client-cms'
@@ -7,7 +7,6 @@ import { Section } from '@vtex/client-cms'
7
7
  interface Props {
8
8
  components: Record<string, ComponentType<any>>
9
9
  sections: Array<{ name: string; data: any }>
10
- context?: unknown
11
10
  }
12
11
 
13
12
  const useDividedSections = (sections: Section[]) => {
@@ -23,7 +22,7 @@ const useDividedSections = (sections: Section[]) => {
23
22
  }, [sections])
24
23
  }
25
24
 
26
- const RenderSectionsBase = ({ sections = [], context, components }: Props) => {
25
+ const RenderSectionsBase = ({ sections = [], components }: Props) => {
27
26
  return (
28
27
  <>
29
28
  {sections.map(({ name, data }, index) => {
@@ -42,7 +41,7 @@ const RenderSectionsBase = ({ sections = [], context, components }: Props) => {
42
41
 
43
42
  return (
44
43
  <SectionBoundary key={`cms-section-${index}`} name={name}>
45
- <Component {...data} context={context} />
44
+ <Component {...data} />
46
45
  </SectionBoundary>
47
46
  )
48
47
  })}
@@ -71,4 +70,4 @@ function RenderSections({
71
70
  )
72
71
  }
73
72
 
74
- export default RenderSections
73
+ export default memo(RenderSections)
@@ -110,12 +110,13 @@ function Navbar({
110
110
  aria-label={menuIconAlt}
111
111
  />
112
112
  <Link
113
+ href="/"
113
114
  data-fs-navbar-logo
114
- href={logo.link ? logo.link.url : '/'}
115
- title={logo.link ? logo.link.title : homeLabel}
116
115
  prefetch={false}
116
+ title={homeLabel}
117
+ aria-label={homeLabel}
117
118
  >
118
- <Logo src={logo.src} alt={logo.alt} />
119
+ <Logo {...logo} />
119
120
  </Link>
120
121
  </>
121
122
  )}
@@ -51,12 +51,13 @@ function NavbarSlider({
51
51
  {...NavbarSliderWrapper.props}
52
52
  >
53
53
  <Link
54
- data-fs-navbar-slider-logo
55
- href={logo.link ? logo.link.url : '/'}
56
- title={logo.link ? logo.link.title : homeLabel}
54
+ href="/"
57
55
  onClick={fadeOut}
56
+ title={homeLabel}
57
+ aria-label={homeLabel}
58
+ data-fs-navbar-slider-logo
58
59
  >
59
- <Logo alt={logo.alt} src={logo.src} />
60
+ <Logo {...logo} />
60
61
  </Link>
61
62
  </NavbarSliderHeader.Component>
62
63
  <NavbarSliderContent.Component {...NavbarSliderContent.props}>
@@ -2,18 +2,19 @@ import {
2
2
  ProductGrid as UIProductGrid,
3
3
  ProductGridItem as UIProductGridItem,
4
4
  } from '@faststore/ui'
5
- import type { ProductSummary_ProductFragment } from '@generated/graphql'
5
+ import type { ClientProductsQueryQuery } from '@generated/graphql'
6
6
  import ProductGridSkeleton from 'src/components/skeletons/ProductGridSkeleton'
7
7
 
8
8
  import { ProductCardProps } from '../ProductCard'
9
9
 
10
10
  import { __experimentalProductCard as ProductCard } from 'src/components/sections/ProductGallery/Overrides'
11
+ import { memo } from 'react'
11
12
 
12
13
  interface Props {
13
14
  /**
14
15
  * Products listed on the grid.
15
16
  */
16
- products: Array<{ node: ProductSummary_ProductFragment }>
17
+ products: ClientProductsQueryQuery['search']['products']['edges']
17
18
  page: number
18
19
  /**
19
20
  * Quantity of products listed.
@@ -64,4 +65,4 @@ function ProductGrid({
64
65
  )
65
66
  }
66
67
 
67
- export default ProductGrid
68
+ export default memo(ProductGrid)
@@ -4,36 +4,31 @@ import Breadcrumb from 'src/components/ui/Breadcrumb'
4
4
 
5
5
  import Section from '../Section'
6
6
 
7
- import {
8
- ServerCollectionPageQueryQuery,
9
- ServerProductPageQueryQuery,
10
- } from '@generated/graphql'
11
7
  import styles from './section.module.scss'
12
-
13
- type BreadcrumbContext =
14
- | ServerProductPageQueryQuery['product']
15
- | ServerCollectionPageQueryQuery['collection']
8
+ import {
9
+ PDPContext,
10
+ PLPContext,
11
+ isPDP,
12
+ isPLP,
13
+ usePage,
14
+ } from 'src/sdk/overrides/PageProvider'
16
15
 
17
16
  interface BreadcrumbSectionProps {
18
- context?: BreadcrumbContext
19
17
  icon: string
20
18
  alt: string
21
19
  }
22
20
 
23
- const isProduct = (x: any): x is ServerProductPageQueryQuery['product'] =>
24
- x?.sku != undefined && x?.sku != null
25
- const isCollection = (
26
- x: any
27
- ): x is ServerCollectionPageQueryQuery['collection'] =>
28
- x?.seo != undefined && x?.seo != null && x?.sku == undefined
29
-
30
- function BreadcrumbSection({ context, ...otherProps }: BreadcrumbSectionProps) {
31
- const title = isCollection(context) ? context?.seo?.title : 'All Products'
21
+ function BreadcrumbSection({ ...otherProps }: BreadcrumbSectionProps) {
22
+ const context = usePage<PDPContext | PLPContext>()
23
+ const title = isPLP(context)
24
+ ? context?.data?.collection?.seo?.title
25
+ : 'All Products'
32
26
  const fallback = [{ item: '/', name: title, position: 1 }]
33
- const breadcrumbList = isProduct(context)
34
- ? context?.breadcrumbList?.itemListElement
35
- : isCollection(context)
36
- ? context?.breadcrumbList?.itemListElement
27
+
28
+ const breadcrumbList = isPDP(context)
29
+ ? context?.data?.product?.breadcrumbList?.itemListElement
30
+ : isPLP(context)
31
+ ? context?.data?.collection?.breadcrumbList?.itemListElement
37
32
  : fallback
38
33
 
39
34
  return (
@@ -1,24 +1,26 @@
1
1
  import { useMemo } from 'react'
2
2
 
3
- import type { ProductDetailsFragment_ProductFragment } from '@generated/graphql'
4
3
  import UIProductShelf from 'src/components/ui/ProductShelf'
5
4
  import { useInView } from 'react-intersection-observer'
5
+ import { useProductsQuery } from 'src/sdk/product/useProductsQuery'
6
+ import { usePDP } from 'src/sdk/overrides/PageProvider'
6
7
  import styles from '../ProductShelf/section.module.scss'
7
8
  import Section from '../Section'
8
9
 
9
10
  interface Props {
10
11
  items: number
11
12
  title: string
12
- context: ProductDetailsFragment_ProductFragment
13
13
  kind: 'buy' | 'view'
14
14
  }
15
15
 
16
- const CrossSellingShelf = ({ items, title, context, kind }: Props) => {
16
+ const CrossSellingShelf = ({ items: first, title, kind }: Props) => {
17
17
  const { ref, inView } = useInView()
18
+ const context = usePDP()
19
+ const productGroupID = context?.data?.product?.isVariantOf?.productGroupID
18
20
 
19
21
  const selectedFacets = useMemo(
20
- () => [{ key: kind, value: context.isVariantOf.productGroupID }],
21
- [kind, context.isVariantOf.productGroupID]
22
+ () => [{ key: kind, value: productGroupID }],
23
+ [kind, productGroupID]
22
24
  )
23
25
 
24
26
  return (
@@ -28,7 +30,7 @@ const CrossSellingShelf = ({ items, title, context, kind }: Props) => {
28
30
  >
29
31
  <UIProductShelf
30
32
  inView={inView}
31
- first={items}
33
+ first={first}
32
34
  title={title}
33
35
  selectedFacets={selectedFacets}
34
36
  />
@@ -11,7 +11,6 @@ import UIFooter, {
11
11
  import type { FooterLinksProps, FooterSocialProps } from '../../common/Footer'
12
12
 
13
13
  import Logo from 'src/components/ui/Logo'
14
- import Link from 'src/components/ui/Link'
15
14
  import UIIncentives from '../../ui/Incentives'
16
15
  import type { Incentive } from '../../ui/Incentives'
17
16
 
@@ -27,10 +26,6 @@ export type FooterProps = {
27
26
  logo: {
28
27
  src: string
29
28
  alt: string
30
- link: {
31
- url: string
32
- title: string
33
- }
34
29
  }
35
30
  copyrightInfo: string
36
31
  acceptedPaymentMethods: {
@@ -45,7 +40,7 @@ const Footer = ({
45
40
  footerLinks,
46
41
  footerSocial,
47
42
  footerSocial: { title: footerSocialTitle },
48
- logo: { src: logoSrc, alt: logoAlt, link: logoLink },
43
+ logo: { src: logoSrc, alt: logoAlt },
49
44
  copyrightInfo,
50
45
  acceptedPaymentMethods: {
51
46
  showPaymentMethods,
@@ -53,7 +48,6 @@ const Footer = ({
53
48
  paymentMethods,
54
49
  },
55
50
  }: FooterProps) => {
56
- const homeLabel = 'Go to Home'
57
51
  return (
58
52
  <Section className={`section ${styles.section} section-footer`}>
59
53
  <UIFooter>
@@ -66,13 +60,7 @@ const Footer = ({
66
60
  />
67
61
  </UIFooterNavigation>
68
62
  <UIFooterInfo>
69
- <Link
70
- href={logoLink ? logoLink.url : '/'}
71
- title={logoLink ? logoLink.title : homeLabel}
72
- >
73
- <Logo alt={logoAlt} src={logoSrc} />
74
- </Link>
75
-
63
+ <Logo alt={logoAlt} src={logoSrc} />
76
64
  {showPaymentMethods && (
77
65
  <UIPaymentMethods
78
66
  flagList={paymentMethods}
@@ -13,10 +13,6 @@ export interface NavbarProps {
13
13
  logo: {
14
14
  alt: string
15
15
  src: string
16
- link: {
17
- url: string
18
- title: string
19
- }
20
16
  }
21
17
  searchInput: {
22
18
  sort: string
@@ -1,14 +1,12 @@
1
1
  import { useEffect, useState } from 'react'
2
2
 
3
3
  import { gql } from '@faststore/graphql-utils'
4
- import { sendAnalyticsEvent } from '@faststore/sdk'
5
4
  import type { CurrencyCode, ViewItemEvent } from '@faststore/sdk'
6
- import type { ProductDetailsFragment_ProductFragment } from '@generated/graphql'
5
+ import { sendAnalyticsEvent } from '@faststore/sdk'
7
6
 
8
- import { useSession } from 'src/sdk/session'
9
- import { useProduct } from 'src/sdk/product/useProduct'
10
- import { useFormattedPrice } from 'src/sdk/product/useFormattedPrice'
11
7
  import type { AnalyticsItem } from 'src/sdk/analytics/types'
8
+ import { useFormattedPrice } from 'src/sdk/product/useFormattedPrice'
9
+ import { useSession } from 'src/sdk/session'
12
10
 
13
11
  import Section from '../Section'
14
12
  import ProductDescription from 'src/components/ui/ProductDescription'
@@ -17,15 +15,13 @@ import { ProductDetailsSettings } from 'src/components/ui/ProductDetails'
17
15
  import styles from './section.module.scss'
18
16
 
19
17
  import {
20
- ProductTitle,
21
18
  DiscountBadge,
19
+ ProductTitle,
22
20
  __experimentalImageGallery as ImageGallery,
23
21
  __experimentalShippingSimulation as ShippingSimulation,
24
22
  } from 'src/components/sections/ProductDetails/Overrides'
25
23
 
26
- interface ProductDetailsContextProps {
27
- context: ProductDetailsFragment_ProductFragment
28
- }
24
+ import { usePDP } from 'src/sdk/overrides/PageProvider'
29
25
 
30
26
  export interface ProductDetailsProps {
31
27
  productTitle: {
@@ -59,7 +55,6 @@ export interface ProductDetailsProps {
59
55
  }
60
56
 
61
57
  function ProductDetails({
62
- context: staleProduct,
63
58
  productTitle: {
64
59
  refNumber: showRefNumber,
65
60
  discountBadge: {
@@ -87,36 +82,31 @@ function ProductDetails({
87
82
  initiallyExpanded: productDescriptionInitiallyExpanded,
88
83
  displayDescription: shouldDisplayProductDescription,
89
84
  },
90
- }: ProductDetailsProps & ProductDetailsContextProps) {
85
+ }: ProductDetailsProps) {
91
86
  const { currency } = useSession()
92
87
  const [quantity, setQuantity] = useState(1)
88
+ const context = usePDP()
89
+ const { product, isValidating } = context?.data
93
90
 
94
- // Stale while revalidate the product for fetching the new price etc
95
- const { data, isValidating } = useProduct(staleProduct.id, {
96
- product: staleProduct,
97
- })
98
-
99
- if (!data) {
91
+ if (!product) {
100
92
  throw new Error('NotFound')
101
93
  }
102
94
 
103
95
  const {
104
- product: {
105
- id,
106
- sku,
107
- gtin,
108
- name: variantName,
109
- brand,
110
- isVariantOf,
111
- description,
112
- isVariantOf: { name, productGroupID: productId },
113
- image: productImages,
114
- offers: {
115
- offers: [{ availability, price, listPrice, seller }],
116
- lowPrice,
117
- },
96
+ id,
97
+ sku,
98
+ gtin,
99
+ name: variantName,
100
+ brand,
101
+ isVariantOf,
102
+ description,
103
+ isVariantOf: { name, productGroupID: productId },
104
+ image: productImages,
105
+ offers: {
106
+ offers: [{ availability, price, listPrice, seller }],
107
+ lowPrice,
118
108
  },
119
- } = data
109
+ } = product
120
110
 
121
111
  useEffect(() => {
122
112
  sendAnalyticsEvent<ViewItemEvent<AnalyticsItem>>({
@@ -191,7 +181,7 @@ function ProductDetails({
191
181
  >
192
182
  {!outOfStock ? (
193
183
  <ProductDetailsSettings
194
- product={data.product}
184
+ product={product}
195
185
  isValidating={isValidating}
196
186
  buyButtonTitle={buyButtonTitle}
197
187
  quantity={quantity}