@graphcommerce/algolia-search 9.1.0-canary.55 → 10.0.0-canary.56
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 +80 -0
- package/Config.graphqls +2 -2
- package/README.md +4 -12
- package/api/add-hygraph-record.ts +11 -7
- package/api/remove-hygraph-record.ts +9 -6
- package/components/SearchBox/SearchBox.tsx +5 -4
- package/lib/configuration.ts +4 -2
- package/package.json +29 -17
- package/plugins/AlgoliaProductSortPlugin.tsx +2 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,85 @@
|
|
|
1
1
|
# @graphcommerce/algolia-search
|
|
2
2
|
|
|
3
|
+
## 10.0.0-canary.56
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#2546](https://github.com/graphcommerce-org/graphcommerce/pull/2546) [`ed9332a`](https://github.com/graphcommerce-org/graphcommerce/commit/ed9332a7f78966d932041d9a7725641edc92b28d) - ## GraphCommerce 10 - Turbopack Support
|
|
8
|
+
|
|
9
|
+
This major release brings full Turbopack compatibility, dramatically improving development speed.
|
|
10
|
+
|
|
11
|
+
### 🚀 Turbopack-Compatible Interceptor System
|
|
12
|
+
|
|
13
|
+
The entire plugin/interceptor system has been rewritten to work with Turbopack:
|
|
14
|
+
|
|
15
|
+
- **No more Webpack plugins** - Removed `InterceptorPlugin` webpack plugin entirely
|
|
16
|
+
- **File-based interception** - Original files are moved to `.original.tsx` and replaced with interceptor content
|
|
17
|
+
- **Direct imports** - Interceptors import from `.original` files instead of embedding source
|
|
18
|
+
- **New CLI commands**:
|
|
19
|
+
- `graphcommerce codegen-interceptors` - Generate interceptor files
|
|
20
|
+
- `graphcommerce cleanup-interceptors` - Reset interceptor system, restore original files
|
|
21
|
+
- **Stable file hashing** - Deterministic interceptor generation for better caching
|
|
22
|
+
|
|
23
|
+
### ⚙️ Treeshakable Configuration System
|
|
24
|
+
|
|
25
|
+
Replaced Webpack `DefinePlugin`-based `import.meta.graphCommerce` with a new generated configuration system:
|
|
26
|
+
|
|
27
|
+
- **New `codegen-config-values` command** - Generates TypeScript files with precise typing
|
|
28
|
+
- **Schema-driven** - Dynamically introspects Zod schemas to determine all available properties
|
|
29
|
+
- **Fully treeshakable** - Unused config values are eliminated from the bundle
|
|
30
|
+
- **Type-safe** - Uses `Get<GraphCommerceConfig, 'path'>` for nested property access
|
|
31
|
+
- **Separate files for nested objects** - Optimal treeshaking for complex configurations
|
|
32
|
+
|
|
33
|
+
### 🔧 withGraphCommerce Changes
|
|
34
|
+
|
|
35
|
+
- **Removed** `InterceptorPlugin` - No longer needed with file-based interception
|
|
36
|
+
- **Removed** `DefinePlugin` for `import.meta.graphCommerce` - Replaced with generated config
|
|
37
|
+
- **Removed** `@mui/*` alias rewrites - No longer required
|
|
38
|
+
- **Added** Turbopack loader rules for `.yaml`, `.yml`, and `.po` files
|
|
39
|
+
- **Added** `serverExternalPackages` for all `@whatwg-node/*` packages
|
|
40
|
+
- **Added** `optimizePackageImports` for better bundle optimization
|
|
41
|
+
- **Added** `images.qualities: [52, 75]` for Next.js image optimization
|
|
42
|
+
|
|
43
|
+
### 📦 Lingui Configuration
|
|
44
|
+
|
|
45
|
+
- **Renamed** `lingui.config.js` → `lingui.config.ts` with TypeScript support
|
|
46
|
+
- **Updated** `@graphcommerce/lingui-next/config` to TypeScript with proper exports
|
|
47
|
+
- **Simplified** formatter options
|
|
48
|
+
|
|
49
|
+
### ⚛️ React 19 & Next.js 16 Compatibility
|
|
50
|
+
|
|
51
|
+
- Updated `RefObject<T>` types for React 19 (now includes `null` by default)
|
|
52
|
+
- Replaced deprecated `React.VFC` with `React.FC`
|
|
53
|
+
- Fixed `useRef` calls to require explicit initial values
|
|
54
|
+
- Updated `MutableRefObject` usage in `framer-scroller`
|
|
55
|
+
|
|
56
|
+
### 📋 ESLint 9 Flat Config
|
|
57
|
+
|
|
58
|
+
- Migrated from legacy `.eslintrc` to new flat config format (`eslint.config.mjs`)
|
|
59
|
+
- Updated `@typescript-eslint/*` packages to v8
|
|
60
|
+
- Fixed AST selector for `SxProps` rule (`typeParameters` → `typeArguments`)
|
|
61
|
+
|
|
62
|
+
### 🔄 Apollo Client
|
|
63
|
+
|
|
64
|
+
- Fixed deprecated `name` option → `clientAwareness: { name: 'ssr' }`
|
|
65
|
+
- Updated error handling types to accept `ApolloError | null | undefined`
|
|
66
|
+
|
|
67
|
+
### ⚠️ Breaking Changes
|
|
68
|
+
|
|
69
|
+
- **Node.js 24.x not supported** - Restricted to `>=20 <24.0.0` due to [nodejs/undici#4290](https://github.com/nodejs/undici/issues/4290)
|
|
70
|
+
- **Interceptor files changed** - Original components now at `.original.tsx`
|
|
71
|
+
- **Config access changed** - Use generated config values instead of `import.meta.graphCommerce`
|
|
72
|
+
- **ESLint config format** - Must use flat config (`eslint.config.mjs`)
|
|
73
|
+
- **Lingui config** - Rename `lingui.config.js` to `lingui.config.ts`
|
|
74
|
+
|
|
75
|
+
### 🗑️ Removed
|
|
76
|
+
|
|
77
|
+
- `InterceptorPlugin` webpack plugin
|
|
78
|
+
- `configToImportMeta` utility
|
|
79
|
+
- Webpack `DefinePlugin` usage for config
|
|
80
|
+
- `@mui/*` modern alias rewrites
|
|
81
|
+
- Debug plugins (`CircularDependencyPlugin`, `DuplicatesPlugin`) ([@paales](https://github.com/paales))
|
|
82
|
+
|
|
3
83
|
## 9.1.0-canary.55
|
|
4
84
|
|
|
5
85
|
## 9.1.0-canary.54
|
package/Config.graphqls
CHANGED
|
@@ -71,12 +71,12 @@ extend input GraphCommerceConfig {
|
|
|
71
71
|
algoliaSearchDebounceTime: Int
|
|
72
72
|
|
|
73
73
|
"""
|
|
74
|
-
Configure your Algolia
|
|
74
|
+
Configure your Algolia Hygraph index. This will create a new index for Hygraph data if it doesn't exist in Algolia.
|
|
75
75
|
"""
|
|
76
76
|
algoliaHygraphIndex: String
|
|
77
77
|
|
|
78
78
|
"""
|
|
79
|
-
Configure your Algolia
|
|
79
|
+
Configure your Algolia Hygraph secret. This will be used to authenticate the Hygraph data.
|
|
80
80
|
"""
|
|
81
81
|
hygraphSecret: String
|
|
82
82
|
}
|
package/README.md
CHANGED
|
@@ -167,15 +167,7 @@ return {
|
|
|
167
167
|
|
|
168
168
|
return (
|
|
169
169
|
<>
|
|
170
|
-
<PageMeta
|
|
171
|
-
title={
|
|
172
|
-
search
|
|
173
|
-
? i18n._(/* i18n */ 'Results for ‘{search}’', { search })
|
|
174
|
-
: i18n._(/* i18n */ 'Search')
|
|
175
|
-
}
|
|
176
|
-
metaRobots={['noindex']}
|
|
177
|
-
canonical='/search'
|
|
178
|
-
/>
|
|
170
|
+
<PageMeta title={search ? t`Results for ‘${search}’` : t`Search`} metaRobots={['noindex']} />
|
|
179
171
|
|
|
180
172
|
+ <SearchContext serverProps={serverState}>
|
|
181
173
|
```
|
|
@@ -185,7 +177,7 @@ return {
|
|
|
185
177
|
1. Follow the algolia docs to enable the Algolia integration in Magento 2
|
|
186
178
|
[here](https://www.algolia.com/doc/integration/magento-2/getting-started/quick-start/?client=php).
|
|
187
179
|
|
|
188
|
-
## Add Algolia indexing to
|
|
180
|
+
## Add Algolia indexing to Hygraph
|
|
189
181
|
|
|
190
182
|
1. Add the `algoliasearch` package to your project
|
|
191
183
|
|
|
@@ -237,8 +229,8 @@ export default (req: NextApiRequest, res: NextApiResponse) =>
|
|
|
237
229
|
await removeHygraphRecord(req, res)
|
|
238
230
|
```
|
|
239
231
|
|
|
240
|
-
6. Follow the webhook setup guide to add the webhooks to your
|
|
232
|
+
6. Follow the webhook setup guide to add the webhooks to your Hygraph project.
|
|
241
233
|
|
|
242
234
|
You can follow
|
|
243
235
|
[these](https://hygraph.com/docs/guides/webhooks/webhooks-overview#configure-webhooks)
|
|
244
|
-
instructions to configure the webhooks in your
|
|
236
|
+
instructions to configure the webhooks in your Hygraph project.
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import type { Page } from '@graphcommerce/graphql-mesh'
|
|
2
|
+
import {
|
|
3
|
+
algoliaApplicationId,
|
|
4
|
+
algoliaHygraphIndex,
|
|
5
|
+
algoliaSearchOnlyApiKey,
|
|
6
|
+
canonicalBaseUrl,
|
|
7
|
+
hygraphSecret,
|
|
8
|
+
} from '@graphcommerce/next-config/config'
|
|
2
9
|
import { verifyWebhookSignature } from '@hygraph/utils'
|
|
3
10
|
import algoliasearch from 'algoliasearch'
|
|
4
11
|
import type { NextApiRequest, NextApiResponse } from 'next'
|
|
@@ -12,12 +19,9 @@ type AlgoliaResult = {
|
|
|
12
19
|
algoliaLastUpdateAtCET: string
|
|
13
20
|
}
|
|
14
21
|
|
|
15
|
-
const algolia = algoliasearch(
|
|
16
|
-
import.meta.graphCommerce.algoliaApplicationId,
|
|
17
|
-
import.meta.graphCommerce.algoliaSearchOnlyApiKey,
|
|
18
|
-
)
|
|
22
|
+
const algolia = algoliasearch(algoliaApplicationId, algoliaSearchOnlyApiKey)
|
|
19
23
|
|
|
20
|
-
const indexName =
|
|
24
|
+
const indexName = algoliaHygraphIndex
|
|
21
25
|
const index = typeof indexName === 'string' ? algolia.initIndex(indexName) : undefined
|
|
22
26
|
|
|
23
27
|
export function addHygraphRecord(req: NextApiRequest, res: NextApiResponse) {
|
|
@@ -26,7 +30,7 @@ export function addHygraphRecord(req: NextApiRequest, res: NextApiResponse) {
|
|
|
26
30
|
const { body } = req
|
|
27
31
|
const gcms = req.headers['gcms-signature']
|
|
28
32
|
const signature = Array.isArray(gcms) ? gcms[0] : gcms
|
|
29
|
-
const secret =
|
|
33
|
+
const secret = hygraphSecret
|
|
30
34
|
|
|
31
35
|
if (!index) return res.status(400).send('Missing "algoliaHygraphIndex" config variable')
|
|
32
36
|
if (!secret) return res.status(400).send('Missing "hygraphSecret" config variable')
|
|
@@ -40,7 +44,7 @@ export function addHygraphRecord(req: NextApiRequest, res: NextApiResponse) {
|
|
|
40
44
|
const { id: objectID, localizations } = data
|
|
41
45
|
|
|
42
46
|
const objects = localizations.map((localization: Page & { updatedAt: string }) => {
|
|
43
|
-
const url = `${
|
|
47
|
+
const url = `${canonicalBaseUrl}/${localization?.url}`
|
|
44
48
|
const algoliaObject: AlgoliaResult = {
|
|
45
49
|
name: localization?.title ?? '',
|
|
46
50
|
content: localization?.metaDescription,
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
algoliaApplicationId,
|
|
3
|
+
algoliaHygraphIndex,
|
|
4
|
+
algoliaSearchOnlyApiKey,
|
|
5
|
+
hygraphSecret,
|
|
6
|
+
} from '@graphcommerce/next-config/config'
|
|
1
7
|
import { verifyWebhookSignature } from '@hygraph/utils'
|
|
2
8
|
import algoliasearch from 'algoliasearch'
|
|
3
9
|
import type { NextApiRequest, NextApiResponse } from 'next'
|
|
4
10
|
|
|
5
|
-
const algolia = algoliasearch(
|
|
6
|
-
import.meta.graphCommerce.algoliaApplicationId,
|
|
7
|
-
import.meta.graphCommerce.algoliaSearchOnlyApiKey,
|
|
8
|
-
)
|
|
11
|
+
const algolia = algoliasearch(algoliaApplicationId, algoliaSearchOnlyApiKey)
|
|
9
12
|
|
|
10
|
-
const indexName =
|
|
13
|
+
const indexName = algoliaHygraphIndex
|
|
11
14
|
const index = indexName ? algolia.initIndex(indexName) : undefined
|
|
12
15
|
|
|
13
16
|
export async function removeHygraphRecord(req: NextApiRequest, res: NextApiResponse) {
|
|
@@ -16,7 +19,7 @@ export async function removeHygraphRecord(req: NextApiRequest, res: NextApiRespo
|
|
|
16
19
|
const { body } = req
|
|
17
20
|
const gcms = req.headers['gcms-signature']
|
|
18
21
|
const signature = Array.isArray(gcms) ? gcms[0] : gcms
|
|
19
|
-
const secret =
|
|
22
|
+
const secret = hygraphSecret
|
|
20
23
|
|
|
21
24
|
if (!index) return res.status(400).send('Missing "algoliaHygraphIndex" config variable')
|
|
22
25
|
if (!secret) return res.status(400).send('Missing "hygraphSecret" config variable')
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SearchFormProps } from '@graphcommerce/magento-search'
|
|
2
|
-
import {
|
|
2
|
+
import { algoliaSearchDebounceTime } from '@graphcommerce/next-config/config'
|
|
3
|
+
import { Trans } from '@lingui/react/macro'
|
|
3
4
|
import { Box, debounce } from '@mui/material'
|
|
4
5
|
import TextField from '@mui/material/TextField'
|
|
5
6
|
import type { ChangeEvent } from 'react'
|
|
@@ -20,7 +21,7 @@ export function SearchBox(props: SearchBoxProps) {
|
|
|
20
21
|
const debounceSearch = useCallback(
|
|
21
22
|
debounce(
|
|
22
23
|
(e: ChangeEvent<HTMLTextAreaElement | HTMLInputElement>) => refine(e.target.value),
|
|
23
|
-
|
|
24
|
+
algoliaSearchDebounceTime ?? 0,
|
|
24
25
|
),
|
|
25
26
|
[refine],
|
|
26
27
|
)
|
|
@@ -39,8 +40,8 @@ export function SearchBox(props: SearchBoxProps) {
|
|
|
39
40
|
paddingRight: '7px',
|
|
40
41
|
})}
|
|
41
42
|
>
|
|
42
|
-
{totalResults === 1 && <Trans
|
|
43
|
-
{totalResults > 1 && <Trans
|
|
43
|
+
{totalResults === 1 && <Trans>{totalResults} result</Trans>}
|
|
44
|
+
{totalResults > 1 && <Trans>{totalResults} results</Trans>}
|
|
44
45
|
</Box>
|
|
45
46
|
)
|
|
46
47
|
|
package/lib/configuration.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { algoliaApplicationId, algoliaSearchOnlyApiKey } from '@graphcommerce/next-config/config'
|
|
2
|
+
|
|
3
|
+
export const applicationId = algoliaApplicationId ?? ''
|
|
4
|
+
export const searchOnlyApiKey = algoliaSearchOnlyApiKey ?? ''
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/algolia-search",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "10.0.0-canary.56",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,26 +12,38 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"algoliasearch": "^4.
|
|
15
|
+
"algoliasearch": "^4.25.2"
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@graphcommerce/ecommerce-ui": "^
|
|
19
|
-
"@graphcommerce/eslint-config-pwa": "^
|
|
20
|
-
"@graphcommerce/graphql": "^
|
|
21
|
-
"@graphcommerce/graphql-mesh": "^
|
|
22
|
-
"@graphcommerce/magento-product": "^
|
|
23
|
-
"@graphcommerce/magento-search": "^
|
|
24
|
-
"@graphcommerce/magento-store": "^
|
|
25
|
-
"@graphcommerce/next-config": "^
|
|
26
|
-
"@graphcommerce/next-ui": "^
|
|
27
|
-
"@graphcommerce/prettier-config-pwa": "^
|
|
28
|
-
"@graphcommerce/typescript-config-pwa": "^
|
|
29
|
-
"@lingui/core": "^
|
|
30
|
-
"@lingui/macro": "^
|
|
31
|
-
"@lingui/react": "^
|
|
18
|
+
"@graphcommerce/ecommerce-ui": "^10.0.0-canary.56",
|
|
19
|
+
"@graphcommerce/eslint-config-pwa": "^10.0.0-canary.56",
|
|
20
|
+
"@graphcommerce/graphql": "^10.0.0-canary.56",
|
|
21
|
+
"@graphcommerce/graphql-mesh": "^10.0.0-canary.56",
|
|
22
|
+
"@graphcommerce/magento-product": "^10.0.0-canary.56",
|
|
23
|
+
"@graphcommerce/magento-search": "^10.0.0-canary.56",
|
|
24
|
+
"@graphcommerce/magento-store": "^10.0.0-canary.56",
|
|
25
|
+
"@graphcommerce/next-config": "^10.0.0-canary.56",
|
|
26
|
+
"@graphcommerce/next-ui": "^10.0.0-canary.56",
|
|
27
|
+
"@graphcommerce/prettier-config-pwa": "^10.0.0-canary.56",
|
|
28
|
+
"@graphcommerce/typescript-config-pwa": "^10.0.0-canary.56",
|
|
29
|
+
"@lingui/core": "^5",
|
|
30
|
+
"@lingui/macro": "^5",
|
|
31
|
+
"@lingui/react": "^5",
|
|
32
32
|
"@mui/material": "^5.10.16",
|
|
33
33
|
"next": "*",
|
|
34
|
-
"react": "^
|
|
34
|
+
"react": "^19.2.0",
|
|
35
35
|
"react-instantsearch-hooks-web": "^6.47.3"
|
|
36
|
+
},
|
|
37
|
+
"exports": {
|
|
38
|
+
".": "./index.ts",
|
|
39
|
+
"./plugins/AlgoliaCategorySearchResults": "./plugins/AlgoliaCategorySearchResults.tsx",
|
|
40
|
+
"./plugins/AlgoliaFiltersPlugin": "./plugins/AlgoliaFiltersPlugin.tsx",
|
|
41
|
+
"./plugins/AlgoliaPageSearchResults": "./plugins/AlgoliaPageSearchResults.tsx",
|
|
42
|
+
"./plugins/AlgoliaPaginationPlugin": "./plugins/AlgoliaPaginationPlugin.tsx",
|
|
43
|
+
"./plugins/AlgoliaProductListCountPlugin": "./plugins/AlgoliaProductListCountPlugin.tsx",
|
|
44
|
+
"./plugins/AlgoliaProductSearchResultsPlugin": "./plugins/AlgoliaProductSearchResultsPlugin.tsx",
|
|
45
|
+
"./plugins/AlgoliaProductSortPlugin": "./plugins/AlgoliaProductSortPlugin.tsx",
|
|
46
|
+
"./plugins/AlgoliaSearchContextPlugin": "./plugins/AlgoliaSearchContextPlugin.tsx",
|
|
47
|
+
"./plugins/AlgoliaSearchFieldPlugin": "./plugins/AlgoliaSearchFieldPlugin.tsx"
|
|
36
48
|
}
|
|
37
49
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ProductFiltersProps } from '@graphcommerce/magento-product'
|
|
2
2
|
import type { IfConfig, PluginProps } from '@graphcommerce/next-config'
|
|
3
3
|
import { storefrontConfig } from '@graphcommerce/next-ui'
|
|
4
|
-
import {
|
|
4
|
+
import { t } from '@lingui/core/macro'
|
|
5
5
|
import { useRouter } from 'next/router'
|
|
6
6
|
import { useSortBy } from 'react-instantsearch-hooks-web'
|
|
7
7
|
import { RenderChip } from '../components/Chip/RenderChip'
|
|
@@ -20,14 +20,7 @@ function AlgoliaProductSortPlugin(props: PluginProps<ProductFiltersProps>) {
|
|
|
20
20
|
|
|
21
21
|
if (!options) return null
|
|
22
22
|
|
|
23
|
-
return
|
|
24
|
-
<RenderChip
|
|
25
|
-
__typename='Sort'
|
|
26
|
-
title={rest.title ?? i18n._(/* i18n */ 'Sort')}
|
|
27
|
-
attribute='sort'
|
|
28
|
-
{...sort}
|
|
29
|
-
/>
|
|
30
|
-
)
|
|
23
|
+
return <RenderChip __typename='Sort' title={rest.title ?? t`Sort`} attribute='sort' {...sort} />
|
|
31
24
|
}
|
|
32
25
|
|
|
33
26
|
export const Plugin = AlgoliaProductSortPlugin
|