From 8ee5eff9a5f6572bbfa772dbad3f8a99835a2070 Mon Sep 17 00:00:00 2001 From: Lucas Vyskubenko Date: Wed, 14 Aug 2024 16:16:31 -0300 Subject: [PATCH 001/154] test: return values in resolver --- packages/api/src/__generated__/schema.ts | 2 ++ packages/api/src/platforms/vtex/resolvers/product.ts | 3 ++- packages/api/src/typeDefs/product.graphql | 4 ++++ packages/core/@generated/graphql.ts | 2 ++ packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts | 2 ++ 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/api/src/__generated__/schema.ts b/packages/api/src/__generated__/schema.ts index d7d15951a0..756eaf4fc9 100644 --- a/packages/api/src/__generated__/schema.ts +++ b/packages/api/src/__generated__/schema.ts @@ -952,6 +952,8 @@ export type StoreProduct = { brand: StoreBrand; /** List of items consisting of chain linked web pages, ending with the current page. */ breadcrumbList: StoreBreadcrumbList; + /** Product categories. */ + categoryId: Scalars['String']; /** Product description. */ description: Scalars['String']; /** Global Trade Item Number. */ diff --git a/packages/api/src/platforms/vtex/resolvers/product.ts b/packages/api/src/platforms/vtex/resolvers/product.ts index db945e61f9..589d4e1418 100644 --- a/packages/api/src/platforms/vtex/resolvers/product.ts +++ b/packages/api/src/platforms/vtex/resolvers/product.ts @@ -44,7 +44,8 @@ export const StoreProduct: Record> & { image: Resolver } = { - productID: ({ itemId }) => itemId, + productID: ({ itemId }) => itemId+`@44444444`, + categoryId: ({ isVariantOf: { categoryId }}) => categoryId, name: ({ isVariantOf, name }) => name ?? isVariantOf.productName, slug: ({ isVariantOf: { linkText }, itemId }) => getSlug(linkText, itemId), description: ({ isVariantOf: { description } }) => description, diff --git a/packages/api/src/typeDefs/product.graphql b/packages/api/src/typeDefs/product.graphql index 1fb4613112..426d471aa5 100644 --- a/packages/api/src/typeDefs/product.graphql +++ b/packages/api/src/typeDefs/product.graphql @@ -31,6 +31,10 @@ type StoreProduct { """ description: String! """ + Product categories. + """ + categoryId: String! + """ Array of images. """ image(context: String = "generic", limit: Int = -1): [StoreImage!]! diff --git a/packages/core/@generated/graphql.ts b/packages/core/@generated/graphql.ts index 12eed73925..ea78c8d6b6 100644 --- a/packages/core/@generated/graphql.ts +++ b/packages/core/@generated/graphql.ts @@ -909,6 +909,8 @@ export type StoreProduct = { brand: StoreBrand /** List of items consisting of chain linked web pages, ending with the current page. */ breadcrumbList: StoreBreadcrumbList + /** Product categories. */ + categoryId: Scalars['String']['output'] /** Product description. */ description: Scalars['String']['output'] /** Global Trade Item Number. */ diff --git a/packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts b/packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts index f2afd30484..a0dfc1244e 100644 --- a/packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts +++ b/packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts @@ -24,6 +24,8 @@ export const useViewItemListEvent = ({ currency: { code }, } = useSession() + console.log(`products33333`, products) + const sendViewItemListEvent = useCallback(() => { sendAnalyticsEvent>({ name: 'view_item_list', From 3f3cc71e0cffecde71d8df95f73ee86a44e88c52 Mon Sep 17 00:00:00 2001 From: Lucas Vyskubenko Date: Wed, 14 Aug 2024 17:00:15 -0300 Subject: [PATCH 002/154] test: add in the gph --- packages/core/@generated/gql.ts | 4 ++-- packages/core/@generated/graphql.ts | 8 ++++++-- .../components/sections/ProductDetails/ProductDetails.tsx | 2 ++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/core/@generated/gql.ts b/packages/core/@generated/gql.ts index e1340dcce6..6ba3337543 100644 --- a/packages/core/@generated/gql.ts +++ b/packages/core/@generated/gql.ts @@ -16,7 +16,7 @@ const documents = { types.ProductSummary_ProductFragmentDoc, '\n fragment Filter_facets on StoreFacet {\n ... on StoreFacetRange {\n key\n label\n\n min {\n selected\n absolute\n }\n\n max {\n selected\n absolute\n }\n\n __typename\n }\n ... on StoreFacetBoolean {\n key\n label\n values {\n label\n value\n selected\n quantity\n }\n\n __typename\n }\n }\n': types.Filter_FacetsFragmentDoc, - '\n fragment ProductDetailsFragment_product on StoreProduct {\n id: productID\n sku\n name\n gtin\n description\n unitMultiplier\n isVariantOf {\n name\n productGroupID\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n # Contains necessary info to add this item to cart\n ...CartProductItem\n }\n': + '\n fragment ProductDetailsFragment_product on StoreProduct {\n id: productID\n sku\n name\n gtin\n categoryId\n\n description\n unitMultiplier\n isVariantOf {\n name\n productGroupID\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n # Contains necessary info to add this item to cart\n ...CartProductItem\n }\n': types.ProductDetailsFragment_ProductFragmentDoc, '\n fragment ClientManyProducts on Query {\n search(\n first: $first\n after: $after\n sort: $sort\n term: $term\n selectedFacets: $selectedFacets\n ) {\n products {\n pageInfo {\n totalCount\n }\n }\n }\n }\n': types.ClientManyProductsFragmentDoc, @@ -76,7 +76,7 @@ export function gql( * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function gql( - source: '\n fragment ProductDetailsFragment_product on StoreProduct {\n id: productID\n sku\n name\n gtin\n description\n unitMultiplier\n isVariantOf {\n name\n productGroupID\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n # Contains necessary info to add this item to cart\n ...CartProductItem\n }\n' + source: '\n fragment ProductDetailsFragment_product on StoreProduct {\n id: productID\n sku\n name\n gtin\n categoryId\n\n description\n unitMultiplier\n isVariantOf {\n name\n productGroupID\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n # Contains necessary info to add this item to cart\n ...CartProductItem\n }\n' ): typeof import('./graphql').ProductDetailsFragment_ProductFragmentDoc /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. diff --git a/packages/core/@generated/graphql.ts b/packages/core/@generated/graphql.ts index ea78c8d6b6..cb5bc7889d 100644 --- a/packages/core/@generated/graphql.ts +++ b/packages/core/@generated/graphql.ts @@ -1157,6 +1157,7 @@ export type ProductDetailsFragment_ProductFragment = { sku: string name: string gtin: string + categoryId: string description: string unitMultiplier: number | null id: string @@ -1243,6 +1244,7 @@ export type ServerProductQueryQuery = { name: string description: string releaseDate: string + categoryId: string unitMultiplier: number | null id: string seo: { title: string; description: string; canonical: string } @@ -1498,6 +1500,7 @@ export type ClientProductQueryQuery = { sku: string name: string gtin: string + categoryId: string description: string unitMultiplier: number | null id: string @@ -1779,6 +1782,7 @@ export const ProductDetailsFragment_ProductFragmentDoc = sku name gtin + categoryId description unitMultiplier isVariantOf { @@ -2038,7 +2042,7 @@ export const ServerCollectionPageQueryDocument = { export const ServerProductQueryDocument = { __meta__: { operationName: 'ServerProductQuery', - operationHash: '46103bee661405bde706d72126fdbf9b0a0c9e6e', + operationHash: '517b4ec34753b76b9fca9e72f6ce0a9427d22a05', }, } as unknown as TypedDocumentString< ServerProductQueryQuery, @@ -2083,7 +2087,7 @@ export const ClientProductGalleryQueryDocument = { export const ClientProductQueryDocument = { __meta__: { operationName: 'ClientProductQuery', - operationHash: '7d121ef8d4dc99174e64e4429a9b977b8bbebed8', + operationHash: '5839f2e715b02f93045c3aa76993ec1072e33f63', }, } as unknown as TypedDocumentString< ClientProductQueryQuery, diff --git a/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx b/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx index 62e262b11a..030ffb4cd1 100644 --- a/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx +++ b/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx @@ -271,6 +271,8 @@ export const fragment = gql(` sku name gtin + categoryId + description unitMultiplier isVariantOf { From f0ede4175928d31b1dcab04af08c6b3850e14dcd Mon Sep 17 00:00:00 2001 From: Lucas Vyskubenko Date: Wed, 14 Aug 2024 17:15:55 -0300 Subject: [PATCH 003/154] test: returning category id --- packages/api/src/platforms/vtex/resolvers/product.ts | 2 +- packages/core/@generated/gql.ts | 4 ++-- packages/core/@generated/graphql.ts | 8 ++++++-- .../src/components/product/ProductCard/ProductCard.tsx | 1 + 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/api/src/platforms/vtex/resolvers/product.ts b/packages/api/src/platforms/vtex/resolvers/product.ts index 589d4e1418..979fdc287a 100644 --- a/packages/api/src/platforms/vtex/resolvers/product.ts +++ b/packages/api/src/platforms/vtex/resolvers/product.ts @@ -44,7 +44,7 @@ export const StoreProduct: Record> & { image: Resolver } = { - productID: ({ itemId }) => itemId+`@44444444`, + productID: ({ itemId }) => itemId, categoryId: ({ isVariantOf: { categoryId }}) => categoryId, name: ({ isVariantOf, name }) => name ?? isVariantOf.productName, slug: ({ isVariantOf: { linkText }, itemId }) => getSlug(linkText, itemId), diff --git a/packages/core/@generated/gql.ts b/packages/core/@generated/gql.ts index 6ba3337543..de2dee99f5 100644 --- a/packages/core/@generated/gql.ts +++ b/packages/core/@generated/gql.ts @@ -12,7 +12,7 @@ import * as types from './graphql' * Therefore it is highly recommended to use the babel or swc plugin for production. */ const documents = { - '\n fragment ProductSummary_product on StoreProduct {\n id: productID\n slug\n sku\n brand {\n brandName: name\n }\n name\n gtin\n\n isVariantOf {\n productGroupID\n name\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n listPrice\n listPriceWithTaxes\n quantity\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n': + '\n fragment ProductSummary_product on StoreProduct {\n id: productID\n slug\n sku\n brand {\n brandName: name\n }\n name\n gtin\n categoryId\n\n isVariantOf {\n productGroupID\n name\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n listPrice\n listPriceWithTaxes\n quantity\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n': types.ProductSummary_ProductFragmentDoc, '\n fragment Filter_facets on StoreFacet {\n ... on StoreFacetRange {\n key\n label\n\n min {\n selected\n absolute\n }\n\n max {\n selected\n absolute\n }\n\n __typename\n }\n ... on StoreFacetBoolean {\n key\n label\n values {\n label\n value\n selected\n quantity\n }\n\n __typename\n }\n }\n': types.Filter_FacetsFragmentDoc, @@ -64,7 +64,7 @@ const documents = { * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function gql( - source: '\n fragment ProductSummary_product on StoreProduct {\n id: productID\n slug\n sku\n brand {\n brandName: name\n }\n name\n gtin\n\n isVariantOf {\n productGroupID\n name\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n listPrice\n listPriceWithTaxes\n quantity\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n' + source: '\n fragment ProductSummary_product on StoreProduct {\n id: productID\n slug\n sku\n brand {\n brandName: name\n }\n name\n gtin\n categoryId\n\n isVariantOf {\n productGroupID\n name\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n listPrice\n listPriceWithTaxes\n quantity\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n' ): typeof import('./graphql').ProductSummary_ProductFragmentDoc /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. diff --git a/packages/core/@generated/graphql.ts b/packages/core/@generated/graphql.ts index cb5bc7889d..43fa39ca15 100644 --- a/packages/core/@generated/graphql.ts +++ b/packages/core/@generated/graphql.ts @@ -1105,6 +1105,7 @@ export type ProductSummary_ProductFragment = { sku: string name: string gtin: string + categoryId: string id: string brand: { name: string; brandName: string } isVariantOf: { productGroupID: string; name: string } @@ -1417,6 +1418,7 @@ export type ClientManyProductsQueryQuery = { sku: string name: string gtin: string + categoryId: string id: string brand: { name: string; brandName: string } isVariantOf: { productGroupID: string; name: string } @@ -1550,6 +1552,7 @@ export type ClientSearchSuggestionsQueryQuery = { sku: string name: string gtin: string + categoryId: string id: string brand: { name: string; brandName: string } isVariantOf: { productGroupID: string; name: string } @@ -1675,6 +1678,7 @@ export const ProductSummary_ProductFragmentDoc = new TypedDocumentString( } name gtin + categoryId isVariantOf { productGroupID name @@ -2069,7 +2073,7 @@ export const SubscribeToNewsletterDocument = { export const ClientManyProductsQueryDocument = { __meta__: { operationName: 'ClientManyProductsQuery', - operationHash: '99012563e9885c3b27a716ca212a2c317e7ec12f', + operationHash: 'c1da168d1070355bd99268eb196c8479f5c714bb', }, } as unknown as TypedDocumentString< ClientManyProductsQueryQuery, @@ -2096,7 +2100,7 @@ export const ClientProductQueryDocument = { export const ClientSearchSuggestionsQueryDocument = { __meta__: { operationName: 'ClientSearchSuggestionsQuery', - operationHash: '47af7b9c9e0fb18b01050767daf3e765f67819ac', + operationHash: '930191332cee0b0b30fef83f105855f965c241cf', }, } as unknown as TypedDocumentString< ClientSearchSuggestionsQueryQuery, diff --git a/packages/core/src/components/product/ProductCard/ProductCard.tsx b/packages/core/src/components/product/ProductCard/ProductCard.tsx index d9aa1e034e..f81f618cac 100644 --- a/packages/core/src/components/product/ProductCard/ProductCard.tsx +++ b/packages/core/src/components/product/ProductCard/ProductCard.tsx @@ -153,6 +153,7 @@ export const fragment = gql(` } name gtin + categoryId isVariantOf { productGroupID From b855d6701fc1ecd598a8402f261a3ffc93f97060 Mon Sep 17 00:00:00 2001 From: Lucas Vyskubenko Date: Wed, 14 Aug 2024 18:56:49 -0300 Subject: [PATCH 004/154] feat: return categories --- packages/api/src/__generated__/schema.ts | 9 ++++++ .../src/platforms/vtex/resolvers/product.ts | 12 ++++++++ packages/api/src/typeDefs/categories.graphql | 10 +++++++ packages/api/src/typeDefs/product.graphql | 6 +++- packages/core/@generated/gql.ts | 8 +++--- packages/core/@generated/graphql.ts | 28 ++++++++++++++++--- .../product/ProductCard/ProductCard.tsx | 3 ++ .../ProductDetails/ProductDetails.tsx | 3 ++ .../analytics/hooks/useViewItemListEvent.ts | 3 ++ .../core/src/utils/createCategoryObject.ts | 7 +++++ 10 files changed, 80 insertions(+), 9 deletions(-) create mode 100644 packages/api/src/typeDefs/categories.graphql create mode 100644 packages/core/src/utils/createCategoryObject.ts diff --git a/packages/api/src/__generated__/schema.ts b/packages/api/src/__generated__/schema.ts index 756eaf4fc9..c0ab42a222 100644 --- a/packages/api/src/__generated__/schema.ts +++ b/packages/api/src/__generated__/schema.ts @@ -687,6 +687,13 @@ export type StoreCartMessage = { text: Scalars['String']; }; +/** Item of a Category. */ +export type StoreCategoryItem = { + __typename?: 'StoreCategoryItem'; + /** Name of the Category. */ + name: Scalars['String']; +}; + /** Product collection information. */ export type StoreCollection = { __typename?: 'StoreCollection'; @@ -953,6 +960,8 @@ export type StoreProduct = { /** List of items consisting of chain linked web pages, ending with the current page. */ breadcrumbList: StoreBreadcrumbList; /** Product categories. */ + categories: Array; + /** Product category Id. */ categoryId: Scalars['String']; /** Product description. */ description: Scalars['String']; diff --git a/packages/api/src/platforms/vtex/resolvers/product.ts b/packages/api/src/platforms/vtex/resolvers/product.ts index 979fdc287a..09eadabd1b 100644 --- a/packages/api/src/platforms/vtex/resolvers/product.ts +++ b/packages/api/src/platforms/vtex/resolvers/product.ts @@ -46,6 +46,18 @@ export const StoreProduct: Record> & { } = { productID: ({ itemId }) => itemId, categoryId: ({ isVariantOf: { categoryId }}) => categoryId, + categories: ({ isVariantOf: { categories }}) => { + const categoriesOnj = categories.reverse().map((categoryPath:string, index:number) => { + const splitted = categoryPath.split('/') + const name = splitted[splitted.length - 2] + + return { + name, + position: index + 1, + } + }) + return categoriesOnj + }, name: ({ isVariantOf, name }) => name ?? isVariantOf.productName, slug: ({ isVariantOf: { linkText }, itemId }) => getSlug(linkText, itemId), description: ({ isVariantOf: { description } }) => description, diff --git a/packages/api/src/typeDefs/categories.graphql b/packages/api/src/typeDefs/categories.graphql new file mode 100644 index 0000000000..9af5a01f68 --- /dev/null +++ b/packages/api/src/typeDefs/categories.graphql @@ -0,0 +1,10 @@ +""" +Item of a Category. +""" +type StoreCategoryItem { + """ + Name of the Category. + """ + name: String! + +} diff --git a/packages/api/src/typeDefs/product.graphql b/packages/api/src/typeDefs/product.graphql index 426d471aa5..c050c1f511 100644 --- a/packages/api/src/typeDefs/product.graphql +++ b/packages/api/src/typeDefs/product.graphql @@ -31,9 +31,13 @@ type StoreProduct { """ description: String! """ - Product categories. + Product category Id. """ categoryId: String! + """ + Product categories. + """ + categories: [StoreCategoryItem!]! """ Array of images. """ diff --git a/packages/core/@generated/gql.ts b/packages/core/@generated/gql.ts index de2dee99f5..5431c5e5dd 100644 --- a/packages/core/@generated/gql.ts +++ b/packages/core/@generated/gql.ts @@ -12,11 +12,11 @@ import * as types from './graphql' * Therefore it is highly recommended to use the babel or swc plugin for production. */ const documents = { - '\n fragment ProductSummary_product on StoreProduct {\n id: productID\n slug\n sku\n brand {\n brandName: name\n }\n name\n gtin\n categoryId\n\n isVariantOf {\n productGroupID\n name\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n listPrice\n listPriceWithTaxes\n quantity\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n': + '\n fragment ProductSummary_product on StoreProduct {\n id: productID\n slug\n sku\n brand {\n brandName: name\n }\n name\n gtin\n categoryId\n categories {\n name\n }\n\n isVariantOf {\n productGroupID\n name\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n listPrice\n listPriceWithTaxes\n quantity\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n': types.ProductSummary_ProductFragmentDoc, '\n fragment Filter_facets on StoreFacet {\n ... on StoreFacetRange {\n key\n label\n\n min {\n selected\n absolute\n }\n\n max {\n selected\n absolute\n }\n\n __typename\n }\n ... on StoreFacetBoolean {\n key\n label\n values {\n label\n value\n selected\n quantity\n }\n\n __typename\n }\n }\n': types.Filter_FacetsFragmentDoc, - '\n fragment ProductDetailsFragment_product on StoreProduct {\n id: productID\n sku\n name\n gtin\n categoryId\n\n description\n unitMultiplier\n isVariantOf {\n name\n productGroupID\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n # Contains necessary info to add this item to cart\n ...CartProductItem\n }\n': + '\n fragment ProductDetailsFragment_product on StoreProduct {\n id: productID\n sku\n name\n gtin\n categoryId\n categories {\n name\n }\n\n description\n unitMultiplier\n isVariantOf {\n name\n productGroupID\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n # Contains necessary info to add this item to cart\n ...CartProductItem\n }\n': types.ProductDetailsFragment_ProductFragmentDoc, '\n fragment ClientManyProducts on Query {\n search(\n first: $first\n after: $after\n sort: $sort\n term: $term\n selectedFacets: $selectedFacets\n ) {\n products {\n pageInfo {\n totalCount\n }\n }\n }\n }\n': types.ClientManyProductsFragmentDoc, @@ -64,7 +64,7 @@ const documents = { * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function gql( - source: '\n fragment ProductSummary_product on StoreProduct {\n id: productID\n slug\n sku\n brand {\n brandName: name\n }\n name\n gtin\n categoryId\n\n isVariantOf {\n productGroupID\n name\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n listPrice\n listPriceWithTaxes\n quantity\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n' + source: '\n fragment ProductSummary_product on StoreProduct {\n id: productID\n slug\n sku\n brand {\n brandName: name\n }\n name\n gtin\n categoryId\n categories {\n name\n }\n\n isVariantOf {\n productGroupID\n name\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n listPrice\n listPriceWithTaxes\n quantity\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n' ): typeof import('./graphql').ProductSummary_ProductFragmentDoc /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. @@ -76,7 +76,7 @@ export function gql( * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function gql( - source: '\n fragment ProductDetailsFragment_product on StoreProduct {\n id: productID\n sku\n name\n gtin\n categoryId\n\n description\n unitMultiplier\n isVariantOf {\n name\n productGroupID\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n # Contains necessary info to add this item to cart\n ...CartProductItem\n }\n' + source: '\n fragment ProductDetailsFragment_product on StoreProduct {\n id: productID\n sku\n name\n gtin\n categoryId\n categories {\n name\n }\n\n description\n unitMultiplier\n isVariantOf {\n name\n productGroupID\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n\n image {\n url\n alternateName\n }\n\n brand {\n name\n }\n\n offers {\n lowPrice\n lowPriceWithTaxes\n offers {\n availability\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n seller {\n identifier\n }\n }\n }\n\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n\n # Contains necessary info to add this item to cart\n ...CartProductItem\n }\n' ): typeof import('./graphql').ProductDetailsFragment_ProductFragmentDoc /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. diff --git a/packages/core/@generated/graphql.ts b/packages/core/@generated/graphql.ts index 43fa39ca15..87d525bceb 100644 --- a/packages/core/@generated/graphql.ts +++ b/packages/core/@generated/graphql.ts @@ -667,6 +667,12 @@ export type StoreCartMessage = { text: Scalars['String']['output'] } +/** Item of a Category. */ +export type StoreCategoryItem = { + /** Name of the Category. */ + name: Scalars['String']['output'] +} + /** Product collection information. */ export type StoreCollection = { /** List of items consisting of chain linked web pages, ending with the current page. */ @@ -910,6 +916,8 @@ export type StoreProduct = { /** List of items consisting of chain linked web pages, ending with the current page. */ breadcrumbList: StoreBreadcrumbList /** Product categories. */ + categories: Array + /** Product category Id. */ categoryId: Scalars['String']['output'] /** Product description. */ description: Scalars['String']['output'] @@ -1108,6 +1116,7 @@ export type ProductSummary_ProductFragment = { categoryId: string id: string brand: { name: string; brandName: string } + categories: Array<{ name: string }> isVariantOf: { productGroupID: string; name: string } image: Array<{ url: string; alternateName: string }> offers: { @@ -1162,6 +1171,7 @@ export type ProductDetailsFragment_ProductFragment = { description: string unitMultiplier: number | null id: string + categories: Array<{ name: string }> isVariantOf: { name: string productGroupID: string @@ -1280,6 +1290,7 @@ export type ServerProductQueryQuery = { availableVariations: any | null } | null } + categories: Array<{ name: string }> additionalProperty: Array<{ propertyID: string name: string @@ -1421,6 +1432,7 @@ export type ClientManyProductsQueryQuery = { categoryId: string id: string brand: { name: string; brandName: string } + categories: Array<{ name: string }> isVariantOf: { productGroupID: string; name: string } image: Array<{ url: string; alternateName: string }> offers: { @@ -1506,6 +1518,7 @@ export type ClientProductQueryQuery = { description: string unitMultiplier: number | null id: string + categories: Array<{ name: string }> isVariantOf: { name: string productGroupID: string @@ -1555,6 +1568,7 @@ export type ClientSearchSuggestionsQueryQuery = { categoryId: string id: string brand: { name: string; brandName: string } + categories: Array<{ name: string }> isVariantOf: { productGroupID: string; name: string } image: Array<{ url: string; alternateName: string }> offers: { @@ -1679,6 +1693,9 @@ export const ProductSummary_ProductFragmentDoc = new TypedDocumentString( name gtin categoryId + categories { + name + } isVariantOf { productGroupID name @@ -1787,6 +1804,9 @@ export const ProductDetailsFragment_ProductFragmentDoc = name gtin categoryId + categories { + name + } description unitMultiplier isVariantOf { @@ -2046,7 +2066,7 @@ export const ServerCollectionPageQueryDocument = { export const ServerProductQueryDocument = { __meta__: { operationName: 'ServerProductQuery', - operationHash: '517b4ec34753b76b9fca9e72f6ce0a9427d22a05', + operationHash: 'b66995c497b41d1bd968b4cd66d1810a99037308', }, } as unknown as TypedDocumentString< ServerProductQueryQuery, @@ -2073,7 +2093,7 @@ export const SubscribeToNewsletterDocument = { export const ClientManyProductsQueryDocument = { __meta__: { operationName: 'ClientManyProductsQuery', - operationHash: 'c1da168d1070355bd99268eb196c8479f5c714bb', + operationHash: 'd7e5f9d71b0c6b53defd32131b4334990aa8ec1d', }, } as unknown as TypedDocumentString< ClientManyProductsQueryQuery, @@ -2091,7 +2111,7 @@ export const ClientProductGalleryQueryDocument = { export const ClientProductQueryDocument = { __meta__: { operationName: 'ClientProductQuery', - operationHash: '5839f2e715b02f93045c3aa76993ec1072e33f63', + operationHash: 'c3d5097bd0ee3df9f81802e5fd59348f3a6785df', }, } as unknown as TypedDocumentString< ClientProductQueryQuery, @@ -2100,7 +2120,7 @@ export const ClientProductQueryDocument = { export const ClientSearchSuggestionsQueryDocument = { __meta__: { operationName: 'ClientSearchSuggestionsQuery', - operationHash: '930191332cee0b0b30fef83f105855f965c241cf', + operationHash: '87b5bfc88c26a2a0b236dc57ad6331e31565c642', }, } as unknown as TypedDocumentString< ClientSearchSuggestionsQueryQuery, diff --git a/packages/core/src/components/product/ProductCard/ProductCard.tsx b/packages/core/src/components/product/ProductCard/ProductCard.tsx index f81f618cac..628fd8b62d 100644 --- a/packages/core/src/components/product/ProductCard/ProductCard.tsx +++ b/packages/core/src/components/product/ProductCard/ProductCard.tsx @@ -154,6 +154,9 @@ export const fragment = gql(` name gtin categoryId + categories { + name + } isVariantOf { productGroupID diff --git a/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx b/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx index 030ffb4cd1..744ab5c03a 100644 --- a/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx +++ b/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx @@ -272,6 +272,9 @@ export const fragment = gql(` name gtin categoryId + categories { + name + } description unitMultiplier diff --git a/packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts b/packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts index a0dfc1244e..cccf9add65 100644 --- a/packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts +++ b/packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts @@ -7,6 +7,8 @@ import type { ProductSummary_ProductFragment } from '@generated/graphql' import type { AnalyticsItem } from '../types' +import { createCategoryObject } from '../../../utils/createCategoryObject' + type Props = { products: Array<{ node: ProductSummary_ProductFragment }> title: string @@ -44,6 +46,7 @@ export const useViewItemListEvent = ({ currency: code as CurrencyCode, item_variant_name: product.name, product_reference_id: product.gtin, + // ...createCategoryObject(products.categories.map(item => item.name)) })), }, }) diff --git a/packages/core/src/utils/createCategoryObject.ts b/packages/core/src/utils/createCategoryObject.ts new file mode 100644 index 0000000000..985ad25c11 --- /dev/null +++ b/packages/core/src/utils/createCategoryObject.ts @@ -0,0 +1,7 @@ +export function createCategoryObject(array: string[]): Record { + const result: Record = {} + array.forEach((item, index) => { + result[`item_category${index + 1}`] = item + }) + return result +} From 9ec147357d4a78ba54d832b2774b05372e29945a Mon Sep 17 00:00:00 2001 From: Lucas Vyskubenko Date: Wed, 14 Aug 2024 19:13:46 -0300 Subject: [PATCH 005/154] feat: event "useViewItemListEvent" returning categories --- packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts | 2 +- packages/core/src/utils/createCategoryObject.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts b/packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts index cccf9add65..6baafe42d4 100644 --- a/packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts +++ b/packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts @@ -46,7 +46,7 @@ export const useViewItemListEvent = ({ currency: code as CurrencyCode, item_variant_name: product.name, product_reference_id: product.gtin, - // ...createCategoryObject(products.categories.map(item => item.name)) + ...createCategoryObject(product.categories.map((item) => item.name)), })), }, }) diff --git a/packages/core/src/utils/createCategoryObject.ts b/packages/core/src/utils/createCategoryObject.ts index 985ad25c11..c73897c1e3 100644 --- a/packages/core/src/utils/createCategoryObject.ts +++ b/packages/core/src/utils/createCategoryObject.ts @@ -1,7 +1,7 @@ export function createCategoryObject(array: string[]): Record { const result: Record = {} array.forEach((item, index) => { - result[`item_category${index + 1}`] = item + result[`item_category${index ? index + 1 : ''}`] = item }) return result } From ab2a4f2fdfa06e71e5054bc86d6ae5ad29579432 Mon Sep 17 00:00:00 2001 From: Lucas Vyskubenko Date: Thu, 15 Aug 2024 11:28:26 -0300 Subject: [PATCH 006/154] chore: update GA event "view_item"and "select_item --- packages/core/@generated/gql.ts | 4 ++-- packages/core/@generated/graphql.ts | 18 +++++++++++++++--- .../product/ProductCard/ProductCard.tsx | 7 ++++++- .../sections/ProductDetails/ProductDetails.tsx | 6 ++++++ .../ui/ProductGallery/ProductGalleryPage.tsx | 2 +- .../ui/ProductShelf/ProductShelf.tsx | 1 + .../analytics/hooks/useViewItemListEvent.ts | 2 +- packages/core/src/sdk/cart/index.ts | 3 +++ packages/core/src/sdk/cart/useBuyButton.ts | 2 ++ .../core/src/sdk/product/useProductLink.ts | 8 ++++++++ 10 files changed, 45 insertions(+), 8 deletions(-) diff --git a/packages/core/@generated/gql.ts b/packages/core/@generated/gql.ts index 5431c5e5dd..727bfc3320 100644 --- a/packages/core/@generated/gql.ts +++ b/packages/core/@generated/gql.ts @@ -38,7 +38,7 @@ const documents = { types.ServerCollectionPageQueryDocument, '\n query ServerProductQuery($locator: [IStoreSelectedFacet!]!) {\n ...ServerProduct\n product(locator: $locator) {\n id: productID\n\n seo {\n title\n description\n canonical\n }\n\n brand {\n name\n }\n\n sku\n gtin\n name\n description\n releaseDate\n\n breadcrumbList {\n itemListElement {\n item\n name\n position\n }\n }\n\n image {\n url\n alternateName\n }\n\n offers {\n lowPrice\n highPrice\n lowPriceWithTaxes\n priceCurrency\n offers {\n availability\n price\n priceValidUntil\n priceCurrency\n itemCondition\n seller {\n identifier\n }\n }\n }\n\n isVariantOf {\n productGroupID\n }\n\n ...ProductDetailsFragment_product\n }\n }\n': types.ServerProductQueryDocument, - '\n mutation ValidateCartMutation($cart: IStoreCart!, $session: IStoreSession!) {\n validateCart(cart: $cart, session: $session) {\n order {\n orderNumber\n acceptedOffer {\n ...CartItem\n }\n }\n messages {\n ...CartMessage\n }\n }\n }\n\n fragment CartMessage on StoreCartMessage {\n text\n status\n }\n\n fragment CartItem on StoreOffer {\n seller {\n identifier\n }\n quantity\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n itemOffered {\n ...CartProductItem\n }\n }\n\n fragment CartProductItem on StoreProduct {\n sku\n name\n unitMultiplier\n image {\n url\n alternateName\n }\n brand {\n name\n }\n isVariantOf {\n productGroupID\n name\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n gtin\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n': + '\n mutation ValidateCartMutation($cart: IStoreCart!, $session: IStoreSession!) {\n validateCart(cart: $cart, session: $session) {\n order {\n orderNumber\n acceptedOffer {\n ...CartItem\n }\n }\n messages {\n ...CartMessage\n }\n }\n }\n\n fragment CartMessage on StoreCartMessage {\n text\n status\n }\n\n fragment CartItem on StoreOffer {\n seller {\n identifier\n }\n quantity\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n itemOffered {\n ...CartProductItem\n }\n }\n\n fragment CartProductItem on StoreProduct {\n sku\n name\n unitMultiplier\n image {\n url\n alternateName\n }\n brand {\n name\n }\n categories {\n name\n }\n isVariantOf {\n productGroupID\n name\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n gtin\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n': types.ValidateCartMutationDocument, '\n mutation SubscribeToNewsletter($data: IPersonNewsletter!) {\n subscribeToNewsletter(data: $data) {\n id\n }\n }\n': types.SubscribeToNewsletterDocument, @@ -142,7 +142,7 @@ export function gql( * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function gql( - source: '\n mutation ValidateCartMutation($cart: IStoreCart!, $session: IStoreSession!) {\n validateCart(cart: $cart, session: $session) {\n order {\n orderNumber\n acceptedOffer {\n ...CartItem\n }\n }\n messages {\n ...CartMessage\n }\n }\n }\n\n fragment CartMessage on StoreCartMessage {\n text\n status\n }\n\n fragment CartItem on StoreOffer {\n seller {\n identifier\n }\n quantity\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n itemOffered {\n ...CartProductItem\n }\n }\n\n fragment CartProductItem on StoreProduct {\n sku\n name\n unitMultiplier\n image {\n url\n alternateName\n }\n brand {\n name\n }\n isVariantOf {\n productGroupID\n name\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n gtin\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n' + source: '\n mutation ValidateCartMutation($cart: IStoreCart!, $session: IStoreSession!) {\n validateCart(cart: $cart, session: $session) {\n order {\n orderNumber\n acceptedOffer {\n ...CartItem\n }\n }\n messages {\n ...CartMessage\n }\n }\n }\n\n fragment CartMessage on StoreCartMessage {\n text\n status\n }\n\n fragment CartItem on StoreOffer {\n seller {\n identifier\n }\n quantity\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n itemOffered {\n ...CartProductItem\n }\n }\n\n fragment CartProductItem on StoreProduct {\n sku\n name\n unitMultiplier\n image {\n url\n alternateName\n }\n brand {\n name\n }\n categories {\n name\n }\n isVariantOf {\n productGroupID\n name\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n gtin\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n' ): typeof import('./graphql').ValidateCartMutationDocument /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. diff --git a/packages/core/@generated/graphql.ts b/packages/core/@generated/graphql.ts index 87d525bceb..c55b512b48 100644 --- a/packages/core/@generated/graphql.ts +++ b/packages/core/@generated/graphql.ts @@ -1323,6 +1323,7 @@ export type ValidateCartMutationMutation = { gtin: string image: Array<{ url: string; alternateName: string }> brand: { name: string } + categories: Array<{ name: string }> isVariantOf: { productGroupID: string name: string @@ -1361,6 +1362,7 @@ export type CartItemFragment = { gtin: string image: Array<{ url: string; alternateName: string }> brand: { name: string } + categories: Array<{ name: string }> isVariantOf: { productGroupID: string name: string @@ -1386,6 +1388,7 @@ export type CartProductItemFragment = { gtin: string image: Array<{ url: string; alternateName: string }> brand: { name: string } + categories: Array<{ name: string }> isVariantOf: { productGroupID: string name: string @@ -1775,6 +1778,9 @@ export const CartProductItemFragmentDoc = new TypedDocumentString( brand { name } + categories { + name + } isVariantOf { productGroupID name @@ -1858,6 +1864,9 @@ export const ProductDetailsFragment_ProductFragmentDoc = brand { name } + categories { + name + } isVariantOf { productGroupID name @@ -2025,6 +2034,9 @@ export const CartItemFragmentDoc = new TypedDocumentString( brand { name } + categories { + name + } isVariantOf { productGroupID name @@ -2066,7 +2078,7 @@ export const ServerCollectionPageQueryDocument = { export const ServerProductQueryDocument = { __meta__: { operationName: 'ServerProductQuery', - operationHash: 'b66995c497b41d1bd968b4cd66d1810a99037308', + operationHash: '95a15ae444251c9ab5d244a1deb1e45866aa0925', }, } as unknown as TypedDocumentString< ServerProductQueryQuery, @@ -2075,7 +2087,7 @@ export const ServerProductQueryDocument = { export const ValidateCartMutationDocument = { __meta__: { operationName: 'ValidateCartMutation', - operationHash: '324471076994dca94a47adcaf1c6b8f7896e1b4f', + operationHash: '31351ee7997006c11e5b526e4e0377ba2589b508', }, } as unknown as TypedDocumentString< ValidateCartMutationMutation, @@ -2111,7 +2123,7 @@ export const ClientProductGalleryQueryDocument = { export const ClientProductQueryDocument = { __meta__: { operationName: 'ClientProductQuery', - operationHash: 'c3d5097bd0ee3df9f81802e5fd59348f3a6785df', + operationHash: 'fe46ea558419c9762643e9af6307ddb4b7554da7', }, } as unknown as TypedDocumentString< ClientProductQueryQuery, diff --git a/packages/core/src/components/product/ProductCard/ProductCard.tsx b/packages/core/src/components/product/ProductCard/ProductCard.tsx index 628fd8b62d..44d536c965 100644 --- a/packages/core/src/components/product/ProductCard/ProductCard.tsx +++ b/packages/core/src/components/product/ProductCard/ProductCard.tsx @@ -46,6 +46,10 @@ export interface ProductCardProps { * Specifies the button's label. */ buttonLabel?: string + /** + * Specifies item list name. + */ + list_name?: string /** * Enables a DiscountBadge to the component. */ @@ -71,6 +75,7 @@ function ProductCard({ onButtonClick, showDiscountBadge = true, taxesConfiguration, + list_name, ...otherProps }: ProductCardProps) { const { @@ -85,7 +90,7 @@ function ProductCard({ } = product const linkProps = { - ...useProductLink({ product, selectedOffer: 0, index }), + ...useProductLink({ product, selectedOffer: 0, index, list_name }), as: NextLink, passHref: true, legacyBehavior: false, diff --git a/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx b/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx index 744ab5c03a..1ccaf4a56d 100644 --- a/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx +++ b/packages/core/src/components/sections/ProductDetails/ProductDetails.tsx @@ -17,6 +17,8 @@ import { useOverrideComponents } from '../../../sdk/overrides/OverrideContext' import { ProductDetailsDefaultComponents } from './DefaultComponents' import { getOverridableSection } from '../../../sdk/overrides/getOverriddenSection' +import { createCategoryObject } from '../../../utils/createCategoryObject' + export interface ProductDetailsProps { productTitle: { refNumber: boolean @@ -131,6 +133,9 @@ function ProductDetails({ currency: currency.code as CurrencyCode, item_variant_name: variantName, product_reference_id: gtin, + ...createCategoryObject( + product.categories.map((item) => item.name) + ), }, ], }, @@ -145,6 +150,7 @@ function ProductDetails({ currency.code, variantName, gtin, + product.categories, ]) const outOfStock = useMemo( diff --git a/packages/core/src/components/ui/ProductGallery/ProductGalleryPage.tsx b/packages/core/src/components/ui/ProductGallery/ProductGalleryPage.tsx index d27e22061a..31da0de3bb 100644 --- a/packages/core/src/components/ui/ProductGallery/ProductGalleryPage.tsx +++ b/packages/core/src/components/ui/ProductGallery/ProductGalleryPage.tsx @@ -10,7 +10,7 @@ interface Props { title: string productCard?: Pick< ProductCardProps, - 'showDiscountBadge' | 'bordered' | 'taxesConfiguration' + 'showDiscountBadge' | 'bordered' | 'taxesConfiguration' | 'list_name' > itemsPerPage: number } diff --git a/packages/core/src/components/ui/ProductShelf/ProductShelf.tsx b/packages/core/src/components/ui/ProductShelf/ProductShelf.tsx index b372b1bed7..c499c8c5d1 100644 --- a/packages/core/src/components/ui/ProductShelf/ProductShelf.tsx +++ b/packages/core/src/components/ui/ProductShelf/ProductShelf.tsx @@ -110,6 +110,7 @@ function ProductShelf({ // Dynamic props shouldn't be overridable // This decision can be reviewed later if needed key={`${product.node.id}`} + list_name={title} product={product.node} index={idx + 1} /> diff --git a/packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts b/packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts index 6baafe42d4..f08911ebe5 100644 --- a/packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts +++ b/packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts @@ -26,7 +26,7 @@ export const useViewItemListEvent = ({ currency: { code }, } = useSession() - console.log(`products33333`, products) + //console.log(`products33333`, products) const sendViewItemListEvent = useCallback(() => { sendAnalyticsEvent>({ diff --git a/packages/core/src/sdk/cart/index.ts b/packages/core/src/sdk/cart/index.ts index 7764237ec0..5e10d0bc34 100644 --- a/packages/core/src/sdk/cart/index.ts +++ b/packages/core/src/sdk/cart/index.ts @@ -68,6 +68,9 @@ export const ValidateCartMutation = gql(` brand { name } + categories { + name + } isVariantOf { productGroupID name diff --git a/packages/core/src/sdk/cart/useBuyButton.ts b/packages/core/src/sdk/cart/useBuyButton.ts index 5317ed6e79..287849c319 100644 --- a/packages/core/src/sdk/cart/useBuyButton.ts +++ b/packages/core/src/sdk/cart/useBuyButton.ts @@ -23,6 +23,8 @@ export const useBuyButton = (item: CartItem | null) => { return } + console.log(`pdp item`, item) + sendAnalyticsEvent>({ name: 'add_to_cart', params: { diff --git a/packages/core/src/sdk/product/useProductLink.ts b/packages/core/src/sdk/product/useProductLink.ts index 488b901a3d..00b52c6b05 100644 --- a/packages/core/src/sdk/product/useProductLink.ts +++ b/packages/core/src/sdk/product/useProductLink.ts @@ -7,16 +7,20 @@ import type { ProductSummary_ProductFragment } from '@generated/graphql' import { useSession } from '../session' import type { AnalyticsItem, SearchSelectItemEvent } from '../analytics/types' +import { createCategoryObject } from '../../utils/createCategoryObject' + export type ProductLinkOptions = { index: number product: ProductSummary_ProductFragment selectedOffer: number + list_name: string } export const useProductLink = ({ index, product, selectedOffer, + list_name, }: ProductLinkOptions) => { const { slug } = product const { @@ -33,6 +37,7 @@ export const useProductLink = ({ item_name: product.isVariantOf.name, item_brand: product.brand.name, item_variant: product.sku, + item_list_name: list_name ? list_name : '', index, price: product.offers.offers[selectedOffer].price, discount: @@ -41,6 +46,9 @@ export const useProductLink = ({ currency: code as CurrencyCode, item_variant_name: product.name, product_reference_id: product.gtin, + ...createCategoryObject( + product.categories.map((item) => item.name) + ), }, ], }, From b897ed282cdb31549008f42f1a310ecdd0141232 Mon Sep 17 00:00:00 2001 From: Lucas Vyskubenko Date: Thu, 15 Aug 2024 15:40:54 -0300 Subject: [PATCH 007/154] feat: add categories to GA event "add_to_cart --- packages/api/src/__generated__/schema.ts | 2 ++ packages/api/src/typeDefs/offer.graphql | 4 ++++ packages/api/src/typeDefs/product.graphql | 2 +- packages/core/src/components/cart/CartItem/CartItem.tsx | 1 + .../components/ui/ProductDetails/ProductDetailsSettings.tsx | 2 ++ packages/core/src/sdk/cart/index.ts | 6 +++++- packages/core/src/sdk/cart/useBuyButton.ts | 5 +++++ 7 files changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/api/src/__generated__/schema.ts b/packages/api/src/__generated__/schema.ts index c0ab42a222..1570aa5393 100644 --- a/packages/api/src/__generated__/schema.ts +++ b/packages/api/src/__generated__/schema.ts @@ -880,6 +880,8 @@ export type StoreOffer = { __typename?: 'StoreOffer'; /** Offer item availability. */ availability: Scalars['String']; + /** Product categories. */ + categories: Array; /** Offer item condition. */ itemCondition: Scalars['String']; /** Information on the item being offered. */ diff --git a/packages/api/src/typeDefs/offer.graphql b/packages/api/src/typeDefs/offer.graphql index a77582feb6..76318e041e 100644 --- a/packages/api/src/typeDefs/offer.graphql +++ b/packages/api/src/typeDefs/offer.graphql @@ -50,6 +50,10 @@ type StoreOffer { Number of items offered. """ quantity: Int! + """ + Product categories. + """ + categories: [StoreCategoryItem!]! } """ diff --git a/packages/api/src/typeDefs/product.graphql b/packages/api/src/typeDefs/product.graphql index c050c1f511..3c3bb7bfcc 100644 --- a/packages/api/src/typeDefs/product.graphql +++ b/packages/api/src/typeDefs/product.graphql @@ -34,7 +34,7 @@ type StoreProduct { Product category Id. """ categoryId: String! - """ + """ Product categories. """ categories: [StoreCategoryItem!]! diff --git a/packages/core/src/components/cart/CartItem/CartItem.tsx b/packages/core/src/components/cart/CartItem/CartItem.tsx index bf69b115a5..6be2d11bd3 100644 --- a/packages/core/src/components/cart/CartItem/CartItem.tsx +++ b/packages/core/src/components/cart/CartItem/CartItem.tsx @@ -74,6 +74,7 @@ function CartItem({ useUnitMultiplier = false, taxesConfiguration, }: Props) { + console.log(`CartItem`, item) const btnProps = useRemoveButton(item) const { sendCartItemEvent } = useCartItemEvent() diff --git a/packages/core/src/components/ui/ProductDetails/ProductDetailsSettings.tsx b/packages/core/src/components/ui/ProductDetails/ProductDetailsSettings.tsx index 97d248ce19..655856a710 100644 --- a/packages/core/src/components/ui/ProductDetails/ProductDetailsSettings.tsx +++ b/packages/core/src/components/ui/ProductDetails/ProductDetailsSettings.tsx @@ -63,6 +63,7 @@ function ProductDetailsSettings({ isVariantOf: { skuVariants }, image: productImages, additionalProperty, + categories, offers: { offers: [ { @@ -85,6 +86,7 @@ function ProductDetailsSettings({ listPriceWithTaxes, seller, quantity, + categories, itemOffered: { sku, name: variantName, diff --git a/packages/core/src/sdk/cart/index.ts b/packages/core/src/sdk/cart/index.ts index 5e10d0bc34..6d199b114e 100644 --- a/packages/core/src/sdk/cart/index.ts +++ b/packages/core/src/sdk/cart/index.ts @@ -16,7 +16,9 @@ import { request } from '../graphql/request' import { sessionStore } from '../session' import { createValidationStore, useStore } from '../useStore' -export interface CartItem extends SDKCartItem, CartItemFragment {} +export interface CartItem extends SDKCartItem, CartItemFragment { + categories: Array<{ name: string }> +} export interface Cart extends SDKCart { messages?: CartMessageFragment[] @@ -172,6 +174,8 @@ export const useCart = ( const cart = useStore(cartStore) const isValidating = useStore(validationStore) + console.log(`cartStore`, cart) + return useMemo(() => { const cartTotals = cart.items.reduce( (totals, curr) => { diff --git a/packages/core/src/sdk/cart/useBuyButton.ts b/packages/core/src/sdk/cart/useBuyButton.ts index 287849c319..a5ab23cea2 100644 --- a/packages/core/src/sdk/cart/useBuyButton.ts +++ b/packages/core/src/sdk/cart/useBuyButton.ts @@ -9,6 +9,8 @@ import { useSession } from '../session' import { useUI } from '@faststore/ui' import { cartStore } from './index' +import { createCategoryObject } from '../../utils/createCategoryObject' + export const useBuyButton = (item: CartItem | null) => { const { openCart } = useUI() const { @@ -44,6 +46,9 @@ export const useBuyButton = (item: CartItem | null) => { currency: code as CurrencyCode, item_variant_name: item.itemOffered.name, product_reference_id: item.itemOffered.gtin, + ...createCategoryObject( + item.categories.map((item: any) => item.name) + ), }, ], }, From 23ba6ce40bbc93b6e0d6e118350455c06ab25cdb Mon Sep 17 00:00:00 2001 From: Lucas Vyskubenko Date: Thu, 15 Aug 2024 15:48:09 -0300 Subject: [PATCH 008/154] feat: add categories to GA events "remove_from_cart" and "view_cart --- .../core/src/components/cart/CartSidebar/CartSidebar.tsx | 5 +++++ packages/core/src/sdk/cart/useRemoveButton.ts | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/packages/core/src/components/cart/CartSidebar/CartSidebar.tsx b/packages/core/src/components/cart/CartSidebar/CartSidebar.tsx index d20ac2ab23..fe61f49a97 100644 --- a/packages/core/src/components/cart/CartSidebar/CartSidebar.tsx +++ b/packages/core/src/components/cart/CartSidebar/CartSidebar.tsx @@ -15,6 +15,8 @@ import { useCart } from 'src/sdk/cart' import { useCheckoutButton } from 'src/sdk/cart/useCheckoutButton' import { useSession } from 'src/sdk/session' +import { createCategoryObject } from '../../../utils/createCategoryObject' + import Gift from '../../ui/Gift' import CartItem from '../CartItem' import EmptyCart from '../EmptyCart' @@ -44,6 +46,9 @@ function useViewCartEvent() { currency: code as CurrencyCode, item_variant_name: item.itemOffered.name, product_reference_id: item.itemOffered.gtin, + ...createCategoryObject( + item.categories.map((cat: { name: any }) => cat.name) + ), })), }, }) diff --git a/packages/core/src/sdk/cart/useRemoveButton.ts b/packages/core/src/sdk/cart/useRemoveButton.ts index f8f2b64511..86bbe70510 100644 --- a/packages/core/src/sdk/cart/useRemoveButton.ts +++ b/packages/core/src/sdk/cart/useRemoveButton.ts @@ -8,6 +8,8 @@ import { useSession } from '../session' import { cartStore } from './index' import type { CartItem } from '.' +import { createCategoryObject } from '../../utils/createCategoryObject' + export const useRemoveButton = (item: CartItem | null) => { const { currency: { code }, @@ -38,6 +40,9 @@ export const useRemoveButton = (item: CartItem | null) => { currency: code as CurrencyCode, item_variant_name: item.itemOffered.name, product_reference_id: item.itemOffered.gtin, + ...createCategoryObject( + item.categories.map((cat: { name: any }) => cat.name) + ), }, ], }, From 64413451a7963fd0c25f9f97fdf88674d2bb613b Mon Sep 17 00:00:00 2001 From: Lucas Vyskubenko Date: Thu, 15 Aug 2024 15:51:26 -0300 Subject: [PATCH 009/154] chore: remove consoles --- packages/core/src/components/cart/CartItem/CartItem.tsx | 1 - packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts | 2 -- packages/core/src/sdk/cart/index.ts | 2 -- packages/core/src/sdk/cart/useBuyButton.ts | 2 -- 4 files changed, 7 deletions(-) diff --git a/packages/core/src/components/cart/CartItem/CartItem.tsx b/packages/core/src/components/cart/CartItem/CartItem.tsx index 6be2d11bd3..bf69b115a5 100644 --- a/packages/core/src/components/cart/CartItem/CartItem.tsx +++ b/packages/core/src/components/cart/CartItem/CartItem.tsx @@ -74,7 +74,6 @@ function CartItem({ useUnitMultiplier = false, taxesConfiguration, }: Props) { - console.log(`CartItem`, item) const btnProps = useRemoveButton(item) const { sendCartItemEvent } = useCartItemEvent() diff --git a/packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts b/packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts index f08911ebe5..df38fe22d9 100644 --- a/packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts +++ b/packages/core/src/sdk/analytics/hooks/useViewItemListEvent.ts @@ -26,8 +26,6 @@ export const useViewItemListEvent = ({ currency: { code }, } = useSession() - //console.log(`products33333`, products) - const sendViewItemListEvent = useCallback(() => { sendAnalyticsEvent>({ name: 'view_item_list', diff --git a/packages/core/src/sdk/cart/index.ts b/packages/core/src/sdk/cart/index.ts index 6d199b114e..9f209f553d 100644 --- a/packages/core/src/sdk/cart/index.ts +++ b/packages/core/src/sdk/cart/index.ts @@ -174,8 +174,6 @@ export const useCart = ( const cart = useStore(cartStore) const isValidating = useStore(validationStore) - console.log(`cartStore`, cart) - return useMemo(() => { const cartTotals = cart.items.reduce( (totals, curr) => { diff --git a/packages/core/src/sdk/cart/useBuyButton.ts b/packages/core/src/sdk/cart/useBuyButton.ts index a5ab23cea2..bd5056cb10 100644 --- a/packages/core/src/sdk/cart/useBuyButton.ts +++ b/packages/core/src/sdk/cart/useBuyButton.ts @@ -25,8 +25,6 @@ export const useBuyButton = (item: CartItem | null) => { return } - console.log(`pdp item`, item) - sendAnalyticsEvent>({ name: 'add_to_cart', params: { From bf42f940cfbec3d1d1f113e6aaed5bc7b9b0601d Mon Sep 17 00:00:00 2001 From: Lucas Vyskubenko Date: Thu, 15 Aug 2024 16:03:16 -0300 Subject: [PATCH 010/154] fix: parse search prop for GA event --- .../components/search/SearchProductItem/SearchProductItem.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/core/src/components/search/SearchProductItem/SearchProductItem.tsx b/packages/core/src/components/search/SearchProductItem/SearchProductItem.tsx index 6a6f168f35..d2a990870a 100644 --- a/packages/core/src/components/search/SearchProductItem/SearchProductItem.tsx +++ b/packages/core/src/components/search/SearchProductItem/SearchProductItem.tsx @@ -30,10 +30,13 @@ function SearchProductItem({ values: { onSearchSelection }, } = useSearch() + const list_name = 'search' + const { href, onClick, ...baseLinkProps } = useProductLink({ product, selectedOffer: 0, index, + list_name, }) const { From 47d4f1a2ed1a88a31d2514bd466bac53ed9e1d29 Mon Sep 17 00:00:00 2001 From: Lucas Vyskubenko Date: Thu, 15 Aug 2024 16:19:13 -0300 Subject: [PATCH 011/154] fix: list issues --- packages/core/@generated/gql.ts | 4 ++-- packages/core/@generated/graphql.ts | 25 ++++++++++--------------- packages/core/src/sdk/cart/index.ts | 6 +++--- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/packages/core/@generated/gql.ts b/packages/core/@generated/gql.ts index 727bfc3320..f92b4089d1 100644 --- a/packages/core/@generated/gql.ts +++ b/packages/core/@generated/gql.ts @@ -38,7 +38,7 @@ const documents = { types.ServerCollectionPageQueryDocument, '\n query ServerProductQuery($locator: [IStoreSelectedFacet!]!) {\n ...ServerProduct\n product(locator: $locator) {\n id: productID\n\n seo {\n title\n description\n canonical\n }\n\n brand {\n name\n }\n\n sku\n gtin\n name\n description\n releaseDate\n\n breadcrumbList {\n itemListElement {\n item\n name\n position\n }\n }\n\n image {\n url\n alternateName\n }\n\n offers {\n lowPrice\n highPrice\n lowPriceWithTaxes\n priceCurrency\n offers {\n availability\n price\n priceValidUntil\n priceCurrency\n itemCondition\n seller {\n identifier\n }\n }\n }\n\n isVariantOf {\n productGroupID\n }\n\n ...ProductDetailsFragment_product\n }\n }\n': types.ServerProductQueryDocument, - '\n mutation ValidateCartMutation($cart: IStoreCart!, $session: IStoreSession!) {\n validateCart(cart: $cart, session: $session) {\n order {\n orderNumber\n acceptedOffer {\n ...CartItem\n }\n }\n messages {\n ...CartMessage\n }\n }\n }\n\n fragment CartMessage on StoreCartMessage {\n text\n status\n }\n\n fragment CartItem on StoreOffer {\n seller {\n identifier\n }\n quantity\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n itemOffered {\n ...CartProductItem\n }\n }\n\n fragment CartProductItem on StoreProduct {\n sku\n name\n unitMultiplier\n image {\n url\n alternateName\n }\n brand {\n name\n }\n categories {\n name\n }\n isVariantOf {\n productGroupID\n name\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n gtin\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n': + '\n mutation ValidateCartMutation($cart: IStoreCart!, $session: IStoreSession!) {\n validateCart(cart: $cart, session: $session) {\n order {\n orderNumber\n acceptedOffer {\n ...CartItem\n }\n }\n messages {\n ...CartMessage\n }\n }\n }\n\n fragment CartMessage on StoreCartMessage {\n text\n status\n }\n\n fragment CartItem on StoreOffer {\n seller {\n identifier\n }\n quantity\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n categories {\n name\n }\n itemOffered {\n ...CartProductItem\n }\n }\n\n fragment CartProductItem on StoreProduct {\n sku\n name\n unitMultiplier\n image {\n url\n alternateName\n }\n brand {\n name\n }\n isVariantOf {\n productGroupID\n name\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n gtin\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n': types.ValidateCartMutationDocument, '\n mutation SubscribeToNewsletter($data: IPersonNewsletter!) {\n subscribeToNewsletter(data: $data) {\n id\n }\n }\n': types.SubscribeToNewsletterDocument, @@ -142,7 +142,7 @@ export function gql( * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function gql( - source: '\n mutation ValidateCartMutation($cart: IStoreCart!, $session: IStoreSession!) {\n validateCart(cart: $cart, session: $session) {\n order {\n orderNumber\n acceptedOffer {\n ...CartItem\n }\n }\n messages {\n ...CartMessage\n }\n }\n }\n\n fragment CartMessage on StoreCartMessage {\n text\n status\n }\n\n fragment CartItem on StoreOffer {\n seller {\n identifier\n }\n quantity\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n itemOffered {\n ...CartProductItem\n }\n }\n\n fragment CartProductItem on StoreProduct {\n sku\n name\n unitMultiplier\n image {\n url\n alternateName\n }\n brand {\n name\n }\n categories {\n name\n }\n isVariantOf {\n productGroupID\n name\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n gtin\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n' + source: '\n mutation ValidateCartMutation($cart: IStoreCart!, $session: IStoreSession!) {\n validateCart(cart: $cart, session: $session) {\n order {\n orderNumber\n acceptedOffer {\n ...CartItem\n }\n }\n messages {\n ...CartMessage\n }\n }\n }\n\n fragment CartMessage on StoreCartMessage {\n text\n status\n }\n\n fragment CartItem on StoreOffer {\n seller {\n identifier\n }\n quantity\n price\n priceWithTaxes\n listPrice\n listPriceWithTaxes\n categories {\n name\n }\n itemOffered {\n ...CartProductItem\n }\n }\n\n fragment CartProductItem on StoreProduct {\n sku\n name\n unitMultiplier\n image {\n url\n alternateName\n }\n brand {\n name\n }\n isVariantOf {\n productGroupID\n name\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n gtin\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n' ): typeof import('./graphql').ValidateCartMutationDocument /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. diff --git a/packages/core/@generated/graphql.ts b/packages/core/@generated/graphql.ts index c55b512b48..1083f5bfd7 100644 --- a/packages/core/@generated/graphql.ts +++ b/packages/core/@generated/graphql.ts @@ -841,6 +841,8 @@ export type StoreListItem = { export type StoreOffer = { /** Offer item availability. */ availability: Scalars['String']['output'] + /** Product categories. */ + categories: Array /** Offer item condition. */ itemCondition: Scalars['String']['output'] /** Information on the item being offered. */ @@ -1316,6 +1318,7 @@ export type ValidateCartMutationMutation = { listPrice: number listPriceWithTaxes: number seller: { identifier: string } + categories: Array<{ name: string }> itemOffered: { sku: string name: string @@ -1323,7 +1326,6 @@ export type ValidateCartMutationMutation = { gtin: string image: Array<{ url: string; alternateName: string }> brand: { name: string } - categories: Array<{ name: string }> isVariantOf: { productGroupID: string name: string @@ -1355,6 +1357,7 @@ export type CartItemFragment = { listPrice: number listPriceWithTaxes: number seller: { identifier: string } + categories: Array<{ name: string }> itemOffered: { sku: string name: string @@ -1362,7 +1365,6 @@ export type CartItemFragment = { gtin: string image: Array<{ url: string; alternateName: string }> brand: { name: string } - categories: Array<{ name: string }> isVariantOf: { productGroupID: string name: string @@ -1388,7 +1390,6 @@ export type CartProductItemFragment = { gtin: string image: Array<{ url: string; alternateName: string }> brand: { name: string } - categories: Array<{ name: string }> isVariantOf: { productGroupID: string name: string @@ -1778,9 +1779,6 @@ export const CartProductItemFragmentDoc = new TypedDocumentString( brand { name } - categories { - name - } isVariantOf { productGroupID name @@ -1864,9 +1862,6 @@ export const ProductDetailsFragment_ProductFragmentDoc = brand { name } - categories { - name - } isVariantOf { productGroupID name @@ -2019,6 +2014,9 @@ export const CartItemFragmentDoc = new TypedDocumentString( priceWithTaxes listPrice listPriceWithTaxes + categories { + name + } itemOffered { ...CartProductItem } @@ -2034,9 +2032,6 @@ export const CartItemFragmentDoc = new TypedDocumentString( brand { name } - categories { - name - } isVariantOf { productGroupID name @@ -2078,7 +2073,7 @@ export const ServerCollectionPageQueryDocument = { export const ServerProductQueryDocument = { __meta__: { operationName: 'ServerProductQuery', - operationHash: '95a15ae444251c9ab5d244a1deb1e45866aa0925', + operationHash: 'b66995c497b41d1bd968b4cd66d1810a99037308', }, } as unknown as TypedDocumentString< ServerProductQueryQuery, @@ -2087,7 +2082,7 @@ export const ServerProductQueryDocument = { export const ValidateCartMutationDocument = { __meta__: { operationName: 'ValidateCartMutation', - operationHash: '31351ee7997006c11e5b526e4e0377ba2589b508', + operationHash: 'dbc28779ac0f1e3cbaa0b85c28531029046eebe1', }, } as unknown as TypedDocumentString< ValidateCartMutationMutation, @@ -2123,7 +2118,7 @@ export const ClientProductGalleryQueryDocument = { export const ClientProductQueryDocument = { __meta__: { operationName: 'ClientProductQuery', - operationHash: 'fe46ea558419c9762643e9af6307ddb4b7554da7', + operationHash: 'c3d5097bd0ee3df9f81802e5fd59348f3a6785df', }, } as unknown as TypedDocumentString< ClientProductQueryQuery, diff --git a/packages/core/src/sdk/cart/index.ts b/packages/core/src/sdk/cart/index.ts index 9f209f553d..4a2866de54 100644 --- a/packages/core/src/sdk/cart/index.ts +++ b/packages/core/src/sdk/cart/index.ts @@ -54,6 +54,9 @@ export const ValidateCartMutation = gql(` priceWithTaxes listPrice listPriceWithTaxes + categories { + name + } itemOffered { ...CartProductItem } @@ -70,9 +73,6 @@ export const ValidateCartMutation = gql(` brand { name } - categories { - name - } isVariantOf { productGroupID name From ff12ccfdf1cc909dc708912fa5b0c95e6aaaef57 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 20:47:32 -0300 Subject: [PATCH 012/154] Chore(deps): Bump braces from 3.0.2 to 3.0.3 (#2345) Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3.
Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=braces&package-manager=npm_and_yarn&previous-version=3.0.2&new-version=3.0.3)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) You can trigger a rebase of this PR by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/vtex/faststore/network/alerts).
> **Note** > Automatic rebases have been disabled on this pull request as it has been open for over 30 days. Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/yarn.lock b/yarn.lock index 66c5c3fe07..2b4397868c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5577,11 +5577,11 @@ brace-expansion@^2.0.1: balanced-match "^1.0.0" braces@^3.0.2, braces@~3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + version "3.0.3" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789" + integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA== dependencies: - fill-range "^7.0.1" + fill-range "^7.1.1" browserslist@^4.21.3, browserslist@^4.21.4: version "4.21.4" @@ -8996,10 +8996,10 @@ filelist@^1.0.4: dependencies: minimatch "^5.0.1" -fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== +fill-range@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292" + integrity sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg== dependencies: to-regex-range "^5.0.1" @@ -16987,7 +16987,7 @@ string-similarity@^4.0.1: resolved "https://registry.yarnpkg.com/string-similarity/-/string-similarity-4.0.4.tgz#42d01ab0b34660ea8a018da8f56a3309bb8b2a5b" integrity sha512-/q/8Q4Bl4ZKAPjj8WerIBJWALKkaPRfrvhfF8k/B23i4nzrlRj2/go1m90In7nG/3XDSbOo0+pu6RvCTM9RGMQ== -"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0": version "4.2.3" resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -17005,6 +17005,15 @@ string-width@^1.0.1: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" +"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" @@ -17099,7 +17108,7 @@ stringify-entities@^4.0.0: character-entities-html4 "^2.0.0" character-entities-legacy "^3.0.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": version "6.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -17127,6 +17136,13 @@ strip-ansi@^5.1.0: dependencies: ansi-regex "^4.1.0" +strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + strip-ansi@^7.0.1, strip-ansi@^7.1.0: version "7.1.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" @@ -18829,7 +18845,7 @@ wordwrap@^1.0.0: resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== @@ -18863,6 +18879,15 @@ wrap-ansi@^6.0.1, wrap-ansi@^6.2.0: string-width "^4.1.0" strip-ansi "^6.0.0" +wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + wrap-ansi@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" From f8acb467c49fad7ef64e577ed8d592b1a29a6d4a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 21 Aug 2024 22:07:01 -0300 Subject: [PATCH 013/154] Chore(deps): Bump axios from 1.6.8 to 1.7.4 (#2418) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps [axios](https://github.com/axios/axios) from 1.6.8 to 1.7.4.
Release notes

Sourced from axios's releases.

Release v1.7.4

Release notes:

Bug Fixes

Contributors to this release

Release v1.7.3

Release notes:

Bug Fixes

  • adapter: fix progress event emitting; (#6518) (e3c76fc)
  • fetch: fix withCredentials request config (#6505) (85d4d0e)
  • xhr: return original config on errors from XHR adapter (#6515) (8966ee7)

Contributors to this release

Release v1.7.2

Release notes:

Bug Fixes

Contributors to this release

Release v1.7.1

Release notes:

Bug Fixes

  • fetch: fixed ReferenceError issue when TextEncoder is not available in the environment; (#6410) (733f15f)

Contributors to this release

Release v1.7.0

Release notes:

Features

... (truncated)

Changelog

Sourced from axios's changelog.

1.7.4 (2024-08-13)

Bug Fixes

Contributors to this release

1.7.3 (2024-08-01)

Bug Fixes

  • adapter: fix progress event emitting; (#6518) (e3c76fc)
  • fetch: fix withCredentials request config (#6505) (85d4d0e)
  • xhr: return original config on errors from XHR adapter (#6515) (8966ee7)

Contributors to this release

1.7.2 (2024-05-21)

Bug Fixes

Contributors to this release

1.7.1 (2024-05-20)

Bug Fixes

  • fetch: fixed ReferenceError issue when TextEncoder is not available in the environment; (#6410) (733f15f)

Contributors to this release

... (truncated)

Commits

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=axios&package-manager=npm_and_yarn&previous-version=1.6.8&new-version=1.7.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) ---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot merge` will merge this PR after your CI passes on it - `@dependabot squash and merge` will squash and merge this PR after your CI passes on it - `@dependabot cancel merge` will cancel a previously requested merge and block automerging - `@dependabot reopen` will reopen this PR if it is closed - `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually - `@dependabot show ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/vtex/faststore/network/alerts).
Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 2b4397868c..91f73b9573 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5315,9 +5315,9 @@ axe-core@^4.8.1: integrity sha512-/dlp0fxyM3R8YW7MFzaHWXrf4zzbr0vaYb23VBFCl83R7nWNPg/yaQw2Dc8jzCMmDVLhSdzH8MjrsuIUuvX+6g== axios@^1.6.0: - version "1.6.8" - resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.8.tgz#66d294951f5d988a00e87a0ffb955316a619ea66" - integrity sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ== + version "1.7.4" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.7.4.tgz#4c8ded1b43683c8dd362973c393f3ede24052aa2" + integrity sha512-DukmaFRnY6AzAALSH4J2M3k6PkaC+MfaAGdEERRWcC9q3/TWQwLpHR8ZRLKTdQ3aBDL64EdluRDjJqKw+BPZEw== dependencies: follow-redirects "^1.15.6" form-data "^4.0.0" From c87448153f3cd42850fcc8aa7666268c4256856f Mon Sep 17 00:00:00 2001 From: vtexgithubbot Date: Thu, 22 Aug 2024 01:12:49 +0000 Subject: [PATCH 014/154] [no ci] Release: 3.0.94 --- apps/site/package.json | 10 +++++----- lerna.json | 2 +- packages/api/package.json | 6 +++--- packages/cli/README.md | 16 ++++++++-------- packages/cli/package.json | 8 ++++---- packages/components/package.json | 6 +++--- packages/core/package.json | 14 +++++++------- packages/eslint-config/package.json | 2 +- packages/graphql-utils/package.json | 6 +++--- packages/lighthouse/package.json | 6 +++--- packages/sdk/package.json | 4 ++-- packages/shared/package.json | 2 +- packages/ui/package.json | 8 ++++---- 13 files changed, 45 insertions(+), 45 deletions(-) diff --git a/apps/site/package.json b/apps/site/package.json index 7095ca9bab..54e2992ccc 100644 --- a/apps/site/package.json +++ b/apps/site/package.json @@ -1,6 +1,6 @@ { "name": "site", - "version": "3.0.89", + "version": "3.0.94", "author": "Emerson Laurentino @emersonlaurentino", "license": "MIT", "private": true, @@ -10,9 +10,9 @@ "start": "next start" }, "dependencies": { - "@faststore/api": "^3.0.88", - "@faststore/sdk": "^3.0.88", - "@faststore/ui": "^3.0.89", + "@faststore/api": "^3.0.94", + "@faststore/sdk": "^3.0.94", + "@faststore/ui": "^3.0.94", "next": "13.0.7", "nextra": "^2.8.0", "nextra-theme-docs": "^2.8.0", @@ -21,7 +21,7 @@ "sass": "^1.57.1" }, "devDependencies": { - "@faststore/eslint-config": "^3.0.88", + "@faststore/eslint-config": "^3.0.94", "@types/node": "^18.11.16", "eslint": "7.32.0", "react-docgen-typescript": "^2.2.2", diff --git a/lerna.json b/lerna.json index aa0308fbd7..1d3a620948 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "3.0.93", + "version": "3.0.94", "npmClient": "yarn", "command": { "publish": { diff --git a/packages/api/package.json b/packages/api/package.json index 00f07030ee..048472d8ae 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/api", - "version": "3.0.88", + "version": "3.0.94", "license": "MIT", "main": "dist/cjs/src/index.js", "typings": "dist/esm/src/index.d.ts", @@ -51,8 +51,8 @@ }, "devDependencies": { "@envelop/core": "^2.6.0", - "@faststore/eslint-config": "^3.0.88", - "@faststore/shared": "^3.0.88", + "@faststore/eslint-config": "^3.0.94", + "@faststore/shared": "^3.0.94", "@graphql-codegen/cli": "2.2.0", "@graphql-codegen/typescript": "2.2.2", "@parcel/watcher": "^2.4.0", diff --git a/packages/cli/README.md b/packages/cli/README.md index b25cdcfaf1..69a49f2436 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -30,7 +30,7 @@ $ npm install -g @faststore/cli $ faststore COMMAND running command... $ faststore (--version) -@faststore/cli/3.0.93 linux-x64 node-v18.20.4 +@faststore/cli/3.0.94 linux-x64 node-v18.20.4 $ faststore --help [COMMAND] USAGE $ faststore COMMAND @@ -60,7 +60,7 @@ ARGUMENTS PATH The path where the FastStore being built is. Defaults to cwd. ``` -_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v3.0.93/dist/commands/build.ts)_ +_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v3.0.94/dist/commands/build.ts)_ ## `faststore cms-sync [PATH]` @@ -75,7 +75,7 @@ FLAGS -d, --dry-run ``` -_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v3.0.93/dist/commands/cms-sync.ts)_ +_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v3.0.94/dist/commands/cms-sync.ts)_ ## `faststore dev [PATH]` @@ -87,7 +87,7 @@ ARGUMENTS PATH The path where the FastStore being run is. Defaults to cwd. ``` -_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v3.0.93/dist/commands/dev.ts)_ +_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v3.0.94/dist/commands/dev.ts)_ ## `faststore generate-graphql [PATH]` @@ -102,7 +102,7 @@ FLAGS -d, --debug ``` -_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v3.0.93/dist/commands/generate-graphql.ts)_ +_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v3.0.94/dist/commands/generate-graphql.ts)_ ## `faststore help [COMMAND]` @@ -142,7 +142,7 @@ EXAMPLES $ yarn faststore init discovery ``` -_See code: [dist/commands/init.ts](https://github.com/vtex/faststore/blob/v3.0.93/dist/commands/init.ts)_ +_See code: [dist/commands/init.ts](https://github.com/vtex/faststore/blob/v3.0.94/dist/commands/init.ts)_ ## `faststore start [PATH]` @@ -154,7 +154,7 @@ ARGUMENTS PATH The path where the FastStore being run is. Defaults to cwd. ``` -_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v3.0.93/dist/commands/start.ts)_ +_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v3.0.94/dist/commands/start.ts)_ ## `faststore test [PATH]` @@ -166,5 +166,5 @@ ARGUMENTS PATH The path where the FastStore being tested is. Defaults to cwd. ``` -_See code: [dist/commands/test.ts](https://github.com/vtex/faststore/blob/v3.0.93/dist/commands/test.ts)_ +_See code: [dist/commands/test.ts](https://github.com/vtex/faststore/blob/v3.0.94/dist/commands/test.ts)_ diff --git a/packages/cli/package.json b/packages/cli/package.json index 41edefe0c3..c5fc5ec15e 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/cli", - "version": "3.0.93", + "version": "3.0.94", "description": "FastStore CLI", "author": "Emerson Laurentino @emersonlaurentino", "bin": { @@ -18,7 +18,7 @@ ], "dependencies": { "@antfu/ni": "^0.21.12", - "@faststore/core": "^3.0.93", + "@faststore/core": "^3.0.94", "@inquirer/prompts": "^5.1.2", "@oclif/core": "^1.16.4", "@oclif/plugin-help": "^5", @@ -31,8 +31,8 @@ "path": "^0.12.7" }, "devDependencies": { - "@faststore/eslint-config": "^3.0.88", - "@faststore/shared": "^3.0.88", + "@faststore/eslint-config": "^3.0.94", + "@faststore/shared": "^3.0.94", "@types/chai": "^4", "@types/degit": "^2.8.6", "@types/fs-extra": "^9.0.13", diff --git a/packages/components/package.json b/packages/components/package.json index ac6b81ff8f..75ea4aad1c 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/components", - "version": "3.0.89", + "version": "3.0.94", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "typings": "dist/esm/index.d.ts", @@ -35,8 +35,8 @@ "react-dom": "^18.2.0" }, "devDependencies": { - "@faststore/eslint-config": "^3.0.88", - "@faststore/shared": "^3.0.88", + "@faststore/eslint-config": "^3.0.94", + "@faststore/shared": "^3.0.94", "@testing-library/react": "^14.3.0", "@types/react": "^18.2.42", "@types/react-dom": "^18.2.17", diff --git a/packages/core/package.json b/packages/core/package.json index 042080f291..36aa96d844 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/core", - "version": "3.0.93", + "version": "3.0.94", "license": "MIT", "repository": "vtex/faststore", "browserslist": "supports es6-module and not dead", @@ -43,11 +43,11 @@ "@envelop/graphql-jit": "^1.1.1", "@envelop/parser-cache": "^2.2.0", "@envelop/validation-cache": "^2.2.0", - "@faststore/api": "^3.0.88", - "@faststore/components": "^3.0.89", - "@faststore/graphql-utils": "^3.0.88", - "@faststore/sdk": "^3.0.88", - "@faststore/ui": "^3.0.89", + "@faststore/api": "^3.0.94", + "@faststore/components": "^3.0.94", + "@faststore/graphql-utils": "^3.0.94", + "@faststore/sdk": "^3.0.94", + "@faststore/ui": "^3.0.94", "@graphql-codegen/cli": "^5.0.2", "@graphql-codegen/client-preset": "^4.2.6", "@graphql-codegen/typescript": "^4.0.7", @@ -88,7 +88,7 @@ "devDependencies": { "@cypress/code-coverage": "^3.12.1", "@envelop/testing": "^6.0.0", - "@faststore/eslint-config": "^3.0.88", + "@faststore/eslint-config": "^3.0.94", "@faststore/lighthouse": "^1.12.32", "@lhci/cli": "^0.9.0", "@testing-library/cypress": "^10.0.1", diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json index 080b3486dc..7911986c3c 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/eslint-config", - "version": "3.0.88", + "version": "3.0.94", "main": "index.js", "license": "MIT", "repository": "vtex/faststore", diff --git a/packages/graphql-utils/package.json b/packages/graphql-utils/package.json index 8f14121e28..d13fe6b33c 100644 --- a/packages/graphql-utils/package.json +++ b/packages/graphql-utils/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/graphql-utils", - "version": "3.0.88", + "version": "3.0.94", "description": "GraphQL utilities", "repository": { "type": "git", @@ -21,8 +21,8 @@ "graphql": "^15.6.1" }, "devDependencies": { - "@faststore/eslint-config": "^3.0.88", - "@faststore/shared": "^3.0.88", + "@faststore/eslint-config": "^3.0.94", + "@faststore/shared": "^3.0.94", "cross-env": "^7.0.2", "eslint": "7.32.0", "typescript": "^4.2.4" diff --git a/packages/lighthouse/package.json b/packages/lighthouse/package.json index 06cc0b3278..9233a69f53 100644 --- a/packages/lighthouse/package.json +++ b/packages/lighthouse/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/lighthouse", - "version": "3.0.88", + "version": "3.0.94", "author": "Emerson Laurentino", "license": "MIT", "repository": { @@ -24,8 +24,8 @@ "lint": "eslint src/**/*.ts" }, "devDependencies": { - "@faststore/eslint-config": "^3.0.88", - "@faststore/shared": "^3.0.88", + "@faststore/eslint-config": "^3.0.94", + "@faststore/shared": "^3.0.94", "eslint": "7.32.0", "typescript": "^4.2.4" } diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 61ceccc3a5..e84a84f3cc 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/sdk", - "version": "3.0.88", + "version": "3.0.94", "description": "Hooks for creating your next component library", "license": "MIT", "repository": { @@ -37,7 +37,7 @@ "react": "^18.2.0" }, "devDependencies": { - "@faststore/shared": "^3.0.88", + "@faststore/shared": "^3.0.94", "@size-limit/preset-small-lib": "^7.0.8", "@testing-library/react-hooks": "^8.0.1", "fake-indexeddb": "^3.1.3", diff --git a/packages/shared/package.json b/packages/shared/package.json index 4892a7c318..4e37e41ffc 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/shared", - "version": "3.0.88", + "version": "3.0.94", "private": true, "files": [ "tsconfig.json" diff --git a/packages/ui/package.json b/packages/ui/package.json index 3c3a96465f..26bcf6afd3 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/ui", - "version": "3.0.89", + "version": "3.0.94", "description": "A lightweight, framework agnostic component library for React", "author": "emersonlaurentino", "license": "MIT", @@ -48,7 +48,7 @@ } ], "dependencies": { - "@faststore/components": "^3.0.89", + "@faststore/components": "^3.0.94", "include-media": "^1.4.10", "modern-normalize": "^1.1.0", "react-swipeable": "^7.0.0", @@ -59,8 +59,8 @@ "react-dom": "^18.2.0" }, "devDependencies": { - "@faststore/eslint-config": "^3.0.88", - "@faststore/shared": "^3.0.88", + "@faststore/eslint-config": "^3.0.94", + "@faststore/shared": "^3.0.94", "@size-limit/preset-small-lib": "^7.0.8", "@types/tabbable": "^3.1.1", "babel-loader": "^8.2.5", From 44234ba882579265220dd27d0060a6320d3c96d6 Mon Sep 17 00:00:00 2001 From: Emerson Laurentino Date: Thu, 22 Aug 2024 16:22:28 -0300 Subject: [PATCH 015/154] metatag generated at (#2417) ## What's the purpose of this pull request? create a metatag in build time in order to know when the build was created. ## How it works? using the faststore cli we generate a date and insert on store html ## How to test it? finding the `data-generated-at` metatag on source code. ### Starters Deploy Preview ## References --- packages/cli/src/commands/build.ts | 8 ++-- packages/cli/src/utils/commands.ts | 9 ++++- packages/cli/src/utils/directory.ts | 3 +- packages/cli/src/utils/generate.ts | 63 ++++++++++++++++++++++------- packages/core/next-env.d.ts | 1 + packages/core/next-seo.config.ts | 16 ++++++++ packages/core/src/pages/_app.tsx | 15 +++---- 7 files changed, 83 insertions(+), 32 deletions(-) create mode 100644 packages/core/next-seo.config.ts diff --git a/packages/cli/src/commands/build.ts b/packages/cli/src/commands/build.ts index 519a9124ba..c505bbaa16 100644 --- a/packages/cli/src/commands/build.ts +++ b/packages/cli/src/commands/build.ts @@ -3,17 +3,17 @@ import chalk from 'chalk' import { spawnSync } from 'child_process' import { existsSync } from 'fs' import { copySync, moveSync, readdirSync, removeSync } from 'fs-extra' +import { getPreferredPackageManager } from '../utils/commands' import { withBasePath } from '../utils/directory' import { generate } from '../utils/generate' -import { getPreferredPackageManager } from '../utils/commands' export default class Build extends Command { - static args = [ { name: 'path', - description: 'The path where the FastStore being built is. Defaults to cwd.', - } + description: + 'The path where the FastStore being built is. Defaults to cwd.', + }, ] async run() { diff --git a/packages/cli/src/utils/commands.ts b/packages/cli/src/utils/commands.ts index 8dea84545c..35240cd616 100644 --- a/packages/cli/src/utils/commands.ts +++ b/packages/cli/src/utils/commands.ts @@ -1,8 +1,13 @@ -import { spawnSync } from "node:child_process" +import { spawnSync } from 'node:child_process' // Retrieves the package manager based on the developer lockfile, using `ni`. export function getPreferredPackageManager() { - const agent = spawnSync("na", ['\?'], { encoding: 'utf8', shell: true }).stdout.trim() + const agent = spawnSync('na', ['?'], { + encoding: 'utf8', + shell: true, + }).stdout.trim() + + if (agent === '') return 'yarn' // Default to Yarn return agent } diff --git a/packages/cli/src/utils/directory.ts b/packages/cli/src/utils/directory.ts index f331c8ccf1..2c711b63a4 100644 --- a/packages/cli/src/utils/directory.ts +++ b/packages/cli/src/utils/directory.ts @@ -53,7 +53,8 @@ export const withBasePath = (basepath: string) => { userThemesFileDir: path.join(userSrcDir, 'themes'), userCMSDir: path.join(getRoot(), 'cms', 'faststore'), userStoreConfigFile: path.join(getRoot(), 'faststore.config.js'), - + + tmpSeoConfig: path.join(tmpDir, 'next-seo.config.ts'), tmpFolderName, tmpDir, tmpCustomizationsSrcDir: path.join(tmpDir, 'src', 'customizations', 'src'), diff --git a/packages/cli/src/utils/generate.ts b/packages/cli/src/utils/generate.ts index 7a2564f33f..55f9ee6db0 100644 --- a/packages/cli/src/utils/generate.ts +++ b/packages/cli/src/utils/generate.ts @@ -7,6 +7,7 @@ import { readFileSync, readdirSync, removeSync, + writeFileSync, writeJsonSync, } from 'fs-extra' import path from 'path' @@ -65,7 +66,7 @@ const TS_CONFIG_STRICT_RULES_ENABLED = ['noImplicitAny'] as const /** * Modify TypeScript compilation settings (tsconfig.json) to disable specific strict - * type checking rules when files are moved to the .faststore folder. + * type checking rules when files are moved to the .faststore folder. * TODO: The idea is to change the strict to false when all strict rules are migrated. */ function disableTsConfigStrictRules(basePath: string) { @@ -76,7 +77,7 @@ function disableTsConfigStrictRules(basePath: string) { const coreTsConfigFile = readFileSync(coreTsConfigPath, 'utf8') const tsConfig = JSON.parse(coreTsConfigFile) - TS_CONFIG_STRICT_RULES_ENABLED.forEach(strictRule => { + TS_CONFIG_STRICT_RULES_ENABLED.forEach((strictRule) => { tsConfig.compilerOptions[strictRule] = false }) @@ -138,12 +139,16 @@ async function copyCypressFiles(basePath: string) { try { // Cypress 9.x config file if (existsSync(`${userDir}/cypress.json`)) { - copySync(`${userDir}/cypress.json`, `${tmpDir}/cypress.json`, { dereference: true }) + copySync(`${userDir}/cypress.json`, `${tmpDir}/cypress.json`, { + dereference: true, + }) } // Cypress 12.x config file if (existsSync(`${userDir}/cypress.config.ts`)) { - copySync(`${userDir}/cypress.config.ts`, `${tmpDir}/cypress.config.ts`, { dereference: true }) + copySync(`${userDir}/cypress.config.ts`, `${tmpDir}/cypress.config.ts`, { + dereference: true, + }) } const userStoreConfig = await import(path.resolve(userStoreConfigFile)) @@ -155,7 +160,7 @@ async function copyCypressFiles(basePath: string) { ) { copySync(`${userDir}/cypress`, `${tmpDir}/cypress`, { overwrite: true, - dereference: true + dereference: true, }) console.log(`${chalk.green('success')} - Cypress test files copied`) @@ -175,7 +180,12 @@ async function copyCypressFiles(basePath: string) { } function copyUserStarterToCustomizations(basePath: string) { - const { userSrcDir, tmpCustomizationsSrcDir, userStoreConfigFile, tmpStoreConfigFile } = withBasePath(basePath) + const { + userSrcDir, + tmpCustomizationsSrcDir, + userStoreConfigFile, + tmpStoreConfigFile, + } = withBasePath(basePath) try { if (existsSync(userSrcDir) && readdirSync(userSrcDir).length > 0) { @@ -203,11 +213,7 @@ async function createCmsWebhookUrlsJsonFile(basePath: string) { const { webhookUrls } = userStoreConfig?.vtexHeadlessCms try { - writeJsonSync( - tmpCMSWebhookUrlsFile, - { urls: webhookUrls }, - { spaces: 2 } - ) + writeJsonSync(tmpCMSWebhookUrlsFile, { urls: webhookUrls }, { spaces: 2 }) console.log(`${chalk.green('success')} - CMS webhook URLs file created`) } catch (err) { console.error(`${chalk.red('error')} - ${err}`) @@ -218,7 +224,11 @@ async function createCmsWebhookUrlsJsonFile(basePath: string) { } async function copyTheme(basePath: string) { - const { userStoreConfigFile, userThemesFileDir, tmpThemesCustomizationsFile } = withBasePath(basePath) + const { + userStoreConfigFile, + userThemesFileDir, + tmpThemesCustomizationsFile, + } = withBasePath(basePath) const storeConfig = await import(path.resolve(userStoreConfigFile)) if (storeConfig.theme) { const customTheme = path.join( @@ -229,7 +239,8 @@ async function copyTheme(basePath: string) { try { copyFileSync(customTheme, tmpThemesCustomizationsFile) console.log( - `${chalk.green('success')} - ${storeConfig.theme + `${chalk.green('success')} - ${ + storeConfig.theme } theme has been applied` ) } catch (err) { @@ -237,8 +248,10 @@ async function copyTheme(basePath: string) { } } else { console.info( - `${chalk.blue('info')} - The ${storeConfig.theme - } theme was added to the config file but the ${storeConfig.theme + `${chalk.blue('info')} - The ${ + storeConfig.theme + } theme was added to the config file but the ${ + storeConfig.theme }.scss file does not exist in the themes folder. Read more: https://www.faststore.dev/docs/themes/overview` ) } @@ -254,6 +267,25 @@ async function copyTheme(basePath: string) { } } +function updateBuildTime(basePath: string) { + try { + const { tmpSeoConfig } = withBasePath(basePath) + let config = readFileSync(tmpSeoConfig, 'utf8') + const newBuildTime = new Date().toISOString() + + config = config.replace( + /const buildTime = .*?;/, + `const buildTime = '${newBuildTime}';` + ) + + writeFileSync(tmpSeoConfig, config) + + console.log(`${chalk.green('success')} - Build time updated`, newBuildTime) + } catch (error) { + console.error(`${chalk.red('error')} - Updating build time:`, error) + } +} + export async function generate(options: GenerateOptions) { const { basePath, setup = false } = options @@ -270,6 +302,7 @@ export async function generate(options: GenerateOptions) { await Promise.all([ setupPromise, + updateBuildTime(basePath), copyUserStarterToCustomizations(basePath), copyTheme(basePath), createCmsWebhookUrlsJsonFile(basePath), diff --git a/packages/core/next-env.d.ts b/packages/core/next-env.d.ts index 4f11a03dc6..fd36f9494e 100644 --- a/packages/core/next-env.d.ts +++ b/packages/core/next-env.d.ts @@ -1,5 +1,6 @@ /// /// +/// // NOTE: This file should not be edited // see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/packages/core/next-seo.config.ts b/packages/core/next-seo.config.ts new file mode 100644 index 0000000000..d6c0066d51 --- /dev/null +++ b/packages/core/next-seo.config.ts @@ -0,0 +1,16 @@ +import { DefaultSeoProps } from 'next-seo' +import storeConfig from './faststore.config' + +const buildTime = new Date().toISOString() + +const config: DefaultSeoProps = { + norobots: storeConfig.experimental.noRobots, + additionalMetaTags: [ + { + name: 'generated-at', + content: buildTime, + }, + ], +} + +export default config diff --git a/packages/core/src/pages/_app.tsx b/packages/core/src/pages/_app.tsx index baf6f53fec..4335056e0d 100644 --- a/packages/core/src/pages/_app.tsx +++ b/packages/core/src/pages/_app.tsx @@ -1,17 +1,12 @@ -// FastStore UI's base styles -import '../styles/global/index.scss' - -import '../customizations/src/themes/index.scss' - +import { UIProvider } from '@faststore/ui' import type { AppProps } from 'next/app' import NextNProgress from 'nextjs-progressbar' - -import { UIProvider } from '@faststore/ui' import Layout from 'src/Layout' import AnalyticsHandler from 'src/sdk/analytics' import ErrorBoundary from 'src/sdk/error/ErrorBoundary' - -import storeConfig from '../../faststore.config' +import SEO from '../../next-seo.config' +import '../customizations/src/themes/index.scss' +import '../styles/global/index.scss' import { DefaultSeo } from 'next-seo' @@ -24,7 +19,7 @@ function App({ Component, pageProps }: AppProps) { options={{ showSpinner: false }} /> - + From a548fc594acace26d628d4b7cd0f2c1098782ca5 Mon Sep 17 00:00:00 2001 From: Fanny Chien Date: Thu, 22 Aug 2024 22:57:54 -0300 Subject: [PATCH 016/154] release: FastStore core v3.0.94 (#2421) #2417 follow-up. Adds generated-at metatag on source code to identify when the build was created. --- packages/core/next-env.d.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/core/next-env.d.ts b/packages/core/next-env.d.ts index fd36f9494e..4f11a03dc6 100644 --- a/packages/core/next-env.d.ts +++ b/packages/core/next-env.d.ts @@ -1,6 +1,5 @@ /// /// -/// // NOTE: This file should not be edited // see https://nextjs.org/docs/basic-features/typescript for more information. From 75f7614df6bfaa0441500d45dc1fe7fb31242558 Mon Sep 17 00:00:00 2001 From: vtexgithubbot Date: Fri, 23 Aug 2024 02:03:22 +0000 Subject: [PATCH 017/154] [no ci] Release: 3.0.95 --- apps/site/package.json | 10 +++++----- lerna.json | 2 +- packages/api/package.json | 6 +++--- packages/cli/README.md | 16 ++++++++-------- packages/cli/package.json | 8 ++++---- packages/components/package.json | 6 +++--- packages/core/package.json | 14 +++++++------- packages/eslint-config/package.json | 2 +- packages/graphql-utils/package.json | 6 +++--- packages/lighthouse/package.json | 6 +++--- packages/sdk/package.json | 4 ++-- packages/shared/package.json | 2 +- packages/ui/package.json | 8 ++++---- 13 files changed, 45 insertions(+), 45 deletions(-) diff --git a/apps/site/package.json b/apps/site/package.json index 54e2992ccc..8b06a5813a 100644 --- a/apps/site/package.json +++ b/apps/site/package.json @@ -1,6 +1,6 @@ { "name": "site", - "version": "3.0.94", + "version": "3.0.95", "author": "Emerson Laurentino @emersonlaurentino", "license": "MIT", "private": true, @@ -10,9 +10,9 @@ "start": "next start" }, "dependencies": { - "@faststore/api": "^3.0.94", - "@faststore/sdk": "^3.0.94", - "@faststore/ui": "^3.0.94", + "@faststore/api": "^3.0.95", + "@faststore/sdk": "^3.0.95", + "@faststore/ui": "^3.0.95", "next": "13.0.7", "nextra": "^2.8.0", "nextra-theme-docs": "^2.8.0", @@ -21,7 +21,7 @@ "sass": "^1.57.1" }, "devDependencies": { - "@faststore/eslint-config": "^3.0.94", + "@faststore/eslint-config": "^3.0.95", "@types/node": "^18.11.16", "eslint": "7.32.0", "react-docgen-typescript": "^2.2.2", diff --git a/lerna.json b/lerna.json index 1d3a620948..cf652a0a05 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "3.0.94", + "version": "3.0.95", "npmClient": "yarn", "command": { "publish": { diff --git a/packages/api/package.json b/packages/api/package.json index 048472d8ae..bf96861457 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/api", - "version": "3.0.94", + "version": "3.0.95", "license": "MIT", "main": "dist/cjs/src/index.js", "typings": "dist/esm/src/index.d.ts", @@ -51,8 +51,8 @@ }, "devDependencies": { "@envelop/core": "^2.6.0", - "@faststore/eslint-config": "^3.0.94", - "@faststore/shared": "^3.0.94", + "@faststore/eslint-config": "^3.0.95", + "@faststore/shared": "^3.0.95", "@graphql-codegen/cli": "2.2.0", "@graphql-codegen/typescript": "2.2.2", "@parcel/watcher": "^2.4.0", diff --git a/packages/cli/README.md b/packages/cli/README.md index 69a49f2436..a85011b8b6 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -30,7 +30,7 @@ $ npm install -g @faststore/cli $ faststore COMMAND running command... $ faststore (--version) -@faststore/cli/3.0.94 linux-x64 node-v18.20.4 +@faststore/cli/3.0.95 linux-x64 node-v18.20.4 $ faststore --help [COMMAND] USAGE $ faststore COMMAND @@ -60,7 +60,7 @@ ARGUMENTS PATH The path where the FastStore being built is. Defaults to cwd. ``` -_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v3.0.94/dist/commands/build.ts)_ +_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v3.0.95/dist/commands/build.ts)_ ## `faststore cms-sync [PATH]` @@ -75,7 +75,7 @@ FLAGS -d, --dry-run ``` -_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v3.0.94/dist/commands/cms-sync.ts)_ +_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v3.0.95/dist/commands/cms-sync.ts)_ ## `faststore dev [PATH]` @@ -87,7 +87,7 @@ ARGUMENTS PATH The path where the FastStore being run is. Defaults to cwd. ``` -_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v3.0.94/dist/commands/dev.ts)_ +_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v3.0.95/dist/commands/dev.ts)_ ## `faststore generate-graphql [PATH]` @@ -102,7 +102,7 @@ FLAGS -d, --debug ``` -_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v3.0.94/dist/commands/generate-graphql.ts)_ +_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v3.0.95/dist/commands/generate-graphql.ts)_ ## `faststore help [COMMAND]` @@ -142,7 +142,7 @@ EXAMPLES $ yarn faststore init discovery ``` -_See code: [dist/commands/init.ts](https://github.com/vtex/faststore/blob/v3.0.94/dist/commands/init.ts)_ +_See code: [dist/commands/init.ts](https://github.com/vtex/faststore/blob/v3.0.95/dist/commands/init.ts)_ ## `faststore start [PATH]` @@ -154,7 +154,7 @@ ARGUMENTS PATH The path where the FastStore being run is. Defaults to cwd. ``` -_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v3.0.94/dist/commands/start.ts)_ +_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v3.0.95/dist/commands/start.ts)_ ## `faststore test [PATH]` @@ -166,5 +166,5 @@ ARGUMENTS PATH The path where the FastStore being tested is. Defaults to cwd. ``` -_See code: [dist/commands/test.ts](https://github.com/vtex/faststore/blob/v3.0.94/dist/commands/test.ts)_ +_See code: [dist/commands/test.ts](https://github.com/vtex/faststore/blob/v3.0.95/dist/commands/test.ts)_ diff --git a/packages/cli/package.json b/packages/cli/package.json index c5fc5ec15e..e246bec766 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/cli", - "version": "3.0.94", + "version": "3.0.95", "description": "FastStore CLI", "author": "Emerson Laurentino @emersonlaurentino", "bin": { @@ -18,7 +18,7 @@ ], "dependencies": { "@antfu/ni": "^0.21.12", - "@faststore/core": "^3.0.94", + "@faststore/core": "^3.0.95", "@inquirer/prompts": "^5.1.2", "@oclif/core": "^1.16.4", "@oclif/plugin-help": "^5", @@ -31,8 +31,8 @@ "path": "^0.12.7" }, "devDependencies": { - "@faststore/eslint-config": "^3.0.94", - "@faststore/shared": "^3.0.94", + "@faststore/eslint-config": "^3.0.95", + "@faststore/shared": "^3.0.95", "@types/chai": "^4", "@types/degit": "^2.8.6", "@types/fs-extra": "^9.0.13", diff --git a/packages/components/package.json b/packages/components/package.json index 75ea4aad1c..8ae400e522 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/components", - "version": "3.0.94", + "version": "3.0.95", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "typings": "dist/esm/index.d.ts", @@ -35,8 +35,8 @@ "react-dom": "^18.2.0" }, "devDependencies": { - "@faststore/eslint-config": "^3.0.94", - "@faststore/shared": "^3.0.94", + "@faststore/eslint-config": "^3.0.95", + "@faststore/shared": "^3.0.95", "@testing-library/react": "^14.3.0", "@types/react": "^18.2.42", "@types/react-dom": "^18.2.17", diff --git a/packages/core/package.json b/packages/core/package.json index 36aa96d844..1715427c05 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/core", - "version": "3.0.94", + "version": "3.0.95", "license": "MIT", "repository": "vtex/faststore", "browserslist": "supports es6-module and not dead", @@ -43,11 +43,11 @@ "@envelop/graphql-jit": "^1.1.1", "@envelop/parser-cache": "^2.2.0", "@envelop/validation-cache": "^2.2.0", - "@faststore/api": "^3.0.94", - "@faststore/components": "^3.0.94", - "@faststore/graphql-utils": "^3.0.94", - "@faststore/sdk": "^3.0.94", - "@faststore/ui": "^3.0.94", + "@faststore/api": "^3.0.95", + "@faststore/components": "^3.0.95", + "@faststore/graphql-utils": "^3.0.95", + "@faststore/sdk": "^3.0.95", + "@faststore/ui": "^3.0.95", "@graphql-codegen/cli": "^5.0.2", "@graphql-codegen/client-preset": "^4.2.6", "@graphql-codegen/typescript": "^4.0.7", @@ -88,7 +88,7 @@ "devDependencies": { "@cypress/code-coverage": "^3.12.1", "@envelop/testing": "^6.0.0", - "@faststore/eslint-config": "^3.0.94", + "@faststore/eslint-config": "^3.0.95", "@faststore/lighthouse": "^1.12.32", "@lhci/cli": "^0.9.0", "@testing-library/cypress": "^10.0.1", diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json index 7911986c3c..6983428d74 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/eslint-config", - "version": "3.0.94", + "version": "3.0.95", "main": "index.js", "license": "MIT", "repository": "vtex/faststore", diff --git a/packages/graphql-utils/package.json b/packages/graphql-utils/package.json index d13fe6b33c..18b102a3b3 100644 --- a/packages/graphql-utils/package.json +++ b/packages/graphql-utils/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/graphql-utils", - "version": "3.0.94", + "version": "3.0.95", "description": "GraphQL utilities", "repository": { "type": "git", @@ -21,8 +21,8 @@ "graphql": "^15.6.1" }, "devDependencies": { - "@faststore/eslint-config": "^3.0.94", - "@faststore/shared": "^3.0.94", + "@faststore/eslint-config": "^3.0.95", + "@faststore/shared": "^3.0.95", "cross-env": "^7.0.2", "eslint": "7.32.0", "typescript": "^4.2.4" diff --git a/packages/lighthouse/package.json b/packages/lighthouse/package.json index 9233a69f53..c6debfda0b 100644 --- a/packages/lighthouse/package.json +++ b/packages/lighthouse/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/lighthouse", - "version": "3.0.94", + "version": "3.0.95", "author": "Emerson Laurentino", "license": "MIT", "repository": { @@ -24,8 +24,8 @@ "lint": "eslint src/**/*.ts" }, "devDependencies": { - "@faststore/eslint-config": "^3.0.94", - "@faststore/shared": "^3.0.94", + "@faststore/eslint-config": "^3.0.95", + "@faststore/shared": "^3.0.95", "eslint": "7.32.0", "typescript": "^4.2.4" } diff --git a/packages/sdk/package.json b/packages/sdk/package.json index e84a84f3cc..5007c04caf 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/sdk", - "version": "3.0.94", + "version": "3.0.95", "description": "Hooks for creating your next component library", "license": "MIT", "repository": { @@ -37,7 +37,7 @@ "react": "^18.2.0" }, "devDependencies": { - "@faststore/shared": "^3.0.94", + "@faststore/shared": "^3.0.95", "@size-limit/preset-small-lib": "^7.0.8", "@testing-library/react-hooks": "^8.0.1", "fake-indexeddb": "^3.1.3", diff --git a/packages/shared/package.json b/packages/shared/package.json index 4e37e41ffc..efb3f0db7c 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/shared", - "version": "3.0.94", + "version": "3.0.95", "private": true, "files": [ "tsconfig.json" diff --git a/packages/ui/package.json b/packages/ui/package.json index 26bcf6afd3..a451920deb 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/ui", - "version": "3.0.94", + "version": "3.0.95", "description": "A lightweight, framework agnostic component library for React", "author": "emersonlaurentino", "license": "MIT", @@ -48,7 +48,7 @@ } ], "dependencies": { - "@faststore/components": "^3.0.94", + "@faststore/components": "^3.0.95", "include-media": "^1.4.10", "modern-normalize": "^1.1.0", "react-swipeable": "^7.0.0", @@ -59,8 +59,8 @@ "react-dom": "^18.2.0" }, "devDependencies": { - "@faststore/eslint-config": "^3.0.94", - "@faststore/shared": "^3.0.94", + "@faststore/eslint-config": "^3.0.95", + "@faststore/shared": "^3.0.95", "@size-limit/preset-small-lib": "^7.0.8", "@types/tabbable": "^3.1.1", "babel-loader": "^8.2.5", From af0de616b37fbe6a1511fb17ba01e9ae38e65efd Mon Sep 17 00:00:00 2001 From: ataideverton <56592231+ataideverton@users.noreply.github.com> Date: Mon, 2 Sep 2024 11:18:53 -0300 Subject: [PATCH 018/154] Feat: Adds Card Component (#2398) ## What's the purpose of this pull request? - To add the card component. The card component is integral part of the B2B Self Management design but it's also a generic component and according to the design team, will be used on things like MyAccount in the future. ![image](https://github.com/user-attachments/assets/897c55b5-63be-40c6-a8ec-51153c098d81) [Figma](https://www.figma.com/proto/r3swf1BAZB3yJa9FrgcyXx/Buyer-Organizations-%C2%B7-2024?node-id=128-37169&t=SCMy7ME6H9mqtsiN-0&scaling=min-zoom&page-id=128%3A31910) ## How to test it? ### Starters Deploy Preview [Preview](https://sfj-8b4430d--b2bfaststoredev.preview.vtex.app/self-management) [PR on Starter](https://github.com/vtex-sites/b2bfaststoredev.store/pull/88) --- apps/site/pages/components/molecules/card.mdx | 197 ++++++++++++++++++ packages/components/src/index.ts | 7 + .../components/src/molecules/Card/Card.tsx | 54 +++++ .../components/src/molecules/Card/index.ts | 2 + .../src/components/molecules/Card/styles.scss | 47 +++++ packages/ui/src/styles/components.scss | 2 + 6 files changed, 309 insertions(+) create mode 100644 apps/site/pages/components/molecules/card.mdx create mode 100644 packages/components/src/molecules/Card/Card.tsx create mode 100644 packages/components/src/molecules/Card/index.ts create mode 100644 packages/ui/src/components/molecules/Card/styles.scss diff --git a/apps/site/pages/components/molecules/card.mdx b/apps/site/pages/components/molecules/card.mdx new file mode 100644 index 0000000000..74999d4356 --- /dev/null +++ b/apps/site/pages/components/molecules/card.mdx @@ -0,0 +1,197 @@ +--- +description: Display some information divided into a body and a header. +--- + +import path from 'path' +import { useSSG } from 'nextra/ssg' +import { Tab, Tabs } from 'nextra-theme-docs' +import PropsSection from 'site/components/PropsSection' +import { TokenTable, TokenRow, TokenDivider } from 'site/components/Tokens' +import { OverviewSection } from 'site/components/OverviewSection' +import { Card } from '@faststore/ui' +import { getComponentPropsFrom } from 'site/components/utilities/propsSection' + +export const getStaticProps = () => { + const cardPath = path.resolve(__filename) + const components = ['Card.tsx'] + const [cardProps] = getComponentPropsFrom(cardPath, components) + return { + props: { + // We add an `ssg` field to the page props, + // which will be provided to the Nextra `useSSG` hook. + ssg: { + cardProps, + }, + }, + } +} + +export const CardPropsSection = ({ component }) => { + // Get the data from SSG, and render it as a component. + const { cardProps } = useSSG() + return { + Card: , + }[component] +} + +
+ +# Card + +Card displays some information divided into a body and a header. + +
+ +## Overview + + + + + +

First Product

+
+

Second Product

+
+
+ + + +

Message

+
+
+ +
+ ```tsx + +

First Product

+
+

Second Product

+
+ ``` + + ```tsx + +

Message

+
+ ``` + + + Code Example + + +
+ +--- + +## Import + +Import the component from [@faststore/ui](/../components) + +```tsx +import { Card } from '@faststore/ui' +``` + +### Import Styles into your FastStore project + +To apply the styles of this component in your FastStore project, import the following into your stylesheet: + +```scss copy +@import '@faststore/ui/src/components/molecules/Card/styles.scss'; +``` + +Follow the instructions in the [Importing FastStore UI component styles](/docs/customizing/importing-styles-to-faststore-ui-components) tutorial. + +--- + +## Usage + + + +

First Product

+
+

Second Product

+
+
+```tsx + +

First Product

+
+

Second Product

+
+``` + +--- + +## Props + + + +--- + +## Design Tokens + + + + + + + + + + + + + + +--- + +## Customization + +For further customization, you can use the following data attributes: + +`data-fs-card` + +`data-fs-card-header` + +`data-fs-card-title` + +`data-fs-card-body` + +--- diff --git a/packages/components/src/index.ts b/packages/components/src/index.ts index fbe63d3f5b..3764572943 100644 --- a/packages/components/src/index.ts +++ b/packages/components/src/index.ts @@ -67,6 +67,13 @@ export type { CarouselBulletsProps, } from './molecules/Carousel' +export { + default as Card +} from './molecules/Card' +export type { + CardProps +} from './molecules/Card' + export { default as CartItem, CartItemImage, diff --git a/packages/components/src/molecules/Card/Card.tsx b/packages/components/src/molecules/Card/Card.tsx new file mode 100644 index 0000000000..e275e998fc --- /dev/null +++ b/packages/components/src/molecules/Card/Card.tsx @@ -0,0 +1,54 @@ +import type { HTMLAttributes } from "react"; +import React, { forwardRef } from 'react' + +import { IconButton, Icon } from '../..' + +export interface CardProps extends Omit, 'role'> { + /** + * Specifies the text to be loaded into the header. + */ + title: string + /** + * ID to find this component in testing tools (e.g.: cypress, testing library, and jest). + */ + testId?: string + /** + * Specifies the card max width. + */ + maxWidth?: string + /** + * Specifies what icon to use following the FastStore Icon sheet. + */ + iconName?: string + /** + * Function that should be executed when the icon is clicked + */ + iconAction?: () => void +} + +const Card = forwardRef(function Card({ + title, + maxWidth, + testId = 'fs-card', + iconName, + iconAction, + children, + ...otherProps +}, ref) { + return ( +
+
+
{title}
+ {iconName && ( + } + aria-label={`${title} action`} onClick={iconAction} /> + )} +
+
+ {children} +
+
+ ) +}) + +export default Card diff --git a/packages/components/src/molecules/Card/index.ts b/packages/components/src/molecules/Card/index.ts new file mode 100644 index 0000000000..e081cabffb --- /dev/null +++ b/packages/components/src/molecules/Card/index.ts @@ -0,0 +1,2 @@ +export { default } from './Card' +export type { CardProps } from './Card' diff --git a/packages/ui/src/components/molecules/Card/styles.scss b/packages/ui/src/components/molecules/Card/styles.scss new file mode 100644 index 0000000000..8143013873 --- /dev/null +++ b/packages/ui/src/components/molecules/Card/styles.scss @@ -0,0 +1,47 @@ +[data-fs-card] { + // -------------------------------------------------------- + // Design Tokens for Card + // -------------------------------------------------------- + + // Default properties + --fs-card-border-radius : var(--fs-border-radius); + --fs-card-border-width : var(--fs-border-width); + --fs-card-border-color : var(--fs-border-color-light); + + // Header + --fs-card-header-padding : var(--fs-spacing-3); + --fs-card-header-bkg-color : var(--fs-color-neutral-bkg); + --fs-card-header-font-weight : var(--fs-text-weight-bold); + --fs-card-header-icon-color : var(--fs-color-main-2); + + // Body + --fs-card-body-padding : var(--fs-spacing-3); + + // -------------------------------------------------------- + // Structural Styles + // -------------------------------------------------------- + border: var(--fs-card-border-width) solid var(--fs-card-border-color); + border-radius: var(--fs-card-border-radius); + + [data-fs-card-header] { + border-top-left-radius: var(--fs-card-border-radius); + border-top-right-radius: var(--fs-card-border-radius); + padding: var(--fs-card-header-padding); + background-color: var(--fs-card-header-bkg-color); + font-weight: var(--fs-card-header-font-weight); + display: flex; + justify-content: space-between; + + [data-fs-button]{ + --fs-button-height: var(--fs-spacing-4); + } + + [data-fs-icon]{ + color: var(--fs-card-header-icon-color); + } + } + + [data-fs-card-body] { + padding: var(--fs-card-body-padding); + } +} diff --git a/packages/ui/src/styles/components.scss b/packages/ui/src/styles/components.scss index 5ac5d88155..798238e2ee 100644 --- a/packages/ui/src/styles/components.scss +++ b/packages/ui/src/styles/components.scss @@ -21,6 +21,7 @@ @import "../components/molecules/Alert/styles"; @import "../components/molecules/Breadcrumb/styles"; @import "../components/molecules/BuyButton/styles"; +@import "../components/molecules/Card/styles"; @import "../components/molecules/Carousel/styles"; @import "../components/molecules/CartItem/styles"; @import "../components/molecules/CheckboxField/styles"; @@ -55,6 +56,7 @@ @import "../components/molecules/Toggle/styles"; @import "../components/molecules/ToggleField/styles"; + // Organisms @import "../components/organisms/BannerText/styles"; @import "../components/organisms/BannerNewsletter/styles"; From dbcdb34361a930d5bcb15cacb605985ac592704f Mon Sep 17 00:00:00 2001 From: vtexgithubbot Date: Mon, 2 Sep 2024 14:24:38 +0000 Subject: [PATCH 019/154] [no ci] Release: 3.0.96 --- apps/site/package.json | 4 ++-- lerna.json | 2 +- packages/cli/README.md | 16 ++++++++-------- packages/cli/package.json | 4 ++-- packages/components/package.json | 2 +- packages/core/package.json | 6 +++--- packages/ui/package.json | 4 ++-- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/apps/site/package.json b/apps/site/package.json index 8b06a5813a..d71920fca6 100644 --- a/apps/site/package.json +++ b/apps/site/package.json @@ -1,6 +1,6 @@ { "name": "site", - "version": "3.0.95", + "version": "3.0.96", "author": "Emerson Laurentino @emersonlaurentino", "license": "MIT", "private": true, @@ -12,7 +12,7 @@ "dependencies": { "@faststore/api": "^3.0.95", "@faststore/sdk": "^3.0.95", - "@faststore/ui": "^3.0.95", + "@faststore/ui": "^3.0.96", "next": "13.0.7", "nextra": "^2.8.0", "nextra-theme-docs": "^2.8.0", diff --git a/lerna.json b/lerna.json index cf652a0a05..dac33c8b06 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "3.0.95", + "version": "3.0.96", "npmClient": "yarn", "command": { "publish": { diff --git a/packages/cli/README.md b/packages/cli/README.md index a85011b8b6..459db17a4a 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -30,7 +30,7 @@ $ npm install -g @faststore/cli $ faststore COMMAND running command... $ faststore (--version) -@faststore/cli/3.0.95 linux-x64 node-v18.20.4 +@faststore/cli/3.0.96 linux-x64 node-v18.20.4 $ faststore --help [COMMAND] USAGE $ faststore COMMAND @@ -60,7 +60,7 @@ ARGUMENTS PATH The path where the FastStore being built is. Defaults to cwd. ``` -_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v3.0.95/dist/commands/build.ts)_ +_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v3.0.96/dist/commands/build.ts)_ ## `faststore cms-sync [PATH]` @@ -75,7 +75,7 @@ FLAGS -d, --dry-run ``` -_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v3.0.95/dist/commands/cms-sync.ts)_ +_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v3.0.96/dist/commands/cms-sync.ts)_ ## `faststore dev [PATH]` @@ -87,7 +87,7 @@ ARGUMENTS PATH The path where the FastStore being run is. Defaults to cwd. ``` -_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v3.0.95/dist/commands/dev.ts)_ +_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v3.0.96/dist/commands/dev.ts)_ ## `faststore generate-graphql [PATH]` @@ -102,7 +102,7 @@ FLAGS -d, --debug ``` -_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v3.0.95/dist/commands/generate-graphql.ts)_ +_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v3.0.96/dist/commands/generate-graphql.ts)_ ## `faststore help [COMMAND]` @@ -142,7 +142,7 @@ EXAMPLES $ yarn faststore init discovery ``` -_See code: [dist/commands/init.ts](https://github.com/vtex/faststore/blob/v3.0.95/dist/commands/init.ts)_ +_See code: [dist/commands/init.ts](https://github.com/vtex/faststore/blob/v3.0.96/dist/commands/init.ts)_ ## `faststore start [PATH]` @@ -154,7 +154,7 @@ ARGUMENTS PATH The path where the FastStore being run is. Defaults to cwd. ``` -_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v3.0.95/dist/commands/start.ts)_ +_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v3.0.96/dist/commands/start.ts)_ ## `faststore test [PATH]` @@ -166,5 +166,5 @@ ARGUMENTS PATH The path where the FastStore being tested is. Defaults to cwd. ``` -_See code: [dist/commands/test.ts](https://github.com/vtex/faststore/blob/v3.0.95/dist/commands/test.ts)_ +_See code: [dist/commands/test.ts](https://github.com/vtex/faststore/blob/v3.0.96/dist/commands/test.ts)_ diff --git a/packages/cli/package.json b/packages/cli/package.json index e246bec766..6c013de325 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/cli", - "version": "3.0.95", + "version": "3.0.96", "description": "FastStore CLI", "author": "Emerson Laurentino @emersonlaurentino", "bin": { @@ -18,7 +18,7 @@ ], "dependencies": { "@antfu/ni": "^0.21.12", - "@faststore/core": "^3.0.95", + "@faststore/core": "^3.0.96", "@inquirer/prompts": "^5.1.2", "@oclif/core": "^1.16.4", "@oclif/plugin-help": "^5", diff --git a/packages/components/package.json b/packages/components/package.json index 8ae400e522..7264010cc8 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/components", - "version": "3.0.95", + "version": "3.0.96", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "typings": "dist/esm/index.d.ts", diff --git a/packages/core/package.json b/packages/core/package.json index 1715427c05..9754c267e3 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/core", - "version": "3.0.95", + "version": "3.0.96", "license": "MIT", "repository": "vtex/faststore", "browserslist": "supports es6-module and not dead", @@ -44,10 +44,10 @@ "@envelop/parser-cache": "^2.2.0", "@envelop/validation-cache": "^2.2.0", "@faststore/api": "^3.0.95", - "@faststore/components": "^3.0.95", + "@faststore/components": "^3.0.96", "@faststore/graphql-utils": "^3.0.95", "@faststore/sdk": "^3.0.95", - "@faststore/ui": "^3.0.95", + "@faststore/ui": "^3.0.96", "@graphql-codegen/cli": "^5.0.2", "@graphql-codegen/client-preset": "^4.2.6", "@graphql-codegen/typescript": "^4.0.7", diff --git a/packages/ui/package.json b/packages/ui/package.json index a451920deb..88d61c678a 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/ui", - "version": "3.0.95", + "version": "3.0.96", "description": "A lightweight, framework agnostic component library for React", "author": "emersonlaurentino", "license": "MIT", @@ -48,7 +48,7 @@ } ], "dependencies": { - "@faststore/components": "^3.0.95", + "@faststore/components": "^3.0.96", "include-media": "^1.4.10", "modern-normalize": "^1.1.0", "react-swipeable": "^7.0.0", From e405d0589a131c60fb999c8691cc201bf2639cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lar=C3=ADcia=20Mota?= Date: Tue, 3 Sep 2024 12:15:27 -0300 Subject: [PATCH 020/154] Fix: duplicated queries due to hasOnlyDefaultSalesChannel (#2429) ## What's the purpose of this pull request? The `ClientManyProductsQuery` was being fetched twice with almost the same parameters, the only difference was the `hasOnlyDefaultSalesChannel` introduced on this [PR](https://github.com/vtex/faststore/pull/2282) and used only by the `useAuth` hook. It doesn't need to be sent on the `ClientManyProductsQuery`, only on the `ValidateSession` mutation. These other queries were also being affected: `ClientSearchSuggestionsQuery`, `ClientProductGalleryQuery` and `ClientProductQuery`. ## How it works? It filters the `hasOnlyDefaultSalesChannel` key out of the `channel` object in the `useSession` before sending it on the query. ## How to test it? Running `yarn dev` and checking on the PDP that the `ClientManyProductsQuery` is not duplicated and is not sending the `hasOnlyDefaultSalesChannel` on `channel`. | Before | After | | -|-| | Screenshot 2024-09-02 at 14 00 24 | Screenshot 2024-09-02 at 13 58 30 | | Screenshot 2024-09-02 at 14 00 54 | | ### Starters Deploy Preview ## References - [Slack thread](https://vtex.slack.com/archives/C051B6LL91U/p1725284216284089) --- packages/core/src/sdk/auth/index.ts | 6 +++- .../src/sdk/product/useLocalizedVariables.ts | 4 +-- packages/core/src/sdk/session/index.ts | 28 +++++++++++++++++-- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/packages/core/src/sdk/auth/index.ts b/packages/core/src/sdk/auth/index.ts index 37d405afaf..b1d090d13d 100644 --- a/packages/core/src/sdk/auth/index.ts +++ b/packages/core/src/sdk/auth/index.ts @@ -1,7 +1,11 @@ import { useSession } from '../session' export const useAuth = () => { - const { person, isValidating, channel: channelJson } = useSession() + const { + person, + isValidating, + channel: channelJson, + } = useSession({ filter: false }) const channel = JSON.parse(channelJson) as { salesChannel: number diff --git a/packages/core/src/sdk/product/useLocalizedVariables.ts b/packages/core/src/sdk/product/useLocalizedVariables.ts index ae1ebd93ae..73ca339c41 100644 --- a/packages/core/src/sdk/product/useLocalizedVariables.ts +++ b/packages/core/src/sdk/product/useLocalizedVariables.ts @@ -1,7 +1,7 @@ -import { useMemo } from 'react' import { ClientManyProductsQueryQueryVariables } from '@generated/graphql' -import { useSession } from '../session' +import { useMemo } from 'react' import { ITEMS_PER_SECTION } from 'src/constants' +import { useSession } from '../session' const toArray = (x: T[] | T | undefined) => Array.isArray(x) ? x : x ? [x] : [] diff --git a/packages/core/src/sdk/session/index.ts b/packages/core/src/sdk/session/index.ts index aa7c22e22a..aa5c45153e 100644 --- a/packages/core/src/sdk/session/index.ts +++ b/packages/core/src/sdk/session/index.ts @@ -69,15 +69,37 @@ export const sessionStore = { }, } -export const useSession = () => { - const session = useStore(sessionStore) +interface SessionOptions { + filter?: boolean +} + +/** + * This custom hook is used to retrieve the session data and filter the channel object. + * The channel object filtering removes the hasOnlyDefaultSalesChannel key. + * This key is used only in the useAuth hook and is only required to send on the ValidateSession mutation, + * so we remove it from the session's channel object to avoid unnecessary cache invalidations and query executions. + * + * @param options - Optional configuration for the hook. + * @param options.filter - A boolean value indicating whether to filter the channel object or not. Default is true. + * @returns An object containing the session data, channel object, and a flag indicating whether the session is being validated. + */ + +export const useSession = ({ filter }: SessionOptions = { filter: true }) => { + let { channel, ...session } = useStore(sessionStore) const isValidating = useStore(validationStore) + if (filter) { + const { hasOnlyDefaultSalesChannel, ...filteredChannel } = + JSON.parse(channel) + channel = JSON.stringify(filteredChannel) + } + return useMemo( () => ({ ...session, + channel, isValidating, }), - [isValidating, session] + [isValidating, session, channel] ) } From 22f2107c8cea05da8aaa411a7e61731130b4a5f3 Mon Sep 17 00:00:00 2001 From: Eduardo Formiga Date: Tue, 3 Sep 2024 12:16:48 -0300 Subject: [PATCH 021/154] Fix: Rollback fuzzy params in PLP (#2427) ## What's the purpose of this pull request? This PR reverts the following PRs: - https://github.com/vtex/faststore/pull/2307 - https://github.com/vtex/faststore/pull/2204 Also, it resolves the conflicts from the current main branch. ## How it works? We are removing the reload issue caused by the use of fuzzy logic and operators in handling IS requests. The team will try another approach to address the usage of fuzzy logic and operators in IS requests allowing the search engine decide the best parameters for the search. ## How to test it? You can run the project locally and double-check if the PLP/Search page just loads once. Also, you can use the preview URL from starter PR: PLP: https://sfj-728d5af--starter.preview.vtex.app/office Search: https://sfj-728d5af--starter.preview.vtex.app/s?q=shirt&sort=score_desc&page=0 ### Starters Deploy Preview - https://github.com/vtex-sites/starter.store/pull/517 ## References --- packages/api/mocks/AllProductsQuery.ts | 22 +++---- packages/api/mocks/ProductQuery.ts | 6 +- packages/api/mocks/RedirectQuery.ts | 62 +++++++++--------- packages/api/mocks/SearchQuery.ts | 18 +++--- packages/api/mocks/ValidateCartMutation.ts | 4 +- packages/api/src/__generated__/schema.ts | 2 - .../platforms/vtex/clients/search/index.ts | 56 ++--------------- .../platforms/vtex/resolvers/searchResult.ts | 12 ++-- .../api/src/platforms/vtex/utils/facets.ts | 22 ++----- packages/api/src/typeDefs/query.graphql | 4 -- packages/core/@generated/gql.ts | 12 +--- packages/core/@generated/graphql.ts | 20 ++---- .../src/sdk/product/useProductGalleryQuery.ts | 63 +++++-------------- packages/core/src/sdk/search/state.ts | 7 +-- 14 files changed, 96 insertions(+), 214 deletions(-) diff --git a/packages/api/mocks/AllProductsQuery.ts b/packages/api/mocks/AllProductsQuery.ts index 3b2becaff4..437b2426b2 100644 --- a/packages/api/mocks/AllProductsQuery.ts +++ b/packages/api/mocks/AllProductsQuery.ts @@ -78,7 +78,7 @@ export const AllProductsQueryFirst5 = `query AllProducts { ` export const productSearchPage1Count5Fetch = { - info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=1&count=5&query=&sort=&locale=en-US&hideUnavailableItems=false', + info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false', init: undefined, options: { storeCookies: expect.any(Function) }, result: { @@ -86,8 +86,8 @@ export const productSearchPage1Count5Fetch = { { cacheId: 'sp-99995946', productId: '99995946', - description: '4k Philips Monitor 27"', - productName: '4k Philips Monitor 27"', + description: '4k Philips Monitor 27\"', + productName: '4k Philips Monitor 27\"', linkText: '4k-philips-monitor', brand: 'adidas', brandId: 2000004, @@ -209,7 +209,7 @@ export const productSearchPage1Count5Fetch = { ], itemId: '99988213', name: 'Monitor 27', - nameComplete: '4k Philips Monitor 27" Monitor 27', + nameComplete: '4k Philips Monitor 27\" Monitor 27', complementName: '', referenceId: [ { @@ -831,36 +831,36 @@ export const productSearchPage1Count5Fetch = { current: { index: 1, proxyUrl: - 'search/trade-policy/1?page=1&count=5&query=&sort=&operator=and&fuzzy=0', + 'search/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=auto&operator=and', }, before: [], after: [ { index: 2, proxyUrl: - 'search/trade-policy/1?page=2&count=5&query=&sort=&operator=and&fuzzy=0', + 'search/trade-policy/1?page=2&count=5&query=&sort=&fuzzy=auto&operator=and', }, { index: 3, proxyUrl: - 'search/trade-policy/1?page=3&count=5&query=&sort=&operator=and&fuzzy=0', + 'search/trade-policy/1?page=3&count=5&query=&sort=&fuzzy=auto&operator=and', }, { index: 4, proxyUrl: - 'search/trade-policy/1?page=4&count=5&query=&sort=&operator=and&fuzzy=0', + 'search/trade-policy/1?page=4&count=5&query=&sort=&fuzzy=auto&operator=and', }, { index: 5, proxyUrl: - 'search/trade-policy/1?page=5&count=5&query=&sort=&operator=and&fuzzy=0', + 'search/trade-policy/1?page=5&count=5&query=&sort=&fuzzy=auto&operator=and', }, ], perPage: 5, next: { index: 2, proxyUrl: - 'search/trade-policy/1?page=2&count=5&query=&sort=&operator=and&fuzzy=0', + 'search/trade-policy/1?page=2&count=5&query=&sort=&fuzzy=auto&operator=and', }, previous: { index: 0, @@ -871,7 +871,7 @@ export const productSearchPage1Count5Fetch = { last: { index: 50, proxyUrl: - 'search/trade-policy/1?page=50&count=5&query=&sort=&operator=and&fuzzy=0', + 'search/trade-policy/1?page=50&count=5&query=&sort=&fuzzy=auto&operator=and', }, }, }, diff --git a/packages/api/mocks/ProductQuery.ts b/packages/api/mocks/ProductQuery.ts index d49629599e..19d9c13fd2 100644 --- a/packages/api/mocks/ProductQuery.ts +++ b/packages/api/mocks/ProductQuery.ts @@ -63,7 +63,7 @@ export const ProductByIdQuery = `query ProductQuery { ` export const productSearchFetch = { - info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=1&count=1&query=sku%3A64953394&sort=&locale=en-US&hideUnavailableItems=false', + info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=1&count=1&query=sku%3A64953394&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false', init: undefined, options: { storeCookies: expect.any(Function) }, result: { @@ -229,7 +229,7 @@ export const productSearchFetch = { correction: { misspelled: true, }, - fuzzy: '0', + fuzzy: 'auto', operator: 'and', translated: false, pagination: { @@ -237,7 +237,7 @@ export const productSearchFetch = { current: { index: 1, proxyUrl: - 'search/trade-policy/1?page=1&count=1&query=sku:64953394&sort=&locale=en-US&hide-unavailable-items=false&operator=and&fuzzy=0', + 'search/trade-policy/1?page=1&count=1&query=sku:64953394&sort=&fuzzy=auto&operator=and', }, before: [], after: [], diff --git a/packages/api/mocks/RedirectQuery.ts b/packages/api/mocks/RedirectQuery.ts index 322cbb41f5..485bf99123 100644 --- a/packages/api/mocks/RedirectQuery.ts +++ b/packages/api/mocks/RedirectQuery.ts @@ -6,36 +6,36 @@ export const RedirectQueryTermTech = `query RedirectSearch { ` export const redirectTermTechFetch = { - info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=2&count=1&query=tech&sort=&locale=en-US&hideUnavailableItems=false', - init: undefined, - options: { storeCookies: expect.any(Function) }, - result: { - products: [], - recordsFiltered: 0, - fuzzy: 'auto', - operator: 'and', - redirect: '/technology', - translated: false, - pagination: { - count: 1, - current: { - index: 0, - }, - before: [], - after: [], - perPage: 0, - next: { - index: 0, - }, - previous: { - index: 0, - }, - first: { - index: 0, - }, - last: { - index: 0, - }, + info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=2&count=1&query=tech&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false', + init: undefined, + options: { storeCookies: expect.any(Function) }, + result: { + products: [], + recordsFiltered: 0, + fuzzy: 'auto', + operator: 'and', + redirect: '/technology', + translated: false, + pagination: { + count: 1, + current: { + index: 0, + }, + before: [], + after: [], + perPage: 0, + next: { + index: 0, + }, + previous: { + index: 0, + }, + first: { + index: 0, + }, + last: { + index: 0, + }, + }, }, - }, } diff --git a/packages/api/mocks/SearchQuery.ts b/packages/api/mocks/SearchQuery.ts index 8b648cbe8d..cab1117ff7 100644 --- a/packages/api/mocks/SearchQuery.ts +++ b/packages/api/mocks/SearchQuery.ts @@ -101,7 +101,7 @@ export const SearchQueryFirst5Products = `query SearchQuery { }` export const productSearchCategory1Fetch = { - info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/category-1/office/trade-policy/1?page=1&count=5&query=&sort=&locale=en-US&hideUnavailableItems=false', + info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/category-1/office/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false', init: undefined, options: { storeCookies: expect.any(Function) }, result: { @@ -1348,36 +1348,36 @@ export const productSearchCategory1Fetch = { current: { index: 1, proxyUrl: - 'search/category-1/office/trade-policy/1?page=1&count=5&query=&sort=&operator=and&fuzzy=0', + 'search/category-1/office/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=auto&operator=and', }, before: [], after: [ { index: 2, proxyUrl: - 'search/category-1/office/trade-policy/1?page=2&count=5&query=&sort=&operator=and&fuzzy=0', + 'search/category-1/office/trade-policy/1?page=2&count=5&query=&sort=&fuzzy=auto&operator=and', }, { index: 3, proxyUrl: - 'search/category-1/office/trade-policy/1?page=3&count=5&query=&sort=&operator=and&fuzzy=0', + 'search/category-1/office/trade-policy/1?page=3&count=5&query=&sort=&fuzzy=auto&operator=and', }, { index: 4, proxyUrl: - 'search/category-1/office/trade-policy/1?page=4&count=5&query=&sort=&operator=and&fuzzy=0', + 'search/category-1/office/trade-policy/1?page=4&count=5&query=&sort=&fuzzy=auto&operator=and', }, { index: 5, proxyUrl: - 'search/category-1/office/trade-policy/1?page=5&count=5&query=&sort=&operator=and&fuzzy=0', + 'search/category-1/office/trade-policy/1?page=5&count=5&query=&sort=&fuzzy=auto&operator=and', }, ], perPage: 5, next: { index: 2, proxyUrl: - 'search/category-1/office/trade-policy/1?page=2&count=5&query=&sort=&operator=and&fuzzy=0', + 'search/category-1/office/trade-policy/1?page=2&count=5&query=&sort=&fuzzy=auto&operator=and', }, previous: { index: 0, @@ -1388,14 +1388,14 @@ export const productSearchCategory1Fetch = { last: { index: 50, proxyUrl: - 'search/category-1/office/trade-policy/1?page=50&count=5&query=&sort=&operator=and&fuzzy=0', + 'search/category-1/office/trade-policy/1?page=50&count=5&query=&sort=&fuzzy=auto&operator=and', }, }, }, } export const attributeSearchCategory1Fetch = { - info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/facets/category-1/office/trade-policy/1?page=1&count=5&query=&sort=&locale=en-US&hideUnavailableItems=false', + info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/facets/category-1/office/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false', init: undefined, options: { storeCookies: expect.any(Function) }, result: { diff --git a/packages/api/mocks/ValidateCartMutation.ts b/packages/api/mocks/ValidateCartMutation.ts index 2520a208e7..c61cb8cf55 100644 --- a/packages/api/mocks/ValidateCartMutation.ts +++ b/packages/api/mocks/ValidateCartMutation.ts @@ -347,7 +347,7 @@ export const checkoutOrderFormCustomDataInvalidFetch = { } export const productSearchPage1Count1Fetch = { - info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=1&count=1&query=sku%3A2737806&sort=&locale=en-US&hideUnavailableItems=false', + info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=1&count=1&query=sku%3A2737806&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false', init: undefined, options: { storeCookies: expect.any(Function) }, result: { @@ -523,7 +523,7 @@ export const productSearchPage1Count1Fetch = { current: { index: 1, proxyUrl: - 'search/trade-policy/1?page=1&count=1&query=sku:2737806&sort=&locale=en-US&hide-unavailable-items=false&operator=and&fuzzy=0', + 'search/trade-policy/1?page=1&count=1&query=sku:2737806&sort=&fuzzy=auto&operator=and', }, before: [], after: [], diff --git a/packages/api/src/__generated__/schema.ts b/packages/api/src/__generated__/schema.ts index d7d15951a0..61a55df546 100644 --- a/packages/api/src/__generated__/schema.ts +++ b/packages/api/src/__generated__/schema.ts @@ -509,8 +509,6 @@ export type QueryShippingArgs = { /** Search result. */ export type SearchMetadata = { __typename?: 'SearchMetadata'; - /** Indicates how the search engine corrected the misspelled word by using fuzzy logic. */ - fuzzy: Scalars['String']; /** Indicates if the search term was misspelled. */ isTermMisspelled: Scalars['Boolean']; /** Logical operator used to run the search. */ diff --git a/packages/api/src/platforms/vtex/clients/search/index.ts b/packages/api/src/platforms/vtex/clients/search/index.ts index 9d2160423c..66e6fad8c4 100644 --- a/packages/api/src/platforms/vtex/clients/search/index.ts +++ b/packages/api/src/platforms/vtex/clients/search/index.ts @@ -1,11 +1,7 @@ import { fetchAPI } from '../fetch' import type { IStoreSelectedFacet } from '../../../../__generated__/schema' import type { Context, Options } from '../../' -import type { - SelectedFacet, - FuzzyFacet, - OperatorFacet, -} from '../../utils/facets' +import type { SelectedFacet } from '../../utils/facets' import type { Facet, FacetValueBoolean, @@ -43,38 +39,14 @@ export interface ProductLocator { value: string } -// channel keys const POLICY_KEY = 'trade-policy' const REGION_KEY = 'region-id' - -// search parameters -const FUZZY_KEY = 'fuzzy' -const OPERATOR_KEY = 'operator' - -const EXTRA_FACETS_KEYS = new Set([ - POLICY_KEY, - REGION_KEY, - FUZZY_KEY, - OPERATOR_KEY, -]) +const CHANNEL_KEYS = new Set([POLICY_KEY, REGION_KEY]) export const isFacetBoolean = ( facet: Facet ): facet is Facet => facet.type === 'TEXT' -const isFuzzyFacet = (facet: SelectedFacet): facet is FuzzyFacet => { - return ( - facet.key === 'fuzzy' && - (facet.value === '0' || facet.value === '1' || facet.value === 'auto') - ) -} - -const isOperatorFacet = (facet: SelectedFacet): facet is OperatorFacet => { - return ( - facet.key === 'operator' && (facet.value === 'and' || facet.value === 'or') - ) -} - export const IntelligentSearch = ( { account, environment, hideUnavailableItems }: Options, ctx: Context @@ -113,9 +85,7 @@ export const IntelligentSearch = ( } const addDefaultFacets = (facets: SelectedFacet[]) => { - const withDefaultFacets = facets.filter( - ({ key }) => !EXTRA_FACETS_KEYS.has(key) - ) + const withDefaultFacets = facets.filter(({ key }) => !CHANNEL_KEYS.has(key)) const policyFacet = facets.find(({ key }) => key === POLICY_KEY) ?? getPolicyFacet() @@ -134,22 +104,6 @@ export const IntelligentSearch = ( return withDefaultFacets } - const addSearchParamsFacets = ( - facets: SelectedFacet[], - params: URLSearchParams - ) => { - const fuzzyFacet = facets.find(({ key }) => key === FUZZY_KEY) ?? null - const operatorFacet = facets.find(({ key }) => key === OPERATOR_KEY) ?? null - - if (fuzzyFacet && isFuzzyFacet(fuzzyFacet)) { - params.append(FUZZY_KEY, fuzzyFacet.value) - } - - if (operatorFacet && isOperatorFacet(operatorFacet)) { - params.append(OPERATOR_KEY, operatorFacet.value) - } - } - const search = ({ query = '', page, @@ -157,12 +111,14 @@ export const IntelligentSearch = ( sort = '', selectedFacets = [], type, + fuzzy = 'auto', }: SearchArgs): Promise => { const params = new URLSearchParams({ page: (page + 1).toString(), count: count.toString(), query, sort, + fuzzy, locale: ctx.storage.locale, }) @@ -174,8 +130,6 @@ export const IntelligentSearch = ( .map(({ key, value }) => `${key}/${value}`) .join('/') - addSearchParamsFacets(selectedFacets, params) - return fetchAPI( `${base}/_v/api/intelligent-search/${type}/${pathname}?${params.toString()}`, undefined, diff --git a/packages/api/src/platforms/vtex/resolvers/searchResult.ts b/packages/api/src/platforms/vtex/resolvers/searchResult.ts index dc6a9c78c9..e1e47131c5 100644 --- a/packages/api/src/platforms/vtex/resolvers/searchResult.ts +++ b/packages/api/src/platforms/vtex/resolvers/searchResult.ts @@ -14,8 +14,8 @@ const isRootFacet = (facet: Facet, isDepartment: boolean, isBrand: boolean) => isDepartment ? facet.key === 'category-1' : isBrand - ? facet.key === 'brand' - : false + ? facet.key === 'brand' + : false export const StoreSearchResult: Record> = { suggestions: async (root, _, ctx) => { @@ -117,12 +117,16 @@ export const StoreSearchResult: Record> = { return filteredFacets }, - metadata: async ({ productSearchPromise }) => { + metadata: async ({ searchArgs, productSearchPromise }) => { + if (!searchArgs.query) { + return null + } + const productSearchResult = await productSearchPromise + return { isTermMisspelled: productSearchResult.correction?.misspelled ?? false, logicalOperator: productSearchResult.operator, - fuzzy: productSearchResult.fuzzy, } }, } diff --git a/packages/api/src/platforms/vtex/utils/facets.ts b/packages/api/src/platforms/vtex/utils/facets.ts index 8bc06ad153..2291f5c2f2 100644 --- a/packages/api/src/platforms/vtex/utils/facets.ts +++ b/packages/api/src/platforms/vtex/utils/facets.ts @@ -6,28 +6,18 @@ export interface SelectedFacet { value: string } -export type FuzzyFacet = { - key: 'fuzzy' - value: '0' | '1' | 'auto' -} - -export type OperatorFacet = { - key: 'operator' - value: 'and' | 'or' -} - export interface CrossSellingFacet { key: keyof typeof FACET_CROSS_SELLING_MAP value: string } export const FACET_CROSS_SELLING_MAP = { - buy: 'whoboughtalsobought', - view: 'whosawalsosaw', - similars: 'similars', - viewAndBought: 'whosawalsobought', - accessories: 'accessories', - suggestions: 'suggestions', + buy: "whoboughtalsobought", + view: "whosawalsosaw", + similars: "similars", + viewAndBought: "whosawalsobought", + accessories: "accessories", + suggestions: "suggestions", } as const /** diff --git a/packages/api/src/typeDefs/query.graphql b/packages/api/src/typeDefs/query.graphql index 3334a2e71c..0e38c291b2 100644 --- a/packages/api/src/typeDefs/query.graphql +++ b/packages/api/src/typeDefs/query.graphql @@ -160,10 +160,6 @@ type SearchMetadata { Logical operator used to run the search. """ logicalOperator: String! - """ - Indicates how the search engine corrected the misspelled word by using fuzzy logic. - """ - fuzzy: String! } """ diff --git a/packages/core/@generated/gql.ts b/packages/core/@generated/gql.ts index e1340dcce6..7364cd0d25 100644 --- a/packages/core/@generated/gql.ts +++ b/packages/core/@generated/gql.ts @@ -44,10 +44,8 @@ const documents = { types.SubscribeToNewsletterDocument, '\n query ClientManyProductsQuery(\n $first: Int!\n $after: String\n $sort: StoreSort!\n $term: String!\n $selectedFacets: [IStoreSelectedFacet!]!\n ) {\n ...ClientManyProducts\n search(\n first: $first\n after: $after\n sort: $sort\n term: $term\n selectedFacets: $selectedFacets\n ) {\n products {\n pageInfo {\n totalCount\n }\n edges {\n node {\n ...ProductSummary_product\n }\n }\n }\n }\n }\n': types.ClientManyProductsQueryDocument, - '\n query ClientProductGalleryQuery(\n $first: Int!\n $after: String!\n $sort: StoreSort!\n $term: String!\n $selectedFacets: [IStoreSelectedFacet!]!\n ) {\n ...ClientProductGallery\n redirect(term: $term, selectedFacets: $selectedFacets) {\n url\n }\n search(\n first: $first\n after: $after\n sort: $sort\n term: $term\n selectedFacets: $selectedFacets\n ) {\n products {\n pageInfo {\n totalCount\n }\n }\n facets {\n ...Filter_facets\n }\n metadata {\n ...SearchEvent_metadata\n }\n }\n }\n': + '\n query ClientProductGalleryQuery(\n $first: Int!\n $after: String!\n $sort: StoreSort!\n $term: String!\n $selectedFacets: [IStoreSelectedFacet!]!\n ) {\n ...ClientProductGallery\n redirect(term: $term, selectedFacets: $selectedFacets) {\n url\n }\n search(\n first: $first\n after: $after\n sort: $sort\n term: $term\n selectedFacets: $selectedFacets\n ) {\n products {\n pageInfo {\n totalCount\n }\n }\n facets {\n ...Filter_facets\n }\n metadata {\n ...SearchEvent_metadata\n }\n }\n }\n\n fragment SearchEvent_metadata on SearchMetadata {\n isTermMisspelled\n logicalOperator\n }\n': types.ClientProductGalleryQueryDocument, - '\n fragment SearchEvent_metadata on SearchMetadata {\n isTermMisspelled\n logicalOperator\n fuzzy\n }\n': - types.SearchEvent_MetadataFragmentDoc, '\n query ClientProductQuery($locator: [IStoreSelectedFacet!]!) {\n ...ClientProduct\n product(locator: $locator) {\n ...ProductDetailsFragment_product\n }\n }\n': types.ClientProductQueryDocument, '\n query ClientSearchSuggestionsQuery(\n $term: String!\n $selectedFacets: [IStoreSelectedFacet!]\n ) {\n ...ClientSearchSuggestions\n search(first: 5, term: $term, selectedFacets: $selectedFacets) {\n suggestions {\n terms {\n value\n }\n products {\n ...ProductSummary_product\n }\n }\n products {\n pageInfo {\n totalCount\n }\n }\n metadata {\n ...SearchEvent_metadata\n }\n }\n }\n': @@ -160,14 +158,8 @@ export function gql( * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function gql( - source: '\n query ClientProductGalleryQuery(\n $first: Int!\n $after: String!\n $sort: StoreSort!\n $term: String!\n $selectedFacets: [IStoreSelectedFacet!]!\n ) {\n ...ClientProductGallery\n redirect(term: $term, selectedFacets: $selectedFacets) {\n url\n }\n search(\n first: $first\n after: $after\n sort: $sort\n term: $term\n selectedFacets: $selectedFacets\n ) {\n products {\n pageInfo {\n totalCount\n }\n }\n facets {\n ...Filter_facets\n }\n metadata {\n ...SearchEvent_metadata\n }\n }\n }\n' + source: '\n query ClientProductGalleryQuery(\n $first: Int!\n $after: String!\n $sort: StoreSort!\n $term: String!\n $selectedFacets: [IStoreSelectedFacet!]!\n ) {\n ...ClientProductGallery\n redirect(term: $term, selectedFacets: $selectedFacets) {\n url\n }\n search(\n first: $first\n after: $after\n sort: $sort\n term: $term\n selectedFacets: $selectedFacets\n ) {\n products {\n pageInfo {\n totalCount\n }\n }\n facets {\n ...Filter_facets\n }\n metadata {\n ...SearchEvent_metadata\n }\n }\n }\n\n fragment SearchEvent_metadata on SearchMetadata {\n isTermMisspelled\n logicalOperator\n }\n' ): typeof import('./graphql').ClientProductGalleryQueryDocument -/** - * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. - */ -export function gql( - source: '\n fragment SearchEvent_metadata on SearchMetadata {\n isTermMisspelled\n logicalOperator\n fuzzy\n }\n' -): typeof import('./graphql').SearchEvent_MetadataFragmentDoc /** * The gql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ diff --git a/packages/core/@generated/graphql.ts b/packages/core/@generated/graphql.ts index 12eed73925..b3d289130b 100644 --- a/packages/core/@generated/graphql.ts +++ b/packages/core/@generated/graphql.ts @@ -503,8 +503,6 @@ export type QueryShippingArgs = { /** Search result. */ export type SearchMetadata = { - /** Indicates how the search engine corrected the misspelled word by using fuzzy logic. */ - fuzzy: Scalars['String']['output'] /** Indicates if the search term was misspelled. */ isTermMisspelled: Scalars['Boolean']['output'] /** Logical operator used to run the search. */ @@ -1473,18 +1471,13 @@ export type ClientProductGalleryQueryQuery = { max: { selected: number; absolute: number } } > - metadata: { - isTermMisspelled: boolean - logicalOperator: string - fuzzy: string - } | null + metadata: { isTermMisspelled: boolean; logicalOperator: string } | null } } export type SearchEvent_MetadataFragment = { isTermMisspelled: boolean logicalOperator: string - fuzzy: string } export type ClientProductQueryQueryVariables = Exact<{ @@ -1570,11 +1563,7 @@ export type ClientSearchSuggestionsQueryQuery = { }> } products: { pageInfo: { totalCount: number } } - metadata: { - isTermMisspelled: boolean - logicalOperator: string - fuzzy: string - } | null + metadata: { isTermMisspelled: boolean; logicalOperator: string } | null } } @@ -2019,7 +2008,6 @@ export const SearchEvent_MetadataFragmentDoc = new TypedDocumentString( fragment SearchEvent_metadata on SearchMetadata { isTermMisspelled logicalOperator - fuzzy } `, { fragmentName: 'SearchEvent_metadata' } @@ -2072,7 +2060,7 @@ export const ClientManyProductsQueryDocument = { export const ClientProductGalleryQueryDocument = { __meta__: { operationName: 'ClientProductGalleryQuery', - operationHash: 'bfc40da32b60f9404a4adb96b0856e3fbb04b076', + operationHash: '177fe68cb385737b0901fc9e105f0a4813e18a20', }, } as unknown as TypedDocumentString< ClientProductGalleryQueryQuery, @@ -2090,7 +2078,7 @@ export const ClientProductQueryDocument = { export const ClientSearchSuggestionsQueryDocument = { __meta__: { operationName: 'ClientSearchSuggestionsQuery', - operationHash: '47af7b9c9e0fb18b01050767daf3e765f67819ac', + operationHash: '71809c86cb940861f01bcc57dbaf57e6f41cb378', }, } as unknown as TypedDocumentString< ClientSearchSuggestionsQueryQuery, diff --git a/packages/core/src/sdk/product/useProductGalleryQuery.ts b/packages/core/src/sdk/product/useProductGalleryQuery.ts index 1f09972f24..701d576e5e 100644 --- a/packages/core/src/sdk/product/useProductGalleryQuery.ts +++ b/packages/core/src/sdk/product/useProductGalleryQuery.ts @@ -1,18 +1,17 @@ import { sendAnalyticsEvent } from '@faststore/sdk' -import { useSearch, setFacet } from '@faststore/sdk' import { gql } from '@generated' import { useQuery } from 'src/sdk/graphql/useQuery' -import { useLocalizedVariables } from './useLocalizedVariables' import { useSession } from 'src/sdk/session' +import { useLocalizedVariables } from './useLocalizedVariables' +import { Facet } from '@faststore/sdk/dist/types' import type { ClientManyProductsQueryQueryVariables, ClientProductGalleryQueryQuery as Query, ClientProductGalleryQueryQueryVariables as Variables, } from '@generated/graphql' import type { IntelligentSearchQueryEvent } from 'src/sdk/analytics/types' -import type { Facet } from '@faststore/sdk/dist/types' /** * This query is run on the browser and contains @@ -52,13 +51,10 @@ export const query = gql(` } } } -`) -export const fragment = gql(` fragment SearchEvent_metadata on SearchMetadata { isTermMisspelled logicalOperator - fuzzy } `) @@ -76,8 +72,6 @@ export const useProductGalleryQuery = ({ itemsPerPage, }: ProductGalleryQueryOptions) => { const { locale } = useSession() - const { state, setState } = useSearch() - const localizedVariables = useLocalizedVariables({ first: itemsPerPage, after: '0', @@ -86,49 +80,20 @@ export const useProductGalleryQuery = ({ selectedFacets, }) - const findFacetValue = ( - facets: Facet[], - searchParam: string - ): string | null => { - const facet = facets.find(({ key }) => key === searchParam) - return facet?.value ?? null - } - return useQuery(query, localizedVariables, { onSuccess: (data) => { - if (data) { - // Cancel query onSuccess event when redirecting - if (data?.redirect?.url) { - return - } - - const fuzzyFacetValue = findFacetValue(selectedFacets, 'fuzzy') - const operatorFacetValue = findFacetValue(selectedFacets, 'operator') - - if (!fuzzyFacetValue && !operatorFacetValue) { - setState({ - ...state, - selectedFacets: [ - ...selectedFacets, - { key: 'fuzzy', value: data.search.metadata?.fuzzy }, - { key: 'operator', value: data.search.metadata?.logicalOperator }, - ], - }) - } - - if (term) { - sendAnalyticsEvent({ - name: 'intelligent_search_query', - params: { - locale, - term, - url: window.location.href, - logicalOperator: data.search.metadata?.logicalOperator ?? 'and', - isTermMisspelled: data.search.metadata?.isTermMisspelled ?? false, - totalCount: data.search.products.pageInfo.totalCount, - }, - }) - } + if (data && term) { + sendAnalyticsEvent({ + name: 'intelligent_search_query', + params: { + locale, + term, + url: window.location.href, + logicalOperator: data.search.metadata?.logicalOperator ?? 'and', + isTermMisspelled: data.search.metadata?.isTermMisspelled ?? false, + totalCount: data.search.products.pageInfo.totalCount, + }, + }) } }, }) diff --git a/packages/core/src/sdk/search/state.ts b/packages/core/src/sdk/search/state.ts index cbae36b491..01080c1ee9 100644 --- a/packages/core/src/sdk/search/state.ts +++ b/packages/core/src/sdk/search/state.ts @@ -5,12 +5,7 @@ export const useApplySearchState = () => { const router = useRouter() return useCallback( - (url: URL) => { - const newUrl = `${url.pathname}${url.search}` - return url.searchParams.has('fuzzy') && url.searchParams.has('operator') - ? router.replace(newUrl) - : router.push(newUrl) - }, + (url: URL) => router.push(`${url.pathname}${url.search}`), [router] ) } From df0e2d3d8c4f09d7782013f7ba25d73e51d3b7a1 Mon Sep 17 00:00:00 2001 From: vtexgithubbot Date: Tue, 3 Sep 2024 15:22:00 +0000 Subject: [PATCH 022/154] [no ci] Release: 3.0.97 --- apps/site/package.json | 10 +++++----- lerna.json | 2 +- packages/api/package.json | 6 +++--- packages/cli/README.md | 16 ++++++++-------- packages/cli/package.json | 8 ++++---- packages/components/package.json | 6 +++--- packages/core/package.json | 14 +++++++------- packages/eslint-config/package.json | 2 +- packages/graphql-utils/package.json | 6 +++--- packages/lighthouse/package.json | 6 +++--- packages/sdk/package.json | 4 ++-- packages/shared/package.json | 2 +- packages/ui/package.json | 8 ++++---- 13 files changed, 45 insertions(+), 45 deletions(-) diff --git a/apps/site/package.json b/apps/site/package.json index d71920fca6..7f4ce73a1b 100644 --- a/apps/site/package.json +++ b/apps/site/package.json @@ -1,6 +1,6 @@ { "name": "site", - "version": "3.0.96", + "version": "3.0.97", "author": "Emerson Laurentino @emersonlaurentino", "license": "MIT", "private": true, @@ -10,9 +10,9 @@ "start": "next start" }, "dependencies": { - "@faststore/api": "^3.0.95", - "@faststore/sdk": "^3.0.95", - "@faststore/ui": "^3.0.96", + "@faststore/api": "^3.0.97", + "@faststore/sdk": "^3.0.97", + "@faststore/ui": "^3.0.97", "next": "13.0.7", "nextra": "^2.8.0", "nextra-theme-docs": "^2.8.0", @@ -21,7 +21,7 @@ "sass": "^1.57.1" }, "devDependencies": { - "@faststore/eslint-config": "^3.0.95", + "@faststore/eslint-config": "^3.0.97", "@types/node": "^18.11.16", "eslint": "7.32.0", "react-docgen-typescript": "^2.2.2", diff --git a/lerna.json b/lerna.json index dac33c8b06..637bcf71ee 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "3.0.96", + "version": "3.0.97", "npmClient": "yarn", "command": { "publish": { diff --git a/packages/api/package.json b/packages/api/package.json index bf96861457..83b867eda3 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/api", - "version": "3.0.95", + "version": "3.0.97", "license": "MIT", "main": "dist/cjs/src/index.js", "typings": "dist/esm/src/index.d.ts", @@ -51,8 +51,8 @@ }, "devDependencies": { "@envelop/core": "^2.6.0", - "@faststore/eslint-config": "^3.0.95", - "@faststore/shared": "^3.0.95", + "@faststore/eslint-config": "^3.0.97", + "@faststore/shared": "^3.0.97", "@graphql-codegen/cli": "2.2.0", "@graphql-codegen/typescript": "2.2.2", "@parcel/watcher": "^2.4.0", diff --git a/packages/cli/README.md b/packages/cli/README.md index 459db17a4a..6241ea998b 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -30,7 +30,7 @@ $ npm install -g @faststore/cli $ faststore COMMAND running command... $ faststore (--version) -@faststore/cli/3.0.96 linux-x64 node-v18.20.4 +@faststore/cli/3.0.97 linux-x64 node-v18.20.4 $ faststore --help [COMMAND] USAGE $ faststore COMMAND @@ -60,7 +60,7 @@ ARGUMENTS PATH The path where the FastStore being built is. Defaults to cwd. ``` -_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v3.0.96/dist/commands/build.ts)_ +_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v3.0.97/dist/commands/build.ts)_ ## `faststore cms-sync [PATH]` @@ -75,7 +75,7 @@ FLAGS -d, --dry-run ``` -_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v3.0.96/dist/commands/cms-sync.ts)_ +_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v3.0.97/dist/commands/cms-sync.ts)_ ## `faststore dev [PATH]` @@ -87,7 +87,7 @@ ARGUMENTS PATH The path where the FastStore being run is. Defaults to cwd. ``` -_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v3.0.96/dist/commands/dev.ts)_ +_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v3.0.97/dist/commands/dev.ts)_ ## `faststore generate-graphql [PATH]` @@ -102,7 +102,7 @@ FLAGS -d, --debug ``` -_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v3.0.96/dist/commands/generate-graphql.ts)_ +_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v3.0.97/dist/commands/generate-graphql.ts)_ ## `faststore help [COMMAND]` @@ -142,7 +142,7 @@ EXAMPLES $ yarn faststore init discovery ``` -_See code: [dist/commands/init.ts](https://github.com/vtex/faststore/blob/v3.0.96/dist/commands/init.ts)_ +_See code: [dist/commands/init.ts](https://github.com/vtex/faststore/blob/v3.0.97/dist/commands/init.ts)_ ## `faststore start [PATH]` @@ -154,7 +154,7 @@ ARGUMENTS PATH The path where the FastStore being run is. Defaults to cwd. ``` -_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v3.0.96/dist/commands/start.ts)_ +_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v3.0.97/dist/commands/start.ts)_ ## `faststore test [PATH]` @@ -166,5 +166,5 @@ ARGUMENTS PATH The path where the FastStore being tested is. Defaults to cwd. ``` -_See code: [dist/commands/test.ts](https://github.com/vtex/faststore/blob/v3.0.96/dist/commands/test.ts)_ +_See code: [dist/commands/test.ts](https://github.com/vtex/faststore/blob/v3.0.97/dist/commands/test.ts)_ diff --git a/packages/cli/package.json b/packages/cli/package.json index 6c013de325..6ee7a7880b 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/cli", - "version": "3.0.96", + "version": "3.0.97", "description": "FastStore CLI", "author": "Emerson Laurentino @emersonlaurentino", "bin": { @@ -18,7 +18,7 @@ ], "dependencies": { "@antfu/ni": "^0.21.12", - "@faststore/core": "^3.0.96", + "@faststore/core": "^3.0.97", "@inquirer/prompts": "^5.1.2", "@oclif/core": "^1.16.4", "@oclif/plugin-help": "^5", @@ -31,8 +31,8 @@ "path": "^0.12.7" }, "devDependencies": { - "@faststore/eslint-config": "^3.0.95", - "@faststore/shared": "^3.0.95", + "@faststore/eslint-config": "^3.0.97", + "@faststore/shared": "^3.0.97", "@types/chai": "^4", "@types/degit": "^2.8.6", "@types/fs-extra": "^9.0.13", diff --git a/packages/components/package.json b/packages/components/package.json index 7264010cc8..921d1f82e2 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/components", - "version": "3.0.96", + "version": "3.0.97", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "typings": "dist/esm/index.d.ts", @@ -35,8 +35,8 @@ "react-dom": "^18.2.0" }, "devDependencies": { - "@faststore/eslint-config": "^3.0.95", - "@faststore/shared": "^3.0.95", + "@faststore/eslint-config": "^3.0.97", + "@faststore/shared": "^3.0.97", "@testing-library/react": "^14.3.0", "@types/react": "^18.2.42", "@types/react-dom": "^18.2.17", diff --git a/packages/core/package.json b/packages/core/package.json index 9754c267e3..3bb5cec89f 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/core", - "version": "3.0.96", + "version": "3.0.97", "license": "MIT", "repository": "vtex/faststore", "browserslist": "supports es6-module and not dead", @@ -43,11 +43,11 @@ "@envelop/graphql-jit": "^1.1.1", "@envelop/parser-cache": "^2.2.0", "@envelop/validation-cache": "^2.2.0", - "@faststore/api": "^3.0.95", - "@faststore/components": "^3.0.96", - "@faststore/graphql-utils": "^3.0.95", - "@faststore/sdk": "^3.0.95", - "@faststore/ui": "^3.0.96", + "@faststore/api": "^3.0.97", + "@faststore/components": "^3.0.97", + "@faststore/graphql-utils": "^3.0.97", + "@faststore/sdk": "^3.0.97", + "@faststore/ui": "^3.0.97", "@graphql-codegen/cli": "^5.0.2", "@graphql-codegen/client-preset": "^4.2.6", "@graphql-codegen/typescript": "^4.0.7", @@ -88,7 +88,7 @@ "devDependencies": { "@cypress/code-coverage": "^3.12.1", "@envelop/testing": "^6.0.0", - "@faststore/eslint-config": "^3.0.95", + "@faststore/eslint-config": "^3.0.97", "@faststore/lighthouse": "^1.12.32", "@lhci/cli": "^0.9.0", "@testing-library/cypress": "^10.0.1", diff --git a/packages/eslint-config/package.json b/packages/eslint-config/package.json index 6983428d74..8ba46a6c3f 100644 --- a/packages/eslint-config/package.json +++ b/packages/eslint-config/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/eslint-config", - "version": "3.0.95", + "version": "3.0.97", "main": "index.js", "license": "MIT", "repository": "vtex/faststore", diff --git a/packages/graphql-utils/package.json b/packages/graphql-utils/package.json index 18b102a3b3..ef5e05cb40 100644 --- a/packages/graphql-utils/package.json +++ b/packages/graphql-utils/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/graphql-utils", - "version": "3.0.95", + "version": "3.0.97", "description": "GraphQL utilities", "repository": { "type": "git", @@ -21,8 +21,8 @@ "graphql": "^15.6.1" }, "devDependencies": { - "@faststore/eslint-config": "^3.0.95", - "@faststore/shared": "^3.0.95", + "@faststore/eslint-config": "^3.0.97", + "@faststore/shared": "^3.0.97", "cross-env": "^7.0.2", "eslint": "7.32.0", "typescript": "^4.2.4" diff --git a/packages/lighthouse/package.json b/packages/lighthouse/package.json index c6debfda0b..265bf2db75 100644 --- a/packages/lighthouse/package.json +++ b/packages/lighthouse/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/lighthouse", - "version": "3.0.95", + "version": "3.0.97", "author": "Emerson Laurentino", "license": "MIT", "repository": { @@ -24,8 +24,8 @@ "lint": "eslint src/**/*.ts" }, "devDependencies": { - "@faststore/eslint-config": "^3.0.95", - "@faststore/shared": "^3.0.95", + "@faststore/eslint-config": "^3.0.97", + "@faststore/shared": "^3.0.97", "eslint": "7.32.0", "typescript": "^4.2.4" } diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 5007c04caf..6795031e28 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/sdk", - "version": "3.0.95", + "version": "3.0.97", "description": "Hooks for creating your next component library", "license": "MIT", "repository": { @@ -37,7 +37,7 @@ "react": "^18.2.0" }, "devDependencies": { - "@faststore/shared": "^3.0.95", + "@faststore/shared": "^3.0.97", "@size-limit/preset-small-lib": "^7.0.8", "@testing-library/react-hooks": "^8.0.1", "fake-indexeddb": "^3.1.3", diff --git a/packages/shared/package.json b/packages/shared/package.json index efb3f0db7c..2da2bebf92 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/shared", - "version": "3.0.95", + "version": "3.0.97", "private": true, "files": [ "tsconfig.json" diff --git a/packages/ui/package.json b/packages/ui/package.json index 88d61c678a..0706e1d060 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/ui", - "version": "3.0.96", + "version": "3.0.97", "description": "A lightweight, framework agnostic component library for React", "author": "emersonlaurentino", "license": "MIT", @@ -48,7 +48,7 @@ } ], "dependencies": { - "@faststore/components": "^3.0.96", + "@faststore/components": "^3.0.97", "include-media": "^1.4.10", "modern-normalize": "^1.1.0", "react-swipeable": "^7.0.0", @@ -59,8 +59,8 @@ "react-dom": "^18.2.0" }, "devDependencies": { - "@faststore/eslint-config": "^3.0.95", - "@faststore/shared": "^3.0.95", + "@faststore/eslint-config": "^3.0.97", + "@faststore/shared": "^3.0.97", "@size-limit/preset-small-lib": "^7.0.8", "@types/tabbable": "^3.1.1", "babel-loader": "^8.2.5", From 2857b66d52a1f6cf17a2e5da9d5aa3e16f658a3c Mon Sep 17 00:00:00 2001 From: Emerson Laurentino Date: Wed, 4 Sep 2024 20:28:48 -0300 Subject: [PATCH 023/154] Fix: Add 'show-invisible-items' parameter to IntelligentSearch API (#2431) In this PR we add the `show-invisible-items` param to IS api in order to enhance the invisible SKU --- packages/api/mocks/ValidateCartMutation.ts | 2 +- packages/api/src/platforms/vtex/clients/search/index.ts | 6 ++++++ packages/api/src/platforms/vtex/loaders/sku.ts | 6 +++++- packages/api/src/platforms/vtex/resolvers/validateCart.ts | 4 ++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/api/mocks/ValidateCartMutation.ts b/packages/api/mocks/ValidateCartMutation.ts index c61cb8cf55..f46b8b327b 100644 --- a/packages/api/mocks/ValidateCartMutation.ts +++ b/packages/api/mocks/ValidateCartMutation.ts @@ -347,7 +347,7 @@ export const checkoutOrderFormCustomDataInvalidFetch = { } export const productSearchPage1Count1Fetch = { - info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=1&count=1&query=sku%3A2737806&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false', + info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=1&count=1&query=sku%3A2737806&sort=&fuzzy=auto&locale=en-US&show-invisible-items=true&hideUnavailableItems=false', init: undefined, options: { storeCookies: expect.any(Function) }, result: { diff --git a/packages/api/src/platforms/vtex/clients/search/index.ts b/packages/api/src/platforms/vtex/clients/search/index.ts index 66e6fad8c4..d2c9e7834b 100644 --- a/packages/api/src/platforms/vtex/clients/search/index.ts +++ b/packages/api/src/platforms/vtex/clients/search/index.ts @@ -32,6 +32,7 @@ export interface SearchArgs { selectedFacets?: SelectedFacet[] fuzzy?: '0' | '1' | 'auto' hideUnavailableItems?: boolean + showInvisibleItems?: boolean } export interface ProductLocator { @@ -112,6 +113,7 @@ export const IntelligentSearch = ( selectedFacets = [], type, fuzzy = 'auto', + showInvisibleItems, }: SearchArgs): Promise => { const params = new URLSearchParams({ page: (page + 1).toString(), @@ -122,6 +124,10 @@ export const IntelligentSearch = ( locale: ctx.storage.locale, }) + if (showInvisibleItems) { + params.append('show-invisible-items', 'true') + } + if (hideUnavailableItems !== undefined) { params.append('hideUnavailableItems', hideUnavailableItems.toString()) } diff --git a/packages/api/src/platforms/vtex/loaders/sku.ts b/packages/api/src/platforms/vtex/loaders/sku.ts index e68e530f06..c8bfb1a0ab 100644 --- a/packages/api/src/platforms/vtex/loaders/sku.ts +++ b/packages/api/src/platforms/vtex/loaders/sku.ts @@ -7,11 +7,15 @@ import type { Options } from '..' import type { Clients } from '../clients' export const getSkuLoader = (_: Options, clients: Clients) => { - const loader = async (skuIds: readonly string[]) => { + const loader = async (keys: readonly string[]) => { + const skuIds = keys.map((key) => key.split('-')[0]); + const showInvisibleItems = keys.some((key) => key.split('-')[1] === 'invisibleItems') + const { products } = await clients.search.products({ query: `sku:${skuIds.join(';')}`, page: 0, count: skuIds.length, + showInvisibleItems }) const skuBySkuId = products.reduce((acc, product) => { diff --git a/packages/api/src/platforms/vtex/resolvers/validateCart.ts b/packages/api/src/platforms/vtex/resolvers/validateCart.ts index b376f522cb..66b0d23cc1 100644 --- a/packages/api/src/platforms/vtex/resolvers/validateCart.ts +++ b/packages/api/src/platforms/vtex/resolvers/validateCart.ts @@ -156,7 +156,7 @@ const orderFormToCart = async ( orderNumber: form.orderFormId, acceptedOffer: form.items.map(async (item) => ({ ...item, - product: await skuLoader.load(item.id), + product: await skuLoader.load(`${item.id}-invisibleItems`), })), }, messages: form.messages.map(({ text, status }) => ({ @@ -316,7 +316,7 @@ export const validateCart = async ( const orderNumber = order?.orderNumber ? order.orderNumber : getCookieCheckoutOrderNumber(ctx.headers.cookie, 'checkout.vtex.com') - + const { acceptedOffer, shouldSplitItem } = order const { clients: { commerce }, From 8493dc04b0b2d3a420fb8796ca40bf25a5a4079d Mon Sep 17 00:00:00 2001 From: vtexgithubbot Date: Wed, 4 Sep 2024 23:33:59 +0000 Subject: [PATCH 024/154] [no ci] Release: 3.0.98 --- apps/site/package.json | 4 ++-- lerna.json | 2 +- packages/api/package.json | 2 +- packages/cli/README.md | 16 ++++++++-------- packages/cli/package.json | 4 ++-- packages/core/package.json | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/apps/site/package.json b/apps/site/package.json index 7f4ce73a1b..b109f65900 100644 --- a/apps/site/package.json +++ b/apps/site/package.json @@ -1,6 +1,6 @@ { "name": "site", - "version": "3.0.97", + "version": "3.0.98", "author": "Emerson Laurentino @emersonlaurentino", "license": "MIT", "private": true, @@ -10,7 +10,7 @@ "start": "next start" }, "dependencies": { - "@faststore/api": "^3.0.97", + "@faststore/api": "^3.0.98", "@faststore/sdk": "^3.0.97", "@faststore/ui": "^3.0.97", "next": "13.0.7", diff --git a/lerna.json b/lerna.json index 637bcf71ee..c0f9da2540 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "3.0.97", + "version": "3.0.98", "npmClient": "yarn", "command": { "publish": { diff --git a/packages/api/package.json b/packages/api/package.json index 83b867eda3..5173696627 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/api", - "version": "3.0.97", + "version": "3.0.98", "license": "MIT", "main": "dist/cjs/src/index.js", "typings": "dist/esm/src/index.d.ts", diff --git a/packages/cli/README.md b/packages/cli/README.md index 6241ea998b..5bfee2683c 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -30,7 +30,7 @@ $ npm install -g @faststore/cli $ faststore COMMAND running command... $ faststore (--version) -@faststore/cli/3.0.97 linux-x64 node-v18.20.4 +@faststore/cli/3.0.98 linux-x64 node-v18.20.4 $ faststore --help [COMMAND] USAGE $ faststore COMMAND @@ -60,7 +60,7 @@ ARGUMENTS PATH The path where the FastStore being built is. Defaults to cwd. ``` -_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v3.0.97/dist/commands/build.ts)_ +_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v3.0.98/dist/commands/build.ts)_ ## `faststore cms-sync [PATH]` @@ -75,7 +75,7 @@ FLAGS -d, --dry-run ``` -_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v3.0.97/dist/commands/cms-sync.ts)_ +_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v3.0.98/dist/commands/cms-sync.ts)_ ## `faststore dev [PATH]` @@ -87,7 +87,7 @@ ARGUMENTS PATH The path where the FastStore being run is. Defaults to cwd. ``` -_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v3.0.97/dist/commands/dev.ts)_ +_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v3.0.98/dist/commands/dev.ts)_ ## `faststore generate-graphql [PATH]` @@ -102,7 +102,7 @@ FLAGS -d, --debug ``` -_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v3.0.97/dist/commands/generate-graphql.ts)_ +_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v3.0.98/dist/commands/generate-graphql.ts)_ ## `faststore help [COMMAND]` @@ -142,7 +142,7 @@ EXAMPLES $ yarn faststore init discovery ``` -_See code: [dist/commands/init.ts](https://github.com/vtex/faststore/blob/v3.0.97/dist/commands/init.ts)_ +_See code: [dist/commands/init.ts](https://github.com/vtex/faststore/blob/v3.0.98/dist/commands/init.ts)_ ## `faststore start [PATH]` @@ -154,7 +154,7 @@ ARGUMENTS PATH The path where the FastStore being run is. Defaults to cwd. ``` -_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v3.0.97/dist/commands/start.ts)_ +_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v3.0.98/dist/commands/start.ts)_ ## `faststore test [PATH]` @@ -166,5 +166,5 @@ ARGUMENTS PATH The path where the FastStore being tested is. Defaults to cwd. ``` -_See code: [dist/commands/test.ts](https://github.com/vtex/faststore/blob/v3.0.97/dist/commands/test.ts)_ +_See code: [dist/commands/test.ts](https://github.com/vtex/faststore/blob/v3.0.98/dist/commands/test.ts)_ diff --git a/packages/cli/package.json b/packages/cli/package.json index 6ee7a7880b..8cecc3e508 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/cli", - "version": "3.0.97", + "version": "3.0.98", "description": "FastStore CLI", "author": "Emerson Laurentino @emersonlaurentino", "bin": { @@ -18,7 +18,7 @@ ], "dependencies": { "@antfu/ni": "^0.21.12", - "@faststore/core": "^3.0.97", + "@faststore/core": "^3.0.98", "@inquirer/prompts": "^5.1.2", "@oclif/core": "^1.16.4", "@oclif/plugin-help": "^5", diff --git a/packages/core/package.json b/packages/core/package.json index 3bb5cec89f..faa309dacf 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/core", - "version": "3.0.97", + "version": "3.0.98", "license": "MIT", "repository": "vtex/faststore", "browserslist": "supports es6-module and not dead", @@ -43,7 +43,7 @@ "@envelop/graphql-jit": "^1.1.1", "@envelop/parser-cache": "^2.2.0", "@envelop/validation-cache": "^2.2.0", - "@faststore/api": "^3.0.97", + "@faststore/api": "^3.0.98", "@faststore/components": "^3.0.97", "@faststore/graphql-utils": "^3.0.97", "@faststore/sdk": "^3.0.97", From 73d540e863c5b130dbac4d50552da918bedd3c20 Mon Sep 17 00:00:00 2001 From: JoelsonFerreiraM3 <121126786+JoelsonFerreiraM3@users.noreply.github.com> Date: Thu, 5 Sep 2024 13:02:07 -0300 Subject: [PATCH 025/154] fix: validateCart mutation merging orderForm items with assemply options (#2401) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What's the purpose of this pull request? Fix the validateCart mutation resolver that is overriding the orderForm for items that should be splitted. ## How it works? When adding different assembly options for the same product, it must be kept separate in the orderForm. To prevent this merge, the parentItemIndex field is checked to see if that item is associated with the assembly of another item. ## How to test it? In https://devjoelson--jwpepperdev.myvtex.com/1309475/p Add different combinations to your cart, for example: ![image](https://github.com/user-attachments/assets/b86c9367-f025-4fae-a221-350e94f5ee7a) ![image](https://github.com/user-attachments/assets/48792798-a636-4c01-990a-25522570f267) As a result, we will have the same product duplicated in the cart: ![image](https://github.com/user-attachments/assets/c8a95ca8-481b-475b-bf94-5994b5b4ddc8) When we copy and paste the cookie from orderForm to faststore, it should not change the cart as it does in this example: ![image](https://github.com/user-attachments/assets/1bd4c6b9-bd2b-4a49-bb37-6bc7e1df1a62) and then, when updating the cart in IO, we have the change that shouldn't happen: ![image](https://github.com/user-attachments/assets/54b97ec6-01ac-454e-aef9-d5d989bf2d83) --------- Co-authored-by: Lucas Feijó --- .../platforms/vtex/resolvers/validateCart.ts | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/api/src/platforms/vtex/resolvers/validateCart.ts b/packages/api/src/platforms/vtex/resolvers/validateCart.ts index 66b0d23cc1..4b5a96d0c6 100644 --- a/packages/api/src/platforms/vtex/resolvers/validateCart.ts +++ b/packages/api/src/platforms/vtex/resolvers/validateCart.ts @@ -109,10 +109,20 @@ const equals = (storeOrder: IStoreOrder, orderForm: OrderForm) => { return isSameOrder && orderItemsAreSync } +function hasChildItem(items: OrderFormItem[], itemId: string) { + return items?.some(item => item.parentItemIndex && items[item.parentItemIndex].id === itemId) +} + +function hasParentItem(items: OrderFormItem[], itemId: string) { + return items?.some(item => item.id === itemId && item.parentItemIndex !== null) +} + const joinItems = (form: OrderForm) => { const itemsById = form.items.reduce( - (acc, item) => { - const id = getId(orderFormItemToOffer(item)) + (acc, item, idx) => { + const id = hasParentItem(form.items, item.id) || hasChildItem(form.items, item.id) ? + `${getId(orderFormItemToOffer(item))}::${idx}` : + getId(orderFormItemToOffer(item)) if (!acc[id]) { acc[id] = [] @@ -377,6 +387,13 @@ export const validateCart = async ( // Update existing items const [head, ...tail] = maybeOriginItem + + if(hasParentItem(orderForm.items, head.itemOffered.sku) || hasChildItem(orderForm.items, head.itemOffered.sku)) { + acc.itemsToUpdate.push(head) + + return acc + } + const totalQuantity = items.reduce((acc, curr) => acc + curr.quantity, 0) // set total quantity to first item From c37b1d1e9dd1965d309fdf4bd52e176ee3e4eecc Mon Sep 17 00:00:00 2001 From: vtexgithubbot Date: Thu, 5 Sep 2024 16:08:54 +0000 Subject: [PATCH 026/154] [no ci] Release: 3.0.99 --- apps/site/package.json | 4 ++-- lerna.json | 2 +- packages/api/package.json | 2 +- packages/cli/README.md | 16 ++++++++-------- packages/cli/package.json | 4 ++-- packages/core/package.json | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/apps/site/package.json b/apps/site/package.json index b109f65900..1401e75264 100644 --- a/apps/site/package.json +++ b/apps/site/package.json @@ -1,6 +1,6 @@ { "name": "site", - "version": "3.0.98", + "version": "3.0.99", "author": "Emerson Laurentino @emersonlaurentino", "license": "MIT", "private": true, @@ -10,7 +10,7 @@ "start": "next start" }, "dependencies": { - "@faststore/api": "^3.0.98", + "@faststore/api": "^3.0.99", "@faststore/sdk": "^3.0.97", "@faststore/ui": "^3.0.97", "next": "13.0.7", diff --git a/lerna.json b/lerna.json index c0f9da2540..510a38644b 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "3.0.98", + "version": "3.0.99", "npmClient": "yarn", "command": { "publish": { diff --git a/packages/api/package.json b/packages/api/package.json index 5173696627..dcea58df66 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/api", - "version": "3.0.98", + "version": "3.0.99", "license": "MIT", "main": "dist/cjs/src/index.js", "typings": "dist/esm/src/index.d.ts", diff --git a/packages/cli/README.md b/packages/cli/README.md index 5bfee2683c..9d4b4eed71 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -30,7 +30,7 @@ $ npm install -g @faststore/cli $ faststore COMMAND running command... $ faststore (--version) -@faststore/cli/3.0.98 linux-x64 node-v18.20.4 +@faststore/cli/3.0.99 linux-x64 node-v18.20.4 $ faststore --help [COMMAND] USAGE $ faststore COMMAND @@ -60,7 +60,7 @@ ARGUMENTS PATH The path where the FastStore being built is. Defaults to cwd. ``` -_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v3.0.98/dist/commands/build.ts)_ +_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v3.0.99/dist/commands/build.ts)_ ## `faststore cms-sync [PATH]` @@ -75,7 +75,7 @@ FLAGS -d, --dry-run ``` -_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v3.0.98/dist/commands/cms-sync.ts)_ +_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v3.0.99/dist/commands/cms-sync.ts)_ ## `faststore dev [PATH]` @@ -87,7 +87,7 @@ ARGUMENTS PATH The path where the FastStore being run is. Defaults to cwd. ``` -_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v3.0.98/dist/commands/dev.ts)_ +_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v3.0.99/dist/commands/dev.ts)_ ## `faststore generate-graphql [PATH]` @@ -102,7 +102,7 @@ FLAGS -d, --debug ``` -_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v3.0.98/dist/commands/generate-graphql.ts)_ +_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v3.0.99/dist/commands/generate-graphql.ts)_ ## `faststore help [COMMAND]` @@ -142,7 +142,7 @@ EXAMPLES $ yarn faststore init discovery ``` -_See code: [dist/commands/init.ts](https://github.com/vtex/faststore/blob/v3.0.98/dist/commands/init.ts)_ +_See code: [dist/commands/init.ts](https://github.com/vtex/faststore/blob/v3.0.99/dist/commands/init.ts)_ ## `faststore start [PATH]` @@ -154,7 +154,7 @@ ARGUMENTS PATH The path where the FastStore being run is. Defaults to cwd. ``` -_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v3.0.98/dist/commands/start.ts)_ +_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v3.0.99/dist/commands/start.ts)_ ## `faststore test [PATH]` @@ -166,5 +166,5 @@ ARGUMENTS PATH The path where the FastStore being tested is. Defaults to cwd. ``` -_See code: [dist/commands/test.ts](https://github.com/vtex/faststore/blob/v3.0.98/dist/commands/test.ts)_ +_See code: [dist/commands/test.ts](https://github.com/vtex/faststore/blob/v3.0.99/dist/commands/test.ts)_ diff --git a/packages/cli/package.json b/packages/cli/package.json index 8cecc3e508..c3f04d2bd9 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/cli", - "version": "3.0.98", + "version": "3.0.99", "description": "FastStore CLI", "author": "Emerson Laurentino @emersonlaurentino", "bin": { @@ -18,7 +18,7 @@ ], "dependencies": { "@antfu/ni": "^0.21.12", - "@faststore/core": "^3.0.98", + "@faststore/core": "^3.0.99", "@inquirer/prompts": "^5.1.2", "@oclif/core": "^1.16.4", "@oclif/plugin-help": "^5", diff --git a/packages/core/package.json b/packages/core/package.json index faa309dacf..9ae828ac72 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/core", - "version": "3.0.98", + "version": "3.0.99", "license": "MIT", "repository": "vtex/faststore", "browserslist": "supports es6-module and not dead", @@ -43,7 +43,7 @@ "@envelop/graphql-jit": "^1.1.1", "@envelop/parser-cache": "^2.2.0", "@envelop/validation-cache": "^2.2.0", - "@faststore/api": "^3.0.98", + "@faststore/api": "^3.0.99", "@faststore/components": "^3.0.97", "@faststore/graphql-utils": "^3.0.97", "@faststore/sdk": "^3.0.97", From 0917e4e6e0350688352ddc1c6c71009ab1b1c6bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lar=C3=ADcia=20Mota?= Date: Tue, 10 Sep 2024 10:41:46 -0300 Subject: [PATCH 027/154] Feat: Make simulationBehavior search param configurable (#2439) ## What's the purpose of this pull request? Make the `simulationBehavior` param from IS configurable through the faststore.config file. ## How it works? When the `simulationBehavior` is present on the config file it'll be used on the IS fetch, example: `https://{{account}}.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/category-1/office/trade-policy/1?page=1&count=12&query=&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false&simulationBehavior=skip` Otherwise, if it's not present, it'll continue working as it already was: `https://{{account}}.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/category-1/office/trade-policy/1?page=1&count=12&query=&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false` ## How to test it? Run `yarn dev` and ensure it's working as expected. Then, add the `simulationBehavior` param to the `faststore.config.default.js` file inside the `api` object. Use one of the following values: `default`, `skip` or `only1P`. Also, ensure it's working as expected. ### Starters Deploy Preview I've set the `simulationBehavior` to `skip` on [this](https://github.com/vtex-sites/starter.store/pull/524/files) preview: https://sfj-2fb19ff--starter.preview.vtex.app/ And in this [one](https://github.com/vtex-sites/starter.store/pull/525/files) there isn't a `simulationBehavior` being set on faststore.config: https://sfj-e8d957e--starter.preview.vtex.app/ One visible difference is that the Magic Mouse product when the `simulationBehavior` is `skip`, IS returns an `AvailableQuantity` of `10000` while when the `simulationBehavior` isn't configured it returns `0`. I've confirmed using the IS API directly: - `https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/productClusterIds/140/trade-policy/1?page=1&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false&count=10&query=` and - `https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/productClusterIds/140/trade-policy/1?page=1&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false&simulationBehavior=skip&count=10&query=` Here are the screenshots showing the previews and the IS return: | SimulationBehavior = skip | SimulationBehavior not on config | | ---- | ---- | |Screenshot 2024-09-05 at 17 08 34 | Screenshot 2024-09-05 at 17 09 29| | Screenshot 2024-09-05 at 17 35 12|Screenshot 2024-09-05 at 17 35 20 | ## References - [Slack thread](https://vtex.slack.com/archives/C03L3CRCDC4/p1725470335934909) --- packages/api/mocks/AllProductsQuery.ts | 2 +- packages/api/mocks/ProductQuery.ts | 2 +- packages/api/mocks/RedirectQuery.ts | 62 +++++++++---------- packages/api/mocks/SearchQuery.ts | 4 +- .../platforms/vtex/clients/search/index.ts | 14 +++-- packages/api/src/platforms/vtex/index.ts | 11 ++-- packages/api/test/mutations.test.ts | 6 +- packages/api/test/queries.test.ts | 59 +++++++++--------- packages/core/src/server/options.ts | 2 + 9 files changed, 85 insertions(+), 77 deletions(-) diff --git a/packages/api/mocks/AllProductsQuery.ts b/packages/api/mocks/AllProductsQuery.ts index 437b2426b2..3e23e96b9d 100644 --- a/packages/api/mocks/AllProductsQuery.ts +++ b/packages/api/mocks/AllProductsQuery.ts @@ -78,7 +78,7 @@ export const AllProductsQueryFirst5 = `query AllProducts { ` export const productSearchPage1Count5Fetch = { - info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false', + info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false&simulationBehavior=skip', init: undefined, options: { storeCookies: expect.any(Function) }, result: { diff --git a/packages/api/mocks/ProductQuery.ts b/packages/api/mocks/ProductQuery.ts index 19d9c13fd2..b9b72a4cbc 100644 --- a/packages/api/mocks/ProductQuery.ts +++ b/packages/api/mocks/ProductQuery.ts @@ -63,7 +63,7 @@ export const ProductByIdQuery = `query ProductQuery { ` export const productSearchFetch = { - info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=1&count=1&query=sku%3A64953394&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false', + info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=1&count=1&query=sku%3A64953394&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false&simulationBehavior=skip', init: undefined, options: { storeCookies: expect.any(Function) }, result: { diff --git a/packages/api/mocks/RedirectQuery.ts b/packages/api/mocks/RedirectQuery.ts index 485bf99123..1a1b1f1c21 100644 --- a/packages/api/mocks/RedirectQuery.ts +++ b/packages/api/mocks/RedirectQuery.ts @@ -6,36 +6,36 @@ export const RedirectQueryTermTech = `query RedirectSearch { ` export const redirectTermTechFetch = { - info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=2&count=1&query=tech&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false', - init: undefined, - options: { storeCookies: expect.any(Function) }, - result: { - products: [], - recordsFiltered: 0, - fuzzy: 'auto', - operator: 'and', - redirect: '/technology', - translated: false, - pagination: { - count: 1, - current: { - index: 0, - }, - before: [], - after: [], - perPage: 0, - next: { - index: 0, - }, - previous: { - index: 0, - }, - first: { - index: 0, - }, - last: { - index: 0, - }, - }, + info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/trade-policy/1?page=2&count=1&query=tech&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false&simulationBehavior=skip', + init: undefined, + options: { storeCookies: expect.any(Function) }, + result: { + products: [], + recordsFiltered: 0, + fuzzy: 'auto', + operator: 'and', + redirect: '/technology', + translated: false, + pagination: { + count: 1, + current: { + index: 0, + }, + before: [], + after: [], + perPage: 0, + next: { + index: 0, + }, + previous: { + index: 0, + }, + first: { + index: 0, + }, + last: { + index: 0, + }, }, + }, } diff --git a/packages/api/mocks/SearchQuery.ts b/packages/api/mocks/SearchQuery.ts index cab1117ff7..1d426b9c04 100644 --- a/packages/api/mocks/SearchQuery.ts +++ b/packages/api/mocks/SearchQuery.ts @@ -101,7 +101,7 @@ export const SearchQueryFirst5Products = `query SearchQuery { }` export const productSearchCategory1Fetch = { - info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/category-1/office/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false', + info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/product_search/category-1/office/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false&simulationBehavior=skip', init: undefined, options: { storeCookies: expect.any(Function) }, result: { @@ -1395,7 +1395,7 @@ export const productSearchCategory1Fetch = { } export const attributeSearchCategory1Fetch = { - info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/facets/category-1/office/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false', + info: 'https://storeframework.vtexcommercestable.com.br/api/io/_v/api/intelligent-search/facets/category-1/office/trade-policy/1?page=1&count=5&query=&sort=&fuzzy=auto&locale=en-US&hideUnavailableItems=false&simulationBehavior=skip', init: undefined, options: { storeCookies: expect.any(Function) }, result: { diff --git a/packages/api/src/platforms/vtex/clients/search/index.ts b/packages/api/src/platforms/vtex/clients/search/index.ts index d2c9e7834b..e8331c9f2b 100644 --- a/packages/api/src/platforms/vtex/clients/search/index.ts +++ b/packages/api/src/platforms/vtex/clients/search/index.ts @@ -1,17 +1,17 @@ -import { fetchAPI } from '../fetch' -import type { IStoreSelectedFacet } from '../../../../__generated__/schema' import type { Context, Options } from '../../' +import type { IStoreSelectedFacet } from '../../../../__generated__/schema' +import { getStoreCookie } from '../../utils/cookies' import type { SelectedFacet } from '../../utils/facets' +import { fetchAPI } from '../fetch' import type { Facet, - FacetValueBoolean, FacetSearchResult, + FacetValueBoolean, } from './types/FacetSearchResult' import type { ProductSearchResult, Suggestion, } from './types/ProductSearchResult' -import { getStoreCookie } from '../../utils/cookies' export type Sort = | 'price:desc' @@ -49,7 +49,7 @@ export const isFacetBoolean = ( ): facet is Facet => facet.type === 'TEXT' export const IntelligentSearch = ( - { account, environment, hideUnavailableItems }: Options, + { account, environment, hideUnavailableItems, simulationBehavior }: Options, ctx: Context ) => { const base = `https://${account}.${environment}.com.br/api/io` @@ -132,6 +132,10 @@ export const IntelligentSearch = ( params.append('hideUnavailableItems', hideUnavailableItems.toString()) } + if (simulationBehavior !== undefined) { + params.append('simulationBehavior', simulationBehavior.toString()) + } + const pathname = addDefaultFacets(selectedFacets) .map(({ key, value }) => `${key}/${value}`) .join('/') diff --git a/packages/api/src/platforms/vtex/index.ts b/packages/api/src/platforms/vtex/index.ts index a815793d4e..ba26455b95 100644 --- a/packages/api/src/platforms/vtex/index.ts +++ b/packages/api/src/platforms/vtex/index.ts @@ -1,4 +1,7 @@ +import type { Clients } from './clients' import { getClients } from './clients' +import type { SearchArgs } from './clients/search' +import type { Loaders } from './loaders' import { getLoaders } from './loaders' import { StoreAggregateOffer } from './resolvers/aggregateOffer' import { StoreAggregateRating } from './resolvers/aggregateRating' @@ -6,7 +9,7 @@ import { StoreCollection } from './resolvers/collection' import { StoreFacet, StoreFacetBoolean, - StoreFacetRange, + StoreFacetRange } from './resolvers/facet' import { StoreFacetValueBoolean } from './resolvers/faceValue' import { Mutation } from './resolvers/mutation' @@ -21,11 +24,8 @@ import { StoreSearchResult } from './resolvers/searchResult' import { StoreSeo } from './resolvers/seo' import { ShippingSLA } from './resolvers/shippingSLA' import { SkuVariants } from './resolvers/skuVariations' -import ChannelMarshal from './utils/channel' -import type { Loaders } from './loaders' -import type { Clients } from './clients' import type { Channel } from './utils/channel' -import type { SearchArgs } from './clients/search' +import ChannelMarshal from './utils/channel' export interface Options { platform: 'vtex' @@ -36,6 +36,7 @@ export interface Options { channel: string locale: string hideUnavailableItems: boolean + simulationBehavior?: 'default' | 'skip' | 'only1P' incrementAddress: boolean flags?: FeatureFlags } diff --git a/packages/api/test/mutations.test.ts b/packages/api/test/mutations.test.ts index 4a94d6eade..09dc13ccd9 100644 --- a/packages/api/test/mutations.test.ts +++ b/packages/api/test/mutations.test.ts @@ -1,5 +1,6 @@ import { execute, parse } from 'graphql' +import { salesChannelStaleFetch } from '../mocks/salesChannel' import { checkoutOrderFormCustomDataInvalidFetch, checkoutOrderFormCustomDataStaleFetch, @@ -14,9 +15,8 @@ import { ValidateCartMutation, ValidCart, } from '../mocks/ValidateCartMutation' -import { getContextFactory, getSchema } from '../src' -import { salesChannelStaleFetch } from '../mocks/salesChannel' import type { Options } from '../src' +import { getContextFactory, getSchema } from '../src' const apiOptions = { platform: 'vtex', @@ -106,7 +106,7 @@ test('`validateCart` mutation should return `null` when a valid cart is passed', expect(mockedFetch).toHaveBeenCalledWith( fetchAPICall.info, fetchAPICall.init, - fetchAPICall.options, + fetchAPICall.options ) }) diff --git a/packages/api/test/queries.test.ts b/packages/api/test/queries.test.ts index 677d2946fd..78e4f772b5 100644 --- a/packages/api/test/queries.test.ts +++ b/packages/api/test/queries.test.ts @@ -1,44 +1,44 @@ import { execute, parse } from 'graphql' -import type { Options } from '../src' -import { getSchema, getContextFactory } from '../src' +import { + AllCollectionsQueryFirst5, + catalogBrandListFetch, + catalogCategory3Fetch, + catalogPageTypeAcer, + catalogPageTypeAdidas, + catalogPageTypeBrand, + catalogPageTypeIRobot, + catalogPageTypeSkechers +} from '../mocks/AllCollectionsQuery' import { AllProductsQueryFirst5, - productSearchPage1Count5Fetch, + productSearchPage1Count5Fetch } from '../mocks/AllProductsQuery' import { CollectionDesksQuery, pageTypeDesksFetch, pageTypeOfficeDesksFetch, - pageTypeOfficeFetch, + pageTypeOfficeFetch } from '../mocks/CollectionQuery' import { ProductByIdQuery, productSearchFetch } from '../mocks/ProductQuery' import { - AllCollectionsQueryFirst5, - catalogBrandListFetch, - catalogCategory3Fetch, - catalogPageTypeAcer, - catalogPageTypeAdidas, - catalogPageTypeBrand, - catalogPageTypeIRobot, - catalogPageTypeSkechers, -} from '../mocks/AllCollectionsQuery' + RedirectQueryTermTech, + redirectTermTechFetch +} from '../mocks/RedirectQuery' +import { salesChannelStaleFetch } from '../mocks/salesChannel' import { - SearchQueryFirst5Products, - productSearchCategory1Fetch, attributeSearchCategory1Fetch, + productSearchCategory1Fetch, + SearchQueryFirst5Products } from '../mocks/SearchQuery' -import { salesChannelStaleFetch } from '../mocks/salesChannel' +import { regionFetch, SellersQueryResult } from '../mocks/SellersQuery' import { - shippingSimulationFetch, addressFetch, - ShippingSimulationQueryResult, + shippingSimulationFetch, + ShippingSimulationQueryResult } from '../mocks/ShippingQuery' -import { - RedirectQueryTermTech, - redirectTermTechFetch, -} from '../mocks/RedirectQuery' -import { SellersQueryResult, regionFetch } from '../mocks/SellersQuery' +import type { Options } from '../src' +import { getContextFactory, getSchema } from '../src' const apiOptions = { platform: 'vtex', @@ -48,6 +48,7 @@ const apiOptions = { locale: 'en-US', subDomainPrefix: ['www'], hideUnavailableItems: false, + simulationBehavior: 'skip', incrementAddress: false, flags: { enableOrderFormSync: true, @@ -128,7 +129,7 @@ test('`collection` query', async () => { expect(mockedFetch).toHaveBeenCalledWith( fetchAPICall.info, fetchAPICall.init, - fetchAPICall.options, + fetchAPICall.options ) }) @@ -150,7 +151,7 @@ test('`product` query', async () => { expect(mockedFetch).toHaveBeenCalledWith( fetchAPICall.info, fetchAPICall.init, - fetchAPICall.options, + fetchAPICall.options ) }) @@ -180,7 +181,7 @@ test('`allCollections` query', async () => { expect(mockedFetch).toHaveBeenCalledWith( fetchAPICall.info, fetchAPICall.init, - fetchAPICall.options, + fetchAPICall.options ) }) @@ -202,7 +203,7 @@ test('`allProducts` query', async () => { expect(mockedFetch).toHaveBeenCalledWith( fetchAPICall.info, fetchAPICall.init, - fetchAPICall.options, + fetchAPICall.options ) }) @@ -228,7 +229,7 @@ test('`search` query', async () => { expect(mockedFetch).toHaveBeenCalledWith( fetchAPICall.info, fetchAPICall.init, - fetchAPICall.options, + fetchAPICall.options ) }) @@ -293,7 +294,7 @@ test('`sellers` query', async () => { expect(mockedFetch).toHaveBeenCalledWith( fetchAPICall.info, fetchAPICall.init, - fetchAPICall.options, + fetchAPICall.options ) }) expect(response).toMatchSnapshot() diff --git a/packages/core/src/server/options.ts b/packages/core/src/server/options.ts index 5d75d8bed6..b40e7e3654 100644 --- a/packages/core/src/server/options.ts +++ b/packages/core/src/server/options.ts @@ -8,6 +8,8 @@ export const apiOptions: APIOptions = { environment: storeConfig.api.environment as APIOptions['environment'], subDomainPrefix: storeConfig.api.subDomainPrefix ?? ['www'], hideUnavailableItems: storeConfig.api.hideUnavailableItems, + simulationBehavior: (storeConfig.api as Record) + .simulationBehavior, incrementAddress: storeConfig.api.incrementAddress, channel: storeConfig.session.channel, locale: storeConfig.session.locale, From 3670e7871aaf7ada1b32287e890b076c7f81c54f Mon Sep 17 00:00:00 2001 From: vtexgithubbot Date: Tue, 10 Sep 2024 13:46:59 +0000 Subject: [PATCH 028/154] [no ci] Release: 3.0.100 --- apps/site/package.json | 4 ++-- lerna.json | 2 +- packages/api/package.json | 2 +- packages/cli/README.md | 16 ++++++++-------- packages/cli/package.json | 4 ++-- packages/core/package.json | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/apps/site/package.json b/apps/site/package.json index 1401e75264..6854b23a08 100644 --- a/apps/site/package.json +++ b/apps/site/package.json @@ -1,6 +1,6 @@ { "name": "site", - "version": "3.0.99", + "version": "3.0.100", "author": "Emerson Laurentino @emersonlaurentino", "license": "MIT", "private": true, @@ -10,7 +10,7 @@ "start": "next start" }, "dependencies": { - "@faststore/api": "^3.0.99", + "@faststore/api": "^3.0.100", "@faststore/sdk": "^3.0.97", "@faststore/ui": "^3.0.97", "next": "13.0.7", diff --git a/lerna.json b/lerna.json index 510a38644b..70d1c4190e 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "3.0.99", + "version": "3.0.100", "npmClient": "yarn", "command": { "publish": { diff --git a/packages/api/package.json b/packages/api/package.json index dcea58df66..e79d36acfd 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/api", - "version": "3.0.99", + "version": "3.0.100", "license": "MIT", "main": "dist/cjs/src/index.js", "typings": "dist/esm/src/index.d.ts", diff --git a/packages/cli/README.md b/packages/cli/README.md index 9d4b4eed71..349d19269c 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -30,7 +30,7 @@ $ npm install -g @faststore/cli $ faststore COMMAND running command... $ faststore (--version) -@faststore/cli/3.0.99 linux-x64 node-v18.20.4 +@faststore/cli/3.0.100 linux-x64 node-v18.20.4 $ faststore --help [COMMAND] USAGE $ faststore COMMAND @@ -60,7 +60,7 @@ ARGUMENTS PATH The path where the FastStore being built is. Defaults to cwd. ``` -_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v3.0.99/dist/commands/build.ts)_ +_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v3.0.100/dist/commands/build.ts)_ ## `faststore cms-sync [PATH]` @@ -75,7 +75,7 @@ FLAGS -d, --dry-run ``` -_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v3.0.99/dist/commands/cms-sync.ts)_ +_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v3.0.100/dist/commands/cms-sync.ts)_ ## `faststore dev [PATH]` @@ -87,7 +87,7 @@ ARGUMENTS PATH The path where the FastStore being run is. Defaults to cwd. ``` -_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v3.0.99/dist/commands/dev.ts)_ +_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v3.0.100/dist/commands/dev.ts)_ ## `faststore generate-graphql [PATH]` @@ -102,7 +102,7 @@ FLAGS -d, --debug ``` -_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v3.0.99/dist/commands/generate-graphql.ts)_ +_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v3.0.100/dist/commands/generate-graphql.ts)_ ## `faststore help [COMMAND]` @@ -142,7 +142,7 @@ EXAMPLES $ yarn faststore init discovery ``` -_See code: [dist/commands/init.ts](https://github.com/vtex/faststore/blob/v3.0.99/dist/commands/init.ts)_ +_See code: [dist/commands/init.ts](https://github.com/vtex/faststore/blob/v3.0.100/dist/commands/init.ts)_ ## `faststore start [PATH]` @@ -154,7 +154,7 @@ ARGUMENTS PATH The path where the FastStore being run is. Defaults to cwd. ``` -_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v3.0.99/dist/commands/start.ts)_ +_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v3.0.100/dist/commands/start.ts)_ ## `faststore test [PATH]` @@ -166,5 +166,5 @@ ARGUMENTS PATH The path where the FastStore being tested is. Defaults to cwd. ``` -_See code: [dist/commands/test.ts](https://github.com/vtex/faststore/blob/v3.0.99/dist/commands/test.ts)_ +_See code: [dist/commands/test.ts](https://github.com/vtex/faststore/blob/v3.0.100/dist/commands/test.ts)_ diff --git a/packages/cli/package.json b/packages/cli/package.json index c3f04d2bd9..5d6a57c5a7 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/cli", - "version": "3.0.99", + "version": "3.0.100", "description": "FastStore CLI", "author": "Emerson Laurentino @emersonlaurentino", "bin": { @@ -18,7 +18,7 @@ ], "dependencies": { "@antfu/ni": "^0.21.12", - "@faststore/core": "^3.0.99", + "@faststore/core": "^3.0.100", "@inquirer/prompts": "^5.1.2", "@oclif/core": "^1.16.4", "@oclif/plugin-help": "^5", diff --git a/packages/core/package.json b/packages/core/package.json index 9ae828ac72..bd3c002f30 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/core", - "version": "3.0.99", + "version": "3.0.100", "license": "MIT", "repository": "vtex/faststore", "browserslist": "supports es6-module and not dead", @@ -43,7 +43,7 @@ "@envelop/graphql-jit": "^1.1.1", "@envelop/parser-cache": "^2.2.0", "@envelop/validation-cache": "^2.2.0", - "@faststore/api": "^3.0.99", + "@faststore/api": "^3.0.100", "@faststore/components": "^3.0.97", "@faststore/graphql-utils": "^3.0.97", "@faststore/sdk": "^3.0.97", From f25908c7c87daf99f307f463fb7ec09c8ee16f5a Mon Sep 17 00:00:00 2001 From: Eduardo Formiga Date: Tue, 10 Sep 2024 17:45:50 -0300 Subject: [PATCH 029/154] fix: adds optional icon to icon prop (#2443) ## What's the purpose of this pull request? This PR attempts to fix type errors related to this component in some customer's stores. ``` ./src/components/region/RegionModal/RegionModal.tsx:76:10 Type error: Right operand of ?? is unreachable because the left operand is never nullish. ``` ## How it works? ## How to test it? ### Starters Deploy Preview ## References --- .../core/src/components/region/RegionModal/RegionModal.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/components/region/RegionModal/RegionModal.tsx b/packages/core/src/components/region/RegionModal/RegionModal.tsx index 2f001ae91c..40213fd5de 100644 --- a/packages/core/src/components/region/RegionModal/RegionModal.tsx +++ b/packages/core/src/components/region/RegionModal/RegionModal.tsx @@ -22,7 +22,7 @@ interface RegionModalProps { text?: string to?: string icon?: { - icon: string + icon?: string alt: string } } @@ -73,7 +73,7 @@ function RegionModal({ children: ( <> {idkPostalCodeLinkText} - {!!idkPostalCodeLinkIcon ?? ( + {!!idkPostalCodeLinkIcon && ( Date: Tue, 10 Sep 2024 20:51:19 +0000 Subject: [PATCH 030/154] [no ci] Release: 3.0.101 --- lerna.json | 2 +- packages/cli/README.md | 16 ++++++++-------- packages/cli/package.json | 4 ++-- packages/core/package.json | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lerna.json b/lerna.json index 70d1c4190e..be9953fc5b 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "3.0.100", + "version": "3.0.101", "npmClient": "yarn", "command": { "publish": { diff --git a/packages/cli/README.md b/packages/cli/README.md index 349d19269c..b1cfc3636a 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -30,7 +30,7 @@ $ npm install -g @faststore/cli $ faststore COMMAND running command... $ faststore (--version) -@faststore/cli/3.0.100 linux-x64 node-v18.20.4 +@faststore/cli/3.0.101 linux-x64 node-v18.20.4 $ faststore --help [COMMAND] USAGE $ faststore COMMAND @@ -60,7 +60,7 @@ ARGUMENTS PATH The path where the FastStore being built is. Defaults to cwd. ``` -_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v3.0.100/dist/commands/build.ts)_ +_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v3.0.101/dist/commands/build.ts)_ ## `faststore cms-sync [PATH]` @@ -75,7 +75,7 @@ FLAGS -d, --dry-run ``` -_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v3.0.100/dist/commands/cms-sync.ts)_ +_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v3.0.101/dist/commands/cms-sync.ts)_ ## `faststore dev [PATH]` @@ -87,7 +87,7 @@ ARGUMENTS PATH The path where the FastStore being run is. Defaults to cwd. ``` -_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v3.0.100/dist/commands/dev.ts)_ +_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v3.0.101/dist/commands/dev.ts)_ ## `faststore generate-graphql [PATH]` @@ -102,7 +102,7 @@ FLAGS -d, --debug ``` -_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v3.0.100/dist/commands/generate-graphql.ts)_ +_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v3.0.101/dist/commands/generate-graphql.ts)_ ## `faststore help [COMMAND]` @@ -142,7 +142,7 @@ EXAMPLES $ yarn faststore init discovery ``` -_See code: [dist/commands/init.ts](https://github.com/vtex/faststore/blob/v3.0.100/dist/commands/init.ts)_ +_See code: [dist/commands/init.ts](https://github.com/vtex/faststore/blob/v3.0.101/dist/commands/init.ts)_ ## `faststore start [PATH]` @@ -154,7 +154,7 @@ ARGUMENTS PATH The path where the FastStore being run is. Defaults to cwd. ``` -_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v3.0.100/dist/commands/start.ts)_ +_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v3.0.101/dist/commands/start.ts)_ ## `faststore test [PATH]` @@ -166,5 +166,5 @@ ARGUMENTS PATH The path where the FastStore being tested is. Defaults to cwd. ``` -_See code: [dist/commands/test.ts](https://github.com/vtex/faststore/blob/v3.0.100/dist/commands/test.ts)_ +_See code: [dist/commands/test.ts](https://github.com/vtex/faststore/blob/v3.0.101/dist/commands/test.ts)_ diff --git a/packages/cli/package.json b/packages/cli/package.json index 5d6a57c5a7..4ef4ffe0c1 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/cli", - "version": "3.0.100", + "version": "3.0.101", "description": "FastStore CLI", "author": "Emerson Laurentino @emersonlaurentino", "bin": { @@ -18,7 +18,7 @@ ], "dependencies": { "@antfu/ni": "^0.21.12", - "@faststore/core": "^3.0.100", + "@faststore/core": "^3.0.101", "@inquirer/prompts": "^5.1.2", "@oclif/core": "^1.16.4", "@oclif/plugin-help": "^5", diff --git a/packages/core/package.json b/packages/core/package.json index bd3c002f30..e85a20f2ad 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/core", - "version": "3.0.100", + "version": "3.0.101", "license": "MIT", "repository": "vtex/faststore", "browserslist": "supports es6-module and not dead", From 3cfc1989745e3b97cd346dc7ac49a3f2806b9358 Mon Sep 17 00:00:00 2001 From: JoelsonFerreiraM3 <121126786+JoelsonFerreiraM3@users.noreply.github.com> Date: Tue, 10 Sep 2024 21:27:42 -0300 Subject: [PATCH 031/154] Fix: Custom theme import priority (#2442) ## What's the purpose of this pull request? Fix custom theme import priority --------- Co-authored-by: Fanny Chien --- packages/core/src/pages/_app.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/core/src/pages/_app.tsx b/packages/core/src/pages/_app.tsx index 4335056e0d..97fef596f3 100644 --- a/packages/core/src/pages/_app.tsx +++ b/packages/core/src/pages/_app.tsx @@ -5,8 +5,10 @@ import Layout from 'src/Layout' import AnalyticsHandler from 'src/sdk/analytics' import ErrorBoundary from 'src/sdk/error/ErrorBoundary' import SEO from '../../next-seo.config' -import '../customizations/src/themes/index.scss' + +// FastStore UI's base styles import '../styles/global/index.scss' +import '../customizations/src/themes/index.scss' import { DefaultSeo } from 'next-seo' From ea149271ded00f5820d598babb39d79585c43e4f Mon Sep 17 00:00:00 2001 From: vtexgithubbot Date: Wed, 11 Sep 2024 00:32:54 +0000 Subject: [PATCH 032/154] [no ci] Release: 3.0.102 --- lerna.json | 2 +- packages/cli/README.md | 16 ++++++++-------- packages/cli/package.json | 4 ++-- packages/core/package.json | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lerna.json b/lerna.json index be9953fc5b..b2c6896c71 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "3.0.101", + "version": "3.0.102", "npmClient": "yarn", "command": { "publish": { diff --git a/packages/cli/README.md b/packages/cli/README.md index b1cfc3636a..9e8aa91237 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -30,7 +30,7 @@ $ npm install -g @faststore/cli $ faststore COMMAND running command... $ faststore (--version) -@faststore/cli/3.0.101 linux-x64 node-v18.20.4 +@faststore/cli/3.0.102 linux-x64 node-v18.20.4 $ faststore --help [COMMAND] USAGE $ faststore COMMAND @@ -60,7 +60,7 @@ ARGUMENTS PATH The path where the FastStore being built is. Defaults to cwd. ``` -_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v3.0.101/dist/commands/build.ts)_ +_See code: [dist/commands/build.ts](https://github.com/vtex/faststore/blob/v3.0.102/dist/commands/build.ts)_ ## `faststore cms-sync [PATH]` @@ -75,7 +75,7 @@ FLAGS -d, --dry-run ``` -_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v3.0.101/dist/commands/cms-sync.ts)_ +_See code: [dist/commands/cms-sync.ts](https://github.com/vtex/faststore/blob/v3.0.102/dist/commands/cms-sync.ts)_ ## `faststore dev [PATH]` @@ -87,7 +87,7 @@ ARGUMENTS PATH The path where the FastStore being run is. Defaults to cwd. ``` -_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v3.0.101/dist/commands/dev.ts)_ +_See code: [dist/commands/dev.ts](https://github.com/vtex/faststore/blob/v3.0.102/dist/commands/dev.ts)_ ## `faststore generate-graphql [PATH]` @@ -102,7 +102,7 @@ FLAGS -d, --debug ``` -_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v3.0.101/dist/commands/generate-graphql.ts)_ +_See code: [dist/commands/generate-graphql.ts](https://github.com/vtex/faststore/blob/v3.0.102/dist/commands/generate-graphql.ts)_ ## `faststore help [COMMAND]` @@ -142,7 +142,7 @@ EXAMPLES $ yarn faststore init discovery ``` -_See code: [dist/commands/init.ts](https://github.com/vtex/faststore/blob/v3.0.101/dist/commands/init.ts)_ +_See code: [dist/commands/init.ts](https://github.com/vtex/faststore/blob/v3.0.102/dist/commands/init.ts)_ ## `faststore start [PATH]` @@ -154,7 +154,7 @@ ARGUMENTS PATH The path where the FastStore being run is. Defaults to cwd. ``` -_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v3.0.101/dist/commands/start.ts)_ +_See code: [dist/commands/start.ts](https://github.com/vtex/faststore/blob/v3.0.102/dist/commands/start.ts)_ ## `faststore test [PATH]` @@ -166,5 +166,5 @@ ARGUMENTS PATH The path where the FastStore being tested is. Defaults to cwd. ``` -_See code: [dist/commands/test.ts](https://github.com/vtex/faststore/blob/v3.0.101/dist/commands/test.ts)_ +_See code: [dist/commands/test.ts](https://github.com/vtex/faststore/blob/v3.0.102/dist/commands/test.ts)_ diff --git a/packages/cli/package.json b/packages/cli/package.json index 4ef4ffe0c1..624e23bd3a 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/cli", - "version": "3.0.101", + "version": "3.0.102", "description": "FastStore CLI", "author": "Emerson Laurentino @emersonlaurentino", "bin": { @@ -18,7 +18,7 @@ ], "dependencies": { "@antfu/ni": "^0.21.12", - "@faststore/core": "^3.0.101", + "@faststore/core": "^3.0.102", "@inquirer/prompts": "^5.1.2", "@oclif/core": "^1.16.4", "@oclif/plugin-help": "^5", diff --git a/packages/core/package.json b/packages/core/package.json index e85a20f2ad..3204f7dffe 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@faststore/core", - "version": "3.0.101", + "version": "3.0.102", "license": "MIT", "repository": "vtex/faststore", "browserslist": "supports es6-module and not dead", From cd93d30b62a254758a63de2a696d5ff25267a7ad Mon Sep 17 00:00:00 2001 From: Fanny Chien Date: Thu, 12 Sep 2024 10:18:04 -0300 Subject: [PATCH 033/154] Feat: Adds jest-axe and Card component test (#2440) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What's the purpose of this pull request? - Setup `@testing-library/jest-dom` to help to test our components when checking an element's attributes, its text content, its css classes... - Adds `Card` component tests - Introduces accessibility tests: This won't guarantee that what we're building is accessible, but it's a first step towards it. 🥳 - Updates `CheckboxField` component test TODO: Document ## How it works? Currently, our components library do not have tests, but we want to introduce them for upcoming components. For existing components, we will gradually add tests retroactively. ## How to test it? 1. navigate to `packages/components` -> run `yarn install` 2. run `yarn test`, you will be able to see the tests running image _____ 3. removing `