@faststore/core 2.2.0-alpha.2 → 2.2.0-alpha.4

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 (169) hide show
  1. package/.next/BUILD_ID +1 -0
  2. package/.next/build-manifest.json +129 -0
  3. package/.next/cache/.tsbuildinfo +1 -0
  4. package/.next/cache/config.json +7 -0
  5. package/.next/cache/eslint/.cache_1gneedd +1 -0
  6. package/.next/cache/next-server.js.nft.json +1 -0
  7. package/.next/cache/webpack/client-production/0.pack +0 -0
  8. package/.next/cache/webpack/client-production/index.pack +0 -0
  9. package/.next/cache/webpack/server-production/0.pack +0 -0
  10. package/.next/cache/webpack/server-production/index.pack +0 -0
  11. package/.next/export-marker.json +1 -0
  12. package/.next/images-manifest.json +1 -0
  13. package/.next/next-server.js.nft.json +1 -0
  14. package/.next/package.json +1 -0
  15. package/.next/prerender-manifest.json +1 -0
  16. package/.next/react-loadable-manifest.json +44 -0
  17. package/.next/required-server-files.json +1 -0
  18. package/.next/routes-manifest.json +1 -0
  19. package/.next/server/chunks/112.js +2078 -0
  20. package/.next/server/chunks/177.js +120 -0
  21. package/.next/server/chunks/183.js +94 -0
  22. package/.next/server/chunks/184.js +61 -0
  23. package/.next/server/chunks/186.js +113 -0
  24. package/.next/server/chunks/289.js +242 -0
  25. package/.next/server/chunks/312.js +697 -0
  26. package/.next/server/chunks/350.js +200 -0
  27. package/.next/server/chunks/483.js +651 -0
  28. package/.next/server/chunks/52.js +4007 -0
  29. package/.next/server/chunks/53.js +61 -0
  30. package/.next/server/chunks/530.js +626 -0
  31. package/.next/server/chunks/574.js +145 -0
  32. package/.next/server/chunks/576.js +94 -0
  33. package/.next/server/chunks/647.js +437 -0
  34. package/.next/server/chunks/676.js +32 -0
  35. package/.next/server/chunks/693.js +58 -0
  36. package/.next/server/chunks/71.js +1294 -0
  37. package/.next/server/chunks/74.js +4084 -0
  38. package/.next/server/chunks/753.js +554 -0
  39. package/.next/server/chunks/779.js +58 -0
  40. package/.next/server/chunks/817.js +4007 -0
  41. package/.next/server/chunks/825.js +4039 -0
  42. package/.next/server/chunks/854.js +72 -0
  43. package/.next/server/chunks/859.js +959 -0
  44. package/.next/server/chunks/98.js +163 -0
  45. package/.next/server/chunks/988.js +211 -0
  46. package/.next/server/chunks/font-manifest.json +1 -0
  47. package/.next/server/font-manifest.json +1 -0
  48. package/.next/server/middleware-build-manifest.js +1 -0
  49. package/.next/server/middleware-manifest.json +6 -0
  50. package/.next/server/middleware-react-loadable-manifest.js +1 -0
  51. package/.next/server/pages/404.js +386 -0
  52. package/.next/server/pages/404.js.nft.json +1 -0
  53. package/.next/server/pages/500.js +388 -0
  54. package/.next/server/pages/500.js.nft.json +1 -0
  55. package/.next/server/pages/[...slug].js +1128 -0
  56. package/.next/server/pages/[...slug].js.nft.json +1 -0
  57. package/.next/server/pages/[slug]/p.js +2271 -0
  58. package/.next/server/pages/[slug]/p.js.nft.json +1 -0
  59. package/.next/server/pages/_app.js +280 -0
  60. package/.next/server/pages/_app.js.nft.json +1 -0
  61. package/.next/server/pages/_document.js +374 -0
  62. package/.next/server/pages/_document.js.nft.json +1 -0
  63. package/.next/server/pages/_error.js +164 -0
  64. package/.next/server/pages/_error.js.nft.json +1 -0
  65. package/.next/server/pages/account.js +363 -0
  66. package/.next/server/pages/account.js.nft.json +1 -0
  67. package/.next/server/pages/api/graphql.js +450 -0
  68. package/.next/server/pages/api/graphql.js.nft.json +1 -0
  69. package/.next/server/pages/api/health/live.js +31 -0
  70. package/.next/server/pages/api/health/live.js.nft.json +1 -0
  71. package/.next/server/pages/api/health/ready.js +31 -0
  72. package/.next/server/pages/api/health/ready.js.nft.json +1 -0
  73. package/.next/server/pages/api/preview.js +148 -0
  74. package/.next/server/pages/api/preview.js.nft.json +1 -0
  75. package/.next/server/pages/checkout.js +363 -0
  76. package/.next/server/pages/checkout.js.nft.json +1 -0
  77. package/.next/server/pages/en-US/404.html +81 -0
  78. package/.next/server/pages/en-US/404.json +1 -0
  79. package/.next/server/pages/en-US/500.html +81 -0
  80. package/.next/server/pages/en-US/500.json +1 -0
  81. package/.next/server/pages/en-US/account.html +81 -0
  82. package/.next/server/pages/en-US/account.json +1 -0
  83. package/.next/server/pages/en-US/checkout.html +81 -0
  84. package/.next/server/pages/en-US/checkout.json +1 -0
  85. package/.next/server/pages/en-US/login.html +81 -0
  86. package/.next/server/pages/en-US/login.json +1 -0
  87. package/.next/server/pages/en-US/s.html +81 -0
  88. package/.next/server/pages/en-US/s.json +1 -0
  89. package/.next/server/pages/en-US.html +81 -0
  90. package/.next/server/pages/en-US.json +1 -0
  91. package/.next/server/pages/index.js +439 -0
  92. package/.next/server/pages/index.js.nft.json +1 -0
  93. package/.next/server/pages/login.js +368 -0
  94. package/.next/server/pages/login.js.nft.json +1 -0
  95. package/.next/server/pages/s.js +548 -0
  96. package/.next/server/pages/s.js.nft.json +1 -0
  97. package/.next/server/pages-manifest.json +18 -0
  98. package/.next/server/webpack-api-runtime.js +229 -0
  99. package/.next/server/webpack-runtime.js +229 -0
  100. package/.next/static/Piv80SwIkzuCeXWq6ayXm/_buildManifest.js +1 -0
  101. package/.next/static/Piv80SwIkzuCeXWq6ayXm/_ssgManifest.js +1 -0
  102. package/.next/static/chunks/148.582eaa81293ee470.js +1 -0
  103. package/.next/static/chunks/238-cc3cce1c586338ad.js +1 -0
  104. package/.next/static/chunks/243-3d6b4b3a366e19c2.js +1 -0
  105. package/.next/static/chunks/530.ec68de379130c11e.js +1 -0
  106. package/.next/static/chunks/548-4ee971bf7bdb3e81.js +1 -0
  107. package/.next/static/chunks/574.70612be06fd1365f.js +1 -0
  108. package/.next/static/chunks/651.7142f31ce1e052b3.js +1 -0
  109. package/.next/static/chunks/709.daf1eddebf1e7952.js +1 -0
  110. package/.next/static/chunks/738-a5ff304828f20cbf.js +1 -0
  111. package/.next/static/chunks/741.52f7fb873418346f.js +1 -0
  112. package/.next/static/chunks/932-f3b8452686f38109.js +1 -0
  113. package/.next/static/chunks/98.40c7e17d9de4eb8f.js +1 -0
  114. package/.next/static/chunks/988.afda042dd9ba11d1.js +1 -0
  115. package/.next/static/chunks/framework-dfd14d7ce6600b03.js +1 -0
  116. package/.next/static/chunks/main-fd466221927468fd.js +1 -0
  117. package/.next/static/chunks/pages/404-af78f7cd1d3c1f60.js +1 -0
  118. package/.next/static/chunks/pages/500-f6346ca5f9dc4fef.js +1 -0
  119. package/.next/static/chunks/pages/[...slug]-0ac7c3d2aed38670.js +1 -0
  120. package/.next/static/chunks/pages/[slug]/p-f2316527aa17d525.js +1 -0
  121. package/.next/static/chunks/pages/_app-6d0e6ab9a4dd8106.js +1 -0
  122. package/.next/static/chunks/pages/_error-a7a0c1d9bfbb4f38.js +1 -0
  123. package/.next/static/chunks/pages/account-05bd79fb78365e88.js +1 -0
  124. package/.next/static/chunks/pages/checkout-c973786e68f25a39.js +1 -0
  125. package/.next/static/chunks/pages/index-ae164b770dd07875.js +1 -0
  126. package/.next/static/chunks/pages/login-8deb9243376b6aa1.js +1 -0
  127. package/.next/static/chunks/pages/s-b7aff694059d908d.js +1 -0
  128. package/.next/static/chunks/polyfills-c67a75d1b6f99dc8.js +1 -0
  129. package/.next/static/chunks/webpack-70a459a1a7205194.js +1 -0
  130. package/.next/static/css/373ae96b742c3694.css +1 -0
  131. package/.next/static/css/527e334fa69cf40a.css +1 -0
  132. package/.next/static/css/6e1a7434f061d0ef.css +1 -0
  133. package/.next/static/css/7ca374e5534a3f68.css +1 -0
  134. package/.next/static/css/9e76fef1c9ca89af.css +1 -0
  135. package/.next/static/css/a2eefb25a4608343.css +1 -0
  136. package/.next/static/css/cb7d1fcea42fab9c.css +1 -0
  137. package/.next/static/css/df588bb98c0b0ca6.css +1 -0
  138. package/.next/static/css/e3b039e8f5daf95f.css +1 -0
  139. package/.next/static/css/f0e2d1b8832e935d.css +1 -0
  140. package/.next/trace +80 -0
  141. package/.turbo/turbo-build.log +6 -6
  142. package/.turbo/turbo-test.log +9 -9
  143. package/@generated/graphql/index.ts +8 -0
  144. package/@generated/graphql/persisted.json +2 -2
  145. package/cms/faststore/sections.json +12 -0
  146. package/package.json +7 -5
  147. package/public/~partytown/debug/partytown-atomics.js +556 -0
  148. package/public/~partytown/debug/partytown-media.js +374 -0
  149. package/public/~partytown/debug/partytown-sandbox-sw.js +543 -0
  150. package/public/~partytown/debug/partytown-sw.js +59 -0
  151. package/public/~partytown/debug/partytown-ww-atomics.js +1789 -0
  152. package/public/~partytown/debug/partytown-ww-sw.js +1781 -0
  153. package/public/~partytown/debug/partytown.js +72 -0
  154. package/public/~partytown/partytown-atomics.js +2 -0
  155. package/public/~partytown/partytown-media.js +2 -0
  156. package/public/~partytown/partytown-sw.js +2 -0
  157. package/public/~partytown/partytown.js +2 -0
  158. package/src/components/sections/ProductDetails/Overrides.tsx +4 -4
  159. package/src/components/sections/ProductDetails/ProductDetails.tsx +5 -0
  160. package/src/components/ui/ImageGallery/ImageGallery.tsx +13 -6
  161. package/src/components/ui/ProductDetails/ProductDetailsSettings.tsx +42 -23
  162. package/src/pages/[...slug].tsx +4 -2
  163. package/src/sdk/analytics/platform/vtex/search.ts +53 -21
  164. package/src/sdk/analytics/types.ts +14 -0
  165. package/src/sdk/product/useProductGalleryQuery.ts +32 -3
  166. package/src/sdk/search/useSuggestions.ts +41 -7
  167. package/src/server/generator/schema.ts +2 -1
  168. package/src/typings/overrides.ts +5 -2
  169. package/generate.sh +0 -71
@@ -1,17 +1,26 @@
1
+ import { sendAnalyticsEvent } from '@faststore/sdk'
1
2
  import { gql } from '@faststore/graphql-utils'
2
3
 
4
+ import { useQuery } from 'src/sdk/graphql/useQuery'
5
+ import { useLocalizedVariables } from './useLocalizedVariables'
6
+ import { useSession } from 'src/sdk/session'
7
+
3
8
  import type {
4
9
  ClientProductGalleryQueryQuery as Query,
5
10
  ClientProductGalleryQueryQueryVariables as Variables,
6
11
  } from '@generated/graphql'
7
- import { useQuery } from 'src/sdk/graphql/useQuery'
8
- import { useLocalizedVariables } from './useLocalizedVariables'
12
+ import type { IntelligentSearchQueryEvent } from 'src/sdk/analytics/types'
9
13
 
10
14
  /**
11
15
  * This query is run on the browser and contains
12
16
  * the current search state of the user
13
17
  */
14
18
  export const query = gql`
19
+ fragment SearchEvent_metadata on SearchMetadata {
20
+ isTermMisspelled
21
+ logicalOperator
22
+ }
23
+
15
24
  query ClientProductGalleryQuery(
16
25
  $first: Int!
17
26
  $after: String!
@@ -35,6 +44,9 @@ export const query = gql`
35
44
  facets {
36
45
  ...Filter_facets
37
46
  }
47
+ metadata {
48
+ ...SearchEvent_metadata
49
+ }
38
50
  }
39
51
  }
40
52
  `
@@ -45,6 +57,7 @@ export const useProductGalleryQuery = ({
45
57
  selectedFacets,
46
58
  itemsPerPage,
47
59
  }) => {
60
+ const { locale } = useSession()
48
61
  const localizedVariables = useLocalizedVariables({
49
62
  first: itemsPerPage,
50
63
  after: '0',
@@ -53,5 +66,21 @@ export const useProductGalleryQuery = ({
53
66
  selectedFacets,
54
67
  })
55
68
 
56
- return useQuery<Query, Variables>(query, localizedVariables)
69
+ return useQuery<Query, Variables>(query, localizedVariables, {
70
+ onSuccess: (data) => {
71
+ if (data && term) {
72
+ sendAnalyticsEvent<IntelligentSearchQueryEvent>({
73
+ name: 'intelligent_search_query',
74
+ params: {
75
+ locale,
76
+ term,
77
+ url: window.location.href,
78
+ logicalOperator: data.search.metadata?.logicalOperator ?? 'and',
79
+ isTermMisspelled: data.search.metadata?.isTermMisspelled ?? false,
80
+ totalCount: data.search.products.pageInfo.totalCount,
81
+ },
82
+ })
83
+ }
84
+ },
85
+ })
57
86
  }
@@ -1,10 +1,14 @@
1
- import { gql } from '@faststore/graphql-utils'
1
+ import { useMemo } from 'react'
2
2
 
3
+ import { sendAnalyticsEvent } from '@faststore/sdk'
4
+ import { gql } from '@faststore/graphql-utils'
3
5
  import { useQuery } from 'src/sdk/graphql/useQuery'
6
+
4
7
  import type {
5
8
  SearchSuggestionsQueryQuery as Query,
6
9
  SearchSuggestionsQueryQueryVariables as Variables,
7
10
  } from '@generated/graphql'
11
+ import type { IntelligentSearchQueryEvent } from '../analytics/types'
8
12
 
9
13
  import { useSession } from '../session'
10
14
 
@@ -24,6 +28,14 @@ const query = gql`
24
28
  ...ProductSummary_product
25
29
  }
26
30
  }
31
+ products {
32
+ pageInfo {
33
+ totalCount
34
+ }
35
+ }
36
+ metadata {
37
+ ...SearchEvent_metadata
38
+ }
27
39
  }
28
40
  }
29
41
  `
@@ -31,12 +43,34 @@ const query = gql`
31
43
  function useSuggestions(term: string, limit: number = MAX_SUGGESTIONS) {
32
44
  const { channel, locale } = useSession()
33
45
 
34
- const { data, error } = useQuery<Query, Variables>(query, {
35
- term,
36
- selectedFacets: [
37
- { key: 'channel', value: channel ?? '' },
38
- { key: 'locale', value: locale },
39
- ],
46
+ const variables = useMemo(
47
+ () => ({
48
+ term,
49
+ selectedFacets: [
50
+ { key: 'channel', value: channel ?? '' },
51
+ { key: 'locale', value: locale },
52
+ ],
53
+ }),
54
+ [term, locale, channel]
55
+ )
56
+ const { data, error } = useQuery<Query, Variables>(query, variables, {
57
+ onSuccess: (callbackData) => {
58
+ if (callbackData && term) {
59
+ sendAnalyticsEvent<IntelligentSearchQueryEvent>({
60
+ name: 'intelligent_search_query',
61
+ params: {
62
+ locale,
63
+ term,
64
+ url: window.location.href,
65
+ logicalOperator:
66
+ callbackData.search.metadata?.logicalOperator ?? 'and',
67
+ isTermMisspelled:
68
+ callbackData.search.metadata?.isTermMisspelled ?? false,
69
+ totalCount: callbackData.search.products.pageInfo.totalCount,
70
+ },
71
+ })
72
+ }
73
+ },
40
74
  })
41
75
 
42
76
  return {
@@ -1,3 +1,4 @@
1
+ import path from 'path'
1
2
  import { writeFileSync } from 'fs-extra'
2
3
  import { getSchema, getTypeDefs } from '@faststore/api'
3
4
  import { printSchemaWithDirectives } from '@graphql-tools/utils'
@@ -69,7 +70,7 @@ export const getMergedSchema = (): GraphQLSchema =>
69
70
  export function writeGraphqlSchemaFile(apiSchema: GraphQLSchema) {
70
71
  try {
71
72
  writeFileSync(
72
- [process.cwd(), '@generated', 'graphql', 'schema.graphql'].join('/'),
73
+ path.join(process.cwd(), '@generated', 'graphql', 'schema.graphql'),
73
74
  printSchemaWithDirectives(apiSchema)
74
75
  )
75
76
 
@@ -13,7 +13,7 @@ import type {
13
13
  IconButtonProps,
14
14
  IconProps,
15
15
  ImageGalleryProps,
16
- ImageZoomProps,
16
+ ImageGalleryViewerProps,
17
17
  InputFieldProps,
18
18
  LinkButtonProps,
19
19
  NavbarButtonsProps,
@@ -197,7 +197,10 @@ export type ProductDetailsOverrideDefinition = SectionOverrideDefinition<
197
197
  ImageGalleryProps,
198
198
  ImageGalleryProps
199
199
  >
200
- ImageZoom: ComponentOverrideDefinition<ImageZoomProps, ImageZoomProps>
200
+ ImageGalleryViewer: ComponentOverrideDefinition<
201
+ ImageGalleryViewerProps,
202
+ ImageGalleryViewerProps
203
+ >
201
204
  __experimentalImageGalleryImage: ComponentOverrideDefinition<any, any>
202
205
  __experimentalImageGallery: ComponentOverrideDefinition<any, any>
203
206
  __experimentalShippingSimulation: ComponentOverrideDefinition<any, any>
package/generate.sh DELETED
@@ -1,71 +0,0 @@
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 "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
-
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}"