edge-impulse-api 1.82.6 → 1.82.7

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 (127) hide show
  1. package/build/library/sdk/api/adminApi.d.ts +4 -6
  2. package/build/library/sdk/api/adminApi.js +4782 -4928
  3. package/build/library/sdk/api/adminApi.js.map +1 -1
  4. package/build/library/sdk/api/authApi.d.ts +4 -6
  5. package/build/library/sdk/api/authApi.js +88 -56
  6. package/build/library/sdk/api/authApi.js.map +1 -1
  7. package/build/library/sdk/api/cDNApi.d.ts +4 -6
  8. package/build/library/sdk/api/cDNApi.js +76 -53
  9. package/build/library/sdk/api/cDNApi.js.map +1 -1
  10. package/build/library/sdk/api/canaryApi.d.ts +4 -6
  11. package/build/library/sdk/api/canaryApi.js +79 -53
  12. package/build/library/sdk/api/canaryApi.js.map +1 -1
  13. package/build/library/sdk/api/classifyApi.d.ts +4 -6
  14. package/build/library/sdk/api/classifyApi.js +527 -499
  15. package/build/library/sdk/api/classifyApi.js.map +1 -1
  16. package/build/library/sdk/api/dSPApi.d.ts +4 -6
  17. package/build/library/sdk/api/dSPApi.js +938 -942
  18. package/build/library/sdk/api/dSPApi.js.map +1 -1
  19. package/build/library/sdk/api/deploymentApi.d.ts +4 -6
  20. package/build/library/sdk/api/deploymentApi.js +680 -603
  21. package/build/library/sdk/api/deploymentApi.js.map +1 -1
  22. package/build/library/sdk/api/devicesApi.d.ts +4 -6
  23. package/build/library/sdk/api/devicesApi.js +802 -800
  24. package/build/library/sdk/api/devicesApi.js.map +1 -1
  25. package/build/library/sdk/api/emailVerificationApi.d.ts +4 -6
  26. package/build/library/sdk/api/emailVerificationApi.js +184 -190
  27. package/build/library/sdk/api/emailVerificationApi.js.map +1 -1
  28. package/build/library/sdk/api/exportApi.d.ts +4 -6
  29. package/build/library/sdk/api/exportApi.js +88 -56
  30. package/build/library/sdk/api/exportApi.js.map +1 -1
  31. package/build/library/sdk/api/featureFlagsApi.d.ts +4 -6
  32. package/build/library/sdk/api/featureFlagsApi.js +76 -52
  33. package/build/library/sdk/api/featureFlagsApi.js.map +1 -1
  34. package/build/library/sdk/api/healthApi.d.ts +4 -6
  35. package/build/library/sdk/api/healthApi.js +111 -97
  36. package/build/library/sdk/api/healthApi.js.map +1 -1
  37. package/build/library/sdk/api/impulseApi.d.ts +4 -6
  38. package/build/library/sdk/api/impulseApi.js +942 -902
  39. package/build/library/sdk/api/impulseApi.js.map +1 -1
  40. package/build/library/sdk/api/integrationsApi.d.ts +4 -6
  41. package/build/library/sdk/api/integrationsApi.js +136 -106
  42. package/build/library/sdk/api/integrationsApi.js.map +1 -1
  43. package/build/library/sdk/api/jobsApi.d.ts +4 -6
  44. package/build/library/sdk/api/jobsApi.js +2270 -2326
  45. package/build/library/sdk/api/jobsApi.js.map +1 -1
  46. package/build/library/sdk/api/learnApi.d.ts +22 -6
  47. package/build/library/sdk/api/learnApi.js +1597 -1424
  48. package/build/library/sdk/api/learnApi.js.map +1 -1
  49. package/build/library/sdk/api/loginApi.d.ts +4 -6
  50. package/build/library/sdk/api/loginApi.js +112 -98
  51. package/build/library/sdk/api/loginApi.js.map +1 -1
  52. package/build/library/sdk/api/metricsApi.d.ts +4 -6
  53. package/build/library/sdk/api/metricsApi.js +148 -144
  54. package/build/library/sdk/api/metricsApi.js.map +1 -1
  55. package/build/library/sdk/api/optimizationApi.d.ts +4 -6
  56. package/build/library/sdk/api/optimizationApi.js +844 -844
  57. package/build/library/sdk/api/optimizationApi.js.map +1 -1
  58. package/build/library/sdk/api/organizationBlocksApi.d.ts +4 -6
  59. package/build/library/sdk/api/organizationBlocksApi.js +1968 -1550
  60. package/build/library/sdk/api/organizationBlocksApi.js.map +1 -1
  61. package/build/library/sdk/api/organizationCreateProjectApi.d.ts +4 -6
  62. package/build/library/sdk/api/organizationCreateProjectApi.js +700 -652
  63. package/build/library/sdk/api/organizationCreateProjectApi.js.map +1 -1
  64. package/build/library/sdk/api/organizationDataApi.d.ts +4 -6
  65. package/build/library/sdk/api/organizationDataApi.js +2074 -1985
  66. package/build/library/sdk/api/organizationDataApi.js.map +1 -1
  67. package/build/library/sdk/api/organizationDataCampaignsApi.d.ts +4 -6
  68. package/build/library/sdk/api/organizationDataCampaignsApi.js +626 -602
  69. package/build/library/sdk/api/organizationDataCampaignsApi.js.map +1 -1
  70. package/build/library/sdk/api/organizationJobsApi.d.ts +4 -6
  71. package/build/library/sdk/api/organizationJobsApi.js +417 -399
  72. package/build/library/sdk/api/organizationJobsApi.js.map +1 -1
  73. package/build/library/sdk/api/organizationPipelinesApi.d.ts +4 -6
  74. package/build/library/sdk/api/organizationPipelinesApi.js +419 -401
  75. package/build/library/sdk/api/organizationPipelinesApi.js.map +1 -1
  76. package/build/library/sdk/api/organizationPortalsApi.d.ts +4 -6
  77. package/build/library/sdk/api/organizationPortalsApi.js +372 -352
  78. package/build/library/sdk/api/organizationPortalsApi.js.map +1 -1
  79. package/build/library/sdk/api/organizationsApi.d.ts +4 -6
  80. package/build/library/sdk/api/organizationsApi.js +4024 -4050
  81. package/build/library/sdk/api/organizationsApi.js.map +1 -1
  82. package/build/library/sdk/api/performanceCalibrationApi.d.ts +4 -6
  83. package/build/library/sdk/api/performanceCalibrationApi.js +586 -560
  84. package/build/library/sdk/api/performanceCalibrationApi.js.map +1 -1
  85. package/build/library/sdk/api/postProcessingApi.d.ts +4 -6
  86. package/build/library/sdk/api/postProcessingApi.js +279 -255
  87. package/build/library/sdk/api/postProcessingApi.js.map +1 -1
  88. package/build/library/sdk/api/projectsApi.d.ts +4 -6
  89. package/build/library/sdk/api/projectsApi.js +2758 -2818
  90. package/build/library/sdk/api/projectsApi.js.map +1 -1
  91. package/build/library/sdk/api/rawDataApi.d.ts +4 -6
  92. package/build/library/sdk/api/rawDataApi.js +3055 -3131
  93. package/build/library/sdk/api/rawDataApi.js.map +1 -1
  94. package/build/library/sdk/api/testApi.d.ts +4 -6
  95. package/build/library/sdk/api/testApi.js +152 -108
  96. package/build/library/sdk/api/testApi.js.map +1 -1
  97. package/build/library/sdk/api/themesApi.d.ts +4 -6
  98. package/build/library/sdk/api/themesApi.js +341 -305
  99. package/build/library/sdk/api/themesApi.js.map +1 -1
  100. package/build/library/sdk/api/thirdPartyAuthApi.d.ts +4 -6
  101. package/build/library/sdk/api/thirdPartyAuthApi.js +387 -353
  102. package/build/library/sdk/api/thirdPartyAuthApi.js.map +1 -1
  103. package/build/library/sdk/api/uploadPortalApi.d.ts +4 -6
  104. package/build/library/sdk/api/uploadPortalApi.js +375 -355
  105. package/build/library/sdk/api/uploadPortalApi.js.map +1 -1
  106. package/build/library/sdk/api/userApi.d.ts +4 -6
  107. package/build/library/sdk/api/userApi.js +2345 -2452
  108. package/build/library/sdk/api/userApi.js.map +1 -1
  109. package/build/library/sdk/api/vlmApi.d.ts +4 -6
  110. package/build/library/sdk/api/vlmApi.js +277 -253
  111. package/build/library/sdk/api/vlmApi.js.map +1 -1
  112. package/build/library/sdk/api/whitelabelsApi.d.ts +4 -6
  113. package/build/library/sdk/api/whitelabelsApi.js +408 -398
  114. package/build/library/sdk/api/whitelabelsApi.js.map +1 -1
  115. package/build/library/sdk/model/deployPretrainedModelRequest.d.ts +4 -0
  116. package/build/library/sdk/model/deployPretrainedModelRequest.js +5 -0
  117. package/build/library/sdk/model/deployPretrainedModelRequest.js.map +1 -1
  118. package/build/library/sdk/model/models.d.ts +47 -7
  119. package/build/library/sdk/model/models.js +33 -22
  120. package/build/library/sdk/model/models.js.map +1 -1
  121. package/build/library/sdk/model/uploadPretrainedModelByUrlRequest.d.ts +47 -0
  122. package/build/library/sdk/model/uploadPretrainedModelByUrlRequest.js +55 -0
  123. package/build/library/sdk/model/uploadPretrainedModelByUrlRequest.js.map +1 -0
  124. package/build/library/sdk/model/uploadPretrainedModelRequest.d.ts +4 -0
  125. package/build/library/sdk/model/uploadPretrainedModelRequest.js +5 -0
  126. package/build/library/sdk/model/uploadPretrainedModelRequest.js.map +1 -1
  127. package/package.json +3 -2
@@ -12,14 +12,31 @@
12
12
  */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.ImpulseApi = exports.ImpulseApiApiKeys = void 0;
15
- // tslint:disable-next-line: variable-name, no-var-requires
16
15
  const PATH = require('path');
17
- // tslint:disable-next-line: no-unsafe-any
18
16
  module.paths.push(PATH.join(process.cwd(), 'node_modules'));
19
- const localVarRequest = require("request");
17
+ let fetch;
18
+ let FormData;
19
+ if (globalThis.fetch && globalThis.FormData) {
20
+ fetch = globalThis.fetch;
21
+ FormData = globalThis.FormData;
22
+ }
23
+ else {
24
+ const undici = require('undici');
25
+ fetch = undici.fetch;
26
+ FormData = undici.FormData;
27
+ }
20
28
  const models_1 = require("../model/models");
21
29
  const models_2 = require("../model/models");
22
30
  let defaultBasePath = 'https://studio.edgeimpulse.com/v1';
31
+ async function parseResponse(res) {
32
+ const ct = (res.headers.get('content-type') || '').toLowerCase();
33
+ if (ct.includes('application/json'))
34
+ return res.json();
35
+ if (/^(image|video|audio)\/|application\/(octet-stream|zip|x-tar|cbor)/.test(ct)) {
36
+ return Buffer.from(await res.arrayBuffer());
37
+ }
38
+ return res.text();
39
+ }
23
40
  // ===============================================
24
41
  // This file is autogenerated - Please do not edit
25
42
  // ===============================================
@@ -30,10 +47,30 @@ var ImpulseApiApiKeys;
30
47
  ImpulseApiApiKeys[ImpulseApiApiKeys["JWTHttpHeaderAuthentication"] = 2] = "JWTHttpHeaderAuthentication";
31
48
  })(ImpulseApiApiKeys = exports.ImpulseApiApiKeys || (exports.ImpulseApiApiKeys = {}));
32
49
  class ImpulseApi {
50
+ async handleResponse(response, returnType) {
51
+ let body = await parseResponse(response);
52
+ if (!response.ok) {
53
+ let errorMsg;
54
+ if (typeof body === 'object' && body !== null && 'error' in body) {
55
+ errorMsg = body.error;
56
+ }
57
+ else {
58
+ errorMsg = `Failed to call "${response.url}", returned ${response.status}: ` + (typeof body === 'string' ? body : JSON.stringify(body));
59
+ }
60
+ throw new Error(errorMsg);
61
+ }
62
+ if (returnType) {
63
+ body = models_1.ObjectSerializer.deserialize(body, returnType);
64
+ }
65
+ if (typeof body.success === 'boolean' && !body.success) {
66
+ const errString = `Failed to call "${response.url}", returned ${response.status}: ` + body.error;
67
+ throw new Error(body.error || errString);
68
+ }
69
+ return body;
70
+ }
33
71
  constructor(basePathOrUsername, opts, password, basePath) {
34
72
  this._basePath = defaultBasePath;
35
73
  this.defaultHeaders = {};
36
- this._useQuerystring = false;
37
74
  this._opts = {};
38
75
  this.authentications = {
39
76
  'default': new models_1.VoidAuth(),
@@ -54,9 +91,6 @@ class ImpulseApi {
54
91
  }
55
92
  this.opts = opts !== null && opts !== void 0 ? opts : {};
56
93
  }
57
- set useQuerystring(value) {
58
- this._useQuerystring = value;
59
- }
60
94
  set basePath(basePath) {
61
95
  this._basePath = basePath;
62
96
  }
@@ -90,9 +124,11 @@ class ImpulseApi {
90
124
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
91
125
  .replace('{' + 'impulseId' + '}', encodeURIComponent(String(impulseId)));
92
126
  let localVarQueryParameters = {};
93
- let localVarHeaderParams = Object.assign({
94
- 'User-Agent': 'edgeimpulse-api nodejs'
95
- }, this.defaultHeaders);
127
+ let localVarHeaderParams = {
128
+ 'User-Agent': 'edgeimpulse-api nodejs',
129
+ 'Content-Type': 'application/json',
130
+ ...this.defaultHeaders,
131
+ };
96
132
  const produces = ['application/json'];
97
133
  // give precedence to 'application/json'
98
134
  if (produces.indexOf('application/json') >= 0) {
@@ -101,7 +137,7 @@ class ImpulseApi {
101
137
  else {
102
138
  localVarHeaderParams.Accept = produces.join(',');
103
139
  }
104
- let localVarFormParams = {};
140
+ let localVarFormParams;
105
141
  // verify required parameter 'projectId' is not null or undefined
106
142
  if (projectId === null || projectId === undefined) {
107
143
  throw new Error('Required parameter projectId was null or undefined when calling cloneImpulseComplete.');
@@ -114,56 +150,52 @@ class ImpulseApi {
114
150
  if (cloneImpulseRequest === null || cloneImpulseRequest === undefined) {
115
151
  throw new Error('Required parameter cloneImpulseRequest was null or undefined when calling cloneImpulseComplete.');
116
152
  }
117
- Object.assign(localVarHeaderParams, options.headers);
118
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
119
- let localVarUseFormData = false;
153
+ localVarHeaderParams = {
154
+ ...localVarHeaderParams,
155
+ ...options.headers,
156
+ ...this.opts.extraHeaders,
157
+ };
158
+ const queryString = Object.entries(localVarQueryParameters)
159
+ .filter(([, value]) => value !== undefined)
160
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
161
+ .join('&');
162
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
120
163
  let localVarRequestOptions = {
121
164
  method: 'POST',
122
- qs: localVarQueryParameters,
123
- headers: localVarHeaderParams,
124
- uri: localVarPath,
125
- useQuerystring: this._useQuerystring,
126
- agentOptions: { keepAlive: false },
127
- json: true,
128
- body: models_1.ObjectSerializer.serialize(cloneImpulseRequest, "CloneImpulseRequest")
165
+ headers: { ...localVarHeaderParams },
129
166
  };
130
- let authenticationPromise = Promise.resolve();
131
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
132
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
133
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
134
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
135
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
136
- return authenticationPromise.then(() => {
137
- if (Object.keys(localVarFormParams).length) {
138
- if (localVarUseFormData) {
139
- localVarRequestOptions.formData = localVarFormParams;
140
- }
141
- else {
142
- localVarRequestOptions.form = localVarFormParams;
143
- }
167
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(cloneImpulseRequest, "CloneImpulseRequest"));
168
+ let requestOptions = localVarRequestOptions;
169
+ let url = localVarUrl;
170
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
171
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
172
+ url = auth_ApiKeyAuthentication.url;
173
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
174
+ requestOptions = auth_JWTAuthentication.requestOptions;
175
+ url = auth_JWTAuthentication.url;
176
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
177
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
178
+ url = auth_JWTHttpHeaderAuthentication.url;
179
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
180
+ requestOptions = auth_OAuth2.requestOptions;
181
+ url = auth_OAuth2.url;
182
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
183
+ requestOptions = authDefault.requestOptions;
184
+ url = authDefault.url;
185
+ if (localVarFormParams) {
186
+ delete requestOptions.headers['Content-Type'];
187
+ if (localVarFormParams instanceof FormData) {
188
+ // FormData: fetch will handle Content-Type automatically.
189
+ requestOptions.body = localVarFormParams;
144
190
  }
145
- return new Promise((resolve, reject) => {
146
- localVarRequest(localVarRequestOptions, (error, response, body) => {
147
- if (error) {
148
- reject(error);
149
- }
150
- else {
151
- body = models_1.ObjectSerializer.deserialize(body, "StartJobResponse");
152
- if (typeof body.success === 'boolean' && !body.success) {
153
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
154
- reject(new Error(body.error || errString));
155
- }
156
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
157
- resolve(body);
158
- }
159
- else {
160
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
161
- reject(errString);
162
- }
163
- }
164
- });
165
- });
166
- });
191
+ else if (Object.keys(localVarFormParams).length > 0) {
192
+ // URL-encoded form
193
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
194
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
195
+ }
196
+ }
197
+ const response = await fetch(url, requestOptions);
198
+ return this.handleResponse(response, 'StartJobResponse');
167
199
  }
168
200
  /**
169
201
  * Clones the complete structure (incl. config) of an impulse. Does not copy data.
@@ -177,9 +209,11 @@ class ImpulseApi {
177
209
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
178
210
  .replace('{' + 'impulseId' + '}', encodeURIComponent(String(impulseId)));
179
211
  let localVarQueryParameters = {};
180
- let localVarHeaderParams = Object.assign({
181
- 'User-Agent': 'edgeimpulse-api nodejs'
182
- }, this.defaultHeaders);
212
+ let localVarHeaderParams = {
213
+ 'User-Agent': 'edgeimpulse-api nodejs',
214
+ 'Content-Type': 'application/json',
215
+ ...this.defaultHeaders,
216
+ };
183
217
  const produces = ['application/json'];
184
218
  // give precedence to 'application/json'
185
219
  if (produces.indexOf('application/json') >= 0) {
@@ -188,7 +222,7 @@ class ImpulseApi {
188
222
  else {
189
223
  localVarHeaderParams.Accept = produces.join(',');
190
224
  }
191
- let localVarFormParams = {};
225
+ let localVarFormParams;
192
226
  // verify required parameter 'projectId' is not null or undefined
193
227
  if (projectId === null || projectId === undefined) {
194
228
  throw new Error('Required parameter projectId was null or undefined when calling cloneImpulseStructure.');
@@ -201,56 +235,52 @@ class ImpulseApi {
201
235
  if (cloneImpulseRequest === null || cloneImpulseRequest === undefined) {
202
236
  throw new Error('Required parameter cloneImpulseRequest was null or undefined when calling cloneImpulseStructure.');
203
237
  }
204
- Object.assign(localVarHeaderParams, options.headers);
205
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
206
- let localVarUseFormData = false;
238
+ localVarHeaderParams = {
239
+ ...localVarHeaderParams,
240
+ ...options.headers,
241
+ ...this.opts.extraHeaders,
242
+ };
243
+ const queryString = Object.entries(localVarQueryParameters)
244
+ .filter(([, value]) => value !== undefined)
245
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
246
+ .join('&');
247
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
207
248
  let localVarRequestOptions = {
208
249
  method: 'POST',
209
- qs: localVarQueryParameters,
210
- headers: localVarHeaderParams,
211
- uri: localVarPath,
212
- useQuerystring: this._useQuerystring,
213
- agentOptions: { keepAlive: false },
214
- json: true,
215
- body: models_1.ObjectSerializer.serialize(cloneImpulseRequest, "CloneImpulseRequest")
250
+ headers: { ...localVarHeaderParams },
216
251
  };
217
- let authenticationPromise = Promise.resolve();
218
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
219
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
220
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
221
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
222
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
223
- return authenticationPromise.then(() => {
224
- if (Object.keys(localVarFormParams).length) {
225
- if (localVarUseFormData) {
226
- localVarRequestOptions.formData = localVarFormParams;
227
- }
228
- else {
229
- localVarRequestOptions.form = localVarFormParams;
230
- }
252
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(cloneImpulseRequest, "CloneImpulseRequest"));
253
+ let requestOptions = localVarRequestOptions;
254
+ let url = localVarUrl;
255
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
256
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
257
+ url = auth_ApiKeyAuthentication.url;
258
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
259
+ requestOptions = auth_JWTAuthentication.requestOptions;
260
+ url = auth_JWTAuthentication.url;
261
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
262
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
263
+ url = auth_JWTHttpHeaderAuthentication.url;
264
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
265
+ requestOptions = auth_OAuth2.requestOptions;
266
+ url = auth_OAuth2.url;
267
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
268
+ requestOptions = authDefault.requestOptions;
269
+ url = authDefault.url;
270
+ if (localVarFormParams) {
271
+ delete requestOptions.headers['Content-Type'];
272
+ if (localVarFormParams instanceof FormData) {
273
+ // FormData: fetch will handle Content-Type automatically.
274
+ requestOptions.body = localVarFormParams;
231
275
  }
232
- return new Promise((resolve, reject) => {
233
- localVarRequest(localVarRequestOptions, (error, response, body) => {
234
- if (error) {
235
- reject(error);
236
- }
237
- else {
238
- body = models_1.ObjectSerializer.deserialize(body, "CreateImpulseResponse");
239
- if (typeof body.success === 'boolean' && !body.success) {
240
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
241
- reject(new Error(body.error || errString));
242
- }
243
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
244
- resolve(body);
245
- }
246
- else {
247
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
248
- reject(errString);
249
- }
250
- }
251
- });
252
- });
253
- });
276
+ else if (Object.keys(localVarFormParams).length > 0) {
277
+ // URL-encoded form
278
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
279
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
280
+ }
281
+ }
282
+ const response = await fetch(url, requestOptions);
283
+ return this.handleResponse(response, 'CreateImpulseResponse');
254
284
  }
255
285
  /**
256
286
  * Sets the impulse for this project. If you specify `impulseId` then that impulse is created/updated, otherwise the default impulse is created/updated.
@@ -263,9 +293,11 @@ class ImpulseApi {
263
293
  const localVarPath = this.basePath + '/api/{projectId}/impulse'
264
294
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
265
295
  let localVarQueryParameters = {};
266
- let localVarHeaderParams = Object.assign({
267
- 'User-Agent': 'edgeimpulse-api nodejs'
268
- }, this.defaultHeaders);
296
+ let localVarHeaderParams = {
297
+ 'User-Agent': 'edgeimpulse-api nodejs',
298
+ 'Content-Type': 'application/json',
299
+ ...this.defaultHeaders,
300
+ };
269
301
  const produces = ['application/json'];
270
302
  // give precedence to 'application/json'
271
303
  if (produces.indexOf('application/json') >= 0) {
@@ -274,7 +306,7 @@ class ImpulseApi {
274
306
  else {
275
307
  localVarHeaderParams.Accept = produces.join(',');
276
308
  }
277
- let localVarFormParams = {};
309
+ let localVarFormParams;
278
310
  // verify required parameter 'projectId' is not null or undefined
279
311
  if (projectId === null || projectId === undefined) {
280
312
  throw new Error('Required parameter projectId was null or undefined when calling createImpulse.');
@@ -286,56 +318,52 @@ class ImpulseApi {
286
318
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
287
319
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
288
320
  }
289
- Object.assign(localVarHeaderParams, options.headers);
290
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
291
- let localVarUseFormData = false;
321
+ localVarHeaderParams = {
322
+ ...localVarHeaderParams,
323
+ ...options.headers,
324
+ ...this.opts.extraHeaders,
325
+ };
326
+ const queryString = Object.entries(localVarQueryParameters)
327
+ .filter(([, value]) => value !== undefined)
328
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
329
+ .join('&');
330
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
292
331
  let localVarRequestOptions = {
293
332
  method: 'POST',
294
- qs: localVarQueryParameters,
295
- headers: localVarHeaderParams,
296
- uri: localVarPath,
297
- useQuerystring: this._useQuerystring,
298
- agentOptions: { keepAlive: false },
299
- json: true,
300
- body: models_1.ObjectSerializer.serialize(createImpulseRequest, "CreateImpulseRequest")
333
+ headers: { ...localVarHeaderParams },
301
334
  };
302
- let authenticationPromise = Promise.resolve();
303
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
304
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
305
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
306
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
307
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
308
- return authenticationPromise.then(() => {
309
- if (Object.keys(localVarFormParams).length) {
310
- if (localVarUseFormData) {
311
- localVarRequestOptions.formData = localVarFormParams;
312
- }
313
- else {
314
- localVarRequestOptions.form = localVarFormParams;
315
- }
335
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(createImpulseRequest, "CreateImpulseRequest"));
336
+ let requestOptions = localVarRequestOptions;
337
+ let url = localVarUrl;
338
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
339
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
340
+ url = auth_ApiKeyAuthentication.url;
341
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
342
+ requestOptions = auth_JWTAuthentication.requestOptions;
343
+ url = auth_JWTAuthentication.url;
344
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
345
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
346
+ url = auth_JWTHttpHeaderAuthentication.url;
347
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
348
+ requestOptions = auth_OAuth2.requestOptions;
349
+ url = auth_OAuth2.url;
350
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
351
+ requestOptions = authDefault.requestOptions;
352
+ url = authDefault.url;
353
+ if (localVarFormParams) {
354
+ delete requestOptions.headers['Content-Type'];
355
+ if (localVarFormParams instanceof FormData) {
356
+ // FormData: fetch will handle Content-Type automatically.
357
+ requestOptions.body = localVarFormParams;
316
358
  }
317
- return new Promise((resolve, reject) => {
318
- localVarRequest(localVarRequestOptions, (error, response, body) => {
319
- if (error) {
320
- reject(error);
321
- }
322
- else {
323
- body = models_1.ObjectSerializer.deserialize(body, "CreateImpulseResponse");
324
- if (typeof body.success === 'boolean' && !body.success) {
325
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
326
- reject(new Error(body.error || errString));
327
- }
328
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
329
- resolve(body);
330
- }
331
- else {
332
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
333
- reject(errString);
334
- }
335
- }
336
- });
337
- });
338
- });
359
+ else if (Object.keys(localVarFormParams).length > 0) {
360
+ // URL-encoded form
361
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
362
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
363
+ }
364
+ }
365
+ const response = await fetch(url, requestOptions);
366
+ return this.handleResponse(response, 'CreateImpulseResponse');
339
367
  }
340
368
  /**
341
369
  * Create a new empty impulse, and return the ID.
@@ -347,9 +375,11 @@ class ImpulseApi {
347
375
  const localVarPath = this.basePath + '/api/{projectId}/impulse/new'
348
376
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
349
377
  let localVarQueryParameters = {};
350
- let localVarHeaderParams = Object.assign({
351
- 'User-Agent': 'edgeimpulse-api nodejs'
352
- }, this.defaultHeaders);
378
+ let localVarHeaderParams = {
379
+ 'User-Agent': 'edgeimpulse-api nodejs',
380
+ 'Content-Type': 'application/json',
381
+ ...this.defaultHeaders,
382
+ };
353
383
  const produces = ['application/json'];
354
384
  // give precedence to 'application/json'
355
385
  if (produces.indexOf('application/json') >= 0) {
@@ -358,61 +388,57 @@ class ImpulseApi {
358
388
  else {
359
389
  localVarHeaderParams.Accept = produces.join(',');
360
390
  }
361
- let localVarFormParams = {};
391
+ let localVarFormParams;
362
392
  // verify required parameter 'projectId' is not null or undefined
363
393
  if (projectId === null || projectId === undefined) {
364
394
  throw new Error('Required parameter projectId was null or undefined when calling createNewEmptyImpulse.');
365
395
  }
366
- Object.assign(localVarHeaderParams, options.headers);
367
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
368
- let localVarUseFormData = false;
396
+ localVarHeaderParams = {
397
+ ...localVarHeaderParams,
398
+ ...options.headers,
399
+ ...this.opts.extraHeaders,
400
+ };
401
+ const queryString = Object.entries(localVarQueryParameters)
402
+ .filter(([, value]) => value !== undefined)
403
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
404
+ .join('&');
405
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
369
406
  let localVarRequestOptions = {
370
407
  method: 'POST',
371
- qs: localVarQueryParameters,
372
- headers: localVarHeaderParams,
373
- uri: localVarPath,
374
- useQuerystring: this._useQuerystring,
375
- agentOptions: { keepAlive: false },
376
- json: true,
377
- body: models_1.ObjectSerializer.serialize(createNewEmptyImpulseRequest, "CreateNewEmptyImpulseRequest")
408
+ headers: { ...localVarHeaderParams },
378
409
  };
379
- let authenticationPromise = Promise.resolve();
380
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
381
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
382
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
383
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
384
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
385
- return authenticationPromise.then(() => {
386
- if (Object.keys(localVarFormParams).length) {
387
- if (localVarUseFormData) {
388
- localVarRequestOptions.formData = localVarFormParams;
389
- }
390
- else {
391
- localVarRequestOptions.form = localVarFormParams;
392
- }
410
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(createNewEmptyImpulseRequest, "CreateNewEmptyImpulseRequest"));
411
+ let requestOptions = localVarRequestOptions;
412
+ let url = localVarUrl;
413
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
414
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
415
+ url = auth_ApiKeyAuthentication.url;
416
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
417
+ requestOptions = auth_JWTAuthentication.requestOptions;
418
+ url = auth_JWTAuthentication.url;
419
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
420
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
421
+ url = auth_JWTHttpHeaderAuthentication.url;
422
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
423
+ requestOptions = auth_OAuth2.requestOptions;
424
+ url = auth_OAuth2.url;
425
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
426
+ requestOptions = authDefault.requestOptions;
427
+ url = authDefault.url;
428
+ if (localVarFormParams) {
429
+ delete requestOptions.headers['Content-Type'];
430
+ if (localVarFormParams instanceof FormData) {
431
+ // FormData: fetch will handle Content-Type automatically.
432
+ requestOptions.body = localVarFormParams;
393
433
  }
394
- return new Promise((resolve, reject) => {
395
- localVarRequest(localVarRequestOptions, (error, response, body) => {
396
- if (error) {
397
- reject(error);
398
- }
399
- else {
400
- body = models_1.ObjectSerializer.deserialize(body, "CreateNewEmptyImpulseResponse");
401
- if (typeof body.success === 'boolean' && !body.success) {
402
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
403
- reject(new Error(body.error || errString));
404
- }
405
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
406
- resolve(body);
407
- }
408
- else {
409
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
410
- reject(errString);
411
- }
412
- }
413
- });
414
- });
415
- });
434
+ else if (Object.keys(localVarFormParams).length > 0) {
435
+ // URL-encoded form
436
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
437
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
438
+ }
439
+ }
440
+ const response = await fetch(url, requestOptions);
441
+ return this.handleResponse(response, 'CreateNewEmptyImpulseResponse');
416
442
  }
417
443
  /**
418
444
  * Clears the impulse and all associated blocks for this project. If you specify `impulseId` then that impulse is cleared, otherwise the default impulse is cleared.
@@ -424,9 +450,11 @@ class ImpulseApi {
424
450
  const localVarPath = this.basePath + '/api/{projectId}/impulse'
425
451
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
426
452
  let localVarQueryParameters = {};
427
- let localVarHeaderParams = Object.assign({
428
- 'User-Agent': 'edgeimpulse-api nodejs'
429
- }, this.defaultHeaders);
453
+ let localVarHeaderParams = {
454
+ 'User-Agent': 'edgeimpulse-api nodejs',
455
+ 'Content-Type': 'application/json',
456
+ ...this.defaultHeaders,
457
+ };
430
458
  const produces = ['application/json'];
431
459
  // give precedence to 'application/json'
432
460
  if (produces.indexOf('application/json') >= 0) {
@@ -435,7 +463,7 @@ class ImpulseApi {
435
463
  else {
436
464
  localVarHeaderParams.Accept = produces.join(',');
437
465
  }
438
- let localVarFormParams = {};
466
+ let localVarFormParams;
439
467
  // verify required parameter 'projectId' is not null or undefined
440
468
  if (projectId === null || projectId === undefined) {
441
469
  throw new Error('Required parameter projectId was null or undefined when calling deleteImpulse.');
@@ -443,55 +471,51 @@ class ImpulseApi {
443
471
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
444
472
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
445
473
  }
446
- Object.assign(localVarHeaderParams, options.headers);
447
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
448
- let localVarUseFormData = false;
474
+ localVarHeaderParams = {
475
+ ...localVarHeaderParams,
476
+ ...options.headers,
477
+ ...this.opts.extraHeaders,
478
+ };
479
+ const queryString = Object.entries(localVarQueryParameters)
480
+ .filter(([, value]) => value !== undefined)
481
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
482
+ .join('&');
483
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
449
484
  let localVarRequestOptions = {
450
485
  method: 'DELETE',
451
- qs: localVarQueryParameters,
452
- headers: localVarHeaderParams,
453
- uri: localVarPath,
454
- useQuerystring: this._useQuerystring,
455
- agentOptions: { keepAlive: false },
456
- json: true,
486
+ headers: { ...localVarHeaderParams },
457
487
  };
458
- let authenticationPromise = Promise.resolve();
459
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
460
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
461
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
462
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
463
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
464
- return authenticationPromise.then(() => {
465
- if (Object.keys(localVarFormParams).length) {
466
- if (localVarUseFormData) {
467
- localVarRequestOptions.formData = localVarFormParams;
468
- }
469
- else {
470
- localVarRequestOptions.form = localVarFormParams;
471
- }
488
+ let requestOptions = localVarRequestOptions;
489
+ let url = localVarUrl;
490
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
491
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
492
+ url = auth_ApiKeyAuthentication.url;
493
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
494
+ requestOptions = auth_JWTAuthentication.requestOptions;
495
+ url = auth_JWTAuthentication.url;
496
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
497
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
498
+ url = auth_JWTHttpHeaderAuthentication.url;
499
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
500
+ requestOptions = auth_OAuth2.requestOptions;
501
+ url = auth_OAuth2.url;
502
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
503
+ requestOptions = authDefault.requestOptions;
504
+ url = authDefault.url;
505
+ if (localVarFormParams) {
506
+ delete requestOptions.headers['Content-Type'];
507
+ if (localVarFormParams instanceof FormData) {
508
+ // FormData: fetch will handle Content-Type automatically.
509
+ requestOptions.body = localVarFormParams;
472
510
  }
473
- return new Promise((resolve, reject) => {
474
- localVarRequest(localVarRequestOptions, (error, response, body) => {
475
- if (error) {
476
- reject(error);
477
- }
478
- else {
479
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
480
- if (typeof body.success === 'boolean' && !body.success) {
481
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
482
- reject(new Error(body.error || errString));
483
- }
484
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
485
- resolve(body);
486
- }
487
- else {
488
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
489
- reject(errString);
490
- }
491
- }
492
- });
493
- });
494
- });
511
+ else if (Object.keys(localVarFormParams).length > 0) {
512
+ // URL-encoded form
513
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
514
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
515
+ }
516
+ }
517
+ const response = await fetch(url, requestOptions);
518
+ return this.handleResponse(response, 'GenericApiResponse');
495
519
  }
496
520
  /**
497
521
  * Download all impulse for a project, including accuracy and performance metrics, as JSON or CSV.
@@ -503,9 +527,11 @@ class ImpulseApi {
503
527
  const localVarPath = this.basePath + '/api/{projectId}/download-impulses-detailed'
504
528
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
505
529
  let localVarQueryParameters = {};
506
- let localVarHeaderParams = Object.assign({
507
- 'User-Agent': 'edgeimpulse-api nodejs'
508
- }, this.defaultHeaders);
530
+ let localVarHeaderParams = {
531
+ 'User-Agent': 'edgeimpulse-api nodejs',
532
+ 'Content-Type': 'application/json',
533
+ ...this.defaultHeaders,
534
+ };
509
535
  const produces = ['application/octet-stream'];
510
536
  // give precedence to 'application/json'
511
537
  if (produces.indexOf('application/json') >= 0) {
@@ -514,7 +540,7 @@ class ImpulseApi {
514
540
  else {
515
541
  localVarHeaderParams.Accept = produces.join(',');
516
542
  }
517
- let localVarFormParams = {};
543
+ let localVarFormParams;
518
544
  // verify required parameter 'projectId' is not null or undefined
519
545
  if (projectId === null || projectId === undefined) {
520
546
  throw new Error('Required parameter projectId was null or undefined when calling downloadDetailedImpulses.');
@@ -522,55 +548,51 @@ class ImpulseApi {
522
548
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.format) !== undefined) {
523
549
  localVarQueryParameters['format'] = models_1.ObjectSerializer.serialize(queryParams.format, "'json' | 'csv'");
524
550
  }
525
- Object.assign(localVarHeaderParams, options.headers);
526
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
527
- let localVarUseFormData = false;
551
+ localVarHeaderParams = {
552
+ ...localVarHeaderParams,
553
+ ...options.headers,
554
+ ...this.opts.extraHeaders,
555
+ };
556
+ const queryString = Object.entries(localVarQueryParameters)
557
+ .filter(([, value]) => value !== undefined)
558
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
559
+ .join('&');
560
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
528
561
  let localVarRequestOptions = {
529
562
  method: 'GET',
530
- qs: localVarQueryParameters,
531
- headers: localVarHeaderParams,
532
- uri: localVarPath,
533
- useQuerystring: this._useQuerystring,
534
- agentOptions: { keepAlive: false },
535
- encoding: null,
563
+ headers: { ...localVarHeaderParams },
536
564
  };
537
- let authenticationPromise = Promise.resolve();
538
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
539
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
540
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
541
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
542
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
543
- return authenticationPromise.then(() => {
544
- if (Object.keys(localVarFormParams).length) {
545
- if (localVarUseFormData) {
546
- localVarRequestOptions.formData = localVarFormParams;
547
- }
548
- else {
549
- localVarRequestOptions.form = localVarFormParams;
550
- }
565
+ let requestOptions = localVarRequestOptions;
566
+ let url = localVarUrl;
567
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
568
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
569
+ url = auth_ApiKeyAuthentication.url;
570
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
571
+ requestOptions = auth_JWTAuthentication.requestOptions;
572
+ url = auth_JWTAuthentication.url;
573
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
574
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
575
+ url = auth_JWTHttpHeaderAuthentication.url;
576
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
577
+ requestOptions = auth_OAuth2.requestOptions;
578
+ url = auth_OAuth2.url;
579
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
580
+ requestOptions = authDefault.requestOptions;
581
+ url = authDefault.url;
582
+ if (localVarFormParams) {
583
+ delete requestOptions.headers['Content-Type'];
584
+ if (localVarFormParams instanceof FormData) {
585
+ // FormData: fetch will handle Content-Type automatically.
586
+ requestOptions.body = localVarFormParams;
551
587
  }
552
- return new Promise((resolve, reject) => {
553
- localVarRequest(localVarRequestOptions, (error, response, body) => {
554
- if (error) {
555
- reject(error);
556
- }
557
- else {
558
- body = models_1.ObjectSerializer.deserialize(body, "Buffer");
559
- if (typeof body.success === 'boolean' && !body.success) {
560
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
561
- reject(new Error(body.error || errString));
562
- }
563
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
564
- resolve(body);
565
- }
566
- else {
567
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
568
- reject(errString);
569
- }
570
- }
571
- });
572
- });
573
- });
588
+ else if (Object.keys(localVarFormParams).length > 0) {
589
+ // URL-encoded form
590
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
591
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
592
+ }
593
+ }
594
+ const response = await fetch(url, requestOptions);
595
+ return this.handleResponse(response, 'Buffer');
574
596
  }
575
597
  /**
576
598
  * Retrieve all impulse for a project, including accuracy and performance metrics.
@@ -581,9 +603,11 @@ class ImpulseApi {
581
603
  const localVarPath = this.basePath + '/api/{projectId}/impulses-detailed'
582
604
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
583
605
  let localVarQueryParameters = {};
584
- let localVarHeaderParams = Object.assign({
585
- 'User-Agent': 'edgeimpulse-api nodejs'
586
- }, this.defaultHeaders);
606
+ let localVarHeaderParams = {
607
+ 'User-Agent': 'edgeimpulse-api nodejs',
608
+ 'Content-Type': 'application/json',
609
+ ...this.defaultHeaders,
610
+ };
587
611
  const produces = ['application/json'];
588
612
  // give precedence to 'application/json'
589
613
  if (produces.indexOf('application/json') >= 0) {
@@ -592,60 +616,56 @@ class ImpulseApi {
592
616
  else {
593
617
  localVarHeaderParams.Accept = produces.join(',');
594
618
  }
595
- let localVarFormParams = {};
619
+ let localVarFormParams;
596
620
  // verify required parameter 'projectId' is not null or undefined
597
621
  if (projectId === null || projectId === undefined) {
598
622
  throw new Error('Required parameter projectId was null or undefined when calling getAllDetailedImpulses.');
599
623
  }
600
- Object.assign(localVarHeaderParams, options.headers);
601
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
602
- let localVarUseFormData = false;
624
+ localVarHeaderParams = {
625
+ ...localVarHeaderParams,
626
+ ...options.headers,
627
+ ...this.opts.extraHeaders,
628
+ };
629
+ const queryString = Object.entries(localVarQueryParameters)
630
+ .filter(([, value]) => value !== undefined)
631
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
632
+ .join('&');
633
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
603
634
  let localVarRequestOptions = {
604
635
  method: 'GET',
605
- qs: localVarQueryParameters,
606
- headers: localVarHeaderParams,
607
- uri: localVarPath,
608
- useQuerystring: this._useQuerystring,
609
- agentOptions: { keepAlive: false },
610
- json: true,
636
+ headers: { ...localVarHeaderParams },
611
637
  };
612
- let authenticationPromise = Promise.resolve();
613
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
614
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
615
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
616
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
617
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
618
- return authenticationPromise.then(() => {
619
- if (Object.keys(localVarFormParams).length) {
620
- if (localVarUseFormData) {
621
- localVarRequestOptions.formData = localVarFormParams;
622
- }
623
- else {
624
- localVarRequestOptions.form = localVarFormParams;
625
- }
638
+ let requestOptions = localVarRequestOptions;
639
+ let url = localVarUrl;
640
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
641
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
642
+ url = auth_ApiKeyAuthentication.url;
643
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
644
+ requestOptions = auth_JWTAuthentication.requestOptions;
645
+ url = auth_JWTAuthentication.url;
646
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
647
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
648
+ url = auth_JWTHttpHeaderAuthentication.url;
649
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
650
+ requestOptions = auth_OAuth2.requestOptions;
651
+ url = auth_OAuth2.url;
652
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
653
+ requestOptions = authDefault.requestOptions;
654
+ url = authDefault.url;
655
+ if (localVarFormParams) {
656
+ delete requestOptions.headers['Content-Type'];
657
+ if (localVarFormParams instanceof FormData) {
658
+ // FormData: fetch will handle Content-Type automatically.
659
+ requestOptions.body = localVarFormParams;
626
660
  }
627
- return new Promise((resolve, reject) => {
628
- localVarRequest(localVarRequestOptions, (error, response, body) => {
629
- if (error) {
630
- reject(error);
631
- }
632
- else {
633
- body = models_1.ObjectSerializer.deserialize(body, "GetAllDetailedImpulsesResponse");
634
- if (typeof body.success === 'boolean' && !body.success) {
635
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
636
- reject(new Error(body.error || errString));
637
- }
638
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
639
- resolve(body);
640
- }
641
- else {
642
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
643
- reject(errString);
644
- }
645
- }
646
- });
647
- });
648
- });
661
+ else if (Object.keys(localVarFormParams).length > 0) {
662
+ // URL-encoded form
663
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
664
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
665
+ }
666
+ }
667
+ const response = await fetch(url, requestOptions);
668
+ return this.handleResponse(response, 'GetAllDetailedImpulsesResponse');
649
669
  }
650
670
  /**
651
671
  * Retrieve all impulse for a project
@@ -656,9 +676,11 @@ class ImpulseApi {
656
676
  const localVarPath = this.basePath + '/api/{projectId}/impulses'
657
677
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
658
678
  let localVarQueryParameters = {};
659
- let localVarHeaderParams = Object.assign({
660
- 'User-Agent': 'edgeimpulse-api nodejs'
661
- }, this.defaultHeaders);
679
+ let localVarHeaderParams = {
680
+ 'User-Agent': 'edgeimpulse-api nodejs',
681
+ 'Content-Type': 'application/json',
682
+ ...this.defaultHeaders,
683
+ };
662
684
  const produces = ['application/json'];
663
685
  // give precedence to 'application/json'
664
686
  if (produces.indexOf('application/json') >= 0) {
@@ -667,60 +689,56 @@ class ImpulseApi {
667
689
  else {
668
690
  localVarHeaderParams.Accept = produces.join(',');
669
691
  }
670
- let localVarFormParams = {};
692
+ let localVarFormParams;
671
693
  // verify required parameter 'projectId' is not null or undefined
672
694
  if (projectId === null || projectId === undefined) {
673
695
  throw new Error('Required parameter projectId was null or undefined when calling getAllImpulses.');
674
696
  }
675
- Object.assign(localVarHeaderParams, options.headers);
676
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
677
- let localVarUseFormData = false;
697
+ localVarHeaderParams = {
698
+ ...localVarHeaderParams,
699
+ ...options.headers,
700
+ ...this.opts.extraHeaders,
701
+ };
702
+ const queryString = Object.entries(localVarQueryParameters)
703
+ .filter(([, value]) => value !== undefined)
704
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
705
+ .join('&');
706
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
678
707
  let localVarRequestOptions = {
679
708
  method: 'GET',
680
- qs: localVarQueryParameters,
681
- headers: localVarHeaderParams,
682
- uri: localVarPath,
683
- useQuerystring: this._useQuerystring,
684
- agentOptions: { keepAlive: false },
685
- json: true,
709
+ headers: { ...localVarHeaderParams },
686
710
  };
687
- let authenticationPromise = Promise.resolve();
688
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
689
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
690
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
691
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
692
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
693
- return authenticationPromise.then(() => {
694
- if (Object.keys(localVarFormParams).length) {
695
- if (localVarUseFormData) {
696
- localVarRequestOptions.formData = localVarFormParams;
697
- }
698
- else {
699
- localVarRequestOptions.form = localVarFormParams;
700
- }
711
+ let requestOptions = localVarRequestOptions;
712
+ let url = localVarUrl;
713
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
714
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
715
+ url = auth_ApiKeyAuthentication.url;
716
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
717
+ requestOptions = auth_JWTAuthentication.requestOptions;
718
+ url = auth_JWTAuthentication.url;
719
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
720
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
721
+ url = auth_JWTHttpHeaderAuthentication.url;
722
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
723
+ requestOptions = auth_OAuth2.requestOptions;
724
+ url = auth_OAuth2.url;
725
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
726
+ requestOptions = authDefault.requestOptions;
727
+ url = authDefault.url;
728
+ if (localVarFormParams) {
729
+ delete requestOptions.headers['Content-Type'];
730
+ if (localVarFormParams instanceof FormData) {
731
+ // FormData: fetch will handle Content-Type automatically.
732
+ requestOptions.body = localVarFormParams;
701
733
  }
702
- return new Promise((resolve, reject) => {
703
- localVarRequest(localVarRequestOptions, (error, response, body) => {
704
- if (error) {
705
- reject(error);
706
- }
707
- else {
708
- body = models_1.ObjectSerializer.deserialize(body, "GetAllImpulsesResponse");
709
- if (typeof body.success === 'boolean' && !body.success) {
710
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
711
- reject(new Error(body.error || errString));
712
- }
713
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
714
- resolve(body);
715
- }
716
- else {
717
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
718
- reject(errString);
719
- }
720
- }
721
- });
722
- });
723
- });
734
+ else if (Object.keys(localVarFormParams).length > 0) {
735
+ // URL-encoded form
736
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
737
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
738
+ }
739
+ }
740
+ const response = await fetch(url, requestOptions);
741
+ return this.handleResponse(response, 'GetAllImpulsesResponse');
724
742
  }
725
743
  /**
726
744
  * Retrieve all transfer learning models across all categories
@@ -731,9 +749,11 @@ class ImpulseApi {
731
749
  const localVarPath = this.basePath + '/api/{projectId}/transfer-learning-models'
732
750
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
733
751
  let localVarQueryParameters = {};
734
- let localVarHeaderParams = Object.assign({
735
- 'User-Agent': 'edgeimpulse-api nodejs'
736
- }, this.defaultHeaders);
752
+ let localVarHeaderParams = {
753
+ 'User-Agent': 'edgeimpulse-api nodejs',
754
+ 'Content-Type': 'application/json',
755
+ ...this.defaultHeaders,
756
+ };
737
757
  const produces = ['application/json'];
738
758
  // give precedence to 'application/json'
739
759
  if (produces.indexOf('application/json') >= 0) {
@@ -742,60 +762,56 @@ class ImpulseApi {
742
762
  else {
743
763
  localVarHeaderParams.Accept = produces.join(',');
744
764
  }
745
- let localVarFormParams = {};
765
+ let localVarFormParams;
746
766
  // verify required parameter 'projectId' is not null or undefined
747
767
  if (projectId === null || projectId === undefined) {
748
768
  throw new Error('Required parameter projectId was null or undefined when calling getAllTransferLearningModels.');
749
769
  }
750
- Object.assign(localVarHeaderParams, options.headers);
751
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
752
- let localVarUseFormData = false;
770
+ localVarHeaderParams = {
771
+ ...localVarHeaderParams,
772
+ ...options.headers,
773
+ ...this.opts.extraHeaders,
774
+ };
775
+ const queryString = Object.entries(localVarQueryParameters)
776
+ .filter(([, value]) => value !== undefined)
777
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
778
+ .join('&');
779
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
753
780
  let localVarRequestOptions = {
754
781
  method: 'GET',
755
- qs: localVarQueryParameters,
756
- headers: localVarHeaderParams,
757
- uri: localVarPath,
758
- useQuerystring: this._useQuerystring,
759
- agentOptions: { keepAlive: false },
760
- json: true,
782
+ headers: { ...localVarHeaderParams },
761
783
  };
762
- let authenticationPromise = Promise.resolve();
763
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
764
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
765
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
766
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
767
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
768
- return authenticationPromise.then(() => {
769
- if (Object.keys(localVarFormParams).length) {
770
- if (localVarUseFormData) {
771
- localVarRequestOptions.formData = localVarFormParams;
772
- }
773
- else {
774
- localVarRequestOptions.form = localVarFormParams;
775
- }
784
+ let requestOptions = localVarRequestOptions;
785
+ let url = localVarUrl;
786
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
787
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
788
+ url = auth_ApiKeyAuthentication.url;
789
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
790
+ requestOptions = auth_JWTAuthentication.requestOptions;
791
+ url = auth_JWTAuthentication.url;
792
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
793
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
794
+ url = auth_JWTHttpHeaderAuthentication.url;
795
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
796
+ requestOptions = auth_OAuth2.requestOptions;
797
+ url = auth_OAuth2.url;
798
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
799
+ requestOptions = authDefault.requestOptions;
800
+ url = authDefault.url;
801
+ if (localVarFormParams) {
802
+ delete requestOptions.headers['Content-Type'];
803
+ if (localVarFormParams instanceof FormData) {
804
+ // FormData: fetch will handle Content-Type automatically.
805
+ requestOptions.body = localVarFormParams;
776
806
  }
777
- return new Promise((resolve, reject) => {
778
- localVarRequest(localVarRequestOptions, (error, response, body) => {
779
- if (error) {
780
- reject(error);
781
- }
782
- else {
783
- body = models_1.ObjectSerializer.deserialize(body, "GetAllTransferLearningModelsResponse");
784
- if (typeof body.success === 'boolean' && !body.success) {
785
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
786
- reject(new Error(body.error || errString));
787
- }
788
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
789
- resolve(body);
790
- }
791
- else {
792
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
793
- reject(errString);
794
- }
795
- }
796
- });
797
- });
798
- });
807
+ else if (Object.keys(localVarFormParams).length > 0) {
808
+ // URL-encoded form
809
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
810
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
811
+ }
812
+ }
813
+ const response = await fetch(url, requestOptions);
814
+ return this.handleResponse(response, 'GetAllTransferLearningModelsResponse');
799
815
  }
800
816
  /**
801
817
  * Retrieve the impulse for this project. If you specify `impulseId` then that impulse is returned, otherwise the default impulse is returned.
@@ -807,9 +823,11 @@ class ImpulseApi {
807
823
  const localVarPath = this.basePath + '/api/{projectId}/impulse'
808
824
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
809
825
  let localVarQueryParameters = {};
810
- let localVarHeaderParams = Object.assign({
811
- 'User-Agent': 'edgeimpulse-api nodejs'
812
- }, this.defaultHeaders);
826
+ let localVarHeaderParams = {
827
+ 'User-Agent': 'edgeimpulse-api nodejs',
828
+ 'Content-Type': 'application/json',
829
+ ...this.defaultHeaders,
830
+ };
813
831
  const produces = ['application/json'];
814
832
  // give precedence to 'application/json'
815
833
  if (produces.indexOf('application/json') >= 0) {
@@ -818,7 +836,7 @@ class ImpulseApi {
818
836
  else {
819
837
  localVarHeaderParams.Accept = produces.join(',');
820
838
  }
821
- let localVarFormParams = {};
839
+ let localVarFormParams;
822
840
  // verify required parameter 'projectId' is not null or undefined
823
841
  if (projectId === null || projectId === undefined) {
824
842
  throw new Error('Required parameter projectId was null or undefined when calling getImpulse.');
@@ -826,55 +844,51 @@ class ImpulseApi {
826
844
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
827
845
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
828
846
  }
829
- Object.assign(localVarHeaderParams, options.headers);
830
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
831
- let localVarUseFormData = false;
847
+ localVarHeaderParams = {
848
+ ...localVarHeaderParams,
849
+ ...options.headers,
850
+ ...this.opts.extraHeaders,
851
+ };
852
+ const queryString = Object.entries(localVarQueryParameters)
853
+ .filter(([, value]) => value !== undefined)
854
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
855
+ .join('&');
856
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
832
857
  let localVarRequestOptions = {
833
858
  method: 'GET',
834
- qs: localVarQueryParameters,
835
- headers: localVarHeaderParams,
836
- uri: localVarPath,
837
- useQuerystring: this._useQuerystring,
838
- agentOptions: { keepAlive: false },
839
- json: true,
859
+ headers: { ...localVarHeaderParams },
840
860
  };
841
- let authenticationPromise = Promise.resolve();
842
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
843
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
844
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
845
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
846
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
847
- return authenticationPromise.then(() => {
848
- if (Object.keys(localVarFormParams).length) {
849
- if (localVarUseFormData) {
850
- localVarRequestOptions.formData = localVarFormParams;
851
- }
852
- else {
853
- localVarRequestOptions.form = localVarFormParams;
854
- }
861
+ let requestOptions = localVarRequestOptions;
862
+ let url = localVarUrl;
863
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
864
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
865
+ url = auth_ApiKeyAuthentication.url;
866
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
867
+ requestOptions = auth_JWTAuthentication.requestOptions;
868
+ url = auth_JWTAuthentication.url;
869
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
870
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
871
+ url = auth_JWTHttpHeaderAuthentication.url;
872
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
873
+ requestOptions = auth_OAuth2.requestOptions;
874
+ url = auth_OAuth2.url;
875
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
876
+ requestOptions = authDefault.requestOptions;
877
+ url = authDefault.url;
878
+ if (localVarFormParams) {
879
+ delete requestOptions.headers['Content-Type'];
880
+ if (localVarFormParams instanceof FormData) {
881
+ // FormData: fetch will handle Content-Type automatically.
882
+ requestOptions.body = localVarFormParams;
855
883
  }
856
- return new Promise((resolve, reject) => {
857
- localVarRequest(localVarRequestOptions, (error, response, body) => {
858
- if (error) {
859
- reject(error);
860
- }
861
- else {
862
- body = models_1.ObjectSerializer.deserialize(body, "GetImpulseResponse");
863
- if (typeof body.success === 'boolean' && !body.success) {
864
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
865
- reject(new Error(body.error || errString));
866
- }
867
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
868
- resolve(body);
869
- }
870
- else {
871
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
872
- reject(errString);
873
- }
874
- }
875
- });
876
- });
877
- });
884
+ else if (Object.keys(localVarFormParams).length > 0) {
885
+ // URL-encoded form
886
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
887
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
888
+ }
889
+ }
890
+ const response = await fetch(url, requestOptions);
891
+ return this.handleResponse(response, 'GetImpulseResponse');
878
892
  }
879
893
  /**
880
894
  * Retrieve the impulse for this project including disabled blocks. If you specify `impulseId` then that impulse is returned, otherwise the default impulse is returned.
@@ -886,9 +900,11 @@ class ImpulseApi {
886
900
  const localVarPath = this.basePath + '/api/{projectId}/impulse/all'
887
901
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
888
902
  let localVarQueryParameters = {};
889
- let localVarHeaderParams = Object.assign({
890
- 'User-Agent': 'edgeimpulse-api nodejs'
891
- }, this.defaultHeaders);
903
+ let localVarHeaderParams = {
904
+ 'User-Agent': 'edgeimpulse-api nodejs',
905
+ 'Content-Type': 'application/json',
906
+ ...this.defaultHeaders,
907
+ };
892
908
  const produces = ['application/json'];
893
909
  // give precedence to 'application/json'
894
910
  if (produces.indexOf('application/json') >= 0) {
@@ -897,7 +913,7 @@ class ImpulseApi {
897
913
  else {
898
914
  localVarHeaderParams.Accept = produces.join(',');
899
915
  }
900
- let localVarFormParams = {};
916
+ let localVarFormParams;
901
917
  // verify required parameter 'projectId' is not null or undefined
902
918
  if (projectId === null || projectId === undefined) {
903
919
  throw new Error('Required parameter projectId was null or undefined when calling getImpulseAll.');
@@ -905,55 +921,51 @@ class ImpulseApi {
905
921
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
906
922
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
907
923
  }
908
- Object.assign(localVarHeaderParams, options.headers);
909
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
910
- let localVarUseFormData = false;
924
+ localVarHeaderParams = {
925
+ ...localVarHeaderParams,
926
+ ...options.headers,
927
+ ...this.opts.extraHeaders,
928
+ };
929
+ const queryString = Object.entries(localVarQueryParameters)
930
+ .filter(([, value]) => value !== undefined)
931
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
932
+ .join('&');
933
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
911
934
  let localVarRequestOptions = {
912
935
  method: 'GET',
913
- qs: localVarQueryParameters,
914
- headers: localVarHeaderParams,
915
- uri: localVarPath,
916
- useQuerystring: this._useQuerystring,
917
- agentOptions: { keepAlive: false },
918
- json: true,
936
+ headers: { ...localVarHeaderParams },
919
937
  };
920
- let authenticationPromise = Promise.resolve();
921
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
922
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
923
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
924
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
925
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
926
- return authenticationPromise.then(() => {
927
- if (Object.keys(localVarFormParams).length) {
928
- if (localVarUseFormData) {
929
- localVarRequestOptions.formData = localVarFormParams;
930
- }
931
- else {
932
- localVarRequestOptions.form = localVarFormParams;
933
- }
938
+ let requestOptions = localVarRequestOptions;
939
+ let url = localVarUrl;
940
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
941
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
942
+ url = auth_ApiKeyAuthentication.url;
943
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
944
+ requestOptions = auth_JWTAuthentication.requestOptions;
945
+ url = auth_JWTAuthentication.url;
946
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
947
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
948
+ url = auth_JWTHttpHeaderAuthentication.url;
949
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
950
+ requestOptions = auth_OAuth2.requestOptions;
951
+ url = auth_OAuth2.url;
952
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
953
+ requestOptions = authDefault.requestOptions;
954
+ url = authDefault.url;
955
+ if (localVarFormParams) {
956
+ delete requestOptions.headers['Content-Type'];
957
+ if (localVarFormParams instanceof FormData) {
958
+ // FormData: fetch will handle Content-Type automatically.
959
+ requestOptions.body = localVarFormParams;
934
960
  }
935
- return new Promise((resolve, reject) => {
936
- localVarRequest(localVarRequestOptions, (error, response, body) => {
937
- if (error) {
938
- reject(error);
939
- }
940
- else {
941
- body = models_1.ObjectSerializer.deserialize(body, "GetImpulseResponse");
942
- if (typeof body.success === 'boolean' && !body.success) {
943
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
944
- reject(new Error(body.error || errString));
945
- }
946
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
947
- resolve(body);
948
- }
949
- else {
950
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
951
- reject(errString);
952
- }
953
- }
954
- });
955
- });
956
- });
961
+ else if (Object.keys(localVarFormParams).length > 0) {
962
+ // URL-encoded form
963
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
964
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
965
+ }
966
+ }
967
+ const response = await fetch(url, requestOptions);
968
+ return this.handleResponse(response, 'GetImpulseResponse');
957
969
  }
958
970
  /**
959
971
  * Lists all possible blocks that can be used in the impulse
@@ -964,9 +976,11 @@ class ImpulseApi {
964
976
  const localVarPath = this.basePath + '/api/{projectId}/impulse/blocks'
965
977
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
966
978
  let localVarQueryParameters = {};
967
- let localVarHeaderParams = Object.assign({
968
- 'User-Agent': 'edgeimpulse-api nodejs'
969
- }, this.defaultHeaders);
979
+ let localVarHeaderParams = {
980
+ 'User-Agent': 'edgeimpulse-api nodejs',
981
+ 'Content-Type': 'application/json',
982
+ ...this.defaultHeaders,
983
+ };
970
984
  const produces = ['application/json'];
971
985
  // give precedence to 'application/json'
972
986
  if (produces.indexOf('application/json') >= 0) {
@@ -975,60 +989,56 @@ class ImpulseApi {
975
989
  else {
976
990
  localVarHeaderParams.Accept = produces.join(',');
977
991
  }
978
- let localVarFormParams = {};
992
+ let localVarFormParams;
979
993
  // verify required parameter 'projectId' is not null or undefined
980
994
  if (projectId === null || projectId === undefined) {
981
995
  throw new Error('Required parameter projectId was null or undefined when calling getImpulseBlocks.');
982
996
  }
983
- Object.assign(localVarHeaderParams, options.headers);
984
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
985
- let localVarUseFormData = false;
997
+ localVarHeaderParams = {
998
+ ...localVarHeaderParams,
999
+ ...options.headers,
1000
+ ...this.opts.extraHeaders,
1001
+ };
1002
+ const queryString = Object.entries(localVarQueryParameters)
1003
+ .filter(([, value]) => value !== undefined)
1004
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1005
+ .join('&');
1006
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
986
1007
  let localVarRequestOptions = {
987
1008
  method: 'GET',
988
- qs: localVarQueryParameters,
989
- headers: localVarHeaderParams,
990
- uri: localVarPath,
991
- useQuerystring: this._useQuerystring,
992
- agentOptions: { keepAlive: false },
993
- json: true,
1009
+ headers: { ...localVarHeaderParams },
994
1010
  };
995
- let authenticationPromise = Promise.resolve();
996
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
997
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
998
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
999
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1000
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1001
- return authenticationPromise.then(() => {
1002
- if (Object.keys(localVarFormParams).length) {
1003
- if (localVarUseFormData) {
1004
- localVarRequestOptions.formData = localVarFormParams;
1005
- }
1006
- else {
1007
- localVarRequestOptions.form = localVarFormParams;
1008
- }
1011
+ let requestOptions = localVarRequestOptions;
1012
+ let url = localVarUrl;
1013
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1014
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1015
+ url = auth_ApiKeyAuthentication.url;
1016
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1017
+ requestOptions = auth_JWTAuthentication.requestOptions;
1018
+ url = auth_JWTAuthentication.url;
1019
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1020
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1021
+ url = auth_JWTHttpHeaderAuthentication.url;
1022
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1023
+ requestOptions = auth_OAuth2.requestOptions;
1024
+ url = auth_OAuth2.url;
1025
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1026
+ requestOptions = authDefault.requestOptions;
1027
+ url = authDefault.url;
1028
+ if (localVarFormParams) {
1029
+ delete requestOptions.headers['Content-Type'];
1030
+ if (localVarFormParams instanceof FormData) {
1031
+ // FormData: fetch will handle Content-Type automatically.
1032
+ requestOptions.body = localVarFormParams;
1009
1033
  }
1010
- return new Promise((resolve, reject) => {
1011
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1012
- if (error) {
1013
- reject(error);
1014
- }
1015
- else {
1016
- body = models_1.ObjectSerializer.deserialize(body, "GetImpulseBlocksResponse");
1017
- if (typeof body.success === 'boolean' && !body.success) {
1018
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1019
- reject(new Error(body.error || errString));
1020
- }
1021
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1022
- resolve(body);
1023
- }
1024
- else {
1025
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1026
- reject(errString);
1027
- }
1028
- }
1029
- });
1030
- });
1031
- });
1034
+ else if (Object.keys(localVarFormParams).length > 0) {
1035
+ // URL-encoded form
1036
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1037
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1038
+ }
1039
+ }
1040
+ const response = await fetch(url, requestOptions);
1041
+ return this.handleResponse(response, 'GetImpulseBlocksResponse');
1032
1042
  }
1033
1043
  /**
1034
1044
  * Returns an unused block ID. Use this function to determine new block IDs when you construct an impulse; so you won\'t accidentally re-use block IDs.
@@ -1039,9 +1049,11 @@ class ImpulseApi {
1039
1049
  const localVarPath = this.basePath + '/api/{projectId}/impulse/get-new-block-id'
1040
1050
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
1041
1051
  let localVarQueryParameters = {};
1042
- let localVarHeaderParams = Object.assign({
1043
- 'User-Agent': 'edgeimpulse-api nodejs'
1044
- }, this.defaultHeaders);
1052
+ let localVarHeaderParams = {
1053
+ 'User-Agent': 'edgeimpulse-api nodejs',
1054
+ 'Content-Type': 'application/json',
1055
+ ...this.defaultHeaders,
1056
+ };
1045
1057
  const produces = ['application/json'];
1046
1058
  // give precedence to 'application/json'
1047
1059
  if (produces.indexOf('application/json') >= 0) {
@@ -1050,60 +1062,56 @@ class ImpulseApi {
1050
1062
  else {
1051
1063
  localVarHeaderParams.Accept = produces.join(',');
1052
1064
  }
1053
- let localVarFormParams = {};
1065
+ let localVarFormParams;
1054
1066
  // verify required parameter 'projectId' is not null or undefined
1055
1067
  if (projectId === null || projectId === undefined) {
1056
1068
  throw new Error('Required parameter projectId was null or undefined when calling getNewBlockId.');
1057
1069
  }
1058
- Object.assign(localVarHeaderParams, options.headers);
1059
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1060
- let localVarUseFormData = false;
1070
+ localVarHeaderParams = {
1071
+ ...localVarHeaderParams,
1072
+ ...options.headers,
1073
+ ...this.opts.extraHeaders,
1074
+ };
1075
+ const queryString = Object.entries(localVarQueryParameters)
1076
+ .filter(([, value]) => value !== undefined)
1077
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1078
+ .join('&');
1079
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1061
1080
  let localVarRequestOptions = {
1062
1081
  method: 'POST',
1063
- qs: localVarQueryParameters,
1064
- headers: localVarHeaderParams,
1065
- uri: localVarPath,
1066
- useQuerystring: this._useQuerystring,
1067
- agentOptions: { keepAlive: false },
1068
- json: true,
1082
+ headers: { ...localVarHeaderParams },
1069
1083
  };
1070
- let authenticationPromise = Promise.resolve();
1071
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1072
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1073
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1074
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1075
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1076
- return authenticationPromise.then(() => {
1077
- if (Object.keys(localVarFormParams).length) {
1078
- if (localVarUseFormData) {
1079
- localVarRequestOptions.formData = localVarFormParams;
1080
- }
1081
- else {
1082
- localVarRequestOptions.form = localVarFormParams;
1083
- }
1084
+ let requestOptions = localVarRequestOptions;
1085
+ let url = localVarUrl;
1086
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1087
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1088
+ url = auth_ApiKeyAuthentication.url;
1089
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1090
+ requestOptions = auth_JWTAuthentication.requestOptions;
1091
+ url = auth_JWTAuthentication.url;
1092
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1093
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1094
+ url = auth_JWTHttpHeaderAuthentication.url;
1095
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1096
+ requestOptions = auth_OAuth2.requestOptions;
1097
+ url = auth_OAuth2.url;
1098
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1099
+ requestOptions = authDefault.requestOptions;
1100
+ url = authDefault.url;
1101
+ if (localVarFormParams) {
1102
+ delete requestOptions.headers['Content-Type'];
1103
+ if (localVarFormParams instanceof FormData) {
1104
+ // FormData: fetch will handle Content-Type automatically.
1105
+ requestOptions.body = localVarFormParams;
1084
1106
  }
1085
- return new Promise((resolve, reject) => {
1086
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1087
- if (error) {
1088
- reject(error);
1089
- }
1090
- else {
1091
- body = models_1.ObjectSerializer.deserialize(body, "GetNewBlockIdResponse");
1092
- if (typeof body.success === 'boolean' && !body.success) {
1093
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1094
- reject(new Error(body.error || errString));
1095
- }
1096
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1097
- resolve(body);
1098
- }
1099
- else {
1100
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1101
- reject(errString);
1102
- }
1103
- }
1104
- });
1105
- });
1106
- });
1107
+ else if (Object.keys(localVarFormParams).length > 0) {
1108
+ // URL-encoded form
1109
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1110
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1111
+ }
1112
+ }
1113
+ const response = await fetch(url, requestOptions);
1114
+ return this.handleResponse(response, 'GetNewBlockIdResponse');
1107
1115
  }
1108
1116
  /**
1109
1117
  * Regenerate model testing results (without re-running feature generation). Use this if thresholds changed (e.g. via setImpulseThresholds), but no job was kicked off automatically.
@@ -1116,9 +1124,11 @@ class ImpulseApi {
1116
1124
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
1117
1125
  .replace('{' + 'impulseId' + '}', encodeURIComponent(String(impulseId)));
1118
1126
  let localVarQueryParameters = {};
1119
- let localVarHeaderParams = Object.assign({
1120
- 'User-Agent': 'edgeimpulse-api nodejs'
1121
- }, this.defaultHeaders);
1127
+ let localVarHeaderParams = {
1128
+ 'User-Agent': 'edgeimpulse-api nodejs',
1129
+ 'Content-Type': 'application/json',
1130
+ ...this.defaultHeaders,
1131
+ };
1122
1132
  const produces = ['application/json'];
1123
1133
  // give precedence to 'application/json'
1124
1134
  if (produces.indexOf('application/json') >= 0) {
@@ -1127,7 +1137,7 @@ class ImpulseApi {
1127
1137
  else {
1128
1138
  localVarHeaderParams.Accept = produces.join(',');
1129
1139
  }
1130
- let localVarFormParams = {};
1140
+ let localVarFormParams;
1131
1141
  // verify required parameter 'projectId' is not null or undefined
1132
1142
  if (projectId === null || projectId === undefined) {
1133
1143
  throw new Error('Required parameter projectId was null or undefined when calling regenerateModelTestingSummary.');
@@ -1136,55 +1146,51 @@ class ImpulseApi {
1136
1146
  if (impulseId === null || impulseId === undefined) {
1137
1147
  throw new Error('Required parameter impulseId was null or undefined when calling regenerateModelTestingSummary.');
1138
1148
  }
1139
- Object.assign(localVarHeaderParams, options.headers);
1140
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1141
- let localVarUseFormData = false;
1149
+ localVarHeaderParams = {
1150
+ ...localVarHeaderParams,
1151
+ ...options.headers,
1152
+ ...this.opts.extraHeaders,
1153
+ };
1154
+ const queryString = Object.entries(localVarQueryParameters)
1155
+ .filter(([, value]) => value !== undefined)
1156
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1157
+ .join('&');
1158
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1142
1159
  let localVarRequestOptions = {
1143
1160
  method: 'POST',
1144
- qs: localVarQueryParameters,
1145
- headers: localVarHeaderParams,
1146
- uri: localVarPath,
1147
- useQuerystring: this._useQuerystring,
1148
- agentOptions: { keepAlive: false },
1149
- json: true,
1161
+ headers: { ...localVarHeaderParams },
1150
1162
  };
1151
- let authenticationPromise = Promise.resolve();
1152
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1153
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1154
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1155
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1156
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1157
- return authenticationPromise.then(() => {
1158
- if (Object.keys(localVarFormParams).length) {
1159
- if (localVarUseFormData) {
1160
- localVarRequestOptions.formData = localVarFormParams;
1161
- }
1162
- else {
1163
- localVarRequestOptions.form = localVarFormParams;
1164
- }
1163
+ let requestOptions = localVarRequestOptions;
1164
+ let url = localVarUrl;
1165
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1166
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1167
+ url = auth_ApiKeyAuthentication.url;
1168
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1169
+ requestOptions = auth_JWTAuthentication.requestOptions;
1170
+ url = auth_JWTAuthentication.url;
1171
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1172
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1173
+ url = auth_JWTHttpHeaderAuthentication.url;
1174
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1175
+ requestOptions = auth_OAuth2.requestOptions;
1176
+ url = auth_OAuth2.url;
1177
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1178
+ requestOptions = authDefault.requestOptions;
1179
+ url = authDefault.url;
1180
+ if (localVarFormParams) {
1181
+ delete requestOptions.headers['Content-Type'];
1182
+ if (localVarFormParams instanceof FormData) {
1183
+ // FormData: fetch will handle Content-Type automatically.
1184
+ requestOptions.body = localVarFormParams;
1165
1185
  }
1166
- return new Promise((resolve, reject) => {
1167
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1168
- if (error) {
1169
- reject(error);
1170
- }
1171
- else {
1172
- body = models_1.ObjectSerializer.deserialize(body, "StartJobResponse");
1173
- if (typeof body.success === 'boolean' && !body.success) {
1174
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1175
- reject(new Error(body.error || errString));
1176
- }
1177
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1178
- resolve(body);
1179
- }
1180
- else {
1181
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1182
- reject(errString);
1183
- }
1184
- }
1185
- });
1186
- });
1187
- });
1186
+ else if (Object.keys(localVarFormParams).length > 0) {
1187
+ // URL-encoded form
1188
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1189
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1190
+ }
1191
+ }
1192
+ const response = await fetch(url, requestOptions);
1193
+ return this.handleResponse(response, 'StartJobResponse');
1188
1194
  }
1189
1195
  /**
1190
1196
  * Set thresholds (e.g. min. confidence rating, or min. anomaly score) for an impulse.
@@ -1198,9 +1204,11 @@ class ImpulseApi {
1198
1204
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
1199
1205
  .replace('{' + 'impulseId' + '}', encodeURIComponent(String(impulseId)));
1200
1206
  let localVarQueryParameters = {};
1201
- let localVarHeaderParams = Object.assign({
1202
- 'User-Agent': 'edgeimpulse-api nodejs'
1203
- }, this.defaultHeaders);
1207
+ let localVarHeaderParams = {
1208
+ 'User-Agent': 'edgeimpulse-api nodejs',
1209
+ 'Content-Type': 'application/json',
1210
+ ...this.defaultHeaders,
1211
+ };
1204
1212
  const produces = ['application/json'];
1205
1213
  // give precedence to 'application/json'
1206
1214
  if (produces.indexOf('application/json') >= 0) {
@@ -1209,7 +1217,7 @@ class ImpulseApi {
1209
1217
  else {
1210
1218
  localVarHeaderParams.Accept = produces.join(',');
1211
1219
  }
1212
- let localVarFormParams = {};
1220
+ let localVarFormParams;
1213
1221
  // verify required parameter 'projectId' is not null or undefined
1214
1222
  if (projectId === null || projectId === undefined) {
1215
1223
  throw new Error('Required parameter projectId was null or undefined when calling setImpulseThresholds.');
@@ -1222,56 +1230,52 @@ class ImpulseApi {
1222
1230
  if (setImpulseThresholdsRequest === null || setImpulseThresholdsRequest === undefined) {
1223
1231
  throw new Error('Required parameter setImpulseThresholdsRequest was null or undefined when calling setImpulseThresholds.');
1224
1232
  }
1225
- Object.assign(localVarHeaderParams, options.headers);
1226
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1227
- let localVarUseFormData = false;
1233
+ localVarHeaderParams = {
1234
+ ...localVarHeaderParams,
1235
+ ...options.headers,
1236
+ ...this.opts.extraHeaders,
1237
+ };
1238
+ const queryString = Object.entries(localVarQueryParameters)
1239
+ .filter(([, value]) => value !== undefined)
1240
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1241
+ .join('&');
1242
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1228
1243
  let localVarRequestOptions = {
1229
1244
  method: 'POST',
1230
- qs: localVarQueryParameters,
1231
- headers: localVarHeaderParams,
1232
- uri: localVarPath,
1233
- useQuerystring: this._useQuerystring,
1234
- agentOptions: { keepAlive: false },
1235
- json: true,
1236
- body: models_1.ObjectSerializer.serialize(setImpulseThresholdsRequest, "SetImpulseThresholdsRequest")
1245
+ headers: { ...localVarHeaderParams },
1237
1246
  };
1238
- let authenticationPromise = Promise.resolve();
1239
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1240
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1241
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1242
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1243
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1244
- return authenticationPromise.then(() => {
1245
- if (Object.keys(localVarFormParams).length) {
1246
- if (localVarUseFormData) {
1247
- localVarRequestOptions.formData = localVarFormParams;
1248
- }
1249
- else {
1250
- localVarRequestOptions.form = localVarFormParams;
1251
- }
1247
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(setImpulseThresholdsRequest, "SetImpulseThresholdsRequest"));
1248
+ let requestOptions = localVarRequestOptions;
1249
+ let url = localVarUrl;
1250
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1251
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1252
+ url = auth_ApiKeyAuthentication.url;
1253
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1254
+ requestOptions = auth_JWTAuthentication.requestOptions;
1255
+ url = auth_JWTAuthentication.url;
1256
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1257
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1258
+ url = auth_JWTHttpHeaderAuthentication.url;
1259
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1260
+ requestOptions = auth_OAuth2.requestOptions;
1261
+ url = auth_OAuth2.url;
1262
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1263
+ requestOptions = authDefault.requestOptions;
1264
+ url = authDefault.url;
1265
+ if (localVarFormParams) {
1266
+ delete requestOptions.headers['Content-Type'];
1267
+ if (localVarFormParams instanceof FormData) {
1268
+ // FormData: fetch will handle Content-Type automatically.
1269
+ requestOptions.body = localVarFormParams;
1252
1270
  }
1253
- return new Promise((resolve, reject) => {
1254
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1255
- if (error) {
1256
- reject(error);
1257
- }
1258
- else {
1259
- body = models_1.ObjectSerializer.deserialize(body, "SetImpulseThresholdsResponse");
1260
- if (typeof body.success === 'boolean' && !body.success) {
1261
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1262
- reject(new Error(body.error || errString));
1263
- }
1264
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1265
- resolve(body);
1266
- }
1267
- else {
1268
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1269
- reject(errString);
1270
- }
1271
- }
1272
- });
1273
- });
1274
- });
1271
+ else if (Object.keys(localVarFormParams).length > 0) {
1272
+ // URL-encoded form
1273
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1274
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1275
+ }
1276
+ }
1277
+ const response = await fetch(url, requestOptions);
1278
+ return this.handleResponse(response, 'SetImpulseThresholdsResponse');
1275
1279
  }
1276
1280
  /**
1277
1281
  * Set the complete impulse state for a project, writing impulses in the old (pre-impulse experiments) format. This completely clears out all files on FSx for this project. This is an internal API.
@@ -1285,9 +1289,11 @@ class ImpulseApi {
1285
1289
  const localVarPath = this.basePath + '/api/{projectId}/impulse/legacy-set-impulse'
1286
1290
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
1287
1291
  let localVarQueryParameters = {};
1288
- let localVarHeaderParams = Object.assign({
1289
- 'User-Agent': 'edgeimpulse-api nodejs'
1290
- }, this.defaultHeaders);
1292
+ let localVarHeaderParams = {
1293
+ 'User-Agent': 'edgeimpulse-api nodejs',
1294
+ 'Content-Type': 'application/json',
1295
+ ...this.defaultHeaders,
1296
+ };
1291
1297
  const produces = ['application/json'];
1292
1298
  // give precedence to 'application/json'
1293
1299
  if (produces.indexOf('application/json') >= 0) {
@@ -1296,7 +1302,7 @@ class ImpulseApi {
1296
1302
  else {
1297
1303
  localVarHeaderParams.Accept = produces.join(',');
1298
1304
  }
1299
- let localVarFormParams = {};
1305
+ let localVarFormParams;
1300
1306
  // verify required parameter 'projectId' is not null or undefined
1301
1307
  if (projectId === null || projectId === undefined) {
1302
1308
  throw new Error('Required parameter projectId was null or undefined when calling setLegacyImpulseStateInternal.');
@@ -1313,67 +1319,105 @@ class ImpulseApi {
1313
1319
  if (params.config === null || params.config === undefined) {
1314
1320
  throw new Error('Required parameter params.config was null or undefined when calling setLegacyImpulseStateInternal.');
1315
1321
  }
1316
- Object.assign(localVarHeaderParams, options.headers);
1317
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1318
- let localVarUseFormData = false;
1322
+ localVarHeaderParams = {
1323
+ ...localVarHeaderParams,
1324
+ ...options.headers,
1325
+ ...this.opts.extraHeaders,
1326
+ };
1319
1327
  if (params.zip !== undefined) {
1320
- localVarFormParams['zip'] = params.zip;
1328
+ if (!(localVarFormParams instanceof FormData)) {
1329
+ const existingParams = localVarFormParams;
1330
+ localVarFormParams = new FormData();
1331
+ if (existingParams && typeof existingParams === 'object') {
1332
+ Object.keys(existingParams).forEach(key => {
1333
+ localVarFormParams.append(key, existingParams[key]);
1334
+ });
1335
+ }
1336
+ }
1337
+ const zipFiles = Array.isArray(params.zip) ? params.zip : [params.zip];
1338
+ const Blob = globalThis.Blob || require('buffer').Blob;
1339
+ zipFiles.forEach((f) => {
1340
+ localVarFormParams.append('zip', new Blob([f.value], {
1341
+ type: f.options.contentType
1342
+ }), f.options.filename);
1343
+ });
1321
1344
  }
1322
- localVarUseFormData = true;
1323
1345
  if (params.impulse !== undefined) {
1324
- localVarFormParams['impulse'] = params.impulse;
1346
+ if (!(localVarFormParams instanceof FormData)) {
1347
+ const existingParams = localVarFormParams;
1348
+ localVarFormParams = new FormData();
1349
+ if (existingParams && typeof existingParams === 'object') {
1350
+ Object.keys(existingParams).forEach(key => {
1351
+ localVarFormParams.append(key, existingParams[key]);
1352
+ });
1353
+ }
1354
+ }
1355
+ const impulseFiles = Array.isArray(params.impulse) ? params.impulse : [params.impulse];
1356
+ const Blob = globalThis.Blob || require('buffer').Blob;
1357
+ impulseFiles.forEach((f) => {
1358
+ localVarFormParams.append('impulse', new Blob([f.value], {
1359
+ type: f.options.contentType
1360
+ }), f.options.filename);
1361
+ });
1325
1362
  }
1326
- localVarUseFormData = true;
1327
1363
  if (params.config !== undefined) {
1328
- localVarFormParams['config'] = params.config;
1364
+ if (!(localVarFormParams instanceof FormData)) {
1365
+ const existingParams = localVarFormParams;
1366
+ localVarFormParams = new FormData();
1367
+ if (existingParams && typeof existingParams === 'object') {
1368
+ Object.keys(existingParams).forEach(key => {
1369
+ localVarFormParams.append(key, existingParams[key]);
1370
+ });
1371
+ }
1372
+ }
1373
+ const configFiles = Array.isArray(params.config) ? params.config : [params.config];
1374
+ const Blob = globalThis.Blob || require('buffer').Blob;
1375
+ configFiles.forEach((f) => {
1376
+ localVarFormParams.append('config', new Blob([f.value], {
1377
+ type: f.options.contentType
1378
+ }), f.options.filename);
1379
+ });
1329
1380
  }
1330
- localVarUseFormData = true;
1381
+ const queryString = Object.entries(localVarQueryParameters)
1382
+ .filter(([, value]) => value !== undefined)
1383
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1384
+ .join('&');
1385
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1331
1386
  let localVarRequestOptions = {
1332
1387
  method: 'POST',
1333
- qs: localVarQueryParameters,
1334
- headers: localVarHeaderParams,
1335
- uri: localVarPath,
1336
- useQuerystring: this._useQuerystring,
1337
- agentOptions: { keepAlive: false },
1338
- json: true,
1388
+ headers: { ...localVarHeaderParams },
1339
1389
  };
1340
- let authenticationPromise = Promise.resolve();
1341
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1342
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1343
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1344
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1345
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1346
- return authenticationPromise.then(() => {
1347
- if (Object.keys(localVarFormParams).length) {
1348
- if (localVarUseFormData) {
1349
- localVarRequestOptions.formData = localVarFormParams;
1350
- }
1351
- else {
1352
- localVarRequestOptions.form = localVarFormParams;
1353
- }
1390
+ let requestOptions = localVarRequestOptions;
1391
+ let url = localVarUrl;
1392
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1393
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1394
+ url = auth_ApiKeyAuthentication.url;
1395
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1396
+ requestOptions = auth_JWTAuthentication.requestOptions;
1397
+ url = auth_JWTAuthentication.url;
1398
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1399
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1400
+ url = auth_JWTHttpHeaderAuthentication.url;
1401
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1402
+ requestOptions = auth_OAuth2.requestOptions;
1403
+ url = auth_OAuth2.url;
1404
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1405
+ requestOptions = authDefault.requestOptions;
1406
+ url = authDefault.url;
1407
+ if (localVarFormParams) {
1408
+ delete requestOptions.headers['Content-Type'];
1409
+ if (localVarFormParams instanceof FormData) {
1410
+ // FormData: fetch will handle Content-Type automatically.
1411
+ requestOptions.body = localVarFormParams;
1354
1412
  }
1355
- return new Promise((resolve, reject) => {
1356
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1357
- if (error) {
1358
- reject(error);
1359
- }
1360
- else {
1361
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
1362
- if (typeof body.success === 'boolean' && !body.success) {
1363
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1364
- reject(new Error(body.error || errString));
1365
- }
1366
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1367
- resolve(body);
1368
- }
1369
- else {
1370
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1371
- reject(errString);
1372
- }
1373
- }
1374
- });
1375
- });
1376
- });
1413
+ else if (Object.keys(localVarFormParams).length > 0) {
1414
+ // URL-encoded form
1415
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1416
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1417
+ }
1418
+ }
1419
+ const response = await fetch(url, requestOptions);
1420
+ return this.handleResponse(response, 'GenericApiResponse');
1377
1421
  }
1378
1422
  /**
1379
1423
  * Update the impulse for this project. If you specify `impulseId` then that impulse is created/updated, otherwise the default impulse is created/updated.
@@ -1386,9 +1430,11 @@ class ImpulseApi {
1386
1430
  const localVarPath = this.basePath + '/api/{projectId}/impulse/update'
1387
1431
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
1388
1432
  let localVarQueryParameters = {};
1389
- let localVarHeaderParams = Object.assign({
1390
- 'User-Agent': 'edgeimpulse-api nodejs'
1391
- }, this.defaultHeaders);
1433
+ let localVarHeaderParams = {
1434
+ 'User-Agent': 'edgeimpulse-api nodejs',
1435
+ 'Content-Type': 'application/json',
1436
+ ...this.defaultHeaders,
1437
+ };
1392
1438
  const produces = ['application/json'];
1393
1439
  // give precedence to 'application/json'
1394
1440
  if (produces.indexOf('application/json') >= 0) {
@@ -1397,7 +1443,7 @@ class ImpulseApi {
1397
1443
  else {
1398
1444
  localVarHeaderParams.Accept = produces.join(',');
1399
1445
  }
1400
- let localVarFormParams = {};
1446
+ let localVarFormParams;
1401
1447
  // verify required parameter 'projectId' is not null or undefined
1402
1448
  if (projectId === null || projectId === undefined) {
1403
1449
  throw new Error('Required parameter projectId was null or undefined when calling updateImpulse.');
@@ -1409,56 +1455,52 @@ class ImpulseApi {
1409
1455
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
1410
1456
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
1411
1457
  }
1412
- Object.assign(localVarHeaderParams, options.headers);
1413
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1414
- let localVarUseFormData = false;
1458
+ localVarHeaderParams = {
1459
+ ...localVarHeaderParams,
1460
+ ...options.headers,
1461
+ ...this.opts.extraHeaders,
1462
+ };
1463
+ const queryString = Object.entries(localVarQueryParameters)
1464
+ .filter(([, value]) => value !== undefined)
1465
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1466
+ .join('&');
1467
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1415
1468
  let localVarRequestOptions = {
1416
1469
  method: 'POST',
1417
- qs: localVarQueryParameters,
1418
- headers: localVarHeaderParams,
1419
- uri: localVarPath,
1420
- useQuerystring: this._useQuerystring,
1421
- agentOptions: { keepAlive: false },
1422
- json: true,
1423
- body: models_1.ObjectSerializer.serialize(updateImpulseRequest, "UpdateImpulseRequest")
1470
+ headers: { ...localVarHeaderParams },
1424
1471
  };
1425
- let authenticationPromise = Promise.resolve();
1426
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1427
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1428
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1429
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1430
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1431
- return authenticationPromise.then(() => {
1432
- if (Object.keys(localVarFormParams).length) {
1433
- if (localVarUseFormData) {
1434
- localVarRequestOptions.formData = localVarFormParams;
1435
- }
1436
- else {
1437
- localVarRequestOptions.form = localVarFormParams;
1438
- }
1472
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(updateImpulseRequest, "UpdateImpulseRequest"));
1473
+ let requestOptions = localVarRequestOptions;
1474
+ let url = localVarUrl;
1475
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1476
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1477
+ url = auth_ApiKeyAuthentication.url;
1478
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1479
+ requestOptions = auth_JWTAuthentication.requestOptions;
1480
+ url = auth_JWTAuthentication.url;
1481
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1482
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1483
+ url = auth_JWTHttpHeaderAuthentication.url;
1484
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1485
+ requestOptions = auth_OAuth2.requestOptions;
1486
+ url = auth_OAuth2.url;
1487
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1488
+ requestOptions = authDefault.requestOptions;
1489
+ url = authDefault.url;
1490
+ if (localVarFormParams) {
1491
+ delete requestOptions.headers['Content-Type'];
1492
+ if (localVarFormParams instanceof FormData) {
1493
+ // FormData: fetch will handle Content-Type automatically.
1494
+ requestOptions.body = localVarFormParams;
1439
1495
  }
1440
- return new Promise((resolve, reject) => {
1441
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1442
- if (error) {
1443
- reject(error);
1444
- }
1445
- else {
1446
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
1447
- if (typeof body.success === 'boolean' && !body.success) {
1448
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1449
- reject(new Error(body.error || errString));
1450
- }
1451
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1452
- resolve(body);
1453
- }
1454
- else {
1455
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1456
- reject(errString);
1457
- }
1458
- }
1459
- });
1460
- });
1461
- });
1496
+ else if (Object.keys(localVarFormParams).length > 0) {
1497
+ // URL-encoded form
1498
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1499
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1500
+ }
1501
+ }
1502
+ const response = await fetch(url, requestOptions);
1503
+ return this.handleResponse(response, 'GenericApiResponse');
1462
1504
  }
1463
1505
  /**
1464
1506
  * Verify the validity of a custom DSP block
@@ -1470,9 +1512,11 @@ class ImpulseApi {
1470
1512
  const localVarPath = this.basePath + '/api/{projectId}/verify-dsp-block/url'
1471
1513
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
1472
1514
  let localVarQueryParameters = {};
1473
- let localVarHeaderParams = Object.assign({
1474
- 'User-Agent': 'edgeimpulse-api nodejs'
1475
- }, this.defaultHeaders);
1515
+ let localVarHeaderParams = {
1516
+ 'User-Agent': 'edgeimpulse-api nodejs',
1517
+ 'Content-Type': 'application/json',
1518
+ ...this.defaultHeaders,
1519
+ };
1476
1520
  const produces = ['application/json'];
1477
1521
  // give precedence to 'application/json'
1478
1522
  if (produces.indexOf('application/json') >= 0) {
@@ -1481,7 +1525,7 @@ class ImpulseApi {
1481
1525
  else {
1482
1526
  localVarHeaderParams.Accept = produces.join(',');
1483
1527
  }
1484
- let localVarFormParams = {};
1528
+ let localVarFormParams;
1485
1529
  // verify required parameter 'projectId' is not null or undefined
1486
1530
  if (projectId === null || projectId === undefined) {
1487
1531
  throw new Error('Required parameter projectId was null or undefined when calling verifyDspBlockUrl.');
@@ -1490,56 +1534,52 @@ class ImpulseApi {
1490
1534
  if (verifyDspBlockUrlRequest === null || verifyDspBlockUrlRequest === undefined) {
1491
1535
  throw new Error('Required parameter verifyDspBlockUrlRequest was null or undefined when calling verifyDspBlockUrl.');
1492
1536
  }
1493
- Object.assign(localVarHeaderParams, options.headers);
1494
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1495
- let localVarUseFormData = false;
1537
+ localVarHeaderParams = {
1538
+ ...localVarHeaderParams,
1539
+ ...options.headers,
1540
+ ...this.opts.extraHeaders,
1541
+ };
1542
+ const queryString = Object.entries(localVarQueryParameters)
1543
+ .filter(([, value]) => value !== undefined)
1544
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1545
+ .join('&');
1546
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1496
1547
  let localVarRequestOptions = {
1497
1548
  method: 'POST',
1498
- qs: localVarQueryParameters,
1499
- headers: localVarHeaderParams,
1500
- uri: localVarPath,
1501
- useQuerystring: this._useQuerystring,
1502
- agentOptions: { keepAlive: false },
1503
- json: true,
1504
- body: models_1.ObjectSerializer.serialize(verifyDspBlockUrlRequest, "VerifyDspBlockUrlRequest")
1549
+ headers: { ...localVarHeaderParams },
1505
1550
  };
1506
- let authenticationPromise = Promise.resolve();
1507
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1508
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1509
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1510
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1511
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1512
- return authenticationPromise.then(() => {
1513
- if (Object.keys(localVarFormParams).length) {
1514
- if (localVarUseFormData) {
1515
- localVarRequestOptions.formData = localVarFormParams;
1516
- }
1517
- else {
1518
- localVarRequestOptions.form = localVarFormParams;
1519
- }
1551
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(verifyDspBlockUrlRequest, "VerifyDspBlockUrlRequest"));
1552
+ let requestOptions = localVarRequestOptions;
1553
+ let url = localVarUrl;
1554
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1555
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1556
+ url = auth_ApiKeyAuthentication.url;
1557
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1558
+ requestOptions = auth_JWTAuthentication.requestOptions;
1559
+ url = auth_JWTAuthentication.url;
1560
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1561
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1562
+ url = auth_JWTHttpHeaderAuthentication.url;
1563
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1564
+ requestOptions = auth_OAuth2.requestOptions;
1565
+ url = auth_OAuth2.url;
1566
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1567
+ requestOptions = authDefault.requestOptions;
1568
+ url = authDefault.url;
1569
+ if (localVarFormParams) {
1570
+ delete requestOptions.headers['Content-Type'];
1571
+ if (localVarFormParams instanceof FormData) {
1572
+ // FormData: fetch will handle Content-Type automatically.
1573
+ requestOptions.body = localVarFormParams;
1520
1574
  }
1521
- return new Promise((resolve, reject) => {
1522
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1523
- if (error) {
1524
- reject(error);
1525
- }
1526
- else {
1527
- body = models_1.ObjectSerializer.deserialize(body, "VerifyDspBlockUrlResponse");
1528
- if (typeof body.success === 'boolean' && !body.success) {
1529
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1530
- reject(new Error(body.error || errString));
1531
- }
1532
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1533
- resolve(body);
1534
- }
1535
- else {
1536
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1537
- reject(errString);
1538
- }
1539
- }
1540
- });
1541
- });
1542
- });
1575
+ else if (Object.keys(localVarFormParams).length > 0) {
1576
+ // URL-encoded form
1577
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1578
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1579
+ }
1580
+ }
1581
+ const response = await fetch(url, requestOptions);
1582
+ return this.handleResponse(response, 'VerifyDspBlockUrlResponse');
1543
1583
  }
1544
1584
  }
1545
1585
  exports.ImpulseApi = ImpulseApi;