@algolia/client-insights 5.0.0-alpha.73 → 5.0.0-alpha.76

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.
@@ -1,12 +1,10 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var clientCommon = require('@algolia/client-common');
6
4
  var requesterNodeHttp = require('@algolia/requester-node-http');
7
5
 
8
6
  // 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.
9
- const apiClientVersion = '5.0.0-alpha.73';
7
+ const apiClientVersion = '5.0.0-alpha.76';
10
8
  const REGIONS = ['de', 'us'];
11
9
  function getDefaultHosts(region) {
12
10
  const url = !region
@@ -70,8 +68,8 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
70
68
  *
71
69
  * @summary Send requests to the Algolia REST API.
72
70
  * @param del - The del object.
73
- * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
74
- * @param del.parameters - Query parameters to be applied to the current query.
71
+ * @param del.path - Path of the endpoint, anything after \"/1\" must be specified.
72
+ * @param del.parameters - Query parameters to apply to the current query.
75
73
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
76
74
  */
77
75
  del({ path, parameters }, requestOptions) {
@@ -94,8 +92,8 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
94
92
  *
95
93
  * @summary Send requests to the Algolia REST API.
96
94
  * @param get - The get object.
97
- * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
98
- * @param get.parameters - Query parameters to be applied to the current query.
95
+ * @param get.path - Path of the endpoint, anything after \"/1\" must be specified.
96
+ * @param get.parameters - Query parameters to apply to the current query.
99
97
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
100
98
  */
101
99
  get({ path, parameters }, requestOptions) {
@@ -118,9 +116,9 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
118
116
  *
119
117
  * @summary Send requests to the Algolia REST API.
120
118
  * @param post - The post object.
121
- * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
122
- * @param post.parameters - Query parameters to be applied to the current query.
123
- * @param post.body - The parameters to send with the custom request.
119
+ * @param post.path - Path of the endpoint, anything after \"/1\" must be specified.
120
+ * @param post.parameters - Query parameters to apply to the current query.
121
+ * @param post.body - Parameters to send with the custom request.
124
122
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
125
123
  */
126
124
  post({ path, parameters, body }, requestOptions) {
@@ -170,9 +168,9 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
170
168
  *
171
169
  * @summary Send requests to the Algolia REST API.
172
170
  * @param put - The put object.
173
- * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
174
- * @param put.parameters - Query parameters to be applied to the current query.
175
- * @param put.body - The parameters to send with the custom request.
171
+ * @param put.path - Path of the endpoint, anything after \"/1\" must be specified.
172
+ * @param put.parameters - Query parameters to apply to the current query.
173
+ * @param put.body - Parameters to send with the custom request.
176
174
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
177
175
  */
178
176
  put({ path, parameters, body }, requestOptions) {
@@ -662,7 +662,7 @@ function createXhrRequester() {
662
662
  }
663
663
 
664
664
  // 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.
665
- const apiClientVersion = '5.0.0-alpha.73';
665
+ const apiClientVersion = '5.0.0-alpha.76';
666
666
  const REGIONS = ['de', 'us'];
667
667
  function getDefaultHosts(region) {
668
668
  const url = !region
@@ -726,8 +726,8 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
726
726
  *
727
727
  * @summary Send requests to the Algolia REST API.
728
728
  * @param del - The del object.
729
- * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
730
- * @param del.parameters - Query parameters to be applied to the current query.
729
+ * @param del.path - Path of the endpoint, anything after \"/1\" must be specified.
730
+ * @param del.parameters - Query parameters to apply to the current query.
731
731
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
732
732
  */
733
733
  del({ path, parameters }, requestOptions) {
@@ -750,8 +750,8 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
750
750
  *
751
751
  * @summary Send requests to the Algolia REST API.
752
752
  * @param get - The get object.
753
- * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
754
- * @param get.parameters - Query parameters to be applied to the current query.
753
+ * @param get.path - Path of the endpoint, anything after \"/1\" must be specified.
754
+ * @param get.parameters - Query parameters to apply to the current query.
755
755
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
756
756
  */
757
757
  get({ path, parameters }, requestOptions) {
@@ -774,9 +774,9 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
774
774
  *
775
775
  * @summary Send requests to the Algolia REST API.
776
776
  * @param post - The post object.
777
- * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
778
- * @param post.parameters - Query parameters to be applied to the current query.
779
- * @param post.body - The parameters to send with the custom request.
777
+ * @param post.path - Path of the endpoint, anything after \"/1\" must be specified.
778
+ * @param post.parameters - Query parameters to apply to the current query.
779
+ * @param post.body - Parameters to send with the custom request.
780
780
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
781
781
  */
782
782
  post({ path, parameters, body }, requestOptions) {
@@ -826,9 +826,9 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
826
826
  *
827
827
  * @summary Send requests to the Algolia REST API.
828
828
  * @param put - The put object.
829
- * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
830
- * @param put.parameters - Query parameters to be applied to the current query.
831
- * @param put.body - The parameters to send with the custom request.
829
+ * @param put.path - Path of the endpoint, anything after \"/1\" must be specified.
830
+ * @param put.parameters - Query parameters to apply to the current query.
831
+ * @param put.body - Parameters to send with the custom request.
832
832
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
833
833
  */
834
834
  put({ path, parameters, body }, requestOptions) {
@@ -2,7 +2,7 @@ import { createAuth, createTransporter, getAlgoliaAgent, DEFAULT_CONNECT_TIMEOUT
2
2
  import { createHttpRequester } from '@algolia/requester-node-http';
3
3
 
4
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.0.0-alpha.73';
5
+ const apiClientVersion = '5.0.0-alpha.76';
6
6
  const REGIONS = ['de', 'us'];
7
7
  function getDefaultHosts(region) {
8
8
  const url = !region
@@ -66,8 +66,8 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
66
66
  *
67
67
  * @summary Send requests to the Algolia REST API.
68
68
  * @param del - The del object.
69
- * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
70
- * @param del.parameters - Query parameters to be applied to the current query.
69
+ * @param del.path - Path of the endpoint, anything after \"/1\" must be specified.
70
+ * @param del.parameters - Query parameters to apply to the current query.
71
71
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
72
72
  */
73
73
  del({ path, parameters }, requestOptions) {
@@ -90,8 +90,8 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
90
90
  *
91
91
  * @summary Send requests to the Algolia REST API.
92
92
  * @param get - The get object.
93
- * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
94
- * @param get.parameters - Query parameters to be applied to the current query.
93
+ * @param get.path - Path of the endpoint, anything after \"/1\" must be specified.
94
+ * @param get.parameters - Query parameters to apply to the current query.
95
95
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
96
96
  */
97
97
  get({ path, parameters }, requestOptions) {
@@ -114,9 +114,9 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
114
114
  *
115
115
  * @summary Send requests to the Algolia REST API.
116
116
  * @param post - The post object.
117
- * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
118
- * @param post.parameters - Query parameters to be applied to the current query.
119
- * @param post.body - The parameters to send with the custom request.
117
+ * @param post.path - Path of the endpoint, anything after \"/1\" must be specified.
118
+ * @param post.parameters - Query parameters to apply to the current query.
119
+ * @param post.body - Parameters to send with the custom request.
120
120
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
121
121
  */
122
122
  post({ path, parameters, body }, requestOptions) {
@@ -166,9 +166,9 @@ function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMo
166
166
  *
167
167
  * @summary Send requests to the Algolia REST API.
168
168
  * @param put - The put object.
169
- * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
170
- * @param put.parameters - Query parameters to be applied to the current query.
171
- * @param put.body - The parameters to send with the custom request.
169
+ * @param put.path - Path of the endpoint, anything after \"/1\" must be specified.
170
+ * @param put.parameters - Query parameters to apply to the current query.
171
+ * @param put.body - Parameters to send with the custom request.
172
172
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
173
173
  */
174
174
  put({ path, parameters, body }, requestOptions) {
@@ -1,2 +1,2 @@
1
- /*! client-insights.umd.js | 5.0.0-alpha.73 | © 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-insights"]={})}(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)||"{}")}return{get:(e,t,r={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>{const r=JSON.stringify(e),s=a()[r];return Promise.all([s||t(),void 0!==s])})).then((([e,t])=>Promise.all([e,t||r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve().then((()=>{const n=a();return n[JSON.stringify(e)]=t,s().setItem(r,JSON.stringify(n)),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,n={miss:()=>Promise.resolve()})=>s.get(e,a,n).catch((()=>r({caches:t}).get(e,a,n))),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 n=JSON.stringify(r);if(n in t)return Promise.resolve(e.serializable?JSON.parse(t[n]):t[n]);const o=s();return o.then((e=>a.miss(e))).then((()=>o))},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 n(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 o(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===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:String(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),o(this,"name","AlgoliaError"),t&&(this.name=t)}}class c extends i{constructor(e,t,r){super(e,r),o(this,"stackTrace",void 0),this.stackTrace=t}}class u extends c{constructor(e){super("Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.",e,"RetryError")}}class l extends c{constructor(e,t,r,s="ApiError"){super(e,r,s),o(this,"status",void 0),this.status=t}}class h extends i{constructor(e,t){super(e,"DeserializationError"),o(this,"response",void 0),this.response=t}}class d extends l{constructor(e,t,r,s){super(e,t,s,"DetailedApiError"),o(this,"error",void 0),this.error=r}}function m(e,t,r){const s=function(e){const t=e=>"[object Object]"===Object.prototype.toString.call(e)||"[object Array]"===Object.prototype.toString.call(e);return Object.keys(e).map((r=>`${r}=${encodeURIComponent(t(e[r])?JSON.stringify(e[r]):e[r])}`)).join("&")}(r);let a=`${e.protocol}://${e.url}/${"/"===t.charAt(0)?t.substr(1):t}`;return s.length&&(a+=`?${s}`),a}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:o,requester:i,requestsCache:c,responsesCache:g}){async function f(c,g,f=!0){const y=[],v=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)}(c,g),P=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,c.headers,g.headers),w="GET"===c.method?{...c.data,...g.data}:{},b={...s,...c.queryParameters,...w};if(a.value&&(b["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])?b[e]=g.queryParameters[e].toString():b[e]=g.queryParameters[e];let q=0;const O=async(e,r)=>{const s=e.pop();if(void 0===s)throw new u(function(e){return e.map((e=>p(e)))}(y));let a=g.timeout;void 0===a&&(a=f?o.read:o.write);const w={data:v,headers:P,method:c.method,url:m(s,c.path,b),connectTimeout:r(q,o.connect),responseTimeout:r(q,a)},T=t=>{const r={request:w,response:t,host:s,triesLeft:e.length};return y.push(r),r},E=await i.send(w);if(function({isTimedOut:e,status:t}){return e||function({isTimedOut:e,status:t}){return!e&&0==~~t}({isTimedOut:e,status:t})||2!=~~(t/100)&&4!=~~(t/100)}(E)){const a=T(E);return E.isTimedOut&&q++,console.log("Retryable failure",p(a)),await t.set(s,n(s,E.isTimedOut?"timed out":"down")),O(e,r)}if(function({status:e}){return 2==~~(e/100)}(E))return function(e){try{return JSON.parse(e.content)}catch(t){throw new h(t.message,e)}}(E);throw T(E),function({content:e,status:t},r){try{const s=JSON.parse(e);return"error"in s?new d(s.message,t,s.error,r):new l(s.message,t,r)}catch(e){}return new l(e,t,r)}(E,y)},T=e.filter((e=>"readWrite"===e.accept||(f?"read"===e.accept:"write"===e.accept))),E=await async function(e){const r=await Promise.all(e.map((e=>t.get(e,(()=>Promise.resolve(n(e))))))),s=r.filter((e=>e.isUp())),a=r.filter((e=>e.isTimedOut())),o=[...s,...a];return{hosts:o.length>0?o:e,getTimeout:(e,t)=>(0===a.length&&0===e?1:a.length+3+e)*t}}(T);return O([...E.hosts].reverse(),E.getTimeout)}return{hostsCache:t,requester:i,timeouts:o,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 n=()=>f(e,t);if(!0!==(t.cacheable||e.cacheable))return n();const o={request:e,requestOptions:t,transporter:{queryParameters:s,headers:r}};return g.get(o,(()=>c.get(o,(()=>c.set(o,n()).then((e=>Promise.all([c.delete(o),e])),(e=>Promise.all([c.delete(o),Promise.reject(e)]))).then((([e,t])=>t))))),{miss:e=>g.set(o,e)})},requestsCache:c,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.0.0-alpha.73",v=["de","us"];e.apiClientVersion=y,e.insightsClient=function(e,a,n,o){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!a||"string"!=typeof a)throw new Error("`apiKey` is missing.");if(n&&("string"!=typeof n||!v.includes(n)))throw new Error(`\`region\` must be one of the following: ${v.join(", ")}`);return function({appId:e,apiKey:t,authMode:r,algoliaAgents:s,region:a,...n}){const o=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:(c=a,[{url:c?"insights.{region}.algolia.io".replace("{region}",c):"insights.algolia.io",accept:"readWrite",protocol:"https"}]),...n,algoliaAgent:f({algoliaAgents:s,client:"Insights",version:y}),baseHeaders:{"content-type":"text/plain",...o.headers(),...n.baseHeaders},baseQueryParameters:{...o.queryParameters(),...n.baseQueryParameters}});var c;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})},del({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `del`.");const s={method:"DELETE",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return i.request(s,r)},get({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `get`.");const s={method:"GET",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return i.request(s,r)},post({path:e,parameters:t,body:r},s){if(!e)throw new Error("Parameter `path` is required when calling `post`.");const a={method:"POST",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(a,s)},pushEvents(e,t){if(!e)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!e.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");const r={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:e};return i.request(r,t)},put({path:e,parameters:t,body:r},s){if(!e)throw new Error("Parameter `path` is required when calling `put`.");const a={method:"PUT",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(a,s)}}}({appId:e,apiKey:a,region:n,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 n;r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===n&&(clearTimeout(a),n=s(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(a),clearTimeout(n),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(a),clearTimeout(n),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()]}),...o})}}));
1
+ /*! client-insights.umd.js | 5.0.0-alpha.76 | © 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-insights"]={})}(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)||"{}")}return{get:(e,t,r={miss:()=>Promise.resolve()})=>Promise.resolve().then((()=>{const r=JSON.stringify(e),s=a()[r];return Promise.all([s||t(),void 0!==s])})).then((([e,t])=>Promise.all([e,t||r.miss(e)]))).then((([e])=>e)),set:(e,t)=>Promise.resolve().then((()=>{const n=a();return n[JSON.stringify(e)]=t,s().setItem(r,JSON.stringify(n)),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,n={miss:()=>Promise.resolve()})=>s.get(e,a,n).catch((()=>r({caches:t}).get(e,a,n))),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 n=JSON.stringify(r);if(n in t)return Promise.resolve(e.serializable?JSON.parse(t[n]):t[n]);const o=s();return o.then((e=>a.miss(e))).then((()=>o))},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 n(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 o(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===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:String(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),o(this,"name","AlgoliaError"),t&&(this.name=t)}}class c extends i{constructor(e,t,r){super(e,r),o(this,"stackTrace",void 0),this.stackTrace=t}}class u extends c{constructor(e){super("Unreachable hosts - your application id may be incorrect. If the error persists, contact support@algolia.com.",e,"RetryError")}}class l extends c{constructor(e,t,r,s="ApiError"){super(e,r,s),o(this,"status",void 0),this.status=t}}class h extends i{constructor(e,t){super(e,"DeserializationError"),o(this,"response",void 0),this.response=t}}class d extends l{constructor(e,t,r,s){super(e,t,s,"DetailedApiError"),o(this,"error",void 0),this.error=r}}function m(e,t,r){const s=function(e){const t=e=>"[object Object]"===Object.prototype.toString.call(e)||"[object Array]"===Object.prototype.toString.call(e);return Object.keys(e).map((r=>`${r}=${encodeURIComponent(t(e[r])?JSON.stringify(e[r]):e[r])}`)).join("&")}(r);let a=`${e.protocol}://${e.url}/${"/"===t.charAt(0)?t.substr(1):t}`;return s.length&&(a+=`?${s}`),a}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:o,requester:i,requestsCache:c,responsesCache:g}){async function f(c,g,f=!0){const y=[],v=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)}(c,g),P=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,c.headers,g.headers),w="GET"===c.method?{...c.data,...g.data}:{},b={...s,...c.queryParameters,...w};if(a.value&&(b["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])?b[e]=g.queryParameters[e].toString():b[e]=g.queryParameters[e];let q=0;const O=async(e,r)=>{const s=e.pop();if(void 0===s)throw new u(function(e){return e.map((e=>p(e)))}(y));let a=g.timeout;void 0===a&&(a=f?o.read:o.write);const w={data:v,headers:P,method:c.method,url:m(s,c.path,b),connectTimeout:r(q,o.connect),responseTimeout:r(q,a)},T=t=>{const r={request:w,response:t,host:s,triesLeft:e.length};return y.push(r),r},E=await i.send(w);if(function({isTimedOut:e,status:t}){return e||function({isTimedOut:e,status:t}){return!e&&0==~~t}({isTimedOut:e,status:t})||2!=~~(t/100)&&4!=~~(t/100)}(E)){const a=T(E);return E.isTimedOut&&q++,console.log("Retryable failure",p(a)),await t.set(s,n(s,E.isTimedOut?"timed out":"down")),O(e,r)}if(function({status:e}){return 2==~~(e/100)}(E))return function(e){try{return JSON.parse(e.content)}catch(t){throw new h(t.message,e)}}(E);throw T(E),function({content:e,status:t},r){try{const s=JSON.parse(e);return"error"in s?new d(s.message,t,s.error,r):new l(s.message,t,r)}catch(e){}return new l(e,t,r)}(E,y)},T=e.filter((e=>"readWrite"===e.accept||(f?"read"===e.accept:"write"===e.accept))),E=await async function(e){const r=await Promise.all(e.map((e=>t.get(e,(()=>Promise.resolve(n(e))))))),s=r.filter((e=>e.isUp())),a=r.filter((e=>e.isTimedOut())),o=[...s,...a];return{hosts:o.length>0?o:e,getTimeout:(e,t)=>(0===a.length&&0===e?1:a.length+3+e)*t}}(T);return O([...E.hosts].reverse(),E.getTimeout)}return{hostsCache:t,requester:i,timeouts:o,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 n=()=>f(e,t);if(!0!==(t.cacheable||e.cacheable))return n();const o={request:e,requestOptions:t,transporter:{queryParameters:s,headers:r}};return g.get(o,(()=>c.get(o,(()=>c.set(o,n()).then((e=>Promise.all([c.delete(o),e])),(e=>Promise.all([c.delete(o),Promise.reject(e)]))).then((([e,t])=>t))))),{miss:e=>g.set(o,e)})},requestsCache:c,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.0.0-alpha.76",v=["de","us"];e.apiClientVersion=y,e.insightsClient=function(e,a,n,o){if(!e||"string"!=typeof e)throw new Error("`appId` is missing.");if(!a||"string"!=typeof a)throw new Error("`apiKey` is missing.");if(n&&("string"!=typeof n||!v.includes(n)))throw new Error(`\`region\` must be one of the following: ${v.join(", ")}`);return function({appId:e,apiKey:t,authMode:r,algoliaAgents:s,region:a,...n}){const o=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:(c=a,[{url:c?"insights.{region}.algolia.io".replace("{region}",c):"insights.algolia.io",accept:"readWrite",protocol:"https"}]),...n,algoliaAgent:f({algoliaAgents:s,client:"Insights",version:y}),baseHeaders:{"content-type":"text/plain",...o.headers(),...n.baseHeaders},baseQueryParameters:{...o.queryParameters(),...n.baseQueryParameters}});var c;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})},del({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `del`.");const s={method:"DELETE",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return i.request(s,r)},get({path:e,parameters:t},r){if(!e)throw new Error("Parameter `path` is required when calling `get`.");const s={method:"GET",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{}};return i.request(s,r)},post({path:e,parameters:t,body:r},s){if(!e)throw new Error("Parameter `path` is required when calling `post`.");const a={method:"POST",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(a,s)},pushEvents(e,t){if(!e)throw new Error("Parameter `insightsEvents` is required when calling `pushEvents`.");if(!e.events)throw new Error("Parameter `insightsEvents.events` is required when calling `pushEvents`.");const r={method:"POST",path:"/1/events",queryParameters:{},headers:{},data:e};return i.request(r,t)},put({path:e,parameters:t,body:r},s){if(!e)throw new Error("Parameter `path` is required when calling `put`.");const a={method:"PUT",path:"/1{path}".replace("{path}",e),queryParameters:t||{},headers:{},data:r||{}};return i.request(a,s)}}}({appId:e,apiKey:a,region:n,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 n;r.onreadystatechange=()=>{r.readyState>r.OPENED&&void 0===n&&(clearTimeout(a),n=s(e.responseTimeout,"Socket timeout"))},r.onerror=()=>{0===r.status&&(clearTimeout(a),clearTimeout(n),t({content:r.responseText||"Network request failed",status:r.status,isTimedOut:!1}))},r.onload=()=>{clearTimeout(a),clearTimeout(n),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()]}),...o})}}));
@@ -3,11 +3,11 @@
3
3
  */
4
4
  export type DelProps = {
5
5
  /**
6
- * The path of the API endpoint to target, anything after the /1 needs to be specified.
6
+ * Path of the endpoint, anything after \"/1\" must be specified.
7
7
  */
8
8
  path: string;
9
9
  /**
10
- * Query parameters to be applied to the current query.
10
+ * Query parameters to apply to the current query.
11
11
  */
12
12
  parameters?: Record<string, any>;
13
13
  };
@@ -16,11 +16,11 @@ export type DelProps = {
16
16
  */
17
17
  export type GetProps = {
18
18
  /**
19
- * The path of the API endpoint to target, anything after the /1 needs to be specified.
19
+ * Path of the endpoint, anything after \"/1\" must be specified.
20
20
  */
21
21
  path: string;
22
22
  /**
23
- * Query parameters to be applied to the current query.
23
+ * Query parameters to apply to the current query.
24
24
  */
25
25
  parameters?: Record<string, any>;
26
26
  };
@@ -29,15 +29,15 @@ export type GetProps = {
29
29
  */
30
30
  export type PostProps = {
31
31
  /**
32
- * The path of the API endpoint to target, anything after the /1 needs to be specified.
32
+ * Path of the endpoint, anything after \"/1\" must be specified.
33
33
  */
34
34
  path: string;
35
35
  /**
36
- * Query parameters to be applied to the current query.
36
+ * Query parameters to apply to the current query.
37
37
  */
38
38
  parameters?: Record<string, any>;
39
39
  /**
40
- * The parameters to send with the custom request.
40
+ * Parameters to send with the custom request.
41
41
  */
42
42
  body?: Record<string, any>;
43
43
  };
@@ -46,15 +46,15 @@ export type PostProps = {
46
46
  */
47
47
  export type PutProps = {
48
48
  /**
49
- * The path of the API endpoint to target, anything after the /1 needs to be specified.
49
+ * Path of the endpoint, anything after \"/1\" must be specified.
50
50
  */
51
51
  path: string;
52
52
  /**
53
- * Query parameters to be applied to the current query.
53
+ * Query parameters to apply to the current query.
54
54
  */
55
55
  parameters?: Record<string, any>;
56
56
  /**
57
- * The parameters to send with the custom request.
57
+ * Parameters to send with the custom request.
58
58
  */
59
59
  body?: Record<string, any>;
60
60
  };
@@ -2,7 +2,7 @@ import type { CreateClientOptions, RequestOptions } from '@algolia/client-common
2
2
  import type { DelProps, GetProps, PostProps, PutProps } from '../model/clientMethodProps';
3
3
  import type { EventsResponse } from '../model/eventsResponse';
4
4
  import type { InsightsEvents } from '../model/insightsEvents';
5
- export declare const apiClientVersion = "5.0.0-alpha.73";
5
+ export declare const apiClientVersion = "5.0.0-alpha.76";
6
6
  export declare const REGIONS: readonly ["de", "us"];
7
7
  export type Region = (typeof REGIONS)[number];
8
8
  export declare function createInsightsClient({ appId: appIdOption, apiKey: apiKeyOption, authMode, algoliaAgents, region: regionOption, ...options }: CreateClientOptions & {
@@ -33,8 +33,8 @@ export declare function createInsightsClient({ appId: appIdOption, apiKey: apiKe
33
33
  *
34
34
  * @summary Send requests to the Algolia REST API.
35
35
  * @param del - The del object.
36
- * @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
37
- * @param del.parameters - Query parameters to be applied to the current query.
36
+ * @param del.path - Path of the endpoint, anything after \"/1\" must be specified.
37
+ * @param del.parameters - Query parameters to apply to the current query.
38
38
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
39
39
  */
40
40
  del({ path, parameters }: DelProps, requestOptions?: RequestOptions): Promise<Record<string, any>>;
@@ -43,8 +43,8 @@ export declare function createInsightsClient({ appId: appIdOption, apiKey: apiKe
43
43
  *
44
44
  * @summary Send requests to the Algolia REST API.
45
45
  * @param get - The get object.
46
- * @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
47
- * @param get.parameters - Query parameters to be applied to the current query.
46
+ * @param get.path - Path of the endpoint, anything after \"/1\" must be specified.
47
+ * @param get.parameters - Query parameters to apply to the current query.
48
48
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
49
49
  */
50
50
  get({ path, parameters }: GetProps, requestOptions?: RequestOptions): Promise<Record<string, any>>;
@@ -53,9 +53,9 @@ export declare function createInsightsClient({ appId: appIdOption, apiKey: apiKe
53
53
  *
54
54
  * @summary Send requests to the Algolia REST API.
55
55
  * @param post - The post object.
56
- * @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
57
- * @param post.parameters - Query parameters to be applied to the current query.
58
- * @param post.body - The parameters to send with the custom request.
56
+ * @param post.path - Path of the endpoint, anything after \"/1\" must be specified.
57
+ * @param post.parameters - Query parameters to apply to the current query.
58
+ * @param post.body - Parameters to send with the custom request.
59
59
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
60
60
  */
61
61
  post({ path, parameters, body }: PostProps, requestOptions?: RequestOptions): Promise<Record<string, any>>;
@@ -72,9 +72,9 @@ export declare function createInsightsClient({ appId: appIdOption, apiKey: apiKe
72
72
  *
73
73
  * @summary Send requests to the Algolia REST API.
74
74
  * @param put - The put object.
75
- * @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
76
- * @param put.parameters - Query parameters to be applied to the current query.
77
- * @param put.body - The parameters to send with the custom request.
75
+ * @param put.path - Path of the endpoint, anything after \"/1\" must be specified.
76
+ * @param put.parameters - Query parameters to apply to the current query.
77
+ * @param put.body - Parameters to send with the custom request.
78
78
  * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
79
79
  */
80
80
  put({ path, parameters, body }: PutProps, requestOptions?: RequestOptions): Promise<Record<string, any>>;
@@ -5,11 +5,11 @@
5
5
  */
6
6
  export type DelProps = {
7
7
  /**
8
- * The path of the API endpoint to target, anything after the /1 needs to be specified.
8
+ * Path of the endpoint, anything after \"/1\" must be specified.
9
9
  */
10
10
  path: string;
11
11
  /**
12
- * Query parameters to be applied to the current query.
12
+ * Query parameters to apply to the current query.
13
13
  */
14
14
  parameters?: Record<string, any>;
15
15
  };
@@ -19,11 +19,11 @@ export type DelProps = {
19
19
  */
20
20
  export type GetProps = {
21
21
  /**
22
- * The path of the API endpoint to target, anything after the /1 needs to be specified.
22
+ * Path of the endpoint, anything after \"/1\" must be specified.
23
23
  */
24
24
  path: string;
25
25
  /**
26
- * Query parameters to be applied to the current query.
26
+ * Query parameters to apply to the current query.
27
27
  */
28
28
  parameters?: Record<string, any>;
29
29
  };
@@ -33,15 +33,15 @@ export type GetProps = {
33
33
  */
34
34
  export type PostProps = {
35
35
  /**
36
- * The path of the API endpoint to target, anything after the /1 needs to be specified.
36
+ * Path of the endpoint, anything after \"/1\" must be specified.
37
37
  */
38
38
  path: string;
39
39
  /**
40
- * Query parameters to be applied to the current query.
40
+ * Query parameters to apply to the current query.
41
41
  */
42
42
  parameters?: Record<string, any>;
43
43
  /**
44
- * The parameters to send with the custom request.
44
+ * Parameters to send with the custom request.
45
45
  */
46
46
  body?: Record<string, any>;
47
47
  };
@@ -51,15 +51,15 @@ export type PostProps = {
51
51
  */
52
52
  export type PutProps = {
53
53
  /**
54
- * The path of the API endpoint to target, anything after the /1 needs to be specified.
54
+ * Path of the endpoint, anything after \"/1\" must be specified.
55
55
  */
56
56
  path: string;
57
57
  /**
58
- * Query parameters to be applied to the current query.
58
+ * Query parameters to apply to the current query.
59
59
  */
60
60
  parameters?: Record<string, any>;
61
61
  /**
62
- * The parameters to send with the custom request.
62
+ * Parameters to send with the custom request.
63
63
  */
64
64
  body?: Record<string, any>;
65
65
  };
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@algolia/client-insights",
3
- "version": "5.0.0-alpha.73",
3
+ "version": "5.0.0-alpha.76",
4
4
  "description": "JavaScript client for client-insights",
5
5
  "repository": "algolia/algoliasearch-client-javascript",
6
6
  "license": "MIT",
7
7
  "author": "Algolia",
8
+ "type": "module",
8
9
  "exports": {
9
10
  ".": {
10
11
  "node": {
@@ -38,14 +39,14 @@
38
39
  "clean": "rm -rf ./dist || true"
39
40
  },
40
41
  "dependencies": {
41
- "@algolia/client-common": "5.0.0-alpha.73",
42
- "@algolia/requester-browser-xhr": "5.0.0-alpha.73",
43
- "@algolia/requester-node-http": "5.0.0-alpha.73"
42
+ "@algolia/client-common": "5.0.0-alpha.76",
43
+ "@algolia/requester-browser-xhr": "5.0.0-alpha.76",
44
+ "@algolia/requester-node-http": "5.0.0-alpha.76"
44
45
  },
45
46
  "devDependencies": {
46
- "@types/node": "18.16.18",
47
- "rollup": "2.79.1",
48
- "typescript": "5.0.4"
47
+ "@types/node": "18.17.0",
48
+ "rollup": "3.26.3",
49
+ "typescript": "5.1.6"
49
50
  },
50
51
  "engines": {
51
52
  "node": ">= 14.0.0"