@faststore/core 3.0.91 → 3.0.94

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 (57) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +13 -13
  3. package/.next/cache/.tsbuildinfo +1 -1
  4. package/.next/cache/config.json +3 -3
  5. package/.next/cache/eslint/.cache_1gneedd +1 -1
  6. package/.next/cache/webpack/client-production/0.pack +0 -0
  7. package/.next/cache/webpack/client-production/index.pack +0 -0
  8. package/.next/cache/webpack/server-production/0.pack +0 -0
  9. package/.next/cache/webpack/server-production/index.pack +0 -0
  10. package/.next/next-minimal-server.js.nft.json +1 -1
  11. package/.next/next-server.js.nft.json +1 -1
  12. package/.next/prerender-manifest.js +1 -1
  13. package/.next/prerender-manifest.json +1 -1
  14. package/.next/react-loadable-manifest.json +1 -1
  15. package/.next/routes-manifest.json +1 -1
  16. package/.next/server/middleware-build-manifest.js +1 -1
  17. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  18. package/.next/server/pages/en-US/404.html +2 -2
  19. package/.next/server/pages/en-US/404.json +1 -1
  20. package/.next/server/pages/en-US/500.html +2 -2
  21. package/.next/server/pages/en-US/500.json +1 -1
  22. package/.next/server/pages/en-US/account.html +2 -2
  23. package/.next/server/pages/en-US/account.json +1 -1
  24. package/.next/server/pages/en-US/checkout.html +2 -2
  25. package/.next/server/pages/en-US/checkout.json +1 -1
  26. package/.next/server/pages/en-US/login.html +2 -2
  27. package/.next/server/pages/en-US/login.json +1 -1
  28. package/.next/server/pages/en-US/s.html +2 -2
  29. package/.next/server/pages/en-US/s.json +1 -1
  30. package/.next/server/pages/en-US.html +2 -2
  31. package/.next/server/pages/en-US.json +1 -1
  32. package/.next/static/chunks/{65.da22595d53beae76.js → 65.78da4e775f896fbd.js} +1 -1
  33. package/.next/static/chunks/{webpack-63df43b7e99450a0.js → webpack-91a2417668848fcd.js} +1 -1
  34. package/.next/trace +95 -95
  35. package/.turbo/turbo-build.log +2 -2
  36. package/.turbo/turbo-test.log +4 -4
  37. package/package.json +8 -8
  38. package/src/components/cms/SectionBoundary.tsx +16 -3
  39. package/src/components/common/Footer/Footer.tsx +8 -3
  40. package/src/components/search/SearchDropdown/SearchDropdown.tsx +8 -3
  41. package/src/components/search/SearchInput/SearchInput.tsx +2 -1
  42. package/src/components/search/Sort/Sort.tsx +9 -4
  43. package/src/components/templates/LandingPage/LandingPage.tsx +1 -1
  44. package/src/components/templates/ProductListingPage/ProductListing.tsx +1 -1
  45. package/src/components/ui/Image/loader.ts +6 -1
  46. package/src/components/ui/ImageGallery/ImageGallery.tsx +7 -1
  47. package/src/components/ui/Newsletter/NewsletterAddendum.tsx +2 -0
  48. package/src/customizations/src/dynamicContent/index.ts +1 -1
  49. package/src/pages/[slug]/p.tsx +1 -1
  50. package/src/sdk/analytics/index.tsx +1 -1
  51. package/src/sdk/error/ErrorBoundary/ErrorBoundary.tsx +14 -2
  52. package/src/sdk/overrides/overrides.ts +37 -27
  53. package/src/sdk/product/useProductGalleryQuery.ts +9 -1
  54. package/test/utils/multipleTemplates.test.ts +1 -1
  55. package/tsconfig.json +3 -2
  56. /package/.next/static/{611u5v6WsM_jVmU27RR3i → Yr9s02jekj4n4_pjuAZIX}/_buildManifest.js +0 -0
  57. /package/.next/static/{611u5v6WsM_jVmU27RR3i → Yr9s02jekj4n4_pjuAZIX}/_ssgManifest.js +0 -0
@@ -46,8 +46,8 @@ Browserslist: caniuse-lite is outdated. Please run:
46
46
  Collecting page data ...
47
47
  Generating static pages (0/7) ...
48
48
 
49
49
  Generating static pages (1/7)
50
-
51
50
  Generating static pages (3/7)
52
51
  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.
52
+
53
53
  Generating static pages (3/7)
54
54
 
55
55
  Generating static pages (5/7)
56
56
 
57
57
  ✓ Generating static pages (7/7)
58
58
  Finalizing page optimization ...
@@ -75,7 +75,7 @@ Route (pages) Size First Load JS
75
75
  ├ chunks/framework-8e279965036b6169.js 45.4 kB
76
76
  ├ chunks/main-6f63f6746cc029db.js 33.1 kB
77
77
  ├ chunks/pages/_app-c25fabc2435c8961.js 12.6 kB
78
- ├ chunks/webpack-63df43b7e99450a0.js 2.45 kB
78
+ ├ chunks/webpack-91a2417668848fcd.js 2.45 kB
79
79
  └ css/ee0556daedda6306.css 3.07 kB
80
80
 
81
81
  λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
@@ -1,10 +1,10 @@
1
1
  $ jest
2
- PASS test/utils/multipleTemplates.test.ts (31.737 s)
3
- PASS test/server/cms/index.test.ts (32.031 s)
4
- PASS test/server/index.test.ts (34.133 s)
2
+ PASS test/utils/multipleTemplates.test.ts (32.249 s)
3
+ PASS test/server/cms/index.test.ts (32.366 s)
4
+ PASS test/server/index.test.ts (34.408 s)
5
5
 
6
6
  Test Suites: 3 passed, 3 total
7
7
  Tests: 19 passed, 19 total
8
8
  Snapshots: 0 total
9
- Time: 35.22 s
9
+ Time: 35.416 s
10
10
  Ran all test suites.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/core",
3
- "version": "3.0.91",
3
+ "version": "3.0.94",
4
4
  "license": "MIT",
5
5
  "repository": "vtex/faststore",
6
6
  "browserslist": "supports es6-module and not dead",
@@ -43,11 +43,11 @@
43
43
  "@envelop/graphql-jit": "^1.1.1",
44
44
  "@envelop/parser-cache": "^2.2.0",
45
45
  "@envelop/validation-cache": "^2.2.0",
46
- "@faststore/api": "^3.0.88",
47
- "@faststore/components": "^3.0.89",
48
- "@faststore/graphql-utils": "^3.0.88",
49
- "@faststore/sdk": "^3.0.88",
50
- "@faststore/ui": "^3.0.89",
46
+ "@faststore/api": "^3.0.94",
47
+ "@faststore/components": "^3.0.94",
48
+ "@faststore/graphql-utils": "^3.0.94",
49
+ "@faststore/sdk": "^3.0.94",
50
+ "@faststore/ui": "^3.0.94",
51
51
  "@graphql-codegen/cli": "^5.0.2",
52
52
  "@graphql-codegen/client-preset": "^4.2.6",
53
53
  "@graphql-codegen/typescript": "^4.0.7",
@@ -88,7 +88,7 @@
88
88
  "devDependencies": {
89
89
  "@cypress/code-coverage": "^3.12.1",
90
90
  "@envelop/testing": "^6.0.0",
91
- "@faststore/eslint-config": "^3.0.88",
91
+ "@faststore/eslint-config": "^3.0.94",
92
92
  "@faststore/lighthouse": "^1.12.32",
93
93
  "@lhci/cli": "^0.9.0",
94
94
  "@testing-library/cypress": "^10.0.1",
@@ -130,5 +130,5 @@
130
130
  "node": "18.19.0",
131
131
  "yarn": "1.19.1"
132
132
  },
133
- "gitHead": "a53f26dce73b16ac30f92aab03f90d031e6e3025"
133
+ "gitHead": "c87448153f3cd42850fcc8aa7666268c4256856f"
134
134
  }
@@ -1,11 +1,24 @@
1
1
  import { Component } from 'react'
2
2
  import type { ErrorInfo, ReactNode } from 'react'
3
3
 
4
- class SectionBoundary extends Component<{
4
+ interface ErrorBoundaryProps {
5
5
  children: ReactNode
6
6
  name: string
7
- }> {
8
- public state = { hasError: false, error: null }
7
+ }
8
+
9
+ interface ErrorBoundaryState {
10
+ hasError: Boolean
11
+ error: Error | null
12
+ }
13
+
14
+ class SectionBoundary extends Component<
15
+ ErrorBoundaryProps,
16
+ ErrorBoundaryState
17
+ > {
18
+ public state: ErrorBoundaryState = {
19
+ hasError: false,
20
+ error: null,
21
+ }
9
22
 
10
23
  public static getDerivedStateFromError(error: Error) {
11
24
  return {
@@ -1,14 +1,19 @@
1
+ import { ReactNode } from 'react'
1
2
  import { mark } from 'src/sdk/tests/mark'
2
3
 
3
- export function FooterInfo({ children }) {
4
+ interface FooterProps {
5
+ children: ReactNode
6
+ }
7
+
8
+ export function FooterInfo({ children }: FooterProps) {
4
9
  return <div data-fs-footer-info>{children}</div>
5
10
  }
6
11
 
7
- export function FooterNavigation({ children }) {
12
+ export function FooterNavigation({ children }: FooterProps) {
8
13
  return <div data-fs-footer-navigation>{children}</div>
9
14
  }
10
15
 
11
- export function Footer({ children }) {
16
+ export function Footer({ children }: FooterProps) {
12
17
  return (
13
18
  <footer
14
19
  data-fs-footer
@@ -14,7 +14,12 @@ import { ProductSummary_ProductFragment } from '@generated/graphql'
14
14
  import SearchProductItem from 'src/components/search/SearchProductItem'
15
15
  import { formatSearchPath } from 'src/sdk/search/formatSearchPath'
16
16
 
17
- function SearchDropdown({ sort, ...otherProps }) {
17
+ interface SearchDropdownProps {
18
+ sort: SearchState['sort']
19
+ [key: string]: any
20
+ }
21
+
22
+ function SearchDropdown({ sort, ...otherProps }: SearchDropdownProps) {
18
23
  const {
19
24
  values: { onSearchSelection, products, term, terms },
20
25
  } = useSearch()
@@ -32,14 +37,14 @@ function SearchDropdown({ sort, ...otherProps }) {
32
37
  linkProps={{
33
38
  href: formatSearchPath({
34
39
  term: suggestion,
35
- sort: sort as SearchState['sort'],
40
+ sort,
36
41
  }),
37
42
  onClick: () =>
38
43
  onSearchSelection?.(
39
44
  suggestion,
40
45
  formatSearchPath({
41
46
  term: suggestion,
42
- sort: sort as SearchState['sort'],
47
+ sort,
43
48
  })
44
49
  ),
45
50
  }}
@@ -1,5 +1,6 @@
1
1
  import type { SearchEvent, SearchState } from '@faststore/sdk'
2
2
  import { sendAnalyticsEvent } from '@faststore/sdk'
3
+
3
4
  import type {
4
5
  SearchInputFieldProps as UISearchInputFieldProps,
5
6
  SearchInputFieldRef as UISearchInputFieldRef,
@@ -133,7 +134,7 @@ const SearchInput = forwardRef<SearchInputRef, SearchInputProps>(
133
134
 
134
135
  {searchDropdownVisible && (
135
136
  <Suspense fallback={null}>
136
- <SearchDropdown sort={sort} />
137
+ <SearchDropdown sort={sort as SearchState['sort']} />
137
138
  </Suspense>
138
139
  )}
139
140
  </UISearchInput>
@@ -27,13 +27,18 @@ export interface SortProps {
27
27
  }
28
28
  }
29
29
 
30
+ type SortOptionKeys = keyof SortProps['options']
31
+
30
32
  function Sort({ label = 'Sort by', options = OptionsMap }: SortProps) {
31
33
  const { state, setState } = useSearch()
32
34
 
33
- const optionsMap = Object.keys(options).reduce((acc, currentKey) => {
34
- acc[currentKey] = options[currentKey] ?? OptionsMap[currentKey]
35
- return acc
36
- }, {})
35
+ const optionsMap = Object.keys(options).reduce(
36
+ (acc, currentKey: SortOptionKeys) => {
37
+ acc[currentKey] = options[currentKey] ?? OptionsMap[currentKey]
38
+ return acc
39
+ },
40
+ {} as Record<SortOptionKeys, string>
41
+ )
37
42
 
38
43
  return (
39
44
  <SelectField
@@ -100,7 +100,7 @@ export const getLandingPageBySlug = async (
100
100
  try {
101
101
  if (storeConfig.cms.data) {
102
102
  const cmsData = JSON.parse(storeConfig.cms.data)
103
- const pageBySlug = cmsData['landingPage'].find((page) => {
103
+ const pageBySlug = cmsData['landingPage'].find((page: any) => {
104
104
  slug === page.settings?.seo?.slug
105
105
  })
106
106
 
@@ -47,7 +47,7 @@ const COMPONENTS: Record<string, ComponentType<any>> = {
47
47
 
48
48
  // Array merging strategy from deepmerge that makes client arrays overwrite server array
49
49
  // https://www.npmjs.com/package/deepmerge
50
- const overwriteMerge = (_, sourceArray) => sourceArray
50
+ const overwriteMerge = (_: any[], sourceArray: any[]) => sourceArray
51
51
 
52
52
  export default function ProductListing({
53
53
  page: { sections, settings },
@@ -1,7 +1,12 @@
1
1
  import storeConfig from 'faststore.config'
2
+ import { ImageLoaderProps } from 'next/image'
2
3
  const THUMBOR_SERVER = `https://${storeConfig.api.storeId}.vtexassets.com`
3
4
 
4
- export default function customImageLoader({ src, width, quality }) {
5
+ export default function customImageLoader({
6
+ src,
7
+ width,
8
+ quality,
9
+ }: ImageLoaderProps) {
5
10
  const preSizeComponents = [THUMBOR_SERVER, 'unsafe']
6
11
 
7
12
  // proportional to the width, enter a height of 0,
@@ -5,7 +5,13 @@ import { useRouter } from 'next/router'
5
5
  import type { ImageGalleryProps as UIImageGalleryProps } from '@faststore/ui'
6
6
  import { useOverrideComponents } from 'src/sdk/overrides/OverrideContext'
7
7
 
8
- const ImageComponent = ({ url, alternateName }) => {
8
+ const ImageComponent = ({
9
+ url,
10
+ alternateName,
11
+ }: {
12
+ url: string
13
+ alternateName?: string
14
+ }) => {
9
15
  const { __experimentalImageGalleryImage: Image } =
10
16
  useOverrideComponents<'ProductDetails'>()
11
17
 
@@ -13,6 +13,8 @@
13
13
  *
14
14
  * This is a limitation not only for this component, but for every native & custom component that makes use of Rich Text.
15
15
  */
16
+
17
+ // @ts-ignore motivation: cannot find the draftjs-to-html package types.
16
18
  import draftToHtml from 'draftjs-to-html'
17
19
  import { NewsletterAddendum as UINewsletterAddendum } from '@faststore/ui'
18
20
  import type { NewsletterAddendumProps as UINewsletterAddendumProps } from '@faststore/ui'
@@ -11,6 +11,6 @@
11
11
 
12
12
  // export default dynamicContent;
13
13
 
14
- const dynamicContent = {}
14
+ const dynamicContent: Record<string, any> = {}
15
15
 
16
16
  export default dynamicContent
@@ -63,7 +63,7 @@ type Props = PDPContentType & {
63
63
 
64
64
  // Array merging strategy from deepmerge that makes client arrays overwrite server array
65
65
  // https://www.npmjs.com/package/deepmerge
66
- const overwriteMerge = (_, sourceArray) => sourceArray
66
+ const overwriteMerge = (_: any[], sourceArray: any[]) => sourceArray
67
67
 
68
68
  function Page({ data: server, sections, globalSections, offers, meta }: Props) {
69
69
  const { product } = server
@@ -11,7 +11,7 @@ if (typeof window !== 'undefined') {
11
11
  }
12
12
  }
13
13
 
14
- const AnalyticsHandler = () => {
14
+ const AnalyticsHandler = (): null => {
15
15
  useAnalyticsEvent((event: AnalyticsEvent) => {
16
16
  // Cleans the ecommerce object before pushing a new one
17
17
  // This prevents the new data from getting merged with the previous one
@@ -15,8 +15,20 @@ if (typeof window !== 'undefined') {
15
15
  window.setInterval(() => setReloads(0), 30e3)
16
16
  }
17
17
 
18
- class ErrorBoundary extends Component<{ children: ReactNode }> {
19
- public state = { hasError: false, error: null }
18
+ interface ErrorBoundaryProps {
19
+ children: ReactNode
20
+ }
21
+
22
+ interface ErrorBoundaryState {
23
+ hasError: Boolean
24
+ error: Error | null
25
+ }
26
+
27
+ class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
28
+ public state: ErrorBoundaryState = {
29
+ hasError: false,
30
+ error: null,
31
+ }
20
32
 
21
33
  public static getDerivedStateFromError(error: Error) {
22
34
  return {
@@ -7,6 +7,9 @@ import type {
7
7
 
8
8
  import type { SectionsOverrides } from '../../typings/overrides'
9
9
 
10
+ /* TODO: Fix typescript errors. It is necessary to further investigate the typing
11
+ issues of this file. Error lines have been marked with the @ts-ignore comment*/
12
+
10
13
  export function getSectionOverrides<
11
14
  SectionName extends keyof SectionsOverrides
12
15
  >(
@@ -15,38 +18,45 @@ export function getSectionOverrides<
15
18
  ): OverriddenComponents<SectionName> {
16
19
  const overriddenComponents = {} as OverriddenComponents<SectionName>
17
20
 
18
- Object.entries(defaultComponents).forEach(([key, value]) => {
19
- const componentOverride:
20
- | ComponentOverrideDefinition<unknown, unknown>
21
- | undefined = override.components?.[key]
22
-
23
- if (!componentOverride) {
24
- overriddenComponents[key] = {
25
- Component: value,
26
- props: {},
21
+ Object.entries<React.ComponentType>(defaultComponents).forEach(
22
+ ([key, value]) => {
23
+ const componentOverride:
24
+ | ComponentOverrideDefinition<React.ComponentType, unknown>
25
+ | undefined =
26
+ // @ts-ignore
27
+ override.components?.[key]
28
+
29
+ if (!componentOverride) {
30
+ // @ts-ignore
31
+ overriddenComponents[key] = {
32
+ Component: value,
33
+ props: {},
34
+ }
35
+
36
+ return
27
37
  }
28
38
 
29
- return
30
- }
31
-
32
- if (componentOverride.Component && componentOverride.props) {
33
- console.warn(
34
- `Mixed use of Component and props overrides detected. Defaulting to Component override: component ${key} in the ${override.section} section.`
35
- )
36
- }
37
-
38
- if (componentOverride.Component) {
39
- overriddenComponents[key] = {
40
- Component: componentOverride.Component,
41
- props: {},
39
+ if (componentOverride.Component && componentOverride.props) {
40
+ console.warn(
41
+ `Mixed use of Component and props overrides detected. Defaulting to Component override: component ${key} in the ${override.section} section.`
42
+ )
42
43
  }
43
- } else {
44
- overriddenComponents[key] = {
45
- Component: value,
46
- props: componentOverride.props ?? {},
44
+
45
+ if (componentOverride.Component) {
46
+ // @ts-ignore
47
+ overriddenComponents[key] = {
48
+ Component: componentOverride.Component,
49
+ props: {},
50
+ }
51
+ } else {
52
+ // @ts-ignore
53
+ overriddenComponents[key] = {
54
+ Component: value,
55
+ props: componentOverride.props ?? {},
56
+ }
47
57
  }
48
58
  }
49
- })
59
+ )
50
60
 
51
61
  return overriddenComponents
52
62
  }
@@ -7,6 +7,7 @@ import { useLocalizedVariables } from './useLocalizedVariables'
7
7
  import { useSession } from 'src/sdk/session'
8
8
 
9
9
  import type {
10
+ ClientManyProductsQueryQueryVariables,
10
11
  ClientProductGalleryQueryQuery as Query,
11
12
  ClientProductGalleryQueryQueryVariables as Variables,
12
13
  } from '@generated/graphql'
@@ -61,12 +62,19 @@ export const fragment = gql(`
61
62
  }
62
63
  `)
63
64
 
65
+ type ProductGalleryQueryOptions = {
66
+ itemsPerPage: number
67
+ selectedFacets: Facet[]
68
+ sort: ClientManyProductsQueryQueryVariables['sort']
69
+ term: ClientManyProductsQueryQueryVariables['term']
70
+ }
71
+
64
72
  export const useProductGalleryQuery = ({
65
73
  term,
66
74
  sort,
67
75
  selectedFacets,
68
76
  itemsPerPage,
69
- }) => {
77
+ }: ProductGalleryQueryOptions) => {
70
78
  const { locale } = useSession()
71
79
  const { state, setState } = useSearch()
72
80
 
@@ -61,7 +61,7 @@ describe('Multiple page templates', () => {
61
61
  })
62
62
 
63
63
  it('should return false when the rewrites is empty array', () => {
64
- const rewritesArr = []
64
+ const rewritesArr: Rewrite[] = []
65
65
  const result = hasRewritesConfigForSlug({
66
66
  rewrites: rewritesArr,
67
67
  templateValue: '/test/my-office',
package/tsconfig.json CHANGED
@@ -22,13 +22,14 @@
22
22
  ]
23
23
  },
24
24
  "forceConsistentCasingInFileNames": true,
25
- "strict": false,
25
+ "noImplicitAny": true,
26
26
  "incremental": true,
27
27
  "isolatedModules": true,
28
28
  "target": "es5",
29
29
  "lib": ["dom", "dom.iterable", "esnext"],
30
30
  "skipLibCheck": true,
31
- "esModuleInterop": true
31
+ "esModuleInterop": true,
32
+ "strict": false
32
33
  },
33
34
  "include": ["*.d.ts", "src/**/*.ts", "src/**/*.tsx", "@generated/**/*.ts"],
34
35
  "exclude": ["node_modules", "public"]