@faststore/core 2.2.0-alpha.0 → 2.2.0-alpha.2
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/.turbo/turbo-build.log +3 -3
- package/.turbo/turbo-test.log +11 -11
- package/cms/faststore/sections.json +32 -2
- package/faststore.config.js +1 -1
- package/generate.sh +2 -2
- package/index.ts +2 -0
- package/package.json +8 -8
- package/src/components/ThirdPartyScripts/ThirdPartyScripts.tsx +2 -1
- package/src/components/navigation/Navbar/Navbar.tsx +3 -4
- package/src/components/navigation/NavbarSlider/NavbarSlider.tsx +4 -5
- package/src/components/sections/CrossSellingShelf/CrossSellingShelf.tsx +0 -1
- package/src/components/sections/Footer/Footer.tsx +14 -2
- package/src/components/sections/Navbar/Navbar.tsx +4 -0
- package/src/customizations/GlobalOverrides.tsx +2 -0
- package/src/customizations/components/overrides/ThirdPartyScripts.tsx +9 -0
- package/src/customizations/scripts/ThirdPartyScripts.tsx +8 -0
- package/src/sdk/analytics/platform/vtex/search.ts +15 -11
- package/src/utils/getCookie.ts +14 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -28,7 +28,7 @@ Route (pages) Size First Load JS
|
|
|
28
28
|
├ ● /[...slug] 4.83 kB 210 kB
|
|
29
29
|
├ └ css/527e334fa69cf40a.css 1.85 kB
|
|
30
30
|
├ ● /[slug]/p 11.3 kB 205 kB
|
|
31
|
-
├ └ css/
|
|
31
|
+
├ └ css/4b7138899cd07c63.css 11.3 kB
|
|
32
32
|
├ ○ /404 1.19 kB 114 kB
|
|
33
33
|
├ ● /500 1.21 kB 114 kB
|
|
34
34
|
├ ● /account 670 B 113 kB
|
|
@@ -42,8 +42,8 @@ Route (pages) Size First Load JS
|
|
|
42
42
|
+ First Load JS shared by all 81 kB
|
|
43
43
|
├ chunks/framework-dfd14d7ce6600b03.js 45.3 kB
|
|
44
44
|
├ chunks/main-fd466221927468fd.js 23.9 kB
|
|
45
|
-
├ chunks/pages/_app-
|
|
46
|
-
├ chunks/webpack-
|
|
45
|
+
├ chunks/pages/_app-6d0e6ab9a4dd8106.js 6.45 kB
|
|
46
|
+
├ chunks/webpack-2e9da2bb669ad415.js 2.29 kB
|
|
47
47
|
└ css/9e76fef1c9ca89af.css 3.06 kB
|
|
48
48
|
|
|
49
49
|
λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
$ tsdx test
|
|
2
2
|
ts-jest[versions] (WARN) Version 29.1.0 of jest installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=25.0.0 <26.0.0). Please do not report issues in ts-jest if you are using unsupported versions.
|
|
3
3
|
ts-jest[versions] (WARN) Version 4.9.4 of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=3.4.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions.
|
|
4
|
-
PASS test/server/index.test.ts (
|
|
4
|
+
PASS test/server/index.test.ts (17.219s)
|
|
5
5
|
FastStore GraphQL Layer
|
|
6
6
|
@faststore/api
|
|
7
|
-
✓ should return a valid GraphQL schema (
|
|
8
|
-
✓ should return a valid GraphQL schema contain all expected types (
|
|
9
|
-
✓ should return a valid GraphQL schema contain all expected queries (
|
|
10
|
-
✓ should return a valid GraphQL schema contain all expected mutations
|
|
7
|
+
✓ should return a valid GraphQL schema (7ms)
|
|
8
|
+
✓ should return a valid GraphQL schema contain all expected types (53ms)
|
|
9
|
+
✓ should return a valid GraphQL schema contain all expected queries (1ms)
|
|
10
|
+
✓ should return a valid GraphQL schema contain all expected mutations
|
|
11
11
|
VTEX API Extension
|
|
12
|
-
✓ getTypeDefsFromFolder function should return an Array (
|
|
12
|
+
✓ getTypeDefsFromFolder function should return an Array (14ms)
|
|
13
13
|
Third Party API Extension
|
|
14
|
-
✓ getTypeDefsFromFolder function should return an Array (
|
|
14
|
+
✓ getTypeDefsFromFolder function should return an Array (6ms)
|
|
15
15
|
Final Schema after merging
|
|
16
|
-
✓ should return a valid merged GraphQL schema (
|
|
16
|
+
✓ should return a valid merged GraphQL schema (111ms)
|
|
17
17
|
Envelop
|
|
18
|
-
✓ should exist with its plugins (
|
|
19
|
-
✓ should handle options and execute (
|
|
18
|
+
✓ should exist with its plugins (65ms)
|
|
19
|
+
✓ should handle options and execute (226ms)
|
|
20
20
|
|
|
21
21
|
Test Suites: 1 passed, 1 total
|
|
22
22
|
Tests: 9 passed, 9 total
|
|
23
23
|
Snapshots: 0 total
|
|
24
|
-
Time:
|
|
24
|
+
Time: 18.262s
|
|
25
25
|
Ran all test suites.
|
|
@@ -166,6 +166,21 @@
|
|
|
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
|
+
}
|
|
169
184
|
}
|
|
170
185
|
}
|
|
171
186
|
},
|
|
@@ -556,8 +571,23 @@
|
|
|
556
571
|
}
|
|
557
572
|
},
|
|
558
573
|
"alt": {
|
|
559
|
-
"
|
|
560
|
-
"
|
|
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
|
+
}
|
|
561
591
|
}
|
|
562
592
|
}
|
|
563
593
|
},
|
package/faststore.config.js
CHANGED
package/generate.sh
CHANGED
|
@@ -62,8 +62,8 @@ run_command() {
|
|
|
62
62
|
# Run "yarn generate:schema" without outputting logs and errors
|
|
63
63
|
run_command "yarn generate:schema" "Failed to run 'yarn generate:schema'. Please check your setup." "false"
|
|
64
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"
|
|
65
|
+
# Run "yarn graphql-codegen" and capture the output
|
|
66
|
+
run_command "yarn graphql-codegen" "GraphQL was not optimized and TS files were not updated. Changes in the GraphQL layer did not take effect" "false"
|
|
67
67
|
|
|
68
68
|
# Run "yarn format:generated" and display a warning if it produces output
|
|
69
69
|
run_command "yarn format:generated" "Failed to format generated files. 'yarn format:generated' thrown errors" "true"
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/core",
|
|
3
|
-
"version": "2.2.0-alpha.
|
|
3
|
+
"version": "2.2.0-alpha.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"browserslist": "supports es6-module and not dead",
|
|
6
6
|
"exports": {
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"@envelop/graphql-jit": "^1.1.1",
|
|
36
36
|
"@envelop/parser-cache": "^2.2.0",
|
|
37
37
|
"@envelop/validation-cache": "^2.2.0",
|
|
38
|
-
"@faststore/api": "^2.2.0-alpha.
|
|
39
|
-
"@faststore/components": "^2.2.0-alpha.
|
|
40
|
-
"@faststore/graphql-utils": "^2.2.0-alpha.
|
|
41
|
-
"@faststore/sdk": "^2.2.0-alpha.
|
|
42
|
-
"@faststore/ui": "^2.2.0-alpha.
|
|
38
|
+
"@faststore/api": "^2.2.0-alpha.1",
|
|
39
|
+
"@faststore/components": "^2.2.0-alpha.1",
|
|
40
|
+
"@faststore/graphql-utils": "^2.2.0-alpha.1",
|
|
41
|
+
"@faststore/sdk": "^2.2.0-alpha.1",
|
|
42
|
+
"@faststore/ui": "^2.2.0-alpha.1",
|
|
43
43
|
"@graphql-codegen/cli": "^3.3.1",
|
|
44
44
|
"@graphql-codegen/typescript": "^3.0.4",
|
|
45
45
|
"@graphql-codegen/typescript-operations": "^3.0.4",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@cypress/code-coverage": "^3.9.10",
|
|
80
80
|
"@envelop/testing": "^6.0.0",
|
|
81
|
-
"@faststore/eslint-config": "^2.2.0-alpha.
|
|
81
|
+
"@faststore/eslint-config": "^2.2.0-alpha.1",
|
|
82
82
|
"@faststore/lighthouse": "^1.12.32",
|
|
83
83
|
"@lhci/cli": "^0.9.0",
|
|
84
84
|
"@storybook/addon-a11y": "^6.5.9",
|
|
@@ -125,5 +125,5 @@
|
|
|
125
125
|
"msw": {
|
|
126
126
|
"workerDirectory": "public"
|
|
127
127
|
},
|
|
128
|
-
"gitHead": "
|
|
128
|
+
"gitHead": "e7c49e9acbd86b8501badc384476a10d4f39054f"
|
|
129
129
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Partytown } from '@builder.io/partytown/react'
|
|
2
|
-
|
|
2
|
+
import OverrideComponents from 'src/customizations/GlobalOverrides'
|
|
3
3
|
import storeConfig from '../../../faststore.config'
|
|
4
4
|
import GoogleTagManager from './GoogleTagManager'
|
|
5
5
|
import VTEX from './vtex'
|
|
@@ -26,6 +26,7 @@ function ThirdPartyScripts() {
|
|
|
26
26
|
<>
|
|
27
27
|
{includeGTM && <GoogleTagManager containerId={gtmContainerId} />}
|
|
28
28
|
{includeVTEX && <VTEX />}
|
|
29
|
+
<OverrideComponents.ThirdPartyScripts />
|
|
29
30
|
<Partytown
|
|
30
31
|
key="partytown"
|
|
31
32
|
// Variables to forward to from main to worker
|
|
@@ -110,13 +110,12 @@ function Navbar({
|
|
|
110
110
|
aria-label={menuIconAlt}
|
|
111
111
|
/>
|
|
112
112
|
<Link
|
|
113
|
-
href="/"
|
|
114
113
|
data-fs-navbar-logo
|
|
114
|
+
href={logo.link ? logo.link.url : '/'}
|
|
115
|
+
title={logo.link ? logo.link.title : homeLabel}
|
|
115
116
|
prefetch={false}
|
|
116
|
-
title={homeLabel}
|
|
117
|
-
aria-label={homeLabel}
|
|
118
117
|
>
|
|
119
|
-
<Logo {
|
|
118
|
+
<Logo src={logo.src} alt={logo.alt} />
|
|
120
119
|
</Link>
|
|
121
120
|
</>
|
|
122
121
|
)}
|
|
@@ -51,13 +51,12 @@ function NavbarSlider({
|
|
|
51
51
|
{...NavbarSliderWrapper.props}
|
|
52
52
|
>
|
|
53
53
|
<Link
|
|
54
|
-
href="/"
|
|
55
|
-
onClick={fadeOut}
|
|
56
|
-
title={homeLabel}
|
|
57
|
-
aria-label={homeLabel}
|
|
58
54
|
data-fs-navbar-slider-logo
|
|
55
|
+
href={logo.link ? logo.link.url : '/'}
|
|
56
|
+
title={logo.link ? logo.link.title : homeLabel}
|
|
57
|
+
onClick={fadeOut}
|
|
59
58
|
>
|
|
60
|
-
<Logo {
|
|
59
|
+
<Logo alt={logo.alt} src={logo.src} />
|
|
61
60
|
</Link>
|
|
62
61
|
</NavbarSliderHeader.Component>
|
|
63
62
|
<NavbarSliderContent.Component {...NavbarSliderContent.props}>
|
|
@@ -2,7 +2,6 @@ import { useMemo } from 'react'
|
|
|
2
2
|
|
|
3
3
|
import UIProductShelf from 'src/components/ui/ProductShelf'
|
|
4
4
|
import { useInView } from 'react-intersection-observer'
|
|
5
|
-
import { useProductsQuery } from 'src/sdk/product/useProductsQuery'
|
|
6
5
|
import { usePDP } from 'src/sdk/overrides/PageProvider'
|
|
7
6
|
import styles from '../ProductShelf/section.module.scss'
|
|
8
7
|
import Section from '../Section'
|
|
@@ -11,6 +11,7 @@ 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'
|
|
14
15
|
import UIIncentives from '../../ui/Incentives'
|
|
15
16
|
import type { Incentive } from '../../ui/Incentives'
|
|
16
17
|
|
|
@@ -26,6 +27,10 @@ export type FooterProps = {
|
|
|
26
27
|
logo: {
|
|
27
28
|
src: string
|
|
28
29
|
alt: string
|
|
30
|
+
link: {
|
|
31
|
+
url: string
|
|
32
|
+
title: string
|
|
33
|
+
}
|
|
29
34
|
}
|
|
30
35
|
copyrightInfo: string
|
|
31
36
|
acceptedPaymentMethods: {
|
|
@@ -40,7 +45,7 @@ const Footer = ({
|
|
|
40
45
|
footerLinks,
|
|
41
46
|
footerSocial,
|
|
42
47
|
footerSocial: { title: footerSocialTitle },
|
|
43
|
-
logo: { src: logoSrc, alt: logoAlt },
|
|
48
|
+
logo: { src: logoSrc, alt: logoAlt, link: logoLink },
|
|
44
49
|
copyrightInfo,
|
|
45
50
|
acceptedPaymentMethods: {
|
|
46
51
|
showPaymentMethods,
|
|
@@ -48,6 +53,7 @@ const Footer = ({
|
|
|
48
53
|
paymentMethods,
|
|
49
54
|
},
|
|
50
55
|
}: FooterProps) => {
|
|
56
|
+
const homeLabel = 'Go to Home'
|
|
51
57
|
return (
|
|
52
58
|
<Section className={`section ${styles.section} section-footer`}>
|
|
53
59
|
<UIFooter>
|
|
@@ -60,7 +66,13 @@ const Footer = ({
|
|
|
60
66
|
/>
|
|
61
67
|
</UIFooterNavigation>
|
|
62
68
|
<UIFooterInfo>
|
|
63
|
-
<
|
|
69
|
+
<Link
|
|
70
|
+
href={logoLink ? logoLink.url : '/'}
|
|
71
|
+
title={logoLink ? logoLink.title : homeLabel}
|
|
72
|
+
>
|
|
73
|
+
<Logo alt={logoAlt} src={logoSrc} />
|
|
74
|
+
</Link>
|
|
75
|
+
|
|
64
76
|
{showPaymentMethods && (
|
|
65
77
|
<UIPaymentMethods
|
|
66
78
|
flagList={paymentMethods}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import WebFontsOverrides from 'src/customizations/components/overrides/WebFonts'
|
|
2
2
|
import { default as CoreWebFonts } from 'src/fonts/WebFonts'
|
|
3
|
+
import ThirdPartyScriptsOverrides from 'src/customizations/components/overrides/ThirdPartyScripts'
|
|
3
4
|
|
|
4
5
|
const Components = {
|
|
5
6
|
WebFonts: CoreWebFonts,
|
|
6
7
|
...WebFontsOverrides.components,
|
|
8
|
+
...ThirdPartyScriptsOverrides.components,
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
export const WebFonts = Components.WebFonts
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* More info at: https://www.notion.so/vtexhandbook/Event-API-Documentation-48eee26730cf4d7f80f8fd7262231f84
|
|
3
3
|
*/
|
|
4
4
|
import type { AnalyticsEvent } from '@faststore/sdk'
|
|
5
|
+
import type { SearchSelectItemEvent } from '../../types'
|
|
5
6
|
|
|
6
7
|
import config from '../../../../../faststore.config'
|
|
7
|
-
import
|
|
8
|
+
import { getCookie } from '../../../../utils/getCookie'
|
|
8
9
|
|
|
9
10
|
const THIRTY_MINUTES_S = 30 * 60
|
|
10
11
|
const ONE_YEAR_S = 365 * 24 * 3600
|
|
@@ -14,27 +15,30 @@ const randomUUID = () =>
|
|
|
14
15
|
? crypto.randomUUID()
|
|
15
16
|
: (Math.random() * 1e6).toFixed(0)
|
|
16
17
|
|
|
17
|
-
const
|
|
18
|
-
|
|
18
|
+
const createCookie = (key: string, expiresSecond: number) => {
|
|
19
|
+
// Setting the domain attribute specifies which host can receive it; we need it to make the cookies available on the `secure` subdomain.
|
|
20
|
+
// Although https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie mentioned leading dot (.) is not needed and ignored. I couldn't set the cookies without it.
|
|
21
|
+
const urlDomain = `.${new URL(config.storeUrl).hostname}`
|
|
19
22
|
|
|
20
23
|
return () => {
|
|
21
|
-
const
|
|
22
|
-
const isExpired = !item || timelapsed(item.createdAt) > expiresSecond
|
|
23
|
-
const payload: string = isExpired ? randomUUID() : item.payload
|
|
24
|
+
const isExpired = getCookie(key) === undefined
|
|
24
25
|
|
|
25
26
|
if (isExpired) {
|
|
26
|
-
const
|
|
27
|
+
const value = randomUUID()
|
|
28
|
+
|
|
29
|
+
document.cookie = `${key}=${value}; max-age=${expiresSecond}; domain=${urlDomain}; path=/;`
|
|
30
|
+
// Setting the `path=/` makes the cookie accessible on any path of the domain/subdomain
|
|
27
31
|
|
|
28
|
-
|
|
32
|
+
return value
|
|
29
33
|
}
|
|
30
34
|
|
|
31
|
-
return
|
|
35
|
+
return getCookie(key)
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
const user = {
|
|
36
|
-
anonymous:
|
|
37
|
-
session:
|
|
40
|
+
anonymous: createCookie('vtex-faststore-anonymous', ONE_YEAR_S),
|
|
41
|
+
session: createCookie('vtex-faststore-session', THIRTY_MINUTES_S),
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
type SearchEvent =
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function getCookie(name: string): string | undefined {
|
|
2
|
+
const cookieString = decodeURIComponent(document.cookie)
|
|
3
|
+
const cookies = cookieString.split(';')
|
|
4
|
+
|
|
5
|
+
for (const cookie of cookies) {
|
|
6
|
+
const [cookieName, cookieValue] = cookie.trim().split('=')
|
|
7
|
+
|
|
8
|
+
if (cookieName === name) {
|
|
9
|
+
return cookieValue
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return undefined // Cookie not found
|
|
14
|
+
}
|