edge-impulse-api 1.82.6 → 1.82.8

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.PerformanceCalibrationApi = exports.PerformanceCalibrationApiApiKeys = 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 PerformanceCalibrationApiApiKeys;
30
47
  PerformanceCalibrationApiApiKeys[PerformanceCalibrationApiApiKeys["JWTHttpHeaderAuthentication"] = 2] = "JWTHttpHeaderAuthentication";
31
48
  })(PerformanceCalibrationApiApiKeys = exports.PerformanceCalibrationApiApiKeys || (exports.PerformanceCalibrationApiApiKeys = {}));
32
49
  class PerformanceCalibrationApi {
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 PerformanceCalibrationApi {
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
  }
@@ -88,9 +122,11 @@ class PerformanceCalibrationApi {
88
122
  const localVarPath = this.basePath + '/api/{projectId}/performance-calibration/clear'
89
123
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
90
124
  let localVarQueryParameters = {};
91
- let localVarHeaderParams = Object.assign({
92
- 'User-Agent': 'edgeimpulse-api nodejs'
93
- }, this.defaultHeaders);
125
+ let localVarHeaderParams = {
126
+ 'User-Agent': 'edgeimpulse-api nodejs',
127
+ 'Content-Type': 'application/json',
128
+ ...this.defaultHeaders,
129
+ };
94
130
  const produces = ['application/json'];
95
131
  // give precedence to 'application/json'
96
132
  if (produces.indexOf('application/json') >= 0) {
@@ -99,7 +135,7 @@ class PerformanceCalibrationApi {
99
135
  else {
100
136
  localVarHeaderParams.Accept = produces.join(',');
101
137
  }
102
- let localVarFormParams = {};
138
+ let localVarFormParams;
103
139
  // verify required parameter 'projectId' is not null or undefined
104
140
  if (projectId === null || projectId === undefined) {
105
141
  throw new Error('Required parameter projectId was null or undefined when calling clearPerformanceCalibrationState.');
@@ -107,55 +143,51 @@ class PerformanceCalibrationApi {
107
143
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
108
144
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
109
145
  }
110
- Object.assign(localVarHeaderParams, options.headers);
111
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
112
- let localVarUseFormData = false;
146
+ localVarHeaderParams = {
147
+ ...localVarHeaderParams,
148
+ ...options.headers,
149
+ ...this.opts.extraHeaders,
150
+ };
151
+ const queryString = Object.entries(localVarQueryParameters)
152
+ .filter(([, value]) => value !== undefined)
153
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
154
+ .join('&');
155
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
113
156
  let localVarRequestOptions = {
114
157
  method: 'POST',
115
- qs: localVarQueryParameters,
116
- headers: localVarHeaderParams,
117
- uri: localVarPath,
118
- useQuerystring: this._useQuerystring,
119
- agentOptions: { keepAlive: false },
120
- json: true,
121
- };
122
- let authenticationPromise = Promise.resolve();
123
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
124
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
125
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
126
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
127
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
128
- return authenticationPromise.then(() => {
129
- if (Object.keys(localVarFormParams).length) {
130
- if (localVarUseFormData) {
131
- localVarRequestOptions.formData = localVarFormParams;
132
- }
133
- else {
134
- localVarRequestOptions.form = localVarFormParams;
135
- }
158
+ headers: { ...localVarHeaderParams },
159
+ };
160
+ let requestOptions = localVarRequestOptions;
161
+ let url = localVarUrl;
162
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
163
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
164
+ url = auth_ApiKeyAuthentication.url;
165
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
166
+ requestOptions = auth_JWTAuthentication.requestOptions;
167
+ url = auth_JWTAuthentication.url;
168
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
169
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
170
+ url = auth_JWTHttpHeaderAuthentication.url;
171
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
172
+ requestOptions = auth_OAuth2.requestOptions;
173
+ url = auth_OAuth2.url;
174
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
175
+ requestOptions = authDefault.requestOptions;
176
+ url = authDefault.url;
177
+ if (localVarFormParams) {
178
+ delete requestOptions.headers['Content-Type'];
179
+ if (localVarFormParams instanceof FormData) {
180
+ // FormData: fetch will handle Content-Type automatically.
181
+ requestOptions.body = localVarFormParams;
136
182
  }
137
- return new Promise((resolve, reject) => {
138
- localVarRequest(localVarRequestOptions, (error, response, body) => {
139
- if (error) {
140
- reject(error);
141
- }
142
- else {
143
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
144
- if (typeof body.success === 'boolean' && !body.success) {
145
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
146
- reject(new Error(body.error || errString));
147
- }
148
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
149
- resolve(body);
150
- }
151
- else {
152
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
153
- reject(errString);
154
- }
155
- }
156
- });
157
- });
158
- });
183
+ else if (Object.keys(localVarFormParams).length > 0) {
184
+ // URL-encoded form
185
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
186
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
187
+ }
188
+ }
189
+ const response = await fetch(url, requestOptions);
190
+ return this.handleResponse(response, 'GenericApiResponse');
159
191
  }
160
192
  /**
161
193
  * Clears the current performance calibration parameters
@@ -167,9 +199,11 @@ class PerformanceCalibrationApi {
167
199
  const localVarPath = this.basePath + '/api/{projectId}/performance-calibration/parameters'
168
200
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
169
201
  let localVarQueryParameters = {};
170
- let localVarHeaderParams = Object.assign({
171
- 'User-Agent': 'edgeimpulse-api nodejs'
172
- }, this.defaultHeaders);
202
+ let localVarHeaderParams = {
203
+ 'User-Agent': 'edgeimpulse-api nodejs',
204
+ 'Content-Type': 'application/json',
205
+ ...this.defaultHeaders,
206
+ };
173
207
  const produces = ['application/json'];
174
208
  // give precedence to 'application/json'
175
209
  if (produces.indexOf('application/json') >= 0) {
@@ -178,7 +212,7 @@ class PerformanceCalibrationApi {
178
212
  else {
179
213
  localVarHeaderParams.Accept = produces.join(',');
180
214
  }
181
- let localVarFormParams = {};
215
+ let localVarFormParams;
182
216
  // verify required parameter 'projectId' is not null or undefined
183
217
  if (projectId === null || projectId === undefined) {
184
218
  throw new Error('Required parameter projectId was null or undefined when calling deletePerformanceCalibrationSavedParameters.');
@@ -186,55 +220,51 @@ class PerformanceCalibrationApi {
186
220
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
187
221
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
188
222
  }
189
- Object.assign(localVarHeaderParams, options.headers);
190
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
191
- let localVarUseFormData = false;
223
+ localVarHeaderParams = {
224
+ ...localVarHeaderParams,
225
+ ...options.headers,
226
+ ...this.opts.extraHeaders,
227
+ };
228
+ const queryString = Object.entries(localVarQueryParameters)
229
+ .filter(([, value]) => value !== undefined)
230
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
231
+ .join('&');
232
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
192
233
  let localVarRequestOptions = {
193
234
  method: 'DELETE',
194
- qs: localVarQueryParameters,
195
- headers: localVarHeaderParams,
196
- uri: localVarPath,
197
- useQuerystring: this._useQuerystring,
198
- agentOptions: { keepAlive: false },
199
- json: true,
200
- };
201
- let authenticationPromise = Promise.resolve();
202
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
203
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
204
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
205
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
206
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
207
- return authenticationPromise.then(() => {
208
- if (Object.keys(localVarFormParams).length) {
209
- if (localVarUseFormData) {
210
- localVarRequestOptions.formData = localVarFormParams;
211
- }
212
- else {
213
- localVarRequestOptions.form = localVarFormParams;
214
- }
235
+ headers: { ...localVarHeaderParams },
236
+ };
237
+ let requestOptions = localVarRequestOptions;
238
+ let url = localVarUrl;
239
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
240
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
241
+ url = auth_ApiKeyAuthentication.url;
242
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
243
+ requestOptions = auth_JWTAuthentication.requestOptions;
244
+ url = auth_JWTAuthentication.url;
245
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
246
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
247
+ url = auth_JWTHttpHeaderAuthentication.url;
248
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
249
+ requestOptions = auth_OAuth2.requestOptions;
250
+ url = auth_OAuth2.url;
251
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
252
+ requestOptions = authDefault.requestOptions;
253
+ url = authDefault.url;
254
+ if (localVarFormParams) {
255
+ delete requestOptions.headers['Content-Type'];
256
+ if (localVarFormParams instanceof FormData) {
257
+ // FormData: fetch will handle Content-Type automatically.
258
+ requestOptions.body = localVarFormParams;
215
259
  }
216
- return new Promise((resolve, reject) => {
217
- localVarRequest(localVarRequestOptions, (error, response, body) => {
218
- if (error) {
219
- reject(error);
220
- }
221
- else {
222
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
223
- if (typeof body.success === 'boolean' && !body.success) {
224
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
225
- reject(new Error(body.error || errString));
226
- }
227
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
228
- resolve(body);
229
- }
230
- else {
231
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
232
- reject(errString);
233
- }
234
- }
235
- });
236
- });
237
- });
260
+ else if (Object.keys(localVarFormParams).length > 0) {
261
+ // URL-encoded form
262
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
263
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
264
+ }
265
+ }
266
+ const response = await fetch(url, requestOptions);
267
+ return this.handleResponse(response, 'GenericApiResponse');
238
268
  }
239
269
  /**
240
270
  * Get performance calibration ground truth data
@@ -246,9 +276,11 @@ class PerformanceCalibrationApi {
246
276
  const localVarPath = this.basePath + '/api/{projectId}/performance-calibration/ground-truth'
247
277
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
248
278
  let localVarQueryParameters = {};
249
- let localVarHeaderParams = Object.assign({
250
- 'User-Agent': 'edgeimpulse-api nodejs'
251
- }, this.defaultHeaders);
279
+ let localVarHeaderParams = {
280
+ 'User-Agent': 'edgeimpulse-api nodejs',
281
+ 'Content-Type': 'application/json',
282
+ ...this.defaultHeaders,
283
+ };
252
284
  const produces = ['application/json'];
253
285
  // give precedence to 'application/json'
254
286
  if (produces.indexOf('application/json') >= 0) {
@@ -257,7 +289,7 @@ class PerformanceCalibrationApi {
257
289
  else {
258
290
  localVarHeaderParams.Accept = produces.join(',');
259
291
  }
260
- let localVarFormParams = {};
292
+ let localVarFormParams;
261
293
  // verify required parameter 'projectId' is not null or undefined
262
294
  if (projectId === null || projectId === undefined) {
263
295
  throw new Error('Required parameter projectId was null or undefined when calling getPerformanceCalibrationGroundTruth.');
@@ -265,55 +297,51 @@ class PerformanceCalibrationApi {
265
297
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
266
298
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
267
299
  }
268
- Object.assign(localVarHeaderParams, options.headers);
269
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
270
- let localVarUseFormData = false;
300
+ localVarHeaderParams = {
301
+ ...localVarHeaderParams,
302
+ ...options.headers,
303
+ ...this.opts.extraHeaders,
304
+ };
305
+ const queryString = Object.entries(localVarQueryParameters)
306
+ .filter(([, value]) => value !== undefined)
307
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
308
+ .join('&');
309
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
271
310
  let localVarRequestOptions = {
272
311
  method: 'GET',
273
- qs: localVarQueryParameters,
274
- headers: localVarHeaderParams,
275
- uri: localVarPath,
276
- useQuerystring: this._useQuerystring,
277
- agentOptions: { keepAlive: false },
278
- json: true,
279
- };
280
- let authenticationPromise = Promise.resolve();
281
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
282
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
283
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
284
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
285
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
286
- return authenticationPromise.then(() => {
287
- if (Object.keys(localVarFormParams).length) {
288
- if (localVarUseFormData) {
289
- localVarRequestOptions.formData = localVarFormParams;
290
- }
291
- else {
292
- localVarRequestOptions.form = localVarFormParams;
293
- }
312
+ headers: { ...localVarHeaderParams },
313
+ };
314
+ let requestOptions = localVarRequestOptions;
315
+ let url = localVarUrl;
316
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
317
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
318
+ url = auth_ApiKeyAuthentication.url;
319
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
320
+ requestOptions = auth_JWTAuthentication.requestOptions;
321
+ url = auth_JWTAuthentication.url;
322
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
323
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
324
+ url = auth_JWTHttpHeaderAuthentication.url;
325
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
326
+ requestOptions = auth_OAuth2.requestOptions;
327
+ url = auth_OAuth2.url;
328
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
329
+ requestOptions = authDefault.requestOptions;
330
+ url = authDefault.url;
331
+ if (localVarFormParams) {
332
+ delete requestOptions.headers['Content-Type'];
333
+ if (localVarFormParams instanceof FormData) {
334
+ // FormData: fetch will handle Content-Type automatically.
335
+ requestOptions.body = localVarFormParams;
294
336
  }
295
- return new Promise((resolve, reject) => {
296
- localVarRequest(localVarRequestOptions, (error, response, body) => {
297
- if (error) {
298
- reject(error);
299
- }
300
- else {
301
- body = models_1.ObjectSerializer.deserialize(body, "GetPerformanceCalibrationGroundTruthResponse");
302
- if (typeof body.success === 'boolean' && !body.success) {
303
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
304
- reject(new Error(body.error || errString));
305
- }
306
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
307
- resolve(body);
308
- }
309
- else {
310
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
311
- reject(errString);
312
- }
313
- }
314
- });
315
- });
316
- });
337
+ else if (Object.keys(localVarFormParams).length > 0) {
338
+ // URL-encoded form
339
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
340
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
341
+ }
342
+ }
343
+ const response = await fetch(url, requestOptions);
344
+ return this.handleResponse(response, 'GetPerformanceCalibrationGroundTruthResponse');
317
345
  }
318
346
  /**
319
347
  * Get performance calibration parameter sets
@@ -325,9 +353,11 @@ class PerformanceCalibrationApi {
325
353
  const localVarPath = this.basePath + '/api/{projectId}/performance-calibration/parameter-sets'
326
354
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
327
355
  let localVarQueryParameters = {};
328
- let localVarHeaderParams = Object.assign({
329
- 'User-Agent': 'edgeimpulse-api nodejs'
330
- }, this.defaultHeaders);
356
+ let localVarHeaderParams = {
357
+ 'User-Agent': 'edgeimpulse-api nodejs',
358
+ 'Content-Type': 'application/json',
359
+ ...this.defaultHeaders,
360
+ };
331
361
  const produces = ['application/json'];
332
362
  // give precedence to 'application/json'
333
363
  if (produces.indexOf('application/json') >= 0) {
@@ -336,7 +366,7 @@ class PerformanceCalibrationApi {
336
366
  else {
337
367
  localVarHeaderParams.Accept = produces.join(',');
338
368
  }
339
- let localVarFormParams = {};
369
+ let localVarFormParams;
340
370
  // verify required parameter 'projectId' is not null or undefined
341
371
  if (projectId === null || projectId === undefined) {
342
372
  throw new Error('Required parameter projectId was null or undefined when calling getPerformanceCalibrationParameterSets.');
@@ -344,55 +374,51 @@ class PerformanceCalibrationApi {
344
374
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
345
375
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
346
376
  }
347
- Object.assign(localVarHeaderParams, options.headers);
348
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
349
- let localVarUseFormData = false;
377
+ localVarHeaderParams = {
378
+ ...localVarHeaderParams,
379
+ ...options.headers,
380
+ ...this.opts.extraHeaders,
381
+ };
382
+ const queryString = Object.entries(localVarQueryParameters)
383
+ .filter(([, value]) => value !== undefined)
384
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
385
+ .join('&');
386
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
350
387
  let localVarRequestOptions = {
351
388
  method: 'GET',
352
- qs: localVarQueryParameters,
353
- headers: localVarHeaderParams,
354
- uri: localVarPath,
355
- useQuerystring: this._useQuerystring,
356
- agentOptions: { keepAlive: false },
357
- json: true,
358
- };
359
- let authenticationPromise = Promise.resolve();
360
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
361
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
362
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
363
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
364
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
365
- return authenticationPromise.then(() => {
366
- if (Object.keys(localVarFormParams).length) {
367
- if (localVarUseFormData) {
368
- localVarRequestOptions.formData = localVarFormParams;
369
- }
370
- else {
371
- localVarRequestOptions.form = localVarFormParams;
372
- }
389
+ headers: { ...localVarHeaderParams },
390
+ };
391
+ let requestOptions = localVarRequestOptions;
392
+ let url = localVarUrl;
393
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
394
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
395
+ url = auth_ApiKeyAuthentication.url;
396
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
397
+ requestOptions = auth_JWTAuthentication.requestOptions;
398
+ url = auth_JWTAuthentication.url;
399
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
400
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
401
+ url = auth_JWTHttpHeaderAuthentication.url;
402
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
403
+ requestOptions = auth_OAuth2.requestOptions;
404
+ url = auth_OAuth2.url;
405
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
406
+ requestOptions = authDefault.requestOptions;
407
+ url = authDefault.url;
408
+ if (localVarFormParams) {
409
+ delete requestOptions.headers['Content-Type'];
410
+ if (localVarFormParams instanceof FormData) {
411
+ // FormData: fetch will handle Content-Type automatically.
412
+ requestOptions.body = localVarFormParams;
373
413
  }
374
- return new Promise((resolve, reject) => {
375
- localVarRequest(localVarRequestOptions, (error, response, body) => {
376
- if (error) {
377
- reject(error);
378
- }
379
- else {
380
- body = models_1.ObjectSerializer.deserialize(body, "GetPerformanceCalibrationParameterSetsResponse");
381
- if (typeof body.success === 'boolean' && !body.success) {
382
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
383
- reject(new Error(body.error || errString));
384
- }
385
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
386
- resolve(body);
387
- }
388
- else {
389
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
390
- reject(errString);
391
- }
392
- }
393
- });
394
- });
395
- });
414
+ else if (Object.keys(localVarFormParams).length > 0) {
415
+ // URL-encoded form
416
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
417
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
418
+ }
419
+ }
420
+ const response = await fetch(url, requestOptions);
421
+ return this.handleResponse(response, 'GetPerformanceCalibrationParameterSetsResponse');
396
422
  }
397
423
  /**
398
424
  * Get performance calibration raw result
@@ -404,9 +430,11 @@ class PerformanceCalibrationApi {
404
430
  const localVarPath = this.basePath + '/api/{projectId}/performance-calibration/raw-result'
405
431
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
406
432
  let localVarQueryParameters = {};
407
- let localVarHeaderParams = Object.assign({
408
- 'User-Agent': 'edgeimpulse-api nodejs'
409
- }, this.defaultHeaders);
433
+ let localVarHeaderParams = {
434
+ 'User-Agent': 'edgeimpulse-api nodejs',
435
+ 'Content-Type': 'application/json',
436
+ ...this.defaultHeaders,
437
+ };
410
438
  const produces = ['application/json'];
411
439
  // give precedence to 'application/json'
412
440
  if (produces.indexOf('application/json') >= 0) {
@@ -415,7 +443,7 @@ class PerformanceCalibrationApi {
415
443
  else {
416
444
  localVarHeaderParams.Accept = produces.join(',');
417
445
  }
418
- let localVarFormParams = {};
446
+ let localVarFormParams;
419
447
  // verify required parameter 'projectId' is not null or undefined
420
448
  if (projectId === null || projectId === undefined) {
421
449
  throw new Error('Required parameter projectId was null or undefined when calling getPerformanceCalibrationRawResult.');
@@ -423,55 +451,51 @@ class PerformanceCalibrationApi {
423
451
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
424
452
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
425
453
  }
426
- Object.assign(localVarHeaderParams, options.headers);
427
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
428
- let localVarUseFormData = false;
454
+ localVarHeaderParams = {
455
+ ...localVarHeaderParams,
456
+ ...options.headers,
457
+ ...this.opts.extraHeaders,
458
+ };
459
+ const queryString = Object.entries(localVarQueryParameters)
460
+ .filter(([, value]) => value !== undefined)
461
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
462
+ .join('&');
463
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
429
464
  let localVarRequestOptions = {
430
465
  method: 'GET',
431
- qs: localVarQueryParameters,
432
- headers: localVarHeaderParams,
433
- uri: localVarPath,
434
- useQuerystring: this._useQuerystring,
435
- agentOptions: { keepAlive: false },
436
- json: true,
437
- };
438
- let authenticationPromise = Promise.resolve();
439
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
440
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
441
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
442
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
443
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
444
- return authenticationPromise.then(() => {
445
- if (Object.keys(localVarFormParams).length) {
446
- if (localVarUseFormData) {
447
- localVarRequestOptions.formData = localVarFormParams;
448
- }
449
- else {
450
- localVarRequestOptions.form = localVarFormParams;
451
- }
466
+ headers: { ...localVarHeaderParams },
467
+ };
468
+ let requestOptions = localVarRequestOptions;
469
+ let url = localVarUrl;
470
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
471
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
472
+ url = auth_ApiKeyAuthentication.url;
473
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
474
+ requestOptions = auth_JWTAuthentication.requestOptions;
475
+ url = auth_JWTAuthentication.url;
476
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
477
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
478
+ url = auth_JWTHttpHeaderAuthentication.url;
479
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
480
+ requestOptions = auth_OAuth2.requestOptions;
481
+ url = auth_OAuth2.url;
482
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
483
+ requestOptions = authDefault.requestOptions;
484
+ url = authDefault.url;
485
+ if (localVarFormParams) {
486
+ delete requestOptions.headers['Content-Type'];
487
+ if (localVarFormParams instanceof FormData) {
488
+ // FormData: fetch will handle Content-Type automatically.
489
+ requestOptions.body = localVarFormParams;
452
490
  }
453
- return new Promise((resolve, reject) => {
454
- localVarRequest(localVarRequestOptions, (error, response, body) => {
455
- if (error) {
456
- reject(error);
457
- }
458
- else {
459
- body = models_1.ObjectSerializer.deserialize(body, "GetPerformanceCalibrationRawResultResponse");
460
- if (typeof body.success === 'boolean' && !body.success) {
461
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
462
- reject(new Error(body.error || errString));
463
- }
464
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
465
- resolve(body);
466
- }
467
- else {
468
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
469
- reject(errString);
470
- }
471
- }
472
- });
473
- });
474
- });
491
+ else if (Object.keys(localVarFormParams).length > 0) {
492
+ // URL-encoded form
493
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
494
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
495
+ }
496
+ }
497
+ const response = await fetch(url, requestOptions);
498
+ return this.handleResponse(response, 'GetPerformanceCalibrationRawResultResponse');
475
499
  }
476
500
  /**
477
501
  * Get performance calibration stored parameters
@@ -483,9 +507,11 @@ class PerformanceCalibrationApi {
483
507
  const localVarPath = this.basePath + '/api/{projectId}/performance-calibration/parameters'
484
508
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
485
509
  let localVarQueryParameters = {};
486
- let localVarHeaderParams = Object.assign({
487
- 'User-Agent': 'edgeimpulse-api nodejs'
488
- }, this.defaultHeaders);
510
+ let localVarHeaderParams = {
511
+ 'User-Agent': 'edgeimpulse-api nodejs',
512
+ 'Content-Type': 'application/json',
513
+ ...this.defaultHeaders,
514
+ };
489
515
  const produces = ['application/json'];
490
516
  // give precedence to 'application/json'
491
517
  if (produces.indexOf('application/json') >= 0) {
@@ -494,7 +520,7 @@ class PerformanceCalibrationApi {
494
520
  else {
495
521
  localVarHeaderParams.Accept = produces.join(',');
496
522
  }
497
- let localVarFormParams = {};
523
+ let localVarFormParams;
498
524
  // verify required parameter 'projectId' is not null or undefined
499
525
  if (projectId === null || projectId === undefined) {
500
526
  throw new Error('Required parameter projectId was null or undefined when calling getPerformanceCalibrationSavedParameters.');
@@ -502,55 +528,51 @@ class PerformanceCalibrationApi {
502
528
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
503
529
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
504
530
  }
505
- Object.assign(localVarHeaderParams, options.headers);
506
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
507
- let localVarUseFormData = false;
531
+ localVarHeaderParams = {
532
+ ...localVarHeaderParams,
533
+ ...options.headers,
534
+ ...this.opts.extraHeaders,
535
+ };
536
+ const queryString = Object.entries(localVarQueryParameters)
537
+ .filter(([, value]) => value !== undefined)
538
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
539
+ .join('&');
540
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
508
541
  let localVarRequestOptions = {
509
542
  method: 'GET',
510
- qs: localVarQueryParameters,
511
- headers: localVarHeaderParams,
512
- uri: localVarPath,
513
- useQuerystring: this._useQuerystring,
514
- agentOptions: { keepAlive: false },
515
- json: true,
516
- };
517
- let authenticationPromise = Promise.resolve();
518
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
519
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
520
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
521
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
522
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
523
- return authenticationPromise.then(() => {
524
- if (Object.keys(localVarFormParams).length) {
525
- if (localVarUseFormData) {
526
- localVarRequestOptions.formData = localVarFormParams;
527
- }
528
- else {
529
- localVarRequestOptions.form = localVarFormParams;
530
- }
543
+ headers: { ...localVarHeaderParams },
544
+ };
545
+ let requestOptions = localVarRequestOptions;
546
+ let url = localVarUrl;
547
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
548
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
549
+ url = auth_ApiKeyAuthentication.url;
550
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
551
+ requestOptions = auth_JWTAuthentication.requestOptions;
552
+ url = auth_JWTAuthentication.url;
553
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
554
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
555
+ url = auth_JWTHttpHeaderAuthentication.url;
556
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
557
+ requestOptions = auth_OAuth2.requestOptions;
558
+ url = auth_OAuth2.url;
559
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
560
+ requestOptions = authDefault.requestOptions;
561
+ url = authDefault.url;
562
+ if (localVarFormParams) {
563
+ delete requestOptions.headers['Content-Type'];
564
+ if (localVarFormParams instanceof FormData) {
565
+ // FormData: fetch will handle Content-Type automatically.
566
+ requestOptions.body = localVarFormParams;
531
567
  }
532
- return new Promise((resolve, reject) => {
533
- localVarRequest(localVarRequestOptions, (error, response, body) => {
534
- if (error) {
535
- reject(error);
536
- }
537
- else {
538
- body = models_1.ObjectSerializer.deserialize(body, "GetPerformanceCalibrationParametersResponse");
539
- if (typeof body.success === 'boolean' && !body.success) {
540
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
541
- reject(new Error(body.error || errString));
542
- }
543
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
544
- resolve(body);
545
- }
546
- else {
547
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
548
- reject(errString);
549
- }
550
- }
551
- });
552
- });
553
- });
568
+ else if (Object.keys(localVarFormParams).length > 0) {
569
+ // URL-encoded form
570
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
571
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
572
+ }
573
+ }
574
+ const response = await fetch(url, requestOptions);
575
+ return this.handleResponse(response, 'GetPerformanceCalibrationParametersResponse');
554
576
  }
555
577
  /**
556
578
  * Get performance calibration status
@@ -562,9 +584,11 @@ class PerformanceCalibrationApi {
562
584
  const localVarPath = this.basePath + '/api/{projectId}/performance-calibration/status'
563
585
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
564
586
  let localVarQueryParameters = {};
565
- let localVarHeaderParams = Object.assign({
566
- 'User-Agent': 'edgeimpulse-api nodejs'
567
- }, this.defaultHeaders);
587
+ let localVarHeaderParams = {
588
+ 'User-Agent': 'edgeimpulse-api nodejs',
589
+ 'Content-Type': 'application/json',
590
+ ...this.defaultHeaders,
591
+ };
568
592
  const produces = ['application/json'];
569
593
  // give precedence to 'application/json'
570
594
  if (produces.indexOf('application/json') >= 0) {
@@ -573,7 +597,7 @@ class PerformanceCalibrationApi {
573
597
  else {
574
598
  localVarHeaderParams.Accept = produces.join(',');
575
599
  }
576
- let localVarFormParams = {};
600
+ let localVarFormParams;
577
601
  // verify required parameter 'projectId' is not null or undefined
578
602
  if (projectId === null || projectId === undefined) {
579
603
  throw new Error('Required parameter projectId was null or undefined when calling getPerformanceCalibrationStatus.');
@@ -581,55 +605,51 @@ class PerformanceCalibrationApi {
581
605
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
582
606
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
583
607
  }
584
- Object.assign(localVarHeaderParams, options.headers);
585
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
586
- let localVarUseFormData = false;
608
+ localVarHeaderParams = {
609
+ ...localVarHeaderParams,
610
+ ...options.headers,
611
+ ...this.opts.extraHeaders,
612
+ };
613
+ const queryString = Object.entries(localVarQueryParameters)
614
+ .filter(([, value]) => value !== undefined)
615
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
616
+ .join('&');
617
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
587
618
  let localVarRequestOptions = {
588
619
  method: 'GET',
589
- qs: localVarQueryParameters,
590
- headers: localVarHeaderParams,
591
- uri: localVarPath,
592
- useQuerystring: this._useQuerystring,
593
- agentOptions: { keepAlive: false },
594
- json: true,
595
- };
596
- let authenticationPromise = Promise.resolve();
597
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
598
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
599
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
600
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
601
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
602
- return authenticationPromise.then(() => {
603
- if (Object.keys(localVarFormParams).length) {
604
- if (localVarUseFormData) {
605
- localVarRequestOptions.formData = localVarFormParams;
606
- }
607
- else {
608
- localVarRequestOptions.form = localVarFormParams;
609
- }
620
+ headers: { ...localVarHeaderParams },
621
+ };
622
+ let requestOptions = localVarRequestOptions;
623
+ let url = localVarUrl;
624
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
625
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
626
+ url = auth_ApiKeyAuthentication.url;
627
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
628
+ requestOptions = auth_JWTAuthentication.requestOptions;
629
+ url = auth_JWTAuthentication.url;
630
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
631
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
632
+ url = auth_JWTHttpHeaderAuthentication.url;
633
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
634
+ requestOptions = auth_OAuth2.requestOptions;
635
+ url = auth_OAuth2.url;
636
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
637
+ requestOptions = authDefault.requestOptions;
638
+ url = authDefault.url;
639
+ if (localVarFormParams) {
640
+ delete requestOptions.headers['Content-Type'];
641
+ if (localVarFormParams instanceof FormData) {
642
+ // FormData: fetch will handle Content-Type automatically.
643
+ requestOptions.body = localVarFormParams;
610
644
  }
611
- return new Promise((resolve, reject) => {
612
- localVarRequest(localVarRequestOptions, (error, response, body) => {
613
- if (error) {
614
- reject(error);
615
- }
616
- else {
617
- body = models_1.ObjectSerializer.deserialize(body, "GetPerformanceCalibrationStatusResponse");
618
- if (typeof body.success === 'boolean' && !body.success) {
619
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
620
- reject(new Error(body.error || errString));
621
- }
622
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
623
- resolve(body);
624
- }
625
- else {
626
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
627
- reject(errString);
628
- }
629
- }
630
- });
631
- });
632
- });
645
+ else if (Object.keys(localVarFormParams).length > 0) {
646
+ // URL-encoded form
647
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
648
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
649
+ }
650
+ }
651
+ const response = await fetch(url, requestOptions);
652
+ return this.handleResponse(response, 'GetPerformanceCalibrationStatusResponse');
633
653
  }
634
654
  /**
635
655
  * Internal endpoint, API is subject to change. Get results of most recent post processing run.
@@ -641,9 +661,11 @@ class PerformanceCalibrationApi {
641
661
  const localVarPath = this.basePath + '/api/{projectId}/post-processing/results'
642
662
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
643
663
  let localVarQueryParameters = {};
644
- let localVarHeaderParams = Object.assign({
645
- 'User-Agent': 'edgeimpulse-api nodejs'
646
- }, this.defaultHeaders);
664
+ let localVarHeaderParams = {
665
+ 'User-Agent': 'edgeimpulse-api nodejs',
666
+ 'Content-Type': 'application/json',
667
+ ...this.defaultHeaders,
668
+ };
647
669
  const produces = ['application/json'];
648
670
  // give precedence to 'application/json'
649
671
  if (produces.indexOf('application/json') >= 0) {
@@ -652,7 +674,7 @@ class PerformanceCalibrationApi {
652
674
  else {
653
675
  localVarHeaderParams.Accept = produces.join(',');
654
676
  }
655
- let localVarFormParams = {};
677
+ let localVarFormParams;
656
678
  // verify required parameter 'projectId' is not null or undefined
657
679
  if (projectId === null || projectId === undefined) {
658
680
  throw new Error('Required parameter projectId was null or undefined when calling getPostProcessingResults.');
@@ -660,55 +682,51 @@ class PerformanceCalibrationApi {
660
682
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
661
683
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
662
684
  }
663
- Object.assign(localVarHeaderParams, options.headers);
664
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
665
- let localVarUseFormData = false;
685
+ localVarHeaderParams = {
686
+ ...localVarHeaderParams,
687
+ ...options.headers,
688
+ ...this.opts.extraHeaders,
689
+ };
690
+ const queryString = Object.entries(localVarQueryParameters)
691
+ .filter(([, value]) => value !== undefined)
692
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
693
+ .join('&');
694
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
666
695
  let localVarRequestOptions = {
667
696
  method: 'GET',
668
- qs: localVarQueryParameters,
669
- headers: localVarHeaderParams,
670
- uri: localVarPath,
671
- useQuerystring: this._useQuerystring,
672
- agentOptions: { keepAlive: false },
673
- json: true,
674
- };
675
- let authenticationPromise = Promise.resolve();
676
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
677
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
678
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
679
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
680
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
681
- return authenticationPromise.then(() => {
682
- if (Object.keys(localVarFormParams).length) {
683
- if (localVarUseFormData) {
684
- localVarRequestOptions.formData = localVarFormParams;
685
- }
686
- else {
687
- localVarRequestOptions.form = localVarFormParams;
688
- }
697
+ headers: { ...localVarHeaderParams },
698
+ };
699
+ let requestOptions = localVarRequestOptions;
700
+ let url = localVarUrl;
701
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
702
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
703
+ url = auth_ApiKeyAuthentication.url;
704
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
705
+ requestOptions = auth_JWTAuthentication.requestOptions;
706
+ url = auth_JWTAuthentication.url;
707
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
708
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
709
+ url = auth_JWTHttpHeaderAuthentication.url;
710
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
711
+ requestOptions = auth_OAuth2.requestOptions;
712
+ url = auth_OAuth2.url;
713
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
714
+ requestOptions = authDefault.requestOptions;
715
+ url = authDefault.url;
716
+ if (localVarFormParams) {
717
+ delete requestOptions.headers['Content-Type'];
718
+ if (localVarFormParams instanceof FormData) {
719
+ // FormData: fetch will handle Content-Type automatically.
720
+ requestOptions.body = localVarFormParams;
689
721
  }
690
- return new Promise((resolve, reject) => {
691
- localVarRequest(localVarRequestOptions, (error, response, body) => {
692
- if (error) {
693
- reject(error);
694
- }
695
- else {
696
- body = models_1.ObjectSerializer.deserialize(body, "GetPostProcessingResultsResponse");
697
- if (typeof body.success === 'boolean' && !body.success) {
698
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
699
- reject(new Error(body.error || errString));
700
- }
701
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
702
- resolve(body);
703
- }
704
- else {
705
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
706
- reject(errString);
707
- }
708
- }
709
- });
710
- });
711
- });
722
+ else if (Object.keys(localVarFormParams).length > 0) {
723
+ // URL-encoded form
724
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
725
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
726
+ }
727
+ }
728
+ const response = await fetch(url, requestOptions);
729
+ return this.handleResponse(response, 'GetPostProcessingResultsResponse');
712
730
  }
713
731
  /**
714
732
  * Get the synthetic sample as a WAV file
@@ -720,9 +738,11 @@ class PerformanceCalibrationApi {
720
738
  const localVarPath = this.basePath + '/api/{projectId}/performance-calibration/wav'
721
739
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
722
740
  let localVarQueryParameters = {};
723
- let localVarHeaderParams = Object.assign({
724
- 'User-Agent': 'edgeimpulse-api nodejs'
725
- }, this.defaultHeaders);
741
+ let localVarHeaderParams = {
742
+ 'User-Agent': 'edgeimpulse-api nodejs',
743
+ 'Content-Type': 'application/json',
744
+ ...this.defaultHeaders,
745
+ };
726
746
  const produces = ['audio/wav'];
727
747
  // give precedence to 'application/json'
728
748
  if (produces.indexOf('application/json') >= 0) {
@@ -731,7 +751,7 @@ class PerformanceCalibrationApi {
731
751
  else {
732
752
  localVarHeaderParams.Accept = produces.join(',');
733
753
  }
734
- let localVarFormParams = {};
754
+ let localVarFormParams;
735
755
  // verify required parameter 'projectId' is not null or undefined
736
756
  if (projectId === null || projectId === undefined) {
737
757
  throw new Error('Required parameter projectId was null or undefined when calling getWavFile.');
@@ -739,55 +759,51 @@ class PerformanceCalibrationApi {
739
759
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
740
760
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
741
761
  }
742
- Object.assign(localVarHeaderParams, options.headers);
743
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
744
- let localVarUseFormData = false;
762
+ localVarHeaderParams = {
763
+ ...localVarHeaderParams,
764
+ ...options.headers,
765
+ ...this.opts.extraHeaders,
766
+ };
767
+ const queryString = Object.entries(localVarQueryParameters)
768
+ .filter(([, value]) => value !== undefined)
769
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
770
+ .join('&');
771
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
745
772
  let localVarRequestOptions = {
746
773
  method: 'GET',
747
- qs: localVarQueryParameters,
748
- headers: localVarHeaderParams,
749
- uri: localVarPath,
750
- useQuerystring: this._useQuerystring,
751
- agentOptions: { keepAlive: false },
752
- encoding: null,
753
- };
754
- let authenticationPromise = Promise.resolve();
755
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
756
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
757
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
758
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
759
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
760
- return authenticationPromise.then(() => {
761
- if (Object.keys(localVarFormParams).length) {
762
- if (localVarUseFormData) {
763
- localVarRequestOptions.formData = localVarFormParams;
764
- }
765
- else {
766
- localVarRequestOptions.form = localVarFormParams;
767
- }
774
+ headers: { ...localVarHeaderParams },
775
+ };
776
+ let requestOptions = localVarRequestOptions;
777
+ let url = localVarUrl;
778
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
779
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
780
+ url = auth_ApiKeyAuthentication.url;
781
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
782
+ requestOptions = auth_JWTAuthentication.requestOptions;
783
+ url = auth_JWTAuthentication.url;
784
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
785
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
786
+ url = auth_JWTHttpHeaderAuthentication.url;
787
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
788
+ requestOptions = auth_OAuth2.requestOptions;
789
+ url = auth_OAuth2.url;
790
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
791
+ requestOptions = authDefault.requestOptions;
792
+ url = authDefault.url;
793
+ if (localVarFormParams) {
794
+ delete requestOptions.headers['Content-Type'];
795
+ if (localVarFormParams instanceof FormData) {
796
+ // FormData: fetch will handle Content-Type automatically.
797
+ requestOptions.body = localVarFormParams;
768
798
  }
769
- return new Promise((resolve, reject) => {
770
- localVarRequest(localVarRequestOptions, (error, response, body) => {
771
- if (error) {
772
- reject(error);
773
- }
774
- else {
775
- body = models_1.ObjectSerializer.deserialize(body, "Buffer");
776
- if (typeof body.success === 'boolean' && !body.success) {
777
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
778
- reject(new Error(body.error || errString));
779
- }
780
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
781
- resolve(body);
782
- }
783
- else {
784
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
785
- reject(errString);
786
- }
787
- }
788
- });
789
- });
790
- });
799
+ else if (Object.keys(localVarFormParams).length > 0) {
800
+ // URL-encoded form
801
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
802
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
803
+ }
804
+ }
805
+ const response = await fetch(url, requestOptions);
806
+ return this.handleResponse(response, 'Buffer');
791
807
  }
792
808
  /**
793
809
  * Set the current performance calibration parameters
@@ -800,9 +816,11 @@ class PerformanceCalibrationApi {
800
816
  const localVarPath = this.basePath + '/api/{projectId}/performance-calibration/parameters'
801
817
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
802
818
  let localVarQueryParameters = {};
803
- let localVarHeaderParams = Object.assign({
804
- 'User-Agent': 'edgeimpulse-api nodejs'
805
- }, this.defaultHeaders);
819
+ let localVarHeaderParams = {
820
+ 'User-Agent': 'edgeimpulse-api nodejs',
821
+ 'Content-Type': 'application/json',
822
+ ...this.defaultHeaders,
823
+ };
806
824
  const produces = ['application/json'];
807
825
  // give precedence to 'application/json'
808
826
  if (produces.indexOf('application/json') >= 0) {
@@ -811,7 +829,7 @@ class PerformanceCalibrationApi {
811
829
  else {
812
830
  localVarHeaderParams.Accept = produces.join(',');
813
831
  }
814
- let localVarFormParams = {};
832
+ let localVarFormParams;
815
833
  // verify required parameter 'projectId' is not null or undefined
816
834
  if (projectId === null || projectId === undefined) {
817
835
  throw new Error('Required parameter projectId was null or undefined when calling setPerformanceCalibrationSavedParameters.');
@@ -823,56 +841,52 @@ class PerformanceCalibrationApi {
823
841
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
824
842
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
825
843
  }
826
- Object.assign(localVarHeaderParams, options.headers);
827
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
828
- let localVarUseFormData = false;
844
+ localVarHeaderParams = {
845
+ ...localVarHeaderParams,
846
+ ...options.headers,
847
+ ...this.opts.extraHeaders,
848
+ };
849
+ const queryString = Object.entries(localVarQueryParameters)
850
+ .filter(([, value]) => value !== undefined)
851
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
852
+ .join('&');
853
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
829
854
  let localVarRequestOptions = {
830
855
  method: 'POST',
831
- qs: localVarQueryParameters,
832
- headers: localVarHeaderParams,
833
- uri: localVarPath,
834
- useQuerystring: this._useQuerystring,
835
- agentOptions: { keepAlive: false },
836
- json: true,
837
- body: models_1.ObjectSerializer.serialize(performanceCalibrationSaveParameterSetRequest, "PerformanceCalibrationSaveParameterSetRequest")
838
- };
839
- let authenticationPromise = Promise.resolve();
840
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
841
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
842
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
843
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
844
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
845
- return authenticationPromise.then(() => {
846
- if (Object.keys(localVarFormParams).length) {
847
- if (localVarUseFormData) {
848
- localVarRequestOptions.formData = localVarFormParams;
849
- }
850
- else {
851
- localVarRequestOptions.form = localVarFormParams;
852
- }
856
+ headers: { ...localVarHeaderParams },
857
+ };
858
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(performanceCalibrationSaveParameterSetRequest, "PerformanceCalibrationSaveParameterSetRequest"));
859
+ let requestOptions = localVarRequestOptions;
860
+ let url = localVarUrl;
861
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
862
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
863
+ url = auth_ApiKeyAuthentication.url;
864
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
865
+ requestOptions = auth_JWTAuthentication.requestOptions;
866
+ url = auth_JWTAuthentication.url;
867
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
868
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
869
+ url = auth_JWTHttpHeaderAuthentication.url;
870
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
871
+ requestOptions = auth_OAuth2.requestOptions;
872
+ url = auth_OAuth2.url;
873
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
874
+ requestOptions = authDefault.requestOptions;
875
+ url = authDefault.url;
876
+ if (localVarFormParams) {
877
+ delete requestOptions.headers['Content-Type'];
878
+ if (localVarFormParams instanceof FormData) {
879
+ // FormData: fetch will handle Content-Type automatically.
880
+ requestOptions.body = localVarFormParams;
853
881
  }
854
- return new Promise((resolve, reject) => {
855
- localVarRequest(localVarRequestOptions, (error, response, body) => {
856
- if (error) {
857
- reject(error);
858
- }
859
- else {
860
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
861
- if (typeof body.success === 'boolean' && !body.success) {
862
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
863
- reject(new Error(body.error || errString));
864
- }
865
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
866
- resolve(body);
867
- }
868
- else {
869
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
870
- reject(errString);
871
- }
872
- }
873
- });
874
- });
875
- });
882
+ else if (Object.keys(localVarFormParams).length > 0) {
883
+ // URL-encoded form
884
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
885
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
886
+ }
887
+ }
888
+ const response = await fetch(url, requestOptions);
889
+ return this.handleResponse(response, 'GenericApiResponse');
876
890
  }
877
891
  /**
878
892
  * Upload a zip files with a wav file and its Label metadata to run performance calibration on it.
@@ -885,9 +899,11 @@ class PerformanceCalibrationApi {
885
899
  const localVarPath = this.basePath + '/api/{projectId}/performance-calibration/files'
886
900
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
887
901
  let localVarQueryParameters = {};
888
- let localVarHeaderParams = Object.assign({
889
- 'User-Agent': 'edgeimpulse-api nodejs'
890
- }, this.defaultHeaders);
902
+ let localVarHeaderParams = {
903
+ 'User-Agent': 'edgeimpulse-api nodejs',
904
+ 'Content-Type': 'application/json',
905
+ ...this.defaultHeaders,
906
+ };
891
907
  const produces = ['application/json'];
892
908
  // give precedence to 'application/json'
893
909
  if (produces.indexOf('application/json') >= 0) {
@@ -896,7 +912,7 @@ class PerformanceCalibrationApi {
896
912
  else {
897
913
  localVarHeaderParams.Accept = produces.join(',');
898
914
  }
899
- let localVarFormParams = {};
915
+ let localVarFormParams;
900
916
  // verify required parameter 'projectId' is not null or undefined
901
917
  if (projectId === null || projectId === undefined) {
902
918
  throw new Error('Required parameter projectId was null or undefined when calling uploadLabeledAudio.');
@@ -908,59 +924,69 @@ class PerformanceCalibrationApi {
908
924
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.impulseId) !== undefined) {
909
925
  localVarQueryParameters['impulseId'] = models_1.ObjectSerializer.serialize(queryParams.impulseId, "number");
910
926
  }
911
- Object.assign(localVarHeaderParams, options.headers);
912
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
913
- let localVarUseFormData = false;
927
+ localVarHeaderParams = {
928
+ ...localVarHeaderParams,
929
+ ...options.headers,
930
+ ...this.opts.extraHeaders,
931
+ };
914
932
  if (params.zip !== undefined) {
915
- localVarFormParams['zip'] = params.zip;
933
+ if (!(localVarFormParams instanceof FormData)) {
934
+ const existingParams = localVarFormParams;
935
+ localVarFormParams = new FormData();
936
+ if (existingParams && typeof existingParams === 'object') {
937
+ Object.keys(existingParams).forEach(key => {
938
+ localVarFormParams.append(key, existingParams[key]);
939
+ });
940
+ }
941
+ }
942
+ const zipFiles = Array.isArray(params.zip) ? params.zip : [params.zip];
943
+ const Blob = globalThis.Blob || require('buffer').Blob;
944
+ zipFiles.forEach((f) => {
945
+ localVarFormParams.append('zip', new Blob([f.value], {
946
+ type: f.options.contentType
947
+ }), f.options.filename);
948
+ });
916
949
  }
917
- localVarUseFormData = true;
950
+ const queryString = Object.entries(localVarQueryParameters)
951
+ .filter(([, value]) => value !== undefined)
952
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
953
+ .join('&');
954
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
918
955
  let localVarRequestOptions = {
919
956
  method: 'POST',
920
- qs: localVarQueryParameters,
921
- headers: localVarHeaderParams,
922
- uri: localVarPath,
923
- useQuerystring: this._useQuerystring,
924
- agentOptions: { keepAlive: false },
925
- json: true,
926
- };
927
- let authenticationPromise = Promise.resolve();
928
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
929
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
930
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
931
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
932
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
933
- return authenticationPromise.then(() => {
934
- if (Object.keys(localVarFormParams).length) {
935
- if (localVarUseFormData) {
936
- localVarRequestOptions.formData = localVarFormParams;
937
- }
938
- else {
939
- localVarRequestOptions.form = localVarFormParams;
940
- }
957
+ headers: { ...localVarHeaderParams },
958
+ };
959
+ let requestOptions = localVarRequestOptions;
960
+ let url = localVarUrl;
961
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
962
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
963
+ url = auth_ApiKeyAuthentication.url;
964
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
965
+ requestOptions = auth_JWTAuthentication.requestOptions;
966
+ url = auth_JWTAuthentication.url;
967
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
968
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
969
+ url = auth_JWTHttpHeaderAuthentication.url;
970
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
971
+ requestOptions = auth_OAuth2.requestOptions;
972
+ url = auth_OAuth2.url;
973
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
974
+ requestOptions = authDefault.requestOptions;
975
+ url = authDefault.url;
976
+ if (localVarFormParams) {
977
+ delete requestOptions.headers['Content-Type'];
978
+ if (localVarFormParams instanceof FormData) {
979
+ // FormData: fetch will handle Content-Type automatically.
980
+ requestOptions.body = localVarFormParams;
941
981
  }
942
- return new Promise((resolve, reject) => {
943
- localVarRequest(localVarRequestOptions, (error, response, body) => {
944
- if (error) {
945
- reject(error);
946
- }
947
- else {
948
- body = models_1.ObjectSerializer.deserialize(body, "PerformanceCalibrationUploadLabeledAudioResponse");
949
- if (typeof body.success === 'boolean' && !body.success) {
950
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
951
- reject(new Error(body.error || errString));
952
- }
953
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
954
- resolve(body);
955
- }
956
- else {
957
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
958
- reject(errString);
959
- }
960
- }
961
- });
962
- });
963
- });
982
+ else if (Object.keys(localVarFormParams).length > 0) {
983
+ // URL-encoded form
984
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
985
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
986
+ }
987
+ }
988
+ const response = await fetch(url, requestOptions);
989
+ return this.handleResponse(response, 'PerformanceCalibrationUploadLabeledAudioResponse');
964
990
  }
965
991
  }
966
992
  exports.PerformanceCalibrationApi = PerformanceCalibrationApi;