This commit is contained in:
CHEVALLIER Abel
2025-11-13 16:23:22 +01:00
parent de9c515a47
commit cb235644dc
34924 changed files with 3811102 additions and 0 deletions

21
node_modules/@algolia/client-query-suggestions/LICENSE generated vendored Normal file
View File

@@ -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.

View File

@@ -0,0 +1,77 @@
<p align="center">
<a href="https://www.algolia.com">
<img alt="Algolia for JavaScript" src="https://raw.githubusercontent.com/algolia/algoliasearch-client-common/master/banners/javascript.png" >
</a>
<h4 align="center">The perfect starting point to integrate <a href="https://algolia.com" target="_blank">Algolia</a> within your JavaScript project</h4>
<p align="center">
<a href="https://npmjs.org/package/@algolia/client-query-suggestions"><img src="https://img.shields.io/npm/v/@algolia/client-query-suggestions.svg?style=flat-square" alt="NPM version"></img></a>
<a href="http://npm-stat.com/charts.html?package=@algolia/client-query-suggestions"><img src="https://img.shields.io/npm/dm/@algolia/client-query-suggestions.svg?style=flat-square" alt="NPM downloads"></a>
<a href="https://www.jsdelivr.com/package/npm/@algolia/client-query-suggestions"><img src="https://data.jsdelivr.com/v1/package/npm/@algolia/client-query-suggestions/badge" alt="jsDelivr Downloads"></img></a>
<a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-green.svg?style=flat-square" alt="License"></a>
</p>
</p>
<p align="center">
<a href="https://www.algolia.com/doc/libraries/javascript/" target="_blank">Documentation</a>
<a href="https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/" target="_blank">InstantSearch</a>
<a href="https://discourse.algolia.com" target="_blank">Community Forum</a>
<a href="http://stackoverflow.com/questions/tagged/algolia" target="_blank">Stack Overflow</a>
<a href="https://github.com/algolia/algoliasearch-client-javascript/issues" target="_blank">Report a bug</a>
<a href="https://www.algolia.com/doc/libraries/javascript/v5/" target="_blank">FAQ</a>
<a href="https://alg.li/support" target="_blank">Support</a>
</p>
## ✨ 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/client-query-suggestions` if you already have `algoliasearch` installed.
To get started, you first need to install @algolia/client-query-suggestions (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/client-query-suggestions@5.35.0
# or
npm install @algolia/client-query-suggestions@5.35.0
# or
pnpm add @algolia/client-query-suggestions@5.35.0
```
### Without a package manager
Add the following JavaScript snippet to the <head> of your website:
```html
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-query-suggestions@5.35.0/dist/builds/browser.umd.js"></script>
```
### Usage
You can now import the Algolia API client in your project and play with it.
```js
import { querySuggestionsClient } from '@algolia/client-query-suggestions';
const client = querySuggestionsClient('YOUR_APP_ID', 'YOUR_API_KEY');
```
For full documentation, visit the **[Algolia JavaScript API Client](https://www.algolia.com/doc/libraries/javascript/v5/methods/query-suggestions/)**.
## ❓ 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).

View File

@@ -0,0 +1,410 @@
import * as _algolia_client_common from '@algolia/client-common';
import { CreateClientOptions, RequestOptions, ClientOptions } from '@algolia/client-common';
type BaseResponse = {
/**
* HTTP status code.
*/
status?: number | undefined;
/**
* Details about the response, such as error messages.
*/
message?: string | undefined;
};
type ConfigStatus = {
/**
* Name of the Query Suggestions index (case-sensitive).
*/
indexName?: string | undefined;
/**
* Whether the creation or update of the Query Suggestions index is in progress.
*/
isRunning?: boolean | undefined;
/**
* Date and time when the Query Suggestions index was last built, in RFC 3339 format.
*/
lastBuiltAt?: string | undefined;
/**
* Date and time when the Query Suggestions index was last updated successfully.
*/
lastSuccessfulBuiltAt?: string | undefined;
/**
* Duration of the last successful build in seconds.
*/
lastSuccessfulBuildDuration?: string | undefined;
};
type AppID = {
/**
* Algolia application ID to which this Query Suggestions configuration belongs.
*/
appID?: string | undefined;
};
/**
* Languages for deduplicating singular and plural suggestions. If specified, only the more popular form is included.
*/
type Languages = Array<string> | boolean;
/**
* Facet to use as category.
*/
type Facet = {
/**
* Facet name.
*/
attribute?: string | undefined;
/**
* Number of suggestions.
*/
amount?: number | undefined;
};
/**
* Configuration of an Algolia index for Query Suggestions.
*/
type SourceIndex = {
/**
* Name of the Algolia index (case-sensitive) to use as source for query suggestions.
*/
indexName: string;
/**
* If true, Query Suggestions uses all replica indices to find popular searches. If false, only the primary index is used.
*/
replicas?: boolean | undefined;
analyticsTags?: Array<string> | null | undefined;
facets?: Array<Facet> | null | undefined;
/**
* Minimum number of hits required to be included as a suggestion. A search query must at least generate `minHits` search results to be included in the Query Suggestions index.
*/
minHits?: number | undefined;
/**
* Minimum letters required to be included as a suggestion. A search query must be at least `minLetters` long to be included in the Query Suggestions index.
*/
minLetters?: number | undefined;
generate?: Array<Array<string>> | null | undefined;
external?: Array<string> | null | undefined;
};
/**
* Query Suggestions configuration.
*/
type Configuration = {
/**
* Algolia indices from which to get the popular searches for query suggestions.
*/
sourceIndices: Array<SourceIndex>;
languages?: Languages | undefined;
exclude?: Array<string> | null | undefined;
/**
* Whether to turn on personalized query suggestions.
*/
enablePersonalization?: boolean | undefined;
/**
* Whether to include suggestions with special characters.
*/
allowSpecialCharacters?: boolean | undefined;
};
/**
* Query Suggestions configuration.
*/
type ConfigurationWithIndex = Record<string, unknown> & Configuration;
/**
* API response for retrieving Query Suggestions configurations.
*/
type ConfigurationResponse = AppID & ConfigurationWithIndex;
/**
* Type of log entry. - `SKIP`. A query is skipped because it doesn\'t match the conditions for successful inclusion. For example, when a query doesn\'t generate enough search results. - `INFO`. An informative log entry. - `ERROR`. The Query Suggestions process encountered an error.
*/
type LogLevel = 'SKIP' | 'INFO' | 'ERROR';
type LogFile = {
/**
* Date and time of the log entry, in RFC 3339 format.
*/
timestamp?: string | undefined;
level?: LogLevel | undefined;
/**
* Details about this log entry.
*/
message?: string | undefined;
/**
* Level indicating the position of a suggestion in a hierarchy of records. For example, a `contextLevel` of 1 indicates that this suggestion belongs to a previous suggestion with `contextLevel` 0.
*/
contextLevel?: number | undefined;
};
/**
* Properties for the `customDelete` method.
*/
type CustomDeleteProps = {
/**
* Path of the endpoint, for example `1/newFeature`.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: {
[key: string]: any;
} | undefined;
};
/**
* Properties for the `customGet` method.
*/
type CustomGetProps = {
/**
* Path of the endpoint, for example `1/newFeature`.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: {
[key: string]: any;
} | undefined;
};
/**
* Properties for the `customPost` method.
*/
type CustomPostProps = {
/**
* Path of the endpoint, for example `1/newFeature`.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: {
[key: string]: any;
} | undefined;
/**
* Parameters to send with the custom request.
*/
body?: Record<string, unknown> | undefined;
};
/**
* Properties for the `customPut` method.
*/
type CustomPutProps = {
/**
* Path of the endpoint, for example `1/newFeature`.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: {
[key: string]: any;
} | undefined;
/**
* Parameters to send with the custom request.
*/
body?: Record<string, unknown> | undefined;
};
/**
* Properties for the `deleteConfig` method.
*/
type DeleteConfigProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
};
/**
* Properties for the `getConfig` method.
*/
type GetConfigProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
};
/**
* Properties for the `getConfigStatus` method.
*/
type GetConfigStatusProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
};
/**
* Properties for the `getLogFile` method.
*/
type GetLogFileProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
};
/**
* Properties for the `updateConfig` method.
*/
type UpdateConfigProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
configuration: Configuration;
};
declare const apiClientVersion = "5.35.0";
declare const REGIONS: readonly ["eu", "us"];
type Region = (typeof REGIONS)[number];
type RegionOptions = {
region: Region;
};
declare function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & RegionOptions): {
transporter: _algolia_client_common.Transporter;
/**
* The `appId` currently in use.
*/
appId: string;
/**
* The `apiKey` currently in use.
*/
apiKey: string;
/**
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
*/
clearCache(): Promise<void>;
/**
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
*/
readonly _ua: string;
/**
* 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 | undefined): void;
/**
* 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;
/**
* Creates a new Query Suggestions configuration. You can have up to 100 configurations per Algolia application.
*
* Required API Key ACLs:
* - editSettings
* @param configurationWithIndex - The configurationWithIndex object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
createConfig(configurationWithIndex: ConfigurationWithIndex, requestOptions?: RequestOptions): Promise<BaseResponse>;
/**
* This method lets you send requests to the Algolia REST API.
* @param customDelete - The customDelete object.
* @param customDelete.path - Path of the endpoint, for example `1/newFeature`.
* @param customDelete.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* This method lets you send requests to the Algolia REST API.
* @param customGet - The customGet object.
* @param customGet.path - Path of the endpoint, for example `1/newFeature`.
* @param customGet.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* This method lets you send requests to the Algolia REST API.
* @param customPost - The customPost object.
* @param customPost.path - Path of the endpoint, for example `1/newFeature`.
* @param customPost.parameters - Query parameters to apply to the current query.
* @param customPost.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPost({ path, parameters, body }: CustomPostProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* This method lets you send requests to the Algolia REST API.
* @param customPut - The customPut object.
* @param customPut.path - Path of the endpoint, for example `1/newFeature`.
* @param customPut.parameters - Query parameters to apply to the current query.
* @param customPut.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPut({ path, parameters, body }: CustomPutProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* Deletes a Query Suggestions configuration. Deleting only removes the configuration and stops updates to the Query Suggestions index. To delete the Query Suggestions index itself, use the Search API and the `Delete an index` operation.
*
* Required API Key ACLs:
* - editSettings
* @param deleteConfig - The deleteConfig object.
* @param deleteConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
deleteConfig({ indexName }: DeleteConfigProps, requestOptions?: RequestOptions): Promise<BaseResponse>;
/**
* Retrieves all Query Suggestions configurations of your Algolia application.
*
* Required API Key ACLs:
* - settings
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getAllConfigs(requestOptions?: RequestOptions | undefined): Promise<Array<ConfigurationResponse>>;
/**
* Retrieves a single Query Suggestions configuration by its index name.
*
* Required API Key ACLs:
* - settings
* @param getConfig - The getConfig object.
* @param getConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfig({ indexName }: GetConfigProps, requestOptions?: RequestOptions): Promise<ConfigurationResponse>;
/**
* Reports the status of a Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getConfigStatus - The getConfigStatus object.
* @param getConfigStatus.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfigStatus({ indexName }: GetConfigStatusProps, requestOptions?: RequestOptions): Promise<ConfigStatus>;
/**
* Retrieves the logs for a single Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getLogFile - The getLogFile object.
* @param getLogFile.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getLogFile({ indexName }: GetLogFileProps, requestOptions?: RequestOptions): Promise<LogFile>;
/**
* Updates a QuerySuggestions configuration.
*
* Required API Key ACLs:
* - editSettings
* @param updateConfig - The updateConfig object.
* @param updateConfig.indexName - Query Suggestions index name.
* @param updateConfig.configuration - The configuration object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
updateConfig({ indexName, configuration }: UpdateConfigProps, requestOptions?: RequestOptions): Promise<BaseResponse>;
};
/**
* Error.
*/
type ErrorBase = Record<string, any> & {
message?: string | undefined;
};
declare function querySuggestionsClient(appId: string, apiKey: string, region: Region, options?: ClientOptions | undefined): QuerySuggestionsClient;
type QuerySuggestionsClient = ReturnType<typeof createQuerySuggestionsClient>;
export { type AppID, type BaseResponse, type ConfigStatus, type Configuration, type ConfigurationResponse, type ConfigurationWithIndex, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type DeleteConfigProps, type ErrorBase, type Facet, type GetConfigProps, type GetConfigStatusProps, type GetLogFileProps, type Languages, type LogFile, type LogLevel, type QuerySuggestionsClient, type Region, type RegionOptions, type SourceIndex, type UpdateConfigProps, apiClientVersion, querySuggestionsClient };

View File

@@ -0,0 +1,391 @@
// builds/browser.ts
import { createXhrRequester } from "@algolia/requester-browser-xhr";
import {
createBrowserLocalStorageCache,
createFallbackableCache,
createMemoryCache,
createNullLogger
} from "@algolia/client-common";
// src/querySuggestionsClient.ts
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.35.0";
var REGIONS = ["eu", "us"];
function getDefaultHosts(region) {
const url = "query-suggestions.{region}.algolia.com".replace("{region}", region);
return [{ url, accept: "readWrite", protocol: "https" }];
}
function createQuerySuggestionsClient({
appId: appIdOption,
apiKey: apiKeyOption,
authMode,
algoliaAgents,
region: regionOption,
...options
}) {
const auth = createAuth(appIdOption, apiKeyOption, authMode);
const transporter = createTransporter({
hosts: getDefaultHosts(regionOption),
...options,
algoliaAgent: getAlgoliaAgent({
algoliaAgents,
client: "QuerySuggestions",
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() {
return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0);
},
/**
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
*/
get _ua() {
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, version) {
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 }) {
if (!authMode || authMode === "WithinHeaders") {
transporter.baseHeaders["x-algolia-api-key"] = apiKey;
} else {
transporter.baseQueryParameters["x-algolia-api-key"] = apiKey;
}
},
/**
* Creates a new Query Suggestions configuration. You can have up to 100 configurations per Algolia application.
*
* Required API Key ACLs:
* - editSettings
* @param configurationWithIndex - The configurationWithIndex object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
createConfig(configurationWithIndex, requestOptions) {
if (!configurationWithIndex) {
throw new Error("Parameter `configurationWithIndex` is required when calling `createConfig`.");
}
const requestPath = "/1/configs";
const headers = {};
const queryParameters = {};
const request = {
method: "POST",
path: requestPath,
queryParameters,
headers,
data: configurationWithIndex
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customDelete - The customDelete object.
* @param customDelete.path - Path of the endpoint, for example `1/newFeature`.
* @param customDelete.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customDelete({ path, parameters }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customDelete`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "DELETE",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customGet - The customGet object.
* @param customGet.path - Path of the endpoint, for example `1/newFeature`.
* @param customGet.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customGet({ path, parameters }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customGet`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customPost - The customPost object.
* @param customPost.path - Path of the endpoint, for example `1/newFeature`.
* @param customPost.parameters - Query parameters to apply to the current query.
* @param customPost.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPost({ path, parameters, body }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customPost`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "POST",
path: requestPath,
queryParameters,
headers,
data: body ? body : {}
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customPut - The customPut object.
* @param customPut.path - Path of the endpoint, for example `1/newFeature`.
* @param customPut.parameters - Query parameters to apply to the current query.
* @param customPut.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPut({ path, parameters, body }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customPut`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "PUT",
path: requestPath,
queryParameters,
headers,
data: body ? body : {}
};
return transporter.request(request, requestOptions);
},
/**
* Deletes a Query Suggestions configuration. Deleting only removes the configuration and stops updates to the Query Suggestions index. To delete the Query Suggestions index itself, use the Search API and the `Delete an index` operation.
*
* Required API Key ACLs:
* - editSettings
* @param deleteConfig - The deleteConfig object.
* @param deleteConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
deleteConfig({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `deleteConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "DELETE",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves all Query Suggestions configurations of your Algolia application.
*
* Required API Key ACLs:
* - settings
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getAllConfigs(requestOptions) {
const requestPath = "/1/configs";
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves a single Query Suggestions configuration by its index name.
*
* Required API Key ACLs:
* - settings
* @param getConfig - The getConfig object.
* @param getConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfig({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Reports the status of a Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getConfigStatus - The getConfigStatus object.
* @param getConfigStatus.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfigStatus({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getConfigStatus`.");
}
const requestPath = "/1/configs/{indexName}/status".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves the logs for a single Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getLogFile - The getLogFile object.
* @param getLogFile.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getLogFile({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getLogFile`.");
}
const requestPath = "/1/logs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Updates a QuerySuggestions configuration.
*
* Required API Key ACLs:
* - editSettings
* @param updateConfig - The updateConfig object.
* @param updateConfig.indexName - Query Suggestions index name.
* @param updateConfig.configuration - The configuration object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
updateConfig({ indexName, configuration }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `updateConfig`.");
}
if (!configuration) {
throw new Error("Parameter `configuration` is required when calling `updateConfig`.");
}
if (!configuration.sourceIndices) {
throw new Error("Parameter `configuration.sourceIndices` is required when calling `updateConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "PUT",
path: requestPath,
queryParameters,
headers,
data: configuration
};
return transporter.request(request, requestOptions);
}
};
}
// builds/browser.ts
function querySuggestionsClient(appId, apiKey, region, options) {
if (!appId || typeof appId !== "string") {
throw new Error("`appId` is missing.");
}
if (!apiKey || typeof apiKey !== "string") {
throw new Error("`apiKey` is missing.");
}
if (!region || region && (typeof region !== "string" || !REGIONS.includes(region))) {
throw new Error(`\`region\` is required and must be one of the following: ${REGIONS.join(", ")}`);
}
return createQuerySuggestionsClient({
appId,
apiKey,
region,
timeouts: {
connect: 1e3,
read: 2e3,
write: 3e4
},
logger: createNullLogger(),
requester: createXhrRequester(),
algoliaAgents: [{ segment: "Browser" }],
authMode: "WithinQueryParameters",
responsesCache: createMemoryCache(),
requestsCache: createMemoryCache({ serializable: false }),
hostsCache: createFallbackableCache({
caches: [createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }), createMemoryCache()]
}),
...options
});
}
export {
apiClientVersion,
querySuggestionsClient
};
//# sourceMappingURL=browser.js.map

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,385 @@
// builds/fetch.ts
import { createMemoryCache, createNullCache, createNullLogger } from "@algolia/client-common";
import { createFetchRequester } from "@algolia/requester-fetch";
// src/querySuggestionsClient.ts
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.35.0";
var REGIONS = ["eu", "us"];
function getDefaultHosts(region) {
const url = "query-suggestions.{region}.algolia.com".replace("{region}", region);
return [{ url, accept: "readWrite", protocol: "https" }];
}
function createQuerySuggestionsClient({
appId: appIdOption,
apiKey: apiKeyOption,
authMode,
algoliaAgents,
region: regionOption,
...options
}) {
const auth = createAuth(appIdOption, apiKeyOption, authMode);
const transporter = createTransporter({
hosts: getDefaultHosts(regionOption),
...options,
algoliaAgent: getAlgoliaAgent({
algoliaAgents,
client: "QuerySuggestions",
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() {
return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0);
},
/**
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
*/
get _ua() {
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, version) {
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 }) {
if (!authMode || authMode === "WithinHeaders") {
transporter.baseHeaders["x-algolia-api-key"] = apiKey;
} else {
transporter.baseQueryParameters["x-algolia-api-key"] = apiKey;
}
},
/**
* Creates a new Query Suggestions configuration. You can have up to 100 configurations per Algolia application.
*
* Required API Key ACLs:
* - editSettings
* @param configurationWithIndex - The configurationWithIndex object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
createConfig(configurationWithIndex, requestOptions) {
if (!configurationWithIndex) {
throw new Error("Parameter `configurationWithIndex` is required when calling `createConfig`.");
}
const requestPath = "/1/configs";
const headers = {};
const queryParameters = {};
const request = {
method: "POST",
path: requestPath,
queryParameters,
headers,
data: configurationWithIndex
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customDelete - The customDelete object.
* @param customDelete.path - Path of the endpoint, for example `1/newFeature`.
* @param customDelete.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customDelete({ path, parameters }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customDelete`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "DELETE",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customGet - The customGet object.
* @param customGet.path - Path of the endpoint, for example `1/newFeature`.
* @param customGet.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customGet({ path, parameters }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customGet`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customPost - The customPost object.
* @param customPost.path - Path of the endpoint, for example `1/newFeature`.
* @param customPost.parameters - Query parameters to apply to the current query.
* @param customPost.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPost({ path, parameters, body }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customPost`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "POST",
path: requestPath,
queryParameters,
headers,
data: body ? body : {}
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customPut - The customPut object.
* @param customPut.path - Path of the endpoint, for example `1/newFeature`.
* @param customPut.parameters - Query parameters to apply to the current query.
* @param customPut.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPut({ path, parameters, body }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customPut`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "PUT",
path: requestPath,
queryParameters,
headers,
data: body ? body : {}
};
return transporter.request(request, requestOptions);
},
/**
* Deletes a Query Suggestions configuration. Deleting only removes the configuration and stops updates to the Query Suggestions index. To delete the Query Suggestions index itself, use the Search API and the `Delete an index` operation.
*
* Required API Key ACLs:
* - editSettings
* @param deleteConfig - The deleteConfig object.
* @param deleteConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
deleteConfig({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `deleteConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "DELETE",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves all Query Suggestions configurations of your Algolia application.
*
* Required API Key ACLs:
* - settings
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getAllConfigs(requestOptions) {
const requestPath = "/1/configs";
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves a single Query Suggestions configuration by its index name.
*
* Required API Key ACLs:
* - settings
* @param getConfig - The getConfig object.
* @param getConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfig({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Reports the status of a Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getConfigStatus - The getConfigStatus object.
* @param getConfigStatus.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfigStatus({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getConfigStatus`.");
}
const requestPath = "/1/configs/{indexName}/status".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves the logs for a single Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getLogFile - The getLogFile object.
* @param getLogFile.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getLogFile({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getLogFile`.");
}
const requestPath = "/1/logs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Updates a QuerySuggestions configuration.
*
* Required API Key ACLs:
* - editSettings
* @param updateConfig - The updateConfig object.
* @param updateConfig.indexName - Query Suggestions index name.
* @param updateConfig.configuration - The configuration object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
updateConfig({ indexName, configuration }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `updateConfig`.");
}
if (!configuration) {
throw new Error("Parameter `configuration` is required when calling `updateConfig`.");
}
if (!configuration.sourceIndices) {
throw new Error("Parameter `configuration.sourceIndices` is required when calling `updateConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "PUT",
path: requestPath,
queryParameters,
headers,
data: configuration
};
return transporter.request(request, requestOptions);
}
};
}
// builds/fetch.ts
function querySuggestionsClient(appId, apiKey, region, options) {
if (!appId || typeof appId !== "string") {
throw new Error("`appId` is missing.");
}
if (!apiKey || typeof apiKey !== "string") {
throw new Error("`apiKey` is missing.");
}
if (!region || region && (typeof region !== "string" || !REGIONS.includes(region))) {
throw new Error(`\`region\` is required and must be one of the following: ${REGIONS.join(", ")}`);
}
return {
...createQuerySuggestionsClient({
appId,
apiKey,
region,
timeouts: {
connect: 2e3,
read: 5e3,
write: 3e4
},
logger: createNullLogger(),
requester: createFetchRequester(),
algoliaAgents: [{ segment: "Fetch" }],
responsesCache: createNullCache(),
requestsCache: createNullCache(),
hostsCache: createMemoryCache(),
...options
})
};
}
export {
apiClientVersion,
querySuggestionsClient
};
//# sourceMappingURL=fetch.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,411 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// builds/node.ts
var node_exports = {};
__export(node_exports, {
apiClientVersion: () => apiClientVersion,
querySuggestionsClient: () => querySuggestionsClient
});
module.exports = __toCommonJS(node_exports);
var import_requester_node_http = require("@algolia/requester-node-http");
var import_client_common2 = require("@algolia/client-common");
// src/querySuggestionsClient.ts
var import_client_common = require("@algolia/client-common");
var apiClientVersion = "5.35.0";
var REGIONS = ["eu", "us"];
function getDefaultHosts(region) {
const url = "query-suggestions.{region}.algolia.com".replace("{region}", region);
return [{ url, accept: "readWrite", protocol: "https" }];
}
function createQuerySuggestionsClient({
appId: appIdOption,
apiKey: apiKeyOption,
authMode,
algoliaAgents,
region: regionOption,
...options
}) {
const auth = (0, import_client_common.createAuth)(appIdOption, apiKeyOption, authMode);
const transporter = (0, import_client_common.createTransporter)({
hosts: getDefaultHosts(regionOption),
...options,
algoliaAgent: (0, import_client_common.getAlgoliaAgent)({
algoliaAgents,
client: "QuerySuggestions",
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() {
return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0);
},
/**
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
*/
get _ua() {
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, version) {
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 }) {
if (!authMode || authMode === "WithinHeaders") {
transporter.baseHeaders["x-algolia-api-key"] = apiKey;
} else {
transporter.baseQueryParameters["x-algolia-api-key"] = apiKey;
}
},
/**
* Creates a new Query Suggestions configuration. You can have up to 100 configurations per Algolia application.
*
* Required API Key ACLs:
* - editSettings
* @param configurationWithIndex - The configurationWithIndex object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
createConfig(configurationWithIndex, requestOptions) {
if (!configurationWithIndex) {
throw new Error("Parameter `configurationWithIndex` is required when calling `createConfig`.");
}
const requestPath = "/1/configs";
const headers = {};
const queryParameters = {};
const request = {
method: "POST",
path: requestPath,
queryParameters,
headers,
data: configurationWithIndex
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customDelete - The customDelete object.
* @param customDelete.path - Path of the endpoint, for example `1/newFeature`.
* @param customDelete.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customDelete({ path, parameters }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customDelete`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "DELETE",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customGet - The customGet object.
* @param customGet.path - Path of the endpoint, for example `1/newFeature`.
* @param customGet.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customGet({ path, parameters }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customGet`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customPost - The customPost object.
* @param customPost.path - Path of the endpoint, for example `1/newFeature`.
* @param customPost.parameters - Query parameters to apply to the current query.
* @param customPost.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPost({ path, parameters, body }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customPost`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "POST",
path: requestPath,
queryParameters,
headers,
data: body ? body : {}
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customPut - The customPut object.
* @param customPut.path - Path of the endpoint, for example `1/newFeature`.
* @param customPut.parameters - Query parameters to apply to the current query.
* @param customPut.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPut({ path, parameters, body }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customPut`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "PUT",
path: requestPath,
queryParameters,
headers,
data: body ? body : {}
};
return transporter.request(request, requestOptions);
},
/**
* Deletes a Query Suggestions configuration. Deleting only removes the configuration and stops updates to the Query Suggestions index. To delete the Query Suggestions index itself, use the Search API and the `Delete an index` operation.
*
* Required API Key ACLs:
* - editSettings
* @param deleteConfig - The deleteConfig object.
* @param deleteConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
deleteConfig({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `deleteConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "DELETE",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves all Query Suggestions configurations of your Algolia application.
*
* Required API Key ACLs:
* - settings
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getAllConfigs(requestOptions) {
const requestPath = "/1/configs";
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves a single Query Suggestions configuration by its index name.
*
* Required API Key ACLs:
* - settings
* @param getConfig - The getConfig object.
* @param getConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfig({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Reports the status of a Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getConfigStatus - The getConfigStatus object.
* @param getConfigStatus.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfigStatus({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getConfigStatus`.");
}
const requestPath = "/1/configs/{indexName}/status".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves the logs for a single Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getLogFile - The getLogFile object.
* @param getLogFile.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getLogFile({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getLogFile`.");
}
const requestPath = "/1/logs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Updates a QuerySuggestions configuration.
*
* Required API Key ACLs:
* - editSettings
* @param updateConfig - The updateConfig object.
* @param updateConfig.indexName - Query Suggestions index name.
* @param updateConfig.configuration - The configuration object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
updateConfig({ indexName, configuration }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `updateConfig`.");
}
if (!configuration) {
throw new Error("Parameter `configuration` is required when calling `updateConfig`.");
}
if (!configuration.sourceIndices) {
throw new Error("Parameter `configuration.sourceIndices` is required when calling `updateConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "PUT",
path: requestPath,
queryParameters,
headers,
data: configuration
};
return transporter.request(request, requestOptions);
}
};
}
// builds/node.ts
function querySuggestionsClient(appId, apiKey, region, options) {
if (!appId || typeof appId !== "string") {
throw new Error("`appId` is missing.");
}
if (!apiKey || typeof apiKey !== "string") {
throw new Error("`apiKey` is missing.");
}
if (!region || region && (typeof region !== "string" || !REGIONS.includes(region))) {
throw new Error(`\`region\` is required and must be one of the following: ${REGIONS.join(", ")}`);
}
return {
...createQuerySuggestionsClient({
appId,
apiKey,
region,
timeouts: {
connect: 2e3,
read: 5e3,
write: 3e4
},
logger: (0, import_client_common2.createNullLogger)(),
requester: (0, import_requester_node_http.createHttpRequester)(),
algoliaAgents: [{ segment: "Node.js", version: process.versions.node }],
responsesCache: (0, import_client_common2.createNullCache)(),
requestsCache: (0, import_client_common2.createNullCache)(),
hostsCache: (0, import_client_common2.createMemoryCache)(),
...options
})
};
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
apiClientVersion,
querySuggestionsClient
});
//# sourceMappingURL=node.cjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,385 @@
// builds/node.ts
import { createHttpRequester } from "@algolia/requester-node-http";
import { createMemoryCache, createNullCache, createNullLogger } from "@algolia/client-common";
// src/querySuggestionsClient.ts
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.35.0";
var REGIONS = ["eu", "us"];
function getDefaultHosts(region) {
const url = "query-suggestions.{region}.algolia.com".replace("{region}", region);
return [{ url, accept: "readWrite", protocol: "https" }];
}
function createQuerySuggestionsClient({
appId: appIdOption,
apiKey: apiKeyOption,
authMode,
algoliaAgents,
region: regionOption,
...options
}) {
const auth = createAuth(appIdOption, apiKeyOption, authMode);
const transporter = createTransporter({
hosts: getDefaultHosts(regionOption),
...options,
algoliaAgent: getAlgoliaAgent({
algoliaAgents,
client: "QuerySuggestions",
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() {
return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0);
},
/**
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
*/
get _ua() {
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, version) {
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 }) {
if (!authMode || authMode === "WithinHeaders") {
transporter.baseHeaders["x-algolia-api-key"] = apiKey;
} else {
transporter.baseQueryParameters["x-algolia-api-key"] = apiKey;
}
},
/**
* Creates a new Query Suggestions configuration. You can have up to 100 configurations per Algolia application.
*
* Required API Key ACLs:
* - editSettings
* @param configurationWithIndex - The configurationWithIndex object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
createConfig(configurationWithIndex, requestOptions) {
if (!configurationWithIndex) {
throw new Error("Parameter `configurationWithIndex` is required when calling `createConfig`.");
}
const requestPath = "/1/configs";
const headers = {};
const queryParameters = {};
const request = {
method: "POST",
path: requestPath,
queryParameters,
headers,
data: configurationWithIndex
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customDelete - The customDelete object.
* @param customDelete.path - Path of the endpoint, for example `1/newFeature`.
* @param customDelete.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customDelete({ path, parameters }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customDelete`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "DELETE",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customGet - The customGet object.
* @param customGet.path - Path of the endpoint, for example `1/newFeature`.
* @param customGet.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customGet({ path, parameters }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customGet`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customPost - The customPost object.
* @param customPost.path - Path of the endpoint, for example `1/newFeature`.
* @param customPost.parameters - Query parameters to apply to the current query.
* @param customPost.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPost({ path, parameters, body }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customPost`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "POST",
path: requestPath,
queryParameters,
headers,
data: body ? body : {}
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customPut - The customPut object.
* @param customPut.path - Path of the endpoint, for example `1/newFeature`.
* @param customPut.parameters - Query parameters to apply to the current query.
* @param customPut.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPut({ path, parameters, body }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customPut`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "PUT",
path: requestPath,
queryParameters,
headers,
data: body ? body : {}
};
return transporter.request(request, requestOptions);
},
/**
* Deletes a Query Suggestions configuration. Deleting only removes the configuration and stops updates to the Query Suggestions index. To delete the Query Suggestions index itself, use the Search API and the `Delete an index` operation.
*
* Required API Key ACLs:
* - editSettings
* @param deleteConfig - The deleteConfig object.
* @param deleteConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
deleteConfig({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `deleteConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "DELETE",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves all Query Suggestions configurations of your Algolia application.
*
* Required API Key ACLs:
* - settings
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getAllConfigs(requestOptions) {
const requestPath = "/1/configs";
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves a single Query Suggestions configuration by its index name.
*
* Required API Key ACLs:
* - settings
* @param getConfig - The getConfig object.
* @param getConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfig({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Reports the status of a Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getConfigStatus - The getConfigStatus object.
* @param getConfigStatus.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfigStatus({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getConfigStatus`.");
}
const requestPath = "/1/configs/{indexName}/status".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves the logs for a single Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getLogFile - The getLogFile object.
* @param getLogFile.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getLogFile({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getLogFile`.");
}
const requestPath = "/1/logs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Updates a QuerySuggestions configuration.
*
* Required API Key ACLs:
* - editSettings
* @param updateConfig - The updateConfig object.
* @param updateConfig.indexName - Query Suggestions index name.
* @param updateConfig.configuration - The configuration object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
updateConfig({ indexName, configuration }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `updateConfig`.");
}
if (!configuration) {
throw new Error("Parameter `configuration` is required when calling `updateConfig`.");
}
if (!configuration.sourceIndices) {
throw new Error("Parameter `configuration.sourceIndices` is required when calling `updateConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "PUT",
path: requestPath,
queryParameters,
headers,
data: configuration
};
return transporter.request(request, requestOptions);
}
};
}
// builds/node.ts
function querySuggestionsClient(appId, apiKey, region, options) {
if (!appId || typeof appId !== "string") {
throw new Error("`appId` is missing.");
}
if (!apiKey || typeof apiKey !== "string") {
throw new Error("`apiKey` is missing.");
}
if (!region || region && (typeof region !== "string" || !REGIONS.includes(region))) {
throw new Error(`\`region\` is required and must be one of the following: ${REGIONS.join(", ")}`);
}
return {
...createQuerySuggestionsClient({
appId,
apiKey,
region,
timeouts: {
connect: 2e3,
read: 5e3,
write: 3e4
},
logger: createNullLogger(),
requester: createHttpRequester(),
algoliaAgents: [{ segment: "Node.js", version: process.versions.node }],
responsesCache: createNullCache(),
requestsCache: createNullCache(),
hostsCache: createMemoryCache(),
...options
})
};
}
export {
apiClientVersion,
querySuggestionsClient
};
//# sourceMappingURL=node.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,385 @@
// builds/worker.ts
import { createMemoryCache, createNullCache, createNullLogger } from "@algolia/client-common";
import { createFetchRequester } from "@algolia/requester-fetch";
// src/querySuggestionsClient.ts
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.35.0";
var REGIONS = ["eu", "us"];
function getDefaultHosts(region) {
const url = "query-suggestions.{region}.algolia.com".replace("{region}", region);
return [{ url, accept: "readWrite", protocol: "https" }];
}
function createQuerySuggestionsClient({
appId: appIdOption,
apiKey: apiKeyOption,
authMode,
algoliaAgents,
region: regionOption,
...options
}) {
const auth = createAuth(appIdOption, apiKeyOption, authMode);
const transporter = createTransporter({
hosts: getDefaultHosts(regionOption),
...options,
algoliaAgent: getAlgoliaAgent({
algoliaAgents,
client: "QuerySuggestions",
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() {
return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0);
},
/**
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
*/
get _ua() {
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, version) {
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 }) {
if (!authMode || authMode === "WithinHeaders") {
transporter.baseHeaders["x-algolia-api-key"] = apiKey;
} else {
transporter.baseQueryParameters["x-algolia-api-key"] = apiKey;
}
},
/**
* Creates a new Query Suggestions configuration. You can have up to 100 configurations per Algolia application.
*
* Required API Key ACLs:
* - editSettings
* @param configurationWithIndex - The configurationWithIndex object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
createConfig(configurationWithIndex, requestOptions) {
if (!configurationWithIndex) {
throw new Error("Parameter `configurationWithIndex` is required when calling `createConfig`.");
}
const requestPath = "/1/configs";
const headers = {};
const queryParameters = {};
const request = {
method: "POST",
path: requestPath,
queryParameters,
headers,
data: configurationWithIndex
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customDelete - The customDelete object.
* @param customDelete.path - Path of the endpoint, for example `1/newFeature`.
* @param customDelete.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customDelete({ path, parameters }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customDelete`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "DELETE",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customGet - The customGet object.
* @param customGet.path - Path of the endpoint, for example `1/newFeature`.
* @param customGet.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customGet({ path, parameters }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customGet`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customPost - The customPost object.
* @param customPost.path - Path of the endpoint, for example `1/newFeature`.
* @param customPost.parameters - Query parameters to apply to the current query.
* @param customPost.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPost({ path, parameters, body }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customPost`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "POST",
path: requestPath,
queryParameters,
headers,
data: body ? body : {}
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customPut - The customPut object.
* @param customPut.path - Path of the endpoint, for example `1/newFeature`.
* @param customPut.parameters - Query parameters to apply to the current query.
* @param customPut.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPut({ path, parameters, body }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customPut`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "PUT",
path: requestPath,
queryParameters,
headers,
data: body ? body : {}
};
return transporter.request(request, requestOptions);
},
/**
* Deletes a Query Suggestions configuration. Deleting only removes the configuration and stops updates to the Query Suggestions index. To delete the Query Suggestions index itself, use the Search API and the `Delete an index` operation.
*
* Required API Key ACLs:
* - editSettings
* @param deleteConfig - The deleteConfig object.
* @param deleteConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
deleteConfig({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `deleteConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "DELETE",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves all Query Suggestions configurations of your Algolia application.
*
* Required API Key ACLs:
* - settings
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getAllConfigs(requestOptions) {
const requestPath = "/1/configs";
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves a single Query Suggestions configuration by its index name.
*
* Required API Key ACLs:
* - settings
* @param getConfig - The getConfig object.
* @param getConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfig({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Reports the status of a Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getConfigStatus - The getConfigStatus object.
* @param getConfigStatus.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfigStatus({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getConfigStatus`.");
}
const requestPath = "/1/configs/{indexName}/status".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves the logs for a single Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getLogFile - The getLogFile object.
* @param getLogFile.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getLogFile({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getLogFile`.");
}
const requestPath = "/1/logs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Updates a QuerySuggestions configuration.
*
* Required API Key ACLs:
* - editSettings
* @param updateConfig - The updateConfig object.
* @param updateConfig.indexName - Query Suggestions index name.
* @param updateConfig.configuration - The configuration object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
updateConfig({ indexName, configuration }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `updateConfig`.");
}
if (!configuration) {
throw new Error("Parameter `configuration` is required when calling `updateConfig`.");
}
if (!configuration.sourceIndices) {
throw new Error("Parameter `configuration.sourceIndices` is required when calling `updateConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "PUT",
path: requestPath,
queryParameters,
headers,
data: configuration
};
return transporter.request(request, requestOptions);
}
};
}
// builds/worker.ts
function querySuggestionsClient(appId, apiKey, region, options) {
if (!appId || typeof appId !== "string") {
throw new Error("`appId` is missing.");
}
if (!apiKey || typeof apiKey !== "string") {
throw new Error("`apiKey` is missing.");
}
if (!region || region && (typeof region !== "string" || !REGIONS.includes(region))) {
throw new Error(`\`region\` is required and must be one of the following: ${REGIONS.join(", ")}`);
}
return {
...createQuerySuggestionsClient({
appId,
apiKey,
region,
timeouts: {
connect: 2e3,
read: 5e3,
write: 3e4
},
logger: createNullLogger(),
requester: createFetchRequester(),
algoliaAgents: [{ segment: "Worker" }],
responsesCache: createNullCache(),
requestsCache: createNullCache(),
hostsCache: createMemoryCache(),
...options
})
};
}
export {
apiClientVersion,
querySuggestionsClient
};
//# sourceMappingURL=worker.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,411 @@
import * as _algolia_client_common from '@algolia/client-common';
import { CreateClientOptions, RequestOptions, ClientOptions } from '@algolia/client-common';
type BaseResponse = {
/**
* HTTP status code.
*/
status?: number | undefined;
/**
* Details about the response, such as error messages.
*/
message?: string | undefined;
};
type ConfigStatus = {
/**
* Name of the Query Suggestions index (case-sensitive).
*/
indexName?: string | undefined;
/**
* Whether the creation or update of the Query Suggestions index is in progress.
*/
isRunning?: boolean | undefined;
/**
* Date and time when the Query Suggestions index was last built, in RFC 3339 format.
*/
lastBuiltAt?: string | undefined;
/**
* Date and time when the Query Suggestions index was last updated successfully.
*/
lastSuccessfulBuiltAt?: string | undefined;
/**
* Duration of the last successful build in seconds.
*/
lastSuccessfulBuildDuration?: string | undefined;
};
type AppID = {
/**
* Algolia application ID to which this Query Suggestions configuration belongs.
*/
appID?: string | undefined;
};
/**
* Languages for deduplicating singular and plural suggestions. If specified, only the more popular form is included.
*/
type Languages = Array<string> | boolean;
/**
* Facet to use as category.
*/
type Facet = {
/**
* Facet name.
*/
attribute?: string | undefined;
/**
* Number of suggestions.
*/
amount?: number | undefined;
};
/**
* Configuration of an Algolia index for Query Suggestions.
*/
type SourceIndex = {
/**
* Name of the Algolia index (case-sensitive) to use as source for query suggestions.
*/
indexName: string;
/**
* If true, Query Suggestions uses all replica indices to find popular searches. If false, only the primary index is used.
*/
replicas?: boolean | undefined;
analyticsTags?: Array<string> | null | undefined;
facets?: Array<Facet> | null | undefined;
/**
* Minimum number of hits required to be included as a suggestion. A search query must at least generate `minHits` search results to be included in the Query Suggestions index.
*/
minHits?: number | undefined;
/**
* Minimum letters required to be included as a suggestion. A search query must be at least `minLetters` long to be included in the Query Suggestions index.
*/
minLetters?: number | undefined;
generate?: Array<Array<string>> | null | undefined;
external?: Array<string> | null | undefined;
};
/**
* Query Suggestions configuration.
*/
type Configuration = {
/**
* Algolia indices from which to get the popular searches for query suggestions.
*/
sourceIndices: Array<SourceIndex>;
languages?: Languages | undefined;
exclude?: Array<string> | null | undefined;
/**
* Whether to turn on personalized query suggestions.
*/
enablePersonalization?: boolean | undefined;
/**
* Whether to include suggestions with special characters.
*/
allowSpecialCharacters?: boolean | undefined;
};
/**
* Query Suggestions configuration.
*/
type ConfigurationWithIndex = Record<string, unknown> & Configuration;
/**
* API response for retrieving Query Suggestions configurations.
*/
type ConfigurationResponse = AppID & ConfigurationWithIndex;
/**
* Type of log entry. - `SKIP`. A query is skipped because it doesn\'t match the conditions for successful inclusion. For example, when a query doesn\'t generate enough search results. - `INFO`. An informative log entry. - `ERROR`. The Query Suggestions process encountered an error.
*/
type LogLevel = 'SKIP' | 'INFO' | 'ERROR';
type LogFile = {
/**
* Date and time of the log entry, in RFC 3339 format.
*/
timestamp?: string | undefined;
level?: LogLevel | undefined;
/**
* Details about this log entry.
*/
message?: string | undefined;
/**
* Level indicating the position of a suggestion in a hierarchy of records. For example, a `contextLevel` of 1 indicates that this suggestion belongs to a previous suggestion with `contextLevel` 0.
*/
contextLevel?: number | undefined;
};
/**
* Properties for the `customDelete` method.
*/
type CustomDeleteProps = {
/**
* Path of the endpoint, for example `1/newFeature`.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: {
[key: string]: any;
} | undefined;
};
/**
* Properties for the `customGet` method.
*/
type CustomGetProps = {
/**
* Path of the endpoint, for example `1/newFeature`.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: {
[key: string]: any;
} | undefined;
};
/**
* Properties for the `customPost` method.
*/
type CustomPostProps = {
/**
* Path of the endpoint, for example `1/newFeature`.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: {
[key: string]: any;
} | undefined;
/**
* Parameters to send with the custom request.
*/
body?: Record<string, unknown> | undefined;
};
/**
* Properties for the `customPut` method.
*/
type CustomPutProps = {
/**
* Path of the endpoint, for example `1/newFeature`.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: {
[key: string]: any;
} | undefined;
/**
* Parameters to send with the custom request.
*/
body?: Record<string, unknown> | undefined;
};
/**
* Properties for the `deleteConfig` method.
*/
type DeleteConfigProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
};
/**
* Properties for the `getConfig` method.
*/
type GetConfigProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
};
/**
* Properties for the `getConfigStatus` method.
*/
type GetConfigStatusProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
};
/**
* Properties for the `getLogFile` method.
*/
type GetLogFileProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
};
/**
* Properties for the `updateConfig` method.
*/
type UpdateConfigProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
configuration: Configuration;
};
declare const apiClientVersion = "5.35.0";
declare const REGIONS: readonly ["eu", "us"];
type Region = (typeof REGIONS)[number];
type RegionOptions = {
region: Region;
};
declare function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & RegionOptions): {
transporter: _algolia_client_common.Transporter;
/**
* The `appId` currently in use.
*/
appId: string;
/**
* The `apiKey` currently in use.
*/
apiKey: string;
/**
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
*/
clearCache(): Promise<void>;
/**
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
*/
readonly _ua: string;
/**
* 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 | undefined): void;
/**
* 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;
/**
* Creates a new Query Suggestions configuration. You can have up to 100 configurations per Algolia application.
*
* Required API Key ACLs:
* - editSettings
* @param configurationWithIndex - The configurationWithIndex object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
createConfig(configurationWithIndex: ConfigurationWithIndex, requestOptions?: RequestOptions): Promise<BaseResponse>;
/**
* This method lets you send requests to the Algolia REST API.
* @param customDelete - The customDelete object.
* @param customDelete.path - Path of the endpoint, for example `1/newFeature`.
* @param customDelete.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* This method lets you send requests to the Algolia REST API.
* @param customGet - The customGet object.
* @param customGet.path - Path of the endpoint, for example `1/newFeature`.
* @param customGet.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* This method lets you send requests to the Algolia REST API.
* @param customPost - The customPost object.
* @param customPost.path - Path of the endpoint, for example `1/newFeature`.
* @param customPost.parameters - Query parameters to apply to the current query.
* @param customPost.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPost({ path, parameters, body }: CustomPostProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* This method lets you send requests to the Algolia REST API.
* @param customPut - The customPut object.
* @param customPut.path - Path of the endpoint, for example `1/newFeature`.
* @param customPut.parameters - Query parameters to apply to the current query.
* @param customPut.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPut({ path, parameters, body }: CustomPutProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* Deletes a Query Suggestions configuration. Deleting only removes the configuration and stops updates to the Query Suggestions index. To delete the Query Suggestions index itself, use the Search API and the `Delete an index` operation.
*
* Required API Key ACLs:
* - editSettings
* @param deleteConfig - The deleteConfig object.
* @param deleteConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
deleteConfig({ indexName }: DeleteConfigProps, requestOptions?: RequestOptions): Promise<BaseResponse>;
/**
* Retrieves all Query Suggestions configurations of your Algolia application.
*
* Required API Key ACLs:
* - settings
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getAllConfigs(requestOptions?: RequestOptions | undefined): Promise<Array<ConfigurationResponse>>;
/**
* Retrieves a single Query Suggestions configuration by its index name.
*
* Required API Key ACLs:
* - settings
* @param getConfig - The getConfig object.
* @param getConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfig({ indexName }: GetConfigProps, requestOptions?: RequestOptions): Promise<ConfigurationResponse>;
/**
* Reports the status of a Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getConfigStatus - The getConfigStatus object.
* @param getConfigStatus.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfigStatus({ indexName }: GetConfigStatusProps, requestOptions?: RequestOptions): Promise<ConfigStatus>;
/**
* Retrieves the logs for a single Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getLogFile - The getLogFile object.
* @param getLogFile.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getLogFile({ indexName }: GetLogFileProps, requestOptions?: RequestOptions): Promise<LogFile>;
/**
* Updates a QuerySuggestions configuration.
*
* Required API Key ACLs:
* - editSettings
* @param updateConfig - The updateConfig object.
* @param updateConfig.indexName - Query Suggestions index name.
* @param updateConfig.configuration - The configuration object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
updateConfig({ indexName, configuration }: UpdateConfigProps, requestOptions?: RequestOptions): Promise<BaseResponse>;
};
/**
* Error.
*/
type ErrorBase = Record<string, any> & {
message?: string | undefined;
};
type QuerySuggestionsClient = ReturnType<typeof createQuerySuggestionsClient>;
declare function querySuggestionsClient(appId: string, apiKey: string, region: Region, options?: ClientOptions | undefined): QuerySuggestionsClient;
export { type AppID, type BaseResponse, type ConfigStatus, type Configuration, type ConfigurationResponse, type ConfigurationWithIndex, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type DeleteConfigProps, type ErrorBase, type Facet, type GetConfigProps, type GetConfigStatusProps, type GetLogFileProps, type Languages, type LogFile, type LogLevel, type QuerySuggestionsClient, type Region, type RegionOptions, type SourceIndex, type UpdateConfigProps, apiClientVersion, querySuggestionsClient };

View File

@@ -0,0 +1,411 @@
import * as _algolia_client_common from '@algolia/client-common';
import { CreateClientOptions, RequestOptions, ClientOptions } from '@algolia/client-common';
type BaseResponse = {
/**
* HTTP status code.
*/
status?: number | undefined;
/**
* Details about the response, such as error messages.
*/
message?: string | undefined;
};
type ConfigStatus = {
/**
* Name of the Query Suggestions index (case-sensitive).
*/
indexName?: string | undefined;
/**
* Whether the creation or update of the Query Suggestions index is in progress.
*/
isRunning?: boolean | undefined;
/**
* Date and time when the Query Suggestions index was last built, in RFC 3339 format.
*/
lastBuiltAt?: string | undefined;
/**
* Date and time when the Query Suggestions index was last updated successfully.
*/
lastSuccessfulBuiltAt?: string | undefined;
/**
* Duration of the last successful build in seconds.
*/
lastSuccessfulBuildDuration?: string | undefined;
};
type AppID = {
/**
* Algolia application ID to which this Query Suggestions configuration belongs.
*/
appID?: string | undefined;
};
/**
* Languages for deduplicating singular and plural suggestions. If specified, only the more popular form is included.
*/
type Languages = Array<string> | boolean;
/**
* Facet to use as category.
*/
type Facet = {
/**
* Facet name.
*/
attribute?: string | undefined;
/**
* Number of suggestions.
*/
amount?: number | undefined;
};
/**
* Configuration of an Algolia index for Query Suggestions.
*/
type SourceIndex = {
/**
* Name of the Algolia index (case-sensitive) to use as source for query suggestions.
*/
indexName: string;
/**
* If true, Query Suggestions uses all replica indices to find popular searches. If false, only the primary index is used.
*/
replicas?: boolean | undefined;
analyticsTags?: Array<string> | null | undefined;
facets?: Array<Facet> | null | undefined;
/**
* Minimum number of hits required to be included as a suggestion. A search query must at least generate `minHits` search results to be included in the Query Suggestions index.
*/
minHits?: number | undefined;
/**
* Minimum letters required to be included as a suggestion. A search query must be at least `minLetters` long to be included in the Query Suggestions index.
*/
minLetters?: number | undefined;
generate?: Array<Array<string>> | null | undefined;
external?: Array<string> | null | undefined;
};
/**
* Query Suggestions configuration.
*/
type Configuration = {
/**
* Algolia indices from which to get the popular searches for query suggestions.
*/
sourceIndices: Array<SourceIndex>;
languages?: Languages | undefined;
exclude?: Array<string> | null | undefined;
/**
* Whether to turn on personalized query suggestions.
*/
enablePersonalization?: boolean | undefined;
/**
* Whether to include suggestions with special characters.
*/
allowSpecialCharacters?: boolean | undefined;
};
/**
* Query Suggestions configuration.
*/
type ConfigurationWithIndex = Record<string, unknown> & Configuration;
/**
* API response for retrieving Query Suggestions configurations.
*/
type ConfigurationResponse = AppID & ConfigurationWithIndex;
/**
* Type of log entry. - `SKIP`. A query is skipped because it doesn\'t match the conditions for successful inclusion. For example, when a query doesn\'t generate enough search results. - `INFO`. An informative log entry. - `ERROR`. The Query Suggestions process encountered an error.
*/
type LogLevel = 'SKIP' | 'INFO' | 'ERROR';
type LogFile = {
/**
* Date and time of the log entry, in RFC 3339 format.
*/
timestamp?: string | undefined;
level?: LogLevel | undefined;
/**
* Details about this log entry.
*/
message?: string | undefined;
/**
* Level indicating the position of a suggestion in a hierarchy of records. For example, a `contextLevel` of 1 indicates that this suggestion belongs to a previous suggestion with `contextLevel` 0.
*/
contextLevel?: number | undefined;
};
/**
* Properties for the `customDelete` method.
*/
type CustomDeleteProps = {
/**
* Path of the endpoint, for example `1/newFeature`.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: {
[key: string]: any;
} | undefined;
};
/**
* Properties for the `customGet` method.
*/
type CustomGetProps = {
/**
* Path of the endpoint, for example `1/newFeature`.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: {
[key: string]: any;
} | undefined;
};
/**
* Properties for the `customPost` method.
*/
type CustomPostProps = {
/**
* Path of the endpoint, for example `1/newFeature`.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: {
[key: string]: any;
} | undefined;
/**
* Parameters to send with the custom request.
*/
body?: Record<string, unknown> | undefined;
};
/**
* Properties for the `customPut` method.
*/
type CustomPutProps = {
/**
* Path of the endpoint, for example `1/newFeature`.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: {
[key: string]: any;
} | undefined;
/**
* Parameters to send with the custom request.
*/
body?: Record<string, unknown> | undefined;
};
/**
* Properties for the `deleteConfig` method.
*/
type DeleteConfigProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
};
/**
* Properties for the `getConfig` method.
*/
type GetConfigProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
};
/**
* Properties for the `getConfigStatus` method.
*/
type GetConfigStatusProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
};
/**
* Properties for the `getLogFile` method.
*/
type GetLogFileProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
};
/**
* Properties for the `updateConfig` method.
*/
type UpdateConfigProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
configuration: Configuration;
};
declare const apiClientVersion = "5.35.0";
declare const REGIONS: readonly ["eu", "us"];
type Region = (typeof REGIONS)[number];
type RegionOptions = {
region: Region;
};
declare function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & RegionOptions): {
transporter: _algolia_client_common.Transporter;
/**
* The `appId` currently in use.
*/
appId: string;
/**
* The `apiKey` currently in use.
*/
apiKey: string;
/**
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
*/
clearCache(): Promise<void>;
/**
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
*/
readonly _ua: string;
/**
* 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 | undefined): void;
/**
* 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;
/**
* Creates a new Query Suggestions configuration. You can have up to 100 configurations per Algolia application.
*
* Required API Key ACLs:
* - editSettings
* @param configurationWithIndex - The configurationWithIndex object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
createConfig(configurationWithIndex: ConfigurationWithIndex, requestOptions?: RequestOptions): Promise<BaseResponse>;
/**
* This method lets you send requests to the Algolia REST API.
* @param customDelete - The customDelete object.
* @param customDelete.path - Path of the endpoint, for example `1/newFeature`.
* @param customDelete.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* This method lets you send requests to the Algolia REST API.
* @param customGet - The customGet object.
* @param customGet.path - Path of the endpoint, for example `1/newFeature`.
* @param customGet.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* This method lets you send requests to the Algolia REST API.
* @param customPost - The customPost object.
* @param customPost.path - Path of the endpoint, for example `1/newFeature`.
* @param customPost.parameters - Query parameters to apply to the current query.
* @param customPost.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPost({ path, parameters, body }: CustomPostProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* This method lets you send requests to the Algolia REST API.
* @param customPut - The customPut object.
* @param customPut.path - Path of the endpoint, for example `1/newFeature`.
* @param customPut.parameters - Query parameters to apply to the current query.
* @param customPut.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPut({ path, parameters, body }: CustomPutProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* Deletes a Query Suggestions configuration. Deleting only removes the configuration and stops updates to the Query Suggestions index. To delete the Query Suggestions index itself, use the Search API and the `Delete an index` operation.
*
* Required API Key ACLs:
* - editSettings
* @param deleteConfig - The deleteConfig object.
* @param deleteConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
deleteConfig({ indexName }: DeleteConfigProps, requestOptions?: RequestOptions): Promise<BaseResponse>;
/**
* Retrieves all Query Suggestions configurations of your Algolia application.
*
* Required API Key ACLs:
* - settings
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getAllConfigs(requestOptions?: RequestOptions | undefined): Promise<Array<ConfigurationResponse>>;
/**
* Retrieves a single Query Suggestions configuration by its index name.
*
* Required API Key ACLs:
* - settings
* @param getConfig - The getConfig object.
* @param getConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfig({ indexName }: GetConfigProps, requestOptions?: RequestOptions): Promise<ConfigurationResponse>;
/**
* Reports the status of a Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getConfigStatus - The getConfigStatus object.
* @param getConfigStatus.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfigStatus({ indexName }: GetConfigStatusProps, requestOptions?: RequestOptions): Promise<ConfigStatus>;
/**
* Retrieves the logs for a single Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getLogFile - The getLogFile object.
* @param getLogFile.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getLogFile({ indexName }: GetLogFileProps, requestOptions?: RequestOptions): Promise<LogFile>;
/**
* Updates a QuerySuggestions configuration.
*
* Required API Key ACLs:
* - editSettings
* @param updateConfig - The updateConfig object.
* @param updateConfig.indexName - Query Suggestions index name.
* @param updateConfig.configuration - The configuration object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
updateConfig({ indexName, configuration }: UpdateConfigProps, requestOptions?: RequestOptions): Promise<BaseResponse>;
};
/**
* Error.
*/
type ErrorBase = Record<string, any> & {
message?: string | undefined;
};
type QuerySuggestionsClient = ReturnType<typeof createQuerySuggestionsClient>;
declare function querySuggestionsClient(appId: string, apiKey: string, region: Region, options?: ClientOptions | undefined): QuerySuggestionsClient;
export { type AppID, type BaseResponse, type ConfigStatus, type Configuration, type ConfigurationResponse, type ConfigurationWithIndex, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type DeleteConfigProps, type ErrorBase, type Facet, type GetConfigProps, type GetConfigStatusProps, type GetLogFileProps, type Languages, type LogFile, type LogLevel, type QuerySuggestionsClient, type Region, type RegionOptions, type SourceIndex, type UpdateConfigProps, apiClientVersion, querySuggestionsClient };

View File

@@ -0,0 +1,411 @@
import * as _algolia_client_common from '@algolia/client-common';
import { CreateClientOptions, RequestOptions, ClientOptions } from '@algolia/client-common';
type BaseResponse = {
/**
* HTTP status code.
*/
status?: number | undefined;
/**
* Details about the response, such as error messages.
*/
message?: string | undefined;
};
type ConfigStatus = {
/**
* Name of the Query Suggestions index (case-sensitive).
*/
indexName?: string | undefined;
/**
* Whether the creation or update of the Query Suggestions index is in progress.
*/
isRunning?: boolean | undefined;
/**
* Date and time when the Query Suggestions index was last built, in RFC 3339 format.
*/
lastBuiltAt?: string | undefined;
/**
* Date and time when the Query Suggestions index was last updated successfully.
*/
lastSuccessfulBuiltAt?: string | undefined;
/**
* Duration of the last successful build in seconds.
*/
lastSuccessfulBuildDuration?: string | undefined;
};
type AppID = {
/**
* Algolia application ID to which this Query Suggestions configuration belongs.
*/
appID?: string | undefined;
};
/**
* Languages for deduplicating singular and plural suggestions. If specified, only the more popular form is included.
*/
type Languages = Array<string> | boolean;
/**
* Facet to use as category.
*/
type Facet = {
/**
* Facet name.
*/
attribute?: string | undefined;
/**
* Number of suggestions.
*/
amount?: number | undefined;
};
/**
* Configuration of an Algolia index for Query Suggestions.
*/
type SourceIndex = {
/**
* Name of the Algolia index (case-sensitive) to use as source for query suggestions.
*/
indexName: string;
/**
* If true, Query Suggestions uses all replica indices to find popular searches. If false, only the primary index is used.
*/
replicas?: boolean | undefined;
analyticsTags?: Array<string> | null | undefined;
facets?: Array<Facet> | null | undefined;
/**
* Minimum number of hits required to be included as a suggestion. A search query must at least generate `minHits` search results to be included in the Query Suggestions index.
*/
minHits?: number | undefined;
/**
* Minimum letters required to be included as a suggestion. A search query must be at least `minLetters` long to be included in the Query Suggestions index.
*/
minLetters?: number | undefined;
generate?: Array<Array<string>> | null | undefined;
external?: Array<string> | null | undefined;
};
/**
* Query Suggestions configuration.
*/
type Configuration = {
/**
* Algolia indices from which to get the popular searches for query suggestions.
*/
sourceIndices: Array<SourceIndex>;
languages?: Languages | undefined;
exclude?: Array<string> | null | undefined;
/**
* Whether to turn on personalized query suggestions.
*/
enablePersonalization?: boolean | undefined;
/**
* Whether to include suggestions with special characters.
*/
allowSpecialCharacters?: boolean | undefined;
};
/**
* Query Suggestions configuration.
*/
type ConfigurationWithIndex = Record<string, unknown> & Configuration;
/**
* API response for retrieving Query Suggestions configurations.
*/
type ConfigurationResponse = AppID & ConfigurationWithIndex;
/**
* Type of log entry. - `SKIP`. A query is skipped because it doesn\'t match the conditions for successful inclusion. For example, when a query doesn\'t generate enough search results. - `INFO`. An informative log entry. - `ERROR`. The Query Suggestions process encountered an error.
*/
type LogLevel = 'SKIP' | 'INFO' | 'ERROR';
type LogFile = {
/**
* Date and time of the log entry, in RFC 3339 format.
*/
timestamp?: string | undefined;
level?: LogLevel | undefined;
/**
* Details about this log entry.
*/
message?: string | undefined;
/**
* Level indicating the position of a suggestion in a hierarchy of records. For example, a `contextLevel` of 1 indicates that this suggestion belongs to a previous suggestion with `contextLevel` 0.
*/
contextLevel?: number | undefined;
};
/**
* Properties for the `customDelete` method.
*/
type CustomDeleteProps = {
/**
* Path of the endpoint, for example `1/newFeature`.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: {
[key: string]: any;
} | undefined;
};
/**
* Properties for the `customGet` method.
*/
type CustomGetProps = {
/**
* Path of the endpoint, for example `1/newFeature`.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: {
[key: string]: any;
} | undefined;
};
/**
* Properties for the `customPost` method.
*/
type CustomPostProps = {
/**
* Path of the endpoint, for example `1/newFeature`.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: {
[key: string]: any;
} | undefined;
/**
* Parameters to send with the custom request.
*/
body?: Record<string, unknown> | undefined;
};
/**
* Properties for the `customPut` method.
*/
type CustomPutProps = {
/**
* Path of the endpoint, for example `1/newFeature`.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: {
[key: string]: any;
} | undefined;
/**
* Parameters to send with the custom request.
*/
body?: Record<string, unknown> | undefined;
};
/**
* Properties for the `deleteConfig` method.
*/
type DeleteConfigProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
};
/**
* Properties for the `getConfig` method.
*/
type GetConfigProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
};
/**
* Properties for the `getConfigStatus` method.
*/
type GetConfigStatusProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
};
/**
* Properties for the `getLogFile` method.
*/
type GetLogFileProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
};
/**
* Properties for the `updateConfig` method.
*/
type UpdateConfigProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
configuration: Configuration;
};
declare const apiClientVersion = "5.35.0";
declare const REGIONS: readonly ["eu", "us"];
type Region = (typeof REGIONS)[number];
type RegionOptions = {
region: Region;
};
declare function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & RegionOptions): {
transporter: _algolia_client_common.Transporter;
/**
* The `appId` currently in use.
*/
appId: string;
/**
* The `apiKey` currently in use.
*/
apiKey: string;
/**
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
*/
clearCache(): Promise<void>;
/**
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
*/
readonly _ua: string;
/**
* 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 | undefined): void;
/**
* 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;
/**
* Creates a new Query Suggestions configuration. You can have up to 100 configurations per Algolia application.
*
* Required API Key ACLs:
* - editSettings
* @param configurationWithIndex - The configurationWithIndex object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
createConfig(configurationWithIndex: ConfigurationWithIndex, requestOptions?: RequestOptions): Promise<BaseResponse>;
/**
* This method lets you send requests to the Algolia REST API.
* @param customDelete - The customDelete object.
* @param customDelete.path - Path of the endpoint, for example `1/newFeature`.
* @param customDelete.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* This method lets you send requests to the Algolia REST API.
* @param customGet - The customGet object.
* @param customGet.path - Path of the endpoint, for example `1/newFeature`.
* @param customGet.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* This method lets you send requests to the Algolia REST API.
* @param customPost - The customPost object.
* @param customPost.path - Path of the endpoint, for example `1/newFeature`.
* @param customPost.parameters - Query parameters to apply to the current query.
* @param customPost.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPost({ path, parameters, body }: CustomPostProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* This method lets you send requests to the Algolia REST API.
* @param customPut - The customPut object.
* @param customPut.path - Path of the endpoint, for example `1/newFeature`.
* @param customPut.parameters - Query parameters to apply to the current query.
* @param customPut.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPut({ path, parameters, body }: CustomPutProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* Deletes a Query Suggestions configuration. Deleting only removes the configuration and stops updates to the Query Suggestions index. To delete the Query Suggestions index itself, use the Search API and the `Delete an index` operation.
*
* Required API Key ACLs:
* - editSettings
* @param deleteConfig - The deleteConfig object.
* @param deleteConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
deleteConfig({ indexName }: DeleteConfigProps, requestOptions?: RequestOptions): Promise<BaseResponse>;
/**
* Retrieves all Query Suggestions configurations of your Algolia application.
*
* Required API Key ACLs:
* - settings
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getAllConfigs(requestOptions?: RequestOptions | undefined): Promise<Array<ConfigurationResponse>>;
/**
* Retrieves a single Query Suggestions configuration by its index name.
*
* Required API Key ACLs:
* - settings
* @param getConfig - The getConfig object.
* @param getConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfig({ indexName }: GetConfigProps, requestOptions?: RequestOptions): Promise<ConfigurationResponse>;
/**
* Reports the status of a Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getConfigStatus - The getConfigStatus object.
* @param getConfigStatus.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfigStatus({ indexName }: GetConfigStatusProps, requestOptions?: RequestOptions): Promise<ConfigStatus>;
/**
* Retrieves the logs for a single Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getLogFile - The getLogFile object.
* @param getLogFile.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getLogFile({ indexName }: GetLogFileProps, requestOptions?: RequestOptions): Promise<LogFile>;
/**
* Updates a QuerySuggestions configuration.
*
* Required API Key ACLs:
* - editSettings
* @param updateConfig - The updateConfig object.
* @param updateConfig.indexName - Query Suggestions index name.
* @param updateConfig.configuration - The configuration object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
updateConfig({ indexName, configuration }: UpdateConfigProps, requestOptions?: RequestOptions): Promise<BaseResponse>;
};
/**
* Error.
*/
type ErrorBase = Record<string, any> & {
message?: string | undefined;
};
type QuerySuggestionsClient = ReturnType<typeof createQuerySuggestionsClient>;
declare function querySuggestionsClient(appId: string, apiKey: string, region: Region, options?: ClientOptions | undefined): QuerySuggestionsClient;
export { type AppID, type BaseResponse, type ConfigStatus, type Configuration, type ConfigurationResponse, type ConfigurationWithIndex, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type DeleteConfigProps, type ErrorBase, type Facet, type GetConfigProps, type GetConfigStatusProps, type GetLogFileProps, type Languages, type LogFile, type LogLevel, type QuerySuggestionsClient, type Region, type RegionOptions, type SourceIndex, type UpdateConfigProps, apiClientVersion, querySuggestionsClient };

View File

@@ -0,0 +1,377 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/querySuggestionsClient.ts
var querySuggestionsClient_exports = {};
__export(querySuggestionsClient_exports, {
REGIONS: () => REGIONS,
apiClientVersion: () => apiClientVersion,
createQuerySuggestionsClient: () => createQuerySuggestionsClient
});
module.exports = __toCommonJS(querySuggestionsClient_exports);
var import_client_common = require("@algolia/client-common");
var apiClientVersion = "5.35.0";
var REGIONS = ["eu", "us"];
function getDefaultHosts(region) {
const url = "query-suggestions.{region}.algolia.com".replace("{region}", region);
return [{ url, accept: "readWrite", protocol: "https" }];
}
function createQuerySuggestionsClient({
appId: appIdOption,
apiKey: apiKeyOption,
authMode,
algoliaAgents,
region: regionOption,
...options
}) {
const auth = (0, import_client_common.createAuth)(appIdOption, apiKeyOption, authMode);
const transporter = (0, import_client_common.createTransporter)({
hosts: getDefaultHosts(regionOption),
...options,
algoliaAgent: (0, import_client_common.getAlgoliaAgent)({
algoliaAgents,
client: "QuerySuggestions",
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() {
return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0);
},
/**
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
*/
get _ua() {
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, version) {
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 }) {
if (!authMode || authMode === "WithinHeaders") {
transporter.baseHeaders["x-algolia-api-key"] = apiKey;
} else {
transporter.baseQueryParameters["x-algolia-api-key"] = apiKey;
}
},
/**
* Creates a new Query Suggestions configuration. You can have up to 100 configurations per Algolia application.
*
* Required API Key ACLs:
* - editSettings
* @param configurationWithIndex - The configurationWithIndex object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
createConfig(configurationWithIndex, requestOptions) {
if (!configurationWithIndex) {
throw new Error("Parameter `configurationWithIndex` is required when calling `createConfig`.");
}
const requestPath = "/1/configs";
const headers = {};
const queryParameters = {};
const request = {
method: "POST",
path: requestPath,
queryParameters,
headers,
data: configurationWithIndex
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customDelete - The customDelete object.
* @param customDelete.path - Path of the endpoint, for example `1/newFeature`.
* @param customDelete.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customDelete({ path, parameters }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customDelete`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "DELETE",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customGet - The customGet object.
* @param customGet.path - Path of the endpoint, for example `1/newFeature`.
* @param customGet.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customGet({ path, parameters }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customGet`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customPost - The customPost object.
* @param customPost.path - Path of the endpoint, for example `1/newFeature`.
* @param customPost.parameters - Query parameters to apply to the current query.
* @param customPost.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPost({ path, parameters, body }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customPost`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "POST",
path: requestPath,
queryParameters,
headers,
data: body ? body : {}
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customPut - The customPut object.
* @param customPut.path - Path of the endpoint, for example `1/newFeature`.
* @param customPut.parameters - Query parameters to apply to the current query.
* @param customPut.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPut({ path, parameters, body }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customPut`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "PUT",
path: requestPath,
queryParameters,
headers,
data: body ? body : {}
};
return transporter.request(request, requestOptions);
},
/**
* Deletes a Query Suggestions configuration. Deleting only removes the configuration and stops updates to the Query Suggestions index. To delete the Query Suggestions index itself, use the Search API and the `Delete an index` operation.
*
* Required API Key ACLs:
* - editSettings
* @param deleteConfig - The deleteConfig object.
* @param deleteConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
deleteConfig({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `deleteConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "DELETE",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves all Query Suggestions configurations of your Algolia application.
*
* Required API Key ACLs:
* - settings
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getAllConfigs(requestOptions) {
const requestPath = "/1/configs";
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves a single Query Suggestions configuration by its index name.
*
* Required API Key ACLs:
* - settings
* @param getConfig - The getConfig object.
* @param getConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfig({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Reports the status of a Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getConfigStatus - The getConfigStatus object.
* @param getConfigStatus.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfigStatus({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getConfigStatus`.");
}
const requestPath = "/1/configs/{indexName}/status".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves the logs for a single Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getLogFile - The getLogFile object.
* @param getLogFile.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getLogFile({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getLogFile`.");
}
const requestPath = "/1/logs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Updates a QuerySuggestions configuration.
*
* Required API Key ACLs:
* - editSettings
* @param updateConfig - The updateConfig object.
* @param updateConfig.indexName - Query Suggestions index name.
* @param updateConfig.configuration - The configuration object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
updateConfig({ indexName, configuration }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `updateConfig`.");
}
if (!configuration) {
throw new Error("Parameter `configuration` is required when calling `updateConfig`.");
}
if (!configuration.sourceIndices) {
throw new Error("Parameter `configuration.sourceIndices` is required when calling `updateConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "PUT",
path: requestPath,
queryParameters,
headers,
data: configuration
};
return transporter.request(request, requestOptions);
}
};
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
REGIONS,
apiClientVersion,
createQuerySuggestionsClient
});
//# sourceMappingURL=querySuggestionsClient.cjs.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,350 @@
// src/querySuggestionsClient.ts
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
var apiClientVersion = "5.35.0";
var REGIONS = ["eu", "us"];
function getDefaultHosts(region) {
const url = "query-suggestions.{region}.algolia.com".replace("{region}", region);
return [{ url, accept: "readWrite", protocol: "https" }];
}
function createQuerySuggestionsClient({
appId: appIdOption,
apiKey: apiKeyOption,
authMode,
algoliaAgents,
region: regionOption,
...options
}) {
const auth = createAuth(appIdOption, apiKeyOption, authMode);
const transporter = createTransporter({
hosts: getDefaultHosts(regionOption),
...options,
algoliaAgent: getAlgoliaAgent({
algoliaAgents,
client: "QuerySuggestions",
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() {
return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0);
},
/**
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
*/
get _ua() {
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, version) {
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 }) {
if (!authMode || authMode === "WithinHeaders") {
transporter.baseHeaders["x-algolia-api-key"] = apiKey;
} else {
transporter.baseQueryParameters["x-algolia-api-key"] = apiKey;
}
},
/**
* Creates a new Query Suggestions configuration. You can have up to 100 configurations per Algolia application.
*
* Required API Key ACLs:
* - editSettings
* @param configurationWithIndex - The configurationWithIndex object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
createConfig(configurationWithIndex, requestOptions) {
if (!configurationWithIndex) {
throw new Error("Parameter `configurationWithIndex` is required when calling `createConfig`.");
}
const requestPath = "/1/configs";
const headers = {};
const queryParameters = {};
const request = {
method: "POST",
path: requestPath,
queryParameters,
headers,
data: configurationWithIndex
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customDelete - The customDelete object.
* @param customDelete.path - Path of the endpoint, for example `1/newFeature`.
* @param customDelete.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customDelete({ path, parameters }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customDelete`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "DELETE",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customGet - The customGet object.
* @param customGet.path - Path of the endpoint, for example `1/newFeature`.
* @param customGet.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customGet({ path, parameters }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customGet`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customPost - The customPost object.
* @param customPost.path - Path of the endpoint, for example `1/newFeature`.
* @param customPost.parameters - Query parameters to apply to the current query.
* @param customPost.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPost({ path, parameters, body }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customPost`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "POST",
path: requestPath,
queryParameters,
headers,
data: body ? body : {}
};
return transporter.request(request, requestOptions);
},
/**
* This method lets you send requests to the Algolia REST API.
* @param customPut - The customPut object.
* @param customPut.path - Path of the endpoint, for example `1/newFeature`.
* @param customPut.parameters - Query parameters to apply to the current query.
* @param customPut.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPut({ path, parameters, body }, requestOptions) {
if (!path) {
throw new Error("Parameter `path` is required when calling `customPut`.");
}
const requestPath = "/{path}".replace("{path}", path);
const headers = {};
const queryParameters = parameters ? parameters : {};
const request = {
method: "PUT",
path: requestPath,
queryParameters,
headers,
data: body ? body : {}
};
return transporter.request(request, requestOptions);
},
/**
* Deletes a Query Suggestions configuration. Deleting only removes the configuration and stops updates to the Query Suggestions index. To delete the Query Suggestions index itself, use the Search API and the `Delete an index` operation.
*
* Required API Key ACLs:
* - editSettings
* @param deleteConfig - The deleteConfig object.
* @param deleteConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
deleteConfig({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `deleteConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "DELETE",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves all Query Suggestions configurations of your Algolia application.
*
* Required API Key ACLs:
* - settings
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getAllConfigs(requestOptions) {
const requestPath = "/1/configs";
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves a single Query Suggestions configuration by its index name.
*
* Required API Key ACLs:
* - settings
* @param getConfig - The getConfig object.
* @param getConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfig({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Reports the status of a Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getConfigStatus - The getConfigStatus object.
* @param getConfigStatus.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfigStatus({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getConfigStatus`.");
}
const requestPath = "/1/configs/{indexName}/status".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Retrieves the logs for a single Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getLogFile - The getLogFile object.
* @param getLogFile.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getLogFile({ indexName }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `getLogFile`.");
}
const requestPath = "/1/logs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "GET",
path: requestPath,
queryParameters,
headers
};
return transporter.request(request, requestOptions);
},
/**
* Updates a QuerySuggestions configuration.
*
* Required API Key ACLs:
* - editSettings
* @param updateConfig - The updateConfig object.
* @param updateConfig.indexName - Query Suggestions index name.
* @param updateConfig.configuration - The configuration object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
updateConfig({ indexName, configuration }, requestOptions) {
if (!indexName) {
throw new Error("Parameter `indexName` is required when calling `updateConfig`.");
}
if (!configuration) {
throw new Error("Parameter `configuration` is required when calling `updateConfig`.");
}
if (!configuration.sourceIndices) {
throw new Error("Parameter `configuration.sourceIndices` is required when calling `updateConfig`.");
}
const requestPath = "/1/configs/{indexName}".replace("{indexName}", encodeURIComponent(indexName));
const headers = {};
const queryParameters = {};
const request = {
method: "PUT",
path: requestPath,
queryParameters,
headers,
data: configuration
};
return transporter.request(request, requestOptions);
}
};
}
export {
REGIONS,
apiClientVersion,
createQuerySuggestionsClient
};
//# sourceMappingURL=querySuggestionsClient.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,411 @@
import * as _algolia_client_common from '@algolia/client-common';
import { CreateClientOptions, RequestOptions, ClientOptions } from '@algolia/client-common';
type BaseResponse = {
/**
* HTTP status code.
*/
status?: number | undefined;
/**
* Details about the response, such as error messages.
*/
message?: string | undefined;
};
type ConfigStatus = {
/**
* Name of the Query Suggestions index (case-sensitive).
*/
indexName?: string | undefined;
/**
* Whether the creation or update of the Query Suggestions index is in progress.
*/
isRunning?: boolean | undefined;
/**
* Date and time when the Query Suggestions index was last built, in RFC 3339 format.
*/
lastBuiltAt?: string | undefined;
/**
* Date and time when the Query Suggestions index was last updated successfully.
*/
lastSuccessfulBuiltAt?: string | undefined;
/**
* Duration of the last successful build in seconds.
*/
lastSuccessfulBuildDuration?: string | undefined;
};
type AppID = {
/**
* Algolia application ID to which this Query Suggestions configuration belongs.
*/
appID?: string | undefined;
};
/**
* Languages for deduplicating singular and plural suggestions. If specified, only the more popular form is included.
*/
type Languages = Array<string> | boolean;
/**
* Facet to use as category.
*/
type Facet = {
/**
* Facet name.
*/
attribute?: string | undefined;
/**
* Number of suggestions.
*/
amount?: number | undefined;
};
/**
* Configuration of an Algolia index for Query Suggestions.
*/
type SourceIndex = {
/**
* Name of the Algolia index (case-sensitive) to use as source for query suggestions.
*/
indexName: string;
/**
* If true, Query Suggestions uses all replica indices to find popular searches. If false, only the primary index is used.
*/
replicas?: boolean | undefined;
analyticsTags?: Array<string> | null | undefined;
facets?: Array<Facet> | null | undefined;
/**
* Minimum number of hits required to be included as a suggestion. A search query must at least generate `minHits` search results to be included in the Query Suggestions index.
*/
minHits?: number | undefined;
/**
* Minimum letters required to be included as a suggestion. A search query must be at least `minLetters` long to be included in the Query Suggestions index.
*/
minLetters?: number | undefined;
generate?: Array<Array<string>> | null | undefined;
external?: Array<string> | null | undefined;
};
/**
* Query Suggestions configuration.
*/
type Configuration = {
/**
* Algolia indices from which to get the popular searches for query suggestions.
*/
sourceIndices: Array<SourceIndex>;
languages?: Languages | undefined;
exclude?: Array<string> | null | undefined;
/**
* Whether to turn on personalized query suggestions.
*/
enablePersonalization?: boolean | undefined;
/**
* Whether to include suggestions with special characters.
*/
allowSpecialCharacters?: boolean | undefined;
};
/**
* Query Suggestions configuration.
*/
type ConfigurationWithIndex = Record<string, unknown> & Configuration;
/**
* API response for retrieving Query Suggestions configurations.
*/
type ConfigurationResponse = AppID & ConfigurationWithIndex;
/**
* Type of log entry. - `SKIP`. A query is skipped because it doesn\'t match the conditions for successful inclusion. For example, when a query doesn\'t generate enough search results. - `INFO`. An informative log entry. - `ERROR`. The Query Suggestions process encountered an error.
*/
type LogLevel = 'SKIP' | 'INFO' | 'ERROR';
type LogFile = {
/**
* Date and time of the log entry, in RFC 3339 format.
*/
timestamp?: string | undefined;
level?: LogLevel | undefined;
/**
* Details about this log entry.
*/
message?: string | undefined;
/**
* Level indicating the position of a suggestion in a hierarchy of records. For example, a `contextLevel` of 1 indicates that this suggestion belongs to a previous suggestion with `contextLevel` 0.
*/
contextLevel?: number | undefined;
};
/**
* Properties for the `customDelete` method.
*/
type CustomDeleteProps = {
/**
* Path of the endpoint, for example `1/newFeature`.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: {
[key: string]: any;
} | undefined;
};
/**
* Properties for the `customGet` method.
*/
type CustomGetProps = {
/**
* Path of the endpoint, for example `1/newFeature`.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: {
[key: string]: any;
} | undefined;
};
/**
* Properties for the `customPost` method.
*/
type CustomPostProps = {
/**
* Path of the endpoint, for example `1/newFeature`.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: {
[key: string]: any;
} | undefined;
/**
* Parameters to send with the custom request.
*/
body?: Record<string, unknown> | undefined;
};
/**
* Properties for the `customPut` method.
*/
type CustomPutProps = {
/**
* Path of the endpoint, for example `1/newFeature`.
*/
path: string;
/**
* Query parameters to apply to the current query.
*/
parameters?: {
[key: string]: any;
} | undefined;
/**
* Parameters to send with the custom request.
*/
body?: Record<string, unknown> | undefined;
};
/**
* Properties for the `deleteConfig` method.
*/
type DeleteConfigProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
};
/**
* Properties for the `getConfig` method.
*/
type GetConfigProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
};
/**
* Properties for the `getConfigStatus` method.
*/
type GetConfigStatusProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
};
/**
* Properties for the `getLogFile` method.
*/
type GetLogFileProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
};
/**
* Properties for the `updateConfig` method.
*/
type UpdateConfigProps = {
/**
* Query Suggestions index name.
*/
indexName: string;
configuration: Configuration;
};
declare const apiClientVersion = "5.35.0";
declare const REGIONS: readonly ["eu", "us"];
type Region = (typeof REGIONS)[number];
type RegionOptions = {
region: Region;
};
declare function createQuerySuggestionsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & RegionOptions): {
transporter: _algolia_client_common.Transporter;
/**
* The `appId` currently in use.
*/
appId: string;
/**
* The `apiKey` currently in use.
*/
apiKey: string;
/**
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
*/
clearCache(): Promise<void>;
/**
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
*/
readonly _ua: string;
/**
* 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 | undefined): void;
/**
* 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;
/**
* Creates a new Query Suggestions configuration. You can have up to 100 configurations per Algolia application.
*
* Required API Key ACLs:
* - editSettings
* @param configurationWithIndex - The configurationWithIndex object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
createConfig(configurationWithIndex: ConfigurationWithIndex, requestOptions?: RequestOptions): Promise<BaseResponse>;
/**
* This method lets you send requests to the Algolia REST API.
* @param customDelete - The customDelete object.
* @param customDelete.path - Path of the endpoint, for example `1/newFeature`.
* @param customDelete.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* This method lets you send requests to the Algolia REST API.
* @param customGet - The customGet object.
* @param customGet.path - Path of the endpoint, for example `1/newFeature`.
* @param customGet.parameters - Query parameters to apply to the current query.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* This method lets you send requests to the Algolia REST API.
* @param customPost - The customPost object.
* @param customPost.path - Path of the endpoint, for example `1/newFeature`.
* @param customPost.parameters - Query parameters to apply to the current query.
* @param customPost.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPost({ path, parameters, body }: CustomPostProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* This method lets you send requests to the Algolia REST API.
* @param customPut - The customPut object.
* @param customPut.path - Path of the endpoint, for example `1/newFeature`.
* @param customPut.parameters - Query parameters to apply to the current query.
* @param customPut.body - Parameters to send with the custom request.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
customPut({ path, parameters, body }: CustomPutProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
/**
* Deletes a Query Suggestions configuration. Deleting only removes the configuration and stops updates to the Query Suggestions index. To delete the Query Suggestions index itself, use the Search API and the `Delete an index` operation.
*
* Required API Key ACLs:
* - editSettings
* @param deleteConfig - The deleteConfig object.
* @param deleteConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
deleteConfig({ indexName }: DeleteConfigProps, requestOptions?: RequestOptions): Promise<BaseResponse>;
/**
* Retrieves all Query Suggestions configurations of your Algolia application.
*
* Required API Key ACLs:
* - settings
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getAllConfigs(requestOptions?: RequestOptions | undefined): Promise<Array<ConfigurationResponse>>;
/**
* Retrieves a single Query Suggestions configuration by its index name.
*
* Required API Key ACLs:
* - settings
* @param getConfig - The getConfig object.
* @param getConfig.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfig({ indexName }: GetConfigProps, requestOptions?: RequestOptions): Promise<ConfigurationResponse>;
/**
* Reports the status of a Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getConfigStatus - The getConfigStatus object.
* @param getConfigStatus.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getConfigStatus({ indexName }: GetConfigStatusProps, requestOptions?: RequestOptions): Promise<ConfigStatus>;
/**
* Retrieves the logs for a single Query Suggestions index.
*
* Required API Key ACLs:
* - settings
* @param getLogFile - The getLogFile object.
* @param getLogFile.indexName - Query Suggestions index name.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
getLogFile({ indexName }: GetLogFileProps, requestOptions?: RequestOptions): Promise<LogFile>;
/**
* Updates a QuerySuggestions configuration.
*
* Required API Key ACLs:
* - editSettings
* @param updateConfig - The updateConfig object.
* @param updateConfig.indexName - Query Suggestions index name.
* @param updateConfig.configuration - The configuration object.
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
*/
updateConfig({ indexName, configuration }: UpdateConfigProps, requestOptions?: RequestOptions): Promise<BaseResponse>;
};
/**
* Error.
*/
type ErrorBase = Record<string, any> & {
message?: string | undefined;
};
type QuerySuggestionsClient = ReturnType<typeof createQuerySuggestionsClient>;
declare function querySuggestionsClient(appId: string, apiKey: string, region: Region, options?: ClientOptions | undefined): QuerySuggestionsClient;
export { type AppID, type BaseResponse, type ConfigStatus, type Configuration, type ConfigurationResponse, type ConfigurationWithIndex, type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type DeleteConfigProps, type ErrorBase, type Facet, type GetConfigProps, type GetConfigStatusProps, type GetLogFileProps, type Languages, type LogFile, type LogLevel, type QuerySuggestionsClient, type Region, type RegionOptions, type SourceIndex, type UpdateConfigProps, apiClientVersion, querySuggestionsClient };

View File

@@ -0,0 +1 @@
export * from './dist/node';

View File

@@ -0,0 +1 @@
module.exports = require('./dist/builds/node.cjs');

View File

@@ -0,0 +1,68 @@
{
"version": "5.35.0",
"repository": {
"type": "git",
"url": "git+https://github.com/algolia/algoliasearch-client-javascript.git"
},
"homepage": "https://github.com/algolia/algoliasearch-client-javascript/tree/main/packages/client-query-suggestions#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/client-query-suggestions",
"description": "JavaScript client for client-query-suggestions",
"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.35.0",
"@algolia/requester-browser-xhr": "5.35.0",
"@algolia/requester-fetch": "5.35.0",
"@algolia/requester-node-http": "5.35.0"
},
"devDependencies": {
"@arethetypeswrong/cli": "0.18.2",
"@types/node": "22.16.5",
"publint": "0.3.12",
"rollup": "4.41.0",
"tsup": "8.5.0",
"typescript": "5.8.3"
},
"engines": {
"node": ">= 14.0.0"
}
}