"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.20.3"; 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 allow you to send requests to the Algolia REST API. * @param customDelete - The customDelete object. * @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified. * @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 allow you to send requests to the Algolia REST API. * @param customGet - The customGet object. * @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified. * @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 allow you to send requests to the Algolia REST API. * @param customPost - The customPost object. * @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified. * @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 allow you to send requests to the Algolia REST API. * @param customPut - The customPut object. * @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified. * @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