@algolia/client-personalization 5.2.4 → 5.2.5

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.
Files changed (49) hide show
  1. package/dist/browser.d.ts +190 -0
  2. package/dist/builds/browser.js +323 -0
  3. package/dist/builds/browser.js.map +1 -0
  4. package/dist/builds/browser.min.js +2 -0
  5. package/dist/builds/browser.min.js.map +1 -0
  6. package/dist/builds/browser.umd.js +12 -0
  7. package/dist/builds/node.cjs +341 -0
  8. package/dist/builds/node.cjs.map +1 -0
  9. package/dist/builds/node.js +321 -0
  10. package/dist/builds/node.js.map +1 -0
  11. package/dist/node.d.cts +190 -0
  12. package/dist/node.d.ts +190 -0
  13. package/dist/src/personalizationClient.cjs +308 -0
  14. package/dist/src/personalizationClient.cjs.map +1 -0
  15. package/dist/src/personalizationClient.js +281 -0
  16. package/dist/src/personalizationClient.js.map +1 -0
  17. package/index.d.ts +1 -1
  18. package/index.js +1 -1
  19. package/package.json +28 -25
  20. package/dist/builds/browser.d.ts +0 -24
  21. package/dist/builds/browser.d.ts.map +0 -1
  22. package/dist/builds/node.d.ts +0 -24
  23. package/dist/builds/node.d.ts.map +0 -1
  24. package/dist/client-personalization.cjs +0 -297
  25. package/dist/client-personalization.esm.browser.js +0 -971
  26. package/dist/client-personalization.esm.node.js +0 -294
  27. package/dist/client-personalization.umd.js +0 -2
  28. package/dist/model/clientMethodProps.d.ts +0 -79
  29. package/dist/model/clientMethodProps.d.ts.map +0 -1
  30. package/dist/model/deleteUserProfileResponse.d.ts +0 -11
  31. package/dist/model/deleteUserProfileResponse.d.ts.map +0 -1
  32. package/dist/model/errorBase.d.ts +0 -7
  33. package/dist/model/errorBase.d.ts.map +0 -1
  34. package/dist/model/eventScoring.d.ts +0 -13
  35. package/dist/model/eventScoring.d.ts.map +0 -1
  36. package/dist/model/eventType.d.ts +0 -5
  37. package/dist/model/eventType.d.ts.map +0 -1
  38. package/dist/model/facetScoring.d.ts +0 -11
  39. package/dist/model/facetScoring.d.ts.map +0 -1
  40. package/dist/model/getUserTokenResponse.d.ts +0 -15
  41. package/dist/model/getUserTokenResponse.d.ts.map +0 -1
  42. package/dist/model/index.d.ts +0 -10
  43. package/dist/model/index.d.ts.map +0 -1
  44. package/dist/model/personalizationStrategyParams.d.ts +0 -17
  45. package/dist/model/personalizationStrategyParams.d.ts.map +0 -1
  46. package/dist/model/setPersonalizationStrategyResponse.d.ts +0 -7
  47. package/dist/model/setPersonalizationStrategyResponse.d.ts.map +0 -1
  48. package/dist/src/personalizationClient.d.ts +0 -113
  49. package/dist/src/personalizationClient.d.ts.map +0 -1
package/dist/node.d.ts ADDED
@@ -0,0 +1,190 @@
1
+ import * as _algolia_client_common from '@algolia/client-common';
2
+ import { ClientOptions } from '@algolia/client-common';
3
+
4
+ type DeleteUserProfileResponse = {
5
+ /**
6
+ * Unique pseudonymous or anonymous user identifier. This helps with analytics and click and conversion events. For more information, see [user token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
7
+ */
8
+ userToken: string;
9
+ /**
10
+ * Date and time when the user profile can be safely considered to be deleted. Any events received after the `deletedUntil` date start a new user profile.
11
+ */
12
+ deletedUntil: string;
13
+ };
14
+
15
+ /**
16
+ * Error.
17
+ */
18
+ type ErrorBase = Record<string, any> & {
19
+ message?: string;
20
+ };
21
+
22
+ /**
23
+ * Event type.
24
+ */
25
+ type EventType = 'click' | 'conversion' | 'view';
26
+
27
+ type EventScoring = {
28
+ /**
29
+ * Event score.
30
+ */
31
+ score: number;
32
+ /**
33
+ * Event name.
34
+ */
35
+ eventName: string;
36
+ eventType: EventType;
37
+ };
38
+
39
+ type FacetScoring = {
40
+ /**
41
+ * Event score.
42
+ */
43
+ score: number;
44
+ /**
45
+ * Facet attribute name.
46
+ */
47
+ facetName: string;
48
+ };
49
+
50
+ type GetUserTokenResponse = {
51
+ /**
52
+ * Unique pseudonymous or anonymous user identifier. This helps with analytics and click and conversion events. For more information, see [user token](https://www.algolia.com/doc/guides/sending-events/concepts/usertoken/).
53
+ */
54
+ userToken: string;
55
+ /**
56
+ * Date and time of the last event from this user, in RFC 3339 format.
57
+ */
58
+ lastEventAt: string;
59
+ /**
60
+ * Scores for different facet values. Scores represent the user affinity for a user profile towards specific facet values, given the personalization strategy and past events.
61
+ */
62
+ scores: Record<string, unknown>;
63
+ };
64
+
65
+ type PersonalizationStrategyParams = {
66
+ /**
67
+ * Scores associated with each event. The higher the scores, the higher the impact of those events on the personalization of search results.
68
+ */
69
+ eventScoring: EventScoring[];
70
+ /**
71
+ * Scores associated with each facet. The higher the scores, the higher the impact of those events on the personalization of search results.
72
+ */
73
+ facetScoring: FacetScoring[];
74
+ /**
75
+ * Impact of personalization on the search results. If set to 0, personalization has no impact on the search results.
76
+ */
77
+ personalizationImpact: number;
78
+ };
79
+
80
+ type SetPersonalizationStrategyResponse = {
81
+ /**
82
+ * A message confirming the strategy update.
83
+ */
84
+ message: string;
85
+ };
86
+
87
+ /**
88
+ * Properties for the `customDelete` method.
89
+ */
90
+ type CustomDeleteProps = {
91
+ /**
92
+ * Path of the endpoint, anything after \"/1\" must be specified.
93
+ */
94
+ path: string;
95
+ /**
96
+ * Query parameters to apply to the current query.
97
+ */
98
+ parameters?: Record<string, any>;
99
+ };
100
+ /**
101
+ * Properties for the `customGet` method.
102
+ */
103
+ type CustomGetProps = {
104
+ /**
105
+ * Path of the endpoint, anything after \"/1\" must be specified.
106
+ */
107
+ path: string;
108
+ /**
109
+ * Query parameters to apply to the current query.
110
+ */
111
+ parameters?: Record<string, any>;
112
+ };
113
+ /**
114
+ * Properties for the `customPost` method.
115
+ */
116
+ type CustomPostProps = {
117
+ /**
118
+ * Path of the endpoint, anything after \"/1\" must be specified.
119
+ */
120
+ path: string;
121
+ /**
122
+ * Query parameters to apply to the current query.
123
+ */
124
+ parameters?: Record<string, any>;
125
+ /**
126
+ * Parameters to send with the custom request.
127
+ */
128
+ body?: Record<string, unknown>;
129
+ };
130
+ /**
131
+ * Properties for the `customPut` method.
132
+ */
133
+ type CustomPutProps = {
134
+ /**
135
+ * Path of the endpoint, anything after \"/1\" must be specified.
136
+ */
137
+ path: string;
138
+ /**
139
+ * Query parameters to apply to the current query.
140
+ */
141
+ parameters?: Record<string, any>;
142
+ /**
143
+ * Parameters to send with the custom request.
144
+ */
145
+ body?: Record<string, unknown>;
146
+ };
147
+ /**
148
+ * Properties for the `deleteUserProfile` method.
149
+ */
150
+ type DeleteUserProfileProps = {
151
+ /**
152
+ * Unique identifier representing a user for which to fetch the personalization profile.
153
+ */
154
+ userToken: string;
155
+ };
156
+ /**
157
+ * Properties for the `getUserTokenProfile` method.
158
+ */
159
+ type GetUserTokenProfileProps = {
160
+ /**
161
+ * Unique identifier representing a user for which to fetch the personalization profile.
162
+ */
163
+ userToken: string;
164
+ };
165
+
166
+ declare const apiClientVersion = "5.2.5";
167
+ declare const REGIONS: readonly ["eu", "us"];
168
+ type Region = (typeof REGIONS)[number];
169
+
170
+ /**
171
+ * The client type.
172
+ */
173
+ type PersonalizationClient = ReturnType<typeof personalizationClient>;
174
+ declare function personalizationClient(appId: string, apiKey: string, region: Region, options?: ClientOptions): {
175
+ transporter: _algolia_client_common.Transporter;
176
+ appId: string;
177
+ clearCache(): Promise<void>;
178
+ _ua: string;
179
+ addAlgoliaAgent(segment: string, version?: string): void;
180
+ customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
181
+ customGet({ path, parameters }: CustomGetProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
182
+ customPost({ path, parameters, body }: CustomPostProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
183
+ customPut({ path, parameters, body }: CustomPutProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<Record<string, unknown>>;
184
+ deleteUserProfile({ userToken }: DeleteUserProfileProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<DeleteUserProfileResponse>;
185
+ getPersonalizationStrategy(requestOptions?: _algolia_client_common.RequestOptions): Promise<PersonalizationStrategyParams>;
186
+ getUserTokenProfile({ userToken }: GetUserTokenProfileProps, requestOptions?: _algolia_client_common.RequestOptions): Promise<GetUserTokenResponse>;
187
+ setPersonalizationStrategy(personalizationStrategyParams: PersonalizationStrategyParams, requestOptions?: _algolia_client_common.RequestOptions): Promise<SetPersonalizationStrategyResponse>;
188
+ };
189
+
190
+ export { type CustomDeleteProps, type CustomGetProps, type CustomPostProps, type CustomPutProps, type DeleteUserProfileProps, type DeleteUserProfileResponse, type ErrorBase, type EventScoring, type EventType, type FacetScoring, type GetUserTokenProfileProps, type GetUserTokenResponse, type PersonalizationClient, type PersonalizationStrategyParams, type Region, type SetPersonalizationStrategyResponse, apiClientVersion, personalizationClient };
@@ -0,0 +1,308 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/personalizationClient.ts
21
+ var personalizationClient_exports = {};
22
+ __export(personalizationClient_exports, {
23
+ REGIONS: () => REGIONS,
24
+ apiClientVersion: () => apiClientVersion,
25
+ createPersonalizationClient: () => createPersonalizationClient
26
+ });
27
+ module.exports = __toCommonJS(personalizationClient_exports);
28
+ var import_client_common = require("@algolia/client-common");
29
+ var apiClientVersion = "5.2.5";
30
+ var REGIONS = ["eu", "us"];
31
+ function getDefaultHosts(region) {
32
+ const url = "personalization.{region}.algolia.com".replace("{region}", region);
33
+ return [{ url, accept: "readWrite", protocol: "https" }];
34
+ }
35
+ function createPersonalizationClient({
36
+ appId: appIdOption,
37
+ apiKey: apiKeyOption,
38
+ authMode,
39
+ algoliaAgents,
40
+ region: regionOption,
41
+ ...options
42
+ }) {
43
+ const auth = (0, import_client_common.createAuth)(appIdOption, apiKeyOption, authMode);
44
+ const transporter = (0, import_client_common.createTransporter)({
45
+ hosts: getDefaultHosts(regionOption),
46
+ ...options,
47
+ algoliaAgent: (0, import_client_common.getAlgoliaAgent)({
48
+ algoliaAgents,
49
+ client: "Personalization",
50
+ version: apiClientVersion
51
+ }),
52
+ baseHeaders: {
53
+ "content-type": "text/plain",
54
+ ...auth.headers(),
55
+ ...options.baseHeaders
56
+ },
57
+ baseQueryParameters: {
58
+ ...auth.queryParameters(),
59
+ ...options.baseQueryParameters
60
+ }
61
+ });
62
+ return {
63
+ transporter,
64
+ /**
65
+ * The `appId` currently in use.
66
+ */
67
+ appId: appIdOption,
68
+ /**
69
+ * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
70
+ */
71
+ clearCache() {
72
+ return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => void 0);
73
+ },
74
+ /**
75
+ * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
76
+ */
77
+ get _ua() {
78
+ return transporter.algoliaAgent.value;
79
+ },
80
+ /**
81
+ * Adds a `segment` to the `x-algolia-agent` sent with every requests.
82
+ *
83
+ * @param segment - The algolia agent (user-agent) segment to add.
84
+ * @param version - The version of the agent.
85
+ */
86
+ addAlgoliaAgent(segment, version) {
87
+ transporter.algoliaAgent.add({ segment, version });
88
+ },
89
+ /**
90
+ * This method allow you to send requests to the Algolia REST API.
91
+ *
92
+ * @param customDelete - The customDelete object.
93
+ * @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
94
+ * @param customDelete.parameters - Query parameters to apply to the current query.
95
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
96
+ */
97
+ customDelete({ path, parameters }, requestOptions) {
98
+ if (!path) {
99
+ throw new Error("Parameter `path` is required when calling `customDelete`.");
100
+ }
101
+ const requestPath = "/{path}".replace("{path}", path);
102
+ const headers = {};
103
+ const queryParameters = parameters ? parameters : {};
104
+ const request = {
105
+ method: "DELETE",
106
+ path: requestPath,
107
+ queryParameters,
108
+ headers
109
+ };
110
+ return transporter.request(request, requestOptions);
111
+ },
112
+ /**
113
+ * This method allow you to send requests to the Algolia REST API.
114
+ *
115
+ * @param customGet - The customGet object.
116
+ * @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
117
+ * @param customGet.parameters - Query parameters to apply to the current query.
118
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
119
+ */
120
+ customGet({ path, parameters }, requestOptions) {
121
+ if (!path) {
122
+ throw new Error("Parameter `path` is required when calling `customGet`.");
123
+ }
124
+ const requestPath = "/{path}".replace("{path}", path);
125
+ const headers = {};
126
+ const queryParameters = parameters ? parameters : {};
127
+ const request = {
128
+ method: "GET",
129
+ path: requestPath,
130
+ queryParameters,
131
+ headers
132
+ };
133
+ return transporter.request(request, requestOptions);
134
+ },
135
+ /**
136
+ * This method allow you to send requests to the Algolia REST API.
137
+ *
138
+ * @param customPost - The customPost object.
139
+ * @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
140
+ * @param customPost.parameters - Query parameters to apply to the current query.
141
+ * @param customPost.body - Parameters to send with the custom request.
142
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
143
+ */
144
+ customPost({ path, parameters, body }, requestOptions) {
145
+ if (!path) {
146
+ throw new Error("Parameter `path` is required when calling `customPost`.");
147
+ }
148
+ const requestPath = "/{path}".replace("{path}", path);
149
+ const headers = {};
150
+ const queryParameters = parameters ? parameters : {};
151
+ const request = {
152
+ method: "POST",
153
+ path: requestPath,
154
+ queryParameters,
155
+ headers,
156
+ data: body ? body : {}
157
+ };
158
+ return transporter.request(request, requestOptions);
159
+ },
160
+ /**
161
+ * This method allow you to send requests to the Algolia REST API.
162
+ *
163
+ * @param customPut - The customPut object.
164
+ * @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
165
+ * @param customPut.parameters - Query parameters to apply to the current query.
166
+ * @param customPut.body - Parameters to send with the custom request.
167
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
168
+ */
169
+ customPut({ path, parameters, body }, requestOptions) {
170
+ if (!path) {
171
+ throw new Error("Parameter `path` is required when calling `customPut`.");
172
+ }
173
+ const requestPath = "/{path}".replace("{path}", path);
174
+ const headers = {};
175
+ const queryParameters = parameters ? parameters : {};
176
+ const request = {
177
+ method: "PUT",
178
+ path: requestPath,
179
+ queryParameters,
180
+ headers,
181
+ data: body ? body : {}
182
+ };
183
+ return transporter.request(request, requestOptions);
184
+ },
185
+ /**
186
+ * Deletes a user profile. The response includes a date and time when the user profile can safely be considered deleted.
187
+ *
188
+ * Required API Key ACLs:
189
+ * - recommendation.
190
+ *
191
+ * @param deleteUserProfile - The deleteUserProfile object.
192
+ * @param deleteUserProfile.userToken - Unique identifier representing a user for which to fetch the personalization profile.
193
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
194
+ */
195
+ deleteUserProfile({ userToken }, requestOptions) {
196
+ if (!userToken) {
197
+ throw new Error("Parameter `userToken` is required when calling `deleteUserProfile`.");
198
+ }
199
+ const requestPath = "/1/profiles/{userToken}".replace("{userToken}", encodeURIComponent(userToken));
200
+ const headers = {};
201
+ const queryParameters = {};
202
+ const request = {
203
+ method: "DELETE",
204
+ path: requestPath,
205
+ queryParameters,
206
+ headers
207
+ };
208
+ return transporter.request(request, requestOptions);
209
+ },
210
+ /**
211
+ * Retrieves the current personalization strategy.
212
+ *
213
+ * Required API Key ACLs:
214
+ * - recommendation.
215
+ *
216
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
217
+ */
218
+ getPersonalizationStrategy(requestOptions) {
219
+ const requestPath = "/1/strategies/personalization";
220
+ const headers = {};
221
+ const queryParameters = {};
222
+ const request = {
223
+ method: "GET",
224
+ path: requestPath,
225
+ queryParameters,
226
+ headers
227
+ };
228
+ return transporter.request(request, requestOptions);
229
+ },
230
+ /**
231
+ * Retrieves a user profile and their affinities for different facets.
232
+ *
233
+ * Required API Key ACLs:
234
+ * - recommendation.
235
+ *
236
+ * @param getUserTokenProfile - The getUserTokenProfile object.
237
+ * @param getUserTokenProfile.userToken - Unique identifier representing a user for which to fetch the personalization profile.
238
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
239
+ */
240
+ getUserTokenProfile({ userToken }, requestOptions) {
241
+ if (!userToken) {
242
+ throw new Error("Parameter `userToken` is required when calling `getUserTokenProfile`.");
243
+ }
244
+ const requestPath = "/1/profiles/personalization/{userToken}".replace(
245
+ "{userToken}",
246
+ encodeURIComponent(userToken)
247
+ );
248
+ const headers = {};
249
+ const queryParameters = {};
250
+ const request = {
251
+ method: "GET",
252
+ path: requestPath,
253
+ queryParameters,
254
+ headers
255
+ };
256
+ return transporter.request(request, requestOptions);
257
+ },
258
+ /**
259
+ * Creates a new personalization strategy.
260
+ *
261
+ * Required API Key ACLs:
262
+ * - recommendation.
263
+ *
264
+ * @param personalizationStrategyParams - The personalizationStrategyParams object.
265
+ * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
266
+ */
267
+ setPersonalizationStrategy(personalizationStrategyParams, requestOptions) {
268
+ if (!personalizationStrategyParams) {
269
+ throw new Error(
270
+ "Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`."
271
+ );
272
+ }
273
+ if (!personalizationStrategyParams.eventScoring) {
274
+ throw new Error(
275
+ "Parameter `personalizationStrategyParams.eventScoring` is required when calling `setPersonalizationStrategy`."
276
+ );
277
+ }
278
+ if (!personalizationStrategyParams.facetScoring) {
279
+ throw new Error(
280
+ "Parameter `personalizationStrategyParams.facetScoring` is required when calling `setPersonalizationStrategy`."
281
+ );
282
+ }
283
+ if (!personalizationStrategyParams.personalizationImpact) {
284
+ throw new Error(
285
+ "Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`."
286
+ );
287
+ }
288
+ const requestPath = "/1/strategies/personalization";
289
+ const headers = {};
290
+ const queryParameters = {};
291
+ const request = {
292
+ method: "POST",
293
+ path: requestPath,
294
+ queryParameters,
295
+ headers,
296
+ data: personalizationStrategyParams
297
+ };
298
+ return transporter.request(request, requestOptions);
299
+ }
300
+ };
301
+ }
302
+ // Annotate the CommonJS export names for ESM import in node:
303
+ 0 && (module.exports = {
304
+ REGIONS,
305
+ apiClientVersion,
306
+ createPersonalizationClient
307
+ });
308
+ //# sourceMappingURL=personalizationClient.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../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 { 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.2.5';\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 * 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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,2BAA+D;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,WAAO,iCAAW,aAAa,cAAc,QAAQ;AAC3D,QAAM,kBAAc,wCAAkB;AAAA,IACpC,OAAO,gBAAgB,YAAY;AAAA,IACnC,GAAG;AAAA,IACH,kBAAc,sCAAgB;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,GAAG,QAAQ;AAAA,IACb;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL;AAAA;AAAA;AAAA;AAAA,IAKA,OAAO;AAAA;AAAA;AAAA;AAAA,IAKP,aAA4B;AAC1B,aAAO,QAAQ,IAAI,CAAC,YAAY,cAAc,MAAM,GAAG,YAAY,eAAe,MAAM,CAAC,CAAC,EAAE,KAAK,MAAM,MAAS;AAAA,IAClH;AAAA;AAAA;AAAA;AAAA,IAKA,IAAI,MAAc;AAChB,aAAO,YAAY,a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