@algolia/client-personalization 5.3.1 → 5.4.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/dist/browser.d.ts +1 -1
- package/dist/builds/browser.js +33 -34
- 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/fetch.js +334 -0
- package/dist/builds/fetch.js.map +1 -0
- package/dist/builds/node.cjs +33 -34
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +33 -34
- package/dist/builds/node.js.map +1 -1
- package/dist/fetch.d.ts +286 -0
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/src/personalizationClient.cjs +33 -34
- package/dist/src/personalizationClient.cjs.map +1 -1
- package/dist/src/personalizationClient.js +33 -34
- package/dist/src/personalizationClient.js.map +1 -1
- package/package.json +9 -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.
|
|
159
|
+
declare const apiClientVersion = "5.4.0";
|
|
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.
|
|
14
|
+
var apiClientVersion = "5.4.0";
|
|
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.
|
|
@@ -80,9 +79,9 @@ function createPersonalizationClient({
|
|
|
80
79
|
*/
|
|
81
80
|
setClientApiKey({ apiKey }) {
|
|
82
81
|
if (!authMode || authMode === "WithinHeaders") {
|
|
83
|
-
|
|
82
|
+
transporter.baseHeaders["x-algolia-api-key"] = apiKey;
|
|
84
83
|
} else {
|
|
85
|
-
|
|
84
|
+
transporter.baseQueryParameters["x-algolia-api-key"] = apiKey;
|
|
86
85
|
}
|
|
87
86
|
},
|
|
88
87
|
/**
|
|
@@ -106,7 +105,7 @@ function createPersonalizationClient({
|
|
|
106
105
|
queryParameters,
|
|
107
106
|
headers
|
|
108
107
|
};
|
|
109
|
-
return
|
|
108
|
+
return transporter.request(request, requestOptions);
|
|
110
109
|
},
|
|
111
110
|
/**
|
|
112
111
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -129,7 +128,7 @@ function createPersonalizationClient({
|
|
|
129
128
|
queryParameters,
|
|
130
129
|
headers
|
|
131
130
|
};
|
|
132
|
-
return
|
|
131
|
+
return transporter.request(request, requestOptions);
|
|
133
132
|
},
|
|
134
133
|
/**
|
|
135
134
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -154,7 +153,7 @@ function createPersonalizationClient({
|
|
|
154
153
|
headers,
|
|
155
154
|
data: body ? body : {}
|
|
156
155
|
};
|
|
157
|
-
return
|
|
156
|
+
return transporter.request(request, requestOptions);
|
|
158
157
|
},
|
|
159
158
|
/**
|
|
160
159
|
* This method allow you to send requests to the Algolia REST API.
|
|
@@ -179,7 +178,7 @@ function createPersonalizationClient({
|
|
|
179
178
|
headers,
|
|
180
179
|
data: body ? body : {}
|
|
181
180
|
};
|
|
182
|
-
return
|
|
181
|
+
return transporter.request(request, requestOptions);
|
|
183
182
|
},
|
|
184
183
|
/**
|
|
185
184
|
* Deletes a user profile. The response includes a date and time when the user profile can safely be considered deleted.
|
|
@@ -204,7 +203,7 @@ function createPersonalizationClient({
|
|
|
204
203
|
queryParameters,
|
|
205
204
|
headers
|
|
206
205
|
};
|
|
207
|
-
return
|
|
206
|
+
return transporter.request(request, requestOptions);
|
|
208
207
|
},
|
|
209
208
|
/**
|
|
210
209
|
* Retrieves the current personalization strategy.
|
|
@@ -224,7 +223,7 @@ function createPersonalizationClient({
|
|
|
224
223
|
queryParameters,
|
|
225
224
|
headers
|
|
226
225
|
};
|
|
227
|
-
return
|
|
226
|
+
return transporter.request(request, requestOptions);
|
|
228
227
|
},
|
|
229
228
|
/**
|
|
230
229
|
* Retrieves a user profile and their affinities for different facets.
|
|
@@ -252,7 +251,7 @@ function createPersonalizationClient({
|
|
|
252
251
|
queryParameters,
|
|
253
252
|
headers
|
|
254
253
|
};
|
|
255
|
-
return
|
|
254
|
+
return transporter.request(request, requestOptions);
|
|
256
255
|
},
|
|
257
256
|
/**
|
|
258
257
|
* Creates a new personalization strategy.
|
|
@@ -294,7 +293,7 @@ function createPersonalizationClient({
|
|
|
294
293
|
headers,
|
|
295
294
|
data: personalizationStrategyParams
|
|
296
295
|
};
|
|
297
|
-
return
|
|
296
|
+
return transporter.request(request, requestOptions);
|
|
298
297
|
}
|
|
299
298
|
};
|
|
300
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.1';\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 if (!authMode || authMode === 'WithinHeaders') {\n this.transporter.baseHeaders['x-algolia-api-key'] = apiKey;\n } else {\n this.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 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,u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;AACF;;;ADhWO,SAAS,sBACd,OACA,QACA,QACA,SACuB;AACvB,MAAI,CAAC,SAAS,OAAO,UAAU,UAAU;AACvC,UAAM,IAAI,MAAM,qBAAqB;AAAA,EACvC;AAEA,MAAI,CAAC,UAAU,OAAO,WAAW,UAAU;AACzC,UAAM,IAAI,MAAM,sBAAsB;AAAA,EACxC;AAEA,MAAI,CAAC,UAAW,WAAW,OAAO,WAAW,YAAY,CAAC,QAAQ,SAAS,MAAM,IAAK;AACpF,UAAM,IAAI,MAAM,4DAA4D,QAAQ,KAAK,IAAI,CAAC,EAAE;AAAA,EAClG;AAEA,SAAO,4BAA4B;AAAA,IACjC;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,MACR,SAAS;AAAA,MACT,MAAM;AAAA,MACN,OAAO;AAAA,IACT;AAAA,IACA,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.4.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 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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ACN,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,2 +1,2 @@
|
|
|
1
|
-
function L(r,e,s="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return{headers(){return s==="WithinHeaders"?t:{}},queryParameters(){return s==="WithinQueryParameters"?t:{}}}}function W(r){let e,s=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function a(){return JSON.parse(t().getItem(s)||"{}")}function l(o){t().setItem(s,JSON.stringify(o))}function p(){let o=r.timeToLive?r.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},t().setItem(s,JSON.stringify(u)),n})},delete(o){return Promise.resolve().then(()=>{let n=a();delete n[JSON.stringify(o)],t().setItem(s,JSON.stringify(n))})},clear(){return Promise.resolve().then(()=>{t().removeItem(s)})}}}function Y(){return{get(r,e,s={miss:()=>Promise.resolve()}){return e().then(a=>Promise.all([a,s.miss(a)])).then(([a])=>a)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function R(r){let e=[...r.caches],s=e.shift();return s===void 0?Y():{get(t,a,l={miss:()=>Promise.resolve()}){return s.get(t,a,l).catch(()=>R({caches:e}).get(t,a,l))},set(t,a){return s.set(t,a).catch(()=>R({caches:e}).set(t,a))},delete(t){return s.delete(t).catch(()=>R({caches:e}).delete(t))},clear(){return s.clear().catch(()=>R({caches:e}).clear())}}}function O(r={serializable:!0}){let e={};return{get(s,t,a={miss:()=>Promise.resolve()}){let l=JSON.stringify(s);if(l in e)return Promise.resolve(r.serializable?JSON.parse(e[l]):e[l]);let p=t();return p.then(o=>a.miss(o)).then(()=>p)},set(s,t){return e[JSON.stringify(s)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(s){return delete e[JSON.stringify(s)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var I=2*60*1e3;function H(r,e="up"){let s=Date.now();function t(){return e==="up"||Date.now()-s>I}function a(){return e==="timed out"&&Date.now()-s<=I}return{...r,status:e,lastUpdate:s,isUp:t,isTimedOut:a}}var j=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}},J=class extends j{stackTrace;constructor(r,e,s){super(r,s),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,s,t="ApiError"){super(r,s,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,s,t){super(r,e,t,"DetailedApiError"),this.error=s}};function te(r,e,s){let t=se(s),a=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(a+=`?${t}`),a}function se(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 oe(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let s=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(s)}function ae(r,e,s){let t={Accept:"application/json",...r,...e,...s},a={};return Object.keys(t).forEach(l=>{let p=t[l];a[l.toLowerCase()]=p}),a}function ne(r){try{return JSON.parse(r.content)}catch(e){throw new ee(e.message,r)}}function ie({content:r,status:e},s){try{let t=JSON.parse(r);return"error"in t?new re(t.message,e,t.error,s):new b(t.message,e,s)}catch{}return new b(r,e,s)}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:s,baseQueryParameters:t,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(H(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={...t,...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,z=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:te(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,H(q,E.isTimedOut?"timed out":"down")),z(f,A)}if(ue(E))return ne(E);throw k(E),ie(E,g)},V=r.filter(f=>f.accept==="readWrite"||(P?f.accept==="read":f.accept==="write")),D=await u(V);return z([...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:t,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:t,hosts:r,request:d,requestsCache:o,responsesCache:n}}function he(r){let e={value:`Algolia for JavaScript (${r})`,add(s){let t=`; ${s.segment}${s.version!==void 0?` (${s.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function M({algoliaAgents:r,client:e,version:s}){let t=he(s).add({segment:e,version:s});return r.forEach(a=>t.add(a)),t}var Q=1e3,F=2e3,B=3e4;function X(){function r(e){return new Promise(s=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(o=>t.setRequestHeader(o,e.headers[o]));let a=(o,n)=>setTimeout(()=>{t.abort(),s({status:0,content:n,isTimedOut:!0})},o),l=a(e.connectTimeout,"Connection timeout"),p;t.onreadystatechange=()=>{t.readyState>t.OPENED&&p===void 0&&(clearTimeout(l),p=a(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(l),clearTimeout(p),s({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(l),clearTimeout(p),s({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}var v="5.3.1",x=["eu","us"];function pe(r){return[{url:"personalization.{region}.algolia.com".replace("{region}",r),accept:"readWrite",protocol:"https"}]}function K({appId:r,apiKey:e,authMode:s,algoliaAgents:t,region:a,...l}){let p=L(r,e,s);return{transporter:G({hosts:pe(a),...l,algoliaAgent:M({algoliaAgents:t,client:"Personalization",version:v}),baseHeaders:{"content-type":"text/plain",...p.headers(),...l.baseHeaders},baseQueryParameters:{...p.queryParameters(),...l.baseQueryParameters}}),appId:r,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}){!s||s==="WithinHeaders"?this.transporter.baseHeaders["x-algolia-api-key"]=o:this.transporter.baseQueryParameters["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 He(r,e,s,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(!s||s&&(typeof s!="string"||!x.includes(s)))throw new Error(`\`region\` is required and must be one of the following: ${x.join(", ")}`);return K({appId:r,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}-${r}`}),O()]}),...t})}export{v as apiClientVersion,He as personalizationClient};
|
|
1
|
+
function W(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 L(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(a){t().setItem(o,JSON.stringify(a))}function p(){let a=r.timeToLive?r.timeToLive*1e3:null,s=n(),i=Object.fromEntries(Object.entries(s).filter(([,h])=>h.timestamp!==void 0));if(m(i),!a)return;let u=Object.fromEntries(Object.entries(i).filter(([,h])=>{let l=new Date().getTime();return!(h.timestamp+a<l)}));m(u)}return{get(a,s,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),n()[JSON.stringify(a)])).then(u=>Promise.all([u?u.value:s(),u!==void 0])).then(([u,h])=>Promise.all([u,h||i.miss(u)])).then(([u])=>u)},set(a,s){return Promise.resolve().then(()=>{let i=n();return i[JSON.stringify(a)]={timestamp:new Date().getTime(),value:s},t().setItem(o,JSON.stringify(i)),s})},delete(a){return Promise.resolve().then(()=>{let s=n();delete s[JSON.stringify(a)],t().setItem(o,JSON.stringify(s))})},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 p=t();return p.then(a=>n.miss(a)).then(()=>p)},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 $=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}},j=class extends ${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 ${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 se(r,e){if(r.method==="GET"||r.data===void 0&&e.data===void 0)return;let o=Array.isArray(r.data)?r.data:{...r.data,...e.data};return JSON.stringify(o)}function ae(r,e,o){let t={Accept:"application/json",...r,...e,...o},n={};return Object.keys(t).forEach(m=>{let p=t[m];n[m.toLowerCase()]=p}),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=>G(e))}function G(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 J({hosts:r,hostsCache:e,baseHeaders:o,baseQueryParameters:t,algoliaAgent:n,timeouts:m,requester:p,requestsCache:a,responsesCache:s}){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()),P=c.filter(d=>d.isTimedOut()),w=[...g,...P];return{hosts:w.length>0?w:l,getTimeout(d,T){return(P.length===0&&d===0?1:P.length+3+d)*T}}}async function u(l,c,g=!0){let P=[],w=se(l,c),y=ae(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 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(P));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:f.length};return P.push(_),_},E=await p.send(N);if(le(E)){let U=k(E);return E.isTimedOut&&S++,console.log("Retryable failure",G(U)),await e.set(q,H(q,E.isTimedOut?"timed out":"down")),x(f,A)}if(ue(E))return ne(E);throw k(E),ie(E,P)},V=r.filter(f=>f.accept==="readWrite"||(g?f.accept==="read":f.accept==="write")),D=await i(V);return x([...D.hosts].reverse(),D.getTimeout)}function h(l,c={}){let g=l.useReadTransporter||l.method==="GET";if(!g)return u(l,c,g);let P=()=>u(l,c);if((c.cacheable||l.cacheable)!==!0)return P();let y={request:l,requestOptions:c,transporter:{queryParameters:t,headers:o}};return s.get(y,()=>a.get(y,()=>a.set(y,P()).then(d=>Promise.all([a.delete(y),d]),d=>Promise.all([a.delete(y),Promise.reject(d)])).then(([d,T])=>T)),{miss:d=>s.set(y,d)})}return{hostsCache:e,requester:p,timeouts:m,algoliaAgent:n,baseHeaders:o,baseQueryParameters:t,hosts:r,request:h,requestsCache:a,responsesCache:s}}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(a=>t.setRequestHeader(a,e.headers[a]));let n=(a,s)=>setTimeout(()=>{t.abort(),o({status:0,content:s,isTimedOut:!0})},a),m=n(e.connectTimeout,"Connection timeout"),p;t.onreadystatechange=()=>{t.readyState>t.OPENED&&p===void 0&&(clearTimeout(m),p=n(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(m),clearTimeout(p),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(m),clearTimeout(p),o({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}var v="5.4.0",z=["eu","us"];function pe(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 p=W(r,e,o),a=J({hosts:pe(n),...m,algoliaAgent:M({algoliaAgents:t,client:"Personalization",version:v}),baseHeaders:{"content-type":"text/plain",...p.headers(),...m.baseHeaders},baseQueryParameters:{...p.queryParameters(),...m.baseQueryParameters}});return{transporter:a,appId:r,clearCache(){return Promise.all([a.requestsCache.clear(),a.responsesCache.clear()]).then(()=>{})},get _ua(){return a.algoliaAgent.value},addAlgoliaAgent(s,i){a.algoliaAgent.add({segment:s,version:i})},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?a.baseHeaders["x-algolia-api-key"]=s:a.baseQueryParameters["x-algolia-api-key"]=s},customDelete({path:s,parameters:i},u){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let g={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return a.request(g,u)},customGet({path:s,parameters:i},u){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let g={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return a.request(g,u)},customPost({path:s,parameters:i,body:u},h){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let P={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:u||{}};return a.request(P,h)},customPut({path:s,parameters:i,body:u},h){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let P={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:u||{}};return a.request(P,h)},deleteUserProfile({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `deleteUserProfile`.");let c={method:"DELETE",path:"/1/profiles/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(c,i)},getPersonalizationStrategy(s){let l={method:"GET",path:"/1/strategies/personalization",queryParameters:{},headers:{}};return a.request(l,s)},getUserTokenProfile({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `getUserTokenProfile`.");let c={method:"GET",path:"/1/profiles/personalization/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return a.request(c,i)},setPersonalizationStrategy(s,i){if(!s)throw new Error("Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.");if(!s.eventScoring)throw new Error("Parameter `personalizationStrategyParams.eventScoring` is required when calling `setPersonalizationStrategy`.");if(!s.facetScoring)throw new Error("Parameter `personalizationStrategyParams.facetScoring` is required when calling `setPersonalizationStrategy`.");if(!s.personalizationImpact)throw new Error("Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`.");let c={method:"POST",path:"/1/strategies/personalization",queryParameters:{},headers:{},data:s};return a.request(c,i)}}}function _e(r,e,o,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(!o||o&&(typeof o!="string"||!z.includes(o)))throw new Error(`\`region\` is required and must be one of the following: ${z.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:[L({key:`${v}-${r}`}),O()]}),...t})}export{v as apiClientVersion,_e as personalizationClient};
|
|
2
2
|
//# sourceMappingURL=browser.min.js.map
|