@algolia/client-personalization 5.20.3 → 5.20.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,11 +41,11 @@ All of our clients comes with type definition, and are available for both browse
41
41
  ### With a package manager
42
42
 
43
43
  ```bash
44
- yarn add @algolia/client-personalization@5.20.3
44
+ yarn add @algolia/client-personalization@5.20.4
45
45
  # or
46
- npm install @algolia/client-personalization@5.20.3
46
+ npm install @algolia/client-personalization@5.20.4
47
47
  # or
48
- pnpm add @algolia/client-personalization@5.20.3
48
+ pnpm add @algolia/client-personalization@5.20.4
49
49
  ```
50
50
 
51
51
  ### Without a package manager
@@ -53,7 +53,7 @@ pnpm add @algolia/client-personalization@5.20.3
53
53
  Add the following JavaScript snippet to the <head> of your website:
54
54
 
55
55
  ```html
56
- <script src="https://cdn.jsdelivr.net/npm/@algolia/client-personalization@5.20.3/dist/builds/browser.umd.js"></script>
56
+ <script src="https://cdn.jsdelivr.net/npm/@algolia/client-personalization@5.20.4/dist/builds/browser.umd.js"></script>
57
57
  ```
58
58
 
59
59
  ### Usage
package/dist/browser.d.ts CHANGED
@@ -164,7 +164,7 @@ type GetUserTokenProfileProps = {
164
164
  userToken: string;
165
165
  };
166
166
 
167
- declare const apiClientVersion = "5.20.3";
167
+ declare const apiClientVersion = "5.20.4";
168
168
  declare const REGIONS: readonly ["eu", "us"];
169
169
  type Region = (typeof REGIONS)[number];
170
170
  type RegionOptions = {
@@ -205,7 +205,7 @@ declare function createPersonalizationClient({ appId: appIdOption, apiKey: apiKe
205
205
  apiKey: string;
206
206
  }): void;
207
207
  /**
208
- * This method allow you to send requests to the Algolia REST API.
208
+ * This method lets you send requests to the Algolia REST API.
209
209
  * @param customDelete - The customDelete object.
210
210
  * @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
211
211
  * @param customDelete.parameters - Query parameters to apply to the current query.
@@ -213,7 +213,7 @@ declare function createPersonalizationClient({ appId: appIdOption, apiKey: apiKe
213
213
  */
214
214
  customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
215
215
  /**
216
- * This method allow you to send requests to the Algolia REST API.
216
+ * This method lets you send requests to the Algolia REST API.
217
217
  * @param customGet - The customGet object.
218
218
  * @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
219
219
  * @param customGet.parameters - Query parameters to apply to the current query.
@@ -221,7 +221,7 @@ declare function createPersonalizationClient({ appId: appIdOption, apiKey: apiKe
221
221
  */
222
222
  customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
223
223
  /**
224
- * This method allow you to send requests to the Algolia REST API.
224
+ * This method lets you send requests to the Algolia REST API.
225
225
  * @param customPost - The customPost object.
226
226
  * @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
227
227
  * @param customPost.parameters - Query parameters to apply to the current query.
@@ -230,7 +230,7 @@ declare function createPersonalizationClient({ appId: appIdOption, apiKey: apiKe
230
230
  */
231
231
  customPost({ path, parameters, body }: CustomPostProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
232
232
  /**
233
- * This method allow you to send requests to the Algolia REST API.
233
+ * This method lets you send requests to the Algolia REST API.
234
234
  * @param customPut - The customPut object.
235
235
  * @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
236
236
  * @param customPut.parameters - Query parameters to apply to the current query.
@@ -9,7 +9,7 @@ import {
9
9
 
10
10
  // src/personalizationClient.ts
11
11
  import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
12
- var apiClientVersion = "5.20.3";
12
+ var apiClientVersion = "5.20.4";
13
13
  var REGIONS = ["eu", "us"];
14
14
  function getDefaultHosts(region) {
15
15
  const url = "personalization.{region}.algolia.com".replace("{region}", region);
@@ -87,7 +87,7 @@ function createPersonalizationClient({
87
87
  }
88
88
  },
89
89
  /**
90
- * This method allow you to send requests to the Algolia REST API.
90
+ * This method lets you send requests to the Algolia REST API.
91
91
  * @param customDelete - The customDelete object.
92
92
  * @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
93
93
  * @param customDelete.parameters - Query parameters to apply to the current query.
@@ -109,7 +109,7 @@ function createPersonalizationClient({
109
109
  return transporter.request(request, requestOptions);
110
110
  },
111
111
  /**
112
- * This method allow you to send requests to the Algolia REST API.
112
+ * This method lets you send requests to the Algolia REST API.
113
113
  * @param customGet - The customGet object.
114
114
  * @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
115
115
  * @param customGet.parameters - Query parameters to apply to the current query.
@@ -131,7 +131,7 @@ function createPersonalizationClient({
131
131
  return transporter.request(request, requestOptions);
132
132
  },
133
133
  /**
134
- * This method allow you to send requests to the Algolia REST API.
134
+ * This method lets you send requests to the Algolia REST API.
135
135
  * @param customPost - The customPost object.
136
136
  * @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
137
137
  * @param customPost.parameters - Query parameters to apply to the current query.
@@ -155,7 +155,7 @@ function createPersonalizationClient({
155
155
  return transporter.request(request, requestOptions);
156
156
  },
157
157
  /**
158
- * This method allow you to send requests to the Algolia REST API.
158
+ * This method lets you send requests to the Algolia REST API.
159
159
  * @param customPut - The customPut object.
160
160
  * @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
161
161
  * @param customPut.parameters - Query parameters to apply to the current query.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../builds/browser.ts","../../src/personalizationClient.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\nimport { createXhrRequester } from '@algolia/requester-browser-xhr';\n\nimport {\n createBrowserLocalStorageCache,\n createFallbackableCache,\n createMemoryCache,\n createNullLogger,\n} from '@algolia/client-common';\n\nimport type { ClientOptions } from '@algolia/client-common';\n\nimport { apiClientVersion, createPersonalizationClient } from '../src/personalizationClient';\n\nimport type { Region } from '../src/personalizationClient';\nimport { REGIONS } from '../src/personalizationClient';\n\nexport type { Region, RegionOptions } from '../src/personalizationClient';\n\nexport { apiClientVersion } from '../src/personalizationClient';\n\nexport * from '../model';\n\nexport function personalizationClient(\n appId: string,\n apiKey: string,\n region: Region,\n options?: ClientOptions,\n): PersonalizationClient {\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 if (!region || (region && (typeof region !== 'string' || !REGIONS.includes(region)))) {\n throw new Error(`\\`region\\` is required and must be one of the following: ${REGIONS.join(', ')}`);\n }\n\n return createPersonalizationClient({\n appId,\n apiKey,\n region,\n timeouts: {\n connect: 1000,\n read: 2000,\n write: 30000,\n },\n logger: createNullLogger(),\n requester: createXhrRequester(),\n algoliaAgents: [{ segment: 'Browser' }],\n authMode: 'WithinQueryParameters',\n responsesCache: createMemoryCache(),\n requestsCache: createMemoryCache({ serializable: false }),\n hostsCache: createFallbackableCache({\n caches: [createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }), createMemoryCache()],\n }),\n ...options,\n });\n}\n\nexport type PersonalizationClient = ReturnType<typeof createPersonalizationClient>;\n","// 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\nimport type {\n CreateClientOptions,\n Headers,\n Host,\n QueryParameters,\n Request,\n RequestOptions,\n} from '@algolia/client-common';\nimport { createAuth, createTransporter, getAlgoliaAgent } from '@algolia/client-common';\n\nimport type { DeleteUserProfileResponse } from '../model/deleteUserProfileResponse';\n\nimport type { GetUserTokenResponse } from '../model/getUserTokenResponse';\nimport type { PersonalizationStrategyParams } from '../model/personalizationStrategyParams';\nimport type { SetPersonalizationStrategyResponse } from '../model/setPersonalizationStrategyResponse';\n\nimport type {\n CustomDeleteProps,\n CustomGetProps,\n CustomPostProps,\n CustomPutProps,\n DeleteUserProfileProps,\n GetUserTokenProfileProps,\n} from '../model/clientMethodProps';\n\nexport const apiClientVersion = '5.20.3';\n\nexport const REGIONS = ['eu', 'us'] as const;\nexport type Region = (typeof REGIONS)[number];\nexport type RegionOptions = { region: Region };\n\nfunction getDefaultHosts(region: Region): Host[] {\n const url = 'personalization.{region}.algolia.com'.replace('{region}', region);\n\n return [{ url, accept: 'readWrite', protocol: 'https' }];\n}\n\nexport function createPersonalizationClient({\n appId: appIdOption,\n apiKey: apiKeyOption,\n authMode,\n algoliaAgents,\n region: regionOption,\n ...options\n}: CreateClientOptions & RegionOptions) {\n const auth = createAuth(appIdOption, apiKeyOption, authMode);\n const transporter = createTransporter({\n hosts: getDefaultHosts(regionOption),\n ...options,\n algoliaAgent: getAlgoliaAgent({\n algoliaAgents,\n client: 'Personalization',\n version: apiClientVersion,\n }),\n baseHeaders: {\n 'content-type': 'text/plain',\n ...auth.headers(),\n ...options.baseHeaders,\n },\n baseQueryParameters: {\n ...auth.queryParameters(),\n ...options.baseQueryParameters,\n },\n });\n\n return {\n transporter,\n\n /**\n * The `appId` currently in use.\n */\n appId: appIdOption,\n\n /**\n * The `apiKey` currently in use.\n */\n apiKey: apiKeyOption,\n\n /**\n * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.\n */\n clearCache(): Promise<void> {\n return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => undefined);\n },\n\n /**\n * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.\n */\n get _ua(): string {\n return transporter.algoliaAgent.value;\n },\n\n /**\n * Adds a `segment` to the `x-algolia-agent` sent with every requests.\n *\n * @param segment - The algolia agent (user-agent) segment to add.\n * @param version - The version of the agent.\n */\n addAlgoliaAgent(segment: string, version?: string): void {\n transporter.algoliaAgent.add({ segment, version });\n },\n\n /**\n * Helper method to switch the API key used to authenticate the requests.\n *\n * @param params - Method params.\n * @param params.apiKey - The new API Key to use.\n */\n setClientApiKey({ apiKey }: { apiKey: string }): void {\n if (!authMode || authMode === 'WithinHeaders') {\n transporter.baseHeaders['x-algolia-api-key'] = apiKey;\n } else {\n transporter.baseQueryParameters['x-algolia-api-key'] = apiKey;\n }\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n * @param customDelete - The customDelete object.\n * @param customDelete.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customDelete.parameters - Query parameters to apply to the current query.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customDelete(\n { path, parameters }: CustomDeleteProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customDelete`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'DELETE',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n * @param customGet - The customGet object.\n * @param customGet.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customGet.parameters - Query parameters to apply to the current query.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customGet`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'GET',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n * @param customPost - The customPost object.\n * @param customPost.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customPost.parameters - Query parameters to apply to the current query.\n * @param customPost.body - Parameters to send with the custom request.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customPost(\n { path, parameters, body }: CustomPostProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customPost`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'POST',\n path: requestPath,\n queryParameters,\n headers,\n data: body ? body : {},\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n * @param customPut - The customPut object.\n * @param customPut.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customPut.parameters - Query parameters to apply to the current query.\n * @param customPut.body - Parameters to send with the custom request.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customPut(\n { path, parameters, body }: CustomPutProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customPut`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'PUT',\n path: requestPath,\n queryParameters,\n headers,\n data: body ? body : {},\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * Deletes a user profile. The response includes a date and time when the user profile can safely be considered deleted.\n *\n * Required API Key ACLs:\n * - recommendation\n * @param deleteUserProfile - The deleteUserProfile object.\n * @param deleteUserProfile.userToken - Unique identifier representing a user for which to fetch the personalization profile.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n deleteUserProfile(\n { userToken }: DeleteUserProfileProps,\n requestOptions?: RequestOptions,\n ): Promise<DeleteUserProfileResponse> {\n if (!userToken) {\n throw new Error('Parameter `userToken` is required when calling `deleteUserProfile`.');\n }\n\n const requestPath = '/1/profiles/{userToken}'.replace('{userToken}', encodeURIComponent(userToken));\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'DELETE',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * Retrieves the current personalization strategy.\n *\n * Required API Key ACLs:\n * - recommendation\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n getPersonalizationStrategy(requestOptions?: RequestOptions): Promise<PersonalizationStrategyParams> {\n const requestPath = '/1/strategies/personalization';\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'GET',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * Retrieves a user profile and their affinities for different facets.\n *\n * Required API Key ACLs:\n * - recommendation\n * @param getUserTokenProfile - The getUserTokenProfile object.\n * @param getUserTokenProfile.userToken - Unique identifier representing a user for which to fetch the personalization profile.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n getUserTokenProfile(\n { userToken }: GetUserTokenProfileProps,\n requestOptions?: RequestOptions,\n ): Promise<GetUserTokenResponse> {\n if (!userToken) {\n throw new Error('Parameter `userToken` is required when calling `getUserTokenProfile`.');\n }\n\n const requestPath = '/1/profiles/personalization/{userToken}'.replace(\n '{userToken}',\n encodeURIComponent(userToken),\n );\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'GET',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * Creates a new personalization strategy.\n *\n * Required API Key ACLs:\n * - recommendation\n * @param personalizationStrategyParams - The personalizationStrategyParams object.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n setPersonalizationStrategy(\n personalizationStrategyParams: PersonalizationStrategyParams,\n requestOptions?: RequestOptions,\n ): Promise<SetPersonalizationStrategyResponse> {\n if (!personalizationStrategyParams) {\n throw new Error(\n 'Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.',\n );\n }\n\n if (!personalizationStrategyParams.eventsScoring) {\n throw new Error(\n 'Parameter `personalizationStrategyParams.eventsScoring` is required when calling `setPersonalizationStrategy`.',\n );\n }\n if (!personalizationStrategyParams.facetsScoring) {\n throw new Error(\n 'Parameter `personalizationStrategyParams.facetsScoring` is required when calling `setPersonalizationStrategy`.',\n );\n }\n if (!personalizationStrategyParams.personalizationImpact) {\n throw new Error(\n 'Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`.',\n );\n }\n\n const requestPath = '/1/strategies/personalization';\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'POST',\n path: requestPath,\n queryParameters,\n headers,\n data: personalizationStrategyParams,\n };\n\n return transporter.request(request, requestOptions);\n },\n };\n}\n"],"mappings":";AAEA,SAAS,0BAA0B;AAEnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACCP,SAAS,YAAY,mBAAmB,uBAAuB;AAiBxD,IAAM,mBAAmB;AAEzB,IAAM,UAAU,CAAC,MAAM,IAAI;AAIlC,SAAS,gBAAgB,QAAwB;AAC/C,QAAM,MAAM,uCAAuC,QAAQ,YAAY,MAAM;AAE7E,SAAO,CAAC,EAAE,KAAK,QAAQ,aAAa,UAAU,QAAQ,CAAC;AACzD;AAEO,SAAS,4BAA4B;AAAA,EAC1C,OAAO;AAAA,EACP,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,GAAG;AACL,GAAwC;AACtC,QAAM,OAAO,WAAW,aAAa,cAAc,QAAQ;AAC3D,QAAM,cAAc,kBAAkB;AAAA,IACpC,OAAO,gBAAgB,YAAY;AAAA,IACnC,GAAG;AAAA,IACH,cAAc,gBAAgB;AAAA,MAC5B;AAAA,MACA,QAAQ;AAAA,MACR,SAAS;AAAA,IACX,CAAC;AAAA,IACD,aAAa;AAAA,MACX,gBAAgB;AAAA,MAChB,GAAG,KAAK,QAAQ;AAAA,MAChB,GAAG,QAAQ;AAAA,IACb;AAAA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AAgB,kBAAkB;AAAA,IAClC,eAAe,kBAAkB,EAAE,cAAc,MAAM,CAAC;AAAA,IACxD,YAAY,wBAAwB;AAAA,MAClC,QAAQ,CAAC,+BAA+B,EAAE,KAAK,GAAG,gBAAgB,IAAI,KAAK,GAAG,CAAC,GAAG,kBAAkB,CAAC;AAAA,IACvG,CAAC;AAAA,IACD,GAAG;AAAA,EACL,CAAC;AACH;","names":[]}
1
+ {"version":3,"sources":["../../builds/browser.ts","../../src/personalizationClient.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\nimport { createXhrRequester } from '@algolia/requester-browser-xhr';\n\nimport {\n createBrowserLocalStorageCache,\n createFallbackableCache,\n createMemoryCache,\n createNullLogger,\n} from '@algolia/client-common';\n\nimport type { ClientOptions } from '@algolia/client-common';\n\nimport { apiClientVersion, createPersonalizationClient } from '../src/personalizationClient';\n\nimport type { Region } from '../src/personalizationClient';\nimport { REGIONS } from '../src/personalizationClient';\n\nexport type { Region, RegionOptions } from '../src/personalizationClient';\n\nexport { apiClientVersion } from '../src/personalizationClient';\n\nexport * from '../model';\n\nexport function personalizationClient(\n appId: string,\n apiKey: string,\n region: Region,\n options?: ClientOptions,\n): PersonalizationClient {\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 if (!region || (region && (typeof region !== 'string' || !REGIONS.includes(region)))) {\n throw new Error(`\\`region\\` is required and must be one of the following: ${REGIONS.join(', ')}`);\n }\n\n return createPersonalizationClient({\n appId,\n apiKey,\n region,\n timeouts: {\n connect: 1000,\n read: 2000,\n write: 30000,\n },\n logger: createNullLogger(),\n requester: createXhrRequester(),\n algoliaAgents: [{ segment: 'Browser' }],\n authMode: 'WithinQueryParameters',\n responsesCache: createMemoryCache(),\n requestsCache: createMemoryCache({ serializable: false }),\n hostsCache: createFallbackableCache({\n caches: [createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }), createMemoryCache()],\n }),\n ...options,\n });\n}\n\nexport type PersonalizationClient = ReturnType<typeof createPersonalizationClient>;\n","// 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\nimport type {\n CreateClientOptions,\n Headers,\n Host,\n QueryParameters,\n Request,\n RequestOptions,\n} from '@algolia/client-common';\nimport { createAuth, createTransporter, getAlgoliaAgent } from '@algolia/client-common';\n\nimport type { DeleteUserProfileResponse } from '../model/deleteUserProfileResponse';\n\nimport type { GetUserTokenResponse } from '../model/getUserTokenResponse';\nimport type { PersonalizationStrategyParams } from '../model/personalizationStrategyParams';\nimport type { SetPersonalizationStrategyResponse } from '../model/setPersonalizationStrategyResponse';\n\nimport type {\n CustomDeleteProps,\n CustomGetProps,\n CustomPostProps,\n CustomPutProps,\n DeleteUserProfileProps,\n GetUserTokenProfileProps,\n} from '../model/clientMethodProps';\n\nexport const apiClientVersion = '5.20.4';\n\nexport const REGIONS = ['eu', 'us'] as const;\nexport type Region = (typeof REGIONS)[number];\nexport type RegionOptions = { region: Region };\n\nfunction getDefaultHosts(region: Region): Host[] {\n const url = 'personalization.{region}.algolia.com'.replace('{region}', region);\n\n return [{ url, accept: 'readWrite', protocol: 'https' }];\n}\n\nexport function createPersonalizationClient({\n appId: appIdOption,\n apiKey: apiKeyOption,\n authMode,\n algoliaAgents,\n region: regionOption,\n ...options\n}: CreateClientOptions & RegionOptions) {\n const auth = createAuth(appIdOption, apiKeyOption, authMode);\n const transporter = createTransporter({\n hosts: getDefaultHosts(regionOption),\n ...options,\n algoliaAgent: getAlgoliaAgent({\n algoliaAgents,\n client: 'Personalization',\n version: apiClientVersion,\n }),\n baseHeaders: {\n 'content-type': 'text/plain',\n ...auth.headers(),\n ...options.baseHeaders,\n },\n baseQueryParameters: {\n ...auth.queryParameters(),\n ...options.baseQueryParameters,\n },\n });\n\n return {\n transporter,\n\n /**\n * The `appId` currently in use.\n */\n appId: appIdOption,\n\n /**\n * The `apiKey` currently in use.\n */\n apiKey: apiKeyOption,\n\n /**\n * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.\n */\n clearCache(): Promise<void> {\n return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => undefined);\n },\n\n /**\n * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.\n */\n get _ua(): string {\n return transporter.algoliaAgent.value;\n },\n\n /**\n * Adds a `segment` to the `x-algolia-agent` sent with every requests.\n *\n * @param segment - The algolia agent (user-agent) segment to add.\n * @param version - The version of the agent.\n */\n addAlgoliaAgent(segment: string, version?: string): void {\n transporter.algoliaAgent.add({ segment, version });\n },\n\n /**\n * Helper method to switch the API key used to authenticate the requests.\n *\n * @param params - Method params.\n * @param params.apiKey - The new API Key to use.\n */\n setClientApiKey({ apiKey }: { apiKey: string }): void {\n if (!authMode || authMode === 'WithinHeaders') {\n transporter.baseHeaders['x-algolia-api-key'] = apiKey;\n } else {\n transporter.baseQueryParameters['x-algolia-api-key'] = apiKey;\n }\n },\n\n /**\n * This method lets you send requests to the Algolia REST API.\n * @param customDelete - The customDelete object.\n * @param customDelete.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customDelete.parameters - Query parameters to apply to the current query.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customDelete(\n { path, parameters }: CustomDeleteProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customDelete`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'DELETE',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method lets you send requests to the Algolia REST API.\n * @param customGet - The customGet object.\n * @param customGet.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customGet.parameters - Query parameters to apply to the current query.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customGet`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'GET',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method lets you send requests to the Algolia REST API.\n * @param customPost - The customPost object.\n * @param customPost.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customPost.parameters - Query parameters to apply to the current query.\n * @param customPost.body - Parameters to send with the custom request.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customPost(\n { path, parameters, body }: CustomPostProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customPost`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'POST',\n path: requestPath,\n queryParameters,\n headers,\n data: body ? body : {},\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method lets you send requests to the Algolia REST API.\n * @param customPut - The customPut object.\n * @param customPut.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customPut.parameters - Query parameters to apply to the current query.\n * @param customPut.body - Parameters to send with the custom request.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customPut(\n { path, parameters, body }: CustomPutProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customPut`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'PUT',\n path: requestPath,\n queryParameters,\n headers,\n data: body ? body : {},\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * Deletes a user profile. The response includes a date and time when the user profile can safely be considered deleted.\n *\n * Required API Key ACLs:\n * - recommendation\n * @param deleteUserProfile - The deleteUserProfile object.\n * @param deleteUserProfile.userToken - Unique identifier representing a user for which to fetch the personalization profile.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n deleteUserProfile(\n { userToken }: DeleteUserProfileProps,\n requestOptions?: RequestOptions,\n ): Promise<DeleteUserProfileResponse> {\n if (!userToken) {\n throw new Error('Parameter `userToken` is required when calling `deleteUserProfile`.');\n }\n\n const requestPath = '/1/profiles/{userToken}'.replace('{userToken}', encodeURIComponent(userToken));\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'DELETE',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * Retrieves the current personalization strategy.\n *\n * Required API Key ACLs:\n * - recommendation\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n getPersonalizationStrategy(requestOptions?: RequestOptions): Promise<PersonalizationStrategyParams> {\n const requestPath = '/1/strategies/personalization';\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'GET',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * Retrieves a user profile and their affinities for different facets.\n *\n * Required API Key ACLs:\n * - recommendation\n * @param getUserTokenProfile - The getUserTokenProfile object.\n * @param getUserTokenProfile.userToken - Unique identifier representing a user for which to fetch the personalization profile.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n getUserTokenProfile(\n { userToken }: GetUserTokenProfileProps,\n requestOptions?: RequestOptions,\n ): Promise<GetUserTokenResponse> {\n if (!userToken) {\n throw new Error('Parameter `userToken` is required when calling `getUserTokenProfile`.');\n }\n\n const requestPath = '/1/profiles/personalization/{userToken}'.replace(\n '{userToken}',\n encodeURIComponent(userToken),\n );\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'GET',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * Creates a new personalization strategy.\n *\n * Required API Key ACLs:\n * - recommendation\n * @param personalizationStrategyParams - The personalizationStrategyParams object.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n setPersonalizationStrategy(\n personalizationStrategyParams: PersonalizationStrategyParams,\n requestOptions?: RequestOptions,\n ): Promise<SetPersonalizationStrategyResponse> {\n if (!personalizationStrategyParams) {\n throw new Error(\n 'Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.',\n );\n }\n\n if (!personalizationStrategyParams.eventsScoring) {\n throw new Error(\n 'Parameter `personalizationStrategyParams.eventsScoring` is required when calling `setPersonalizationStrategy`.',\n );\n }\n if (!personalizationStrategyParams.facetsScoring) {\n throw new Error(\n 'Parameter `personalizationStrategyParams.facetsScoring` is required when calling `setPersonalizationStrategy`.',\n );\n }\n if (!personalizationStrategyParams.personalizationImpact) {\n throw new Error(\n 'Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`.',\n );\n }\n\n const requestPath = '/1/strategies/personalization';\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'POST',\n path: requestPath,\n queryParameters,\n headers,\n data: personalizationStrategyParams,\n };\n\n return transporter.request(request, requestOptions);\n },\n };\n}\n"],"mappings":";AAEA,SAAS,0BAA0B;AAEnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACCP,SAAS,YAAY,mBAAmB,uBAAuB;AAiBxD,IAAM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F;;;AD3VO,SAAS,sBACd,OACA,QACA,QACA,SACuB;AACvB,MAAI,CAAC,SAAS,OAAO,UAAU,UAAU;AACvC,UAAM,IAAI,MAAM,qBAAqB;AAAA,EACvC;AAEA,MAAI,CAAC,UAAU,OAAO,WAAW,UAAU;AACzC,UAAM,IAAI,MAAM,sBAAsB;AAAA,EACxC;AAEA,MAAI,CAAC,UAAW,WAAW,OAAO,WAAW,YAAY,CAAC,QAAQ,SAAS,MAAM,IAAK;AACpF,UAAM,IAAI,MAAM,4DAA4D,QAAQ,KAAK,IAAI,CAAC,EAAE;AAAA,EAClG;AAEA,SAAO,4BAA4B;AAAA,IACjC;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,MACR,SAAS;AAAA,MACT,MAAM;AAAA,MACN,OAAO;AAAA,IACT;AAAA,IACA,QAAQ,iBAAiB;AAAA,IACzB,WAAW,mBAAmB;AAAA,IAC9B,eAAe,CAAC,EAAE,SAAS,UAAU,CAAC;AAAA,IACtC,UAAU;AAAA,IACV,gBAAgB,kBAAkB;AAAA,IAClC,eAAe,kBAAkB,EAAE,cAAc,MAAM,CAAC;AAAA,IACxD,YAAY,wBAAwB;AAAA,MAClC,QAAQ,CAAC,+BAA+B,EAAE,KAAK,GAAG,gBAAgB,IAAI,KAAK,GAAG,CAAC,GAAG,kBAAkB,CAAC;AAAA,IACvG,CAAC;AAAA,IACD,GAAG;AAAA,EACL,CAAC;AACH;","names":[]}
@@ -1,2 +1,2 @@
1
- function H(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(n=>t.setRequestHeader(n,e.headers[n]));let a=(n,s)=>setTimeout(()=>{t.abort(),o({status:0,content:s,isTimedOut:!0})},n),m=a(e.connectTimeout,"Connection timeout"),h;t.onreadystatechange=()=>{t.readyState>t.OPENED&&h===void 0&&(clearTimeout(m),h=a(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(m),clearTimeout(h),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(m),clearTimeout(h),o({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}function j(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function a(){return JSON.parse(t().getItem(o)||"{}")}function m(n){t().setItem(o,JSON.stringify(n))}function h(){let n=r.timeToLive?r.timeToLive*1e3:null,s=a(),i=Object.fromEntries(Object.entries(s).filter(([,d])=>d.timestamp!==void 0));if(m(i),!n)return;let u=Object.fromEntries(Object.entries(i).filter(([,d])=>{let P=new Date().getTime();return!(d.timestamp+n<P)}));m(u)}return{get(n,s,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(h(),a()[JSON.stringify(n)])).then(u=>Promise.all([u?u.value:s(),u!==void 0])).then(([u,d])=>Promise.all([u,d||i.miss(u)])).then(([u])=>u)},set(n,s){return Promise.resolve().then(()=>{let i=a();return i[JSON.stringify(n)]={timestamp:new Date().getTime(),value:s},t().setItem(o,JSON.stringify(i)),s})},delete(n){return Promise.resolve().then(()=>{let s=a();delete s[JSON.stringify(n)],t().setItem(o,JSON.stringify(s))})},clear(){return Promise.resolve().then(()=>{t().removeItem(o)})}}}function V(){return{get(r,e,o={miss:()=>Promise.resolve()}){return e().then(a=>Promise.all([a,o.miss(a)])).then(([a])=>a)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function q(r){let e=[...r.caches],o=e.shift();return o===void 0?V():{get(t,a,m={miss:()=>Promise.resolve()}){return o.get(t,a,m).catch(()=>q({caches:e}).get(t,a,m))},set(t,a){return o.set(t,a).catch(()=>q({caches:e}).set(t,a))},delete(t){return o.delete(t).catch(()=>q({caches:e}).delete(t))},clear(){return o.clear().catch(()=>q({caches:e}).clear())}}}function O(r={serializable:!0}){let e={};return{get(o,t,a={miss:()=>Promise.resolve()}){let m=JSON.stringify(o);if(m in e)return Promise.resolve(r.serializable?JSON.parse(e[m]):e[m]);let h=t();return h.then(n=>a.miss(n)).then(()=>h)},set(o,t){return e[JSON.stringify(o)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(o){return delete e[JSON.stringify(o)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}function Y(r){let e={value:`Algolia for JavaScript (${r})`,add(o){let t=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function G(r,e,o="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return{headers(){return o==="WithinHeaders"?t:{}},queryParameters(){return o==="WithinQueryParameters"?t:{}}}}function W({algoliaAgents:r,client:e,version:o}){let t=Y(o).add({segment:e,version:o});return r.forEach(a=>t.add(a)),t}function J(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var L=2*60*1e3;function $(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>L}function a(){return e==="timed out"&&Date.now()-o<=L}return{...r,status:e,lastUpdate:o,isUp:t,isTimedOut:a}}var Q=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}},M=class extends Q{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e}},Z=class extends M{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",r,"RetryError")}},z=class extends M{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e}},ee=class extends Q{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},re=class extends z{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o}};function te(r,e,o){let t=oe(o),a=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(a+=`?${t}`),a}function oe(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replace(/\+/g,"%20")}`).join("&")}function se(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let o=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(o)}function ae(r,e,o){let t={Accept:"application/json",...r,...e,...o},a={};return Object.keys(t).forEach(m=>{let h=t[m];a[m.toLowerCase()]=h}),a}function ne(r){try{return JSON.parse(r.content)}catch(e){throw new ee(e.message,r)}}function ie({content:r,status:e},o){try{let t=JSON.parse(r);return"error"in t?new re(t.message,e,t.error,o):new z(t.message,e,o)}catch{}return new z(r,e,o)}function ce({isTimedOut:r,status:e}){return!r&&~~e===0}function ue({isTimedOut:r,status:e}){return r||ce({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:r}){return~~(r/100)===2}function me(r){return r.map(e=>F(e))}function F(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function B({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:a,algoliaAgent:m,timeouts:h,requester:n,requestsCache:s,responsesCache:i}){async function u(c){let l=await Promise.all(c.map(p=>e.get(p,()=>Promise.resolve($(p))))),g=l.filter(p=>p.isUp()),y=l.filter(p=>p.isTimedOut()),R=[...g,...y];return{hosts:R.length>0?R:c,getTimeout(p,E){return(y.length===0&&p===0?1:y.length+3+p)*E}}}async function d(c,l,g=!0){let y=[],R=se(c,l),T=ae(o,c.headers,l.headers),p=c.method==="GET"?{...c.data,...l.data}:{},E={...a,...c.queryParameters,...p};if(m.value&&(E["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let f of Object.keys(l.queryParameters))!l.queryParameters[f]||Object.prototype.toString.call(l.queryParameters[f])==="[object Object]"?E[f]=l.queryParameters[f]:E[f]=l.queryParameters[f].toString();let S=0,U=async(f,C)=>{let v=f.pop();if(v===void 0)throw new Z(me(y));let b={...h,...l.timeouts},D={data:R,headers:T,method:c.method,url:te(v,c.path,E),connectTimeout:C(S,b.connect),responseTimeout:C(S,g?b.read:b.write)},_=x=>{let I={request:D,response:x,host:v,triesLeft:f.length};return y.push(I),I},w=await n.send(D);if(ue(w)){let x=_(w);return w.isTimedOut&&S++,t.info("Retryable failure",F(x)),await e.set(v,$(v,w.isTimedOut?"timed out":"down")),U(f,C)}if(le(w))return ne(w);throw _(w),ie(w,y)},K=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),k=await u(K);return U([...k.hosts].reverse(),k.getTimeout)}function P(c,l={}){let g=c.useReadTransporter||c.method==="GET";if(!g)return d(c,l,g);let y=()=>d(c,l);if((l.cacheable||c.cacheable)!==!0)return y();let T={request:c,requestOptions:l,transporter:{queryParameters:a,headers:o}};return i.get(T,()=>s.get(T,()=>s.set(T,y()).then(p=>Promise.all([s.delete(T),p]),p=>Promise.all([s.delete(T),Promise.reject(p)])).then(([p,E])=>E)),{miss:p=>i.set(T,p)})}return{hostsCache:e,requester:n,timeouts:h,logger:t,algoliaAgent:m,baseHeaders:o,baseQueryParameters:a,hosts:r,request:P,requestsCache:s,responsesCache:i}}var A="5.20.3",N=["eu","us"];function de(r){return[{url:"personalization.{region}.algolia.com".replace("{region}",r),accept:"readWrite",protocol:"https"}]}function X({appId:r,apiKey:e,authMode:o,algoliaAgents:t,region:a,...m}){let h=G(r,e,o),n=B({hosts:de(a),...m,algoliaAgent:W({algoliaAgents:t,client:"Personalization",version:A}),baseHeaders:{"content-type":"text/plain",...h.headers(),...m.baseHeaders},baseQueryParameters:{...h.queryParameters(),...m.baseQueryParameters}});return{transporter:n,appId:r,apiKey:e,clearCache(){return Promise.all([n.requestsCache.clear(),n.responsesCache.clear()]).then(()=>{})},get _ua(){return n.algoliaAgent.value},addAlgoliaAgent(s,i){n.algoliaAgent.add({segment:s,version:i})},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?n.baseHeaders["x-algolia-api-key"]=s:n.baseQueryParameters["x-algolia-api-key"]=s},customDelete({path:s,parameters:i},u){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return n.request(l,u)},customGet({path:s,parameters:i},u){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return n.request(l,u)},customPost({path:s,parameters:i,body:u},d){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:u||{}};return n.request(g,d)},customPut({path:s,parameters:i,body:u},d){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:u||{}};return n.request(g,d)},deleteUserProfile({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `deleteUserProfile`.");let c={method:"DELETE",path:"/1/profiles/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return n.request(c,i)},getPersonalizationStrategy(s){let P={method:"GET",path:"/1/strategies/personalization",queryParameters:{},headers:{}};return n.request(P,s)},getUserTokenProfile({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `getUserTokenProfile`.");let c={method:"GET",path:"/1/profiles/personalization/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return n.request(c,i)},setPersonalizationStrategy(s,i){if(!s)throw new Error("Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.");if(!s.eventsScoring)throw new Error("Parameter `personalizationStrategyParams.eventsScoring` is required when calling `setPersonalizationStrategy`.");if(!s.facetsScoring)throw new Error("Parameter `personalizationStrategyParams.facetsScoring` is required when calling `setPersonalizationStrategy`.");if(!s.personalizationImpact)throw new Error("Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`.");let c={method:"POST",path:"/1/strategies/personalization",queryParameters:{},headers:{},data:s};return n.request(c,i)}}}function _e(r,e,o,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(!o||o&&(typeof o!="string"||!N.includes(o)))throw new Error(`\`region\` is required and must be one of the following: ${N.join(", ")}`);return X({appId:r,apiKey:e,region:o,timeouts:{connect:1e3,read:2e3,write:3e4},logger:J(),requester:H(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:q({caches:[j({key:`${A}-${r}`}),O()]}),...t})}export{A as apiClientVersion,_e as personalizationClient};
1
+ function H(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(n=>t.setRequestHeader(n,e.headers[n]));let a=(n,s)=>setTimeout(()=>{t.abort(),o({status:0,content:s,isTimedOut:!0})},n),m=a(e.connectTimeout,"Connection timeout"),h;t.onreadystatechange=()=>{t.readyState>t.OPENED&&h===void 0&&(clearTimeout(m),h=a(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(m),clearTimeout(h),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(m),clearTimeout(h),o({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}function j(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function a(){return JSON.parse(t().getItem(o)||"{}")}function m(n){t().setItem(o,JSON.stringify(n))}function h(){let n=r.timeToLive?r.timeToLive*1e3:null,s=a(),i=Object.fromEntries(Object.entries(s).filter(([,d])=>d.timestamp!==void 0));if(m(i),!n)return;let u=Object.fromEntries(Object.entries(i).filter(([,d])=>{let P=new Date().getTime();return!(d.timestamp+n<P)}));m(u)}return{get(n,s,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(h(),a()[JSON.stringify(n)])).then(u=>Promise.all([u?u.value:s(),u!==void 0])).then(([u,d])=>Promise.all([u,d||i.miss(u)])).then(([u])=>u)},set(n,s){return Promise.resolve().then(()=>{let i=a();return i[JSON.stringify(n)]={timestamp:new Date().getTime(),value:s},t().setItem(o,JSON.stringify(i)),s})},delete(n){return Promise.resolve().then(()=>{let s=a();delete s[JSON.stringify(n)],t().setItem(o,JSON.stringify(s))})},clear(){return Promise.resolve().then(()=>{t().removeItem(o)})}}}function V(){return{get(r,e,o={miss:()=>Promise.resolve()}){return e().then(a=>Promise.all([a,o.miss(a)])).then(([a])=>a)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function q(r){let e=[...r.caches],o=e.shift();return o===void 0?V():{get(t,a,m={miss:()=>Promise.resolve()}){return o.get(t,a,m).catch(()=>q({caches:e}).get(t,a,m))},set(t,a){return o.set(t,a).catch(()=>q({caches:e}).set(t,a))},delete(t){return o.delete(t).catch(()=>q({caches:e}).delete(t))},clear(){return o.clear().catch(()=>q({caches:e}).clear())}}}function O(r={serializable:!0}){let e={};return{get(o,t,a={miss:()=>Promise.resolve()}){let m=JSON.stringify(o);if(m in e)return Promise.resolve(r.serializable?JSON.parse(e[m]):e[m]);let h=t();return h.then(n=>a.miss(n)).then(()=>h)},set(o,t){return e[JSON.stringify(o)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(o){return delete e[JSON.stringify(o)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}function Y(r){let e={value:`Algolia for JavaScript (${r})`,add(o){let t=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function G(r,e,o="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return{headers(){return o==="WithinHeaders"?t:{}},queryParameters(){return o==="WithinQueryParameters"?t:{}}}}function W({algoliaAgents:r,client:e,version:o}){let t=Y(o).add({segment:e,version:o});return r.forEach(a=>t.add(a)),t}function J(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var L=2*60*1e3;function $(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>L}function a(){return e==="timed out"&&Date.now()-o<=L}return{...r,status:e,lastUpdate:o,isUp:t,isTimedOut:a}}var Q=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}},M=class extends Q{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e}},Z=class extends M{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",r,"RetryError")}},z=class extends M{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e}},ee=class extends Q{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},re=class extends z{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o}};function te(r,e,o){let t=oe(o),a=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(a+=`?${t}`),a}function oe(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replace(/\+/g,"%20")}`).join("&")}function se(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let o=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(o)}function ae(r,e,o){let t={Accept:"application/json",...r,...e,...o},a={};return Object.keys(t).forEach(m=>{let h=t[m];a[m.toLowerCase()]=h}),a}function ne(r){try{return JSON.parse(r.content)}catch(e){throw new ee(e.message,r)}}function ie({content:r,status:e},o){try{let t=JSON.parse(r);return"error"in t?new re(t.message,e,t.error,o):new z(t.message,e,o)}catch{}return new z(r,e,o)}function ce({isTimedOut:r,status:e}){return!r&&~~e===0}function ue({isTimedOut:r,status:e}){return r||ce({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function le({status:r}){return~~(r/100)===2}function me(r){return r.map(e=>F(e))}function F(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function B({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:a,algoliaAgent:m,timeouts:h,requester:n,requestsCache:s,responsesCache:i}){async function u(c){let l=await Promise.all(c.map(p=>e.get(p,()=>Promise.resolve($(p))))),g=l.filter(p=>p.isUp()),y=l.filter(p=>p.isTimedOut()),R=[...g,...y];return{hosts:R.length>0?R:c,getTimeout(p,E){return(y.length===0&&p===0?1:y.length+3+p)*E}}}async function d(c,l,g=!0){let y=[],R=se(c,l),T=ae(o,c.headers,l.headers),p=c.method==="GET"?{...c.data,...l.data}:{},E={...a,...c.queryParameters,...p};if(m.value&&(E["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let f of Object.keys(l.queryParameters))!l.queryParameters[f]||Object.prototype.toString.call(l.queryParameters[f])==="[object Object]"?E[f]=l.queryParameters[f]:E[f]=l.queryParameters[f].toString();let S=0,U=async(f,C)=>{let v=f.pop();if(v===void 0)throw new Z(me(y));let b={...h,...l.timeouts},D={data:R,headers:T,method:c.method,url:te(v,c.path,E),connectTimeout:C(S,b.connect),responseTimeout:C(S,g?b.read:b.write)},_=x=>{let I={request:D,response:x,host:v,triesLeft:f.length};return y.push(I),I},w=await n.send(D);if(ue(w)){let x=_(w);return w.isTimedOut&&S++,t.info("Retryable failure",F(x)),await e.set(v,$(v,w.isTimedOut?"timed out":"down")),U(f,C)}if(le(w))return ne(w);throw _(w),ie(w,y)},K=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),k=await u(K);return U([...k.hosts].reverse(),k.getTimeout)}function P(c,l={}){let g=c.useReadTransporter||c.method==="GET";if(!g)return d(c,l,g);let y=()=>d(c,l);if((l.cacheable||c.cacheable)!==!0)return y();let T={request:c,requestOptions:l,transporter:{queryParameters:a,headers:o}};return i.get(T,()=>s.get(T,()=>s.set(T,y()).then(p=>Promise.all([s.delete(T),p]),p=>Promise.all([s.delete(T),Promise.reject(p)])).then(([p,E])=>E)),{miss:p=>i.set(T,p)})}return{hostsCache:e,requester:n,timeouts:h,logger:t,algoliaAgent:m,baseHeaders:o,baseQueryParameters:a,hosts:r,request:P,requestsCache:s,responsesCache:i}}var A="5.20.4",N=["eu","us"];function de(r){return[{url:"personalization.{region}.algolia.com".replace("{region}",r),accept:"readWrite",protocol:"https"}]}function X({appId:r,apiKey:e,authMode:o,algoliaAgents:t,region:a,...m}){let h=G(r,e,o),n=B({hosts:de(a),...m,algoliaAgent:W({algoliaAgents:t,client:"Personalization",version:A}),baseHeaders:{"content-type":"text/plain",...h.headers(),...m.baseHeaders},baseQueryParameters:{...h.queryParameters(),...m.baseQueryParameters}});return{transporter:n,appId:r,apiKey:e,clearCache(){return Promise.all([n.requestsCache.clear(),n.responsesCache.clear()]).then(()=>{})},get _ua(){return n.algoliaAgent.value},addAlgoliaAgent(s,i){n.algoliaAgent.add({segment:s,version:i})},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?n.baseHeaders["x-algolia-api-key"]=s:n.baseQueryParameters["x-algolia-api-key"]=s},customDelete({path:s,parameters:i},u){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return n.request(l,u)},customGet({path:s,parameters:i},u){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return n.request(l,u)},customPost({path:s,parameters:i,body:u},d){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:u||{}};return n.request(g,d)},customPut({path:s,parameters:i,body:u},d){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:u||{}};return n.request(g,d)},deleteUserProfile({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `deleteUserProfile`.");let c={method:"DELETE",path:"/1/profiles/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return n.request(c,i)},getPersonalizationStrategy(s){let P={method:"GET",path:"/1/strategies/personalization",queryParameters:{},headers:{}};return n.request(P,s)},getUserTokenProfile({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `getUserTokenProfile`.");let c={method:"GET",path:"/1/profiles/personalization/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return n.request(c,i)},setPersonalizationStrategy(s,i){if(!s)throw new Error("Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.");if(!s.eventsScoring)throw new Error("Parameter `personalizationStrategyParams.eventsScoring` is required when calling `setPersonalizationStrategy`.");if(!s.facetsScoring)throw new Error("Parameter `personalizationStrategyParams.facetsScoring` is required when calling `setPersonalizationStrategy`.");if(!s.personalizationImpact)throw new Error("Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`.");let c={method:"POST",path:"/1/strategies/personalization",queryParameters:{},headers:{},data:s};return n.request(c,i)}}}function _e(r,e,o,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(!o||o&&(typeof o!="string"||!N.includes(o)))throw new Error(`\`region\` is required and must be one of the following: ${N.join(", ")}`);return X({appId:r,apiKey:e,region:o,timeouts:{connect:1e3,read:2e3,write:3e4},logger:J(),requester:H(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:q({caches:[j({key:`${A}-${r}`}),O()]}),...t})}export{A as apiClientVersion,_e as personalizationClient};
2
2
  //# sourceMappingURL=browser.min.js.map