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.DSPApi = exports.DSPApiApiKeys = 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 DSPApiApiKeys;
30
47
  DSPApiApiKeys[DSPApiApiKeys["JWTHttpHeaderAuthentication"] = 2] = "JWTHttpHeaderAuthentication";
31
48
  })(DSPApiApiKeys = exports.DSPApiApiKeys || (exports.DSPApiApiKeys = {}));
32
49
  class DSPApi {
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 DSPApi {
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
  }
@@ -89,9 +123,11 @@ class DSPApi {
89
123
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
90
124
  .replace('{' + 'dspId' + '}', encodeURIComponent(String(dspId)));
91
125
  let localVarQueryParameters = {};
92
- let localVarHeaderParams = Object.assign({
93
- 'User-Agent': 'edgeimpulse-api nodejs'
94
- }, this.defaultHeaders);
126
+ let localVarHeaderParams = {
127
+ 'User-Agent': 'edgeimpulse-api nodejs',
128
+ 'Content-Type': 'application/json',
129
+ ...this.defaultHeaders,
130
+ };
95
131
  const produces = ['application/json'];
96
132
  // give precedence to 'application/json'
97
133
  if (produces.indexOf('application/json') >= 0) {
@@ -100,7 +136,7 @@ class DSPApi {
100
136
  else {
101
137
  localVarHeaderParams.Accept = produces.join(',');
102
138
  }
103
- let localVarFormParams = {};
139
+ let localVarFormParams;
104
140
  // verify required parameter 'projectId' is not null or undefined
105
141
  if (projectId === null || projectId === undefined) {
106
142
  throw new Error('Required parameter projectId was null or undefined when calling clearDspBlock.');
@@ -109,55 +145,51 @@ class DSPApi {
109
145
  if (dspId === null || dspId === undefined) {
110
146
  throw new Error('Required parameter dspId was null or undefined when calling clearDspBlock.');
111
147
  }
112
- Object.assign(localVarHeaderParams, options.headers);
113
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
114
- let localVarUseFormData = false;
148
+ localVarHeaderParams = {
149
+ ...localVarHeaderParams,
150
+ ...options.headers,
151
+ ...this.opts.extraHeaders,
152
+ };
153
+ const queryString = Object.entries(localVarQueryParameters)
154
+ .filter(([, value]) => value !== undefined)
155
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
156
+ .join('&');
157
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
115
158
  let localVarRequestOptions = {
116
159
  method: 'POST',
117
- qs: localVarQueryParameters,
118
- headers: localVarHeaderParams,
119
- uri: localVarPath,
120
- useQuerystring: this._useQuerystring,
121
- agentOptions: { keepAlive: false },
122
- json: true,
160
+ headers: { ...localVarHeaderParams },
123
161
  };
124
- let authenticationPromise = Promise.resolve();
125
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
126
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
127
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
128
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
129
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
130
- return authenticationPromise.then(() => {
131
- if (Object.keys(localVarFormParams).length) {
132
- if (localVarUseFormData) {
133
- localVarRequestOptions.formData = localVarFormParams;
134
- }
135
- else {
136
- localVarRequestOptions.form = localVarFormParams;
137
- }
162
+ let requestOptions = localVarRequestOptions;
163
+ let url = localVarUrl;
164
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
165
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
166
+ url = auth_ApiKeyAuthentication.url;
167
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
168
+ requestOptions = auth_JWTAuthentication.requestOptions;
169
+ url = auth_JWTAuthentication.url;
170
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
171
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
172
+ url = auth_JWTHttpHeaderAuthentication.url;
173
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
174
+ requestOptions = auth_OAuth2.requestOptions;
175
+ url = auth_OAuth2.url;
176
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
177
+ requestOptions = authDefault.requestOptions;
178
+ url = authDefault.url;
179
+ if (localVarFormParams) {
180
+ delete requestOptions.headers['Content-Type'];
181
+ if (localVarFormParams instanceof FormData) {
182
+ // FormData: fetch will handle Content-Type automatically.
183
+ requestOptions.body = localVarFormParams;
184
+ }
185
+ else if (Object.keys(localVarFormParams).length > 0) {
186
+ // URL-encoded form
187
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
188
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
138
189
  }
139
- return new Promise((resolve, reject) => {
140
- localVarRequest(localVarRequestOptions, (error, response, body) => {
141
- if (error) {
142
- reject(error);
143
- }
144
- else {
145
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
146
- if (typeof body.success === 'boolean' && !body.success) {
147
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
148
- reject(new Error(body.error || errString));
149
- }
150
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
151
- resolve(body);
152
- }
153
- else {
154
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
155
- reject(errString);
156
- }
157
- }
158
- });
159
- });
160
- });
190
+ }
191
+ const response = await fetch(url, requestOptions);
192
+ return this.handleResponse(response, 'GenericApiResponse');
161
193
  }
162
194
  /**
163
195
  * Download an artifact from a DSP block for debugging. This is an internal API.
@@ -172,9 +204,11 @@ class DSPApi {
172
204
  .replace('{' + 'dspId' + '}', encodeURIComponent(String(dspId)))
173
205
  .replace('{' + 'key' + '}', encodeURIComponent(String(key)));
174
206
  let localVarQueryParameters = {};
175
- let localVarHeaderParams = Object.assign({
176
- 'User-Agent': 'edgeimpulse-api nodejs'
177
- }, this.defaultHeaders);
207
+ let localVarHeaderParams = {
208
+ 'User-Agent': 'edgeimpulse-api nodejs',
209
+ 'Content-Type': 'application/json',
210
+ ...this.defaultHeaders,
211
+ };
178
212
  const produces = ['application/octet-stream'];
179
213
  // give precedence to 'application/json'
180
214
  if (produces.indexOf('application/json') >= 0) {
@@ -183,7 +217,7 @@ class DSPApi {
183
217
  else {
184
218
  localVarHeaderParams.Accept = produces.join(',');
185
219
  }
186
- let localVarFormParams = {};
220
+ let localVarFormParams;
187
221
  // verify required parameter 'projectId' is not null or undefined
188
222
  if (projectId === null || projectId === undefined) {
189
223
  throw new Error('Required parameter projectId was null or undefined when calling downloadDspArtifact.');
@@ -196,55 +230,51 @@ class DSPApi {
196
230
  if (key === null || key === undefined) {
197
231
  throw new Error('Required parameter key was null or undefined when calling downloadDspArtifact.');
198
232
  }
199
- Object.assign(localVarHeaderParams, options.headers);
200
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
201
- let localVarUseFormData = false;
233
+ localVarHeaderParams = {
234
+ ...localVarHeaderParams,
235
+ ...options.headers,
236
+ ...this.opts.extraHeaders,
237
+ };
238
+ const queryString = Object.entries(localVarQueryParameters)
239
+ .filter(([, value]) => value !== undefined)
240
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
241
+ .join('&');
242
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
202
243
  let localVarRequestOptions = {
203
244
  method: 'GET',
204
- qs: localVarQueryParameters,
205
- headers: localVarHeaderParams,
206
- uri: localVarPath,
207
- useQuerystring: this._useQuerystring,
208
- agentOptions: { keepAlive: false },
209
- encoding: null,
245
+ headers: { ...localVarHeaderParams },
210
246
  };
211
- let authenticationPromise = Promise.resolve();
212
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
213
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
214
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
215
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
216
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
217
- return authenticationPromise.then(() => {
218
- if (Object.keys(localVarFormParams).length) {
219
- if (localVarUseFormData) {
220
- localVarRequestOptions.formData = localVarFormParams;
221
- }
222
- else {
223
- localVarRequestOptions.form = localVarFormParams;
224
- }
247
+ let requestOptions = localVarRequestOptions;
248
+ let url = localVarUrl;
249
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
250
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
251
+ url = auth_ApiKeyAuthentication.url;
252
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
253
+ requestOptions = auth_JWTAuthentication.requestOptions;
254
+ url = auth_JWTAuthentication.url;
255
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
256
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
257
+ url = auth_JWTHttpHeaderAuthentication.url;
258
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
259
+ requestOptions = auth_OAuth2.requestOptions;
260
+ url = auth_OAuth2.url;
261
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
262
+ requestOptions = authDefault.requestOptions;
263
+ url = authDefault.url;
264
+ if (localVarFormParams) {
265
+ delete requestOptions.headers['Content-Type'];
266
+ if (localVarFormParams instanceof FormData) {
267
+ // FormData: fetch will handle Content-Type automatically.
268
+ requestOptions.body = localVarFormParams;
225
269
  }
226
- return new Promise((resolve, reject) => {
227
- localVarRequest(localVarRequestOptions, (error, response, body) => {
228
- if (error) {
229
- reject(error);
230
- }
231
- else {
232
- body = models_1.ObjectSerializer.deserialize(body, "Buffer");
233
- if (typeof body.success === 'boolean' && !body.success) {
234
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
235
- reject(new Error(body.error || errString));
236
- }
237
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
238
- resolve(body);
239
- }
240
- else {
241
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
242
- reject(errString);
243
- }
244
- }
245
- });
246
- });
247
- });
270
+ else if (Object.keys(localVarFormParams).length > 0) {
271
+ // URL-encoded form
272
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
273
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
274
+ }
275
+ }
276
+ const response = await fetch(url, requestOptions);
277
+ return this.handleResponse(response, 'Buffer');
248
278
  }
249
279
  /**
250
280
  * Download output from a DSP block over all data in the training set, already sliced in windows. In Numpy binary format.
@@ -260,9 +290,11 @@ class DSPApi {
260
290
  .replace('{' + 'dspId' + '}', encodeURIComponent(String(dspId)))
261
291
  .replace('{' + 'category' + '}', encodeURIComponent(String(category)));
262
292
  let localVarQueryParameters = {};
263
- let localVarHeaderParams = Object.assign({
264
- 'User-Agent': 'edgeimpulse-api nodejs'
265
- }, this.defaultHeaders);
293
+ let localVarHeaderParams = {
294
+ 'User-Agent': 'edgeimpulse-api nodejs',
295
+ 'Content-Type': 'application/json',
296
+ ...this.defaultHeaders,
297
+ };
266
298
  const produces = ['application/octet-stream'];
267
299
  // give precedence to 'application/json'
268
300
  if (produces.indexOf('application/json') >= 0) {
@@ -271,7 +303,7 @@ class DSPApi {
271
303
  else {
272
304
  localVarHeaderParams.Accept = produces.join(',');
273
305
  }
274
- let localVarFormParams = {};
306
+ let localVarFormParams;
275
307
  // verify required parameter 'projectId' is not null or undefined
276
308
  if (projectId === null || projectId === undefined) {
277
309
  throw new Error('Required parameter projectId was null or undefined when calling downloadDspData.');
@@ -287,55 +319,51 @@ class DSPApi {
287
319
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.raw) !== undefined) {
288
320
  localVarQueryParameters['raw'] = models_1.ObjectSerializer.serialize(queryParams.raw, "boolean");
289
321
  }
290
- Object.assign(localVarHeaderParams, options.headers);
291
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
292
- let localVarUseFormData = false;
322
+ localVarHeaderParams = {
323
+ ...localVarHeaderParams,
324
+ ...options.headers,
325
+ ...this.opts.extraHeaders,
326
+ };
327
+ const queryString = Object.entries(localVarQueryParameters)
328
+ .filter(([, value]) => value !== undefined)
329
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
330
+ .join('&');
331
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
293
332
  let localVarRequestOptions = {
294
333
  method: 'GET',
295
- qs: localVarQueryParameters,
296
- headers: localVarHeaderParams,
297
- uri: localVarPath,
298
- useQuerystring: this._useQuerystring,
299
- agentOptions: { keepAlive: false },
300
- encoding: null,
334
+ headers: { ...localVarHeaderParams },
301
335
  };
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
- }
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;
358
+ }
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';
316
363
  }
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, "Buffer");
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
- });
364
+ }
365
+ const response = await fetch(url, requestOptions);
366
+ return this.handleResponse(response, 'Buffer');
339
367
  }
340
368
  /**
341
369
  * Download labels for a DSP block over all data in the training set, already sliced in windows.
@@ -350,9 +378,11 @@ class DSPApi {
350
378
  .replace('{' + 'dspId' + '}', encodeURIComponent(String(dspId)))
351
379
  .replace('{' + 'category' + '}', encodeURIComponent(String(category)));
352
380
  let localVarQueryParameters = {};
353
- let localVarHeaderParams = Object.assign({
354
- 'User-Agent': 'edgeimpulse-api nodejs'
355
- }, this.defaultHeaders);
381
+ let localVarHeaderParams = {
382
+ 'User-Agent': 'edgeimpulse-api nodejs',
383
+ 'Content-Type': 'application/json',
384
+ ...this.defaultHeaders,
385
+ };
356
386
  const produces = ['application/octet-stream'];
357
387
  // give precedence to 'application/json'
358
388
  if (produces.indexOf('application/json') >= 0) {
@@ -361,7 +391,7 @@ class DSPApi {
361
391
  else {
362
392
  localVarHeaderParams.Accept = produces.join(',');
363
393
  }
364
- let localVarFormParams = {};
394
+ let localVarFormParams;
365
395
  // verify required parameter 'projectId' is not null or undefined
366
396
  if (projectId === null || projectId === undefined) {
367
397
  throw new Error('Required parameter projectId was null or undefined when calling downloadDspLabels.');
@@ -374,55 +404,51 @@ class DSPApi {
374
404
  if (category === null || category === undefined) {
375
405
  throw new Error('Required parameter category was null or undefined when calling downloadDspLabels.');
376
406
  }
377
- Object.assign(localVarHeaderParams, options.headers);
378
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
379
- let localVarUseFormData = false;
407
+ localVarHeaderParams = {
408
+ ...localVarHeaderParams,
409
+ ...options.headers,
410
+ ...this.opts.extraHeaders,
411
+ };
412
+ const queryString = Object.entries(localVarQueryParameters)
413
+ .filter(([, value]) => value !== undefined)
414
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
415
+ .join('&');
416
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
380
417
  let localVarRequestOptions = {
381
418
  method: 'GET',
382
- qs: localVarQueryParameters,
383
- headers: localVarHeaderParams,
384
- uri: localVarPath,
385
- useQuerystring: this._useQuerystring,
386
- agentOptions: { keepAlive: false },
387
- encoding: null,
419
+ headers: { ...localVarHeaderParams },
388
420
  };
389
- let authenticationPromise = Promise.resolve();
390
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
391
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
392
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
393
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
394
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
395
- return authenticationPromise.then(() => {
396
- if (Object.keys(localVarFormParams).length) {
397
- if (localVarUseFormData) {
398
- localVarRequestOptions.formData = localVarFormParams;
399
- }
400
- else {
401
- localVarRequestOptions.form = localVarFormParams;
402
- }
421
+ let requestOptions = localVarRequestOptions;
422
+ let url = localVarUrl;
423
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
424
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
425
+ url = auth_ApiKeyAuthentication.url;
426
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
427
+ requestOptions = auth_JWTAuthentication.requestOptions;
428
+ url = auth_JWTAuthentication.url;
429
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
430
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
431
+ url = auth_JWTHttpHeaderAuthentication.url;
432
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
433
+ requestOptions = auth_OAuth2.requestOptions;
434
+ url = auth_OAuth2.url;
435
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
436
+ requestOptions = authDefault.requestOptions;
437
+ url = authDefault.url;
438
+ if (localVarFormParams) {
439
+ delete requestOptions.headers['Content-Type'];
440
+ if (localVarFormParams instanceof FormData) {
441
+ // FormData: fetch will handle Content-Type automatically.
442
+ requestOptions.body = localVarFormParams;
403
443
  }
404
- return new Promise((resolve, reject) => {
405
- localVarRequest(localVarRequestOptions, (error, response, body) => {
406
- if (error) {
407
- reject(error);
408
- }
409
- else {
410
- body = models_1.ObjectSerializer.deserialize(body, "Buffer");
411
- if (typeof body.success === 'boolean' && !body.success) {
412
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
413
- reject(new Error(body.error || errString));
414
- }
415
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
416
- resolve(body);
417
- }
418
- else {
419
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
420
- reject(errString);
421
- }
422
- }
423
- });
424
- });
425
- });
444
+ else if (Object.keys(localVarFormParams).length > 0) {
445
+ // URL-encoded form
446
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
447
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
448
+ }
449
+ }
450
+ const response = await fetch(url, requestOptions);
451
+ return this.handleResponse(response, 'Buffer');
426
452
  }
427
453
  /**
428
454
  * Runs the DSP block against a sample. This will move the sliding window (dependent on the sliding window length and the sliding window increase parameters in the impulse) over the complete file, and run the DSP function for every window that is extracted.
@@ -437,9 +463,11 @@ class DSPApi {
437
463
  .replace('{' + 'dspId' + '}', encodeURIComponent(String(dspId)))
438
464
  .replace('{' + 'sampleId' + '}', encodeURIComponent(String(sampleId)));
439
465
  let localVarQueryParameters = {};
440
- let localVarHeaderParams = Object.assign({
441
- 'User-Agent': 'edgeimpulse-api nodejs'
442
- }, this.defaultHeaders);
466
+ let localVarHeaderParams = {
467
+ 'User-Agent': 'edgeimpulse-api nodejs',
468
+ 'Content-Type': 'application/json',
469
+ ...this.defaultHeaders,
470
+ };
443
471
  const produces = ['application/json'];
444
472
  // give precedence to 'application/json'
445
473
  if (produces.indexOf('application/json') >= 0) {
@@ -448,7 +476,7 @@ class DSPApi {
448
476
  else {
449
477
  localVarHeaderParams.Accept = produces.join(',');
450
478
  }
451
- let localVarFormParams = {};
479
+ let localVarFormParams;
452
480
  // verify required parameter 'projectId' is not null or undefined
453
481
  if (projectId === null || projectId === undefined) {
454
482
  throw new Error('Required parameter projectId was null or undefined when calling dspGetFeaturesForSample.');
@@ -461,55 +489,51 @@ class DSPApi {
461
489
  if (sampleId === null || sampleId === undefined) {
462
490
  throw new Error('Required parameter sampleId was null or undefined when calling dspGetFeaturesForSample.');
463
491
  }
464
- Object.assign(localVarHeaderParams, options.headers);
465
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
466
- let localVarUseFormData = false;
492
+ localVarHeaderParams = {
493
+ ...localVarHeaderParams,
494
+ ...options.headers,
495
+ ...this.opts.extraHeaders,
496
+ };
497
+ const queryString = Object.entries(localVarQueryParameters)
498
+ .filter(([, value]) => value !== undefined)
499
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
500
+ .join('&');
501
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
467
502
  let localVarRequestOptions = {
468
503
  method: 'GET',
469
- qs: localVarQueryParameters,
470
- headers: localVarHeaderParams,
471
- uri: localVarPath,
472
- useQuerystring: this._useQuerystring,
473
- agentOptions: { keepAlive: false },
474
- json: true,
504
+ headers: { ...localVarHeaderParams },
475
505
  };
476
- let authenticationPromise = Promise.resolve();
477
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
478
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
479
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
480
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
481
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
482
- return authenticationPromise.then(() => {
483
- if (Object.keys(localVarFormParams).length) {
484
- if (localVarUseFormData) {
485
- localVarRequestOptions.formData = localVarFormParams;
486
- }
487
- else {
488
- localVarRequestOptions.form = localVarFormParams;
489
- }
506
+ let requestOptions = localVarRequestOptions;
507
+ let url = localVarUrl;
508
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
509
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
510
+ url = auth_ApiKeyAuthentication.url;
511
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
512
+ requestOptions = auth_JWTAuthentication.requestOptions;
513
+ url = auth_JWTAuthentication.url;
514
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
515
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
516
+ url = auth_JWTHttpHeaderAuthentication.url;
517
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
518
+ requestOptions = auth_OAuth2.requestOptions;
519
+ url = auth_OAuth2.url;
520
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
521
+ requestOptions = authDefault.requestOptions;
522
+ url = authDefault.url;
523
+ if (localVarFormParams) {
524
+ delete requestOptions.headers['Content-Type'];
525
+ if (localVarFormParams instanceof FormData) {
526
+ // FormData: fetch will handle Content-Type automatically.
527
+ requestOptions.body = localVarFormParams;
528
+ }
529
+ else if (Object.keys(localVarFormParams).length > 0) {
530
+ // URL-encoded form
531
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
532
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
490
533
  }
491
- return new Promise((resolve, reject) => {
492
- localVarRequest(localVarRequestOptions, (error, response, body) => {
493
- if (error) {
494
- reject(error);
495
- }
496
- else {
497
- body = models_1.ObjectSerializer.deserialize(body, "DspSampleFeaturesResponse");
498
- if (typeof body.success === 'boolean' && !body.success) {
499
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
500
- reject(new Error(body.error || errString));
501
- }
502
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
503
- resolve(body);
504
- }
505
- else {
506
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
507
- reject(errString);
508
- }
509
- }
510
- });
511
- });
512
- });
534
+ }
535
+ const response = await fetch(url, requestOptions);
536
+ return this.handleResponse(response, 'DspSampleFeaturesResponse');
513
537
  }
514
538
  /**
515
539
  * Get a sample of trained features, this extracts a number of samples and their labels. Used to visualize the current training set.
@@ -527,9 +551,11 @@ class DSPApi {
527
551
  .replace('{' + 'dspId' + '}', encodeURIComponent(String(dspId)))
528
552
  .replace('{' + 'category' + '}', encodeURIComponent(String(category)));
529
553
  let localVarQueryParameters = {};
530
- let localVarHeaderParams = Object.assign({
531
- 'User-Agent': 'edgeimpulse-api nodejs'
532
- }, this.defaultHeaders);
554
+ let localVarHeaderParams = {
555
+ 'User-Agent': 'edgeimpulse-api nodejs',
556
+ 'Content-Type': 'application/json',
557
+ ...this.defaultHeaders,
558
+ };
533
559
  const produces = ['application/json'];
534
560
  // give precedence to 'application/json'
535
561
  if (produces.indexOf('application/json') >= 0) {
@@ -538,7 +564,7 @@ class DSPApi {
538
564
  else {
539
565
  localVarHeaderParams.Accept = produces.join(',');
540
566
  }
541
- let localVarFormParams = {};
567
+ let localVarFormParams;
542
568
  // verify required parameter 'projectId' is not null or undefined
543
569
  if (projectId === null || projectId === undefined) {
544
570
  throw new Error('Required parameter projectId was null or undefined when calling dspSampleTrainedFeatures.');
@@ -572,55 +598,51 @@ class DSPApi {
572
598
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.featureAx3) !== undefined) {
573
599
  localVarQueryParameters['featureAx3'] = models_1.ObjectSerializer.serialize(queryParams.featureAx3, "number");
574
600
  }
575
- Object.assign(localVarHeaderParams, options.headers);
576
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
577
- let localVarUseFormData = false;
601
+ localVarHeaderParams = {
602
+ ...localVarHeaderParams,
603
+ ...options.headers,
604
+ ...this.opts.extraHeaders,
605
+ };
606
+ const queryString = Object.entries(localVarQueryParameters)
607
+ .filter(([, value]) => value !== undefined)
608
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
609
+ .join('&');
610
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
578
611
  let localVarRequestOptions = {
579
612
  method: 'GET',
580
- qs: localVarQueryParameters,
581
- headers: localVarHeaderParams,
582
- uri: localVarPath,
583
- useQuerystring: this._useQuerystring,
584
- agentOptions: { keepAlive: false },
585
- json: true,
613
+ headers: { ...localVarHeaderParams },
586
614
  };
587
- let authenticationPromise = Promise.resolve();
588
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
589
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
590
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
591
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
592
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
593
- return authenticationPromise.then(() => {
594
- if (Object.keys(localVarFormParams).length) {
595
- if (localVarUseFormData) {
596
- localVarRequestOptions.formData = localVarFormParams;
597
- }
598
- else {
599
- localVarRequestOptions.form = localVarFormParams;
600
- }
615
+ let requestOptions = localVarRequestOptions;
616
+ let url = localVarUrl;
617
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
618
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
619
+ url = auth_ApiKeyAuthentication.url;
620
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
621
+ requestOptions = auth_JWTAuthentication.requestOptions;
622
+ url = auth_JWTAuthentication.url;
623
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
624
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
625
+ url = auth_JWTHttpHeaderAuthentication.url;
626
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
627
+ requestOptions = auth_OAuth2.requestOptions;
628
+ url = auth_OAuth2.url;
629
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
630
+ requestOptions = authDefault.requestOptions;
631
+ url = authDefault.url;
632
+ if (localVarFormParams) {
633
+ delete requestOptions.headers['Content-Type'];
634
+ if (localVarFormParams instanceof FormData) {
635
+ // FormData: fetch will handle Content-Type automatically.
636
+ requestOptions.body = localVarFormParams;
601
637
  }
602
- return new Promise((resolve, reject) => {
603
- localVarRequest(localVarRequestOptions, (error, response, body) => {
604
- if (error) {
605
- reject(error);
606
- }
607
- else {
608
- body = models_1.ObjectSerializer.deserialize(body, "DspTrainedFeaturesResponse");
609
- if (typeof body.success === 'boolean' && !body.success) {
610
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
611
- reject(new Error(body.error || errString));
612
- }
613
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
614
- resolve(body);
615
- }
616
- else {
617
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
618
- reject(errString);
619
- }
620
- }
621
- });
622
- });
623
- });
638
+ else if (Object.keys(localVarFormParams).length > 0) {
639
+ // URL-encoded form
640
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
641
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
642
+ }
643
+ }
644
+ const response = await fetch(url, requestOptions);
645
+ return this.handleResponse(response, 'DspTrainedFeaturesResponse');
624
646
  }
625
647
  /**
626
648
  * Get a set of parameters, found as a result of running the DSP autotuner.
@@ -633,9 +655,11 @@ class DSPApi {
633
655
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
634
656
  .replace('{' + 'dspId' + '}', encodeURIComponent(String(dspId)));
635
657
  let localVarQueryParameters = {};
636
- let localVarHeaderParams = Object.assign({
637
- 'User-Agent': 'edgeimpulse-api nodejs'
638
- }, this.defaultHeaders);
658
+ let localVarHeaderParams = {
659
+ 'User-Agent': 'edgeimpulse-api nodejs',
660
+ 'Content-Type': 'application/json',
661
+ ...this.defaultHeaders,
662
+ };
639
663
  const produces = ['application/json'];
640
664
  // give precedence to 'application/json'
641
665
  if (produces.indexOf('application/json') >= 0) {
@@ -644,7 +668,7 @@ class DSPApi {
644
668
  else {
645
669
  localVarHeaderParams.Accept = produces.join(',');
646
670
  }
647
- let localVarFormParams = {};
671
+ let localVarFormParams;
648
672
  // verify required parameter 'projectId' is not null or undefined
649
673
  if (projectId === null || projectId === undefined) {
650
674
  throw new Error('Required parameter projectId was null or undefined when calling getAutotunerResults.');
@@ -653,55 +677,51 @@ class DSPApi {
653
677
  if (dspId === null || dspId === undefined) {
654
678
  throw new Error('Required parameter dspId was null or undefined when calling getAutotunerResults.');
655
679
  }
656
- Object.assign(localVarHeaderParams, options.headers);
657
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
658
- let localVarUseFormData = false;
680
+ localVarHeaderParams = {
681
+ ...localVarHeaderParams,
682
+ ...options.headers,
683
+ ...this.opts.extraHeaders,
684
+ };
685
+ const queryString = Object.entries(localVarQueryParameters)
686
+ .filter(([, value]) => value !== undefined)
687
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
688
+ .join('&');
689
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
659
690
  let localVarRequestOptions = {
660
691
  method: 'GET',
661
- qs: localVarQueryParameters,
662
- headers: localVarHeaderParams,
663
- uri: localVarPath,
664
- useQuerystring: this._useQuerystring,
665
- agentOptions: { keepAlive: false },
666
- json: true,
692
+ headers: { ...localVarHeaderParams },
667
693
  };
668
- let authenticationPromise = Promise.resolve();
669
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
670
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
671
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
672
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
673
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
674
- return authenticationPromise.then(() => {
675
- if (Object.keys(localVarFormParams).length) {
676
- if (localVarUseFormData) {
677
- localVarRequestOptions.formData = localVarFormParams;
678
- }
679
- else {
680
- localVarRequestOptions.form = localVarFormParams;
681
- }
694
+ let requestOptions = localVarRequestOptions;
695
+ let url = localVarUrl;
696
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
697
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
698
+ url = auth_ApiKeyAuthentication.url;
699
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
700
+ requestOptions = auth_JWTAuthentication.requestOptions;
701
+ url = auth_JWTAuthentication.url;
702
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
703
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
704
+ url = auth_JWTHttpHeaderAuthentication.url;
705
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
706
+ requestOptions = auth_OAuth2.requestOptions;
707
+ url = auth_OAuth2.url;
708
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
709
+ requestOptions = authDefault.requestOptions;
710
+ url = authDefault.url;
711
+ if (localVarFormParams) {
712
+ delete requestOptions.headers['Content-Type'];
713
+ if (localVarFormParams instanceof FormData) {
714
+ // FormData: fetch will handle Content-Type automatically.
715
+ requestOptions.body = localVarFormParams;
716
+ }
717
+ else if (Object.keys(localVarFormParams).length > 0) {
718
+ // URL-encoded form
719
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
720
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
682
721
  }
683
- return new Promise((resolve, reject) => {
684
- localVarRequest(localVarRequestOptions, (error, response, body) => {
685
- if (error) {
686
- reject(error);
687
- }
688
- else {
689
- body = models_1.ObjectSerializer.deserialize(body, "DspAutotunerResults");
690
- if (typeof body.success === 'boolean' && !body.success) {
691
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
692
- reject(new Error(body.error || errString));
693
- }
694
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
695
- resolve(body);
696
- }
697
- else {
698
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
699
- reject(errString);
700
- }
701
- }
702
- });
703
- });
704
- });
722
+ }
723
+ const response = await fetch(url, requestOptions);
724
+ return this.handleResponse(response, 'DspAutotunerResults');
705
725
  }
706
726
  /**
707
727
  * Retrieve the configuration parameters for the DSP block. Use the impulse functions to retrieve all DSP blocks.
@@ -714,9 +734,11 @@ class DSPApi {
714
734
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
715
735
  .replace('{' + 'dspId' + '}', encodeURIComponent(String(dspId)));
716
736
  let localVarQueryParameters = {};
717
- let localVarHeaderParams = Object.assign({
718
- 'User-Agent': 'edgeimpulse-api nodejs'
719
- }, this.defaultHeaders);
737
+ let localVarHeaderParams = {
738
+ 'User-Agent': 'edgeimpulse-api nodejs',
739
+ 'Content-Type': 'application/json',
740
+ ...this.defaultHeaders,
741
+ };
720
742
  const produces = ['application/json'];
721
743
  // give precedence to 'application/json'
722
744
  if (produces.indexOf('application/json') >= 0) {
@@ -725,7 +747,7 @@ class DSPApi {
725
747
  else {
726
748
  localVarHeaderParams.Accept = produces.join(',');
727
749
  }
728
- let localVarFormParams = {};
750
+ let localVarFormParams;
729
751
  // verify required parameter 'projectId' is not null or undefined
730
752
  if (projectId === null || projectId === undefined) {
731
753
  throw new Error('Required parameter projectId was null or undefined when calling getDspConfig.');
@@ -734,55 +756,51 @@ class DSPApi {
734
756
  if (dspId === null || dspId === undefined) {
735
757
  throw new Error('Required parameter dspId was null or undefined when calling getDspConfig.');
736
758
  }
737
- Object.assign(localVarHeaderParams, options.headers);
738
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
739
- let localVarUseFormData = false;
759
+ localVarHeaderParams = {
760
+ ...localVarHeaderParams,
761
+ ...options.headers,
762
+ ...this.opts.extraHeaders,
763
+ };
764
+ const queryString = Object.entries(localVarQueryParameters)
765
+ .filter(([, value]) => value !== undefined)
766
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
767
+ .join('&');
768
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
740
769
  let localVarRequestOptions = {
741
770
  method: 'GET',
742
- qs: localVarQueryParameters,
743
- headers: localVarHeaderParams,
744
- uri: localVarPath,
745
- useQuerystring: this._useQuerystring,
746
- agentOptions: { keepAlive: false },
747
- json: true,
771
+ headers: { ...localVarHeaderParams },
748
772
  };
749
- let authenticationPromise = Promise.resolve();
750
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
751
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
752
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
753
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
754
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
755
- return authenticationPromise.then(() => {
756
- if (Object.keys(localVarFormParams).length) {
757
- if (localVarUseFormData) {
758
- localVarRequestOptions.formData = localVarFormParams;
759
- }
760
- else {
761
- localVarRequestOptions.form = localVarFormParams;
762
- }
773
+ let requestOptions = localVarRequestOptions;
774
+ let url = localVarUrl;
775
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
776
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
777
+ url = auth_ApiKeyAuthentication.url;
778
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
779
+ requestOptions = auth_JWTAuthentication.requestOptions;
780
+ url = auth_JWTAuthentication.url;
781
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
782
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
783
+ url = auth_JWTHttpHeaderAuthentication.url;
784
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
785
+ requestOptions = auth_OAuth2.requestOptions;
786
+ url = auth_OAuth2.url;
787
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
788
+ requestOptions = authDefault.requestOptions;
789
+ url = authDefault.url;
790
+ if (localVarFormParams) {
791
+ delete requestOptions.headers['Content-Type'];
792
+ if (localVarFormParams instanceof FormData) {
793
+ // FormData: fetch will handle Content-Type automatically.
794
+ requestOptions.body = localVarFormParams;
795
+ }
796
+ else if (Object.keys(localVarFormParams).length > 0) {
797
+ // URL-encoded form
798
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
799
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
763
800
  }
764
- return new Promise((resolve, reject) => {
765
- localVarRequest(localVarRequestOptions, (error, response, body) => {
766
- if (error) {
767
- reject(error);
768
- }
769
- else {
770
- body = models_1.ObjectSerializer.deserialize(body, "DSPConfigResponse");
771
- if (typeof body.success === 'boolean' && !body.success) {
772
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
773
- reject(new Error(body.error || errString));
774
- }
775
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
776
- resolve(body);
777
- }
778
- else {
779
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
780
- reject(errString);
781
- }
782
- }
783
- });
784
- });
785
- });
801
+ }
802
+ const response = await fetch(url, requestOptions);
803
+ return this.handleResponse(response, 'DSPConfigResponse');
786
804
  }
787
805
  /**
788
806
  * Retrieve the feature importance for a DSP block (only available for blocks where dimensionalityReduction is not enabled)
@@ -795,9 +813,11 @@ class DSPApi {
795
813
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
796
814
  .replace('{' + 'dspId' + '}', encodeURIComponent(String(dspId)));
797
815
  let localVarQueryParameters = {};
798
- let localVarHeaderParams = Object.assign({
799
- 'User-Agent': 'edgeimpulse-api nodejs'
800
- }, this.defaultHeaders);
816
+ let localVarHeaderParams = {
817
+ 'User-Agent': 'edgeimpulse-api nodejs',
818
+ 'Content-Type': 'application/json',
819
+ ...this.defaultHeaders,
820
+ };
801
821
  const produces = ['application/json'];
802
822
  // give precedence to 'application/json'
803
823
  if (produces.indexOf('application/json') >= 0) {
@@ -806,7 +826,7 @@ class DSPApi {
806
826
  else {
807
827
  localVarHeaderParams.Accept = produces.join(',');
808
828
  }
809
- let localVarFormParams = {};
829
+ let localVarFormParams;
810
830
  // verify required parameter 'projectId' is not null or undefined
811
831
  if (projectId === null || projectId === undefined) {
812
832
  throw new Error('Required parameter projectId was null or undefined when calling getDspFeatureImportance.');
@@ -815,55 +835,51 @@ class DSPApi {
815
835
  if (dspId === null || dspId === undefined) {
816
836
  throw new Error('Required parameter dspId was null or undefined when calling getDspFeatureImportance.');
817
837
  }
818
- Object.assign(localVarHeaderParams, options.headers);
819
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
820
- let localVarUseFormData = false;
838
+ localVarHeaderParams = {
839
+ ...localVarHeaderParams,
840
+ ...options.headers,
841
+ ...this.opts.extraHeaders,
842
+ };
843
+ const queryString = Object.entries(localVarQueryParameters)
844
+ .filter(([, value]) => value !== undefined)
845
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
846
+ .join('&');
847
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
821
848
  let localVarRequestOptions = {
822
849
  method: 'GET',
823
- qs: localVarQueryParameters,
824
- headers: localVarHeaderParams,
825
- uri: localVarPath,
826
- useQuerystring: this._useQuerystring,
827
- agentOptions: { keepAlive: false },
828
- json: true,
850
+ headers: { ...localVarHeaderParams },
829
851
  };
830
- let authenticationPromise = Promise.resolve();
831
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
832
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
833
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
834
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
835
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
836
- return authenticationPromise.then(() => {
837
- if (Object.keys(localVarFormParams).length) {
838
- if (localVarUseFormData) {
839
- localVarRequestOptions.formData = localVarFormParams;
840
- }
841
- else {
842
- localVarRequestOptions.form = localVarFormParams;
843
- }
852
+ let requestOptions = localVarRequestOptions;
853
+ let url = localVarUrl;
854
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
855
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
856
+ url = auth_ApiKeyAuthentication.url;
857
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
858
+ requestOptions = auth_JWTAuthentication.requestOptions;
859
+ url = auth_JWTAuthentication.url;
860
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
861
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
862
+ url = auth_JWTHttpHeaderAuthentication.url;
863
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
864
+ requestOptions = auth_OAuth2.requestOptions;
865
+ url = auth_OAuth2.url;
866
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
867
+ requestOptions = authDefault.requestOptions;
868
+ url = authDefault.url;
869
+ if (localVarFormParams) {
870
+ delete requestOptions.headers['Content-Type'];
871
+ if (localVarFormParams instanceof FormData) {
872
+ // FormData: fetch will handle Content-Type automatically.
873
+ requestOptions.body = localVarFormParams;
874
+ }
875
+ else if (Object.keys(localVarFormParams).length > 0) {
876
+ // URL-encoded form
877
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
878
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
844
879
  }
845
- return new Promise((resolve, reject) => {
846
- localVarRequest(localVarRequestOptions, (error, response, body) => {
847
- if (error) {
848
- reject(error);
849
- }
850
- else {
851
- body = models_1.ObjectSerializer.deserialize(body, "DspFeatureImportanceResponse");
852
- if (typeof body.success === 'boolean' && !body.success) {
853
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
854
- reject(new Error(body.error || errString));
855
- }
856
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
857
- resolve(body);
858
- }
859
- else {
860
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
861
- reject(errString);
862
- }
863
- }
864
- });
865
- });
866
- });
880
+ }
881
+ const response = await fetch(url, requestOptions);
882
+ return this.handleResponse(response, 'DspFeatureImportanceResponse');
867
883
  }
868
884
  /**
869
885
  * Retrieve the names of the features the DSP block generates
@@ -876,9 +892,11 @@ class DSPApi {
876
892
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
877
893
  .replace('{' + 'dspId' + '}', encodeURIComponent(String(dspId)));
878
894
  let localVarQueryParameters = {};
879
- let localVarHeaderParams = Object.assign({
880
- 'User-Agent': 'edgeimpulse-api nodejs'
881
- }, this.defaultHeaders);
895
+ let localVarHeaderParams = {
896
+ 'User-Agent': 'edgeimpulse-api nodejs',
897
+ 'Content-Type': 'application/json',
898
+ ...this.defaultHeaders,
899
+ };
882
900
  const produces = ['application/json'];
883
901
  // give precedence to 'application/json'
884
902
  if (produces.indexOf('application/json') >= 0) {
@@ -887,7 +905,7 @@ class DSPApi {
887
905
  else {
888
906
  localVarHeaderParams.Accept = produces.join(',');
889
907
  }
890
- let localVarFormParams = {};
908
+ let localVarFormParams;
891
909
  // verify required parameter 'projectId' is not null or undefined
892
910
  if (projectId === null || projectId === undefined) {
893
911
  throw new Error('Required parameter projectId was null or undefined when calling getDspFeatureLabels.');
@@ -896,55 +914,51 @@ class DSPApi {
896
914
  if (dspId === null || dspId === undefined) {
897
915
  throw new Error('Required parameter dspId was null or undefined when calling getDspFeatureLabels.');
898
916
  }
899
- Object.assign(localVarHeaderParams, options.headers);
900
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
901
- let localVarUseFormData = false;
917
+ localVarHeaderParams = {
918
+ ...localVarHeaderParams,
919
+ ...options.headers,
920
+ ...this.opts.extraHeaders,
921
+ };
922
+ const queryString = Object.entries(localVarQueryParameters)
923
+ .filter(([, value]) => value !== undefined)
924
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
925
+ .join('&');
926
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
902
927
  let localVarRequestOptions = {
903
928
  method: 'GET',
904
- qs: localVarQueryParameters,
905
- headers: localVarHeaderParams,
906
- uri: localVarPath,
907
- useQuerystring: this._useQuerystring,
908
- agentOptions: { keepAlive: false },
909
- json: true,
929
+ headers: { ...localVarHeaderParams },
910
930
  };
911
- let authenticationPromise = Promise.resolve();
912
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
913
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
914
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
915
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
916
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
917
- return authenticationPromise.then(() => {
918
- if (Object.keys(localVarFormParams).length) {
919
- if (localVarUseFormData) {
920
- localVarRequestOptions.formData = localVarFormParams;
921
- }
922
- else {
923
- localVarRequestOptions.form = localVarFormParams;
924
- }
931
+ let requestOptions = localVarRequestOptions;
932
+ let url = localVarUrl;
933
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
934
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
935
+ url = auth_ApiKeyAuthentication.url;
936
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
937
+ requestOptions = auth_JWTAuthentication.requestOptions;
938
+ url = auth_JWTAuthentication.url;
939
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
940
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
941
+ url = auth_JWTHttpHeaderAuthentication.url;
942
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
943
+ requestOptions = auth_OAuth2.requestOptions;
944
+ url = auth_OAuth2.url;
945
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
946
+ requestOptions = authDefault.requestOptions;
947
+ url = authDefault.url;
948
+ if (localVarFormParams) {
949
+ delete requestOptions.headers['Content-Type'];
950
+ if (localVarFormParams instanceof FormData) {
951
+ // FormData: fetch will handle Content-Type automatically.
952
+ requestOptions.body = localVarFormParams;
953
+ }
954
+ else if (Object.keys(localVarFormParams).length > 0) {
955
+ // URL-encoded form
956
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
957
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
925
958
  }
926
- return new Promise((resolve, reject) => {
927
- localVarRequest(localVarRequestOptions, (error, response, body) => {
928
- if (error) {
929
- reject(error);
930
- }
931
- else {
932
- body = models_1.ObjectSerializer.deserialize(body, "DspFeatureLabelsResponse");
933
- if (typeof body.success === 'boolean' && !body.success) {
934
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
935
- reject(new Error(body.error || errString));
936
- }
937
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
938
- resolve(body);
939
- }
940
- else {
941
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
942
- reject(errString);
943
- }
944
- }
945
- });
946
- });
947
- });
959
+ }
960
+ const response = await fetch(url, requestOptions);
961
+ return this.handleResponse(response, 'DspFeatureLabelsResponse');
948
962
  }
949
963
  /**
950
964
  * Retrieve the metadata from a generated DSP block.
@@ -959,9 +973,11 @@ class DSPApi {
959
973
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
960
974
  .replace('{' + 'dspId' + '}', encodeURIComponent(String(dspId)));
961
975
  let localVarQueryParameters = {};
962
- let localVarHeaderParams = Object.assign({
963
- 'User-Agent': 'edgeimpulse-api nodejs'
964
- }, this.defaultHeaders);
976
+ let localVarHeaderParams = {
977
+ 'User-Agent': 'edgeimpulse-api nodejs',
978
+ 'Content-Type': 'application/json',
979
+ ...this.defaultHeaders,
980
+ };
965
981
  const produces = ['application/json'];
966
982
  // give precedence to 'application/json'
967
983
  if (produces.indexOf('application/json') >= 0) {
@@ -970,7 +986,7 @@ class DSPApi {
970
986
  else {
971
987
  localVarHeaderParams.Accept = produces.join(',');
972
988
  }
973
- let localVarFormParams = {};
989
+ let localVarFormParams;
974
990
  // verify required parameter 'projectId' is not null or undefined
975
991
  if (projectId === null || projectId === undefined) {
976
992
  throw new Error('Required parameter projectId was null or undefined when calling getDspMetadata.');
@@ -985,55 +1001,51 @@ class DSPApi {
985
1001
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.category) !== undefined) {
986
1002
  localVarQueryParameters['category'] = models_1.ObjectSerializer.serialize(queryParams.category, "'training' | 'testing' | 'all'");
987
1003
  }
988
- Object.assign(localVarHeaderParams, options.headers);
989
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
990
- let localVarUseFormData = false;
1004
+ localVarHeaderParams = {
1005
+ ...localVarHeaderParams,
1006
+ ...options.headers,
1007
+ ...this.opts.extraHeaders,
1008
+ };
1009
+ const queryString = Object.entries(localVarQueryParameters)
1010
+ .filter(([, value]) => value !== undefined)
1011
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1012
+ .join('&');
1013
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
991
1014
  let localVarRequestOptions = {
992
1015
  method: 'GET',
993
- qs: localVarQueryParameters,
994
- headers: localVarHeaderParams,
995
- uri: localVarPath,
996
- useQuerystring: this._useQuerystring,
997
- agentOptions: { keepAlive: false },
998
- json: true,
1016
+ headers: { ...localVarHeaderParams },
999
1017
  };
1000
- let authenticationPromise = Promise.resolve();
1001
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1002
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1003
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1004
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1005
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1006
- return authenticationPromise.then(() => {
1007
- if (Object.keys(localVarFormParams).length) {
1008
- if (localVarUseFormData) {
1009
- localVarRequestOptions.formData = localVarFormParams;
1010
- }
1011
- else {
1012
- localVarRequestOptions.form = localVarFormParams;
1013
- }
1018
+ let requestOptions = localVarRequestOptions;
1019
+ let url = localVarUrl;
1020
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1021
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1022
+ url = auth_ApiKeyAuthentication.url;
1023
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1024
+ requestOptions = auth_JWTAuthentication.requestOptions;
1025
+ url = auth_JWTAuthentication.url;
1026
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1027
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1028
+ url = auth_JWTHttpHeaderAuthentication.url;
1029
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1030
+ requestOptions = auth_OAuth2.requestOptions;
1031
+ url = auth_OAuth2.url;
1032
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1033
+ requestOptions = authDefault.requestOptions;
1034
+ url = authDefault.url;
1035
+ if (localVarFormParams) {
1036
+ delete requestOptions.headers['Content-Type'];
1037
+ if (localVarFormParams instanceof FormData) {
1038
+ // FormData: fetch will handle Content-Type automatically.
1039
+ requestOptions.body = localVarFormParams;
1014
1040
  }
1015
- return new Promise((resolve, reject) => {
1016
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1017
- if (error) {
1018
- reject(error);
1019
- }
1020
- else {
1021
- body = models_1.ObjectSerializer.deserialize(body, "DSPMetadataResponse");
1022
- if (typeof body.success === 'boolean' && !body.success) {
1023
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1024
- reject(new Error(body.error || errString));
1025
- }
1026
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1027
- resolve(body);
1028
- }
1029
- else {
1030
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1031
- reject(errString);
1032
- }
1033
- }
1034
- });
1035
- });
1036
- });
1041
+ else if (Object.keys(localVarFormParams).length > 0) {
1042
+ // URL-encoded form
1043
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1044
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1045
+ }
1046
+ }
1047
+ const response = await fetch(url, requestOptions);
1048
+ return this.handleResponse(response, 'DSPMetadataResponse');
1037
1049
  }
1038
1050
  /**
1039
1051
  * Get raw sample data, but with only the axes selected by the DSP block. E.g. if you have selected only accX and accY as inputs for the DSP block, but the raw sample also contains accZ, accZ is filtered out. If you pass dspId = 0 this will return a raw graph without any processing.
@@ -1051,9 +1063,11 @@ class DSPApi {
1051
1063
  .replace('{' + 'dspId' + '}', encodeURIComponent(String(dspId)))
1052
1064
  .replace('{' + 'sampleId' + '}', encodeURIComponent(String(sampleId)));
1053
1065
  let localVarQueryParameters = {};
1054
- let localVarHeaderParams = Object.assign({
1055
- 'User-Agent': 'edgeimpulse-api nodejs'
1056
- }, this.defaultHeaders);
1066
+ let localVarHeaderParams = {
1067
+ 'User-Agent': 'edgeimpulse-api nodejs',
1068
+ 'Content-Type': 'application/json',
1069
+ ...this.defaultHeaders,
1070
+ };
1057
1071
  const produces = ['application/json'];
1058
1072
  // give precedence to 'application/json'
1059
1073
  if (produces.indexOf('application/json') >= 0) {
@@ -1062,7 +1076,7 @@ class DSPApi {
1062
1076
  else {
1063
1077
  localVarHeaderParams.Accept = produces.join(',');
1064
1078
  }
1065
- let localVarFormParams = {};
1079
+ let localVarFormParams;
1066
1080
  // verify required parameter 'projectId' is not null or undefined
1067
1081
  if (projectId === null || projectId === undefined) {
1068
1082
  throw new Error('Required parameter projectId was null or undefined when calling getDspRawSample.');
@@ -1084,55 +1098,51 @@ class DSPApi {
1084
1098
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.useCachedUpsampledData) !== undefined) {
1085
1099
  localVarQueryParameters['useCachedUpsampledData'] = models_1.ObjectSerializer.serialize(queryParams.useCachedUpsampledData, "boolean");
1086
1100
  }
1087
- Object.assign(localVarHeaderParams, options.headers);
1088
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1089
- let localVarUseFormData = false;
1101
+ localVarHeaderParams = {
1102
+ ...localVarHeaderParams,
1103
+ ...options.headers,
1104
+ ...this.opts.extraHeaders,
1105
+ };
1106
+ const queryString = Object.entries(localVarQueryParameters)
1107
+ .filter(([, value]) => value !== undefined)
1108
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1109
+ .join('&');
1110
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1090
1111
  let localVarRequestOptions = {
1091
1112
  method: 'GET',
1092
- qs: localVarQueryParameters,
1093
- headers: localVarHeaderParams,
1094
- uri: localVarPath,
1095
- useQuerystring: this._useQuerystring,
1096
- agentOptions: { keepAlive: false },
1097
- json: true,
1113
+ headers: { ...localVarHeaderParams },
1098
1114
  };
1099
- let authenticationPromise = Promise.resolve();
1100
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1101
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1102
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1103
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1104
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1105
- return authenticationPromise.then(() => {
1106
- if (Object.keys(localVarFormParams).length) {
1107
- if (localVarUseFormData) {
1108
- localVarRequestOptions.formData = localVarFormParams;
1109
- }
1110
- else {
1111
- localVarRequestOptions.form = localVarFormParams;
1112
- }
1115
+ let requestOptions = localVarRequestOptions;
1116
+ let url = localVarUrl;
1117
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1118
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1119
+ url = auth_ApiKeyAuthentication.url;
1120
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1121
+ requestOptions = auth_JWTAuthentication.requestOptions;
1122
+ url = auth_JWTAuthentication.url;
1123
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1124
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1125
+ url = auth_JWTHttpHeaderAuthentication.url;
1126
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1127
+ requestOptions = auth_OAuth2.requestOptions;
1128
+ url = auth_OAuth2.url;
1129
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1130
+ requestOptions = authDefault.requestOptions;
1131
+ url = authDefault.url;
1132
+ if (localVarFormParams) {
1133
+ delete requestOptions.headers['Content-Type'];
1134
+ if (localVarFormParams instanceof FormData) {
1135
+ // FormData: fetch will handle Content-Type automatically.
1136
+ requestOptions.body = localVarFormParams;
1137
+ }
1138
+ else if (Object.keys(localVarFormParams).length > 0) {
1139
+ // URL-encoded form
1140
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1141
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1113
1142
  }
1114
- return new Promise((resolve, reject) => {
1115
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1116
- if (error) {
1117
- reject(error);
1118
- }
1119
- else {
1120
- body = models_1.ObjectSerializer.deserialize(body, "GetSampleResponse");
1121
- if (typeof body.success === 'boolean' && !body.success) {
1122
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1123
- reject(new Error(body.error || errString));
1124
- }
1125
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1126
- resolve(body);
1127
- }
1128
- else {
1129
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1130
- reject(errString);
1131
- }
1132
- }
1133
- });
1134
- });
1135
- });
1143
+ }
1144
+ const response = await fetch(url, requestOptions);
1145
+ return this.handleResponse(response, 'GetSampleResponse');
1136
1146
  }
1137
1147
  /**
1138
1148
  * Get slice of raw sample data, but with only the axes selected by the DSP block. E.g. if you have selected only accX and accY as inputs for the DSP block, but the raw sample also contains accZ, accZ is filtered out.
@@ -1150,9 +1160,11 @@ class DSPApi {
1150
1160
  .replace('{' + 'dspId' + '}', encodeURIComponent(String(dspId)))
1151
1161
  .replace('{' + 'sampleId' + '}', encodeURIComponent(String(sampleId)));
1152
1162
  let localVarQueryParameters = {};
1153
- let localVarHeaderParams = Object.assign({
1154
- 'User-Agent': 'edgeimpulse-api nodejs'
1155
- }, this.defaultHeaders);
1163
+ let localVarHeaderParams = {
1164
+ 'User-Agent': 'edgeimpulse-api nodejs',
1165
+ 'Content-Type': 'application/json',
1166
+ ...this.defaultHeaders,
1167
+ };
1156
1168
  const produces = ['application/json'];
1157
1169
  // give precedence to 'application/json'
1158
1170
  if (produces.indexOf('application/json') >= 0) {
@@ -1161,7 +1173,7 @@ class DSPApi {
1161
1173
  else {
1162
1174
  localVarHeaderParams.Accept = produces.join(',');
1163
1175
  }
1164
- let localVarFormParams = {};
1176
+ let localVarFormParams;
1165
1177
  // verify required parameter 'projectId' is not null or undefined
1166
1178
  if (projectId === null || projectId === undefined) {
1167
1179
  throw new Error('Required parameter projectId was null or undefined when calling getDspSampleSlice.');
@@ -1187,55 +1199,51 @@ class DSPApi {
1187
1199
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.truncateStructuredLabels) !== undefined) {
1188
1200
  localVarQueryParameters['truncateStructuredLabels'] = models_1.ObjectSerializer.serialize(queryParams.truncateStructuredLabels, "boolean");
1189
1201
  }
1190
- Object.assign(localVarHeaderParams, options.headers);
1191
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1192
- let localVarUseFormData = false;
1202
+ localVarHeaderParams = {
1203
+ ...localVarHeaderParams,
1204
+ ...options.headers,
1205
+ ...this.opts.extraHeaders,
1206
+ };
1207
+ const queryString = Object.entries(localVarQueryParameters)
1208
+ .filter(([, value]) => value !== undefined)
1209
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1210
+ .join('&');
1211
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1193
1212
  let localVarRequestOptions = {
1194
1213
  method: 'GET',
1195
- qs: localVarQueryParameters,
1196
- headers: localVarHeaderParams,
1197
- uri: localVarPath,
1198
- useQuerystring: this._useQuerystring,
1199
- agentOptions: { keepAlive: false },
1200
- json: true,
1214
+ headers: { ...localVarHeaderParams },
1201
1215
  };
1202
- let authenticationPromise = Promise.resolve();
1203
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1204
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1205
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1206
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1207
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1208
- return authenticationPromise.then(() => {
1209
- if (Object.keys(localVarFormParams).length) {
1210
- if (localVarUseFormData) {
1211
- localVarRequestOptions.formData = localVarFormParams;
1212
- }
1213
- else {
1214
- localVarRequestOptions.form = localVarFormParams;
1215
- }
1216
+ let requestOptions = localVarRequestOptions;
1217
+ let url = localVarUrl;
1218
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1219
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1220
+ url = auth_ApiKeyAuthentication.url;
1221
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1222
+ requestOptions = auth_JWTAuthentication.requestOptions;
1223
+ url = auth_JWTAuthentication.url;
1224
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1225
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1226
+ url = auth_JWTHttpHeaderAuthentication.url;
1227
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1228
+ requestOptions = auth_OAuth2.requestOptions;
1229
+ url = auth_OAuth2.url;
1230
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1231
+ requestOptions = authDefault.requestOptions;
1232
+ url = authDefault.url;
1233
+ if (localVarFormParams) {
1234
+ delete requestOptions.headers['Content-Type'];
1235
+ if (localVarFormParams instanceof FormData) {
1236
+ // FormData: fetch will handle Content-Type automatically.
1237
+ requestOptions.body = localVarFormParams;
1216
1238
  }
1217
- return new Promise((resolve, reject) => {
1218
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1219
- if (error) {
1220
- reject(error);
1221
- }
1222
- else {
1223
- body = models_1.ObjectSerializer.deserialize(body, "GetSampleResponse");
1224
- if (typeof body.success === 'boolean' && !body.success) {
1225
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1226
- reject(new Error(body.error || errString));
1227
- }
1228
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1229
- resolve(body);
1230
- }
1231
- else {
1232
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1233
- reject(errString);
1234
- }
1235
- }
1236
- });
1237
- });
1238
- });
1239
+ else if (Object.keys(localVarFormParams).length > 0) {
1240
+ // URL-encoded form
1241
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1242
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1243
+ }
1244
+ }
1245
+ const response = await fetch(url, requestOptions);
1246
+ return this.handleResponse(response, 'GetSampleResponse');
1239
1247
  }
1240
1248
  /**
1241
1249
  * Get estimated performance (latency and RAM) for the DSP block, for all supported project latency devices.
@@ -1248,9 +1256,11 @@ class DSPApi {
1248
1256
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
1249
1257
  .replace('{' + 'dspId' + '}', encodeURIComponent(String(dspId)));
1250
1258
  let localVarQueryParameters = {};
1251
- let localVarHeaderParams = Object.assign({
1252
- 'User-Agent': 'edgeimpulse-api nodejs'
1253
- }, this.defaultHeaders);
1259
+ let localVarHeaderParams = {
1260
+ 'User-Agent': 'edgeimpulse-api nodejs',
1261
+ 'Content-Type': 'application/json',
1262
+ ...this.defaultHeaders,
1263
+ };
1254
1264
  const produces = ['application/json'];
1255
1265
  // give precedence to 'application/json'
1256
1266
  if (produces.indexOf('application/json') >= 0) {
@@ -1259,7 +1269,7 @@ class DSPApi {
1259
1269
  else {
1260
1270
  localVarHeaderParams.Accept = produces.join(',');
1261
1271
  }
1262
- let localVarFormParams = {};
1272
+ let localVarFormParams;
1263
1273
  // verify required parameter 'projectId' is not null or undefined
1264
1274
  if (projectId === null || projectId === undefined) {
1265
1275
  throw new Error('Required parameter projectId was null or undefined when calling getPerformanceAllVariants.');
@@ -1268,55 +1278,51 @@ class DSPApi {
1268
1278
  if (dspId === null || dspId === undefined) {
1269
1279
  throw new Error('Required parameter dspId was null or undefined when calling getPerformanceAllVariants.');
1270
1280
  }
1271
- Object.assign(localVarHeaderParams, options.headers);
1272
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1273
- let localVarUseFormData = false;
1281
+ localVarHeaderParams = {
1282
+ ...localVarHeaderParams,
1283
+ ...options.headers,
1284
+ ...this.opts.extraHeaders,
1285
+ };
1286
+ const queryString = Object.entries(localVarQueryParameters)
1287
+ .filter(([, value]) => value !== undefined)
1288
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1289
+ .join('&');
1290
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1274
1291
  let localVarRequestOptions = {
1275
1292
  method: 'GET',
1276
- qs: localVarQueryParameters,
1277
- headers: localVarHeaderParams,
1278
- uri: localVarPath,
1279
- useQuerystring: this._useQuerystring,
1280
- agentOptions: { keepAlive: false },
1281
- json: true,
1293
+ headers: { ...localVarHeaderParams },
1282
1294
  };
1283
- let authenticationPromise = Promise.resolve();
1284
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1285
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1286
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1287
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1288
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1289
- return authenticationPromise.then(() => {
1290
- if (Object.keys(localVarFormParams).length) {
1291
- if (localVarUseFormData) {
1292
- localVarRequestOptions.formData = localVarFormParams;
1293
- }
1294
- else {
1295
- localVarRequestOptions.form = localVarFormParams;
1296
- }
1295
+ let requestOptions = localVarRequestOptions;
1296
+ let url = localVarUrl;
1297
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1298
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1299
+ url = auth_ApiKeyAuthentication.url;
1300
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1301
+ requestOptions = auth_JWTAuthentication.requestOptions;
1302
+ url = auth_JWTAuthentication.url;
1303
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1304
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1305
+ url = auth_JWTHttpHeaderAuthentication.url;
1306
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1307
+ requestOptions = auth_OAuth2.requestOptions;
1308
+ url = auth_OAuth2.url;
1309
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1310
+ requestOptions = authDefault.requestOptions;
1311
+ url = authDefault.url;
1312
+ if (localVarFormParams) {
1313
+ delete requestOptions.headers['Content-Type'];
1314
+ if (localVarFormParams instanceof FormData) {
1315
+ // FormData: fetch will handle Content-Type automatically.
1316
+ requestOptions.body = localVarFormParams;
1317
+ }
1318
+ else if (Object.keys(localVarFormParams).length > 0) {
1319
+ // URL-encoded form
1320
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1321
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1297
1322
  }
1298
- return new Promise((resolve, reject) => {
1299
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1300
- if (error) {
1301
- reject(error);
1302
- }
1303
- else {
1304
- body = models_1.ObjectSerializer.deserialize(body, "DspPerformanceAllVariantsResponse");
1305
- if (typeof body.success === 'boolean' && !body.success) {
1306
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1307
- reject(new Error(body.error || errString));
1308
- }
1309
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1310
- resolve(body);
1311
- }
1312
- else {
1313
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1314
- reject(errString);
1315
- }
1316
- }
1317
- });
1318
- });
1319
- });
1323
+ }
1324
+ const response = await fetch(url, requestOptions);
1325
+ return this.handleResponse(response, 'DspPerformanceAllVariantsResponse');
1320
1326
  }
1321
1327
  /**
1322
1328
  * Takes in a features array and runs it through the DSP block. This data should have the same frequency as set in the input block in your impulse.
@@ -1330,9 +1336,11 @@ class DSPApi {
1330
1336
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
1331
1337
  .replace('{' + 'dspId' + '}', encodeURIComponent(String(dspId)));
1332
1338
  let localVarQueryParameters = {};
1333
- let localVarHeaderParams = Object.assign({
1334
- 'User-Agent': 'edgeimpulse-api nodejs'
1335
- }, this.defaultHeaders);
1339
+ let localVarHeaderParams = {
1340
+ 'User-Agent': 'edgeimpulse-api nodejs',
1341
+ 'Content-Type': 'application/json',
1342
+ ...this.defaultHeaders,
1343
+ };
1336
1344
  const produces = ['application/json'];
1337
1345
  // give precedence to 'application/json'
1338
1346
  if (produces.indexOf('application/json') >= 0) {
@@ -1341,7 +1349,7 @@ class DSPApi {
1341
1349
  else {
1342
1350
  localVarHeaderParams.Accept = produces.join(',');
1343
1351
  }
1344
- let localVarFormParams = {};
1352
+ let localVarFormParams;
1345
1353
  // verify required parameter 'projectId' is not null or undefined
1346
1354
  if (projectId === null || projectId === undefined) {
1347
1355
  throw new Error('Required parameter projectId was null or undefined when calling runDspOnFeaturesArray.');
@@ -1354,56 +1362,52 @@ class DSPApi {
1354
1362
  if (dspRunRequestWithFeatures === null || dspRunRequestWithFeatures === undefined) {
1355
1363
  throw new Error('Required parameter dspRunRequestWithFeatures was null or undefined when calling runDspOnFeaturesArray.');
1356
1364
  }
1357
- Object.assign(localVarHeaderParams, options.headers);
1358
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1359
- let localVarUseFormData = false;
1365
+ localVarHeaderParams = {
1366
+ ...localVarHeaderParams,
1367
+ ...options.headers,
1368
+ ...this.opts.extraHeaders,
1369
+ };
1370
+ const queryString = Object.entries(localVarQueryParameters)
1371
+ .filter(([, value]) => value !== undefined)
1372
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1373
+ .join('&');
1374
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1360
1375
  let localVarRequestOptions = {
1361
1376
  method: 'POST',
1362
- qs: localVarQueryParameters,
1363
- headers: localVarHeaderParams,
1364
- uri: localVarPath,
1365
- useQuerystring: this._useQuerystring,
1366
- agentOptions: { keepAlive: false },
1367
- json: true,
1368
- body: models_1.ObjectSerializer.serialize(dspRunRequestWithFeatures, "DspRunRequestWithFeatures")
1377
+ headers: { ...localVarHeaderParams },
1369
1378
  };
1370
- let authenticationPromise = Promise.resolve();
1371
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1372
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1373
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1374
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1375
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1376
- return authenticationPromise.then(() => {
1377
- if (Object.keys(localVarFormParams).length) {
1378
- if (localVarUseFormData) {
1379
- localVarRequestOptions.formData = localVarFormParams;
1380
- }
1381
- else {
1382
- localVarRequestOptions.form = localVarFormParams;
1383
- }
1379
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(dspRunRequestWithFeatures, "DspRunRequestWithFeatures"));
1380
+ let requestOptions = localVarRequestOptions;
1381
+ let url = localVarUrl;
1382
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1383
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1384
+ url = auth_ApiKeyAuthentication.url;
1385
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1386
+ requestOptions = auth_JWTAuthentication.requestOptions;
1387
+ url = auth_JWTAuthentication.url;
1388
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1389
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1390
+ url = auth_JWTHttpHeaderAuthentication.url;
1391
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1392
+ requestOptions = auth_OAuth2.requestOptions;
1393
+ url = auth_OAuth2.url;
1394
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1395
+ requestOptions = authDefault.requestOptions;
1396
+ url = authDefault.url;
1397
+ if (localVarFormParams) {
1398
+ delete requestOptions.headers['Content-Type'];
1399
+ if (localVarFormParams instanceof FormData) {
1400
+ // FormData: fetch will handle Content-Type automatically.
1401
+ requestOptions.body = localVarFormParams;
1384
1402
  }
1385
- return new Promise((resolve, reject) => {
1386
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1387
- if (error) {
1388
- reject(error);
1389
- }
1390
- else {
1391
- body = models_1.ObjectSerializer.deserialize(body, "DspRunResponse");
1392
- if (typeof body.success === 'boolean' && !body.success) {
1393
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1394
- reject(new Error(body.error || errString));
1395
- }
1396
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1397
- resolve(body);
1398
- }
1399
- else {
1400
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1401
- reject(errString);
1402
- }
1403
- }
1404
- });
1405
- });
1406
- });
1403
+ else if (Object.keys(localVarFormParams).length > 0) {
1404
+ // URL-encoded form
1405
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1406
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1407
+ }
1408
+ }
1409
+ const response = await fetch(url, requestOptions);
1410
+ return this.handleResponse(response, 'DspRunResponse');
1407
1411
  }
1408
1412
  /**
1409
1413
  * Get slice of sample data, and run it through the DSP block. This only the axes selected by the DSP block. E.g. if you have selected only accX and accY as inputs for the DSP block, but the raw sample also contains accZ, accZ is filtered out.
@@ -1421,9 +1425,11 @@ class DSPApi {
1421
1425
  .replace('{' + 'dspId' + '}', encodeURIComponent(String(dspId)))
1422
1426
  .replace('{' + 'sampleId' + '}', encodeURIComponent(String(sampleId)));
1423
1427
  let localVarQueryParameters = {};
1424
- let localVarHeaderParams = Object.assign({
1425
- 'User-Agent': 'edgeimpulse-api nodejs'
1426
- }, this.defaultHeaders);
1428
+ let localVarHeaderParams = {
1429
+ 'User-Agent': 'edgeimpulse-api nodejs',
1430
+ 'Content-Type': 'application/json',
1431
+ ...this.defaultHeaders,
1432
+ };
1427
1433
  const produces = ['application/json'];
1428
1434
  // give precedence to 'application/json'
1429
1435
  if (produces.indexOf('application/json') >= 0) {
@@ -1432,7 +1438,7 @@ class DSPApi {
1432
1438
  else {
1433
1439
  localVarHeaderParams.Accept = produces.join(',');
1434
1440
  }
1435
- let localVarFormParams = {};
1441
+ let localVarFormParams;
1436
1442
  // verify required parameter 'projectId' is not null or undefined
1437
1443
  if (projectId === null || projectId === undefined) {
1438
1444
  throw new Error('Required parameter projectId was null or undefined when calling runDspSampleSlice.');
@@ -1459,56 +1465,52 @@ class DSPApi {
1459
1465
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.sliceEnd) !== undefined) {
1460
1466
  localVarQueryParameters['sliceEnd'] = models_1.ObjectSerializer.serialize(queryParams.sliceEnd, "number");
1461
1467
  }
1462
- Object.assign(localVarHeaderParams, options.headers);
1463
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1464
- let localVarUseFormData = false;
1468
+ localVarHeaderParams = {
1469
+ ...localVarHeaderParams,
1470
+ ...options.headers,
1471
+ ...this.opts.extraHeaders,
1472
+ };
1473
+ const queryString = Object.entries(localVarQueryParameters)
1474
+ .filter(([, value]) => value !== undefined)
1475
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1476
+ .join('&');
1477
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1465
1478
  let localVarRequestOptions = {
1466
1479
  method: 'POST',
1467
- qs: localVarQueryParameters,
1468
- headers: localVarHeaderParams,
1469
- uri: localVarPath,
1470
- useQuerystring: this._useQuerystring,
1471
- agentOptions: { keepAlive: false },
1472
- json: true,
1473
- body: models_1.ObjectSerializer.serialize(dspRunRequestWithoutFeatures, "DspRunRequestWithoutFeatures")
1480
+ headers: { ...localVarHeaderParams },
1474
1481
  };
1475
- let authenticationPromise = Promise.resolve();
1476
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1477
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1478
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1479
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1480
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1481
- return authenticationPromise.then(() => {
1482
- if (Object.keys(localVarFormParams).length) {
1483
- if (localVarUseFormData) {
1484
- localVarRequestOptions.formData = localVarFormParams;
1485
- }
1486
- else {
1487
- localVarRequestOptions.form = localVarFormParams;
1488
- }
1482
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(dspRunRequestWithoutFeatures, "DspRunRequestWithoutFeatures"));
1483
+ let requestOptions = localVarRequestOptions;
1484
+ let url = localVarUrl;
1485
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1486
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1487
+ url = auth_ApiKeyAuthentication.url;
1488
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1489
+ requestOptions = auth_JWTAuthentication.requestOptions;
1490
+ url = auth_JWTAuthentication.url;
1491
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1492
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1493
+ url = auth_JWTHttpHeaderAuthentication.url;
1494
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1495
+ requestOptions = auth_OAuth2.requestOptions;
1496
+ url = auth_OAuth2.url;
1497
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1498
+ requestOptions = authDefault.requestOptions;
1499
+ url = authDefault.url;
1500
+ if (localVarFormParams) {
1501
+ delete requestOptions.headers['Content-Type'];
1502
+ if (localVarFormParams instanceof FormData) {
1503
+ // FormData: fetch will handle Content-Type automatically.
1504
+ requestOptions.body = localVarFormParams;
1505
+ }
1506
+ else if (Object.keys(localVarFormParams).length > 0) {
1507
+ // URL-encoded form
1508
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1509
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1489
1510
  }
1490
- return new Promise((resolve, reject) => {
1491
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1492
- if (error) {
1493
- reject(error);
1494
- }
1495
- else {
1496
- body = models_1.ObjectSerializer.deserialize(body, "DspRunResponseWithSample");
1497
- if (typeof body.success === 'boolean' && !body.success) {
1498
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1499
- reject(new Error(body.error || errString));
1500
- }
1501
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1502
- resolve(body);
1503
- }
1504
- else {
1505
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1506
- reject(errString);
1507
- }
1508
- }
1509
- });
1510
- });
1511
- });
1511
+ }
1512
+ const response = await fetch(url, requestOptions);
1513
+ return this.handleResponse(response, 'DspRunResponseWithSample');
1512
1514
  }
1513
1515
  /**
1514
1516
  * Get slice of sample data, and run it through the DSP block. This only the axes selected by the DSP block. E.g. if you have selected only accX and accY as inputs for the DSP block, but the raw sample also contains accZ, accZ is filtered out.
@@ -1525,9 +1527,11 @@ class DSPApi {
1525
1527
  .replace('{' + 'dspId' + '}', encodeURIComponent(String(dspId)))
1526
1528
  .replace('{' + 'sampleId' + '}', encodeURIComponent(String(sampleId)));
1527
1529
  let localVarQueryParameters = {};
1528
- let localVarHeaderParams = Object.assign({
1529
- 'User-Agent': 'edgeimpulse-api nodejs'
1530
- }, this.defaultHeaders);
1530
+ let localVarHeaderParams = {
1531
+ 'User-Agent': 'edgeimpulse-api nodejs',
1532
+ 'Content-Type': 'application/json',
1533
+ ...this.defaultHeaders,
1534
+ };
1531
1535
  const produces = ['application/json'];
1532
1536
  // give precedence to 'application/json'
1533
1537
  if (produces.indexOf('application/json') >= 0) {
@@ -1536,7 +1540,7 @@ class DSPApi {
1536
1540
  else {
1537
1541
  localVarHeaderParams.Accept = produces.join(',');
1538
1542
  }
1539
- let localVarFormParams = {};
1543
+ let localVarFormParams;
1540
1544
  // verify required parameter 'projectId' is not null or undefined
1541
1545
  if (projectId === null || projectId === undefined) {
1542
1546
  throw new Error('Required parameter projectId was null or undefined when calling runDspSampleSliceReadOnly.');
@@ -1559,55 +1563,51 @@ class DSPApi {
1559
1563
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.sliceEnd) !== undefined) {
1560
1564
  localVarQueryParameters['sliceEnd'] = models_1.ObjectSerializer.serialize(queryParams.sliceEnd, "number");
1561
1565
  }
1562
- Object.assign(localVarHeaderParams, options.headers);
1563
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1564
- let localVarUseFormData = false;
1566
+ localVarHeaderParams = {
1567
+ ...localVarHeaderParams,
1568
+ ...options.headers,
1569
+ ...this.opts.extraHeaders,
1570
+ };
1571
+ const queryString = Object.entries(localVarQueryParameters)
1572
+ .filter(([, value]) => value !== undefined)
1573
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1574
+ .join('&');
1575
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1565
1576
  let localVarRequestOptions = {
1566
1577
  method: 'GET',
1567
- qs: localVarQueryParameters,
1568
- headers: localVarHeaderParams,
1569
- uri: localVarPath,
1570
- useQuerystring: this._useQuerystring,
1571
- agentOptions: { keepAlive: false },
1572
- json: true,
1578
+ headers: { ...localVarHeaderParams },
1573
1579
  };
1574
- let authenticationPromise = Promise.resolve();
1575
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1576
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1577
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1578
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1579
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1580
- return authenticationPromise.then(() => {
1581
- if (Object.keys(localVarFormParams).length) {
1582
- if (localVarUseFormData) {
1583
- localVarRequestOptions.formData = localVarFormParams;
1584
- }
1585
- else {
1586
- localVarRequestOptions.form = localVarFormParams;
1587
- }
1580
+ let requestOptions = localVarRequestOptions;
1581
+ let url = localVarUrl;
1582
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1583
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1584
+ url = auth_ApiKeyAuthentication.url;
1585
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1586
+ requestOptions = auth_JWTAuthentication.requestOptions;
1587
+ url = auth_JWTAuthentication.url;
1588
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1589
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1590
+ url = auth_JWTHttpHeaderAuthentication.url;
1591
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1592
+ requestOptions = auth_OAuth2.requestOptions;
1593
+ url = auth_OAuth2.url;
1594
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1595
+ requestOptions = authDefault.requestOptions;
1596
+ url = authDefault.url;
1597
+ if (localVarFormParams) {
1598
+ delete requestOptions.headers['Content-Type'];
1599
+ if (localVarFormParams instanceof FormData) {
1600
+ // FormData: fetch will handle Content-Type automatically.
1601
+ requestOptions.body = localVarFormParams;
1588
1602
  }
1589
- return new Promise((resolve, reject) => {
1590
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1591
- if (error) {
1592
- reject(error);
1593
- }
1594
- else {
1595
- body = models_1.ObjectSerializer.deserialize(body, "DspRunResponseWithSample");
1596
- if (typeof body.success === 'boolean' && !body.success) {
1597
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1598
- reject(new Error(body.error || errString));
1599
- }
1600
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1601
- resolve(body);
1602
- }
1603
- else {
1604
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1605
- reject(errString);
1606
- }
1607
- }
1608
- });
1609
- });
1610
- });
1603
+ else if (Object.keys(localVarFormParams).length > 0) {
1604
+ // URL-encoded form
1605
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1606
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1607
+ }
1608
+ }
1609
+ const response = await fetch(url, requestOptions);
1610
+ return this.handleResponse(response, 'DspRunResponseWithSample');
1611
1611
  }
1612
1612
  /**
1613
1613
  * Set configuration parameters for the DSP block. Only values set in the body will be overwritten.
@@ -1621,9 +1621,11 @@ class DSPApi {
1621
1621
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
1622
1622
  .replace('{' + 'dspId' + '}', encodeURIComponent(String(dspId)));
1623
1623
  let localVarQueryParameters = {};
1624
- let localVarHeaderParams = Object.assign({
1625
- 'User-Agent': 'edgeimpulse-api nodejs'
1626
- }, this.defaultHeaders);
1624
+ let localVarHeaderParams = {
1625
+ 'User-Agent': 'edgeimpulse-api nodejs',
1626
+ 'Content-Type': 'application/json',
1627
+ ...this.defaultHeaders,
1628
+ };
1627
1629
  const produces = ['application/json'];
1628
1630
  // give precedence to 'application/json'
1629
1631
  if (produces.indexOf('application/json') >= 0) {
@@ -1632,7 +1634,7 @@ class DSPApi {
1632
1634
  else {
1633
1635
  localVarHeaderParams.Accept = produces.join(',');
1634
1636
  }
1635
- let localVarFormParams = {};
1637
+ let localVarFormParams;
1636
1638
  // verify required parameter 'projectId' is not null or undefined
1637
1639
  if (projectId === null || projectId === undefined) {
1638
1640
  throw new Error('Required parameter projectId was null or undefined when calling setDspConfig.');
@@ -1645,56 +1647,52 @@ class DSPApi {
1645
1647
  if (dSPConfigRequest === null || dSPConfigRequest === undefined) {
1646
1648
  throw new Error('Required parameter dSPConfigRequest was null or undefined when calling setDspConfig.');
1647
1649
  }
1648
- Object.assign(localVarHeaderParams, options.headers);
1649
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1650
- let localVarUseFormData = false;
1650
+ localVarHeaderParams = {
1651
+ ...localVarHeaderParams,
1652
+ ...options.headers,
1653
+ ...this.opts.extraHeaders,
1654
+ };
1655
+ const queryString = Object.entries(localVarQueryParameters)
1656
+ .filter(([, value]) => value !== undefined)
1657
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1658
+ .join('&');
1659
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1651
1660
  let localVarRequestOptions = {
1652
1661
  method: 'POST',
1653
- qs: localVarQueryParameters,
1654
- headers: localVarHeaderParams,
1655
- uri: localVarPath,
1656
- useQuerystring: this._useQuerystring,
1657
- agentOptions: { keepAlive: false },
1658
- json: true,
1659
- body: models_1.ObjectSerializer.serialize(dSPConfigRequest, "DSPConfigRequest")
1662
+ headers: { ...localVarHeaderParams },
1660
1663
  };
1661
- let authenticationPromise = Promise.resolve();
1662
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1663
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1664
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1665
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1666
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1667
- return authenticationPromise.then(() => {
1668
- if (Object.keys(localVarFormParams).length) {
1669
- if (localVarUseFormData) {
1670
- localVarRequestOptions.formData = localVarFormParams;
1671
- }
1672
- else {
1673
- localVarRequestOptions.form = localVarFormParams;
1674
- }
1664
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(dSPConfigRequest, "DSPConfigRequest"));
1665
+ let requestOptions = localVarRequestOptions;
1666
+ let url = localVarUrl;
1667
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1668
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1669
+ url = auth_ApiKeyAuthentication.url;
1670
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1671
+ requestOptions = auth_JWTAuthentication.requestOptions;
1672
+ url = auth_JWTAuthentication.url;
1673
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1674
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1675
+ url = auth_JWTHttpHeaderAuthentication.url;
1676
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1677
+ requestOptions = auth_OAuth2.requestOptions;
1678
+ url = auth_OAuth2.url;
1679
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1680
+ requestOptions = authDefault.requestOptions;
1681
+ url = authDefault.url;
1682
+ if (localVarFormParams) {
1683
+ delete requestOptions.headers['Content-Type'];
1684
+ if (localVarFormParams instanceof FormData) {
1685
+ // FormData: fetch will handle Content-Type automatically.
1686
+ requestOptions.body = localVarFormParams;
1687
+ }
1688
+ else if (Object.keys(localVarFormParams).length > 0) {
1689
+ // URL-encoded form
1690
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1691
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1675
1692
  }
1676
- return new Promise((resolve, reject) => {
1677
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1678
- if (error) {
1679
- reject(error);
1680
- }
1681
- else {
1682
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
1683
- if (typeof body.success === 'boolean' && !body.success) {
1684
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1685
- reject(new Error(body.error || errString));
1686
- }
1687
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1688
- resolve(body);
1689
- }
1690
- else {
1691
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1692
- reject(errString);
1693
- }
1694
- }
1695
- });
1696
- });
1697
- });
1693
+ }
1694
+ const response = await fetch(url, requestOptions);
1695
+ return this.handleResponse(response, 'GenericApiResponse');
1698
1696
  }
1699
1697
  /**
1700
1698
  * Returns performance characteristics for a custom DSP block (needs `hasTfliteImplementation`). Updates are streamed over the websocket API (or can be retrieved through the /stdout endpoint). Use getProfileTfliteJobResult to get the results when the job is completed.
@@ -1708,9 +1706,11 @@ class DSPApi {
1708
1706
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
1709
1707
  .replace('{' + 'dspId' + '}', encodeURIComponent(String(dspId)));
1710
1708
  let localVarQueryParameters = {};
1711
- let localVarHeaderParams = Object.assign({
1712
- 'User-Agent': 'edgeimpulse-api nodejs'
1713
- }, this.defaultHeaders);
1709
+ let localVarHeaderParams = {
1710
+ 'User-Agent': 'edgeimpulse-api nodejs',
1711
+ 'Content-Type': 'application/json',
1712
+ ...this.defaultHeaders,
1713
+ };
1714
1714
  const produces = ['application/json'];
1715
1715
  // give precedence to 'application/json'
1716
1716
  if (produces.indexOf('application/json') >= 0) {
@@ -1719,7 +1719,7 @@ class DSPApi {
1719
1719
  else {
1720
1720
  localVarHeaderParams.Accept = produces.join(',');
1721
1721
  }
1722
- let localVarFormParams = {};
1722
+ let localVarFormParams;
1723
1723
  // verify required parameter 'projectId' is not null or undefined
1724
1724
  if (projectId === null || projectId === undefined) {
1725
1725
  throw new Error('Required parameter projectId was null or undefined when calling startProfileCustomDspBlock.');
@@ -1732,56 +1732,52 @@ class DSPApi {
1732
1732
  if (dspRunRequestWithoutFeaturesReadOnly === null || dspRunRequestWithoutFeaturesReadOnly === undefined) {
1733
1733
  throw new Error('Required parameter dspRunRequestWithoutFeaturesReadOnly was null or undefined when calling startProfileCustomDspBlock.');
1734
1734
  }
1735
- Object.assign(localVarHeaderParams, options.headers);
1736
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1737
- let localVarUseFormData = false;
1735
+ localVarHeaderParams = {
1736
+ ...localVarHeaderParams,
1737
+ ...options.headers,
1738
+ ...this.opts.extraHeaders,
1739
+ };
1740
+ const queryString = Object.entries(localVarQueryParameters)
1741
+ .filter(([, value]) => value !== undefined)
1742
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1743
+ .join('&');
1744
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1738
1745
  let localVarRequestOptions = {
1739
1746
  method: 'POST',
1740
- qs: localVarQueryParameters,
1741
- headers: localVarHeaderParams,
1742
- uri: localVarPath,
1743
- useQuerystring: this._useQuerystring,
1744
- agentOptions: { keepAlive: false },
1745
- json: true,
1746
- body: models_1.ObjectSerializer.serialize(dspRunRequestWithoutFeaturesReadOnly, "DspRunRequestWithoutFeaturesReadOnly")
1747
+ headers: { ...localVarHeaderParams },
1747
1748
  };
1748
- let authenticationPromise = Promise.resolve();
1749
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1750
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1751
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1752
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1753
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1754
- return authenticationPromise.then(() => {
1755
- if (Object.keys(localVarFormParams).length) {
1756
- if (localVarUseFormData) {
1757
- localVarRequestOptions.formData = localVarFormParams;
1758
- }
1759
- else {
1760
- localVarRequestOptions.form = localVarFormParams;
1761
- }
1749
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(dspRunRequestWithoutFeaturesReadOnly, "DspRunRequestWithoutFeaturesReadOnly"));
1750
+ let requestOptions = localVarRequestOptions;
1751
+ let url = localVarUrl;
1752
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1753
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1754
+ url = auth_ApiKeyAuthentication.url;
1755
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1756
+ requestOptions = auth_JWTAuthentication.requestOptions;
1757
+ url = auth_JWTAuthentication.url;
1758
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1759
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1760
+ url = auth_JWTHttpHeaderAuthentication.url;
1761
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1762
+ requestOptions = auth_OAuth2.requestOptions;
1763
+ url = auth_OAuth2.url;
1764
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1765
+ requestOptions = authDefault.requestOptions;
1766
+ url = authDefault.url;
1767
+ if (localVarFormParams) {
1768
+ delete requestOptions.headers['Content-Type'];
1769
+ if (localVarFormParams instanceof FormData) {
1770
+ // FormData: fetch will handle Content-Type automatically.
1771
+ requestOptions.body = localVarFormParams;
1762
1772
  }
1763
- return new Promise((resolve, reject) => {
1764
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1765
- if (error) {
1766
- reject(error);
1767
- }
1768
- else {
1769
- body = models_1.ObjectSerializer.deserialize(body, "StartJobResponse");
1770
- if (typeof body.success === 'boolean' && !body.success) {
1771
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1772
- reject(new Error(body.error || errString));
1773
- }
1774
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1775
- resolve(body);
1776
- }
1777
- else {
1778
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1779
- reject(errString);
1780
- }
1781
- }
1782
- });
1783
- });
1784
- });
1773
+ else if (Object.keys(localVarFormParams).length > 0) {
1774
+ // URL-encoded form
1775
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1776
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1777
+ }
1778
+ }
1779
+ const response = await fetch(url, requestOptions);
1780
+ return this.handleResponse(response, 'StartJobResponse');
1785
1781
  }
1786
1782
  }
1787
1783
  exports.DSPApi = DSPApi;