@faststore/core 3.98.0-dev.4 → 3.98.0-dev.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +41 -41
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/config.json +3 -3
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/prerender-manifest.js +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/react-loadable-manifest.json +28 -17
- package/.next/routes-manifest.json +1 -1
- package/.next/server/chunks/2336.js +6 -0
- package/.next/server/chunks/3890.js +11 -11
- package/.next/server/chunks/7098.js +1 -1
- package/.next/server/chunks/948.js +2 -2
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/pages/404.js +1 -1
- package/.next/server/pages/404.js.nft.json +1 -1
- package/.next/server/pages/500.js +1 -1
- package/.next/server/pages/500.js.nft.json +1 -1
- package/.next/server/pages/[...slug].js +1 -1
- package/.next/server/pages/[...slug].js.nft.json +1 -1
- package/.next/server/pages/[slug]/p.js +1 -1
- package/.next/server/pages/[slug]/p.js.nft.json +1 -1
- package/.next/server/pages/_app.js +1 -1
- package/.next/server/pages/_app.js.nft.json +1 -1
- package/.next/server/pages/_document.js.nft.json +1 -1
- package/.next/server/pages/_error.js +1 -1
- package/.next/server/pages/_error.js.nft.json +1 -1
- package/.next/server/pages/api/fs/logout.js.nft.json +1 -1
- package/.next/server/pages/api/graphql.js.nft.json +1 -1
- package/.next/server/pages/api/health/live.js.nft.json +1 -1
- package/.next/server/pages/api/health/ready.js.nft.json +1 -1
- package/.next/server/pages/api/preview.js.nft.json +1 -1
- package/.next/server/pages/checkout.js +1 -1
- package/.next/server/pages/checkout.js.nft.json +1 -1
- package/.next/server/pages/en-US/404.html +2 -2
- package/.next/server/pages/en-US/404.json +1 -1
- package/.next/server/pages/en-US/500.html +2 -2
- package/.next/server/pages/en-US/500.json +1 -1
- package/.next/server/pages/en-US/checkout.html +2 -2
- package/.next/server/pages/en-US/checkout.json +1 -1
- package/.next/server/pages/en-US/login.html +2 -2
- package/.next/server/pages/en-US/login.json +1 -1
- package/.next/server/pages/en-US/s.html +2 -2
- package/.next/server/pages/en-US/s.json +1 -1
- package/.next/server/pages/en-US.html +2 -2
- package/.next/server/pages/en-US.json +1 -1
- package/.next/server/pages/index.js +1 -1
- package/.next/server/pages/index.js.nft.json +1 -1
- package/.next/server/pages/login.js +1 -1
- package/.next/server/pages/login.js.nft.json +1 -1
- package/.next/server/pages/pvt/account/403.js +1 -1
- package/.next/server/pages/pvt/account/403.js.nft.json +1 -1
- package/.next/server/pages/pvt/account/404.js +1 -1
- package/.next/server/pages/pvt/account/404.js.nft.json +1 -1
- package/.next/server/pages/pvt/account/[...unknown].js +1 -1
- package/.next/server/pages/pvt/account/[...unknown].js.nft.json +1 -1
- package/.next/server/pages/pvt/account/orders/[id].js +1 -1
- package/.next/server/pages/pvt/account/orders/[id].js.nft.json +1 -1
- package/.next/server/pages/pvt/account/orders.js +1 -1
- package/.next/server/pages/pvt/account/orders.js.nft.json +1 -1
- package/.next/server/pages/pvt/account/profile.js +1 -1
- package/.next/server/pages/pvt/account/profile.js.nft.json +1 -1
- package/.next/server/pages/pvt/account/security.js +1 -1
- package/.next/server/pages/pvt/account/security.js.nft.json +1 -1
- package/.next/server/pages/pvt/account/user-details.js +1 -1
- package/.next/server/pages/pvt/account/user-details.js.nft.json +1 -1
- package/.next/server/pages/pvt/account.js +1 -1
- package/.next/server/pages/pvt/account.js.nft.json +1 -1
- package/.next/server/pages/s.js +1 -1
- package/.next/server/pages/s.js.nft.json +1 -1
- package/.next/server/pages-manifest.json +1 -1
- package/.next/server/webpack-runtime.js +1 -1
- package/.next/static/{p7uWa16NlhAmYvbUs2ds3 → 3YyETsM_ICzJh8iCbl24o}/_buildManifest.js +1 -1
- package/.next/static/chunks/{1841.a1b15f2c88e02d32.js → 1841.b3a98a2a1886b09c.js} +1 -1
- package/.next/static/chunks/{6393.e4b26fee060438d6.js → 6393.fc3a7002110b07a9.js} +1 -1
- package/.next/static/chunks/{7191-4bf7ddfc2bd0f3a9.js → 7191-91a7e2902cbb78eb.js} +1 -1
- package/.next/static/chunks/9173-004874438ae65e64.js +1 -0
- package/.next/static/chunks/{9399.48251a278809f7d3.js → 9399.eb5fc80e2649be72.js} +1 -1
- package/.next/static/chunks/ShoppingAssistant.ba191eb4dbed67e5.js +1 -0
- package/.next/static/chunks/pages/[slug]/{p-0901bccd311c7775.js → p-15e4c70dcf969e68.js} +1 -1
- package/.next/static/chunks/pages/_app-9709623009fd94a5.js +1 -0
- package/.next/static/chunks/pages/pvt/account/orders/{[id]-e03ebb0393ac92a2.js → [id]-46c461739ff3b436.js} +1 -1
- package/.next/static/chunks/webpack-c56d30359092c45c.js +1 -0
- package/.next/static/css/f16438bcf4508fb3.css +1 -0
- package/.next/trace +141 -140
- package/.turbo/turbo-build.log +25 -31
- package/.turbo/turbo-test.log +6 -7
- package/CHANGELOG.md +16 -0
- package/cms/faststore/sections.json +10 -0
- package/package.json +3 -2
- package/src/components/ThirdPartyScripts/index.ts +1 -0
- package/src/components/ThirdPartyScripts/useShoppingAssistant.tsx +30 -0
- package/src/components/account/MyAccountDrawer/OrganizationDrawer/OrganizationDrawer.tsx +27 -18
- package/src/components/account/MyAccountDrawer/OrganizationDrawer/useReloadAfterLogoutReturn.ts +75 -0
- package/src/components/cms/global/Components.ts +8 -0
- package/src/components/sections/ShoppingAssistant/ShoppingAssistant.tsx +24 -0
- package/src/components/sections/ShoppingAssistant/index.ts +1 -0
- package/src/components/sections/ShoppingAssistant/section.module.scss +5 -0
- package/src/pages/_app.tsx +2 -0
- package/src/sdk/graphql/request.ts +1 -1
- package/src/sdk/graphql/useQuery.ts +23 -6
- package/src/utils/cookieCacheBusting.ts +35 -41
- package/test/utils/cookieCacheBusting.test.ts +54 -47
- package/.next/server/chunks/772.js +0 -6
- package/.next/static/chunks/9173-ddb551c7ca3de40b.js +0 -1
- package/.next/static/chunks/pages/_app-eae02e7ad5c9db46.js +0 -1
- package/.next/static/chunks/webpack-1947faa4988b2d76.js +0 -1
- /package/.next/static/{p7uWa16NlhAmYvbUs2ds3 → 3YyETsM_ICzJh8iCbl24o}/_ssgManifest.js +0 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @faststore/core@3.98.0-dev.
|
|
2
|
+
> @faststore/core@3.98.0-dev.6 prebuild /home/runner/work/faststore/faststore/packages/core
|
|
3
3
|
> na run partytown && na run generate
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> @faststore/core@3.98.0-dev.
|
|
6
|
+
> @faststore/core@3.98.0-dev.6 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.98.0-dev.
|
|
11
|
+
> @faststore/core@3.98.0-dev.6 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.98.0-dev.
|
|
15
|
+
> @faststore/core@3.98.0-dev.6 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.98.0-dev.
|
|
20
|
+
> @faststore/core@3.98.0-dev.6 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.98.0-dev.
|
|
40
|
+
> @faststore/core@3.98.0-dev.6 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.98.0-dev.
|
|
44
|
+
> @faststore/core@3.98.0-dev.6 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
|
|
@@ -79,58 +79,52 @@ Import trace for requested module:
|
|
|
79
79
|
|
|
80
80
|
Collecting page data ...
|
|
81
81
|
Generating static pages (0/6) ...
|
|
82
|
-
Webchat not found. Add a new component for this section or remove it from the CMS
|
|
83
|
-
Webchat not found. Add a new component for this section or remove it from the CMS
|
|
84
82
|
|
|
85
83
|
Generating static pages (1/6)
|
|
86
|
-
Webchat not found. Add a new component for this section or remove it from the CMS
|
|
87
84
|
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.
|
|
88
85
|
|
|
89
86
|
Generating static pages (2/6)
|
|
90
|
-
Webchat not found. Add a new component for this section or remove it from the CMS
|
|
91
87
|
|
|
92
88
|
Generating static pages (4/6)
|
|
93
|
-
Webchat not found. Add a new component for this section or remove it from the CMS
|
|
94
|
-
Webchat not found. Add a new component for this section or remove it from the CMS
|
|
95
89
|
|
|
96
90
|
✓ Generating static pages (6/6)
|
|
97
91
|
Finalizing page optimization ...
|
|
98
92
|
Collecting build traces ...
|
|
99
93
|
|
|
100
94
|
Route (pages) Size First Load JS
|
|
101
|
-
┌ ● / 7.39 kB
|
|
95
|
+
┌ ● / 7.39 kB 148 kB
|
|
102
96
|
├ └ css/02259c549b2179f2.css 3.1 kB
|
|
103
97
|
├ /_app 0 B 108 kB
|
|
104
|
-
├ ● /[...slug] 2.56 kB
|
|
98
|
+
├ ● /[...slug] 2.56 kB 158 kB
|
|
105
99
|
├ ● /[slug]/p 98.2 kB 238 kB
|
|
106
100
|
├ └ css/a6a4ebbe01adbbad.css 22.2 kB
|
|
107
|
-
├ ○ /404 1.57 kB
|
|
108
|
-
├ ● /500 1.57 kB
|
|
101
|
+
├ ○ /404 1.57 kB 142 kB
|
|
102
|
+
├ ● /500 1.57 kB 142 kB
|
|
109
103
|
├ λ /api/fs/logout 0 B 108 kB
|
|
110
104
|
├ λ /api/graphql 0 B 108 kB
|
|
111
105
|
├ λ /api/health/live 0 B 108 kB
|
|
112
106
|
├ λ /api/health/ready 0 B 108 kB
|
|
113
107
|
├ λ /api/preview 0 B 108 kB
|
|
114
|
-
├ ● /checkout 749 B
|
|
115
|
-
├ ● /login 1.7 kB
|
|
116
|
-
├ λ /pvt/account 247 B
|
|
117
|
-
├ ● /pvt/account/[...unknown] 287 B
|
|
118
|
-
├ λ /pvt/account/403 2.98 kB
|
|
108
|
+
├ ● /checkout 749 B 141 kB
|
|
109
|
+
├ ● /login 1.7 kB 142 kB
|
|
110
|
+
├ λ /pvt/account 247 B 109 kB
|
|
111
|
+
├ ● /pvt/account/[...unknown] 287 B 109 kB
|
|
112
|
+
├ λ /pvt/account/403 2.98 kB 143 kB
|
|
119
113
|
├ └ css/0fae3d432331aae9.css 4.68 kB
|
|
120
114
|
├ λ /pvt/account/404 2.18 kB 142 kB
|
|
121
115
|
├ └ css/0fc6b2ff69142c6a.css 4.74 kB
|
|
122
|
-
├ λ /pvt/account/orders 9.78 kB
|
|
116
|
+
├ λ /pvt/account/orders 9.78 kB 150 kB
|
|
123
117
|
├ └ css/40a294d0a24ad01d.css 14.1 kB
|
|
124
|
-
├ λ /pvt/account/orders/[id] 13.7 kB
|
|
118
|
+
├ λ /pvt/account/orders/[id] 13.7 kB 154 kB
|
|
125
119
|
├ └ css/08d03445f1797608.css 13.8 kB
|
|
126
|
-
├ λ /pvt/account/profile 1.98 kB
|
|
120
|
+
├ λ /pvt/account/profile 1.98 kB 142 kB
|
|
127
121
|
├ └ css/47f1b4e8de15d314.css 4.42 kB
|
|
128
|
-
├ λ /pvt/account/security 3.96 kB
|
|
122
|
+
├ λ /pvt/account/security 3.96 kB 144 kB
|
|
129
123
|
├ └ css/973dd40d4773e8cd.css 5.74 kB
|
|
130
|
-
├ λ /pvt/account/user-details 1.91 kB
|
|
124
|
+
├ λ /pvt/account/user-details 1.91 kB 142 kB
|
|
131
125
|
├ └ css/05c399956ff24b77.css 4.54 kB
|
|
132
|
-
└ ● /s 3.36 kB
|
|
133
|
-
+ First Load JS shared by all
|
|
126
|
+
└ ● /s 3.36 kB 159 kB
|
|
127
|
+
+ First Load JS shared by all 112 kB
|
|
134
128
|
├ chunks/framework-d514426edf885c68.js 45.4 kB
|
|
135
129
|
├ chunks/main-ec03882c4375091d.js 33.2 kB
|
|
136
|
-
├ chunks/pages/_app-
|
|
137
|
-
├ chunks/webpack-
|
|
130
|
+
├ chunks/pages/_app-9709623009fd94a5.js 25.8 kB
|
|
131
|
+
├ chunks/webpack-c56d30359092c45c.js 3.9 kB
|
|
138
132
|
└ css/0f070d03aacd9cc5.css 3.57 kB
|
|
139
133
|
|
|
140
134
|
λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
|
|
2
|
-
> @faststore/core@3.98.0-dev.
|
|
2
|
+
> @faststore/core@3.98.0-dev.6 test /home/runner/work/faststore/faststore/packages/core
|
|
3
3
|
> jest
|
|
4
4
|
|
|
5
|
-
PASS test/utils/multipleTemplates.test.ts (
|
|
6
|
-
PASS test/utils/clearCookies.test.ts (
|
|
7
|
-
PASS test/server/cms/global.test.ts
|
|
5
|
+
PASS test/utils/multipleTemplates.test.ts (27.088 s)
|
|
6
|
+
PASS test/utils/clearCookies.test.ts (27.484 s)
|
|
8
7
|
PASS test/utils/cookieCacheBusting.test.ts
|
|
8
|
+
PASS test/server/cms/global.test.ts
|
|
9
9
|
PASS test/server/cms/index.test.ts
|
|
10
|
-
PASS test/server/index.test.ts (
|
|
11
|
-
A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --detectOpenHandles to find leaks. Active timers can also cause this, ensure that .unref() was called on them.
|
|
10
|
+
PASS test/server/index.test.ts (31.032 s)
|
|
12
11
|
|
|
13
12
|
Test Suites: 6 passed, 6 total
|
|
14
13
|
Tests: 47 passed, 47 total
|
|
15
14
|
Snapshots: 0 total
|
|
16
|
-
Time:
|
|
15
|
+
Time: 32.089 s
|
|
17
16
|
Ran all test suites.
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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.98.0-dev.7](https://github.com/vtex/faststore/compare/v3.98.0-dev.6...v3.98.0-dev.7) (2026-03-26)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @faststore/core
|
|
9
|
+
|
|
10
|
+
# [3.98.0-dev.6](https://github.com/vtex/faststore/compare/v3.98.0-dev.5...v3.98.0-dev.6) (2026-03-24)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- enhance cache key management in useQuery ([#3230](https://github.com/vtex/faststore/issues/3230)) ([3f28502](https://github.com/vtex/faststore/commit/3f28502a8d381e476728661ea1150d0777ba87d1))
|
|
15
|
+
|
|
16
|
+
# [3.98.0-dev.5](https://github.com/vtex/faststore/compare/v3.98.0-dev.4...v3.98.0-dev.5) (2026-03-24)
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
- Add Webchat component and script integration + hCMS - SFS-3084 ([#3242](https://github.com/vtex/faststore/issues/3242)) ([04c3fbb](https://github.com/vtex/faststore/commit/04c3fbb91d028c5828998388105d327913194074))
|
|
21
|
+
|
|
6
22
|
# [3.98.0-dev.4](https://github.com/vtex/faststore/compare/v3.98.0-dev.3...v3.98.0-dev.4) (2026-03-23)
|
|
7
23
|
|
|
8
24
|
### Features
|
|
@@ -2546,5 +2546,15 @@
|
|
|
2546
2546
|
}
|
|
2547
2547
|
}
|
|
2548
2548
|
}
|
|
2549
|
+
},
|
|
2550
|
+
{
|
|
2551
|
+
"name": "ShoppingAssistant",
|
|
2552
|
+
"requiredScopes": [],
|
|
2553
|
+
"schema": {
|
|
2554
|
+
"title": "Shopping Assistant",
|
|
2555
|
+
"description": "To enable Shopping Assistant, make sure you have finished the setup at Agentic CX > Dashboard.",
|
|
2556
|
+
"type": "object",
|
|
2557
|
+
"properties": {}
|
|
2558
|
+
}
|
|
2549
2559
|
}
|
|
2550
2560
|
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/core",
|
|
3
|
-
"version": "3.98.0-dev.
|
|
3
|
+
"version": "3.98.0-dev.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
"fast-deep-equal": "^3.1.3",
|
|
86
86
|
"fs-extra": "^10.1.0",
|
|
87
87
|
"graphql": "^15.6.0",
|
|
88
|
+
"idb-keyval": "^5.1.3",
|
|
88
89
|
"include-media": "^1.4.10",
|
|
89
90
|
"isomorphic-unfetch": "^3.1.0",
|
|
90
91
|
"lexical": "^0.34.0",
|
|
@@ -123,5 +124,5 @@
|
|
|
123
124
|
"ts-jest": "29.1.1",
|
|
124
125
|
"typescript": "5.3.2"
|
|
125
126
|
},
|
|
126
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "e1ba23ab797254f3d2676d75db84b82649dcce87"
|
|
127
128
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { RefObject } from 'react'
|
|
2
|
+
import { useEffect } from 'react'
|
|
3
|
+
|
|
4
|
+
const SHOPPING_ASSISTANT_SCRIPT_URL = 'https://cdn.cloud.weni.ai/agentic-cx.js'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Injects the Shopping Assistant script when the hook runs, unless third-party scripts are disabled.
|
|
8
|
+
* @param containerRef - Optional ref to an HTMLElement. When provided, the script is appended inside this container (e.g. inside the ShoppingAssistant section). Otherwise the script is appended to document.head.
|
|
9
|
+
* Must be used in a component rendered in the body (not inside Next.js Head) so that useEffect runs on the client.
|
|
10
|
+
*/
|
|
11
|
+
export function useShoppingAssistant(
|
|
12
|
+
containerRef?: RefObject<HTMLElement | null>
|
|
13
|
+
): void {
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (process.env.DISABLE_3P_SCRIPTS) return
|
|
16
|
+
|
|
17
|
+
const script = document.createElement('script')
|
|
18
|
+
script.src = SHOPPING_ASSISTANT_SCRIPT_URL
|
|
19
|
+
const container = containerRef?.current
|
|
20
|
+
if (container) {
|
|
21
|
+
container.appendChild(script)
|
|
22
|
+
} else {
|
|
23
|
+
document.head.appendChild(script)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return () => {
|
|
27
|
+
script.remove()
|
|
28
|
+
}
|
|
29
|
+
}, [containerRef])
|
|
30
|
+
}
|
|
@@ -11,6 +11,7 @@ import storeConfig from '../../../../../discovery.config'
|
|
|
11
11
|
import { ProfileSummary } from '../ProfileSummary/ProfileSummary'
|
|
12
12
|
import { OrganizationDrawerBody } from './OrganizationDrawerBody'
|
|
13
13
|
import { OrganizationDrawerHeader } from './OrganizationDrawerHeader'
|
|
14
|
+
import { setReloadAfterLogoutReturn } from './useReloadAfterLogoutReturn'
|
|
14
15
|
import styles from './section.module.scss'
|
|
15
16
|
|
|
16
17
|
type OrganizationDrawerProps = {
|
|
@@ -27,6 +28,7 @@ const clearBrowserStorageForCurrentDomain = async () => {
|
|
|
27
28
|
const sessionStorageKeys = [
|
|
28
29
|
'faststore_session_ready',
|
|
29
30
|
'faststore_auth_cookie_value',
|
|
31
|
+
'faststore_person_id',
|
|
30
32
|
'faststore_cache_bust_last_value',
|
|
31
33
|
]
|
|
32
34
|
|
|
@@ -53,6 +55,25 @@ const clearBrowserStorageForCurrentDomain = async () => {
|
|
|
53
55
|
} catch {}
|
|
54
56
|
} catch {}
|
|
55
57
|
|
|
58
|
+
// Clear IndexedDB: remove session key first (avoids blocked when DB has open connections),
|
|
59
|
+
// then delete the whole keyval-store
|
|
60
|
+
try {
|
|
61
|
+
if ('indexedDB' in window) {
|
|
62
|
+
const { del } = await import('idb-keyval')
|
|
63
|
+
await del('fs::session').catch(() => {})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const idb = window.indexedDB
|
|
67
|
+
if (idb) {
|
|
68
|
+
await new Promise<void>((resolve) => {
|
|
69
|
+
const req = idb.deleteDatabase('keyval-store')
|
|
70
|
+
req.onsuccess = () => resolve()
|
|
71
|
+
req.onerror = () => resolve()
|
|
72
|
+
req.onblocked = () => resolve()
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
} catch {}
|
|
76
|
+
|
|
56
77
|
// Clear all cookies containing 'vtex' in the name (case-insensitive)
|
|
57
78
|
try {
|
|
58
79
|
const hostname = window.location.hostname
|
|
@@ -80,21 +101,6 @@ const clearBrowserStorageForCurrentDomain = async () => {
|
|
|
80
101
|
}
|
|
81
102
|
}
|
|
82
103
|
} catch {}
|
|
83
|
-
|
|
84
|
-
// Clear IndexedDB (keyval-store)
|
|
85
|
-
try {
|
|
86
|
-
if (!('indexedDB' in window)) return
|
|
87
|
-
|
|
88
|
-
const idb = window.indexedDB
|
|
89
|
-
if (!idb) return
|
|
90
|
-
|
|
91
|
-
await new Promise<void>((resolve) => {
|
|
92
|
-
const req = idb.deleteDatabase('keyval-store')
|
|
93
|
-
req.onsuccess = () => resolve()
|
|
94
|
-
req.onerror = () => resolve()
|
|
95
|
-
req.onblocked = () => resolve()
|
|
96
|
-
})
|
|
97
|
-
} catch {}
|
|
98
104
|
}
|
|
99
105
|
|
|
100
106
|
export const doLogout = async (_event?: unknown) => {
|
|
@@ -104,16 +110,19 @@ export const doLogout = async (_event?: unknown) => {
|
|
|
104
110
|
// Clear client-side storage (sessionStorage, localStorage, IndexedDB, non-HttpOnly cookies)
|
|
105
111
|
await clearBrowserStorageForCurrentDomain()
|
|
106
112
|
|
|
107
|
-
// Clear HttpOnly cookies via API endpoint (server-side)
|
|
113
|
+
// Clear HttpOnly cookies via API endpoint (server-side).
|
|
114
|
+
// Must await and consume the response so Set-Cookie headers are fully processed before redirect.
|
|
108
115
|
try {
|
|
109
|
-
await fetch('/api/fs/logout', {
|
|
116
|
+
const res = await fetch('/api/fs/logout', {
|
|
110
117
|
method: 'POST',
|
|
111
118
|
credentials: 'include',
|
|
112
119
|
})
|
|
120
|
+
await res.json().catch((): null => null)
|
|
113
121
|
} catch {
|
|
114
|
-
// Continue even if API call fails
|
|
122
|
+
// Continue even if API call fails (e.g. network error)
|
|
115
123
|
}
|
|
116
124
|
} finally {
|
|
125
|
+
setReloadAfterLogoutReturn()
|
|
117
126
|
window.location.assign(
|
|
118
127
|
`${storeConfig.secureSubdomain}/api/vtexid/pub/logout?scope=${storeConfig.api.storeId}&returnUrl=${storeConfig.storeUrl}`
|
|
119
128
|
)
|
package/src/components/account/MyAccountDrawer/OrganizationDrawer/useReloadAfterLogoutReturn.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* When the user logs out from the OrganizationDrawer, we redirect to VTEX ID logout
|
|
5
|
+
* and then return to the store. We need to reload so session-dependent data
|
|
6
|
+
* (e.g. ProductShelf) and caches are fresh. This module ties that reload to the drawer flow.
|
|
7
|
+
*
|
|
8
|
+
* The return can happen in two ways:
|
|
9
|
+
* 1) bfcache restore: user hits Back or browser restores from cache → pageshow with persisted=true
|
|
10
|
+
* 2) Fresh load: VTEX ID redirects back → new navigation, persisted=false
|
|
11
|
+
*
|
|
12
|
+
* We handle both: check the flag on mount (fresh load) and on pageshow (bfcache).
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const RELOAD_AFTER_LOGOUT_KEY = 'faststore_reload_after_logout_return'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Call before redirecting to logout. When the user returns to the store, the app
|
|
19
|
+
* will reload once so session state and caches are fresh.
|
|
20
|
+
*/
|
|
21
|
+
export const setReloadAfterLogoutReturn = (): void => {
|
|
22
|
+
if (typeof sessionStorage === 'undefined') return
|
|
23
|
+
try {
|
|
24
|
+
sessionStorage.setItem(RELOAD_AFTER_LOGOUT_KEY, '1')
|
|
25
|
+
} catch {
|
|
26
|
+
// Ignore
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const RELOAD_DELAY_MS = 1000
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Forces a full navigation with cache-busting param instead of reload().
|
|
34
|
+
* Bypasses disk cache by changing the URL, ensuring fresh HTML and API responses.
|
|
35
|
+
*/
|
|
36
|
+
const forceRefreshWithoutCache = (): void => {
|
|
37
|
+
const url = new URL(window.location.href)
|
|
38
|
+
url.searchParams.set('_', Date.now().toString())
|
|
39
|
+
window.location.replace(url.toString())
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const checkAndReloadIfReturnedFromLogout = (): void => {
|
|
43
|
+
try {
|
|
44
|
+
if (sessionStorage.getItem(RELOAD_AFTER_LOGOUT_KEY)) {
|
|
45
|
+
sessionStorage.removeItem(RELOAD_AFTER_LOGOUT_KEY)
|
|
46
|
+
setTimeout(forceRefreshWithoutCache, RELOAD_DELAY_MS)
|
|
47
|
+
}
|
|
48
|
+
} catch {
|
|
49
|
+
// Ignore.
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Hook to use in _app. Ensures a full reload when the user returns from logout
|
|
55
|
+
* (either via bfcache or fresh redirect), so data matches the new session.
|
|
56
|
+
*/
|
|
57
|
+
export const useReloadAfterLogoutReturn = (): void => {
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (typeof window === 'undefined') return
|
|
60
|
+
|
|
61
|
+
// 1) On mount: handles fresh load return (VTEX ID redirect). pageshow with persisted=false
|
|
62
|
+
// means we never get the event for that case, so we must check here.
|
|
63
|
+
checkAndReloadIfReturnedFromLogout()
|
|
64
|
+
|
|
65
|
+
// 2) On pageshow with persisted: handles bfcache restore
|
|
66
|
+
const onPageShow = (event: PageTransitionEvent) => {
|
|
67
|
+
if (event.persisted) {
|
|
68
|
+
checkAndReloadIfReturnedFromLogout()
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
window.addEventListener('pageshow', onPageShow)
|
|
73
|
+
return () => window.removeEventListener('pageshow', onPageShow)
|
|
74
|
+
}, [])
|
|
75
|
+
}
|
|
@@ -36,6 +36,13 @@ const RegionSlider = dynamic(
|
|
|
36
36
|
),
|
|
37
37
|
{ ssr: false }
|
|
38
38
|
)
|
|
39
|
+
const ShoppingAssistant = dynamic(
|
|
40
|
+
() =>
|
|
41
|
+
import(
|
|
42
|
+
/* webpackChunkName: "ShoppingAssistant" */ 'src/components/sections/ShoppingAssistant'
|
|
43
|
+
),
|
|
44
|
+
{ ssr: false }
|
|
45
|
+
)
|
|
39
46
|
|
|
40
47
|
const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
41
48
|
[getComponentKey(Alert, 'Alert')]: Alert,
|
|
@@ -46,6 +53,7 @@ const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
|
46
53
|
[getComponentKey(RegionModal, 'RegionModal')]: RegionModal, // out of viewport
|
|
47
54
|
[getComponentKey(RegionSlider, 'RegionSlider')]: RegionSlider, // out of viewport
|
|
48
55
|
[getComponentKey(Footer, 'Footer')]: Footer, // out of viewport
|
|
56
|
+
[getComponentKey(ShoppingAssistant, 'ShoppingAssistant')]: ShoppingAssistant,
|
|
49
57
|
...PLUGINS_COMPONENTS,
|
|
50
58
|
...CUSTOM_COMPONENTS,
|
|
51
59
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import { useShoppingAssistant } from 'src/components/ThirdPartyScripts'
|
|
4
|
+
|
|
5
|
+
import Section from '../Section'
|
|
6
|
+
|
|
7
|
+
import styles from './section.module.scss'
|
|
8
|
+
|
|
9
|
+
const ShoppingAssistant = () => {
|
|
10
|
+
const scriptContainerRef = useRef<HTMLDivElement>(null)
|
|
11
|
+
useShoppingAssistant(scriptContainerRef)
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<Section
|
|
15
|
+
className={`${styles.section} section-shopping-assistant layout__section`}
|
|
16
|
+
>
|
|
17
|
+
<div ref={scriptContainerRef} aria-hidden="true" hidden />
|
|
18
|
+
</Section>
|
|
19
|
+
)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
ShoppingAssistant.$componentKey = 'ShoppingAssistant'
|
|
23
|
+
|
|
24
|
+
export default ShoppingAssistant
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ShoppingAssistant'
|
package/src/pages/_app.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import { useRouter } from 'next/router'
|
|
|
6
6
|
import { useSearch } from '@faststore/sdk'
|
|
7
7
|
import { UIProvider } from '@faststore/ui'
|
|
8
8
|
|
|
9
|
+
import { useReloadAfterLogoutReturn } from 'src/components/account/MyAccountDrawer/OrganizationDrawer/useReloadAfterLogoutReturn'
|
|
9
10
|
import ThirdPartyScripts from 'src/components/ThirdPartyScripts'
|
|
10
11
|
import Layout from 'src/Layout'
|
|
11
12
|
import AnalyticsHandler from 'src/sdk/analytics'
|
|
@@ -24,6 +25,7 @@ import { ITEMS_PER_PAGE } from 'src/constants'
|
|
|
24
25
|
|
|
25
26
|
function App({ Component, pageProps }: AppProps) {
|
|
26
27
|
useGeolocation()
|
|
28
|
+
useReloadAfterLogoutReturn()
|
|
27
29
|
storeConfig.experimental?.scrollRestoration && useScrollRestoration()
|
|
28
30
|
const router = useRouter()
|
|
29
31
|
const { start: startGlobalSearchState } = useSearch()
|
|
@@ -29,7 +29,7 @@ export const request = async <Query = unknown, Variables = unknown>(
|
|
|
29
29
|
variables: Variables,
|
|
30
30
|
options?: RequestOptions
|
|
31
31
|
) => {
|
|
32
|
-
// Get cache busting value based
|
|
32
|
+
// Get cache busting value based person?.id from session
|
|
33
33
|
const value = getClientCacheBustingValue()
|
|
34
34
|
|
|
35
35
|
const { data, errors } = await baseRequest<Variables, Query>('/api/graphql', {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import useSWR from 'swr'
|
|
2
1
|
import type { SWRConfiguration } from 'swr'
|
|
2
|
+
import useSWR from 'swr'
|
|
3
|
+
|
|
4
|
+
import { getClientCacheBustingValue } from 'src/utils/cookieCacheBusting'
|
|
3
5
|
|
|
4
|
-
import { request } from './request'
|
|
5
6
|
import type { Operation, RequestOptions } from './request'
|
|
7
|
+
import { request } from './request'
|
|
6
8
|
|
|
7
9
|
export type QueryOptions = SWRConfiguration &
|
|
8
10
|
RequestOptions & { doNotRun?: boolean }
|
|
@@ -12,6 +14,19 @@ export const getKey = <Variables>(
|
|
|
12
14
|
variables: Variables
|
|
13
15
|
) => `${operationName}::${JSON.stringify(variables)}`
|
|
14
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Returns a suffix for the cache key based on auth state (logged-in vs anonymous).
|
|
19
|
+
* This ensures SWR keeps separate cache entries for logged-in and logged-out users,
|
|
20
|
+
* avoiding stale product data (e.g. prices, availability) when switching session state.
|
|
21
|
+
*/
|
|
22
|
+
const getSessionCacheKeySuffix = (): string => {
|
|
23
|
+
if (typeof window === 'undefined') {
|
|
24
|
+
return ''
|
|
25
|
+
}
|
|
26
|
+
const value = getClientCacheBustingValue()
|
|
27
|
+
return value ?? ''
|
|
28
|
+
}
|
|
29
|
+
|
|
15
30
|
export const DEFAULT_OPTIONS = {
|
|
16
31
|
errorRetryCount: 3,
|
|
17
32
|
refreshWhenHidden: false,
|
|
@@ -27,10 +42,12 @@ export const useQuery = <Data, Variables = Record<string, unknown>>(
|
|
|
27
42
|
options?: QueryOptions
|
|
28
43
|
) =>
|
|
29
44
|
useSWR<Data>(
|
|
30
|
-
() =>
|
|
31
|
-
options?.doNotRun
|
|
32
|
-
|
|
33
|
-
|
|
45
|
+
() => {
|
|
46
|
+
if (options?.doNotRun) return null
|
|
47
|
+
const baseKey = getKey(operation['__meta__']['operationName'], variables)
|
|
48
|
+
const sessionSuffix = getSessionCacheKeySuffix()
|
|
49
|
+
return `${baseKey}::${sessionSuffix}`
|
|
50
|
+
},
|
|
34
51
|
{
|
|
35
52
|
fetcher: () => {
|
|
36
53
|
return new Promise((resolve) => {
|