1 line
172 KiB
Plaintext
1 line
172 KiB
Plaintext
|
{"version":3,"sources":["../../builds/node.ts","../../src/searchClient.ts"],"sourcesContent":["// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.\n\nexport type SearchClient = ReturnType<typeof createSearchClient> & SearchClientNodeHelpers;\n\nimport { createHmac } from 'node:crypto';\n\nimport { createHttpRequester } from '@algolia/requester-node-http';\n\nimport {\n IndexAlreadyExistsError,\n IndexNotFoundError,\n IndicesInSameAppError,\n createMemoryCache,\n createNullCache,\n createNullLogger,\n serializeQueryParameters,\n} from '@algolia/client-common';\n\nimport type { ClientOptions, RequestOptions } from '@algolia/client-common';\n\nimport { createSearchClient } from '../src/searchClient';\n\nexport { apiClientVersion } from '../src/searchClient';\n\nexport * from '../model';\n\nimport type {\n AccountCopyIndexOptions,\n BrowseResponse,\n GenerateSecuredApiKeyOptions,\n GetSecuredApiKeyRemainingValidityOptions,\n SearchClientNodeHelpers,\n SearchRulesResponse,\n SearchSynonymsResponse,\n UpdatedAtResponse,\n} from '../model';\n\nexport function searchClient(appId: string, apiKey: string, options?: ClientOptions | undefined): SearchClient {\n if (!appId || typeof appId !== 'string') {\n throw new Error('`appId` is missing.');\n }\n\n if (!apiKey || typeof apiKey !== 'string') {\n throw new Error('`apiKey` is missing.');\n }\n\n return {\n ...createSearchClient({\n appId,\n apiKey,\n timeouts: {\n connect: 2000,\n read: 5000,\n write: 30000,\n },\n logger: createNullLogger(),\n requester: createHttpRequester(),\n algoliaAgents: [{ segment: 'Node.js', version: process.versions.node }],\n responsesCache: createNullCache(),\n requestsCache: createNullCache(),\n hostsCache: createMemoryCache(),\n ...options,\n }),\n /**\n * Helper: Generates a secured API key based on the given `parentApiKey` and given `restrictions`.\n *\n * @summary Helper: Generates a secured API key based on the given `parentApiKey` and given `restrictions`.\n * @param generateSecuredApiKey - The `generateSecuredApiKey` object.\n * @param generateSecuredApiKey.parentApiKey - The base API key from which to generate the new secured one.\n * @param generateSecuredApiKey.restrictions - A set of properties defining the restrictions of the secured API key.\n */\n generateSecuredApiKey: ({ parentApiKey, restrictions = {} }: GenerateSecuredApiKeyOptions): string => {\n let mergedRestrictions = restrictions;\n if (restrictions.searchParams) {\n // merge searchParams with the root restrictions\n mergedRestrictions = {\n ...restrictions,\n ...restrictions.searchParams,\n };\n\n delete mergedRestrictions.searchParams;\n }\n\n mergedRestrictions = Object.keys(mergedRestrictions)\n .sort()\n .reduce(\n (acc, key) => {\n acc[key] = (mergedRestrictions as any)[key];\n return acc;\n },\n {} as Record<string, unknown>,\n );\n\n const queryParameters = serializeQueryParameters(mergedRestrictions);\n return Buffer.from(\n createHmac('sha256', parentApiKey).update(queryParameters).digest('hex') + queryParameters,\n ).toString('base64');\n },\n\n /**\n * Helper: Copies the given `sourceIndexName` records, rules and synonyms to an other Algolia application for the given `destinationIndexName`.\n * See https://api-clients-automation.netlify.app/docs/add-new-api-client#5-helpers for implementation details.\n *\n * @summary Helper: Copies the given `sourceIndexName` records, rules and synonyms to an other Algolia application for the given `destinationIndexName`.\n * @param accountCopyIndex - The `accountCopyIndex` object.\n * @param accountCopyIndex.sourceIndexName - The name of the index to copy.\n * @param accountCopy
|