@graphcommerce/algolia-products 9.0.0-canary.99 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,72 +1,70 @@
1
1
  # @graphcommerce/algolia-products
2
2
 
3
- ## 9.0.0-canary.99
3
+ ## 9.0.0
4
4
 
5
- ## 9.0.0-canary.98
6
-
7
- ## 9.0.0-canary.97
5
+ ### Minor Changes
8
6
 
9
- ## 9.0.0-canary.96
7
+ - [#2336](https://github.com/graphcommerce-org/graphcommerce/pull/2336) [`95ce63c`](https://github.com/graphcommerce-org/graphcommerce/commit/95ce63cd32463835239ba959734cdaf1aa7f3f7b) - Added algolia search suggestions ([@Renzovh](https://github.com/Renzovh))
10
8
 
11
- ## 9.0.0-canary.95
9
+ - [#2309](https://github.com/graphcommerce-org/graphcommerce/pull/2309) [`9c1110e`](https://github.com/graphcommerce-org/graphcommerce/commit/9c1110ed018139dec7e7183f783208c158ee7ead) - Algolia Magento 2 implemented as a GraphQL Mesh resolver: Allows full integration without modying any frontend components. ([@Renzovh](https://github.com/Renzovh))
12
10
 
13
- ## 9.0.0-canary.94
11
+ - [#2377](https://github.com/graphcommerce-org/graphcommerce/pull/2377) [`56fcc45`](https://github.com/graphcommerce-org/graphcommerce/commit/56fcc45b60e43574c64fcdd7b02f8062d677e250) - Integrated algolia product queries into graphql-mesh. Provides fast and accurate searches, that can be personalised via magento-algolia and its algolia dashboard ([@Renzovh](https://github.com/Renzovh))
14
12
 
15
- ## 9.0.0-canary.93
13
+ ### Patch Changes
16
14
 
17
- ## 9.0.0-canary.92
15
+ - [#2385](https://github.com/graphcommerce-org/graphcommerce/pull/2385) [`44f18b5`](https://github.com/graphcommerce-org/graphcommerce/commit/44f18b5a8986935728f7147d6f506dd1376fd594) - Added support for Adobe Commerce for Algolia. ([@paales](https://github.com/paales))
18
16
 
19
- ## 9.0.0-canary.91
17
+ - [#2334](https://github.com/graphcommerce-org/graphcommerce/pull/2334) [`3140735`](https://github.com/graphcommerce-org/graphcommerce/commit/3140735a8a49f8bebcbfde4e581515884446e05d) - Added support for customer group pricing. ([@Renzovh](https://github.com/Renzovh))
20
18
 
21
- ## 9.0.0-canary.90
19
+ - [#2417](https://github.com/graphcommerce-org/graphcommerce/pull/2417) [`743e7e2`](https://github.com/graphcommerce-org/graphcommerce/commit/743e7e275c8f0bfe32a5240c08eed92120085cc0) - Prevent errors by returning string instead of array ([@Renzovh](https://github.com/Renzovh))
22
20
 
23
- ## 9.0.0-canary.89
21
+ ## 9.0.0-canary.118
24
22
 
25
- ## 9.0.0-canary.88
23
+ ## 9.0.0-canary.117
26
24
 
27
- ## 9.0.0-canary.87
25
+ ## 9.0.0-canary.116
28
26
 
29
- ## 9.0.0-canary.86
27
+ ## 9.0.0-canary.115
30
28
 
31
- ## 9.0.0-canary.85
29
+ ## 9.0.0-canary.114
32
30
 
33
- ## 9.0.0-canary.84
31
+ ## 9.0.0-canary.113
34
32
 
35
- ### Minor Changes
33
+ ## 9.0.0-canary.112
36
34
 
37
- - [#2377](https://github.com/graphcommerce-org/graphcommerce/pull/2377) [`56fcc45`](https://github.com/graphcommerce-org/graphcommerce/commit/56fcc45b60e43574c64fcdd7b02f8062d677e250) - Integrated algolia product queries into graphql-mesh. Provides fast and accurate searches, that can be personalised via magento-algolia and its algolia dashboard ([@Renzovh](https://github.com/Renzovh))
35
+ ## 9.0.0-canary.111
38
36
 
39
- ## 9.0.0-canary.83
37
+ ## 9.0.0-canary.110
40
38
 
41
- ## 9.0.0-canary.82
39
+ ## 9.0.0-canary.109
42
40
 
43
- ## 9.0.0-canary.81
41
+ ## 9.0.0-canary.108
44
42
 
45
- ## 9.0.0-canary.80
43
+ ## 9.0.0-canary.107
46
44
 
47
- ## 9.0.0-canary.79
45
+ ## 9.0.0-canary.106
48
46
 
49
- ## 9.0.0-canary.78
47
+ ### Patch Changes
50
48
 
51
- ## 9.0.0-canary.77
49
+ - [#2385](https://github.com/graphcommerce-org/graphcommerce/pull/2385) [`44f18b5`](https://github.com/graphcommerce-org/graphcommerce/commit/44f18b5a8986935728f7147d6f506dd1376fd594) - Added support for Adobe Commerce for Algolia. ([@paales](https://github.com/paales))
52
50
 
53
- ## 9.0.0-canary.76
51
+ ## 9.0.0-canary.105
54
52
 
55
- ## 9.0.0-canary.75
53
+ ## 9.0.0-canary.104
56
54
 
57
- ## 9.0.0-canary.74
55
+ ## 9.0.0-canary.103
58
56
 
59
- ## 9.0.0-canary.73
57
+ ## 9.0.0-canary.100
60
58
 
61
- ## 9.0.0-canary.72
59
+ ### Patch Changes
62
60
 
63
- ## 9.0.0-canary.71
61
+ - [#2417](https://github.com/graphcommerce-org/graphcommerce/pull/2417) [`743e7e2`](https://github.com/graphcommerce-org/graphcommerce/commit/743e7e275c8f0bfe32a5240c08eed92120085cc0) - Prevent errors by returning string instead of array ([@Renzovh](https://github.com/Renzovh))
64
62
 
65
- ## 9.0.0-canary.70
63
+ ## 9.0.0-canary.84
66
64
 
67
- ## 9.0.0-canary.69
65
+ ### Minor Changes
68
66
 
69
- ## 9.0.0-canary.68
67
+ - [#2377](https://github.com/graphcommerce-org/graphcommerce/pull/2377) [`56fcc45`](https://github.com/graphcommerce-org/graphcommerce/commit/56fcc45b60e43574c64fcdd7b02f8062d677e250) - Integrated algolia product queries into graphql-mesh. Provides fast and accurate searches, that can be personalised via magento-algolia and its algolia dashboard ([@Renzovh](https://github.com/Renzovh))
70
68
 
71
69
  ## 9.0.0-canary.67
72
70
 
@@ -74,24 +72,12 @@
74
72
 
75
73
  - [#2336](https://github.com/graphcommerce-org/graphcommerce/pull/2336) [`95ce63c`](https://github.com/graphcommerce-org/graphcommerce/commit/95ce63cd32463835239ba959734cdaf1aa7f3f7b) - Added algolia search suggestions ([@Renzovh](https://github.com/Renzovh))
76
74
 
77
- ## 9.0.0-canary.66
78
-
79
- ## 9.0.0-canary.65
80
-
81
75
  ## 9.0.0-canary.64
82
76
 
83
77
  ### Patch Changes
84
78
 
85
79
  - [#2334](https://github.com/graphcommerce-org/graphcommerce/pull/2334) [`3140735`](https://github.com/graphcommerce-org/graphcommerce/commit/3140735a8a49f8bebcbfde4e581515884446e05d) - Added support for customer group pricing ([@Renzovh](https://github.com/Renzovh))
86
80
 
87
- ## 9.0.0-canary.63
88
-
89
- ## 9.0.0-canary.62
90
-
91
- ## 9.0.0-canary.61
92
-
93
- ## 9.0.0-canary.60
94
-
95
81
  ## 9.0.0-canary.59
96
82
 
97
83
  ### Minor Changes
@@ -1,4 +1,5 @@
1
- import { ApolloCache, setContext } from '@graphcommerce/graphql'
1
+ import type { ApolloCache } from '@graphcommerce/graphql'
2
+ import { setContext } from '@graphcommerce/graphql'
2
3
  import { CustomerDocument } from '@graphcommerce/magento-customer'
3
4
 
4
5
  declare module '@apollo/client' {
@@ -5,8 +5,8 @@ import type {
5
5
  CategoryResult,
6
6
  MeshContext,
7
7
  } from '@graphcommerce/graphql-mesh'
8
- import { AttributeList } from './getAttributeList'
9
- import { GetStoreConfigReturn } from './getStoreConfig'
8
+ import type { AttributeList } from './getAttributeList'
9
+ import type { GetStoreConfigReturn } from './getStoreConfig'
10
10
 
11
11
  type AlgoliaFacets = { [facetName: string]: AlgoliaFacetOption }
12
12
  type AlgoliaFacetOption = { [facetOption: string]: number }
@@ -41,6 +41,7 @@ function compare(a, b) {
41
41
  return 0
42
42
  }
43
43
 
44
+ /** @public */
44
45
  export function algoliaPricesToPricesAggregations(pricesList: {
45
46
  [key: string]: number
46
47
  }): AggregationOption[] {
@@ -109,6 +110,7 @@ export function algoliaPricesToPricesAggregations(pricesList: {
109
110
  return Object.values(pricesBucket)
110
111
  }
111
112
 
113
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
112
114
  function assertAlgoliaFacets(facets: any): facets is AlgoliaFacets {
113
115
  return true
114
116
  }
@@ -116,7 +118,8 @@ function assertAlgoliaFacets(facets: any): facets is AlgoliaFacets {
116
118
  /**
117
119
  * Map algolia facets to aggregations format
118
120
  *
119
- * TODO: Make sure the aggregations are sorted correctly: https://magento-247-git-canary-graphcommerce.vercel.app/men/photography, through position
121
+ * TODO: Make sure the aggregations are sorted correctly:
122
+ * https://magento-247-git-canary-graphcommerce.vercel.app/men/photography, through position
120
123
  */
121
124
  export function algoliaFacetsToAggregations(
122
125
  algoliaFacets: AlgoliasearchResponse['facets'],
@@ -11,11 +11,9 @@ import type {
11
11
  ResolversParentTypes,
12
12
  ResolversTypes,
13
13
  } from '@graphcommerce/graphql-mesh'
14
- // eslint-disable-next-line import/no-extraneous-dependencies
15
- import { GraphQLResolveInfo } from 'graphql'
16
- import { GetStoreConfigReturn } from './getStoreConfig'
14
+ import type { GetStoreConfigReturn } from './getStoreConfig'
17
15
 
18
- export function assertAdditional(
16
+ function assertAdditional(
19
17
  additional: unknown,
20
18
  ): additional is AlgoliaProductHitAdditionalProperties {
21
19
  return true
@@ -122,7 +120,7 @@ export function algoliaHitToMagentoProduct(
122
120
  hit: Algoliahit,
123
121
  storeConfig: GetStoreConfigReturn,
124
122
  customerGroup: number,
125
- ): ProductsItemsItem | null {
123
+ ): (ProductsItemsItem & { staged: boolean }) | null {
126
124
  const { objectID, additionalProperties } = hit
127
125
  if (!assertAdditional(additionalProperties)) return null
128
126
 
@@ -147,10 +145,21 @@ export function algoliaHitToMagentoProduct(
147
145
  ...rest
148
146
  } = additionalProperties
149
147
 
148
+ // Some custom attributes are returned as array while they need to be a string. Flatten those arrays
149
+ const flattenedCustomAttributes = {}
150
+ for (const [key, value] of Object.entries(rest)) {
151
+ if (value !== null && Array.isArray(value) && value?.length > 0) {
152
+ flattenedCustomAttributes[key] = value.toString()
153
+ delete rest[key]
154
+ }
155
+ }
156
+
150
157
  return {
158
+ staged: false,
151
159
  redirect_code: 0,
152
160
  __typename: algoliaTypeToTypename[type_id as keyof typeof algoliaTypeToTypename],
153
161
  uid: btoa(objectID),
162
+ id: Number(objectID),
154
163
  sku: Array.isArray(sku) ? sku[0] : `${sku}`,
155
164
  price_range: mapPriceRange(price, storeConfig, customerGroup),
156
165
  created_at: created_at ? new Date(created_at).toISOString() : null,
@@ -187,5 +196,6 @@ export function algoliaHitToMagentoProduct(
187
196
  url_key: algoliaUrlToUrlKey(url, storeConfig?.base_link_url),
188
197
  url_suffix: storeConfig?.product_url_suffix,
189
198
  ...rest,
199
+ ...flattenedCustomAttributes,
190
200
  }
191
201
  }
@@ -19,7 +19,7 @@ export async function getAttributeList(context: MeshContext): Promise<AttributeL
19
19
  entityType: 'CATALOG_PRODUCT',
20
20
  filters: {},
21
21
  },
22
- selectionSet: `{ items{ code label } }`,
22
+ selectionSet: '{ items{ code label } }',
23
23
  context,
24
24
  }).then((res) => res?.items)) as { label?: string; code: string }[]
25
25
  attributeListCache = filterNonNullableKeys(items, ['label'])
@@ -1,4 +1,4 @@
1
- import { MeshContext, Maybe, StoreConfig } from '@graphcommerce/graphql-mesh'
1
+ import type { Maybe, MeshContext, StoreConfig } from '@graphcommerce/graphql-mesh'
2
2
 
3
3
  export type GetStoreConfigReturn =
4
4
  | Maybe<
@@ -1,14 +1,14 @@
1
1
  import type {
2
- ProductAttributeFilterInput,
3
2
  AlgolianumericFilters_Input,
3
+ ProductAttributeFilterInput,
4
4
  } from '@graphcommerce/graphql-mesh'
5
5
  import {
6
6
  isFilterTypeEqual,
7
- isFilterTypeRange,
8
7
  isFilterTypeMatch,
8
+ isFilterTypeRange,
9
9
  } from '@graphcommerce/magento-product'
10
- import { InputMaybe } from '@graphcommerce/next-config'
11
- import { GetStoreConfigReturn } from './getStoreConfig'
10
+ import type { InputMaybe } from '@graphcommerce/next-config'
11
+ import type { GetStoreConfigReturn } from './getStoreConfig'
12
12
  import { nonNullable } from './utils'
13
13
 
14
14
  /**
package/mesh/resolvers.ts CHANGED
@@ -1,11 +1,9 @@
1
- import {
2
- AlgoliasearchResponse,
3
- hasSelectionSetPath,
4
- type Resolvers,
5
- } from '@graphcommerce/graphql-mesh'
1
+ import type { AlgoliasearchResponse, Resolvers } from '@graphcommerce/graphql-mesh'
2
+ import { hasSelectionSetPath } from '@graphcommerce/graphql-mesh'
6
3
  import type { GraphQLError, GraphQLResolveInfo } from 'graphql'
7
4
  import { algoliaFacetsToAggregations, getCategoryList } from './algoliaFacetsToAggregations'
8
- import { algoliaHitToMagentoProduct, ProductsItemsItem } from './algoliaHitToMagentoProduct'
5
+ import type { ProductsItemsItem } from './algoliaHitToMagentoProduct'
6
+ import { algoliaHitToMagentoProduct } from './algoliaHitToMagentoProduct'
9
7
  import { getAlgoliaSettings } from './getAlgoliaSettings'
10
8
  import { getAttributeList } from './getAttributeList'
11
9
  import { getGroupId } from './getGroupId'
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  AlgoliasettingsResponse,
3
3
  MeshContext,
4
4
  ProductAttributeSortInput,
@@ -6,7 +6,7 @@ import {
6
6
  SortField,
7
7
  } from '@graphcommerce/graphql-mesh'
8
8
  import { nonNullable } from '@graphcommerce/magento-customer'
9
- import { AttributeList } from './getAttributeList'
9
+ import type { AttributeList } from './getAttributeList'
10
10
  import { getIndexName } from './getIndexName'
11
11
 
12
12
  export type SortingOptions = Record<string, SortField & { dirs: SortEnum[] }>
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/algolia-products",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "9.0.0-canary.99",
5
+ "version": "9.0.0",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -15,18 +15,18 @@
15
15
  "generate": "tsx scripts/generate-spec.mts"
16
16
  },
17
17
  "peerDependencies": {
18
- "@graphcommerce/google-datalayer": "^9.0.0-canary.99",
19
- "@graphcommerce/graphql": "^9.0.0-canary.99",
20
- "@graphcommerce/graphql-mesh": "^9.0.0-canary.99",
21
- "@graphcommerce/magento-customer": "^9.0.0-canary.99",
22
- "@graphcommerce/magento-product": "^9.0.0-canary.99",
23
- "@graphcommerce/magento-search": "^9.0.0-canary.99",
24
- "@graphcommerce/next-config": "^9.0.0-canary.99",
25
- "@graphcommerce/next-ui": "^9.0.0-canary.99",
18
+ "@graphcommerce/google-datalayer": "^9.0.0",
19
+ "@graphcommerce/graphql": "^9.0.0",
20
+ "@graphcommerce/graphql-mesh": "^9.0.0",
21
+ "@graphcommerce/magento-customer": "^9.0.0",
22
+ "@graphcommerce/magento-product": "^9.0.0",
23
+ "@graphcommerce/magento-search": "^9.0.0",
24
+ "@graphcommerce/next-config": "^9.0.0",
25
+ "@graphcommerce/next-ui": "^9.0.0",
26
26
  "react": "^18.2.0"
27
27
  },
28
28
  "devDependencies": {
29
- "graphql": "^16.0.0",
30
- "tsx": "^4.16.2"
29
+ "graphql": "^16.10.0",
30
+ "tsx": "^4.19.2"
31
31
  }
32
32
  }
@@ -1,4 +1,4 @@
1
- import { GraphQLProviderProps } from '@graphcommerce/graphql'
1
+ import type { GraphQLProviderProps } from '@graphcommerce/graphql'
2
2
  import type { PluginConfig, PluginProps } from '@graphcommerce/next-config'
3
3
  import { customerGroupIdLink } from '../link/customerGroupIdLink'
4
4
 
@@ -1,9 +1,9 @@
1
1
  import type {
2
- useProductListApplyCategoryDefaults as useProductListApplyDefaults,
3
- productListApplyCategoryDefaults as productListApplyDefaults,
4
2
  categoryDefaultsToProductListFilters as defaultsToProductListFilters,
3
+ productListApplyCategoryDefaults as productListApplyDefaults,
4
+ useProductListApplyCategoryDefaults as useProductListApplyDefaults,
5
5
  } from '@graphcommerce/magento-product'
6
- import { FunctionPlugin, PluginConfig } from '@graphcommerce/next-config'
6
+ import type { FunctionPlugin, PluginConfig } from '@graphcommerce/next-config'
7
7
  import { applyEngineVariables } from '../utils/applyEngineVariable'
8
8
 
9
9
  export const config: PluginConfig = {
@@ -1,9 +1,9 @@
1
1
  import type {
2
- useProductListApplySearchDefaults as useProductListApplyDefaults,
3
- productListApplySearchDefaults as productListApplyDefaults,
4
2
  searchDefaultsToProductListFilters as defaultsToProductListFilters,
3
+ productListApplySearchDefaults as productListApplyDefaults,
4
+ useProductListApplySearchDefaults as useProductListApplyDefaults,
5
5
  } from '@graphcommerce/magento-search'
6
- import { FunctionPlugin, PluginConfig } from '@graphcommerce/next-config'
6
+ import type { FunctionPlugin, PluginConfig } from '@graphcommerce/next-config'
7
7
  import { applyEngineVariables } from '../utils/applyEngineVariable'
8
8
 
9
9
  export const config: PluginConfig = {
@@ -1,11 +0,0 @@
1
- import type { ProductListQueryVariables } from '@graphcommerce/magento-product'
2
-
3
- export function applyEngineVariables(variables: ProductListQueryVariables | undefined) {
4
- return {
5
- ...variables,
6
- filters: {
7
- ...variables?.filters,
8
- engine: { eq: 'algolia' },
9
- },
10
- }
11
- }