diff --git a/packages/algoliasearch/builds/browser.ts b/packages/algoliasearch/builds/browser.ts index 004e88e2a..3287beb77 100644 --- a/packages/algoliasearch/builds/browser.ts +++ b/packages/algoliasearch/builds/browser.ts @@ -14,6 +14,8 @@ import type { QuerySuggestionsClient } from '@algolia/client-query-suggestions'; import { querySuggestionsClient } from '@algolia/client-query-suggestions'; import type { SearchClient } from '@algolia/client-search'; import { searchClient } from '@algolia/client-search'; +import type { CompositionClient } from '@algolia/composition'; +import { compositionClient } from '@algolia/composition'; import type { IngestionClient } from '@algolia/ingestion'; import { ingestionClient } from '@algolia/ingestion'; import type { MonitoringClient } from '@algolia/monitoring'; @@ -36,6 +38,7 @@ export * from './models'; export type Algoliasearch = SearchClient & { initAbtesting: (initOptions: InitClientOptions & AbtestingRegionOptions) => AbtestingClient; initAnalytics: (initOptions: InitClientOptions & AnalyticsRegionOptions) => AnalyticsClient; + initComposition: (initOptions?: InitClientOptions) => CompositionClient; initIngestion: (initOptions: InitClientOptions & IngestionRegionOptions) => IngestionClient; initInsights: (initOptions: InitClientOptions & InsightsRegionOptions) => InsightsClient; initMonitoring: (initOptions?: InitClientOptions) => MonitoringClient; @@ -83,6 +86,10 @@ export function algoliasearch(appId: string, apiKey: string, options?: ClientOpt ); }, + initComposition: (initOptions: InitClientOptions = {}): CompositionClient => { + return compositionClient(initOptions.appId || appId, initOptions.apiKey || apiKey, initOptions.options); + }, + initIngestion: (initOptions: InitClientOptions & IngestionRegionOptions): IngestionClient => { return ingestionClient( initOptions.appId || appId, diff --git a/packages/algoliasearch/builds/fetch.ts b/packages/algoliasearch/builds/fetch.ts index 004e88e2a..3287beb77 100644 --- a/packages/algoliasearch/builds/fetch.ts +++ b/packages/algoliasearch/builds/fetch.ts @@ -14,6 +14,8 @@ import type { QuerySuggestionsClient } from '@algolia/client-query-suggestions'; import { querySuggestionsClient } from '@algolia/client-query-suggestions'; import type { SearchClient } from '@algolia/client-search'; import { searchClient } from '@algolia/client-search'; +import type { CompositionClient } from '@algolia/composition'; +import { compositionClient } from '@algolia/composition'; import type { IngestionClient } from '@algolia/ingestion'; import { ingestionClient } from '@algolia/ingestion'; import type { MonitoringClient } from '@algolia/monitoring'; @@ -36,6 +38,7 @@ export * from './models'; export type Algoliasearch = SearchClient & { initAbtesting: (initOptions: InitClientOptions & AbtestingRegionOptions) => AbtestingClient; initAnalytics: (initOptions: InitClientOptions & AnalyticsRegionOptions) => AnalyticsClient; + initComposition: (initOptions?: InitClientOptions) => CompositionClient; initIngestion: (initOptions: InitClientOptions & IngestionRegionOptions) => IngestionClient; initInsights: (initOptions: InitClientOptions & InsightsRegionOptions) => InsightsClient; initMonitoring: (initOptions?: InitClientOptions) => MonitoringClient; @@ -83,6 +86,10 @@ export function algoliasearch(appId: string, apiKey: string, options?: ClientOpt ); }, + initComposition: (initOptions: InitClientOptions = {}): CompositionClient => { + return compositionClient(initOptions.appId || appId, initOptions.apiKey || apiKey, initOptions.options); + }, + initIngestion: (initOptions: InitClientOptions & IngestionRegionOptions): IngestionClient => { return ingestionClient( initOptions.appId || appId, diff --git a/packages/algoliasearch/builds/models.ts b/packages/algoliasearch/builds/models.ts index f58ec0096..0b74f28fd 100644 --- a/packages/algoliasearch/builds/models.ts +++ b/packages/algoliasearch/builds/models.ts @@ -2,6 +2,7 @@ import type { Region as AbtestingRegion, RegionOptions as AbtestingRegionOptions } from '@algolia/client-abtesting'; import type { Region as AnalyticsRegion, RegionOptions as AnalyticsRegionOptions } from '@algolia/client-analytics'; + import type { Region as InsightsRegion, RegionOptions as InsightsRegionOptions } from '@algolia/client-insights'; import type { Region as IngestionRegion, RegionOptions as IngestionRegionOptions } from '@algolia/ingestion'; @@ -46,8 +47,8 @@ import type { CustomGetProps, CustomPostProps, CustomPutProps, - DeletedAtResponse, DeleteSourceProps, + DeletedAtResponse, Distinct, Edit, EditType, @@ -55,18 +56,20 @@ import type { ExactOnSingleWordQuery, Exhaustive, FacetFilters, + FacetHits, FacetOrdering, - Facets, FacetStats, + Facets, GetTaskProps, HighlightResult, HighlightResultOption, + Hit, IgnorePlurals, IndexSettingsAsSearchParams, InsideBoundingBox, Languages, - MatchedGeoLocation, MatchLevel, + MatchedGeoLocation, Mode, NumericFilters, OptionalFilters, @@ -79,6 +82,7 @@ import type { QueryType, Range, RankingInfo, + ReRankingApplyFilter, Redirect, RedirectRuleIndexData, RedirectRuleIndexMetadata, @@ -86,11 +90,15 @@ import type { RemoveStopWords, RemoveWordsIfNoResults, RenderingContent, - ReRankingApplyFilter, + SearchForFacetValuesProps, + SearchForFacetValuesRequest, + SearchForFacetValuesResponse, + SearchHits, SearchPagination, SearchParams, SearchParamsObject, SearchParamsQuery, + SearchResponse, SemanticSearch, SnippetResult, SnippetResultOption, @@ -113,6 +121,7 @@ export * from '@algolia/client-insights'; export * from '@algolia/client-personalization'; export * from '@algolia/client-query-suggestions'; export * from '@algolia/client-search'; +export * from '@algolia/composition'; export * from '@algolia/ingestion'; export * from '@algolia/monitoring'; export * from '@algolia/recommend'; @@ -178,8 +187,8 @@ export type { CustomGetProps, CustomPostProps, CustomPutProps, - DeletedAtResponse, DeleteSourceProps, + DeletedAtResponse, Distinct, Edit, EditType, @@ -187,18 +196,20 @@ export type { ExactOnSingleWordQuery, Exhaustive, FacetFilters, + FacetHits, FacetOrdering, - Facets, FacetStats, + Facets, GetTaskProps, HighlightResult, HighlightResultOption, + Hit, IgnorePlurals, IndexSettingsAsSearchParams, InsideBoundingBox, Languages, - MatchedGeoLocation, MatchLevel, + MatchedGeoLocation, Mode, NumericFilters, OptionalFilters, @@ -211,6 +222,7 @@ export type { QueryType, Range, RankingInfo, + ReRankingApplyFilter, Redirect, RedirectRuleIndexData, RedirectRuleIndexMetadata, @@ -218,11 +230,15 @@ export type { RemoveStopWords, RemoveWordsIfNoResults, RenderingContent, - ReRankingApplyFilter, + SearchForFacetValuesProps, + SearchForFacetValuesRequest, + SearchForFacetValuesResponse, + SearchHits, SearchPagination, SearchParams, SearchParamsObject, SearchParamsQuery, + SearchResponse, SemanticSearch, SnippetResult, SnippetResultOption, diff --git a/packages/algoliasearch/builds/node.ts b/packages/algoliasearch/builds/node.ts index 004e88e2a..3287beb77 100644 --- a/packages/algoliasearch/builds/node.ts +++ b/packages/algoliasearch/builds/node.ts @@ -14,6 +14,8 @@ import type { QuerySuggestionsClient } from '@algolia/client-query-suggestions'; import { querySuggestionsClient } from '@algolia/client-query-suggestions'; import type { SearchClient } from '@algolia/client-search'; import { searchClient } from '@algolia/client-search'; +import type { CompositionClient } from '@algolia/composition'; +import { compositionClient } from '@algolia/composition'; import type { IngestionClient } from '@algolia/ingestion'; import { ingestionClient } from '@algolia/ingestion'; import type { MonitoringClient } from '@algolia/monitoring'; @@ -36,6 +38,7 @@ export * from './models'; export type Algoliasearch = SearchClient & { initAbtesting: (initOptions: InitClientOptions & AbtestingRegionOptions) => AbtestingClient; initAnalytics: (initOptions: InitClientOptions & AnalyticsRegionOptions) => AnalyticsClient; + initComposition: (initOptions?: InitClientOptions) => CompositionClient; initIngestion: (initOptions: InitClientOptions & IngestionRegionOptions) => IngestionClient; initInsights: (initOptions: InitClientOptions & InsightsRegionOptions) => InsightsClient; initMonitoring: (initOptions?: InitClientOptions) => MonitoringClient; @@ -83,6 +86,10 @@ export function algoliasearch(appId: string, apiKey: string, options?: ClientOpt ); }, + initComposition: (initOptions: InitClientOptions = {}): CompositionClient => { + return compositionClient(initOptions.appId || appId, initOptions.apiKey || apiKey, initOptions.options); + }, + initIngestion: (initOptions: InitClientOptions & IngestionRegionOptions): IngestionClient => { return ingestionClient( initOptions.appId || appId, diff --git a/packages/algoliasearch/builds/worker.ts b/packages/algoliasearch/builds/worker.ts index 004e88e2a..3287beb77 100644 --- a/packages/algoliasearch/builds/worker.ts +++ b/packages/algoliasearch/builds/worker.ts @@ -14,6 +14,8 @@ import type { QuerySuggestionsClient } from '@algolia/client-query-suggestions'; import { querySuggestionsClient } from '@algolia/client-query-suggestions'; import type { SearchClient } from '@algolia/client-search'; import { searchClient } from '@algolia/client-search'; +import type { CompositionClient } from '@algolia/composition'; +import { compositionClient } from '@algolia/composition'; import type { IngestionClient } from '@algolia/ingestion'; import { ingestionClient } from '@algolia/ingestion'; import type { MonitoringClient } from '@algolia/monitoring'; @@ -36,6 +38,7 @@ export * from './models'; export type Algoliasearch = SearchClient & { initAbtesting: (initOptions: InitClientOptions & AbtestingRegionOptions) => AbtestingClient; initAnalytics: (initOptions: InitClientOptions & AnalyticsRegionOptions) => AnalyticsClient; + initComposition: (initOptions?: InitClientOptions) => CompositionClient; initIngestion: (initOptions: InitClientOptions & IngestionRegionOptions) => IngestionClient; initInsights: (initOptions: InitClientOptions & InsightsRegionOptions) => InsightsClient; initMonitoring: (initOptions?: InitClientOptions) => MonitoringClient; @@ -83,6 +86,10 @@ export function algoliasearch(appId: string, apiKey: string, options?: ClientOpt ); }, + initComposition: (initOptions: InitClientOptions = {}): CompositionClient => { + return compositionClient(initOptions.appId || appId, initOptions.apiKey || apiKey, initOptions.options); + }, + initIngestion: (initOptions: InitClientOptions & IngestionRegionOptions): IngestionClient => { return ingestionClient( initOptions.appId || appId, diff --git a/packages/algoliasearch/package.json b/packages/algoliasearch/package.json index 17636c6cd..fa3ac077c 100644 --- a/packages/algoliasearch/package.json +++ b/packages/algoliasearch/package.json @@ -81,6 +81,7 @@ "@algolia/client-personalization": "5.19.0", "@algolia/client-query-suggestions": "5.19.0", "@algolia/client-search": "5.19.0", + "@algolia/composition": "0.0.1", "@algolia/ingestion": "1.19.0", "@algolia/monitoring": "1.19.0", "@algolia/recommend": "5.19.0", diff --git a/packages/client-composition/README.md b/packages/client-composition/README.md index c1381d311..c952dada1 100644 --- a/packages/client-composition/README.md +++ b/packages/client-composition/README.md @@ -66,7 +66,7 @@ import { compositionClient } from '@algolia/client-composition'; const client = compositionClient('YOUR_APP_ID', 'YOUR_API_KEY'); ``` -For full documentation, visit the **[Algolia JavaScript API Client](https://www.algolia.com/doc/libraries/javascript/v5/methods/composition/)**. +For full documentation, visit the **[Algolia JavaScript API Client](https://www.algolia.com/doc/libraries/javascript/v5/methods/composition-full/)**. ## ❓ Troubleshooting diff --git a/packages/client-composition/builds/browser.ts b/packages/client-composition/builds/browser.ts index 8fd653013..933a90d96 100644 --- a/packages/client-composition/builds/browser.ts +++ b/packages/client-composition/builds/browser.ts @@ -11,9 +11,9 @@ import { import type { ClientOptions } from '@algolia/client-common'; -import { apiClientVersion, createCompositionClient } from '../src/compositionClient'; +import { apiClientVersion, createCompositionClient } from '../src/compositionFullClient'; -export { apiClientVersion } from '../src/compositionClient'; +export { apiClientVersion } from '../src/compositionFullClient'; export * from '../model'; diff --git a/packages/client-composition/builds/fetch.ts b/packages/client-composition/builds/fetch.ts index 8934cdc33..55992207f 100644 --- a/packages/client-composition/builds/fetch.ts +++ b/packages/client-composition/builds/fetch.ts @@ -7,9 +7,9 @@ import { createFetchRequester } from '@algolia/requester-fetch'; import type { ClientOptions } from '@algolia/client-common'; -import { createCompositionClient } from '../src/compositionClient'; +import { createCompositionClient } from '../src/compositionFullClient'; -export { apiClientVersion } from '../src/compositionClient'; +export { apiClientVersion } from '../src/compositionFullClient'; export * from '../model'; diff --git a/packages/client-composition/builds/node.ts b/packages/client-composition/builds/node.ts index 26d2ad6d1..3590107d6 100644 --- a/packages/client-composition/builds/node.ts +++ b/packages/client-composition/builds/node.ts @@ -8,9 +8,9 @@ import { createMemoryCache, createNullCache, createNullLogger } from '@algolia/c import type { ClientOptions } from '@algolia/client-common'; -import { createCompositionClient } from '../src/compositionClient'; +import { createCompositionClient } from '../src/compositionFullClient'; -export { apiClientVersion } from '../src/compositionClient'; +export { apiClientVersion } from '../src/compositionFullClient'; export * from '../model'; diff --git a/packages/client-composition/builds/worker.ts b/packages/client-composition/builds/worker.ts index b47e7b73c..500df27b0 100644 --- a/packages/client-composition/builds/worker.ts +++ b/packages/client-composition/builds/worker.ts @@ -7,9 +7,9 @@ import { createFetchRequester } from '@algolia/requester-fetch'; import type { ClientOptions } from '@algolia/client-common'; -import { createCompositionClient } from '../src/compositionClient'; +import { createCompositionClient } from '../src/compositionFullClient'; -export { apiClientVersion } from '../src/compositionClient'; +export { apiClientVersion } from '../src/compositionFullClient'; export * from '../model'; diff --git a/packages/client-composition/src/compositionClient.ts b/packages/client-composition/src/compositionFullClient.ts similarity index 99% rename from packages/client-composition/src/compositionClient.ts rename to packages/client-composition/src/compositionFullClient.ts index 764111cd0..ed79224db 100644 --- a/packages/client-composition/src/compositionClient.ts +++ b/packages/client-composition/src/compositionFullClient.ts @@ -91,7 +91,7 @@ export function createCompositionClient({ ...options, algoliaAgent: getAlgoliaAgent({ algoliaAgents, - client: 'Composition', + client: 'CompositionFull', version: apiClientVersion, }), baseHeaders: { diff --git a/packages/composition/LICENSE b/packages/composition/LICENSE new file mode 100644 index 000000000..fddf416f9 --- /dev/null +++ b/packages/composition/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2013-Present Algolia + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/composition/README.md b/packages/composition/README.md new file mode 100644 index 000000000..89761b638 --- /dev/null +++ b/packages/composition/README.md @@ -0,0 +1,77 @@ +

+ + Algolia for JavaScript + + +

The perfect starting point to integrate Algolia within your JavaScript project

+ +

+ NPM version + NPM downloads + jsDelivr Downloads + License +

+

+ +

+ Documentation • + InstantSearch • + Community Forum • + Stack Overflow • + Report a bug • + FAQ • + Support +

+ +## ✨ Features + +- Thin & **minimal low-level HTTP client** to interact with Algolia's API +- Works both on the **browser** and **node.js** +- **UMD and ESM compatible**, you can use it with any module loader +- Built with TypeScript + +## 💡 Getting Started + +> [!TIP] +> This API client is already a dependency of [the algoliasearch client](https://www.npmjs.com/package/algoliasearch), you don't need to manually install `@algolia/composition` if you already have `algoliasearch` installed. + +To get started, you first need to install @algolia/composition (or any other available API client package). +All of our clients comes with type definition, and are available for both browser and node environments. + +### With a package manager + +```bash +yarn add @algolia/composition@0.0.1 +# or +npm install @algolia/composition@0.0.1 +# or +pnpm add @algolia/composition@0.0.1 +``` + +### Without a package manager + +Add the following JavaScript snippet to the of your website: + +```html + +``` + +### Usage + +You can now import the Algolia API client in your project and play with it. + +```js +import { compositionClient } from '@algolia/composition'; + +const client = compositionClient('YOUR_APP_ID', 'YOUR_API_KEY'); +``` + +For full documentation, visit the **[Algolia JavaScript API Client](https://www.algolia.com/doc/libraries/javascript/v5/methods/composition/)**. + +## ❓ Troubleshooting + +Encountering an issue? Before reaching out to support, we recommend heading to our [FAQ](https://www.algolia.com/doc/libraries/javascript/v5/) where you will find answers for the most common issues and gotchas with the client. You can also open [a GitHub issue](https://github.com/algolia/api-clients-automation/issues/new?assignees=&labels=&projects=&template=Bug_report.md) + +## 📄 License + +The Algolia JavaScript API Client is an open-sourced software licensed under the [MIT license](LICENSE). diff --git a/packages/composition/builds/browser.ts b/packages/composition/builds/browser.ts new file mode 100644 index 000000000..8fd653013 --- /dev/null +++ b/packages/composition/builds/browser.ts @@ -0,0 +1,50 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import { createXhrRequester } from '@algolia/requester-browser-xhr'; + +import { + createBrowserLocalStorageCache, + createFallbackableCache, + createMemoryCache, + createNullLogger, +} from '@algolia/client-common'; + +import type { ClientOptions } from '@algolia/client-common'; + +import { apiClientVersion, createCompositionClient } from '../src/compositionClient'; + +export { apiClientVersion } from '../src/compositionClient'; + +export * from '../model'; + +export function compositionClient(appId: string, apiKey: string, options?: ClientOptions): CompositionClient { + if (!appId || typeof appId !== 'string') { + throw new Error('`appId` is missing.'); + } + + if (!apiKey || typeof apiKey !== 'string') { + throw new Error('`apiKey` is missing.'); + } + + return createCompositionClient({ + appId, + apiKey, + timeouts: { + connect: 1000, + read: 2000, + write: 30000, + }, + logger: createNullLogger(), + requester: createXhrRequester(), + algoliaAgents: [{ segment: 'Browser' }], + authMode: 'WithinHeaders', + responsesCache: createMemoryCache(), + requestsCache: createMemoryCache({ serializable: false }), + hostsCache: createFallbackableCache({ + caches: [createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }), createMemoryCache()], + }), + ...options, + }); +} + +export type CompositionClient = ReturnType; diff --git a/packages/composition/builds/fetch.ts b/packages/composition/builds/fetch.ts new file mode 100644 index 000000000..8934cdc33 --- /dev/null +++ b/packages/composition/builds/fetch.ts @@ -0,0 +1,43 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +export type CompositionClient = ReturnType; + +import { createMemoryCache, createNullCache, createNullLogger } from '@algolia/client-common'; +import { createFetchRequester } from '@algolia/requester-fetch'; + +import type { ClientOptions } from '@algolia/client-common'; + +import { createCompositionClient } from '../src/compositionClient'; + +export { apiClientVersion } from '../src/compositionClient'; + +export * from '../model'; + +export function compositionClient(appId: string, apiKey: string, options?: ClientOptions): CompositionClient { + if (!appId || typeof appId !== 'string') { + throw new Error('`appId` is missing.'); + } + + if (!apiKey || typeof apiKey !== 'string') { + throw new Error('`apiKey` is missing.'); + } + + return { + ...createCompositionClient({ + appId, + apiKey, + timeouts: { + connect: 2000, + read: 5000, + write: 30000, + }, + logger: createNullLogger(), + requester: createFetchRequester(), + algoliaAgents: [{ segment: 'Fetch' }], + responsesCache: createNullCache(), + requestsCache: createNullCache(), + hostsCache: createMemoryCache(), + ...options, + }), + }; +} diff --git a/packages/composition/builds/node.ts b/packages/composition/builds/node.ts new file mode 100644 index 000000000..26d2ad6d1 --- /dev/null +++ b/packages/composition/builds/node.ts @@ -0,0 +1,44 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +export type CompositionClient = ReturnType; + +import { createHttpRequester } from '@algolia/requester-node-http'; + +import { createMemoryCache, createNullCache, createNullLogger } from '@algolia/client-common'; + +import type { ClientOptions } from '@algolia/client-common'; + +import { createCompositionClient } from '../src/compositionClient'; + +export { apiClientVersion } from '../src/compositionClient'; + +export * from '../model'; + +export function compositionClient(appId: string, apiKey: string, options?: ClientOptions): CompositionClient { + if (!appId || typeof appId !== 'string') { + throw new Error('`appId` is missing.'); + } + + if (!apiKey || typeof apiKey !== 'string') { + throw new Error('`apiKey` is missing.'); + } + + return { + ...createCompositionClient({ + appId, + apiKey, + timeouts: { + connect: 2000, + read: 5000, + write: 30000, + }, + logger: createNullLogger(), + requester: createHttpRequester(), + algoliaAgents: [{ segment: 'Node.js', version: process.versions.node }], + responsesCache: createNullCache(), + requestsCache: createNullCache(), + hostsCache: createMemoryCache(), + ...options, + }), + }; +} diff --git a/packages/composition/builds/worker.ts b/packages/composition/builds/worker.ts new file mode 100644 index 000000000..b47e7b73c --- /dev/null +++ b/packages/composition/builds/worker.ts @@ -0,0 +1,43 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +export type CompositionClient = ReturnType; + +import { createMemoryCache, createNullCache, createNullLogger } from '@algolia/client-common'; +import { createFetchRequester } from '@algolia/requester-fetch'; + +import type { ClientOptions } from '@algolia/client-common'; + +import { createCompositionClient } from '../src/compositionClient'; + +export { apiClientVersion } from '../src/compositionClient'; + +export * from '../model'; + +export function compositionClient(appId: string, apiKey: string, options?: ClientOptions): CompositionClient { + if (!appId || typeof appId !== 'string') { + throw new Error('`appId` is missing.'); + } + + if (!apiKey || typeof apiKey !== 'string') { + throw new Error('`apiKey` is missing.'); + } + + return { + ...createCompositionClient({ + appId, + apiKey, + timeouts: { + connect: 2000, + read: 5000, + write: 30000, + }, + logger: createNullLogger(), + requester: createFetchRequester(), + algoliaAgents: [{ segment: 'Worker' }], + responsesCache: createNullCache(), + requestsCache: createNullCache(), + hostsCache: createMemoryCache(), + ...options, + }), + }; +} diff --git a/packages/composition/index.d.ts b/packages/composition/index.d.ts new file mode 100644 index 000000000..e81a1cd3e --- /dev/null +++ b/packages/composition/index.d.ts @@ -0,0 +1 @@ +export * from './dist/node'; diff --git a/packages/composition/index.js b/packages/composition/index.js new file mode 100644 index 000000000..21e26aad3 --- /dev/null +++ b/packages/composition/index.js @@ -0,0 +1 @@ +module.exports = require('./dist/builds/node.cjs'); diff --git a/packages/composition/model/aroundPrecision.ts b/packages/composition/model/aroundPrecision.ts new file mode 100644 index 000000000..79ff0cd59 --- /dev/null +++ b/packages/composition/model/aroundPrecision.ts @@ -0,0 +1,8 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { Range } from './range'; + +/** + * Precision of a coordinate-based search in meters to group results with similar distances. The Geo ranking criterion considers all matches within the same range of distances to be equal. + */ +export type AroundPrecision = number | Array; diff --git a/packages/composition/model/aroundRadius.ts b/packages/composition/model/aroundRadius.ts new file mode 100644 index 000000000..8198f1e75 --- /dev/null +++ b/packages/composition/model/aroundRadius.ts @@ -0,0 +1,8 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { AroundRadiusAll } from './aroundRadiusAll'; + +/** + * Maximum radius for a search around a central location. This parameter works in combination with the `aroundLatLng` and `aroundLatLngViaIP` parameters. By default, the search radius is determined automatically from the density of hits around the central location. The search radius is small if there are many hits close to the central coordinates. + */ +export type AroundRadius = number | AroundRadiusAll; diff --git a/packages/composition/model/aroundRadiusAll.ts b/packages/composition/model/aroundRadiusAll.ts new file mode 100644 index 000000000..e5f107060 --- /dev/null +++ b/packages/composition/model/aroundRadiusAll.ts @@ -0,0 +1,6 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +/** + * Return all records with a valid `_geoloc` attribute. Don\'t filter by distance. + */ +export type AroundRadiusAll = 'all'; diff --git a/packages/composition/model/banner.ts b/packages/composition/model/banner.ts new file mode 100644 index 000000000..793feec15 --- /dev/null +++ b/packages/composition/model/banner.ts @@ -0,0 +1,13 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { BannerImage } from './bannerImage'; +import type { BannerLink } from './bannerLink'; + +/** + * Banner with image and link to redirect users. + */ +export type Banner = { + image?: BannerImage; + + link?: BannerLink; +}; diff --git a/packages/composition/model/bannerImage.ts b/packages/composition/model/bannerImage.ts new file mode 100644 index 000000000..a0988168e --- /dev/null +++ b/packages/composition/model/bannerImage.ts @@ -0,0 +1,12 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { BannerImageUrl } from './bannerImageUrl'; + +/** + * Image to show inside a banner. + */ +export type BannerImage = { + urls?: Array; + + title?: string; +}; diff --git a/packages/composition/model/bannerImageUrl.ts b/packages/composition/model/bannerImageUrl.ts new file mode 100644 index 000000000..6be2b3efd --- /dev/null +++ b/packages/composition/model/bannerImageUrl.ts @@ -0,0 +1,8 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +/** + * URL for an image to show inside a banner. + */ +export type BannerImageUrl = { + url?: string; +}; diff --git a/packages/composition/model/bannerLink.ts b/packages/composition/model/bannerLink.ts new file mode 100644 index 000000000..52800a208 --- /dev/null +++ b/packages/composition/model/bannerLink.ts @@ -0,0 +1,8 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +/** + * Link for a banner defined in the Merchandising Studio. + */ +export type BannerLink = { + url?: string; +}; diff --git a/packages/composition/model/baseSearchResponse.ts b/packages/composition/model/baseSearchResponse.ts new file mode 100644 index 000000000..2c0cffc54 --- /dev/null +++ b/packages/composition/model/baseSearchResponse.ts @@ -0,0 +1,129 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { Exhaustive } from './exhaustive'; +import type { FacetStats } from './facetStats'; +import type { Redirect } from './redirect'; +import type { RenderingContent } from './renderingContent'; + +export type BaseSearchResponse = Record & { + /** + * A/B test ID. This is only included in the response for indices that are part of an A/B test. + */ + abTestID?: number; + + /** + * Variant ID. This is only included in the response for indices that are part of an A/B test. + */ + abTestVariantID?: number; + + /** + * Computed geographical location. + */ + aroundLatLng?: string; + + /** + * Distance from a central coordinate provided by `aroundLatLng`. + */ + automaticRadius?: string; + + exhaustive?: Exhaustive; + + /** + * Rules applied to the query. + */ + appliedRules?: Array>; + + /** + * See the `facetsCount` field of the `exhaustive` object in the response. + */ + exhaustiveFacetsCount?: boolean; + + /** + * See the `nbHits` field of the `exhaustive` object in the response. + */ + exhaustiveNbHits?: boolean; + + /** + * See the `typo` field of the `exhaustive` object in the response. + */ + exhaustiveTypo?: boolean; + + /** + * Facet counts. + */ + facets?: { [key: string]: { [key: string]: number } }; + + /** + * Statistics for numerical facets. + */ + facets_stats?: { [key: string]: FacetStats }; + + /** + * Index name used for the query. + */ + index?: string; + + /** + * Index name used for the query. During A/B testing, the targeted index isn\'t always the index used by the query. + */ + indexUsed?: string; + + /** + * Warnings about the query. + */ + message?: string; + + /** + * Number of hits selected and sorted by the relevant sort algorithm. + */ + nbSortedHits?: number; + + /** + * Post-[normalization](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/#what-does-normalization-mean) query string that will be searched. + */ + parsedQuery?: string; + + /** + * Time the server took to process the request, in milliseconds. + */ + processingTimeMS: number; + + /** + * Experimental. List of processing steps and their times, in milliseconds. You can use this list to investigate performance issues. + */ + processingTimingsMS?: Record; + + /** + * Markup text indicating which parts of the original query have been removed to retrieve a non-empty result set. + */ + queryAfterRemoval?: string; + + redirect?: Redirect; + + renderingContent?: RenderingContent; + + /** + * Time the server took to process the request, in milliseconds. + */ + serverTimeMS?: number; + + /** + * Host name of the server that processed the request. + */ + serverUsed?: string; + + /** + * An object with custom data. You can store up to 32kB as custom data. + */ + userData?: Record; + + /** + * Unique identifier for the query. This is used for [click analytics](https://www.algolia.com/doc/guides/analytics/click-analytics/). + */ + queryID?: string; + + /** + * Whether automatic events collection is enabled for the application. + */ + _automaticInsights?: boolean; +}; diff --git a/packages/composition/model/clientMethodProps.ts b/packages/composition/model/clientMethodProps.ts new file mode 100644 index 000000000..1811f4176 --- /dev/null +++ b/packages/composition/model/clientMethodProps.ts @@ -0,0 +1,30 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { RequestBody } from '../model/requestBody'; +import type { SearchForFacetValuesRequest } from '../model/searchForFacetValuesRequest'; + +/** + * Properties for the `search` method. + */ +export type SearchProps = { + /** + * Unique Composition ObjectID. + */ + compositionID: string; + requestBody: RequestBody; +}; + +/** + * Properties for the `searchForFacetValues` method. + */ +export type SearchForFacetValuesProps = { + /** + * Unique Composition ObjectID. + */ + compositionID: string; + /** + * Facet attribute in which to search for values. This attribute must be included in the `attributesForFaceting` index setting with the `searchable()` modifier. + */ + facetName: string; + searchForFacetValuesRequest?: SearchForFacetValuesRequest; +}; diff --git a/packages/composition/model/compositionBaseSearchResponse.ts b/packages/composition/model/compositionBaseSearchResponse.ts new file mode 100644 index 000000000..93ff89037 --- /dev/null +++ b/packages/composition/model/compositionBaseSearchResponse.ts @@ -0,0 +1,7 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { CompositionsSearchResponse } from './compositionsSearchResponse'; + +export type CompositionBaseSearchResponse = Record & { + compositions?: CompositionsSearchResponse; +}; diff --git a/packages/composition/model/compositionIdRankingInfo.ts b/packages/composition/model/compositionIdRankingInfo.ts new file mode 100644 index 000000000..76095fe08 --- /dev/null +++ b/packages/composition/model/compositionIdRankingInfo.ts @@ -0,0 +1,7 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +export type CompositionIdRankingInfo = { + index: string; + + injectedItemKey: string; +}; diff --git a/packages/composition/model/compositionRankingInfo.ts b/packages/composition/model/compositionRankingInfo.ts new file mode 100644 index 000000000..8a76969a4 --- /dev/null +++ b/packages/composition/model/compositionRankingInfo.ts @@ -0,0 +1,7 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { CompositionIdRankingInfo } from './compositionIdRankingInfo'; + +export type CompositionRankingInfo = { + composed?: { [key: string]: CompositionIdRankingInfo }; +}; diff --git a/packages/composition/model/compositionRunAppliedRules.ts b/packages/composition/model/compositionRunAppliedRules.ts new file mode 100644 index 000000000..6a101f1d1 --- /dev/null +++ b/packages/composition/model/compositionRunAppliedRules.ts @@ -0,0 +1,8 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +export type CompositionRunAppliedRules = { + /** + * Unique record identifier. + */ + objectID: string; +}; diff --git a/packages/composition/model/compositionRunSearchResponse.ts b/packages/composition/model/compositionRunSearchResponse.ts new file mode 100644 index 000000000..477ffd2d9 --- /dev/null +++ b/packages/composition/model/compositionRunSearchResponse.ts @@ -0,0 +1,12 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { CompositionRunAppliedRules } from './compositionRunAppliedRules'; + +export type CompositionRunSearchResponse = Record & { + /** + * Unique record identifier. + */ + objectID: string; + + appliedRules?: Array; +}; diff --git a/packages/composition/model/compositionsSearchResponse.ts b/packages/composition/model/compositionsSearchResponse.ts new file mode 100644 index 000000000..1db7f3852 --- /dev/null +++ b/packages/composition/model/compositionsSearchResponse.ts @@ -0,0 +1,7 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { CompositionRunSearchResponse } from './compositionRunSearchResponse'; + +export type CompositionsSearchResponse = Record & { + run: Array; +}; diff --git a/packages/composition/model/errorBase.ts b/packages/composition/model/errorBase.ts new file mode 100644 index 000000000..960e509cb --- /dev/null +++ b/packages/composition/model/errorBase.ts @@ -0,0 +1,8 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +/** + * Error. + */ +export type ErrorBase = Record & { + message?: string; +}; diff --git a/packages/composition/model/exhaustive.ts b/packages/composition/model/exhaustive.ts new file mode 100644 index 000000000..6e578adf1 --- /dev/null +++ b/packages/composition/model/exhaustive.ts @@ -0,0 +1,31 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +/** + * Whether certain properties of the search response are calculated exhaustive (exact) or approximated. + */ +export type Exhaustive = { + /** + * Whether the facet count is exhaustive (`true`) or approximate (`false`). See the [related discussion](https://support.algolia.com/hc/en-us/articles/4406975248145-Why-are-my-facet-and-hit-counts-not-accurate-). + */ + facetsCount?: boolean; + + /** + * The value is `false` if not all facet values are retrieved. + */ + facetValues?: boolean; + + /** + * Whether the `nbHits` is exhaustive (`true`) or approximate (`false`). When the query takes more than 50ms to be processed, the engine makes an approximation. This can happen when using complex filters on millions of records, when typo-tolerance was not exhaustive, or when enough hits have been retrieved (for example, after the engine finds 10,000 exact matches). `nbHits` is reported as non-exhaustive whenever an approximation is made, even if the approximation didn’t, in the end, impact the exhaustivity of the query. + */ + nbHits?: boolean; + + /** + * Rules matching exhaustivity. The value is `false` if rules were enable for this query, and could not be fully processed due a timeout. This is generally caused by the number of alternatives (such as typos) which is too large. + */ + rulesMatch?: boolean; + + /** + * Whether the typo search was exhaustive (`true`) or approximate (`false`). An approximation is done when the typo search query part takes more than 10% of the query budget (ie. 5ms by default) to be processed (this can happen when a lot of typo alternatives exist for the query). This field will not be included when typo-tolerance is entirely disabled. + */ + typo?: boolean; +}; diff --git a/packages/composition/model/facetFilters.ts b/packages/composition/model/facetFilters.ts new file mode 100644 index 000000000..0dc5e336e --- /dev/null +++ b/packages/composition/model/facetFilters.ts @@ -0,0 +1,6 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +/** + * Filter the search by facet values, so that only records with the same facet values are retrieved. **Prefer using the `filters` parameter, which supports all filter types and combinations with boolean operators.** - `[filter1, filter2]` is interpreted as `filter1 AND filter2`. - `[[filter1, filter2], filter3]` is interpreted as `filter1 OR filter2 AND filter3`. - `facet:-value` is interpreted as `NOT facet:value`. While it\'s best to avoid attributes that start with a `-`, you can still filter them by escaping with a backslash: `facet:\\-value`. + */ +export type FacetFilters = Array | string; diff --git a/packages/composition/model/facetHits.ts b/packages/composition/model/facetHits.ts new file mode 100644 index 000000000..bd205a61e --- /dev/null +++ b/packages/composition/model/facetHits.ts @@ -0,0 +1,18 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +export type FacetHits = { + /** + * Facet value. + */ + value: string; + + /** + * Highlighted attribute value, including HTML tags. + */ + highlighted: string; + + /** + * Number of records with this facet value. [The count may be approximated](https://support.algolia.com/hc/en-us/articles/4406975248145-Why-are-my-facet-and-hit-counts-not-accurate-). + */ + count: number; +}; diff --git a/packages/composition/model/facetOrdering.ts b/packages/composition/model/facetOrdering.ts new file mode 100644 index 000000000..18b84be27 --- /dev/null +++ b/packages/composition/model/facetOrdering.ts @@ -0,0 +1,16 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { Facets } from './facets'; +import type { Value } from './value'; + +/** + * Order of facet names and facet values in your UI. + */ +export type FacetOrdering = { + facets?: Facets; + + /** + * Order of facet values. One object for each facet. + */ + values?: { [key: string]: Value }; +}; diff --git a/packages/composition/model/facetStats.ts b/packages/composition/model/facetStats.ts new file mode 100644 index 000000000..f8bb276a8 --- /dev/null +++ b/packages/composition/model/facetStats.ts @@ -0,0 +1,23 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +export type FacetStats = { + /** + * Minimum value in the results. + */ + min?: number; + + /** + * Maximum value in the results. + */ + max?: number; + + /** + * Average facet value in the results. + */ + avg?: number; + + /** + * Sum of all values in the results. + */ + sum?: number; +}; diff --git a/packages/composition/model/facets.ts b/packages/composition/model/facets.ts new file mode 100644 index 000000000..d99f83ff2 --- /dev/null +++ b/packages/composition/model/facets.ts @@ -0,0 +1,11 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +/** + * Order of facet names. + */ +export type Facets = { + /** + * Explicit order of facets or facet values. This setting lets you always show specific facets or facet values at the top of the list. + */ + order?: Array; +}; diff --git a/packages/composition/model/highlightResult.ts b/packages/composition/model/highlightResult.ts new file mode 100644 index 000000000..102271a17 --- /dev/null +++ b/packages/composition/model/highlightResult.ts @@ -0,0 +1,5 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { HighlightResultOption } from './highlightResultOption'; + +export type HighlightResult = HighlightResultOption | { [key: string]: HighlightResult } | Array; diff --git a/packages/composition/model/highlightResultOption.ts b/packages/composition/model/highlightResultOption.ts new file mode 100644 index 000000000..47ab0b748 --- /dev/null +++ b/packages/composition/model/highlightResultOption.ts @@ -0,0 +1,25 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { MatchLevel } from './matchLevel'; + +/** + * Surround words that match the query with HTML tags for highlighting. + */ +export type HighlightResultOption = { + /** + * Highlighted attribute value, including HTML tags. + */ + value: string; + + matchLevel: MatchLevel; + + /** + * List of matched words from the search query. + */ + matchedWords: Array; + + /** + * Whether the entire attribute value is highlighted. + */ + fullyHighlighted?: boolean; +}; diff --git a/packages/composition/model/hit.ts b/packages/composition/model/hit.ts new file mode 100644 index 000000000..a7d56b6c2 --- /dev/null +++ b/packages/composition/model/hit.ts @@ -0,0 +1,29 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { HighlightResult } from './highlightResult'; +import type { HitRankingInfo } from './hitRankingInfo'; +import type { SnippetResult } from './snippetResult'; + +/** + * Search result. A hit is a record from your index, augmented with special attributes for highlighting, snippeting, and ranking. + */ +export type Hit> = T & { + /** + * Unique record identifier. + */ + objectID: string; + + /** + * Surround words that match the query with HTML tags for highlighting. + */ + _highlightResult?: { [key: string]: HighlightResult }; + + /** + * Snippets that show the context around a matching search query. + */ + _snippetResult?: { [key: string]: SnippetResult }; + + _rankingInfo?: HitRankingInfo; + + _distinctSeqID?: number; +}; diff --git a/packages/composition/model/hitRankingInfo.ts b/packages/composition/model/hitRankingInfo.ts new file mode 100644 index 000000000..7f1379c9a --- /dev/null +++ b/packages/composition/model/hitRankingInfo.ts @@ -0,0 +1,6 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { CompositionRankingInfo } from './compositionRankingInfo'; +import type { RankingInfo } from './rankingInfo'; + +export type HitRankingInfo = RankingInfo & CompositionRankingInfo; diff --git a/packages/composition/model/index.ts b/packages/composition/model/index.ts new file mode 100644 index 000000000..d040613e2 --- /dev/null +++ b/packages/composition/model/index.ts @@ -0,0 +1,62 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +export * from './aroundPrecision'; +export * from './aroundRadius'; +export * from './aroundRadiusAll'; +export * from './banner'; +export * from './bannerImage'; +export * from './bannerImageUrl'; +export * from './bannerLink'; +export * from './baseSearchResponse'; +export * from './clientMethodProps'; +export * from './compositionBaseSearchResponse'; +export * from './compositionIdRankingInfo'; +export * from './compositionRankingInfo'; +export * from './compositionRunAppliedRules'; +export * from './compositionRunSearchResponse'; +export * from './compositionsSearchResponse'; +export * from './errorBase'; +export * from './exhaustive'; +export * from './facetFilters'; +export * from './facetHits'; +export * from './facetOrdering'; +export * from './facets'; +export * from './facetStats'; +export * from './highlightResult'; +export * from './highlightResultOption'; +export * from './hit'; +export * from './hitRankingInfo'; +export * from './insideBoundingBox'; +export * from './matchedGeoLocation'; +export * from './matchLevel'; +export * from './numericFilters'; +export * from './optionalFilters'; +export * from './params'; +export * from './personalization'; +export * from './range'; +export * from './rankingInfo'; +export * from './redirect'; +export * from './redirectRuleIndexData'; +export * from './redirectRuleIndexMetadata'; +export * from './redirectURL'; +export * from './renderingContent'; +export * from './requestBody'; +export * from './resultsCompositionInfoResponse'; +export * from './resultsCompositionsResponse'; +export * from './resultsInjectedItemAppliedRulesInfoResponse'; +export * from './resultsInjectedItemInfoResponse'; +export * from './searchForFacetValuesParams'; +export * from './searchForFacetValuesRequest'; +export * from './searchForFacetValuesResponse'; +export * from './searchForFacetValuesResults'; +export * from './searchHits'; +export * from './searchPagination'; +export * from './searchResponse'; +export * from './searchResults'; +export * from './searchResultsItem'; +export * from './snippetResult'; +export * from './snippetResultOption'; +export * from './sortRemainingBy'; +export * from './supportedLanguage'; +export * from './value'; +export * from './widgets'; diff --git a/packages/composition/model/insideBoundingBox.ts b/packages/composition/model/insideBoundingBox.ts new file mode 100644 index 000000000..8a498532f --- /dev/null +++ b/packages/composition/model/insideBoundingBox.ts @@ -0,0 +1,3 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +export type InsideBoundingBox = string | Array>; diff --git a/packages/composition/model/matchLevel.ts b/packages/composition/model/matchLevel.ts new file mode 100644 index 000000000..2cb9f4d21 --- /dev/null +++ b/packages/composition/model/matchLevel.ts @@ -0,0 +1,6 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +/** + * Whether the whole query string matches or only a part. + */ +export type MatchLevel = 'none' | 'partial' | 'full'; diff --git a/packages/composition/model/matchedGeoLocation.ts b/packages/composition/model/matchedGeoLocation.ts new file mode 100644 index 000000000..018634191 --- /dev/null +++ b/packages/composition/model/matchedGeoLocation.ts @@ -0,0 +1,18 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +export type MatchedGeoLocation = { + /** + * Latitude of the matched location. + */ + lat?: number; + + /** + * Longitude of the matched location. + */ + lng?: number; + + /** + * Distance between the matched location and the search location (in meters). + */ + distance?: number; +}; diff --git a/packages/composition/model/numericFilters.ts b/packages/composition/model/numericFilters.ts new file mode 100644 index 000000000..6129dc5d3 --- /dev/null +++ b/packages/composition/model/numericFilters.ts @@ -0,0 +1,6 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +/** + * Filter by numeric facets. **Prefer using the `filters` parameter, which supports all filter types and combinations with boolean operators.** You can use numeric comparison operators: `<`, `<=`, `=`, `!=`, `>`, `>=`. Comparisons are precise up to 3 decimals. You can also provide ranges: `facet: TO `. The range includes the lower and upper boundaries. The same combination rules apply as for `facetFilters`. + */ +export type NumericFilters = Array | string; diff --git a/packages/composition/model/optionalFilters.ts b/packages/composition/model/optionalFilters.ts new file mode 100644 index 000000000..677b9239c --- /dev/null +++ b/packages/composition/model/optionalFilters.ts @@ -0,0 +1,6 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +/** + * Filters to promote or demote records in the search results. Optional filters work like facet filters, but they don\'t exclude records from the search results. Records that match the optional filter rank before records that don\'t match. If you\'re using a negative filter `facet:-value`, matching records rank after records that don\'t match. - Optional filters don\'t work on virtual replicas. - Optional filters are applied _after_ sort-by attributes. - Optional filters are applied _before_ custom ranking attributes (in the default [ranking](https://www.algolia.com/doc/guides/managing-results/relevance-overview/in-depth/ranking-criteria/)). - Optional filters don\'t work with numeric attributes. + */ +export type OptionalFilters = Array | string; diff --git a/packages/composition/model/params.ts b/packages/composition/model/params.ts new file mode 100644 index 000000000..013907f5c --- /dev/null +++ b/packages/composition/model/params.ts @@ -0,0 +1,120 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { AroundPrecision } from './aroundPrecision'; +import type { AroundRadius } from './aroundRadius'; +import type { FacetFilters } from './facetFilters'; +import type { InsideBoundingBox } from './insideBoundingBox'; +import type { NumericFilters } from './numericFilters'; +import type { OptionalFilters } from './optionalFilters'; +import type { SupportedLanguage } from './supportedLanguage'; + +export type Params = { + /** + * Search query. + */ + query?: string; + + /** + * Filter expression to only include items that match the filter criteria in the response. You can use these filter expressions: - **Numeric filters.** ` `, where `` is one of `<`, `<=`, `=`, `!=`, `>`, `>=`. - **Ranges.** `: TO ` where `` and `` are the lower and upper limits of the range (inclusive). - **Facet filters.** `:` where `` is a facet attribute (case-sensitive) and `` a facet value. - **Tag filters.** `_tags:` or just `` (case-sensitive). - **Boolean filters.** `: true | false`. You can combine filters with `AND`, `OR`, and `NOT` operators with the following restrictions: - You can only combine filters of the same type with `OR`. **Not supported:** `facet:value OR num > 3`. - You can\'t use `NOT` with combinations of filters. **Not supported:** `NOT(facet:value OR facet:value)` - You can\'t combine conjunctions (`AND`) with `OR`. **Not supported:** `facet:value OR (facet:value AND facet:value)` Use quotes around your filters, if the facet attribute name or facet value has spaces, keywords (`OR`, `AND`, `NOT`), or quotes. If a facet attribute is an array, the filter matches if it matches at least one element of the array. For more information, see [Filters](https://www.algolia.com/doc/guides/managing-results/refine-results/filtering/). + */ + filters?: string; + + /** + * Page of search results to retrieve. + */ + page?: number; + + /** + * Whether the search response should include detailed ranking information. + */ + getRankingInfo?: boolean; + + relevancyStrictness?: number; + + facetFilters?: FacetFilters; + + optionalFilters?: OptionalFilters; + + numericFilters?: NumericFilters; + + /** + * Number of hits per page. + */ + hitsPerPage?: number; + + /** + * Coordinates for the center of a circle, expressed as a comma-separated string of latitude and longitude. Only records included within a circle around this central location are included in the results. The radius of the circle is determined by the `aroundRadius` and `minimumAroundRadius` settings. This parameter is ignored if you also specify `insidePolygon` or `insideBoundingBox`. + */ + aroundLatLng?: string; + + /** + * Whether to obtain the coordinates from the request\'s IP address. + */ + aroundLatLngViaIP?: boolean; + + aroundRadius?: AroundRadius; + + aroundPrecision?: AroundPrecision; + + /** + * Minimum radius (in meters) for a search around a location when `aroundRadius` isn\'t set. + */ + minimumAroundRadius?: number; + + insideBoundingBox?: InsideBoundingBox | null; + + /** + * Coordinates of a polygon in which to search. Polygons are defined by 3 to 10,000 points. Each point is represented by its latitude and longitude. Provide multiple polygons as nested arrays. For more information, see [filtering inside polygons](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas). This parameter is ignored if you also specify `insideBoundingBox`. + */ + insidePolygon?: Array>; + + /** + * Languages for language-specific query processing steps such as plurals, stop-word removal, and word-detection dictionaries. This setting sets a default list of languages used by the `removeStopWords` and `ignorePlurals` settings. This setting also sets a dictionary for word detection in the logogram-based [CJK](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/normalization/#normalization-for-logogram-based-languages-cjk) languages. To support this, you must place the CJK language **first**. **You should always specify a query language.** If you don\'t specify an indexing language, the search engine uses all [supported languages](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/supported-languages/), or the languages you specified with the `ignorePlurals` or `removeStopWords` parameters. This can lead to unexpected search results. For more information, see [Language-specific configuration](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/language-specific-configurations/). + */ + queryLanguages?: Array; + + /** + * ISO language codes that adjust settings that are useful for processing natural language queries (as opposed to keyword searches): - Sets `removeStopWords` and `ignorePlurals` to the list of provided languages. - Sets `removeWordsIfNoResults` to `allOptional`. - Adds a `natural_language` attribute to `ruleContexts` and `analyticsTags`. + */ + naturalLanguages?: Array; + + /** + * Whether to enable rules. + */ + enableRules?: boolean; + + /** + * Assigns a rule context to the search query. [Rule contexts](https://www.algolia.com/doc/guides/managing-results/rules/rules-overview/how-to/customize-search-results-by-platform/#whats-a-context) are strings that you can use to trigger matching rules. + */ + ruleContexts?: Array; + + /** + * Unique pseudonymous or anonymous user identifier. This helps with analytics and click and conversion events. For more information, see [user token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/). + */ + userToken?: string; + + /** + * Whether to include a `queryID` attribute in the response. The query ID is a unique identifier for a search query and is required for tracking [click and conversion events](https://www.algolia.com/guides/sending-events/getting-started/). + */ + clickAnalytics?: boolean; + + /** + * Whether this search will be included in Analytics. + */ + analytics?: boolean; + + /** + * Tags to apply to the query for [segmenting analytics data](https://www.algolia.com/doc/guides/search-analytics/guides/segments/). + */ + analyticsTags?: Array; + + /** + * Whether to enable A/B testing for this search. + */ + enableABTest?: boolean; + + /** + * Whether this search will use [Dynamic Re-Ranking](https://www.algolia.com/doc/guides/algolia-ai/re-ranking/). This setting only has an effect if you activated Dynamic Re-Ranking for this index in the Algolia dashboard. + */ + enableReRanking?: boolean; +}; diff --git a/packages/composition/model/personalization.ts b/packages/composition/model/personalization.ts new file mode 100644 index 000000000..c8efd58b1 --- /dev/null +++ b/packages/composition/model/personalization.ts @@ -0,0 +1,18 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +export type Personalization = { + /** + * The score of the filters. + */ + filtersScore?: number; + + /** + * The score of the ranking. + */ + rankingScore?: number; + + /** + * The score of the event. + */ + score?: number; +}; diff --git a/packages/composition/model/range.ts b/packages/composition/model/range.ts new file mode 100644 index 000000000..780b75be7 --- /dev/null +++ b/packages/composition/model/range.ts @@ -0,0 +1,16 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +/** + * Range object with lower and upper values in meters to define custom ranges. + */ +export type Range = { + /** + * Lower boundary of a range in meters. The Geo ranking criterion considers all records within the range to be equal. + */ + from?: number; + + /** + * Upper boundary of a range in meters. The Geo ranking criterion considers all records within the range to be equal. + */ + value?: number; +}; diff --git a/packages/composition/model/rankingInfo.ts b/packages/composition/model/rankingInfo.ts new file mode 100644 index 000000000..50c5a3058 --- /dev/null +++ b/packages/composition/model/rankingInfo.ts @@ -0,0 +1,68 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { MatchedGeoLocation } from './matchedGeoLocation'; +import type { Personalization } from './personalization'; + +/** + * Object with detailed information about the record\'s ranking. + */ +export type RankingInfo = { + /** + * Whether a filter matched the query. + */ + filters?: number; + + /** + * Position of the first matched word in the best matching attribute of the record. + */ + firstMatchedWord: number; + + /** + * Distance between the geo location in the search query and the best matching geo location in the record, divided by the geo precision (in meters). + */ + geoDistance: number; + + /** + * Precision used when computing the geo distance, in meters. + */ + geoPrecision?: number; + + matchedGeoLocation?: MatchedGeoLocation; + + personalization?: Personalization; + + /** + * Number of exactly matched words. + */ + nbExactWords: number; + + /** + * Number of typos encountered when matching the record. + */ + nbTypos: number; + + /** + * Whether the record was promoted by a rule. + */ + promoted?: boolean; + + /** + * Number of words between multiple matches in the query plus 1. For single word queries, `proximityDistance` is 0. + */ + proximityDistance?: number; + + /** + * Overall ranking of the record, expressed as a single integer. This attribute is internal. + */ + userScore: number; + + /** + * Number of matched words. + */ + words?: number; + + /** + * Whether the record is re-ranked. + */ + promotedByReRanking?: boolean; +}; diff --git a/packages/composition/model/redirect.ts b/packages/composition/model/redirect.ts new file mode 100644 index 000000000..fa3ea30ff --- /dev/null +++ b/packages/composition/model/redirect.ts @@ -0,0 +1,10 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { RedirectRuleIndexMetadata } from './redirectRuleIndexMetadata'; + +/** + * [Redirect results to a URL](https://www.algolia.com/doc/guides/managing-results/rules/merchandising-and-promoting/how-to/redirects/), this this parameter is for internal use only. + */ +export type Redirect = { + index?: Array; +}; diff --git a/packages/composition/model/redirectRuleIndexData.ts b/packages/composition/model/redirectRuleIndexData.ts new file mode 100644 index 000000000..fbb7ea140 --- /dev/null +++ b/packages/composition/model/redirectRuleIndexData.ts @@ -0,0 +1,8 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +/** + * Redirect rule data. + */ +export type RedirectRuleIndexData = { + ruleObjectID: string; +}; diff --git a/packages/composition/model/redirectRuleIndexMetadata.ts b/packages/composition/model/redirectRuleIndexMetadata.ts new file mode 100644 index 000000000..33802fc69 --- /dev/null +++ b/packages/composition/model/redirectRuleIndexMetadata.ts @@ -0,0 +1,27 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { RedirectRuleIndexData } from './redirectRuleIndexData'; + +export type RedirectRuleIndexMetadata = { + /** + * Source index for the redirect rule. + */ + source: string; + + /** + * Destination index for the redirect rule. + */ + dest: string; + + /** + * Reason for the redirect rule. + */ + reason: string; + + /** + * Redirect rule status. + */ + succeed: boolean; + + data: RedirectRuleIndexData; +}; diff --git a/packages/composition/model/redirectURL.ts b/packages/composition/model/redirectURL.ts new file mode 100644 index 000000000..8f66f7ee2 --- /dev/null +++ b/packages/composition/model/redirectURL.ts @@ -0,0 +1,8 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +/** + * The redirect rule container. + */ +export type RedirectURL = { + url?: string; +}; diff --git a/packages/composition/model/renderingContent.ts b/packages/composition/model/renderingContent.ts new file mode 100644 index 000000000..ddb01bde8 --- /dev/null +++ b/packages/composition/model/renderingContent.ts @@ -0,0 +1,16 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { FacetOrdering } from './facetOrdering'; +import type { RedirectURL } from './redirectURL'; +import type { Widgets } from './widgets'; + +/** + * Extra data that can be used in the search UI. You can use this to control aspects of your search UI, such as the order of facet names and values without changing your frontend code. + */ +export type RenderingContent = { + facetOrdering?: FacetOrdering; + + redirect?: RedirectURL; + + widgets?: Widgets; +}; diff --git a/packages/composition/model/requestBody.ts b/packages/composition/model/requestBody.ts new file mode 100644 index 000000000..3e936f9eb --- /dev/null +++ b/packages/composition/model/requestBody.ts @@ -0,0 +1,7 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { Params } from './params'; + +export type RequestBody = { + params?: Params; +}; diff --git a/packages/composition/model/resultsCompositionInfoResponse.ts b/packages/composition/model/resultsCompositionInfoResponse.ts new file mode 100644 index 000000000..2aa12f6ef --- /dev/null +++ b/packages/composition/model/resultsCompositionInfoResponse.ts @@ -0,0 +1,7 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { ResultsInjectedItemInfoResponse } from './resultsInjectedItemInfoResponse'; + +export type ResultsCompositionInfoResponse = { + injectedItems: Array; +}; diff --git a/packages/composition/model/resultsCompositionsResponse.ts b/packages/composition/model/resultsCompositionsResponse.ts new file mode 100644 index 000000000..763a799e2 --- /dev/null +++ b/packages/composition/model/resultsCompositionsResponse.ts @@ -0,0 +1,7 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { ResultsCompositionInfoResponse } from './resultsCompositionInfoResponse'; + +export type ResultsCompositionsResponse = Record & { + compositions: { [key: string]: ResultsCompositionInfoResponse }; +}; diff --git a/packages/composition/model/resultsInjectedItemAppliedRulesInfoResponse.ts b/packages/composition/model/resultsInjectedItemAppliedRulesInfoResponse.ts new file mode 100644 index 000000000..b70808f3d --- /dev/null +++ b/packages/composition/model/resultsInjectedItemAppliedRulesInfoResponse.ts @@ -0,0 +1,8 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +export type ResultsInjectedItemAppliedRulesInfoResponse = { + /** + * Unique record identifier. + */ + objectID: string; +}; diff --git a/packages/composition/model/resultsInjectedItemInfoResponse.ts b/packages/composition/model/resultsInjectedItemInfoResponse.ts new file mode 100644 index 000000000..35a86a467 --- /dev/null +++ b/packages/composition/model/resultsInjectedItemInfoResponse.ts @@ -0,0 +1,9 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { ResultsInjectedItemAppliedRulesInfoResponse } from './resultsInjectedItemAppliedRulesInfoResponse'; + +export type ResultsInjectedItemInfoResponse = Record & { + key: string; + + appliedRules?: Array; +}; diff --git a/packages/composition/model/searchForFacetValuesParams.ts b/packages/composition/model/searchForFacetValuesParams.ts new file mode 100644 index 000000000..8b57a2e7e --- /dev/null +++ b/packages/composition/model/searchForFacetValuesParams.ts @@ -0,0 +1,17 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { Params } from './params'; + +export type SearchForFacetValuesParams = { + /** + * Search query. + */ + query?: string; + + /** + * Maximum number of facet values to return when [searching for facet values](https://www.algolia.com/doc/guides/managing-results/refine-results/faceting/#search-for-facet-values). + */ + maxFacetHits?: number; + + searchQuery?: Params; +}; diff --git a/packages/composition/model/searchForFacetValuesRequest.ts b/packages/composition/model/searchForFacetValuesRequest.ts new file mode 100644 index 000000000..62ac3a2dd --- /dev/null +++ b/packages/composition/model/searchForFacetValuesRequest.ts @@ -0,0 +1,7 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { SearchForFacetValuesParams } from './searchForFacetValuesParams'; + +export type SearchForFacetValuesRequest = { + params?: SearchForFacetValuesParams; +}; diff --git a/packages/composition/model/searchForFacetValuesResponse.ts b/packages/composition/model/searchForFacetValuesResponse.ts new file mode 100644 index 000000000..cbe8e92f7 --- /dev/null +++ b/packages/composition/model/searchForFacetValuesResponse.ts @@ -0,0 +1,10 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { SearchForFacetValuesResults } from './searchForFacetValuesResults'; + +export type SearchForFacetValuesResponse = { + /** + * Search for facet values results. + */ + results?: Array; +}; diff --git a/packages/composition/model/searchForFacetValuesResults.ts b/packages/composition/model/searchForFacetValuesResults.ts new file mode 100644 index 000000000..94960fdee --- /dev/null +++ b/packages/composition/model/searchForFacetValuesResults.ts @@ -0,0 +1,22 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { FacetHits } from './facetHits'; + +export type SearchForFacetValuesResults = { + indexName: string; + + /** + * Matching facet values. + */ + facetHits: Array; + + /** + * Whether the facet count is exhaustive (true) or approximate (false). For more information, see [Why are my facet and hit counts not accurate](https://support.algolia.com/hc/en-us/articles/4406975248145-Why-are-my-facet-and-hit-counts-not-accurate-). + */ + exhaustiveFacetsCount: boolean; + + /** + * Time the server took to process the request, in milliseconds. + */ + processingTimeMS?: number; +}; diff --git a/packages/composition/model/searchHits.ts b/packages/composition/model/searchHits.ts new file mode 100644 index 000000000..3e410b8a0 --- /dev/null +++ b/packages/composition/model/searchHits.ts @@ -0,0 +1,20 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { Hit } from './hit'; + +export type SearchHits> = Record & { + /** + * Search results (hits). Hits are records from your index that match the search criteria, augmented with additional attributes, such as, for highlighting. + */ + hits: Hit[]; + + /** + * Search query. + */ + query: string; + + /** + * URL-encoded string of all search parameters. + */ + params: string; +}; diff --git a/packages/composition/model/searchPagination.ts b/packages/composition/model/searchPagination.ts new file mode 100644 index 000000000..d5420c628 --- /dev/null +++ b/packages/composition/model/searchPagination.ts @@ -0,0 +1,23 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +export type SearchPagination = { + /** + * Page of search results to retrieve. + */ + page: number; + + /** + * Number of results (hits). + */ + nbHits: number; + + /** + * Number of pages of results. + */ + nbPages: number; + + /** + * Number of hits per page. + */ + hitsPerPage: number; +}; diff --git a/packages/composition/model/searchResponse.ts b/packages/composition/model/searchResponse.ts new file mode 100644 index 000000000..61fd97428 --- /dev/null +++ b/packages/composition/model/searchResponse.ts @@ -0,0 +1,6 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { CompositionBaseSearchResponse } from './compositionBaseSearchResponse'; +import type { SearchResults } from './searchResults'; + +export type SearchResponse> = CompositionBaseSearchResponse & SearchResults; diff --git a/packages/composition/model/searchResults.ts b/packages/composition/model/searchResults.ts new file mode 100644 index 000000000..34e9a400a --- /dev/null +++ b/packages/composition/model/searchResults.ts @@ -0,0 +1,10 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { SearchResultsItem } from './searchResultsItem'; + +export type SearchResults> = { + /** + * Search results. + */ + results: SearchResultsItem[]; +}; diff --git a/packages/composition/model/searchResultsItem.ts b/packages/composition/model/searchResultsItem.ts new file mode 100644 index 000000000..7ada04731 --- /dev/null +++ b/packages/composition/model/searchResultsItem.ts @@ -0,0 +1,11 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { BaseSearchResponse } from './baseSearchResponse'; +import type { ResultsCompositionsResponse } from './resultsCompositionsResponse'; +import type { SearchHits } from './searchHits'; +import type { SearchPagination } from './searchPagination'; + +export type SearchResultsItem> = BaseSearchResponse & + SearchPagination & + SearchHits & + ResultsCompositionsResponse; diff --git a/packages/composition/model/snippetResult.ts b/packages/composition/model/snippetResult.ts new file mode 100644 index 000000000..0d9abff48 --- /dev/null +++ b/packages/composition/model/snippetResult.ts @@ -0,0 +1,5 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { SnippetResultOption } from './snippetResultOption'; + +export type SnippetResult = SnippetResultOption | { [key: string]: SnippetResult } | Array; diff --git a/packages/composition/model/snippetResultOption.ts b/packages/composition/model/snippetResultOption.ts new file mode 100644 index 000000000..daab65f2d --- /dev/null +++ b/packages/composition/model/snippetResultOption.ts @@ -0,0 +1,15 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { MatchLevel } from './matchLevel'; + +/** + * Snippets that show the context around a matching search query. + */ +export type SnippetResultOption = { + /** + * Highlighted attribute value, including HTML tags. + */ + value: string; + + matchLevel: MatchLevel; +}; diff --git a/packages/composition/model/sortRemainingBy.ts b/packages/composition/model/sortRemainingBy.ts new file mode 100644 index 000000000..85fc5bd88 --- /dev/null +++ b/packages/composition/model/sortRemainingBy.ts @@ -0,0 +1,6 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +/** + * Order of facet values that aren\'t explicitly positioned with the `order` setting. - `count`. Order remaining facet values by decreasing count. The count is the number of matching records containing this facet value. - `alpha`. Sort facet values alphabetically. - `hidden`. Don\'t show facet values that aren\'t explicitly positioned. + */ +export type SortRemainingBy = 'count' | 'alpha' | 'hidden'; diff --git a/packages/composition/model/supportedLanguage.ts b/packages/composition/model/supportedLanguage.ts new file mode 100644 index 000000000..85f2111cc --- /dev/null +++ b/packages/composition/model/supportedLanguage.ts @@ -0,0 +1,74 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +/** + * ISO code for a supported language. + */ +export type SupportedLanguage = + | 'af' + | 'ar' + | 'az' + | 'bg' + | 'bn' + | 'ca' + | 'cs' + | 'cy' + | 'da' + | 'de' + | 'el' + | 'en' + | 'eo' + | 'es' + | 'et' + | 'eu' + | 'fa' + | 'fi' + | 'fo' + | 'fr' + | 'ga' + | 'gl' + | 'he' + | 'hi' + | 'hu' + | 'hy' + | 'id' + | 'is' + | 'it' + | 'ja' + | 'ka' + | 'kk' + | 'ko' + | 'ku' + | 'ky' + | 'lt' + | 'lv' + | 'mi' + | 'mn' + | 'mr' + | 'ms' + | 'mt' + | 'nb' + | 'nl' + | 'no' + | 'ns' + | 'pl' + | 'ps' + | 'pt' + | 'pt-br' + | 'qu' + | 'ro' + | 'ru' + | 'sk' + | 'sq' + | 'sv' + | 'sw' + | 'ta' + | 'te' + | 'th' + | 'tl' + | 'tn' + | 'tr' + | 'tt' + | 'uk' + | 'ur' + | 'uz' + | 'zh'; diff --git a/packages/composition/model/value.ts b/packages/composition/model/value.ts new file mode 100644 index 000000000..72cd05add --- /dev/null +++ b/packages/composition/model/value.ts @@ -0,0 +1,17 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { SortRemainingBy } from './sortRemainingBy'; + +export type Value = { + /** + * Explicit order of facets or facet values. This setting lets you always show specific facets or facet values at the top of the list. + */ + order?: Array; + + sortRemainingBy?: SortRemainingBy; + + /** + * Hide facet values. + */ + hide?: Array; +}; diff --git a/packages/composition/model/widgets.ts b/packages/composition/model/widgets.ts new file mode 100644 index 000000000..ee0f95779 --- /dev/null +++ b/packages/composition/model/widgets.ts @@ -0,0 +1,13 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { Banner } from './banner'; + +/** + * Widgets returned from any rules that are applied to the current search. + */ +export type Widgets = { + /** + * Banners defined in the Merchandising Studio for a given search. + */ + banners?: Array; +}; diff --git a/packages/composition/package.json b/packages/composition/package.json new file mode 100644 index 000000000..d219bb59b --- /dev/null +++ b/packages/composition/package.json @@ -0,0 +1,68 @@ +{ + "version": "0.0.1", + "repository": { + "type": "git", + "url": "git+https://github.com/algolia/algoliasearch-client-javascript.git" + }, + "homepage": "https://github.com/algolia/algoliasearch-client-javascript/packages/composition#readme", + "type": "module", + "license": "MIT", + "author": "Algolia", + "scripts": { + "build": "yarn clean && yarn tsup && yarn rollup -c rollup.config.js", + "clean": "rm -rf ./dist || true", + "test:bundle": "publint . && attw --pack ." + }, + "name": "@algolia/composition", + "description": "JavaScript client for composition", + "exports": { + ".": { + "node": { + "types": { + "import": "./dist/node.d.ts", + "module": "./dist/node.d.ts", + "require": "./dist/node.d.cts" + }, + "import": "./dist/builds/node.js", + "module": "./dist/builds/node.js", + "require": "./dist/builds/node.cjs" + }, + "worker": { + "types": "./dist/worker.d.ts", + "default": "./dist/builds/worker.js" + }, + "default": { + "types": "./dist/browser.d.ts", + "module": "./dist/builds/browser.js", + "import": "./dist/builds/browser.js", + "default": "./dist/builds/browser.umd.js" + } + }, + "./dist/builds/*": "./dist/builds/*.js" + }, + "jsdelivr": "./dist/builds/browser.umd.js", + "unpkg": "./dist/builds/browser.umd.js", + "react-native": "./dist/builds/browser.js", + "files": [ + "dist", + "index.js", + "index.d.ts" + ], + "dependencies": { + "@algolia/client-common": "5.19.0", + "@algolia/requester-browser-xhr": "5.19.0", + "@algolia/requester-fetch": "5.19.0", + "@algolia/requester-node-http": "5.19.0" + }, + "devDependencies": { + "@arethetypeswrong/cli": "0.17.3", + "@types/node": "22.10.7", + "publint": "0.3.2", + "rollup": "4.30.1", + "tsup": "8.3.5", + "typescript": "5.7.3" + }, + "engines": { + "node": ">= 14.0.0" + } +} diff --git a/packages/composition/rollup.config.js b/packages/composition/rollup.config.js new file mode 100644 index 000000000..1746eabe0 --- /dev/null +++ b/packages/composition/rollup.config.js @@ -0,0 +1,17 @@ +export default [ + { + input: 'dist/builds/browser.min.js', + external: ['dom'], + cache: false, + output: { + esModule: false, + file: 'dist/builds/browser.umd.js', + name: '@algolia/composition', + format: 'umd', + sourcemap: false, + globals: { + ['compositionClient']: 'compositionClient', + }, + }, + }, +]; diff --git a/packages/composition/src/compositionClient.ts b/packages/composition/src/compositionClient.ts new file mode 100644 index 000000000..368925746 --- /dev/null +++ b/packages/composition/src/compositionClient.ts @@ -0,0 +1,217 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { + CreateClientOptions, + Headers, + Host, + QueryParameters, + Request, + RequestOptions, +} from '@algolia/client-common'; +import { createAuth, createTransporter, getAlgoliaAgent, shuffle } from '@algolia/client-common'; + +import type { SearchForFacetValuesResponse } from '../model/searchForFacetValuesResponse'; +import type { SearchResponse } from '../model/searchResponse'; + +import type { SearchForFacetValuesProps, SearchProps } from '../model/clientMethodProps'; + +export const apiClientVersion = '0.0.1'; + +function getDefaultHosts(appId: string): Host[] { + return ( + [ + { + url: `${appId}-dsn.algolia.net`, + accept: 'read', + protocol: 'https', + }, + { + url: `${appId}.algolia.net`, + accept: 'write', + protocol: 'https', + }, + ] as Host[] + ).concat( + shuffle([ + { + url: `${appId}-1.algolianet.com`, + accept: 'readWrite', + protocol: 'https', + }, + { + url: `${appId}-2.algolianet.com`, + accept: 'readWrite', + protocol: 'https', + }, + { + url: `${appId}-3.algolianet.com`, + accept: 'readWrite', + protocol: 'https', + }, + ]), + ); +} + +export function createCompositionClient({ + appId: appIdOption, + apiKey: apiKeyOption, + authMode, + algoliaAgents, + ...options +}: CreateClientOptions) { + const auth = createAuth(appIdOption, apiKeyOption, authMode); + const transporter = createTransporter({ + hosts: getDefaultHosts(appIdOption), + ...options, + algoliaAgent: getAlgoliaAgent({ + algoliaAgents, + client: 'Composition', + version: apiClientVersion, + }), + baseHeaders: { + 'content-type': 'text/plain', + ...auth.headers(), + ...options.baseHeaders, + }, + baseQueryParameters: { + ...auth.queryParameters(), + ...options.baseQueryParameters, + }, + }); + + return { + transporter, + + /** + * The `appId` currently in use. + */ + appId: appIdOption, + + /** + * The `apiKey` currently in use. + */ + apiKey: apiKeyOption, + + /** + * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties. + */ + clearCache(): Promise { + return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => undefined); + }, + + /** + * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system. + */ + get _ua(): string { + return transporter.algoliaAgent.value; + }, + + /** + * Adds a `segment` to the `x-algolia-agent` sent with every requests. + * + * @param segment - The algolia agent (user-agent) segment to add. + * @param version - The version of the agent. + */ + addAlgoliaAgent(segment: string, version?: string): void { + transporter.algoliaAgent.add({ segment, version }); + }, + + /** + * Helper method to switch the API key used to authenticate the requests. + * + * @param params - Method params. + * @param params.apiKey - The new API Key to use. + */ + setClientApiKey({ apiKey }: { apiKey: string }): void { + if (!authMode || authMode === 'WithinHeaders') { + transporter.baseHeaders['x-algolia-api-key'] = apiKey; + } else { + transporter.baseQueryParameters['x-algolia-api-key'] = apiKey; + } + }, + + /** + * Runs a query on a single composition and returns matching results. + * + * Required API Key ACLs: + * - search + * @param search - The search object. + * @param search.compositionID - Unique Composition ObjectID. + * @param search.requestBody - The requestBody object. + * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. + */ + search( + { compositionID, requestBody }: SearchProps, + requestOptions?: RequestOptions, + ): Promise> { + if (!compositionID) { + throw new Error('Parameter `compositionID` is required when calling `search`.'); + } + + if (!requestBody) { + throw new Error('Parameter `requestBody` is required when calling `search`.'); + } + + const requestPath = '/1/compositions/{compositionID}/run'.replace( + '{compositionID}', + encodeURIComponent(compositionID), + ); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + + const request: Request = { + method: 'POST', + path: requestPath, + queryParameters, + headers, + data: requestBody, + useReadTransporter: true, + cacheable: true, + }; + + return transporter.request(request, requestOptions); + }, + + /** + * Searches for values of a specified facet attribute on the composition\'s main source\'s index. - By default, facet values are sorted by decreasing count. You can adjust this with the `sortFacetValueBy` parameter. - Searching for facet values doesn\'t work if you have **more than 65 searchable facets and searchable attributes combined**. + * + * Required API Key ACLs: + * - search + * @param searchForFacetValues - The searchForFacetValues object. + * @param searchForFacetValues.compositionID - Unique Composition ObjectID. + * @param searchForFacetValues.facetName - Facet attribute in which to search for values. This attribute must be included in the `attributesForFaceting` index setting with the `searchable()` modifier. + * @param searchForFacetValues.searchForFacetValuesRequest - The searchForFacetValuesRequest object. + * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. + */ + searchForFacetValues( + { compositionID, facetName, searchForFacetValuesRequest }: SearchForFacetValuesProps, + requestOptions?: RequestOptions, + ): Promise { + if (!compositionID) { + throw new Error('Parameter `compositionID` is required when calling `searchForFacetValues`.'); + } + + if (!facetName) { + throw new Error('Parameter `facetName` is required when calling `searchForFacetValues`.'); + } + + const requestPath = '/1/compositions/{compositionID}/facets/{facetName}/query' + .replace('{compositionID}', encodeURIComponent(compositionID)) + .replace('{facetName}', encodeURIComponent(facetName)); + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + + const request: Request = { + method: 'POST', + path: requestPath, + queryParameters, + headers, + data: searchForFacetValuesRequest ? searchForFacetValuesRequest : {}, + useReadTransporter: true, + cacheable: true, + }; + + return transporter.request(request, requestOptions); + }, + }; +} diff --git a/packages/composition/tsconfig.json b/packages/composition/tsconfig.json new file mode 100644 index 000000000..444e8bb64 --- /dev/null +++ b/packages/composition/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "outDir": "dist" + }, + "include": ["src", "model", "builds"], + "exclude": ["dist", "node_modules"] +} diff --git a/packages/composition/tsup.config.ts b/packages/composition/tsup.config.ts new file mode 100644 index 000000000..8c60a6c07 --- /dev/null +++ b/packages/composition/tsup.config.ts @@ -0,0 +1,67 @@ +import type { Options } from 'tsup'; +import { defineConfig } from 'tsup'; + +import { getBaseBrowserOptions, getBaseNodeOptions, getDependencies } from '../../base.tsup.config'; + +import pkg from './package.json' with { type: 'json' }; + +const nodeOptions: Options = { + ...getBaseNodeOptions(pkg, __dirname), + dts: { entry: { node: 'builds/node.ts' } }, + entry: ['builds/node.ts', 'src/*.ts'], +}; + +const nodeConfigs: Options[] = [ + { + ...nodeOptions, + format: 'cjs', + name: `node ${pkg.name} cjs`, + }, + { + ...nodeOptions, + format: 'esm', + name: `node ${pkg.name} esm`, + }, + { + ...nodeOptions, + format: 'esm', + name: `fetch ${pkg.name} esm`, + dts: { entry: { fetch: 'builds/fetch.ts' } }, + external: getDependencies(pkg, 'fetch'), + entry: ['builds/fetch.ts', 'src/*.ts'], + }, + { + ...nodeOptions, + format: 'esm', + name: `worker ${pkg.name} esm`, + dts: { entry: { worker: 'builds/worker.ts' } }, + external: getDependencies(pkg, 'worker'), + entry: ['builds/worker.ts', 'src/*.ts'], + }, +]; + +const browserOptions: Options = { + ...getBaseBrowserOptions(pkg, __dirname), + globalName: 'compositionClient', +}; + +const browserConfigs: Options[] = [ + { + ...browserOptions, + minify: false, + name: `browser ${pkg.name} esm`, + dts: { entry: { browser: 'builds/browser.ts' } }, + entry: ['builds/browser.ts', 'src/*.ts'], + }, + { + ...browserOptions, + dts: false, + minify: true, + name: `browser ${pkg.name} min esm`, + entry: { 'builds/browser.min': 'builds/browser.ts' }, + external: [], + noExternal: getDependencies(pkg, 'xhr'), + }, +]; + +export default defineConfig([...nodeConfigs, ...browserConfigs]); diff --git a/yarn.lock b/yarn.lock index 735dfd1ca..db5b547a2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -139,6 +139,23 @@ __metadata: languageName: unknown linkType: soft +"@algolia/composition@npm:0.0.1, @algolia/composition@workspace:packages/composition": + version: 0.0.0-use.local + resolution: "@algolia/composition@workspace:packages/composition" + dependencies: + "@algolia/client-common": "npm:5.19.0" + "@algolia/requester-browser-xhr": "npm:5.19.0" + "@algolia/requester-fetch": "npm:5.19.0" + "@algolia/requester-node-http": "npm:5.19.0" + "@arethetypeswrong/cli": "npm:0.17.3" + "@types/node": "npm:22.10.7" + publint: "npm:0.3.2" + rollup: "npm:4.30.1" + tsup: "npm:8.3.5" + typescript: "npm:5.7.3" + languageName: unknown + linkType: soft + "@algolia/ingestion@npm:1.19.0, @algolia/ingestion@workspace:packages/ingestion": version: 0.0.0-use.local resolution: "@algolia/ingestion@workspace:packages/ingestion" @@ -2300,6 +2317,7 @@ __metadata: "@algolia/client-personalization": "npm:5.19.0" "@algolia/client-query-suggestions": "npm:5.19.0" "@algolia/client-search": "npm:5.19.0" + "@algolia/composition": "npm:0.0.1" "@algolia/ingestion": "npm:1.19.0" "@algolia/monitoring": "npm:1.19.0" "@algolia/recommend": "npm:5.19.0"