@algolia/client-personalization 5.7.0 → 5.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -6
- package/dist/browser.d.ts +94 -95
- package/dist/builds/browser.js +9 -17
- 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 +6 -14
- package/dist/builds/fetch.js.map +1 -1
- package/dist/builds/node.cjs +6 -14
- package/dist/builds/node.cjs.map +1 -1
- package/dist/builds/node.js +7 -15
- package/dist/builds/node.js.map +1 -1
- package/dist/fetch.d.ts +93 -93
- package/dist/node.d.cts +93 -93
- package/dist/node.d.ts +93 -93
- package/dist/src/personalizationClient.cjs +5 -13
- package/dist/src/personalizationClient.cjs.map +1 -1
- package/dist/src/personalizationClient.js +5 -13
- package/dist/src/personalizationClient.js.map +1 -1
- package/index.d.ts +0 -1
- package/index.js +1 -2
- package/model/clientMethodProps.ts +4 -4
- package/model/index.ts +1 -1
- package/model/personalizationStrategyParams.ts +2 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -40,13 +40,12 @@ All of our clients comes with type definition, and are available for both browse
|
|
|
40
40
|
|
|
41
41
|
### With a package manager
|
|
42
42
|
|
|
43
|
-
|
|
44
43
|
```bash
|
|
45
|
-
yarn add @algolia/client-personalization@5.
|
|
44
|
+
yarn add @algolia/client-personalization@5.8.1
|
|
46
45
|
# or
|
|
47
|
-
npm install @algolia/client-personalization@5.
|
|
46
|
+
npm install @algolia/client-personalization@5.8.1
|
|
48
47
|
# or
|
|
49
|
-
pnpm add @algolia/client-personalization@5.
|
|
48
|
+
pnpm add @algolia/client-personalization@5.8.1
|
|
50
49
|
```
|
|
51
50
|
|
|
52
51
|
### Without a package manager
|
|
@@ -54,7 +53,7 @@ pnpm add @algolia/client-personalization@5.7.0
|
|
|
54
53
|
Add the following JavaScript snippet to the <head> of your website:
|
|
55
54
|
|
|
56
55
|
```html
|
|
57
|
-
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-personalization@5.
|
|
56
|
+
<script src="https://cdn.jsdelivr.net/npm/@algolia/client-personalization@5.8.1/dist/builds/browser.umd.js"></script>
|
|
58
57
|
```
|
|
59
58
|
|
|
60
59
|
### Usage
|
|
@@ -75,4 +74,4 @@ Encountering an issue? Before reaching out to support, we recommend heading to o
|
|
|
75
74
|
|
|
76
75
|
## 📄 License
|
|
77
76
|
|
|
78
|
-
The Algolia JavaScript API Client is an open-sourced software licensed under the [MIT license](LICENSE).
|
|
77
|
+
The Algolia JavaScript API Client is an open-sourced software licensed under the [MIT license](LICENSE).
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,6 +1,82 @@
|
|
|
1
1
|
import * as _algolia_client_common from '@algolia/client-common';
|
|
2
2
|
import { CreateClientOptions, RequestOptions, ClientOptions } from '@algolia/client-common';
|
|
3
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
|
+
type GetUserTokenResponse = {
|
|
16
|
+
/**
|
|
17
|
+
* 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/).
|
|
18
|
+
*/
|
|
19
|
+
userToken: string;
|
|
20
|
+
/**
|
|
21
|
+
* Date and time of the last event from this user, in RFC 3339 format.
|
|
22
|
+
*/
|
|
23
|
+
lastEventAt: string;
|
|
24
|
+
/**
|
|
25
|
+
* 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.
|
|
26
|
+
*/
|
|
27
|
+
scores: Record<string, unknown>;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Event type.
|
|
32
|
+
*/
|
|
33
|
+
type EventType = 'click' | 'conversion' | 'view';
|
|
34
|
+
|
|
35
|
+
type EventScoring = {
|
|
36
|
+
/**
|
|
37
|
+
* Event score.
|
|
38
|
+
*/
|
|
39
|
+
score: number;
|
|
40
|
+
/**
|
|
41
|
+
* Event name.
|
|
42
|
+
*/
|
|
43
|
+
eventName: string;
|
|
44
|
+
eventType: EventType;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
type FacetScoring = {
|
|
48
|
+
/**
|
|
49
|
+
* Event score.
|
|
50
|
+
*/
|
|
51
|
+
score: number;
|
|
52
|
+
/**
|
|
53
|
+
* Facet attribute name.
|
|
54
|
+
*/
|
|
55
|
+
facetName: string;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
type PersonalizationStrategyParams = {
|
|
59
|
+
/**
|
|
60
|
+
* Scores associated with each event. The higher the scores, the higher the impact of those events on the personalization of search results.
|
|
61
|
+
*/
|
|
62
|
+
eventScoring: Array<EventScoring>;
|
|
63
|
+
/**
|
|
64
|
+
* Scores associated with each facet. The higher the scores, the higher the impact of those events on the personalization of search results.
|
|
65
|
+
*/
|
|
66
|
+
facetScoring: Array<FacetScoring>;
|
|
67
|
+
/**
|
|
68
|
+
* Impact of personalization on the search results. If set to 0, personalization has no impact on the search results.
|
|
69
|
+
*/
|
|
70
|
+
personalizationImpact: number;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
type SetPersonalizationStrategyResponse = {
|
|
74
|
+
/**
|
|
75
|
+
* A message confirming the strategy update.
|
|
76
|
+
*/
|
|
77
|
+
message: string;
|
|
78
|
+
};
|
|
79
|
+
|
|
4
80
|
/**
|
|
5
81
|
* Properties for the `customDelete` method.
|
|
6
82
|
*/
|
|
@@ -12,7 +88,9 @@ type CustomDeleteProps = {
|
|
|
12
88
|
/**
|
|
13
89
|
* Query parameters to apply to the current query.
|
|
14
90
|
*/
|
|
15
|
-
parameters?:
|
|
91
|
+
parameters?: {
|
|
92
|
+
[key: string]: any;
|
|
93
|
+
};
|
|
16
94
|
};
|
|
17
95
|
/**
|
|
18
96
|
* Properties for the `customGet` method.
|
|
@@ -25,7 +103,9 @@ type CustomGetProps = {
|
|
|
25
103
|
/**
|
|
26
104
|
* Query parameters to apply to the current query.
|
|
27
105
|
*/
|
|
28
|
-
parameters?:
|
|
106
|
+
parameters?: {
|
|
107
|
+
[key: string]: any;
|
|
108
|
+
};
|
|
29
109
|
};
|
|
30
110
|
/**
|
|
31
111
|
* Properties for the `customPost` method.
|
|
@@ -38,7 +118,9 @@ type CustomPostProps = {
|
|
|
38
118
|
/**
|
|
39
119
|
* Query parameters to apply to the current query.
|
|
40
120
|
*/
|
|
41
|
-
parameters?:
|
|
121
|
+
parameters?: {
|
|
122
|
+
[key: string]: any;
|
|
123
|
+
};
|
|
42
124
|
/**
|
|
43
125
|
* Parameters to send with the custom request.
|
|
44
126
|
*/
|
|
@@ -55,7 +137,9 @@ type CustomPutProps = {
|
|
|
55
137
|
/**
|
|
56
138
|
* Query parameters to apply to the current query.
|
|
57
139
|
*/
|
|
58
|
-
parameters?:
|
|
140
|
+
parameters?: {
|
|
141
|
+
[key: string]: any;
|
|
142
|
+
};
|
|
59
143
|
/**
|
|
60
144
|
* Parameters to send with the custom request.
|
|
61
145
|
*/
|
|
@@ -80,83 +164,7 @@ type GetUserTokenProfileProps = {
|
|
|
80
164
|
userToken: string;
|
|
81
165
|
};
|
|
82
166
|
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* 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/).
|
|
86
|
-
*/
|
|
87
|
-
userToken: string;
|
|
88
|
-
/**
|
|
89
|
-
* 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.
|
|
90
|
-
*/
|
|
91
|
-
deletedUntil: string;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
type GetUserTokenResponse = {
|
|
95
|
-
/**
|
|
96
|
-
* 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/).
|
|
97
|
-
*/
|
|
98
|
-
userToken: string;
|
|
99
|
-
/**
|
|
100
|
-
* Date and time of the last event from this user, in RFC 3339 format.
|
|
101
|
-
*/
|
|
102
|
-
lastEventAt: string;
|
|
103
|
-
/**
|
|
104
|
-
* 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.
|
|
105
|
-
*/
|
|
106
|
-
scores: Record<string, unknown>;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Event type.
|
|
111
|
-
*/
|
|
112
|
-
type EventType = 'click' | 'conversion' | 'view';
|
|
113
|
-
|
|
114
|
-
type EventScoring = {
|
|
115
|
-
/**
|
|
116
|
-
* Event score.
|
|
117
|
-
*/
|
|
118
|
-
score: number;
|
|
119
|
-
/**
|
|
120
|
-
* Event name.
|
|
121
|
-
*/
|
|
122
|
-
eventName: string;
|
|
123
|
-
eventType: EventType;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
type FacetScoring = {
|
|
127
|
-
/**
|
|
128
|
-
* Event score.
|
|
129
|
-
*/
|
|
130
|
-
score: number;
|
|
131
|
-
/**
|
|
132
|
-
* Facet attribute name.
|
|
133
|
-
*/
|
|
134
|
-
facetName: string;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
type PersonalizationStrategyParams = {
|
|
138
|
-
/**
|
|
139
|
-
* Scores associated with each event. The higher the scores, the higher the impact of those events on the personalization of search results.
|
|
140
|
-
*/
|
|
141
|
-
eventScoring: EventScoring[];
|
|
142
|
-
/**
|
|
143
|
-
* Scores associated with each facet. The higher the scores, the higher the impact of those events on the personalization of search results.
|
|
144
|
-
*/
|
|
145
|
-
facetScoring: FacetScoring[];
|
|
146
|
-
/**
|
|
147
|
-
* Impact of personalization on the search results. If set to 0, personalization has no impact on the search results.
|
|
148
|
-
*/
|
|
149
|
-
personalizationImpact: number;
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
type SetPersonalizationStrategyResponse = {
|
|
153
|
-
/**
|
|
154
|
-
* A message confirming the strategy update.
|
|
155
|
-
*/
|
|
156
|
-
message: string;
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
declare const apiClientVersion = "5.7.0";
|
|
167
|
+
declare const apiClientVersion = "5.8.1";
|
|
160
168
|
declare const REGIONS: readonly ["eu", "us"];
|
|
161
169
|
type Region = (typeof REGIONS)[number];
|
|
162
170
|
declare function createPersonalizationClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & {
|
|
@@ -193,7 +201,6 @@ declare function createPersonalizationClient({ appId: appIdOption, apiKey: apiKe
|
|
|
193
201
|
}): void;
|
|
194
202
|
/**
|
|
195
203
|
* This method allow you to send requests to the Algolia REST API.
|
|
196
|
-
*
|
|
197
204
|
* @param customDelete - The customDelete object.
|
|
198
205
|
* @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
199
206
|
* @param customDelete.parameters - Query parameters to apply to the current query.
|
|
@@ -202,7 +209,6 @@ declare function createPersonalizationClient({ appId: appIdOption, apiKey: apiKe
|
|
|
202
209
|
customDelete({ path, parameters }: CustomDeleteProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
|
|
203
210
|
/**
|
|
204
211
|
* This method allow you to send requests to the Algolia REST API.
|
|
205
|
-
*
|
|
206
212
|
* @param customGet - The customGet object.
|
|
207
213
|
* @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
208
214
|
* @param customGet.parameters - Query parameters to apply to the current query.
|
|
@@ -211,7 +217,6 @@ declare function createPersonalizationClient({ appId: appIdOption, apiKey: apiKe
|
|
|
211
217
|
customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
|
|
212
218
|
/**
|
|
213
219
|
* This method allow you to send requests to the Algolia REST API.
|
|
214
|
-
*
|
|
215
220
|
* @param customPost - The customPost object.
|
|
216
221
|
* @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
217
222
|
* @param customPost.parameters - Query parameters to apply to the current query.
|
|
@@ -221,7 +226,6 @@ declare function createPersonalizationClient({ appId: appIdOption, apiKey: apiKe
|
|
|
221
226
|
customPost({ path, parameters, body }: CustomPostProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>>;
|
|
222
227
|
/**
|
|
223
228
|
* This method allow you to send requests to the Algolia REST API.
|
|
224
|
-
*
|
|
225
229
|
* @param customPut - The customPut object.
|
|
226
230
|
* @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
227
231
|
* @param customPut.parameters - Query parameters to apply to the current query.
|
|
@@ -233,8 +237,7 @@ declare function createPersonalizationClient({ appId: appIdOption, apiKey: apiKe
|
|
|
233
237
|
* Deletes a user profile. The response includes a date and time when the user profile can safely be considered deleted.
|
|
234
238
|
*
|
|
235
239
|
* Required API Key ACLs:
|
|
236
|
-
*
|
|
237
|
-
*
|
|
240
|
+
* - recommendation
|
|
238
241
|
* @param deleteUserProfile - The deleteUserProfile object.
|
|
239
242
|
* @param deleteUserProfile.userToken - Unique identifier representing a user for which to fetch the personalization profile.
|
|
240
243
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
@@ -244,8 +247,7 @@ declare function createPersonalizationClient({ appId: appIdOption, apiKey: apiKe
|
|
|
244
247
|
* Retrieves the current personalization strategy.
|
|
245
248
|
*
|
|
246
249
|
* Required API Key ACLs:
|
|
247
|
-
*
|
|
248
|
-
*
|
|
250
|
+
* - recommendation
|
|
249
251
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
250
252
|
*/
|
|
251
253
|
getPersonalizationStrategy(requestOptions?: RequestOptions): Promise<PersonalizationStrategyParams>;
|
|
@@ -253,8 +255,7 @@ declare function createPersonalizationClient({ appId: appIdOption, apiKey: apiKe
|
|
|
253
255
|
* Retrieves a user profile and their affinities for different facets.
|
|
254
256
|
*
|
|
255
257
|
* Required API Key ACLs:
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
+
* - recommendation
|
|
258
259
|
* @param getUserTokenProfile - The getUserTokenProfile object.
|
|
259
260
|
* @param getUserTokenProfile.userToken - Unique identifier representing a user for which to fetch the personalization profile.
|
|
260
261
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
@@ -264,8 +265,7 @@ declare function createPersonalizationClient({ appId: appIdOption, apiKey: apiKe
|
|
|
264
265
|
* Creates a new personalization strategy.
|
|
265
266
|
*
|
|
266
267
|
* Required API Key ACLs:
|
|
267
|
-
*
|
|
268
|
-
*
|
|
268
|
+
* - recommendation
|
|
269
269
|
* @param personalizationStrategyParams - The personalizationStrategyParams object.
|
|
270
270
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
271
271
|
*/
|
|
@@ -279,8 +279,7 @@ type ErrorBase = Record<string, any> & {
|
|
|
279
279
|
message?: string;
|
|
280
280
|
};
|
|
281
281
|
|
|
282
|
-
type PersonalizationClient = ReturnType<typeof createPersonalizationClient>;
|
|
283
|
-
|
|
284
282
|
declare function personalizationClient(appId: string, apiKey: string, region: Region, options?: ClientOptions): PersonalizationClient;
|
|
283
|
+
type PersonalizationClient = ReturnType<typeof createPersonalizationClient>;
|
|
285
284
|
|
|
286
285
|
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 };
|
package/dist/builds/browser.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
// builds/browser.ts
|
|
2
|
+
import { createXhrRequester } from "@algolia/requester-browser-xhr";
|
|
2
3
|
import {
|
|
3
|
-
createNullLogger,
|
|
4
|
-
createMemoryCache,
|
|
5
|
-
createFallbackableCache,
|
|
6
4
|
createBrowserLocalStorageCache,
|
|
5
|
+
createFallbackableCache,
|
|
6
|
+
createMemoryCache,
|
|
7
|
+
createNullLogger,
|
|
7
8
|
DEFAULT_CONNECT_TIMEOUT_BROWSER,
|
|
8
9
|
DEFAULT_READ_TIMEOUT_BROWSER,
|
|
9
10
|
DEFAULT_WRITE_TIMEOUT_BROWSER
|
|
10
11
|
} from "@algolia/client-common";
|
|
11
|
-
import { createXhrRequester } from "@algolia/requester-browser-xhr";
|
|
12
12
|
|
|
13
13
|
// src/personalizationClient.ts
|
|
14
14
|
import { createAuth, createTransporter, getAlgoliaAgent } from "@algolia/client-common";
|
|
15
|
-
var apiClientVersion = "5.
|
|
15
|
+
var apiClientVersion = "5.8.1";
|
|
16
16
|
var REGIONS = ["eu", "us"];
|
|
17
17
|
function getDefaultHosts(region) {
|
|
18
18
|
const url = "personalization.{region}.algolia.com".replace("{region}", region);
|
|
@@ -87,7 +87,6 @@ function createPersonalizationClient({
|
|
|
87
87
|
},
|
|
88
88
|
/**
|
|
89
89
|
* This method allow you to send requests to the Algolia REST API.
|
|
90
|
-
*
|
|
91
90
|
* @param customDelete - The customDelete object.
|
|
92
91
|
* @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
93
92
|
* @param customDelete.parameters - Query parameters to apply to the current query.
|
|
@@ -110,7 +109,6 @@ function createPersonalizationClient({
|
|
|
110
109
|
},
|
|
111
110
|
/**
|
|
112
111
|
* This method allow you to send requests to the Algolia REST API.
|
|
113
|
-
*
|
|
114
112
|
* @param customGet - The customGet object.
|
|
115
113
|
* @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
116
114
|
* @param customGet.parameters - Query parameters to apply to the current query.
|
|
@@ -133,7 +131,6 @@ function createPersonalizationClient({
|
|
|
133
131
|
},
|
|
134
132
|
/**
|
|
135
133
|
* This method allow you to send requests to the Algolia REST API.
|
|
136
|
-
*
|
|
137
134
|
* @param customPost - The customPost object.
|
|
138
135
|
* @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
139
136
|
* @param customPost.parameters - Query parameters to apply to the current query.
|
|
@@ -158,7 +155,6 @@ function createPersonalizationClient({
|
|
|
158
155
|
},
|
|
159
156
|
/**
|
|
160
157
|
* This method allow you to send requests to the Algolia REST API.
|
|
161
|
-
*
|
|
162
158
|
* @param customPut - The customPut object.
|
|
163
159
|
* @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
|
|
164
160
|
* @param customPut.parameters - Query parameters to apply to the current query.
|
|
@@ -185,8 +181,7 @@ function createPersonalizationClient({
|
|
|
185
181
|
* Deletes a user profile. The response includes a date and time when the user profile can safely be considered deleted.
|
|
186
182
|
*
|
|
187
183
|
* Required API Key ACLs:
|
|
188
|
-
*
|
|
189
|
-
*
|
|
184
|
+
* - recommendation
|
|
190
185
|
* @param deleteUserProfile - The deleteUserProfile object.
|
|
191
186
|
* @param deleteUserProfile.userToken - Unique identifier representing a user for which to fetch the personalization profile.
|
|
192
187
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
@@ -210,8 +205,7 @@ function createPersonalizationClient({
|
|
|
210
205
|
* Retrieves the current personalization strategy.
|
|
211
206
|
*
|
|
212
207
|
* Required API Key ACLs:
|
|
213
|
-
*
|
|
214
|
-
*
|
|
208
|
+
* - recommendation
|
|
215
209
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
216
210
|
*/
|
|
217
211
|
getPersonalizationStrategy(requestOptions) {
|
|
@@ -230,8 +224,7 @@ function createPersonalizationClient({
|
|
|
230
224
|
* Retrieves a user profile and their affinities for different facets.
|
|
231
225
|
*
|
|
232
226
|
* Required API Key ACLs:
|
|
233
|
-
*
|
|
234
|
-
*
|
|
227
|
+
* - recommendation
|
|
235
228
|
* @param getUserTokenProfile - The getUserTokenProfile object.
|
|
236
229
|
* @param getUserTokenProfile.userToken - Unique identifier representing a user for which to fetch the personalization profile.
|
|
237
230
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
@@ -258,8 +251,7 @@ function createPersonalizationClient({
|
|
|
258
251
|
* Creates a new personalization strategy.
|
|
259
252
|
*
|
|
260
253
|
* Required API Key ACLs:
|
|
261
|
-
*
|
|
262
|
-
*
|
|
254
|
+
* - recommendation
|
|
263
255
|
* @param personalizationStrategyParams - The personalizationStrategyParams object.
|
|
264
256
|
* @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
|
|
265
257
|
*/
|
|
@@ -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 createNullLogger,\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 logger: createNullLogger(),\n requester: createXhrRequester(),\n algoliaAgents: [{ segment: 'Browser' }],\n authMode: 'WithinQueryParameters',\n responsesCache: createMemoryCache(),\n requestsCache: createMemoryCache({ serializable: false }),\n hostsCache: createFallbackableCache({\n caches: [createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }), createMemoryCache()],\n }),\n ...options,\n });\n}\n","// 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.7.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,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;;;ACVnC,SAAS,YAAY,mBAAmB,uBAAuB;AAuBxD,IAAM,mBAAmB;AAEzB,IAAM,UAAU,CAAC,MAAM,IAAI;AAGlC,SAAS,gBAAgB,QAAwB;AAC/C,QAAM,MAAM,uCAAuC,QAAQ,YAAY,MAAM;AAE7E,SAAO,CAAC,EAAE,KAAK,QAAQ,aAAa,UAAU,QAAQ,CAAC;AACzD;AAGO,SAAS,4BAA4B;AAAA,EAC1C,OAAO;AAAA,EACP,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR,GAAG;AACL,GAA6C;AAC3C,QAAM,OAAO,WAAW,aAAa,cAAc,QAAQ;AAC3D,QAAM,cAAc,kBAAkB;AAAA,IACpC,OAAO,gBAAgB,YAAY;AAAA,IACnC,GAAG;AAAA,IACH,cAAc,gBAAgB;AAAA,MAC5B;AAAA,MACA,QAAQ;AAAA,MACR,SAAS;AAAA,IACX,CAAC;AAAA,IACD,aAAa;AAAA,MACX,gBAAgB;AAAA,MAChB,GAAG,KAAK,QAAQ;AAAA,MAChB,GAAG,QAAQ;AAAA,IACb;AAAA,IACA,qBAAqB;AAAA,MACnB,GAAG,KAAK,gBAAgB;AAAA,MACxB,GAAG,QAAQ;AA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,CAAC;AAAA,IACxD,YAAY,wBAAwB;AAAA,MAClC,QAAQ,CAAC,+BAA+B,EAAE,KAAK,GAAG,gBAAgB,IAAI,KAAK,GAAG,CAAC,GAAG,kBAAkB,CAAC;AAAA,IACvG,CAAC;AAAA,IACD,GAAG;AAAA,EACL,CAAC;AACH;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../builds/browser.ts","../../src/personalizationClient.ts"],"sourcesContent":["// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.\n\nimport { createXhrRequester } from '@algolia/requester-browser-xhr';\n\nimport {\n ClientOptions,\n createBrowserLocalStorageCache,\n createFallbackableCache,\n createMemoryCache,\n createNullLogger,\n DEFAULT_CONNECT_TIMEOUT_BROWSER,\n DEFAULT_READ_TIMEOUT_BROWSER,\n DEFAULT_WRITE_TIMEOUT_BROWSER,\n} from '@algolia/client-common';\n\nimport { apiClientVersion, createPersonalizationClient } from '../src/personalizationClient';\n\nimport { Region, REGIONS } from '../src/personalizationClient';\n\nexport * from '../model';\nexport { apiClientVersion, Region } from '../src/personalizationClient';\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 logger: createNullLogger(),\n requester: createXhrRequester(),\n algoliaAgents: [{ segment: 'Browser' }],\n authMode: 'WithinQueryParameters',\n responsesCache: createMemoryCache(),\n requestsCache: createMemoryCache({ serializable: false }),\n hostsCache: createFallbackableCache({\n caches: [createBrowserLocalStorageCache({ key: `${apiClientVersion}-${appId}` }), createMemoryCache()],\n }),\n ...options,\n });\n}\n\nexport type PersonalizationClient = ReturnType<typeof createPersonalizationClient>;\n","// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.\n\nimport type {\n CreateClientOptions,\n Headers,\n Host,\n QueryParameters,\n Request,\n RequestOptions,\n} from '@algolia/client-common';\nimport { createAuth, createTransporter, getAlgoliaAgent } from '@algolia/client-common';\n\nimport type { DeleteUserProfileResponse } from '../model/deleteUserProfileResponse';\n\nimport type { GetUserTokenResponse } from '../model/getUserTokenResponse';\nimport type { PersonalizationStrategyParams } from '../model/personalizationStrategyParams';\nimport type { SetPersonalizationStrategyResponse } from '../model/setPersonalizationStrategyResponse';\n\nimport type {\n CustomDeleteProps,\n CustomGetProps,\n CustomPostProps,\n CustomPutProps,\n DeleteUserProfileProps,\n GetUserTokenProfileProps,\n} from '../model/clientMethodProps';\n\nexport const apiClientVersion = '5.8.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\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 * @param customDelete - The customDelete object.\n * @param customDelete.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customDelete.parameters - Query parameters to apply to the current query.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customDelete(\n { path, parameters }: CustomDeleteProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customDelete`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'DELETE',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n * @param customGet - The customGet object.\n * @param customGet.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customGet.parameters - Query parameters to apply to the current query.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customGet({ path, parameters }: CustomGetProps, requestOptions?: RequestOptions): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customGet`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'GET',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n * @param customPost - The customPost object.\n * @param customPost.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customPost.parameters - Query parameters to apply to the current query.\n * @param customPost.body - Parameters to send with the custom request.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customPost(\n { path, parameters, body }: CustomPostProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customPost`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'POST',\n path: requestPath,\n queryParameters,\n headers,\n data: body ? body : {},\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * This method allow you to send requests to the Algolia REST API.\n * @param customPut - The customPut object.\n * @param customPut.path - Path of the endpoint, anything after \\\"/1\\\" must be specified.\n * @param customPut.parameters - Query parameters to apply to the current query.\n * @param customPut.body - Parameters to send with the custom request.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n customPut(\n { path, parameters, body }: CustomPutProps,\n requestOptions?: RequestOptions,\n ): Promise<Record<string, unknown>> {\n if (!path) {\n throw new Error('Parameter `path` is required when calling `customPut`.');\n }\n\n const requestPath = '/{path}'.replace('{path}', path);\n const headers: Headers = {};\n const queryParameters: QueryParameters = parameters ? parameters : {};\n\n const request: Request = {\n method: 'PUT',\n path: requestPath,\n queryParameters,\n headers,\n data: body ? body : {},\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * Deletes a user profile. The response includes a date and time when the user profile can safely be considered deleted.\n *\n * Required API Key ACLs:\n * - recommendation\n * @param deleteUserProfile - The deleteUserProfile object.\n * @param deleteUserProfile.userToken - Unique identifier representing a user for which to fetch the personalization profile.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n deleteUserProfile(\n { userToken }: DeleteUserProfileProps,\n requestOptions?: RequestOptions,\n ): Promise<DeleteUserProfileResponse> {\n if (!userToken) {\n throw new Error('Parameter `userToken` is required when calling `deleteUserProfile`.');\n }\n\n const requestPath = '/1/profiles/{userToken}'.replace('{userToken}', encodeURIComponent(userToken));\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'DELETE',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * Retrieves the current personalization strategy.\n *\n * Required API Key ACLs:\n * - recommendation\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n getPersonalizationStrategy(requestOptions?: RequestOptions): Promise<PersonalizationStrategyParams> {\n const requestPath = '/1/strategies/personalization';\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'GET',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * Retrieves a user profile and their affinities for different facets.\n *\n * Required API Key ACLs:\n * - recommendation\n * @param getUserTokenProfile - The getUserTokenProfile object.\n * @param getUserTokenProfile.userToken - Unique identifier representing a user for which to fetch the personalization profile.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n getUserTokenProfile(\n { userToken }: GetUserTokenProfileProps,\n requestOptions?: RequestOptions,\n ): Promise<GetUserTokenResponse> {\n if (!userToken) {\n throw new Error('Parameter `userToken` is required when calling `getUserTokenProfile`.');\n }\n\n const requestPath = '/1/profiles/personalization/{userToken}'.replace(\n '{userToken}',\n encodeURIComponent(userToken),\n );\n const headers: Headers = {};\n const queryParameters: QueryParameters = {};\n\n const request: Request = {\n method: 'GET',\n path: requestPath,\n queryParameters,\n headers,\n };\n\n return transporter.request(request, requestOptions);\n },\n\n /**\n * Creates a new personalization strategy.\n *\n * Required API Key ACLs:\n * - recommendation\n * @param personalizationStrategyParams - The personalizationStrategyParams object.\n * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.\n */\n setPersonalizationStrategy(\n personalizationStrategyParams: PersonalizationStrategyParams,\n requestOptions?: RequestOptions,\n ): Promise<SetPersonalizationStrategyResponse> {\n if (!personalizationStrategyParams) {\n throw new Error(\n 'Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.',\n );\n }\n\n if (!personalizationStrategyParams.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":";AAEA,SAAS,0BAA0B;AAEnC;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACHP,SAAS,YAAY,mBAAmB,uBAAu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sBACd,OACA,QACA,QACA,SACuB;AACvB,MAAI,CAAC,SAAS,OAAO,UAAU,UAAU;AACvC,UAAM,IAAI,MAAM,qBAAqB;AAAA,EACvC;AAEA,MAAI,CAAC,UAAU,OAAO,WAAW,UAAU;AACzC,UAAM,IAAI,MAAM,sBAAsB;AAAA,EACxC;AAEA,MAAI,CAAC,UAAW,WAAW,OAAO,WAAW,YAAY,CAAC,QAAQ,SAAS,MAAM,IAAK;AACpF,UAAM,IAAI,MAAM,4DAA4D,QAAQ,KAAK,IAAI,CAAC,EAAE;AAAA,EAClG;AAEA,SAAO,4BAA4B;AAAA,IACjC;AAAA,IACA;AAAA,IACA;AAAA,IACA,UAAU;AAAA,MACR,SAAS;AAAA,MACT,MAAM;AAAA,MACN,OAAO;AAAA,IACT;AAAA,IACA,QAAQ,iBAAiB;AAAA,IACzB,WAAW,mBAAmB;AAAA,IAC9B,eAAe,CAAC,EAAE,SAAS,UAAU,CAAC;AAAA,IACtC,UAAU;AAAA,IACV,gBAAgB,kBAAkB;AAAA,IAClC,eAAe,kBAAkB,EAAE,cAAc,MAAM,CAAC;AAAA,IACxD,YAAY,wBAAwB;AAAA,MAClC,QAAQ,CAAC,+BAA+B,EAAE,KAAK,GAAG,gBAAgB,IAAI,KAAK,GAAG,CAAC,GAAG,kBAAkB,CAAC;AAAA,IACvG,CAAC;AAAA,IACD,GAAG;AAAA,EACL,CAAC;AACH;","names":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function W(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function a(){return JSON.parse(t().getItem(o)||"{}")}function m(n){t().setItem(o,JSON.stringify(n))}function h(){let n=r.timeToLive?r.timeToLive*1e3:null,s=a(),i=Object.fromEntries(Object.entries(s).filter(([,d])=>d.timestamp!==void 0));if(m(i),!n)return;let u=Object.fromEntries(Object.entries(i).filter(([,d])=>{let f=new Date().getTime();return!(d.timestamp+n<f)}));m(u)}return{get(n,s,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(h(),a()[JSON.stringify(n)])).then(u=>Promise.all([u?u.value:s(),u!==void 0])).then(([u,d])=>Promise.all([u,d||i.miss(u)])).then(([u])=>u)},set(n,s){return Promise.resolve().then(()=>{let i=a();return i[JSON.stringify(n)]={timestamp:new Date().getTime(),value:s},t().setItem(o,JSON.stringify(i)),s})},delete(n){return Promise.resolve().then(()=>{let s=a();delete s[JSON.stringify(n)],t().setItem(o,JSON.stringify(s))})},clear(){return Promise.resolve().then(()=>{t().removeItem(o)})}}}function ee(){return{get(r,e,o={miss:()=>Promise.resolve()}){return e().then(a=>Promise.all([a,o.miss(a)])).then(([a])=>a)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function w(r){let e=[...r.caches],o=e.shift();return o===void 0?ee():{get(t,a,m={miss:()=>Promise.resolve()}){return o.get(t,a,m).catch(()=>w({caches:e}).get(t,a,m))},set(t,a){return o.set(t,a).catch(()=>w({caches:e}).set(t,a))},delete(t){return o.delete(t).catch(()=>w({caches:e}).delete(t))},clear(){return o.clear().catch(()=>w({caches:e}).clear())}}}function O(r={serializable:!0}){let e={};return{get(o,t,a={miss:()=>Promise.resolve()}){let m=JSON.stringify(o);if(m in e)return Promise.resolve(r.serializable?JSON.parse(e[m]):e[m]);let h=t();return h.then(n=>a.miss(n)).then(()=>h)},set(o,t){return e[JSON.stringify(o)]=r.serializable?JSON.stringify(t):t,Promise.resolve(t)},delete(o){return delete e[JSON.stringify(o)],Promise.resolve()},clear(){return e={},Promise.resolve()}}}var $=1e3,j=2e3,G=3e4;function re(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 J(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 M({algoliaAgents:r,client:e,version:o}){let t=re(o).add({segment:e,version:o});return r.forEach(a=>t.add(a)),t}function Q(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var L=2*60*1e3;function H(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>L}function a(){return e==="timed out"&&Date.now()-o<=L}return{...r,status:e,lastUpdate:o,isUp:t,isTimedOut:a}}var F=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}},B=class extends F{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e}},te=class extends B{constructor(r){super("Unreachable hosts - your application id may be incorrect. If the error persists, please reach out to the Algolia Support team: https://alg.li/support.",r,"RetryError")}},z=class extends B{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e}},oe=class extends F{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},se=class extends z{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o}};function ae(r,e,o){let t=ne(o),a=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(a+=`?${t}`),a}function ne(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 ie(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 ce(r,e,o){let t={Accept:"application/json",...r,...e,...o},a={};return Object.keys(t).forEach(m=>{let h=t[m];a[m.toLowerCase()]=h}),a}function ue(r){try{return JSON.parse(r.content)}catch(e){throw new oe(e.message,r)}}function le({content:r,status:e},o){try{let t=JSON.parse(r);return"error"in t?new se(t.message,e,t.error,o):new z(t.message,e,o)}catch{}return new z(r,e,o)}function me({isTimedOut:r,status:e}){return!r&&~~e===0}function de({isTimedOut:r,status:e}){return r||me({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function pe({status:r}){return~~(r/100)===2}function he(r){return r.map(e=>X(e))}function X(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 K({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:a,algoliaAgent:m,timeouts:h,requester:n,requestsCache:s,responsesCache:i}){async function u(c){let l=await Promise.all(c.map(p=>e.get(p,()=>Promise.resolve(H(p))))),g=l.filter(p=>p.isUp()),y=l.filter(p=>p.isTimedOut()),q=[...g,...y];return{hosts:q.length>0?q:c,getTimeout(p,E){return(y.length===0&&p===0?1:y.length+3+p)*E}}}async function d(c,l,g=!0){let y=[],q=ie(c,l),T=ce(o,c.headers,l.headers),p=c.method==="GET"?{...c.data,...l.data}:{},E={...a,...c.queryParameters,...p};if(m.value&&(E["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let P of Object.keys(l.queryParameters))!l.queryParameters[P]||Object.prototype.toString.call(l.queryParameters[P])==="[object Object]"?E[P]=l.queryParameters[P]:E[P]=l.queryParameters[P].toString();let S=0,D=async(P,C)=>{let v=P.pop();if(v===void 0)throw new te(he(y));let b={...h,...l.timeouts},N={data:q,headers:T,method:c.method,url:ae(v,c.path,E),connectTimeout:C(S,b.connect),responseTimeout:C(S,g?b.read:b.write)},k=U=>{let I={request:N,response:U,host:v,triesLeft:P.length};return y.push(I),I},R=await n.send(N);if(de(R)){let U=k(R);return R.isTimedOut&&S++,t.info("Retryable failure",X(U)),await e.set(v,H(v,R.isTimedOut?"timed out":"down")),D(P,C)}if(pe(R))return ue(R);throw k(R),le(R,y)},Z=r.filter(P=>P.accept==="readWrite"||(g?P.accept==="read":P.accept==="write")),_=await u(Z);return D([..._.hosts].reverse(),_.getTimeout)}function f(c,l={}){let g=c.useReadTransporter||c.method==="GET";if(!g)return d(c,l,g);let y=()=>d(c,l);if((l.cacheable||c.cacheable)!==!0)return y();let T={request:c,requestOptions:l,transporter:{queryParameters:a,headers:o}};return i.get(T,()=>s.get(T,()=>s.set(T,y()).then(p=>Promise.all([s.delete(T),p]),p=>Promise.all([s.delete(T),Promise.reject(p)])).then(([p,E])=>E)),{miss:p=>i.set(T,p)})}return{hostsCache:e,requester:n,timeouts:h,logger:t,algoliaAgent:m,baseHeaders:o,baseQueryParameters:a,hosts:r,request:f,requestsCache:s,responsesCache:i}}function V(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(n=>t.setRequestHeader(n,e.headers[n]));let a=(n,s)=>setTimeout(()=>{t.abort(),o({status:0,content:s,isTimedOut:!0})},n),m=a(e.connectTimeout,"Connection timeout"),h;t.onreadystatechange=()=>{t.readyState>t.OPENED&&h===void 0&&(clearTimeout(m),h=a(e.responseTimeout,"Socket timeout"))},t.onerror=()=>{t.status===0&&(clearTimeout(m),clearTimeout(h),o({content:t.responseText||"Network request failed",status:t.status,isTimedOut:!1}))},t.onload=()=>{clearTimeout(m),clearTimeout(h),o({content:t.responseText,status:t.status,isTimedOut:!1})},t.send(e.data)})}return{send:r}}var A="5.7.0",x=["eu","us"];function Pe(r){return[{url:"personalization.{region}.algolia.com".replace("{region}",r),accept:"readWrite",protocol:"https"}]}function Y({appId:r,apiKey:e,authMode:o,algoliaAgents:t,region:a,...m}){let h=J(r,e,o),n=K({hosts:Pe(a),...m,algoliaAgent:M({algoliaAgents:t,client:"Personalization",version:A}),baseHeaders:{"content-type":"text/plain",...h.headers(),...m.baseHeaders},baseQueryParameters:{...h.queryParameters(),...m.baseQueryParameters}});return{transporter:n,appId:r,clearCache(){return Promise.all([n.requestsCache.clear(),n.responsesCache.clear()]).then(()=>{})},get _ua(){return n.algoliaAgent.value},addAlgoliaAgent(s,i){n.algoliaAgent.add({segment:s,version:i})},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?n.baseHeaders["x-algolia-api-key"]=s:n.baseQueryParameters["x-algolia-api-key"]=s},customDelete({path:s,parameters:i},u){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return n.request(l,u)},customGet({path:s,parameters:i},u){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return n.request(l,u)},customPost({path:s,parameters:i,body:u},d){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:u||{}};return n.request(g,d)},customPut({path:s,parameters:i,body:u},d){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:u||{}};return n.request(g,d)},deleteUserProfile({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `deleteUserProfile`.");let c={method:"DELETE",path:"/1/profiles/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return n.request(c,i)},getPersonalizationStrategy(s){let f={method:"GET",path:"/1/strategies/personalization",queryParameters:{},headers:{}};return n.request(f,s)},getUserTokenProfile({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `getUserTokenProfile`.");let c={method:"GET",path:"/1/profiles/personalization/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return n.request(c,i)},setPersonalizationStrategy(s,i){if(!s)throw new Error("Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.");if(!s.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 n.request(c,i)}}}function Le(r,e,o,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(!o||o&&(typeof o!="string"||!x.includes(o)))throw new Error(`\`region\` is required and must be one of the following: ${x.join(", ")}`);return Y({appId:r,apiKey:e,region:o,timeouts:{connect:$,read:j,write:G},logger:Q(),requester:V(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:w({caches:[W({key:`${A}-${r}`}),O()]}),...t})}export{A as apiClientVersion,Le as personalizationClient};
|
|
1
|
+
function L(){function r(e){return new Promise(o=>{let t=new XMLHttpRequest;t.open(e.method,e.url,!0),Object.keys(e.headers).forEach(n=>t.setRequestHeader(n,e.headers[n]));let a=(n,s)=>setTimeout(()=>{t.abort(),o({status:0,content:s,isTimedOut:!0})},n),m=a(e.connectTimeout,"Connection timeout"),p;t.onreadystatechange=()=>{t.readyState>t.OPENED&&p===void 0&&(clearTimeout(m),p=a(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}}function $(r){let e,o=`algolia-client-js-${r.key}`;function t(){return e===void 0&&(e=r.localStorage||window.localStorage),e}function a(){return JSON.parse(t().getItem(o)||"{}")}function m(n){t().setItem(o,JSON.stringify(n))}function p(){let n=r.timeToLive?r.timeToLive*1e3:null,s=a(),i=Object.fromEntries(Object.entries(s).filter(([,d])=>d.timestamp!==void 0));if(m(i),!n)return;let u=Object.fromEntries(Object.entries(i).filter(([,d])=>{let f=new Date().getTime();return!(d.timestamp+n<f)}));m(u)}return{get(n,s,i={miss:()=>Promise.resolve()}){return Promise.resolve().then(()=>(p(),a()[JSON.stringify(n)])).then(u=>Promise.all([u?u.value:s(),u!==void 0])).then(([u,d])=>Promise.all([u,d||i.miss(u)])).then(([u])=>u)},set(n,s){return Promise.resolve().then(()=>{let i=a();return i[JSON.stringify(n)]={timestamp:new Date().getTime(),value:s},t().setItem(o,JSON.stringify(i)),s})},delete(n){return Promise.resolve().then(()=>{let s=a();delete s[JSON.stringify(n)],t().setItem(o,JSON.stringify(s))})},clear(){return Promise.resolve().then(()=>{t().removeItem(o)})}}}function ee(){return{get(r,e,o={miss:()=>Promise.resolve()}){return e().then(a=>Promise.all([a,o.miss(a)])).then(([a])=>a)},set(r,e){return Promise.resolve(e)},delete(r){return Promise.resolve()},clear(){return Promise.resolve()}}}function w(r){let e=[...r.caches],o=e.shift();return o===void 0?ee():{get(t,a,m={miss:()=>Promise.resolve()}){return o.get(t,a,m).catch(()=>w({caches:e}).get(t,a,m))},set(t,a){return o.set(t,a).catch(()=>w({caches:e}).set(t,a))},delete(t){return o.delete(t).catch(()=>w({caches:e}).delete(t))},clear(){return o.clear().catch(()=>w({caches:e}).clear())}}}function O(r={serializable:!0}){let e={};return{get(o,t,a={miss:()=>Promise.resolve()}){let m=JSON.stringify(o);if(m in e)return Promise.resolve(r.serializable?JSON.parse(e[m]):e[m]);let p=t();return p.then(n=>a.miss(n)).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 j=1e3,G=2e3,J=3e4;function re(r){let e={value:`Algolia for JavaScript (${r})`,add(o){let t=`; ${o.segment}${o.version!==void 0?` (${o.version})`:""}`;return e.value.indexOf(t)===-1&&(e.value=`${e.value}${t}`),e}};return e}function M(r,e,o="WithinHeaders"){let t={"x-algolia-api-key":e,"x-algolia-application-id":r};return{headers(){return o==="WithinHeaders"?t:{}},queryParameters(){return o==="WithinQueryParameters"?t:{}}}}function Q({algoliaAgents:r,client:e,version:o}){let t=re(o).add({segment:e,version:o});return r.forEach(a=>t.add(a)),t}function F(){return{debug(r,e){return Promise.resolve()},info(r,e){return Promise.resolve()},error(r,e){return Promise.resolve()}}}var H=2*60*1e3;function W(r,e="up"){let o=Date.now();function t(){return e==="up"||Date.now()-o>H}function a(){return e==="timed out"&&Date.now()-o<=H}return{...r,status:e,lastUpdate:o,isUp:t,isTimedOut:a}}var B=class extends Error{name="AlgoliaError";constructor(r,e){super(r),e&&(this.name=e)}},X=class extends B{stackTrace;constructor(r,e,o){super(r,o),this.stackTrace=e}},te=class extends X{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")}},x=class extends X{status;constructor(r,e,o,t="ApiError"){super(r,o,t),this.status=e}},oe=class extends B{response;constructor(r,e){super(r,"DeserializationError"),this.response=e}},se=class extends x{error;constructor(r,e,o,t){super(r,e,t,"DetailedApiError"),this.error=o}};function ae(r,e,o){let t=ne(o),a=`${r.protocol}://${r.url}${r.port?`:${r.port}`:""}/${e.charAt(0)==="/"?e.substring(1):e}`;return t.length&&(a+=`?${t}`),a}function ne(r){return Object.keys(r).filter(e=>r[e]!==void 0).sort().map(e=>`${e}=${encodeURIComponent(Object.prototype.toString.call(r[e])==="[object Array]"?r[e].join(","):r[e]).replace(/\+/g,"%20")}`).join("&")}function ie(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 ce(r,e,o){let t={Accept:"application/json",...r,...e,...o},a={};return Object.keys(t).forEach(m=>{let p=t[m];a[m.toLowerCase()]=p}),a}function ue(r){try{return JSON.parse(r.content)}catch(e){throw new oe(e.message,r)}}function le({content:r,status:e},o){try{let t=JSON.parse(r);return"error"in t?new se(t.message,e,t.error,o):new x(t.message,e,o)}catch{}return new x(r,e,o)}function me({isTimedOut:r,status:e}){return!r&&~~e===0}function de({isTimedOut:r,status:e}){return r||me({isTimedOut:r,status:e})||~~(e/100)!==2&&~~(e/100)!==4}function he({status:r}){return~~(r/100)===2}function pe(r){return r.map(e=>K(e))}function K(r){let e=r.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...r,request:{...r.request,headers:{...r.request.headers,...e}}}}function V({hosts:r,hostsCache:e,baseHeaders:o,logger:t,baseQueryParameters:a,algoliaAgent:m,timeouts:p,requester:n,requestsCache:s,responsesCache:i}){async function u(c){let l=await Promise.all(c.map(h=>e.get(h,()=>Promise.resolve(W(h))))),g=l.filter(h=>h.isUp()),y=l.filter(h=>h.isTimedOut()),q=[...g,...y];return{hosts:q.length>0?q:c,getTimeout(h,E){return(y.length===0&&h===0?1:y.length+3+h)*E}}}async function d(c,l,g=!0){let y=[],q=ie(c,l),T=ce(o,c.headers,l.headers),h=c.method==="GET"?{...c.data,...l.data}:{},E={...a,...c.queryParameters,...h};if(m.value&&(E["x-algolia-agent"]=m.value),l&&l.queryParameters)for(let P of Object.keys(l.queryParameters))!l.queryParameters[P]||Object.prototype.toString.call(l.queryParameters[P])==="[object Object]"?E[P]=l.queryParameters[P]:E[P]=l.queryParameters[P].toString();let S=0,D=async(P,C)=>{let v=P.pop();if(v===void 0)throw new te(pe(y));let b={...p,...l.timeouts},N={data:q,headers:T,method:c.method,url:ae(v,c.path,E),connectTimeout:C(S,b.connect),responseTimeout:C(S,g?b.read:b.write)},k=U=>{let I={request:N,response:U,host:v,triesLeft:P.length};return y.push(I),I},R=await n.send(N);if(de(R)){let U=k(R);return R.isTimedOut&&S++,t.info("Retryable failure",K(U)),await e.set(v,W(v,R.isTimedOut?"timed out":"down")),D(P,C)}if(he(R))return ue(R);throw k(R),le(R,y)},Z=r.filter(P=>P.accept==="readWrite"||(g?P.accept==="read":P.accept==="write")),_=await u(Z);return D([..._.hosts].reverse(),_.getTimeout)}function f(c,l={}){let g=c.useReadTransporter||c.method==="GET";if(!g)return d(c,l,g);let y=()=>d(c,l);if((l.cacheable||c.cacheable)!==!0)return y();let T={request:c,requestOptions:l,transporter:{queryParameters:a,headers:o}};return i.get(T,()=>s.get(T,()=>s.set(T,y()).then(h=>Promise.all([s.delete(T),h]),h=>Promise.all([s.delete(T),Promise.reject(h)])).then(([h,E])=>E)),{miss:h=>i.set(T,h)})}return{hostsCache:e,requester:n,timeouts:p,logger:t,algoliaAgent:m,baseHeaders:o,baseQueryParameters:a,hosts:r,request:f,requestsCache:s,responsesCache:i}}var A="5.8.1",z=["eu","us"];function Pe(r){return[{url:"personalization.{region}.algolia.com".replace("{region}",r),accept:"readWrite",protocol:"https"}]}function Y({appId:r,apiKey:e,authMode:o,algoliaAgents:t,region:a,...m}){let p=M(r,e,o),n=V({hosts:Pe(a),...m,algoliaAgent:Q({algoliaAgents:t,client:"Personalization",version:A}),baseHeaders:{"content-type":"text/plain",...p.headers(),...m.baseHeaders},baseQueryParameters:{...p.queryParameters(),...m.baseQueryParameters}});return{transporter:n,appId:r,clearCache(){return Promise.all([n.requestsCache.clear(),n.responsesCache.clear()]).then(()=>{})},get _ua(){return n.algoliaAgent.value},addAlgoliaAgent(s,i){n.algoliaAgent.add({segment:s,version:i})},setClientApiKey({apiKey:s}){!o||o==="WithinHeaders"?n.baseHeaders["x-algolia-api-key"]=s:n.baseQueryParameters["x-algolia-api-key"]=s},customDelete({path:s,parameters:i},u){if(!s)throw new Error("Parameter `path` is required when calling `customDelete`.");let l={method:"DELETE",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return n.request(l,u)},customGet({path:s,parameters:i},u){if(!s)throw new Error("Parameter `path` is required when calling `customGet`.");let l={method:"GET",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{}};return n.request(l,u)},customPost({path:s,parameters:i,body:u},d){if(!s)throw new Error("Parameter `path` is required when calling `customPost`.");let g={method:"POST",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:u||{}};return n.request(g,d)},customPut({path:s,parameters:i,body:u},d){if(!s)throw new Error("Parameter `path` is required when calling `customPut`.");let g={method:"PUT",path:"/{path}".replace("{path}",s),queryParameters:i||{},headers:{},data:u||{}};return n.request(g,d)},deleteUserProfile({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `deleteUserProfile`.");let c={method:"DELETE",path:"/1/profiles/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return n.request(c,i)},getPersonalizationStrategy(s){let f={method:"GET",path:"/1/strategies/personalization",queryParameters:{},headers:{}};return n.request(f,s)},getUserTokenProfile({userToken:s},i){if(!s)throw new Error("Parameter `userToken` is required when calling `getUserTokenProfile`.");let c={method:"GET",path:"/1/profiles/personalization/{userToken}".replace("{userToken}",encodeURIComponent(s)),queryParameters:{},headers:{}};return n.request(c,i)},setPersonalizationStrategy(s,i){if(!s)throw new Error("Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.");if(!s.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 n.request(c,i)}}}function $e(r,e,o,t){if(!r||typeof r!="string")throw new Error("`appId` is missing.");if(!e||typeof e!="string")throw new Error("`apiKey` is missing.");if(!o||o&&(typeof o!="string"||!z.includes(o)))throw new Error(`\`region\` is required and must be one of the following: ${z.join(", ")}`);return Y({appId:r,apiKey:e,region:o,timeouts:{connect:j,read:G,write:J},logger:F(),requester:L(),algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:O(),requestsCache:O({serializable:!1}),hostsCache:w({caches:[$({key:`${A}-${r}`}),O()]}),...t})}export{A as apiClientVersion,$e as personalizationClient};
|
|
2
2
|
//# sourceMappingURL=browser.min.js.map
|