@algolia/client-personalization 5.3.0 → 5.3.2
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/dist/browser.d.ts +1 -1
- package/dist/builds/browser.js +36 -33
- package/dist/builds/browser.js.map +1 -1
- package/dist/builds/browser.min.js +1 -1
- package/dist/builds/browser.min.js.map +1 -1
- package/dist/builds/browser.umd.js +2 -2
- package/dist/builds/node.cjs +36 -33
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +36 -33
- package/dist/builds/node.js.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/src/personalizationClient.cjs +36 -33
- package/dist/src/personalizationClient.cjs.map +1 -1
- package/dist/src/personalizationClient.js +36 -33
- package/dist/src/personalizationClient.js.map +1 -1
- package/package.json +4 -4
package/dist/browser.d.ts
CHANGED
|
@@ -156,7 +156,7 @@ type SetPersonalizationStrategyResponse = {
|
|
|
156
156
|
message: string;
|
|
157
157
|
};
|
|
158
158
|
|
|
159
|
-
declare const apiClientVersion = "5.3.
|
|
159
|
+
declare const apiClientVersion = "5.3.2";
|
|
160
160
|
declare const REGIONS: readonly ["eu", "us"];
|
|
161
161
|
type Region = (typeof REGIONS)[number];
|
|
162
162
|
declare function createPersonalizationClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & {
|
package/dist/builds/browser.js
CHANGED
|
@@ -11,7 +11,7 @@ import { createXhrRequester } from "@algolia/requester-browser-xhr";
|
|
|
11
11
|
|
|
12
12
|
// src/personalizationClient.ts
|
|
13
13
|
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
|
|
14
|
-
var apiClientVersion = "5.3.
|
|
14
|
+
var apiClientVersion = "5.3.2";
|
|
15
15
|
var REGIONS = ["eu", "us"];
|
|
16
16
|
function getDefaultHosts(region) {
|
|
17
17
|
const url = "personalization.{region}.algolia.com".replace("{region}", region);
|
|
@@ -26,25 +26,26 @@ function createPersonalizationClient({
|
|
|
26
26
|
...options
|
|
27
27
|
}) {
|
|
28
28
|
const auth = createAuth(appIdOption, apiKeyOption, authMode);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
version: apiClientVersion
|
|
37
|
-
}),
|
|
38
|
-
baseHeaders: {
|
|
39
|
-
"content-type": "text/plain",
|
|
40
|
-
...auth.headers(),
|
|
41
|
-
...options.baseHeaders
|
|
42
|
-
},
|
|
43
|
-
baseQueryParameters: {
|
|
44
|
-
...auth.queryParameters(),
|
|
45
|
-
...options.baseQueryParameters
|
|
46
|
-
}
|
|
29
|
+
const transporter = createTransporter({
|
|
30
|
+
hosts: getDefaultHosts(regionOption),
|
|
31
|
+
...options,
|
|
32
|
+
algoliaAgent: getAlgoliaAgent({
|
|
33
|
+
algoliaAgents,
|
|
34
|
+
client: "Personalization",
|
|
35
|
+
version: apiClientVersion
|
|
47
36
|
}),
|
|
37
|
+
baseHeaders: {
|
|
38
|
+
"content-type": "text/plain",
|
|
39
|
+
...auth.headers(),
|
|
40
|
+
...options.baseHeaders
|
|
41
|
+
},
|
|
42
|
+
baseQueryParameters: {
|
|
43
|
+
...auth.queryParameters(),
|
|
44
|
+
...options.baseQueryParameters
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
transporter,
|
|
48
49
|
/**
|
|
49
50
|
* The `appId` currently in use.
|
|
50
51
|
*/
|
|
@@ -53,15 +54,13 @@ function createPersonalizationClient({
|
|
|
53
54
|
* Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
|
|
54
55
|
*/
|
|
55
56
|
clearCache() {
|
|
56
|
-
return Promise.all([
|
|
57
|
-
() => void 0
|
|
58
|
-
);
|
|
57
|
+
return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0);
|
|
59
58
|
},
|
|
60
59
|
/**
|
|
61
60
|
* Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
|
|
62
61
|
*/
|
|
63
62
|
get _ua() {
|
|
64
|
-
return
|
|
63
|
+
return transporter.algoliaAgent.value;
|
|
65
64
|
},
|
|
66
65
|
/**
|
|
67
66
|
* Adds a `segment` to the `x-algolia-agent` sent with every requests.
|
|
@@ -70,7 +69,7 @@ function createPersonalizationClient({
|
|
|
70
69
|
* @param version - The version of the agent.
|
|
71
70
|
*/
|
|
72
71
|
addAlgoliaAgent(segment, version) {
|
|
73
|
-
|
|
72
|
+
transporter.algoliaAgent.add({ segment, version });
|
|
74
73
|
},
|
|
75
74
|
/**
|
|
76
75
|
* Helper method to switch the API key used to authenticate the requests.
|
|
@@ -79,7 +78,11 @@ function createPersonalizationClient({
|
|
|
79
78
|
* @param params.apiKey - The new API Key to use.
|
|
80
79
|
*/
|
|
81
80
|
setClientApiKey({ apiKey }) {
|
|
82
|
-
|
|
81
|
+
if (!authMode || authMode === "WithinHeaders") {
|
|
82
|
+
transporter.baseHeaders["x-algolia-api-key"] = apiKey;
|
|
83
|
+
} else {
|
|
84
|
+
transporter.baseQueryParameters["x-algolia-api-key"] = apiKey;
|
|
85
|
+
}
|
|
83
86
|
},
|
|
84
87
|
/**
|
|
85
88
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -102,7 +105,7 @@ function createPersonalizationClient({
|
|
|
102
105
|
queryParameters,
|
|
103
106
|
headers
|
|
104
107
|
};
|
|
105
|
-
return
|
|
108
|
+
return transporter.request(request, requestOptions);
|
|
106
109
|
},
|
|
107
110
|
/**
|
|
108
111
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -125,7 +128,7 @@ function createPersonalizationClient({
|
|
|
125
128
|
queryParameters,
|
|
126
129
|
headers
|
|
127
130
|
};
|
|
128
|
-
return
|
|
131
|
+
return transporter.request(request, requestOptions);
|
|
129
132
|
},
|
|
130
133
|
/**
|
|
131
134
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -150,7 +153,7 @@ function createPersonalizationClient({
|
|
|
150
153
|
headers,
|
|
151
154
|
data: body ? body : {}
|
|
152
155
|
};
|
|
153
|
-
return
|
|
156
|
+
return transporter.request(request, requestOptions);
|
|
154
157
|
},
|
|
155
158
|
/**
|
|
156
159
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -175,7 +178,7 @@ function createPersonalizationClient({
|
|
|
175
178
|
headers,
|
|
176
179
|
data: body ? body : {}
|
|
177
180
|
};
|
|
178
|
-
return
|
|
181
|
+
return transporter.request(request, requestOptions);
|
|
179
182
|
},
|
|
180
183
|
/**
|
|
181
184
|
* Deletes a user profile. The response includes a date and time when the user profile can safely be considered deleted.
|
|
@@ -200,7 +203,7 @@ function createPersonalizationClient({
|
|
|
200
203
|
queryParameters,
|
|
201
204
|
headers
|
|
202
205
|
};
|
|
203
|
-
return
|
|
206
|
+
return transporter.request(request, requestOptions);
|
|
204
207
|
},
|
|
205
208
|
/**
|
|
206
209
|
* Retrieves the current personalization strategy.
|
|
@@ -220,7 +223,7 @@ function createPersonalizationClient({
|
|
|
220
223
|
queryParameters,
|
|
221
224
|
headers
|
|
222
225
|
};
|
|
223
|
-
return
|
|
226
|
+
return transporter.request(request, requestOptions);
|
|
224
227
|
},
|
|
225
228
|
/**
|
|
226
229
|
* Retrieves a user profile and their affinities for different facets.
|
|
@@ -248,7 +251,7 @@ function createPersonalizationClient({
|
|
|
248
251
|
queryParameters,
|
|
249
252
|
headers
|
|
250
253
|
};
|
|
251
|
-
return
|
|
254
|
+
return transporter.request(request, requestOptions);
|
|
252
255
|
},
|
|
253
256
|
/**
|
|
254
257
|
* Creates a new personalization strategy.
|
|
@@ -290,7 +293,7 @@ function createPersonalizationClient({
|
|
|
290
293
|
headers,
|
|
291
294
|
data: personalizationStrategyParams
|
|
292
295
|
};
|
|
293
|
-
return
|
|
296
|
+
return transporter.request(request, requestOptions);
|
|
294
297
|
}
|
|
295
298
|
};
|
|
296
299
|
}
|
|
@@ -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 type { ClientOptions } from '@algolia/client-common';\nimport {\n createMemoryCache,\n createFallbackableCache,\n createBrowserLocalStorageCache,\n DEFAULT_CONNECT_TIMEOUT_BROWSER,\n DEFAULT_READ_TIMEOUT_BROWSER,\n DEFAULT_WRITE_TIMEOUT_BROWSER,\n} from '@algolia/client-common';\nimport { createXhrRequester } from '@algolia/requester-browser-xhr';\n\nimport type { Region } from '../src/personalizationClient';\nimport { createPersonalizationClient, apiClientVersion, REGIONS } from '../src/personalizationClient';\n\nexport type PersonalizationClient = ReturnType<typeof createPersonalizationClient>;\n\nexport { apiClientVersion, Region } from '../src/personalizationClient';\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: DEFAULT_CONNECT_TIMEOUT_BROWSER,\n read: DEFAULT_READ_TIMEOUT_BROWSER,\n write: DEFAULT_WRITE_TIMEOUT_BROWSER,\n },\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","// 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 { createAuth, createTransporter, getAlgoliaAgent } from '@algolia/client-common';\nimport type {\n CreateClientOptions,\n Headers,\n Host,\n QueryParameters,\n Request,\n RequestOptions,\n} from '@algolia/client-common';\n\nimport type {\n CustomDeleteProps,\n CustomGetProps,\n CustomPostProps,\n CustomPutProps,\n DeleteUserProfileProps,\n GetUserTokenProfileProps,\n} from '../model/clientMethodProps';\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\nexport const apiClientVersion = '5.3.0';\n\nexport const REGIONS = ['eu', 'us'] as const;\nexport type Region = (typeof REGIONS)[number];\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\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function createPersonalizationClient({\n appId: appIdOption,\n apiKey: apiKeyOption,\n authMode,\n algoliaAgents,\n region: regionOption,\n ...options\n}: CreateClientOptions & { region: Region }) {\n const auth = createAuth(appIdOption, apiKeyOption, authMode);\n\n return {\n 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 /**\n * The `appId` currently in use.\n */\n appId: appIdOption,\n\n /**\n * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.\n */\n clearCache(): Promise<void> {\n return Promise.all([this.transporter.requestsCache.clear(), this.transporter.responsesCache.clear()]).then(\n () => undefined,\n );\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 this.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 this.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 this.transporter.baseHeaders['x-algolia-api-key'] = apiKey;\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n *\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 this.transporter.request(request, requestOptions);\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n *\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 this.transporter.request(request, requestOptions);\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n *\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 this.transporter.request(request, requestOptions);\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n *\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 this.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 *\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 this.transporter.request(request, requestOptions);\n },\n\n /**\n * Retrieves the current personalization strategy.\n *\n * Required API Key ACLs:\n * - recommendation.\n *\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 this.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 *\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 this.transporter.request(request, requestOptions);\n },\n\n /**\n * Creates a new personalization strategy.\n *\n * Required API Key ACLs:\n * - recommendation.\n *\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.eventScoring) {\n throw new Error(\n 'Parameter `personalizationStrategyParams.eventScoring` is required when calling `setPersonalizationStrategy`.',\n );\n }\n if (!personalizationStrategyParams.facetScoring) {\n throw new Error(\n 'Parameter `personalizationStrategyParams.facetScoring` 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 this.transporter.request(request, requestOptions);\n },\n };\n}\n"],"mappings":";AAGA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;;;ACTnC,SAAS,YAAY,mBAAmB,uBAAuB;AAuBxD,IAAM,mBAAmB;AAEzB,IAAM,UAAU,CAAC,MAAM,IAAI;AAGlC,SAAS,gBAAgB,QAAwB;AAC/C,QAAM,MAAM,uCAAuC,QAAQ,YAAY,MAAM;AAE7E,SAAO,CAAC,EAAE,KAAK,QAAQ,aAAa,UAAU,QAAQ,CAAC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M,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,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 type { ClientOptions } from '@algolia/client-common';\nimport {\n createMemoryCache,\n createFallbackableCache,\n createBrowserLocalStorageCache,\n DEFAULT_CONNECT_TIMEOUT_BROWSER,\n DEFAULT_READ_TIMEOUT_BROWSER,\n DEFAULT_WRITE_TIMEOUT_BROWSER,\n} from '@algolia/client-common';\nimport { createXhrRequester } from '@algolia/requester-browser-xhr';\n\nimport type { Region } from '../src/personalizationClient';\nimport { createPersonalizationClient, apiClientVersion, REGIONS } from '../src/personalizationClient';\n\nexport type PersonalizationClient = ReturnType<typeof createPersonalizationClient>;\n\nexport { apiClientVersion, Region } from '../src/personalizationClient';\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: DEFAULT_CONNECT_TIMEOUT_BROWSER,\n read: DEFAULT_READ_TIMEOUT_BROWSER,\n write: DEFAULT_WRITE_TIMEOUT_BROWSER,\n },\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","// 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 { createAuth, createTransporter, getAlgoliaAgent } from '@algolia/client-common';\nimport type {\n CreateClientOptions,\n Headers,\n Host,\n QueryParameters,\n Request,\n RequestOptions,\n} from '@algolia/client-common';\n\nimport type {\n CustomDeleteProps,\n CustomGetProps,\n CustomPostProps,\n CustomPutProps,\n DeleteUserProfileProps,\n GetUserTokenProfileProps,\n} from '../model/clientMethodProps';\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\nexport const apiClientVersion = '5.3.2';\n\nexport const REGIONS = ['eu', 'us'] as const;\nexport type Region = (typeof REGIONS)[number];\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\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function createPersonalizationClient({\n appId: appIdOption,\n apiKey: apiKeyOption,\n authMode,\n algoliaAgents,\n region: regionOption,\n ...options\n}: CreateClientOptions & { region: Region }) {\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 * 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 *\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 *\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 *\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 *\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 *\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 *\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 *\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 *\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.eventScoring) {\n throw new Error(\n 'Parameter `personalizationStrategyParams.eventScoring` is required when calling `setPersonalizationStrategy`.',\n );\n }\n if (!personalizationStrategyParams.facetScoring) {\n throw new Error(\n 'Parameter `personalizationStrategyParams.facetScoring` 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":";AAGA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;;;ACTnC,SAAS,YAAY,mBAAmB,uBAAuB;AAuBxD,IAAM,mBAAmB;AAEzB,IAAM,UAAU,CAAC,MAAM,IAAI;AAGlC,SAAS,gBAAgB,QAAwB;AAC/C,QAAM,MAAM,uCAAuC,QAAQ,YAAY,MAAM;AAE7E,SAAO,CAAC,EAAE,KAAK,QAAQ,aAAa,UAAU,QAAQ,CAAC;AACzD;AAGO,SAAS,4BAA4B;AAAA,EAC1C,OAAO;AAAA,EACP,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,GAAG;AACL,GAA6C;AAC3C,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,IACA,qBAAqB;AAAA,MACnB,GAAG,KAAK,gBAAgB;AAAA,MACxB,GA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ACxD,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(t,e,s="WithinHeaders"){let r={"x-algolia-api-key":e,"x-algolia-application-id":t};return{headers(){return s==="WithinHeaders"?r:{}},queryParameters(){return s==="WithinQueryParameters"?r:{}}}}function W(t){let e,s=`algolia-client-js-${t.key}`;function r(){return e===void 0&&(e=t.localStorage||window.localStorage),e}function a(){return JSON.parse(r().getItem(s)||"{}")}function l(o){r().setItem(s,JSON.stringify(o))}function p(){let o=t.timeToLive?t.timeToLive*1e3:null,n=a(),u=Object.fromEntries(Object.entries(n).filter(([,d])=>d.timestamp!==void 0));if(l(u),!o)return;let m=Object.fromEntries(Object.entries(u).filter(([,d])=>{let i=new Date().getTime();return!(d.timestamp+o<i)}));l(m)}return{get(o,n,u={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),a()[JSON.stringify(o)])).then(m=>Promise.all([m?m.value:n(),m!==void 0])).then(([m,d])=>Promise.all([m,d||u.miss(m)])).then(([m])=>m)},set(o,n){return Promise.resolve().then(()=>{let u=a();return u[JSON.stringify(o)]={timestamp:new Date().getTime(),value:n},r().setItem(s,JSON.stringify(u)),n})},delete(o){return Promise.resolve().then(()=>{let n=a();delete n[JSON.stringify(o)],r().setItem(s,JSON.stringify(n))})},clear(){return Promise.resolve().then(()=>{r().removeItem(s)})}}}function Y(){return{get(t,e,s={miss:()=>Promise.resolve()}){return e().then(a=>Promise.all([a,s.miss(a)])).then(([a])=>a)},set(t,e){return Promise.resolve(e)},delete(t){return Promise.resolve()},clear(){return Promise.resolve()}}}function R(t){let e=[...t.caches],s=e.shift();return s===void 0?Y():{get(r,a,l={miss:()=>Promise.resolve()}){return s.get(r,a,l).catch(()=>R({caches:e}).get(r,a,l))},set(r,a){return s.set(r,a).catch(()=>R({caches:e}).set(r,a))},delete(r){return s.delete(r).catch(()=>R({caches:e}).delete(r))},clear(){return s.clear().catch(()=>R({caches:e}).clear())}}}function O(t={serializable:!0}){let e={};return{get(s,r,a={miss:()=>Promise.resolve()}){let l=JSON.stringify(s);if(l in e)return Promise.resolve(t.serializable?JSON.parse(e[l]):e[l]);let p=r();return p.then(o=>a.miss(o)).then(()=>p)},set(s,r){return e[JSON.stringify(s)]=t.serializable?JSON.stringify(r):r,Promise.resolve(r)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var I=2*60*1e3;function L(t,e="up"){let s=Date.now();function r(){return e==="up"||Date.now()-s>I}function a(){return e==="timed out"&&Date.now()-s<=I}return{...t,status:e,lastUpdate:s,isUp:r,isTimedOut:a}}var j=class extends Error{name="AlgoliaError";constructor(t,e){super(t),e&&(this.name=e)}},J=class extends j{stackTrace;constructor(t,e,s){super(t,s),this.stackTrace=e}},Z=class extends J{constructor(t){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.",t,"RetryError")}},b=class extends J{status;constructor(t,e,s,r="ApiError"){super(t,s,r),this.status=e}},ee=class extends j{response;constructor(t,e){super(t,"DeserializationError"),this.response=e}},te=class extends b{error;constructor(t,e,s,r){super(t,e,r,"DetailedApiError"),this.error=s}};function re(t,e,s){let r=se(s),a=`${t.protocol}://${t.url}${t.port?`:${t.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return r.length&&(a+=`?${r}`),a}function se(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]).replaceAll("+","%20")}`).join("&")}function oe(t,e){if(t.method==="GET"||t.data===void 0&&e.data===void 0)return;let s=Array.isArray(t.data)?t.data:{...t.data,...e.data};return JSON.stringify(s)}function ae(t,e,s){let r={Accept:"application/json",...t,...e,...s},a={};return Object.keys(r).forEach(l=>{let p=r[l];a[l.toLowerCase()]=p}),a}function ne(t){try{return JSON.parse(t.content)}catch(e){throw new ee(e.message,t)}}function ie({content:t,status:e},s){try{let r=JSON.parse(t);return"error"in r?new te(r.message,e,r.error,s):new b(r.message,e,s)}catch{}return new b(t,e,s)}function ce({isTimedOut:t,status:e}){return!t&&~~e===0}function le({isTimedOut:t,status:e}){return t||ce({isTimedOut:t,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function ue({status:t}){return~~(t/100)===2}function me(t){return t.map(e=>$(e))}function $(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 G({hosts:t,hostsCache:e,baseHeaders:s,baseQueryParameters:r,algoliaAgent:a,timeouts:l,requester:p,requestsCache:o,responsesCache:n}){async function u(i){let c=await Promise.all(i.map(h=>e.get(h,()=>Promise.resolve(L(h))))),P=c.filter(h=>h.isUp()),g=c.filter(h=>h.isTimedOut()),w=[...P,...g];return{hosts:w.length>0?w:i,getTimeout(h,T){return(g.length===0&&h===0?1:g.length+3+h)*T}}}async function m(i,c,P=!0){let g=[],w=oe(i,c),y=ae(s,i.headers,c.headers),h=i.method==="GET"?{...i.data,...c.data}:{},T={...r,...i.queryParameters,...h};if(a.value&&(T["x-algolia-agent"]=a.value),c&&c.queryParameters)for(let f of Object.keys(c.queryParameters))!c.queryParameters[f]||Object.prototype.toString.call(c.queryParameters[f])==="[object Object]"?T[f]=c.queryParameters[f]:T[f]=c.queryParameters[f].toString();let S=0,x=async(f,A)=>{let q=f.pop();if(q===void 0)throw new Z(me(g));let C={...l,...c.timeouts},N={data:w,headers:y,method:i.method,url:re(q,i.path,T),connectTimeout:A(S,C.connect),responseTimeout:A(S,P?C.read:C.write)},k=U=>{let _={request:N,response:U,host:q,triesLeft:f.length};return g.push(_),_},E=await p.send(N);if(le(E)){let U=k(E);return E.isTimedOut&&S++,console.log("Retryable failure",$(U)),await e.set(q,L(q,E.isTimedOut?"timed out":"down")),x(f,A)}if(ue(E))return ne(E);throw k(E),ie(E,g)},V=t.filter(f=>f.accept==="readWrite"||(P?f.accept==="read":f.accept==="write")),D=await u(V);return x([...D.hosts].reverse(),D.getTimeout)}function d(i,c={}){let P=i.useReadTransporter||i.method==="GET";if(!P)return m(i,c,P);let g=()=>m(i,c);if((c.cacheable||i.cacheable)!==!0)return g();let y={request:i,requestOptions:c,transporter:{queryParameters:r,headers:s}};return n.get(y,()=>o.get(y,()=>o.set(y,g()).then(h=>Promise.all([o.delete(y),h]),h=>Promise.all([o.delete(y),Promise.reject(h)])).then(([h,T])=>T)),{miss:h=>n.set(y,h)})}return{hostsCache:e,requester:p,timeouts:l,algoliaAgent:a,baseHeaders:s,baseQueryParameters:r,hosts:t,request:d,requestsCache:o,responsesCache:n}}function he(t){let e={value:`Algolia for JavaScript (${t})`,add(s){let r=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(r)===-1&&(e.value=`${e.value}${r}`),e}};return e}function M({algoliaAgents:t,client:e,version:s}){let r=he(s).add({segment:e,version:s});return t.forEach(a=>r.add(a)),r}var Q=1e3,F=2e3,B=3e4;function X(){function t(e){return new Promise(s=>{let r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach(o=>r.setRequestHeader(o,e.headers[o]));let a=(o,n)=>setTimeout(()=>{r.abort(),s({status:0,content:n,isTimedOut:!0})},o),l=a(e.connectTimeout,"Connection timeout"),p;r.onreadystatechange=()=>{r.readyState>r.OPENED&&p===void 0&&(clearTimeout(l),p=a(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{r.status===0&&(clearTimeout(l),clearTimeout(p),s({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(l),clearTimeout(p),s({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)})}return{send:t}}var v="5.3.0",z=["eu","us"];function pe(t){return[{url:"personalization.{region}.algolia.com".replace("{region}",t),accept:"readWrite",protocol:"https"}]}function K({appId:t,apiKey:e,authMode:s,algoliaAgents:r,region:a,...l}){let p=H(t,e,s);return{transporter:G({hosts:pe(a),...l,algoliaAgent:M({algoliaAgents:r,client:"Personalization",version:v}),baseHeaders:{"content-type":"text/plain",...p.headers(),...l.baseHeaders},baseQueryParameters:{...p.queryParameters(),...l.baseQueryParameters}}),appId:t,clearCache(){return Promise.all([this.transporter.requestsCache.clear(),this.transporter.responsesCache.clear()]).then(()=>{})},get _ua(){return this.transporter.algoliaAgent.value},addAlgoliaAgent(o,n){this.transporter.algoliaAgent.add({segment:o,version:n})},setClientApiKey({apiKey:o}){this.transporter.baseHeaders["x-algolia-api-key"]=o},customDelete({path:o,parameters:n},u){if(!o)throw new Error("Parameter `path` is required when calling `customDelete`.");let c={method:"DELETE",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{}};return this.transporter.request(c,u)},customGet({path:o,parameters:n},u){if(!o)throw new Error("Parameter `path` is required when calling `customGet`.");let c={method:"GET",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{}};return this.transporter.request(c,u)},customPost({path:o,parameters:n,body:u},m){if(!o)throw new Error("Parameter `path` is required when calling `customPost`.");let P={method:"POST",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:u||{}};return this.transporter.request(P,m)},customPut({path:o,parameters:n,body:u},m){if(!o)throw new Error("Parameter `path` is required when calling `customPut`.");let P={method:"PUT",path:"/{path}".replace("{path}",o),queryParameters:n||{},headers:{},data:u||{}};return this.transporter.request(P,m)},deleteUserProfile({userToken:o},n){if(!o)throw new Error("Parameter `userToken` is required when calling `deleteUserProfile`.");let i={method:"DELETE",path:"/1/profiles/{userToken}".replace("{userToken}",encodeURIComponent(o)),queryParameters:{},headers:{}};return this.transporter.request(i,n)},getPersonalizationStrategy(o){let d={method:"GET",path:"/1/strategies/personalization",queryParameters:{},headers:{}};return this.transporter.request(d,o)},getUserTokenProfile({userToken:o},n){if(!o)throw new Error("Parameter `userToken` is required when calling `getUserTokenProfile`.");let i={method:"GET",path:"/1/profiles/personalization/{userToken}".replace("{userToken}",encodeURIComponent(o)),queryParameters:{},headers:{}};return this.transporter.request(i,n)},setPersonalizationStrategy(o,n){if(!o)throw new Error("Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.");if(!o.eventScoring)throw new Error("Parameter `personalizationStrategyParams.eventScoring` is required when calling `setPersonalizationStrategy`.");if(!o.facetScoring)throw new Error("Parameter `personalizationStrategyParams.facetScoring` is required when calling `setPersonalizationStrategy`.");if(!o.personalizationImpact)throw new Error("Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`.");let i={method:"POST",path:"/1/strategies/personalization",queryParameters:{},headers:{},data:o};return this.transporter.request(i,n)}}}function Le(t,e,s,r){if(!t||typeof t!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(!s||s&&(typeof s!="string"||!z.includes(s)))throw new Error(`\`region\` is required and must be one of the following: ${z.join(", ")}`);return K({appId:t,apiKey:e,region:s,timeouts:{connect:Q,read:F,write:B},requester:X(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:R({caches:[W({key:`${v}-${t}`}),O()]}),...r})}export{v as apiClientVersion,Le as personalizationClient};
|
|
1
|
+
function L(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(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function n(){return JSON.parse(t().getItem(o)||"{}")}function m(s){t().setItem(o,JSON.stringify(s))}function h(){let s=r.timeToLive?r.timeToLive*1e3:null,a=n(),i=Object.fromEntries(Object.entries(a).filter(([,p])=>p.timestamp!==void 0));if(m(i),!s)return;let u=Object.fromEntries(Object.entries(i).filter(([,p])=>{let l=new Date().getTime();return!(p.timestamp+s<l)}));m(u)}return{get(s,a,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(h(),n()[JSON.stringify(s)])).then(u=>Promise.all([u?u.value:a(),u!==void 0])).then(([u,p])=>Promise.all([u,p||i.miss(u)])).then(([u])=>u)},set(s,a){return Promise.resolve().then(()=>{let i=n();return i[JSON.stringify(s)]={timestamp:new Date().getTime(),value:a},t().setItem(o,JSON.stringify(i)),a})},delete(s){return Promise.resolve().then(()=>{let a=n();delete a[JSON.stringify(s)],t().setItem(o,JSON.stringify(a))})},clear(){return Promise.resolve().then(()=>{t().removeItem(o)})}}}function Y(){return{get(r,e,o={miss:()=>Promise.resolve()}){return e().then(n=>Promise.all([n,o.miss(n)])).then(([n])=>n)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function R(r){let e=[...r.caches],o=e.shift();return o===void 0?Y():{get(t,n,m={miss:()=>Promise.resolve()}){return o.get(t,n,m).catch(()=>R({caches:e}).get(t,n,m))},set(t,n){return o.set(t,n).catch(()=>R({caches:e}).set(t,n))},delete(t){return o.delete(t).catch(()=>R({caches:e}).delete(t))},clear(){return o.clear().catch(()=>R({caches:e}).clear())}}}function O(r={serializable:!0}){let e={};return{get(o,t,n={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(s=>n.miss(s)).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()}}}var I=2*60*1e3;function H(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>I}function n(){return e==="timed out"&&Date.now()-o<=I}return{...r,status:e,lastUpdate:o,isUp:t,isTimedOut:n}}var j=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}},J=class extends j{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e}},Z=class extends J{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")}},b=class extends J{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e}},ee=class extends j{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},re=class extends b{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o}};function te(r,e,o){let t=oe(o),n=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(n+=`?${t}`),n}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]).replaceAll("+","%20")}`).join("&")}function ae(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 se(r,e,o){let t={Accept:"application/json",...r,...e,...o},n={};return Object.keys(t).forEach(m=>{let h=t[m];n[m.toLowerCase()]=h}),n}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 b(t.message,e,o)}catch{}return new b(r,e,o)}function ce({isTimedOut:r,status:e}){return!r&&~~e===0}function le({isTimedOut:r,status:e}){return r||ce({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function ue({status:r}){return~~(r/100)===2}function me(r){return r.map(e=>$(e))}function $(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 G({hosts:r,hostsCache:e,baseHeaders:o,baseQueryParameters:t,algoliaAgent:n,timeouts:m,requester:h,requestsCache:s,responsesCache:a}){async function i(l){let c=await Promise.all(l.map(d=>e.get(d,()=>Promise.resolve(H(d))))),g=c.filter(d=>d.isUp()),f=c.filter(d=>d.isTimedOut()),w=[...g,...f];return{hosts:w.length>0?w:l,getTimeout(d,T){return(f.length===0&&d===0?1:f.length+3+d)*T}}}async function u(l,c,g=!0){let f=[],w=ae(l,c),y=se(o,l.headers,c.headers),d=l.method==="GET"?{...l.data,...c.data}:{},T={...t,...l.queryParameters,...d};if(n.value&&(T["x-algolia-agent"]=n.value),c&&c.queryParameters)for(let P of Object.keys(c.queryParameters))!c.queryParameters[P]||Object.prototype.toString.call(c.queryParameters[P])==="[object Object]"?T[P]=c.queryParameters[P]:T[P]=c.queryParameters[P].toString();let S=0,z=async(P,A)=>{let q=P.pop();if(q===void 0)throw new Z(me(f));let C={...m,...c.timeouts},N={data:w,headers:y,method:l.method,url:te(q,l.path,T),connectTimeout:A(S,C.connect),responseTimeout:A(S,g?C.read:C.write)},k=U=>{let _={request:N,response:U,host:q,triesLeft:P.length};return f.push(_),_},E=await h.send(N);if(le(E)){let U=k(E);return E.isTimedOut&&S++,console.log("Retryable failure",$(U)),await e.set(q,H(q,E.isTimedOut?"timed out":"down")),z(P,A)}if(ue(E))return ne(E);throw k(E),ie(E,f)},V=r.filter(P=>P.accept==="readWrite"||(g?P.accept==="read":P.accept==="write")),D=await i(V);return z([...D.hosts].reverse(),D.getTimeout)}function p(l,c={}){let g=l.useReadTransporter||l.method==="GET";if(!g)return u(l,c,g);let f=()=>u(l,c);if((c.cacheable||l.cacheable)!==!0)return f();let y={request:l,requestOptions:c,transporter:{queryParameters:t,headers:o}};return a.get(y,()=>s.get(y,()=>s.set(y,f()).then(d=>Promise.all([s.delete(y),d]),d=>Promise.all([s.delete(y),Promise.reject(d)])).then(([d,T])=>T)),{miss:d=>a.set(y,d)})}return{hostsCache:e,requester:h,timeouts:m,algoliaAgent:n,baseHeaders:o,baseQueryParameters:t,hosts:r,request:p,requestsCache:s,responsesCache:a}}function de(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({algoliaAgents:r,client:e,version:o}){let t=de(o).add({segment:e,version:o});return r.forEach(n=>t.add(n)),t}var Q=1e3,F=2e3,B=3e4;function X(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(s=>t.setRequestHeader(s,e.headers[s]));let n=(s,a)=>setTimeout(()=>{t.abort(),o({status:0,content:a,isTimedOut:!0})},s),m=n(e.connectTimeout,"Connection timeout"),h;t.onreadystatechange=()=>{t.readyState>t.OPENED&&h===void 0&&(clearTimeout(m),h=n(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}}var v="5.3.2",x=["eu","us"];function he(r){return[{url:"personalization.{region}.algolia.com".replace("{region}",r),accept:"readWrite",protocol:"https"}]}function K({appId:r,apiKey:e,authMode:o,algoliaAgents:t,region:n,...m}){let h=L(r,e,o),s=G({hosts:he(n),...m,algoliaAgent:M({algoliaAgents:t,client:"Personalization",version:v}),baseHeaders:{"content-type":"text/plain",...h.headers(),...m.baseHeaders},baseQueryParameters:{...h.queryParameters(),...m.baseQueryParameters}});return{transporter:s,appId:r,clearCache(){return Promise.all([s.requestsCache.clear(),s.responsesCache.clear()]).then(()=>{})},get _ua(){return s.algoliaAgent.value},addAlgoliaAgent(a,i){s.algoliaAgent.add({segment:a,version:i})},setClientApiKey({apiKey:a}){!o||o==="WithinHeaders"?s.baseHeaders["x-algolia-api-key"]=a:s.baseQueryParameters["x-algolia-api-key"]=a},customDelete({path:a,parameters:i},u){if(!a)throw new Error("Parameter `path` is required when calling `customDelete`.");let g={method:"DELETE",path:"/{path}".replace("{path}",a),queryParameters:i||{},headers:{}};return s.request(g,u)},customGet({path:a,parameters:i},u){if(!a)throw new Error("Parameter `path` is required when calling `customGet`.");let g={method:"GET",path:"/{path}".replace("{path}",a),queryParameters:i||{},headers:{}};return s.request(g,u)},customPost({path:a,parameters:i,body:u},p){if(!a)throw new Error("Parameter `path` is required when calling `customPost`.");let f={method:"POST",path:"/{path}".replace("{path}",a),queryParameters:i||{},headers:{},data:u||{}};return s.request(f,p)},customPut({path:a,parameters:i,body:u},p){if(!a)throw new Error("Parameter `path` is required when calling `customPut`.");let f={method:"PUT",path:"/{path}".replace("{path}",a),queryParameters:i||{},headers:{},data:u||{}};return s.request(f,p)},deleteUserProfile({userToken:a},i){if(!a)throw new Error("Parameter `userToken` is required when calling `deleteUserProfile`.");let c={method:"DELETE",path:"/1/profiles/{userToken}".replace("{userToken}",encodeURIComponent(a)),queryParameters:{},headers:{}};return s.request(c,i)},getPersonalizationStrategy(a){let l={method:"GET",path:"/1/strategies/personalization",queryParameters:{},headers:{}};return s.request(l,a)},getUserTokenProfile({userToken:a},i){if(!a)throw new Error("Parameter `userToken` is required when calling `getUserTokenProfile`.");let c={method:"GET",path:"/1/profiles/personalization/{userToken}".replace("{userToken}",encodeURIComponent(a)),queryParameters:{},headers:{}};return s.request(c,i)},setPersonalizationStrategy(a,i){if(!a)throw new Error("Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.");if(!a.eventScoring)throw new Error("Parameter `personalizationStrategyParams.eventScoring` is required when calling `setPersonalizationStrategy`.");if(!a.facetScoring)throw new Error("Parameter `personalizationStrategyParams.facetScoring` is required when calling `setPersonalizationStrategy`.");if(!a.personalizationImpact)throw new Error("Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`.");let c={method:"POST",path:"/1/strategies/personalization",queryParameters:{},headers:{},data:a};return s.request(c,i)}}}function He(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"||!x.includes(o)))throw new Error(`\`region\` is required and must be one of the following: ${x.join(", ")}`);return K({appId:r,apiKey:e,region:o,timeouts:{connect:Q,read:F,write:B},requester:X(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:R({caches:[W({key:`${v}-${r}`}),O()]}),...t})}export{v as apiClientVersion,He as personalizationClient};
|
|
2
2
|
//# sourceMappingURL=browser.min.js.map
|