@algolia/client-personalization 5.53.0 → 5.54.0
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 +4 -4
- package/dist/browser.d.ts +1 -1
- package/dist/builds/browser.js +24 -40
- package/dist/builds/browser.js.map +1 -1
- package/dist/builds/browser.min.js +5 -1
- package/dist/builds/browser.min.js.map +1 -1
- package/dist/builds/browser.umd.js +7 -3
- package/dist/builds/fetch.js +24 -40
- package/dist/builds/fetch.js.map +1 -1
- package/dist/builds/node.cjs +23 -39
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +24 -40
- package/dist/builds/node.js.map +1 -1
- package/dist/builds/worker.js +24 -40
- package/dist/builds/worker.js.map +1 -1
- package/dist/fetch.d.ts +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/src/personalizationClient.cjs +23 -39
- package/dist/src/personalizationClient.cjs.map +1 -1
- package/dist/src/personalizationClient.js +24 -40
- package/dist/src/personalizationClient.js.map +1 -1
- package/dist/worker.d.ts +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -40,11 +40,11 @@ All of our clients comes with type definition, and are available for both browse
|
|
|
40
40
|
### With a package manager
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
yarn add @algolia/client-personalization@5.
|
|
43
|
+
yarn add @algolia/client-personalization@5.54.0
|
|
44
44
|
# or
|
|
45
|
-
npm install @algolia/client-personalization@5.
|
|
45
|
+
npm install @algolia/client-personalization@5.54.0
|
|
46
46
|
# or
|
|
47
|
-
pnpm add @algolia/client-personalization@5.
|
|
47
|
+
pnpm add @algolia/client-personalization@5.54.0
|
|
48
48
|
```
|
|
49
49
|
|
|
50
50
|
### Without a package manager
|
|
@@ -52,7 +52,7 @@ pnpm add @algolia/client-personalization@5.53.0
|
|
|
52
52
|
Add the following JavaScript snippet to the <head> of your website:
|
|
53
53
|
|
|
54
54
|
```html
|
|
55
|
-
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-personalization@5.
|
|
55
|
+
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-personalization@5.54.0/dist/builds/browser.umd.js"></script>
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
### 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.
|
|
167
|
+
declare const apiClientVersion = "5.54.0";
|
|
168
168
|
declare const REGIONS: readonly ["eu", "us"];
|
|
169
169
|
type Region = (typeof REGIONS)[number];
|
|
170
170
|
type RegionOptions = {
|
package/dist/builds/browser.js
CHANGED
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
import { createXhrRequester } from "@algolia/requester-browser-xhr";
|
|
9
9
|
|
|
10
10
|
// src/personalizationClient.ts
|
|
11
|
-
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
|
|
12
|
-
var apiClientVersion = "5.
|
|
11
|
+
import { createAuth, createTransporter, getAlgoliaAgent, validateRequired } from "@algolia/client-common";
|
|
12
|
+
var apiClientVersion = "5.54.0";
|
|
13
13
|
var REGIONS = ["eu", "us"];
|
|
14
14
|
function getDefaultHosts(region) {
|
|
15
15
|
const url = "personalization.{region}.algolia.com".replace("{region}", region);
|
|
@@ -94,9 +94,7 @@ function createPersonalizationClient({
|
|
|
94
94
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
95
95
|
*/
|
|
96
96
|
customDelete({ path, parameters }, requestOptions) {
|
|
97
|
-
|
|
98
|
-
throw new Error("Parameter `path` is required when calling `customDelete`.");
|
|
99
|
-
}
|
|
97
|
+
validateRequired("path", "customDelete", path);
|
|
100
98
|
const requestPath = "/{path}".replace("{path}", path);
|
|
101
99
|
const headers = {};
|
|
102
100
|
const queryParameters = parameters ? parameters : {};
|
|
@@ -116,9 +114,7 @@ function createPersonalizationClient({
|
|
|
116
114
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
117
115
|
*/
|
|
118
116
|
customGet({ path, parameters }, requestOptions) {
|
|
119
|
-
|
|
120
|
-
throw new Error("Parameter `path` is required when calling `customGet`.");
|
|
121
|
-
}
|
|
117
|
+
validateRequired("path", "customGet", path);
|
|
122
118
|
const requestPath = "/{path}".replace("{path}", path);
|
|
123
119
|
const headers = {};
|
|
124
120
|
const queryParameters = parameters ? parameters : {};
|
|
@@ -139,9 +135,7 @@ function createPersonalizationClient({
|
|
|
139
135
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
140
136
|
*/
|
|
141
137
|
customPost({ path, parameters, body }, requestOptions) {
|
|
142
|
-
|
|
143
|
-
throw new Error("Parameter `path` is required when calling `customPost`.");
|
|
144
|
-
}
|
|
138
|
+
validateRequired("path", "customPost", path);
|
|
145
139
|
const requestPath = "/{path}".replace("{path}", path);
|
|
146
140
|
const headers = {};
|
|
147
141
|
const queryParameters = parameters ? parameters : {};
|
|
@@ -163,9 +157,7 @@ function createPersonalizationClient({
|
|
|
163
157
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
164
158
|
*/
|
|
165
159
|
customPut({ path, parameters, body }, requestOptions) {
|
|
166
|
-
|
|
167
|
-
throw new Error("Parameter `path` is required when calling `customPut`.");
|
|
168
|
-
}
|
|
160
|
+
validateRequired("path", "customPut", path);
|
|
169
161
|
const requestPath = "/{path}".replace("{path}", path);
|
|
170
162
|
const headers = {};
|
|
171
163
|
const queryParameters = parameters ? parameters : {};
|
|
@@ -188,9 +180,7 @@ function createPersonalizationClient({
|
|
|
188
180
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
189
181
|
*/
|
|
190
182
|
deleteUserProfile({ userToken }, requestOptions) {
|
|
191
|
-
|
|
192
|
-
throw new Error("Parameter `userToken` is required when calling `deleteUserProfile`.");
|
|
193
|
-
}
|
|
183
|
+
validateRequired("userToken", "deleteUserProfile", userToken);
|
|
194
184
|
const requestPath = "/1/profiles/{userToken}".replace("{userToken}", encodeURIComponent(userToken));
|
|
195
185
|
const headers = {};
|
|
196
186
|
const queryParameters = {};
|
|
@@ -231,9 +221,7 @@ function createPersonalizationClient({
|
|
|
231
221
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
232
222
|
*/
|
|
233
223
|
getUserTokenProfile({ userToken }, requestOptions) {
|
|
234
|
-
|
|
235
|
-
throw new Error("Parameter `userToken` is required when calling `getUserTokenProfile`.");
|
|
236
|
-
}
|
|
224
|
+
validateRequired("userToken", "getUserTokenProfile", userToken);
|
|
237
225
|
const requestPath = "/1/profiles/personalization/{userToken}".replace(
|
|
238
226
|
"{userToken}",
|
|
239
227
|
encodeURIComponent(userToken)
|
|
@@ -257,26 +245,22 @@ function createPersonalizationClient({
|
|
|
257
245
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
258
246
|
*/
|
|
259
247
|
setPersonalizationStrategy(personalizationStrategyParams, requestOptions) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
throw new Error(
|
|
277
|
-
"Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`."
|
|
278
|
-
);
|
|
279
|
-
}
|
|
248
|
+
validateRequired("personalizationStrategyParams", "setPersonalizationStrategy", personalizationStrategyParams);
|
|
249
|
+
validateRequired(
|
|
250
|
+
"personalizationStrategyParams.eventsScoring",
|
|
251
|
+
"setPersonalizationStrategy",
|
|
252
|
+
personalizationStrategyParams.eventsScoring
|
|
253
|
+
);
|
|
254
|
+
validateRequired(
|
|
255
|
+
"personalizationStrategyParams.facetsScoring",
|
|
256
|
+
"setPersonalizationStrategy",
|
|
257
|
+
personalizationStrategyParams.facetsScoring
|
|
258
|
+
);
|
|
259
|
+
validateRequired(
|
|
260
|
+
"personalizationStrategyParams.personalizationImpact",
|
|
261
|
+
"setPersonalizationStrategy",
|
|
262
|
+
personalizationStrategyParams.personalizationImpact
|
|
263
|
+
);
|
|
280
264
|
const requestPath = "/1/strategies/personalization";
|
|
281
265
|
const headers = {};
|
|
282
266
|
const queryParameters = {};
|
|
@@ -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 {\n createBrowserLocalStorageCache,\n createFallbackableCache,\n createMemoryCache,\n createNullLogger,\n} from '@algolia/client-common';\nimport { createXhrRequester } from '@algolia/requester-browser-xhr';\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 | undefined,\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 const { compression: _compression, ...browserOptions } = options || {};\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 ...browserOptions,\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';\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.53.0';\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 | undefined): 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, for example `1/newFeature`.\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, for example `1/newFeature`.\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, for example `1/newFeature`.\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, for example `1/newFeature`.\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 | undefined): 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;AAAA,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R,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA,MAAM;AAAA,MACR;AAEA,aAAO,YAAY,QAAQ,SAAS,cAAc;AAAA,IACpD;AAAA,EACF;AACF;;;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,QAAM,EAAE,aAAa,cAAc,GAAG,eAAe,IAAI,WAAW,CAAC;AAErE,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
|
+
{"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 {\n createBrowserLocalStorageCache,\n createFallbackableCache,\n createMemoryCache,\n createNullLogger,\n} from '@algolia/client-common';\nimport { createXhrRequester } from '@algolia/requester-browser-xhr';\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 | undefined,\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 const { compression: _compression, ...browserOptions } = options || {};\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 ...browserOptions,\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, validateRequired } from '@algolia/client-common';\n\nimport type { DeleteUserProfileResponse } from '../model/deleteUserProfileResponse';\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.54.0';\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 | undefined): 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, for example `1/newFeature`.\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 validateRequired('path', 'customDelete', path);\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, for example `1/newFeature`.\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 validateRequired('path', 'customGet', path);\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, for example `1/newFeature`.\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 validateRequired('path', 'customPost', path);\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, for example `1/newFeature`.\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 validateRequired('path', 'customPut', path);\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 validateRequired('userToken', 'deleteUserProfile', userToken);\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 | undefined): 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 validateRequired('userToken', 'getUserTokenProfile', userToken);\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 validateRequired('personalizationStrategyParams', 'setPersonalizationStrategy', personalizationStrategyParams);\n\n validateRequired(\n 'personalizationStrategyParams.eventsScoring',\n 'setPersonalizationStrategy',\n personalizationStrategyParams.eventsScoring,\n );\n validateRequired(\n 'personalizationStrategyParams.facetsScoring',\n 'setPersonalizationStrategy',\n personalizationStrategyParams.facetsScoring,\n );\n validateRequired(\n 'personalizationStrategyParams.personalizationImpact',\n 'setPersonalizationStrategy',\n personalizationStrategyParams.personalizationImpact,\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;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;;;ACEnC,SAAS,YAAY,mBAAmB,iBAAiB,wBAAwB;AAgB1E,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,GAA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,IACD,GAAG;AAAA,EACL,CAAC;AACH;","names":[]}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
function W(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 c(s){t().setItem(o,JSON.stringify(s))}function m(){return new Promise(s=>setTimeout(s,0))}function i(){let s=r.timeToLive?r.timeToLive*1e3:null,n=a(),u=new Date().getTime(),p=!1;return{namespace:Object.fromEntries(Object.entries(n).filter(([,h])=>!h||h.timestamp===void 0||s&&h.timestamp+s<u?(p=!0,!1):!0)),changed:p}}return{get(s,n,u={miss:()=>Promise.resolve()}){return m().then(()=>{let{namespace:p,changed:P}=i(),h=p[JSON.stringify(s)];return P&&c(p),h?h.value:n().then(y=>u.miss(y).then(()=>y))})},set(s,n){return m().then(()=>{let u=a();return u[JSON.stringify(s)]={timestamp:new Date().getTime(),value:n},t().setItem(o,JSON.stringify(u)),n})},delete(s){return m().then(()=>{let n=a();delete n[JSON.stringify(s)],t().setItem(o,JSON.stringify(n))})},clear(){return Promise.resolve().then(()=>{t().removeItem(o)})}}}function te(){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 S(r){let e=[...r.caches],o=e.shift();return o===void 0?te():{get(t,a,c={miss:()=>Promise.resolve()}){return o.get(t,a,c).catch(()=>S({caches:e}).get(t,a,c))},set(t,a){return o.set(t,a).catch(()=>S({caches:e}).set(t,a))},delete(t){return o.delete(t).catch(()=>S({caches:e}).delete(t))},clear(){return o.clear().catch(()=>S({caches:e}).clear())}}}function A(r={serializable:!0}){let e={};return{get(o,t,a={miss:()=>Promise.resolve()}){let c=JSON.stringify(o);if(c in e)return Promise.resolve(r.serializable?JSON.parse(e[c]):e[c]);let m=t();return m.then(i=>a.miss(i)).then(()=>m)},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 oe(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 M(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 Q({algoliaAgents:r,client:e,version:o}){let t=oe(o).add({segment:e,version:o});return r.forEach(a=>t.add(a)),t}function F(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var se=750,J=120*1e3;function j(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>J}function a(){return e==="timed out"&&Date.now()-o<=J}return{...r,status:e,lastUpdate:o,isUp:t,isTimedOut:a}}var B=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}};var X=class extends B{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e}},ae=class extends X{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please visit our help center https://alg.li/support-unreachable-hosts or reach out to the Algolia Support team: https://alg.li/support",r,"RetryError")}},D=class extends X{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e}},ne=class extends B{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},ie=class extends D{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o}};function ce(r,e,o){let t=ue(o),a=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(a+=`?${t}`),a}function ue(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 le(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 me(r,e,o){let t={Accept:"application/json",...r,...e,...o},a={};return Object.keys(t).forEach(c=>{let m=t[c];a[c.toLowerCase()]=m}),a}function de(r){try{return JSON.parse(r.content)}catch(e){throw new ne(e.message,r)}}function pe({content:r,status:e},o){try{let t=JSON.parse(r);return"error"in t?new ie(t.message,e,t.error,o):new D(t.message,e,o)}catch{}return new D(r,e,o)}function he({isTimedOut:r,status:e}){return!r&&~~e===0}function fe({isTimedOut:r,status:e}){return r||he({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function ge({status:r}){return~~(r/100)===2}function Pe(r){return r.map(e=>K(e))}function K(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 V({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:a,algoliaAgent:c,timeouts:m,requester:i,requestsCache:s,responsesCache:n,compress:u,compression:p}){async function P(l){let f=await Promise.all(l.map(d=>e.get(d,()=>Promise.resolve(j(d))))),q=f.filter(d=>d.isUp()),E=f.filter(d=>d.isTimedOut()),w=[...q,...E];return{hosts:w.length>0?w:l,getTimeout(d,v){return(E.length===0&&d===0?1:E.length+3+d)*v}}}async function h(l,f,q){let E=[],w=le(l,f),T=me(o,l.headers,f.headers),d=p==="gzip"&&w!==void 0&&w.length>se&&(l.method==="POST"||l.method==="PUT");d&&u===void 0&&t.info("Compression is disabled because no compress method is available.");let v=d&&u!==void 0,I=v?await u(w):w;v&&(T["content-encoding"]="gzip");let ee=l.method==="GET"?{...l.data,...f.data}:{},x={...a,...l.queryParameters,...ee};if(c.value&&(x["x-algolia-agent"]=c.value),f&&f.queryParameters)for(let g of Object.keys(f.queryParameters))!f.queryParameters[g]||Object.prototype.toString.call(f.queryParameters[g])==="[object Object]"?x[g]=f.queryParameters[g]:x[g]=f.queryParameters[g].toString();let b=0,_=async(g,z)=>{let O=g.pop();if(O===void 0)throw new ae(Pe(E));let N={...m,...f.timeouts},L={data:I,headers:T,method:l.method,url:ce(O,l.path,x),connectTimeout:z(b,N.connect),responseTimeout:z(b,q?N.read:N.write)},$=U=>{let G={request:L,response:U,host:O,triesLeft:g.length};return E.push(G),G},R=await i.send(L);if(fe(R)){let U=$(R);return R.isTimedOut&&b++,t.info("Retryable failure",K(U)),await e.set(O,j(O,R.isTimedOut?"timed out":"down")),_(g,z)}if(ge(R))return de(R);throw $(R),pe(R,E)},re=r.filter(g=>g.accept==="readWrite"||(q?g.accept==="read":g.accept==="write")),H=await P(re);return _([...H.hosts].reverse(),H.getTimeout)}function y(l,f={}){let q=()=>h(l,f,E),E=l.useReadTransporter||l.method==="GET";if((f.cacheable||l.cacheable)!==!0)return q();let T={request:l,requestOptions:f,transporter:{queryParameters:a,headers:o}};return n.get(T,()=>s.get(T,()=>s.set(T,q()).then(d=>Promise.all([s.delete(T),d]),d=>Promise.all([s.delete(T),Promise.reject(d)])).then(([d,v])=>v)),{miss:d=>n.set(T,d)})}return{hostsCache:e,requester:i,timeouts:m,logger:t,algoliaAgent:c,baseHeaders:o,baseQueryParameters:a,hosts:r,request:y,requestsCache:s,responsesCache:n}}function Y(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(i=>t.setRequestHeader(i,e.headers[i]));let a=(i,s)=>setTimeout(()=>{t.abort(),o({status:0,content:s,isTimedOut:!0})},i),c=a(e.connectTimeout,"Connection timeout"),m;t.onreadystatechange=()=>{t.readyState>t.OPENED&&m===void 0&&(clearTimeout(c),m=a(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(c),clearTimeout(m),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(c),clearTimeout(m),o({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}var C="5.53.0",k=["eu","us"];function ye(r){return[{url:"personalization.{region}.algolia.com".replace("{region}",r),accept:"readWrite",protocol:"https"}]}function Z({appId:r,apiKey:e,authMode:o,algoliaAgents:t,region:a,...c}){let m=M(r,e,o),i=V({hosts:ye(a),...c,algoliaAgent:Q({algoliaAgents:t,client:"Personalization",version:C}),baseHeaders:{"content-type":"text/plain",...m.headers(),...c.baseHeaders},baseQueryParameters:{...m.queryParameters(),...c.baseQueryParameters}});return{transporter:i,appId:r,apiKey:e,clearCache(){return Promise.all([i.requestsCache.clear(),i.responsesCache.clear()]).then(()=>{})},get _ua(){return i.algoliaAgent.value},addAlgoliaAgent(s,n){i.algoliaAgent.add({segment:s,version:n})},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?i.baseHeaders["x-algolia-api-key"]=s:i.baseQueryParameters["x-algolia-api-key"]=s},customDelete({path:s,parameters:n},u){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let y={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return i.request(y,u)},customGet({path:s,parameters:n},u){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let y={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{}};return i.request(y,u)},customPost({path:s,parameters:n,body:u},p){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let l={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:u||{}};return i.request(l,p)},customPut({path:s,parameters:n,body:u},p){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let l={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:n||{},headers:{},data:u||{}};return i.request(l,p)},deleteUserProfile({userToken:s},n){if(!s)throw new Error("Parameter `userToken` is required when calling `deleteUserProfile`.");let h={method:"DELETE",path:"/1/profiles/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return i.request(h,n)},getPersonalizationStrategy(s){let P={method:"GET",path:"/1/strategies/personalization",queryParameters:{},headers:{}};return i.request(P,s)},getUserTokenProfile({userToken:s},n){if(!s)throw new Error("Parameter `userToken` is required when calling `getUserTokenProfile`.");let h={method:"GET",path:"/1/profiles/personalization/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return i.request(h,n)},setPersonalizationStrategy(s,n){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 h={method:"POST",path:"/1/strategies/personalization",queryParameters:{},headers:{},data:s};return i.request(h,n)}}}function Je(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"||!k.includes(o)))throw new Error(`\`region\` is required and must be one of the following: ${k.join(", ")}`);let{compression:a,...c}=t||{};return Z({appId:r,apiKey:e,region:o,timeouts:{connect:1e3,read:2e3,write:3e4},logger:F(),requester:Y(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:A(),requestsCache:A({serializable:!1}),hostsCache:S({caches:[W({key:`${C}-${r}`}),A()]}),...c})}export{C as apiClientVersion,Je as personalizationClient};
|
|
1
|
+
function Y(t){let e,r=`algolia-client-js-${t.key}`;function s(){return e===void 0&&(e=t.localStorage||window.localStorage),e}function a(){return JSON.parse(s().getItem(r)||"{}")}function c(n){s().setItem(r,JSON.stringify(n))}function m(){return new Promise(n=>setTimeout(n,0))}function i(){let n=t.timeToLive?t.timeToLive*1e3:null,o=a(),l=new Date().getTime(),p=!1;return{namespace:Object.fromEntries(Object.entries(o).filter(([,f])=>!f||f.timestamp===void 0||n&&f.timestamp+n<l?(p=!0,!1):!0)),changed:p}}return{get(n,o,l={miss:()=>Promise.resolve()}){return m().then(()=>{let{namespace:p,changed:g}=i(),f=p[JSON.stringify(n)];return g&&c(p),f?f.value:o().then(T=>l.miss(T).then(()=>T))})},set(n,o){return m().then(()=>{let l=a();return l[JSON.stringify(n)]={timestamp:new Date().getTime(),value:o},s().setItem(r,JSON.stringify(l)),o})},delete(n){return m().then(()=>{let o=a();delete o[JSON.stringify(n)],s().setItem(r,JSON.stringify(o))})},clear(){return Promise.resolve().then(()=>{s().removeItem(r)})}}}function ce(){return{get(t,e,r={miss:()=>Promise.resolve()}){return e().then(a=>Promise.all([a,r.miss(a)])).then(([a])=>a)},set(t,e){return Promise.resolve(e)},delete(t){return Promise.resolve()},clear(){return Promise.resolve()}}}function A(t){let e=[...t.caches],r=e.shift();return r===void 0?ce():{get(s,a,c={miss:()=>Promise.resolve()}){return r.get(s,a,c).catch(()=>A({caches:e}).get(s,a,c))},set(s,a){return r.set(s,a).catch(()=>A({caches:e}).set(s,a))},delete(s){return r.delete(s).catch(()=>A({caches:e}).delete(s))},clear(){return r.clear().catch(()=>A({caches:e}).clear())}}}function D(t={serializable:!0}){let e={};return{get(r,s,a={miss:()=>Promise.resolve()}){let c=JSON.stringify(r);if(c in e)return Promise.resolve(t.serializable?JSON.parse(e[c]):e[c]);let m=s();return m.then(i=>a.miss(i)).then(()=>m)},set(r,s){return e[JSON.stringify(r)]=t.serializable?JSON.stringify(s):s,Promise.resolve(s)},delete(r){return delete e[JSON.stringify(r)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}function le(t){let e={value:`Algolia for JavaScript (${t})`,add(r){let s=`; ${r.segment}${r.version!==void 0?` (${r.version})`:""}`;return e.value.indexOf(s)===-1&&(e.value=`${e.value}${s}`),e}};return e}function Z(t,e,r="WithinHeaders"){let s={"x-algolia-api-key":e,"x-algolia-application-id":t};return{headers(){return r==="WithinHeaders"?s:{}},queryParameters(){return r==="WithinQueryParameters"?s:{}}}}function ee({algoliaAgents:t,client:e,version:r}){let s=le(r).add({segment:e,version:r});return t.forEach(a=>s.add(a)),s}function te(){return{debug(t,e){return Promise.resolve()},info(t,e){return Promise.resolve()},error(t,e){return Promise.resolve()}}}var ue=10*1024*1024;async function*de(t){let e=t.getReader();try{for(;;){let{done:r,value:s}=await e.read();if(r)return;yield s}}finally{e.releaseLock()}}function me(t){return Symbol.asyncIterator in t?t:de(t)}async function*pe(t){let e=new TextDecoder("utf-8"),r=[],s=0,a=!1,c=!0;for await(let i of me(t)){let n=e.decode(i,{stream:!0}),o=0;for(a&&(a=!1,n.length>0&&n[0]===`
|
|
2
|
+
`&&(o=1));o<n.length;){let l=n.indexOf("\r",o),p=n.indexOf(`
|
|
3
|
+
`,o);if(l===-1&&p===-1){let u=n.slice(o);if(r.push(u),s+=u.length,s>ue)throw new Error("SSE line buffer exceeded 10MB");break}let g,f;l!==-1&&(p===-1||l<p)?(g=l,l+1<n.length?f=n[l+1]===`
|
|
4
|
+
`?2:1:(a=!0,f=1)):(g=p,f=1);let T=n.slice(o,g);r.push(T);let R=r.length===1?r[0]:r.join("");r.length=0,s=0,c&&(R.startsWith("\uFEFF")&&(R=R.slice(1)),c=!1),yield R,o=g+f}}let m=e.decode();if(m&&r.push(m),r.length>0){let i=r.join("");c&&i.startsWith("\uFEFF")&&(i=i.slice(1)),yield i}}var fe=class{data=[];eventType="";lastEventId=null;retry=null;decode(t){if(t==="")return this.dispatch();if(t[0]===":")return null;let e=t.indexOf(":"),r,s;switch(e===-1?(r=t,s=""):(r=t.slice(0,e),s=t.slice(e+1),s[0]===" "&&(s=s.slice(1))),r){case"data":this.data.push(s);break;case"event":this.eventType=s;break;case"id":s.includes("\0")||(this.lastEventId=s);break;case"retry":/^[0-9]+$/.test(s)&&(this.retry=parseInt(s,10));break}return null}dispatch(){let t=this.eventType;if(this.eventType="",this.data.length===0)return null;let e={data:this.data.join(`
|
|
5
|
+
`),event:t,id:this.lastEventId,retry:this.retry};return this.data=[],e}};async function*he(t){let e=new fe;for await(let r of pe(t)){let s=e.decode(r);s!==null&&(yield s)}}var ge=750,M=120*1e3;function Q(t,e="up"){let r=Date.now();function s(){return e==="up"||Date.now()-r>M}function a(){return e==="timed out"&&Date.now()-r<=M}return{...t,status:e,lastUpdate:r,isUp:s,isTimedOut:a}}var re=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e)}};var se=class extends re{stackTrace;constructor(t,e,r){super(t,r),this.stackTrace=e}},B=class extends se{constructor(t){super("Unreachable hosts - your application id may be incorrect. If the error persists, please visit our help center https://alg.li/support-unreachable-hosts or reach out to the Algolia Support team: https://alg.li/support",t,"RetryError")}},$=class extends se{status;constructor(t,e,r,s="ApiError"){super(t,r,s),this.status=e}},Pe=class extends re{response;constructor(t,e){super(t,"DeserializationError"),this.response=e}},ye=class extends ${error;constructor(t,e,r,s){super(t,e,s,"DetailedApiError"),this.error=r}};function X(t,e,r){let s=Te(r),a=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return s.length&&(a+=`?${s}`),a}function Te(t){return Object.keys(t).filter(e=>t[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(t[e])==="[object Array]"?t[e].join(","):t[e]).replace(/\+/g,"%20")}`).join("&")}function K(t,e){if(t.method==="GET"||t.data===void 0&&e.data===void 0)return;let r=Array.isArray(t.data)?t.data:{...t.data,...e.data};return JSON.stringify(r)}function V(t,e,r){let s={Accept:"application/json",...t,...e,...r},a={};return Object.keys(s).forEach(c=>{let m=s[c];a[c.toLowerCase()]=m}),a}function Ee(t){if(!(t.status===204||t.content.length===0))try{return JSON.parse(t.content)}catch(e){throw new Pe(e.message,t)}}function ve({content:t,status:e},r){try{let s=JSON.parse(t);return"error"in s?new ye(s.message,e,s.error,r):new $(s.message,e,r)}catch{}return new $(t,e,r)}function Se({isTimedOut:t,status:e}){return!t&&~~e===0}function Re({isTimedOut:t,status:e}){return t||Se({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function we({status:t}){return~~(t/100)===2}function xe(t){return t.map(e=>ne(e))}function ne(t){let e=t.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...t,request:{...t.request,headers:{...t.request.headers,...e}}}}function oe({hosts:t,hostsCache:e,baseHeaders:r,logger:s,baseQueryParameters:a,algoliaAgent:c,timeouts:m,requester:i,requestsCache:n,responsesCache:o,compress:l,compression:p}){async function g(u){let d=await Promise.all(u.map(h=>e.get(h,()=>Promise.resolve(Q(h))))),x=d.filter(h=>h.isUp()),E=d.filter(h=>h.isTimedOut()),w=[...x,...E];return{hosts:w.length>0?w:u,getTimeout(h,b){return(E.length===0&&h===0?1:E.length+3+h)*b}}}async function f(u,d,x){let E=[],w=K(u,d),P=V(r,u.headers,d.headers),h=p==="gzip"&&w!==void 0&&w.length>ge&&(u.method==="POST"||u.method==="PUT");h&&l===void 0&&s.info("Compression is disabled because no compress method is available.");let b=h&&l!==void 0,U=b?await l(w):w;b&&(P["content-encoding"]="gzip");let k=u.method==="GET"?{...u.data,...d.data}:{},O={...a,...u.queryParameters,...k};if(c.value&&(O["x-algolia-agent"]=c.value),d&&d.queryParameters)for(let y of Object.keys(d.queryParameters))!d.queryParameters[y]||Object.prototype.toString.call(d.queryParameters[y])==="[object Object]"?O[y]=d.queryParameters[y]:O[y]=d.queryParameters[y].toString();let I=0,z=async(y,_)=>{let C=y.pop();if(C===void 0)throw new B(xe(E));let L={...m,...d.timeouts},G={data:U,headers:P,method:u.method,url:X(C,u.path,O),connectTimeout:_(I,L.connect),responseTimeout:_(I,x?L.read:L.write)},W=H=>{let J={request:G,response:H,host:C,triesLeft:y.length};return E.push(J),J},q=await i.send(G);if(Re(q)){let H=W(q);return q.isTimedOut&&I++,s.info("Retryable failure",ne(H)),await e.set(C,Q(C,q.isTimedOut?"timed out":"down")),z(y,_)}if(we(q))return Ee(q);throw W(q),ve(q,E)},v=t.filter(y=>y.accept==="readWrite"||(x?y.accept==="read":y.accept==="write")),F=await g(v);return z([...F.hosts].reverse(),F.getTimeout)}function T(u,d={}){let x=()=>f(u,d,E),E=u.useReadTransporter||u.method==="GET";if((d.cacheable||u.cacheable)!==!0)return x();let P={request:u,requestOptions:d,transporter:{queryParameters:a,headers:r}};return o.get(P,()=>n.get(P,()=>n.set(P,x()).then(h=>Promise.all([n.delete(P),h]),h=>Promise.all([n.delete(P),Promise.reject(h)])).then(([h,b])=>b)),{miss:h=>o.set(P,h)})}async function*R(u,d={}){if(!i.sendStream)throw new Error("This requester does not support streaming");let x=K(u,d),E=V(r,u.headers,d.headers);E.accept="text/event-stream";let w=u.method==="GET"?{...u.data,...d.data}:{},P={...a,...u.queryParameters,...w};if(c.value&&(P["x-algolia-agent"]=c.value),d&&d.queryParameters)for(let v of Object.keys(d.queryParameters))!d.queryParameters[v]||Object.prototype.toString.call(d.queryParameters[v])==="[object Object]"?P[v]=d.queryParameters[v]:P[v]=d.queryParameters[v].toString();let h=u.useReadTransporter||u.method==="GET",b=t.filter(v=>v.accept==="readWrite"||(h?v.accept==="read":v.accept==="write")),k=(await g(b)).hosts[0];if(!k)throw new B([]);let O={...m,...d.timeouts},I={data:x,headers:E,method:u.method,url:X(k,u.path,P),connectTimeout:O.connect,responseTimeout:h?O.read:O.write},z=await i.sendStream(I);yield*he(z)}return{hostsCache:e,requester:i,timeouts:m,logger:s,algoliaAgent:c,baseHeaders:r,baseQueryParameters:a,hosts:t,request:T,requestStream:R,requestsCache:n,responsesCache:o}}function S(t,e,r){if(r==null||typeof r=="string"&&r.length===0)throw new Error(`Parameter \`${t}\` is required when calling \`${e}\`.`)}function ae(){function t(e){return new Promise(r=>{let s=new XMLHttpRequest;s.open(e.method,e.url,!0),Object.keys(e.headers).forEach(i=>s.setRequestHeader(i,e.headers[i]));let a=(i,n)=>setTimeout(()=>{s.abort(),r({status:0,content:n,isTimedOut:!0})},i),c=a(e.connectTimeout,"Connection timeout"),m;s.onreadystatechange=()=>{s.readyState>s.OPENED&&m===void 0&&(clearTimeout(c),m=a(e.responseTimeout,"Socket timeout"))},s.onerror=()=>{s.status===0&&(clearTimeout(c),clearTimeout(m),r({content:s.responseText||"Network request failed",status:s.status,isTimedOut:!1}))},s.onload=()=>{clearTimeout(c),clearTimeout(m),r({content:s.responseText,status:s.status,isTimedOut:!1})},s.send(e.data)})}return{send:t}}var N="5.54.0",j=["eu","us"];function be(t){return[{url:"personalization.{region}.algolia.com".replace("{region}",t),accept:"readWrite",protocol:"https"}]}function ie({appId:t,apiKey:e,authMode:r,algoliaAgents:s,region:a,...c}){let m=Z(t,e,r),i=oe({hosts:be(a),...c,algoliaAgent:ee({algoliaAgents:s,client:"Personalization",version:N}),baseHeaders:{"content-type":"text/plain",...m.headers(),...c.baseHeaders},baseQueryParameters:{...m.queryParameters(),...c.baseQueryParameters}});return{transporter:i,appId:t,apiKey:e,clearCache(){return Promise.all([i.requestsCache.clear(),i.responsesCache.clear()]).then(()=>{})},get _ua(){return i.algoliaAgent.value},addAlgoliaAgent(n,o){i.algoliaAgent.add({segment:n,version:o})},setClientApiKey({apiKey:n}){!r||r==="WithinHeaders"?i.baseHeaders["x-algolia-api-key"]=n:i.baseQueryParameters["x-algolia-api-key"]=n},customDelete({path:n,parameters:o},l){S("path","customDelete",n);let T={method:"DELETE",path:"/{path}".replace("{path}",n),queryParameters:o||{},headers:{}};return i.request(T,l)},customGet({path:n,parameters:o},l){S("path","customGet",n);let T={method:"GET",path:"/{path}".replace("{path}",n),queryParameters:o||{},headers:{}};return i.request(T,l)},customPost({path:n,parameters:o,body:l},p){S("path","customPost",n);let R={method:"POST",path:"/{path}".replace("{path}",n),queryParameters:o||{},headers:{},data:l||{}};return i.request(R,p)},customPut({path:n,parameters:o,body:l},p){S("path","customPut",n);let R={method:"PUT",path:"/{path}".replace("{path}",n),queryParameters:o||{},headers:{},data:l||{}};return i.request(R,p)},deleteUserProfile({userToken:n},o){S("userToken","deleteUserProfile",n);let f={method:"DELETE",path:"/1/profiles/{userToken}".replace("{userToken}",encodeURIComponent(n)),queryParameters:{},headers:{}};return i.request(f,o)},getPersonalizationStrategy(n){let g={method:"GET",path:"/1/strategies/personalization",queryParameters:{},headers:{}};return i.request(g,n)},getUserTokenProfile({userToken:n},o){S("userToken","getUserTokenProfile",n);let f={method:"GET",path:"/1/profiles/personalization/{userToken}".replace("{userToken}",encodeURIComponent(n)),queryParameters:{},headers:{}};return i.request(f,o)},setPersonalizationStrategy(n,o){S("personalizationStrategyParams","setPersonalizationStrategy",n),S("personalizationStrategyParams.eventsScoring","setPersonalizationStrategy",n.eventsScoring),S("personalizationStrategyParams.facetsScoring","setPersonalizationStrategy",n.facetsScoring),S("personalizationStrategyParams.personalizationImpact","setPersonalizationStrategy",n.personalizationImpact);let f={method:"POST",path:"/1/strategies/personalization",queryParameters:{},headers:{},data:n};return i.request(f,o)}}}function Ve(t,e,r,s){if(!t||typeof t!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(!r||r&&(typeof r!="string"||!j.includes(r)))throw new Error(`\`region\` is required and must be one of the following: ${j.join(", ")}`);let{compression:a,...c}=s||{};return ie({appId:t,apiKey:e,region:r,timeouts:{connect:1e3,read:2e3,write:3e4},logger:te(),requester:ae(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:D(),requestsCache:D({serializable:!1}),hostsCache:A({caches:[Y({key:`${N}-${t}`}),D()]}),...c})}export{N as apiClientVersion,Ve as personalizationClient};
|
|
2
6
|
//# sourceMappingURL=browser.min.js.map
|