From d9cc222008779e5595186c84d85a555c2133a987 Mon Sep 17 00:00:00 2001 From: algolia-bot Date: Wed, 28 Aug 2024 22:23:52 +0000 Subject: [PATCH] Merge branch 'main' into fix/javascript-algoliasearch-build (generated) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clément Vannicatte --- .../packages/algoliasearch/builds/browser.ts | 120 +++++++----------- .../packages/algoliasearch/builds/node.ts | 114 ++++++----------- .../packages/algoliasearch/package.json | 6 +- .../packages/client-abtesting/package.json | 2 +- .../packages/client-analytics/package.json | 2 +- .../packages/client-insights/package.json | 2 +- .../client-personalization/package.json | 2 +- .../client-query-suggestions/package.json | 2 +- .../packages/client-search/package.json | 2 +- .../packages/client-usage/package.json | 2 +- .../packages/ingestion/package.json | 2 +- .../packages/monitoring/package.json | 2 +- .../packages/recommend/package.json | 2 +- 13 files changed, 97 insertions(+), 163 deletions(-) diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch/builds/browser.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch/builds/browser.ts index 25ada62184d..5cc045cbccc 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch/builds/browser.ts +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch/builds/browser.ts @@ -1,11 +1,10 @@ // Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. -import type { AbtestingClient } from '@algolia/client-abtesting'; -import type { Region as AbtestingRegion } from '@algolia/client-abtesting/src/abtestingClient'; -import { createAbtestingClient, REGIONS as abtestingRegions } from '@algolia/client-abtesting/src/abtestingClient'; -import type { AnalyticsClient } from '@algolia/client-analytics'; -import { createAnalyticsClient, REGIONS as analyticsRegions } from '@algolia/client-analytics/src/analyticsClient'; -import type { Region as AnalyticsRegion } from '@algolia/client-analytics/src/analyticsClient'; +import type { AbtestingClient, Region as AbtestingRegion } from '@algolia/client-abtesting'; +import { abtestingClient } from '@algolia/client-abtesting'; +import type { AnalyticsClient, Region as AnalyticsRegion } from '@algolia/client-analytics'; +import { analyticsClient } from '@algolia/client-analytics'; +import type { ClientOptions } from '@algolia/client-common'; import { DEFAULT_CONNECT_TIMEOUT_BROWSER, DEFAULT_READ_TIMEOUT_BROWSER, @@ -14,16 +13,11 @@ import { createFallbackableCache, createMemoryCache, } from '@algolia/client-common'; -import type { ClientOptions, CreateClientOptions } from '@algolia/client-common'; -import type { PersonalizationClient } from '@algolia/client-personalization'; -import type { Region as PersonalizationRegion } from '@algolia/client-personalization/src/personalizationClient'; -import { - createPersonalizationClient, - REGIONS as personalizationRegions, -} from '@algolia/client-personalization/src/personalizationClient'; -import { createSearchClient, apiClientVersion as searchClientVersion } from '@algolia/client-search/src/searchClient'; +import type { PersonalizationClient, Region as PersonalizationRegion } from '@algolia/client-personalization'; +import { personalizationClient } from '@algolia/client-personalization'; +import { searchClient, apiClientVersion as searchClientVersion } from '@algolia/client-search'; import type { RecommendClient } from '@algolia/recommend'; -import { createRecommendClient } from '@algolia/recommend/src/recommendClient'; +import { recommendClient } from '@algolia/recommend'; import { createXhrRequester } from '@algolia/requester-browser-xhr'; import type { InitClientOptions, InitClientRegion } from './models'; @@ -46,83 +40,57 @@ export function algoliasearch(appId: string, apiKey: string, options?: ClientOpt if (!apiKey || typeof apiKey !== 'string') { throw new Error('`apiKey` is missing.'); } - const commonOptions: CreateClientOptions = { - apiKey, - appId, - timeouts: { - connect: DEFAULT_CONNECT_TIMEOUT_BROWSER, - read: DEFAULT_READ_TIMEOUT_BROWSER, - write: DEFAULT_WRITE_TIMEOUT_BROWSER, - }, - requester: createXhrRequester(), - algoliaAgents: [{ segment: 'Browser' }], - authMode: 'WithinQueryParameters', - responsesCache: createMemoryCache(), - requestsCache: createMemoryCache({ serializable: false }), - hostsCache: createFallbackableCache({ - caches: [createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }), createMemoryCache()], - }), - ...options, - }; function initRecommend(initOptions: InitClientOptions = {}): RecommendClient { - return createRecommendClient({ - ...commonOptions, - ...initOptions.options, - ...initOptions, - }); + return recommendClient(initOptions.appId || appId, initOptions.apiKey || apiKey, initOptions.options); } function initAnalytics(initOptions: InitClientOptions & InitClientRegion = {}): AnalyticsClient { - if ( - initOptions.region && - (typeof initOptions.region !== 'string' || !analyticsRegions.includes(initOptions.region)) - ) { - throw new Error(`\`region\` must be one of the following: ${analyticsRegions.join(', ')}`); - } - - return createAnalyticsClient({ - ...commonOptions, - ...initOptions.options, - ...initOptions, - }); + return analyticsClient( + initOptions.appId || appId, + initOptions.apiKey || apiKey, + initOptions.region, + initOptions.options, + ); } function initAbtesting(initOptions: InitClientOptions & InitClientRegion = {}): AbtestingClient { - if ( - initOptions.region && - (typeof initOptions.region !== 'string' || !abtestingRegions.includes(initOptions.region)) - ) { - throw new Error(`\`region\` must be one of the following: ${abtestingRegions.join(', ')}`); - } - - return createAbtestingClient({ - ...commonOptions, - ...initOptions.options, - ...initOptions, - }); + return abtestingClient( + initOptions.appId || appId, + initOptions.apiKey || apiKey, + initOptions.region, + initOptions.options, + ); } function initPersonalization( initOptions: InitClientOptions & Required>, ): PersonalizationClient { - if ( - !initOptions.region || - (initOptions.region && - (typeof initOptions.region !== 'string' || !personalizationRegions.includes(initOptions.region))) - ) { - throw new Error(`\`region\` is required and must be one of the following: ${personalizationRegions.join(', ')}`); - } - - return createPersonalizationClient({ - ...commonOptions, - ...initOptions.options, - ...initOptions, - }); + return personalizationClient( + initOptions.appId || appId, + initOptions.apiKey || apiKey, + initOptions.region, + initOptions.options, + ); } return { - ...createSearchClient(commonOptions), + ...searchClient(appId, apiKey, { + timeouts: { + connect: DEFAULT_CONNECT_TIMEOUT_BROWSER, + read: DEFAULT_READ_TIMEOUT_BROWSER, + write: DEFAULT_WRITE_TIMEOUT_BROWSER, + }, + requester: createXhrRequester(), + algoliaAgents: [{ segment: 'Browser' }], + authMode: 'WithinQueryParameters', + responsesCache: createMemoryCache(), + requestsCache: createMemoryCache({ serializable: false }), + hostsCache: createFallbackableCache({ + caches: [createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }), createMemoryCache()], + }), + ...options, + }), /** * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system. */ diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch/builds/node.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch/builds/node.ts index 57d5e07a48e..981a5320c03 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch/builds/node.ts +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch/builds/node.ts @@ -2,12 +2,11 @@ import { createHmac } from 'node:crypto'; -import type { AbtestingClient } from '@algolia/client-abtesting'; -import type { Region as AbtestingRegion } from '@algolia/client-abtesting/src/abtestingClient'; -import { createAbtestingClient, REGIONS as abtestingRegions } from '@algolia/client-abtesting/src/abtestingClient'; -import type { AnalyticsClient } from '@algolia/client-analytics'; -import { createAnalyticsClient, REGIONS as analyticsRegions } from '@algolia/client-analytics/src/analyticsClient'; -import type { Region as AnalyticsRegion } from '@algolia/client-analytics/src/analyticsClient'; +import type { AbtestingClient, Region as AbtestingRegion } from '@algolia/client-abtesting'; +import { abtestingClient } from '@algolia/client-abtesting'; +import type { AnalyticsClient, Region as AnalyticsRegion } from '@algolia/client-analytics'; +import { analyticsClient } from '@algolia/client-analytics'; +import type { ClientOptions } from '@algolia/client-common'; import { DEFAULT_CONNECT_TIMEOUT_NODE, DEFAULT_READ_TIMEOUT_NODE, @@ -16,16 +15,11 @@ import { createNullCache, serializeQueryParameters, } from '@algolia/client-common'; -import type { ClientOptions, CreateClientOptions } from '@algolia/client-common'; -import type { PersonalizationClient } from '@algolia/client-personalization'; -import type { Region as PersonalizationRegion } from '@algolia/client-personalization/src/personalizationClient'; -import { - createPersonalizationClient, - REGIONS as personalizationRegions, -} from '@algolia/client-personalization/src/personalizationClient'; -import { createSearchClient, apiClientVersion as searchClientVersion } from '@algolia/client-search/src/searchClient'; +import type { PersonalizationClient, Region as PersonalizationRegion } from '@algolia/client-personalization'; +import { personalizationClient } from '@algolia/client-personalization'; +import { searchClient, apiClientVersion as searchClientVersion } from '@algolia/client-search'; import type { RecommendClient } from '@algolia/recommend'; -import { createRecommendClient } from '@algolia/recommend/src/recommendClient'; +import { recommendClient } from '@algolia/recommend'; import { createHttpRequester } from '@algolia/requester-node-http'; import type { @@ -53,80 +47,54 @@ export function algoliasearch(appId: string, apiKey: string, options?: ClientOpt if (!apiKey || typeof apiKey !== 'string') { throw new Error('`apiKey` is missing.'); } - const commonOptions: CreateClientOptions = { - apiKey, - appId, - timeouts: { - connect: DEFAULT_CONNECT_TIMEOUT_NODE, - read: DEFAULT_READ_TIMEOUT_NODE, - write: DEFAULT_WRITE_TIMEOUT_NODE, - }, - requester: createHttpRequester(), - algoliaAgents: [{ segment: 'Node.js', version: process.versions.node }], - responsesCache: createNullCache(), - requestsCache: createNullCache(), - hostsCache: createMemoryCache(), - ...options, - }; function initRecommend(initOptions: InitClientOptions = {}): RecommendClient { - return createRecommendClient({ - ...commonOptions, - ...initOptions.options, - ...initOptions, - }); + return recommendClient(initOptions.appId || appId, initOptions.apiKey || apiKey, initOptions.options); } function initAnalytics(initOptions: InitClientOptions & InitClientRegion = {}): AnalyticsClient { - if ( - initOptions.region && - (typeof initOptions.region !== 'string' || !analyticsRegions.includes(initOptions.region)) - ) { - throw new Error(`\`region\` must be one of the following: ${analyticsRegions.join(', ')}`); - } - - return createAnalyticsClient({ - ...commonOptions, - ...initOptions.options, - ...initOptions, - }); + return analyticsClient( + initOptions.appId || appId, + initOptions.apiKey || apiKey, + initOptions.region, + initOptions.options, + ); } function initAbtesting(initOptions: InitClientOptions & InitClientRegion = {}): AbtestingClient { - if ( - initOptions.region && - (typeof initOptions.region !== 'string' || !abtestingRegions.includes(initOptions.region)) - ) { - throw new Error(`\`region\` must be one of the following: ${abtestingRegions.join(', ')}`); - } - - return createAbtestingClient({ - ...commonOptions, - ...initOptions.options, - ...initOptions, - }); + return abtestingClient( + initOptions.appId || appId, + initOptions.apiKey || apiKey, + initOptions.region, + initOptions.options, + ); } function initPersonalization( initOptions: InitClientOptions & Required>, ): PersonalizationClient { - if ( - !initOptions.region || - (initOptions.region && - (typeof initOptions.region !== 'string' || !personalizationRegions.includes(initOptions.region))) - ) { - throw new Error(`\`region\` is required and must be one of the following: ${personalizationRegions.join(', ')}`); - } - - return createPersonalizationClient({ - ...commonOptions, - ...initOptions.options, - ...initOptions, - }); + return personalizationClient( + initOptions.appId || appId, + initOptions.apiKey || apiKey, + initOptions.region, + initOptions.options, + ); } return { - ...createSearchClient(commonOptions), + ...searchClient(appId, apiKey, { + timeouts: { + connect: DEFAULT_CONNECT_TIMEOUT_NODE, + read: DEFAULT_READ_TIMEOUT_NODE, + write: DEFAULT_WRITE_TIMEOUT_NODE, + }, + requester: createHttpRequester(), + algoliaAgents: [{ segment: 'Node.js', version: process.versions.node }], + responsesCache: createNullCache(), + requestsCache: createNullCache(), + hostsCache: createMemoryCache(), + ...options, + }), /** * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system. */ diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch/package.json b/clients/algoliasearch-client-javascript/packages/algoliasearch/package.json index 749e7d32a04..fbff79d73e6 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch/package.json +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch/package.json @@ -11,7 +11,6 @@ "type": "module", "exports": { ".": { - "types": "./index.d.ts", "node": { "import": "./dist/algoliasearch.esm.node.js", "module": "./dist/algoliasearch.esm.node.js", @@ -19,7 +18,7 @@ "default": "./dist/algoliasearch.cjs", "types": "./dist/algoliasearch/builds/node.d.ts" }, - "default": { + "browser": { "umd": "./dist/algoliasearch.umd.js", "module": "./dist/algoliasearch.esm.browser.js", "import": "./dist/algoliasearch.esm.browser.js", @@ -28,7 +27,6 @@ } }, "./lite": { - "types": "./lite.d.ts", "node": { "import": "./dist/lite/lite.esm.node.js", "module": "./dist/lite/lite.esm.node.js", @@ -36,7 +34,7 @@ "default": "./dist/lite/lite.cjs", "types": "./dist/lite/builds/node.d.ts" }, - "default": { + "browser": { "umd": "./dist/lite/lite.umd.js", "module": "./dist/lite/lite.esm.browser.js", "import": "./dist/lite/lite.esm.browser.js", diff --git a/clients/algoliasearch-client-javascript/packages/client-abtesting/package.json b/clients/algoliasearch-client-javascript/packages/client-abtesting/package.json index b40254eb7ab..f388bfff61b 100644 --- a/clients/algoliasearch-client-javascript/packages/client-abtesting/package.json +++ b/clients/algoliasearch-client-javascript/packages/client-abtesting/package.json @@ -18,7 +18,7 @@ "default": "./dist/client-abtesting.cjs", "types": "./dist/builds/node.d.ts" }, - "default": { + "browser": { "umd": "./dist/client-abtesting.umd.js", "module": "./dist/client-abtesting.esm.browser.js", "import": "./dist/client-abtesting.esm.browser.js", diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/package.json b/clients/algoliasearch-client-javascript/packages/client-analytics/package.json index 787a409cd8c..d0d65fd9485 100644 --- a/clients/algoliasearch-client-javascript/packages/client-analytics/package.json +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/package.json @@ -18,7 +18,7 @@ "default": "./dist/client-analytics.cjs", "types": "./dist/builds/node.d.ts" }, - "default": { + "browser": { "umd": "./dist/client-analytics.umd.js", "module": "./dist/client-analytics.esm.browser.js", "import": "./dist/client-analytics.esm.browser.js", diff --git a/clients/algoliasearch-client-javascript/packages/client-insights/package.json b/clients/algoliasearch-client-javascript/packages/client-insights/package.json index b9375dd43a5..bbd0e3030cb 100644 --- a/clients/algoliasearch-client-javascript/packages/client-insights/package.json +++ b/clients/algoliasearch-client-javascript/packages/client-insights/package.json @@ -18,7 +18,7 @@ "default": "./dist/client-insights.cjs", "types": "./dist/builds/node.d.ts" }, - "default": { + "browser": { "umd": "./dist/client-insights.umd.js", "module": "./dist/client-insights.esm.browser.js", "import": "./dist/client-insights.esm.browser.js", diff --git a/clients/algoliasearch-client-javascript/packages/client-personalization/package.json b/clients/algoliasearch-client-javascript/packages/client-personalization/package.json index 74e0b18a495..22e1743ddde 100644 --- a/clients/algoliasearch-client-javascript/packages/client-personalization/package.json +++ b/clients/algoliasearch-client-javascript/packages/client-personalization/package.json @@ -18,7 +18,7 @@ "default": "./dist/client-personalization.cjs", "types": "./dist/builds/node.d.ts" }, - "default": { + "browser": { "umd": "./dist/client-personalization.umd.js", "module": "./dist/client-personalization.esm.browser.js", "import": "./dist/client-personalization.esm.browser.js", diff --git a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/package.json b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/package.json index 03996446284..bf4fc2837f9 100644 --- a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/package.json +++ b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/package.json @@ -18,7 +18,7 @@ "default": "./dist/client-query-suggestions.cjs", "types": "./dist/builds/node.d.ts" }, - "default": { + "browser": { "umd": "./dist/client-query-suggestions.umd.js", "module": "./dist/client-query-suggestions.esm.browser.js", "import": "./dist/client-query-suggestions.esm.browser.js", diff --git a/clients/algoliasearch-client-javascript/packages/client-search/package.json b/clients/algoliasearch-client-javascript/packages/client-search/package.json index 576458f4cb5..6b4e222782b 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/package.json +++ b/clients/algoliasearch-client-javascript/packages/client-search/package.json @@ -18,7 +18,7 @@ "default": "./dist/client-search.cjs", "types": "./dist/builds/node.d.ts" }, - "default": { + "browser": { "umd": "./dist/client-search.umd.js", "module": "./dist/client-search.esm.browser.js", "import": "./dist/client-search.esm.browser.js", diff --git a/clients/algoliasearch-client-javascript/packages/client-usage/package.json b/clients/algoliasearch-client-javascript/packages/client-usage/package.json index 0fc7539e76b..4922217a104 100644 --- a/clients/algoliasearch-client-javascript/packages/client-usage/package.json +++ b/clients/algoliasearch-client-javascript/packages/client-usage/package.json @@ -18,7 +18,7 @@ "default": "./dist/client-usage.cjs", "types": "./dist/builds/node.d.ts" }, - "default": { + "browser": { "umd": "./dist/client-usage.umd.js", "module": "./dist/client-usage.esm.browser.js", "import": "./dist/client-usage.esm.browser.js", diff --git a/clients/algoliasearch-client-javascript/packages/ingestion/package.json b/clients/algoliasearch-client-javascript/packages/ingestion/package.json index 86fb9d6c529..537f830091d 100644 --- a/clients/algoliasearch-client-javascript/packages/ingestion/package.json +++ b/clients/algoliasearch-client-javascript/packages/ingestion/package.json @@ -18,7 +18,7 @@ "default": "./dist/ingestion.cjs", "types": "./dist/builds/node.d.ts" }, - "default": { + "browser": { "umd": "./dist/ingestion.umd.js", "module": "./dist/ingestion.esm.browser.js", "import": "./dist/ingestion.esm.browser.js", diff --git a/clients/algoliasearch-client-javascript/packages/monitoring/package.json b/clients/algoliasearch-client-javascript/packages/monitoring/package.json index 5561dae38f0..6bc693faafc 100644 --- a/clients/algoliasearch-client-javascript/packages/monitoring/package.json +++ b/clients/algoliasearch-client-javascript/packages/monitoring/package.json @@ -18,7 +18,7 @@ "default": "./dist/monitoring.cjs", "types": "./dist/builds/node.d.ts" }, - "default": { + "browser": { "umd": "./dist/monitoring.umd.js", "module": "./dist/monitoring.esm.browser.js", "import": "./dist/monitoring.esm.browser.js", diff --git a/clients/algoliasearch-client-javascript/packages/recommend/package.json b/clients/algoliasearch-client-javascript/packages/recommend/package.json index a9cf98198e4..81a4604dda6 100644 --- a/clients/algoliasearch-client-javascript/packages/recommend/package.json +++ b/clients/algoliasearch-client-javascript/packages/recommend/package.json @@ -18,7 +18,7 @@ "default": "./dist/recommend.cjs", "types": "./dist/builds/node.d.ts" }, - "default": { + "browser": { "umd": "./dist/recommend.umd.js", "module": "./dist/recommend.esm.browser.js", "import": "./dist/recommend.esm.browser.js",