@algolia/client-personalization 5.2.3 → 5.2.4-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +27 -27
  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
@@ -1,294 +0,0 @@
1
- import { createAuth, createTransporter, getAlgoliaAgent, DEFAULT_CONNECT_TIMEOUT_NODE, DEFAULT_READ_TIMEOUT_NODE, DEFAULT_WRITE_TIMEOUT_NODE, createNullCache, createMemoryCache } from '@algolia/client-common';
2
- import { createHttpRequester } from '@algolia/requester-node-http';
3
-
4
- // 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.
5
- const apiClientVersion = '5.2.3';
6
- const REGIONS = ['eu', 'us'];
7
- function getDefaultHosts(region) {
8
- const url = 'personalization.{region}.algolia.com'.replace('{region}', region);
9
- return [{ url, accept: 'readWrite', protocol: 'https' }];
10
- }
11
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
12
- function createPersonalizationClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }) {
13
- const auth = createAuth(appIdOption, apiKeyOption, authMode);
14
- const transporter = createTransporter({
15
- hosts: getDefaultHosts(regionOption),
16
- ...options,
17
- algoliaAgent: getAlgoliaAgent({
18
- algoliaAgents,
19
- client: 'Personalization',
20
- version: apiClientVersion,
21
- }),
22
- baseHeaders: {
23
- 'content-type': 'text/plain',
24
- ...auth.headers(),
25
- ...options.baseHeaders,
26
- },
27
- baseQueryParameters: {
28
- ...auth.queryParameters(),
29
- ...options.baseQueryParameters,
30
- },
31
- });
32
- return {
33
- transporter,
34
- /**
35
- * The `appId` currently in use.
36
- */
37
- appId: appIdOption,
38
- /**
39
- * Clears the cache of the transporter for the `requestsCache` and `responsesCache` properties.
40
- */
41
- clearCache() {
42
- return Promise.all([transporter.requestsCache.clear(), transporter.responsesCache.clear()]).then(() => undefined);
43
- },
44
- /**
45
- * Get the value of the `algoliaAgent`, used by our libraries internally and telemetry system.
46
- */
47
- get _ua() {
48
- return transporter.algoliaAgent.value;
49
- },
50
- /**
51
- * Adds a `segment` to the `x-algolia-agent` sent with every requests.
52
- *
53
- * @param segment - The algolia agent (user-agent) segment to add.
54
- * @param version - The version of the agent.
55
- */
56
- addAlgoliaAgent(segment, version) {
57
- transporter.algoliaAgent.add({ segment, version });
58
- },
59
- /**
60
- * This method allow you to send requests to the Algolia REST API.
61
- *
62
- * @param customDelete - The customDelete object.
63
- * @param customDelete.path - Path of the endpoint, anything after \"/1\" must be specified.
64
- * @param customDelete.parameters - Query parameters to apply to the current query.
65
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
66
- */
67
- customDelete({ path, parameters }, requestOptions) {
68
- if (!path) {
69
- throw new Error('Parameter `path` is required when calling `customDelete`.');
70
- }
71
- const requestPath = '/{path}'.replace('{path}', path);
72
- const headers = {};
73
- const queryParameters = parameters ? parameters : {};
74
- const request = {
75
- method: 'DELETE',
76
- path: requestPath,
77
- queryParameters,
78
- headers,
79
- };
80
- return transporter.request(request, requestOptions);
81
- },
82
- /**
83
- * This method allow you to send requests to the Algolia REST API.
84
- *
85
- * @param customGet - The customGet object.
86
- * @param customGet.path - Path of the endpoint, anything after \"/1\" must be specified.
87
- * @param customGet.parameters - Query parameters to apply to the current query.
88
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
89
- */
90
- customGet({ path, parameters }, requestOptions) {
91
- if (!path) {
92
- throw new Error('Parameter `path` is required when calling `customGet`.');
93
- }
94
- const requestPath = '/{path}'.replace('{path}', path);
95
- const headers = {};
96
- const queryParameters = parameters ? parameters : {};
97
- const request = {
98
- method: 'GET',
99
- path: requestPath,
100
- queryParameters,
101
- headers,
102
- };
103
- return transporter.request(request, requestOptions);
104
- },
105
- /**
106
- * This method allow you to send requests to the Algolia REST API.
107
- *
108
- * @param customPost - The customPost object.
109
- * @param customPost.path - Path of the endpoint, anything after \"/1\" must be specified.
110
- * @param customPost.parameters - Query parameters to apply to the current query.
111
- * @param customPost.body - Parameters to send with the custom request.
112
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
113
- */
114
- customPost({ path, parameters, body }, requestOptions) {
115
- if (!path) {
116
- throw new Error('Parameter `path` is required when calling `customPost`.');
117
- }
118
- const requestPath = '/{path}'.replace('{path}', path);
119
- const headers = {};
120
- const queryParameters = parameters ? parameters : {};
121
- const request = {
122
- method: 'POST',
123
- path: requestPath,
124
- queryParameters,
125
- headers,
126
- data: body ? body : {},
127
- };
128
- return transporter.request(request, requestOptions);
129
- },
130
- /**
131
- * This method allow you to send requests to the Algolia REST API.
132
- *
133
- * @param customPut - The customPut object.
134
- * @param customPut.path - Path of the endpoint, anything after \"/1\" must be specified.
135
- * @param customPut.parameters - Query parameters to apply to the current query.
136
- * @param customPut.body - Parameters to send with the custom request.
137
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
138
- */
139
- customPut({ path, parameters, body }, requestOptions) {
140
- if (!path) {
141
- throw new Error('Parameter `path` is required when calling `customPut`.');
142
- }
143
- const requestPath = '/{path}'.replace('{path}', path);
144
- const headers = {};
145
- const queryParameters = parameters ? parameters : {};
146
- const request = {
147
- method: 'PUT',
148
- path: requestPath,
149
- queryParameters,
150
- headers,
151
- data: body ? body : {},
152
- };
153
- return transporter.request(request, requestOptions);
154
- },
155
- /**
156
- * Deletes a user profile. The response includes a date and time when the user profile can safely be considered deleted.
157
- *
158
- * Required API Key ACLs:
159
- * - recommendation.
160
- *
161
- * @param deleteUserProfile - The deleteUserProfile object.
162
- * @param deleteUserProfile.userToken - Unique identifier representing a user for which to fetch the personalization profile.
163
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
164
- */
165
- deleteUserProfile({ userToken }, requestOptions) {
166
- if (!userToken) {
167
- throw new Error('Parameter `userToken` is required when calling `deleteUserProfile`.');
168
- }
169
- const requestPath = '/1/profiles/{userToken}'.replace('{userToken}', encodeURIComponent(userToken));
170
- const headers = {};
171
- const queryParameters = {};
172
- const request = {
173
- method: 'DELETE',
174
- path: requestPath,
175
- queryParameters,
176
- headers,
177
- };
178
- return transporter.request(request, requestOptions);
179
- },
180
- /**
181
- * Retrieves the current personalization strategy.
182
- *
183
- * Required API Key ACLs:
184
- * - recommendation.
185
- *
186
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
187
- */
188
- getPersonalizationStrategy(requestOptions) {
189
- const requestPath = '/1/strategies/personalization';
190
- const headers = {};
191
- const queryParameters = {};
192
- const request = {
193
- method: 'GET',
194
- path: requestPath,
195
- queryParameters,
196
- headers,
197
- };
198
- return transporter.request(request, requestOptions);
199
- },
200
- /**
201
- * Retrieves a user profile and their affinities for different facets.
202
- *
203
- * Required API Key ACLs:
204
- * - recommendation.
205
- *
206
- * @param getUserTokenProfile - The getUserTokenProfile object.
207
- * @param getUserTokenProfile.userToken - Unique identifier representing a user for which to fetch the personalization profile.
208
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
209
- */
210
- getUserTokenProfile({ userToken }, requestOptions) {
211
- if (!userToken) {
212
- throw new Error('Parameter `userToken` is required when calling `getUserTokenProfile`.');
213
- }
214
- const requestPath = '/1/profiles/personalization/{userToken}'.replace('{userToken}', encodeURIComponent(userToken));
215
- const headers = {};
216
- const queryParameters = {};
217
- const request = {
218
- method: 'GET',
219
- path: requestPath,
220
- queryParameters,
221
- headers,
222
- };
223
- return transporter.request(request, requestOptions);
224
- },
225
- /**
226
- * Creates a new personalization strategy.
227
- *
228
- * Required API Key ACLs:
229
- * - recommendation.
230
- *
231
- * @param personalizationStrategyParams - The personalizationStrategyParams object.
232
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
233
- */
234
- setPersonalizationStrategy(personalizationStrategyParams, requestOptions) {
235
- if (!personalizationStrategyParams) {
236
- throw new Error('Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.');
237
- }
238
- if (!personalizationStrategyParams.eventScoring) {
239
- throw new Error('Parameter `personalizationStrategyParams.eventScoring` is required when calling `setPersonalizationStrategy`.');
240
- }
241
- if (!personalizationStrategyParams.facetScoring) {
242
- throw new Error('Parameter `personalizationStrategyParams.facetScoring` is required when calling `setPersonalizationStrategy`.');
243
- }
244
- if (!personalizationStrategyParams.personalizationImpact) {
245
- throw new Error('Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`.');
246
- }
247
- const requestPath = '/1/strategies/personalization';
248
- const headers = {};
249
- const queryParameters = {};
250
- const request = {
251
- method: 'POST',
252
- path: requestPath,
253
- queryParameters,
254
- headers,
255
- data: personalizationStrategyParams,
256
- };
257
- return transporter.request(request, requestOptions);
258
- },
259
- };
260
- }
261
-
262
- // 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.
263
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
264
- function personalizationClient(appId, apiKey, region, options) {
265
- if (!appId || typeof appId !== 'string') {
266
- throw new Error('`appId` is missing.');
267
- }
268
- if (!apiKey || typeof apiKey !== 'string') {
269
- throw new Error('`apiKey` is missing.');
270
- }
271
- if (!region || (region && (typeof region !== 'string' || !REGIONS.includes(region)))) {
272
- throw new Error(`\`region\` is required and must be one of the following: ${REGIONS.join(', ')}`);
273
- }
274
- return {
275
- ...createPersonalizationClient({
276
- appId,
277
- apiKey,
278
- region,
279
- timeouts: {
280
- connect: DEFAULT_CONNECT_TIMEOUT_NODE,
281
- read: DEFAULT_READ_TIMEOUT_NODE,
282
- write: DEFAULT_WRITE_TIMEOUT_NODE,
283
- },
284
- requester: createHttpRequester(),
285
- algoliaAgents: [{ segment: 'Node.js', version: process.versions.node }],
286
- responsesCache: createNullCache(),
287
- requestsCache: createNullCache(),
288
- hostsCache: createMemoryCache(),
289
- ...options,
290
- }),
291
- };
292
- }
293
-
294
- export { apiClientVersion, personalizationClient };
@@ -1,2 +0,0 @@
1
- /*! client-personalization.umd.js | 5.2.3 | © Algolia, inc. | https://github.com/algolia/algoliasearch-client-javascript */
2
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@algolia/client-personalization"]={})}(this,(function(e){"use strict";function t(e){let t;const r=`algolia-client-js-${e.key}`;function s(){return void 0===t&&(t=e.localStorage||window.localStorage),t}function a(){return JSON.parse(s().getItem(r)||"{}")}function o(e){s().setItem(r,JSON.stringify(e))}return{get:(t,r,s={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>(function(){const t=e.timeToLive?1e3*e.timeToLive:null,r=a(),s=Object.fromEntries(Object.entries(r).filter((([,e])=>void 0!==e.timestamp)));if(o(s),!t)return;o(Object.fromEntries(Object.entries(s).filter((([,e])=>{const r=(new Date).getTime();return!(e.timestamp+t<r)}))))}(),a()[JSON.stringify(t)]))).then((e=>Promise.all([e?e.value:r(),void 0!==e]))).then((([e,t])=>Promise.all([e,t||s.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve().then((()=>{const o=a();return o[JSON.stringify(e)]={timestamp:(new Date).getTime(),value:t},s().setItem(r,JSON.stringify(o)),t})),delete:e=>Promise.resolve().then((()=>{const t=a();delete t[JSON.stringify(e)],s().setItem(r,JSON.stringify(t))})),clear:()=>Promise.resolve().then((()=>{s().removeItem(r)}))}}function r(e){const t=[...e.caches],s=t.shift();return void 0===s?{get:(e,t,r={miss:()=>Promise.resolve()})=>t().then((e=>Promise.all([e,r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve(t),delete:e=>Promise.resolve(),clear:()=>Promise.resolve()}:{get:(e,a,o={miss:()=>Promise.resolve()})=>s.get(e,a,o).catch((()=>r({caches:t}).get(e,a,o))),set:(e,a)=>s.set(e,a).catch((()=>r({caches:t}).set(e,a))),delete:e=>s.delete(e).catch((()=>r({caches:t}).delete(e))),clear:()=>s.clear().catch((()=>r({caches:t}).clear()))}}function s(e={serializable:!0}){let t={};return{get(r,s,a={miss:()=>Promise.resolve()}){const o=JSON.stringify(r);if(o in t)return Promise.resolve(e.serializable?JSON.parse(t[o]):t[o]);const n=s();return n.then((e=>a.miss(e))).then((()=>n))},set:(r,s)=>(t[JSON.stringify(r)]=e.serializable?JSON.stringify(s):s,Promise.resolve(s)),delete:e=>(delete t[JSON.stringify(e)],Promise.resolve()),clear:()=>(t={},Promise.resolve())}}const a=12e4;function o(e,t="up"){const r=Date.now();return{...e,status:t,lastUpdate:r,isUp:function(){return"up"===t||Date.now()-r>a},isTimedOut:function(){return"timed out"===t&&Date.now()-r<=a}}}function n(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class i extends Error{constructor(e,t){super(e),n(this,"name","AlgoliaError"),t&&(this.name=t)}}class u extends i{constructor(e,t,r){super(e,r),n(this,"stackTrace",void 0),this.stackTrace=t}}class c extends u{constructor(e){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.",e,"RetryError")}}class l extends u{constructor(e,t,r,s="ApiError"){super(e,r,s),n(this,"status",void 0),this.status=t}}class m extends i{constructor(e,t){super(e,"DeserializationError"),n(this,"response",void 0),this.response=t}}class h extends l{constructor(e,t,r,s){super(e,t,s,"DetailedApiError"),n(this,"error",void 0),this.error=r}}function d(e,t,r){const s=(a=r,Object.keys(a).filter((e=>void 0!==a[e])).sort().map((e=>`${e}=${encodeURIComponent("[object Array]"===Object.prototype.toString.call(a[e])?a[e].join(","):a[e]).replaceAll("+","%20")}`)).join("&"));var a;let o=`${e.protocol}://${e.url}${e.port?`:${e.port}`:""}/${"/"===t.charAt(0)?t.substring(1):t}`;return s.length&&(o+=`?${s}`),o}function p(e){const t=e.request.headers["x-algolia-api-key"]?{"x-algolia-api-key":"*****"}:{};return{...e,request:{...e.request,headers:{...e.request.headers,...t}}}}function g({hosts:e,hostsCache:t,baseHeaders:r,baseQueryParameters:s,algoliaAgent:a,timeouts:n,requester:i,requestsCache:u,responsesCache:g}){async function f(u,g,f=!0){const y=[],P=function(e,t){if("GET"===e.method||void 0===e.data&&void 0===t.data)return;const r=Array.isArray(e.data)?e.data:{...e.data,...t.data};return JSON.stringify(r)}(u,g),w=function(e,t,r){const s={Accept:"application/json",...e,...t,...r},a={};return Object.keys(s).forEach((e=>{const t=s[e];a[e.toLowerCase()]=t})),a}(r,u.headers,g.headers),v="GET"===u.method?{...u.data,...g.data}:{},q={...s,...u.queryParameters,...v};if(a.value&&(q["x-algolia-agent"]=a.value),g&&g.queryParameters)for(const e of Object.keys(g.queryParameters))g.queryParameters[e]&&"[object Object]"!==Object.prototype.toString.call(g.queryParameters[e])?q[e]=g.queryParameters[e].toString():q[e]=g.queryParameters[e];let T=0;const b=async(e,r)=>{const s=e.pop();if(void 0===s)throw new c(function(e){return e.map((e=>p(e)))}(y));const a={...n,...g.timeouts},v={data:P,headers:w,method:u.method,url:d(s,u.path,q),connectTimeout:r(T,a.connect),responseTimeout:r(T,f?a.read:a.write)},O=t=>{const r={request:v,response:t,host:s,triesLeft:e.length};return y.push(r),r},S=await i.send(v);if(function({isTimedOut:e,status:t}){return e||function({isTimedOut:e,status:t}){return!e&&!~~t}({isTimedOut:e,status:t})||2!=~~(t/100)&&4!=~~(t/100)}(S)){const a=O(S);return S.isTimedOut&&T++,console.log("Retryable failure",p(a)),await t.set(s,o(s,S.isTimedOut?"timed out":"down")),b(e,r)}if(function({status:e}){return 2==~~(e/100)}(S))return function(e){try{return JSON.parse(e.content)}catch(t){throw new m(t.message,e)}}(S);throw O(S),function({content:e,status:t},r){try{const s=JSON.parse(e);return"error"in s?new h(s.message,t,s.error,r):new l(s.message,t,r)}catch{}return new l(e,t,r)}(S,y)},O=e.filter((e=>"readWrite"===e.accept||(f?"read"===e.accept:"write"===e.accept))),S=await async function(e){const r=await Promise.all(e.map((e=>t.get(e,(()=>Promise.resolve(o(e))))))),s=r.filter((e=>e.isUp())),a=r.filter((e=>e.isTimedOut())),n=[...s,...a];return{hosts:n.length>0?n:e,getTimeout:(e,t)=>(0===a.length&&0===e?1:a.length+3+e)*t}}(O);return b([...S.hosts].reverse(),S.getTimeout)}return{hostsCache:t,requester:i,timeouts:n,algoliaAgent:a,baseHeaders:r,baseQueryParameters:s,hosts:e,request:function(e,t={}){const a=e.useReadTransporter||"GET"===e.method;if(!a)return f(e,t,a);const o=()=>f(e,t);if(!0!==(t.cacheable||e.cacheable))return o();const n={request:e,requestOptions:t,transporter:{queryParameters:s,headers:r}};return g.get(n,(()=>u.get(n,(()=>u.set(n,o()).then((e=>Promise.all([u.delete(n),e])),(e=>Promise.all([u.delete(n),Promise.reject(e)]))).then((([e,t])=>t))))),{miss:e=>g.set(n,e)})},requestsCache:u,responsesCache:g}}function f({algoliaAgents:e,client:t,version:r}){const s=function(e){const t={value:`Algolia for JavaScript (${e})`,add(e){const r=`; ${e.segment}${void 0!==e.version?` (${e.version})`:""}`;return-1===t.value.indexOf(r)&&(t.value=`${t.value}${r}`),t}};return t}(r).add({segment:t,version:r});return e.forEach((e=>s.add(e))),s}const y="5.2.3",P=["eu","us"];e.apiClientVersion=y,e.personalizationClient=function(e,a,o,n){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!a||"string"!=typeof a)throw new Error("`apiKey` is missing.");if(!o||o&&("string"!=typeof o||!P.includes(o)))throw new Error(`\`region\` is required and must be one of the following: ${P.join(", ")}`);return function({appId:e,apiKey:t,authMode:r,algoliaAgents:s,region:a,...o}){const n=function(e,t,r="WithinHeaders"){const s={"x-algolia-api-key":t,"x-algolia-application-id":e};return{headers:()=>"WithinHeaders"===r?s:{},queryParameters:()=>"WithinQueryParameters"===r?s:{}}}(e,t,r),i=g({hosts:(u=a,[{url:"personalization.{region}.algolia.com".replace("{region}",u),accept:"readWrite",protocol:"https"}]),...o,algoliaAgent:f({algoliaAgents:s,client:"Personalization",version:y}),baseHeaders:{"content-type":"text/plain",...n.headers(),...o.baseHeaders},baseQueryParameters:{...n.queryParameters(),...o.baseQueryParameters}});var u;return{transporter:i,appId:e,clearCache:()=>Promise.all([i.requestsCache.clear(),i.responsesCache.clear()]).then((()=>{})),get _ua(){return i.algoliaAgent.value},addAlgoliaAgent(e,t){i.algoliaAgent.add({segment:e,version:t})},customDelete({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `customDelete`.");const s={method:"DELETE",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return i.request(s,r)},customGet({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `customGet`.");const s={method:"GET",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return i.request(s,r)},customPost({path:e,parameters:t,body:r},s){if(!e)throw new Error("Parameter `path` is required when calling `customPost`.");const a={method:"POST",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(a,s)},customPut({path:e,parameters:t,body:r},s){if(!e)throw new Error("Parameter `path` is required when calling `customPut`.");const a={method:"PUT",path:"/{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(a,s)},deleteUserProfile({userToken:e},t){if(!e)throw new Error("Parameter `userToken` is required when calling `deleteUserProfile`.");const r={method:"DELETE",path:"/1/profiles/{userToken}".replace("{userToken}",encodeURIComponent(e)),queryParameters:{},headers:{}};return i.request(r,t)},getPersonalizationStrategy(e){const t={method:"GET",path:"/1/strategies/personalization",queryParameters:{},headers:{}};return i.request(t,e)},getUserTokenProfile({userToken:e},t){if(!e)throw new Error("Parameter `userToken` is required when calling `getUserTokenProfile`.");const r={method:"GET",path:"/1/profiles/personalization/{userToken}".replace("{userToken}",encodeURIComponent(e)),queryParameters:{},headers:{}};return i.request(r,t)},setPersonalizationStrategy(e,t){if(!e)throw new Error("Parameter `personalizationStrategyParams` is required when calling `setPersonalizationStrategy`.");if(!e.eventScoring)throw new Error("Parameter `personalizationStrategyParams.eventScoring` is required when calling `setPersonalizationStrategy`.");if(!e.facetScoring)throw new Error("Parameter `personalizationStrategyParams.facetScoring` is required when calling `setPersonalizationStrategy`.");if(!e.personalizationImpact)throw new Error("Parameter `personalizationStrategyParams.personalizationImpact` is required when calling `setPersonalizationStrategy`.");const r={method:"POST",path:"/1/strategies/personalization",queryParameters:{},headers:{},data:e};return i.request(r,t)}}}({appId:e,apiKey:a,region:o,timeouts:{connect:1e3,read:2e3,write:3e4},requester:{send:function(e){return new Promise((t=>{const r=new XMLHttpRequest;r.open(e.method,e.url,!0),Object.keys(e.headers).forEach((t=>r.setRequestHeader(t,e.headers[t])));const s=(e,s)=>setTimeout((()=>{r.abort(),t({status:0,content:s,isTimedOut:!0})}),e),a=s(e.connectTimeout,"Connection timeout");let o;r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===o&&(clearTimeout(a),o=s(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(a),clearTimeout(o),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(a),clearTimeout(o),t({content:r.responseText,status:r.status,isTimedOut:!1})},r.send(e.data)}))}},algoliaAgents:[{segment:"Browser"}],authMode:"WithinQueryParameters",responsesCache:s(),requestsCache:s({serializable:!1}),hostsCache:r({caches:[t({key:`${y}-${e}`}),s()]}),...n})}}));
@@ -1,79 +0,0 @@
1
- /**
2
- * Properties for the `customDelete` method.
3
- */
4
- export type CustomDeleteProps = {
5
- /**
6
- * Path of the endpoint, anything after \"/1\" must be specified.
7
- */
8
- path: string;
9
- /**
10
- * Query parameters to apply to the current query.
11
- */
12
- parameters?: Record<string, any>;
13
- };
14
- /**
15
- * Properties for the `customGet` method.
16
- */
17
- export type CustomGetProps = {
18
- /**
19
- * Path of the endpoint, anything after \"/1\" must be specified.
20
- */
21
- path: string;
22
- /**
23
- * Query parameters to apply to the current query.
24
- */
25
- parameters?: Record<string, any>;
26
- };
27
- /**
28
- * Properties for the `customPost` method.
29
- */
30
- export type CustomPostProps = {
31
- /**
32
- * Path of the endpoint, anything after \"/1\" must be specified.
33
- */
34
- path: string;
35
- /**
36
- * Query parameters to apply to the current query.
37
- */
38
- parameters?: Record<string, any>;
39
- /**
40
- * Parameters to send with the custom request.
41
- */
42
- body?: Record<string, unknown>;
43
- };
44
- /**
45
- * Properties for the `customPut` method.
46
- */
47
- export type CustomPutProps = {
48
- /**
49
- * Path of the endpoint, anything after \"/1\" must be specified.
50
- */
51
- path: string;
52
- /**
53
- * Query parameters to apply to the current query.
54
- */
55
- parameters?: Record<string, any>;
56
- /**
57
- * Parameters to send with the custom request.
58
- */
59
- body?: Record<string, unknown>;
60
- };
61
- /**
62
- * Properties for the `deleteUserProfile` method.
63
- */
64
- export type DeleteUserProfileProps = {
65
- /**
66
- * Unique identifier representing a user for which to fetch the personalization profile.
67
- */
68
- userToken: string;
69
- };
70
- /**
71
- * Properties for the `getUserTokenProfile` method.
72
- */
73
- export type GetUserTokenProfileProps = {
74
- /**
75
- * Unique identifier representing a user for which to fetch the personalization profile.
76
- */
77
- userToken: string;
78
- };
79
- //# sourceMappingURL=clientMethodProps.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"clientMethodProps.d.ts","sourceRoot":"","sources":["../../model/clientMethodProps.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
@@ -1,11 +0,0 @@
1
- export type DeleteUserProfileResponse = {
2
- /**
3
- * 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/).
4
- */
5
- userToken: string;
6
- /**
7
- * 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.
8
- */
9
- deletedUntil: string;
10
- };
11
- //# sourceMappingURL=deleteUserProfileResponse.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"deleteUserProfileResponse.d.ts","sourceRoot":"","sources":["../../model/deleteUserProfileResponse.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,yBAAyB,GAAG;IACtC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Error.
3
- */
4
- export type ErrorBase = Record<string, any> & {
5
- message?: string;
6
- };
7
- //# sourceMappingURL=errorBase.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errorBase.d.ts","sourceRoot":"","sources":["../../model/errorBase.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC"}
@@ -1,13 +0,0 @@
1
- import type { EventType } from './eventType';
2
- export type EventScoring = {
3
- /**
4
- * Event score.
5
- */
6
- score: number;
7
- /**
8
- * Event name.
9
- */
10
- eventName: string;
11
- eventType: EventType;
12
- };
13
- //# sourceMappingURL=eventScoring.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"eventScoring.d.ts","sourceRoot":"","sources":["../../model/eventScoring.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC"}
@@ -1,5 +0,0 @@
1
- /**
2
- * Event type.
3
- */
4
- export type EventType = 'click' | 'conversion' | 'view';
5
- //# sourceMappingURL=eventType.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"eventType.d.ts","sourceRoot":"","sources":["../../model/eventType.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,YAAY,GAAG,MAAM,CAAC"}
@@ -1,11 +0,0 @@
1
- export type FacetScoring = {
2
- /**
3
- * Event score.
4
- */
5
- score: number;
6
- /**
7
- * Facet attribute name.
8
- */
9
- facetName: string;
10
- };
11
- //# sourceMappingURL=facetScoring.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"facetScoring.d.ts","sourceRoot":"","sources":["../../model/facetScoring.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC"}
@@ -1,15 +0,0 @@
1
- export type GetUserTokenResponse = {
2
- /**
3
- * 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/).
4
- */
5
- userToken: string;
6
- /**
7
- * Date and time of the last event from this user, in RFC 3339 format.
8
- */
9
- lastEventAt: string;
10
- /**
11
- * 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.
12
- */
13
- scores: Record<string, unknown>;
14
- };
15
- //# sourceMappingURL=getUserTokenResponse.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getUserTokenResponse.d.ts","sourceRoot":"","sources":["../../model/getUserTokenResponse.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,oBAAoB,GAAG;IACjC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC,CAAC"}
@@ -1,10 +0,0 @@
1
- export * from './deleteUserProfileResponse';
2
- export * from './errorBase';
3
- export * from './eventScoring';
4
- export * from './eventType';
5
- export * from './facetScoring';
6
- export * from './getUserTokenResponse';
7
- export * from './personalizationStrategyParams';
8
- export * from './setPersonalizationStrategyResponse';
9
- export * from './clientMethodProps';
10
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../model/index.ts"],"names":[],"mappings":"AAEA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,sCAAsC,CAAC;AACrD,cAAc,qBAAqB,CAAC"}
@@ -1,17 +0,0 @@
1
- import type { EventScoring } from './eventScoring';
2
- import type { FacetScoring } from './facetScoring';
3
- export type PersonalizationStrategyParams = {
4
- /**
5
- * Scores associated with each event. The higher the scores, the higher the impact of those events on the personalization of search results.
6
- */
7
- eventScoring: EventScoring[];
8
- /**
9
- * Scores associated with each facet. The higher the scores, the higher the impact of those events on the personalization of search results.
10
- */
11
- facetScoring: FacetScoring[];
12
- /**
13
- * Impact of personalization on the search results. If set to 0, personalization has no impact on the search results.
14
- */
15
- personalizationImpact: number;
16
- };
17
- //# sourceMappingURL=personalizationStrategyParams.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"personalizationStrategyParams.d.ts","sourceRoot":"","sources":["../../model/personalizationStrategyParams.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD,MAAM,MAAM,6BAA6B,GAAG;IAC1C;;OAEG;IACH,YAAY,EAAE,YAAY,EAAE,CAAC;IAE7B;;OAEG;IACH,YAAY,EAAE,YAAY,EAAE,CAAC;IAE7B;;OAEG;IACH,qBAAqB,EAAE,MAAM,CAAC;CAC/B,CAAC"}
@@ -1,7 +0,0 @@
1
- export type SetPersonalizationStrategyResponse = {
2
- /**
3
- * A message confirming the strategy update.
4
- */
5
- message: string;
6
- };
7
- //# sourceMappingURL=setPersonalizationStrategyResponse.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setPersonalizationStrategyResponse.d.ts","sourceRoot":"","sources":["../../model/setPersonalizationStrategyResponse.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,kCAAkC,GAAG;IAC/C;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}